ThreatTableComponent ​
Inherits: Resource
ThreatTableComponent manages the aggression (threat) system for NPC entities. It tracks and calculates aggression levels towards players, influencing target selection and combat behavior. Key features:
Description ​
- Maintains a threat table storing aggression values for each player
- Provides methods for adding, decaying, and resetting threat
- Handles target selection based on highest threat
- Manages combat state transitions based on threat levels
- Responds to entity death or freeing events
Variables ​
Entity | entity | |
Dictionary | threat_table | {} |
Dictionary | connected_entities | {} |
Array[Entity] | forced_targets | [] |
Methods ​
void | threat_table_component_setup( system_hub: GameHost.SystemHub, parent_entity: Entity ) |
void | receive_threat_from_player( player: Entity, threat_amount: int ) |
void | force_target( source: Entity ) |
void | release_forced_target( source: Entity ) |
float | get_threat( source: Entity ) |
void | set_threat( source: Entity, value: float ) |
float | get_highest_threat() |
Entity | select_target_player() |
void | decay_threat( decay_factor: float = 0.95 ) |
void | reset_target_threat( player: Entity ) |
bool | all_threat_null() |
Entity | get_highest_threat_target() |
void | clear_threat() |
Variable descriptions ​
Entity entity ​
The entity (NPC) that owns this threat table
Dictionary threat_table = ​
Dictionary to store player threat amounts
Dictionary connected_entities = ​
Dictionary to track which entities we're connected to
Array[Entity] forced_targets = [] ​
Entities that forced this NPC to target them (a taunt), the latest last: while there is one, it is the target whatever the threat says
Method descriptions ​
void threat_table_component_setup( system_hub: GameHost.SystemHub, parent_entity: Entity ) ​
Initializes the ThreatTableComponent
void receive_threat_from_player( player: Entity, threat_amount: int ) ​
Adds threat for a player and updates the entity's target
void force_target( source: Entity ) ​
Makes the NPC attack this source (a taunt).
void release_forced_target( source: Entity ) ​
Lets the NPC choose its target again.
float get_threat( source: Entity ) ​
The threat an entity has on this NPC (0 = none)
void set_threat( source: Entity, value: float ) ​
Sets the threat of an entity outright (0 or less removes it)
float get_highest_threat() ​
The highest threat any entity has on this NPC
Entity select_target_player() ​
Selects the player with the highest threat as the target
void decay_threat( decay_factor: float = 0.95 ) ​
Reduces threat for all players over time
void reset_target_threat( player: Entity ) ​
Resets the threat for a specific player
bool all_threat_null() ​
Checks if all threat values are null (no targets)
Entity get_highest_threat_target() ​
Returns the player with the highest threat
void clear_threat() ​
Clears all threat values