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?
Automatic game start?
Automatic game start?
"There's no such thing as stupid questions. There's just stupid people." - Mr. Garrison
Re: Automatic game start?
Check what autopilot does. It automatically respawns after a death.
Re: Automatic game start?
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.blast wrote:Check what autopilot does. It automatically respawns after a death.
"There's no such thing as stupid questions. There's just stupid people." - Mr. Garrison
Re: Automatic game start?
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.
Re: Automatic game start?
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
Re: Automatic game start?
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:
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.
Anyways, looks like LocalPlayer.cxx might be your best bet, specifically:
Code: Select all
if (isAutoPilot()) {
CMDMGR.run("restart");
}
And don't admire the code too much. A lot of that code is really, really old stuff and might not follow best practices.
Re: Automatic game start?
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:
Edit: Or then just comment the "if(isAutoPilot())" away in function doUpdateMotion() in LocalPlayer.cxx, as suggested by blast above.
Code: Select all
GameKeeper::Player *playerData = GameKeeper::Player::getPlayerByIndex(victimIndex);
playerData->player.queueSpawn();
"There's no such thing as stupid questions. There's just stupid people." - Mr. Garrison