• 🏆 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] Can't find bug in this

Status
Not open for further replies.
Level 4
Joined
Sep 23, 2010
Messages
88
I'm trying to make arena where both team are teleported to the arena and are moved to watch regions, then trigger moves random unit from unit group (team1 / team2 heros) to region and then another trigger starts with unit enter region and then it moves hero to arena removing invulnerability (made for watchers) and unpauses them (for watchers too). But for some reason team1 works perfectly, but team2 doesn't get to the point where random hero is moved to the region for preparation, I tried EVERYTHING I could come up with and couldn't fix it. The triggers for both teams are the same.
Here they are:
  • Timer Expires
    • Events
      • Time - ArenaTimer expires
    • Conditions
    • Actions
      • Game - Display to (All players) the text: You have 30 seconds...
      • Wait 30.00 seconds
      • Game - Display to (All players) the text: Arena is starting!
      • Wait 2.00 seconds
      • Set ArenaTime = True
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Visibility - Enable Modifier[((Integer A) + 100)]
      • Unit Group - Remove all units from HeroGroups[1]
      • Unit Group - Remove all units from HeroGroups[2]
      • For each (Integer A) from 1 to 10, do (Actions)
        • Loop - Actions
          • Hero - Instantly revive Hero[(Integer A)] at (Center of Team1 Spawn <gen>), Hide revival graphics
          • Unit - Add Invulnerable (Neutral) to Hero[(Integer A)]
          • Unit - Set life of Hero[(Integer A)] to 100.00%
          • Unit - Set mana of Hero[(Integer A)] to 100.00%
          • Camera - Pan camera for Player[(Integer A)] to (Center of Arena Visibility <gen>) over 0.50 seconds
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • And - All (Conditions) are true
                • Conditions
                  • (Hero[(Integer A)] is alive) Equal to True
                  • Or - Any (Conditions) are true
                    • Conditions
                      • (Owner of Hero[(Integer A)]) Equal to Player 1 (Red)
                      • (Owner of Hero[(Integer A)]) Equal to Player 2 (Blue)
                      • (Owner of Hero[(Integer A)]) Equal to Player 3 (Teal)
                      • (Owner of Hero[(Integer A)]) Equal to Player 4 (Purple)
                      • (Owner of Hero[(Integer A)]) Equal to Player 5 (Yellow)
            • Then - Actions
              • Unit - Move Hero[(Integer A)] instantly to ArenaWatchPoint[(Integer A)], facing 180.00 degrees
              • Unit Group - Add Hero[(Integer A)] to HeroGroups[1]
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • And - All (Conditions) are true
                • Conditions
                  • (Hero[(Integer A)] is alive) Equal to True
                  • Or - Any (Conditions) are true
                    • Conditions
                      • (Owner of Hero[(Integer A)]) Equal to Player 6 (Orange)
                      • (Owner of Hero[(Integer A)]) Equal to Player 7 (Green)
                      • (Owner of Hero[(Integer A)]) Equal to Player 8 (Pink)
                      • (Owner of Hero[(Integer A)]) Equal to Player 9 (Gray)
                      • (Owner of Hero[(Integer A)]) Equal to Player 10 (Light Blue)
            • Then - Actions
              • Unit - Move Hero[(Integer A)] instantly to ArenaWatchPoint[(Integer A)], facing 180.00 degrees
              • Unit Group - Add Hero[(Integer A)] to HeroGroups[2]
            • Else - Actions
      • Unit - Pause all units
      • Unit - Move (Random unit from HeroGroups[1]) instantly to (Center of ArenaHeroDetect <gen>), facing 0.00 degrees
      • Unit - Move (Random unit from HeroGroups[2]) instantly to (Center of ArenaHeroDetect <gen>), facing 180.00 degrees
If more information needed, just ask.
 
Level 17
Joined
Feb 11, 2011
Messages
1,860
1. Why is it "Enable Modifier[((Integer A) + 100)]" and not "Enable Modifier[(Integer A)]"?
2. You have lots of location leaks.
3. I would suggest splitting the Loops into 2 parts:

Team 1:
  • For each (Integer A) from 1 to 5, do (Actions)
Team 2:
  • For each (Integer A) from 6 to 10, do (Actions)
 
Level 4
Joined
Sep 23, 2010
Messages
88
3. Yeah I had it like that and nothing happened... and for 1. +100 is that I was too lazy to make a new variable...
 
Level 26
Joined
Mar 19, 2008
Messages
3,140
Additionaly:
1. Try replacing Integer A (which sucks.. nono it actually SUUCKSSS) with custom integer variable ;)
2. Like mentioned - remove location leaks.
3. Use player group variables and add given players at map initialization to those forces - it makes your life easier.
4. Remove tha And - All -> funciton if/then/else checks if all conditions are true by default.
5. 4 + 3 = just two condition lines instead of 10.
6. Use non array variables for HeroGroup - if you aren't using more than or equal to 3 arrays it's waste of memory.

Improvement of Loop function (just the For each (...) part):

  • For each (Integer i) from 1 to 10, do (Actions)
    • Loop - Actions
      • Set p = (Center of Team1 Spawn <gen>)
      • Hero - Instantly revive Hero[i] at p, Hide revival graphics
      • Unit - Add Invulnerable (Neutral) to Hero[i]
      • Unit - Set life of Hero[i] to 100.00%
      • Unit - Set mana of Hero[i] to 100.00%
      • Custom script: call RemoveLocation(udg_p)
      • Set p = (Center of Arena Visibility <gen>)
      • Camera - Pan camera for Player[i] to p over 0.50 seconds
      • Custom script: call RemoveLocation(udg_p)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Hero[(Integer A)] is alive) Equal to True
          • ((Owner of Hero[i]) is in Team1) Equal to True
        • Then - Actions
          • Unit - Move Hero[i] instantly to ArenaWatchPoint[i], facing 180.00 degrees
          • Unit Group - Add Hero[i] to HeroGroups1
        • Else - Actions
          • Unit - Move Hero[i] instantly to ArenaWatchPoint[i], facing 180.00 degrees
          • Unit Group - Add Hero[i] to HeroGroups2
 
Level 17
Joined
Feb 11, 2011
Messages
1,860
Here are my triggers:
  • Fight
    • Events
      • Player - Player 1 (Red) types a chat message containing -go as An exact match
    • Conditions
    • Actions
      • Unit Group - Remove all units from Team_1
      • Unit Group - Remove all units from Team_2
      • 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
              • (Hero[(Integer A)] is alive) Equal to True
              • (Owner of Hero[(Integer A)]) Equal to (Player((Integer A)))
            • Then - Actions
              • Set Temp_Point = (Center of WatchPoint[(Integer A)])
              • Unit - Move Hero[(Integer A)] instantly to Temp_Point, facing Default building facing degrees
              • Camera - Pan camera for (Owner of Hero[(Integer A)]) to Temp_Point over 0.50 seconds
              • Custom script: call RemoveLocation(udg_Temp_Point)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Owner of Hero[(Integer A)]) is an ally of Player 1 (Red)) Equal to True
                • Then - Actions
                  • Unit Group - Add Hero[(Integer A)] to Team_1
                • Else - Actions
                  • Unit Group - Add Hero[(Integer A)] to Team_2
            • Else - Actions
      • Unit - Pause all units
      • Wait 1.00 seconds
      • Set Temp_Point = (Random point in Arena <gen>)
      • Unit - Move (Random unit from Team_1) instantly to Temp_Point
      • Custom script: call RemoveLocation(udg_Temp_Point)
      • Set Temp_Point = (Random point in Arena <gen>)
      • Unit - Move (Random unit from Team_2) instantly to Temp_Point
      • Custom script: call RemoveLocation(udg_Temp_Point)
Note that I trigger this with "-go" for testing purposes. You can add other things in like giving them full HP and MP before the battle.

EDIT: Used Spinnaker's suggestions.
EDIT 2: Remove stupid mistake.
 
Level 4
Joined
Sep 23, 2010
Messages
88
Thank you for posting,
1. I have nothing to say against it, butI don't see the problem in integer A.
2. What do you mean, locationg leaks? :p
3. Ok.
4. Ok.
5. What? :D
6. I'll try.
 
Level 4
Joined
Sep 23, 2010
Messages
88
But can you explain from my code, why doesn't random hero from unit group herogroups2 doesn't move instantly to ArenaDetect region?
 
Level 26
Joined
Mar 19, 2008
Messages
3,140
But can you explain from my code, why doesn't random hero from unit group herogroups2 doesn't move instantly to ArenaDetect region?

There are three posibilities:
- The murderer was Integer A
- Since Integer A is a terrorist, I bet he stole some of trigger's life-energy
- If none of above, the only reason left is: Integer A

There are also less possible issues, like you haven't declared the point ArenaWatchPoint or forces further than Player 5 don't exist.


>>>>>>>>>>>
EDIT: Btw, whats wrong with my solution KviZ? It's far more efficient than the second one.
 
Level 4
Joined
Sep 23, 2010
Messages
88
I don't know what's wrong with yours, I want both of your codes actualy, to see which works the best, sorry if I ask too much :/
 
Level 4
Joined
Sep 23, 2010
Messages
88
I found the bug. I made another unit group and asigned it to team2 and it worked! Finaly :D of 2 days of trying to fix it XD
 
Status
Not open for further replies.
Top