BodySwap


 

Posted by SKREAMZ (195.147.209.*) at 1:10 PM, 8/17/2001:

Title: BodySwap
Difficulty: Easy
By: SKREAMZ
Note: Please give credit where credit is due.
======================================================

NEWCODE
OLDCODE
COMMENTS
TUT

first we open g_cmds.c look for this code and add the new


else if (Q_stricmp(cmd, "playerlist") == 0)
Cmd_PlayerList_f(ent);
//new code start
else if (Q_stricmp(cmd, "bodyswap") == 0)
GetVictim(ent);
//new code end
else // anything that doesn't match a command will be a chat
Cmd_Say_f (ent, false, true);

now close that file and make a new file called bodyswap.c and add this


#include "g_local.h"


void BodySwap(edict_t *self, edict_t *other)
{
vec3_t origin;
vec3_t angles;
int inventory[MAX_ITEMS];
int i;
int health;

VectorCopy(other->s.origin, origin);
VectorCopy(other->s.angles, angles);

VectorCopy(self->s.origin, other->s.origin);
VectorCopy(self->s.angles, other->s.angles);

VectorCopy(origin, self->s.origin);
VectorCopy(angles, self->s.angles);

for(i = 0; i < MAX_ITEMS; i++)
inventory[i] = self->client->pers.inventory[i];

for(i = 0; i < MAX_ITEMS; i++)
self->client->pers.inventory[i] = other->client->pers.inventory[i];

for(i = 0; i < MAX_ITEMS; i++)
other->client->pers.inventory[i] = inventory[i];

health = self->health;
self->health = other->health;
other->health = health;

if(self->health <= 50)
player_die(self, self, self, 100, self->s.origin);
else if(other->health > self->health - 50)
self->health -= 50;

}


void GetVictim(edict_t *ent)
{
edict_t *other = NULL;

while((other = findradius(other, ent->s.origin, 3000)) != NULL)
{
if(!(other->svflags & SVF_MONSTER) && !other->client)
continue;

if(other == ent->owner)
continue;

if(other == ent)
continue;

if(!other->takedamage)
continue;

if(other->health <= 0)
continue;

if(!visible(ent, other))
continue;

if(!infront(ent, other))
continue;

BodySwap(ent, other);
}
}


ive not tested this yet as to some problems to my compiler :-(




Replies:             (Local time is: 10:56:38 AM, 4/23/2004)

Tutorial: BodySwap - SKREAMZ at 1:10 PM, 8/17/2001 (1 reply)


Post A Reply

Name

E-Mail

Subject

 

Message

 

Preview Message

 

 

Optional Link URL

Link Title

Optional Image URL


[ Replies | Post Reply | QDeveLS - Quake2 Message Board ]

accessed 91 times
309755 messages displayed