• 🏆 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!

SHOW IN BBCODE - How to make the Last one win?

Status
Not open for further replies.

old

old

Level 6
Joined
May 8, 2016
Messages
112
  • Dead P1
    • Events
      • Unit - A unit owned by Player 1 (Red) Dies
    • Conditions
      • ((Dying unit) is A Hero) Equal to True
    • Actions
      • Set Lives[1] = (Lives[1] - 1)
  • Dead Global
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Dying unit) is A Hero) Equal to True
      • Lives[(Player number of (Owner of (Dying unit)))] Equal to 0
    • Actions
      • Game - Defeat (Owner of (Dying unit)) with the message: Defeat!
      • Unit - Remove (Dying unit) from the game
This mode is last man stand, heroes have a X number of lives and if they lost they are removed with defeat... Ok.
But how can i make to the last one win? All are defeated but the last one still in game alone without any "GG WP"...
Give me step by step with BBCode please (Example: You must create an XXXXXX and add an YYYYY to do ......... etc)
 
Level 39
Joined
Feb 27, 2007
Messages
5,034
If you set the map's victory conditions right, it will probably display a victory message for the only remaining player since you've actually called the "defeat player" function. Otherwise add this after you defeat whomever just died:
  • Set PlayingPlayers = 0
  • Loop - For each (integer a) from 1 to 12 do (actions)
    • Loop - Actions
      • If (conditions) then do (actions) else do (else actions)
        • If - Conditions
          • ((Player((Integer A))) slot status) Equal to Is playing
        • Then - Actions
          • Set PlayingPlayers = PlayingPlayers + 1
          • Set WinPlayer = Player((Integer A))
        • Else - Actions
  • If (All conditions are true) then do (actions) else do (else actions)
    • If - Conditions
      • PlayingPlayers equal to 1
    • Then - Actions
      • Game - Victory WinPlayer (Show dialogs, Show scores)
    • Else - Actions
Read through to understand why this is the way it is. It checks how many players are still playing (I'm fairly certain that won't count computer players) and if it's only 1 then that player must have won. WinPlayer can safely be set whenever we find a playing player because we only care about when there's 1 un-defeated player left.
 
Status
Not open for further replies.
Top