Game Development Community

Mission finish when all bot are dead?

by Jonathan Kelly · in Torque Game Engine · 01/20/2005 (7:47 am) · 8 replies

Hey, I'm trying to find where would be the best place to do this.

I need to check if all the bots are dead, then to go back to our main menu.

Any help?

#1
01/20/2005 (8:01 am)
Never tried anything like this (yet) but one way to it would be to have a variable (botCount) in the server and every time a bot spawns you increase it by one. Then every time a bot dies a function in the bot is called that can decrease the botCount by one and at the same time call a function in the servercode that checks if the variable has reached 0. If it has, simply restart or call whatever function you have that returns server to starting state.
#2
01/20/2005 (8:33 am)
Anthony did something like this for an early Lore training mission.

He put all the objects (in this case Land Mines) in a sim group, and looked in that sim group to see if any items were still there.

When there were no longer any items in the simgroup, he ended the mission.

He might be able to explain more precisely what he did, if that is not enough to go on.
#3
01/21/2005 (7:20 am)
Put the check in the OnDeath function. This way, every time you kill a bot you'll see if it's time to end the game
#4
01/21/2005 (10:08 am)
Where is the OnDeath function?
#5
01/21/2005 (10:13 am)
Starter.fps/server/scripts/game.cs
#6
01/22/2005 (8:30 am)
I beleive it's in player.cs or AIPlayer.CS, it's called when a player get's hit by a projectile, and he is dead.

So when this happens to an AIplayer, you decrement your bot counter. when it reaches 0, the game ends.
#7
01/22/2005 (8:45 am)
Problem with on death approach is say you have all you bots in a sim group. The bots will not be removed from the group until they are deleted you might try using a schedual an periodically monitor to check to see if you bots are dead.

Personally I find putting bot into s simset makes it very easy to see if bots are alive if they are dead they will be removed from the group and inturn the simgroup count will go down
#8
01/23/2005 (6:47 am)
@Anthony

Why bother including the bots in a simgroup or a simset ? The live quite well on their own :-)

All he needs is a global $botcounter. The OnDeath function is a really good place to decrement this counter, so when it reaches 0, the game ends.