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

Lose the game when hero dies

Status
Not open for further replies.
Level 10
Joined
Nov 5, 2008
Messages
536
When a player looses his Hero he looses the game.
When there is only one player left in the game with a hero, that player wins the game.



How would you trigger this in an efficent way?
 
Level 3
Joined
Jul 27, 2008
Messages
35
I'm going to try and do this even though I'm not very good with triggers (you might want to let someone else come along and post some kind of better way of doing it :con:).

  • Events
    • Unit - A unit Dies
  • Conditions
    • ((Triggering unit) is A Hero) Equal to True
  • Actions
    • -------- You can replace this with any other form of defeat. --------
    • Game - Defeat (Owner of (Triggering unit)) with the message: Whatever
    • -------- This variable would initially be set to however many players there are. --------
    • Set herosLeft = (herosLeft - 1)
    • -------- This player group would contain all of the players who are playing. --------
    • Player Group - Remove (Owner of (Triggering unit)) from remainingPlayers
    • -------- This activates the trigger that checks to see if someone wins yet. --------
    • Trigger - Run Check For Winner <gen> (checking conditions)
And then the "Check For Winner" trigger would be this:

  • Events
  • Conditions
    • herosLeft Equal to 1
  • Actions
    • -------- This takes the player who hasn't lost yet and makes them win. --------
    • Player Group - Pick every player in remainingPlayers and do (Actions)
      • Loop - Actions
        • Game - Victory (Picked player) (Show dialogs, Show scores)
 
Level 19
Joined
Feb 25, 2009
Messages
2,004
Kabel said:
  • -------- This variable would initially be set to however many players there are. --------
  • Set herosLeft = (herosLeft - 1)

In my game there can be 2 - 4 players, if I set the variable to 4 and then there are only 2 players playing, will that cause any problems?

Since the "Check for winner" trigger checks for "herosLeft" to be 1, that will be no problem.
 
Level 13
Joined
Sep 14, 2008
Messages
1,407
Since the "Check for winner" trigger checks for "herosLeft" to be 1, that will be no problem.


Actually that will be the big problem :)

Because if 2 players are playing and the variable is set to 4 it will not run when one of them dies ALTHOUGh the other one just won :)

You need to set it too the number of playing players.

Try:

For Integer a 1-4
if(player(convert player number(Integer A)) is Playing equals to true)
Then: Set HerosLeft = HerosLeft + 1
 
Level 9
Joined
Aug 27, 2009
Messages
473
Kabel:
  • HeroDies
  • Events
    • Unit - A unit Dies
  • Conditions
    • ((Triggering unit) is A Hero) Equal to True
  • Actions
    • -------- You can replace this with any other form of defeat. --------
    • Game - Defeat (Owner of (Triggering unit)) with the message: Whatever
    • -------- This variable would initially be set to however many players there are. --------
    • Set herosLeft = (herosLeft - 1)
    • -------- This player group would contain all of the players who are playing. --------
    • Player Group - Remove (Owner of (Triggering unit)) from remainingPlayers
    • -------- This activates the trigger that checks to see if someone wins yet. --------
    • Trigger - Run Check For Winner <gen> (checking conditions)
  • Events
  • Conditions
    • herosLeft Equal to 1
  • Actions
    • -------- This takes the player who hasn't lost yet and makes them win. --------
    • Player Group - Pick every player in remainingPlayers and do (Actions)
      • Loop - Actions
        • Game - Victory (Picked player) (Show dialogs, Show scores)

Use that, but remove the "Run Trigger..." just add an If - Then - Else and put the Conditions and Actions from "Check For Winner" to "HeroDies". If you understand..

And this:
Add this to your Map Initialization:

For Integer a 1-12
If
Player(Integer A) is playing
Then
Set (Variable) herosLeft = herosLeft + 1

If you didnt understand i will make the
  • tag.[/QUOTE]
 
Status
Not open for further replies.
Top