HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

EVENT_UNIT_DAMAGED lags?

04-11-2007, 04:52 PM#1
zeroXD
Collapse JASS:
function Trig_Mark_of_the_Necromancer_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A03Y'
endfunction

function MarkOfTheNecromancer_Damage takes nothing returns nothing
local unit u = GetTriggerUnit()
local real dmg = GetEventDamage()
local real mana = dmg/100*(10+(udg_MotN_Level*20))
    call SetUnitState( udg_Reanimator, UNIT_STATE_MANA, GetUnitState(udg_Reanimator, UNIT_STATE_MANA)+mana )
    call AbilityEffectText( udg_Reanimator, GetUnitState(udg_Reanimator, UNIT_STATE_MANA)+mana, 25, 25, 255 )
set u = null
endfunction

function Trig_Mark_of_the_Necromancer_Actions takes nothing returns nothing
local unit target = GetSpellTargetUnit()
local unit caster = GetTriggerUnit()
local trigger t = CreateTrigger()
local integer level = GetUnitAbilityLevel( caster, 'A03Y' )
    set udg_MotN_Level = level
    call TriggerRegisterUnitEvent( t, target, EVENT_UNIT_DAMAGED )
    call TriggerAddAction( t, function MarkOfTheNecromancer_Damage )
    loop
        call TriggerSleepAction( 0.01 )
        exitwhen GetUnitAbilityLevel( target, 'B019' ) == 0
    endloop
    call DestroyTrigger( t )
set t = null
set caster = null
set target = null
endfunction

//===========================================================================
function InitTrig_Mark_of_the_Necromancer takes nothing returns nothing
    set gg_trg_Mark_of_the_Necromancer = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Mark_of_the_Necromancer, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Mark_of_the_Necromancer, Condition( function Trig_Mark_of_the_Necromancer_Conditions ) )
    call TriggerAddAction( gg_trg_Mark_of_the_Necromancer, function Trig_Mark_of_the_Necromancer_Actions )
endfunction

I have two spells that works like this, but my problem is; all of them lags. A lot.
Why does this happen, and what can I do about it?
04-11-2007, 05:04 PM#2
akolyt0r
The loop seems to be infinite (cant say that for sure because i dont know what abilityeffecttext does)
04-11-2007, 05:04 PM#3
Captain Griffen
You leak a trigger action.
04-11-2007, 05:28 PM#4
zeroXD
The loop is not infinite, it ends when the buff expires. (B019)
EDIT: AbilityEffectText is just a floating text function for stuff like a critical strike... Removed it because it's impossible read the text because the target suffer too much damage.

Okay, I got another question; how do I fix the trigger action leak?
04-11-2007, 05:39 PM#5
Captain Griffen
Look in your common.j file.

If you haven't extracted it from the mpq (I think it's the patch one?) do so. Best thing you'll ever do for JASS.
04-11-2007, 06:11 PM#6
Vexorian
AbilityEffectText seems to be called a lot of times, so I would like to see its code, it may have some important leaks.