• 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] Unit Group Limit

Status
Not open for further replies.
Level 5
Joined
Nov 4, 2006
Messages
132
How would I limit the amount of units of a certain tech level that a player can have?

I have 3 different groups of units Tech1, Tech2 and Tech3 units

I want it so that every player can only have a maximum of
36 Tech 1 units
24 Tech 2 units
12 Tech 3 units

There are about 5 different units per tech level

How would I do this in GUI?
 
Level 16
Joined
Oct 12, 2008
Messages
1,570
If the units are trained like normal units, it is very simple:

Footman & Rifleman = Tech1
Mortar Team & Flying Machine = Tech2
Knight & Griphon Rider = Tech3

  • Train a unit
    • Events
      • Unit - A unit Finishes training a unit
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • (Unit-type of (Trained unit)) Equal to Footman
              • (Unit-type of (Trained unit)) Equal to Rifleman
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of units in Tech1[(Player number of (Owner of (Trained unit)))]) Less than or equal to 35
            • Then - Actions
              • Unit Group - Add (Trained unit) to Tech1[(Player number of (Owner of (Trained unit)))]
            • Else - Actions
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • (Unit-type of (Trained unit)) Equal to Mortar Team
              • (Unit-type of (Trained unit)) Equal to Flying Machine
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of units in Tech2[(Player number of (Owner of (Trained unit)))]) Less than or equal to 23
            • Then - Actions
              • Unit Group - Add (Trained unit) to Tech2[(Player number of (Owner of (Trained unit)))]
            • Else - Actions
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • (Unit-type of (Trained unit)) Equal to Knight
              • (Unit-type of (Trained unit)) Equal to Gryphon Rider
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of units in Tech3[(Player number of (Owner of (Trained unit)))]) Less than or equal to 11
            • Then - Actions
              • Unit Group - Add (Trained unit) to Tech3[(Player number of (Owner of (Trained unit)))]
            • Else - Actions
        • Else - Actions
 
Level 8
Joined
Dec 8, 2007
Messages
312
Sounds like simple Player - Limit Training of Unit-Type action
Here is example:
  • Limit
    • Events
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Player - Limit training of Footman to 36 for (Picked player)
          • Player - Limit training of Rifleman to 36 for (Picked player)
          • Player - Limit training of Mortar Team to 12 for (Picked player)
          • Player - ....and so on
 
Level 5
Joined
Nov 4, 2006
Messages
132
JansiGx thats not what I want as that would mean you could have 36 footman AND 36 rifleman while I wanted it so I could only have 36 Tech 1 units. eg: 18 footman and 18 fileman, or 10 footman and 26 rifleman.

But dont worry Eleandor and Yixx have shown me how to do it.
 
Level 16
Joined
Oct 12, 2008
Messages
1,570
Doombringer,, I actually dont know if a unit is deleted out of the unit group if it dies,,
I made a little trigger for it,,

  • Delete Unit
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Triggering unit) is in Tech1[Player Number of (owner of(triggering unit))]) Equal to True
        • Then - Actions
          • Unit Group - Remove (Triggering unit) from Tech1[Player Number of (owner of(triggering unit))]
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Triggering unit) is in Tech2[Player Number of (owner of(triggering unit))] Equal to True
        • Then - Actions
          • Unit Group - Remove (Triggering unit) from Tech2[Player Number of (owner of(triggering unit))]
        • Else - Actions If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Triggering unit) is in Tech3[Player Number of (owner of(triggering unit))]) Equal to True
        • Then - Actions
          • Unit Group - Remove (Triggering unit) from Tech3[Player Number of (owner of(triggering unit))]
        • Else - Actions
Hope it helped :thumbs_up:
 
Level 5
Joined
Nov 4, 2006
Messages
132
Yeh I figured that out myself but I was wondering how do I cancel units in the queue as it works fine exept it continues building the units in the queue so you can get about 5-6 more units than you are supposed to.
 
Last edited:
Status
Not open for further replies.
Top