• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Please review this trigger

Status
Not open for further replies.
Level 7
Joined
Jun 23, 2009
Messages
297
I just finished this trigger, but, I have the impression it wouldn't work 100% correctly, or that it could be done in a much better and/or shorter way.
Basically, I have a map with two teams, humans and demons, at the beginning of the map, it detects whether there are two demons playing, or only one, then, it sets a variable depending on this.
EnemiesPlaying = 1 means that only player 11 is playing as a demon
EnemiesPlaying = 2 means that only player 12 is playing as a demon
EnemiesPlaying = 3 means that both players are playing as demons
Humans win when all demons are dead, and demons win when all humans are dead.
Now that you know that, please review my trigger, check if it could be done in a shorter or better way, thanks!

  • Events
  • Unit - A unit owned by Player 11 (Dark Green) Dies
  • Unit - A unit owned by Player 12 (Brown) Dies
  • Conditions
  • (Unit-type of (Triggering unit)) Equal to Balnazzar
  • Actions
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • EnemiesPlaying Equal to 3
    • Then - Actions
    • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (EnemiesPlaying Equal to 1) or (EnemiesPlaying Equal to 2)
        • Then - Actions
          • Game - Defeat Player 11 (Dark Green) with the message: Defeat!
          • Game - Defeat Player 12 (Brown) with the message: Defeat!
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • EnemiesPlaying Equal to 3
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Owner of (Triggering unit)) Equal to Player 11 (Dark Green)
                • Then - Actions
                  • Set EnemiesPlaying = 2
                • Else - Actions
                  • If ((Owner of (Triggering unit)) Equal to Player 12 (Brown)) then do (Set EnemigosJugando = 1) else do (Game - Display to (All players) the text: |cFFFF0000Error|r: ...)
            • Else - Actions
              • Game - Display to (All players) the text: cFFFF0000Error|r:
 
Yeah I just wanted it to be more specific, since EnemiesPlaying = 0 means no enemy is playing, and i test the map a lot without any enemies, I just wanted to be sure it wouldn't glitch

I see... ^_^

and oh, the last if-then will not run EVER (the one with the condition of enemy = 3) since it was on the else action of an if-then that is only run when enemy is not equal to 3...
 
Level 7
Joined
Jun 23, 2009
Messages
297
I see... ^_^

and oh, the last if-then will not run EVER (the one with the condition of enemy = 3) since it was on the else action of an if-then that is only run when enemy is not equal to 3...


If you mean the
  • If ((Owner of (Triggering unit)) Equal to Player 12 (Brown)) then do (Set EnemigosJugando = 1) else do (Game - Display to (All players) the text: |cFFFF0000Error|r: ...)
Yeah, I know, I just put it to fool around, in case something went wrong, users would be informed of the error :p
 
  • (A)
  • If - Conditions
    • EnemiesPlaying Equal to 3
  • Then - Actions
  • Else - Actions
    • (B)
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (EnemiesPlaying Equal to 1) or (EnemiesPlaying Equal to 2)
    • Then - Actions
      • Game - Defeat Player 11 (Dark Green) with the message: Defeat!
      • Game - Defeat Player 12 (Brown) with the message: Defeat!
    • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • THIS ONE!!!
        • If - Conditions
          • EnemiesPlaying Equal to 3
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Owner of (Triggering unit)) Equal to Player 11 (Dark Green)
            • Then - Actions
              • Set EnemiesPlaying = 2
              • Else - Actions
                • If ((Owner of (Triggering unit)) Equal to Player 12 (Brown)) then do (Set EnemigosJugando = 1) else do (Game - Display to (All players) the text: |cFFFF0000Error|r: ...)
          • Else - Actions
            • Game - Display to (All players) the text: cFFFF0000Error|r

look at the part that says THIS ONE!!!

it was on the else action of an -if-then-else(B) that was on the else action of another if-then-else with the condition EnemiesPlaying equal to 3 (A)... meaning if A was true, B won't even run, and if it would run, then EnemiesPlaying is not equal to 3 meaning THIS ONE!!! will always be false...
 
Status
Not open for further replies.
Top