• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Trigger] Leakless unit creation.

Status
Not open for further replies.
Level 4
Joined
Jun 16, 2009
Messages
92
Does creating a unit or a number of units, leak?

It seems that over time, my map starts to slow down. It slows waaaaay down through the production of a massive amount of units.

It had to off-set the unit production via wait triggers just to avoid the massive "lag" spike you get upon unit creation via waves.

Mind you that I'm curious about the actual unit creation in itself, not the point variables, as I grab and delete those once they are created.

If spawning units via triggers causes such a massive stutter, would spawning them via abilities be smoother?

One of my map's main focuses is the mass periodic creation of units.


Any help is appreciated.
 
Level 4
Joined
Jun 16, 2009
Messages
92
  • Events
    • Time - tTimerSpawns[1] expires
  • Conditions
  • Actions
    • Set xTempPoint = (Center of A1aSpawns <gen>)
    • Unit - Create 3 Bonebreaker for Player 11 (Dark Green) at xTempPoint facing Default building facing (270.0) degrees
    • Unit - Create 1 Waterbreather for Player 11 (Dark Green) at xTempPoint facing Default building facing (270.0) degrees
    • Custom script: call RemoveLocation( udg_xTempPoint )
    • Set xTempPoint = (Center of A1bSpawns <gen>)
    • Unit - Create 3 Bonebreaker for Player 11 (Dark Green) at xTempPoint facing Default building facing (270.0) degrees
    • Unit - Create 1 Waterbreather for Player 11 (Dark Green) at xTempPoint facing Default building facing (270.0) degrees
    • Custom script: call RemoveLocation( udg_xTempPoint )
    • Set xTempPoint = (Center of A1cSpawns <gen>)
    • Unit - Create 3 Bonebreaker for Player 11 (Dark Green) at xTempPoint facing Default building facing (270.0) degrees
    • Unit - Create 1 Waterbreather for Player 11 (Dark Green) at xTempPoint facing Default building facing (270.0) degrees
    • Custom script: call RemoveLocation( udg_xTempPoint )
    • Set xTempPoint = (Center of A3aSpawns <gen>)
    • Unit - Create 3 Deadwalker for Player 12 (Brown) at xTempPoint facing Default building facing (270.0) degrees
    • Unit - Create 1 Blightcrawler Acolyte for Player 12 (Brown) at xTempPoint facing Default building facing (270.0) degrees
    • Custom script: call RemoveLocation( udg_xTempPoint )
    • Set xTempPoint = (Center of A3bSpawns <gen>)
    • Unit - Create 3 Deadwalker for Player 12 (Brown) at xTempPoint facing Default building facing (270.0) degrees
    • Unit - Create 1 Blightcrawler Acolyte for Player 12 (Brown) at xTempPoint facing Default building facing (270.0) degrees
    • Custom script: call RemoveLocation( udg_xTempPoint )
    • Set xTempPoint = (Center of A3cSpawns <gen>)
    • Unit - Create 3 Deadwalker for Player 12 (Brown) at xTempPoint facing Default building facing (270.0) degrees
    • Unit - Create 1 Blightcrawler Acolyte for Player 12 (Brown) at xTempPoint facing Default building facing (270.0) degrees
    • Custom script: call RemoveLocation( udg_xTempPoint )
    • Set xTempPoint = (Center of A2aSpawns <gen>)
    • If ((Void Gate 0001 <gen> is alive) Equal to True) then do (Unit - Create 6 Voidblade for Neutral Hostile at xTempPoint facing Default building facing (270.0) degrees) else do (Do nothing)
    • If ((Void Gate 0001 <gen> is alive) Equal to True) then do (Unit - Create 4 Beyonder for Neutral Hostile at xTempPoint facing Default building facing (270.0) degrees) else do (Do nothing)
    • Custom script: call RemoveLocation( udg_xTempPoint )
    • Set xTempPoint = (Center of A4aSpawns <gen>)
    • If ((Void Gate 0003 <gen> is alive) Equal to True) then do (Unit - Create 3 Voidblade for Neutral Hostile at xTempPoint facing Default building facing (270.0) degrees) else do (Do nothing)
    • If ((Void Gate 0003 <gen> is alive) Equal to True) then do (Unit - Create 2 Beyonder for Neutral Hostile at xTempPoint facing Default building facing (270.0) degrees) else do (Do nothing)
    • Custom script: call RemoveLocation( udg_xTempPoint )
    • Set xTempPoint = (Center of A4bSpawns <gen>)
    • If ((Void Gate 0004 <gen> is alive) Equal to True) then do (Unit - Create 3 Voidblade for Neutral Hostile at xTempPoint facing Default building facing (270.0) degrees) else do (Do nothing)
    • If ((Void Gate 0004 <gen> is alive) Equal to True) then do (Unit - Create 2 Beyonder for Neutral Hostile at xTempPoint facing Default building facing (270.0) degrees) else do (Do nothing)
    • Custom script: call RemoveLocation( udg_xTempPoint )
    • Set xTempPoint = (Center of A2cSpawns <gen>)
    • If ((Void Gate 0002 <gen> is alive) Equal to True) then do (Unit - Create 6 Voidblade for Neutral Hostile at xTempPoint facing Default building facing (270.0) degrees) else do (Do nothing)
    • If ((Void Gate 0002 <gen> is alive) Equal to True) then do (Unit - Create 4 Beyonder for Neutral Hostile at xTempPoint facing Default building facing (270.0) degrees) else do (Do nothing)
    • Custom script: call RemoveLocation( udg_xTempPoint )
Like I said, the point removal isn't the problem. Just... when units spawn, they create a massive burst of lag. I am screwing around with different things at this very moment. Going to see if spawning units via a spell would prevent the lag.
 
Level 4
Joined
Jun 16, 2009
Messages
92
How many units are we talking? They can technically be leaked if not removed, but generally that's what you want in warcraft :p

Units are a class of data just like any other handle, and wc is only built to handle so many.

That's maybe, 80 units every wave, depending.
I have two modes, one is 30 second wave timer, the other is 10 seconds.
The 10 second wave timer slows to a grind within a good 3 minutes.


EDIT: Also, the towers do a pretty good job at neutralizing units, so there is, at most, maybe 500 units running through the map at any given point. And this seems entirely reasonable.
 
Level 4
Joined
Jun 16, 2009
Messages
92
500 is reasonable, but then again, who says it's a grinding hault? you or everyone? It could be your specs at 500...

I have a very formidable computer, and if it "lags" for me, then that means it'll definitely lag for 'someone' on the net. And that is unacceptable. :'(
 
Level 8
Joined
Aug 4, 2008
Messages
279
U could make it smaller, first set the variables:
Set xTempPoint[1] = Center of A1aSpawns
Set xTempPoint[2] = Center of A1bSpawns
until the points u want are finished.
Then do a loop
For each (Integer A) from 1 to (here is to number of the last index u use for xTempPoint).
Loop -
Unit - Create 3 Deadwalker for Player 12 (Brown) at xTempPoint[Integer A] facing Default building facing (270.0) degrees
Unit - Create 1 Blightcrawler Acolyte for Player 12 (Brown) at xTempPoint[Integer A] facing Default building facing (270.0) degrees
 
Level 4
Joined
Jun 16, 2009
Messages
92
What a shame, I suppose I will have to stick to a smaller amount of active units. Thanks for the thoughts.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,202
Unit creation does not leak, and will not slow your map down in any way. SWAT AM is a perfect example where after 8000 zombies, the game will still run at the same framerate and no lag ever occurs during zombie spawn.

Poor creation method however will make lag. This includes leaking other non related objects like locations or forces or unit handle indexes due to non nulling of locals. It also includes spawning them in a poor or unsafe way, like ontop of other units or an insane number at once. Also creating units which never can be removed will cause this like spell dummy units or unkillable units which never are removed or die.

I say the 2 main reasons for any lag you encounter are you are creating multiple units ontop of each other, and using locals / locations in a leak prone way. For efficent and lagless spawning, spawn units at individual and preferably unocupied positions and make sure that the triggers do not leak any objects as a side affect. Also try spawning units over time, as the less units created at once, the less time the processor takes to advance frame.
 
Level 4
Joined
Jun 16, 2009
Messages
92
I will try this, perhaps looping integers that spawn units individually at random locations within a region, instead of 3 through a single line of code. We shall see. I'll post the updated code soon, and let you know the results.

I did what I had said I would do, create looping integers to spawn the units one by one, but it did not help reduce the unit lag. Sooooo, I offset each spawn by .5 seconds. This helped the longer spawn timer mode out a little bit, but the unit creation in my "flood" mode was still ridiculously slow.

It gets progressively worse within the first two minutes time, a really bad snowball effect.

If it helps to say, I 'am' spawning a lot of Neutral Hostile (as well as player) units. Although I don't believe that has anything to do with the situation.
 
Last edited by a moderator:
Level 4
Joined
Jun 16, 2009
Messages
92
  • Events
    • Time - tTimerSpawns[1] expires
  • Actions
    • For each (Integer B) from 1 to 3, do (Actions)
      • Loop - Actions
        • Set xTempPoint = (Random point in A1aSpawns <gen>)
        • Unit - Create 1 Bonebreaker for Player 11 (Dark Green) at xTempPoint facing Default building facing (270.0) degrees
        • Custom script: call RemoveLocation( udg_xTempPoint )
    • Set xTempPoint = (Random point in A1aSpawns <gen>)
    • Unit - Create 1 Waterbreather for Player 11 (Dark Green) at xTempPoint facing Default building facing (270.0) degrees
    • Custom script: call RemoveLocation( udg_xTempPoint )
    • Wait 0.20 game-time seconds
    • For each (Integer B) from 1 to 3, do (Actions)
      • Loop - Actions
        • Set xTempPoint = (Random point in A1bSpawns <gen>)
        • Unit - Create 1 Bonebreaker for Player 11 (Dark Green) at xTempPoint facing Default building facing (270.0) degrees
        • Custom script: call RemoveLocation( udg_xTempPoint )
    • Set xTempPoint = (Random point in A1bSpawns <gen>)
    • Unit - Create 1 Waterbreather for Player 11 (Dark Green) at xTempPoint facing Default building facing (270.0) degrees
    • Custom script: call RemoveLocation( udg_xTempPoint )
    • Wait 0.20 game-time seconds
    • For each (Integer B) from 1 to 3, do (Actions)
      • Loop - Actions
        • Set xTempPoint = (Random point in A1cSpawns <gen>)
        • Unit - Create 1 Bonebreaker for Player 11 (Dark Green) at xTempPoint facing Default building facing (270.0) degrees
        • Custom script: call RemoveLocation( udg_xTempPoint )
    • Set xTempPoint = (Random point in A1cSpawns <gen>)
    • Unit - Create 1 Waterbreather for Player 11 (Dark Green) at xTempPoint facing Default building facing (270.0) degrees
    • Custom script: call RemoveLocation( udg_xTempPoint )
    • Wait 0.20 game-time seconds
    • For each (Integer B) from 1 to 3, do (Actions)
      • Loop - Actions
        • Set xTempPoint = (Random point in A3aSpawns <gen>)
        • Unit - Create 1 Deadwalker for Player 11 (Dark Green) at xTempPoint facing Default building facing (270.0) degrees
        • Custom script: call RemoveLocation( udg_xTempPoint )
    • Set xTempPoint = (Random point in A3aSpawns <gen>)
    • Unit - Create 1 Blightcrawler Acolyte for Player 12 (Brown) at xTempPoint facing Default building facing (270.0) degrees
    • Custom script: call RemoveLocation( udg_xTempPoint )
    • Wait 0.20 game-time seconds
    • For each (Integer B) from 1 to 3, do (Actions)
      • Loop - Actions
        • Set xTempPoint = (Random point in A3bSpawns <gen>)
        • Unit - Create 1 Deadwalker for Player 11 (Dark Green) at xTempPoint facing Default building facing (270.0) degrees
        • Custom script: call RemoveLocation( udg_xTempPoint )
    • Set xTempPoint = (Random point in A3bSpawns <gen>)
    • Unit - Create 1 Blightcrawler Acolyte for Player 12 (Brown) at xTempPoint facing Default building facing (270.0) degrees
    • Custom script: call RemoveLocation( udg_xTempPoint )
    • Wait 0.20 game-time seconds
    • For each (Integer B) from 1 to 3, do (Actions)
      • Loop - Actions
        • Set xTempPoint = (Random point in A3cSpawns <gen>)
        • Unit - Create 1 Deadwalker for Player 11 (Dark Green) at xTempPoint facing Default building facing (270.0) degrees
        • Custom script: call RemoveLocation( udg_xTempPoint )
    • Set xTempPoint = (Random point in A3cSpawns <gen>)
    • Unit - Create 1 Blightcrawler Acolyte for Player 12 (Brown) at xTempPoint facing Default building facing (270.0) degrees
    • Custom script: call RemoveLocation( udg_xTempPoint )
    • Wait 0.20 game-time seconds
    • For each (Integer B) from 1 to 6, do (Actions)
      • Loop - Actions
        • Set xTempPoint = (Random point in A2aSpawns <gen>)
        • If ((Void Gate 0001 <gen> is alive) Equal to True) then do (Unit - Create 1 Voidblade for Neutral Hostile at xTempPoint facing Default building facing (270.0) degrees) else do (Do nothing)
        • Custom script: call RemoveLocation( udg_xTempPoint )
    • Wait 0.20 game-time seconds
    • For each (Integer B) from 1 to 4, do (Actions)
      • Loop - Actions
        • Set xTempPoint = (Random point in A2aSpawns <gen>)
        • If ((Void Gate 0001 <gen> is alive) Equal to True) then do (Unit - Create 1 Beyonder for Neutral Hostile at xTempPoint facing Default building facing (270.0) degrees) else do (Do nothing)
        • Custom script: call RemoveLocation( udg_xTempPoint )
    • Wait 0.20 game-time seconds
    • For each (Integer B) from 1 to 6, do (Actions)
      • Loop - Actions
        • Set xTempPoint = (Random point in A4aSpawns <gen>)
        • If ((Void Gate 0003 <gen> is alive) Equal to True) then do (Unit - Create 1 Voidblade for Neutral Hostile at xTempPoint facing Default building facing (270.0) degrees) else do (Do nothing)
        • Custom script: call RemoveLocation( udg_xTempPoint )
    • Wait 0.20 game-time seconds
    • For each (Integer B) from 1 to 4, do (Actions)
      • Loop - Actions
        • Set xTempPoint = (Random point in A4aSpawns <gen>)
        • If ((Void Gate 0003 <gen> is alive) Equal to True) then do (Unit - Create 1 Beyonder for Neutral Hostile at xTempPoint facing Default building facing (270.0) degrees) else do (Do nothing)
        • Custom script: call RemoveLocation( udg_xTempPoint )
    • Wait 0.20 game-time seconds
    • For each (Integer B) from 1 to 6, do (Actions)
      • Loop - Actions
        • Set xTempPoint = (Random point in A4bSpawns <gen>)
        • If ((Void Gate 0004 <gen> is alive) Equal to True) then do (Unit - Create 1 Voidblade for Neutral Hostile at xTempPoint facing Default building facing (270.0) degrees) else do (Do nothing)
        • Custom script: call RemoveLocation( udg_xTempPoint )
    • Wait 0.20 game-time seconds
    • For each (Integer B) from 1 to 4, do (Actions)
      • Loop - Actions
        • Set xTempPoint = (Random point in A4bSpawns <gen>)
        • If ((Void Gate 0004 <gen> is alive) Equal to True) then do (Unit - Create 1 Beyonder for Neutral Hostile at xTempPoint facing Default building facing (270.0) degrees) else do (Do nothing)
        • Custom script: call RemoveLocation( udg_xTempPoint )
    • Wait 0.20 game-time seconds
    • For each (Integer B) from 1 to 6, do (Actions)
      • Loop - Actions
        • Set xTempPoint = (Random point in A2cSpawns <gen>)
        • If ((Void Gate 0002 <gen> is alive) Equal to True) then do (Unit - Create 1 Voidblade for Neutral Hostile at xTempPoint facing Default building facing (270.0) degrees) else do (Do nothing)
        • Custom script: call RemoveLocation( udg_xTempPoint )
    • Wait 0.20 game-time seconds
    • For each (Integer B) from 1 to 4, do (Actions)
      • Loop - Actions
        • Set xTempPoint = (Random point in A2cSpawns <gen>)
        • If ((Void Gate 0002 <gen> is alive) Equal to True) then do (Unit - Create 1 Beyonder for Neutral Hostile at xTempPoint facing Default building facing (270.0) degrees) else do (Do nothing)
        • Custom script: call RemoveLocation( udg_xTempPoint )
Enjoy that, wall of incredible text.

In my "flood" mode, this is happening every 10 seconds.
 
Level 4
Joined
Mar 14, 2009
Messages
98
I don't think that this trigger is leaking, nor causing the lag. Are you sure this is the cause?

Edit: Nevermind, I just remembered that PolledWait leaks. So, yeah, there is a leak concerning "Wait X game-time seconds". I still think that something else is the cause for the incredible lag though.
 
Level 4
Joined
Jun 16, 2009
Messages
92
I only added the waits to 'reduce' the amount of units spawning at the exact same time.

Without the waits, the problem still persists.

Honestly I'm stumped.
 
Level 4
Joined
Mar 14, 2009
Messages
98
Are you sure that other triggers aren't causing the lag? Maybe the game slows down because there are leaking spells that are often used or something. You can also try reducing the decay time. It should be somewhere in Gameplay Constants under the Advanced tab. Maybe a reduction in corpses cluttering the map would reduce the lag?
 
Level 4
Joined
Jun 16, 2009
Messages
92
I could understand if I had a trigger like, unit enters playable map area going off on every spawn, but I don't. There is a burst of lag at every spawn point.

I will try the corpse decay redux.
 
Status
Not open for further replies.
Top