• 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.

[Solved] Spawning Units

Status
Not open for further replies.
Level 11
Joined
Jun 20, 2017
Messages
380
So I came up with this, but the second unit cannot be spawn!?
The maximum food is 300, so 1 food per animals.
Any better/shorter trigger?!
  • Spawning Animals
    • Events
      • Unit - A unit Finishes training a unit
    • Conditions
    • Actions
      • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Unit-type of (Trained unit)) is Undead) Equal to (==) True
        • Then - Actions
          • Set Point = (Rally-Point of (Triggering unit) as a point)
          • Set Point2 = (Position of (Triggering unit))
          • Set Point3 = (Point2 offset by 64.00 towards (Angle from Point2 to Point) degrees)
          • Set Player = (Owner of (Triggering unit))
          • Set Integer = (Player number of Player)
            • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (Unit-type of (Trained unit)) Equal to (==) Chicken
              • Then - Actions
                • Unit - Order (Triggering unit) to train/upgrade to a Chicken
                • Unit - Remove (Trained unit) from the game
                  • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                    • Then - Actions
                      • Unit - Create 1 Chicken for (Triggering player) at Point3 facing Default building facing (270.0) degrees
                      • Unit Group - Add (Last created unit) to UnitGroup_Animals
                      • Unit - Move (Last created unit) instantly to Point3
                      • Unit - Set the custom value of (Last created unit) to (Player number of (Owner of (Triggering unit)))
                      • Unit - Order (Last created unit) to Move To Point
                    • Else - Actions
                      • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • Unit_Animals Not equal to (!=) No unit
                          • (Custom value of Unit_Animals) Equal to (==) (Player number of (Owner of (Triggering unit)))
                        • Then - Actions
                          • Set Unit_Animals = (Random unit from UnitGroup_Animals)
                          • Set Point4 = (Position of Unit_Animals)
                          • Unit Group - Remove Unit_Animals from UnitGroups_Animals[(Player number of (Owner of (Triggering unit)))]
                          • Unit - Remove Unit_Animals from the game
                          • Wait 30.00 seconds
                          • Unit - Create 1 Chicken 2 for (Triggering player) at Point4 facing Default building facing (270.0) degrees
                          • Unit - Set the custom value of (Last created unit) to (Player number of (Owner of (Triggering unit)))
                          • Unit - Create 1 Dummy Animals for (Triggering player) at Point4 facing Default building facing (270.0) degrees
                          • Animation - Change (Last created unit)'s size to (30.00%, 30.00%, 30.00%) of its original size
                          • Unit - Add a 1.50 second Generic expiration timer to (Last created unit)
                          • Custom script: call RemoveLocation(udg_Point4)
                        • Else - Actions
              • Else - Actions
            • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (Unit-type of (Trained unit)) Equal to (==) Rabbit
              • Then - Actions
                • Unit - Order (Triggering unit) to train/upgrade to a Rabbit
                • Unit - Remove (Trained unit) from the game
                  • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                    • Then - Actions
                      • Unit - Create 1 Rabbit for (Triggering player) at Point3 facing Default building facing (270.0) degrees
                      • Unit Group - Add (Last created unit) to UnitGroup_Animals
                      • Unit - Move (Last created unit) instantly to Point3
                      • Unit - Set the custom value of (Last created unit) to (Player number of (Owner of (Triggering unit)))
                      • Unit - Order (Last created unit) to Move To Point
                    • Else - Actions
                      • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • Unit_Animals Not equal to (!=) No unit
                          • (Custom value of Unit_Animals) Equal to (==) (Player number of (Owner of (Triggering unit)))
                        • Then - Actions
                          • Set Unit_Animals = (Random unit from UnitGroup_Animals)
                          • Set Point4 = (Position of Unit_Animals)
                          • Unit Group - Remove Unit_Animals from UnitGroups_Animals[(Player number of (Owner of (Triggering unit)))]
                          • Unit - Remove Unit_Animals from the game
                          • Wait 30.00 seconds
                          • Unit - Create 1 Rabbit 2 for (Triggering player) at Point4 facing Default building facing (270.0) degrees
                          • Unit - Set the custom value of (Last created unit) to (Player number of (Owner of (Triggering unit)))
                          • Unit - Create 1 Dummy Animals for (Triggering player) at Point4 facing Default building facing (270.0) degrees
                          • Animation - Change (Last created unit)'s size to (30.00%, 30.00%, 30.00%) of its original size
                          • Unit - Add a 1.50 second Generic expiration timer to (Last created unit)
                          • Custom script: call RemoveLocation(udg_Point4)
                        • Else - Actions
              • Else - Actions
            • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (Unit-type of (Trained unit)) Equal to (==) Sheep
              • Then - Actions
                • Unit - Order (Triggering unit) to train/upgrade to a Sheep
                • Unit - Remove (Trained unit) from the game
                  • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                    • Then - Actions
                      • Unit - Create 1 Sheep for (Triggering player) at Point3 facing Default building facing (270.0) degrees
                      • Unit Group - Add (Last created unit) to UnitGroup_Animals
                      • Unit - Move (Last created unit) instantly to Point3
                      • Unit - Set the custom value of (Last created unit) to (Player number of (Owner of (Triggering unit)))
                      • Unit - Order (Last created unit) to Move To Point
                    • Else - Actions
                      • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • Unit_Animals Not equal to (!=) No unit
                          • (Custom value of Unit_Animals) Equal to (==) (Player number of (Owner of (Triggering unit)))
                        • Then - Actions
                          • Set Unit_Animals = (Random unit from UnitGroup_Animals)
                          • Set Point4 = (Position of Unit_Animals)
                          • Unit Group - Remove Unit_Animals from UnitGroups_Animals[(Player number of (Owner of (Triggering unit)))]
                          • Unit - Remove Unit_Animals from the game
                          • Wait 30.00 seconds
                          • Unit - Create 1 Sheep 2 for (Triggering player) at Point4 facing Default building facing (270.0) degrees
                          • Unit - Set the custom value of (Last created unit) to (Player number of (Owner of (Triggering unit)))
                          • Unit - Create 1 Dummy Animals for (Triggering player) at Point4 facing Default building facing (270.0) degrees
                          • Animation - Change (Last created unit)'s size to (30.00%, 30.00%, 30.00%) of its original size
                          • Unit - Add a 1.50 second Generic expiration timer to (Last created unit)
                          • Custom script: call RemoveLocation(udg_Point4)
                        • Else - Actions
              • Else - Actions
            • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (Unit-type of (Trained unit)) Equal to (==) Pig
              • Then - Actions
                • Unit - Order (Triggering unit) to train/upgrade to a Pig
                • Unit - Remove (Trained unit) from the game
                  • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                    • Then - Actions
                      • Unit - Create 1 Pig for (Triggering player) at Point3 facing Default building facing (270.0) degrees
                      • Unit Group - Add (Last created unit) to UnitGroup_Animals
                      • Unit - Move (Last created unit) instantly to Point3
                      • Unit - Set the custom value of (Last created unit) to (Player number of (Owner of (Triggering unit)))
                      • Unit - Order (Last created unit) to Move To Point
                    • Else - Actions
                      • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • Unit_Animals Not equal to (!=) No unit
                          • (Custom value of Unit_Animals) Equal to (==) (Player number of (Owner of (Triggering unit)))
                        • Then - Actions
                          • Set Unit_Animals = (Random unit from UnitGroup_Animals)
                          • Set Point4 = (Position of Unit_Animals)
                          • Unit Group - Remove Unit_Animals from UnitGroups_Animals[(Player number of (Owner of (Triggering unit)))]
                          • Unit - Remove Unit_Animals from the game
                          • Wait 30.00 seconds
                          • Unit - Create 1 Pig 2 for (Triggering player) at Point4 facing Default building facing (270.0) degrees
                          • Unit - Set the custom value of (Last created unit) to (Player number of (Owner of (Triggering unit)))
                          • Unit - Create 1 Dummy Animals for (Triggering player) at Point4 facing Default building facing (270.0) degrees
                          • Animation - Change (Last created unit)'s size to (30.00%, 30.00%, 30.00%) of its original size
                          • Unit - Add a 1.50 second Generic expiration timer to (Last created unit)
                          • Custom script: call RemoveLocation(udg_Point4)
                        • Else - Actions
              • Else - Actions
          • Custom script: call RemoveLocation(udg_Point)
          • Custom script: call RemoveLocation(udg_Point2)
          • Custom script: call RemoveLocation(udg_Point3)
        • Else - Actions
      • -------- Stuck --------
      • Set Integer_Stuck = 0
      • Unit Group - Pick every unit in UnitGroup_Stuck and do (Actions)
        • Loop - Actions
          • Unit - Set the custom value of (Picked unit) to Integer_Stuck
          • Set Points_Stuck[Integer_Stuck] = (Position of (Picked unit))
          • Set Integer_Stuck = (Integer_Stuck + 1)
          • Custom script: call RemoveLocation (udg_Points_Stuck[udg_Integer_Stuck])
      • Unit Group - Pick every unit in UnitGroup_Stuck and do (Actions)
        • Loop - Actions
          • Set Point = (Position of (Picked unit))
            • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (X of Point) Equal to (==) (X of Points_Stuck[(Custom value of (Picked unit))])
                • (Y of Point) Equal to (==) (Y of Points_Stuck[(Custom value of (Picked unit))])
              • Then - Actions
                • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • (Terrain pathing at Point of type Walkability is off) Equal to (==) False
                  • Then - Actions
                    • Unit - Move (Picked unit) instantly to Point
                  • Else - Actions
                • Set Integer2 = (Random integer number between 1 and 18)
                • Set Point2 = (Random point in Rects_Way[Integer_Stuck])
                • Unit - Set level of RegionWanderer for (Picked unit) to Integer2
                • Unit - Order (Picked unit) to Attack-Move To Point2
                • Custom script: call RemoveLocation (udg_Point2)
              • Else - Actions
          • Custom script: call RemoveLocation (udg_Point)
 
Last edited:
Status
Not open for further replies.
Top