Buzzardbrain
Based on game build 714014 | Last updated: 2026-03-03
Overview
Buzzardbrain implements the behavior tree for buzzard entities in DST. Its primary responsibility is to guide buzzard movement and interaction: seeking and consuming placed food (e.g., corpses), defending food when attacked, and fleeing threats or fire depending on mutation state. Regular buzzards (non-mutated) prioritize food they can see and aggressively defend it; mutated buzzards (tagged lunar_aligned) do not consume food but instead actively seek corpses to defend and attack non-mutated intruders. The brain integrates with the combat, health, burnable, and locomotor components, and uses custom behavior nodes (StandAndAttack, Wander, Leash) to drive state transitions.
Usage example
local inst = CreateEntity()
inst:AddComponent("brain")
inst.components.brain:SetBrainClass("buzzardbrain")
-- Additional setup (tags, combat, health, etc.) handled by prefab definition
Dependencies & tags
Components used: combat, health, burnable, locomotor
Tags checked: buzzard, lunar_aligned, player, monster, scarytoprey, notarget, playerghost, creaturecorpse, NOCLICK, NOINTERACT, INLIMBO, outofreach, edible_omni, edible_meat, edible_veggie, edible_insect, edible_fruit, edible_mushroom
Tags added: None
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
corpse | entity or nil | nil | Reference to the current corpse being eaten/defended. |
corpse_time | number | GetTime() | Timestamp of last corpse abandonment; used for mutation-based flight logic. |
threat | boolean or entity | false | Cached threat: false = untested, nil = none found, entity = threat found. |
shouldGoAway | boolean | false | Flag indicating the buzzard should flee. |
_on_corpse_ignite | function | nil | Event handler attached to the corpse's onignite. |
_on_corpse_chomped | function | nil | Event handler attached to the corpse's chomped. |
Main functions
OwnCorpse(corpse)
- Description: Claims a corpse for consumption or defense. Registers event listeners for
onigniteandchompedevents on the corpse. Ensures only a limited number of buzzards (based on corpse size) can claim the same corpse. - Parameters:
corpse(entity) — The corpse entity to claim. - Returns: Nothing.
- Error states: Does nothing if the corpse is already fully occupied by the configured max owners.
LoseCorpseOwnership()
- Description: Releases ownership of the current corpse, removes event listeners, and resets internal state. Updates
corpse_time. - Parameters: None.
- Returns: Nothing.
ShouldIgnoreCorpse(corpse)
- Description: Determines if this buzzard should be prevented from eating the given corpse due to max-occupancy limits.
- Parameters:
corpse(entity) — The corpse entity to check. - Returns:
trueif this buzzard should ignore the corpse;falseotherwise. - Error states: None. Uses global
ignorethesetable andSIZE_TO_NUM_OWNERSmapping.
FindCorpse()
- Description: Searches for a valid corpse within range. If found, calls
OwnCorpse; otherwise, callsLoseCorpseOwnership. - Parameters: None.
- Returns:
trueif a corpse was found and claimed;falseotherwise. - Error states: None. Validity includes burning checks for non-mutated buzzards.
IsCorpseValid()
- Description: Checks if the currently owned corpse (
self.corpse) is still valid for consumption/defense. - Parameters: None.
- Returns:
trueif the corpse is valid;falseotherwise. - Error states: Returns
falseifself.corpseisnilor invalid.
GetCorpsePosition()
- Description: Returns the position of the current valid corpse, or
nilif none. - Parameters: None.
- Returns:
{x, y, z}(position vector) ornil.
FindThreat()
- Description: Finds a nearby threat within
SEE_THREAT_DIST(shorter for mutated buzzards). Uses caching via thethreatproperty to avoid recomputation. - Parameters: None.
- Returns: Entity (threat) or
nil. - Error states: None.
IsThreatened()
- Description: Determines if the buzzard is currently threatened (i.e., a threat exists and the stategraph is not busy).
- Parameters: None.
- Returns: Entity (threat) or
nil. - Error states: Returns
nilif the buzzard is in a busy state (sleeping,busy,flight).
DealWithThreat()
- Description: Handles threat response: if near food/corpse, attempts to defend (via
combat:SetTargetorcombat:SuggestTarget); if threat is unreachable or no food present, setsshouldGoAwayto flee. - Parameters: None.
- Returns:
trueif the buzzard engaged the threat or is defending;falseif it failed to engage (e.g., threat already targeted by another buzzard in mutated case). - Error states: Returns
falseonly for mutated buzzards ifcombat:SuggestTargetfails.
DoUpdate()
- Description: Called during behavior tree updates to refresh internal caches.
- Parameters: None.
- Returns: Nothing.
OnStart()
- Description: Initializes the behavior tree root node with priority-based conditional logic: fleeing fire/threats, defending food, eating, wandering, and leashing to corpse. Sets up mutated vs non-mutated branching.
- Parameters: None.
- Returns: Nothing.
- Error states: None. Behavior tree built using
PriorityNode,WhileNode,IfNode, and action nodes (StandAndAttack,Wander,Leash,FaceEntity,DoAction,ActionNode).
OnStop()
- Description: Releases corpse ownership and cleans up event listeners.
- Parameters: None.
- Returns: Nothing.
Events & listeners
- Listens to:
onigniteon the currentcorpse: Suggests the igniting entity as a combat target if valid.chompedon the currentcorpse: Sets the chomping entity as a combat target if valid (aggressive against non-mutated buzzards for regular buzzards; against non-mutated entities for mutated buzzards).
- Pushes:
corpse_eat— emitted immediately when the buzzard faces and begins eating a valid corpse (duringchompnode execution).locomote— emitted bylocomotor:Stop()(viaOnStop,DealWithThreat,EatFoodAction, etc.).