• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Delay between aura effects.

Status
Not open for further replies.
Level 4
Joined
Feb 2, 2009
Messages
71
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.
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
 
Level 6
Joined
Sep 5, 2007
Messages
264
Get into the object editor, go to the "buffs" section, find the buff that your ability uses, press control-D. Next to your ability's name is a "raw-code".

Just use UnitRemoveAbility(unit, raw-code), using the buff's raw-code. The flaw in this, is that you have to do it for all the effected units (pick all units in range), which can result in a fair CPU load, depending on how often you do it.
 
Level 4
Joined
Feb 2, 2009
Messages
71
Isn't that was I just did?
JASS:
call UnitRemoveAbility(caster, 'ForB')
When I press ctrl+D it says ForB:BHad(Formation Aura). And I'm under the buff section.
I'm pretty sure I should use ForB, don't know what BHad is though.

And as I said. There's no difference when I use this line compared to when I don't.
 
Level 6
Joined
Sep 5, 2007
Messages
264
That's the right raw-code, your problem is somewhere else... I'd have to assume it's with the "TriggerSleepAction", never put them inside a loop. Just make the trigger run on a periodic timer.

Sorry about the delayed response, I haven't been on for a few days :hohum:
 
Status
Not open for further replies.
Top