Skip to content

PriorityAttackLogic ​

Inherits: AttackStateLogic < Resource

PriorityAttackLogic evaluates a list of actions in priority order and executes the first valid one. This is used for NPCs with abilities that should be used under specific conditions.

Description ​

Scenario 1 example: Caster NPC

  • Priority 100: Use special ability (if off cooldown, random delay passed)
  • Priority 1: Basic attack (fallback, handled by combat script)

Actions are checked from highest to lowest priority. The first action whose conditions are met gets executed.

Properties ​

Array[CombatAction]actions[]
floatmin_first_delay5.0
floatmax_first_delay7.0
floatrest_after_action0.5

Variables ​

floatfirst_ability_delay0.0
boolfirst_ability_usedfalse
floatrest_timer0.0

Methods ​

voidsetup( system_hub: GameHost.SystemHub, entity_ref: Entity, script: ModularCombatScript )
boolexecute( delta: float )
Dictionaryto_save_data()
voidfrom_save_data( save_data: Dictionary )
voidcleanup()

Property descriptions ​

Array[CombatAction] actions = [] ​

List of actions sorted by priority (highest first)

float min_first_delay = 5.0 ​

Minimum delay before first ability (seconds)

float max_first_delay = 7.0 ​

Maximum delay before first ability (seconds)

float rest_after_action = 0.5 ​

Rest period after successful action execution (seconds)

Variable descriptions ​

float first_ability_delay = 0.0 ​

Timer for the first ability delay (random 5-7s delay before first cast)

bool first_ability_used = false ​

Whether the first ability has been used yet

float rest_timer = 0.0 ​

Timer for rest period after successful action

Method descriptions ​

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

Setup the priority logic

bool execute( delta: float ) ​

Execute the highest priority valid action

Dictionary to_save_data() ​

Save runtime state

void from_save_data( save_data: Dictionary ) ​

Restore runtime state

void cleanup() ​

Cleanup all actions