Unit Cap

pride2518

New Member
Reaction score
4
How do I make it so that if X player has more than X units of type Fiend, it will not create units for him anymore? Here is the trigger I'm using to spawn.

Trigger:
  • Spawn
    • Events
      • Time - Every 10.00 seconds of game time
    • Conditions
    • Actions
      • Set Temp_Point = (Center of RedB <gen>)
      • If ((Player 1 (Red) slot status) Equal to Is playing) then do (Unit - Create 1 Fiend for Player 1 (Red) at Temp_Point facing Default building facing degrees) else do (Do nothing)
      • Custom script: call RemoveLocation (udg_Temp_Point)
      • Set Temp_Point = (Center of BlueB <gen>)
      • If ((Player 2 (Blue) slot status) Equal to Is playing) then do (Unit - Create 1 Fiend for Player 2 (Blue) at Temp_Point facing Default building facing degrees) else do (Do nothing)
      • Custom script: call RemoveLocation (udg_Temp_Point)
      • Set Temp_Point = (Center of TealB <gen>)
      • If ((Player 3 (Teal) slot status) Equal to Is playing) then do (Unit - Create 1 Fiend for Player 3 (Teal) at Temp_Point facing Default building facing degrees) else do (Do nothing)
      • Custom script: call RemoveLocation (udg_Temp_Point)
      • Set Temp_Point = (Center of PurpB <gen>)
      • If ((Player 4 (Purple) slot status) Equal to Is playing) then do (Unit - Create 1 Fiend for Player 4 (Purple) at Temp_Point facing Default building facing degrees) else do (Do nothing)
      • Custom script: call RemoveLocation (udg_Temp_Point)
      • Set Temp_Point = (Center of YellowB <gen>)
      • If ((Player 5 (Yellow) slot status) Equal to Is playing) then do (Unit - Create 1 Fiend for Player 5 (Yellow) at Temp_Point facing Default building facing degrees) else do (Do nothing)
      • Custom script: call RemoveLocation (udg_Temp_Point)
      • Set Temp_Point = (Center of OrangeB <gen>)
      • If ((Player 6 (Orange) slot status) Equal to Is playing) then do (Unit - Create 1 Fiend for Player 6 (Orange) at Temp_Point facing Default building facing degrees) else do (Do nothing)
      • Custom script: call RemoveLocation (udg_Temp_Point)
      • Set Temp_Point = (Center of GreenB <gen>)
      • If ((Player 7 (Green) slot status) Equal to Is playing) then do (Unit - Create 1 Fiend for Player 7 (Green) at Temp_Point facing Default building facing degrees) else do (Do nothing)
      • Custom script: call RemoveLocation (udg_Temp_Point)
      • Set Temp_Point = (Center of PinkB <gen>)
      • If ((Player 8 (Pink) slot status) Equal to Is playing) then do (Unit - Create 1 Fiend for Player 8 (Pink) at Temp_Point facing Default building facing degrees) else do (Do nothing)
      • Custom script: call RemoveLocation (udg_Temp_Point)
 

niceone

New Member
Reaction score
3
I guess check the whole map for how mutch units he has and then when its equal or smaller then 50 don't spawn a creep for that player.

Trigger:
  • Events
    • Conditions
      • (Number of units in (Units in (Playable map area) owned by Player 1 (Red))) Less than or equal to 50
    • Actions
    • Spawn for that player.
 

Accname

2D-Graphics enthusiast
Reaction score
1,464
save all the units you create via this trigger inside a unitgroup and check the number of units inside.
 

Inflicted

Currently inactive
Reaction score
63
yeah just have a few variables to count it, like Fiends_Alive: integer array[12]

and then have

Trigger:
  • actions
    • if (Fiends_Alive less than 50):
    • Set Temp_Point = (Center of RedB <gen>)
    • If ((Player 1 (Red) slot status) Equal to Is playing) then do (Unit - Create 1 Fiend for Player 1 (Red) at Temp_Point facing Default building facing degrees) else do (Do nothing)
    • Custom script: call RemoveLocation (udg_Temp_Point)
    • set Fiends_Alive[1] to Fiends_Alive[1]+1



Trigger:
  • events
    • unit - unit dies
    • conditions
    • unit type is *Fiend*
    • actions
    • set Fiends_Alive[Player number of (Owner of Dying unit)] to (Fiends_Alive[Player number of (Owner of Dying unit)] -1)

and then everytime u create one just add one on etc etc.. this is just rough, but this kindof system would work.


----------------------------------------

note: your method is also unnecessarily long, u could shorten it by using a Player Group's method.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      • Ghan
        Administrator - Servers are fun

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top