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
116 Ammo
: Array [A_BULLETS
..A_CELLS
] of Word;
117 MaxAmmo
: Array [A_BULLETS
..A_CELLS
] of Word;
118 Weapon
: Array [WEAPON_KASTET
..WEAPON_SUPERPULEMET
] of Boolean;
119 Rulez
: Set of R_ITEM_BACKPACK
..R_BERSERK
;
128 TPlayer
= class (TObject
)
136 FDirection
: TDirection
;
144 FMonsterKills
: Integer;
150 FCanJetpack
: Boolean;
156 FBFGFireCounter
: SmallInt;
157 FLastSpawnerUID
: Word;
161 FSpectatePlayer
: Integer;
163 FSavedState
: TPlayerSavedState
;
165 FModel
: TPlayerModel
;
168 FActionForce
: Boolean;
169 FActionChanged
: Boolean;
171 FFireAngle
: SmallInt;
173 FShellTimer
: Integer;
175 FSawSound
: TPlayableSound
;
176 FSawSoundIdle
: TPlayableSound
;
177 FSawSoundHit
: TPlayableSound
;
178 FSawSoundSelect
: TPlayableSound
;
179 FJetSoundOn
: TPlayableSound
;
180 FJetSoundOff
: TPlayableSound
;
181 FJetSoundFly
: TPlayableSound
;
185 FJustTeleported
: Boolean;
188 function CollideLevel(XInc
, YInc
: Integer): Boolean;
189 function StayOnStep(XInc
, YInc
: Integer): Boolean;
190 function HeadInLiquid(XInc
, YInc
: Integer): Boolean;
191 function BodyInLiquid(XInc
, YInc
: Integer): Boolean;
192 function BodyInAcid(XInc
, YInc
: Integer): Boolean;
193 function FullInLift(XInc
, YInc
: Integer): Integer;
194 {procedure CollideItem();}
195 procedure FlySmoke(Times
: DWORD
= 1);
196 function GetAmmoByWeapon(Weapon
: Byte): Word;
197 procedure SetAction(Action
: Byte; Force
: Boolean = False);
198 procedure OnDamage(Angle
: SmallInt); virtual;
199 function firediry(): Integer;
201 procedure Run(Direction
: TDirection
);
202 procedure NextWeapon();
203 procedure PrevWeapon();
210 procedure cycleWeapon (dir
: Integer);
211 function getNextWeaponIndex (): Byte; // return 255 for "no switch"
212 procedure resetWeaponQueue ();
215 FDamageBuffer
: Integer;
217 FAmmo
: Array [A_BULLETS
..A_CELLS
] of Word;
218 FMaxAmmo
: Array [A_BULLETS
..A_CELLS
] of Word;
219 FWeapon
: Array [WEAPON_KASTET
..WEAPON_SUPERPULEMET
] of Boolean;
220 FRulez
: Set of R_ITEM_BACKPACK
..R_BERSERK
;
222 FMegaRulez
: Array [MR_SUIT
..MR_MAX
] of DWORD
;
223 FReloading
: Array [WEAPON_KASTET
..WEAPON_SUPERPULEMET
] of Word;
224 FTime
: Array [T_RESPAWN
..T_FLAGCAP
] of DWORD
;
225 FKeys
: Array [KEY_LEFT
..KEY_CHAT
] of TKeyState
;
227 FPreferredTeam
: Byte;
230 FWantsInGame
: Boolean;
234 FActualModelName
: string;
240 constructor Create(); virtual;
241 destructor Destroy(); override;
242 procedure Respawn(Silent
: Boolean; Force
: Boolean = False); virtual;
243 function GetRespawnPoint(): Byte;
244 procedure PressKey(Key
: Byte; Time
: Word = 1);
245 procedure ReleaseKeys();
246 procedure SetModel(ModelName
: String);
247 procedure SetColor(Color
: TRGB
);
248 procedure SetWeapon(W
: Byte);
249 function IsKeyPressed(K
: Byte): Boolean;
250 function GetKeys(): Byte;
251 function PickItem(ItemType
: Byte; respawn
: Boolean; var remove
: Boolean): Boolean; virtual;
252 function Collide(X
, Y
: Integer; Width
, Height
: Word): Boolean; overload
;
253 function Collide(Panel
: TPanel
): Boolean; overload
;
254 function Collide(X
, Y
: Integer): Boolean; overload
;
255 procedure SetDirection(Direction
: TDirection
);
256 procedure GetSecret();
257 function TeleportTo(X
, Y
: Integer; silent
: Boolean; dir
: Byte): Boolean;
259 procedure Push(vx
, vy
: Integer);
260 procedure ChangeModel(ModelName
: String);
261 procedure SwitchTeam
;
262 procedure ChangeTeam(Team
: Byte);
264 function GetFlag(Flag
: Byte): Boolean;
265 procedure SetFlag(Flag
: Byte);
266 function DropFlag(): Boolean;
267 procedure AllRulez(Health
: Boolean);
268 procedure RestoreHealthArmor();
269 procedure FragCombo();
270 procedure GiveItem(ItemType
: Byte);
271 procedure Damage(value
: Word; SpawnerUID
: Word; vx
, vy
: Integer; t
: Byte); virtual;
272 function Heal(value
: Word; Soft
: Boolean): Boolean; virtual;
273 procedure MakeBloodVector(Count
: Word; VelX
, VelY
: Integer);
274 procedure MakeBloodSimple(Count
: Word);
275 procedure Kill(KillType
: Byte; SpawnerUID
: Word; t
: Byte);
276 procedure Reset(Force
: Boolean);
277 procedure Spectate(NoMove
: Boolean = False);
278 procedure SwitchNoClip
;
279 procedure SoftReset();
280 procedure Draw(); virtual;
281 procedure DrawPain();
282 procedure DrawPickup();
283 procedure DrawRulez();
285 procedure DrawBubble();
287 procedure Update(); virtual;
288 procedure RememberState();
289 procedure RecallState();
290 procedure SaveState(var Mem
: TBinMemoryWriter
); virtual;
291 procedure LoadState(var Mem
: TBinMemoryReader
); virtual;
292 procedure PauseSounds(Enable
: Boolean);
293 procedure NetFire(Wpn
: Byte; X
, Y
, AX
, AY
: Integer; WID
: Integer = -1);
294 procedure DoLerp(Level
: Integer = 2);
295 procedure SetLerp(XTo
, YTo
: Integer);
296 procedure QueueWeaponSwitch(Weapon
: Byte);
297 procedure RealizeCurrentWeapon();
299 procedure JetpackOff
;
301 property Name
: String read FName write FName
;
302 property Model
: TPlayerModel read FModel
;
303 property Health
: Integer read FHealth write FHealth
;
304 property Lives
: Byte read FLives write FLives
;
305 property Armor
: Integer read FArmor write FArmor
;
306 property Air
: Integer read FAir write FAir
;
307 property JetFuel
: Integer read FJetFuel write FJetFuel
;
308 property Frags
: Integer read FFrags write FFrags
;
309 property Death
: Integer read FDeath write FDeath
;
310 property Kills
: Integer read FKills write FKills
;
311 property CurrWeap
: Byte read FCurrWeap write FCurrWeap
;
312 property MonsterKills
: Integer read FMonsterKills write FMonsterKills
;
313 property Secrets
: Integer read FSecrets
;
314 property GodMode
: Boolean read FGodMode write FGodMode
;
315 property NoTarget
: Boolean read FNoTarget write FNoTarget
;
316 property NoReload
: Boolean read FNoReload write FNoReload
;
317 property Live
: Boolean read FLive write FLive
;
318 property Flag
: Byte read FFlag
;
319 property Team
: Byte read FTeam write FTeam
;
320 property Direction
: TDirection read FDirection
;
321 property GameX
: Integer read FObj
.X write FObj
.X
;
322 property GameY
: Integer read FObj
.Y write FObj
.Y
;
323 property GameVelX
: Integer read FObj
.Vel
.X write FObj
.Vel
.X
;
324 property GameVelY
: Integer read FObj
.Vel
.Y write FObj
.Vel
.Y
;
325 property GameAccelX
: Integer read FObj
.Accel
.X write FObj
.Accel
.X
;
326 property GameAccelY
: Integer read FObj
.Accel
.Y write FObj
.Accel
.Y
;
327 property Vel
: TPoint2i read FObj
.Vel
;
328 property Obj
: TObj read FObj
;
329 property IncCam
: Integer read FIncCam write FIncCam
;
330 property UID
: Word read FUID write FUID
;
331 property JustTeleported
: Boolean read FJustTeleported write FJustTeleported
;
332 property NetTime
: LongWord read FNetTime write FNetTime
;
342 WeaponPrior
: Array [WEAPON_KASTET
..WEAPON_SUPERPULEMET
] of Byte;
343 CloseWeaponPrior
: Array [WEAPON_KASTET
..WEAPON_SUPERPULEMET
] of Byte;
344 //SafeWeaponPrior: Array [WEAPON_KASTET..WEAPON_SUPERPULEMET] of Byte;
352 TBot
= class (TPlayer
)
354 FSelectedWeapon
: Byte;
357 FAIFlags
: Array of TAIFlag
;
358 FDifficult
: TDifficult
;
360 function GetRnd(a
: Byte): Boolean;
361 function GetInterval(a
: Byte; radius
: SmallInt): SmallInt;
362 function RunDirection(): TDirection
;
363 function FullInStep(XInc
, YInc
: Integer): Boolean;
364 //function NeedItem(Item: Byte): Byte;
365 procedure SelectWeapon(Dist
: Integer);
366 procedure SetAIFlag(fName
, fValue
: String20
);
367 function GetAIFlag(fName
: String20
): String20
;
368 procedure RemoveAIFlag(fName
: String20
);
369 function Healthy(): Byte;
370 procedure UpdateMove();
371 procedure UpdateCombat();
372 function KeyPressed(Key
: Word): Boolean;
373 procedure ReleaseKey(Key
: Byte);
374 function TargetOnScreen(TX
, TY
: Integer): Boolean;
375 procedure OnDamage(Angle
: SmallInt); override;
378 procedure Respawn(Silent
: Boolean; Force
: Boolean = False); override;
379 constructor Create(); override;
380 destructor Destroy(); override;
381 procedure Draw(); override;
382 function PickItem(ItemType
: Byte; force
: Boolean; var remove
: Boolean): Boolean; override;
383 function Heal(value
: Word; Soft
: Boolean): Boolean; override;
384 procedure Update(); override;
385 procedure SaveState(var Mem
: TBinMemoryWriter
); override;
386 procedure LoadState(var Mem
: TBinMemoryReader
); override;
408 TCorpse
= class (TObject
)
416 FAnimation
: TAnimation
;
417 FAnimationMask
: TAnimation
;
420 constructor Create(X
, Y
: Integer; ModelName
: String; aMess
: Boolean);
421 destructor Destroy(); override;
422 procedure Damage(Value
: Word; vx
, vy
: Integer);
425 procedure SaveState(var Mem
: TBinMemoryWriter
);
426 procedure LoadState(var Mem
: TBinMemoryReader
);
428 property Obj
: TObj read FObj
;
429 property State
: Byte read FState
;
430 property Mess
: Boolean read FMess
;
433 TTeamStat
= Array [TEAM_RED
..TEAM_BLUE
] of
439 gPlayers
: Array of TPlayer
;
440 gCorpses
: Array of TCorpse
;
441 gGibs
: Array of TGib
;
442 gShells
: Array of TShell
;
443 gTeamStat
: TTeamStat
;
444 gFly
: Boolean = False;
445 gAimLine
: Boolean = False;
446 gChatBubble
: Byte = 0;
450 MAX_RUNVEL
: Integer = 8;
451 VEL_JUMP
: Integer = 10;
452 SHELL_TIMEOUT
: Cardinal = 60000;
454 function Lerp(X
, Y
, Factor
: Integer): Integer;
456 procedure g_Gibs_SetMax(Count
: Word);
457 function g_Gibs_GetMax(): Word;
458 procedure g_Corpses_SetMax(Count
: Word);
459 function g_Corpses_GetMax(): Word;
460 procedure g_Shells_SetMax(Count
: Word);
461 function g_Shells_GetMax(): Word;
463 procedure g_Player_Init();
464 procedure g_Player_Free();
465 function g_Player_Create(ModelName
: String; Color
: TRGB
; Team
: Byte; Bot
: Boolean): Word;
466 function g_Player_CreateFromState(var Mem
: TBinMemoryReader
): Word;
467 procedure g_Player_Remove(UID
: Word);
468 procedure g_Player_ResetTeams();
469 procedure g_Player_UpdateAll();
470 procedure g_Player_DrawAll();
471 procedure g_Player_DrawDebug(p
: TPlayer
);
472 procedure g_Player_DrawHealth();
473 procedure g_Player_RememberAll();
474 procedure g_Player_ResetAll(Force
, Silent
: Boolean);
475 function g_Player_Get(UID
: Word): TPlayer
;
476 function g_Player_GetCount(): Byte;
477 function g_Player_GetStats(): TPlayerStatArray
;
478 function g_Player_ValidName(Name
: String): Boolean;
479 procedure g_Player_CreateCorpse(Player
: TPlayer
);
480 procedure g_Player_CreateGibs(fX
, fY
: Integer; ModelName
: String; fColor
: TRGB
);
481 procedure g_Player_CreateShell(fX
, fY
, dX
, dY
: Integer; T
: Byte);
482 procedure g_Player_UpdatePhysicalObjects();
483 procedure g_Player_DrawCorpses();
484 procedure g_Player_DrawShells();
485 procedure g_Player_RemoveAllCorpses();
486 procedure g_Player_Corpses_SaveState(var Mem
: TBinMemoryWriter
);
487 procedure g_Player_Corpses_LoadState(var Mem
: TBinMemoryReader
);
488 procedure g_Bot_Add(Team
, Difficult
: Byte);
489 procedure g_Bot_AddList(Team
: Byte; lname
: ShortString; num
: Integer = -1);
490 procedure g_Bot_MixNames();
491 procedure g_Bot_RemoveAll();
496 e_log
, g_map
, g_items
, g_console
, SysUtils
, g_gfx
, Math
,
497 g_options
, g_triggers
, g_menu
, MAPDEF
, g_game
,
498 wadreader
, g_main
, g_monsters
, CONFIG
, g_language
, g_net
, g_netmsg
;
508 diag_precision
: Byte;
512 w_prior1
: Array [WEAPON_KASTET
..WEAPON_SUPERPULEMET
] of Byte;
513 w_prior2
: Array [WEAPON_KASTET
..WEAPON_SUPERPULEMET
] of Byte;
514 w_prior3
: Array [WEAPON_KASTET
..WEAPON_SUPERPULEMET
] of Byte;
518 TIME_RESPAWN1
= 1500;
519 TIME_RESPAWN2
= 2000;
520 TIME_RESPAWN3
= 3000;
523 JET_MAX
= 540; // ~30 sec
524 PLAYER_SUIT_TIME
= 30000;
525 PLAYER_INVUL_TIME
= 30000;
526 PLAYER_INVIS_TIME
= 35000;
527 FRAG_COMBO_TIME
= 3000;
531 ANGLE_RIGHTDOWN
= -35;
533 ANGLE_LEFTDOWN
= -145;
534 PLAYER_HEADRECT
: TRectWH
= (X
:24; Y
:12; Width
:20; Height
:12);
535 WEAPONPOINT
: Array [TDirection
] of TPoint
= ((X
:16; Y
:32), (X
:47; Y
:32));
538 BOT_UNSAFEDIST
= 128;
539 TEAMCOLOR
: Array [TEAM_RED
..TEAM_BLUE
] of TRGB
= ((R
:255; G
:0; B
:0),
541 DIFFICULT_EASY
: TDifficult
= (DiagFire
: 32; InvisFire
: 32; DiagPrecision
: 32;
542 FlyPrecision
: 32; Cover
: 32; CloseJump
: 32;
543 WeaponPrior
:(0,0,0,0,0,0,0,0,0,0); CloseWeaponPrior
:(0,0,0,0,0,0,0,0,0,0));
544 DIFFICULT_MEDIUM
: TDifficult
= (DiagFire
: 127; InvisFire
: 127; DiagPrecision
: 127;
545 FlyPrecision
: 127; Cover
: 127; CloseJump
: 127;
546 WeaponPrior
:(0,0,0,0,0,0,0,0,0,0); CloseWeaponPrior
:(0,0,0,0,0,0,0,0,0,0));
547 DIFFICULT_HARD
: TDifficult
= (DiagFire
: 255; InvisFire
: 255; DiagPrecision
: 255;
548 FlyPrecision
: 255; Cover
: 255; CloseJump
: 255;
549 WeaponPrior
:(0,0,0,0,0,0,0,0,0,0); CloseWeaponPrior
:(0,0,0,0,0,0,0,0,0,0));
550 WEAPON_PRIOR1
: Array [WEAPON_KASTET
..WEAPON_SUPERPULEMET
] of Byte =
551 (WEAPON_SUPERPULEMET
, WEAPON_SHOTGUN2
, WEAPON_SHOTGUN1
,
552 WEAPON_CHAINGUN
, WEAPON_PLASMA
, WEAPON_ROCKETLAUNCHER
,
553 WEAPON_BFG
, WEAPON_PISTOL
, WEAPON_SAW
, WEAPON_KASTET
);
554 WEAPON_PRIOR2
: Array [WEAPON_KASTET
..WEAPON_SUPERPULEMET
] of Byte =
555 (WEAPON_SUPERPULEMET
, WEAPON_BFG
, WEAPON_ROCKETLAUNCHER
,
556 WEAPON_SHOTGUN2
, WEAPON_PLASMA
, WEAPON_SHOTGUN1
,
557 WEAPON_CHAINGUN
, WEAPON_PISTOL
, WEAPON_SAW
, WEAPON_KASTET
);
558 //WEAPON_PRIOR3: Array [WEAPON_KASTET..WEAPON_SUPERPULEMET] of Byte =
559 // (WEAPON_SUPERPULEMET, WEAPON_BFG, WEAPON_PLASMA,
560 // WEAPON_SHOTGUN2, WEAPON_CHAINGUN, WEAPON_SHOTGUN1,
561 // WEAPON_SAW, WEAPON_ROCKETLAUNCHER, WEAPON_PISTOL, WEAPON_KASTET);
562 WEAPON_RELOAD
: Array [WEAPON_KASTET
..WEAPON_SUPERPULEMET
] of Byte =
563 (5, 2, 6, 18, 36, 2, 12, 2, 14, 2);
565 PLAYER_SIGNATURE
= $52594C50; // 'PLYR'
566 CORPSE_SIGNATURE
= $50524F43; // 'CORP'
568 BOTNAMES_FILENAME
= 'botnames.txt';
569 BOTLIST_FILENAME
= 'botlist.txt';
573 MaxCorpses
: Word = 20;
574 MaxShells
: Word = 300;
575 CurrentGib
: Integer = 0;
576 CurrentShell
: Integer = 0;
577 BotNames
: Array of String;
578 BotList
: Array of TBotProfile
;
580 function Lerp(X
, Y
, Factor
: Integer): Integer;
582 Result
:= X
+ ((Y
- X
) div Factor
);
585 function SameTeam(UID1
, UID2
: Word): Boolean;
589 if (UID1
> UID_MAX_PLAYER
) or (UID1
<= UID_MAX_GAME
) or
590 (UID2
> UID_MAX_PLAYER
) or (UID2
<= UID_MAX_GAME
) then Exit
;
592 if (g_Player_Get(UID1
) = nil) or (g_Player_Get(UID2
) = nil) then Exit
;
594 if ((g_Player_Get(UID1
).Team
= TEAM_NONE
) or
595 (g_Player_Get(UID2
).Team
= TEAM_NONE
)) then Exit
;
597 Result
:= g_Player_Get(UID1
).FTeam
= g_Player_Get(UID2
).FTeam
;
600 procedure g_Gibs_SetMax(Count
: Word);
603 SetLength(gGibs
, Count
);
605 if CurrentGib
>= Count
then
609 function g_Gibs_GetMax(): Word;
614 procedure g_Shells_SetMax(Count
: Word);
617 SetLength(gShells
, Count
);
619 if CurrentShell
>= Count
then
623 function g_Shells_GetMax(): Word;
629 procedure g_Corpses_SetMax(Count
: Word);
632 SetLength(gCorpses
, Count
);
635 function g_Corpses_GetMax(): Word;
637 Result
:= MaxCorpses
;
640 function g_Player_Create(ModelName
: String; Color
: TRGB
; Team
: Byte; Bot
: Boolean): Word;
650 // Åñòü ëè ìåñòî â gPlayers:
651 if gPlayers
<> nil then
652 for a
:= 0 to High(gPlayers
) do
653 if gPlayers
[a
] = nil then
659 // Íåò ìåñòà - ðàñøèðÿåì gPlayers:
662 SetLength(gPlayers
, Length(gPlayers
)+1);
666 // Ñîçäàåì îáúåêò èãðîêà:
668 gPlayers
[a
] := TBot
.Create()
670 gPlayers
[a
] := TPlayer
.Create();
673 gPlayers
[a
].FActualModelName
:= ModelName
;
674 gPlayers
[a
].SetModel(ModelName
);
676 // Íåò ìîäåëè - ñîçäàíèå íå âîçìîæíî:
677 if gPlayers
[a
].FModel
= nil then
681 g_FatalError(Format(_lc
[I_GAME_ERROR_MODEL
], [ModelName
]));
685 if not (Team
in [TEAM_RED
, TEAM_BLUE
]) then
686 if Random(2) = 0 then
690 gPlayers
[a
].FPreferredTeam
:= Team
;
692 case gGameSettings
.GameMode
of
693 GM_DM
: gPlayers
[a
].FTeam
:= TEAM_NONE
;
695 GM_CTF
: gPlayers
[a
].FTeam
:= gPlayers
[a
].FPreferredTeam
;
697 GM_COOP
: gPlayers
[a
].FTeam
:= TEAM_COOP
;
700 // Åñëè êîìàíäíàÿ èãðà - êðàñèì ìîäåëü â öâåò êîìàíäû:
701 gPlayers
[a
].FColor
:= Color
;
702 if gPlayers
[a
].FTeam
in [TEAM_RED
, TEAM_BLUE
] then
703 gPlayers
[a
].FModel
.Color
:= TEAMCOLOR
[gPlayers
[a
].FTeam
]
705 gPlayers
[a
].FModel
.Color
:= Color
;
707 gPlayers
[a
].FUID
:= g_CreateUID(UID_PLAYER
);
708 gPlayers
[a
].FLive
:= False;
710 Result
:= gPlayers
[a
].FUID
;
713 function g_Player_CreateFromState(var Mem
: TBinMemoryReader
): Word;
726 if sig
<> PLAYER_SIGNATURE
then // 'PLYR'
728 raise EBinSizeError
.Create('g_Player_CreateFromState: Wrong Player Signature');
732 Mem
.ReadBoolean(Bot
);
737 // Åñòü ëè ìåñòî â gPlayers:
738 if gPlayers
<> nil then
739 for a
:= 0 to High(gPlayers
) do
740 if gPlayers
[a
] = nil then
746 // Íåò ìåñòà - ðàñøèðÿåì gPlayers:
749 SetLength(gPlayers
, Length(gPlayers
)+1);
753 // Ñîçäàåì îáúåêò èãðîêà:
755 gPlayers
[a
] := TBot
.Create()
757 gPlayers
[a
] := TPlayer
.Create();
758 gPlayers
[a
].FIamBot
:= Bot
;
759 gPlayers
[a
].FPhysics
:= True;
762 Mem
.ReadWord(gPlayers
[a
].FUID
);
764 Mem
.ReadString(gPlayers
[a
].FName
);
766 Mem
.ReadByte(gPlayers
[a
].FTeam
);
767 gPlayers
[a
].FPreferredTeam
:= gPlayers
[a
].FTeam
;
769 Mem
.ReadBoolean(gPlayers
[a
].FLive
);
770 // Èçðàñõîäîâàë ëè âñå æèçíè:
771 Mem
.ReadBoolean(gPlayers
[a
].FNoRespawn
);
775 gPlayers
[a
].FDirection
:= D_LEFT
777 gPlayers
[a
].FDirection
:= D_RIGHT
;
779 Mem
.ReadInt(gPlayers
[a
].FHealth
);
781 Mem
.ReadByte(gPlayers
[a
].FLives
);
783 Mem
.ReadInt(gPlayers
[a
].FArmor
);
785 Mem
.ReadInt(gPlayers
[a
].FAir
);
787 Mem
.ReadInt(gPlayers
[a
].FJetFuel
);
789 Mem
.ReadInt(gPlayers
[a
].FPain
);
791 Mem
.ReadInt(gPlayers
[a
].FKills
);
793 Mem
.ReadInt(gPlayers
[a
].FMonsterKills
);
795 Mem
.ReadInt(gPlayers
[a
].FFrags
);
797 Mem
.ReadByte(gPlayers
[a
].FFragCombo
);
798 // Âðåìÿ ïîñëåäíåãî ôðàãà:
799 Mem
.ReadDWORD(gPlayers
[a
].FLastFrag
);
801 Mem
.ReadInt(gPlayers
[a
].FDeath
);
803 Mem
.ReadByte(gPlayers
[a
].FFlag
);
805 Mem
.ReadInt(gPlayers
[a
].FSecrets
);
807 Mem
.ReadByte(gPlayers
[a
].FCurrWeap
);
808 // Ñëåäóþùåå æåëàåìîå îðóæèå:
809 Mem
.ReadWord(gPlayers
[a
].FNextWeap
);
810 // Âðåìÿ çàðÿäêè BFG:
811 Mem
.ReadSmallInt(gPlayers
[a
].FBFGFireCounter
);
813 Mem
.ReadInt(gPlayers
[a
].FDamageBuffer
);
814 // Ïîñëåäíèé óäàðèâøèé:
815 Mem
.ReadWord(gPlayers
[a
].FLastSpawnerUID
);
816 // Òèï ïîñëåäíåãî ïîëó÷åííîãî óðîíà:
817 Mem
.ReadByte(gPlayers
[a
].FLastHit
);
819 Obj_LoadState(@gPlayers
[a
].FObj
, Mem
);
820 // Òåêóùåå êîëè÷åñòâî ïàòðîíîâ:
821 for i
:= A_BULLETS
to A_CELLS
do
822 Mem
.ReadWord(gPlayers
[a
].FAmmo
[i
]);
823 // Ìàêñèìàëüíîå êîëè÷åñòâî ïàòðîíîâ:
824 for i
:= A_BULLETS
to A_CELLS
do
825 Mem
.ReadWord(gPlayers
[a
].FMaxAmmo
[i
]);
827 for i
:= WEAPON_KASTET
to WEAPON_SUPERPULEMET
do
828 Mem
.ReadBoolean(gPlayers
[a
].FWeapon
[i
]);
829 // Âðåìÿ ïåðåçàðÿäêè îðóæèÿ:
830 for i
:= WEAPON_KASTET
to WEAPON_SUPERPULEMET
do
831 Mem
.ReadWord(gPlayers
[a
].FReloading
[i
]);
835 Include(gPlayers
[a
].FRulez
, R_ITEM_BACKPACK
);
836 // Íàëè÷èå êðàñíîãî êëþ÷à:
839 Include(gPlayers
[a
].FRulez
, R_KEY_RED
);
840 // Íàëè÷èå çåëåíîãî êëþ÷à:
843 Include(gPlayers
[a
].FRulez
, R_KEY_GREEN
);
844 // Íàëè÷èå ñèíåãî êëþ÷à:
847 Include(gPlayers
[a
].FRulez
, R_KEY_BLUE
);
851 Include(gPlayers
[a
].FRulez
, R_BERSERK
);
852 // Âðåìÿ äåéñòâèÿ ñïåöèàëüíûõ ïðåäìåòîâ:
853 for i
:= MR_SUIT
to MR_MAX
do
854 Mem
.ReadDWORD(gPlayers
[a
].FMegaRulez
[i
]);
855 // Âðåìÿ äî ïîâòîðíîãî ðåñïàóíà, ñìåíû îðóæèÿ, èñîëüçîâàíèÿ, çàõâàòà ôëàãà:
856 for i
:= T_RESPAWN
to T_FLAGCAP
do
857 Mem
.ReadDWORD(gPlayers
[a
].FTime
[i
]);
860 Mem
.ReadString(gPlayers
[a
].FActualModelName
);
862 Mem
.ReadByte(gPlayers
[a
].FColor
.R
);
863 Mem
.ReadByte(gPlayers
[a
].FColor
.G
);
864 Mem
.ReadByte(gPlayers
[a
].FColor
.B
);
865 // Îáíîâëÿåì ìîäåëü èãðîêà:
866 gPlayers
[a
].SetModel(gPlayers
[a
].FActualModelName
);
868 // Íåò ìîäåëè - ñîçäàíèå íå âîçìîæíî:
869 if gPlayers
[a
].FModel
= nil then
873 g_FatalError(Format(_lc
[I_GAME_ERROR_MODEL
], [gPlayers
[a
].FActualModelName
]));
877 // Åñëè êîìàíäíàÿ èãðà - êðàñèì ìîäåëü â öâåò êîìàíäû:
878 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
879 gPlayers
[a
].FModel
.Color
:= TEAMCOLOR
[gPlayers
[a
].FTeam
]
881 gPlayers
[a
].FModel
.Color
:= gPlayers
[a
].FColor
;
883 Result
:= gPlayers
[a
].FUID
;
886 procedure g_Player_ResetTeams();
890 if g_Game_IsClient
then
892 if gPlayers
= nil then
894 for a
:= Low(gPlayers
) to High(gPlayers
) do
895 if gPlayers
[a
] <> nil then
896 case gGameSettings
.GameMode
of
898 gPlayers
[a
].ChangeTeam(TEAM_NONE
);
900 if not (gPlayers
[a
].Team
in [TEAM_RED
, TEAM_BLUE
]) then
901 if gPlayers
[a
].FPreferredTeam
in [TEAM_RED
, TEAM_BLUE
] then
902 gPlayers
[a
].ChangeTeam(gPlayers
[a
].FPreferredTeam
)
905 gPlayers
[a
].ChangeTeam(TEAM_RED
)
907 gPlayers
[a
].ChangeTeam(TEAM_BLUE
);
910 gPlayers
[a
].ChangeTeam(TEAM_COOP
);
914 procedure g_Bot_Add(Team
, Difficult
: Byte);
917 _name
, _model
: String;
920 if not g_Game_IsServer
then Exit
;
922 // Ñïèñîê íàçâàíèé ìîäåëåé:
923 m
:= g_PlayerModel_GetNames();
928 if (gGameSettings
.GameType
= GT_SINGLE
) or (gGameSettings
.GameMode
= GM_COOP
) then
929 Team
:= TEAM_COOP
// COOP
931 if gGameSettings
.GameMode
= GM_DM
then
932 Team
:= TEAM_NONE
// DM
934 if Team
= TEAM_NONE
then // CTF / TDM
936 // Àâòîáàëàíñ êîìàíä:
940 for a
:= 0 to High(gPlayers
) do
941 if gPlayers
[a
] <> nil then
943 if gPlayers
[a
].Team
= TEAM_RED
then
946 if gPlayers
[a
].Team
= TEAM_BLUE
then
956 if Random(2) = 0 then
962 // Âûáèðàåì áîòó èìÿ:
964 if BotNames
<> nil then
965 for a
:= 0 to High(BotNames
) do
966 if g_Player_ValidName(BotNames
[a
]) then
968 _name
:= BotNames
[a
];
972 // Èìåíè íåò, çàäàåì ñëó÷àéíîå:
975 _name
:= Format('DFBOT%.2d', [Random(100)]);
976 until g_Player_ValidName(_name
);
978 // Âûáèðàåì ñëó÷àéíóþ ìîäåëü:
979 _model
:= m
[Random(Length(m
))];
982 with g_Player_Get(g_Player_Create(_model
,
983 _RGB(Min(Random(9)*32, 255),
984 Min(Random(9)*32, 255),
985 Min(Random(9)*32, 255)),
986 Team
, True)) as TBot
do
991 1: FDifficult
:= DIFFICULT_EASY
;
992 2: FDifficult
:= DIFFICULT_MEDIUM
;
993 else FDifficult
:= DIFFICULT_HARD
;
996 for a
:= WEAPON_KASTET
to WEAPON_SUPERPULEMET
do
998 FDifficult
.WeaponPrior
[a
] := WEAPON_PRIOR1
[a
];
999 FDifficult
.CloseWeaponPrior
[a
] := WEAPON_PRIOR2
[a
];
1000 //FDifficult.SafeWeaponPrior[a] := WEAPON_PRIOR3[a];
1003 g_Console_Add(Format(_lc
[I_PLAYER_JOIN
], [Name
]), True);
1005 if g_Game_IsNet
then MH_SEND_PlayerCreate(UID
);
1006 if g_Game_IsServer
and (gGameSettings
.MaxLives
> 0) then
1011 procedure g_Bot_AddList(Team
: Byte; lName
: ShortString; num
: Integer = -1);
1014 _name
, _model
: String;
1017 if not g_Game_IsServer
then Exit
;
1019 // Ñïèñîê íàçâàíèé ìîäåëåé:
1020 m
:= g_PlayerModel_GetNames();
1025 if (gGameSettings
.GameType
= GT_SINGLE
) or (gGameSettings
.GameMode
= GM_COOP
) then
1026 Team
:= TEAM_COOP
// COOP
1028 if gGameSettings
.GameMode
= GM_DM
then
1029 Team
:= TEAM_NONE
// DM
1031 if Team
= TEAM_NONE
then
1032 Team
:= BotList
[num
].team
; // CTF / TDM
1034 // Âûáèðàåì íàñòðîéêè áîòà èç ñïèñêà ïî íîìåðó èëè èìåíè:
1035 lName
:= AnsiLowerCase(lName
);
1036 if (num
< 0) or (num
> Length(BotList
)-1) then
1038 if (num
= -1) and (lName
<> '') and (BotList
<> nil) then
1039 for a
:= 0 to High(BotList
) do
1040 if AnsiLowerCase(BotList
[a
].name
) = lName
then
1049 _name
:= BotList
[num
].name
;
1050 // Çàíÿòî - âûáèðàåì ñëó÷àéíîå:
1051 if not g_Player_ValidName(_name
) then
1053 _name
:= Format('DFBOT%.2d', [Random(100)]);
1054 until g_Player_ValidName(_name
);
1057 _model
:= BotList
[num
].model
;
1058 // Íåò òàêîé - âûáèðàåì ñëó÷àéíóþ:
1059 if not InSArray(_model
, m
) then
1060 _model
:= m
[Random(Length(m
))];
1063 with g_Player_Get(g_Player_Create(_model
, BotList
[num
].color
, Team
, True)) as TBot
do
1067 FDifficult
.DiagFire
:= BotList
[num
].diag_fire
;
1068 FDifficult
.InvisFire
:= BotList
[num
].invis_fire
;
1069 FDifficult
.DiagPrecision
:= BotList
[num
].diag_precision
;
1070 FDifficult
.FlyPrecision
:= BotList
[num
].fly_precision
;
1071 FDifficult
.Cover
:= BotList
[num
].cover
;
1072 FDifficult
.CloseJump
:= BotList
[num
].close_jump
;
1074 for a
:= WEAPON_KASTET
to WEAPON_SUPERPULEMET
do
1076 FDifficult
.WeaponPrior
[a
] := BotList
[num
].w_prior1
[a
];
1077 FDifficult
.CloseWeaponPrior
[a
] := BotList
[num
].w_prior2
[a
];
1078 //FDifficult.SafeWeaponPrior[a] := BotList[num].w_prior3[a];
1081 g_Console_Add(Format(_lc
[I_PLAYER_JOIN
], [Name
]), True);
1083 if g_Game_IsNet
then MH_SEND_PlayerCreate(UID
);
1087 procedure g_Bot_RemoveAll();
1091 if not g_Game_IsServer
then Exit
;
1092 if gPlayers
= nil then Exit
;
1094 for a
:= 0 to High(gPlayers
) do
1095 if gPlayers
[a
] <> nil then
1096 if gPlayers
[a
] is TBot
then
1098 gPlayers
[a
].Lives
:= 0;
1099 gPlayers
[a
].Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
1100 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [gPlayers
[a
].Name
]), True);
1101 g_Player_Remove(gPlayers
[a
].FUID
);
1107 procedure g_Bot_MixNames();
1112 if BotNames
<> nil then
1113 for a
:= 0 to High(BotNames
) do
1115 b
:= Random(Length(BotNames
));
1117 Botnames
[a
] := BotNames
[b
];
1122 procedure g_Player_Remove(UID
: Word);
1126 if gPlayers
= nil then Exit
;
1128 if g_Game_IsServer
and g_Game_IsNet
then
1129 MH_SEND_PlayerDelete(UID
);
1131 for i
:= 0 to High(gPlayers
) do
1132 if gPlayers
[i
] <> nil then
1133 if gPlayers
[i
].FUID
= UID
then
1135 if gPlayers
[i
] is TPlayer
then
1136 TPlayer(gPlayers
[i
]).Free()
1138 TBot(gPlayers
[i
]).Free();
1144 procedure g_Player_Init();
1154 if not FileExists(DataDir
+ BOTNAMES_FILENAME
) then
1157 // ×èòàåì âîçìîæíûå èìåíà áîòîâ èç ôàéëà:
1158 AssignFile(F
, DataDir
+ BOTNAMES_FILENAME
);
1169 SetLength(BotNames
, Length(BotNames
)+1);
1170 BotNames
[High(BotNames
)] := s
;
1178 // ×èòàåì ôàéë ñ ïàðàìåòðàìè áîòîâ:
1179 config
:= TConfig
.CreateFile(DataDir
+ BOTLIST_FILENAME
);
1183 while config
.SectionExists(IntToStr(a
)) do
1185 SetLength(BotList
, Length(BotList
)+1);
1187 with BotList
[High(BotList
)] do
1190 name
:= config
.ReadStr(IntToStr(a
), 'name', '');
1192 model
:= config
.ReadStr(IntToStr(a
), 'model', '');
1194 if config
.ReadStr(IntToStr(a
), 'team', 'red') = 'red' then
1199 sa
:= parse(config
.ReadStr(IntToStr(a
), 'color', ''));
1200 color
.R
:= StrToIntDef(sa
[0], 0);
1201 color
.G
:= StrToIntDef(sa
[1], 0);
1202 color
.B
:= StrToIntDef(sa
[2], 0);
1203 // Âåðîÿòíîñòü ñòðåëüáû ïîä óãëîì:
1204 diag_fire
:= config
.ReadInt(IntToStr(a
), 'diag_fire', 0);
1205 // Âåðîÿòíîñòü îòâåòíîãî îãíÿ ïî íåâèäèìîìó ñîïåðíèêó:
1206 invis_fire
:= config
.ReadInt(IntToStr(a
), 'invis_fire', 0);
1207 // Òî÷íîñòü ñòðåëüáû ïîä óãëîì:
1208 diag_precision
:= config
.ReadInt(IntToStr(a
), 'diag_precision', 0);
1209 // Òî÷íîñòü ñòðåëüáû â ïîëåòå:
1210 fly_precision
:= config
.ReadInt(IntToStr(a
), 'fly_precision', 0);
1211 // Òî÷íîñòü óêëîíåíèÿ îò ñíàðÿäîâ:
1212 cover
:= config
.ReadInt(IntToStr(a
), 'cover', 0);
1213 // Âåðîÿòíîñòü ïðûæêà ïðè ïðèáëèæåíèè ñîïåðíèêà:
1214 close_jump
:= config
.ReadInt(IntToStr(a
), 'close_jump', 0);
1215 // Ïðèîðèòåòû îðóæèÿ äëÿ äàëüíåãî áîÿ:
1216 sa
:= parse(config
.ReadStr(IntToStr(a
), 'w_prior1', ''));
1217 if Length(sa
) = 10 then
1219 w_prior1
[b
] := EnsureRange(StrToInt(sa
[b
]), 0, 9);
1220 // Ïðèîðèòåòû îðóæèÿ äëÿ áëèæíåãî áîÿ:
1221 sa
:= parse(config
.ReadStr(IntToStr(a
), 'w_prior2', ''));
1222 if Length(sa
) = 10 then
1224 w_prior2
[b
] := EnsureRange(StrToInt(sa
[b
]), 0, 9);
1226 {sa := parse(config.ReadStr(IntToStr(a), 'w_prior3', ''));
1227 if Length(sa) = 10 then
1229 w_prior3[b] := EnsureRange(StrToInt(sa[b]), 0, 9);}
1238 procedure g_Player_Free();
1242 if gPlayers
<> nil then
1244 for i
:= 0 to High(gPlayers
) do
1245 if gPlayers
[i
] <> nil then
1247 if gPlayers
[i
] is TPlayer
then
1248 TPlayer(gPlayers
[i
]).Free()
1250 TBot(gPlayers
[i
]).Free();
1261 procedure g_Player_UpdateAll();
1265 if gPlayers
= nil then Exit
;
1267 for i
:= 0 to High(gPlayers
) do
1268 if gPlayers
[i
] <> nil then
1269 if gPlayers
[i
] is TPlayer
then gPlayers
[i
].Update()
1270 else TBot(gPlayers
[i
]).Update();
1273 procedure g_Player_DrawAll();
1277 if gPlayers
= nil then Exit
;
1279 for i
:= 0 to High(gPlayers
) do
1280 if gPlayers
[i
] <> nil then
1281 if gPlayers
[i
] is TPlayer
then gPlayers
[i
].Draw()
1282 else TBot(gPlayers
[i
]).Draw();
1285 procedure g_Player_DrawDebug(p
: TPlayer
);
1289 if p
= nil then Exit
;
1290 if (@p
.FObj
) = nil then Exit
;
1292 e_TextureFontGetSize(gStdFont
, fW
, fH
);
1294 e_TextureFontPrint(0, 0 , 'Pos X: ' + IntToStr(p
.FObj
.X
), gStdFont
);
1295 e_TextureFontPrint(0, fH
, 'Pos Y: ' + IntToStr(p
.FObj
.Y
), gStdFont
);
1296 e_TextureFontPrint(0, fH
* 2, 'Vel X: ' + IntToStr(p
.FObj
.Vel
.X
), gStdFont
);
1297 e_TextureFontPrint(0, fH
* 3, 'Vel Y: ' + IntToStr(p
.FObj
.Vel
.Y
), gStdFont
);
1298 e_TextureFontPrint(0, fH
* 4, 'Acc X: ' + IntToStr(p
.FObj
.Accel
.X
), gStdFont
);
1299 e_TextureFontPrint(0, fH
* 5, 'Acc Y: ' + IntToStr(p
.FObj
.Accel
.Y
), gStdFont
);
1302 procedure g_Player_DrawHealth();
1307 if gPlayers
= nil then Exit
;
1308 e_TextureFontGetSize(gStdFont
, fW
, fH
);
1310 for i
:= 0 to High(gPlayers
) do
1311 if gPlayers
[i
] <> nil then
1313 e_TextureFontPrint(gPlayers
[i
].FObj
.X
+ gPlayers
[i
].FObj
.Rect
.X
,
1314 gPlayers
[i
].FObj
.Y
+ gPlayers
[i
].FObj
.Rect
.Y
+ gPlayers
[i
].FObj
.Rect
.Height
- fH
* 2,
1315 IntToStr(gPlayers
[i
].FHealth
), gStdFont
);
1316 e_TextureFontPrint(gPlayers
[i
].FObj
.X
+ gPlayers
[i
].FObj
.Rect
.X
,
1317 gPlayers
[i
].FObj
.Y
+ gPlayers
[i
].FObj
.Rect
.Y
+ gPlayers
[i
].FObj
.Rect
.Height
- fH
,
1318 IntToStr(gPlayers
[i
].FArmor
), gStdFont
);
1322 function g_Player_Get(UID
: Word): TPlayer
;
1328 if gPlayers
= nil then
1331 for a
:= 0 to High(gPlayers
) do
1332 if gPlayers
[a
] <> nil then
1333 if gPlayers
[a
].FUID
= UID
then
1335 Result
:= gPlayers
[a
];
1340 function g_Player_GetCount(): Byte;
1346 if gPlayers
= nil then
1349 for a
:= 0 to High(gPlayers
) do
1350 if gPlayers
[a
] <> nil then
1351 Result
:= Result
+ 1;
1354 function g_Player_GetStats(): TPlayerStatArray
;
1360 if gPlayers
= nil then Exit
;
1362 for a
:= 0 to High(gPlayers
) do
1363 if gPlayers
[a
] <> nil then
1365 SetLength(Result
, Length(Result
)+1);
1366 with Result
[High(Result
)] do
1368 Ping
:= gPlayers
[a
].FPing
;
1369 Loss
:= gPlayers
[a
].FLoss
;
1370 Name
:= gPlayers
[a
].FName
;
1371 Team
:= gPlayers
[a
].FTeam
;
1372 Frags
:= gPlayers
[a
].FFrags
;
1373 Deaths
:= gPlayers
[a
].FDeath
;
1374 Kills
:= gPlayers
[a
].FKills
;
1375 Color
:= gPlayers
[a
].FModel
.Color
;
1376 Lives
:= gPlayers
[a
].FLives
;
1377 Spectator
:= gPlayers
[a
].FSpectator
;
1382 procedure g_Player_RememberAll
;
1386 for i
:= Low(gPlayers
) to High(gPlayers
) do
1387 if (gPlayers
[i
] <> nil) and gPlayers
[i
].Live
then
1388 gPlayers
[i
].RememberState
;
1391 procedure g_Player_ResetAll(Force
, Silent
: Boolean);
1395 gTeamStat
[TEAM_RED
].Goals
:= 0;
1396 gTeamStat
[TEAM_BLUE
].Goals
:= 0;
1398 if gPlayers
<> nil then
1399 for i
:= 0 to High(gPlayers
) do
1400 if gPlayers
[i
] <> nil then
1402 gPlayers
[i
].Reset(Force
);
1404 if gPlayers
[i
] is TPlayer
then
1406 if (not gPlayers
[i
].FSpectator
) or gPlayers
[i
].FWantsInGame
then
1407 gPlayers
[i
].Respawn(Silent
)
1409 gPlayers
[i
].Spectate();
1412 TBot(gPlayers
[i
]).Respawn(Silent
);
1416 procedure g_Player_CreateCorpse(Player
: TPlayer
);
1423 if Player
.FObj
.Y
>= gMapInfo
.Height
+128 then
1428 if (FHealth
>= -50) or (gGibsCount
= 0) then
1430 if (gCorpses
= nil) or (Length(gCorpses
) = 0) then
1434 for find_id
:= 0 to High(gCorpses
) do
1435 if gCorpses
[find_id
] = nil then
1442 find_id
:= Random(Length(gCorpses
));
1444 gCorpses
[find_id
] := TCorpse
.Create(FObj
.X
, FObj
.Y
, FModel
.Name
, FHealth
< -20);
1445 gCorpses
[find_id
].FColor
:= FModel
.Color
;
1446 gCorpses
[find_id
].FObj
.Vel
:= FObj
.Vel
;
1447 gCorpses
[find_id
].FObj
.Accel
:= FObj
.Accel
;
1450 g_Player_CreateGibs(FObj
.X
+ PLAYER_RECT_CX
,
1451 FObj
.Y
+ PLAYER_RECT_CY
,
1452 FModel
.Name
, FModel
.Color
);
1456 procedure g_Player_CreateShell(fX
, fY
, dX
, dY
: Integer; T
: Byte);
1460 if (gShells
= nil) or (Length(gShells
) = 0) then
1463 with gShells
[CurrentShell
] do
1469 if T
= SHELL_BULLET
then
1471 if g_Texture_Get('TEXTURE_SHELL_BULLET', SID
) then
1475 Obj
.Rect
.Width
:= 4;
1476 Obj
.Rect
.Height
:= 2;
1480 if g_Texture_Get('TEXTURE_SHELL_SHELL', SID
) then
1484 Obj
.Rect
.Width
:= 7;
1485 Obj
.Rect
.Height
:= 3;
1491 g_Obj_Push(@Obj
, dX
+ Random(4)-Random(4), dY
-Random(4));
1492 RAngle
:= Random(360);
1493 Timeout
:= gTime
+ SHELL_TIMEOUT
;
1495 if CurrentShell
>= High(gShells
) then
1502 procedure g_Player_CreateGibs(fX
, fY
: Integer; ModelName
: string; fColor
: TRGB
);
1505 GibsArray
: TGibsArray
;
1507 if (gGibs
= nil) or (Length(gGibs
) = 0) then
1509 if not g_PlayerModel_GetGibs(ModelName
, GibsArray
) then
1512 for a
:= 0 to High(GibsArray
) do
1513 with gGibs
[CurrentGib
] do
1516 ID
:= GibsArray
[a
].ID
;
1517 MaskID
:= GibsArray
[a
].MaskID
;
1520 Obj
.Rect
:= GibsArray
[a
].Rect
;
1521 Obj
.X
:= fX
-GibsArray
[a
].Rect
.X
-(GibsArray
[a
].Rect
.Width
div 2);
1522 Obj
.Y
:= fY
-GibsArray
[a
].Rect
.Y
-(GibsArray
[a
].Rect
.Height
div 2);
1523 g_Obj_PushA(@Obj
, 25 + Random(10), Random(361));
1524 RAngle
:= Random(360);
1526 if gBloodCount
> 0 then
1527 g_GFX_Blood(fX
, fY
, 16*gBloodCount
+Random(5*gBloodCount
), -16+Random(33), -16+Random(33),
1528 Random(48), Random(48), 150, 0, 0);
1530 if CurrentGib
>= High(gGibs
) then
1537 procedure g_Player_UpdatePhysicalObjects();
1543 procedure ShellSound_Bounce(X
, Y
: Integer; T
: Byte);
1548 if T
= SHELL_BULLET
then
1549 g_Sound_PlayExAt('SOUND_PLAYER_CASING' + IntToStr(k
), X
, Y
)
1551 g_Sound_PlayExAt('SOUND_PLAYER_SHELL' + IntToStr(k
), X
, Y
);
1556 if gGibs
<> nil then
1557 for i
:= 0 to High(gGibs
) do
1558 if gGibs
[i
].Live
then
1562 mr
:= g_Obj_Move(@Obj
, True, False, True);
1564 if WordBool(mr
and MOVE_FALLOUT
) then
1570 // Îòëåòàåò îò óäàðà î ñòåíó/ïîòîëîê/ïîë:
1571 if WordBool(mr
and MOVE_HITWALL
) then
1572 Obj
.Vel
.X
:= -(vel
.X
div 2);
1573 if WordBool(mr
and (MOVE_HITCEIL
or MOVE_HITLAND
)) then
1574 Obj
.Vel
.Y
:= -(vel
.Y
div 2);
1576 if (Obj
.Vel
.X
>= 0) then
1578 RAngle
:= RAngle
+ Abs(Obj
.Vel
.X
)*6 + Abs(Obj
.Vel
.Y
);
1579 if RAngle
>= 360 then
1580 RAngle
:= RAngle
mod 360;
1581 end else begin // Counter-clockwise
1582 RAngle
:= RAngle
- Abs(Obj
.Vel
.X
)*6 - Abs(Obj
.Vel
.Y
);
1584 RAngle
:= (360 - (Abs(RAngle
) mod 360)) mod 360;
1587 // Ñîïðîòèâëåíèå âîçäóõà äëÿ êóñêà òðóïà:
1588 if gTime
mod (GAME_TICK
*3) = 0 then
1589 Obj
.Vel
.X
:= z_dec(Obj
.Vel
.X
, 1);
1593 if gCorpses
<> nil then
1594 for i
:= 0 to High(gCorpses
) do
1595 if gCorpses
[i
] <> nil then
1596 if gCorpses
[i
].State
= CORPSE_STATE_REMOVEME
then
1602 gCorpses
[i
].Update();
1605 if gShells
<> nil then
1606 for i
:= 0 to High(gShells
) do
1607 if gShells
[i
].Live
then
1611 mr
:= g_Obj_Move(@Obj
, True, False, True);
1613 if WordBool(mr
and MOVE_FALLOUT
) or (gShells
[i
].Timeout
< gTime
) then
1619 // Îòëåòàåò îò óäàðà î ñòåíó/ïîòîëîê/ïîë:
1620 if WordBool(mr
and MOVE_HITWALL
) then
1622 Obj
.Vel
.X
:= -(vel
.X
div 2);
1623 if not WordBool(mr
and MOVE_INWATER
) then
1624 ShellSound_Bounce(Obj
.X
, Obj
.Y
, SType
);
1626 if WordBool(mr
and (MOVE_HITCEIL
or MOVE_HITLAND
)) then
1628 Obj
.Vel
.Y
:= -(vel
.Y
div 2);
1629 if Obj
.Vel
.X
<> 0 then Obj
.Vel
.X
:= Obj
.Vel
.X
div 2;
1630 if (Obj
.Vel
.X
= 0) and (Obj
.Vel
.Y
= 0) then
1632 if RAngle
mod 90 <> 0 then
1633 RAngle
:= (RAngle
div 90) * 90;
1635 else if not WordBool(mr
and MOVE_INWATER
) then
1636 ShellSound_Bounce(Obj
.X
, Obj
.Y
, SType
);
1639 if (Obj
.Vel
.X
>= 0) then
1641 RAngle
:= RAngle
+ Abs(Obj
.Vel
.X
)*8 + Abs(Obj
.Vel
.Y
);
1642 if RAngle
>= 360 then
1643 RAngle
:= RAngle
mod 360;
1644 end else begin // Counter-clockwise
1645 RAngle
:= RAngle
- Abs(Obj
.Vel
.X
)*8 - Abs(Obj
.Vel
.Y
);
1647 RAngle
:= (360 - (Abs(RAngle
) mod 360)) mod 360;
1652 procedure g_Player_DrawCorpses();
1657 if gGibs
<> nil then
1658 for i
:= 0 to High(gGibs
) do
1659 if gGibs
[i
].Live
then
1662 if not g_Obj_Collide(sX
, sY
, sWidth
, sHeight
, @Obj
) then
1665 a
.X
:= Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2);
1666 a
.y
:= Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2);
1668 e_DrawAdv(ID
, Obj
.X
, Obj
.Y
, 0, True, False, RAngle
, @a
, M_NONE
);
1671 e_DrawAdv(MaskID
, Obj
.X
, Obj
.Y
, 0, True, False, RAngle
, @a
, M_NONE
);
1677 if gCorpses
<> nil then
1678 for i
:= 0 to High(gCorpses
) do
1679 if gCorpses
[i
] <> nil then
1683 procedure g_Player_DrawShells();
1688 if gShells
<> nil then
1689 for i
:= 0 to High(gShells
) do
1690 if gShells
[i
].Live
then
1693 if not g_Obj_Collide(sX
, sY
, sWidth
, sHeight
, @Obj
) then
1699 e_DrawAdv(SpriteID
, Obj
.X
, Obj
.Y
, 0, True, False, RAngle
, @a
, M_NONE
);
1703 procedure g_Player_RemoveAllCorpses();
1709 SetLength(gGibs
, MaxGibs
);
1710 SetLength(gShells
, MaxGibs
);
1714 if gCorpses
<> nil then
1715 for i
:= 0 to High(gCorpses
) do
1719 SetLength(gCorpses
, MaxCorpses
);
1722 procedure g_Player_Corpses_SaveState(var Mem
: TBinMemoryWriter
);
1727 // Ñ÷èòàåì êîëè÷åñòâî ñóùåñòâóþùèõ òðóïîâ:
1729 if gCorpses
<> nil then
1730 for i
:= 0 to High(gCorpses
) do
1731 if gCorpses
[i
] <> nil then
1734 Mem
:= TBinMemoryWriter
.Create((count
+1) * 128);
1736 // Êîëè÷åñòâî òðóïîâ:
1737 Mem
.WriteInt(count
);
1743 for i
:= 0 to High(gCorpses
) do
1744 if gCorpses
[i
] <> nil then
1747 Mem
.WriteString(gCorpses
[i
].FModelName
);
1749 b
:= gCorpses
[i
].Mess
;
1750 Mem
.WriteBoolean(b
);
1751 // Ñîõðàíÿåì äàííûå òðóïà:
1752 gCorpses
[i
].SaveState(Mem
);
1756 procedure g_Player_Corpses_LoadState(var Mem
: TBinMemoryReader
);
1765 g_Player_RemoveAllCorpses();
1767 // Êîëè÷åñòâî òðóïîâ:
1770 if count
> Length(gCorpses
) then
1772 raise EBinSizeError
.Create('g_Player_Corpses_LoadState: Too Many Corpses');
1779 for i
:= 0 to count
-1 do
1782 Mem
.ReadString(str
);
1786 gCorpses
[i
] := TCorpse
.Create(0, 0, str
, b
);
1787 // Çàãðóæàåì äàííûå òðóïà:
1788 gCorpses
[i
].LoadState(Mem
);
1794 procedure TPlayer
.BFGHit();
1796 g_Weapon_BFGHit(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
1797 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2));
1798 if g_Game_IsServer
and g_Game_IsNet
then
1799 MH_SEND_Effect(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
1800 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2),
1804 procedure TPlayer
.ChangeModel(ModelName
: string);
1806 Model
: TPlayerModel
;
1808 Model
:= g_PlayerModel_Get(ModelName
);
1809 if Model
= nil then Exit
;
1815 procedure TPlayer
.SetModel(ModelName
: string);
1819 m
:= g_PlayerModel_Get(ModelName
);
1822 g_SimpleError(Format(_lc
[I_GAME_ERROR_MODEL_FALLBACK
], [ModelName
]));
1823 m
:= g_PlayerModel_Get('doomer');
1826 g_FatalError(Format(_lc
[I_GAME_ERROR_MODEL
], ['doomer']));
1831 if FModel
<> nil then
1836 if not (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then
1837 FModel
.Color
:= FColor
1839 FModel
.Color
:= TEAMCOLOR
[FTeam
];
1840 FModel
.SetWeapon(FCurrWeap
);
1841 FModel
.SetFlag(FFlag
);
1842 SetDirection(FDirection
);
1845 procedure TPlayer
.SetColor(Color
: TRGB
);
1848 if not (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then
1849 if FModel
<> nil then FModel
.Color
:= Color
;
1852 procedure TPlayer
.SwitchTeam
;
1854 if g_Game_IsClient
then
1856 if not (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then Exit
;
1858 if gGameOn
and FLive
then
1859 Kill(K_SIMPLEKILL
, FUID
, HIT_SELF
);
1861 if FTeam
= TEAM_RED
then
1863 ChangeTeam(TEAM_BLUE
);
1864 g_Console_Add(Format(_lc
[I_PLAYER_CHTEAM_BLUE
], [FName
]), True);
1865 if g_Game_IsNet
then
1866 MH_SEND_GameEvent(NET_EV_CHANGE_TEAM
, TEAM_BLUE
, FName
);
1870 ChangeTeam(TEAM_RED
);
1871 g_Console_Add(Format(_lc
[I_PLAYER_CHTEAM_RED
], [FName
]), True);
1872 if g_Game_IsNet
then
1873 MH_SEND_GameEvent(NET_EV_CHANGE_TEAM
, TEAM_RED
, FName
);
1875 FPreferredTeam
:= FTeam
;
1878 procedure TPlayer
.ChangeTeam(Team
: Byte);
1885 TEAM_RED
, TEAM_BLUE
:
1886 FModel
.Color
:= TEAMCOLOR
[Team
];
1888 FModel
.Color
:= FColor
;
1890 if (FTeam
<> OldTeam
) and g_Game_IsNet
and g_Game_IsServer
then
1891 MH_SEND_PlayerStats(FUID
);
1895 procedure TPlayer.CollideItem();
1900 if gItems = nil then Exit;
1901 if not FLive then Exit;
1903 for i := 0 to High(gItems) do
1906 if (ItemType <> ITEM_NONE) and Live then
1907 if g_Obj_Collide(FObj.X+PLAYER_RECT.X, FObj.Y+PLAYER_RECT.Y, PLAYER_RECT.Width,
1908 PLAYER_RECT.Height, @Obj) then
1910 if not PickItem(ItemType, gItems[i].Respawnable, r) then Continue;
1912 if ItemType in [ITEM_SPHERE_BLUE, ITEM_SPHERE_WHITE, ITEM_INVUL] then
1913 g_Sound_PlayExAt('SOUND_ITEM_GETRULEZ', FObj.X, FObj.Y)
1914 else if ItemType in [ITEM_MEDKIT_SMALL, ITEM_MEDKIT_LARGE, ITEM_MEDKIT_BLACK] then
1915 g_Sound_PlayExAt('SOUND_ITEM_GETMED', FObj.X, FObj.Y)
1916 else g_Sound_PlayExAt('SOUND_ITEM_GETITEM', FObj.X, FObj.Y);
1918 // Íàäî óáðàòü ñ êàðòû, åñëè ýòî íå êëþ÷, êîòîðûì íóæíî ïîäåëèòñÿ ñ äðóãèì èãðîêîì:
1919 if r and not ((ItemType in [ITEM_KEY_RED, ITEM_KEY_GREEN, ITEM_KEY_BLUE]) and
1920 (gGameSettings.GameType = GT_SINGLE) and
1921 (g_Player_GetCount() > 1)) then
1922 if not Respawnable then g_Items_Remove(i) else g_Items_Pick(i);
1928 function TPlayer
.CollideLevel(XInc
, YInc
: Integer): Boolean;
1930 Result
:= g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
,
1931 PLAYER_RECT
.Width
, PLAYER_RECT
.Height
, PANEL_WALL
,
1935 constructor TPlayer
.Create();
1941 FSawSound
:= TPlayableSound
.Create();
1942 FSawSoundIdle
:= TPlayableSound
.Create();
1943 FSawSoundHit
:= TPlayableSound
.Create();
1944 FSawSoundSelect
:= TPlayableSound
.Create();
1945 FJetSoundFly
:= TPlayableSound
.Create();
1946 FJetSoundOn
:= TPlayableSound
.Create();
1947 FJetSoundOff
:= TPlayableSound
.Create();
1949 FSawSound
.SetByName('SOUND_WEAPON_FIRESAW');
1950 FSawSoundIdle
.SetByName('SOUND_WEAPON_IDLESAW');
1951 FSawSoundHit
.SetByName('SOUND_WEAPON_HITSAW');
1952 FSawSoundSelect
.SetByName('SOUND_WEAPON_SELECTSAW');
1953 FJetSoundFly
.SetByName('SOUND_PLAYER_JETFLY');
1954 FJetSoundOn
.SetByName('SOUND_PLAYER_JETON');
1955 FJetSoundOff
.SetByName('SOUND_PLAYER_JETOFF');
1957 FSpectatePlayer
:= -1;
1961 FSavedState
.WaitRecall
:= False;
1964 FActualModelName
:= 'doomer';
1967 FObj
.Rect
:= PLAYER_RECT
;
1969 FBFGFireCounter
:= -1;
1970 FJustTeleported
:= False;
1974 procedure TPlayer
.Damage(value
: Word; SpawnerUID
: Word; vx
, vy
: Integer; t
: Byte);
1978 if (not g_Game_IsClient
) and (not FLive
) then
1983 // Íåóÿçâèìîñòü íå ñïàñàåò îò ëîâóøåê:
1984 if ((t
= HIT_TRAP
) or (t
= HIT_SELF
)) and (not FGodMode
) then
1986 if not g_Game_IsClient
then
1989 if t
= HIT_TRAP
then
1991 // Ëîâóøêà óáèâàåò ñðàçó:
1993 Kill(K_EXTRAHARDKILL
, SpawnerUID
, t
);
1995 if t
= HIT_SELF
then
1999 Kill(K_SIMPLEKILL
, SpawnerUID
, t
);
2002 // Îáíóëèòü äåéñòâèÿ ïðèìî÷åê, ÷òîáû ôîí ïðîïàë
2003 FMegaRulez
[MR_SUIT
] := 0;
2004 FMegaRulez
[MR_INVUL
] := 0;
2005 FMegaRulez
[MR_INVIS
] := 0;
2009 // Íî îò îñòàëüíîãî ñïàñàåò:
2010 if FMegaRulez
[MR_INVUL
] >= gTime
then
2017 // Åñëè åñòü óðîí ñâîèì, èëè ðàíèë ñàì ñåáÿ, èëè òåáÿ ðàíèë ïðîòèâíèê:
2018 if LongBool(gGameSettings
.Options
and GAME_OPTION_TEAMDAMAGE
) or
2019 (SpawnerUID
= FUID
) or
2020 (not SameTeam(FUID
, SpawnerUID
)) then
2022 FLastSpawnerUID
:= SpawnerUID
;
2024 // Êðîâü (ïóçûðüêè, åñëè â âîäå):
2025 if gBloodCount
> 0 then
2027 c
:= Min(value
, 200)*gBloodCount
+ Random(Min(value
, 200) div 2);
2028 if value
div 4 <= c
then
2029 c
:= c
- (value
div 4)
2033 if (t
= HIT_SOME
) and (vx
= 0) and (vy
= 0) then
2037 HIT_TRAP
, HIT_ACID
, HIT_FLAME
, HIT_SELF
: MakeBloodSimple(c
);
2038 HIT_BFG
, HIT_ROCKET
, HIT_SOME
: MakeBloodVector(c
, vx
, vy
);
2041 if t
= HIT_WATER
then
2042 g_GFX_Bubbles(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2),
2043 FObj
.Y
+PLAYER_RECT
.Y
-4, value
div 2, 8, 4);
2048 Inc(FDamageBuffer
, value
);
2052 FPain
:= FPain
+ value
;
2055 if g_Game_IsServer
and g_Game_IsNet
then
2057 MH_SEND_PlayerDamage(FUID
, t
, SpawnerUID
, value
, vx
, vy
);
2058 MH_SEND_PlayerStats(FUID
);
2059 MH_SEND_PlayerPos(False, FUID
);
2063 function TPlayer
.Heal(value
: Word; Soft
: Boolean): Boolean;
2066 if g_Game_IsClient
then
2071 if Soft
and (FHealth
< PLAYER_HP_SOFT
) then
2073 IncMax(FHealth
, value
, PLAYER_HP_SOFT
);
2076 if (not Soft
) and (FHealth
< PLAYER_HP_LIMIT
) then
2078 IncMax(FHealth
, value
, PLAYER_HP_LIMIT
);
2082 if Result
and g_Game_IsServer
and g_Game_IsNet
then
2083 MH_SEND_PlayerStats(FUID
);
2086 destructor TPlayer
.Destroy();
2088 if (gPlayer1
<> nil) and (gPlayer1
.FUID
= FUID
) then
2090 if (gPlayer2
<> nil) and (gPlayer2
.FUID
= FUID
) then
2094 FSawSoundIdle
.Free();
2095 FSawSoundHit
.Free();
2096 FJetSoundFly
.Free();
2098 FJetSoundOff
.Free();
2104 procedure TPlayer
.DrawBubble();
2106 bubX
, bubY
: Integer;
2109 Rw
, Gw
, Bw
: SmallInt;
2112 bubX
:= FObj
.X
+FObj
.Rect
.X
+ IfThen(FDirection
= D_LEFT
, -4, 18);
2113 bubY
:= FObj
.Y
+FObj
.Rect
.Y
- 18;
2121 1: // simple textual non-bubble
2123 bubX
:= FObj
.X
+FObj
.Rect
.X
- 11;
2124 bubY
:= FObj
.Y
+FObj
.Rect
.Y
- 17;
2125 e_TextureFontPrint(bubX
, bubY
, '[...]', gStdFont
);
2128 2: // advanced pixel-perfect bubble
2130 if FTeam
= TEAM_RED
then
2133 if FTeam
= TEAM_BLUE
then
2136 3: // colored bubble
2138 Rb
:= FModel
.Color
.R
;
2139 Gb
:= FModel
.Color
.G
;
2140 Bb
:= FModel
.Color
.B
;
2141 Rw
:= Min(Rb
* 2 + 64, 255);
2142 Gw
:= Min(Gb
* 2 + 64, 255);
2143 Bw
:= Min(Bb
* 2 + 64, 255);
2144 if (Abs(Rw
- Rb
) < 32)
2145 or (Abs(Gw
- Gb
) < 32)
2146 or (Abs(Bw
- Bb
) < 32) then
2148 Rb
:= Max(Rw
div 2 - 16, 0);
2149 Gb
:= Max(Gw
div 2 - 16, 0);
2150 Bb
:= Max(Bw
div 2 - 16, 0);
2153 4: // custom textured bubble
2155 if g_Texture_Get('TEXTURE_PLAYER_TALKBUBBLE', ID
) then
2156 if FDirection
= D_RIGHT
then
2157 e_Draw(ID
, bubX
- 6, bubY
- 7, 0, True, False)
2159 e_Draw(ID
, bubX
- 6, bubY
- 7, 0, True, False, M_HORIZONTAL
);
2165 e_DrawQuad(bubX
+ 1, bubY
, bubX
+ 18, bubY
+ 13, Rb
, Gb
, Bb
);
2166 e_DrawQuad(bubX
, bubY
+ 1, bubX
+ 19, bubY
+ 12, Rb
, Gb
, Bb
);
2168 e_DrawFillQuad(bubX
+ 1, bubY
+ 1, bubX
+ 18, bubY
+ 12, Rw
, Gw
, Bw
, 0);
2171 Dot
:= IfThen(FDirection
= D_LEFT
, 14, 5);
2172 e_DrawLine(1, bubX
+ Dot
, bubY
+ 14, bubX
+ Dot
, bubY
+ 16, Rb
, Gb
, Bb
);
2173 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
);
2174 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
);
2175 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
);
2176 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
);
2180 e_DrawFillQuad(bubX
+ Dot
, bubY
+ 8, bubX
+ Dot
+ 1, bubY
+ 9, Rb
, Gb
, Bb
, 0);
2181 e_DrawFillQuad(bubX
+ Dot
+ 3, bubY
+ 8, bubX
+ Dot
+ 4, bubY
+ 9, Rb
, Gb
, Bb
, 0);
2182 e_DrawFillQuad(bubX
+ Dot
+ 6, bubY
+ 8, bubX
+ Dot
+ 7, bubY
+ 9, Rb
, Gb
, Bb
, 0);
2185 procedure TPlayer
.Draw();
2193 if (FMegaRulez
[MR_INVUL
] > gTime
) and (gPlayerDrawn
<> Self
) then
2194 if g_Texture_Get('TEXTURE_PLAYER_INVULPENTA', ID
) then
2196 e_GetTextureSize(ID
, @w
, @h
);
2197 if FDirection
= D_LEFT
then
2198 e_Draw(ID
, FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2)-(w
div 2)+4,
2199 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2)-(h
div 2)-7, 0, True, False)
2201 e_Draw(ID
, FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2)-(w
div 2)-2,
2202 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2)-(h
div 2)-7, 0, True, False);
2205 if FMegaRulez
[MR_INVIS
] > gTime
then
2207 if (gPlayerDrawn
<> nil) and ((Self
= gPlayerDrawn
) or
2208 ((FTeam
= gPlayerDrawn
.Team
) and (gGameSettings
.GameMode
<> GM_DM
))) then
2210 if (FMegaRulez
[MR_INVIS
] - gTime
) <= 2100 then
2211 dr
:= not Odd((FMegaRulez
[MR_INVIS
] - gTime
) div 300)
2215 FModel
.Draw(FObj
.X
, FObj
.Y
, 200)
2217 FModel
.Draw(FObj
.X
, FObj
.Y
);
2220 FModel
.Draw(FObj
.X
, FObj
.Y
, 254);
2223 FModel
.Draw(FObj
.X
, FObj
.Y
);
2226 if g_debug_Frames
then
2228 e_DrawQuad(FObj
.X
+FObj
.Rect
.X
,
2230 FObj
.X
+FObj
.Rect
.X
+FObj
.Rect
.Width
-1,
2231 FObj
.Y
+FObj
.Rect
.Y
+FObj
.Rect
.Height
-1,
2235 if (gChatBubble
> 0) and (FKeys
[KEY_CHAT
].Pressed
) and not FGhost
then
2237 // e_DrawPoint(5, 335, 288, 255, 0, 0); // DL, UR, DL, UR
2238 if gAimLine
and Live
and
2239 ((Self
= gPlayer1
) or (Self
= gPlayer2
)) then
2243 procedure TPlayer
.DrawAim();
2245 wx
, wy
, xx
, yy
: Integer;
2249 wx
:= FObj
.X
+ WEAPONPOINT
[FDirection
].X
+ IfThen(FDirection
= D_LEFT
, 7, -7);
2250 wy
:= FObj
.Y
+ WEAPONPOINT
[FDirection
].Y
;
2259 1: begin // Chainsaw
2266 if angle
= ANGLE_RIGHTUP
then Dec(angle
, 2);
2267 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 4);
2268 if angle
= ANGLE_LEFTUP
then Inc(angle
, 2);
2269 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 4);
2274 if angle
= ANGLE_RIGHTUP
then Dec(angle
, 2);
2275 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 4);
2276 if angle
= ANGLE_LEFTUP
then Inc(angle
, 2);
2277 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 4);
2279 4: begin // Double Shotgun
2282 if angle
= ANGLE_RIGHTUP
then Dec(angle
, 2);
2283 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 4);
2284 if angle
= ANGLE_LEFTUP
then Inc(angle
, 2);
2285 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 4);
2287 5: begin // Chaingun
2290 if angle
= ANGLE_RIGHTUP
then Dec(angle
, 2);
2291 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 4);
2292 if angle
= ANGLE_LEFTUP
then Inc(angle
, 2);
2293 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 4);
2295 6: begin // Rocket Launcher
2298 if angle
= ANGLE_RIGHTUP
then Inc(angle
, 2);
2299 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 4);
2300 if angle
= ANGLE_LEFTUP
then Dec(angle
, 2);
2301 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 4);
2303 7: begin // Plasmagun
2306 if angle
= ANGLE_RIGHTUP
then Inc(angle
);
2307 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 3);
2308 if angle
= ANGLE_LEFTUP
then Dec(angle
);
2309 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 3);
2314 if angle
= ANGLE_RIGHTUP
then Inc(angle
, 1);
2315 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 2);
2316 if angle
= ANGLE_LEFTUP
then Dec(angle
, 1);
2317 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 2);
2319 9: begin // Super Chaingun
2322 if angle
= ANGLE_RIGHTUP
then Dec(angle
, 2);
2323 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 4);
2324 if angle
= ANGLE_LEFTUP
then Inc(angle
, 2);
2325 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 4);
2328 xx
:= Trunc(Cos(-DegToRad(angle
)) * len
) + wx
;
2329 yy
:= Trunc(Sin(-DegToRad(angle
)) * len
) + wy
;
2330 e_DrawLine(sz
, wx
, wy
, xx
, yy
, 255, 0, 0, 96);
2333 procedure TPlayer
.DrawGUI();
2336 X
, Y
, SY
, a
, p
, m
: Integer;
2340 stat
: TPlayerStatArray
;
2342 X
:= gPlayerScreenSize
.X
;
2343 SY
:= gPlayerScreenSize
.Y
;
2346 if gShowGoals
and (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then
2348 if gGameSettings
.GameMode
= GM_CTF
then
2352 if gGameSettings
.GameMode
= GM_CTF
then
2354 s
:= 'TEXTURE_PLAYER_REDFLAG';
2355 if gFlags
[FLAG_RED
].State
= FLAG_STATE_CAPTURED
then
2356 s
:= 'TEXTURE_PLAYER_REDFLAG_S';
2357 if gFlags
[FLAG_RED
].State
= FLAG_STATE_DROPPED
then
2358 s
:= 'TEXTURE_PLAYER_REDFLAG_D';
2359 if g_Texture_Get(s
, ID
) then
2360 e_Draw(ID
, X
-16-32, 240-72-4, 0, True, False);
2363 s
:= IntToStr(gTeamStat
[TEAM_RED
].Goals
);
2364 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2365 e_CharFont_PrintEx(gMenuFont
, X
-16-a
-tw
, 240-72-4, s
, TEAMCOLOR
[TEAM_RED
]);
2367 if gGameSettings
.GameMode
= GM_CTF
then
2369 s
:= 'TEXTURE_PLAYER_BLUEFLAG';
2370 if gFlags
[FLAG_BLUE
].State
= FLAG_STATE_CAPTURED
then
2371 s
:= 'TEXTURE_PLAYER_BLUEFLAG_S';
2372 if gFlags
[FLAG_BLUE
].State
= FLAG_STATE_DROPPED
then
2373 s
:= 'TEXTURE_PLAYER_BLUEFLAG_D';
2374 if g_Texture_Get(s
, ID
) then
2375 e_Draw(ID
, X
-16-32, 240-32-4, 0, True, False);
2378 s
:= IntToStr(gTeamStat
[TEAM_BLUE
].Goals
);
2379 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2380 e_CharFont_PrintEx(gMenuFont
, X
-16-a
-tw
, 240-32-4, s
, TEAMCOLOR
[TEAM_BLUE
]);
2383 if g_Texture_Get('TEXTURE_PLAYER_HUDBG', ID
) then
2384 e_DrawFill(ID
, X
, 0, 1, (gPlayerScreenSize
.Y
div 256)+IfThen(gPlayerScreenSize
.Y
mod 256 > 0, 1, 0),
2387 if g_Texture_Get('TEXTURE_PLAYER_HUD', ID
) then
2388 e_Draw(ID
, X
+2, Y
, 0, True, False);
2390 if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
2394 s
:= IntToStr(Frags
);
2395 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2396 e_CharFont_PrintEx(gMenuFont
, X
-16-tw
, Y
, s
, _RGB(255, 0, 0));
2401 stat
:= g_Player_GetStats();
2406 for a
:= 0 to High(stat
) do
2407 if stat
[a
].Name
<> Name
then
2409 if stat
[a
].Frags
> m
then m
:= stat
[a
].Frags
;
2410 if stat
[a
].Frags
> Frags
then p
:= p
+1;
2414 s
:= IntToStr(p
)+' / '+IntToStr(Length(stat
))+' ';
2415 if Frags
>= m
then s
:= s
+'+' else s
:= s
+'-';
2416 s
:= s
+IntToStr(Abs(Frags
-m
));
2418 e_CharFont_GetSize(gMenuSmallFont
, s
, tw
, th
);
2419 e_CharFont_PrintEx(gMenuSmallFont
, X
-16-tw
, Y
+32, s
, _RGB(255, 0, 0));
2422 if gShowLives
and (gGameSettings
.MaxLives
> 0) then
2424 s
:= IntToStr(Lives
);
2425 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2426 e_CharFont_PrintEx(gMenuFont
, X
-16-tw
, SY
-32, s
, _RGB(0, 255, 0));
2430 e_CharFont_GetSize(gMenuSmallFont
, FName
, tw
, th
);
2431 e_CharFont_PrintEx(gMenuSmallFont
, X
+98-(tw
div 2), Y
+8, FName
, _RGB(255, 0, 0));
2433 if R_BERSERK
in FRulez
then
2434 e_Draw(gItemsTexturesID
[ITEM_MEDKIT_BLACK
], X
+37, Y
+45, 0, True, False)
2436 e_Draw(gItemsTexturesID
[ITEM_MEDKIT_LARGE
], X
+37, Y
+45, 0, True, False);
2438 if g_Texture_Get('TEXTURE_PLAYER_ARMORHUD', ID
) then
2439 e_Draw(ID
, X
+36, Y
+77, 0, True, False);
2441 s
:= IntToStr(IfThen(FHealth
> 0, FHealth
, 0));
2442 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2443 e_CharFont_PrintEx(gMenuFont
, X
+178-tw
, Y
+40, s
, _RGB(255, 0, 0));
2445 s
:= IntToStr(FArmor
);
2446 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2447 e_CharFont_PrintEx(gMenuFont
, X
+178-tw
, Y
+68, s
, _RGB(255, 0, 0));
2449 s
:= IntToStr(GetAmmoByWeapon(FCurrWeap
));
2455 ID
:= gItemsTexturesID
[ITEM_WEAPON_KASTET
];
2460 ID
:= gItemsTexturesID
[ITEM_WEAPON_SAW
];
2462 WEAPON_PISTOL
: ID
:= gItemsTexturesID
[ITEM_WEAPON_PISTOL
];
2463 WEAPON_CHAINGUN
: ID
:= gItemsTexturesID
[ITEM_WEAPON_CHAINGUN
];
2464 WEAPON_SHOTGUN1
: ID
:= gItemsTexturesID
[ITEM_WEAPON_SHOTGUN1
];
2465 WEAPON_SHOTGUN2
: ID
:= gItemsTexturesID
[ITEM_WEAPON_SHOTGUN2
];
2466 WEAPON_SUPERPULEMET
: ID
:= gItemsTexturesID
[ITEM_WEAPON_SUPERPULEMET
];
2467 WEAPON_ROCKETLAUNCHER
: ID
:= gItemsTexturesID
[ITEM_WEAPON_ROCKETLAUNCHER
];
2468 WEAPON_PLASMA
: ID
:= gItemsTexturesID
[ITEM_WEAPON_PLASMA
];
2469 WEAPON_BFG
: ID
:= gItemsTexturesID
[ITEM_WEAPON_BFG
];
2472 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2473 e_CharFont_PrintEx(gMenuFont
, X
+178-tw
, Y
+158, s
, _RGB(255, 0, 0));
2474 e_Draw(ID
, X
+20, Y
+160, 0, True, False);
2476 if R_KEY_RED
in FRulez
then
2477 e_Draw(gItemsTexturesID
[ITEM_KEY_RED
], X
+78, Y
+214, 0, True, False);
2479 if R_KEY_GREEN
in FRulez
then
2480 e_Draw(gItemsTexturesID
[ITEM_KEY_GREEN
], X
+95, Y
+214, 0, True, False);
2482 if R_KEY_BLUE
in FRulez
then
2483 e_Draw(gItemsTexturesID
[ITEM_KEY_BLUE
], X
+112, Y
+214, 0, True, False);
2485 if FJetFuel
> 0 then
2487 if g_Texture_Get('TEXTURE_PLAYER_HUDAIR', ID
) then
2488 e_Draw(ID
, X
+2, Y
+116, 0, True, False);
2489 if g_Texture_Get('TEXTURE_PLAYER_HUDJET', ID
) then
2490 e_Draw(ID
, X
+2, Y
+126, 0, True, False);
2491 e_DrawLine(4, X
+16, Y
+122, X
+16+Trunc(168*IfThen(FAir
> 0, FAir
, 0)/AIR_MAX
), Y
+122, 0, 0, 196);
2492 e_DrawLine(4, X
+16, Y
+132, X
+16+Trunc(168*FJetFuel
/JET_MAX
), Y
+132, 208, 0, 0);
2496 if g_Texture_Get('TEXTURE_PLAYER_HUDAIR', ID
) then
2497 e_Draw(ID
, X
+2, Y
+124, 0, True, False);
2498 e_DrawLine(4, X
+16, Y
+130, X
+16+Trunc(168*IfThen(FAir
> 0, FAir
, 0)/AIR_MAX
), Y
+130, 0, 0, 196);
2501 if gShowPing
and g_Game_IsClient
then
2503 s
:= _lc
[I_GAME_PING_HUD
] + IntToStr(NetPeer
.lastRoundTripTime
) + _lc
[I_NET_SLIST_PING_MS
];
2504 e_TextureFontPrint(X
+ 4, Y
+ 242, s
, gStdFont
);
2510 e_TextureFontPrint(X
+ 4, Y
+ 242, _lc
[I_PLAYER_SPECT
], gStdFont
);
2511 e_TextureFontPrint(X
+ 4, Y
+ 258, _lc
[I_PLAYER_SPECT2
], gStdFont
);
2512 e_TextureFontPrint(X
+ 4, Y
+ 274, _lc
[I_PLAYER_SPECT1
], gStdFont
);
2515 e_TextureFontGetSize(gStdFont
, cw
, ch
);
2516 s
:= _lc
[I_PLAYER_SPECT4
];
2517 e_TextureFontPrintEx(gScreenWidth
div 2 - cw
*(Length(s
) div 2),
2518 gScreenHeight
-4-ch
, s
, gStdFont
, 255, 255, 255, 1, True);
2519 e_TextureFontPrint(X
+ 4, Y
+ 290, _lc
[I_PLAYER_SPECT1S
], gStdFont
);
2525 procedure TPlayer
.DrawRulez();
2529 // Ïðè âçÿòèè íåóÿçâèìîñòè ðèñóåòñÿ èíâåðñèîííûé áåëûé ôîí
2530 if FMegaRulez
[MR_INVUL
] >= gTime
then
2532 if (FMegaRulez
[MR_INVUL
]-gTime
) <= 2100 then
2533 dr
:= not Odd((FMegaRulez
[MR_INVUL
]-gTime
) div 300)
2538 e_DrawFillQuad(0, 0, gPlayerScreenSize
.X
-1, gPlayerScreenSize
.Y
-1,
2539 191, 191, 191, 0, B_INVERT
);
2542 // Ïðè âçÿòèè çàùèòíîãî êîñòþìà ðèñóåòñÿ çåëåíîâàòûé ôîí
2543 if FMegaRulez
[MR_SUIT
] >= gTime
then
2545 if (FMegaRulez
[MR_SUIT
]-gTime
) <= 2100 then
2546 dr
:= not Odd((FMegaRulez
[MR_SUIT
]-gTime
) div 300)
2551 e_DrawFillQuad(0, 0, gPlayerScreenSize
.X
-1, gPlayerScreenSize
.Y
-1,
2552 0, 96, 0, 200, B_NONE
);
2555 // Ïðè âçÿòèè áåðñåðêà ðèñóåòñÿ êðàñíîâàòûé ôîí
2556 if (FBerserk
>= 0) and (LongWord(FBerserk
) >= gTime
) and (gFlash
= 2) then
2558 e_DrawFillQuad(0, 0, gPlayerScreenSize
.X
-1, gPlayerScreenSize
.Y
-1,
2559 255, 0, 0, 200, B_NONE
);
2563 procedure TPlayer
.DrawPain();
2567 if FPain
= 0 then Exit
;
2571 if a
< 15 then h
:= 0
2572 else if a
< 35 then h
:= 1
2573 else if a
< 55 then h
:= 2
2574 else if a
< 75 then h
:= 3
2575 else if a
< 95 then h
:= 4
2578 //if a > 255 then a := 255;
2580 e_DrawFillQuad(0, 0, gPlayerScreenSize
.X
-1, gPlayerScreenSize
.Y
-1, 255, 0, 0, 255-h
*50);
2581 //e_DrawFillQuad(0, 0, gPlayerScreenSize.X-1, gPlayerScreenSize.Y-1, 255-min(128, a), 255-a, 255-a, 0, B_FILTER);
2584 procedure TPlayer
.DrawPickup();
2588 if FPickup
= 0 then Exit
;
2592 if a
< 15 then h
:= 1
2593 else if a
< 35 then h
:= 2
2594 else if a
< 55 then h
:= 3
2595 else if a
< 75 then h
:= 4
2598 e_DrawFillQuad(0, 0, gPlayerScreenSize
.X
-1, gPlayerScreenSize
.Y
-1, 150, 200, 150, 255-h
*50);
2601 procedure TPlayer
.Fire();
2603 f
, DidFire
: Boolean;
2604 wx
, wy
, xd
, yd
: Integer;
2607 if g_Game_IsClient
then Exit
;
2608 // FBFGFireCounter - âðåìÿ ïåðåä âûñòðåëîì (äëÿ BFG)
2609 // FReloading - âðåìÿ ïîñëå âûñòðåëà (äëÿ âñåãî)
2617 if FReloading
[FCurrWeap
] <> 0 then Exit
;
2622 wx
:= FObj
.X
+WEAPONPOINT
[FDirection
].X
;
2623 wy
:= FObj
.Y
+WEAPONPOINT
[FDirection
].Y
;
2624 xd
:= wx
+IfThen(FDirection
= D_LEFT
, -30, 30);
2625 yd
:= wy
+firediry();
2630 if R_BERSERK
in FRulez
then
2632 //g_Weapon_punch(FObj.X+FObj.Rect.X, FObj.Y+FObj.Rect.Y, 75, FUID);
2633 obj
.X
:= FObj
.X
+FObj
.Rect
.X
;
2634 obj
.Y
:= FObj
.Y
+FObj
.Rect
.Y
;
2637 obj
.rect
.Width
:= 39;
2638 obj
.rect
.Height
:= 52;
2639 obj
.Vel
.X
:= (xd
-wx
) div 2;
2640 obj
.Vel
.Y
:= (yd
-wy
) div 2;
2641 obj
.Accel
.X
:= xd
-wx
;
2642 obj
.Accel
.y
:= yd
-wy
;
2644 if g_Weapon_Hit(@obj
, 50, FUID
, HIT_SOME
) <> 0 then
2645 g_Sound_PlayExAt('SOUND_WEAPON_HITBERSERK', FObj
.X
, FObj
.Y
)
2647 g_Sound_PlayExAt('SOUND_WEAPON_MISSBERSERK', FObj
.X
, FObj
.Y
);
2651 FPain
:= min(FPain
+ 25, 50);
2652 end else g_Weapon_punch(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
, 3, FUID
);
2655 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
2660 if g_Weapon_chainsaw(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
,
2661 IfThen(gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
], 9, 3), FUID
) <> 0 then
2663 FSawSoundSelect
.Stop();
2665 FSawSoundHit
.PlayAt(FObj
.X
, FObj
.Y
);
2667 else if not FSawSoundHit
.IsPlaying() then
2669 FSawSoundSelect
.Stop();
2670 FSawSound
.PlayAt(FObj
.X
, FObj
.Y
);
2673 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
2679 if FAmmo
[A_BULLETS
] > 0 then
2681 g_Weapon_pistol(wx
, wy
, xd
, yd
, FUID
);
2682 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
2683 Dec(FAmmo
[A_BULLETS
]);
2684 FFireAngle
:= FAngle
;
2687 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
2688 GameVelX
, GameVelY
-2, SHELL_BULLET
);
2692 if FAmmo
[A_SHELLS
] > 0 then
2694 g_Weapon_shotgun(wx
, wy
, xd
, yd
, FUID
);
2695 if not gSoundEffectsDF
then g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN', wx
, wy
);
2696 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
2697 Dec(FAmmo
[A_SHELLS
]);
2698 FFireAngle
:= FAngle
;
2702 FShellType
:= SHELL_SHELL
;
2706 if FAmmo
[A_SHELLS
] >= 2 then
2708 g_Weapon_dshotgun(wx
, wy
, xd
, yd
, FUID
);
2709 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
2710 Dec(FAmmo
[A_SHELLS
], 2);
2711 FFireAngle
:= FAngle
;
2715 FShellType
:= SHELL_DBLSHELL
;
2719 if FAmmo
[A_BULLETS
] > 0 then
2721 g_Weapon_mgun(wx
, wy
, xd
, yd
, FUID
);
2722 if not gSoundEffectsDF
then g_Sound_PlayExAt('SOUND_WEAPON_FIREPISTOL', wx
, wy
);
2723 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
2724 Dec(FAmmo
[A_BULLETS
]);
2725 FFireAngle
:= FAngle
;
2728 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
2729 GameVelX
, GameVelY
-2, SHELL_BULLET
);
2732 WEAPON_ROCKETLAUNCHER
:
2733 if FAmmo
[A_ROCKETS
] > 0 then
2735 g_Weapon_rocket(wx
, wy
, xd
, yd
, FUID
);
2736 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
2737 Dec(FAmmo
[A_ROCKETS
]);
2738 FFireAngle
:= FAngle
;
2744 if FAmmo
[A_CELLS
] > 0 then
2746 g_Weapon_plasma(wx
, wy
, xd
, yd
, FUID
);
2747 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
2748 Dec(FAmmo
[A_CELLS
]);
2749 FFireAngle
:= FAngle
;
2755 if (FAmmo
[A_CELLS
] >= 40) and (FBFGFireCounter
= -1) then
2757 FBFGFireCounter
:= 17;
2758 if not FNoReload
then
2759 g_Sound_PlayExAt('SOUND_WEAPON_STARTFIREBFG', FObj
.X
, FObj
.Y
);
2760 Dec(FAmmo
[A_CELLS
], 40);
2764 WEAPON_SUPERPULEMET
:
2765 if FAmmo
[A_SHELLS
] > 0 then
2767 g_Weapon_shotgun(wx
, wy
, xd
, yd
, FUID
);
2768 if not gSoundEffectsDF
then g_Sound_PlayExAt('SOUND_WEAPON_FIRECGUN', wx
, wy
);
2769 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
2770 Dec(FAmmo
[A_SHELLS
]);
2771 FFireAngle
:= FAngle
;
2774 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
2775 GameVelX
, GameVelY
-2, SHELL_SHELL
);
2779 if g_Game_IsNet
then
2783 if FCurrWeap
<> WEAPON_BFG
then
2784 MH_SEND_PlayerFire(FUID
, FCurrWeap
, wx
, wy
, xd
, yd
, LastShotID
)
2786 if not FNoReload
then
2787 MH_SEND_Sound(FObj
.X
, FObj
.Y
, 'SOUND_WEAPON_STARTFIREBFG');
2790 MH_SEND_PlayerStats(FUID
);
2795 if (FAngle
= 0) or (FAngle
= 180) then SetAction(A_ATTACK
)
2796 else if (FAngle
= ANGLE_LEFTDOWN
) or (FAngle
= ANGLE_RIGHTDOWN
) then SetAction(A_ATTACKDOWN
)
2797 else if (FAngle
= ANGLE_LEFTUP
) or (FAngle
= ANGLE_RIGHTUP
) then SetAction(A_ATTACKUP
);
2800 function TPlayer
.GetAmmoByWeapon(Weapon
: Byte): Word;
2803 WEAPON_PISTOL
, WEAPON_CHAINGUN
: Result
:= FAmmo
[A_BULLETS
];
2804 WEAPON_SHOTGUN1
, WEAPON_SHOTGUN2
, WEAPON_SUPERPULEMET
: Result
:= FAmmo
[A_SHELLS
];
2805 WEAPON_ROCKETLAUNCHER
: Result
:= FAmmo
[A_ROCKETS
];
2806 WEAPON_PLASMA
, WEAPON_BFG
: Result
:= FAmmo
[A_CELLS
];
2811 function TPlayer
.HeadInLiquid(XInc
, YInc
: Integer): Boolean;
2813 Result
:= g_Map_CollidePanel(FObj
.X
+PLAYER_HEADRECT
.X
+XInc
, FObj
.Y
+PLAYER_HEADRECT
.Y
+YInc
,
2814 PLAYER_HEADRECT
.Width
, PLAYER_HEADRECT
.Height
,
2815 PANEL_WATER
or PANEL_ACID1
or PANEL_ACID2
, True);
2818 procedure TPlayer
.JetpackOn
;
2822 FJetSoundOn
.SetPosition(0);
2823 FJetSoundOn
.PlayAt(FObj
.X
, FObj
.Y
);
2827 procedure TPlayer
.JetpackOff
;
2831 FJetSoundOff
.SetPosition(0);
2832 FJetSoundOff
.PlayAt(FObj
.X
, FObj
.Y
);
2835 procedure TPlayer
.Jump();
2837 if gFly
or FJetpack
then
2839 // Ïîëåò (÷èò-êîä èëè äæåòïàê):
2840 if FObj
.Vel
.Y
> -VEL_FLY
then
2841 FObj
.Vel
.Y
:= FObj
.Vel
.Y
- 3;
2844 if FJetFuel
> 0 then
2846 if (FJetFuel
< 1) and g_Game_IsServer
then
2850 if g_Game_IsNet
then
2851 MH_SEND_PlayerStats(FUID
);
2857 // Íå âêëþ÷àòü äæåòïàê â ðåæèìå ïðîõîæäåíèÿ ñêâîçü ñòåíû
2859 FCanJetpack
:= False;
2861 // Ïðûãàåì èëè âñïëûâàåì:
2862 if (CollideLevel(0, 1) or
2863 g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+PLAYER_RECT
.Y
+36, PLAYER_RECT
.Width
,
2864 PLAYER_RECT
.Height
-33, PANEL_STEP
, False)
2865 ) and (FObj
.Accel
.Y
= 0) then // Íå ïðûãàòü, åñëè åñòü âåðòèêàëüíîå óñêîðåíèå
2867 FObj
.Vel
.Y
:= -VEL_JUMP
;
2868 FCanJetpack
:= False;
2872 if BodyInLiquid(0, 0) then
2873 FObj
.Vel
.Y
:= -VEL_SW
2874 else if (FJetFuel
> 0) and FCanJetpack
and
2875 g_Game_IsServer
and (not g_Obj_CollideLiquid(@FObj
, 0, 0)) then
2879 if g_Game_IsNet
then
2880 MH_SEND_PlayerStats(FUID
);
2885 procedure TPlayer
.Kill(KillType
: Byte; SpawnerUID
: Word; t
: Byte);
2887 a
, i
, k
, ab
, ar
: Byte;
2891 srv
, netsrv
: Boolean;
2896 procedure PushItem(t
: Byte);
2900 id
:= g_Items_Create(FObj
.X
, FObj
.Y
, t
, True, False);
2901 if KillType
= K_EXTRAHARDKILL
then // -7..+7; -8..0
2902 g_Obj_Push(@gItems
[id
].Obj
, (FObj
.Vel
.X
div 2)-7+Random(15),
2903 (FObj
.Vel
.Y
div 2)-Random(9))
2905 if KillType
= K_HARDKILL
then // -5..+5; -5..0
2906 g_Obj_Push(@gItems
[id
].Obj
, (FObj
.Vel
.X
div 2)-5+Random(11),
2907 (FObj
.Vel
.Y
div 2)-Random(6))
2908 else // -3..+3; -3..0
2909 g_Obj_Push(@gItems
[id
].Obj
, (FObj
.Vel
.X
div 2)-3+Random(7),
2910 (FObj
.Vel
.Y
div 2)-Random(4));
2912 if g_Game_IsNet
and g_Game_IsServer
then
2913 MH_SEND_ItemSpawn(True, id
);
2917 DoFrags
:= (gGameSettings
.MaxLives
= 0) or (gGameSettings
.GameMode
= GM_COOP
);
2918 Srv
:= g_Game_IsServer
;
2919 Netsrv
:= g_Game_IsServer
and g_Game_IsNet
;
2920 if Srv
then FDeath
:= FDeath
+ 1;
2925 if not FPhysics
then
2931 if (gGameSettings
.MaxLives
> 0) and Srv
and (gLMSRespawn
= LMS_RESPAWN_NONE
) then
2933 if FLives
> 0 then FLives
:= FLives
- 1;
2934 if FLives
= 0 then FNoRespawn
:= True;
2937 // Íîìåð òèïà ñìåðòè:
2940 K_SIMPLEKILL
: a
:= 1;
2942 K_EXTRAHARDKILL
: a
:= 3;
2947 if not FModel
.PlaySound(MODELSOUND_DIE
, a
, FObj
.X
, FObj
.Y
) then
2949 if FModel
.PlaySound(MODELSOUND_DIE
, i
, FObj
.X
, FObj
.Y
) then
2956 FTime
[T_RESPAWN
] := gTime
+ TIME_RESPAWN1
;
2958 FTime
[T_RESPAWN
] := gTime
+ TIME_RESPAWN2
;
2959 K_EXTRAHARDKILL
, K_FALLKILL
:
2960 FTime
[T_RESPAWN
] := gTime
+ TIME_RESPAWN3
;
2963 // Ïåðåêëþ÷àåì ñîñòîÿíèå:
2967 K_HARDKILL
, K_EXTRAHARDKILL
:
2971 // Ðåàêöèÿ ìîíñòðîâ íà ñìåðòü èãðîêà:
2972 if (KillType
<> K_FALLKILL
) and (Srv
) then
2973 g_Monsters_killedp();
2975 if SpawnerUID
= FUID
then
2977 if Srv
and (DoFrags
or (gGameSettings
.GameMode
= GM_TDM
)) then
2982 g_Console_Add(Format(_lc
[I_PLAYER_KILL_SELF
], [FName
]), True);
2985 if g_GetUIDType(SpawnerUID
) = UID_PLAYER
then
2986 begin // Óáèò äðóãèì èãðîêîì
2987 KP
:= g_Player_Get(SpawnerUID
);
2988 if (KP
<> nil) and Srv
then
2990 if (DoFrags
or (gGameSettings
.GameMode
= GM_TDM
)) then
2991 if SameTeam(FUID
, SpawnerUID
) then
3001 if (gGameSettings
.GameMode
= GM_TDM
) and DoFrags
then
3002 Inc(gTeamStat
[KP
.Team
].Goals
,
3003 IfThen(SameTeam(FUID
, SpawnerUID
), -1, 1));
3005 if netsrv
then MH_SEND_PlayerStats(SpawnerUID
);
3008 plr
:= g_Player_Get(SpawnerUID
);
3016 g_Console_Add(Format(_lc
[I_PLAYER_KILL_EXTRAHARD_2
],
3020 g_Console_Add(Format(_lc
[I_PLAYER_KILL_EXTRAHARD_1
],
3024 g_Console_Add(Format(_lc
[I_PLAYER_KILL
],
3029 else if g_GetUIDType(SpawnerUID
) = UID_MONSTER
then
3030 begin // Óáèò ìîíñòðîì
3031 mon
:= g_Monsters_Get(SpawnerUID
);
3035 s
:= g_Monsters_GetKilledBy(mon
.MonsterType
);
3039 g_Console_Add(Format(_lc
[I_PLAYER_KILL_EXTRAHARD_2
],
3043 g_Console_Add(Format(_lc
[I_PLAYER_KILL_EXTRAHARD_1
],
3047 g_Console_Add(Format(_lc
[I_PLAYER_KILL
],
3052 else // Îñîáûå òèïû ñìåðòè
3055 HIT_SELF
: g_Console_Add(Format(_lc
[I_PLAYER_KILL_SELF
], [FName
]), True);
3056 HIT_FALL
: g_Console_Add(Format(_lc
[I_PLAYER_KILL_FALL
], [FName
]), True);
3057 HIT_WATER
: g_Console_Add(Format(_lc
[I_PLAYER_KILL_WATER
], [FName
]), True);
3058 HIT_ACID
: g_Console_Add(Format(_lc
[I_PLAYER_KILL_ACID
], [FName
]), True);
3059 HIT_TRAP
: g_Console_Add(Format(_lc
[I_PLAYER_KILL_TRAP
], [FName
]), True);
3060 else g_Console_Add(Format(_lc
[I_PLAYER_DIED
], [FName
]), True);
3066 for a
:= WEAPON_KASTET
to WEAPON_SUPERPULEMET
do
3070 WEAPON_SAW
: i
:= ITEM_WEAPON_SAW
;
3071 WEAPON_SHOTGUN1
: i
:= ITEM_WEAPON_SHOTGUN1
;
3072 WEAPON_SHOTGUN2
: i
:= ITEM_WEAPON_SHOTGUN2
;
3073 WEAPON_CHAINGUN
: i
:= ITEM_WEAPON_CHAINGUN
;
3074 WEAPON_ROCKETLAUNCHER
: i
:= ITEM_WEAPON_ROCKETLAUNCHER
;
3075 WEAPON_PLASMA
: i
:= ITEM_WEAPON_PLASMA
;
3076 WEAPON_BFG
: i
:= ITEM_WEAPON_BFG
;
3077 WEAPON_SUPERPULEMET
: i
:= ITEM_WEAPON_SUPERPULEMET
;
3086 if R_ITEM_BACKPACK
in FRulez
then
3087 PushItem(ITEM_AMMO_BACKPACK
);
3089 // Âûáðîñ ðàêåòíîãî ðàíöà:
3090 if FJetFuel
> 0 then
3091 PushItem(ITEM_JETPACK
);
3094 if not (gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
]) then
3096 if R_KEY_RED
in FRulez
then
3097 PushItem(ITEM_KEY_RED
);
3099 if R_KEY_GREEN
in FRulez
then
3100 PushItem(ITEM_KEY_GREEN
);
3102 if R_KEY_BLUE
in FRulez
then
3103 PushItem(ITEM_KEY_BLUE
);
3110 g_Player_CreateCorpse(Self
);
3112 if Srv
and (gGameSettings
.MaxLives
> 0) and FNoRespawn
and
3113 (gLMSRespawn
= LMS_RESPAWN_NONE
) then
3119 for i
:= Low(gPlayers
) to High(gPlayers
) do
3121 if gPlayers
[i
] = nil then continue
;
3122 if (not gPlayers
[i
].FNoRespawn
) and (not gPlayers
[i
].FSpectator
) then
3125 if gPlayers
[i
].FTeam
= TEAM_RED
then Inc(ar
)
3126 else if gPlayers
[i
].FTeam
= TEAM_BLUE
then Inc(ab
);
3131 OldLR
:= gLMSRespawn
;
3132 if (gGameSettings
.GameMode
= GM_COOP
) then
3136 // everyone is dead, restart the map
3137 g_Game_Message(_lc
[I_MESSAGE_LMS_LOSE
], 144);
3139 MH_SEND_GameEvent(NET_EV_LMS_LOSE
);
3140 gLMSRespawn
:= LMS_RESPAWN_FINAL
;
3141 gLMSRespawnTime
:= gTime
+ 5000;
3143 else if (a
= 1) then
3145 if (gPlayers
[k
] <> nil) and not (gPlayers
[k
] is TBot
) then
3146 if (gPlayers
[k
] = gPlayer1
) or
3147 (gPlayers
[k
] = gPlayer2
) then
3148 g_Console_Add('*** ' + _lc
[I_MESSAGE_LMS_SURVIVOR
] + ' ***', True)
3149 else if Netsrv
and (gPlayers
[k
].FClientID
>= 0) then
3150 MH_SEND_GameEvent(NET_EV_LMS_SURVIVOR
, 0, 'N', gPlayers
[k
].FClientID
);
3153 else if (gGameSettings
.GameMode
= GM_TDM
) then
3155 if (ab
= 0) and (ar
<> 0) then
3158 g_Game_Message(Format(_lc
[I_MESSAGE_TLMS_WIN
], [AnsiUpperCase(_lc
[I_GAME_TEAM_RED
])]), 144);
3160 MH_SEND_GameEvent(NET_EV_TLMS_WIN
, TEAM_RED
);
3161 Inc(gTeamStat
[TEAM_RED
].Goals
);
3162 gLMSRespawn
:= LMS_RESPAWN_FINAL
;
3163 gLMSRespawnTime
:= gTime
+ 5000;
3165 else if (ar
= 0) and (ab
<> 0) then
3168 g_Game_Message(Format(_lc
[I_MESSAGE_TLMS_WIN
], [AnsiUpperCase(_lc
[I_GAME_TEAM_BLUE
])]), 144);
3170 MH_SEND_GameEvent(NET_EV_TLMS_WIN
, TEAM_BLUE
);
3171 Inc(gTeamStat
[TEAM_BLUE
].Goals
);
3172 gLMSRespawn
:= LMS_RESPAWN_FINAL
;
3173 gLMSRespawnTime
:= gTime
+ 5000;
3175 else if (ar
= 0) and (ab
= 0) then
3178 g_Game_Message(_lc
[I_GAME_WIN_DRAW
], 144);
3180 MH_SEND_GameEvent(NET_EV_LMS_DRAW
, 0, FName
);
3181 gLMSRespawn
:= LMS_RESPAWN_FINAL
;
3182 gLMSRespawnTime
:= gTime
+ 5000;
3185 else if (gGameSettings
.GameMode
= GM_DM
) then
3189 if gPlayers
[k
] <> nil then
3192 // survivor is the winner
3193 g_Game_Message(Format(_lc
[I_MESSAGE_LMS_WIN
], [AnsiUpperCase(FName
)]), 144);
3195 MH_SEND_GameEvent(NET_EV_LMS_WIN
, 0, FName
);
3198 gLMSRespawn
:= LMS_RESPAWN_FINAL
;
3199 gLMSRespawnTime
:= gTime
+ 5000;
3201 else if (a
= 0) then
3203 // everyone is dead, restart the map
3204 g_Game_Message(_lc
[I_GAME_WIN_DRAW
], 144);
3206 MH_SEND_GameEvent(NET_EV_LMS_DRAW
, 0, FName
);
3207 gLMSRespawn
:= LMS_RESPAWN_FINAL
;
3208 gLMSRespawnTime
:= gTime
+ 5000;
3211 if srv
and (OldLR
= LMS_RESPAWN_NONE
) and (gLMSRespawn
> LMS_RESPAWN_NONE
) then
3213 if NetMode
= NET_SERVER
then
3214 MH_SEND_GameEvent(NET_EV_LMS_WARMUP
, (gLMSRespawnTime
- gTime
) div 1000)
3216 g_Console_Add(Format(_lc
[I_MSG_WARMUP_START
], [(gLMSRespawnTime
- gTime
) div 1000]), True);
3222 MH_SEND_PlayerStats(FUID
);
3223 MH_SEND_PlayerDeath(FUID
, KillType
, t
, SpawnerUID
);
3224 if gGameSettings
.GameMode
= GM_TDM
then MH_SEND_GameStats
;
3227 if srv
and FNoRespawn
then Spectate(True);
3228 FWantsInGame
:= True;
3231 function TPlayer
.BodyInLiquid(XInc
, YInc
: Integer): Boolean;
3233 Result
:= g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
, PLAYER_RECT
.Width
,
3234 PLAYER_RECT
.Height
-20, PANEL_WATER
or PANEL_ACID1
or PANEL_ACID2
, False);
3237 function TPlayer
.BodyInAcid(XInc
, YInc
: Integer): Boolean;
3239 Result
:= g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
, PLAYER_RECT
.Width
,
3240 PLAYER_RECT
.Height
-20, PANEL_ACID1
or PANEL_ACID2
, False);
3243 procedure TPlayer
.MakeBloodSimple(Count
: Word);
3245 g_GFX_Blood(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)+8,
3246 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2),
3247 Count
div 2, 3, -1, 16, (PLAYER_RECT
.Height
*2 div 3),
3249 g_GFX_Blood(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-8,
3250 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2),
3251 Count
div 2, -3, -1, 16, (PLAYER_RECT
.Height
*2) div 3,
3255 procedure TPlayer
.MakeBloodVector(Count
: Word; VelX
, VelY
: Integer);
3257 g_GFX_Blood(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2),
3258 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2),
3259 Count
, VelX
, VelY
, 16, (PLAYER_RECT
.Height
*2) div 3,
3263 procedure TPlayer
.QueueWeaponSwitch(Weapon
: Byte);
3265 if g_Game_IsClient
then Exit
;
3266 if Weapon
> High(FWeapon
) then Exit
;
3267 FNextWeap
:= FNextWeap
or (1 shl Weapon
);
3270 procedure TPlayer
.resetWeaponQueue ();
3275 // return 255 for "no switch"; resets `FNextWeap`
3276 function TPlayer
.getNextWeaponIndex (): Byte;
3279 wantThisWeapon
: array[0..64] of Boolean;
3281 result
:= 255; // default result: "no switch"
3282 for i
:= 0 to High(wantThisWeapon
) do wantThisWeapon
[i
] := false;
3283 for i
:= 0 to High(FWeapon
) do if (FNextWeap
and (1 shl i
)) <> 0 then wantThisWeapon
[i
] := true;
3284 if wantThisWeapon
[FCurrWeap
] then
3286 // these hacks implements alternating between SG and SSG; sorry
3287 if FCurrWeap
= WEAPON_SHOTGUN1
then wantThisWeapon
[WEAPON_SHOTGUN2
] := true;
3288 if FCurrWeap
= WEAPON_SHOTGUN2
then wantThisWeapon
[WEAPON_SHOTGUN1
] := true;
3289 // these hacks implements alternating between knuckles and chainsaw; sorry
3290 if FCurrWeap
= WEAPON_KASTET
then wantThisWeapon
[WEAPON_SAW
] := true;
3291 if FCurrWeap
= WEAPON_SAW
then wantThisWeapon
[WEAPON_KASTET
] := true;
3293 // now exclude currently selected weapon from the set
3294 wantThisWeapon
[FCurrWeap
] := false;
3295 // no more hacks (yet)
3296 // do not reset weapon queue, it will be done in `RealizeCurrentWeapon()`
3297 // now try weapons in descending order
3298 for i
:= High(FWeapon
) downto 0 do
3300 if wantThisWeapon
[i
] and FWeapon
[i
] then
3309 procedure TPlayer
.RealizeCurrentWeapon();
3313 nw
:= getNextWeaponIndex();
3314 if nw
> High(FWeapon
) then begin resetWeaponQueue(); exit
; end; // don't forget to reset queue here!
3316 if FBFGFireCounter
<> -1 then exit
;
3317 if FTime
[T_SWITCH
] > gTime
then exit
;
3319 for i
:= WEAPON_KASTET
to WEAPON_SUPERPULEMET
do if FReloading
[i
] > 0 then exit
;
3324 FTime
[T_SWITCH
] := gTime
+156;
3325 if FCurrWeap
= WEAPON_SAW
then FSawSoundSelect
.PlayAt(FObj
.X
, FObj
.Y
);
3326 FModel
.SetWeapon(FCurrWeap
);
3327 if g_Game_IsNet
then MH_SEND_PlayerStats(FUID
);
3329 // reset weapon queue; `getNextWeaponIndex()` guarantees to not select a weapon player don't have
3333 procedure TPlayer
.cycleWeapon (dir
: Integer);
3337 if dir
< 0 then dir
:= 1 else if dir
> 0 then dir
:= 1 else exit
;
3339 for i
:= 0 to High(FWeapon
) do
3342 if cwi
< 0 then cwi
+= length(FWeapon
)
3343 else if cwi
> High(FWeapon
) then cwi
:= cwi
-length(FWeapon
);
3344 if FWeapon
[cwi
] then
3346 QueueWeaponSwitch(Byte(cwi
));
3352 procedure TPlayer
.NextWeapon();
3354 if g_Game_IsClient
then Exit
;
3358 procedure TPlayer
.PrevWeapon();
3360 if g_Game_IsClient
then Exit
;
3364 procedure TPlayer
.SetWeapon(W
: Byte);
3366 if FCurrWeap
<> W
then
3367 if W
= WEAPON_SAW
then
3368 FSawSoundSelect
.PlayAt(FObj
.X
, FObj
.Y
);
3371 FModel
.SetWeapon(CurrWeap
);
3375 function TPlayer
.PickItem(ItemType
: Byte; respawn
: Boolean; var remove
: Boolean): Boolean;
3380 if g_Game_IsClient
then Exit
;
3382 // a = true - ìåñòî ñïàâíà ïðåäìåòà:
3383 a
:= LongBool(gGameSettings
.Options
and GAME_OPTION_WEAPONSTAY
) and respawn
;
3388 if FHealth
< PLAYER_HP_SOFT
then
3390 IncMax(FHealth
, 10, PLAYER_HP_SOFT
);
3393 if gFlash
= 2 then Inc(FPickup
, 5);
3397 if FHealth
< PLAYER_HP_SOFT
then
3399 IncMax(FHealth
, 25, PLAYER_HP_SOFT
);
3402 if gFlash
= 2 then Inc(FPickup
, 5);
3406 if FArmor
< PLAYER_AP_SOFT
then
3408 FArmor
:= PLAYER_AP_SOFT
;
3411 if gFlash
= 2 then Inc(FPickup
, 5);
3415 if FArmor
< PLAYER_AP_LIMIT
then
3417 FArmor
:= PLAYER_AP_LIMIT
;
3420 if gFlash
= 2 then Inc(FPickup
, 5);
3424 if FHealth
< PLAYER_HP_LIMIT
then
3426 IncMax(FHealth
, 100, PLAYER_HP_LIMIT
);
3429 if gFlash
= 2 then Inc(FPickup
, 5);
3433 if (FHealth
< PLAYER_HP_LIMIT
) or (FArmor
< PLAYER_AP_LIMIT
) then
3435 if FHealth
< PLAYER_HP_LIMIT
then
3436 FHealth
:= PLAYER_HP_LIMIT
;
3437 if FArmor
< PLAYER_AP_LIMIT
then
3438 FArmor
:= PLAYER_AP_LIMIT
;
3441 if gFlash
= 2 then Inc(FPickup
, 5);
3445 if (not FWeapon
[WEAPON_SAW
]) or ((not respawn
) and (gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
])) then
3447 FWeapon
[WEAPON_SAW
] := True;
3449 if gFlash
= 2 then Inc(FPickup
, 5);
3450 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
3453 ITEM_WEAPON_SHOTGUN1
:
3454 if (FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
]) or not FWeapon
[WEAPON_SHOTGUN1
] then
3456 // Íóæíî, ÷òîáû íå âçÿòü âñå ïóëè ñðàçó:
3457 if a
and FWeapon
[WEAPON_SHOTGUN1
] then Exit
;
3459 IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
3460 FWeapon
[WEAPON_SHOTGUN1
] := True;
3462 if gFlash
= 2 then Inc(FPickup
, 5);
3463 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
3466 ITEM_WEAPON_SHOTGUN2
:
3467 if (FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
]) or not FWeapon
[WEAPON_SHOTGUN2
] then
3469 if a
and FWeapon
[WEAPON_SHOTGUN2
] then Exit
;
3471 IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
3472 FWeapon
[WEAPON_SHOTGUN2
] := True;
3474 if gFlash
= 2 then Inc(FPickup
, 5);
3475 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
3478 ITEM_WEAPON_CHAINGUN
:
3479 if (FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
]) or not FWeapon
[WEAPON_CHAINGUN
] then
3481 if a
and FWeapon
[WEAPON_CHAINGUN
] then Exit
;
3483 IncMax(FAmmo
[A_BULLETS
], 50, FMaxAmmo
[A_BULLETS
]);
3484 FWeapon
[WEAPON_CHAINGUN
] := True;
3486 if gFlash
= 2 then Inc(FPickup
, 5);
3487 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
3490 ITEM_WEAPON_ROCKETLAUNCHER
:
3491 if (FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
]) or not FWeapon
[WEAPON_ROCKETLAUNCHER
] then
3493 if a
and FWeapon
[WEAPON_ROCKETLAUNCHER
] then Exit
;
3495 IncMax(FAmmo
[A_ROCKETS
], 2, FMaxAmmo
[A_ROCKETS
]);
3496 FWeapon
[WEAPON_ROCKETLAUNCHER
] := True;
3498 if gFlash
= 2 then Inc(FPickup
, 5);
3499 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
3503 if (FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
]) or not FWeapon
[WEAPON_PLASMA
] then
3505 if a
and FWeapon
[WEAPON_PLASMA
] then Exit
;
3507 IncMax(FAmmo
[A_CELLS
], 40, FMaxAmmo
[A_CELLS
]);
3508 FWeapon
[WEAPON_PLASMA
] := True;
3510 if gFlash
= 2 then Inc(FPickup
, 5);
3511 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
3515 if (FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
]) or not FWeapon
[WEAPON_BFG
] then
3517 if a
and FWeapon
[WEAPON_BFG
] then Exit
;
3519 IncMax(FAmmo
[A_CELLS
], 40, FMaxAmmo
[A_CELLS
]);
3520 FWeapon
[WEAPON_BFG
] := True;
3522 if gFlash
= 2 then Inc(FPickup
, 5);
3523 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
3526 ITEM_WEAPON_SUPERPULEMET
:
3527 if (FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
]) or not FWeapon
[WEAPON_SUPERPULEMET
] then
3529 if a
and FWeapon
[WEAPON_SUPERPULEMET
] then Exit
;
3531 IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
3532 FWeapon
[WEAPON_SUPERPULEMET
] := True;
3534 if gFlash
= 2 then Inc(FPickup
, 5);
3535 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
3539 if FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
] then
3541 IncMax(FAmmo
[A_BULLETS
], 10, FMaxAmmo
[A_BULLETS
]);
3544 if gFlash
= 2 then Inc(FPickup
, 5);
3547 ITEM_AMMO_BULLETS_BOX
:
3548 if FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
] then
3550 IncMax(FAmmo
[A_BULLETS
], 50, FMaxAmmo
[A_BULLETS
]);
3553 if gFlash
= 2 then Inc(FPickup
, 5);
3557 if FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
] then
3559 IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
3562 if gFlash
= 2 then Inc(FPickup
, 5);
3565 ITEM_AMMO_SHELLS_BOX
:
3566 if FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
] then
3568 IncMax(FAmmo
[A_SHELLS
], 25, FMaxAmmo
[A_SHELLS
]);
3571 if gFlash
= 2 then Inc(FPickup
, 5);
3575 if FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
] then
3577 IncMax(FAmmo
[A_ROCKETS
], 1, FMaxAmmo
[A_ROCKETS
]);
3580 if gFlash
= 2 then Inc(FPickup
, 5);
3583 ITEM_AMMO_ROCKET_BOX
:
3584 if FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
] then
3586 IncMax(FAmmo
[A_ROCKETS
], 5, FMaxAmmo
[A_ROCKETS
]);
3589 if gFlash
= 2 then Inc(FPickup
, 5);
3593 if FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
] then
3595 IncMax(FAmmo
[A_CELLS
], 40, FMaxAmmo
[A_CELLS
]);
3598 if gFlash
= 2 then Inc(FPickup
, 5);
3602 if FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
] then
3604 IncMax(FAmmo
[A_CELLS
], 100, FMaxAmmo
[A_CELLS
]);
3607 if gFlash
= 2 then Inc(FPickup
, 5);
3611 if not(R_ITEM_BACKPACK
in FRulez
) or
3612 (FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
]) or
3613 (FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
]) or
3614 (FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
]) or
3615 (FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
]) then
3617 FMaxAmmo
[A_BULLETS
] := 400;
3618 FMaxAmmo
[A_SHELLS
] := 100;
3619 FMaxAmmo
[A_ROCKETS
] := 100;
3620 FMaxAmmo
[A_CELLS
] := 600;
3622 if FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
] then
3623 IncMax(FAmmo
[A_BULLETS
], 10, FMaxAmmo
[A_BULLETS
]);
3624 if FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
] then
3625 IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
3626 if FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
] then
3627 IncMax(FAmmo
[A_ROCKETS
], 1, FMaxAmmo
[A_ROCKETS
]);
3628 if FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
] then
3629 IncMax(FAmmo
[A_CELLS
], 40, FMaxAmmo
[A_CELLS
]);
3631 FRulez
:= FRulez
+ [R_ITEM_BACKPACK
];
3634 if gFlash
= 2 then Inc(FPickup
, 5);
3638 if not(R_KEY_RED
in FRulez
) then
3640 Include(FRulez
, R_KEY_RED
);
3642 remove
:= (gGameSettings
.GameMode
<> GM_COOP
) and (g_Player_GetCount() < 2);
3643 if gFlash
= 2 then Inc(FPickup
, 5);
3644 if (not remove
) and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETITEM');
3648 if not(R_KEY_GREEN
in FRulez
) then
3650 Include(FRulez
, R_KEY_GREEN
);
3652 remove
:= (gGameSettings
.GameMode
<> GM_COOP
) and (g_Player_GetCount() < 2);
3653 if gFlash
= 2 then Inc(FPickup
, 5);
3654 if (not remove
) and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETITEM');
3658 if not(R_KEY_BLUE
in FRulez
) then
3660 Include(FRulez
, R_KEY_BLUE
);
3662 remove
:= (gGameSettings
.GameMode
<> GM_COOP
) and (g_Player_GetCount() < 2);
3663 if gFlash
= 2 then Inc(FPickup
, 5);
3664 if (not remove
) and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETITEM');
3668 if FMegaRulez
[MR_SUIT
] < gTime
+PLAYER_SUIT_TIME
then
3670 FMegaRulez
[MR_SUIT
] := gTime
+PLAYER_SUIT_TIME
;
3673 if gFlash
= 2 then Inc(FPickup
, 5);
3677 if FAir
< AIR_MAX
then
3682 if gFlash
= 2 then Inc(FPickup
, 5);
3687 if not (R_BERSERK
in FRulez
) then
3689 Include(FRulez
, R_BERSERK
);
3690 if FBFGFireCounter
= -1 then
3692 FCurrWeap
:= WEAPON_KASTET
;
3694 FModel
.SetWeapon(WEAPON_KASTET
);
3698 if gFlash
= 2 then Inc(FPickup
, 5);
3699 FBerserk
:= gTime
+30000;
3703 if FHealth
< PLAYER_HP_SOFT
then
3705 FHealth
:= PLAYER_HP_SOFT
;
3706 FBerserk
:= gTime
+30000;
3713 if FMegaRulez
[MR_INVUL
] < gTime
+PLAYER_INVUL_TIME
then
3715 FMegaRulez
[MR_INVUL
] := gTime
+PLAYER_INVUL_TIME
;
3718 if gFlash
= 2 then Inc(FPickup
, 5);
3722 if FHealth
< PLAYER_HP_LIMIT
then
3724 IncMax(FHealth
, 4, PLAYER_HP_LIMIT
);
3727 if gFlash
= 2 then Inc(FPickup
, 5);
3731 if FArmor
< PLAYER_AP_LIMIT
then
3733 IncMax(FArmor
, 5, PLAYER_AP_LIMIT
);
3736 if gFlash
= 2 then Inc(FPickup
, 5);
3740 if FJetFuel
< JET_MAX
then
3742 FJetFuel
:= JET_MAX
;
3745 if gFlash
= 2 then Inc(FPickup
, 5);
3749 if FMegaRulez
[MR_INVIS
] < gTime
+PLAYER_INVIS_TIME
then
3751 FMegaRulez
[MR_INVIS
] := gTime
+PLAYER_INVIS_TIME
;
3754 if gFlash
= 2 then Inc(FPickup
, 5);
3759 procedure TPlayer
.Touch();
3763 //FModel.PlaySound(MODELSOUND_PAIN, 1, FObj.X, FObj.Y);
3766 // Áðîñèòü ôëàã òîâàðèùó:
3767 if gGameSettings
.GameMode
= GM_CTF
then
3772 procedure TPlayer
.Push(vx
, vy
: Integer);
3774 if (not FPhysics
) and FGhost
then
3776 FObj
.Accel
.X
:= FObj
.Accel
.X
+ vx
;
3777 FObj
.Accel
.Y
:= FObj
.Accel
.Y
+ vy
;
3778 if g_Game_IsNet
and g_Game_IsServer
then
3779 MH_SEND_PlayerPos(True, FUID
, NET_EVERYONE
);
3782 procedure TPlayer
.Reset(Force
: Boolean);
3788 FTime
[T_RESPAWN
] := 0;
3789 FTime
[T_FLAGCAP
] := 0;
3802 FSpectator
:= False;
3805 FSpectatePlayer
:= -1;
3806 FNoRespawn
:= False;
3808 FLives
:= gGameSettings
.MaxLives
;
3813 procedure TPlayer
.SoftReset();
3819 FBFGFireCounter
:= -1;
3827 SetAction(A_STAND
, True);
3830 function TPlayer
.GetRespawnPoint(): Byte;
3835 // Íà áóäóùåå: FSpawn - èãðîê óæå èãðàë è ïåðåðîæäàåòñÿ
3837 // Îäèíî÷íàÿ èãðà/êîîïåðàòèâ
3838 if gGameSettings
.GameMode
in [GM_COOP
, GM_SINGLE
] then
3840 if (Self
= gPlayer1
) or (Self
= gPlayer2
) then
3842 // Òî÷êà ïîÿâëåíèÿ ñâîåãî èãðîêà
3843 if Self
= gPlayer1
then
3844 c
:= RESPAWNPOINT_PLAYER1
3846 c
:= RESPAWNPOINT_PLAYER2
;
3847 if g_Map_GetPointCount(c
) > 0 then
3853 // Òî÷êà ïîÿâëåíèÿ äðóãîãî èãðîêà
3854 if Self
= gPlayer1
then
3855 c
:= RESPAWNPOINT_PLAYER2
3857 c
:= RESPAWNPOINT_PLAYER1
;
3858 if g_Map_GetPointCount(c
) > 0 then
3865 // Òî÷êà ïîÿâëåíèÿ ëþáîãî èãðîêà (áîòà)
3866 if Random(2) = 0 then
3867 c
:= RESPAWNPOINT_PLAYER1
3869 c
:= RESPAWNPOINT_PLAYER2
;
3870 if g_Map_GetPointCount(c
) > 0 then
3877 // Òî÷êà ëþáîé èç êîìàíä
3878 if Random(2) = 0 then
3879 c
:= RESPAWNPOINT_RED
3881 c
:= RESPAWNPOINT_BLUE
;
3882 if g_Map_GetPointCount(c
) > 0 then
3889 c
:= RESPAWNPOINT_DM
;
3890 if g_Map_GetPointCount(c
) > 0 then
3898 if gGameSettings
.GameMode
= GM_DM
then
3901 c
:= RESPAWNPOINT_DM
;
3902 if g_Map_GetPointCount(c
) > 0 then
3908 // Òî÷êà ïîÿâëåíèÿ ëþáîãî èãðîêà
3909 if Random(2) = 0 then
3910 c
:= RESPAWNPOINT_PLAYER1
3912 c
:= RESPAWNPOINT_PLAYER2
;
3913 if g_Map_GetPointCount(c
) > 0 then
3919 // Òî÷êà ëþáîé èç êîìàíä
3920 if Random(2) = 0 then
3921 c
:= RESPAWNPOINT_RED
3923 c
:= RESPAWNPOINT_BLUE
;
3924 if g_Map_GetPointCount(c
) > 0 then
3932 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
3934 // Òî÷êà ñâîåé êîìàíäû
3935 c
:= RESPAWNPOINT_DM
;
3936 if FTeam
= TEAM_RED
then
3937 c
:= RESPAWNPOINT_RED
;
3938 if FTeam
= TEAM_BLUE
then
3939 c
:= RESPAWNPOINT_BLUE
;
3940 if g_Map_GetPointCount(c
) > 0 then
3947 c
:= RESPAWNPOINT_DM
;
3948 if g_Map_GetPointCount(c
) > 0 then
3954 // Òî÷êà ïîÿâëåíèÿ ëþáîãî èãðîêà
3955 if Random(2) = 0 then
3956 c
:= RESPAWNPOINT_PLAYER1
3958 c
:= RESPAWNPOINT_PLAYER2
;
3959 if g_Map_GetPointCount(c
) > 0 then
3965 // Òî÷êà äðóãîé êîìàíäû
3966 c
:= RESPAWNPOINT_DM
;
3967 if FTeam
= TEAM_RED
then
3968 c
:= RESPAWNPOINT_BLUE
;
3969 if FTeam
= TEAM_BLUE
then
3970 c
:= RESPAWNPOINT_RED
;
3971 if g_Map_GetPointCount(c
) > 0 then
3979 procedure TPlayer
.Respawn(Silent
: Boolean; Force
: Boolean = False);
3981 RespawnPoint
: TRespawnPoint
;
3986 if not g_Game_IsServer
then
3990 FWantsInGame
:= True;
3991 FJustTeleported
:= True;
3994 FTime
[T_RESPAWN
] := 0;
3998 // if server changes MaxLives we gotta be ready
3999 if gGameSettings
.MaxLives
= 0 then FNoRespawn
:= False;
4001 // Åùå íåëüçÿ âîçðîäèòüñÿ:
4002 if FTime
[T_RESPAWN
] > gTime
then
4005 // Ïðîñðàë âñå æèçíè:
4008 if not FSpectator
then Spectate(True);
4009 FWantsInGame
:= True;
4013 if (gGameSettings
.GameType
<> GT_SINGLE
) and (gGameSettings
.GameMode
<> GM_COOP
) then
4014 begin // "Ñâîÿ èãðà"
4015 // Áåðñåðê íå ñîõðàíÿåòñÿ ìåæäó óðîâíÿìè:
4016 FRulez
:= FRulez
-[R_BERSERK
];
4018 else // "Îäèíî÷íàÿ èãðà"/"Êîîï"
4020 // Áåðñåðê è êëþ÷è íå ñîõðàíÿþòñÿ ìåæäó óðîâíÿìè:
4021 FRulez
:= FRulez
-[R_KEY_RED
, R_KEY_GREEN
, R_KEY_BLUE
, R_BERSERK
];
4024 // Ïîëó÷àåì òî÷êó ñïàóíà èãðîêà:
4025 c
:= GetRespawnPoint();
4030 // Âîñêðåøåíèå áåç îðóæèÿ:
4033 FHealth
:= PLAYER_HP_SOFT
;
4039 for a
:= WEAPON_KASTET
to WEAPON_SUPERPULEMET
do
4041 FWeapon
[a
] := False;
4045 FWeapon
[WEAPON_PISTOL
] := True;
4046 FWeapon
[WEAPON_KASTET
] := True;
4047 FCurrWeap
:= WEAPON_PISTOL
;
4050 FModel
.SetWeapon(FCurrWeap
);
4052 for b
:= A_BULLETS
to A_CELLS
do
4055 FAmmo
[A_BULLETS
] := 50;
4057 FMaxAmmo
[A_BULLETS
] := 200;
4058 FMaxAmmo
[A_SHELLS
] := 50;
4059 FMaxAmmo
[A_ROCKETS
] := 50;
4060 FMaxAmmo
[A_CELLS
] := 300;
4062 if gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
] then
4063 FRulez
:= [R_KEY_RED
, R_KEY_GREEN
, R_KEY_BLUE
]
4068 // Ïîëó÷àåì êîîðäèíàòû òî÷êè âîçðîæäåíèÿ:
4069 if not g_Map_GetPoint(c
, RespawnPoint
) then
4071 g_FatalError(_lc
[I_GAME_ERROR_GET_SPAWN
]);
4075 // Óñòàíîâêà êîîðäèíàò è ñáðîñ âñåõ ïàðàìåòðîâ:
4076 FObj
.X
:= RespawnPoint
.X
-PLAYER_RECT
.X
;
4077 FObj
.Y
:= RespawnPoint
.Y
-PLAYER_RECT
.Y
;
4083 FDirection
:= RespawnPoint
.Direction
;
4084 if FDirection
= D_LEFT
then
4090 FBFGFireCounter
:= -1;
4095 SetAction(A_STAND
, True);
4096 FModel
.Direction
:= FDirection
;
4098 for a
:= Low(FTime
) to High(FTime
) do
4101 for a
:= Low(FMegaRulez
) to High(FMegaRulez
) do
4106 FCanJetpack
:= False;
4108 // Àíèìàöèÿ âîçðîæäåíèÿ:
4109 if (not gLoadGameMode
) and (not Silent
) then
4110 if g_Frames_Get(ID
, 'FRAMES_TELEPORT') then
4112 Anim
:= TAnimation
.Create(ID
, False, 3);
4113 g_GFX_OnceAnim(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-32,
4114 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)-32, Anim
);
4118 FSpectator
:= False;
4121 FSpectatePlayer
:= -1;
4124 if g_Game_IsNet
then
4126 MH_SEND_PlayerPos(True, FUID
, NET_EVERYONE
);
4127 MH_SEND_PlayerStats(FUID
, NET_EVERYONE
);
4129 MH_SEND_Effect(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-32,
4130 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)-32,
4135 procedure TPlayer
.Spectate(NoMove
: Boolean = False);
4138 Kill(K_EXTRAHARDKILL
, FUID
, HIT_SOME
)
4139 else if (not NoMove
) then
4141 GameX
:= gMapInfo
.Width
div 2;
4142 GameY
:= gMapInfo
.Height
div 2;
4151 FWantsInGame
:= False;
4156 if Self
= gPlayer1
then
4161 if Self
= gPlayer2
then
4168 if g_Game_IsNet
then
4169 MH_SEND_PlayerStats(FUID
);
4172 procedure TPlayer
.SwitchNoClip
;
4176 FGhost
:= not FGhost
;
4177 FPhysics
:= not FGhost
;
4189 procedure TPlayer
.Run(Direction
: TDirection
);
4193 if MAX_RUNVEL
> 8 then
4197 if Direction
= D_LEFT
then
4199 if FObj
.Vel
.X
> -MAX_RUNVEL
then
4200 FObj
.Vel
.X
:= FObj
.Vel
.X
- (MAX_RUNVEL
shr 3);
4203 if FObj
.Vel
.X
< MAX_RUNVEL
then
4204 FObj
.Vel
.X
:= FObj
.Vel
.X
+ (MAX_RUNVEL
shr 3);
4206 // Âîçìîæíî, ïèíàåì êóñêè:
4207 if (FObj
.Vel
.X
<> 0) and (gGibs
<> nil) then
4209 b
:= Abs(FObj
.Vel
.X
);
4210 if b
> 1 then b
:= b
* (Random(8 div b
) + 1);
4211 for a
:= 0 to High(gGibs
) do
4212 if gGibs
[a
].Live
and
4213 g_Obj_Collide(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
+FObj
.Rect
.Height
-4,
4214 FObj
.Rect
.Width
, 8, @gGibs
[a
].Obj
) and (Random(3) = 0) then
4216 if FObj
.Vel
.X
< 0 then
4217 g_Obj_PushA(@gGibs
[a
].Obj
, b
, Random(61)+120) // íàëåâî
4219 g_Obj_PushA(@gGibs
[a
].Obj
, b
, Random(61)); // íàïðàâî
4225 procedure TPlayer
.SeeDown();
4227 SetAction(A_SEEDOWN
);
4229 if FDirection
= D_LEFT
then FAngle
:= ANGLE_LEFTDOWN
else FAngle
:= ANGLE_RIGHTDOWN
;
4231 if FIncCam
> -120 then DecMin(FIncCam
, 5, -120);
4234 procedure TPlayer
.SeeUp();
4238 if FDirection
= D_LEFT
then FAngle
:= ANGLE_LEFTUP
else FAngle
:= ANGLE_RIGHTUP
;
4240 if FIncCam
< 120 then IncMax(FIncCam
, 5, 120);
4243 procedure TPlayer
.SetAction(Action
: Byte; Force
: Boolean = False);
4251 A_ATTACK
: Prior
:= 2;
4252 A_SEEUP
: Prior
:= 1;
4253 A_SEEDOWN
: Prior
:= 1;
4254 A_ATTACKUP
: Prior
:= 2;
4255 A_ATTACKDOWN
: Prior
:= 2;
4260 if (Prior
> FActionPrior
) or Force
then
4261 if not ((Prior
= 2) and (FCurrWeap
= WEAPON_SAW
)) then
4263 FActionPrior
:= Prior
;
4264 FActionAnim
:= Action
;
4265 FActionForce
:= Force
;
4266 FActionChanged
:= True;
4269 if Action
in [A_ATTACK
, A_ATTACKUP
, A_ATTACKDOWN
] then FModel
.SetFire(True);
4272 function TPlayer
.StayOnStep(XInc
, YInc
: Integer): Boolean;
4274 Result
:= not g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+YInc
+PLAYER_RECT
.Y
+PLAYER_RECT
.Height
-1,
4275 PLAYER_RECT
.Width
, 1, PANEL_STEP
, False)
4276 and g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+YInc
+PLAYER_RECT
.Y
+PLAYER_RECT
.Height
,
4277 PLAYER_RECT
.Width
, 1, PANEL_STEP
, False);
4280 function TPlayer
.TeleportTo(X
, Y
: Integer; silent
: Boolean; dir
: Byte): Boolean;
4287 if g_CollideLevel(X
, Y
, PLAYER_RECT
.Width
, PLAYER_RECT
.Height
) then
4289 g_Sound_PlayExAt('SOUND_GAME_NOTELEPORT', FObj
.X
, FObj
.Y
);
4290 if g_Game_IsServer
and g_Game_IsNet
then
4291 MH_SEND_Sound(FObj
.X
, FObj
.Y
, 'SOUND_GAME_NOTELEPORT');
4295 FJustTeleported
:= True;
4300 if g_Frames_Get(ID
, 'FRAMES_TELEPORT') then
4302 Anim
:= TAnimation
.Create(ID
, False, 3);
4305 g_Sound_PlayExAt('SOUND_GAME_TELEPORT', FObj
.X
, FObj
.Y
);
4306 g_GFX_OnceAnim(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-32,
4307 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)-32, Anim
);
4308 if g_Game_IsServer
and g_Game_IsNet
then
4309 MH_SEND_Effect(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-32,
4310 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)-32, 1,
4314 FObj
.X
:= X
-PLAYER_RECT
.X
;
4315 FObj
.Y
:= Y
-PLAYER_RECT
.Y
;
4316 if FLive
and FGhost
then
4322 if not g_Game_IsNet
then
4326 SetDirection(D_LEFT
);
4332 SetDirection(D_RIGHT
);
4338 if FDirection
= D_RIGHT
then
4340 SetDirection(D_LEFT
);
4345 SetDirection(D_RIGHT
);
4351 if not silent
and (Anim
<> nil) then
4353 g_GFX_OnceAnim(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-32,
4354 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)-32, Anim
);
4357 if g_Game_IsServer
and g_Game_IsNet
then
4358 MH_SEND_Effect(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-32,
4359 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)-32, 0,
4366 function nonz(a
: Single): Single;
4374 procedure TPlayer
.Update();
4377 i
, ii
, wx
, wy
, xd
, yd
, k
: Integer;
4378 blockmon
, headwater
, dospawn
: Boolean;
4383 NetServer
:= g_Game_IsNet
and g_Game_IsServer
;
4384 AnyServer
:= g_Game_IsServer
;
4386 if g_Game_IsClient
and (NetInterpLevel
> 0) then
4387 DoLerp(NetInterpLevel
+ 1)
4393 if FClientID
>= 0 then
4395 FPing
:= NetClients
[FClientID
].Peer
^.lastRoundTripTime
;
4396 if NetClients
[FClientID
].Peer
^.packetsSent
> 0 then
4397 FLoss
:= Round(100*NetClients
[FClientID
].Peer
^.packetsLost
/NetClients
[FClientID
].Peer
^.packetsSent
)
4406 if FLive
and (gFly
or FJetpack
) then
4409 if FDirection
= D_LEFT
then
4414 if FLive
and (not FGhost
) then
4416 if FKeys
[KEY_UP
].Pressed
then
4418 if FKeys
[KEY_DOWN
].Pressed
then
4422 if (not (FKeys
[KEY_UP
].Pressed
or FKeys
[KEY_DOWN
].Pressed
)) and
4425 i
:= g_basic
.Sign(FIncCam
);
4426 FIncCam
:= Abs(FIncCam
);
4427 DecMin(FIncCam
, 5, 0);
4428 FIncCam
:= FIncCam
*i
;
4431 if gTime
mod (GAME_TICK
*2) <> 0 then
4433 if (FObj
.Vel
.X
= 0) and FLive
then
4435 if FKeys
[KEY_LEFT
].Pressed
then
4437 if FKeys
[KEY_RIGHT
].Pressed
then
4442 g_Obj_Move(@FObj
, True, True, True);
4447 FActionChanged
:= False;
4451 // Let alive player do some actions
4452 if FKeys
[KEY_LEFT
].Pressed
then Run(D_LEFT
);
4453 if FKeys
[KEY_RIGHT
].Pressed
then Run(D_RIGHT
);
4454 if FKeys
[KEY_NEXTWEAPON
].Pressed
and AnyServer
then NextWeapon();
4455 if FKeys
[KEY_PREVWEAPON
].Pressed
and AnyServer
then PrevWeapon();
4456 if FKeys
[KEY_FIRE
].Pressed
and AnyServer
then Fire();
4457 if FKeys
[KEY_OPEN
].Pressed
and AnyServer
then Use();
4458 if FKeys
[KEY_JUMP
].Pressed
then Jump()
4461 if AnyServer
and FJetpack
then
4465 if NetServer
then MH_SEND_PlayerStats(FUID
);
4467 FCanJetpack
:= True;
4474 for k
:= Low(FKeys
) to KEY_CHAT
-1 do
4476 if FKeys
[k
].Pressed
then
4484 if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
4487 if (FTime
[T_RESPAWN
] <= gTime
) and
4488 gGameOn
and (not FLive
) then
4490 if (g_Player_GetCount() > 1) then
4494 gExit
:= EXIT_RESTART
;
4499 // Dead spectator actions
4502 if FKeys
[KEY_OPEN
].Pressed
and AnyServer
then Fire();
4503 if FKeys
[KEY_FIRE
].Pressed
and AnyServer
then
4507 if (FSpectatePlayer
>= High(gPlayers
)) then
4508 FSpectatePlayer
:= -1
4512 for I
:= FSpectatePlayer
+ 1 to High(gPlayers
) do
4513 if gPlayers
[I
] <> nil then
4514 if gPlayers
[I
].Live
then
4515 if gPlayers
[I
].UID
<> FUID
then
4517 FSpectatePlayer
:= I
;
4522 if not SetSpect
then FSpectatePlayer
:= -1;
4533 if FKeys
[KEY_UP
].Pressed
or FKeys
[KEY_JUMP
].Pressed
then
4535 FYTo
:= FObj
.Y
- 32;
4536 FSpectatePlayer
:= -1;
4538 if FKeys
[KEY_DOWN
].Pressed
then
4540 FYTo
:= FObj
.Y
+ 32;
4541 FSpectatePlayer
:= -1;
4543 if FKeys
[KEY_LEFT
].Pressed
then
4545 FXTo
:= FObj
.X
- 32;
4546 FSpectatePlayer
:= -1;
4548 if FKeys
[KEY_RIGHT
].Pressed
then
4550 FXTo
:= FObj
.X
+ 32;
4551 FSpectatePlayer
:= -1;
4554 if (FXTo
< -64) then
4556 else if (FXTo
> gMapInfo
.Width
+ 32) then
4557 FXTo
:= gMapInfo
.Width
+ 32;
4558 if (FYTo
< -72) then
4560 else if (FYTo
> gMapInfo
.Height
+ 32) then
4561 FYTo
:= gMapInfo
.Height
+ 32;
4565 g_Obj_Move(@FObj
, True, True, True)
4571 if (FSpectatePlayer
<= High(gPlayers
)) and (FSpectatePlayer
>= 0) then
4572 if gPlayers
[FSpectatePlayer
] <> nil then
4573 if gPlayers
[FSpectatePlayer
].Live
then
4575 FXTo
:= gPlayers
[FSpectatePlayer
].GameX
;
4576 FYTo
:= gPlayers
[FSpectatePlayer
].GameY
;
4580 blockmon
:= g_Map_CollidePanel(FObj
.X
+PLAYER_HEADRECT
.X
, FObj
.Y
+PLAYER_HEADRECT
.Y
,
4581 PLAYER_HEADRECT
.Width
, PLAYER_HEADRECT
.Height
,
4582 PANEL_BLOCKMON
, True);
4583 headwater
:= HeadInLiquid(0, 0);
4585 // Ñîïðîòèâëåíèå âîçäóõà:
4586 if (not FLive
) or not (FKeys
[KEY_LEFT
].Pressed
or FKeys
[KEY_RIGHT
].Pressed
) then
4587 if FObj
.Vel
.X
<> 0 then
4588 FObj
.Vel
.X
:= z_dec(FObj
.Vel
.X
, 1);
4590 if (FLastHit
= HIT_TRAP
) and (FPain
> 90) then FPain
:= 90;
4591 DecMin(FPain
, 5, 0);
4592 DecMin(FPickup
, 1, 0);
4594 if FLive
and (FObj
.Y
> gMapInfo
.Height
+128) and AnyServer
then
4596 // Îáíóëèòü äåéñòâèÿ ïðèìî÷åê, ÷òîáû ôîí ïðîïàë
4597 FMegaRulez
[MR_SUIT
] := 0;
4598 FMegaRulez
[MR_INVUL
] := 0;
4599 FMegaRulez
[MR_INVIS
] := 0;
4600 Kill(K_FALLKILL
, 0, HIT_FALL
);
4607 if FCurrWeap
= WEAPON_SAW
then
4608 if not (FSawSound
.IsPlaying() or FSawSoundHit
.IsPlaying() or
4609 FSawSoundSelect
.IsPlaying()) then
4610 FSawSoundIdle
.PlayAt(FObj
.X
, FObj
.Y
);
4613 if (not FJetSoundFly
.IsPlaying()) and (not FJetSoundOn
.IsPlaying()) and
4614 (not FJetSoundOff
.IsPlaying()) then
4616 FJetSoundFly
.SetPosition(0);
4617 FJetSoundFly
.PlayAt(FObj
.X
, FObj
.Y
);
4620 for b
:= WEAPON_KASTET
to WEAPON_SUPERPULEMET
do
4621 if FReloading
[b
] > 0 then
4627 if FShellTimer
> -1 then
4628 if FShellTimer
= 0 then
4630 if FShellType
= SHELL_SHELL
then
4631 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
4632 GameVelX
, GameVelY
-2, SHELL_SHELL
)
4633 else if FShellType
= SHELL_DBLSHELL
then
4635 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
4636 GameVelX
+1, GameVelY
-2, SHELL_SHELL
);
4637 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
4638 GameVelX
-1, GameVelY
-2, SHELL_SHELL
);
4641 end else Dec(FShellTimer
);
4643 if (FBFGFireCounter
> -1) then
4644 if FBFGFireCounter
= 0 then
4648 wx
:= FObj
.X
+WEAPONPOINT
[FDirection
].X
;
4649 wy
:= FObj
.Y
+WEAPONPOINT
[FDirection
].Y
;
4650 xd
:= wx
+IfThen(FDirection
= D_LEFT
, -30, 30);
4651 yd
:= wy
+firediry();
4652 g_Weapon_bfgshot(wx
, wy
, xd
, yd
, FUID
);
4653 if NetServer
then MH_SEND_PlayerFire(FUID
, WEAPON_BFG
, wx
, wy
, xd
, yd
);
4654 if (FAngle
= 0) or (FAngle
= 180) then SetAction(A_ATTACK
)
4655 else if (FAngle
= ANGLE_LEFTDOWN
) or (FAngle
= ANGLE_RIGHTDOWN
) then SetAction(A_ATTACKDOWN
)
4656 else if (FAngle
= ANGLE_LEFTUP
) or (FAngle
= ANGLE_RIGHTUP
) then SetAction(A_ATTACKUP
);
4659 FReloading
[WEAPON_BFG
] := WEAPON_RELOAD
[WEAPON_BFG
];
4660 FBFGFireCounter
:= -1;
4663 FBFGFireCounter
:= 0
4665 Dec(FBFGFireCounter
);
4667 if (FMegaRulez
[MR_SUIT
] < gTime
) and AnyServer
then
4669 b
:= g_GetAcidHit(FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+PLAYER_RECT
.Y
, PLAYER_RECT
.Width
, PLAYER_RECT
.Height
);
4671 if (b
> 0) and (gTime
mod (15*GAME_TICK
) = 0) then Damage(b
, 0, 0, 0, HIT_ACID
);
4674 if (headwater
or blockmon
) then
4680 if AnyServer
then Damage(10, 0, 0, 0, HIT_WATER
);
4683 else if (FAir
mod 31 = 0) and not blockmon
then
4685 g_GFX_Bubbles(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2), FObj
.Y
+PLAYER_RECT
.Y
-4, 5+Random(6), 8, 4);
4686 if Random(2) = 0 then
4687 g_Sound_PlayExAt('SOUND_GAME_BUBBLE1', FObj
.X
, FObj
.Y
)
4689 g_Sound_PlayExAt('SOUND_GAME_BUBBLE2', FObj
.X
, FObj
.Y
);
4691 end else if FAir
< AIR_DEF
then
4694 if FDamageBuffer
> 0 then
4696 if FDamageBuffer
>= 9 then
4700 if FDamageBuffer
< 30 then i
:= 9
4701 else if FDamageBuffer
< 100 then i
:= 18
4705 ii
:= Round(FDamageBuffer
*FHealth
/ nonz(FArmor
*(3/4)+FHealth
));
4706 FArmor
:= FArmor
-(FDamageBuffer
-ii
);
4707 FHealth
:= FHealth
-ii
;
4710 FHealth
:= FHealth
+FArmor
;
4715 if FHealth
<= 0 then
4716 if FHealth
> -30 then Kill(K_SIMPLEKILL
, FLastSpawnerUID
, FLastHit
)
4717 else if FHealth
> -50 then Kill(K_HARDKILL
, FLastSpawnerUID
, FLastHit
)
4718 else Kill(K_EXTRAHARDKILL
, FLastSpawnerUID
, FLastHit
);
4722 if FDamageBuffer
<= 20 then FModel
.PlaySound(MODELSOUND_PAIN
, 1, FObj
.X
, FObj
.Y
)
4723 else if FDamageBuffer
<= 55 then FModel
.PlaySound(MODELSOUND_PAIN
, 2, FObj
.X
, FObj
.Y
)
4724 else if FDamageBuffer
<= 120 then FModel
.PlaySound(MODELSOUND_PAIN
, 3, FObj
.X
, FObj
.Y
)
4725 else FModel
.PlaySound(MODELSOUND_PAIN
, 4, FObj
.X
, FObj
.Y
);
4732 end; // if FLive then ...
4734 if (FActionAnim
= A_PAIN
) and (FModel
.Animation
<> A_PAIN
) then
4736 FModel
.ChangeAnimation(FActionAnim
, FActionForce
);
4737 FModel
.GetCurrentAnimation
.MinLength
:= i
;
4738 FModel
.GetCurrentAnimationMask
.MinLength
:= i
;
4739 end else FModel
.ChangeAnimation(FActionAnim
, FActionForce
and (FModel
.Animation
<> A_STAND
));
4741 if (FModel
.GetCurrentAnimation
.Played
or ((not FActionChanged
) and (FModel
.Animation
= A_WALK
)))
4742 then SetAction(A_STAND
, True);
4744 if not ((FModel
.Animation
= A_WALK
) and (Abs(FObj
.Vel
.X
) < 4) and not FModel
.Fire
) then FModel
.Update
;
4746 for b
:= Low(FKeys
) to High(FKeys
) do
4747 if FKeys
[b
].Time
= 0 then FKeys
[b
].Pressed
:= False else Dec(FKeys
[b
].Time
);
4750 function TPlayer
.Collide(X
, Y
: Integer; Width
, Height
: Word): Boolean;
4752 Result
:= g_Collide(FObj
.X
+PLAYER_RECT
.X
,
4753 FObj
.Y
+PLAYER_RECT
.Y
,
4760 function TPlayer
.Collide(Panel
: TPanel
): Boolean;
4762 Result
:= g_Collide(FObj
.X
+PLAYER_RECT
.X
,
4763 FObj
.Y
+PLAYER_RECT
.Y
,
4767 Panel
.Width
, Panel
.Height
);
4770 function TPlayer
.Collide(X
, Y
: Integer): Boolean;
4772 X
:= X
-FObj
.X
-PLAYER_RECT
.X
;
4773 Y
:= Y
-FObj
.Y
-PLAYER_RECT
.Y
;
4774 Result
:= (x
>= 0) and (x
<= PLAYER_RECT
.Width
) and
4775 (y
>= 0) and (y
<= PLAYER_RECT
.Height
);
4778 function g_Player_ValidName(Name
: string): Boolean;
4784 if gPlayers
= nil then Exit
;
4786 for a
:= 0 to High(gPlayers
) do
4787 if gPlayers
[a
] <> nil then
4788 if LowerCase(Name
) = LowerCase(gPlayers
[a
].FName
) then
4795 procedure TPlayer
.SetDirection(Direction
: TDirection
);
4799 d
:= FModel
.Direction
;
4801 FModel
.Direction
:= Direction
;
4802 if d
<> Direction
then FModel
.ChangeAnimation(FModel
.Animation
, True);
4804 FDirection
:= Direction
;
4807 function TPlayer
.GetKeys(): Byte;
4811 if R_KEY_RED
in FRulez
then Result
:= KEY_RED
;
4812 if R_KEY_GREEN
in FRulez
then Result
:= Result
or KEY_GREEN
;
4813 if R_KEY_BLUE
in FRulez
then Result
:= Result
or KEY_BLUE
;
4815 if FTeam
= TEAM_RED
then Result
:= Result
or KEY_REDTEAM
;
4816 if FTeam
= TEAM_BLUE
then Result
:= Result
or KEY_BLUETEAM
;
4819 procedure TPlayer
.Use();
4823 if FTime
[T_USE
] > gTime
then Exit
;
4825 g_Triggers_PressR(FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+PLAYER_RECT
.Y
, PLAYER_RECT
.Width
,
4826 PLAYER_RECT
.Height
, FUID
, ACTIVATE_PLAYERPRESS
);
4828 for a
:= 0 to High(gPlayers
) do
4829 if (gPlayers
[a
] <> nil) and (gPlayers
[a
] <> Self
) and
4830 gPlayers
[a
].Live
and SameTeam(FUID
, gPlayers
[a
].FUID
) and
4831 g_Obj_Collide(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
,
4832 FObj
.Rect
.Width
, FObj
.Rect
.Height
, @gPlayers
[a
].FObj
) then
4834 gPlayers
[a
].Touch();
4835 if g_Game_IsNet
and g_Game_IsServer
then
4836 MH_SEND_GameEvent(NET_EV_PLAYER_TOUCH
, gPlayers
[a
].FUID
);
4839 FTime
[T_USE
] := gTime
+120;
4842 procedure TPlayer
.NetFire(Wpn
: Byte; X
, Y
, AX
, AY
: Integer; WID
: Integer = -1);
4846 WX
, WY
, XD
, YD
: Integer;
4857 if R_BERSERK
in FRulez
then
4859 //g_Weapon_punch(FObj.X+FObj.Rect.X, FObj.Y+FObj.Rect.Y, 75, FUID);
4860 obj
.X
:= FObj
.X
+FObj
.Rect
.X
;
4861 obj
.Y
:= FObj
.Y
+FObj
.Rect
.Y
;
4864 obj
.rect
.Width
:= 39;
4865 obj
.rect
.Height
:= 52;
4866 obj
.Vel
.X
:= (xd
-wx
) div 2;
4867 obj
.Vel
.Y
:= (yd
-wy
) div 2;
4868 obj
.Accel
.X
:= xd
-wx
;
4869 obj
.Accel
.y
:= yd
-wy
;
4871 if g_Weapon_Hit(@obj
, 50, FUID
, HIT_SOME
) <> 0 then
4872 g_Sound_PlayExAt('SOUND_WEAPON_HITBERSERK', FObj
.X
, FObj
.Y
)
4874 g_Sound_PlayExAt('SOUND_WEAPON_MISSBERSERK', FObj
.X
, FObj
.Y
);
4878 FPain
:= min(FPain
+ 25, 50);
4880 g_Weapon_punch(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
, 3, FUID
);
4885 if g_Weapon_chainsaw(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
,
4886 IfThen(gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
], 9, 3), FUID
) <> 0 then
4888 FSawSoundSelect
.Stop();
4890 FSawSoundHit
.PlayAt(FObj
.X
, FObj
.Y
);
4892 else if not FSawSoundHit
.IsPlaying() then
4894 FSawSoundSelect
.Stop();
4895 FSawSound
.PlayAt(FObj
.X
, FObj
.Y
);
4902 g_Sound_PlayExAt('SOUND_WEAPON_FIREPISTOL', GameX
, Gamey
);
4903 FFireAngle
:= FAngle
;
4905 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
4906 GameVelX
, GameVelY
-2, SHELL_BULLET
);
4911 g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN', Gamex
, Gamey
);
4912 FFireAngle
:= FAngle
;
4915 FShellType
:= SHELL_SHELL
;
4920 g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN2', Gamex
, Gamey
);
4921 FFireAngle
:= FAngle
;
4924 FShellType
:= SHELL_DBLSHELL
;
4929 g_Sound_PlayExAt('SOUND_WEAPON_FIRECGUN', Gamex
, Gamey
);
4930 FFireAngle
:= FAngle
;
4932 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
4933 GameVelX
, GameVelY
-2, SHELL_BULLET
);
4936 WEAPON_ROCKETLAUNCHER
:
4938 g_Weapon_Rocket(wx
, wy
, xd
, yd
, FUID
, WID
);
4939 FFireAngle
:= FAngle
;
4945 g_Weapon_Plasma(wx
, wy
, xd
, yd
, FUID
, WID
);
4946 FFireAngle
:= FAngle
;
4952 g_Weapon_BFGShot(wx
, wy
, xd
, yd
, FUID
, WID
);
4953 FFireAngle
:= FAngle
;
4957 WEAPON_SUPERPULEMET
:
4959 g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN', Gamex
, Gamey
);
4960 FFireAngle
:= FAngle
;
4962 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
4963 GameVelX
, GameVelY
-2, SHELL_SHELL
);
4969 if (FAngle
= 0) or (FAngle
= 180) then SetAction(A_ATTACK
)
4970 else if (FAngle
= ANGLE_LEFTDOWN
) or (FAngle
= ANGLE_RIGHTDOWN
) then SetAction(A_ATTACKDOWN
)
4971 else if (FAngle
= ANGLE_LEFTUP
) or (FAngle
= ANGLE_RIGHTUP
) then SetAction(A_ATTACKUP
);
4974 procedure TPlayer
.DoLerp(Level
: Integer = 2);
4976 if FObj
.X
<> FXTo
then FObj
.X
:= Lerp(FObj
.X
, FXTo
, Level
);
4977 if FObj
.Y
<> FYTo
then FObj
.Y
:= Lerp(FObj
.Y
, FYTo
, Level
);
4980 procedure TPlayer
.SetLerp(XTo
, YTo
: Integer);
4984 if NetInterpLevel
< 1 then
4994 AX
:= Abs(FXTo
- FObj
.X
);
4995 AY
:= Abs(FYTo
- FObj
.Y
);
4996 if (AX
> 32) or (AX
<= NetInterpLevel
) then
4998 if (AY
> 32) or (AY
<= NetInterpLevel
) then
5003 function TPlayer
.FullInLift(XInc
, YInc
: Integer): Integer;
5005 if g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
,
5006 PLAYER_RECT
.Width
, PLAYER_RECT
.Height
-8,
5007 PANEL_LIFTUP
, False) then Result
:= -1
5009 if g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
,
5010 PLAYER_RECT
.Width
, PLAYER_RECT
.Height
-8,
5011 PANEL_LIFTDOWN
, False) then Result
:= 1
5015 function TPlayer
.GetFlag(Flag
: Byte): Boolean;
5022 if Flag
= FLAG_NONE
then
5025 if not g_Game_IsServer
then Exit
;
5027 // Ïðèíåñ ÷óæîé ôëàã íà ñâîþ áàçó:
5028 if (Flag
= FTeam
) and
5029 (gFlags
[Flag
].State
= FLAG_STATE_NORMAL
) and
5030 (FFlag
<> FLAG_NONE
) then
5032 if FFlag
= FLAG_RED
then
5033 s
:= _lc
[I_PLAYER_FLAG_RED
]
5035 s
:= _lc
[I_PLAYER_FLAG_BLUE
];
5037 evtype
:= FLAG_STATE_SCORED
;
5039 ts
:= Format('%.4d', [gFlags
[FFlag
].CaptureTime
]);
5040 Insert('.', ts
, Length(ts
) + 1 - 3);
5041 g_Console_Add(Format(_lc
[I_PLAYER_FLAG_CAPTURE
], [FName
, s
, ts
]), True);
5043 g_Map_ResetFlag(FFlag
);
5044 g_Game_Message(Format(_lc
[I_MESSAGE_FLAG_CAPTURE
], [AnsiUpperCase(s
)]), 144);
5046 gTeamStat
[FTeam
].Goals
:= gTeamStat
[FTeam
].Goals
+ 1;
5049 if g_Game_IsNet
then
5051 MH_SEND_FlagEvent(evtype
, FFlag
, FUID
, False);
5055 gFlags
[FFlag
].CaptureTime
:= 0;
5060 // Ïîäîáðàë ñâîé ôëàã - âåðíóë åãî íà áàçó:
5061 if (Flag
= FTeam
) and
5062 (gFlags
[Flag
].State
= FLAG_STATE_DROPPED
) then
5064 if Flag
= FLAG_RED
then
5065 s
:= _lc
[I_PLAYER_FLAG_RED
]
5067 s
:= _lc
[I_PLAYER_FLAG_BLUE
];
5069 evtype
:= FLAG_STATE_RETURNED
;
5070 gFlags
[Flag
].CaptureTime
:= 0;
5072 g_Console_Add(Format(_lc
[I_PLAYER_FLAG_RETURN
], [FName
, s
]), True);
5074 g_Map_ResetFlag(Flag
);
5075 g_Game_Message(Format(_lc
[I_MESSAGE_FLAG_RETURN
], [AnsiUpperCase(s
)]), 144);
5078 if g_Game_IsNet
then
5080 MH_SEND_FlagEvent(evtype
, Flag
, FUID
, False);
5086 // Ïîäîáðàë ÷óæîé ôëàã:
5087 if (Flag
<> FTeam
) and (FTime
[T_FLAGCAP
] <= gTime
) then
5091 if Flag
= FLAG_RED
then
5092 s
:= _lc
[I_PLAYER_FLAG_RED
]
5094 s
:= _lc
[I_PLAYER_FLAG_BLUE
];
5096 evtype
:= FLAG_STATE_CAPTURED
;
5098 g_Console_Add(Format(_lc
[I_PLAYER_FLAG_GET
], [FName
, s
]), True);
5100 g_Game_Message(Format(_lc
[I_MESSAGE_FLAG_GET
], [AnsiUpperCase(s
)]), 144);
5102 gFlags
[Flag
].State
:= FLAG_STATE_CAPTURED
;
5105 if g_Game_IsNet
then
5107 MH_SEND_FlagEvent(evtype
, Flag
, FUID
, False);
5113 procedure TPlayer
.SetFlag(Flag
: Byte);
5116 if FModel
<> nil then
5117 FModel
.SetFlag(FFlag
);
5120 function TPlayer
.DropFlag(): Boolean;
5125 if (not g_Game_IsServer
) or (FFlag
= FLAG_NONE
) then
5127 FTime
[T_FLAGCAP
] := gTime
+ 2000;
5128 with gFlags
[FFlag
] do
5132 Direction
:= FDirection
;
5133 State
:= FLAG_STATE_DROPPED
;
5135 g_Obj_Push(@Obj
, (FObj
.Vel
.X
div 2)-2+Random(5),
5136 (FObj
.Vel
.Y
div 2)-2+Random(5));
5138 if FFlag
= FLAG_RED
then
5139 s
:= _lc
[I_PLAYER_FLAG_RED
]
5141 s
:= _lc
[I_PLAYER_FLAG_BLUE
];
5143 g_Console_Add(Format(_lc
[I_PLAYER_FLAG_DROP
], [FName
, s
]), True);
5144 g_Game_Message(Format(_lc
[I_MESSAGE_FLAG_DROP
], [AnsiUpperCase(s
)]), 144);
5146 if g_Game_IsNet
then
5147 MH_SEND_FlagEvent(FLAG_STATE_DROPPED
, Flag
, FUID
, False);
5153 procedure TPlayer
.GetSecret();
5158 procedure TPlayer
.PressKey(Key
: Byte; Time
: Word = 1);
5160 Assert(Key
<= High(FKeys
));
5162 FKeys
[Key
].Pressed
:= True;
5163 FKeys
[Key
].Time
:= Time
;
5166 function TPlayer
.IsKeyPressed(K
: Byte): Boolean;
5168 Result
:= FKeys
[K
].Pressed
;
5171 procedure TPlayer
.ReleaseKeys();
5175 for a
:= Low(FKeys
) to High(FKeys
) do
5177 FKeys
[a
].Pressed
:= False;
5182 procedure TPlayer
.OnDamage(Angle
: SmallInt);
5186 function TPlayer
.firediry(): Integer;
5188 if FKeys
[KEY_UP
].Pressed
then Result
:= -42
5189 else if FKeys
[KEY_DOWN
].Pressed
then Result
:= 19
5193 procedure TPlayer
.RememberState();
5197 FSavedState
.Health
:= FHealth
;
5198 FSavedState
.Armor
:= FArmor
;
5199 FSavedState
.Air
:= FAir
;
5200 FSavedState
.JetFuel
:= FJetFuel
;
5201 FSavedState
.CurrWeap
:= FCurrWeap
;
5202 FSavedState
.NextWeap
:= FNextWeap
;
5205 FSavedState
.Ammo
[i
] := FAmmo
[i
];
5207 FSavedState
.MaxAmmo
[i
] := FMaxAmmo
[i
];
5209 FSavedState
.Rulez
:= FRulez
;
5210 FSavedState
.WaitRecall
:= True;
5213 procedure TPlayer
.RecallState();
5217 if not FSavedState
.WaitRecall
then Exit
;
5219 FHealth
:= FSavedState
.Health
;
5220 FArmor
:= FSavedState
.Armor
;
5221 FAir
:= FSavedState
.Air
;
5222 FJetFuel
:= FSavedState
.JetFuel
;
5223 FCurrWeap
:= FSavedState
.CurrWeap
;
5224 FNextWeap
:= FSavedState
.NextWeap
;
5227 FAmmo
[i
] := FSavedState
.Ammo
[i
];
5229 FMaxAmmo
[i
] := FSavedState
.MaxAmmo
[i
];
5231 FRulez
:= FSavedState
.Rulez
;
5232 FSavedState
.WaitRecall
:= False;
5234 if gGameSettings
.GameType
= GT_SERVER
then
5235 MH_SEND_PlayerStats(FUID
);
5238 procedure TPlayer
.SaveState(var Mem
: TBinMemoryWriter
);
5250 Mem
:= TBinMemoryWriter
.Create(i
);
5252 // Ñèãíàòóðà èãðîêà:
5253 sig
:= PLAYER_SIGNATURE
; // 'PLYR'
5254 Mem
.WriteDWORD(sig
);
5256 Mem
.WriteBoolean(FIamBot
);
5258 Mem
.WriteWord(FUID
);
5260 Mem
.WriteString(FName
, 32);
5262 Mem
.WriteByte(FTeam
);
5264 Mem
.WriteBoolean(FLive
);
5265 // Èçðàñõîäîâàë ëè âñå æèçíè:
5266 Mem
.WriteBoolean(FNoRespawn
);
5268 if FDirection
= D_LEFT
then
5274 Mem
.WriteInt(FHealth
);
5276 Mem
.WriteByte(FLives
);
5278 Mem
.WriteInt(FArmor
);
5282 Mem
.WriteInt(FJetFuel
);
5284 Mem
.WriteInt(FPain
);
5286 Mem
.WriteInt(FKills
);
5288 Mem
.WriteInt(FMonsterKills
);
5290 Mem
.WriteInt(FFrags
);
5292 Mem
.WriteByte(FFragCombo
);
5293 // Âðåìÿ ïîñëåäíåãî ôðàãà:
5294 Mem
.WriteDWORD(FLastFrag
);
5296 Mem
.WriteInt(FDeath
);
5297 // Êàêîé ôëàã íåñåò:
5298 Mem
.WriteByte(FFlag
);
5300 Mem
.WriteInt(FSecrets
);
5302 Mem
.WriteByte(FCurrWeap
);
5304 Mem
.WriteWord(FNextWeap
);
5305 // Âðåìÿ çàðÿäêè BFG:
5306 Mem
.WriteSmallInt(FBFGFireCounter
);
5308 Mem
.WriteInt(FDamageBuffer
);
5309 // Ïîñëåäíèé óäàðèâøèé:
5310 Mem
.WriteWord(FLastSpawnerUID
);
5311 // Òèï ïîñëåäíåãî ïîëó÷åííîãî óðîíà:
5312 Mem
.WriteByte(FLastHit
);
5314 Obj_SaveState(@FObj
, Mem
);
5315 // Òåêóùåå êîëè÷åñòâî ïàòðîíîâ:
5316 for i
:= A_BULLETS
to A_CELLS
do
5317 Mem
.WriteWord(FAmmo
[i
]);
5318 // Ìàêñèìàëüíîå êîëè÷åñòâî ïàòðîíîâ:
5319 for i
:= A_BULLETS
to A_CELLS
do
5320 Mem
.WriteWord(FMaxAmmo
[i
]);
5322 for i
:= WEAPON_KASTET
to WEAPON_SUPERPULEMET
do
5323 Mem
.WriteBoolean(FWeapon
[i
]);
5324 // Âðåìÿ ïåðåçàðÿäêè îðóæèÿ:
5325 for i
:= WEAPON_KASTET
to WEAPON_SUPERPULEMET
do
5326 Mem
.WriteWord(FReloading
[i
]);
5328 if R_ITEM_BACKPACK
in FRulez
then
5333 // Íàëè÷èå êðàñíîãî êëþ÷à:
5334 if R_KEY_RED
in FRulez
then
5339 // Íàëè÷èå çåëåíîãî êëþ÷à:
5340 if R_KEY_GREEN
in FRulez
then
5345 // Íàëè÷èå ñèíåãî êëþ÷à:
5346 if R_KEY_BLUE
in FRulez
then
5351 // Íàëè÷èå áåðñåðêà:
5352 if R_BERSERK
in FRulez
then
5357 // Âðåìÿ äåéñòâèÿ ñïåöèàëüíûõ ïðåäìåòîâ:
5358 for i
:= MR_SUIT
to MR_MAX
do
5359 Mem
.WriteDWORD(FMegaRulez
[i
]);
5360 // Âðåìÿ äî ïîâòîðíîãî ðåñïàóíà, ñìåíû îðóæèÿ, èñîëüçîâàíèÿ, çàõâàòà ôëàãà:
5361 for i
:= T_RESPAWN
to T_FLAGCAP
do
5362 Mem
.WriteDWORD(FTime
[i
]);
5365 Mem
.WriteString(str
);
5375 procedure TPlayer
.LoadState(var Mem
: TBinMemoryReader
);
5385 // Ñèãíàòóðà èãðîêà:
5387 if sig
<> PLAYER_SIGNATURE
then // 'PLYR'
5389 raise EBinSizeError
.Create('TPlayer.LoadState: Wrong Player Signature');
5392 Mem
.ReadBoolean(FIamBot
);
5396 Mem
.ReadString(str
);
5397 if (Self
<> gPlayer1
) and (Self
<> gPlayer2
) then
5400 Mem
.ReadByte(FTeam
);
5402 Mem
.ReadBoolean(FLive
);
5403 // Èçðàñõîäîâàë ëè âñå æèçíè:
5404 Mem
.ReadBoolean(FNoRespawn
);
5408 FDirection
:= D_LEFT
5410 FDirection
:= D_RIGHT
;
5412 Mem
.ReadInt(FHealth
);
5414 Mem
.ReadByte(FLives
);
5416 Mem
.ReadInt(FArmor
);
5420 Mem
.ReadInt(FJetFuel
);
5424 Mem
.ReadInt(FKills
);
5426 Mem
.ReadInt(FMonsterKills
);
5428 Mem
.ReadInt(FFrags
);
5430 Mem
.ReadByte(FFragCombo
);
5431 // Âðåìÿ ïîñëåäíåãî ôðàãà:
5432 Mem
.ReadDWORD(FLastFrag
);
5434 Mem
.ReadInt(FDeath
);
5435 // Êàêîé ôëàã íåñåò:
5436 Mem
.ReadByte(FFlag
);
5438 Mem
.ReadInt(FSecrets
);
5440 Mem
.ReadByte(FCurrWeap
);
5442 Mem
.ReadWord(FNextWeap
);
5443 // Âðåìÿ çàðÿäêè BFG:
5444 Mem
.ReadSmallInt(FBFGFireCounter
);
5446 Mem
.ReadInt(FDamageBuffer
);
5447 // Ïîñëåäíèé óäàðèâøèé:
5448 Mem
.ReadWord(FLastSpawnerUID
);
5449 // Òèï ïîñëåäíåãî ïîëó÷åííîãî óðîíà:
5450 Mem
.ReadByte(FLastHit
);
5452 Obj_LoadState(@FObj
, Mem
);
5453 // Òåêóùåå êîëè÷åñòâî ïàòðîíîâ:
5454 for i
:= A_BULLETS
to A_CELLS
do
5455 Mem
.ReadWord(FAmmo
[i
]);
5456 // Ìàêñèìàëüíîå êîëè÷åñòâî ïàòðîíîâ:
5457 for i
:= A_BULLETS
to A_CELLS
do
5458 Mem
.ReadWord(FMaxAmmo
[i
]);
5460 for i
:= WEAPON_KASTET
to WEAPON_SUPERPULEMET
do
5461 Mem
.ReadBoolean(FWeapon
[i
]);
5462 // Âðåìÿ ïåðåçàðÿäêè îðóæèÿ:
5463 for i
:= WEAPON_KASTET
to WEAPON_SUPERPULEMET
do
5464 Mem
.ReadWord(FReloading
[i
]);
5468 Include(FRulez
, R_ITEM_BACKPACK
);
5469 // Íàëè÷èå êðàñíîãî êëþ÷à:
5472 Include(FRulez
, R_KEY_RED
);
5473 // Íàëè÷èå çåëåíîãî êëþ÷à:
5476 Include(FRulez
, R_KEY_GREEN
);
5477 // Íàëè÷èå ñèíåãî êëþ÷à:
5480 Include(FRulez
, R_KEY_BLUE
);
5481 // Íàëè÷èå áåðñåðêà:
5484 Include(FRulez
, R_BERSERK
);
5485 // Âðåìÿ äåéñòâèÿ ñïåöèàëüíûõ ïðåäìåòîâ:
5486 for i
:= MR_SUIT
to MR_MAX
do
5487 Mem
.ReadDWORD(FMegaRulez
[i
]);
5488 // Âðåìÿ äî ïîâòîðíîãî ðåñïàóíà, ñìåíû îðóæèÿ, èñîëüçîâàíèÿ, çàõâàòà ôëàãà:
5489 for i
:= T_RESPAWN
to T_FLAGCAP
do
5490 Mem
.ReadDWORD(FTime
[i
]);
5492 Mem
.ReadString(str
);
5494 Mem
.ReadByte(FColor
.R
);
5495 Mem
.ReadByte(FColor
.G
);
5496 Mem
.ReadByte(FColor
.B
);
5497 if Self
= gPlayer1
then
5499 str
:= gPlayer1Settings
.Model
;
5500 FColor
:= gPlayer1Settings
.Color
;
5502 if Self
= gPlayer2
then
5504 str
:= gPlayer2Settings
.Model
;
5505 FColor
:= gPlayer2Settings
.Color
;
5507 // Îáíîâëÿåì ìîäåëü èãðîêà:
5509 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
5510 FModel
.Color
:= TEAMCOLOR
[FTeam
]
5512 FModel
.Color
:= FColor
;
5515 procedure TPlayer
.AllRulez(Health
: Boolean);
5521 FHealth
:= PLAYER_HP_LIMIT
;
5522 FArmor
:= PLAYER_AP_LIMIT
;
5526 for a
:= WEAPON_KASTET
to WEAPON_SUPERPULEMET
do FWeapon
[a
] := True;
5527 for a
:= A_BULLETS
to A_CELLS
do FAmmo
[a
] := 30000;
5528 FRulez
:= FRulez
+[R_KEY_RED
, R_KEY_GREEN
, R_KEY_BLUE
];
5531 procedure TPlayer
.RestoreHealthArmor();
5533 FHealth
:= PLAYER_HP_LIMIT
;
5534 FArmor
:= PLAYER_AP_LIMIT
;
5537 procedure TPlayer
.FragCombo();
5541 if (gGameSettings
.GameMode
in [GM_COOP
, GM_SINGLE
]) or g_Game_IsClient
then
5543 if gTime
- FLastFrag
< FRAG_COMBO_TIME
then
5545 if FFragCombo
< 5 then
5547 Param
:= FUID
or (FFragCombo
shl 16);
5548 if (FComboEvnt
>= Low(gDelayedEvents
)) and
5549 (FComboEvnt
<= High(gDelayedEvents
)) and
5550 gDelayedEvents
[FComboEvnt
].Pending
and
5551 (gDelayedEvents
[FComboEvnt
].DEType
= DE_KILLCOMBO
) and
5552 (gDelayedEvents
[FComboEvnt
].DENum
and $FFFF = FUID
) then
5554 gDelayedEvents
[FComboEvnt
].Time
:= gTime
+ 500;
5555 gDelayedEvents
[FComboEvnt
].DENum
:= Param
;
5558 FComboEvnt
:= g_Game_DelayEvent(DE_KILLCOMBO
, 500, Param
);
5566 procedure TPlayer
.GiveItem(ItemType
: Byte);
5570 if FMegaRulez
[MR_SUIT
] < gTime
+PLAYER_SUIT_TIME
then
5572 FMegaRulez
[MR_SUIT
] := gTime
+PLAYER_SUIT_TIME
;
5576 if FAir
< AIR_MAX
then
5583 if not (R_BERSERK
in FRulez
) then
5585 Include(FRulez
, R_BERSERK
);
5586 if FBFGFireCounter
< 1 then
5588 FCurrWeap
:= WEAPON_KASTET
;
5590 FModel
.SetWeapon(WEAPON_KASTET
);
5594 FBerserk
:= gTime
+30000;
5596 if FHealth
< PLAYER_HP_SOFT
then
5598 FHealth
:= PLAYER_HP_SOFT
;
5599 FBerserk
:= gTime
+30000;
5604 if FMegaRulez
[MR_INVUL
] < gTime
+PLAYER_INVUL_TIME
then
5606 FMegaRulez
[MR_INVUL
] := gTime
+PLAYER_INVUL_TIME
;
5610 if FMegaRulez
[MR_INVIS
] < gTime
+PLAYER_INVIS_TIME
then
5612 FMegaRulez
[MR_INVIS
] := gTime
+PLAYER_INVIS_TIME
;
5616 if FJetFuel
< JET_MAX
then
5618 FJetFuel
:= JET_MAX
;
5621 ITEM_WEAPON_SAW
: FWeapon
[WEAPON_SAW
] := True;
5622 ITEM_WEAPON_SHOTGUN1
: FWeapon
[WEAPON_SHOTGUN1
] := True;
5623 ITEM_WEAPON_SHOTGUN2
: FWeapon
[WEAPON_SHOTGUN2
] := True;
5624 ITEM_WEAPON_CHAINGUN
: FWeapon
[WEAPON_CHAINGUN
] := True;
5625 ITEM_WEAPON_ROCKETLAUNCHER
: FWeapon
[WEAPON_ROCKETLAUNCHER
] := True;
5626 ITEM_WEAPON_PLASMA
: FWeapon
[WEAPON_PLASMA
] := True;
5627 ITEM_WEAPON_BFG
: FWeapon
[WEAPON_BFG
] := True;
5628 ITEM_WEAPON_SUPERPULEMET
: FWeapon
[WEAPON_SUPERPULEMET
] := True;
5630 ITEM_AMMO_BULLETS
: if FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
] then IncMax(FAmmo
[A_BULLETS
], 10, FMaxAmmo
[A_BULLETS
]);
5631 ITEM_AMMO_BULLETS_BOX
: if FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
] then IncMax(FAmmo
[A_BULLETS
], 50, FMaxAmmo
[A_BULLETS
]);
5632 ITEM_AMMO_SHELLS
: if FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
] then IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
5633 ITEM_AMMO_SHELLS_BOX
: if FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
] then IncMax(FAmmo
[A_SHELLS
], 25, FMaxAmmo
[A_SHELLS
]);
5634 ITEM_AMMO_ROCKET
: if FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
] then IncMax(FAmmo
[A_ROCKETS
], 1, FMaxAmmo
[A_ROCKETS
]);
5635 ITEM_AMMO_ROCKET_BOX
: if FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
] then IncMax(FAmmo
[A_ROCKETS
], 5, FMaxAmmo
[A_ROCKETS
]);
5636 ITEM_AMMO_CELL
: if FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
] then IncMax(FAmmo
[A_CELLS
], 40, FMaxAmmo
[A_CELLS
]);
5637 ITEM_AMMO_CELL_BIG
: if FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
] then IncMax(FAmmo
[A_CELLS
], 100, FMaxAmmo
[A_CELLS
]);
5640 if (FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
]) or
5641 (FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
]) or
5642 (FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
]) or
5643 (FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
]) then
5645 FMaxAmmo
[A_BULLETS
] := 400;
5646 FMaxAmmo
[A_SHELLS
] := 100;
5647 FMaxAmmo
[A_ROCKETS
] := 100;
5648 FMaxAmmo
[A_CELLS
] := 600;
5650 if FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
] then IncMax(FAmmo
[A_BULLETS
], 10, FMaxAmmo
[A_BULLETS
]);
5651 if FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
] then IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
5652 if FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
] then IncMax(FAmmo
[A_ROCKETS
], 1, FMaxAmmo
[A_ROCKETS
]);
5653 if FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
] then IncMax(FAmmo
[A_CELLS
], 40, FMaxAmmo
[A_CELLS
]);
5655 FRulez
:= FRulez
+ [R_ITEM_BACKPACK
];
5658 ITEM_KEY_RED
: if not (R_KEY_RED
in FRulez
) then Include(FRulez
, R_KEY_RED
);
5659 ITEM_KEY_GREEN
: if not (R_KEY_GREEN
in FRulez
) then Include(FRulez
, R_KEY_GREEN
);
5660 ITEM_KEY_BLUE
: if not (R_KEY_BLUE
in FRulez
) then Include(FRulez
, R_KEY_BLUE
);
5662 ITEM_BOTTLE
: if FHealth
< PLAYER_HP_LIMIT
then IncMax(FHealth
, 4, PLAYER_HP_LIMIT
);
5663 ITEM_HELMET
: if FArmor
< PLAYER_AP_LIMIT
then IncMax(FArmor
, 5, PLAYER_AP_LIMIT
);
5668 if g_Game_IsNet
and g_Game_IsServer
then
5669 MH_SEND_PlayerStats(FUID
);
5672 procedure TPlayer
.FlySmoke(Times
: DWORD
= 1);
5677 if (Random(5) = 1) and (Times
= 1) then
5680 if BodyInLiquid(0, 0) then
5682 g_GFX_Bubbles(Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2)+Random(3)-1,
5683 Obj
.Y
+Obj
.Rect
.Height
+8, 1, 8, 4);
5684 if Random(2) = 0 then
5685 g_Sound_PlayExAt('SOUND_GAME_BUBBLE1', FObj
.X
, FObj
.Y
)
5687 g_Sound_PlayExAt('SOUND_GAME_BUBBLE2', FObj
.X
, FObj
.Y
);
5691 if g_Frames_Get(id
, 'FRAMES_SMOKE') then
5693 for i
:= 1 to Times
do
5695 Anim
:= TAnimation
.Create(id
, False, 3);
5697 g_GFX_OnceAnim(Obj
.X
+Obj
.Rect
.X
+Random(Obj
.Rect
.Width
+Times
*2)-(Anim
.Width
div 2),
5698 Obj
.Y
+Obj
.Rect
.Height
-4+Random(8+Times
*2), Anim
, ONCEANIM_SMOKE
);
5704 procedure TPlayer
.PauseSounds(Enable
: Boolean);
5706 FSawSound
.Pause(Enable
);
5707 FSawSoundIdle
.Pause(Enable
);
5708 FSawSoundHit
.Pause(Enable
);
5709 FSawSoundSelect
.Pause(Enable
);
5714 constructor TCorpse
.Create(X
, Y
: Integer; ModelName
: String; aMess
: Boolean);
5719 FObj
.Rect
:= PLAYER_CORPSERECT
;
5720 FModelName
:= ModelName
;
5725 FState
:= CORPSE_STATE_MESS
;
5726 g_PlayerModel_GetAnim(ModelName
, A_DIE2
, FAnimation
, FAnimationMask
);
5730 FState
:= CORPSE_STATE_NORMAL
;
5731 g_PlayerModel_GetAnim(ModelName
, A_DIE1
, FAnimation
, FAnimationMask
);
5735 destructor TCorpse
.Destroy();
5742 procedure TCorpse
.Damage(Value
: Word; vx
, vy
: Integer);
5746 if FState
= CORPSE_STATE_REMOVEME
then
5749 FDamage
:= FDamage
+ Value
;
5751 if FDamage
> 150 then
5753 if FAnimation
<> nil then
5758 FState
:= CORPSE_STATE_REMOVEME
;
5760 g_Player_CreateGibs(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
5761 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2),
5762 FModelName
, FColor
);
5763 // Çâóê ìÿñà îò òðóïà:
5764 pm
:= g_PlayerModel_Get(FModelName
);
5765 pm
.PlaySound(MODELSOUND_DIE
, 5, FObj
.X
, FObj
.Y
);
5771 FObj
.Vel
.X
:= FObj
.Vel
.X
+ vx
;
5772 FObj
.Vel
.Y
:= FObj
.Vel
.Y
+ vy
;
5773 g_GFX_Blood(FObj
.X
+PLAYER_CORPSERECT
.X
+(PLAYER_CORPSERECT
.Width
div 2),
5774 FObj
.Y
+PLAYER_CORPSERECT
.Y
+(PLAYER_CORPSERECT
.Height
div 2),
5775 Value
, vx
, vy
, 16, (PLAYER_CORPSERECT
.Height
*2) div 3,
5780 procedure TCorpse
.Draw();
5782 if FState
= CORPSE_STATE_REMOVEME
then
5785 if FAnimation
<> nil then
5786 FAnimation
.Draw(FObj
.X
, FObj
.Y
, M_NONE
);
5788 if FAnimationMask
<> nil then
5791 FAnimationMask
.Draw(FObj
.X
, FObj
.Y
, M_NONE
);
5798 procedure TCorpse
.Update();
5802 if FState
= CORPSE_STATE_REMOVEME
then
5805 if gTime
mod (GAME_TICK
*2) <> 0 then
5807 g_Obj_Move(@FObj
, True, True, True);
5812 // Ñîïðîòèâëåíèå âîçäóõà äëÿ òðóïà:
5813 FObj
.Vel
.X
:= z_dec(FObj
.Vel
.X
, 1);
5815 st
:= g_Obj_Move(@FObj
, True, True, True);
5817 if WordBool(st
and MOVE_FALLOUT
) then
5819 FState
:= CORPSE_STATE_REMOVEME
;
5823 if FAnimation
<> nil then
5824 FAnimation
.Update();
5825 if FAnimationMask
<> nil then
5826 FAnimationMask
.Update();
5829 procedure TCorpse
.SaveState(var Mem
: TBinMemoryWriter
);
5838 sig
:= CORPSE_SIGNATURE
; // 'CORP'
5839 Mem
.WriteDWORD(sig
);
5841 Mem
.WriteByte(FState
);
5842 // Íàêîïëåííûé óðîí:
5843 Mem
.WriteByte(FDamage
);
5845 Mem
.WriteByte(FColor
.R
);
5846 Mem
.WriteByte(FColor
.G
);
5847 Mem
.WriteByte(FColor
.B
);
5849 Obj_SaveState(@FObj
, Mem
);
5850 // Åñòü ëè àíèìàöèÿ:
5851 anim
:= FAnimation
<> nil;
5852 Mem
.WriteBoolean(anim
);
5853 // Åñëè åñòü - ñîõðàíÿåì:
5855 FAnimation
.SaveState(Mem
);
5856 // Åñòü ëè ìàñêà àíèìàöèè:
5857 anim
:= FAnimationMask
<> nil;
5858 Mem
.WriteBoolean(anim
);
5859 // Åñëè åñòü - ñîõðàíÿåì:
5861 FAnimationMask
.SaveState(Mem
);
5864 procedure TCorpse
.LoadState(var Mem
: TBinMemoryReader
);
5874 if sig
<> CORPSE_SIGNATURE
then // 'CORP'
5876 raise EBinSizeError
.Create('TCorpse.LoadState: Wrong Corpse Signature');
5879 Mem
.ReadByte(FState
);
5880 // Íàêîïëåííûé óðîí:
5881 Mem
.ReadByte(FDamage
);
5883 Mem
.ReadByte(FColor
.R
);
5884 Mem
.ReadByte(FColor
.G
);
5885 Mem
.ReadByte(FColor
.B
);
5887 Obj_LoadState(@FObj
, Mem
);
5888 // Åñòü ëè àíèìàöèÿ:
5889 Mem
.ReadBoolean(anim
);
5890 // Åñëè åñòü - çàãðóæàåì:
5893 Assert(FAnimation
<> nil, 'TCorpse.LoadState: no FAnimation');
5894 FAnimation
.LoadState(Mem
);
5896 // Åñòü ëè ìàñêà àíèìàöèè:
5897 Mem
.ReadBoolean(anim
);
5898 // Åñëè åñòü - çàãðóæàåì:
5901 Assert(FAnimationMask
<> nil, 'TCorpse.LoadState: no FAnimationMask');
5902 FAnimationMask
.LoadState(Mem
);
5908 constructor TBot
.Create();
5915 FSpectator
:= False;
5922 for a
:= WEAPON_KASTET
to WEAPON_SUPERPULEMET
do
5924 FDifficult
.WeaponPrior
[a
] := WEAPON_PRIOR1
[a
];
5925 FDifficult
.CloseWeaponPrior
[a
] := WEAPON_PRIOR2
[a
];
5926 //FDifficult.SafeWeaponPrior[a] := WEAPON_PRIOR3[a];
5930 destructor TBot
.Destroy();
5933 inherited Destroy();
5936 procedure TBot
.Draw();
5940 //if FTargetUID <> 0 then e_DrawLine(1, FObj.X, FObj.Y, g_Player_Get(FTargetUID).FObj.X,
5941 // g_Player_Get(FTargetUID).FObj.Y, 255, 0, 0);
5944 procedure TBot
.Respawn(Silent
: Boolean; Force
: Boolean = False);
5946 inherited Respawn(Silent
, Force
);
5949 FSelectedWeapon
:= FCurrWeap
;
5954 procedure TBot
.UpdateCombat();
5967 TTargetRecord
= array of TTarget
;
5969 function Compare(a
, b
: TTarget
): Integer;
5971 if a
.Line
and not b
.Line
then // A íà ëèíèè îãíÿ
5974 if not a
.Line
and b
.Line
then // B íà ëèíèè îãíÿ
5976 else // È A, è B íà ëèíèè èëè íå íà ëèíèè îãíÿ
5977 if (a
.Line
and b
.Line
) or ((not a
.Line
) and (not b
.Line
)) then
5979 if a
.Dist
> b
.Dist
then // B áëèæå
5981 else // A áëèæå èëè ðàâíîóäàëåííî ñ B
5984 else // Ñòðàííî -> A
5989 a
, x1
, y1
, x2
, y2
: Integer;
5990 targets
: TTargetRecord
;
5992 Target
, BestTarget
: TTarget
;
5993 firew
, fireh
: Integer;
5997 vsPlayer
, vsMonster
, ok
: Boolean;
5999 vsPlayer
:= LongBool(gGameSettings
.Options
and GAME_OPTION_BOTVSPLAYER
);
6000 vsMonster
:= LongBool(gGameSettings
.Options
and GAME_OPTION_BOTVSMONSTER
);
6002 // Åñëè òåêóùåå îðóæèå íå òî, ÷òî íóæíî, òî ìåíÿåì:
6003 if FCurrWeap
<> FSelectedWeapon
then
6006 // Åñëè íóæíî ñòðåëÿòü è íóæíîå îðóæèå, òî íàæàòü "Ñòðåëÿòü":
6007 if (GetAIFlag('NEEDFIRE') <> '') and (FCurrWeap
= FSelectedWeapon
) then
6009 RemoveAIFlag('NEEDFIRE');
6012 WEAPON_PLASMA
, WEAPON_SUPERPULEMET
, WEAPON_CHAINGUN
: PressKey(KEY_FIRE
, 20);
6013 WEAPON_SAW
, WEAPON_KASTET
, WEAPON_MEGAKASTET
: PressKey(KEY_FIRE
, 40);
6014 else PressKey(KEY_FIRE
);
6018 // Êîîðäèíàòû ñòâîëà:
6019 x1
:= FObj
.X
+ WEAPONPOINT
[FDirection
].X
;
6020 y1
:= FObj
.Y
+ WEAPONPOINT
[FDirection
].Y
;
6022 Target
.UID
:= FTargetUID
;
6025 if Target
.UID
<> 0 then
6026 begin // Öåëü åñòü - íàñòðàèâàåì
6027 if (g_GetUIDType(Target
.UID
) = UID_PLAYER
) and
6030 with g_Player_Get(Target
.UID
) do
6032 if (@FObj
) <> nil then
6039 Target
.cX
:= Target
.X
+ PLAYER_RECT_CX
;
6040 Target
.cY
:= Target
.Y
+ PLAYER_RECT_CY
;
6041 Target
.Rect
:= PLAYER_RECT
;
6042 Target
.Visible
:= g_TraceVector(x1
, y1
, Target
.cX
, Target
.cY
);
6043 Target
.Line
:= (y1
+4 < Target
.Y
+PLAYER_RECT
.Y
+PLAYER_RECT
.Height
) and
6044 (y1
-4 > Target
.Y
+PLAYER_RECT
.Y
);
6045 Target
.IsPlayer
:= True;
6049 if (g_GetUIDType(Target
.UID
) = UID_MONSTER
) and
6052 mon
:= g_Monsters_Get(Target
.UID
);
6055 Target
.X
:= mon
.Obj
.X
;
6056 Target
.Y
:= mon
.Obj
.Y
;
6058 Target
.cX
:= Target
.X
+ mon
.Obj
.Rect
.X
+ (mon
.Obj
.Rect
.Width
div 2);
6059 Target
.cY
:= Target
.Y
+ mon
.Obj
.Rect
.Y
+ (mon
.Obj
.Rect
.Height
div 2);
6060 Target
.Rect
:= mon
.Obj
.Rect
;
6061 Target
.Visible
:= g_TraceVector(x1
, y1
, Target
.cX
, Target
.cY
);
6062 Target
.Line
:= (y1
+4 < Target
.Y
+ mon
.Obj
.Rect
.Y
+ mon
.Obj
.Rect
.Height
) and
6063 (y1
-4 > Target
.Y
+ mon
.Obj
.Rect
.Y
);
6064 Target
.IsPlayer
:= False;
6071 begin // Öåëè íåò - îáíóëÿåì
6076 Target
.Visible
:= False;
6077 Target
.Line
:= False;
6078 Target
.IsPlayer
:= False;
6083 // Åñëè öåëü íå âèäèìà èëè íå íà ëèíèè îãíÿ, òî èùåì âñå âîçìîæíûå öåëè:
6084 if (not Target
.Line
) or (not Target
.Visible
) then
6088 for a
:= 0 to High(gPlayers
) do
6089 if (gPlayers
[a
] <> nil) and (gPlayers
[a
].Live
) and
6090 (gPlayers
[a
].FUID
<> FUID
) and
6091 (not SameTeam(FUID
, gPlayers
[a
].FUID
)) and
6092 (not gPlayers
[a
].NoTarget
) and
6093 (gPlayers
[a
].FMegaRulez
[MR_INVIS
] < gTime
) then
6095 if not TargetOnScreen(gPlayers
[a
].FObj
.X
+ PLAYER_RECT
.X
,
6096 gPlayers
[a
].FObj
.Y
+ PLAYER_RECT
.Y
) then
6099 x2
:= gPlayers
[a
].FObj
.X
+ PLAYER_RECT_CX
;
6100 y2
:= gPlayers
[a
].FObj
.Y
+ PLAYER_RECT_CY
;
6102 // Åñëè èãðîê íà ýêðàíå è íå ïðèêðûò ñòåíîé:
6103 if g_TraceVector(x1
, y1
, x2
, y2
) then
6105 // Äîáàâëÿåì ê ñïèñêó âîçìîæíûõ öåëåé:
6106 SetLength(targets
, Length(targets
)+1);
6107 with targets
[High(targets
)] do
6109 UID
:= gPlayers
[a
].FUID
;
6110 X
:= gPlayers
[a
].FObj
.X
;
6111 Y
:= gPlayers
[a
].FObj
.Y
;
6114 Rect
:= PLAYER_RECT
;
6115 Dist
:= g_PatchLength(x1
, y1
, x2
, y2
);
6116 Line
:= (y1
+4 < Target
.Y
+PLAYER_RECT
.Y
+PLAYER_RECT
.Height
) and
6117 (y1
-4 > Target
.Y
+PLAYER_RECT
.Y
);
6125 if vsMonster
and (gMonsters
<> nil) then
6126 for a
:= 0 to High(gMonsters
) do
6127 if (gMonsters
[a
] <> nil) and (gMonsters
[a
].Live
) and
6128 (gMonsters
[a
].MonsterType
<> MONSTER_BARREL
) then
6130 mon
:= gMonsters
[a
];
6132 if not TargetOnScreen(mon
.Obj
.X
+ mon
.Obj
.Rect
.X
,
6133 mon
.Obj
.Y
+ mon
.Obj
.Rect
.Y
) then
6136 x2
:= mon
.Obj
.X
+ mon
.Obj
.Rect
.X
+ (mon
.Obj
.Rect
.Width
div 2);
6137 y2
:= mon
.Obj
.Y
+ mon
.Obj
.Rect
.Y
+ (mon
.Obj
.Rect
.Height
div 2);
6139 // Åñëè ìîíñòð íà ýêðàíå è íå ïðèêðûò ñòåíîé:
6140 if g_TraceVector(x1
, y1
, x2
, y2
) then
6142 // Äîáàâëÿåì ê ñïèñêó âîçìîæíûõ öåëåé:
6143 SetLength(targets
, Length(targets
)+1);
6144 with targets
[High(targets
)] do
6151 Rect
:= mon
.Obj
.Rect
;
6152 Dist
:= g_PatchLength(x1
, y1
, x2
, y2
);
6153 Line
:= (y1
+4 < Target
.Y
+ mon
.Obj
.Rect
.Y
+ mon
.Obj
.Rect
.Height
) and
6154 (y1
-4 > Target
.Y
+ mon
.Obj
.Rect
.Y
);
6162 // Åñëè åñòü âîçìîæíûå öåëè:
6163 // (Âûáèðàåì ëó÷øóþ, ìåíÿåì îðóæèå è áåæèì ê íåé/îò íåå)
6164 if targets
<> nil then
6166 // Âûáèðàåì íàèëó÷øóþ öåëü:
6167 BestTarget
:= targets
[0];
6168 if Length(targets
) > 1 then
6169 for a
:= 1 to High(targets
) do
6170 if Compare(BestTarget
, targets
[a
]) = 1 then
6171 BestTarget
:= targets
[a
];
6173 // Åñëè ëó÷øàÿ öåëü "âèäíåå" òåêóùåé, òî òåêóùàÿ := ëó÷øàÿ:
6174 if ((not Target
.Visible
) and BestTarget
.Visible
and (Target
.UID
<> BestTarget
.UID
)) or
6175 ((not Target
.Line
) and BestTarget
.Line
and BestTarget
.Visible
) then
6177 Target
:= BestTarget
;
6179 if (Healthy() = 3) or ((Healthy() = 2)) then
6180 begin // Åñëè çäîðîâû - äîãîíÿåì
6181 if ((RunDirection() = D_LEFT
) and (Target
.X
> FObj
.X
)) then
6182 SetAIFlag('GORIGHT', '1');
6183 if ((RunDirection() = D_RIGHT
) and (Target
.X
< FObj
.X
)) then
6184 SetAIFlag('GOLEFT', '1');
6187 begin // Åñëè ïîáèòû - óáåãàåì
6188 if ((RunDirection() = D_LEFT
) and (Target
.X
< FObj
.X
)) then
6189 SetAIFlag('GORIGHT', '1');
6190 if ((RunDirection() = D_RIGHT
) and (Target
.X
> FObj
.X
)) then
6191 SetAIFlag('GOLEFT', '1');
6194 // Âûáèðàåì îðóæèå íà îñíîâå ðàññòîÿíèÿ è ïðèîðèòåòîâ:
6195 SelectWeapon(Abs(x1
-Target
.cX
));
6200 // (Äîãîíÿåì/óáåãàåì, ñòðåëÿåì ïî íàïðàâëåíèþ ê öåëè)
6201 // (Åñëè öåëü äàëåêî, òî õâàòèò ñëåäèòü çà íåé)
6202 if Target
.UID
<> 0 then
6204 if not TargetOnScreen(Target
.X
+ Target
.Rect
.X
,
6205 Target
.Y
+ Target
.Rect
.Y
) then
6206 begin // Öåëü ñáåæàëà ñ "ýêðàíà"
6207 if (Healthy() = 3) or ((Healthy() = 2)) then
6208 begin // Åñëè çäîðîâû - äîãîíÿåì
6209 if ((RunDirection() = D_LEFT
) and (Target
.X
> FObj
.X
)) then
6210 SetAIFlag('GORIGHT', '1');
6211 if ((RunDirection() = D_RIGHT
) and (Target
.X
< FObj
.X
)) then
6212 SetAIFlag('GOLEFT', '1');
6215 begin // Åñëè ïîáèòû - çàáûâàåì î öåëè è óáåãàåì
6217 if ((RunDirection() = D_LEFT
) and (Target
.X
< FObj
.X
)) then
6218 SetAIFlag('GORIGHT', '1');
6219 if ((RunDirection() = D_RIGHT
) and (Target
.X
> FObj
.X
)) then
6220 SetAIFlag('GOLEFT', '1');
6224 begin // Öåëü ïîêà íà "ýêðàíå"
6225 // Åñëè öåëü íå çàãîðîæåíà ñòåíîé, òî îòìå÷àåì, êîãäà åå âèäåëè:
6226 if g_TraceVector(x1
, y1
, Target
.cX
, Target
.cY
) then
6227 FLastVisible
:= gTime
;
6228 // Åñëè ðàçíèöà âûñîò íå âåëèêà, òî äîãîíÿåì:
6229 if (Abs(FObj
.Y
-Target
.Y
) <= 128) then
6231 if ((RunDirection() = D_LEFT
) and (Target
.X
> FObj
.X
)) then
6232 SetAIFlag('GORIGHT', '1');
6233 if ((RunDirection() = D_RIGHT
) and (Target
.X
< FObj
.X
)) then
6234 SetAIFlag('GOLEFT', '1');
6238 // Âûáèðàåì óãîë ââåðõ:
6239 if FDirection
= D_LEFT
then
6240 angle
:= ANGLE_LEFTUP
6242 angle
:= ANGLE_RIGHTUP
;
6244 firew
:= Trunc(Cos(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
6245 fireh
:= Trunc(Sin(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
6247 // Åñëè ïðè óãëå ââåðõ ìîæíî ïîïàñòü â ïðèáëèçèòåëüíîå ïîëîæåíèå öåëè:
6248 if g_CollideLine(x1
, y1
, x1
+firew
, y1
+fireh
,
6249 Target
.X
+Target
.Rect
.X
+GetInterval(FDifficult
.DiagPrecision
, 128), //96
6250 Target
.Y
+Target
.Rect
.Y
+GetInterval(FDifficult
.DiagPrecision
, 128),
6251 Target
.Rect
.Width
, Target
.Rect
.Height
) and
6252 g_TraceVector(x1
, y1
, Target
.cX
, Target
.cY
) then
6253 begin // òî íóæíî ñòðåëÿòü ââåðõ
6254 SetAIFlag('NEEDFIRE', '1');
6255 SetAIFlag('NEEDSEEUP', '1');
6258 // Âûáèðàåì óãîë âíèç:
6259 if FDirection
= D_LEFT
then
6260 angle
:= ANGLE_LEFTDOWN
6262 angle
:= ANGLE_RIGHTDOWN
;
6264 firew
:= Trunc(Cos(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
6265 fireh
:= Trunc(Sin(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
6267 // Åñëè ïðè óãëå âíèç ìîæíî ïîïàñòü â ïðèáëèçèòåëüíîå ïîëîæåíèå öåëè:
6268 if g_CollideLine(x1
, y1
, x1
+firew
, y1
+fireh
,
6269 Target
.X
+Target
.Rect
.X
+GetInterval(FDifficult
.DiagPrecision
, 128),
6270 Target
.Y
+Target
.Rect
.Y
+GetInterval(FDifficult
.DiagPrecision
, 128),
6271 Target
.Rect
.Width
, Target
.Rect
.Height
) and
6272 g_TraceVector(x1
, y1
, Target
.cX
, Target
.cY
) then
6273 begin // òî íóæíî ñòðåëÿòü âíèç
6274 SetAIFlag('NEEDFIRE', '1');
6275 SetAIFlag('NEEDSEEDOWN', '1');
6278 // Åñëè öåëü âèäíî è îíà íà òàêîé æå âûñîòå:
6279 if Target
.Visible
and
6280 (y1
+4 < Target
.Y
+Target
.Rect
.Y
+Target
.Rect
.Height
) and
6281 (y1
-4 > Target
.Y
+Target
.Rect
.Y
) then
6283 // Åñëè èäåì â ñòîðîíó öåëè, òî íàäî ñòðåëÿòü:
6284 if ((FDirection
= D_LEFT
) and (Target
.X
< FObj
.X
)) or
6285 ((FDirection
= D_RIGHT
) and (Target
.X
> FObj
.X
)) then
6286 begin // òî íóæíî ñòðåëÿòü âïåðåä
6287 SetAIFlag('NEEDFIRE', '1');
6288 SetAIFlag('NEEDSEEDOWN', '');
6289 SetAIFlag('NEEDSEEUP', '');
6291 // Åñëè öåëü â ïðåäåëàõ "ýêðàíà" è ñëîæíîñòü ïîçâîëÿåò ïðûæêè ñáëèæåíèÿ:
6292 if Abs(FObj
.X
-Target
.X
) < Trunc(gPlayerScreenSize
.X
*0.75) then
6293 if GetRnd(FDifficult
.CloseJump
) then
6294 begin // òî åñëè ïîâåçåò - ïðûãàåì (îñîáåííî, åñëè áëèçêî)
6295 if Abs(FObj
.X
-Target
.X
) < 128 then
6299 if Random(a
) = 0 then
6300 SetAIFlag('NEEDJUMP', '1');
6304 // Åñëè öåëü âñå åùå åñòü:
6305 if Target
.UID
<> 0 then
6306 if gTime
-FLastVisible
> 2000 then // Åñëè âèäåëè äàâíî
6307 Target
.UID
:= 0 // òî çàáûòü öåëü
6308 else // Åñëè âèäåëè íåäàâíî
6309 begin // íî öåëü óáèëè
6310 if Target
.IsPlayer
then
6311 begin // Öåëü - èãðîê
6312 pla
:= g_Player_Get(Target
.UID
);
6313 if (pla
= nil) or (not pla
.Live
) or pla
.NoTarget
or
6314 (pla
.FMegaRulez
[MR_INVIS
] >= gTime
) then
6315 Target
.UID
:= 0; // òî çàáûòü öåëü
6318 begin // Öåëü - ìîíñòð
6319 mon
:= g_Monsters_Get(Target
.UID
);
6320 if (mon
= nil) or (not mon
.Live
) then
6321 Target
.UID
:= 0; // òî çàáûòü öåëü
6324 end; // if Target.UID <> 0
6326 FTargetUID
:= Target
.UID
;
6328 // Åñëè âîçìîæíûõ öåëåé íåò:
6329 // (Àòàêà ÷åãî-íèáóäü ñëåâà èëè ñïðàâà)
6330 if targets
= nil then
6331 if GetAIFlag('ATTACKLEFT') <> '' then
6332 begin // Åñëè íóæíî àòàêîâàòü íàëåâî
6333 RemoveAIFlag('ATTACKLEFT');
6335 SetAIFlag('NEEDJUMP', '1');
6337 if RunDirection() = D_RIGHT
then
6338 begin // Èäåì íå â òó ñòîðîíó
6339 if (Healthy() > 1) and GetRnd(FDifficult
.InvisFire
) then
6340 begin // Åñëè çäîðîâû, òî, âîçìîæíî, ñòðåëÿåì áåæèì âëåâî è ñòðåëÿåì
6341 SetAIFlag('NEEDFIRE', '1');
6342 SetAIFlag('GOLEFT', '1');
6346 begin // Èäåì â íóæíóþ ñòîðîíó
6347 if GetRnd(FDifficult
.InvisFire
) then // Âîçìîæíî, ñòðåëÿåì âñëåïóþ
6348 SetAIFlag('NEEDFIRE', '1');
6349 if Healthy() <= 1 then // Ïîáèòû - óáåãàåì
6350 SetAIFlag('GORIGHT', '1');
6354 if GetAIFlag('ATTACKRIGHT') <> '' then
6355 begin // Åñëè íóæíî àòàêîâàòü íàïðàâî
6356 RemoveAIFlag('ATTACKRIGHT');
6358 SetAIFlag('NEEDJUMP', '1');
6360 if RunDirection() = D_LEFT
then
6361 begin // Èäåì íå â òó ñòîðîíó
6362 if (Healthy() > 1) and GetRnd(FDifficult
.InvisFire
) then
6363 begin // Åñëè çäîðîâû, òî, âîçìîæíî, áåæèì âïðàâî è ñòðåëÿåì
6364 SetAIFlag('NEEDFIRE', '1');
6365 SetAIFlag('GORIGHT', '1');
6370 if GetRnd(FDifficult
.InvisFire
) then // Âîçìîæíî, ñòðåëÿåì âñëåïóþ
6371 SetAIFlag('NEEDFIRE', '1');
6372 if Healthy() <= 1 then // Ïîáèòû - óáåãàåì
6373 SetAIFlag('GOLEFT', '1');
6377 //HACK! (does it belongs there?)
6378 RealizeCurrentWeapon();
6380 // Åñëè åñòü âîçìîæíûå öåëè:
6381 // (Ñòðåëÿåì ïî íàïðàâëåíèþ ê öåëÿì)
6382 if (targets
<> nil) and (GetAIFlag('NEEDFIRE') <> '') then
6383 for a
:= 0 to High(targets
) do
6385 // Åñëè ìîæåì ñòðåëÿòü ïî äèàãîíàëè:
6386 if GetRnd(FDifficult
.DiagFire
) then
6388 // Èùåì öåëü ñâåðõó è ñòðåëÿåì, åñëè åñòü:
6389 if FDirection
= D_LEFT
then
6390 angle
:= ANGLE_LEFTUP
6392 angle
:= ANGLE_RIGHTUP
;
6394 firew
:= Trunc(Cos(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
6395 fireh
:= Trunc(Sin(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
6397 if g_CollideLine(x1
, y1
, x1
+firew
, y1
+fireh
,
6398 targets
[a
].X
+targets
[a
].Rect
.X
+GetInterval(FDifficult
.DiagPrecision
, 128),
6399 targets
[a
].Y
+targets
[a
].Rect
.Y
+GetInterval(FDifficult
.DiagPrecision
, 128),
6400 targets
[a
].Rect
.Width
, targets
[a
].Rect
.Height
) and
6401 g_TraceVector(x1
, y1
, targets
[a
].cX
, targets
[a
].cY
) then
6403 SetAIFlag('NEEDFIRE', '1');
6404 SetAIFlag('NEEDSEEUP', '1');
6407 // Èùåì öåëü ñíèçó è ñòðåëÿåì, åñëè åñòü:
6408 if FDirection
= D_LEFT
then
6409 angle
:= ANGLE_LEFTDOWN
6411 angle
:= ANGLE_RIGHTDOWN
;
6413 firew
:= Trunc(Cos(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
6414 fireh
:= Trunc(Sin(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
6416 if g_CollideLine(x1
, y1
, x1
+firew
, y1
+fireh
,
6417 targets
[a
].X
+targets
[a
].Rect
.X
+GetInterval(FDifficult
.DiagPrecision
, 128),
6418 targets
[a
].Y
+targets
[a
].Rect
.Y
+GetInterval(FDifficult
.DiagPrecision
, 128),
6419 targets
[a
].Rect
.Width
, targets
[a
].Rect
.Height
) and
6420 g_TraceVector(x1
, y1
, targets
[a
].cX
, targets
[a
].cY
) then
6422 SetAIFlag('NEEDFIRE', '1');
6423 SetAIFlag('NEEDSEEDOWN', '1');
6427 // Åñëè öåëü "ïåðåä íîñîì", òî ñòðåëÿåì:
6428 if targets
[a
].Line
and targets
[a
].Visible
and
6429 (((FDirection
= D_LEFT
) and (targets
[a
].X
< FObj
.X
)) or
6430 ((FDirection
= D_RIGHT
) and (targets
[a
].X
> FObj
.X
))) then
6432 SetAIFlag('NEEDFIRE', '1');
6437 // Åñëè ëåòèò ïóëÿ, òî, âîçìîæíî, ïîäïðûãèâàåì:
6438 if g_Weapon_Danger(FUID
, FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+PLAYER_RECT
.Y
,
6439 PLAYER_RECT
.Width
, PLAYER_RECT
.Height
,
6440 40+GetInterval(FDifficult
.Cover
, 40)) then
6441 SetAIFlag('NEEDJUMP', '1');
6443 // Åñëè êîí÷èëèñü ïàòîðíû, òî íóæíî ñìåíèòü îðóæèå:
6444 ammo
:= GetAmmoByWeapon(FCurrWeap
);
6445 if ((FCurrWeap
= WEAPON_SHOTGUN2
) and (ammo
< 2)) or
6446 ((FCurrWeap
= WEAPON_BFG
) and (ammo
< 40)) or
6448 SetAIFlag('SELECTWEAPON', '1');
6450 // Åñëè íóæíî ñìåíèòü îðóæèå, òî âûáèðàåì íóæíîå:
6451 if GetAIFlag('SELECTWEAPON') = '1' then
6454 RemoveAIFlag('SELECTWEAPON');
6458 procedure TBot
.Update();
6471 // Ïðîâåðÿåì, îòêëþ÷¸í ëè AI áîòîâ
6472 if (g_debug_BotAIOff
= 1) and (Team
= TEAM_RED
) then
6474 if (g_debug_BotAIOff
= 2) and (Team
= TEAM_BLUE
) then
6476 if g_debug_BotAIOff
= 3 then
6489 procedure TBot
.ReleaseKey(Key
: Byte);
6498 function TBot
.KeyPressed(Key
: Word): Boolean;
6500 Result
:= FKeys
[Key
].Pressed
;
6503 function TBot
.GetAIFlag(fName
: String20
): String20
;
6509 fName
:= LowerCase(fName
);
6511 if FAIFlags
<> nil then
6512 for a
:= 0 to High(FAIFlags
) do
6513 if LowerCase(FAIFlags
[a
].Name
) = fName
then
6515 Result
:= FAIFlags
[a
].Value
;
6520 procedure TBot
.RemoveAIFlag(fName
: String20
);
6524 if FAIFlags
= nil then Exit
;
6526 fName
:= LowerCase(fName
);
6528 for a
:= 0 to High(FAIFlags
) do
6529 if LowerCase(FAIFlags
[a
].Name
) = fName
then
6531 if a
<> High(FAIFlags
) then
6532 for b
:= a
to High(FAIFlags
)-1 do
6533 FAIFlags
[b
] := FAIFlags
[b
+1];
6535 SetLength(FAIFlags
, Length(FAIFlags
)-1);
6540 procedure TBot
.SetAIFlag(fName
, fValue
: String20
);
6548 fName
:= LowerCase(fName
);
6550 if FAIFlags
<> nil then
6551 for a
:= 0 to High(FAIFlags
) do
6552 if LowerCase(FAIFlags
[a
].Name
) = fName
then
6558 if ok
then FAIFlags
[a
].Value
:= fValue
6561 SetLength(FAIFlags
, Length(FAIFlags
)+1);
6562 with FAIFlags
[High(FAIFlags
)] do
6570 procedure TBot
.UpdateMove
;
6572 procedure GoLeft(Time
: Word = 1);
6574 ReleaseKey(KEY_LEFT
);
6575 ReleaseKey(KEY_RIGHT
);
6576 PressKey(KEY_LEFT
, Time
);
6577 SetDirection(D_LEFT
);
6580 procedure GoRight(Time
: Word = 1);
6582 ReleaseKey(KEY_LEFT
);
6583 ReleaseKey(KEY_RIGHT
);
6584 PressKey(KEY_RIGHT
, Time
);
6585 SetDirection(D_RIGHT
);
6588 function Rnd(a
: Word): Boolean;
6590 Result
:= Random(a
) = 0;
6593 procedure Turn(Time
: Word = 1200);
6595 if RunDirection() = D_LEFT
then GoRight(Time
) else GoLeft(Time
);
6600 ReleaseKey(KEY_LEFT
);
6601 ReleaseKey(KEY_RIGHT
);
6604 function CanRunLeft(): Boolean;
6606 Result
:= not CollideLevel(-1, 0);
6609 function CanRunRight(): Boolean;
6611 Result
:= not CollideLevel(1, 0);
6614 function CanRun(): Boolean;
6616 if RunDirection() = D_LEFT
then Result
:= CanRunLeft() else Result
:= CanRunRight();
6619 procedure Jump(Time
: Word = 30);
6621 PressKey(KEY_JUMP
, Time
);
6624 function NearHole(): Boolean;
6628 { TODO 5 : Ëåñòíèöû }
6629 sx
:= IfThen(RunDirection() = D_LEFT
, -1, 1);
6630 for x
:= 1 to PLAYER_RECT
.Width
do
6631 if (not StayOnStep(x
*sx
, 0)) and
6632 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
)) and
6633 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
*2)) then
6642 function BorderHole(): Boolean;
6646 { TODO 5 : Ëåñòíèöû }
6647 sx
:= IfThen(RunDirection() = D_LEFT
, -1, 1);
6648 for x
:= 1 to PLAYER_RECT
.Width
do
6649 if (not StayOnStep(x
*sx
, 0)) and
6650 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
)) and
6651 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
*2)) then
6653 for xx
:= x
to x
+32 do
6654 if CollideLevel(xx
*sx
, PLAYER_RECT
.Height
) then
6664 function NearDeepHole(): Boolean;
6670 sx
:= IfThen(RunDirection() = D_LEFT
, -1, 1);
6673 for x
:= 1 to PLAYER_RECT
.Width
do
6674 if (not StayOnStep(x
*sx
, 0)) and
6675 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
)) and
6676 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
*2)) then
6678 while FObj
.Y
+y
*PLAYER_RECT
.Height
< gMapInfo
.Height
do
6680 if CollideLevel(x
*sx
, PLAYER_RECT
.Height
*y
) then Exit
;
6685 end else Result
:= False;
6688 function OverDeepHole(): Boolean;
6695 while FObj
.Y
+y
*PLAYER_RECT
.Height
< gMapInfo
.Height
do
6697 if CollideLevel(0, PLAYER_RECT
.Height
*y
) then Exit
;
6704 function OnGround(): Boolean;
6706 Result
:= StayOnStep(0, 0) or CollideLevel(0, 1);
6709 function OnLadder(): Boolean;
6711 Result
:= FullInStep(0, 0);
6714 function BelowLadder(): Boolean;
6716 Result
:= (FullInStep(IfThen(RunDirection() = D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -PLAYER_RECT
.Height
) and
6717 not CollideLevel(IfThen(RunDirection() = D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -PLAYER_RECT
.Height
)) or
6718 (FullInStep(IfThen(RunDirection() = D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -BOT_MAXJUMP
) and
6719 not CollideLevel(IfThen(RunDirection() = D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -BOT_MAXJUMP
));
6722 function BelowLiftUp(): Boolean;
6724 Result
:= ((FullInLift(IfThen(RunDirection() = D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -PLAYER_RECT
.Height
) = -1) and
6725 not CollideLevel(IfThen(RunDirection() = D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -PLAYER_RECT
.Height
)) or
6726 ((FullInLift(IfThen(RunDirection() = D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -BOT_MAXJUMP
) = -1) and
6727 not CollideLevel(IfThen(RunDirection() = D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -BOT_MAXJUMP
));
6730 function OnTopLift(): Boolean;
6732 Result
:= (FullInLift(0, 0) = -1) and (FullInLift(0, -32) = 0);
6735 function CanJumpOver(): Boolean;
6739 sx
:= IfThen(RunDirection() = D_LEFT
, -1, 1);
6743 if not CollideLevel(sx
, 0) then Exit
;
6745 for y
:= 1 to BOT_MAXJUMP
do
6746 if CollideLevel(0, -y
) then Exit
else
6747 if not CollideLevel(sx
, -y
) then
6754 function CanJumpUp(Dist
: ShortInt): Boolean;
6761 if CollideLevel(Dist
, 0) then Exit
;
6764 for y
:= 0 to BOT_MAXJUMP
do
6765 if CollideLevel(Dist
, -y
) then
6774 for yy
:= y
+1 to BOT_MAXJUMP
do
6775 if not CollideLevel(Dist
, -yy
) then
6784 for y
:= 0 to BOT_MAXJUMP
do
6785 if CollideLevel(0, -y
) then
6793 if y
< yy
then Exit
;
6798 function IsSafeTrigger(): Boolean;
6803 if gTriggers
= nil then
6805 for a
:= 0 to High(gTriggers
) do
6806 if Collide(gTriggers
[a
].X
,
6809 gTriggers
[a
].Height
) and
6810 (gTriggers
[a
].TriggerType
in [TRIGGER_EXIT
, TRIGGER_CLOSEDOOR
,
6811 TRIGGER_CLOSETRAP
, TRIGGER_TRAP
,
6812 TRIGGER_PRESS
, TRIGGER_ON
, TRIGGER_OFF
,
6813 TRIGGER_ONOFF
, TRIGGER_SPAWNMONSTER
,
6814 TRIGGER_DAMAGE
, TRIGGER_SHOT
]) then
6819 // Âîçìîæíî, íàæèìàåì êíîïêó:
6820 if Rnd(16) and IsSafeTrigger() then
6823 // Åñëè ïîä ëèôòîì èëè ñòóïåíüêàìè, òî, âîçìîæíî, ïðûãàåì:
6824 if OnLadder() or ((BelowLadder() or BelowLiftUp()) and Rnd(8)) then
6826 ReleaseKey(KEY_LEFT
);
6827 ReleaseKey(KEY_RIGHT
);
6831 // Èäåì âëåâî, åñëè íàäî áûëî:
6832 if GetAIFlag('GOLEFT') <> '' then
6834 RemoveAIFlag('GOLEFT');
6835 if CanRunLeft() then
6839 // Èäåì âïðàâî, åñëè íàäî áûëî:
6840 if GetAIFlag('GORIGHT') <> '' then
6842 RemoveAIFlag('GORIGHT');
6843 if CanRunRight() then
6847 // Åñëè âûëåòåëè çà êàðòó, òî ïðîáóåì âåðíóòüñÿ:
6848 if FObj
.X
< -32 then
6851 if FObj
.X
+32 > gMapInfo
.Width
then
6854 // Ïðûãàåì, åñëè íàäî áûëî:
6855 if GetAIFlag('NEEDJUMP') <> '' then
6858 RemoveAIFlag('NEEDJUMP');
6861 // Ñìîòðèì ââåðõ, åñëè íàäî áûëî:
6862 if GetAIFlag('NEEDSEEUP') <> '' then
6865 ReleaseKey(KEY_DOWN
);
6866 PressKey(KEY_UP
, 20);
6867 RemoveAIFlag('NEEDSEEUP');
6870 // Ñìîòðèì âíèç, åñëè íàäî áûëî:
6871 if GetAIFlag('NEEDSEEDOWN') <> '' then
6874 ReleaseKey(KEY_DOWN
);
6875 PressKey(KEY_DOWN
, 20);
6876 RemoveAIFlag('NEEDSEEDOWN');
6879 // Åñëè íóæíî áûëî â äûðó è ìû íå íà çåìëå, òî ïîêîðíî ëåòèì:
6880 if GetAIFlag('GOINHOLE') <> '' then
6881 if not OnGround() then
6883 ReleaseKey(KEY_LEFT
);
6884 ReleaseKey(KEY_RIGHT
);
6885 RemoveAIFlag('GOINHOLE');
6886 SetAIFlag('FALLINHOLE', '1');
6889 // Åñëè ïàäàëè è äîñòèãëè çåìëè, òî õâàòèò ïàäàòü:
6890 if GetAIFlag('FALLINHOLE') <> '' then
6892 RemoveAIFlag('FALLINHOLE');
6894 // Åñëè ëåòåëè ïðÿìî è ñåé÷àñ íå íà ëåñòíèöå èëè íà âåðøèíå ëèôòà, òî îòõîäèì â ñòîðîíó:
6895 if not (KeyPressed(KEY_LEFT
) or KeyPressed(KEY_RIGHT
)) then
6896 if GetAIFlag('FALLINHOLE') = '' then
6897 if (not OnLadder()) or (FObj
.Vel
.Y
>= 0) or (OnTopLift()) then
6903 // Åñëè íà çåìëå è ìîæíî ïîäïðûãíóòü, òî, âîçìîæíî, ïðûãàåì:
6905 CanJumpUp(IfThen(RunDirection() = D_LEFT
, -1, 1)*32) and
6909 // Åñëè íà çåìëå è âîçëå äûðû (ãëóáèíà > 2 ðîñòîâ èãðîêà):
6910 if OnGround() and NearHole() then
6911 if NearDeepHole() then // Åñëè ýòî áåçäíà
6913 0..3: Turn(); // Áåæèì îáðàòíî
6914 4: Jump(); // Ïðûãàåì
6915 5: begin // Ïðûãàåì îáðàòíî
6920 else // Ýòî íå áåçäíà è ìû åùå íå ëåòèì òóäà
6921 if GetAIFlag('GOINHOLE') = '' then
6923 0: Turn(); // Íå íóæíî òóäà
6924 1: Jump(); // Âäðóã ïîâåçåò - ïðûãàåì
6925 else // Åñëè ÿìà ñ ãðàíèöåé, òî ïðè ñëó÷àå ìîæíî òóäà ïðûãíóòü
6926 if BorderHole() then
6927 SetAIFlag('GOINHOLE', '1');
6930 // Åñëè íà çåìëå, íî íåêóäà èäòè:
6931 if (not CanRun()) and OnGround() then
6933 // Åñëè ìû íà ëåñòíèöå èëè ìîæíî ïåðåïðûãíóòü, òî ïðûãàåì:
6934 if CanJumpOver() or OnLadder() then
6936 else // èíà÷å ïîïûòàåìñÿ â äðóãóþ ñòîðîíó
6937 if Random(2) = 0 then
6939 if IsSafeTrigger() then
6945 // Îñòàëîñü ìàëî âîçäóõà:
6946 if FAir
< 36 * 2 then
6949 // Âûáèðàåìñÿ èç êèñëîòû, åñëè íåò êîñòþìà, îáîæãëèñü, èëè ìàëî çäîðîâüÿ:
6950 if (FMegaRulez
[MR_SUIT
] < gTime
) and ((FLastHit
= HIT_ACID
) or (Healthy() <= 1)) then
6951 if BodyInAcid(0, 0) then
6955 function TBot
.FullInStep(XInc
, YInc
: Integer): Boolean;
6957 Result
:= g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
,
6958 PLAYER_RECT
.Width
, PLAYER_RECT
.Height
, PANEL_STEP
, False);
6961 {function TBot.NeedItem(Item: Byte): Byte;
6966 procedure TBot
.SelectWeapon(Dist
: Integer);
6970 function HaveAmmo(weapon
: Byte): Boolean;
6973 WEAPON_PISTOL
: Result
:= FAmmo
[A_BULLETS
] >= 1;
6974 WEAPON_SHOTGUN1
: Result
:= FAmmo
[A_SHELLS
] >= 1;
6975 WEAPON_SHOTGUN2
: Result
:= FAmmo
[A_SHELLS
] >= 2;
6976 WEAPON_CHAINGUN
: Result
:= FAmmo
[A_BULLETS
] >= 10;
6977 WEAPON_ROCKETLAUNCHER
: Result
:= FAmmo
[A_ROCKETS
] >= 1;
6978 WEAPON_PLASMA
: Result
:= FAmmo
[A_CELLS
] >= 10;
6979 WEAPON_BFG
: Result
:= FAmmo
[A_CELLS
] >= 40;
6980 WEAPON_SUPERPULEMET
: Result
:= FAmmo
[A_SHELLS
] >= 1;
6981 else Result
:= True;
6986 if Dist
= -1 then Dist
:= BOT_LONGDIST
;
6988 if Dist
> BOT_LONGDIST
then
6989 begin // Äàëüíèé áîé
6991 if FWeapon
[FDifficult
.WeaponPrior
[a
]] and HaveAmmo(FDifficult
.WeaponPrior
[a
]) then
6993 FSelectedWeapon
:= FDifficult
.WeaponPrior
[a
];
6997 else //if Dist > BOT_UNSAFEDIST then
6998 begin // Áëèæíèé áîé
7000 if FWeapon
[FDifficult
.CloseWeaponPrior
[a
]] and HaveAmmo(FDifficult
.CloseWeaponPrior
[a
]) then
7002 FSelectedWeapon
:= FDifficult
.CloseWeaponPrior
[a
];
7009 if FWeapon[FDifficult.SafeWeaponPrior[a]] and HaveAmmo(FDifficult.SafeWeaponPrior[a]) then
7011 FSelectedWeapon := FDifficult.SafeWeaponPrior[a];
7017 function TBot
.PickItem(ItemType
: Byte; force
: Boolean; var remove
: Boolean): Boolean;
7019 Result
:= inherited PickItem(ItemType
, force
, remove
);
7021 if Result
then SetAIFlag('SELECTWEAPON', '1');
7024 function TBot
.Heal(value
: Word; Soft
: Boolean): Boolean;
7026 Result
:= inherited Heal(value
, Soft
);
7029 function TBot
.Healthy(): Byte;
7031 if FMegaRulez
[MR_INVUL
] >= gTime
then Result
:= 3
7032 else if (FHealth
> 80) or ((FHealth
> 50) and (FArmor
> 20)) then Result
:= 3
7033 else if (FHealth
> 50) then Result
:= 2
7034 else if (FHealth
> 20) then Result
:= 1
7038 function TBot
.TargetOnScreen(TX
, TY
: Integer): Boolean;
7040 Result
:= (Abs(FObj
.X
-TX
) <= Trunc(gPlayerScreenSize
.X
*0.6)) and
7041 (Abs(FObj
.Y
-TY
) <= Trunc(gPlayerScreenSize
.Y
*0.6));
7044 procedure TBot
.OnDamage(Angle
: SmallInt);
7052 if (Angle
= 0) or (Angle
= 180) then
7055 if (g_GetUIDType(FLastSpawnerUID
) = UID_PLAYER
) and
7056 LongBool(gGameSettings
.Options
and GAME_OPTION_BOTVSPLAYER
) then
7058 pla
:= g_Player_Get(FLastSpawnerUID
);
7059 ok
:= not TargetOnScreen(pla
.FObj
.X
+ PLAYER_RECT
.X
,
7060 pla
.FObj
.Y
+ PLAYER_RECT
.Y
);
7063 if (g_GetUIDType(FLastSpawnerUID
) = UID_MONSTER
) and
7064 LongBool(gGameSettings
.Options
and GAME_OPTION_BOTVSMONSTER
) then
7066 mon
:= g_Monsters_Get(FLastSpawnerUID
);
7067 ok
:= not TargetOnScreen(mon
.Obj
.X
+ mon
.Obj
.Rect
.X
,
7068 mon
.Obj
.Y
+ mon
.Obj
.Rect
.Y
);
7073 SetAIFlag('ATTACKLEFT', '1')
7075 SetAIFlag('ATTACKRIGHT', '1');
7079 function TBot
.RunDirection(): TDirection
;
7081 if Abs(Vel
.X
) >= 1 then
7083 if Vel
.X
> 0 then Result
:= D_RIGHT
else Result
:= D_LEFT
;
7085 Result
:= FDirection
;
7088 function TBot
.GetRnd(a
: Byte): Boolean;
7090 if a
= 0 then Result
:= False
7091 else if a
= 255 then Result
:= True
7092 else Result
:= Random(256) > 255-a
;
7095 function TBot
.GetInterval(a
: Byte; radius
: SmallInt): SmallInt;
7097 Result
:= Round((255-a
)/255*radius
*(Random(2)-1));
7100 procedure TBot
.SaveState(var Mem
: TBinMemoryWriter
);
7106 inherited SaveState(Mem
);
7108 // Âûáðàííîå îðóæèå:
7109 Mem
.WriteByte(FSelectedWeapon
);
7111 Mem
.WriteWord(FTargetUID
);
7112 // Âðåìÿ ïîòåðè öåëè:
7113 Mem
.WriteDWORD(FLastVisible
);
7114 // Êîëè÷åñòâî ôëàãîâ ÈÈ:
7115 dw
:= Length(FAIFlags
);
7118 for i
:= 0 to Integer(dw
)-1 do
7120 Mem
.WriteString(FAIFlags
[i
].Name
, 20);
7121 Mem
.WriteString(FAIFlags
[i
].Value
, 20);
7123 // Íàñòðîéêè ñëîæíîñòè:
7125 Mem
.WriteMemory(p
, SizeOf(TDifficult
));
7128 procedure TBot
.LoadState(var Mem
: TBinMemoryReader
);
7134 inherited LoadState(Mem
);
7136 // Âûáðàííîå îðóæèå:
7137 Mem
.ReadByte(FSelectedWeapon
);
7139 Mem
.ReadWord(FTargetUID
);
7140 // Âðåìÿ ïîòåðè öåëè:
7141 Mem
.ReadDWORD(FLastVisible
);
7142 // Êîëè÷åñòâî ôëàãîâ ÈÈ:
7144 SetLength(FAIFlags
, dw
);
7146 for i
:= 0 to Integer(dw
)-1 do
7148 Mem
.ReadString(FAIFlags
[i
].Name
);
7149 Mem
.ReadString(FAIFlags
[i
].Value
);
7151 // Íàñòðîéêè ñëîæíîñòè:
7152 Mem
.ReadMemory(p
, dw
);
7153 if dw
<> SizeOf(TDifficult
) then
7155 raise EBinSizeError
.Create('TBot.LoadState: Wrong FDifficult Size');
7157 FDifficult
:= TDifficult(p
^);