Sgknight
Based on game build 714014 | Last updated: 2026-03-08
Overview
SGknight is the stategraph for the Yoth Knight boss entity in DST. It governs all combat, movement, and environmental states including idle, taunting, jousting (high-speed collision-based attacks), hitting, stunning, and death. It integrates with the combat, health, locomotor, and sleeper components to coordinate animations, physics, and AI behavior. The jousting mechanic uses custom hit detection via DoJoustAoe, which evaluates lance trajectory and platform boundaries to determine collisions and attacks.
Usage example
The stategraph is automatically used by the clockwork_knight prefab during its initialization. Modders typically do not instantiate this stategraph directly. Instead, they may extend or override its states by:
- Adding custom states to the
statesarray before the finalreturncall. - Patching event handlers (e.g., for
doattackordojoust) viaStateGraph:ReplaceState. Example for reference:
-- Not applicable for direct instantiation
-- SGknight is automatically invoked by the Yoth Knight prefab
Dependencies & tags
Components used:
combat— for attack scheduling, cooldowns, target tracking, andDoAttackhealth— forIsDeadcheckslocomotor— for movement control and speed multipliersleeper— for sleep/wake transitions
Tags added/removed:
- Added states:
idle,canrotate,busy,jousting,jumping,hit,attack,stunned,nosleep,noelectrocute,caninterrupt,caninterrupt - Tags like
busy,jousting,jumping,stunned,nosleep, andnoelectrocuteare dynamically added/removed during state transitions.
Properties
No public properties are defined in this stategraph. It exclusively defines states and events; data is stored in inst.sg.statemem, inst.sg.mem, or inst.sg.lasttags (e.g., statemem.dir, mem.stunhits, lasttags["stunned"]).
Main functions
This file is a StateGraph definition, not a component class, so it exposes no public methods. It defines:
- A list of
stateswithonenter,onupdate,ontimeout,onexit,timeline, andevents. - A list of
eventsthat respond to global events (e.g.,doattack,dojoust,despawn). It is exported viareturn StateGraph("knight", states, events, "idle").
Events & listeners
Listens to (via EventHandler):
animover— triggers state transitions after animations completedoattack— transitions toattackstate (unlessbusyor dead)dojoust— initiates jousting toward a targetdespawn— initiatesdespawnsequencespawned— initiatesspawnedsequencedoattack(inhitstate) — buffers or executes attack post-hitdojoust(inhitstate) — buffers or executes joust post-hitjoust_collide— transitions tojoust_collidestate on lance impactgotosleep/wake— handled viaCommonHandlers.OnSleepEx()andCommonHandlers.OnWakeEx()OnHop()— handles boat/platform hoppingOnLocomote,OnSink,OnFallInVoid,OnFreeze,OnElectrocute,OnAttacked,OnDeath— handled viaCommonHandlers.*
Pushes (via inst:PushEvent):
locomote— viaLocoMotor:Stop()gotosleep— when first entering sleepknockback— targets knocked back during joustjoust_collide— triggered on joust impact (self or opponent)