Skip to content

CombatReaction ​

Inherits: Resource

CombatReaction represents an event-driven response that can trigger in any combat state. Unlike actions in priority lists, reactions are always listening for their trigger event.

Description ​

Examples:

  • OnDamageTaken: Use defensive ability
  • OnAllyDied: Enrage
  • OnPlayerCasting: Interrupt
  • OnHealthBelowPercent: Emergency heal

Reactions work by connecting to entity signals and checking conditions when events fire.

Properties ​

Stringreaction_name"Unnamed Reaction"
TriggerEventtrigger_eventTriggerEvent.DAMAGE_TAKEN
Array[EntityCondition]conditions[]
Array[CombatAction]reaction_actions[]
floatreaction_cooldown0.0
floathealth_threshold_percent30.0

Variables ​

Entityentity
ModularCombatScriptcombat_script
floatcooldown_remaining0.0
CombatSessioncurrent_encounternull
ChronoManagerchrono_manager
EventManagerevent_manager

Methods ​

voidsetup( system_hub: GameHost.SystemHub, entity_ref: Entity, script: ModularCombatScript )
voidset_encounter( encounter: CombatSession )
boolshould_trigger()
voidexecute_reaction()
voidprocess( delta: float )
voidcleanup()

Enumerations ​

enum TriggerEvent ​

The options of trigger event: damage taken, damage dealt, health below percent, ally died, enemy died, target changed, effect gained, effect lost, ability used.

  • DAMAGE_TAKEN = 0 - When this entity takes damage
  • DAMAGE_DEALT = 1 - When this entity deals damage
  • HEALTH_BELOW_PERCENT = 2 - When health drops below threshold
  • ALLY_DIED = 3 - When an ally dies
  • ENEMY_DIED = 4 - When an enemy dies
  • TARGET_CHANGED = 5 - When target changes
  • EFFECT_GAINED = 6 - When this entity gains an effect
  • EFFECT_LOST = 7 - When this entity loses an effect
  • ABILITY_USED = 8 - When target uses an ability

Property descriptions ​

String reaction_name = "Unnamed Reaction" ​

Display name for debugging

TriggerEvent trigger_event = TriggerEvent.DAMAGE_TAKEN ​

Event that triggers this reaction

Array[EntityCondition] conditions = [] ​

Conditions that must be met for reaction to execute (in addition to event trigger)

Array[CombatAction] reaction_actions = [] ​

Actions to execute when reaction triggers

float reaction_cooldown = 0.0 ​

Cooldown before this reaction can trigger again (seconds)

float health_threshold_percent = 30.0 ​

For HEALTH_BELOW_PERCENT trigger

Variable descriptions ​

Entity entity ​

Reference to the entity

ModularCombatScript combat_script ​

Reference to the combat script

float cooldown_remaining = 0.0 ​

Internal cooldown timer

CombatSession current_encounter = null ​

Add this property at the top with other variables

ChronoManager chrono_manager ​

SystemRefrences

EventManager event_manager ​

The event manager the reaction listens to.

Method descriptions ​

void setup( system_hub: GameHost.SystemHub, entity_ref: Entity, script: ModularCombatScript ) ​

Setup the reaction with entity and behavior script references

void set_encounter( encounter: CombatSession ) ​

Set the current encounter and connect/disconnect encounter signals

bool should_trigger() ​

Check if reaction should trigger (called by combat script or signal handlers)

void execute_reaction() ​

Execute the reaction

void process( delta: float ) ​

Update cooldown (called by combat script)

void cleanup() ​

Cleanup