• 🏆 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] Something Wrong With Loop

Status
Not open for further replies.

sentrywiz

S

sentrywiz

Hi peeps.

I have this loop that picks units from each of the active player's groups and teleports them into their own region. Have been testing it, but so far I can see that it only picks my group.... idk why. Other players (bots) have units in their groups as well, its not like their groups are empty.

Some help regarding vars (all are not null and determined on map init or when player trains a unit):

Player is a Player Array variable.
PlayerGroup is an UnitGroup Array variable.
PlayerDummyPicker is a Unit Array variable.
PlayerRegion is a Region Array variable.

Also this trigger is launched by another trigger when the round starts (timer runs out/players click ESC)

  • Move Player Legions
    • Events
    • Conditions
    • Actions
      • 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
              • (Player[(Integer A)] slot status) Equal to Is playing
              • (Number of units in PlayerGroup[(Integer A)]) Greater than 0
            • Then - Actions
              • Game - Display to (All players) the text: (picking + ((Name of Player[(Integer A)]) + 's legion))
              • Unit - Hide Player_DummyPicker[(Integer A)]
              • Unit Group - Pick every unit in PlayerGroup[(Integer A)] and do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Integer A) Less than or equal to 5
                    • Then - Actions
                      • Set tempLoc = (Center of Player_Region[(Integer A)])
                      • Camera - Pan camera for Player[(Integer A)] to tempLoc over 0.00 seconds
                      • Unit - Make (Picked unit) Vulnerable
                      • Unit - Move (Picked unit) instantly to tempLoc, facing 90.00 degrees
                      • Selection - Select PlayerGroup[(Integer A)] for Player[(Integer A)]
                      • Custom script: call RemoveLocation ( udg_tempLoc )
                    • Else - Actions
                      • Set tempLoc = (Center of Player_Region[(Integer A)])
                      • Camera - Pan camera for Player[(Integer A)] to tempLoc over 0.00 seconds
                      • Unit - Make (Picked unit) Vulnerable
                      • Unit - Move (Picked unit) instantly to tempLoc, facing 270.00 degrees
                      • Selection - Select PlayerGroup[(Integer A)] for Player[(Integer A)]
                      • Custom script: call RemoveLocation ( udg_tempLoc )
            • Else - Actions
Anyone see something I don't?
 
Level 25
Joined
Sep 26, 2009
Messages
2,378
You need to initialize unit groups. Either via custom script, by creating unit group via "Set variable" function or in the most simple way - set "Size" of the array in the variable editor to your desired amount. If it's for each player, then a size 12.
 

sentrywiz

S

sentrywiz

You need to initialize unit groups. Either via custom script, by creating unit group via "Set variable" function or in the most simple way - set "Size" of the array in the variable editor to your desired amount. If it's for each player, then a size 12.

I tried both. It doesn't work.

EDIT:

I am confused beyond words. I tried everything via game messages to check if playergroup is empty.
Nothing. Its like my group is the only one that exists. None of the other groups even get picked.
 
its not like their groups are empty
You can prove it? So other operations work fine with their unit groups?


- Use your own custom integer for loop.
- Certain actions can be moved out of the Then/Else blocks, as they are completly same.


Edit:

Its like my group is the only one that exists.
Then you probably should read more carefully what Nichilus posted.
 
Level 25
Joined
Sep 26, 2009
Messages
2,378
What about this condition: (Player[(Integer A)] slot status) Equal to Is playing? Ain't you the only one playing during tests? Or are there other players? I don't think computer counts as playing.


Edit: A side note - into If/Then/Else block you should put only actions which are different from one another. In your case it is the "Unit - Move (Picked unit) instantly to tempLoc, facing 270.00 degrees" action. That way it will be easier to read as you don't have to go through blocks of same actions. That doesn't mean it's incorrect the way you have it right now, though.
Also, you could resolve the facing angle without ITE block by using calculation "90.00 + ((Player number / 6) * 180.00). As player numbers are integers, the (Player number / 6) part will return number 0 for players 1-5 and number 1 for players 6-11.
 

sentrywiz

S

sentrywiz

What about this condition: (Player[(Integer A)] slot status) Equal to Is playing? Ain't you the only one playing during tests? Or are there other players? I don't think computer counts as playing.

@IcemanBo I have read it. Loop operations work. PlayerGroups and Players don't.

Computer counts as playing. If the slot isn't open/closed, its playing.

Something horribly strange happens. When I test the map through WE, it works!
Just as intended.

But when I start warcraft and put computers and start a game, it just magically breaks.

Here is the init trigger. It works and it doesn't and I have no idea why.


  • Player Array
    • Events
    • Conditions
    • Actions
      • Set Bool_MBCreated = False
      • Quest - Create a Required quest titled About the map with the description Legion of Creeps |c..., using icon path ReplaceableTextures\CommandButtons\BTNRallyPoint.blp
      • Quest - Create a Required quest titled Game Options with the description There are various g..., using icon path ReplaceableTextures\CommandButtons\BTNPhilosophersStone.blp
      • Quest - Create a Required quest titled Useful Information with the description |cffffcc00Gold|r is..., using icon path ReplaceableTextures\CommandButtons\BTNScroll.blp
      • Quest - Create a Optional quest titled Map Source with the description This map can be fou..., using icon path ReplaceableTextures\CommandButtons\BTNSnazzyScrollGreen.blp
      • Set Player[1] = Player 1 (Red)
      • Set Player[2] = Player 2 (Blue)
      • Set Player[3] = Player 3 (Teal)
      • Set Player[4] = Player 4 (Purple)
      • Set Player[5] = Player 5 (Yellow)
      • Set Player[6] = Player 6 (Orange)
      • Set Player[7] = Player 7 (Green)
      • Set Player[8] = Player 8 (Pink)
      • Set Player[9] = Player 9 (Gray)
      • Set Player[10] = Player 10 (Light Blue)
      • 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
              • (Player[(Integer A)] slot status) Equal to Is playing
            • Then - Actions
              • Set Int_PlayersOnline = (Int_PlayersOnline + 1)
              • Set PlayerGroup[(Integer A)] = (Units in (Playable map area))
              • Unit Group - Remove all units from PlayerGroup[(Integer A)]
              • Game - Display to (All players) the text: (Name of Player[(Integer A)])
            • Else - Actions


Maybe you want to test for yourself?
Here's the map, try it out. I'm pulling hairs from this insanity.

View attachment Legion of Creeps v1a.w3x
 

sentrywiz

S

sentrywiz

Bump.

I haven't tested, but would making 10 separate unit groups solve this... ?
I still don't get it why it doesn't work.

If anyone has any answers or some sort of guess, please let me know.
 

sentrywiz

S

sentrywiz

I don't want waste too much of time to reproduce test conditions. Could you upload a example map which is reduced to your problem?

Already solved. And I get ya, testing takes time and patience.

+rep to JaysProjex, IcemanBo, Nichilus

To all that might encounter this sort of thing -- don't re-use integer A/B loops exclusively.
Use your own integers for loops. This was the sole perpetrator for this problem.
Map works as intended now.
 
Last edited by a moderator:

sentrywiz

S

sentrywiz

IcemanBo already wrote that you should use your own integer for the loop :D

Yeah, but IcemanBo didn't tell me that THAT IS THE PROBLEM :p

There is a big difference between "you should use X because of reasons" and "your loop is buggy, use your own integer"
One is advice / suggestion. The other is a clear solution.
 
Status
Not open for further replies.
Top