SetUnitAbilityLevel
- Parameters
-
whichUnit unit
Target unit.
abilcode integer
Abilities' raw code identifier.
level integer
New ability level.
- comment
Sets the new level of unit's ability.
- note
You can only set levels which are defined for the current ability. For example, most WC3 abilities have levels 1-3. Setting level <=0 will instead set it to level 1. Setting level >maximum will instead set it to abilities' highest level defined in WorldEditor.
- note
When a unit picks up an item with an ability, the ability will be added to the unit's list of abilities. Thus, this function can be used to set the level of an ability for an item on the unit, too. Since it's an attribute of the unit, a level set this way will not be retained when the item is dropped and picked up again. Via item abilities, a unit can have more than one instance of ability with the same ability id. This function will only set the level of the most recently obtained ability instance, then, which corresponds to the first ability instance found when using
BlzGetUnitAbilityByIndex
counting upwards.- bug
It's possible to set a unit's building ability (like 'AHbu') to level 0 without an effect. See
GetUnitAbilityLevel
.- patch
1.17a
- Source
- common.j
- return type
integer
- Source code
native SetUnitAbilityLevel takes unit whichUnit, integer abilcode, integer level returns integer