Hello everyone,
I have made the following trigger which works perfectly fine functionality wise, but it makes the game lag-spike whenever it is executed. Is there something I can do to avoid this problem without altering the functionality? Perhaps some jass code?
The trigger spawns units but limits the amount of total units on the map to ensure that it is not too difficult and prevents spawning too many units making the game lag if they are killed too slowly.
There are some weak units and some heroes with strong AOE damage and they can periodically kill about ~20 units with an ultimate spell which lag-spikes the map when it has to spawn units and iterate through the spawn loops.
Here is a snippet of the trigger:

I have made the following trigger which works perfectly fine functionality wise, but it makes the game lag-spike whenever it is executed. Is there something I can do to avoid this problem without altering the functionality? Perhaps some jass code?
The trigger spawns units but limits the amount of total units on the map to ensure that it is not too difficult and prevents spawning too many units making the game lag if they are killed too slowly.
There are some weak units and some heroes with strong AOE damage and they can periodically kill about ~20 units with an ultimate spell which lag-spikes the map when it has to spawn units and iterate through the spawn loops.
Here is a snippet of the trigger:
-
For each (Integer Spawn) from 1 to 30, do (Actions)
-
Loop - Actions
-
Wait until ((Number of units in (Units in (Playable map area) matching (((Entire Region that I want to exclude <gen> contains (Matching unit)) Equal to False) and (((Matching unit) belongs to an enemy of Player 1 (Red)) Equal to True)))) Less than or equal to XXX), checking every 2.00 seconds
-
Unit - Create 1 Voidwalker for (Random player from Legion_of_Monsters) at (Center of Spawn Area Late <gen>) facing Default building facing degrees
-
Unit - Create 1 Crypt Fiend for (Random player from Legion_of_Monsters) at (Center of Spawn Area Late <gen>) facing Default building facing degrees
-
Wait until ((Number of units in (Units in (Playable map area) matching (((Entire Region that I want to exclude <gen> contains (Matching unit)) Equal to False) and (((Matching unit) belongs to an enemy of Player 1 (Red)) Equal to True)))) Less than or equal to XXX), checking every 2.00 seconds
-
Unit - Create 1 Abomination for (Random player from Legion_of_Monsters) at (Center of Spawn Area Late <gen>) facing Default building facing degrees
-
Unit - Create 1 Felguard for (Random player from Legion_of_Monsters) at (Center of Spawn Area Late <gen>) facing Default building facing degrees
-
-
-
Actions
-
For each (Integer numberxxx) from 1 to 50, do (Actions)
-
Loop - Actions
-
Wait until ((Number of units in (Units in (Playable map area) matching (((Entire Region that I want to exclude <gen> contains (Matching unit)) Equal to False) and (((Matching unit) belongs to an enemy of Player 1 (Red)) Equal to True)))) Less than or equal to 99999), checking every 2.00 seconds
-
-
-