Friday, July 27, 2007

View Radar on Maps without Radar

By: Phasmophage (aka "Phaz")

Here's a sweet little number that you won't want to pass up... How would you like radar on those maps without radar? Now you can have an advantage over with tanks by having access to your radar on maps that don't allow it! As Phaz tells us:

"On maps with no radar, the radar limit is set to 0 or a negative number. This will fix it to the correct number, the size of the world. So now no more hide and seek!"

For this, we visit RadarRenderer.cxx in /src/bzflag/ of the extracted source. Start by searching for "void RadarRenderer::render(SceneRenderer&" and you will come to this section:

void RadarRenderer::render(SceneRenderer& renderer, bool blank, bool observer)
{
RenderNode::resetTriangleCount();

const float radarLimit = BZDBCache::radarLimit;
if (!BZDB.isTrue("displayRadar") || (radarLimit <= 0.0f)) {
triangleCount = 0;
return;

First, look at this line from above:

const float radarLimit = BZDBCache::radarLimit;

Change that line to this:

float test = BZDBCache::radarLimit;

Below that, you will see this line:

if (!BZDB.isTrue("displayRadar") || (radarLimit <= 0.0f)) {

Change that line to this:

if(test<=0.0) {

Next, you will see this line:

triangleCount = 0;

Change that line to this:

test = BZDB.eval(StateDatabase::BZDB_WORLDSIZE);

The next line you see is this:

return;

Change it to this (all one, single line):

BZDB.setFloat(StateDatabase::BZDB_RADARLIMIT, BZDB.eval(StateDatabase::BZDB_WORLDSIZE));

On the next line, you will see this:

}

Directly below the "}" (vertically aligned), add this line:

const float radarLimit = test;

So that the two lines together look like this:

}
const float radarLimit = test;

The entire edit should like this:

void RadarRenderer::render(SceneRenderer& renderer, bool blank, bool observer)
{
RenderNode::resetTriangleCount();

float test = BZDBCache::radarLimit;
if(test<=0.0) {
test = BZDB.eval(StateDatabase::BZDB_WORLDSIZE);
BZDB.setFloat(StateDatabase::BZDB_RADARLIMIT, BZDB.eval(StateDatabase::BZDB_WORLDSIZE));
}
const float radarLimit = test;
// render the frame

Save the file, compile your client, and you're done. To view Phasmophage's original instructions, read his comment to "HOWTO: See Invisible Bullets and Actual Colors on Radar" at the blog Cheating BZFlag.

As always...

Have fun!

No comments: