Pigelitefighterbrain
Based on game build 714014 | Last updated: 2026-02-27
Overview
Pigelitefighterbrain is an AI brain component that controls the behavior of the Pig King's elite fighter. It uses a behavior tree (BT) to manage decision-making, integrating combat (ChaseAndAttack), following a leader, panic responses (from haunting or fire), avoidance of electric fences, and despawn logic. This brain inherits from Brain and overrides OnStart() to construct the behavior tree root node.
It depends on several components:
follower: retrieves the leader entity viaGetLeader()for proximity-based following.hauntable: checkspanicstatus to trigger panicked behavior during hauntings.health: monitorstakingfiredamageto initiate panic when on fire.
Usage example
This brain is typically assigned to an entity during entity initialization via inst:AddComponent("pigelitefighterbrain"). It does not require manual function calls — it operates automatically by reacting to events and state changes.
inst:AddComponent("pigelitefighterbrain")
inst:AddComponent("follower")
inst:AddComponent("health")
inst:AddComponent("hauntable")
Dependencies & tags
Components used: follower, hauntable, health
Tags: None identified (the brain itself does not add or remove tags; tag usage is internal to state graph interactions via HasStateTag("jumping")).
Properties
The constructor does not define any instance-specific properties beyond the inherited Brain behavior. All state is managed internally through the behavior tree and local helper functions.
| Property | Type | Default Value | Description |
|---|---|---|---|
inst | Entity | — | The entity instance this brain controls (inherited from Brain). |
bt | BT | nil (set in OnStart) | Behavior tree instance constructed during initialization. |
Main functions
OnStart()
- Description: Initializes and assigns the behavior tree root. Constructs a priority-based tree with conditional branches for high-priority states (jumping, panic, fire, electric shock, despawn), followed by default combat and following behavior.
- Parameters: None.
- Returns: Nothing.
- Error states: None documented; assumes all required components (
follower,hauntable,health) are attached toinst.
Events & listeners
-
Pushes:
"despawn": Fired in a loop when_should_despawnis true or when no leader is present andGetLeader()returnsnil.
-
Listens to: None (this component does not directly register event listeners; state changes are captured implicitly via
WhileNodeconditions polling component properties).