Spell causes horrifying lag

cr4xzZz

Also known as azwraith_ftL.
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~

† Ғσſ ŧħə ѕαĸε Φƒ ~Ğ䣚~ †
>>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!
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.
> 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~

† Ғσſ ŧħə ѕαĸε Φƒ ~Ğ䣚~ †
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
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 The Helper:
    It happens in corporations. They just absorb the companies they buy and it is not about the love of making awesome games it is how much money can we make with the least amount of cost.
  • The Helper The Helper:
    Blizzard is watered down now hopefully they can pull it together
  • The Helper The Helper:
    they got a server engineer job opening :)
  • Ghan Ghan:
    I really do not want to move to California otherwise I might consider it.
  • The Helper The Helper:
    yeah California is not anywhere you really want to live
  • The Helper The Helper:
    That is why I did not take the job Blizzard offered me back in the day, there is no way I could have moved my family there on what they were offering, not even close and that was like 20 years ago
  • The Helper The Helper:
    yeah they wanted me on the tech support team when they did not get me they got one of the next MVPs in Dinobot
  • The Helper The Helper:
    Dinobot was one of the youngest of the MVPs tkron probably could have worked for Blizzard but he had a good job in Chicago doing business programming already
  • The Helper The Helper:
    Dinobot probably still works for Blizzard would love to reconnect with that guy
  • The Helper The Helper:
    I wonder what ever happened to Wargasm?
  • The Helper The Helper:
    This new version of Xenforo really is awesome
  • Ghan Ghan:
    Wargasm is still around. He works for the domain registrar where thehelper.net is kept.

    Members online

    No members online now.

    Affiliates

    Hive Workshop
    Top