Lunar Grazer Brain
Based on game build 714014 | Last updated: 2026-02-27
Overview
This brain component defines the behavior tree logic for the Lunar Grazer entity, a hostile mob in Don't Starve Together. It dynamically selects behaviors depending on combat readiness (cooldown), target state (sleeping vs awake), and entity condition (e.g., debris protection). It orchestrates core behaviors like ChaseAndAttack, Leash (for stalling/stalking), Wander, and conditional despawn logic. The brain integrates with several components—combat, health, grogginess, sleeper, and knownlocations—to determine state transitions and act accordingly.
Dependencies & Tags
-
Components used:
combat: accessesHasTarget(),InCooldown(), andtargetproperty.health: accessesIsHurt().grogginess: accessesIsKnockedOut()(viaSleepCheckhelper).sleeper: accessesIsAsleep()(viaSleepCheckhelper).knownlocations: accessesGetLocation("spawnpoint").
-
Tags checked via stategraph (
inst.sg):"debris": triggers respawn behavior."invisible": skips awake behavior."knockout": indirectly checked viaIsKnockedOut()(used for sleeping target detection).
Properties
No public properties are explicitly initialized in the constructor. Behavior configuration is embedded in the behavior tree construction within OnStart().
Main Functions
LunarGrazerBrain:OnStart()
- Description: Constructs and assigns the root behavior tree for the Lunar Grazer. This function is called automatically by the brain framework when the entity spawns or the brain is initialized.
- Parameters: None.
- Returns:
nil(setsself.btinternally).
IsSleeper(target)
- Description: Helper function used internally to determine whether a potential target is capable of sleeping or being knocked out. Used to decide between aggressive vs stalking attack patterns.
- Parameters:
target(Entity): The target entity to inspect.
- Returns:
boolean—trueif the target has either agrogginessorsleepercomponent; otherwisefalse.
SleepCheck(target)
- Description: Checks whether the target is currently in a sleeping or knocked-out state. Excludes entities in the
"dismounting"state when using grogginess. Used to prioritize stealth engagement. - Parameters:
target(Entity): The target entity to inspect.
- Returns:
boolean—trueif the target is knocked out or asleep; otherwisefalse.
DoStalking(inst)
- Description: Computes a target position that positions the Lunar Grazer to the side of its target (strafing motion) when in combat. Used by the
Leashbehavior to maintain ranged combat positioning. - Parameters:
inst(Entity): The Lunar Grazer entity instance.
- Returns:
Vector3— A world position (x, 0, z) at which the Lunar Grazer should move to maintain stalker-like positioning. Returnsnilif there is no current combat target.
GetTargetPos(inst)
- Description: Helper function to retrieve the current world position of the combat target.
- Parameters:
inst(Entity): The Lunar Grazer entity instance.
- Returns:
Vector3— The position ofself.inst.components.combat.target.
GetHome(inst)
- Description: Retrieves the spawn point location (used for patrol/despawn logic).
- Parameters:
inst(Entity): The Lunar Grazer entity instance.
- Returns:
Vector3?— The stored "spawnpoint" location fromknownlocations, ornilif unset.
Events & Listeners
- Listens to: None (no explicit
inst:ListenForEventcalls). - Pushes:
"lunar_grazer_respawn"— Pushed when in debris state and not hurt, to trigger respawn logic."lunar_grazer_despawn"— Pushed when loitering at spawn point for too long without target found.
Note: Event dispatch is handled through inst:PushEvent(...) inside the behavior tree; no additional event handlers are defined in this file.