Quake DeveLS - Flares

Author: John Rittenhouse
Difficulty: Easy


Flares are quite simple for me to code since they are already in my mod Star Troopers. They are best used with the lights out !

Add this function to a file (maybe p_weapon.c ?) :

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);
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.

Flashlight #1

Now for the flashlight I wish id added in the cone value they talk about in their source code but I checked for it and it isn't there so I guess they haven't added it in yet(It should be in for Duke Nukem Forever since they have a flashlight in there). Now I will show you how to do the flashlight. Add at the top of g_cmds.c add this "int FLASHLIGHT = 0". Then add this code into Client_Command at the correct place.

        else if(Q_stricmp (cmd, "flashlight") == 0 && !(deathmatch->value))
                if (FLASHLIGHT)
                        ent->flashlight->think = G_FreeEdict;
                        FLASHLIGHT = 0;
                        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;
                        VectorCopy (ent->s.origin,ent->flashlight->s.origin);
                        FLASHLIGHT = 1;
Now add above Client_Command this code. This code moves the flashlight to the same pos as the player.
void FlashLightMove(edict_t *ent)
        ent->nextthink = level.time +0.1;
Now add into G_Local.h at the bottom this into the edict_s definition.
        edict_t *flashlight;
This flashlight is a little buggy, so here's an alternative flashlight for you :

Flashlight #2

Guess what I got the flashlight to work correctly shortly after I got CTF into mod to work(YEAH!!!!). SO here it is. First we need to add a flag to tell when its on or off in "g_local.h" my flags look like this and you can see the last flag is the flashlight flag the one you will add in.

// 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
Okay now add in this command here to "g_cmds.c
        else if(Q_stricmp (cmd, "flashlight") == 0 && !(deathmatch->value))
                if (ent->flags & FL_FLASHLIGHT)
                        ent->flags &= ~FL_FLASHLIGHT;
                        FLASHLIGHT = 0;
                        ent->flags |= FL_FLASHLIGHT;
                        FLASHLIGHT = 1;
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
        if (ent->flags & FL_FLASHLIGHT)
                ent->s.effects |= EF_FLAG1|EF_FLAG2;
THat should work so whenever you use the command "cmd flashlight" Hope you like this SumFuka! [Yep, I love it ! - Sum].

John Rittenhouse .

This site, and all content and graphics displayed on it,
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