Sgstalker
Based on game build 714014 | Last updated: 2026-03-08
Overview
SGstalker is the stategraph responsible for controlling the stalker's behavior in Don't Starve Together. It orchestrates transitions between states based on internal flags, incoming events (e.g., attacks, summons, roars), and game state. It handles unique stalker abilities such as spawning shields, summoning minions and channelers, activating mind control, executing taunts, and managing visual/audio effects—including camera shakes, emissive blinking, sound fading, and visual trails. The stategraph integrates with core systems like locomotion, physics, health, entity tracking, and epicscare, and maintains state tags to coordinate interruptibility, busy status, and interaction permissions during complex animations.
Usage example
-- Example: Triggering a roar that may initiate the taunt state
if not inst.sg:HasStateTag("busy") and not inst.sg:HasStateTag("roar") then
inst.sg:GoToState("taunt")
end
-- Example: Setting blink intensity based on threat level
if threat_level > 0.8 then
BlinkHigh(inst)
elseif threat_level > 0.3 then
BlinkMed(inst)
else
BlinkLow(inst)
end
Dependencies & tags
Components used:
CommonHandlers— forOnLocomote,OnSink,OnFallInVoid, andHitRecoveryDelayTUNING.STALKER_HIT_RECOVERY— hit recovery timeout constantTUNING.STALKER_SPEED— walk speed reset constantTUNING.ATRIUM_GATE_DESTABILIZE_DELAY— used in death3_pst timelinelocomotor— used to halt movement (:StopMoving()) in gate statesAnimState— for animation control (:PlayAnimation,:PushAnimation,:AnimDone,:GetCurrentAnimationLength)SoundEmitter— for sound playback and fading (:PlaySound)sg— stategraph interface (:GoToState,:AddStateTag,:RemoveStateTag,:SetTimeout)components.health— to check:IsDead()inflinch_loop,fallapartcomponents.epicscare— for scare effect (:Scare(5)) ineat_loop,mindcontrol_loopcomponents.entitytracker— for retrieving stargate entity (:GetEntity("stargate"))inst.Physics— for stopping physics (:Stop()) in gate statesinst.Transform— for facing control (:SetSixFaced,:SetFourFaced,:ForceFacePoint)
Tags:
INLIMBO,notarget,invisible,noattack,flight,playerghost,shadow,shadowchesspiece,shadowcreature,shadow— part ofAREAATTACK_EXCLUDETAGSbusy,idle,canrotate,moving,hit,attack,snare,spikes,summoning,feasting,roar,movingdeath,delaydeath,caninterrupt,usinggate,flinching,hasshield,attacked,attacker,NOCLICK,skullache,fallapart,mindcontrol- Direct manipulation:
NOCLICKadded indeath{,2,3}_enter, removed onexitbusyadded ineat_loop,eat_pst,mindcontrol_pre,mindcontrol_loop,mindcontrol_pst,flinch,flinch_loop,skullache,fallapart,idle_gate,idle_gate_loop,idle_gate_pst; removed ineat_pst,mindcontrol_pst,idle_gate_pstfeastingadded ineat_loopmindcontroladded inmindcontrol_pre,mindcontrol_loop,mindcontrol_pstflinchadded inflinch,flinch_loopdelaydeathadded inflinch,flinch_loop,skullache,fallapartusinggateadded inidle_gate,idle_gate_loopcaninterruptadded inidle_gate,idle_gate_loop,idle_gate_pstskullacheadded inskullachefallapartadded infallapart
- Instance properties (no direct tag ops):
returntogate,atriumstalker,foreststalker,persists,mindcontrolsoundtask
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
returntogate | boolean | false | Indicates whether the stalker should return to gate behavior |
foreststalker | boolean | false | Determines if visual trail effect should be applied |
atriumstalker | boolean | false | Likely used to distinguish Atrium variant behavior |
persists | boolean | false | Entity persistence flag |
hasshield | boolean | false | Flag indicating active shield state |
wantstoroar | boolean | false | Temporary flag indicating pending roar intent |
wantstoflinch | boolean | false | Temporary flag indicating pending flinch intent |
wantstoskullache | boolean | false | Temporary flag indicating pending skullache intent |
wantstofallapart | boolean | false | Temporary flag indicating pending fallapart intent |
mindcontrolsoundtask | Task | nil | Task handle for sound fade-out scheduling |
Main functions
ShakeIfClose(inst)
- Description: Triggers a full-screen camera shake with parameters tuned for proximity; activated when the stalker is near players.
- Parameters:
inst— the stalker entity instance. - Returns:
nil
ShakeRoar(inst)
- Description: Triggers a stronger and longer full-screen camera shake during roar or taunt actions.
- Parameters:
inst— the stalker entity instance. - Returns:
nil
ShakeSummonRoar(inst)
- Description: Triggers a moderate full-screen camera shake used during minion or channeler summoning roars.
- Parameters:
inst— the stalker entity instance. - Returns:
nil
ShakeSummon(inst)
- Description: Triggers a vertical-only camera shake during minion summoning.
- Parameters:
inst— the stalker entity instance. - Returns:
nil
ShakePound(inst)
- Description: Triggers a vertical-only camera shake during ground-pound attacks (e.g., snare or spikes).
- Parameters:
inst— the stalker entity instance. - Returns:
nil
ShakeMindControl(inst)
- Description: Triggers a strong full-screen camera shake when mind control activates.
- Parameters:
inst— the stalker entity instance. - Returns:
nil
ShakeDeath(inst)
- Description: Triggers a vertical-only camera shake during death animations.
- Parameters:
inst— the stalker entity instance. - Returns:
nil
SetBlinkLevel(inst, level)
- Description: Adjusts the stalker’s emissive tint via
SetAddColourand dynamic light intensity viaSetLightOverride, based on thelevel(0.0 to 1.0). - Parameters:
inst— the stalker entity instance.level— float value from0(off) to1(full intensity).
- Returns:
nil
BlinkHigh(inst)
- Description: Sets the blink level to
1. - Parameters:
inst— the stalker entity instance. - Returns:
nil
BlinkMed(inst)
- Description: Sets the blink level to
0.3. - Parameters:
inst— the stalker entity instance. - Returns:
nil
BlinkLow(inst)
- Description: Sets the blink level to
0.2. - Parameters:
inst— the stalker entity instance. - Returns:
nil
BlinkOff(inst)
- Description: Sets the blink level to
0. - Parameters:
inst— the stalker entity instance. - Returns:
nil
DoTrail(inst)
- Description: Calls
inst:DoTrail()only ifinst.foreststalkeristrue; creates a visual trail effect for forest variant. - Parameters:
inst— the stalker entity instance. - Returns:
nil
PickShield(inst)
- Description: Determines which shield variant (1, 2, 3, or 4) to spawn. Prioritizes main shields (3/4) if cooldown
MAIN_SHIELD_CD = 1.2has elapsed. - Parameters:
inst— the stalker entity instance. - Returns: Integer
1,2,3, or4, ornilif no shield is selected (e.g., shield is still on cooldown). - Error states: Returns
nilsilently on cooldown.
StartMindControlSound(inst)
- Description: Ensures the mind control looping sound is playing; cancels any pending fade-out task and restarts playback if not already playing.
- Parameters:
inst— the stalker entity instance. - Returns:
nil
OnMindControlSoundFaded(inst)
- Description: Called after a 10-second fade-out; resets
mindcontrolsoundtaskand kills the sound. - Parameters:
inst— the stalker entity instance. - Returns:
nil
StopMindControlSound(inst)
- Description: Initiates a 10-second fade-out of the mind control sound (volume ramped to 0) and schedules
OnMindControlSoundFaded. - Parameters:
inst— the stalker entity instance. - Returns:
nil
ShouldReturnToGate(inst)
- Description: Checks if the stalker should return to gate behavior: returns
trueonly ifinst.returntogateistrueand it has no combat target. - Parameters:
inst— the stalker entity instance. - Returns:
boolean—trueif returning to gate is valid;falseotherwise.
Events & listeners
Listened events:
death: transitions to appropriate death state, except those withdelaydeathtag.doattack: if notbusy/dead, transitions toattack.fossilsnare: if notbusy/dead, passesdata.targetstosnare.fossilspikes: if notbusy/dead, transitions tospikes.shadowchannelers: if notbusy/dead, transitions tosummon_channelers_pre.fossilminions: if notbusy/dead, transitions tosummon_minions_pre.fossilfeast: if notbusy/dead, transitions toeat_pre.mindcontrol: if notbusy/dead, transitions tomindcontrol_pre.attacked: handles shield spawn, hit recovery, and interrupt logic; transitions tohitunless blocked. Also decrementsdata.resistineat_loopwhen no shield is present.roar: transitions totauntif possible; otherwise setswantstoroar.flinch: setswantstoflinchand transitions toflinchif possible.skullache: transitions toskullacheimmediately or setswantstoskullache.fallapart: transitions tofallapartimmediately or setswantstofallapart.animover: triggers state transitions when main animation ends ineat_loop,eat_pst,mindcontrol_pre,mindcontrol_loop,flinch,idle_gate,idle_gate_loop,fallapart.animqueueover: triggers transitions when animation queue ends inflinch_loop,skullache.
Pushed events:
- None identified.