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

Limit training of multiple unit-types to one value

Status
Not open for further replies.
Level 11
Joined
Aug 6, 2009
Messages
697
It only took me forever, but here you go:

  • Untitled Trigger 003
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- TempGroups are unit groups. --------
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Set TempInt = (Player number of (Picked player))
          • Set UnitLimit[TempInt] = 39
          • -------- UnitLimit is the maximum amount of units for all 3 unit types. --------
          • Set TempGroup = (Units owned by (Picked player) of type Footman)
          • Set TempGroup2 = (Units owned by (Picked player) of type Knight)
          • Set TempGroup3 = (Units owned by (Picked player) of type Rifleman)
          • Set UnitType1[TempInt] = (Number of units in TempGroup)
          • Set UnitType2[TempInt] = (Number of units in TempGroup2)
          • Set UnitType3[TempInt] = (Number of units in TempGroup3)
          • Unit Group - Remove all units of TempGroup from TempGroup
          • Unit Group - Remove all units of TempGroup2 from TempGroup2
          • Unit Group - Remove all units of TempGroup3 from TempGroup3
          • Custom script: call DestroyGroup(udg_TempGroup)
          • Custom script: call DestroyGroup(udg_TempGroup2)
          • Custom script: call DestroyGroup(udg_TempGroup3)
          • Player - Limit training of Footman to (UnitLimit[TempInt] - (UnitType2[TempInt] + UnitType3[TempInt])) for (Player(TempInt))
          • Player - Limit training of Knight to (UnitLimit[TempInt] - (UnitType1[TempInt] + UnitType3[TempInt])) for (Player(TempInt))
          • Player - Limit training of Rifleman to (UnitLimit[TempInt] - (UnitType1[TempInt] + UnitType2[TempInt])) for (Player(TempInt))
  • Untitled Trigger 001
    • Events
      • Unit - A unit Is issued an order with no target
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Issued order) Equal to (Order(footman))
          • (Issued order) Equal to (Order(rifleman))
          • (Issued order) Equal to (Order(knight))
    • Actions
      • Set TempInt = (Player number of (Owner of (Triggering unit)))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Issued order) Equal to (Order(footman))
        • Then - Actions
          • Set UnitType1[TempInt] = (UnitType1[TempInt] + 1)
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Issued order) Equal to (Order(knight))
            • Then - Actions
              • Set UnitType2[TempInt] = (UnitType2[TempInt] + 1)
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Issued order) Equal to (Order(rifleman))
                • Then - Actions
                  • Set UnitType3[TempInt] = (UnitType3[TempInt] + 1)
                • Else - Actions
      • Player - Limit training of Footman to (UnitLimit[TempInt] - (UnitType2[TempInt] + UnitType3[TempInt])) for (Player(TempInt))
      • Player - Limit training of Knight to (UnitLimit[TempInt] - (UnitType1[TempInt] + UnitType3[TempInt])) for (Player(TempInt))
      • Player - Limit training of Rifleman to (UnitLimit[TempInt] - (UnitType1[TempInt] + UnitType2[TempInt])) for (Player(TempInt))
  • Untitled Trigger 002
    • Events
      • Unit - A unit Dies
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Unit-type of (Triggering unit)) Equal to Footman
          • (Unit-type of (Triggering unit)) Equal to Knight
          • (Unit-type of (Triggering unit)) Equal to Rifleman
    • Actions
      • Set TempInt = (Player number of (Owner of (Dying unit)))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Triggering unit)) Equal to Footman
        • Then - Actions
          • Set UnitType1[TempInt] = (UnitType1[TempInt] - 1)
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Triggering unit)) Equal to Knight
            • Then - Actions
              • Set UnitType2[TempInt] = (UnitType2[TempInt] - 1)
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Unit-type of (Triggering unit)) Equal to Rifleman
                • Then - Actions
                  • Set UnitType3[TempInt] = (UnitType3[TempInt] - 1)
                • Else - Actions
      • Player - Limit training of Footman to (UnitLimit[TempInt] - (UnitType2[TempInt] + UnitType3[TempInt])) for (Player(TempInt))
      • Player - Limit training of Knight to (UnitLimit[TempInt] - (UnitType1[TempInt] + UnitType3[TempInt])) for (Player(TempInt))
      • Player - Limit training of Rifleman to (UnitLimit[TempInt] - (UnitType1[TempInt] + UnitType2[TempInt])) for (Player(TempInt))
  • Untitled Trigger 004
    • Events
      • Unit - A unit Cancels training a unit
    • Conditions
    • Actions
      • Set TempInt = (Player number of (Owner of (Triggering unit)))
      • Set CancelledUnit = (Trained unit-type)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • CancelledUnit Equal to Footman
              • CancelledUnit Equal to Knight
              • CancelledUnit Equal to Rifleman
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • CancelledUnit Equal to Footman
            • Then - Actions
              • Set UnitType1[TempInt] = (UnitType1[TempInt] - 1)
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • CancelledUnit Equal to Knight
                • Then - Actions
                  • Set UnitType2[TempInt] = (UnitType2[TempInt] - 1)
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • CancelledUnit Equal to Rifleman
                    • Then - Actions
                      • Set UnitType3[TempInt] = (UnitType3[TempInt] - 1)
                    • Else - Actions
          • Player - Limit training of Footman to (UnitLimit[TempInt] - (UnitType2[TempInt] + UnitType3[TempInt])) for (Player(TempInt))
          • Player - Limit training of Knight to (UnitLimit[TempInt] - (UnitType1[TempInt] + UnitType3[TempInt])) for (Player(TempInt))
          • Player - Limit training of Rifleman to (UnitLimit[TempInt] - (UnitType1[TempInt] + UnitType2[TempInt])) for (Player(TempInt))
        • Else - Actions
 

Attachments

  • LimitedUnitTrainingForCombinedUnitTypes.w3x
    22.3 KB · Views: 34
Level 15
Joined
Sep 6, 2015
Messages
576
It only took me forever, but here you go:

  • Untitled Trigger 003
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- TempGroups are unit groups. --------
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Set TempInt = (Player number of (Picked player))
          • Set UnitLimit[TempInt] = 39
          • -------- UnitLimit is the maximum amount of units for all 3 unit types. --------
          • Set TempGroup = (Units owned by (Picked player) of type Footman)
          • Set TempGroup2 = (Units owned by (Picked player) of type Knight)
          • Set TempGroup3 = (Units owned by (Picked player) of type Rifleman)
          • Set UnitType1[TempInt] = (Number of units in TempGroup)
          • Set UnitType2[TempInt] = (Number of units in TempGroup2)
          • Set UnitType3[TempInt] = (Number of units in TempGroup3)
          • Unit Group - Remove all units of TempGroup from TempGroup
          • Unit Group - Remove all units of TempGroup2 from TempGroup2
          • Unit Group - Remove all units of TempGroup3 from TempGroup3
          • Custom script: call DestroyGroup(udg_TempGroup)
          • Custom script: call DestroyGroup(udg_TempGroup2)
          • Custom script: call DestroyGroup(udg_TempGroup3)
          • Player - Limit training of Footman to (UnitLimit[TempInt] - (UnitType2[TempInt] + UnitType3[TempInt])) for (Player(TempInt))
          • Player - Limit training of Knight to (UnitLimit[TempInt] - (UnitType1[TempInt] + UnitType3[TempInt])) for (Player(TempInt))
          • Player - Limit training of Rifleman to (UnitLimit[TempInt] - (UnitType1[TempInt] + UnitType2[TempInt])) for (Player(TempInt))
  • Untitled Trigger 001
    • Events
      • Unit - A unit Is issued an order with no target
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Issued order) Equal to (Order(footman))
          • (Issued order) Equal to (Order(rifleman))
          • (Issued order) Equal to (Order(knight))
    • Actions
      • Set TempInt = (Player number of (Owner of (Triggering unit)))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Issued order) Equal to (Order(footman))
        • Then - Actions
          • Set UnitType1[TempInt] = (UnitType1[TempInt] + 1)
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Issued order) Equal to (Order(knight))
            • Then - Actions
              • Set UnitType2[TempInt] = (UnitType2[TempInt] + 1)
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Issued order) Equal to (Order(rifleman))
                • Then - Actions
                  • Set UnitType3[TempInt] = (UnitType3[TempInt] + 1)
                • Else - Actions
      • Player - Limit training of Footman to (UnitLimit[TempInt] - (UnitType2[TempInt] + UnitType3[TempInt])) for (Player(TempInt))
      • Player - Limit training of Knight to (UnitLimit[TempInt] - (UnitType1[TempInt] + UnitType3[TempInt])) for (Player(TempInt))
      • Player - Limit training of Rifleman to (UnitLimit[TempInt] - (UnitType1[TempInt] + UnitType2[TempInt])) for (Player(TempInt))
  • Untitled Trigger 002
    • Events
      • Unit - A unit Dies
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Unit-type of (Triggering unit)) Equal to Footman
          • (Unit-type of (Triggering unit)) Equal to Knight
          • (Unit-type of (Triggering unit)) Equal to Rifleman
    • Actions
      • Set TempInt = (Player number of (Owner of (Dying unit)))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Triggering unit)) Equal to Footman
        • Then - Actions
          • Set UnitType1[TempInt] = (UnitType1[TempInt] - 1)
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Triggering unit)) Equal to Knight
            • Then - Actions
              • Set UnitType2[TempInt] = (UnitType2[TempInt] - 1)
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Unit-type of (Triggering unit)) Equal to Rifleman
                • Then - Actions
                  • Set UnitType3[TempInt] = (UnitType3[TempInt] - 1)
                • Else - Actions
      • Player - Limit training of Footman to (UnitLimit[TempInt] - (UnitType2[TempInt] + UnitType3[TempInt])) for (Player(TempInt))
      • Player - Limit training of Knight to (UnitLimit[TempInt] - (UnitType1[TempInt] + UnitType3[TempInt])) for (Player(TempInt))
      • Player - Limit training of Rifleman to (UnitLimit[TempInt] - (UnitType1[TempInt] + UnitType2[TempInt])) for (Player(TempInt))
  • Untitled Trigger 004
    • Events
      • Unit - A unit Cancels training a unit
    • Conditions
    • Actions
      • Set TempInt = (Player number of (Owner of (Triggering unit)))
      • Set CancelledUnit = (Trained unit-type)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • CancelledUnit Equal to Footman
              • CancelledUnit Equal to Knight
              • CancelledUnit Equal to Rifleman
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • CancelledUnit Equal to Footman
            • Then - Actions
              • Set UnitType1[TempInt] = (UnitType1[TempInt] - 1)
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • CancelledUnit Equal to Knight
                • Then - Actions
                  • Set UnitType2[TempInt] = (UnitType2[TempInt] - 1)
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • CancelledUnit Equal to Rifleman
                    • Then - Actions
                      • Set UnitType3[TempInt] = (UnitType3[TempInt] - 1)
                    • Else - Actions
          • Player - Limit training of Footman to (UnitLimit[TempInt] - (UnitType2[TempInt] + UnitType3[TempInt])) for (Player(TempInt))
          • Player - Limit training of Knight to (UnitLimit[TempInt] - (UnitType1[TempInt] + UnitType3[TempInt])) for (Player(TempInt))
          • Player - Limit training of Rifleman to (UnitLimit[TempInt] - (UnitType1[TempInt] + UnitType2[TempInt])) for (Player(TempInt))
        • Else - Actions
Wow, it works. Thank you very much.

Just, what should I write in the order strings for unit types, their current name, name of the base unit, or some special order string for the unit?
 
Level 11
Joined
Aug 6, 2009
Messages
697
I tend to use this when the object editor doesn't say the ID of the unit. I assume you are using custom units, so just order the barracks to create a footman for example, and then the order unit should pop up on the screen. Someone probably knows a better way. ¯\_(ツ)_/¯

  • Untitled Trigger 005
    • Events
      • Unit - A unit Is issued an order with no target
    • Conditions
    • Actions
      • Game - Display to (All players) the text: (String((Issued order)))
Edit:My bad, wrong event.
 
Level 16
Joined
Mar 24, 2017
Messages
827
It only took me forever, but here you go:

  • Untitled Trigger 003
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- TempGroups are unit groups. --------
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Set TempInt = (Player number of (Picked player))
          • Set UnitLimit[TempInt] = 39
          • -------- UnitLimit is the maximum amount of units for all 3 unit types. --------
          • Set TempGroup = (Units owned by (Picked player) of type Footman)
          • Set TempGroup2 = (Units owned by (Picked player) of type Knight)
          • Set TempGroup3 = (Units owned by (Picked player) of type Rifleman)
          • Set UnitType1[TempInt] = (Number of units in TempGroup)
          • Set UnitType2[TempInt] = (Number of units in TempGroup2)
          • Set UnitType3[TempInt] = (Number of units in TempGroup3)
          • Unit Group - Remove all units of TempGroup from TempGroup
          • Unit Group - Remove all units of TempGroup2 from TempGroup2
          • Unit Group - Remove all units of TempGroup3 from TempGroup3
          • Custom script: call DestroyGroup(udg_TempGroup)
          • Custom script: call DestroyGroup(udg_TempGroup2)
          • Custom script: call DestroyGroup(udg_TempGroup3)
          • Player - Limit training of Footman to (UnitLimit[TempInt] - (UnitType2[TempInt] + UnitType3[TempInt])) for (Player(TempInt))
          • Player - Limit training of Knight to (UnitLimit[TempInt] - (UnitType1[TempInt] + UnitType3[TempInt])) for (Player(TempInt))
          • Player - Limit training of Rifleman to (UnitLimit[TempInt] - (UnitType1[TempInt] + UnitType2[TempInt])) for (Player(TempInt))
  • Untitled Trigger 001
    • Events
      • Unit - A unit Is issued an order with no target
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Issued order) Equal to (Order(footman))
          • (Issued order) Equal to (Order(rifleman))
          • (Issued order) Equal to (Order(knight))
    • Actions
      • Set TempInt = (Player number of (Owner of (Triggering unit)))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Issued order) Equal to (Order(footman))
        • Then - Actions
          • Set UnitType1[TempInt] = (UnitType1[TempInt] + 1)
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Issued order) Equal to (Order(knight))
            • Then - Actions
              • Set UnitType2[TempInt] = (UnitType2[TempInt] + 1)
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Issued order) Equal to (Order(rifleman))
                • Then - Actions
                  • Set UnitType3[TempInt] = (UnitType3[TempInt] + 1)
                • Else - Actions
      • Player - Limit training of Footman to (UnitLimit[TempInt] - (UnitType2[TempInt] + UnitType3[TempInt])) for (Player(TempInt))
      • Player - Limit training of Knight to (UnitLimit[TempInt] - (UnitType1[TempInt] + UnitType3[TempInt])) for (Player(TempInt))
      • Player - Limit training of Rifleman to (UnitLimit[TempInt] - (UnitType1[TempInt] + UnitType2[TempInt])) for (Player(TempInt))
  • Untitled Trigger 002
    • Events
      • Unit - A unit Dies
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Unit-type of (Triggering unit)) Equal to Footman
          • (Unit-type of (Triggering unit)) Equal to Knight
          • (Unit-type of (Triggering unit)) Equal to Rifleman
    • Actions
      • Set TempInt = (Player number of (Owner of (Dying unit)))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Triggering unit)) Equal to Footman
        • Then - Actions
          • Set UnitType1[TempInt] = (UnitType1[TempInt] - 1)
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Triggering unit)) Equal to Knight
            • Then - Actions
              • Set UnitType2[TempInt] = (UnitType2[TempInt] - 1)
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Unit-type of (Triggering unit)) Equal to Rifleman
                • Then - Actions
                  • Set UnitType3[TempInt] = (UnitType3[TempInt] - 1)
                • Else - Actions
      • Player - Limit training of Footman to (UnitLimit[TempInt] - (UnitType2[TempInt] + UnitType3[TempInt])) for (Player(TempInt))
      • Player - Limit training of Knight to (UnitLimit[TempInt] - (UnitType1[TempInt] + UnitType3[TempInt])) for (Player(TempInt))
      • Player - Limit training of Rifleman to (UnitLimit[TempInt] - (UnitType1[TempInt] + UnitType2[TempInt])) for (Player(TempInt))
  • Untitled Trigger 004
    • Events
      • Unit - A unit Cancels training a unit
    • Conditions
    • Actions
      • Set TempInt = (Player number of (Owner of (Triggering unit)))
      • Set CancelledUnit = (Trained unit-type)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • CancelledUnit Equal to Footman
              • CancelledUnit Equal to Knight
              • CancelledUnit Equal to Rifleman
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • CancelledUnit Equal to Footman
            • Then - Actions
              • Set UnitType1[TempInt] = (UnitType1[TempInt] - 1)
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • CancelledUnit Equal to Knight
                • Then - Actions
                  • Set UnitType2[TempInt] = (UnitType2[TempInt] - 1)
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • CancelledUnit Equal to Rifleman
                    • Then - Actions
                      • Set UnitType3[TempInt] = (UnitType3[TempInt] - 1)
                    • Else - Actions
          • Player - Limit training of Footman to (UnitLimit[TempInt] - (UnitType2[TempInt] + UnitType3[TempInt])) for (Player(TempInt))
          • Player - Limit training of Knight to (UnitLimit[TempInt] - (UnitType1[TempInt] + UnitType3[TempInt])) for (Player(TempInt))
          • Player - Limit training of Rifleman to (UnitLimit[TempInt] - (UnitType1[TempInt] + UnitType2[TempInt])) for (Player(TempInt))
        • Else - Actions

this may come in very useful
 
Status
Not open for further replies.
Top