• 🏆 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] Strange bug with loop trigger

Status
Not open for further replies.
Level 8
Joined
Sep 24, 2007
Messages
300
This is the trigger that creates all needed units and stores them into a group variable.

  • create units
    • Events
      • Player - Player 1 (Red) types a chat message containing start as An exact match
      • Time - CountdownToBattle expires
    • Conditions
    • Actions
      • Countdown Timer - Destroy CdTimerWindow
        • Do Multiple ActionsFor each (Integer A) from 1 to 36, do (Actions)
          • Loop - Actions
            • -------- GONDOR MEELE CORPS 1 --------
            • Set Temploc = (Center of meele spawn gondor 1 <gen>)
            • Unit - Create 1 Footman for Player 6 (Orange) at Temploc facing 180.00 degrees
            • Unit Group - Add (Last created unit) to UnitGroup[1]
            • Animation - Change (Last created unit)'s vertex coloring to (100.00%, 10.00%, 10.00%) with 60.00% transparency
            • Animation - Change Command Center 0026 <gen>'s vertex coloring to (100.00%, 10.00%, 10.00%) with 0.00% transparency
            • Custom script: call RemoveLocation(udg_Temploc)
            • -------- GONDOR MEELE CORPS 2 --------
            • Set Temploc = (Center of meele spawn gondor 2 <gen>)
            • Unit - Create 1 Footman for Player 6 (Orange) at Temploc facing 180.00 degrees
            • Unit Group - Add (Last created unit) to UnitGroup[2]
            • Animation - Change (Last created unit)'s vertex coloring to (10.00%, 100.00%, 10.00%) with 0.00% transparency
            • Animation - Change Command Center 0028 <gen>'s vertex coloring to (10.00%, 100.00%, 10.00%) with 60.00% transparency
            • Custom script: call RemoveLocation(udg_Temploc)
            • -------- GONDOR MEELE CORPS 3 --------
            • Set Temploc = (Center of meele spawn gondor 3 <gen>)
            • Unit - Create 1 Rohan knight for Player 6 (Orange) at Temploc facing 180.00 degrees
            • Unit Group - Add (Last created unit) to UnitGroup[3]
            • Custom script: call RemoveLocation(udg_Temploc)
            • -------- GONDOR RANGED 1 --------
            • Set Temploc = (Center of ranged spawn gondor 2 <gen>)
            • Unit - Create 1 Archer for Player 6 (Orange) at Temploc facing 180.00 degrees
            • Unit Group - Add (Last created unit) to UnitGroup[4]
            • Animation - Change (Last created unit)'s vertex coloring to (100.00%, 10.00%, 10.00%) with 0.00% transparency
            • Custom script: call RemoveLocation(udg_Temploc)
            • -------- GONDOR RANGED 2 --------
            • Set Temploc = (Center of ranged spawn gondor 1 <gen>)
            • Unit - Create 1 Archer for Player 6 (Orange) at Temploc facing 180.00 degrees
            • Unit Group - Add (Last created unit) to UnitGroup[5]
            • Animation - Change (Last created unit)'s vertex coloring to (10.00%, 100.00%, 10.00%) with 0.00% transparency
            • Custom script: call RemoveLocation(udg_Temploc)
            • -------- GONDOR AIR --------
            • Set Temploc = (Center of air spawn gondor <gen>)
            • Unit - Create 1 Gryphon Rider for Player 6 (Orange) at Temploc facing 180.00 degrees
            • Unit Group - Add (Last created unit) to UnitGroup[6]
            • Custom script: call RemoveLocation(udg_Temploc)
            • -------- MORDOR MEELE 1 --------
            • Set Temploc = (Center of meele spawn mordor 1 <gen>)
            • Unit - Create 1 Grunt for Player 12 (Brown) at Temploc facing 180.00 degrees
            • Unit Group - Add (Last created unit) to UnitGroup[9]
            • Animation - Change (Last created unit)'s vertex coloring to (100.00%, 10.00%, 10.00%) with 0.00% transparency
            • Custom script: call RemoveLocation(udg_Temploc)
            • -------- MORDOR MEELE 2 --------
            • Set Temploc = (Center of meele spawn mordor 2 <gen>)
            • Unit - Create 1 Grunt for Player 12 (Brown) at Temploc facing 180.00 degrees
            • Unit Group - Add (Last created unit) to UnitGroup[10]
            • Animation - Change (Last created unit)'s vertex coloring to (10.00%, 100.00%, 10.00%) with 0.00% transparency
            • Custom script: call RemoveLocation(udg_Temploc)
            • -------- MORDOR MEELE 3 --------
            • Set Temploc = (Center of meele spawn mordor 3 <gen>)
            • Unit - Create 1 Raider for Player 12 (Brown) at Temploc facing 180.00 degrees
            • Unit Group - Add (Last created unit) to UnitGroup[11]
            • Custom script: call RemoveLocation(udg_Temploc)
            • -------- MORDOR RANGED 1 --------
            • Set Temploc = (Center of ranged spawn mordor 1 <gen>)
            • Unit - Create 1 Headhunter for Player 12 (Brown) at Temploc facing 180.00 degrees
            • Unit Group - Add (Last created unit) to UnitGroup[12]
            • Animation - Change (Last created unit)'s vertex coloring to (100.00%, 10.00%, 10.00%) with 0.00% transparency
            • Custom script: call RemoveLocation(udg_Temploc)
            • -------- MORDOR RANGED 2 --------
            • Set Temploc = (Center of ranged spawn mordor 2 <gen>)
            • Unit - Create 1 Headhunter for Player 12 (Brown) at Temploc facing 180.00 degrees
            • Unit Group - Add (Last created unit) to UnitGroup[13]
            • Animation - Change (Last created unit)'s vertex coloring to (10.00%, 100.00%, 10.00%) with 0.00% transparency
            • Custom script: call RemoveLocation(udg_Temploc)
            • -------- MORDOR AIR --------
            • Set Temploc = (Center of air spawn mordor <gen>)
            • Unit - Create 1 Headhunter for Player 12 (Brown) at Temploc facing 180.00 degrees
            • Unit Group - Add (Last created unit) to UnitGroup[14]
            • Custom script: call RemoveLocation(udg_Temploc)
        • Do Multiple ActionsFor each (Integer A) from 1 to 8, do (Actions)
          • Loop - Actions
            • -------- GONDOR ARTILERY 1 --------
            • Set Temploc = (Center of artilery spawn gondor 1 <gen>)
            • Unit - Create 1 Catapult for Player 6 (Orange) at Temploc facing 180.00 degrees
            • Unit Group - Add (Last created unit) to UnitGroup[7]
            • Animation - Change (Last created unit)'s vertex coloring to (10.00%, 100.00%, 10.00%) with 0.00% transparency
            • Custom script: call RemoveLocation(udg_Temploc)
            • -------- GONDOR ARTILERY 2 --------
            • Set Temploc = (Center of artilery spawn gondor 2 <gen>)
            • Unit - Create 1 Big distance artilery for Player 6 (Orange) at Temploc facing 180.00 degrees
            • Unit Group - Add (Last created unit) to UnitGroup[8]
            • Animation - Change (Last created unit)'s vertex coloring to (100.00%, 10.00%, 10.00%) with 0.00% transparency
            • Custom script: call RemoveLocation(udg_Temploc)
            • -------- MORDOR ARTILERY 1 --------
            • Set Temploc = (Center of artilery spawn mordor 1 <gen>)
            • Unit - Create 1 Catapult for Player 12 (Brown) at Temploc facing 180.00 degrees
            • Unit Group - Add (Last created unit) to UnitGroup[15]
            • Animation - Change (Last created unit)'s vertex coloring to (100.00%, 10.00%, 10.00%) with 0.00% transparency
            • Custom script: call RemoveLocation(udg_Temploc)
            • -------- MORDOR ARTILERY 2 --------
            • Set Temploc = (Center of artilery spawn mordor 2 <gen>)
            • Unit - Create 1 Catapult for Player 12 (Brown) at Temploc facing 180.00 degrees
            • Unit Group - Add (Last created unit) to UnitGroup[16]
            • Animation - Change (Last created unit)'s vertex coloring to (10.00%, 100.00%, 10.00%) with 0.00% transparency
            • Custom script: call RemoveLocation(udg_Temploc)
And this one moves the groups when certain command spells are casted (note: custom value of casting unit is the same as group's number)

  • army movements
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
    • Actions
      • -------- ARMY MOVEMENTS --------
        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Ability being cast) Equal to (==) Move-Attack to location 1
          • Then - Actions
            • Unit Group - Order UnitGroup[(Custom value of (Triggering unit))] to Attack-Move To CommandLoc[(((Player number of (Owner of (Triggering unit))) x 5) + 1)]
          • Else - Actions
            • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (Ability being cast) Equal to (==) Move-Attack to location 2
              • Then - Actions
                • Unit Group - Order UnitGroup[(Custom value of (Triggering unit))] to Attack-Move To CommandLoc[(((Player number of (Owner of (Triggering unit))) x 5) + 2)]
              • Else - Actions
                • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • (Ability being cast) Equal to (==) Move-Attack to location 3
                  • Then - Actions
                    • Unit Group - Order UnitGroup[(Custom value of (Triggering unit))] to Attack-Move To CommandLoc[(((Player number of (Owner of (Triggering unit))) x 5) + 3)]
                  • Else - Actions
                    • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                      • If - Conditions
                        • (Ability being cast) Equal to (==) Move-Attack to location 4
                      • Then - Actions
                        • Unit Group - Order UnitGroup[(Custom value of (Triggering unit))] to Attack-Move To CommandLoc[(((Player number of (Owner of (Triggering unit))) x 5) + 4)]
                      • Else - Actions
                        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                          • If - Conditions
                            • (Ability being cast) Equal to (==) Move-Attack to location 5
                          • Then - Actions
                            • Unit Group - Order UnitGroup[(Custom value of (Triggering unit))] to Attack-Move To CommandLoc[(((Player number of (Owner of (Triggering unit))) x 5) + 5)]
                          • Else - Actions
                            • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                              • If - Conditions
                                • (Ability being cast) Equal to (==) Retreat!
                              • Then - Actions
                                • Set Temploc = (Position of (Triggering unit))
                                • Unit Group - Order UnitGroup[(Custom value of (Triggering unit))] to Move To Temploc
                                • Custom script: call RemoveLocation(udg_Temploc)
                              • Else - Actions

Problem that appears in-game: Only first 11 units obey the orders, like the others were not stored in the group. Now why is that? It's always 11.
 
Level 8
Joined
Apr 30, 2009
Messages
338
Instead of ordering the unit group, try "pick all units in unit group" and order picked unit.

  • Untitled Trigger 001
    • Events
    • Conditions
    • Actions
      • Unit Group - Pick every unit in temp_group and do (Actions)
        • Loop - Actions
          • Unit - Order (Picked unit) to Attack-Move To temp_point0
When you order a group, the limit of units is 12, but when you do this loop it is unlimited.
 
Level 8
Joined
Apr 30, 2009
Messages
338
It even says it when you do the unit group action that the most it will order is 12.
 
Status
Not open for further replies.
Top