• 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.
  • Create a faction for Warcraft 3 and enter Hive's 19th Techtree Contest: Co-Op Commanders! Click here to enter!
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 21st Texturing Contest: Upgrade is now concluded, time to vote for your favourite set of icons! Click here to vote!

Trigger for Unit Group is not working

Status
Not open for further replies.
Level 30
Joined
Sep 26, 2009
Messages
2,622
Hello... I made this trigger

  • Player4 Group
    • Events
      • Unit - A unit Finishes training a unit
    • Conditions
      • (Owner of (Triggering unit)) Equal to Player 4 (Purple)
    • Actions
      • Unit Group - Add (Trained unit) to Player4_Group[Player4_Group_Number]
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in Player4_Group[Player4_Group_Number]) Equal to 6
        • Then - Actions
          • Wait 1.00 seconds
          • Unit Group - Pick every unit in Player4_Group[Player4_Group_Number] and do (Actions)
            • Loop - Actions
              • Unit - Order (Picked unit) to Attack-Move To (Random point in Goal <gen>)
              • Unit Group - Remove (Picked unit) from Player4_Group[Player4_Group_Number]
              • Set Player4_Group_Number = (Player4_Group_Number + 1)
        • Else - Actions
          • Do nothing

so each time a unit owned by player 4 is trained, it is add to unit group and once this unit group has 6 units in it, it is ordered to go to Goal<gen>.
This trigger works, but only once.
The "Player4_Group_Number" is integer variable with no array and initial value equal to 1.
At first, the trigger didn't have "Player4_Group_Number" variable, but later I add it, hoping that maybe once each unit group is different it would work... but it doesn't...

I also used
  • Custom script: call DestroyGroup (udg_Player4_Group)
when I didn't have array checked for the Unit group. I don't know how to use this custom script for unit group with array however, so I didn't use it in the later "version".

Does anyone know what to do so it works every time?
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
I think this should not be in the loop:

  • Set Player4_Group_Number = (Player4_Group_Number + 1)
Random point in region leaks and the Do Nothing can be removed.

This worked fine for me:

  • Untitled Trigger 068
    • Events
      • Unit - A unit Finishes training a unit
    • Conditions
      • (Owner of (Triggering unit)) Equal to Player 1 (Red)
    • Actions
      • Unit Group - Add (Trained unit) to Temp_Group_3
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in Temp_Group_3) Equal to 4
        • Then - Actions
          • Unit Group - Pick every unit in Temp_Group_3 and do (Actions)
            • Loop - Actions
              • Set Temp_Loc_1 = (Random point in Region 004 <gen>)
              • Unit - Order (Picked unit) to Attack-Move To Temp_Loc_1
              • Unit Group - Remove (Picked unit) from Temp_Group_3
              • Custom script: call RemoveLocation(udg_Temp_Loc_1)
        • Else - Actions
 
Status
Not open for further replies.
Top