What makes this trigger jerky.

keychup

Active Member
Reaction score
34
Effect: When A unit casts this spell a buff will be placed on him and he will turn red. when the buff is removed his color turns back to normal over 1 second. While Buff is placed on him his atkspd and movspd are doubled and blocks incoming damage by ½

Trigger 1: This marks the unit to be colored
Trigger:
  • ragingbull mark
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to E - Raging Bull
    • Actions
      • Unit - Add E - Raging Bull (Unit Marker) to (Triggering unit)


Trigger 2: This makes a hashtable
Trigger:
  • color hashtable
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set zz_color_hash = (Last created hashtable)


Trigger 3: This colors the units
Trigger:
  • color effect
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Set zz_UnitGroupA = (Units in (Playable map area))
      • Unit Group - Pick every unit in zz_UnitGroupA and do (Actions)
        • Loop - Actions
          • Set zz_color_unit = (Load 0 of (Key (Picked unit)) in zz_color_hash)
          • Set zz_color_red_hue = (Load 1 of (Key (Picked unit)) from zz_color_hash)
          • Set zz_color_red_rate = (Load 2 of (Key (Picked unit)) from zz_color_hash)
          • Set zz_color_green_hue = (Load 3 of (Key (Picked unit)) from zz_color_hash)
          • Set zz_color_green_rate = (Load 4 of (Key (Picked unit)) from zz_color_hash)
          • Set zz_color_blue_hue = (Load 5 of (Key (Picked unit)) from zz_color_hash)
          • Set zz_color_blue_rate = (Load 6 of (Key (Picked unit)) from zz_color_hash)
          • Set zz_color_transp_hue = (Load 7 of (Key (Picked unit)) from zz_color_hash)
          • Set zz_color_transp_rate = (Load 8 of (Key (Picked unit)) from zz_color_hash)
          • Set zz_color_red_hue = (zz_color_red_hue + zz_color_red_rate)
          • Hashtable - Save zz_color_red_hue as 1 of (Key (Picked unit)) in zz_color_hash
          • Set zz_color_green_hue = (zz_color_green_hue + zz_color_green_rate)
          • Hashtable - Save zz_color_green_hue as 3 of (Key (Picked unit)) in zz_color_hash
          • Set zz_color_blue_hue = (zz_color_blue_hue + zz_color_blue_rate)
          • Hashtable - Save zz_color_blue_hue as 5 of (Key (Picked unit)) in zz_color_hash
          • Set zz_color_transp_hue = (zz_color_transp_hue + zz_color_transp_rate)
          • Hashtable - Save zz_color_transp_hue as 7 of (Key (Picked unit)) in zz_color_hash
          • Animation - Change zz_color_unit's vertex coloring to (zz_color_red_hue%, zz_color_green_hue%, zz_color_green_hue%) with zz_color_transp_hue% transparency
          • -------- Added Effects --------
          • Trigger - Run ragingbull effect <gen> (checking conditions)
      • Custom script: call DestroyGroup (udg_zz_UnitGroupA)


Trigger 4: Trigger 3 runs this trigger. this trigger changes the modifications to the unit
Trigger:
  • ragingbull effect
    • Events
    • Conditions
    • Actions
      • Set zz_UnitGroupA = (Units in (Playable map area) matching ((Level of E - Raging Bull (Unit Marker) for (Matching unit)) Greater than 0))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in zz_UnitGroupA) Greater than 0
        • Then - Actions
          • Unit Group - Pick every unit in zz_UnitGroupA and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Picked unit) has buff Raging Bull) Equal to True
                • Then - Actions
                  • Set zz_color_unit = (Picked unit)
                  • Hashtable - Save Handle Ofzz_color_unit as 0 of (Key (Picked unit)) in zz_color_hash
                  • Set zz_color_red_hue = 100.00
                  • Hashtable - Save zz_color_red_hue as 1 of (Key (Picked unit)) in zz_color_hash
                  • Set zz_color_red_rate = 0.00
                  • Hashtable - Save zz_color_red_rate as 2 of (Key (Picked unit)) in zz_color_hash
                  • Set zz_color_green_hue = 0.00
                  • Hashtable - Save zz_color_green_hue as 3 of (Key (Picked unit)) in zz_color_hash
                  • Set zz_color_green_rate = 0.00
                  • Hashtable - Save zz_color_green_rate as 4 of (Key (Picked unit)) in zz_color_hash
                  • Set zz_color_blue_hue = 0.00
                  • Hashtable - Save zz_color_blue_hue as 5 of (Key (Picked unit)) in zz_color_hash
                  • Set zz_color_blue_rate = 0.00
                  • Hashtable - Save zz_color_blue_rate as 6 of (Key (Picked unit)) in zz_color_hash
                  • Set zz_color_transp_hue = 0.00
                  • Hashtable - Save zz_color_transp_hue as 7 of (Key (Picked unit)) in zz_color_hash
                  • Set zz_color_transp_rate = 0.00
                  • Hashtable - Save zz_color_transp_rate as 8 of (Key (Picked unit)) in zz_color_hash
                • Else - Actions
                  • Set zz_color_unit = (Picked unit)
                  • Hashtable - Save Handle Ofzz_color_unit as 0 of (Key (Picked unit)) in zz_color_hash
                  • Set zz_color_red_hue = 100.00
                  • Hashtable - Save zz_color_red_hue as 1 of (Key (Picked unit)) in zz_color_hash
                  • Set zz_color_red_rate = 0.00
                  • Hashtable - Save zz_color_red_rate as 2 of (Key (Picked unit)) in zz_color_hash
                  • Set zz_color_green_hue = 0.00
                  • Hashtable - Save zz_color_green_hue as 3 of (Key (Picked unit)) in zz_color_hash
                  • Set zz_color_green_rate = 3.33
                  • Hashtable - Save zz_color_green_rate as 4 of (Key (Picked unit)) in zz_color_hash
                  • Set zz_color_blue_hue = 0.00
                  • Hashtable - Save zz_color_blue_hue as 5 of (Key (Picked unit)) in zz_color_hash
                  • Set zz_color_blue_rate = 3.33
                  • Hashtable - Save zz_color_blue_rate as 6 of (Key (Picked unit)) in zz_color_hash
                  • Set zz_color_transp_hue = 0.00
                  • Hashtable - Save zz_color_transp_hue as 7 of (Key (Picked unit)) in zz_color_hash
                  • Set zz_color_transp_rate = 0.00
                  • Hashtable - Save zz_color_transp_rate as 8 of (Key (Picked unit)) in zz_color_hash
                  • Unit - Remove E - Raging Bull (Unit Marker) from (Picked unit)
        • Else - Actions
      • Custom script: call DestroyGroup (udg_zz_UnitGroupA)
 

Dirac

22710180
Reaction score
147
So what's the question? What's wrong? All i see is a bunch of unnecessary codes stored inside a hashtable when it clearly could use a simple unit indexing system to store them inside vars with their custom value
 

keychup

Active Member
Reaction score
34
Hint: The problem seems to be in Trigger 4. I tried disabling Trigger 4 and the game ran smoothly.
 

keychup

Active Member
Reaction score
34
So what's the question? What's wrong? All i see is a bunch of unnecessary codes stored inside a hashtable when it clearly could use a simple unit indexing system to store them inside vars with their custom value
I dont know what the problem is. Maybe you could find the problem. I actually found the problem was in trigger 4. so look closely.
 

keychup

Active Member
Reaction score
34
I just came up with another piece of information. the trigger only causes the game to lag if i am using the power saver feature on my laptop. This feature reduces the brightness and performance of my laptop where possible. Could it be that the feature is the cause of the lag and not completely the trigger's fault? I'll upload the map for all you guys to test. Tell me if the game lags on your computers. If anyone else has the power saver feature, try turning it on and see if there's a difference when you use it.

EDIT: It turns out that it doesnt lag ONLY when the Power Saver is on. There have been instances where it only lags when the coloring starts and when other periodic events are executed.

View attachment Arts of Battle.w3x
 

Happy

Well-Known Member
Reaction score
71
i would say Trigger 4 causes the problem because it runs about (Number of units on playable map area) times. move the run ragingbull effect trigger out of the loop. that should remove the problem.
 

keychup

Active Member
Reaction score
34
I tried that too. But if I do that then the recoloring rates can't be set and thus recoloring won't occur.

But I like what you're getting at.

Perhaps if i find a way to refer to units with the Unit Marker ability without making a unit group then perhaps the color
rates could be set by referring to only specific units using the Trigger 3 functions by itself.

Any suggestions?

I could try making Trigger 4 its own periodic event. But then again, there are already 4 of those in the map and i should be able to make as less as i can.

There's also the alternative of using timers.

However it seems that for both these methods I would still need to create the Unit Group.

If it's possible I could use an event which fires the trigger when the unit loses the buff, but I'm not sure how to detect that sort of event.

EDIT:

Oh, now I understand. You mean to simply to place the function outside the loop. I had the impression that you meant i should remove the function out of the trigger completely. Thank you.

Lesson: I learned that the function caused the trigger to pick every unit in Trigger 4 for every unit picked in Trigger 3. Thus if there are 22 units on the field the trigger will be run 22x22 = 484 times every 0.03 seconds (or 16133 times per second). And with 8 keys the hashtable was fiddled 129064 times a second.
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
it is because you are saving so many values into a hashtable every 0.03 seconds, hashtables are a bit laggier than variables and even then that many values 33 times a second is huge

EDIT: oh i see you solved it
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top