📄 cl_ents.c
字号:
if (effects & EF_FLAG1)
V_AddLight (ent.origin, 225, 1.0, 0.1, 0.1);
else if (effects & EF_FLAG2)
V_AddLight (ent.origin, 225, 0.1, 0.1, 1.0);
else if (effects & EF_TAGTRAIL) //PGM
V_AddLight (ent.origin, 225, 1.0, 1.0, 0.0); //PGM
else if (effects & EF_TRACKERTRAIL) //PGM
V_AddLight (ent.origin, 225, -1.0, -1.0, -1.0); //PGM
continue;
}
// if set to invisible, skip
if (!s1->modelindex)
continue;
if (effects & EF_BFG)
{
ent.flags |= RF_TRANSLUCENT;
ent.alpha = 0.30;
}
// RAFAEL
if (effects & EF_PLASMA)
{
ent.flags |= RF_TRANSLUCENT;
ent.alpha = 0.6;
}
if (effects & EF_SPHERETRANS)
{
ent.flags |= RF_TRANSLUCENT;
// PMM - *sigh* yet more EF overloading
if (effects & EF_TRACKERTRAIL)
ent.alpha = 0.6;
else
ent.alpha = 0.3;
}
//pmm
// add to refresh list
V_AddEntity (&ent);
// color shells generate a seperate entity for the main model
if (effects & EF_COLOR_SHELL)
{
// PMM - at this point, all of the shells have been handled
// if we're in the rogue pack, set up the custom mixing, otherwise just
// keep going
// if(Developer_searchpath(2) == 2)
// {
// all of the solo colors are fine. we need to catch any of the combinations that look bad
// (double & half) and turn them into the appropriate color, and make double/quad something special
if (renderfx & RF_SHELL_HALF_DAM)
{
if(Developer_searchpath(2) == 2)
{
// ditch the half damage shell if any of red, blue, or double are on
if (renderfx & (RF_SHELL_RED|RF_SHELL_BLUE|RF_SHELL_DOUBLE))
renderfx &= ~RF_SHELL_HALF_DAM;
}
}
if (renderfx & RF_SHELL_DOUBLE)
{
if(Developer_searchpath(2) == 2)
{
// lose the yellow shell if we have a red, blue, or green shell
if (renderfx & (RF_SHELL_RED|RF_SHELL_BLUE|RF_SHELL_GREEN))
renderfx &= ~RF_SHELL_DOUBLE;
// if we have a red shell, turn it to purple by adding blue
if (renderfx & RF_SHELL_RED)
renderfx |= RF_SHELL_BLUE;
// if we have a blue shell (and not a red shell), turn it to cyan by adding green
else if (renderfx & RF_SHELL_BLUE)
// go to green if it's on already, otherwise do cyan (flash green)
if (renderfx & RF_SHELL_GREEN)
renderfx &= ~RF_SHELL_BLUE;
else
renderfx |= RF_SHELL_GREEN;
}
}
// }
// pmm
ent.flags = renderfx | RF_TRANSLUCENT;
ent.alpha = 0.30;
V_AddEntity (&ent);
}
ent.skin = NULL; // never use a custom skin on others
ent.skinnum = 0;
ent.flags = 0;
ent.alpha = 0;
// duplicate for linked models
if (s1->modelindex2)
{
if (s1->modelindex2 == 255)
{ // custom weapon
ci = &cl.clientinfo[s1->skinnum & 0xff];
i = (s1->skinnum >> 8); // 0 is default weapon model
if (!cl_vwep->value || i > MAX_CLIENTWEAPONMODELS - 1)
i = 0;
ent.model = ci->weaponmodel[i];
if (!ent.model) {
if (i != 0)
ent.model = ci->weaponmodel[0];
if (!ent.model)
ent.model = cl.baseclientinfo.weaponmodel[0];
}
}
else
ent.model = cl.model_draw[s1->modelindex2];
// PMM - check for the defender sphere shell .. make it translucent
// replaces the previous version which used the high bit on modelindex2 to determine transparency
if (!Q_strcasecmp (cl.configstrings[CS_MODELS+(s1->modelindex2)], "models/items/shell/tris.md2"))
{
ent.alpha = 0.32;
ent.flags = RF_TRANSLUCENT;
}
// pmm
V_AddEntity (&ent);
//PGM - make sure these get reset.
ent.flags = 0;
ent.alpha = 0;
//PGM
}
if (s1->modelindex3)
{
ent.model = cl.model_draw[s1->modelindex3];
V_AddEntity (&ent);
}
if (s1->modelindex4)
{
ent.model = cl.model_draw[s1->modelindex4];
V_AddEntity (&ent);
}
if ( effects & EF_POWERSCREEN )
{
ent.model = cl_mod_powerscreen;
ent.oldframe = 0;
ent.frame = 0;
ent.flags |= (RF_TRANSLUCENT | RF_SHELL_GREEN);
ent.alpha = 0.30;
V_AddEntity (&ent);
}
// add automatic particle trails
if ( (effects&~EF_ROTATE) )
{
if (effects & EF_ROCKET)
{
CL_RocketTrail (cent->lerp_origin, ent.origin, cent);
V_AddLight (ent.origin, 200, 1, 1, 0);
}
// PGM - Do not reorder EF_BLASTER and EF_HYPERBLASTER.
// EF_BLASTER | EF_TRACKER is a special case for EF_BLASTER2... Cheese!
else if (effects & EF_BLASTER)
{
// CL_BlasterTrail (cent->lerp_origin, ent.origin);
//PGM
if (effects & EF_TRACKER) // lame... problematic?
{
CL_BlasterTrail2 (cent->lerp_origin, ent.origin);
V_AddLight (ent.origin, 200, 0, 1, 0);
}
else
{
CL_BlasterTrail (cent->lerp_origin, ent.origin);
V_AddLight (ent.origin, 200, 1, 1, 0);
}
//PGM
}
else if (effects & EF_HYPERBLASTER)
{
if (effects & EF_TRACKER) // PGM overloaded for blaster2.
V_AddLight (ent.origin, 200, 0, 1, 0); // PGM
else // PGM
V_AddLight (ent.origin, 200, 1, 1, 0);
}
else if (effects & EF_GIB)
{
CL_DiminishingTrail (cent->lerp_origin, ent.origin, cent, effects);
}
else if (effects & EF_GRENADE)
{
CL_DiminishingTrail (cent->lerp_origin, ent.origin, cent, effects);
}
else if (effects & EF_FLIES)
{
CL_FlyEffect (cent, ent.origin);
}
else if (effects & EF_BFG)
{
static int bfg_lightramp[6] = {300, 400, 600, 300, 150, 75};
if (effects & EF_ANIM_ALLFAST)
{
CL_BfgParticles (&ent);
i = 200;
}
else
{
i = bfg_lightramp[s1->frame];
}
V_AddLight (ent.origin, i, 0, 1, 0);
}
// RAFAEL
else if (effects & EF_TRAP)
{
ent.origin[2] += 32;
CL_TrapParticles (&ent);
i = (rand()%100) + 100;
V_AddLight (ent.origin, i, 1, 0.8, 0.1);
}
else if (effects & EF_FLAG1)
{
CL_FlagTrail (cent->lerp_origin, ent.origin, 242);
V_AddLight (ent.origin, 225, 1, 0.1, 0.1);
}
else if (effects & EF_FLAG2)
{
CL_FlagTrail (cent->lerp_origin, ent.origin, 115);
V_AddLight (ent.origin, 225, 0.1, 0.1, 1);
}
//======
//ROGUE
else if (effects & EF_TAGTRAIL)
{
CL_TagTrail (cent->lerp_origin, ent.origin, 220);
V_AddLight (ent.origin, 225, 1.0, 1.0, 0.0);
}
else if (effects & EF_TRACKERTRAIL)
{
if (effects & EF_TRACKER)
{
float intensity;
intensity = 50 + (500 * (sin(cl.time/500.0) + 1.0));
// FIXME - check out this effect in rendition
if(vidref_val == VIDREF_GL)
V_AddLight (ent.origin, intensity, -1.0, -1.0, -1.0);
else
V_AddLight (ent.origin, -1.0 * intensity, 1.0, 1.0, 1.0);
}
else
{
CL_Tracker_Shell (cent->lerp_origin);
V_AddLight (ent.origin, 155, -1.0, -1.0, -1.0);
}
}
else if (effects & EF_TRACKER)
{
CL_TrackerTrail (cent->lerp_origin, ent.origin, 0);
// FIXME - check out this effect in rendition
if(vidref_val == VIDREF_GL)
V_AddLight (ent.origin, 200, -1, -1, -1);
else
V_AddLight (ent.origin, -200, 1, 1, 1);
}
//ROGUE
//======
// RAFAEL
else if (effects & EF_GREENGIB)
{
CL_DiminishingTrail (cent->lerp_origin, ent.origin, cent, effects);
}
// RAFAEL
else if (effects & EF_IONRIPPER)
{
CL_IonripperTrail (cent->lerp_origin, ent.origin);
V_AddLight (ent.origin, 100, 1, 0.5, 0.5);
}
// RAFAEL
else if (effects & EF_BLUEHYPERBLASTER)
{
V_AddLight (ent.origin, 200, 0, 0, 1);
}
// RAFAEL
else if (effects & EF_PLASMA)
{
if (effects & EF_ANIM_ALLFAST)
{
CL_BlasterTrail (cent->lerp_origin, ent.origin);
}
V_AddLight (ent.origin, 130, 1, 0.5, 0.5);
}
}
VectorCopy (ent.origin, cent->lerp_origin);
}
}
/*
==============
CL_AddViewWeapon
==============
*/
void CL_AddViewWeapon (player_state_t *ps, player_state_t *ops)
{
entity_t gun; // view model
int i;
// allow the gun to be completely removed
if (!cl_gun->value)
return;
// don't draw gun if in wide angle view
if (ps->fov > 90)
return;
memset (&gun, 0, sizeof(gun));
if (gun_model)
gun.model = gun_model; // development tool
else
gun.model = cl.model_draw[ps->gunindex];
if (!gun.model)
return;
// set up gun position
for (i=0 ; i<3 ; i++)
{
gun.origin[i] = cl.refdef.vieworg[i] + ops->gunoffset[i]
+ cl.lerpfrac * (ps->gunoffset[i] - ops->gunoffset[i]);
gun.angles[i] = cl.refdef.viewangles[i] + LerpAngle (ops->gunangles[i],
ps->gunangles[i], cl.lerpfrac);
}
if (gun_frame)
{
gun.frame = gun_frame; // development tool
gun.oldframe = gun_frame; // development tool
}
else
{
gun.frame = ps->gunframe;
if (gun.frame == 0)
gun.oldframe = 0; // just changed weapons, don't lerp from old
else
gun.oldframe = ops->gunframe;
}
gun.flags = RF_MINLIGHT | RF_DEPTHHACK | RF_WEAPONMODEL;
gun.backlerp = 1.0 - cl.lerpfrac;
VectorCopy (gun.origin, gun.oldorigin); // don't lerp at all
V_AddEntity (&gun);
}
/*
===============
CL_CalcViewValues
Sets cl.refdef view values
===============
*/
void CL_CalcViewValues (void)
{
int i;
float lerp, backlerp;
centity_t *ent;
frame_t *oldframe;
player_state_t *ps, *ops;
// find the previous frame to interpolate from
ps = &cl.frame.playerstate;
i = (cl.frame.serverframe - 1) & UPDATE_MASK;
oldframe = &cl.frames[i];
if (oldframe->serverframe != cl.frame.serverframe-1 || !oldframe->valid)
oldframe = &cl.frame; // previous frame was dropped or involid
ops = &oldframe->playerstate;
// see if the player entity was teleported this frame
if ( fabs(ops->pmove.origin[0] - ps->pmove.origin[0]) > 256*8
|| abs(ops->pmove.origin[1] - ps->pmove.origin[1]) > 256*8
|| abs(ops->pmove.origin[2] - ps->pmove.origin[2]) > 256*8)
ops = ps; // don't interpolate
ent = &cl_entities[cl.playernum+1];
lerp = cl.lerpfrac;
// calculate the origin
if ((cl_predict->value) && !(cl.frame.playerstate.pmove.pm_flags & PMF_NO_PREDICTION))
{ // use predicted values
unsigned delta;
backlerp = 1.0 - lerp;
for (i=0 ; i<3 ; i++)
{
cl.refdef.vieworg[i] = cl.predicted_origin[i] + ops->viewoffset[i]
+ cl.lerpfrac * (ps->viewoffset[i] - ops->viewoffset[i])
- backlerp * cl.prediction_error[i];
}
// smooth out stair climbing
delta = cls.realtime - cl.predicted_step_time;
if (delta < 100)
cl.refdef.vieworg[2] -= cl.predicted_step * (100 - delta) * 0.01;
}
else
{ // just use interpolated values
for (i=0 ; i<3 ; i++)
cl.refdef.vieworg[i] = ops->pmove.origin[i]*0.125 + ops->viewoffset[i]
+ lerp * (ps->pmove.origin[i]*0.125 + ps->viewoffset[i]
- (ops->pmove.origin[i]*0.125 + ops->viewoffset[i]) );
}
// if not running a demo or on a locked frame, add the local angle movement
if ( cl.frame.playerstate.pmove.pm_type < PM_DEAD )
{ // use predicted values
for (i=0 ; i<3 ; i++)
cl.refdef.viewangles[i] = cl.predicted_angles[i];
}
else
{ // just use interpolated values
for (i=0 ; i<3 ; i++)
cl.refdef.viewangles[i] = LerpAngle (ops->viewangles[i], ps->viewangles[i], lerp);
}
for (i=0 ; i<3 ; i++)
cl.refdef.viewangles[i] += LerpAngle (ops->kick_angles[i], ps->kick_angles[i], lerp);
AngleVectors (cl.refdef.viewangles, cl.v_forward, cl.v_right, cl.v_up);
// interpolate field of view
cl.refdef.fov_x = ops->fov + lerp * (ps->fov - ops->fov);
// don't interpolate blend color
for (i=0 ; i<4 ; i++)
cl.refdef.blend[i] = ps->blend[i];
// add the weapon
CL_AddViewWeapon (ps, ops);
}
/*
===============
CL_AddEntities
Emits all entities, particles, and lights to the refresh
===============
*/
void CL_AddEntities (void)
{
if (cls.state != ca_active)
return;
if (cl.time > cl.frame.servertime)
{
if (cl_showclamp->value)
Com_Printf ("high clamp %i\n", cl.time - cl.frame.servertime);
cl.time = cl.frame.servertime;
cl.lerpfrac = 1.0;
}
else if (cl.time < cl.frame.servertime - 100)
{
if (cl_showclamp->value)
Com_Printf ("low clamp %i\n", cl.frame.servertime-100 - cl.time);
cl.time = cl.frame.servertime - 100;
cl.lerpfrac = 0;
}
else
cl.lerpfrac = 1.0 - (cl.frame.servertime - cl.time) * 0.01;
if (cl_timedemo->value)
cl.lerpfrac = 1.0;
// CL_AddPacketEntities (&cl.frame);
// CL_AddTEnts ();
// CL_AddParticles ();
// CL_AddDLights ();
// CL_AddLightStyles ();
CL_CalcViewValues ();
// PMM - moved this here so the heat beam has the right values for the vieworg, and can lock the beam to the gun
CL_AddPacketEntities (&cl.frame);
#if 0
CL_AddProjectiles ();
#endif
CL_AddTEnts ();
CL_AddParticles ();
CL_AddDLights ();
CL_AddLightStyles ();
}
/*
===============
CL_GetEntitySoundOrigin
Called to get the sound spatialization origin
===============
*/
void CL_GetEntitySoundOrigin (int ent, vec3_t org)
{
centity_t *old;
if (ent < 0 || ent >= MAX_EDICTS)
Com_Error (ERR_DROP, "CL_GetEntitySoundOrigin: bad ent");
old = &cl_entities[ent];
VectorCopy (old->lerp_origin, org);
// FIXME: bmodel issues...
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -