I'm using the code from here:
c_baseanimating.cpp
- Code: Select all
void C_BaseAnimating::ProcessMuzzleFlashEvent()
{
// If we have an attachment, then stick a light on it.
if ( muzzleflash_light.GetBool() )
{
//FIXME: We should really use a named attachment for this
if ( m_Attachments.Count() > 0 )
{ /* Original Muzzle-flash light code
//Start muzzleflash mod code
Vector vAttachment, vAng;
QAngle angles;
GetAttachment( 1, vAttachment, angles ); // set 1 instead "attachment"
AngleVectors( angles, &vAng );
vAttachment += vAng * 2;
dlight_t *dl = effects->CL_AllocDlight ( index );
dl->origin = vAttachment;
dl->color.r = 255;
dl->color.g = 192;
dl->color.b = 64;
dl->color.exponent = 7.5;
dl->die = gpGlobals->curtime + 0.03f;
dl->radius = random->RandomFloat( 64.0f, 96.0f );
//End muzzleflash mod code
}
}
}
The issues shown in the video are as follows:
-First part of the video: This is how it's supposed to look. The muzzleflash lighting lasts but a brief moment with each shot, both on the NPC and on the environment. It looks correct on two conditions: either there's no "dl->color.exponent" in the code (though it's hardly bright enough) or the NPC is under the influence of 4 light_spot entities or more.
-Second part of the video: This is how it's NOT supposed to look. The problem is that the light affecting the NPC lasts too long. It should be just short flashes. It happens when I use "dl->color.exponent" in there or the NPC is affected by 3 light_spot entities or less.
-Third part of the video: Is there any way to block the dynamic light from going through walls? Clipping it somehow?
Thank you.


