Wiki

trigger · has_ability

Definition

  • Supported scope:CHARACTER
  • Supported target:any

Description

does unit leader have the abilityCheck if a unit leader has the ability.
Example: has_ability = force_attack

Hands-On Notes

Hands-on notes are AI-generated and checked against the vanilla command vocabulary — treat them as a starting point, not authoritative reference. The definition above is the game's own documentation.

Hands-On Usage

has_ability is commonly used to check whether a specific leader has unlocked a particular active ability, thereby deciding whether to trigger subsequent events or special effects—for example, granting additional bonuses to leaders possessing the "force attack" ability. In mods featuring custom leader progression systems, it can also be used to restrict certain traits so that only leaders who have mastered specific abilities can acquire them.

# Only allow adding a trait if the character has the force_attack ability
if = {
    limit = {
        has_ability = force_attack
    }
    add_unit_leader_trait = aggressive_assaulter
}

Synergy

  • [has_trait](/wiki/trigger/has_trait): Typically used in conjunction with has_ability—first check whether the leader holds a specific trait, then verify whether they have unlocked the corresponding active ability. Together, they establish a more precise conditional threshold.
  • [add_trait](/wiki/effect/add_trait): After confirming the leader possesses a certain ability, use this effect to grant a new trait, forming an advanced logic chain of "ability unlocks trait".
  • [add_timed_unit_leader_trait](/wiki/effect/add_timed_unit_leader_trait): Similar to add_trait, but applies a temporary bonus to leaders meeting ability conditions, suitable for designing time-limited skill enhancement effects.
  • [is_corps_commander](/wiki/trigger/is_corps_commander) / [is_field_marshal](/wiki/trigger/is_field_marshal): Abilities belong to specific commander types; using these triggers in conjunction avoids unintended judgment triggers under wrong leader scopes.

Common Pitfalls

  1. Scope Errors: has_ability is only valid within the CHARACTER scope. Using it directly in country or state scopes will cause script silent failures or errors. You must first enter the correct character scope via any_army_leader, random_army_leader, or similar constructs.
  2. Ability Key Spelling Dependency on Game Files: The ability identifier comes from definitions in unit_leader_abilities, not from trait names. Beginners often confuse trait names with ability names, causing conditions to never evaluate to true. Always verify the exact key in the /common/unit_leader_abilities/ directory.