[Trigger] Why this cause lag?

Status
Not open for further replies.
Level 2
Joined
Feb 6, 2011
Messages
19
When I use this spell about 10 times really fast
it cause lag why?

  • aa
    • Event
      • Unit - A unit Cast Spell
    • Condition
      • (Ability being cast) Equal to Shadow Strike
    • Action
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • a Equal to 0
        • Then - Actions
          • Trigger - Turn on a <a>
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Target unit of ability being cast) has buff Shadow Strike Equal to TRUE
        • Then - Actions
          • Unit Group - Add (Target unit of ability being cast) to Group
        • Else - Actions
      • Set a = (a + 1)
      • Set b = (b + 1)
      • Set Damage[b] = (100.00 + (Real((Intelligence of (Casting unit) (Including bonuses)))))
      • Set Duration[b] = 50
      • Set Unit[b] = (Casting unit)
      • Set Target[b] = (Target unit of ability being cast)
  • a
    • ?대깽??
      • Time - Every 0.20 seconds of game time
    • 議곌굔
    • ?≪뀡
      • For each (Integer c) from 1 to b, do (Actions)
        • Loop - Actions
          • Set Duration[c] = (Duration[c] - 1)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Target[c] is in Group) Equal to TRUE
            • Then - Actions
              • Unit Group - Remove Target[c] from Group
              • Set Target[c] = No unit
              • Set Duration[c] = 0
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Duration[c] Equal to 0
            • Then - Actions
              • Unit - Order Unit[c] to damage Target[c] for Damage[c] using attack type magic and damage type Fire.
              • Set Target[c] = No unit
              • Set a = (a - 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • a Equal to 0
                • Then - Actions
                  • Set b = 0
                  • Trigger - Turn off (This trigger)
                • Else - Actions
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Interval[c] Equal to 0
                • Then - Actions
                  • Set Interval[c] = 5
                  • Unit - Order Unit[c] to damage Target[c] for Damage[c] using attack type magic and damage type Fire.
                • Else - Actions
                  • Set Interval[c] = (Interval[c] - 1)
Its lagging
What can I improve?
This trigger was made for target only DOT which should be unstackable
Why lagging and What can I improve?
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,241
Arrays start at 0.
Make sure the for loop is exiting correctly and not looping until the op limit is hit.

Your loop code does not make sense. It adds it to Group and then the first itteration instantly removes it from Group and makes it null. You then order null to be damaged (nonsense). I think you need to remake the whole loop, it does not seem to be making much sense to me.
 
this is my experiment...

instead of 'has buff = true' I used custom values of the unit but you must set the custom value first...after the loop is over set it again to other custom values, this way you dont need the checking of buffs...I do this coz custom values cannot be dispelled...

anyway, you really dont need the unit group, timer is enough...like DS said, your trigger doesnt make sense...
 
Level 2
Joined
Feb 6, 2011
Messages
19
How can I indexing?
I am using it custom value instead of group
and Dr Super Good : you dont get buff immediatly when shadow strike is casted
so it makes sense and it works but laggy
But what do u means by Arrays start at 0.
Make sure the for loop is exiting correctly and not looping until the op limit is hit.
I dont understand
Anyway why this cause lag?
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,241
You are using shadow strike as the base ability? In that case you probably set the damage interval to 0 or other stats to buggy values. I distinctly remember that shadow strike will cause huge performance degredation (no lag, but very low FPS) when cast with some of its stats set to 0. Set it to longer than the ability lasts (eg 3600 seconds), it will never run as the duration is insanly long and will aviod the huge performance consumption that shadow strike has with 0 damage interval.

Arrays start at index 0.... YourArray[0] is a completly valid piece of code and will work and store / fetch data from index 0 of an array. This is a standard programmer expectation that blizzard actually managed to follow. Additionally WC3 arrays are actually array lists so they will dynamically expand as additional indicies are needed (upwards, negative indicies will always be invalid). WC3 arrays are limmited to 2^13 indicies.
 
Last edited:
OR instead of buffs use Special Effects...


  • DOT
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Shadow Strike
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • a Equal to 0
        • Then - Actions
          • Trigger - Turn on DOT Loop <gen>
        • Else - Actions
      • Set a = (a + 1)
      • Set b = (b + 1)
      • Set Unit[b] = (Triggering unit)
      • Set Target[b] = (Target unit of ability being cast)
      • Set Damage[b] = (100.00 + (Real((Intelligence of Unit[b] (Include bonuses)))))
      • Set Duration[b] = 50.00
      • Special Effect - Create a special effect attached to the overhead of (Target unit of ability being cast) using Abilities\Spells\Other\SoulBurn\SoulBurnbuff.mdl
      • Set Sfx[b] = (Last created special effect)
  • DOT Loop
    • Events
      • Time - Every 0.20 seconds of game time
    • Conditions
    • Actions
      • For each (Integer c) from 1 to b, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Duration[c] Greater than 0.00
              • (Target[c] is alive) Equal to True
            • Then - Actions
              • Set Duration[c] = (Duration[c] - 0.20)
              • Unit - Cause Unit[c] to damage Target[c], dealing Damage[c] damage of attack type Spells and damage type Normal
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Or - Any (Conditions) are true
                    • Conditions
                      • Duration[c] Less than or equal to 0.00
                      • (Target[c] is alive) Equal to False
                • Then - Actions
                  • Special Effect - Destroy Sfx[c]
                  • Set a = (a - 1)
                • Else - Actions
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • a Equal to 0
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions
 
Level 2
Joined
Feb 6, 2011
Messages
19
So Dr Super Good, you mean I must not use Shadow Strike as base ability
and I have to starting using array from 0?
So I must set the array like this?

  • Ritual of Evil 1
    • 이벤트
      • Unit - A unit 능력 효과 시작
    • 조건
      • (Ability being cast) Equal to 악마의 의식
    • 액션
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • HS_RE1 Equal to 0
        • Then - Actions
          • Trigger - Turn on Ritual of Evil 2 <생성>
        • Else - Actions
          • Set HS_RE1 = (HS_RE1 + 1)
          • Set HS_RE2 = (HS_RE2 + 1)
  • Ritual of Evil 2
    • 이벤트
      • Time - Every 0.10 seconds of game time
    • 조건
    • 액션
      • For each (Integer HS_RE3) from 0 to HS_RE2, do (Actions)
        • Loop - Actions
Make it to use Array from 0 and Loop starts from 0.
Also change base ability to another.
Are these all I have to do?
 
Level 16
Joined
Jun 24, 2009
Messages
1,409
Here you are an example for a good index system
first set the maximum array value, try to set it to a proper value so not too small that the trigger could exceed and not too big that can cause lagg
  • Init
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Ability
    • Actions
      • Set Get = False
      • For each (Integer A) from 1 to Max, do (Actions) [loop till the maximum size given in an init trigger]
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Get Equal to False
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Recycle[(Integer A)] Equal to True [checks if the integer A slot is free]
                • Then - Actions
                  • Set Index = (Integer A)
                  • Set Get= True [with this the trigger only choose the first free slot]
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Integer A) Equal to Max
                    • Then - Actions
                      • Set Max = (Max + 1) [if the current size is not enought it increases it]
                      • Set Recycle[Max] = True
                    • Else - Actions
            • Else - Actions
      • Set Caster[Index] = (Triggering unit)
      • Set Timer[Index] = (2.00 + (Real((Level of Ability for Caster[Index]))))
      • Set Etc.... [other things you want to store example locations or damage]
      • Set Has[Index] = True [this will check if the trigger still have to run for that unit]
      • Set Count = (Count + 1) [counts the number of units casted the spell]
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Loop <gen> is on) Equal to False
        • Then - Actions
          • Trigger - Turn on Loop <gen>
        • Else - Actions
  • Loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • For each (Integer Integer) from 1 to Max, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Has[Integer] Equal to True
            • Then - Actions
              • [Things you want to do]
              • Set Has[Index] = False
              • Set Count = (Count - 1)
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Count Equal to 0
                • Then - Actions
                  • Trigger - Turn off (This trigger)
                • Else - Actions
 
Last edited:

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,241
So Dr Super Good, you mean I must not use Shadow Strike as base ability
I will say again.... You most likly have set its cast time to 0 which means it applys the perodic damage hundreds of times a second. Even if the damage is 0, it will still deal damage (of quantitiy 0).

Try setting cast time to 10 seconds. I believe cast time with shadow strike is a special case (where it does not actually add cast time, but instead represents the damage delay period).
 
Status
Not open for further replies.
Top