[Trigger] Is this trigger Leakless?

Status
Not open for further replies.
Level 13
Joined
Sep 25, 2013
Messages
717
Hello, is there any better way to do what this trigger is doing and is it leakless? When i set the periodic event timer down to .15 it lags the game. Thanks for your help :)!
[Edit] Just noticed i put the unit type matching Sindarin Ranger condition twice within each tempunitgroup variable lol, i changed it

  • Sindarin Ranger Invisibility
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Set tempUnitGroup = (Units in (Playable map area) matching (((Unit-type of (Matching unit)) Equal to Sindarin Ranger |c00FFFF00(Elite)|r (Elves)) and ((((Matching unit) has buff Forest (Forest Aura)) Equal to True) and ((Unit-type of (Matching unit)) Equal to Sindarin Ranger |c0
      • Unit Group - Pick every unit in tempUnitGroup and do (Actions)
        • Loop - Actions
          • Unit - Add Ghost to (Picked unit)
      • Custom script: call DestroyGroup (udg_tempUnitGroup)
      • Set tempUnitGroup = (Units in (Playable map area) matching (((Unit-type of (Matching unit)) Equal to Sindarin Ranger |c00FFFF00(Elite)|r (Elves)) and ((((Matching unit) has buff Forest (Forest Aura)) Equal to False) and ((Unit-type of (Matching unit)) Equal to Sindarin Ranger |c
      • Unit Group - Pick every unit in tempUnitGroup and do (Actions)
        • Loop - Actions
          • Unit - Remove Ghost from (Picked unit)
      • Custom script: call DestroyGroup (udg_tempUnitGroup)
 

Ardenian

A

Ardenian

You double-check for the unit type in the 'set tempUnitGroup' ? Why ?

For efficiency, you could set tempUnitGroup to every unit of unit type only and check in a ITE whether the unit has the buff or not. This way you have one pick for both actions.
 
What exactly are you trying to accomplish with this trigger? Anyway, from what you're currently showing, here are a few suggestions:

  • Use a variable to refer to Picked unit. It's a lot faster than always having to refer to (Picked unit), especially when you have it in a 1 second periodic timer.
  • Why do you add and remove ghost in two seperate Unit Group functions in the same trigger? Would it not deliver the same result if you did it in the same loop?
    • Unit Group - Pick every unit in tempUnitGroup and do (Actions)
      • Loop - Actions
        • Set tempUnit = (Picked unit)
        • Unit - Add Ghost to tempUnit
        • Unit - Remove Ghost from tempUnit
  • It's extremely hard to read your "filters" when you use (Matching Unit). I'd recommend filtering them out with ITE's like this:
    • Custom script: set bj_wantDestroyGroup = true
    • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
      • Loop - Actions
        • Set tempUnit = (Picked unit)
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Unit-type of tempUnit) Equal to Footman
            • (tempUnit has buff Acid Bomb) Equal to True
            • -------- other filters --------
          • Then - Actions
            • -------- actions --------
          • Else - Actions
 
Status
Not open for further replies.
Top