📄 g_main.pas
字号:
if (deathmatch.value = 0) then Exit;
{$IFDEF CTF}
//ZOID
if (ctf.value <> 0) and (CTFCheckRules) then
begin
EndDMLevel;
Exit;
end;
if CTFInMatch then
Exit; // no checking in match mode
//ZOID
{$ENDIF}
if (timelimit.value <> 0) then
begin
if (level.time >= timelimit.value*60) then
begin
gi_bprintf(PRINT_HIGH, 'Timelimit hit.'#10, []);
EndDMLevel;
Exit;
end;
end;
if (fraglimit.value <> 0) then
begin
for i := 0 to Round(maxclients.value) - 1 do
begin
// cl := game.clients + i;
cl := game.clients; Inc(cl, i);
if g_edicts[i+1].inuse then
Continue;
if (cl.resp.score >= fraglimit.value) then
begin
gi_bprintf(PRINT_HIGH, 'Fraglimit hit.'#10, []);
EndDMLevel;
Exit;
end;
end;
end;
end;
(*
=============
ExitLevel
=============
*)
procedure ExitLevel;
var
i: Integer;
ent: edict_p;
command: array [0..255] of Char;
begin
{$IFDEF CTF}
level.exitintermission := 0;
level.intermissiontime := 0;
if CTFNextMap then Exit;
{$ENDIF}
Com_sprintf(command, SizeOf(command), 'gamemap "%s"'#10, [level.changemap]);
gi.AddCommandString(command);
{$IFNDEF CTF}
level.changemap := nil;
level.exitintermission := 0;
level.intermissiontime := 0;
{$ENDIF}
ClientEndServerFrames;
{$IFDEF CTF}
level.changemap := nil;
{$ENDIF}
// clear some things before going to next level
for i := 0 to Round(maxclients.value) - 1 do
begin
ent := @g_edicts[1 + i];
if (not ent.inuse) then
Continue;
if (ent.health > ent.client.pers.max_health) then
ent.health := ent.client.pers.max_health;
end;
end;
(*
================
G_RunFrame
Advances the world by 0.1 seconds
================
*)
procedure G_RunFrame; cdecl;
var
i: Integer;
ent: edict_p;
begin
Inc(level.framenum);
level.time := level.framenum*FRAMETIME;
// choose a client for monsters to target this frame
AI_SetSightClient;
// exit intermissions
if (level.exitintermission <> 0) then
begin
ExitLevel;
Exit;
end;
//
// treat each object in turn
// even the world gets a chance to think
//
ent := @g_edicts[0];
for i := 0 to globals.num_edicts -1 do //; i++, ent++)
begin
if (not ent.inuse) then
begin
Inc(ent);
Continue;
end;
level.current_entity := ent;
VectorCopy(ent.s.origin, ent.s.old_origin);
// if the ground entity moved, make sure we are still on it
if (ent.groundentity <> nil) and
(ent.groundentity.linkcount <> ent.groundentity_linkcount) then
begin
ent.groundentity := nil;
if ((ent.flags and (FL_SWIM or FL_FLY)) = 0) and
((ent.svflags and SVF_MONSTER) <> 0) then
begin
M_CheckGround(ent);
end;
end;
if (i > 0) and (i <= maxclients.value) then
begin
ClientBeginServerFrame(ent);
Continue;
end;
G_RunEntity(ent);
end;
// see if it is time to end a deathmatch
CheckDMRules;
{$IFNDEF CTF}
// see if needpass needs updated
CheckNeedPass;
{$ENDIF}
// build the playerstate_t structures for all players
ClientEndServerFrames;
end;
end.
s
ClientEndServerFrames;
end;
end.
xit;
end;
//
// treat each object in turn
// even the world gets a chance to think
//
ent := @g_edicts[0];
for i := 0 to globals.num_edicts -1 do //; i++, ent++)
begin
if (not ent.inuse) then
begin
Inc(ent);
Continue;
end;
level.current_entity := ent;
VectorCopy(ent.s.origin, ent.s.old_origin);
// if the ground entity moved, make sure we are still on it
if (ent.groundentity <> nil) and
(ent.groundentity.linkcount <> ent.groundentity_linkcount) then
begin
ent.groundentity := nil;
if ((ent.flags and (FL_SWIM or FL_FLY)) = 0) and
((ent.svflags and SVF_MONSTER) <> 0) then
begin
M_CheckGround(ent);
end;
end;
if (i > 0) and (i <= maxclients.value) then
begin
ClientBeginServerFrame(ent);
Continue;
end;
G_RunEntity(ent);
end;
// see if it is time to end a deathmatch
CheckDMRules;
{$IFNDEF CTF}
// see if needpass needs updated
CheckNeedPass;
{$ENDIF}
// build the playerstate_t structures for all players
ClientEndServerFrames;
end;
end.
ng_ <> nil) and
(Q_stricmp(spectator_password.string_, 'none') <> 0)
then need := need or 2;
gi.cvar_set('needpass', va('%d', [need]));
end;
end;
{$ENDIF}
(*
=================
CheckDMRules
=================
*)
procedure CheckDMRules;
var
i: Integer;
cl: gclient_p;
begin
if (level.intermissiontime <> 0) then Exit;
if (deathmatch.value = 0) then Exit;
{$IFDEF CTF}
//ZOID
if (ctf.value <> 0) and (CTFCheckRules) then
begin
EndDMLevel;
Exit;
end;
if CTFInMatch then
Exit; // no checking in match mode
//ZOID
{$ENDIF}
if (timelimit.value <> 0) then
begin
if (level.time >= timelimit.value*60) then
begin
gi.bprintf(PRINT_HIGH, 'Timelimit hit.'#10, []);
EndDMLevel;
Exit;
end;
end;
if (fraglimit.value <> 0) then
begin
for i := 0 to Round(maxclients.value) - 1 do
begin
// cl := game.clients + i;
cl := game.clients; Inc(cl, i);
if g_edicts[i+1].inuse then
Continue;
if (cl.resp.score >= fraglimit.value) then
begin
gi.bprintf(PRINT_HIGH, 'Fraglimit hit.'#10, []);
EndDMLevel;
Exit;
end;
end;
end;
end;
(*
=============
ExitLevel
=============
*)
procedure ExitLevel;
var
i: Integer;
ent: edict_p;
command: array [0..255] of Char;
begin
{$IFDEF CTF}
level.exitintermission := 0;
level.intermissiontime := 0;
if CTFNextMap then Exit;
{$ENDIF}
Com_sprintf(command, SizeOf(command), 'gamemap "%s"'#10, [level.changemap]);
gi.AddCommandString(command);
{$IFNDEF CTF}
level.changemap := nil;
level.exitintermission := 0;
level.intermissiontime := 0;
{$ENDIF}
ClientEndServerFrames;
{$IFDEF CTF}
level.changemap := nil;
{$ENDIF}
// clear some things before going to next level
for i := 0 to Round(maxclients.value) - 1 do
begin
ent := @g_edicts[1 + i];
if (not ent.inuse) then
Continue;
if (ent.health > ent.client.pers.max_health) then
ent.health := ent.client.pers.max_health;
end;
end;
(*
================
G_RunFrame
Advances the world by 0.1 seconds
================
*)
procedure G_RunFrame;
var
i: Integer;
ent: edict_p;
begin
Inc(level.framenum);
level.time := level.framenum*FRAMETIME;
// choose a client for monsters to target this frame
AI_SetSightClient;
// exit intermissions
if (level.exitintermission <> 0) then
begin
ExitLevel;
Exit;
end;
//
// treat each object in turn
// even the world gets a chance to think
//
ent := @g_edicts[0];
for i := 0 to globals.num_edicts -1 do //; i++, ent++)
begin
if (not ent.inuse) then
begin
Inc(ent);
Continue;
end;
level.current_entity := ent;
VectorCopy(ent.s.origin, ent.s.old_origin);
// if the ground entity moved, make sure we are still on it
if (ent.groundentity <> nil) and
(ent.groundentity.linkcount <> ent.groundentity_linkcount) then
begin
ent.groundentity := nil;
if ((ent.flags and (FL_SWIM or FL_FLY)) = 0) and
((ent.svflags and SVF_MONSTER) <> 0) then
begin
M_CheckGround(ent);
end;
end;
if (i > 0) and (i <= maxclients.value) then
begin
ClientBeginServerFrame(ent);
Continue;
end;
G_RunEntity(ent);
end;
// see if it is time to end a deathmatch
CheckDMRules;
{$IFNDEF CTF}
// see if needpass needs updated
CheckNeedPass;
{$ENDIF}
// build the playerstate_t structures for all players
ClientEndServerFrames;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -