[Solved] Multiple select unit actions

Level 12
Joined
Jul 5, 2014
Messages
551
I have a persistently bugging experience with select unit. Long story short: I'm making a puzzle like the one with the sheeps from the Blood Elf campaign, except it requires selecting rather than standing on the platform. I run it with If/Then/Else with an integer variable that increases every time to correct selection is made. While it works by itself, the moment I added a failure (else) option, it immediately fails because it interprets the first selection as a second as well. This is what the trigger looks like:

  • Solving
    • Events
      • Player - Player 2 (Blue) Selects a unit
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Triggering unit) Equal to First 0126 <gen>) and (Puzzle Equal to 0)
        • Then - Actions
          • Wait 0.20 seconds
          • Set Puzzle = 1
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Triggering unit) Not equal to First 0126 <gen>
            • Then - Actions
              • Trigger - Turn off (This trigger)
              • Game - Display to (All players) the text: Oh nooooo!
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Triggering unit) Equal to Second 0124 <gen>) and (Puzzle Equal to 1)
        • Then - Actions
          • Wait 0.20 seconds
          • Set Puzzle = 2
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Triggering unit) Not equal to Second <gen>) and (Puzzle Equal to 1)
            • Then - Actions
              • Trigger - Turn off (This trigger)
              • Game - Display to (All players) the text: Oh nooooo!
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Triggering unit) Equal to Third 0127 <gen>) and (Puzzle Equal to 2)
        • Then - Actions
          • Trigger - Turn off (This trigger)
          • Wait 0.20 seconds
          • Trigger - Turn off Reset Puzzle <gen> (trigger when cancelled the puzzle)
          • Trigger - Turn off Puzzle <gen> (trigger to begin)
          • Game - Display to (All players) the text: Win!
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Triggering unit) Not equal to Third <gen>) and (Puzzle Equal to 2)
            • Then - Actions
              • Trigger - Turn off (This trigger)
              • Game - Display to (All players) the text: Oh nooooo!
            • Else - Actions
 
Level 24
Joined
Feb 27, 2019
Messages
833
The logic is not sound. Checking if (Triggering unit) Not equal to A unit will be true in 2/3 cases and the three ITE's always run. It can be fixed with a nested ITE which is a chain of continuous if then else statements of which when one is true the chain ends or it ends when it reaches the end which in this case means the wrong unit was selected.
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • Puzzle Equal to 0
      • ((Triggering unit) Equal to Unit0
    • Then - Actions
      • Set Puzzle = 1
      • Game - Display to (All players) the text: Success first
    • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Puzzle Equal to 1
          • ((Triggering unit) Equal to Unit1
        • Then - Actions
          • Set Puzzle = 2
          • Game - Display to (All players) the text: Success second
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Puzzle Equal to 2
              • ((Triggering unit) Equal to Unit2
            • Then - Actions
              • Set Puzzle = 3
              • Game - Display to (All players) the text: Success third
            • Else - Actions
              • Set Puzzle = 0
              • Game - Display to (All players) the text: Oh noo!!
 
Level 12
Joined
Jul 5, 2014
Messages
551
The logic is not sound. Checking if (Triggering unit) Not equal to A unit will be true in 2/3 cases and the three ITE's always run. It can be fixed with a nested ITE which is a chain of continuous if then else statements of which when one is true the chain ends or it ends when it reaches the end which in this case means the wrong unit was selected.
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • Puzzle Equal to 0
      • ((Triggering unit) Equal to Unit0
    • Then - Actions
      • Set Puzzle = 1
      • Game - Display to (All players) the text: Success first
    • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Puzzle Equal to 1
          • ((Triggering unit) Equal to Unit1
        • Then - Actions
          • Set Puzzle = 2
          • Game - Display to (All players) the text: Success second
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Puzzle Equal to 2
              • ((Triggering unit) Equal to Unit2
            • Then - Actions
              • Set Puzzle = 3
              • Game - Display to (All players) the text: Success third
            • Else - Actions
              • Set Puzzle = 0
              • Game - Display to (All players) the text: Oh noo!!
Yeah, it works with your trigger. The reason I'm confused because in the original it considered 1 selection as more, despite Puzzle started on 0. But when it turned to 1, it somehow felt it as a second selection, despite I put a delay before setting Puzzle from 0 to 1 to make sure it doesn't match the second condition when clicking.
 
Level 24
Joined
Feb 27, 2019
Messages
833
Yeah, it works with your trigger. The reason I'm confused because in the original it considered 1 selection as more, despite Puzzle started on 0. But when it turned to 1, it somehow felt it as a second selection, despite I put a delay before setting Puzzle from 0 to 1 to make sure it doesn't match the second condition when clicking.
Per heaps this is what was confusing, adding a wait in an ITE is just like any action, it occurs in order. The next ITE is not started until the first ITE is completed. That would mean the next ITE's condition: ((Triggering unit) Not equal to Second <gen>) and (Puzzle Equal to 1) is True.
 
Level 12
Joined
Jul 5, 2014
Messages
551
Per heaps this is what was confusing, adding a wait in an ITE is just like any action, it occurs in order. The next ITE is not started until the first ITE is completed. That would mean the next ITE's condition: ((Triggering unit) Not equal to Second <gen>) and (Puzzle Equal to 1) is True.
Oh. So it wasn't a simultaneous reaction after the click but ITE 1 and ITE 2, etc. Yeah, that explains it. Thanks for clarifying, it's kinda embarrassing now.
 
Top