Showing posts with label kill me. Show all posts
Showing posts with label kill me. Show all posts

Tuesday, January 1, 2008

Super "Kill Me" on Demand

By: Lord Jesus

Got an annoying teammate that needs to be kicked (if the server kicks for team kills)? Perhaps that annoying teammate simply needs calibration with a point reduction... Or, how would you like to be able to hook up your buddies with some mad points?

Here's a modification to Choose Who Kills You brought to you by a collaboration between blogger,Someone, and BZFlag Cheat's newest team member, NightMare.

With "Choose Who Kills You", you enter in your command to be killed by another player on demand (e.g., "/k"). The getting killed ends after you blow up and the point is transferred. Let's say, though, that you would like to do it over and over again without having to enter the command manually each and every time. One way might be to set up a macro such as ctrl+k to enter "." + /k + [Enter] to facilitate rapid keystroke entries. Another way might be to set up a key command and select victims similar to the way in which one uses "k" to silence or "unsilence" other players. There are a variety of ways which are possible. After all, there are usually more than one way to skin a cat, as the old saying goes.

The technique that we will use here is to set up a command for it. A separate command is used to terminate the automatic suicide, as it were. Additionally, this particular method works separately from killMe, so you can use either one without conflict. The example that we use here will show lines of code for both. The single killMe is optional, of course, but highly recommended :)

Before we begin, let's review some limitations. This method described here (as well as single killMe) will NOT work if you:
    1. have god mode enabled. This is highly important. If you can toggle god mode, ensure that it is toggled off. Otherwise, you will need to build without the god mode cheat or nothing will happen when you try to use the Super killMe (or single killMe, for that matter). UPDATE: See Using God Mode with Choose Who Kills You if you want to use (or would like to continue to use) god mode.

    2. are an observer. Note, though, that you can choose to be killed by an observer. You just can't be killed while YOU are an observer.

    3. have not yet spawned (e.g., when you first join a server).

    4. are dead. For the automatic Super killMe, I strongly recommend that you utilize Respawn Instantly.

Additionally, I have noticed that commonly at least one player on a server is not affected by either killMe or Super killMe. So, if you go to try it out and it doesn't work on the first victim, try some others just to be sure. Also, if a victim leaves the server during the automatic Super killMe (e.g., getting kicked for team killing, just simply leaving, and so on), then the killed message will reflect that you have been killed by the server. This occurs when you are killed by an unknown player (a player who has signed off is a player that no longer exists).

playing.cxx

Let's begin now by going back to playing.cxx. Do you remember where we added "int killMe"? Let's add another one so that the section looks like this (from the beginning of the file):

/* bzflag
* Copyright (c) 1993 - 2006 Tim Riker
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the license found in the file
* named COPYING that should have accompanied this file.
*
* THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/

// interface header
#include "playing.h"

// system includes
#ifdef _WIN32
#include
#include
#include
#include
#else
#include
#include
#include
#include
#include
#endif
#include
int killMe;
int SuperkillMe;

Next, search for "used later", and you will find this section:

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

if (hit) {
// i got shot! terminate the shot that hit me and blow up.

Look at the second line:

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

Below that, let's add our lines of code:

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

if (SuperkillMe)
{
gotBlowedUp(myTank,GotShot,SuperkillMe);
}

Look at the line below the addition above:

if (message.length() > 0) {

Add "else" at teh beginning of the line so that it now reads like this:

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

The edited section should now look like this:

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

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

if (SuperkillMe)
{
gotBlowedUp(myTank,GotShot,SuperkillMe);
}
else if (message.length() > 0) {

if (hit) {
// i got shot! terminate the shot that hit me and blow up.

Notice that in the killMe section you see "killMe=0" but SuperkillMe does not have a corresponding line. The line resets killMe so that the process of getting blown up doesn't keep going and going. This allows you to have single use killMe. Since we want the automatic killMe (i.e., SuperkillMe) to keep going, there is no line resetting that value back to 0.

UPDATE: As mentioned previously, this cheat would continue the SuperkillMe even after the player signs off or gets kicked. Thus, the killer is then unknown and the killed message is "Killed by the server", and you would have to use your command to end it (such as /ks) to stop the SuperkillMe. Here's a simple fix to end the SuperkillMe automatically when the player no longer on the server.

Let's continue with playing.cxx and search for "Killed by the server". You will will find this section:

} else {
// 1-4 are messages sent when the player dies because of someone else
if (reason >= GotShot && reason <= GenocideEffect) {
Player *killerPlayer = lookupPlayer(killer);
if (!killerPlayer) {
blowedUpNotice = "Killed by the server";
} else {

Notice this line: blowedUpNotice = "Killed by the server";

After that line, add this line:

SuperkillMe = 0;

The section should now look like this:

} else {
// 1-4 are messages sent when the player dies because of someone else
if (reason >= GotShot && reason <= GenocideEffect) {
Player *killerPlayer = lookupPlayer(killer);
if (!killerPlayer) {
blowedUpNotice = "Killed by the server";
SuperkillMe = 0;
} else {

At this point, we are finished with editing playing.cxx.

ComposeDefaultKey.cxx

Next, let's go to setting up the actual commands. For this we go to ComposeDefaultKey.cxx. Do you recall where we put "extern int killMe;"? Search for "MAX_MESSAGE_HISTORY (20)", and you will come to this section:

#define MAX_MESSAGE_HISTORY (20)

MessageQueue messageHistory;
unsigned int messageHistoryIndex = 0;


static bool isWordCompletion(const BzfKeyEvent& key)

Notice the line "unsigned int messageHistoryIndex = 0;". Below that, we will add our lines of code:

extern int killMe;
extern int SuperkillMe;

The edited section should look like this:

#define MAX_MESSAGE_HISTORY (20)

MessageQueue messageHistory;
unsigned int messageHistoryIndex = 0;
extern int killMe;
extern int SuperkillMe;

static bool isWordCompletion(const BzfKeyEvent& key)

Next, let's set up our commands. Here, we use "/k" for a single killMe, and we use "/kk" for SuperkillMe. Keep in mind that you are free to use any command that you desire. For example, if you prefer /killme over /k, then edit that line accordingly. Search for "if (sendIt) {", and you will see this section:

if (sendIt) {
std::string message = hud->getComposeString();
if (message.length() > 0) {
const char* cmd = message.c_str();
if (LocalCommand::execute(cmd)) {
;
} else if (serverLink) {

Notice the line "std::string message = hud->getComposeString();". Below that, we will add our lines of code:

if(message=="/kk") {
const Player *someOther = LocalPlayer::getMyTank()->getRecipient();
if (someOther)
{
SuperkillMe = someOther->getId();
}
}

else if(message=="/ks") {
SuperkillMe = 0;
}

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

The next line after our addition is "if (message.length() > 0) {". Let's add "else" in front of that so that the line now reads like this:

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

The section after our change should now read like this:

if (sendIt) {
std::string message = hud->getComposeString();

if(message=="/kk") {
const Player *someOther = LocalPlayer::getMyTank()->getRecipient();
if (someOther)
{
SuperkillMe = someOther->getId();
}
}

else if(message=="/ks") {
SuperkillMe = 0;
}

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

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

In the example above, we used "/ks" as the command to terminate the automatic getting killed on demand, or SuperkillMe. When we enter the command "/ks", SuperkillMe is set to 0, and automatic getting killed is over until we initiate it again.

After you make your changes, save your files, compile your new client, and you're done. Watching dead or paused players rack up points or team kills can be quite amusing... as well as observers going on killing sprees :P

In the immortal words of dj28:

"Have fun pissing people off and ruining their fun."

>:)

**********

Related posts:

Choose Who Kills You
Using God Mode with Choose Who Kills You