Onliners

Affiliates

Adding muzzle flashes that also light up world brushes

By Cale 'Mazor' Dunlap

Untitled Document

Function
names are in RED

File
names are in ORANGE

We all know that
guns produce a flash of light when shot (well, not all, but most). Half-Life
already has a system similar to this implemented, but it only lights entities.
This will show you how to light the world. Now the beauty of the system I have,
is that you don't take up any more network traffic for the lighting. Its all
done via the weapon's fire event.

First open ev_hldm.h,
then at the bottom add:

void
EV_HLDM_MuzzleFlash( vec3_t pos, float amount
);

Then open ev_hldm.cpp,
this is where we will make the function body, above:

// play
a strike sound based on the texture that was hit by the attack traceline.
VecSrc/VecEnd are the
// original traceline endpoints used by the attacker, iBulletType is the type
of bullet that hit the texture.
// returns volume of strike instrument (crowbar) to playfloat EV_HLDM_PlayTextureSound( int
idx, pmtrace_t *ptr, float *vecSrc, float
*vecEnd, int iBulletType )

Now that creates
a call to the muzzle flash function with the proper location, and a varying
flash intensity of ~1.0, which when it gets into the function, it is multiplied
by 100, so the flash radius is anywhere between 80 and 120 after calculation.
This creates a good varying effect because not every muzzle flash always has
the same radius and intensity. You can alter the color as much as you like.
Good intensities for small weapons (pistols, smg's, etc) is anywhere between
0.8 - 2.0. Which makes the radius somewhere beteween 80 and 200. Larger weapons,
like machineguns would have a number from 2.5 - 4.0. That makes the flashes
250-400 units wide, definately enough to light up a room. I used a very similar
system in Firearms to create the muzzle flash lighting.