Author: John Rittenhouse
Flares
Add this function to a file (maybe p_weapon.c ?) :
Flashlight #1
Flashlight #2
This site, and all content and graphics displayed on it,
Difficulty: Easy
That will allow you to shoot a flare. I will let you put that in however you want since different people do that different ways.
You could put it in as a simple command ("cmd flare") or you could add a whole new weapon,
the flare-launcher maybe, with a new weapon model, sound effect, etc.
By the way the flares kinda remind me of the light sticks since it is glowing green.
void fire_flare (edict_t *self, vec3_t start, vec3_t aimdir, int damage, int speed, float timer, float damage_radius)
{
edict_t *grenade;
vec3_t dir;
vec3_t forward, right, up;
vectoangles (aimdir, dir);
AngleVectors (dir, forward, right, up);
grenade = G_Spawn();
VectorCopy (start, grenade->s.origin);
VectorScale (aimdir, speed, grenade->velocity);
VectorMA (grenade->velocity, 200 + crandom() * 10.0, up, grenade->velocity);
VectorMA (grenade->velocity, crandom() * 10.0, right, grenade->velocity);
VectorSet (grenade->avelocity, 300, 300, 300);
grenade->movetype = MOVETYPE_BOUNCE;
grenade->clipmask = MASK_SHOT;
grenade->solid = SOLID_BBOX;
grenade->s.effects |= EF_BLASTER;
grenade->s.renderfx |= RF_SHELL_GREEN;
VectorClear (grenade->mins);
VectorClear (grenade->maxs);
grenade->s.modelindex = gi.modelindex ("models/objects/grenade/tris.md2");
grenade->owner = self;
grenade->touch = Grenade_Touch;
grenade->nextthink = level.time + timer + 35;
grenade->think = Grenade_Explode;
grenade->dmg = damage;
grenade->dmg_radius = damage_radius;
grenade->classname = "grenade";
// CCH: a few more attributes to let the grenade 'die'
VectorSet(grenade->mins, -3, -3, 0);
VectorSet(grenade->maxs, 3, 3, 6);
grenade->mass = 2;
grenade->health = 10;
grenade->die = Grenade_Die;
grenade->takedamage = DAMAGE_YES;
grenade->monsterinfo.aiflags = AI_NOSTEP;
gi.linkentity (grenade);
}
Now add above Client_Command this code. This code moves the flashlight to the same pos as the player.
else if(Q_stricmp (cmd, "flashlight") == 0 && !(deathmatch->value))
{
if (FLASHLIGHT)
{
ent->flashlight->think = G_FreeEdict;
FLASHLIGHT = 0;
}
else
{
ent->flashlight = G_Spawn();
ent->flashlight->think = FlashLightMove;
ent->flashlight->nextthink = level.time +0.1;
ent->flashlight->s.effects = EF_BLASTER;
ent->flashlight->s.modelindex = 1;
ent->flashlight->solid = SOLID_NOT;
ent->flashlight->owner = ent;
ent->flashlight->movetype =MOVETYPE_NOCLIP;
ent->flashlight->clipmask = MASK_SHOT;
gi.linkentity(ent->flashlight);
VectorCopy (ent->s.origin,ent->flashlight->s.origin);
FLASHLIGHT = 1;
}
}
Now add into G_Local.h at the bottom this into the edict_s definition.
void FlashLightMove(edict_t *ent)
{
VectorCopy(ent->owner->s.origin,ent->s.origin);
ent->nextthink = level.time +0.1;
}
This flashlight is a little buggy, so here's an alternative flashlight
for you :
edict_t *flashlight;
Okay now add in this command here to "g_cmds.c
// edict->flags
#define FL_FLY 0x00000001
#define FL_SWIM 0x00000002 // implied immunity to drowining
#define FL_IMMUNE_LASER 0x00000004
#define FL_INWATER 0x00000008
#define FL_GODMODE 0x00000010
#define FL_NOTARGET 0x00000020
#define FL_IMMUNE_SLIME 0x00000040
#define FL_IMMUNE_LAVA 0x00000080
#define FL_PARTIALGROUND 0x00000100 // not all corners are valid
#define FL_WATERJUMP 0x00000200 // player jumping out of water
#define FL_TEAMSLAVE 0x00000400 // not the first on the team
#define FL_NO_KNOCKBACK 0x00000800
#define FL_POWER_ARMOR 0x00001000 // power armor (if any) is active
#define FL_RESPAWN 0x80000000 // used for item respawning
#define FL_BOOTS 0x00010000 //Anti-Gravity boots flag
#define FL_GRAPPLING 0x00002000 //used for grappling hook JR 1/19/98
#define FL_OBJECT 0x00004000
#define FL_SATELLITE 0x00008000 //USed for the satellite JR 3/17/98
#define FL_PARAL 0x00020000 //used fo paralyzation
#define FL_FLASHLIGHT 0x00040000
Now we need to add the thing that lights us up so we goto the file "p_view.c". Now goto the end of the command "G_SetClientEffects" and add this code
else if(Q_stricmp (cmd, "flashlight") == 0 && !(deathmatch->value))
{
if (ent->flags & FL_FLASHLIGHT)
{
ent->flags &= ~FL_FLASHLIGHT;
FLASHLIGHT = 0;
}
else
{
ent->flags |= FL_FLASHLIGHT;
FLASHLIGHT = 1;
}
}
THat should work so whenever you use the command "cmd flashlight"
Hope you like this SumFuka! [Yep, I love it ! - Sum].
if (ent->flags & FL_FLASHLIGHT)
{
ent->s.effects |= EF_FLAG1|EF_FLAG2;
}
are ©opyrighted to the
Quake DeveLS
team. All rights received.
Got a suggestion? Comment? Question? Hate mail?
Send it
to us!
Oh yeah, this site is best viewed in 16 Bit or higher, with the resolution on
800*600.
Thanks to
Planet Quake for their great help and support with hosting.
Best viewed with Netscape
4