• 🏆 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] Spawn system comparison

Which is Optimized?

  • Trigger 1?

    Votes: 0 0.0%

  • Total voters
    2
  • Poll closed .
Status
Not open for further replies.
Level 5
Joined
Apr 13, 2017
Messages
157
Well this is a spawn system from one of my friend's map(I'm not gonna state him until he replies here and says that this is his creation).

So I need you to compare the two triggers to show which is better for cleaning leaks and which is more optimized.
Only 1 variable was used in each trigger
Code:
SpawnPoint - The Location where units are spawned

spawn1 - Region.
  • Spawn
    • Events
      • Time - Every 45.00 seconds of game time
    • Conditions
      • GameOver Equal to False
    • Actions
      • Set SpawnPoint = (Center of spawn1 <gen>)
      • Unit - Create 1 Soldier for Player 11 (Dark Green) at SpawnPoint facing Default building facing degrees
      • Custom script: call RemoveLocation(udg_SpawnPoint)
      • Set HumanSpawnPoint = (Center of spawn1 <gen>)
      • Unit - Create 1 Milita for Player 11 (Dark Green) at SpawnPoint facing Default building facing degrees
      • Custom script: call RemoveLocation(udg_SpawnPoint)
      • Set HumanSpawnPoint = (Center of spawn1 <gen>)
      • Unit - Create 1 Footman for Player 11 (Dark Green) at SpawnPoint facing Default building facing degrees
      • Custom script: call RemoveLocation(udg_SpawnPoint)
      • Set HumanSpawnPoint = (Center of spawn1 <gen>)
      • Unit - Create 1 Rifleman for Player 11 (Dark Green) at SpawnPoint facing Default building facing degrees
      • Custom script: call RemoveLocation(udg_SpawnPoint)

  • Spawn
    • Events
      • Time - Every 45.00 seconds of game time
    • Conditions
      • GameOver Equal to False
    • Actions
      • Set SpawnPoint = (Center of spawn1 <gen>)
      • Unit - Create 1 Soldier for Player 11 (Dark Green) at SpawnPoint facing Default building facing degrees
      • Unit - Create 1 Milita for Player 11 (Dark Green) at SpawnPoint facing Default building facing degrees
      • Unit - Create 1 Footman for Player 11 (Dark Green) at SpawnPoint facing Default building facing degrees
      • Unit - Create 1 Rifleman for Player 11 (Dark Green) at SpawnPoint facing Default building facing degrees
      • Custom script: call RemoveLocation(udg_SpawnPoint)

Hope you can help him find the right one, and if there are other mistakes in the trigger, please tell me :)
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,183
In GUI, when you use a point/location you create a location which remains in memory, which is why you need to remove it with a script to prevent a memory leak.
Now, since you store the created location into a variable you can use that variable over and over, and it wont leak as long as you do not overwrite it.
So as long as you do not edit the variable, you do not need to remove and re-set it.
 
Level 13
Joined
Oct 12, 2016
Messages
769
There's no need to add and remove the same point 4 times when it's a common point.
You can recycle the same point for each action if you need that specific location.
Because of this, it's indeed more efficient in terms of memory usage.
 
That's what i mean. You get the center of an Rect at map init.
It would be better to give the regions better names tbh.
  • Ini
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Spawn[0] = (Center of Red-base)
      • Set Spawn[1] = (Center of Green-Base)
      • Set Spawn[2] = (Center of Corner)
Every spawn wave you reuse the locations.
  • Spawn
    • Events
      • Time - Every 5.00 seconds of game time
    • Conditions
    • Actions
      • Unit - Create 1 Minion for Player 1 (Red) at Spawn[0] facing Default building facing degrees
      • Unit - Order (Last created unit) to Attack/Move to Spawn[2]
      • Unit - Create 1 Minion for Player 7 (Green) at Spawn[1] facing Default building facing degrees
      • Unit - Order (Last created unit) to Attack/Move to Spawn[2]
Even on the wave order this locations can still be used.
  • Reoder
    • Events
      • Unit - A unit enters Corner
    • Conditions
      • ((Triggering unit) is A Hero) Equal to False
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Triggering unit)) Equal to Player 1 (Red)
        • Then - Actions
          • Unit - Order (Triggering unit) to Attack/Move to Spawn[1]
        • Else - Actions
          • Unit - Order (Triggering unit) to Attack/Move to Spawn[0]
Complettly removes the need to remove them, looks nicer and is correct.
Edit: One could use non array-Locations but than you end with dozens of locations for wave pathing and spawning, which would flooding the variable list.
 
Last edited:
Status
Not open for further replies.
Top