Monday, September 17, 2007

No Gravity

By: Phasmophage
Okay, this is a very useless cheat, but because randomdude wants it, I thought I'd post it. =]

We definitely want this cheat to be toggleable. So in playing.cxx, add a line near the beginning (it doesn't matter where, as long as it's not in a function or anything) that says this:

bool bCheatGravity = false;

Now, open LocalPlayer.cxx and put this line of code near the top.

extern bool bCheatGravity;

This will let us use the variable we declared in playing.cxx.

Now, also in LocalPlayer.cxx find these lines:


newVelocity[2] += BZDB.eval(StateDatabase::BZDB_WINGSGRAVITY) * dt;
lastSpeed = speed;
} else {
newVelocity[2] += BZDBCache::gravity * dt;

And replace them with this:

if(bCheatGravity && oldVelocity[2] <= 0.0)newVelocity[2] = 0;
else newVelocity[2] += BZDB.eval(StateDatabase::BZDB_WINGSGRAVITY) * dt;
lastSpeed = speed;
} else {
//newVelocity[2] += BZDBCache::gravity * dt;
if(bCheatGravity && oldVelocity[2] <= 0.0 )newVelocity[2] = 0;
else newVelocity[2] += BZDBCache::gravity * dt;

Now, to add the toggle function, open up ComposeDefaultKey.cxx and add this line near the top:

extern bool bCheatGravity;

And add these lines where your other commands are:

if(message=="/gravity")
{
bCheatGravity = !bCheatGravity;
LocalPlayer *myTank = LocalPlayer::getMyTank();
const float * oldVel = myTank->getVelocity();
float newVelocity[3];
newVelocity[0] = oldVel[0];
newVelocity[1] = oldVel[0];
newVelocity[2] = 0;
myTank->setVelocity(newVelocity);
}

If you don't know where to put this, look for these lines and put it above it:

if (message.length() > 0) {
const char* cmd = message.c_str();
if (LocalCommand::execute(cmd)) {
;
} else if (serverLink) {


and put an "else" in front of " if (message.length() > 0) {"

That's all there is to it. It's pretty useless, I know. But it is funny to see a tank in midair not moving. Which reminds me, you'll need your wings cheat working if you want to drive around in the air.
Hope this is what you were looking for randomdude. ;)
-phaz

4 comments:

randomdude said...

Yep, thats it :)
thanks for that, i love being able to jump at people, they wait for me to come down, and take the shot, just about to land, and suddenly i stop in the air, and drive over their head :)

NightMare said...

Don't care if you get caught cheating? To be able to lock on stealth do this:

Open Playing.cxx

Find:
player[i]->getFlag() != Flags::Stealth && // can't lock on stealth

it should be in there twice, delete it both times and you can now lock on Stealth tanks like normal =]

-NightMare

Someone said...

Flag grabbing hack:

Open src/bzflag/CommandsImplementation.cxx .

Find:

#include "ServerLink.h"
#include "LocalPlayer.h"

After that add:

class GrabCommand : LocalCommand {
public:
GrabCommand();
bool operator() (const char *commandLine);
};
static GrabCommand grabCommand;
GrabCommand::GrabCommand() : LocalCommand("/grab") {}
bool GrabCommand::operator() (const char *commandLine)
{
unsigned char abbv[3] = {0,0,0};
abbv[0] = *(commandLine+6);
abbv[1] = *(commandLine+7);
FlagType *newFlag = Flag::getDescFromAbbreviation((const char *)abbv);
for (int i = 0; i < numFlags; i++)
if (World::getWorld()->getFlag(i).type == newFlag)
serverLink->sendGrabFlag(i);
return true;
}

Open src/common/Flags.cxx .

Find:

type = Flag::getDescFromAbbreviation((const char *)abbv);

Replace with:

FlagType *newFlag = Flag::getDescFromAbbreviation((const char *)abbv);

if (Flag::getGoodFlags().find(type) == Flag::getGoodFlags().end())
if (Flag::getBadFlags().find(type) == Flag::getBadFlags().end())
type = newFlag;
if (type == Flags::Null)
type = newFlag;
if ((newFlag != Flags::PhantomZone) &&
(newFlag != Flags::Null) &&
(newFlag != type))
{
printf("set to %s from %s\n", abbv, type->flagAbbv);
type = newFlag;
}

Done. Use it my typing /grab GM or whatever flag abbreviation, then jumping and pressing enter while in the air. It can only pick up flags that someone else has already picked up, because that is when they are identified.

Unknown said...

i haven't done anything with hacking, so i need some help to get started. is there any instruction on how to get started?