Is this trigger causing my map to lag so hard?

Level 6
Joined
Jul 12, 2017
Messages
137
So my map has been lagging from time to time, probably due to a lot of enemies at once and this trigger moves the certain type of enemies. I suspect as this is the only periodic time trigger I have which moves a lot of unit at once, it may cause the massive lag but how do I fix it? Is this trigger really the problem?

Thank you in advance.

  • Enemies Attack Move
    • Events
      • Time - Every 30.00 seconds of game time
    • Conditions
    • Actions
      • Set VariableSet UnitGroup1 = (Units in (Playable map area) matching (((Matching unit) belongs to an ally of Player 21 (Coal).) Equal to True))
      • Set VariableSet UnitGroup2 = (Units in (Playable map area) matching (((Matching unit) belongs to an enemy of Player 21 (Coal).) Equal to True))
      • Set VariableSet Point1 = (Position of (Random unit from UnitGroup2))
      • Unit Group - Pick every unit in UnitGroup1 and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Owner of (Picked unit)) Not equal to Player 17 (Wheat)
              • (Owner of (Picked unit)) Not equal to Player 24 (Peanut)
            • Then - Actions
              • Unit - Order (Picked unit) to Attack-Move To Point1
            • Else - Actions
              • Do nothing
      • Custom script: call RemoveLocation(udg_Point1)
      • Custom script: call DestroyGroup(udg_UnitGroup1)
      • Custom script: call DestroyGroup(udg_UnitGroup2)
 

Uncle

Warcraft Moderator
Level 48
Joined
Aug 10, 2018
Messages
4,678
Your trigger would only cause a performance issue when it runs which is once every 30.00 seconds. If your performance issue is happening more often than that then it's something else. That being said, you can make this trigger more efficient by manually Adding/Removing units from the Unit Groups as the units enter/leave the map instead of doing it all at once. You're also not using filters to prevent things like Dead units from being added to the Unit Groups. Point1 could be the position of a dead unit, a structure, a ward, etc...

Regarding triggers that can cause performance issues, I believe Attack/Damage Events are the major cause for performance issues when large numbers of units are on the map.

Anyway, I think you can answer your own question pretty easily, when you disable the trigger does the map performance improve?
 
Level 34
Joined
Feb 27, 2007
Messages
4,595
My best guess is they have waaaaaay too many units trying to move at once and pathfinding is breaking down. When pathfinding for units get slow they seem delayed and it looks a lot like the game is lagging even though it's not. Could you post a video of the behavior you see in your map, or confirm that it's not just pathfinding from too many units doing it at once?
 
Level 24
Joined
Mar 15, 2012
Messages
2,790
My best guess is they have waaaaaay too many units trying to move at once and pathfinding is breaking down. When pathfinding for units get slow they seem delayed and it looks a lot like the game is lagging even though it's not. Could you post a video of the behavior you see in your map, or confirm that it's not just pathfinding from too many units doing it at once?
Its literal lag where players screens freeze or stutter, though there is a solution for that too which is making cannon fodder aka weak type units have no unit collision where they behave like air units but still have ground pathing. Unit delay still happens around 300+ units at once or 150+ units trying to navigate around cliffs/blocked pathing or attacking units.
 
Top