AbilityInstance ​
Inherits: RefCounted
Runtime instance of an ability that references an AbilityDefinition for configuration Handles execution state, cooldowns, and effect application with definition-based logic delegation Now follows the effects architecture pattern - definitions contain logic, instances contain runtime state
Variables ​
Methods ​
Signals ​
ability_used( ability_instance: AbilityInstance ) ​
Emitted when the ability is used
ability_state_changed( ability_instance: AbilityInstance, old_state: AbilityState, new_state: AbilityState ) ​
Emitted when ability state changes (ready, cooldown, etc.)
ability_appearance_changed( ability_instance: AbilityInstance ) ​
Emitted when ability properties are dynamically changed (icon, name, description)
rank_changed( ability_instance: AbilityInstance, old_rank: int, new_rank: int ) ​
Emitted when the rank of the ability changes (trained or given by gear or an effect)
cooldown_started( ability_instance: AbilityInstance, duration: float ) ​
Emitted when the ability's cooldown starts
cooldown_ended( ability_instance: AbilityInstance ) ​
Emitted when the ability's cooldown ends
ability_reflected( ability_instance: AbilityInstance, ward_holder: Entity ) ​
Emitted when a reflective ward sent this ability back at its caster (ward_holder is who it was aimed at)
charge_consumed( ability_instance: AbilityInstance, charges_remaining: int, max_charges: int ) ​
Emitted when a charge is consumed (for charge stack abilities)
charge_restored( ability_instance: AbilityInstance, charges_remaining: int, max_charges: int ) ​
Emitted when a charge is restored/regenerated (for charge stack abilities)
charges_changed( ability_instance: AbilityInstance, charges_remaining: int, max_charges: int ) ​
Emitted when charge count changes for any reason (consumed, restored, or reset)
toggle_activated( ability_instance: AbilityInstance ) ​
Emitted when a toggle ability is activated
toggle_deactivated( ability_instance: AbilityInstance ) ​
Emitted when a toggle ability is deactivated
toggle_state_changed( ability_instance: AbilityInstance, is_active: bool ) ​
Emitted when toggle state changes for any reason
Enumerations ​
enum AbilityState ​
The options of ability state: ready, casting, channeling, silenced, on cooldown, inactive.
- READY =
0 - CASTING =
1 - CHANNELING =
2 - SILENCED =
3 - ON_COOLDOWN =
4 - INACTIVE =
5
enum AbilityUseAttemptResult ​
The options of ability use attempt result: ok, entity dead, on global cooldown, on cooldown, insufficient resource, ability not found, ability inactive, silenced, target out of range, disarmed ....
- OK =
0 - ENTITY_DEAD =
1 - ON_GLOBAL_COOLDOWN =
2 - ON_COOLDOWN =
3 - INSUFFICIENT_RESOURCE =
4 - ABILITY_NOT_FOUND =
5 - ABILITY_INACTIVE =
6 - SILENCED =
7 - TARGET_OUT_OF_RANGE =
8 - DISARMED =
9 - INCAPACITATED =
10 - WEAPON_REQUIREMENT_NOT_MET =
11 - INVALID_TARGET =
12 - REQUIREMENTS_NOT_MET =
13 - BUSY =
14 - SCHOOL_LOCKED =
15 - TOGGLE_TOO_SOON =
16 - NO_AMMO =
17
enum SourceType ​
The options of source type: intrinsic, external, stateful, persistent.
- INTRINSIC =
0 - EXTERNAL =
1 - STATEFUL =
2
Constants ​
Array[String]STAT_MODIFIED_PROPERTIES =["cooldown_duration", "cost_amount", "gain_amount", "cast_duration", "max_ran...- The properties the stats of the user can change (AbilityModifierStatEffect): cooldown, cost, gain, and the cast time and range of the strategies
Variable descriptions ​
AbilityDefinition definition ​
Reference to the immutable ability definition (shared across instances)
Entity user ​
The entity that owns/uses this ability
SourceType source = SourceType.PERSISTENT ​
Source type for save/load logic
CombatManager combat_manager ​
SystemManagers refs
ChronoManager chrono_manager ​
The manager of timers the ability takes its timers from.
TargetStrategyInstance target_strategy_instance ​
Runtime instance of the targeting strategy
UseStrategyInstance use_strategy_instance ​
Runtime instance of the use strategy
AbilityState current_state = AbilityState.READY ​
Current execution state of the ability
Variant current_target = null ​
Current target for this ability execution
Dictionary runtime_data = ​
Runtime data storage for ability-specific information
Array[Effect] live_effects = [] ​
Live effects array - only created when effects are modified
bool has_live_effects = false ​
Whether this instance has been modified and uses live_effects instead of definition.effects
int current_combo_step = 0 ​
Current combo step (0 = first use, 1 = second use, etc.)
Timer combo_timeout_timer = null ​
Timer for combo timeout
Array[Timer] charge_timers = [] ​
Array of charge timers for individual charge cooldowns
int current_charges = 0 ​
Current number of available charges
Timer cooldown_timer = null ​
Timer for ability cooldown
Timer application_delay_timer = null ​
Timer for application delay
Variant delayed_application_target = null ​
Target stored for delayed application
bool effects_pending = false ​
True from the end of the use strategy until the delayed effects have been applied: the ability cannot be used again meanwhile
Dictionary last_cost_paid = ​
What the last use paid, for a refund: {"pool_id": int, "amount": float}
float use_charge_fraction = 1.0 ​
How far a drawn shot was drawn when it was released (0 to 1; 1 for everything that is not drawn): effects that scale with the charge read it
Dictionary last_ammo_paid = ​
What the last use took as ammo or reagent (see AmmoCost), for the refund
Array[Effect] ammo_effects_for_use = [] ​
The effects of the ammo spent by the last use (a poison arrow): applied with the ability's own effects
Array[EffectInstance] active_passive_effects = [] ​
Active effect instances from this passive ability (only for PassiveAbilityDefinition)
bool is_monitoring_requirements = false ​
Whether this passive is monitoring requirements reactively
bool icon_changed = false ​
Whether the icon has been dynamically changed
bool name_changed = false ​
Whether the name has been dynamically changed
bool description_changed = false ​
Whether the description has been dynamically changed
Texture2D current_icon = null ​
Current dynamic icon (if changed)
String current_display_name = "" ​
Current dynamic display name (if changed)
String current_description = "" ​
Current dynamic description (if changed)
Dictionary runtime_property_overrides = ​
Runtime overrides for definition properties (only set when modified by effects)
PropertyModifierSet modifiers = PropertyModifierSet.new() ​
Modifiers from abilities, effects and stats (cooldown, cost, gain ...): they stack and can be taken away by their source
int trained_rank = 1 ​
The rank the ability was trained to (1 = the first rank). The rank that counts is get_rank(): this plus the ranks gear or an effect add
int rewarded_ranks = 0 ​
The part of trained_rank that rewards give again on every load (the ranks of a skill tree node: the tree applies its rewards again after a load). A save keeps trained_rank minus this, so a rank is never counted twice
Method descriptions ​
int get_ability_school() ​
Get ability school (runtime override or definition)
bool get_on_global_cooldown() ​
Get GCD setting (runtime override or definition)
Array get_stat_entries( property_name: String ) ​
What the stats of the user change on a property of this ability: ability modifier stat effects, worked out when asked
int get_max_rank() ​
The highest rank the ability can be trained to
int get_rank() ​
The rank of the ability now: what it was trained to, plus the ranks that gear and effects add (+1 to all fire spells; these can go over the highest trained rank)
int get_rank_bonus() ​
The ranks that gear, auras and other effects of the user add to this ability
bool can_rank_up() ​
Can the ability be trained one more rank?
bool set_rank( new_rank: int ) ​
Trains the ability to a rank (between 1 and its highest). True when the rank changed
bool rank_up( by: int = 1 ) ​
Trains the ability one or more ranks. False when it is at its highest rank already
void notify_rank_bonus_changed( old_bonus: int ) ​
Tells the ability that a bonus to its rank changed (gear on or off): its numbers are read live, so only the announcement is needed
Array get_rank_entries( property_name: String ) ​
What the rank of this ability changes on a property: the rank properties of the definition at the current rank (nothing for an ability without ranks)
float get_cooldown_duration() ​
Get cooldown duration: the runtime override, the weapon speed or the definition, then the modifiers on top
float get_cost_amount() ​
Get cost amount (runtime override or definition)
float get_gain_amount() ​
Get gain amount (runtime override or definition)
int get_cost_pool_id() ​
Get cost pool name (runtime override or definition)
int get_gain_pool_id() ​
Get gain pool name (runtime override or definition)
float get_combo_timeout() ​
Get combo timeout (runtime override or definition)
int get_current_combo_step() ​
Get current combo step (for UI display)
int get_max_combo_steps() ​
Get max combo steps (for UI display)
float get_combo_timeout_remaining() ​
Get combo timeout remaining (for UI display)
bool is_in_combo() ​
Check if ability is in combo sequence
void set_runtime_property( property_name: String, value: Variant ) ​
Set a runtime property override
void clear_runtime_property( property_name: String ) ​
Clear a runtime property override (reverts to definition value)
bool has_runtime_override( property_name: String ) ​
Check if a property has a runtime override
Dictionary get_all_runtime_overrides() ​
Get all runtime overrides (for debugging/save states)
void clear_all_runtime_overrides() ​
Clear all runtime overrides
AbilityUseAttemptResult use_ability( target: Variant = null, from_action: bool = false ) ​
Execute the ability with optional target and action flag
void apply_ability_effects( target: Variant ) ​
Apply ability effects with smart registration logic
AbilityUseAttemptResult can_use( from_action: bool = false ) ​
Check if ability can be used
void refund_cost() ​
Give back what the last use cost (a cast that was cancelled, not one that an interrupt effect stopped)
bool try_interrupt() ​
Try to interrupt this ability (an interrupt effect, a kick): what was spent stays spent and the ability goes on cooldown
void receive_shared_cooldown( duration: float ) ​
A member of one of the ability's groups was used: this ability is on cooldown for the shared time too (unless it is busy or already on a longer one)
void set_state( new_state: AbilityState ) ​
Enhanced state setting with entity coordination
Array get_current_effects() ​
Get effects to apply (DELEGATED TO DEFINITION)
bool add_effect_by_id( effect_id: int ) ​
Add effect to ability using DatabaseEffects (copy-on-write)
Array[int] remove_effect_by_id( effect_id: int ) ​
Remove effect from ability by ID (copy-on-write)
bool restore_effect_by_id_at_positions( effect_id: int, positions: Array[int] ) ​
Restore effect at specific positions (copy-on-write)
void reset_to_definition_effects() ​
Reset to definition effects (clear live modifications)
bool has_effect_modifications() ​
Check if ability has been modified from its definition
Dictionary get_effects_memory_info() ​
Get memory usage info for debugging
AbilityDefinition swap_definition( new_definition: AbilityDefinition ) ​
Swap this ability's definition to another, returning the original for later restoration. Rebuilds strategy instances and reconnects signals to match the new definition.
String get_display_name() ​
Get the display name (dynamic or from definition)
String get_description() ​
Get the description (dynamic or from definition)
bool can_miss() ​
Can this use of the ability miss? Its Hit rule, or the project's choice when it follows the default. Only active abilities roll to hit
bool is_ranged_attack() ​
Is this a ranged attack? Its Attack style, or for Automatic the range of the ability against the melee range of the game settings (no range limit counts as melee)
float get_max_range() ​
Get the max range
float get_ai_range() ​
The distance an AI works with: the max range, and for an ability with no range limit (a max range of 0, as the targeting treats it) the Sight Range of the user
Texture2D get_icon() ​
Get the icon (dynamic or from definition)
int get_id() ​
Get the ability ID
int get_school() ​
Get the ability school (use runtime-aware getter)
void set_dynamic_icon( new_icon: Texture2D ) ​
Set a dynamic icon for this ability instance
void set_dynamic_display_name( new_name: String ) ​
Set a dynamic display name for this ability instance
void set_dynamic_description( new_description: String ) ​
Set a dynamic description for this ability instance
void reset_dynamic_properties() ​
Reset dynamic properties to definition defaults
float get_cooldown_remaining() ​
Get remaining cooldown time
bool is_on_cooldown() ​
Check if ability is on cooldown
int get_current_charges() ​
Get current charge count (for UI display)
int get_max_charges() ​
Get max charges (for UI display)
bool is_inactive() ​
Check if ability is inactive
String get_requirement_failure_message() ​
Get requirement failure message for UI tooltips
String get_requirements_summary() ​
Get requirements summary for UI tooltips
bool is_executing() ​
Check if ability is currently being executed
bool is_ready() ​
Check if ability is ready to use (considers charges and requirements)
void setup_requirement_monitoring() ​
Set up reactive requirement monitoring for any ability with requirements
void cleanup_requirement_monitoring() ​
Clean up reactive requirement monitoring
void check_and_update_requirement_state() ​
Check requirements and update ability state accordingly
void activate_passive_effects() ​
Apply the passive effects when this ability is added to an entity, if its requirements hold (or it has none). An instance that starts with unmet requirements is INACTIVE and applies them when they become true (check_and_update_requirement_state)
void apply_passive_effects() ​
Apply passive ability effects to the user entity
void remove_passive_effects() ​
Remove all passive ability effects from the user entity
bool is_passive_active() ​
Check if this passive ability's effects are currently active
Array[EffectInstance] get_active_passive_effects() ​
Get all currently active effect instances from this passive
Dictionary to_save_data() ​
Save instance runtime state
void from_save_data( save_data: Dictionary ) ​
Load instance runtime state
void cleanup() ​
Clean up all resources used by this ability instance
void cleanup_timers() ​
Gives the cooldown timer back to the manager.
String get_ammo_warning() ​
What to tell the player when the last attempt was refused for missing ammo or a reagent ("Out Of Ammo!")
void release_input() ​
The key that started this ability was released: a drawn shot is loosed (or cancelled when released too early)