Sgfused Shadeling
Based on game build 714014 | Last updated: 2026-03-08
Overview
SGfused_shadeling is the stategraph defining the full behavioral lifecycle of the fused_shadeling boss entity. It handles transitions between states such as idle wandering, jumping (with speed decay and knockback), attacking via combat component, getting hit (triggering teleportation), taunting ( interrupting damage immunity), spawning/despawning sequences, and managing temporary invulnerability. It leverages CommonHandlers and CommonStates utilities to integrate standard movement and state transitions, while directly interacting with the combat, health, locomotor, lootdropper, timer, and miasmamanager components during execution.
Usage example
-- Typically added to the fused_shadeling prefab definition in prefabs/fused_shadeling.lua
inst:AddTag("shadeling")
inst:AddComponent("combat")
inst:AddComponent("health")
inst:AddComponent("locomotor")
inst:AddComponent("lootdropper")
inst:AddComponent("timer")
inst:AddComponent("miasmamanager") -- via world component
-- Stategraph is attached at prefab creation time by DST engine
-- Manual state changes are done via:
inst.sg:GoToState("attack", target)
inst.sg:GoToState("hit")
inst.sg:GoToState("jump_pre", target_position)
Dependencies & tags
Components used:
combat(DoAttack,DropTarget,StartAttack,TryAttack,target)health(IsDead)locomotor(Stop,StopMoving,EnableGroundSpeedMultiplier)lootdropper(DropLoot)timer(StartTimer)miasmamanager(GetMiasmaAtPoint,IsMiasmaActiveviaTheWorld.components.miasmamanager)
Tags:
- Added:
idle,canrotate,busy,noattack,jumping,attack,hit,taunt,temp_invincible,invisible - State tags added dynamically:
noattack,temp_invincible,invisible,busy,jumping,attack,hit,taunt - Removed:
noattack,busy,temp_invincible,invisible,NOCLICK(via state transitions)
Properties
No public properties. All state-specific data is stored in inst.sg.mem or inst.sg.statemem.
Main functions
This file defines a StateGraph, not a component class; therefore it returns no callable methods. State behavior is implemented via state entries in the states table and events array. Stategraph entry points are controlled by the engine via inst.sg:GoToState().
CommonHandlers.OnLocomote and OnDeath
- Description: Event handlers provided by
stategraphs/commonstates.luathat automatically transition the entity towalkordeathstates in response to locomotion and health events. - Parameters: None (defined externally).
- Returns: Nothing.
go_to_idle(inst)
- Description: Helper function to transition the entity back to the
idlestate. - Parameters:
inst(EntityInstance) - the shadeling entity instance. - Returns: Nothing.
teleport_test_fn(test_position)
- Description: Predicate function used during teleportation to verify that a candidate position has miasma present.
- Parameters:
test_position(Vector3) - candidate world position. - Returns:
trueifGetMiasmaAtPoint()returns non-nil at that position, elsefalse.
do_teleport(inst)
- Description: Attempts to find a walkable position within a miasma-enabled radius and teleports the shadeling there. Used during hit/teleport transitions.
- Parameters:
inst(EntityInstance) - the shadeling entity instance. - Returns: Nothing.
Events & listeners
-
Listens to:
animover– triggers idle repetition or next transition after animation completes.animqueueover– fires on death state conclusion to remove the entity.doattack– initiates theattackstate if not busy or dead.attacked– triggers thehitstate, possibly followed byteleport_pre(on random chance or lighter weapon hit).try_jump– initiatesjump_prewith provided jump target if not busy.do_despawn– setspersists = false, marksdespawning, and transitions todespawn_pre.locomote– viaCommonHandlers.OnLocomote(not explicitly listed, but implies movement event handling).death– viaCommonHandlers.OnDeath(transition todeath).
-
Pushes:
droppedtarget– viacombat:DropTarget()(only if no next target).doattack– viacombat:DoAttack()during attack timeline.- Events from component interactions (e.g.,
SetPositionby bomb spawner) are not pushed by this stategraph itself.