• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Trigger] capping spawns

Status
Not open for further replies.
Level 2
Joined
Apr 14, 2008
Messages
12
hey i was wondering if anyone could describe to me the triggers that i would need to be able to place a cap on the number of units of a certain type on the map. the units are created through spawning only and i want to have a trigger that will bring the trigger to spawn more units back on after the population of the type of units being capped has come down again. if this has already been posted please post a link as i couldn't find anything resent on it

thanks
 
Level 9
Joined
Feb 19, 2006
Messages
115
Just use a variable to store the number of those units in the map. Create a global integer, and each time you spawn a unit of that type, add 1 to the variable, and whenever a unit of that type dies, subtract 1 from it.
So, something like this...

  • Spawning trigger
    • Events
      • Something - some event (periodic event maybe?)
      • Conditions
        • Integer Comparison - (NumOfUnits less then MaxUnits)
      • Actions
        • Unit - Create unit blah blah blah
        • Set - Set(NumOfUnits to Arithmetic(NumOfUnits + 1))
  • Unit Dies
    • Events
      • A Unit Dies - Unit type equal to YourUnit
    • Conditions
    • Actions
      • Set - Set(NumOfUnits to Arithmetic(NumOfUnits - 1))
Make a different variable for each unit type, or try using arrays.
 
Status
Not open for further replies.
Top