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

[Trigger] Order unit to repetitively build

Status
Not open for further replies.
Level 6
Joined
Jul 23, 2018
Messages
243
Hello everyone,
Today I make 2 triggers that makes units to start building and another one to make them repetitive building. But they don't seem to work. Units do nothing when the game started. And I want to avoid the hard way which is specifying a unit. There is only 4 units in the map but they did nothing. I know my triggers hace leaks leaked but I'm testing if these triggers work or not.
  • Siege Ini
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units of type Mechanical Engineer) and do (Actions)
        • Loop - Actions
          • Unit Group - Add (Picked unit) to GroupCast[0]
      • Set SiegeBuildG[0] = (Units in South Rect <gen> matching (((Owner of (Matching unit)) Equal to Player 6 (Orange)) and ((Unit-type of (Matching unit)) Equal to Mechanical Engineer)))
      • Set SiegeBuildG[1] = (Units in North Rect <gen> matching (((Owner of (Matching unit)) Equal to Player 12 (Brown)) and ((Unit-type of (Matching unit)) Equal to Mechanical Engineer)))
      • Set Loc_Sie[0] = (Center of Siege Build <gen>)
      • Set Loc_Sie[1] = (Center of Siege Build Copy <gen>)
      • Set Loc_Sie[2] = (Center of Siege Build Copy 2 <gen>)
      • Set Loc_Sie[3] = (Center of Siege Build Copy 3 <gen>)
      • Unit Group - Pick every unit in SiegeBuildG[0] and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is in GroupCast[0]) Equal to True
            • Then - Actions
              • Unit - Order (Picked unit) to build a Ballista (Building) at Loc_Sie[0]
              • Unit - Order (Picked unit) to build a Ballista (Building) at Loc_Sie[1]
              • Unit Group - Add all units of GroupCast[0] to GroupCast[1]
              • Unit Group - Remove all units of GroupCast[0] from GroupCast[0]
            • Else - Actions
      • Unit Group - Pick every unit in SiegeBuildG[1] and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is in GroupCast[0]) Equal to True
            • Then - Actions
              • Unit - Order (Picked unit) to build a Ballista (Building) at Loc_Sie[2]
              • Unit - Order (Picked unit) to build a Ballista (Building) at Loc_Sie[3]
              • Unit Group - Add all units of GroupCast[0] to GroupCast[1]
              • Unit Group - Remove all units of GroupCast[0] from GroupCast[0]
            • Else - Actions
      • Custom script: call RemoveLocation(udg_Loc_Sie[0])
      • Custom script: call RemoveLocation(udg_Loc_Sie[1])
      • Custom script: call RemoveLocation(udg_Loc_Sie[2])
      • Custom script: call RemoveLocation(udg_Loc_Sie[3])
  • Siege Repeat
    • Events
      • Unit - A unit owned by Player 6 (Orange) Finishes construction
      • Unit - A unit owned by Player 12 (Brown) Finishes construction
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Unit-type of (Triggering unit)) Equal to Catapult (Building)
          • (Unit-type of (Triggering unit)) Equal to Glaive Thrower (Building)
          • (Unit-type of (Triggering unit)) Equal to Demolisher (Building)
          • (Unit-type of (Triggering unit)) Equal to Ballista (Building)
    • Actions
      • Wait 3.00 seconds
      • Set SiegeBuildG[0] = (Units in South Rect <gen> matching (((Owner of (Matching unit)) Equal to Player 6 (Orange)) and ((Unit-type of (Matching unit)) Equal to Mechanical Engineer)))
      • Set SiegeBuildG[1] = (Units in North Rect <gen> matching (((Owner of (Matching unit)) Equal to Player 12 (Brown)) and ((Unit-type of (Matching unit)) Equal to Mechanical Engineer)))
      • Set Loc_Sie[0] = (Center of Siege Build <gen>)
      • Set Loc_Sie[1] = (Center of Siege Build Copy <gen>)
      • Set Loc_Sie[2] = (Center of Siege Build Copy 2 <gen>)
      • Set Loc_Sie[3] = (Center of Siege Build Copy 3 <gen>)
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in SiegeBuildG[0] and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is in GroupCast[0]) Equal to True
            • Then - Actions
              • Unit - Order (Picked unit) to build a Ballista (Building) at Loc_Sie[0]
              • Unit - Order (Picked unit) to build a Ballista (Building) at Loc_Sie[1]
              • Unit Group - Add all units of GroupCast[0] to GroupCast[1]
              • Unit Group - Remove all units of GroupCast[0] from GroupCast[0]
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Picked unit) is in GroupCast[1]) Equal to True
                • Then - Actions
                  • Unit - Order (Picked unit) to build a Catapult (Building) at Loc_Sie[0]
                  • Unit - Order (Picked unit) to build a Catapult (Building) at Loc_Sie[1]
                  • Unit Group - Add all units of GroupCast[1] to GroupCast[2]
                  • Unit Group - Remove all units of GroupCast[1] from GroupCast[1]
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • ((Picked unit) is in GroupCast[2]) Equal to True
                    • Then - Actions
                      • Unit - Order (Picked unit) to build a Glaive Thrower (Building) at Loc_Sie[0]
                      • Unit - Order (Picked unit) to build a Glaive Thrower (Building) at Loc_Sie[1]
                      • Unit Group - Add all units of GroupCast[2] to GroupCast[3]
                      • Unit Group - Remove all units of GroupCast[2] from GroupCast[2]
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • ((Picked unit) is in GroupCast[3]) Equal to True
                        • Then - Actions
                          • Unit - Order (Picked unit) to build a Demolisher (Building) at Loc_Sie[0]
                          • Unit - Order (Picked unit) to build a Demolisher (Building) at Loc_Sie[1]
                          • Unit Group - Add all units of GroupCast[3] to GroupCast[0]
                          • Unit Group - Remove all units of GroupCast[3] from GroupCast[3]
                        • Else - Actions
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in SiegeBuildG[1] and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is in GroupCast[0]) Equal to True
            • Then - Actions
              • Unit - Order (Picked unit) to build a Ballista (Building) at Loc_Sie[2]
              • Unit - Order (Picked unit) to build a Ballista (Building) at Loc_Sie[3]
              • Unit Group - Add all units of GroupCast[0] to GroupCast[1]
              • Unit Group - Remove all units of GroupCast[0] from GroupCast[0]
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Picked unit) is in GroupCast[1]) Equal to True
                • Then - Actions
                  • Unit - Order (Picked unit) to build a Catapult (Building) at Loc_Sie[2]
                  • Unit - Order (Picked unit) to build a Catapult (Building) at Loc_Sie[3]
                  • Unit Group - Add all units of GroupCast[1] to GroupCast[2]
                  • Unit Group - Remove all units of GroupCast[1] from GroupCast[1]
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • ((Picked unit) is in GroupCast[2]) Equal to True
                    • Then - Actions
                      • Unit - Order (Picked unit) to build a Glaive Thrower (Building) at Loc_Sie[2]
                      • Unit - Order (Picked unit) to build a Glaive Thrower (Building) at Loc_Sie[3]
                      • Unit Group - Add all units of GroupCast[2] to GroupCast[3]
                      • Unit Group - Remove all units of GroupCast[2] from GroupCast[2]
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • ((Picked unit) is in GroupCast[3]) Equal to True
                        • Then - Actions
                          • Unit - Order (Picked unit) to build a Demolisher (Building) at Loc_Sie[2]
                          • Unit - Order (Picked unit) to build a Demolisher (Building) at Loc_Sie[3]
                          • Unit Group - Add all units of GroupCast[3] to GroupCast[0]
                          • Unit Group - Remove all units of GroupCast[3] from GroupCast[3]
                        • Else - Actions
      • Custom script: call RemoveLocation(udg_Loc_Sie[0])
      • Custom script: call RemoveLocation(udg_Loc_Sie[1])
      • Custom script: call RemoveLocation(udg_Loc_Sie[2])
      • Custom script: call RemoveLocation(udg_Loc_Sie[3])
I have 3 more like the third trigger which replaces glaive thrower (building) and other mobile siege weapon
  • Catapult
    • Events
      • Unit - A unit owned by Player 1 (Red) Finishes construction
      • Unit - A unit owned by Player 2 (Blue) Finishes construction
      • Unit - A unit owned by Player 3 (Teal) Finishes construction
      • Unit - A unit owned by Player 4 (Purple) Finishes construction
      • Unit - A unit owned by Player 5 (Yellow) Finishes construction
      • Unit - A unit owned by Player 6 (Orange) Finishes construction
      • Unit - A unit owned by Player 7 (Green) Finishes construction
      • Unit - A unit owned by Player 8 (Pink) Finishes construction
      • Unit - A unit owned by Player 9 (Gray) Finishes construction
      • Unit - A unit owned by Player 10 (Light Blue) Finishes construction
      • Unit - A unit owned by Player 11 (Dark Green) Finishes construction
      • Unit - A unit owned by Player 12 (Brown) Finishes construction
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Catapult (Building)
    • Actions
      • Set CV = (Custom value of (Triggering unit))
      • Set SW[CV] = (Triggering unit)
      • Set Loc_Sie[CV] = (Position of SW[CV])
      • Unit - Remove SW[CV] from the game
      • Unit - Create 1 Catapult (Unit) for (Owner of (Constructed structure)) at Loc_Sie[CV] facing Default building facing degrees
      • Custom script: call RemoveLocation(udg_Loc_Sie[udg_CV])
      • Set CV = (Custom value of (Last created unit))
      • Set SW[CV] = (Last created unit)
      • Set Loc_Sie[CV] = (Position of SW[CV])
      • Custom script: set bj_wantDestroyGroup = true
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (SW[CV] belongs to an ally of Player 6 (Orange)) Equal to True
        • Then - Actions
          • Unit - Create 1 Repairer for Player 6 (Orange) at Loc_Sie[CV] facing Default building facing degrees
          • Wait 0.10 game-time seconds
          • Unit Group - Pick every unit in (Units within 200.00 of Loc_Sie[CV] matching ((Unit-type of (Matching unit)) Equal to Repairer)) and do (Actions)
            • Loop - Actions
              • Unit - Order (Picked unit) to Right-Click SW[CV]
        • Else - Actions
          • Unit - Create 1 Repairer for Player 12 (Brown) at Loc_Sie[CV] facing Default building facing degrees
          • Unit Group - Pick every unit in (Units within 200.00 of Loc_Sie[CV] matching ((Unit-type of (Matching unit)) Equal to Repairer)) and do (Actions)
            • Loop - Actions
              • Unit - Order (Picked unit) to Right-Click SW[CV]
      • Custom script: call DestroyGroup(udg_UniG[udg_CV])
      • Custom script: call RemoveLocation(udg_Loc_Sie[udg_CV])
 
Last edited:
Level 17
Joined
Apr 27, 2008
Messages
2,455
try to identify better where it doesn't work, change the event map initialisation to game elapsed (0 s is enough).
Why ? because then text messages will be saved in chat box
Then put debug messages, like printing unit name to see what's working or not
 
Status
Not open for further replies.
Top