• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Trigger] Lagging Trigger Need help

Status
Not open for further replies.
Level 16
Joined
Jul 31, 2012
Messages
2,217
  • Gold
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Speed_Break_Stopped Equal to True
        • Then - Actions
          • Unit - Remove Speed Break Fx from (Random unit from (Units of type Anub'Seaker))
        • Else - Actions
      • Unit Group - Order Sc_Bot_Creeps[1] to Attack-Move To (Center of Turn Region Bottom <gen>)
      • Unit Group - Order Sc_Bot_Creeps[2] to Attack-Move To (Center of Corrupted World Tree <gen>)
      • Unit Group - Order Sc_Mid_Creeps[1] to Attack-Move To (Center of MidTurnSc <gen>)
      • Unit Group - Order Sc_Mid_Creeps[2] to Attack-Move To (Center of Corrupted World Tree <gen>)
      • Unit Group - Order Sc_Top_Creeps[1] to Attack-Move To (Center of Turn Region Top <gen>)
      • Unit Group - Order Sc_Top_Creeps[2] to Attack-Move To (Center of Corrupted World Tree <gen>)
      • Unit Group - Order Se_Bot_Creeps[1] to Attack-Move To (Center of Turn Region Bottom <gen>)
      • Unit Group - Order Se_Bot_Creeps[2] to Attack-Move To (Center of The Frozen Throne <gen>)
      • Unit Group - Order Se_Mid_Creeps to Attack-Move To (Center of The Frozen Throne <gen>)
      • Unit Group - Order Se_Top_Creeps[1] to Attack-Move To (Center of Turn Region Top <gen>)
      • Unit Group - Order Se_Top_Creeps[2] to Attack-Move To (Center of The Frozen Throne <gen>)
      • Set Playing_Players_Numb = (Number of players in (All players matching ((((Matching player) controller) Equal to User) and (((Matching player) slot status) Equal to Is playing))))
      • Set Playing_Players_Numb_Se = (Number of players in (All players matching ((((Matching player) controller) Equal to User) and ((((Matching player) slot status) Equal to Is playing) and ((Owner of (Matching unit)) Equal to (Random player from (All allies of Player 2 (Blue))))))))
      • Set Playing_Players_Numb_Sc = (Number of players in (All players matching ((((Matching player) controller) Equal to User) and ((((Matching player) slot status) Equal to Is playing) and ((Owner of (Matching unit)) Equal to (Random player from (All allies of Player 8 (Pink))))))))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Random unit from (Units of type Tiny)) has an item of type Aghanim's Scepter (Grow - Tiny)) Equal to True
          • Tiny_Holding_Tree Equal to False
        • Then - Actions
          • Set Tiny_Holding_Tree = True
          • Player - Enable War Club (Tiny) for (Owner of (Random unit from (Units of type Tiny)))
          • Unit - Order (Random unit from (Units in (Playable map area) matching (((Unit-type of (Matching unit)) Equal to Tiny) and (((Matching unit) is an illusion) Equal to False)))) to Night Elf Mountain Giant - War Club (Random destructible in (Playable map area) matching ((Destructible-type of (Matching destructible)) Equal to Snowy Tree Wall))
          • Wait 1.77 seconds
          • Player - Disable War Club (Tiny) for (Owner of (Random unit from (Units of type Tiny)))
        • Else - Actions
          • Do nothing
      • Set y = (((Real((Level of Grow for (Random unit from (Units in (Playable map area) matching ((((Matching unit) is an illusion) Equal to False) and ((Unit-type of (Matching unit)) Equal to Tiny))))))) x (100.00 / 3.00)) + 50.00)
      • Unit Group - Pick every unit in (Units of type Tiny) and do (Actions)
        • Loop - Actions
          • Animation - Change (Picked unit)'s size to (y%, y%, y%) of its original size
      • Set y = 0.00
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of Damaging Haste for (Random unit from (Units of type Anub'Seaker))) Not equal to 0
        • Then - Actions
          • Set x = 0
          • Set x = (Integer((((Current movement speed of (Random unit from (Units of type Anub'Seaker))) - 0.00) x (2.00 x ((Real((Level of Damaging Haste for (Random unit from (Units of type Anub'Seaker))))) x (0.03 / 1.00))))))
          • Unit - Set level of Damaging Haste Damage Bonus for (Random unit from (Units of type Anub'Seaker)) to x
          • Set x = 0
        • Else - Actions
          • Do nothing
      • Animation - Change (Random unit from (Units of type Dracula))'s vertex coloring to (0.00%, 0.00%, 0.00%) with 0.00% transparency
      • Animation - Change (Random unit from (Units of type Dracula))'s vertex coloring to (70.00%, 70.00%, 70.00%) with 0.00% transparency
      • Unit - Turn collision for (Random unit from (Units of type Traxex)) Off
      • Unit - Turn collision for (Random unit from (Units of type Shandris)) On
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of Blur for Blur_Mortred) Not equal to 0
        • Then - Actions
          • Animation - Change Blur_Mortred's vertex coloring to (100.00%, 100.00%, 100.00%) with (20.00 + (15.00 x (Real((Level of Blur for Blur_Mortred)))))% transparency
        • Else - Actions
          • Do nothing
      • For each (Integer x) from 1 to 12, do (Actions)
        • Loop - Actions
          • Set Combo_timer[(Integer x)] = (Combo_timer[(Integer x)] - 1.00)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Combo_timer[(Integer x)] Less than 0.00
            • Then - Actions
              • Set Combo[(Integer x)] = 0
            • Else - Actions
              • Do nothing
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Player - Add 2 to (Owner of (Random unit from (Units in (Playable map area) matching (((Matching unit) is A town-hall-type unit) Equal to True)))) Current gold
          • Player - Add Gold_Rate to (Picked player) Current gold
          • Player - Add 1 to (Picked player) Food used
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked player) Food used) Equal to Food_Max
            • Then - Actions
              • Player - Set (Picked player) Food used to 0
              • Player - Set Player 7 (Green) Food used to 0
              • Player - Set Player 1 (Red) Food used to 0
            • Else - Actions
              • Do nothing
      • Player - Add 1 to Player 1 (Red) Food used
      • Player - Add 1 to Player 7 (Green) Food used
      • Player - Add 1 to Player 1 (Red) Current gold
      • Player - Add 1 to Player 7 (Green) Current gold
This is my Trigger and it provokes lag every second
Note that all actions are necessary [almost]

Can someone help me to improve it
 
Last edited by a moderator:
Yes,you have read what the leaks are,but the question is : "Did you understand it?". You should have require yourself into a Reading Comprehension Test,and let's see what the results is.

About the trigger.
you have 11 location leaks
and you have 13 group leaks.
11 + 13 = 24 leaks
and the scary thing is that the trigger loops.So if your game lasted for an hour,

24 * 3600 = 86400 leaks!

Note: When you are reading the tutorial,make sure you understand it. If you said that you have read it,then you won't have any problems with that trigger. But the problem is that,you didn't comprehend what was written in that tutorial. Next time,please comprehend what you are reading so that your life won't be at stake.
 
  • Unit Group - Order Sc_Bot_Creeps[1] to Attack-Move To (Center of Turn Region Bottom <gen>)
    • Unit Group - Order Sc_Bot_Creeps[2] to Attack-Move To (Center of Corrupted World Tree <gen>)
    • Unit Group - Order Sc_Mid_Creeps[1] to Attack-Move To (Center of MidTurnSc <gen>)
    • Unit Group - Order Sc_Mid_Creeps[2] to Attack-Move To (Center of Corrupted World Tree <gen>)
    • Unit Group - Order Sc_Top_Creeps[1] to Attack-Move To (Center of Turn Region Top <gen>)
    • Unit Group - Order Sc_Top_Creeps[2] to Attack-Move To (Center of Corrupted World Tree <gen>)
    • Unit Group - Order Se_Bot_Creeps[1] to Attack-Move To (Center of Turn Region Bottom <gen>)
    • Unit Group - Order Se_Bot_Creeps[2] to Attack-Move To (Center of The Frozen Throne <gen>)
    • Unit Group - Order Se_Mid_Creeps to Attack-Move To (Center of The Frozen Throne <gen>)
    • Unit Group - Order Se_Top_Creeps[1] to Attack-Move To (Center of Turn Region Top <gen>)
    • Unit Group - Order Se_Top_Creeps[2] to Attack-Move To (Center of The Frozen Throne <gen>)
This is what's lagging everything.
Sadly, there's not much that could be done to improve it.
You can probably replace the way it does enumeration over units by manually ordering units, but that would only work if you need the group only once, meaning it only works well for dynamic groups.

The point leaks should be fixed. ((Center of xxx))

  • Unit - Turn collision for (Random unit from (Units of type Traxex)) Off
    • Unit - Turn collision for (Random unit from (Units of type Shandris)) On
This stuff here is a problem too.
(Units of type xxx) causes a permanent leak.

There's too much group enumeration code in here :v
So many "threads" are popping up for each unit.

  • Player Group - Pick every player in (All players) and do (Actions)
    • Loop - Actions
      • Player - Add 2 to (Owner of (Random unit from (Units in (Playable map area) matching (((Matching unit) is A town-hall-type unit) Equal to True)))) Current gold
This is also a source of lag.
You're picking every single unit on the map and checking if that unit is a town-hall or not, then you're picking a random unit from that group.
This is what you should do to improve it:

- Create 4 variables: A hashtable, a unit array and 2 integers
Call the hashtable townHallHash
Call the unit array townHalls
Call the first integer townHallStackIndex
Call the second integer tempInt

On map initialization:

  • Hashtable - Create a hashtable
  • Set townHallHash = (Last created hashtable)
Whenever a unit enters the map, if he is a town-hall-type unit:

  • Set townHalls[townHallStackIndex] = (Triggering unit)
  • Custom script: call SaveInteger(udg_townHallHash, GetHandleId(udg_townHalls[udg_townHallStackIndex]), 0, udg_townHallStackIndex)
  • Set townHallStackIndex = (townHallStackIndex + 1)
Whenever a unit leaves the map, if he is a town-hall-type unit:

  • Custom script: set udg_tempInt = LoadInteger(udg_townHallHash, GetHandleId(GetTriggerUnit()), 0)
  • Set townHalls[tempInt] = townHalls[(townHallStackIndex - 1)]
  • Set townHallStackIndex = (townHallStackIndex - 1)
This way, instead of getting all units on the map every single time, what you would do instead is this:

  • Player Group - Pick every player in (All players) and do (Actions)
    • Loop - Actions
      • Player - Add 2 to (Owner of townHalls[(Random integer between 0 and (townHallStackIndex - 1))]) Current gold
Now as for other parts of the code:

  • Unit - Turn collision for (Random unit from (Units of type Traxex)) Off
  • Unit - Turn collision for (Random unit from (Units of type Shandris)) On
This can be improved with a similar method as I mentioned above.
Make a list for units of type Traxex and a list for units of Shandris.
If there's only supposed to be 1 of each, store them into variables.
 
Level 16
Joined
Jul 31, 2012
Messages
2,217
multiple unit group order
I'll fix the point and see want i can improve

2 collision units
I'll store them into 2 variables

town hall thing
When i made this i was like a beginner in GUI so i didn't knew what was the best
I can easily store the town hall units owner in a player group which is more easy than hashtables

Thx for this magtheridon
 
Level 16
Joined
Jul 31, 2012
Messages
2,217
Here is the new trigger
Note : there was another trigger that fires also every second so i merged them
  • Gold
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Speed_Break_Stopped Equal to True
        • Then - Actions
          • Unit - Remove Speed Break Fx from (Random unit from (Units of type Anub'Seaker))
        • Else - Actions
      • Set Playing_Players_Numb = (Number of players in (All players matching ((((Matching player) controller) Equal to User) and (((Matching player) slot status) Equal to Is playing))))
      • Set Playing_Players_Numb_Se = (Number of players in (All players matching ((((Matching player) controller) Equal to User) and ((((Matching player) slot status) Equal to Is playing) and ((Owner of (Matching unit)) Equal to (Random player from (All allies of Player 2 (Blue))))))))
      • Set Playing_Players_Numb_Sc = (Number of players in (All players matching ((((Matching player) controller) Equal to User) and ((((Matching player) slot status) Equal to Is playing) and ((Owner of (Matching unit)) Equal to (Random player from (All allies of Player 8 (Pink))))))))
      • Set y = (((Real((Level of Grow for Tiny))) x (100.00 / 3.00)) + 50.00)
      • Unit Group - Pick every unit in (Units of type Tiny) and do (Actions) ///even if it causes permanent leak its is neccesary
        • Loop - Actions
          • Animation - Change (Picked unit)'s size to (y%, y%, y%) of its original size
      • Set y = 0.00
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of Damaging Haste for Anub_Seaker) Not equal to 0
        • Then - Actions
          • Set x = 0
          • Set x = (Integer((((Current movement speed of Anub_Seaker) - 0.00) x (2.00 x ((Real((Level of Damaging Haste for Anub_Seaker))) x (0.03 / 1.00))))))
          • Unit - Set level of Damaging Haste Damage Bonus for Anub_Seaker to x
          • Set x = 0
        • Else - Actions
      • Animation - Change (Random unit from (Units of type Dracula))'s vertex coloring to (0.00%, 0.00%, 0.00%) with 0.00% transparency
      • Animation - Change (Random unit from (Units of type Dracula))'s vertex coloring to (70.00%, 70.00%, 70.00%) with 0.00% transparency
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of Blur for Blur_Mortred) Not equal to 0
        • Then - Actions
          • Animation - Change Blur_Mortred's vertex coloring to (100.00%, 100.00%, 100.00%) with (20.00 + (15.00 x (Real((Level of Blur for Blur_Mortred)))))% transparency
        • Else - Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Player - Add Gold_Rate to (Picked player) Current gold
          • Player - Add 1 to (Picked player) Food used
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked player) Food used) Equal to Food_Max
            • Then - Actions
              • Player - Set (Picked player) Food used to 0
              • Player - Set Player 7 (Green) Food used to 0
              • Player - Set Player 1 (Red) Food used to 0
            • Else - Actions
      • Player Group - Pick every player in Golden_Scepter_Players and do (Actions)
        • Loop - Actions
          • Player - Add 2 to (Picked player) Current gold
      • Player - Add 1 to Player 1 (Red) Food used
      • Player - Add 1 to Player 7 (Green) Food used
      • Player - Add 1 to Player 1 (Red) Current gold
      • Player - Add 1 to Player 7 (Green) Current gold
      • For each (Integer x) from 1 to 12, do (Actions)
        • Loop - Actions
          • Set Combo_timer[x] = (Combo_timer[x] - 1.00)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Combo_timer[x] Less than 0.00
            • Then - Actions
              • Set Combo[x] = 0
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Player(x)) slot status) Equal to Is playing
              • ((Player(x)) controller) Equal to Computer
            • Then - Actions
              • Multiboard - Set the text for (Last created multiboard) item in column 7, row Multiboard_Player_Position[x] to (String(Spree[x]))
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • ((Player(x)) slot status) Equal to Is playing
                  • ((Player(x)) controller) Equal to Computer
                  • (Player(x)) Equal to Player 1 (Red)
                  • (Player(x)) Equal to Player 7 (Green)
            • Then - Actions
              • Multiboard - Set the text for (Multiboard) item in column 3, row Multiboard_Player_Position[x] to (String((Hero level of (Random unit from (Units owned by (Player(x)) matching (((Matching unit) is A Hero) Equal to True))))))
              • Multiboard - Set the text for (Multiboard) item in column 4, row Multiboard_Player_Position[x] to (<Empty String> + (String(K[x])))
              • Multiboard - Set the text for (Multiboard) item in column 5, row Multiboard_Player_Position[x] to (<Empty String> + (String(D[x])))
              • Multiboard - Set the text for (Multiboard) item in column 6, row Multiboard_Player_Position[x] to (((String(C_K[(Integer A)])) + /) + (String(C_D[x])))
              • Multiboard - Set the text for (Multiboard) item in column 7, row Multiboard_Player_Position[x] to (String(Spree[x]))
            • Else - Actions
      • -------- multiboard --------
      • Multiboard - Change the title of (Multiboard) to (|cffff0000 + ((String(Kill_Se)) + (|r/|cff0000ff + ((String(Death_Se)) + (|r - |cffff0000 + ((String(Number_Towers_Se)) + (|r/|cff00ff00 + ((String(Number_Towers_Sc)) + (|r - |cffff0000 + ((String(Kill_Sc)) + (|r/|cff0000ff + (String(Death_Sc)))))))))))))
      • Multiboard - Set the text for (Multiboard) item in column 3, row Multiboard_Player_Position[1] to <Empty String>
      • Multiboard - Set the text for (Multiboard) item in column 3, row Multiboard_Player_Position[7] to <Empty String>
      • Multiboard - Set the icon for (Multiboard) item in column 1, row Multiboard_Player_Position[1] to ReplaceableTextures\CommandButtons\BTNCorruptedTreeOfLife.blp
      • Multiboard - Set the icon for (Multiboard) item in column 1, row Multiboard_Player_Position[7] to ReplaceableTextures\CommandButtons\BTNIcyTreasureBox.blp
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Tiny has an item of type Aghanim's Scepter (Grow - Tiny)) Equal to True
          • Tiny_Holding_Tree Equal to False
        • Then - Actions
          • Set Tiny_Holding_Tree = True
          • Player - Enable War Club (Tiny) for (Owner of Tiny)
          • Unit - Order Tiny to Night Elf Mountain Giant - War Club (Random destructible in (Playable map area) matching ((Destructible-type of (Matching destructible)) Equal to Snowy Tree Wall))
          • Wait 1.77 seconds
          • Player - Disable War Club (Tiny) for (Owner of Tiny)
        • Else - Actions
 
Last edited:
Level 16
Joined
Jul 31, 2012
Messages
2,217
take out all the do nothing actions

you should also set the multiboard to a variable and use tht rather than last created multiboard.

Y do u add food to player ? it doesnt seem to be used for anything

the do nothing are not important; adding them or not
the multiboard is now stored in a variable

the food in my map is not used for anything but the seconds passing
 
Status
Not open for further replies.
Top