Skip to content

ASAbility

PT | EN
Inherits: Resource

Base 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

TypeNameDefault
floatability_duration0.0
Base duration of the ability.
intability_duration_policy0
Defines how the ability duration is handled (0: Instant, 1: Duration, 2: Infinite).
Stringability_name""
Unique name for this ability.
StringNameability_tag&""
The unique tag identifying this ability.
boolability_use_custom_durationfalse
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).
floatcooldown_duration0.0
Base duration of cooldown.
StringName[]cooldown_tags[]
Tags applied during cooldown.
boolcooldown_use_customfalse
If true, triggers custom magnitude calculation for cooldown duration.
Dictionary[]costs[]
Array of native costs (attribute and amount).
boolcosts_use_customfalse
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

ReturnName
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.
voidactivate_ability( owner: ASComponent, spec: ASAbilitySpec = null, target_node: Object = null)
Starts the ability execution. Handles native costs and cooldown application automatically.
voidadd_cost( attribute: StringName, amount: float)
Adds a native cost modifier.
voidadd_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.
voidadd_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.
voidapply_costs( owner: ASComponent, spec: ASAbilitySpec = null) const
Applies the costs of the ability to the owner.
floatcalculate_ability_duration( owner: ASComponent) const
Calculates the duration of the ability, considering [member ability_use_custom_duration].
boolcan_activate_ability( owner: ASComponent, spec: ASAbilitySpec = null) const
Returns true if the ability can be activated (checks tags, costs, and cooldown).
boolcan_afford_costs( owner: ASComponent, spec: ASAbilitySpec = null) const
Checks if the owner has enough resources to afford the costs.
boolcan_satisfy_requirements( owner: ASComponent, spec: ASAbilitySpec = null) const
Checks if the owner satisfies the attribute requirements defined in this ability.
voidend_ability( owner: ASComponent, spec: ASAbilitySpec = null)
Ends the ability execution and cleans up owned tags.
floatget_cost_amount( attribute: StringName) const
Returns the cost amount for a specific attribute of this ability.
floatget_requirement_amount( attribute: StringName) const
Returns the numeric requirement value for a specific attribute of this ability.
intget_requirement_count( ) const
Returns the total number of attribute prerequisites defined for this ability.
boolremove_cost( attribute: StringName)
Removes a cost definition for a specific attribute.
boolremove_requirement( attribute: StringName)
Removes an attribute requirement by its tag name. Returns true if the requirement existed and was successfully removed.

Constants

NameValue
POLICY_INSTANT0
Ability triggers its effect once and ends immediately.
POLICY_DURATION1
Ability has a fixed duration.
POLICY_INFINITE2
Ability remains active until explicitly ended.
TRIGGER_ON_TAG_ADDED0
Ability attempts to activate when a specific Tag is added to the owner.
TRIGGER_ON_TAG_REMOVED1
Ability attempts to activate when a specific Tag is removed from the owner.
TRIGGER_ON_EVENT2
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”.