Saturday, July 21, 2007

HOWTO: Respawn Instantly

Brought to you by blogger, Someone :)

Someone actually brought this to us a while back, and I apologize for taking so long to post it. Anyway, here's a tip that will allow you to respawn instantly after exploding. In LocalPlayer.cxx (in /src/bzflag/ of the extracted source), search for "else if (location == Exploding)" and you will find this section:

} else if (location == Exploding) {
// see if explosing time has expired
if (lastTime - getExplodeTime() >= BZDB.eval(StateDatabase::BZDB_EXPLODETIME)) {
dt -= float((lastTime - getExplodeTime()) - BZDB.eval(StateDatabase::BZDB_EXPLODETIME));
if (dt <>
dt = 0.0f;
}
setStatus(PlayerState::DeadStatus);
location = Dead;
if (isAutoPilot()) {
CMDMGR.run("restart");
}
}

// can't control explosion motion
newVelocity[2] += BZDBCache::gravity * dt;
newAngVel = 0.0f; // or oldAngVel to spin while exploding
} else if ((location == OnGround) || (location == OnBuilding) ||


First, let's look at the first through eighth lines from above:

} else if (location == Exploding) {
// see if explosing time has expired
if (lastTime - getExplodeTime() >= BZDB.eval(StateDatabase::BZDB_EXPLODETIME)) {
dt -= float((lastTime - getExplodeTime()) - BZDB.eval(StateDatabase::BZDB_EXPLODETIME));
if (dt <>
dt = 0.0f;
}
setStatus(PlayerState::DeadStatus);


Let's remove the second through seventh lines so that it now reads like this:

} else if (location == Exploding) {
setStatus(PlayerState::DeadStatus);

In my personal edit, I aligned the fist "s" of " setStatus" just below the below the first "e" of "else if". Next, notice this section:

setStatus(PlayerState::DeadStatus);
location = Dead;
if (isAutoPilot()) {
CMDMGR.run("restart");

Let's remove "location = Dead;" and "if (isAutoPilot()) {". Below the line "location = Dead;", add the following (again, I aligned the lines vertically in my personal edit):

LocalPlayer *myTank = LocalPlayer::getMyTank();

Below that line, add this line:

myTank->setJumpPressed(false);

The above edits should now read like this (all aligned vertically in my pesonal edit):

setStatus(PlayerState::DeadStatus);
location = Dead;
LocalPlayer *myTank = LocalPlayer::getMyTank();
myTank->setJumpPressed(false);
CMDMGR.run("restart");

Next, notice this section:

CMDMGR.run("restart");
}
}

// can't control explosion motion
newVelocity[2] += BZDBCache::gravity * dt;
newAngVel = 0.0f; // or oldAngVel to spin while exploding
} else if ((location == OnGround) || (location == OnBuilding) ||

Let's remove the lines between "CMDMGR.run("restart");" and " } else if ((location == OnGround) || (location == OnBuilding) ||" so that the section now reads like this:

CMDMGR.run("restart");
} else if ((location == OnGround) || (location == OnBuilding) ||

In my personal edit, I vertically aligned "} else if ((location == OnGround) || (location == OnBuilding) ||" with the previous else if line "} else if (location == Exploding) {"

When you are finished, compile your client and you're done. To view Someone's original instructions, read his comment to "HOWTO: Drop Bad Flags Instantly".

As always...

Have fun!

Related posts:
HOWTO: Drop Bad Flags Instantly
HOWTO: Drop Bad Flags Like Regular Flags
HOWTO: Classic God Mode

0 Comments:

Post a Comment

<< Home