- Joined
- Mar 9, 2023
- Messages
- 43
Hello!
In one of my abilities, I want to give the hero a scaling attack speed bonus. This is via adding a variant of the gloves of speed ability, then manipulating its integer field. However, it's constantly 0. If I change the field in the object editor of course it increases. Been double-checking with the debug.
Here's the gist of it:
It correctly sets the variables, adds the ability, correctly increases and decreases the ability. However, the integer field just doesn't get changed. It's always the same as the object editor.
Later on, I remove the ability and clean up, but that's not a concern. Help is appreciated!
Edit:
Solved! Here is the updated version:
In one of my abilities, I want to give the hero a scaling attack speed bonus. This is via adding a variant of the gloves of speed ability, then manipulating its integer field. However, it's constantly 0. If I change the field in the object editor of course it increases. Been double-checking with the debug.
Here's the gist of it:
JASS:
local unit u = GetTriggerUnit()
local integer abilityId = 'A0CE' //my ability
local integer as = R2I(GetUnitState(u,UNIT_STATE_MAX_MANA)*0.05) //It can be any value, still doesn't work
local ability a
call UnitAddAbility(u, abilityId)
set a = BlzGetUnitAbility(u, abilityId)
call IncUnitAbilityLevelSwapped( abilityId, u )
call BlzSetAbilityIntegerLevelField(a, ConvertAbilityIntegerLevelField('Isx1'), 0, as)
call DecUnitAbilityLevelSwapped( abilityId, u )
It correctly sets the variables, adds the ability, correctly increases and decreases the ability. However, the integer field just doesn't get changed. It's always the same as the object editor.
Later on, I remove the ability and clean up, but that's not a concern. Help is appreciated!
Edit:
Solved! Here is the updated version:
JASS:
local unit u = GetTriggerUnit()
local integer abilityId = 'A0CE'
local real as = GetUnitState(u, UNIT_STATE_MAX_MANA) * 0.05
local ability a
call UnitAddAbility(u, abilityId)
set a = BlzGetUnitAbility(u, abilityId)
call IncUnitAbilityLevelSwapped(abilityId, u)
call BlzSetAbilityRealLevelField(a, ABILITY_RLF_ATTACK_SPEED_INCREASE_ISX1, 0, as)
call DecUnitAbilityLevelSwapped(abilityId, u)
///Clean up and removal
Last edited: