Spiderqueenbrain
Based on game build 714014 | Last updated: 2026-02-27
Overview
The Spiderqueenbrain component implements the decision-making logic for the Spider Queen boss. It determines when to spawn followers (spiders), where to plant new spider dens, and how to respond to threats like panic triggers and player attacks. It integrates with core behavior trees (via Brain and BT) and relies on the IncrementalProducer component to govern follower production limits. The component follows DST’s ECS pattern by attaching to an entity (self.inst) and overriding OnStart to construct the behavior tree.
Usage example
-- Attaching the Spider Queen brain to an entity (e.g., in a prefab definition)
inst:AddComponent("brain")
inst.components.brain:SetBrain("spiderqueenbrain")
-- The component automatically initializes its behavior tree when the entity enters the world
Dependencies & tags
Components used:
incrementalproducer(accessed viainst.components.incrementalproducer)sg(stategraph, accessed viainst.sg)
Tags checked or required:
blocker— used to detect nearby obstructions when placing a nestspiderden— used to enforce minimum spacing between spider densspiderqueen— used to enforce minimum spacing between Spider Queens
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
inst | Entity | nil | The entity instance this brain controls (inherited from Brain). |
bt | BT (behavior tree) | nil | The behavior tree created in OnStart. |
| — | — | — | No additional public properties are explicitly defined in the constructor. |
Main functions
CanSpawnChild()
- Description: Checks whether the Spider Queen is eligible to spawn a new follower spider. Requires sufficient age, non-busy state, and that
IncrementalProducerreports producible units remain. - Parameters: None.
- Returns:
trueif a child can be spawned; otherwisefalse. - Error states: Returns
falseifself.inst.components.incrementalproduceris missing orCanProduce()returnsfalse.
CanPlantNest()
- Description: Determines if the Spider Queen can plant a new spider den. Checks minimum age, surrounding clearance from blockers, and minimum spacing from other dens and Spider Queens.
- Parameters: None.
- Returns:
trueif a nest can be placed; otherwisefalse. - Error states: Returns
falseif the entity is too young or if nearby blockers or dens violate spacing rules.
OnStart()
- Description: Initializes the behavior tree for the Spider Queen. Sets up a priority node with states for panic, nest placement, spawning, chasing/attacking, and wandering. This function is called when the entity’s state graph begins.
- Parameters: None.
- Returns:
nil. - Error states: None — always initializes the behavior tree on call.
Events & listeners
Listens to: Events are handled by the parent Brain and behavior tree system (not directly by this component). Specific listeners for panic triggers (PanicTrigger, ElectricFencePanicTrigger) are embedded in BrainCommon, which this component uses.
Pushes: Events are fired via the state graph (inst.sg:GoToState(...)), not directly through PushEvent.