Automatic game start?

Questions or HOWTOs about the above? Post 'em here...
Post Reply
catcha
Private First Class
Private First Class
Posts: 22
Joined: Tue Nov 17, 2009 8:24 pm

Automatic game start?

Post by catcha »

Hi all,

I'd like to modify bzflag 2.0.12 so that it starts automatically without any controller actions (so, every time the player dies, he/she restarts in a random position without having to press mouse or key). I don't understand the code well enough to do this. I'd guess the restart is done somewhere in player or localplayer modules but couldn't find it. Any suggestions?
"There's no such thing as stupid questions. There's just stupid people." - Mr. Garrison
User avatar
blast
General
General
Posts: 4931
Joined: Fri Mar 21, 2003 3:49 pm
Location: playing.cxx
Contact:

Re: Automatic game start?

Post by blast »

Check what autopilot does. It automatically respawns after a death.
"In addition to knowing the secrets of the Universe, I can assure you that I am also quite potty trained." -Koenma (Yu Yu Hakusho)

Image
catcha
Private First Class
Private First Class
Posts: 22
Joined: Tue Nov 17, 2009 8:24 pm

Re: Automatic game start?

Post by catcha »

blast wrote:Check what autopilot does. It automatically respawns after a death.
Thanks for the suggestion, but I found nuthing related to respawning in bzflag/autopilot.cxx. Could you be more specific with where to look? Thanks.
"There's no such thing as stupid questions. There's just stupid people." - Mr. Garrison
User avatar
blast
General
General
Posts: 4931
Joined: Fri Mar 21, 2003 3:49 pm
Location: playing.cxx
Contact:

Re: Automatic game start?

Post by blast »

If you are wanting to code, you should learn how to use the search function of your OS or IDE. So again, look for autopilot.
"In addition to knowing the secrets of the Universe, I can assure you that I am also quite potty trained." -Koenma (Yu Yu Hakusho)

Image
catcha
Private First Class
Private First Class
Posts: 22
Joined: Tue Nov 17, 2009 8:24 pm

Re: Automatic game start?

Post by catcha »

There's a lot of stuff related to autopilot (104 matching lines in 23 matching files), so I thought to ask whether you experts can make understanding the code any easier. I must admit that I really admire bzflag especially after going through the source code, and you probably have all the right to be a bit arrogant about sharing your wisdom to outsiders. Thanks for your help so far.
"There's no such thing as stupid questions. There's just stupid people." - Mr. Garrison
User avatar
blast
General
General
Posts: 4931
Joined: Fri Mar 21, 2003 3:49 pm
Location: playing.cxx
Contact:

Re: Automatic game start?

Post by blast »

There's a lot fewer occurrences of isAutoPilot though. (Only 19 in the src/bzflag/ directory) So part of searching is looking for things to help narrow the search.

Anyways, looks like LocalPlayer.cxx might be your best bet, specifically:

Code: Select all

if (isAutoPilot()) {
  CMDMGR.run("restart");
}
You can use CMDMGR.run to do lots of other things. More commands are listed in clientCommands.cxx.

And don't admire the code too much. A lot of that code is really, really old stuff and might not follow best practices. ;)
"In addition to knowing the secrets of the Universe, I can assure you that I am also quite potty trained." -Koenma (Yu Yu Hakusho)

Image
catcha
Private First Class
Private First Class
Posts: 22
Joined: Tue Nov 17, 2009 8:24 pm

Re: Automatic game start?

Post by catcha »

To answer my own question (perhaps someone else at some distant future might also wonder about this). To add automatic respawn after getting killed, add the following at the end of the function playerKilled() in bzfs.cxx:

Code: Select all

GameKeeper::Player *playerData = GameKeeper::Player::getPlayerByIndex(victimIndex);
playerData->player.queueSpawn();
Edit: Or then just comment the "if(isAutoPilot())" away in function doUpdateMotion() in LocalPlayer.cxx, as suggested by blast above.
"There's no such thing as stupid questions. There's just stupid people." - Mr. Garrison
Post Reply