• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

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,968
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,184
  • 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,184
  • 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,240
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