Home › Lua API › UnitAbility
Available out of the box. Usable from Lua in the unmodified game.
UnitAbility
7 methods. Symbol/current columns are function addresses (RVA) of the native wrapper.
Signatures are recovered from the game code. ⚠ = partly understood (arguments may be missing or approximate). ? after a name = optional argument. Types: integer/number are Lua numbers, enum-typed arguments show the C++ type in brackets. Two signatures mean the method is registered separately for the UI and the gameplay state and each wrapper was decoded on its own. "same code as" in the Symbol column means the compiler merged identical functions: those methods share one wrapper and cannot be told apart by address.
| Method |
Signature |
Where |
Reference |
Symbol |
Current |
| AddAbilityCount |
UnitAbility:AddAbilityCount(eAbility: number/string[UnitAbilityTypes]) (or nothing) args: eAbility — Index of a row of the UnitAbilities table (the value of GameInfo.UnitAbilities[...].Index). |
gameplay |
— |
0x6ff230 |
0x6ff980 |
| CanHaveAbility |
UnitAbility:CanHaveAbility(eAbility: number/string[UnitAbilityTypes]) → boolean (or nothing) args: eAbility — Index of a row of the UnitAbilities table (the value of GameInfo.UnitAbilities[...].Index). |
gameplay |
— |
0x6ff290 |
0x6ff9e0 |
| ChangeAbilityCount ★ |
UnitAbility:ChangeAbilityCount(eAbility: number/string[UnitAbilityTypes], iDelta?: number) → boolean args: eAbility — Index of a row of the UnitAbilities table (the value of GameInfo.UnitAbilities[...].Index).; iDelta — A number. |
gameplay |
— |
0x6ff320 |
0x6ffa70 |
| GetAbilities |
UI state: UnitAbility:GetAbilities() → number[] gameplay state: UnitAbility:GetAbilities() → table{Ability: number, Count: number}[] |
ui-cache, gameplay |
— |
0x6bd940 |
0x6bdec0 |
| GetAbilityCount |
UnitAbility:GetAbilityCount(eAbility: number/string[UnitAbilityTypes]) → number args: eAbility — Index of a row of the UnitAbilities table (the value of GameInfo.UnitAbilities[...].Index). returns: A count or amount (the scripts name the result count / num / amount). (inferred) |
gameplay |
— |
0x6ff5c0 |
0x6ffd10 |
| HasAbility |
UnitAbility:HasAbility(eAbility: number/string[UnitAbilityTypes]) → boolean args: eAbility — Index of a row of the UnitAbilities table (the value of GameInfo.UnitAbilities[...].Index). |
gameplay |
— |
0x6ff670 |
0x6ffdc0 |
| RemoveAbilityCount |
UnitAbility:RemoveAbilityCount(eAbility: number/string[UnitAbilityTypes]) (or nothing) args: eAbility — Index of a row of the UnitAbilities table (the value of GameInfo.UnitAbilities[...].Index). |
gameplay |
— |
0x6ff720 |
0x6ffe70 |
Notes (★)
ChangeAbilityCount
Adds or removes a unit ability at run time by a signed count; returns whether the change was applied.
- The count methods (GetAbilityCount, ChangeAbilityCount, AddAbilityCount, RemoveAbilityCount, HasAbility) are registered on the gameplay state only; GetAbilities is on both states. None of them appear in the community reference.
[verified; evidence: dll-registration — UnitAbility registration tables]
- Civ6-GCO grants and strips an ability by name with a signed delta: ChangeAbilityCount("ABILITY_NO_MOVEMENT", 1) to immobilise a garrison, and ChangeAbilityCount("ABILITY_NO_MOVEMENT", -GetAbilityCount(...)) to clear it, keeping the boolean result. It also copies abilities onto a re-created unit this way. A type name string is accepted in place of an id, matching the recovered number|string parameter.
[inferred; evidence: community-reference — Civ6-GCO Scripts/GCO_AltHistScript.lua:692,796,1637; GCO_UnitScript.lua ~1416; third-party mod Civ6-GCO (Gedemon, 2021), not a Firaxis script]
See also: UnitAbility.GetAbilityCount, UnitAbility.HasAbility, UnitAbility.AddAbilityCount, UnitAbility.RemoveAbilityCount