6 g_basic
, g_player
, e_graphics
, Classes
, g_res_downloader
,
7 SysUtils
, g_sound
, g_gui
, MAPSTRUCT
, WADEDITOR
, md5
;
10 TGameSettings
= record
26 TDelayedEvent
= record
34 TPlayerSettings
= record
53 function g_Game_IsNet(): Boolean;
54 function g_Game_IsServer(): Boolean;
55 function g_Game_IsClient(): Boolean;
56 procedure g_Game_Init();
57 procedure g_Game_Free();
58 procedure g_Game_LoadData();
59 procedure g_Game_FreeData();
60 procedure g_Game_Update();
61 procedure g_Game_Draw();
62 procedure g_Game_Quit();
63 procedure g_Game_SetupScreenSize();
64 procedure g_Game_ChangeResolution(newWidth
, newHeight
: Word; nowFull
, nowMax
: Boolean);
65 function g_Game_ModeToText(Mode
: Byte): string;
66 function g_Game_TextToMode(Mode
: string): Byte;
67 procedure g_Game_ExecuteEvent(Name
: String);
68 function g_Game_DelayEvent(DEType
: Byte; Time
: LongWord; Num
: Integer = 0; Str
: String = ''): Integer;
69 procedure g_Game_AddPlayer(Team
: Byte = TEAM_NONE
);
70 procedure g_Game_RemovePlayer();
71 procedure g_Game_Spectate();
72 procedure g_Game_SpectateCenterView();
73 procedure g_Game_StartSingle(Map
: String; TwoPlayers
: Boolean; nPlayers
: Byte);
74 procedure g_Game_StartCustom(Map
: String; GameMode
: Byte; TimeLimit
, GoalLimit
: Word; MaxLives
: Byte; Options
: LongWord; nPlayers
: Byte);
75 procedure g_Game_StartServer(Map
: String; GameMode
: Byte; TimeLimit
, GoalLimit
: Word; MaxLives
: Byte; Options
: LongWord; nPlayers
: Byte; IPAddr
: LongWord; Port
: Word);
76 procedure g_Game_StartClient(Addr
: String; Port
: Word; PW
: String);
77 procedure g_Game_Restart();
78 procedure g_Game_RestartLevel();
79 procedure g_Game_RestartRound(NoMapRestart
: Boolean = False);
80 procedure g_Game_ClientWAD(NewWAD
: String; WHash
: TMD5Digest
);
81 procedure g_Game_SaveOptions();
82 function g_Game_StartMap(Map
: String; Force
: Boolean = False): Boolean;
83 procedure g_Game_ChangeMap(MapPath
: String);
84 procedure g_Game_ExitLevel(Map
: Char16
);
85 function g_Game_GetFirstMap(WAD
: String): String;
86 function g_Game_GetNextMap(): String;
87 procedure g_Game_NextLevel();
88 procedure g_Game_Pause(Enable
: Boolean);
89 procedure g_Game_InGameMenu(Show
: Boolean);
90 function g_Game_IsWatchedPlayer(UID
: Word): Boolean;
91 function g_Game_IsWatchedTeam(Team
: Byte): Boolean;
92 procedure g_Game_Message(Msg
: String; Time
: Word);
93 procedure g_Game_LoadMapList(FileName
: String);
94 procedure g_Game_PauseAllSounds(Enable
: Boolean);
95 procedure g_Game_StopAllSounds(all
: Boolean);
96 procedure g_Game_UpdateTriggerSounds();
97 function g_Game_GetMegaWADInfo(WAD
: String): TMegaWADInfo
;
98 procedure g_Game_Announce_GoodShot(SpawnerUID
: Word);
99 procedure g_Game_Announce_KillCombo(Param
: Integer);
100 procedure g_Game_StartVote(Command
, Initiator
: string);
101 procedure g_Game_CheckVote
;
102 procedure g_TakeScreenShot();
103 procedure g_FatalError(Text: String);
104 procedure g_SimpleError(Text: String);
105 function g_Game_IsTestMap(): Boolean;
106 procedure g_Game_DeleteTestMap();
107 procedure GameCVars(P
: SArray
);
108 procedure GameCommands(P
: SArray
);
109 procedure DebugCommands(P
: SArray
);
110 procedure g_Game_Process_Params
;
111 procedure g_Game_SetLoadingText(Text: String; Max
: Integer; reWrite
: Boolean);
112 procedure g_Game_StepLoading();
113 procedure g_Game_ClearLoading();
114 procedure g_Game_SetDebugMode();
115 procedure DrawLoadingStat();
117 { procedure SetWinPause(Enable: Boolean); }
122 LOADING_SHOW_STEP
= 100;
123 LOADING_INTERLINE
= 20;
138 MESSAGE_DIKEY
= WM_USER
+ 1;
143 EXIT_ENDLEVELSINGLE
= 4;
144 EXIT_ENDLEVELCUSTOM
= 5;
146 GAME_OPTION_RESERVED
= 1;
147 GAME_OPTION_TEAMDAMAGE
= 2;
148 GAME_OPTION_ALLOWEXIT
= 4;
149 GAME_OPTION_WEAPONSTAY
= 8;
150 GAME_OPTION_MONSTERS
= 16;
151 GAME_OPTION_BOTVSPLAYER
= 32;
152 GAME_OPTION_BOTVSMONSTER
= 64;
157 STATE_INTERCUSTOM
= 3;
158 STATE_INTERSINGLE
= 4;
164 LMS_RESPAWN_NONE
= 0;
165 LMS_RESPAWN_WARMUP
= 1;
166 LMS_RESPAWN_FINAL
= 2;
182 CONFIG_FILENAME
= 'Doom2DF.cfg';
183 LOG_FILENAME
= 'Doom2DF.log';
185 TEST_MAP_NAME
= '$$$_TEST_$$$';
187 STD_PLAYER_MODEL
= 'Doomer';
191 gGameSettings
: TGameSettings
;
192 gPlayer1Settings
: TPlayerSettings
;
193 gPlayer2Settings
: TPlayerSettings
;
195 gPlayerScreenSize
: TPoint
;
196 gPlayer1ScreenCoord
: TPoint
;
197 gPlayer2ScreenCoord
: TPoint
;
198 gPlayer1
: TPlayer
= nil;
199 gPlayer2
: TPlayer
= nil;
200 gPlayerDrawn
: TPlayer
= nil;
202 gSwitchGameMode
: Byte = GM_DM
;
203 gHearPoint1
, gHearPoint2
: THearPoint
;
204 gSoundEffectsDF
: Boolean = False;
205 gSoundTriggerTime
: Word = 0;
206 gAnnouncer
: Byte = ANNOUNCE_NONE
;
207 goodsnd
: array[0..3] of TPlayableSound
;
208 killsnd
: array[0..3] of TPlayableSound
;
209 gDefInterTime
: ShortInt = -1;
210 gInterEndTime
: LongWord = 0;
211 gInterTime
: LongWord = 0;
212 gServInterTime
: Byte = 0;
213 gGameStartTime
: LongWord = 0;
214 gTotalMonsters
: Integer = 0;
216 gShowTime
: Boolean = True;
217 gShowFPS
: Boolean = False;
218 gShowGoals
: Boolean = True;
219 gShowStat
: Boolean = True;
220 gShowKillMsg
: Boolean = True;
221 gShowLives
: Boolean = True;
222 gShowPing
: Boolean = False;
223 gShowMap
: Boolean = False;
225 gState
: Byte = STATE_NONE
;
227 sWidth
, sHeight
: Word;
228 gSpectMode
: Byte = SPECT_NONE
;
229 gSpectHUD
: Boolean = True;
230 gSpectKeyPress
: Boolean = False;
231 gSpectX
: Integer = 0;
232 gSpectY
: Integer = 0;
233 gSpectStep
: Byte = 8;
234 gSpectViewTwo
: Boolean = False;
235 gSpectPID1
: Integer = -1;
236 gSpectPID2
: Integer = -1;
237 gMusic
: TMusic
= nil;
238 gLoadGameMode
: Boolean;
239 gCheats
: Boolean = False;
240 gMapOnce
: Boolean = False;
241 gMapToDelete
: String;
242 gTempDelete
: Boolean = False;
243 gLastMap
: Boolean = False;
244 gWinPosX
, gWinPosY
: Integer;
245 gWinSizeX
, gWinSizeY
: Integer;
246 gWinFrameX
, gWinFrameY
, gWinCaption
: Integer;
247 gWinActive
: Boolean = False;
248 gResolutionChange
: Boolean = False;
249 gRC_Width
, gRC_Height
: Word;
250 gRC_FullScreen
, gRC_Maximized
: Boolean;
251 gLanguageChange
: Boolean = False;
252 gDebugMode
: Boolean = False;
253 g_debug_Sounds
: Boolean = False;
254 g_debug_Frames
: Boolean = False;
255 g_debug_WinMsgs
: Boolean = False;
256 g_debug_MonsterOff
: Boolean = False;
257 g_debug_BotAIOff
: Byte = 0;
258 g_debug_HealthBar
: Boolean = False;
259 g_Debug_Player
: Boolean = False;
260 gCoopMonstersKilled
: Word = 0;
261 gCoopSecretsFound
: Word = 0;
262 gCoopTotalMonstersKilled
: Word = 0;
263 gCoopTotalSecretsFound
: Word = 0;
264 gCoopTotalMonsters
: Word = 0;
265 gCoopTotalSecrets
: Word = 0;
266 gStatsOff
: Boolean = False;
267 gStatsPressed
: Boolean = False;
268 gExitByTrigger
: Boolean = False;
269 gNextMap
: String = '';
270 gLMSRespawn
: Byte = LMS_RESPAWN_NONE
;
271 gLMSRespawnTime
: Cardinal = 0;
272 gLMSSoftSpawn
: Boolean = False;
273 gMissionFailed
: Boolean = False;
274 gVoteInProgress
: Boolean = False;
275 gVotePassed
: Boolean = False;
276 gVoteCommand
: string = '';
277 gVoteTimer
: Cardinal = 0;
278 gVoteCmdTimer
: Cardinal = 0;
279 gVoteCount
: Integer = 0;
280 gVoteTimeout
: Cardinal = 30;
281 gVoted
: Boolean = False;
282 gVotesEnabled
: Boolean = True;
283 gEvents
: Array of TGameEvent
;
284 gDelayedEvents
: Array of TDelayedEvent
;
286 P1MoveButton
: Byte = 0;
287 P2MoveButton
: Byte = 0;
292 g_textures
, g_main
, g_window
, g_menu
,
293 e_input
, e_log
, g_console
, g_items
, g_map
,
294 g_playermodel
, g_gfx
, g_options
, g_weapons
, Math
,
295 g_triggers
, MAPDEF
, g_monsters
, e_sound
, CONFIG
,
296 BinEditor
, g_language
, g_net
, SDL
,
297 ENet
, e_fixedbuffer
, g_netmsg
, g_netmaster
, GL
, GLExt
;
300 TEndCustomGameStat
= record
301 PlayerStat
: TPlayerStatArray
;
305 Map
, MapName
: String;
308 TEndSingleGameStat
= record
309 PlayerStat
: Array [0..1] of record
315 TotalSecrets
: Integer;
318 TLoadingStat
= record
322 Msgs
: Array of String;
326 TParamStrValue
= record
331 TParamStrValues
= Array of TParamStrValue
;
334 INTER_ACTION_TEXT
= 1;
335 INTER_ACTION_PIC
= 2;
336 INTER_ACTION_MUSIC
= 3;
340 FPSCounter
, UPSCounter
: Word;
341 FPSTime
, UPSTime
: LongWord;
342 DataLoaded
: Boolean = False;
343 LastScreenShot
: Int64;
344 IsDrawStat
: Boolean = False;
345 CustomStat
: TEndCustomGameStat
;
346 SingleStat
: TEndSingleGameStat
;
347 LoadingStat
: TLoadingStat
;
348 EndingGameCounter
: Byte = 0;
351 MapList
: SArray
= nil;
352 MapIndex
: Integer = -1;
358 text: Array of ShortString;
359 anim
: Array of ShortString;
360 pic
: Array of ShortString;
361 mus
: Array of ShortString;
363 triggers
: Array of record
365 actions
: Array of record
366 action
, p1
, p2
: Integer;
369 cur_trigger
: Integer;
382 function Compare(a
, b
: TPlayerStat
): Integer;
384 if a
.Spectator
then Result
:= 1
385 else if b
.Spectator
then Result
:= -1
386 else if a
.Frags
< b
.Frags
then Result
:= 1
387 else if a
.Frags
> b
.Frags
then Result
:= -1
388 else if a
.Deaths
< b
.Deaths
then Result
:= -1
389 else if a
.Deaths
> b
.Deaths
then Result
:= 1
390 else if a
.Kills
< b
.Kills
then Result
:= -1
394 procedure SortGameStat(var stat
: TPlayerStatArray
);
399 if stat
= nil then Exit
;
401 for I
:= High(stat
) downto Low(stat
) do
402 for J
:= Low(stat
) to High(stat
) - 1 do
403 if Compare(stat
[J
], stat
[J
+ 1]) = 1 then
406 stat
[J
] := stat
[J
+ 1];
411 function g_Game_ModeToText(Mode
: Byte): string;
415 GM_DM
: Result
:= _lc
[I_MENU_GAME_TYPE_DM
];
416 GM_TDM
: Result
:= _lc
[I_MENU_GAME_TYPE_TDM
];
417 GM_CTF
: Result
:= _lc
[I_MENU_GAME_TYPE_CTF
];
418 GM_COOP
: Result
:= _lc
[I_MENU_GAME_TYPE_COOP
];
419 GM_SINGLE
: Result
:= _lc
[I_MENU_GAME_TYPE_SINGLE
];
423 function g_Game_TextToMode(Mode
: string): Byte;
426 Mode
:= UpperCase(Mode
);
427 if Mode
= _lc
[I_MENU_GAME_TYPE_DM
] then
432 if Mode
= _lc
[I_MENU_GAME_TYPE_TDM
] then
437 if Mode
= _lc
[I_MENU_GAME_TYPE_CTF
] then
442 if Mode
= _lc
[I_MENU_GAME_TYPE_COOP
] then
447 if Mode
= _lc
[I_MENU_GAME_TYPE_SINGLE
] then
454 function g_Game_IsNet(): Boolean;
456 Result
:= (gGameSettings
.GameType
in [GT_SERVER
, GT_CLIENT
]);
459 function g_Game_IsServer(): Boolean;
461 Result
:= (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
, GT_SERVER
]);
464 function g_Game_IsClient(): Boolean;
466 Result
:= (gGameSettings
.GameType
= GT_CLIENT
);
469 function g_Game_GetMegaWADInfo(WAD
: String): TMegaWADInfo
;
476 Result
.name
:= ExtractFileName(WAD
);
477 Result
.description
:= '';
480 w
:= TWADEditor_1
.Create();
483 if not w
.GetResource('', 'INTERSCRIPT', p
, len
) then
489 cfg
:= TConfig
.CreateMem(p
, len
);
490 Result
.name
:= cfg
.ReadStr('megawad', 'name', ExtractFileName(WAD
));
491 Result
.description
:= cfg
.ReadStr('megawad', 'description', '');
492 Result
.author
:= cfg
.ReadStr('megawad', 'author', '');
493 Result
.pic
:= cfg
.ReadStr('megawad', 'pic', '');
499 procedure g_Game_FreeWAD();
503 for a
:= 0 to High(MegaWAD
.res
.pic
) do
504 if MegaWAD
.res
.pic
[a
] <> '' then
505 g_Texture_Delete(MegaWAD
.res
.pic
[a
]);
507 for a
:= 0 to High(MegaWAD
.res
.mus
) do
508 if MegaWAD
.res
.mus
[a
] <> '' then
509 g_Sound_Delete(MegaWAD
.res
.mus
[a
]);
511 MegaWAD
.res
.pic
:= nil;
512 MegaWAD
.res
.text := nil;
513 MegaWAD
.res
.anim
:= nil;
514 MegaWAD
.res
.mus
:= nil;
515 MegaWAD
.triggers
:= nil;
517 g_Texture_Delete('TEXTURE_endpic');
518 g_Sound_Delete('MUSIC_endmus');
520 ZeroMemory(@MegaWAD
, SizeOf(MegaWAD
));
521 gGameSettings
.WAD
:= '';
524 procedure g_Game_LoadWAD(WAD
: string);
533 gGameSettings
.WAD
:= WAD
;
534 if not (gGameSettings
.GameMode
in [GM_COOP
, GM_SINGLE
]) then
537 MegaWAD
.info
:= g_Game_GetMegaWADInfo(MapsDir
+ WAD
);
539 w
:= TWADEditor_1
.Create();
540 w
.ReadFile(MapsDir
+ WAD
);
542 if not w
.GetResource('', 'INTERSCRIPT', p
, len
) then
548 cfg
:= TConfig
.CreateMem(p
, len
);
553 s := cfg.ReadStr('pic', 'pic'+IntToStr(b), '');
554 if s = '' then Break;
557 SetLength(MegaWAD.res.pic, Length(MegaWAD.res.pic)+1);
558 MegaWAD.res.pic[High(MegaWAD.res.pic)] := s;
560 g_Texture_CreateWADEx(s, s);
566 s := cfg.ReadStr('mus', 'mus'+IntToStr(b), '');
567 if s = '' then Break;
570 SetLength(MegaWAD.res.mus, Length(MegaWAD.res.mus)+1);
571 MegaWAD.res.mus[High(MegaWAD.res.mus)] := s;
573 g_Music_CreateWADEx(s, s);
576 MegaWAD
.endpic
:= cfg
.ReadStr('megawad', 'endpic', '');
577 if MegaWAD
.endpic
<> '' then
579 g_ProcessResourceStr(MegaWAD
.endpic
, @s
, nil, nil);
580 if s
= '' then s
:= MapsDir
+WAD
else s
:= GameDir
+'/wads/';
581 g_Texture_CreateWADEx('TEXTURE_endpic', s
+MegaWAD
.endpic
);
583 MegaWAD
.endmus
:= cfg
.ReadStr('megawad', 'endmus', 'Standart.wad:D2DMUS\ÊÎÍÅÖ');
584 if MegaWAD
.endmus
<> '' then
586 g_ProcessResourceStr(MegaWAD
.endmus
, @s
, nil, nil);
587 if s
= '' then s
:= MapsDir
+WAD
else s
:= GameDir
+'/wads/';
588 g_Sound_CreateWADEx('MUSIC_endmus', s
+MegaWAD
.endmus
, True);
596 {procedure start_trigger(t: string);
600 function next_trigger(): Boolean;
604 procedure DisableCheats();
610 if gPlayer1
<> nil then gPlayer1
.GodMode
:= False;
611 if gPlayer2
<> nil then gPlayer2
.GodMode
:= False;
612 if gPlayer1
<> nil then gPlayer1
.NoTarget
:= False;
613 if gPlayer2
<> nil then gPlayer2
.NoTarget
:= False;
616 procedure g_Game_ExecuteEvent(Name
: String);
622 if gEvents
= nil then
624 for a
:= 0 to High(gEvents
) do
625 if gEvents
[a
].Name
= Name
then
627 if gEvents
[a
].Command
<> '' then
628 g_Console_Process(gEvents
[a
].Command
, True);
633 function g_Game_DelayEvent(DEType
: Byte; Time
: LongWord; Num
: Integer = 0; Str
: String = ''): Integer;
638 if gDelayedEvents
<> nil then
639 for a
:= 0 to High(gDelayedEvents
) do
640 if not gDelayedEvents
[a
].Pending
then
647 SetLength(gDelayedEvents
, Length(gDelayedEvents
) + 1);
648 n
:= High(gDelayedEvents
);
650 gDelayedEvents
[n
].Pending
:= True;
651 gDelayedEvents
[n
].DEType
:= DEType
;
652 gDelayedEvents
[n
].DENum
:= Num
;
653 gDelayedEvents
[n
].DEStr
:= Str
;
654 if DEType
= DE_GLOBEVENT
then
655 gDelayedEvents
[n
].Time
:= (GetTimer() div 1000) + Time
657 gDelayedEvents
[n
].Time
:= gTime
+ Time
;
664 FileName
, SectionName
, ResName
: string;
666 if g_Game_IsNet
and g_Game_IsServer
then
667 MH_SEND_GameEvent(NET_EV_MAPEND
, Byte(gMissionFailed
));
673 g_Game_StopAllSounds(False);
678 EndingGameCounter
:= 0;
679 g_ActiveWindow
:= nil;
681 gLMSRespawn
:= LMS_RESPAWN_NONE
;
682 gLMSRespawnTime
:= 0;
685 EXIT_SIMPLE
: // Âûõîä ÷åðåç ìåíþ èëè êîíåö òåñòà
690 begin // Ýòî áûë òåñò
694 begin // Âûõîä â ãëàâíîå ìåíþ
695 gMusic
.SetByName('MUSIC_MENU');
697 if gState
<> STATE_SLIST
then
699 g_GUI_ShowWindow('MainMenu');
700 gState
:= STATE_MENU
;
703 // Îáíîâëÿåì ñïèñîê ñåðâåðîâ
704 slReturnPressed
:= True;
705 if g_Net_Slist_Fetch(slCurrent
) then
707 if slCurrent
= nil then
708 slWaitStr
:= _lc
[I_NET_SLIST_NOSERVERS
];
711 slWaitStr
:= _lc
[I_NET_SLIST_ERROR
];
714 g_Game_ExecuteEvent('ongameend');
718 EXIT_RESTART
: // Íà÷àòü óðîâåíü ñíà÷àëà
720 if not g_Game_IsClient
then g_Game_Restart();
723 EXIT_ENDLEVELCUSTOM
: // Çàêîí÷èëñÿ óðîâåíü â Ñâîåé èãðå
725 // Ñòàòèñòèêà Ñâîåé èãðû:
726 g_ProcessResourceStr(gMapInfo
.Map
, FileName
, SectionName
, ResName
);
728 CustomStat
.GameTime
:= gTime
;
729 CustomStat
.Map
:= ExtractFileName(FileName
)+':'+ResName
;
730 CustomStat
.MapName
:= gMapInfo
.Name
;
731 CustomStat
.GameMode
:= gGameSettings
.GameMode
;
732 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
733 CustomStat
.TeamStat
:= gTeamStat
;
735 CustomStat
.PlayerStat
:= nil;
737 // Ñòàòèñòèêà èãðîêîâ:
738 if gPlayers
<> nil then
740 for a
:= 0 to High(gPlayers
) do
741 if gPlayers
[a
] <> nil then
743 SetLength(CustomStat
.PlayerStat
, Length(CustomStat
.PlayerStat
)+1);
744 with CustomStat
.PlayerStat
[High(CustomStat
.PlayerStat
)] do
746 Name
:= gPlayers
[a
].Name
;
747 Frags
:= gPlayers
[a
].Frags
;
748 Deaths
:= gPlayers
[a
].Death
;
749 Kills
:= gPlayers
[a
].Kills
;
750 Team
:= gPlayers
[a
].Team
;
751 Color
:= gPlayers
[a
].Model
.Color
;
752 Spectator
:= gPlayers
[a
].FSpectator
;
756 SortGameStat(CustomStat
.PlayerStat
);
759 g_Game_ExecuteEvent('onmapend');
762 EndingGameCounter
:= 255;
763 gState
:= STATE_FOLD
;
765 if gDefInterTime
< 0 then
766 gInterEndTime
:= IfThen((gGameSettings
.GameType
= GT_SERVER
) and (gPlayer1
= nil), 15000, 25000)
768 gInterEndTime
:= gDefInterTime
* 1000;
771 EXIT_ENDLEVELSINGLE
: // Çàêîí÷èëñÿ óðîâåíü â Îäèíî÷íîé èãðå
773 // Ñòàòèñòèêà Îäèíî÷íîé èãðû:
774 SingleStat
.GameTime
:= gTime
;
775 SingleStat
.TwoPlayers
:= gPlayer2
<> nil;
776 SingleStat
.TotalSecrets
:= gSecretsCount
;
777 // Ñòàòèñòèêà ïåðâîãî èãðîêà:
778 SingleStat
.PlayerStat
[0].Kills
:= gPlayer1
.MonsterKills
;
779 SingleStat
.PlayerStat
[0].Secrets
:= gPlayer1
.Secrets
;
780 // Ñòàòèñòèêà âòîðîãî èãðîêà (åñëè åñòü):
781 if SingleStat
.TwoPlayers
then
783 SingleStat
.PlayerStat
[1].Kills
:= gPlayer2
.MonsterKills
;
784 SingleStat
.PlayerStat
[1].Secrets
:= gPlayer2
.Secrets
;
787 g_Game_ExecuteEvent('onmapend');
790 if gNextMap
<> '' then
792 gMusic
.SetByName('MUSIC_INTERMUS');
794 gState
:= STATE_INTERSINGLE
;
796 g_Game_ExecuteEvent('oninter');
798 else // Áîëüøå íåò êàðò
801 EndingGameCounter
:= 255;
802 gState
:= STATE_FOLD
;
807 // Îêîí÷àíèå îáðàáîòàíî:
808 if gExit
<> EXIT_QUIT
then
812 procedure DrawStat();
814 pc
, x
, y
, w
, h
: Integer;
815 w1
, w2
, w3
, w4
: Integer;
817 cw
, ch
, r
, g
, b
, rr
, gg
, bb
: Byte;
820 stat
: TPlayerStatArray
;
827 pc
:= g_Player_GetCount
;
828 e_TextureFontGetSize(gStdFont
, cw
, ch
);
830 w
:= gScreenWidth
-(gScreenWidth
div 5);
831 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
834 h
:= 40+ch
*5+(ch
+8)*pc
;
835 x
:= (gScreenWidth
div 2)-(w
div 2);
836 y
:= (gScreenHeight
div 2)-(h
div 2);
838 e_DrawFillQuad(x
, y
, x
+w
-1, y
+h
-1, 64, 64, 64, 32);
839 e_DrawQuad(x
, y
, x
+w
-1, y
+h
-1, 255, 127, 0);
841 g_ProcessResourceStr(gMapInfo
.Map
, @wad
, nil, @map
);
842 wad
:= ExtractFileName(wad
);
843 mapstr
:= wad
+ ':\' + map
+ ' - ' + gMapInfo
.Name
;
845 case gGameSettings
.GameMode
of
848 if gGameSettings
.MaxLives
= 0 then
851 s1
:= _lc
[I_GAME_LMS
];
852 s2
:= Format(_lc
[I_GAME_FRAG_LIMIT
], [gGameSettings
.GoalLimit
]);
853 s3
:= Format(_lc
[I_GAME_TIME_LIMIT
], [gGameSettings
.TimeLimit
div 3600, (gGameSettings
.TimeLimit
div 60) mod 60, gGameSettings
.TimeLimit
mod 60]);
858 if gGameSettings
.MaxLives
= 0 then
859 s1
:= _lc
[I_GAME_TDM
]
861 s1
:= _lc
[I_GAME_TLMS
];
862 s2
:= Format(_lc
[I_GAME_FRAG_LIMIT
], [gGameSettings
.GoalLimit
]);
863 s3
:= Format(_lc
[I_GAME_TIME_LIMIT
], [gGameSettings
.TimeLimit
div 3600, (gGameSettings
.TimeLimit
div 60) mod 60, gGameSettings
.TimeLimit
mod 60]);
868 s1
:= _lc
[I_GAME_CTF
];
869 s2
:= Format(_lc
[I_GAME_SCORE_LIMIT
], [gGameSettings
.GoalLimit
]);
870 s3
:= Format(_lc
[I_GAME_TIME_LIMIT
], [gGameSettings
.TimeLimit
div 3600, (gGameSettings
.TimeLimit
div 60) mod 60, gGameSettings
.TimeLimit
mod 60]);
875 if gGameSettings
.MaxLives
= 0 then
876 s1
:= _lc
[I_GAME_COOP
]
878 s1
:= _lc
[I_GAME_SURV
];
879 s2
:= _lc
[I_GAME_MONSTERS
] + ' ' + IntToStr(gCoopMonstersKilled
) + '/' + IntToStr(gTotalMonsters
);
880 s3
:= _lc
[I_GAME_SECRETS
] + ' ' + IntToStr(gCoopSecretsFound
) + '/' + IntToStr(gSecretsCount
);
891 e_TextureFontPrintEx(x
+(w
div 2)-(Length(s1
)*cw
div 2), _y
, s1
, gStdFont
, 255, 255, 255, 1);
893 e_TextureFontPrintEx(x
+(w
div 2)-(Length(mapstr
)*cw
div 2), _y
, mapstr
, gStdFont
, 200, 200, 200, 1);
895 e_TextureFontPrintEx(x
+16, _y
, s2
, gStdFont
, 200, 200, 200, 1);
897 e_TextureFontPrintEx(x
+w
-16-(Length(s3
))*cw
, _y
, s3
,
898 gStdFont
, 200, 200, 200, 1);
900 if NetMode
= NET_SERVER
then
901 e_TextureFontPrintEx(x
+8, y
+ 8, _lc
[I_NET_SERVER
], gStdFont
, 255, 255, 255, 1)
903 if NetMode
= NET_CLIENT
then
904 e_TextureFontPrintEx(x
+8, y
+ 8,
905 NetClientIP
+ ':' + IntToStr(NetClientPort
), gStdFont
, 255, 255, 255, 1);
909 stat
:= g_Player_GetStats();
912 w2
:= (w
-16) div 6 + 48; // øèðèíà 2 ñòîëáöà
913 w3
:= (w
-16) div 6; // øèðèíà 3 è 4 ñòîëáöîâ
915 w1
:= w
-16-w2
-w3
-w4
; // îñòàâøååñÿ ïðîñòðàíñòâî - äëÿ öâåòà è èìåíè èãðîêà
917 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
921 for a
:= TEAM_RED
to TEAM_BLUE
do
925 s1
:= _lc
[I_GAME_TEAM_RED
];
932 s1
:= _lc
[I_GAME_TEAM_BLUE
];
938 e_TextureFontPrintEx(x
+16, _y
, s1
, gStdFont
, r
, g
, b
, 1);
939 e_TextureFontPrintEx(x
+w1
+16, _y
, IntToStr(gTeamStat
[a
].Goals
),
940 gStdFont
, r
, g
, b
, 1);
942 _y
:= _y
+ch
+(ch
div 4);
943 e_DrawLine(1, x
+16, _y
, x
+w
-16, _y
, r
, g
, b
);
946 for aa
:= 0 to High(stat
) do
947 if stat
[aa
].Team
= a
then
963 e_TextureFontPrintEx(x
+16, _y
, Name
, gStdFont
, rr
, gg
, bb
, 1);
965 e_TextureFontPrintEx(x
+w1
+16, _y
, Format(_lc
[I_GAME_PING_MS
], [Ping
, Loss
]), gStdFont
, rr
, gg
, bb
, 1);
967 e_TextureFontPrintEx(x
+w1
+w2
+16, _y
, IntToStr(Frags
), gStdFont
, rr
, gg
, bb
, 1);
969 e_TextureFontPrintEx(x
+w1
+w2
+w3
+16, _y
, IntToStr(Deaths
), gStdFont
, rr
, gg
, bb
, 1);
976 else if gGameSettings
.GameMode
in [GM_DM
, GM_COOP
] then
979 e_TextureFontPrintEx(x
+16, _y
, _lc
[I_GAME_PLAYER_NAME
], gStdFont
, 255, 127, 0, 1);
980 e_TextureFontPrintEx(x
+16+w1
, _y
, _lc
[I_GAME_PING
], gStdFont
, 255, 127, 0, 1);
981 e_TextureFontPrintEx(x
+16+w1
+w2
, _y
, _lc
[I_GAME_FRAGS
], gStdFont
, 255, 127, 0, 1);
982 e_TextureFontPrintEx(x
+16+w1
+w2
+w3
, _y
, _lc
[I_GAME_DEATHS
], gStdFont
, 255, 127, 0, 1);
985 for aa
:= 0 to High(stat
) do
999 e_DrawFillQuad(x
+16, _y
+4, x
+32-1, _y
+16+4-1, Color
.R
, Color
.G
, Color
.B
, 0);
1000 e_DrawQuad(x
+16, _y
+4, x
+32-1, _y
+16+4-1, 192, 192, 192);
1002 e_TextureFontPrintEx(x
+16+16+8, _y
+4, Name
, gStdFont
, r
, g
, 0, 1);
1004 e_TextureFontPrintEx(x
+w1
+16, _y
+4, Format(_lc
[I_GAME_PING_MS
], [Ping
, Loss
]), gStdFont
, r
, g
, 0, 1);
1006 e_TextureFontPrintEx(x
+w1
+w2
+16, _y
+4, IntToStr(Frags
), gStdFont
, r
, g
, 0, 1);
1008 e_TextureFontPrintEx(x
+w1
+w2
+w3
+16, _y
+4, IntToStr(Deaths
), gStdFont
, r
, g
, 0, 1);
1014 procedure g_Game_Init();
1020 gTempDelete
:= False;
1022 g_Texture_CreateWADEx('MENU_BACKGROUND', GameWAD
+':TEXTURES\TITLE');
1023 g_Texture_CreateWADEx('INTER', GameWAD
+':TEXTURES\INTER');
1024 g_Texture_CreateWADEx('ENDGAME_EN', GameWAD
+':TEXTURES\ENDGAME_EN');
1025 g_Texture_CreateWADEx('ENDGAME_RU', GameWAD
+':TEXTURES\ENDGAME_RU');
1027 LoadStdFont('STDTXT', 'STDFONT', gStdFont
);
1028 LoadFont('MENUTXT', 'MENUFONT', gMenuFont
);
1029 LoadFont('SMALLTXT', 'SMALLFONT', gMenuSmallFont
);
1031 g_Game_ClearLoading();
1032 g_Game_SetLoadingText(Format('Doom 2D: Forever %s', [GAME_VERSION
]), 0, False);
1033 g_Game_SetLoadingText('', 0, False);
1035 g_Game_SetLoadingText(_lc
[I_LOAD_CONSOLE
], 0, False);
1038 g_Game_SetLoadingText(_lc
[I_LOAD_MODELS
], 0, False);
1039 g_PlayerModel_LoadData();
1041 if FindFirst(ModelsDir
+'*.wad', faAnyFile
, SR
) = 0 then
1043 if not g_PlayerModel_Load(ModelsDir
+SR
.Name
) then
1044 e_WriteLog(Format('Error loading model %s', [SR
.Name
]), MSG_WARNING
);
1045 until FindNext(SR
) <> 0;
1051 LastScreenShot
:= 0;
1053 {e_MouseInfo.Accel := 1.0;}
1055 g_Game_SetLoadingText(_lc
[I_LOAD_GAME_DATA
], 0, False);
1058 g_Game_SetLoadingText(_lc
[I_LOAD_MUSIC
], 0, False);
1059 g_Sound_CreateWADEx('MUSIC_INTERMUS', GameWAD
+':MUSIC\INTERMUS', True);
1060 g_Sound_CreateWADEx('MUSIC_MENU', GameWAD
+':MUSIC\MENU', True);
1061 g_Sound_CreateWADEx('MUSIC_ROUNDMUS', GameWAD
+':MUSIC\ROUNDMUS', True);
1062 g_Sound_CreateWADEx('MUSIC_STDENDMUS', GameWAD
+':MUSIC\ENDMUS', True);
1064 g_Game_SetLoadingText(_lc
[I_LOAD_MENUS
], 0, False);
1067 gMusic
:= TMusic
.Create();
1068 gMusic
.SetByName('MUSIC_MENU');
1071 gGameSettings
.WarmupTime
:= 30;
1073 gState
:= STATE_MENU
;
1075 SetLength(gEvents
, 6);
1076 gEvents
[0].Name
:= 'ongamestart';
1077 gEvents
[1].Name
:= 'ongameend';
1078 gEvents
[2].Name
:= 'onmapstart';
1079 gEvents
[3].Name
:= 'onmapend';
1080 gEvents
[4].Name
:= 'oninter';
1081 gEvents
[5].Name
:= 'onwadend';
1084 procedure g_Game_Free();
1086 if NetMode
= NET_CLIENT
then g_Net_Disconnect();
1087 if NetMode
= NET_SERVER
then g_Net_Host_Die();
1091 g_Player_RemoveAllCorpses();
1093 gGameSettings
.GameType
:= GT_NONE
;
1094 if gGameSettings
.GameMode
= GM_SINGLE
then
1095 gGameSettings
.GameMode
:= GM_DM
;
1096 gSwitchGameMode
:= gGameSettings
.GameMode
;
1099 gExitByTrigger
:= False;
1102 function IsActivePlayer(p
: TPlayer
): Boolean;
1107 Result
:= (not p
.FDummy
) and (not p
.FSpectator
);
1110 function GetActivePlayer_ByID(ID
: Integer): TPlayer
;
1117 if gPlayers
= nil then
1119 for a
:= Low(gPlayers
) to High(gPlayers
) do
1120 if IsActivePlayer(gPlayers
[a
]) then
1122 if gPlayers
[a
].UID
<> ID
then
1124 Result
:= gPlayers
[a
];
1129 function GetActivePlayerID_Next(Skip
: Integer = -1): Integer;
1135 if gPlayers
= nil then
1139 for a
:= Low(gPlayers
) to High(gPlayers
) do
1140 if IsActivePlayer(gPlayers
[a
]) then
1142 SetLength(ids
, Length(ids
) + 1);
1143 ids
[High(ids
)] := gPlayers
[a
].UID
;
1144 if gPlayers
[a
].UID
= Skip
then
1147 if Length(ids
) = 0 then
1152 Result
:= ids
[(idx
+ 1) mod Length(ids
)];
1155 function GetActivePlayerID_Prev(Skip
: Integer = -1): Integer;
1161 if gPlayers
= nil then
1165 for a
:= Low(gPlayers
) to High(gPlayers
) do
1166 if IsActivePlayer(gPlayers
[a
]) then
1168 SetLength(ids
, Length(ids
) + 1);
1169 ids
[High(ids
)] := gPlayers
[a
].UID
;
1170 if gPlayers
[a
].UID
= Skip
then
1173 if Length(ids
) = 0 then
1176 Result
:= ids
[Length(ids
) - 1]
1178 Result
:= ids
[(Length(ids
) - 1 + idx
) mod Length(ids
)];
1181 procedure g_Game_Update();
1183 Msg
: g_gui
.TMessage
;
1189 // Ïîðà âûêëþ÷àòü èãðó:
1190 if gExit
= EXIT_QUIT
then
1192 // Èãðà çàêîí÷èëàñü - îáðàáàòûâàåì:
1196 if gExit
= EXIT_QUIT
then
1200 // ×èòàåì êëàâèàòóðó è äæîéñòèê, åñëè îêíî àêòèâíî:
1203 // Îáíîâëÿåì êîíñîëü (äâèæåíèå è ñîîáùåíèÿ):
1206 if (NetMode
= NET_NONE
) and (g_Game_IsNet
) and (gGameOn
or (gState
in [STATE_FOLD
, STATE_INTERCUSTOM
])) then
1208 gExit
:= EXIT_SIMPLE
;
1214 STATE_INTERSINGLE
, // Ñòàòèñòêà ïîñëå ïðîõîæäåíèÿ óðîâíÿ â Îäèíî÷íîé èãðå
1215 STATE_INTERCUSTOM
, // Ñòàòèñòêà ïîñëå ïðîõîæäåíèÿ óðîâíÿ â Ñâîåé èãðå
1216 STATE_INTERTEXT
, // Òåêñò ìåæäó óðîâíÿìè
1217 STATE_INTERPIC
: // Êàðòèíêà ìåæäó óðîâíÿìè
1219 if g_Game_IsNet
and g_Game_IsServer
then
1221 gInterTime
:= gInterTime
+ GAME_TICK
;
1222 a
:= Min((gInterEndTime
- gInterTime
) div 1000 + 1, 255);
1223 if a
<> gServInterTime
then
1225 gServInterTime
:= a
;
1226 MH_SEND_TimeSync(gServInterTime
);
1230 if (not g_Game_IsClient
) and
1233 (e_KeyPressed(IK_RETURN
) or e_KeyPressed(IK_KPRETURN
) or e_KeyPressed(IK_SPACE
))
1234 and (not gJustChatted
) and (not gConsoleShow
) and (not gChatShow
)
1235 and (g_ActiveWindow
= nil)
1237 or (g_Game_IsNet
and (gInterTime
> gInterEndTime
))
1240 begin // Íàæàëè <Enter>/<Ïðîáåë> èëè ïðîøëî äîñòàòî÷íî âðåìåíè:
1241 g_Game_StopAllSounds(True);
1243 if gMapOnce
then // Ýòî áûë òåñò
1244 gExit
:= EXIT_SIMPLE
1246 if gNextMap
<> '' then // Ïåðåõîäèì íà ñëåäóþùóþ êàðòó
1247 g_Game_ChangeMap(gNextMap
)
1248 else // Ñëåäóþùåé êàðòû íåò
1250 if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
] then
1252 // Âûõîä â ãëàâíîå ìåíþ:
1254 g_GUI_ShowWindow('MainMenu');
1255 gMusic
.SetByName('MUSIC_MENU');
1257 gState
:= STATE_MENU
;
1260 // Ôèíàëüíàÿ êàðòèíêà:
1261 g_Game_ExecuteEvent('onwadend');
1263 if not gMusic
.SetByName('MUSIC_endmus') then
1264 gMusic
.SetByName('MUSIC_STDENDMUS');
1266 gState
:= STATE_ENDPIC
;
1268 g_Game_ExecuteEvent('ongameend');
1274 if gState
= STATE_INTERTEXT
then
1275 if InterText
.counter
> 0 then
1276 InterText
.counter
:= InterText
.counter
- 1;
1279 STATE_FOLD
: // Çàòóõàíèå ýêðàíà
1281 if EndingGameCounter
= 0 then
1283 // Çàêîí÷èëñÿ óðîâåíü â Ñâîåé èãðå:
1284 if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
1286 if gLastMap
and (gGameSettings
.GameMode
= GM_COOP
) then
1288 g_Game_ExecuteEvent('onwadend');
1289 if not gMusic
.SetByName('MUSIC_endmus') then
1290 gMusic
.SetByName('MUSIC_STDENDMUS');
1293 gMusic
.SetByName('MUSIC_ROUNDMUS');
1296 gState
:= STATE_INTERCUSTOM
;
1298 else // Çàêîí÷èëàñü ïîñëåäíÿÿ êàðòà â Îäèíî÷íîé èãðå
1300 gMusic
.SetByName('MUSIC_INTERMUS');
1302 gState
:= STATE_INTERSINGLE
;
1304 g_Game_ExecuteEvent('oninter');
1307 DecMin(EndingGameCounter
, 6, 0);
1310 STATE_ENDPIC
: // Êàðòèíêà îêîí÷àíèÿ ìåãàÂàäà
1312 if gMapOnce
then // Ýòî áûë òåñò
1314 gExit
:= EXIT_SIMPLE
;
1320 g_Serverlist_Control(slCurrent
);
1323 if g_Game_IsNet
then
1324 if not gConsoleShow
then
1325 if not gChatShow
then
1327 if g_ActiveWindow
= nil then
1329 if e_KeyPressed(gGameControls
.GameControls
.Chat
) then
1330 g_Console_Chat_Switch(False)
1331 else if (e_KeyPressed(gGameControls
.GameControls
.TeamChat
)) and
1332 (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then
1333 g_Console_Chat_Switch(True);
1336 if not gChatEnter
then
1337 if (not e_KeyPressed(gGameControls
.GameControls
.Chat
))
1338 and (not e_KeyPressed(gGameControls
.GameControls
.TeamChat
)) then
1341 // Ñòàòèñòèêà ïî Tab:
1343 IsDrawStat
:= (not gConsoleShow
) and (not gChatShow
) and
1344 (gGameSettings
.GameType
<> GT_SINGLE
) and
1345 e_KeyPressed(gGameControls
.GameControls
.Stat
);
1348 if gGameOn
and not gPause
and (gState
<> STATE_FOLD
) then
1350 // Âðåìÿ += 28 ìèëëèñåêóíä:
1351 gTime
:= gTime
+ GAME_TICK
;
1353 // Ñîîáùåíèå ïîñåðåäèíå ýêðàíà:
1354 if MessageTime
= 0 then
1356 if MessageTime
> 0 then
1357 MessageTime
:= MessageTime
- 1;
1359 if (g_Game_IsServer
) then
1361 // Áûë çàäàí ëèìèò âðåìåíè:
1362 if (gGameSettings
.TimeLimit
> 0) then
1363 if (gTime
- gGameStartTime
) div 1000 >= gGameSettings
.TimeLimit
then
1364 begin // Îí ïðîøåë => êîíåö óðîâíÿ
1369 // Íàäî ðåñïàâíèòü èãðîêîâ â LMS:
1370 if (gLMSRespawn
> LMS_RESPAWN_NONE
) and (gLMSRespawnTime
< gTime
) then
1371 g_Game_RestartRound(gLMSSoftSpawn
);
1373 // Ïðîâåðèì ðåçóëüòàò ãîëîñîâàíèÿ, åñëè âðåìÿ ïðîøëî
1374 if gVoteInProgress
and (gVoteTimer
< gTime
) then
1376 else if gVotePassed
and (gVoteCmdTimer
< gTime
) then
1378 g_Console_Process(gVoteCommand
);
1380 gVotePassed
:= False;
1383 // Çàìåðÿåì âðåìÿ çàõâàòà ôëàãîâ
1384 if gFlags
[FLAG_RED
].State
= FLAG_STATE_CAPTURED
then
1385 gFlags
[FLAG_RED
].CaptureTime
:= gFlags
[FLAG_RED
].CaptureTime
+ GAME_TICK
;
1386 if gFlags
[FLAG_BLUE
].State
= FLAG_STATE_CAPTURED
then
1387 gFlags
[FLAG_BLUE
].CaptureTime
:= gFlags
[FLAG_BLUE
].CaptureTime
+ GAME_TICK
;
1389 // Áûë çàäàí ëèìèò ïîáåä:
1390 if (gGameSettings
.GoalLimit
> 0) then
1394 if gGameSettings
.GameMode
= GM_DM
then
1395 begin // Â DM èùåì èãðîêà ñ max ôðàãàìè
1396 for i
:= 0 to High(gPlayers
) do
1397 if gPlayers
[i
] <> nil then
1398 if gPlayers
[i
].Frags
> b
then
1399 b
:= gPlayers
[i
].Frags
;
1402 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
1403 begin //  CTF/TDM âûáèðàåì êîìàíäó ñ íàèáîëüøèì ñ÷åòîì
1404 b
:= Max(gTeamStat
[TEAM_RED
].Goals
, gTeamStat
[TEAM_BLUE
].Goals
);
1407 // Ëèìèò ïîáåä íàáðàí => êîíåö óðîâíÿ:
1408 if b
>= gGameSettings
.GoalLimit
then
1415 // Îáðàáàòûâàåì êëàâèøè èãðîêîâ:
1416 if gPlayer1
<> nil then gPlayer1
.ReleaseKeys();
1417 if gPlayer2
<> nil then gPlayer2
.ReleaseKeys();
1418 if (not gConsoleShow
) and (not gChatShow
) and (g_ActiveWindow
= nil) then
1421 if gPlayer1
<> nil then
1422 with gGameControls
.P1Control
do
1424 if e_KeyPressed(KeyLeft
) and (not e_KeyPressed(KeyRight
)) then
1425 P1MoveButton
:= 1 // Íàæàòà òîëüêî "Âëåâî"
1427 if (not e_KeyPressed(KeyLeft
)) and e_KeyPressed(KeyRight
) then
1428 P1MoveButton
:= 2 // Íàæàòà òîëüêî "Âïðàâî"
1430 if (not e_KeyPressed(KeyLeft
)) and (not e_KeyPressed(KeyRight
)) then
1431 P1MoveButton
:= 0; // Íå íàæàòû íè "Âëåâî", íè "Âïðàâî"
1433 // Ñåé÷àñ èëè ðàíüøå áûëè íàæàòû "Âëåâî"/"Âïðàâî" => ïåðåäàåì èãðîêó:
1434 if P1MoveButton
= 1 then
1435 gPlayer1
.PressKey(KEY_LEFT
)
1437 if P1MoveButton
= 2 then
1438 gPlayer1
.PressKey(KEY_RIGHT
);
1440 // Ðàíüøå áûëà íàæàòà "Âïðàâî", à ñåé÷àñ "Âëåâî" => áåæèì âïðàâî, ñìîòðèì âëåâî:
1441 if (P1MoveButton
= 2) and e_KeyPressed(KeyLeft
) then
1442 gPlayer1
.SetDirection(D_LEFT
)
1444 // Ðàíüøå áûëà íàæàòà "Âëåâî", à ñåé÷àñ "Âïðàâî" => áåæèì âëåâî, ñìîòðèì âïðàâî:
1445 if (P1MoveButton
= 1) and e_KeyPressed(KeyRight
) then
1446 gPlayer1
.SetDirection(D_RIGHT
)
1448 // ×òî-òî áûëî íàæàòî è íå èçìåíèëîñü => êóäà áåæèì, òóäà è ñìîòðèì:
1449 if P1MoveButton
<> 0 then
1450 gPlayer1
.SetDirection(TDirection(P1MoveButton
-1));
1452 // Îñòàëüíûå êëàâèøè:
1453 if e_KeyPressed(KeyJump
) then gPlayer1
.PressKey(KEY_JUMP
);
1454 if e_KeyPressed(KeyUp
) then gPlayer1
.PressKey(KEY_UP
);
1455 if e_KeyPressed(KeyDown
) then gPlayer1
.PressKey(KEY_DOWN
);
1456 if e_KeyPressed(KeyFire
) then gPlayer1
.PressKey(KEY_FIRE
);
1457 if e_KeyPressed(KeyNextWeapon
) then gPlayer1
.PressKey(KEY_NEXTWEAPON
);
1458 if e_KeyPressed(KeyPrevWeapon
) then gPlayer1
.PressKey(KEY_PREVWEAPON
);
1459 if e_KeyPressed(KeyOpen
) then gPlayer1
.PressKey(KEY_OPEN
);
1462 if gPlayer2
<> nil then
1463 with gGameControls
.P2Control
do
1465 if e_KeyPressed(KeyLeft
) and (not e_KeyPressed(KeyRight
)) then
1466 P2MoveButton
:= 1 // Íàæàòà òîëüêî "Âëåâî"
1468 if (not e_KeyPressed(KeyLeft
)) and e_KeyPressed(KeyRight
) then
1469 P2MoveButton
:= 2 // Íàæàòà òîëüêî "Âïðàâî"
1471 if (not e_KeyPressed(KeyLeft
)) and (not e_KeyPressed(KeyRight
)) then
1472 P2MoveButton
:= 0; // Íå íàæàòû íè "Âëåâî", íè "Âïðàâî"
1474 // Ñåé÷àñ èëè ðàíüøå áûëè íàæàòû "Âëåâî"/"Âïðàâî" => ïåðåäàåì èãðîêó:
1475 if P2MoveButton
= 1 then
1476 gPlayer2
.PressKey(KEY_LEFT
, 1000)
1478 if P2MoveButton
= 2 then
1479 gPlayer2
.PressKey(KEY_RIGHT
, 1000);
1481 // Ðàíüøå áûëà íàæàòà "Âïðàâî", à ñåé÷àñ "Âëåâî" => áåæèì âïðàâî, ñìîòðèì âëåâî:
1482 if (P2MoveButton
= 2) and e_KeyPressed(KeyLeft
) then
1483 gPlayer2
.SetDirection(D_LEFT
)
1485 // Ðàíüøå áûëà íàæàòà "Âëåâî", à ñåé÷àñ "Âïðàâî" => áåæèì âëåâî, ñìîòðèì âïðàâî:
1486 if (P2MoveButton
= 1) and e_KeyPressed(KeyRight
) then
1487 gPlayer2
.SetDirection(D_RIGHT
)
1489 // ×òî-òî áûëî íàæàòî è íå èçìåíèëîñü => êóäà áåæèì, òóäà è ñìîòðèì:
1490 if P2MoveButton
<> 0 then
1491 gPlayer2
.SetDirection(TDirection(P2MoveButton
-1));
1493 // Îñòàëüíûå êëàâèøè:
1494 if e_KeyPressed(KeyJump
) then gPlayer2
.PressKey(KEY_JUMP
, 1000);
1495 if e_KeyPressed(KeyUp
) then gPlayer2
.PressKey(KEY_UP
, 1000);
1496 if e_KeyPressed(KeyDown
) then gPlayer2
.PressKey(KEY_DOWN
, 1000);
1497 if e_KeyPressed(KeyFire
) then gPlayer2
.PressKey(KEY_FIRE
);
1498 if e_KeyPressed(KeyNextWeapon
) then gPlayer2
.PressKey(KEY_NEXTWEAPON
);
1499 if e_KeyPressed(KeyPrevWeapon
) then gPlayer2
.PressKey(KEY_PREVWEAPON
);
1500 if e_KeyPressed(KeyOpen
) then gPlayer2
.PressKey(KEY_OPEN
);
1502 end // if not console
1504 if g_Game_IsNet
and (gPlayer1
<> nil) then
1505 gPlayer1
.PressKey(KEY_CHAT
, 10000);
1510 if (gPlayer1
= nil) and (gPlayer2
= nil) and
1511 (not gConsoleShow
) and (not gChatShow
) and (g_ActiveWindow
= nil) then
1513 if not gSpectKeyPress
then
1515 if e_KeyPressed(gGameControls
.P1Control
.KeyJump
) then
1517 // switch spect mode
1519 SPECT_NONE
: ; // not spectator
1521 SPECT_MAPVIEW
: Inc(gSpectMode
);
1522 SPECT_PLAYERS
: gSpectMode
:= SPECT_STATS
; // reset to 1
1524 gSpectKeyPress
:= True;
1526 if gSpectMode
= SPECT_MAPVIEW
then
1528 if e_KeyPressed(gGameControls
.P1Control
.KeyLeft
) then
1529 gSpectX
:= Max(gSpectX
- gSpectStep
, 0);
1530 if e_KeyPressed(gGameControls
.P1Control
.KeyRight
) then
1531 gSpectX
:= Min(gSpectX
+ gSpectStep
, gMapInfo
.Width
- gScreenWidth
);
1532 if e_KeyPressed(gGameControls
.P1Control
.KeyUp
) then
1533 gSpectY
:= Max(gSpectY
- gSpectStep
, 0);
1534 if e_KeyPressed(gGameControls
.P1Control
.KeyDown
) then
1535 gSpectY
:= Min(gSpectY
+ gSpectStep
, gMapInfo
.Height
- gScreenHeight
);
1536 if e_KeyPressed(gGameControls
.P1Control
.KeyPrevWeapon
) then
1539 if gSpectStep
> 4 then gSpectStep
:= gSpectStep
shr 1;
1540 gSpectKeyPress
:= True;
1542 if e_KeyPressed(gGameControls
.P1Control
.KeyNextWeapon
) then
1545 if gSpectStep
< 64 then gSpectStep
:= gSpectStep
shl 1;
1546 gSpectKeyPress
:= True;
1549 if gSpectMode
= SPECT_PLAYERS
then
1551 if e_KeyPressed(gGameControls
.P1Control
.KeyUp
) then
1554 gSpectViewTwo
:= True;
1555 gSpectKeyPress
:= True;
1557 if e_KeyPressed(gGameControls
.P1Control
.KeyDown
) then
1559 // remove second view
1560 gSpectViewTwo
:= False;
1561 gSpectKeyPress
:= True;
1563 if e_KeyPressed(gGameControls
.P1Control
.KeyLeft
) then
1565 // prev player (view 1)
1566 gSpectPID1
:= GetActivePlayerID_Prev(gSpectPID1
);
1567 gSpectKeyPress
:= True;
1569 if e_KeyPressed(gGameControls
.P1Control
.KeyRight
) then
1571 // next player (view 1)
1572 gSpectPID1
:= GetActivePlayerID_Next(gSpectPID1
);
1573 gSpectKeyPress
:= True;
1575 if e_KeyPressed(gGameControls
.P1Control
.KeyPrevWeapon
) then
1577 // prev player (view 2)
1578 gSpectPID2
:= GetActivePlayerID_Prev(gSpectPID2
);
1579 gSpectKeyPress
:= True;
1581 if e_KeyPressed(gGameControls
.P1Control
.KeyNextWeapon
) then
1583 // next player (view 2)
1584 gSpectPID2
:= GetActivePlayerID_Next(gSpectPID2
);
1585 gSpectKeyPress
:= True;
1590 if (not e_KeyPressed(gGameControls
.P1Control
.KeyJump
)) and
1591 (not e_KeyPressed(gGameControls
.P1Control
.KeyLeft
)) and
1592 (not e_KeyPressed(gGameControls
.P1Control
.KeyRight
)) and
1593 (not e_KeyPressed(gGameControls
.P1Control
.KeyUp
)) and
1594 (not e_KeyPressed(gGameControls
.P1Control
.KeyDown
)) and
1595 (not e_KeyPressed(gGameControls
.P1Control
.KeyPrevWeapon
)) and
1596 (not e_KeyPressed(gGameControls
.P1Control
.KeyNextWeapon
)) then
1597 gSpectKeyPress
:= False;
1600 // Îáíîâëÿåì âñå îñòàëüíîå:
1603 g_Triggers_Update();
1605 g_Monsters_Update();
1607 g_Player_UpdateAll();
1608 g_Player_UpdatePhysicalObjects();
1609 if gGameSettings
.GameType
= GT_SERVER
then
1610 if Length(gMonstersSpawned
) > 0 then
1612 for I
:= 0 to High(gMonstersSpawned
) do
1613 MH_SEND_MonsterSpawn(gMonstersSpawned
[I
]);
1614 SetLength(gMonstersSpawned
, 0);
1617 if (gSoundTriggerTime
> 8) then
1619 g_Game_UpdateTriggerSounds();
1620 gSoundTriggerTime
:= 0;
1623 Inc(gSoundTriggerTime
);
1625 if (NetMode
= NET_SERVER
) then
1627 Inc(NetTimeToUpdate
);
1628 Inc(NetTimeToReliable
);
1629 if NetTimeToReliable
>= NetRelupdRate
then
1631 for I
:= 0 to High(gPlayers
) do
1632 if gPlayers
[I
] <> nil then
1633 MH_SEND_PlayerPos(True, gPlayers
[I
].UID
);
1635 if gMonsters
<> nil then
1636 for I
:= 0 to High(gMonsters
) do
1637 if gMonsters
[I
] <> nil then
1639 if (gMonsters
[I
].MonsterType
= MONSTER_BARREL
) then
1641 if (gMonsters
[I
].GameVelX
<> 0) or (gMonsters
[I
].GameVelY
<> 0) then
1642 MH_SEND_MonsterPos(gMonsters
[I
].UID
);
1645 if (gMonsters
[I
].MonsterState
<> MONSTATE_SLEEP
) then
1646 if (gMonsters
[I
].MonsterState
<> MONSTATE_DEAD
) or
1647 (gMonsters
[I
].GameVelX
<> 0) or
1648 (gMonsters
[I
].GameVelY
<> 0) then
1649 MH_SEND_MonsterPos(gMonsters
[I
].UID
);
1652 NetTimeToReliable
:= 0;
1653 NetTimeToUpdate
:= NetUpdateRate
;
1655 else if NetTimeToUpdate
>= NetUpdateRate
then
1657 if gPlayers
<> nil then
1658 for I
:= 0 to High(gPlayers
) do
1659 if gPlayers
[I
] <> nil then
1660 MH_SEND_PlayerPos(False, gPlayers
[I
].UID
);
1662 if gMonsters
<> nil then
1663 for I
:= 0 to High(gMonsters
) do
1664 if gMonsters
[I
] <> nil then
1666 if (gMonsters
[I
].MonsterType
= MONSTER_BARREL
) then
1668 if (gMonsters
[I
].GameVelX
<> 0) or (gMonsters
[I
].GameVelY
<> 0) then
1669 MH_SEND_MonsterPos(gMonsters
[I
].UID
);
1672 if (gMonsters
[I
].MonsterState
<> MONSTATE_SLEEP
) then
1673 if (gMonsters
[I
].MonsterState
<> MONSTATE_DEAD
) or
1674 (gMonsters
[I
].GameVelX
<> 0) or
1675 (gMonsters
[I
].GameVelY
<> 0) then
1676 MH_SEND_MonsterPos(gMonsters
[I
].UID
);
1679 NetTimeToUpdate
:= 0;
1682 if NetUseMaster
then
1683 if gTime
>= NetTimeToMaster
then
1685 if (NetMHost
= nil) or (NetMPeer
= nil) then
1686 if not g_Net_Slist_Connect
then
1687 g_Console_Add(_lc
[I_NET_MSG_ERROR
] + _lc
[I_NET_SLIST_ERROR
]);
1690 NetTimeToMaster
:= gTime
+ NetMasterRate
;
1694 if NetMode
= NET_CLIENT
then
1695 MC_SEND_PlayerPos();
1696 end; // if gameOn ...
1698 // Àêòèâíî îêíî èíòåðôåéñà - ïåðåäàåì êëàâèøè åìó:
1699 if g_ActiveWindow
<> nil then
1701 w
:= e_GetFirstKeyPressed();
1703 if (w
<> IK_INVALID
) then
1705 Msg
.Msg
:= MESSAGE_DIKEY
;
1707 g_ActiveWindow
.OnMessage(Msg
);
1710 // Åñëè îíî îò ýòîãî íå çàêðûëîñü, òî îáíîâëÿåì:
1711 if g_ActiveWindow
<> nil then
1712 g_ActiveWindow
.Update();
1714 // Íóæíî ñìåíèòü ðàçðåøåíèå:
1715 if gResolutionChange
then
1717 e_WriteLog('Changing resolution', MSG_NOTIFY
);
1718 g_Game_ChangeResolution(gRC_Width
, gRC_Height
, gRC_FullScreen
, gRC_Maximized
);
1719 gResolutionChange
:= False;
1722 // Íóæíî ñìåíèòü ÿçûê:
1723 if gLanguageChange
then
1725 //e_WriteLog('Read language file', MSG_NOTIFY);
1726 //g_Language_Load(DataDir + gLanguage + '.txt');
1727 g_Language_Set(gLanguage
);
1729 gLanguageChange
:= False;
1733 // Äåëàåì ñêðèíøîò (íå ÷àùå 200 ìèëëèñåêóíä):
1734 if e_KeyPressed(gGameControls
.GameControls
.TakeScreenshot
) then
1735 if (GetTimer()-LastScreenShot
) > 200000 then
1738 LastScreenShot
:= GetTimer();
1741 // Ãîðÿ÷àÿ êëàâèøà äëÿ âûçîâà ìåíþ âûõîäà èç èãðû (F10):
1742 if e_KeyPressed(IK_F10
) and
1744 (not gConsoleShow
) and
1745 (g_ActiveWindow
= nil) then
1750 Time
:= GetTimer() div 1000;
1752 // Îáðàáîòêà îòëîæåííûõ ñîáûòèé:
1753 if gDelayedEvents
<> nil then
1754 for a
:= 0 to High(gDelayedEvents
) do
1755 if gDelayedEvents
[a
].Pending
and
1757 ((gDelayedEvents
[a
].DEType
= DE_GLOBEVENT
) and (gDelayedEvents
[a
].Time
<= Time
)) or
1758 ((gDelayedEvents
[a
].DEType
> DE_GLOBEVENT
) and (gDelayedEvents
[a
].Time
<= gTime
))
1761 case gDelayedEvents
[a
].DEType
of
1763 g_Game_ExecuteEvent(gDelayedEvents
[a
].DEStr
);
1766 g_Game_Announce_GoodShot(gDelayedEvents
[a
].DENum
);
1770 g_Game_Announce_KillCombo(gDelayedEvents
[a
].DENum
);
1771 if g_Game_IsNet
and g_Game_IsServer
then
1772 MH_SEND_GameEvent(NET_EV_KILLCOMBO
, gDelayedEvents
[a
].DENum
);
1775 gDelayedEvents
[a
].Pending
:= False;
1778 // Êàæäóþ ñåêóíäó îáíîâëÿåì ñ÷åò÷èê îáíîâëåíèé:
1779 UPSCounter
:= UPSCounter
+ 1;
1780 if Time
- UPSTime
>= 1000 then
1788 procedure g_Game_LoadData();
1790 if DataLoaded
then Exit
;
1792 e_WriteLog('Loading game data...', MSG_NOTIFY
);
1794 g_Texture_CreateWADEx('NOTEXTURE', GameWAD
+':TEXTURES\NOTEXTURE');
1795 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUD', GameWAD
+':TEXTURES\HUD');
1796 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUDAIR', GameWAD
+':TEXTURES\AIRBAR');
1797 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUDJET', GameWAD
+':TEXTURES\JETBAR');
1798 g_Texture_CreateWADEx('TEXTURE_PLAYER_HUDBG', GameWAD
+':TEXTURES\HUDBG');
1799 g_Texture_CreateWADEx('TEXTURE_PLAYER_ARMORHUD', GameWAD
+':TEXTURES\ARMORHUD');
1800 g_Texture_CreateWADEx('TEXTURE_PLAYER_REDFLAG', GameWAD
+':TEXTURES\FLAGHUD_RB');
1801 g_Texture_CreateWADEx('TEXTURE_PLAYER_REDFLAG_S', GameWAD
+':TEXTURES\FLAGHUD_RS');
1802 g_Texture_CreateWADEx('TEXTURE_PLAYER_REDFLAG_D', GameWAD
+':TEXTURES\FLAGHUD_RD');
1803 g_Texture_CreateWADEx('TEXTURE_PLAYER_BLUEFLAG', GameWAD
+':TEXTURES\FLAGHUD_BB');
1804 g_Texture_CreateWADEx('TEXTURE_PLAYER_BLUEFLAG_S', GameWAD
+':TEXTURES\FLAGHUD_BS');
1805 g_Texture_CreateWADEx('TEXTURE_PLAYER_BLUEFLAG_D', GameWAD
+':TEXTURES\FLAGHUD_BD');
1806 g_Texture_CreateWADEx('TEXTURE_PLAYER_TALKBUBBLE', GameWAD
+':TEXTURES\TALKBUBBLE');
1807 g_Texture_CreateWADEx('TEXTURE_PLAYER_INVULPENTA', GameWAD
+':TEXTURES\PENTA');
1808 g_Frames_CreateWAD(nil, 'FRAMES_TELEPORT', GameWAD
+':TEXTURES\TELEPORT', 64, 64, 10, False);
1809 g_Sound_CreateWADEx('SOUND_GAME_TELEPORT', GameWAD
+':SOUNDS\TELEPORT');
1810 g_Sound_CreateWADEx('SOUND_GAME_NOTELEPORT', GameWAD
+':SOUNDS\NOTELEPORT');
1811 g_Sound_CreateWADEx('SOUND_GAME_DOOROPEN', GameWAD
+':SOUNDS\DOOROPEN');
1812 g_Sound_CreateWADEx('SOUND_GAME_DOORCLOSE', GameWAD
+':SOUNDS\DOORCLOSE');
1813 g_Sound_CreateWADEx('SOUND_GAME_BULK1', GameWAD
+':SOUNDS\BULK1');
1814 g_Sound_CreateWADEx('SOUND_GAME_BULK2', GameWAD
+':SOUNDS\BULK2');
1815 g_Sound_CreateWADEx('SOUND_GAME_BUBBLE1', GameWAD
+':SOUNDS\BUBBLE1');
1816 g_Sound_CreateWADEx('SOUND_GAME_BUBBLE2', GameWAD
+':SOUNDS\BUBBLE2');
1817 g_Sound_CreateWADEx('SOUND_GAME_SWITCH1', GameWAD
+':SOUNDS\SWITCH1');
1818 g_Sound_CreateWADEx('SOUND_GAME_SWITCH0', GameWAD
+':SOUNDS\SWITCH0');
1819 g_Sound_CreateWADEx('SOUND_GAME_RADIO', GameWAD
+':SOUNDS\RADIO');
1820 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD1', GameWAD
+':SOUNDS\GOOD1');
1821 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD2', GameWAD
+':SOUNDS\GOOD2');
1822 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD3', GameWAD
+':SOUNDS\GOOD3');
1823 g_Sound_CreateWADEx('SOUND_ANNOUNCER_GOOD4', GameWAD
+':SOUNDS\GOOD4');
1824 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILL2X', GameWAD
+':SOUNDS\KILL2X');
1825 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILL3X', GameWAD
+':SOUNDS\KILL3X');
1826 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILL4X', GameWAD
+':SOUNDS\KILL4X');
1827 g_Sound_CreateWADEx('SOUND_ANNOUNCER_KILLMX', GameWAD
+':SOUNDS\KILLMX');
1829 goodsnd
[0] := TPlayableSound
.Create();
1830 goodsnd
[1] := TPlayableSound
.Create();
1831 goodsnd
[2] := TPlayableSound
.Create();
1832 goodsnd
[3] := TPlayableSound
.Create();
1834 goodsnd
[0].SetByName('SOUND_ANNOUNCER_GOOD1');
1835 goodsnd
[1].SetByName('SOUND_ANNOUNCER_GOOD2');
1836 goodsnd
[2].SetByName('SOUND_ANNOUNCER_GOOD3');
1837 goodsnd
[3].SetByName('SOUND_ANNOUNCER_GOOD4');
1839 killsnd
[0] := TPlayableSound
.Create();
1840 killsnd
[1] := TPlayableSound
.Create();
1841 killsnd
[2] := TPlayableSound
.Create();
1842 killsnd
[3] := TPlayableSound
.Create();
1844 killsnd
[0].SetByName('SOUND_ANNOUNCER_KILL2X');
1845 killsnd
[1].SetByName('SOUND_ANNOUNCER_KILL3X');
1846 killsnd
[2].SetByName('SOUND_ANNOUNCER_KILL4X');
1847 killsnd
[3].SetByName('SOUND_ANNOUNCER_KILLMX');
1849 g_Game_SetLoadingText(_lc
[I_LOAD_ITEMS_DATA
], 0, False);
1852 g_Game_SetLoadingText(_lc
[I_LOAD_WEAPONS_DATA
], 0, False);
1853 g_Weapon_LoadData();
1855 g_Monsters_LoadData();
1860 procedure g_Game_FreeData();
1862 if not DataLoaded
then Exit
;
1865 g_Weapon_FreeData();
1866 g_Monsters_FreeData();
1868 e_WriteLog('Releasing game data...', MSG_NOTIFY
);
1870 g_Texture_Delete('NOTEXTURE');
1871 g_Texture_Delete('TEXTURE_PLAYER_HUD');
1872 g_Texture_Delete('TEXTURE_PLAYER_HUDBG');
1873 g_Texture_Delete('TEXTURE_PLAYER_ARMORHUD');
1874 g_Texture_Delete('TEXTURE_PLAYER_REDFLAG');
1875 g_Texture_Delete('TEXTURE_PLAYER_REDFLAG_S');
1876 g_Texture_Delete('TEXTURE_PLAYER_REDFLAG_D');
1877 g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG');
1878 g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG_S');
1879 g_Texture_Delete('TEXTURE_PLAYER_BLUEFLAG_D');
1880 g_Texture_Delete('TEXTURE_PLAYER_TALKBUBBLE');
1881 g_Texture_Delete('TEXTURE_PLAYER_INVULPENTA');
1882 g_Frames_DeleteByName('FRAMES_TELEPORT');
1883 g_Sound_Delete('SOUND_GAME_TELEPORT');
1884 g_Sound_Delete('SOUND_GAME_NOTELEPORT');
1885 g_Sound_Delete('SOUND_GAME_DOOROPEN');
1886 g_Sound_Delete('SOUND_GAME_DOORCLOSE');
1887 g_Sound_Delete('SOUND_GAME_BULK1');
1888 g_Sound_Delete('SOUND_GAME_BULK2');
1889 g_Sound_Delete('SOUND_GAME_BUBBLE1');
1890 g_Sound_Delete('SOUND_GAME_BUBBLE2');
1891 g_Sound_Delete('SOUND_GAME_SWITCH1');
1892 g_Sound_Delete('SOUND_GAME_SWITCH0');
1899 g_Sound_Delete('SOUND_ANNOUNCER_GOOD1');
1900 g_Sound_Delete('SOUND_ANNOUNCER_GOOD2');
1901 g_Sound_Delete('SOUND_ANNOUNCER_GOOD3');
1902 g_Sound_Delete('SOUND_ANNOUNCER_GOOD4');
1909 g_Sound_Delete('SOUND_ANNOUNCER_KILL2X');
1910 g_Sound_Delete('SOUND_ANNOUNCER_KILL3X');
1911 g_Sound_Delete('SOUND_ANNOUNCER_KILL4X');
1912 g_Sound_Delete('SOUND_ANNOUNCER_KILLMX');
1914 DataLoaded
:= False;
1917 procedure DrawCustomStat();
1923 ww2
, hh2
, r
, g
, b
, rr
, gg
, bb
: Byte;
1924 s1
, s2
, topstr
: String;
1926 e_TextureFontGetSize(gStdFont
, ww2
, hh2
);
1929 if e_KeyPressed(IK_TAB
) then
1931 if not gStatsPressed
then
1933 gStatsOff
:= not gStatsOff
;
1934 gStatsPressed
:= True;
1938 gStatsPressed
:= False;
1942 s1
:= _lc
[I_MENU_INTER_NOTICE_TAB
];
1943 w
:= (Length(s1
) * ww2
) div 2;
1944 x
:= gScreenWidth
div 2 - w
;
1946 e_TextureFontPrint(x
, y
, s1
, gStdFont
);
1950 if (gGameSettings
.GameMode
= GM_COOP
) then
1952 if gMissionFailed
then
1953 topstr
:= _lc
[I_MENU_INTER_MISSION_FAIL
]
1955 topstr
:= _lc
[I_MENU_INTER_LEVEL_COMPLETE
];
1958 topstr
:= _lc
[I_MENU_INTER_ROUND_OVER
];
1960 e_CharFont_GetSize(gMenuFont
, topstr
, ww1
, hh1
);
1961 e_CharFont_Print(gMenuFont
, (gScreenWidth
div 2)-(ww1
div 2), 16, topstr
);
1963 if g_Game_IsNet
then
1965 topstr
:= Format(_lc
[I_MENU_INTER_NOTICE_TIME
], [gServInterTime
]);
1966 if not gChatShow
then
1967 e_TextureFontPrintEx((gScreenWidth
div 2)-(Length(topstr
)*ww2
div 2),
1968 gScreenHeight
-(hh2
+4)*2, topstr
, gStdFont
, 255, 255, 255, 1);
1971 if g_Game_IsClient
then
1972 topstr
:= _lc
[I_MENU_INTER_NOTICE_MAP
]
1974 topstr
:= _lc
[I_MENU_INTER_NOTICE_SPACE
];
1975 if not gChatShow
then
1976 e_TextureFontPrintEx((gScreenWidth
div 2)-(Length(topstr
)*ww2
div 2),
1977 gScreenHeight
-(hh2
+4), topstr
, gStdFont
, 255, 255, 255, 1);
1982 w
:= gScreenWidth
-x
*2;
1988 e_DrawFillQuad(x
, y
, gScreenWidth
-x
-1, gScreenHeight
-y
-1, 64, 64, 64, 32);
1989 e_DrawQuad(x
, y
, gScreenWidth
-x
-1, gScreenHeight
-y
-1, 255, 127, 0);
1991 m
:= Max(Length(_lc
[I_MENU_MAP
])+1, Length(_lc
[I_GAME_GAME_TIME
])+1)*ww2
;
1993 case CustomStat
.GameMode
of
1996 if gGameSettings
.MaxLives
= 0 then
1997 s1
:= _lc
[I_GAME_DM
]
1999 s1
:= _lc
[I_GAME_LMS
];
2003 if gGameSettings
.MaxLives
= 0 then
2004 s1
:= _lc
[I_GAME_TDM
]
2006 s1
:= _lc
[I_GAME_TLMS
];
2008 GM_CTF
: s1
:= _lc
[I_GAME_CTF
];
2011 if gGameSettings
.MaxLives
= 0 then
2012 s1
:= _lc
[I_GAME_COOP
]
2014 s1
:= _lc
[I_GAME_SURV
];
2020 e_TextureFontPrintEx(x
+(w
div 2)-(Length(s1
)*ww2
div 2), _y
, s1
, gStdFont
, 255, 255, 255, 1);
2024 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_MENU_MAP
], gStdFont
, 255, 127, 0, 1);
2025 e_TextureFontPrint(x
+8+m
, _y
, Format('%s - %s', [CustomStat
.Map
, CustomStat
.MapName
]), gStdFont
);
2028 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_GAME_TIME
], gStdFont
, 255, 127, 0, 1);
2029 e_TextureFontPrint(x
+8+m
, _y
, Format('%d:%.2d:%.2d', [CustomStat
.GameTime
div 1000 div 3600,
2030 (CustomStat
.GameTime
div 1000 div 60) mod 60,
2031 CustomStat
.GameTime
div 1000 mod 60]), gStdFont
);
2033 pc
:= Length(CustomStat
.PlayerStat
);
2034 if pc
= 0 then Exit
;
2036 if CustomStat
.GameMode
= GM_COOP
then
2038 m
:= Max(Length(_lc
[I_GAME_MONSTERS
])+1, Length(_lc
[I_GAME_SECRETS
])+1)*ww2
;
2040 s2
:= _lc
[I_GAME_MONSTERS
];
2041 e_TextureFontPrintEx(x
+8, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2042 e_TextureFontPrintEx(x
+8+m
, _y
, IntToStr(gCoopMonstersKilled
) + '/' + IntToStr(gTotalMonsters
), gStdFont
, 255, 255, 255, 1);
2044 s2
:= _lc
[I_GAME_SECRETS
];
2045 e_TextureFontPrintEx(x
+8, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2046 e_TextureFontPrintEx(x
+8+m
, _y
, IntToStr(gCoopSecretsFound
) + '/' + IntToStr(gSecretsCount
), gStdFont
, 255, 255, 255, 1);
2049 m
:= Max(Length(_lc
[I_GAME_MONSTERS_TOTAL
])+1, Length(_lc
[I_GAME_SECRETS_TOTAL
])+1)*ww2
;
2051 s2
:= _lc
[I_GAME_MONSTERS_TOTAL
];
2052 e_TextureFontPrintEx(x
+250, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2053 e_TextureFontPrintEx(x
+250+m
, _y
, IntToStr(gCoopTotalMonstersKilled
) + '/' + IntToStr(gCoopTotalMonsters
), gStdFont
, 255, 255, 255, 1);
2055 s2
:= _lc
[I_GAME_SECRETS_TOTAL
];
2056 e_TextureFontPrintEx(x
+250, _y
, s2
, gStdFont
, 255, 127, 0, 1);
2057 e_TextureFontPrintEx(x
+250+m
, _y
, IntToStr(gCoopTotalSecretsFound
) + '/' + IntToStr(gCoopTotalSecrets
), gStdFont
, 255, 255, 255, 1);
2061 if CustomStat
.GameMode
in [GM_TDM
, GM_CTF
] then
2066 if TeamStat
[TEAM_RED
].Goals
> TeamStat
[TEAM_BLUE
].Goals
then s1
:= _lc
[I_GAME_WIN_RED
]
2067 else if TeamStat
[TEAM_BLUE
].Goals
> TeamStat
[TEAM_RED
].Goals
then s1
:= _lc
[I_GAME_WIN_BLUE
]
2068 else s1
:= _lc
[I_GAME_WIN_DRAW
];
2070 e_TextureFontPrintEx(x
+8+(w
div 2)-(Length(s1
)*ww2
div 2), _y
, s1
, gStdFont
, 255, 255, 255, 1);
2073 for t
:= TEAM_RED
to TEAM_BLUE
do
2075 if t
= TEAM_RED
then
2077 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_TEAM_RED
],
2078 gStdFont
, 255, 0, 0, 1);
2079 e_TextureFontPrintEx(x
+w1
+8, _y
, IntToStr(CustomStat
.TeamStat
[TEAM_RED
].Goals
),
2080 gStdFont
, 255, 0, 0, 1);
2087 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_TEAM_BLUE
],
2088 gStdFont
, 0, 0, 255, 1);
2089 e_TextureFontPrintEx(x
+w1
+8, _y
, IntToStr(CustomStat
.TeamStat
[TEAM_BLUE
].Goals
),
2090 gStdFont
, 0, 0, 255, 1);
2096 e_DrawLine(1, x
+8, _y
+20, x
-8+w
, _y
+20, r
, g
, b
);
2099 for p
:= 0 to High(CustomStat
.PlayerStat
) do
2100 if CustomStat
.PlayerStat
[p
].Team
= t
then
2101 with CustomStat
.PlayerStat
[p
] do
2115 e_TextureFontPrintEx(x
+8, _y
, Name
, gStdFont
, rr
, gg
, bb
, 1);
2116 e_TextureFontPrintEx(x
+w1
+8, _y
, IntToStr(Frags
), gStdFont
, rr
, gg
, bb
, 1);
2117 e_TextureFontPrintEx(x
+w1
+w2
+8, _y
, IntToStr(Deaths
), gStdFont
, rr
, gg
, bb
, 1);
2124 else if CustomStat
.GameMode
in [GM_DM
, GM_COOP
] then
2127 e_TextureFontPrintEx(x
+8, _y
, _lc
[I_GAME_PLAYER_NAME
], gStdFont
, 255, 127, 0, 1);
2128 e_TextureFontPrintEx(x
+8+w1
, _y
, _lc
[I_GAME_FRAGS
], gStdFont
, 255, 127, 0, 1);
2129 e_TextureFontPrintEx(x
+8+w1
+w2
, _y
, _lc
[I_GAME_DEATHS
], gStdFont
, 255, 127, 0, 1);
2132 for p
:= 0 to High(CustomStat
.PlayerStat
) do
2133 with CustomStat
.PlayerStat
[p
] do
2135 e_DrawFillQuad(x
+8, _y
+4, x
+24-1, _y
+16+4-1, Color
.R
, Color
.G
, Color
.B
, 0);
2142 e_TextureFontPrintEx(x
+8+16+8, _y
+4, Name
, gStdFont
, r
, r
, r
, 1, True);
2143 e_TextureFontPrintEx(x
+w1
+8+16+8, _y
+4, IntToStr(Frags
), gStdFont
, r
, r
, r
, 1, True);
2144 e_TextureFontPrintEx(x
+w1
+w2
+8+16+8, _y
+4, IntToStr(Deaths
), gStdFont
, r
, r
, r
, 1, True);
2150 procedure DrawSingleStat();
2152 tm
, key_x
, val_x
, y
: Integer;
2156 procedure player_stat(n
: Integer);
2162 s1
:= Format(' %d ', [SingleStat
.PlayerStat
[n
].Kills
]);
2163 s2
:= Format(' %d', [gTotalMonsters
]);
2165 e_CharFont_Print(gMenuFont
, key_x
, y
, _lc
[I_MENU_INTER_KILLS
]);
2166 e_CharFont_PrintEx(gMenuFont
, val_x
, y
, s1
, _RGB(255, 0, 0));
2167 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2168 e_CharFont_Print(gMenuFont
, val_x
+w1
, y
, '/');
2170 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2171 e_CharFont_PrintEx(gMenuFont
, val_x
+w1
, y
, s2
, _RGB(255, 0, 0));
2173 // "Kills-per-minute: ##.#":
2174 s1
:= _lc
[I_MENU_INTER_KPM
];
2176 kpm
:= (SingleStat
.PlayerStat
[n
].Kills
/ tm
) * 60
2178 kpm
:= SingleStat
.PlayerStat
[n
].Kills
;
2179 s2
:= Format(' %.1f', [kpm
]);
2181 e_CharFont_Print(gMenuFont
, key_x
, y
+32, s1
);
2182 e_CharFont_PrintEx(gMenuFont
, val_x
, y
+32, s2
, _RGB(255, 0, 0));
2184 // "Secrets found: # / #":
2185 s1
:= Format(' %d ', [SingleStat
.PlayerStat
[n
].Secrets
]);
2186 s2
:= Format(' %d', [SingleStat
.TotalSecrets
]);
2188 e_CharFont_Print(gMenuFont
, key_x
, y
+64, _lc
[I_MENU_INTER_SECRETS
]);
2189 e_CharFont_PrintEx(gMenuFont
, val_x
, y
+64, s1
, _RGB(255, 0, 0));
2190 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2191 e_CharFont_Print(gMenuFont
, val_x
+w1
, y
+64, '/');
2193 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2194 e_CharFont_PrintEx(gMenuFont
, val_x
+w1
, y
+64, s2
, _RGB(255, 0, 0));
2198 // "Level Complete":
2199 e_CharFont_GetSize(gMenuFont
, _lc
[I_MENU_INTER_LEVEL_COMPLETE
], w1
, h
);
2200 e_CharFont_Print(gMenuFont
, (gScreenWidth
-w1
) div 2, 32, _lc
[I_MENU_INTER_LEVEL_COMPLETE
]);
2202 // Îïðåäåëÿåì êîîðäèíàòû âûðàâíèâàíèÿ ïî ñàìîé äëèííîé ñòðîêå:
2203 s1
:= _lc
[I_MENU_INTER_KPM
];
2204 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2207 e_CharFont_GetSize(gMenuFont
, s1
, w2
, h
);
2209 key_x
:= (gScreenWidth
-w1
-w2
) div 2;
2210 val_x
:= key_x
+ w1
;
2213 tm
:= SingleStat
.GameTime
div 1000;
2214 s1
:= _lc
[I_MENU_INTER_TIME
];
2215 s2
:= Format(' %d:%.2d:%.2d', [tm
div (60*60), (tm
mod (60*60)) div 60, tm
mod 60]);
2217 e_CharFont_Print(gMenuFont
, key_x
, 80, s1
);
2218 e_CharFont_PrintEx(gMenuFont
, val_x
, 80, s2
, _RGB(255, 0, 0));
2220 if SingleStat
.TwoPlayers
then
2223 s1
:= _lc
[I_MENU_PLAYER_1
];
2224 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2225 e_CharFont_Print(gMenuFont
, (gScreenWidth
-w1
) div 2, 128, s1
);
2227 // Ñòàòèñòèêà ïåðâîãî èãðîêà:
2232 s1
:= _lc
[I_MENU_PLAYER_2
];
2233 e_CharFont_GetSize(gMenuFont
, s1
, w1
, h
);
2234 e_CharFont_Print(gMenuFont
, (gScreenWidth
-w1
) div 2, 288, s1
);
2236 // Ñòàòèñòèêà âòîðîãî èãðîêà:
2242 // Ñòàòèñòèêà ïåðâîãî èãðîêà:
2248 procedure DrawLoadingStat();
2254 if Length(LoadingStat
.Msgs
) = 0 then
2257 e_CharFont_GetSize(gMenuFont
, _lc
[I_MENU_LOADING
], ww
, hh
);
2258 yy
:= (gScreenHeight
div 3);
2259 e_CharFont_Print(gMenuFont
, (gScreenWidth
div 2)-(ww
div 2), yy
-2*hh
, _lc
[I_MENU_LOADING
]);
2260 xx
:= (gScreenWidth
div 3);
2263 for i
:= 0 to NextMsg
-1 do
2265 if (i
= (NextMsg
-1)) and (MaxValue
> 0) then
2266 s
:= Format('%s: %d/%d', [Msgs
[i
], CurValue
, MaxValue
])
2270 e_CharFont_PrintEx(gMenuSmallFont
, xx
, yy
, s
, _RGB(255, 0, 0));
2271 yy
:= yy
+ LOADING_INTERLINE
;
2275 procedure DrawMinimap(p
: TPlayer
; RenderRect
: TRect
);
2277 a
, aX
, aY
, aX2
, aY2
, Scale
, ScaleSz
: Integer;
2279 if (gMapInfo
.Width
> RenderRect
.Right
- RenderRect
.Left
) or
2280 (gMapInfo
.Height
> RenderRect
.Bottom
- RenderRect
.Top
) then
2283 // Ñêîëüêî ïèêñåëîâ êàðòû â 1 ïèêñåëå ìèíè-êàðòû:
2284 ScaleSz
:= 16 div Scale
;
2285 // Ðàçìåðû ìèíè-êàðòû:
2286 aX
:= max(gMapInfo
.Width
div ScaleSz
, 1);
2287 aY
:= max(gMapInfo
.Height
div ScaleSz
, 1);
2289 e_DrawFillQuad(0, 0, aX
-1, aY
-1, 0, 0, 0, 0);
2291 if gWalls
<> nil then
2294 for a
:= 0 to High(gWalls
) do
2296 if PanelType
<> 0 then
2298 // Ëåâûé âåðõíèé óãîë:
2299 aX
:= X
div ScaleSz
;
2300 aY
:= Y
div ScaleSz
;
2302 aX2
:= max(Width
div ScaleSz
, 1);
2303 aY2
:= max(Height
div ScaleSz
, 1);
2304 // Ïðàâûé íèæíèé óãîë:
2305 aX2
:= aX
+ aX2
- 1;
2306 aY2
:= aY
+ aY2
- 1;
2309 PANEL_WALL
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 208, 208, 208, 0);
2310 PANEL_OPENDOOR
, PANEL_CLOSEDOOR
:
2311 if Enabled
then e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 160, 160, 160, 0);
2315 if gSteps
<> nil then
2318 for a
:= 0 to High(gSteps
) do
2320 if PanelType
<> 0 then
2322 // Ëåâûé âåðõíèé óãîë:
2323 aX
:= X
div ScaleSz
;
2324 aY
:= Y
div ScaleSz
;
2326 aX2
:= max(Width
div ScaleSz
, 1);
2327 aY2
:= max(Height
div ScaleSz
, 1);
2328 // Ïðàâûé íèæíèé óãîë:
2329 aX2
:= aX
+ aX2
- 1;
2330 aY2
:= aY
+ aY2
- 1;
2332 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 128, 128, 128, 0);
2335 if gLifts
<> nil then
2338 for a
:= 0 to High(gLifts
) do
2340 if PanelType
<> 0 then
2342 // Ëåâûé âåðõíèé óãîë:
2343 aX
:= X
div ScaleSz
;
2344 aY
:= Y
div ScaleSz
;
2346 aX2
:= max(Width
div ScaleSz
, 1);
2347 aY2
:= max(Height
div ScaleSz
, 1);
2348 // Ïðàâûé íèæíèé óãîë:
2349 aX2
:= aX
+ aX2
- 1;
2350 aY2
:= aY
+ aY2
- 1;
2353 0: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 116, 72, 36, 0);
2354 1: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 116, 124, 96, 0);
2355 2: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 200, 80, 4, 0);
2356 3: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 252, 140, 56, 0);
2360 if gWater
<> nil then
2363 for a
:= 0 to High(gWater
) do
2365 if PanelType
<> 0 then
2367 // Ëåâûé âåðõíèé óãîë:
2368 aX
:= X
div ScaleSz
;
2369 aY
:= Y
div ScaleSz
;
2371 aX2
:= max(Width
div ScaleSz
, 1);
2372 aY2
:= max(Height
div ScaleSz
, 1);
2373 // Ïðàâûé íèæíèé óãîë:
2374 aX2
:= aX
+ aX2
- 1;
2375 aY2
:= aY
+ aY2
- 1;
2377 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 0, 192, 0);
2380 if gAcid1
<> nil then
2382 // Ðèñóåì êèñëîòó 1:
2383 for a
:= 0 to High(gAcid1
) do
2385 if PanelType
<> 0 then
2387 // Ëåâûé âåðõíèé óãîë:
2388 aX
:= X
div ScaleSz
;
2389 aY
:= Y
div ScaleSz
;
2391 aX2
:= max(Width
div ScaleSz
, 1);
2392 aY2
:= max(Height
div ScaleSz
, 1);
2393 // Ïðàâûé íèæíèé óãîë:
2394 aX2
:= aX
+ aX2
- 1;
2395 aY2
:= aY
+ aY2
- 1;
2397 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 176, 0, 0);
2400 if gAcid2
<> nil then
2402 // Ðèñóåì êèñëîòó 2:
2403 for a
:= 0 to High(gAcid2
) do
2405 if PanelType
<> 0 then
2407 // Ëåâûé âåðõíèé óãîë:
2408 aX
:= X
div ScaleSz
;
2409 aY
:= Y
div ScaleSz
;
2411 aX2
:= max(Width
div ScaleSz
, 1);
2412 aY2
:= max(Height
div ScaleSz
, 1);
2413 // Ïðàâûé íèæíèé óãîë:
2414 aX2
:= aX
+ aX2
- 1;
2415 aY2
:= aY
+ aY2
- 1;
2417 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 176, 0, 0, 0);
2420 if gPlayers
<> nil then
2423 for a
:= 0 to High(gPlayers
) do
2424 if gPlayers
[a
] <> nil then with gPlayers
[a
] do
2426 // Ëåâûé âåðõíèé óãîë:
2427 aX
:= Obj
.X
div ScaleSz
+ 1;
2428 aY
:= Obj
.Y
div ScaleSz
+ 1;
2430 aX2
:= max(Obj
.Rect
.Width
div ScaleSz
, 1);
2431 aY2
:= max(Obj
.Rect
.Height
div ScaleSz
, 1);
2432 // Ïðàâûé íèæíèé óãîë:
2433 aX2
:= aX
+ aX2
- 1;
2434 aY2
:= aY
+ aY2
- 1;
2436 if gPlayers
[a
] = p
then
2437 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 255, 0, 0)
2440 TEAM_RED
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 255, 0, 0, 0);
2441 TEAM_BLUE
: e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 0, 0, 255, 0);
2442 else e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 255, 128, 0, 0);
2446 if gMonsters
<> nil then
2449 for a
:= 0 to High(gMonsters
) do
2450 if gMonsters
[a
] <> nil then with gMonsters
[a
] do
2452 // Ëåâûé âåðõíèé óãîë:
2453 aX
:= Obj
.X
div ScaleSz
+ 1;
2454 aY
:= Obj
.Y
div ScaleSz
+ 1;
2456 aX2
:= max(Obj
.Rect
.Width
div ScaleSz
, 1);
2457 aY2
:= max(Obj
.Rect
.Height
div ScaleSz
, 1);
2458 // Ïðàâûé íèæíèé óãîë:
2459 aX2
:= aX
+ aX2
- 1;
2460 aY2
:= aY
+ aY2
- 1;
2462 e_DrawFillQuad(aX
, aY
, aX2
, aY2
, 255, 255, 0, 0);
2468 procedure DrawMapView(x
, y
, w
, h
: Integer);
2474 bx
:= Round(x
/(gMapInfo
.Width
- w
)*(gBackSize
.X
- w
));
2475 by
:= Round(y
/(gMapInfo
.Height
- h
)*(gBackSize
.Y
- h
));
2476 g_Map_DrawBack(-bx
, -by
);
2483 glTranslatef(-x
, -y
, 0);
2485 g_Map_DrawPanels(PANEL_BACK
);
2486 g_Map_DrawPanels(PANEL_STEP
);
2489 g_Player_DrawShells();
2491 g_Player_DrawCorpses();
2492 g_Map_DrawPanels(PANEL_WALL
);
2494 g_Map_DrawPanels(PANEL_CLOSEDOOR
);
2497 g_Map_DrawPanels(PANEL_ACID1
);
2498 g_Map_DrawPanels(PANEL_ACID2
);
2499 g_Map_DrawPanels(PANEL_WATER
);
2500 g_Map_DrawPanels(PANEL_FORE
);
2501 if g_debug_HealthBar
then
2503 g_Monsters_DrawHealth();
2504 g_Player_DrawHealth();
2510 procedure DrawPlayer(p
: TPlayer
);
2512 px
, py
, a
, b
, c
, d
: Integer;
2515 if (p
= nil) or (p
.FDummy
) then
2518 g_Map_DrawBack(0, 0);
2527 px
:= p
.GameX
+ PLAYER_RECT_CX
;
2528 py
:= p
.GameY
+ PLAYER_RECT_CY
;
2530 if px
> (gPlayerScreenSize
.X
div 2) then
2531 a
:= -px
+ (gPlayerScreenSize
.X
div 2)
2534 if py
> (gPlayerScreenSize
.Y
div 2) then
2535 b
:= -py
+ (gPlayerScreenSize
.Y
div 2)
2538 if px
> (gMapInfo
.Width
- (gPlayerScreenSize
.X
div 2)) then
2539 a
:= -gMapInfo
.Width
+ gPlayerScreenSize
.X
;
2540 if py
> (gMapInfo
.Height
- (gPlayerScreenSize
.Y
div 2)) then
2541 b
:= -gMapInfo
.Height
+ gPlayerScreenSize
.Y
;
2542 if gMapInfo
.Width
<= gPlayerScreenSize
.X
then
2544 if gMapInfo
.Height
<= gPlayerScreenSize
.Y
then
2547 if p
.IncCam
<> 0 then
2549 if py
> (gMapInfo
.Height
- (gPlayerScreenSize
.Y
div 2)) then
2551 if p
.IncCam
> 120-(py
-(gMapInfo
.Height
-(gPlayerScreenSize
.Y
div 2))) then
2552 p
.IncCam
:= 120-(py
-(gMapInfo
.Height
-(gPlayerScreenSize
.Y
div 2)));
2555 if py
< (gPlayerScreenSize
.Y
div 2) then
2557 if p
.IncCam
< -120+((gPlayerScreenSize
.Y
div 2)-py
) then
2558 p
.IncCam
:= -120+((gPlayerScreenSize
.Y
div 2)-py
);
2561 if p
.IncCam
< 0 then
2562 while (py
+(gPlayerScreenSize
.Y
div 2)-p
.IncCam
> gMapInfo
.Height
) and
2564 p
.IncCam
:= p
.IncCam
+ 1;
2566 if p
.IncCam
> 0 then
2567 while (py
-(gPlayerScreenSize
.Y
div 2)-p
.IncCam
< 0) and
2569 p
.IncCam
:= p
.IncCam
- 1;
2572 if (px
< gPlayerScreenSize
.X
div 2) or
2573 (gMapInfo
.Width
-gPlayerScreenSize
.X
<= 256) then
2576 if (px
> gMapInfo
.Width
-(gPlayerScreenSize
.X
div 2)) then
2577 c
:= gBackSize
.X
- gPlayerScreenSize
.X
2579 c
:= Round((px
-(gPlayerScreenSize
.X
div 2))/(gMapInfo
.Width
-gPlayerScreenSize
.X
)*(gBackSize
.X
-gPlayerScreenSize
.X
));
2581 if (py
-p
.IncCam
<= gPlayerScreenSize
.Y
div 2) or
2582 (gMapInfo
.Height
-gPlayerScreenSize
.Y
<= 256) then
2585 if (py
-p
.IncCam
>= gMapInfo
.Height
-(gPlayerScreenSize
.Y
div 2)) then
2586 d
:= gBackSize
.Y
- gPlayerScreenSize
.Y
2588 d
:= Round((py
-p
.IncCam
-(gPlayerScreenSize
.Y
div 2))/(gMapInfo
.Height
-gPlayerScreenSize
.Y
)*(gBackSize
.Y
-gPlayerScreenSize
.Y
));
2590 g_Map_DrawBack(-c
, -d
);
2593 sY
:= -(b
+p
.IncCam
);
2594 sWidth
:= gPlayerScreenSize
.X
;
2595 sHeight
:= gPlayerScreenSize
.Y
;
2597 glTranslatef(a
, b
+p
.IncCam
, 0);
2599 g_Map_DrawPanels(PANEL_BACK
);
2600 g_Map_DrawPanels(PANEL_STEP
);
2603 g_Player_DrawShells();
2605 g_Player_DrawCorpses();
2606 g_Map_DrawPanels(PANEL_WALL
);
2608 g_Map_DrawPanels(PANEL_CLOSEDOOR
);
2611 g_Map_DrawPanels(PANEL_ACID1
);
2612 g_Map_DrawPanels(PANEL_ACID2
);
2613 g_Map_DrawPanels(PANEL_WATER
);
2614 g_Map_DrawPanels(PANEL_FORE
);
2615 if g_debug_HealthBar
then
2617 g_Monsters_DrawHealth();
2618 g_Player_DrawHealth();
2621 if p
.FSpectator
then
2622 e_TextureFontPrintEx(p
.GameX
+ PLAYER_RECT_CX
- 4,
2623 p
.GameY
+ PLAYER_RECT_CY
- 4,
2624 'X', gStdFont
, 255, 255, 255, 1, True);
2626 for a := 0 to High(gCollideMap) do
2627 for b := 0 to High(gCollideMap[a]) do
2630 if ByteBool(gCollideMap[a, b] and MARK_WALL) then
2632 if ByteBool(gCollideMap[a, b] and MARK_DOOR) then
2636 1: e_DrawPoint(1, b, a, 200, 200, 200);
2637 2: e_DrawPoint(1, b, a, 64, 64, 255);
2638 3: e_DrawPoint(1, b, a, 255, 0, 255);
2649 //DrawMinimap(p, _TRect(0, 0, 128, 128));
2650 if g_Debug_Player
then
2651 g_Player_DrawDebug(p
);
2655 procedure g_Game_Draw();
2662 plView1
, plView2
: TPlayer
;
2665 if gExit
= EXIT_QUIT
then Exit
;
2667 Time
:= GetTimer() div 1000;
2668 FPSCounter
:= FPSCounter
+1;
2669 if Time
- FPSTime
>= 1000 then
2676 if gGameOn
or (gState
= STATE_FOLD
) then
2678 if (gPlayer1
<> nil) and (gPlayer2
<> nil) then
2680 gSpectMode
:= SPECT_NONE
;
2681 if not gRevertPlayers
then
2683 plView1
:= gPlayer1
;
2684 plView2
:= gPlayer2
;
2688 plView1
:= gPlayer2
;
2689 plView2
:= gPlayer1
;
2693 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
2695 gSpectMode
:= SPECT_NONE
;
2696 if gPlayer2
= nil then
2699 plView1
:= gPlayer2
;
2708 if (plView1
= nil) and (plView2
= nil) and (gSpectMode
= SPECT_NONE
) then
2709 gSpectMode
:= SPECT_STATS
;
2711 if gSpectMode
= SPECT_PLAYERS
then
2712 if gPlayers
<> nil then
2714 plView1
:= GetActivePlayer_ByID(gSpectPID1
);
2715 if plView1
= nil then
2717 gSpectPID1
:= GetActivePlayerID_Next();
2718 plView1
:= GetActivePlayer_ByID(gSpectPID1
);
2720 if gSpectViewTwo
then
2722 plView2
:= GetActivePlayer_ByID(gSpectPID2
);
2723 if plView2
= nil then
2725 gSpectPID2
:= GetActivePlayerID_Next();
2726 plView2
:= GetActivePlayer_ByID(gSpectPID2
);
2731 if gSpectMode
= SPECT_MAPVIEW
then
2733 // Ðåæèì ïðîñìîòðà êàðòû
2735 e_SetViewPort(0, 0, gScreenWidth
, gScreenHeight
);
2736 DrawMapView(gSpectX
, gSpectY
, gScreenWidth
, gScreenHeight
);
2737 gHearPoint1
.Active
:= True;
2738 gHearPoint1
.Coords
.X
:= gScreenWidth
div 2 + gSpectX
;
2739 gHearPoint1
.Coords
.Y
:= gScreenHeight
div 2 + gSpectY
;
2740 gHearPoint2
.Active
:= False;
2744 Split
:= (plView1
<> nil) and (plView2
<> nil);
2746 // Òî÷êè ñëóõà èãðîêîâ
2747 if plView1
<> nil then
2749 gHearPoint1
.Active
:= True;
2750 gHearPoint1
.Coords
.X
:= plView1
.GameX
;
2751 gHearPoint1
.Coords
.Y
:= plView1
.GameY
;
2753 gHearPoint1
.Active
:= False;
2754 if plView2
<> nil then
2756 gHearPoint2
.Active
:= True;
2757 gHearPoint2
.Coords
.X
:= plView2
.GameX
;
2758 gHearPoint2
.Coords
.Y
:= plView2
.GameY
;
2760 gHearPoint2
.Active
:= False;
2762 // Ðàçìåð ýêðàíîâ èãðîêîâ:
2763 gPlayerScreenSize
.X
:= gScreenWidth
-196;
2766 gPlayerScreenSize
.Y
:= gScreenHeight
div 2;
2767 if gScreenHeight
mod 2 = 0 then
2768 Dec(gPlayerScreenSize
.Y
);
2771 gPlayerScreenSize
.Y
:= gScreenHeight
;
2774 if gScreenHeight
mod 2 = 0 then
2775 e_SetViewPort(0, gPlayerScreenSize
.Y
+2, gPlayerScreenSize
.X
+196, gPlayerScreenSize
.Y
)
2777 e_SetViewPort(0, gPlayerScreenSize
.Y
+1, gPlayerScreenSize
.X
+196, gPlayerScreenSize
.Y
);
2779 DrawPlayer(plView1
);
2780 gPlayer1ScreenCoord
.X
:= sX
;
2781 gPlayer1ScreenCoord
.Y
:= sY
;
2785 e_SetViewPort(0, 0, gPlayerScreenSize
.X
+196, gPlayerScreenSize
.Y
);
2787 DrawPlayer(plView2
);
2788 gPlayer2ScreenCoord
.X
:= sX
;
2789 gPlayer2ScreenCoord
.Y
:= sY
;
2792 e_SetViewPort(0, 0, gScreenWidth
, gScreenHeight
);
2795 e_DrawLine(2, 0, gScreenHeight
div 2, gScreenWidth
, gScreenHeight
div 2, 0, 0, 0);
2798 if MessageText
<> '' then
2802 e_CharFont_GetSizeFmt(gMenuFont
, MessageText
, w
, h
);
2804 e_CharFont_PrintFmt(gMenuFont
, (gScreenWidth
div 2)-(w
div 2),
2805 (gScreenHeight
div 2)-(h
div 2), MessageText
)
2807 e_CharFont_PrintFmt(gMenuFont
, (gScreenWidth
div 2)-(w
div 2),
2808 Round(gScreenHeight
/ 2.75)-(h
div 2), MessageText
);
2811 if IsDrawStat
or (gSpectMode
= 1) then DrawStat();
2813 if gSpectHUD
and (not gChatShow
) and (gSpectMode
<> SPECT_NONE
) then
2815 // Draw spectator GUI
2818 e_TextureFontGetSize(gStdFont
, ww
, hh
);
2821 e_TextureFontPrintEx(0, gScreenHeight
- (hh
+2)*2, 'MODE: Stats', gStdFont
, 255, 255, 255, 1);
2823 e_TextureFontPrintEx(0, gScreenHeight
- (hh
+2)*2, 'MODE: Observe Map', gStdFont
, 255, 255, 255, 1);
2825 e_TextureFontPrintEx(0, gScreenHeight
- (hh
+2)*2, 'MODE: Watch Players', gStdFont
, 255, 255, 255, 1);
2827 e_TextureFontPrintEx(2*ww
, gScreenHeight
- (hh
+2), '< jump >', gStdFont
, 255, 255, 255, 1);
2828 if gSpectMode
= SPECT_MAPVIEW
then
2830 e_TextureFontPrintEx(22*ww
, gScreenHeight
- (hh
+2)*2, '[-]', gStdFont
, 255, 255, 255, 1);
2831 e_TextureFontPrintEx(26*ww
, gScreenHeight
- (hh
+2)*2, 'Step ' + IntToStr(gSpectStep
), gStdFont
, 255, 255, 255, 1);
2832 e_TextureFontPrintEx(34*ww
, gScreenHeight
- (hh
+2)*2, '[+]', gStdFont
, 255, 255, 255, 1);
2833 e_TextureFontPrintEx(18*ww
, gScreenHeight
- (hh
+2), '<prev weap>', gStdFont
, 255, 255, 255, 1);
2834 e_TextureFontPrintEx(30*ww
, gScreenHeight
- (hh
+2), '<next weap>', gStdFont
, 255, 255, 255, 1);
2836 if gSpectMode
= SPECT_PLAYERS
then
2838 e_TextureFontPrintEx(22*ww
, gScreenHeight
- (hh
+2)*2, 'Player 1', gStdFont
, 255, 255, 255, 1);
2839 e_TextureFontPrintEx(20*ww
, gScreenHeight
- (hh
+2), '<left/right>', gStdFont
, 255, 255, 255, 1);
2840 if gSpectViewTwo
then
2842 e_TextureFontPrintEx(37*ww
, gScreenHeight
- (hh
+2)*2, 'Player 2', gStdFont
, 255, 255, 255, 1);
2843 e_TextureFontPrintEx(34*ww
, gScreenHeight
- (hh
+2), '<prev w/next w>', gStdFont
, 255, 255, 255, 1);
2844 e_TextureFontPrintEx(52*ww
, gScreenHeight
- (hh
+2)*2, '2x View', gStdFont
, 255, 255, 255, 1);
2845 e_TextureFontPrintEx(51*ww
, gScreenHeight
- (hh
+2), '<up/down>', gStdFont
, 255, 255, 255, 1);
2849 e_TextureFontPrintEx(35*ww
, gScreenHeight
- (hh
+2)*2, '2x View', gStdFont
, 255, 255, 255, 1);
2850 e_TextureFontPrintEx(34*ww
, gScreenHeight
- (hh
+2), '<up/down>', gStdFont
, 255, 255, 255, 1);
2856 if gPause
and gGameOn
and (g_ActiveWindow
= nil) then
2858 e_DrawFillQuad(0, 0, gScreenWidth
-1, gScreenHeight
-1, 48, 48, 48, 180);
2860 e_CharFont_GetSize(gMenuFont
, _lc
[I_MENU_PAUSE
], w
, h
);
2861 e_CharFont_Print(gMenuFont
, (gScreenWidth
div 2)-(w
div 2),
2862 (gScreenHeight
div 2)-(h
div 2), _lc
[I_MENU_PAUSE
]);
2867 if (gState
= STATE_MENU
) then
2869 if ((g_ActiveWindow
= nil) or (g_ActiveWindow
.BackTexture
= '')) then
2871 if g_Texture_Get('MENU_BACKGROUND', ID
) then
2872 e_DrawSize(ID
, 0, 0, 0, False, False, gScreenWidth
, gScreenHeight
)
2873 else e_Clear(GL_COLOR_BUFFER_BIT
, 0, 0, 0);
2875 if g_ActiveWindow
<> nil then
2876 e_DrawFillQuad(0, 0, gScreenWidth
-1, gScreenHeight
-1, 48, 48, 48, 180);
2879 if gState
= STATE_FOLD
then
2880 e_DrawFillQuad(0, 0, gScreenWidth
-1, gScreenHeight
-1, 0, 0, 0, EndingGameCounter
);
2882 if gState
= STATE_INTERCUSTOM
then
2884 if gLastMap
and (gGameSettings
.GameMode
= GM_COOP
) then
2886 back
:= 'TEXTURE_endpic';
2887 if not g_Texture_Get(back
, ID
) then
2888 back
:= _lc
[I_TEXTURE_ENDPIC
];
2893 if g_Texture_Get(back
, ID
) then
2894 e_DrawSize(ID
, 0, 0, 0, False, False, gScreenWidth
, gScreenHeight
)
2896 e_Clear(GL_COLOR_BUFFER_BIT
, 0, 0, 0);
2900 if g_ActiveWindow
<> nil then
2901 e_DrawFillQuad(0, 0, gScreenWidth
-1, gScreenHeight
-1, 48, 48, 48, 180);
2904 if gState
= STATE_INTERSINGLE
then
2906 if EndingGameCounter
> 0 then
2907 e_DrawFillQuad(0, 0, gScreenWidth
-1, gScreenHeight
-1, 0, 0, 0, EndingGameCounter
)
2912 if g_Texture_Get(back
, ID
) then
2913 e_DrawSize(ID
, 0, 0, 0, False, False, gScreenWidth
, gScreenHeight
)
2915 e_Clear(GL_COLOR_BUFFER_BIT
, 0, 0, 0);
2919 if g_ActiveWindow
<> nil then
2920 e_DrawFillQuad(0, 0, gScreenWidth
-1, gScreenHeight
-1, 48, 48, 48, 180);
2924 if gState
= STATE_ENDPIC
then
2927 if not g_Texture_Get('TEXTURE_endpic', ID
) then
2928 g_Texture_Get(_lc
[I_TEXTURE_ENDPIC
], ID
);
2930 if ID
<> DWORD(-1) then
2931 e_DrawSize(ID
, 0, 0, 0, False, False, gScreenWidth
, gScreenHeight
)
2933 e_Clear(GL_COLOR_BUFFER_BIT
, 0, 0, 0);
2935 if g_ActiveWindow
<> nil then
2936 e_DrawFillQuad(0, 0, gScreenWidth
-1, gScreenHeight
-1, 48, 48, 48, 180);
2939 if gState
= STATE_SLIST
then
2941 if g_Texture_Get('MENU_BACKGROUND', ID
) then
2943 e_DrawSize(ID
, 0, 0, 0, False, False, gScreenWidth
, gScreenHeight
);
2944 e_DrawFillQuad(0, 0, gScreenWidth
-1, gScreenHeight
-1, 48, 48, 48, 180);
2946 g_Serverlist_Draw(slCurrent
);
2950 if g_ActiveWindow
<> nil then
2953 e_DrawFillQuad(0, 0, gScreenWidth
-1, gScreenHeight
-1, 48, 48, 48, 180);
2954 g_ActiveWindow
.Draw();
2960 if g_debug_Sounds and gGameOn then
2962 for w := 0 to High(e_SoundsArray) do
2963 for h := 0 to e_SoundsArray[w].nRefs do
2964 e_DrawPoint(1, w+100, h+100, 255, 0, 0);
2970 e_TextureFontPrint(0, 0, Format('FPS: %d', [FPS
]), gStdFont
);
2971 e_TextureFontPrint(0, 16, Format('UPS: %d', [UPS
]), gStdFont
);
2974 if gGameOn
and gShowTime
and (gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
]) then
2975 e_TextureFontPrint(gScreenWidth
-72, 0,
2976 Format('%d:%.2d:%.2d', [gTime
div 1000 div 3600, (gTime
div 1000 div 60) mod 60, gTime
div 1000 mod 60]),
2980 procedure g_Game_Quit();
2982 g_Game_StopAllSounds(True);
2984 g_Game_SaveOptions();
2986 g_PlayerModel_FreeData();
2987 g_Texture_DeleteAll();
2988 g_Frames_DeleteAll();
2991 if NetInitDone
then g_Net_Free
;
2993 // Íàäî óäàëèòü êàðòó ïîñëå òåñòà:
2994 if gMapToDelete
<> '' then
2995 g_Game_DeleteTestMap();
3001 procedure g_FatalError(Text: String);
3003 g_Console_Add(Format(_lc
[I_FATAL_ERROR
], [Text]), True);
3004 e_WriteLog(Format(_lc
[I_FATAL_ERROR
], [Text]), MSG_WARNING
);
3006 gExit
:= EXIT_SIMPLE
;
3009 procedure g_SimpleError(Text: String);
3011 g_Console_Add(Format(_lc
[I_SIMPLE_ERROR
], [Text]), True);
3012 e_WriteLog(Format(_lc
[I_SIMPLE_ERROR
], [Text]), MSG_WARNING
);
3015 procedure g_Game_SetupScreenSize();
3019 // Ðàçìåð ýêðàíîâ èãðîêîâ:
3020 gPlayerScreenSize
.X
:= gScreenWidth
-196;
3021 if (gPlayer1
<> nil) and (gPlayer2
<> nil) then
3022 gPlayerScreenSize
.Y
:= gScreenHeight
div 2
3024 gPlayerScreenSize
.Y
:= gScreenHeight
;
3026 // Ðàçìåð çàäíåãî ïëàíà:
3027 if BackID
<> DWORD(-1) then
3031 if (gScreenWidth
*d
> gMapInfo
.Width
) or
3032 (gScreenHeight
*d
> gMapInfo
.Height
) then
3035 gBackSize
.X
:= Round(gScreenWidth
*d
);
3036 gBackSize
.Y
:= Round(gScreenHeight
*d
);
3040 procedure g_Game_ChangeResolution(newWidth
, newHeight
: Word; nowFull
, nowMax
: Boolean);
3042 g_Window_SetSize(newWidth
, newHeight
, nowFull
);
3045 procedure g_Game_AddPlayer(Team
: Byte = TEAM_NONE
);
3047 if ((not gGameOn
) and (gState
<> STATE_INTERCUSTOM
))
3048 or (not (gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
])) then
3050 if gPlayer1
= nil then
3052 if g_Game_IsClient
then
3054 if NetPlrUID1
> -1 then
3056 MC_SEND_CheatRequest(NET_CHEAT_SPECTATE
);
3057 gPlayer1
:= g_Player_Get(NetPlrUID1
);
3062 if not (Team
in [TEAM_RED
, TEAM_BLUE
]) then
3063 Team
:= gPlayer1Settings
.Team
;
3065 // Ñîçäàíèå ïåðâîãî èãðîêà:
3066 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
3067 gPlayer1Settings
.Color
,
3069 if gPlayer1
= nil then
3070 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]))
3073 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
3074 g_Console_Add(Format(_lc
[I_PLAYER_JOIN
], [gPlayer1
.Name
]), True);
3075 if g_Game_IsServer
and g_Game_IsNet
then
3076 MH_SEND_PlayerCreate(gPlayer1
.UID
);
3077 gPlayer1
.Respawn(False, True);
3079 if g_Game_IsNet
and NetUseMaster
then
3085 if gPlayer2
= nil then
3087 if g_Game_IsClient
then
3089 if NetPlrUID2
> -1 then
3090 gPlayer2
:= g_Player_Get(NetPlrUID2
);
3094 if not (Team
in [TEAM_RED
, TEAM_BLUE
]) then
3095 Team
:= gPlayer2Settings
.Team
;
3097 // Ñîçäàíèå âòîðîãî èãðîêà:
3098 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
3099 gPlayer2Settings
.Color
,
3101 if gPlayer2
= nil then
3102 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]))
3105 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
3106 g_Console_Add(Format(_lc
[I_PLAYER_JOIN
], [gPlayer2
.Name
]), True);
3107 if g_Game_IsServer
and g_Game_IsNet
then
3108 MH_SEND_PlayerCreate(gPlayer2
.UID
);
3109 gPlayer2
.Respawn(False, True);
3111 if g_Game_IsNet
and NetUseMaster
then
3119 procedure g_Game_RemovePlayer();
3123 if ((not gGameOn
) and (gState
<> STATE_INTERCUSTOM
))
3124 or (not (gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
])) then
3129 if g_Game_IsServer
then
3132 Pl
.Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
3133 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [Pl
.Name
]), True);
3134 g_Player_Remove(Pl
.UID
);
3136 if g_Game_IsNet
and NetUseMaster
then
3145 if g_Game_IsServer
then
3148 Pl
.Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
3149 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [Pl
.Name
]), True);
3150 g_Player_Remove(Pl
.UID
);
3152 if g_Game_IsNet
and NetUseMaster
then
3157 MC_SEND_CheatRequest(NET_CHEAT_SPECTATE
);
3163 procedure g_Game_Spectate();
3165 g_Game_RemovePlayer();
3166 if gPlayer1
<> nil then
3167 g_Game_RemovePlayer();
3170 procedure g_Game_SpectateCenterView();
3172 gSpectX
:= Max(gMapInfo
.Width
div 2 - gScreenWidth
div 2, 0);
3173 gSpectY
:= Max(gMapInfo
.Height
div 2 - gScreenHeight
div 2, 0);
3176 procedure g_Game_StartSingle(Map
: String; TwoPlayers
: Boolean; nPlayers
: Byte);
3182 e_WriteLog('Starting singleplayer game...', MSG_NOTIFY
);
3184 g_Game_ClearLoading();
3187 FillByte(gGameSettings
, SizeOf(TGameSettings
), 0);
3190 gGameSettings
.GameType
:= GT_SINGLE
;
3191 gGameSettings
.MaxLives
:= 0;
3192 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_ALLOWEXIT
;
3193 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_MONSTERS
;
3194 gGameSettings
.Options
:= gGameSettings
.Options
+ GAME_OPTION_BOTVSMONSTER
;
3195 gSwitchGameMode
:= GM_SINGLE
;
3197 g_Game_ExecuteEvent('ongamestart');
3199 // Óñòàíîâêà ðàçìåðîâ îêîí èãðîêîâ:
3200 g_Game_SetupScreenSize();
3202 // Ñîçäàíèå ïåðâîãî èãðîêà:
3203 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
3204 gPlayer1Settings
.Color
,
3205 gPlayer1Settings
.Team
, False));
3206 if gPlayer1
= nil then
3208 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
3212 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
3215 // Ñîçäàíèå âòîðîãî èãðîêà, åñëè åñòü:
3218 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
3219 gPlayer2Settings
.Color
,
3220 gPlayer2Settings
.Team
, False));
3221 if gPlayer2
= nil then
3223 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]));
3227 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
3231 // Çàãðóçêà è çàïóñê êàðòû:
3232 if not g_Game_StartMap(MAP
, True) then
3234 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [gGameSettings
.WAD
+ ':\' + MAP
]));
3238 // Íàñòðîéêè èãðîêîâ è áîòîâ:
3242 for i
:= nPl
+1 to nPlayers
do
3243 g_Player_Create(STD_PLAYER_MODEL
, _RGB(0, 0, 0), 0, True);
3246 procedure g_Game_StartCustom(Map
: String; GameMode
: Byte;
3247 TimeLimit
, GoalLimit
: Word;
3249 Options
: LongWord; nPlayers
: Byte);
3255 e_WriteLog('Starting custom game...', MSG_NOTIFY
);
3257 g_Game_ClearLoading();
3260 gGameSettings
.GameType
:= GT_CUSTOM
;
3261 gGameSettings
.GameMode
:= GameMode
;
3262 gSwitchGameMode
:= GameMode
;
3263 gGameSettings
.TimeLimit
:= TimeLimit
;
3264 gGameSettings
.GoalLimit
:= GoalLimit
;
3265 gGameSettings
.MaxLives
:= IfThen(GameMode
= GM_CTF
, 0, MaxLives
);
3266 gGameSettings
.Options
:= Options
;
3268 gCoopTotalMonstersKilled
:= 0;
3269 gCoopTotalSecretsFound
:= 0;
3270 gCoopTotalMonsters
:= 0;
3271 gCoopTotalSecrets
:= 0;
3275 g_Game_ExecuteEvent('ongamestart');
3277 // Óñòàíîâêà ðàçìåðîâ îêîí èãðîêîâ:
3278 g_Game_SetupScreenSize();
3280 // Ðåæèì íàáëþäàòåëÿ:
3281 if nPlayers
= 0 then
3288 if nPlayers
>= 1 then
3290 // Ñîçäàíèå ïåðâîãî èãðîêà:
3291 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
3292 gPlayer1Settings
.Color
,
3293 gPlayer1Settings
.Team
, False));
3294 if gPlayer1
= nil then
3296 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
3300 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
3304 if nPlayers
>= 2 then
3306 // Ñîçäàíèå âòîðîãî èãðîêà:
3307 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
3308 gPlayer2Settings
.Color
,
3309 gPlayer2Settings
.Team
, False));
3310 if gPlayer2
= nil then
3312 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]));
3316 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
3320 // Çàãðóçêà è çàïóñê êàðòû:
3321 if not g_Game_StartMap(Map
, True) then
3323 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [Map
]));
3327 // Íåò òî÷åê ïîÿâëåíèÿ:
3328 if (g_Map_GetPointCount(RESPAWNPOINT_PLAYER1
) +
3329 g_Map_GetPointCount(RESPAWNPOINT_PLAYER2
) +
3330 g_Map_GetPointCount(RESPAWNPOINT_DM
) +
3331 g_Map_GetPointCount(RESPAWNPOINT_RED
)+
3332 g_Map_GetPointCount(RESPAWNPOINT_BLUE
)) < 1 then
3334 g_FatalError(_lc
[I_GAME_ERROR_GET_SPAWN
]);
3338 // Íàñòðîéêè èãðîêîâ è áîòîâ:
3342 for i
:= nPl
+1 to nPlayers
do
3343 g_Player_Create(STD_PLAYER_MODEL
, _RGB(0, 0, 0), 0, True);
3346 procedure g_Game_StartServer(Map
: String; GameMode
: Byte;
3347 TimeLimit
, GoalLimit
: Word; MaxLives
: Byte;
3348 Options
: LongWord; nPlayers
: Byte;
3349 IPAddr
: LongWord; Port
: Word);
3353 e_WriteLog('Starting net game (server)...', MSG_NOTIFY
);
3355 g_Game_ClearLoading();
3358 gGameSettings
.GameType
:= GT_SERVER
;
3359 gGameSettings
.GameMode
:= GameMode
;
3360 gSwitchGameMode
:= GameMode
;
3361 gGameSettings
.TimeLimit
:= TimeLimit
;
3362 gGameSettings
.GoalLimit
:= GoalLimit
;
3363 gGameSettings
.MaxLives
:= IfThen(GameMode
= GM_CTF
, 0, MaxLives
);
3364 gGameSettings
.Options
:= Options
;
3366 gCoopTotalMonstersKilled
:= 0;
3367 gCoopTotalSecretsFound
:= 0;
3368 gCoopTotalMonsters
:= 0;
3369 gCoopTotalSecrets
:= 0;
3373 g_Game_ExecuteEvent('ongamestart');
3375 // Óñòàíîâêà ðàçìåðîâ îêíà èãðîêà
3376 g_Game_SetupScreenSize();
3378 // Ðåæèì íàáëþäàòåëÿ:
3379 if nPlayers
= 0 then
3385 if nPlayers
>= 1 then
3387 // Ñîçäàíèå ïåðâîãî èãðîêà:
3388 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
3389 gPlayer1Settings
.Color
,
3390 gPlayer1Settings
.Team
, False));
3391 if gPlayer1
= nil then
3393 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
3397 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
3400 if nPlayers
>= 2 then
3402 // Ñîçäàíèå âòîðîãî èãðîêà:
3403 gPlayer2
:= g_Player_Get(g_Player_Create(gPlayer2Settings
.Model
,
3404 gPlayer2Settings
.Color
,
3405 gPlayer2Settings
.Team
, False));
3406 if gPlayer2
= nil then
3408 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [2]));
3412 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
3416 if not g_Net_Host(IPAddr
, Port
, NetMaxClients
) then
3418 g_FatalError(_lc
[I_NET_MSG
] + _lc
[I_NET_ERR_HOST
]);
3422 g_Net_Slist_Set(NetSlistIP
, NetSlistPort
);
3424 // Çàãðóçêà è çàïóñê êàðòû:
3425 if not g_Game_StartMap(Map
, True) then
3427 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [Map
]));
3431 // Íåò òî÷åê ïîÿâëåíèÿ:
3432 if (g_Map_GetPointCount(RESPAWNPOINT_PLAYER1
) +
3433 g_Map_GetPointCount(RESPAWNPOINT_PLAYER2
) +
3434 g_Map_GetPointCount(RESPAWNPOINT_DM
) +
3435 g_Map_GetPointCount(RESPAWNPOINT_RED
)+
3436 g_Map_GetPointCount(RESPAWNPOINT_BLUE
)) < 1 then
3438 g_FatalError(_lc
[I_GAME_ERROR_GET_SPAWN
]);
3442 // Íàñòðîéêè èãðîêîâ è áîòîâ:
3445 NetState
:= NET_STATE_GAME
;
3448 procedure g_Game_StartClient(Addr
: String; Port
: Word; PW
: String);
3462 e_WriteLog('Starting net game (client)...', MSG_NOTIFY
);
3463 e_WriteLog('NET: Trying to connect to ' + Addr
+ ':' + IntToStr(Port
) + '...', MSG_NOTIFY
);
3465 g_Game_ClearLoading();
3468 gGameSettings
.GameType
:= GT_CLIENT
;
3470 gCoopTotalMonstersKilled
:= 0;
3471 gCoopTotalSecretsFound
:= 0;
3472 gCoopTotalMonsters
:= 0;
3473 gCoopTotalSecrets
:= 0;
3477 g_Game_ExecuteEvent('ongamestart');
3479 // Óñòàíîâêà ðàçìåðîâ îêîí èãðîêîâ:
3480 g_Game_SetupScreenSize();
3482 NetState
:= NET_STATE_AUTH
;
3484 g_Game_SetLoadingText(_lc
[I_LOAD_CONNECT
], 0, False);
3486 if not g_Net_Connect(Addr
, Port
) then
3488 g_FatalError(_lc
[I_NET_MSG
] + _lc
[I_NET_ERR_CONN
]);
3489 NetState
:= NET_STATE_NONE
;
3493 g_Game_SetLoadingText(_lc
[I_LOAD_SEND_INFO
], 0, False);
3495 g_Game_SetLoadingText(_lc
[I_LOAD_WAIT_INFO
], 0, False);
3500 while (enet_host_service(NetHost
, @NetEvent
, 0) > 0) do
3502 if (NetEvent
.kind
= ENET_EVENT_TYPE_RECEIVE
) then
3504 Ptr
:= NetEvent
.packet
^.data
;
3507 MID
:= e_Raw_Read_Byte(Ptr
);
3509 if (MID
= NET_MSG_INFO
) and (State
= 0) then
3511 NetMyID
:= e_Raw_Read_Byte(Ptr
);
3512 NetPlrUID1
:= e_Raw_Read_Word(Ptr
);
3514 WadName
:= e_Raw_Read_String(Ptr
);
3515 Map
:= e_Raw_Read_String(Ptr
);
3517 gWADHash
:= e_Raw_Read_MD5(Ptr
);
3519 gGameSettings
.GameMode
:= e_Raw_Read_Byte(Ptr
);
3520 gSwitchGameMode
:= gGameSettings
.GameMode
;
3521 gGameSettings
.GoalLimit
:= e_Raw_Read_Word(Ptr
);
3522 gGameSettings
.TimeLimit
:= e_Raw_Read_Word(Ptr
);
3523 gGameSettings
.MaxLives
:= e_Raw_Read_Byte(Ptr
);
3524 gGameSettings
.Options
:= e_Raw_Read_LongWord(Ptr
);
3525 T
:= e_Raw_Read_LongWord(Ptr
);
3527 newResPath
:= g_Res_SearchSameWAD(MapsDir
, WadName
, gWADHash
);
3528 if newResPath
= '' then
3530 g_Game_SetLoadingText(_lc
[I_LOAD_DL_RES
], 0, False);
3531 newResPath
:= g_Res_DownloadWAD(WadName
);
3532 if newResPath
= '' then
3534 g_FatalError(_lc
[I_NET_ERR_HASH
]);
3535 enet_packet_destroy(NetEvent
.packet
);
3536 NetState
:= NET_STATE_NONE
;
3540 newResPath
:= ExtractRelativePath(MapsDir
, newResPath
);
3542 gPlayer1
:= g_Player_Get(g_Player_Create(gPlayer1Settings
.Model
,
3543 gPlayer1Settings
.Color
,
3544 gPlayer1Settings
.Team
, False));
3546 if gPlayer1
= nil then
3548 g_FatalError(Format(_lc
[I_GAME_ERROR_PLAYER_CREATE
], [1]));
3550 enet_packet_destroy(NetEvent
.packet
);
3551 NetState
:= NET_STATE_NONE
;
3555 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
3556 gPlayer1
.UID
:= NetPlrUID1
;
3557 gPlayer1
.Reset(True);
3559 if not g_Game_StartMap(newResPath
+ ':\' + Map
, True) then
3561 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [WadName
+ ':\' + Map
]));
3563 enet_packet_destroy(NetEvent
.packet
);
3564 NetState
:= NET_STATE_NONE
;
3572 enet_packet_destroy(NetEvent
.packet
);
3576 enet_packet_destroy(NetEvent
.packet
);
3579 if (NetEvent
.kind
= ENET_EVENT_TYPE_DISCONNECT
) then
3582 if (NetEvent
.data
<= NET_DISC_MAX
) then
3583 g_Console_Add(_lc
[I_NET_MSG_ERROR
] + _lc
[I_NET_ERR_CONN
] + ' ' +
3584 _lc
[TStrings_Locale(Cardinal(I_NET_DISC_NONE
) + NetEvent
.data
)], True);
3594 if e_KeyPressed(IK_ESCAPE
) or e_KeyPressed(IK_SPACE
) then
3603 g_FatalError(_lc
[I_NET_MSG
] + _lc
[I_NET_ERR_CONN
]);
3604 NetState
:= NET_STATE_NONE
;
3608 gLMSRespawn
:= LMS_RESPAWN_NONE
;
3609 gLMSRespawnTime
:= 0;
3612 NetState
:= NET_STATE_GAME
;
3613 MC_SEND_FullStateRequest
;
3614 e_WriteLog('NET: Connection successful.', MSG_NOTIFY
);
3617 procedure g_Game_SaveOptions();
3619 g_Options_Write_Video(GameDir
+'/'+CONFIG_FILENAME
);
3622 procedure g_Game_ChangeMap(MapPath
: String);
3626 g_Game_ClearLoading();
3628 Force
:= gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
];
3629 // Åñëè óðîâåíü çàâåðøèëñÿ ïî òðèããåðó Âûõîä, íå î÷èùàòü èíâåíòàðü
3630 if gExitByTrigger
then
3633 gExitByTrigger
:= False;
3635 if not g_Game_StartMap(MapPath
, Force
) then
3636 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_LOAD
], [MapPath
]));
3639 procedure g_Game_Restart();
3643 if g_Game_IsClient
then
3645 g_ProcessResourceStr(gMapInfo
.Map
, nil, nil, @Map
);
3649 g_Game_ClearLoading();
3650 g_Game_StartMap(Map
, True);
3653 function g_Game_StartMap(Map
: String; Force
: Boolean = False): Boolean;
3655 NewWAD
, ResName
: String;
3659 g_Player_RemoveAllCorpses();
3661 if (not g_Game_IsClient
) and
3662 (gSwitchGameMode
<> gGameSettings
.GameMode
) and
3663 (gGameSettings
.GameMode
<> GM_SINGLE
) then
3665 if gSwitchGameMode
= GM_CTF
then
3666 gGameSettings
.MaxLives
:= 0;
3667 gGameSettings
.GameMode
:= gSwitchGameMode
;
3670 gSwitchGameMode
:= gGameSettings
.GameMode
;
3672 g_Player_ResetTeams();
3674 if Pos(':\', Map
) > 0 then
3676 g_ProcessResourceStr(Map
, @NewWAD
, nil, @ResName
);
3677 if g_Game_IsServer
then
3679 gWADHash
:= MD5File(MapsDir
+ NewWAD
);
3680 g_Game_LoadWAD(NewWAD
);
3682 // hash recieved in MC_RECV_GameEvent -> NET_EV_MAPSTART
3683 g_Game_ClientWAD(NewWAD
, gWADHash
);
3687 Result
:= g_Map_Load(MapsDir
+ gGameSettings
.WAD
+ ':\' + ResName
);
3690 g_Player_ResetAll(Force
or gLastMap
, gGameSettings
.GameType
= GT_SINGLE
);
3692 gState
:= STATE_NONE
;
3693 g_ActiveWindow
:= nil;
3699 if gGameSettings
.GameMode
= GM_CTF
then
3701 g_Map_ResetFlag(FLAG_RED
);
3702 g_Map_ResetFlag(FLAG_BLUE
);
3703 // CTF, à ôëàãîâ íåò:
3704 if not g_Map_HaveFlagPoints() then
3705 g_SimpleError(_lc
[I_GAME_ERROR_CTF
]);
3710 gState
:= STATE_MENU
;
3717 NetTimeToUpdate
:= 1;
3718 NetTimeToReliable
:= 0;
3719 NetTimeToMaster
:= NetMasterRate
;
3720 gLMSRespawn
:= LMS_RESPAWN_NONE
;
3721 gLMSRespawnTime
:= 0;
3722 gMissionFailed
:= False;
3725 gCoopMonstersKilled
:= 0;
3726 gCoopSecretsFound
:= 0;
3728 gVoteInProgress
:= False;
3729 gVotePassed
:= False;
3735 if not gGameOn
then Exit
;
3737 g_Game_SpectateCenterView();
3739 if (gGameSettings
.MaxLives
> 0) and (gGameSettings
.WarmupTime
> 0) then
3741 gLMSRespawn
:= LMS_RESPAWN_WARMUP
;
3742 gLMSRespawnTime
:= gTime
+ gGameSettings
.WarmupTime
*1000;
3743 gLMSSoftSpawn
:= True;
3744 if NetMode
= NET_SERVER
then
3745 MH_SEND_GameEvent(NET_EV_LMS_WARMUP
, (gLMSRespawnTime
- gTime
) div 1000)
3747 g_Console_Add(Format(_lc
[I_MSG_WARMUP_START
], [(gLMSRespawnTime
- gTime
) div 1000]), True);
3750 if NetMode
= NET_SERVER
then
3752 MH_SEND_GameEvent(NET_EV_MAPSTART
, gGameSettings
.GameMode
, Map
);
3755 if NetUseMaster
then
3757 if (NetMHost
= nil) or (NetMPeer
= nil) then
3758 if not g_Net_Slist_Connect
then
3759 g_Console_Add(_lc
[I_NET_MSG_ERROR
] + _lc
[I_NET_SLIST_ERROR
]);
3764 if NetClients
<> nil then
3765 for I
:= 0 to High(NetClients
) do
3766 if NetClients
[I
].Used
then
3768 NetClients
[I
].Voted
:= False;
3769 if NetClients
[I
].RequestedFullUpdate
then
3771 MH_SEND_Everything((NetClients
[I
].State
= NET_STATE_AUTH
), I
);
3772 NetClients
[I
].RequestedFullUpdate
:= False;
3776 g_Net_UnbanNonPermHosts();
3781 gCoopTotalMonstersKilled
:= 0;
3782 gCoopTotalSecretsFound
:= 0;
3783 gCoopTotalMonsters
:= 0;
3784 gCoopTotalSecrets
:= 0;
3788 g_Game_ExecuteEvent('onmapstart');
3791 procedure SetFirstLevel();
3795 MapList
:= g_Map_GetMapsList(MapsDir
+ gGameSettings
.WAD
);
3796 if MapList
= nil then
3799 SortSArray(MapList
);
3800 gNextMap
:= MapList
[Low(MapList
)];
3805 procedure g_Game_ExitLevel(Map
: Char16
);
3809 gCoopTotalMonstersKilled
:= gCoopTotalMonstersKilled
+ gCoopMonstersKilled
;
3810 gCoopTotalSecretsFound
:= gCoopTotalSecretsFound
+ gCoopSecretsFound
;
3811 gCoopTotalMonsters
:= gCoopTotalMonsters
+ gTotalMonsters
;
3812 gCoopTotalSecrets
:= gCoopTotalSecrets
+ gSecretsCount
;
3814 // Âûøëè â âûõîä â Îäèíî÷íîé èãðå:
3815 if gGameSettings
.GameType
= GT_SINGLE
then
3816 gExit
:= EXIT_ENDLEVELSINGLE
3817 else // Âûøëè â âûõîä â Ñâîåé èãðå
3819 gExit
:= EXIT_ENDLEVELCUSTOM
;
3820 if gGameSettings
.GameMode
= GM_COOP
then
3821 g_Player_RememberAll
;
3823 if not g_Map_Exist(MapsDir
+ gGameSettings
.WAD
+ ':\' + gNextMap
) then
3826 if gGameSettings
.GameMode
= GM_COOP
then
3829 gStatsPressed
:= True;
3830 gNextMap
:= 'MAP01';
3832 if not g_Map_Exist(MapsDir
+ gGameSettings
.WAD
+ ':\' + gNextMap
) then
3835 if g_Game_IsNet
then
3837 MH_SEND_GameStats();
3838 MH_SEND_CoopStats();
3844 procedure g_Game_RestartLevel();
3848 if gGameSettings
.GameMode
= GM_SINGLE
then
3853 gExit
:= EXIT_ENDLEVELCUSTOM
;
3854 g_ProcessResourceStr(gMapInfo
.Map
, nil, nil, @Map
);
3858 procedure g_Game_ClientWAD(NewWAD
: String; WHash
: TMD5Digest
);
3862 if LowerCase(NewWAD
) = LowerCase(gGameSettings
.WAD
) then
3864 if not g_Game_IsClient
then
3866 gWAD
:= g_Res_SearchSameWAD(MapsDir
, ExtractFileName(NewWAD
), WHash
);
3869 g_Game_SetLoadingText(_lc
[I_LOAD_DL_RES
], 0, False);
3870 gWAD
:= g_Res_DownloadWAD(ExtractFileName(NewWAD
));
3874 g_FatalError(Format(_lc
[I_GAME_ERROR_MAP_WAD
], [ExtractFileName(NewWAD
)]));
3878 NewWAD
:= ExtractRelativePath(MapsDir
, gWAD
);
3879 g_Game_LoadWAD(NewWAD
);
3882 procedure g_Game_RestartRound(NoMapRestart
: Boolean = False);
3884 i
, n
, nb
, nr
: Integer;
3886 if not g_Game_IsServer
then Exit
;
3887 if gLMSRespawn
= LMS_RESPAWN_NONE
then Exit
;
3888 gLMSRespawn
:= LMS_RESPAWN_NONE
;
3889 gLMSRespawnTime
:= 0;
3892 if (gGameSettings
.GameMode
= GM_COOP
) and not NoMapRestart
then
3894 gMissionFailed
:= True;
3895 g_Game_RestartLevel
;
3899 n
:= 0; nb
:= 0; nr
:= 0;
3900 for i
:= Low(gPlayers
) to High(gPlayers
) do
3901 if (gPlayers
[i
] <> nil) and
3902 ((not gPlayers
[i
].FSpectator
) or gPlayers
[i
].FWantsInGame
or
3903 (gPlayers
[i
] is TBot
)) then
3906 if gPlayers
[i
].Team
= TEAM_RED
then Inc(nr
)
3907 else if gPlayers
[i
].Team
= TEAM_BLUE
then Inc(nb
)
3910 if (n
< 2) or ((gGameSettings
.GameMode
= GM_TDM
) and ((nr
= 0) or (nb
= 0))) then
3912 // wait a second until the fuckers finally decide to join
3913 gLMSRespawn
:= LMS_RESPAWN_WARMUP
;
3914 gLMSRespawnTime
:= gTime
+ 1000;
3915 gLMSSoftSpawn
:= NoMapRestart
;
3919 g_Player_RemoveAllCorpses
;
3920 g_Game_Message(_lc
[I_MESSAGE_LMS_START
], 144);
3921 if g_Game_IsNet
then
3922 MH_SEND_GameEvent(NET_EV_LMS_START
);
3924 for i
:= Low(gPlayers
) to High(gPlayers
) do
3926 if gPlayers
[i
] = nil then continue
;
3927 if gPlayers
[i
] is TBot
then gPlayers
[i
].FWantsInGame
:= True;
3928 // don't touch normal spectators
3929 if gPlayers
[i
].FSpectator
and not gPlayers
[i
].FWantsInGame
then
3931 gPlayers
[i
].FNoRespawn
:= True;
3932 gPlayers
[i
].Lives
:= 0;
3933 if g_Game_IsNet
then
3934 MH_SEND_PlayerStats(gPlayers
[I
].UID
);
3937 gPlayers
[i
].FNoRespawn
:= False;
3938 gPlayers
[i
].Lives
:= gGameSettings
.MaxLives
;
3939 gPlayers
[i
].Respawn(False, True);
3940 if gGameSettings
.GameMode
= GM_COOP
then
3942 gPlayers
[i
].Frags
:= 0;
3943 gPlayers
[i
].RecallState
;
3945 if (gPlayer1
= nil) and (gLMSPID1
> 0) then
3946 gPlayer1
:= g_Player_Get(gLMSPID1
);
3947 if (gPlayer2
= nil) and (gLMSPID2
> 0) then
3948 gPlayer2
:= g_Player_Get(gLMSPID2
);
3951 for i
:= Low(gItems
) to High(gItems
) do
3953 if gItems
[i
].Respawnable
then
3955 gItems
[i
].QuietRespawn
:= True;
3956 gItems
[i
].RespawnTime
:= 0;
3961 if g_Game_IsNet
then MH_SEND_ItemDestroy(True, i
);
3965 for i
:= Low(gMonsters
) to High(gMonsters
) do
3967 if (gMonsters
[i
] <> nil) and not gMonsters
[i
].FNoRespawn
then
3968 gMonsters
[i
].Respawn
;
3971 gLMSSoftSpawn
:= False;
3974 function g_Game_GetFirstMap(WAD
: String): String;
3978 MapList
:= g_Map_GetMapsList(WAD
);
3979 if MapList
= nil then
3982 SortSArray(MapList
);
3983 Result
:= MapList
[Low(MapList
)];
3985 if not g_Map_Exist(WAD
+ ':\' + Result
) then
3991 function g_Game_GetNextMap(): String;
3998 MapList
:= g_Map_GetMapsList(MapsDir
+ gGameSettings
.WAD
);
3999 if MapList
= nil then
4002 g_ProcessResourceStr(gMapInfo
.Map
, nil, nil, @Map
);
4004 SortSArray(MapList
);
4006 for I
:= Low(MapList
) to High(MapList
) do
4007 if Map
= MapList
[I
] then
4013 if MapIndex
<> -255 then
4015 if MapIndex
= High(MapList
) then
4016 Result
:= MapList
[Low(MapList
)]
4018 Result
:= MapList
[MapIndex
+ 1];
4020 if not g_Map_Exist(MapsDir
+ gGameSettings
.WAD
+ ':\' + Result
) then Result
:= Map
;
4026 procedure g_Game_NextLevel();
4028 if gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
, GM_COOP
] then
4029 gExit
:= EXIT_ENDLEVELCUSTOM
4032 gExit
:= EXIT_ENDLEVELSINGLE
;
4036 if gNextMap
<> '' then Exit
;
4037 gNextMap
:= g_Game_GetNextMap();
4040 function g_Game_IsTestMap(): Boolean;
4042 FName
, Sect
, Res
: String;
4044 g_ProcessResourceStr(gMapInfo
.Map
, FName
, Sect
, Res
);
4045 Result
:= UpperCase(Res
) = TEST_MAP_NAME
;
4048 procedure g_Game_DeleteTestMap();
4056 a
:= Pos('.wad:\', gMapToDelete
);
4060 // Âûäåëÿåì èìÿ wad-ôàéëà è èìÿ êàðòû:
4061 WadName
:= Copy(gMapToDelete
, 1, a
+ 3);
4062 Delete(gMapToDelete
, 1, a
+ 5);
4063 gMapToDelete
:= UpperCase(gMapToDelete
);
4065 CopyMemory(@MapName
[0], @gMapToDelete
[1], Min(16, Length(gMapToDelete
)));
4067 // Èìÿ êàðòû íå ñòàíäàðòíîå òåñòîâîå:
4068 if MapName
<> TEST_MAP_NAME
then
4071 if not gTempDelete
then
4073 time
:= g_GetFileTime(WadName
);
4074 WAD
:= TWADEditor_1
.Create();
4077 if not WAD
.ReadFile(WadName
) then
4078 begin // Íåò òàêîãî WAD-ôàéëà
4083 // Ñîñòàâëÿåì ñïèñîê êàðò è èùåì íóæíóþ:
4085 MapList
:= WAD
.GetResourcesList('');
4087 if MapList
<> nil then
4088 for a
:= 0 to High(MapList
) do
4089 if MapList
[a
] = MapName
then
4091 // Óäàëÿåì è ñîõðàíÿåì:
4092 WAD
.RemoveResource('', MapName
);
4093 WAD
.SaveTo(WadName
);
4098 g_SetFileTime(WadName
, time
);
4100 DeleteFile(WadName
);
4103 procedure GameCVars(P
: SArray
);
4106 stat
: TPlayerStatArray
;
4111 cmd
:= LowerCase(P
[0]);
4112 if cmd
= 'r_showfps' then
4114 if (Length(P
) > 1) and
4115 ((P
[1] = '1') or (P
[1] = '0')) then
4116 gShowFPS
:= (P
[1][1] = '1');
4119 g_Console_Add(_lc
[I_MSG_SHOW_FPS_ON
])
4121 g_Console_Add(_lc
[I_MSG_SHOW_FPS_OFF
]);
4123 else if (cmd
= 'g_friendlyfire') and not g_Game_IsClient
then
4125 with gGameSettings
do
4127 if (Length(P
) > 1) and
4128 ((P
[1] = '1') or (P
[1] = '0')) then
4130 if (P
[1][1] = '1') then
4131 Options
:= Options
or GAME_OPTION_TEAMDAMAGE
4133 Options
:= Options
and (not GAME_OPTION_TEAMDAMAGE
);
4136 if (LongBool(Options
and GAME_OPTION_TEAMDAMAGE
)) then
4137 g_Console_Add(_lc
[I_MSG_FRIENDLY_FIRE_ON
])
4139 g_Console_Add(_lc
[I_MSG_FRIENDLY_FIRE_OFF
]);
4141 if g_Game_IsNet
then MH_SEND_GameSettings
;
4144 else if (cmd
= 'g_weaponstay') and not g_Game_IsClient
then
4146 with gGameSettings
do
4148 if (Length(P
) > 1) and
4149 ((P
[1] = '1') or (P
[1] = '0')) then
4151 if (P
[1][1] = '1') then
4152 Options
:= Options
or GAME_OPTION_WEAPONSTAY
4154 Options
:= Options
and (not GAME_OPTION_WEAPONSTAY
);
4157 if (LongBool(Options
and GAME_OPTION_WEAPONSTAY
)) then
4158 g_Console_Add(_lc
[I_MSG_WEAPONSTAY_ON
])
4160 g_Console_Add(_lc
[I_MSG_WEAPONSTAY_OFF
]);
4162 if g_Game_IsNet
then MH_SEND_GameSettings
;
4165 else if cmd
= 'g_gamemode' then
4167 a
:= g_Game_TextToMode(P
[1]);
4168 if a
= GM_SINGLE
then a
:= GM_COOP
;
4169 if (Length(P
) > 1) and (a
<> GM_NONE
) and (not g_Game_IsClient
) then
4171 gSwitchGameMode
:= a
;
4172 if (gGameOn
and (gGameSettings
.GameMode
= GM_SINGLE
)) or
4173 (gState
= STATE_INTERSINGLE
) then
4174 gSwitchGameMode
:= GM_SINGLE
;
4176 gGameSettings
.GameMode
:= gSwitchGameMode
;
4178 if gSwitchGameMode
= gGameSettings
.GameMode
then
4179 g_Console_Add(Format(_lc
[I_MSG_GAMEMODE_CURRENT
],
4180 [g_Game_ModeToText(gGameSettings
.GameMode
)]))
4182 g_Console_Add(Format(_lc
[I_MSG_GAMEMODE_CHANGE
],
4183 [g_Game_ModeToText(gGameSettings
.GameMode
),
4184 g_Game_ModeToText(gSwitchGameMode
)]));
4186 else if (cmd
= 'g_allow_exit') and not g_Game_IsClient
then
4188 with gGameSettings
do
4190 if (Length(P
) > 1) and
4191 ((P
[1] = '1') or (P
[1] = '0')) then
4193 if (P
[1][1] = '1') then
4194 Options
:= Options
or GAME_OPTION_ALLOWEXIT
4196 Options
:= Options
and (not GAME_OPTION_ALLOWEXIT
);
4199 if (LongBool(Options
and GAME_OPTION_ALLOWEXIT
)) then
4200 g_Console_Add(_lc
[I_MSG_ALLOWEXIT_ON
])
4202 g_Console_Add(_lc
[I_MSG_ALLOWEXIT_OFF
]);
4203 g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
4205 if g_Game_IsNet
then MH_SEND_GameSettings
;
4208 else if (cmd
= 'g_allow_monsters') and not g_Game_IsClient
then
4210 with gGameSettings
do
4212 if (Length(P
) > 1) and
4213 ((P
[1] = '1') or (P
[1] = '0')) then
4215 if (P
[1][1] = '1') then
4216 Options
:= Options
or GAME_OPTION_MONSTERS
4218 Options
:= Options
and (not GAME_OPTION_MONSTERS
);
4221 if (LongBool(Options
and GAME_OPTION_MONSTERS
)) then
4222 g_Console_Add(_lc
[I_MSG_ALLOWMON_ON
])
4224 g_Console_Add(_lc
[I_MSG_ALLOWMON_OFF
]);
4225 g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
4227 if g_Game_IsNet
then MH_SEND_GameSettings
;
4230 else if (cmd
= 'g_bot_vsplayers') and not g_Game_IsClient
then
4232 with gGameSettings
do
4234 if (Length(P
) > 1) and
4235 ((P
[1] = '1') or (P
[1] = '0')) then
4237 if (P
[1][1] = '1') then
4238 Options
:= Options
or GAME_OPTION_BOTVSPLAYER
4240 Options
:= Options
and (not GAME_OPTION_BOTVSPLAYER
);
4243 if (LongBool(Options
and GAME_OPTION_BOTVSPLAYER
)) then
4244 g_Console_Add(_lc
[I_MSG_BOTSVSPLAYERS_ON
])
4246 g_Console_Add(_lc
[I_MSG_BOTSVSPLAYERS_OFF
]);
4248 if g_Game_IsNet
then MH_SEND_GameSettings
;
4251 else if (cmd
= 'g_bot_vsmonsters') and not g_Game_IsClient
then
4253 with gGameSettings
do
4255 if (Length(P
) > 1) and
4256 ((P
[1] = '1') or (P
[1] = '0')) then
4258 if (P
[1][1] = '1') then
4259 Options
:= Options
or GAME_OPTION_BOTVSMONSTER
4261 Options
:= Options
and (not GAME_OPTION_BOTVSMONSTER
);
4264 if (LongBool(Options
and GAME_OPTION_BOTVSMONSTER
)) then
4265 g_Console_Add(_lc
[I_MSG_BOTSVSMONSTERS_ON
])
4267 g_Console_Add(_lc
[I_MSG_BOTSVSMONSTERS_OFF
]);
4269 if g_Game_IsNet
then MH_SEND_GameSettings
;
4272 else if (cmd
= 'g_warmuptime') and not g_Game_IsClient
then
4274 if Length(P
) > 1 then
4276 if StrToIntDef(P
[1], gGameSettings
.WarmupTime
) = 0 then
4277 gGameSettings
.WarmupTime
:= 30
4279 gGameSettings
.WarmupTime
:= StrToIntDef(P
[1], gGameSettings
.WarmupTime
);
4282 g_Console_Add(Format(_lc
[I_MSG_WARMUP
],
4283 [gGameSettings
.WarmupTime
]));
4284 g_Console_Add(_lc
[I_MSG_ONMAPCHANGE
]);
4286 else if cmd
= 'net_interp' then
4288 if (Length(P
) > 1) then
4289 NetInterpLevel
:= StrToIntDef(P
[1], NetInterpLevel
);
4291 g_Console_Add('net_interp = ' + IntToStr(NetInterpLevel
));
4292 config
:= TConfig
.CreateFile(GameDir
+'/'+CONFIG_FILENAME
);
4293 config
.WriteInt('Client', 'InterpolationSteps', NetInterpLevel
);
4294 config
.SaveFile(GameDir
+'/'+CONFIG_FILENAME
);
4297 else if cmd
= 'net_forceplayerupdate' then
4299 if (Length(P
) > 1) and
4300 ((P
[1] = '1') or (P
[1] = '0')) then
4301 NetForcePlayerUpdate
:= (P
[1][1] = '1');
4303 if NetForcePlayerUpdate
then
4304 g_Console_Add('net_forceplayerupdate = 1')
4306 g_Console_Add('net_forceplayerupdate = 0');
4307 config
:= TConfig
.CreateFile(GameDir
+'/'+CONFIG_FILENAME
);
4308 config
.WriteBool('Client', 'ForcePlayerUpdate', NetForcePlayerUpdate
);
4309 config
.SaveFile(GameDir
+'/'+CONFIG_FILENAME
);
4312 else if cmd
= 'net_predictself' then
4314 if (Length(P
) > 1) and
4315 ((P
[1] = '1') or (P
[1] = '0')) then
4316 NetPredictSelf
:= (P
[1][1] = '1');
4318 if NetPredictSelf
then
4319 g_Console_Add('net_predictself = 1')
4321 g_Console_Add('net_predictself = 0');
4322 config
:= TConfig
.CreateFile(GameDir
+'/'+CONFIG_FILENAME
);
4323 config
.WriteBool('Client', 'PredictSelf', NetPredictSelf
);
4324 config
.SaveFile(GameDir
+'/'+CONFIG_FILENAME
);
4327 else if cmd
= 'sv_name' then
4329 if (Length(P
) > 1) and (Length(P
[1]) > 0) then
4331 NetServerName
:= P
[1];
4332 if Length(NetServerName
) > 64 then
4333 SetLength(NetServerName
, 64);
4334 if g_Game_IsServer
and g_Game_IsNet
and NetUseMaster
then
4338 g_Console_Add(cmd
+ ' = "' + NetServerName
+ '"');
4340 else if cmd
= 'sv_passwd' then
4342 if (Length(P
) > 1) and (Length(P
[1]) > 0) then
4344 NetPassword
:= P
[1];
4345 if Length(NetPassword
) > 24 then
4346 SetLength(NetPassword
, 24);
4347 if g_Game_IsServer
and g_Game_IsNet
and NetUseMaster
then
4351 g_Console_Add(cmd
+ ' = "' + AnsiLowerCase(NetPassword
) + '"');
4353 else if cmd
= 'sv_maxplrs' then
4355 if (Length(P
) > 1) then
4357 NetMaxClients
:= Min(Max(StrToIntDef(P
[1], NetMaxClients
), 1), NET_MAXCLIENTS
);
4358 if g_Game_IsServer
and g_Game_IsNet
then
4361 for a
:= 0 to High(NetClients
) do
4362 if NetClients
[a
].Used
then
4365 if b
> NetMaxClients
then
4367 s
:= g_Player_Get(NetClients
[a
].Player
).Name
;
4368 enet_peer_disconnect(NetClients
[a
].Peer
, NET_DISC_FULL
);
4369 g_Console_Add(Format(_lc
[I_PLAYER_KICK
], [s
]));
4370 MH_SEND_GameEvent(NET_EV_PLAYER_KICK
, 0, s
);
4373 if NetUseMaster
then
4378 g_Console_Add(cmd
+ ' = ' + IntToStr(NetMaxClients
));
4380 else if cmd
= 'sv_public' then
4382 if (Length(P
) > 1) then
4384 NetUseMaster
:= StrToIntDef(P
[1], Byte(NetUseMaster
)) > 0;
4385 if g_Game_IsServer
and g_Game_IsNet
then
4386 if NetUseMaster
then
4388 if NetMPeer
= nil then
4389 if not g_Net_Slist_Connect() then
4390 g_Console_Add(_lc
[I_NET_MSG_ERROR
] + _lc
[I_NET_SLIST_ERROR
]);
4391 g_Net_Slist_Update();
4394 if NetMPeer
<> nil then
4395 g_Net_Slist_Disconnect();
4398 g_Console_Add(cmd
+ ' = ' + IntToStr(Byte(NetUseMaster
)));
4400 else if cmd
= 'sv_intertime' then
4402 if (Length(P
) > 1) then
4403 gDefInterTime
:= Min(Max(StrToIntDef(P
[1], gDefInterTime
), -1), 120);
4405 g_Console_Add(cmd
+ ' = ' + IntToStr(gDefInterTime
));
4407 else if cmd
= 'p1_name' then
4409 if (Length(P
) > 1) and gGameOn
then
4411 if g_Game_IsClient
then
4413 gPlayer1Settings
.Name
:= b_Text_Unformat(P
[1]);
4414 MC_SEND_PlayerSettings
;
4417 if gPlayer1
<> nil then
4419 gPlayer1
.Name
:= b_Text_Unformat(P
[1]);
4420 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer1
.UID
);
4423 gPlayer1Settings
.Name
:= b_Text_Unformat(P
[1]);
4426 else if cmd
= 'p2_name' then
4428 if (Length(P
) > 1) and gGameOn
then
4430 if g_Game_IsClient
then
4432 gPlayer2Settings
.Name
:= b_Text_Unformat(P
[1]);
4433 MC_SEND_PlayerSettings
;
4436 if gPlayer2
<> nil then
4438 gPlayer2
.Name
:= b_Text_Unformat(P
[1]);
4439 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer2
.UID
);
4442 gPlayer2Settings
.Name
:= b_Text_Unformat(P
[1]);
4445 else if cmd
= 'p1_color' then
4447 if Length(P
) > 3 then
4448 if g_Game_IsClient
then
4450 gPlayer1Settings
.Color
:= _RGB(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
4451 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
4452 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
4453 MC_SEND_PlayerSettings
;
4456 if gPlayer1
<> nil then
4458 gPlayer1
.Model
.SetColor(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
4459 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
4460 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
4461 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer1
.UID
);
4464 gPlayer1Settings
.Color
:= _RGB(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
4465 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
4466 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
4468 else if (cmd
= 'p2_color') and not g_Game_IsNet
then
4470 if Length(P
) > 3 then
4471 if g_Game_IsClient
then
4473 gPlayer2Settings
.Color
:= _RGB(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
4474 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
4475 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
4476 MC_SEND_PlayerSettings
;
4479 if gPlayer2
<> nil then
4481 gPlayer2
.Model
.SetColor(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
4482 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
4483 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
4484 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer2
.UID
);
4487 gPlayer2Settings
.Color
:= _RGB(EnsureRange(StrToIntDef(P
[1], 0), 0, 255),
4488 EnsureRange(StrToIntDef(P
[2], 0), 0, 255),
4489 EnsureRange(StrToIntDef(P
[3], 0), 0, 255));
4491 else if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
4493 if cmd
= 'r_showtime' then
4495 if (Length(P
) > 1) and
4496 ((P
[1] = '1') or (P
[1] = '0')) then
4497 gShowTime
:= (P
[1][1] = '1');
4500 g_Console_Add(_lc
[I_MSG_TIME_ON
])
4502 g_Console_Add(_lc
[I_MSG_TIME_OFF
]);
4504 else if cmd
= 'r_showscore' then
4506 if (Length(P
) > 1) and
4507 ((P
[1] = '1') or (P
[1] = '0')) then
4508 gShowGoals
:= (P
[1][1] = '1');
4511 g_Console_Add(_lc
[I_MSG_SCORE_ON
])
4513 g_Console_Add(_lc
[I_MSG_SCORE_OFF
]);
4515 else if cmd
= 'r_showstat' then
4517 if (Length(P
) > 1) and
4518 ((P
[1] = '1') or (P
[1] = '0')) then
4519 gShowStat
:= (P
[1][1] = '1');
4522 g_Console_Add(_lc
[I_MSG_STATS_ON
])
4524 g_Console_Add(_lc
[I_MSG_STATS_OFF
]);
4526 else if cmd
= 'r_showkillmsg' then
4528 if (Length(P
) > 1) and
4529 ((P
[1] = '1') or (P
[1] = '0')) then
4530 gShowKillMsg
:= (P
[1][1] = '1');
4532 if gShowKillMsg
then
4533 g_Console_Add(_lc
[I_MSG_KILL_MSGS_ON
])
4535 g_Console_Add(_lc
[I_MSG_KILL_MSGS_OFF
]);
4537 else if cmd
= 'r_showlives' then
4539 if (Length(P
) > 1) and
4540 ((P
[1] = '1') or (P
[1] = '0')) then
4541 gShowLives
:= (P
[1][1] = '1');
4544 g_Console_Add(_lc
[I_MSG_LIVES_ON
])
4546 g_Console_Add(_lc
[I_MSG_LIVES_OFF
]);
4548 else if cmd
= 'r_showspect' then
4550 if (Length(P
) > 1) and
4551 ((P
[1] = '1') or (P
[1] = '0')) then
4552 gSpectHUD
:= (P
[1][1] = '1');
4555 g_Console_Add(_lc
[I_MSG_SPECT_HUD_ON
])
4557 g_Console_Add(_lc
[I_MSG_SPECT_HUD_OFF
]);
4559 else if cmd
= 'r_showping' then
4561 if (Length(P
) > 1) and
4562 ((P
[1] = '1') or (P
[1] = '0')) then
4563 gShowPing
:= (P
[1][1] = '1');
4566 g_Console_Add(_lc
[I_MSG_PING_ON
])
4568 g_Console_Add(_lc
[I_MSG_PING_OFF
]);
4570 else if (cmd
= 'g_scorelimit') and not g_Game_IsClient
then
4572 if Length(P
) > 1 then
4574 if StrToIntDef(P
[1], gGameSettings
.GoalLimit
) = 0 then
4575 gGameSettings
.GoalLimit
:= 0
4580 if gGameSettings
.GameMode
= GM_DM
then
4582 stat
:= g_Player_GetStats();
4584 for a
:= 0 to High(stat
) do
4585 if stat
[a
].Frags
> b
then
4589 b
:= Max(gTeamStat
[TEAM_RED
].Goals
, gTeamStat
[TEAM_BLUE
].Goals
);
4591 gGameSettings
.GoalLimit
:= Max(StrToIntDef(P
[1], gGameSettings
.GoalLimit
), b
);
4594 if g_Game_IsNet
then MH_SEND_GameSettings
;
4597 g_Console_Add(Format(_lc
[I_MSG_SCORE_LIMIT
], [gGameSettings
.GoalLimit
]));
4599 else if (cmd
= 'g_timelimit') and not g_Game_IsClient
then
4601 if (Length(P
) > 1) and (StrToIntDef(P
[1], -1) >= 0) then
4602 gGameSettings
.TimeLimit
:= StrToIntDef(P
[1], -1);
4604 g_Console_Add(Format(_lc
[I_MSG_TIME_LIMIT
],
4605 [gGameSettings
.TimeLimit
div 3600,
4606 (gGameSettings
.TimeLimit
div 60) mod 60,
4607 gGameSettings
.TimeLimit
mod 60]));
4608 if g_Game_IsNet
then MH_SEND_GameSettings
;
4610 else if (cmd
= 'g_maxlives') and not g_Game_IsClient
then
4612 if Length(P
) > 1 then
4614 if StrToIntDef(P
[1], gGameSettings
.MaxLives
) = 0 then
4615 gGameSettings
.MaxLives
:= 0
4619 stat
:= g_Player_GetStats();
4621 for a
:= 0 to High(stat
) do
4622 if stat
[a
].Lives
> b
then
4624 gGameSettings
.MaxLives
:=
4625 Max(StrToIntDef(P
[1], gGameSettings
.MaxLives
), b
);
4629 g_Console_Add(Format(_lc
[I_MSG_LIVES
],
4630 [gGameSettings
.MaxLives
]));
4631 if g_Game_IsNet
then MH_SEND_GameSettings
;
4636 procedure DebugCommands(P
: SArray
);
4642 // Êîìàíäû îòëàäî÷íîãî ðåæèìà:
4645 cmd
:= LowerCase(P
[0]);
4646 if cmd
= 'd_window' then
4648 g_Console_Add(Format('gWinPosX = %d, gWinPosY %d', [gWinPosX
, gWinPosY
]));
4649 g_Console_Add(Format('gWinRealPosX = %d, gWinRealPosY %d', [gWinRealPosX
, gWinRealPosY
]));
4650 g_Console_Add(Format('gScreenWidth = %d, gScreenHeight = %d', [gScreenWidth
, gScreenHeight
]));
4651 g_Console_Add(Format('gWinSizeX = %d, gWinSizeY = %d', [gWinSizeX
, gWinSizeY
]));
4652 g_Console_Add(Format('Frame X = %d, Y = %d, Caption Y = %d', [gWinFrameX
, gWinFrameY
, gWinCaption
]));
4654 else if cmd
= 'd_sounds' then
4656 if (Length(P
) > 1) and
4657 ((P
[1] = '1') or (P
[1] = '0')) then
4658 g_Debug_Sounds
:= (P
[1][1] = '1');
4660 g_Console_Add(Format('d_sounds is %d', [Byte(g_Debug_Sounds
)]));
4662 else if cmd
= 'd_frames' then
4664 if (Length(P
) > 1) and
4665 ((P
[1] = '1') or (P
[1] = '0')) then
4666 g_Debug_Frames
:= (P
[1][1] = '1');
4668 g_Console_Add(Format('d_frames is %d', [Byte(g_Debug_Frames
)]));
4670 else if cmd
= 'd_winmsg' then
4672 if (Length(P
) > 1) and
4673 ((P
[1] = '1') or (P
[1] = '0')) then
4674 g_Debug_WinMsgs
:= (P
[1][1] = '1');
4676 g_Console_Add(Format('d_winmsg is %d', [Byte(g_Debug_WinMsgs
)]));
4678 else if (cmd
= 'd_monoff') and not g_Game_IsNet
then
4680 if (Length(P
) > 1) and
4681 ((P
[1] = '1') or (P
[1] = '0')) then
4682 g_Debug_MonsterOff
:= (P
[1][1] = '1');
4684 g_Console_Add(Format('d_monoff is %d', [Byte(g_debug_MonsterOff
)]));
4686 else if (cmd
= 'd_botoff') and not g_Game_IsNet
then
4688 if Length(P
) > 1 then
4690 '0': g_debug_BotAIOff
:= 0;
4691 '1': g_debug_BotAIOff
:= 1;
4692 '2': g_debug_BotAIOff
:= 2;
4693 '3': g_debug_BotAIOff
:= 3;
4696 g_Console_Add(Format('d_botoff is %d', [g_debug_BotAIOff
]));
4698 else if cmd
= 'd_monster' then
4700 if gGameOn
and (gPlayer1
<> nil) and (gPlayer1
.Live
) and (not g_Game_IsNet
) then
4701 if Length(P
) < 2 then
4703 g_Console_Add(cmd
+ ' [ID | Name] [behaviour]');
4704 g_Console_Add('ID | Name');
4705 for b
:= MONSTER_DEMON
to MONSTER_MAN
do
4706 g_Console_Add(Format('%2d | %s', [b
, g_Monsters_GetNameByID(b
)]));
4709 a
:= StrToIntDef(P
[1], 0);
4710 if (a
< MONSTER_DEMON
) or (a
> MONSTER_MAN
) then
4711 a
:= g_Monsters_GetIDByName(P
[1]);
4713 if (a
< MONSTER_DEMON
) or (a
> MONSTER_MAN
) then
4714 g_Console_Add(Format(_lc
[I_MSG_NO_MONSTER
], [P
[1]]))
4717 with gPlayer1
.Obj
do
4718 b
:= g_Monsters_Create(a
,
4719 X
+ Rect
.X
+ (Rect
.Width
div 2),
4720 Y
+ Rect
.Y
+ Rect
.Height
,
4721 gPlayer1
.Direction
, True);
4722 if (Length(P
) > 2) and (b
>= 0) then
4723 gMonsters
[b
].MonsterBehaviour
:= Min(Max(StrToIntDef(P
[2], BH_NORMAL
), BH_NORMAL
), BH_GOOD
);
4727 else if (cmd
= 'd_health') then
4729 if (Length(P
) > 1) and
4730 ((P
[1] = '1') or (P
[1] = '0')) then
4731 g_debug_HealthBar
:= (P
[1][1] = '1');
4733 g_Console_Add(Format('d_health is %d', [Byte(g_debug_HealthBar
)]));
4735 else if (cmd
= 'd_player') then
4737 if (Length(P
) > 1) and
4738 ((P
[1] = '1') or (P
[1] = '0')) then
4739 g_debug_Player
:= (P
[1][1] = '1');
4741 g_Console_Add(Format(cmd
+ ' is %d', [Byte(g_Debug_Player
)]));
4743 else if (cmd
= 'd_joy') then
4746 g_Console_Add(e_JoystickStateToString(a
));
4750 g_Console_Add(_lc
[I_MSG_NOT_DEBUG
]);
4753 procedure GameCommands(P
: SArray
);
4759 pl
: pTNetClient
= nil;
4766 cmd
:= LowerCase(P
[0]);
4768 if (cmd
= 'quit') or
4775 else if cmd
= 'pause' then
4777 if (g_ActiveWindow
= nil) then
4778 g_Game_Pause(not gPause
);
4780 else if cmd
= 'endgame' then
4781 gExit
:= EXIT_SIMPLE
4782 else if cmd
= 'restart' then
4784 if gGameOn
or (gState
in [STATE_INTERSINGLE
, STATE_INTERCUSTOM
]) then
4786 if g_Game_IsClient
then
4788 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4793 g_Console_Add(_lc
[I_MSG_NOT_GAME
]);
4795 else if cmd
= 'kick' then
4797 if g_Game_IsServer
then
4799 if Length(P
) < 2 then
4801 g_Console_Add('kick <name>');
4806 g_Console_Add('kick <name>');
4810 if g_Game_IsNet
then
4811 pl
:= g_Net_Client_ByName(P
[1]);
4814 s
:= g_Net_ClientName_ByID(pl
^.ID
);
4815 enet_peer_disconnect(pl
^.Peer
, NET_DISC_KICK
);
4816 g_Console_Add(Format(_lc
[I_PLAYER_KICK
], [s
]));
4817 MH_SEND_GameEvent(NET_EV_PLAYER_KICK
, 0, s
);
4818 if NetUseMaster
then
4820 end else if gPlayers
<> nil then
4821 for a
:= Low(gPlayers
) to High(gPlayers
) do
4822 if gPlayers
[a
] <> nil then
4823 if Copy(LowerCase(gPlayers
[a
].Name
), 1, Length(P
[1])) = LowerCase(P
[1]) then
4825 // Íå îòêëþ÷àòü îñíîâíûõ èãðîêîâ â ñèíãëå
4826 if not(gPlayers
[a
] is TBot
) and (gGameSettings
.GameType
= GT_SINGLE
) then
4828 gPlayers
[a
].Lives
:= 0;
4829 gPlayers
[a
].Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
4830 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [gPlayers
[a
].Name
]), True);
4831 g_Player_Remove(gPlayers
[a
].UID
);
4832 if NetUseMaster
then
4834 // Åñëè íå ïåðåìåøàòü, ïðè äîáàâëåíèè íîâûõ áîòîâ ïîÿâÿòñÿ ñòàðûå
4838 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
4840 else if cmd
= 'kick_id' then
4842 if g_Game_IsServer
and g_Game_IsNet
then
4844 if Length(P
) < 2 then
4846 g_Console_Add('kick_id <client ID>');
4851 g_Console_Add('kick_id <client ID>');
4855 a
:= StrToIntDef(P
[1], 0);
4856 if (NetClients
<> nil) and (a
<= High(NetClients
)) then
4858 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
4860 s
:= g_Net_ClientName_ByID(NetClients
[a
].ID
);
4861 enet_peer_disconnect(NetClients
[a
].Peer
, NET_DISC_KICK
);
4862 g_Console_Add(Format(_lc
[I_PLAYER_KICK
], [s
]));
4863 MH_SEND_GameEvent(NET_EV_PLAYER_KICK
, 0, s
);
4864 if NetUseMaster
then
4869 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4871 else if cmd
= 'ban' then
4873 if g_Game_IsServer
and g_Game_IsNet
then
4875 if Length(P
) < 2 then
4877 g_Console_Add('ban <name>');
4882 g_Console_Add('ban <name>');
4886 pl
:= g_Net_Client_ByName(P
[1]);
4889 s
:= g_Net_ClientName_ByID(pl
^.ID
);
4890 g_Net_BanHost(pl
^.Peer
^.address
.host
, False);
4891 enet_peer_disconnect(pl
^.Peer
, NET_DISC_TEMPBAN
);
4892 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
4893 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
4894 if NetUseMaster
then
4897 g_Console_Add(Format(_lc
[I_NET_ERR_NAME404
], [P
[1]]));
4899 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4901 else if cmd
= 'ban_id' then
4903 if g_Game_IsServer
and g_Game_IsNet
then
4905 if Length(P
) < 2 then
4907 g_Console_Add('ban_id <client ID>');
4912 g_Console_Add('ban_id <client ID>');
4916 a
:= StrToIntDef(P
[1], 0);
4917 if (NetClients
<> nil) and (a
<= High(NetClients
)) then
4918 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
4920 s
:= g_Net_ClientName_ByID(NetClients
[a
].ID
);
4921 g_Net_BanHost(NetClients
[a
].Peer
^.address
.host
, False);
4922 enet_peer_disconnect(NetClients
[a
].Peer
, NET_DISC_TEMPBAN
);
4923 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
4924 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
4925 if NetUseMaster
then
4929 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4931 else if cmd
= 'permban' then
4933 if g_Game_IsServer
and g_Game_IsNet
then
4935 if Length(P
) < 2 then
4937 g_Console_Add('permban <name>');
4942 g_Console_Add('permban <name>');
4946 pl
:= g_Net_Client_ByName(P
[1]);
4949 s
:= g_Net_ClientName_ByID(pl
^.ID
);
4950 g_Net_BanHost(pl
^.Peer
^.address
.host
);
4951 enet_peer_disconnect(pl
^.Peer
, NET_DISC_BAN
);
4952 g_Net_SaveBanList();
4953 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
4954 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
4955 if NetUseMaster
then
4958 g_Console_Add(Format(_lc
[I_NET_ERR_NAME404
], [P
[1]]));
4960 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4962 else if cmd
= 'permban_id' then
4964 if g_Game_IsServer
and g_Game_IsNet
then
4966 if Length(P
) < 2 then
4968 g_Console_Add('permban_id <client ID>');
4973 g_Console_Add('permban_id <client ID>');
4977 a
:= StrToIntDef(P
[1], 0);
4978 if (NetClients
<> nil) and (a
<= High(NetClients
)) then
4979 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
4981 s
:= g_Net_ClientName_ByID(NetClients
[a
].ID
);
4982 g_Net_BanHost(NetClients
[a
].Peer
^.address
.host
);
4983 enet_peer_disconnect(NetClients
[a
].Peer
, NET_DISC_BAN
);
4984 g_Net_SaveBanList();
4985 g_Console_Add(Format(_lc
[I_PLAYER_BAN
], [s
]));
4986 MH_SEND_GameEvent(NET_EV_PLAYER_BAN
, 0, s
);
4987 if NetUseMaster
then
4991 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
4993 else if cmd
= 'unban' then
4995 if g_Game_IsServer
and g_Game_IsNet
then
4997 if Length(P
) < 2 then
4999 g_Console_Add('unban <IP Address>');
5004 g_Console_Add('unban <IP Address>');
5008 if g_Net_UnbanHost(P
[1]) then
5010 g_Console_Add(Format(_lc
[I_MSG_UNBAN_OK
], [P
[1]]));
5011 g_Net_SaveBanList();
5013 g_Console_Add(Format(_lc
[I_MSG_UNBAN_FAIL
], [P
[1]]));
5015 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
5017 else if cmd
= 'clientlist' then
5019 if g_Game_IsServer
and g_Game_IsNet
then
5022 if NetClients
<> nil then
5023 for a
:= Low(NetClients
) to High(NetClients
) do
5024 if NetClients
[a
].Used
and (NetClients
[a
].Peer
<> nil) then
5026 plr
:= g_Player_Get(NetClients
[a
].Player
);
5027 if plr
= nil then continue
;
5029 g_Console_Add(Format('#%2d: %-15s | %s', [a
,
5030 IpToStr(NetClients
[a
].Peer
^.address
.host
), plr
.Name
]));
5033 g_Console_Add(_lc
[I_MSG_NOCLIENTS
]);
5035 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
5037 else if cmd
= 'connect' then
5039 if (NetMode
= NET_NONE
) then
5041 if Length(P
) < 2 then
5043 g_Console_Add('connect <IP> [port] [password]');
5048 g_Console_Add('connect <IP> [port] [password]');
5052 if Length(P
) > 2 then
5053 prt
:= StrToIntDef(P
[2], 25666)
5057 if Length(P
) > 3 then
5062 g_Game_StartClient(P
[1], prt
, pw
);
5065 else if cmd
= 'disconnect' then
5067 if (NetMode
= NET_CLIENT
) then
5070 else if cmd
= 'reconnect' then
5072 if (NetMode
= NET_SERVER
) then
5075 if (NetMode
= NET_CLIENT
) then
5078 gExit
:= EXIT_SIMPLE
;
5082 //TODO: Use last successful password to reconnect, instead of ''
5083 g_Game_StartClient(NetClientIP
, NetClientPort
, '');
5085 else if (cmd
= 'addbot') or
5086 (cmd
= 'bot_add') then
5088 if Length(P
) > 1 then
5089 g_Bot_Add(TEAM_NONE
, StrToIntDef(P
[1], 2))
5091 g_Bot_Add(TEAM_NONE
, 2);
5093 else if cmd
= 'bot_addlist' then
5095 if Length(P
) > 1 then
5096 if Length(P
) = 2 then
5097 g_Bot_AddList(TEAM_NONE
, P
[1], StrToIntDef(P
[1], -1))
5099 g_Bot_AddList(IfThen(P
[2] = 'red', TEAM_RED
, TEAM_BLUE
), P
[1], StrToIntDef(P
[1], -1));
5101 else if cmd
= 'bot_removeall' then
5103 else if cmd
= 'chat' then
5105 if g_Game_IsNet
then
5107 if Length(P
) > 1 then
5109 for a
:= 1 to High(P
) do
5110 chstr
:= chstr
+ P
[a
] + ' ';
5112 if Length(chstr
) > 200 then SetLength(chstr
, 200);
5114 if Length(chstr
) < 1 then
5116 g_Console_Add('chat <text>');
5120 chstr
:= b_Text_Format(chstr
);
5121 if g_Game_IsClient
then
5122 MC_SEND_Chat(chstr
, NET_CHAT_PLAYER
)
5124 MH_SEND_Chat(gPlayer1Settings
.Name
+ ': ' + chstr
, NET_CHAT_PLAYER
);
5127 g_Console_Add('chat <text>');
5129 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
5131 else if cmd
= 'teamchat' then
5133 if g_Game_IsNet
and (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then
5135 if Length(P
) > 1 then
5137 for a
:= 1 to High(P
) do
5138 chstr
:= chstr
+ P
[a
] + ' ';
5140 if Length(chstr
) > 200 then SetLength(chstr
, 200);
5142 if Length(chstr
) < 1 then
5144 g_Console_Add('teamchat <text>');
5148 chstr
:= b_Text_Format(chstr
);
5149 if g_Game_IsClient
then
5150 MC_SEND_Chat(chstr
, NET_CHAT_TEAM
)
5152 MH_SEND_Chat(gPlayer1Settings
.Name
+ ': ' + chstr
, NET_CHAT_TEAM
,
5153 gPlayer1Settings
.Team
);
5156 g_Console_Add('teamchat <text>');
5158 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
5160 else if cmd
= 'game' then
5162 if gGameSettings
.GameType
<> GT_NONE
then
5164 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
5167 if Length(P
) = 1 then
5169 g_Console_Add(cmd
+ ' <WAD> [MAP] [# players]');
5172 // Èãðà åù¸ íå çàïóùåíà, ñíà÷àëà íàì íàäî çàãðóçèòü êàêîé-òî WAD
5173 if Pos('.wad', LowerCase(P
[1])) = 0 then
5174 P
[1] := P
[1] + '.wad';
5176 if FileExists(MapsDir
+ P
[1]) then
5178 // Åñëè êàðòà íå óêàçàíà, áåð¸ì ïåðâóþ êàðòó â ôàéëå
5179 if Length(P
) < 3 then
5182 P
[2] := g_Game_GetFirstMap(MapsDir
+ P
[1]);
5185 s
:= P
[1] + ':\' + UpperCase(P
[2]);
5187 if g_Map_Exist(MapsDir
+ s
) then
5189 // Çàïóñêàåì ñâîþ èãðó
5191 with gGameSettings
do
5193 GameMode
:= g_Game_TextToMode(gcGameMode
);
5194 if gSwitchGameMode
<> GM_NONE
then
5195 GameMode
:= gSwitchGameMode
;
5196 if GameMode
= GM_NONE
then GameMode
:= GM_DM
;
5197 if GameMode
= GM_SINGLE
then GameMode
:= GM_COOP
;
5199 if Length(P
) >= 4 then
5200 b
:= StrToIntDef(P
[3], 1);
5201 g_Game_StartCustom(s
, GameMode
, TimeLimit
,
5202 GoalLimit
, MaxLives
, Options
, b
);
5207 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[1]]))
5209 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [UpperCase(P
[2])]));
5211 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]));
5213 else if cmd
= 'host' then
5215 if gGameSettings
.GameType
<> GT_NONE
then
5217 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
5220 if Length(P
) < 4 then
5222 g_Console_Add(cmd
+ ' <listen IP> <port> <WAD> [MAP] [# players]');
5225 if not StrToIp(P
[1], listen
) then
5227 prt
:= StrToIntDef(P
[2], 25666);
5229 if Pos('.wad', LowerCase(P
[3])) = 0 then
5230 P
[3] := P
[3] + '.wad';
5232 if FileExists(MapsDir
+ P
[3]) then
5234 // Åñëè êàðòà íå óêàçàíà, áåð¸ì ïåðâóþ êàðòó â ôàéëå
5235 if Length(P
) < 5 then
5238 P
[4] := g_Game_GetFirstMap(MapsDir
+ P
[1]);
5241 s
:= P
[3] + ':\' + UpperCase(P
[4]);
5243 if g_Map_Exist(MapsDir
+ s
) then
5245 // Çàïóñêàåì ñâîþ èãðó
5247 with gGameSettings
do
5249 GameMode
:= g_Game_TextToMode(gcGameMode
);
5250 if gSwitchGameMode
<> GM_NONE
then
5251 GameMode
:= gSwitchGameMode
;
5252 if GameMode
= GM_NONE
then GameMode
:= GM_DM
;
5253 if GameMode
= GM_SINGLE
then GameMode
:= GM_COOP
;
5255 if Length(P
) >= 6 then
5256 b
:= StrToIntDef(P
[5], 0);
5257 g_Game_StartServer(s
, GameMode
, TimeLimit
,
5258 GoalLimit
, MaxLives
, Options
, b
, listen
, prt
);
5263 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[3]]))
5265 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [UpperCase(P
[4])]));
5267 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[3]]));
5269 else if cmd
= 'map' then
5271 if Length(P
) = 1 then
5273 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
5275 g_Console_Add(cmd
+ ' <MAP>');
5276 g_Console_Add(cmd
+ ' <WAD> [MAP]');
5278 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
5280 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
5282 // Èä¸ò ñâîÿ èãðà èëè ñåðâåð
5283 if Length(P
) < 3 then
5285 // Ïåðâûé ïàðàìåòð - ëèáî êàðòà, ëèáî èìÿ WAD ôàéëà
5286 s
:= UpperCase(P
[1]);
5287 if g_Map_Exist(MapsDir
+ gGameSettings
.WAD
+ ':\' + s
) then
5288 begin // Êàðòà íàøëàñü
5289 gExitByTrigger
:= False;
5291 begin // Èä¸ò èãðà - çàâåðøàåì óðîâåíü
5293 gExit
:= EXIT_ENDLEVELCUSTOM
;
5295 else // Èíòåðìèññèÿ - ñðàçó çàãðóæàåì êàðòó
5296 g_Game_ChangeMap(s
);
5299 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [s
]));
5300 // Òàêîé êàðòû íåò, èùåì WAD ôàéë
5301 if Pos('.wad', LowerCase(P
[1])) = 0 then
5302 P
[1] := P
[1] + '.wad';
5304 if FileExists(MapsDir
+ P
[1]) then
5306 // Ïàðàìåòðà êàðòû íåò, ïîýòîìó ñòàâèì ïåðâóþ èç ôàéëà
5308 P
[2] := g_Game_GetFirstMap(MapsDir
+ P
[1]);
5310 s
:= P
[1] + ':\' + P
[2];
5312 if g_Map_Exist(MapsDir
+ s
) then
5314 gExitByTrigger
:= False;
5316 begin // Èä¸ò èãðà - çàâåðøàåì óðîâåíü
5318 gExit
:= EXIT_ENDLEVELCUSTOM
;
5320 else // Èíòåðìèññèÿ - ñðàçó çàãðóæàåì êàðòó
5321 g_Game_ChangeMap(s
);
5324 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[1]]))
5326 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]));
5328 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]));
5332 // Óêàçàíî äâà ïàðàìåòðà, çíà÷èò ïåðâûé - WAD ôàéë, à âòîðîé - êàðòà
5333 if Pos('.wad', LowerCase(P
[1])) = 0 then
5334 P
[1] := P
[1] + '.wad';
5336 if FileExists(MapsDir
+ P
[1]) then
5339 P
[2] := UpperCase(P
[2]);
5340 s
:= P
[1] + ':\' + P
[2];
5342 if g_Map_Exist(MapsDir
+ s
) then
5343 begin // Íàøëè êàðòó
5344 gExitByTrigger
:= False;
5346 begin // Èä¸ò èãðà - çàâåðøàåì óðîâåíü
5348 gExit
:= EXIT_ENDLEVELCUSTOM
;
5350 else // Èíòåðìèññèÿ - ñðàçó çàãðóæàåì êàðòó
5351 g_Game_ChangeMap(s
);
5353 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]));
5355 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]));
5358 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
5360 else if cmd
= 'nextmap' then
5362 if not(gGameOn
or (gState
= STATE_INTERCUSTOM
)) then
5363 g_Console_Add(_lc
[I_MSG_NOT_GAME
])
5366 if Length(P
) = 1 then
5368 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
5370 g_Console_Add(cmd
+ ' <MAP>');
5371 g_Console_Add(cmd
+ ' <WAD> [MAP]');
5374 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
5379 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
5381 if Length(P
) < 3 then
5383 // Ïåðâûé ïàðàìåòð - ëèáî êàðòà, ëèáî èìÿ WAD ôàéëà
5384 s
:= UpperCase(P
[1]);
5385 if g_Map_Exist(MapsDir
+ gGameSettings
.WAD
+ ':\' + s
) then
5386 begin // Êàðòà íàøëàñü
5387 gExitByTrigger
:= False;
5392 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [s
]));
5393 // Òàêîé êàðòû íåò, èùåì WAD ôàéë
5394 if Pos('.wad', LowerCase(P
[1])) = 0 then
5395 P
[1] := P
[1] + '.wad';
5397 if FileExists(MapsDir
+ P
[1]) then
5399 // Ïàðàìåòðà êàðòû íåò, ïîýòîìó ñòàâèì ïåðâóþ èç ôàéëà
5401 P
[2] := g_Game_GetFirstMap(MapsDir
+ P
[1]);
5403 s
:= P
[1] + ':\' + P
[2];
5405 if g_Map_Exist(MapsDir
+ s
) then
5406 begin // Óñòàíàâëèâàåì êàðòó
5407 gExitByTrigger
:= False;
5412 g_Console_Add(Format(_lc
[I_MSG_NO_MAPS
], [P
[1]]))
5414 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]));
5416 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]));
5420 // Óêàçàíî äâà ïàðàìåòðà, çíà÷èò ïåðâûé - WAD ôàéë, à âòîðîé - êàðòà
5421 if Pos('.wad', LowerCase(P
[1])) = 0 then
5422 P
[1] := P
[1] + '.wad';
5424 if FileExists(MapsDir
+ P
[1]) then
5427 P
[2] := UpperCase(P
[2]);
5428 s
:= P
[1] + ':\' + P
[2];
5430 if g_Map_Exist(MapsDir
+ s
) then
5431 begin // Íàøëè êàðòó
5432 gExitByTrigger
:= False;
5436 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [P
[2]]));
5438 g_Console_Add(Format(_lc
[I_MSG_NO_WAD
], [P
[1]]));
5441 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
5444 if gNextMap
= '' then
5445 g_Console_Add(_lc
[I_MSG_NEXTMAP_UNSET
])
5447 g_Console_Add(Format(_lc
[I_MSG_NEXTMAP_SET
], [gNextMap
]));
5450 else if (cmd
= 'endmap') or (cmd
= 'goodbye') then
5453 g_Console_Add(_lc
[I_MSG_NOT_GAME
])
5455 if g_Game_IsServer
and (gGameSettings
.GameType
<> GT_SINGLE
) then
5457 gExitByTrigger
:= False;
5458 // Ñëåäóþùàÿ êàðòà íå çàäàíà, ïðîáóåì íàéòè òðèããåð Âûõîä
5459 if (gNextMap
= '') and (gTriggers
<> nil) then
5460 for a
:= 0 to High(gTriggers
) do
5461 if gTriggers
[a
].TriggerType
= TRIGGER_EXIT
then
5463 gExitByTrigger
:= True;
5464 gNextMap
:= gTriggers
[a
].Data
.MapName
;
5467 // Èùåì ñëåäóþùóþ êàðòó â WAD ôàéëå
5468 if gNextMap
= '' then
5469 gNextMap
:= g_Game_GetNextMap();
5470 // Ïðîâåðÿåì, íå çàäàí ëè WAD ôàéë ðåñóðñíîé ñòðîêîé
5471 if Pos(':\', gNextMap
) = 0 then
5472 s
:= gGameSettings
.WAD
+ ':\' + gNextMap
5475 // Åñëè êàðòà íàéäåíà, âûõîäèì ñ óðîâíÿ
5476 if g_Map_Exist(MapsDir
+ s
) then
5477 gExit
:= EXIT_ENDLEVELCUSTOM
5479 g_Console_Add(Format(_lc
[I_MSG_NO_MAP
], [gNextMap
]));
5481 g_Console_Add(_lc
[I_MSG_GM_UNAVAIL
]);
5483 else if (cmd
= 'event') then
5485 if (Length(P
) <= 1) then
5487 for a
:= 0 to High(gEvents
) do
5488 if gEvents
[a
].Command
= '' then
5489 g_Console_Add(gEvents
[a
].Name
+ ' <none>')
5491 g_Console_Add(gEvents
[a
].Name
+ ' "' + gEvents
[a
].Command
+ '"');
5494 if (Length(P
) = 2) then
5496 for a
:= 0 to High(gEvents
) do
5497 if gEvents
[a
].Name
= P
[1] then
5498 if gEvents
[a
].Command
= '' then
5499 g_Console_Add(gEvents
[a
].Name
+ ' <none>')
5501 g_Console_Add(gEvents
[a
].Name
+ ' "' + gEvents
[a
].Command
+ '"');
5504 for a
:= 0 to High(gEvents
) do
5505 if gEvents
[a
].Name
= P
[1] then
5507 gEvents
[a
].Command
:= '';
5508 for b
:= 2 to High(P
) do
5509 if Pos(' ', P
[b
]) = 0 then
5510 gEvents
[a
].Command
:= gEvents
[a
].Command
+ ' ' + P
[b
]
5512 gEvents
[a
].Command
:= gEvents
[a
].Command
+ ' "' + P
[b
] + '"';
5513 gEvents
[a
].Command
:= Trim(gEvents
[a
].Command
);
5517 // Êîìàíäû Ñâîåé èãðû:
5518 else if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
5520 if cmd
= 'bot_addred' then
5522 if Length(P
) > 1 then
5523 g_Bot_Add(TEAM_RED
, StrToIntDef(P
[1], 2))
5525 g_Bot_Add(TEAM_RED
, 2);
5527 else if cmd
= 'bot_addblue' then
5529 if Length(P
) > 1 then
5530 g_Bot_Add(TEAM_BLUE
, StrToIntDef(P
[1], 2))
5532 g_Bot_Add(TEAM_BLUE
, 2);
5534 else if cmd
= 'suicide' then
5538 if g_Game_IsClient
then
5539 MC_SEND_CheatRequest(NET_CHEAT_SUICIDE
)
5542 if gPlayer1
<> nil then
5543 gPlayer1
.Damage(SUICIDE_DAMAGE
, gPlayer1
.UID
, 0, 0, HIT_SELF
);
5544 if gPlayer2
<> nil then
5545 gPlayer2
.Damage(SUICIDE_DAMAGE
, gPlayer2
.UID
, 0, 0, HIT_SELF
);
5549 else if cmd
= 'spectate' then
5555 else if cmd
= 'say' then
5557 if g_Game_IsServer
and g_Game_IsNet
then
5559 if Length(P
) > 1 then
5562 for a
:= 1 to High(P
) do
5563 chstr
:= chstr
+ P
[a
] + ' ';
5565 if Length(chstr
) > 200 then SetLength(chstr
, 200);
5567 if Length(chstr
) < 1 then
5569 g_Console_Add('say <text>');
5573 chstr
:= b_Text_Format(chstr
);
5574 MH_SEND_Chat(chstr
, NET_CHAT_PLAYER
);
5576 else g_Console_Add('say <text>');
5578 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
5580 else if cmd
= 'tell' then
5582 if g_Game_IsServer
and g_Game_IsNet
then
5584 if (Length(P
) > 2) and (P
[1] <> '') then
5587 for a
:= 2 to High(P
) do
5588 chstr
:= chstr
+ P
[a
] + ' ';
5590 if Length(chstr
) > 200 then SetLength(chstr
, 200);
5592 if Length(chstr
) < 1 then
5594 g_Console_Add('tell <playername> <text>');
5598 pl
:= g_Net_Client_ByName(P
[1]);
5600 MH_SEND_Chat(b_Text_Format(chstr
), NET_CHAT_PLAYER
, pl
^.ID
)
5602 g_Console_Add(Format(_lc
[I_NET_ERR_NAME404
], [P
[1]]));
5604 else g_Console_Add('tell <playername> <text>');
5606 g_Console_Add(_lc
[I_MSG_SERVERONLY
]);
5608 else if (cmd
= 'overtime') and not g_Game_IsClient
then
5610 if (Length(P
) = 1) or (StrToIntDef(P
[1], -1) <= 0) then
5612 // Äîïîëíèòåëüíîå âðåìÿ:
5613 gGameSettings
.TimeLimit
:= (gTime
- gGameStartTime
) div 1000 + Word(StrToIntDef(P
[1], 0));
5615 g_Console_Add(Format(_lc
[I_MSG_TIME_LIMIT
],
5616 [gGameSettings
.TimeLimit
div 3600,
5617 (gGameSettings
.TimeLimit
div 60) mod 60,
5618 gGameSettings
.TimeLimit
mod 60]));
5619 if g_Game_IsNet
then MH_SEND_GameSettings
;
5621 else if (cmd
= 'rcon_password') and g_Game_IsClient
then
5623 if (Length(P
) <= 1) then
5624 g_Console_Add('rcon_password <password>')
5626 MC_SEND_RCONPassword(P
[1]);
5628 else if cmd
= 'rcon' then
5630 if g_Game_IsClient
then
5632 if Length(P
) > 1 then
5635 for a
:= 1 to High(P
) do
5636 chstr
:= chstr
+ P
[a
] + ' ';
5638 if Length(chstr
) > 200 then SetLength(chstr
, 200);
5640 if Length(chstr
) < 1 then
5642 g_Console_Add('rcon <command>');
5646 MC_SEND_RCONCommand(chstr
);
5648 else g_Console_Add('rcon <command>');
5651 else if cmd
= 'ready' then
5653 if g_Game_IsServer
and (gLMSRespawn
= LMS_RESPAWN_WARMUP
) then
5654 gLMSRespawnTime
:= gTime
+ 100;
5656 else if (cmd
= 'callvote') and g_Game_IsNet
then
5658 if Length(P
) > 1 then
5661 for a
:= 1 to High(P
) do begin
5662 if a
> 1 then chstr
:= chstr
+ ' ';
5663 chstr
:= chstr
+ P
[a
];
5666 if Length(chstr
) > 200 then SetLength(chstr
, 200);
5668 if Length(chstr
) < 1 then
5670 g_Console_Add('callvote <command>');
5674 if g_Game_IsClient
then
5675 MC_SEND_Vote(True, chstr
)
5677 g_Game_StartVote(chstr
, gPlayer1Settings
.Name
);
5678 g_Console_Process('vote', True);
5681 g_Console_Add('callvote <command>');
5683 else if (cmd
= 'vote') and g_Game_IsNet
then
5685 if g_Game_IsClient
then
5687 else if gVoteInProgress
then
5689 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
5690 a
:= Floor((NetClientCount
+1)/2.0) + 1
5692 a
:= Floor(NetClientCount
/2.0) + 1;
5697 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_REVOKED
], [gPlayer1Settings
.Name
, gVoteCount
, a
]), True);
5698 MH_SEND_VoteEvent(NET_VE_REVOKE
, gPlayer1Settings
.Name
, 'a', gVoteCount
, a
);
5704 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_VOTE
], [gPlayer1Settings
.Name
, gVoteCount
, a
]), True);
5705 MH_SEND_VoteEvent(NET_VE_VOTE
, gPlayer1Settings
.Name
, 'a', gVoteCount
, a
);
5713 procedure g_TakeScreenShot();
5718 for a
:= 1 to High(Word) do
5720 FileName
:= Format(GameDir
+'/Screenshots/Screenshot%.3d.bmp', [a
]);
5721 if not FileExists(FileName
) then
5723 e_MakeScreenshot(FileName
, gScreenWidth
, gScreenHeight
);
5724 g_Console_Add(Format(_lc
[I_CONSOLE_SCREENSHOT
], [ExtractFileName(FileName
)]));
5730 procedure g_Game_InGameMenu(Show
: Boolean);
5732 if (g_ActiveWindow
= nil) and Show
then
5734 if gGameSettings
.GameType
= GT_SINGLE
then
5735 g_GUI_ShowWindow('GameSingleMenu')
5738 if g_Game_IsClient
then
5739 g_GUI_ShowWindow('GameClientMenu')
5741 if g_Game_IsNet
then
5742 g_GUI_ShowWindow('GameServerMenu')
5744 g_GUI_ShowWindow('GameCustomMenu');
5746 g_Sound_PlayEx('MENU_OPEN');
5748 // Ïàóçà ïðè ìåíþ òîëüêî â îäèíî÷íîé èãðå:
5749 if (not g_Game_IsNet
) then
5753 if (g_ActiveWindow
<> nil) and (not Show
) then
5755 // Ïàóçà ïðè ìåíþ òîëüêî â îäèíî÷íîé èãðå:
5756 if (not g_Game_IsNet
) then
5757 g_Game_Pause(False);
5761 procedure g_Game_Pause(Enable
: Boolean);
5766 if gPause
= Enable
then
5769 if not (gGameSettings
.GameType
in [GT_SINGLE
, GT_CUSTOM
]) then
5773 g_Game_PauseAllSounds(Enable
);
5776 procedure g_Game_PauseAllSounds(Enable
: Boolean);
5781 if gTriggers
<> nil then
5782 for i
:= 0 to High(gTriggers
) do
5783 with gTriggers
[i
] do
5784 if (TriggerType
= TRIGGER_SOUND
) and
5786 Sound
.IsPlaying() then
5788 Sound
.Pause(Enable
);
5792 if gPlayers
<> nil then
5793 for i
:= 0 to High(gPlayers
) do
5794 if gPlayers
[i
] <> nil then
5795 gPlayers
[i
].PauseSounds(Enable
);
5798 if gMusic
<> nil then
5799 gMusic
.Pause(Enable
);
5802 procedure g_Game_StopAllSounds(all
: Boolean);
5806 if gTriggers
<> nil then
5807 for i
:= 0 to High(gTriggers
) do
5808 with gTriggers
[i
] do
5809 if (TriggerType
= TRIGGER_SOUND
) and
5813 if gMusic
<> nil then
5820 procedure g_Game_UpdateTriggerSounds();
5824 if gTriggers
<> nil then
5825 for i
:= 0 to High(gTriggers
) do
5826 with gTriggers
[i
] do
5827 if (TriggerType
= TRIGGER_SOUND
) and
5830 Sound
.IsPlaying() then
5832 if ((gPlayer1
<> nil) and g_CollidePoint(gPlayer1
.GameX
, gPlayer1
.GameY
, X
, Y
, Width
, Height
)) or
5833 ((gPlayer2
<> nil) and g_CollidePoint(gPlayer2
.GameX
, gPlayer2
.GameY
, X
, Y
, Width
, Height
)) then
5835 Sound
.SetPan(0.5 - Data
.Pan
/255.0);
5836 Sound
.SetVolume(Data
.Volume
/255.0);
5839 Sound
.SetCoords(X
+(Width
div 2), Y
+(Height
div 2), Data
.Volume
/255.0);
5843 function g_Game_IsWatchedPlayer(UID
: Word): Boolean;
5846 if (gPlayer1
<> nil) and (gPlayer1
.UID
= UID
) then
5851 if (gPlayer2
<> nil) and (gPlayer2
.UID
= UID
) then
5856 if gSpectMode
<> SPECT_PLAYERS
then
5858 if gSpectPID1
= UID
then
5863 if gSpectViewTwo
and (gSpectPID2
= UID
) then
5870 function g_Game_IsWatchedTeam(Team
: Byte): Boolean;
5875 if (gPlayer1
<> nil) and (gPlayer1
.Team
= Team
) then
5880 if (gPlayer2
<> nil) and (gPlayer2
.Team
= Team
) then
5885 if gSpectMode
<> SPECT_PLAYERS
then
5887 Pl
:= g_Player_Get(gSpectPID1
);
5888 if (Pl
<> nil) and (Pl
.Team
= Team
) then
5893 if gSpectViewTwo
then
5895 Pl
:= g_Player_Get(gSpectPID2
);
5896 if (Pl
<> nil) and (Pl
.Team
= Team
) then
5904 procedure g_Game_Message(Msg
: string; Time
: Word);
5906 MessageText
:= b_Text_Format(Msg
);
5907 MessageTime
:= Time
;
5910 procedure g_Game_Announce_GoodShot(SpawnerUID
: Word);
5919 if not g_Game_IsWatchedPlayer(SpawnerUID
) then
5923 if goodsnd
[a
].IsPlaying() then
5926 goodsnd
[Random(4)].Play();
5929 procedure g_Game_Announce_KillCombo(Param
: Integer);
5936 UID
:= Param
and $FFFF;
5941 Pl
:= g_Player_Get(UID
);
5950 g_Console_Add(Format(_lc
[I_PLAYER_KILL_2X
], [Name
]), True);
5954 g_Console_Add(Format(_lc
[I_PLAYER_KILL_3X
], [Name
]), True);
5958 g_Console_Add(Format(_lc
[I_PLAYER_KILL_4X
], [Name
]), True);
5962 g_Console_Add(Format(_lc
[I_PLAYER_KILL_MX
], [Name
]), True);
5970 if not g_Game_IsWatchedPlayer(UID
) then
5973 if (not g_Game_IsWatchedPlayer(UID
)) and (c
< 4) then
5977 if killsnd
[n
].IsPlaying() then
5982 procedure g_Game_StartVote(Command
, Initiator
: string);
5986 if not gVotesEnabled
then Exit
;
5987 if gGameSettings
.GameType
<> GT_SERVER
then Exit
;
5988 if gVoteInProgress
or gVotePassed
then
5990 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_INPROGRESS
], [gVoteCommand
]), True);
5991 MH_SEND_VoteEvent(NET_VE_INPROGRESS
, gVoteCommand
);
5994 gVoteInProgress
:= True;
5995 gVotePassed
:= False;
5996 gVoteTimer
:= gTime
+ gVoteTimeout
* 1000;
5999 gVoteCommand
:= Command
;
6001 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
6002 Need
:= Floor((NetClientCount
+1)/2.0)+1
6004 Need
:= Floor(NetClientCount
/2.0)+1;
6005 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_STARTED
], [Initiator
, Command
, Need
]), True);
6006 MH_SEND_VoteEvent(NET_VE_STARTED
, Initiator
, Command
, Need
);
6009 procedure g_Game_CheckVote
;
6013 if gGameSettings
.GameType
<> GT_SERVER
then Exit
;
6014 if not gVoteInProgress
then Exit
;
6016 if (gTime
>= gVoteTimer
) then
6018 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
6019 Need
:= Floor((NetClientCount
+1)/2.0) + 1
6021 Need
:= Floor(NetClientCount
/2.0) + 1;
6022 if gVoteCount
>= Need
then
6024 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_PASSED
], [gVoteCommand
]), True);
6025 MH_SEND_VoteEvent(NET_VE_PASSED
, gVoteCommand
);
6026 gVotePassed
:= True;
6027 gVoteCmdTimer
:= gTime
+ 5000;
6031 g_Console_Add(_lc
[I_MESSAGE_VOTE_FAILED
], True);
6032 MH_SEND_VoteEvent(NET_VE_FAILED
);
6034 if NetClients
<> nil then
6035 for I
:= Low(NetClients
) to High(NetClients
) do
6036 if NetClients
[i
].Used
then
6037 NetClients
[i
].Voted
:= False;
6038 gVoteInProgress
:= False;
6044 if (gPlayer1
<> nil) or (gPlayer2
<> nil) then
6045 Need
:= Floor((NetClientCount
+1)/2.0) + 1
6047 Need
:= Floor(NetClientCount
/2.0) + 1;
6048 if gVoteCount
>= Need
then
6050 g_Console_Add(Format(_lc
[I_MESSAGE_VOTE_PASSED
], [gVoteCommand
]), True);
6051 MH_SEND_VoteEvent(NET_VE_PASSED
, gVoteCommand
);
6052 gVoteInProgress
:= False;
6053 gVotePassed
:= True;
6054 gVoteCmdTimer
:= gTime
+ 5000;
6057 if NetClients
<> nil then
6058 for I
:= Low(NetClients
) to High(NetClients
) do
6059 if NetClients
[i
].Used
then
6060 NetClients
[i
].Voted
:= False;
6065 procedure g_Game_LoadMapList(FileName
: string);
6073 if not FileExists(FileName
) then Exit
;
6075 AssignFile(ListFile
, FileName
);
6077 while not EOF(ListFile
) do
6079 ReadLn(ListFile
, s
);
6082 if s
= '' then Continue
;
6084 SetLength(MapList
, Length(MapList
)+1);
6085 MapList
[High(MapList
)] := s
;
6087 CloseFile(ListFile
);
6090 procedure g_Game_SetDebugMode();
6093 // ×èòû (äàæå â ñâîåé èãðå):
6097 procedure g_Game_SetLoadingText(Text: String; Max
: Integer; reWrite
: Boolean);
6101 if Length(LoadingStat
.Msgs
) = 0 then
6107 begin // Ïåðåõîäèì íà ñëåäóþùóþ ñòðîêó èëè ñêðîëëèðóåì:
6108 if NextMsg
= Length(Msgs
) then
6110 for i
:= 0 to High(Msgs
)-1 do
6111 Msgs
[i
] := Msgs
[i
+1];
6119 Msgs
[NextMsg
-1] := Text;
6125 g_ActiveWindow
:= nil;
6130 procedure g_Game_StepLoading();
6136 if (ShowCount
> LOADING_SHOW_STEP
) then
6144 procedure g_Game_ClearLoading();
6153 len
:= ((gScreenHeight
div 3)*2 - 50) div LOADING_INTERLINE
;
6154 if len
< 1 then len
:= 1;
6155 SetLength(Msgs
, len
);
6156 for len
:= Low(Msgs
) to High(Msgs
) do
6162 procedure Parse_Params(var pars
: TParamStrValues
);
6169 while i
<= ParamCount
do
6172 if (s
[1] = '-') and (Length(s
) > 1) then
6174 if (s
[2] = '-') and (Length(s
) > 2) then
6175 begin // Îäèíî÷íûé ïàðàìåòð
6176 SetLength(pars
, Length(pars
) + 1);
6177 with pars
[High(pars
)] do
6179 Name
:= LowerCase(s
);
6184 if (i
< ParamCount
) then
6185 begin // Ïàðàìåòð ñî çíà÷åíèåì
6187 SetLength(pars
, Length(pars
) + 1);
6188 with pars
[High(pars
)] do
6190 Name
:= LowerCase(s
);
6191 Value
:= LowerCase(ParamStr(i
));
6200 function Find_Param_Value(var pars
: TParamStrValues
; aName
: String): String;
6205 for i
:= 0 to High(pars
) do
6206 if pars
[i
].Name
= aName
then
6208 Result
:= pars
[i
].Value
;
6213 procedure g_Game_Process_Params();
6215 pars
: TParamStrValues
;
6218 LimT
, LimS
: Integer;
6229 s
:= Find_Param_Value(pars
, '--debug');
6231 g_Game_SetDebugMode();
6233 // Connect when game loads
6234 ip
:= Find_Param_Value(pars
, '-connect');
6238 s
:= Find_Param_Value(pars
, '-port');
6239 if (s
= '') or not TryStrToInt(s
, Port
) then
6242 s
:= Find_Param_Value(pars
, '-pw');
6244 g_Game_StartClient(ip
, Port
, s
);
6248 // Start map when game loads:
6249 map
:= LowerCase(Find_Param_Value(pars
, '-map'));
6250 if (map
<> '') and (Pos('.wad:\', map
) > 0) then
6253 s
:= Find_Param_Value(pars
, '-gm');
6254 GMode
:= g_Game_TextToMode(s
);
6255 if GMode
= GM_NONE
then GMode
:= GM_DM
;
6256 if GMode
= GM_SINGLE
then GMode
:= GM_COOP
;
6259 s
:= Find_Param_Value(pars
, '-limt');
6260 if (s
= '') or (not TryStrToInt(s
, LimT
)) then
6266 s
:= Find_Param_Value(pars
, '-lims');
6267 if (s
= '') or (not TryStrToInt(s
, LimS
)) then
6273 s
:= Find_Param_Value(pars
, '-lives');
6274 if (s
= '') or (not TryStrToInt(s
, Lives
)) then
6280 s
:= Find_Param_Value(pars
, '-opt');
6282 Opt
:= GAME_OPTION_ALLOWEXIT
or GAME_OPTION_BOTVSPLAYER
or GAME_OPTION_BOTVSMONSTER
6284 Opt
:= StrToIntDef(s
, 0);
6286 Opt
:= GAME_OPTION_ALLOWEXIT
or GAME_OPTION_BOTVSPLAYER
or GAME_OPTION_BOTVSMONSTER
;
6289 s
:= Find_Param_Value(pars
, '--close');
6293 // Delete test map after play:
6294 s
:= Find_Param_Value(pars
, '--testdelete');
6296 gMapToDelete
:= MapsDir
+ map
;
6298 // Delete temporary WAD after play:
6299 s
:= Find_Param_Value(pars
, '--tempdelete');
6302 gMapToDelete
:= MapsDir
+ map
;
6303 gTempDelete
:= True;
6306 // Number of players:
6307 s
:= Find_Param_Value(pars
, '-pl');
6311 n
:= StrToIntDef(s
, 1);
6314 s
:= Find_Param_Value(pars
, '-port');
6315 if (s
= '') or not TryStrToInt(s
, Port
) then
6316 g_Game_StartCustom(map
, GMode
, LimT
, LimS
, Lives
, Opt
, n
)
6318 g_Game_StartServer(map
, GMode
, LimT
, LimS
, Lives
, Opt
, n
, 0, Port
);
6321 // Execute script when game loads:
6322 s
:= Find_Param_Value(pars
, '-exec');
6325 if Pos(':\', s
) = 0 then
6326 s
:= GameDir
+ '/' + s
;
6331 if IOResult
<> 0 then
6333 e_WriteLog(Format(_lc
[I_SIMPLE_ERROR
], ['Failed to read file: ' + s
]), MSG_WARNING
);
6334 g_Console_Add(Format(_lc
[I_CONSOLE_ERROR_READ
], [s
]));
6338 e_WriteLog('Executing script: ' + s
, MSG_NOTIFY
);
6339 g_Console_Add(Format(_lc
[I_CONSOLE_EXEC
], [s
]));
6344 if IOResult
<> 0 then
6346 e_WriteLog(Format(_lc
[I_SIMPLE_ERROR
], ['Failed to read file: ' + s
]), MSG_WARNING
);
6347 g_Console_Add(Format(_lc
[I_CONSOLE_ERROR_READ
], [s
]));
6351 if Pos('#', s
) <> 1 then // script comment
6352 g_Console_Process(s
, True);