• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Most efficient way to spawn enemies in TD

Status
Not open for further replies.
Level 7
Joined
Jun 23, 2009
Messages
297
I'm creating a TD, and I started a spawn system using 1 trigger per wave. Then, I realize I can improve the system quite a lot, and I start making it more and more simple, untill I get this:

  • Wave 1
    • Events
      • Time - Elapsed game time is 20.00 seconds
    • Conditions
    • Actions
      • Set BornEnemies = (((Online_Players x 4) + 2) / 4)
      • Set UnitType = Footmen
      • Set TempPoint = (Random point in Region 1 <gen>)
      • Unit - Create BornEnemies UnitType for Player 12 (Brown) at TempPoint facing Default building facing degrees
      • Set TempPoint = (Random point in Region 2 <gen>)
      • Unit - Create BornEnemies UnitType for Player 12 (Brown) at TempPoint facing Default building facing degrees
      • Set TempPoint = (Random point in Region 3 <gen>)
      • Unit - Create BornEnemies UnitType for Player 12 (Brown) at TempPoint facing Default building facing degrees
      • Set TempPoint = (Random point in Region 4 <gen>)
      • Unit - Create BornEnemies UnitType for Player 12 (Brown) at TempPoint facing Default building facing degrees
      • Wait 3.00 seconds
      • Trigger - Run (This trigger) (ignoring conditions)
      • Custom script: call RemoveLocation( udg_TempPoint)
      • Custom script: call DestroyTrigger(GetTriggeringTrigger())

So, I have a 4 region map, for 4 players (that's why x 4 / 4), and I want units to spawn according to the number of online players, that is, if 1 player is online, only 4 units are spawned (aprox number), but if 4 players are online then 16 units are spawned, etc.

What I'm asking, is for you guys to indicate me a better way to make the spawning system, by better I mean leakless, faster, more simple, and above all, the day I want to change the number of units spawned, I just need to change 1 number/variable.
Maybe even in 1 single trigger, that would be awesome.

If it's not too much to ask, I'd rather have someone explain how to do this, instead of doing it for me.


Thank you for your time.
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
  • Wave 1
    • Events
      • Time - Elapsed game time is 20.00 seconds
    • Conditions
    • Actions
      • Set BornEnemies = (((Online_Players x 4) + 2) / 4)
      • Set UnitType = Footmen
      • Set TempPoint = (Random point in Region 1 <gen>)
      • Unit - Create BornEnemies UnitType for Player 12 (Brown) at TempPoint facing Default building facing degrees
      • Custom script: call RemoveLocation( udg_TempPoint)
      • Set TempPoint = (Random point in Region 2 <gen>)
      • Unit - Create BornEnemies UnitType for Player 12 (Brown) at TempPoint facing Default building facing degrees
      • Custom script: call RemoveLocation( udg_TempPoint)
      • Set TempPoint = (Random point in Region 3 <gen>)
      • Unit - Create BornEnemies UnitType for Player 12 (Brown) at TempPoint facing Default building facing degrees
      • Custom script: call RemoveLocation( udg_TempPoint)
      • Set TempPoint = (Random point in Region 4 <gen>)
      • Unit - Create BornEnemies UnitType for Player 12 (Brown) at TempPoint facing Default building facing degrees
      • Custom script: call RemoveLocation( udg_TempPoint)
      • Wait 3.00 seconds
      • Trigger - Run (This trigger) (ignoring conditions)
      • Custom script: call DestroyTrigger(GetTriggeringTrigger())
1 player: BornEnemies = (((1 x 4) + 2) / 4) = 6/4 = 1,5 -> 1
2 players: BornEnemies = (((2 x 4) + 2) / 4) = 10/4 = 2,5 -> 2
3 players: BornEnemies = (((3 x 4) + 2) / 4) = 14/4 = 3,5 -> 3

So you might aswell use BornEnemies = players
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
No. Warcraft 3 doesn't "overwrite" points. It stores them as heavy but unvaluable garbage. Neither does with Unit Groups.
 
Status
Not open for further replies.
Top