HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Telling Map to end game when all Players dead?

01-23-2004, 02:34 PM#1
shadow)ps(
Ok i want the map to end the game when ALL player MAIN units are dead, in this case, siege tanks. i know it has to do with variables and i have used them. but the game always ends when theres like, one person left alive. never 2 more more, just 1. i made a seperate variable for each player, like player1 player2 etc. etc. and their all false in the beginning. the map is supposed to end when all the respective variables are true. i already made triggers to detect any slots not filled by players and have them set the respective variable to true. i also set it so if a player leaves it sets the variable as well. but the end game trigger always fires before everyone is dead, namely when only one person is left alive. any ideas as to whats wrong?
01-23-2004, 02:40 PM#2
DaKaN
first of all use 1 boolean array

PlayerDead[]

then when a steam tank dies, get the PlayerNumberOf(GetOwnerOf(TriggerUnit())). and use that as the array's index

set PlayerDead[Player Number of (Owner of (Trigger Unit) )] = true

loop from 1 to (insert your max players here)
If PlayerDead[Integfer A] = true then
set PlayerDead[0] = true
else
set PlayerDead[0] = false
endif

If PlayerDead[0] == true then
end game
endif
01-23-2004, 02:43 PM#3
shadow)ps(
you can "rescue" the dead, doi have to add another trigger to put it to false?
01-23-2004, 02:48 PM#4
RaeVanMorlock
Quote:
Originally posted by shadow)ps(
Ok i want the map to end the game when ALL player MAIN units are dead, in this case, siege tanks.

First thing that comes to mind is to make a variable called SiegeCount of type Integer and use a trigger based off of this pseudo-code...

Events
. Unit - A unit dies

Conditions
. (Unit-Type of (Dying Unit)) Equal to Siege Tank

Actions
. Unit Group - Pick every unit in (Units in (Playable map area) matching ((Unit-type of (Matching Unit)) Equal to Siege Tank)) and do (Actions)
. . Loop - Actions
. . . Set SiegeCount = SiegeCount + 1
. If SiegeCount = 0 Then
. . Then - Actions
. . . Player Group - Pick every player in All Players and do (Actions)
. . . . Loop - Actions
. . . . . Game - Defeat Picked Player with the message: Defeat!




Update:
Dakan's code won't work because the ending value of PlayerDead[0] would be equivalent to whether or not the last player is dead instead of if all the players are dead

You'd have to do somethign more like:

AllPlayersDead = True
For IntegerA = 1 to 12
. If PlayerDead[IntegerA] = False Then
. . AllPlayersDead = False

This way, so long as one player is not dead, all players aren't dead. But if there is no 'not dead' player than the original assignment of AllPlayersDead will hold true throughout the loop.
01-23-2004, 08:53 PM#5
DaKaN
Yea i made a slight typo, was a little early in the morning. The count method would work fine as long as you add a check to make sure the unit is alive. Dead units still get counted in the pick every unit functions.
01-23-2004, 09:08 PM#6
RaeVanMorlock
Quote:
Originally posted by DaKaN
Dead units still get counted in the pick every unit functions.

They do? That's good to know.

It really depends on the rules of the game if they should be counted then. Maybe so long as there's a corpse available to rescue, the game should continue. The description was rather vague and all.
01-23-2004, 11:49 PM#7
DaKaN
Dead units are still counted until thier decomposition is complete (because they still can be used by spells like raise dead and animate dead, or exhume corpse etc.)