Monday, December 31, 2007

Guided Bullets

Ok this code is pretty nice, just lock onto your opponent and it shoots in the direction they're going or right at them pretty accurately. I didn't create this code, but I'm not sure who gave it to me but here it is:


You might have trouble if you have guided lasers.

In src/bzflag/playing.cxx find:

// see if it's inside lock-on angle (if we're trying to lock-on)
if (a <>getFlag() == Flags::GuidedMissile) // am i locking on?
tankHasShotType(myTank, Flags::GuidedMissile)) &&
player[i]->getFlag() != Flags::Stealth && // can't lock on stealth
!player[i]->isPaused() && // can't lock on paused
!player[i]->isNotResponding() && // can't lock on not responding
d < besttarget =" player[i];" bestdistance =" d;" lockedon =" true;">getFlag() == Flags::GuidedMissile) // am i locking on?

To:

(1 // am i locking on?

In src/bzflag/LocalPlayer.cxx find:

// Set _shotsKeepVerticalVelocity on the server if you want shots
// to have the same vertical velocity as the tank when fired.
// keeping shots moving horizontally makes the game more playable.
firingInfo.shot.vel[2] = 0.0f;

Add this after it:

if (getTarget()) {
const Player * targ = getTarget();
double myx = LocalPlayer::getMyTank()->getPosition()[0];
double myy = LocalPlayer::getMyTank()->getPosition()[1];
double myz = LocalPlayer::getMyTank()->getPosition()[2] +
LocalPlayer::getMyTank()->getMuzzleHeight();
double hisx = targ->getPosition()[0];
double hisy = targ->getPosition()[1];
double hisz = targ->getPosition()[2] + targ->getMuzzleHeight();
double hisvx = targ->getVelocity()[0];
double hisvy = targ->getVelocity()[1];
double hisvz = targ->getVelocity()[2];
double deltax = hisx - myx;
double deltay = hisy - myy;
double distance = hypotf(deltax,deltay)- BZDBCache::tankRadius;
// - BZDB.eval(StateDatabase::BZDB_MUZZLEFRONT);
if (distance <= 0) distance = 0; double shotspeed = BZDB.eval(StateDatabase::BZDB_SHOTSPEED)*( LocalPlayer::getMyTank()->getFlag() == Flags::Laser ?
BZDB.eval(StateDatabase::BZDB_LASERADVEL) :
LocalPlayer::getMyTank()->getFlag() == Flags::RapidFire ?
BZDB.eval(StateDatabase::BZDB_RFIREADVEL) :
LocalPlayer::getMyTank()->getFlag() == Flags::MachineGun ?
BZDB.eval(StateDatabase::BZDB_MGUNADVEL) : 1);
double errdistance = 1.0;
float tx, ty, tz;
for (int tries=0 ; errdistance > 0.05 && tries < t =" (float)distance" omega="fabs(targ-">getAngularVelocity());
double sx,sy;
if ((targ->getStatus() & PlayerState::Falling) fabs(omega)
< sx="t*hisvx;" sy="t*hisvy;" hisspeed =" hypotf(hisvx," alfa =" omega" r =" hisspeed" dx =" r" dy2 =" r" beta =" atan2(dy2,">getAngularVelocity() >
0 ? 1 : -1);
double gamma = atan2(hisvy, hisvx);
double rho = gamma+beta;
sx = hisspeed * t * cos(rho);
sy = hisspeed * t * sin(rho);
}
tx=(float)hisx+(float)sx;
ty=(float)hisy+(float)sy;
tz=(float)hisz+(float)hisvz*t;
if (targ->getStatus() & PlayerState::Falling)
tz += 0.5f * BZDBCache::gravity * t * t;
if (tz < 0) tz = 0;
double distance2 = hypotf(tx - myx, ty - myy);
errdistance = fabs(distance2-distance) / (distance + ZERO_TOLERANCE);
distance = distance2;
}
float projpos[3];
projpos[0] = tx; projpos[1] = ty; projpos[2] = tz;
float heading = atan2f(projpos[1] - myy, projpos[0] - myx);
firingInfo.shot.vel[0] = cosf(heading) *
BZDB.eval(StateDatabase::BZDB_SHOTSPEED);
firingInfo.shot.vel[1] = sinf(heading) *
BZDB.eval(StateDatabase::BZDB_SHOTSPEED);
firingInfo.shot.vel[2] = sinf(atan2f(projpos[2]-myz,
hypotf(projpos[1]-myy,
projpos[0]-myx)))*BZDB.eval(StateDatabase::BZDB_SHOTSPEED);
firingInfo.shot.pos[0] = myx;
firingInfo.shot.pos[1] = myy;
firingInfo.shot.pos[2] = myz;
}

There you go.

-NightMare

Choose your tank size

Ok this is posted in a comment by "person" but "someone" is the one who came up with this cheat I just think it should be posted so more people can see it and don't have to go looking through comments to find it so here it is.

At top of src/bzflag/CommandsImplementation.cxx:

extern float sizeCheat;
class SizeCommand : LocalCommand {
public:
SizeCommand();
bool operator() (const char *commandLine);
};
static SizeCommand sizeCommand;
SizeCommand::SizeCommand() : LocalCommand("/size") {}
bool SizeCommand::operator() (const char *commandLine)
{
sizeCheat = atof(commandLine+6);
return true;
}

At top of src/bzflag/Player.cxx:

#include "LocalPlayer.h"
float sizeCheat = 1.0f;
Find:
else if (effectFlag == Flags::Narrow) {
dimensionsTarget[1] = 0.001f;
}

Add this after:

if (id == LocalPlayer::getMyTank()->getId())
{
dimensionsTarget[0] *= sizeCheat;
dimensionsTarget[1] *= sizeCheat;
}

And that should be it. Now just type /size .1 to /size 1. You must either be killed or pick up or drop a flag for the size to change. Sizes range from 0.0 (Can't be shot by a bullot) to 1.0 (Normal tank size). Sometimes just a /size .7 is nice to give yourself an "edge" =].

-NightMare

Teleport in FRONT of your opponent.

This is just like the /behind code down below where you teleport behind them, only with this code you will teleport in front of them. Kind of a dumb code but fun to mess with people.
Open src/bzflag/composeDefaultKey.cxx:
Find your /behind cheat that you have. It should Look like this:

else if(message=="/behind") {
const Player *Other = LocalPlayer::getMyTank()->getRecipient();
if(Other)
{
LocalPlayer::getMyTank()->setStatus(LocalPlayer::getMyTank()->getStatus() int(PlayerState::Teleporting));
const float* pos = Other->getPosition();
const float* dir = Other->getForward();
const float* vel = Other->getVelocity();
float newpos[3];
float newvel[3];
newpos[0] = pos[0] - 10 * dir[0];
newpos[1] = pos[1] - 10 * dir[1];
newpos[2] = pos[2] + 0.01;
newvel[0] = vel[0];
newvel[1] = vel[1];
newvel[2] = vel[2];
LocalPlayer::getMyTank()->move(newpos, Other->getAngle());
LocalPlayer::getMyTank()->setStatus(LocalPlayer::getMyTank()->getStatus() & ~int(PlayerState::Teleporting));
}
}

Then directly below that add this:

else if(message=="/front") {
const Player *Other = LocalPlayer::getMyTank()->getRecipient();
if(Other)
{
LocalPlayer::getMyTank()->setStatus(LocalPlayer::getMyTank()->getStatus() int(PlayerState::Teleporting));
const float* pos = Other->getPosition();
const float* dir = Other->getForward();
const float* vel = Other->getVelocity();
float newpos[3];
float newvel[3];
newpos[0] = pos[0] + 10 * dir[0];
newpos[1] = pos[1] + 10 * dir[1];
newpos[2] = pos[2] + 0.01;
newvel[0] = vel[0];
newvel[1] = vel[1];
newvel[2] = vel[2];
LocalPlayer::getMyTank()->move(newpos, TargetingUtils::getTargetAzimuth(newpos , pos ));
}
LocalPlayer::getMyTank()->setStatus(LocalPlayer::getMyTank()->getStatus() & ~int(PlayerState::Teleporting));
}

And that is all. Like I said, it is stupid but fun to mess with people when you teleport behind then in front back in forth. Credit for this goes to Phaz =].

-NightMare

Shot prediction.

This will draw a line on your radar to predict where your shots will go. Its almost exactly perfect. It doesn't work on all servers for some reason, but it should work on most. It is very helpful for 3 shot no jump servers. This code was found through a chat between mrmolez and someone else. So here it is for everyone else to see lol.

Open RadarRenderer.cxx
Find:

//draw world weapon shots

Add this right before it:

FiringInfo myInfo(*myTank, 0);
if (myInfo.flagType != Flags::ShockWave) {
if (!BZDB.isTrue(StateDatabase::BZDB_SHOTSKEEPVERTICALV))
myInfo.shot.vel[2] = 0.0f;
myInfo.flagType = Flags::Laser;
myInfo.lifetime /= 100;
const float cs = colorScale(myInfo.shot.pos[2], muzzleHeight);
glColor3f(1.0f * cs, 1.0f * cs, 1.0f * cs);
LocalShotPath myPath(myInfo);
myPath.radarRender();
}

Let me know how this works for you guys. If you don't like it just take it out lol.

-NightMare

Sunday, December 30, 2007

Choose Who Kills You

Ok this is a very very powerful cheat. With this cheat you send a PM to the player saying "/kill" and you will instantly be killed by that person. It is very useful and funny when you do it to teammates and they get booted for TKing or their score drops immedietly.
In src/bzflag/playing.cxx:
Add to top:

int killMe;

Find:

// used later
float waterLevel = World::getWorld()->getWaterLevel();

Add this after:

if (killMe)
{
gotBlowedUp(myTank,GotShot,killMe);
killMe = 0;
}

In src/bzflag/composeDefaultKey.cxx:
Add to top:

extern int killMe;

Find:

else if (message.length() > 0) {

Add this before that:

else if(message=="/kill") {
const Player *Other = LocalPlayer::getMyTank()->getRecipient();
if(Other)
{ killMe = Other->getId();
}
}

And that is it. Now type /kill in a messege to someone and you will be killed by them. Make sure you do NOT have god mode on when you try to do this otherwise it won't work. Also there is usually 1 random player everytime you log into a server that the code doesn't work against. But other than that one player it should work against everyone else. Let me know if this code works for you guys.

-NightMare