names are in RED
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:
EV_HLDM_MuzzleFlash( vec3_t pos, float amount
Then open ev_hldm.cpp ,
this is where we will make the function body, above:
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 play
float EV_HLDM_PlayTextureSound( int
idx, pmtrace_t *ptr, float *vecSrc, float
*vecEnd, int iBulletType )
void EV_HLDM_MuzzleFlash(vec3_t pos, float
??????dlight_t *dl = gEngfuncs.pEfxAPI->CL_AllocDlight(0);
??????dl->origin = pos;
??????dl->color.r = 255; // red
??????dl->color.g = 255; // green
??????dl->color.b = 128; // blue
??????dl->radius = amount * 100;
??????dl->die = gEngfuncs.GetClientTime() +
// mazor end
Now find the function:
void EV_FireGlock1( event_args_t *args )
Find in the function
where it says:
vecSrc, origin );
Right after that
line add this:
EV_HLDM_MuzzleFlash( vecSrc, 1.0 + gEngfuncs.pfnRandomFloat( -0.2, 0.2 ) );
// mazor end
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.
Any questions or
comments email me: email@example.com (Link: mazor579-at-hotmail.com)