1 (* Copyright (C) DooM 2D:Forever Developers
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 {$INCLUDE ../shared/a_modes.inc}
23 e_graphics
, g_playermodel
, g_basic
, g_textures
,
24 g_weapons
, g_phys
, g_sound
, g_saveload
, MAPDEF
,
57 AmmoLimits
: Array [0..1] of Array [A_BULLETS
..A_HIGH
] of Word =
58 ((200, 50, 50, 300, 100),
59 (400, 100, 100, 600, 200));
80 ANGLE_NONE
= Low(SmallInt);
82 CORPSE_STATE_REMOVEME
= 0;
83 CORPSE_STATE_NORMAL
= 1;
84 CORPSE_STATE_MESS
= 2;
86 PLAYER_RECT
: TRectWH
= (X
:15; Y
:12; Width
:34; Height
:52);
87 PLAYER_RECT_CX
= 15+(34 div 2);
88 PLAYER_RECT_CY
= 12+(52 div 2);
89 PLAYER_CORPSERECT
: TRectWH
= (X
:15; Y
:48; Width
:34; Height
:16);
92 PLAYER_HP_LIMIT
= 200;
94 PLAYER_AP_LIMIT
= 200;
97 PLAYER1_DEF_COLOR
: TRGB
= (R
:64; G
:175; B
:48);
98 PLAYER2_DEF_COLOR
: TRGB
= (R
:96; G
:96; B
:96);
114 TPlayerStatArray
= Array of TPlayerStat
;
116 TPlayerSavedState
= record
124 Ammo
: Array [A_BULLETS
..A_HIGH
] of Word;
125 MaxAmmo
: Array [A_BULLETS
..A_HIGH
] of Word;
126 Weapon
: Array [WP_FIRST
..WP_LAST
] of Boolean;
127 Rulez
: Set of R_ITEM_BACKPACK
..R_BERSERK
;
136 TPlayer
= class (TObject
)
144 FDirection
: TDirection
;
152 FMonsterKills
: Integer;
158 FCanJetpack
: Boolean;
164 FNextWeapDelay
: Byte; // frames
165 FBFGFireCounter
: SmallInt;
166 FLastSpawnerUID
: Word;
170 FSpectatePlayer
: Integer;
171 FFirePainTime
: Integer;
174 FSavedState
: TPlayerSavedState
;
176 FModel
: TPlayerModel
;
179 FActionForce
: Boolean;
180 FActionChanged
: Boolean;
182 FFireAngle
: SmallInt;
184 FShellTimer
: Integer;
186 FSawSound
: TPlayableSound
;
187 FSawSoundIdle
: TPlayableSound
;
188 FSawSoundHit
: TPlayableSound
;
189 FSawSoundSelect
: TPlayableSound
;
190 FJetSoundOn
: TPlayableSound
;
191 FJetSoundOff
: TPlayableSound
;
192 FJetSoundFly
: TPlayableSound
;
196 FJustTeleported
: Boolean;
199 function CollideLevel(XInc
, YInc
: Integer): Boolean;
200 function StayOnStep(XInc
, YInc
: Integer): Boolean;
201 function HeadInLiquid(XInc
, YInc
: Integer): Boolean;
202 function BodyInLiquid(XInc
, YInc
: Integer): Boolean;
203 function BodyInAcid(XInc
, YInc
: Integer): Boolean;
204 function FullInLift(XInc
, YInc
: Integer): Integer;
205 {procedure CollideItem();}
206 procedure FlySmoke(Times
: DWORD
= 1);
207 procedure OnFireFlame(Times
: DWORD
= 1);
208 function GetAmmoByWeapon(Weapon
: Byte): Word;
209 procedure SetAction(Action
: Byte; Force
: Boolean = False);
210 procedure OnDamage(Angle
: SmallInt); virtual;
211 function firediry(): Integer;
213 procedure Run(Direction
: TDirection
);
214 procedure NextWeapon();
215 procedure PrevWeapon();
222 function getNextWeaponIndex (): Byte; // return 255 for "no switch"
223 procedure resetWeaponQueue ();
224 function hasAmmoForWeapon (weapon
: Byte): Boolean;
227 FDamageBuffer
: Integer;
229 FAmmo
: Array [A_BULLETS
..A_HIGH
] of Word;
230 FMaxAmmo
: Array [A_BULLETS
..A_HIGH
] of Word;
231 FWeapon
: Array [WP_FIRST
..WP_LAST
] of Boolean;
232 FRulez
: Set of R_ITEM_BACKPACK
..R_BERSERK
;
234 FMegaRulez
: Array [MR_SUIT
..MR_MAX
] of DWORD
;
235 FReloading
: Array [WP_FIRST
..WP_LAST
] of Word;
236 FTime
: Array [T_RESPAWN
..T_FLAGCAP
] of DWORD
;
237 FKeys
: Array [KEY_LEFT
..KEY_CHAT
] of TKeyState
;
239 FPreferredTeam
: Byte;
242 FWantsInGame
: Boolean;
246 FActualModelName
: string;
253 // debug: viewport offset
254 viewPortX
, viewPortY
, viewPortW
, viewPortH
: Integer;
256 function isValidViewPort (): Boolean; inline;
258 constructor Create(); virtual;
259 destructor Destroy(); override;
260 procedure Respawn(Silent
: Boolean; Force
: Boolean = False); virtual;
261 function GetRespawnPoint(): Byte;
262 procedure PressKey(Key
: Byte; Time
: Word = 1);
263 procedure ReleaseKeys();
264 procedure SetModel(ModelName
: String);
265 procedure SetColor(Color
: TRGB
);
266 procedure SetWeapon(W
: Byte);
267 function IsKeyPressed(K
: Byte): Boolean;
268 function GetKeys(): Byte;
269 function PickItem(ItemType
: Byte; arespawn
: Boolean; var remove
: Boolean): Boolean; virtual;
270 function Collide(X
, Y
: Integer; Width
, Height
: Word): Boolean; overload
;
271 function Collide(Panel
: TPanel
): Boolean; overload
;
272 function Collide(X
, Y
: Integer): Boolean; overload
;
273 procedure SetDirection(Direction
: TDirection
);
274 procedure GetSecret();
275 function TeleportTo(X
, Y
: Integer; silent
: Boolean; dir
: Byte): Boolean;
277 procedure Push(vx
, vy
: Integer);
278 procedure ChangeModel(ModelName
: String);
279 procedure SwitchTeam
;
280 procedure ChangeTeam(Team
: Byte);
282 function GetFlag(Flag
: Byte): Boolean;
283 procedure SetFlag(Flag
: Byte);
284 function DropFlag(): Boolean;
285 procedure AllRulez(Health
: Boolean);
286 procedure RestoreHealthArmor();
287 procedure FragCombo();
288 procedure GiveItem(ItemType
: Byte);
289 procedure Damage(value
: Word; SpawnerUID
: Word; vx
, vy
: Integer; t
: Byte); virtual;
290 function Heal(value
: Word; Soft
: Boolean): Boolean; virtual;
291 procedure MakeBloodVector(Count
: Word; VelX
, VelY
: Integer);
292 procedure MakeBloodSimple(Count
: Word);
293 procedure Kill(KillType
: Byte; SpawnerUID
: Word; t
: Byte);
294 procedure Reset(Force
: Boolean);
295 procedure Spectate(NoMove
: Boolean = False);
296 procedure SwitchNoClip
;
297 procedure SoftReset();
298 procedure Draw(); virtual;
299 procedure DrawPain();
300 procedure DrawPickup();
301 procedure DrawRulez();
303 procedure DrawBubble();
305 procedure Update(); virtual;
306 procedure RememberState();
307 procedure RecallState();
308 procedure SaveState(var Mem
: TBinMemoryWriter
); virtual;
309 procedure LoadState(var Mem
: TBinMemoryReader
); virtual;
310 procedure PauseSounds(Enable
: Boolean);
311 procedure NetFire(Wpn
: Byte; X
, Y
, AX
, AY
: Integer; WID
: Integer = -1);
312 procedure DoLerp(Level
: Integer = 2);
313 procedure SetLerp(XTo
, YTo
: Integer);
314 procedure QueueWeaponSwitch(Weapon
: Byte);
315 procedure RealizeCurrentWeapon();
317 procedure JetpackOff
;
318 procedure CatchFire(Attacker
: Word);
320 //WARNING! this does nothing for now, but still call it!
321 procedure positionChanged (); //WARNING! call this after entity position was changed, or coldet will not work right!
323 procedure getMapBox (out x
, y
, w
, h
: Integer); inline;
324 procedure moveBy (dx
, dy
: Integer); inline;
327 property Vel
: TPoint2i read FObj
.Vel
;
328 property Obj
: TObj read FObj
;
331 property Name
: String read FName write FName
;
332 property Model
: TPlayerModel read FModel
;
333 property Health
: Integer read FHealth write FHealth
;
334 property Lives
: Byte read FLives write FLives
;
335 property Armor
: Integer read FArmor write FArmor
;
336 property Air
: Integer read FAir write FAir
;
337 property JetFuel
: Integer read FJetFuel write FJetFuel
;
338 property Frags
: Integer read FFrags write FFrags
;
339 property Death
: Integer read FDeath write FDeath
;
340 property Kills
: Integer read FKills write FKills
;
341 property CurrWeap
: Byte read FCurrWeap write FCurrWeap
;
342 property MonsterKills
: Integer read FMonsterKills write FMonsterKills
;
343 property Secrets
: Integer read FSecrets
;
344 property GodMode
: Boolean read FGodMode write FGodMode
;
345 property NoTarget
: Boolean read FNoTarget write FNoTarget
;
346 property NoReload
: Boolean read FNoReload write FNoReload
;
347 property alive
: Boolean read FAlive write FAlive
;
348 property Flag
: Byte read FFlag
;
349 property Team
: Byte read FTeam write FTeam
;
350 property Direction
: TDirection read FDirection
;
351 property GameX
: Integer read FObj
.X write FObj
.X
;
352 property GameY
: Integer read FObj
.Y write FObj
.Y
;
353 property GameVelX
: Integer read FObj
.Vel
.X write FObj
.Vel
.X
;
354 property GameVelY
: Integer read FObj
.Vel
.Y write FObj
.Vel
.Y
;
355 property GameAccelX
: Integer read FObj
.Accel
.X write FObj
.Accel
.X
;
356 property GameAccelY
: Integer read FObj
.Accel
.Y write FObj
.Accel
.Y
;
357 property IncCam
: Integer read FIncCam write FIncCam
;
358 property UID
: Word read FUID write FUID
;
359 property JustTeleported
: Boolean read FJustTeleported write FJustTeleported
;
360 property NetTime
: LongWord read FNetTime write FNetTime
;
370 WeaponPrior
: Array [WP_FIRST
..WP_LAST
] of Byte;
371 CloseWeaponPrior
: Array [WP_FIRST
..WP_LAST
] of Byte;
372 //SafeWeaponPrior: Array [WP_FIRST..WP_LAST] of Byte;
380 TBot
= class (TPlayer
)
382 FSelectedWeapon
: Byte;
385 FAIFlags
: Array of TAIFlag
;
386 FDifficult
: TDifficult
;
388 function GetRnd(a
: Byte): Boolean;
389 function GetInterval(a
: Byte; radius
: SmallInt): SmallInt;
390 function RunDirection(): TDirection
;
391 function FullInStep(XInc
, YInc
: Integer): Boolean;
392 //function NeedItem(Item: Byte): Byte;
393 procedure SelectWeapon(Dist
: Integer);
394 procedure SetAIFlag(aName
, fValue
: String20
);
395 function GetAIFlag(aName
: String20
): String20
;
396 procedure RemoveAIFlag(aName
: String20
);
397 function Healthy(): Byte;
398 procedure UpdateMove();
399 procedure UpdateCombat();
400 function KeyPressed(Key
: Word): Boolean;
401 procedure ReleaseKey(Key
: Byte);
402 function TargetOnScreen(TX
, TY
: Integer): Boolean;
403 procedure OnDamage(Angle
: SmallInt); override;
406 procedure Respawn(Silent
: Boolean; Force
: Boolean = False); override;
407 constructor Create(); override;
408 destructor Destroy(); override;
409 procedure Draw(); override;
410 function PickItem(ItemType
: Byte; force
: Boolean; var remove
: Boolean): Boolean; override;
411 function Heal(value
: Word; Soft
: Boolean): Boolean; override;
412 procedure Update(); override;
413 procedure SaveState(var Mem
: TBinMemoryWriter
); override;
414 procedure LoadState(var Mem
: TBinMemoryReader
); override;
426 procedure getMapBox (out x
, y
, w
, h
: Integer); inline;
427 procedure moveBy (dx
, dy
: Integer); inline;
429 procedure positionChanged (); inline; //WARNING! call this after entity position was changed, or coldet will not work right!
443 procedure getMapBox (out x
, y
, w
, h
: Integer); inline;
444 procedure moveBy (dx
, dy
: Integer); inline;
446 procedure positionChanged (); inline; //WARNING! call this after entity position was changed, or coldet will not work right!
449 TCorpse
= class (TObject
)
457 FAnimation
: TAnimation
;
458 FAnimationMask
: TAnimation
;
461 constructor Create(X
, Y
: Integer; ModelName
: String; aMess
: Boolean);
462 destructor Destroy(); override;
463 procedure Damage(Value
: Word; vx
, vy
: Integer);
466 procedure SaveState(var Mem
: TBinMemoryWriter
);
467 procedure LoadState(var Mem
: TBinMemoryReader
);
469 procedure getMapBox (out x
, y
, w
, h
: Integer); inline;
470 procedure moveBy (dx
, dy
: Integer); inline;
472 procedure positionChanged (); inline; //WARNING! call this after entity position was changed, or coldet will not work right!
474 function ObjPtr (): PObj
; inline;
476 property Obj
: TObj read FObj
; // copies object
477 property State
: Byte read FState
;
478 property Mess
: Boolean read FMess
;
481 TTeamStat
= Array [TEAM_RED
..TEAM_BLUE
] of
487 gPlayers
: Array of TPlayer
;
488 gCorpses
: Array of TCorpse
;
489 gGibs
: Array of TGib
;
490 gShells
: Array of TShell
;
491 gTeamStat
: TTeamStat
;
492 gFly
: Boolean = False;
493 gAimLine
: Boolean = False;
494 gChatBubble
: Byte = 0;
498 MAX_RUNVEL
: Integer = 8;
499 VEL_JUMP
: Integer = 10;
500 SHELL_TIMEOUT
: Cardinal = 60000;
502 function Lerp(X
, Y
, Factor
: Integer): Integer;
504 procedure g_Gibs_SetMax(Count
: Word);
505 function g_Gibs_GetMax(): Word;
506 procedure g_Corpses_SetMax(Count
: Word);
507 function g_Corpses_GetMax(): Word;
508 procedure g_Shells_SetMax(Count
: Word);
509 function g_Shells_GetMax(): Word;
511 procedure g_Player_Init();
512 procedure g_Player_Free();
513 function g_Player_Create(ModelName
: String; Color
: TRGB
; Team
: Byte; Bot
: Boolean): Word;
514 function g_Player_CreateFromState(var Mem
: TBinMemoryReader
): Word;
515 procedure g_Player_Remove(UID
: Word);
516 procedure g_Player_ResetTeams();
517 procedure g_Player_UpdateAll();
518 procedure g_Player_DrawAll();
519 procedure g_Player_DrawDebug(p
: TPlayer
);
520 procedure g_Player_DrawHealth();
521 procedure g_Player_RememberAll();
522 procedure g_Player_ResetAll(Force
, Silent
: Boolean);
523 function g_Player_Get(UID
: Word): TPlayer
;
524 function g_Player_GetCount(): Byte;
525 function g_Player_GetStats(): TPlayerStatArray
;
526 function g_Player_ValidName(Name
: String): Boolean;
527 procedure g_Player_CreateCorpse(Player
: TPlayer
);
528 procedure g_Player_CreateGibs(fX
, fY
: Integer; ModelName
: String; fColor
: TRGB
);
529 procedure g_Player_CreateShell(fX
, fY
, dX
, dY
: Integer; T
: Byte);
530 procedure g_Player_UpdatePhysicalObjects();
531 procedure g_Player_DrawCorpses();
532 procedure g_Player_DrawShells();
533 procedure g_Player_RemoveAllCorpses();
534 procedure g_Player_Corpses_SaveState(var Mem
: TBinMemoryWriter
);
535 procedure g_Player_Corpses_LoadState(var Mem
: TBinMemoryReader
);
536 procedure g_Bot_Add(Team
, Difficult
: Byte);
537 procedure g_Bot_AddList(Team
: Byte; lname
: ShortString; num
: Integer = -1);
538 procedure g_Bot_MixNames();
539 procedure g_Bot_RemoveAll();
544 e_log
, g_map
, g_items
, g_console
, SysUtils
, g_gfx
, Math
,
545 g_options
, g_triggers
, g_menu
, g_game
, g_grid
,
546 wadreader
, g_main
, g_monsters
, CONFIG
, g_language
,
547 g_net
, g_netmsg
, g_window
, GL
, g_holmes
;
557 diag_precision
: Byte;
561 w_prior1
: Array [WP_FIRST
..WP_LAST
] of Byte;
562 w_prior2
: Array [WP_FIRST
..WP_LAST
] of Byte;
563 w_prior3
: Array [WP_FIRST
..WP_LAST
] of Byte;
567 TIME_RESPAWN1
= 1500;
568 TIME_RESPAWN2
= 2000;
569 TIME_RESPAWN3
= 3000;
572 JET_MAX
= 540; // ~30 sec
573 PLAYER_SUIT_TIME
= 30000;
574 PLAYER_INVUL_TIME
= 30000;
575 PLAYER_INVIS_TIME
= 35000;
576 FRAG_COMBO_TIME
= 3000;
580 ANGLE_RIGHTDOWN
= -35;
582 ANGLE_LEFTDOWN
= -145;
583 PLAYER_HEADRECT
: TRectWH
= (X
:24; Y
:12; Width
:20; Height
:12);
584 WEAPONPOINT
: Array [TDirection
] of TDFPoint
= ((X
:16; Y
:32), (X
:47; Y
:32));
587 BOT_UNSAFEDIST
= 128;
588 TEAMCOLOR
: Array [TEAM_RED
..TEAM_BLUE
] of TRGB
= ((R
:255; G
:0; B
:0),
590 DIFFICULT_EASY
: TDifficult
= (DiagFire
: 32; InvisFire
: 32; DiagPrecision
: 32;
591 FlyPrecision
: 32; Cover
: 32; CloseJump
: 32;
592 WeaponPrior
:(0,0,0,0,0,0,0,0,0,0,0); CloseWeaponPrior
:(0,0,0,0,0,0,0,0,0,0,0));
593 DIFFICULT_MEDIUM
: TDifficult
= (DiagFire
: 127; InvisFire
: 127; DiagPrecision
: 127;
594 FlyPrecision
: 127; Cover
: 127; CloseJump
: 127;
595 WeaponPrior
:(0,0,0,0,0,0,0,0,0,0,0); CloseWeaponPrior
:(0,0,0,0,0,0,0,0,0,0,0));
596 DIFFICULT_HARD
: TDifficult
= (DiagFire
: 255; InvisFire
: 255; DiagPrecision
: 255;
597 FlyPrecision
: 255; Cover
: 255; CloseJump
: 255;
598 WeaponPrior
:(0,0,0,0,0,0,0,0,0,0,0); CloseWeaponPrior
:(0,0,0,0,0,0,0,0,0,0,0));
599 WEAPON_PRIOR1
: Array [WP_FIRST
..WP_LAST
] of Byte =
600 (WEAPON_FLAMETHROWER
, WEAPON_SUPERPULEMET
,
601 WEAPON_SHOTGUN2
, WEAPON_SHOTGUN1
,
602 WEAPON_CHAINGUN
, WEAPON_PLASMA
, WEAPON_ROCKETLAUNCHER
,
603 WEAPON_BFG
, WEAPON_PISTOL
, WEAPON_SAW
, WEAPON_KASTET
);
604 WEAPON_PRIOR2
: Array [WP_FIRST
..WP_LAST
] of Byte =
605 (WEAPON_FLAMETHROWER
, WEAPON_SUPERPULEMET
,
606 WEAPON_BFG
, WEAPON_ROCKETLAUNCHER
,
607 WEAPON_SHOTGUN2
, WEAPON_PLASMA
, WEAPON_SHOTGUN1
,
608 WEAPON_CHAINGUN
, WEAPON_PISTOL
, WEAPON_SAW
, WEAPON_KASTET
);
609 //WEAPON_PRIOR3: Array [WP_FIRST..WP_LAST] of Byte =
610 // (WEAPON_FLAMETHROWER, WEAPON_SUPERPULEMET,
611 // WEAPON_BFG, WEAPON_PLASMA, WEAPON_SHOTGUN2,
612 // WEAPON_CHAINGUN, WEAPON_SHOTGUN1, WEAPON_SAW,
613 // WEAPON_ROCKETLAUNCHER, WEAPON_PISTOL, WEAPON_KASTET);
614 WEAPON_RELOAD
: Array [WP_FIRST
..WP_LAST
] of Byte =
615 (5, 2, 6, 18, 36, 2, 12, 2, 14, 2, 2);
617 PLAYER_SIGNATURE
= $52594C50; // 'PLYR'
618 CORPSE_SIGNATURE
= $50524F43; // 'CORP'
620 BOTNAMES_FILENAME
= 'botnames.txt';
621 BOTLIST_FILENAME
= 'botlist.txt';
625 MaxCorpses
: Word = 20;
626 MaxShells
: Word = 300;
627 CurrentGib
: Integer = 0;
628 CurrentShell
: Integer = 0;
629 BotNames
: Array of String;
630 BotList
: Array of TBotProfile
;
633 function Lerp(X
, Y
, Factor
: Integer): Integer;
635 Result
:= X
+ ((Y
- X
) div Factor
);
638 function SameTeam(UID1
, UID2
: Word): Boolean;
642 if (UID1
> UID_MAX_PLAYER
) or (UID1
<= UID_MAX_GAME
) or
643 (UID2
> UID_MAX_PLAYER
) or (UID2
<= UID_MAX_GAME
) then Exit
;
645 if (g_Player_Get(UID1
) = nil) or (g_Player_Get(UID2
) = nil) then Exit
;
647 if ((g_Player_Get(UID1
).Team
= TEAM_NONE
) or
648 (g_Player_Get(UID2
).Team
= TEAM_NONE
)) then Exit
;
650 Result
:= g_Player_Get(UID1
).FTeam
= g_Player_Get(UID2
).FTeam
;
653 procedure g_Gibs_SetMax(Count
: Word);
656 SetLength(gGibs
, Count
);
658 if CurrentGib
>= Count
then
662 function g_Gibs_GetMax(): Word;
667 procedure g_Shells_SetMax(Count
: Word);
670 SetLength(gShells
, Count
);
672 if CurrentShell
>= Count
then
676 function g_Shells_GetMax(): Word;
682 procedure g_Corpses_SetMax(Count
: Word);
685 SetLength(gCorpses
, Count
);
688 function g_Corpses_GetMax(): Word;
690 Result
:= MaxCorpses
;
693 function g_Player_Create(ModelName
: String; Color
: TRGB
; Team
: Byte; Bot
: Boolean): Word;
703 // Åñòü ëè ìåñòî â gPlayers:
704 if gPlayers
<> nil then
705 for a
:= 0 to High(gPlayers
) do
706 if gPlayers
[a
] = nil then
712 // Íåò ìåñòà - ðàñøèðÿåì gPlayers:
715 SetLength(gPlayers
, Length(gPlayers
)+1);
719 // Ñîçäàåì îáúåêò èãðîêà:
721 gPlayers
[a
] := TBot
.Create()
723 gPlayers
[a
] := TPlayer
.Create();
726 gPlayers
[a
].FActualModelName
:= ModelName
;
727 gPlayers
[a
].SetModel(ModelName
);
729 // Íåò ìîäåëè - ñîçäàíèå íå âîçìîæíî:
730 if gPlayers
[a
].FModel
= nil then
734 g_FatalError(Format(_lc
[I_GAME_ERROR_MODEL
], [ModelName
]));
738 if not (Team
in [TEAM_RED
, TEAM_BLUE
]) then
739 if Random(2) = 0 then
743 gPlayers
[a
].FPreferredTeam
:= Team
;
745 case gGameSettings
.GameMode
of
746 GM_DM
: gPlayers
[a
].FTeam
:= TEAM_NONE
;
748 GM_CTF
: gPlayers
[a
].FTeam
:= gPlayers
[a
].FPreferredTeam
;
750 GM_COOP
: gPlayers
[a
].FTeam
:= TEAM_COOP
;
753 // Åñëè êîìàíäíàÿ èãðà - êðàñèì ìîäåëü â öâåò êîìàíäû:
754 gPlayers
[a
].FColor
:= Color
;
755 if gPlayers
[a
].FTeam
in [TEAM_RED
, TEAM_BLUE
] then
756 gPlayers
[a
].FModel
.Color
:= TEAMCOLOR
[gPlayers
[a
].FTeam
]
758 gPlayers
[a
].FModel
.Color
:= Color
;
760 gPlayers
[a
].FUID
:= g_CreateUID(UID_PLAYER
);
761 gPlayers
[a
].FAlive
:= False;
763 Result
:= gPlayers
[a
].FUID
;
766 function g_Player_CreateFromState(var Mem
: TBinMemoryReader
): Word;
779 if sig
<> PLAYER_SIGNATURE
then // 'PLYR'
781 raise EBinSizeError
.Create('g_Player_CreateFromState: Wrong Player Signature');
785 Mem
.ReadBoolean(Bot
);
790 // Åñòü ëè ìåñòî â gPlayers:
791 if gPlayers
<> nil then
792 for a
:= 0 to High(gPlayers
) do
793 if gPlayers
[a
] = nil then
799 // Íåò ìåñòà - ðàñøèðÿåì gPlayers:
802 SetLength(gPlayers
, Length(gPlayers
)+1);
806 // Ñîçäàåì îáúåêò èãðîêà:
808 gPlayers
[a
] := TBot
.Create()
810 gPlayers
[a
] := TPlayer
.Create();
811 gPlayers
[a
].FIamBot
:= Bot
;
812 gPlayers
[a
].FPhysics
:= True;
815 Mem
.ReadWord(gPlayers
[a
].FUID
);
817 Mem
.ReadString(gPlayers
[a
].FName
);
819 Mem
.ReadByte(gPlayers
[a
].FTeam
);
820 gPlayers
[a
].FPreferredTeam
:= gPlayers
[a
].FTeam
;
822 Mem
.ReadBoolean(gPlayers
[a
].FAlive
);
823 // Èçðàñõîäîâàë ëè âñå æèçíè:
824 Mem
.ReadBoolean(gPlayers
[a
].FNoRespawn
);
828 gPlayers
[a
].FDirection
:= D_LEFT
830 gPlayers
[a
].FDirection
:= D_RIGHT
;
832 Mem
.ReadInt(gPlayers
[a
].FHealth
);
834 Mem
.ReadByte(gPlayers
[a
].FLives
);
836 Mem
.ReadInt(gPlayers
[a
].FArmor
);
838 Mem
.ReadInt(gPlayers
[a
].FAir
);
840 Mem
.ReadInt(gPlayers
[a
].FJetFuel
);
842 Mem
.ReadInt(gPlayers
[a
].FPain
);
844 Mem
.ReadInt(gPlayers
[a
].FKills
);
846 Mem
.ReadInt(gPlayers
[a
].FMonsterKills
);
848 Mem
.ReadInt(gPlayers
[a
].FFrags
);
850 Mem
.ReadByte(gPlayers
[a
].FFragCombo
);
851 // Âðåìÿ ïîñëåäíåãî ôðàãà:
852 Mem
.ReadDWORD(gPlayers
[a
].FLastFrag
);
854 Mem
.ReadInt(gPlayers
[a
].FDeath
);
856 Mem
.ReadByte(gPlayers
[a
].FFlag
);
858 Mem
.ReadInt(gPlayers
[a
].FSecrets
);
860 Mem
.ReadByte(gPlayers
[a
].FCurrWeap
);
861 // Ñëåäóþùåå æåëàåìîå îðóæèå:
862 Mem
.ReadWord(gPlayers
[a
].FNextWeap
);
864 Mem
.ReadByte(gPlayers
[a
].FNextWeapDelay
);
865 // Âðåìÿ çàðÿäêè BFG:
866 Mem
.ReadSmallInt(gPlayers
[a
].FBFGFireCounter
);
868 Mem
.ReadInt(gPlayers
[a
].FDamageBuffer
);
869 // Ïîñëåäíèé óäàðèâøèé:
870 Mem
.ReadWord(gPlayers
[a
].FLastSpawnerUID
);
871 // Òèï ïîñëåäíåãî ïîëó÷åííîãî óðîíà:
872 Mem
.ReadByte(gPlayers
[a
].FLastHit
);
874 Obj_LoadState(@gPlayers
[a
].FObj
, Mem
);
875 // Òåêóùåå êîëè÷åñòâî ïàòðîíîâ:
876 for i
:= A_BULLETS
to A_HIGH
do
877 Mem
.ReadWord(gPlayers
[a
].FAmmo
[i
]);
878 // Ìàêñèìàëüíîå êîëè÷åñòâî ïàòðîíîâ:
879 for i
:= A_BULLETS
to A_HIGH
do
880 Mem
.ReadWord(gPlayers
[a
].FMaxAmmo
[i
]);
882 for i
:= WP_FIRST
to WP_LAST
do
883 Mem
.ReadBoolean(gPlayers
[a
].FWeapon
[i
]);
884 // Âðåìÿ ïåðåçàðÿäêè îðóæèÿ:
885 for i
:= WP_FIRST
to WP_LAST
do
886 Mem
.ReadWord(gPlayers
[a
].FReloading
[i
]);
890 Include(gPlayers
[a
].FRulez
, R_ITEM_BACKPACK
);
891 // Íàëè÷èå êðàñíîãî êëþ÷à:
894 Include(gPlayers
[a
].FRulez
, R_KEY_RED
);
895 // Íàëè÷èå çåëåíîãî êëþ÷à:
898 Include(gPlayers
[a
].FRulez
, R_KEY_GREEN
);
899 // Íàëè÷èå ñèíåãî êëþ÷à:
902 Include(gPlayers
[a
].FRulez
, R_KEY_BLUE
);
906 Include(gPlayers
[a
].FRulez
, R_BERSERK
);
907 // Âðåìÿ äåéñòâèÿ ñïåöèàëüíûõ ïðåäìåòîâ:
908 for i
:= MR_SUIT
to MR_MAX
do
909 Mem
.ReadDWORD(gPlayers
[a
].FMegaRulez
[i
]);
910 // Âðåìÿ äî ïîâòîðíîãî ðåñïàóíà, ñìåíû îðóæèÿ, èñîëüçîâàíèÿ, çàõâàòà ôëàãà:
911 for i
:= T_RESPAWN
to T_FLAGCAP
do
912 Mem
.ReadDWORD(gPlayers
[a
].FTime
[i
]);
915 Mem
.ReadString(gPlayers
[a
].FActualModelName
);
917 Mem
.ReadByte(gPlayers
[a
].FColor
.R
);
918 Mem
.ReadByte(gPlayers
[a
].FColor
.G
);
919 Mem
.ReadByte(gPlayers
[a
].FColor
.B
);
920 // Îáíîâëÿåì ìîäåëü èãðîêà:
921 gPlayers
[a
].SetModel(gPlayers
[a
].FActualModelName
);
923 // Íåò ìîäåëè - ñîçäàíèå íå âîçìîæíî:
924 if gPlayers
[a
].FModel
= nil then
928 g_FatalError(Format(_lc
[I_GAME_ERROR_MODEL
], [gPlayers
[a
].FActualModelName
]));
932 // Åñëè êîìàíäíàÿ èãðà - êðàñèì ìîäåëü â öâåò êîìàíäû:
933 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
934 gPlayers
[a
].FModel
.Color
:= TEAMCOLOR
[gPlayers
[a
].FTeam
]
936 gPlayers
[a
].FModel
.Color
:= gPlayers
[a
].FColor
;
938 Result
:= gPlayers
[a
].FUID
;
941 procedure g_Player_ResetTeams();
945 if g_Game_IsClient
then
947 if gPlayers
= nil then
949 for a
:= Low(gPlayers
) to High(gPlayers
) do
950 if gPlayers
[a
] <> nil then
951 case gGameSettings
.GameMode
of
953 gPlayers
[a
].ChangeTeam(TEAM_NONE
);
955 if not (gPlayers
[a
].Team
in [TEAM_RED
, TEAM_BLUE
]) then
956 if gPlayers
[a
].FPreferredTeam
in [TEAM_RED
, TEAM_BLUE
] then
957 gPlayers
[a
].ChangeTeam(gPlayers
[a
].FPreferredTeam
)
960 gPlayers
[a
].ChangeTeam(TEAM_RED
)
962 gPlayers
[a
].ChangeTeam(TEAM_BLUE
);
965 gPlayers
[a
].ChangeTeam(TEAM_COOP
);
969 procedure g_Bot_Add(Team
, Difficult
: Byte);
972 _name
, _model
: String;
975 if not g_Game_IsServer
then Exit
;
977 // Ñïèñîê íàçâàíèé ìîäåëåé:
978 m
:= g_PlayerModel_GetNames();
983 if (gGameSettings
.GameType
= GT_SINGLE
) or (gGameSettings
.GameMode
= GM_COOP
) then
984 Team
:= TEAM_COOP
// COOP
986 if gGameSettings
.GameMode
= GM_DM
then
987 Team
:= TEAM_NONE
// DM
989 if Team
= TEAM_NONE
then // CTF / TDM
991 // Àâòîáàëàíñ êîìàíä:
995 for a
:= 0 to High(gPlayers
) do
996 if gPlayers
[a
] <> nil then
998 if gPlayers
[a
].Team
= TEAM_RED
then
1001 if gPlayers
[a
].Team
= TEAM_BLUE
then
1011 if Random(2) = 0 then
1017 // Âûáèðàåì áîòó èìÿ:
1019 if BotNames
<> nil then
1020 for a
:= 0 to High(BotNames
) do
1021 if g_Player_ValidName(BotNames
[a
]) then
1023 _name
:= BotNames
[a
];
1027 // Èìåíè íåò, çàäàåì ñëó÷àéíîå:
1030 _name
:= Format('DFBOT%.2d', [Random(100)]);
1031 until g_Player_ValidName(_name
);
1033 // Âûáèðàåì ñëó÷àéíóþ ìîäåëü:
1034 _model
:= m
[Random(Length(m
))];
1037 with g_Player_Get(g_Player_Create(_model
,
1038 _RGB(Min(Random(9)*32, 255),
1039 Min(Random(9)*32, 255),
1040 Min(Random(9)*32, 255)),
1041 Team
, True)) as TBot
do
1046 1: FDifficult
:= DIFFICULT_EASY
;
1047 2: FDifficult
:= DIFFICULT_MEDIUM
;
1048 else FDifficult
:= DIFFICULT_HARD
;
1051 for a
:= WP_FIRST
to WP_LAST
do
1053 FDifficult
.WeaponPrior
[a
] := WEAPON_PRIOR1
[a
];
1054 FDifficult
.CloseWeaponPrior
[a
] := WEAPON_PRIOR2
[a
];
1055 //FDifficult.SafeWeaponPrior[a] := WEAPON_PRIOR3[a];
1058 g_Console_Add(Format(_lc
[I_PLAYER_JOIN
], [Name
]), True);
1060 if g_Game_IsNet
then MH_SEND_PlayerCreate(UID
);
1061 if g_Game_IsServer
and (gGameSettings
.MaxLives
> 0) then
1066 procedure g_Bot_AddList(Team
: Byte; lName
: ShortString; num
: Integer = -1);
1069 _name
, _model
: String;
1072 if not g_Game_IsServer
then Exit
;
1074 // Ñïèñîê íàçâàíèé ìîäåëåé:
1075 m
:= g_PlayerModel_GetNames();
1080 if (gGameSettings
.GameType
= GT_SINGLE
) or (gGameSettings
.GameMode
= GM_COOP
) then
1081 Team
:= TEAM_COOP
// COOP
1083 if gGameSettings
.GameMode
= GM_DM
then
1084 Team
:= TEAM_NONE
// DM
1086 if Team
= TEAM_NONE
then
1087 Team
:= BotList
[num
].team
; // CTF / TDM
1089 // Âûáèðàåì íàñòðîéêè áîòà èç ñïèñêà ïî íîìåðó èëè èìåíè:
1090 lName
:= AnsiLowerCase(lName
);
1091 if (num
< 0) or (num
> Length(BotList
)-1) then
1093 if (num
= -1) and (lName
<> '') and (BotList
<> nil) then
1094 for a
:= 0 to High(BotList
) do
1095 if AnsiLowerCase(BotList
[a
].name
) = lName
then
1104 _name
:= BotList
[num
].name
;
1105 // Çàíÿòî - âûáèðàåì ñëó÷àéíîå:
1106 if not g_Player_ValidName(_name
) then
1108 _name
:= Format('DFBOT%.2d', [Random(100)]);
1109 until g_Player_ValidName(_name
);
1112 _model
:= BotList
[num
].model
;
1113 // Íåò òàêîé - âûáèðàåì ñëó÷àéíóþ:
1114 if not InSArray(_model
, m
) then
1115 _model
:= m
[Random(Length(m
))];
1118 with g_Player_Get(g_Player_Create(_model
, BotList
[num
].color
, Team
, True)) as TBot
do
1122 FDifficult
.DiagFire
:= BotList
[num
].diag_fire
;
1123 FDifficult
.InvisFire
:= BotList
[num
].invis_fire
;
1124 FDifficult
.DiagPrecision
:= BotList
[num
].diag_precision
;
1125 FDifficult
.FlyPrecision
:= BotList
[num
].fly_precision
;
1126 FDifficult
.Cover
:= BotList
[num
].cover
;
1127 FDifficult
.CloseJump
:= BotList
[num
].close_jump
;
1129 for a
:= WP_FIRST
to WP_LAST
do
1131 FDifficult
.WeaponPrior
[a
] := BotList
[num
].w_prior1
[a
];
1132 FDifficult
.CloseWeaponPrior
[a
] := BotList
[num
].w_prior2
[a
];
1133 //FDifficult.SafeWeaponPrior[a] := BotList[num].w_prior3[a];
1136 g_Console_Add(Format(_lc
[I_PLAYER_JOIN
], [Name
]), True);
1138 if g_Game_IsNet
then MH_SEND_PlayerCreate(UID
);
1142 procedure g_Bot_RemoveAll();
1146 if not g_Game_IsServer
then Exit
;
1147 if gPlayers
= nil then Exit
;
1149 for a
:= 0 to High(gPlayers
) do
1150 if gPlayers
[a
] <> nil then
1151 if gPlayers
[a
] is TBot
then
1153 gPlayers
[a
].Lives
:= 0;
1154 gPlayers
[a
].Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
1155 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [gPlayers
[a
].Name
]), True);
1156 g_Player_Remove(gPlayers
[a
].FUID
);
1162 procedure g_Bot_MixNames();
1167 if BotNames
<> nil then
1168 for a
:= 0 to High(BotNames
) do
1170 b
:= Random(Length(BotNames
));
1172 Botnames
[a
] := BotNames
[b
];
1177 procedure g_Player_Remove(UID
: Word);
1181 if gPlayers
= nil then Exit
;
1183 if g_Game_IsServer
and g_Game_IsNet
then
1184 MH_SEND_PlayerDelete(UID
);
1186 for i
:= 0 to High(gPlayers
) do
1187 if gPlayers
[i
] <> nil then
1188 if gPlayers
[i
].FUID
= UID
then
1190 if gPlayers
[i
] is TPlayer
then
1191 TPlayer(gPlayers
[i
]).Free()
1193 TBot(gPlayers
[i
]).Free();
1199 procedure g_Player_Init();
1209 if not FileExists(DataDir
+ BOTNAMES_FILENAME
) then
1212 // ×èòàåì âîçìîæíûå èìåíà áîòîâ èç ôàéëà:
1213 AssignFile(F
, DataDir
+ BOTNAMES_FILENAME
);
1224 SetLength(BotNames
, Length(BotNames
)+1);
1225 BotNames
[High(BotNames
)] := s
;
1233 // ×èòàåì ôàéë ñ ïàðàìåòðàìè áîòîâ:
1234 config
:= TConfig
.CreateFile(DataDir
+ BOTLIST_FILENAME
);
1238 while config
.SectionExists(IntToStr(a
)) do
1240 SetLength(BotList
, Length(BotList
)+1);
1242 with BotList
[High(BotList
)] do
1245 name
:= config
.ReadStr(IntToStr(a
), 'name', '');
1247 model
:= config
.ReadStr(IntToStr(a
), 'model', '');
1249 if config
.ReadStr(IntToStr(a
), 'team', 'red') = 'red' then
1254 sa
:= parse(config
.ReadStr(IntToStr(a
), 'color', ''));
1255 color
.R
:= StrToIntDef(sa
[0], 0);
1256 color
.G
:= StrToIntDef(sa
[1], 0);
1257 color
.B
:= StrToIntDef(sa
[2], 0);
1258 // Âåðîÿòíîñòü ñòðåëüáû ïîä óãëîì:
1259 diag_fire
:= config
.ReadInt(IntToStr(a
), 'diag_fire', 0);
1260 // Âåðîÿòíîñòü îòâåòíîãî îãíÿ ïî íåâèäèìîìó ñîïåðíèêó:
1261 invis_fire
:= config
.ReadInt(IntToStr(a
), 'invis_fire', 0);
1262 // Òî÷íîñòü ñòðåëüáû ïîä óãëîì:
1263 diag_precision
:= config
.ReadInt(IntToStr(a
), 'diag_precision', 0);
1264 // Òî÷íîñòü ñòðåëüáû â ïîëåòå:
1265 fly_precision
:= config
.ReadInt(IntToStr(a
), 'fly_precision', 0);
1266 // Òî÷íîñòü óêëîíåíèÿ îò ñíàðÿäîâ:
1267 cover
:= config
.ReadInt(IntToStr(a
), 'cover', 0);
1268 // Âåðîÿòíîñòü ïðûæêà ïðè ïðèáëèæåíèè ñîïåðíèêà:
1269 close_jump
:= config
.ReadInt(IntToStr(a
), 'close_jump', 0);
1270 // Ïðèîðèòåòû îðóæèÿ äëÿ äàëüíåãî áîÿ:
1271 sa
:= parse(config
.ReadStr(IntToStr(a
), 'w_prior1', ''));
1272 if Length(sa
) = 10 then
1274 w_prior1
[b
] := EnsureRange(StrToInt(sa
[b
]), 0, 9);
1275 // Ïðèîðèòåòû îðóæèÿ äëÿ áëèæíåãî áîÿ:
1276 sa
:= parse(config
.ReadStr(IntToStr(a
), 'w_prior2', ''));
1277 if Length(sa
) = 10 then
1279 w_prior2
[b
] := EnsureRange(StrToInt(sa
[b
]), 0, 9);
1281 {sa := parse(config.ReadStr(IntToStr(a), 'w_prior3', ''));
1282 if Length(sa) = 10 then
1284 w_prior3[b] := EnsureRange(StrToInt(sa[b]), 0, 9);}
1293 procedure g_Player_Free();
1297 if gPlayers
<> nil then
1299 for i
:= 0 to High(gPlayers
) do
1300 if gPlayers
[i
] <> nil then
1302 if gPlayers
[i
] is TPlayer
then
1303 TPlayer(gPlayers
[i
]).Free()
1305 TBot(gPlayers
[i
]).Free();
1316 procedure g_Player_UpdateAll();
1320 if gPlayers
= nil then Exit
;
1322 //e_WriteLog('***g_Player_UpdateAll: ENTER', MSG_WARNING);
1323 for i
:= 0 to High(gPlayers
) do
1325 if gPlayers
[i
] <> nil then
1327 if gPlayers
[i
] is TPlayer
then
1329 gPlayers
[i
].Update();
1330 gPlayers
[i
].RealizeCurrentWeapon(); // WARNING! DO NOT MOVE THIS INTO `Update()`!
1334 // bot updates weapons in `UpdateCombat()`
1335 TBot(gPlayers
[i
]).Update();
1339 //e_WriteLog('***g_Player_UpdateAll: EXIT', MSG_WARNING);
1342 procedure g_Player_DrawAll();
1346 if gPlayers
= nil then Exit
;
1348 for i
:= 0 to High(gPlayers
) do
1349 if gPlayers
[i
] <> nil then
1350 if gPlayers
[i
] is TPlayer
then gPlayers
[i
].Draw()
1351 else TBot(gPlayers
[i
]).Draw();
1354 procedure g_Player_DrawDebug(p
: TPlayer
);
1358 if p
= nil then Exit
;
1359 if (@p
.FObj
) = nil then Exit
;
1361 e_TextureFontGetSize(gStdFont
, fW
, fH
);
1363 e_TextureFontPrint(0, 0 , 'Pos X: ' + IntToStr(p
.FObj
.X
), gStdFont
);
1364 e_TextureFontPrint(0, fH
, 'Pos Y: ' + IntToStr(p
.FObj
.Y
), gStdFont
);
1365 e_TextureFontPrint(0, fH
* 2, 'Vel X: ' + IntToStr(p
.FObj
.Vel
.X
), gStdFont
);
1366 e_TextureFontPrint(0, fH
* 3, 'Vel Y: ' + IntToStr(p
.FObj
.Vel
.Y
), gStdFont
);
1367 e_TextureFontPrint(0, fH
* 4, 'Acc X: ' + IntToStr(p
.FObj
.Accel
.X
), gStdFont
);
1368 e_TextureFontPrint(0, fH
* 5, 'Acc Y: ' + IntToStr(p
.FObj
.Accel
.Y
), gStdFont
);
1371 procedure g_Player_DrawHealth();
1376 if gPlayers
= nil then Exit
;
1377 e_TextureFontGetSize(gStdFont
, fW
, fH
);
1379 for i
:= 0 to High(gPlayers
) do
1380 if gPlayers
[i
] <> nil then
1382 e_TextureFontPrint(gPlayers
[i
].FObj
.X
+ gPlayers
[i
].FObj
.Rect
.X
,
1383 gPlayers
[i
].FObj
.Y
+ gPlayers
[i
].FObj
.Rect
.Y
+ gPlayers
[i
].FObj
.Rect
.Height
- fH
* 2,
1384 IntToStr(gPlayers
[i
].FHealth
), gStdFont
);
1385 e_TextureFontPrint(gPlayers
[i
].FObj
.X
+ gPlayers
[i
].FObj
.Rect
.X
,
1386 gPlayers
[i
].FObj
.Y
+ gPlayers
[i
].FObj
.Rect
.Y
+ gPlayers
[i
].FObj
.Rect
.Height
- fH
,
1387 IntToStr(gPlayers
[i
].FArmor
), gStdFont
);
1391 function g_Player_Get(UID
: Word): TPlayer
;
1397 if gPlayers
= nil then
1400 for a
:= 0 to High(gPlayers
) do
1401 if gPlayers
[a
] <> nil then
1402 if gPlayers
[a
].FUID
= UID
then
1404 Result
:= gPlayers
[a
];
1409 function g_Player_GetCount(): Byte;
1415 if gPlayers
= nil then
1418 for a
:= 0 to High(gPlayers
) do
1419 if gPlayers
[a
] <> nil then
1420 Result
:= Result
+ 1;
1423 function g_Player_GetStats(): TPlayerStatArray
;
1429 if gPlayers
= nil then Exit
;
1431 for a
:= 0 to High(gPlayers
) do
1432 if gPlayers
[a
] <> nil then
1434 SetLength(Result
, Length(Result
)+1);
1435 with Result
[High(Result
)] do
1437 Ping
:= gPlayers
[a
].FPing
;
1438 Loss
:= gPlayers
[a
].FLoss
;
1439 Name
:= gPlayers
[a
].FName
;
1440 Team
:= gPlayers
[a
].FTeam
;
1441 Frags
:= gPlayers
[a
].FFrags
;
1442 Deaths
:= gPlayers
[a
].FDeath
;
1443 Kills
:= gPlayers
[a
].FKills
;
1444 Color
:= gPlayers
[a
].FModel
.Color
;
1445 Lives
:= gPlayers
[a
].FLives
;
1446 Spectator
:= gPlayers
[a
].FSpectator
;
1451 procedure g_Player_RememberAll
;
1455 for i
:= Low(gPlayers
) to High(gPlayers
) do
1456 if (gPlayers
[i
] <> nil) and gPlayers
[i
].alive
then
1457 gPlayers
[i
].RememberState
;
1460 procedure g_Player_ResetAll(Force
, Silent
: Boolean);
1464 gTeamStat
[TEAM_RED
].Goals
:= 0;
1465 gTeamStat
[TEAM_BLUE
].Goals
:= 0;
1467 if gPlayers
<> nil then
1468 for i
:= 0 to High(gPlayers
) do
1469 if gPlayers
[i
] <> nil then
1471 gPlayers
[i
].Reset(Force
);
1473 if gPlayers
[i
] is TPlayer
then
1475 if (not gPlayers
[i
].FSpectator
) or gPlayers
[i
].FWantsInGame
then
1476 gPlayers
[i
].Respawn(Silent
)
1478 gPlayers
[i
].Spectate();
1481 TBot(gPlayers
[i
]).Respawn(Silent
);
1485 procedure g_Player_CreateCorpse(Player
: TPlayer
);
1490 if Player
.alive
then
1492 if Player
.FObj
.Y
>= gMapInfo
.Height
+128 then
1497 if (FHealth
>= -50) or (gGibsCount
= 0) then
1499 if (gCorpses
= nil) or (Length(gCorpses
) = 0) then
1503 for find_id
:= 0 to High(gCorpses
) do
1504 if gCorpses
[find_id
] = nil then
1511 find_id
:= Random(Length(gCorpses
));
1513 gCorpses
[find_id
] := TCorpse
.Create(FObj
.X
, FObj
.Y
, FModel
.Name
, FHealth
< -20);
1514 gCorpses
[find_id
].FColor
:= FModel
.Color
;
1515 gCorpses
[find_id
].FObj
.Vel
:= FObj
.Vel
;
1516 gCorpses
[find_id
].FObj
.Accel
:= FObj
.Accel
;
1519 g_Player_CreateGibs(FObj
.X
+ PLAYER_RECT_CX
,
1520 FObj
.Y
+ PLAYER_RECT_CY
,
1521 FModel
.Name
, FModel
.Color
);
1525 procedure g_Player_CreateShell(fX
, fY
, dX
, dY
: Integer; T
: Byte);
1529 if (gShells
= nil) or (Length(gShells
) = 0) then
1532 with gShells
[CurrentShell
] do
1538 if T
= SHELL_BULLET
then
1540 if g_Texture_Get('TEXTURE_SHELL_BULLET', SID
) then
1544 Obj
.Rect
.Width
:= 4;
1545 Obj
.Rect
.Height
:= 2;
1549 if g_Texture_Get('TEXTURE_SHELL_SHELL', SID
) then
1553 Obj
.Rect
.Width
:= 7;
1554 Obj
.Rect
.Height
:= 3;
1560 g_Obj_Push(@Obj
, dX
+ Random(4)-Random(4), dY
-Random(4));
1561 positionChanged(); // this updates spatial accelerators
1562 RAngle
:= Random(360);
1563 Timeout
:= gTime
+ SHELL_TIMEOUT
;
1565 if CurrentShell
>= High(gShells
) then
1572 procedure g_Player_CreateGibs(fX
, fY
: Integer; ModelName
: string; fColor
: TRGB
);
1575 GibsArray
: TGibsArray
;
1577 if (gGibs
= nil) or (Length(gGibs
) = 0) then
1579 if not g_PlayerModel_GetGibs(ModelName
, GibsArray
) then
1582 for a
:= 0 to High(GibsArray
) do
1583 with gGibs
[CurrentGib
] do
1586 ID
:= GibsArray
[a
].ID
;
1587 MaskID
:= GibsArray
[a
].MaskID
;
1590 Obj
.Rect
:= GibsArray
[a
].Rect
;
1591 Obj
.X
:= fX
-GibsArray
[a
].Rect
.X
-(GibsArray
[a
].Rect
.Width
div 2);
1592 Obj
.Y
:= fY
-GibsArray
[a
].Rect
.Y
-(GibsArray
[a
].Rect
.Height
div 2);
1593 g_Obj_PushA(@Obj
, 25 + Random(10), Random(361));
1594 positionChanged(); // this updates spatial accelerators
1595 RAngle
:= Random(360);
1597 if gBloodCount
> 0 then
1598 g_GFX_Blood(fX
, fY
, 16*gBloodCount
+Random(5*gBloodCount
), -16+Random(33), -16+Random(33),
1599 Random(48), Random(48), 150, 0, 0);
1601 if CurrentGib
>= High(gGibs
) then
1608 procedure g_Player_UpdatePhysicalObjects();
1614 procedure ShellSound_Bounce(X
, Y
: Integer; T
: Byte);
1619 if T
= SHELL_BULLET
then
1620 g_Sound_PlayExAt('SOUND_PLAYER_CASING' + IntToStr(k
), X
, Y
)
1622 g_Sound_PlayExAt('SOUND_PLAYER_SHELL' + IntToStr(k
), X
, Y
);
1627 if gGibs
<> nil then
1628 for i
:= 0 to High(gGibs
) do
1629 if gGibs
[i
].alive
then
1633 mr
:= g_Obj_Move(@Obj
, True, False, True);
1634 positionChanged(); // this updates spatial accelerators
1636 if WordBool(mr
and MOVE_FALLOUT
) then
1642 // Îòëåòàåò îò óäàðà î ñòåíó/ïîòîëîê/ïîë:
1643 if WordBool(mr
and MOVE_HITWALL
) then
1644 Obj
.Vel
.X
:= -(vel
.X
div 2);
1645 if WordBool(mr
and (MOVE_HITCEIL
or MOVE_HITLAND
)) then
1646 Obj
.Vel
.Y
:= -(vel
.Y
div 2);
1648 if (Obj
.Vel
.X
>= 0) then
1650 RAngle
:= RAngle
+ Abs(Obj
.Vel
.X
)*6 + Abs(Obj
.Vel
.Y
);
1651 if RAngle
>= 360 then
1652 RAngle
:= RAngle
mod 360;
1653 end else begin // Counter-clockwise
1654 RAngle
:= RAngle
- Abs(Obj
.Vel
.X
)*6 - Abs(Obj
.Vel
.Y
);
1656 RAngle
:= (360 - (Abs(RAngle
) mod 360)) mod 360;
1659 // Ñîïðîòèâëåíèå âîçäóõà äëÿ êóñêà òðóïà:
1660 if gTime
mod (GAME_TICK
*3) = 0 then
1661 Obj
.Vel
.X
:= z_dec(Obj
.Vel
.X
, 1);
1665 if gCorpses
<> nil then
1666 for i
:= 0 to High(gCorpses
) do
1667 if gCorpses
[i
] <> nil then
1668 if gCorpses
[i
].State
= CORPSE_STATE_REMOVEME
then
1674 gCorpses
[i
].Update();
1677 if gShells
<> nil then
1678 for i
:= 0 to High(gShells
) do
1679 if gShells
[i
].alive
then
1683 mr
:= g_Obj_Move(@Obj
, True, False, True);
1684 positionChanged(); // this updates spatial accelerators
1686 if WordBool(mr
and MOVE_FALLOUT
) or (gShells
[i
].Timeout
< gTime
) then
1692 // Îòëåòàåò îò óäàðà î ñòåíó/ïîòîëîê/ïîë:
1693 if WordBool(mr
and MOVE_HITWALL
) then
1695 Obj
.Vel
.X
:= -(vel
.X
div 2);
1696 if not WordBool(mr
and MOVE_INWATER
) then
1697 ShellSound_Bounce(Obj
.X
, Obj
.Y
, SType
);
1699 if WordBool(mr
and (MOVE_HITCEIL
or MOVE_HITLAND
)) then
1701 Obj
.Vel
.Y
:= -(vel
.Y
div 2);
1702 if Obj
.Vel
.X
<> 0 then Obj
.Vel
.X
:= Obj
.Vel
.X
div 2;
1703 if (Obj
.Vel
.X
= 0) and (Obj
.Vel
.Y
= 0) then
1705 if RAngle
mod 90 <> 0 then
1706 RAngle
:= (RAngle
div 90) * 90;
1708 else if not WordBool(mr
and MOVE_INWATER
) then
1709 ShellSound_Bounce(Obj
.X
, Obj
.Y
, SType
);
1712 if (Obj
.Vel
.X
>= 0) then
1714 RAngle
:= RAngle
+ Abs(Obj
.Vel
.X
)*8 + Abs(Obj
.Vel
.Y
);
1715 if RAngle
>= 360 then
1716 RAngle
:= RAngle
mod 360;
1717 end else begin // Counter-clockwise
1718 RAngle
:= RAngle
- Abs(Obj
.Vel
.X
)*8 - Abs(Obj
.Vel
.Y
);
1720 RAngle
:= (360 - (Abs(RAngle
) mod 360)) mod 360;
1726 procedure TGib
.getMapBox (out x
, y
, w
, h
: Integer); inline;
1728 x
:= Obj
.X
+Obj
.Rect
.X
;
1729 y
:= Obj
.Y
+Obj
.Rect
.Y
;
1730 w
:= Obj
.Rect
.Width
;
1731 h
:= Obj
.Rect
.Height
;
1734 procedure TGib
.moveBy (dx
, dy
: Integer); inline;
1736 if (dx
<> 0) or (dy
<> 0) then
1745 procedure TShell
.getMapBox (out x
, y
, w
, h
: Integer); inline;
1749 w
:= Obj
.Rect
.Width
;
1750 h
:= Obj
.Rect
.Height
;
1753 procedure TShell
.moveBy (dx
, dy
: Integer); inline;
1755 if (dx
<> 0) or (dy
<> 0) then
1764 procedure TGib
.positionChanged (); inline; begin end;
1765 procedure TShell
.positionChanged (); inline; begin end;
1768 procedure g_Player_DrawCorpses();
1773 if gGibs
<> nil then
1774 for i
:= 0 to High(gGibs
) do
1775 if gGibs
[i
].alive
then
1778 if not g_Obj_Collide(sX
, sY
, sWidth
, sHeight
, @Obj
) then
1781 a
.X
:= Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2);
1782 a
.y
:= Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2);
1784 e_DrawAdv(ID
, Obj
.X
, Obj
.Y
, 0, True, False, RAngle
, @a
, M_NONE
);
1787 e_DrawAdv(MaskID
, Obj
.X
, Obj
.Y
, 0, True, False, RAngle
, @a
, M_NONE
);
1793 if gCorpses
<> nil then
1794 for i
:= 0 to High(gCorpses
) do
1795 if gCorpses
[i
] <> nil then
1799 procedure g_Player_DrawShells();
1804 if gShells
<> nil then
1805 for i
:= 0 to High(gShells
) do
1806 if gShells
[i
].alive
then
1809 if not g_Obj_Collide(sX
, sY
, sWidth
, sHeight
, @Obj
) then
1815 e_DrawAdv(SpriteID
, Obj
.X
, Obj
.Y
, 0, True, False, RAngle
, @a
, M_NONE
);
1819 procedure g_Player_RemoveAllCorpses();
1825 SetLength(gGibs
, MaxGibs
);
1826 SetLength(gShells
, MaxGibs
);
1830 if gCorpses
<> nil then
1831 for i
:= 0 to High(gCorpses
) do
1835 SetLength(gCorpses
, MaxCorpses
);
1838 procedure g_Player_Corpses_SaveState(var Mem
: TBinMemoryWriter
);
1843 // Ñ÷èòàåì êîëè÷åñòâî ñóùåñòâóþùèõ òðóïîâ:
1845 if gCorpses
<> nil then
1846 for i
:= 0 to High(gCorpses
) do
1847 if gCorpses
[i
] <> nil then
1850 Mem
:= TBinMemoryWriter
.Create((count
+1) * 128);
1852 // Êîëè÷åñòâî òðóïîâ:
1853 Mem
.WriteInt(count
);
1859 for i
:= 0 to High(gCorpses
) do
1860 if gCorpses
[i
] <> nil then
1863 Mem
.WriteString(gCorpses
[i
].FModelName
);
1865 b
:= gCorpses
[i
].Mess
;
1866 Mem
.WriteBoolean(b
);
1867 // Ñîõðàíÿåì äàííûå òðóïà:
1868 gCorpses
[i
].SaveState(Mem
);
1872 procedure g_Player_Corpses_LoadState(var Mem
: TBinMemoryReader
);
1881 g_Player_RemoveAllCorpses();
1883 // Êîëè÷åñòâî òðóïîâ:
1886 if count
> Length(gCorpses
) then
1888 raise EBinSizeError
.Create('g_Player_Corpses_LoadState: Too Many Corpses');
1895 for i
:= 0 to count
-1 do
1898 Mem
.ReadString(str
);
1902 gCorpses
[i
] := TCorpse
.Create(0, 0, str
, b
);
1903 // Çàãðóæàåì äàííûå òðóïà:
1904 gCorpses
[i
].LoadState(Mem
);
1910 function TPlayer
.isValidViewPort (): Boolean; inline; begin result
:= (viewPortW
> 0) and (viewPortH
> 0); end;
1912 procedure TPlayer
.BFGHit();
1914 g_Weapon_BFGHit(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
1915 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2));
1916 if g_Game_IsServer
and g_Game_IsNet
then
1917 MH_SEND_Effect(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
1918 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2),
1922 procedure TPlayer
.ChangeModel(ModelName
: string);
1924 locModel
: TPlayerModel
;
1926 locModel
:= g_PlayerModel_Get(ModelName
);
1927 if locModel
= nil then Exit
;
1933 procedure TPlayer
.SetModel(ModelName
: string);
1937 m
:= g_PlayerModel_Get(ModelName
);
1940 g_SimpleError(Format(_lc
[I_GAME_ERROR_MODEL_FALLBACK
], [ModelName
]));
1941 m
:= g_PlayerModel_Get('doomer');
1944 g_FatalError(Format(_lc
[I_GAME_ERROR_MODEL
], ['doomer']));
1949 if FModel
<> nil then
1954 if not (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then
1955 FModel
.Color
:= FColor
1957 FModel
.Color
:= TEAMCOLOR
[FTeam
];
1958 FModel
.SetWeapon(FCurrWeap
);
1959 FModel
.SetFlag(FFlag
);
1960 SetDirection(FDirection
);
1963 procedure TPlayer
.SetColor(Color
: TRGB
);
1966 if not (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then
1967 if FModel
<> nil then FModel
.Color
:= Color
;
1970 procedure TPlayer
.SwitchTeam
;
1972 if g_Game_IsClient
then
1974 if not (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then Exit
;
1976 if gGameOn
and FAlive
then
1977 Kill(K_SIMPLEKILL
, FUID
, HIT_SELF
);
1979 if FTeam
= TEAM_RED
then
1981 ChangeTeam(TEAM_BLUE
);
1982 g_Console_Add(Format(_lc
[I_PLAYER_CHTEAM_BLUE
], [FName
]), True);
1983 if g_Game_IsNet
then
1984 MH_SEND_GameEvent(NET_EV_CHANGE_TEAM
, TEAM_BLUE
, FName
);
1988 ChangeTeam(TEAM_RED
);
1989 g_Console_Add(Format(_lc
[I_PLAYER_CHTEAM_RED
], [FName
]), True);
1990 if g_Game_IsNet
then
1991 MH_SEND_GameEvent(NET_EV_CHANGE_TEAM
, TEAM_RED
, FName
);
1993 FPreferredTeam
:= FTeam
;
1996 procedure TPlayer
.ChangeTeam(Team
: Byte);
2003 TEAM_RED
, TEAM_BLUE
:
2004 FModel
.Color
:= TEAMCOLOR
[Team
];
2006 FModel
.Color
:= FColor
;
2008 if (FTeam
<> OldTeam
) and g_Game_IsNet
and g_Game_IsServer
then
2009 MH_SEND_PlayerStats(FUID
);
2013 procedure TPlayer.CollideItem();
2018 if gItems = nil then Exit;
2019 if not FAlive then Exit;
2021 for i := 0 to High(gItems) do
2024 if (ItemType <> ITEM_NONE) and alive then
2025 if g_Obj_Collide(FObj.X+PLAYER_RECT.X, FObj.Y+PLAYER_RECT.Y, PLAYER_RECT.Width,
2026 PLAYER_RECT.Height, @Obj) then
2028 if not PickItem(ItemType, gItems[i].Respawnable, r) then Continue;
2030 if ItemType in [ITEM_SPHERE_BLUE, ITEM_SPHERE_WHITE, ITEM_INVUL] then
2031 g_Sound_PlayExAt('SOUND_ITEM_GETRULEZ', FObj.X, FObj.Y)
2032 else if ItemType in [ITEM_MEDKIT_SMALL, ITEM_MEDKIT_LARGE, ITEM_MEDKIT_BLACK] then
2033 g_Sound_PlayExAt('SOUND_ITEM_GETMED', FObj.X, FObj.Y)
2034 else g_Sound_PlayExAt('SOUND_ITEM_GETITEM', FObj.X, FObj.Y);
2036 // Íàäî óáðàòü ñ êàðòû, åñëè ýòî íå êëþ÷, êîòîðûì íóæíî ïîäåëèòñÿ ñ äðóãèì èãðîêîì:
2037 if r and not ((ItemType in [ITEM_KEY_RED, ITEM_KEY_GREEN, ITEM_KEY_BLUE]) and
2038 (gGameSettings.GameType = GT_SINGLE) and
2039 (g_Player_GetCount() > 1)) then
2040 if not Respawnable then g_Items_Remove(i) else g_Items_Pick(i);
2046 function TPlayer
.CollideLevel(XInc
, YInc
: Integer): Boolean;
2048 Result
:= g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
,
2049 PLAYER_RECT
.Width
, PLAYER_RECT
.Height
, PANEL_WALL
,
2053 constructor TPlayer
.Create();
2064 FSawSound
:= TPlayableSound
.Create();
2065 FSawSoundIdle
:= TPlayableSound
.Create();
2066 FSawSoundHit
:= TPlayableSound
.Create();
2067 FSawSoundSelect
:= TPlayableSound
.Create();
2068 FJetSoundFly
:= TPlayableSound
.Create();
2069 FJetSoundOn
:= TPlayableSound
.Create();
2070 FJetSoundOff
:= TPlayableSound
.Create();
2072 FSawSound
.SetByName('SOUND_WEAPON_FIRESAW');
2073 FSawSoundIdle
.SetByName('SOUND_WEAPON_IDLESAW');
2074 FSawSoundHit
.SetByName('SOUND_WEAPON_HITSAW');
2075 FSawSoundSelect
.SetByName('SOUND_WEAPON_SELECTSAW');
2076 FJetSoundFly
.SetByName('SOUND_PLAYER_JETFLY');
2077 FJetSoundOn
.SetByName('SOUND_PLAYER_JETON');
2078 FJetSoundOff
.SetByName('SOUND_PLAYER_JETOFF');
2080 FSpectatePlayer
:= -1;
2084 FSavedState
.WaitRecall
:= False;
2090 FActualModelName
:= 'doomer';
2093 FObj
.Rect
:= PLAYER_RECT
;
2095 FBFGFireCounter
:= -1;
2096 FJustTeleported
:= False;
2102 procedure TPlayer
.positionChanged (); inline;
2106 procedure TPlayer
.Damage(value
: Word; SpawnerUID
: Word; vx
, vy
: Integer; t
: Byte);
2110 if (not g_Game_IsClient
) and (not FAlive
) then
2115 // Íåóÿçâèìîñòü íå ñïàñàåò îò ëîâóøåê:
2116 if ((t
= HIT_TRAP
) or (t
= HIT_SELF
)) and (not FGodMode
) then
2118 if not g_Game_IsClient
then
2121 if t
= HIT_TRAP
then
2123 // Ëîâóøêà óáèâàåò ñðàçó:
2125 Kill(K_EXTRAHARDKILL
, SpawnerUID
, t
);
2127 if t
= HIT_SELF
then
2131 Kill(K_SIMPLEKILL
, SpawnerUID
, t
);
2134 // Îáíóëèòü äåéñòâèÿ ïðèìî÷åê, ÷òîáû ôîí ïðîïàë
2135 FMegaRulez
[MR_SUIT
] := 0;
2136 FMegaRulez
[MR_INVUL
] := 0;
2137 FMegaRulez
[MR_INVIS
] := 0;
2141 // Íî îò îñòàëüíîãî ñïàñàåò:
2142 if FMegaRulez
[MR_INVUL
] >= gTime
then
2149 // Åñëè åñòü óðîí ñâîèì, èëè ðàíèë ñàì ñåáÿ, èëè òåáÿ ðàíèë ïðîòèâíèê:
2150 if LongBool(gGameSettings
.Options
and GAME_OPTION_TEAMDAMAGE
) or
2151 (SpawnerUID
= FUID
) or
2152 (not SameTeam(FUID
, SpawnerUID
)) then
2154 FLastSpawnerUID
:= SpawnerUID
;
2156 // Êðîâü (ïóçûðüêè, åñëè â âîäå):
2157 if gBloodCount
> 0 then
2159 c
:= Min(value
, 200)*gBloodCount
+ Random(Min(value
, 200) div 2);
2160 if value
div 4 <= c
then
2161 c
:= c
- (value
div 4)
2165 if (t
= HIT_SOME
) and (vx
= 0) and (vy
= 0) then
2169 HIT_TRAP
, HIT_ACID
, HIT_FLAME
, HIT_SELF
: MakeBloodSimple(c
);
2170 HIT_BFG
, HIT_ROCKET
, HIT_SOME
: MakeBloodVector(c
, vx
, vy
);
2173 if t
= HIT_WATER
then
2174 g_GFX_Bubbles(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2),
2175 FObj
.Y
+PLAYER_RECT
.Y
-4, value
div 2, 8, 4);
2180 Inc(FDamageBuffer
, value
);
2184 FPain
:= FPain
+ value
;
2187 if g_Game_IsServer
and g_Game_IsNet
then
2189 MH_SEND_PlayerDamage(FUID
, t
, SpawnerUID
, value
, vx
, vy
);
2190 MH_SEND_PlayerStats(FUID
);
2191 MH_SEND_PlayerPos(False, FUID
);
2195 function TPlayer
.Heal(value
: Word; Soft
: Boolean): Boolean;
2198 if g_Game_IsClient
then
2203 if Soft
and (FHealth
< PLAYER_HP_SOFT
) then
2205 IncMax(FHealth
, value
, PLAYER_HP_SOFT
);
2208 if (not Soft
) and (FHealth
< PLAYER_HP_LIMIT
) then
2210 IncMax(FHealth
, value
, PLAYER_HP_LIMIT
);
2214 if Result
and g_Game_IsServer
and g_Game_IsNet
then
2215 MH_SEND_PlayerStats(FUID
);
2218 destructor TPlayer
.Destroy();
2220 if (gPlayer1
<> nil) and (gPlayer1
.FUID
= FUID
) then
2222 if (gPlayer2
<> nil) and (gPlayer2
.FUID
= FUID
) then
2226 FSawSoundIdle
.Free();
2227 FSawSoundHit
.Free();
2228 FJetSoundFly
.Free();
2230 FJetSoundOff
.Free();
2236 procedure TPlayer
.DrawBubble();
2238 bubX
, bubY
: Integer;
2241 Rw
, Gw
, Bw
: SmallInt;
2244 bubX
:= FObj
.X
+FObj
.Rect
.X
+ IfThen(FDirection
= D_LEFT
, -4, 18);
2245 bubY
:= FObj
.Y
+FObj
.Rect
.Y
- 18;
2253 1: // simple textual non-bubble
2255 bubX
:= FObj
.X
+FObj
.Rect
.X
- 11;
2256 bubY
:= FObj
.Y
+FObj
.Rect
.Y
- 17;
2257 e_TextureFontPrint(bubX
, bubY
, '[...]', gStdFont
);
2260 2: // advanced pixel-perfect bubble
2262 if FTeam
= TEAM_RED
then
2265 if FTeam
= TEAM_BLUE
then
2268 3: // colored bubble
2270 Rb
:= FModel
.Color
.R
;
2271 Gb
:= FModel
.Color
.G
;
2272 Bb
:= FModel
.Color
.B
;
2273 Rw
:= Min(Rb
* 2 + 64, 255);
2274 Gw
:= Min(Gb
* 2 + 64, 255);
2275 Bw
:= Min(Bb
* 2 + 64, 255);
2276 if (Abs(Rw
- Rb
) < 32)
2277 or (Abs(Gw
- Gb
) < 32)
2278 or (Abs(Bw
- Bb
) < 32) then
2280 Rb
:= Max(Rw
div 2 - 16, 0);
2281 Gb
:= Max(Gw
div 2 - 16, 0);
2282 Bb
:= Max(Bw
div 2 - 16, 0);
2285 4: // custom textured bubble
2287 if g_Texture_Get('TEXTURE_PLAYER_TALKBUBBLE', ID
) then
2288 if FDirection
= D_RIGHT
then
2289 e_Draw(ID
, bubX
- 6, bubY
- 7, 0, True, False)
2291 e_Draw(ID
, bubX
- 6, bubY
- 7, 0, True, False, M_HORIZONTAL
);
2297 e_DrawQuad(bubX
+ 1, bubY
, bubX
+ 18, bubY
+ 13, Rb
, Gb
, Bb
);
2298 e_DrawQuad(bubX
, bubY
+ 1, bubX
+ 19, bubY
+ 12, Rb
, Gb
, Bb
);
2300 e_DrawFillQuad(bubX
+ 1, bubY
+ 1, bubX
+ 18, bubY
+ 12, Rw
, Gw
, Bw
, 0);
2303 Dot
:= IfThen(FDirection
= D_LEFT
, 14, 5);
2304 e_DrawLine(1, bubX
+ Dot
, bubY
+ 14, bubX
+ Dot
, bubY
+ 16, Rb
, Gb
, Bb
);
2305 e_DrawLine(1, bubX
+ IfThen(FDirection
= D_LEFT
, Dot
- 1, Dot
+ 1), bubY
+ 13, bubX
+ IfThen(FDirection
= D_LEFT
, Dot
- 1, Dot
+ 1), bubY
+ 15, Rw
, Gw
, Bw
);
2306 e_DrawLine(1, bubX
+ IfThen(FDirection
= D_LEFT
, Dot
- 2, Dot
+ 2), bubY
+ 13, bubX
+ IfThen(FDirection
= D_LEFT
, Dot
- 2, Dot
+ 2), bubY
+ 14, Rw
, Gw
, Bw
);
2307 e_DrawLine(1, bubX
+ IfThen(FDirection
= D_LEFT
, Dot
- 3, Dot
+ 3), bubY
+ 13, bubX
+ IfThen(FDirection
= D_LEFT
, Dot
- 3, Dot
+ 3), bubY
+ 13, Rw
, Gw
, Bw
);
2308 e_DrawLine(1, bubX
+ IfThen(FDirection
= D_LEFT
, Dot
- 3, Dot
+ 3), bubY
+ 14, bubX
+ IfThen(FDirection
= D_LEFT
, Dot
- 1, Dot
+ 1), bubY
+ 16, Rb
, Gb
, Bb
);
2312 e_DrawFillQuad(bubX
+ Dot
, bubY
+ 8, bubX
+ Dot
+ 1, bubY
+ 9, Rb
, Gb
, Bb
, 0);
2313 e_DrawFillQuad(bubX
+ Dot
+ 3, bubY
+ 8, bubX
+ Dot
+ 4, bubY
+ 9, Rb
, Gb
, Bb
, 0);
2314 e_DrawFillQuad(bubX
+ Dot
+ 6, bubY
+ 8, bubX
+ Dot
+ 7, bubY
+ 9, Rb
, Gb
, Bb
, 0);
2317 procedure TPlayer
.Draw();
2325 if (FMegaRulez
[MR_INVUL
] > gTime
) and (gPlayerDrawn
<> Self
) then
2326 if g_Texture_Get('TEXTURE_PLAYER_INVULPENTA', ID
) then
2328 e_GetTextureSize(ID
, @w
, @h
);
2329 if FDirection
= D_LEFT
then
2330 e_Draw(ID
, FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2)-(w
div 2)+4,
2331 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2)-(h
div 2)-7+FObj
.slopeUpLeft
, 0, True, False)
2333 e_Draw(ID
, FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2)-(w
div 2)-2,
2334 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2)-(h
div 2)-7+FObj
.slopeUpLeft
, 0, True, False);
2337 if FMegaRulez
[MR_INVIS
] > gTime
then
2339 if (gPlayerDrawn
<> nil) and ((Self
= gPlayerDrawn
) or
2340 ((FTeam
= gPlayerDrawn
.Team
) and (gGameSettings
.GameMode
<> GM_DM
))) then
2342 if (FMegaRulez
[MR_INVIS
] - gTime
) <= 2100 then
2343 dr
:= not Odd((FMegaRulez
[MR_INVIS
] - gTime
) div 300)
2347 FModel
.Draw(FObj
.X
, FObj
.Y
+FObj
.slopeUpLeft
, 200)
2349 FModel
.Draw(FObj
.X
, FObj
.Y
+FObj
.slopeUpLeft
);
2352 FModel
.Draw(FObj
.X
, FObj
.Y
+FObj
.slopeUpLeft
, 254);
2355 FModel
.Draw(FObj
.X
, FObj
.Y
+FObj
.slopeUpLeft
);
2358 if g_debug_Frames
then
2360 e_DrawQuad(FObj
.X
+FObj
.Rect
.X
,
2362 FObj
.X
+FObj
.Rect
.X
+FObj
.Rect
.Width
-1,
2363 FObj
.Y
+FObj
.Rect
.Y
+FObj
.Rect
.Height
-1,
2367 if (gChatBubble
> 0) and (FKeys
[KEY_CHAT
].Pressed
) and not FGhost
then
2369 // e_DrawPoint(5, 335, 288, 255, 0, 0); // DL, UR, DL, UR
2370 if gAimLine
and alive
and
2371 ((Self
= gPlayer1
) or (Self
= gPlayer2
)) then
2376 procedure TPlayer
.DrawAim();
2377 procedure drawCast (sz
: Integer; ax0
, ay0
, ax1
, ay1
: Integer);
2381 if isValidViewPort
and (self
= gPlayer1
) then
2383 g_Holmes_plrLaser(ax0
, ay0
, ax1
, ay1
);
2386 e_DrawLine(sz
, ax0
, ay0
, ax1
, ay1
, 255, 0, 0, 96);
2387 if (g_Map_traceToNearestWall(ax0
, ay0
, ax1
, ay1
, @ex
, @ey
) <> nil) then
2389 e_DrawLine(sz
, ax0
, ay0
, ex
, ey
, 0, 255, 0, 96);
2393 e_DrawLine(sz
, ax0
, ay0
, ex
, ey
, 0, 0, 255, 96);
2398 wx
, wy
, xx
, yy
: Integer;
2402 wx
:= FObj
.X
+ WEAPONPOINT
[FDirection
].X
+ IfThen(FDirection
= D_LEFT
, 7, -7);
2403 wy
:= FObj
.Y
+ WEAPONPOINT
[FDirection
].Y
;
2412 1: begin // Chainsaw
2419 if angle
= ANGLE_RIGHTUP
then Dec(angle
, 2);
2420 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 4);
2421 if angle
= ANGLE_LEFTUP
then Inc(angle
, 2);
2422 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 4);
2427 if angle
= ANGLE_RIGHTUP
then Dec(angle
, 2);
2428 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 4);
2429 if angle
= ANGLE_LEFTUP
then Inc(angle
, 2);
2430 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 4);
2432 4: begin // Double Shotgun
2435 if angle
= ANGLE_RIGHTUP
then Dec(angle
, 2);
2436 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 4);
2437 if angle
= ANGLE_LEFTUP
then Inc(angle
, 2);
2438 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 4);
2440 5: begin // Chaingun
2443 if angle
= ANGLE_RIGHTUP
then Dec(angle
, 2);
2444 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 4);
2445 if angle
= ANGLE_LEFTUP
then Inc(angle
, 2);
2446 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 4);
2448 6: begin // Rocket Launcher
2451 if angle
= ANGLE_RIGHTUP
then Inc(angle
, 2);
2452 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 4);
2453 if angle
= ANGLE_LEFTUP
then Dec(angle
, 2);
2454 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 4);
2456 7: begin // Plasmagun
2459 if angle
= ANGLE_RIGHTUP
then Inc(angle
);
2460 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 3);
2461 if angle
= ANGLE_LEFTUP
then Dec(angle
);
2462 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 3);
2467 if angle
= ANGLE_RIGHTUP
then Inc(angle
, 1);
2468 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 2);
2469 if angle
= ANGLE_LEFTUP
then Dec(angle
, 1);
2470 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 2);
2472 9: begin // Super Chaingun
2475 if angle
= ANGLE_RIGHTUP
then Dec(angle
, 2);
2476 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 4);
2477 if angle
= ANGLE_LEFTUP
then Inc(angle
, 2);
2478 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 4);
2481 xx
:= Trunc(Cos(-DegToRad(angle
)) * len
) + wx
;
2482 yy
:= Trunc(Sin(-DegToRad(angle
)) * len
) + wy
;
2483 {$IF DEFINED(D2F_DEBUG)}
2484 drawCast(sz
, wx
, wy
, xx
, yy
);
2486 e_DrawLine(sz
, wx
, wy
, xx
, yy
, 255, 0, 0, 96);
2490 procedure TPlayer
.DrawGUI();
2493 X
, Y
, SY
, a
, p
, m
: Integer;
2497 stat
: TPlayerStatArray
;
2499 X
:= gPlayerScreenSize
.X
;
2500 SY
:= gPlayerScreenSize
.Y
;
2503 if gShowGoals
and (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then
2505 if gGameSettings
.GameMode
= GM_CTF
then
2509 if gGameSettings
.GameMode
= GM_CTF
then
2511 s
:= 'TEXTURE_PLAYER_REDFLAG';
2512 if gFlags
[FLAG_RED
].State
= FLAG_STATE_CAPTURED
then
2513 s
:= 'TEXTURE_PLAYER_REDFLAG_S';
2514 if gFlags
[FLAG_RED
].State
= FLAG_STATE_DROPPED
then
2515 s
:= 'TEXTURE_PLAYER_REDFLAG_D';
2516 if g_Texture_Get(s
, ID
) then
2517 e_Draw(ID
, X
-16-32, 240-72-4, 0, True, False);
2520 s
:= IntToStr(gTeamStat
[TEAM_RED
].Goals
);
2521 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2522 e_CharFont_PrintEx(gMenuFont
, X
-16-a
-tw
, 240-72-4, s
, TEAMCOLOR
[TEAM_RED
]);
2524 if gGameSettings
.GameMode
= GM_CTF
then
2526 s
:= 'TEXTURE_PLAYER_BLUEFLAG';
2527 if gFlags
[FLAG_BLUE
].State
= FLAG_STATE_CAPTURED
then
2528 s
:= 'TEXTURE_PLAYER_BLUEFLAG_S';
2529 if gFlags
[FLAG_BLUE
].State
= FLAG_STATE_DROPPED
then
2530 s
:= 'TEXTURE_PLAYER_BLUEFLAG_D';
2531 if g_Texture_Get(s
, ID
) then
2532 e_Draw(ID
, X
-16-32, 240-32-4, 0, True, False);
2535 s
:= IntToStr(gTeamStat
[TEAM_BLUE
].Goals
);
2536 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2537 e_CharFont_PrintEx(gMenuFont
, X
-16-a
-tw
, 240-32-4, s
, TEAMCOLOR
[TEAM_BLUE
]);
2540 if g_Texture_Get('TEXTURE_PLAYER_HUDBG', ID
) then
2541 e_DrawFill(ID
, X
, 0, 1, (gPlayerScreenSize
.Y
div 256)+IfThen(gPlayerScreenSize
.Y
mod 256 > 0, 1, 0),
2544 if g_Texture_Get('TEXTURE_PLAYER_HUD', ID
) then
2545 e_Draw(ID
, X
+2, Y
, 0, True, False);
2547 if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
2551 s
:= IntToStr(Frags
);
2552 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2553 e_CharFont_PrintEx(gMenuFont
, X
-16-tw
, Y
, s
, _RGB(255, 0, 0));
2558 stat
:= g_Player_GetStats();
2563 for a
:= 0 to High(stat
) do
2564 if stat
[a
].Name
<> Name
then
2566 if stat
[a
].Frags
> m
then m
:= stat
[a
].Frags
;
2567 if stat
[a
].Frags
> Frags
then p
:= p
+1;
2571 s
:= IntToStr(p
)+' / '+IntToStr(Length(stat
))+' ';
2572 if Frags
>= m
then s
:= s
+'+' else s
:= s
+'-';
2573 s
:= s
+IntToStr(Abs(Frags
-m
));
2575 e_CharFont_GetSize(gMenuSmallFont
, s
, tw
, th
);
2576 e_CharFont_PrintEx(gMenuSmallFont
, X
-16-tw
, Y
+32, s
, _RGB(255, 0, 0));
2579 if gShowLives
and (gGameSettings
.MaxLives
> 0) then
2581 s
:= IntToStr(Lives
);
2582 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2583 e_CharFont_PrintEx(gMenuFont
, X
-16-tw
, SY
-32, s
, _RGB(0, 255, 0));
2587 e_CharFont_GetSize(gMenuSmallFont
, FName
, tw
, th
);
2588 e_CharFont_PrintEx(gMenuSmallFont
, X
+98-(tw
div 2), Y
+8, FName
, _RGB(255, 0, 0));
2590 if R_BERSERK
in FRulez
then
2591 e_Draw(gItemsTexturesID
[ITEM_MEDKIT_BLACK
], X
+37, Y
+45, 0, True, False)
2593 e_Draw(gItemsTexturesID
[ITEM_MEDKIT_LARGE
], X
+37, Y
+45, 0, True, False);
2595 if g_Texture_Get('TEXTURE_PLAYER_ARMORHUD', ID
) then
2596 e_Draw(ID
, X
+36, Y
+77, 0, True, False);
2598 s
:= IntToStr(IfThen(FHealth
> 0, FHealth
, 0));
2599 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2600 e_CharFont_PrintEx(gMenuFont
, X
+178-tw
, Y
+40, s
, _RGB(255, 0, 0));
2602 s
:= IntToStr(FArmor
);
2603 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2604 e_CharFont_PrintEx(gMenuFont
, X
+178-tw
, Y
+68, s
, _RGB(255, 0, 0));
2606 s
:= IntToStr(GetAmmoByWeapon(FCurrWeap
));
2612 ID
:= gItemsTexturesID
[ITEM_WEAPON_KASTET
];
2617 ID
:= gItemsTexturesID
[ITEM_WEAPON_SAW
];
2619 WEAPON_PISTOL
: ID
:= gItemsTexturesID
[ITEM_WEAPON_PISTOL
];
2620 WEAPON_CHAINGUN
: ID
:= gItemsTexturesID
[ITEM_WEAPON_CHAINGUN
];
2621 WEAPON_SHOTGUN1
: ID
:= gItemsTexturesID
[ITEM_WEAPON_SHOTGUN1
];
2622 WEAPON_SHOTGUN2
: ID
:= gItemsTexturesID
[ITEM_WEAPON_SHOTGUN2
];
2623 WEAPON_SUPERPULEMET
: ID
:= gItemsTexturesID
[ITEM_WEAPON_SUPERPULEMET
];
2624 WEAPON_ROCKETLAUNCHER
: ID
:= gItemsTexturesID
[ITEM_WEAPON_ROCKETLAUNCHER
];
2625 WEAPON_PLASMA
: ID
:= gItemsTexturesID
[ITEM_WEAPON_PLASMA
];
2626 WEAPON_BFG
: ID
:= gItemsTexturesID
[ITEM_WEAPON_BFG
];
2627 WEAPON_FLAMETHROWER
: ID
:= gItemsTexturesID
[ITEM_WEAPON_FLAMETHROWER
];
2630 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2631 e_CharFont_PrintEx(gMenuFont
, X
+178-tw
, Y
+158, s
, _RGB(255, 0, 0));
2632 e_Draw(ID
, X
+20, Y
+160, 0, True, False);
2634 if R_KEY_RED
in FRulez
then
2635 e_Draw(gItemsTexturesID
[ITEM_KEY_RED
], X
+78, Y
+214, 0, True, False);
2637 if R_KEY_GREEN
in FRulez
then
2638 e_Draw(gItemsTexturesID
[ITEM_KEY_GREEN
], X
+95, Y
+214, 0, True, False);
2640 if R_KEY_BLUE
in FRulez
then
2641 e_Draw(gItemsTexturesID
[ITEM_KEY_BLUE
], X
+112, Y
+214, 0, True, False);
2643 if FJetFuel
> 0 then
2645 if g_Texture_Get('TEXTURE_PLAYER_HUDAIR', ID
) then
2646 e_Draw(ID
, X
+2, Y
+116, 0, True, False);
2647 if g_Texture_Get('TEXTURE_PLAYER_HUDJET', ID
) then
2648 e_Draw(ID
, X
+2, Y
+126, 0, True, False);
2649 e_DrawLine(4, X
+16, Y
+122, X
+16+Trunc(168*IfThen(FAir
> 0, FAir
, 0)/AIR_MAX
), Y
+122, 0, 0, 196);
2650 e_DrawLine(4, X
+16, Y
+132, X
+16+Trunc(168*FJetFuel
/JET_MAX
), Y
+132, 208, 0, 0);
2654 if g_Texture_Get('TEXTURE_PLAYER_HUDAIR', ID
) then
2655 e_Draw(ID
, X
+2, Y
+124, 0, True, False);
2656 e_DrawLine(4, X
+16, Y
+130, X
+16+Trunc(168*IfThen(FAir
> 0, FAir
, 0)/AIR_MAX
), Y
+130, 0, 0, 196);
2659 if gShowPing
and g_Game_IsClient
then
2661 s
:= _lc
[I_GAME_PING_HUD
] + IntToStr(NetPeer
.lastRoundTripTime
) + _lc
[I_NET_SLIST_PING_MS
];
2662 e_TextureFontPrint(X
+ 4, Y
+ 242, s
, gStdFont
);
2668 e_TextureFontPrint(X
+ 4, Y
+ 242, _lc
[I_PLAYER_SPECT
], gStdFont
);
2669 e_TextureFontPrint(X
+ 4, Y
+ 258, _lc
[I_PLAYER_SPECT2
], gStdFont
);
2670 e_TextureFontPrint(X
+ 4, Y
+ 274, _lc
[I_PLAYER_SPECT1
], gStdFont
);
2673 e_TextureFontGetSize(gStdFont
, cw
, ch
);
2674 s
:= _lc
[I_PLAYER_SPECT4
];
2675 e_TextureFontPrintEx(gScreenWidth
div 2 - cw
*(Length(s
) div 2),
2676 gScreenHeight
-4-ch
, s
, gStdFont
, 255, 255, 255, 1, True);
2677 e_TextureFontPrint(X
+ 4, Y
+ 290, _lc
[I_PLAYER_SPECT1S
], gStdFont
);
2683 procedure TPlayer
.DrawRulez();
2687 // Ïðè âçÿòèè íåóÿçâèìîñòè ðèñóåòñÿ èíâåðñèîííûé áåëûé ôîí
2688 if FMegaRulez
[MR_INVUL
] >= gTime
then
2690 if (FMegaRulez
[MR_INVUL
]-gTime
) <= 2100 then
2691 dr
:= not Odd((FMegaRulez
[MR_INVUL
]-gTime
) div 300)
2696 e_DrawFillQuad(0, 0, gPlayerScreenSize
.X
-1, gPlayerScreenSize
.Y
-1,
2697 191, 191, 191, 0, B_INVERT
);
2700 // Ïðè âçÿòèè çàùèòíîãî êîñòþìà ðèñóåòñÿ çåëåíîâàòûé ôîí
2701 if FMegaRulez
[MR_SUIT
] >= gTime
then
2703 if (FMegaRulez
[MR_SUIT
]-gTime
) <= 2100 then
2704 dr
:= not Odd((FMegaRulez
[MR_SUIT
]-gTime
) div 300)
2709 e_DrawFillQuad(0, 0, gPlayerScreenSize
.X
-1, gPlayerScreenSize
.Y
-1,
2710 0, 96, 0, 200, B_NONE
);
2713 // Ïðè âçÿòèè áåðñåðêà ðèñóåòñÿ êðàñíîâàòûé ôîí
2714 if (FBerserk
>= 0) and (LongWord(FBerserk
) >= gTime
) and (gFlash
= 2) then
2716 e_DrawFillQuad(0, 0, gPlayerScreenSize
.X
-1, gPlayerScreenSize
.Y
-1,
2717 255, 0, 0, 200, B_NONE
);
2721 procedure TPlayer
.DrawPain();
2725 if FPain
= 0 then Exit
;
2729 if a
< 15 then h
:= 0
2730 else if a
< 35 then h
:= 1
2731 else if a
< 55 then h
:= 2
2732 else if a
< 75 then h
:= 3
2733 else if a
< 95 then h
:= 4
2736 //if a > 255 then a := 255;
2738 e_DrawFillQuad(0, 0, gPlayerScreenSize
.X
-1, gPlayerScreenSize
.Y
-1, 255, 0, 0, 255-h
*50);
2739 //e_DrawFillQuad(0, 0, gPlayerScreenSize.X-1, gPlayerScreenSize.Y-1, 255-min(128, a), 255-a, 255-a, 0, B_FILTER);
2742 procedure TPlayer
.DrawPickup();
2746 if FPickup
= 0 then Exit
;
2750 if a
< 15 then h
:= 1
2751 else if a
< 35 then h
:= 2
2752 else if a
< 55 then h
:= 3
2753 else if a
< 75 then h
:= 4
2756 e_DrawFillQuad(0, 0, gPlayerScreenSize
.X
-1, gPlayerScreenSize
.Y
-1, 150, 200, 150, 255-h
*50);
2759 procedure TPlayer
.Fire();
2761 f
, DidFire
: Boolean;
2762 wx
, wy
, xd
, yd
: Integer;
2765 if g_Game_IsClient
then Exit
;
2766 // FBFGFireCounter - âðåìÿ ïåðåä âûñòðåëîì (äëÿ BFG)
2767 // FReloading - âðåìÿ ïîñëå âûñòðåëà (äëÿ âñåãî)
2775 if FReloading
[FCurrWeap
] <> 0 then Exit
;
2780 wx
:= FObj
.X
+WEAPONPOINT
[FDirection
].X
;
2781 wy
:= FObj
.Y
+WEAPONPOINT
[FDirection
].Y
;
2782 xd
:= wx
+IfThen(FDirection
= D_LEFT
, -30, 30);
2783 yd
:= wy
+firediry();
2788 if R_BERSERK
in FRulez
then
2790 //g_Weapon_punch(FObj.X+FObj.Rect.X, FObj.Y+FObj.Rect.Y, 75, FUID);
2791 locobj
.X
:= FObj
.X
+FObj
.Rect
.X
;
2792 locobj
.Y
:= FObj
.Y
+FObj
.Rect
.Y
;
2795 locobj
.rect
.Width
:= 39;
2796 locobj
.rect
.Height
:= 52;
2797 locobj
.Vel
.X
:= (xd
-wx
) div 2;
2798 locobj
.Vel
.Y
:= (yd
-wy
) div 2;
2799 locobj
.Accel
.X
:= xd
-wx
;
2800 locobj
.Accel
.y
:= yd
-wy
;
2802 if g_Weapon_Hit(@locobj
, 50, FUID
, HIT_SOME
) <> 0 then
2803 g_Sound_PlayExAt('SOUND_WEAPON_HITBERSERK', FObj
.X
, FObj
.Y
)
2805 g_Sound_PlayExAt('SOUND_WEAPON_MISSBERSERK', FObj
.X
, FObj
.Y
);
2809 FPain
:= min(FPain
+ 25, 50);
2810 end else g_Weapon_punch(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
, 3, FUID
);
2813 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
2818 if g_Weapon_chainsaw(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
,
2819 IfThen(gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
], 9, 3), FUID
) <> 0 then
2821 FSawSoundSelect
.Stop();
2823 FSawSoundHit
.PlayAt(FObj
.X
, FObj
.Y
);
2825 else if not FSawSoundHit
.IsPlaying() then
2827 FSawSoundSelect
.Stop();
2828 FSawSound
.PlayAt(FObj
.X
, FObj
.Y
);
2831 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
2837 if FAmmo
[A_BULLETS
] > 0 then
2839 g_Weapon_pistol(wx
, wy
, xd
, yd
, FUID
);
2840 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
2841 Dec(FAmmo
[A_BULLETS
]);
2842 FFireAngle
:= FAngle
;
2845 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
2846 GameVelX
, GameVelY
-2, SHELL_BULLET
);
2850 if FAmmo
[A_SHELLS
] > 0 then
2852 g_Weapon_shotgun(wx
, wy
, xd
, yd
, FUID
);
2853 if not gSoundEffectsDF
then g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN', wx
, wy
);
2854 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
2855 Dec(FAmmo
[A_SHELLS
]);
2856 FFireAngle
:= FAngle
;
2860 FShellType
:= SHELL_SHELL
;
2864 if FAmmo
[A_SHELLS
] >= 2 then
2866 g_Weapon_dshotgun(wx
, wy
, xd
, yd
, FUID
);
2867 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
2868 Dec(FAmmo
[A_SHELLS
], 2);
2869 FFireAngle
:= FAngle
;
2873 FShellType
:= SHELL_DBLSHELL
;
2877 if FAmmo
[A_BULLETS
] > 0 then
2879 g_Weapon_mgun(wx
, wy
, xd
, yd
, FUID
);
2880 if not gSoundEffectsDF
then g_Sound_PlayExAt('SOUND_WEAPON_FIREPISTOL', wx
, wy
);
2881 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
2882 Dec(FAmmo
[A_BULLETS
]);
2883 FFireAngle
:= FAngle
;
2886 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
2887 GameVelX
, GameVelY
-2, SHELL_BULLET
);
2890 WEAPON_ROCKETLAUNCHER
:
2891 if FAmmo
[A_ROCKETS
] > 0 then
2893 g_Weapon_rocket(wx
, wy
, xd
, yd
, FUID
);
2894 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
2895 Dec(FAmmo
[A_ROCKETS
]);
2896 FFireAngle
:= FAngle
;
2902 if FAmmo
[A_CELLS
] > 0 then
2904 g_Weapon_plasma(wx
, wy
, xd
, yd
, FUID
);
2905 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
2906 Dec(FAmmo
[A_CELLS
]);
2907 FFireAngle
:= FAngle
;
2913 if (FAmmo
[A_CELLS
] >= 40) and (FBFGFireCounter
= -1) then
2915 FBFGFireCounter
:= 17;
2916 if not FNoReload
then
2917 g_Sound_PlayExAt('SOUND_WEAPON_STARTFIREBFG', FObj
.X
, FObj
.Y
);
2918 Dec(FAmmo
[A_CELLS
], 40);
2922 WEAPON_SUPERPULEMET
:
2923 if FAmmo
[A_SHELLS
] > 0 then
2925 g_Weapon_shotgun(wx
, wy
, xd
, yd
, FUID
);
2926 if not gSoundEffectsDF
then g_Sound_PlayExAt('SOUND_WEAPON_FIRECGUN', wx
, wy
);
2927 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
2928 Dec(FAmmo
[A_SHELLS
]);
2929 FFireAngle
:= FAngle
;
2932 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
2933 GameVelX
, GameVelY
-2, SHELL_SHELL
);
2936 WEAPON_FLAMETHROWER
:
2937 if FAmmo
[A_FUEL
] > 0 then
2939 g_Weapon_flame(wx
, wy
, xd
, yd
, FUID
);
2940 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
2942 FFireAngle
:= FAngle
;
2948 if g_Game_IsNet
then
2952 if FCurrWeap
<> WEAPON_BFG
then
2953 MH_SEND_PlayerFire(FUID
, FCurrWeap
, wx
, wy
, xd
, yd
, LastShotID
)
2955 if not FNoReload
then
2956 MH_SEND_Sound(FObj
.X
, FObj
.Y
, 'SOUND_WEAPON_STARTFIREBFG');
2959 MH_SEND_PlayerStats(FUID
);
2964 if (FAngle
= 0) or (FAngle
= 180) then SetAction(A_ATTACK
)
2965 else if (FAngle
= ANGLE_LEFTDOWN
) or (FAngle
= ANGLE_RIGHTDOWN
) then SetAction(A_ATTACKDOWN
)
2966 else if (FAngle
= ANGLE_LEFTUP
) or (FAngle
= ANGLE_RIGHTUP
) then SetAction(A_ATTACKUP
);
2969 function TPlayer
.GetAmmoByWeapon(Weapon
: Byte): Word;
2972 WEAPON_PISTOL
, WEAPON_CHAINGUN
: Result
:= FAmmo
[A_BULLETS
];
2973 WEAPON_SHOTGUN1
, WEAPON_SHOTGUN2
, WEAPON_SUPERPULEMET
: Result
:= FAmmo
[A_SHELLS
];
2974 WEAPON_ROCKETLAUNCHER
: Result
:= FAmmo
[A_ROCKETS
];
2975 WEAPON_PLASMA
, WEAPON_BFG
: Result
:= FAmmo
[A_CELLS
];
2976 WEAPON_FLAMETHROWER
: Result
:= FAmmo
[A_FUEL
];
2981 function TPlayer
.HeadInLiquid(XInc
, YInc
: Integer): Boolean;
2983 Result
:= g_Map_CollidePanel(FObj
.X
+PLAYER_HEADRECT
.X
+XInc
, FObj
.Y
+PLAYER_HEADRECT
.Y
+YInc
,
2984 PLAYER_HEADRECT
.Width
, PLAYER_HEADRECT
.Height
,
2985 PANEL_WATER
or PANEL_ACID1
or PANEL_ACID2
, True);
2988 procedure TPlayer
.JetpackOn
;
2992 FJetSoundOn
.SetPosition(0);
2993 FJetSoundOn
.PlayAt(FObj
.X
, FObj
.Y
);
2997 procedure TPlayer
.JetpackOff
;
3001 FJetSoundOff
.SetPosition(0);
3002 FJetSoundOff
.PlayAt(FObj
.X
, FObj
.Y
);
3005 procedure TPlayer
.CatchFire(Attacker
: Word);
3008 FFireAttacker
:= Attacker
;
3009 if g_Game_IsNet
and g_Game_IsServer
then
3010 MH_SEND_PlayerStats(FUID
);
3013 procedure TPlayer
.Jump();
3015 if gFly
or FJetpack
then
3017 // Ïîëåò (÷èò-êîä èëè äæåòïàê):
3018 if FObj
.Vel
.Y
> -VEL_FLY
then
3019 FObj
.Vel
.Y
:= FObj
.Vel
.Y
- 3;
3022 if FJetFuel
> 0 then
3024 if (FJetFuel
< 1) and g_Game_IsServer
then
3028 if g_Game_IsNet
then
3029 MH_SEND_PlayerStats(FUID
);
3035 // Íå âêëþ÷àòü äæåòïàê â ðåæèìå ïðîõîæäåíèÿ ñêâîçü ñòåíû
3037 FCanJetpack
:= False;
3039 // Ïðûãàåì èëè âñïëûâàåì:
3040 if (CollideLevel(0, 1) or
3041 g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+PLAYER_RECT
.Y
+36, PLAYER_RECT
.Width
,
3042 PLAYER_RECT
.Height
-33, PANEL_STEP
, False)
3043 ) and (FObj
.Accel
.Y
= 0) then // Íå ïðûãàòü, åñëè åñòü âåðòèêàëüíîå óñêîðåíèå
3045 FObj
.Vel
.Y
:= -VEL_JUMP
;
3046 FCanJetpack
:= False;
3050 if BodyInLiquid(0, 0) then
3051 FObj
.Vel
.Y
:= -VEL_SW
3052 else if (FJetFuel
> 0) and FCanJetpack
and
3053 g_Game_IsServer
and (not g_Obj_CollideLiquid(@FObj
, 0, 0)) then
3057 if g_Game_IsNet
then
3058 MH_SEND_PlayerStats(FUID
);
3063 procedure TPlayer
.Kill(KillType
: Byte; SpawnerUID
: Word; t
: Byte);
3065 a
, i
, k
, ab
, ar
: Byte;
3069 srv
, netsrv
: Boolean;
3075 procedure PushItem(t
: Byte);
3079 id
:= g_Items_Create(FObj
.X
, FObj
.Y
, t
, True, False);
3080 it
:= g_Items_ByIdx(id
);
3081 if KillType
= K_EXTRAHARDKILL
then // -7..+7; -8..0
3083 g_Obj_Push(@it
.Obj
, (FObj
.Vel
.X
div 2)-7+Random(15),
3084 (FObj
.Vel
.Y
div 2)-Random(9));
3085 it
.positionChanged(); // this updates spatial accelerators
3089 if KillType
= K_HARDKILL
then // -5..+5; -5..0
3091 g_Obj_Push(@it
.Obj
, (FObj
.Vel
.X
div 2)-5+Random(11),
3092 (FObj
.Vel
.Y
div 2)-Random(6));
3094 else // -3..+3; -3..0
3096 g_Obj_Push(@it
.Obj
, (FObj
.Vel
.X
div 2)-3+Random(7),
3097 (FObj
.Vel
.Y
div 2)-Random(4));
3099 it
.positionChanged(); // this updates spatial accelerators
3102 if g_Game_IsNet
and g_Game_IsServer
then
3103 MH_SEND_ItemSpawn(True, id
);
3107 DoFrags
:= (gGameSettings
.MaxLives
= 0) or (gGameSettings
.GameMode
= GM_COOP
);
3108 Srv
:= g_Game_IsServer
;
3109 Netsrv
:= g_Game_IsServer
and g_Game_IsNet
;
3110 if Srv
then FDeath
:= FDeath
+ 1;
3115 if not FPhysics
then
3121 if (gGameSettings
.MaxLives
> 0) and Srv
and (gLMSRespawn
= LMS_RESPAWN_NONE
) then
3123 if FLives
> 0 then FLives
:= FLives
- 1;
3124 if FLives
= 0 then FNoRespawn
:= True;
3127 // Íîìåð òèïà ñìåðòè:
3130 K_SIMPLEKILL
: a
:= 1;
3132 K_EXTRAHARDKILL
: a
:= 3;
3137 if not FModel
.PlaySound(MODELSOUND_DIE
, a
, FObj
.X
, FObj
.Y
) then
3139 if FModel
.PlaySound(MODELSOUND_DIE
, i
, FObj
.X
, FObj
.Y
) then
3146 FTime
[T_RESPAWN
] := gTime
+ TIME_RESPAWN1
;
3148 FTime
[T_RESPAWN
] := gTime
+ TIME_RESPAWN2
;
3149 K_EXTRAHARDKILL
, K_FALLKILL
:
3150 FTime
[T_RESPAWN
] := gTime
+ TIME_RESPAWN3
;
3153 // Ïåðåêëþ÷àåì ñîñòîÿíèå:
3157 K_HARDKILL
, K_EXTRAHARDKILL
:
3161 // Ðåàêöèÿ ìîíñòðîâ íà ñìåðòü èãðîêà:
3162 if (KillType
<> K_FALLKILL
) and (Srv
) then
3163 g_Monsters_killedp();
3165 if SpawnerUID
= FUID
then
3167 if Srv
and (DoFrags
or (gGameSettings
.GameMode
= GM_TDM
)) then
3172 g_Console_Add(Format(_lc
[I_PLAYER_KILL_SELF
], [FName
]), True);
3175 if g_GetUIDType(SpawnerUID
) = UID_PLAYER
then
3176 begin // Óáèò äðóãèì èãðîêîì
3177 KP
:= g_Player_Get(SpawnerUID
);
3178 if (KP
<> nil) and Srv
then
3180 if (DoFrags
or (gGameSettings
.GameMode
= GM_TDM
)) then
3181 if SameTeam(FUID
, SpawnerUID
) then
3191 if (gGameSettings
.GameMode
= GM_TDM
) and DoFrags
then
3192 Inc(gTeamStat
[KP
.Team
].Goals
,
3193 IfThen(SameTeam(FUID
, SpawnerUID
), -1, 1));
3195 if netsrv
then MH_SEND_PlayerStats(SpawnerUID
);
3198 plr
:= g_Player_Get(SpawnerUID
);
3206 g_Console_Add(Format(_lc
[I_PLAYER_KILL_EXTRAHARD_2
],
3210 g_Console_Add(Format(_lc
[I_PLAYER_KILL_EXTRAHARD_1
],
3214 g_Console_Add(Format(_lc
[I_PLAYER_KILL
],
3219 else if g_GetUIDType(SpawnerUID
) = UID_MONSTER
then
3220 begin // Óáèò ìîíñòðîì
3221 mon
:= g_Monsters_ByUID(SpawnerUID
);
3225 s
:= g_Mons_GetKilledByTypeId(mon
.MonsterType
);
3229 g_Console_Add(Format(_lc
[I_PLAYER_KILL_EXTRAHARD_2
],
3233 g_Console_Add(Format(_lc
[I_PLAYER_KILL_EXTRAHARD_1
],
3237 g_Console_Add(Format(_lc
[I_PLAYER_KILL
],
3242 else // Îñîáûå òèïû ñìåðòè
3245 HIT_SELF
: g_Console_Add(Format(_lc
[I_PLAYER_KILL_SELF
], [FName
]), True);
3246 HIT_FALL
: g_Console_Add(Format(_lc
[I_PLAYER_KILL_FALL
], [FName
]), True);
3247 HIT_WATER
: g_Console_Add(Format(_lc
[I_PLAYER_KILL_WATER
], [FName
]), True);
3248 HIT_ACID
: g_Console_Add(Format(_lc
[I_PLAYER_KILL_ACID
], [FName
]), True);
3249 HIT_TRAP
: g_Console_Add(Format(_lc
[I_PLAYER_KILL_TRAP
], [FName
]), True);
3250 else g_Console_Add(Format(_lc
[I_PLAYER_DIED
], [FName
]), True);
3256 for a
:= WP_FIRST
to WP_LAST
do
3260 WEAPON_SAW
: i
:= ITEM_WEAPON_SAW
;
3261 WEAPON_SHOTGUN1
: i
:= ITEM_WEAPON_SHOTGUN1
;
3262 WEAPON_SHOTGUN2
: i
:= ITEM_WEAPON_SHOTGUN2
;
3263 WEAPON_CHAINGUN
: i
:= ITEM_WEAPON_CHAINGUN
;
3264 WEAPON_ROCKETLAUNCHER
: i
:= ITEM_WEAPON_ROCKETLAUNCHER
;
3265 WEAPON_PLASMA
: i
:= ITEM_WEAPON_PLASMA
;
3266 WEAPON_BFG
: i
:= ITEM_WEAPON_BFG
;
3267 WEAPON_SUPERPULEMET
: i
:= ITEM_WEAPON_SUPERPULEMET
;
3268 WEAPON_FLAMETHROWER
: i
:= ITEM_WEAPON_FLAMETHROWER
;
3277 if R_ITEM_BACKPACK
in FRulez
then
3278 PushItem(ITEM_AMMO_BACKPACK
);
3280 // Âûáðîñ ðàêåòíîãî ðàíöà:
3281 if FJetFuel
> 0 then
3282 PushItem(ITEM_JETPACK
);
3285 if not (gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
]) then
3287 if R_KEY_RED
in FRulez
then
3288 PushItem(ITEM_KEY_RED
);
3290 if R_KEY_GREEN
in FRulez
then
3291 PushItem(ITEM_KEY_GREEN
);
3293 if R_KEY_BLUE
in FRulez
then
3294 PushItem(ITEM_KEY_BLUE
);
3301 g_Player_CreateCorpse(Self
);
3303 if Srv
and (gGameSettings
.MaxLives
> 0) and FNoRespawn
and
3304 (gLMSRespawn
= LMS_RESPAWN_NONE
) then
3310 for i
:= Low(gPlayers
) to High(gPlayers
) do
3312 if gPlayers
[i
] = nil then continue
;
3313 if (not gPlayers
[i
].FNoRespawn
) and (not gPlayers
[i
].FSpectator
) then
3316 if gPlayers
[i
].FTeam
= TEAM_RED
then Inc(ar
)
3317 else if gPlayers
[i
].FTeam
= TEAM_BLUE
then Inc(ab
);
3322 OldLR
:= gLMSRespawn
;
3323 if (gGameSettings
.GameMode
= GM_COOP
) then
3327 // everyone is dead, restart the map
3328 g_Game_Message(_lc
[I_MESSAGE_LMS_LOSE
], 144);
3330 MH_SEND_GameEvent(NET_EV_LMS_LOSE
);
3331 gLMSRespawn
:= LMS_RESPAWN_FINAL
;
3332 gLMSRespawnTime
:= gTime
+ 5000;
3334 else if (a
= 1) then
3336 if (gPlayers
[k
] <> nil) and not (gPlayers
[k
] is TBot
) then
3337 if (gPlayers
[k
] = gPlayer1
) or
3338 (gPlayers
[k
] = gPlayer2
) then
3339 g_Console_Add('*** ' + _lc
[I_MESSAGE_LMS_SURVIVOR
] + ' ***', True)
3340 else if Netsrv
and (gPlayers
[k
].FClientID
>= 0) then
3341 MH_SEND_GameEvent(NET_EV_LMS_SURVIVOR
, 0, 'N', gPlayers
[k
].FClientID
);
3344 else if (gGameSettings
.GameMode
= GM_TDM
) then
3346 if (ab
= 0) and (ar
<> 0) then
3349 g_Game_Message(Format(_lc
[I_MESSAGE_TLMS_WIN
], [AnsiUpperCase(_lc
[I_GAME_TEAM_RED
])]), 144);
3351 MH_SEND_GameEvent(NET_EV_TLMS_WIN
, TEAM_RED
);
3352 Inc(gTeamStat
[TEAM_RED
].Goals
);
3353 gLMSRespawn
:= LMS_RESPAWN_FINAL
;
3354 gLMSRespawnTime
:= gTime
+ 5000;
3356 else if (ar
= 0) and (ab
<> 0) then
3359 g_Game_Message(Format(_lc
[I_MESSAGE_TLMS_WIN
], [AnsiUpperCase(_lc
[I_GAME_TEAM_BLUE
])]), 144);
3361 MH_SEND_GameEvent(NET_EV_TLMS_WIN
, TEAM_BLUE
);
3362 Inc(gTeamStat
[TEAM_BLUE
].Goals
);
3363 gLMSRespawn
:= LMS_RESPAWN_FINAL
;
3364 gLMSRespawnTime
:= gTime
+ 5000;
3366 else if (ar
= 0) and (ab
= 0) then
3369 g_Game_Message(_lc
[I_GAME_WIN_DRAW
], 144);
3371 MH_SEND_GameEvent(NET_EV_LMS_DRAW
, 0, FName
);
3372 gLMSRespawn
:= LMS_RESPAWN_FINAL
;
3373 gLMSRespawnTime
:= gTime
+ 5000;
3376 else if (gGameSettings
.GameMode
= GM_DM
) then
3380 if gPlayers
[k
] <> nil then
3383 // survivor is the winner
3384 g_Game_Message(Format(_lc
[I_MESSAGE_LMS_WIN
], [AnsiUpperCase(FName
)]), 144);
3386 MH_SEND_GameEvent(NET_EV_LMS_WIN
, 0, FName
);
3389 gLMSRespawn
:= LMS_RESPAWN_FINAL
;
3390 gLMSRespawnTime
:= gTime
+ 5000;
3392 else if (a
= 0) then
3394 // everyone is dead, restart the map
3395 g_Game_Message(_lc
[I_GAME_WIN_DRAW
], 144);
3397 MH_SEND_GameEvent(NET_EV_LMS_DRAW
, 0, FName
);
3398 gLMSRespawn
:= LMS_RESPAWN_FINAL
;
3399 gLMSRespawnTime
:= gTime
+ 5000;
3402 if srv
and (OldLR
= LMS_RESPAWN_NONE
) and (gLMSRespawn
> LMS_RESPAWN_NONE
) then
3404 if NetMode
= NET_SERVER
then
3405 MH_SEND_GameEvent(NET_EV_LMS_WARMUP
, (gLMSRespawnTime
- gTime
) div 1000)
3407 g_Console_Add(Format(_lc
[I_MSG_WARMUP_START
], [(gLMSRespawnTime
- gTime
) div 1000]), True);
3413 MH_SEND_PlayerStats(FUID
);
3414 MH_SEND_PlayerDeath(FUID
, KillType
, t
, SpawnerUID
);
3415 if gGameSettings
.GameMode
= GM_TDM
then MH_SEND_GameStats
;
3418 if srv
and FNoRespawn
then Spectate(True);
3419 FWantsInGame
:= True;
3422 function TPlayer
.BodyInLiquid(XInc
, YInc
: Integer): Boolean;
3424 Result
:= g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
, PLAYER_RECT
.Width
,
3425 PLAYER_RECT
.Height
-20, PANEL_WATER
or PANEL_ACID1
or PANEL_ACID2
, False);
3428 function TPlayer
.BodyInAcid(XInc
, YInc
: Integer): Boolean;
3430 Result
:= g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
, PLAYER_RECT
.Width
,
3431 PLAYER_RECT
.Height
-20, PANEL_ACID1
or PANEL_ACID2
, False);
3434 procedure TPlayer
.MakeBloodSimple(Count
: Word);
3436 g_GFX_Blood(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)+8,
3437 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2),
3438 Count
div 2, 3, -1, 16, (PLAYER_RECT
.Height
*2 div 3),
3440 g_GFX_Blood(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-8,
3441 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2),
3442 Count
div 2, -3, -1, 16, (PLAYER_RECT
.Height
*2) div 3,
3446 procedure TPlayer
.MakeBloodVector(Count
: Word; VelX
, VelY
: Integer);
3448 g_GFX_Blood(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2),
3449 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2),
3450 Count
, VelX
, VelY
, 16, (PLAYER_RECT
.Height
*2) div 3,
3454 procedure TPlayer
.QueueWeaponSwitch(Weapon
: Byte);
3456 if g_Game_IsClient
then Exit
;
3457 if Weapon
> High(FWeapon
) then Exit
;
3458 FNextWeap
:= FNextWeap
or (1 shl Weapon
);
3461 procedure TPlayer
.resetWeaponQueue ();
3464 FNextWeapDelay
:= 0;
3467 function TPlayer
.hasAmmoForWeapon (weapon
: Byte): Boolean;
3471 WEAPON_KASTET
, WEAPON_SAW
: result
:= true;
3472 WEAPON_SHOTGUN1
, WEAPON_SHOTGUN2
: result
:= (FAmmo
[A_SHELLS
] > 0);
3473 WEAPON_PISTOL
, WEAPON_CHAINGUN
, WEAPON_SUPERPULEMET
: result
:= (FAmmo
[A_BULLETS
] > 0);
3474 WEAPON_ROCKETLAUNCHER
: result
:= (FAmmo
[A_ROCKETS
] > 0);
3475 WEAPON_PLASMA
, WEAPON_BFG
: result
:= (FAmmo
[A_CELLS
] > 0);
3476 WEAPON_FLAMETHROWER
: result
:= (FAmmo
[A_FUEL
] > 0);
3477 else result
:= (weapon
< length(FWeapon
));
3481 // return 255 for "no switch"
3482 function TPlayer
.getNextWeaponIndex (): Byte;
3485 wantThisWeapon
: array[0..64] of Boolean;
3486 wwc
: Integer = 0; //HACK!
3489 result
:= 255; // default result: "no switch"
3490 // had weapon cycling on previous frame? remove that flag
3491 if (FNextWeap
and $2000) <> 0 then
3493 FNextWeap
:= FNextWeap
and $1FFF;
3494 FNextWeapDelay
:= 0;
3496 // cycling has priority
3497 if (FNextWeap
and $C000) <> 0 then
3499 if (FNextWeap
and $8000) <> 0 then
3503 FNextWeap
:= FNextWeap
or $2000; // we need this
3504 if FNextWeapDelay
> 0 then
3505 exit
; // cooldown time
3507 for i
:= 0 to High(FWeapon
) do
3509 cwi
:= (cwi
+length(FWeapon
)+dir
) mod length(FWeapon
);
3510 if FWeapon
[cwi
] then
3512 //e_WriteLog(Format(' SWITCH: cur=%d; new=%d', [FCurrWeap, cwi]), MSG_WARNING);
3513 result
:= Byte(cwi
);
3514 FNextWeapDelay
:= 10;
3522 for i
:= 0 to High(wantThisWeapon
) do
3523 wantThisWeapon
[i
] := false;
3524 for i
:= 0 to High(FWeapon
) do
3525 if (FNextWeap
and (1 shl i
)) <> 0 then
3527 wantThisWeapon
[i
] := true;
3530 // exclude currently selected weapon from the set
3531 wantThisWeapon
[FCurrWeap
] := false;
3532 // slow down alterations a little
3535 //e_WriteLog(Format(' FNextWeap=%x; delay=%d', [FNextWeap, FNextWeapDelay]), MSG_WARNING);
3536 // more than one weapon requested, assume "alteration" and check alteration delay
3537 if FNextWeapDelay
> 0 then
3543 // do not reset weapon queue, it will be done in `RealizeCurrentWeapon()`
3544 // but clear all counters if no weapon should be switched
3550 //e_WriteLog(Format('wwc=%d', [wwc]), MSG_WARNING);
3551 // try weapons in descending order
3552 for i
:= High(FWeapon
) downto 0 do
3554 if wantThisWeapon
[i
] and FWeapon
[i
] and ((wwc
= 1) or hasAmmoForWeapon(i
)) then
3559 FNextWeapDelay
:= 10; // anyway, 'cause why not
3563 // no suitable weapon found, so reset the queue, to avoid accidental "queuing" of weapon w/o ammo
3567 procedure TPlayer
.RealizeCurrentWeapon();
3568 function switchAllowed (): Boolean;
3573 if FBFGFireCounter
<> -1 then
3575 if FTime
[T_SWITCH
] > gTime
then
3577 for i
:= WP_FIRST
to WP_LAST
do
3578 if FReloading
[i
] > 0 then
3586 //e_WriteLog(Format('***RealizeCurrentWeapon: FNextWeap=%x; FNextWeapDelay=%d', [FNextWeap, FNextWeapDelay]), MSG_WARNING);
3587 //FNextWeap := FNextWeap and $1FFF;
3588 if FNextWeapDelay
> 0 then Dec(FNextWeapDelay
); // "alteration delay"
3590 if not switchAllowed
then
3592 //HACK for weapon cycling
3593 if (FNextWeap
and $7000) <> 0 then FNextWeap
:= 0;
3597 nw
:= getNextWeaponIndex();
3598 if nw
= 255 then exit
; // don't reset anything here
3599 if nw
> High(FWeapon
) then
3601 // don't forget to reset queue here!
3602 //e_WriteLog(' RealizeCurrentWeapon: WUTAFUUUU', MSG_WARNING);
3610 FTime
[T_SWITCH
] := gTime
+156;
3611 if FCurrWeap
= WEAPON_SAW
then FSawSoundSelect
.PlayAt(FObj
.X
, FObj
.Y
);
3612 FModel
.SetWeapon(FCurrWeap
);
3613 if g_Game_IsNet
then MH_SEND_PlayerStats(FUID
);
3617 procedure TPlayer
.NextWeapon();
3619 if g_Game_IsClient
then Exit
;
3623 procedure TPlayer
.PrevWeapon();
3625 if g_Game_IsClient
then Exit
;
3629 procedure TPlayer
.SetWeapon(W
: Byte);
3631 if FCurrWeap
<> W
then
3632 if W
= WEAPON_SAW
then
3633 FSawSoundSelect
.PlayAt(FObj
.X
, FObj
.Y
);
3636 FModel
.SetWeapon(CurrWeap
);
3640 function TPlayer
.PickItem(ItemType
: Byte; arespawn
: Boolean; var remove
: Boolean): Boolean;
3642 function allowBerserkSwitching (): Boolean;
3644 if (FBFGFireCounter
<> -1) then begin result
:= false; exit
; end;
3646 if gBerserkAutoswitch
then exit
;
3647 if not (gDebugMode
or gCheats
) then exit
;
3655 if g_Game_IsClient
then Exit
;
3657 // a = true - ìåñòî ñïàâíà ïðåäìåòà:
3658 a
:= LongBool(gGameSettings
.Options
and GAME_OPTION_WEAPONSTAY
) and arespawn
;
3663 if FHealth
< PLAYER_HP_SOFT
then
3665 IncMax(FHealth
, 10, PLAYER_HP_SOFT
);
3669 if gFlash
= 2 then Inc(FPickup
, 5);
3673 if FHealth
< PLAYER_HP_SOFT
then
3675 IncMax(FHealth
, 25, PLAYER_HP_SOFT
);
3679 if gFlash
= 2 then Inc(FPickup
, 5);
3683 if FArmor
< PLAYER_AP_SOFT
then
3685 FArmor
:= PLAYER_AP_SOFT
;
3688 if gFlash
= 2 then Inc(FPickup
, 5);
3692 if FArmor
< PLAYER_AP_LIMIT
then
3694 FArmor
:= PLAYER_AP_LIMIT
;
3697 if gFlash
= 2 then Inc(FPickup
, 5);
3701 if FHealth
< PLAYER_HP_LIMIT
then
3703 IncMax(FHealth
, 100, PLAYER_HP_LIMIT
);
3707 if gFlash
= 2 then Inc(FPickup
, 5);
3711 if (FHealth
< PLAYER_HP_LIMIT
) or (FArmor
< PLAYER_AP_LIMIT
) then
3713 if FHealth
< PLAYER_HP_LIMIT
then
3714 FHealth
:= PLAYER_HP_LIMIT
;
3715 if FArmor
< PLAYER_AP_LIMIT
then
3716 FArmor
:= PLAYER_AP_LIMIT
;
3720 if gFlash
= 2 then Inc(FPickup
, 5);
3724 if (not FWeapon
[WEAPON_SAW
]) or ((not arespawn
) and (gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
])) then
3726 FWeapon
[WEAPON_SAW
] := True;
3728 if gFlash
= 2 then Inc(FPickup
, 5);
3729 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
3732 ITEM_WEAPON_SHOTGUN1
:
3733 if (FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
]) or not FWeapon
[WEAPON_SHOTGUN1
] then
3735 // Íóæíî, ÷òîáû íå âçÿòü âñå ïóëè ñðàçó:
3736 if a
and FWeapon
[WEAPON_SHOTGUN1
] then Exit
;
3738 IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
3739 FWeapon
[WEAPON_SHOTGUN1
] := True;
3741 if gFlash
= 2 then Inc(FPickup
, 5);
3742 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
3745 ITEM_WEAPON_SHOTGUN2
:
3746 if (FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
]) or not FWeapon
[WEAPON_SHOTGUN2
] then
3748 if a
and FWeapon
[WEAPON_SHOTGUN2
] then Exit
;
3750 IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
3751 FWeapon
[WEAPON_SHOTGUN2
] := True;
3753 if gFlash
= 2 then Inc(FPickup
, 5);
3754 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
3757 ITEM_WEAPON_CHAINGUN
:
3758 if (FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
]) or not FWeapon
[WEAPON_CHAINGUN
] then
3760 if a
and FWeapon
[WEAPON_CHAINGUN
] then Exit
;
3762 IncMax(FAmmo
[A_BULLETS
], 50, FMaxAmmo
[A_BULLETS
]);
3763 FWeapon
[WEAPON_CHAINGUN
] := True;
3765 if gFlash
= 2 then Inc(FPickup
, 5);
3766 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
3769 ITEM_WEAPON_ROCKETLAUNCHER
:
3770 if (FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
]) or not FWeapon
[WEAPON_ROCKETLAUNCHER
] then
3772 if a
and FWeapon
[WEAPON_ROCKETLAUNCHER
] then Exit
;
3774 IncMax(FAmmo
[A_ROCKETS
], 2, FMaxAmmo
[A_ROCKETS
]);
3775 FWeapon
[WEAPON_ROCKETLAUNCHER
] := True;
3777 if gFlash
= 2 then Inc(FPickup
, 5);
3778 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
3782 if (FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
]) or not FWeapon
[WEAPON_PLASMA
] then
3784 if a
and FWeapon
[WEAPON_PLASMA
] then Exit
;
3786 IncMax(FAmmo
[A_CELLS
], 40, FMaxAmmo
[A_CELLS
]);
3787 FWeapon
[WEAPON_PLASMA
] := True;
3789 if gFlash
= 2 then Inc(FPickup
, 5);
3790 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
3794 if (FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
]) or not FWeapon
[WEAPON_BFG
] then
3796 if a
and FWeapon
[WEAPON_BFG
] then Exit
;
3798 IncMax(FAmmo
[A_CELLS
], 40, FMaxAmmo
[A_CELLS
]);
3799 FWeapon
[WEAPON_BFG
] := True;
3801 if gFlash
= 2 then Inc(FPickup
, 5);
3802 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
3805 ITEM_WEAPON_SUPERPULEMET
:
3806 if (FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
]) or not FWeapon
[WEAPON_SUPERPULEMET
] then
3808 if a
and FWeapon
[WEAPON_SUPERPULEMET
] then Exit
;
3810 IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
3811 FWeapon
[WEAPON_SUPERPULEMET
] := True;
3813 if gFlash
= 2 then Inc(FPickup
, 5);
3814 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
3817 ITEM_WEAPON_FLAMETHROWER
:
3818 if (FAmmo
[A_FUEL
] < FMaxAmmo
[A_FUEL
]) or not FWeapon
[WEAPON_FLAMETHROWER
] then
3820 if a
and FWeapon
[WEAPON_FLAMETHROWER
] then Exit
;
3822 IncMax(FAmmo
[A_FUEL
], 100, FMaxAmmo
[A_FUEL
]);
3823 FWeapon
[WEAPON_FLAMETHROWER
] := True;
3825 if gFlash
= 2 then Inc(FPickup
, 5);
3826 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
3830 if FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
] then
3832 IncMax(FAmmo
[A_BULLETS
], 10, FMaxAmmo
[A_BULLETS
]);
3835 if gFlash
= 2 then Inc(FPickup
, 5);
3838 ITEM_AMMO_BULLETS_BOX
:
3839 if FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
] then
3841 IncMax(FAmmo
[A_BULLETS
], 50, FMaxAmmo
[A_BULLETS
]);
3844 if gFlash
= 2 then Inc(FPickup
, 5);
3848 if FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
] then
3850 IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
3853 if gFlash
= 2 then Inc(FPickup
, 5);
3856 ITEM_AMMO_SHELLS_BOX
:
3857 if FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
] then
3859 IncMax(FAmmo
[A_SHELLS
], 25, FMaxAmmo
[A_SHELLS
]);
3862 if gFlash
= 2 then Inc(FPickup
, 5);
3866 if FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
] then
3868 IncMax(FAmmo
[A_ROCKETS
], 1, FMaxAmmo
[A_ROCKETS
]);
3871 if gFlash
= 2 then Inc(FPickup
, 5);
3874 ITEM_AMMO_ROCKET_BOX
:
3875 if FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
] then
3877 IncMax(FAmmo
[A_ROCKETS
], 5, FMaxAmmo
[A_ROCKETS
]);
3880 if gFlash
= 2 then Inc(FPickup
, 5);
3884 if FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
] then
3886 IncMax(FAmmo
[A_CELLS
], 40, FMaxAmmo
[A_CELLS
]);
3889 if gFlash
= 2 then Inc(FPickup
, 5);
3893 if FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
] then
3895 IncMax(FAmmo
[A_CELLS
], 100, FMaxAmmo
[A_CELLS
]);
3898 if gFlash
= 2 then Inc(FPickup
, 5);
3902 if FAmmo
[A_FUEL
] < FMaxAmmo
[A_FUEL
] then
3904 IncMax(FAmmo
[A_FUEL
], 100, FMaxAmmo
[A_FUEL
]);
3907 if gFlash
= 2 then Inc(FPickup
, 5);
3911 if not(R_ITEM_BACKPACK
in FRulez
) or
3912 (FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
]) or
3913 (FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
]) or
3914 (FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
]) or
3915 (FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
]) or
3916 (FMaxAmmo
[A_FUEL
] < AmmoLimits
[1, A_FUEL
]) then
3918 FMaxAmmo
[A_BULLETS
] := AmmoLimits
[1, A_BULLETS
];
3919 FMaxAmmo
[A_SHELLS
] := AmmoLimits
[1, A_SHELLS
];
3920 FMaxAmmo
[A_ROCKETS
] := AmmoLimits
[1, A_ROCKETS
];
3921 FMaxAmmo
[A_CELLS
] := AmmoLimits
[1, A_CELLS
];
3922 FMaxAmmo
[A_FUEL
] := AmmoLimits
[1, A_FUEL
];
3924 if FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
] then
3925 IncMax(FAmmo
[A_BULLETS
], 10, FMaxAmmo
[A_BULLETS
]);
3926 if FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
] then
3927 IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
3928 if FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
] then
3929 IncMax(FAmmo
[A_ROCKETS
], 1, FMaxAmmo
[A_ROCKETS
]);
3930 if FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
] then
3931 IncMax(FAmmo
[A_CELLS
], 40, FMaxAmmo
[A_CELLS
]);
3933 FRulez
:= FRulez
+ [R_ITEM_BACKPACK
];
3936 if gFlash
= 2 then Inc(FPickup
, 5);
3940 if not(R_KEY_RED
in FRulez
) then
3942 Include(FRulez
, R_KEY_RED
);
3944 remove
:= (gGameSettings
.GameMode
<> GM_COOP
) and (g_Player_GetCount() < 2);
3945 if gFlash
= 2 then Inc(FPickup
, 5);
3946 if (not remove
) and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETITEM');
3950 if not(R_KEY_GREEN
in FRulez
) then
3952 Include(FRulez
, R_KEY_GREEN
);
3954 remove
:= (gGameSettings
.GameMode
<> GM_COOP
) and (g_Player_GetCount() < 2);
3955 if gFlash
= 2 then Inc(FPickup
, 5);
3956 if (not remove
) and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETITEM');
3960 if not(R_KEY_BLUE
in FRulez
) then
3962 Include(FRulez
, R_KEY_BLUE
);
3964 remove
:= (gGameSettings
.GameMode
<> GM_COOP
) and (g_Player_GetCount() < 2);
3965 if gFlash
= 2 then Inc(FPickup
, 5);
3966 if (not remove
) and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETITEM');
3970 if FMegaRulez
[MR_SUIT
] < gTime
+PLAYER_SUIT_TIME
then
3972 FMegaRulez
[MR_SUIT
] := gTime
+PLAYER_SUIT_TIME
;
3976 if gFlash
= 2 then Inc(FPickup
, 5);
3980 if FAir
< AIR_MAX
then
3985 if gFlash
= 2 then Inc(FPickup
, 5);
3990 if not (R_BERSERK
in FRulez
) then
3992 Include(FRulez
, R_BERSERK
);
3993 if allowBerserkSwitching
then
3995 FCurrWeap
:= WEAPON_KASTET
;
3997 FModel
.SetWeapon(WEAPON_KASTET
);
4002 if gFlash
= 2 then Inc(FPickup
, 5);
4004 FBerserk
:= gTime
+30000;
4009 if FHealth
< PLAYER_HP_SOFT
then
4011 FHealth
:= PLAYER_HP_SOFT
;
4012 FBerserk
:= gTime
+30000;
4020 if FMegaRulez
[MR_INVUL
] < gTime
+PLAYER_INVUL_TIME
then
4022 FMegaRulez
[MR_INVUL
] := gTime
+PLAYER_INVUL_TIME
;
4025 if gFlash
= 2 then Inc(FPickup
, 5);
4029 if FHealth
< PLAYER_HP_LIMIT
then
4031 IncMax(FHealth
, 4, PLAYER_HP_LIMIT
);
4035 if gFlash
= 2 then Inc(FPickup
, 5);
4039 if FArmor
< PLAYER_AP_LIMIT
then
4041 IncMax(FArmor
, 5, PLAYER_AP_LIMIT
);
4044 if gFlash
= 2 then Inc(FPickup
, 5);
4048 if FJetFuel
< JET_MAX
then
4050 FJetFuel
:= JET_MAX
;
4053 if gFlash
= 2 then Inc(FPickup
, 5);
4057 if FMegaRulez
[MR_INVIS
] < gTime
+PLAYER_INVIS_TIME
then
4059 FMegaRulez
[MR_INVIS
] := gTime
+PLAYER_INVIS_TIME
;
4062 if gFlash
= 2 then Inc(FPickup
, 5);
4067 procedure TPlayer
.Touch();
4071 //FModel.PlaySound(MODELSOUND_PAIN, 1, FObj.X, FObj.Y);
4074 // Áðîñèòü ôëàã òîâàðèùó:
4075 if gGameSettings
.GameMode
= GM_CTF
then
4080 procedure TPlayer
.Push(vx
, vy
: Integer);
4082 if (not FPhysics
) and FGhost
then
4084 FObj
.Accel
.X
:= FObj
.Accel
.X
+ vx
;
4085 FObj
.Accel
.Y
:= FObj
.Accel
.Y
+ vy
;
4086 if g_Game_IsNet
and g_Game_IsServer
then
4087 MH_SEND_PlayerPos(True, FUID
, NET_EVERYONE
);
4090 procedure TPlayer
.Reset(Force
: Boolean);
4096 FTime
[T_RESPAWN
] := 0;
4097 FTime
[T_FLAGCAP
] := 0;
4110 FSpectator
:= False;
4113 FSpectatePlayer
:= -1;
4114 FNoRespawn
:= False;
4116 FLives
:= gGameSettings
.MaxLives
;
4121 procedure TPlayer
.SoftReset();
4127 FBFGFireCounter
:= -1;
4135 SetAction(A_STAND
, True);
4138 function TPlayer
.GetRespawnPoint(): Byte;
4143 // Íà áóäóùåå: FSpawn - èãðîê óæå èãðàë è ïåðåðîæäàåòñÿ
4145 // Îäèíî÷íàÿ èãðà/êîîïåðàòèâ
4146 if gGameSettings
.GameMode
in [GM_COOP
, GM_SINGLE
] then
4148 if (Self
= gPlayer1
) or (Self
= gPlayer2
) then
4150 // Òî÷êà ïîÿâëåíèÿ ñâîåãî èãðîêà
4151 if Self
= gPlayer1
then
4152 c
:= RESPAWNPOINT_PLAYER1
4154 c
:= RESPAWNPOINT_PLAYER2
;
4155 if g_Map_GetPointCount(c
) > 0 then
4161 // Òî÷êà ïîÿâëåíèÿ äðóãîãî èãðîêà
4162 if Self
= gPlayer1
then
4163 c
:= RESPAWNPOINT_PLAYER2
4165 c
:= RESPAWNPOINT_PLAYER1
;
4166 if g_Map_GetPointCount(c
) > 0 then
4173 // Òî÷êà ïîÿâëåíèÿ ëþáîãî èãðîêà (áîòà)
4174 if Random(2) = 0 then
4175 c
:= RESPAWNPOINT_PLAYER1
4177 c
:= RESPAWNPOINT_PLAYER2
;
4178 if g_Map_GetPointCount(c
) > 0 then
4185 // Òî÷êà ëþáîé èç êîìàíä
4186 if Random(2) = 0 then
4187 c
:= RESPAWNPOINT_RED
4189 c
:= RESPAWNPOINT_BLUE
;
4190 if g_Map_GetPointCount(c
) > 0 then
4197 c
:= RESPAWNPOINT_DM
;
4198 if g_Map_GetPointCount(c
) > 0 then
4206 if gGameSettings
.GameMode
= GM_DM
then
4209 c
:= RESPAWNPOINT_DM
;
4210 if g_Map_GetPointCount(c
) > 0 then
4216 // Òî÷êà ïîÿâëåíèÿ ëþáîãî èãðîêà
4217 if Random(2) = 0 then
4218 c
:= RESPAWNPOINT_PLAYER1
4220 c
:= RESPAWNPOINT_PLAYER2
;
4221 if g_Map_GetPointCount(c
) > 0 then
4227 // Òî÷êà ëþáîé èç êîìàíä
4228 if Random(2) = 0 then
4229 c
:= RESPAWNPOINT_RED
4231 c
:= RESPAWNPOINT_BLUE
;
4232 if g_Map_GetPointCount(c
) > 0 then
4240 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
4242 // Òî÷êà ñâîåé êîìàíäû
4243 c
:= RESPAWNPOINT_DM
;
4244 if FTeam
= TEAM_RED
then
4245 c
:= RESPAWNPOINT_RED
;
4246 if FTeam
= TEAM_BLUE
then
4247 c
:= RESPAWNPOINT_BLUE
;
4248 if g_Map_GetPointCount(c
) > 0 then
4255 c
:= RESPAWNPOINT_DM
;
4256 if g_Map_GetPointCount(c
) > 0 then
4262 // Òî÷êà ïîÿâëåíèÿ ëþáîãî èãðîêà
4263 if Random(2) = 0 then
4264 c
:= RESPAWNPOINT_PLAYER1
4266 c
:= RESPAWNPOINT_PLAYER2
;
4267 if g_Map_GetPointCount(c
) > 0 then
4273 // Òî÷êà äðóãîé êîìàíäû
4274 c
:= RESPAWNPOINT_DM
;
4275 if FTeam
= TEAM_RED
then
4276 c
:= RESPAWNPOINT_BLUE
;
4277 if FTeam
= TEAM_BLUE
then
4278 c
:= RESPAWNPOINT_RED
;
4279 if g_Map_GetPointCount(c
) > 0 then
4287 procedure TPlayer
.Respawn(Silent
: Boolean; Force
: Boolean = False);
4289 RespawnPoint
: TRespawnPoint
;
4294 if not g_Game_IsServer
then
4298 FWantsInGame
:= True;
4299 FJustTeleported
:= True;
4302 FTime
[T_RESPAWN
] := 0;
4306 // if server changes MaxLives we gotta be ready
4307 if gGameSettings
.MaxLives
= 0 then FNoRespawn
:= False;
4309 // Åùå íåëüçÿ âîçðîäèòüñÿ:
4310 if FTime
[T_RESPAWN
] > gTime
then
4313 // Ïðîñðàë âñå æèçíè:
4316 if not FSpectator
then Spectate(True);
4317 FWantsInGame
:= True;
4321 if (gGameSettings
.GameType
<> GT_SINGLE
) and (gGameSettings
.GameMode
<> GM_COOP
) then
4322 begin // "Ñâîÿ èãðà"
4323 // Áåðñåðê íå ñîõðàíÿåòñÿ ìåæäó óðîâíÿìè:
4324 FRulez
:= FRulez
-[R_BERSERK
];
4326 else // "Îäèíî÷íàÿ èãðà"/"Êîîï"
4328 // Áåðñåðê è êëþ÷è íå ñîõðàíÿþòñÿ ìåæäó óðîâíÿìè:
4329 FRulez
:= FRulez
-[R_KEY_RED
, R_KEY_GREEN
, R_KEY_BLUE
, R_BERSERK
];
4332 // Ïîëó÷àåì òî÷êó ñïàóíà èãðîêà:
4333 c
:= GetRespawnPoint();
4338 // Âîñêðåøåíèå áåç îðóæèÿ:
4341 FHealth
:= PLAYER_HP_SOFT
;
4347 for a
:= WP_FIRST
to WP_LAST
do
4349 FWeapon
[a
] := False;
4353 FWeapon
[WEAPON_PISTOL
] := True;
4354 FWeapon
[WEAPON_KASTET
] := True;
4355 FCurrWeap
:= WEAPON_PISTOL
;
4358 FModel
.SetWeapon(FCurrWeap
);
4360 for b
:= A_BULLETS
to A_HIGH
do
4363 FAmmo
[A_BULLETS
] := 50;
4365 FMaxAmmo
[A_BULLETS
] := AmmoLimits
[0, A_BULLETS
];
4366 FMaxAmmo
[A_SHELLS
] := AmmoLimits
[0, A_SHELLS
];
4367 FMaxAmmo
[A_ROCKETS
] := AmmoLimits
[0, A_SHELLS
];
4368 FMaxAmmo
[A_CELLS
] := AmmoLimits
[0, A_CELLS
];
4369 FMaxAmmo
[A_FUEL
] := AmmoLimits
[0, A_FUEL
];
4371 if gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
] then
4372 FRulez
:= [R_KEY_RED
, R_KEY_GREEN
, R_KEY_BLUE
]
4377 // Ïîëó÷àåì êîîðäèíàòû òî÷êè âîçðîæäåíèÿ:
4378 if not g_Map_GetPoint(c
, RespawnPoint
) then
4380 g_FatalError(_lc
[I_GAME_ERROR_GET_SPAWN
]);
4384 // Óñòàíîâêà êîîðäèíàò è ñáðîñ âñåõ ïàðàìåòðîâ:
4385 FObj
.X
:= RespawnPoint
.X
-PLAYER_RECT
.X
;
4386 FObj
.Y
:= RespawnPoint
.Y
-PLAYER_RECT
.Y
;
4392 FDirection
:= RespawnPoint
.Direction
;
4393 if FDirection
= D_LEFT
then
4399 FBFGFireCounter
:= -1;
4404 SetAction(A_STAND
, True);
4405 FModel
.Direction
:= FDirection
;
4407 for a
:= Low(FTime
) to High(FTime
) do
4410 for a
:= Low(FMegaRulez
) to High(FMegaRulez
) do
4415 FCanJetpack
:= False;
4420 // Àíèìàöèÿ âîçðîæäåíèÿ:
4421 if (not gLoadGameMode
) and (not Silent
) then
4422 if g_Frames_Get(ID
, 'FRAMES_TELEPORT') then
4424 Anim
:= TAnimation
.Create(ID
, False, 3);
4425 g_GFX_OnceAnim(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-32,
4426 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)-32, Anim
);
4430 FSpectator
:= False;
4433 FSpectatePlayer
:= -1;
4436 if g_Game_IsNet
then
4438 MH_SEND_PlayerPos(True, FUID
, NET_EVERYONE
);
4439 MH_SEND_PlayerStats(FUID
, NET_EVERYONE
);
4441 MH_SEND_Effect(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-32,
4442 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)-32,
4447 procedure TPlayer
.Spectate(NoMove
: Boolean = False);
4450 Kill(K_EXTRAHARDKILL
, FUID
, HIT_SOME
)
4451 else if (not NoMove
) then
4453 GameX
:= gMapInfo
.Width
div 2;
4454 GameY
:= gMapInfo
.Height
div 2;
4463 FWantsInGame
:= False;
4468 if Self
= gPlayer1
then
4473 if Self
= gPlayer2
then
4480 if g_Game_IsNet
then
4481 MH_SEND_PlayerStats(FUID
);
4484 procedure TPlayer
.SwitchNoClip
;
4488 FGhost
:= not FGhost
;
4489 FPhysics
:= not FGhost
;
4501 procedure TPlayer
.Run(Direction
: TDirection
);
4505 if MAX_RUNVEL
> 8 then
4509 if Direction
= D_LEFT
then
4511 if FObj
.Vel
.X
> -MAX_RUNVEL
then
4512 FObj
.Vel
.X
:= FObj
.Vel
.X
- (MAX_RUNVEL
shr 3);
4515 if FObj
.Vel
.X
< MAX_RUNVEL
then
4516 FObj
.Vel
.X
:= FObj
.Vel
.X
+ (MAX_RUNVEL
shr 3);
4518 // Âîçìîæíî, ïèíàåì êóñêè:
4519 if (FObj
.Vel
.X
<> 0) and (gGibs
<> nil) then
4521 b
:= Abs(FObj
.Vel
.X
);
4522 if b
> 1 then b
:= b
* (Random(8 div b
) + 1);
4523 for a
:= 0 to High(gGibs
) do
4525 if gGibs
[a
].alive
and
4526 g_Obj_Collide(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
+FObj
.Rect
.Height
-4,
4527 FObj
.Rect
.Width
, 8, @gGibs
[a
].Obj
) and (Random(3) = 0) then
4530 if FObj
.Vel
.X
< 0 then
4532 g_Obj_PushA(@gGibs
[a
].Obj
, b
, Random(61)+120) // íàëåâî
4536 g_Obj_PushA(@gGibs
[a
].Obj
, b
, Random(61)); // íàïðàâî
4538 gGibs
[a
].positionChanged(); // this updates spatial accelerators
4546 procedure TPlayer
.SeeDown();
4548 SetAction(A_SEEDOWN
);
4550 if FDirection
= D_LEFT
then FAngle
:= ANGLE_LEFTDOWN
else FAngle
:= ANGLE_RIGHTDOWN
;
4552 if FIncCam
> -120 then DecMin(FIncCam
, 5, -120);
4555 procedure TPlayer
.SeeUp();
4559 if FDirection
= D_LEFT
then FAngle
:= ANGLE_LEFTUP
else FAngle
:= ANGLE_RIGHTUP
;
4561 if FIncCam
< 120 then IncMax(FIncCam
, 5, 120);
4564 procedure TPlayer
.SetAction(Action
: Byte; Force
: Boolean = False);
4572 A_ATTACK
: Prior
:= 2;
4573 A_SEEUP
: Prior
:= 1;
4574 A_SEEDOWN
: Prior
:= 1;
4575 A_ATTACKUP
: Prior
:= 2;
4576 A_ATTACKDOWN
: Prior
:= 2;
4581 if (Prior
> FActionPrior
) or Force
then
4582 if not ((Prior
= 2) and (FCurrWeap
= WEAPON_SAW
)) then
4584 FActionPrior
:= Prior
;
4585 FActionAnim
:= Action
;
4586 FActionForce
:= Force
;
4587 FActionChanged
:= True;
4590 if Action
in [A_ATTACK
, A_ATTACKUP
, A_ATTACKDOWN
] then FModel
.SetFire(True);
4593 function TPlayer
.StayOnStep(XInc
, YInc
: Integer): Boolean;
4595 Result
:= not g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+YInc
+PLAYER_RECT
.Y
+PLAYER_RECT
.Height
-1,
4596 PLAYER_RECT
.Width
, 1, PANEL_STEP
, False)
4597 and g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+YInc
+PLAYER_RECT
.Y
+PLAYER_RECT
.Height
,
4598 PLAYER_RECT
.Width
, 1, PANEL_STEP
, False);
4601 function TPlayer
.TeleportTo(X
, Y
: Integer; silent
: Boolean; dir
: Byte): Boolean;
4608 if g_CollideLevel(X
, Y
, PLAYER_RECT
.Width
, PLAYER_RECT
.Height
) then
4610 g_Sound_PlayExAt('SOUND_GAME_NOTELEPORT', FObj
.X
, FObj
.Y
);
4611 if g_Game_IsServer
and g_Game_IsNet
then
4612 MH_SEND_Sound(FObj
.X
, FObj
.Y
, 'SOUND_GAME_NOTELEPORT');
4616 FJustTeleported
:= True;
4621 if g_Frames_Get(ID
, 'FRAMES_TELEPORT') then
4623 Anim
:= TAnimation
.Create(ID
, False, 3);
4626 g_Sound_PlayExAt('SOUND_GAME_TELEPORT', FObj
.X
, FObj
.Y
);
4627 g_GFX_OnceAnim(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-32,
4628 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)-32, Anim
);
4629 if g_Game_IsServer
and g_Game_IsNet
then
4630 MH_SEND_Effect(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-32,
4631 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)-32, 1,
4635 FObj
.X
:= X
-PLAYER_RECT
.X
;
4636 FObj
.Y
:= Y
-PLAYER_RECT
.Y
;
4637 if FAlive
and FGhost
then
4643 if not g_Game_IsNet
then
4647 SetDirection(D_LEFT
);
4653 SetDirection(D_RIGHT
);
4659 if FDirection
= D_RIGHT
then
4661 SetDirection(D_LEFT
);
4666 SetDirection(D_RIGHT
);
4672 if not silent
and (Anim
<> nil) then
4674 g_GFX_OnceAnim(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-32,
4675 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)-32, Anim
);
4678 if g_Game_IsServer
and g_Game_IsNet
then
4679 MH_SEND_Effect(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-32,
4680 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)-32, 0,
4687 function nonz(a
: Single): Single;
4695 procedure TPlayer
.Update();
4698 i
, ii
, wx
, wy
, xd
, yd
, k
: Integer;
4699 blockmon
, headwater
, dospawn
: Boolean;
4704 NetServer
:= g_Game_IsNet
and g_Game_IsServer
;
4705 AnyServer
:= g_Game_IsServer
;
4707 if g_Game_IsClient
and (NetInterpLevel
> 0) then
4708 DoLerp(NetInterpLevel
+ 1)
4714 if FClientID
>= 0 then
4716 FPing
:= NetClients
[FClientID
].Peer
^.lastRoundTripTime
;
4717 if NetClients
[FClientID
].Peer
^.packetsSent
> 0 then
4718 FLoss
:= Round(100*NetClients
[FClientID
].Peer
^.packetsLost
/NetClients
[FClientID
].Peer
^.packetsSent
)
4727 if FAlive
and (gFly
or FJetpack
) then
4730 if FDirection
= D_LEFT
then
4735 if FAlive
and (not FGhost
) then
4737 if FKeys
[KEY_UP
].Pressed
then
4739 if FKeys
[KEY_DOWN
].Pressed
then
4743 if (not (FKeys
[KEY_UP
].Pressed
or FKeys
[KEY_DOWN
].Pressed
)) and
4746 i
:= g_basic
.Sign(FIncCam
);
4747 FIncCam
:= Abs(FIncCam
);
4748 DecMin(FIncCam
, 5, 0);
4749 FIncCam
:= FIncCam
*i
;
4752 // no need to do that each second frame, weapon queue will take care of it
4753 if FAlive
and FKeys
[KEY_NEXTWEAPON
].Pressed
and AnyServer
then NextWeapon();
4754 if FAlive
and FKeys
[KEY_PREVWEAPON
].Pressed
and AnyServer
then PrevWeapon();
4756 if gTime
mod (GAME_TICK
*2) <> 0 then
4758 if (FObj
.Vel
.X
= 0) and FAlive
then
4760 if FKeys
[KEY_LEFT
].Pressed
then
4762 if FKeys
[KEY_RIGHT
].Pressed
then
4768 g_Obj_Move(@FObj
, True, True, True);
4769 positionChanged(); // this updates spatial accelerators
4775 FActionChanged
:= False;
4779 // Let alive player do some actions
4780 if FKeys
[KEY_LEFT
].Pressed
then Run(D_LEFT
);
4781 if FKeys
[KEY_RIGHT
].Pressed
then Run(D_RIGHT
);
4782 //if FKeys[KEY_NEXTWEAPON].Pressed and AnyServer then NextWeapon();
4783 //if FKeys[KEY_PREVWEAPON].Pressed and AnyServer then PrevWeapon();
4784 if FKeys
[KEY_FIRE
].Pressed
and AnyServer
then Fire();
4785 if FKeys
[KEY_OPEN
].Pressed
and AnyServer
then Use();
4786 if FKeys
[KEY_JUMP
].Pressed
then Jump()
4789 if AnyServer
and FJetpack
then
4793 if NetServer
then MH_SEND_PlayerStats(FUID
);
4795 FCanJetpack
:= True;
4802 for k
:= Low(FKeys
) to KEY_CHAT
-1 do
4804 if FKeys
[k
].Pressed
then
4812 if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
4815 if (FTime
[T_RESPAWN
] <= gTime
) and
4816 gGameOn
and (not FAlive
) then
4818 if (g_Player_GetCount() > 1) then
4822 gExit
:= EXIT_RESTART
;
4827 // Dead spectator actions
4830 if FKeys
[KEY_OPEN
].Pressed
and AnyServer
then Fire();
4831 if FKeys
[KEY_FIRE
].Pressed
and AnyServer
then
4835 if (FSpectatePlayer
>= High(gPlayers
)) then
4836 FSpectatePlayer
:= -1
4840 for I
:= FSpectatePlayer
+ 1 to High(gPlayers
) do
4841 if gPlayers
[I
] <> nil then
4842 if gPlayers
[I
].alive
then
4843 if gPlayers
[I
].UID
<> FUID
then
4845 FSpectatePlayer
:= I
;
4850 if not SetSpect
then FSpectatePlayer
:= -1;
4861 if FKeys
[KEY_UP
].Pressed
or FKeys
[KEY_JUMP
].Pressed
then
4863 FYTo
:= FObj
.Y
- 32;
4864 FSpectatePlayer
:= -1;
4866 if FKeys
[KEY_DOWN
].Pressed
then
4868 FYTo
:= FObj
.Y
+ 32;
4869 FSpectatePlayer
:= -1;
4871 if FKeys
[KEY_LEFT
].Pressed
then
4873 FXTo
:= FObj
.X
- 32;
4874 FSpectatePlayer
:= -1;
4876 if FKeys
[KEY_RIGHT
].Pressed
then
4878 FXTo
:= FObj
.X
+ 32;
4879 FSpectatePlayer
:= -1;
4882 if (FXTo
< -64) then
4884 else if (FXTo
> gMapInfo
.Width
+ 32) then
4885 FXTo
:= gMapInfo
.Width
+ 32;
4886 if (FYTo
< -72) then
4888 else if (FYTo
> gMapInfo
.Height
+ 32) then
4889 FYTo
:= gMapInfo
.Height
+ 32;
4894 g_Obj_Move(@FObj
, True, True, True);
4895 positionChanged(); // this updates spatial accelerators
4902 if (FSpectatePlayer
<= High(gPlayers
)) and (FSpectatePlayer
>= 0) then
4903 if gPlayers
[FSpectatePlayer
] <> nil then
4904 if gPlayers
[FSpectatePlayer
].alive
then
4906 FXTo
:= gPlayers
[FSpectatePlayer
].GameX
;
4907 FYTo
:= gPlayers
[FSpectatePlayer
].GameY
;
4911 blockmon
:= g_Map_CollidePanel(FObj
.X
+PLAYER_HEADRECT
.X
, FObj
.Y
+PLAYER_HEADRECT
.Y
,
4912 PLAYER_HEADRECT
.Width
, PLAYER_HEADRECT
.Height
,
4913 PANEL_BLOCKMON
, True);
4914 headwater
:= HeadInLiquid(0, 0);
4916 // Ñîïðîòèâëåíèå âîçäóõà:
4917 if (not FAlive
) or not (FKeys
[KEY_LEFT
].Pressed
or FKeys
[KEY_RIGHT
].Pressed
) then
4918 if FObj
.Vel
.X
<> 0 then
4919 FObj
.Vel
.X
:= z_dec(FObj
.Vel
.X
, 1);
4921 if (FLastHit
= HIT_TRAP
) and (FPain
> 90) then FPain
:= 90;
4922 DecMin(FPain
, 5, 0);
4923 DecMin(FPickup
, 1, 0);
4925 if FAlive
and (FObj
.Y
> Integer(gMapInfo
.Height
)+128) and AnyServer
then
4927 // Îáíóëèòü äåéñòâèÿ ïðèìî÷åê, ÷òîáû ôîí ïðîïàë
4928 FMegaRulez
[MR_SUIT
] := 0;
4929 FMegaRulez
[MR_INVUL
] := 0;
4930 FMegaRulez
[MR_INVIS
] := 0;
4931 Kill(K_FALLKILL
, 0, HIT_FALL
);
4938 if FCurrWeap
= WEAPON_SAW
then
4939 if not (FSawSound
.IsPlaying() or FSawSoundHit
.IsPlaying() or
4940 FSawSoundSelect
.IsPlaying()) then
4941 FSawSoundIdle
.PlayAt(FObj
.X
, FObj
.Y
);
4944 if (not FJetSoundFly
.IsPlaying()) and (not FJetSoundOn
.IsPlaying()) and
4945 (not FJetSoundOff
.IsPlaying()) then
4947 FJetSoundFly
.SetPosition(0);
4948 FJetSoundFly
.PlayAt(FObj
.X
, FObj
.Y
);
4951 for b
:= WP_FIRST
to WP_LAST
do
4952 if FReloading
[b
] > 0 then
4958 if FShellTimer
> -1 then
4959 if FShellTimer
= 0 then
4961 if FShellType
= SHELL_SHELL
then
4962 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
4963 GameVelX
, GameVelY
-2, SHELL_SHELL
)
4964 else if FShellType
= SHELL_DBLSHELL
then
4966 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
4967 GameVelX
+1, GameVelY
-2, SHELL_SHELL
);
4968 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
4969 GameVelX
-1, GameVelY
-2, SHELL_SHELL
);
4972 end else Dec(FShellTimer
);
4974 if (FBFGFireCounter
> -1) then
4975 if FBFGFireCounter
= 0 then
4979 wx
:= FObj
.X
+WEAPONPOINT
[FDirection
].X
;
4980 wy
:= FObj
.Y
+WEAPONPOINT
[FDirection
].Y
;
4981 xd
:= wx
+IfThen(FDirection
= D_LEFT
, -30, 30);
4982 yd
:= wy
+firediry();
4983 g_Weapon_bfgshot(wx
, wy
, xd
, yd
, FUID
);
4984 if NetServer
then MH_SEND_PlayerFire(FUID
, WEAPON_BFG
, wx
, wy
, xd
, yd
);
4985 if (FAngle
= 0) or (FAngle
= 180) then SetAction(A_ATTACK
)
4986 else if (FAngle
= ANGLE_LEFTDOWN
) or (FAngle
= ANGLE_RIGHTDOWN
) then SetAction(A_ATTACKDOWN
)
4987 else if (FAngle
= ANGLE_LEFTUP
) or (FAngle
= ANGLE_RIGHTUP
) then SetAction(A_ATTACKUP
);
4990 FReloading
[WEAPON_BFG
] := WEAPON_RELOAD
[WEAPON_BFG
];
4991 FBFGFireCounter
:= -1;
4994 FBFGFireCounter
:= 0
4996 Dec(FBFGFireCounter
);
4998 if (FMegaRulez
[MR_SUIT
] < gTime
) and AnyServer
then
5000 b
:= g_GetAcidHit(FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+PLAYER_RECT
.Y
, PLAYER_RECT
.Width
, PLAYER_RECT
.Height
);
5002 if (b
> 0) and (gTime
mod (15*GAME_TICK
) = 0) then Damage(b
, 0, 0, 0, HIT_ACID
);
5005 if (headwater
or blockmon
) then
5011 if AnyServer
then Damage(10, 0, 0, 0, HIT_WATER
);
5014 else if (FAir
mod 31 = 0) and not blockmon
then
5016 g_GFX_Bubbles(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2), FObj
.Y
+PLAYER_RECT
.Y
-4, 5+Random(6), 8, 4);
5017 if Random(2) = 0 then
5018 g_Sound_PlayExAt('SOUND_GAME_BUBBLE1', FObj
.X
, FObj
.Y
)
5020 g_Sound_PlayExAt('SOUND_GAME_BUBBLE2', FObj
.X
, FObj
.Y
);
5022 end else if FAir
< AIR_DEF
then
5025 if FFireTime
> 0 then
5027 if BodyInLiquid(0, 0) then
5032 else if FMegaRulez
[MR_SUIT
] >= gTime
then
5034 if FMegaRulez
[MR_SUIT
] = gTime
then
5041 if FFirePainTime
<= 0 then
5043 if g_Game_IsServer
then
5044 Damage(5, FFireAttacker
, 0, 0, HIT_FLAME
);
5045 FFirePainTime
:= 18;
5047 FFirePainTime
:= FFirePainTime
- 1;
5048 FFireTime
:= FFireTime
- 1;
5049 if (FFireTime
= 0) and g_Game_IsNet
and g_Game_IsServer
then
5050 MH_SEND_PlayerStats(FUID
);
5054 if FDamageBuffer
> 0 then
5056 if FDamageBuffer
>= 9 then
5060 if FDamageBuffer
< 30 then i
:= 9
5061 else if FDamageBuffer
< 100 then i
:= 18
5065 ii
:= Round(FDamageBuffer
*FHealth
/ nonz(FArmor
*(3/4)+FHealth
));
5066 FArmor
:= FArmor
-(FDamageBuffer
-ii
);
5067 FHealth
:= FHealth
-ii
;
5070 FHealth
:= FHealth
+FArmor
;
5075 if FHealth
<= 0 then
5076 if FHealth
> -30 then Kill(K_SIMPLEKILL
, FLastSpawnerUID
, FLastHit
)
5077 else if FHealth
> -50 then Kill(K_HARDKILL
, FLastSpawnerUID
, FLastHit
)
5078 else Kill(K_EXTRAHARDKILL
, FLastSpawnerUID
, FLastHit
);
5082 if FDamageBuffer
<= 20 then FModel
.PlaySound(MODELSOUND_PAIN
, 1, FObj
.X
, FObj
.Y
)
5083 else if FDamageBuffer
<= 55 then FModel
.PlaySound(MODELSOUND_PAIN
, 2, FObj
.X
, FObj
.Y
)
5084 else if FDamageBuffer
<= 120 then FModel
.PlaySound(MODELSOUND_PAIN
, 3, FObj
.X
, FObj
.Y
)
5085 else FModel
.PlaySound(MODELSOUND_PAIN
, 4, FObj
.X
, FObj
.Y
);
5092 end; // if FAlive then ...
5094 if (FActionAnim
= A_PAIN
) and (FModel
.Animation
<> A_PAIN
) then
5096 FModel
.ChangeAnimation(FActionAnim
, FActionForce
);
5097 FModel
.GetCurrentAnimation
.MinLength
:= i
;
5098 FModel
.GetCurrentAnimationMask
.MinLength
:= i
;
5099 end else FModel
.ChangeAnimation(FActionAnim
, FActionForce
and (FModel
.Animation
<> A_STAND
));
5101 if (FModel
.GetCurrentAnimation
.Played
or ((not FActionChanged
) and (FModel
.Animation
= A_WALK
)))
5102 then SetAction(A_STAND
, True);
5104 if not ((FModel
.Animation
= A_WALK
) and (Abs(FObj
.Vel
.X
) < 4) and not FModel
.Fire
) then FModel
.Update
;
5106 for b
:= Low(FKeys
) to High(FKeys
) do
5107 if FKeys
[b
].Time
= 0 then FKeys
[b
].Pressed
:= False else Dec(FKeys
[b
].Time
);
5111 procedure TPlayer
.getMapBox (out x
, y
, w
, h
: Integer); inline;
5113 x
:= FObj
.X
+PLAYER_RECT
.X
;
5114 y
:= FObj
.Y
+PLAYER_RECT
.Y
;
5115 w
:= PLAYER_RECT
.Width
;
5116 h
:= PLAYER_RECT
.Height
;
5120 procedure TPlayer
.moveBy (dx
, dy
: Integer); inline;
5122 if (dx
<> 0) or (dy
<> 0) then
5131 function TPlayer
.Collide(X
, Y
: Integer; Width
, Height
: Word): Boolean;
5133 Result
:= g_Collide(FObj
.X
+PLAYER_RECT
.X
,
5134 FObj
.Y
+PLAYER_RECT
.Y
,
5141 function TPlayer
.Collide(Panel
: TPanel
): Boolean;
5143 Result
:= g_Collide(FObj
.X
+PLAYER_RECT
.X
,
5144 FObj
.Y
+PLAYER_RECT
.Y
,
5148 Panel
.Width
, Panel
.Height
);
5151 function TPlayer
.Collide(X
, Y
: Integer): Boolean;
5153 X
:= X
-FObj
.X
-PLAYER_RECT
.X
;
5154 Y
:= Y
-FObj
.Y
-PLAYER_RECT
.Y
;
5155 Result
:= (x
>= 0) and (x
<= PLAYER_RECT
.Width
) and
5156 (y
>= 0) and (y
<= PLAYER_RECT
.Height
);
5159 function g_Player_ValidName(Name
: string): Boolean;
5165 if gPlayers
= nil then Exit
;
5167 for a
:= 0 to High(gPlayers
) do
5168 if gPlayers
[a
] <> nil then
5169 if LowerCase(Name
) = LowerCase(gPlayers
[a
].FName
) then
5176 procedure TPlayer
.SetDirection(Direction
: TDirection
);
5180 d
:= FModel
.Direction
;
5182 FModel
.Direction
:= Direction
;
5183 if d
<> Direction
then FModel
.ChangeAnimation(FModel
.Animation
, True);
5185 FDirection
:= Direction
;
5188 function TPlayer
.GetKeys(): Byte;
5192 if R_KEY_RED
in FRulez
then Result
:= KEY_RED
;
5193 if R_KEY_GREEN
in FRulez
then Result
:= Result
or KEY_GREEN
;
5194 if R_KEY_BLUE
in FRulez
then Result
:= Result
or KEY_BLUE
;
5196 if FTeam
= TEAM_RED
then Result
:= Result
or KEY_REDTEAM
;
5197 if FTeam
= TEAM_BLUE
then Result
:= Result
or KEY_BLUETEAM
;
5200 procedure TPlayer
.Use();
5204 if FTime
[T_USE
] > gTime
then Exit
;
5206 g_Triggers_PressR(FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+PLAYER_RECT
.Y
, PLAYER_RECT
.Width
,
5207 PLAYER_RECT
.Height
, FUID
, ACTIVATE_PLAYERPRESS
);
5209 for a
:= 0 to High(gPlayers
) do
5210 if (gPlayers
[a
] <> nil) and (gPlayers
[a
] <> Self
) and
5211 gPlayers
[a
].alive
and SameTeam(FUID
, gPlayers
[a
].FUID
) and
5212 g_Obj_Collide(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
,
5213 FObj
.Rect
.Width
, FObj
.Rect
.Height
, @gPlayers
[a
].FObj
) then
5215 gPlayers
[a
].Touch();
5216 if g_Game_IsNet
and g_Game_IsServer
then
5217 MH_SEND_GameEvent(NET_EV_PLAYER_TOUCH
, gPlayers
[a
].FUID
);
5220 FTime
[T_USE
] := gTime
+120;
5223 procedure TPlayer
.NetFire(Wpn
: Byte; X
, Y
, AX
, AY
: Integer; WID
: Integer = -1);
5227 WX
, WY
, XD
, YD
: Integer;
5238 if R_BERSERK
in FRulez
then
5240 //g_Weapon_punch(FObj.X+FObj.Rect.X, FObj.Y+FObj.Rect.Y, 75, FUID);
5241 locobj
.X
:= FObj
.X
+FObj
.Rect
.X
;
5242 locobj
.Y
:= FObj
.Y
+FObj
.Rect
.Y
;
5245 locobj
.rect
.Width
:= 39;
5246 locobj
.rect
.Height
:= 52;
5247 locobj
.Vel
.X
:= (xd
-wx
) div 2;
5248 locobj
.Vel
.Y
:= (yd
-wy
) div 2;
5249 locobj
.Accel
.X
:= xd
-wx
;
5250 locobj
.Accel
.y
:= yd
-wy
;
5252 if g_Weapon_Hit(@locobj
, 50, FUID
, HIT_SOME
) <> 0 then
5253 g_Sound_PlayExAt('SOUND_WEAPON_HITBERSERK', FObj
.X
, FObj
.Y
)
5255 g_Sound_PlayExAt('SOUND_WEAPON_MISSBERSERK', FObj
.X
, FObj
.Y
);
5259 FPain
:= min(FPain
+ 25, 50);
5261 g_Weapon_punch(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
, 3, FUID
);
5266 if g_Weapon_chainsaw(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
,
5267 IfThen(gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
], 9, 3), FUID
) <> 0 then
5269 FSawSoundSelect
.Stop();
5271 FSawSoundHit
.PlayAt(FObj
.X
, FObj
.Y
);
5273 else if not FSawSoundHit
.IsPlaying() then
5275 FSawSoundSelect
.Stop();
5276 FSawSound
.PlayAt(FObj
.X
, FObj
.Y
);
5283 g_Sound_PlayExAt('SOUND_WEAPON_FIREPISTOL', GameX
, Gamey
);
5284 FFireAngle
:= FAngle
;
5286 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
5287 GameVelX
, GameVelY
-2, SHELL_BULLET
);
5292 g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN', Gamex
, Gamey
);
5293 FFireAngle
:= FAngle
;
5296 FShellType
:= SHELL_SHELL
;
5301 g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN2', Gamex
, Gamey
);
5302 FFireAngle
:= FAngle
;
5305 FShellType
:= SHELL_DBLSHELL
;
5310 g_Sound_PlayExAt('SOUND_WEAPON_FIRECGUN', Gamex
, Gamey
);
5311 FFireAngle
:= FAngle
;
5313 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
5314 GameVelX
, GameVelY
-2, SHELL_BULLET
);
5317 WEAPON_ROCKETLAUNCHER
:
5319 g_Weapon_Rocket(wx
, wy
, xd
, yd
, FUID
, WID
);
5320 FFireAngle
:= FAngle
;
5326 g_Weapon_Plasma(wx
, wy
, xd
, yd
, FUID
, WID
);
5327 FFireAngle
:= FAngle
;
5333 g_Weapon_BFGShot(wx
, wy
, xd
, yd
, FUID
, WID
);
5334 FFireAngle
:= FAngle
;
5338 WEAPON_SUPERPULEMET
:
5340 g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN', Gamex
, Gamey
);
5341 FFireAngle
:= FAngle
;
5343 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
5344 GameVelX
, GameVelY
-2, SHELL_SHELL
);
5347 WEAPON_FLAMETHROWER
:
5349 g_Weapon_flame(wx
, wy
, xd
, yd
, FUID
, WID
);
5350 FFireAngle
:= FAngle
;
5357 if (FAngle
= 0) or (FAngle
= 180) then SetAction(A_ATTACK
)
5358 else if (FAngle
= ANGLE_LEFTDOWN
) or (FAngle
= ANGLE_RIGHTDOWN
) then SetAction(A_ATTACKDOWN
)
5359 else if (FAngle
= ANGLE_LEFTUP
) or (FAngle
= ANGLE_RIGHTUP
) then SetAction(A_ATTACKUP
);
5362 procedure TPlayer
.DoLerp(Level
: Integer = 2);
5364 if FObj
.X
<> FXTo
then FObj
.X
:= Lerp(FObj
.X
, FXTo
, Level
);
5365 if FObj
.Y
<> FYTo
then FObj
.Y
:= Lerp(FObj
.Y
, FYTo
, Level
);
5368 procedure TPlayer
.SetLerp(XTo
, YTo
: Integer);
5372 if NetInterpLevel
< 1 then
5382 AX
:= Abs(FXTo
- FObj
.X
);
5383 AY
:= Abs(FYTo
- FObj
.Y
);
5384 if (AX
> 32) or (AX
<= NetInterpLevel
) then
5386 if (AY
> 32) or (AY
<= NetInterpLevel
) then
5391 function TPlayer
.FullInLift(XInc
, YInc
: Integer): Integer;
5393 if g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
,
5394 PLAYER_RECT
.Width
, PLAYER_RECT
.Height
-8,
5395 PANEL_LIFTUP
, False) then Result
:= -1
5397 if g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
,
5398 PLAYER_RECT
.Width
, PLAYER_RECT
.Height
-8,
5399 PANEL_LIFTDOWN
, False) then Result
:= 1
5403 function TPlayer
.GetFlag(Flag
: Byte): Boolean;
5410 if Flag
= FLAG_NONE
then
5413 if not g_Game_IsServer
then Exit
;
5415 // Ïðèíåñ ÷óæîé ôëàã íà ñâîþ áàçó:
5416 if (Flag
= FTeam
) and
5417 (gFlags
[Flag
].State
= FLAG_STATE_NORMAL
) and
5418 (FFlag
<> FLAG_NONE
) then
5420 if FFlag
= FLAG_RED
then
5421 s
:= _lc
[I_PLAYER_FLAG_RED
]
5423 s
:= _lc
[I_PLAYER_FLAG_BLUE
];
5425 evtype
:= FLAG_STATE_SCORED
;
5427 ts
:= Format('%.4d', [gFlags
[FFlag
].CaptureTime
]);
5428 Insert('.', ts
, Length(ts
) + 1 - 3);
5429 g_Console_Add(Format(_lc
[I_PLAYER_FLAG_CAPTURE
], [FName
, s
, ts
]), True);
5431 g_Map_ResetFlag(FFlag
);
5432 g_Game_Message(Format(_lc
[I_MESSAGE_FLAG_CAPTURE
], [AnsiUpperCase(s
)]), 144);
5434 gTeamStat
[FTeam
].Goals
:= gTeamStat
[FTeam
].Goals
+ 1;
5437 if g_Game_IsNet
then
5439 MH_SEND_FlagEvent(evtype
, FFlag
, FUID
, False);
5443 gFlags
[FFlag
].CaptureTime
:= 0;
5448 // Ïîäîáðàë ñâîé ôëàã - âåðíóë åãî íà áàçó:
5449 if (Flag
= FTeam
) and
5450 (gFlags
[Flag
].State
= FLAG_STATE_DROPPED
) then
5452 if Flag
= FLAG_RED
then
5453 s
:= _lc
[I_PLAYER_FLAG_RED
]
5455 s
:= _lc
[I_PLAYER_FLAG_BLUE
];
5457 evtype
:= FLAG_STATE_RETURNED
;
5458 gFlags
[Flag
].CaptureTime
:= 0;
5460 g_Console_Add(Format(_lc
[I_PLAYER_FLAG_RETURN
], [FName
, s
]), True);
5462 g_Map_ResetFlag(Flag
);
5463 g_Game_Message(Format(_lc
[I_MESSAGE_FLAG_RETURN
], [AnsiUpperCase(s
)]), 144);
5466 if g_Game_IsNet
then
5468 MH_SEND_FlagEvent(evtype
, Flag
, FUID
, False);
5474 // Ïîäîáðàë ÷óæîé ôëàã:
5475 if (Flag
<> FTeam
) and (FTime
[T_FLAGCAP
] <= gTime
) then
5479 if Flag
= FLAG_RED
then
5480 s
:= _lc
[I_PLAYER_FLAG_RED
]
5482 s
:= _lc
[I_PLAYER_FLAG_BLUE
];
5484 evtype
:= FLAG_STATE_CAPTURED
;
5486 g_Console_Add(Format(_lc
[I_PLAYER_FLAG_GET
], [FName
, s
]), True);
5488 g_Game_Message(Format(_lc
[I_MESSAGE_FLAG_GET
], [AnsiUpperCase(s
)]), 144);
5490 gFlags
[Flag
].State
:= FLAG_STATE_CAPTURED
;
5493 if g_Game_IsNet
then
5495 MH_SEND_FlagEvent(evtype
, Flag
, FUID
, False);
5501 procedure TPlayer
.SetFlag(Flag
: Byte);
5504 if FModel
<> nil then
5505 FModel
.SetFlag(FFlag
);
5508 function TPlayer
.DropFlag(): Boolean;
5513 if (not g_Game_IsServer
) or (FFlag
= FLAG_NONE
) then
5515 FTime
[T_FLAGCAP
] := gTime
+ 2000;
5516 with gFlags
[FFlag
] do
5520 Direction
:= FDirection
;
5521 State
:= FLAG_STATE_DROPPED
;
5523 g_Obj_Push(@Obj
, (FObj
.Vel
.X
div 2)-2+Random(5),
5524 (FObj
.Vel
.Y
div 2)-2+Random(5));
5525 positionChanged(); // this updates spatial accelerators
5527 if FFlag
= FLAG_RED
then
5528 s
:= _lc
[I_PLAYER_FLAG_RED
]
5530 s
:= _lc
[I_PLAYER_FLAG_BLUE
];
5532 g_Console_Add(Format(_lc
[I_PLAYER_FLAG_DROP
], [FName
, s
]), True);
5533 g_Game_Message(Format(_lc
[I_MESSAGE_FLAG_DROP
], [AnsiUpperCase(s
)]), 144);
5535 if g_Game_IsNet
then
5536 MH_SEND_FlagEvent(FLAG_STATE_DROPPED
, Flag
, FUID
, False);
5542 procedure TPlayer
.GetSecret();
5547 procedure TPlayer
.PressKey(Key
: Byte; Time
: Word = 1);
5549 Assert(Key
<= High(FKeys
));
5551 FKeys
[Key
].Pressed
:= True;
5552 FKeys
[Key
].Time
:= Time
;
5555 function TPlayer
.IsKeyPressed(K
: Byte): Boolean;
5557 Result
:= FKeys
[K
].Pressed
;
5560 procedure TPlayer
.ReleaseKeys();
5564 for a
:= Low(FKeys
) to High(FKeys
) do
5566 FKeys
[a
].Pressed
:= False;
5571 procedure TPlayer
.OnDamage(Angle
: SmallInt);
5575 function TPlayer
.firediry(): Integer;
5577 if FKeys
[KEY_UP
].Pressed
then Result
:= -42
5578 else if FKeys
[KEY_DOWN
].Pressed
then Result
:= 19
5582 procedure TPlayer
.RememberState();
5586 FSavedState
.Health
:= FHealth
;
5587 FSavedState
.Armor
:= FArmor
;
5588 FSavedState
.Air
:= FAir
;
5589 FSavedState
.JetFuel
:= FJetFuel
;
5590 FSavedState
.CurrWeap
:= FCurrWeap
;
5591 FSavedState
.NextWeap
:= FNextWeap
;
5592 FSavedState
.NextWeapDelay
:= FNextWeapDelay
;
5595 FSavedState
.Ammo
[i
] := FAmmo
[i
];
5597 FSavedState
.MaxAmmo
[i
] := FMaxAmmo
[i
];
5599 FSavedState
.Rulez
:= FRulez
;
5600 FSavedState
.WaitRecall
:= True;
5603 procedure TPlayer
.RecallState();
5607 if not FSavedState
.WaitRecall
then Exit
;
5609 FHealth
:= FSavedState
.Health
;
5610 FArmor
:= FSavedState
.Armor
;
5611 FAir
:= FSavedState
.Air
;
5612 FJetFuel
:= FSavedState
.JetFuel
;
5613 FCurrWeap
:= FSavedState
.CurrWeap
;
5614 FNextWeap
:= FSavedState
.NextWeap
;
5615 FNextWeapDelay
:= FSavedState
.NextWeapDelay
;
5618 FAmmo
[i
] := FSavedState
.Ammo
[i
];
5620 FMaxAmmo
[i
] := FSavedState
.MaxAmmo
[i
];
5622 FRulez
:= FSavedState
.Rulez
;
5623 FSavedState
.WaitRecall
:= False;
5625 if gGameSettings
.GameType
= GT_SERVER
then
5626 MH_SEND_PlayerStats(FUID
);
5629 procedure TPlayer
.SaveState(var Mem
: TBinMemoryWriter
);
5641 Mem
:= TBinMemoryWriter
.Create(i
);
5643 // Ñèãíàòóðà èãðîêà:
5644 sig
:= PLAYER_SIGNATURE
; // 'PLYR'
5645 Mem
.WriteDWORD(sig
);
5647 Mem
.WriteBoolean(FIamBot
);
5649 Mem
.WriteWord(FUID
);
5651 Mem
.WriteString(FName
, 32);
5653 Mem
.WriteByte(FTeam
);
5655 Mem
.WriteBoolean(FAlive
);
5656 // Èçðàñõîäîâàë ëè âñå æèçíè:
5657 Mem
.WriteBoolean(FNoRespawn
);
5659 if FDirection
= D_LEFT
then
5665 Mem
.WriteInt(FHealth
);
5667 Mem
.WriteByte(FLives
);
5669 Mem
.WriteInt(FArmor
);
5673 Mem
.WriteInt(FJetFuel
);
5675 Mem
.WriteInt(FPain
);
5677 Mem
.WriteInt(FKills
);
5679 Mem
.WriteInt(FMonsterKills
);
5681 Mem
.WriteInt(FFrags
);
5683 Mem
.WriteByte(FFragCombo
);
5684 // Âðåìÿ ïîñëåäíåãî ôðàãà:
5685 Mem
.WriteDWORD(FLastFrag
);
5687 Mem
.WriteInt(FDeath
);
5688 // Êàêîé ôëàã íåñåò:
5689 Mem
.WriteByte(FFlag
);
5691 Mem
.WriteInt(FSecrets
);
5693 Mem
.WriteByte(FCurrWeap
);
5695 Mem
.WriteWord(FNextWeap
);
5697 Mem
.WriteByte(FNextWeapDelay
);
5698 // Âðåìÿ çàðÿäêè BFG:
5699 Mem
.WriteSmallInt(FBFGFireCounter
);
5701 Mem
.WriteInt(FDamageBuffer
);
5702 // Ïîñëåäíèé óäàðèâøèé:
5703 Mem
.WriteWord(FLastSpawnerUID
);
5704 // Òèï ïîñëåäíåãî ïîëó÷åííîãî óðîíà:
5705 Mem
.WriteByte(FLastHit
);
5707 Obj_SaveState(@FObj
, Mem
);
5708 // Òåêóùåå êîëè÷åñòâî ïàòðîíîâ:
5709 for i
:= A_BULLETS
to A_HIGH
do
5710 Mem
.WriteWord(FAmmo
[i
]);
5711 // Ìàêñèìàëüíîå êîëè÷åñòâî ïàòðîíîâ:
5712 for i
:= A_BULLETS
to A_HIGH
do
5713 Mem
.WriteWord(FMaxAmmo
[i
]);
5715 for i
:= WP_FIRST
to WP_LAST
do
5716 Mem
.WriteBoolean(FWeapon
[i
]);
5717 // Âðåìÿ ïåðåçàðÿäêè îðóæèÿ:
5718 for i
:= WP_FIRST
to WP_LAST
do
5719 Mem
.WriteWord(FReloading
[i
]);
5721 if R_ITEM_BACKPACK
in FRulez
then
5726 // Íàëè÷èå êðàñíîãî êëþ÷à:
5727 if R_KEY_RED
in FRulez
then
5732 // Íàëè÷èå çåëåíîãî êëþ÷à:
5733 if R_KEY_GREEN
in FRulez
then
5738 // Íàëè÷èå ñèíåãî êëþ÷à:
5739 if R_KEY_BLUE
in FRulez
then
5744 // Íàëè÷èå áåðñåðêà:
5745 if R_BERSERK
in FRulez
then
5750 // Âðåìÿ äåéñòâèÿ ñïåöèàëüíûõ ïðåäìåòîâ:
5751 for i
:= MR_SUIT
to MR_MAX
do
5752 Mem
.WriteDWORD(FMegaRulez
[i
]);
5753 // Âðåìÿ äî ïîâòîðíîãî ðåñïàóíà, ñìåíû îðóæèÿ, èñîëüçîâàíèÿ, çàõâàòà ôëàãà:
5754 for i
:= T_RESPAWN
to T_FLAGCAP
do
5755 Mem
.WriteDWORD(FTime
[i
]);
5758 Mem
.WriteString(str
);
5768 procedure TPlayer
.LoadState(var Mem
: TBinMemoryReader
);
5778 // Ñèãíàòóðà èãðîêà:
5780 if sig
<> PLAYER_SIGNATURE
then // 'PLYR'
5782 raise EBinSizeError
.Create('TPlayer.LoadState: Wrong Player Signature');
5785 Mem
.ReadBoolean(FIamBot
);
5789 Mem
.ReadString(str
);
5790 if (Self
<> gPlayer1
) and (Self
<> gPlayer2
) then
5793 Mem
.ReadByte(FTeam
);
5795 Mem
.ReadBoolean(FAlive
);
5796 // Èçðàñõîäîâàë ëè âñå æèçíè:
5797 Mem
.ReadBoolean(FNoRespawn
);
5801 FDirection
:= D_LEFT
5803 FDirection
:= D_RIGHT
;
5805 Mem
.ReadInt(FHealth
);
5807 Mem
.ReadByte(FLives
);
5809 Mem
.ReadInt(FArmor
);
5813 Mem
.ReadInt(FJetFuel
);
5817 Mem
.ReadInt(FKills
);
5819 Mem
.ReadInt(FMonsterKills
);
5821 Mem
.ReadInt(FFrags
);
5823 Mem
.ReadByte(FFragCombo
);
5824 // Âðåìÿ ïîñëåäíåãî ôðàãà:
5825 Mem
.ReadDWORD(FLastFrag
);
5827 Mem
.ReadInt(FDeath
);
5828 // Êàêîé ôëàã íåñåò:
5829 Mem
.ReadByte(FFlag
);
5831 Mem
.ReadInt(FSecrets
);
5833 Mem
.ReadByte(FCurrWeap
);
5835 Mem
.ReadWord(FNextWeap
);
5837 Mem
.ReadByte(FNextWeapDelay
);
5838 // Âðåìÿ çàðÿäêè BFG:
5839 Mem
.ReadSmallInt(FBFGFireCounter
);
5841 Mem
.ReadInt(FDamageBuffer
);
5842 // Ïîñëåäíèé óäàðèâøèé:
5843 Mem
.ReadWord(FLastSpawnerUID
);
5844 // Òèï ïîñëåäíåãî ïîëó÷åííîãî óðîíà:
5845 Mem
.ReadByte(FLastHit
);
5847 Obj_LoadState(@FObj
, Mem
);
5848 // Òåêóùåå êîëè÷åñòâî ïàòðîíîâ:
5849 for i
:= A_BULLETS
to A_HIGH
do
5850 Mem
.ReadWord(FAmmo
[i
]);
5851 // Ìàêñèìàëüíîå êîëè÷åñòâî ïàòðîíîâ:
5852 for i
:= A_BULLETS
to A_HIGH
do
5853 Mem
.ReadWord(FMaxAmmo
[i
]);
5855 for i
:= WP_FIRST
to WP_LAST
do
5856 Mem
.ReadBoolean(FWeapon
[i
]);
5857 // Âðåìÿ ïåðåçàðÿäêè îðóæèÿ:
5858 for i
:= WP_FIRST
to WP_LAST
do
5859 Mem
.ReadWord(FReloading
[i
]);
5863 Include(FRulez
, R_ITEM_BACKPACK
);
5864 // Íàëè÷èå êðàñíîãî êëþ÷à:
5867 Include(FRulez
, R_KEY_RED
);
5868 // Íàëè÷èå çåëåíîãî êëþ÷à:
5871 Include(FRulez
, R_KEY_GREEN
);
5872 // Íàëè÷èå ñèíåãî êëþ÷à:
5875 Include(FRulez
, R_KEY_BLUE
);
5876 // Íàëè÷èå áåðñåðêà:
5879 Include(FRulez
, R_BERSERK
);
5880 // Âðåìÿ äåéñòâèÿ ñïåöèàëüíûõ ïðåäìåòîâ:
5881 for i
:= MR_SUIT
to MR_MAX
do
5882 Mem
.ReadDWORD(FMegaRulez
[i
]);
5883 // Âðåìÿ äî ïîâòîðíîãî ðåñïàóíà, ñìåíû îðóæèÿ, èñîëüçîâàíèÿ, çàõâàòà ôëàãà:
5884 for i
:= T_RESPAWN
to T_FLAGCAP
do
5885 Mem
.ReadDWORD(FTime
[i
]);
5887 Mem
.ReadString(str
);
5889 Mem
.ReadByte(FColor
.R
);
5890 Mem
.ReadByte(FColor
.G
);
5891 Mem
.ReadByte(FColor
.B
);
5892 if Self
= gPlayer1
then
5894 str
:= gPlayer1Settings
.Model
;
5895 FColor
:= gPlayer1Settings
.Color
;
5897 if Self
= gPlayer2
then
5899 str
:= gPlayer2Settings
.Model
;
5900 FColor
:= gPlayer2Settings
.Color
;
5902 // Îáíîâëÿåì ìîäåëü èãðîêà:
5904 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
5905 FModel
.Color
:= TEAMCOLOR
[FTeam
]
5907 FModel
.Color
:= FColor
;
5910 procedure TPlayer
.AllRulez(Health
: Boolean);
5916 FHealth
:= PLAYER_HP_LIMIT
;
5917 FArmor
:= PLAYER_AP_LIMIT
;
5921 for a
:= WP_FIRST
to WP_LAST
do FWeapon
[a
] := True;
5922 for a
:= A_BULLETS
to A_HIGH
do FAmmo
[a
] := 30000;
5923 FRulez
:= FRulez
+[R_KEY_RED
, R_KEY_GREEN
, R_KEY_BLUE
];
5926 procedure TPlayer
.RestoreHealthArmor();
5928 FHealth
:= PLAYER_HP_LIMIT
;
5929 FArmor
:= PLAYER_AP_LIMIT
;
5932 procedure TPlayer
.FragCombo();
5936 if (gGameSettings
.GameMode
in [GM_COOP
, GM_SINGLE
]) or g_Game_IsClient
then
5938 if gTime
- FLastFrag
< FRAG_COMBO_TIME
then
5940 if FFragCombo
< 5 then
5942 Param
:= FUID
or (FFragCombo
shl 16);
5943 if (FComboEvnt
>= Low(gDelayedEvents
)) and
5944 (FComboEvnt
<= High(gDelayedEvents
)) and
5945 gDelayedEvents
[FComboEvnt
].Pending
and
5946 (gDelayedEvents
[FComboEvnt
].DEType
= DE_KILLCOMBO
) and
5947 (gDelayedEvents
[FComboEvnt
].DENum
and $FFFF = FUID
) then
5949 gDelayedEvents
[FComboEvnt
].Time
:= gTime
+ 500;
5950 gDelayedEvents
[FComboEvnt
].DENum
:= Param
;
5953 FComboEvnt
:= g_Game_DelayEvent(DE_KILLCOMBO
, 500, Param
);
5961 procedure TPlayer
.GiveItem(ItemType
: Byte);
5965 if FMegaRulez
[MR_SUIT
] < gTime
+PLAYER_SUIT_TIME
then
5967 FMegaRulez
[MR_SUIT
] := gTime
+PLAYER_SUIT_TIME
;
5971 if FAir
< AIR_MAX
then
5978 if not (R_BERSERK
in FRulez
) then
5980 Include(FRulez
, R_BERSERK
);
5981 if FBFGFireCounter
< 1 then
5983 FCurrWeap
:= WEAPON_KASTET
;
5985 FModel
.SetWeapon(WEAPON_KASTET
);
5989 FBerserk
:= gTime
+30000;
5991 if FHealth
< PLAYER_HP_SOFT
then
5993 FHealth
:= PLAYER_HP_SOFT
;
5994 FBerserk
:= gTime
+30000;
5999 if FMegaRulez
[MR_INVUL
] < gTime
+PLAYER_INVUL_TIME
then
6001 FMegaRulez
[MR_INVUL
] := gTime
+PLAYER_INVUL_TIME
;
6005 if FMegaRulez
[MR_INVIS
] < gTime
+PLAYER_INVIS_TIME
then
6007 FMegaRulez
[MR_INVIS
] := gTime
+PLAYER_INVIS_TIME
;
6011 if FJetFuel
< JET_MAX
then
6013 FJetFuel
:= JET_MAX
;
6016 ITEM_MEDKIT_SMALL
: if FHealth
< PLAYER_HP_SOFT
then IncMax(FHealth
, 10, PLAYER_HP_SOFT
);
6017 ITEM_MEDKIT_LARGE
: if FHealth
< PLAYER_HP_SOFT
then IncMax(FHealth
, 25, PLAYER_HP_SOFT
);
6019 ITEM_ARMOR_GREEN
: if FArmor
< PLAYER_AP_SOFT
then FArmor
:= PLAYER_AP_SOFT
;
6020 ITEM_ARMOR_BLUE
: if FArmor
< PLAYER_AP_LIMIT
then FArmor
:= PLAYER_AP_LIMIT
;
6022 ITEM_SPHERE_BLUE
: if FHealth
< PLAYER_HP_LIMIT
then IncMax(FHealth
, 100, PLAYER_HP_LIMIT
);
6024 if (FHealth
< PLAYER_HP_LIMIT
) or (FArmor
< PLAYER_AP_LIMIT
) then
6026 if FHealth
< PLAYER_HP_LIMIT
then FHealth
:= PLAYER_HP_LIMIT
;
6027 if FArmor
< PLAYER_AP_LIMIT
then FArmor
:= PLAYER_AP_LIMIT
;
6030 ITEM_WEAPON_SAW
: FWeapon
[WEAPON_SAW
] := True;
6031 ITEM_WEAPON_SHOTGUN1
: FWeapon
[WEAPON_SHOTGUN1
] := True;
6032 ITEM_WEAPON_SHOTGUN2
: FWeapon
[WEAPON_SHOTGUN2
] := True;
6033 ITEM_WEAPON_CHAINGUN
: FWeapon
[WEAPON_CHAINGUN
] := True;
6034 ITEM_WEAPON_ROCKETLAUNCHER
: FWeapon
[WEAPON_ROCKETLAUNCHER
] := True;
6035 ITEM_WEAPON_PLASMA
: FWeapon
[WEAPON_PLASMA
] := True;
6036 ITEM_WEAPON_BFG
: FWeapon
[WEAPON_BFG
] := True;
6037 ITEM_WEAPON_SUPERPULEMET
: FWeapon
[WEAPON_SUPERPULEMET
] := True;
6038 ITEM_WEAPON_FLAMETHROWER
: FWeapon
[WEAPON_FLAMETHROWER
] := True;
6040 ITEM_AMMO_BULLETS
: if FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
] then IncMax(FAmmo
[A_BULLETS
], 10, FMaxAmmo
[A_BULLETS
]);
6041 ITEM_AMMO_BULLETS_BOX
: if FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
] then IncMax(FAmmo
[A_BULLETS
], 50, FMaxAmmo
[A_BULLETS
]);
6042 ITEM_AMMO_SHELLS
: if FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
] then IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
6043 ITEM_AMMO_SHELLS_BOX
: if FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
] then IncMax(FAmmo
[A_SHELLS
], 25, FMaxAmmo
[A_SHELLS
]);
6044 ITEM_AMMO_ROCKET
: if FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
] then IncMax(FAmmo
[A_ROCKETS
], 1, FMaxAmmo
[A_ROCKETS
]);
6045 ITEM_AMMO_ROCKET_BOX
: if FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
] then IncMax(FAmmo
[A_ROCKETS
], 5, FMaxAmmo
[A_ROCKETS
]);
6046 ITEM_AMMO_CELL
: if FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
] then IncMax(FAmmo
[A_CELLS
], 40, FMaxAmmo
[A_CELLS
]);
6047 ITEM_AMMO_CELL_BIG
: if FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
] then IncMax(FAmmo
[A_CELLS
], 100, FMaxAmmo
[A_CELLS
]);
6048 ITEM_AMMO_FUELCAN
: if FAmmo
[A_FUEL
] < FMaxAmmo
[A_FUEL
] then IncMax(FAmmo
[A_FUEL
], 100, FMaxAmmo
[A_FUEL
]);
6051 if (FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
]) or
6052 (FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
]) or
6053 (FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
]) or
6054 (FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
]) or
6055 (FMaxAmmo
[A_FUEL
] < AmmoLimits
[1, A_FUEL
]) then
6057 FMaxAmmo
[A_BULLETS
] := AmmoLimits
[1, A_BULLETS
];
6058 FMaxAmmo
[A_SHELLS
] := AmmoLimits
[1, A_SHELLS
];
6059 FMaxAmmo
[A_ROCKETS
] := AmmoLimits
[1, A_ROCKETS
];
6060 FMaxAmmo
[A_CELLS
] := AmmoLimits
[1, A_CELLS
];
6061 FMaxAmmo
[A_FUEL
] := AmmoLimits
[1, A_FUEL
];
6063 if FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
] then IncMax(FAmmo
[A_BULLETS
], 10, FMaxAmmo
[A_BULLETS
]);
6064 if FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
] then IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
6065 if FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
] then IncMax(FAmmo
[A_ROCKETS
], 1, FMaxAmmo
[A_ROCKETS
]);
6066 if FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
] then IncMax(FAmmo
[A_CELLS
], 40, FMaxAmmo
[A_CELLS
]);
6068 FRulez
:= FRulez
+ [R_ITEM_BACKPACK
];
6071 ITEM_KEY_RED
: if not (R_KEY_RED
in FRulez
) then Include(FRulez
, R_KEY_RED
);
6072 ITEM_KEY_GREEN
: if not (R_KEY_GREEN
in FRulez
) then Include(FRulez
, R_KEY_GREEN
);
6073 ITEM_KEY_BLUE
: if not (R_KEY_BLUE
in FRulez
) then Include(FRulez
, R_KEY_BLUE
);
6075 ITEM_BOTTLE
: if FHealth
< PLAYER_HP_LIMIT
then IncMax(FHealth
, 4, PLAYER_HP_LIMIT
);
6076 ITEM_HELMET
: if FArmor
< PLAYER_AP_LIMIT
then IncMax(FArmor
, 5, PLAYER_AP_LIMIT
);
6081 if g_Game_IsNet
and g_Game_IsServer
then
6082 MH_SEND_PlayerStats(FUID
);
6085 procedure TPlayer
.FlySmoke(Times
: DWORD
= 1);
6090 if (Random(5) = 1) and (Times
= 1) then
6093 if BodyInLiquid(0, 0) then
6095 g_GFX_Bubbles(Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2)+Random(3)-1,
6096 Obj
.Y
+Obj
.Rect
.Height
+8, 1, 8, 4);
6097 if Random(2) = 0 then
6098 g_Sound_PlayExAt('SOUND_GAME_BUBBLE1', FObj
.X
, FObj
.Y
)
6100 g_Sound_PlayExAt('SOUND_GAME_BUBBLE2', FObj
.X
, FObj
.Y
);
6104 if g_Frames_Get(id
, 'FRAMES_SMOKE') then
6106 for i
:= 1 to Times
do
6108 Anim
:= TAnimation
.Create(id
, False, 3);
6110 g_GFX_OnceAnim(Obj
.X
+Obj
.Rect
.X
+Random(Obj
.Rect
.Width
+Times
*2)-(Anim
.Width
div 2),
6111 Obj
.Y
+Obj
.Rect
.Height
-4+Random(8+Times
*2), Anim
, ONCEANIM_SMOKE
);
6117 procedure TPlayer
.OnFireFlame(Times
: DWORD
= 1);
6122 if (Random(10) = 1) and (Times
= 1) then
6125 if g_Frames_Get(id
, 'FRAMES_FLAME') then
6127 for i
:= 1 to Times
do
6129 Anim
:= TAnimation
.Create(id
, False, 3);
6131 g_GFX_OnceAnim(Obj
.X
+Obj
.Rect
.X
+Random(Obj
.Rect
.Width
+Times
*2)-(Anim
.Width
div 2),
6132 Obj
.Y
+8+Random(8+Times
*2), Anim
, ONCEANIM_SMOKE
);
6138 procedure TPlayer
.PauseSounds(Enable
: Boolean);
6140 FSawSound
.Pause(Enable
);
6141 FSawSoundIdle
.Pause(Enable
);
6142 FSawSoundHit
.Pause(Enable
);
6143 FSawSoundSelect
.Pause(Enable
);
6148 constructor TCorpse
.Create(X
, Y
: Integer; ModelName
: String; aMess
: Boolean);
6153 FObj
.Rect
:= PLAYER_CORPSERECT
;
6154 FModelName
:= ModelName
;
6159 FState
:= CORPSE_STATE_MESS
;
6160 g_PlayerModel_GetAnim(ModelName
, A_DIE2
, FAnimation
, FAnimationMask
);
6164 FState
:= CORPSE_STATE_NORMAL
;
6165 g_PlayerModel_GetAnim(ModelName
, A_DIE1
, FAnimation
, FAnimationMask
);
6169 destructor TCorpse
.Destroy();
6176 function TCorpse
.ObjPtr (): PObj
; inline; begin result
:= @FObj
; end;
6178 procedure TCorpse
.positionChanged (); inline; begin end;
6180 procedure TCorpse
.moveBy (dx
, dy
: Integer); inline;
6182 if (dx
<> 0) or (dy
<> 0) then
6191 procedure TCorpse
.getMapBox (out x
, y
, w
, h
: Integer); inline;
6193 x
:= FObj
.X
+PLAYER_CORPSERECT
.X
;
6194 y
:= FObj
.Y
+PLAYER_CORPSERECT
.Y
;
6195 w
:= PLAYER_CORPSERECT
.Width
;
6196 h
:= PLAYER_CORPSERECT
.Height
;
6200 procedure TCorpse
.Damage(Value
: Word; vx
, vy
: Integer);
6204 if FState
= CORPSE_STATE_REMOVEME
then
6207 FDamage
:= FDamage
+ Value
;
6209 if FDamage
> 150 then
6211 if FAnimation
<> nil then
6216 FState
:= CORPSE_STATE_REMOVEME
;
6218 g_Player_CreateGibs(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
6219 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2),
6220 FModelName
, FColor
);
6221 // Çâóê ìÿñà îò òðóïà:
6222 pm
:= g_PlayerModel_Get(FModelName
);
6223 pm
.PlaySound(MODELSOUND_DIE
, 5, FObj
.X
, FObj
.Y
);
6229 FObj
.Vel
.X
:= FObj
.Vel
.X
+ vx
;
6230 FObj
.Vel
.Y
:= FObj
.Vel
.Y
+ vy
;
6231 g_GFX_Blood(FObj
.X
+PLAYER_CORPSERECT
.X
+(PLAYER_CORPSERECT
.Width
div 2),
6232 FObj
.Y
+PLAYER_CORPSERECT
.Y
+(PLAYER_CORPSERECT
.Height
div 2),
6233 Value
, vx
, vy
, 16, (PLAYER_CORPSERECT
.Height
*2) div 3,
6238 procedure TCorpse
.Draw();
6240 if FState
= CORPSE_STATE_REMOVEME
then
6243 if FAnimation
<> nil then
6244 FAnimation
.Draw(FObj
.X
, FObj
.Y
, M_NONE
);
6246 if FAnimationMask
<> nil then
6249 FAnimationMask
.Draw(FObj
.X
, FObj
.Y
, M_NONE
);
6256 procedure TCorpse
.Update();
6260 if FState
= CORPSE_STATE_REMOVEME
then
6263 if gTime
mod (GAME_TICK
*2) <> 0 then
6265 g_Obj_Move(@FObj
, True, True, True);
6266 positionChanged(); // this updates spatial accelerators
6270 // Ñîïðîòèâëåíèå âîçäóõà äëÿ òðóïà:
6271 FObj
.Vel
.X
:= z_dec(FObj
.Vel
.X
, 1);
6273 st
:= g_Obj_Move(@FObj
, True, True, True);
6274 positionChanged(); // this updates spatial accelerators
6276 if WordBool(st
and MOVE_FALLOUT
) then
6278 FState
:= CORPSE_STATE_REMOVEME
;
6282 if FAnimation
<> nil then
6283 FAnimation
.Update();
6284 if FAnimationMask
<> nil then
6285 FAnimationMask
.Update();
6288 procedure TCorpse
.SaveState(var Mem
: TBinMemoryWriter
);
6297 sig
:= CORPSE_SIGNATURE
; // 'CORP'
6298 Mem
.WriteDWORD(sig
);
6300 Mem
.WriteByte(FState
);
6301 // Íàêîïëåííûé óðîí:
6302 Mem
.WriteByte(FDamage
);
6304 Mem
.WriteByte(FColor
.R
);
6305 Mem
.WriteByte(FColor
.G
);
6306 Mem
.WriteByte(FColor
.B
);
6308 Obj_SaveState(@FObj
, Mem
);
6309 // Åñòü ëè àíèìàöèÿ:
6310 anim
:= FAnimation
<> nil;
6311 Mem
.WriteBoolean(anim
);
6312 // Åñëè åñòü - ñîõðàíÿåì:
6314 FAnimation
.SaveState(Mem
);
6315 // Åñòü ëè ìàñêà àíèìàöèè:
6316 anim
:= FAnimationMask
<> nil;
6317 Mem
.WriteBoolean(anim
);
6318 // Åñëè åñòü - ñîõðàíÿåì:
6320 FAnimationMask
.SaveState(Mem
);
6323 procedure TCorpse
.LoadState(var Mem
: TBinMemoryReader
);
6333 if sig
<> CORPSE_SIGNATURE
then // 'CORP'
6335 raise EBinSizeError
.Create('TCorpse.LoadState: Wrong Corpse Signature');
6338 Mem
.ReadByte(FState
);
6339 // Íàêîïëåííûé óðîí:
6340 Mem
.ReadByte(FDamage
);
6342 Mem
.ReadByte(FColor
.R
);
6343 Mem
.ReadByte(FColor
.G
);
6344 Mem
.ReadByte(FColor
.B
);
6346 Obj_LoadState(@FObj
, Mem
);
6347 // Åñòü ëè àíèìàöèÿ:
6348 Mem
.ReadBoolean(anim
);
6349 // Åñëè åñòü - çàãðóæàåì:
6352 Assert(FAnimation
<> nil, 'TCorpse.LoadState: no FAnimation');
6353 FAnimation
.LoadState(Mem
);
6355 // Åñòü ëè ìàñêà àíèìàöèè:
6356 Mem
.ReadBoolean(anim
);
6357 // Åñëè åñòü - çàãðóæàåì:
6360 Assert(FAnimationMask
<> nil, 'TCorpse.LoadState: no FAnimationMask');
6361 FAnimationMask
.LoadState(Mem
);
6367 constructor TBot
.Create();
6374 FSpectator
:= False;
6381 for a
:= WP_FIRST
to WP_LAST
do
6383 FDifficult
.WeaponPrior
[a
] := WEAPON_PRIOR1
[a
];
6384 FDifficult
.CloseWeaponPrior
[a
] := WEAPON_PRIOR2
[a
];
6385 //FDifficult.SafeWeaponPrior[a] := WEAPON_PRIOR3[a];
6389 destructor TBot
.Destroy();
6392 inherited Destroy();
6395 procedure TBot
.Draw();
6399 //if FTargetUID <> 0 then e_DrawLine(1, FObj.X, FObj.Y, g_Player_Get(FTargetUID).FObj.X,
6400 // g_Player_Get(FTargetUID).FObj.Y, 255, 0, 0);
6403 procedure TBot
.Respawn(Silent
: Boolean; Force
: Boolean = False);
6405 inherited Respawn(Silent
, Force
);
6408 FSelectedWeapon
:= FCurrWeap
;
6413 procedure TBot
.UpdateCombat();
6426 TTargetRecord
= array of TTarget
;
6428 function Compare(a
, b
: TTarget
): Integer;
6430 if a
.Line
and not b
.Line
then // A íà ëèíèè îãíÿ
6433 if not a
.Line
and b
.Line
then // B íà ëèíèè îãíÿ
6435 else // È A, è B íà ëèíèè èëè íå íà ëèíèè îãíÿ
6436 if (a
.Line
and b
.Line
) or ((not a
.Line
) and (not b
.Line
)) then
6438 if a
.Dist
> b
.Dist
then // B áëèæå
6440 else // A áëèæå èëè ðàâíîóäàëåííî ñ B
6443 else // Ñòðàííî -> A
6448 a
, x1
, y1
, x2
, y2
: Integer;
6449 targets
: TTargetRecord
;
6451 Target
, BestTarget
: TTarget
;
6452 firew
, fireh
: Integer;
6456 vsPlayer
, vsMonster
, ok
: Boolean;
6459 function monsUpdate (mon
: TMonster
): Boolean;
6461 result
:= false; // don't stop
6462 if mon
.alive
and (mon
.MonsterType
<> MONSTER_BARREL
) then
6464 if not TargetOnScreen(mon
.Obj
.X
+mon
.Obj
.Rect
.X
, mon
.Obj
.Y
+mon
.Obj
.Rect
.Y
) then exit
;
6466 x2
:= mon
.Obj
.X
+mon
.Obj
.Rect
.X
+(mon
.Obj
.Rect
.Width
div 2);
6467 y2
:= mon
.Obj
.Y
+mon
.Obj
.Rect
.Y
+(mon
.Obj
.Rect
.Height
div 2);
6469 // Åñëè ìîíñòð íà ýêðàíå è íå ïðèêðûò ñòåíîé
6470 if g_TraceVector(x1
, y1
, x2
, y2
) then
6472 // Äîáàâëÿåì ê ñïèñêó âîçìîæíûõ öåëåé
6473 SetLength(targets
, Length(targets
)+1);
6474 with targets
[High(targets
)] do
6481 Rect
:= mon
.Obj
.Rect
;
6482 Dist
:= g_PatchLength(x1
, y1
, x2
, y2
);
6483 Line
:= (y1
+4 < Target
.Y
+ mon
.Obj
.Rect
.Y
+ mon
.Obj
.Rect
.Height
) and
6484 (y1
-4 > Target
.Y
+ mon
.Obj
.Rect
.Y
);
6493 vsPlayer
:= LongBool(gGameSettings
.Options
and GAME_OPTION_BOTVSPLAYER
);
6494 vsMonster
:= LongBool(gGameSettings
.Options
and GAME_OPTION_BOTVSMONSTER
);
6496 // Åñëè òåêóùåå îðóæèå íå òî, ÷òî íóæíî, òî ìåíÿåì:
6497 if FCurrWeap
<> FSelectedWeapon
then
6500 // Åñëè íóæíî ñòðåëÿòü è íóæíîå îðóæèå, òî íàæàòü "Ñòðåëÿòü":
6501 if (GetAIFlag('NEEDFIRE') <> '') and (FCurrWeap
= FSelectedWeapon
) then
6503 RemoveAIFlag('NEEDFIRE');
6506 WEAPON_PLASMA
, WEAPON_SUPERPULEMET
, WEAPON_CHAINGUN
: PressKey(KEY_FIRE
, 20);
6507 WEAPON_SAW
, WEAPON_KASTET
, WEAPON_FLAMETHROWER
: PressKey(KEY_FIRE
, 40);
6508 else PressKey(KEY_FIRE
);
6512 // Êîîðäèíàòû ñòâîëà:
6513 x1
:= FObj
.X
+ WEAPONPOINT
[FDirection
].X
;
6514 y1
:= FObj
.Y
+ WEAPONPOINT
[FDirection
].Y
;
6516 Target
.UID
:= FTargetUID
;
6519 if Target
.UID
<> 0 then
6520 begin // Öåëü åñòü - íàñòðàèâàåì
6521 if (g_GetUIDType(Target
.UID
) = UID_PLAYER
) and
6524 tpla
:= g_Player_Get(Target
.UID
);
6528 if (@FObj
) <> nil then
6535 Target
.cX
:= Target
.X
+ PLAYER_RECT_CX
;
6536 Target
.cY
:= Target
.Y
+ PLAYER_RECT_CY
;
6537 Target
.Rect
:= PLAYER_RECT
;
6538 Target
.Visible
:= g_TraceVector(x1
, y1
, Target
.cX
, Target
.cY
);
6539 Target
.Line
:= (y1
+4 < Target
.Y
+PLAYER_RECT
.Y
+PLAYER_RECT
.Height
) and
6540 (y1
-4 > Target
.Y
+PLAYER_RECT
.Y
);
6541 Target
.IsPlayer
:= True;
6545 if (g_GetUIDType(Target
.UID
) = UID_MONSTER
) and
6548 mon
:= g_Monsters_ByUID(Target
.UID
);
6551 Target
.X
:= mon
.Obj
.X
;
6552 Target
.Y
:= mon
.Obj
.Y
;
6554 Target
.cX
:= Target
.X
+ mon
.Obj
.Rect
.X
+ (mon
.Obj
.Rect
.Width
div 2);
6555 Target
.cY
:= Target
.Y
+ mon
.Obj
.Rect
.Y
+ (mon
.Obj
.Rect
.Height
div 2);
6556 Target
.Rect
:= mon
.Obj
.Rect
;
6557 Target
.Visible
:= g_TraceVector(x1
, y1
, Target
.cX
, Target
.cY
);
6558 Target
.Line
:= (y1
+4 < Target
.Y
+ mon
.Obj
.Rect
.Y
+ mon
.Obj
.Rect
.Height
) and
6559 (y1
-4 > Target
.Y
+ mon
.Obj
.Rect
.Y
);
6560 Target
.IsPlayer
:= False;
6567 begin // Öåëè íåò - îáíóëÿåì
6572 Target
.Visible
:= False;
6573 Target
.Line
:= False;
6574 Target
.IsPlayer
:= False;
6579 // Åñëè öåëü íå âèäèìà èëè íå íà ëèíèè îãíÿ, òî èùåì âñå âîçìîæíûå öåëè:
6580 if (not Target
.Line
) or (not Target
.Visible
) then
6584 for a
:= 0 to High(gPlayers
) do
6585 if (gPlayers
[a
] <> nil) and (gPlayers
[a
].alive
) and
6586 (gPlayers
[a
].FUID
<> FUID
) and
6587 (not SameTeam(FUID
, gPlayers
[a
].FUID
)) and
6588 (not gPlayers
[a
].NoTarget
) and
6589 (gPlayers
[a
].FMegaRulez
[MR_INVIS
] < gTime
) then
6591 if not TargetOnScreen(gPlayers
[a
].FObj
.X
+ PLAYER_RECT
.X
,
6592 gPlayers
[a
].FObj
.Y
+ PLAYER_RECT
.Y
) then
6595 x2
:= gPlayers
[a
].FObj
.X
+ PLAYER_RECT_CX
;
6596 y2
:= gPlayers
[a
].FObj
.Y
+ PLAYER_RECT_CY
;
6598 // Åñëè èãðîê íà ýêðàíå è íå ïðèêðûò ñòåíîé:
6599 if g_TraceVector(x1
, y1
, x2
, y2
) then
6601 // Äîáàâëÿåì ê ñïèñêó âîçìîæíûõ öåëåé:
6602 SetLength(targets
, Length(targets
)+1);
6603 with targets
[High(targets
)] do
6605 UID
:= gPlayers
[a
].FUID
;
6606 X
:= gPlayers
[a
].FObj
.X
;
6607 Y
:= gPlayers
[a
].FObj
.Y
;
6610 Rect
:= PLAYER_RECT
;
6611 Dist
:= g_PatchLength(x1
, y1
, x2
, y2
);
6612 Line
:= (y1
+4 < Target
.Y
+PLAYER_RECT
.Y
+PLAYER_RECT
.Height
) and
6613 (y1
-4 > Target
.Y
+PLAYER_RECT
.Y
);
6621 if vsMonster
then g_Mons_ForEach(monsUpdate
);
6624 // Åñëè åñòü âîçìîæíûå öåëè:
6625 // (Âûáèðàåì ëó÷øóþ, ìåíÿåì îðóæèå è áåæèì ê íåé/îò íåå)
6626 if targets
<> nil then
6628 // Âûáèðàåì íàèëó÷øóþ öåëü:
6629 BestTarget
:= targets
[0];
6630 if Length(targets
) > 1 then
6631 for a
:= 1 to High(targets
) do
6632 if Compare(BestTarget
, targets
[a
]) = 1 then
6633 BestTarget
:= targets
[a
];
6635 // Åñëè ëó÷øàÿ öåëü "âèäíåå" òåêóùåé, òî òåêóùàÿ := ëó÷øàÿ:
6636 if ((not Target
.Visible
) and BestTarget
.Visible
and (Target
.UID
<> BestTarget
.UID
)) or
6637 ((not Target
.Line
) and BestTarget
.Line
and BestTarget
.Visible
) then
6639 Target
:= BestTarget
;
6641 if (Healthy() = 3) or ((Healthy() = 2)) then
6642 begin // Åñëè çäîðîâû - äîãîíÿåì
6643 if ((RunDirection() = D_LEFT
) and (Target
.X
> FObj
.X
)) then
6644 SetAIFlag('GORIGHT', '1');
6645 if ((RunDirection() = D_RIGHT
) and (Target
.X
< FObj
.X
)) then
6646 SetAIFlag('GOLEFT', '1');
6649 begin // Åñëè ïîáèòû - óáåãàåì
6650 if ((RunDirection() = D_LEFT
) and (Target
.X
< FObj
.X
)) then
6651 SetAIFlag('GORIGHT', '1');
6652 if ((RunDirection() = D_RIGHT
) and (Target
.X
> FObj
.X
)) then
6653 SetAIFlag('GOLEFT', '1');
6656 // Âûáèðàåì îðóæèå íà îñíîâå ðàññòîÿíèÿ è ïðèîðèòåòîâ:
6657 SelectWeapon(Abs(x1
-Target
.cX
));
6662 // (Äîãîíÿåì/óáåãàåì, ñòðåëÿåì ïî íàïðàâëåíèþ ê öåëè)
6663 // (Åñëè öåëü äàëåêî, òî õâàòèò ñëåäèòü çà íåé)
6664 if Target
.UID
<> 0 then
6666 if not TargetOnScreen(Target
.X
+ Target
.Rect
.X
,
6667 Target
.Y
+ Target
.Rect
.Y
) then
6668 begin // Öåëü ñáåæàëà ñ "ýêðàíà"
6669 if (Healthy() = 3) or ((Healthy() = 2)) then
6670 begin // Åñëè çäîðîâû - äîãîíÿåì
6671 if ((RunDirection() = D_LEFT
) and (Target
.X
> FObj
.X
)) then
6672 SetAIFlag('GORIGHT', '1');
6673 if ((RunDirection() = D_RIGHT
) and (Target
.X
< FObj
.X
)) then
6674 SetAIFlag('GOLEFT', '1');
6677 begin // Åñëè ïîáèòû - çàáûâàåì î öåëè è óáåãàåì
6679 if ((RunDirection() = D_LEFT
) and (Target
.X
< FObj
.X
)) then
6680 SetAIFlag('GORIGHT', '1');
6681 if ((RunDirection() = D_RIGHT
) and (Target
.X
> FObj
.X
)) then
6682 SetAIFlag('GOLEFT', '1');
6686 begin // Öåëü ïîêà íà "ýêðàíå"
6687 // Åñëè öåëü íå çàãîðîæåíà ñòåíîé, òî îòìå÷àåì, êîãäà åå âèäåëè:
6688 if g_TraceVector(x1
, y1
, Target
.cX
, Target
.cY
) then
6689 FLastVisible
:= gTime
;
6690 // Åñëè ðàçíèöà âûñîò íå âåëèêà, òî äîãîíÿåì:
6691 if (Abs(FObj
.Y
-Target
.Y
) <= 128) then
6693 if ((RunDirection() = D_LEFT
) and (Target
.X
> FObj
.X
)) then
6694 SetAIFlag('GORIGHT', '1');
6695 if ((RunDirection() = D_RIGHT
) and (Target
.X
< FObj
.X
)) then
6696 SetAIFlag('GOLEFT', '1');
6700 // Âûáèðàåì óãîë ââåðõ:
6701 if FDirection
= D_LEFT
then
6702 angle
:= ANGLE_LEFTUP
6704 angle
:= ANGLE_RIGHTUP
;
6706 firew
:= Trunc(Cos(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
6707 fireh
:= Trunc(Sin(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
6709 // Åñëè ïðè óãëå ââåðõ ìîæíî ïîïàñòü â ïðèáëèçèòåëüíîå ïîëîæåíèå öåëè:
6710 if g_CollideLine(x1
, y1
, x1
+firew
, y1
+fireh
,
6711 Target
.X
+Target
.Rect
.X
+GetInterval(FDifficult
.DiagPrecision
, 128), //96
6712 Target
.Y
+Target
.Rect
.Y
+GetInterval(FDifficult
.DiagPrecision
, 128),
6713 Target
.Rect
.Width
, Target
.Rect
.Height
) and
6714 g_TraceVector(x1
, y1
, Target
.cX
, Target
.cY
) then
6715 begin // òî íóæíî ñòðåëÿòü ââåðõ
6716 SetAIFlag('NEEDFIRE', '1');
6717 SetAIFlag('NEEDSEEUP', '1');
6720 // Âûáèðàåì óãîë âíèç:
6721 if FDirection
= D_LEFT
then
6722 angle
:= ANGLE_LEFTDOWN
6724 angle
:= ANGLE_RIGHTDOWN
;
6726 firew
:= Trunc(Cos(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
6727 fireh
:= Trunc(Sin(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
6729 // Åñëè ïðè óãëå âíèç ìîæíî ïîïàñòü â ïðèáëèçèòåëüíîå ïîëîæåíèå öåëè:
6730 if g_CollideLine(x1
, y1
, x1
+firew
, y1
+fireh
,
6731 Target
.X
+Target
.Rect
.X
+GetInterval(FDifficult
.DiagPrecision
, 128),
6732 Target
.Y
+Target
.Rect
.Y
+GetInterval(FDifficult
.DiagPrecision
, 128),
6733 Target
.Rect
.Width
, Target
.Rect
.Height
) and
6734 g_TraceVector(x1
, y1
, Target
.cX
, Target
.cY
) then
6735 begin // òî íóæíî ñòðåëÿòü âíèç
6736 SetAIFlag('NEEDFIRE', '1');
6737 SetAIFlag('NEEDSEEDOWN', '1');
6740 // Åñëè öåëü âèäíî è îíà íà òàêîé æå âûñîòå:
6741 if Target
.Visible
and
6742 (y1
+4 < Target
.Y
+Target
.Rect
.Y
+Target
.Rect
.Height
) and
6743 (y1
-4 > Target
.Y
+Target
.Rect
.Y
) then
6745 // Åñëè èäåì â ñòîðîíó öåëè, òî íàäî ñòðåëÿòü:
6746 if ((FDirection
= D_LEFT
) and (Target
.X
< FObj
.X
)) or
6747 ((FDirection
= D_RIGHT
) and (Target
.X
> FObj
.X
)) then
6748 begin // òî íóæíî ñòðåëÿòü âïåðåä
6749 SetAIFlag('NEEDFIRE', '1');
6750 SetAIFlag('NEEDSEEDOWN', '');
6751 SetAIFlag('NEEDSEEUP', '');
6753 // Åñëè öåëü â ïðåäåëàõ "ýêðàíà" è ñëîæíîñòü ïîçâîëÿåò ïðûæêè ñáëèæåíèÿ:
6754 if Abs(FObj
.X
-Target
.X
) < Trunc(gPlayerScreenSize
.X
*0.75) then
6755 if GetRnd(FDifficult
.CloseJump
) then
6756 begin // òî åñëè ïîâåçåò - ïðûãàåì (îñîáåííî, åñëè áëèçêî)
6757 if Abs(FObj
.X
-Target
.X
) < 128 then
6761 if Random(a
) = 0 then
6762 SetAIFlag('NEEDJUMP', '1');
6766 // Åñëè öåëü âñå åùå åñòü:
6767 if Target
.UID
<> 0 then
6768 if gTime
-FLastVisible
> 2000 then // Åñëè âèäåëè äàâíî
6769 Target
.UID
:= 0 // òî çàáûòü öåëü
6770 else // Åñëè âèäåëè íåäàâíî
6771 begin // íî öåëü óáèëè
6772 if Target
.IsPlayer
then
6773 begin // Öåëü - èãðîê
6774 pla
:= g_Player_Get(Target
.UID
);
6775 if (pla
= nil) or (not pla
.alive
) or pla
.NoTarget
or
6776 (pla
.FMegaRulez
[MR_INVIS
] >= gTime
) then
6777 Target
.UID
:= 0; // òî çàáûòü öåëü
6780 begin // Öåëü - ìîíñòð
6781 mon
:= g_Monsters_ByUID(Target
.UID
);
6782 if (mon
= nil) or (not mon
.alive
) then
6783 Target
.UID
:= 0; // òî çàáûòü öåëü
6786 end; // if Target.UID <> 0
6788 FTargetUID
:= Target
.UID
;
6790 // Åñëè âîçìîæíûõ öåëåé íåò:
6791 // (Àòàêà ÷åãî-íèáóäü ñëåâà èëè ñïðàâà)
6792 if targets
= nil then
6793 if GetAIFlag('ATTACKLEFT') <> '' then
6794 begin // Åñëè íóæíî àòàêîâàòü íàëåâî
6795 RemoveAIFlag('ATTACKLEFT');
6797 SetAIFlag('NEEDJUMP', '1');
6799 if RunDirection() = D_RIGHT
then
6800 begin // Èäåì íå â òó ñòîðîíó
6801 if (Healthy() > 1) and GetRnd(FDifficult
.InvisFire
) then
6802 begin // Åñëè çäîðîâû, òî, âîçìîæíî, ñòðåëÿåì áåæèì âëåâî è ñòðåëÿåì
6803 SetAIFlag('NEEDFIRE', '1');
6804 SetAIFlag('GOLEFT', '1');
6808 begin // Èäåì â íóæíóþ ñòîðîíó
6809 if GetRnd(FDifficult
.InvisFire
) then // Âîçìîæíî, ñòðåëÿåì âñëåïóþ
6810 SetAIFlag('NEEDFIRE', '1');
6811 if Healthy() <= 1 then // Ïîáèòû - óáåãàåì
6812 SetAIFlag('GORIGHT', '1');
6816 if GetAIFlag('ATTACKRIGHT') <> '' then
6817 begin // Åñëè íóæíî àòàêîâàòü íàïðàâî
6818 RemoveAIFlag('ATTACKRIGHT');
6820 SetAIFlag('NEEDJUMP', '1');
6822 if RunDirection() = D_LEFT
then
6823 begin // Èäåì íå â òó ñòîðîíó
6824 if (Healthy() > 1) and GetRnd(FDifficult
.InvisFire
) then
6825 begin // Åñëè çäîðîâû, òî, âîçìîæíî, áåæèì âïðàâî è ñòðåëÿåì
6826 SetAIFlag('NEEDFIRE', '1');
6827 SetAIFlag('GORIGHT', '1');
6832 if GetRnd(FDifficult
.InvisFire
) then // Âîçìîæíî, ñòðåëÿåì âñëåïóþ
6833 SetAIFlag('NEEDFIRE', '1');
6834 if Healthy() <= 1 then // Ïîáèòû - óáåãàåì
6835 SetAIFlag('GOLEFT', '1');
6839 //HACK! (does it belongs there?)
6840 RealizeCurrentWeapon();
6842 // Åñëè åñòü âîçìîæíûå öåëè:
6843 // (Ñòðåëÿåì ïî íàïðàâëåíèþ ê öåëÿì)
6844 if (targets
<> nil) and (GetAIFlag('NEEDFIRE') <> '') then
6845 for a
:= 0 to High(targets
) do
6847 // Åñëè ìîæåì ñòðåëÿòü ïî äèàãîíàëè:
6848 if GetRnd(FDifficult
.DiagFire
) then
6850 // Èùåì öåëü ñâåðõó è ñòðåëÿåì, åñëè åñòü:
6851 if FDirection
= D_LEFT
then
6852 angle
:= ANGLE_LEFTUP
6854 angle
:= ANGLE_RIGHTUP
;
6856 firew
:= Trunc(Cos(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
6857 fireh
:= Trunc(Sin(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
6859 if g_CollideLine(x1
, y1
, x1
+firew
, y1
+fireh
,
6860 targets
[a
].X
+targets
[a
].Rect
.X
+GetInterval(FDifficult
.DiagPrecision
, 128),
6861 targets
[a
].Y
+targets
[a
].Rect
.Y
+GetInterval(FDifficult
.DiagPrecision
, 128),
6862 targets
[a
].Rect
.Width
, targets
[a
].Rect
.Height
) and
6863 g_TraceVector(x1
, y1
, targets
[a
].cX
, targets
[a
].cY
) then
6865 SetAIFlag('NEEDFIRE', '1');
6866 SetAIFlag('NEEDSEEUP', '1');
6869 // Èùåì öåëü ñíèçó è ñòðåëÿåì, åñëè åñòü:
6870 if FDirection
= D_LEFT
then
6871 angle
:= ANGLE_LEFTDOWN
6873 angle
:= ANGLE_RIGHTDOWN
;
6875 firew
:= Trunc(Cos(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
6876 fireh
:= Trunc(Sin(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
6878 if g_CollideLine(x1
, y1
, x1
+firew
, y1
+fireh
,
6879 targets
[a
].X
+targets
[a
].Rect
.X
+GetInterval(FDifficult
.DiagPrecision
, 128),
6880 targets
[a
].Y
+targets
[a
].Rect
.Y
+GetInterval(FDifficult
.DiagPrecision
, 128),
6881 targets
[a
].Rect
.Width
, targets
[a
].Rect
.Height
) and
6882 g_TraceVector(x1
, y1
, targets
[a
].cX
, targets
[a
].cY
) then
6884 SetAIFlag('NEEDFIRE', '1');
6885 SetAIFlag('NEEDSEEDOWN', '1');
6889 // Åñëè öåëü "ïåðåä íîñîì", òî ñòðåëÿåì:
6890 if targets
[a
].Line
and targets
[a
].Visible
and
6891 (((FDirection
= D_LEFT
) and (targets
[a
].X
< FObj
.X
)) or
6892 ((FDirection
= D_RIGHT
) and (targets
[a
].X
> FObj
.X
))) then
6894 SetAIFlag('NEEDFIRE', '1');
6899 // Åñëè ëåòèò ïóëÿ, òî, âîçìîæíî, ïîäïðûãèâàåì:
6900 if g_Weapon_Danger(FUID
, FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+PLAYER_RECT
.Y
,
6901 PLAYER_RECT
.Width
, PLAYER_RECT
.Height
,
6902 40+GetInterval(FDifficult
.Cover
, 40)) then
6903 SetAIFlag('NEEDJUMP', '1');
6905 // Åñëè êîí÷èëèñü ïàòîðíû, òî íóæíî ñìåíèòü îðóæèå:
6906 ammo
:= GetAmmoByWeapon(FCurrWeap
);
6907 if ((FCurrWeap
= WEAPON_SHOTGUN2
) and (ammo
< 2)) or
6908 ((FCurrWeap
= WEAPON_BFG
) and (ammo
< 40)) or
6910 SetAIFlag('SELECTWEAPON', '1');
6912 // Åñëè íóæíî ñìåíèòü îðóæèå, òî âûáèðàåì íóæíîå:
6913 if GetAIFlag('SELECTWEAPON') = '1' then
6916 RemoveAIFlag('SELECTWEAPON');
6920 procedure TBot
.Update();
6933 // Ïðîâåðÿåì, îòêëþ÷¸í ëè AI áîòîâ
6934 if (g_debug_BotAIOff
= 1) and (Team
= TEAM_RED
) then
6936 if (g_debug_BotAIOff
= 2) and (Team
= TEAM_BLUE
) then
6938 if g_debug_BotAIOff
= 3 then
6948 RealizeCurrentWeapon();
6955 procedure TBot
.ReleaseKey(Key
: Byte);
6964 function TBot
.KeyPressed(Key
: Word): Boolean;
6966 Result
:= FKeys
[Key
].Pressed
;
6969 function TBot
.GetAIFlag(aName
: String20
): String20
;
6975 aName
:= LowerCase(aName
);
6977 if FAIFlags
<> nil then
6978 for a
:= 0 to High(FAIFlags
) do
6979 if LowerCase(FAIFlags
[a
].Name
) = aName
then
6981 Result
:= FAIFlags
[a
].Value
;
6986 procedure TBot
.RemoveAIFlag(aName
: String20
);
6990 if FAIFlags
= nil then Exit
;
6992 aName
:= LowerCase(aName
);
6994 for a
:= 0 to High(FAIFlags
) do
6995 if LowerCase(FAIFlags
[a
].Name
) = aName
then
6997 if a
<> High(FAIFlags
) then
6998 for b
:= a
to High(FAIFlags
)-1 do
6999 FAIFlags
[b
] := FAIFlags
[b
+1];
7001 SetLength(FAIFlags
, Length(FAIFlags
)-1);
7006 procedure TBot
.SetAIFlag(aName
, fValue
: String20
);
7014 aName
:= LowerCase(aName
);
7016 if FAIFlags
<> nil then
7017 for a
:= 0 to High(FAIFlags
) do
7018 if LowerCase(FAIFlags
[a
].Name
) = aName
then
7024 if ok
then FAIFlags
[a
].Value
:= fValue
7027 SetLength(FAIFlags
, Length(FAIFlags
)+1);
7028 with FAIFlags
[High(FAIFlags
)] do
7036 procedure TBot
.UpdateMove
;
7038 procedure GoLeft(Time
: Word = 1);
7040 ReleaseKey(KEY_LEFT
);
7041 ReleaseKey(KEY_RIGHT
);
7042 PressKey(KEY_LEFT
, Time
);
7043 SetDirection(D_LEFT
);
7046 procedure GoRight(Time
: Word = 1);
7048 ReleaseKey(KEY_LEFT
);
7049 ReleaseKey(KEY_RIGHT
);
7050 PressKey(KEY_RIGHT
, Time
);
7051 SetDirection(D_RIGHT
);
7054 function Rnd(a
: Word): Boolean;
7056 Result
:= Random(a
) = 0;
7059 procedure Turn(Time
: Word = 1200);
7061 if RunDirection() = D_LEFT
then GoRight(Time
) else GoLeft(Time
);
7066 ReleaseKey(KEY_LEFT
);
7067 ReleaseKey(KEY_RIGHT
);
7070 function CanRunLeft(): Boolean;
7072 Result
:= not CollideLevel(-1, 0);
7075 function CanRunRight(): Boolean;
7077 Result
:= not CollideLevel(1, 0);
7080 function CanRun(): Boolean;
7082 if RunDirection() = D_LEFT
then Result
:= CanRunLeft() else Result
:= CanRunRight();
7085 procedure Jump(Time
: Word = 30);
7087 PressKey(KEY_JUMP
, Time
);
7090 function NearHole(): Boolean;
7094 { TODO 5 : Ëåñòíèöû }
7095 sx
:= IfThen(RunDirection() = D_LEFT
, -1, 1);
7096 for x
:= 1 to PLAYER_RECT
.Width
do
7097 if (not StayOnStep(x
*sx
, 0)) and
7098 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
)) and
7099 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
*2)) then
7108 function BorderHole(): Boolean;
7112 { TODO 5 : Ëåñòíèöû }
7113 sx
:= IfThen(RunDirection() = D_LEFT
, -1, 1);
7114 for x
:= 1 to PLAYER_RECT
.Width
do
7115 if (not StayOnStep(x
*sx
, 0)) and
7116 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
)) and
7117 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
*2)) then
7119 for xx
:= x
to x
+32 do
7120 if CollideLevel(xx
*sx
, PLAYER_RECT
.Height
) then
7130 function NearDeepHole(): Boolean;
7136 sx
:= IfThen(RunDirection() = D_LEFT
, -1, 1);
7139 for x
:= 1 to PLAYER_RECT
.Width
do
7140 if (not StayOnStep(x
*sx
, 0)) and
7141 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
)) and
7142 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
*2)) then
7144 while FObj
.Y
+y
*PLAYER_RECT
.Height
< gMapInfo
.Height
do
7146 if CollideLevel(x
*sx
, PLAYER_RECT
.Height
*y
) then Exit
;
7151 end else Result
:= False;
7154 function OverDeepHole(): Boolean;
7161 while FObj
.Y
+y
*PLAYER_RECT
.Height
< gMapInfo
.Height
do
7163 if CollideLevel(0, PLAYER_RECT
.Height
*y
) then Exit
;
7170 function OnGround(): Boolean;
7172 Result
:= StayOnStep(0, 0) or CollideLevel(0, 1);
7175 function OnLadder(): Boolean;
7177 Result
:= FullInStep(0, 0);
7180 function BelowLadder(): Boolean;
7182 Result
:= (FullInStep(IfThen(RunDirection() = D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -PLAYER_RECT
.Height
) and
7183 not CollideLevel(IfThen(RunDirection() = D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -PLAYER_RECT
.Height
)) or
7184 (FullInStep(IfThen(RunDirection() = D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -BOT_MAXJUMP
) and
7185 not CollideLevel(IfThen(RunDirection() = D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -BOT_MAXJUMP
));
7188 function BelowLiftUp(): Boolean;
7190 Result
:= ((FullInLift(IfThen(RunDirection() = D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -PLAYER_RECT
.Height
) = -1) and
7191 not CollideLevel(IfThen(RunDirection() = D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -PLAYER_RECT
.Height
)) or
7192 ((FullInLift(IfThen(RunDirection() = D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -BOT_MAXJUMP
) = -1) and
7193 not CollideLevel(IfThen(RunDirection() = D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -BOT_MAXJUMP
));
7196 function OnTopLift(): Boolean;
7198 Result
:= (FullInLift(0, 0) = -1) and (FullInLift(0, -32) = 0);
7201 function CanJumpOver(): Boolean;
7205 sx
:= IfThen(RunDirection() = D_LEFT
, -1, 1);
7209 if not CollideLevel(sx
, 0) then Exit
;
7211 for y
:= 1 to BOT_MAXJUMP
do
7212 if CollideLevel(0, -y
) then Exit
else
7213 if not CollideLevel(sx
, -y
) then
7220 function CanJumpUp(Dist
: ShortInt): Boolean;
7227 if CollideLevel(Dist
, 0) then Exit
;
7230 for y
:= 0 to BOT_MAXJUMP
do
7231 if CollideLevel(Dist
, -y
) then
7240 for yy
:= y
+1 to BOT_MAXJUMP
do
7241 if not CollideLevel(Dist
, -yy
) then
7250 for y
:= 0 to BOT_MAXJUMP
do
7251 if CollideLevel(0, -y
) then
7259 if y
< yy
then Exit
;
7264 function IsSafeTrigger(): Boolean;
7269 if gTriggers
= nil then
7271 for a
:= 0 to High(gTriggers
) do
7272 if Collide(gTriggers
[a
].X
,
7275 gTriggers
[a
].Height
) and
7276 (gTriggers
[a
].TriggerType
in [TRIGGER_EXIT
, TRIGGER_CLOSEDOOR
,
7277 TRIGGER_CLOSETRAP
, TRIGGER_TRAP
,
7278 TRIGGER_PRESS
, TRIGGER_ON
, TRIGGER_OFF
,
7279 TRIGGER_ONOFF
, TRIGGER_SPAWNMONSTER
,
7280 TRIGGER_DAMAGE
, TRIGGER_SHOT
]) then
7285 // Âîçìîæíî, íàæèìàåì êíîïêó:
7286 if Rnd(16) and IsSafeTrigger() then
7289 // Åñëè ïîä ëèôòîì èëè ñòóïåíüêàìè, òî, âîçìîæíî, ïðûãàåì:
7290 if OnLadder() or ((BelowLadder() or BelowLiftUp()) and Rnd(8)) then
7292 ReleaseKey(KEY_LEFT
);
7293 ReleaseKey(KEY_RIGHT
);
7297 // Èäåì âëåâî, åñëè íàäî áûëî:
7298 if GetAIFlag('GOLEFT') <> '' then
7300 RemoveAIFlag('GOLEFT');
7301 if CanRunLeft() then
7305 // Èäåì âïðàâî, åñëè íàäî áûëî:
7306 if GetAIFlag('GORIGHT') <> '' then
7308 RemoveAIFlag('GORIGHT');
7309 if CanRunRight() then
7313 // Åñëè âûëåòåëè çà êàðòó, òî ïðîáóåì âåðíóòüñÿ:
7314 if FObj
.X
< -32 then
7317 if FObj
.X
+32 > gMapInfo
.Width
then
7320 // Ïðûãàåì, åñëè íàäî áûëî:
7321 if GetAIFlag('NEEDJUMP') <> '' then
7324 RemoveAIFlag('NEEDJUMP');
7327 // Ñìîòðèì ââåðõ, åñëè íàäî áûëî:
7328 if GetAIFlag('NEEDSEEUP') <> '' then
7331 ReleaseKey(KEY_DOWN
);
7332 PressKey(KEY_UP
, 20);
7333 RemoveAIFlag('NEEDSEEUP');
7336 // Ñìîòðèì âíèç, åñëè íàäî áûëî:
7337 if GetAIFlag('NEEDSEEDOWN') <> '' then
7340 ReleaseKey(KEY_DOWN
);
7341 PressKey(KEY_DOWN
, 20);
7342 RemoveAIFlag('NEEDSEEDOWN');
7345 // Åñëè íóæíî áûëî â äûðó è ìû íå íà çåìëå, òî ïîêîðíî ëåòèì:
7346 if GetAIFlag('GOINHOLE') <> '' then
7347 if not OnGround() then
7349 ReleaseKey(KEY_LEFT
);
7350 ReleaseKey(KEY_RIGHT
);
7351 RemoveAIFlag('GOINHOLE');
7352 SetAIFlag('FALLINHOLE', '1');
7355 // Åñëè ïàäàëè è äîñòèãëè çåìëè, òî õâàòèò ïàäàòü:
7356 if GetAIFlag('FALLINHOLE') <> '' then
7358 RemoveAIFlag('FALLINHOLE');
7360 // Åñëè ëåòåëè ïðÿìî è ñåé÷àñ íå íà ëåñòíèöå èëè íà âåðøèíå ëèôòà, òî îòõîäèì â ñòîðîíó:
7361 if not (KeyPressed(KEY_LEFT
) or KeyPressed(KEY_RIGHT
)) then
7362 if GetAIFlag('FALLINHOLE') = '' then
7363 if (not OnLadder()) or (FObj
.Vel
.Y
>= 0) or (OnTopLift()) then
7369 // Åñëè íà çåìëå è ìîæíî ïîäïðûãíóòü, òî, âîçìîæíî, ïðûãàåì:
7371 CanJumpUp(IfThen(RunDirection() = D_LEFT
, -1, 1)*32) and
7375 // Åñëè íà çåìëå è âîçëå äûðû (ãëóáèíà > 2 ðîñòîâ èãðîêà):
7376 if OnGround() and NearHole() then
7377 if NearDeepHole() then // Åñëè ýòî áåçäíà
7379 0..3: Turn(); // Áåæèì îáðàòíî
7380 4: Jump(); // Ïðûãàåì
7381 5: begin // Ïðûãàåì îáðàòíî
7386 else // Ýòî íå áåçäíà è ìû åùå íå ëåòèì òóäà
7387 if GetAIFlag('GOINHOLE') = '' then
7389 0: Turn(); // Íå íóæíî òóäà
7390 1: Jump(); // Âäðóã ïîâåçåò - ïðûãàåì
7391 else // Åñëè ÿìà ñ ãðàíèöåé, òî ïðè ñëó÷àå ìîæíî òóäà ïðûãíóòü
7392 if BorderHole() then
7393 SetAIFlag('GOINHOLE', '1');
7396 // Åñëè íà çåìëå, íî íåêóäà èäòè:
7397 if (not CanRun()) and OnGround() then
7399 // Åñëè ìû íà ëåñòíèöå èëè ìîæíî ïåðåïðûãíóòü, òî ïðûãàåì:
7400 if CanJumpOver() or OnLadder() then
7402 else // èíà÷å ïîïûòàåìñÿ â äðóãóþ ñòîðîíó
7403 if Random(2) = 0 then
7405 if IsSafeTrigger() then
7411 // Îñòàëîñü ìàëî âîçäóõà:
7412 if FAir
< 36 * 2 then
7415 // Âûáèðàåìñÿ èç êèñëîòû, åñëè íåò êîñòþìà, îáîæãëèñü, èëè ìàëî çäîðîâüÿ:
7416 if (FMegaRulez
[MR_SUIT
] < gTime
) and ((FLastHit
= HIT_ACID
) or (Healthy() <= 1)) then
7417 if BodyInAcid(0, 0) then
7421 function TBot
.FullInStep(XInc
, YInc
: Integer): Boolean;
7423 Result
:= g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
,
7424 PLAYER_RECT
.Width
, PLAYER_RECT
.Height
, PANEL_STEP
, False);
7427 {function TBot.NeedItem(Item: Byte): Byte;
7432 procedure TBot
.SelectWeapon(Dist
: Integer);
7436 function HaveAmmo(weapon
: Byte): Boolean;
7439 WEAPON_PISTOL
: Result
:= FAmmo
[A_BULLETS
] >= 1;
7440 WEAPON_SHOTGUN1
: Result
:= FAmmo
[A_SHELLS
] >= 1;
7441 WEAPON_SHOTGUN2
: Result
:= FAmmo
[A_SHELLS
] >= 2;
7442 WEAPON_CHAINGUN
: Result
:= FAmmo
[A_BULLETS
] >= 10;
7443 WEAPON_ROCKETLAUNCHER
: Result
:= FAmmo
[A_ROCKETS
] >= 1;
7444 WEAPON_PLASMA
: Result
:= FAmmo
[A_CELLS
] >= 10;
7445 WEAPON_BFG
: Result
:= FAmmo
[A_CELLS
] >= 40;
7446 WEAPON_SUPERPULEMET
: Result
:= FAmmo
[A_SHELLS
] >= 1;
7447 WEAPON_FLAMETHROWER
: Result
:= FAmmo
[A_FUEL
] >= 1;
7448 else Result
:= True;
7453 if Dist
= -1 then Dist
:= BOT_LONGDIST
;
7455 if Dist
> BOT_LONGDIST
then
7456 begin // Äàëüíèé áîé
7458 if FWeapon
[FDifficult
.WeaponPrior
[a
]] and HaveAmmo(FDifficult
.WeaponPrior
[a
]) then
7460 FSelectedWeapon
:= FDifficult
.WeaponPrior
[a
];
7464 else //if Dist > BOT_UNSAFEDIST then
7465 begin // Áëèæíèé áîé
7467 if FWeapon
[FDifficult
.CloseWeaponPrior
[a
]] and HaveAmmo(FDifficult
.CloseWeaponPrior
[a
]) then
7469 FSelectedWeapon
:= FDifficult
.CloseWeaponPrior
[a
];
7476 if FWeapon[FDifficult.SafeWeaponPrior[a]] and HaveAmmo(FDifficult.SafeWeaponPrior[a]) then
7478 FSelectedWeapon := FDifficult.SafeWeaponPrior[a];
7484 function TBot
.PickItem(ItemType
: Byte; force
: Boolean; var remove
: Boolean): Boolean;
7486 Result
:= inherited PickItem(ItemType
, force
, remove
);
7488 if Result
then SetAIFlag('SELECTWEAPON', '1');
7491 function TBot
.Heal(value
: Word; Soft
: Boolean): Boolean;
7493 Result
:= inherited Heal(value
, Soft
);
7496 function TBot
.Healthy(): Byte;
7498 if FMegaRulez
[MR_INVUL
] >= gTime
then Result
:= 3
7499 else if (FHealth
> 80) or ((FHealth
> 50) and (FArmor
> 20)) then Result
:= 3
7500 else if (FHealth
> 50) then Result
:= 2
7501 else if (FHealth
> 20) then Result
:= 1
7505 function TBot
.TargetOnScreen(TX
, TY
: Integer): Boolean;
7507 Result
:= (Abs(FObj
.X
-TX
) <= Trunc(gPlayerScreenSize
.X
*0.6)) and
7508 (Abs(FObj
.Y
-TY
) <= Trunc(gPlayerScreenSize
.Y
*0.6));
7511 procedure TBot
.OnDamage(Angle
: SmallInt);
7519 if (Angle
= 0) or (Angle
= 180) then
7522 if (g_GetUIDType(FLastSpawnerUID
) = UID_PLAYER
) and
7523 LongBool(gGameSettings
.Options
and GAME_OPTION_BOTVSPLAYER
) then
7525 pla
:= g_Player_Get(FLastSpawnerUID
);
7526 ok
:= not TargetOnScreen(pla
.FObj
.X
+ PLAYER_RECT
.X
,
7527 pla
.FObj
.Y
+ PLAYER_RECT
.Y
);
7530 if (g_GetUIDType(FLastSpawnerUID
) = UID_MONSTER
) and
7531 LongBool(gGameSettings
.Options
and GAME_OPTION_BOTVSMONSTER
) then
7533 mon
:= g_Monsters_ByUID(FLastSpawnerUID
);
7534 ok
:= not TargetOnScreen(mon
.Obj
.X
+ mon
.Obj
.Rect
.X
,
7535 mon
.Obj
.Y
+ mon
.Obj
.Rect
.Y
);
7540 SetAIFlag('ATTACKLEFT', '1')
7542 SetAIFlag('ATTACKRIGHT', '1');
7546 function TBot
.RunDirection(): TDirection
;
7548 if Abs(Vel
.X
) >= 1 then
7550 if Vel
.X
> 0 then Result
:= D_RIGHT
else Result
:= D_LEFT
;
7552 Result
:= FDirection
;
7555 function TBot
.GetRnd(a
: Byte): Boolean;
7557 if a
= 0 then Result
:= False
7558 else if a
= 255 then Result
:= True
7559 else Result
:= Random(256) > 255-a
;
7562 function TBot
.GetInterval(a
: Byte; radius
: SmallInt): SmallInt;
7564 Result
:= Round((255-a
)/255*radius
*(Random(2)-1));
7567 procedure TBot
.SaveState(var Mem
: TBinMemoryWriter
);
7573 inherited SaveState(Mem
);
7575 // Âûáðàííîå îðóæèå:
7576 Mem
.WriteByte(FSelectedWeapon
);
7578 Mem
.WriteWord(FTargetUID
);
7579 // Âðåìÿ ïîòåðè öåëè:
7580 Mem
.WriteDWORD(FLastVisible
);
7581 // Êîëè÷åñòâî ôëàãîâ ÈÈ:
7582 dw
:= Length(FAIFlags
);
7585 for i
:= 0 to Integer(dw
)-1 do
7587 Mem
.WriteString(FAIFlags
[i
].Name
, 20);
7588 Mem
.WriteString(FAIFlags
[i
].Value
, 20);
7590 // Íàñòðîéêè ñëîæíîñòè:
7592 Mem
.WriteMemory(p
, SizeOf(TDifficult
));
7595 procedure TBot
.LoadState(var Mem
: TBinMemoryReader
);
7601 inherited LoadState(Mem
);
7603 // Âûáðàííîå îðóæèå:
7604 Mem
.ReadByte(FSelectedWeapon
);
7606 Mem
.ReadWord(FTargetUID
);
7607 // Âðåìÿ ïîòåðè öåëè:
7608 Mem
.ReadDWORD(FLastVisible
);
7609 // Êîëè÷åñòâî ôëàãîâ ÈÈ:
7611 SetLength(FAIFlags
, dw
);
7613 for i
:= 0 to Integer(dw
)-1 do
7615 Mem
.ReadString(FAIFlags
[i
].Name
);
7616 Mem
.ReadString(FAIFlags
[i
].Value
);
7618 // Íàñòðîéêè ñëîæíîñòè:
7619 Mem
.ReadMemory(p
, dw
);
7620 if dw
<> SizeOf(TDifficult
) then
7622 raise EBinSizeError
.Create('TBot.LoadState: Wrong FDifficult Size');
7624 FDifficult
:= TDifficult(p
^);
7629 conRegVar('cheat_berserk_autoswitch', @gBerserkAutoswitch
, 'autoswitch to fist when berserk pack taken', '', true, true);