Shadow Knightbrain
Based on game build 714014 | Last updated: 2026-03-03
Overview
Shadow_KnightBrain implements the AI logic for the Shadow Knight entity using a behavior tree (BT) built from common DST behavior components. It manages combat engagement (chasing and attacking when no target is active), evasive dodging (run away) when a target is locked on and attacking, facing the nearest player for visual alignment, and autonomous wandering while waiting for a timer to trigger a despawn event. This brain relies heavily on the combat and health components for real-time state evaluation.
Usage example
local inst = CreateEntity()
inst:AddTag("shadowknight")
inst:AddComponent("combat")
inst:AddComponent("health")
inst:AddBrain("shadow_knightbrain")
Dependencies & tags
Components used: combat, health
Tags: Checks notarget, playerghost on potential targets; no tags added or removed by this component itself.
Properties
No public properties.
Main functions
OnStart()
- Description: Initializes the behavior tree root node with a priority structure. The tree evaluates combat state to decide between attacking (via
ChaseAndAttack), dodging (viaRunAway), facing a nearby player (viaFaceEntity), and performing concurrent wandering with a timed despawn action. - Parameters: None.
- Returns: Nothing.
- Error states: None identified. Requires
self.inst.components.combatandself.inst.components.healthto be present for correct node evaluation.
Events & listeners
- Listens to: None.
- Pushes:
despawn— fired when the timed despawn counter reachesTUNING.SHADOW_CHESSPIECE_DESPAWN_TIMEvia anActionNodein the behavior tree.