Game Development Community

Win conditions

by Joshua Dentz · in RTS Starter Kit · 07/08/2008 (7:04 pm) · 11 replies

I need to implement the win condition for my standard rts type game. if there is only one team left, the game should end. could some one point me in the right direction to accomplish this?

#1
07/09/2008 (10:12 pm)
Mostly i need to know where the server keeps track of the number of players. then i could just throw an if statment somewhere and check the number of remaining players. i tried putting an if statement that checked clientGroup.getCount() inside RTSConnection::onClientLeaveGame() (server-side gameConnection.cs), but as far as i can tell the clientGroup count doesnt change when a client leaves
#2
07/09/2008 (10:32 pm)
Well thats weird because afaik ClientGroup count *does* change. You have however, another place to check for the current number of clients: the global variable $Server::PlayerCount.
#3
07/09/2008 (10:34 pm)
Thanks Novack, i'll give that a try.
#4
07/10/2008 (12:51 am)
Just thinking about it, it might not be the best solution to *only* count the current number of client connections. That will much probably left you in the situation of not ending the match until someone disconnects, because the non-existance of units on the map, do not means a client disconnection, afair.

You better count the units, or the buildings, something more orthodox.
#5
07/10/2008 (5:49 pm)
Well im still having issues.
in my game every team/player has a queen. when u kill the queen player::onDisabled gets called. i added a check to see if the unit killed was a queen. if it is i send a command to client "endGame" so currently it is possible to lose my game. endgame deletes all the players units and buildings (im not trying to implement a way to keep them, i dont have time). now as for the last man standing: i put a check at the bottom of RTSConnection::onClientLeaveGame() when my clientGroup.getCount check didnt work i just put a echo in there giving me the return from get count. i started a server and had a friend join my game. i killed his queen and his screen went to the endGameGui. my echo didnt come through at that point, so i had him hit the disconnect button in the endgamegui. still my echo didnt come through... when does onClientLeaveGame get called?

ok that was my bad i had it inside an if statement waiting for playerCount to drop below 2. apperently the ClientGroup.getCount() and the $Server::playerCount both still say 2 players in the game after the client leaves...or at least at the end of onClientLeaveGame()...does the player count get decrimented after onClientLeaveGame?
#6
07/10/2008 (7:08 pm)
Why not just add the queens to a separate simgroup? A queen would automatically be removed from the simgroup upon its deletion. Then you can use it in the same way as ClientGroup. Easy way to keep track of objects.
#7
07/10/2008 (9:27 pm)
Quote:A queen would automatically be removed from the simgroup upon its deletion.
Thats actually true, but its always that way; the real meaning to use a simgroup is the other way: an object will be automatically deleted, upon the simgroup deletion. Also, any object can be in only one simgroup at a time, what makes not really recomendable to waste a SimGroup for a task that dont make use of its primary feature. For example, in this case, if Joshua uses a SimGroup then the queen will not be in the RTSConnection.units a SimGroup collector for units cleaning. The actual need is just a list of queens, a SimSet would be enough.

On the matter itself,
Quote:...does the player count get decrimented after onClientLeaveGame?
Yes, exactly. After all sounds pretty logic isnt? ;)
You will find that part of the $Server::playerCount logic in example\common\server\clientConnection.cs.
Look specially at the onDrop() function which is in fact the one that calls onClientLeaveGame().
#8
07/11/2008 (7:15 pm)
Thanks for the info, i already found that actually and now im just trying to figure out how to tell the winner that he/she has won the game. how do i call upon the last client if i dont know the index?
#9
07/11/2008 (8:58 pm)
The simplest idea that comes to my mind is to follow which Queen is lost (to what team she belonged). Then just send the correspondent msg to each player with messageTeam(), and schedule endMission() for -lets say- 8 seconds inmediately after the match result message has been sent.
#10
07/14/2008 (5:17 pm)
If i understand u right, i have already done that. if your queen dies u leave the game and go to the endgame screen. that works just fine...what i need to know is how to access the last client when all but one queen has died.
#11
07/14/2008 (5:52 pm)
Ok here is a better question...if i step through all the clients..is ther a way to tell if the client has already lost?