Sgcarnival Crowkid
Based on game build 714014 | Last updated: 2026-03-08
Overview
The SGcarnival_crowkid state graph defines the complete behavior tree for the Carnival Crowkid NPC. It orchestrates animations, sound playback, and logic flow across various states — including idle, eating snacks, sitting at campfires, reacting to minigame excitement (cheer/boo), reacting to minigame completion, and giving rewards upon gift receipt. It integrates with the locomotor, talker, stackable, minigame_spectator, and common state helpers to produce contextual, dynamic behaviors.
Usage example
This state graph is not added as a component but instantiated automatically by the engine as part of the carnival_crowkid prefab definition. It is invoked internally when the Crowkid entity enters or transitions between behaviors.
-- The state graph is referenced internally by the Crowkid prefab and is not manually instantiated.
-- Example of how it integrates:
-- The prefab `carnival_crowkid` includes:
-- inst:AddStateGraph("carnival_crowkid")
-- inst.sg:GoToState("idle")
Dependencies & tags
Components used: locomotor, talker, stackable, minigame_spectator
Tags added/removed/checks: States may include tags "idle", "canrotate", "talking", "busy", "flight", "game_over". No static tags are added/removed; tags are set per-state via the tags array.
Properties
No public properties are exposed. State memory (inst.sg.statemem) is used internally (e.g., giver, rewards_given, loops) but not intended for external consumption.
Main functions
GoToGameOverState(inst)
- Description: Transitions the Crowkid to the appropriate minigame-over state (
minigame_over_cheerorminigame_over_boo) depending on whether the minigame ended successfully (i.e.,_good_endingistrue). - Parameters:
inst(Entity instance) — the Crowkid entity. - Returns: Nothing.
- Error states: Uses
nilas a safe fallback ifminigame_spectatoror_good_endingare missing.
DropRewards(inst)
- Description: Spawns carnival prize tickets and game tokens at the Crowkid's position and launches them toward the gift-giver if known. Ensures rewards are only given once per interaction.
- Parameters:
inst(Entity instance) — the Crowkid entity. - Returns: Nothing.
- Error states: No-op if
rewards_givenis alreadytrue; gracefully handles a missing or invalidgiver.
GetEatSnackState(inst)
- Description: Returns the appropriate state name (
"eat_popcorn"or"eat_corntea") based on the Crowkid'shas_snackfield, ornilif no snack is held. - Parameters:
inst(Entity instance) — the Crowkid entity. - Returns: String (
"eat_popcorn","eat_corntea") ornil. - Error states: Assumes
inst.has_snackis a string; returnsnilif it is missing or unexpected.
Events & listeners
- Listens to:
locomote— viaCommonHandlers.OnLocomote(true, true)minigame_spectator_start_outro— triggers transition to game-over stateontalk— initiates talk animation if idle, depending on minigame presenceanimoverandanimqueueover— used across multiple states to return toidleor loop animations
- Pushes:
- No events are explicitly pushed by this state graph. It responds to external events but does not fire its own.