Sgcrabking Mob
Based on game build 714014 | Last updated: 2026-03-08
Overview
The SGcrabking_mob stategraph defines the core behavior of the Crab King mob in DST. It orchestrates state transitions for idle, movement, combat (single-target and area-of-effect spin attacks), diving, drowning, breaking, and flying. It leverages components like combat, locomotor, health, drownable, and lootdropper, and integrates with common state handlers (CommonHandlers) for shared behaviors like sleep, freeze, and electrocute states.
Usage example
This stategraph is applied to a prefab by returning it from the stategraph file (e.g., in the prefab's master_postinit). It is not directly added as a component, but instantiated as the entity's stategraph:
inst.entity:AddStateGraph("crabking_mob")
inst.sg = StateGraph("crabking_mob", ...)
Dependencies & tags
Components used: combat, locomotor, health, drownable, lootdropper
Tags: States use various tags including busy, moving, idle, attack, canrotate, nosleep, nofreeze, noattack, noelectrocute, nomorph, drowning, invisible, spinning, jumping, nointerrupt, nopredict, doing.
Properties
No public properties defined. This file is a stategraph definition, not a component with instance state.
Main functions
AOEAttack(inst, dist, radius, targets)
- Description: Performs an area-of-effect (AOE) attack for the Crab King. Sets
ignorehitrangeon the combat component, finds valid entities in a circle centered offset bydistin the facing direction, and executesDoAttackon each valid target withinradius. Resetsignorehitrangeafterward. - Parameters:
inst(Entity) — The mob instance performing the attack.dist(number) — Offset distance to apply to the attack center along the mob's facing direction.radius(number) — Base radius for AOE hit detection.targets(table or nil) — Optional table to track already-hit targets to prevent duplicates.
- Returns: Nothing.
- Error states: Does not explicitly fail; non-existent or invalid targets in the radius are skipped due to validation checks (
IsValid(),IsInLimbo(),IsDead(),CanTarget()).
Events & listeners
- Listens to:
"onsink"— Triggersdive_pst_waterif drowning conditions are met."attacked"— Initiateshitstate unless already busy, attacking, moving, or electrocuting; handles electrocution viaCommonHandlers.TryElectrocuteOnAttacked."doattack"— Initiatesattackorspin_attackbased on taglargecreatureand target distance; otherwiseattack."locomote"— Synchronizes state with locomotion intent: transitions topremovingwhen starting movement (if not attacking) oridlewhen stopping."death"— Triggersdeathstate unconditionally."animover"— Used in multiple states to transition to next state upon animation completion."hit_ground"— Used inflyingstate to determine transition toflying_pst_landorflying_pst_water."ontimeout"— Used inpremoving,spin_attack,spin_attack_loop,taunt,break_water, andbreak_landto handle timed transitions.
- Pushes: None directly (event pushing is handled via stategraph framework and common handlers).