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

📄 p_view.pas

📁 delphi编的不错的贪吃蛇
💻 PAS
📖 第 1 页 / 共 3 页
字号:
  if (ent.client.quad_framenum > level.framenum) AND (level.framenum & 8)
//ZOID
{$ELSE}
  if (ent.client.quad_framenum > level.framenum)
{$ENDIF}
  then begin
    remaining := ent.client.quad_framenum - level.framenum;
    if (remaining > 30) OR (remaining & 4) then
      ent.s.effects := ent.s.effects OR EF_QUAD;
  end;

{$IFDEF CTF}
//ZOID
  if (ent.client.invincible_framenum > level.framenum) AND (level.framenum & 8)
//ZOID
{$ELSE}
  if (ent.client.invincible_framenum > level.framenum)
{$ENDIF}
  then begin
    remaining := ent.client.invincible_framenum - level.framenum;
    if (remaining > 30) OR (remaining & 4) then
      ent.s.effects := ent.s.effects OR EF_PENT;
  end;

  // show cheaters!!!
  if (ent.flags & FL_GODMODE) then
  begin
    ent.s.effects := ent.s.effects OR EF_COLOR_SHELL;
    ent.s.renderfx := ent.s.renderfx OR (RF_SHELL_RED OR RF_SHELL_GREEN OR RF_SHELL_BLUE);
  end;
end;//procedure (GAME <> CTF)


{*
===============
G_SetClientEvent
===============
*}
// (GAME=CTF)
procedure G_SetClientEvent (edict_t *ent);
begin
  if (ent.s.event) then
    Exit;

  if ( ent.groundentity && xyspeed > 225) then
    if ( (int)(current_client->bobtime+bobmove) != bobcycle )
      ent.s.event := EV_FOOTSTEP;
end;//procedure (GAME=CTF)


{*
===============
G_SetClientSound
===============
*}
// (GAME <> CTF)
procedure G_SetClientSound (edict_t *ent)
var
	char	*weap;
begin
{$IFDEF CTF}
  if (ent.client.resp.game_helpchanged <> game.helpchanged) then
  begin
    ent.client.resp.game_helpchanged := game.helpchanged;
    ent.client.resp.helpchanged := 1;
  end;

  // help beep (no more than three times)
  if (ent.client.resp.helpchanged && ent.client.resp.helpchanged <= 3 && !(level.framenum&63) ) then
  begin
    ent.client.resp.helpchanged++;
    gi.sound (ent, CHAN_VOICE, gi.soundindex ('misc/pc_up.wav'), 1, ATTN_STATIC, 0);
  end;
{$ELSE}
  if (ent.client.pers.game_helpchanged <> game.helpchanged) then
  begin
    ent.client.pers.game_helpchanged := game.helpchanged;
    ent.client.pers.helpchanged := 1;
  end;

  // help beep (no more than three times)
  if (ent.client.pers.helpchanged && ent.client.pers.helpchanged <= 3 && !(level.framenum&63) ) then
  begin
    ent.client.pers.helpchanged++;
    gi.sound (ent, CHAN_VOICE, gi.soundindex ('misc/pc_up.wav'), 1, ATTN_STATIC, 0);
  end;
{$ENDIF}

  if (ent.client.pers.weapon)
  then weap := ent.client.pers.weapon.classname;
  else weap := '';

  if (ent->waterlevel && (ent->watertype&(CONTENTS_LAVA|CONTENTS_SLIME)) )
  then ent.s.sound := snd_fry
  else
    if (strcmp(weap, 'weapon_railgun') == 0)
    then ent.s.sound := gi.soundindex('weapons/rg_hum.wav');
    else
      if (strcmp(weap, 'weapon_bfg') == 0)
      then ent.s.sound := gi.soundindex('weapons/bfg_hum.wav')
      else
        if (ent.client.weapon_sound)
        then ent.s.sound := ent.client.weapon_sound
        else ent.s.sound := 0;
end;//procedure (GAME <> CTF)

{*
===============
G_SetClientFrame
===============
*}
// (GAME <> CTF)
procedure G_SetClientFrame (edict_t *ent);
var
	gclient_t	*client;
  duck, run : qboolean;
begin
  if (ent.s.modelindex <> 255)
    Exit;  // not in the player model

  client := ent.client;

  if (client->ps.pmove.pm_flags & PMF_DUCKED)
  then duck := true
  else duck := false;
  if (xyspeed)
  then run := true
  else run := false;

  // check for stand/duck and stop/go transitions
  if (duck <> client.anim_duck) AND (client.anim_priority < ANIM_DEATH) then
    goto newanim;
  if (run <> client.anim_run) AND (client.anim_priority = ANIM_BASIC) then
    goto newanim;
  if (!ent->groundentity) AND (client.anim_priority <= ANIM_WAVE) then
    goto newanim;

  if(client.anim_priority = ANIM_REVERSE)
  then
    if (ent.s.frame > client.anim_end) then
    begin
      ent->s.frame--;
      Exit;
    end;
  else
    if (ent.s.frame < client.anim_end) then
    begin
      // continue an animation
      ent->s.frame++;
      Exit;
    end;

  if (client.anim_priority = ANIM_DEATH) then
    Exit;   // stay there
  if (client.anim_priority = ANIM_JUMP) then
  begin
    if (!ent->groundentity) then
      Exit;   // stay there
    ent.client.anim_priority := ANIM_WAVE;
    ent.s.frame := FRAME_jump3;
    ent.client.anim_end := FRAME_jump6;
    Exit;
  end;

newanim:
  // return to either a running or standing frame
  client.anim_priority := ANIM_BASIC;
  client.anim_duck := duck;
  client.anim_run := run;

  if (!ent->groundentity)
  then begin
{$IFDEF CTF}
//ZOID: if on grapple, don't go into jump frame, go into standing
//frame
    if (client.ctf_grapple)
    then begin
      ent->s.frame = FRAME_stand01;
      client->anim_end = FRAME_stand40;
    end
    else begin
//ZOID
      client.anim_priority := ANIM_JUMP;
      if (ent.s.frame <> FRAME_jump2) then
        ent.s.frame := FRAME_jump1;
      client.anim_end := FRAME_jump2;
    end;
{$ELSE}
    client.anim_priority := ANIM_JUMP;
    if (ent.s.frame <> FRAME_jump2) then
      ent.s.frame := FRAME_jump1;
    client.anim_end := FRAME_jump2;
{$ENDIF}
  end
  else
    if (run)
    then
      // running
      if (duck)
      then begin
        ent.s.frame := FRAME_crwalk1;
        client.anim_end := FRAME_crwalk6;
      end
      else begin
        ent.s.frame := FRAME_run1;
        client.anim_end := FRAME_run6;
      end;
    else
      // standing
      if (duck)
      then begin
        ent.s.frame := FRAME_crstnd01;
        client.anim_end := FRAME_crstnd19;
      end
      else begin
        ent.s.frame := FRAME_stand01;
        client.anim_end := FRAME_stand40;
      end;
end;//procedure (GAME <> CTF)


{*
=================
ClientEndServerFrame

Called for each player at the end of the server frame
and right after spawning
=================
*}
// (GAME <> CTF)
procedure ClientEndServerFrame (edict_t *ent);
var
  bobtime : float;
  i       : integer;
begin
  current_player := ent;
  current_client := ent.client;

  //
  // If the origin or velocity have changed since ClientThink(),
  // update the pmove values.  This will happen when the client
  // is pushed by a bmodel or kicked by an explosion.
  //
  // If it wasn't updated here, the view position would lag a frame
  // behind the body position when pushed -- "sinking into plats"
  //
  for i:=0 to 2 do
  begin
    current_client.ps.pmove.origin[i] := ent.s.origin[i] * 8.0;
    current_client.ps.pmove.velocity[i] := ent.velocity[i] * 8.0;
  end;

  //
  // If the end of unit layout is displayed, don't give
  // the player any normal movement attributes
  //
  if (level.intermissiontime) then
  begin
    // FIXME: add view drifting here?
    current_client.ps.blend[3] := 0;
    current_client.ps.fov := 90;
    G_SetStats (ent);
    Exit;
  end;

  AngleVectors (ent.client.v_angle, forward, right, up);

  // burn from lava, etc
  P_WorldEffects ();

  //
  // set model angles from view angles so other things in
  // the world can tell which direction you are looking
  //
  if (ent.client.v_angle[PITCH] > 180)
  then ent.s.angles[PITCH] := (-360 + ent.client.v_angle[PITCH])/3;
  else ent.s.angles[PITCH] := ent.client.v_angle[PITCH]/3;
  ent.s.angles[YAW] := ent.client.v_angle[YAW];
  ent.s.angles[ROLL] := 0;
  ent.s.angles[ROLL] := SV_CalcRoll (ent.s.angles, ent.velocity)*4;

  //
  // calculate speed and cycle to be used for
  // all cyclic walking effects
  //
  xyspeed := sqrt(ent.velocity[0]*ent.velocity[0] + ent.velocity[1]*ent.velocity[1]);

  if (xyspeed < 5)
  then begin
    bobmove := 0;
    current_client.bobtime := 0;  // start at beginning of cycle again
  end
  else
    if (ent->groundentity) then
    begin
      // so bobbing only cycles when on ground
      if (xyspeed > 210)
      then bobmove := 0.25
      else
        if (xyspeed > 100)
        then bobmove := 0.125
        else bobmove := 0.0625;
    end;

{Y}  bobtime = (current_client->bobtime += bobmove);

  if (current_client->ps.pmove.pm_flags & PMF_DUCKED) then
    bobtime := bobtime * 4;

  bobcycle := (int)bobtime;
  bobfracsin := abs(sin(bobtime*M_PI));

  // detect hitting the floor
  P_FallingDamage (ent);

  // apply all the damage taken this frame
  P_DamageFeedback (ent);

  // determine the view offsets
  SV_CalcViewOffset (ent);

  // determine the gun offsets
  SV_CalcGunOffset (ent);

  // determine the full screen color blend
  // must be after viewoffset, so eye contents can be
  // accurately determined
  // FIXME: with client prediction, the contents
  // should be determined by the client
  SV_CalcBlend (ent);

{$IFDEF CTF}
//ZOID
  if (!ent.client.chase_target) then
//ZOID
    G_SetStats (ent);

//ZOID
//update chasecam follower stats
  for i:=1 to maxclients.value do
  begin
    edict_t *e = g_edicts + i;
    if (!e.inuse) OR (e.client.chase_target <> ent) then
      Continue;
    memcpy (e->client->ps.stats,
            ent->client->ps.stats,
            sizeof(ent->client->ps.stats));
    e.client.ps.stats[STAT_LAYOUTS] := 1;
    Break;
  end;
//ZOID
{$ELSE}
  // chase cam stuff
  if (ent.client.resp.spectator)
  then G_SetSpectatorStats(ent)
  else G_SetStats (ent);
  G_CheckChaseStats(ent);
{$ENDIF}

  G_SetClientEvent (ent);

  G_SetClientEffects (ent);

  G_SetClientSound (ent);

  G_SetClientFrame (ent);

  VectorCopy (ent.velocity, ent.client.oldvelocity);
  VectorCopy (ent.client.ps.viewangles, ent.client.oldviewangles);

  // clear weapon kicks
  VectorClear (ent.client.kick_origin);
  VectorClear (ent.client.kick_angles);

  // if the scoreboard is up, update it
//  if (ent.client.showscores) && !(level.framenum & 31) ) then
  if (ent.client.showscores) AND ((level.framenum AND 31) = 0) then
  begin
{$IFDEF CTF}
//ZOID
    if (ent.client.menu)
    then begin
      PMenu_Do_Update(ent);
      ent.client.menudirty := false;
      ent.client.menutime := level.time;
    end
    else DeathmatchScoreboardMessage (ent, ent.enemy);
    gi.unicast (ent, false);
//ZOID
{$ELSE}
    DeathmatchScoreboardMessage (ent, ent.enemy);
    gi.unicast (ent, false);
{$ENDIF}
  end;//if
end;//procedure (GAME <> CTF)

// End of file


My current problems:
--------------------
1)  if (rand()&1)

2)  bobtime = (current_client->bobtime += bobmove);
    A = (B += C)

⌨️ 快捷键说明

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