Created 14 years ago2010-10-02 07:18:19 UTC by Un_Nem
cl_entity_t *ent;
dlight_t *dl;
ent = cl_entities + cl.playernum + 1;
if ( ent->curstate.effects & (EF_BRIGHTLIGHT|EF_DIMLIGHT) && cl.worldmodel )
{
if ( cl.pLight && cl.pLight->key == 1 )
dl = cl.pLight;
else
dl = efx.CL_AllocDlight (1);
if ( ent->curstate.effects & EF_BRIGHTLIGHT )
{
dl->color.r = dl->color.g = dl->color.b = 250;
dl->radius = 400;
VectorCopy (ent->origin, dl->origin);
dl->origin[2] += 16;
}
else
{
pmtrace_t trace;
vec3_t end;
float falloff;
VectorCopy (ent->origin, dl->origin);
VectorAdd( dl->origin, cl.viewheight, dl->origin );
VectorMA( dl->origin, FLASHLIGHT_DISTANCE, vpn, end );
// Trace a line outward, use studio box to avoid expensive studio hull calcs
pmove->usehull = 2;
trace = PM_PlayerTrace( dl->origin, end, PM_STUDIO_BOX, -1 );
if ( trace.ent > 0 )
{
// If we hit a studio model, light it at it's origin so it lights properly (no falloff)
if ( pmove->physents[ trace.ent].studiomodel )
{
VectorCopy( pmove->physents[trace.ent ].origin, trace.endpos );
}
}
VectorCopy( trace.endpos, dl->origin );
falloff = trace.fraction*FLASHLIGHT_DISTANCE;
if ( falloff < 500 )
falloff = 1.0;
else
falloff = 500.0 / (falloff);
falloff *= falloff;
dl->radius = 80;
dl->color.r = dl->color.g = dl->color.b = 255 * falloff;
#if 0
dlight_t *halo;
halo = efx.CL_AllocDlight( 2 );
halo->color.r = halo->color.g = halo->color.b = 60;
halo->radius = 200;
VectorCopy (ent->origin, halo->origin);
halo->origin[2] += 16;
halo->die = cl.time + 0.2;
#endif
}
cl.pLight = dl;
dl->die = cl.time + 0.2;
CL_TouchLight( dl );
}
else
{
if ( cl.pLight && cl.pLight->key == 1 )
cl.pLight->die = cl.time;
cl.pLight = NULL;
}
} [/quote]