[Trigger] Help with Victory Conditions

Level 13
Joined
Sep 25, 2013
Messages
793
Hi, for my 6 player map I want players to be able to choose their team number in the lobby and then in game the last team with any remaining (undefeated) players wins.
So for example, if there a 3 teams of 2 players each, then when team 1 and team 2 players are all defeated, team 3 wins and victory cinematic plays (I already have the cinematic created).

It sounds simple but I am stumped. I will pay for help. Thank you
Alternatively I can help you with terraining your map, I'm okay at that

My map:
LOTR Mount Doom Battle 1.51
 
Here's one way of doing it, maybe overcomplicated but I wasn't feeling very clever.

1) Track the players that can "lose the game" at the very beginning:
  • Game Over Track Users
    • Events
      • Time - Elapsed game time is 0.01 seconds
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked player) controller) Equal to User
            • Then - Actions
              • Player Group - Add (Picked player) to Team_All_Users
            • Else - Actions
2) Then whenever a player "loses the game" run this trigger to check if there's a winning team:
  • Game Over Check
    • Events
    • Conditions
      • Game_Is_Over Equal to False
    • Actions
      • -------- Reset any old calculations: --------
      • Player Group - Remove all players from Team_Winners.
      • Player Group - Remove all players from Team_Losers.
      • -------- --------
      • -------- Consider all players as winners: --------
      • Player Group - Pick every player in Team_All_Users and do (Actions)
        • Loop - Actions
          • Set VariableSet Team_Player = (Picked player)
          • Player Group - Add Team_Player to Team_Winners
      • -------- --------
      • -------- Then remove any defeated players: --------
      • Player Group - Pick every player in Team_Winners and do (Actions)
        • Loop - Actions
          • Set VariableSet Team_Player = (Picked player)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Player_Is_Defeated[(Player number of Team_Player)] Equal to True
            • Then - Actions
              • Player Group - Remove Team_Player from Team_Winners.
              • Player Group - Add Team_Player to Team_Losers
            • Else - Actions
      • -------- --------
      • -------- Then check if any opposing teams still remain: --------
      • Set VariableSet Team_Has_Opposition = False
      • Set VariableSet Team_Player_Last = Neutral Passive
      • Player Group - Pick every player in Team_Winners and do (Actions)
        • Loop - Actions
          • Set VariableSet Team_Player = (Picked player)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Team_Player is an enemy of Team_Player_Last.) Equal to True
            • Then - Actions
              • Set VariableSet Team_Has_Opposition = True
            • Else - Actions
          • Set VariableSet Team_Player_Last = Team_Player
      • -------- --------
      • -------- If there's no opposition within this group then the game is over (one team remains): --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Team_Has_Opposition Equal to False
        • Then - Actions
          • -------- The only player(s) remaining in Team_Winners are part of the winning team, let's gather them and their allies for victory: --------
          • Set VariableSet Team_Player_Last = (Random player from Team_Winners)
          • Player Group - Pick every player in Team_All_Users and do (Actions)
            • Loop - Actions
              • Set VariableSet Team_Player = (Picked player)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Team_Player is an ally of Team_Player_Last.) Equal to True
                • Then - Actions
                  • Player Group - Add Team_Player to Team_Winners
                  • Player Group - Remove Team_Player from Team_Losers.
                • Else - Actions
          • -------- --------
          • Trigger - Run Game Over Finish <gen> (checking conditions)
        • Else - Actions
3) This last trigger runs when the game is officially over, it's Actions can be combined with your Victory Cinematic trigger:
  • Game Over Finish
    • Events
    • Conditions
      • Game_Is_Over Equal to False
    • Actions
      • -------- The game is officially over, the winners and losers have been separated into two groups: --------
      • Set VariableSet Game_Is_Over = True
      • Player Group - Pick every player in Team_Winners and do (Actions)
        • Loop - Actions
          • Game - Victory (Picked player) (Show dialogs, Show scores)
      • Player Group - Pick every player in Team_Losers and do (Actions)
        • Loop - Actions
          • Game - Defeat (Picked player) with the message: Defeat!

Here's an example of using the system, let's say you lose the game when your town hall dies:
  • Example of losing the game
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is A town-hall-type unit) Equal to True
      • Player_Is_Defeated[(Player number of (Owner of (Triggering unit)))] Equal to False
    • Actions
      • -------- Something happened that caused this player to "lose the game". --------
      • Set VariableSet Player_Is_Defeated[(Player number of (Owner of (Triggering unit)))] = True
      • Trigger - Run Game Over Check <gen> (checking conditions)
So you mark the Player as defeated and Run the "Game Over Check" trigger. This checks to see if one team remains. If so, the game will come to an end.

Variables used:
1757837530341.png


Important notes:

1) You'll want to think about what happens when a Player leaves the game. You'll likely want to Set Player_Is_Defeated to True for them and run Game Over Check immediately afterwards. But it's also your call, maybe Players have to destroy the leaver's base before you consider them defeated.

2) In Game Over Track Users you'll want to customize the Team_All_Users player group. Currently it's only tracking Users, so if your map supports Computer players then they should be added to it as well! It should contain anyone that can become defeated.

If you fail to consider these notes then your map may never come to an end. This is because some Players may remain marked as undefeated despite having lost the game.
 

Attachments

Last edited:
This may be a simpler approach, haven't tested so I don't know if it works.
  • Alive Players
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked player) slot status) Equal to Is playing
            • Then - Actions
              • Player Group - Add (Picked player) to AlivePlayers
            • Else - Actions
The following trigger defeats a player when their last unit/building dies. You can modify the conditions if that's not what you want.
  • Player Dies
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Units owned by (Owner of (Dying unit)) matching (((Matching unit) is alive) Equal to True).) is empty) Equal to True
    • Actions
      • Player Group - Remove (Owner of (Dying unit)) from AlivePlayers.
      • Game - Defeat (Owner of (Dying unit)) with the message: Defeat!
      • Trigger - Run Victory Defeat Check <gen> (checking conditions)
In the following trigger you'll of course want to add every player to the events.
  • Player Leaves
    • Events
      • Player - Player 1 (Red) leaves the game
    • Conditions
    • Actions
      • Player Group - Remove (Triggering player) from AlivePlayers.
      • Game - Defeat (Triggering player) with the message: Defeat!
      • Trigger - Run Victory Defeat Check <gen> (checking conditions)
  • Victory Defeat Check
    • Events
    • Conditions
    • Actions
      • Set VariableSet PlayerCheck = (Random player from AlivePlayers)
      • Player Group - Pick every player in AlivePlayers and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Team number of PlayerCheck) Not equal to (Team number of (Picked player))
            • Then - Actions
              • Skip remaining actions
            • Else - Actions
      • Player Group - Pick every player in AlivePlayers and do (Actions)
        • Loop - Actions
          • Game - Victory (Picked player) (Show dialogs, Show scores)
      • Trigger - Run Victory Cinematic <gen> (checking conditions)
Variables:
  • PlayerCheck (Player)
  • AlivePlayers (Player Group)
Edit: this doesn't account for players leaving the game before being defeated.
Edit 2: now it does.
Edit 3: I don't know if using the Victory action on a player ends the game for that player, actually. If it does, you'll want to move that to the end of the victory cinematic.
 
Last edited:
Here's one way of doing it, maybe overcomplicated but I wasn't feeling very clever.

1) Track the players that can "lose the game" at the very beginning:
  • Game Over Track Users
    • Events
      • Time - Elapsed game time is 0.01 seconds
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked player) controller) Equal to User
            • Then - Actions
              • Player Group - Add (Picked player) to Team_All_Users
            • Else - Actions
2) Then whenever a player "loses the game" run this trigger to check if there's a winning team:
  • Game Over Check
    • Events
    • Conditions
      • Game_Is_Over Equal to False
    • Actions
      • -------- Reset any old calculations: --------
      • Player Group - Remove all players from Team_Winners.
      • Player Group - Remove all players from Team_Losers.
      • -------- --------
      • -------- Consider all players as winners: --------
      • Player Group - Pick every player in Team_All_Users and do (Actions)
        • Loop - Actions
          • Set VariableSet Team_Player = (Picked player)
          • Player Group - Add Team_Player to Team_Winners
      • -------- --------
      • -------- Then remove any defeated players: --------
      • Player Group - Pick every player in Team_Winners and do (Actions)
        • Loop - Actions
          • Set VariableSet Team_Player = (Picked player)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Player_Is_Defeated[(Player number of Team_Player)] Equal to True
            • Then - Actions
              • Player Group - Remove Team_Player from Team_Winners.
              • Player Group - Add Team_Player to Team_Losers
            • Else - Actions
      • -------- --------
      • -------- Then check if any opposing teams still remain: --------
      • Set VariableSet Team_Has_Opposition = False
      • Set VariableSet Team_Player_Last = Neutral Passive
      • Player Group - Pick every player in Team_Winners and do (Actions)
        • Loop - Actions
          • Set VariableSet Team_Player = (Picked player)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Team_Player is an enemy of Team_Player_Last.) Equal to True
            • Then - Actions
              • Set VariableSet Team_Has_Opposition = True
            • Else - Actions
          • Set VariableSet Team_Player_Last = Team_Player
      • -------- --------
      • -------- If there's no opposition within this group then the game is over (one team remains): --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Team_Has_Opposition Equal to False
        • Then - Actions
          • -------- The only player(s) remaining in Team_Winners are part of the winning team, let's gather them and their allies for victory: --------
          • Set VariableSet Team_Player_Last = (Random player from Team_Winners)
          • Player Group - Pick every player in Team_All_Users and do (Actions)
            • Loop - Actions
              • Set VariableSet Team_Player = (Picked player)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Team_Player is an ally of Team_Player_Last.) Equal to True
                • Then - Actions
                  • Player Group - Add Team_Player to Team_Winners
                  • Player Group - Remove Team_Player from Team_Losers.
                • Else - Actions
          • -------- --------
          • Trigger - Run Game Over Finish <gen> (checking conditions)
        • Else - Actions
3) This last trigger runs when the game is officially over, it's Actions can be combined with your Victory Cinematic trigger:
  • Game Over Finish
    • Events
    • Conditions
      • Game_Is_Over Equal to False
    • Actions
      • -------- The game is officially over, the winners and losers have been separated into two groups: --------
      • Set VariableSet Game_Is_Over = True
      • Player Group - Pick every player in Team_Winners and do (Actions)
        • Loop - Actions
          • Game - Victory (Picked player) (Show dialogs, Show scores)
      • Player Group - Pick every player in Team_Losers and do (Actions)
        • Loop - Actions
          • Game - Defeat (Picked player) with the message: Defeat!

Here's an example of using the system, let's say you lose the game when your town hall dies:
  • Example of losing the game
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is A town-hall-type unit) Equal to True
      • Player_Is_Defeated[(Player number of (Owner of (Triggering unit)))] Equal to False
    • Actions
      • -------- Something happened that caused this player to "lose the game". --------
      • Set VariableSet Player_Is_Defeated[(Player number of (Owner of (Triggering unit)))] = True
      • Trigger - Run Game Over Check <gen> (checking conditions)
So you mark the Player as defeated and Run the "Game Over Check" trigger. This checks to see if one team remains. If so, the game will come to an end.

Variables used:
View attachment 549211

Important notes:

1) You'll want to think about what happens when a Player leaves the game. You'll likely want to Set Player_Is_Defeated to True for them and run Game Over Check immediately afterwards. But it's also your call, maybe Players have to destroy the leaver's base before you consider them defeated.

2) In Game Over Track Users you'll want to customize the Team_All_Users player group. Currently it's only tracking Users, so if your map supports Computer players then they should be added to it as well! It should contain anyone that can become defeated.

If you fail to consider these notes then your map may never come to an end. This is because some Players may remain marked as undefeated despite having lost the game.
Wow, thank you for the detailed tutorial! What compels you to spend your time answering these requests? Thank you very much!
 
This may be a simpler approach, haven't tested so I don't know if it works.
  • Alive Players
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked player) slot status) Equal to Is playing
            • Then - Actions
              • Player Group - Add (Picked player) to AlivePlayers
            • Else - Actions
The following trigger defeats a player when their last unit/building dies. You can modify the conditions if that's not what you want.
  • Player Dies
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Units owned by (Owner of (Dying unit)) matching (((Matching unit) is alive) Equal to True).) is empty) Equal to True
    • Actions
      • Player Group - Remove (Owner of (Dying unit)) from AlivePlayers.
      • Game - Defeat (Owner of (Dying unit)) with the message: Defeat!
      • Trigger - Run Victory Defeat Check <gen> (checking conditions)
In the following trigger you'll of course want to add every player to the events.
  • Player Leaves
    • Events
      • Player - Player 1 (Red) leaves the game
    • Conditions
    • Actions
      • Player Group - Remove (Triggering player) from AlivePlayers.
      • Game - Defeat (Triggering player) with the message: Defeat!
      • Trigger - Run Victory Defeat Check <gen> (checking conditions)
  • Victory Defeat Check
    • Events
    • Conditions
    • Actions
      • Set VariableSet PlayerCheck = (Random player from AlivePlayers)
      • Player Group - Pick every player in AlivePlayers and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Team number of PlayerCheck) Not equal to (Team number of (Picked player))
            • Then - Actions
              • Skip remaining actions
            • Else - Actions
      • Player Group - Pick every player in AlivePlayers and do (Actions)
        • Loop - Actions
          • Game - Victory (Picked player) (Show dialogs, Show scores)
      • Trigger - Run Victory Cinematic <gen> (checking conditions)
Variables:
  • PlayerCheck (Player)
  • AlivePlayers (Player Group)
Edit: this doesn't account for players leaving the game before being defeated.
Edit 2: now it does.
Edit 3: I don't know if using the Victory action on a player ends the game for that player, actually. If it does, you'll want to move that to the end of the victory cinematic.
Thank you for creating this system for me, I'm gonna give a try after work today! Much thanks!
 
Back
Top