Saturday, June 23, 2007

HOWTO: Drop Bad Flags Instantly

Bad flags are annoying, are they not? This is especially true in situations such as grabbing Jamming when your opponent has Cloaking. And those time limits! On servers with bad flag drop such as 15 seconds or more, waiting can be ever so dull. Wide Angle isn't so awfully bad if you get used being able to utilize it; but, let's face it; there are certainly other more desirable flags.

Here's an edit that will allow you to drop bad flags instantly even on servers that do not allow dropping of bad flags (an added bonus). Most players probably won't notice; however, there is a chance that the more experienced players might very well notice -- even if after a while -- as well as administrators especially if they're already monitoring you out of suspicion.

Open LocalPlayer.cxx in the /src/bzflag/ directory of the extracted source, and find the following lines:

// drop bad flag if timeout has expired
if (!isPaused() && dt > 0.0f && World::getWorld()->allowShakeTimeout() &&
getFlag() != Flags::Null && getFlag()->endurance == FlagSticky &&
flagShakingTime > 0.0f) {
flagShakingTime -= dt;
if (flagShakingTime <= 0.0f) { flagShakingTime = 0.0f; server->sendDropFlag(getPosition());


First, look at the second line:

if (!isPaused() &&amp; dt > 0.0f && World::getWorld()->allowShakeTimeout() &&

Let's remove "World::getWorld()->allowShakeTimeout() &&" so that it reads like this:

if (!isPaused() &&amp; dt > 0.0f &&

Next, let's look at the fifth line:

flagShakingTime -= dt;

Let's change "-= dt" to "= 0.0f" so that the line reads like this:

flagShakingTime = 0.0f;

The above will allow you to drop bad flags instantly on servers that allow for dropping of bad flags. To be able to drop flags on servers that don't allow dropping, we need to edit elsewhere. Take note, however, that experienced players will most likely notice your dropping bad flags if you are playing on a server that doesn't allow it. To add the ability, find the following lines:

// if it's bad then reset countdowns and set antidote flag
if (getFlag() != Flags::Null && getFlag()->endurance == FlagSticky) {
if (World::getWorld()->allowShakeTimeout())
flagShakingTime = World::getWorld()->getFlagShakeTimeout();

Look at the third line:

if (World::getWorld()->allowShakeTimeout())

Remove "->allowShakeTimeout()" so that it reads like this:

if (World::getWorld())

Next, let's look at the forth line:

flagShakingTime = World::getWorld()->getFlagShakeTimeout();

Replace "= World::getWorld()->getFlagShakeTimeout();" with "= 0.05f;" so that it reads like this:

flagShakingTime = 0.05f;

I originally tried the number to "0.0f". When I tested it on my server not allowing bad flag dropping, and no win limit, it didn't work; I picked up a bad flag and it didn't drop. So, 0.05f "works". All of this tip works even if there are easier and/or more efficient ways of accomplishing the same ends :)

When you're finished, save your file, compile your new client, and...

Have fun!

Related post:
HOWTO: Drop Bad Flags Like Regular Flags

7 Comments:

Blogger Ben said...

Get a grip and a sense of humour prick

6/29/2007 10:09 AM  
Blogger someone said...

First, can you get rid of the previous comment?

---

Instant respawn cheat:

In src/bzflag/LocalPlayer.cxx search for 'else if (location == Exploding)' and you will find a section:

newAngVel = oldAngVel;
} 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 < 0.0f) {
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) ||

Replace it with:

newAngVel = oldAngVel;
} else if (location == Exploding) {
setStatus(PlayerState::DeadStatus);
location = Dead;
LocalPlayer *myTank = LocalPlayer::getMyTank();
myTank->setJumpPressed(false);
CMDMGR.run("restart");
} else if ((location == OnGround) || (location == OnBuilding) ||

Now compile and run bzflag. Immediately after you die, you will automatically respawn.

----

Later, I'll give you backwards in OO.

7/05/2007 10:20 AM  
Blogger someone said...

Backwards is OO:

In src/bzflag/LocalPlayer.cxx search for 'expelled = (obstacle->getType()' and you will find a section:

if (expelled && phased)
expelled = (obstacle->getType() == WallObstacle::getClassName() ||
obstacle->getType() == Teleporter::getClassName() ||
(getFlag() == Flags::OscillationOverthruster && desiredSpeed < 0.0f &&
p[2] == 0.0f));
return obstacle;


Replace it with:

if (expelled && phased)
expelled = (obstacle->getType() == WallObstacle::getClassName() ||
obstacle->getType() == Teleporter::getClassName());
return obstacle;

Search for 'expelled = (obstacle->getType()' and you will find a similar section:

expelled = (obstacle != NULL);
if (expelled && phased)
expelled = (obstacle->getType() == WallObstacle::getClassName() ||
obstacle->getType() == Teleporter::getClassName() ||
(hasOOflag && desiredSpeed < 0.0f && p[2] == 0.0f));

if (obstacle != NULL) {

Replace it with:

expelled = (obstacle != NULL);
if (expelled && phased)
expelled = (obstacle->getType() == WallObstacle::getClassName() ||
obstacle->getType() == Teleporter::getClassName());

if (obstacle != NULL) {

7/05/2007 2:50 PM  
Blogger phasmophage said...

One easy way to drop a bad flag is to edit the cmdDrop function in clientCommands.cxx

Find this part:
if (myTank != NULL) {
FlagType* flag = myTank->getFlag();
if ((flag != Flags::Null) && !myTank->isPaused() &&
(flag->endurance != FlagSticky) && !myTank->isPhantomZoned() &&
!(flag == Flags::OscillationOverthruster &&
myTank->getLocation() == LocalPlayer::InBuilding)) {
serverLink->sendDropFlag(myTank->getPosition());
// changed: on windows it may happen the MsgDropFlag
// never comes back to us, so we drop it right away
handleFlagDropped(myTank);
}
}


and take out the "(flag->endurance != FlagSticky) &&"
Then you can drop a bad flag like a regular one.

7/20/2007 4:37 PM  
Blogger CRW said...

Someone, I apologize for taking so long to post your tip. Thank you very much for sharing! I tried out the driving backward with OO in a building, but that didn't quite work. Is there anything that you can add to that tip to complete it?

Phaz, thanks for the tip about dropping bad flags ;) Your tip is certainly easier that the one I originally posted.

Please keep these tips rolling in!

7/21/2007 4:59 PM  
Blogger phasmophage said...

For backing up into a building with OO, there are 3 things I think we have to get rid of. (Sorry to end my sentence with a preposition.) They are located in LocalPlayer.cxx

Find this piece of code:
if (expelled && phased)
expelled = (obstacle->getType() == WallObstacle::getClassName() ||
obstacle->getType() == Teleporter::getClassName() ||
(getFlag() == Flags::OscillationOverthruster && desiredSpeed < 0.0f &&
p[2] == 0.0f));

Then take out the "||
(getFlag() == Flags::OscillationOverthruster && desiredSpeed < 0.0f &&
p[2] == 0.0f)"

The second part, almost exactly like the first looks like this:

if (expelled && phased)
expelled = (obstacle->getType() == WallObstacle::getClassName() ||
obstacle->getType() == Teleporter::getClassName() ||
(hasOOflag && desiredSpeed < 0.0f && p[2] == 0.0f));

Take out the "||
(hasOOflag && desiredSpeed < 0.0f && p[2] == 0.0f)"

The first two don't let you backup into a building. To backup while _inside_ a building, look for this code:

// oscillation overthruster tank in building can't back up
if (fracOfMaxSpeed < 0.0f && getLocation() == InBuilding &&
flag == Flags::OscillationOverthruster && !bCheatOO) {
fracOfMaxSpeed = 0.0f;
}

And you can pretty much delete it.

This should work. Hope this helps.
-phaz

7/21/2007 5:19 PM  
Blogger Someone said...

Thanks for publishing it! Sorry about the OO thing.

8/03/2007 5:46 PM  

Post a Comment

<< Home