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/>.
22 e_graphics
, g_playermodel
, g_basic
, g_textures
,
23 g_weapons
, g_phys
, g_sound
, g_saveload
, MAPSTRUCT
,
73 ANGLE_NONE
= Low(SmallInt);
75 CORPSE_STATE_REMOVEME
= 0;
76 CORPSE_STATE_NORMAL
= 1;
77 CORPSE_STATE_MESS
= 2;
79 PLAYER_RECT
: TRectWH
= (X
:15; Y
:12; Width
:34; Height
:52);
80 PLAYER_RECT_CX
= 15+(34 div 2);
81 PLAYER_RECT_CY
= 12+(52 div 2);
82 PLAYER_CORPSERECT
: TRectWH
= (X
:15; Y
:48; Width
:34; Height
:16);
85 PLAYER_HP_LIMIT
= 200;
87 PLAYER_AP_LIMIT
= 200;
90 PLAYER1_DEF_COLOR
: TRGB
= (R
:64; G
:175; B
:48);
91 PLAYER2_DEF_COLOR
: TRGB
= (R
:96; G
:96; B
:96);
107 TPlayerStatArray
= Array of TPlayerStat
;
109 TPlayerSavedState
= record
115 Ammo
: Array [A_BULLETS
..A_CELLS
] of Word;
116 MaxAmmo
: Array [A_BULLETS
..A_CELLS
] of Word;
117 Weapon
: Array [WEAPON_KASTET
..WEAPON_SUPERPULEMET
] of Boolean;
118 Rulez
: Set of R_ITEM_BACKPACK
..R_BERSERK
;
127 TPlayer
= class (TObject
)
135 FDirection
: TDirection
;
143 FMonsterKills
: Integer;
149 FCanJetpack
: Boolean;
154 FBFGFireCounter
: SmallInt;
155 FLastSpawnerUID
: Word;
159 FSpectatePlayer
: Integer;
161 FSavedState
: TPlayerSavedState
;
163 FModel
: TPlayerModel
;
166 FActionForce
: Boolean;
167 FActionChanged
: Boolean;
169 FFireAngle
: SmallInt;
171 FShellTimer
: Integer;
173 FSawSound
: TPlayableSound
;
174 FSawSoundIdle
: TPlayableSound
;
175 FSawSoundHit
: TPlayableSound
;
176 FSawSoundSelect
: TPlayableSound
;
177 FJetSoundOn
: TPlayableSound
;
178 FJetSoundOff
: TPlayableSound
;
179 FJetSoundFly
: TPlayableSound
;
183 FJustTeleported
: Boolean;
186 function CollideLevel(XInc
, YInc
: Integer): Boolean;
187 function StayOnStep(XInc
, YInc
: Integer): Boolean;
188 function HeadInLiquid(XInc
, YInc
: Integer): Boolean;
189 function BodyInLiquid(XInc
, YInc
: Integer): Boolean;
190 function BodyInAcid(XInc
, YInc
: Integer): Boolean;
191 function FullInLift(XInc
, YInc
: Integer): Integer;
192 {procedure CollideItem();}
193 procedure FlySmoke(Times
: DWORD
= 1);
194 function GetAmmoByWeapon(Weapon
: Byte): Word;
195 procedure SetAction(Action
: Byte; Force
: Boolean = False);
196 procedure OnDamage(Angle
: SmallInt); virtual;
197 function firediry(): Integer;
199 procedure Run(Direction
: TDirection
);
200 procedure NextWeapon();
201 procedure PrevWeapon();
209 FDamageBuffer
: Integer;
211 FAmmo
: Array [A_BULLETS
..A_CELLS
] of Word;
212 FMaxAmmo
: Array [A_BULLETS
..A_CELLS
] of Word;
213 FWeapon
: Array [WEAPON_KASTET
..WEAPON_SUPERPULEMET
] of Boolean;
214 FRulez
: Set of R_ITEM_BACKPACK
..R_BERSERK
;
216 FMegaRulez
: Array [MR_SUIT
..MR_MAX
] of DWORD
;
217 FReloading
: Array [WEAPON_KASTET
..WEAPON_SUPERPULEMET
] of Word;
218 FTime
: Array [T_RESPAWN
..T_FLAGCAP
] of DWORD
;
219 FKeys
: Array [KEY_LEFT
..KEY_CHAT
] of TKeyState
;
221 FPreferredTeam
: Byte;
224 FWantsInGame
: Boolean;
228 FActualModelName
: string;
234 constructor Create(); virtual;
235 destructor Destroy(); override;
236 procedure Respawn(Silent
: Boolean; Force
: Boolean = False); virtual;
237 function GetRespawnPoint(): Byte;
238 procedure PressKey(Key
: Byte; Time
: Word = 1);
239 procedure ReleaseKeys();
240 procedure SetModel(ModelName
: String);
241 procedure SetColor(Color
: TRGB
);
242 procedure SetWeapon(W
: Byte);
243 function IsKeyPressed(K
: Byte): Boolean;
244 function GetKeys(): Byte;
245 function PickItem(ItemType
: Byte; respawn
: Boolean; var remove
: Boolean): Boolean; virtual;
246 function Collide(X
, Y
: Integer; Width
, Height
: Word): Boolean; overload
;
247 function Collide(Panel
: TPanel
): Boolean; overload
;
248 function Collide(X
, Y
: Integer): Boolean; overload
;
249 procedure SetDirection(Direction
: TDirection
);
250 procedure GetSecret();
251 function TeleportTo(X
, Y
: Integer; silent
: Boolean; dir
: Byte): Boolean;
253 procedure Push(vx
, vy
: Integer);
254 procedure ChangeModel(ModelName
: String);
255 procedure SwitchTeam
;
256 procedure ChangeTeam(Team
: Byte);
258 function GetFlag(Flag
: Byte): Boolean;
259 procedure SetFlag(Flag
: Byte);
260 function DropFlag(): Boolean;
261 procedure AllRulez(Health
: Boolean);
262 procedure RestoreHealthArmor();
263 procedure FragCombo();
264 procedure GiveItem(ItemType
: Byte);
265 procedure Damage(value
: Word; SpawnerUID
: Word; vx
, vy
: Integer; t
: Byte); virtual;
266 function Heal(value
: Word; Soft
: Boolean): Boolean; virtual;
267 procedure MakeBloodVector(Count
: Word; VelX
, VelY
: Integer);
268 procedure MakeBloodSimple(Count
: Word);
269 procedure Kill(KillType
: Byte; SpawnerUID
: Word; t
: Byte);
270 procedure Reset(Force
: Boolean);
271 procedure Spectate(NoMove
: Boolean = False);
272 procedure SwitchNoClip
;
273 procedure SoftReset();
274 procedure Draw(); virtual;
275 procedure DrawPain();
276 procedure DrawPickup();
277 procedure DrawRulez();
279 procedure DrawBubble();
281 procedure Update(); virtual;
282 procedure RememberState();
283 procedure RecallState();
284 procedure SaveState(var Mem
: TBinMemoryWriter
); virtual;
285 procedure LoadState(var Mem
: TBinMemoryReader
); virtual;
286 procedure PauseSounds(Enable
: Boolean);
287 procedure NetFire(Wpn
: Byte; X
, Y
, AX
, AY
: Integer; WID
: Integer = -1);
288 procedure DoLerp(Level
: Integer = 2);
289 procedure SetLerp(XTo
, YTo
: Integer);
291 procedure JetpackOff
;
293 property Name
: String read FName write FName
;
294 property Model
: TPlayerModel read FModel
;
295 property Health
: Integer read FHealth write FHealth
;
296 property Lives
: Byte read FLives write FLives
;
297 property Armor
: Integer read FArmor write FArmor
;
298 property Air
: Integer read FAir write FAir
;
299 property JetFuel
: Integer read FJetFuel write FJetFuel
;
300 property Frags
: Integer read FFrags write FFrags
;
301 property Death
: Integer read FDeath write FDeath
;
302 property Kills
: Integer read FKills write FKills
;
303 property CurrWeap
: Byte read FCurrWeap write FCurrWeap
;
304 property MonsterKills
: Integer read FMonsterKills write FMonsterKills
;
305 property Secrets
: Integer read FSecrets
;
306 property GodMode
: Boolean read FGodMode write FGodMode
;
307 property NoTarget
: Boolean read FNoTarget write FNoTarget
;
308 property NoReload
: Boolean read FNoReload write FNoReload
;
309 property Live
: Boolean read FLive write FLive
;
310 property Flag
: Byte read FFlag
;
311 property Team
: Byte read FTeam write FTeam
;
312 property Direction
: TDirection read FDirection
;
313 property GameX
: Integer read FObj
.X write FObj
.X
;
314 property GameY
: Integer read FObj
.Y write FObj
.Y
;
315 property GameVelX
: Integer read FObj
.Vel
.X write FObj
.Vel
.X
;
316 property GameVelY
: Integer read FObj
.Vel
.Y write FObj
.Vel
.Y
;
317 property GameAccelX
: Integer read FObj
.Accel
.X write FObj
.Accel
.X
;
318 property GameAccelY
: Integer read FObj
.Accel
.Y write FObj
.Accel
.Y
;
319 property Vel
: TPoint2i read FObj
.Vel
;
320 property Obj
: TObj read FObj
;
321 property IncCam
: Integer read FIncCam write FIncCam
;
322 property UID
: Word read FUID write FUID
;
323 property JustTeleported
: Boolean read FJustTeleported write FJustTeleported
;
324 property NetTime
: LongWord read FNetTime write FNetTime
;
334 WeaponPrior
: Array [WEAPON_KASTET
..WEAPON_SUPERPULEMET
] of Byte;
335 CloseWeaponPrior
: Array [WEAPON_KASTET
..WEAPON_SUPERPULEMET
] of Byte;
336 //SafeWeaponPrior: Array [WEAPON_KASTET..WEAPON_SUPERPULEMET] of Byte;
344 TBot
= class (TPlayer
)
346 FSelectedWeapon
: Byte;
349 FAIFlags
: Array of TAIFlag
;
350 FDifficult
: TDifficult
;
352 function GetRnd(a
: Byte): Boolean;
353 function GetInterval(a
: Byte; radius
: SmallInt): SmallInt;
354 function RunDirection(): TDirection
;
355 function FullInStep(XInc
, YInc
: Integer): Boolean;
356 //function NeedItem(Item: Byte): Byte;
357 procedure SelectWeapon(Dist
: Integer);
358 procedure SetAIFlag(fName
, fValue
: String20
);
359 function GetAIFlag(fName
: String20
): String20
;
360 procedure RemoveAIFlag(fName
: String20
);
361 function Healthy(): Byte;
362 procedure UpdateMove();
363 procedure UpdateCombat();
364 function KeyPressed(Key
: Word): Boolean;
365 procedure ReleaseKey(Key
: Byte);
366 function TargetOnScreen(TX
, TY
: Integer): Boolean;
367 procedure OnDamage(Angle
: SmallInt); override;
370 procedure Respawn(Silent
: Boolean; Force
: Boolean = False); override;
371 constructor Create(); override;
372 destructor Destroy(); override;
373 procedure Draw(); override;
374 function PickItem(ItemType
: Byte; force
: Boolean; var remove
: Boolean): Boolean; override;
375 function Heal(value
: Word; Soft
: Boolean): Boolean; override;
376 procedure Update(); override;
377 procedure SaveState(var Mem
: TBinMemoryWriter
); override;
378 procedure LoadState(var Mem
: TBinMemoryReader
); override;
400 TCorpse
= class (TObject
)
408 FAnimation
: TAnimation
;
409 FAnimationMask
: TAnimation
;
412 constructor Create(X
, Y
: Integer; ModelName
: String; aMess
: Boolean);
413 destructor Destroy(); override;
414 procedure Damage(Value
: Word; vx
, vy
: Integer);
417 procedure SaveState(var Mem
: TBinMemoryWriter
);
418 procedure LoadState(var Mem
: TBinMemoryReader
);
420 property Obj
: TObj read FObj
;
421 property State
: Byte read FState
;
422 property Mess
: Boolean read FMess
;
425 TTeamStat
= Array [TEAM_RED
..TEAM_BLUE
] of
431 gPlayers
: Array of TPlayer
;
432 gCorpses
: Array of TCorpse
;
433 gGibs
: Array of TGib
;
434 gShells
: Array of TShell
;
435 gTeamStat
: TTeamStat
;
436 gFly
: Boolean = False;
437 gAimLine
: Boolean = False;
438 gChatBubble
: Byte = 0;
442 MAX_RUNVEL
: Integer = 8;
443 VEL_JUMP
: Integer = 10;
444 SHELL_TIMEOUT
: Cardinal = 60000;
446 function Lerp(X
, Y
, Factor
: Integer): Integer;
448 procedure g_Gibs_SetMax(Count
: Word);
449 function g_Gibs_GetMax(): Word;
450 procedure g_Corpses_SetMax(Count
: Word);
451 function g_Corpses_GetMax(): Word;
452 procedure g_Shells_SetMax(Count
: Word);
453 function g_Shells_GetMax(): Word;
455 procedure g_Player_Init();
456 procedure g_Player_Free();
457 function g_Player_Create(ModelName
: String; Color
: TRGB
; Team
: Byte; Bot
: Boolean): Word;
458 function g_Player_CreateFromState(var Mem
: TBinMemoryReader
): Word;
459 procedure g_Player_Remove(UID
: Word);
460 procedure g_Player_ResetTeams();
461 procedure g_Player_UpdateAll();
462 procedure g_Player_DrawAll();
463 procedure g_Player_DrawDebug(p
: TPlayer
);
464 procedure g_Player_DrawHealth();
465 procedure g_Player_RememberAll();
466 procedure g_Player_ResetAll(Force
, Silent
: Boolean);
467 function g_Player_Get(UID
: Word): TPlayer
;
468 function g_Player_GetCount(): Byte;
469 function g_Player_GetStats(): TPlayerStatArray
;
470 function g_Player_ValidName(Name
: String): Boolean;
471 procedure g_Player_CreateCorpse(Player
: TPlayer
);
472 procedure g_Player_CreateGibs(fX
, fY
: Integer; ModelName
: String; fColor
: TRGB
);
473 procedure g_Player_CreateShell(fX
, fY
, dX
, dY
: Integer; T
: Byte);
474 procedure g_Player_UpdatePhysicalObjects();
475 procedure g_Player_DrawCorpses();
476 procedure g_Player_DrawShells();
477 procedure g_Player_RemoveAllCorpses();
478 procedure g_Player_Corpses_SaveState(var Mem
: TBinMemoryWriter
);
479 procedure g_Player_Corpses_LoadState(var Mem
: TBinMemoryReader
);
480 procedure g_Bot_Add(Team
, Difficult
: Byte);
481 procedure g_Bot_AddList(Team
: Byte; lname
: ShortString; num
: Integer = -1);
482 procedure g_Bot_MixNames();
483 procedure g_Bot_RemoveAll();
488 e_log
, g_map
, g_items
, g_console
, SysUtils
, g_gfx
, Math
,
489 g_options
, g_triggers
, g_menu
, MAPDEF
, g_game
,
490 wadreader
, g_main
, g_monsters
, CONFIG
, g_language
, g_net
, g_netmsg
;
500 diag_precision
: Byte;
504 w_prior1
: Array [WEAPON_KASTET
..WEAPON_SUPERPULEMET
] of Byte;
505 w_prior2
: Array [WEAPON_KASTET
..WEAPON_SUPERPULEMET
] of Byte;
506 w_prior3
: Array [WEAPON_KASTET
..WEAPON_SUPERPULEMET
] of Byte;
510 TIME_RESPAWN1
= 1500;
511 TIME_RESPAWN2
= 2000;
512 TIME_RESPAWN3
= 3000;
515 JET_MAX
= 540; // ~30 sec
516 PLAYER_SUIT_TIME
= 30000;
517 PLAYER_INVUL_TIME
= 30000;
518 PLAYER_INVIS_TIME
= 35000;
519 FRAG_COMBO_TIME
= 3000;
523 ANGLE_RIGHTDOWN
= -35;
525 ANGLE_LEFTDOWN
= -145;
526 PLAYER_HEADRECT
: TRectWH
= (X
:24; Y
:12; Width
:20; Height
:12);
527 WEAPONPOINT
: Array [TDirection
] of TPoint
= ((X
:16; Y
:32), (X
:47; Y
:32));
530 BOT_UNSAFEDIST
= 128;
531 TEAMCOLOR
: Array [TEAM_RED
..TEAM_BLUE
] of TRGB
= ((R
:255; G
:0; B
:0),
533 DIFFICULT_EASY
: TDifficult
= (DiagFire
: 32; InvisFire
: 32; DiagPrecision
: 32;
534 FlyPrecision
: 32; Cover
: 32; CloseJump
: 32;
535 WeaponPrior
:(0,0,0,0,0,0,0,0,0,0); CloseWeaponPrior
:(0,0,0,0,0,0,0,0,0,0));
536 DIFFICULT_MEDIUM
: TDifficult
= (DiagFire
: 127; InvisFire
: 127; DiagPrecision
: 127;
537 FlyPrecision
: 127; Cover
: 127; CloseJump
: 127;
538 WeaponPrior
:(0,0,0,0,0,0,0,0,0,0); CloseWeaponPrior
:(0,0,0,0,0,0,0,0,0,0));
539 DIFFICULT_HARD
: TDifficult
= (DiagFire
: 255; InvisFire
: 255; DiagPrecision
: 255;
540 FlyPrecision
: 255; Cover
: 255; CloseJump
: 255;
541 WeaponPrior
:(0,0,0,0,0,0,0,0,0,0); CloseWeaponPrior
:(0,0,0,0,0,0,0,0,0,0));
542 WEAPON_PRIOR1
: Array [WEAPON_KASTET
..WEAPON_SUPERPULEMET
] of Byte =
543 (WEAPON_SUPERPULEMET
, WEAPON_SHOTGUN2
, WEAPON_SHOTGUN1
,
544 WEAPON_CHAINGUN
, WEAPON_PLASMA
, WEAPON_ROCKETLAUNCHER
,
545 WEAPON_BFG
, WEAPON_PISTOL
, WEAPON_SAW
, WEAPON_KASTET
);
546 WEAPON_PRIOR2
: Array [WEAPON_KASTET
..WEAPON_SUPERPULEMET
] of Byte =
547 (WEAPON_SUPERPULEMET
, WEAPON_BFG
, WEAPON_ROCKETLAUNCHER
,
548 WEAPON_SHOTGUN2
, WEAPON_PLASMA
, WEAPON_SHOTGUN1
,
549 WEAPON_CHAINGUN
, WEAPON_PISTOL
, WEAPON_SAW
, WEAPON_KASTET
);
550 //WEAPON_PRIOR3: Array [WEAPON_KASTET..WEAPON_SUPERPULEMET] of Byte =
551 // (WEAPON_SUPERPULEMET, WEAPON_BFG, WEAPON_PLASMA,
552 // WEAPON_SHOTGUN2, WEAPON_CHAINGUN, WEAPON_SHOTGUN1,
553 // WEAPON_SAW, WEAPON_ROCKETLAUNCHER, WEAPON_PISTOL, WEAPON_KASTET);
554 WEAPON_RELOAD
: Array [WEAPON_KASTET
..WEAPON_SUPERPULEMET
] of Byte =
555 (5, 2, 6, 18, 36, 2, 12, 2, 14, 2);
557 PLAYER_SIGNATURE
= $52594C50; // 'PLYR'
558 CORPSE_SIGNATURE
= $50524F43; // 'CORP'
560 BOTNAMES_FILENAME
= 'botnames.txt';
561 BOTLIST_FILENAME
= 'botlist.txt';
565 MaxCorpses
: Word = 20;
566 MaxShells
: Word = 300;
567 CurrentGib
: Integer = 0;
568 CurrentShell
: Integer = 0;
569 BotNames
: Array of String;
570 BotList
: Array of TBotProfile
;
572 function Lerp(X
, Y
, Factor
: Integer): Integer;
574 Result
:= X
+ ((Y
- X
) div Factor
);
577 function SameTeam(UID1
, UID2
: Word): Boolean;
581 if (UID1
> UID_MAX_PLAYER
) or (UID1
<= UID_MAX_GAME
) or
582 (UID2
> UID_MAX_PLAYER
) or (UID2
<= UID_MAX_GAME
) then Exit
;
584 if (g_Player_Get(UID1
) = nil) or (g_Player_Get(UID2
) = nil) then Exit
;
586 if ((g_Player_Get(UID1
).Team
= TEAM_NONE
) or
587 (g_Player_Get(UID2
).Team
= TEAM_NONE
)) then Exit
;
589 Result
:= g_Player_Get(UID1
).FTeam
= g_Player_Get(UID2
).FTeam
;
592 procedure g_Gibs_SetMax(Count
: Word);
595 SetLength(gGibs
, Count
);
597 if CurrentGib
>= Count
then
601 function g_Gibs_GetMax(): Word;
606 procedure g_Shells_SetMax(Count
: Word);
609 SetLength(gShells
, Count
);
611 if CurrentShell
>= Count
then
615 function g_Shells_GetMax(): Word;
621 procedure g_Corpses_SetMax(Count
: Word);
624 SetLength(gCorpses
, Count
);
627 function g_Corpses_GetMax(): Word;
629 Result
:= MaxCorpses
;
632 function g_Player_Create(ModelName
: String; Color
: TRGB
; Team
: Byte; Bot
: Boolean): Word;
642 // Åñòü ëè ìåñòî â gPlayers:
643 if gPlayers
<> nil then
644 for a
:= 0 to High(gPlayers
) do
645 if gPlayers
[a
] = nil then
651 // Íåò ìåñòà - ðàñøèðÿåì gPlayers:
654 SetLength(gPlayers
, Length(gPlayers
)+1);
658 // Ñîçäàåì îáúåêò èãðîêà:
660 gPlayers
[a
] := TBot
.Create()
662 gPlayers
[a
] := TPlayer
.Create();
665 gPlayers
[a
].FActualModelName
:= ModelName
;
666 gPlayers
[a
].SetModel(ModelName
);
668 // Íåò ìîäåëè - ñîçäàíèå íå âîçìîæíî:
669 if gPlayers
[a
].FModel
= nil then
673 g_FatalError(Format(_lc
[I_GAME_ERROR_MODEL
], [ModelName
]));
677 if not (Team
in [TEAM_RED
, TEAM_BLUE
]) then
678 if Random(2) = 0 then
682 gPlayers
[a
].FPreferredTeam
:= Team
;
684 case gGameSettings
.GameMode
of
685 GM_DM
: gPlayers
[a
].FTeam
:= TEAM_NONE
;
687 GM_CTF
: gPlayers
[a
].FTeam
:= gPlayers
[a
].FPreferredTeam
;
689 GM_COOP
: gPlayers
[a
].FTeam
:= TEAM_COOP
;
692 // Åñëè êîìàíäíàÿ èãðà - êðàñèì ìîäåëü â öâåò êîìàíäû:
693 gPlayers
[a
].FColor
:= Color
;
694 if gPlayers
[a
].FTeam
in [TEAM_RED
, TEAM_BLUE
] then
695 gPlayers
[a
].FModel
.Color
:= TEAMCOLOR
[gPlayers
[a
].FTeam
]
697 gPlayers
[a
].FModel
.Color
:= Color
;
699 gPlayers
[a
].FUID
:= g_CreateUID(UID_PLAYER
);
700 gPlayers
[a
].FLive
:= False;
702 Result
:= gPlayers
[a
].FUID
;
705 function g_Player_CreateFromState(var Mem
: TBinMemoryReader
): Word;
718 if sig
<> PLAYER_SIGNATURE
then // 'PLYR'
720 raise EBinSizeError
.Create('g_Player_CreateFromState: Wrong Player Signature');
724 Mem
.ReadBoolean(Bot
);
729 // Åñòü ëè ìåñòî â gPlayers:
730 if gPlayers
<> nil then
731 for a
:= 0 to High(gPlayers
) do
732 if gPlayers
[a
] = nil then
738 // Íåò ìåñòà - ðàñøèðÿåì gPlayers:
741 SetLength(gPlayers
, Length(gPlayers
)+1);
745 // Ñîçäàåì îáúåêò èãðîêà:
747 gPlayers
[a
] := TBot
.Create()
749 gPlayers
[a
] := TPlayer
.Create();
750 gPlayers
[a
].FIamBot
:= Bot
;
751 gPlayers
[a
].FPhysics
:= True;
754 Mem
.ReadWord(gPlayers
[a
].FUID
);
756 Mem
.ReadString(gPlayers
[a
].FName
);
758 Mem
.ReadByte(gPlayers
[a
].FTeam
);
759 gPlayers
[a
].FPreferredTeam
:= gPlayers
[a
].FTeam
;
761 Mem
.ReadBoolean(gPlayers
[a
].FLive
);
762 // Èçðàñõîäîâàë ëè âñå æèçíè:
763 Mem
.ReadBoolean(gPlayers
[a
].FNoRespawn
);
767 gPlayers
[a
].FDirection
:= D_LEFT
769 gPlayers
[a
].FDirection
:= D_RIGHT
;
771 Mem
.ReadInt(gPlayers
[a
].FHealth
);
773 Mem
.ReadByte(gPlayers
[a
].FLives
);
775 Mem
.ReadInt(gPlayers
[a
].FArmor
);
777 Mem
.ReadInt(gPlayers
[a
].FAir
);
779 Mem
.ReadInt(gPlayers
[a
].FJetFuel
);
781 Mem
.ReadInt(gPlayers
[a
].FPain
);
783 Mem
.ReadInt(gPlayers
[a
].FKills
);
785 Mem
.ReadInt(gPlayers
[a
].FMonsterKills
);
787 Mem
.ReadInt(gPlayers
[a
].FFrags
);
789 Mem
.ReadByte(gPlayers
[a
].FFragCombo
);
790 // Âðåìÿ ïîñëåäíåãî ôðàãà:
791 Mem
.ReadDWORD(gPlayers
[a
].FLastFrag
);
793 Mem
.ReadInt(gPlayers
[a
].FDeath
);
795 Mem
.ReadByte(gPlayers
[a
].FFlag
);
797 Mem
.ReadInt(gPlayers
[a
].FSecrets
);
799 Mem
.ReadByte(gPlayers
[a
].FCurrWeap
);
800 // Âðåìÿ çàðÿäêè BFG:
801 Mem
.ReadSmallInt(gPlayers
[a
].FBFGFireCounter
);
803 Mem
.ReadInt(gPlayers
[a
].FDamageBuffer
);
804 // Ïîñëåäíèé óäàðèâøèé:
805 Mem
.ReadWord(gPlayers
[a
].FLastSpawnerUID
);
806 // Òèï ïîñëåäíåãî ïîëó÷åííîãî óðîíà:
807 Mem
.ReadByte(gPlayers
[a
].FLastHit
);
809 Obj_LoadState(@gPlayers
[a
].FObj
, Mem
);
810 // Òåêóùåå êîëè÷åñòâî ïàòðîíîâ:
811 for i
:= A_BULLETS
to A_CELLS
do
812 Mem
.ReadWord(gPlayers
[a
].FAmmo
[i
]);
813 // Ìàêñèìàëüíîå êîëè÷åñòâî ïàòðîíîâ:
814 for i
:= A_BULLETS
to A_CELLS
do
815 Mem
.ReadWord(gPlayers
[a
].FMaxAmmo
[i
]);
817 for i
:= WEAPON_KASTET
to WEAPON_SUPERPULEMET
do
818 Mem
.ReadBoolean(gPlayers
[a
].FWeapon
[i
]);
819 // Âðåìÿ ïåðåçàðÿäêè îðóæèÿ:
820 for i
:= WEAPON_KASTET
to WEAPON_SUPERPULEMET
do
821 Mem
.ReadWord(gPlayers
[a
].FReloading
[i
]);
825 Include(gPlayers
[a
].FRulez
, R_ITEM_BACKPACK
);
826 // Íàëè÷èå êðàñíîãî êëþ÷à:
829 Include(gPlayers
[a
].FRulez
, R_KEY_RED
);
830 // Íàëè÷èå çåëåíîãî êëþ÷à:
833 Include(gPlayers
[a
].FRulez
, R_KEY_GREEN
);
834 // Íàëè÷èå ñèíåãî êëþ÷à:
837 Include(gPlayers
[a
].FRulez
, R_KEY_BLUE
);
841 Include(gPlayers
[a
].FRulez
, R_BERSERK
);
842 // Âðåìÿ äåéñòâèÿ ñïåöèàëüíûõ ïðåäìåòîâ:
843 for i
:= MR_SUIT
to MR_MAX
do
844 Mem
.ReadDWORD(gPlayers
[a
].FMegaRulez
[i
]);
845 // Âðåìÿ äî ïîâòîðíîãî ðåñïàóíà, ñìåíû îðóæèÿ, èñîëüçîâàíèÿ, çàõâàòà ôëàãà:
846 for i
:= T_RESPAWN
to T_FLAGCAP
do
847 Mem
.ReadDWORD(gPlayers
[a
].FTime
[i
]);
850 Mem
.ReadString(gPlayers
[a
].FActualModelName
);
852 Mem
.ReadByte(gPlayers
[a
].FColor
.R
);
853 Mem
.ReadByte(gPlayers
[a
].FColor
.G
);
854 Mem
.ReadByte(gPlayers
[a
].FColor
.B
);
855 // Îáíîâëÿåì ìîäåëü èãðîêà:
856 gPlayers
[a
].SetModel(gPlayers
[a
].FActualModelName
);
858 // Íåò ìîäåëè - ñîçäàíèå íå âîçìîæíî:
859 if gPlayers
[a
].FModel
= nil then
863 g_FatalError(Format(_lc
[I_GAME_ERROR_MODEL
], [gPlayers
[a
].FActualModelName
]));
867 // Åñëè êîìàíäíàÿ èãðà - êðàñèì ìîäåëü â öâåò êîìàíäû:
868 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
869 gPlayers
[a
].FModel
.Color
:= TEAMCOLOR
[gPlayers
[a
].FTeam
]
871 gPlayers
[a
].FModel
.Color
:= gPlayers
[a
].FColor
;
873 Result
:= gPlayers
[a
].FUID
;
876 procedure g_Player_ResetTeams();
880 if g_Game_IsClient
then
882 if gPlayers
= nil then
884 for a
:= Low(gPlayers
) to High(gPlayers
) do
885 if gPlayers
[a
] <> nil then
886 case gGameSettings
.GameMode
of
888 gPlayers
[a
].ChangeTeam(TEAM_NONE
);
890 if not (gPlayers
[a
].Team
in [TEAM_RED
, TEAM_BLUE
]) then
891 if gPlayers
[a
].FPreferredTeam
in [TEAM_RED
, TEAM_BLUE
] then
892 gPlayers
[a
].ChangeTeam(gPlayers
[a
].FPreferredTeam
)
895 gPlayers
[a
].ChangeTeam(TEAM_RED
)
897 gPlayers
[a
].ChangeTeam(TEAM_BLUE
);
900 gPlayers
[a
].ChangeTeam(TEAM_COOP
);
904 procedure g_Bot_Add(Team
, Difficult
: Byte);
907 _name
, _model
: String;
910 if not g_Game_IsServer
then Exit
;
912 // Ñïèñîê íàçâàíèé ìîäåëåé:
913 m
:= g_PlayerModel_GetNames();
918 if (gGameSettings
.GameType
= GT_SINGLE
) or (gGameSettings
.GameMode
= GM_COOP
) then
919 Team
:= TEAM_COOP
// COOP
921 if gGameSettings
.GameMode
= GM_DM
then
922 Team
:= TEAM_NONE
// DM
924 if Team
= TEAM_NONE
then // CTF / TDM
926 // Àâòîáàëàíñ êîìàíä:
930 for a
:= 0 to High(gPlayers
) do
931 if gPlayers
[a
] <> nil then
933 if gPlayers
[a
].Team
= TEAM_RED
then
936 if gPlayers
[a
].Team
= TEAM_BLUE
then
946 if Random(2) = 0 then
952 // Âûáèðàåì áîòó èìÿ:
954 if BotNames
<> nil then
955 for a
:= 0 to High(BotNames
) do
956 if g_Player_ValidName(BotNames
[a
]) then
958 _name
:= BotNames
[a
];
962 // Èìåíè íåò, çàäàåì ñëó÷àéíîå:
965 _name
:= Format('DFBOT%.2d', [Random(100)]);
966 until g_Player_ValidName(_name
);
968 // Âûáèðàåì ñëó÷àéíóþ ìîäåëü:
969 _model
:= m
[Random(Length(m
))];
972 with g_Player_Get(g_Player_Create(_model
,
973 _RGB(Min(Random(9)*32, 255),
974 Min(Random(9)*32, 255),
975 Min(Random(9)*32, 255)),
976 Team
, True)) as TBot
do
981 1: FDifficult
:= DIFFICULT_EASY
;
982 2: FDifficult
:= DIFFICULT_MEDIUM
;
983 else FDifficult
:= DIFFICULT_HARD
;
986 for a
:= WEAPON_KASTET
to WEAPON_SUPERPULEMET
do
988 FDifficult
.WeaponPrior
[a
] := WEAPON_PRIOR1
[a
];
989 FDifficult
.CloseWeaponPrior
[a
] := WEAPON_PRIOR2
[a
];
990 //FDifficult.SafeWeaponPrior[a] := WEAPON_PRIOR3[a];
993 g_Console_Add(Format(_lc
[I_PLAYER_JOIN
], [Name
]), True);
995 if g_Game_IsNet
then MH_SEND_PlayerCreate(UID
);
996 if g_Game_IsServer
and (gGameSettings
.MaxLives
> 0) then
1001 procedure g_Bot_AddList(Team
: Byte; lName
: ShortString; num
: Integer = -1);
1004 _name
, _model
: String;
1007 if not g_Game_IsServer
then Exit
;
1009 // Ñïèñîê íàçâàíèé ìîäåëåé:
1010 m
:= g_PlayerModel_GetNames();
1015 if (gGameSettings
.GameType
= GT_SINGLE
) or (gGameSettings
.GameMode
= GM_COOP
) then
1016 Team
:= TEAM_COOP
// COOP
1018 if gGameSettings
.GameMode
= GM_DM
then
1019 Team
:= TEAM_NONE
// DM
1021 if Team
= TEAM_NONE
then
1022 Team
:= BotList
[num
].team
; // CTF / TDM
1024 // Âûáèðàåì íàñòðîéêè áîòà èç ñïèñêà ïî íîìåðó èëè èìåíè:
1025 lName
:= AnsiLowerCase(lName
);
1026 if (num
< 0) or (num
> Length(BotList
)-1) then
1028 if (num
= -1) and (lName
<> '') and (BotList
<> nil) then
1029 for a
:= 0 to High(BotList
) do
1030 if AnsiLowerCase(BotList
[a
].name
) = lName
then
1039 _name
:= BotList
[num
].name
;
1040 // Çàíÿòî - âûáèðàåì ñëó÷àéíîå:
1041 if not g_Player_ValidName(_name
) then
1043 _name
:= Format('DFBOT%.2d', [Random(100)]);
1044 until g_Player_ValidName(_name
);
1047 _model
:= BotList
[num
].model
;
1048 // Íåò òàêîé - âûáèðàåì ñëó÷àéíóþ:
1049 if not InSArray(_model
, m
) then
1050 _model
:= m
[Random(Length(m
))];
1053 with g_Player_Get(g_Player_Create(_model
, BotList
[num
].color
, Team
, True)) as TBot
do
1057 FDifficult
.DiagFire
:= BotList
[num
].diag_fire
;
1058 FDifficult
.InvisFire
:= BotList
[num
].invis_fire
;
1059 FDifficult
.DiagPrecision
:= BotList
[num
].diag_precision
;
1060 FDifficult
.FlyPrecision
:= BotList
[num
].fly_precision
;
1061 FDifficult
.Cover
:= BotList
[num
].cover
;
1062 FDifficult
.CloseJump
:= BotList
[num
].close_jump
;
1064 for a
:= WEAPON_KASTET
to WEAPON_SUPERPULEMET
do
1066 FDifficult
.WeaponPrior
[a
] := BotList
[num
].w_prior1
[a
];
1067 FDifficult
.CloseWeaponPrior
[a
] := BotList
[num
].w_prior2
[a
];
1068 //FDifficult.SafeWeaponPrior[a] := BotList[num].w_prior3[a];
1071 g_Console_Add(Format(_lc
[I_PLAYER_JOIN
], [Name
]), True);
1073 if g_Game_IsNet
then MH_SEND_PlayerCreate(UID
);
1077 procedure g_Bot_RemoveAll();
1081 if not g_Game_IsServer
then Exit
;
1082 if gPlayers
= nil then Exit
;
1084 for a
:= 0 to High(gPlayers
) do
1085 if gPlayers
[a
] <> nil then
1086 if gPlayers
[a
] is TBot
then
1088 gPlayers
[a
].Lives
:= 0;
1089 gPlayers
[a
].Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
1090 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [gPlayers
[a
].Name
]), True);
1091 g_Player_Remove(gPlayers
[a
].FUID
);
1097 procedure g_Bot_MixNames();
1102 if BotNames
<> nil then
1103 for a
:= 0 to High(BotNames
) do
1105 b
:= Random(Length(BotNames
));
1107 Botnames
[a
] := BotNames
[b
];
1112 procedure g_Player_Remove(UID
: Word);
1116 if gPlayers
= nil then Exit
;
1118 if g_Game_IsServer
and g_Game_IsNet
then
1119 MH_SEND_PlayerDelete(UID
);
1121 for i
:= 0 to High(gPlayers
) do
1122 if gPlayers
[i
] <> nil then
1123 if gPlayers
[i
].FUID
= UID
then
1125 if gPlayers
[i
] is TPlayer
then
1126 TPlayer(gPlayers
[i
]).Free()
1128 TBot(gPlayers
[i
]).Free();
1134 procedure g_Player_Init();
1144 if not FileExists(DataDir
+ BOTNAMES_FILENAME
) then
1147 // ×èòàåì âîçìîæíûå èìåíà áîòîâ èç ôàéëà:
1148 AssignFile(F
, DataDir
+ BOTNAMES_FILENAME
);
1159 SetLength(BotNames
, Length(BotNames
)+1);
1160 BotNames
[High(BotNames
)] := s
;
1168 // ×èòàåì ôàéë ñ ïàðàìåòðàìè áîòîâ:
1169 config
:= TConfig
.CreateFile(DataDir
+ BOTLIST_FILENAME
);
1173 while config
.SectionExists(IntToStr(a
)) do
1175 SetLength(BotList
, Length(BotList
)+1);
1177 with BotList
[High(BotList
)] do
1180 name
:= config
.ReadStr(IntToStr(a
), 'name', '');
1182 model
:= config
.ReadStr(IntToStr(a
), 'model', '');
1184 if config
.ReadStr(IntToStr(a
), 'team', 'red') = 'red' then
1189 sa
:= parse(config
.ReadStr(IntToStr(a
), 'color', ''));
1190 color
.R
:= StrToIntDef(sa
[0], 0);
1191 color
.G
:= StrToIntDef(sa
[1], 0);
1192 color
.B
:= StrToIntDef(sa
[2], 0);
1193 // Âåðîÿòíîñòü ñòðåëüáû ïîä óãëîì:
1194 diag_fire
:= config
.ReadInt(IntToStr(a
), 'diag_fire', 0);
1195 // Âåðîÿòíîñòü îòâåòíîãî îãíÿ ïî íåâèäèìîìó ñîïåðíèêó:
1196 invis_fire
:= config
.ReadInt(IntToStr(a
), 'invis_fire', 0);
1197 // Òî÷íîñòü ñòðåëüáû ïîä óãëîì:
1198 diag_precision
:= config
.ReadInt(IntToStr(a
), 'diag_precision', 0);
1199 // Òî÷íîñòü ñòðåëüáû â ïîëåòå:
1200 fly_precision
:= config
.ReadInt(IntToStr(a
), 'fly_precision', 0);
1201 // Òî÷íîñòü óêëîíåíèÿ îò ñíàðÿäîâ:
1202 cover
:= config
.ReadInt(IntToStr(a
), 'cover', 0);
1203 // Âåðîÿòíîñòü ïðûæêà ïðè ïðèáëèæåíèè ñîïåðíèêà:
1204 close_jump
:= config
.ReadInt(IntToStr(a
), 'close_jump', 0);
1205 // Ïðèîðèòåòû îðóæèÿ äëÿ äàëüíåãî áîÿ:
1206 sa
:= parse(config
.ReadStr(IntToStr(a
), 'w_prior1', ''));
1207 if Length(sa
) = 10 then
1209 w_prior1
[b
] := EnsureRange(StrToInt(sa
[b
]), 0, 9);
1210 // Ïðèîðèòåòû îðóæèÿ äëÿ áëèæíåãî áîÿ:
1211 sa
:= parse(config
.ReadStr(IntToStr(a
), 'w_prior2', ''));
1212 if Length(sa
) = 10 then
1214 w_prior2
[b
] := EnsureRange(StrToInt(sa
[b
]), 0, 9);
1216 {sa := parse(config.ReadStr(IntToStr(a), 'w_prior3', ''));
1217 if Length(sa) = 10 then
1219 w_prior3[b] := EnsureRange(StrToInt(sa[b]), 0, 9);}
1228 procedure g_Player_Free();
1232 if gPlayers
<> nil then
1234 for i
:= 0 to High(gPlayers
) do
1235 if gPlayers
[i
] <> nil then
1237 if gPlayers
[i
] is TPlayer
then
1238 TPlayer(gPlayers
[i
]).Free()
1240 TBot(gPlayers
[i
]).Free();
1251 procedure g_Player_UpdateAll();
1255 if gPlayers
= nil then Exit
;
1257 for i
:= 0 to High(gPlayers
) do
1258 if gPlayers
[i
] <> nil then
1259 if gPlayers
[i
] is TPlayer
then gPlayers
[i
].Update()
1260 else TBot(gPlayers
[i
]).Update();
1263 procedure g_Player_DrawAll();
1267 if gPlayers
= nil then Exit
;
1269 for i
:= 0 to High(gPlayers
) do
1270 if gPlayers
[i
] <> nil then
1271 if gPlayers
[i
] is TPlayer
then gPlayers
[i
].Draw()
1272 else TBot(gPlayers
[i
]).Draw();
1275 procedure g_Player_DrawDebug(p
: TPlayer
);
1279 if p
= nil then Exit
;
1280 if (@p
.FObj
) = nil then Exit
;
1282 e_TextureFontGetSize(gStdFont
, fW
, fH
);
1284 e_TextureFontPrint(0, 0 , 'Pos X: ' + IntToStr(p
.FObj
.X
), gStdFont
);
1285 e_TextureFontPrint(0, fH
, 'Pos Y: ' + IntToStr(p
.FObj
.Y
), gStdFont
);
1286 e_TextureFontPrint(0, fH
* 2, 'Vel X: ' + IntToStr(p
.FObj
.Vel
.X
), gStdFont
);
1287 e_TextureFontPrint(0, fH
* 3, 'Vel Y: ' + IntToStr(p
.FObj
.Vel
.Y
), gStdFont
);
1288 e_TextureFontPrint(0, fH
* 4, 'Acc X: ' + IntToStr(p
.FObj
.Accel
.X
), gStdFont
);
1289 e_TextureFontPrint(0, fH
* 5, 'Acc Y: ' + IntToStr(p
.FObj
.Accel
.Y
), gStdFont
);
1292 procedure g_Player_DrawHealth();
1297 if gPlayers
= nil then Exit
;
1298 e_TextureFontGetSize(gStdFont
, fW
, fH
);
1300 for i
:= 0 to High(gPlayers
) do
1301 if gPlayers
[i
] <> nil then
1303 e_TextureFontPrint(gPlayers
[i
].FObj
.X
+ gPlayers
[i
].FObj
.Rect
.X
,
1304 gPlayers
[i
].FObj
.Y
+ gPlayers
[i
].FObj
.Rect
.Y
+ gPlayers
[i
].FObj
.Rect
.Height
- fH
* 2,
1305 IntToStr(gPlayers
[i
].FHealth
), gStdFont
);
1306 e_TextureFontPrint(gPlayers
[i
].FObj
.X
+ gPlayers
[i
].FObj
.Rect
.X
,
1307 gPlayers
[i
].FObj
.Y
+ gPlayers
[i
].FObj
.Rect
.Y
+ gPlayers
[i
].FObj
.Rect
.Height
- fH
,
1308 IntToStr(gPlayers
[i
].FArmor
), gStdFont
);
1312 function g_Player_Get(UID
: Word): TPlayer
;
1318 if gPlayers
= nil then
1321 for a
:= 0 to High(gPlayers
) do
1322 if gPlayers
[a
] <> nil then
1323 if gPlayers
[a
].FUID
= UID
then
1325 Result
:= gPlayers
[a
];
1330 function g_Player_GetCount(): Byte;
1336 if gPlayers
= nil then
1339 for a
:= 0 to High(gPlayers
) do
1340 if gPlayers
[a
] <> nil then
1341 Result
:= Result
+ 1;
1344 function g_Player_GetStats(): TPlayerStatArray
;
1350 if gPlayers
= nil then Exit
;
1352 for a
:= 0 to High(gPlayers
) do
1353 if gPlayers
[a
] <> nil then
1355 SetLength(Result
, Length(Result
)+1);
1356 with Result
[High(Result
)] do
1358 Ping
:= gPlayers
[a
].FPing
;
1359 Loss
:= gPlayers
[a
].FLoss
;
1360 Name
:= gPlayers
[a
].FName
;
1361 Team
:= gPlayers
[a
].FTeam
;
1362 Frags
:= gPlayers
[a
].FFrags
;
1363 Deaths
:= gPlayers
[a
].FDeath
;
1364 Kills
:= gPlayers
[a
].FKills
;
1365 Color
:= gPlayers
[a
].FModel
.Color
;
1366 Lives
:= gPlayers
[a
].FLives
;
1367 Spectator
:= gPlayers
[a
].FSpectator
;
1372 procedure g_Player_RememberAll
;
1376 for i
:= Low(gPlayers
) to High(gPlayers
) do
1377 if (gPlayers
[i
] <> nil) and gPlayers
[i
].Live
then
1378 gPlayers
[i
].RememberState
;
1381 procedure g_Player_ResetAll(Force
, Silent
: Boolean);
1385 gTeamStat
[TEAM_RED
].Goals
:= 0;
1386 gTeamStat
[TEAM_BLUE
].Goals
:= 0;
1388 if gPlayers
<> nil then
1389 for i
:= 0 to High(gPlayers
) do
1390 if gPlayers
[i
] <> nil then
1392 gPlayers
[i
].Reset(Force
);
1394 if gPlayers
[i
] is TPlayer
then
1396 if (not gPlayers
[i
].FSpectator
) or gPlayers
[i
].FWantsInGame
then
1397 gPlayers
[i
].Respawn(Silent
)
1399 gPlayers
[i
].Spectate();
1402 TBot(gPlayers
[i
]).Respawn(Silent
);
1406 procedure g_Player_CreateCorpse(Player
: TPlayer
);
1413 if Player
.FObj
.Y
>= gMapInfo
.Height
+128 then
1418 if (FHealth
>= -50) or (gGibsCount
= 0) then
1420 if (gCorpses
= nil) or (Length(gCorpses
) = 0) then
1424 for find_id
:= 0 to High(gCorpses
) do
1425 if gCorpses
[find_id
] = nil then
1432 find_id
:= Random(Length(gCorpses
));
1434 gCorpses
[find_id
] := TCorpse
.Create(FObj
.X
, FObj
.Y
, FModel
.Name
, FHealth
< -20);
1435 gCorpses
[find_id
].FColor
:= FModel
.Color
;
1436 gCorpses
[find_id
].FObj
.Vel
:= FObj
.Vel
;
1437 gCorpses
[find_id
].FObj
.Accel
:= FObj
.Accel
;
1440 g_Player_CreateGibs(FObj
.X
+ PLAYER_RECT_CX
,
1441 FObj
.Y
+ PLAYER_RECT_CY
,
1442 FModel
.Name
, FModel
.Color
);
1446 procedure g_Player_CreateShell(fX
, fY
, dX
, dY
: Integer; T
: Byte);
1450 if (gShells
= nil) or (Length(gShells
) = 0) then
1453 with gShells
[CurrentShell
] do
1459 if T
= SHELL_BULLET
then
1461 if g_Texture_Get('TEXTURE_SHELL_BULLET', SID
) then
1465 Obj
.Rect
.Width
:= 4;
1466 Obj
.Rect
.Height
:= 2;
1470 if g_Texture_Get('TEXTURE_SHELL_SHELL', SID
) then
1474 Obj
.Rect
.Width
:= 7;
1475 Obj
.Rect
.Height
:= 3;
1481 g_Obj_Push(@Obj
, dX
+ Random(4)-Random(4), dY
-Random(4));
1482 RAngle
:= Random(360);
1483 Timeout
:= gTime
+ SHELL_TIMEOUT
;
1485 if CurrentShell
>= High(gShells
) then
1492 procedure g_Player_CreateGibs(fX
, fY
: Integer; ModelName
: string; fColor
: TRGB
);
1495 GibsArray
: TGibsArray
;
1497 if (gGibs
= nil) or (Length(gGibs
) = 0) then
1499 if not g_PlayerModel_GetGibs(ModelName
, GibsArray
) then
1502 for a
:= 0 to High(GibsArray
) do
1503 with gGibs
[CurrentGib
] do
1506 ID
:= GibsArray
[a
].ID
;
1507 MaskID
:= GibsArray
[a
].MaskID
;
1510 Obj
.Rect
:= GibsArray
[a
].Rect
;
1511 Obj
.X
:= fX
-GibsArray
[a
].Rect
.X
-(GibsArray
[a
].Rect
.Width
div 2);
1512 Obj
.Y
:= fY
-GibsArray
[a
].Rect
.Y
-(GibsArray
[a
].Rect
.Height
div 2);
1513 g_Obj_PushA(@Obj
, 25 + Random(10), Random(361));
1514 RAngle
:= Random(360);
1516 if gBloodCount
> 0 then
1517 g_GFX_Blood(fX
, fY
, 16*gBloodCount
+Random(5*gBloodCount
), -16+Random(33), -16+Random(33),
1518 Random(48), Random(48), 150, 0, 0);
1520 if CurrentGib
>= High(gGibs
) then
1527 procedure g_Player_UpdatePhysicalObjects();
1533 procedure ShellSound_Bounce(X
, Y
: Integer; T
: Byte);
1538 if T
= SHELL_BULLET
then
1539 g_Sound_PlayExAt('SOUND_PLAYER_CASING' + IntToStr(k
), X
, Y
)
1541 g_Sound_PlayExAt('SOUND_PLAYER_SHELL' + IntToStr(k
), X
, Y
);
1546 if gGibs
<> nil then
1547 for i
:= 0 to High(gGibs
) do
1548 if gGibs
[i
].Live
then
1552 mr
:= g_Obj_Move(@Obj
, True, False, True);
1554 if WordBool(mr
and MOVE_FALLOUT
) then
1560 // Îòëåòàåò îò óäàðà î ñòåíó/ïîòîëîê/ïîë:
1561 if WordBool(mr
and MOVE_HITWALL
) then
1562 Obj
.Vel
.X
:= -(vel
.X
div 2);
1563 if WordBool(mr
and (MOVE_HITCEIL
or MOVE_HITLAND
)) then
1564 Obj
.Vel
.Y
:= -(vel
.Y
div 2);
1566 if (Obj
.Vel
.X
>= 0) then
1568 RAngle
:= RAngle
+ Abs(Obj
.Vel
.X
)*6 + Abs(Obj
.Vel
.Y
);
1569 if RAngle
>= 360 then
1570 RAngle
:= RAngle
mod 360;
1571 end else begin // Counter-clockwise
1572 RAngle
:= RAngle
- Abs(Obj
.Vel
.X
)*6 - Abs(Obj
.Vel
.Y
);
1574 RAngle
:= (360 - (Abs(RAngle
) mod 360)) mod 360;
1577 // Ñîïðîòèâëåíèå âîçäóõà äëÿ êóñêà òðóïà:
1578 if gTime
mod (GAME_TICK
*3) = 0 then
1579 Obj
.Vel
.X
:= z_dec(Obj
.Vel
.X
, 1);
1583 if gCorpses
<> nil then
1584 for i
:= 0 to High(gCorpses
) do
1585 if gCorpses
[i
] <> nil then
1586 if gCorpses
[i
].State
= CORPSE_STATE_REMOVEME
then
1592 gCorpses
[i
].Update();
1595 if gShells
<> nil then
1596 for i
:= 0 to High(gShells
) do
1597 if gShells
[i
].Live
then
1601 mr
:= g_Obj_Move(@Obj
, True, False, True);
1603 if WordBool(mr
and MOVE_FALLOUT
) or (gShells
[i
].Timeout
< gTime
) then
1609 // Îòëåòàåò îò óäàðà î ñòåíó/ïîòîëîê/ïîë:
1610 if WordBool(mr
and MOVE_HITWALL
) then
1612 Obj
.Vel
.X
:= -(vel
.X
div 2);
1613 if not WordBool(mr
and MOVE_INWATER
) then
1614 ShellSound_Bounce(Obj
.X
, Obj
.Y
, SType
);
1616 if WordBool(mr
and (MOVE_HITCEIL
or MOVE_HITLAND
)) then
1618 Obj
.Vel
.Y
:= -(vel
.Y
div 2);
1619 if Obj
.Vel
.X
<> 0 then Obj
.Vel
.X
:= Obj
.Vel
.X
div 2;
1620 if (Obj
.Vel
.X
= 0) and (Obj
.Vel
.Y
= 0) then
1622 if RAngle
mod 90 <> 0 then
1623 RAngle
:= (RAngle
div 90) * 90;
1625 else if not WordBool(mr
and MOVE_INWATER
) then
1626 ShellSound_Bounce(Obj
.X
, Obj
.Y
, SType
);
1629 if (Obj
.Vel
.X
>= 0) then
1631 RAngle
:= RAngle
+ Abs(Obj
.Vel
.X
)*8 + Abs(Obj
.Vel
.Y
);
1632 if RAngle
>= 360 then
1633 RAngle
:= RAngle
mod 360;
1634 end else begin // Counter-clockwise
1635 RAngle
:= RAngle
- Abs(Obj
.Vel
.X
)*8 - Abs(Obj
.Vel
.Y
);
1637 RAngle
:= (360 - (Abs(RAngle
) mod 360)) mod 360;
1642 procedure g_Player_DrawCorpses();
1647 if gGibs
<> nil then
1648 for i
:= 0 to High(gGibs
) do
1649 if gGibs
[i
].Live
then
1652 if not g_Obj_Collide(sX
, sY
, sWidth
, sHeight
, @Obj
) then
1655 a
.X
:= Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2);
1656 a
.y
:= Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2);
1658 e_DrawAdv(ID
, Obj
.X
, Obj
.Y
, 0, True, False, RAngle
, @a
, M_NONE
);
1661 e_DrawAdv(MaskID
, Obj
.X
, Obj
.Y
, 0, True, False, RAngle
, @a
, M_NONE
);
1667 if gCorpses
<> nil then
1668 for i
:= 0 to High(gCorpses
) do
1669 if gCorpses
[i
] <> nil then
1673 procedure g_Player_DrawShells();
1678 if gShells
<> nil then
1679 for i
:= 0 to High(gShells
) do
1680 if gShells
[i
].Live
then
1683 if not g_Obj_Collide(sX
, sY
, sWidth
, sHeight
, @Obj
) then
1689 e_DrawAdv(SpriteID
, Obj
.X
, Obj
.Y
, 0, True, False, RAngle
, @a
, M_NONE
);
1693 procedure g_Player_RemoveAllCorpses();
1699 SetLength(gGibs
, MaxGibs
);
1700 SetLength(gShells
, MaxGibs
);
1704 if gCorpses
<> nil then
1705 for i
:= 0 to High(gCorpses
) do
1709 SetLength(gCorpses
, MaxCorpses
);
1712 procedure g_Player_Corpses_SaveState(var Mem
: TBinMemoryWriter
);
1717 // Ñ÷èòàåì êîëè÷åñòâî ñóùåñòâóþùèõ òðóïîâ:
1719 if gCorpses
<> nil then
1720 for i
:= 0 to High(gCorpses
) do
1721 if gCorpses
[i
] <> nil then
1724 Mem
:= TBinMemoryWriter
.Create((count
+1) * 128);
1726 // Êîëè÷åñòâî òðóïîâ:
1727 Mem
.WriteInt(count
);
1733 for i
:= 0 to High(gCorpses
) do
1734 if gCorpses
[i
] <> nil then
1737 Mem
.WriteString(gCorpses
[i
].FModelName
);
1739 b
:= gCorpses
[i
].Mess
;
1740 Mem
.WriteBoolean(b
);
1741 // Ñîõðàíÿåì äàííûå òðóïà:
1742 gCorpses
[i
].SaveState(Mem
);
1746 procedure g_Player_Corpses_LoadState(var Mem
: TBinMemoryReader
);
1755 g_Player_RemoveAllCorpses();
1757 // Êîëè÷åñòâî òðóïîâ:
1760 if count
> Length(gCorpses
) then
1762 raise EBinSizeError
.Create('g_Player_Corpses_LoadState: Too Many Corpses');
1769 for i
:= 0 to count
-1 do
1772 Mem
.ReadString(str
);
1776 gCorpses
[i
] := TCorpse
.Create(0, 0, str
, b
);
1777 // Çàãðóæàåì äàííûå òðóïà:
1778 gCorpses
[i
].LoadState(Mem
);
1784 procedure TPlayer
.BFGHit();
1786 g_Weapon_BFGHit(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
1787 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2));
1788 if g_Game_IsServer
and g_Game_IsNet
then
1789 MH_SEND_Effect(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
1790 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2),
1794 procedure TPlayer
.ChangeModel(ModelName
: string);
1796 Model
: TPlayerModel
;
1798 Model
:= g_PlayerModel_Get(ModelName
);
1799 if Model
= nil then Exit
;
1805 procedure TPlayer
.SetModel(ModelName
: string);
1809 m
:= g_PlayerModel_Get(ModelName
);
1812 g_SimpleError(Format(_lc
[I_GAME_ERROR_MODEL_FALLBACK
], [ModelName
]));
1813 m
:= g_PlayerModel_Get('doomer');
1816 g_FatalError(Format(_lc
[I_GAME_ERROR_MODEL
], ['doomer']));
1821 if FModel
<> nil then
1826 if not (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then
1827 FModel
.Color
:= FColor
1829 FModel
.Color
:= TEAMCOLOR
[FTeam
];
1830 FModel
.SetWeapon(FCurrWeap
);
1831 FModel
.SetFlag(FFlag
);
1832 SetDirection(FDirection
);
1835 procedure TPlayer
.SetColor(Color
: TRGB
);
1838 if not (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then
1839 if FModel
<> nil then FModel
.Color
:= Color
;
1842 procedure TPlayer
.SwitchTeam
;
1844 if g_Game_IsClient
then
1846 if not (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then Exit
;
1848 if gGameOn
and FLive
then
1849 Kill(K_SIMPLEKILL
, FUID
, HIT_SELF
);
1851 if FTeam
= TEAM_RED
then
1853 ChangeTeam(TEAM_BLUE
);
1854 g_Console_Add(Format(_lc
[I_PLAYER_CHTEAM_BLUE
], [FName
]), True);
1855 if g_Game_IsNet
then
1856 MH_SEND_GameEvent(NET_EV_CHANGE_TEAM
, TEAM_BLUE
, FName
);
1860 ChangeTeam(TEAM_RED
);
1861 g_Console_Add(Format(_lc
[I_PLAYER_CHTEAM_RED
], [FName
]), True);
1862 if g_Game_IsNet
then
1863 MH_SEND_GameEvent(NET_EV_CHANGE_TEAM
, TEAM_RED
, FName
);
1865 FPreferredTeam
:= FTeam
;
1868 procedure TPlayer
.ChangeTeam(Team
: Byte);
1875 TEAM_RED
, TEAM_BLUE
:
1876 FModel
.Color
:= TEAMCOLOR
[Team
];
1878 FModel
.Color
:= FColor
;
1880 if (FTeam
<> OldTeam
) and g_Game_IsNet
and g_Game_IsServer
then
1881 MH_SEND_PlayerStats(FUID
);
1885 procedure TPlayer.CollideItem();
1890 if gItems = nil then Exit;
1891 if not FLive then Exit;
1893 for i := 0 to High(gItems) do
1896 if (ItemType <> ITEM_NONE) and Live then
1897 if g_Obj_Collide(FObj.X+PLAYER_RECT.X, FObj.Y+PLAYER_RECT.Y, PLAYER_RECT.Width,
1898 PLAYER_RECT.Height, @Obj) then
1900 if not PickItem(ItemType, gItems[i].Respawnable, r) then Continue;
1902 if ItemType in [ITEM_SPHERE_BLUE, ITEM_SPHERE_WHITE, ITEM_INVUL] then
1903 g_Sound_PlayExAt('SOUND_ITEM_GETRULEZ', FObj.X, FObj.Y)
1904 else if ItemType in [ITEM_MEDKIT_SMALL, ITEM_MEDKIT_LARGE, ITEM_MEDKIT_BLACK] then
1905 g_Sound_PlayExAt('SOUND_ITEM_GETMED', FObj.X, FObj.Y)
1906 else g_Sound_PlayExAt('SOUND_ITEM_GETITEM', FObj.X, FObj.Y);
1908 // Íàäî óáðàòü ñ êàðòû, åñëè ýòî íå êëþ÷, êîòîðûì íóæíî ïîäåëèòñÿ ñ äðóãèì èãðîêîì:
1909 if r and not ((ItemType in [ITEM_KEY_RED, ITEM_KEY_GREEN, ITEM_KEY_BLUE]) and
1910 (gGameSettings.GameType = GT_SINGLE) and
1911 (g_Player_GetCount() > 1)) then
1912 if not Respawnable then g_Items_Remove(i) else g_Items_Pick(i);
1918 function TPlayer
.CollideLevel(XInc
, YInc
: Integer): Boolean;
1920 Result
:= g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
,
1921 PLAYER_RECT
.Width
, PLAYER_RECT
.Height
, PANEL_WALL
,
1925 constructor TPlayer
.Create();
1931 FSawSound
:= TPlayableSound
.Create();
1932 FSawSoundIdle
:= TPlayableSound
.Create();
1933 FSawSoundHit
:= TPlayableSound
.Create();
1934 FSawSoundSelect
:= TPlayableSound
.Create();
1935 FJetSoundFly
:= TPlayableSound
.Create();
1936 FJetSoundOn
:= TPlayableSound
.Create();
1937 FJetSoundOff
:= TPlayableSound
.Create();
1939 FSawSound
.SetByName('SOUND_WEAPON_FIRESAW');
1940 FSawSoundIdle
.SetByName('SOUND_WEAPON_IDLESAW');
1941 FSawSoundHit
.SetByName('SOUND_WEAPON_HITSAW');
1942 FSawSoundSelect
.SetByName('SOUND_WEAPON_SELECTSAW');
1943 FJetSoundFly
.SetByName('SOUND_PLAYER_JETFLY');
1944 FJetSoundOn
.SetByName('SOUND_PLAYER_JETON');
1945 FJetSoundOff
.SetByName('SOUND_PLAYER_JETOFF');
1947 FSpectatePlayer
:= -1;
1951 FSavedState
.WaitRecall
:= False;
1954 FActualModelName
:= 'doomer';
1957 FObj
.Rect
:= PLAYER_RECT
;
1959 FBFGFireCounter
:= -1;
1960 FJustTeleported
:= False;
1964 procedure TPlayer
.Damage(value
: Word; SpawnerUID
: Word; vx
, vy
: Integer; t
: Byte);
1968 if (not g_Game_IsClient
) and (not FLive
) then
1973 // Íåóÿçâèìîñòü íå ñïàñàåò îò ëîâóøåê:
1974 if ((t
= HIT_TRAP
) or (t
= HIT_SELF
)) and (not FGodMode
) then
1976 if not g_Game_IsClient
then
1979 if t
= HIT_TRAP
then
1981 // Ëîâóøêà óáèâàåò ñðàçó:
1983 Kill(K_EXTRAHARDKILL
, SpawnerUID
, t
);
1985 if t
= HIT_SELF
then
1989 Kill(K_SIMPLEKILL
, SpawnerUID
, t
);
1992 // Îáíóëèòü äåéñòâèÿ ïðèìî÷åê, ÷òîáû ôîí ïðîïàë
1993 FMegaRulez
[MR_SUIT
] := 0;
1994 FMegaRulez
[MR_INVUL
] := 0;
1995 FMegaRulez
[MR_INVIS
] := 0;
1999 // Íî îò îñòàëüíîãî ñïàñàåò:
2000 if FMegaRulez
[MR_INVUL
] >= gTime
then
2007 // Åñëè åñòü óðîí ñâîèì, èëè ðàíèë ñàì ñåáÿ, èëè òåáÿ ðàíèë ïðîòèâíèê:
2008 if LongBool(gGameSettings
.Options
and GAME_OPTION_TEAMDAMAGE
) or
2009 (SpawnerUID
= FUID
) or
2010 (not SameTeam(FUID
, SpawnerUID
)) then
2012 FLastSpawnerUID
:= SpawnerUID
;
2014 // Êðîâü (ïóçûðüêè, åñëè â âîäå):
2015 if gBloodCount
> 0 then
2017 c
:= Min(value
, 200)*gBloodCount
+ Random(Min(value
, 200) div 2);
2018 if value
div 4 <= c
then
2019 c
:= c
- (value
div 4)
2023 if (t
= HIT_SOME
) and (vx
= 0) and (vy
= 0) then
2027 HIT_TRAP
, HIT_ACID
, HIT_FLAME
, HIT_SELF
: MakeBloodSimple(c
);
2028 HIT_BFG
, HIT_ROCKET
, HIT_SOME
: MakeBloodVector(c
, vx
, vy
);
2031 if t
= HIT_WATER
then
2032 g_GFX_Bubbles(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2),
2033 FObj
.Y
+PLAYER_RECT
.Y
-4, value
div 2, 8, 4);
2038 Inc(FDamageBuffer
, value
);
2042 FPain
:= FPain
+ value
;
2045 if g_Game_IsServer
and g_Game_IsNet
then
2047 MH_SEND_PlayerDamage(FUID
, t
, SpawnerUID
, value
, vx
, vy
);
2048 MH_SEND_PlayerStats(FUID
);
2049 MH_SEND_PlayerPos(False, FUID
);
2053 function TPlayer
.Heal(value
: Word; Soft
: Boolean): Boolean;
2056 if g_Game_IsClient
then
2061 if Soft
and (FHealth
< PLAYER_HP_SOFT
) then
2063 IncMax(FHealth
, value
, PLAYER_HP_SOFT
);
2066 if (not Soft
) and (FHealth
< PLAYER_HP_LIMIT
) then
2068 IncMax(FHealth
, value
, PLAYER_HP_LIMIT
);
2072 if Result
and g_Game_IsServer
and g_Game_IsNet
then
2073 MH_SEND_PlayerStats(FUID
);
2076 destructor TPlayer
.Destroy();
2078 if (gPlayer1
<> nil) and (gPlayer1
.FUID
= FUID
) then
2080 if (gPlayer2
<> nil) and (gPlayer2
.FUID
= FUID
) then
2084 FSawSoundIdle
.Free();
2085 FSawSoundHit
.Free();
2086 FJetSoundFly
.Free();
2088 FJetSoundOff
.Free();
2094 procedure TPlayer
.DrawBubble();
2096 bubX
, bubY
: Integer;
2099 Rw
, Gw
, Bw
: SmallInt;
2102 bubX
:= FObj
.X
+FObj
.Rect
.X
+ IfThen(FDirection
= D_LEFT
, -4, 18);
2103 bubY
:= FObj
.Y
+FObj
.Rect
.Y
- 18;
2111 1: // simple textual non-bubble
2113 bubX
:= FObj
.X
+FObj
.Rect
.X
- 11;
2114 bubY
:= FObj
.Y
+FObj
.Rect
.Y
- 17;
2115 e_TextureFontPrint(bubX
, bubY
, '[...]', gStdFont
);
2118 2: // advanced pixel-perfect bubble
2120 if FTeam
= TEAM_RED
then
2123 if FTeam
= TEAM_BLUE
then
2126 3: // colored bubble
2128 Rb
:= FModel
.Color
.R
;
2129 Gb
:= FModel
.Color
.G
;
2130 Bb
:= FModel
.Color
.B
;
2131 Rw
:= Min(Rb
* 2 + 64, 255);
2132 Gw
:= Min(Gb
* 2 + 64, 255);
2133 Bw
:= Min(Bb
* 2 + 64, 255);
2134 if (Abs(Rw
- Rb
) < 32)
2135 or (Abs(Gw
- Gb
) < 32)
2136 or (Abs(Bw
- Bb
) < 32) then
2138 Rb
:= Max(Rw
div 2 - 16, 0);
2139 Gb
:= Max(Gw
div 2 - 16, 0);
2140 Bb
:= Max(Bw
div 2 - 16, 0);
2143 4: // custom textured bubble
2145 if g_Texture_Get('TEXTURE_PLAYER_TALKBUBBLE', ID
) then
2146 if FDirection
= D_RIGHT
then
2147 e_Draw(ID
, bubX
- 6, bubY
- 7, 0, True, False)
2149 e_Draw(ID
, bubX
- 6, bubY
- 7, 0, True, False, M_HORIZONTAL
);
2155 e_DrawQuad(bubX
+ 1, bubY
, bubX
+ 18, bubY
+ 13, Rb
, Gb
, Bb
);
2156 e_DrawQuad(bubX
, bubY
+ 1, bubX
+ 19, bubY
+ 12, Rb
, Gb
, Bb
);
2158 e_DrawFillQuad(bubX
+ 1, bubY
+ 1, bubX
+ 18, bubY
+ 12, Rw
, Gw
, Bw
, 0);
2161 Dot
:= IfThen(FDirection
= D_LEFT
, 14, 5);
2162 e_DrawLine(1, bubX
+ Dot
, bubY
+ 14, bubX
+ Dot
, bubY
+ 16, Rb
, Gb
, Bb
);
2163 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
);
2164 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
);
2165 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
);
2166 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
);
2170 e_DrawFillQuad(bubX
+ Dot
, bubY
+ 8, bubX
+ Dot
+ 1, bubY
+ 9, Rb
, Gb
, Bb
, 0);
2171 e_DrawFillQuad(bubX
+ Dot
+ 3, bubY
+ 8, bubX
+ Dot
+ 4, bubY
+ 9, Rb
, Gb
, Bb
, 0);
2172 e_DrawFillQuad(bubX
+ Dot
+ 6, bubY
+ 8, bubX
+ Dot
+ 7, bubY
+ 9, Rb
, Gb
, Bb
, 0);
2175 procedure TPlayer
.Draw();
2183 if (FMegaRulez
[MR_INVUL
] > gTime
) and (gPlayerDrawn
<> Self
) then
2184 if g_Texture_Get('TEXTURE_PLAYER_INVULPENTA', ID
) then
2186 e_GetTextureSize(ID
, @w
, @h
);
2187 if FDirection
= D_LEFT
then
2188 e_Draw(ID
, FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2)-(w
div 2)+4,
2189 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2)-(h
div 2)-7, 0, True, False)
2191 e_Draw(ID
, FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2)-(w
div 2)-2,
2192 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2)-(h
div 2)-7, 0, True, False);
2195 if FMegaRulez
[MR_INVIS
] > gTime
then
2197 if (gPlayerDrawn
<> nil) and ((Self
= gPlayerDrawn
) or
2198 ((FTeam
= gPlayerDrawn
.Team
) and (gGameSettings
.GameMode
<> GM_DM
))) then
2200 if (FMegaRulez
[MR_INVIS
] - gTime
) <= 2100 then
2201 dr
:= not Odd((FMegaRulez
[MR_INVIS
] - gTime
) div 300)
2205 FModel
.Draw(FObj
.X
, FObj
.Y
, 200)
2207 FModel
.Draw(FObj
.X
, FObj
.Y
);
2210 FModel
.Draw(FObj
.X
, FObj
.Y
, 254);
2213 FModel
.Draw(FObj
.X
, FObj
.Y
);
2216 if g_debug_Frames
then
2218 e_DrawQuad(FObj
.X
+FObj
.Rect
.X
,
2220 FObj
.X
+FObj
.Rect
.X
+FObj
.Rect
.Width
-1,
2221 FObj
.Y
+FObj
.Rect
.Y
+FObj
.Rect
.Height
-1,
2225 if (gChatBubble
> 0) and (FKeys
[KEY_CHAT
].Pressed
) and not FGhost
then
2227 // e_DrawPoint(5, 335, 288, 255, 0, 0); // DL, UR, DL, UR
2228 if gAimLine
and Live
and
2229 ((Self
= gPlayer1
) or (Self
= gPlayer2
)) then
2233 procedure TPlayer
.DrawAim();
2235 wx
, wy
, xx
, yy
: Integer;
2239 wx
:= FObj
.X
+ WEAPONPOINT
[FDirection
].X
+ IfThen(FDirection
= D_LEFT
, 7, -7);
2240 wy
:= FObj
.Y
+ WEAPONPOINT
[FDirection
].Y
;
2249 1: begin // Chainsaw
2256 if angle
= ANGLE_RIGHTUP
then Dec(angle
, 2);
2257 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 4);
2258 if angle
= ANGLE_LEFTUP
then Inc(angle
, 2);
2259 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 4);
2264 if angle
= ANGLE_RIGHTUP
then Dec(angle
, 2);
2265 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 4);
2266 if angle
= ANGLE_LEFTUP
then Inc(angle
, 2);
2267 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 4);
2269 4: begin // Double Shotgun
2272 if angle
= ANGLE_RIGHTUP
then Dec(angle
, 2);
2273 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 4);
2274 if angle
= ANGLE_LEFTUP
then Inc(angle
, 2);
2275 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 4);
2277 5: begin // Chaingun
2280 if angle
= ANGLE_RIGHTUP
then Dec(angle
, 2);
2281 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 4);
2282 if angle
= ANGLE_LEFTUP
then Inc(angle
, 2);
2283 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 4);
2285 6: begin // Rocket Launcher
2288 if angle
= ANGLE_RIGHTUP
then Inc(angle
, 2);
2289 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 4);
2290 if angle
= ANGLE_LEFTUP
then Dec(angle
, 2);
2291 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 4);
2293 7: begin // Plasmagun
2296 if angle
= ANGLE_RIGHTUP
then Inc(angle
);
2297 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 3);
2298 if angle
= ANGLE_LEFTUP
then Dec(angle
);
2299 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 3);
2304 if angle
= ANGLE_RIGHTUP
then Inc(angle
, 1);
2305 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 2);
2306 if angle
= ANGLE_LEFTUP
then Dec(angle
, 1);
2307 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 2);
2309 9: begin // Super Chaingun
2312 if angle
= ANGLE_RIGHTUP
then Dec(angle
, 2);
2313 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 4);
2314 if angle
= ANGLE_LEFTUP
then Inc(angle
, 2);
2315 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 4);
2318 xx
:= Trunc(Cos(-DegToRad(angle
)) * len
) + wx
;
2319 yy
:= Trunc(Sin(-DegToRad(angle
)) * len
) + wy
;
2320 e_DrawLine(sz
, wx
, wy
, xx
, yy
, 255, 0, 0, 96);
2323 procedure TPlayer
.DrawGUI();
2326 X
, Y
, SY
, a
, p
, m
: Integer;
2330 stat
: TPlayerStatArray
;
2332 X
:= gPlayerScreenSize
.X
;
2333 SY
:= gPlayerScreenSize
.Y
;
2336 if gShowGoals
and (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then
2338 if gGameSettings
.GameMode
= GM_CTF
then
2342 if gGameSettings
.GameMode
= GM_CTF
then
2344 s
:= 'TEXTURE_PLAYER_REDFLAG';
2345 if gFlags
[FLAG_RED
].State
= FLAG_STATE_CAPTURED
then
2346 s
:= 'TEXTURE_PLAYER_REDFLAG_S';
2347 if gFlags
[FLAG_RED
].State
= FLAG_STATE_DROPPED
then
2348 s
:= 'TEXTURE_PLAYER_REDFLAG_D';
2349 if g_Texture_Get(s
, ID
) then
2350 e_Draw(ID
, X
-16-32, 240-72-4, 0, True, False);
2353 s
:= IntToStr(gTeamStat
[TEAM_RED
].Goals
);
2354 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2355 e_CharFont_PrintEx(gMenuFont
, X
-16-a
-tw
, 240-72-4, s
, TEAMCOLOR
[TEAM_RED
]);
2357 if gGameSettings
.GameMode
= GM_CTF
then
2359 s
:= 'TEXTURE_PLAYER_BLUEFLAG';
2360 if gFlags
[FLAG_BLUE
].State
= FLAG_STATE_CAPTURED
then
2361 s
:= 'TEXTURE_PLAYER_BLUEFLAG_S';
2362 if gFlags
[FLAG_BLUE
].State
= FLAG_STATE_DROPPED
then
2363 s
:= 'TEXTURE_PLAYER_BLUEFLAG_D';
2364 if g_Texture_Get(s
, ID
) then
2365 e_Draw(ID
, X
-16-32, 240-32-4, 0, True, False);
2368 s
:= IntToStr(gTeamStat
[TEAM_BLUE
].Goals
);
2369 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2370 e_CharFont_PrintEx(gMenuFont
, X
-16-a
-tw
, 240-32-4, s
, TEAMCOLOR
[TEAM_BLUE
]);
2373 if g_Texture_Get('TEXTURE_PLAYER_HUDBG', ID
) then
2374 e_DrawFill(ID
, X
, 0, 1, (gPlayerScreenSize
.Y
div 256)+IfThen(gPlayerScreenSize
.Y
mod 256 > 0, 1, 0),
2377 if g_Texture_Get('TEXTURE_PLAYER_HUD', ID
) then
2378 e_Draw(ID
, X
+2, Y
, 0, True, False);
2380 if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
2384 s
:= IntToStr(Frags
);
2385 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2386 e_CharFont_PrintEx(gMenuFont
, X
-16-tw
, Y
, s
, _RGB(255, 0, 0));
2391 stat
:= g_Player_GetStats();
2396 for a
:= 0 to High(stat
) do
2397 if stat
[a
].Name
<> Name
then
2399 if stat
[a
].Frags
> m
then m
:= stat
[a
].Frags
;
2400 if stat
[a
].Frags
> Frags
then p
:= p
+1;
2404 s
:= IntToStr(p
)+' / '+IntToStr(Length(stat
))+' ';
2405 if Frags
>= m
then s
:= s
+'+' else s
:= s
+'-';
2406 s
:= s
+IntToStr(Abs(Frags
-m
));
2408 e_CharFont_GetSize(gMenuSmallFont
, s
, tw
, th
);
2409 e_CharFont_PrintEx(gMenuSmallFont
, X
-16-tw
, Y
+32, s
, _RGB(255, 0, 0));
2412 if gShowLives
and (gGameSettings
.MaxLives
> 0) then
2414 s
:= IntToStr(Lives
);
2415 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2416 e_CharFont_PrintEx(gMenuFont
, X
-16-tw
, SY
-32, s
, _RGB(0, 255, 0));
2420 e_CharFont_GetSize(gMenuSmallFont
, FName
, tw
, th
);
2421 e_CharFont_PrintEx(gMenuSmallFont
, X
+98-(tw
div 2), Y
+8, FName
, _RGB(255, 0, 0));
2423 if R_BERSERK
in FRulez
then
2424 e_Draw(gItemsTexturesID
[ITEM_MEDKIT_BLACK
], X
+37, Y
+45, 0, True, False)
2426 e_Draw(gItemsTexturesID
[ITEM_MEDKIT_LARGE
], X
+37, Y
+45, 0, True, False);
2428 if g_Texture_Get('TEXTURE_PLAYER_ARMORHUD', ID
) then
2429 e_Draw(ID
, X
+36, Y
+77, 0, True, False);
2431 s
:= IntToStr(IfThen(FHealth
> 0, FHealth
, 0));
2432 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2433 e_CharFont_PrintEx(gMenuFont
, X
+178-tw
, Y
+40, s
, _RGB(255, 0, 0));
2435 s
:= IntToStr(FArmor
);
2436 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2437 e_CharFont_PrintEx(gMenuFont
, X
+178-tw
, Y
+68, s
, _RGB(255, 0, 0));
2439 s
:= IntToStr(GetAmmoByWeapon(FCurrWeap
));
2445 ID
:= gItemsTexturesID
[ITEM_WEAPON_KASTET
];
2450 ID
:= gItemsTexturesID
[ITEM_WEAPON_SAW
];
2452 WEAPON_PISTOL
: ID
:= gItemsTexturesID
[ITEM_WEAPON_PISTOL
];
2453 WEAPON_CHAINGUN
: ID
:= gItemsTexturesID
[ITEM_WEAPON_CHAINGUN
];
2454 WEAPON_SHOTGUN1
: ID
:= gItemsTexturesID
[ITEM_WEAPON_SHOTGUN1
];
2455 WEAPON_SHOTGUN2
: ID
:= gItemsTexturesID
[ITEM_WEAPON_SHOTGUN2
];
2456 WEAPON_SUPERPULEMET
: ID
:= gItemsTexturesID
[ITEM_WEAPON_SUPERPULEMET
];
2457 WEAPON_ROCKETLAUNCHER
: ID
:= gItemsTexturesID
[ITEM_WEAPON_ROCKETLAUNCHER
];
2458 WEAPON_PLASMA
: ID
:= gItemsTexturesID
[ITEM_WEAPON_PLASMA
];
2459 WEAPON_BFG
: ID
:= gItemsTexturesID
[ITEM_WEAPON_BFG
];
2462 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2463 e_CharFont_PrintEx(gMenuFont
, X
+178-tw
, Y
+158, s
, _RGB(255, 0, 0));
2464 e_Draw(ID
, X
+20, Y
+160, 0, True, False);
2466 if R_KEY_RED
in FRulez
then
2467 e_Draw(gItemsTexturesID
[ITEM_KEY_RED
], X
+78, Y
+214, 0, True, False);
2469 if R_KEY_GREEN
in FRulez
then
2470 e_Draw(gItemsTexturesID
[ITEM_KEY_GREEN
], X
+95, Y
+214, 0, True, False);
2472 if R_KEY_BLUE
in FRulez
then
2473 e_Draw(gItemsTexturesID
[ITEM_KEY_BLUE
], X
+112, Y
+214, 0, True, False);
2475 if FJetFuel
> 0 then
2477 if g_Texture_Get('TEXTURE_PLAYER_HUDAIR', ID
) then
2478 e_Draw(ID
, X
+2, Y
+116, 0, True, False);
2479 if g_Texture_Get('TEXTURE_PLAYER_HUDJET', ID
) then
2480 e_Draw(ID
, X
+2, Y
+126, 0, True, False);
2481 e_DrawLine(4, X
+16, Y
+122, X
+16+Trunc(168*IfThen(FAir
> 0, FAir
, 0)/AIR_MAX
), Y
+122, 0, 0, 196);
2482 e_DrawLine(4, X
+16, Y
+132, X
+16+Trunc(168*FJetFuel
/JET_MAX
), Y
+132, 208, 0, 0);
2486 if g_Texture_Get('TEXTURE_PLAYER_HUDAIR', ID
) then
2487 e_Draw(ID
, X
+2, Y
+124, 0, True, False);
2488 e_DrawLine(4, X
+16, Y
+130, X
+16+Trunc(168*IfThen(FAir
> 0, FAir
, 0)/AIR_MAX
), Y
+130, 0, 0, 196);
2491 if gShowPing
and g_Game_IsClient
then
2493 s
:= _lc
[I_GAME_PING_HUD
] + IntToStr(NetPeer
.lastRoundTripTime
) + _lc
[I_NET_SLIST_PING_MS
];
2494 e_TextureFontPrint(X
+ 4, Y
+ 242, s
, gStdFont
);
2500 e_TextureFontPrint(X
+ 4, Y
+ 242, _lc
[I_PLAYER_SPECT
], gStdFont
);
2501 e_TextureFontPrint(X
+ 4, Y
+ 258, _lc
[I_PLAYER_SPECT2
], gStdFont
);
2502 e_TextureFontPrint(X
+ 4, Y
+ 274, _lc
[I_PLAYER_SPECT1
], gStdFont
);
2505 e_TextureFontGetSize(gStdFont
, cw
, ch
);
2506 s
:= _lc
[I_PLAYER_SPECT4
];
2507 e_TextureFontPrintEx(gScreenWidth
div 2 - cw
*(Length(s
) div 2),
2508 gScreenHeight
-4-ch
, s
, gStdFont
, 255, 255, 255, 1, True);
2509 e_TextureFontPrint(X
+ 4, Y
+ 290, _lc
[I_PLAYER_SPECT1S
], gStdFont
);
2515 procedure TPlayer
.DrawRulez();
2519 // Ïðè âçÿòèè íåóÿçâèìîñòè ðèñóåòñÿ èíâåðñèîííûé áåëûé ôîí
2520 if FMegaRulez
[MR_INVUL
] >= gTime
then
2522 if (FMegaRulez
[MR_INVUL
]-gTime
) <= 2100 then
2523 dr
:= not Odd((FMegaRulez
[MR_INVUL
]-gTime
) div 300)
2528 e_DrawFillQuad(0, 0, gPlayerScreenSize
.X
-1, gPlayerScreenSize
.Y
-1,
2529 191, 191, 191, 0, B_INVERT
);
2532 // Ïðè âçÿòèè çàùèòíîãî êîñòþìà ðèñóåòñÿ çåëåíîâàòûé ôîí
2533 if FMegaRulez
[MR_SUIT
] >= gTime
then
2535 if (FMegaRulez
[MR_SUIT
]-gTime
) <= 2100 then
2536 dr
:= not Odd((FMegaRulez
[MR_SUIT
]-gTime
) div 300)
2541 e_DrawFillQuad(0, 0, gPlayerScreenSize
.X
-1, gPlayerScreenSize
.Y
-1,
2542 0, 96, 0, 200, B_NONE
);
2545 // Ïðè âçÿòèè áåðñåðêà ðèñóåòñÿ êðàñíîâàòûé ôîí
2546 if (FBerserk
>= 0) and (LongWord(FBerserk
) >= gTime
) and (gFlash
= 2) then
2548 e_DrawFillQuad(0, 0, gPlayerScreenSize
.X
-1, gPlayerScreenSize
.Y
-1,
2549 255, 0, 0, 200, B_NONE
);
2553 procedure TPlayer
.DrawPain();
2557 if FPain
= 0 then Exit
;
2561 if a
< 15 then h
:= 0
2562 else if a
< 35 then h
:= 1
2563 else if a
< 55 then h
:= 2
2564 else if a
< 75 then h
:= 3
2565 else if a
< 95 then h
:= 4
2568 //if a > 255 then a := 255;
2570 e_DrawFillQuad(0, 0, gPlayerScreenSize
.X
-1, gPlayerScreenSize
.Y
-1, 255, 0, 0, 255-h
*50);
2571 //e_DrawFillQuad(0, 0, gPlayerScreenSize.X-1, gPlayerScreenSize.Y-1, 255-min(128, a), 255-a, 255-a, 0, B_FILTER);
2574 procedure TPlayer
.DrawPickup();
2578 if FPickup
= 0 then Exit
;
2582 if a
< 15 then h
:= 1
2583 else if a
< 35 then h
:= 2
2584 else if a
< 55 then h
:= 3
2585 else if a
< 75 then h
:= 4
2588 e_DrawFillQuad(0, 0, gPlayerScreenSize
.X
-1, gPlayerScreenSize
.Y
-1, 150, 200, 150, 255-h
*50);
2591 procedure TPlayer
.Fire();
2593 f
, DidFire
: Boolean;
2594 wx
, wy
, xd
, yd
: Integer;
2597 if g_Game_IsClient
then Exit
;
2598 // FBFGFireCounter - âðåìÿ ïåðåä âûñòðåëîì (äëÿ BFG)
2599 // FReloading - âðåìÿ ïîñëå âûñòðåëà (äëÿ âñåãî)
2607 if FReloading
[FCurrWeap
] <> 0 then Exit
;
2612 wx
:= FObj
.X
+WEAPONPOINT
[FDirection
].X
;
2613 wy
:= FObj
.Y
+WEAPONPOINT
[FDirection
].Y
;
2614 xd
:= wx
+IfThen(FDirection
= D_LEFT
, -30, 30);
2615 yd
:= wy
+firediry();
2620 if R_BERSERK
in FRulez
then
2622 //g_Weapon_punch(FObj.X+FObj.Rect.X, FObj.Y+FObj.Rect.Y, 75, FUID);
2623 obj
.X
:= FObj
.X
+FObj
.Rect
.X
;
2624 obj
.Y
:= FObj
.Y
+FObj
.Rect
.Y
;
2627 obj
.rect
.Width
:= 39;
2628 obj
.rect
.Height
:= 52;
2629 obj
.Vel
.X
:= (xd
-wx
) div 2;
2630 obj
.Vel
.Y
:= (yd
-wy
) div 2;
2631 obj
.Accel
.X
:= xd
-wx
;
2632 obj
.Accel
.y
:= yd
-wy
;
2634 if g_Weapon_Hit(@obj
, 50, FUID
, HIT_SOME
) <> 0 then
2635 g_Sound_PlayExAt('SOUND_WEAPON_HITBERSERK', FObj
.X
, FObj
.Y
)
2637 g_Sound_PlayExAt('SOUND_WEAPON_MISSBERSERK', FObj
.X
, FObj
.Y
);
2641 FPain
:= min(FPain
+ 25, 50);
2642 end else g_Weapon_punch(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
, 3, FUID
);
2645 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
2650 if g_Weapon_chainsaw(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
,
2651 IfThen(gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
], 9, 3), FUID
) <> 0 then
2653 FSawSoundSelect
.Stop();
2655 FSawSoundHit
.PlayAt(FObj
.X
, FObj
.Y
);
2657 else if not FSawSoundHit
.IsPlaying() then
2659 FSawSoundSelect
.Stop();
2660 FSawSound
.PlayAt(FObj
.X
, FObj
.Y
);
2663 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
2669 if FAmmo
[A_BULLETS
] > 0 then
2671 g_Weapon_pistol(wx
, wy
, xd
, yd
, FUID
);
2672 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
2673 Dec(FAmmo
[A_BULLETS
]);
2674 FFireAngle
:= FAngle
;
2677 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
2678 GameVelX
, GameVelY
-2, SHELL_BULLET
);
2682 if FAmmo
[A_SHELLS
] > 0 then
2684 g_Weapon_shotgun(wx
, wy
, xd
, yd
, FUID
);
2685 if not gSoundEffectsDF
then g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN', wx
, wy
);
2686 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
2687 Dec(FAmmo
[A_SHELLS
]);
2688 FFireAngle
:= FAngle
;
2692 FShellType
:= SHELL_SHELL
;
2696 if FAmmo
[A_SHELLS
] >= 2 then
2698 g_Weapon_dshotgun(wx
, wy
, xd
, yd
, FUID
);
2699 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
2700 Dec(FAmmo
[A_SHELLS
], 2);
2701 FFireAngle
:= FAngle
;
2705 FShellType
:= SHELL_DBLSHELL
;
2709 if FAmmo
[A_BULLETS
] > 0 then
2711 g_Weapon_mgun(wx
, wy
, xd
, yd
, FUID
);
2712 if not gSoundEffectsDF
then g_Sound_PlayExAt('SOUND_WEAPON_FIREPISTOL', wx
, wy
);
2713 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
2714 Dec(FAmmo
[A_BULLETS
]);
2715 FFireAngle
:= FAngle
;
2718 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
2719 GameVelX
, GameVelY
-2, SHELL_BULLET
);
2722 WEAPON_ROCKETLAUNCHER
:
2723 if FAmmo
[A_ROCKETS
] > 0 then
2725 g_Weapon_rocket(wx
, wy
, xd
, yd
, FUID
);
2726 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
2727 Dec(FAmmo
[A_ROCKETS
]);
2728 FFireAngle
:= FAngle
;
2734 if FAmmo
[A_CELLS
] > 0 then
2736 g_Weapon_plasma(wx
, wy
, xd
, yd
, FUID
);
2737 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
2738 Dec(FAmmo
[A_CELLS
]);
2739 FFireAngle
:= FAngle
;
2745 if (FAmmo
[A_CELLS
] >= 40) and (FBFGFireCounter
= -1) then
2747 FBFGFireCounter
:= 17;
2748 if not FNoReload
then
2749 g_Sound_PlayExAt('SOUND_WEAPON_STARTFIREBFG', FObj
.X
, FObj
.Y
);
2750 Dec(FAmmo
[A_CELLS
], 40);
2754 WEAPON_SUPERPULEMET
:
2755 if FAmmo
[A_SHELLS
] > 0 then
2757 g_Weapon_shotgun(wx
, wy
, xd
, yd
, FUID
);
2758 if not gSoundEffectsDF
then g_Sound_PlayExAt('SOUND_WEAPON_FIRECGUN', wx
, wy
);
2759 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
2760 Dec(FAmmo
[A_SHELLS
]);
2761 FFireAngle
:= FAngle
;
2764 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
2765 GameVelX
, GameVelY
-2, SHELL_SHELL
);
2769 if g_Game_IsNet
then
2773 if FCurrWeap
<> WEAPON_BFG
then
2774 MH_SEND_PlayerFire(FUID
, FCurrWeap
, wx
, wy
, xd
, yd
, LastShotID
)
2776 if not FNoReload
then
2777 MH_SEND_Sound(FObj
.X
, FObj
.Y
, 'SOUND_WEAPON_STARTFIREBFG');
2780 MH_SEND_PlayerStats(FUID
);
2785 if (FAngle
= 0) or (FAngle
= 180) then SetAction(A_ATTACK
)
2786 else if (FAngle
= ANGLE_LEFTDOWN
) or (FAngle
= ANGLE_RIGHTDOWN
) then SetAction(A_ATTACKDOWN
)
2787 else if (FAngle
= ANGLE_LEFTUP
) or (FAngle
= ANGLE_RIGHTUP
) then SetAction(A_ATTACKUP
);
2790 function TPlayer
.GetAmmoByWeapon(Weapon
: Byte): Word;
2793 WEAPON_PISTOL
, WEAPON_CHAINGUN
: Result
:= FAmmo
[A_BULLETS
];
2794 WEAPON_SHOTGUN1
, WEAPON_SHOTGUN2
, WEAPON_SUPERPULEMET
: Result
:= FAmmo
[A_SHELLS
];
2795 WEAPON_ROCKETLAUNCHER
: Result
:= FAmmo
[A_ROCKETS
];
2796 WEAPON_PLASMA
, WEAPON_BFG
: Result
:= FAmmo
[A_CELLS
];
2801 function TPlayer
.HeadInLiquid(XInc
, YInc
: Integer): Boolean;
2803 Result
:= g_Map_CollidePanel(FObj
.X
+PLAYER_HEADRECT
.X
+XInc
, FObj
.Y
+PLAYER_HEADRECT
.Y
+YInc
,
2804 PLAYER_HEADRECT
.Width
, PLAYER_HEADRECT
.Height
,
2805 PANEL_WATER
or PANEL_ACID1
or PANEL_ACID2
, True);
2808 procedure TPlayer
.JetpackOn
;
2812 FJetSoundOn
.SetPosition(0);
2813 FJetSoundOn
.PlayAt(FObj
.X
, FObj
.Y
);
2817 procedure TPlayer
.JetpackOff
;
2821 FJetSoundOff
.SetPosition(0);
2822 FJetSoundOff
.PlayAt(FObj
.X
, FObj
.Y
);
2825 procedure TPlayer
.Jump();
2827 if gFly
or FJetpack
then
2829 // Ïîëåò (÷èò-êîä èëè äæåòïàê):
2830 if FObj
.Vel
.Y
> -VEL_FLY
then
2831 FObj
.Vel
.Y
:= FObj
.Vel
.Y
- 3;
2834 if FJetFuel
> 0 then
2836 if (FJetFuel
< 1) and g_Game_IsServer
then
2840 if g_Game_IsNet
then
2841 MH_SEND_PlayerStats(FUID
);
2847 // Íå âêëþ÷àòü äæåòïàê â ðåæèìå ïðîõîæäåíèÿ ñêâîçü ñòåíû
2849 FCanJetpack
:= False;
2851 // Ïðûãàåì èëè âñïëûâàåì:
2852 if (CollideLevel(0, 1) or
2853 g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+PLAYER_RECT
.Y
+36, PLAYER_RECT
.Width
,
2854 PLAYER_RECT
.Height
-33, PANEL_STEP
, False)
2855 ) and (FObj
.Accel
.Y
= 0) then // Íå ïðûãàòü, åñëè åñòü âåðòèêàëüíîå óñêîðåíèå
2857 FObj
.Vel
.Y
:= -VEL_JUMP
;
2858 FCanJetpack
:= False;
2862 if BodyInLiquid(0, 0) then
2863 FObj
.Vel
.Y
:= -VEL_SW
2864 else if (FJetFuel
> 0) and FCanJetpack
and
2865 g_Game_IsServer
and (not g_Obj_CollideLiquid(@FObj
, 0, 0)) then
2869 if g_Game_IsNet
then
2870 MH_SEND_PlayerStats(FUID
);
2875 procedure TPlayer
.Kill(KillType
: Byte; SpawnerUID
: Word; t
: Byte);
2877 a
, i
, k
, ab
, ar
: Byte;
2881 srv
, netsrv
: Boolean;
2886 procedure PushItem(t
: Byte);
2890 id
:= g_Items_Create(FObj
.X
, FObj
.Y
, t
, True, False);
2891 if KillType
= K_EXTRAHARDKILL
then // -7..+7; -8..0
2892 g_Obj_Push(@gItems
[id
].Obj
, (FObj
.Vel
.X
div 2)-7+Random(15),
2893 (FObj
.Vel
.Y
div 2)-Random(9))
2895 if KillType
= K_HARDKILL
then // -5..+5; -5..0
2896 g_Obj_Push(@gItems
[id
].Obj
, (FObj
.Vel
.X
div 2)-5+Random(11),
2897 (FObj
.Vel
.Y
div 2)-Random(6))
2898 else // -3..+3; -3..0
2899 g_Obj_Push(@gItems
[id
].Obj
, (FObj
.Vel
.X
div 2)-3+Random(7),
2900 (FObj
.Vel
.Y
div 2)-Random(4));
2902 if g_Game_IsNet
and g_Game_IsServer
then
2903 MH_SEND_ItemSpawn(True, id
);
2907 DoFrags
:= (gGameSettings
.MaxLives
= 0) or (gGameSettings
.GameMode
= GM_COOP
);
2908 Srv
:= g_Game_IsServer
;
2909 Netsrv
:= g_Game_IsServer
and g_Game_IsNet
;
2910 if Srv
then FDeath
:= FDeath
+ 1;
2915 if not FPhysics
then
2921 if (gGameSettings
.MaxLives
> 0) and Srv
and (gLMSRespawn
= LMS_RESPAWN_NONE
) then
2923 if FLives
> 0 then FLives
:= FLives
- 1;
2924 if FLives
= 0 then FNoRespawn
:= True;
2927 // Íîìåð òèïà ñìåðòè:
2930 K_SIMPLEKILL
: a
:= 1;
2932 K_EXTRAHARDKILL
: a
:= 3;
2937 if not FModel
.PlaySound(MODELSOUND_DIE
, a
, FObj
.X
, FObj
.Y
) then
2939 if FModel
.PlaySound(MODELSOUND_DIE
, i
, FObj
.X
, FObj
.Y
) then
2946 FTime
[T_RESPAWN
] := gTime
+ TIME_RESPAWN1
;
2948 FTime
[T_RESPAWN
] := gTime
+ TIME_RESPAWN2
;
2949 K_EXTRAHARDKILL
, K_FALLKILL
:
2950 FTime
[T_RESPAWN
] := gTime
+ TIME_RESPAWN3
;
2953 // Ïåðåêëþ÷àåì ñîñòîÿíèå:
2957 K_HARDKILL
, K_EXTRAHARDKILL
:
2961 // Ðåàêöèÿ ìîíñòðîâ íà ñìåðòü èãðîêà:
2962 if (KillType
<> K_FALLKILL
) and (Srv
) then
2963 g_Monsters_killedp();
2965 if SpawnerUID
= FUID
then
2967 if Srv
and (DoFrags
or (gGameSettings
.GameMode
= GM_TDM
)) then
2972 g_Console_Add(Format(_lc
[I_PLAYER_KILL_SELF
], [FName
]), True);
2975 if g_GetUIDType(SpawnerUID
) = UID_PLAYER
then
2976 begin // Óáèò äðóãèì èãðîêîì
2977 KP
:= g_Player_Get(SpawnerUID
);
2978 if (KP
<> nil) and Srv
then
2980 if (DoFrags
or (gGameSettings
.GameMode
= GM_TDM
)) then
2981 if SameTeam(FUID
, SpawnerUID
) then
2991 if (gGameSettings
.GameMode
= GM_TDM
) and DoFrags
then
2992 Inc(gTeamStat
[KP
.Team
].Goals
,
2993 IfThen(SameTeam(FUID
, SpawnerUID
), -1, 1));
2995 if netsrv
then MH_SEND_PlayerStats(SpawnerUID
);
2998 plr
:= g_Player_Get(SpawnerUID
);
3006 g_Console_Add(Format(_lc
[I_PLAYER_KILL_EXTRAHARD_2
],
3010 g_Console_Add(Format(_lc
[I_PLAYER_KILL_EXTRAHARD_1
],
3014 g_Console_Add(Format(_lc
[I_PLAYER_KILL
],
3019 else if g_GetUIDType(SpawnerUID
) = UID_MONSTER
then
3020 begin // Óáèò ìîíñòðîì
3021 mon
:= g_Monsters_Get(SpawnerUID
);
3025 s
:= g_Monsters_GetKilledBy(mon
.MonsterType
);
3029 g_Console_Add(Format(_lc
[I_PLAYER_KILL_EXTRAHARD_2
],
3033 g_Console_Add(Format(_lc
[I_PLAYER_KILL_EXTRAHARD_1
],
3037 g_Console_Add(Format(_lc
[I_PLAYER_KILL
],
3042 else // Îñîáûå òèïû ñìåðòè
3045 HIT_SELF
: g_Console_Add(Format(_lc
[I_PLAYER_KILL_SELF
], [FName
]), True);
3046 HIT_FALL
: g_Console_Add(Format(_lc
[I_PLAYER_KILL_FALL
], [FName
]), True);
3047 HIT_WATER
: g_Console_Add(Format(_lc
[I_PLAYER_KILL_WATER
], [FName
]), True);
3048 HIT_ACID
: g_Console_Add(Format(_lc
[I_PLAYER_KILL_ACID
], [FName
]), True);
3049 HIT_TRAP
: g_Console_Add(Format(_lc
[I_PLAYER_KILL_TRAP
], [FName
]), True);
3050 else g_Console_Add(Format(_lc
[I_PLAYER_DIED
], [FName
]), True);
3056 for a
:= WEAPON_KASTET
to WEAPON_SUPERPULEMET
do
3060 WEAPON_SAW
: i
:= ITEM_WEAPON_SAW
;
3061 WEAPON_SHOTGUN1
: i
:= ITEM_WEAPON_SHOTGUN1
;
3062 WEAPON_SHOTGUN2
: i
:= ITEM_WEAPON_SHOTGUN2
;
3063 WEAPON_CHAINGUN
: i
:= ITEM_WEAPON_CHAINGUN
;
3064 WEAPON_ROCKETLAUNCHER
: i
:= ITEM_WEAPON_ROCKETLAUNCHER
;
3065 WEAPON_PLASMA
: i
:= ITEM_WEAPON_PLASMA
;
3066 WEAPON_BFG
: i
:= ITEM_WEAPON_BFG
;
3067 WEAPON_SUPERPULEMET
: i
:= ITEM_WEAPON_SUPERPULEMET
;
3076 if R_ITEM_BACKPACK
in FRulez
then
3077 PushItem(ITEM_AMMO_BACKPACK
);
3079 // Âûáðîñ ðàêåòíîãî ðàíöà:
3080 if FJetFuel
> 0 then
3081 PushItem(ITEM_JETPACK
);
3084 if not (gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
]) then
3086 if R_KEY_RED
in FRulez
then
3087 PushItem(ITEM_KEY_RED
);
3089 if R_KEY_GREEN
in FRulez
then
3090 PushItem(ITEM_KEY_GREEN
);
3092 if R_KEY_BLUE
in FRulez
then
3093 PushItem(ITEM_KEY_BLUE
);
3100 g_Player_CreateCorpse(Self
);
3102 if Srv
and (gGameSettings
.MaxLives
> 0) and FNoRespawn
and
3103 (gLMSRespawn
= LMS_RESPAWN_NONE
) then
3109 for i
:= Low(gPlayers
) to High(gPlayers
) do
3111 if gPlayers
[i
] = nil then continue
;
3112 if (not gPlayers
[i
].FNoRespawn
) and (not gPlayers
[i
].FSpectator
) then
3115 if gPlayers
[i
].FTeam
= TEAM_RED
then Inc(ar
)
3116 else if gPlayers
[i
].FTeam
= TEAM_BLUE
then Inc(ab
);
3121 OldLR
:= gLMSRespawn
;
3122 if (gGameSettings
.GameMode
= GM_COOP
) then
3126 // everyone is dead, restart the map
3127 g_Game_Message(_lc
[I_MESSAGE_LMS_LOSE
], 144);
3129 MH_SEND_GameEvent(NET_EV_LMS_LOSE
);
3130 gLMSRespawn
:= LMS_RESPAWN_FINAL
;
3131 gLMSRespawnTime
:= gTime
+ 5000;
3133 else if (a
= 1) then
3135 if (gPlayers
[k
] <> nil) and not (gPlayers
[k
] is TBot
) then
3136 if (gPlayers
[k
] = gPlayer1
) or
3137 (gPlayers
[k
] = gPlayer2
) then
3138 g_Console_Add('*** ' + _lc
[I_MESSAGE_LMS_SURVIVOR
] + ' ***', True)
3139 else if Netsrv
and (gPlayers
[k
].FClientID
>= 0) then
3140 MH_SEND_GameEvent(NET_EV_LMS_SURVIVOR
, 0, 'N', gPlayers
[k
].FClientID
);
3143 else if (gGameSettings
.GameMode
= GM_TDM
) then
3145 if (ab
= 0) and (ar
<> 0) then
3148 g_Game_Message(Format(_lc
[I_MESSAGE_TLMS_WIN
], [AnsiUpperCase(_lc
[I_GAME_TEAM_RED
])]), 144);
3150 MH_SEND_GameEvent(NET_EV_TLMS_WIN
, TEAM_RED
);
3151 Inc(gTeamStat
[TEAM_RED
].Goals
);
3152 gLMSRespawn
:= LMS_RESPAWN_FINAL
;
3153 gLMSRespawnTime
:= gTime
+ 5000;
3155 else if (ar
= 0) and (ab
<> 0) then
3158 g_Game_Message(Format(_lc
[I_MESSAGE_TLMS_WIN
], [AnsiUpperCase(_lc
[I_GAME_TEAM_BLUE
])]), 144);
3160 MH_SEND_GameEvent(NET_EV_TLMS_WIN
, TEAM_BLUE
);
3161 Inc(gTeamStat
[TEAM_BLUE
].Goals
);
3162 gLMSRespawn
:= LMS_RESPAWN_FINAL
;
3163 gLMSRespawnTime
:= gTime
+ 5000;
3165 else if (ar
= 0) and (ab
= 0) then
3168 g_Game_Message(_lc
[I_GAME_WIN_DRAW
], 144);
3170 MH_SEND_GameEvent(NET_EV_LMS_DRAW
, 0, FName
);
3171 gLMSRespawn
:= LMS_RESPAWN_FINAL
;
3172 gLMSRespawnTime
:= gTime
+ 5000;
3175 else if (gGameSettings
.GameMode
= GM_DM
) then
3179 if gPlayers
[k
] <> nil then
3182 // survivor is the winner
3183 g_Game_Message(Format(_lc
[I_MESSAGE_LMS_WIN
], [AnsiUpperCase(FName
)]), 144);
3185 MH_SEND_GameEvent(NET_EV_LMS_WIN
, 0, FName
);
3188 gLMSRespawn
:= LMS_RESPAWN_FINAL
;
3189 gLMSRespawnTime
:= gTime
+ 5000;
3191 else if (a
= 0) then
3193 // everyone is dead, restart the map
3194 g_Game_Message(_lc
[I_GAME_WIN_DRAW
], 144);
3196 MH_SEND_GameEvent(NET_EV_LMS_DRAW
, 0, FName
);
3197 gLMSRespawn
:= LMS_RESPAWN_FINAL
;
3198 gLMSRespawnTime
:= gTime
+ 5000;
3201 if srv
and (OldLR
= LMS_RESPAWN_NONE
) and (gLMSRespawn
> LMS_RESPAWN_NONE
) then
3203 if NetMode
= NET_SERVER
then
3204 MH_SEND_GameEvent(NET_EV_LMS_WARMUP
, (gLMSRespawnTime
- gTime
) div 1000)
3206 g_Console_Add(Format(_lc
[I_MSG_WARMUP_START
], [(gLMSRespawnTime
- gTime
) div 1000]), True);
3212 MH_SEND_PlayerStats(FUID
);
3213 MH_SEND_PlayerDeath(FUID
, KillType
, t
, SpawnerUID
);
3214 if gGameSettings
.GameMode
= GM_TDM
then MH_SEND_GameStats
;
3217 if srv
and FNoRespawn
then Spectate(True);
3218 FWantsInGame
:= True;
3221 function TPlayer
.BodyInLiquid(XInc
, YInc
: Integer): Boolean;
3223 Result
:= g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
, PLAYER_RECT
.Width
,
3224 PLAYER_RECT
.Height
-20, PANEL_WATER
or PANEL_ACID1
or PANEL_ACID2
, False);
3227 function TPlayer
.BodyInAcid(XInc
, YInc
: Integer): Boolean;
3229 Result
:= g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
, PLAYER_RECT
.Width
,
3230 PLAYER_RECT
.Height
-20, PANEL_ACID1
or PANEL_ACID2
, False);
3233 procedure TPlayer
.MakeBloodSimple(Count
: Word);
3235 g_GFX_Blood(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)+8,
3236 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2),
3237 Count
div 2, 3, -1, 16, (PLAYER_RECT
.Height
*2 div 3),
3239 g_GFX_Blood(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-8,
3240 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2),
3241 Count
div 2, -3, -1, 16, (PLAYER_RECT
.Height
*2) div 3,
3245 procedure TPlayer
.MakeBloodVector(Count
: Word; VelX
, VelY
: Integer);
3247 g_GFX_Blood(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2),
3248 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2),
3249 Count
, VelX
, VelY
, 16, (PLAYER_RECT
.Height
*2) div 3,
3253 procedure TPlayer
.NextWeapon();
3258 if g_Game_IsClient
then Exit
;
3259 if FBFGFireCounter
<> -1 then Exit
;
3261 if FTime
[T_SWITCH
] > gTime
then Exit
;
3263 for i
:= WEAPON_KASTET
to WEAPON_SUPERPULEMET
do
3264 if FReloading
[i
] > 0 then Exit
;
3268 for i
:= FCurrWeap
+1 to WEAPON_SUPERPULEMET
do
3277 for i
:= WEAPON_KASTET
to FCurrWeap
-1 do
3284 FTime
[T_SWITCH
] := gTime
+156;
3286 if FCurrWeap
= WEAPON_SAW
then
3287 FSawSoundSelect
.PlayAt(FObj
.X
, FObj
.Y
);
3289 FModel
.SetWeapon(FCurrWeap
);
3291 if g_Game_IsNet
then MH_SEND_PlayerStats(FUID
);
3294 procedure TPlayer
.PrevWeapon();
3299 if g_Game_IsClient
then Exit
;
3300 if FBFGFireCounter
<> -1 then Exit
;
3302 if FTime
[T_SWITCH
] > gTime
then Exit
;
3304 for i
:= WEAPON_KASTET
to WEAPON_SUPERPULEMET
do
3305 if FReloading
[i
] > 0 then Exit
;
3309 if FCurrWeap
> 0 then
3310 for i
:= FCurrWeap
-1 downto WEAPON_KASTET
do
3319 for i
:= WEAPON_SUPERPULEMET
downto FCurrWeap
+1 do
3326 FTime
[T_SWITCH
] := gTime
+156;
3328 if FCurrWeap
= WEAPON_SAW
then
3329 FSawSoundSelect
.PlayAt(FObj
.X
, FObj
.Y
);
3331 FModel
.SetWeapon(FCurrWeap
);
3333 if g_Game_IsNet
then MH_SEND_PlayerStats(FUID
);
3336 procedure TPlayer
.SetWeapon(W
: Byte);
3338 if FCurrWeap
<> W
then
3339 if W
= WEAPON_SAW
then
3340 FSawSoundSelect
.PlayAt(FObj
.X
, FObj
.Y
);
3343 FModel
.SetWeapon(CurrWeap
);
3346 function TPlayer
.PickItem(ItemType
: Byte; respawn
: Boolean; var remove
: Boolean): Boolean;
3351 if g_Game_IsClient
then Exit
;
3353 // a = true - ìåñòî ñïàâíà ïðåäìåòà:
3354 a
:= LongBool(gGameSettings
.Options
and GAME_OPTION_WEAPONSTAY
) and respawn
;
3359 if FHealth
< PLAYER_HP_SOFT
then
3361 IncMax(FHealth
, 10, PLAYER_HP_SOFT
);
3364 if gFlash
= 2 then Inc(FPickup
, 5);
3368 if FHealth
< PLAYER_HP_SOFT
then
3370 IncMax(FHealth
, 25, PLAYER_HP_SOFT
);
3373 if gFlash
= 2 then Inc(FPickup
, 5);
3377 if FArmor
< PLAYER_AP_SOFT
then
3379 FArmor
:= PLAYER_AP_SOFT
;
3382 if gFlash
= 2 then Inc(FPickup
, 5);
3386 if FArmor
< PLAYER_AP_LIMIT
then
3388 FArmor
:= PLAYER_AP_LIMIT
;
3391 if gFlash
= 2 then Inc(FPickup
, 5);
3395 if FHealth
< PLAYER_HP_LIMIT
then
3397 IncMax(FHealth
, 100, PLAYER_HP_LIMIT
);
3400 if gFlash
= 2 then Inc(FPickup
, 5);
3404 if (FHealth
< PLAYER_HP_LIMIT
) or (FArmor
< PLAYER_AP_LIMIT
) then
3406 if FHealth
< PLAYER_HP_LIMIT
then
3407 FHealth
:= PLAYER_HP_LIMIT
;
3408 if FArmor
< PLAYER_AP_LIMIT
then
3409 FArmor
:= PLAYER_AP_LIMIT
;
3412 if gFlash
= 2 then Inc(FPickup
, 5);
3416 if (not FWeapon
[WEAPON_SAW
]) or ((not respawn
) and (gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
])) then
3418 FWeapon
[WEAPON_SAW
] := True;
3420 if gFlash
= 2 then Inc(FPickup
, 5);
3421 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
3424 ITEM_WEAPON_SHOTGUN1
:
3425 if (FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
]) or not FWeapon
[WEAPON_SHOTGUN1
] then
3427 // Íóæíî, ÷òîáû íå âçÿòü âñå ïóëè ñðàçó:
3428 if a
and FWeapon
[WEAPON_SHOTGUN1
] then Exit
;
3430 IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
3431 FWeapon
[WEAPON_SHOTGUN1
] := True;
3433 if gFlash
= 2 then Inc(FPickup
, 5);
3434 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
3437 ITEM_WEAPON_SHOTGUN2
:
3438 if (FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
]) or not FWeapon
[WEAPON_SHOTGUN2
] then
3440 if a
and FWeapon
[WEAPON_SHOTGUN2
] then Exit
;
3442 IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
3443 FWeapon
[WEAPON_SHOTGUN2
] := True;
3445 if gFlash
= 2 then Inc(FPickup
, 5);
3446 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
3449 ITEM_WEAPON_CHAINGUN
:
3450 if (FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
]) or not FWeapon
[WEAPON_CHAINGUN
] then
3452 if a
and FWeapon
[WEAPON_CHAINGUN
] then Exit
;
3454 IncMax(FAmmo
[A_BULLETS
], 50, FMaxAmmo
[A_BULLETS
]);
3455 FWeapon
[WEAPON_CHAINGUN
] := True;
3457 if gFlash
= 2 then Inc(FPickup
, 5);
3458 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
3461 ITEM_WEAPON_ROCKETLAUNCHER
:
3462 if (FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
]) or not FWeapon
[WEAPON_ROCKETLAUNCHER
] then
3464 if a
and FWeapon
[WEAPON_ROCKETLAUNCHER
] then Exit
;
3466 IncMax(FAmmo
[A_ROCKETS
], 2, FMaxAmmo
[A_ROCKETS
]);
3467 FWeapon
[WEAPON_ROCKETLAUNCHER
] := True;
3469 if gFlash
= 2 then Inc(FPickup
, 5);
3470 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
3474 if (FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
]) or not FWeapon
[WEAPON_PLASMA
] then
3476 if a
and FWeapon
[WEAPON_PLASMA
] then Exit
;
3478 IncMax(FAmmo
[A_CELLS
], 40, FMaxAmmo
[A_CELLS
]);
3479 FWeapon
[WEAPON_PLASMA
] := True;
3481 if gFlash
= 2 then Inc(FPickup
, 5);
3482 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
3486 if (FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
]) or not FWeapon
[WEAPON_BFG
] then
3488 if a
and FWeapon
[WEAPON_BFG
] then Exit
;
3490 IncMax(FAmmo
[A_CELLS
], 40, FMaxAmmo
[A_CELLS
]);
3491 FWeapon
[WEAPON_BFG
] := True;
3493 if gFlash
= 2 then Inc(FPickup
, 5);
3494 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
3497 ITEM_WEAPON_SUPERPULEMET
:
3498 if (FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
]) or not FWeapon
[WEAPON_SUPERPULEMET
] then
3500 if a
and FWeapon
[WEAPON_SUPERPULEMET
] then Exit
;
3502 IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
3503 FWeapon
[WEAPON_SUPERPULEMET
] := True;
3505 if gFlash
= 2 then Inc(FPickup
, 5);
3506 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
3510 if FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
] then
3512 IncMax(FAmmo
[A_BULLETS
], 10, FMaxAmmo
[A_BULLETS
]);
3515 if gFlash
= 2 then Inc(FPickup
, 5);
3518 ITEM_AMMO_BULLETS_BOX
:
3519 if FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
] then
3521 IncMax(FAmmo
[A_BULLETS
], 50, FMaxAmmo
[A_BULLETS
]);
3524 if gFlash
= 2 then Inc(FPickup
, 5);
3528 if FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
] then
3530 IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
3533 if gFlash
= 2 then Inc(FPickup
, 5);
3536 ITEM_AMMO_SHELLS_BOX
:
3537 if FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
] then
3539 IncMax(FAmmo
[A_SHELLS
], 25, FMaxAmmo
[A_SHELLS
]);
3542 if gFlash
= 2 then Inc(FPickup
, 5);
3546 if FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
] then
3548 IncMax(FAmmo
[A_ROCKETS
], 1, FMaxAmmo
[A_ROCKETS
]);
3551 if gFlash
= 2 then Inc(FPickup
, 5);
3554 ITEM_AMMO_ROCKET_BOX
:
3555 if FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
] then
3557 IncMax(FAmmo
[A_ROCKETS
], 5, FMaxAmmo
[A_ROCKETS
]);
3560 if gFlash
= 2 then Inc(FPickup
, 5);
3564 if FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
] then
3566 IncMax(FAmmo
[A_CELLS
], 40, FMaxAmmo
[A_CELLS
]);
3569 if gFlash
= 2 then Inc(FPickup
, 5);
3573 if FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
] then
3575 IncMax(FAmmo
[A_CELLS
], 100, FMaxAmmo
[A_CELLS
]);
3578 if gFlash
= 2 then Inc(FPickup
, 5);
3582 if not(R_ITEM_BACKPACK
in FRulez
) or
3583 (FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
]) or
3584 (FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
]) or
3585 (FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
]) or
3586 (FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
]) then
3588 FMaxAmmo
[A_BULLETS
] := 400;
3589 FMaxAmmo
[A_SHELLS
] := 100;
3590 FMaxAmmo
[A_ROCKETS
] := 100;
3591 FMaxAmmo
[A_CELLS
] := 600;
3593 if FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
] then
3594 IncMax(FAmmo
[A_BULLETS
], 10, FMaxAmmo
[A_BULLETS
]);
3595 if FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
] then
3596 IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
3597 if FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
] then
3598 IncMax(FAmmo
[A_ROCKETS
], 1, FMaxAmmo
[A_ROCKETS
]);
3599 if FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
] then
3600 IncMax(FAmmo
[A_CELLS
], 40, FMaxAmmo
[A_CELLS
]);
3602 FRulez
:= FRulez
+ [R_ITEM_BACKPACK
];
3605 if gFlash
= 2 then Inc(FPickup
, 5);
3609 if not(R_KEY_RED
in FRulez
) then
3611 Include(FRulez
, R_KEY_RED
);
3613 remove
:= (gGameSettings
.GameMode
<> GM_COOP
) and (g_Player_GetCount() < 2);
3614 if gFlash
= 2 then Inc(FPickup
, 5);
3615 if (not remove
) and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETITEM');
3619 if not(R_KEY_GREEN
in FRulez
) then
3621 Include(FRulez
, R_KEY_GREEN
);
3623 remove
:= (gGameSettings
.GameMode
<> GM_COOP
) and (g_Player_GetCount() < 2);
3624 if gFlash
= 2 then Inc(FPickup
, 5);
3625 if (not remove
) and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETITEM');
3629 if not(R_KEY_BLUE
in FRulez
) then
3631 Include(FRulez
, R_KEY_BLUE
);
3633 remove
:= (gGameSettings
.GameMode
<> GM_COOP
) and (g_Player_GetCount() < 2);
3634 if gFlash
= 2 then Inc(FPickup
, 5);
3635 if (not remove
) and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETITEM');
3639 if FMegaRulez
[MR_SUIT
] < gTime
+PLAYER_SUIT_TIME
then
3641 FMegaRulez
[MR_SUIT
] := gTime
+PLAYER_SUIT_TIME
;
3644 if gFlash
= 2 then Inc(FPickup
, 5);
3648 if FAir
< AIR_MAX
then
3653 if gFlash
= 2 then Inc(FPickup
, 5);
3658 if not (R_BERSERK
in FRulez
) then
3660 Include(FRulez
, R_BERSERK
);
3661 if FBFGFireCounter
= -1 then
3663 FCurrWeap
:= WEAPON_KASTET
;
3664 FModel
.SetWeapon(WEAPON_KASTET
);
3668 if gFlash
= 2 then Inc(FPickup
, 5);
3669 FBerserk
:= gTime
+30000;
3673 if FHealth
< PLAYER_HP_SOFT
then
3675 FHealth
:= PLAYER_HP_SOFT
;
3676 FBerserk
:= gTime
+30000;
3683 if FMegaRulez
[MR_INVUL
] < gTime
+PLAYER_INVUL_TIME
then
3685 FMegaRulez
[MR_INVUL
] := gTime
+PLAYER_INVUL_TIME
;
3688 if gFlash
= 2 then Inc(FPickup
, 5);
3692 if FHealth
< PLAYER_HP_LIMIT
then
3694 IncMax(FHealth
, 4, PLAYER_HP_LIMIT
);
3697 if gFlash
= 2 then Inc(FPickup
, 5);
3701 if FArmor
< PLAYER_AP_LIMIT
then
3703 IncMax(FArmor
, 5, PLAYER_AP_LIMIT
);
3706 if gFlash
= 2 then Inc(FPickup
, 5);
3710 if FJetFuel
< JET_MAX
then
3712 FJetFuel
:= JET_MAX
;
3715 if gFlash
= 2 then Inc(FPickup
, 5);
3719 if FMegaRulez
[MR_INVIS
] < gTime
+PLAYER_INVIS_TIME
then
3721 FMegaRulez
[MR_INVIS
] := gTime
+PLAYER_INVIS_TIME
;
3724 if gFlash
= 2 then Inc(FPickup
, 5);
3729 procedure TPlayer
.Touch();
3733 //FModel.PlaySound(MODELSOUND_PAIN, 1, FObj.X, FObj.Y);
3736 // Áðîñèòü ôëàã òîâàðèùó:
3737 if gGameSettings
.GameMode
= GM_CTF
then
3742 procedure TPlayer
.Push(vx
, vy
: Integer);
3744 if (not FPhysics
) and FGhost
then
3746 FObj
.Accel
.X
:= FObj
.Accel
.X
+ vx
;
3747 FObj
.Accel
.Y
:= FObj
.Accel
.Y
+ vy
;
3748 if g_Game_IsNet
and g_Game_IsServer
then
3749 MH_SEND_PlayerPos(True, FUID
, NET_EVERYONE
);
3752 procedure TPlayer
.Reset(Force
: Boolean);
3758 FTime
[T_RESPAWN
] := 0;
3759 FTime
[T_FLAGCAP
] := 0;
3772 FSpectator
:= False;
3775 FSpectatePlayer
:= -1;
3776 FNoRespawn
:= False;
3778 FLives
:= gGameSettings
.MaxLives
;
3783 procedure TPlayer
.SoftReset();
3789 FBFGFireCounter
:= -1;
3797 SetAction(A_STAND
, True);
3800 function TPlayer
.GetRespawnPoint(): Byte;
3805 // Íà áóäóùåå: FSpawn - èãðîê óæå èãðàë è ïåðåðîæäàåòñÿ
3807 // Îäèíî÷íàÿ èãðà/êîîïåðàòèâ
3808 if gGameSettings
.GameMode
in [GM_COOP
, GM_SINGLE
] then
3810 if (Self
= gPlayer1
) or (Self
= gPlayer2
) then
3812 // Òî÷êà ïîÿâëåíèÿ ñâîåãî èãðîêà
3813 if Self
= gPlayer1
then
3814 c
:= RESPAWNPOINT_PLAYER1
3816 c
:= RESPAWNPOINT_PLAYER2
;
3817 if g_Map_GetPointCount(c
) > 0 then
3823 // Òî÷êà ïîÿâëåíèÿ äðóãîãî èãðîêà
3824 if Self
= gPlayer1
then
3825 c
:= RESPAWNPOINT_PLAYER2
3827 c
:= RESPAWNPOINT_PLAYER1
;
3828 if g_Map_GetPointCount(c
) > 0 then
3835 // Òî÷êà ïîÿâëåíèÿ ëþáîãî èãðîêà (áîòà)
3836 if Random(2) = 0 then
3837 c
:= RESPAWNPOINT_PLAYER1
3839 c
:= RESPAWNPOINT_PLAYER2
;
3840 if g_Map_GetPointCount(c
) > 0 then
3847 // Òî÷êà ëþáîé èç êîìàíä
3848 if Random(2) = 0 then
3849 c
:= RESPAWNPOINT_RED
3851 c
:= RESPAWNPOINT_BLUE
;
3852 if g_Map_GetPointCount(c
) > 0 then
3859 c
:= RESPAWNPOINT_DM
;
3860 if g_Map_GetPointCount(c
) > 0 then
3868 if gGameSettings
.GameMode
= GM_DM
then
3871 c
:= RESPAWNPOINT_DM
;
3872 if g_Map_GetPointCount(c
) > 0 then
3878 // Òî÷êà ïîÿâëåíèÿ ëþáîãî èãðîêà
3879 if Random(2) = 0 then
3880 c
:= RESPAWNPOINT_PLAYER1
3882 c
:= RESPAWNPOINT_PLAYER2
;
3883 if g_Map_GetPointCount(c
) > 0 then
3889 // Òî÷êà ëþáîé èç êîìàíä
3890 if Random(2) = 0 then
3891 c
:= RESPAWNPOINT_RED
3893 c
:= RESPAWNPOINT_BLUE
;
3894 if g_Map_GetPointCount(c
) > 0 then
3902 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
3904 // Òî÷êà ñâîåé êîìàíäû
3905 c
:= RESPAWNPOINT_DM
;
3906 if FTeam
= TEAM_RED
then
3907 c
:= RESPAWNPOINT_RED
;
3908 if FTeam
= TEAM_BLUE
then
3909 c
:= RESPAWNPOINT_BLUE
;
3910 if g_Map_GetPointCount(c
) > 0 then
3917 c
:= RESPAWNPOINT_DM
;
3918 if g_Map_GetPointCount(c
) > 0 then
3924 // Òî÷êà ïîÿâëåíèÿ ëþáîãî èãðîêà
3925 if Random(2) = 0 then
3926 c
:= RESPAWNPOINT_PLAYER1
3928 c
:= RESPAWNPOINT_PLAYER2
;
3929 if g_Map_GetPointCount(c
) > 0 then
3935 // Òî÷êà äðóãîé êîìàíäû
3936 c
:= RESPAWNPOINT_DM
;
3937 if FTeam
= TEAM_RED
then
3938 c
:= RESPAWNPOINT_BLUE
;
3939 if FTeam
= TEAM_BLUE
then
3940 c
:= RESPAWNPOINT_RED
;
3941 if g_Map_GetPointCount(c
) > 0 then
3949 procedure TPlayer
.Respawn(Silent
: Boolean; Force
: Boolean = False);
3951 RespawnPoint
: TRespawnPoint
;
3956 if not g_Game_IsServer
then
3960 FWantsInGame
:= True;
3961 FJustTeleported
:= True;
3964 FTime
[T_RESPAWN
] := 0;
3968 // if server changes MaxLives we gotta be ready
3969 if gGameSettings
.MaxLives
= 0 then FNoRespawn
:= False;
3971 // Åùå íåëüçÿ âîçðîäèòüñÿ:
3972 if FTime
[T_RESPAWN
] > gTime
then
3975 // Ïðîñðàë âñå æèçíè:
3978 if not FSpectator
then Spectate(True);
3979 FWantsInGame
:= True;
3983 if (gGameSettings
.GameType
<> GT_SINGLE
) and (gGameSettings
.GameMode
<> GM_COOP
) then
3984 begin // "Ñâîÿ èãðà"
3985 // Áåðñåðê íå ñîõðàíÿåòñÿ ìåæäó óðîâíÿìè:
3986 FRulez
:= FRulez
-[R_BERSERK
];
3988 else // "Îäèíî÷íàÿ èãðà"/"Êîîï"
3990 // Áåðñåðê è êëþ÷è íå ñîõðàíÿþòñÿ ìåæäó óðîâíÿìè:
3991 FRulez
:= FRulez
-[R_KEY_RED
, R_KEY_GREEN
, R_KEY_BLUE
, R_BERSERK
];
3994 // Ïîëó÷àåì òî÷êó ñïàóíà èãðîêà:
3995 c
:= GetRespawnPoint();
4000 // Âîñêðåøåíèå áåç îðóæèÿ:
4003 FHealth
:= PLAYER_HP_SOFT
;
4009 for a
:= WEAPON_KASTET
to WEAPON_SUPERPULEMET
do
4011 FWeapon
[a
] := False;
4015 FWeapon
[WEAPON_PISTOL
] := True;
4016 FWeapon
[WEAPON_KASTET
] := True;
4017 FCurrWeap
:= WEAPON_PISTOL
;
4019 FModel
.SetWeapon(FCurrWeap
);
4021 for b
:= A_BULLETS
to A_CELLS
do
4024 FAmmo
[A_BULLETS
] := 50;
4026 FMaxAmmo
[A_BULLETS
] := 200;
4027 FMaxAmmo
[A_SHELLS
] := 50;
4028 FMaxAmmo
[A_ROCKETS
] := 50;
4029 FMaxAmmo
[A_CELLS
] := 300;
4031 if gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
] then
4032 FRulez
:= [R_KEY_RED
, R_KEY_GREEN
, R_KEY_BLUE
]
4037 // Ïîëó÷àåì êîîðäèíàòû òî÷êè âîçðîæäåíèÿ:
4038 if not g_Map_GetPoint(c
, RespawnPoint
) then
4040 g_FatalError(_lc
[I_GAME_ERROR_GET_SPAWN
]);
4044 // Óñòàíîâêà êîîðäèíàò è ñáðîñ âñåõ ïàðàìåòðîâ:
4045 FObj
.X
:= RespawnPoint
.X
-PLAYER_RECT
.X
;
4046 FObj
.Y
:= RespawnPoint
.Y
-PLAYER_RECT
.Y
;
4052 FDirection
:= RespawnPoint
.Direction
;
4053 if FDirection
= D_LEFT
then
4059 FBFGFireCounter
:= -1;
4064 SetAction(A_STAND
, True);
4065 FModel
.Direction
:= FDirection
;
4067 for a
:= Low(FTime
) to High(FTime
) do
4070 for a
:= Low(FMegaRulez
) to High(FMegaRulez
) do
4075 FCanJetpack
:= False;
4077 // Àíèìàöèÿ âîçðîæäåíèÿ:
4078 if (not gLoadGameMode
) and (not Silent
) then
4079 if g_Frames_Get(ID
, 'FRAMES_TELEPORT') then
4081 Anim
:= TAnimation
.Create(ID
, False, 3);
4082 g_GFX_OnceAnim(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-32,
4083 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)-32, Anim
);
4087 FSpectator
:= False;
4090 FSpectatePlayer
:= -1;
4093 if g_Game_IsNet
then
4095 MH_SEND_PlayerPos(True, FUID
, NET_EVERYONE
);
4096 MH_SEND_PlayerStats(FUID
, NET_EVERYONE
);
4098 MH_SEND_Effect(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-32,
4099 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)-32,
4104 procedure TPlayer
.Spectate(NoMove
: Boolean = False);
4107 Kill(K_EXTRAHARDKILL
, FUID
, HIT_SOME
)
4108 else if (not NoMove
) then
4110 GameX
:= gMapInfo
.Width
div 2;
4111 GameY
:= gMapInfo
.Height
div 2;
4120 FWantsInGame
:= False;
4125 if Self
= gPlayer1
then
4130 if Self
= gPlayer2
then
4137 if g_Game_IsNet
then
4138 MH_SEND_PlayerStats(FUID
);
4141 procedure TPlayer
.SwitchNoClip
;
4145 FGhost
:= not FGhost
;
4146 FPhysics
:= not FGhost
;
4158 procedure TPlayer
.Run(Direction
: TDirection
);
4162 if MAX_RUNVEL
> 8 then
4166 if Direction
= D_LEFT
then
4168 if FObj
.Vel
.X
> -MAX_RUNVEL
then
4169 FObj
.Vel
.X
:= FObj
.Vel
.X
- (MAX_RUNVEL
shr 3);
4172 if FObj
.Vel
.X
< MAX_RUNVEL
then
4173 FObj
.Vel
.X
:= FObj
.Vel
.X
+ (MAX_RUNVEL
shr 3);
4175 // Âîçìîæíî, ïèíàåì êóñêè:
4176 if (FObj
.Vel
.X
<> 0) and (gGibs
<> nil) then
4178 b
:= Abs(FObj
.Vel
.X
);
4179 if b
> 1 then b
:= b
* (Random(8 div b
) + 1);
4180 for a
:= 0 to High(gGibs
) do
4181 if gGibs
[a
].Live
and
4182 g_Obj_Collide(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
+FObj
.Rect
.Height
-4,
4183 FObj
.Rect
.Width
, 8, @gGibs
[a
].Obj
) and (Random(3) = 0) then
4185 if FObj
.Vel
.X
< 0 then
4186 g_Obj_PushA(@gGibs
[a
].Obj
, b
, Random(61)+120) // íàëåâî
4188 g_Obj_PushA(@gGibs
[a
].Obj
, b
, Random(61)); // íàïðàâî
4194 procedure TPlayer
.SeeDown();
4196 SetAction(A_SEEDOWN
);
4198 if FDirection
= D_LEFT
then FAngle
:= ANGLE_LEFTDOWN
else FAngle
:= ANGLE_RIGHTDOWN
;
4200 if FIncCam
> -120 then DecMin(FIncCam
, 5, -120);
4203 procedure TPlayer
.SeeUp();
4207 if FDirection
= D_LEFT
then FAngle
:= ANGLE_LEFTUP
else FAngle
:= ANGLE_RIGHTUP
;
4209 if FIncCam
< 120 then IncMax(FIncCam
, 5, 120);
4212 procedure TPlayer
.SetAction(Action
: Byte; Force
: Boolean = False);
4220 A_ATTACK
: Prior
:= 2;
4221 A_SEEUP
: Prior
:= 1;
4222 A_SEEDOWN
: Prior
:= 1;
4223 A_ATTACKUP
: Prior
:= 2;
4224 A_ATTACKDOWN
: Prior
:= 2;
4229 if (Prior
> FActionPrior
) or Force
then
4230 if not ((Prior
= 2) and (FCurrWeap
= WEAPON_SAW
)) then
4232 FActionPrior
:= Prior
;
4233 FActionAnim
:= Action
;
4234 FActionForce
:= Force
;
4235 FActionChanged
:= True;
4238 if Action
in [A_ATTACK
, A_ATTACKUP
, A_ATTACKDOWN
] then FModel
.SetFire(True);
4241 function TPlayer
.StayOnStep(XInc
, YInc
: Integer): Boolean;
4243 Result
:= not g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+YInc
+PLAYER_RECT
.Y
+PLAYER_RECT
.Height
-1,
4244 PLAYER_RECT
.Width
, 1, PANEL_STEP
, False)
4245 and g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+YInc
+PLAYER_RECT
.Y
+PLAYER_RECT
.Height
,
4246 PLAYER_RECT
.Width
, 1, PANEL_STEP
, False);
4249 function TPlayer
.TeleportTo(X
, Y
: Integer; silent
: Boolean; dir
: Byte): Boolean;
4256 if g_CollideLevel(X
, Y
, PLAYER_RECT
.Width
, PLAYER_RECT
.Height
) then
4258 g_Sound_PlayExAt('SOUND_GAME_NOTELEPORT', FObj
.X
, FObj
.Y
);
4259 if g_Game_IsServer
and g_Game_IsNet
then
4260 MH_SEND_Sound(FObj
.X
, FObj
.Y
, 'SOUND_GAME_NOTELEPORT');
4264 FJustTeleported
:= True;
4269 if g_Frames_Get(ID
, 'FRAMES_TELEPORT') then
4271 Anim
:= TAnimation
.Create(ID
, False, 3);
4274 g_Sound_PlayExAt('SOUND_GAME_TELEPORT', FObj
.X
, FObj
.Y
);
4275 g_GFX_OnceAnim(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-32,
4276 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)-32, Anim
);
4277 if g_Game_IsServer
and g_Game_IsNet
then
4278 MH_SEND_Effect(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-32,
4279 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)-32, 1,
4283 FObj
.X
:= X
-PLAYER_RECT
.X
;
4284 FObj
.Y
:= Y
-PLAYER_RECT
.Y
;
4285 if FLive
and FGhost
then
4291 if not g_Game_IsNet
then
4295 SetDirection(D_LEFT
);
4301 SetDirection(D_RIGHT
);
4307 if FDirection
= D_RIGHT
then
4309 SetDirection(D_LEFT
);
4314 SetDirection(D_RIGHT
);
4320 if not silent
and (Anim
<> nil) then
4322 g_GFX_OnceAnim(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-32,
4323 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)-32, Anim
);
4326 if g_Game_IsServer
and g_Game_IsNet
then
4327 MH_SEND_Effect(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-32,
4328 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)-32, 0,
4335 function nonz(a
: Single): Single;
4343 procedure TPlayer
.Update();
4346 i
, ii
, wx
, wy
, xd
, yd
, k
: Integer;
4347 blockmon
, headwater
, dospawn
: Boolean;
4352 NetServer
:= g_Game_IsNet
and g_Game_IsServer
;
4353 AnyServer
:= g_Game_IsServer
;
4355 if g_Game_IsClient
and (NetInterpLevel
> 0) then
4356 DoLerp(NetInterpLevel
+ 1)
4362 if FClientID
>= 0 then
4364 FPing
:= NetClients
[FClientID
].Peer
^.lastRoundTripTime
;
4365 if NetClients
[FClientID
].Peer
^.packetsSent
> 0 then
4366 FLoss
:= Round(100*NetClients
[FClientID
].Peer
^.packetsLost
/NetClients
[FClientID
].Peer
^.packetsSent
)
4375 if FLive
and (gFly
or FJetpack
) then
4378 if FDirection
= D_LEFT
then
4383 if FLive
and (not FGhost
) then
4385 if FKeys
[KEY_UP
].Pressed
then
4387 if FKeys
[KEY_DOWN
].Pressed
then
4391 if (not (FKeys
[KEY_UP
].Pressed
or FKeys
[KEY_DOWN
].Pressed
)) and
4394 i
:= g_basic
.Sign(FIncCam
);
4395 FIncCam
:= Abs(FIncCam
);
4396 DecMin(FIncCam
, 5, 0);
4397 FIncCam
:= FIncCam
*i
;
4400 if gTime
mod (GAME_TICK
*2) <> 0 then
4402 if (FObj
.Vel
.X
= 0) and FLive
then
4404 if FKeys
[KEY_LEFT
].Pressed
then
4406 if FKeys
[KEY_RIGHT
].Pressed
then
4411 g_Obj_Move(@FObj
, True, True, True);
4416 FActionChanged
:= False;
4420 // Let alive player do some actions
4421 if FKeys
[KEY_LEFT
].Pressed
then Run(D_LEFT
);
4422 if FKeys
[KEY_RIGHT
].Pressed
then Run(D_RIGHT
);
4423 if FKeys
[KEY_NEXTWEAPON
].Pressed
and AnyServer
then NextWeapon();
4424 if FKeys
[KEY_PREVWEAPON
].Pressed
and AnyServer
then PrevWeapon();
4425 if FKeys
[KEY_FIRE
].Pressed
and AnyServer
then Fire();
4426 if FKeys
[KEY_OPEN
].Pressed
and AnyServer
then Use();
4427 if FKeys
[KEY_JUMP
].Pressed
then Jump()
4430 if AnyServer
and FJetpack
then
4434 if NetServer
then MH_SEND_PlayerStats(FUID
);
4436 FCanJetpack
:= True;
4443 for k
:= Low(FKeys
) to KEY_CHAT
-1 do
4445 if FKeys
[k
].Pressed
then
4453 if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
4456 if (FTime
[T_RESPAWN
] <= gTime
) and
4457 gGameOn
and (not FLive
) then
4459 if (g_Player_GetCount() > 1) then
4463 gExit
:= EXIT_RESTART
;
4468 // Dead spectator actions
4471 if FKeys
[KEY_OPEN
].Pressed
and AnyServer
then Fire();
4472 if FKeys
[KEY_FIRE
].Pressed
and AnyServer
then
4476 if (FSpectatePlayer
>= High(gPlayers
)) then
4477 FSpectatePlayer
:= -1
4481 for I
:= FSpectatePlayer
+ 1 to High(gPlayers
) do
4482 if gPlayers
[I
] <> nil then
4483 if gPlayers
[I
].Live
then
4484 if gPlayers
[I
].UID
<> FUID
then
4486 FSpectatePlayer
:= I
;
4491 if not SetSpect
then FSpectatePlayer
:= -1;
4502 if FKeys
[KEY_UP
].Pressed
or FKeys
[KEY_JUMP
].Pressed
then
4504 FYTo
:= FObj
.Y
- 32;
4505 FSpectatePlayer
:= -1;
4507 if FKeys
[KEY_DOWN
].Pressed
then
4509 FYTo
:= FObj
.Y
+ 32;
4510 FSpectatePlayer
:= -1;
4512 if FKeys
[KEY_LEFT
].Pressed
then
4514 FXTo
:= FObj
.X
- 32;
4515 FSpectatePlayer
:= -1;
4517 if FKeys
[KEY_RIGHT
].Pressed
then
4519 FXTo
:= FObj
.X
+ 32;
4520 FSpectatePlayer
:= -1;
4523 if (FXTo
< -64) then
4525 else if (FXTo
> gMapInfo
.Width
+ 32) then
4526 FXTo
:= gMapInfo
.Width
+ 32;
4527 if (FYTo
< -72) then
4529 else if (FYTo
> gMapInfo
.Height
+ 32) then
4530 FYTo
:= gMapInfo
.Height
+ 32;
4534 g_Obj_Move(@FObj
, True, True, True)
4540 if (FSpectatePlayer
<= High(gPlayers
)) and (FSpectatePlayer
>= 0) then
4541 if gPlayers
[FSpectatePlayer
] <> nil then
4542 if gPlayers
[FSpectatePlayer
].Live
then
4544 FXTo
:= gPlayers
[FSpectatePlayer
].GameX
;
4545 FYTo
:= gPlayers
[FSpectatePlayer
].GameY
;
4549 blockmon
:= g_Map_CollidePanel(FObj
.X
+PLAYER_HEADRECT
.X
, FObj
.Y
+PLAYER_HEADRECT
.Y
,
4550 PLAYER_HEADRECT
.Width
, PLAYER_HEADRECT
.Height
,
4551 PANEL_BLOCKMON
, True);
4552 headwater
:= HeadInLiquid(0, 0);
4554 // Ñîïðîòèâëåíèå âîçäóõà:
4555 if (not FLive
) or not (FKeys
[KEY_LEFT
].Pressed
or FKeys
[KEY_RIGHT
].Pressed
) then
4556 if FObj
.Vel
.X
<> 0 then
4557 FObj
.Vel
.X
:= z_dec(FObj
.Vel
.X
, 1);
4559 if (FLastHit
= HIT_TRAP
) and (FPain
> 90) then FPain
:= 90;
4560 DecMin(FPain
, 5, 0);
4561 DecMin(FPickup
, 1, 0);
4563 if FLive
and (FObj
.Y
> gMapInfo
.Height
+128) and AnyServer
then
4565 // Îáíóëèòü äåéñòâèÿ ïðèìî÷åê, ÷òîáû ôîí ïðîïàë
4566 FMegaRulez
[MR_SUIT
] := 0;
4567 FMegaRulez
[MR_INVUL
] := 0;
4568 FMegaRulez
[MR_INVIS
] := 0;
4569 Kill(K_FALLKILL
, 0, HIT_FALL
);
4576 if FCurrWeap
= WEAPON_SAW
then
4577 if not (FSawSound
.IsPlaying() or FSawSoundHit
.IsPlaying() or
4578 FSawSoundSelect
.IsPlaying()) then
4579 FSawSoundIdle
.PlayAt(FObj
.X
, FObj
.Y
);
4582 if (not FJetSoundFly
.IsPlaying()) and (not FJetSoundOn
.IsPlaying()) and
4583 (not FJetSoundOff
.IsPlaying()) then
4585 FJetSoundFly
.SetPosition(0);
4586 FJetSoundFly
.PlayAt(FObj
.X
, FObj
.Y
);
4589 for b
:= WEAPON_KASTET
to WEAPON_SUPERPULEMET
do
4590 if FReloading
[b
] > 0 then
4596 if FShellTimer
> -1 then
4597 if FShellTimer
= 0 then
4599 if FShellType
= SHELL_SHELL
then
4600 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
4601 GameVelX
, GameVelY
-2, SHELL_SHELL
)
4602 else if FShellType
= SHELL_DBLSHELL
then
4604 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
4605 GameVelX
+1, GameVelY
-2, SHELL_SHELL
);
4606 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
4607 GameVelX
-1, GameVelY
-2, SHELL_SHELL
);
4610 end else Dec(FShellTimer
);
4612 if (FBFGFireCounter
> -1) then
4613 if FBFGFireCounter
= 0 then
4617 wx
:= FObj
.X
+WEAPONPOINT
[FDirection
].X
;
4618 wy
:= FObj
.Y
+WEAPONPOINT
[FDirection
].Y
;
4619 xd
:= wx
+IfThen(FDirection
= D_LEFT
, -30, 30);
4620 yd
:= wy
+firediry();
4621 g_Weapon_bfgshot(wx
, wy
, xd
, yd
, FUID
);
4622 if NetServer
then MH_SEND_PlayerFire(FUID
, WEAPON_BFG
, wx
, wy
, xd
, yd
);
4623 if (FAngle
= 0) or (FAngle
= 180) then SetAction(A_ATTACK
)
4624 else if (FAngle
= ANGLE_LEFTDOWN
) or (FAngle
= ANGLE_RIGHTDOWN
) then SetAction(A_ATTACKDOWN
)
4625 else if (FAngle
= ANGLE_LEFTUP
) or (FAngle
= ANGLE_RIGHTUP
) then SetAction(A_ATTACKUP
);
4628 FReloading
[WEAPON_BFG
] := WEAPON_RELOAD
[WEAPON_BFG
];
4629 FBFGFireCounter
:= -1;
4632 FBFGFireCounter
:= 0
4634 Dec(FBFGFireCounter
);
4636 if (FMegaRulez
[MR_SUIT
] < gTime
) and AnyServer
then
4638 b
:= g_GetAcidHit(FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+PLAYER_RECT
.Y
, PLAYER_RECT
.Width
, PLAYER_RECT
.Height
);
4640 if (b
> 0) and (gTime
mod (15*GAME_TICK
) = 0) then Damage(b
, 0, 0, 0, HIT_ACID
);
4643 if (headwater
or blockmon
) then
4649 if AnyServer
then Damage(10, 0, 0, 0, HIT_WATER
);
4652 else if (FAir
mod 31 = 0) and not blockmon
then
4654 g_GFX_Bubbles(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2), FObj
.Y
+PLAYER_RECT
.Y
-4, 5+Random(6), 8, 4);
4655 if Random(2) = 0 then
4656 g_Sound_PlayExAt('SOUND_GAME_BUBBLE1', FObj
.X
, FObj
.Y
)
4658 g_Sound_PlayExAt('SOUND_GAME_BUBBLE2', FObj
.X
, FObj
.Y
);
4660 end else if FAir
< AIR_DEF
then
4663 if FDamageBuffer
> 0 then
4665 if FDamageBuffer
>= 9 then
4669 if FDamageBuffer
< 30 then i
:= 9
4670 else if FDamageBuffer
< 100 then i
:= 18
4674 ii
:= Round(FDamageBuffer
*FHealth
/ nonz(FArmor
*(3/4)+FHealth
));
4675 FArmor
:= FArmor
-(FDamageBuffer
-ii
);
4676 FHealth
:= FHealth
-ii
;
4679 FHealth
:= FHealth
+FArmor
;
4684 if FHealth
<= 0 then
4685 if FHealth
> -30 then Kill(K_SIMPLEKILL
, FLastSpawnerUID
, FLastHit
)
4686 else if FHealth
> -50 then Kill(K_HARDKILL
, FLastSpawnerUID
, FLastHit
)
4687 else Kill(K_EXTRAHARDKILL
, FLastSpawnerUID
, FLastHit
);
4691 if FDamageBuffer
<= 20 then FModel
.PlaySound(MODELSOUND_PAIN
, 1, FObj
.X
, FObj
.Y
)
4692 else if FDamageBuffer
<= 55 then FModel
.PlaySound(MODELSOUND_PAIN
, 2, FObj
.X
, FObj
.Y
)
4693 else if FDamageBuffer
<= 120 then FModel
.PlaySound(MODELSOUND_PAIN
, 3, FObj
.X
, FObj
.Y
)
4694 else FModel
.PlaySound(MODELSOUND_PAIN
, 4, FObj
.X
, FObj
.Y
);
4701 end; // if FLive then ...
4703 if (FActionAnim
= A_PAIN
) and (FModel
.Animation
<> A_PAIN
) then
4705 FModel
.ChangeAnimation(FActionAnim
, FActionForce
);
4706 FModel
.GetCurrentAnimation
.MinLength
:= i
;
4707 FModel
.GetCurrentAnimationMask
.MinLength
:= i
;
4708 end else FModel
.ChangeAnimation(FActionAnim
, FActionForce
and (FModel
.Animation
<> A_STAND
));
4710 if (FModel
.GetCurrentAnimation
.Played
or ((not FActionChanged
) and (FModel
.Animation
= A_WALK
)))
4711 then SetAction(A_STAND
, True);
4713 if not ((FModel
.Animation
= A_WALK
) and (Abs(FObj
.Vel
.X
) < 4) and not FModel
.Fire
) then FModel
.Update
;
4715 for b
:= Low(FKeys
) to High(FKeys
) do
4716 if FKeys
[b
].Time
= 0 then FKeys
[b
].Pressed
:= False else Dec(FKeys
[b
].Time
);
4719 function TPlayer
.Collide(X
, Y
: Integer; Width
, Height
: Word): Boolean;
4721 Result
:= g_Collide(FObj
.X
+PLAYER_RECT
.X
,
4722 FObj
.Y
+PLAYER_RECT
.Y
,
4729 function TPlayer
.Collide(Panel
: TPanel
): Boolean;
4731 Result
:= g_Collide(FObj
.X
+PLAYER_RECT
.X
,
4732 FObj
.Y
+PLAYER_RECT
.Y
,
4736 Panel
.Width
, Panel
.Height
);
4739 function TPlayer
.Collide(X
, Y
: Integer): Boolean;
4741 X
:= X
-FObj
.X
-PLAYER_RECT
.X
;
4742 Y
:= Y
-FObj
.Y
-PLAYER_RECT
.Y
;
4743 Result
:= (x
>= 0) and (x
<= PLAYER_RECT
.Width
) and
4744 (y
>= 0) and (y
<= PLAYER_RECT
.Height
);
4747 function g_Player_ValidName(Name
: string): Boolean;
4753 if gPlayers
= nil then Exit
;
4755 for a
:= 0 to High(gPlayers
) do
4756 if gPlayers
[a
] <> nil then
4757 if LowerCase(Name
) = LowerCase(gPlayers
[a
].FName
) then
4764 procedure TPlayer
.SetDirection(Direction
: TDirection
);
4768 d
:= FModel
.Direction
;
4770 FModel
.Direction
:= Direction
;
4771 if d
<> Direction
then FModel
.ChangeAnimation(FModel
.Animation
, True);
4773 FDirection
:= Direction
;
4776 function TPlayer
.GetKeys(): Byte;
4780 if R_KEY_RED
in FRulez
then Result
:= KEY_RED
;
4781 if R_KEY_GREEN
in FRulez
then Result
:= Result
or KEY_GREEN
;
4782 if R_KEY_BLUE
in FRulez
then Result
:= Result
or KEY_BLUE
;
4784 if FTeam
= TEAM_RED
then Result
:= Result
or KEY_REDTEAM
;
4785 if FTeam
= TEAM_BLUE
then Result
:= Result
or KEY_BLUETEAM
;
4788 procedure TPlayer
.Use();
4792 if FTime
[T_USE
] > gTime
then Exit
;
4794 g_Triggers_PressR(FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+PLAYER_RECT
.Y
, PLAYER_RECT
.Width
,
4795 PLAYER_RECT
.Height
, FUID
, ACTIVATE_PLAYERPRESS
);
4797 for a
:= 0 to High(gPlayers
) do
4798 if (gPlayers
[a
] <> nil) and (gPlayers
[a
] <> Self
) and
4799 gPlayers
[a
].Live
and SameTeam(FUID
, gPlayers
[a
].FUID
) and
4800 g_Obj_Collide(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
,
4801 FObj
.Rect
.Width
, FObj
.Rect
.Height
, @gPlayers
[a
].FObj
) then
4803 gPlayers
[a
].Touch();
4804 if g_Game_IsNet
and g_Game_IsServer
then
4805 MH_SEND_GameEvent(NET_EV_PLAYER_TOUCH
, gPlayers
[a
].FUID
);
4808 FTime
[T_USE
] := gTime
+120;
4811 procedure TPlayer
.NetFire(Wpn
: Byte; X
, Y
, AX
, AY
: Integer; WID
: Integer = -1);
4815 WX
, WY
, XD
, YD
: Integer;
4826 if R_BERSERK
in FRulez
then
4828 //g_Weapon_punch(FObj.X+FObj.Rect.X, FObj.Y+FObj.Rect.Y, 75, FUID);
4829 obj
.X
:= FObj
.X
+FObj
.Rect
.X
;
4830 obj
.Y
:= FObj
.Y
+FObj
.Rect
.Y
;
4833 obj
.rect
.Width
:= 39;
4834 obj
.rect
.Height
:= 52;
4835 obj
.Vel
.X
:= (xd
-wx
) div 2;
4836 obj
.Vel
.Y
:= (yd
-wy
) div 2;
4837 obj
.Accel
.X
:= xd
-wx
;
4838 obj
.Accel
.y
:= yd
-wy
;
4840 if g_Weapon_Hit(@obj
, 50, FUID
, HIT_SOME
) <> 0 then
4841 g_Sound_PlayExAt('SOUND_WEAPON_HITBERSERK', FObj
.X
, FObj
.Y
)
4843 g_Sound_PlayExAt('SOUND_WEAPON_MISSBERSERK', FObj
.X
, FObj
.Y
);
4847 FPain
:= min(FPain
+ 25, 50);
4849 g_Weapon_punch(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
, 3, FUID
);
4854 if g_Weapon_chainsaw(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
,
4855 IfThen(gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
], 9, 3), FUID
) <> 0 then
4857 FSawSoundSelect
.Stop();
4859 FSawSoundHit
.PlayAt(FObj
.X
, FObj
.Y
);
4861 else if not FSawSoundHit
.IsPlaying() then
4863 FSawSoundSelect
.Stop();
4864 FSawSound
.PlayAt(FObj
.X
, FObj
.Y
);
4871 g_Sound_PlayExAt('SOUND_WEAPON_FIREPISTOL', GameX
, Gamey
);
4872 FFireAngle
:= FAngle
;
4874 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
4875 GameVelX
, GameVelY
-2, SHELL_BULLET
);
4880 g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN', Gamex
, Gamey
);
4881 FFireAngle
:= FAngle
;
4884 FShellType
:= SHELL_SHELL
;
4889 g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN2', Gamex
, Gamey
);
4890 FFireAngle
:= FAngle
;
4893 FShellType
:= SHELL_DBLSHELL
;
4898 g_Sound_PlayExAt('SOUND_WEAPON_FIRECGUN', Gamex
, Gamey
);
4899 FFireAngle
:= FAngle
;
4901 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
4902 GameVelX
, GameVelY
-2, SHELL_BULLET
);
4905 WEAPON_ROCKETLAUNCHER
:
4907 g_Weapon_Rocket(wx
, wy
, xd
, yd
, FUID
, WID
);
4908 FFireAngle
:= FAngle
;
4914 g_Weapon_Plasma(wx
, wy
, xd
, yd
, FUID
, WID
);
4915 FFireAngle
:= FAngle
;
4921 g_Weapon_BFGShot(wx
, wy
, xd
, yd
, FUID
, WID
);
4922 FFireAngle
:= FAngle
;
4926 WEAPON_SUPERPULEMET
:
4928 g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN', Gamex
, Gamey
);
4929 FFireAngle
:= FAngle
;
4931 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
4932 GameVelX
, GameVelY
-2, SHELL_SHELL
);
4938 if (FAngle
= 0) or (FAngle
= 180) then SetAction(A_ATTACK
)
4939 else if (FAngle
= ANGLE_LEFTDOWN
) or (FAngle
= ANGLE_RIGHTDOWN
) then SetAction(A_ATTACKDOWN
)
4940 else if (FAngle
= ANGLE_LEFTUP
) or (FAngle
= ANGLE_RIGHTUP
) then SetAction(A_ATTACKUP
);
4943 procedure TPlayer
.DoLerp(Level
: Integer = 2);
4945 if FObj
.X
<> FXTo
then FObj
.X
:= Lerp(FObj
.X
, FXTo
, Level
);
4946 if FObj
.Y
<> FYTo
then FObj
.Y
:= Lerp(FObj
.Y
, FYTo
, Level
);
4949 procedure TPlayer
.SetLerp(XTo
, YTo
: Integer);
4953 if NetInterpLevel
< 1 then
4963 AX
:= Abs(FXTo
- FObj
.X
);
4964 AY
:= Abs(FYTo
- FObj
.Y
);
4965 if (AX
> 32) or (AX
<= NetInterpLevel
) then
4967 if (AY
> 32) or (AY
<= NetInterpLevel
) then
4972 function TPlayer
.FullInLift(XInc
, YInc
: Integer): Integer;
4974 if g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
,
4975 PLAYER_RECT
.Width
, PLAYER_RECT
.Height
-8,
4976 PANEL_LIFTUP
, False) then Result
:= -1
4978 if g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
,
4979 PLAYER_RECT
.Width
, PLAYER_RECT
.Height
-8,
4980 PANEL_LIFTDOWN
, False) then Result
:= 1
4984 function TPlayer
.GetFlag(Flag
: Byte): Boolean;
4991 if Flag
= FLAG_NONE
then
4994 if not g_Game_IsServer
then Exit
;
4996 // Ïðèíåñ ÷óæîé ôëàã íà ñâîþ áàçó:
4997 if (Flag
= FTeam
) and
4998 (gFlags
[Flag
].State
= FLAG_STATE_NORMAL
) and
4999 (FFlag
<> FLAG_NONE
) then
5001 if FFlag
= FLAG_RED
then
5002 s
:= _lc
[I_PLAYER_FLAG_RED
]
5004 s
:= _lc
[I_PLAYER_FLAG_BLUE
];
5006 evtype
:= FLAG_STATE_SCORED
;
5008 ts
:= Format('%.4d', [gFlags
[FFlag
].CaptureTime
]);
5009 Insert('.', ts
, Length(ts
) + 1 - 3);
5010 g_Console_Add(Format(_lc
[I_PLAYER_FLAG_CAPTURE
], [FName
, s
, ts
]), True);
5012 g_Map_ResetFlag(FFlag
);
5013 g_Game_Message(Format(_lc
[I_MESSAGE_FLAG_CAPTURE
], [AnsiUpperCase(s
)]), 144);
5015 gTeamStat
[FTeam
].Goals
:= gTeamStat
[FTeam
].Goals
+ 1;
5018 if g_Game_IsNet
then
5020 MH_SEND_FlagEvent(evtype
, FFlag
, FUID
, False);
5024 gFlags
[FFlag
].CaptureTime
:= 0;
5029 // Ïîäîáðàë ñâîé ôëàã - âåðíóë åãî íà áàçó:
5030 if (Flag
= FTeam
) and
5031 (gFlags
[Flag
].State
= FLAG_STATE_DROPPED
) then
5033 if Flag
= FLAG_RED
then
5034 s
:= _lc
[I_PLAYER_FLAG_RED
]
5036 s
:= _lc
[I_PLAYER_FLAG_BLUE
];
5038 evtype
:= FLAG_STATE_RETURNED
;
5039 gFlags
[Flag
].CaptureTime
:= 0;
5041 g_Console_Add(Format(_lc
[I_PLAYER_FLAG_RETURN
], [FName
, s
]), True);
5043 g_Map_ResetFlag(Flag
);
5044 g_Game_Message(Format(_lc
[I_MESSAGE_FLAG_RETURN
], [AnsiUpperCase(s
)]), 144);
5047 if g_Game_IsNet
then
5049 MH_SEND_FlagEvent(evtype
, Flag
, FUID
, False);
5055 // Ïîäîáðàë ÷óæîé ôëàã:
5056 if (Flag
<> FTeam
) and (FTime
[T_FLAGCAP
] <= gTime
) then
5060 if Flag
= FLAG_RED
then
5061 s
:= _lc
[I_PLAYER_FLAG_RED
]
5063 s
:= _lc
[I_PLAYER_FLAG_BLUE
];
5065 evtype
:= FLAG_STATE_CAPTURED
;
5067 g_Console_Add(Format(_lc
[I_PLAYER_FLAG_GET
], [FName
, s
]), True);
5069 g_Game_Message(Format(_lc
[I_MESSAGE_FLAG_GET
], [AnsiUpperCase(s
)]), 144);
5071 gFlags
[Flag
].State
:= FLAG_STATE_CAPTURED
;
5074 if g_Game_IsNet
then
5076 MH_SEND_FlagEvent(evtype
, Flag
, FUID
, False);
5082 procedure TPlayer
.SetFlag(Flag
: Byte);
5085 if FModel
<> nil then
5086 FModel
.SetFlag(FFlag
);
5089 function TPlayer
.DropFlag(): Boolean;
5094 if (not g_Game_IsServer
) or (FFlag
= FLAG_NONE
) then
5096 FTime
[T_FLAGCAP
] := gTime
+ 2000;
5097 with gFlags
[FFlag
] do
5101 Direction
:= FDirection
;
5102 State
:= FLAG_STATE_DROPPED
;
5104 g_Obj_Push(@Obj
, (FObj
.Vel
.X
div 2)-2+Random(5),
5105 (FObj
.Vel
.Y
div 2)-2+Random(5));
5107 if FFlag
= FLAG_RED
then
5108 s
:= _lc
[I_PLAYER_FLAG_RED
]
5110 s
:= _lc
[I_PLAYER_FLAG_BLUE
];
5112 g_Console_Add(Format(_lc
[I_PLAYER_FLAG_DROP
], [FName
, s
]), True);
5113 g_Game_Message(Format(_lc
[I_MESSAGE_FLAG_DROP
], [AnsiUpperCase(s
)]), 144);
5115 if g_Game_IsNet
then
5116 MH_SEND_FlagEvent(FLAG_STATE_DROPPED
, Flag
, FUID
, False);
5122 procedure TPlayer
.GetSecret();
5127 procedure TPlayer
.PressKey(Key
: Byte; Time
: Word = 1);
5129 Assert(Key
<= High(FKeys
));
5131 FKeys
[Key
].Pressed
:= True;
5132 FKeys
[Key
].Time
:= Time
;
5135 function TPlayer
.IsKeyPressed(K
: Byte): Boolean;
5137 Result
:= FKeys
[K
].Pressed
;
5140 procedure TPlayer
.ReleaseKeys();
5144 for a
:= Low(FKeys
) to High(FKeys
) do
5146 FKeys
[a
].Pressed
:= False;
5151 procedure TPlayer
.OnDamage(Angle
: SmallInt);
5155 function TPlayer
.firediry(): Integer;
5157 if FKeys
[KEY_UP
].Pressed
then Result
:= -42
5158 else if FKeys
[KEY_DOWN
].Pressed
then Result
:= 19
5162 procedure TPlayer
.RememberState();
5166 FSavedState
.Health
:= FHealth
;
5167 FSavedState
.Armor
:= FArmor
;
5168 FSavedState
.Air
:= FAir
;
5169 FSavedState
.JetFuel
:= FJetFuel
;
5170 FSavedState
.CurrWeap
:= FCurrWeap
;
5173 FSavedState
.Ammo
[i
] := FAmmo
[i
];
5175 FSavedState
.MaxAmmo
[i
] := FMaxAmmo
[i
];
5177 FSavedState
.Rulez
:= FRulez
;
5178 FSavedState
.WaitRecall
:= True;
5181 procedure TPlayer
.RecallState();
5185 if not FSavedState
.WaitRecall
then Exit
;
5187 FHealth
:= FSavedState
.Health
;
5188 FArmor
:= FSavedState
.Armor
;
5189 FAir
:= FSavedState
.Air
;
5190 FJetFuel
:= FSavedState
.JetFuel
;
5191 FCurrWeap
:= FSavedState
.CurrWeap
;
5194 FAmmo
[i
] := FSavedState
.Ammo
[i
];
5196 FMaxAmmo
[i
] := FSavedState
.MaxAmmo
[i
];
5198 FRulez
:= FSavedState
.Rulez
;
5199 FSavedState
.WaitRecall
:= False;
5201 if gGameSettings
.GameType
= GT_SERVER
then
5202 MH_SEND_PlayerStats(FUID
);
5205 procedure TPlayer
.SaveState(var Mem
: TBinMemoryWriter
);
5217 Mem
:= TBinMemoryWriter
.Create(i
);
5219 // Ñèãíàòóðà èãðîêà:
5220 sig
:= PLAYER_SIGNATURE
; // 'PLYR'
5221 Mem
.WriteDWORD(sig
);
5223 Mem
.WriteBoolean(FIamBot
);
5225 Mem
.WriteWord(FUID
);
5227 Mem
.WriteString(FName
, 32);
5229 Mem
.WriteByte(FTeam
);
5231 Mem
.WriteBoolean(FLive
);
5232 // Èçðàñõîäîâàë ëè âñå æèçíè:
5233 Mem
.WriteBoolean(FNoRespawn
);
5235 if FDirection
= D_LEFT
then
5241 Mem
.WriteInt(FHealth
);
5243 Mem
.WriteByte(FLives
);
5245 Mem
.WriteInt(FArmor
);
5249 Mem
.WriteInt(FJetFuel
);
5251 Mem
.WriteInt(FPain
);
5253 Mem
.WriteInt(FKills
);
5255 Mem
.WriteInt(FMonsterKills
);
5257 Mem
.WriteInt(FFrags
);
5259 Mem
.WriteByte(FFragCombo
);
5260 // Âðåìÿ ïîñëåäíåãî ôðàãà:
5261 Mem
.WriteDWORD(FLastFrag
);
5263 Mem
.WriteInt(FDeath
);
5264 // Êàêîé ôëàã íåñåò:
5265 Mem
.WriteByte(FFlag
);
5267 Mem
.WriteInt(FSecrets
);
5269 Mem
.WriteByte(FCurrWeap
);
5270 // Âðåìÿ çàðÿäêè BFG:
5271 Mem
.WriteSmallInt(FBFGFireCounter
);
5273 Mem
.WriteInt(FDamageBuffer
);
5274 // Ïîñëåäíèé óäàðèâøèé:
5275 Mem
.WriteWord(FLastSpawnerUID
);
5276 // Òèï ïîñëåäíåãî ïîëó÷åííîãî óðîíà:
5277 Mem
.WriteByte(FLastHit
);
5279 Obj_SaveState(@FObj
, Mem
);
5280 // Òåêóùåå êîëè÷åñòâî ïàòðîíîâ:
5281 for i
:= A_BULLETS
to A_CELLS
do
5282 Mem
.WriteWord(FAmmo
[i
]);
5283 // Ìàêñèìàëüíîå êîëè÷åñòâî ïàòðîíîâ:
5284 for i
:= A_BULLETS
to A_CELLS
do
5285 Mem
.WriteWord(FMaxAmmo
[i
]);
5287 for i
:= WEAPON_KASTET
to WEAPON_SUPERPULEMET
do
5288 Mem
.WriteBoolean(FWeapon
[i
]);
5289 // Âðåìÿ ïåðåçàðÿäêè îðóæèÿ:
5290 for i
:= WEAPON_KASTET
to WEAPON_SUPERPULEMET
do
5291 Mem
.WriteWord(FReloading
[i
]);
5293 if R_ITEM_BACKPACK
in FRulez
then
5298 // Íàëè÷èå êðàñíîãî êëþ÷à:
5299 if R_KEY_RED
in FRulez
then
5304 // Íàëè÷èå çåëåíîãî êëþ÷à:
5305 if R_KEY_GREEN
in FRulez
then
5310 // Íàëè÷èå ñèíåãî êëþ÷à:
5311 if R_KEY_BLUE
in FRulez
then
5316 // Íàëè÷èå áåðñåðêà:
5317 if R_BERSERK
in FRulez
then
5322 // Âðåìÿ äåéñòâèÿ ñïåöèàëüíûõ ïðåäìåòîâ:
5323 for i
:= MR_SUIT
to MR_MAX
do
5324 Mem
.WriteDWORD(FMegaRulez
[i
]);
5325 // Âðåìÿ äî ïîâòîðíîãî ðåñïàóíà, ñìåíû îðóæèÿ, èñîëüçîâàíèÿ, çàõâàòà ôëàãà:
5326 for i
:= T_RESPAWN
to T_FLAGCAP
do
5327 Mem
.WriteDWORD(FTime
[i
]);
5330 Mem
.WriteString(str
);
5340 procedure TPlayer
.LoadState(var Mem
: TBinMemoryReader
);
5350 // Ñèãíàòóðà èãðîêà:
5352 if sig
<> PLAYER_SIGNATURE
then // 'PLYR'
5354 raise EBinSizeError
.Create('TPlayer.LoadState: Wrong Player Signature');
5357 Mem
.ReadBoolean(FIamBot
);
5361 Mem
.ReadString(str
);
5362 if (Self
<> gPlayer1
) and (Self
<> gPlayer2
) then
5365 Mem
.ReadByte(FTeam
);
5367 Mem
.ReadBoolean(FLive
);
5368 // Èçðàñõîäîâàë ëè âñå æèçíè:
5369 Mem
.ReadBoolean(FNoRespawn
);
5373 FDirection
:= D_LEFT
5375 FDirection
:= D_RIGHT
;
5377 Mem
.ReadInt(FHealth
);
5379 Mem
.ReadByte(FLives
);
5381 Mem
.ReadInt(FArmor
);
5385 Mem
.ReadInt(FJetFuel
);
5389 Mem
.ReadInt(FKills
);
5391 Mem
.ReadInt(FMonsterKills
);
5393 Mem
.ReadInt(FFrags
);
5395 Mem
.ReadByte(FFragCombo
);
5396 // Âðåìÿ ïîñëåäíåãî ôðàãà:
5397 Mem
.ReadDWORD(FLastFrag
);
5399 Mem
.ReadInt(FDeath
);
5400 // Êàêîé ôëàã íåñåò:
5401 Mem
.ReadByte(FFlag
);
5403 Mem
.ReadInt(FSecrets
);
5405 Mem
.ReadByte(FCurrWeap
);
5406 // Âðåìÿ çàðÿäêè BFG:
5407 Mem
.ReadSmallInt(FBFGFireCounter
);
5409 Mem
.ReadInt(FDamageBuffer
);
5410 // Ïîñëåäíèé óäàðèâøèé:
5411 Mem
.ReadWord(FLastSpawnerUID
);
5412 // Òèï ïîñëåäíåãî ïîëó÷åííîãî óðîíà:
5413 Mem
.ReadByte(FLastHit
);
5415 Obj_LoadState(@FObj
, Mem
);
5416 // Òåêóùåå êîëè÷åñòâî ïàòðîíîâ:
5417 for i
:= A_BULLETS
to A_CELLS
do
5418 Mem
.ReadWord(FAmmo
[i
]);
5419 // Ìàêñèìàëüíîå êîëè÷åñòâî ïàòðîíîâ:
5420 for i
:= A_BULLETS
to A_CELLS
do
5421 Mem
.ReadWord(FMaxAmmo
[i
]);
5423 for i
:= WEAPON_KASTET
to WEAPON_SUPERPULEMET
do
5424 Mem
.ReadBoolean(FWeapon
[i
]);
5425 // Âðåìÿ ïåðåçàðÿäêè îðóæèÿ:
5426 for i
:= WEAPON_KASTET
to WEAPON_SUPERPULEMET
do
5427 Mem
.ReadWord(FReloading
[i
]);
5431 Include(FRulez
, R_ITEM_BACKPACK
);
5432 // Íàëè÷èå êðàñíîãî êëþ÷à:
5435 Include(FRulez
, R_KEY_RED
);
5436 // Íàëè÷èå çåëåíîãî êëþ÷à:
5439 Include(FRulez
, R_KEY_GREEN
);
5440 // Íàëè÷èå ñèíåãî êëþ÷à:
5443 Include(FRulez
, R_KEY_BLUE
);
5444 // Íàëè÷èå áåðñåðêà:
5447 Include(FRulez
, R_BERSERK
);
5448 // Âðåìÿ äåéñòâèÿ ñïåöèàëüíûõ ïðåäìåòîâ:
5449 for i
:= MR_SUIT
to MR_MAX
do
5450 Mem
.ReadDWORD(FMegaRulez
[i
]);
5451 // Âðåìÿ äî ïîâòîðíîãî ðåñïàóíà, ñìåíû îðóæèÿ, èñîëüçîâàíèÿ, çàõâàòà ôëàãà:
5452 for i
:= T_RESPAWN
to T_FLAGCAP
do
5453 Mem
.ReadDWORD(FTime
[i
]);
5455 Mem
.ReadString(str
);
5457 Mem
.ReadByte(FColor
.R
);
5458 Mem
.ReadByte(FColor
.G
);
5459 Mem
.ReadByte(FColor
.B
);
5460 if Self
= gPlayer1
then
5462 str
:= gPlayer1Settings
.Model
;
5463 FColor
:= gPlayer1Settings
.Color
;
5465 if Self
= gPlayer2
then
5467 str
:= gPlayer2Settings
.Model
;
5468 FColor
:= gPlayer2Settings
.Color
;
5470 // Îáíîâëÿåì ìîäåëü èãðîêà:
5472 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
5473 FModel
.Color
:= TEAMCOLOR
[FTeam
]
5475 FModel
.Color
:= FColor
;
5478 procedure TPlayer
.AllRulez(Health
: Boolean);
5484 FHealth
:= PLAYER_HP_LIMIT
;
5485 FArmor
:= PLAYER_AP_LIMIT
;
5489 for a
:= WEAPON_KASTET
to WEAPON_SUPERPULEMET
do FWeapon
[a
] := True;
5490 for a
:= A_BULLETS
to A_CELLS
do FAmmo
[a
] := 30000;
5491 FRulez
:= FRulez
+[R_KEY_RED
, R_KEY_GREEN
, R_KEY_BLUE
];
5494 procedure TPlayer
.RestoreHealthArmor();
5496 FHealth
:= PLAYER_HP_LIMIT
;
5497 FArmor
:= PLAYER_AP_LIMIT
;
5500 procedure TPlayer
.FragCombo();
5504 if (gGameSettings
.GameMode
in [GM_COOP
, GM_SINGLE
]) or g_Game_IsClient
then
5506 if gTime
- FLastFrag
< FRAG_COMBO_TIME
then
5508 if FFragCombo
< 5 then
5510 Param
:= FUID
or (FFragCombo
shl 16);
5511 if (FComboEvnt
>= Low(gDelayedEvents
)) and
5512 (FComboEvnt
<= High(gDelayedEvents
)) and
5513 gDelayedEvents
[FComboEvnt
].Pending
and
5514 (gDelayedEvents
[FComboEvnt
].DEType
= DE_KILLCOMBO
) and
5515 (gDelayedEvents
[FComboEvnt
].DENum
and $FFFF = FUID
) then
5517 gDelayedEvents
[FComboEvnt
].Time
:= gTime
+ 500;
5518 gDelayedEvents
[FComboEvnt
].DENum
:= Param
;
5521 FComboEvnt
:= g_Game_DelayEvent(DE_KILLCOMBO
, 500, Param
);
5529 procedure TPlayer
.GiveItem(ItemType
: Byte);
5533 if FMegaRulez
[MR_SUIT
] < gTime
+PLAYER_SUIT_TIME
then
5535 FMegaRulez
[MR_SUIT
] := gTime
+PLAYER_SUIT_TIME
;
5539 if FAir
< AIR_MAX
then
5546 if not (R_BERSERK
in FRulez
) then
5548 Include(FRulez
, R_BERSERK
);
5549 if FBFGFireCounter
< 1 then
5551 FCurrWeap
:= WEAPON_KASTET
;
5552 FModel
.SetWeapon(WEAPON_KASTET
);
5556 FBerserk
:= gTime
+30000;
5558 if FHealth
< PLAYER_HP_SOFT
then
5560 FHealth
:= PLAYER_HP_SOFT
;
5561 FBerserk
:= gTime
+30000;
5566 if FMegaRulez
[MR_INVUL
] < gTime
+PLAYER_INVUL_TIME
then
5568 FMegaRulez
[MR_INVUL
] := gTime
+PLAYER_INVUL_TIME
;
5572 if FMegaRulez
[MR_INVIS
] < gTime
+PLAYER_INVIS_TIME
then
5574 FMegaRulez
[MR_INVIS
] := gTime
+PLAYER_INVIS_TIME
;
5578 if FJetFuel
< JET_MAX
then
5580 FJetFuel
:= JET_MAX
;
5586 if g_Game_IsNet
and g_Game_IsServer
then
5587 MH_SEND_PlayerStats(FUID
);
5590 procedure TPlayer
.FlySmoke(Times
: DWORD
= 1);
5595 if (Random(5) = 1) and (Times
= 1) then
5598 if BodyInLiquid(0, 0) then
5600 g_GFX_Bubbles(Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2)+Random(3)-1,
5601 Obj
.Y
+Obj
.Rect
.Height
+8, 1, 8, 4);
5602 if Random(2) = 0 then
5603 g_Sound_PlayExAt('SOUND_GAME_BUBBLE1', FObj
.X
, FObj
.Y
)
5605 g_Sound_PlayExAt('SOUND_GAME_BUBBLE2', FObj
.X
, FObj
.Y
);
5609 if g_Frames_Get(id
, 'FRAMES_SMOKE') then
5611 for i
:= 1 to Times
do
5613 Anim
:= TAnimation
.Create(id
, False, 3);
5615 g_GFX_OnceAnim(Obj
.X
+Obj
.Rect
.X
+Random(Obj
.Rect
.Width
+Times
*2)-(Anim
.Width
div 2),
5616 Obj
.Y
+Obj
.Rect
.Height
-4+Random(8+Times
*2), Anim
, ONCEANIM_SMOKE
);
5622 procedure TPlayer
.PauseSounds(Enable
: Boolean);
5624 FSawSound
.Pause(Enable
);
5625 FSawSoundIdle
.Pause(Enable
);
5626 FSawSoundHit
.Pause(Enable
);
5627 FSawSoundSelect
.Pause(Enable
);
5632 constructor TCorpse
.Create(X
, Y
: Integer; ModelName
: String; aMess
: Boolean);
5637 FObj
.Rect
:= PLAYER_CORPSERECT
;
5638 FModelName
:= ModelName
;
5643 FState
:= CORPSE_STATE_MESS
;
5644 g_PlayerModel_GetAnim(ModelName
, A_DIE2
, FAnimation
, FAnimationMask
);
5648 FState
:= CORPSE_STATE_NORMAL
;
5649 g_PlayerModel_GetAnim(ModelName
, A_DIE1
, FAnimation
, FAnimationMask
);
5653 destructor TCorpse
.Destroy();
5660 procedure TCorpse
.Damage(Value
: Word; vx
, vy
: Integer);
5664 if FState
= CORPSE_STATE_REMOVEME
then
5667 FDamage
:= FDamage
+ Value
;
5669 if FDamage
> 150 then
5671 if FAnimation
<> nil then
5676 FState
:= CORPSE_STATE_REMOVEME
;
5678 g_Player_CreateGibs(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
5679 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2),
5680 FModelName
, FColor
);
5681 // Çâóê ìÿñà îò òðóïà:
5682 pm
:= g_PlayerModel_Get(FModelName
);
5683 pm
.PlaySound(MODELSOUND_DIE
, 5, FObj
.X
, FObj
.Y
);
5689 FObj
.Vel
.X
:= FObj
.Vel
.X
+ vx
;
5690 FObj
.Vel
.Y
:= FObj
.Vel
.Y
+ vy
;
5691 g_GFX_Blood(FObj
.X
+PLAYER_CORPSERECT
.X
+(PLAYER_CORPSERECT
.Width
div 2),
5692 FObj
.Y
+PLAYER_CORPSERECT
.Y
+(PLAYER_CORPSERECT
.Height
div 2),
5693 Value
, vx
, vy
, 16, (PLAYER_CORPSERECT
.Height
*2) div 3,
5698 procedure TCorpse
.Draw();
5700 if FState
= CORPSE_STATE_REMOVEME
then
5703 if FAnimation
<> nil then
5704 FAnimation
.Draw(FObj
.X
, FObj
.Y
, M_NONE
);
5706 if FAnimationMask
<> nil then
5709 FAnimationMask
.Draw(FObj
.X
, FObj
.Y
, M_NONE
);
5716 procedure TCorpse
.Update();
5720 if FState
= CORPSE_STATE_REMOVEME
then
5723 if gTime
mod (GAME_TICK
*2) <> 0 then
5725 g_Obj_Move(@FObj
, True, True, True);
5730 // Ñîïðîòèâëåíèå âîçäóõà äëÿ òðóïà:
5731 FObj
.Vel
.X
:= z_dec(FObj
.Vel
.X
, 1);
5733 st
:= g_Obj_Move(@FObj
, True, True, True);
5735 if WordBool(st
and MOVE_FALLOUT
) then
5737 FState
:= CORPSE_STATE_REMOVEME
;
5741 if FAnimation
<> nil then
5742 FAnimation
.Update();
5743 if FAnimationMask
<> nil then
5744 FAnimationMask
.Update();
5747 procedure TCorpse
.SaveState(var Mem
: TBinMemoryWriter
);
5756 sig
:= CORPSE_SIGNATURE
; // 'CORP'
5757 Mem
.WriteDWORD(sig
);
5759 Mem
.WriteByte(FState
);
5760 // Íàêîïëåííûé óðîí:
5761 Mem
.WriteByte(FDamage
);
5763 Mem
.WriteByte(FColor
.R
);
5764 Mem
.WriteByte(FColor
.G
);
5765 Mem
.WriteByte(FColor
.B
);
5767 Obj_SaveState(@FObj
, Mem
);
5768 // Åñòü ëè àíèìàöèÿ:
5769 anim
:= FAnimation
<> nil;
5770 Mem
.WriteBoolean(anim
);
5771 // Åñëè åñòü - ñîõðàíÿåì:
5773 FAnimation
.SaveState(Mem
);
5774 // Åñòü ëè ìàñêà àíèìàöèè:
5775 anim
:= FAnimationMask
<> nil;
5776 Mem
.WriteBoolean(anim
);
5777 // Åñëè åñòü - ñîõðàíÿåì:
5779 FAnimationMask
.SaveState(Mem
);
5782 procedure TCorpse
.LoadState(var Mem
: TBinMemoryReader
);
5792 if sig
<> CORPSE_SIGNATURE
then // 'CORP'
5794 raise EBinSizeError
.Create('TCorpse.LoadState: Wrong Corpse Signature');
5797 Mem
.ReadByte(FState
);
5798 // Íàêîïëåííûé óðîí:
5799 Mem
.ReadByte(FDamage
);
5801 Mem
.ReadByte(FColor
.R
);
5802 Mem
.ReadByte(FColor
.G
);
5803 Mem
.ReadByte(FColor
.B
);
5805 Obj_LoadState(@FObj
, Mem
);
5806 // Åñòü ëè àíèìàöèÿ:
5807 Mem
.ReadBoolean(anim
);
5808 // Åñëè åñòü - çàãðóæàåì:
5811 Assert(FAnimation
<> nil, 'TCorpse.LoadState: no FAnimation');
5812 FAnimation
.LoadState(Mem
);
5814 // Åñòü ëè ìàñêà àíèìàöèè:
5815 Mem
.ReadBoolean(anim
);
5816 // Åñëè åñòü - çàãðóæàåì:
5819 Assert(FAnimationMask
<> nil, 'TCorpse.LoadState: no FAnimationMask');
5820 FAnimationMask
.LoadState(Mem
);
5826 constructor TBot
.Create();
5833 FSpectator
:= False;
5840 for a
:= WEAPON_KASTET
to WEAPON_SUPERPULEMET
do
5842 FDifficult
.WeaponPrior
[a
] := WEAPON_PRIOR1
[a
];
5843 FDifficult
.CloseWeaponPrior
[a
] := WEAPON_PRIOR2
[a
];
5844 //FDifficult.SafeWeaponPrior[a] := WEAPON_PRIOR3[a];
5848 destructor TBot
.Destroy();
5851 inherited Destroy();
5854 procedure TBot
.Draw();
5858 //if FTargetUID <> 0 then e_DrawLine(1, FObj.X, FObj.Y, g_Player_Get(FTargetUID).FObj.X,
5859 // g_Player_Get(FTargetUID).FObj.Y, 255, 0, 0);
5862 procedure TBot
.Respawn(Silent
: Boolean; Force
: Boolean = False);
5864 inherited Respawn(Silent
, Force
);
5867 FSelectedWeapon
:= FCurrWeap
;
5871 procedure TBot
.UpdateCombat();
5884 TTargetRecord
= array of TTarget
;
5886 function Compare(a
, b
: TTarget
): Integer;
5888 if a
.Line
and not b
.Line
then // A íà ëèíèè îãíÿ
5891 if not a
.Line
and b
.Line
then // B íà ëèíèè îãíÿ
5893 else // È A, è B íà ëèíèè èëè íå íà ëèíèè îãíÿ
5894 if (a
.Line
and b
.Line
) or ((not a
.Line
) and (not b
.Line
)) then
5896 if a
.Dist
> b
.Dist
then // B áëèæå
5898 else // A áëèæå èëè ðàâíîóäàëåííî ñ B
5901 else // Ñòðàííî -> A
5906 a
, x1
, y1
, x2
, y2
: Integer;
5907 targets
: TTargetRecord
;
5909 Target
, BestTarget
: TTarget
;
5910 firew
, fireh
: Integer;
5914 vsPlayer
, vsMonster
, ok
: Boolean;
5916 vsPlayer
:= LongBool(gGameSettings
.Options
and GAME_OPTION_BOTVSPLAYER
);
5917 vsMonster
:= LongBool(gGameSettings
.Options
and GAME_OPTION_BOTVSMONSTER
);
5919 // Åñëè òåêóùåå îðóæèå íå òî, ÷òî íóæíî, òî ìåíÿåì:
5920 if FCurrWeap
<> FSelectedWeapon
then
5923 // Åñëè íóæíî ñòðåëÿòü è íóæíîå îðóæèå, òî íàæàòü "Ñòðåëÿòü":
5924 if (GetAIFlag('NEEDFIRE') <> '') and (FCurrWeap
= FSelectedWeapon
) then
5926 RemoveAIFlag('NEEDFIRE');
5929 WEAPON_PLASMA
, WEAPON_SUPERPULEMET
, WEAPON_CHAINGUN
: PressKey(KEY_FIRE
, 20);
5930 WEAPON_SAW
, WEAPON_KASTET
, WEAPON_MEGAKASTET
: PressKey(KEY_FIRE
, 40);
5931 else PressKey(KEY_FIRE
);
5935 // Êîîðäèíàòû ñòâîëà:
5936 x1
:= FObj
.X
+ WEAPONPOINT
[FDirection
].X
;
5937 y1
:= FObj
.Y
+ WEAPONPOINT
[FDirection
].Y
;
5939 Target
.UID
:= FTargetUID
;
5942 if Target
.UID
<> 0 then
5943 begin // Öåëü åñòü - íàñòðàèâàåì
5944 if (g_GetUIDType(Target
.UID
) = UID_PLAYER
) and
5947 with g_Player_Get(Target
.UID
) do
5949 if (@FObj
) <> nil then
5956 Target
.cX
:= Target
.X
+ PLAYER_RECT_CX
;
5957 Target
.cY
:= Target
.Y
+ PLAYER_RECT_CY
;
5958 Target
.Rect
:= PLAYER_RECT
;
5959 Target
.Visible
:= g_TraceVector(x1
, y1
, Target
.cX
, Target
.cY
);
5960 Target
.Line
:= (y1
+4 < Target
.Y
+PLAYER_RECT
.Y
+PLAYER_RECT
.Height
) and
5961 (y1
-4 > Target
.Y
+PLAYER_RECT
.Y
);
5962 Target
.IsPlayer
:= True;
5966 if (g_GetUIDType(Target
.UID
) = UID_MONSTER
) and
5969 mon
:= g_Monsters_Get(Target
.UID
);
5972 Target
.X
:= mon
.Obj
.X
;
5973 Target
.Y
:= mon
.Obj
.Y
;
5975 Target
.cX
:= Target
.X
+ mon
.Obj
.Rect
.X
+ (mon
.Obj
.Rect
.Width
div 2);
5976 Target
.cY
:= Target
.Y
+ mon
.Obj
.Rect
.Y
+ (mon
.Obj
.Rect
.Height
div 2);
5977 Target
.Rect
:= mon
.Obj
.Rect
;
5978 Target
.Visible
:= g_TraceVector(x1
, y1
, Target
.cX
, Target
.cY
);
5979 Target
.Line
:= (y1
+4 < Target
.Y
+ mon
.Obj
.Rect
.Y
+ mon
.Obj
.Rect
.Height
) and
5980 (y1
-4 > Target
.Y
+ mon
.Obj
.Rect
.Y
);
5981 Target
.IsPlayer
:= False;
5988 begin // Öåëè íåò - îáíóëÿåì
5993 Target
.Visible
:= False;
5994 Target
.Line
:= False;
5995 Target
.IsPlayer
:= False;
6000 // Åñëè öåëü íå âèäèìà èëè íå íà ëèíèè îãíÿ, òî èùåì âñå âîçìîæíûå öåëè:
6001 if (not Target
.Line
) or (not Target
.Visible
) then
6005 for a
:= 0 to High(gPlayers
) do
6006 if (gPlayers
[a
] <> nil) and (gPlayers
[a
].Live
) and
6007 (gPlayers
[a
].FUID
<> FUID
) and
6008 (not SameTeam(FUID
, gPlayers
[a
].FUID
)) and
6009 (not gPlayers
[a
].NoTarget
) and
6010 (gPlayers
[a
].FMegaRulez
[MR_INVIS
] < gTime
) then
6012 if not TargetOnScreen(gPlayers
[a
].FObj
.X
+ PLAYER_RECT
.X
,
6013 gPlayers
[a
].FObj
.Y
+ PLAYER_RECT
.Y
) then
6016 x2
:= gPlayers
[a
].FObj
.X
+ PLAYER_RECT_CX
;
6017 y2
:= gPlayers
[a
].FObj
.Y
+ PLAYER_RECT_CY
;
6019 // Åñëè èãðîê íà ýêðàíå è íå ïðèêðûò ñòåíîé:
6020 if g_TraceVector(x1
, y1
, x2
, y2
) then
6022 // Äîáàâëÿåì ê ñïèñêó âîçìîæíûõ öåëåé:
6023 SetLength(targets
, Length(targets
)+1);
6024 with targets
[High(targets
)] do
6026 UID
:= gPlayers
[a
].FUID
;
6027 X
:= gPlayers
[a
].FObj
.X
;
6028 Y
:= gPlayers
[a
].FObj
.Y
;
6031 Rect
:= PLAYER_RECT
;
6032 Dist
:= g_PatchLength(x1
, y1
, x2
, y2
);
6033 Line
:= (y1
+4 < Target
.Y
+PLAYER_RECT
.Y
+PLAYER_RECT
.Height
) and
6034 (y1
-4 > Target
.Y
+PLAYER_RECT
.Y
);
6042 if vsMonster
and (gMonsters
<> nil) then
6043 for a
:= 0 to High(gMonsters
) do
6044 if (gMonsters
[a
] <> nil) and (gMonsters
[a
].Live
) and
6045 (gMonsters
[a
].MonsterType
<> MONSTER_BARREL
) then
6047 mon
:= gMonsters
[a
];
6049 if not TargetOnScreen(mon
.Obj
.X
+ mon
.Obj
.Rect
.X
,
6050 mon
.Obj
.Y
+ mon
.Obj
.Rect
.Y
) then
6053 x2
:= mon
.Obj
.X
+ mon
.Obj
.Rect
.X
+ (mon
.Obj
.Rect
.Width
div 2);
6054 y2
:= mon
.Obj
.Y
+ mon
.Obj
.Rect
.Y
+ (mon
.Obj
.Rect
.Height
div 2);
6056 // Åñëè ìîíñòð íà ýêðàíå è íå ïðèêðûò ñòåíîé:
6057 if g_TraceVector(x1
, y1
, x2
, y2
) then
6059 // Äîáàâëÿåì ê ñïèñêó âîçìîæíûõ öåëåé:
6060 SetLength(targets
, Length(targets
)+1);
6061 with targets
[High(targets
)] do
6068 Rect
:= mon
.Obj
.Rect
;
6069 Dist
:= g_PatchLength(x1
, y1
, x2
, y2
);
6070 Line
:= (y1
+4 < Target
.Y
+ mon
.Obj
.Rect
.Y
+ mon
.Obj
.Rect
.Height
) and
6071 (y1
-4 > Target
.Y
+ mon
.Obj
.Rect
.Y
);
6079 // Åñëè åñòü âîçìîæíûå öåëè:
6080 // (Âûáèðàåì ëó÷øóþ, ìåíÿåì îðóæèå è áåæèì ê íåé/îò íåå)
6081 if targets
<> nil then
6083 // Âûáèðàåì íàèëó÷øóþ öåëü:
6084 BestTarget
:= targets
[0];
6085 if Length(targets
) > 1 then
6086 for a
:= 1 to High(targets
) do
6087 if Compare(BestTarget
, targets
[a
]) = 1 then
6088 BestTarget
:= targets
[a
];
6090 // Åñëè ëó÷øàÿ öåëü "âèäíåå" òåêóùåé, òî òåêóùàÿ := ëó÷øàÿ:
6091 if ((not Target
.Visible
) and BestTarget
.Visible
and (Target
.UID
<> BestTarget
.UID
)) or
6092 ((not Target
.Line
) and BestTarget
.Line
and BestTarget
.Visible
) then
6094 Target
:= BestTarget
;
6096 if (Healthy() = 3) or ((Healthy() = 2)) then
6097 begin // Åñëè çäîðîâû - äîãîíÿåì
6098 if ((RunDirection() = D_LEFT
) and (Target
.X
> FObj
.X
)) then
6099 SetAIFlag('GORIGHT', '1');
6100 if ((RunDirection() = D_RIGHT
) and (Target
.X
< FObj
.X
)) then
6101 SetAIFlag('GOLEFT', '1');
6104 begin // Åñëè ïîáèòû - óáåãàåì
6105 if ((RunDirection() = D_LEFT
) and (Target
.X
< FObj
.X
)) then
6106 SetAIFlag('GORIGHT', '1');
6107 if ((RunDirection() = D_RIGHT
) and (Target
.X
> FObj
.X
)) then
6108 SetAIFlag('GOLEFT', '1');
6111 // Âûáèðàåì îðóæèå íà îñíîâå ðàññòîÿíèÿ è ïðèîðèòåòîâ:
6112 SelectWeapon(Abs(x1
-Target
.cX
));
6117 // (Äîãîíÿåì/óáåãàåì, ñòðåëÿåì ïî íàïðàâëåíèþ ê öåëè)
6118 // (Åñëè öåëü äàëåêî, òî õâàòèò ñëåäèòü çà íåé)
6119 if Target
.UID
<> 0 then
6121 if not TargetOnScreen(Target
.X
+ Target
.Rect
.X
,
6122 Target
.Y
+ Target
.Rect
.Y
) then
6123 begin // Öåëü ñáåæàëà ñ "ýêðàíà"
6124 if (Healthy() = 3) or ((Healthy() = 2)) then
6125 begin // Åñëè çäîðîâû - äîãîíÿåì
6126 if ((RunDirection() = D_LEFT
) and (Target
.X
> FObj
.X
)) then
6127 SetAIFlag('GORIGHT', '1');
6128 if ((RunDirection() = D_RIGHT
) and (Target
.X
< FObj
.X
)) then
6129 SetAIFlag('GOLEFT', '1');
6132 begin // Åñëè ïîáèòû - çàáûâàåì î öåëè è óáåãàåì
6134 if ((RunDirection() = D_LEFT
) and (Target
.X
< FObj
.X
)) then
6135 SetAIFlag('GORIGHT', '1');
6136 if ((RunDirection() = D_RIGHT
) and (Target
.X
> FObj
.X
)) then
6137 SetAIFlag('GOLEFT', '1');
6141 begin // Öåëü ïîêà íà "ýêðàíå"
6142 // Åñëè öåëü íå çàãîðîæåíà ñòåíîé, òî îòìå÷àåì, êîãäà åå âèäåëè:
6143 if g_TraceVector(x1
, y1
, Target
.cX
, Target
.cY
) then
6144 FLastVisible
:= gTime
;
6145 // Åñëè ðàçíèöà âûñîò íå âåëèêà, òî äîãîíÿåì:
6146 if (Abs(FObj
.Y
-Target
.Y
) <= 128) then
6148 if ((RunDirection() = D_LEFT
) and (Target
.X
> FObj
.X
)) then
6149 SetAIFlag('GORIGHT', '1');
6150 if ((RunDirection() = D_RIGHT
) and (Target
.X
< FObj
.X
)) then
6151 SetAIFlag('GOLEFT', '1');
6155 // Âûáèðàåì óãîë ââåðõ:
6156 if FDirection
= D_LEFT
then
6157 angle
:= ANGLE_LEFTUP
6159 angle
:= ANGLE_RIGHTUP
;
6161 firew
:= Trunc(Cos(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
6162 fireh
:= Trunc(Sin(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
6164 // Åñëè ïðè óãëå ââåðõ ìîæíî ïîïàñòü â ïðèáëèçèòåëüíîå ïîëîæåíèå öåëè:
6165 if g_CollideLine(x1
, y1
, x1
+firew
, y1
+fireh
,
6166 Target
.X
+Target
.Rect
.X
+GetInterval(FDifficult
.DiagPrecision
, 128), //96
6167 Target
.Y
+Target
.Rect
.Y
+GetInterval(FDifficult
.DiagPrecision
, 128),
6168 Target
.Rect
.Width
, Target
.Rect
.Height
) and
6169 g_TraceVector(x1
, y1
, Target
.cX
, Target
.cY
) then
6170 begin // òî íóæíî ñòðåëÿòü ââåðõ
6171 SetAIFlag('NEEDFIRE', '1');
6172 SetAIFlag('NEEDSEEUP', '1');
6175 // Âûáèðàåì óãîë âíèç:
6176 if FDirection
= D_LEFT
then
6177 angle
:= ANGLE_LEFTDOWN
6179 angle
:= ANGLE_RIGHTDOWN
;
6181 firew
:= Trunc(Cos(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
6182 fireh
:= Trunc(Sin(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
6184 // Åñëè ïðè óãëå âíèç ìîæíî ïîïàñòü â ïðèáëèçèòåëüíîå ïîëîæåíèå öåëè:
6185 if g_CollideLine(x1
, y1
, x1
+firew
, y1
+fireh
,
6186 Target
.X
+Target
.Rect
.X
+GetInterval(FDifficult
.DiagPrecision
, 128),
6187 Target
.Y
+Target
.Rect
.Y
+GetInterval(FDifficult
.DiagPrecision
, 128),
6188 Target
.Rect
.Width
, Target
.Rect
.Height
) and
6189 g_TraceVector(x1
, y1
, Target
.cX
, Target
.cY
) then
6190 begin // òî íóæíî ñòðåëÿòü âíèç
6191 SetAIFlag('NEEDFIRE', '1');
6192 SetAIFlag('NEEDSEEDOWN', '1');
6195 // Åñëè öåëü âèäíî è îíà íà òàêîé æå âûñîòå:
6196 if Target
.Visible
and
6197 (y1
+4 < Target
.Y
+Target
.Rect
.Y
+Target
.Rect
.Height
) and
6198 (y1
-4 > Target
.Y
+Target
.Rect
.Y
) then
6200 // Åñëè èäåì â ñòîðîíó öåëè, òî íàäî ñòðåëÿòü:
6201 if ((FDirection
= D_LEFT
) and (Target
.X
< FObj
.X
)) or
6202 ((FDirection
= D_RIGHT
) and (Target
.X
> FObj
.X
)) then
6203 begin // òî íóæíî ñòðåëÿòü âïåðåä
6204 SetAIFlag('NEEDFIRE', '1');
6205 SetAIFlag('NEEDSEEDOWN', '');
6206 SetAIFlag('NEEDSEEUP', '');
6208 // Åñëè öåëü â ïðåäåëàõ "ýêðàíà" è ñëîæíîñòü ïîçâîëÿåò ïðûæêè ñáëèæåíèÿ:
6209 if Abs(FObj
.X
-Target
.X
) < Trunc(gPlayerScreenSize
.X
*0.75) then
6210 if GetRnd(FDifficult
.CloseJump
) then
6211 begin // òî åñëè ïîâåçåò - ïðûãàåì (îñîáåííî, åñëè áëèçêî)
6212 if Abs(FObj
.X
-Target
.X
) < 128 then
6216 if Random(a
) = 0 then
6217 SetAIFlag('NEEDJUMP', '1');
6221 // Åñëè öåëü âñå åùå åñòü:
6222 if Target
.UID
<> 0 then
6223 if gTime
-FLastVisible
> 2000 then // Åñëè âèäåëè äàâíî
6224 Target
.UID
:= 0 // òî çàáûòü öåëü
6225 else // Åñëè âèäåëè íåäàâíî
6226 begin // íî öåëü óáèëè
6227 if Target
.IsPlayer
then
6228 begin // Öåëü - èãðîê
6229 pla
:= g_Player_Get(Target
.UID
);
6230 if (pla
= nil) or (not pla
.Live
) or pla
.NoTarget
or
6231 (pla
.FMegaRulez
[MR_INVIS
] >= gTime
) then
6232 Target
.UID
:= 0; // òî çàáûòü öåëü
6235 begin // Öåëü - ìîíñòð
6236 mon
:= g_Monsters_Get(Target
.UID
);
6237 if (mon
= nil) or (not mon
.Live
) then
6238 Target
.UID
:= 0; // òî çàáûòü öåëü
6241 end; // if Target.UID <> 0
6243 FTargetUID
:= Target
.UID
;
6245 // Åñëè âîçìîæíûõ öåëåé íåò:
6246 // (Àòàêà ÷åãî-íèáóäü ñëåâà èëè ñïðàâà)
6247 if targets
= nil then
6248 if GetAIFlag('ATTACKLEFT') <> '' then
6249 begin // Åñëè íóæíî àòàêîâàòü íàëåâî
6250 RemoveAIFlag('ATTACKLEFT');
6252 SetAIFlag('NEEDJUMP', '1');
6254 if RunDirection() = D_RIGHT
then
6255 begin // Èäåì íå â òó ñòîðîíó
6256 if (Healthy() > 1) and GetRnd(FDifficult
.InvisFire
) then
6257 begin // Åñëè çäîðîâû, òî, âîçìîæíî, ñòðåëÿåì áåæèì âëåâî è ñòðåëÿåì
6258 SetAIFlag('NEEDFIRE', '1');
6259 SetAIFlag('GOLEFT', '1');
6263 begin // Èäåì â íóæíóþ ñòîðîíó
6264 if GetRnd(FDifficult
.InvisFire
) then // Âîçìîæíî, ñòðåëÿåì âñëåïóþ
6265 SetAIFlag('NEEDFIRE', '1');
6266 if Healthy() <= 1 then // Ïîáèòû - óáåãàåì
6267 SetAIFlag('GORIGHT', '1');
6271 if GetAIFlag('ATTACKRIGHT') <> '' then
6272 begin // Åñëè íóæíî àòàêîâàòü íàïðàâî
6273 RemoveAIFlag('ATTACKRIGHT');
6275 SetAIFlag('NEEDJUMP', '1');
6277 if RunDirection() = D_LEFT
then
6278 begin // Èäåì íå â òó ñòîðîíó
6279 if (Healthy() > 1) and GetRnd(FDifficult
.InvisFire
) then
6280 begin // Åñëè çäîðîâû, òî, âîçìîæíî, áåæèì âïðàâî è ñòðåëÿåì
6281 SetAIFlag('NEEDFIRE', '1');
6282 SetAIFlag('GORIGHT', '1');
6287 if GetRnd(FDifficult
.InvisFire
) then // Âîçìîæíî, ñòðåëÿåì âñëåïóþ
6288 SetAIFlag('NEEDFIRE', '1');
6289 if Healthy() <= 1 then // Ïîáèòû - óáåãàåì
6290 SetAIFlag('GOLEFT', '1');
6294 // Åñëè åñòü âîçìîæíûå öåëè:
6295 // (Ñòðåëÿåì ïî íàïðàâëåíèþ ê öåëÿì)
6296 if (targets
<> nil) and (GetAIFlag('NEEDFIRE') <> '') then
6297 for a
:= 0 to High(targets
) do
6299 // Åñëè ìîæåì ñòðåëÿòü ïî äèàãîíàëè:
6300 if GetRnd(FDifficult
.DiagFire
) then
6302 // Èùåì öåëü ñâåðõó è ñòðåëÿåì, åñëè åñòü:
6303 if FDirection
= D_LEFT
then
6304 angle
:= ANGLE_LEFTUP
6306 angle
:= ANGLE_RIGHTUP
;
6308 firew
:= Trunc(Cos(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
6309 fireh
:= Trunc(Sin(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
6311 if g_CollideLine(x1
, y1
, x1
+firew
, y1
+fireh
,
6312 targets
[a
].X
+targets
[a
].Rect
.X
+GetInterval(FDifficult
.DiagPrecision
, 128),
6313 targets
[a
].Y
+targets
[a
].Rect
.Y
+GetInterval(FDifficult
.DiagPrecision
, 128),
6314 targets
[a
].Rect
.Width
, targets
[a
].Rect
.Height
) and
6315 g_TraceVector(x1
, y1
, targets
[a
].cX
, targets
[a
].cY
) then
6317 SetAIFlag('NEEDFIRE', '1');
6318 SetAIFlag('NEEDSEEUP', '1');
6321 // Èùåì öåëü ñíèçó è ñòðåëÿåì, åñëè åñòü:
6322 if FDirection
= D_LEFT
then
6323 angle
:= ANGLE_LEFTDOWN
6325 angle
:= ANGLE_RIGHTDOWN
;
6327 firew
:= Trunc(Cos(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
6328 fireh
:= Trunc(Sin(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
6330 if g_CollideLine(x1
, y1
, x1
+firew
, y1
+fireh
,
6331 targets
[a
].X
+targets
[a
].Rect
.X
+GetInterval(FDifficult
.DiagPrecision
, 128),
6332 targets
[a
].Y
+targets
[a
].Rect
.Y
+GetInterval(FDifficult
.DiagPrecision
, 128),
6333 targets
[a
].Rect
.Width
, targets
[a
].Rect
.Height
) and
6334 g_TraceVector(x1
, y1
, targets
[a
].cX
, targets
[a
].cY
) then
6336 SetAIFlag('NEEDFIRE', '1');
6337 SetAIFlag('NEEDSEEDOWN', '1');
6341 // Åñëè öåëü "ïåðåä íîñîì", òî ñòðåëÿåì:
6342 if targets
[a
].Line
and targets
[a
].Visible
and
6343 (((FDirection
= D_LEFT
) and (targets
[a
].X
< FObj
.X
)) or
6344 ((FDirection
= D_RIGHT
) and (targets
[a
].X
> FObj
.X
))) then
6346 SetAIFlag('NEEDFIRE', '1');
6351 // Åñëè ëåòèò ïóëÿ, òî, âîçìîæíî, ïîäïðûãèâàåì:
6352 if g_Weapon_Danger(FUID
, FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+PLAYER_RECT
.Y
,
6353 PLAYER_RECT
.Width
, PLAYER_RECT
.Height
,
6354 40+GetInterval(FDifficult
.Cover
, 40)) then
6355 SetAIFlag('NEEDJUMP', '1');
6357 // Åñëè êîí÷èëèñü ïàòîðíû, òî íóæíî ñìåíèòü îðóæèå:
6358 ammo
:= GetAmmoByWeapon(FCurrWeap
);
6359 if ((FCurrWeap
= WEAPON_SHOTGUN2
) and (ammo
< 2)) or
6360 ((FCurrWeap
= WEAPON_BFG
) and (ammo
< 40)) or
6362 SetAIFlag('SELECTWEAPON', '1');
6364 // Åñëè íóæíî ñìåíèòü îðóæèå, òî âûáèðàåì íóæíîå:
6365 if GetAIFlag('SELECTWEAPON') = '1' then
6368 RemoveAIFlag('SELECTWEAPON');
6372 procedure TBot
.Update();
6385 // Ïðîâåðÿåì, îòêëþ÷¸í ëè AI áîòîâ
6386 if (g_debug_BotAIOff
= 1) and (Team
= TEAM_RED
) then
6388 if (g_debug_BotAIOff
= 2) and (Team
= TEAM_BLUE
) then
6390 if g_debug_BotAIOff
= 3 then
6403 procedure TBot
.ReleaseKey(Key
: Byte);
6412 function TBot
.KeyPressed(Key
: Word): Boolean;
6414 Result
:= FKeys
[Key
].Pressed
;
6417 function TBot
.GetAIFlag(fName
: String20
): String20
;
6423 fName
:= LowerCase(fName
);
6425 if FAIFlags
<> nil then
6426 for a
:= 0 to High(FAIFlags
) do
6427 if LowerCase(FAIFlags
[a
].Name
) = fName
then
6429 Result
:= FAIFlags
[a
].Value
;
6434 procedure TBot
.RemoveAIFlag(fName
: String20
);
6438 if FAIFlags
= nil then Exit
;
6440 fName
:= LowerCase(fName
);
6442 for a
:= 0 to High(FAIFlags
) do
6443 if LowerCase(FAIFlags
[a
].Name
) = fName
then
6445 if a
<> High(FAIFlags
) then
6446 for b
:= a
to High(FAIFlags
)-1 do
6447 FAIFlags
[b
] := FAIFlags
[b
+1];
6449 SetLength(FAIFlags
, Length(FAIFlags
)-1);
6454 procedure TBot
.SetAIFlag(fName
, fValue
: String20
);
6462 fName
:= LowerCase(fName
);
6464 if FAIFlags
<> nil then
6465 for a
:= 0 to High(FAIFlags
) do
6466 if LowerCase(FAIFlags
[a
].Name
) = fName
then
6472 if ok
then FAIFlags
[a
].Value
:= fValue
6475 SetLength(FAIFlags
, Length(FAIFlags
)+1);
6476 with FAIFlags
[High(FAIFlags
)] do
6484 procedure TBot
.UpdateMove
;
6486 procedure GoLeft(Time
: Word = 1);
6488 ReleaseKey(KEY_LEFT
);
6489 ReleaseKey(KEY_RIGHT
);
6490 PressKey(KEY_LEFT
, Time
);
6491 SetDirection(D_LEFT
);
6494 procedure GoRight(Time
: Word = 1);
6496 ReleaseKey(KEY_LEFT
);
6497 ReleaseKey(KEY_RIGHT
);
6498 PressKey(KEY_RIGHT
, Time
);
6499 SetDirection(D_RIGHT
);
6502 function Rnd(a
: Word): Boolean;
6504 Result
:= Random(a
) = 0;
6507 procedure Turn(Time
: Word = 1200);
6509 if RunDirection() = D_LEFT
then GoRight(Time
) else GoLeft(Time
);
6514 ReleaseKey(KEY_LEFT
);
6515 ReleaseKey(KEY_RIGHT
);
6518 function CanRunLeft(): Boolean;
6520 Result
:= not CollideLevel(-1, 0);
6523 function CanRunRight(): Boolean;
6525 Result
:= not CollideLevel(1, 0);
6528 function CanRun(): Boolean;
6530 if RunDirection() = D_LEFT
then Result
:= CanRunLeft() else Result
:= CanRunRight();
6533 procedure Jump(Time
: Word = 30);
6535 PressKey(KEY_JUMP
, Time
);
6538 function NearHole(): Boolean;
6542 { TODO 5 : Ëåñòíèöû }
6543 sx
:= IfThen(RunDirection() = D_LEFT
, -1, 1);
6544 for x
:= 1 to PLAYER_RECT
.Width
do
6545 if (not StayOnStep(x
*sx
, 0)) and
6546 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
)) and
6547 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
*2)) then
6556 function BorderHole(): Boolean;
6560 { TODO 5 : Ëåñòíèöû }
6561 sx
:= IfThen(RunDirection() = D_LEFT
, -1, 1);
6562 for x
:= 1 to PLAYER_RECT
.Width
do
6563 if (not StayOnStep(x
*sx
, 0)) and
6564 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
)) and
6565 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
*2)) then
6567 for xx
:= x
to x
+32 do
6568 if CollideLevel(xx
*sx
, PLAYER_RECT
.Height
) then
6578 function NearDeepHole(): Boolean;
6584 sx
:= IfThen(RunDirection() = D_LEFT
, -1, 1);
6587 for x
:= 1 to PLAYER_RECT
.Width
do
6588 if (not StayOnStep(x
*sx
, 0)) and
6589 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
)) and
6590 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
*2)) then
6592 while FObj
.Y
+y
*PLAYER_RECT
.Height
< gMapInfo
.Height
do
6594 if CollideLevel(x
*sx
, PLAYER_RECT
.Height
*y
) then Exit
;
6599 end else Result
:= False;
6602 function OverDeepHole(): Boolean;
6609 while FObj
.Y
+y
*PLAYER_RECT
.Height
< gMapInfo
.Height
do
6611 if CollideLevel(0, PLAYER_RECT
.Height
*y
) then Exit
;
6618 function OnGround(): Boolean;
6620 Result
:= StayOnStep(0, 0) or CollideLevel(0, 1);
6623 function OnLadder(): Boolean;
6625 Result
:= FullInStep(0, 0);
6628 function BelowLadder(): Boolean;
6630 Result
:= (FullInStep(IfThen(RunDirection() = D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -PLAYER_RECT
.Height
) and
6631 not CollideLevel(IfThen(RunDirection() = D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -PLAYER_RECT
.Height
)) or
6632 (FullInStep(IfThen(RunDirection() = D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -BOT_MAXJUMP
) and
6633 not CollideLevel(IfThen(RunDirection() = D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -BOT_MAXJUMP
));
6636 function BelowLiftUp(): Boolean;
6638 Result
:= ((FullInLift(IfThen(RunDirection() = D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -PLAYER_RECT
.Height
) = -1) and
6639 not CollideLevel(IfThen(RunDirection() = D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -PLAYER_RECT
.Height
)) or
6640 ((FullInLift(IfThen(RunDirection() = D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -BOT_MAXJUMP
) = -1) and
6641 not CollideLevel(IfThen(RunDirection() = D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -BOT_MAXJUMP
));
6644 function OnTopLift(): Boolean;
6646 Result
:= (FullInLift(0, 0) = -1) and (FullInLift(0, -32) = 0);
6649 function CanJumpOver(): Boolean;
6653 sx
:= IfThen(RunDirection() = D_LEFT
, -1, 1);
6657 if not CollideLevel(sx
, 0) then Exit
;
6659 for y
:= 1 to BOT_MAXJUMP
do
6660 if CollideLevel(0, -y
) then Exit
else
6661 if not CollideLevel(sx
, -y
) then
6668 function CanJumpUp(Dist
: ShortInt): Boolean;
6675 if CollideLevel(Dist
, 0) then Exit
;
6678 for y
:= 0 to BOT_MAXJUMP
do
6679 if CollideLevel(Dist
, -y
) then
6688 for yy
:= y
+1 to BOT_MAXJUMP
do
6689 if not CollideLevel(Dist
, -yy
) then
6698 for y
:= 0 to BOT_MAXJUMP
do
6699 if CollideLevel(0, -y
) then
6707 if y
< yy
then Exit
;
6712 function IsSafeTrigger(): Boolean;
6717 if gTriggers
= nil then
6719 for a
:= 0 to High(gTriggers
) do
6720 if Collide(gTriggers
[a
].X
,
6723 gTriggers
[a
].Height
) and
6724 (gTriggers
[a
].TriggerType
in [TRIGGER_EXIT
, TRIGGER_CLOSEDOOR
,
6725 TRIGGER_CLOSETRAP
, TRIGGER_TRAP
,
6726 TRIGGER_PRESS
, TRIGGER_ON
, TRIGGER_OFF
,
6727 TRIGGER_ONOFF
, TRIGGER_SPAWNMONSTER
,
6728 TRIGGER_DAMAGE
, TRIGGER_SHOT
]) then
6733 // Âîçìîæíî, íàæèìàåì êíîïêó:
6734 if Rnd(16) and IsSafeTrigger() then
6737 // Åñëè ïîä ëèôòîì èëè ñòóïåíüêàìè, òî, âîçìîæíî, ïðûãàåì:
6738 if OnLadder() or ((BelowLadder() or BelowLiftUp()) and Rnd(8)) then
6740 ReleaseKey(KEY_LEFT
);
6741 ReleaseKey(KEY_RIGHT
);
6745 // Èäåì âëåâî, åñëè íàäî áûëî:
6746 if GetAIFlag('GOLEFT') <> '' then
6748 RemoveAIFlag('GOLEFT');
6749 if CanRunLeft() then
6753 // Èäåì âïðàâî, åñëè íàäî áûëî:
6754 if GetAIFlag('GORIGHT') <> '' then
6756 RemoveAIFlag('GORIGHT');
6757 if CanRunRight() then
6761 // Åñëè âûëåòåëè çà êàðòó, òî ïðîáóåì âåðíóòüñÿ:
6762 if FObj
.X
< -32 then
6765 if FObj
.X
+32 > gMapInfo
.Width
then
6768 // Ïðûãàåì, åñëè íàäî áûëî:
6769 if GetAIFlag('NEEDJUMP') <> '' then
6772 RemoveAIFlag('NEEDJUMP');
6775 // Ñìîòðèì ââåðõ, åñëè íàäî áûëî:
6776 if GetAIFlag('NEEDSEEUP') <> '' then
6779 ReleaseKey(KEY_DOWN
);
6780 PressKey(KEY_UP
, 20);
6781 RemoveAIFlag('NEEDSEEUP');
6784 // Ñìîòðèì âíèç, åñëè íàäî áûëî:
6785 if GetAIFlag('NEEDSEEDOWN') <> '' then
6788 ReleaseKey(KEY_DOWN
);
6789 PressKey(KEY_DOWN
, 20);
6790 RemoveAIFlag('NEEDSEEDOWN');
6793 // Åñëè íóæíî áûëî â äûðó è ìû íå íà çåìëå, òî ïîêîðíî ëåòèì:
6794 if GetAIFlag('GOINHOLE') <> '' then
6795 if not OnGround() then
6797 ReleaseKey(KEY_LEFT
);
6798 ReleaseKey(KEY_RIGHT
);
6799 RemoveAIFlag('GOINHOLE');
6800 SetAIFlag('FALLINHOLE', '1');
6803 // Åñëè ïàäàëè è äîñòèãëè çåìëè, òî õâàòèò ïàäàòü:
6804 if GetAIFlag('FALLINHOLE') <> '' then
6806 RemoveAIFlag('FALLINHOLE');
6808 // Åñëè ëåòåëè ïðÿìî è ñåé÷àñ íå íà ëåñòíèöå èëè íà âåðøèíå ëèôòà, òî îòõîäèì â ñòîðîíó:
6809 if not (KeyPressed(KEY_LEFT
) or KeyPressed(KEY_RIGHT
)) then
6810 if GetAIFlag('FALLINHOLE') = '' then
6811 if (not OnLadder()) or (FObj
.Vel
.Y
>= 0) or (OnTopLift()) then
6817 // Åñëè íà çåìëå è ìîæíî ïîäïðûãíóòü, òî, âîçìîæíî, ïðûãàåì:
6819 CanJumpUp(IfThen(RunDirection() = D_LEFT
, -1, 1)*32) and
6823 // Åñëè íà çåìëå è âîçëå äûðû (ãëóáèíà > 2 ðîñòîâ èãðîêà):
6824 if OnGround() and NearHole() then
6825 if NearDeepHole() then // Åñëè ýòî áåçäíà
6827 0..3: Turn(); // Áåæèì îáðàòíî
6828 4: Jump(); // Ïðûãàåì
6829 5: begin // Ïðûãàåì îáðàòíî
6834 else // Ýòî íå áåçäíà è ìû åùå íå ëåòèì òóäà
6835 if GetAIFlag('GOINHOLE') = '' then
6837 0: Turn(); // Íå íóæíî òóäà
6838 1: Jump(); // Âäðóã ïîâåçåò - ïðûãàåì
6839 else // Åñëè ÿìà ñ ãðàíèöåé, òî ïðè ñëó÷àå ìîæíî òóäà ïðûãíóòü
6840 if BorderHole() then
6841 SetAIFlag('GOINHOLE', '1');
6844 // Åñëè íà çåìëå, íî íåêóäà èäòè:
6845 if (not CanRun()) and OnGround() then
6847 // Åñëè ìû íà ëåñòíèöå èëè ìîæíî ïåðåïðûãíóòü, òî ïðûãàåì:
6848 if CanJumpOver() or OnLadder() then
6850 else // èíà÷å ïîïûòàåìñÿ â äðóãóþ ñòîðîíó
6851 if Random(2) = 0 then
6853 if IsSafeTrigger() then
6859 // Îñòàëîñü ìàëî âîçäóõà:
6860 if FAir
< 36 * 2 then
6863 // Âûáèðàåìñÿ èç êèñëîòû, åñëè íåò êîñòþìà, îáîæãëèñü, èëè ìàëî çäîðîâüÿ:
6864 if (FMegaRulez
[MR_SUIT
] < gTime
) and ((FLastHit
= HIT_ACID
) or (Healthy() <= 1)) then
6865 if BodyInAcid(0, 0) then
6869 function TBot
.FullInStep(XInc
, YInc
: Integer): Boolean;
6871 Result
:= g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
,
6872 PLAYER_RECT
.Width
, PLAYER_RECT
.Height
, PANEL_STEP
, False);
6875 {function TBot.NeedItem(Item: Byte): Byte;
6880 procedure TBot
.SelectWeapon(Dist
: Integer);
6884 function HaveAmmo(weapon
: Byte): Boolean;
6887 WEAPON_PISTOL
: Result
:= FAmmo
[A_BULLETS
] >= 1;
6888 WEAPON_SHOTGUN1
: Result
:= FAmmo
[A_SHELLS
] >= 1;
6889 WEAPON_SHOTGUN2
: Result
:= FAmmo
[A_SHELLS
] >= 2;
6890 WEAPON_CHAINGUN
: Result
:= FAmmo
[A_BULLETS
] >= 10;
6891 WEAPON_ROCKETLAUNCHER
: Result
:= FAmmo
[A_ROCKETS
] >= 1;
6892 WEAPON_PLASMA
: Result
:= FAmmo
[A_CELLS
] >= 10;
6893 WEAPON_BFG
: Result
:= FAmmo
[A_CELLS
] >= 40;
6894 WEAPON_SUPERPULEMET
: Result
:= FAmmo
[A_SHELLS
] >= 1;
6895 else Result
:= True;
6900 if Dist
= -1 then Dist
:= BOT_LONGDIST
;
6902 if Dist
> BOT_LONGDIST
then
6903 begin // Äàëüíèé áîé
6905 if FWeapon
[FDifficult
.WeaponPrior
[a
]] and HaveAmmo(FDifficult
.WeaponPrior
[a
]) then
6907 FSelectedWeapon
:= FDifficult
.WeaponPrior
[a
];
6911 else //if Dist > BOT_UNSAFEDIST then
6912 begin // Áëèæíèé áîé
6914 if FWeapon
[FDifficult
.CloseWeaponPrior
[a
]] and HaveAmmo(FDifficult
.CloseWeaponPrior
[a
]) then
6916 FSelectedWeapon
:= FDifficult
.CloseWeaponPrior
[a
];
6923 if FWeapon[FDifficult.SafeWeaponPrior[a]] and HaveAmmo(FDifficult.SafeWeaponPrior[a]) then
6925 FSelectedWeapon := FDifficult.SafeWeaponPrior[a];
6931 function TBot
.PickItem(ItemType
: Byte; force
: Boolean; var remove
: Boolean): Boolean;
6933 Result
:= inherited PickItem(ItemType
, force
, remove
);
6935 if Result
then SetAIFlag('SELECTWEAPON', '1');
6938 function TBot
.Heal(value
: Word; Soft
: Boolean): Boolean;
6940 Result
:= inherited Heal(value
, Soft
);
6943 function TBot
.Healthy(): Byte;
6945 if FMegaRulez
[MR_INVUL
] >= gTime
then Result
:= 3
6946 else if (FHealth
> 80) or ((FHealth
> 50) and (FArmor
> 20)) then Result
:= 3
6947 else if (FHealth
> 50) then Result
:= 2
6948 else if (FHealth
> 20) then Result
:= 1
6952 function TBot
.TargetOnScreen(TX
, TY
: Integer): Boolean;
6954 Result
:= (Abs(FObj
.X
-TX
) <= Trunc(gPlayerScreenSize
.X
*0.6)) and
6955 (Abs(FObj
.Y
-TY
) <= Trunc(gPlayerScreenSize
.Y
*0.6));
6958 procedure TBot
.OnDamage(Angle
: SmallInt);
6966 if (Angle
= 0) or (Angle
= 180) then
6969 if (g_GetUIDType(FLastSpawnerUID
) = UID_PLAYER
) and
6970 LongBool(gGameSettings
.Options
and GAME_OPTION_BOTVSPLAYER
) then
6972 pla
:= g_Player_Get(FLastSpawnerUID
);
6973 ok
:= not TargetOnScreen(pla
.FObj
.X
+ PLAYER_RECT
.X
,
6974 pla
.FObj
.Y
+ PLAYER_RECT
.Y
);
6977 if (g_GetUIDType(FLastSpawnerUID
) = UID_MONSTER
) and
6978 LongBool(gGameSettings
.Options
and GAME_OPTION_BOTVSMONSTER
) then
6980 mon
:= g_Monsters_Get(FLastSpawnerUID
);
6981 ok
:= not TargetOnScreen(mon
.Obj
.X
+ mon
.Obj
.Rect
.X
,
6982 mon
.Obj
.Y
+ mon
.Obj
.Rect
.Y
);
6987 SetAIFlag('ATTACKLEFT', '1')
6989 SetAIFlag('ATTACKRIGHT', '1');
6993 function TBot
.RunDirection(): TDirection
;
6995 if Abs(Vel
.X
) >= 1 then
6997 if Vel
.X
> 0 then Result
:= D_RIGHT
else Result
:= D_LEFT
;
6999 Result
:= FDirection
;
7002 function TBot
.GetRnd(a
: Byte): Boolean;
7004 if a
= 0 then Result
:= False
7005 else if a
= 255 then Result
:= True
7006 else Result
:= Random(256) > 255-a
;
7009 function TBot
.GetInterval(a
: Byte; radius
: SmallInt): SmallInt;
7011 Result
:= Round((255-a
)/255*radius
*(Random(2)-1));
7014 procedure TBot
.SaveState(var Mem
: TBinMemoryWriter
);
7020 inherited SaveState(Mem
);
7022 // Âûáðàííîå îðóæèå:
7023 Mem
.WriteByte(FSelectedWeapon
);
7025 Mem
.WriteWord(FTargetUID
);
7026 // Âðåìÿ ïîòåðè öåëè:
7027 Mem
.WriteDWORD(FLastVisible
);
7028 // Êîëè÷åñòâî ôëàãîâ ÈÈ:
7029 dw
:= Length(FAIFlags
);
7032 for i
:= 0 to Integer(dw
)-1 do
7034 Mem
.WriteString(FAIFlags
[i
].Name
, 20);
7035 Mem
.WriteString(FAIFlags
[i
].Value
, 20);
7037 // Íàñòðîéêè ñëîæíîñòè:
7039 Mem
.WriteMemory(p
, SizeOf(TDifficult
));
7042 procedure TBot
.LoadState(var Mem
: TBinMemoryReader
);
7048 inherited LoadState(Mem
);
7050 // Âûáðàííîå îðóæèå:
7051 Mem
.ReadByte(FSelectedWeapon
);
7053 Mem
.ReadWord(FTargetUID
);
7054 // Âðåìÿ ïîòåðè öåëè:
7055 Mem
.ReadDWORD(FLastVisible
);
7056 // Êîëè÷åñòâî ôëàãîâ ÈÈ:
7058 SetLength(FAIFlags
, dw
);
7060 for i
:= 0 to Integer(dw
)-1 do
7062 Mem
.ReadString(FAIFlags
[i
].Name
);
7063 Mem
.ReadString(FAIFlags
[i
].Value
);
7065 // Íàñòðîéêè ñëîæíîñòè:
7066 Mem
.ReadMemory(p
, dw
);
7067 if dw
<> SizeOf(TDifficult
) then
7069 raise EBinSizeError
.Create('TBot.LoadState: Wrong FDifficult Size');
7071 FDifficult
:= TDifficult(p
^);