Buzzardbrain
Based on game build 714014 | Last updated: 2026-02-27
Overview
The buzzardbrain component implements the decision-making logic for buzzard entities in DST. It controls how buzzards locate and consume food (specifically corpses), defend occupied food when attacked, flee from fire, and respond to nearby threats. The behavior differs between standard buzzards and mutated (lunar-aligned) buzzards: standard buzzards are territorial over food and panic when threatened while idle, whereas mutated buzzards are coordinated, lack panic responses, and do not eat non-corpse food items.
This component uses a Behavior Tree (BT) structure for state management and integrates with the combat, locomotor, health, and burnable components to execute context-aware actions.
Dependencies & Tags
- Components used:
combat:CanTarget,GetAttackRange,GetHitRange,GetLastAttackedTime,HasTarget,InCooldown,SetTarget,SuggestTarget,TargetIshealth:takingfiredamageburnable:IsBurninglocomotor:Stop
- Tags used:
buzzard,edible_omni,edible_meat,edible_veggie,edible_insect,edible_fruit,edible_seeds,edible_fungilunar_aligned,gestaltmutant,player,monster,scarytoprey,notarget,playerghost,NOCLICK,INLIMBO,outofreachcreaturecorpse
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
corpse | Entity or nil | nil | Reference to the corpse currently being eaten. |
corpse_time | Number | GetTime() at start | Timestamp when corpse ownership was lost. Used for mutated buzzard timeout behavior. |
shouldGoAway | Boolean | false | Flag indicating the buzzard should fly away or return home. |
threat | Entity, Boolean, or nil | false | Cached threat entity (nil = none found, false = not yet checked). |
_on_corpse_ignite | Function | nil | Event handler for onignite on the current corpse. |
_on_corpse_chomped | Function | nil | Event handler for chomped on the current corpse. |
bt | BehaviorTree | nil | The active behavior tree instance. |
Main Functions
BuzzardBrain:OwnCorpse(corpse)
- Description: Assigns a corpse to this buzzard as a food source, registers fire/eating event listeners, and updates internal ownership tracking. Prevents over-booking of large corpses by limiting concurrent eaters based on corpse size.
- Parameters:
corpse(Entity): The corpse entity to claim. - Returns: Nothing.
BuzzardBrain:LoseCorpseOwnership()
- Description: Releases ownership of the current corpse, deregisters event listeners, and records the time of loss. This allows other buzzards to claim the corpse later.
- Parameters: None.
- Returns: Nothing.
BuzzardBrain:ShouldIgnoreCorpse(corpse)
- Description: Determines if this buzzard should be prevented from eating a given corpse due to capacity limits. Checks the global
ignorethesetable, which tracks eater counts per corpse. - Parameters:
corpse(Entity): The corpse entity to evaluate. - Returns:
Boolean:trueif the buzzard should skip this corpse; otherwisefalse.
BuzzardBrain:FindCorpse()
- Description: Scans the area for valid corpses using
FindEntity, claims the first valid one viaOwnCorpse, or clears current ownership if none found. - Parameters: None.
- Returns:
Boolean:trueif a corpse was found and claimed;falseotherwise.
BuzzardBrain:IsCorpseValid()
- Description: Validates the currently owned corpse, checking existence, burn status (non-mutated buzzards avoid burning corpses), and ownership limits.
- Parameters: None.
- Returns:
Boolean:trueifself.corpseis valid; otherwisefalse.
BuzzardBrain:GetCorpsePosition()
- Description: Returns the position of the current corpse if valid, or
nil. - Parameters: None.
- Returns:
Vector3?: The world position of the corpse, ornil.
BuzzardBrain:FindThreat()
- Description: Locates the nearest valid threat within the current perception radius, caching the result. Behavior differs for mutated buzzards (shorter detection range, different validity rules).
- Parameters: None.
- Returns:
Entity?: The threat entity, ornilif no threat is found.
BuzzardBrain:IsThreatened()
- Description: Checks if a threat exists and the buzzard is not currently occupied (e.g., sleeping, busy, or in flight).
- Parameters: None.
- Returns:
Entity?: The threat entity if present and not busy; otherwisenil.
BuzzardBrain:DealWithThreat()
- Description: Decides the buzzard’s response to a threat: defend the current food (corpse or edible item) if present, or flee. For mutated buzzards, threats are only suggested (not force-assigned) if another buzzard hasn’t already engaged it.
- Parameters: None.
- Returns:
Boolean:trueif a defensive or fleeing action was initiated;falseif the behavior tree should proceed to the next node.
BuzzardBrain:DoUpdate()
- Description: Resets the threat cache (
self.threat) tofalse, indicating that a fresh threat search should be performed on the next cycle. - Parameters: None.
- Returns: Nothing.
BuzzardBrain:OnStart()
- Description: Constructs the behavior tree root node, which orchestrates all buzzard behaviors. Includes conditional branches for fire flight, mutated timeout flight, corpse eating, food scanning, threat response, and wandering.
- Parameters: None.
- Returns: Nothing.
BuzzardBrain:OnStop()
- Description: Releases ownership of the current corpse and deregisters event listeners to prevent leaks.
- Parameters: None.
- Returns: Nothing.
Events & Listeners
- Listens to:
onignite: On the current corpse entity. Triggers threat suggestion against the igniting entity if valid (used to protect food).chomped: On the current corpse entity. Triggers threat targeting of any entity eating the same corpse (standard buzzards object to sharing; mutated buzzards object only to non-mutant eaters).
- Pushes:
corpse_eat: Fired immediately before facing and consuming a valid corpse. Carries{ corpse = corpse }in the event data.
External Helper Functions
-
Buzzard_ShouldIgnoreCorpse(corpse)
Public wrapper forBuzzardBrain:ShouldIgnoreCorpse, used by external manager components to check corpse availability. -
FindThreat(inst, radius)
Centralized threat search logic usingFindEntitywith tag filters and validity callbacks, differing based onlunar_alignedstatus. -
IsCorpseValid(guy, inst)
Validates corpses for buzzards, considering burn state, mutation state, gestalt arriving flags, and ownership limits. -
Normal_IsValidThreat(guy, inst)
For standard buzzards: allows threats unless they are buzzards that are not close enough to be defended. -
Mutated_IsValidThreat(guy)
For mutated buzzards: allows all threats with acombatcomponent, enabling group targeting. -
GetCorpseRadius(corpse)
Computes a reliable radius for corpse targeting by comparingGetCombatFxSizeand physics radius. -
GetHomePos(inst)
Returns the buzzard’s current position as the “home” location for wander logic. -
GetSeeThreatDist(inst)
Returns the perception radius for threats:7.5for standard,3for mutated buzzards. -
IsSgBusy(inst)
Helper that returnstrueif the stategraph has any of"sleeping","busy", or"flight"tags. -
CanEat(food)
Verifies food is on valid ground (IsOnValidGround). -
EatFoodAction(inst)
Attempts to eat nearby food withinSEE_FOOD_DIST(15 units), returning aBufferedActionornil. -
GoHome(inst)
Returns aBufferedActionto executeACTIONS.GOHOMEifinst.shouldGoAwayis set. -
ShouldFlyAwayFromFire(inst)
TriggersshouldGoAwayif the buzzard is on fire and taking fire damage (but not currently burning). Applies to standard buzzards only. -
Mutated_ShouldFlyAway(inst)
TriggersshouldGoAwayif no corpse has been consumed for overFLY_AWAY_AFTER_NO_CORPSE_TIME(20 seconds). Applies to mutated buzzards only.
Global State
ignorethese: A shared dictionary mapping{ corpse = { [buzzard_inst] = true } }to track which buzzards own each corpse.SIZE_TO_NUM_OWNERS: Maps corpse size strings ("tiny","small","med","large") to maximum allowed concurrent eaters (e.g.,"large"corpses support 10 buzzards).
Key Constants
FLY_AWAY_AFTER_NO_CORPSE_TIME = 20SEE_FOOD_DIST = 15SEE_THREAT_DIST = 7.5MUTATED_SEE_THREAT_DIST = 3NO_TAGS = { "FX", "NOCLICK", "DECOR", "INLIMBO", "outofreach" }FOOD_TAGS = { "edible_omni", "edible_meat", ... }(derived fromFOODGROUP.OMNI.types)FINDTHREAT_MUST_TAGS = { "notarget", "playerghost" }FINDTHREAT_CANT_TAGS = { "player", "monster", "scarytoprey" }FINDTHREAT_MUTATED_CANT_TAGS = { "notarget", "lunar_aligned", "playerghost" }FINDTHREAT_MUTATED_ONE_OF_TAGS = { "player", "monster", "scarytoprey" }UPDATE_RATE = 0.5
Behavior Tree Nodes Used
PriorityNode,WhileNode,IfNode,ConditionNode,ActionNode,FailIfSuccessDecorator,DoAction,Wander,StandAndAttack,FaceEntity,Leash
Behavior Logic Summary
- Non-flying & non-flamethrowering state → evaluate sub-tasks.
- Standard buzzard → flee fire if
takingfiredamage. - Mutated buzzard → fly away if no corpse consumed for 20 seconds.
- Any buzzard → flee if
shouldGoAwayflag set. - Stand and attack → engage current target or remain alert.
- Threat detection → defend food or flee.
- Mutated-only corpse eating → find and consume corpse if no target is active.
- Food seeking → hop to and eat nearby food items.
- Wander → resume idle movement.
Note: Mutated buzzards do not perform food seeking (steps 7–8); they rely solely on corpse consumption.