• 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.

[JASS] Buggy Trigger

Status
Not open for further replies.
Level 3
Joined
Dec 20, 2007
Messages
44
I'm having problems with this trigger, specifically when I use it there is a 1-2 second lag spike where my CPU usage spikes as well. As a note, A01Y is a dummy ability based off of channel, A01Z is a spellbook that holds A020, a negative armor gain based off of spiked carapace. (The premises behind the spell being a DoT that applies a stacking armor debuff each tick)

JASS:
function Trig_expose_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A01Y'
endfunction

function Trig_expose_Actions takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local unit t = GetSpellTargetUnit()
    local real damage = I2R(GetHeroAgi(u,true))*.5
    local integer dura = GetUnitAbilityLevel(u, 'A01Y')+5
    local integer i = 1
    
    call UnitAddAbility(t,'A01Z')
    call SetUnitAbilityLevel(t,'A020',1)
    call SetPlayerAbilityAvailable(GetOwningPlayer(t), 'A01Z', false)
    call PolledWait2(0.25)
    loop
        exitwhen i > dura
        call UnitDamageTarget2(u, t, damage, false)
        call SetUnitAbilityLevel(t,'A020', i)
        call PolledWait2(2.0)
        set i = i + 1
    endloop
    
    call SetUnitAbilityLevel(t,'A020',0)
    call UnitRemoveAbility(t,'A01Z')
    set u = null
    set t = null
endfunction

//===========================================================================
function InitTrig_expose takes nothing returns nothing
    set gg_trg_expose = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_expose, EVENT_PLAYER_UNIT_SPELL_FINISH )
    call TriggerAddCondition( gg_trg_expose, Condition( function Trig_expose_Conditions ) )
    call TriggerAddAction( gg_trg_expose, function Trig_expose_Actions )
endfunction
 
Level 3
Joined
Dec 20, 2007
Messages
44
This is the code for polledwait2 (got it from the forums somewhere, can't remember offhand though)


JASS:
function PolledWait2 takes real duration returns nothing
 local real timeRemaining
 local real st=TimerGetElapsed( bj_gameStartedTimer)
    if st <= 0 then
        set bj_gameStartedTimer = CreateTimer()
        call TimerStart(bj_gameStartedTimer, 1000000, false, null)
    endif
    if (duration > 0) then
        loop
            set timeRemaining = duration - TimerGetElapsed( bj_gameStartedTimer) + st
            exitwhen timeRemaining <= 0
            if (timeRemaining > bj_POLLED_WAIT_SKIP_THRESHOLD) then
                call TriggerSleepAction(0.1 * timeRemaining)
            else
                call TriggerSleepAction(bj_POLLED_WAIT_INTERVAL)
            endif
        endloop
    endif
endfunction
 
Status
Not open for further replies.
Top