• 🏆 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!
  • ✅ Time to vote for the top 3 models! The POLL for Hive's 6th HD Modeling Contest: Mechanical is now open! 📅 Poll close on July 16, 2024! 🔗 Cast your vote now!
  • ✅ The POLL for Hive's Texturing Contest #33 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!

unit spawn optimizing

Status
Not open for further replies.
Level 3
Joined
Jul 26, 2013
Messages
41
  • Attack humans
    • Events
      • Time - Every 200.00 seconds of game time
    • Conditions
    • Actions
      • Game - Display to (All players) the text: ...
      • Trigger - Turn on attack H spawns <gen>
      • Trigger - Turn on attack H spawns2 <gen>
      • Wait 1.50 seconds
      • Trigger - Turn off attack H spawns <gen>
      • Trigger - Turn off attack H spawns2 <gen>
      • AI - Ignore the guard positions of all Player 12 (Brown) units
  • attack H spawns
    • Events
      • Time - Every 0.50 seconds of game time
    • Conditions
    • Actions
      • Unit - Create 1 Skeletal Mage for Player 12 (Brown) at (Random point in gv3 <gen>) facing Default building facing degrees
      • Unit - Order (Last created unit) to Attack-Move To (Position of (Random unit from (Units owned by Player 3 (Teal))))
      • Unit - Create 1 Ghoul for Player 12 (Brown) at (Random point in gv3 <gen>) facing Default building facing degrees
      • Unit - Order (Last created unit) to Attack-Move To (Position of (Random unit from (Units owned by Player 3 (Teal))))
      • Unit - Create 1 Skeleton Warrior for Player 12 (Brown) at (Random point in gv3 <gen>) facing Default building facing degrees
      • Unit - Order (Last created unit) to Attack-Move To (Position of (Random unit from (Units owned by Player 3 (Teal))))
      • Unit - Create 1 Zombie for Player 12 (Brown) at (Random point in gv3 <gen>) facing Default building facing degrees
      • Unit - Order (Last created unit) to Attack-Move To (Position of (Random unit from (Units owned by Player 3 (Teal))))
      • Unit - Create 1 Zergling for Player 12 (Brown) at (Random point in gv3 <gen>) facing Default building facing degrees
      • Unit - Order (Last created unit) to Attack-Move To (Position of (Random unit from (Units owned by Player 3 (Teal))))
My question is what can I do to optimize it? 1) Are the triggers leeking in someway? 2) Is there a problem that I use ''waits'', and if so, what can I replace them with?
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
You can do this to get rid of the wait:
  • Attack humans
    • Events
      • Time - Every 200.00 seconds of game time
    • Conditions
    • Actions
      • Game - Display to (All players) the text: ...
      • Trigger - Turn on attack H spawns <gen>
      • Trigger - Turn on attack H spawns2 <gen>
  • attack H spawns
    • Events
      • Time - Every 0.50 seconds of game time
    • Conditions
    • Actions
      • Unit - Create 1 Skeletal Mage for Player 12 (Brown) at (Random point in gv3 <gen>) facing Default building facing degrees
      • Unit - Order (Last created unit) to Attack-Move To (Position of (Random unit from (Units owned by Player 3 (Teal))))
      • Unit - Create 1 Ghoul for Player 12 (Brown) at (Random point in gv3 <gen>) facing Default building facing degrees
      • Unit - Order (Last created unit) to Attack-Move To (Position of (Random unit from (Units owned by Player 3 (Teal))))
      • Unit - Create 1 Skeleton Warrior for Player 12 (Brown) at (Random point in gv3 <gen>) facing Default building facing degrees
      • Unit - Order (Last created unit) to Attack-Move To (Position of (Random unit from (Units owned by Player 3 (Teal))))
      • Unit - Create 1 Zombie for Player 12 (Brown) at (Random point in gv3 <gen>) facing Default building facing degrees
      • Unit - Order (Last created unit) to Attack-Move To (Position of (Random unit from (Units owned by Player 3 (Teal))))
      • Unit - Create 1 Zergling for Player 12 (Brown) at (Random point in gv3 <gen>) facing Default building facing degrees
      • Unit - Order (Last created unit) to Attack-Move To (Position of (Random unit from (Units owned by Player 3 (Teal))))
      • If count equal to 2 then
        • Turn off this trigger
        • Set count = 0
        • AI - Ignore the guard positions of all Player 12 (Brown) units
      • else
        • Set count = count + 1
      • endif
And read this: http://www.hiveworkshop.com/forums/triggers-scripts-269/things-leak-35124/
 
You can do it like Maker said, but you can still remove some lines in unit creation.


  • Init
    • Ereignisse
      • Map initialization
    • Bedingungen
    • Aktionen
      • Set UnitType[1] = Mage
      • Set UnitType[2] = Ghoul
      • Set UnitType[3] = Warriror
      • Set UnitType[4] = Zombie
      • Set UnitType[5] = Zergling


And when create units then use a loop.

  • For each (Integer A) from 1 to 5, do (Actions)
    • Loop - Actions
      • Unit - Create 1 UnitType[(Integer A)] for Player 12 at Point facing Point
      • Unit - Order (Last created unit) to Attack/Move to Point
If you would change number of unit types, also change the second integer value in top of loop.
And I would replace the Integer A by my own variable.


And as Maker has posted link, don't forget about memory leaks.
 
Status
Not open for further replies.
Top