Trigger Lags a bit

Doom-Angel

Jass User (Just started using NewGen)
Reaction score
167
JASS:
function Fire_Wall_Conditions takes nothing returns boolean
    return (GetSpellAbilityId() == 'ANcl')
endfunction


function CreateFireWall takes nothing returns boolean
    local Data vars = ABCT_GetData()
    local integer i = 0
    local group g = CreateGroup()
    local unit first
    local boolean b
    if(vars.flag) then
       set vars.r = vars.r+50
       set vars.moveX = vars.targetX+(vars.r)*Cos(vars.angle+90 * bj_DEGTORAD)
       set vars.moveY = vars.targetY+(vars.r)*Sin(vars.angle+90 * bj_DEGTORAD)
       set b = CheckPathability(vars.moveX,vars.moveY) and  CheckDestructibleTrick(vars.moveX,vars.moveY)
       if(b) then
          set vars.dummy[vars.i] = CreateUnit(GetOwningPlayer(vars.u),'n001',vars.moveX,vars.moveY, 25.00)
          call UnitApplyTimedLife(vars.dummy[vars.i],'BTLF',4)
          set vars.i = vars.i+1
       endif
       set vars.flag = b
       set vars.moveX = vars.targetX+(vars.r)*Cos(vars.angle-90 * bj_DEGTORAD)
       set vars.moveY = vars.targetY+(vars.r)*Sin(vars.angle-90 * bj_DEGTORAD)
       set b = CheckPathability(vars.moveX,vars.moveY) and CheckDestructibleTrick(vars.moveX,vars.moveY)
       if(b) then
          set vars.dummy[vars.i] = CreateUnit(GetOwningPlayer(vars.u),'n001',vars.moveX,vars.moveY, 25.00)
          call UnitApplyTimedLife(vars.dummy[vars.i],'BTLF',4)
          set vars.i = vars.i+1
       endif
       if(vars.flag) then
           set vars.flag = b
       endif
    endif
      loop
        exitwhen(i>vars.i)
        call GroupEnumUnitsInRange(g,GetUnitX(vars.dummy<i>),GetUnitY(vars.dummy<i>),65,null)
          loop
            set first = FirstOfGroup(g)
            exitwhen(first == null)
            if(IsUnitEnemy(first,GetOwningPlayer(vars.u)) and GetUnitState(first, UNIT_STATE_LIFE) &gt; 0.405 and ModuloInteger(vars.counter, 15) == 0 ) then
               call UnitDamageTarget(vars.u,first,50,true,false,ATTACK_TYPE_MAGIC,DAMAGE_TYPE_FIRE,WEAPON_TYPE_WHOKNOWS)
               call DestroyEffect(AddSpecialEffectTarget(&quot;Abilities\\Spells\\Items\\AIfb\\AIfbSpecialArt.mdl&quot;,first,&quot;chest&quot;))
            endif
            call GroupRemoveUnit(g,first)
          endloop
        set i = i+1
      endloop
    call DestroyGroup(g)
    set vars.counter = vars.counter+1
    return vars.i &gt; 80
endfunction


function Fire_Wall_Actions takes nothing returns nothing
    local Data vars = Data.create()
    local location loc = GetSpellTargetLoc()
    set vars.flag = true
    set vars.counter = 0
    set vars.u = GetTriggerUnit()
    set vars.x = GetUnitX(vars.u)
    set vars.y = GetUnitY(vars.u)
    set vars.targetX = GetLocationX(loc)
    set vars.targetY = GetLocationY(loc)
    set vars.r = 0
    set vars.angle = GetUnitFacing(vars.u) * bj_DEGTORAD
    set vars.dummy[0] = CreateUnit(GetOwningPlayer(vars.u),&#039;n001&#039;,vars.targetX,vars.targetY, 25.00)
    call UnitApplyTimedLife(vars.dummy[0],&#039;BTLF&#039;,4)
    set vars.i = 1
    call ABCT_Start(function CreateFireWall,vars,0.075)
    call Data.destroy(vars)
    call RemoveLocation(loc)
    set loc = null
endfunction

//===========================================================================
function InitTrig_Fire_Wall_U takes nothing returns nothing
    set gg_trg_Fire_Wall_U = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Fire_Wall_U, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Fire_Wall_U, Condition( function Fire_Wall_Conditions ) )
    call TriggerAddAction( gg_trg_Fire_Wall_U, function Fire_Wall_Actions )
endfunction</i></i>

after a few uses with this trigger the game becomes quite laggy for a few moments and after a while goes somewhat normal again...
anyone have a clue what might cause this lag?
 

phyrex1an

Staff Member and irregular helper
Reaction score
447
First of all, it seems as you have a chance to loop forever. vars.i is only incremented inside the if block. I assume that you want to check against vars.counter.
Second thing is that you do the entire loop even if Modulo(counter, 15) != 0, that's kinda unnecessary considering that the actions only happen when it is 0. Wrap the loop in a conditional instead.
Last thing is that the IsUnitEnemy(first,GetOwningPlayer(vars.u)) and GetUnitState(first, UNIT_STATE_LIFE) > 0.405 could as well be a filter in the GroupEnumUnitsInRange. I don't know if that increases the performance thought.

Good luck :)
 

Doom-Angel

Jass User (Just started using NewGen)
Reaction score
167
>First of all, it seems as you have a chance to loop forever. vars.i is only incremented inside the if block. I assume that you want to check against vars.counter.
oh i forgot about that one right thanks

>Second thing is that you do the entire loop even if Modulo(counter, 15) != 0, that's kinda unnecessary considering that the actions only happen when it is 0. Wrap the loop in a conditional instead.
thanks again fixed that one too. (you are good :p)

>Last thing is that the IsUnitEnemy(first,GetOwningPlayer(vars.u)) and GetUnitState(first, UNIT_STATE_LIFE) > 0.405 could as well be a filter in the GroupEnumUnitsInRange. I don't know if that increases the performance thought.

i used to have it before but it had some problems anyway i tried it now and it still having the same problem anyway i left it the way it is.


so i checked the spell and the stuff you gave me works a lot better but after a while you could still see it a bit laggy tough the stuff you gave me improved it by a lot!
when i make mass of this skill it lags but i guess because of the mass of units but after they are gone it still keeps lagging the game a bit like before just less laggy....

anyway do you think you could find anything else to cause it?
improved code:
JASS:
function Fire_Wall_Conditions takes nothing returns boolean
    return (GetSpellAbilityId() == &#039;ANcl&#039;)
endfunction


function CreateFireWall takes nothing returns boolean
    local Data vars = ABCT_GetData()
    local integer i = 0
    local group g = CreateGroup()
    local unit first
    local boolean b
    if(vars.flag) then
       set vars.r = vars.r+50
       set vars.moveX = vars.targetX+(vars.r)*Cos(vars.angle+90 * bj_DEGTORAD)
       set vars.moveY = vars.targetY+(vars.r)*Sin(vars.angle+90 * bj_DEGTORAD)
       set b = CheckPathability(vars.moveX,vars.moveY) and  CheckDestructibleTrick(vars.moveX,vars.moveY)
       if(b) then
          set vars.dummy[vars.i] = CreateUnit(GetOwningPlayer(vars.u),&#039;n001&#039;,vars.moveX,vars.moveY, 25.00)
          call UnitApplyTimedLife(vars.dummy[vars.i],&#039;BTLF&#039;,4)
          set vars.i = vars.i+1
       endif
       set vars.flag = b
       set vars.moveX = vars.targetX+(vars.r)*Cos(vars.angle-90 * bj_DEGTORAD)
       set vars.moveY = vars.targetY+(vars.r)*Sin(vars.angle-90 * bj_DEGTORAD)
       set b = CheckPathability(vars.moveX,vars.moveY) and CheckDestructibleTrick(vars.moveX,vars.moveY)
       if(b) then
          set vars.dummy[vars.i] = CreateUnit(GetOwningPlayer(vars.u),&#039;n001&#039;,vars.moveX,vars.moveY, 25.00)
          call UnitApplyTimedLife(vars.dummy[vars.i],&#039;BTLF&#039;,4)
          set vars.i = vars.i+1
       endif
       if(vars.flag) then
           set vars.flag = b
       endif
    endif
      loop
        exitwhen(i&gt;vars.i)
        call GroupEnumUnitsInRange(g,GetUnitX(vars.dummy<i>),GetUnitY(vars.dummy<i>),65,null)
          loop
            set first = FirstOfGroup(g)
            exitwhen(first == null or ModuloInteger(vars.counter, 13) != 0 )
            if(IsUnitEnemy(first,GetOwningPlayer(vars.u)) and GetUnitState(first, UNIT_STATE_LIFE) &gt; 0.405) then
               call UnitDamageTarget(vars.u,first,50,true,false,ATTACK_TYPE_MAGIC,DAMAGE_TYPE_FIRE,WEAPON_TYPE_WHOKNOWS)
               call DestroyEffect(AddSpecialEffectTarget(&quot;Abilities\\Spells\\Items\\AIfb\\AIfbSpecialArt.mdl&quot;,first,&quot;chest&quot;))
            endif
            call GroupRemoveUnit(g,first)
          endloop
        set i = i+1
      endloop
    call DestroyGroup(g)
    set vars.counter = vars.counter+1
    return vars.counter &gt; 80 or vars.i &gt; 70
endfunction


function Fire_Wall_Actions takes nothing returns nothing
    local Data vars = Data.create()
    local location loc = GetSpellTargetLoc()
    set vars.flag = true
    set vars.counter = 0
    set vars.u = GetTriggerUnit()
    set vars.x = GetUnitX(vars.u)
    set vars.y = GetUnitY(vars.u)
    set vars.targetX = GetLocationX(loc)
    set vars.targetY = GetLocationY(loc)
    set vars.r = 0
    set vars.angle = GetUnitFacing(vars.u) * bj_DEGTORAD
    set vars.dummy[0] = CreateUnit(GetOwningPlayer(vars.u),&#039;n001&#039;,vars.targetX,vars.targetY, 25.00)
    call UnitApplyTimedLife(vars.dummy[0],&#039;BTLF&#039;,4)
    set vars.i = 1
    call ABCT_Start(function CreateFireWall,vars,0.075)
    call Data.destroy(vars)
    call RemoveLocation(loc)
    set loc = null
endfunction

//===========================================================================
function InitTrig_Fire_Wall_U takes nothing returns nothing
    set gg_trg_Fire_Wall_U = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Fire_Wall_U, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Fire_Wall_U, Condition( function Fire_Wall_Conditions ) )
    call TriggerAddAction( gg_trg_Fire_Wall_U, function Fire_Wall_Actions )
endfunction</i></i>

hope you will find it and thanks again :)
 

Doom-Angel

Jass User (Just started using NewGen)
Reaction score
167
Bump

after checking some stuff out i suspect that the cause of it might be the use of ABCT - is it possible?
 

Joker(Div)

Always Here..
Reaction score
86
ABC works the same way as ABCT. Most likely though, ABCT proly did the create the lag. Possible, but not likely.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      • Ghan
        Administrator - Servers are fun

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top