⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cl_ents.pas

📁 delphi编的不错的贪吃蛇
💻 PAS
📖 第 1 页 / 共 3 页
字号:
      else
        ent.alpha := 0.3;
    end;
    //pmm

      // add to refresh list
    V_AddEntity(@ent);

    // color shells generate a seperate entity for the main model
    if ((effects and EF_COLOR_SHELL) <> 0) then
    begin
      // 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 and RF_SHELL_HALF_DAM) <> 0) then
      begin
        if (Developer_searchpath(2) = 2) then
        begin
          // ditch the half damage shell if any of red, blue, or double are on
          if (renderfx and (RF_SHELL_RED or RF_SHELL_BLUE or RF_SHELL_DOUBLE) <> 0) then
            renderfx := renderfx and (not RF_SHELL_HALF_DAM);
        end;
      end;

      if (renderfx and RF_SHELL_DOUBLE <> 0) then
      begin
        if (Developer_searchpath(2) = 2) then
        begin
          // lose the yellow shell if we have a red, blue, or green shell
          if (renderfx and (RF_SHELL_RED or RF_SHELL_BLUE or RF_SHELL_DOUBLE) <> 0) then
            renderfx := renderfx and (not RF_SHELL_DOUBLE);
          // if we have a red shell, turn it to purple by adding blue
          if (renderfx and RF_SHELL_RED <> 0) then
            renderfx := renderfx or RF_SHELL_BLUE
              // if we have a blue shell (and not a red shell), turn it to cyan by adding green
          else if (renderfx and RF_SHELL_BLUE <> 0) then
            // go to green if it's on already, otherwise do cyan (flash green)
            if (renderfx and RF_SHELL_GREEN <> 0) then
              renderfx := renderfx and (not RF_SHELL_BLUE)
            else
              renderfx := renderfx or RF_SHELL_GREEN;
        end;
      end;
      //			}
         // pmm
      ent.flags := renderfx or RF_TRANSLUCENT;
      ent.alpha := 0.30;
      V_AddEntity(@ent);
    end;

    ent.skin := nil;                    // never use a custom skin on others
    ent.skinnum := 0;
    ent.flags := 0;
    ent.alpha := 0;

    // duplicate for linked models
    if (s1.modelindex2 <> 0) then
    begin
      if (s1.modelindex2 = 255) then
      begin
        // custom weapon
        ci := @cl.clientinfo[s1.skinnum and $FF];
        i := (s1.skinnum shr 8);        // 0 is default weapon model
        if (cl_vwep.value = 0) or (i > MAX_CLIENTWEAPONMODELS - 1) then
          i := 0;
        ent.model := ci.weaponmodel[i];
        if (ent.model = nil) then
        begin
          if (i <> 0) then
            ent.model := ci.weaponmodel[0];
          if (ent.model = nil) then
            ent.model := cl.baseclientinfo.weaponmodel[0];
        end;
      end
      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') = 0) then
      begin
        ent.alpha := 0.32;
        ent.flags := RF_TRANSLUCENT;
      end;
      // pmm

      V_AddEntity(@ent);

      //PGM - make sure these get reset.
      ent.flags := 0;
      ent.alpha := 0;
      //PGM
    end;
    if (s1.modelindex3 <> 0) then
    begin
      ent.model := cl.model_draw[s1.modelindex3];
      V_AddEntity(@ent);
    end;
    if (s1.modelindex4 <> 0) then
    begin
      ent.model := cl.model_draw[s1.modelindex4];
      V_AddEntity(@ent);
    end;

    if (effects and EF_POWERSCREEN <> 0) then
    begin
      ent.model := cl_mod_powerscreen;
      ent.oldframe := 0;
      ent.frame := 0;
      ent.flags := ent.flags or (RF_TRANSLUCENT or RF_SHELL_GREEN);
      ent.alpha := 0.30;
      V_AddEntity(@ent);
    end;

    // add automatic particle trails
    if (effects and (not EF_ROTATE) <> 0) then
    begin
      if (effects and EF_ROCKET <> 0) then
      begin
        CL_RocketTrail(cent.lerp_origin, vec3_t(ent.origin), cent);
        V_AddLight(vec3_t(ent.origin), 200, 1, 1, 0);
      end
        // PGM - Do not reorder EF_BLASTER and EF_HYPERBLASTER.
        // EF_BLASTER | EF_TRACKER is a special case for EF_BLASTER2... Cheese!
      else if (effects and EF_BLASTER <> 0) then
      begin
        //				CL_BlasterTrail (cent.lerp_origin, ent.origin);
        //PGM
        if (effects and EF_TRACKER <> 0) then
        begin                           // lame... problematic?
          CL_BlasterTrail2(cent.lerp_origin, vec3_t(ent.origin));
          V_AddLight(vec3_t(ent.origin), 200, 0, 1, 0);
        end
        else
        begin
          CL_BlasterTrail(cent.lerp_origin, vec3_t(ent.origin));
          V_AddLight(vec3_t(ent.origin), 200, 1, 1, 0);
        end;
        //PGM
      end
      else if (effects and EF_HYPERBLASTER <> 0) then
      begin
        if (effects and EF_TRACKER <> 0) then // PGM	overloaded for blaster2.
          V_AddLight(vec3_t(ent.origin), 200, 0, 1, 0) // PGM
        else                            // PGM
          V_AddLight(vec3_t(ent.origin), 200, 1, 1, 0);
      end
      else if (effects and EF_GIB <> 0) then
      begin
        CL_DiminishingTrail(cent.lerp_origin, vec3_t(ent.origin), cent, effects);
      end
      else if (effects and EF_GRENADE <> 0) then
      begin
        CL_DiminishingTrail(cent.lerp_origin, vec3_t(ent.origin), cent, effects);
      end
      else if (effects and EF_FLIES <> 0) then
      begin
        CL_FlyEffect(cent, vec3_t(ent.origin));
      end
      else if (effects and EF_BFG <> 0) then
      begin

        if (effects and EF_ANIM_ALLFAST <> 0) then
        begin
          CL_BfgParticles(@ent);
          i := 200;
        end
        else
        begin
          i := bfg_lightramp[s1.frame];
        end;
        V_AddLight(vec3_t(ent.origin), i, 0, 1, 0);
      end
        // RAFAEL
      else if (effects and EF_TRAP <> 0) then
      begin
        ent.origin[2] := ent.origin[2] + 32;
        CL_TrapParticles(@ent);
        i := (rand() mod 100) + 100;
        V_AddLight(vec3_t(ent.origin), i, 1, 0.8, 0.1);
      end
      else if (effects and EF_FLAG1 <> 0) then
      begin
        CL_FlagTrail(cent.lerp_origin, vec3_t(ent.origin), 242);
        V_AddLight(vec3_t(ent.origin), 225, 1, 0.1, 0.1);
      end
      else if (effects and EF_FLAG2 <> 0) then
      begin
        CL_FlagTrail(cent.lerp_origin, vec3_t(ent.origin), 115);
        V_AddLight(vec3_t(ent.origin), 225, 0.1, 0.1, 1);
      end
        //======
        //ROGUE
      else if (effects and EF_TAGTRAIL <> 0) then
      begin
        CL_TagTrail(cent.lerp_origin, vec3_t(ent.origin), 220);
        V_AddLight(vec3_t(ent.origin), 225, 1.0, 1.0, 0.0);
      end
      else if (effects and EF_TRACKERTRAIL <> 0) then
      begin
        if (effects and EF_TRACKER <> 0) then
        begin
          intensity := 50 + (500 * (sin(cl.time / 500.0) + 1.0));
          // FIXME - check out this effect in rendition
          if (vidref_val = VIDREF_GL) then
            V_AddLight(vec3_t(ent.origin), intensity, -1.0, -1.0, -1.0)
          else
            V_AddLight(vec3_t(ent.origin), -1.0 * intensity, 1.0, 1.0, 1.0);
        end
        else
        begin
          CL_Tracker_Shell(cent.lerp_origin);
          V_AddLight(vec3_t(ent.origin), 155, -1.0, -1.0, -1.0);
        end;
      end
      else if (effects and EF_TRACKER <> 0) then
      begin
        CL_TrackerTrail(cent.lerp_origin, vec3_t(ent.origin), 0);
        // FIXME - check out this effect in rendition
        if (vidref_val = VIDREF_GL) then
          V_AddLight(vec3_t(ent.origin), 200, -1, -1, -1)
        else
          V_AddLight(vec3_t(ent.origin), -200, 1, 1, 1);
      end
        //ROGUE
        //======
           // RAFAEL
      else if (effects and EF_GREENGIB <> 0) then
      begin
        CL_DiminishingTrail(cent.lerp_origin, vec3_t(ent.origin), cent, effects);
      end
        // RAFAEL
      else if (effects and EF_IONRIPPER <> 0) then
      begin
        CL_IonripperTrail(cent.lerp_origin, vec3_t(ent.origin));
        V_AddLight(vec3_t(ent.origin), 100, 1, 0.5, 0.5);
      end
        // RAFAEL
      else if (effects and EF_BLUEHYPERBLASTER <> 0) then
      begin
        V_AddLight(vec3_t(ent.origin), 200, 0, 0, 1);
      end
        // RAFAEL
      else if (effects and EF_PLASMA <> 0) then
      begin
        if (effects and EF_ANIM_ALLFAST <> 0) then
        begin
          CL_BlasterTrail(cent.lerp_origin, vec3_t(ent.origin));
        end;
        V_AddLight(vec3_t(ent.origin), 130, 1, 0.5, 0.5);
      end;
    end;

    VectorCopy(vec3_t(ent.origin), cent.lerp_origin);
  end;
end;

{*
==============
CL_AddViewWeapon
==============
*}
procedure CL_AddViewWeapon(ps: player_state_p; ops: player_state_p);
var
  gun: entity_t;                        // view model
  i: integer;
begin
  // allow the gun to be completely removed
  if (cl_gun.value = 0) then
    exit;

  // don't draw gun if in wide angle view
  if (ps.fov > 90) then
    exit;

  FillChar(gun, sizeof(gun), #0);

  if (gun_model <> nil) then
    gun.model := gun_model              // development tool
  else
    gun.model := cl.model_draw[ps.gunindex];
  if (gun.model = nil) then
    exit;

  // set up gun position
  for i := 0 to 2 do
  begin
    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);
  end;

  if (gun_frame <> 0) then
  begin
    gun.frame := gun_frame;             // development tool
    gun.oldframe := gun_frame;          // development tool
  end
  else
  begin
    gun.frame := ps.gunframe;
    if (gun.frame = 0) then
      gun.oldframe := 0                 // just changed weapons, don't lerp from old
    else
      gun.oldframe := ops.gunframe;
  end;

  gun.flags := RF_MINLIGHT or RF_DEPTHHACK or RF_WEAPONMODEL;
  gun.backlerp := 1.0 - cl.lerpfrac;
  VectorCopy(vec3_t(gun.origin), vec3_t(gun.oldorigin)); // don't lerp at all
  V_AddEntity(@gun);
end;

{*
===============
CL_CalcViewValues

Sets cl.refdef view values
===============
*}
procedure CL_CalcViewValues;
var
  i: integer;
  lerp, backlerp: single;
  ent: centity_p;
  oldframe: frame_p;
  ps, ops: player_state_p;
  delta: word;
begin
  // find the previous frame to interpolate from
  ps := @cl.frame.playerstate;
  i := (cl.frame.serverframe - 1) and UPDATE_MASK;
  oldframe := @cl.frames[i];
  if (oldframe.serverframe <> cl.frame.serverframe - 1) and (not oldframe.valid) then
    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)
    or (abs(ops.pmove.origin[1] - ps.pmove.origin[1]) > 256 * 8)
    or (abs(ops.pmove.origin[2] - ps.pmove.origin[2]) > 256 * 8) then
    ops := ps;                          // don't interpolate

  ent := @cl_entities[cl.playernum + 1];
  lerp := cl.lerpfrac;

  // calculate the origin
  if ((cl_predict.value <> 0) and (cl.frame.playerstate.pmove.pm_flags and PMF_NO_PREDICTION = 0)) then
  begin
    // use predicted values

    backlerp := 1.0 - lerp;
    for i := 0 to 2 do
    begin
      cl.refdef.vieworg[i] := cl.predicted_origin[i] + ops.viewoffset[i]
        + cl.lerpfrac * (ps.viewoffset[i] - ops.viewoffset[i])
        - backlerp * cl.prediction_error[i];
    end;

    // smooth out stair climbing
    delta := cls.realtime - cl.predicted_step_time;
    if (delta < 100) then
      cl.refdef.vieworg[2] := cl.refdef.vieworg[2] - cl.predicted_step * (100 - delta) * 0.01;
  end
  else
  begin                                 // just use interpolated values
    for i := 0 to 2 do
      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]));
  end;

  // if not running a demo or on a locked frame, add the local angle movement
  if (cl.frame.playerstate.pmove.pm_type < PM_DEAD) then
  begin
    // use predicted values
    for i := 0 to 2 do
      cl.refdef.viewangles[i] := cl.predicted_angles[i];
  end
  else
  begin                                 // just use interpolated values
    for i := 0 to 2 do
      cl.refdef.viewangles[i] := LerpAngle(ops.viewangles[i], ps.viewangles[i], lerp);
  end;

  for i := 0 to 2 do
    cl.refdef.viewangles[i] := cl.refdef.viewangles[i] + LerpAngle(ops.kick_angles[i], ps.kick_angles[i], lerp);

  AngleVectors(vec3_t(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 to 3 do
    cl.refdef.blend[i] := ps.blend[i];

  // add the weapon
  CL_AddViewWeapon(ps, ops);
end;

{*
===============
CL_AddEntities

Emits all entities, particles, and lights to the refresh
===============
*}
procedure CL_AddEntities;
begin
  if (cls.state <> ca_active) then
    exit;

  if (cl.time > cl.frame.servertime) then
  begin
    if (cl_showclamp.value <> 0) then
      Com_Printf('high clamp %d'#10, [cl.time - cl.frame.servertime]);
    cl.time := cl.frame.servertime;
    cl.lerpfrac := 1.0;
  end
  else if (cl.time < cl.frame.servertime - 100) then
  begin
    if (cl_showclamp.value <> 0) then
      Com_Printf('low clamp %d'#10, [cl.frame.servertime - 100 - cl.time]);
    cl.time := cl.frame.servertime - 100;
    cl.lerpfrac := 0;
  end
  else
    cl.lerpfrac := 1.0 - (cl.frame.servertime - cl.time) * 0.01;

  if (cl_timedemo.value <> 0) then
    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);
  {
   CL_AddProjectiles ();
  }
  CL_AddTEnts();
  CL_AddParticles();
  CL_AddDLights();
  CL_AddLightStyles();
end;

{*
===============
CL_GetEntitySoundOrigin

Called to get the sound spatialization origin
===============
*}
procedure CL_GetEntitySoundOrigin(ent: integer; var org: vec3_t);
var
  old: centity_p;
begin
  if (ent < 0) or (ent >= MAX_EDICTS) then
    Com_Error(ERR_DROP, 'CL_GetEntitySoundOrigin: bad ent', []);
  old := @cl_entities[ent];
  VectorCopy(old.lerp_origin, org);

  // FIXME: bmodel issues...
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -