VERC: Adding muzzle flashes that also light up world brushes Last edited 16 years ago2002-09-26 13:01:00 UTC by Penguinboy Penguinboy

This article was recovered from an archive and needs to be reviewed

  1. The formatting may be incorrect as it was automatically converted to WikiCode from HTML, it needs to be revised and reformatted
  2. Some information may be out of date as it was written before Half-Life was available on Steam
  3. After the article is re-formatted and updated for Steam HL, remove this notice
  4. Please do not remove the archive notice from the bottom of the article.
  5. Some archive articles are no longer useful, or they duplicate information from other tutorials and entity guides. In this case, delete the page after merging any relevant information into other pages. Contact an admin to delete a page.
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 play

float EV_HLDM_PlayTextureSound( int
idx, pmtrace_t *ptr, float *vecSrc, float
*vecEnd, int iBulletType )

Add this:

// mazor
begin

void EV_HLDM_MuzzleFlash(vec3_t pos, float
amount)

{

??????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() +
0.01;

}

// mazor end

Now find the function:

void EV_FireGlock1( event_args_t *args )
Find in the function
where it says:

EV_GetGunPosition( args,
vecSrc, origin );

Right after that
line add this:

// mazor
begin

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: mazor579@hotmail.com (Link: mazor579-at-hotmail.com)
This article was originally published on the Valve Editing Resource Collective (VERC).
TWHL only archives articles from defunct websites. For more information on TWHL's archiving efforts, please visit the TWHL Archiving Project page.

Comments

You must log in to post a comment. You can login or register a new account.