Here I will show you how to create a simple Flare which will burn for a varible length of time.
I have decided to use 15 seconds though you may wish to change it making it londer or shorter
in duration. There is no limit as to how many flares you can have. Also the flare uses one
Rocket. First you'll need a flare model. In this case I have knocked up a quick flare in Qme 3,
download the zip file flare.zip and place flare.mdl in
the progs folder of this mod.
Ok now the most simple step, open up Weapons.qc and find W_Precache function then at the bottom
paste the following precache:
Still Weapons.qc, scroll to the ImpulseCommands function. And above that we will add the following code:
Spawns a Flare lasting 15 seconds
void() Create_Flare =
local entity flare;
self.currentammo = self.ammo_rockets = self.ammo_rockets - 1; //Uses one rocket
flare = spawn ();
flare.owner = self;
flare.effects = flare.effects | EF_BRIGHTLIGHT;
flare.movetype = MOVETYPE_NONE;
flare.solid = SOLID_NOT;
flare.touch = SUB_Null;
flare.classname = "flare";
flare.think = SUB_Remove;
flare.nextthink = time + 15; //Duration of Effect. Change as suits.
setmodel (flare, "progs/flare.mdl");
setsize (flare, VEC_ORIGIN, VEC_ORIGIN);
setorigin (flare, self.origin);
flare.origin = flare.origin - '0 0 4';
Now in the function ImpulseCommands well create an impulse for the use of our Flare. Above the QuadCheat impulse add:
if (self.impulse == 16)
if (self.ammo_rockets < 1) return;
The above impulse first checks if the player has at least a rocket if the player does it creates the flare.
Save and compile. Now that was pretty simple wasn't it? The flare uses the EF_BRIGHTLIGHT effect lasting for 15 seconds.
There are several things that you can change within this tutorial:
* Cost of the Flare. You can change ammo type or completely remove the cost.
* Duration. Currently 15 seconds, can be more or less as suits you.
* Effect used. EF_BRIGHTLIGHT can be changed to EF_MUZZLEFLASH or EF_DIMLIGHT.
Anyway have fun and happy gaming...