• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Easy training unit trigger

Status
Not open for further replies.
Level 3
Joined
Oct 5, 2016
Messages
53
So, I have a trigger. Random number between 1 and 2. If 1 - train footman, otherwise train rifleman. But I can't make it train footman or another unit if rifleman is not available. Should be with "for each" trigger I assume.
 
Level 13
Joined
May 10, 2009
Messages
868
What if you create a variable array (unit-type) so you can store which units are available for training, then you add another integer variable (let's call it "count") to count how many units a player or computer may order to train it. Then, in the function "random number between", you put "1 and the count variable", and use the unit-type variable in the training function. Of course, you'd have to make another trigger detecting when a player/computer builds/upgrades their base so that they're be able to train such units. (As you know, barracks for both footman and rifleman, but rifleman needs the black smith).
 
Level 3
Joined
Oct 5, 2016
Messages
53
The thing is I made it more simple. I have every 5 sec event and every 5 sec I have a random unit to be trained. What I need is a list of few units under each random case which will build only 1 unit per trigger (conditions are not necessary).
 
Level 40
Joined
Feb 27, 2007
Messages
5,109
The thing is I made it more simple. I have every 5 sec event and every 5 sec I have a random unit to be trained. What I need is a list of few units under each random case which will build only 1 unit per trigger (conditions are not necessary).
That is exactly what BloodSoul described.
  • Events
    • Map Initialization
  • Conditions
  • Actions
    • Set SpawnTypes = 2
    • Set SpawnUnits[1] = Footman
    • Set SpawnUnits[2] = Rifleman
  • Events
    • -------- Whatever your spawn event is --------
  • Conditions
  • Actions
    • Set RandomSpawn = Random integer between 1 and SpawnTypes
    • Unit - Create 1 SpawnUnits[RandomSpawn] for Player....
  • Events
    • -------- Whatever the event that changes the units that can be spawned is --------
  • Conditions
  • Actions
    • -------- If you did only this then instead of riflemen you would spawn mortar teams --------
    • Set SpawnUnits[2] = Mortar Team
    • -------- If you did only this you would no longer spawn riflemen and instead only footmen --------
    • Set SpawnTypes = 1
    • -------- If you did only this then you could spawn footmen, riflemen, or knights! --------
    • Set SpawnTypes = 3
    • Set SpawnUnits[3] = Knight
 
Level 3
Joined
Oct 5, 2016
Messages
53
  • Human Build
    • Events
      • Time - Every 10.00 seconds of game time
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Set humanbuild = (Random integer number between 1 and 7)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • humanbuild Equal to 1
              • ((Picked player) controller) Equal to Computer
              • (Race of (Picked player)) Equal to Human
            • Then - Actions
              • Unit Group - Pick every unit in (Units owned by (Picked player)) and do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                    • Then - Actions
                      • Unit - Order (Picked unit) to train/upgrade to a Footman
                    • Else - Actions
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • humanbuild Equal to 2
              • ((Picked player) controller) Equal to Computer
              • (Race of (Picked player)) Equal to Human
            • Then - Actions
              • Unit Group - Pick every unit in (Units owned by (Picked player)) and do (Actions)
                • Loop - Actions
                  • Unit - Order (Picked unit) to train/upgrade to a Rifleman
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Count non-structure units controlled by (Picked player) (Include incomplete units)) Equal to (Count non-structure units controlled by (Picked player) (Exclude incomplete units))
                    • Then - Actions
                      • Unit - Order (Picked unit) to train/upgrade to a Footman
                    • Else - Actions
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • humanbuild Equal to 3
              • ((Picked player) controller) Equal to Computer
              • (Race of (Picked player)) Equal to Human
            • Then - Actions
              • Unit Group - Pick every unit in (Units owned by (Picked player)) and do (Actions)
                • Loop - Actions
                  • Unit - Order (Picked unit) to train/upgrade to a Knight
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Count non-structure units controlled by (Picked player) (Include incomplete units)) Equal to (Count non-structure units controlled by (Picked player) (Exclude incomplete units))
                    • Then - Actions
                      • Unit - Order (Picked unit) to train/upgrade to a Footman
                    • Else - Actions
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • humanbuild Equal to 3
              • ((Picked player) controller) Equal to Computer
              • (Race of (Picked player)) Equal to Human
            • Then - Actions
              • Unit Group - Pick every unit in (Units owned by (Picked player)) and do (Actions)
                • Loop - Actions
                  • Unit - Order (Picked unit) to train/upgrade to a Priest
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Count non-structure units controlled by (Picked player) (Include incomplete units)) Equal to (Count non-structure units controlled by (Picked player) (Exclude incomplete units))
                    • Then - Actions
                      • Unit - Order (Picked unit) to train/upgrade to a Rifleman
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Count non-structure units controlled by (Picked player) (Include incomplete units)) Equal to (Count non-structure units controlled by (Picked player) (Exclude incomplete units))
                        • Then - Actions
                          • Unit - Order (Picked unit) to train/upgrade to a Footman
                        • Else - Actions
                    • Else - Actions
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • humanbuild Equal to 4
              • ((Picked player) controller) Equal to Computer
              • (Race of (Picked player)) Equal to Human
            • Then - Actions
              • Unit Group - Pick every unit in (Units owned by (Picked player)) and do (Actions)
                • Loop - Actions
                  • Unit - Order (Picked unit) to train/upgrade to a Sorceress
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Count non-structure units controlled by (Picked player) (Include incomplete units)) Equal to (Count non-structure units controlled by (Picked player) (Exclude incomplete units))
                    • Then - Actions
                      • Unit - Order (Picked unit) to train/upgrade to a Rifleman
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Count non-structure units controlled by (Picked player) (Include incomplete units)) Equal to (Count non-structure units controlled by (Picked player) (Exclude incomplete units))
                        • Then - Actions
                          • Unit - Order (Picked unit) to train/upgrade to a Footman
                        • Else - Actions
                    • Else - Actions
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • humanbuild Equal to 5
              • ((Picked player) controller) Equal to Computer
              • (Race of (Picked player)) Equal to Human
            • Then - Actions
              • Unit Group - Pick every unit in (Units owned by (Picked player)) and do (Actions)
                • Loop - Actions
                  • Unit - Order (Picked unit) to train/upgrade to a Spell Breaker
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Count non-structure units controlled by (Picked player) (Include incomplete units)) Equal to (Count non-structure units controlled by (Picked player) (Exclude incomplete units))
                    • Then - Actions
                      • Unit - Order (Picked unit) to train/upgrade to a Knight
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Count non-structure units controlled by (Picked player) (Include incomplete units)) Equal to (Count non-structure units controlled by (Picked player) (Exclude incomplete units))
                        • Then - Actions
                          • Unit - Order (Picked unit) to train/upgrade to a Footman
                        • Else - Actions
                    • Else - Actions
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • humanbuild Equal to 6
              • ((Picked player) controller) Equal to Computer
              • (Race of (Picked player)) Equal to Human
            • Then - Actions
              • Unit Group - Pick every unit in (Units owned by (Picked player)) and do (Actions)
                • Loop - Actions
                  • Unit - Order (Picked unit) to train/upgrade to a Mortar Team
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Count non-structure units controlled by (Picked player) (Include incomplete units)) Equal to (Count non-structure units controlled by (Picked player) (Exclude incomplete units))
                    • Then - Actions
                      • Unit - Order (Picked unit) to train/upgrade to a Knight
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Count non-structure units controlled by (Picked player) (Include incomplete units)) Equal to (Count non-structure units controlled by (Picked player) (Exclude incomplete units))
                        • Then - Actions
                          • Unit - Order (Picked unit) to train/upgrade to a Footman
                        • Else - Actions
                    • Else - Actions
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • humanbuild Equal to 7
              • ((Picked player) controller) Equal to Computer
              • (Race of (Picked player)) Equal to Human
            • Then - Actions
              • Unit Group - Pick every unit in (Units owned by (Picked player)) and do (Actions)
                • Loop - Actions
                  • Unit - Order (Picked unit) to train/upgrade to a Siege Engine (Barrage)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Count non-structure units controlled by (Picked player) (Include incomplete units)) Equal to (Count non-structure units controlled by (Picked player) (Exclude incomplete units))
                    • Then - Actions
                      • Unit - Order (Picked unit) to train/upgrade to a Knight
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Count non-structure units controlled by (Picked player) (Include incomplete units)) Equal to (Count non-structure units controlled by (Picked player) (Exclude incomplete units))
                        • Then - Actions
                          • Unit - Order (Picked unit) to train/upgrade to a Footman
                        • Else - Actions
                    • Else - Actions
            • Else - Actions

Not this is what I did. It works though I'm not sure why.
 
Status
Not open for further replies.
Top