• 🏆 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!

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