Spell causes horrifying lag

cr4xzZz

Also known as azwraith_ftL.
Reaction score
51
I created a spell based on Soul Burn and triggered the damage, because it has to be based on the caster's attributes. However, on cast the game bugs and lags for ~10-15 seconds and I can't seem to find the reason.

I'm not sure it's in the code, because it has no bugs at all.
JASS:

scope Doom

globals
    private constant integer AID_DOOM = 'A00G'
    private constant integer BID_DOOM = 'B009'
endglobals

private struct Data
    unit cast
    unit targ
    integer ticks 
endstruct

private function Conditions takes nothing returns boolean
    return GetSpellAbilityId() == AID_DOOM
endfunction

private function Callback takes nothing returns boolean
    local Data d = ABCT_GetData()
    local real dmg = GetHeroStr(d.cast, true)
    if GetWidgetLife(d.targ) < 0.405 or d.ticks < 0 or GetUnitAbilityLevel(d.targ, BID_DOOM) < 1 then
        call d.destroy()
        return true
    else
        call UnitDamageTarget(d.cast, d.targ, dmg, false, false, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_MAGIC, null)
    endif
    set d.ticks = d.ticks - 1
    return false
endfunction

private function Actions takes nothing returns nothing
    local Data d = Data.create()
    local integer lvl
    set d.cast = GetTriggerUnit()
    set d.targ = GetSpellTargetUnit()
    set lvl = GetUnitAbilityLevel(d.cast, AID_DOOM)
    if GetHeroInt(d.cast, true) > 0 and GetHeroInt(d.cast, true) < 36 then
        set d.ticks = 5
    elseif GetHeroInt(d.cast, true) > 35 and GetHeroInt(d.cast, true) < 51 then
        set d.ticks = 6
    elseif GetHeroInt(d.cast, true) > 50 and GetHeroInt(d.cast, true) < 66 then
        set d.ticks = 7
    elseif GetHeroInt(d.cast, true) > 65 and GetHeroInt(d.cast, true) < 81 then
        set d.ticks = 8
    elseif GetHeroInt(d.cast, true) > 80 and GetHeroInt(d.cast, true) < 96 then
        set d.ticks = 9
    else
        set d.ticks = 10
    endif
    call ABCT_Start(function Callback, d, 1.)
endfunction

function InitTrig_Doom takes nothing returns nothing
    local trigger trig = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(trig, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(trig, Condition(function Conditions))
    call TriggerAddAction(trig, function Actions)
endfunction

endscope
 

~GaLs~

† Ғσſ ŧħə ѕαĸε Φƒ ~Ğ䣚~ †
Reaction score
180
>>game bugs and lags for ~10-15 seconds
1. The target dies and the timer isn't stop?
2. The tick reaches -1 and the timer isn't stop?
 

Dr.Jack

That's Cap'n to you!
Reaction score
109
Well the code seems to be ok as you said. There are no crazy loops or leaks.


>1. The target dies and the timer isn't stop?
2. The tick reaches -1 and the timer isn't stop?

Check the conditions, that can't happen.
Try to add messages around the trigger, see what messages appear and when.
Are you sure there is no other piece of code that causes this?
 

cr4xzZz

Also known as azwraith_ftL.
Reaction score
51
> 2. The tick reaches -1 and the timer isn't stop?
No, the lag starts just when I cast the spell.

> Are you sure there is no other piece of code that causes this?
Rechecked. This trigger is alone.

> Try to add messages around the trigger, see what messages appear and when.
Can't see wether if it displays on time or not... It lags, remember? :rolleyes:

So, it's deffinitely not the code. Maybe soul burn has some stupid bugs? I remember once that I used Silence with a different effect and my fps dropped to 1-2 during the effect...
 

~GaLs~

† Ғσſ ŧħə ѕαĸε Φƒ ~Ğ䣚~ †
Reaction score
180
Tell us whether it is a periodic lag or continuous lag.

Periodic lag - Lag every X sec (Also means that the lag comes from the callback function)
Continuous lag - Lag non-stop (Means something is stucked inside your Ifs)
 

Cohadar

master of fugue
Reaction score
209
You are probably using some special effect with that spell that is not preloaded.
The code is all ok, except the fact that you suck at math
JASS:

private function Actions takes nothing returns nothing
    local Data d = Data.create()
    local integer lvl
    local integer Int
    set d.cast = GetTriggerUnit()
    set d.targ = GetSpellTargetUnit()
    set lvl = GetUnitAbilityLevel(d.cast, AID_DOOM)
    set Int = GetHeroInt(d.cast, true)    
    if Int < 36 then
        set d.ticks = 5
    elseif Int < 51 then
        set d.ticks = 6
    elseif Int < 66 then
        set d.ticks = 7
    elseif Int < 81 then
        set d.ticks = 8
    elseif Int < 96 then
        set d.ticks = 9
    else
        set d.ticks = 10
    endif
    call ABCT_Start(function Callback, d, 1.)
endfunction


and if you wanna get really wild:
JASS:

private function Actions takes nothing returns nothing
    local Data d = Data.create()
    local integer lvl
    local integer Int
    set d.cast = GetTriggerUnit()
    set d.targ = GetSpellTargetUnit()
    set lvl = GetUnitAbilityLevel(d.cast, AID_DOOM)
    set d.ticks = 5+ GetHeroInt(d.cast, true)/15
    call ABCT_Start(function Callback, d, 1.)
endfunction
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top