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}
22 e_graphics
, g_playermodel
, g_basic
, g_textures
,
23 g_weapons
, g_phys
, g_sound
, g_saveload
, MAPSTRUCT
,
56 AmmoLimits
: Array [0..1] of Array [A_BULLETS
..A_HIGH
] of Word =
57 ((200, 50, 50, 300, 100),
58 (400, 100, 100, 600, 200));
79 ANGLE_NONE
= Low(SmallInt);
81 CORPSE_STATE_REMOVEME
= 0;
82 CORPSE_STATE_NORMAL
= 1;
83 CORPSE_STATE_MESS
= 2;
85 PLAYER_RECT
: TRectWH
= (X
:15; Y
:12; Width
:34; Height
:52);
86 PLAYER_RECT_CX
= 15+(34 div 2);
87 PLAYER_RECT_CY
= 12+(52 div 2);
88 PLAYER_CORPSERECT
: TRectWH
= (X
:15; Y
:48; Width
:34; Height
:16);
91 PLAYER_HP_LIMIT
= 200;
93 PLAYER_AP_LIMIT
= 200;
96 PLAYER1_DEF_COLOR
: TRGB
= (R
:64; G
:175; B
:48);
97 PLAYER2_DEF_COLOR
: TRGB
= (R
:96; G
:96; B
:96);
113 TPlayerStatArray
= Array of TPlayerStat
;
115 TPlayerSavedState
= record
123 Ammo
: Array [A_BULLETS
..A_HIGH
] of Word;
124 MaxAmmo
: Array [A_BULLETS
..A_HIGH
] of Word;
125 Weapon
: Array [WP_FIRST
..WP_LAST
] of Boolean;
126 Rulez
: Set of R_ITEM_BACKPACK
..R_BERSERK
;
135 TPlayer
= class (TObject
)
143 FDirection
: TDirection
;
151 FMonsterKills
: Integer;
157 FCanJetpack
: Boolean;
163 FNextWeapDelay
: Byte; // frames
164 FBFGFireCounter
: SmallInt;
165 FLastSpawnerUID
: Word;
169 FSpectatePlayer
: Integer;
170 FFirePainTime
: Integer;
173 FSavedState
: TPlayerSavedState
;
175 FModel
: TPlayerModel
;
178 FActionForce
: Boolean;
179 FActionChanged
: Boolean;
181 FFireAngle
: SmallInt;
183 FShellTimer
: Integer;
185 FSawSound
: TPlayableSound
;
186 FSawSoundIdle
: TPlayableSound
;
187 FSawSoundHit
: TPlayableSound
;
188 FSawSoundSelect
: TPlayableSound
;
189 FJetSoundOn
: TPlayableSound
;
190 FJetSoundOff
: TPlayableSound
;
191 FJetSoundFly
: TPlayableSound
;
195 FJustTeleported
: Boolean;
198 function CollideLevel(XInc
, YInc
: Integer): Boolean;
199 function StayOnStep(XInc
, YInc
: Integer): Boolean;
200 function HeadInLiquid(XInc
, YInc
: Integer): Boolean;
201 function BodyInLiquid(XInc
, YInc
: Integer): Boolean;
202 function BodyInAcid(XInc
, YInc
: Integer): Boolean;
203 function FullInLift(XInc
, YInc
: Integer): Integer;
204 {procedure CollideItem();}
205 procedure FlySmoke(Times
: DWORD
= 1);
206 procedure OnFireFlame(Times
: DWORD
= 1);
207 function GetAmmoByWeapon(Weapon
: Byte): Word;
208 procedure SetAction(Action
: Byte; Force
: Boolean = False);
209 procedure OnDamage(Angle
: SmallInt); virtual;
210 function firediry(): Integer;
212 procedure Run(Direction
: TDirection
);
213 procedure NextWeapon();
214 procedure PrevWeapon();
221 function getNextWeaponIndex (): Byte; // return 255 for "no switch"
222 procedure resetWeaponQueue ();
223 function hasAmmoForWeapon (weapon
: Byte): Boolean;
226 FDamageBuffer
: Integer;
228 FAmmo
: Array [A_BULLETS
..A_HIGH
] of Word;
229 FMaxAmmo
: Array [A_BULLETS
..A_HIGH
] of Word;
230 FWeapon
: Array [WP_FIRST
..WP_LAST
] of Boolean;
231 FRulez
: Set of R_ITEM_BACKPACK
..R_BERSERK
;
233 FMegaRulez
: Array [MR_SUIT
..MR_MAX
] of DWORD
;
234 FReloading
: Array [WP_FIRST
..WP_LAST
] of Word;
235 FTime
: Array [T_RESPAWN
..T_FLAGCAP
] of DWORD
;
236 FKeys
: Array [KEY_LEFT
..KEY_CHAT
] of TKeyState
;
238 FPreferredTeam
: Byte;
241 FWantsInGame
: Boolean;
245 FActualModelName
: string;
252 // debug: viewport offset
253 viewPortX
, viewPortY
, viewPortW
, viewPortH
: Integer;
255 function isValidViewPort (): Boolean; inline;
257 constructor Create(); virtual;
258 destructor Destroy(); override;
259 procedure Respawn(Silent
: Boolean; Force
: Boolean = False); virtual;
260 function GetRespawnPoint(): Byte;
261 procedure PressKey(Key
: Byte; Time
: Word = 1);
262 procedure ReleaseKeys();
263 procedure SetModel(ModelName
: String);
264 procedure SetColor(Color
: TRGB
);
265 procedure SetWeapon(W
: Byte);
266 function IsKeyPressed(K
: Byte): Boolean;
267 function GetKeys(): Byte;
268 function PickItem(ItemType
: Byte; arespawn
: Boolean; var remove
: Boolean): Boolean; virtual;
269 function Collide(X
, Y
: Integer; Width
, Height
: Word): Boolean; overload
;
270 function Collide(Panel
: TPanel
): Boolean; overload
;
271 function Collide(X
, Y
: Integer): Boolean; overload
;
272 procedure SetDirection(Direction
: TDirection
);
273 procedure GetSecret();
274 function TeleportTo(X
, Y
: Integer; silent
: Boolean; dir
: Byte): Boolean;
276 procedure Push(vx
, vy
: Integer);
277 procedure ChangeModel(ModelName
: String);
278 procedure SwitchTeam
;
279 procedure ChangeTeam(Team
: Byte);
281 function GetFlag(Flag
: Byte): Boolean;
282 procedure SetFlag(Flag
: Byte);
283 function DropFlag(): Boolean;
284 procedure AllRulez(Health
: Boolean);
285 procedure RestoreHealthArmor();
286 procedure FragCombo();
287 procedure GiveItem(ItemType
: Byte);
288 procedure Damage(value
: Word; SpawnerUID
: Word; vx
, vy
: Integer; t
: Byte); virtual;
289 function Heal(value
: Word; Soft
: Boolean): Boolean; virtual;
290 procedure MakeBloodVector(Count
: Word; VelX
, VelY
: Integer);
291 procedure MakeBloodSimple(Count
: Word);
292 procedure Kill(KillType
: Byte; SpawnerUID
: Word; t
: Byte);
293 procedure Reset(Force
: Boolean);
294 procedure Spectate(NoMove
: Boolean = False);
295 procedure SwitchNoClip
;
296 procedure SoftReset();
297 procedure Draw(); virtual;
298 procedure DrawPain();
299 procedure DrawPickup();
300 procedure DrawRulez();
302 procedure DrawBubble();
304 procedure Update(); virtual;
305 procedure RememberState();
306 procedure RecallState();
307 procedure SaveState(var Mem
: TBinMemoryWriter
); virtual;
308 procedure LoadState(var Mem
: TBinMemoryReader
); virtual;
309 procedure PauseSounds(Enable
: Boolean);
310 procedure NetFire(Wpn
: Byte; X
, Y
, AX
, AY
: Integer; WID
: Integer = -1);
311 procedure DoLerp(Level
: Integer = 2);
312 procedure SetLerp(XTo
, YTo
: Integer);
313 procedure QueueWeaponSwitch(Weapon
: Byte);
314 procedure RealizeCurrentWeapon();
316 procedure JetpackOff
;
317 procedure CatchFire(Attacker
: Word);
319 //WARNING! this does nothing for now, but still call it!
320 procedure positionChanged (); //WARNING! call this after monster position was changed, or coldet will not work right!
322 procedure getMapBox (out x
, y
, w
, h
: Integer); inline;
324 property Name
: String read FName write FName
;
325 property Model
: TPlayerModel read FModel
;
326 property Health
: Integer read FHealth write FHealth
;
327 property Lives
: Byte read FLives write FLives
;
328 property Armor
: Integer read FArmor write FArmor
;
329 property Air
: Integer read FAir write FAir
;
330 property JetFuel
: Integer read FJetFuel write FJetFuel
;
331 property Frags
: Integer read FFrags write FFrags
;
332 property Death
: Integer read FDeath write FDeath
;
333 property Kills
: Integer read FKills write FKills
;
334 property CurrWeap
: Byte read FCurrWeap write FCurrWeap
;
335 property MonsterKills
: Integer read FMonsterKills write FMonsterKills
;
336 property Secrets
: Integer read FSecrets
;
337 property GodMode
: Boolean read FGodMode write FGodMode
;
338 property NoTarget
: Boolean read FNoTarget write FNoTarget
;
339 property NoReload
: Boolean read FNoReload write FNoReload
;
340 property Live
: Boolean read FLive write FLive
;
341 property Flag
: Byte read FFlag
;
342 property Team
: Byte read FTeam write FTeam
;
343 property Direction
: TDirection read FDirection
;
344 property GameX
: Integer read FObj
.X write FObj
.X
;
345 property GameY
: Integer read FObj
.Y write FObj
.Y
;
346 property GameVelX
: Integer read FObj
.Vel
.X write FObj
.Vel
.X
;
347 property GameVelY
: Integer read FObj
.Vel
.Y write FObj
.Vel
.Y
;
348 property GameAccelX
: Integer read FObj
.Accel
.X write FObj
.Accel
.X
;
349 property GameAccelY
: Integer read FObj
.Accel
.Y write FObj
.Accel
.Y
;
350 property Vel
: TPoint2i read FObj
.Vel
;
351 property Obj
: TObj read FObj
;
352 property IncCam
: Integer read FIncCam write FIncCam
;
353 property UID
: Word read FUID write FUID
;
354 property JustTeleported
: Boolean read FJustTeleported write FJustTeleported
;
355 property NetTime
: LongWord read FNetTime write FNetTime
;
365 WeaponPrior
: Array [WP_FIRST
..WP_LAST
] of Byte;
366 CloseWeaponPrior
: Array [WP_FIRST
..WP_LAST
] of Byte;
367 //SafeWeaponPrior: Array [WP_FIRST..WP_LAST] of Byte;
375 TBot
= class (TPlayer
)
377 FSelectedWeapon
: Byte;
380 FAIFlags
: Array of TAIFlag
;
381 FDifficult
: TDifficult
;
383 function GetRnd(a
: Byte): Boolean;
384 function GetInterval(a
: Byte; radius
: SmallInt): SmallInt;
385 function RunDirection(): TDirection
;
386 function FullInStep(XInc
, YInc
: Integer): Boolean;
387 //function NeedItem(Item: Byte): Byte;
388 procedure SelectWeapon(Dist
: Integer);
389 procedure SetAIFlag(aName
, fValue
: String20
);
390 function GetAIFlag(aName
: String20
): String20
;
391 procedure RemoveAIFlag(aName
: String20
);
392 function Healthy(): Byte;
393 procedure UpdateMove();
394 procedure UpdateCombat();
395 function KeyPressed(Key
: Word): Boolean;
396 procedure ReleaseKey(Key
: Byte);
397 function TargetOnScreen(TX
, TY
: Integer): Boolean;
398 procedure OnDamage(Angle
: SmallInt); override;
401 procedure Respawn(Silent
: Boolean; Force
: Boolean = False); override;
402 constructor Create(); override;
403 destructor Destroy(); override;
404 procedure Draw(); override;
405 function PickItem(ItemType
: Byte; force
: Boolean; var remove
: Boolean): Boolean; override;
406 function Heal(value
: Word; Soft
: Boolean): Boolean; override;
407 procedure Update(); override;
408 procedure SaveState(var Mem
: TBinMemoryWriter
); override;
409 procedure LoadState(var Mem
: TBinMemoryReader
); override;
420 procedure positionChanged (); //WARNING! call this after monster position was changed, or coldet will not work right!
433 procedure positionChanged (); //WARNING! call this after monster position was changed, or coldet will not work right!
436 TCorpse
= class (TObject
)
444 FAnimation
: TAnimation
;
445 FAnimationMask
: TAnimation
;
448 constructor Create(X
, Y
: Integer; ModelName
: String; aMess
: Boolean);
449 destructor Destroy(); override;
450 procedure Damage(Value
: Word; vx
, vy
: Integer);
453 procedure SaveState(var Mem
: TBinMemoryWriter
);
454 procedure LoadState(var Mem
: TBinMemoryReader
);
456 procedure positionChanged (); //WARNING! call this after monster position was changed, or coldet will not work right!
458 property Obj
: TObj read FObj
;
459 property State
: Byte read FState
;
460 property Mess
: Boolean read FMess
;
463 TTeamStat
= Array [TEAM_RED
..TEAM_BLUE
] of
469 gPlayers
: Array of TPlayer
;
470 gCorpses
: Array of TCorpse
;
471 gGibs
: Array of TGib
;
472 gShells
: Array of TShell
;
473 gTeamStat
: TTeamStat
;
474 gFly
: Boolean = False;
475 gAimLine
: Boolean = False;
476 gChatBubble
: Byte = 0;
480 MAX_RUNVEL
: Integer = 8;
481 VEL_JUMP
: Integer = 10;
482 SHELL_TIMEOUT
: Cardinal = 60000;
484 function Lerp(X
, Y
, Factor
: Integer): Integer;
486 procedure g_Gibs_SetMax(Count
: Word);
487 function g_Gibs_GetMax(): Word;
488 procedure g_Corpses_SetMax(Count
: Word);
489 function g_Corpses_GetMax(): Word;
490 procedure g_Shells_SetMax(Count
: Word);
491 function g_Shells_GetMax(): Word;
493 procedure g_Player_Init();
494 procedure g_Player_Free();
495 function g_Player_Create(ModelName
: String; Color
: TRGB
; Team
: Byte; Bot
: Boolean): Word;
496 function g_Player_CreateFromState(var Mem
: TBinMemoryReader
): Word;
497 procedure g_Player_Remove(UID
: Word);
498 procedure g_Player_ResetTeams();
499 procedure g_Player_UpdateAll();
500 procedure g_Player_DrawAll();
501 procedure g_Player_DrawDebug(p
: TPlayer
);
502 procedure g_Player_DrawHealth();
503 procedure g_Player_RememberAll();
504 procedure g_Player_ResetAll(Force
, Silent
: Boolean);
505 function g_Player_Get(UID
: Word): TPlayer
;
506 function g_Player_GetCount(): Byte;
507 function g_Player_GetStats(): TPlayerStatArray
;
508 function g_Player_ValidName(Name
: String): Boolean;
509 procedure g_Player_CreateCorpse(Player
: TPlayer
);
510 procedure g_Player_CreateGibs(fX
, fY
: Integer; ModelName
: String; fColor
: TRGB
);
511 procedure g_Player_CreateShell(fX
, fY
, dX
, dY
: Integer; T
: Byte);
512 procedure g_Player_UpdatePhysicalObjects();
513 procedure g_Player_DrawCorpses();
514 procedure g_Player_DrawShells();
515 procedure g_Player_RemoveAllCorpses();
516 procedure g_Player_Corpses_SaveState(var Mem
: TBinMemoryWriter
);
517 procedure g_Player_Corpses_LoadState(var Mem
: TBinMemoryReader
);
518 procedure g_Bot_Add(Team
, Difficult
: Byte);
519 procedure g_Bot_AddList(Team
: Byte; lname
: ShortString; num
: Integer = -1);
520 procedure g_Bot_MixNames();
521 procedure g_Bot_RemoveAll();
526 e_log
, g_map
, g_items
, g_console
, SysUtils
, g_gfx
, Math
,
527 g_options
, g_triggers
, g_menu
, MAPDEF
, g_game
, g_grid
,
528 wadreader
, g_main
, g_monsters
, CONFIG
, g_language
,
529 g_net
, g_netmsg
, g_window
, GL
;
539 diag_precision
: Byte;
543 w_prior1
: Array [WP_FIRST
..WP_LAST
] of Byte;
544 w_prior2
: Array [WP_FIRST
..WP_LAST
] of Byte;
545 w_prior3
: Array [WP_FIRST
..WP_LAST
] of Byte;
549 TIME_RESPAWN1
= 1500;
550 TIME_RESPAWN2
= 2000;
551 TIME_RESPAWN3
= 3000;
554 JET_MAX
= 540; // ~30 sec
555 PLAYER_SUIT_TIME
= 30000;
556 PLAYER_INVUL_TIME
= 30000;
557 PLAYER_INVIS_TIME
= 35000;
558 FRAG_COMBO_TIME
= 3000;
562 ANGLE_RIGHTDOWN
= -35;
564 ANGLE_LEFTDOWN
= -145;
565 PLAYER_HEADRECT
: TRectWH
= (X
:24; Y
:12; Width
:20; Height
:12);
566 WEAPONPOINT
: Array [TDirection
] of TPoint
= ((X
:16; Y
:32), (X
:47; Y
:32));
569 BOT_UNSAFEDIST
= 128;
570 TEAMCOLOR
: Array [TEAM_RED
..TEAM_BLUE
] of TRGB
= ((R
:255; G
:0; B
:0),
572 DIFFICULT_EASY
: TDifficult
= (DiagFire
: 32; InvisFire
: 32; DiagPrecision
: 32;
573 FlyPrecision
: 32; Cover
: 32; CloseJump
: 32;
574 WeaponPrior
:(0,0,0,0,0,0,0,0,0,0,0); CloseWeaponPrior
:(0,0,0,0,0,0,0,0,0,0,0));
575 DIFFICULT_MEDIUM
: TDifficult
= (DiagFire
: 127; InvisFire
: 127; DiagPrecision
: 127;
576 FlyPrecision
: 127; Cover
: 127; CloseJump
: 127;
577 WeaponPrior
:(0,0,0,0,0,0,0,0,0,0,0); CloseWeaponPrior
:(0,0,0,0,0,0,0,0,0,0,0));
578 DIFFICULT_HARD
: TDifficult
= (DiagFire
: 255; InvisFire
: 255; DiagPrecision
: 255;
579 FlyPrecision
: 255; Cover
: 255; CloseJump
: 255;
580 WeaponPrior
:(0,0,0,0,0,0,0,0,0,0,0); CloseWeaponPrior
:(0,0,0,0,0,0,0,0,0,0,0));
581 WEAPON_PRIOR1
: Array [WP_FIRST
..WP_LAST
] of Byte =
582 (WEAPON_FLAMETHROWER
, WEAPON_SUPERPULEMET
,
583 WEAPON_SHOTGUN2
, WEAPON_SHOTGUN1
,
584 WEAPON_CHAINGUN
, WEAPON_PLASMA
, WEAPON_ROCKETLAUNCHER
,
585 WEAPON_BFG
, WEAPON_PISTOL
, WEAPON_SAW
, WEAPON_KASTET
);
586 WEAPON_PRIOR2
: Array [WP_FIRST
..WP_LAST
] of Byte =
587 (WEAPON_FLAMETHROWER
, WEAPON_SUPERPULEMET
,
588 WEAPON_BFG
, WEAPON_ROCKETLAUNCHER
,
589 WEAPON_SHOTGUN2
, WEAPON_PLASMA
, WEAPON_SHOTGUN1
,
590 WEAPON_CHAINGUN
, WEAPON_PISTOL
, WEAPON_SAW
, WEAPON_KASTET
);
591 //WEAPON_PRIOR3: Array [WP_FIRST..WP_LAST] of Byte =
592 // (WEAPON_FLAMETHROWER, WEAPON_SUPERPULEMET,
593 // WEAPON_BFG, WEAPON_PLASMA, WEAPON_SHOTGUN2,
594 // WEAPON_CHAINGUN, WEAPON_SHOTGUN1, WEAPON_SAW,
595 // WEAPON_ROCKETLAUNCHER, WEAPON_PISTOL, WEAPON_KASTET);
596 WEAPON_RELOAD
: Array [WP_FIRST
..WP_LAST
] of Byte =
597 (5, 2, 6, 18, 36, 2, 12, 2, 14, 2, 2);
599 PLAYER_SIGNATURE
= $52594C50; // 'PLYR'
600 CORPSE_SIGNATURE
= $50524F43; // 'CORP'
602 BOTNAMES_FILENAME
= 'botnames.txt';
603 BOTLIST_FILENAME
= 'botlist.txt';
607 MaxCorpses
: Word = 20;
608 MaxShells
: Word = 300;
609 CurrentGib
: Integer = 0;
610 CurrentShell
: Integer = 0;
611 BotNames
: Array of String;
612 BotList
: Array of TBotProfile
;
615 procedure TGib
.positionChanged (); begin end;
616 procedure TShell
.positionChanged (); begin end;
619 function Lerp(X
, Y
, Factor
: Integer): Integer;
621 Result
:= X
+ ((Y
- X
) div Factor
);
624 function SameTeam(UID1
, UID2
: Word): Boolean;
628 if (UID1
> UID_MAX_PLAYER
) or (UID1
<= UID_MAX_GAME
) or
629 (UID2
> UID_MAX_PLAYER
) or (UID2
<= UID_MAX_GAME
) then Exit
;
631 if (g_Player_Get(UID1
) = nil) or (g_Player_Get(UID2
) = nil) then Exit
;
633 if ((g_Player_Get(UID1
).Team
= TEAM_NONE
) or
634 (g_Player_Get(UID2
).Team
= TEAM_NONE
)) then Exit
;
636 Result
:= g_Player_Get(UID1
).FTeam
= g_Player_Get(UID2
).FTeam
;
639 procedure g_Gibs_SetMax(Count
: Word);
642 SetLength(gGibs
, Count
);
644 if CurrentGib
>= Count
then
648 function g_Gibs_GetMax(): Word;
653 procedure g_Shells_SetMax(Count
: Word);
656 SetLength(gShells
, Count
);
658 if CurrentShell
>= Count
then
662 function g_Shells_GetMax(): Word;
668 procedure g_Corpses_SetMax(Count
: Word);
671 SetLength(gCorpses
, Count
);
674 function g_Corpses_GetMax(): Word;
676 Result
:= MaxCorpses
;
679 function g_Player_Create(ModelName
: String; Color
: TRGB
; Team
: Byte; Bot
: Boolean): Word;
689 // Åñòü ëè ìåñòî â gPlayers:
690 if gPlayers
<> nil then
691 for a
:= 0 to High(gPlayers
) do
692 if gPlayers
[a
] = nil then
698 // Íåò ìåñòà - ðàñøèðÿåì gPlayers:
701 SetLength(gPlayers
, Length(gPlayers
)+1);
705 // Ñîçäàåì îáúåêò èãðîêà:
707 gPlayers
[a
] := TBot
.Create()
709 gPlayers
[a
] := TPlayer
.Create();
712 gPlayers
[a
].FActualModelName
:= ModelName
;
713 gPlayers
[a
].SetModel(ModelName
);
715 // Íåò ìîäåëè - ñîçäàíèå íå âîçìîæíî:
716 if gPlayers
[a
].FModel
= nil then
720 g_FatalError(Format(_lc
[I_GAME_ERROR_MODEL
], [ModelName
]));
724 if not (Team
in [TEAM_RED
, TEAM_BLUE
]) then
725 if Random(2) = 0 then
729 gPlayers
[a
].FPreferredTeam
:= Team
;
731 case gGameSettings
.GameMode
of
732 GM_DM
: gPlayers
[a
].FTeam
:= TEAM_NONE
;
734 GM_CTF
: gPlayers
[a
].FTeam
:= gPlayers
[a
].FPreferredTeam
;
736 GM_COOP
: gPlayers
[a
].FTeam
:= TEAM_COOP
;
739 // Åñëè êîìàíäíàÿ èãðà - êðàñèì ìîäåëü â öâåò êîìàíäû:
740 gPlayers
[a
].FColor
:= Color
;
741 if gPlayers
[a
].FTeam
in [TEAM_RED
, TEAM_BLUE
] then
742 gPlayers
[a
].FModel
.Color
:= TEAMCOLOR
[gPlayers
[a
].FTeam
]
744 gPlayers
[a
].FModel
.Color
:= Color
;
746 gPlayers
[a
].FUID
:= g_CreateUID(UID_PLAYER
);
747 gPlayers
[a
].FLive
:= False;
749 Result
:= gPlayers
[a
].FUID
;
752 function g_Player_CreateFromState(var Mem
: TBinMemoryReader
): Word;
765 if sig
<> PLAYER_SIGNATURE
then // 'PLYR'
767 raise EBinSizeError
.Create('g_Player_CreateFromState: Wrong Player Signature');
771 Mem
.ReadBoolean(Bot
);
776 // Åñòü ëè ìåñòî â gPlayers:
777 if gPlayers
<> nil then
778 for a
:= 0 to High(gPlayers
) do
779 if gPlayers
[a
] = nil then
785 // Íåò ìåñòà - ðàñøèðÿåì gPlayers:
788 SetLength(gPlayers
, Length(gPlayers
)+1);
792 // Ñîçäàåì îáúåêò èãðîêà:
794 gPlayers
[a
] := TBot
.Create()
796 gPlayers
[a
] := TPlayer
.Create();
797 gPlayers
[a
].FIamBot
:= Bot
;
798 gPlayers
[a
].FPhysics
:= True;
801 Mem
.ReadWord(gPlayers
[a
].FUID
);
803 Mem
.ReadString(gPlayers
[a
].FName
);
805 Mem
.ReadByte(gPlayers
[a
].FTeam
);
806 gPlayers
[a
].FPreferredTeam
:= gPlayers
[a
].FTeam
;
808 Mem
.ReadBoolean(gPlayers
[a
].FLive
);
809 // Èçðàñõîäîâàë ëè âñå æèçíè:
810 Mem
.ReadBoolean(gPlayers
[a
].FNoRespawn
);
814 gPlayers
[a
].FDirection
:= D_LEFT
816 gPlayers
[a
].FDirection
:= D_RIGHT
;
818 Mem
.ReadInt(gPlayers
[a
].FHealth
);
820 Mem
.ReadByte(gPlayers
[a
].FLives
);
822 Mem
.ReadInt(gPlayers
[a
].FArmor
);
824 Mem
.ReadInt(gPlayers
[a
].FAir
);
826 Mem
.ReadInt(gPlayers
[a
].FJetFuel
);
828 Mem
.ReadInt(gPlayers
[a
].FPain
);
830 Mem
.ReadInt(gPlayers
[a
].FKills
);
832 Mem
.ReadInt(gPlayers
[a
].FMonsterKills
);
834 Mem
.ReadInt(gPlayers
[a
].FFrags
);
836 Mem
.ReadByte(gPlayers
[a
].FFragCombo
);
837 // Âðåìÿ ïîñëåäíåãî ôðàãà:
838 Mem
.ReadDWORD(gPlayers
[a
].FLastFrag
);
840 Mem
.ReadInt(gPlayers
[a
].FDeath
);
842 Mem
.ReadByte(gPlayers
[a
].FFlag
);
844 Mem
.ReadInt(gPlayers
[a
].FSecrets
);
846 Mem
.ReadByte(gPlayers
[a
].FCurrWeap
);
847 // Ñëåäóþùåå æåëàåìîå îðóæèå:
848 Mem
.ReadWord(gPlayers
[a
].FNextWeap
);
850 Mem
.ReadByte(gPlayers
[a
].FNextWeapDelay
);
851 // Âðåìÿ çàðÿäêè BFG:
852 Mem
.ReadSmallInt(gPlayers
[a
].FBFGFireCounter
);
854 Mem
.ReadInt(gPlayers
[a
].FDamageBuffer
);
855 // Ïîñëåäíèé óäàðèâøèé:
856 Mem
.ReadWord(gPlayers
[a
].FLastSpawnerUID
);
857 // Òèï ïîñëåäíåãî ïîëó÷åííîãî óðîíà:
858 Mem
.ReadByte(gPlayers
[a
].FLastHit
);
860 Obj_LoadState(@gPlayers
[a
].FObj
, Mem
);
861 // Òåêóùåå êîëè÷åñòâî ïàòðîíîâ:
862 for i
:= A_BULLETS
to A_HIGH
do
863 Mem
.ReadWord(gPlayers
[a
].FAmmo
[i
]);
864 // Ìàêñèìàëüíîå êîëè÷åñòâî ïàòðîíîâ:
865 for i
:= A_BULLETS
to A_HIGH
do
866 Mem
.ReadWord(gPlayers
[a
].FMaxAmmo
[i
]);
868 for i
:= WP_FIRST
to WP_LAST
do
869 Mem
.ReadBoolean(gPlayers
[a
].FWeapon
[i
]);
870 // Âðåìÿ ïåðåçàðÿäêè îðóæèÿ:
871 for i
:= WP_FIRST
to WP_LAST
do
872 Mem
.ReadWord(gPlayers
[a
].FReloading
[i
]);
876 Include(gPlayers
[a
].FRulez
, R_ITEM_BACKPACK
);
877 // Íàëè÷èå êðàñíîãî êëþ÷à:
880 Include(gPlayers
[a
].FRulez
, R_KEY_RED
);
881 // Íàëè÷èå çåëåíîãî êëþ÷à:
884 Include(gPlayers
[a
].FRulez
, R_KEY_GREEN
);
885 // Íàëè÷èå ñèíåãî êëþ÷à:
888 Include(gPlayers
[a
].FRulez
, R_KEY_BLUE
);
892 Include(gPlayers
[a
].FRulez
, R_BERSERK
);
893 // Âðåìÿ äåéñòâèÿ ñïåöèàëüíûõ ïðåäìåòîâ:
894 for i
:= MR_SUIT
to MR_MAX
do
895 Mem
.ReadDWORD(gPlayers
[a
].FMegaRulez
[i
]);
896 // Âðåìÿ äî ïîâòîðíîãî ðåñïàóíà, ñìåíû îðóæèÿ, èñîëüçîâàíèÿ, çàõâàòà ôëàãà:
897 for i
:= T_RESPAWN
to T_FLAGCAP
do
898 Mem
.ReadDWORD(gPlayers
[a
].FTime
[i
]);
901 Mem
.ReadString(gPlayers
[a
].FActualModelName
);
903 Mem
.ReadByte(gPlayers
[a
].FColor
.R
);
904 Mem
.ReadByte(gPlayers
[a
].FColor
.G
);
905 Mem
.ReadByte(gPlayers
[a
].FColor
.B
);
906 // Îáíîâëÿåì ìîäåëü èãðîêà:
907 gPlayers
[a
].SetModel(gPlayers
[a
].FActualModelName
);
909 // Íåò ìîäåëè - ñîçäàíèå íå âîçìîæíî:
910 if gPlayers
[a
].FModel
= nil then
914 g_FatalError(Format(_lc
[I_GAME_ERROR_MODEL
], [gPlayers
[a
].FActualModelName
]));
918 // Åñëè êîìàíäíàÿ èãðà - êðàñèì ìîäåëü â öâåò êîìàíäû:
919 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
920 gPlayers
[a
].FModel
.Color
:= TEAMCOLOR
[gPlayers
[a
].FTeam
]
922 gPlayers
[a
].FModel
.Color
:= gPlayers
[a
].FColor
;
924 Result
:= gPlayers
[a
].FUID
;
927 procedure g_Player_ResetTeams();
931 if g_Game_IsClient
then
933 if gPlayers
= nil then
935 for a
:= Low(gPlayers
) to High(gPlayers
) do
936 if gPlayers
[a
] <> nil then
937 case gGameSettings
.GameMode
of
939 gPlayers
[a
].ChangeTeam(TEAM_NONE
);
941 if not (gPlayers
[a
].Team
in [TEAM_RED
, TEAM_BLUE
]) then
942 if gPlayers
[a
].FPreferredTeam
in [TEAM_RED
, TEAM_BLUE
] then
943 gPlayers
[a
].ChangeTeam(gPlayers
[a
].FPreferredTeam
)
946 gPlayers
[a
].ChangeTeam(TEAM_RED
)
948 gPlayers
[a
].ChangeTeam(TEAM_BLUE
);
951 gPlayers
[a
].ChangeTeam(TEAM_COOP
);
955 procedure g_Bot_Add(Team
, Difficult
: Byte);
958 _name
, _model
: String;
961 if not g_Game_IsServer
then Exit
;
963 // Ñïèñîê íàçâàíèé ìîäåëåé:
964 m
:= g_PlayerModel_GetNames();
969 if (gGameSettings
.GameType
= GT_SINGLE
) or (gGameSettings
.GameMode
= GM_COOP
) then
970 Team
:= TEAM_COOP
// COOP
972 if gGameSettings
.GameMode
= GM_DM
then
973 Team
:= TEAM_NONE
// DM
975 if Team
= TEAM_NONE
then // CTF / TDM
977 // Àâòîáàëàíñ êîìàíä:
981 for a
:= 0 to High(gPlayers
) do
982 if gPlayers
[a
] <> nil then
984 if gPlayers
[a
].Team
= TEAM_RED
then
987 if gPlayers
[a
].Team
= TEAM_BLUE
then
997 if Random(2) = 0 then
1003 // Âûáèðàåì áîòó èìÿ:
1005 if BotNames
<> nil then
1006 for a
:= 0 to High(BotNames
) do
1007 if g_Player_ValidName(BotNames
[a
]) then
1009 _name
:= BotNames
[a
];
1013 // Èìåíè íåò, çàäàåì ñëó÷àéíîå:
1016 _name
:= Format('DFBOT%.2d', [Random(100)]);
1017 until g_Player_ValidName(_name
);
1019 // Âûáèðàåì ñëó÷àéíóþ ìîäåëü:
1020 _model
:= m
[Random(Length(m
))];
1023 with g_Player_Get(g_Player_Create(_model
,
1024 _RGB(Min(Random(9)*32, 255),
1025 Min(Random(9)*32, 255),
1026 Min(Random(9)*32, 255)),
1027 Team
, True)) as TBot
do
1032 1: FDifficult
:= DIFFICULT_EASY
;
1033 2: FDifficult
:= DIFFICULT_MEDIUM
;
1034 else FDifficult
:= DIFFICULT_HARD
;
1037 for a
:= WP_FIRST
to WP_LAST
do
1039 FDifficult
.WeaponPrior
[a
] := WEAPON_PRIOR1
[a
];
1040 FDifficult
.CloseWeaponPrior
[a
] := WEAPON_PRIOR2
[a
];
1041 //FDifficult.SafeWeaponPrior[a] := WEAPON_PRIOR3[a];
1044 g_Console_Add(Format(_lc
[I_PLAYER_JOIN
], [Name
]), True);
1046 if g_Game_IsNet
then MH_SEND_PlayerCreate(UID
);
1047 if g_Game_IsServer
and (gGameSettings
.MaxLives
> 0) then
1052 procedure g_Bot_AddList(Team
: Byte; lName
: ShortString; num
: Integer = -1);
1055 _name
, _model
: String;
1058 if not g_Game_IsServer
then Exit
;
1060 // Ñïèñîê íàçâàíèé ìîäåëåé:
1061 m
:= g_PlayerModel_GetNames();
1066 if (gGameSettings
.GameType
= GT_SINGLE
) or (gGameSettings
.GameMode
= GM_COOP
) then
1067 Team
:= TEAM_COOP
// COOP
1069 if gGameSettings
.GameMode
= GM_DM
then
1070 Team
:= TEAM_NONE
// DM
1072 if Team
= TEAM_NONE
then
1073 Team
:= BotList
[num
].team
; // CTF / TDM
1075 // Âûáèðàåì íàñòðîéêè áîòà èç ñïèñêà ïî íîìåðó èëè èìåíè:
1076 lName
:= AnsiLowerCase(lName
);
1077 if (num
< 0) or (num
> Length(BotList
)-1) then
1079 if (num
= -1) and (lName
<> '') and (BotList
<> nil) then
1080 for a
:= 0 to High(BotList
) do
1081 if AnsiLowerCase(BotList
[a
].name
) = lName
then
1090 _name
:= BotList
[num
].name
;
1091 // Çàíÿòî - âûáèðàåì ñëó÷àéíîå:
1092 if not g_Player_ValidName(_name
) then
1094 _name
:= Format('DFBOT%.2d', [Random(100)]);
1095 until g_Player_ValidName(_name
);
1098 _model
:= BotList
[num
].model
;
1099 // Íåò òàêîé - âûáèðàåì ñëó÷àéíóþ:
1100 if not InSArray(_model
, m
) then
1101 _model
:= m
[Random(Length(m
))];
1104 with g_Player_Get(g_Player_Create(_model
, BotList
[num
].color
, Team
, True)) as TBot
do
1108 FDifficult
.DiagFire
:= BotList
[num
].diag_fire
;
1109 FDifficult
.InvisFire
:= BotList
[num
].invis_fire
;
1110 FDifficult
.DiagPrecision
:= BotList
[num
].diag_precision
;
1111 FDifficult
.FlyPrecision
:= BotList
[num
].fly_precision
;
1112 FDifficult
.Cover
:= BotList
[num
].cover
;
1113 FDifficult
.CloseJump
:= BotList
[num
].close_jump
;
1115 for a
:= WP_FIRST
to WP_LAST
do
1117 FDifficult
.WeaponPrior
[a
] := BotList
[num
].w_prior1
[a
];
1118 FDifficult
.CloseWeaponPrior
[a
] := BotList
[num
].w_prior2
[a
];
1119 //FDifficult.SafeWeaponPrior[a] := BotList[num].w_prior3[a];
1122 g_Console_Add(Format(_lc
[I_PLAYER_JOIN
], [Name
]), True);
1124 if g_Game_IsNet
then MH_SEND_PlayerCreate(UID
);
1128 procedure g_Bot_RemoveAll();
1132 if not g_Game_IsServer
then Exit
;
1133 if gPlayers
= nil then Exit
;
1135 for a
:= 0 to High(gPlayers
) do
1136 if gPlayers
[a
] <> nil then
1137 if gPlayers
[a
] is TBot
then
1139 gPlayers
[a
].Lives
:= 0;
1140 gPlayers
[a
].Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
1141 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [gPlayers
[a
].Name
]), True);
1142 g_Player_Remove(gPlayers
[a
].FUID
);
1148 procedure g_Bot_MixNames();
1153 if BotNames
<> nil then
1154 for a
:= 0 to High(BotNames
) do
1156 b
:= Random(Length(BotNames
));
1158 Botnames
[a
] := BotNames
[b
];
1163 procedure g_Player_Remove(UID
: Word);
1167 if gPlayers
= nil then Exit
;
1169 if g_Game_IsServer
and g_Game_IsNet
then
1170 MH_SEND_PlayerDelete(UID
);
1172 for i
:= 0 to High(gPlayers
) do
1173 if gPlayers
[i
] <> nil then
1174 if gPlayers
[i
].FUID
= UID
then
1176 if gPlayers
[i
] is TPlayer
then
1177 TPlayer(gPlayers
[i
]).Free()
1179 TBot(gPlayers
[i
]).Free();
1185 procedure g_Player_Init();
1195 if not FileExists(DataDir
+ BOTNAMES_FILENAME
) then
1198 // ×èòàåì âîçìîæíûå èìåíà áîòîâ èç ôàéëà:
1199 AssignFile(F
, DataDir
+ BOTNAMES_FILENAME
);
1210 SetLength(BotNames
, Length(BotNames
)+1);
1211 BotNames
[High(BotNames
)] := s
;
1219 // ×èòàåì ôàéë ñ ïàðàìåòðàìè áîòîâ:
1220 config
:= TConfig
.CreateFile(DataDir
+ BOTLIST_FILENAME
);
1224 while config
.SectionExists(IntToStr(a
)) do
1226 SetLength(BotList
, Length(BotList
)+1);
1228 with BotList
[High(BotList
)] do
1231 name
:= config
.ReadStr(IntToStr(a
), 'name', '');
1233 model
:= config
.ReadStr(IntToStr(a
), 'model', '');
1235 if config
.ReadStr(IntToStr(a
), 'team', 'red') = 'red' then
1240 sa
:= parse(config
.ReadStr(IntToStr(a
), 'color', ''));
1241 color
.R
:= StrToIntDef(sa
[0], 0);
1242 color
.G
:= StrToIntDef(sa
[1], 0);
1243 color
.B
:= StrToIntDef(sa
[2], 0);
1244 // Âåðîÿòíîñòü ñòðåëüáû ïîä óãëîì:
1245 diag_fire
:= config
.ReadInt(IntToStr(a
), 'diag_fire', 0);
1246 // Âåðîÿòíîñòü îòâåòíîãî îãíÿ ïî íåâèäèìîìó ñîïåðíèêó:
1247 invis_fire
:= config
.ReadInt(IntToStr(a
), 'invis_fire', 0);
1248 // Òî÷íîñòü ñòðåëüáû ïîä óãëîì:
1249 diag_precision
:= config
.ReadInt(IntToStr(a
), 'diag_precision', 0);
1250 // Òî÷íîñòü ñòðåëüáû â ïîëåòå:
1251 fly_precision
:= config
.ReadInt(IntToStr(a
), 'fly_precision', 0);
1252 // Òî÷íîñòü óêëîíåíèÿ îò ñíàðÿäîâ:
1253 cover
:= config
.ReadInt(IntToStr(a
), 'cover', 0);
1254 // Âåðîÿòíîñòü ïðûæêà ïðè ïðèáëèæåíèè ñîïåðíèêà:
1255 close_jump
:= config
.ReadInt(IntToStr(a
), 'close_jump', 0);
1256 // Ïðèîðèòåòû îðóæèÿ äëÿ äàëüíåãî áîÿ:
1257 sa
:= parse(config
.ReadStr(IntToStr(a
), 'w_prior1', ''));
1258 if Length(sa
) = 10 then
1260 w_prior1
[b
] := EnsureRange(StrToInt(sa
[b
]), 0, 9);
1261 // Ïðèîðèòåòû îðóæèÿ äëÿ áëèæíåãî áîÿ:
1262 sa
:= parse(config
.ReadStr(IntToStr(a
), 'w_prior2', ''));
1263 if Length(sa
) = 10 then
1265 w_prior2
[b
] := EnsureRange(StrToInt(sa
[b
]), 0, 9);
1267 {sa := parse(config.ReadStr(IntToStr(a), 'w_prior3', ''));
1268 if Length(sa) = 10 then
1270 w_prior3[b] := EnsureRange(StrToInt(sa[b]), 0, 9);}
1279 procedure g_Player_Free();
1283 if gPlayers
<> nil then
1285 for i
:= 0 to High(gPlayers
) do
1286 if gPlayers
[i
] <> nil then
1288 if gPlayers
[i
] is TPlayer
then
1289 TPlayer(gPlayers
[i
]).Free()
1291 TBot(gPlayers
[i
]).Free();
1302 procedure g_Player_UpdateAll();
1306 if gPlayers
= nil then Exit
;
1308 //e_WriteLog('***g_Player_UpdateAll: ENTER', MSG_WARNING);
1309 for i
:= 0 to High(gPlayers
) do
1311 if gPlayers
[i
] <> nil then
1313 if gPlayers
[i
] is TPlayer
then
1315 gPlayers
[i
].Update();
1316 gPlayers
[i
].RealizeCurrentWeapon(); // WARNING! DO NOT MOVE THIS INTO `Update()`!
1320 // bot updates weapons in `UpdateCombat()`
1321 TBot(gPlayers
[i
]).Update();
1325 //e_WriteLog('***g_Player_UpdateAll: EXIT', MSG_WARNING);
1328 procedure g_Player_DrawAll();
1332 if gPlayers
= nil then Exit
;
1334 for i
:= 0 to High(gPlayers
) do
1335 if gPlayers
[i
] <> nil then
1336 if gPlayers
[i
] is TPlayer
then gPlayers
[i
].Draw()
1337 else TBot(gPlayers
[i
]).Draw();
1340 procedure g_Player_DrawDebug(p
: TPlayer
);
1344 if p
= nil then Exit
;
1345 if (@p
.FObj
) = nil then Exit
;
1347 e_TextureFontGetSize(gStdFont
, fW
, fH
);
1349 e_TextureFontPrint(0, 0 , 'Pos X: ' + IntToStr(p
.FObj
.X
), gStdFont
);
1350 e_TextureFontPrint(0, fH
, 'Pos Y: ' + IntToStr(p
.FObj
.Y
), gStdFont
);
1351 e_TextureFontPrint(0, fH
* 2, 'Vel X: ' + IntToStr(p
.FObj
.Vel
.X
), gStdFont
);
1352 e_TextureFontPrint(0, fH
* 3, 'Vel Y: ' + IntToStr(p
.FObj
.Vel
.Y
), gStdFont
);
1353 e_TextureFontPrint(0, fH
* 4, 'Acc X: ' + IntToStr(p
.FObj
.Accel
.X
), gStdFont
);
1354 e_TextureFontPrint(0, fH
* 5, 'Acc Y: ' + IntToStr(p
.FObj
.Accel
.Y
), gStdFont
);
1357 procedure g_Player_DrawHealth();
1362 if gPlayers
= nil then Exit
;
1363 e_TextureFontGetSize(gStdFont
, fW
, fH
);
1365 for i
:= 0 to High(gPlayers
) do
1366 if gPlayers
[i
] <> nil then
1368 e_TextureFontPrint(gPlayers
[i
].FObj
.X
+ gPlayers
[i
].FObj
.Rect
.X
,
1369 gPlayers
[i
].FObj
.Y
+ gPlayers
[i
].FObj
.Rect
.Y
+ gPlayers
[i
].FObj
.Rect
.Height
- fH
* 2,
1370 IntToStr(gPlayers
[i
].FHealth
), gStdFont
);
1371 e_TextureFontPrint(gPlayers
[i
].FObj
.X
+ gPlayers
[i
].FObj
.Rect
.X
,
1372 gPlayers
[i
].FObj
.Y
+ gPlayers
[i
].FObj
.Rect
.Y
+ gPlayers
[i
].FObj
.Rect
.Height
- fH
,
1373 IntToStr(gPlayers
[i
].FArmor
), gStdFont
);
1377 function g_Player_Get(UID
: Word): TPlayer
;
1383 if gPlayers
= nil then
1386 for a
:= 0 to High(gPlayers
) do
1387 if gPlayers
[a
] <> nil then
1388 if gPlayers
[a
].FUID
= UID
then
1390 Result
:= gPlayers
[a
];
1395 function g_Player_GetCount(): Byte;
1401 if gPlayers
= nil then
1404 for a
:= 0 to High(gPlayers
) do
1405 if gPlayers
[a
] <> nil then
1406 Result
:= Result
+ 1;
1409 function g_Player_GetStats(): TPlayerStatArray
;
1415 if gPlayers
= nil then Exit
;
1417 for a
:= 0 to High(gPlayers
) do
1418 if gPlayers
[a
] <> nil then
1420 SetLength(Result
, Length(Result
)+1);
1421 with Result
[High(Result
)] do
1423 Ping
:= gPlayers
[a
].FPing
;
1424 Loss
:= gPlayers
[a
].FLoss
;
1425 Name
:= gPlayers
[a
].FName
;
1426 Team
:= gPlayers
[a
].FTeam
;
1427 Frags
:= gPlayers
[a
].FFrags
;
1428 Deaths
:= gPlayers
[a
].FDeath
;
1429 Kills
:= gPlayers
[a
].FKills
;
1430 Color
:= gPlayers
[a
].FModel
.Color
;
1431 Lives
:= gPlayers
[a
].FLives
;
1432 Spectator
:= gPlayers
[a
].FSpectator
;
1437 procedure g_Player_RememberAll
;
1441 for i
:= Low(gPlayers
) to High(gPlayers
) do
1442 if (gPlayers
[i
] <> nil) and gPlayers
[i
].Live
then
1443 gPlayers
[i
].RememberState
;
1446 procedure g_Player_ResetAll(Force
, Silent
: Boolean);
1450 gTeamStat
[TEAM_RED
].Goals
:= 0;
1451 gTeamStat
[TEAM_BLUE
].Goals
:= 0;
1453 if gPlayers
<> nil then
1454 for i
:= 0 to High(gPlayers
) do
1455 if gPlayers
[i
] <> nil then
1457 gPlayers
[i
].Reset(Force
);
1459 if gPlayers
[i
] is TPlayer
then
1461 if (not gPlayers
[i
].FSpectator
) or gPlayers
[i
].FWantsInGame
then
1462 gPlayers
[i
].Respawn(Silent
)
1464 gPlayers
[i
].Spectate();
1467 TBot(gPlayers
[i
]).Respawn(Silent
);
1471 procedure g_Player_CreateCorpse(Player
: TPlayer
);
1478 if Player
.FObj
.Y
>= gMapInfo
.Height
+128 then
1483 if (FHealth
>= -50) or (gGibsCount
= 0) then
1485 if (gCorpses
= nil) or (Length(gCorpses
) = 0) then
1489 for find_id
:= 0 to High(gCorpses
) do
1490 if gCorpses
[find_id
] = nil then
1497 find_id
:= Random(Length(gCorpses
));
1499 gCorpses
[find_id
] := TCorpse
.Create(FObj
.X
, FObj
.Y
, FModel
.Name
, FHealth
< -20);
1500 gCorpses
[find_id
].FColor
:= FModel
.Color
;
1501 gCorpses
[find_id
].FObj
.Vel
:= FObj
.Vel
;
1502 gCorpses
[find_id
].FObj
.Accel
:= FObj
.Accel
;
1505 g_Player_CreateGibs(FObj
.X
+ PLAYER_RECT_CX
,
1506 FObj
.Y
+ PLAYER_RECT_CY
,
1507 FModel
.Name
, FModel
.Color
);
1511 procedure g_Player_CreateShell(fX
, fY
, dX
, dY
: Integer; T
: Byte);
1515 if (gShells
= nil) or (Length(gShells
) = 0) then
1518 with gShells
[CurrentShell
] do
1524 if T
= SHELL_BULLET
then
1526 if g_Texture_Get('TEXTURE_SHELL_BULLET', SID
) then
1530 Obj
.Rect
.Width
:= 4;
1531 Obj
.Rect
.Height
:= 2;
1535 if g_Texture_Get('TEXTURE_SHELL_SHELL', SID
) then
1539 Obj
.Rect
.Width
:= 7;
1540 Obj
.Rect
.Height
:= 3;
1546 g_Obj_Push(@Obj
, dX
+ Random(4)-Random(4), dY
-Random(4));
1547 positionChanged(); // this updates spatial accelerators
1548 RAngle
:= Random(360);
1549 Timeout
:= gTime
+ SHELL_TIMEOUT
;
1551 if CurrentShell
>= High(gShells
) then
1558 procedure g_Player_CreateGibs(fX
, fY
: Integer; ModelName
: string; fColor
: TRGB
);
1561 GibsArray
: TGibsArray
;
1563 if (gGibs
= nil) or (Length(gGibs
) = 0) then
1565 if not g_PlayerModel_GetGibs(ModelName
, GibsArray
) then
1568 for a
:= 0 to High(GibsArray
) do
1569 with gGibs
[CurrentGib
] do
1572 ID
:= GibsArray
[a
].ID
;
1573 MaskID
:= GibsArray
[a
].MaskID
;
1576 Obj
.Rect
:= GibsArray
[a
].Rect
;
1577 Obj
.X
:= fX
-GibsArray
[a
].Rect
.X
-(GibsArray
[a
].Rect
.Width
div 2);
1578 Obj
.Y
:= fY
-GibsArray
[a
].Rect
.Y
-(GibsArray
[a
].Rect
.Height
div 2);
1579 g_Obj_PushA(@Obj
, 25 + Random(10), Random(361));
1580 positionChanged(); // this updates spatial accelerators
1581 RAngle
:= Random(360);
1583 if gBloodCount
> 0 then
1584 g_GFX_Blood(fX
, fY
, 16*gBloodCount
+Random(5*gBloodCount
), -16+Random(33), -16+Random(33),
1585 Random(48), Random(48), 150, 0, 0);
1587 if CurrentGib
>= High(gGibs
) then
1594 procedure g_Player_UpdatePhysicalObjects();
1600 procedure ShellSound_Bounce(X
, Y
: Integer; T
: Byte);
1605 if T
= SHELL_BULLET
then
1606 g_Sound_PlayExAt('SOUND_PLAYER_CASING' + IntToStr(k
), X
, Y
)
1608 g_Sound_PlayExAt('SOUND_PLAYER_SHELL' + IntToStr(k
), X
, Y
);
1613 if gGibs
<> nil then
1614 for i
:= 0 to High(gGibs
) do
1615 if gGibs
[i
].Live
then
1619 mr
:= g_Obj_Move(@Obj
, True, False, True);
1620 positionChanged(); // this updates spatial accelerators
1622 if WordBool(mr
and MOVE_FALLOUT
) then
1628 // Îòëåòàåò îò óäàðà î ñòåíó/ïîòîëîê/ïîë:
1629 if WordBool(mr
and MOVE_HITWALL
) then
1630 Obj
.Vel
.X
:= -(vel
.X
div 2);
1631 if WordBool(mr
and (MOVE_HITCEIL
or MOVE_HITLAND
)) then
1632 Obj
.Vel
.Y
:= -(vel
.Y
div 2);
1634 if (Obj
.Vel
.X
>= 0) then
1636 RAngle
:= RAngle
+ Abs(Obj
.Vel
.X
)*6 + Abs(Obj
.Vel
.Y
);
1637 if RAngle
>= 360 then
1638 RAngle
:= RAngle
mod 360;
1639 end else begin // Counter-clockwise
1640 RAngle
:= RAngle
- Abs(Obj
.Vel
.X
)*6 - Abs(Obj
.Vel
.Y
);
1642 RAngle
:= (360 - (Abs(RAngle
) mod 360)) mod 360;
1645 // Ñîïðîòèâëåíèå âîçäóõà äëÿ êóñêà òðóïà:
1646 if gTime
mod (GAME_TICK
*3) = 0 then
1647 Obj
.Vel
.X
:= z_dec(Obj
.Vel
.X
, 1);
1651 if gCorpses
<> nil then
1652 for i
:= 0 to High(gCorpses
) do
1653 if gCorpses
[i
] <> nil then
1654 if gCorpses
[i
].State
= CORPSE_STATE_REMOVEME
then
1660 gCorpses
[i
].Update();
1663 if gShells
<> nil then
1664 for i
:= 0 to High(gShells
) do
1665 if gShells
[i
].Live
then
1669 mr
:= g_Obj_Move(@Obj
, True, False, True);
1670 positionChanged(); // this updates spatial accelerators
1672 if WordBool(mr
and MOVE_FALLOUT
) or (gShells
[i
].Timeout
< gTime
) then
1678 // Îòëåòàåò îò óäàðà î ñòåíó/ïîòîëîê/ïîë:
1679 if WordBool(mr
and MOVE_HITWALL
) then
1681 Obj
.Vel
.X
:= -(vel
.X
div 2);
1682 if not WordBool(mr
and MOVE_INWATER
) then
1683 ShellSound_Bounce(Obj
.X
, Obj
.Y
, SType
);
1685 if WordBool(mr
and (MOVE_HITCEIL
or MOVE_HITLAND
)) then
1687 Obj
.Vel
.Y
:= -(vel
.Y
div 2);
1688 if Obj
.Vel
.X
<> 0 then Obj
.Vel
.X
:= Obj
.Vel
.X
div 2;
1689 if (Obj
.Vel
.X
= 0) and (Obj
.Vel
.Y
= 0) then
1691 if RAngle
mod 90 <> 0 then
1692 RAngle
:= (RAngle
div 90) * 90;
1694 else if not WordBool(mr
and MOVE_INWATER
) then
1695 ShellSound_Bounce(Obj
.X
, Obj
.Y
, SType
);
1698 if (Obj
.Vel
.X
>= 0) then
1700 RAngle
:= RAngle
+ Abs(Obj
.Vel
.X
)*8 + Abs(Obj
.Vel
.Y
);
1701 if RAngle
>= 360 then
1702 RAngle
:= RAngle
mod 360;
1703 end else begin // Counter-clockwise
1704 RAngle
:= RAngle
- Abs(Obj
.Vel
.X
)*8 - Abs(Obj
.Vel
.Y
);
1706 RAngle
:= (360 - (Abs(RAngle
) mod 360)) mod 360;
1711 procedure g_Player_DrawCorpses();
1716 if gGibs
<> nil then
1717 for i
:= 0 to High(gGibs
) do
1718 if gGibs
[i
].Live
then
1721 if not g_Obj_Collide(sX
, sY
, sWidth
, sHeight
, @Obj
) then
1724 a
.X
:= Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2);
1725 a
.y
:= Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2);
1727 e_DrawAdv(ID
, Obj
.X
, Obj
.Y
, 0, True, False, RAngle
, @a
, M_NONE
);
1730 e_DrawAdv(MaskID
, Obj
.X
, Obj
.Y
, 0, True, False, RAngle
, @a
, M_NONE
);
1736 if gCorpses
<> nil then
1737 for i
:= 0 to High(gCorpses
) do
1738 if gCorpses
[i
] <> nil then
1742 procedure g_Player_DrawShells();
1747 if gShells
<> nil then
1748 for i
:= 0 to High(gShells
) do
1749 if gShells
[i
].Live
then
1752 if not g_Obj_Collide(sX
, sY
, sWidth
, sHeight
, @Obj
) then
1758 e_DrawAdv(SpriteID
, Obj
.X
, Obj
.Y
, 0, True, False, RAngle
, @a
, M_NONE
);
1762 procedure g_Player_RemoveAllCorpses();
1768 SetLength(gGibs
, MaxGibs
);
1769 SetLength(gShells
, MaxGibs
);
1773 if gCorpses
<> nil then
1774 for i
:= 0 to High(gCorpses
) do
1778 SetLength(gCorpses
, MaxCorpses
);
1781 procedure g_Player_Corpses_SaveState(var Mem
: TBinMemoryWriter
);
1786 // Ñ÷èòàåì êîëè÷åñòâî ñóùåñòâóþùèõ òðóïîâ:
1788 if gCorpses
<> nil then
1789 for i
:= 0 to High(gCorpses
) do
1790 if gCorpses
[i
] <> nil then
1793 Mem
:= TBinMemoryWriter
.Create((count
+1) * 128);
1795 // Êîëè÷åñòâî òðóïîâ:
1796 Mem
.WriteInt(count
);
1802 for i
:= 0 to High(gCorpses
) do
1803 if gCorpses
[i
] <> nil then
1806 Mem
.WriteString(gCorpses
[i
].FModelName
);
1808 b
:= gCorpses
[i
].Mess
;
1809 Mem
.WriteBoolean(b
);
1810 // Ñîõðàíÿåì äàííûå òðóïà:
1811 gCorpses
[i
].SaveState(Mem
);
1815 procedure g_Player_Corpses_LoadState(var Mem
: TBinMemoryReader
);
1824 g_Player_RemoveAllCorpses();
1826 // Êîëè÷åñòâî òðóïîâ:
1829 if count
> Length(gCorpses
) then
1831 raise EBinSizeError
.Create('g_Player_Corpses_LoadState: Too Many Corpses');
1838 for i
:= 0 to count
-1 do
1841 Mem
.ReadString(str
);
1845 gCorpses
[i
] := TCorpse
.Create(0, 0, str
, b
);
1846 // Çàãðóæàåì äàííûå òðóïà:
1847 gCorpses
[i
].LoadState(Mem
);
1853 function TPlayer
.isValidViewPort (): Boolean; inline; begin result
:= (viewPortW
> 0) and (viewPortH
> 0); end;
1855 procedure TPlayer
.BFGHit();
1857 g_Weapon_BFGHit(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
1858 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2));
1859 if g_Game_IsServer
and g_Game_IsNet
then
1860 MH_SEND_Effect(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
1861 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2),
1865 procedure TPlayer
.ChangeModel(ModelName
: string);
1867 locModel
: TPlayerModel
;
1869 locModel
:= g_PlayerModel_Get(ModelName
);
1870 if locModel
= nil then Exit
;
1876 procedure TPlayer
.SetModel(ModelName
: string);
1880 m
:= g_PlayerModel_Get(ModelName
);
1883 g_SimpleError(Format(_lc
[I_GAME_ERROR_MODEL_FALLBACK
], [ModelName
]));
1884 m
:= g_PlayerModel_Get('doomer');
1887 g_FatalError(Format(_lc
[I_GAME_ERROR_MODEL
], ['doomer']));
1892 if FModel
<> nil then
1897 if not (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then
1898 FModel
.Color
:= FColor
1900 FModel
.Color
:= TEAMCOLOR
[FTeam
];
1901 FModel
.SetWeapon(FCurrWeap
);
1902 FModel
.SetFlag(FFlag
);
1903 SetDirection(FDirection
);
1906 procedure TPlayer
.SetColor(Color
: TRGB
);
1909 if not (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then
1910 if FModel
<> nil then FModel
.Color
:= Color
;
1913 procedure TPlayer
.SwitchTeam
;
1915 if g_Game_IsClient
then
1917 if not (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then Exit
;
1919 if gGameOn
and FLive
then
1920 Kill(K_SIMPLEKILL
, FUID
, HIT_SELF
);
1922 if FTeam
= TEAM_RED
then
1924 ChangeTeam(TEAM_BLUE
);
1925 g_Console_Add(Format(_lc
[I_PLAYER_CHTEAM_BLUE
], [FName
]), True);
1926 if g_Game_IsNet
then
1927 MH_SEND_GameEvent(NET_EV_CHANGE_TEAM
, TEAM_BLUE
, FName
);
1931 ChangeTeam(TEAM_RED
);
1932 g_Console_Add(Format(_lc
[I_PLAYER_CHTEAM_RED
], [FName
]), True);
1933 if g_Game_IsNet
then
1934 MH_SEND_GameEvent(NET_EV_CHANGE_TEAM
, TEAM_RED
, FName
);
1936 FPreferredTeam
:= FTeam
;
1939 procedure TPlayer
.ChangeTeam(Team
: Byte);
1946 TEAM_RED
, TEAM_BLUE
:
1947 FModel
.Color
:= TEAMCOLOR
[Team
];
1949 FModel
.Color
:= FColor
;
1951 if (FTeam
<> OldTeam
) and g_Game_IsNet
and g_Game_IsServer
then
1952 MH_SEND_PlayerStats(FUID
);
1956 procedure TPlayer.CollideItem();
1961 if gItems = nil then Exit;
1962 if not FLive then Exit;
1964 for i := 0 to High(gItems) do
1967 if (ItemType <> ITEM_NONE) and Live then
1968 if g_Obj_Collide(FObj.X+PLAYER_RECT.X, FObj.Y+PLAYER_RECT.Y, PLAYER_RECT.Width,
1969 PLAYER_RECT.Height, @Obj) then
1971 if not PickItem(ItemType, gItems[i].Respawnable, r) then Continue;
1973 if ItemType in [ITEM_SPHERE_BLUE, ITEM_SPHERE_WHITE, ITEM_INVUL] then
1974 g_Sound_PlayExAt('SOUND_ITEM_GETRULEZ', FObj.X, FObj.Y)
1975 else if ItemType in [ITEM_MEDKIT_SMALL, ITEM_MEDKIT_LARGE, ITEM_MEDKIT_BLACK] then
1976 g_Sound_PlayExAt('SOUND_ITEM_GETMED', FObj.X, FObj.Y)
1977 else g_Sound_PlayExAt('SOUND_ITEM_GETITEM', FObj.X, FObj.Y);
1979 // Íàäî óáðàòü ñ êàðòû, åñëè ýòî íå êëþ÷, êîòîðûì íóæíî ïîäåëèòñÿ ñ äðóãèì èãðîêîì:
1980 if r and not ((ItemType in [ITEM_KEY_RED, ITEM_KEY_GREEN, ITEM_KEY_BLUE]) and
1981 (gGameSettings.GameType = GT_SINGLE) and
1982 (g_Player_GetCount() > 1)) then
1983 if not Respawnable then g_Items_Remove(i) else g_Items_Pick(i);
1989 function TPlayer
.CollideLevel(XInc
, YInc
: Integer): Boolean;
1991 Result
:= g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
,
1992 PLAYER_RECT
.Width
, PLAYER_RECT
.Height
, PANEL_WALL
,
1996 constructor TPlayer
.Create();
2007 FSawSound
:= TPlayableSound
.Create();
2008 FSawSoundIdle
:= TPlayableSound
.Create();
2009 FSawSoundHit
:= TPlayableSound
.Create();
2010 FSawSoundSelect
:= TPlayableSound
.Create();
2011 FJetSoundFly
:= TPlayableSound
.Create();
2012 FJetSoundOn
:= TPlayableSound
.Create();
2013 FJetSoundOff
:= TPlayableSound
.Create();
2015 FSawSound
.SetByName('SOUND_WEAPON_FIRESAW');
2016 FSawSoundIdle
.SetByName('SOUND_WEAPON_IDLESAW');
2017 FSawSoundHit
.SetByName('SOUND_WEAPON_HITSAW');
2018 FSawSoundSelect
.SetByName('SOUND_WEAPON_SELECTSAW');
2019 FJetSoundFly
.SetByName('SOUND_PLAYER_JETFLY');
2020 FJetSoundOn
.SetByName('SOUND_PLAYER_JETON');
2021 FJetSoundOff
.SetByName('SOUND_PLAYER_JETOFF');
2023 FSpectatePlayer
:= -1;
2027 FSavedState
.WaitRecall
:= False;
2033 FActualModelName
:= 'doomer';
2036 FObj
.Rect
:= PLAYER_RECT
;
2038 FBFGFireCounter
:= -1;
2039 FJustTeleported
:= False;
2045 procedure TPlayer
.positionChanged ();
2049 procedure TPlayer
.Damage(value
: Word; SpawnerUID
: Word; vx
, vy
: Integer; t
: Byte);
2053 if (not g_Game_IsClient
) and (not FLive
) then
2058 // Íåóÿçâèìîñòü íå ñïàñàåò îò ëîâóøåê:
2059 if ((t
= HIT_TRAP
) or (t
= HIT_SELF
)) and (not FGodMode
) then
2061 if not g_Game_IsClient
then
2064 if t
= HIT_TRAP
then
2066 // Ëîâóøêà óáèâàåò ñðàçó:
2068 Kill(K_EXTRAHARDKILL
, SpawnerUID
, t
);
2070 if t
= HIT_SELF
then
2074 Kill(K_SIMPLEKILL
, SpawnerUID
, t
);
2077 // Îáíóëèòü äåéñòâèÿ ïðèìî÷åê, ÷òîáû ôîí ïðîïàë
2078 FMegaRulez
[MR_SUIT
] := 0;
2079 FMegaRulez
[MR_INVUL
] := 0;
2080 FMegaRulez
[MR_INVIS
] := 0;
2084 // Íî îò îñòàëüíîãî ñïàñàåò:
2085 if FMegaRulez
[MR_INVUL
] >= gTime
then
2092 // Åñëè åñòü óðîí ñâîèì, èëè ðàíèë ñàì ñåáÿ, èëè òåáÿ ðàíèë ïðîòèâíèê:
2093 if LongBool(gGameSettings
.Options
and GAME_OPTION_TEAMDAMAGE
) or
2094 (SpawnerUID
= FUID
) or
2095 (not SameTeam(FUID
, SpawnerUID
)) then
2097 FLastSpawnerUID
:= SpawnerUID
;
2099 // Êðîâü (ïóçûðüêè, åñëè â âîäå):
2100 if gBloodCount
> 0 then
2102 c
:= Min(value
, 200)*gBloodCount
+ Random(Min(value
, 200) div 2);
2103 if value
div 4 <= c
then
2104 c
:= c
- (value
div 4)
2108 if (t
= HIT_SOME
) and (vx
= 0) and (vy
= 0) then
2112 HIT_TRAP
, HIT_ACID
, HIT_FLAME
, HIT_SELF
: MakeBloodSimple(c
);
2113 HIT_BFG
, HIT_ROCKET
, HIT_SOME
: MakeBloodVector(c
, vx
, vy
);
2116 if t
= HIT_WATER
then
2117 g_GFX_Bubbles(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2),
2118 FObj
.Y
+PLAYER_RECT
.Y
-4, value
div 2, 8, 4);
2123 Inc(FDamageBuffer
, value
);
2127 FPain
:= FPain
+ value
;
2130 if g_Game_IsServer
and g_Game_IsNet
then
2132 MH_SEND_PlayerDamage(FUID
, t
, SpawnerUID
, value
, vx
, vy
);
2133 MH_SEND_PlayerStats(FUID
);
2134 MH_SEND_PlayerPos(False, FUID
);
2138 function TPlayer
.Heal(value
: Word; Soft
: Boolean): Boolean;
2141 if g_Game_IsClient
then
2146 if Soft
and (FHealth
< PLAYER_HP_SOFT
) then
2148 IncMax(FHealth
, value
, PLAYER_HP_SOFT
);
2151 if (not Soft
) and (FHealth
< PLAYER_HP_LIMIT
) then
2153 IncMax(FHealth
, value
, PLAYER_HP_LIMIT
);
2157 if Result
and g_Game_IsServer
and g_Game_IsNet
then
2158 MH_SEND_PlayerStats(FUID
);
2161 destructor TPlayer
.Destroy();
2163 if (gPlayer1
<> nil) and (gPlayer1
.FUID
= FUID
) then
2165 if (gPlayer2
<> nil) and (gPlayer2
.FUID
= FUID
) then
2169 FSawSoundIdle
.Free();
2170 FSawSoundHit
.Free();
2171 FJetSoundFly
.Free();
2173 FJetSoundOff
.Free();
2179 procedure TPlayer
.DrawBubble();
2181 bubX
, bubY
: Integer;
2184 Rw
, Gw
, Bw
: SmallInt;
2187 bubX
:= FObj
.X
+FObj
.Rect
.X
+ IfThen(FDirection
= D_LEFT
, -4, 18);
2188 bubY
:= FObj
.Y
+FObj
.Rect
.Y
- 18;
2196 1: // simple textual non-bubble
2198 bubX
:= FObj
.X
+FObj
.Rect
.X
- 11;
2199 bubY
:= FObj
.Y
+FObj
.Rect
.Y
- 17;
2200 e_TextureFontPrint(bubX
, bubY
, '[...]', gStdFont
);
2203 2: // advanced pixel-perfect bubble
2205 if FTeam
= TEAM_RED
then
2208 if FTeam
= TEAM_BLUE
then
2211 3: // colored bubble
2213 Rb
:= FModel
.Color
.R
;
2214 Gb
:= FModel
.Color
.G
;
2215 Bb
:= FModel
.Color
.B
;
2216 Rw
:= Min(Rb
* 2 + 64, 255);
2217 Gw
:= Min(Gb
* 2 + 64, 255);
2218 Bw
:= Min(Bb
* 2 + 64, 255);
2219 if (Abs(Rw
- Rb
) < 32)
2220 or (Abs(Gw
- Gb
) < 32)
2221 or (Abs(Bw
- Bb
) < 32) then
2223 Rb
:= Max(Rw
div 2 - 16, 0);
2224 Gb
:= Max(Gw
div 2 - 16, 0);
2225 Bb
:= Max(Bw
div 2 - 16, 0);
2228 4: // custom textured bubble
2230 if g_Texture_Get('TEXTURE_PLAYER_TALKBUBBLE', ID
) then
2231 if FDirection
= D_RIGHT
then
2232 e_Draw(ID
, bubX
- 6, bubY
- 7, 0, True, False)
2234 e_Draw(ID
, bubX
- 6, bubY
- 7, 0, True, False, M_HORIZONTAL
);
2240 e_DrawQuad(bubX
+ 1, bubY
, bubX
+ 18, bubY
+ 13, Rb
, Gb
, Bb
);
2241 e_DrawQuad(bubX
, bubY
+ 1, bubX
+ 19, bubY
+ 12, Rb
, Gb
, Bb
);
2243 e_DrawFillQuad(bubX
+ 1, bubY
+ 1, bubX
+ 18, bubY
+ 12, Rw
, Gw
, Bw
, 0);
2246 Dot
:= IfThen(FDirection
= D_LEFT
, 14, 5);
2247 e_DrawLine(1, bubX
+ Dot
, bubY
+ 14, bubX
+ Dot
, bubY
+ 16, Rb
, Gb
, Bb
);
2248 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
);
2249 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
);
2250 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
);
2251 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
);
2255 e_DrawFillQuad(bubX
+ Dot
, bubY
+ 8, bubX
+ Dot
+ 1, bubY
+ 9, Rb
, Gb
, Bb
, 0);
2256 e_DrawFillQuad(bubX
+ Dot
+ 3, bubY
+ 8, bubX
+ Dot
+ 4, bubY
+ 9, Rb
, Gb
, Bb
, 0);
2257 e_DrawFillQuad(bubX
+ Dot
+ 6, bubY
+ 8, bubX
+ Dot
+ 7, bubY
+ 9, Rb
, Gb
, Bb
, 0);
2260 procedure TPlayer
.Draw();
2268 if (FMegaRulez
[MR_INVUL
] > gTime
) and (gPlayerDrawn
<> Self
) then
2269 if g_Texture_Get('TEXTURE_PLAYER_INVULPENTA', ID
) then
2271 e_GetTextureSize(ID
, @w
, @h
);
2272 if FDirection
= D_LEFT
then
2273 e_Draw(ID
, FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2)-(w
div 2)+4,
2274 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2)-(h
div 2)-7, 0, True, False)
2276 e_Draw(ID
, FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2)-(w
div 2)-2,
2277 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2)-(h
div 2)-7, 0, True, False);
2280 if FMegaRulez
[MR_INVIS
] > gTime
then
2282 if (gPlayerDrawn
<> nil) and ((Self
= gPlayerDrawn
) or
2283 ((FTeam
= gPlayerDrawn
.Team
) and (gGameSettings
.GameMode
<> GM_DM
))) then
2285 if (FMegaRulez
[MR_INVIS
] - gTime
) <= 2100 then
2286 dr
:= not Odd((FMegaRulez
[MR_INVIS
] - gTime
) div 300)
2290 FModel
.Draw(FObj
.X
, FObj
.Y
, 200)
2292 FModel
.Draw(FObj
.X
, FObj
.Y
);
2295 FModel
.Draw(FObj
.X
, FObj
.Y
, 254);
2298 FModel
.Draw(FObj
.X
, FObj
.Y
);
2301 if g_debug_Frames
then
2303 e_DrawQuad(FObj
.X
+FObj
.Rect
.X
,
2305 FObj
.X
+FObj
.Rect
.X
+FObj
.Rect
.Width
-1,
2306 FObj
.Y
+FObj
.Rect
.Y
+FObj
.Rect
.Height
-1,
2310 if (gChatBubble
> 0) and (FKeys
[KEY_CHAT
].Pressed
) and not FGhost
then
2312 // e_DrawPoint(5, 335, 288, 255, 0, 0); // DL, UR, DL, UR
2313 if gAimLine
and Live
and
2314 ((Self
= gPlayer1
) or (Self
= gPlayer2
)) then
2320 plrMouseX
: Integer = -666;
2321 plrMouseY
: Integer = -666;
2323 //vpw, vph: Integer;
2324 laserX0
, laserY0
, laserX1
, laserY1
: Integer;
2325 monMarkedUID
: Integer = -1;
2327 function pmsCurMapX (): Integer; inline; begin result
:= plrMouseX
+vpx
; end;
2328 function pmsCurMapY (): Integer; inline; begin result
:= plrMouseY
+vpy
; end;
2330 procedure plrDebugMouse (msx
, msy
, but
: Integer; bstate
: Integer);
2332 function wallToggle (pan
: TPanel
; tag
: Integer): Boolean;
2334 result
:= false; // don't stop
2335 if pan
.Enabled
then g_Map_DisableWall(pan
.arrIdx
) else g_Map_EnableWall(pan
.arrIdx
);
2338 function monsAtDump (mon
: TMonster
; tag
: Integer): Boolean;
2340 result
:= false; // don't stop
2341 e_WriteLog(Format('monster #%d; UID=%d', [mon
.arrIdx
, mon
.UID
]), MSG_NOTIFY
);
2342 monMarkedUID
:= mon
.UID
;
2343 //if pan.Enabled then g_Map_DisableWall(pan.arrIdx) else g_Map_EnableWall(pan.arrIdx);
2349 //e_WriteLog(Format('mouse: x=%d; y=%d; but=%d; bstate=%d', [msx, msy, but, bstate]), MSG_NOTIFY);
2350 if (gPlayer1
= nil) then exit
;
2352 if (but
= MouseLeft
) then
2354 mapGrid
.forEachAtPoint(pmsCurMapX
, pmsCurMapY
, wallToggle
, (GridTagWall
or GridTagDoor
));
2358 if (but
= MouseRight
) then
2361 e_WriteLog('===========================', MSG_NOTIFY
);
2362 monsGrid
.forEachAtPoint(pmsCurMapX
, pmsCurMapY
, monsAtDump
);
2363 e_WriteLog('---------------------------', MSG_NOTIFY
);
2369 procedure plrDebugDrawMouse ();
2371 function monsCollector (mon
: TMonster
; tag
: Integer): Boolean;
2374 mx
, my
, mw
, mh
: Integer;
2377 mon
.getMapBox(mx
, my
, mw
, mh
);
2378 e_DrawQuad(mx
, my
, mx
+mw
-1, my
+mh
-1, 255, 255, 0, 96);
2379 if lineAABBIntersects(laserX0
, laserY0
, laserX1
, laserY1
, mx
, my
, mw
, mh
, ex
, ey
) then
2381 e_DrawPoint(8, ex
, ey
, 0, 255, 0);
2387 mx
, my
, mw
, mh
: Integer;
2389 e_DrawPoint(4, plrMouseX
, plrMouseY
, 255, 0, 255);
2390 if (gPlayer1
= nil) then exit
;
2392 //e_WriteLog(Format('(%d,%d)-(%d,%d)', [laserX0, laserY0, laserX1, laserY1]), MSG_NOTIFY);
2395 glTranslatef(-vpx
, -vpy
, 0);
2397 g_Mons_AlongLine(laserX0
, laserY0
, laserX1
, laserY1
, monsCollector
, true);
2399 if (monMarkedUID
<> -1) then
2401 mon
:= g_Monsters_ByUID(monMarkedUID
);
2402 if (mon
<> nil) then
2404 mon
.getMapBox(mx
, my
, mw
, mh
);
2405 e_DrawQuad(mx
, my
, mx
+mw
-1, my
+mh
-1, 255, 0, 0, 30);
2409 //e_DrawPoint(16, laserX0, laserY0, 255, 255, 255);
2415 procedure TPlayer
.DrawAim();
2416 procedure drawCast (sz
: Integer; ax0
, ay0
, ax1
, ay1
: Integer);
2418 procedure drawTileGrid ();
2422 y
:= mapGrid
.gridY0
;
2423 while (y
< mapGrid
.gridY0
+mapGrid
.gridHeight
) do
2425 x
:= mapGrid
.gridX0
;
2426 while (x
< mapGrid
.gridX0
+mapGrid
.gridWidth
) do
2428 if (x
+mapGrid
.tileSize
> viewPortX
) and (y
+mapGrid
.tileSize
> viewPortY
) and
2429 (x
< viewPortX
+viewPortW
) and (y
< viewPortY
+viewPortH
) then
2431 e_DrawQuad(x
, y
, x
+mapGrid
.tileSize
-1, y
+mapGrid
.tileSize
-1, 96, 96, 96, 96);
2433 Inc(x
, mapGrid
.tileSize
);
2435 Inc(y
, mapGrid
.tileSize
);
2442 //mx, my, mw, mh: Integer;
2444 if isValidViewPort
and (self
= gPlayer1
) then
2450 evMouseCB
:= plrDebugMouse
;
2451 postdrawMouse
:= plrDebugDrawMouse
;
2459 e_DrawLine(sz
, ax0
, ay0
, ax1
, ay1
, 255, 0, 0, 96);
2460 if (g_Map_traceToNearestWall(ax0
, ay0
, ax1
, ay1
, @ex
, @ey
) <> nil) then
2462 e_DrawLine(sz
, ax0
, ay0
, ex
, ey
, 0, 255, 0, 96);
2466 e_DrawLine(sz
, ax0
, ay0
, ex
, ey
, 0, 0, 255, 96);
2470 mon := g_Mons_ByIdx(0);
2471 mon.getMapBox(mx, my, mw, mh);
2474 e_DrawLine(2, ax0, ay0, ax1, ay1, 0, 96, 96, 96);
2476 if lineAABBIntersects(ax0, ay0, ax1, ay1, mx, my, mw, mh, ex, ey) then
2478 e_DrawLine(2, ax0, ay0, ex, ey, 255, 255, 0, 96);
2482 e_DrawLine(2, ax0, ay0, ex, ey, 255, 127, 0, 96);
2490 wx
, wy
, xx
, yy
: Integer;
2494 wx
:= FObj
.X
+ WEAPONPOINT
[FDirection
].X
+ IfThen(FDirection
= D_LEFT
, 7, -7);
2495 wy
:= FObj
.Y
+ WEAPONPOINT
[FDirection
].Y
;
2504 1: begin // Chainsaw
2511 if angle
= ANGLE_RIGHTUP
then Dec(angle
, 2);
2512 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 4);
2513 if angle
= ANGLE_LEFTUP
then Inc(angle
, 2);
2514 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 4);
2519 if angle
= ANGLE_RIGHTUP
then Dec(angle
, 2);
2520 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 4);
2521 if angle
= ANGLE_LEFTUP
then Inc(angle
, 2);
2522 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 4);
2524 4: begin // Double Shotgun
2527 if angle
= ANGLE_RIGHTUP
then Dec(angle
, 2);
2528 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 4);
2529 if angle
= ANGLE_LEFTUP
then Inc(angle
, 2);
2530 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 4);
2532 5: begin // Chaingun
2535 if angle
= ANGLE_RIGHTUP
then Dec(angle
, 2);
2536 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 4);
2537 if angle
= ANGLE_LEFTUP
then Inc(angle
, 2);
2538 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 4);
2540 6: begin // Rocket Launcher
2543 if angle
= ANGLE_RIGHTUP
then Inc(angle
, 2);
2544 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 4);
2545 if angle
= ANGLE_LEFTUP
then Dec(angle
, 2);
2546 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 4);
2548 7: begin // Plasmagun
2551 if angle
= ANGLE_RIGHTUP
then Inc(angle
);
2552 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 3);
2553 if angle
= ANGLE_LEFTUP
then Dec(angle
);
2554 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 3);
2559 if angle
= ANGLE_RIGHTUP
then Inc(angle
, 1);
2560 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 2);
2561 if angle
= ANGLE_LEFTUP
then Dec(angle
, 1);
2562 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 2);
2564 9: begin // Super Chaingun
2567 if angle
= ANGLE_RIGHTUP
then Dec(angle
, 2);
2568 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 4);
2569 if angle
= ANGLE_LEFTUP
then Inc(angle
, 2);
2570 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 4);
2573 xx
:= Trunc(Cos(-DegToRad(angle
)) * len
) + wx
;
2574 yy
:= Trunc(Sin(-DegToRad(angle
)) * len
) + wy
;
2575 {$IF DEFINED(D2F_DEBUG)}
2576 drawCast(sz
, wx
, wy
, xx
, yy
);
2578 e_DrawLine(sz
, wx
, wy
, xx
, yy
, 255, 0, 0, 96);
2582 procedure TPlayer
.DrawGUI();
2585 X
, Y
, SY
, a
, p
, m
: Integer;
2589 stat
: TPlayerStatArray
;
2591 X
:= gPlayerScreenSize
.X
;
2592 SY
:= gPlayerScreenSize
.Y
;
2595 if gShowGoals
and (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then
2597 if gGameSettings
.GameMode
= GM_CTF
then
2601 if gGameSettings
.GameMode
= GM_CTF
then
2603 s
:= 'TEXTURE_PLAYER_REDFLAG';
2604 if gFlags
[FLAG_RED
].State
= FLAG_STATE_CAPTURED
then
2605 s
:= 'TEXTURE_PLAYER_REDFLAG_S';
2606 if gFlags
[FLAG_RED
].State
= FLAG_STATE_DROPPED
then
2607 s
:= 'TEXTURE_PLAYER_REDFLAG_D';
2608 if g_Texture_Get(s
, ID
) then
2609 e_Draw(ID
, X
-16-32, 240-72-4, 0, True, False);
2612 s
:= IntToStr(gTeamStat
[TEAM_RED
].Goals
);
2613 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2614 e_CharFont_PrintEx(gMenuFont
, X
-16-a
-tw
, 240-72-4, s
, TEAMCOLOR
[TEAM_RED
]);
2616 if gGameSettings
.GameMode
= GM_CTF
then
2618 s
:= 'TEXTURE_PLAYER_BLUEFLAG';
2619 if gFlags
[FLAG_BLUE
].State
= FLAG_STATE_CAPTURED
then
2620 s
:= 'TEXTURE_PLAYER_BLUEFLAG_S';
2621 if gFlags
[FLAG_BLUE
].State
= FLAG_STATE_DROPPED
then
2622 s
:= 'TEXTURE_PLAYER_BLUEFLAG_D';
2623 if g_Texture_Get(s
, ID
) then
2624 e_Draw(ID
, X
-16-32, 240-32-4, 0, True, False);
2627 s
:= IntToStr(gTeamStat
[TEAM_BLUE
].Goals
);
2628 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2629 e_CharFont_PrintEx(gMenuFont
, X
-16-a
-tw
, 240-32-4, s
, TEAMCOLOR
[TEAM_BLUE
]);
2632 if g_Texture_Get('TEXTURE_PLAYER_HUDBG', ID
) then
2633 e_DrawFill(ID
, X
, 0, 1, (gPlayerScreenSize
.Y
div 256)+IfThen(gPlayerScreenSize
.Y
mod 256 > 0, 1, 0),
2636 if g_Texture_Get('TEXTURE_PLAYER_HUD', ID
) then
2637 e_Draw(ID
, X
+2, Y
, 0, True, False);
2639 if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
2643 s
:= IntToStr(Frags
);
2644 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2645 e_CharFont_PrintEx(gMenuFont
, X
-16-tw
, Y
, s
, _RGB(255, 0, 0));
2650 stat
:= g_Player_GetStats();
2655 for a
:= 0 to High(stat
) do
2656 if stat
[a
].Name
<> Name
then
2658 if stat
[a
].Frags
> m
then m
:= stat
[a
].Frags
;
2659 if stat
[a
].Frags
> Frags
then p
:= p
+1;
2663 s
:= IntToStr(p
)+' / '+IntToStr(Length(stat
))+' ';
2664 if Frags
>= m
then s
:= s
+'+' else s
:= s
+'-';
2665 s
:= s
+IntToStr(Abs(Frags
-m
));
2667 e_CharFont_GetSize(gMenuSmallFont
, s
, tw
, th
);
2668 e_CharFont_PrintEx(gMenuSmallFont
, X
-16-tw
, Y
+32, s
, _RGB(255, 0, 0));
2671 if gShowLives
and (gGameSettings
.MaxLives
> 0) then
2673 s
:= IntToStr(Lives
);
2674 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2675 e_CharFont_PrintEx(gMenuFont
, X
-16-tw
, SY
-32, s
, _RGB(0, 255, 0));
2679 e_CharFont_GetSize(gMenuSmallFont
, FName
, tw
, th
);
2680 e_CharFont_PrintEx(gMenuSmallFont
, X
+98-(tw
div 2), Y
+8, FName
, _RGB(255, 0, 0));
2682 if R_BERSERK
in FRulez
then
2683 e_Draw(gItemsTexturesID
[ITEM_MEDKIT_BLACK
], X
+37, Y
+45, 0, True, False)
2685 e_Draw(gItemsTexturesID
[ITEM_MEDKIT_LARGE
], X
+37, Y
+45, 0, True, False);
2687 if g_Texture_Get('TEXTURE_PLAYER_ARMORHUD', ID
) then
2688 e_Draw(ID
, X
+36, Y
+77, 0, True, False);
2690 s
:= IntToStr(IfThen(FHealth
> 0, FHealth
, 0));
2691 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2692 e_CharFont_PrintEx(gMenuFont
, X
+178-tw
, Y
+40, s
, _RGB(255, 0, 0));
2694 s
:= IntToStr(FArmor
);
2695 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2696 e_CharFont_PrintEx(gMenuFont
, X
+178-tw
, Y
+68, s
, _RGB(255, 0, 0));
2698 s
:= IntToStr(GetAmmoByWeapon(FCurrWeap
));
2704 ID
:= gItemsTexturesID
[ITEM_WEAPON_KASTET
];
2709 ID
:= gItemsTexturesID
[ITEM_WEAPON_SAW
];
2711 WEAPON_PISTOL
: ID
:= gItemsTexturesID
[ITEM_WEAPON_PISTOL
];
2712 WEAPON_CHAINGUN
: ID
:= gItemsTexturesID
[ITEM_WEAPON_CHAINGUN
];
2713 WEAPON_SHOTGUN1
: ID
:= gItemsTexturesID
[ITEM_WEAPON_SHOTGUN1
];
2714 WEAPON_SHOTGUN2
: ID
:= gItemsTexturesID
[ITEM_WEAPON_SHOTGUN2
];
2715 WEAPON_SUPERPULEMET
: ID
:= gItemsTexturesID
[ITEM_WEAPON_SUPERPULEMET
];
2716 WEAPON_ROCKETLAUNCHER
: ID
:= gItemsTexturesID
[ITEM_WEAPON_ROCKETLAUNCHER
];
2717 WEAPON_PLASMA
: ID
:= gItemsTexturesID
[ITEM_WEAPON_PLASMA
];
2718 WEAPON_BFG
: ID
:= gItemsTexturesID
[ITEM_WEAPON_BFG
];
2719 WEAPON_FLAMETHROWER
: ID
:= gItemsTexturesID
[ITEM_WEAPON_FLAMETHROWER
];
2722 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2723 e_CharFont_PrintEx(gMenuFont
, X
+178-tw
, Y
+158, s
, _RGB(255, 0, 0));
2724 e_Draw(ID
, X
+20, Y
+160, 0, True, False);
2726 if R_KEY_RED
in FRulez
then
2727 e_Draw(gItemsTexturesID
[ITEM_KEY_RED
], X
+78, Y
+214, 0, True, False);
2729 if R_KEY_GREEN
in FRulez
then
2730 e_Draw(gItemsTexturesID
[ITEM_KEY_GREEN
], X
+95, Y
+214, 0, True, False);
2732 if R_KEY_BLUE
in FRulez
then
2733 e_Draw(gItemsTexturesID
[ITEM_KEY_BLUE
], X
+112, Y
+214, 0, True, False);
2735 if FJetFuel
> 0 then
2737 if g_Texture_Get('TEXTURE_PLAYER_HUDAIR', ID
) then
2738 e_Draw(ID
, X
+2, Y
+116, 0, True, False);
2739 if g_Texture_Get('TEXTURE_PLAYER_HUDJET', ID
) then
2740 e_Draw(ID
, X
+2, Y
+126, 0, True, False);
2741 e_DrawLine(4, X
+16, Y
+122, X
+16+Trunc(168*IfThen(FAir
> 0, FAir
, 0)/AIR_MAX
), Y
+122, 0, 0, 196);
2742 e_DrawLine(4, X
+16, Y
+132, X
+16+Trunc(168*FJetFuel
/JET_MAX
), Y
+132, 208, 0, 0);
2746 if g_Texture_Get('TEXTURE_PLAYER_HUDAIR', ID
) then
2747 e_Draw(ID
, X
+2, Y
+124, 0, True, False);
2748 e_DrawLine(4, X
+16, Y
+130, X
+16+Trunc(168*IfThen(FAir
> 0, FAir
, 0)/AIR_MAX
), Y
+130, 0, 0, 196);
2751 if gShowPing
and g_Game_IsClient
then
2753 s
:= _lc
[I_GAME_PING_HUD
] + IntToStr(NetPeer
.lastRoundTripTime
) + _lc
[I_NET_SLIST_PING_MS
];
2754 e_TextureFontPrint(X
+ 4, Y
+ 242, s
, gStdFont
);
2760 e_TextureFontPrint(X
+ 4, Y
+ 242, _lc
[I_PLAYER_SPECT
], gStdFont
);
2761 e_TextureFontPrint(X
+ 4, Y
+ 258, _lc
[I_PLAYER_SPECT2
], gStdFont
);
2762 e_TextureFontPrint(X
+ 4, Y
+ 274, _lc
[I_PLAYER_SPECT1
], gStdFont
);
2765 e_TextureFontGetSize(gStdFont
, cw
, ch
);
2766 s
:= _lc
[I_PLAYER_SPECT4
];
2767 e_TextureFontPrintEx(gScreenWidth
div 2 - cw
*(Length(s
) div 2),
2768 gScreenHeight
-4-ch
, s
, gStdFont
, 255, 255, 255, 1, True);
2769 e_TextureFontPrint(X
+ 4, Y
+ 290, _lc
[I_PLAYER_SPECT1S
], gStdFont
);
2775 procedure TPlayer
.DrawRulez();
2779 // Ïðè âçÿòèè íåóÿçâèìîñòè ðèñóåòñÿ èíâåðñèîííûé áåëûé ôîí
2780 if FMegaRulez
[MR_INVUL
] >= gTime
then
2782 if (FMegaRulez
[MR_INVUL
]-gTime
) <= 2100 then
2783 dr
:= not Odd((FMegaRulez
[MR_INVUL
]-gTime
) div 300)
2788 e_DrawFillQuad(0, 0, gPlayerScreenSize
.X
-1, gPlayerScreenSize
.Y
-1,
2789 191, 191, 191, 0, B_INVERT
);
2792 // Ïðè âçÿòèè çàùèòíîãî êîñòþìà ðèñóåòñÿ çåëåíîâàòûé ôîí
2793 if FMegaRulez
[MR_SUIT
] >= gTime
then
2795 if (FMegaRulez
[MR_SUIT
]-gTime
) <= 2100 then
2796 dr
:= not Odd((FMegaRulez
[MR_SUIT
]-gTime
) div 300)
2801 e_DrawFillQuad(0, 0, gPlayerScreenSize
.X
-1, gPlayerScreenSize
.Y
-1,
2802 0, 96, 0, 200, B_NONE
);
2805 // Ïðè âçÿòèè áåðñåðêà ðèñóåòñÿ êðàñíîâàòûé ôîí
2806 if (FBerserk
>= 0) and (LongWord(FBerserk
) >= gTime
) and (gFlash
= 2) then
2808 e_DrawFillQuad(0, 0, gPlayerScreenSize
.X
-1, gPlayerScreenSize
.Y
-1,
2809 255, 0, 0, 200, B_NONE
);
2813 procedure TPlayer
.DrawPain();
2817 if FPain
= 0 then Exit
;
2821 if a
< 15 then h
:= 0
2822 else if a
< 35 then h
:= 1
2823 else if a
< 55 then h
:= 2
2824 else if a
< 75 then h
:= 3
2825 else if a
< 95 then h
:= 4
2828 //if a > 255 then a := 255;
2830 e_DrawFillQuad(0, 0, gPlayerScreenSize
.X
-1, gPlayerScreenSize
.Y
-1, 255, 0, 0, 255-h
*50);
2831 //e_DrawFillQuad(0, 0, gPlayerScreenSize.X-1, gPlayerScreenSize.Y-1, 255-min(128, a), 255-a, 255-a, 0, B_FILTER);
2834 procedure TPlayer
.DrawPickup();
2838 if FPickup
= 0 then Exit
;
2842 if a
< 15 then h
:= 1
2843 else if a
< 35 then h
:= 2
2844 else if a
< 55 then h
:= 3
2845 else if a
< 75 then h
:= 4
2848 e_DrawFillQuad(0, 0, gPlayerScreenSize
.X
-1, gPlayerScreenSize
.Y
-1, 150, 200, 150, 255-h
*50);
2851 procedure TPlayer
.Fire();
2853 f
, DidFire
: Boolean;
2854 wx
, wy
, xd
, yd
: Integer;
2857 if g_Game_IsClient
then Exit
;
2858 // FBFGFireCounter - âðåìÿ ïåðåä âûñòðåëîì (äëÿ BFG)
2859 // FReloading - âðåìÿ ïîñëå âûñòðåëà (äëÿ âñåãî)
2867 if FReloading
[FCurrWeap
] <> 0 then Exit
;
2872 wx
:= FObj
.X
+WEAPONPOINT
[FDirection
].X
;
2873 wy
:= FObj
.Y
+WEAPONPOINT
[FDirection
].Y
;
2874 xd
:= wx
+IfThen(FDirection
= D_LEFT
, -30, 30);
2875 yd
:= wy
+firediry();
2880 if R_BERSERK
in FRulez
then
2882 //g_Weapon_punch(FObj.X+FObj.Rect.X, FObj.Y+FObj.Rect.Y, 75, FUID);
2883 locobj
.X
:= FObj
.X
+FObj
.Rect
.X
;
2884 locobj
.Y
:= FObj
.Y
+FObj
.Rect
.Y
;
2887 locobj
.rect
.Width
:= 39;
2888 locobj
.rect
.Height
:= 52;
2889 locobj
.Vel
.X
:= (xd
-wx
) div 2;
2890 locobj
.Vel
.Y
:= (yd
-wy
) div 2;
2891 locobj
.Accel
.X
:= xd
-wx
;
2892 locobj
.Accel
.y
:= yd
-wy
;
2894 if g_Weapon_Hit(@locobj
, 50, FUID
, HIT_SOME
) <> 0 then
2895 g_Sound_PlayExAt('SOUND_WEAPON_HITBERSERK', FObj
.X
, FObj
.Y
)
2897 g_Sound_PlayExAt('SOUND_WEAPON_MISSBERSERK', FObj
.X
, FObj
.Y
);
2901 FPain
:= min(FPain
+ 25, 50);
2902 end else g_Weapon_punch(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
, 3, FUID
);
2905 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
2910 if g_Weapon_chainsaw(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
,
2911 IfThen(gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
], 9, 3), FUID
) <> 0 then
2913 FSawSoundSelect
.Stop();
2915 FSawSoundHit
.PlayAt(FObj
.X
, FObj
.Y
);
2917 else if not FSawSoundHit
.IsPlaying() then
2919 FSawSoundSelect
.Stop();
2920 FSawSound
.PlayAt(FObj
.X
, FObj
.Y
);
2923 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
2929 if FAmmo
[A_BULLETS
] > 0 then
2931 g_Weapon_pistol(wx
, wy
, xd
, yd
, FUID
);
2932 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
2933 Dec(FAmmo
[A_BULLETS
]);
2934 FFireAngle
:= FAngle
;
2937 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
2938 GameVelX
, GameVelY
-2, SHELL_BULLET
);
2942 if FAmmo
[A_SHELLS
] > 0 then
2944 g_Weapon_shotgun(wx
, wy
, xd
, yd
, FUID
);
2945 if not gSoundEffectsDF
then g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN', wx
, wy
);
2946 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
2947 Dec(FAmmo
[A_SHELLS
]);
2948 FFireAngle
:= FAngle
;
2952 FShellType
:= SHELL_SHELL
;
2956 if FAmmo
[A_SHELLS
] >= 2 then
2958 g_Weapon_dshotgun(wx
, wy
, xd
, yd
, FUID
);
2959 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
2960 Dec(FAmmo
[A_SHELLS
], 2);
2961 FFireAngle
:= FAngle
;
2965 FShellType
:= SHELL_DBLSHELL
;
2969 if FAmmo
[A_BULLETS
] > 0 then
2971 g_Weapon_mgun(wx
, wy
, xd
, yd
, FUID
);
2972 if not gSoundEffectsDF
then g_Sound_PlayExAt('SOUND_WEAPON_FIREPISTOL', wx
, wy
);
2973 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
2974 Dec(FAmmo
[A_BULLETS
]);
2975 FFireAngle
:= FAngle
;
2978 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
2979 GameVelX
, GameVelY
-2, SHELL_BULLET
);
2982 WEAPON_ROCKETLAUNCHER
:
2983 if FAmmo
[A_ROCKETS
] > 0 then
2985 g_Weapon_rocket(wx
, wy
, xd
, yd
, FUID
);
2986 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
2987 Dec(FAmmo
[A_ROCKETS
]);
2988 FFireAngle
:= FAngle
;
2994 if FAmmo
[A_CELLS
] > 0 then
2996 g_Weapon_plasma(wx
, wy
, xd
, yd
, FUID
);
2997 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
2998 Dec(FAmmo
[A_CELLS
]);
2999 FFireAngle
:= FAngle
;
3005 if (FAmmo
[A_CELLS
] >= 40) and (FBFGFireCounter
= -1) then
3007 FBFGFireCounter
:= 17;
3008 if not FNoReload
then
3009 g_Sound_PlayExAt('SOUND_WEAPON_STARTFIREBFG', FObj
.X
, FObj
.Y
);
3010 Dec(FAmmo
[A_CELLS
], 40);
3014 WEAPON_SUPERPULEMET
:
3015 if FAmmo
[A_SHELLS
] > 0 then
3017 g_Weapon_shotgun(wx
, wy
, xd
, yd
, FUID
);
3018 if not gSoundEffectsDF
then g_Sound_PlayExAt('SOUND_WEAPON_FIRECGUN', wx
, wy
);
3019 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
3020 Dec(FAmmo
[A_SHELLS
]);
3021 FFireAngle
:= FAngle
;
3024 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
3025 GameVelX
, GameVelY
-2, SHELL_SHELL
);
3028 WEAPON_FLAMETHROWER
:
3029 if FAmmo
[A_FUEL
] > 0 then
3031 g_Weapon_flame(wx
, wy
, xd
, yd
, FUID
);
3032 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
3034 FFireAngle
:= FAngle
;
3040 if g_Game_IsNet
then
3044 if FCurrWeap
<> WEAPON_BFG
then
3045 MH_SEND_PlayerFire(FUID
, FCurrWeap
, wx
, wy
, xd
, yd
, LastShotID
)
3047 if not FNoReload
then
3048 MH_SEND_Sound(FObj
.X
, FObj
.Y
, 'SOUND_WEAPON_STARTFIREBFG');
3051 MH_SEND_PlayerStats(FUID
);
3056 if (FAngle
= 0) or (FAngle
= 180) then SetAction(A_ATTACK
)
3057 else if (FAngle
= ANGLE_LEFTDOWN
) or (FAngle
= ANGLE_RIGHTDOWN
) then SetAction(A_ATTACKDOWN
)
3058 else if (FAngle
= ANGLE_LEFTUP
) or (FAngle
= ANGLE_RIGHTUP
) then SetAction(A_ATTACKUP
);
3061 function TPlayer
.GetAmmoByWeapon(Weapon
: Byte): Word;
3064 WEAPON_PISTOL
, WEAPON_CHAINGUN
: Result
:= FAmmo
[A_BULLETS
];
3065 WEAPON_SHOTGUN1
, WEAPON_SHOTGUN2
, WEAPON_SUPERPULEMET
: Result
:= FAmmo
[A_SHELLS
];
3066 WEAPON_ROCKETLAUNCHER
: Result
:= FAmmo
[A_ROCKETS
];
3067 WEAPON_PLASMA
, WEAPON_BFG
: Result
:= FAmmo
[A_CELLS
];
3068 WEAPON_FLAMETHROWER
: Result
:= FAmmo
[A_FUEL
];
3073 function TPlayer
.HeadInLiquid(XInc
, YInc
: Integer): Boolean;
3075 Result
:= g_Map_CollidePanel(FObj
.X
+PLAYER_HEADRECT
.X
+XInc
, FObj
.Y
+PLAYER_HEADRECT
.Y
+YInc
,
3076 PLAYER_HEADRECT
.Width
, PLAYER_HEADRECT
.Height
,
3077 PANEL_WATER
or PANEL_ACID1
or PANEL_ACID2
, True);
3080 procedure TPlayer
.JetpackOn
;
3084 FJetSoundOn
.SetPosition(0);
3085 FJetSoundOn
.PlayAt(FObj
.X
, FObj
.Y
);
3089 procedure TPlayer
.JetpackOff
;
3093 FJetSoundOff
.SetPosition(0);
3094 FJetSoundOff
.PlayAt(FObj
.X
, FObj
.Y
);
3097 procedure TPlayer
.CatchFire(Attacker
: Word);
3100 FFireAttacker
:= Attacker
;
3101 if g_Game_IsNet
and g_Game_IsServer
then
3102 MH_SEND_PlayerStats(FUID
);
3105 procedure TPlayer
.Jump();
3107 if gFly
or FJetpack
then
3109 // Ïîëåò (÷èò-êîä èëè äæåòïàê):
3110 if FObj
.Vel
.Y
> -VEL_FLY
then
3111 FObj
.Vel
.Y
:= FObj
.Vel
.Y
- 3;
3114 if FJetFuel
> 0 then
3116 if (FJetFuel
< 1) and g_Game_IsServer
then
3120 if g_Game_IsNet
then
3121 MH_SEND_PlayerStats(FUID
);
3127 // Íå âêëþ÷àòü äæåòïàê â ðåæèìå ïðîõîæäåíèÿ ñêâîçü ñòåíû
3129 FCanJetpack
:= False;
3131 // Ïðûãàåì èëè âñïëûâàåì:
3132 if (CollideLevel(0, 1) or
3133 g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+PLAYER_RECT
.Y
+36, PLAYER_RECT
.Width
,
3134 PLAYER_RECT
.Height
-33, PANEL_STEP
, False)
3135 ) and (FObj
.Accel
.Y
= 0) then // Íå ïðûãàòü, åñëè åñòü âåðòèêàëüíîå óñêîðåíèå
3137 FObj
.Vel
.Y
:= -VEL_JUMP
;
3138 FCanJetpack
:= False;
3142 if BodyInLiquid(0, 0) then
3143 FObj
.Vel
.Y
:= -VEL_SW
3144 else if (FJetFuel
> 0) and FCanJetpack
and
3145 g_Game_IsServer
and (not g_Obj_CollideLiquid(@FObj
, 0, 0)) then
3149 if g_Game_IsNet
then
3150 MH_SEND_PlayerStats(FUID
);
3155 procedure TPlayer
.Kill(KillType
: Byte; SpawnerUID
: Word; t
: Byte);
3157 a
, i
, k
, ab
, ar
: Byte;
3161 srv
, netsrv
: Boolean;
3167 procedure PushItem(t
: Byte);
3171 id
:= g_Items_Create(FObj
.X
, FObj
.Y
, t
, True, False);
3172 it
:= g_Items_ByIdx(id
);
3173 if KillType
= K_EXTRAHARDKILL
then // -7..+7; -8..0
3175 g_Obj_Push(@it
.Obj
, (FObj
.Vel
.X
div 2)-7+Random(15),
3176 (FObj
.Vel
.Y
div 2)-Random(9));
3177 it
.positionChanged(); // this updates spatial accelerators
3181 if KillType
= K_HARDKILL
then // -5..+5; -5..0
3183 g_Obj_Push(@it
.Obj
, (FObj
.Vel
.X
div 2)-5+Random(11),
3184 (FObj
.Vel
.Y
div 2)-Random(6));
3186 else // -3..+3; -3..0
3188 g_Obj_Push(@it
.Obj
, (FObj
.Vel
.X
div 2)-3+Random(7),
3189 (FObj
.Vel
.Y
div 2)-Random(4));
3191 it
.positionChanged(); // this updates spatial accelerators
3194 if g_Game_IsNet
and g_Game_IsServer
then
3195 MH_SEND_ItemSpawn(True, id
);
3199 DoFrags
:= (gGameSettings
.MaxLives
= 0) or (gGameSettings
.GameMode
= GM_COOP
);
3200 Srv
:= g_Game_IsServer
;
3201 Netsrv
:= g_Game_IsServer
and g_Game_IsNet
;
3202 if Srv
then FDeath
:= FDeath
+ 1;
3207 if not FPhysics
then
3213 if (gGameSettings
.MaxLives
> 0) and Srv
and (gLMSRespawn
= LMS_RESPAWN_NONE
) then
3215 if FLives
> 0 then FLives
:= FLives
- 1;
3216 if FLives
= 0 then FNoRespawn
:= True;
3219 // Íîìåð òèïà ñìåðòè:
3222 K_SIMPLEKILL
: a
:= 1;
3224 K_EXTRAHARDKILL
: a
:= 3;
3229 if not FModel
.PlaySound(MODELSOUND_DIE
, a
, FObj
.X
, FObj
.Y
) then
3231 if FModel
.PlaySound(MODELSOUND_DIE
, i
, FObj
.X
, FObj
.Y
) then
3238 FTime
[T_RESPAWN
] := gTime
+ TIME_RESPAWN1
;
3240 FTime
[T_RESPAWN
] := gTime
+ TIME_RESPAWN2
;
3241 K_EXTRAHARDKILL
, K_FALLKILL
:
3242 FTime
[T_RESPAWN
] := gTime
+ TIME_RESPAWN3
;
3245 // Ïåðåêëþ÷àåì ñîñòîÿíèå:
3249 K_HARDKILL
, K_EXTRAHARDKILL
:
3253 // Ðåàêöèÿ ìîíñòðîâ íà ñìåðòü èãðîêà:
3254 if (KillType
<> K_FALLKILL
) and (Srv
) then
3255 g_Monsters_killedp();
3257 if SpawnerUID
= FUID
then
3259 if Srv
and (DoFrags
or (gGameSettings
.GameMode
= GM_TDM
)) then
3264 g_Console_Add(Format(_lc
[I_PLAYER_KILL_SELF
], [FName
]), True);
3267 if g_GetUIDType(SpawnerUID
) = UID_PLAYER
then
3268 begin // Óáèò äðóãèì èãðîêîì
3269 KP
:= g_Player_Get(SpawnerUID
);
3270 if (KP
<> nil) and Srv
then
3272 if (DoFrags
or (gGameSettings
.GameMode
= GM_TDM
)) then
3273 if SameTeam(FUID
, SpawnerUID
) then
3283 if (gGameSettings
.GameMode
= GM_TDM
) and DoFrags
then
3284 Inc(gTeamStat
[KP
.Team
].Goals
,
3285 IfThen(SameTeam(FUID
, SpawnerUID
), -1, 1));
3287 if netsrv
then MH_SEND_PlayerStats(SpawnerUID
);
3290 plr
:= g_Player_Get(SpawnerUID
);
3298 g_Console_Add(Format(_lc
[I_PLAYER_KILL_EXTRAHARD_2
],
3302 g_Console_Add(Format(_lc
[I_PLAYER_KILL_EXTRAHARD_1
],
3306 g_Console_Add(Format(_lc
[I_PLAYER_KILL
],
3311 else if g_GetUIDType(SpawnerUID
) = UID_MONSTER
then
3312 begin // Óáèò ìîíñòðîì
3313 mon
:= g_Monsters_ByUID(SpawnerUID
);
3317 s
:= g_Monsters_GetKilledBy(mon
.MonsterType
);
3321 g_Console_Add(Format(_lc
[I_PLAYER_KILL_EXTRAHARD_2
],
3325 g_Console_Add(Format(_lc
[I_PLAYER_KILL_EXTRAHARD_1
],
3329 g_Console_Add(Format(_lc
[I_PLAYER_KILL
],
3334 else // Îñîáûå òèïû ñìåðòè
3337 HIT_SELF
: g_Console_Add(Format(_lc
[I_PLAYER_KILL_SELF
], [FName
]), True);
3338 HIT_FALL
: g_Console_Add(Format(_lc
[I_PLAYER_KILL_FALL
], [FName
]), True);
3339 HIT_WATER
: g_Console_Add(Format(_lc
[I_PLAYER_KILL_WATER
], [FName
]), True);
3340 HIT_ACID
: g_Console_Add(Format(_lc
[I_PLAYER_KILL_ACID
], [FName
]), True);
3341 HIT_TRAP
: g_Console_Add(Format(_lc
[I_PLAYER_KILL_TRAP
], [FName
]), True);
3342 else g_Console_Add(Format(_lc
[I_PLAYER_DIED
], [FName
]), True);
3348 for a
:= WP_FIRST
to WP_LAST
do
3352 WEAPON_SAW
: i
:= ITEM_WEAPON_SAW
;
3353 WEAPON_SHOTGUN1
: i
:= ITEM_WEAPON_SHOTGUN1
;
3354 WEAPON_SHOTGUN2
: i
:= ITEM_WEAPON_SHOTGUN2
;
3355 WEAPON_CHAINGUN
: i
:= ITEM_WEAPON_CHAINGUN
;
3356 WEAPON_ROCKETLAUNCHER
: i
:= ITEM_WEAPON_ROCKETLAUNCHER
;
3357 WEAPON_PLASMA
: i
:= ITEM_WEAPON_PLASMA
;
3358 WEAPON_BFG
: i
:= ITEM_WEAPON_BFG
;
3359 WEAPON_SUPERPULEMET
: i
:= ITEM_WEAPON_SUPERPULEMET
;
3360 WEAPON_FLAMETHROWER
: i
:= ITEM_WEAPON_FLAMETHROWER
;
3369 if R_ITEM_BACKPACK
in FRulez
then
3370 PushItem(ITEM_AMMO_BACKPACK
);
3372 // Âûáðîñ ðàêåòíîãî ðàíöà:
3373 if FJetFuel
> 0 then
3374 PushItem(ITEM_JETPACK
);
3377 if not (gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
]) then
3379 if R_KEY_RED
in FRulez
then
3380 PushItem(ITEM_KEY_RED
);
3382 if R_KEY_GREEN
in FRulez
then
3383 PushItem(ITEM_KEY_GREEN
);
3385 if R_KEY_BLUE
in FRulez
then
3386 PushItem(ITEM_KEY_BLUE
);
3393 g_Player_CreateCorpse(Self
);
3395 if Srv
and (gGameSettings
.MaxLives
> 0) and FNoRespawn
and
3396 (gLMSRespawn
= LMS_RESPAWN_NONE
) then
3402 for i
:= Low(gPlayers
) to High(gPlayers
) do
3404 if gPlayers
[i
] = nil then continue
;
3405 if (not gPlayers
[i
].FNoRespawn
) and (not gPlayers
[i
].FSpectator
) then
3408 if gPlayers
[i
].FTeam
= TEAM_RED
then Inc(ar
)
3409 else if gPlayers
[i
].FTeam
= TEAM_BLUE
then Inc(ab
);
3414 OldLR
:= gLMSRespawn
;
3415 if (gGameSettings
.GameMode
= GM_COOP
) then
3419 // everyone is dead, restart the map
3420 g_Game_Message(_lc
[I_MESSAGE_LMS_LOSE
], 144);
3422 MH_SEND_GameEvent(NET_EV_LMS_LOSE
);
3423 gLMSRespawn
:= LMS_RESPAWN_FINAL
;
3424 gLMSRespawnTime
:= gTime
+ 5000;
3426 else if (a
= 1) then
3428 if (gPlayers
[k
] <> nil) and not (gPlayers
[k
] is TBot
) then
3429 if (gPlayers
[k
] = gPlayer1
) or
3430 (gPlayers
[k
] = gPlayer2
) then
3431 g_Console_Add('*** ' + _lc
[I_MESSAGE_LMS_SURVIVOR
] + ' ***', True)
3432 else if Netsrv
and (gPlayers
[k
].FClientID
>= 0) then
3433 MH_SEND_GameEvent(NET_EV_LMS_SURVIVOR
, 0, 'N', gPlayers
[k
].FClientID
);
3436 else if (gGameSettings
.GameMode
= GM_TDM
) then
3438 if (ab
= 0) and (ar
<> 0) then
3441 g_Game_Message(Format(_lc
[I_MESSAGE_TLMS_WIN
], [AnsiUpperCase(_lc
[I_GAME_TEAM_RED
])]), 144);
3443 MH_SEND_GameEvent(NET_EV_TLMS_WIN
, TEAM_RED
);
3444 Inc(gTeamStat
[TEAM_RED
].Goals
);
3445 gLMSRespawn
:= LMS_RESPAWN_FINAL
;
3446 gLMSRespawnTime
:= gTime
+ 5000;
3448 else if (ar
= 0) and (ab
<> 0) then
3451 g_Game_Message(Format(_lc
[I_MESSAGE_TLMS_WIN
], [AnsiUpperCase(_lc
[I_GAME_TEAM_BLUE
])]), 144);
3453 MH_SEND_GameEvent(NET_EV_TLMS_WIN
, TEAM_BLUE
);
3454 Inc(gTeamStat
[TEAM_BLUE
].Goals
);
3455 gLMSRespawn
:= LMS_RESPAWN_FINAL
;
3456 gLMSRespawnTime
:= gTime
+ 5000;
3458 else if (ar
= 0) and (ab
= 0) then
3461 g_Game_Message(_lc
[I_GAME_WIN_DRAW
], 144);
3463 MH_SEND_GameEvent(NET_EV_LMS_DRAW
, 0, FName
);
3464 gLMSRespawn
:= LMS_RESPAWN_FINAL
;
3465 gLMSRespawnTime
:= gTime
+ 5000;
3468 else if (gGameSettings
.GameMode
= GM_DM
) then
3472 if gPlayers
[k
] <> nil then
3475 // survivor is the winner
3476 g_Game_Message(Format(_lc
[I_MESSAGE_LMS_WIN
], [AnsiUpperCase(FName
)]), 144);
3478 MH_SEND_GameEvent(NET_EV_LMS_WIN
, 0, FName
);
3481 gLMSRespawn
:= LMS_RESPAWN_FINAL
;
3482 gLMSRespawnTime
:= gTime
+ 5000;
3484 else if (a
= 0) then
3486 // everyone is dead, restart the map
3487 g_Game_Message(_lc
[I_GAME_WIN_DRAW
], 144);
3489 MH_SEND_GameEvent(NET_EV_LMS_DRAW
, 0, FName
);
3490 gLMSRespawn
:= LMS_RESPAWN_FINAL
;
3491 gLMSRespawnTime
:= gTime
+ 5000;
3494 if srv
and (OldLR
= LMS_RESPAWN_NONE
) and (gLMSRespawn
> LMS_RESPAWN_NONE
) then
3496 if NetMode
= NET_SERVER
then
3497 MH_SEND_GameEvent(NET_EV_LMS_WARMUP
, (gLMSRespawnTime
- gTime
) div 1000)
3499 g_Console_Add(Format(_lc
[I_MSG_WARMUP_START
], [(gLMSRespawnTime
- gTime
) div 1000]), True);
3505 MH_SEND_PlayerStats(FUID
);
3506 MH_SEND_PlayerDeath(FUID
, KillType
, t
, SpawnerUID
);
3507 if gGameSettings
.GameMode
= GM_TDM
then MH_SEND_GameStats
;
3510 if srv
and FNoRespawn
then Spectate(True);
3511 FWantsInGame
:= True;
3514 function TPlayer
.BodyInLiquid(XInc
, YInc
: Integer): Boolean;
3516 Result
:= g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
, PLAYER_RECT
.Width
,
3517 PLAYER_RECT
.Height
-20, PANEL_WATER
or PANEL_ACID1
or PANEL_ACID2
, False);
3520 function TPlayer
.BodyInAcid(XInc
, YInc
: Integer): Boolean;
3522 Result
:= g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
, PLAYER_RECT
.Width
,
3523 PLAYER_RECT
.Height
-20, PANEL_ACID1
or PANEL_ACID2
, False);
3526 procedure TPlayer
.MakeBloodSimple(Count
: Word);
3528 g_GFX_Blood(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)+8,
3529 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2),
3530 Count
div 2, 3, -1, 16, (PLAYER_RECT
.Height
*2 div 3),
3532 g_GFX_Blood(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-8,
3533 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2),
3534 Count
div 2, -3, -1, 16, (PLAYER_RECT
.Height
*2) div 3,
3538 procedure TPlayer
.MakeBloodVector(Count
: Word; VelX
, VelY
: Integer);
3540 g_GFX_Blood(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2),
3541 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2),
3542 Count
, VelX
, VelY
, 16, (PLAYER_RECT
.Height
*2) div 3,
3546 procedure TPlayer
.QueueWeaponSwitch(Weapon
: Byte);
3548 if g_Game_IsClient
then Exit
;
3549 if Weapon
> High(FWeapon
) then Exit
;
3550 FNextWeap
:= FNextWeap
or (1 shl Weapon
);
3553 procedure TPlayer
.resetWeaponQueue ();
3556 FNextWeapDelay
:= 0;
3559 function TPlayer
.hasAmmoForWeapon (weapon
: Byte): Boolean;
3563 WEAPON_KASTET
, WEAPON_SAW
: result
:= true;
3564 WEAPON_SHOTGUN1
, WEAPON_SHOTGUN2
: result
:= (FAmmo
[A_SHELLS
] > 0);
3565 WEAPON_PISTOL
, WEAPON_CHAINGUN
, WEAPON_SUPERPULEMET
: result
:= (FAmmo
[A_BULLETS
] > 0);
3566 WEAPON_ROCKETLAUNCHER
: result
:= (FAmmo
[A_ROCKETS
] > 0);
3567 WEAPON_PLASMA
, WEAPON_BFG
: result
:= (FAmmo
[A_CELLS
] > 0);
3568 WEAPON_FLAMETHROWER
: result
:= (FAmmo
[A_FUEL
] > 0);
3569 else result
:= (weapon
< length(FWeapon
));
3573 // return 255 for "no switch"
3574 function TPlayer
.getNextWeaponIndex (): Byte;
3577 wantThisWeapon
: array[0..64] of Boolean;
3578 wwc
: Integer = 0; //HACK!
3581 result
:= 255; // default result: "no switch"
3582 // had weapon cycling on previous frame? remove that flag
3583 if (FNextWeap
and $2000) <> 0 then
3585 FNextWeap
:= FNextWeap
and $1FFF;
3586 FNextWeapDelay
:= 0;
3588 // cycling has priority
3589 if (FNextWeap
and $C000) <> 0 then
3591 if (FNextWeap
and $8000) <> 0 then
3595 FNextWeap
:= FNextWeap
or $2000; // we need this
3596 if FNextWeapDelay
> 0 then
3597 exit
; // cooldown time
3599 for i
:= 0 to High(FWeapon
) do
3601 cwi
:= (cwi
+length(FWeapon
)+dir
) mod length(FWeapon
);
3602 if FWeapon
[cwi
] then
3604 //e_WriteLog(Format(' SWITCH: cur=%d; new=%d', [FCurrWeap, cwi]), MSG_WARNING);
3605 result
:= Byte(cwi
);
3606 FNextWeapDelay
:= 10;
3614 for i
:= 0 to High(wantThisWeapon
) do
3615 wantThisWeapon
[i
] := false;
3616 for i
:= 0 to High(FWeapon
) do
3617 if (FNextWeap
and (1 shl i
)) <> 0 then
3619 wantThisWeapon
[i
] := true;
3622 // exclude currently selected weapon from the set
3623 wantThisWeapon
[FCurrWeap
] := false;
3624 // slow down alterations a little
3627 //e_WriteLog(Format(' FNextWeap=%x; delay=%d', [FNextWeap, FNextWeapDelay]), MSG_WARNING);
3628 // more than one weapon requested, assume "alteration" and check alteration delay
3629 if FNextWeapDelay
> 0 then
3635 // do not reset weapon queue, it will be done in `RealizeCurrentWeapon()`
3636 // but clear all counters if no weapon should be switched
3642 //e_WriteLog(Format('wwc=%d', [wwc]), MSG_WARNING);
3643 // try weapons in descending order
3644 for i
:= High(FWeapon
) downto 0 do
3646 if wantThisWeapon
[i
] and FWeapon
[i
] and ((wwc
= 1) or hasAmmoForWeapon(i
)) then
3651 FNextWeapDelay
:= 10; // anyway, 'cause why not
3655 // no suitable weapon found, so reset the queue, to avoid accidental "queuing" of weapon w/o ammo
3659 procedure TPlayer
.RealizeCurrentWeapon();
3660 function switchAllowed (): Boolean;
3665 if FBFGFireCounter
<> -1 then
3667 if FTime
[T_SWITCH
] > gTime
then
3669 for i
:= WP_FIRST
to WP_LAST
do
3670 if FReloading
[i
] > 0 then
3678 //e_WriteLog(Format('***RealizeCurrentWeapon: FNextWeap=%x; FNextWeapDelay=%d', [FNextWeap, FNextWeapDelay]), MSG_WARNING);
3679 //FNextWeap := FNextWeap and $1FFF;
3680 if FNextWeapDelay
> 0 then Dec(FNextWeapDelay
); // "alteration delay"
3682 if not switchAllowed
then
3684 //HACK for weapon cycling
3685 if (FNextWeap
and $7000) <> 0 then FNextWeap
:= 0;
3689 nw
:= getNextWeaponIndex();
3690 if nw
= 255 then exit
; // don't reset anything here
3691 if nw
> High(FWeapon
) then
3693 // don't forget to reset queue here!
3694 //e_WriteLog(' RealizeCurrentWeapon: WUTAFUUUU', MSG_WARNING);
3702 FTime
[T_SWITCH
] := gTime
+156;
3703 if FCurrWeap
= WEAPON_SAW
then FSawSoundSelect
.PlayAt(FObj
.X
, FObj
.Y
);
3704 FModel
.SetWeapon(FCurrWeap
);
3705 if g_Game_IsNet
then MH_SEND_PlayerStats(FUID
);
3709 procedure TPlayer
.NextWeapon();
3711 if g_Game_IsClient
then Exit
;
3715 procedure TPlayer
.PrevWeapon();
3717 if g_Game_IsClient
then Exit
;
3721 procedure TPlayer
.SetWeapon(W
: Byte);
3723 if FCurrWeap
<> W
then
3724 if W
= WEAPON_SAW
then
3725 FSawSoundSelect
.PlayAt(FObj
.X
, FObj
.Y
);
3728 FModel
.SetWeapon(CurrWeap
);
3732 function TPlayer
.PickItem(ItemType
: Byte; arespawn
: Boolean; var remove
: Boolean): Boolean;
3737 if g_Game_IsClient
then Exit
;
3739 // a = true - ìåñòî ñïàâíà ïðåäìåòà:
3740 a
:= LongBool(gGameSettings
.Options
and GAME_OPTION_WEAPONSTAY
) and arespawn
;
3745 if FHealth
< PLAYER_HP_SOFT
then
3747 IncMax(FHealth
, 10, PLAYER_HP_SOFT
);
3751 if gFlash
= 2 then Inc(FPickup
, 5);
3755 if FHealth
< PLAYER_HP_SOFT
then
3757 IncMax(FHealth
, 25, PLAYER_HP_SOFT
);
3761 if gFlash
= 2 then Inc(FPickup
, 5);
3765 if FArmor
< PLAYER_AP_SOFT
then
3767 FArmor
:= PLAYER_AP_SOFT
;
3770 if gFlash
= 2 then Inc(FPickup
, 5);
3774 if FArmor
< PLAYER_AP_LIMIT
then
3776 FArmor
:= PLAYER_AP_LIMIT
;
3779 if gFlash
= 2 then Inc(FPickup
, 5);
3783 if FHealth
< PLAYER_HP_LIMIT
then
3785 IncMax(FHealth
, 100, PLAYER_HP_LIMIT
);
3789 if gFlash
= 2 then Inc(FPickup
, 5);
3793 if (FHealth
< PLAYER_HP_LIMIT
) or (FArmor
< PLAYER_AP_LIMIT
) then
3795 if FHealth
< PLAYER_HP_LIMIT
then
3796 FHealth
:= PLAYER_HP_LIMIT
;
3797 if FArmor
< PLAYER_AP_LIMIT
then
3798 FArmor
:= PLAYER_AP_LIMIT
;
3802 if gFlash
= 2 then Inc(FPickup
, 5);
3806 if (not FWeapon
[WEAPON_SAW
]) or ((not arespawn
) and (gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
])) then
3808 FWeapon
[WEAPON_SAW
] := True;
3810 if gFlash
= 2 then Inc(FPickup
, 5);
3811 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
3814 ITEM_WEAPON_SHOTGUN1
:
3815 if (FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
]) or not FWeapon
[WEAPON_SHOTGUN1
] then
3817 // Íóæíî, ÷òîáû íå âçÿòü âñå ïóëè ñðàçó:
3818 if a
and FWeapon
[WEAPON_SHOTGUN1
] then Exit
;
3820 IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
3821 FWeapon
[WEAPON_SHOTGUN1
] := True;
3823 if gFlash
= 2 then Inc(FPickup
, 5);
3824 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
3827 ITEM_WEAPON_SHOTGUN2
:
3828 if (FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
]) or not FWeapon
[WEAPON_SHOTGUN2
] then
3830 if a
and FWeapon
[WEAPON_SHOTGUN2
] then Exit
;
3832 IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
3833 FWeapon
[WEAPON_SHOTGUN2
] := True;
3835 if gFlash
= 2 then Inc(FPickup
, 5);
3836 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
3839 ITEM_WEAPON_CHAINGUN
:
3840 if (FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
]) or not FWeapon
[WEAPON_CHAINGUN
] then
3842 if a
and FWeapon
[WEAPON_CHAINGUN
] then Exit
;
3844 IncMax(FAmmo
[A_BULLETS
], 50, FMaxAmmo
[A_BULLETS
]);
3845 FWeapon
[WEAPON_CHAINGUN
] := True;
3847 if gFlash
= 2 then Inc(FPickup
, 5);
3848 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
3851 ITEM_WEAPON_ROCKETLAUNCHER
:
3852 if (FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
]) or not FWeapon
[WEAPON_ROCKETLAUNCHER
] then
3854 if a
and FWeapon
[WEAPON_ROCKETLAUNCHER
] then Exit
;
3856 IncMax(FAmmo
[A_ROCKETS
], 2, FMaxAmmo
[A_ROCKETS
]);
3857 FWeapon
[WEAPON_ROCKETLAUNCHER
] := True;
3859 if gFlash
= 2 then Inc(FPickup
, 5);
3860 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
3864 if (FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
]) or not FWeapon
[WEAPON_PLASMA
] then
3866 if a
and FWeapon
[WEAPON_PLASMA
] then Exit
;
3868 IncMax(FAmmo
[A_CELLS
], 40, FMaxAmmo
[A_CELLS
]);
3869 FWeapon
[WEAPON_PLASMA
] := True;
3871 if gFlash
= 2 then Inc(FPickup
, 5);
3872 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
3876 if (FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
]) or not FWeapon
[WEAPON_BFG
] then
3878 if a
and FWeapon
[WEAPON_BFG
] then Exit
;
3880 IncMax(FAmmo
[A_CELLS
], 40, FMaxAmmo
[A_CELLS
]);
3881 FWeapon
[WEAPON_BFG
] := True;
3883 if gFlash
= 2 then Inc(FPickup
, 5);
3884 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
3887 ITEM_WEAPON_SUPERPULEMET
:
3888 if (FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
]) or not FWeapon
[WEAPON_SUPERPULEMET
] then
3890 if a
and FWeapon
[WEAPON_SUPERPULEMET
] then Exit
;
3892 IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
3893 FWeapon
[WEAPON_SUPERPULEMET
] := True;
3895 if gFlash
= 2 then Inc(FPickup
, 5);
3896 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
3899 ITEM_WEAPON_FLAMETHROWER
:
3900 if (FAmmo
[A_FUEL
] < FMaxAmmo
[A_FUEL
]) or not FWeapon
[WEAPON_FLAMETHROWER
] then
3902 if a
and FWeapon
[WEAPON_FLAMETHROWER
] then Exit
;
3904 IncMax(FAmmo
[A_FUEL
], 100, FMaxAmmo
[A_FUEL
]);
3905 FWeapon
[WEAPON_FLAMETHROWER
] := True;
3907 if gFlash
= 2 then Inc(FPickup
, 5);
3908 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
3912 if FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
] then
3914 IncMax(FAmmo
[A_BULLETS
], 10, FMaxAmmo
[A_BULLETS
]);
3917 if gFlash
= 2 then Inc(FPickup
, 5);
3920 ITEM_AMMO_BULLETS_BOX
:
3921 if FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
] then
3923 IncMax(FAmmo
[A_BULLETS
], 50, FMaxAmmo
[A_BULLETS
]);
3926 if gFlash
= 2 then Inc(FPickup
, 5);
3930 if FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
] then
3932 IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
3935 if gFlash
= 2 then Inc(FPickup
, 5);
3938 ITEM_AMMO_SHELLS_BOX
:
3939 if FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
] then
3941 IncMax(FAmmo
[A_SHELLS
], 25, FMaxAmmo
[A_SHELLS
]);
3944 if gFlash
= 2 then Inc(FPickup
, 5);
3948 if FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
] then
3950 IncMax(FAmmo
[A_ROCKETS
], 1, FMaxAmmo
[A_ROCKETS
]);
3953 if gFlash
= 2 then Inc(FPickup
, 5);
3956 ITEM_AMMO_ROCKET_BOX
:
3957 if FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
] then
3959 IncMax(FAmmo
[A_ROCKETS
], 5, FMaxAmmo
[A_ROCKETS
]);
3962 if gFlash
= 2 then Inc(FPickup
, 5);
3966 if FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
] then
3968 IncMax(FAmmo
[A_CELLS
], 40, FMaxAmmo
[A_CELLS
]);
3971 if gFlash
= 2 then Inc(FPickup
, 5);
3975 if FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
] then
3977 IncMax(FAmmo
[A_CELLS
], 100, FMaxAmmo
[A_CELLS
]);
3980 if gFlash
= 2 then Inc(FPickup
, 5);
3984 if FAmmo
[A_FUEL
] < FMaxAmmo
[A_FUEL
] then
3986 IncMax(FAmmo
[A_FUEL
], 100, FMaxAmmo
[A_FUEL
]);
3989 if gFlash
= 2 then Inc(FPickup
, 5);
3993 if not(R_ITEM_BACKPACK
in FRulez
) or
3994 (FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
]) or
3995 (FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
]) or
3996 (FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
]) or
3997 (FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
]) or
3998 (FMaxAmmo
[A_FUEL
] < AmmoLimits
[1, A_FUEL
]) then
4000 FMaxAmmo
[A_BULLETS
] := AmmoLimits
[1, A_BULLETS
];
4001 FMaxAmmo
[A_SHELLS
] := AmmoLimits
[1, A_SHELLS
];
4002 FMaxAmmo
[A_ROCKETS
] := AmmoLimits
[1, A_ROCKETS
];
4003 FMaxAmmo
[A_CELLS
] := AmmoLimits
[1, A_CELLS
];
4004 FMaxAmmo
[A_FUEL
] := AmmoLimits
[1, A_FUEL
];
4006 if FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
] then
4007 IncMax(FAmmo
[A_BULLETS
], 10, FMaxAmmo
[A_BULLETS
]);
4008 if FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
] then
4009 IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
4010 if FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
] then
4011 IncMax(FAmmo
[A_ROCKETS
], 1, FMaxAmmo
[A_ROCKETS
]);
4012 if FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
] then
4013 IncMax(FAmmo
[A_CELLS
], 40, FMaxAmmo
[A_CELLS
]);
4015 FRulez
:= FRulez
+ [R_ITEM_BACKPACK
];
4018 if gFlash
= 2 then Inc(FPickup
, 5);
4022 if not(R_KEY_RED
in FRulez
) then
4024 Include(FRulez
, R_KEY_RED
);
4026 remove
:= (gGameSettings
.GameMode
<> GM_COOP
) and (g_Player_GetCount() < 2);
4027 if gFlash
= 2 then Inc(FPickup
, 5);
4028 if (not remove
) and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETITEM');
4032 if not(R_KEY_GREEN
in FRulez
) then
4034 Include(FRulez
, R_KEY_GREEN
);
4036 remove
:= (gGameSettings
.GameMode
<> GM_COOP
) and (g_Player_GetCount() < 2);
4037 if gFlash
= 2 then Inc(FPickup
, 5);
4038 if (not remove
) and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETITEM');
4042 if not(R_KEY_BLUE
in FRulez
) then
4044 Include(FRulez
, R_KEY_BLUE
);
4046 remove
:= (gGameSettings
.GameMode
<> GM_COOP
) and (g_Player_GetCount() < 2);
4047 if gFlash
= 2 then Inc(FPickup
, 5);
4048 if (not remove
) and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETITEM');
4052 if FMegaRulez
[MR_SUIT
] < gTime
+PLAYER_SUIT_TIME
then
4054 FMegaRulez
[MR_SUIT
] := gTime
+PLAYER_SUIT_TIME
;
4058 if gFlash
= 2 then Inc(FPickup
, 5);
4062 if FAir
< AIR_MAX
then
4067 if gFlash
= 2 then Inc(FPickup
, 5);
4072 if not (R_BERSERK
in FRulez
) then
4074 Include(FRulez
, R_BERSERK
);
4075 if FBFGFireCounter
= -1 then
4077 FCurrWeap
:= WEAPON_KASTET
;
4079 FModel
.SetWeapon(WEAPON_KASTET
);
4083 if gFlash
= 2 then Inc(FPickup
, 5);
4084 FBerserk
:= gTime
+30000;
4089 if FHealth
< PLAYER_HP_SOFT
then
4091 FHealth
:= PLAYER_HP_SOFT
;
4092 FBerserk
:= gTime
+30000;
4100 if FMegaRulez
[MR_INVUL
] < gTime
+PLAYER_INVUL_TIME
then
4102 FMegaRulez
[MR_INVUL
] := gTime
+PLAYER_INVUL_TIME
;
4105 if gFlash
= 2 then Inc(FPickup
, 5);
4109 if FHealth
< PLAYER_HP_LIMIT
then
4111 IncMax(FHealth
, 4, PLAYER_HP_LIMIT
);
4115 if gFlash
= 2 then Inc(FPickup
, 5);
4119 if FArmor
< PLAYER_AP_LIMIT
then
4121 IncMax(FArmor
, 5, PLAYER_AP_LIMIT
);
4124 if gFlash
= 2 then Inc(FPickup
, 5);
4128 if FJetFuel
< JET_MAX
then
4130 FJetFuel
:= JET_MAX
;
4133 if gFlash
= 2 then Inc(FPickup
, 5);
4137 if FMegaRulez
[MR_INVIS
] < gTime
+PLAYER_INVIS_TIME
then
4139 FMegaRulez
[MR_INVIS
] := gTime
+PLAYER_INVIS_TIME
;
4142 if gFlash
= 2 then Inc(FPickup
, 5);
4147 procedure TPlayer
.Touch();
4151 //FModel.PlaySound(MODELSOUND_PAIN, 1, FObj.X, FObj.Y);
4154 // Áðîñèòü ôëàã òîâàðèùó:
4155 if gGameSettings
.GameMode
= GM_CTF
then
4160 procedure TPlayer
.Push(vx
, vy
: Integer);
4162 if (not FPhysics
) and FGhost
then
4164 FObj
.Accel
.X
:= FObj
.Accel
.X
+ vx
;
4165 FObj
.Accel
.Y
:= FObj
.Accel
.Y
+ vy
;
4166 if g_Game_IsNet
and g_Game_IsServer
then
4167 MH_SEND_PlayerPos(True, FUID
, NET_EVERYONE
);
4170 procedure TPlayer
.Reset(Force
: Boolean);
4176 FTime
[T_RESPAWN
] := 0;
4177 FTime
[T_FLAGCAP
] := 0;
4190 FSpectator
:= False;
4193 FSpectatePlayer
:= -1;
4194 FNoRespawn
:= False;
4196 FLives
:= gGameSettings
.MaxLives
;
4201 procedure TPlayer
.SoftReset();
4207 FBFGFireCounter
:= -1;
4215 SetAction(A_STAND
, True);
4218 function TPlayer
.GetRespawnPoint(): Byte;
4223 // Íà áóäóùåå: FSpawn - èãðîê óæå èãðàë è ïåðåðîæäàåòñÿ
4225 // Îäèíî÷íàÿ èãðà/êîîïåðàòèâ
4226 if gGameSettings
.GameMode
in [GM_COOP
, GM_SINGLE
] then
4228 if (Self
= gPlayer1
) or (Self
= gPlayer2
) then
4230 // Òî÷êà ïîÿâëåíèÿ ñâîåãî èãðîêà
4231 if Self
= gPlayer1
then
4232 c
:= RESPAWNPOINT_PLAYER1
4234 c
:= RESPAWNPOINT_PLAYER2
;
4235 if g_Map_GetPointCount(c
) > 0 then
4241 // Òî÷êà ïîÿâëåíèÿ äðóãîãî èãðîêà
4242 if Self
= gPlayer1
then
4243 c
:= RESPAWNPOINT_PLAYER2
4245 c
:= RESPAWNPOINT_PLAYER1
;
4246 if g_Map_GetPointCount(c
) > 0 then
4253 // Òî÷êà ïîÿâëåíèÿ ëþáîãî èãðîêà (áîòà)
4254 if Random(2) = 0 then
4255 c
:= RESPAWNPOINT_PLAYER1
4257 c
:= RESPAWNPOINT_PLAYER2
;
4258 if g_Map_GetPointCount(c
) > 0 then
4265 // Òî÷êà ëþáîé èç êîìàíä
4266 if Random(2) = 0 then
4267 c
:= RESPAWNPOINT_RED
4269 c
:= RESPAWNPOINT_BLUE
;
4270 if g_Map_GetPointCount(c
) > 0 then
4277 c
:= RESPAWNPOINT_DM
;
4278 if g_Map_GetPointCount(c
) > 0 then
4286 if gGameSettings
.GameMode
= GM_DM
then
4289 c
:= RESPAWNPOINT_DM
;
4290 if g_Map_GetPointCount(c
) > 0 then
4296 // Òî÷êà ïîÿâëåíèÿ ëþáîãî èãðîêà
4297 if Random(2) = 0 then
4298 c
:= RESPAWNPOINT_PLAYER1
4300 c
:= RESPAWNPOINT_PLAYER2
;
4301 if g_Map_GetPointCount(c
) > 0 then
4307 // Òî÷êà ëþáîé èç êîìàíä
4308 if Random(2) = 0 then
4309 c
:= RESPAWNPOINT_RED
4311 c
:= RESPAWNPOINT_BLUE
;
4312 if g_Map_GetPointCount(c
) > 0 then
4320 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
4322 // Òî÷êà ñâîåé êîìàíäû
4323 c
:= RESPAWNPOINT_DM
;
4324 if FTeam
= TEAM_RED
then
4325 c
:= RESPAWNPOINT_RED
;
4326 if FTeam
= TEAM_BLUE
then
4327 c
:= RESPAWNPOINT_BLUE
;
4328 if g_Map_GetPointCount(c
) > 0 then
4335 c
:= RESPAWNPOINT_DM
;
4336 if g_Map_GetPointCount(c
) > 0 then
4342 // Òî÷êà ïîÿâëåíèÿ ëþáîãî èãðîêà
4343 if Random(2) = 0 then
4344 c
:= RESPAWNPOINT_PLAYER1
4346 c
:= RESPAWNPOINT_PLAYER2
;
4347 if g_Map_GetPointCount(c
) > 0 then
4353 // Òî÷êà äðóãîé êîìàíäû
4354 c
:= RESPAWNPOINT_DM
;
4355 if FTeam
= TEAM_RED
then
4356 c
:= RESPAWNPOINT_BLUE
;
4357 if FTeam
= TEAM_BLUE
then
4358 c
:= RESPAWNPOINT_RED
;
4359 if g_Map_GetPointCount(c
) > 0 then
4367 procedure TPlayer
.Respawn(Silent
: Boolean; Force
: Boolean = False);
4369 RespawnPoint
: TRespawnPoint
;
4374 if not g_Game_IsServer
then
4378 FWantsInGame
:= True;
4379 FJustTeleported
:= True;
4382 FTime
[T_RESPAWN
] := 0;
4386 // if server changes MaxLives we gotta be ready
4387 if gGameSettings
.MaxLives
= 0 then FNoRespawn
:= False;
4389 // Åùå íåëüçÿ âîçðîäèòüñÿ:
4390 if FTime
[T_RESPAWN
] > gTime
then
4393 // Ïðîñðàë âñå æèçíè:
4396 if not FSpectator
then Spectate(True);
4397 FWantsInGame
:= True;
4401 if (gGameSettings
.GameType
<> GT_SINGLE
) and (gGameSettings
.GameMode
<> GM_COOP
) then
4402 begin // "Ñâîÿ èãðà"
4403 // Áåðñåðê íå ñîõðàíÿåòñÿ ìåæäó óðîâíÿìè:
4404 FRulez
:= FRulez
-[R_BERSERK
];
4406 else // "Îäèíî÷íàÿ èãðà"/"Êîîï"
4408 // Áåðñåðê è êëþ÷è íå ñîõðàíÿþòñÿ ìåæäó óðîâíÿìè:
4409 FRulez
:= FRulez
-[R_KEY_RED
, R_KEY_GREEN
, R_KEY_BLUE
, R_BERSERK
];
4412 // Ïîëó÷àåì òî÷êó ñïàóíà èãðîêà:
4413 c
:= GetRespawnPoint();
4418 // Âîñêðåøåíèå áåç îðóæèÿ:
4421 FHealth
:= PLAYER_HP_SOFT
;
4427 for a
:= WP_FIRST
to WP_LAST
do
4429 FWeapon
[a
] := False;
4433 FWeapon
[WEAPON_PISTOL
] := True;
4434 FWeapon
[WEAPON_KASTET
] := True;
4435 FCurrWeap
:= WEAPON_PISTOL
;
4438 FModel
.SetWeapon(FCurrWeap
);
4440 for b
:= A_BULLETS
to A_HIGH
do
4443 FAmmo
[A_BULLETS
] := 50;
4445 FMaxAmmo
[A_BULLETS
] := AmmoLimits
[0, A_BULLETS
];
4446 FMaxAmmo
[A_SHELLS
] := AmmoLimits
[0, A_SHELLS
];
4447 FMaxAmmo
[A_ROCKETS
] := AmmoLimits
[0, A_SHELLS
];
4448 FMaxAmmo
[A_CELLS
] := AmmoLimits
[0, A_CELLS
];
4449 FMaxAmmo
[A_FUEL
] := AmmoLimits
[0, A_FUEL
];
4451 if gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
] then
4452 FRulez
:= [R_KEY_RED
, R_KEY_GREEN
, R_KEY_BLUE
]
4457 // Ïîëó÷àåì êîîðäèíàòû òî÷êè âîçðîæäåíèÿ:
4458 if not g_Map_GetPoint(c
, RespawnPoint
) then
4460 g_FatalError(_lc
[I_GAME_ERROR_GET_SPAWN
]);
4464 // Óñòàíîâêà êîîðäèíàò è ñáðîñ âñåõ ïàðàìåòðîâ:
4465 FObj
.X
:= RespawnPoint
.X
-PLAYER_RECT
.X
;
4466 FObj
.Y
:= RespawnPoint
.Y
-PLAYER_RECT
.Y
;
4472 FDirection
:= RespawnPoint
.Direction
;
4473 if FDirection
= D_LEFT
then
4479 FBFGFireCounter
:= -1;
4484 SetAction(A_STAND
, True);
4485 FModel
.Direction
:= FDirection
;
4487 for a
:= Low(FTime
) to High(FTime
) do
4490 for a
:= Low(FMegaRulez
) to High(FMegaRulez
) do
4495 FCanJetpack
:= False;
4500 // Àíèìàöèÿ âîçðîæäåíèÿ:
4501 if (not gLoadGameMode
) and (not Silent
) then
4502 if g_Frames_Get(ID
, 'FRAMES_TELEPORT') then
4504 Anim
:= TAnimation
.Create(ID
, False, 3);
4505 g_GFX_OnceAnim(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-32,
4506 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)-32, Anim
);
4510 FSpectator
:= False;
4513 FSpectatePlayer
:= -1;
4516 if g_Game_IsNet
then
4518 MH_SEND_PlayerPos(True, FUID
, NET_EVERYONE
);
4519 MH_SEND_PlayerStats(FUID
, NET_EVERYONE
);
4521 MH_SEND_Effect(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-32,
4522 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)-32,
4527 procedure TPlayer
.Spectate(NoMove
: Boolean = False);
4530 Kill(K_EXTRAHARDKILL
, FUID
, HIT_SOME
)
4531 else if (not NoMove
) then
4533 GameX
:= gMapInfo
.Width
div 2;
4534 GameY
:= gMapInfo
.Height
div 2;
4543 FWantsInGame
:= False;
4548 if Self
= gPlayer1
then
4553 if Self
= gPlayer2
then
4560 if g_Game_IsNet
then
4561 MH_SEND_PlayerStats(FUID
);
4564 procedure TPlayer
.SwitchNoClip
;
4568 FGhost
:= not FGhost
;
4569 FPhysics
:= not FGhost
;
4581 procedure TPlayer
.Run(Direction
: TDirection
);
4585 if MAX_RUNVEL
> 8 then
4589 if Direction
= D_LEFT
then
4591 if FObj
.Vel
.X
> -MAX_RUNVEL
then
4592 FObj
.Vel
.X
:= FObj
.Vel
.X
- (MAX_RUNVEL
shr 3);
4595 if FObj
.Vel
.X
< MAX_RUNVEL
then
4596 FObj
.Vel
.X
:= FObj
.Vel
.X
+ (MAX_RUNVEL
shr 3);
4598 // Âîçìîæíî, ïèíàåì êóñêè:
4599 if (FObj
.Vel
.X
<> 0) and (gGibs
<> nil) then
4601 b
:= Abs(FObj
.Vel
.X
);
4602 if b
> 1 then b
:= b
* (Random(8 div b
) + 1);
4603 for a
:= 0 to High(gGibs
) do
4605 if gGibs
[a
].Live
and
4606 g_Obj_Collide(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
+FObj
.Rect
.Height
-4,
4607 FObj
.Rect
.Width
, 8, @gGibs
[a
].Obj
) and (Random(3) = 0) then
4610 if FObj
.Vel
.X
< 0 then
4612 g_Obj_PushA(@gGibs
[a
].Obj
, b
, Random(61)+120) // íàëåâî
4616 g_Obj_PushA(@gGibs
[a
].Obj
, b
, Random(61)); // íàïðàâî
4618 gGibs
[a
].positionChanged(); // this updates spatial accelerators
4626 procedure TPlayer
.SeeDown();
4628 SetAction(A_SEEDOWN
);
4630 if FDirection
= D_LEFT
then FAngle
:= ANGLE_LEFTDOWN
else FAngle
:= ANGLE_RIGHTDOWN
;
4632 if FIncCam
> -120 then DecMin(FIncCam
, 5, -120);
4635 procedure TPlayer
.SeeUp();
4639 if FDirection
= D_LEFT
then FAngle
:= ANGLE_LEFTUP
else FAngle
:= ANGLE_RIGHTUP
;
4641 if FIncCam
< 120 then IncMax(FIncCam
, 5, 120);
4644 procedure TPlayer
.SetAction(Action
: Byte; Force
: Boolean = False);
4652 A_ATTACK
: Prior
:= 2;
4653 A_SEEUP
: Prior
:= 1;
4654 A_SEEDOWN
: Prior
:= 1;
4655 A_ATTACKUP
: Prior
:= 2;
4656 A_ATTACKDOWN
: Prior
:= 2;
4661 if (Prior
> FActionPrior
) or Force
then
4662 if not ((Prior
= 2) and (FCurrWeap
= WEAPON_SAW
)) then
4664 FActionPrior
:= Prior
;
4665 FActionAnim
:= Action
;
4666 FActionForce
:= Force
;
4667 FActionChanged
:= True;
4670 if Action
in [A_ATTACK
, A_ATTACKUP
, A_ATTACKDOWN
] then FModel
.SetFire(True);
4673 function TPlayer
.StayOnStep(XInc
, YInc
: Integer): Boolean;
4675 Result
:= not g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+YInc
+PLAYER_RECT
.Y
+PLAYER_RECT
.Height
-1,
4676 PLAYER_RECT
.Width
, 1, PANEL_STEP
, False)
4677 and g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+YInc
+PLAYER_RECT
.Y
+PLAYER_RECT
.Height
,
4678 PLAYER_RECT
.Width
, 1, PANEL_STEP
, False);
4681 function TPlayer
.TeleportTo(X
, Y
: Integer; silent
: Boolean; dir
: Byte): Boolean;
4688 if g_CollideLevel(X
, Y
, PLAYER_RECT
.Width
, PLAYER_RECT
.Height
) then
4690 g_Sound_PlayExAt('SOUND_GAME_NOTELEPORT', FObj
.X
, FObj
.Y
);
4691 if g_Game_IsServer
and g_Game_IsNet
then
4692 MH_SEND_Sound(FObj
.X
, FObj
.Y
, 'SOUND_GAME_NOTELEPORT');
4696 FJustTeleported
:= True;
4701 if g_Frames_Get(ID
, 'FRAMES_TELEPORT') then
4703 Anim
:= TAnimation
.Create(ID
, False, 3);
4706 g_Sound_PlayExAt('SOUND_GAME_TELEPORT', FObj
.X
, FObj
.Y
);
4707 g_GFX_OnceAnim(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-32,
4708 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)-32, Anim
);
4709 if g_Game_IsServer
and g_Game_IsNet
then
4710 MH_SEND_Effect(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-32,
4711 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)-32, 1,
4715 FObj
.X
:= X
-PLAYER_RECT
.X
;
4716 FObj
.Y
:= Y
-PLAYER_RECT
.Y
;
4717 if FLive
and FGhost
then
4723 if not g_Game_IsNet
then
4727 SetDirection(D_LEFT
);
4733 SetDirection(D_RIGHT
);
4739 if FDirection
= D_RIGHT
then
4741 SetDirection(D_LEFT
);
4746 SetDirection(D_RIGHT
);
4752 if not silent
and (Anim
<> nil) then
4754 g_GFX_OnceAnim(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-32,
4755 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)-32, Anim
);
4758 if g_Game_IsServer
and g_Game_IsNet
then
4759 MH_SEND_Effect(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-32,
4760 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)-32, 0,
4767 function nonz(a
: Single): Single;
4775 procedure TPlayer
.Update();
4778 i
, ii
, wx
, wy
, xd
, yd
, k
: Integer;
4779 blockmon
, headwater
, dospawn
: Boolean;
4784 NetServer
:= g_Game_IsNet
and g_Game_IsServer
;
4785 AnyServer
:= g_Game_IsServer
;
4787 if g_Game_IsClient
and (NetInterpLevel
> 0) then
4788 DoLerp(NetInterpLevel
+ 1)
4794 if FClientID
>= 0 then
4796 FPing
:= NetClients
[FClientID
].Peer
^.lastRoundTripTime
;
4797 if NetClients
[FClientID
].Peer
^.packetsSent
> 0 then
4798 FLoss
:= Round(100*NetClients
[FClientID
].Peer
^.packetsLost
/NetClients
[FClientID
].Peer
^.packetsSent
)
4807 if FLive
and (gFly
or FJetpack
) then
4810 if FDirection
= D_LEFT
then
4815 if FLive
and (not FGhost
) then
4817 if FKeys
[KEY_UP
].Pressed
then
4819 if FKeys
[KEY_DOWN
].Pressed
then
4823 if (not (FKeys
[KEY_UP
].Pressed
or FKeys
[KEY_DOWN
].Pressed
)) and
4826 i
:= g_basic
.Sign(FIncCam
);
4827 FIncCam
:= Abs(FIncCam
);
4828 DecMin(FIncCam
, 5, 0);
4829 FIncCam
:= FIncCam
*i
;
4832 // no need to do that each second frame, weapon queue will take care of it
4833 if FLive
and FKeys
[KEY_NEXTWEAPON
].Pressed
and AnyServer
then NextWeapon();
4834 if FLive
and FKeys
[KEY_PREVWEAPON
].Pressed
and AnyServer
then PrevWeapon();
4836 if gTime
mod (GAME_TICK
*2) <> 0 then
4838 if (FObj
.Vel
.X
= 0) and FLive
then
4840 if FKeys
[KEY_LEFT
].Pressed
then
4842 if FKeys
[KEY_RIGHT
].Pressed
then
4848 g_Obj_Move(@FObj
, True, True, True);
4849 positionChanged(); // this updates spatial accelerators
4855 FActionChanged
:= False;
4859 // Let alive player do some actions
4860 if FKeys
[KEY_LEFT
].Pressed
then Run(D_LEFT
);
4861 if FKeys
[KEY_RIGHT
].Pressed
then Run(D_RIGHT
);
4862 //if FKeys[KEY_NEXTWEAPON].Pressed and AnyServer then NextWeapon();
4863 //if FKeys[KEY_PREVWEAPON].Pressed and AnyServer then PrevWeapon();
4864 if FKeys
[KEY_FIRE
].Pressed
and AnyServer
then Fire();
4865 if FKeys
[KEY_OPEN
].Pressed
and AnyServer
then Use();
4866 if FKeys
[KEY_JUMP
].Pressed
then Jump()
4869 if AnyServer
and FJetpack
then
4873 if NetServer
then MH_SEND_PlayerStats(FUID
);
4875 FCanJetpack
:= True;
4882 for k
:= Low(FKeys
) to KEY_CHAT
-1 do
4884 if FKeys
[k
].Pressed
then
4892 if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
4895 if (FTime
[T_RESPAWN
] <= gTime
) and
4896 gGameOn
and (not FLive
) then
4898 if (g_Player_GetCount() > 1) then
4902 gExit
:= EXIT_RESTART
;
4907 // Dead spectator actions
4910 if FKeys
[KEY_OPEN
].Pressed
and AnyServer
then Fire();
4911 if FKeys
[KEY_FIRE
].Pressed
and AnyServer
then
4915 if (FSpectatePlayer
>= High(gPlayers
)) then
4916 FSpectatePlayer
:= -1
4920 for I
:= FSpectatePlayer
+ 1 to High(gPlayers
) do
4921 if gPlayers
[I
] <> nil then
4922 if gPlayers
[I
].Live
then
4923 if gPlayers
[I
].UID
<> FUID
then
4925 FSpectatePlayer
:= I
;
4930 if not SetSpect
then FSpectatePlayer
:= -1;
4941 if FKeys
[KEY_UP
].Pressed
or FKeys
[KEY_JUMP
].Pressed
then
4943 FYTo
:= FObj
.Y
- 32;
4944 FSpectatePlayer
:= -1;
4946 if FKeys
[KEY_DOWN
].Pressed
then
4948 FYTo
:= FObj
.Y
+ 32;
4949 FSpectatePlayer
:= -1;
4951 if FKeys
[KEY_LEFT
].Pressed
then
4953 FXTo
:= FObj
.X
- 32;
4954 FSpectatePlayer
:= -1;
4956 if FKeys
[KEY_RIGHT
].Pressed
then
4958 FXTo
:= FObj
.X
+ 32;
4959 FSpectatePlayer
:= -1;
4962 if (FXTo
< -64) then
4964 else if (FXTo
> gMapInfo
.Width
+ 32) then
4965 FXTo
:= gMapInfo
.Width
+ 32;
4966 if (FYTo
< -72) then
4968 else if (FYTo
> gMapInfo
.Height
+ 32) then
4969 FYTo
:= gMapInfo
.Height
+ 32;
4974 g_Obj_Move(@FObj
, True, True, True);
4975 positionChanged(); // this updates spatial accelerators
4982 if (FSpectatePlayer
<= High(gPlayers
)) and (FSpectatePlayer
>= 0) then
4983 if gPlayers
[FSpectatePlayer
] <> nil then
4984 if gPlayers
[FSpectatePlayer
].Live
then
4986 FXTo
:= gPlayers
[FSpectatePlayer
].GameX
;
4987 FYTo
:= gPlayers
[FSpectatePlayer
].GameY
;
4991 blockmon
:= g_Map_CollidePanel(FObj
.X
+PLAYER_HEADRECT
.X
, FObj
.Y
+PLAYER_HEADRECT
.Y
,
4992 PLAYER_HEADRECT
.Width
, PLAYER_HEADRECT
.Height
,
4993 PANEL_BLOCKMON
, True);
4994 headwater
:= HeadInLiquid(0, 0);
4996 // Ñîïðîòèâëåíèå âîçäóõà:
4997 if (not FLive
) or not (FKeys
[KEY_LEFT
].Pressed
or FKeys
[KEY_RIGHT
].Pressed
) then
4998 if FObj
.Vel
.X
<> 0 then
4999 FObj
.Vel
.X
:= z_dec(FObj
.Vel
.X
, 1);
5001 if (FLastHit
= HIT_TRAP
) and (FPain
> 90) then FPain
:= 90;
5002 DecMin(FPain
, 5, 0);
5003 DecMin(FPickup
, 1, 0);
5005 if FLive
and (FObj
.Y
> Integer(gMapInfo
.Height
)+128) and AnyServer
then
5007 // Îáíóëèòü äåéñòâèÿ ïðèìî÷åê, ÷òîáû ôîí ïðîïàë
5008 FMegaRulez
[MR_SUIT
] := 0;
5009 FMegaRulez
[MR_INVUL
] := 0;
5010 FMegaRulez
[MR_INVIS
] := 0;
5011 Kill(K_FALLKILL
, 0, HIT_FALL
);
5018 if FCurrWeap
= WEAPON_SAW
then
5019 if not (FSawSound
.IsPlaying() or FSawSoundHit
.IsPlaying() or
5020 FSawSoundSelect
.IsPlaying()) then
5021 FSawSoundIdle
.PlayAt(FObj
.X
, FObj
.Y
);
5024 if (not FJetSoundFly
.IsPlaying()) and (not FJetSoundOn
.IsPlaying()) and
5025 (not FJetSoundOff
.IsPlaying()) then
5027 FJetSoundFly
.SetPosition(0);
5028 FJetSoundFly
.PlayAt(FObj
.X
, FObj
.Y
);
5031 for b
:= WP_FIRST
to WP_LAST
do
5032 if FReloading
[b
] > 0 then
5038 if FShellTimer
> -1 then
5039 if FShellTimer
= 0 then
5041 if FShellType
= SHELL_SHELL
then
5042 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
5043 GameVelX
, GameVelY
-2, SHELL_SHELL
)
5044 else if FShellType
= SHELL_DBLSHELL
then
5046 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
5047 GameVelX
+1, GameVelY
-2, SHELL_SHELL
);
5048 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
5049 GameVelX
-1, GameVelY
-2, SHELL_SHELL
);
5052 end else Dec(FShellTimer
);
5054 if (FBFGFireCounter
> -1) then
5055 if FBFGFireCounter
= 0 then
5059 wx
:= FObj
.X
+WEAPONPOINT
[FDirection
].X
;
5060 wy
:= FObj
.Y
+WEAPONPOINT
[FDirection
].Y
;
5061 xd
:= wx
+IfThen(FDirection
= D_LEFT
, -30, 30);
5062 yd
:= wy
+firediry();
5063 g_Weapon_bfgshot(wx
, wy
, xd
, yd
, FUID
);
5064 if NetServer
then MH_SEND_PlayerFire(FUID
, WEAPON_BFG
, wx
, wy
, xd
, yd
);
5065 if (FAngle
= 0) or (FAngle
= 180) then SetAction(A_ATTACK
)
5066 else if (FAngle
= ANGLE_LEFTDOWN
) or (FAngle
= ANGLE_RIGHTDOWN
) then SetAction(A_ATTACKDOWN
)
5067 else if (FAngle
= ANGLE_LEFTUP
) or (FAngle
= ANGLE_RIGHTUP
) then SetAction(A_ATTACKUP
);
5070 FReloading
[WEAPON_BFG
] := WEAPON_RELOAD
[WEAPON_BFG
];
5071 FBFGFireCounter
:= -1;
5074 FBFGFireCounter
:= 0
5076 Dec(FBFGFireCounter
);
5078 if (FMegaRulez
[MR_SUIT
] < gTime
) and AnyServer
then
5080 b
:= g_GetAcidHit(FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+PLAYER_RECT
.Y
, PLAYER_RECT
.Width
, PLAYER_RECT
.Height
);
5082 if (b
> 0) and (gTime
mod (15*GAME_TICK
) = 0) then Damage(b
, 0, 0, 0, HIT_ACID
);
5085 if (headwater
or blockmon
) then
5091 if AnyServer
then Damage(10, 0, 0, 0, HIT_WATER
);
5094 else if (FAir
mod 31 = 0) and not blockmon
then
5096 g_GFX_Bubbles(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2), FObj
.Y
+PLAYER_RECT
.Y
-4, 5+Random(6), 8, 4);
5097 if Random(2) = 0 then
5098 g_Sound_PlayExAt('SOUND_GAME_BUBBLE1', FObj
.X
, FObj
.Y
)
5100 g_Sound_PlayExAt('SOUND_GAME_BUBBLE2', FObj
.X
, FObj
.Y
);
5102 end else if FAir
< AIR_DEF
then
5105 if FFireTime
> 0 then
5107 if BodyInLiquid(0, 0) then
5112 else if FMegaRulez
[MR_SUIT
] >= gTime
then
5114 if FMegaRulez
[MR_SUIT
] = gTime
then
5121 if FFirePainTime
<= 0 then
5123 if g_Game_IsServer
then
5124 Damage(5, FFireAttacker
, 0, 0, HIT_FLAME
);
5125 FFirePainTime
:= 18;
5127 FFirePainTime
:= FFirePainTime
- 1;
5128 FFireTime
:= FFireTime
- 1;
5129 if (FFireTime
= 0) and g_Game_IsNet
and g_Game_IsServer
then
5130 MH_SEND_PlayerStats(FUID
);
5134 if FDamageBuffer
> 0 then
5136 if FDamageBuffer
>= 9 then
5140 if FDamageBuffer
< 30 then i
:= 9
5141 else if FDamageBuffer
< 100 then i
:= 18
5145 ii
:= Round(FDamageBuffer
*FHealth
/ nonz(FArmor
*(3/4)+FHealth
));
5146 FArmor
:= FArmor
-(FDamageBuffer
-ii
);
5147 FHealth
:= FHealth
-ii
;
5150 FHealth
:= FHealth
+FArmor
;
5155 if FHealth
<= 0 then
5156 if FHealth
> -30 then Kill(K_SIMPLEKILL
, FLastSpawnerUID
, FLastHit
)
5157 else if FHealth
> -50 then Kill(K_HARDKILL
, FLastSpawnerUID
, FLastHit
)
5158 else Kill(K_EXTRAHARDKILL
, FLastSpawnerUID
, FLastHit
);
5162 if FDamageBuffer
<= 20 then FModel
.PlaySound(MODELSOUND_PAIN
, 1, FObj
.X
, FObj
.Y
)
5163 else if FDamageBuffer
<= 55 then FModel
.PlaySound(MODELSOUND_PAIN
, 2, FObj
.X
, FObj
.Y
)
5164 else if FDamageBuffer
<= 120 then FModel
.PlaySound(MODELSOUND_PAIN
, 3, FObj
.X
, FObj
.Y
)
5165 else FModel
.PlaySound(MODELSOUND_PAIN
, 4, FObj
.X
, FObj
.Y
);
5172 end; // if FLive then ...
5174 if (FActionAnim
= A_PAIN
) and (FModel
.Animation
<> A_PAIN
) then
5176 FModel
.ChangeAnimation(FActionAnim
, FActionForce
);
5177 FModel
.GetCurrentAnimation
.MinLength
:= i
;
5178 FModel
.GetCurrentAnimationMask
.MinLength
:= i
;
5179 end else FModel
.ChangeAnimation(FActionAnim
, FActionForce
and (FModel
.Animation
<> A_STAND
));
5181 if (FModel
.GetCurrentAnimation
.Played
or ((not FActionChanged
) and (FModel
.Animation
= A_WALK
)))
5182 then SetAction(A_STAND
, True);
5184 if not ((FModel
.Animation
= A_WALK
) and (Abs(FObj
.Vel
.X
) < 4) and not FModel
.Fire
) then FModel
.Update
;
5186 for b
:= Low(FKeys
) to High(FKeys
) do
5187 if FKeys
[b
].Time
= 0 then FKeys
[b
].Pressed
:= False else Dec(FKeys
[b
].Time
);
5190 procedure TPlayer
.getMapBox (out x
, y
, w
, h
: Integer); inline;
5192 x
:= FObj
.X
+PLAYER_RECT
.X
;
5193 y
:= FObj
.Y
+PLAYER_RECT
.Y
;
5194 w
:= PLAYER_RECT
.Width
;
5195 h
:= PLAYER_RECT
.Height
;
5198 function TPlayer
.Collide(X
, Y
: Integer; Width
, Height
: Word): Boolean;
5200 Result
:= g_Collide(FObj
.X
+PLAYER_RECT
.X
,
5201 FObj
.Y
+PLAYER_RECT
.Y
,
5208 function TPlayer
.Collide(Panel
: TPanel
): Boolean;
5210 Result
:= g_Collide(FObj
.X
+PLAYER_RECT
.X
,
5211 FObj
.Y
+PLAYER_RECT
.Y
,
5215 Panel
.Width
, Panel
.Height
);
5218 function TPlayer
.Collide(X
, Y
: Integer): Boolean;
5220 X
:= X
-FObj
.X
-PLAYER_RECT
.X
;
5221 Y
:= Y
-FObj
.Y
-PLAYER_RECT
.Y
;
5222 Result
:= (x
>= 0) and (x
<= PLAYER_RECT
.Width
) and
5223 (y
>= 0) and (y
<= PLAYER_RECT
.Height
);
5226 function g_Player_ValidName(Name
: string): Boolean;
5232 if gPlayers
= nil then Exit
;
5234 for a
:= 0 to High(gPlayers
) do
5235 if gPlayers
[a
] <> nil then
5236 if LowerCase(Name
) = LowerCase(gPlayers
[a
].FName
) then
5243 procedure TPlayer
.SetDirection(Direction
: TDirection
);
5247 d
:= FModel
.Direction
;
5249 FModel
.Direction
:= Direction
;
5250 if d
<> Direction
then FModel
.ChangeAnimation(FModel
.Animation
, True);
5252 FDirection
:= Direction
;
5255 function TPlayer
.GetKeys(): Byte;
5259 if R_KEY_RED
in FRulez
then Result
:= KEY_RED
;
5260 if R_KEY_GREEN
in FRulez
then Result
:= Result
or KEY_GREEN
;
5261 if R_KEY_BLUE
in FRulez
then Result
:= Result
or KEY_BLUE
;
5263 if FTeam
= TEAM_RED
then Result
:= Result
or KEY_REDTEAM
;
5264 if FTeam
= TEAM_BLUE
then Result
:= Result
or KEY_BLUETEAM
;
5267 procedure TPlayer
.Use();
5271 if FTime
[T_USE
] > gTime
then Exit
;
5273 g_Triggers_PressR(FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+PLAYER_RECT
.Y
, PLAYER_RECT
.Width
,
5274 PLAYER_RECT
.Height
, FUID
, ACTIVATE_PLAYERPRESS
);
5276 for a
:= 0 to High(gPlayers
) do
5277 if (gPlayers
[a
] <> nil) and (gPlayers
[a
] <> Self
) and
5278 gPlayers
[a
].Live
and SameTeam(FUID
, gPlayers
[a
].FUID
) and
5279 g_Obj_Collide(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
,
5280 FObj
.Rect
.Width
, FObj
.Rect
.Height
, @gPlayers
[a
].FObj
) then
5282 gPlayers
[a
].Touch();
5283 if g_Game_IsNet
and g_Game_IsServer
then
5284 MH_SEND_GameEvent(NET_EV_PLAYER_TOUCH
, gPlayers
[a
].FUID
);
5287 FTime
[T_USE
] := gTime
+120;
5290 procedure TPlayer
.NetFire(Wpn
: Byte; X
, Y
, AX
, AY
: Integer; WID
: Integer = -1);
5294 WX
, WY
, XD
, YD
: Integer;
5305 if R_BERSERK
in FRulez
then
5307 //g_Weapon_punch(FObj.X+FObj.Rect.X, FObj.Y+FObj.Rect.Y, 75, FUID);
5308 locobj
.X
:= FObj
.X
+FObj
.Rect
.X
;
5309 locobj
.Y
:= FObj
.Y
+FObj
.Rect
.Y
;
5312 locobj
.rect
.Width
:= 39;
5313 locobj
.rect
.Height
:= 52;
5314 locobj
.Vel
.X
:= (xd
-wx
) div 2;
5315 locobj
.Vel
.Y
:= (yd
-wy
) div 2;
5316 locobj
.Accel
.X
:= xd
-wx
;
5317 locobj
.Accel
.y
:= yd
-wy
;
5319 if g_Weapon_Hit(@locobj
, 50, FUID
, HIT_SOME
) <> 0 then
5320 g_Sound_PlayExAt('SOUND_WEAPON_HITBERSERK', FObj
.X
, FObj
.Y
)
5322 g_Sound_PlayExAt('SOUND_WEAPON_MISSBERSERK', FObj
.X
, FObj
.Y
);
5326 FPain
:= min(FPain
+ 25, 50);
5328 g_Weapon_punch(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
, 3, FUID
);
5333 if g_Weapon_chainsaw(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
,
5334 IfThen(gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
], 9, 3), FUID
) <> 0 then
5336 FSawSoundSelect
.Stop();
5338 FSawSoundHit
.PlayAt(FObj
.X
, FObj
.Y
);
5340 else if not FSawSoundHit
.IsPlaying() then
5342 FSawSoundSelect
.Stop();
5343 FSawSound
.PlayAt(FObj
.X
, FObj
.Y
);
5350 g_Sound_PlayExAt('SOUND_WEAPON_FIREPISTOL', GameX
, Gamey
);
5351 FFireAngle
:= FAngle
;
5353 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
5354 GameVelX
, GameVelY
-2, SHELL_BULLET
);
5359 g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN', Gamex
, Gamey
);
5360 FFireAngle
:= FAngle
;
5363 FShellType
:= SHELL_SHELL
;
5368 g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN2', Gamex
, Gamey
);
5369 FFireAngle
:= FAngle
;
5372 FShellType
:= SHELL_DBLSHELL
;
5377 g_Sound_PlayExAt('SOUND_WEAPON_FIRECGUN', Gamex
, Gamey
);
5378 FFireAngle
:= FAngle
;
5380 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
5381 GameVelX
, GameVelY
-2, SHELL_BULLET
);
5384 WEAPON_ROCKETLAUNCHER
:
5386 g_Weapon_Rocket(wx
, wy
, xd
, yd
, FUID
, WID
);
5387 FFireAngle
:= FAngle
;
5393 g_Weapon_Plasma(wx
, wy
, xd
, yd
, FUID
, WID
);
5394 FFireAngle
:= FAngle
;
5400 g_Weapon_BFGShot(wx
, wy
, xd
, yd
, FUID
, WID
);
5401 FFireAngle
:= FAngle
;
5405 WEAPON_SUPERPULEMET
:
5407 g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN', Gamex
, Gamey
);
5408 FFireAngle
:= FAngle
;
5410 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
5411 GameVelX
, GameVelY
-2, SHELL_SHELL
);
5414 WEAPON_FLAMETHROWER
:
5416 g_Weapon_flame(wx
, wy
, xd
, yd
, FUID
, WID
);
5417 FFireAngle
:= FAngle
;
5424 if (FAngle
= 0) or (FAngle
= 180) then SetAction(A_ATTACK
)
5425 else if (FAngle
= ANGLE_LEFTDOWN
) or (FAngle
= ANGLE_RIGHTDOWN
) then SetAction(A_ATTACKDOWN
)
5426 else if (FAngle
= ANGLE_LEFTUP
) or (FAngle
= ANGLE_RIGHTUP
) then SetAction(A_ATTACKUP
);
5429 procedure TPlayer
.DoLerp(Level
: Integer = 2);
5431 if FObj
.X
<> FXTo
then FObj
.X
:= Lerp(FObj
.X
, FXTo
, Level
);
5432 if FObj
.Y
<> FYTo
then FObj
.Y
:= Lerp(FObj
.Y
, FYTo
, Level
);
5435 procedure TPlayer
.SetLerp(XTo
, YTo
: Integer);
5439 if NetInterpLevel
< 1 then
5449 AX
:= Abs(FXTo
- FObj
.X
);
5450 AY
:= Abs(FYTo
- FObj
.Y
);
5451 if (AX
> 32) or (AX
<= NetInterpLevel
) then
5453 if (AY
> 32) or (AY
<= NetInterpLevel
) then
5458 function TPlayer
.FullInLift(XInc
, YInc
: Integer): Integer;
5460 if g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
,
5461 PLAYER_RECT
.Width
, PLAYER_RECT
.Height
-8,
5462 PANEL_LIFTUP
, False) then Result
:= -1
5464 if g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
,
5465 PLAYER_RECT
.Width
, PLAYER_RECT
.Height
-8,
5466 PANEL_LIFTDOWN
, False) then Result
:= 1
5470 function TPlayer
.GetFlag(Flag
: Byte): Boolean;
5477 if Flag
= FLAG_NONE
then
5480 if not g_Game_IsServer
then Exit
;
5482 // Ïðèíåñ ÷óæîé ôëàã íà ñâîþ áàçó:
5483 if (Flag
= FTeam
) and
5484 (gFlags
[Flag
].State
= FLAG_STATE_NORMAL
) and
5485 (FFlag
<> FLAG_NONE
) then
5487 if FFlag
= FLAG_RED
then
5488 s
:= _lc
[I_PLAYER_FLAG_RED
]
5490 s
:= _lc
[I_PLAYER_FLAG_BLUE
];
5492 evtype
:= FLAG_STATE_SCORED
;
5494 ts
:= Format('%.4d', [gFlags
[FFlag
].CaptureTime
]);
5495 Insert('.', ts
, Length(ts
) + 1 - 3);
5496 g_Console_Add(Format(_lc
[I_PLAYER_FLAG_CAPTURE
], [FName
, s
, ts
]), True);
5498 g_Map_ResetFlag(FFlag
);
5499 g_Game_Message(Format(_lc
[I_MESSAGE_FLAG_CAPTURE
], [AnsiUpperCase(s
)]), 144);
5501 gTeamStat
[FTeam
].Goals
:= gTeamStat
[FTeam
].Goals
+ 1;
5504 if g_Game_IsNet
then
5506 MH_SEND_FlagEvent(evtype
, FFlag
, FUID
, False);
5510 gFlags
[FFlag
].CaptureTime
:= 0;
5515 // Ïîäîáðàë ñâîé ôëàã - âåðíóë åãî íà áàçó:
5516 if (Flag
= FTeam
) and
5517 (gFlags
[Flag
].State
= FLAG_STATE_DROPPED
) then
5519 if Flag
= FLAG_RED
then
5520 s
:= _lc
[I_PLAYER_FLAG_RED
]
5522 s
:= _lc
[I_PLAYER_FLAG_BLUE
];
5524 evtype
:= FLAG_STATE_RETURNED
;
5525 gFlags
[Flag
].CaptureTime
:= 0;
5527 g_Console_Add(Format(_lc
[I_PLAYER_FLAG_RETURN
], [FName
, s
]), True);
5529 g_Map_ResetFlag(Flag
);
5530 g_Game_Message(Format(_lc
[I_MESSAGE_FLAG_RETURN
], [AnsiUpperCase(s
)]), 144);
5533 if g_Game_IsNet
then
5535 MH_SEND_FlagEvent(evtype
, Flag
, FUID
, False);
5541 // Ïîäîáðàë ÷óæîé ôëàã:
5542 if (Flag
<> FTeam
) and (FTime
[T_FLAGCAP
] <= gTime
) then
5546 if Flag
= FLAG_RED
then
5547 s
:= _lc
[I_PLAYER_FLAG_RED
]
5549 s
:= _lc
[I_PLAYER_FLAG_BLUE
];
5551 evtype
:= FLAG_STATE_CAPTURED
;
5553 g_Console_Add(Format(_lc
[I_PLAYER_FLAG_GET
], [FName
, s
]), True);
5555 g_Game_Message(Format(_lc
[I_MESSAGE_FLAG_GET
], [AnsiUpperCase(s
)]), 144);
5557 gFlags
[Flag
].State
:= FLAG_STATE_CAPTURED
;
5560 if g_Game_IsNet
then
5562 MH_SEND_FlagEvent(evtype
, Flag
, FUID
, False);
5568 procedure TPlayer
.SetFlag(Flag
: Byte);
5571 if FModel
<> nil then
5572 FModel
.SetFlag(FFlag
);
5575 function TPlayer
.DropFlag(): Boolean;
5580 if (not g_Game_IsServer
) or (FFlag
= FLAG_NONE
) then
5582 FTime
[T_FLAGCAP
] := gTime
+ 2000;
5583 with gFlags
[FFlag
] do
5587 Direction
:= FDirection
;
5588 State
:= FLAG_STATE_DROPPED
;
5590 g_Obj_Push(@Obj
, (FObj
.Vel
.X
div 2)-2+Random(5),
5591 (FObj
.Vel
.Y
div 2)-2+Random(5));
5592 positionChanged(); // this updates spatial accelerators
5594 if FFlag
= FLAG_RED
then
5595 s
:= _lc
[I_PLAYER_FLAG_RED
]
5597 s
:= _lc
[I_PLAYER_FLAG_BLUE
];
5599 g_Console_Add(Format(_lc
[I_PLAYER_FLAG_DROP
], [FName
, s
]), True);
5600 g_Game_Message(Format(_lc
[I_MESSAGE_FLAG_DROP
], [AnsiUpperCase(s
)]), 144);
5602 if g_Game_IsNet
then
5603 MH_SEND_FlagEvent(FLAG_STATE_DROPPED
, Flag
, FUID
, False);
5609 procedure TPlayer
.GetSecret();
5614 procedure TPlayer
.PressKey(Key
: Byte; Time
: Word = 1);
5616 Assert(Key
<= High(FKeys
));
5618 FKeys
[Key
].Pressed
:= True;
5619 FKeys
[Key
].Time
:= Time
;
5622 function TPlayer
.IsKeyPressed(K
: Byte): Boolean;
5624 Result
:= FKeys
[K
].Pressed
;
5627 procedure TPlayer
.ReleaseKeys();
5631 for a
:= Low(FKeys
) to High(FKeys
) do
5633 FKeys
[a
].Pressed
:= False;
5638 procedure TPlayer
.OnDamage(Angle
: SmallInt);
5642 function TPlayer
.firediry(): Integer;
5644 if FKeys
[KEY_UP
].Pressed
then Result
:= -42
5645 else if FKeys
[KEY_DOWN
].Pressed
then Result
:= 19
5649 procedure TPlayer
.RememberState();
5653 FSavedState
.Health
:= FHealth
;
5654 FSavedState
.Armor
:= FArmor
;
5655 FSavedState
.Air
:= FAir
;
5656 FSavedState
.JetFuel
:= FJetFuel
;
5657 FSavedState
.CurrWeap
:= FCurrWeap
;
5658 FSavedState
.NextWeap
:= FNextWeap
;
5659 FSavedState
.NextWeapDelay
:= FNextWeapDelay
;
5662 FSavedState
.Ammo
[i
] := FAmmo
[i
];
5664 FSavedState
.MaxAmmo
[i
] := FMaxAmmo
[i
];
5666 FSavedState
.Rulez
:= FRulez
;
5667 FSavedState
.WaitRecall
:= True;
5670 procedure TPlayer
.RecallState();
5674 if not FSavedState
.WaitRecall
then Exit
;
5676 FHealth
:= FSavedState
.Health
;
5677 FArmor
:= FSavedState
.Armor
;
5678 FAir
:= FSavedState
.Air
;
5679 FJetFuel
:= FSavedState
.JetFuel
;
5680 FCurrWeap
:= FSavedState
.CurrWeap
;
5681 FNextWeap
:= FSavedState
.NextWeap
;
5682 FNextWeapDelay
:= FSavedState
.NextWeapDelay
;
5685 FAmmo
[i
] := FSavedState
.Ammo
[i
];
5687 FMaxAmmo
[i
] := FSavedState
.MaxAmmo
[i
];
5689 FRulez
:= FSavedState
.Rulez
;
5690 FSavedState
.WaitRecall
:= False;
5692 if gGameSettings
.GameType
= GT_SERVER
then
5693 MH_SEND_PlayerStats(FUID
);
5696 procedure TPlayer
.SaveState(var Mem
: TBinMemoryWriter
);
5708 Mem
:= TBinMemoryWriter
.Create(i
);
5710 // Ñèãíàòóðà èãðîêà:
5711 sig
:= PLAYER_SIGNATURE
; // 'PLYR'
5712 Mem
.WriteDWORD(sig
);
5714 Mem
.WriteBoolean(FIamBot
);
5716 Mem
.WriteWord(FUID
);
5718 Mem
.WriteString(FName
, 32);
5720 Mem
.WriteByte(FTeam
);
5722 Mem
.WriteBoolean(FLive
);
5723 // Èçðàñõîäîâàë ëè âñå æèçíè:
5724 Mem
.WriteBoolean(FNoRespawn
);
5726 if FDirection
= D_LEFT
then
5732 Mem
.WriteInt(FHealth
);
5734 Mem
.WriteByte(FLives
);
5736 Mem
.WriteInt(FArmor
);
5740 Mem
.WriteInt(FJetFuel
);
5742 Mem
.WriteInt(FPain
);
5744 Mem
.WriteInt(FKills
);
5746 Mem
.WriteInt(FMonsterKills
);
5748 Mem
.WriteInt(FFrags
);
5750 Mem
.WriteByte(FFragCombo
);
5751 // Âðåìÿ ïîñëåäíåãî ôðàãà:
5752 Mem
.WriteDWORD(FLastFrag
);
5754 Mem
.WriteInt(FDeath
);
5755 // Êàêîé ôëàã íåñåò:
5756 Mem
.WriteByte(FFlag
);
5758 Mem
.WriteInt(FSecrets
);
5760 Mem
.WriteByte(FCurrWeap
);
5762 Mem
.WriteWord(FNextWeap
);
5764 Mem
.WriteByte(FNextWeapDelay
);
5765 // Âðåìÿ çàðÿäêè BFG:
5766 Mem
.WriteSmallInt(FBFGFireCounter
);
5768 Mem
.WriteInt(FDamageBuffer
);
5769 // Ïîñëåäíèé óäàðèâøèé:
5770 Mem
.WriteWord(FLastSpawnerUID
);
5771 // Òèï ïîñëåäíåãî ïîëó÷åííîãî óðîíà:
5772 Mem
.WriteByte(FLastHit
);
5774 Obj_SaveState(@FObj
, Mem
);
5775 // Òåêóùåå êîëè÷åñòâî ïàòðîíîâ:
5776 for i
:= A_BULLETS
to A_HIGH
do
5777 Mem
.WriteWord(FAmmo
[i
]);
5778 // Ìàêñèìàëüíîå êîëè÷åñòâî ïàòðîíîâ:
5779 for i
:= A_BULLETS
to A_HIGH
do
5780 Mem
.WriteWord(FMaxAmmo
[i
]);
5782 for i
:= WP_FIRST
to WP_LAST
do
5783 Mem
.WriteBoolean(FWeapon
[i
]);
5784 // Âðåìÿ ïåðåçàðÿäêè îðóæèÿ:
5785 for i
:= WP_FIRST
to WP_LAST
do
5786 Mem
.WriteWord(FReloading
[i
]);
5788 if R_ITEM_BACKPACK
in FRulez
then
5793 // Íàëè÷èå êðàñíîãî êëþ÷à:
5794 if R_KEY_RED
in FRulez
then
5799 // Íàëè÷èå çåëåíîãî êëþ÷à:
5800 if R_KEY_GREEN
in FRulez
then
5805 // Íàëè÷èå ñèíåãî êëþ÷à:
5806 if R_KEY_BLUE
in FRulez
then
5811 // Íàëè÷èå áåðñåðêà:
5812 if R_BERSERK
in FRulez
then
5817 // Âðåìÿ äåéñòâèÿ ñïåöèàëüíûõ ïðåäìåòîâ:
5818 for i
:= MR_SUIT
to MR_MAX
do
5819 Mem
.WriteDWORD(FMegaRulez
[i
]);
5820 // Âðåìÿ äî ïîâòîðíîãî ðåñïàóíà, ñìåíû îðóæèÿ, èñîëüçîâàíèÿ, çàõâàòà ôëàãà:
5821 for i
:= T_RESPAWN
to T_FLAGCAP
do
5822 Mem
.WriteDWORD(FTime
[i
]);
5825 Mem
.WriteString(str
);
5835 procedure TPlayer
.LoadState(var Mem
: TBinMemoryReader
);
5845 // Ñèãíàòóðà èãðîêà:
5847 if sig
<> PLAYER_SIGNATURE
then // 'PLYR'
5849 raise EBinSizeError
.Create('TPlayer.LoadState: Wrong Player Signature');
5852 Mem
.ReadBoolean(FIamBot
);
5856 Mem
.ReadString(str
);
5857 if (Self
<> gPlayer1
) and (Self
<> gPlayer2
) then
5860 Mem
.ReadByte(FTeam
);
5862 Mem
.ReadBoolean(FLive
);
5863 // Èçðàñõîäîâàë ëè âñå æèçíè:
5864 Mem
.ReadBoolean(FNoRespawn
);
5868 FDirection
:= D_LEFT
5870 FDirection
:= D_RIGHT
;
5872 Mem
.ReadInt(FHealth
);
5874 Mem
.ReadByte(FLives
);
5876 Mem
.ReadInt(FArmor
);
5880 Mem
.ReadInt(FJetFuel
);
5884 Mem
.ReadInt(FKills
);
5886 Mem
.ReadInt(FMonsterKills
);
5888 Mem
.ReadInt(FFrags
);
5890 Mem
.ReadByte(FFragCombo
);
5891 // Âðåìÿ ïîñëåäíåãî ôðàãà:
5892 Mem
.ReadDWORD(FLastFrag
);
5894 Mem
.ReadInt(FDeath
);
5895 // Êàêîé ôëàã íåñåò:
5896 Mem
.ReadByte(FFlag
);
5898 Mem
.ReadInt(FSecrets
);
5900 Mem
.ReadByte(FCurrWeap
);
5902 Mem
.ReadWord(FNextWeap
);
5904 Mem
.ReadByte(FNextWeapDelay
);
5905 // Âðåìÿ çàðÿäêè BFG:
5906 Mem
.ReadSmallInt(FBFGFireCounter
);
5908 Mem
.ReadInt(FDamageBuffer
);
5909 // Ïîñëåäíèé óäàðèâøèé:
5910 Mem
.ReadWord(FLastSpawnerUID
);
5911 // Òèï ïîñëåäíåãî ïîëó÷åííîãî óðîíà:
5912 Mem
.ReadByte(FLastHit
);
5914 Obj_LoadState(@FObj
, Mem
);
5915 // Òåêóùåå êîëè÷åñòâî ïàòðîíîâ:
5916 for i
:= A_BULLETS
to A_HIGH
do
5917 Mem
.ReadWord(FAmmo
[i
]);
5918 // Ìàêñèìàëüíîå êîëè÷åñòâî ïàòðîíîâ:
5919 for i
:= A_BULLETS
to A_HIGH
do
5920 Mem
.ReadWord(FMaxAmmo
[i
]);
5922 for i
:= WP_FIRST
to WP_LAST
do
5923 Mem
.ReadBoolean(FWeapon
[i
]);
5924 // Âðåìÿ ïåðåçàðÿäêè îðóæèÿ:
5925 for i
:= WP_FIRST
to WP_LAST
do
5926 Mem
.ReadWord(FReloading
[i
]);
5930 Include(FRulez
, R_ITEM_BACKPACK
);
5931 // Íàëè÷èå êðàñíîãî êëþ÷à:
5934 Include(FRulez
, R_KEY_RED
);
5935 // Íàëè÷èå çåëåíîãî êëþ÷à:
5938 Include(FRulez
, R_KEY_GREEN
);
5939 // Íàëè÷èå ñèíåãî êëþ÷à:
5942 Include(FRulez
, R_KEY_BLUE
);
5943 // Íàëè÷èå áåðñåðêà:
5946 Include(FRulez
, R_BERSERK
);
5947 // Âðåìÿ äåéñòâèÿ ñïåöèàëüíûõ ïðåäìåòîâ:
5948 for i
:= MR_SUIT
to MR_MAX
do
5949 Mem
.ReadDWORD(FMegaRulez
[i
]);
5950 // Âðåìÿ äî ïîâòîðíîãî ðåñïàóíà, ñìåíû îðóæèÿ, èñîëüçîâàíèÿ, çàõâàòà ôëàãà:
5951 for i
:= T_RESPAWN
to T_FLAGCAP
do
5952 Mem
.ReadDWORD(FTime
[i
]);
5954 Mem
.ReadString(str
);
5956 Mem
.ReadByte(FColor
.R
);
5957 Mem
.ReadByte(FColor
.G
);
5958 Mem
.ReadByte(FColor
.B
);
5959 if Self
= gPlayer1
then
5961 str
:= gPlayer1Settings
.Model
;
5962 FColor
:= gPlayer1Settings
.Color
;
5964 if Self
= gPlayer2
then
5966 str
:= gPlayer2Settings
.Model
;
5967 FColor
:= gPlayer2Settings
.Color
;
5969 // Îáíîâëÿåì ìîäåëü èãðîêà:
5971 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
5972 FModel
.Color
:= TEAMCOLOR
[FTeam
]
5974 FModel
.Color
:= FColor
;
5977 procedure TPlayer
.AllRulez(Health
: Boolean);
5983 FHealth
:= PLAYER_HP_LIMIT
;
5984 FArmor
:= PLAYER_AP_LIMIT
;
5988 for a
:= WP_FIRST
to WP_LAST
do FWeapon
[a
] := True;
5989 for a
:= A_BULLETS
to A_HIGH
do FAmmo
[a
] := 30000;
5990 FRulez
:= FRulez
+[R_KEY_RED
, R_KEY_GREEN
, R_KEY_BLUE
];
5993 procedure TPlayer
.RestoreHealthArmor();
5995 FHealth
:= PLAYER_HP_LIMIT
;
5996 FArmor
:= PLAYER_AP_LIMIT
;
5999 procedure TPlayer
.FragCombo();
6003 if (gGameSettings
.GameMode
in [GM_COOP
, GM_SINGLE
]) or g_Game_IsClient
then
6005 if gTime
- FLastFrag
< FRAG_COMBO_TIME
then
6007 if FFragCombo
< 5 then
6009 Param
:= FUID
or (FFragCombo
shl 16);
6010 if (FComboEvnt
>= Low(gDelayedEvents
)) and
6011 (FComboEvnt
<= High(gDelayedEvents
)) and
6012 gDelayedEvents
[FComboEvnt
].Pending
and
6013 (gDelayedEvents
[FComboEvnt
].DEType
= DE_KILLCOMBO
) and
6014 (gDelayedEvents
[FComboEvnt
].DENum
and $FFFF = FUID
) then
6016 gDelayedEvents
[FComboEvnt
].Time
:= gTime
+ 500;
6017 gDelayedEvents
[FComboEvnt
].DENum
:= Param
;
6020 FComboEvnt
:= g_Game_DelayEvent(DE_KILLCOMBO
, 500, Param
);
6028 procedure TPlayer
.GiveItem(ItemType
: Byte);
6032 if FMegaRulez
[MR_SUIT
] < gTime
+PLAYER_SUIT_TIME
then
6034 FMegaRulez
[MR_SUIT
] := gTime
+PLAYER_SUIT_TIME
;
6038 if FAir
< AIR_MAX
then
6045 if not (R_BERSERK
in FRulez
) then
6047 Include(FRulez
, R_BERSERK
);
6048 if FBFGFireCounter
< 1 then
6050 FCurrWeap
:= WEAPON_KASTET
;
6052 FModel
.SetWeapon(WEAPON_KASTET
);
6056 FBerserk
:= gTime
+30000;
6058 if FHealth
< PLAYER_HP_SOFT
then
6060 FHealth
:= PLAYER_HP_SOFT
;
6061 FBerserk
:= gTime
+30000;
6066 if FMegaRulez
[MR_INVUL
] < gTime
+PLAYER_INVUL_TIME
then
6068 FMegaRulez
[MR_INVUL
] := gTime
+PLAYER_INVUL_TIME
;
6072 if FMegaRulez
[MR_INVIS
] < gTime
+PLAYER_INVIS_TIME
then
6074 FMegaRulez
[MR_INVIS
] := gTime
+PLAYER_INVIS_TIME
;
6078 if FJetFuel
< JET_MAX
then
6080 FJetFuel
:= JET_MAX
;
6083 ITEM_MEDKIT_SMALL
: if FHealth
< PLAYER_HP_SOFT
then IncMax(FHealth
, 10, PLAYER_HP_SOFT
);
6084 ITEM_MEDKIT_LARGE
: if FHealth
< PLAYER_HP_SOFT
then IncMax(FHealth
, 25, PLAYER_HP_SOFT
);
6086 ITEM_ARMOR_GREEN
: if FArmor
< PLAYER_AP_SOFT
then FArmor
:= PLAYER_AP_SOFT
;
6087 ITEM_ARMOR_BLUE
: if FArmor
< PLAYER_AP_LIMIT
then FArmor
:= PLAYER_AP_LIMIT
;
6089 ITEM_SPHERE_BLUE
: if FHealth
< PLAYER_HP_LIMIT
then IncMax(FHealth
, 100, PLAYER_HP_LIMIT
);
6091 if (FHealth
< PLAYER_HP_LIMIT
) or (FArmor
< PLAYER_AP_LIMIT
) then
6093 if FHealth
< PLAYER_HP_LIMIT
then FHealth
:= PLAYER_HP_LIMIT
;
6094 if FArmor
< PLAYER_AP_LIMIT
then FArmor
:= PLAYER_AP_LIMIT
;
6097 ITEM_WEAPON_SAW
: FWeapon
[WEAPON_SAW
] := True;
6098 ITEM_WEAPON_SHOTGUN1
: FWeapon
[WEAPON_SHOTGUN1
] := True;
6099 ITEM_WEAPON_SHOTGUN2
: FWeapon
[WEAPON_SHOTGUN2
] := True;
6100 ITEM_WEAPON_CHAINGUN
: FWeapon
[WEAPON_CHAINGUN
] := True;
6101 ITEM_WEAPON_ROCKETLAUNCHER
: FWeapon
[WEAPON_ROCKETLAUNCHER
] := True;
6102 ITEM_WEAPON_PLASMA
: FWeapon
[WEAPON_PLASMA
] := True;
6103 ITEM_WEAPON_BFG
: FWeapon
[WEAPON_BFG
] := True;
6104 ITEM_WEAPON_SUPERPULEMET
: FWeapon
[WEAPON_SUPERPULEMET
] := True;
6105 ITEM_WEAPON_FLAMETHROWER
: FWeapon
[WEAPON_FLAMETHROWER
] := True;
6107 ITEM_AMMO_BULLETS
: if FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
] then IncMax(FAmmo
[A_BULLETS
], 10, FMaxAmmo
[A_BULLETS
]);
6108 ITEM_AMMO_BULLETS_BOX
: if FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
] then IncMax(FAmmo
[A_BULLETS
], 50, FMaxAmmo
[A_BULLETS
]);
6109 ITEM_AMMO_SHELLS
: if FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
] then IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
6110 ITEM_AMMO_SHELLS_BOX
: if FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
] then IncMax(FAmmo
[A_SHELLS
], 25, FMaxAmmo
[A_SHELLS
]);
6111 ITEM_AMMO_ROCKET
: if FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
] then IncMax(FAmmo
[A_ROCKETS
], 1, FMaxAmmo
[A_ROCKETS
]);
6112 ITEM_AMMO_ROCKET_BOX
: if FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
] then IncMax(FAmmo
[A_ROCKETS
], 5, FMaxAmmo
[A_ROCKETS
]);
6113 ITEM_AMMO_CELL
: if FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
] then IncMax(FAmmo
[A_CELLS
], 40, FMaxAmmo
[A_CELLS
]);
6114 ITEM_AMMO_CELL_BIG
: if FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
] then IncMax(FAmmo
[A_CELLS
], 100, FMaxAmmo
[A_CELLS
]);
6115 ITEM_AMMO_FUELCAN
: if FAmmo
[A_FUEL
] < FMaxAmmo
[A_FUEL
] then IncMax(FAmmo
[A_FUEL
], 100, FMaxAmmo
[A_FUEL
]);
6118 if (FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
]) or
6119 (FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
]) or
6120 (FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
]) or
6121 (FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
]) or
6122 (FMaxAmmo
[A_FUEL
] < AmmoLimits
[1, A_FUEL
]) then
6124 FMaxAmmo
[A_BULLETS
] := AmmoLimits
[1, A_BULLETS
];
6125 FMaxAmmo
[A_SHELLS
] := AmmoLimits
[1, A_SHELLS
];
6126 FMaxAmmo
[A_ROCKETS
] := AmmoLimits
[1, A_ROCKETS
];
6127 FMaxAmmo
[A_CELLS
] := AmmoLimits
[1, A_CELLS
];
6128 FMaxAmmo
[A_FUEL
] := AmmoLimits
[1, A_FUEL
];
6130 if FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
] then IncMax(FAmmo
[A_BULLETS
], 10, FMaxAmmo
[A_BULLETS
]);
6131 if FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
] then IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
6132 if FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
] then IncMax(FAmmo
[A_ROCKETS
], 1, FMaxAmmo
[A_ROCKETS
]);
6133 if FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
] then IncMax(FAmmo
[A_CELLS
], 40, FMaxAmmo
[A_CELLS
]);
6135 FRulez
:= FRulez
+ [R_ITEM_BACKPACK
];
6138 ITEM_KEY_RED
: if not (R_KEY_RED
in FRulez
) then Include(FRulez
, R_KEY_RED
);
6139 ITEM_KEY_GREEN
: if not (R_KEY_GREEN
in FRulez
) then Include(FRulez
, R_KEY_GREEN
);
6140 ITEM_KEY_BLUE
: if not (R_KEY_BLUE
in FRulez
) then Include(FRulez
, R_KEY_BLUE
);
6142 ITEM_BOTTLE
: if FHealth
< PLAYER_HP_LIMIT
then IncMax(FHealth
, 4, PLAYER_HP_LIMIT
);
6143 ITEM_HELMET
: if FArmor
< PLAYER_AP_LIMIT
then IncMax(FArmor
, 5, PLAYER_AP_LIMIT
);
6148 if g_Game_IsNet
and g_Game_IsServer
then
6149 MH_SEND_PlayerStats(FUID
);
6152 procedure TPlayer
.FlySmoke(Times
: DWORD
= 1);
6157 if (Random(5) = 1) and (Times
= 1) then
6160 if BodyInLiquid(0, 0) then
6162 g_GFX_Bubbles(Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2)+Random(3)-1,
6163 Obj
.Y
+Obj
.Rect
.Height
+8, 1, 8, 4);
6164 if Random(2) = 0 then
6165 g_Sound_PlayExAt('SOUND_GAME_BUBBLE1', FObj
.X
, FObj
.Y
)
6167 g_Sound_PlayExAt('SOUND_GAME_BUBBLE2', FObj
.X
, FObj
.Y
);
6171 if g_Frames_Get(id
, 'FRAMES_SMOKE') then
6173 for i
:= 1 to Times
do
6175 Anim
:= TAnimation
.Create(id
, False, 3);
6177 g_GFX_OnceAnim(Obj
.X
+Obj
.Rect
.X
+Random(Obj
.Rect
.Width
+Times
*2)-(Anim
.Width
div 2),
6178 Obj
.Y
+Obj
.Rect
.Height
-4+Random(8+Times
*2), Anim
, ONCEANIM_SMOKE
);
6184 procedure TPlayer
.OnFireFlame(Times
: DWORD
= 1);
6189 if (Random(10) = 1) and (Times
= 1) then
6192 if g_Frames_Get(id
, 'FRAMES_FLAME') then
6194 for i
:= 1 to Times
do
6196 Anim
:= TAnimation
.Create(id
, False, 3);
6198 g_GFX_OnceAnim(Obj
.X
+Obj
.Rect
.X
+Random(Obj
.Rect
.Width
+Times
*2)-(Anim
.Width
div 2),
6199 Obj
.Y
+8+Random(8+Times
*2), Anim
, ONCEANIM_SMOKE
);
6205 procedure TPlayer
.PauseSounds(Enable
: Boolean);
6207 FSawSound
.Pause(Enable
);
6208 FSawSoundIdle
.Pause(Enable
);
6209 FSawSoundHit
.Pause(Enable
);
6210 FSawSoundSelect
.Pause(Enable
);
6215 constructor TCorpse
.Create(X
, Y
: Integer; ModelName
: String; aMess
: Boolean);
6220 FObj
.Rect
:= PLAYER_CORPSERECT
;
6221 FModelName
:= ModelName
;
6226 FState
:= CORPSE_STATE_MESS
;
6227 g_PlayerModel_GetAnim(ModelName
, A_DIE2
, FAnimation
, FAnimationMask
);
6231 FState
:= CORPSE_STATE_NORMAL
;
6232 g_PlayerModel_GetAnim(ModelName
, A_DIE1
, FAnimation
, FAnimationMask
);
6236 destructor TCorpse
.Destroy();
6243 procedure TCorpse
.positionChanged (); begin end;
6245 procedure TCorpse
.Damage(Value
: Word; vx
, vy
: Integer);
6249 if FState
= CORPSE_STATE_REMOVEME
then
6252 FDamage
:= FDamage
+ Value
;
6254 if FDamage
> 150 then
6256 if FAnimation
<> nil then
6261 FState
:= CORPSE_STATE_REMOVEME
;
6263 g_Player_CreateGibs(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
6264 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2),
6265 FModelName
, FColor
);
6266 // Çâóê ìÿñà îò òðóïà:
6267 pm
:= g_PlayerModel_Get(FModelName
);
6268 pm
.PlaySound(MODELSOUND_DIE
, 5, FObj
.X
, FObj
.Y
);
6274 FObj
.Vel
.X
:= FObj
.Vel
.X
+ vx
;
6275 FObj
.Vel
.Y
:= FObj
.Vel
.Y
+ vy
;
6276 g_GFX_Blood(FObj
.X
+PLAYER_CORPSERECT
.X
+(PLAYER_CORPSERECT
.Width
div 2),
6277 FObj
.Y
+PLAYER_CORPSERECT
.Y
+(PLAYER_CORPSERECT
.Height
div 2),
6278 Value
, vx
, vy
, 16, (PLAYER_CORPSERECT
.Height
*2) div 3,
6283 procedure TCorpse
.Draw();
6285 if FState
= CORPSE_STATE_REMOVEME
then
6288 if FAnimation
<> nil then
6289 FAnimation
.Draw(FObj
.X
, FObj
.Y
, M_NONE
);
6291 if FAnimationMask
<> nil then
6294 FAnimationMask
.Draw(FObj
.X
, FObj
.Y
, M_NONE
);
6301 procedure TCorpse
.Update();
6305 if FState
= CORPSE_STATE_REMOVEME
then
6308 if gTime
mod (GAME_TICK
*2) <> 0 then
6310 g_Obj_Move(@FObj
, True, True, True);
6311 positionChanged(); // this updates spatial accelerators
6315 // Ñîïðîòèâëåíèå âîçäóõà äëÿ òðóïà:
6316 FObj
.Vel
.X
:= z_dec(FObj
.Vel
.X
, 1);
6318 st
:= g_Obj_Move(@FObj
, True, True, True);
6319 positionChanged(); // this updates spatial accelerators
6321 if WordBool(st
and MOVE_FALLOUT
) then
6323 FState
:= CORPSE_STATE_REMOVEME
;
6327 if FAnimation
<> nil then
6328 FAnimation
.Update();
6329 if FAnimationMask
<> nil then
6330 FAnimationMask
.Update();
6333 procedure TCorpse
.SaveState(var Mem
: TBinMemoryWriter
);
6342 sig
:= CORPSE_SIGNATURE
; // 'CORP'
6343 Mem
.WriteDWORD(sig
);
6345 Mem
.WriteByte(FState
);
6346 // Íàêîïëåííûé óðîí:
6347 Mem
.WriteByte(FDamage
);
6349 Mem
.WriteByte(FColor
.R
);
6350 Mem
.WriteByte(FColor
.G
);
6351 Mem
.WriteByte(FColor
.B
);
6353 Obj_SaveState(@FObj
, Mem
);
6354 // Åñòü ëè àíèìàöèÿ:
6355 anim
:= FAnimation
<> nil;
6356 Mem
.WriteBoolean(anim
);
6357 // Åñëè åñòü - ñîõðàíÿåì:
6359 FAnimation
.SaveState(Mem
);
6360 // Åñòü ëè ìàñêà àíèìàöèè:
6361 anim
:= FAnimationMask
<> nil;
6362 Mem
.WriteBoolean(anim
);
6363 // Åñëè åñòü - ñîõðàíÿåì:
6365 FAnimationMask
.SaveState(Mem
);
6368 procedure TCorpse
.LoadState(var Mem
: TBinMemoryReader
);
6378 if sig
<> CORPSE_SIGNATURE
then // 'CORP'
6380 raise EBinSizeError
.Create('TCorpse.LoadState: Wrong Corpse Signature');
6383 Mem
.ReadByte(FState
);
6384 // Íàêîïëåííûé óðîí:
6385 Mem
.ReadByte(FDamage
);
6387 Mem
.ReadByte(FColor
.R
);
6388 Mem
.ReadByte(FColor
.G
);
6389 Mem
.ReadByte(FColor
.B
);
6391 Obj_LoadState(@FObj
, Mem
);
6392 // Åñòü ëè àíèìàöèÿ:
6393 Mem
.ReadBoolean(anim
);
6394 // Åñëè åñòü - çàãðóæàåì:
6397 Assert(FAnimation
<> nil, 'TCorpse.LoadState: no FAnimation');
6398 FAnimation
.LoadState(Mem
);
6400 // Åñòü ëè ìàñêà àíèìàöèè:
6401 Mem
.ReadBoolean(anim
);
6402 // Åñëè åñòü - çàãðóæàåì:
6405 Assert(FAnimationMask
<> nil, 'TCorpse.LoadState: no FAnimationMask');
6406 FAnimationMask
.LoadState(Mem
);
6412 constructor TBot
.Create();
6419 FSpectator
:= False;
6426 for a
:= WP_FIRST
to WP_LAST
do
6428 FDifficult
.WeaponPrior
[a
] := WEAPON_PRIOR1
[a
];
6429 FDifficult
.CloseWeaponPrior
[a
] := WEAPON_PRIOR2
[a
];
6430 //FDifficult.SafeWeaponPrior[a] := WEAPON_PRIOR3[a];
6434 destructor TBot
.Destroy();
6437 inherited Destroy();
6440 procedure TBot
.Draw();
6444 //if FTargetUID <> 0 then e_DrawLine(1, FObj.X, FObj.Y, g_Player_Get(FTargetUID).FObj.X,
6445 // g_Player_Get(FTargetUID).FObj.Y, 255, 0, 0);
6448 procedure TBot
.Respawn(Silent
: Boolean; Force
: Boolean = False);
6450 inherited Respawn(Silent
, Force
);
6453 FSelectedWeapon
:= FCurrWeap
;
6458 procedure TBot
.UpdateCombat();
6471 TTargetRecord
= array of TTarget
;
6473 function Compare(a
, b
: TTarget
): Integer;
6475 if a
.Line
and not b
.Line
then // A íà ëèíèè îãíÿ
6478 if not a
.Line
and b
.Line
then // B íà ëèíèè îãíÿ
6480 else // È A, è B íà ëèíèè èëè íå íà ëèíèè îãíÿ
6481 if (a
.Line
and b
.Line
) or ((not a
.Line
) and (not b
.Line
)) then
6483 if a
.Dist
> b
.Dist
then // B áëèæå
6485 else // A áëèæå èëè ðàâíîóäàëåííî ñ B
6488 else // Ñòðàííî -> A
6493 a
, x1
, y1
, x2
, y2
: Integer;
6494 targets
: TTargetRecord
;
6496 Target
, BestTarget
: TTarget
;
6497 firew
, fireh
: Integer;
6501 vsPlayer
, vsMonster
, ok
: Boolean;
6504 function monsUpdate (mon
: TMonster
): Boolean;
6506 result
:= false; // don't stop
6507 if mon
.Live
and (mon
.MonsterType
<> MONSTER_BARREL
) then
6509 if not TargetOnScreen(mon
.Obj
.X
+mon
.Obj
.Rect
.X
, mon
.Obj
.Y
+mon
.Obj
.Rect
.Y
) then exit
;
6511 x2
:= mon
.Obj
.X
+mon
.Obj
.Rect
.X
+(mon
.Obj
.Rect
.Width
div 2);
6512 y2
:= mon
.Obj
.Y
+mon
.Obj
.Rect
.Y
+(mon
.Obj
.Rect
.Height
div 2);
6514 // Åñëè ìîíñòð íà ýêðàíå è íå ïðèêðûò ñòåíîé
6515 if g_TraceVector(x1
, y1
, x2
, y2
) then
6517 // Äîáàâëÿåì ê ñïèñêó âîçìîæíûõ öåëåé
6518 SetLength(targets
, Length(targets
)+1);
6519 with targets
[High(targets
)] do
6526 Rect
:= mon
.Obj
.Rect
;
6527 Dist
:= g_PatchLength(x1
, y1
, x2
, y2
);
6528 Line
:= (y1
+4 < Target
.Y
+ mon
.Obj
.Rect
.Y
+ mon
.Obj
.Rect
.Height
) and
6529 (y1
-4 > Target
.Y
+ mon
.Obj
.Rect
.Y
);
6538 vsPlayer
:= LongBool(gGameSettings
.Options
and GAME_OPTION_BOTVSPLAYER
);
6539 vsMonster
:= LongBool(gGameSettings
.Options
and GAME_OPTION_BOTVSMONSTER
);
6541 // Åñëè òåêóùåå îðóæèå íå òî, ÷òî íóæíî, òî ìåíÿåì:
6542 if FCurrWeap
<> FSelectedWeapon
then
6545 // Åñëè íóæíî ñòðåëÿòü è íóæíîå îðóæèå, òî íàæàòü "Ñòðåëÿòü":
6546 if (GetAIFlag('NEEDFIRE') <> '') and (FCurrWeap
= FSelectedWeapon
) then
6548 RemoveAIFlag('NEEDFIRE');
6551 WEAPON_PLASMA
, WEAPON_SUPERPULEMET
, WEAPON_CHAINGUN
: PressKey(KEY_FIRE
, 20);
6552 WEAPON_SAW
, WEAPON_KASTET
, WEAPON_FLAMETHROWER
: PressKey(KEY_FIRE
, 40);
6553 else PressKey(KEY_FIRE
);
6557 // Êîîðäèíàòû ñòâîëà:
6558 x1
:= FObj
.X
+ WEAPONPOINT
[FDirection
].X
;
6559 y1
:= FObj
.Y
+ WEAPONPOINT
[FDirection
].Y
;
6561 Target
.UID
:= FTargetUID
;
6564 if Target
.UID
<> 0 then
6565 begin // Öåëü åñòü - íàñòðàèâàåì
6566 if (g_GetUIDType(Target
.UID
) = UID_PLAYER
) and
6569 tpla
:= g_Player_Get(Target
.UID
);
6573 if (@FObj
) <> nil then
6580 Target
.cX
:= Target
.X
+ PLAYER_RECT_CX
;
6581 Target
.cY
:= Target
.Y
+ PLAYER_RECT_CY
;
6582 Target
.Rect
:= PLAYER_RECT
;
6583 Target
.Visible
:= g_TraceVector(x1
, y1
, Target
.cX
, Target
.cY
);
6584 Target
.Line
:= (y1
+4 < Target
.Y
+PLAYER_RECT
.Y
+PLAYER_RECT
.Height
) and
6585 (y1
-4 > Target
.Y
+PLAYER_RECT
.Y
);
6586 Target
.IsPlayer
:= True;
6590 if (g_GetUIDType(Target
.UID
) = UID_MONSTER
) and
6593 mon
:= g_Monsters_ByUID(Target
.UID
);
6596 Target
.X
:= mon
.Obj
.X
;
6597 Target
.Y
:= mon
.Obj
.Y
;
6599 Target
.cX
:= Target
.X
+ mon
.Obj
.Rect
.X
+ (mon
.Obj
.Rect
.Width
div 2);
6600 Target
.cY
:= Target
.Y
+ mon
.Obj
.Rect
.Y
+ (mon
.Obj
.Rect
.Height
div 2);
6601 Target
.Rect
:= mon
.Obj
.Rect
;
6602 Target
.Visible
:= g_TraceVector(x1
, y1
, Target
.cX
, Target
.cY
);
6603 Target
.Line
:= (y1
+4 < Target
.Y
+ mon
.Obj
.Rect
.Y
+ mon
.Obj
.Rect
.Height
) and
6604 (y1
-4 > Target
.Y
+ mon
.Obj
.Rect
.Y
);
6605 Target
.IsPlayer
:= False;
6612 begin // Öåëè íåò - îáíóëÿåì
6617 Target
.Visible
:= False;
6618 Target
.Line
:= False;
6619 Target
.IsPlayer
:= False;
6624 // Åñëè öåëü íå âèäèìà èëè íå íà ëèíèè îãíÿ, òî èùåì âñå âîçìîæíûå öåëè:
6625 if (not Target
.Line
) or (not Target
.Visible
) then
6629 for a
:= 0 to High(gPlayers
) do
6630 if (gPlayers
[a
] <> nil) and (gPlayers
[a
].Live
) and
6631 (gPlayers
[a
].FUID
<> FUID
) and
6632 (not SameTeam(FUID
, gPlayers
[a
].FUID
)) and
6633 (not gPlayers
[a
].NoTarget
) and
6634 (gPlayers
[a
].FMegaRulez
[MR_INVIS
] < gTime
) then
6636 if not TargetOnScreen(gPlayers
[a
].FObj
.X
+ PLAYER_RECT
.X
,
6637 gPlayers
[a
].FObj
.Y
+ PLAYER_RECT
.Y
) then
6640 x2
:= gPlayers
[a
].FObj
.X
+ PLAYER_RECT_CX
;
6641 y2
:= gPlayers
[a
].FObj
.Y
+ PLAYER_RECT_CY
;
6643 // Åñëè èãðîê íà ýêðàíå è íå ïðèêðûò ñòåíîé:
6644 if g_TraceVector(x1
, y1
, x2
, y2
) then
6646 // Äîáàâëÿåì ê ñïèñêó âîçìîæíûõ öåëåé:
6647 SetLength(targets
, Length(targets
)+1);
6648 with targets
[High(targets
)] do
6650 UID
:= gPlayers
[a
].FUID
;
6651 X
:= gPlayers
[a
].FObj
.X
;
6652 Y
:= gPlayers
[a
].FObj
.Y
;
6655 Rect
:= PLAYER_RECT
;
6656 Dist
:= g_PatchLength(x1
, y1
, x2
, y2
);
6657 Line
:= (y1
+4 < Target
.Y
+PLAYER_RECT
.Y
+PLAYER_RECT
.Height
) and
6658 (y1
-4 > Target
.Y
+PLAYER_RECT
.Y
);
6666 if vsMonster
then g_Mons_ForEach(monsUpdate
);
6669 // Åñëè åñòü âîçìîæíûå öåëè:
6670 // (Âûáèðàåì ëó÷øóþ, ìåíÿåì îðóæèå è áåæèì ê íåé/îò íåå)
6671 if targets
<> nil then
6673 // Âûáèðàåì íàèëó÷øóþ öåëü:
6674 BestTarget
:= targets
[0];
6675 if Length(targets
) > 1 then
6676 for a
:= 1 to High(targets
) do
6677 if Compare(BestTarget
, targets
[a
]) = 1 then
6678 BestTarget
:= targets
[a
];
6680 // Åñëè ëó÷øàÿ öåëü "âèäíåå" òåêóùåé, òî òåêóùàÿ := ëó÷øàÿ:
6681 if ((not Target
.Visible
) and BestTarget
.Visible
and (Target
.UID
<> BestTarget
.UID
)) or
6682 ((not Target
.Line
) and BestTarget
.Line
and BestTarget
.Visible
) then
6684 Target
:= BestTarget
;
6686 if (Healthy() = 3) or ((Healthy() = 2)) then
6687 begin // Åñëè çäîðîâû - äîãîíÿåì
6688 if ((RunDirection() = D_LEFT
) and (Target
.X
> FObj
.X
)) then
6689 SetAIFlag('GORIGHT', '1');
6690 if ((RunDirection() = D_RIGHT
) and (Target
.X
< FObj
.X
)) then
6691 SetAIFlag('GOLEFT', '1');
6694 begin // Åñëè ïîáèòû - óáåãàåì
6695 if ((RunDirection() = D_LEFT
) and (Target
.X
< FObj
.X
)) then
6696 SetAIFlag('GORIGHT', '1');
6697 if ((RunDirection() = D_RIGHT
) and (Target
.X
> FObj
.X
)) then
6698 SetAIFlag('GOLEFT', '1');
6701 // Âûáèðàåì îðóæèå íà îñíîâå ðàññòîÿíèÿ è ïðèîðèòåòîâ:
6702 SelectWeapon(Abs(x1
-Target
.cX
));
6707 // (Äîãîíÿåì/óáåãàåì, ñòðåëÿåì ïî íàïðàâëåíèþ ê öåëè)
6708 // (Åñëè öåëü äàëåêî, òî õâàòèò ñëåäèòü çà íåé)
6709 if Target
.UID
<> 0 then
6711 if not TargetOnScreen(Target
.X
+ Target
.Rect
.X
,
6712 Target
.Y
+ Target
.Rect
.Y
) then
6713 begin // Öåëü ñáåæàëà ñ "ýêðàíà"
6714 if (Healthy() = 3) or ((Healthy() = 2)) then
6715 begin // Åñëè çäîðîâû - äîãîíÿåì
6716 if ((RunDirection() = D_LEFT
) and (Target
.X
> FObj
.X
)) then
6717 SetAIFlag('GORIGHT', '1');
6718 if ((RunDirection() = D_RIGHT
) and (Target
.X
< FObj
.X
)) then
6719 SetAIFlag('GOLEFT', '1');
6722 begin // Åñëè ïîáèòû - çàáûâàåì î öåëè è óáåãàåì
6724 if ((RunDirection() = D_LEFT
) and (Target
.X
< FObj
.X
)) then
6725 SetAIFlag('GORIGHT', '1');
6726 if ((RunDirection() = D_RIGHT
) and (Target
.X
> FObj
.X
)) then
6727 SetAIFlag('GOLEFT', '1');
6731 begin // Öåëü ïîêà íà "ýêðàíå"
6732 // Åñëè öåëü íå çàãîðîæåíà ñòåíîé, òî îòìå÷àåì, êîãäà åå âèäåëè:
6733 if g_TraceVector(x1
, y1
, Target
.cX
, Target
.cY
) then
6734 FLastVisible
:= gTime
;
6735 // Åñëè ðàçíèöà âûñîò íå âåëèêà, òî äîãîíÿåì:
6736 if (Abs(FObj
.Y
-Target
.Y
) <= 128) then
6738 if ((RunDirection() = D_LEFT
) and (Target
.X
> FObj
.X
)) then
6739 SetAIFlag('GORIGHT', '1');
6740 if ((RunDirection() = D_RIGHT
) and (Target
.X
< FObj
.X
)) then
6741 SetAIFlag('GOLEFT', '1');
6745 // Âûáèðàåì óãîë ââåðõ:
6746 if FDirection
= D_LEFT
then
6747 angle
:= ANGLE_LEFTUP
6749 angle
:= ANGLE_RIGHTUP
;
6751 firew
:= Trunc(Cos(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
6752 fireh
:= Trunc(Sin(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
6754 // Åñëè ïðè óãëå ââåðõ ìîæíî ïîïàñòü â ïðèáëèçèòåëüíîå ïîëîæåíèå öåëè:
6755 if g_CollideLine(x1
, y1
, x1
+firew
, y1
+fireh
,
6756 Target
.X
+Target
.Rect
.X
+GetInterval(FDifficult
.DiagPrecision
, 128), //96
6757 Target
.Y
+Target
.Rect
.Y
+GetInterval(FDifficult
.DiagPrecision
, 128),
6758 Target
.Rect
.Width
, Target
.Rect
.Height
) and
6759 g_TraceVector(x1
, y1
, Target
.cX
, Target
.cY
) then
6760 begin // òî íóæíî ñòðåëÿòü ââåðõ
6761 SetAIFlag('NEEDFIRE', '1');
6762 SetAIFlag('NEEDSEEUP', '1');
6765 // Âûáèðàåì óãîë âíèç:
6766 if FDirection
= D_LEFT
then
6767 angle
:= ANGLE_LEFTDOWN
6769 angle
:= ANGLE_RIGHTDOWN
;
6771 firew
:= Trunc(Cos(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
6772 fireh
:= Trunc(Sin(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
6774 // Åñëè ïðè óãëå âíèç ìîæíî ïîïàñòü â ïðèáëèçèòåëüíîå ïîëîæåíèå öåëè:
6775 if g_CollideLine(x1
, y1
, x1
+firew
, y1
+fireh
,
6776 Target
.X
+Target
.Rect
.X
+GetInterval(FDifficult
.DiagPrecision
, 128),
6777 Target
.Y
+Target
.Rect
.Y
+GetInterval(FDifficult
.DiagPrecision
, 128),
6778 Target
.Rect
.Width
, Target
.Rect
.Height
) and
6779 g_TraceVector(x1
, y1
, Target
.cX
, Target
.cY
) then
6780 begin // òî íóæíî ñòðåëÿòü âíèç
6781 SetAIFlag('NEEDFIRE', '1');
6782 SetAIFlag('NEEDSEEDOWN', '1');
6785 // Åñëè öåëü âèäíî è îíà íà òàêîé æå âûñîòå:
6786 if Target
.Visible
and
6787 (y1
+4 < Target
.Y
+Target
.Rect
.Y
+Target
.Rect
.Height
) and
6788 (y1
-4 > Target
.Y
+Target
.Rect
.Y
) then
6790 // Åñëè èäåì â ñòîðîíó öåëè, òî íàäî ñòðåëÿòü:
6791 if ((FDirection
= D_LEFT
) and (Target
.X
< FObj
.X
)) or
6792 ((FDirection
= D_RIGHT
) and (Target
.X
> FObj
.X
)) then
6793 begin // òî íóæíî ñòðåëÿòü âïåðåä
6794 SetAIFlag('NEEDFIRE', '1');
6795 SetAIFlag('NEEDSEEDOWN', '');
6796 SetAIFlag('NEEDSEEUP', '');
6798 // Åñëè öåëü â ïðåäåëàõ "ýêðàíà" è ñëîæíîñòü ïîçâîëÿåò ïðûæêè ñáëèæåíèÿ:
6799 if Abs(FObj
.X
-Target
.X
) < Trunc(gPlayerScreenSize
.X
*0.75) then
6800 if GetRnd(FDifficult
.CloseJump
) then
6801 begin // òî åñëè ïîâåçåò - ïðûãàåì (îñîáåííî, åñëè áëèçêî)
6802 if Abs(FObj
.X
-Target
.X
) < 128 then
6806 if Random(a
) = 0 then
6807 SetAIFlag('NEEDJUMP', '1');
6811 // Åñëè öåëü âñå åùå åñòü:
6812 if Target
.UID
<> 0 then
6813 if gTime
-FLastVisible
> 2000 then // Åñëè âèäåëè äàâíî
6814 Target
.UID
:= 0 // òî çàáûòü öåëü
6815 else // Åñëè âèäåëè íåäàâíî
6816 begin // íî öåëü óáèëè
6817 if Target
.IsPlayer
then
6818 begin // Öåëü - èãðîê
6819 pla
:= g_Player_Get(Target
.UID
);
6820 if (pla
= nil) or (not pla
.Live
) or pla
.NoTarget
or
6821 (pla
.FMegaRulez
[MR_INVIS
] >= gTime
) then
6822 Target
.UID
:= 0; // òî çàáûòü öåëü
6825 begin // Öåëü - ìîíñòð
6826 mon
:= g_Monsters_ByUID(Target
.UID
);
6827 if (mon
= nil) or (not mon
.Live
) then
6828 Target
.UID
:= 0; // òî çàáûòü öåëü
6831 end; // if Target.UID <> 0
6833 FTargetUID
:= Target
.UID
;
6835 // Åñëè âîçìîæíûõ öåëåé íåò:
6836 // (Àòàêà ÷åãî-íèáóäü ñëåâà èëè ñïðàâà)
6837 if targets
= nil then
6838 if GetAIFlag('ATTACKLEFT') <> '' then
6839 begin // Åñëè íóæíî àòàêîâàòü íàëåâî
6840 RemoveAIFlag('ATTACKLEFT');
6842 SetAIFlag('NEEDJUMP', '1');
6844 if RunDirection() = D_RIGHT
then
6845 begin // Èäåì íå â òó ñòîðîíó
6846 if (Healthy() > 1) and GetRnd(FDifficult
.InvisFire
) then
6847 begin // Åñëè çäîðîâû, òî, âîçìîæíî, ñòðåëÿåì áåæèì âëåâî è ñòðåëÿåì
6848 SetAIFlag('NEEDFIRE', '1');
6849 SetAIFlag('GOLEFT', '1');
6853 begin // Èäåì â íóæíóþ ñòîðîíó
6854 if GetRnd(FDifficult
.InvisFire
) then // Âîçìîæíî, ñòðåëÿåì âñëåïóþ
6855 SetAIFlag('NEEDFIRE', '1');
6856 if Healthy() <= 1 then // Ïîáèòû - óáåãàåì
6857 SetAIFlag('GORIGHT', '1');
6861 if GetAIFlag('ATTACKRIGHT') <> '' then
6862 begin // Åñëè íóæíî àòàêîâàòü íàïðàâî
6863 RemoveAIFlag('ATTACKRIGHT');
6865 SetAIFlag('NEEDJUMP', '1');
6867 if RunDirection() = D_LEFT
then
6868 begin // Èäåì íå â òó ñòîðîíó
6869 if (Healthy() > 1) and GetRnd(FDifficult
.InvisFire
) then
6870 begin // Åñëè çäîðîâû, òî, âîçìîæíî, áåæèì âïðàâî è ñòðåëÿåì
6871 SetAIFlag('NEEDFIRE', '1');
6872 SetAIFlag('GORIGHT', '1');
6877 if GetRnd(FDifficult
.InvisFire
) then // Âîçìîæíî, ñòðåëÿåì âñëåïóþ
6878 SetAIFlag('NEEDFIRE', '1');
6879 if Healthy() <= 1 then // Ïîáèòû - óáåãàåì
6880 SetAIFlag('GOLEFT', '1');
6884 //HACK! (does it belongs there?)
6885 RealizeCurrentWeapon();
6887 // Åñëè åñòü âîçìîæíûå öåëè:
6888 // (Ñòðåëÿåì ïî íàïðàâëåíèþ ê öåëÿì)
6889 if (targets
<> nil) and (GetAIFlag('NEEDFIRE') <> '') then
6890 for a
:= 0 to High(targets
) do
6892 // Åñëè ìîæåì ñòðåëÿòü ïî äèàãîíàëè:
6893 if GetRnd(FDifficult
.DiagFire
) then
6895 // Èùåì öåëü ñâåðõó è ñòðåëÿåì, åñëè åñòü:
6896 if FDirection
= D_LEFT
then
6897 angle
:= ANGLE_LEFTUP
6899 angle
:= ANGLE_RIGHTUP
;
6901 firew
:= Trunc(Cos(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
6902 fireh
:= Trunc(Sin(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
6904 if g_CollideLine(x1
, y1
, x1
+firew
, y1
+fireh
,
6905 targets
[a
].X
+targets
[a
].Rect
.X
+GetInterval(FDifficult
.DiagPrecision
, 128),
6906 targets
[a
].Y
+targets
[a
].Rect
.Y
+GetInterval(FDifficult
.DiagPrecision
, 128),
6907 targets
[a
].Rect
.Width
, targets
[a
].Rect
.Height
) and
6908 g_TraceVector(x1
, y1
, targets
[a
].cX
, targets
[a
].cY
) then
6910 SetAIFlag('NEEDFIRE', '1');
6911 SetAIFlag('NEEDSEEUP', '1');
6914 // Èùåì öåëü ñíèçó è ñòðåëÿåì, åñëè åñòü:
6915 if FDirection
= D_LEFT
then
6916 angle
:= ANGLE_LEFTDOWN
6918 angle
:= ANGLE_RIGHTDOWN
;
6920 firew
:= Trunc(Cos(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
6921 fireh
:= Trunc(Sin(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
6923 if g_CollideLine(x1
, y1
, x1
+firew
, y1
+fireh
,
6924 targets
[a
].X
+targets
[a
].Rect
.X
+GetInterval(FDifficult
.DiagPrecision
, 128),
6925 targets
[a
].Y
+targets
[a
].Rect
.Y
+GetInterval(FDifficult
.DiagPrecision
, 128),
6926 targets
[a
].Rect
.Width
, targets
[a
].Rect
.Height
) and
6927 g_TraceVector(x1
, y1
, targets
[a
].cX
, targets
[a
].cY
) then
6929 SetAIFlag('NEEDFIRE', '1');
6930 SetAIFlag('NEEDSEEDOWN', '1');
6934 // Åñëè öåëü "ïåðåä íîñîì", òî ñòðåëÿåì:
6935 if targets
[a
].Line
and targets
[a
].Visible
and
6936 (((FDirection
= D_LEFT
) and (targets
[a
].X
< FObj
.X
)) or
6937 ((FDirection
= D_RIGHT
) and (targets
[a
].X
> FObj
.X
))) then
6939 SetAIFlag('NEEDFIRE', '1');
6944 // Åñëè ëåòèò ïóëÿ, òî, âîçìîæíî, ïîäïðûãèâàåì:
6945 if g_Weapon_Danger(FUID
, FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+PLAYER_RECT
.Y
,
6946 PLAYER_RECT
.Width
, PLAYER_RECT
.Height
,
6947 40+GetInterval(FDifficult
.Cover
, 40)) then
6948 SetAIFlag('NEEDJUMP', '1');
6950 // Åñëè êîí÷èëèñü ïàòîðíû, òî íóæíî ñìåíèòü îðóæèå:
6951 ammo
:= GetAmmoByWeapon(FCurrWeap
);
6952 if ((FCurrWeap
= WEAPON_SHOTGUN2
) and (ammo
< 2)) or
6953 ((FCurrWeap
= WEAPON_BFG
) and (ammo
< 40)) or
6955 SetAIFlag('SELECTWEAPON', '1');
6957 // Åñëè íóæíî ñìåíèòü îðóæèå, òî âûáèðàåì íóæíîå:
6958 if GetAIFlag('SELECTWEAPON') = '1' then
6961 RemoveAIFlag('SELECTWEAPON');
6965 procedure TBot
.Update();
6978 // Ïðîâåðÿåì, îòêëþ÷¸í ëè AI áîòîâ
6979 if (g_debug_BotAIOff
= 1) and (Team
= TEAM_RED
) then
6981 if (g_debug_BotAIOff
= 2) and (Team
= TEAM_BLUE
) then
6983 if g_debug_BotAIOff
= 3 then
6993 RealizeCurrentWeapon();
7000 procedure TBot
.ReleaseKey(Key
: Byte);
7009 function TBot
.KeyPressed(Key
: Word): Boolean;
7011 Result
:= FKeys
[Key
].Pressed
;
7014 function TBot
.GetAIFlag(aName
: String20
): String20
;
7020 aName
:= LowerCase(aName
);
7022 if FAIFlags
<> nil then
7023 for a
:= 0 to High(FAIFlags
) do
7024 if LowerCase(FAIFlags
[a
].Name
) = aName
then
7026 Result
:= FAIFlags
[a
].Value
;
7031 procedure TBot
.RemoveAIFlag(aName
: String20
);
7035 if FAIFlags
= nil then Exit
;
7037 aName
:= LowerCase(aName
);
7039 for a
:= 0 to High(FAIFlags
) do
7040 if LowerCase(FAIFlags
[a
].Name
) = aName
then
7042 if a
<> High(FAIFlags
) then
7043 for b
:= a
to High(FAIFlags
)-1 do
7044 FAIFlags
[b
] := FAIFlags
[b
+1];
7046 SetLength(FAIFlags
, Length(FAIFlags
)-1);
7051 procedure TBot
.SetAIFlag(aName
, fValue
: String20
);
7059 aName
:= LowerCase(aName
);
7061 if FAIFlags
<> nil then
7062 for a
:= 0 to High(FAIFlags
) do
7063 if LowerCase(FAIFlags
[a
].Name
) = aName
then
7069 if ok
then FAIFlags
[a
].Value
:= fValue
7072 SetLength(FAIFlags
, Length(FAIFlags
)+1);
7073 with FAIFlags
[High(FAIFlags
)] do
7081 procedure TBot
.UpdateMove
;
7083 procedure GoLeft(Time
: Word = 1);
7085 ReleaseKey(KEY_LEFT
);
7086 ReleaseKey(KEY_RIGHT
);
7087 PressKey(KEY_LEFT
, Time
);
7088 SetDirection(D_LEFT
);
7091 procedure GoRight(Time
: Word = 1);
7093 ReleaseKey(KEY_LEFT
);
7094 ReleaseKey(KEY_RIGHT
);
7095 PressKey(KEY_RIGHT
, Time
);
7096 SetDirection(D_RIGHT
);
7099 function Rnd(a
: Word): Boolean;
7101 Result
:= Random(a
) = 0;
7104 procedure Turn(Time
: Word = 1200);
7106 if RunDirection() = D_LEFT
then GoRight(Time
) else GoLeft(Time
);
7111 ReleaseKey(KEY_LEFT
);
7112 ReleaseKey(KEY_RIGHT
);
7115 function CanRunLeft(): Boolean;
7117 Result
:= not CollideLevel(-1, 0);
7120 function CanRunRight(): Boolean;
7122 Result
:= not CollideLevel(1, 0);
7125 function CanRun(): Boolean;
7127 if RunDirection() = D_LEFT
then Result
:= CanRunLeft() else Result
:= CanRunRight();
7130 procedure Jump(Time
: Word = 30);
7132 PressKey(KEY_JUMP
, Time
);
7135 function NearHole(): Boolean;
7139 { TODO 5 : Ëåñòíèöû }
7140 sx
:= IfThen(RunDirection() = D_LEFT
, -1, 1);
7141 for x
:= 1 to PLAYER_RECT
.Width
do
7142 if (not StayOnStep(x
*sx
, 0)) and
7143 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
)) and
7144 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
*2)) then
7153 function BorderHole(): Boolean;
7157 { TODO 5 : Ëåñòíèöû }
7158 sx
:= IfThen(RunDirection() = D_LEFT
, -1, 1);
7159 for x
:= 1 to PLAYER_RECT
.Width
do
7160 if (not StayOnStep(x
*sx
, 0)) and
7161 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
)) and
7162 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
*2)) then
7164 for xx
:= x
to x
+32 do
7165 if CollideLevel(xx
*sx
, PLAYER_RECT
.Height
) then
7175 function NearDeepHole(): Boolean;
7181 sx
:= IfThen(RunDirection() = D_LEFT
, -1, 1);
7184 for x
:= 1 to PLAYER_RECT
.Width
do
7185 if (not StayOnStep(x
*sx
, 0)) and
7186 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
)) and
7187 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
*2)) then
7189 while FObj
.Y
+y
*PLAYER_RECT
.Height
< gMapInfo
.Height
do
7191 if CollideLevel(x
*sx
, PLAYER_RECT
.Height
*y
) then Exit
;
7196 end else Result
:= False;
7199 function OverDeepHole(): Boolean;
7206 while FObj
.Y
+y
*PLAYER_RECT
.Height
< gMapInfo
.Height
do
7208 if CollideLevel(0, PLAYER_RECT
.Height
*y
) then Exit
;
7215 function OnGround(): Boolean;
7217 Result
:= StayOnStep(0, 0) or CollideLevel(0, 1);
7220 function OnLadder(): Boolean;
7222 Result
:= FullInStep(0, 0);
7225 function BelowLadder(): Boolean;
7227 Result
:= (FullInStep(IfThen(RunDirection() = D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -PLAYER_RECT
.Height
) and
7228 not CollideLevel(IfThen(RunDirection() = D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -PLAYER_RECT
.Height
)) or
7229 (FullInStep(IfThen(RunDirection() = D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -BOT_MAXJUMP
) and
7230 not CollideLevel(IfThen(RunDirection() = D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -BOT_MAXJUMP
));
7233 function BelowLiftUp(): Boolean;
7235 Result
:= ((FullInLift(IfThen(RunDirection() = D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -PLAYER_RECT
.Height
) = -1) and
7236 not CollideLevel(IfThen(RunDirection() = D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -PLAYER_RECT
.Height
)) or
7237 ((FullInLift(IfThen(RunDirection() = D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -BOT_MAXJUMP
) = -1) and
7238 not CollideLevel(IfThen(RunDirection() = D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -BOT_MAXJUMP
));
7241 function OnTopLift(): Boolean;
7243 Result
:= (FullInLift(0, 0) = -1) and (FullInLift(0, -32) = 0);
7246 function CanJumpOver(): Boolean;
7250 sx
:= IfThen(RunDirection() = D_LEFT
, -1, 1);
7254 if not CollideLevel(sx
, 0) then Exit
;
7256 for y
:= 1 to BOT_MAXJUMP
do
7257 if CollideLevel(0, -y
) then Exit
else
7258 if not CollideLevel(sx
, -y
) then
7265 function CanJumpUp(Dist
: ShortInt): Boolean;
7272 if CollideLevel(Dist
, 0) then Exit
;
7275 for y
:= 0 to BOT_MAXJUMP
do
7276 if CollideLevel(Dist
, -y
) then
7285 for yy
:= y
+1 to BOT_MAXJUMP
do
7286 if not CollideLevel(Dist
, -yy
) then
7295 for y
:= 0 to BOT_MAXJUMP
do
7296 if CollideLevel(0, -y
) then
7304 if y
< yy
then Exit
;
7309 function IsSafeTrigger(): Boolean;
7314 if gTriggers
= nil then
7316 for a
:= 0 to High(gTriggers
) do
7317 if Collide(gTriggers
[a
].X
,
7320 gTriggers
[a
].Height
) and
7321 (gTriggers
[a
].TriggerType
in [TRIGGER_EXIT
, TRIGGER_CLOSEDOOR
,
7322 TRIGGER_CLOSETRAP
, TRIGGER_TRAP
,
7323 TRIGGER_PRESS
, TRIGGER_ON
, TRIGGER_OFF
,
7324 TRIGGER_ONOFF
, TRIGGER_SPAWNMONSTER
,
7325 TRIGGER_DAMAGE
, TRIGGER_SHOT
]) then
7330 // Âîçìîæíî, íàæèìàåì êíîïêó:
7331 if Rnd(16) and IsSafeTrigger() then
7334 // Åñëè ïîä ëèôòîì èëè ñòóïåíüêàìè, òî, âîçìîæíî, ïðûãàåì:
7335 if OnLadder() or ((BelowLadder() or BelowLiftUp()) and Rnd(8)) then
7337 ReleaseKey(KEY_LEFT
);
7338 ReleaseKey(KEY_RIGHT
);
7342 // Èäåì âëåâî, åñëè íàäî áûëî:
7343 if GetAIFlag('GOLEFT') <> '' then
7345 RemoveAIFlag('GOLEFT');
7346 if CanRunLeft() then
7350 // Èäåì âïðàâî, åñëè íàäî áûëî:
7351 if GetAIFlag('GORIGHT') <> '' then
7353 RemoveAIFlag('GORIGHT');
7354 if CanRunRight() then
7358 // Åñëè âûëåòåëè çà êàðòó, òî ïðîáóåì âåðíóòüñÿ:
7359 if FObj
.X
< -32 then
7362 if FObj
.X
+32 > gMapInfo
.Width
then
7365 // Ïðûãàåì, åñëè íàäî áûëî:
7366 if GetAIFlag('NEEDJUMP') <> '' then
7369 RemoveAIFlag('NEEDJUMP');
7372 // Ñìîòðèì ââåðõ, åñëè íàäî áûëî:
7373 if GetAIFlag('NEEDSEEUP') <> '' then
7376 ReleaseKey(KEY_DOWN
);
7377 PressKey(KEY_UP
, 20);
7378 RemoveAIFlag('NEEDSEEUP');
7381 // Ñìîòðèì âíèç, åñëè íàäî áûëî:
7382 if GetAIFlag('NEEDSEEDOWN') <> '' then
7385 ReleaseKey(KEY_DOWN
);
7386 PressKey(KEY_DOWN
, 20);
7387 RemoveAIFlag('NEEDSEEDOWN');
7390 // Åñëè íóæíî áûëî â äûðó è ìû íå íà çåìëå, òî ïîêîðíî ëåòèì:
7391 if GetAIFlag('GOINHOLE') <> '' then
7392 if not OnGround() then
7394 ReleaseKey(KEY_LEFT
);
7395 ReleaseKey(KEY_RIGHT
);
7396 RemoveAIFlag('GOINHOLE');
7397 SetAIFlag('FALLINHOLE', '1');
7400 // Åñëè ïàäàëè è äîñòèãëè çåìëè, òî õâàòèò ïàäàòü:
7401 if GetAIFlag('FALLINHOLE') <> '' then
7403 RemoveAIFlag('FALLINHOLE');
7405 // Åñëè ëåòåëè ïðÿìî è ñåé÷àñ íå íà ëåñòíèöå èëè íà âåðøèíå ëèôòà, òî îòõîäèì â ñòîðîíó:
7406 if not (KeyPressed(KEY_LEFT
) or KeyPressed(KEY_RIGHT
)) then
7407 if GetAIFlag('FALLINHOLE') = '' then
7408 if (not OnLadder()) or (FObj
.Vel
.Y
>= 0) or (OnTopLift()) then
7414 // Åñëè íà çåìëå è ìîæíî ïîäïðûãíóòü, òî, âîçìîæíî, ïðûãàåì:
7416 CanJumpUp(IfThen(RunDirection() = D_LEFT
, -1, 1)*32) and
7420 // Åñëè íà çåìëå è âîçëå äûðû (ãëóáèíà > 2 ðîñòîâ èãðîêà):
7421 if OnGround() and NearHole() then
7422 if NearDeepHole() then // Åñëè ýòî áåçäíà
7424 0..3: Turn(); // Áåæèì îáðàòíî
7425 4: Jump(); // Ïðûãàåì
7426 5: begin // Ïðûãàåì îáðàòíî
7431 else // Ýòî íå áåçäíà è ìû åùå íå ëåòèì òóäà
7432 if GetAIFlag('GOINHOLE') = '' then
7434 0: Turn(); // Íå íóæíî òóäà
7435 1: Jump(); // Âäðóã ïîâåçåò - ïðûãàåì
7436 else // Åñëè ÿìà ñ ãðàíèöåé, òî ïðè ñëó÷àå ìîæíî òóäà ïðûãíóòü
7437 if BorderHole() then
7438 SetAIFlag('GOINHOLE', '1');
7441 // Åñëè íà çåìëå, íî íåêóäà èäòè:
7442 if (not CanRun()) and OnGround() then
7444 // Åñëè ìû íà ëåñòíèöå èëè ìîæíî ïåðåïðûãíóòü, òî ïðûãàåì:
7445 if CanJumpOver() or OnLadder() then
7447 else // èíà÷å ïîïûòàåìñÿ â äðóãóþ ñòîðîíó
7448 if Random(2) = 0 then
7450 if IsSafeTrigger() then
7456 // Îñòàëîñü ìàëî âîçäóõà:
7457 if FAir
< 36 * 2 then
7460 // Âûáèðàåìñÿ èç êèñëîòû, åñëè íåò êîñòþìà, îáîæãëèñü, èëè ìàëî çäîðîâüÿ:
7461 if (FMegaRulez
[MR_SUIT
] < gTime
) and ((FLastHit
= HIT_ACID
) or (Healthy() <= 1)) then
7462 if BodyInAcid(0, 0) then
7466 function TBot
.FullInStep(XInc
, YInc
: Integer): Boolean;
7468 Result
:= g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
,
7469 PLAYER_RECT
.Width
, PLAYER_RECT
.Height
, PANEL_STEP
, False);
7472 {function TBot.NeedItem(Item: Byte): Byte;
7477 procedure TBot
.SelectWeapon(Dist
: Integer);
7481 function HaveAmmo(weapon
: Byte): Boolean;
7484 WEAPON_PISTOL
: Result
:= FAmmo
[A_BULLETS
] >= 1;
7485 WEAPON_SHOTGUN1
: Result
:= FAmmo
[A_SHELLS
] >= 1;
7486 WEAPON_SHOTGUN2
: Result
:= FAmmo
[A_SHELLS
] >= 2;
7487 WEAPON_CHAINGUN
: Result
:= FAmmo
[A_BULLETS
] >= 10;
7488 WEAPON_ROCKETLAUNCHER
: Result
:= FAmmo
[A_ROCKETS
] >= 1;
7489 WEAPON_PLASMA
: Result
:= FAmmo
[A_CELLS
] >= 10;
7490 WEAPON_BFG
: Result
:= FAmmo
[A_CELLS
] >= 40;
7491 WEAPON_SUPERPULEMET
: Result
:= FAmmo
[A_SHELLS
] >= 1;
7492 WEAPON_FLAMETHROWER
: Result
:= FAmmo
[A_FUEL
] >= 1;
7493 else Result
:= True;
7498 if Dist
= -1 then Dist
:= BOT_LONGDIST
;
7500 if Dist
> BOT_LONGDIST
then
7501 begin // Äàëüíèé áîé
7503 if FWeapon
[FDifficult
.WeaponPrior
[a
]] and HaveAmmo(FDifficult
.WeaponPrior
[a
]) then
7505 FSelectedWeapon
:= FDifficult
.WeaponPrior
[a
];
7509 else //if Dist > BOT_UNSAFEDIST then
7510 begin // Áëèæíèé áîé
7512 if FWeapon
[FDifficult
.CloseWeaponPrior
[a
]] and HaveAmmo(FDifficult
.CloseWeaponPrior
[a
]) then
7514 FSelectedWeapon
:= FDifficult
.CloseWeaponPrior
[a
];
7521 if FWeapon[FDifficult.SafeWeaponPrior[a]] and HaveAmmo(FDifficult.SafeWeaponPrior[a]) then
7523 FSelectedWeapon := FDifficult.SafeWeaponPrior[a];
7529 function TBot
.PickItem(ItemType
: Byte; force
: Boolean; var remove
: Boolean): Boolean;
7531 Result
:= inherited PickItem(ItemType
, force
, remove
);
7533 if Result
then SetAIFlag('SELECTWEAPON', '1');
7536 function TBot
.Heal(value
: Word; Soft
: Boolean): Boolean;
7538 Result
:= inherited Heal(value
, Soft
);
7541 function TBot
.Healthy(): Byte;
7543 if FMegaRulez
[MR_INVUL
] >= gTime
then Result
:= 3
7544 else if (FHealth
> 80) or ((FHealth
> 50) and (FArmor
> 20)) then Result
:= 3
7545 else if (FHealth
> 50) then Result
:= 2
7546 else if (FHealth
> 20) then Result
:= 1
7550 function TBot
.TargetOnScreen(TX
, TY
: Integer): Boolean;
7552 Result
:= (Abs(FObj
.X
-TX
) <= Trunc(gPlayerScreenSize
.X
*0.6)) and
7553 (Abs(FObj
.Y
-TY
) <= Trunc(gPlayerScreenSize
.Y
*0.6));
7556 procedure TBot
.OnDamage(Angle
: SmallInt);
7564 if (Angle
= 0) or (Angle
= 180) then
7567 if (g_GetUIDType(FLastSpawnerUID
) = UID_PLAYER
) and
7568 LongBool(gGameSettings
.Options
and GAME_OPTION_BOTVSPLAYER
) then
7570 pla
:= g_Player_Get(FLastSpawnerUID
);
7571 ok
:= not TargetOnScreen(pla
.FObj
.X
+ PLAYER_RECT
.X
,
7572 pla
.FObj
.Y
+ PLAYER_RECT
.Y
);
7575 if (g_GetUIDType(FLastSpawnerUID
) = UID_MONSTER
) and
7576 LongBool(gGameSettings
.Options
and GAME_OPTION_BOTVSMONSTER
) then
7578 mon
:= g_Monsters_ByUID(FLastSpawnerUID
);
7579 ok
:= not TargetOnScreen(mon
.Obj
.X
+ mon
.Obj
.Rect
.X
,
7580 mon
.Obj
.Y
+ mon
.Obj
.Rect
.Y
);
7585 SetAIFlag('ATTACKLEFT', '1')
7587 SetAIFlag('ATTACKRIGHT', '1');
7591 function TBot
.RunDirection(): TDirection
;
7593 if Abs(Vel
.X
) >= 1 then
7595 if Vel
.X
> 0 then Result
:= D_RIGHT
else Result
:= D_LEFT
;
7597 Result
:= FDirection
;
7600 function TBot
.GetRnd(a
: Byte): Boolean;
7602 if a
= 0 then Result
:= False
7603 else if a
= 255 then Result
:= True
7604 else Result
:= Random(256) > 255-a
;
7607 function TBot
.GetInterval(a
: Byte; radius
: SmallInt): SmallInt;
7609 Result
:= Round((255-a
)/255*radius
*(Random(2)-1));
7612 procedure TBot
.SaveState(var Mem
: TBinMemoryWriter
);
7618 inherited SaveState(Mem
);
7620 // Âûáðàííîå îðóæèå:
7621 Mem
.WriteByte(FSelectedWeapon
);
7623 Mem
.WriteWord(FTargetUID
);
7624 // Âðåìÿ ïîòåðè öåëè:
7625 Mem
.WriteDWORD(FLastVisible
);
7626 // Êîëè÷åñòâî ôëàãîâ ÈÈ:
7627 dw
:= Length(FAIFlags
);
7630 for i
:= 0 to Integer(dw
)-1 do
7632 Mem
.WriteString(FAIFlags
[i
].Name
, 20);
7633 Mem
.WriteString(FAIFlags
[i
].Value
, 20);
7635 // Íàñòðîéêè ñëîæíîñòè:
7637 Mem
.WriteMemory(p
, SizeOf(TDifficult
));
7640 procedure TBot
.LoadState(var Mem
: TBinMemoryReader
);
7646 inherited LoadState(Mem
);
7648 // Âûáðàííîå îðóæèå:
7649 Mem
.ReadByte(FSelectedWeapon
);
7651 Mem
.ReadWord(FTargetUID
);
7652 // Âðåìÿ ïîòåðè öåëè:
7653 Mem
.ReadDWORD(FLastVisible
);
7654 // Êîëè÷åñòâî ôëàãîâ ÈÈ:
7656 SetLength(FAIFlags
, dw
);
7658 for i
:= 0 to Integer(dw
)-1 do
7660 Mem
.ReadString(FAIFlags
[i
].Name
);
7661 Mem
.ReadString(FAIFlags
[i
].Value
);
7663 // Íàñòðîéêè ñëîæíîñòè:
7664 Mem
.ReadMemory(p
, dw
);
7665 if dw
<> SizeOf(TDifficult
) then
7667 raise EBinSizeError
.Create('TBot.LoadState: Wrong FDifficult Size');
7669 FDifficult
:= TDifficult(p
^);