stategraphs/SGwilson.lua
337338339340341342343
function(inst, data)
inst.sg:GoToState("toolbroke", data.tool)
end),
EventHandler("armorbroke",
function(inst, data)
inst.sg:GoToState("armorbroke", data.armor)
337338339340341342343344345346347348349350351352353354355
function(inst, data)
inst.sg:GoToState("toolbroke", data.tool)
end),
EventHandler("torchranout",
function(inst, data)
if not inst.components.inventory:IsItemEquipped(data.torch) then
local sameTool = inst.components.inventory:FindItem(function(item)
return item.prefab == data.torch.prefab
end)
if sameTool then
inst.components.inventory:Equip(sameTool)
end
end
end),
EventHandler("armorbroke",
function(inst, data)
inst.sg:GoToState("armorbroke", data.armor)
661662663664665666
events=
{
EventHandler("animover", function(inst) inst.sg:GoToState("chop") end),
},
},
673674675676677678679
events=
{
EventHandler("unequip", function(inst) inst.sg:GoToState("idle") end ),
EventHandler("animover", function(inst) inst.sg:GoToState("chop") end),
},
},
735736737738739740
events=
{
EventHandler("animover", function(inst)
--inst.AnimState:PlayAnimation("chop_pst")
inst.sg:GoToState("idle")
748749750751752753754
events=
{
EventHandler("unequip", function(inst) inst.sg:GoToState("idle") end ),
EventHandler("animover", function(inst)
--inst.AnimState:PlayAnimation("chop_pst")
inst.sg:GoToState("idle")
753754755756757758
events=
{
EventHandler("animover", function(inst) inst.sg:GoToState("mine") end),
},
},
767768769770771772773
events=
{
EventHandler("unequip", function(inst) inst.sg:GoToState("idle") end ),
EventHandler("animover", function(inst) inst.sg:GoToState("mine") end),
},
},
768769770771772773
timeline=
{
TimeEvent(9*FRAMES, function(inst)
inst:PerformBufferedAction()
inst.sg:RemoveStateTag("premine")
inst.SoundEmitter:PlaySound("dontstarve/wilson/use_pick_rock")
783784785786787788789790791792
timeline=
{
TimeEvent(9*FRAMES, function(inst)
if inst.sg.statemem.action and inst.sg.statemem.action.target then
local fx = SpawnPrefab("mining_fx")
fx.Transform:SetPosition(inst.sg.statemem.action.target:GetPosition():Get())
end
inst:PerformBufferedAction()
inst.sg:RemoveStateTag("premine")
inst.SoundEmitter:PlaySound("dontstarve/wilson/use_pick_rock")
789790791792793794
events=
{
EventHandler("animover", function(inst)
inst.AnimState:PlayAnimation("pickaxe_pst")
inst.sg:GoToState("idle", true)
808809810811812813814
events=
{
EventHandler("unequip", function(inst) inst.sg:GoToState("idle") end ),
EventHandler("animover", function(inst)
inst.AnimState:PlayAnimation("pickaxe_pst")
inst.sg:GoToState("idle", true)
828829830831832833834835836837838
end),
TimeEvent(14*FRAMES, function(inst)
if (TheInput:IsControlPressed(CONTROL_PRIMARY) or
TheInput:IsControlPressed(CONTROL_ACTION) or TheInput:IsControlPressed(CONTROL_CONTROLLER_ACTION)) and
inst.sg.statemem.action and
inst.sg.statemem.action.target and
inst.sg.statemem.action.target:IsActionValid(inst.sg.statemem.action.action) and
inst.sg.statemem.action.target.components.workable then
inst:ClearBufferedAction()
inst:PushBufferedAction(inst.sg.statemem.action)
848849850851852853854855856857858859
end),
TimeEvent(14*FRAMES, function(inst)
if (TheInput:IsControlPressed(CONTROL_SECONDARY) or
TheInput:IsControlPressed(CONTROL_ACTION) or TheInput:IsControlPressed(CONTROL_CONTROLLER_ALTACTION)) and
inst.sg.statemem.action and
inst.sg.statemem.action.target and
inst.sg.statemem.action.target:IsActionValid(inst.sg.statemem.action.action, true) and
inst.sg.statemem.action.target.components.workable then
inst:ClearBufferedAction()
inst:PushBufferedAction(inst.sg.statemem.action)
843844845846847848
events=
{
EventHandler("animover", function(inst)
inst.AnimState:PlayAnimation("pickaxe_pst")
inst.sg:GoToState("idle", true)
864865866867868869870
events=
{
EventHandler("unequip", function(inst) inst.sg:GoToState("idle") end ),
EventHandler("animover", function(inst)
inst.AnimState:PlayAnimation("pickaxe_pst")
inst.sg:GoToState("idle", true)
986987988989990991
events=
{
EventHandler("animover", function(inst) inst.sg:GoToState("dig") end),
},
},
1008100910101011101210131014
events=
{
EventHandler("unequip", function(inst) inst.sg:GoToState("idle") end ),
EventHandler("animover", function(inst) inst.sg:GoToState("dig") end),
},
},
100110021003100410051006100710081009
timeline=
{
TimeEvent(15*FRAMES, function(inst)
inst:PerformBufferedAction()
inst.sg:RemoveStateTag("predig")
inst.SoundEmitter:PlaySound("dontstarve/wilson/dig")
end),
TimeEvent(35*FRAMES, function(inst)
102410251026102710281029103010311032103310341035103610371038
timeline=
{
TimeEvent(15*FRAMES, function(inst)
--[[ if inst.sg.statemem.action and inst.sg.statemem.action.target then
local fx = SpawnPrefab("shovel_dirt")
fx.Transform:SetPosition( inst.sg.statemem.action.target.Transform:GetWorldPosition() )
end
--]]
inst:PerformBufferedAction()
inst.sg:RemoveStateTag("predig")
inst.SoundEmitter:PlaySound("dontstarve/wilson/dig")
end),
TimeEvent(35*FRAMES, function(inst)
102210231024102510261027
events=
{
EventHandler("animover", function(inst)
inst.AnimState:PlayAnimation("shovel_pst")
inst.sg:GoToState("idle", true)
1051105210531054105510561057
events=
{
EventHandler("unequip", function(inst) inst.sg:GoToState("idle") end ),
EventHandler("animover", function(inst)
inst.AnimState:PlayAnimation("shovel_pst")
inst.sg:GoToState("idle", true)
17001701170217031704170517061707170817091710171117121713171417151716
inst.AnimState:Show("ARM_carry")
inst.AnimState:Hide("ARM_normal")
end
end,
timeline=
{
TimeEvent(58*FRAMES, function(inst)
inst.SoundEmitter:PlaySound("dontstarve/common/book_spell")
local fx = SpawnPrefab("pine_needles")
fx.Transform:SetPosition( inst.Transform:GetWorldPosition() )
inst:PerformBufferedAction()
end),
},
173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759
inst.AnimState:Show("ARM_carry")
inst.AnimState:Hide("ARM_normal")
end
if inst.sg.statemem.book_fx then
inst.sg.statemem.book_fx:Remove()
inst.sg.statemem.book_fx = nil
end
end,
timeline=
{
TimeEvent(0, function(inst)
local fxtoplay = "book_fx"
if inst.prefab == "waxwell" then
fxtoplay = "waxwell_book_fx"
end
local fx = SpawnPrefab(fxtoplay)
local pos = inst:GetPosition()
fx.Transform:SetRotation(inst.Transform:GetRotation())
fx.Transform:SetPosition( pos.x, pos.y - .2, pos.z )
inst.sg.statemem.book_fx = fx
end),
TimeEvent(58*FRAMES, function(inst)
inst.SoundEmitter:PlaySound("dontstarve/common/book_spell")
inst:PerformBufferedAction()
inst.sg.statemem.book_fx = nil
end),
},
1772177317741775177617771778
if inst.components.combat.target then
if inst.components.combat.target and inst.components.combat.target:IsValid() then
inst:FacePoint(Vector3(inst.components.combat.target.Transform:GetWorldPosition()))
end
end
1815181618171818181918201821
if inst.components.combat.target then
if inst.components.combat.target and inst.components.combat.target:IsValid() then
inst:FacePoint(inst.components.combat.target.Transform:GetWorldPosition())
end
end