AddStategraphPostInit("wilson", function(sg)
local state = sg.states["play_flute"]
local old_onenter = state.onenter

state.onenter = function(inst)
local bufaction = inst:GetBufferedAction()
local is_flame_play =
bufaction
and bufaction.action == GLOBAL.ACTIONS.PLAY
and bufaction.invobject
and bufaction.invobject:HasTag("flute_flame")

if is_flame_play then
	inst.components.locomotor:Stop()
	inst.AnimState:PlayAnimation("flute")
	inst.AnimState:OverrideSymbol("pan_flute01", "flute_flame", "pan_flute")
	inst.AnimState:Hide("ARM_carry") 
	inst.AnimState:Show("ARM_normal")
	
if inst.components.inventory.activeitem and inst.components.inventory.activeitem.components.instrument then
	inst.components.inventory:ReturnActiveItem()
	end
else
old_onenter(inst)
	end
end
end)

AddStategraphPostInit("wilson", function(sg)
local state = sg.states["play_flute"]
local old_onenter = state.onenter

state.onenter = function(inst)
local bufaction = inst:GetBufferedAction()
local is_frost_play =
bufaction
and bufaction.action == GLOBAL.ACTIONS.PLAY
and bufaction.invobject
and bufaction.invobject:HasTag("flute_frost")

if is_frost_play then
	inst.components.locomotor:Stop()
	inst.AnimState:PlayAnimation("flute")
	inst.AnimState:OverrideSymbol("pan_flute01", "flute_frost", "pan_flute")
	inst.AnimState:Hide("ARM_carry") 
	inst.AnimState:Show("ARM_normal")
	
if inst.components.inventory.activeitem and inst.components.inventory.activeitem.components.instrument then
	inst.components.inventory:ReturnActiveItem()
	end
else
old_onenter(inst)
	end
end
end)

AddStategraphPostInit("wilson", function(sg)
local state = sg.states["play_horn"]
local old_onenter = state.onenter

state.onenter = function(inst)
local bufaction = inst:GetBufferedAction()
local is_healing_play =
bufaction
and bufaction.action == GLOBAL.ACTIONS.PLAY
and bufaction.invobject
and bufaction.invobject:HasTag("flute_healing")

if is_healing_play then
	inst.components.locomotor:Stop()
	inst.AnimState:PlayAnimation("horn")
	inst.AnimState:OverrideSymbol("horn01", "flute_healing", "horn")
	inst.AnimState:Hide("ARM_carry") 
	inst.AnimState:Show("ARM_normal")
	
if inst.components.inventory.activeitem and inst.components.inventory.activeitem.components.instrument then
	inst.components.inventory:ReturnActiveItem()
	end
else
old_onenter(inst)
	end
end
end)