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

[Solved] Action only happen once

Status
Not open for further replies.
Level 4
Joined
Sep 11, 2018
Messages
74
It works the first time but the second time the units just stay there. Any idea? Edit:Removing DestroyGroup works everytime but leaks.
  • Spawn
    • Events
      • Time - Every 30.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer tempintegers[1]) from 1 to 2, do (Actions)
        • Loop - Actions
          • Set temppoint[tempintegers[1]] = (Center of castlespawnreg[tempintegers[1]])
          • Set temppoint2[tempintegers[1]] = (Center of attackcastle[tempintegers[1]])
          • Unit - Create 4 templarforces[1] for players[tempintegers[1]] at temppoint[tempintegers[1]] facing Default building facing degrees
          • Unit - Create 2 templarforces[2] for players[tempintegers[1]] at temppoint[tempintegers[1]] facing Default building facing degrees
          • Unit - Create 1 templarforces[(Random integer number between 3 and 4)] for players[tempintegers[1]] at temppoint[tempintegers[1]] facing Default building facing degrees
          • For each (Integer tempintegers[2]) from 1 to 8, do (Actions)
            • Loop - Actions
              • Unit Group - Pick every unit in (Units owned by players[tempintegers[1]] of type templarforces[tempintegers[2]]) and do (Actions)
                • Loop - Actions
                  • Unit Group - Add (Picked unit) to tempgroup[tempintegers[1]]
          • Unit Group - Order tempgroup[tempintegers[1]] to Attack-Move To temppoint2[tempintegers[1]]
          • Custom script: call RemoveLocation(udg_temppoint[udg_tempintegers[1]])
          • Custom script: call RemoveLocation(udg_temppoint2[udg_tempintegers[1]])
          • Custom script: call DestroyGroup(udg_tempgroup[udg_tempintegers[1]])
 
Last edited:
Level 6
Joined
Aug 28, 2015
Messages
213
you are destroying the group in the end of the trigger and don't create a new one by the next start so you can't add to it.
Also you leaking a group where you pick every units owned by your dynamic player...
this should work:
  • Set Group
    • Events
    • Conditions
    • Actions
      • Set Temp_Point = (Center of (Playable map area))
      • Set Temp_Group[Temp_Integer] = (Units in TemplerZone)
      • Unit Group - Pick every unit in Temp_Group[Temp_Integer] and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • (Unit-type of (Picked unit)) Not equal to TemplarForces
                  • (Owner of (Picked unit)) Not equal to TheTemplars
            • Then - Actions
              • Unit Group - Remove (Picked unit) from Temp_Group[Temp_Integer]
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in Temp_Group[Temp_Integer]) Greater than 0
        • Then - Actions
          • Unit Group - Order Temp_Group[Temp_Integer] to Attack-Move To Temp_Point
        • Else - Actions
      • Custom script: call RemoveLocation(udg_Temp_Point)
      • Custom script: call DestroyGroup(udg_Temp_Group[udg_Temp_Integer])
 
Level 4
Joined
Sep 11, 2018
Messages
74
Why don't this work then? (I just want to know why mine fails. I'll try your method later)
  • Spawn
    • Events
      • Time - Every 30.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer tempintegers[1]) from 1 to 2, do (Actions)
        • Loop - Actions
          • Set temppoint[tempintegers[1]] = (Center of castlespawnreg[tempintegers[1]])
          • Set temppoint2[tempintegers[1]] = (Center of attackcastle[tempintegers[1]])
          • Unit - Create 3 templarforces[1] for players[tempintegers[1]] at temppoint[tempintegers[1]] facing Default building facing degrees
          • Unit - Create 2 templarforces[2] for players[tempintegers[1]] at temppoint[tempintegers[1]] facing Default building facing degrees
          • Unit - Create 1 templarforces[(Random integer number between 3 and 4)] for players[tempintegers[1]] at temppoint[tempintegers[1]] facing Default building facing degrees
          • For each (Integer tempintegers[2]) from 1 to 8, do (Actions)
            • Loop - Actions
              • Set tempgroup[tempintegers[1]] = (Units owned by players[tempintegers[1]] of type templarforces[tempintegers[2]])
          • Unit Group - Order tempgroup[tempintegers[1]] to Attack-Move To temppoint2[tempintegers[1]]
          • Custom script: call RemoveLocation(udg_temppoint[udg_tempintegers[1]])
          • Custom script: call RemoveLocation(udg_temppoint2[udg_tempintegers[1]])
          • Custom script: call DestroyGroup(udg_tempgroup[udg_tempintegers[1]])
This time nothing happens. The units just stay there.
 
Level 6
Joined
Aug 28, 2015
Messages
213
You resetting the group in the second loop again and then just order the last set group... Maybe this one is empty. Let you display for each loop how may units are contained in the group
Also maybe try a custom script after destroying the group, with:
Set udg_tempgroup[temint[1]] = null
 
Level 4
Joined
Sep 11, 2018
Messages
74
Solved it using this:
  • Spawn
    • Events
      • Time - Every 30.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer number[1]) from 1 to 2, do (Actions)
        • Loop - Actions
          • Custom script: set udg_tempgroup[udg_number[1]] = CreateGroup()
          • Set temppoint[number[1]] = (Center of castlespawnreg[number[1]])
          • Set temppoint2[number[1]] = (Center of attackcastle[number[1]])
          • Unit - Create 3 templarforces[1] for players[number[1]] at temppoint[number[1]] facing Default building facing degrees
          • Unit - Create 2 templarforces[2] for players[number[1]] at temppoint[number[1]] facing Default building facing degrees
          • Unit - Create 1 templarforces[(Random integer number between 3 and 4)] for players[number[1]] at temppoint[number[1]] facing Default building facing degrees
          • For each (Integer number[2]) from 1 to 8, do (Actions)
            • Loop - Actions
              • Unit Group - Pick every unit in (Units in playerregion[number[1]] owned by players[number[1]]) and do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Unit-type of (Picked unit)) Equal to templarforces[number[2]]
                    • Then - Actions
                      • Unit Group - Add (Picked unit) to tempgroup[number[1]]
                    • Else - Actions
          • Unit Group - Order tempgroup[number[1]] to Attack-Move To temppoint2[number[1]]
          • Custom script: call RemoveLocation(udg_temppoint[udg_number[1]])
          • Custom script: call RemoveLocation(udg_temppoint2[udg_number[1]])
          • Custom script: call DestroyGroup(udg_tempgroup[udg_number[1]])
Thanks anyway
 
Status
Not open for further replies.
Top