• 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.

How to make a player loose when he has no more units.

Status
Not open for further replies.
Level 19
Joined
Jan 22, 2011
Messages
3,979
That's my question, I tried with a Trigger that checks every 1 sec if a units owned by player is empty and if it was it should defeat that player, if not keep running the trigger, but it didn't worked... I also would apreciate a way to make a player win when he is the last human player who is playing (my map has 2 PC player's) thanks.
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,219
  • Melee Initialization
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Owner of (Triggering unit)) Equal to Player 1 (Red)
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in (Units owned by Player 1 (Red))) Less than or equal to 0
        • Then - Actions
          • Game - Display to (All players) the text: player 1 is out of ...
        • Else - Actions
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,219
  • Melee Initialization
    • Events
      • Unit - A unit Dies
    • 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
              • (Number of units in (Units owned by (Picked player))) Equal to 0
            • Then - Actions
              • Game - Display to (All players) the text: player lost
            • Else - Actions
 
this is a more general one... affects any player that reaches 0 units and does not use a player group iteration

  • Events
    • Unit - A unit Dies
  • Conditions
  • Actions
    • Set tmpPlayer = Triggering Player
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Number of units in (Units owned by tmpPlayer) Less than or equal to 0
      • Then - Actions
        • Game - Display to (All players) the text: Player Name(tmpPlayer) is out of ...
      • Else - Actions
BTW, the unit group leaks...
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
If the players are P1 and P2, this should work.
Trigger

  • Untitled Trigger 125
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Player number of (Triggering player)) Less than 3
    • Actions
      • Set PLAYER = (Triggering player)
      • Custom script: set bj_wantDestroyGroup = true
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in (Units owned by PLAYER matching (((Matching unit) is alive) Equal to True))) Equal to 0
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • PLAYER Equal to Player 1 (Red)
            • Then - Actions
              • Game - Victory Player 2 (Blue) (Show dialogs, Show scores)
            • Else - Actions
              • Game - Victory Player 1 (Red) (Show dialogs, Show scores)
          • Game - Defeat PLAYER with the message: Defeat!
        • Else - Actions
 
Level 7
Joined
Jun 14, 2009
Messages
235
Well as far as I can see, your "win" trigger doesn't have any triggering event.

For your defeat trigger, the game engine doesn't register a unit as being dead when it is killed for some reason. You can however change the trigger condition to check for how many units a player has that are ALIVE, and this works.
 

Attachments

  • Banshe.w3x
    1,009 KB · Views: 31
Status
Not open for further replies.
Top