Delay between aura effects. Is there any way around?
I'm creating an aura which armorbonus is depending on the number of friendly heroes within 400 range of the caster.
Hi there. I need a little help.
Everything is working as expected except one thing.
Whenever the level of the aura is changed, there is like a second delay before the "new" aura take effect (gives armor bonus).
Ex. the ability is changed from lvl 1 to lvl 2. The armorbonus goes like this:
+1 -> 0 -> delay -> +2
Here's how I made the spell:
Please focus on the the problem and forget about leaks and stuff, I'll care about that later.
I'm creating an aura which armorbonus is depending on the number of friendly heroes within 400 range of the caster.
Hi there. I need a little help.
Everything is working as expected except one thing.
Whenever the level of the aura is changed, there is like a second delay before the "new" aura take effect (gives armor bonus).
Ex. the ability is changed from lvl 1 to lvl 2. The armorbonus goes like this:
+1 -> 0 -> delay -> +2
Here's how I made the spell:
Please focus on the the problem and forget about leaks and stuff, I'll care about that later.
JASS:
function Trig_Formation_Conditions takes nothing returns boolean
return ((GetLearnedSkill()) == 'A002' and (GetUnitAbilityLevel(GetTriggerUnit(), 'A002') == 1 ))
endfunction
function FilterAlliesInRange takes nothing returns boolean
local unit filteredUnit = GetFilterUnit()
local real auraRadius = 400.0
return (IsUnitAlly(filteredUnit, GetTriggerPlayer()) and IsUnitType(filteredUnit, UNIT_TYPE_HERO) and not (filteredUnit == GetTriggerUnit()))
endfunction
function Trig_Formation_Actions takes nothing returns nothing
local unit caster = GetTriggerUnit()
local group alliesInRange = CreateGroup()
local filterfunc filter = Filter(function FilterAlliesInRange)
local integer abilityLevel = 0
local integer armorBonus = 0
local real auraRadius = 400.0
call UnitAddAbility(caster, 'ForA') //Adds a non-hero ability that does armor-Aura effect.
loop
set abilityLevel = GetUnitAbilityLevel(caster, 'A002')
call GroupEnumUnitsInRange(alliesInRange, GetUnitX(caster), GetUnitY(caster), auraRadius, filter) //Looking for ally heroes in range
set armorBonus = abilityLevel + CountUnitsInGroup(alliesInRange) //Deciding what level the Aura should be
if not (armorBonus == GetUnitAbilityLevel(caster, 'ForA')) then //If the level of the Aura is already what it should be, then skip the next two actions
call UnitRemoveAbility(caster, 'ForB') //This removes the buff from the old level of the ability. Same result without this string.
call SetUnitAbilityLevel(caster, 'ForA', armorBonus) //Set the level of the Aura to the calculated armorBonus
endif
call TriggerSleepAction(0.1) //Check 10 times per second
endloop
endfunction