• Check out the results of the Techtree Contest #19!
  • 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.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

Lose the game when hero dies

Status
Not open for further replies.
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)
 
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.
 
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
 
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.
Back
Top