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

[Solved] loop not looping... ?

Status
Not open for further replies.
Level 21
Joined
Mar 29, 2020
Messages
1,237
hi,

I have this trigger that is part of an ability that is supposed to send random units in the unit group to random places on the map. it works, but it's not working multiple times like it's supposed to, only once. I can't figure out why.
I'm talking about the loop starting - "for each integer A from 1 to TempInteger."
  • bon voyage option 2 Copy
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Bon Voyage
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of Bon Voyage for (Triggering unit)) Equal to 1
        • Then - Actions
          • Set TempInteger = 3
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Bon Voyage for (Triggering unit)) Equal to 2
            • Then - Actions
              • Set TempInteger = 6
            • Else - Actions
              • Set TempInteger = 10
      • Set TempPoint1 = (Position of (Triggering unit))
      • Set Temp_Group = (Units within 600.00 of TempPoint1 matching (((Matching unit) is A structure) Equal to False))
      • Game - Display to (All players) for 10.00 seconds the text: (number of units in group: + (String((Number of units in Temp_Group))))
      • For each (Integer A) from 1 to TempInteger, do (Actions)
        • Loop - Actions
          • Game - Display to (All players) for 10.00 seconds the text: loop run
          • Set TempUnit = (Random unit from Temp_Group)
          • Set Temp_Point2 = (Position of TempUnit)
          • Special Effect - Create a special effect at Temp_Point2 using Abilities\Spells\Demon\DarkPortal\DarkPortalTarget.mdl
          • Special Effect - Destroy (Last created special effect)
          • Set TempPoint = (Random point in (Playable map area))
          • For each (Integer A) from 1 to 10, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Terrain pathing at TempPoint of type Walkability is off) Equal to True
                • Then - Actions
                  • Custom script: call RemoveLocation (udg_TempPoint)
                  • Set TempPoint = (Random point in (Playable map area))
                • Else - Actions
          • Game - Display to (All players) for 10.00 seconds the text: mid loop
          • Unit - Move TempUnit instantly to TempPoint
          • Special Effect - Create a special effect attached to the overhead of TempUnit using Abilities\Spells\Demon\DarkPortal\DarkPortalTarget.mdl
          • Special Effect - Destroy (Last created special effect)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Terrain pathing at TempPoint of type Walkability is off) Equal to True
              • (TempUnit is A flying unit) Equal to False
            • Then - Actions
              • Unit - Explode TempUnit
            • Else - Actions
          • Unit Group - Remove TempUnit from Temp_Group
          • Custom script: call RemoveLocation (udg_TempPoint)
          • Custom script: call RemoveLocation (udg_Temp_Point2)
          • Game - Display to (All players) for 10.00 seconds the text: loop end
      • Custom script: call RemoveLocation (udg_TempPoint1)
      • Custom script: call DestroyGroup(udg_Temp_Group)
thanks!
 
Level 12
Joined
Feb 5, 2018
Messages
521
Maybe move these:
  • Unit - Move TempUnit instantly to TempPoint
  • empty.gif
    line.gif
    empty.gif
    join.gif
    ani.gif
    Special Effect - Create a special effect attached to the overhead of TempUnit using Abilities\Spells\Demon\DarkPortal\DarkPortalTarget.mdl
  • empty.gif
    line.gif
    empty.gif
    join.gif
    ani.gif
    Special Effect - Destroy (Last created special effect)

Inside this:
For each (Integer A) from 1 to 10, do (Actions)
 
Level 21
Joined
Mar 29, 2020
Messages
1,237
thanks! I actually just got it to work by changing it to "for every integer B" instead of A. not sure if there is a good reason a didn't work or just a bug.

what you suggested doesn't really make sense since the point of that inner loop is just to make it very unlikely for the temppoint to be on unpathable ground. so it doesn't really have to do with the special effects, but thanks.
 
Level 12
Joined
Feb 5, 2018
Messages
521
what you suggested doesn't really make sense since the point of that inner loop is just to make it very unlikely for the temppoint to be on unpathable ground. so it doesn't really have to do with the special effects, but thanks.

Ah my bad it was loop inside a loop, just made too quick look I guess. :)

Also you should create variable integer and use for each integer variable from 1 to tempinteger do actions.
 
Status
Not open for further replies.
Top