HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Does this leak/lag?

05-23-2010, 07:58 PM#1
Idontneedaname
Okay, I've got something very simple here. It's the basic Death Wave of the Dreadlord, but it deals additionally three times the Dreadlord's Intelligence.
My question is if this leaks or causes lag over time.

Collapse JASS:
function DeathWaveAdditionalDamage takes nothing returns nothing
local unit DamagedUnit = GetTriggerUnit()
local unit DamageSource = GetEventDamageSource()

    call DisableTrigger(GetTriggeringTrigger())
    call UnitDamageTarget(DamageSource, DamagedUnit, I2R(3*GetHeroStatBJ(bj_HEROSTAT_INT, DamageSource, true)), true, false, ATTACK_TYPE_HERO, DAMAGE_TYPE_UNKNOWN, WEAPON_TYPE_WHOKNOWS)
    call DestroyTrigger(GetTriggeringTrigger())

endfunction


function Trig_Unbezeichneter_Ausl__ser_001_Conditions takes nothing returns boolean
    if GetSpellAbilityId() == 'AUcs' then
        return true
    endif
    return false
endfunction

function Trig_Unbezeichneter_Ausl__ser_001_Actions takes nothing returns nothing
local unit Caster = GetSpellAbilityUnit()
local group Enemies = GetUnitsInRangeOfLocMatching(2000.00, GetUnitLoc(Caster), null )
local unit First
local integer LoopInt = 1
local trigger array DeathWaveTrigger

    loop
        set First = FirstOfGroup(Enemies)
        exitwhen First == null
        if IsUnitEnemy(First, GetOwningPlayer(Caster)) == true then
            set DeathWaveTrigger[LoopInt] = CreateTrigger()
            call TriggerRegisterUnitEvent(DeathWaveTrigger[LoopInt], First, EVENT_UNIT_DAMAGED)
            call TriggerAddAction(        DeathWaveTrigger[LoopInt], function DeathWaveAdditionalDamage)
            set LoopInt = LoopInt + 1
        endif
        call GroupRemoveUnit(Enemies, First)
        set First = null
    endloop

    call DestroyGroup(Enemies)
    set Enemies = null
    set Caster  = null

    call TriggerSleepAction(1.00)
    loop
        set LoopInt = LoopInt - 1
        exitwhen LoopInt == 0
        call DisableTrigger(DeathWaveTrigger[LoopInt])
        call DestroyTrigger(DeathWaveTrigger[LoopInt])
        set DeathWaveTrigger[LoopInt] = null
    endloop

endfunction

function InitTrig_DeathWave takes nothing returns nothing
    set gg_trg_DeathWave = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_DeathWave, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_DeathWave, Condition( function Trig_Unbezeichneter_Ausl__ser_001_Conditions ) )
    call TriggerAddAction( gg_trg_DeathWave, function Trig_Unbezeichneter_Ausl__ser_001_Actions )
endfunction
05-23-2010, 08:20 PM#2
DioD
why not to test it?
05-24-2010, 12:52 AM#3
Fledermaus
You're not nulling your local variables in the DeathWaveAdditionalDamage actions.

Also GetUnitLoc(Caster) leaks too.
05-24-2010, 09:56 AM#4
Idontneedaname
Thank you very much, I fixed those.
But does creating that much triggers cause lag after some time, even if they're destroyed?
05-24-2010, 10:37 AM#5
DioD
No.
proof = dota
05-24-2010, 02:40 PM#6
Bribe
You have JNGP and the latest War3 patch installed? That would give you much better scope of your variables.
05-25-2010, 10:45 AM#7
Idontneedaname
JNGP - no,
latest patch - yes.

Thank you for your answers, guys; I made further changes and it should be leakfree now.