|
posted 09-04-98 10:47 PM CT (US)
Title: Detonateable Decoys
Difficulty: Moderate to Difficult
By: Philip (aka Maj.Bitch)
Email: peblair@gv.net // please report any bugs(??)
Date: 9-04-98
Note: Please give credit where credit is due.
=============================================================
This is a modification of the Decoy Tutorial originally posted
on QDevels by:John Rittenhouse with some modifications here and
there to add changes. Many thanks go out to him for his originality
and inspiration.
GREAT for placing at
tops (or bottoms) of elevators or ladders.
GREAT for 'lying in
wait' for others to pass by the decoy so you
can blow the bastards up!!
About this Mod:
What this
modification does is allow the player to hit an aliased
key (see below) and create an exact hologram (decoy) of themself.
The holo is view weap enabled and rotates around so as to give motion
to the decoy. The player can detonate the decoy at will (turning it
'off' causes immediate detonation with the associated explosions, etc)
and, by doing so, the holo's explosion will blast apart players
within a 100 unit damage radius. The Holo is also enabled with its
own proximity detonator which is automatically turned 'ON' in 3 seconds
of the holo's creation (thereby giving the holo's originator time to
GET THE HELL AWAY!!) and which detonates if a player comes in
proximity to the holo. Yes. The originator of the holo can be damaged
by either the proximity detonation of the holo or by being within damage
radius when the holo is 'turned off'. Also, if nothing happens in 20 secs
(ie, nobody comes by the holo or the originator doesn't detonate it) then
holo will self destruct!
Okay, let's get
started...
Note: Some of my
functions may have caps in them (which may
cause your compilers to 'not find the functions'. Please
make sure that the functions I have called below
match exactly your functions elsewhere. If mine do not match,
then change'em!!
=============================================================
================== EDICT_S STRUCT MODIFICATIONS =============
=============================================================
Put this declaration
at the bottom of edict_s structure.
edict_t *decoy; //
For Holo-Decoy Edict
=============================================================
================== Q_CMDS.C MODIFICATIONS ===================
=============================================================
At the top of q_cmds.c put the following forward declaration:
void
SP_Decoy(edict_t *self);
=========
At the bottom of ClientCommands in Q_Cmds.c put the following:
else if
(Q_stricmp(cmd, "decoy") == 0 )
SP_Decoy(ent);
=============================================================
============== NEW FILE P_DECOY.C MODIFICATIONS =============
=============================================================
Create a new file
called p_decoy.c and paste in the following:
Be sure that your
#include files are correct!!
#include
"xxxxx.h"
#include "xxxxx.h"
//========= EXTERNAL
FUNCTIONS NEEDED ==================
qboolean visible(edict_t *self, edict_t *other);
void player_die(edict_t *victim, edict_t *weapon, edict_t *shooter, int
damage, vec3_t point);
//========= EXTERNAL FUNCTIONS NEEDED ==================
//======================================================
void Decoy_Die(edict_t *ent, edict_t *weapon, edict_t *shooter, int damage,
vec3_t point) {
vec3_t origin={0,0,0};
VectorMA(ent->s.origin,
-.02, ent->velocity, origin);
gi.WriteByte(svc_temp_entity);
gi.WriteByte(TE_GRENADE_EXPLOSION);
gi.WritePosition(ent->s.origin);
gi.multicast(ent->s.origin, MULTICAST_PVS);
ent->takedamage =
DAMAGE_NO;
gi.WriteByte(svc_temp_entity);
gi.WriteByte(TE_BFG_EXPLOSION);
gi.WritePosition(ent->s.origin);
gi.multicast(ent->s.origin, MULTICAST_PVS);
G_FreeEdict(ent);
KillBox(ent);
free(ent);
}
//======================================================
void Decoy_Explode(edict_t *ent) {
vec3_t origin={0,0,0};
T_RadiusDamage(ent,
ent->owner, ent->dmg, NULL, ent->dmg_radius,0);
Decoy_Die(ent, NULL,
NULL, 0, origin);
}
//======================================================
void Decoy_Think(edict_t *ent) {
edict_t *blip=NULL;
if (level.time >
ent->delay) {
Decoy_Explode(ent);
return; }
while ((blip =
G_Findradius(blip, ent->s.origin, 100)) != NULL) {
if ((!blip->client) || (blip->health <= 0)) continue;
if (!blip->takedamage) continue;
if (!CanDamage(blip, ent)) continue;
if (!visible(ent, blip)) continue;
if (ent->delay-level.time < 17)
Decoy_Explode(ent);
} // end while
ent->nextthink =
level.time + 0.1;
}
//======================================================
#define newDecoy self->decoy
//======================================================
void SP_Decoy(edict_t *self) {
vec3_t origin={0,0,0};
if (newDecoy) {
Decoy_Explode(newDecoy);
newDecoy = NULL;
gi.centerprintf(self,"Decoy off!\n");
return; }
newDecoy =
G_Spawn();
newDecoy->classname="decoy";
newDecoy->takedamage=DAMAGE_AIM;
newDecoy->movetype= MOVETYPE_TOSS;
newDecoy->solid = SOLID_BBOX;
newDecoy->deadflag =DEAD_NO;
newDecoy->clipmask = MASK_PLAYERSOLID;
newDecoy->model = self->model;
newDecoy->s.modelindex = self->s.modelindex;
newDecoy->s.modelindex2 = self->s.modelindex2;
newDecoy->s.frame =0;
// special effects
newDecoy->s.effects |= EF_ROTATE;
newDecoy->s.renderfx |= RF_TRANSLUCENT;
// some additional
s.effects combinations
//newDecoy->s.effects |= EF_QUAD + EF_PENT;
//newDecoy->s.effects |= EF_COLOR_SHELL;
// some renderfx
combinations you can try for yourself
// newDecoy->s.renderfx |= RF_SHELL_RED|RF_SHELL_GREEN|RF_SHELL_BLUE;
// newDecoy->s.renderfx |= RF_TRANSLUCENT;
newDecoy->mass =
200;
newDecoy->health= 20;
newDecoy->max_health =20;
newDecoy->think = Decoy_Think;
newDecoy->nextthink =level.time + 0.1;
newDecoy->delay = level.time + 20;
newDecoy->die = Decoy_Die;
newDecoy->owner = self;
newDecoy->dmg = 100;
newDecoy->dmg_radius = 100;
VectorCopy(self->s.origin,newDecoy->s.origin);
VectorSet(newDecoy->mins, -16, -16, -24);
VectorSet(newDecoy->maxs, 16, 16, 32);
VectorClear(newDecoy->velocity);
gi.linkentity(newDecoy);
gi.centerprintf(self,"Decoy
in Place!\n");
}
============================================================
================= AUTOEXEC.CFG STUFF =======================
============================================================
Inside of your autoexec.cfg file be sure to include this:
Bind a key to the
following as in the example below:
bind F2
"decoy" // Rocket Bombs
================
Have fun and kill
all those bastards!!
regards,
Philip
aka Maj.Bitch
|