📄 p_hud.pas
字号:
begin
DeathmatchScoreboardMessage (ent, ent^.enemy);
gi.unicast (ent, true);
end;
{*
==================
Cmd_Score_f
Display the scoreboard
==================
*}
procedure Cmd_Score_f (ent : edict_p);
begin
ent^.client^.showinventory := false;
ent^.client^.showhelp := false;
{$IFDEF CTF} //only CTF
(*Y//ZOID
if (ent.client.menu) then
PMenu_Close(ent);
//ZOID*)
{$ENDIF}
if (deathmatch^.value = 0) AND (coop^.value = 0) then
Exit;
if (ent^.client^.showscores) then
begin
ent^.client^.showscores := false;
{$IFDEF CTF} //only CTF
ent^.client^.update_chase := true;
{$ENDIF}
Exit;
end;
ent^.client^.showscores := true;
DeathmatchScoreboard (ent);
end;
{*
==================
HelpComputer
Draw help computer.
==================
*}
procedure HelpComputer (ent : edict_p);
var
string_ : array [0..1023] of char;
sk : PChar;
begin
if (skill^.value = 0) then
sk := 'easy'
else if (skill^.value = 1) then
sk := 'medium'
else if (skill^.value = 2) then
sk := 'hard'
else
sk := 'hard+';
// send the layout
Com_sprintf (string_, SizeOf(string_),
'xv 32 yv 8 picn help '+ // background
'xv 202 yv 12 string2 "%s" '+ // skill
'xv 0 yv 24 cstring2 "%s" '+ // level name
'xv 0 yv 54 cstring2 "%s" '+ // help 1
'xv 0 yv 110 cstring2 "%s" '+ // help 2
'xv 50 yv 164 string2 " kills goals secrets" '+
'xv 50 yv 172 string2 "%3i/%3i %i/%i %i/%i" ',
[sk,
level.level_name,
game.helpmessage1,
game.helpmessage2,
level.killed_monsters, level.total_monsters,
level.found_goals, level.total_goals,
level.found_secrets, level.total_secrets]);
gi.WriteByte (svc_layout);
gi.WriteString (string_);
gi.unicast (ent, true);
end;
{*
==================
Cmd_Help_f
Display the current help message
==================
*}
procedure Cmd_Help_f (ent : edict_p);
begin
// this is for backwards compatability
if (deathmatch^.value <> 0) then
begin
Cmd_Score_f (ent);
Exit;
end;
ent^.client^.showinventory := false;
ent^.client^.showscores := false;
{$IFDEF CTF}
if (ent^.client^.showhelp AND (ent^.client^.resp.game_helpchanged = game.helpchanged)) then
{$ELSE}
if (ent^.client^.showhelp AND (ent^.client^.pers.game_helpchanged = game.helpchanged)) then
{$ENDIF}
begin
ent^.client^.showhelp := false;
Exit;
end;
ent^.client^.showhelp := true;
{$IFDEF CTF}
ent^.client^.resp.helpchanged := 0;
{$ELSE}
ent^.client^.pers.helpchanged := 0;
{$ENDIF}
HelpComputer (ent);
end;
//=======================================================================
{*
===============
G_SetStats
===============
*}
procedure G_SetStats (ent : edict_p);
var
item : gitem_p;
index, cells,
power_armor_type : integer;
begin
//
// health
//
ent^.client^.ps.stats[STAT_HEALTH_ICON] := level.pic_health;
ent^.client^.ps.stats[STAT_HEALTH] := ent^.health;
//
// ammo
//
if (ent^.client^.ammo_index = 0) then //idsoft/* || !ent->client->pers.inventory[ent->client->ammo_index] */
begin
ent^.client^.ps.stats[STAT_AMMO_ICON] := 0;
ent^.client^.ps.stats[STAT_AMMO] := 0;
end
else begin
item := @itemlist[ent^.client^.ammo_index];
ent^.client^.ps.stats[STAT_AMMO_ICON] := gi.imageindex (item^.icon);
ent^.client^.ps.stats[STAT_AMMO] := ent^.client^.pers.inventory[ent^.client^.ammo_index];
end;
//
// armor
//
power_armor_type := PowerArmorType (ent);
if (power_armor_type <> 0) then
begin
cells := ent^.client^.pers.inventory[ITEM_INDEX(FindItem ('cells'))];
if (cells = 0) then
begin
// ran out of cells for power armor
ent^.flags := ent^.flags AND (NOT FL_POWER_ARMOR);
gi.sound(ent, CHAN_ITEM, gi.soundindex('misc/power2.wav'), 1, ATTN_NORM, 0);
power_armor_type := 0;
end;
end;
index := ArmorIndex (ent);
if (power_armor_type <> 0) AND
((index = 0) OR ((level.framenum AND 8) <> 0)) then
begin
// flash between power armor and other armor icon
ent^.client^.ps.stats[STAT_ARMOR_ICON] := gi.imageindex ('i_powershield');
ent^.client^.ps.stats[STAT_ARMOR] := cells;
end
else if (index <> 0) then
begin
item := GetItemByIndex (index);
ent^.client^.ps.stats[STAT_ARMOR_ICON] := gi.imageindex (item^.icon);
ent^.client^.ps.stats[STAT_ARMOR] := ent^.client^.pers.inventory[index];
end
else
begin
ent^.client^.ps.stats[STAT_ARMOR_ICON] := 0;
ent^.client^.ps.stats[STAT_ARMOR] := 0;
end;
//
// pickup message
//
if (level.time > ent^.client^.pickup_msg_time) then
begin
ent^.client^.ps.stats[STAT_PICKUP_ICON] := 0;
ent^.client^.ps.stats[STAT_PICKUP_STRING] := 0;
end;
//
// timers
//
if (ent^.client^.quad_framenum > level.framenum) then
begin
ent^.client^.ps.stats[STAT_TIMER_ICON] := gi.imageindex ('p_quad');
ent^.client^.ps.stats[STAT_TIMER] := trunc((ent^.client^.quad_framenum - level.framenum)/10);
end
else if (ent^.client^.invincible_framenum > level.framenum) then
begin
ent^.client^.ps.stats[STAT_TIMER_ICON] := gi.imageindex ('p_invulnerability');
ent^.client^.ps.stats[STAT_TIMER] := trunc((ent^.client^.invincible_framenum - level.framenum)/10);
end
else if (ent^.client^.enviro_framenum > level.framenum) then
begin
ent^.client^.ps.stats[STAT_TIMER_ICON] := gi.imageindex ('p_envirosuit');
ent^.client^.ps.stats[STAT_TIMER] := trunc((ent^.client^.enviro_framenum - level.framenum)/10);
end
else if (ent^.client^.breather_framenum > level.framenum) then
begin
ent^.client^.ps.stats[STAT_TIMER_ICON] := gi.imageindex ('p_rebreather');
ent^.client^.ps.stats[STAT_TIMER] := trunc((ent^.client^.breather_framenum - level.framenum)/10);
end
else
begin
ent^.client^.ps.stats[STAT_TIMER_ICON] := 0;
ent^.client^.ps.stats[STAT_TIMER] := 0;
end;
//
// selected item
//
if (ent^.client^.pers.selected_item = -1) then
ent^.client^.ps.stats[STAT_SELECTED_ICON] := 0
else
ent^.client^.ps.stats[STAT_SELECTED_ICON] := gi.imageindex (itemlist[ent^.client^.pers.selected_item].icon);
ent^.client^.ps.stats[STAT_SELECTED_ITEM] := ent^.client^.pers.selected_item;
//
// layouts
//
ent^.client^.ps.stats[STAT_LAYOUTS] := 0;
if (deathmatch^.value <> 0) then
begin
if (ent^.client^.pers.health <= 0) OR (level.intermissiontime <> 0) OR
(ent^.client^.showscores) then
ent^.client^.ps.stats[STAT_LAYOUTS] := ent^.client^.ps.stats[STAT_LAYOUTS] OR 1;
if (ent^.client^.showinventory) AND (ent^.client^.pers.health > 0) then
ent^.client^.ps.stats[STAT_LAYOUTS] := ent^.client^.ps.stats[STAT_LAYOUTS] OR 2;
end
else begin
if (ent^.client^.showscores OR ent^.client^.showhelp) then
ent^.client^.ps.stats[STAT_LAYOUTS] := ent^.client^.ps.stats[STAT_LAYOUTS] OR 1;
if (ent^.client^.showinventory) AND (ent^.client^.pers.health > 0) then
ent^.client^.ps.stats[STAT_LAYOUTS] := ent^.client^.ps.stats[STAT_LAYOUTS] OR 2;
end;
//
// frags
//
ent^.client^.ps.stats[STAT_FRAGS] := ent^.client^.resp.score;
//
// help icon / current weapon if not shown
//
{$IFDEF CTF}
if (ent^.client^.resp.helpchanged && (level.framenum&8) ) then
{$ELSE}
if (ent^.client^.pers.helpchanged <> 0) and ((level.framenum and 8) <> 0) then
{$ENDIF}
ent^.client^.ps.stats[STAT_HELPICON] := gi.imageindex ('i_help')
else if ((ent^.client^.pers.hand = CENTER_HANDED) OR (ent^.client^.ps.fov > 91)) and (ent^.client^.pers.weapon <> nil) then
ent^.client^.ps.stats[STAT_HELPICON] := gi.imageindex (ent^.client^.pers.weapon^.icon)
else
ent^.client^.ps.stats[STAT_HELPICON] := 0;
{$IFDEF CTF}
//ZOID
SetCTFStats(ent);
//ZOID
{$ELSE}
ent^.client^.ps.stats[STAT_SPECTATOR] := 0;
{$ENDIF}
end;
{$IFNDEF CTF}
{*
===============
G_CheckChaseStats
===============
*}
procedure G_CheckChaseStats (ent : edict_p);
var
i : integer;
cl : gclient_p;
begin
for i := 1 to Trunc(maxclients^.value) do
begin
cl := g_edicts^[i].client;
if (NOT g_edicts^[i].inuse) OR (cl^.chase_target <> ent) then
Continue;
memcpy(@cl^.ps.stats[0], @ent^.client^.ps.stats[0], sizeof(cl^.ps.stats));
G_SetSpectatorStats(@g_edicts^[i]);
end;
end;
{*
===============
G_SetSpectatorStats
===============
*}
procedure G_SetSpectatorStats (ent : edict_p);
var
cl : gclient_p;
begin
cl := ent^.client;
if (cl^.chase_target = Nil) then
G_SetStats (ent);
cl^.ps.stats[STAT_SPECTATOR] := 1;
// layouts are independant in spectator
cl^.ps.stats[STAT_LAYOUTS] := 0;
if (cl^.pers.health <= 0) OR (level.intermissiontime <> 0) OR (cl^.showscores) then
cl^.ps.stats[STAT_LAYOUTS] := cl^.ps.stats[STAT_LAYOUTS] OR 1;
if (cl^.showinventory) AND (cl^.pers.health > 0) then
cl^.ps.stats[STAT_LAYOUTS] := cl^.ps.stats[STAT_LAYOUTS] OR 2;
if (cl^.chase_target <> Nil) AND (cl^.chase_target^.inuse) then
cl^.ps.stats[STAT_CHASE] := CS_PLAYERSKINS + (Cardinal(cl^.chase_target) - Cardinal(g_edicts)) div SizeOf(edict_t) - 1
else
cl^.ps.stats[STAT_CHASE] := 0;
end;
{$ENDIF}
// End of file
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -