Shadow Leechbrain
Based on game build 714014 | Last updated: 2026-02-27
Overview
The Shadow_LeechBrain component defines the behavior tree for the Shadow Leech entity in Don't Starve Together. It enables the leech to pursue and launch physical attacks against the daywalker entity when within range, while falling back to leash-following, orientation toward the target, and eventually wandering when no valid target is present. This component depends on the EntityTracker component to locate the target and integrates several custom behaviors (Leash, FaceEntity, Wander) to orchestrate movement and combat logic.
Usage example
Typically, this brain is assigned to a Shadow Leech entity during its construction, and no additional manual setup is required:
inst:AddBrain("shadow_leechbrain")
The component initializes automatically when added, registering the behavior tree root node. It responds to the "jump" event internally and emits "incoming_jump" to the target upon launch.
Dependencies & tags
Components used:
entitytracker: Used viainst.components.entitytracker:GetEntity("daywalker")to retrieve the target entity.
Tags: None identified.
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
inst | GameObject | N/A | Reference to the entity instance this brain controls. |
bt | BehaviorTree | nil | Initialized in OnStart(); holds the active behavior tree instance. |
Main functions
OnStart()
- Description: Initializes and assigns the root behavior tree node for the Shadow Leech. Constructs a priority-based behavior tree that evaluates whether to jump, leash to the target, face it, or wander.
- Parameters: None.
- Returns: None.
- Error states: If the
entitytrackercomponent is missing or does not contain a"daywalker"entry,GetTarget()returnsnil, causingLeash,FaceEntity, andJumpactions to effectively no-op or fall through toWander.
GetTarget(inst)
- Description: Retrieves the target entity named
"daywalker"from theentitytrackercomponent. - Parameters:
inst: The entity instance (typicallyself.instin the brain).
- Returns:
GameObject?— The target entity if present and valid; otherwisenil.
GetTargetPos(inst)
- Description: Returns the world position of the
"daywalker"target, ornilif the target is absent. - Parameters:
inst: The entity instance.
- Returns:
Vector3?— World position of the target ornil.
KeepTarget(inst, target)
- Description: Guard function that returns
trueif the target entity is still valid. - Parameters:
inst: The entity instance.target: The candidate target entity.
- Returns:
boolean—trueiftarget:IsValid()holds.
ShouldJump(inst)
- Description: Determines whether the Shadow Leech is close enough to the target to initiate a jump.
- Parameters:
inst: The entity instance.
- Returns:
boolean—trueif the distance to the target is<= JUMP_DIST(6 units), otherwisefalse.
Events & listeners
- Listens to: None.
- Pushes:
"jump": Fired when the leech initiates a jump toward the target (only if target is valid)."incoming_jump": Fired on the target entity when the leech is about to jump onto it.
Note: This brain itself does not register event listeners. Event emission occurs within the behavior tree's action node during jump execution.