📄 p_client.pas
字号:
self.client.anim_end := FRAME_crdeath5;*)
end
else begin
Case i of
0: begin
(*Y self.s.frame := FRAME_death101-1;
self.client.anim_end := FRAME_death106;*)
end;
1: begin
(*Y self.s.frame := FRAME_death201-1;
self.client.anim_end := FRAME_death206;*)
end;
2: begin
(*Y self.s.frame := FRAME_death301-1;
self.client.anim_end := FRAME_death308;*)
end;
end;//case
end;
gi.sound (self, CHAN_VOICE,
gi.soundindex(va('*death%i.wav', [random(4)+1])),
1, ATTN_NORM, 0);
end;
end;//else
self.deadflag := DEAD_DEAD;
gi.linkentity (self);
end;//procedure (GAME <> CTF)
//=======================================================================
{*
==============
InitClientPersistant
This is only called when the game first initializes in single player,
but is called after each death and level change in deathmatch
==============
*}
// (GAME <> CTF)
procedure InitClientPersistant (client : gclient_p);
var
item : gitem_p;
begin
(*Y memset (&client->pers, 0, sizeof(client->pers));
item := FindItem('Blaster');
client.pers.selected_item := ITEM_INDEX(item);*)
client.pers.inventory[client.pers.selected_item] := 1;
client.pers.weapon := item;
{$IFDEF CTF} //onlyCTF
//ZOID
client.pers.lastweapon := item;
(*Y item := FindItem('Grapple');
client.pers.inventory[ITEM_INDEX(item)] := 1;*)
//ZOID
{$ENDIF}
client.pers.health := 100;
client.pers.max_health := 100;
client.pers.max_bullets := 200;
client.pers.max_shells := 100;
client.pers.max_rockets := 50;
client.pers.max_grenades := 50;
client.pers.max_cells := 200;
client.pers.max_slugs := 50;
client.pers.connected := true;
end;//procedure (GAME <> CTF)
// (GAME <> CTF)
procedure InitClientResp (client : gclient_p);
var
ctf_team : integer;
id_state : qboolean;
begin
{$IFDEF CTF} //onlyCTF
//ZOID
ctf_team := client.resp.ctf_team;
id_state := client.resp.id_state;
//ZOID
{$ENDIF}
//Y memset (&client->resp, 0, sizeof(client->resp));
{$IFDEF CTF} //onlyCTF
//ZOID
client.resp.ctf_team := ctf_team;
client.resp.id_state := id_state;
//ZOID
{$ENDIF}
client.resp.enterframe := level.framenum;
client.resp.coop_respawn := client.pers;
{$IFDEF CTF} //onlyCTF
(*Y//ZOID
if (ctf->value && client->resp.ctf_team < CTF_TEAM1) then
CTFAssignTeam(client);
//ZOID*)
{$ENDIF}
end;//procedure (GAME <> CTF)
{*
==================
SaveClientData
Some information that should be persistant, like health,
is still stored in the edict structure, so it needs to
be mirrored out to the client structure before all the
edicts are wiped.
==================
*}
// (GAME <> CTF)
procedure SaveClientData; //a few files
var
i : integer;
ent : edict_p;
begin
(*Y for i:=0 to game.maxclients-1 do
begin
ent := @g_edicts[1+i];
if (NOT ent.inuse) then
Continue;
game.clients[i].pers.health := ent.health;
game.clients[i].pers.max_health := ent.max_health;
{$IFDEF CTF}
game.clients[i].pers.powerArmorActive := (ent.flags AND FL_POWER_ARMOR);
{$ELSE}
game.clients[i].pers.savedFlags := (ent.flags AND (FL_GODMODE OR FL_NOTARGET OR FL_POWER_ARMOR));
{$ENDIF}
if (coop.value) then
game.clients[i].pers.score := ent.client.resp.score;
end;//for*)
end;//procedure (GAME <> CTF)
// (GAME <> CTF)
procedure FetchClientEntData (ent : edict_p);
begin
ent.health := ent.client.pers.health;
ent.max_health := ent.client.pers.max_health;
{$IFDEF CTF}
//Y if (ent.client.pers.powerArmorActive) then
ent.flags := ent.flags OR FL_POWER_ARMOR;
{$ELSE}
ent.flags := ent.flags OR ent.client.pers.savedFlags;
{$ENDIF}
if (coop.value <> 0) then
ent.client.resp.score := ent.client.pers.score;
end;//procedure (GAME <> CTF)
{*
=======================================================================
SelectSpawnPoint
=======================================================================
*}
{*
================
PlayersRangeFromSpot
Returns the distance to the nearest player from the given spot
================
*}
// (GAME=CTF)
//function PlayersRangeFromSpot (edict_t *spot) : float;
function PlayersRangeFromSpot (spot : edict_p) : float;
var
player : edict_p;
bestplayerdistance,
playerdistance : float;
v : vec3_t;
n : integer;
begin
bestplayerdistance := 9999999;
//Y for n:=1 to maxclients.value do
begin
player := @g_edicts[n];
(*Y if (NOT player.inuse) then
Continue;
if (player.health <= 0) then
Continue;*)
VectorSubtract (spot.s.origin, player.s.origin, v);
playerdistance := VectorLength (v);
if (playerdistance < bestplayerdistance) then
bestplayerdistance := playerdistance;
end;
Result := bestplayerdistance;
end;//procedure (GAME=CTF)
{*
================
SelectRandomDeathmatchSpawnPoint
go to a random point, but NOT the two points closest
to other players
================
*}
// (GAME=CTF)
function SelectRandomDeathmatchSpawnPoint : edict_p;
var
spot, spot1, spot2 : edict_p;
selection : integer;
range, range1, range2 : float;
// int count = 0;
count : integer;
begin
count := 0; //Y
spot := Nil;
// range1 = range2 = 99999;
range2 := 99999;
range1 := range2;
spot2 := Nil;
spot1 := spot2;
// while ((spot = G_Find (spot, FOFS(classname), 'info_player_deathmatch')) != NULL)
//Y spot := G_Find (spot, FOFS(classname), 'info_player_deathmatch'));
while (spot <> Nil) do
begin
Inc(count);
range := PlayersRangeFromSpot(spot);
if (range < range1)
then begin
range1 := range;
spot1 := spot;
end
else
if (range < range2) then
begin
range2 := range;
spot2 := spot;
end;
end;
if (count=0) then
begin
Result := Nil;
Exit;
end;
if (count <= 2)
then begin
spot2 := Nil;
spot1 := spot2;
end
else
Dec (count, 2);
// selection = rand() % count;
selection := random(count);
spot := Nil;
(* do
{
spot = G_Find (spot, FOFS(classname), 'info_player_deathmatch');
if (spot = spot1) OR (spot = spot2) then
selection++;
} while(selection--);
*)
repeat
//Y spot := G_Find (spot, FOFS(classname), 'info_player_deathmatch');
if (spot = spot1) OR (spot = spot2) then
Inc(selection);
Dec(selection);
until selection=0; //C2Pas ???
Result := spot;
end;//procedure (GAME=CTF)
{*
================
SelectFarthestDeathmatchSpawnPoint
================
*}
// (GAME=CTF)
function SelectFarthestDeathmatchSpawnPoint : edict_p;
var
bestspot, spot : edict_p;
bestdistance,
bestplayerdistance : float;
begin
spot := Nil;
bestspot := Nil;
bestdistance := 0;
// while ((spot = G_Find (spot, FOFS(classname), 'info_player_deathmatch')) != NULL)
//Y spot := G_Find (spot, FOFS(classname), 'info_player_deathmatch'));
while (spot <> Nil) do
begin
bestplayerdistance := PlayersRangeFromSpot (spot);
if (bestplayerdistance > bestdistance) then
begin
bestspot := spot;
bestdistance := bestplayerdistance;
end;
end;
if (bestspot <> Nil) then
begin
Result := bestspot;
Exit;
end;
// if there is a player just spawned on each and every start spot
// we have no choice to turn one into a telefrag meltdown
//Y spot := G_Find (NULL, FOFS(classname), 'info_player_deathmatch');
Result := spot;
end;//procedure (GAME=CTF)
// (GAME=CTF)
function SelectDeathmatchSpawnPoint : edict_p;
begin
// if ( (int)(dmflags->value) & DF_SPAWN_FARTHEST)
if (Trunc(dmflags.value) AND DF_SPAWN_FARTHEST) <> 0
then Result := SelectFarthestDeathmatchSpawnPoint ()
else Result := SelectRandomDeathmatchSpawnPoint ();
end;//procedure (GAME=CTF)
// (GAME=CTF)
function SelectCoopSpawnPoint (ent : edict_p) : edict_p;
var
index : integer;
target : PChar;
//edict_t *spot = NULL;
spot : edict_p;
begin
spot := Nil; //Y
//Y index := ent.client - game.clients;
// player 0 starts in normal player spawn point
if (index=0) then
begin
Result := Nil;
Exit;
end;
spot := Nil; //Y: 穆
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -