Sgcookiecutter
Based on game build 714014 | Last updated: 2026-03-08
Overview
SGcookiecutter is the stategraph for the Cookiecutter entity — a mobile, boat-drilling predator in DST. It defines a complete finite state machine (FSM) that orchestrates movement (walking, swimming, jumping, running), boat drilling (with associated animations and particle effects), combat (via area attacks), and environmental responses (electrocution, sinking, death on land vs. water). It relies heavily on components like locomotor, health, combat, cookiecutterdrill, lootdropper, and boatphysics, and dynamically adjusts animation layer and physics collision masks based on whether the entity is in water or on land/boat.
Usage example
The SGcookiecutter stategraph is not instantiated manually — it is automatically loaded and attached to the Cookiecutter prefab during entity creation. A modder would reference it indirectly by customizing behavior via components or extending the state machine via common state helpers such as CommonStates.AddSleepStates and CommonStates.AddElectrocuteStates.
-- This stategraph is referenced internally by the Cookiecutter prefab.
-- Example of how it is exported:
return StateGraph("cookiecutter", states, events, "resurface", actionhandlers)
Dependencies & tags
Components used:
boatphysics: readsvelocity_x,velocity_zto calculate boat-relative positions during resurfacing.combat: callsDoAreaAttackfor jumping and drilling hit attacks.cookiecutterdrill: callsResetDrilling,ResumeDrilling,PauseDrilling,FinishDrilling,GetIsDoneDrilling.eater: readslasteattimeand writes to it during post-drill.health: checksIsDead, and modifiesinvincible.locomotor: usesWalkForward,RunForward,Stop,StopMoving,Clear, andwalkspeed.lootdropper: callsDropLooton death.
Tags: Adds/Removes NOCLICK, moving, running, busy, idle, drilling, drilling_pst, jumping, nointerrupt, noattack, nosleep, sleeping, electrocute (via CommonStates.AddElectrocuteStates). Checks swimming, noattack, nointerrupt, etc., during state transitions.
Properties
No public properties — this is a stategraph definition, not a component.
Main functions
This file exports a single StateGraph constructor call and defines internal state behavior via state tables and event handlers. No standalone functions are exported.
State handlers (internal)
The following are not exported functions but core logic sections embedded in the state definitions.
SetInvincible(inst, invincible)
- Description: Sets the
invincibleproperty on thehealthcomponent if present and the entity is alive. Used during states likerun_startto grant temporary invincibility. - Parameters:
inst(Entity instance),invincible(boolean). - Returns: Nothing.
SetSortOrderIsInWater(inst, in_water)
- Description: Updates sort order and layer for rendering and collision based on whether the entity is in water (
true) or on land/boat (false). Activates ground collision mask on water entry and restores full mask on exit. - Parameters:
inst(Entity instance),in_water(boolean). - Returns: Nothing.
UpdateWalkSpeedAndHopping(inst)
- Description: Dynamically sets
walkspeedin thelocomotorcomponent based on the validity ofinst.target_wood. If valid, usesAPPROACH_SPEED; otherwise, usesWANDER_SPEED. Called on every update in movement states. - Parameters:
inst(Entity instance). - Returns: Nothing.
State definitions (selected highlights)
"idle"
- Description: Default state when the entity is not moving. Initiates a looping
idleanimation and stops physics. Forces the entity into water (in_water = true) and lowers render layer.
"resurface"
- Description: Handles transition from underwater to surface. Sets
NOCLICK, playsresurfaceanim, repositions ifshould_relocateviaFindSwimmableOffset. Timeline removesNOCLICKand state tags mid-anim. Onanimover, returns toidle.
"gohome"
- Description: Initiates return home (
inst:DoReturnHome()). Playsleaveanimation and goes home onanimover.
"death" / "death_boat"
- Description: Handles entity death.
deathoccurs while in water (render layer set below ground),death_boatoccurs on land (physics collision removed). Both callDropLoot.
"walk" / "walk_start" / "walk_stop"
- Description: Standard walking states with walk-speed locomotion.
walkloops animation and renews timeout to continue walking.walk_startandwalk_stoptransition into and out of looping walk.
"run" / "run_start" / "run_stop"
- Description: High-speed movement states with invincibility via
SetInvincible(true), tagged asrunning,noattack,nosleep,nointerrupt.run_stoptransitions toidlevia timeline after animation.
"eat"
- Description: Transition state that immediately jumps to
"jump_pre"with optional target point.
"jump_pre" → "jumping" → "jump_pst_water" or "jump_pst_boat"
- Description: Handles jumping out of water and landing either in water or on a boat. During
"jumping", collision mask is changed toGROUND,DoAreaAttackis called once, and final landing determines whether"jump_pst_water"or"jump_pst_boat"is entered."jump_pst_boat"automatically triggers"drill"upon exit.
"drill"
- Description: Boat-drilling state. Repeats animation, spawns fluff particles (by wood material: grass/kelp), and starts drilling via
cookiecutterdrill:ResumeDrilling.onupdatechecksGetIsDoneDrillingto exit early. On exit,cookiecutterdrill:PauseDrillingis called and particles tasks are cancelled.
"drill_pst"
- Description: Post-drill cooldown. Sets
NOCLICK, stops physics, playsdrill_pstanim. Timeline callsFinishDrillingand setslasteattime. After timeout, goes to"resurface".
"drill_hit"
- Description: Triggered on attack interruption while drilling. Plays
hitanim, fires area attack viaDoAreaAttack, and returns to"drill"onanimqueueover.
Events & listeners
-
Listens to:
attacked— reacts based on state and water condition: flee (if in water, go toidle) or transition todrill_hit.onsink— if not dead and not already jumping/drilling/electrocuting, goes todrill_pstorgohome.gohome— defers or immediately transitions togohome.death— transitions todeathordeath_boatdepending on water state.gotosleep— if swimming and not interrupted, transitions tosleeporsleeping.teleported— on teleport, goes tojump_pst_water.OnLocomote— handled byCommonHandlers.OnLocomote(true, true); monitors movement changes.animover,animqueueover,ontimeout— used for state transitions (e.g.,"animover"moves toidle,"animqueueover"returns to"drill").
-
Pushes: No events are directly pushed by this stategraph.