• 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.

Spawn Caps

Status
Not open for further replies.
Level 5
Joined
Feb 19, 2008
Messages
110
Hi, I want to make a spawn cap for each of the bases in my map.
Example:
One of my farm bases spawn "farmers" i want the cap of the farm spawn to be 5 units. So you can only have a maximum of 5 units from that base.

Anyone know how to do this?
 
Vars: Farmer count Array 12 (Integer)
Max farmers Array 12 (Integer)

  • Events:
    • Unit - A unit is trained
  • Conditions:
    • Unit type of triggering unit equal to Farmer
  • Actions:
    • If/Then/Else multiple functions:
      • If
        • Farmers[Player number of (owner of (Triggering unit))] equal to (Max Farmers[owner of(Triggering unit))]
      • Then
        • Player - Add (Cost of the farmer) To (Owner of (Triggering unit)) Current gold
        • Game - Display to (Player group(Owner of unit(Triggering unit))) the text: "You have too many farmers!"
        • Else
          • Set Farmers[Player number of (Owner of (triggering unit))] = Farmers[Player number of (Owner of (triggering unit))] + 1
  • Farmer dies
  • Events:
    • Unit - A unit dies
  • Conditions:
    • Unit type of triggering unit equal to Farmer
  • Actions:
    • Set Farmers[Player number of (Owner of (triggering unit))] = Farmers[Player number of (Owner of (triggering unit))] - 1
  • Set farm count
    • Events:
      • Unit - A unit finishes construction
    • Conditions:
      • Unit type of (Triggering unit) Equal to (Farm)
    • Actions:
      • Set Max farmers[Player number of (Owner of (triggering unit))] = Max farmers[Player number of (Owner of (triggering unit))] + 5
  • Set farm count -
    • Events:
      • Unit - A unit dies
    • Conditions:
      • Unit type of (Triggering unit) Equal to (Farm)
    • Actions:
      • Set Max farmers[Player number of (Owner of (triggering unit))] = [Player number of (Owner of (triggering unit))] - 5
 
Level 5
Joined
Feb 19, 2008
Messages
110
Well, it isnt trained, its spawned periodically every 120 seconds.
And it can be several bases spawning the same unit, do i have to make different units for each base?
 
Level 5
Joined
Feb 19, 2008
Messages
110
Kk, so i will have to make different units for each "farm" base? or could i add them to a group or something?
 
Status
Not open for further replies.
Top