• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Two Players Remaining Ends Game

Status
Not open for further replies.
Level 2
Joined
Nov 27, 2012
Messages
7
Hello, I'm in need of help with a Trigger.

I'm sure the solution is pretty easy, but I need a trigger that can detect if there is two players remaining, and end the game in a victory for both of them.

I've tried a few different things, and none of them seem to work. Any help would be appreciated!
 
Level 18
Joined
May 11, 2012
Messages
2,103
ok, let's see: First, make a trigger that count how much players are in the game by doing this trigger:
  • Counting Players Playing
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • For each (Integer A) from 1 to (Number of Players in your map), do (Actions)
        • Loop - Actions
          • If (((Player((Integer A))) slot status) Equal to Is playing) then do (Set CountingPlayersPlaying = (CountingPlayersPlaying + 1)) else do (Do nothing)
          • Trigger - Add to Removing Players from Variable <gen> the event (Player - (Player((Integer A))) leaves the game with a defeat)
          • Trigger - Add to Removing Players from Variable <gen> the event (Player - (Player((Integer A))) leaves the game)
Now you'll have to make a trigger that removes the players from a variable once they are defeated or they leave:
  • Removing Players from Variable
    • Events
    • Conditions
    • Actions
      • Set CountingPlayersPlaying = (CountingPlayersPlaying - 1)
And now the Victory Trigger:
  • Victory Trigger
    • Events
      • Time - Every 5.00 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • CountingPlayersPlaying Less than or equal to 2
        • Then - Actions
          • Game - Display to (All players) the text: You are Victorious!
          • For each (Integer A) from 1 to CountingPlayersPlaying, do (Actions)
            • Loop - Actions
              • Game - Victory (Player((Integer A))) (Show dialogs, Show scores)
        • Else - Actions
Thats preety much it. See how it works for you!
 
Last edited:
Status
Not open for further replies.
Top