problem with a trigger to create unit

Status
Not open for further replies.
Level 4
Joined
Dec 10, 2015
Messages
85
So, I created a trigger that is supposed to create a unit at the position of every single specific type of building. In short, a Warrior must be created at the position of each Warrior Camp. But I tested it in map, and nothing happened at all.
Here is the trigger
  • Warrior spawning
    • Events
      • Time - Every 30.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units of type Warrior Camp) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Owner of (Triggering unit)) Equal to Player 1 (Red)
              • (Owner of (Triggering unit)) Equal to Player 2 (Blue)
              • (Owner of (Triggering unit)) Equal to Player 3 (Teal)
              • (Owner of (Triggering unit)) Equal to Player 4 (Purple)
              • (Owner of (Triggering unit)) Equal to Player 5 (Yellow)
            • Then - Actions
              • Unit - Create 1 Warrior for Player 11 (Dark Green) at (Position of (Triggering unit)) facing 0.00 degrees
            • Else - Actions
              • Unit - Create 1 Warrior for Player 12 (Brown) at (Position of (Triggering unit)) facing 180.00 degrees
If anyone knows what is the problem in there, please let me know
 
well, can you tell me the difference between Trigerring unit, Picked unit and Matching unit so I won't make that mistake again?
Thanks
 
Alright, thanks
BTW, I tryed to change every Triggering unit to Picked Unit, and well, it's weird.
Unit are spawned correctly, at the right place, but for the wrong player.
They are all spawned for the Else Action (Player 12 in that case), even those who matches the condition
 
Alright, thanks
BTW, I tryed to change every Triggering unit to Picked Unit, and well, it's weird.
Unit are spawned correctly, at the right place, but for the wrong player.
They are all spawned for the Else Action (Player 12 in that case), even those who matches the condition

That's because of this part:
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Owner of (Picked unit)) Equal to Player 1 (Red)
      • (Owner of (Picked unit)) Equal to Player 2 (Blue)
      • (Owner of (Picked unit)) Equal to Player 3 (Teal)
      • (Owner of (Picked unit)) Equal to Player 4 (Purple)
      • (Owner of (Picked unit)) Equal to Player 5 (Yellow)
    • Then - Actions
    • Else - Actions
By default, the "If - Conditions" block is an "AND" block, meaning ALL conditions inside the block have to be true.
In your case, the unit has to belong to Player 1 AND player 2 AND ... AND player 5. That is simply not possible, so the condition fails and so the code in the ELSE block is executed.

To fix this, place in the conditions block the "OR - Conditions", which creates an OR block. This will fix your problem, because you want to fire the THEN block when at least one of the conditions is true.

E.g.
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • Or - Conditions
        • (Owner of (Picked unit)) Equal to Player 1 (Red)
        • (Owner of (Picked unit)) Equal to Player 2 (Blue)
        • (Owner of (Picked unit)) Equal to Player 3 (Teal)
        • (Owner of (Picked unit)) Equal to Player 4 (Purple)
        • (Owner of (Picked unit)) Equal to Player 5 (Yellow)
    • Then - Actions
    • Else - Actions
 
Status
Not open for further replies.
Back
Top