ASAbility
Inherits:
ResourceBase resource for defining abilities within the module.
Description
[ASAbility] defines the logic and data for a specific action. It manages its own costs, cooldowns, and tags.
Properties
| Type | Name | Default |
|---|---|---|
float | ability_duration | 0.0 |
Base duration of the ability. | ||
int | ability_duration_policy | 0 |
Defines how the ability duration is handled (0: Instant, 1: Duration, 2: Infinite). | ||
String | ability_name | "" |
Unique name for this ability. | ||
StringName | ability_tag | &"" |
The unique tag identifying this ability. | ||
bool | ability_use_custom_duration | false |
If true, triggers custom magnitude calculation for duration. | ||
StringName[] | activation_blocked_all_tags | [] |
Ability cannot activate if owner has all of these tags simultaneously (AND logic). | ||
StringName[] | activation_blocked_any_tags | [] |
Ability cannot activate if owner has any of these tags (OR logic). | ||
StringName[] | activation_cancel_tags | [] |
Tags of active abilities that will be canceled when this ability activates. | ||
StringName[] | activation_owned_tags | [] |
Tags granted to the owner while the ability is active. | ||
StringName[] | activation_required_all_tags | [] |
Owner must have all of these tags to activate (AND logic). | ||
StringName[] | activation_required_any_tags | [] |
Owner must have at least one of these tags to activate (OR logic). | ||
float | cooldown_duration | 0.0 |
Base duration of cooldown. | ||
StringName[] | cooldown_tags | [] |
Tags applied during cooldown. | ||
bool | cooldown_use_custom | false |
If true, triggers custom magnitude calculation for cooldown duration. | ||
Dictionary[] | costs | [] |
Array of native costs (attribute and amount). | ||
bool | costs_use_custom | false |
If true, triggers custom magnitude calculation for modifier amounts. | ||
ASCue[] | cues | [] |
Visual/Audio cues triggered on start and end. | ||
ASEffect[] | effects | [] |
List of effects applied by this ability. | ||
StringName[] | events_on_activate | [] |
Events dispatched when the ability is successfully activated. | ||
StringName[] | events_on_end | [] |
Events dispatched when the ability ends (regardless of whether it was canceled or finished naturally). | ||
ASAbility[] | phases | [] |
Sequential phases that this ability will execute in order. | ||
Dictionary[] | requirements | [] |
Attribute requirements needed to activate the ability. | ||
ASAbility[] | sub_abilities | [] |
Hierarchical sub-abilities that are unlocked alongside this parent ability. | ||
StringName[] | sub_abilities_auto_activate | [] |
Tags of sub-abilities that should automatically activate when the parent ability starts. | ||
Dictionary[] | triggers | [] |
Automatic triggers for this ability (e.g. activate when a tag is added). | ||
Methods
| Return | Name |
|---|---|
void | _on_activate_ability(
owner: Object, spec: RefCounted)
virtual |
Virtual method to implement the ability’s logic. | |
bool | _on_can_activate_ability(
owner: Object, spec: RefCounted)
virtual const |
Virtual method to implement custom activation requirements. | |
void | _on_end_ability(
owner: Object, spec: RefCounted)
virtual |
Virtual method called when the ability ends. | |
void | activate_ability(
owner: ASComponent, spec: ASAbilitySpec = null, target_node: Object = null) |
Starts the ability execution. Handles native costs and cooldown application automatically. | |
void | add_cost(
attribute: StringName, amount: float) |
Adds a native cost modifier. | |
void | add_requirement(
attribute: StringName, amount: float) |
Adds a prerequisite attribute value required for the ability to activate. Unlike costs, requirements do not consume the attribute; they only verify the current value. | |
void | add_trigger(
tag: StringName, type: int) |
Registers an automatic activation trigger based on Global Tags or ASEvents. For example, an ability can be triggered when ‘State.OnFire’ is added to the actor. | |
void | apply_costs(
owner: ASComponent, spec: ASAbilitySpec = null)
const |
Applies the costs of the ability to the owner. | |
float | calculate_ability_duration(
owner: ASComponent)
const |
Calculates the duration of the ability, considering [member ability_use_custom_duration]. | |
bool | can_activate_ability(
owner: ASComponent, spec: ASAbilitySpec = null)
const |
Returns true if the ability can be activated (checks tags, costs, and cooldown). | |
bool | can_afford_costs(
owner: ASComponent, spec: ASAbilitySpec = null)
const |
Checks if the owner has enough resources to afford the costs. | |
bool | can_satisfy_requirements(
owner: ASComponent, spec: ASAbilitySpec = null)
const |
Checks if the owner satisfies the attribute requirements defined in this ability. | |
void | end_ability(
owner: ASComponent, spec: ASAbilitySpec = null) |
Ends the ability execution and cleans up owned tags. | |
float | get_cost_amount(
attribute: StringName)
const |
Returns the cost amount for a specific attribute of this ability. | |
float | get_requirement_amount(
attribute: StringName)
const |
Returns the numeric requirement value for a specific attribute of this ability. | |
int | get_requirement_count(
)
const |
Returns the total number of attribute prerequisites defined for this ability. | |
bool | remove_cost(
attribute: StringName) |
Removes a cost definition for a specific attribute. | |
bool | remove_requirement(
attribute: StringName) |
Removes an attribute requirement by its tag name. Returns true if the requirement existed and was successfully removed. | |
Constants
| Name | Value |
|---|---|
| POLICY_INSTANT | 0 |
Ability triggers its effect once and ends immediately. | |
| POLICY_DURATION | 1 |
Ability has a fixed duration. | |
| POLICY_INFINITE | 2 |
Ability remains active until explicitly ended. | |
| TRIGGER_ON_TAG_ADDED | 0 |
Ability attempts to activate when a specific Tag is added to the owner. | |
| TRIGGER_ON_TAG_REMOVED | 1 |
Ability attempts to activate when a specific Tag is removed from the owner. | |
| TRIGGER_ON_EVENT | 2 |
Ability attempts to activate when a specific ASEventTag is dispatched to the owner. This is the preferred way for reactive triggers like “Counter-attack on Hit”. | |