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, version 3 of the License ONLY.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 {$INCLUDE ../shared/a_modes.inc}
23 {$IFDEF USE_MEMPOOL}mempool
,{$ENDIF}
24 e_graphics
, g_playermodel
, g_basic
, g_textures
,
25 g_weapons
, g_phys
, g_sound
, g_saveload
, MAPDEF
,
61 AmmoLimits
: Array [0..1] of Array [A_BULLETS
..A_HIGH
] of Word =
62 ((200, 50, 50, 300, 100),
63 (400, 100, 100, 600, 200));
84 ANGLE_NONE
= Low(SmallInt);
86 CORPSE_STATE_REMOVEME
= 0;
87 CORPSE_STATE_NORMAL
= 1;
88 CORPSE_STATE_MESS
= 2;
90 PLAYER_RECT
: TRectWH
= (X
:15; Y
:12; Width
:34; Height
:52);
91 PLAYER_RECT_CX
= 15+(34 div 2);
92 PLAYER_RECT_CY
= 12+(52 div 2);
93 PLAYER_CORPSERECT
: TRectWH
= (X
:15; Y
:48; Width
:34; Height
:16);
96 PLAYER_HP_LIMIT
= 200;
98 PLAYER_AP_LIMIT
= 200;
102 PLAYER_BURN_TIME
= 110;
104 PLAYER1_DEF_COLOR
: TRGB
= (R
:64; G
:175; B
:48);
105 PLAYER2_DEF_COLOR
: TRGB
= (R
:96; G
:96; B
:96);
123 TPlayerStatArray
= Array of TPlayerStat
;
125 TPlayerSavedState
= record
133 Ammo
: Array [A_BULLETS
..A_HIGH
] of Word;
134 MaxAmmo
: Array [A_BULLETS
..A_HIGH
] of Word;
135 Weapon
: Array [WP_FIRST
..WP_LAST
] of Boolean;
136 Rulez
: Set of R_ITEM_BACKPACK
..R_BERSERK
;
145 TPlayer
= class{$IFDEF USE_MEMPOOL}(TPoolObject
){$ENDIF}
153 FDirection
: TDirection
;
161 FMonsterKills
: Integer;
167 FCanJetpack
: Boolean;
173 FNextWeapDelay
: Byte; // frames
174 FBFGFireCounter
: SmallInt;
175 FLastSpawnerUID
: Word;
179 FSpectatePlayer
: Integer;
180 FFirePainTime
: Integer;
183 FSavedStateNum
: Integer;
185 FModel
: TPlayerModel
;
186 FPunchAnim
: TAnimation
;
189 FActionForce
: Boolean;
190 FActionChanged
: Boolean;
192 FFireAngle
: SmallInt;
196 FShellTimer
: Integer;
198 FSawSound
: TPlayableSound
;
199 FSawSoundIdle
: TPlayableSound
;
200 FSawSoundHit
: TPlayableSound
;
201 FSawSoundSelect
: TPlayableSound
;
202 FFlameSoundOn
: TPlayableSound
;
203 FFlameSoundOff
: TPlayableSound
;
204 FFlameSoundWork
: TPlayableSound
;
205 FJetSoundOn
: TPlayableSound
;
206 FJetSoundOff
: TPlayableSound
;
207 FJetSoundFly
: TPlayableSound
;
211 FJustTeleported
: Boolean;
213 mEDamageType
: Integer;
216 function CollideLevel(XInc
, YInc
: Integer): Boolean;
217 function StayOnStep(XInc
, YInc
: Integer): Boolean;
218 function HeadInLiquid(XInc
, YInc
: Integer): Boolean;
219 function BodyInLiquid(XInc
, YInc
: Integer): Boolean;
220 function BodyInAcid(XInc
, YInc
: Integer): Boolean;
221 function FullInLift(XInc
, YInc
: Integer): Integer;
222 {procedure CollideItem();}
223 procedure FlySmoke(Times
: DWORD
= 1);
224 procedure OnFireFlame(Times
: DWORD
= 1);
225 function GetAmmoByWeapon(Weapon
: Byte): Word;
226 procedure SetAction(Action
: Byte; Force
: Boolean = False);
227 procedure OnDamage(Angle
: SmallInt); virtual;
228 function firediry(): Integer;
231 procedure Run(Direction
: TDirection
);
232 procedure NextWeapon();
233 procedure PrevWeapon();
240 function getNextWeaponIndex (): Byte; // return 255 for "no switch"
241 procedure resetWeaponQueue ();
242 function hasAmmoForWeapon (weapon
: Byte): Boolean;
243 function hasAmmoForShooting (weapon
: Byte): Boolean;
244 function shouldSwitch (weapon
: Byte; hadWeapon
: Boolean) : Boolean;
246 procedure doDamage (v
: Integer);
248 function refreshCorpse(): Boolean;
251 FDamageBuffer
: Integer;
253 FAmmo
: Array [A_BULLETS
..A_HIGH
] of Word;
254 FMaxAmmo
: Array [A_BULLETS
..A_HIGH
] of Word;
255 FWeapon
: Array [WP_FIRST
..WP_LAST
] of Boolean;
256 FRulez
: Set of R_ITEM_BACKPACK
..R_BERSERK
;
258 FMegaRulez
: Array [MR_SUIT
..MR_MAX
] of DWORD
;
259 FReloading
: Array [WP_FIRST
..WP_LAST
] of Word;
260 FTime
: Array [T_RESPAWN
..T_FLAGCAP
] of DWORD
;
261 FKeys
: Array [KEY_LEFT
..KEY_CHAT
] of TKeyState
;
262 FWeapSwitchMode
: Byte;
263 FWeapPreferences
: Array [WP_FIRST
.. WP_LAST
+1] of Byte;
264 FSwitchToEmpty
: Byte;
267 FPreferredTeam
: Byte;
270 FWantsInGame
: Boolean;
275 FActualModelName
: string;
282 FSpawnInvul
: Integer;
284 FWaitForFirstSpawn
: Boolean; // set to `true` in server, used to spawn a player on first full state request
287 // debug: viewport offset
288 viewPortX
, viewPortY
, viewPortW
, viewPortH
: Integer;
290 function isValidViewPort (): Boolean; inline;
292 constructor Create(); virtual;
293 destructor Destroy(); override;
294 procedure Respawn(Silent
: Boolean; Force
: Boolean = False); virtual;
295 function GetRespawnPoint(): Byte;
296 procedure PressKey(Key
: Byte; Time
: Word = 1);
297 procedure ReleaseKeys();
298 procedure SetModel(ModelName
: String);
299 procedure SetColor(Color
: TRGB
);
300 function GetColor(): TRGB
;
301 procedure SetWeapon(W
: Byte);
302 function IsKeyPressed(K
: Byte): Boolean;
303 function GetKeys(): Byte;
304 function PickItem(ItemType
: Byte; arespawn
: Boolean; var remove
: Boolean): Boolean; virtual;
305 procedure SetWeaponPrefs(Prefs
: Array of Byte);
306 procedure SetWeaponPref(Weapon
, Pref
: Byte);
307 function GetWeaponPref(Weapon
: Byte) : Byte;
308 function GetMorePrefered() : Byte;
309 function MaySwitch(Weapon
: Byte) : Boolean;
310 function Collide(X
, Y
: Integer; Width
, Height
: Word): Boolean; overload
;
311 function Collide(Panel
: TPanel
): Boolean; overload
;
312 function Collide(X
, Y
: Integer): Boolean; overload
;
313 procedure SetDirection(Direction
: TDirection
);
314 procedure GetSecret();
315 function TeleportTo(X
, Y
: Integer; silent
: Boolean; dir
: Byte): Boolean;
317 procedure Push(vx
, vy
: Integer);
318 procedure ChangeModel(ModelName
: String);
319 procedure SwitchTeam
;
320 procedure ChangeTeam(Team
: Byte);
322 function GetFlag(Flag
: Byte): Boolean;
323 procedure SetFlag(Flag
: Byte);
324 function DropFlag(Silent
: Boolean = True; DoThrow
: Boolean = False): Boolean;
325 function TryDropFlag(): Boolean;
326 procedure AllRulez(Health
: Boolean);
327 procedure RestoreHealthArmor();
328 procedure FragCombo();
329 procedure GiveItem(ItemType
: Byte);
330 procedure Damage(value
: Word; SpawnerUID
: Word; vx
, vy
: Integer; t
: Byte); virtual;
331 function Heal(value
: Word; Soft
: Boolean): Boolean; virtual;
332 procedure MakeBloodVector(Count
: Word; VelX
, VelY
: Integer);
333 procedure MakeBloodSimple(Count
: Word);
334 procedure Kill(KillType
: Byte; SpawnerUID
: Word; t
: Byte);
335 procedure Reset(Force
: Boolean);
336 procedure Spectate(NoMove
: Boolean = False);
337 procedure SwitchNoClip
;
338 procedure SoftReset();
339 procedure Draw(); virtual;
340 procedure DrawPain();
341 procedure DrawPickup();
342 procedure DrawRulez();
344 procedure DrawIndicator(Color
: TRGB
);
345 procedure DrawBubble();
347 procedure PreUpdate();
348 procedure Update(); virtual;
349 procedure RememberState();
350 procedure RecallState();
351 procedure SaveState (st
: TStream
); virtual;
352 procedure LoadState (st
: TStream
); virtual;
353 procedure PauseSounds(Enable
: Boolean);
354 procedure NetFire(Wpn
: Byte; X
, Y
, AX
, AY
: Integer; WID
: Integer = -1);
355 procedure DoLerp(Level
: Integer = 2);
356 procedure SetLerp(XTo
, YTo
: Integer);
357 procedure ProcessWeaponAction(Action
: Byte);
358 procedure QueueWeaponSwitch(Weapon
: Byte);
359 procedure RealizeCurrentWeapon();
363 procedure JetpackOff
;
364 procedure CatchFire(Attacker
: Word; Timeout
: Integer = PLAYER_BURN_TIME
);
366 //WARNING! this does nothing for now, but still call it!
367 procedure positionChanged (); //WARNING! call this after entity position was changed, or coldet will not work right!
369 procedure getMapBox (out x
, y
, w
, h
: Integer); inline;
370 procedure moveBy (dx
, dy
: Integer); inline;
372 function getCameraObj(): TObj
;
375 property Vel
: TPoint2i read FObj
.Vel
;
376 property Obj
: TObj read FObj
;
378 property Name
: String read FName write FName
;
379 property Model
: TPlayerModel read FModel
;
380 property Health
: Integer read FHealth write FHealth
;
381 property Lives
: Byte read FLives write FLives
;
382 property Armor
: Integer read FArmor write FArmor
;
383 property Air
: Integer read FAir write FAir
;
384 property JetFuel
: Integer read FJetFuel write FJetFuel
;
385 property Frags
: Integer read FFrags write FFrags
;
386 property Death
: Integer read FDeath write FDeath
;
387 property Kills
: Integer read FKills write FKills
;
388 property CurrWeap
: Byte read FCurrWeap write FCurrWeap
;
389 property WeapSwitchMode
: Byte read FWeapSwitchMode write FWeapSwitchMode
;
390 property SwitchToEmpty
: Byte read FSwitchToEmpty write FSwitchToEmpty
;
391 property SkipFist
: Byte read FSkipFist write FSkipFist
;
392 property MonsterKills
: Integer read FMonsterKills write FMonsterKills
;
393 property Secrets
: Integer read FSecrets
;
394 property GodMode
: Boolean read FGodMode write FGodMode
;
395 property NoTarget
: Boolean read FNoTarget write FNoTarget
;
396 property NoReload
: Boolean read FNoReload write FNoReload
;
397 property alive
: Boolean read FAlive write FAlive
;
398 property Flag
: Byte read FFlag
;
399 property Team
: Byte read FTeam write FTeam
;
400 property Direction
: TDirection read FDirection
;
401 property GameX
: Integer read FObj
.X write FObj
.X
;
402 property GameY
: Integer read FObj
.Y write FObj
.Y
;
403 property GameVelX
: Integer read FObj
.Vel
.X write FObj
.Vel
.X
;
404 property GameVelY
: Integer read FObj
.Vel
.Y write FObj
.Vel
.Y
;
405 property GameAccelX
: Integer read FObj
.Accel
.X write FObj
.Accel
.X
;
406 property GameAccelY
: Integer read FObj
.Accel
.Y write FObj
.Accel
.Y
;
407 property IncCam
: Integer read FIncCam write FIncCam
;
408 property IncCamOld
: Integer read FIncCamOld write FIncCamOld
;
409 property SlopeOld
: Integer read FSlopeOld write FSlopeOld
;
410 property UID
: Word read FUID write FUID
;
411 property JustTeleported
: Boolean read FJustTeleported write FJustTeleported
;
412 property NetTime
: LongWord read FNetTime write FNetTime
;
415 property eName
: String read FName write FName
;
416 property eHealth
: Integer read FHealth write FHealth
;
417 property eLives
: Byte read FLives write FLives
;
418 property eArmor
: Integer read FArmor write FArmor
;
419 property eAir
: Integer read FAir write FAir
;
420 property eJetFuel
: Integer read FJetFuel write FJetFuel
;
421 property eFrags
: Integer read FFrags write FFrags
;
422 property eDeath
: Integer read FDeath write FDeath
;
423 property eKills
: Integer read FKills write FKills
;
424 property eCurrWeap
: Byte read FCurrWeap write FCurrWeap
;
425 property eMonsterKills
: Integer read FMonsterKills write FMonsterKills
;
426 property eSecrets
: Integer read FSecrets write FSecrets
;
427 property eGodMode
: Boolean read FGodMode write FGodMode
;
428 property eNoTarget
: Boolean read FNoTarget write FNoTarget
;
429 property eNoReload
: Boolean read FNoReload write FNoReload
;
430 property eAlive
: Boolean read FAlive write FAlive
;
431 property eFlag
: Byte read FFlag
;
432 property eTeam
: Byte read FTeam write FTeam
;
433 property eDirection
: TDirection read FDirection
;
434 property eGameX
: Integer read FObj
.X write FObj
.X
;
435 property eGameY
: Integer read FObj
.Y write FObj
.Y
;
436 property eGameVelX
: Integer read FObj
.Vel
.X write FObj
.Vel
.X
;
437 property eGameVelY
: Integer read FObj
.Vel
.Y write FObj
.Vel
.Y
;
438 property eGameAccelX
: Integer read FObj
.Accel
.X write FObj
.Accel
.X
;
439 property eGameAccelY
: Integer read FObj
.Accel
.Y write FObj
.Accel
.Y
;
440 property eIncCam
: Integer read FIncCam write FIncCam
;
441 property eUID
: Word read FUID
;
442 property eJustTeleported
: Boolean read FJustTeleported
;
443 property eNetTime
: LongWord read FNetTime
;
445 // set this before assigning something to `eDamage`
446 property eDamageType
: Integer read mEDamageType write mEDamageType
;
447 property eDamage
: Integer write doDamage
;
458 WeaponPrior
: packed array [WP_FIRST
..WP_LAST
] of Byte;
459 CloseWeaponPrior
: packed array [WP_FIRST
..WP_LAST
] of Byte;
460 //SafeWeaponPrior: Array [WP_FIRST..WP_LAST] of Byte;
463 procedure save (st
: TStream
);
464 procedure load (st
: TStream
);
472 TBot
= class(TPlayer
)
474 FSelectedWeapon
: Byte;
477 FAIFlags
: Array of TAIFlag
;
478 FDifficult
: TDifficult
;
480 function GetRnd(a
: Byte): Boolean;
481 function GetInterval(a
: Byte; radius
: SmallInt): SmallInt;
482 function RunDirection(): TDirection
;
483 function FullInStep(XInc
, YInc
: Integer): Boolean;
484 //function NeedItem(Item: Byte): Byte;
485 procedure SelectWeapon(Dist
: Integer);
486 procedure SetAIFlag(aName
, fValue
: String20
);
487 function GetAIFlag(aName
: String20
): String20
;
488 procedure RemoveAIFlag(aName
: String20
);
489 function Healthy(): Byte;
490 procedure UpdateMove();
491 procedure UpdateCombat();
492 function KeyPressed(Key
: Word): Boolean;
493 procedure ReleaseKey(Key
: Byte);
494 function TargetOnScreen(TX
, TY
: Integer): Boolean;
495 procedure OnDamage(Angle
: SmallInt); override;
498 procedure Respawn(Silent
: Boolean; Force
: Boolean = False); override;
499 constructor Create(); override;
500 destructor Destroy(); override;
501 procedure Draw(); override;
502 function PickItem(ItemType
: Byte; force
: Boolean; var remove
: Boolean): Boolean; override;
503 function Heal(value
: Word; Soft
: Boolean): Boolean; override;
504 procedure Update(); override;
505 procedure SaveState (st
: TStream
); override;
506 procedure LoadState (st
: TStream
); override;
518 procedure getMapBox (out x
, y
, w
, h
: Integer); inline;
519 procedure moveBy (dx
, dy
: Integer); inline;
521 procedure positionChanged (); inline; //WARNING! call this after entity position was changed, or coldet will not work right!
535 procedure getMapBox (out x
, y
, w
, h
: Integer); inline;
536 procedure moveBy (dx
, dy
: Integer); inline;
538 procedure positionChanged (); inline; //WARNING! call this after entity position was changed, or coldet will not work right!
541 TCorpse
= class{$IFDEF USE_MEMPOOL}(TPoolObject
){$ENDIF}
550 FAnimation
: TAnimation
;
551 FAnimationMask
: TAnimation
;
554 constructor Create(X
, Y
: Integer; ModelName
: String; aMess
: Boolean);
555 destructor Destroy(); override;
556 procedure Damage(Value
: Word; SpawnerUID
: Word; vx
, vy
: Integer);
559 procedure SaveState (st
: TStream
);
560 procedure LoadState (st
: TStream
);
562 procedure getMapBox (out x
, y
, w
, h
: Integer); inline;
563 procedure moveBy (dx
, dy
: Integer); inline;
565 procedure positionChanged (); inline; //WARNING! call this after entity position was changed, or coldet will not work right!
567 function ObjPtr (): PObj
; inline;
569 property Obj
: TObj read FObj
; // copies object
570 property State
: Byte read FState
;
571 property Mess
: Boolean read FMess
;
574 TTeamStat
= Array [TEAM_RED
..TEAM_BLUE
] of
580 gPlayers
: Array of TPlayer
;
581 gCorpses
: Array of TCorpse
;
582 gGibs
: Array of TGib
;
583 gShells
: Array of TShell
;
584 gTeamStat
: TTeamStat
;
585 gFly
: Boolean = False;
586 gAimLine
: Boolean = False;
587 gChatBubble
: Integer = 0;
588 gPlayerIndicator
: Integer = 1;
589 gPlayerIndicatorStyle
: Integer = 0;
591 gSpectLatchPID1
: Word = 0;
592 gSpectLatchPID2
: Word = 0;
593 MAX_RUNVEL
: Integer = 8;
594 VEL_JUMP
: Integer = 10;
595 SHELL_TIMEOUT
: Cardinal = 60000;
597 function Lerp(X
, Y
, Factor
: Integer): Integer;
599 procedure g_Gibs_SetMax(Count
: Word);
600 function g_Gibs_GetMax(): Word;
601 procedure g_Corpses_SetMax(Count
: Word);
602 function g_Corpses_GetMax(): Word;
603 procedure g_Shells_SetMax(Count
: Word);
604 function g_Shells_GetMax(): Word;
606 procedure g_Player_Init();
607 procedure g_Player_Free();
608 function g_Player_Create(ModelName
: String; Color
: TRGB
; Team
: Byte; Bot
: Boolean): Word;
609 function g_Player_CreateFromState (st
: TStream
): Word;
610 procedure g_Player_Remove(UID
: Word);
611 procedure g_Player_ResetTeams();
612 procedure g_Player_PreUpdate();
613 procedure g_Player_UpdateAll();
614 procedure g_Player_DrawAll();
615 procedure g_Player_DrawDebug(p
: TPlayer
);
616 procedure g_Player_DrawHealth();
617 procedure g_Player_RememberAll();
618 procedure g_Player_ResetAll(Force
, Silent
: Boolean);
619 function g_Player_Get(UID
: Word): TPlayer
;
620 function g_Player_GetCount(): Byte;
621 function g_Player_GetStats(): TPlayerStatArray
;
622 function g_Player_ValidName(Name
: String): Boolean;
623 function g_Player_CreateCorpse(Player
: TPlayer
): Integer;
624 procedure g_Player_CreateGibs(fX
, fY
: Integer; ModelName
: String; fColor
: TRGB
);
625 procedure g_Player_CreateShell(fX
, fY
, dX
, dY
: Integer; T
: Byte);
626 procedure g_Player_UpdatePhysicalObjects();
627 procedure g_Player_DrawCorpses();
628 procedure g_Player_DrawShells();
629 procedure g_Player_RemoveAllCorpses();
630 procedure g_Player_Corpses_SaveState (st
: TStream
);
631 procedure g_Player_Corpses_LoadState (st
: TStream
);
632 procedure g_Player_ResetReady();
633 procedure g_Bot_Add(Team
, Difficult
: Byte; Handicap
: Integer = 100);
634 procedure g_Bot_AddList(Team
: Byte; lname
: ShortString; num
: Integer = -1; Handicap
: Integer = 100);
635 procedure g_Bot_MixNames();
636 procedure g_Bot_RemoveAll();
641 {$INCLUDE ../nogl/noGLuses.inc}
642 {$IFDEF ENABLE_HOLMES}
645 e_log
, g_map
, g_items
, g_console
, g_gfx
, Math
,
646 g_options
, g_triggers
, g_menu
, g_game
, g_grid
, e_res
,
647 wadreader
, g_main
, g_monsters
, CONFIG
, g_language
,
648 g_net
, g_netmsg
, g_window
,
651 const PLR_SAVE_VERSION
= 0;
661 diag_precision
: Byte;
665 w_prior1
: Array [WP_FIRST
..WP_LAST
] of Byte;
666 w_prior2
: Array [WP_FIRST
..WP_LAST
] of Byte;
667 w_prior3
: Array [WP_FIRST
..WP_LAST
] of Byte;
671 TIME_RESPAWN1
= 1500;
672 TIME_RESPAWN2
= 2000;
673 TIME_RESPAWN3
= 3000;
676 JET_MAX
= 540; // ~30 sec
677 PLAYER_SUIT_TIME
= 30000;
678 PLAYER_INVUL_TIME
= 30000;
679 PLAYER_INVIS_TIME
= 35000;
680 FRAG_COMBO_TIME
= 3000;
684 ANGLE_RIGHTDOWN
= -35;
686 ANGLE_LEFTDOWN
= -145;
687 PLAYER_HEADRECT
: TRectWH
= (X
:24; Y
:12; Width
:20; Height
:12);
688 WEAPONPOINT
: Array [TDirection
] of TDFPoint
= ((X
:16; Y
:32), (X
:47; Y
:32));
691 BOT_UNSAFEDIST
= 128;
692 TEAMCOLOR
: Array [TEAM_RED
..TEAM_BLUE
] of TRGB
= ((R
:255; G
:0; B
:0),
694 DIFFICULT_EASY
: TDifficult
= (DiagFire
: 32; InvisFire
: 32; DiagPrecision
: 32;
695 FlyPrecision
: 32; Cover
: 32; CloseJump
: 32;
696 WeaponPrior
:(0,0,0,0,0,0,0,0,0,0,0); CloseWeaponPrior
:(0,0,0,0,0,0,0,0,0,0,0));
697 DIFFICULT_MEDIUM
: TDifficult
= (DiagFire
: 127; InvisFire
: 127; DiagPrecision
: 127;
698 FlyPrecision
: 127; Cover
: 127; CloseJump
: 127;
699 WeaponPrior
:(0,0,0,0,0,0,0,0,0,0,0); CloseWeaponPrior
:(0,0,0,0,0,0,0,0,0,0,0));
700 DIFFICULT_HARD
: TDifficult
= (DiagFire
: 255; InvisFire
: 255; DiagPrecision
: 255;
701 FlyPrecision
: 255; Cover
: 255; CloseJump
: 255;
702 WeaponPrior
:(0,0,0,0,0,0,0,0,0,0,0); CloseWeaponPrior
:(0,0,0,0,0,0,0,0,0,0,0));
703 WEAPON_PRIOR1
: Array [WP_FIRST
..WP_LAST
] of Byte =
704 (WEAPON_FLAMETHROWER
, WEAPON_SUPERPULEMET
,
705 WEAPON_SHOTGUN2
, WEAPON_SHOTGUN1
,
706 WEAPON_CHAINGUN
, WEAPON_PLASMA
, WEAPON_ROCKETLAUNCHER
,
707 WEAPON_BFG
, WEAPON_PISTOL
, WEAPON_SAW
, WEAPON_KASTET
);
708 WEAPON_PRIOR2
: Array [WP_FIRST
..WP_LAST
] of Byte =
709 (WEAPON_FLAMETHROWER
, WEAPON_SUPERPULEMET
,
710 WEAPON_BFG
, WEAPON_ROCKETLAUNCHER
,
711 WEAPON_SHOTGUN2
, WEAPON_PLASMA
, WEAPON_SHOTGUN1
,
712 WEAPON_CHAINGUN
, WEAPON_PISTOL
, WEAPON_SAW
, WEAPON_KASTET
);
713 //WEAPON_PRIOR3: Array [WP_FIRST..WP_LAST] of Byte =
714 // (WEAPON_FLAMETHROWER, WEAPON_SUPERPULEMET,
715 // WEAPON_BFG, WEAPON_PLASMA, WEAPON_SHOTGUN2,
716 // WEAPON_CHAINGUN, WEAPON_SHOTGUN1, WEAPON_SAW,
717 // WEAPON_ROCKETLAUNCHER, WEAPON_PISTOL, WEAPON_KASTET);
718 WEAPON_RELOAD
: Array [WP_FIRST
..WP_LAST
] of Byte =
719 (5, 2, 6, 18, 36, 2, 12, 2, 14, 2, 2);
721 PLAYER_SIGNATURE
= $52594C50; // 'PLYR'
722 CORPSE_SIGNATURE
= $50524F43; // 'CORP'
724 BOTNAMES_FILENAME
= 'botnames.txt';
725 BOTLIST_FILENAME
= 'botlist.txt';
729 MaxCorpses
: Word = 20;
730 MaxShells
: Word = 300;
731 CurrentGib
: Integer = 0;
732 CurrentShell
: Integer = 0;
733 BotNames
: Array of String;
734 BotList
: Array of TBotProfile
;
735 SavedStates
: Array of TPlayerSavedState
;
738 function Lerp(X
, Y
, Factor
: Integer): Integer;
740 Result
:= X
+ ((Y
- X
) div Factor
);
743 function SameTeam(UID1
, UID2
: Word): Boolean;
747 if (UID1
> UID_MAX_PLAYER
) or (UID1
<= UID_MAX_GAME
) or
748 (UID2
> UID_MAX_PLAYER
) or (UID2
<= UID_MAX_GAME
) then Exit
;
750 if (g_Player_Get(UID1
) = nil) or (g_Player_Get(UID2
) = nil) then Exit
;
752 if ((g_Player_Get(UID1
).Team
= TEAM_NONE
) or
753 (g_Player_Get(UID2
).Team
= TEAM_NONE
)) then Exit
;
755 Result
:= g_Player_Get(UID1
).FTeam
= g_Player_Get(UID2
).FTeam
;
758 procedure g_Gibs_SetMax(Count
: Word);
761 SetLength(gGibs
, Count
);
763 if CurrentGib
>= Count
then
767 function g_Gibs_GetMax(): Word;
772 procedure g_Shells_SetMax(Count
: Word);
775 SetLength(gShells
, Count
);
777 if CurrentShell
>= Count
then
781 function g_Shells_GetMax(): Word;
787 procedure g_Corpses_SetMax(Count
: Word);
790 SetLength(gCorpses
, Count
);
793 function g_Corpses_GetMax(): Word;
795 Result
:= MaxCorpses
;
798 function g_Player_Create(ModelName
: String; Color
: TRGB
; Team
: Byte; Bot
: Boolean): Word;
808 // Åñòü ëè ìåñòî â gPlayers:
809 if gPlayers
<> nil then
810 for a
:= 0 to High(gPlayers
) do
811 if gPlayers
[a
] = nil then
817 // Íåò ìåñòà - ðàñøèðÿåì gPlayers:
820 SetLength(gPlayers
, Length(gPlayers
)+1);
824 // Ñîçäàåì îáúåêò èãðîêà:
826 gPlayers
[a
] := TBot
.Create()
828 gPlayers
[a
] := TPlayer
.Create();
831 gPlayers
[a
].FActualModelName
:= ModelName
;
832 gPlayers
[a
].SetModel(ModelName
);
834 // Íåò ìîäåëè - ñîçäàíèå íå âîçìîæíî:
835 if gPlayers
[a
].FModel
= nil then
839 g_FatalError(Format(_lc
[I_GAME_ERROR_MODEL
], [ModelName
]));
843 if not (Team
in [TEAM_RED
, TEAM_BLUE
]) then
844 if Random(2) = 0 then
848 gPlayers
[a
].FPreferredTeam
:= Team
;
850 case gGameSettings
.GameMode
of
851 GM_DM
: gPlayers
[a
].FTeam
:= TEAM_NONE
;
853 GM_CTF
: gPlayers
[a
].FTeam
:= gPlayers
[a
].FPreferredTeam
;
855 GM_COOP
: gPlayers
[a
].FTeam
:= TEAM_COOP
;
858 // Åñëè êîìàíäíàÿ èãðà - êðàñèì ìîäåëü â öâåò êîìàíäû:
859 gPlayers
[a
].FColor
:= Color
;
860 if gPlayers
[a
].FTeam
in [TEAM_RED
, TEAM_BLUE
] then
861 gPlayers
[a
].FModel
.Color
:= TEAMCOLOR
[gPlayers
[a
].FTeam
]
863 gPlayers
[a
].FModel
.Color
:= Color
;
865 gPlayers
[a
].FUID
:= g_CreateUID(UID_PLAYER
);
866 gPlayers
[a
].FAlive
:= False;
868 Result
:= gPlayers
[a
].FUID
;
871 function g_Player_CreateFromState (st
: TStream
): Word;
872 var a
: Integer; ok
, Bot
: Boolean; pos
: Int64;
876 // check signature and entity type
878 if not utils
.checkSign(st
, 'PLYR') then raise XStreamError
.Create('invalid player signature');
879 if (utils
.readByte(st
) <> PLR_SAVE_VERSION
) then raise XStreamError
.Create('invalid player version');
880 Bot
:= utils
.readBool(st
);
883 // find free player slot
885 for a
:= 0 to High(gPlayers
) do
886 if gPlayers
[a
] = nil then
892 // allocate player slot
895 SetLength(gPlayers
, Length(gPlayers
)+1);
899 // create entity and load state
901 gPlayers
[a
] := TBot
.Create()
903 gPlayers
[a
] := TPlayer
.Create();
904 gPlayers
[a
].FPhysics
:= True; // ???
905 gPlayers
[a
].LoadState(st
);
907 result
:= gPlayers
[a
].FUID
;
911 procedure g_Player_ResetTeams();
915 if g_Game_IsClient
then
917 if gPlayers
= nil then
919 for a
:= Low(gPlayers
) to High(gPlayers
) do
920 if gPlayers
[a
] <> nil then
921 case gGameSettings
.GameMode
of
923 gPlayers
[a
].ChangeTeam(TEAM_NONE
);
925 if not (gPlayers
[a
].Team
in [TEAM_RED
, TEAM_BLUE
]) then
926 if gPlayers
[a
].FPreferredTeam
in [TEAM_RED
, TEAM_BLUE
] then
927 gPlayers
[a
].ChangeTeam(gPlayers
[a
].FPreferredTeam
)
930 gPlayers
[a
].ChangeTeam(TEAM_RED
)
932 gPlayers
[a
].ChangeTeam(TEAM_BLUE
);
935 gPlayers
[a
].ChangeTeam(TEAM_COOP
);
939 procedure g_Bot_Add(Team
, Difficult
: Byte; Handicap
: Integer = 100);
942 _name
, _model
: String;
945 if not g_Game_IsServer
then Exit
;
947 // Ñïèñîê íàçâàíèé ìîäåëåé:
948 m
:= g_PlayerModel_GetNames();
953 if (gGameSettings
.GameType
= GT_SINGLE
) or (gGameSettings
.GameMode
= GM_COOP
) then
954 Team
:= TEAM_COOP
// COOP
956 if gGameSettings
.GameMode
= GM_DM
then
957 Team
:= TEAM_NONE
// DM
959 if Team
= TEAM_NONE
then // CTF / TDM
961 // Àâòîáàëàíñ êîìàíä:
965 for a
:= 0 to High(gPlayers
) do
966 if gPlayers
[a
] <> nil then
968 if gPlayers
[a
].Team
= TEAM_RED
then
971 if gPlayers
[a
].Team
= TEAM_BLUE
then
981 if Random(2) = 0 then
987 // Âûáèðàåì áîòó èìÿ:
989 if BotNames
<> nil then
990 for a
:= 0 to High(BotNames
) do
991 if g_Player_ValidName(BotNames
[a
]) then
993 _name
:= BotNames
[a
];
997 // Âûáèðàåì ñëó÷àéíóþ ìîäåëü:
998 _model
:= m
[Random(Length(m
))];
1001 with g_Player_Get(g_Player_Create(_model
,
1002 _RGB(Min(Random(9)*32, 255),
1003 Min(Random(9)*32, 255),
1004 Min(Random(9)*32, 255)),
1005 Team
, True)) as TBot
do
1007 // Åñëè èìåíè íåò, äåëàåì åãî èç UID áîòà
1009 Name
:= Format('DFBOT%.5d', [UID
])
1014 1: FDifficult
:= DIFFICULT_EASY
;
1015 2: FDifficult
:= DIFFICULT_MEDIUM
;
1016 else FDifficult
:= DIFFICULT_HARD
;
1019 for a
:= WP_FIRST
to WP_LAST
do
1021 FDifficult
.WeaponPrior
[a
] := WEAPON_PRIOR1
[a
];
1022 FDifficult
.CloseWeaponPrior
[a
] := WEAPON_PRIOR2
[a
];
1023 //FDifficult.SafeWeaponPrior[a] := WEAPON_PRIOR3[a];
1026 FHandicap
:= Handicap
;
1028 g_Console_Add(Format(_lc
[I_PLAYER_JOIN
], [Name
]), True);
1030 if g_Game_IsNet
then MH_SEND_PlayerCreate(UID
);
1031 if g_Game_IsServer
and (gGameSettings
.MaxLives
> 0) then
1036 procedure g_Bot_AddList(Team
: Byte; lName
: ShortString; num
: Integer = -1; Handicap
: Integer = 100);
1039 _name
, _model
: String;
1042 if not g_Game_IsServer
then Exit
;
1044 // Ñïèñîê íàçâàíèé ìîäåëåé:
1045 m
:= g_PlayerModel_GetNames();
1050 if (gGameSettings
.GameType
= GT_SINGLE
) or (gGameSettings
.GameMode
= GM_COOP
) then
1051 Team
:= TEAM_COOP
// COOP
1053 if gGameSettings
.GameMode
= GM_DM
then
1054 Team
:= TEAM_NONE
// DM
1056 if Team
= TEAM_NONE
then
1057 Team
:= BotList
[num
].team
; // CTF / TDM
1059 // Âûáèðàåì íàñòðîéêè áîòà èç ñïèñêà ïî íîìåðó èëè èìåíè:
1060 lName
:= AnsiLowerCase(lName
);
1061 if (num
< 0) or (num
> Length(BotList
)-1) then
1063 if (num
= -1) and (lName
<> '') and (BotList
<> nil) then
1064 for a
:= 0 to High(BotList
) do
1065 if AnsiLowerCase(BotList
[a
].name
) = lName
then
1074 _name
:= BotList
[num
].name
;
1075 // Çàíÿòî - âûáèðàåì ñëó÷àéíîå:
1076 if not g_Player_ValidName(_name
) then
1078 _name
:= Format('DFBOT%.2d', [Random(100)]);
1079 until g_Player_ValidName(_name
);
1082 _model
:= BotList
[num
].model
;
1083 // Íåò òàêîé - âûáèðàåì ñëó÷àéíóþ:
1084 if not InSArray(_model
, m
) then
1085 _model
:= m
[Random(Length(m
))];
1088 with g_Player_Get(g_Player_Create(_model
, BotList
[num
].color
, Team
, True)) as TBot
do
1092 FDifficult
.DiagFire
:= BotList
[num
].diag_fire
;
1093 FDifficult
.InvisFire
:= BotList
[num
].invis_fire
;
1094 FDifficult
.DiagPrecision
:= BotList
[num
].diag_precision
;
1095 FDifficult
.FlyPrecision
:= BotList
[num
].fly_precision
;
1096 FDifficult
.Cover
:= BotList
[num
].cover
;
1097 FDifficult
.CloseJump
:= BotList
[num
].close_jump
;
1099 FHandicap
:= Handicap
;
1101 for a
:= WP_FIRST
to WP_LAST
do
1103 FDifficult
.WeaponPrior
[a
] := BotList
[num
].w_prior1
[a
];
1104 FDifficult
.CloseWeaponPrior
[a
] := BotList
[num
].w_prior2
[a
];
1105 //FDifficult.SafeWeaponPrior[a] := BotList[num].w_prior3[a];
1108 g_Console_Add(Format(_lc
[I_PLAYER_JOIN
], [Name
]), True);
1110 if g_Game_IsNet
then MH_SEND_PlayerCreate(UID
);
1114 procedure g_Bot_RemoveAll();
1118 if not g_Game_IsServer
then Exit
;
1119 if gPlayers
= nil then Exit
;
1121 for a
:= 0 to High(gPlayers
) do
1122 if gPlayers
[a
] <> nil then
1123 if gPlayers
[a
] is TBot
then
1125 gPlayers
[a
].Lives
:= 0;
1126 gPlayers
[a
].Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
1127 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [gPlayers
[a
].Name
]), True);
1128 g_Player_Remove(gPlayers
[a
].FUID
);
1134 procedure g_Bot_MixNames();
1139 if BotNames
<> nil then
1140 for a
:= 0 to High(BotNames
) do
1142 b
:= Random(Length(BotNames
));
1144 Botnames
[a
] := BotNames
[b
];
1149 procedure g_Player_Remove(UID
: Word);
1153 if gPlayers
= nil then Exit
;
1155 if g_Game_IsServer
and g_Game_IsNet
then
1156 MH_SEND_PlayerDelete(UID
);
1158 for i
:= 0 to High(gPlayers
) do
1159 if gPlayers
[i
] <> nil then
1160 if gPlayers
[i
].FUID
= UID
then
1162 if gPlayers
[i
] is TPlayer
then
1163 TPlayer(gPlayers
[i
]).Free()
1165 TBot(gPlayers
[i
]).Free();
1171 procedure g_Player_Init();
1182 path
:= BOTNAMES_FILENAME
;
1183 if e_FindResource(DataDirs
, path
) = false then
1186 // ×èòàåì âîçìîæíûå èìåíà áîòîâ èç ôàéëà:
1187 AssignFile(F
, path
);
1198 SetLength(BotNames
, Length(BotNames
)+1);
1199 BotNames
[High(BotNames
)] := s
;
1207 // ×èòàåì ôàéë ñ ïàðàìåòðàìè áîòîâ:
1208 config
:= TConfig
.CreateFile(path
);
1212 while config
.SectionExists(IntToStr(a
)) do
1214 SetLength(BotList
, Length(BotList
)+1);
1216 with BotList
[High(BotList
)] do
1219 name
:= config
.ReadStr(IntToStr(a
), 'name', '');
1221 model
:= config
.ReadStr(IntToStr(a
), 'model', '');
1223 if config
.ReadStr(IntToStr(a
), 'team', 'red') = 'red' then
1228 sa
:= parse(config
.ReadStr(IntToStr(a
), 'color', ''));
1229 color
.R
:= StrToIntDef(sa
[0], 0);
1230 color
.G
:= StrToIntDef(sa
[1], 0);
1231 color
.B
:= StrToIntDef(sa
[2], 0);
1232 // Âåðîÿòíîñòü ñòðåëüáû ïîä óãëîì:
1233 diag_fire
:= config
.ReadInt(IntToStr(a
), 'diag_fire', 0);
1234 // Âåðîÿòíîñòü îòâåòíîãî îãíÿ ïî íåâèäèìîìó ñîïåðíèêó:
1235 invis_fire
:= config
.ReadInt(IntToStr(a
), 'invis_fire', 0);
1236 // Òî÷íîñòü ñòðåëüáû ïîä óãëîì:
1237 diag_precision
:= config
.ReadInt(IntToStr(a
), 'diag_precision', 0);
1238 // Òî÷íîñòü ñòðåëüáû â ïîëåòå:
1239 fly_precision
:= config
.ReadInt(IntToStr(a
), 'fly_precision', 0);
1240 // Òî÷íîñòü óêëîíåíèÿ îò ñíàðÿäîâ:
1241 cover
:= config
.ReadInt(IntToStr(a
), 'cover', 0);
1242 // Âåðîÿòíîñòü ïðûæêà ïðè ïðèáëèæåíèè ñîïåðíèêà:
1243 close_jump
:= config
.ReadInt(IntToStr(a
), 'close_jump', 0);
1244 // Ïðèîðèòåòû îðóæèÿ äëÿ äàëüíåãî áîÿ:
1245 sa
:= parse(config
.ReadStr(IntToStr(a
), 'w_prior1', ''));
1246 if Length(sa
) = 10 then
1248 w_prior1
[b
] := EnsureRange(StrToInt(sa
[b
]), 0, 9);
1249 // Ïðèîðèòåòû îðóæèÿ äëÿ áëèæíåãî áîÿ:
1250 sa
:= parse(config
.ReadStr(IntToStr(a
), 'w_prior2', ''));
1251 if Length(sa
) = 10 then
1253 w_prior2
[b
] := EnsureRange(StrToInt(sa
[b
]), 0, 9);
1255 {sa := parse(config.ReadStr(IntToStr(a), 'w_prior3', ''));
1256 if Length(sa) = 10 then
1258 w_prior3[b] := EnsureRange(StrToInt(sa[b]), 0, 9);}
1265 SetLength(SavedStates
, 0);
1268 procedure g_Player_Free();
1272 if gPlayers
<> nil then
1274 for i
:= 0 to High(gPlayers
) do
1275 if gPlayers
[i
] <> nil then
1277 if gPlayers
[i
] is TPlayer
then
1278 TPlayer(gPlayers
[i
]).Free()
1280 TBot(gPlayers
[i
]).Free();
1289 SetLength(SavedStates
, 0);
1292 procedure g_Player_PreUpdate();
1296 if gPlayers
= nil then Exit
;
1297 for i
:= 0 to High(gPlayers
) do
1298 if gPlayers
[i
] <> nil then
1299 gPlayers
[i
].PreUpdate();
1302 procedure g_Player_UpdateAll();
1306 if gPlayers
= nil then Exit
;
1308 //e_WriteLog('***g_Player_UpdateAll: ENTER', MSG_WARNING);
1309 for i
:= 0 to High(gPlayers
) do
1311 if gPlayers
[i
] <> nil then
1313 if gPlayers
[i
] is TPlayer
then
1315 gPlayers
[i
].Update();
1316 gPlayers
[i
].RealizeCurrentWeapon(); // WARNING! DO NOT MOVE THIS INTO `Update()`!
1320 // bot updates weapons in `UpdateCombat()`
1321 TBot(gPlayers
[i
]).Update();
1325 //e_WriteLog('***g_Player_UpdateAll: EXIT', MSG_WARNING);
1328 procedure g_Player_DrawAll();
1332 if gPlayers
= nil then Exit
;
1334 for i
:= 0 to High(gPlayers
) do
1335 if gPlayers
[i
] <> nil then
1336 if gPlayers
[i
] is TPlayer
then gPlayers
[i
].Draw()
1337 else TBot(gPlayers
[i
]).Draw();
1340 procedure g_Player_DrawDebug(p
: TPlayer
);
1344 if p
= nil then Exit
;
1345 if (@p
.FObj
) = nil then Exit
;
1347 e_TextureFontGetSize(gStdFont
, fW
, fH
);
1349 e_TextureFontPrint(0, 0 , 'Pos X: ' + IntToStr(p
.FObj
.X
), gStdFont
);
1350 e_TextureFontPrint(0, fH
, 'Pos Y: ' + IntToStr(p
.FObj
.Y
), gStdFont
);
1351 e_TextureFontPrint(0, fH
* 2, 'Vel X: ' + IntToStr(p
.FObj
.Vel
.X
), gStdFont
);
1352 e_TextureFontPrint(0, fH
* 3, 'Vel Y: ' + IntToStr(p
.FObj
.Vel
.Y
), gStdFont
);
1353 e_TextureFontPrint(0, fH
* 4, 'Acc X: ' + IntToStr(p
.FObj
.Accel
.X
), gStdFont
);
1354 e_TextureFontPrint(0, fH
* 5, 'Acc Y: ' + IntToStr(p
.FObj
.Accel
.Y
), gStdFont
);
1355 e_TextureFontPrint(0, fH
* 6, 'Old X: ' + IntToStr(p
.FObj
.oldX
), gStdFont
);
1356 e_TextureFontPrint(0, fH
* 7, 'Old Y: ' + IntToStr(p
.FObj
.oldY
), gStdFont
);
1359 procedure g_Player_DrawHealth();
1364 if gPlayers
= nil then Exit
;
1365 e_TextureFontGetSize(gStdFont
, fW
, fH
);
1367 for i
:= 0 to High(gPlayers
) do
1368 if gPlayers
[i
] <> nil then
1370 e_TextureFontPrint(gPlayers
[i
].FObj
.X
+ gPlayers
[i
].FObj
.Rect
.X
,
1371 gPlayers
[i
].FObj
.Y
+ gPlayers
[i
].FObj
.Rect
.Y
+ gPlayers
[i
].FObj
.Rect
.Height
- fH
* 2,
1372 IntToStr(gPlayers
[i
].FHealth
), gStdFont
);
1373 e_TextureFontPrint(gPlayers
[i
].FObj
.X
+ gPlayers
[i
].FObj
.Rect
.X
,
1374 gPlayers
[i
].FObj
.Y
+ gPlayers
[i
].FObj
.Rect
.Y
+ gPlayers
[i
].FObj
.Rect
.Height
- fH
,
1375 IntToStr(gPlayers
[i
].FArmor
), gStdFont
);
1379 function g_Player_Get(UID
: Word): TPlayer
;
1385 if gPlayers
= nil then
1388 for a
:= 0 to High(gPlayers
) do
1389 if gPlayers
[a
] <> nil then
1390 if gPlayers
[a
].FUID
= UID
then
1392 Result
:= gPlayers
[a
];
1397 function g_Player_GetCount(): Byte;
1403 if gPlayers
= nil then
1406 for a
:= 0 to High(gPlayers
) do
1407 if gPlayers
[a
] <> nil then
1408 Result
:= Result
+ 1;
1411 function g_Player_GetStats(): TPlayerStatArray
;
1417 if gPlayers
= nil then Exit
;
1419 for a
:= 0 to High(gPlayers
) do
1420 if gPlayers
[a
] <> nil then
1422 SetLength(Result
, Length(Result
)+1);
1423 with Result
[High(Result
)] do
1426 Ping
:= gPlayers
[a
].FPing
;
1427 Loss
:= gPlayers
[a
].FLoss
;
1428 Name
:= gPlayers
[a
].FName
;
1429 Team
:= gPlayers
[a
].FTeam
;
1430 Frags
:= gPlayers
[a
].FFrags
;
1431 Deaths
:= gPlayers
[a
].FDeath
;
1432 Kills
:= gPlayers
[a
].FKills
;
1433 Color
:= gPlayers
[a
].FModel
.Color
;
1434 Lives
:= gPlayers
[a
].FLives
;
1435 Spectator
:= gPlayers
[a
].FSpectator
;
1436 UID
:= gPlayers
[a
].FUID
;
1441 procedure g_Player_ResetReady();
1445 if not g_Game_IsServer
then Exit
;
1446 if gPlayers
= nil then Exit
;
1448 for a
:= 0 to High(gPlayers
) do
1449 if gPlayers
[a
] <> nil then
1451 gPlayers
[a
].FReady
:= False;
1452 if g_Game_IsNet
then
1453 MH_SEND_GameEvent(NET_EV_INTER_READY
, gPlayers
[a
].UID
, 'N');
1457 procedure g_Player_RememberAll
;
1461 for i
:= Low(gPlayers
) to High(gPlayers
) do
1462 if (gPlayers
[i
] <> nil) and gPlayers
[i
].alive
then
1463 gPlayers
[i
].RememberState
;
1466 procedure g_Player_ResetAll(Force
, Silent
: Boolean);
1470 gTeamStat
[TEAM_RED
].Goals
:= 0;
1471 gTeamStat
[TEAM_BLUE
].Goals
:= 0;
1473 if gPlayers
<> nil then
1474 for i
:= 0 to High(gPlayers
) do
1475 if gPlayers
[i
] <> nil then
1477 gPlayers
[i
].Reset(Force
);
1479 if gPlayers
[i
] is TPlayer
then
1481 if (not gPlayers
[i
].FSpectator
) or gPlayers
[i
].FWantsInGame
then
1482 gPlayers
[i
].Respawn(Silent
)
1484 gPlayers
[i
].Spectate();
1487 TBot(gPlayers
[i
]).Respawn(Silent
);
1491 function g_Player_CreateCorpse(Player
: TPlayer
): Integer;
1499 if Player
.alive
then
1502 // Ðàçðûâàåì ñâÿçü ñ ïðåæíèì òðóïîì:
1503 i
:= Player
.FCorpse
;
1504 if (i
>= 0) and (i
< Length(gCorpses
)) then
1506 if (gCorpses
[i
] <> nil) and (gCorpses
[i
].FPlayerUID
= Player
.FUID
) then
1507 gCorpses
[i
].FPlayerUID
:= 0;
1510 if Player
.FObj
.Y
>= gMapInfo
.Height
+128 then
1515 if (FHealth
>= -50) or (gGibsCount
= 0) then
1517 if (gCorpses
= nil) or (Length(gCorpses
) = 0) then
1521 for find_id
:= 0 to High(gCorpses
) do
1522 if gCorpses
[find_id
] = nil then
1529 find_id
:= Random(Length(gCorpses
));
1531 gCorpses
[find_id
] := TCorpse
.Create(FObj
.X
, FObj
.Y
, FModel
.Name
, FHealth
< -20);
1532 gCorpses
[find_id
].FColor
:= FModel
.Color
;
1533 gCorpses
[find_id
].FObj
.Vel
:= FObj
.Vel
;
1534 gCorpses
[find_id
].FObj
.Accel
:= FObj
.Accel
;
1535 gCorpses
[find_id
].FPlayerUID
:= FUID
;
1540 g_Player_CreateGibs(FObj
.X
+ PLAYER_RECT_CX
,
1541 FObj
.Y
+ PLAYER_RECT_CY
,
1542 FModel
.Name
, FModel
.Color
);
1546 procedure g_Player_CreateShell(fX
, fY
, dX
, dY
: Integer; T
: Byte);
1550 if (gShells
= nil) or (Length(gShells
) = 0) then
1553 with gShells
[CurrentShell
] do
1559 if T
= SHELL_BULLET
then
1561 if g_Texture_Get('TEXTURE_SHELL_BULLET', SID
) then
1565 Obj
.Rect
.Width
:= 4;
1566 Obj
.Rect
.Height
:= 2;
1570 if g_Texture_Get('TEXTURE_SHELL_SHELL', SID
) then
1574 Obj
.Rect
.Width
:= 7;
1575 Obj
.Rect
.Height
:= 3;
1581 g_Obj_Push(@Obj
, dX
+ Random(4)-Random(4), dY
-Random(4));
1582 positionChanged(); // this updates spatial accelerators
1583 RAngle
:= Random(360);
1584 Timeout
:= gTime
+ SHELL_TIMEOUT
;
1586 if CurrentShell
>= High(gShells
) then
1593 procedure g_Player_CreateGibs(fX
, fY
: Integer; ModelName
: string; fColor
: TRGB
);
1596 GibsArray
: TGibsArray
;
1599 if (gGibs
= nil) or (Length(gGibs
) = 0) then
1601 if not g_PlayerModel_GetGibs(ModelName
, GibsArray
) then
1603 Blood
:= g_PlayerModel_GetBlood(ModelName
);
1605 for a
:= 0 to High(GibsArray
) do
1606 with gGibs
[CurrentGib
] do
1609 ID
:= GibsArray
[a
].ID
;
1610 MaskID
:= GibsArray
[a
].MaskID
;
1613 Obj
.Rect
:= GibsArray
[a
].Rect
;
1614 Obj
.X
:= fX
-GibsArray
[a
].Rect
.X
-(GibsArray
[a
].Rect
.Width
div 2);
1615 Obj
.Y
:= fY
-GibsArray
[a
].Rect
.Y
-(GibsArray
[a
].Rect
.Height
div 2);
1616 g_Obj_PushA(@Obj
, 25 + Random(10), Random(361));
1617 positionChanged(); // this updates spatial accelerators
1618 RAngle
:= Random(360);
1620 if gBloodCount
> 0 then
1621 g_GFX_Blood(fX
, fY
, 16*gBloodCount
+Random(5*gBloodCount
), -16+Random(33), -16+Random(33),
1622 Random(48), Random(48), Blood
.R
, Blood
.G
, Blood
.B
, Blood
.Kind
);
1624 if CurrentGib
>= High(gGibs
) then
1631 procedure g_Player_UpdatePhysicalObjects();
1637 procedure ShellSound_Bounce(X
, Y
: Integer; T
: Byte);
1642 if T
= SHELL_BULLET
then
1643 g_Sound_PlayExAt('SOUND_PLAYER_CASING' + IntToStr(k
), X
, Y
)
1645 g_Sound_PlayExAt('SOUND_PLAYER_SHELL' + IntToStr(k
), X
, Y
);
1650 if gGibs
<> nil then
1651 for i
:= 0 to High(gGibs
) do
1652 if gGibs
[i
].alive
then
1659 mr
:= g_Obj_Move(@Obj
, True, False, True);
1660 positionChanged(); // this updates spatial accelerators
1662 if WordBool(mr
and MOVE_FALLOUT
) then
1668 // Îòëåòàåò îò óäàðà î ñòåíó/ïîòîëîê/ïîë:
1669 if WordBool(mr
and MOVE_HITWALL
) then
1670 Obj
.Vel
.X
:= -(vel
.X
div 2);
1671 if WordBool(mr
and (MOVE_HITCEIL
or MOVE_HITLAND
)) then
1672 Obj
.Vel
.Y
:= -(vel
.Y
div 2);
1674 if (Obj
.Vel
.X
>= 0) then
1676 RAngle
:= RAngle
+ Abs(Obj
.Vel
.X
)*6 + Abs(Obj
.Vel
.Y
);
1677 if RAngle
>= 360 then
1678 RAngle
:= RAngle
mod 360;
1679 end else begin // Counter-clockwise
1680 RAngle
:= RAngle
- Abs(Obj
.Vel
.X
)*6 - Abs(Obj
.Vel
.Y
);
1682 RAngle
:= (360 - (Abs(RAngle
) mod 360)) mod 360;
1685 // Ñîïðîòèâëåíèå âîçäóõà äëÿ êóñêà òðóïà:
1686 if gTime
mod (GAME_TICK
*3) = 0 then
1687 Obj
.Vel
.X
:= z_dec(Obj
.Vel
.X
, 1);
1691 if gCorpses
<> nil then
1692 for i
:= 0 to High(gCorpses
) do
1693 if gCorpses
[i
] <> nil then
1694 if gCorpses
[i
].State
= CORPSE_STATE_REMOVEME
then
1700 gCorpses
[i
].Update();
1703 if gShells
<> nil then
1704 for i
:= 0 to High(gShells
) do
1705 if gShells
[i
].alive
then
1712 mr
:= g_Obj_Move(@Obj
, True, False, True);
1713 positionChanged(); // this updates spatial accelerators
1715 if WordBool(mr
and MOVE_FALLOUT
) or (gShells
[i
].Timeout
< gTime
) then
1721 // Îòëåòàåò îò óäàðà î ñòåíó/ïîòîëîê/ïîë:
1722 if WordBool(mr
and MOVE_HITWALL
) then
1724 Obj
.Vel
.X
:= -(vel
.X
div 2);
1725 if not WordBool(mr
and MOVE_INWATER
) then
1726 ShellSound_Bounce(Obj
.X
, Obj
.Y
, SType
);
1728 if WordBool(mr
and (MOVE_HITCEIL
or MOVE_HITLAND
)) then
1730 Obj
.Vel
.Y
:= -(vel
.Y
div 2);
1731 if Obj
.Vel
.X
<> 0 then Obj
.Vel
.X
:= Obj
.Vel
.X
div 2;
1732 if (Obj
.Vel
.X
= 0) and (Obj
.Vel
.Y
= 0) then
1734 if RAngle
mod 90 <> 0 then
1735 RAngle
:= (RAngle
div 90) * 90;
1737 else if not WordBool(mr
and MOVE_INWATER
) then
1738 ShellSound_Bounce(Obj
.X
, Obj
.Y
, SType
);
1741 if (Obj
.Vel
.X
>= 0) then
1743 RAngle
:= RAngle
+ Abs(Obj
.Vel
.X
)*8 + Abs(Obj
.Vel
.Y
);
1744 if RAngle
>= 360 then
1745 RAngle
:= RAngle
mod 360;
1746 end else begin // Counter-clockwise
1747 RAngle
:= RAngle
- Abs(Obj
.Vel
.X
)*8 - Abs(Obj
.Vel
.Y
);
1749 RAngle
:= (360 - (Abs(RAngle
) mod 360)) mod 360;
1755 procedure TGib
.getMapBox (out x
, y
, w
, h
: Integer); inline;
1757 x
:= Obj
.X
+Obj
.Rect
.X
;
1758 y
:= Obj
.Y
+Obj
.Rect
.Y
;
1759 w
:= Obj
.Rect
.Width
;
1760 h
:= Obj
.Rect
.Height
;
1763 procedure TGib
.moveBy (dx
, dy
: Integer); inline;
1765 if (dx
<> 0) or (dy
<> 0) then
1774 procedure TShell
.getMapBox (out x
, y
, w
, h
: Integer); inline;
1778 w
:= Obj
.Rect
.Width
;
1779 h
:= Obj
.Rect
.Height
;
1782 procedure TShell
.moveBy (dx
, dy
: Integer); inline;
1784 if (dx
<> 0) or (dy
<> 0) then
1793 procedure TGib
.positionChanged (); inline; begin end;
1794 procedure TShell
.positionChanged (); inline; begin end;
1797 procedure g_Player_DrawCorpses();
1802 if gGibs
<> nil then
1803 for i
:= 0 to High(gGibs
) do
1804 if gGibs
[i
].alive
then
1807 if not g_Obj_Collide(sX
, sY
, sWidth
, sHeight
, @Obj
) then
1810 Obj
.lerp(gLerpFactor
, fX
, fY
);
1812 a
.X
:= Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2);
1813 a
.y
:= Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2);
1815 e_DrawAdv(ID
, fX
, fY
, 0, True, False, RAngle
, @a
, TMirrorType
.None
);
1818 e_DrawAdv(MaskID
, fX
, fY
, 0, True, False, RAngle
, @a
, TMirrorType
.None
);
1824 if gCorpses
<> nil then
1825 for i
:= 0 to High(gCorpses
) do
1826 if gCorpses
[i
] <> nil then
1830 procedure g_Player_DrawShells();
1835 if gShells
<> nil then
1836 for i
:= 0 to High(gShells
) do
1837 if gShells
[i
].alive
then
1840 if not g_Obj_Collide(sX
, sY
, sWidth
, sHeight
, @Obj
) then
1843 Obj
.lerp(gLerpFactor
, fX
, fY
);
1848 e_DrawAdv(SpriteID
, fX
, fY
, 0, True, False, RAngle
, @a
, TMirrorType
.None
);
1852 procedure g_Player_RemoveAllCorpses();
1858 SetLength(gGibs
, MaxGibs
);
1859 SetLength(gShells
, MaxGibs
);
1863 if gCorpses
<> nil then
1864 for i
:= 0 to High(gCorpses
) do
1868 SetLength(gCorpses
, MaxCorpses
);
1871 procedure g_Player_Corpses_SaveState (st
: TStream
);
1875 // Ñ÷èòàåì êîëè÷åñòâî ñóùåñòâóþùèõ òðóïîâ
1877 for i
:= 0 to High(gCorpses
) do if (gCorpses
[i
] <> nil) then Inc(count
);
1879 // Êîëè÷åñòâî òðóïîâ
1880 utils
.writeInt(st
, LongInt(count
));
1882 if (count
= 0) then exit
;
1885 for i
:= 0 to High(gCorpses
) do
1887 if gCorpses
[i
] <> nil then
1890 utils
.writeStr(st
, gCorpses
[i
].FModelName
);
1892 utils
.writeBool(st
, gCorpses
[i
].Mess
);
1893 // Ñîõðàíÿåì äàííûå òðóïà:
1894 gCorpses
[i
].SaveState(st
);
1900 procedure g_Player_Corpses_LoadState (st
: TStream
);
1908 g_Player_RemoveAllCorpses();
1910 // Êîëè÷åñòâî òðóïîâ:
1911 count
:= utils
.readLongInt(st
);
1912 if (count
< 0) or (count
> Length(gCorpses
)) then raise XStreamError
.Create('invalid number of corpses');
1914 if (count
= 0) then exit
;
1917 for i
:= 0 to count
-1 do
1920 str
:= utils
.readStr(st
);
1922 b
:= utils
.readBool(st
);
1924 gCorpses
[i
] := TCorpse
.Create(0, 0, str
, b
);
1925 // Çàãðóæàåì äàííûå òðóïà
1926 gCorpses
[i
].LoadState(st
);
1933 function TPlayer
.isValidViewPort (): Boolean; inline; begin result
:= (viewPortW
> 0) and (viewPortH
> 0); end;
1935 procedure TPlayer
.BFGHit();
1937 g_Weapon_BFGHit(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
1938 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2));
1939 if g_Game_IsServer
and g_Game_IsNet
then
1940 MH_SEND_Effect(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
1941 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2),
1945 procedure TPlayer
.ChangeModel(ModelName
: string);
1947 locModel
: TPlayerModel
;
1949 locModel
:= g_PlayerModel_Get(ModelName
);
1950 if locModel
= nil then Exit
;
1956 procedure TPlayer
.SetModel(ModelName
: string);
1960 m
:= g_PlayerModel_Get(ModelName
);
1963 g_SimpleError(Format(_lc
[I_GAME_ERROR_MODEL_FALLBACK
], [ModelName
]));
1964 m
:= g_PlayerModel_Get('doomer');
1967 g_FatalError(Format(_lc
[I_GAME_ERROR_MODEL
], ['doomer']));
1972 if FModel
<> nil then
1977 if not (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then
1978 FModel
.Color
:= FColor
1980 FModel
.Color
:= TEAMCOLOR
[FTeam
];
1981 FModel
.SetWeapon(FCurrWeap
);
1982 FModel
.SetFlag(FFlag
);
1983 SetDirection(FDirection
);
1986 procedure TPlayer
.SetColor(Color
: TRGB
);
1989 if not (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then
1990 if FModel
<> nil then FModel
.Color
:= Color
;
1995 function TPlayer
.GetColor(): TRGB
;
1997 result
:= FModel
.Color
;
2000 procedure TPlayer
.SetWeaponPrefs(Prefs
: Array of Byte);
2004 for i
:= WP_FIRST
to WP_LAST
+ 1 do
2006 if (Prefs
[i
] > WP_LAST
+ 1) then
2007 FWeapPreferences
[i
] := 0
2009 FWeapPreferences
[i
] := Prefs
[i
];
2013 procedure TPlayer
.SetWeaponPref(Weapon
, Pref
: Byte);
2015 if (Weapon
> WP_LAST
+ 1) then
2017 else if (Pref
<= WP_LAST
+ 1) and (Weapon
<= WP_LAST
+ 1) then
2018 FWeapPreferences
[Weapon
] := Pref
2019 else if (Weapon
<= WP_LAST
+ 1) and (Pref
> WP_LAST
+ 1) then
2020 FWeapPreferences
[Weapon
] := 0;
2023 function TPlayer
.GetWeaponPref(Weapon
: Byte) : Byte;
2025 if (Weapon
> WP_LAST
+ 1) then
2027 else if (FWeapPreferences
[Weapon
] > WP_LAST
+ 1) then
2030 result
:= FWeapPreferences
[Weapon
];
2033 function TPlayer
.GetMorePrefered() : Byte;
2035 testedWeap
, i
: Byte;
2037 testedWeap
:= FCurrWeap
;
2038 for i
:= WP_FIRST
to WP_LAST
do
2039 if FWeapon
[i
] and maySwitch(i
) and (FWeapPreferences
[i
] > FWeapPreferences
[testedWeap
]) then
2041 if (R_BERSERK
in FRulez
) and (FWeapPreferences
[WP_LAST
+ 1] > FWeapPreferences
[testedWeap
]) then
2042 testedWeap
:= WEAPON_KASTET
;
2043 result
:= testedWeap
;
2046 function TPlayer
.maySwitch(Weapon
: Byte) : Boolean;
2049 if (Weapon
= WEAPON_KASTET
) and (FSkipFist
<> 0) then
2051 if (FSkipFist
= 1) and (not (R_BERSERK
in FRulez
)) then
2054 else if (FSwitchToEmpty
= 0) and (not hasAmmoForShooting(Weapon
)) then
2058 procedure TPlayer
.SwitchTeam
;
2060 if g_Game_IsClient
then
2062 if not (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then Exit
;
2064 if gGameOn
and FAlive
then
2065 Kill(K_SIMPLEKILL
, FUID
, HIT_SELF
);
2067 if FTeam
= TEAM_RED
then
2069 ChangeTeam(TEAM_BLUE
);
2070 g_Console_Add(Format(_lc
[I_PLAYER_CHTEAM_BLUE
], [FName
]), True);
2071 if g_Game_IsNet
then
2072 MH_SEND_GameEvent(NET_EV_CHANGE_TEAM
, TEAM_BLUE
, FName
);
2076 ChangeTeam(TEAM_RED
);
2077 g_Console_Add(Format(_lc
[I_PLAYER_CHTEAM_RED
], [FName
]), True);
2078 if g_Game_IsNet
then
2079 MH_SEND_GameEvent(NET_EV_CHANGE_TEAM
, TEAM_RED
, FName
);
2081 FPreferredTeam
:= FTeam
;
2084 procedure TPlayer
.ChangeTeam(Team
: Byte);
2091 TEAM_RED
, TEAM_BLUE
:
2092 FModel
.Color
:= TEAMCOLOR
[Team
];
2094 FModel
.Color
:= FColor
;
2096 if (FTeam
<> OldTeam
) and g_Game_IsNet
and g_Game_IsServer
then
2097 MH_SEND_PlayerStats(FUID
);
2101 procedure TPlayer.CollideItem();
2106 if gItems = nil then Exit;
2107 if not FAlive then Exit;
2109 for i := 0 to High(gItems) do
2112 if (ItemType <> ITEM_NONE) and alive then
2113 if g_Obj_Collide(FObj.X+PLAYER_RECT.X, FObj.Y+PLAYER_RECT.Y, PLAYER_RECT.Width,
2114 PLAYER_RECT.Height, @Obj) then
2116 if not PickItem(ItemType, gItems[i].Respawnable, r) then Continue;
2118 if ItemType in [ITEM_SPHERE_BLUE, ITEM_SPHERE_WHITE, ITEM_INVUL] then
2119 g_Sound_PlayExAt('SOUND_ITEM_GETRULEZ', FObj.X, FObj.Y)
2120 else if ItemType in [ITEM_MEDKIT_SMALL, ITEM_MEDKIT_LARGE, ITEM_MEDKIT_BLACK] then
2121 g_Sound_PlayExAt('SOUND_ITEM_GETMED', FObj.X, FObj.Y)
2122 else g_Sound_PlayExAt('SOUND_ITEM_GETITEM', FObj.X, FObj.Y);
2124 // Íàäî óáðàòü ñ êàðòû, åñëè ýòî íå êëþ÷, êîòîðûì íóæíî ïîäåëèòñÿ ñ äðóãèì èãðîêîì:
2125 if r and not ((ItemType in [ITEM_KEY_RED, ITEM_KEY_GREEN, ITEM_KEY_BLUE]) and
2126 (gGameSettings.GameType = GT_SINGLE) and
2127 (g_Player_GetCount() > 1)) then
2128 if not Respawnable then g_Items_Remove(i) else g_Items_Pick(i);
2134 function TPlayer
.CollideLevel(XInc
, YInc
: Integer): Boolean;
2136 Result
:= g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
,
2137 PLAYER_RECT
.Width
, PLAYER_RECT
.Height
, PANEL_WALL
,
2141 constructor TPlayer
.Create();
2147 mEDamageType
:= HIT_SOME
;
2153 FSawSound
:= TPlayableSound
.Create();
2154 FSawSoundIdle
:= TPlayableSound
.Create();
2155 FSawSoundHit
:= TPlayableSound
.Create();
2156 FSawSoundSelect
:= TPlayableSound
.Create();
2157 FFlameSoundOn
:= TPlayableSound
.Create();
2158 FFlameSoundOff
:= TPlayableSound
.Create();
2159 FFlameSoundWork
:= TPlayableSound
.Create();
2160 FJetSoundFly
:= TPlayableSound
.Create();
2161 FJetSoundOn
:= TPlayableSound
.Create();
2162 FJetSoundOff
:= TPlayableSound
.Create();
2164 FSawSound
.SetByName('SOUND_WEAPON_FIRESAW');
2165 FSawSoundIdle
.SetByName('SOUND_WEAPON_IDLESAW');
2166 FSawSoundHit
.SetByName('SOUND_WEAPON_HITSAW');
2167 FSawSoundSelect
.SetByName('SOUND_WEAPON_SELECTSAW');
2168 FFlameSoundOn
.SetByName('SOUND_WEAPON_FLAMEON');
2169 FFlameSoundOff
.SetByName('SOUND_WEAPON_FLAMEOFF');
2170 FFlameSoundWork
.SetByName('SOUND_WEAPON_FLAMEWORK');
2171 FJetSoundFly
.SetByName('SOUND_PLAYER_JETFLY');
2172 FJetSoundOn
.SetByName('SOUND_PLAYER_JETON');
2173 FJetSoundOff
.SetByName('SOUND_PLAYER_JETOFF');
2175 FSpectatePlayer
:= -1;
2179 FSavedStateNum
:= -1;
2187 FActualModelName
:= 'doomer';
2190 FObj
.Rect
:= PLAYER_RECT
;
2192 FBFGFireCounter
:= -1;
2193 FJustTeleported
:= False;
2196 FWaitForFirstSpawn
:= false;
2201 procedure TPlayer
.positionChanged (); inline;
2205 procedure TPlayer
.doDamage (v
: Integer);
2207 if (v
<= 0) then exit
;
2208 if (v
> 32767) then v
:= 32767;
2209 Damage(v
, 0, 0, 0, mEDamageType
);
2212 procedure TPlayer
.Damage(value
: Word; SpawnerUID
: Word; vx
, vy
: Integer; t
: Byte);
2216 if (not g_Game_IsClient
) and (not FAlive
) then
2221 // Íåóÿçâèìîñòü íå ñïàñàåò îò ëîâóøåê:
2222 if ((t
= HIT_TRAP
) or (t
= HIT_SELF
)) and (not FGodMode
) then
2224 if not g_Game_IsClient
then
2227 if t
= HIT_TRAP
then
2229 // Ëîâóøêà óáèâàåò ñðàçó:
2231 Kill(K_EXTRAHARDKILL
, SpawnerUID
, t
);
2233 if t
= HIT_SELF
then
2237 Kill(K_SIMPLEKILL
, SpawnerUID
, t
);
2240 // Îáíóëèòü äåéñòâèÿ ïðèìî÷åê, ÷òîáû ôîí ïðîïàë
2241 FMegaRulez
[MR_SUIT
] := 0;
2242 FMegaRulez
[MR_INVUL
] := 0;
2243 FMegaRulez
[MR_INVIS
] := 0;
2248 // Íî îò îñòàëüíîãî ñïàñàåò:
2249 if FMegaRulez
[MR_INVUL
] >= gTime
then
2256 // Åñëè åñòü óðîí ñâîèì, èëè ðàíèë ñàì ñåáÿ, èëè òåáÿ ðàíèë ïðîòèâíèê:
2257 if LongBool(gGameSettings
.Options
and GAME_OPTION_TEAMDAMAGE
) or
2258 (SpawnerUID
= FUID
) or
2259 (not SameTeam(FUID
, SpawnerUID
)) then
2261 FLastSpawnerUID
:= SpawnerUID
;
2263 // Êðîâü (ïóçûðüêè, åñëè â âîäå):
2264 if gBloodCount
> 0 then
2266 c
:= Min(value
, 200)*gBloodCount
+ Random(Min(value
, 200) div 2);
2267 if value
div 4 <= c
then
2268 c
:= c
- (value
div 4)
2272 if (t
= HIT_SOME
) and (vx
= 0) and (vy
= 0) then
2276 HIT_TRAP
, HIT_ACID
, HIT_FLAME
, HIT_SELF
: MakeBloodSimple(c
);
2277 HIT_BFG
, HIT_ROCKET
, HIT_SOME
: MakeBloodVector(c
, vx
, vy
);
2280 if t
= HIT_WATER
then
2281 g_GFX_Bubbles(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2),
2282 FObj
.Y
+PLAYER_RECT
.Y
-4, value
div 2, 8, 4);
2287 Inc(FDamageBuffer
, value
);
2291 FPain
:= FPain
+ value
;
2294 if g_Game_IsServer
and g_Game_IsNet
then
2296 MH_SEND_PlayerDamage(FUID
, t
, SpawnerUID
, value
, vx
, vy
);
2297 MH_SEND_PlayerStats(FUID
);
2298 MH_SEND_PlayerPos(False, FUID
);
2302 function TPlayer
.Heal(value
: Word; Soft
: Boolean): Boolean;
2305 if g_Game_IsClient
then
2310 if Soft
and (FHealth
< PLAYER_HP_SOFT
) then
2312 IncMax(FHealth
, value
, PLAYER_HP_SOFT
);
2315 if (not Soft
) and (FHealth
< PLAYER_HP_LIMIT
) then
2317 IncMax(FHealth
, value
, PLAYER_HP_LIMIT
);
2321 if Result
and g_Game_IsServer
and g_Game_IsNet
then
2322 MH_SEND_PlayerStats(FUID
);
2325 destructor TPlayer
.Destroy();
2327 if (gPlayer1
<> nil) and (gPlayer1
.FUID
= FUID
) then
2329 if (gPlayer2
<> nil) and (gPlayer2
.FUID
= FUID
) then
2333 FSawSoundIdle
.Free();
2334 FSawSoundHit
.Free();
2335 FSawSoundSelect
.Free();
2336 FFlameSoundOn
.Free();
2337 FFlameSoundOff
.Free();
2338 FFlameSoundWork
.Free();
2339 FJetSoundFly
.Free();
2341 FJetSoundOff
.Free();
2343 if FPunchAnim
<> nil then
2349 procedure TPlayer
.DrawIndicator(Color
: TRGB
);
2351 indX
, indY
, fX
, fY
, fSlope
: Integer;
2361 FObj
.lerp(gLerpFactor
, fX
, fY
);
2362 fSlope
:= nlerp(FSlopeOld
, FObj
.slopeUpLeft
, gLerpFactor
);
2364 case gPlayerIndicatorStyle
of
2367 if g_Texture_Get('TEXTURE_PLAYER_INDICATOR', ID
) then
2369 e_GetTextureSize(ID
, @indW
, @indH
);
2373 if (FObj
.X
+ FObj
.Rect
.X
) < 0 then
2376 indX
:= fX
+ FObj
.Rect
.X
+ FObj
.Rect
.Width
;
2377 indY
:= fY
+ FObj
.Rect
.Y
+ (FObj
.Rect
.Height
- indW
) div 2;
2380 else if (FObj
.X
+ FObj
.Rect
.X
+ FObj
.Rect
.Width
) > Max(gMapInfo
.Width
, gPlayerScreenSize
.X
) then
2383 indX
:= fX
+ FObj
.Rect
.X
- indH
;
2384 indY
:= fY
+ FObj
.Rect
.Y
+ (FObj
.Rect
.Height
- indW
) div 2;
2387 else if (FObj
.Y
- indH
) < 0 then
2390 indX
:= fX
+ FObj
.Rect
.X
+ (FObj
.Rect
.Width
- indW
) div 2;
2391 indY
:= fY
+ FObj
.Rect
.Y
+ FObj
.Rect
.Height
;
2397 indX
:= fX
+ FObj
.Rect
.X
+ (FObj
.Rect
.Width
- indW
) div 2;
2401 indY
:= indY
+ fSlope
;
2402 indX
:= EnsureRange(indX
, 0, Max(gMapInfo
.Width
, gPlayerScreenSize
.X
) - indW
);
2403 indY
:= EnsureRange(indY
, 0, Max(gMapInfo
.Height
, gPlayerScreenSize
.Y
) - indH
);
2407 e_DrawAdv(ID
, indX
, indY
, 0, True, False, indA
, @a
);
2414 e_TextureFontGetSize(gStdFont
, nW
, nH
);
2415 indX
:= fX
+ FObj
.Rect
.X
+ (FObj
.Rect
.Width
- Length(FName
) * nW
) div 2;
2416 indY
:= fY
- nH
+ fSlope
;
2417 e_TextureFontPrintEx(indX
, indY
, FName
, gStdFont
, Color
.R
, Color
.G
, Color
.B
, 1.0, True);
2423 procedure TPlayer
.DrawBubble();
2425 bubX
, bubY
, fX
, fY
: Integer;
2428 Rw
, Gw
, Bw
: SmallInt;
2432 CObj
:= getCameraObj();
2433 CObj
.lerp(gLerpFactor
, fX
, fY
);
2434 // NB: _F_Obj.Rect is used to keep the bubble higher; this is not a mistake
2435 bubX
:= fX
+FObj
.Rect
.X
+ IfThen(FDirection
= TDirection
.D_LEFT
, -4, 18);
2436 bubY
:= fY
+FObj
.Rect
.Y
- 18;
2444 1: // simple textual non-bubble
2446 bubX
:= fX
+FObj
.Rect
.X
- 11;
2447 bubY
:= fY
+FObj
.Rect
.Y
- 17;
2448 e_TextureFontPrint(bubX
, bubY
, '[...]', gStdFont
);
2451 2: // advanced pixel-perfect bubble
2453 if FTeam
= TEAM_RED
then
2456 if FTeam
= TEAM_BLUE
then
2459 3: // colored bubble
2461 Rb
:= FModel
.Color
.R
;
2462 Gb
:= FModel
.Color
.G
;
2463 Bb
:= FModel
.Color
.B
;
2464 Rw
:= Min(Rb
* 2 + 64, 255);
2465 Gw
:= Min(Gb
* 2 + 64, 255);
2466 Bw
:= Min(Bb
* 2 + 64, 255);
2467 if (Abs(Rw
- Rb
) < 32)
2468 or (Abs(Gw
- Gb
) < 32)
2469 or (Abs(Bw
- Bb
) < 32) then
2471 Rb
:= Max(Rw
div 2 - 16, 0);
2472 Gb
:= Max(Gw
div 2 - 16, 0);
2473 Bb
:= Max(Bw
div 2 - 16, 0);
2476 4: // custom textured bubble
2478 if g_Texture_Get('TEXTURE_PLAYER_TALKBUBBLE', ID
) then
2479 if FDirection
= TDirection
.D_RIGHT
then
2480 e_Draw(ID
, bubX
- 6, bubY
- 7, 0, True, False)
2482 e_Draw(ID
, bubX
- 6, bubY
- 7, 0, True, False, TMirrorType
.Horizontal
);
2488 e_DrawQuad(bubX
+ 1, bubY
, bubX
+ 18, bubY
+ 13, Rb
, Gb
, Bb
);
2489 e_DrawQuad(bubX
, bubY
+ 1, bubX
+ 19, bubY
+ 12, Rb
, Gb
, Bb
);
2491 e_DrawFillQuad(bubX
+ 1, bubY
+ 1, bubX
+ 18, bubY
+ 12, Rw
, Gw
, Bw
, 0);
2494 Dot
:= IfThen(FDirection
= TDirection
.D_LEFT
, 14, 5);
2495 e_DrawLine(1, bubX
+ Dot
, bubY
+ 14, bubX
+ Dot
, bubY
+ 16, Rb
, Gb
, Bb
);
2496 e_DrawLine(1, bubX
+ IfThen(FDirection
= TDirection
.D_LEFT
, Dot
- 1, Dot
+ 1), bubY
+ 13, bubX
+ IfThen(FDirection
= TDirection
.D_LEFT
, Dot
- 1, Dot
+ 1), bubY
+ 15, Rw
, Gw
, Bw
);
2497 e_DrawLine(1, bubX
+ IfThen(FDirection
= TDirection
.D_LEFT
, Dot
- 2, Dot
+ 2), bubY
+ 13, bubX
+ IfThen(FDirection
= TDirection
.D_LEFT
, Dot
- 2, Dot
+ 2), bubY
+ 14, Rw
, Gw
, Bw
);
2498 e_DrawLine(1, bubX
+ IfThen(FDirection
= TDirection
.D_LEFT
, Dot
- 3, Dot
+ 3), bubY
+ 13, bubX
+ IfThen(FDirection
= TDirection
.D_LEFT
, Dot
- 3, Dot
+ 3), bubY
+ 13, Rw
, Gw
, Bw
);
2499 e_DrawLine(1, bubX
+ IfThen(FDirection
= TDirection
.D_LEFT
, Dot
- 3, Dot
+ 3), bubY
+ 14, bubX
+ IfThen(FDirection
= TDirection
.D_LEFT
, Dot
- 1, Dot
+ 1), bubY
+ 16, Rb
, Gb
, Bb
);
2503 e_DrawFillQuad(bubX
+ Dot
, bubY
+ 8, bubX
+ Dot
+ 1, bubY
+ 9, Rb
, Gb
, Bb
, 0);
2504 e_DrawFillQuad(bubX
+ Dot
+ 3, bubY
+ 8, bubX
+ Dot
+ 4, bubY
+ 9, Rb
, Gb
, Bb
, 0);
2505 e_DrawFillQuad(bubX
+ Dot
+ 6, bubY
+ 8, bubX
+ Dot
+ 7, bubY
+ 9, Rb
, Gb
, Bb
, 0);
2508 procedure TPlayer
.Draw();
2513 Mirror
: TMirrorType
;
2514 fX
, fY
, fSlope
: Integer;
2516 FObj
.lerp(gLerpFactor
, fX
, fY
);
2517 fSlope
:= nlerp(FSlopeOld
, FObj
.slopeUpLeft
, gLerpFactor
);
2521 if Direction
= TDirection
.D_RIGHT
then
2522 Mirror
:= TMirrorType
.None
2524 Mirror
:= TMirrorType
.Horizontal
;
2526 if FPunchAnim
<> nil then
2528 FPunchAnim
.Draw(fX
+IfThen(Direction
= TDirection
.D_LEFT
, 15-FObj
.Rect
.X
, FObj
.Rect
.X
-15),
2529 fY
+fSlope
+FObj
.Rect
.Y
-11, Mirror
);
2530 if FPunchAnim
.played
then
2537 if (FMegaRulez
[MR_INVUL
] > gTime
) and ((gPlayerDrawn
<> Self
) or (FSpawnInvul
>= gTime
)) then
2538 if g_Texture_Get('TEXTURE_PLAYER_INVULPENTA', ID
) then
2540 e_GetTextureSize(ID
, @w
, @h
);
2541 if FDirection
= TDirection
.D_LEFT
then
2542 e_Draw(ID
, fX
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2)-(w
div 2)+4,
2543 fY
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2)-(h
div 2)-7+fSlope
, 0, True, False)
2545 e_Draw(ID
, fX
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2)-(w
div 2)-2,
2546 fY
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2)-(h
div 2)-7+fSlope
, 0, True, False);
2549 if FMegaRulez
[MR_INVIS
] > gTime
then
2551 if (gPlayerDrawn
<> nil) and ((Self
= gPlayerDrawn
) or
2552 ((FTeam
= gPlayerDrawn
.Team
) and (gGameSettings
.GameMode
<> GM_DM
))) then
2554 if (FMegaRulez
[MR_INVIS
] - gTime
) <= 2100 then
2555 dr
:= not Odd((FMegaRulez
[MR_INVIS
] - gTime
) div 300)
2559 FModel
.Draw(fX
, fY
+fSlope
, 200)
2561 FModel
.Draw(fX
, fY
+fSlope
);
2564 FModel
.Draw(fX
, fY
+fSlope
, 254);
2567 FModel
.Draw(fX
, fY
+fSlope
);
2570 if g_debug_Frames
then
2572 e_DrawQuad(FObj
.X
+FObj
.Rect
.X
,
2574 FObj
.X
+FObj
.Rect
.X
+FObj
.Rect
.Width
-1,
2575 FObj
.Y
+FObj
.Rect
.Y
+FObj
.Rect
.Height
-1,
2579 if (gChatBubble
> 0) and (FKeys
[KEY_CHAT
].Pressed
) and not FGhost
then
2580 if (FMegaRulez
[MR_INVIS
] <= gTime
) or ((gPlayerDrawn
<> nil) and ((Self
= gPlayerDrawn
) or
2581 ((FTeam
= gPlayerDrawn
.Team
) and (gGameSettings
.GameMode
<> GM_DM
)))) then
2583 // e_DrawPoint(5, 335, 288, 255, 0, 0); // DL, UR, DL, UR
2584 if gAimLine
and alive
and
2585 ((Self
= gPlayer1
) or (Self
= gPlayer2
)) then
2590 procedure TPlayer
.DrawAim();
2591 procedure drawCast (sz
: Integer; ax0
, ay0
, ax1
, ay1
: Integer);
2596 {$IFDEF ENABLE_HOLMES}
2597 if isValidViewPort
and (self
= gPlayer1
) then
2599 g_Holmes_plrLaser(ax0
, ay0
, ax1
, ay1
);
2603 e_DrawLine(sz
, ax0
, ay0
, ax1
, ay1
, 255, 0, 0, 96);
2604 if (g_Map_traceToNearestWall(ax0
, ay0
, ax1
, ay1
, @ex
, @ey
) <> nil) then
2606 e_DrawLine(sz
, ax0
, ay0
, ex
, ey
, 0, 255, 0, 96);
2610 e_DrawLine(sz
, ax0
, ay0
, ex
, ey
, 0, 0, 255, 96);
2615 wx
, wy
, xx
, yy
: Integer;
2619 wx
:= FObj
.X
+ WEAPONPOINT
[FDirection
].X
+ IfThen(FDirection
= TDirection
.D_LEFT
, 7, -7);
2620 wy
:= FObj
.Y
+ WEAPONPOINT
[FDirection
].Y
;
2629 1: begin // Chainsaw
2636 if angle
= ANGLE_RIGHTUP
then Dec(angle
, 2);
2637 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 4);
2638 if angle
= ANGLE_LEFTUP
then Inc(angle
, 2);
2639 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 4);
2644 if angle
= ANGLE_RIGHTUP
then Dec(angle
, 2);
2645 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 4);
2646 if angle
= ANGLE_LEFTUP
then Inc(angle
, 2);
2647 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 4);
2649 4: begin // Double Shotgun
2652 if angle
= ANGLE_RIGHTUP
then Dec(angle
, 2);
2653 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 4);
2654 if angle
= ANGLE_LEFTUP
then Inc(angle
, 2);
2655 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 4);
2657 5: begin // Chaingun
2660 if angle
= ANGLE_RIGHTUP
then Dec(angle
, 2);
2661 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 4);
2662 if angle
= ANGLE_LEFTUP
then Inc(angle
, 2);
2663 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 4);
2665 6: begin // Rocket Launcher
2668 if angle
= ANGLE_RIGHTUP
then Inc(angle
, 2);
2669 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 4);
2670 if angle
= ANGLE_LEFTUP
then Dec(angle
, 2);
2671 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 4);
2673 7: begin // Plasmagun
2676 if angle
= ANGLE_RIGHTUP
then Inc(angle
);
2677 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 3);
2678 if angle
= ANGLE_LEFTUP
then Dec(angle
);
2679 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 3);
2684 if angle
= ANGLE_RIGHTUP
then Inc(angle
, 1);
2685 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 2);
2686 if angle
= ANGLE_LEFTUP
then Dec(angle
, 1);
2687 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 2);
2689 9: begin // Super Chaingun
2692 if angle
= ANGLE_RIGHTUP
then Dec(angle
, 2);
2693 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 4);
2694 if angle
= ANGLE_LEFTUP
then Inc(angle
, 2);
2695 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 4);
2698 xx
:= Trunc(Cos(-DegToRad(angle
)) * len
) + wx
;
2699 yy
:= Trunc(Sin(-DegToRad(angle
)) * len
) + wy
;
2700 {$IF DEFINED(D2F_DEBUG)}
2701 drawCast(sz
, wx
, wy
, xx
, yy
);
2703 e_DrawLine(sz
, wx
, wy
, xx
, yy
, 255, 0, 0, 96);
2707 procedure TPlayer
.DrawGUI();
2710 X
, Y
, SY
, a
, p
, m
: Integer;
2714 stat
: TPlayerStatArray
;
2716 X
:= gPlayerScreenSize
.X
;
2717 SY
:= gPlayerScreenSize
.Y
;
2720 if gShowGoals
and (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then
2722 if gGameSettings
.GameMode
= GM_CTF
then
2726 if gGameSettings
.GameMode
= GM_CTF
then
2728 s
:= 'TEXTURE_PLAYER_REDFLAG';
2729 if gFlags
[FLAG_RED
].State
= FLAG_STATE_CAPTURED
then
2730 s
:= 'TEXTURE_PLAYER_REDFLAG_S';
2731 if gFlags
[FLAG_RED
].State
= FLAG_STATE_DROPPED
then
2732 s
:= 'TEXTURE_PLAYER_REDFLAG_D';
2733 if g_Texture_Get(s
, ID
) then
2734 e_Draw(ID
, X
-16-32, 240-72-4, 0, True, False);
2737 s
:= IntToStr(gTeamStat
[TEAM_RED
].Goals
);
2738 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2739 e_CharFont_PrintEx(gMenuFont
, X
-16-a
-tw
, 240-72-4, s
, TEAMCOLOR
[TEAM_RED
]);
2741 if gGameSettings
.GameMode
= GM_CTF
then
2743 s
:= 'TEXTURE_PLAYER_BLUEFLAG';
2744 if gFlags
[FLAG_BLUE
].State
= FLAG_STATE_CAPTURED
then
2745 s
:= 'TEXTURE_PLAYER_BLUEFLAG_S';
2746 if gFlags
[FLAG_BLUE
].State
= FLAG_STATE_DROPPED
then
2747 s
:= 'TEXTURE_PLAYER_BLUEFLAG_D';
2748 if g_Texture_Get(s
, ID
) then
2749 e_Draw(ID
, X
-16-32, 240-32-4, 0, True, False);
2752 s
:= IntToStr(gTeamStat
[TEAM_BLUE
].Goals
);
2753 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2754 e_CharFont_PrintEx(gMenuFont
, X
-16-a
-tw
, 240-32-4, s
, TEAMCOLOR
[TEAM_BLUE
]);
2757 if g_Texture_Get('TEXTURE_PLAYER_HUDBG', ID
) then
2758 e_DrawFill(ID
, X
, 0, 1, (gPlayerScreenSize
.Y
div 256)+IfThen(gPlayerScreenSize
.Y
mod 256 > 0, 1, 0),
2761 if g_Texture_Get('TEXTURE_PLAYER_HUD', ID
) then
2762 e_Draw(ID
, X
+2, Y
, 0, True, False);
2764 if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
2768 s
:= IntToStr(Frags
);
2769 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2770 e_CharFont_PrintEx(gMenuFont
, X
-16-tw
, Y
, s
, _RGB(255, 0, 0));
2775 stat
:= g_Player_GetStats();
2780 for a
:= 0 to High(stat
) do
2781 if stat
[a
].Name
<> Name
then
2783 if stat
[a
].Frags
> m
then m
:= stat
[a
].Frags
;
2784 if stat
[a
].Frags
> Frags
then p
:= p
+1;
2788 s
:= IntToStr(p
)+' / '+IntToStr(Length(stat
))+' ';
2789 if Frags
>= m
then s
:= s
+'+' else s
:= s
+'-';
2790 s
:= s
+IntToStr(Abs(Frags
-m
));
2792 e_CharFont_GetSize(gMenuSmallFont
, s
, tw
, th
);
2793 e_CharFont_PrintEx(gMenuSmallFont
, X
-16-tw
, Y
+32, s
, _RGB(255, 0, 0));
2796 if gLMSRespawn
> LMS_RESPAWN_NONE
then
2798 s
:= _lc
[I_GAME_WARMUP
];
2799 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2800 s
:= s
+ ': ' + IntToStr((gLMSRespawnTime
- gTime
) div 1000);
2801 e_CharFont_PrintEx(gMenuFont
, X
-64-tw
, SY
-32, s
, _RGB(0, 255, 0));
2803 else if gShowLives
and (gGameSettings
.MaxLives
> 0) then
2805 s
:= IntToStr(Lives
);
2806 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2807 e_CharFont_PrintEx(gMenuFont
, X
-16-tw
, SY
-32, s
, _RGB(0, 255, 0));
2811 e_CharFont_GetSize(gMenuSmallFont
, FName
, tw
, th
);
2812 e_CharFont_PrintEx(gMenuSmallFont
, X
+98-(tw
div 2), Y
+8, FName
, _RGB(255, 0, 0));
2814 if R_BERSERK
in FRulez
then
2815 e_Draw(gItemsTexturesID
[ITEM_MEDKIT_BLACK
], X
+37, Y
+45, 0, True, False)
2817 e_Draw(gItemsTexturesID
[ITEM_MEDKIT_LARGE
], X
+37, Y
+45, 0, True, False);
2819 if g_Texture_Get('TEXTURE_PLAYER_ARMORHUD', ID
) then
2820 e_Draw(ID
, X
+36, Y
+77, 0, True, False);
2822 s
:= IntToStr(IfThen(FHealth
> 0, FHealth
, 0));
2823 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2824 e_CharFont_PrintEx(gMenuFont
, X
+178-tw
, Y
+40, s
, _RGB(255, 0, 0));
2826 s
:= IntToStr(FArmor
);
2827 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2828 e_CharFont_PrintEx(gMenuFont
, X
+178-tw
, Y
+68, s
, _RGB(255, 0, 0));
2830 s
:= IntToStr(GetAmmoByWeapon(FCurrWeap
));
2836 ID
:= gItemsTexturesID
[ITEM_WEAPON_KASTET
];
2841 ID
:= gItemsTexturesID
[ITEM_WEAPON_SAW
];
2843 WEAPON_PISTOL
: ID
:= gItemsTexturesID
[ITEM_WEAPON_PISTOL
];
2844 WEAPON_CHAINGUN
: ID
:= gItemsTexturesID
[ITEM_WEAPON_CHAINGUN
];
2845 WEAPON_SHOTGUN1
: ID
:= gItemsTexturesID
[ITEM_WEAPON_SHOTGUN1
];
2846 WEAPON_SHOTGUN2
: ID
:= gItemsTexturesID
[ITEM_WEAPON_SHOTGUN2
];
2847 WEAPON_SUPERPULEMET
: ID
:= gItemsTexturesID
[ITEM_WEAPON_SUPERPULEMET
];
2848 WEAPON_ROCKETLAUNCHER
: ID
:= gItemsTexturesID
[ITEM_WEAPON_ROCKETLAUNCHER
];
2849 WEAPON_PLASMA
: ID
:= gItemsTexturesID
[ITEM_WEAPON_PLASMA
];
2850 WEAPON_BFG
: ID
:= gItemsTexturesID
[ITEM_WEAPON_BFG
];
2851 WEAPON_FLAMETHROWER
: ID
:= gItemsTexturesID
[ITEM_WEAPON_FLAMETHROWER
];
2854 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2855 e_CharFont_PrintEx(gMenuFont
, X
+178-tw
, Y
+158, s
, _RGB(255, 0, 0));
2856 e_Draw(ID
, X
+20, Y
+160, 0, True, False);
2858 if R_KEY_RED
in FRulez
then
2859 e_Draw(gItemsTexturesID
[ITEM_KEY_RED
], X
+78, Y
+214, 0, True, False);
2861 if R_KEY_GREEN
in FRulez
then
2862 e_Draw(gItemsTexturesID
[ITEM_KEY_GREEN
], X
+95, Y
+214, 0, True, False);
2864 if R_KEY_BLUE
in FRulez
then
2865 e_Draw(gItemsTexturesID
[ITEM_KEY_BLUE
], X
+112, Y
+214, 0, True, False);
2867 if FJetFuel
> 0 then
2869 if g_Texture_Get('TEXTURE_PLAYER_HUDAIR', ID
) then
2870 e_Draw(ID
, X
+2, Y
+116, 0, True, False);
2871 if g_Texture_Get('TEXTURE_PLAYER_HUDJET', ID
) then
2872 e_Draw(ID
, X
+2, Y
+126, 0, True, False);
2873 e_DrawLine(4, X
+16, Y
+122, X
+16+Trunc(168*IfThen(FAir
> 0, FAir
, 0)/AIR_MAX
), Y
+122, 0, 0, 196);
2874 e_DrawLine(4, X
+16, Y
+132, X
+16+Trunc(168*FJetFuel
/JET_MAX
), Y
+132, 208, 0, 0);
2878 if g_Texture_Get('TEXTURE_PLAYER_HUDAIR', ID
) then
2879 e_Draw(ID
, X
+2, Y
+124, 0, True, False);
2880 e_DrawLine(4, X
+16, Y
+130, X
+16+Trunc(168*IfThen(FAir
> 0, FAir
, 0)/AIR_MAX
), Y
+130, 0, 0, 196);
2883 if gShowPing
and g_Game_IsClient
then
2885 s
:= _lc
[I_GAME_PING_HUD
] + IntToStr(NetPeer
.lastRoundTripTime
) + _lc
[I_NET_SLIST_PING_MS
];
2886 e_TextureFontPrint(X
+ 4, Y
+ 242, s
, gStdFont
);
2892 e_TextureFontPrint(X
+ 4, Y
+ 242, _lc
[I_PLAYER_SPECT
], gStdFont
);
2893 e_TextureFontPrint(X
+ 4, Y
+ 258, _lc
[I_PLAYER_SPECT2
], gStdFont
);
2894 e_TextureFontPrint(X
+ 4, Y
+ 274, _lc
[I_PLAYER_SPECT1
], gStdFont
);
2897 e_TextureFontGetSize(gStdFont
, cw
, ch
);
2898 s
:= _lc
[I_PLAYER_SPECT4
];
2899 e_TextureFontPrintEx(gScreenWidth
div 2 - cw
*(Length(s
) div 2),
2900 gScreenHeight
-4-ch
, s
, gStdFont
, 255, 255, 255, 1, True);
2901 e_TextureFontPrint(X
+ 4, Y
+ 290, _lc
[I_PLAYER_SPECT1S
], gStdFont
);
2907 procedure TPlayer
.DrawRulez();
2911 // Ïðè âçÿòèè íåóÿçâèìîñòè ðèñóåòñÿ èíâåðñèîííûé áåëûé ôîí
2912 if (FMegaRulez
[MR_INVUL
] >= gTime
) and (FSpawnInvul
< gTime
) then
2914 if (FMegaRulez
[MR_INVUL
]-gTime
) <= 2100 then
2915 dr
:= not Odd((FMegaRulez
[MR_INVUL
]-gTime
) div 300)
2920 e_DrawFillQuad(0, 0, gPlayerScreenSize
.X
-1, gPlayerScreenSize
.Y
-1,
2921 191, 191, 191, 0, TBlending
.Invert
);
2924 // Ïðè âçÿòèè çàùèòíîãî êîñòþìà ðèñóåòñÿ çåëåíîâàòûé ôîí
2925 if FMegaRulez
[MR_SUIT
] >= gTime
then
2927 if (FMegaRulez
[MR_SUIT
]-gTime
) <= 2100 then
2928 dr
:= not Odd((FMegaRulez
[MR_SUIT
]-gTime
) div 300)
2933 e_DrawFillQuad(0, 0, gPlayerScreenSize
.X
-1, gPlayerScreenSize
.Y
-1,
2934 0, 96, 0, 200, TBlending
.None
);
2937 // Ïðè âçÿòèè áåðñåðêà ðèñóåòñÿ êðàñíîâàòûé ôîí
2938 if (FBerserk
>= 0) and (LongWord(FBerserk
) >= gTime
) and (gFlash
= 2) then
2940 e_DrawFillQuad(0, 0, gPlayerScreenSize
.X
-1, gPlayerScreenSize
.Y
-1,
2941 255, 0, 0, 200, TBlending
.None
);
2945 procedure TPlayer
.DrawPain();
2949 if FPain
= 0 then Exit
;
2953 if a
< 15 then h
:= 0
2954 else if a
< 35 then h
:= 1
2955 else if a
< 55 then h
:= 2
2956 else if a
< 75 then h
:= 3
2957 else if a
< 95 then h
:= 4
2960 //if a > 255 then a := 255;
2962 e_DrawFillQuad(0, 0, gPlayerScreenSize
.X
-1, gPlayerScreenSize
.Y
-1, 255, 0, 0, 255-h
*50);
2963 //e_DrawFillQuad(0, 0, gPlayerScreenSize.X-1, gPlayerScreenSize.Y-1, 255-min(128, a), 255-a, 255-a, 0, B_FILTER);
2966 procedure TPlayer
.DrawPickup();
2970 if FPickup
= 0 then Exit
;
2974 if a
< 15 then h
:= 1
2975 else if a
< 35 then h
:= 2
2976 else if a
< 55 then h
:= 3
2977 else if a
< 75 then h
:= 4
2980 e_DrawFillQuad(0, 0, gPlayerScreenSize
.X
-1, gPlayerScreenSize
.Y
-1, 150, 200, 150, 255-h
*50);
2983 procedure TPlayer
.DoPunch();
2988 if FPunchAnim
<> nil then begin
2993 st
:= 'FRAMES_PUNCH';
2994 if R_BERSERK
in FRulez
then
2995 st
:= st
+ '_BERSERK';
2996 if FKeys
[KEY_UP
].Pressed
then
2998 else if FKeys
[KEY_DOWN
].Pressed
then
3000 g_Frames_Get(id
, st
);
3001 FPunchAnim
:= TAnimation
.Create(id
, False, 1);
3004 procedure TPlayer
.Fire();
3006 f
, DidFire
: Boolean;
3007 wx
, wy
, xd
, yd
: Integer;
3010 if g_Game_IsClient
then Exit
;
3011 // FBFGFireCounter - âðåìÿ ïåðåä âûñòðåëîì (äëÿ BFG)
3012 // FReloading - âðåìÿ ïîñëå âûñòðåëà (äëÿ âñåãî)
3020 if FReloading
[FCurrWeap
] <> 0 then Exit
;
3025 wx
:= FObj
.X
+WEAPONPOINT
[FDirection
].X
;
3026 wy
:= FObj
.Y
+WEAPONPOINT
[FDirection
].Y
;
3027 xd
:= wx
+IfThen(FDirection
= TDirection
.D_LEFT
, -30, 30);
3028 yd
:= wy
+firediry();
3034 if R_BERSERK
in FRulez
then
3036 //g_Weapon_punch(FObj.X+FObj.Rect.X, FObj.Y+FObj.Rect.Y, 75, FUID);
3037 locobj
.X
:= FObj
.X
+FObj
.Rect
.X
;
3038 locobj
.Y
:= FObj
.Y
+FObj
.Rect
.Y
;
3041 locobj
.rect
.Width
:= 39;
3042 locobj
.rect
.Height
:= 52;
3043 locobj
.Vel
.X
:= (xd
-wx
) div 2;
3044 locobj
.Vel
.Y
:= (yd
-wy
) div 2;
3045 locobj
.Accel
.X
:= xd
-wx
;
3046 locobj
.Accel
.y
:= yd
-wy
;
3048 if g_Weapon_Hit(@locobj
, 50, FUID
, HIT_SOME
) <> 0 then
3049 g_Sound_PlayExAt('SOUND_WEAPON_HITBERSERK', FObj
.X
, FObj
.Y
)
3051 g_Sound_PlayExAt('SOUND_WEAPON_MISSBERSERK', FObj
.X
, FObj
.Y
);
3053 if (gFlash
= 1) and (FPain
< 50) then FPain
:= min(FPain
+ 25, 50);
3057 g_Weapon_punch(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
, 3, FUID
);
3061 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
3066 if g_Weapon_chainsaw(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
,
3067 IfThen(gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
], 9, 3), FUID
) <> 0 then
3069 FSawSoundSelect
.Stop();
3071 FSawSoundHit
.PlayAt(FObj
.X
, FObj
.Y
);
3073 else if not FSawSoundHit
.IsPlaying() then
3075 FSawSoundSelect
.Stop();
3076 FSawSound
.PlayAt(FObj
.X
, FObj
.Y
);
3079 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
3085 if FAmmo
[A_BULLETS
] > 0 then
3087 g_Weapon_pistol(wx
, wy
, xd
, yd
, FUID
);
3088 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
3089 Dec(FAmmo
[A_BULLETS
]);
3090 FFireAngle
:= FAngle
;
3093 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
3094 GameVelX
, GameVelY
-2, SHELL_BULLET
);
3098 if FAmmo
[A_SHELLS
] > 0 then
3100 g_Weapon_shotgun(wx
, wy
, xd
, yd
, FUID
);
3101 if not gSoundEffectsDF
then g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN', wx
, wy
);
3102 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
3103 Dec(FAmmo
[A_SHELLS
]);
3104 FFireAngle
:= FAngle
;
3108 FShellType
:= SHELL_SHELL
;
3112 if FAmmo
[A_SHELLS
] >= 2 then
3114 g_Weapon_dshotgun(wx
, wy
, xd
, yd
, FUID
);
3115 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
3116 Dec(FAmmo
[A_SHELLS
], 2);
3117 FFireAngle
:= FAngle
;
3121 FShellType
:= SHELL_DBLSHELL
;
3125 if FAmmo
[A_BULLETS
] > 0 then
3127 g_Weapon_mgun(wx
, wy
, xd
, yd
, FUID
);
3128 if not gSoundEffectsDF
then g_Sound_PlayExAt('SOUND_WEAPON_FIREPISTOL', wx
, wy
);
3129 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
3130 Dec(FAmmo
[A_BULLETS
]);
3131 FFireAngle
:= FAngle
;
3134 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
3135 GameVelX
, GameVelY
-2, SHELL_BULLET
);
3138 WEAPON_ROCKETLAUNCHER
:
3139 if FAmmo
[A_ROCKETS
] > 0 then
3141 g_Weapon_rocket(wx
, wy
, xd
, yd
, FUID
);
3142 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
3143 Dec(FAmmo
[A_ROCKETS
]);
3144 FFireAngle
:= FAngle
;
3150 if FAmmo
[A_CELLS
] > 0 then
3152 g_Weapon_plasma(wx
, wy
, xd
, yd
, FUID
);
3153 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
3154 Dec(FAmmo
[A_CELLS
]);
3155 FFireAngle
:= FAngle
;
3161 if (FAmmo
[A_CELLS
] >= 40) and (FBFGFireCounter
= -1) then
3163 FBFGFireCounter
:= 17;
3164 if not FNoReload
then
3165 g_Sound_PlayExAt('SOUND_WEAPON_STARTFIREBFG', FObj
.X
, FObj
.Y
);
3166 Dec(FAmmo
[A_CELLS
], 40);
3170 WEAPON_SUPERPULEMET
:
3171 if FAmmo
[A_SHELLS
] > 0 then
3173 g_Weapon_shotgun(wx
, wy
, xd
, yd
, FUID
);
3174 if not gSoundEffectsDF
then g_Sound_PlayExAt('SOUND_WEAPON_FIRECGUN', wx
, wy
);
3175 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
3176 Dec(FAmmo
[A_SHELLS
]);
3177 FFireAngle
:= FAngle
;
3180 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
3181 GameVelX
, GameVelY
-2, SHELL_SHELL
);
3184 WEAPON_FLAMETHROWER
:
3185 if FAmmo
[A_FUEL
] > 0 then
3187 g_Weapon_flame(wx
, wy
, xd
, yd
, FUID
);
3189 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
3191 FFireAngle
:= FAngle
;
3198 if g_Game_IsNet
and g_Game_IsServer
then MH_SEND_PlayerStats(FUID
);
3202 if g_Game_IsNet
then
3206 if FCurrWeap
<> WEAPON_BFG
then
3207 MH_SEND_PlayerFire(FUID
, FCurrWeap
, wx
, wy
, xd
, yd
, LastShotID
)
3209 if not FNoReload
then
3210 MH_SEND_Sound(FObj
.X
, FObj
.Y
, 'SOUND_WEAPON_STARTFIREBFG');
3213 MH_SEND_PlayerStats(FUID
);
3218 if (FAngle
= 0) or (FAngle
= 180) then SetAction(A_ATTACK
)
3219 else if (FAngle
= ANGLE_LEFTDOWN
) or (FAngle
= ANGLE_RIGHTDOWN
) then SetAction(A_ATTACKDOWN
)
3220 else if (FAngle
= ANGLE_LEFTUP
) or (FAngle
= ANGLE_RIGHTUP
) then SetAction(A_ATTACKUP
);
3223 function TPlayer
.GetAmmoByWeapon(Weapon
: Byte): Word;
3226 WEAPON_PISTOL
, WEAPON_CHAINGUN
: Result
:= FAmmo
[A_BULLETS
];
3227 WEAPON_SHOTGUN1
, WEAPON_SHOTGUN2
, WEAPON_SUPERPULEMET
: Result
:= FAmmo
[A_SHELLS
];
3228 WEAPON_ROCKETLAUNCHER
: Result
:= FAmmo
[A_ROCKETS
];
3229 WEAPON_PLASMA
, WEAPON_BFG
: Result
:= FAmmo
[A_CELLS
];
3230 WEAPON_FLAMETHROWER
: Result
:= FAmmo
[A_FUEL
];
3235 function TPlayer
.HeadInLiquid(XInc
, YInc
: Integer): Boolean;
3237 Result
:= g_Map_CollidePanel(FObj
.X
+PLAYER_HEADRECT
.X
+XInc
, FObj
.Y
+PLAYER_HEADRECT
.Y
+YInc
,
3238 PLAYER_HEADRECT
.Width
, PLAYER_HEADRECT
.Height
,
3239 PANEL_WATER
or PANEL_ACID1
or PANEL_ACID2
, True);
3242 procedure TPlayer
.FlamerOn
;
3244 FFlameSoundOff
.Stop();
3245 FFlameSoundOff
.SetPosition(0);
3248 if (not FFlameSoundOn
.IsPlaying()) and (not FFlameSoundWork
.IsPlaying()) then
3249 FFlameSoundWork
.PlayAt(FObj
.X
, FObj
.Y
);
3253 FFlameSoundOn
.PlayAt(FObj
.X
, FObj
.Y
);
3258 procedure TPlayer
.FlamerOff
;
3262 FFlameSoundOn
.Stop();
3263 FFlameSoundOn
.SetPosition(0);
3264 FFlameSoundWork
.Stop();
3265 FFlameSoundWork
.SetPosition(0);
3266 FFlameSoundOff
.PlayAt(FObj
.X
, FObj
.Y
);
3271 procedure TPlayer
.JetpackOn
;
3275 FJetSoundOn
.SetPosition(0);
3276 FJetSoundOn
.PlayAt(FObj
.X
, FObj
.Y
);
3280 procedure TPlayer
.JetpackOff
;
3284 FJetSoundOff
.SetPosition(0);
3285 FJetSoundOff
.PlayAt(FObj
.X
, FObj
.Y
);
3288 procedure TPlayer
.CatchFire(Attacker
: Word; Timeout
: Integer = PLAYER_BURN_TIME
);
3290 if Timeout
<= 0 then
3292 if (FMegaRulez
[MR_SUIT
] > gTime
) or (FMegaRulez
[MR_INVUL
] > gTime
) then
3293 exit
; // Íå çàãîðàåìñÿ êîãäà åñòü çàùèòà
3294 if g_Obj_CollidePanel(@FObj
, 0, 0, PANEL_WATER
or PANEL_ACID1
or PANEL_ACID2
) then
3295 exit
; // Íå ïîäãîðàåì â âîäå íà âñÿêèé ñëó÷àé
3296 if FFireTime
<= 0 then
3297 g_Sound_PlayExAt('SOUND_IGNITE', FObj
.X
, FObj
.Y
);
3298 FFireTime
:= Timeout
;
3299 FFireAttacker
:= Attacker
;
3300 if g_Game_IsNet
and g_Game_IsServer
then
3301 MH_SEND_PlayerStats(FUID
);
3304 procedure TPlayer
.Jump();
3306 if gFly
or FJetpack
then
3308 // Ïîëåò (÷èò-êîä èëè äæåòïàê):
3309 if FObj
.Vel
.Y
> -VEL_FLY
then
3310 FObj
.Vel
.Y
:= FObj
.Vel
.Y
- 3;
3313 if FJetFuel
> 0 then
3315 if (FJetFuel
< 1) and g_Game_IsServer
then
3319 if g_Game_IsNet
then
3320 MH_SEND_PlayerStats(FUID
);
3326 // Íå âêëþ÷àòü äæåòïàê â ðåæèìå ïðîõîæäåíèÿ ñêâîçü ñòåíû
3328 FCanJetpack
:= False;
3330 // Ïðûãàåì èëè âñïëûâàåì:
3331 if (CollideLevel(0, 1) or
3332 g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+PLAYER_RECT
.Y
+36, PLAYER_RECT
.Width
,
3333 PLAYER_RECT
.Height
-33, PANEL_STEP
, False)
3334 ) and (FObj
.Accel
.Y
= 0) then // Íå ïðûãàòü, åñëè åñòü âåðòèêàëüíîå óñêîðåíèå
3336 FObj
.Vel
.Y
:= -VEL_JUMP
;
3337 FCanJetpack
:= False;
3341 if BodyInLiquid(0, 0) then
3342 FObj
.Vel
.Y
:= -VEL_SW
3343 else if (FJetFuel
> 0) and FCanJetpack
and
3344 g_Game_IsServer
and (not g_Obj_CollideLiquid(@FObj
, 0, 0)) then
3348 if g_Game_IsNet
then
3349 MH_SEND_PlayerStats(FUID
);
3354 procedure TPlayer
.Kill(KillType
: Byte; SpawnerUID
: Word; t
: Byte);
3356 a
, i
, k
, ab
, ar
: Byte;
3360 srv
, netsrv
: Boolean;
3366 procedure PushItem(t
: Byte);
3370 id
:= g_Items_Create(FObj
.X
, FObj
.Y
, t
, True, False);
3371 it
:= g_Items_ByIdx(id
);
3372 if KillType
= K_EXTRAHARDKILL
then // -7..+7; -8..0
3374 g_Obj_Push(@it
.Obj
, (FObj
.Vel
.X
div 2)-7+Random(15),
3375 (FObj
.Vel
.Y
div 2)-Random(9));
3376 it
.positionChanged(); // this updates spatial accelerators
3380 if KillType
= K_HARDKILL
then // -5..+5; -5..0
3382 g_Obj_Push(@it
.Obj
, (FObj
.Vel
.X
div 2)-5+Random(11),
3383 (FObj
.Vel
.Y
div 2)-Random(6));
3385 else // -3..+3; -3..0
3387 g_Obj_Push(@it
.Obj
, (FObj
.Vel
.X
div 2)-3+Random(7),
3388 (FObj
.Vel
.Y
div 2)-Random(4));
3390 it
.positionChanged(); // this updates spatial accelerators
3393 if g_Game_IsNet
and g_Game_IsServer
then
3394 MH_SEND_ItemSpawn(True, id
);
3398 DoFrags
:= (gGameSettings
.MaxLives
= 0) or (gGameSettings
.GameMode
= GM_COOP
);
3399 Srv
:= g_Game_IsServer
;
3400 Netsrv
:= g_Game_IsServer
and g_Game_IsNet
;
3401 if Srv
then FDeath
:= FDeath
+ 1;
3406 if not FPhysics
then
3412 if (gGameSettings
.MaxLives
> 0) and Srv
and (gLMSRespawn
= LMS_RESPAWN_NONE
) then
3414 if FLives
> 0 then FLives
:= FLives
- 1;
3415 if FLives
= 0 then FNoRespawn
:= True;
3418 // Íîìåð òèïà ñìåðòè:
3421 K_SIMPLEKILL
: a
:= 1;
3423 K_EXTRAHARDKILL
: a
:= 3;
3428 if not FModel
.PlaySound(MODELSOUND_DIE
, a
, FObj
.X
, FObj
.Y
) then
3430 if FModel
.PlaySound(MODELSOUND_DIE
, i
, FObj
.X
, FObj
.Y
) then
3437 FTime
[T_RESPAWN
] := gTime
+ TIME_RESPAWN1
;
3439 FTime
[T_RESPAWN
] := gTime
+ TIME_RESPAWN2
;
3440 K_EXTRAHARDKILL
, K_FALLKILL
:
3441 FTime
[T_RESPAWN
] := gTime
+ TIME_RESPAWN3
;
3444 // Ïåðåêëþ÷àåì ñîñòîÿíèå:
3448 K_HARDKILL
, K_EXTRAHARDKILL
:
3452 // Ðåàêöèÿ ìîíñòðîâ íà ñìåðòü èãðîêà:
3453 if (KillType
<> K_FALLKILL
) and (Srv
) then
3454 g_Monsters_killedp();
3456 if SpawnerUID
= FUID
then
3460 if gGameSettings
.GameMode
= GM_TDM
then
3461 Dec(gTeamStat
[FTeam
].Goals
);
3462 if DoFrags
or (gGameSettings
.GameMode
= GM_TDM
) then
3468 g_Console_Add(Format(_lc
[I_PLAYER_KILL_SELF
], [FName
]), True);
3471 if g_GetUIDType(SpawnerUID
) = UID_PLAYER
then
3472 begin // Óáèò äðóãèì èãðîêîì
3473 KP
:= g_Player_Get(SpawnerUID
);
3474 if (KP
<> nil) and Srv
then
3476 if (DoFrags
or (gGameSettings
.GameMode
= GM_TDM
)) then
3477 if SameTeam(FUID
, SpawnerUID
) then
3487 if (gGameSettings
.GameMode
= GM_TDM
) and DoFrags
then
3488 Inc(gTeamStat
[KP
.Team
].Goals
,
3489 IfThen(SameTeam(FUID
, SpawnerUID
), -1, 1));
3491 if netsrv
then MH_SEND_PlayerStats(SpawnerUID
);
3494 plr
:= g_Player_Get(SpawnerUID
);
3502 g_Console_Add(Format(_lc
[I_PLAYER_KILL_EXTRAHARD_2
],
3506 g_Console_Add(Format(_lc
[I_PLAYER_KILL_EXTRAHARD_1
],
3510 g_Console_Add(Format(_lc
[I_PLAYER_KILL
],
3515 else if g_GetUIDType(SpawnerUID
) = UID_MONSTER
then
3516 begin // Óáèò ìîíñòðîì
3517 mon
:= g_Monsters_ByUID(SpawnerUID
);
3521 s
:= g_Mons_GetKilledByTypeId(mon
.MonsterType
);
3525 g_Console_Add(Format(_lc
[I_PLAYER_KILL_EXTRAHARD_2
],
3529 g_Console_Add(Format(_lc
[I_PLAYER_KILL_EXTRAHARD_1
],
3533 g_Console_Add(Format(_lc
[I_PLAYER_KILL
],
3538 else // Îñîáûå òèïû ñìåðòè
3541 HIT_SELF
: g_Console_Add(Format(_lc
[I_PLAYER_KILL_SELF
], [FName
]), True);
3542 HIT_FALL
: g_Console_Add(Format(_lc
[I_PLAYER_KILL_FALL
], [FName
]), True);
3543 HIT_WATER
: g_Console_Add(Format(_lc
[I_PLAYER_KILL_WATER
], [FName
]), True);
3544 HIT_ACID
: g_Console_Add(Format(_lc
[I_PLAYER_KILL_ACID
], [FName
]), True);
3545 HIT_TRAP
: g_Console_Add(Format(_lc
[I_PLAYER_KILL_TRAP
], [FName
]), True);
3546 else g_Console_Add(Format(_lc
[I_PLAYER_DIED
], [FName
]), True);
3552 for a
:= WP_FIRST
to WP_LAST
do
3556 WEAPON_SAW
: i
:= ITEM_WEAPON_SAW
;
3557 WEAPON_SHOTGUN1
: i
:= ITEM_WEAPON_SHOTGUN1
;
3558 WEAPON_SHOTGUN2
: i
:= ITEM_WEAPON_SHOTGUN2
;
3559 WEAPON_CHAINGUN
: i
:= ITEM_WEAPON_CHAINGUN
;
3560 WEAPON_ROCKETLAUNCHER
: i
:= ITEM_WEAPON_ROCKETLAUNCHER
;
3561 WEAPON_PLASMA
: i
:= ITEM_WEAPON_PLASMA
;
3562 WEAPON_BFG
: i
:= ITEM_WEAPON_BFG
;
3563 WEAPON_SUPERPULEMET
: i
:= ITEM_WEAPON_SUPERPULEMET
;
3564 WEAPON_FLAMETHROWER
: i
:= ITEM_WEAPON_FLAMETHROWER
;
3573 if R_ITEM_BACKPACK
in FRulez
then
3574 PushItem(ITEM_AMMO_BACKPACK
);
3576 // Âûáðîñ ðàêåòíîãî ðàíöà:
3577 if FJetFuel
> 0 then
3578 PushItem(ITEM_JETPACK
);
3581 if (not (gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
])) or
3582 (not LongBool(gGameSettings
.Options
and GAME_OPTION_DMKEYS
)) then
3584 if R_KEY_RED
in FRulez
then
3585 PushItem(ITEM_KEY_RED
);
3587 if R_KEY_GREEN
in FRulez
then
3588 PushItem(ITEM_KEY_GREEN
);
3590 if R_KEY_BLUE
in FRulez
then
3591 PushItem(ITEM_KEY_BLUE
);
3595 DropFlag(KillType
= K_FALLKILL
);
3598 FCorpse
:= g_Player_CreateCorpse(Self
);
3600 if Srv
and (gGameSettings
.MaxLives
> 0) and FNoRespawn
and
3601 (gLMSRespawn
= LMS_RESPAWN_NONE
) then
3607 for i
:= Low(gPlayers
) to High(gPlayers
) do
3609 if gPlayers
[i
] = nil then continue
;
3610 if (not gPlayers
[i
].FNoRespawn
) and (not gPlayers
[i
].FSpectator
) then
3613 if gPlayers
[i
].FTeam
= TEAM_RED
then Inc(ar
)
3614 else if gPlayers
[i
].FTeam
= TEAM_BLUE
then Inc(ab
);
3619 OldLR
:= gLMSRespawn
;
3620 if (gGameSettings
.GameMode
= GM_COOP
) then
3624 // everyone is dead, restart the map
3625 g_Game_Message(_lc
[I_MESSAGE_LMS_LOSE
], 144);
3627 MH_SEND_GameEvent(NET_EV_LMS_LOSE
);
3628 gLMSRespawn
:= LMS_RESPAWN_FINAL
;
3629 gLMSRespawnTime
:= gTime
+ 5000;
3631 else if (a
= 1) then
3633 if (gPlayers
[k
] <> nil) and not (gPlayers
[k
] is TBot
) then
3634 if (gPlayers
[k
] = gPlayer1
) or
3635 (gPlayers
[k
] = gPlayer2
) then
3636 g_Console_Add('*** ' + _lc
[I_MESSAGE_LMS_SURVIVOR
] + ' ***', True)
3637 else if Netsrv
and (gPlayers
[k
].FClientID
>= 0) then
3638 MH_SEND_GameEvent(NET_EV_LMS_SURVIVOR
, 0, 'N', gPlayers
[k
].FClientID
);
3641 else if (gGameSettings
.GameMode
= GM_TDM
) then
3643 if (ab
= 0) and (ar
<> 0) then
3646 g_Game_Message(Format(_lc
[I_MESSAGE_TLMS_WIN
], [AnsiUpperCase(_lc
[I_GAME_TEAM_RED
])]), 144);
3648 MH_SEND_GameEvent(NET_EV_TLMS_WIN
, TEAM_RED
);
3649 Inc(gTeamStat
[TEAM_RED
].Goals
);
3650 gLMSRespawn
:= LMS_RESPAWN_FINAL
;
3651 gLMSRespawnTime
:= gTime
+ 5000;
3653 else if (ar
= 0) and (ab
<> 0) then
3656 g_Game_Message(Format(_lc
[I_MESSAGE_TLMS_WIN
], [AnsiUpperCase(_lc
[I_GAME_TEAM_BLUE
])]), 144);
3658 MH_SEND_GameEvent(NET_EV_TLMS_WIN
, TEAM_BLUE
);
3659 Inc(gTeamStat
[TEAM_BLUE
].Goals
);
3660 gLMSRespawn
:= LMS_RESPAWN_FINAL
;
3661 gLMSRespawnTime
:= gTime
+ 5000;
3663 else if (ar
= 0) and (ab
= 0) then
3666 g_Game_Message(_lc
[I_GAME_WIN_DRAW
], 144);
3668 MH_SEND_GameEvent(NET_EV_LMS_DRAW
, 0, FName
);
3669 gLMSRespawn
:= LMS_RESPAWN_FINAL
;
3670 gLMSRespawnTime
:= gTime
+ 5000;
3673 else if (gGameSettings
.GameMode
= GM_DM
) then
3677 if gPlayers
[k
] <> nil then
3680 // survivor is the winner
3681 g_Game_Message(Format(_lc
[I_MESSAGE_LMS_WIN
], [AnsiUpperCase(FName
)]), 144);
3683 MH_SEND_GameEvent(NET_EV_LMS_WIN
, 0, FName
);
3686 gLMSRespawn
:= LMS_RESPAWN_FINAL
;
3687 gLMSRespawnTime
:= gTime
+ 5000;
3689 else if (a
= 0) then
3691 // everyone is dead, restart the map
3692 g_Game_Message(_lc
[I_GAME_WIN_DRAW
], 144);
3694 MH_SEND_GameEvent(NET_EV_LMS_DRAW
, 0, FName
);
3695 gLMSRespawn
:= LMS_RESPAWN_FINAL
;
3696 gLMSRespawnTime
:= gTime
+ 5000;
3699 if srv
and (OldLR
= LMS_RESPAWN_NONE
) and (gLMSRespawn
> LMS_RESPAWN_NONE
) then
3701 if NetMode
= NET_SERVER
then
3702 MH_SEND_GameEvent(NET_EV_LMS_WARMUP
, gLMSRespawnTime
- gTime
)
3704 g_Console_Add(Format(_lc
[I_MSG_WARMUP_START
], [(gLMSRespawnTime
- gTime
) div 1000]), True);
3710 MH_SEND_PlayerStats(FUID
);
3711 MH_SEND_PlayerDeath(FUID
, KillType
, t
, SpawnerUID
);
3712 if gGameSettings
.GameMode
= GM_TDM
then MH_SEND_GameStats
;
3715 if srv
and FNoRespawn
then Spectate(True);
3716 FWantsInGame
:= True;
3719 function TPlayer
.BodyInLiquid(XInc
, YInc
: Integer): Boolean;
3721 Result
:= g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
, PLAYER_RECT
.Width
,
3722 PLAYER_RECT
.Height
-20, PANEL_WATER
or PANEL_ACID1
or PANEL_ACID2
, False);
3725 function TPlayer
.BodyInAcid(XInc
, YInc
: Integer): Boolean;
3727 Result
:= g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
, PLAYER_RECT
.Width
,
3728 PLAYER_RECT
.Height
-20, PANEL_ACID1
or PANEL_ACID2
, False);
3731 procedure TPlayer
.MakeBloodSimple(Count
: Word);
3733 g_GFX_Blood(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)+8,
3734 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2),
3735 Count
div 2, 3, -1, 16, (PLAYER_RECT
.Height
*2 div 3),
3736 FModel
.Blood
.R
, FModel
.Blood
.G
, FModel
.Blood
.B
, FModel
.Blood
.Kind
);
3737 g_GFX_Blood(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-8,
3738 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2),
3739 Count
div 2, -3, -1, 16, (PLAYER_RECT
.Height
*2) div 3,
3740 FModel
.Blood
.R
, FModel
.Blood
.G
, FModel
.Blood
.B
, FModel
.Blood
.Kind
);
3743 procedure TPlayer
.MakeBloodVector(Count
: Word; VelX
, VelY
: Integer);
3745 g_GFX_Blood(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2),
3746 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2),
3747 Count
, VelX
, VelY
, 16, (PLAYER_RECT
.Height
*2) div 3,
3748 FModel
.Blood
.R
, FModel
.Blood
.G
, FModel
.Blood
.B
, FModel
.Blood
.Kind
);
3751 procedure TPlayer
.ProcessWeaponAction(Action
: Byte);
3753 if g_Game_IsClient
then Exit
;
3755 WP_PREV
: PrevWeapon();
3756 WP_NEXT
: NextWeapon();
3760 procedure TPlayer
.QueueWeaponSwitch(Weapon
: Byte);
3762 if g_Game_IsClient
then Exit
;
3763 if Weapon
> High(FWeapon
) then Exit
;
3764 FNextWeap
:= FNextWeap
or (1 shl Weapon
);
3767 procedure TPlayer
.resetWeaponQueue ();
3770 FNextWeapDelay
:= 0;
3773 function TPlayer
.hasAmmoForWeapon (weapon
: Byte): Boolean;
3777 WEAPON_KASTET
, WEAPON_SAW
: result
:= true;
3778 WEAPON_SHOTGUN1
, WEAPON_SHOTGUN2
, WEAPON_SUPERPULEMET
: result
:= (FAmmo
[A_SHELLS
] > 0);
3779 WEAPON_PISTOL
, WEAPON_CHAINGUN
: result
:= (FAmmo
[A_BULLETS
] > 0);
3780 WEAPON_ROCKETLAUNCHER
: result
:= (FAmmo
[A_ROCKETS
] > 0);
3781 WEAPON_PLASMA
, WEAPON_BFG
: result
:= (FAmmo
[A_CELLS
] > 0);
3782 WEAPON_FLAMETHROWER
: result
:= (FAmmo
[A_FUEL
] > 0);
3783 else result
:= (weapon
< length(FWeapon
));
3787 function TPlayer
.hasAmmoForShooting (weapon
: Byte): Boolean;
3791 WEAPON_KASTET
, WEAPON_SAW
: result
:= true;
3792 WEAPON_SHOTGUN1
, WEAPON_SUPERPULEMET
: result
:= (FAmmo
[A_SHELLS
] > 0);
3793 WEAPON_SHOTGUN2
: result
:= (FAmmo
[A_SHELLS
] > 1);
3794 WEAPON_PISTOL
, WEAPON_CHAINGUN
: result
:= (FAmmo
[A_BULLETS
] > 0);
3795 WEAPON_ROCKETLAUNCHER
: result
:= (FAmmo
[A_ROCKETS
] > 0);
3796 WEAPON_PLASMA
: result
:= (FAmmo
[A_CELLS
] > 0);
3797 WEAPON_BFG
: result
:= (FAmmo
[A_CELLS
] >= 40);
3798 WEAPON_FLAMETHROWER
: result
:= (FAmmo
[A_FUEL
] > 0);
3799 else result
:= (weapon
< length(FWeapon
));
3803 function TPlayer
.shouldSwitch (weapon
: Byte; hadWeapon
: Boolean): Boolean;
3806 if (weapon
> WP_LAST
+ 1) then
3811 if (FWeapSwitchMode
= 1) and not hadWeapon
then
3813 else if (FWeapSwitchMode
= 2) then
3814 result
:= (FWeapPreferences
[weapon
] > FWeapPreferences
[FCurrWeap
]);
3817 // return 255 for "no switch"
3818 function TPlayer
.getNextWeaponIndex (): Byte;
3821 wantThisWeapon
: array[0..64] of Boolean;
3822 wwc
: Integer = 0; //HACK!
3825 result
:= 255; // default result: "no switch"
3826 //e_LogWriteFln('FSWITCHTOEMPTY: %s', [FSwitchToEmpty], TMsgType.Notify);
3827 // had weapon cycling on previous frame? remove that flag
3828 if (FNextWeap
and $2000) <> 0 then
3830 FNextWeap
:= FNextWeap
and $1FFF;
3831 FNextWeapDelay
:= 0;
3833 // cycling has priority
3834 if (FNextWeap
and $C000) <> 0 then
3836 if (FNextWeap
and $8000) <> 0 then
3840 FNextWeap
:= FNextWeap
or $2000; // we need this
3841 if FNextWeapDelay
> 0 then
3842 exit
; // cooldown time
3844 for i
:= 0 to High(FWeapon
) do
3846 cwi
:= (cwi
+length(FWeapon
)+dir
) mod length(FWeapon
);
3847 if FWeapon
[cwi
] and maySwitch(cwi
) then
3849 //e_LogWriteFln(' SWITCH: cur=%d; new=%d %s %s', [FCurrWeap, cwi, FSwitchToEmpty, hasAmmoForWeapon(cwi)], TMsgType.Notify);
3850 result
:= Byte(cwi
);
3851 FNextWeapDelay
:= WEAPON_DELAY
;
3859 for i
:= 0 to High(wantThisWeapon
) do
3860 wantThisWeapon
[i
] := false;
3861 for i
:= 0 to High(FWeapon
) do
3862 if (FNextWeap
and (1 shl i
)) <> 0 then
3864 wantThisWeapon
[i
] := true;
3868 // exclude currently selected weapon from the set
3869 wantThisWeapon
[FCurrWeap
] := false;
3870 // slow down alterations a little
3873 //e_WriteLog(Format(' FNextWeap=%x; delay=%d', [FNextWeap, FNextWeapDelay]), MSG_WARNING);
3874 // more than one weapon requested, assume "alteration" and check alteration delay
3875 if FNextWeapDelay
> 0 then
3881 // do not reset weapon queue, it will be done in `RealizeCurrentWeapon()`
3882 // but clear all counters if no weapon should be switched
3888 //e_WriteLog(Format('wwc=%d', [wwc]), MSG_WARNING);
3889 // try weapons in descending order
3890 for i
:= High(FWeapon
) downto 0 do
3892 if wantThisWeapon
[i
] and FWeapon
[i
] and ((wwc
= 1) or hasAmmoForWeapon(i
)) then
3897 FNextWeapDelay
:= WEAPON_DELAY
* 2; // anyway, 'cause why not
3898 //e_LogWriteFln('FOUND %s %s %s', [result, FSwitchToEmpty, hasAmmoForWeapon(i)], TMsgType.Notify);
3902 // no suitable weapon found, so reset the queue, to avoid accidental "queuing" of weapon w/o ammo
3906 procedure TPlayer
.RealizeCurrentWeapon();
3907 function switchAllowed (): Boolean;
3912 if FBFGFireCounter
<> -1 then
3914 if FTime
[T_SWITCH
] > gTime
then
3916 for i
:= WP_FIRST
to WP_LAST
do
3917 if FReloading
[i
] > 0 then
3925 //e_WriteLog(Format('***RealizeCurrentWeapon: FNextWeap=%x; FNextWeapDelay=%d', [FNextWeap, FNextWeapDelay]), MSG_WARNING);
3926 //FNextWeap := FNextWeap and $1FFF;
3927 if FNextWeapDelay
> 0 then Dec(FNextWeapDelay
); // "alteration delay"
3929 if not switchAllowed
then
3931 //HACK for weapon cycling
3932 if (FNextWeap
and $E000) <> 0 then FNextWeap
:= 0;
3936 nw
:= getNextWeaponIndex();
3938 if nw
= 255 then exit
; // don't reset anything here
3939 if nw
> High(FWeapon
) then
3941 // don't forget to reset queue here!
3942 //e_WriteLog(' RealizeCurrentWeapon: WUTAFUUUU', MSG_WARNING);
3950 FTime
[T_SWITCH
] := gTime
+156;
3951 if FCurrWeap
= WEAPON_SAW
then FSawSoundSelect
.PlayAt(FObj
.X
, FObj
.Y
);
3952 FModel
.SetWeapon(FCurrWeap
);
3953 if g_Game_IsNet
then MH_SEND_PlayerStats(FUID
);
3957 procedure TPlayer
.NextWeapon();
3959 if g_Game_IsClient
then Exit
;
3963 procedure TPlayer
.PrevWeapon();
3965 if g_Game_IsClient
then Exit
;
3969 procedure TPlayer
.SetWeapon(W
: Byte);
3971 if FCurrWeap
<> W
then
3972 if W
= WEAPON_SAW
then
3973 FSawSoundSelect
.PlayAt(FObj
.X
, FObj
.Y
);
3976 FModel
.SetWeapon(CurrWeap
);
3980 function TPlayer
.PickItem(ItemType
: Byte; arespawn
: Boolean; var remove
: Boolean): Boolean;
3983 switchWeapon
: Byte = 255;
3984 hadWeapon
: Boolean = False;
3987 if g_Game_IsClient
then Exit
;
3989 // a = true - ìåñòî ñïàâíà ïðåäìåòà:
3990 a
:= LongBool(gGameSettings
.Options
and GAME_OPTION_WEAPONSTAY
) and arespawn
;
3994 if (FHealth
< PLAYER_HP_SOFT
) or (FFireTime
> 0) then
3996 if FHealth
< PLAYER_HP_SOFT
then IncMax(FHealth
, 10, PLAYER_HP_SOFT
);
4000 if gFlash
= 2 then Inc(FPickup
, 5);
4004 if (FHealth
< PLAYER_HP_SOFT
) or (FFireTime
> 0) then
4006 if FHealth
< PLAYER_HP_SOFT
then IncMax(FHealth
, 25, PLAYER_HP_SOFT
);
4010 if gFlash
= 2 then Inc(FPickup
, 5);
4014 if FArmor
< PLAYER_AP_SOFT
then
4016 FArmor
:= PLAYER_AP_SOFT
;
4019 if gFlash
= 2 then Inc(FPickup
, 5);
4023 if FArmor
< PLAYER_AP_LIMIT
then
4025 FArmor
:= PLAYER_AP_LIMIT
;
4028 if gFlash
= 2 then Inc(FPickup
, 5);
4032 if (FHealth
< PLAYER_HP_LIMIT
) or (FFireTime
> 0) then
4034 if FHealth
< PLAYER_HP_LIMIT
then IncMax(FHealth
, 100, PLAYER_HP_LIMIT
);
4038 if gFlash
= 2 then Inc(FPickup
, 5);
4042 if (FHealth
< PLAYER_HP_LIMIT
) or (FArmor
< PLAYER_AP_LIMIT
) or (FFireTime
> 0) then
4044 if FHealth
< PLAYER_HP_LIMIT
then
4045 FHealth
:= PLAYER_HP_LIMIT
;
4046 if FArmor
< PLAYER_AP_LIMIT
then
4047 FArmor
:= PLAYER_AP_LIMIT
;
4051 if gFlash
= 2 then Inc(FPickup
, 5);
4055 if (not FWeapon
[WEAPON_SAW
]) or ((not arespawn
) and (gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
])) then
4057 hadWeapon
:= FWeapon
[WEAPON_SAW
];
4058 switchWeapon
:= WEAPON_SAW
;
4059 FWeapon
[WEAPON_SAW
] := True;
4061 if gFlash
= 2 then Inc(FPickup
, 5);
4062 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
4065 ITEM_WEAPON_SHOTGUN1
:
4066 if (FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
]) or not FWeapon
[WEAPON_SHOTGUN1
] then
4068 // Íóæíî, ÷òîáû íå âçÿòü âñå ïóëè ñðàçó:
4069 if a
and FWeapon
[WEAPON_SHOTGUN1
] then Exit
;
4070 hadWeapon
:= FWeapon
[WEAPON_SHOTGUN1
];
4071 switchWeapon
:= WEAPON_SHOTGUN1
;
4072 IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
4073 FWeapon
[WEAPON_SHOTGUN1
] := True;
4075 if gFlash
= 2 then Inc(FPickup
, 5);
4076 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
4079 ITEM_WEAPON_SHOTGUN2
:
4080 if (FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
]) or not FWeapon
[WEAPON_SHOTGUN2
] then
4082 if a
and FWeapon
[WEAPON_SHOTGUN2
] then Exit
;
4083 hadWeapon
:= FWeapon
[WEAPON_SHOTGUN2
];
4084 switchWeapon
:= WEAPON_SHOTGUN2
;
4085 IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
4086 FWeapon
[WEAPON_SHOTGUN2
] := True;
4088 if gFlash
= 2 then Inc(FPickup
, 5);
4089 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
4092 ITEM_WEAPON_CHAINGUN
:
4093 if (FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
]) or not FWeapon
[WEAPON_CHAINGUN
] then
4095 if a
and FWeapon
[WEAPON_CHAINGUN
] then Exit
;
4096 hadWeapon
:= FWeapon
[WEAPON_CHAINGUN
];
4097 switchWeapon
:= WEAPON_CHAINGUN
;
4098 IncMax(FAmmo
[A_BULLETS
], 50, FMaxAmmo
[A_BULLETS
]);
4099 FWeapon
[WEAPON_CHAINGUN
] := True;
4101 if gFlash
= 2 then Inc(FPickup
, 5);
4102 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
4105 ITEM_WEAPON_ROCKETLAUNCHER
:
4106 if (FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
]) or not FWeapon
[WEAPON_ROCKETLAUNCHER
] then
4108 if a
and FWeapon
[WEAPON_ROCKETLAUNCHER
] then Exit
;
4109 switchWeapon
:= WEAPON_ROCKETLAUNCHER
;
4110 hadWeapon
:= FWeapon
[WEAPON_ROCKETLAUNCHER
];
4111 IncMax(FAmmo
[A_ROCKETS
], 2, FMaxAmmo
[A_ROCKETS
]);
4112 FWeapon
[WEAPON_ROCKETLAUNCHER
] := True;
4114 if gFlash
= 2 then Inc(FPickup
, 5);
4115 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
4119 if (FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
]) or not FWeapon
[WEAPON_PLASMA
] then
4121 if a
and FWeapon
[WEAPON_PLASMA
] then Exit
;
4122 switchWeapon
:= WEAPON_PLASMA
;
4123 hadWeapon
:= FWeapon
[WEAPON_PLASMA
];
4124 IncMax(FAmmo
[A_CELLS
], 40, FMaxAmmo
[A_CELLS
]);
4125 FWeapon
[WEAPON_PLASMA
] := True;
4127 if gFlash
= 2 then Inc(FPickup
, 5);
4128 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
4132 if (FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
]) or not FWeapon
[WEAPON_BFG
] then
4134 if a
and FWeapon
[WEAPON_BFG
] then Exit
;
4135 switchWeapon
:= WEAPON_BFG
;
4136 hadWeapon
:= FWeapon
[WEAPON_BFG
];
4137 IncMax(FAmmo
[A_CELLS
], 40, FMaxAmmo
[A_CELLS
]);
4138 FWeapon
[WEAPON_BFG
] := True;
4140 if gFlash
= 2 then Inc(FPickup
, 5);
4141 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
4144 ITEM_WEAPON_SUPERPULEMET
:
4145 if (FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
]) or not FWeapon
[WEAPON_SUPERPULEMET
] then
4147 if a
and FWeapon
[WEAPON_SUPERPULEMET
] then Exit
;
4148 switchWeapon
:= WEAPON_SUPERPULEMET
;
4149 hadWeapon
:= FWeapon
[WEAPON_SUPERPULEMET
];
4150 IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
4151 FWeapon
[WEAPON_SUPERPULEMET
] := True;
4153 if gFlash
= 2 then Inc(FPickup
, 5);
4154 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
4157 ITEM_WEAPON_FLAMETHROWER
:
4158 if (FAmmo
[A_FUEL
] < FMaxAmmo
[A_FUEL
]) or not FWeapon
[WEAPON_FLAMETHROWER
] then
4160 if a
and FWeapon
[WEAPON_FLAMETHROWER
] then Exit
;
4161 switchWeapon
:= WEAPON_FLAMETHROWER
;
4162 hadWeapon
:= FWeapon
[WEAPON_FLAMETHROWER
];
4163 IncMax(FAmmo
[A_FUEL
], 100, FMaxAmmo
[A_FUEL
]);
4164 FWeapon
[WEAPON_FLAMETHROWER
] := True;
4166 if gFlash
= 2 then Inc(FPickup
, 5);
4167 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
4171 if FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
] then
4173 IncMax(FAmmo
[A_BULLETS
], 10, FMaxAmmo
[A_BULLETS
]);
4176 if gFlash
= 2 then Inc(FPickup
, 5);
4179 ITEM_AMMO_BULLETS_BOX
:
4180 if FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
] then
4182 IncMax(FAmmo
[A_BULLETS
], 50, FMaxAmmo
[A_BULLETS
]);
4185 if gFlash
= 2 then Inc(FPickup
, 5);
4189 if FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
] then
4191 IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
4194 if gFlash
= 2 then Inc(FPickup
, 5);
4197 ITEM_AMMO_SHELLS_BOX
:
4198 if FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
] then
4200 IncMax(FAmmo
[A_SHELLS
], 25, FMaxAmmo
[A_SHELLS
]);
4203 if gFlash
= 2 then Inc(FPickup
, 5);
4207 if FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
] then
4209 IncMax(FAmmo
[A_ROCKETS
], 1, FMaxAmmo
[A_ROCKETS
]);
4212 if gFlash
= 2 then Inc(FPickup
, 5);
4215 ITEM_AMMO_ROCKET_BOX
:
4216 if FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
] then
4218 IncMax(FAmmo
[A_ROCKETS
], 5, FMaxAmmo
[A_ROCKETS
]);
4221 if gFlash
= 2 then Inc(FPickup
, 5);
4225 if FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
] then
4227 IncMax(FAmmo
[A_CELLS
], 40, FMaxAmmo
[A_CELLS
]);
4230 if gFlash
= 2 then Inc(FPickup
, 5);
4234 if FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
] then
4236 IncMax(FAmmo
[A_CELLS
], 100, FMaxAmmo
[A_CELLS
]);
4239 if gFlash
= 2 then Inc(FPickup
, 5);
4243 if FAmmo
[A_FUEL
] < FMaxAmmo
[A_FUEL
] then
4245 IncMax(FAmmo
[A_FUEL
], 100, FMaxAmmo
[A_FUEL
]);
4248 if gFlash
= 2 then Inc(FPickup
, 5);
4252 if not(R_ITEM_BACKPACK
in FRulez
) or
4253 (FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
]) or
4254 (FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
]) or
4255 (FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
]) or
4256 (FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
]) or
4257 (FAmmo
[A_FUEL
] < FMaxAmmo
[A_FUEL
]) then
4259 FMaxAmmo
[A_BULLETS
] := AmmoLimits
[1, A_BULLETS
];
4260 FMaxAmmo
[A_SHELLS
] := AmmoLimits
[1, A_SHELLS
];
4261 FMaxAmmo
[A_ROCKETS
] := AmmoLimits
[1, A_ROCKETS
];
4262 FMaxAmmo
[A_CELLS
] := AmmoLimits
[1, A_CELLS
];
4263 FMaxAmmo
[A_FUEL
] := AmmoLimits
[1, A_FUEL
];
4265 if FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
] then
4266 IncMax(FAmmo
[A_BULLETS
], 10, FMaxAmmo
[A_BULLETS
]);
4267 if FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
] then
4268 IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
4269 if FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
] then
4270 IncMax(FAmmo
[A_ROCKETS
], 1, FMaxAmmo
[A_ROCKETS
]);
4271 if FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
] then
4272 IncMax(FAmmo
[A_CELLS
], 40, FMaxAmmo
[A_CELLS
]);
4273 if FAmmo
[A_FUEL
] < FMaxAmmo
[A_FUEL
] then
4274 IncMax(FAmmo
[A_FUEL
], 50, FMaxAmmo
[A_FUEL
]);
4276 FRulez
:= FRulez
+ [R_ITEM_BACKPACK
];
4279 if gFlash
= 2 then Inc(FPickup
, 5);
4283 if not(R_KEY_RED
in FRulez
) then
4285 Include(FRulez
, R_KEY_RED
);
4287 remove
:= (gGameSettings
.GameMode
<> GM_COOP
) and (g_Player_GetCount() < 2);
4288 if gFlash
= 2 then Inc(FPickup
, 5);
4289 if (not remove
) and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETITEM');
4293 if not(R_KEY_GREEN
in FRulez
) then
4295 Include(FRulez
, R_KEY_GREEN
);
4297 remove
:= (gGameSettings
.GameMode
<> GM_COOP
) and (g_Player_GetCount() < 2);
4298 if gFlash
= 2 then Inc(FPickup
, 5);
4299 if (not remove
) and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETITEM');
4303 if not(R_KEY_BLUE
in FRulez
) then
4305 Include(FRulez
, R_KEY_BLUE
);
4307 remove
:= (gGameSettings
.GameMode
<> GM_COOP
) and (g_Player_GetCount() < 2);
4308 if gFlash
= 2 then Inc(FPickup
, 5);
4309 if (not remove
) and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETITEM');
4313 if FMegaRulez
[MR_SUIT
] < gTime
+PLAYER_SUIT_TIME
then
4315 FMegaRulez
[MR_SUIT
] := gTime
+PLAYER_SUIT_TIME
;
4319 if gFlash
= 2 then Inc(FPickup
, 5);
4323 if FAir
< AIR_MAX
then
4328 if gFlash
= 2 then Inc(FPickup
, 5);
4333 if not (R_BERSERK
in FRulez
) then
4335 Include(FRulez
, R_BERSERK
);
4336 if (FBFGFireCounter
= -1) then
4338 FCurrWeap
:= WEAPON_KASTET
;
4340 FModel
.SetWeapon(WEAPON_KASTET
);
4345 if gFlash
= 2 then Inc(FPickup
, 5);
4347 FBerserk
:= gTime
+30000;
4352 if (FHealth
< PLAYER_HP_SOFT
) or (FFireTime
> 0) then
4354 if FHealth
< PLAYER_HP_SOFT
then FHealth
:= PLAYER_HP_SOFT
;
4355 FBerserk
:= gTime
+30000;
4363 if FMegaRulez
[MR_INVUL
] < gTime
+PLAYER_INVUL_TIME
then
4365 FMegaRulez
[MR_INVUL
] := gTime
+PLAYER_INVUL_TIME
;
4369 if gFlash
= 2 then Inc(FPickup
, 5);
4373 if (FHealth
< PLAYER_HP_LIMIT
) or (FFireTime
> 0) then
4375 if FHealth
< PLAYER_HP_LIMIT
then IncMax(FHealth
, 4, PLAYER_HP_LIMIT
);
4379 if gFlash
= 2 then Inc(FPickup
, 5);
4383 if FArmor
< PLAYER_AP_LIMIT
then
4385 IncMax(FArmor
, 5, PLAYER_AP_LIMIT
);
4388 if gFlash
= 2 then Inc(FPickup
, 5);
4392 if FJetFuel
< JET_MAX
then
4394 FJetFuel
:= JET_MAX
;
4397 if gFlash
= 2 then Inc(FPickup
, 5);
4401 if FMegaRulez
[MR_INVIS
] < gTime
+PLAYER_INVIS_TIME
then
4403 FMegaRulez
[MR_INVIS
] := gTime
+PLAYER_INVIS_TIME
;
4406 if gFlash
= 2 then Inc(FPickup
, 5);
4410 if (shouldSwitch(switchWeapon
, hadWeapon
)) then
4411 QueueWeaponSwitch(switchWeapon
);
4414 procedure TPlayer
.Touch();
4418 //FModel.PlaySound(MODELSOUND_PAIN, 1, FObj.X, FObj.Y);
4421 // Áðîñèòü ôëàã òîâàðèùó:
4422 if gGameSettings
.GameMode
= GM_CTF
then
4427 procedure TPlayer
.Push(vx
, vy
: Integer);
4429 if (not FPhysics
) and FGhost
then
4431 FObj
.Accel
.X
:= FObj
.Accel
.X
+ vx
;
4432 FObj
.Accel
.Y
:= FObj
.Accel
.Y
+ vy
;
4433 if g_Game_IsNet
and g_Game_IsServer
then
4434 MH_SEND_PlayerPos(True, FUID
, NET_EVERYONE
);
4437 procedure TPlayer
.Reset(Force
: Boolean);
4443 FTime
[T_RESPAWN
] := 0;
4444 FTime
[T_FLAGCAP
] := 0;
4460 FSpectator
:= False;
4463 FSpectatePlayer
:= -1;
4464 FNoRespawn
:= False;
4466 FLives
:= gGameSettings
.MaxLives
;
4471 procedure TPlayer
.SoftReset();
4479 FBFGFireCounter
:= -1;
4487 SetAction(A_STAND
, True);
4490 function TPlayer
.GetRespawnPoint(): Byte;
4495 // Íà áóäóùåå: FSpawn - èãðîê óæå èãðàë è ïåðåðîæäàåòñÿ
4497 // Îäèíî÷íàÿ èãðà/êîîïåðàòèâ
4498 if gGameSettings
.GameMode
in [GM_COOP
, GM_SINGLE
] then
4500 if Self
= gPlayer1
then
4502 // player 1 should try to spawn on the player 1 point
4503 if g_Map_GetPointCount(RESPAWNPOINT_PLAYER1
) > 0 then
4504 Exit(RESPAWNPOINT_PLAYER1
)
4505 else if g_Map_GetPointCount(RESPAWNPOINT_PLAYER2
) > 0 then
4506 Exit(RESPAWNPOINT_PLAYER2
);
4508 else if Self
= gPlayer2
then
4510 // player 2 should try to spawn on the player 2 point
4511 if g_Map_GetPointCount(RESPAWNPOINT_PLAYER2
) > 0 then
4512 Exit(RESPAWNPOINT_PLAYER2
)
4513 else if g_Map_GetPointCount(RESPAWNPOINT_PLAYER1
) > 0 then
4514 Exit(RESPAWNPOINT_PLAYER1
);
4518 // other players randomly pick either the first or the second point
4519 c
:= IfThen((Random(2) = 0), RESPAWNPOINT_PLAYER1
, RESPAWNPOINT_PLAYER2
);
4520 if g_Map_GetPointCount(c
) > 0 then
4522 // try the other one
4523 c
:= IfThen((c
= RESPAWNPOINT_PLAYER1
), RESPAWNPOINT_PLAYER2
, RESPAWNPOINT_PLAYER1
);
4524 if g_Map_GetPointCount(c
) > 0 then
4530 if gGameSettings
.GameMode
= GM_DM
then
4532 // try DM points first
4533 if g_Map_GetPointCount(RESPAWNPOINT_DM
) > 0 then
4534 Exit(RESPAWNPOINT_DM
);
4538 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
4540 // try team points first
4541 c
:= RESPAWNPOINT_DM
;
4542 if FTeam
= TEAM_RED
then
4543 c
:= RESPAWNPOINT_RED
4544 else if FTeam
= TEAM_BLUE
then
4545 c
:= RESPAWNPOINT_BLUE
;
4546 if g_Map_GetPointCount(c
) > 0 then
4550 // still haven't found a spawnpoint, try random shit
4551 Result
:= g_Map_GetRandomPointType();
4554 procedure TPlayer
.Respawn(Silent
: Boolean; Force
: Boolean = False);
4556 RespawnPoint
: TRespawnPoint
;
4564 FBFGFireCounter
:= -1;
4571 if not g_Game_IsServer
then
4575 FWantsInGame
:= True;
4576 FJustTeleported
:= True;
4579 FTime
[T_RESPAWN
] := 0;
4583 // if server changes MaxLives we gotta be ready
4584 if gGameSettings
.MaxLives
= 0 then FNoRespawn
:= False;
4586 // Åùå íåëüçÿ âîçðîäèòüñÿ:
4587 if FTime
[T_RESPAWN
] > gTime
then
4590 // Ïðîñðàë âñå æèçíè:
4593 if not FSpectator
then Spectate(True);
4594 FWantsInGame
:= True;
4598 if (gGameSettings
.GameType
<> GT_SINGLE
) and (gGameSettings
.GameMode
<> GM_COOP
) then
4599 begin // "Ñâîÿ èãðà"
4600 // Áåðñåðê íå ñîõðàíÿåòñÿ ìåæäó óðîâíÿìè:
4601 FRulez
:= FRulez
-[R_BERSERK
];
4603 else // "Îäèíî÷íàÿ èãðà"/"Êîîï"
4605 // Áåðñåðê è êëþ÷è íå ñîõðàíÿþòñÿ ìåæäó óðîâíÿìè:
4606 FRulez
:= FRulez
-[R_KEY_RED
, R_KEY_GREEN
, R_KEY_BLUE
, R_BERSERK
];
4609 // Ïîëó÷àåì òî÷êó ñïàóíà èãðîêà:
4610 c
:= GetRespawnPoint();
4615 // Âîñêðåøåíèå áåç îðóæèÿ:
4618 FHealth
:= Round(PLAYER_HP_SOFT
* (FHandicap
/ 100));
4624 for a
:= WP_FIRST
to WP_LAST
do
4626 FWeapon
[a
] := False;
4630 FWeapon
[WEAPON_PISTOL
] := True;
4631 FWeapon
[WEAPON_KASTET
] := True;
4632 FCurrWeap
:= WEAPON_PISTOL
;
4635 FModel
.SetWeapon(FCurrWeap
);
4637 for b
:= A_BULLETS
to A_HIGH
do
4640 FAmmo
[A_BULLETS
] := 50;
4642 FMaxAmmo
[A_BULLETS
] := AmmoLimits
[0, A_BULLETS
];
4643 FMaxAmmo
[A_SHELLS
] := AmmoLimits
[0, A_SHELLS
];
4644 FMaxAmmo
[A_ROCKETS
] := AmmoLimits
[0, A_SHELLS
];
4645 FMaxAmmo
[A_CELLS
] := AmmoLimits
[0, A_CELLS
];
4646 FMaxAmmo
[A_FUEL
] := AmmoLimits
[0, A_FUEL
];
4648 if (gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
]) and
4649 LongBool(gGameSettings
.Options
and GAME_OPTION_DMKEYS
) then
4650 FRulez
:= [R_KEY_RED
, R_KEY_GREEN
, R_KEY_BLUE
]
4655 // Ïîëó÷àåì êîîðäèíàòû òî÷êè âîçðîæäåíèÿ:
4656 if not g_Map_GetPoint(c
, RespawnPoint
) then
4658 g_FatalError(_lc
[I_GAME_ERROR_GET_SPAWN
]);
4662 // Óñòàíîâêà êîîðäèíàò è ñáðîñ âñåõ ïàðàìåòðîâ:
4663 FObj
.X
:= RespawnPoint
.X
-PLAYER_RECT
.X
;
4664 FObj
.Y
:= RespawnPoint
.Y
-PLAYER_RECT
.Y
;
4665 FObj
.oldX
:= FObj
.X
; // don't interpolate after respawn
4666 FObj
.oldY
:= FObj
.Y
;
4672 FDirection
:= RespawnPoint
.Direction
;
4673 if FDirection
= TDirection
.D_LEFT
then
4678 SetAction(A_STAND
, True);
4679 FModel
.Direction
:= FDirection
;
4681 for a
:= Low(FTime
) to High(FTime
) do
4684 for a
:= Low(FMegaRulez
) to High(FMegaRulez
) do
4687 // Respawn invulnerability
4688 if (gGameSettings
.GameType
<> GT_SINGLE
) and (gGameSettings
.SpawnInvul
> 0) then
4690 FMegaRulez
[MR_INVUL
] := gTime
+ gGameSettings
.SpawnInvul
* 1000;
4691 FSpawnInvul
:= FMegaRulez
[MR_INVUL
];
4696 FCanJetpack
:= False;
4702 // Àíèìàöèÿ âîçðîæäåíèÿ:
4703 if (not gLoadGameMode
) and (not Silent
) then
4704 if g_Frames_Get(ID
, 'FRAMES_TELEPORT') then
4706 Anim
:= TAnimation
.Create(ID
, False, 3);
4707 g_GFX_OnceAnim(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-32,
4708 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)-32, Anim
);
4712 FSpectator
:= False;
4715 FSpectatePlayer
:= -1;
4718 if (gPlayer1
= nil) and (gSpectLatchPID1
= FUID
) then
4720 if (gPlayer2
= nil) and (gSpectLatchPID2
= FUID
) then
4723 if g_Game_IsNet
then
4725 MH_SEND_PlayerPos(True, FUID
, NET_EVERYONE
);
4726 MH_SEND_PlayerStats(FUID
, NET_EVERYONE
);
4728 MH_SEND_Effect(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-32,
4729 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)-32,
4734 procedure TPlayer
.Spectate(NoMove
: Boolean = False);
4737 Kill(K_EXTRAHARDKILL
, FUID
, HIT_SOME
)
4738 else if (not NoMove
) then
4740 GameX
:= gMapInfo
.Width
div 2;
4741 GameY
:= gMapInfo
.Height
div 2;
4750 FWantsInGame
:= False;
4756 if Self
= gPlayer1
then
4758 gSpectLatchPID1
:= FUID
;
4761 else if Self
= gPlayer2
then
4763 gSpectLatchPID2
:= FUID
;
4768 if g_Game_IsNet
then
4769 MH_SEND_PlayerStats(FUID
);
4772 procedure TPlayer
.SwitchNoClip
;
4776 FGhost
:= not FGhost
;
4777 FPhysics
:= not FGhost
;
4789 procedure TPlayer
.Run(Direction
: TDirection
);
4793 if MAX_RUNVEL
> 8 then
4797 if Direction
= TDirection
.D_LEFT
then
4799 if FObj
.Vel
.X
> -MAX_RUNVEL
then
4800 FObj
.Vel
.X
:= FObj
.Vel
.X
- (MAX_RUNVEL
shr 3);
4803 if FObj
.Vel
.X
< MAX_RUNVEL
then
4804 FObj
.Vel
.X
:= FObj
.Vel
.X
+ (MAX_RUNVEL
shr 3);
4806 // Âîçìîæíî, ïèíàåì êóñêè:
4807 if (FObj
.Vel
.X
<> 0) and (gGibs
<> nil) then
4809 b
:= Abs(FObj
.Vel
.X
);
4810 if b
> 1 then b
:= b
* (Random(8 div b
) + 1);
4811 for a
:= 0 to High(gGibs
) do
4813 if gGibs
[a
].alive
and
4814 g_Obj_Collide(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
+FObj
.Rect
.Height
-4,
4815 FObj
.Rect
.Width
, 8, @gGibs
[a
].Obj
) and (Random(3) = 0) then
4818 if FObj
.Vel
.X
< 0 then
4820 g_Obj_PushA(@gGibs
[a
].Obj
, b
, Random(61)+120) // íàëåâî
4824 g_Obj_PushA(@gGibs
[a
].Obj
, b
, Random(61)); // íàïðàâî
4826 gGibs
[a
].positionChanged(); // this updates spatial accelerators
4834 procedure TPlayer
.SeeDown();
4836 SetAction(A_SEEDOWN
);
4838 if FDirection
= TDirection
.D_LEFT
then FAngle
:= ANGLE_LEFTDOWN
else FAngle
:= ANGLE_RIGHTDOWN
;
4840 if FIncCam
> -120 then DecMin(FIncCam
, 5, -120);
4843 procedure TPlayer
.SeeUp();
4847 if FDirection
= TDirection
.D_LEFT
then FAngle
:= ANGLE_LEFTUP
else FAngle
:= ANGLE_RIGHTUP
;
4849 if FIncCam
< 120 then IncMax(FIncCam
, 5, 120);
4852 procedure TPlayer
.SetAction(Action
: Byte; Force
: Boolean = False);
4860 A_ATTACK
: Prior
:= 2;
4861 A_SEEUP
: Prior
:= 1;
4862 A_SEEDOWN
: Prior
:= 1;
4863 A_ATTACKUP
: Prior
:= 2;
4864 A_ATTACKDOWN
: Prior
:= 2;
4869 if (Prior
> FActionPrior
) or Force
then
4870 if not ((Prior
= 2) and (FCurrWeap
= WEAPON_SAW
)) then
4872 FActionPrior
:= Prior
;
4873 FActionAnim
:= Action
;
4874 FActionForce
:= Force
;
4875 FActionChanged
:= True;
4878 if Action
in [A_ATTACK
, A_ATTACKUP
, A_ATTACKDOWN
] then FModel
.SetFire(True);
4881 function TPlayer
.StayOnStep(XInc
, YInc
: Integer): Boolean;
4883 Result
:= not g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+YInc
+PLAYER_RECT
.Y
+PLAYER_RECT
.Height
-1,
4884 PLAYER_RECT
.Width
, 1, PANEL_STEP
, False)
4885 and g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+YInc
+PLAYER_RECT
.Y
+PLAYER_RECT
.Height
,
4886 PLAYER_RECT
.Width
, 1, PANEL_STEP
, False);
4889 function TPlayer
.TeleportTo(X
, Y
: Integer; silent
: Boolean; dir
: Byte): Boolean;
4896 if g_CollideLevel(X
, Y
, PLAYER_RECT
.Width
, PLAYER_RECT
.Height
) then
4898 g_Sound_PlayExAt('SOUND_GAME_NOTELEPORT', FObj
.X
, FObj
.Y
);
4899 if g_Game_IsServer
and g_Game_IsNet
then
4900 MH_SEND_Sound(FObj
.X
, FObj
.Y
, 'SOUND_GAME_NOTELEPORT');
4904 FJustTeleported
:= True;
4909 if g_Frames_Get(ID
, 'FRAMES_TELEPORT') then
4911 Anim
:= TAnimation
.Create(ID
, False, 3);
4914 g_Sound_PlayExAt('SOUND_GAME_TELEPORT', FObj
.X
, FObj
.Y
);
4915 g_GFX_OnceAnim(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-32,
4916 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)-32, Anim
);
4917 if g_Game_IsServer
and g_Game_IsNet
then
4918 MH_SEND_Effect(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-32,
4919 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)-32, 1,
4923 FObj
.X
:= X
-PLAYER_RECT
.X
;
4924 FObj
.Y
:= Y
-PLAYER_RECT
.Y
;
4925 FObj
.oldX
:= FObj
.X
; // don't interpolate after respawn
4926 FObj
.oldY
:= FObj
.Y
;
4927 if FAlive
and FGhost
then
4933 if not g_Game_IsNet
then
4937 SetDirection(TDirection
.D_LEFT
);
4943 SetDirection(TDirection
.D_RIGHT
);
4949 if FDirection
= TDirection
.D_RIGHT
then
4951 SetDirection(TDirection
.D_LEFT
);
4956 SetDirection(TDirection
.D_RIGHT
);
4962 if not silent
and (Anim
<> nil) then
4964 g_GFX_OnceAnim(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-32,
4965 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)-32, Anim
);
4968 if g_Game_IsServer
and g_Game_IsNet
then
4969 MH_SEND_Effect(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-32,
4970 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)-32, 0,
4977 function nonz(a
: Single): Single;
4985 function TPlayer
.refreshCorpse(): Boolean;
4991 if FAlive
or FSpectator
then
4993 if (gCorpses
= nil) or (Length(gCorpses
) = 0) then
4995 for i
:= 0 to High(gCorpses
) do
4996 if gCorpses
[i
] <> nil then
4997 if gCorpses
[i
].FPlayerUID
= FUID
then
5005 function TPlayer
.getCameraObj(): TObj
;
5007 if (not FAlive
) and (not FSpectator
) and
5008 (FCorpse
>= 0) and (FCorpse
< Length(gCorpses
)) and
5009 (gCorpses
[FCorpse
] <> nil) and (gCorpses
[FCorpse
].FPlayerUID
= FUID
) then
5011 gCorpses
[FCorpse
].FObj
.slopeUpLeft
:= FObj
.slopeUpLeft
;
5012 Result
:= gCorpses
[FCorpse
].FObj
;
5020 procedure TPlayer
.PreUpdate();
5022 FSlopeOld
:= FObj
.slopeUpLeft
;
5023 FIncCamOld
:= FIncCam
;
5024 FObj
.oldX
:= FObj
.X
;
5025 FObj
.oldY
:= FObj
.Y
;
5028 procedure TPlayer
.Update();
5031 i
, ii
, wx
, wy
, xd
, yd
, k
: Integer;
5032 blockmon
, headwater
, dospawn
: Boolean;
5037 NetServer
:= g_Game_IsNet
and g_Game_IsServer
;
5038 AnyServer
:= g_Game_IsServer
;
5040 if g_Game_IsClient
and (NetInterpLevel
> 0) then
5041 DoLerp(NetInterpLevel
+ 1)
5047 if (FClientID
>= 0) and (NetClients
[FClientID
].Peer
<> nil) then
5049 FPing
:= NetClients
[FClientID
].Peer
^.lastRoundTripTime
;
5050 if NetClients
[FClientID
].Peer
^.packetsSent
> 0 then
5051 FLoss
:= Round(100*NetClients
[FClientID
].Peer
^.packetsLost
/NetClients
[FClientID
].Peer
^.packetsSent
)
5060 if FAlive
and (FPunchAnim
<> nil) then
5061 FPunchAnim
.Update();
5063 if FAlive
and (gFly
or FJetpack
) then
5066 if FDirection
= TDirection
.D_LEFT
then
5071 if FAlive
and (not FGhost
) then
5073 if FKeys
[KEY_UP
].Pressed
then
5075 if FKeys
[KEY_DOWN
].Pressed
then
5079 if (not (FKeys
[KEY_UP
].Pressed
or FKeys
[KEY_DOWN
].Pressed
)) and
5082 i
:= g_basic
.Sign(FIncCam
);
5083 FIncCam
:= Abs(FIncCam
);
5084 DecMin(FIncCam
, 5, 0);
5085 FIncCam
:= FIncCam
*i
;
5088 if gTime
mod (GAME_TICK
*2) <> 0 then
5090 if (FObj
.Vel
.X
= 0) and FAlive
then
5092 if FKeys
[KEY_LEFT
].Pressed
then
5093 Run(TDirection
.D_LEFT
);
5094 if FKeys
[KEY_RIGHT
].Pressed
then
5095 Run(TDirection
.D_RIGHT
);
5100 g_Obj_Move(@FObj
, True, True, True);
5101 positionChanged(); // this updates spatial accelerators
5107 FActionChanged
:= False;
5111 // Let alive player do some actions
5112 if FKeys
[KEY_LEFT
].Pressed
then Run(TDirection
.D_LEFT
);
5113 if FKeys
[KEY_RIGHT
].Pressed
then Run(TDirection
.D_RIGHT
);
5114 if FKeys
[KEY_FIRE
].Pressed
and AnyServer
then Fire()
5120 if NetServer
then MH_SEND_PlayerStats(FUID
);
5123 if FKeys
[KEY_OPEN
].Pressed
and AnyServer
then Use();
5124 if FKeys
[KEY_JUMP
].Pressed
then Jump()
5127 if AnyServer
and FJetpack
then
5131 if NetServer
then MH_SEND_PlayerStats(FUID
);
5133 FCanJetpack
:= True;
5140 for k
:= Low(FKeys
) to KEY_CHAT
-1 do
5142 if FKeys
[k
].Pressed
then
5150 if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
5153 if (FTime
[T_RESPAWN
] <= gTime
) and
5154 gGameOn
and (not FAlive
) then
5156 if (g_Player_GetCount() > 1) then
5160 gExit
:= EXIT_RESTART
;
5165 // Dead spectator actions
5168 if FKeys
[KEY_OPEN
].Pressed
and AnyServer
then Fire();
5169 if FKeys
[KEY_FIRE
].Pressed
and AnyServer
then
5173 if (FSpectatePlayer
>= High(gPlayers
)) then
5174 FSpectatePlayer
:= -1
5178 for I
:= FSpectatePlayer
+ 1 to High(gPlayers
) do
5179 if gPlayers
[I
] <> nil then
5180 if gPlayers
[I
].alive
then
5181 if gPlayers
[I
].UID
<> FUID
then
5183 FSpectatePlayer
:= I
;
5188 if not SetSpect
then FSpectatePlayer
:= -1;
5199 if FKeys
[KEY_UP
].Pressed
or FKeys
[KEY_JUMP
].Pressed
then
5201 FYTo
:= FObj
.Y
- 32;
5202 FSpectatePlayer
:= -1;
5204 if FKeys
[KEY_DOWN
].Pressed
then
5206 FYTo
:= FObj
.Y
+ 32;
5207 FSpectatePlayer
:= -1;
5209 if FKeys
[KEY_LEFT
].Pressed
then
5211 FXTo
:= FObj
.X
- 32;
5212 FSpectatePlayer
:= -1;
5214 if FKeys
[KEY_RIGHT
].Pressed
then
5216 FXTo
:= FObj
.X
+ 32;
5217 FSpectatePlayer
:= -1;
5220 if (FXTo
< -64) then
5222 else if (FXTo
> gMapInfo
.Width
+ 32) then
5223 FXTo
:= gMapInfo
.Width
+ 32;
5224 if (FYTo
< -72) then
5226 else if (FYTo
> gMapInfo
.Height
+ 32) then
5227 FYTo
:= gMapInfo
.Height
+ 32;
5232 g_Obj_Move(@FObj
, True, True, True);
5233 positionChanged(); // this updates spatial accelerators
5240 if (FSpectatePlayer
<= High(gPlayers
)) and (FSpectatePlayer
>= 0) then
5241 if gPlayers
[FSpectatePlayer
] <> nil then
5242 if gPlayers
[FSpectatePlayer
].alive
then
5244 FXTo
:= gPlayers
[FSpectatePlayer
].GameX
;
5245 FYTo
:= gPlayers
[FSpectatePlayer
].GameY
;
5249 blockmon
:= g_Map_CollidePanel(FObj
.X
+PLAYER_HEADRECT
.X
, FObj
.Y
+PLAYER_HEADRECT
.Y
,
5250 PLAYER_HEADRECT
.Width
, PLAYER_HEADRECT
.Height
,
5251 PANEL_BLOCKMON
, True);
5252 headwater
:= HeadInLiquid(0, 0);
5254 // Ñîïðîòèâëåíèå âîçäóõà:
5255 if (not FAlive
) or not (FKeys
[KEY_LEFT
].Pressed
or FKeys
[KEY_RIGHT
].Pressed
) then
5256 if FObj
.Vel
.X
<> 0 then
5257 FObj
.Vel
.X
:= z_dec(FObj
.Vel
.X
, 1);
5259 if (FLastHit
= HIT_TRAP
) and (FPain
> 90) then FPain
:= 90;
5260 DecMin(FPain
, 5, 0);
5261 DecMin(FPickup
, 1, 0);
5263 if FAlive
and (FObj
.Y
> Integer(gMapInfo
.Height
)+128) and AnyServer
then
5265 // Îáíóëèòü äåéñòâèÿ ïðèìî÷åê, ÷òîáû ôîí ïðîïàë
5266 FMegaRulez
[MR_SUIT
] := 0;
5267 FMegaRulez
[MR_INVUL
] := 0;
5268 FMegaRulez
[MR_INVIS
] := 0;
5269 Kill(K_FALLKILL
, 0, HIT_FALL
);
5276 if FCurrWeap
= WEAPON_SAW
then
5277 if not (FSawSound
.IsPlaying() or FSawSoundHit
.IsPlaying() or
5278 FSawSoundSelect
.IsPlaying()) then
5279 FSawSoundIdle
.PlayAt(FObj
.X
, FObj
.Y
);
5282 if (not FJetSoundFly
.IsPlaying()) and (not FJetSoundOn
.IsPlaying()) and
5283 (not FJetSoundOff
.IsPlaying()) then
5285 FJetSoundFly
.SetPosition(0);
5286 FJetSoundFly
.PlayAt(FObj
.X
, FObj
.Y
);
5289 for b
:= WP_FIRST
to WP_LAST
do
5290 if FReloading
[b
] > 0 then
5296 if FShellTimer
> -1 then
5297 if FShellTimer
= 0 then
5299 if FShellType
= SHELL_SHELL
then
5300 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
5301 GameVelX
, GameVelY
-2, SHELL_SHELL
)
5302 else if FShellType
= SHELL_DBLSHELL
then
5304 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
5305 GameVelX
+1, GameVelY
-2, SHELL_SHELL
);
5306 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
5307 GameVelX
-1, GameVelY
-2, SHELL_SHELL
);
5310 end else Dec(FShellTimer
);
5312 if (FBFGFireCounter
> -1) then
5313 if FBFGFireCounter
= 0 then
5317 wx
:= FObj
.X
+WEAPONPOINT
[FDirection
].X
;
5318 wy
:= FObj
.Y
+WEAPONPOINT
[FDirection
].Y
;
5319 xd
:= wx
+IfThen(FDirection
= TDirection
.D_LEFT
, -30, 30);
5320 yd
:= wy
+firediry();
5321 g_Weapon_bfgshot(wx
, wy
, xd
, yd
, FUID
);
5322 if NetServer
then MH_SEND_PlayerFire(FUID
, WEAPON_BFG
, wx
, wy
, xd
, yd
);
5323 if (FAngle
= 0) or (FAngle
= 180) then SetAction(A_ATTACK
)
5324 else if (FAngle
= ANGLE_LEFTDOWN
) or (FAngle
= ANGLE_RIGHTDOWN
) then SetAction(A_ATTACKDOWN
)
5325 else if (FAngle
= ANGLE_LEFTUP
) or (FAngle
= ANGLE_RIGHTUP
) then SetAction(A_ATTACKUP
);
5328 FReloading
[WEAPON_BFG
] := WEAPON_RELOAD
[WEAPON_BFG
];
5329 FBFGFireCounter
:= -1;
5332 FBFGFireCounter
:= 0
5334 Dec(FBFGFireCounter
);
5336 if (FMegaRulez
[MR_SUIT
] < gTime
) and AnyServer
then
5338 b
:= g_GetAcidHit(FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+PLAYER_RECT
.Y
, PLAYER_RECT
.Width
, PLAYER_RECT
.Height
);
5340 if (b
> 0) and (gTime
mod (15*GAME_TICK
) = 0) then Damage(b
, 0, 0, 0, HIT_ACID
);
5343 if (headwater
or blockmon
) then
5349 if AnyServer
then Damage(10, 0, 0, 0, HIT_WATER
);
5352 else if (FAir
mod 31 = 0) and not blockmon
then
5354 g_GFX_Bubbles(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2), FObj
.Y
+PLAYER_RECT
.Y
-4, 5+Random(6), 8, 4);
5355 if Random(2) = 0 then
5356 g_Sound_PlayExAt('SOUND_GAME_BUBBLE1', FObj
.X
, FObj
.Y
)
5358 g_Sound_PlayExAt('SOUND_GAME_BUBBLE2', FObj
.X
, FObj
.Y
);
5360 end else if FAir
< AIR_DEF
then
5363 if FFireTime
> 0 then
5365 if BodyInLiquid(0, 0) then
5370 else if FMegaRulez
[MR_SUIT
] >= gTime
then
5372 if FMegaRulez
[MR_SUIT
] = gTime
then
5379 if FFirePainTime
<= 0 then
5381 if g_Game_IsServer
then
5382 Damage(2, FFireAttacker
, 0, 0, HIT_FLAME
);
5383 FFirePainTime
:= 12 - FFireTime
div 12;
5385 FFirePainTime
:= FFirePainTime
- 1;
5386 FFireTime
:= FFireTime
- 1;
5387 if ((FFireTime
mod 33) = 0) and (FMegaRulez
[MR_INVUL
] < gTime
) then
5388 FModel
.PlaySound(MODELSOUND_PAIN
, 1, FObj
.X
, FObj
.Y
);
5389 if (FFireTime
= 0) and g_Game_IsNet
and g_Game_IsServer
then
5390 MH_SEND_PlayerStats(FUID
);
5394 if FDamageBuffer
> 0 then
5396 if FDamageBuffer
>= 9 then
5400 if FDamageBuffer
< 30 then i
:= 9
5401 else if FDamageBuffer
< 100 then i
:= 18
5405 ii
:= Round(FDamageBuffer
*FHealth
/ nonz(FArmor
*(3/4)+FHealth
));
5406 FArmor
:= FArmor
-(FDamageBuffer
-ii
);
5407 FHealth
:= FHealth
-ii
;
5410 FHealth
:= FHealth
+FArmor
;
5415 if FHealth
<= 0 then
5416 if FHealth
> -30 then Kill(K_SIMPLEKILL
, FLastSpawnerUID
, FLastHit
)
5417 else if FHealth
> -50 then Kill(K_HARDKILL
, FLastSpawnerUID
, FLastHit
)
5418 else Kill(K_EXTRAHARDKILL
, FLastSpawnerUID
, FLastHit
);
5420 if FAlive
and ((FLastHit
<> HIT_FLAME
) or (FFireTime
<= 0)) then
5422 if FDamageBuffer
<= 20 then FModel
.PlaySound(MODELSOUND_PAIN
, 1, FObj
.X
, FObj
.Y
)
5423 else if FDamageBuffer
<= 55 then FModel
.PlaySound(MODELSOUND_PAIN
, 2, FObj
.X
, FObj
.Y
)
5424 else if FDamageBuffer
<= 120 then FModel
.PlaySound(MODELSOUND_PAIN
, 3, FObj
.X
, FObj
.Y
)
5425 else FModel
.PlaySound(MODELSOUND_PAIN
, 4, FObj
.X
, FObj
.Y
);
5432 end; // if FAlive then ...
5434 if (FActionAnim
= A_PAIN
) and (FModel
.Animation
<> A_PAIN
) then
5436 FModel
.ChangeAnimation(FActionAnim
, FActionForce
);
5437 FModel
.GetCurrentAnimation
.MinLength
:= i
;
5438 FModel
.GetCurrentAnimationMask
.MinLength
:= i
;
5439 end else FModel
.ChangeAnimation(FActionAnim
, FActionForce
and (FModel
.Animation
<> A_STAND
));
5441 if (FModel
.GetCurrentAnimation
.Played
or ((not FActionChanged
) and (FModel
.Animation
= A_WALK
)))
5442 then SetAction(A_STAND
, True);
5444 if not ((FModel
.Animation
= A_WALK
) and (Abs(FObj
.Vel
.X
) < 4) and not FModel
.Fire
) then FModel
.Update
;
5446 for b
:= Low(FKeys
) to High(FKeys
) do
5447 if FKeys
[b
].Time
= 0 then FKeys
[b
].Pressed
:= False else Dec(FKeys
[b
].Time
);
5451 procedure TPlayer
.getMapBox (out x
, y
, w
, h
: Integer); inline;
5453 x
:= FObj
.X
+PLAYER_RECT
.X
;
5454 y
:= FObj
.Y
+PLAYER_RECT
.Y
;
5455 w
:= PLAYER_RECT
.Width
;
5456 h
:= PLAYER_RECT
.Height
;
5460 procedure TPlayer
.moveBy (dx
, dy
: Integer); inline;
5462 if (dx
<> 0) or (dy
<> 0) then
5471 function TPlayer
.Collide(X
, Y
: Integer; Width
, Height
: Word): Boolean;
5473 Result
:= g_Collide(FObj
.X
+PLAYER_RECT
.X
,
5474 FObj
.Y
+PLAYER_RECT
.Y
,
5481 function TPlayer
.Collide(Panel
: TPanel
): Boolean;
5483 Result
:= g_Collide(FObj
.X
+PLAYER_RECT
.X
,
5484 FObj
.Y
+PLAYER_RECT
.Y
,
5488 Panel
.Width
, Panel
.Height
);
5491 function TPlayer
.Collide(X
, Y
: Integer): Boolean;
5493 X
:= X
-FObj
.X
-PLAYER_RECT
.X
;
5494 Y
:= Y
-FObj
.Y
-PLAYER_RECT
.Y
;
5495 Result
:= (x
>= 0) and (x
<= PLAYER_RECT
.Width
) and
5496 (y
>= 0) and (y
<= PLAYER_RECT
.Height
);
5499 function g_Player_ValidName(Name
: string): Boolean;
5505 if gPlayers
= nil then Exit
;
5507 for a
:= 0 to High(gPlayers
) do
5508 if gPlayers
[a
] <> nil then
5509 if LowerCase(Name
) = LowerCase(gPlayers
[a
].FName
) then
5516 procedure TPlayer
.SetDirection(Direction
: TDirection
);
5520 d
:= FModel
.Direction
;
5522 FModel
.Direction
:= Direction
;
5523 if d
<> Direction
then FModel
.ChangeAnimation(FModel
.Animation
, True);
5525 FDirection
:= Direction
;
5528 function TPlayer
.GetKeys(): Byte;
5532 if R_KEY_RED
in FRulez
then Result
:= KEY_RED
;
5533 if R_KEY_GREEN
in FRulez
then Result
:= Result
or KEY_GREEN
;
5534 if R_KEY_BLUE
in FRulez
then Result
:= Result
or KEY_BLUE
;
5536 if FTeam
= TEAM_RED
then Result
:= Result
or KEY_REDTEAM
;
5537 if FTeam
= TEAM_BLUE
then Result
:= Result
or KEY_BLUETEAM
;
5540 procedure TPlayer
.Use();
5544 if FTime
[T_USE
] > gTime
then Exit
;
5546 g_Triggers_PressR(FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+PLAYER_RECT
.Y
, PLAYER_RECT
.Width
,
5547 PLAYER_RECT
.Height
, FUID
, ACTIVATE_PLAYERPRESS
);
5549 for a
:= 0 to High(gPlayers
) do
5550 if (gPlayers
[a
] <> nil) and (gPlayers
[a
] <> Self
) and
5551 gPlayers
[a
].alive
and SameTeam(FUID
, gPlayers
[a
].FUID
) and
5552 g_Obj_Collide(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
,
5553 FObj
.Rect
.Width
, FObj
.Rect
.Height
, @gPlayers
[a
].FObj
) then
5555 gPlayers
[a
].Touch();
5556 if g_Game_IsNet
and g_Game_IsServer
then
5557 MH_SEND_GameEvent(NET_EV_PLAYER_TOUCH
, gPlayers
[a
].FUID
);
5560 FTime
[T_USE
] := gTime
+120;
5563 procedure TPlayer
.NetFire(Wpn
: Byte; X
, Y
, AX
, AY
: Integer; WID
: Integer = -1);
5567 WX
, WY
, XD
, YD
: Integer;
5579 if R_BERSERK
in FRulez
then
5581 //g_Weapon_punch(FObj.X+FObj.Rect.X, FObj.Y+FObj.Rect.Y, 75, FUID);
5582 locobj
.X
:= FObj
.X
+FObj
.Rect
.X
;
5583 locobj
.Y
:= FObj
.Y
+FObj
.Rect
.Y
;
5586 locobj
.rect
.Width
:= 39;
5587 locobj
.rect
.Height
:= 52;
5588 locobj
.Vel
.X
:= (xd
-wx
) div 2;
5589 locobj
.Vel
.Y
:= (yd
-wy
) div 2;
5590 locobj
.Accel
.X
:= xd
-wx
;
5591 locobj
.Accel
.y
:= yd
-wy
;
5593 if g_Weapon_Hit(@locobj
, 50, FUID
, HIT_SOME
) <> 0 then
5594 g_Sound_PlayExAt('SOUND_WEAPON_HITBERSERK', FObj
.X
, FObj
.Y
)
5596 g_Sound_PlayExAt('SOUND_WEAPON_MISSBERSERK', FObj
.X
, FObj
.Y
);
5600 FPain
:= min(FPain
+ 25, 50);
5602 g_Weapon_punch(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
, 3, FUID
);
5607 if g_Weapon_chainsaw(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
,
5608 IfThen(gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
], 9, 3), FUID
) <> 0 then
5610 FSawSoundSelect
.Stop();
5612 FSawSoundHit
.PlayAt(FObj
.X
, FObj
.Y
);
5614 else if not FSawSoundHit
.IsPlaying() then
5616 FSawSoundSelect
.Stop();
5617 FSawSound
.PlayAt(FObj
.X
, FObj
.Y
);
5624 g_Sound_PlayExAt('SOUND_WEAPON_FIREPISTOL', GameX
, Gamey
);
5625 FFireAngle
:= FAngle
;
5627 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
5628 GameVelX
, GameVelY
-2, SHELL_BULLET
);
5633 g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN', Gamex
, Gamey
);
5634 FFireAngle
:= FAngle
;
5637 FShellType
:= SHELL_SHELL
;
5642 g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN2', Gamex
, Gamey
);
5643 FFireAngle
:= FAngle
;
5646 FShellType
:= SHELL_DBLSHELL
;
5651 g_Sound_PlayExAt('SOUND_WEAPON_FIRECGUN', Gamex
, Gamey
);
5652 FFireAngle
:= FAngle
;
5654 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
5655 GameVelX
, GameVelY
-2, SHELL_BULLET
);
5658 WEAPON_ROCKETLAUNCHER
:
5660 g_Weapon_Rocket(wx
, wy
, xd
, yd
, FUID
, WID
);
5661 FFireAngle
:= FAngle
;
5667 g_Weapon_Plasma(wx
, wy
, xd
, yd
, FUID
, WID
);
5668 FFireAngle
:= FAngle
;
5674 g_Weapon_BFGShot(wx
, wy
, xd
, yd
, FUID
, WID
);
5675 FFireAngle
:= FAngle
;
5679 WEAPON_SUPERPULEMET
:
5681 g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN', Gamex
, Gamey
);
5682 FFireAngle
:= FAngle
;
5684 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
5685 GameVelX
, GameVelY
-2, SHELL_SHELL
);
5688 WEAPON_FLAMETHROWER
:
5690 g_Weapon_flame(wx
, wy
, xd
, yd
, FUID
, WID
);
5692 FFireAngle
:= FAngle
;
5699 if (FAngle
= 0) or (FAngle
= 180) then SetAction(A_ATTACK
)
5700 else if (FAngle
= ANGLE_LEFTDOWN
) or (FAngle
= ANGLE_RIGHTDOWN
) then SetAction(A_ATTACKDOWN
)
5701 else if (FAngle
= ANGLE_LEFTUP
) or (FAngle
= ANGLE_RIGHTUP
) then SetAction(A_ATTACKUP
);
5704 procedure TPlayer
.DoLerp(Level
: Integer = 2);
5706 if FObj
.X
<> FXTo
then FObj
.X
:= Lerp(FObj
.X
, FXTo
, Level
);
5707 if FObj
.Y
<> FYTo
then FObj
.Y
:= Lerp(FObj
.Y
, FYTo
, Level
);
5710 procedure TPlayer
.SetLerp(XTo
, YTo
: Integer);
5716 if FJustTeleported
or (NetInterpLevel
< 1) then
5720 if FJustTeleported
then
5722 FObj
.oldX
:= FObj
.X
;
5723 FObj
.oldY
:= FObj
.Y
;
5728 AX
:= Abs(FXTo
- FObj
.X
);
5729 AY
:= Abs(FYTo
- FObj
.Y
);
5730 if (AX
> 32) or (AX
<= NetInterpLevel
) then
5732 if (AY
> 32) or (AY
<= NetInterpLevel
) then
5737 function TPlayer
.FullInLift(XInc
, YInc
: Integer): Integer;
5739 if g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
,
5740 PLAYER_RECT
.Width
, PLAYER_RECT
.Height
-8,
5741 PANEL_LIFTUP
, False) then Result
:= -1
5743 if g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
,
5744 PLAYER_RECT
.Width
, PLAYER_RECT
.Height
-8,
5745 PANEL_LIFTDOWN
, False) then Result
:= 1
5749 function TPlayer
.GetFlag(Flag
: Byte): Boolean;
5756 if Flag
= FLAG_NONE
then
5759 if not g_Game_IsServer
then Exit
;
5761 // Ïðèíåñ ÷óæîé ôëàã íà ñâîþ áàçó:
5762 if (Flag
= FTeam
) and
5763 (gFlags
[Flag
].State
= FLAG_STATE_NORMAL
) and
5764 (FFlag
<> FLAG_NONE
) then
5766 if FFlag
= FLAG_RED
then
5767 s
:= _lc
[I_PLAYER_FLAG_RED
]
5769 s
:= _lc
[I_PLAYER_FLAG_BLUE
];
5771 evtype
:= FLAG_STATE_SCORED
;
5773 ts
:= Format('%.4d', [gFlags
[FFlag
].CaptureTime
]);
5774 Insert('.', ts
, Length(ts
) + 1 - 3);
5775 g_Console_Add(Format(_lc
[I_PLAYER_FLAG_CAPTURE
], [FName
, s
, ts
]), True);
5777 g_Map_ResetFlag(FFlag
);
5778 g_Game_Message(Format(_lc
[I_MESSAGE_FLAG_CAPTURE
], [AnsiUpperCase(s
)]), 144);
5780 if ((Self
= gPlayer1
) or (Self
= gPlayer2
)
5781 or ((gPlayer1
<> nil) and (gPlayer1
.Team
= FTeam
))
5782 or ((gPlayer2
<> nil) and (gPlayer2
.Team
= FTeam
))) then
5787 if not sound_cap_flag
[a
].IsPlaying() then
5788 sound_cap_flag
[a
].Play();
5790 gTeamStat
[FTeam
].Goals
:= gTeamStat
[FTeam
].Goals
+ 1;
5793 if g_Game_IsNet
then
5795 MH_SEND_FlagEvent(evtype
, FFlag
, FUID
, False);
5799 gFlags
[FFlag
].CaptureTime
:= 0;
5804 // Ïîäîáðàë ñâîé ôëàã - âåðíóë åãî íà áàçó:
5805 if (Flag
= FTeam
) and
5806 (gFlags
[Flag
].State
= FLAG_STATE_DROPPED
) then
5808 if Flag
= FLAG_RED
then
5809 s
:= _lc
[I_PLAYER_FLAG_RED
]
5811 s
:= _lc
[I_PLAYER_FLAG_BLUE
];
5813 evtype
:= FLAG_STATE_RETURNED
;
5814 gFlags
[Flag
].CaptureTime
:= 0;
5816 g_Console_Add(Format(_lc
[I_PLAYER_FLAG_RETURN
], [FName
, s
]), True);
5818 g_Map_ResetFlag(Flag
);
5819 g_Game_Message(Format(_lc
[I_MESSAGE_FLAG_RETURN
], [AnsiUpperCase(s
)]), 144);
5821 if ((Self
= gPlayer1
) or (Self
= gPlayer2
)
5822 or ((gPlayer1
<> nil) and (gPlayer1
.Team
= FTeam
))
5823 or ((gPlayer2
<> nil) and (gPlayer2
.Team
= FTeam
))) then
5828 if not sound_ret_flag
[a
].IsPlaying() then
5829 sound_ret_flag
[a
].Play();
5832 if g_Game_IsNet
then
5834 MH_SEND_FlagEvent(evtype
, Flag
, FUID
, False);
5840 // Ïîäîáðàë ÷óæîé ôëàã:
5841 if (Flag
<> FTeam
) and (FTime
[T_FLAGCAP
] <= gTime
) then
5845 if Flag
= FLAG_RED
then
5846 s
:= _lc
[I_PLAYER_FLAG_RED
]
5848 s
:= _lc
[I_PLAYER_FLAG_BLUE
];
5850 evtype
:= FLAG_STATE_CAPTURED
;
5852 g_Console_Add(Format(_lc
[I_PLAYER_FLAG_GET
], [FName
, s
]), True);
5854 g_Game_Message(Format(_lc
[I_MESSAGE_FLAG_GET
], [AnsiUpperCase(s
)]), 144);
5856 gFlags
[Flag
].State
:= FLAG_STATE_CAPTURED
;
5858 if ((Self
= gPlayer1
) or (Self
= gPlayer2
)
5859 or ((gPlayer1
<> nil) and (gPlayer1
.Team
= FTeam
))
5860 or ((gPlayer2
<> nil) and (gPlayer2
.Team
= FTeam
))) then
5865 if not sound_get_flag
[a
].IsPlaying() then
5866 sound_get_flag
[a
].Play();
5869 if g_Game_IsNet
then
5871 MH_SEND_FlagEvent(evtype
, Flag
, FUID
, False);
5877 procedure TPlayer
.SetFlag(Flag
: Byte);
5880 if FModel
<> nil then
5881 FModel
.SetFlag(FFlag
);
5884 function TPlayer
.TryDropFlag(): Boolean;
5886 if LongBool(gGameSettings
.Options
and GAME_OPTION_ALLOWDROPFLAG
) then
5887 Result
:= DropFlag(False, LongBool(gGameSettings
.Options
and GAME_OPTION_THROWFLAG
))
5892 function TPlayer
.DropFlag(Silent
: Boolean = True; DoThrow
: Boolean = False): Boolean;
5899 if (not g_Game_IsServer
) or (FFlag
= FLAG_NONE
) then
5901 FTime
[T_FLAGCAP
] := gTime
+ 2000;
5902 with gFlags
[FFlag
] do
5906 Direction
:= FDirection
;
5907 State
:= FLAG_STATE_DROPPED
;
5911 xv
:= FObj
.Vel
.X
+ IfThen(Direction
= TDirection
.D_RIGHT
, 10, -10);
5912 yv
:= FObj
.Vel
.Y
- 2;
5916 xv
:= (FObj
.Vel
.X
div 2);
5917 yv
:= (FObj
.Vel
.Y
div 2) - 2;
5919 g_Obj_Push(@Obj
, xv
, yv
);
5921 positionChanged(); // this updates spatial accelerators
5923 if FFlag
= FLAG_RED
then
5924 s
:= _lc
[I_PLAYER_FLAG_RED
]
5926 s
:= _lc
[I_PLAYER_FLAG_BLUE
];
5928 g_Console_Add(Format(_lc
[I_PLAYER_FLAG_DROP
], [FName
, s
]), True);
5929 g_Game_Message(Format(_lc
[I_MESSAGE_FLAG_DROP
], [AnsiUpperCase(s
)]), 144);
5931 if ((Self
= gPlayer1
) or (Self
= gPlayer2
)
5932 or ((gPlayer1
<> nil) and (gPlayer1
.Team
= FTeam
))
5933 or ((gPlayer2
<> nil) and (gPlayer2
.Team
= FTeam
))) then
5938 if (not Silent
) and (not sound_lost_flag
[a
].IsPlaying()) then
5939 sound_lost_flag
[a
].Play();
5941 if g_Game_IsNet
then
5942 MH_SEND_FlagEvent(FLAG_STATE_DROPPED
, Flag
, FUID
, False);
5948 procedure TPlayer
.GetSecret();
5950 if (self
= gPlayer1
) or (self
= gPlayer2
) then
5952 g_Console_Add(Format(_lc
[I_PLAYER_SECRET
], [FName
]), True);
5953 g_Sound_PlayEx('SOUND_GAME_SECRET');
5958 procedure TPlayer
.PressKey(Key
: Byte; Time
: Word = 1);
5960 Assert(Key
<= High(FKeys
));
5962 FKeys
[Key
].Pressed
:= True;
5963 FKeys
[Key
].Time
:= Time
;
5966 function TPlayer
.IsKeyPressed(K
: Byte): Boolean;
5968 Result
:= FKeys
[K
].Pressed
;
5971 procedure TPlayer
.ReleaseKeys();
5975 for a
:= Low(FKeys
) to High(FKeys
) do
5977 FKeys
[a
].Pressed
:= False;
5982 procedure TPlayer
.OnDamage(Angle
: SmallInt);
5986 function TPlayer
.firediry(): Integer;
5988 if FKeys
[KEY_UP
].Pressed
then Result
:= -42
5989 else if FKeys
[KEY_DOWN
].Pressed
then Result
:= 19
5993 procedure TPlayer
.RememberState();
5996 SavedState
: TPlayerSavedState
;
5998 SavedState
.Health
:= FHealth
;
5999 SavedState
.Armor
:= FArmor
;
6000 SavedState
.Air
:= FAir
;
6001 SavedState
.JetFuel
:= FJetFuel
;
6002 SavedState
.CurrWeap
:= FCurrWeap
;
6003 SavedState
.NextWeap
:= FNextWeap
;
6004 SavedState
.NextWeapDelay
:= FNextWeapDelay
;
6005 for i
:= Low(FWeapon
) to High(FWeapon
) do
6006 SavedState
.Weapon
[i
] := FWeapon
[i
];
6007 for i
:= Low(FAmmo
) to High(FAmmo
) do
6008 SavedState
.Ammo
[i
] := FAmmo
[i
];
6009 for i
:= Low(FMaxAmmo
) to High(FMaxAmmo
) do
6010 SavedState
.MaxAmmo
[i
] := FMaxAmmo
[i
];
6011 SavedState
.Rulez
:= FRulez
- [R_KEY_RED
, R_KEY_GREEN
, R_KEY_BLUE
];
6013 FSavedStateNum
:= -1;
6014 for i
:= Low(SavedStates
) to High(SavedStates
) do
6015 if not SavedStates
[i
].Used
then
6017 FSavedStateNum
:= i
;
6020 if FSavedStateNum
< 0 then
6022 SetLength(SavedStates
, Length(SavedStates
) + 1);
6023 FSavedStateNum
:= High(SavedStates
);
6026 SavedState
.Used
:= True;
6027 SavedStates
[FSavedStateNum
] := SavedState
;
6030 procedure TPlayer
.RecallState();
6033 SavedState
: TPlayerSavedState
;
6035 if(FSavedStateNum
< 0) or (FSavedStateNum
> High(SavedStates
)) then
6038 SavedState
:= SavedStates
[FSavedStateNum
];
6039 SavedStates
[FSavedStateNum
].Used
:= False;
6040 FSavedStateNum
:= -1;
6042 FHealth
:= SavedState
.Health
;
6043 FArmor
:= SavedState
.Armor
;
6044 FAir
:= SavedState
.Air
;
6045 FJetFuel
:= SavedState
.JetFuel
;
6046 FCurrWeap
:= SavedState
.CurrWeap
;
6047 FNextWeap
:= SavedState
.NextWeap
;
6048 FNextWeapDelay
:= SavedState
.NextWeapDelay
;
6049 for i
:= Low(FWeapon
) to High(FWeapon
) do
6050 FWeapon
[i
] := SavedState
.Weapon
[i
];
6051 for i
:= Low(FAmmo
) to High(FAmmo
) do
6052 FAmmo
[i
] := SavedState
.Ammo
[i
];
6053 for i
:= Low(FMaxAmmo
) to High(FMaxAmmo
) do
6054 FMaxAmmo
[i
] := SavedState
.MaxAmmo
[i
];
6055 FRulez
:= SavedState
.Rulez
;
6057 if gGameSettings
.GameType
= GT_SERVER
then
6058 MH_SEND_PlayerStats(FUID
);
6061 procedure TPlayer
.SaveState (st
: TStream
);
6067 utils
.writeSign(st
, 'PLYR');
6068 utils
.writeInt(st
, Byte(PLR_SAVE_VERSION
)); // version
6070 utils
.writeBool(st
, FIamBot
);
6072 utils
.writeInt(st
, Word(FUID
));
6074 utils
.writeStr(st
, FName
);
6076 utils
.writeInt(st
, Byte(FTeam
));
6078 utils
.writeBool(st
, FAlive
);
6079 // Èçðàñõîäîâàë ëè âñå æèçíè
6080 utils
.writeBool(st
, FNoRespawn
);
6082 if FDirection
= TDirection
.D_LEFT
then b
:= 1 else b
:= 2; // D_RIGHT
6083 utils
.writeInt(st
, Byte(b
));
6085 utils
.writeInt(st
, LongInt(FHealth
));
6086 // Êîýôôèöèåíò èíâàëèäíîñòè
6087 utils
.writeInt(st
, LongInt(FHandicap
));
6089 utils
.writeInt(st
, Byte(FLives
));
6091 utils
.writeInt(st
, LongInt(FArmor
));
6093 utils
.writeInt(st
, LongInt(FAir
));
6095 utils
.writeInt(st
, LongInt(FJetFuel
));
6097 utils
.writeInt(st
, LongInt(FPain
));
6099 utils
.writeInt(st
, LongInt(FKills
));
6101 utils
.writeInt(st
, LongInt(FMonsterKills
));
6103 utils
.writeInt(st
, LongInt(FFrags
));
6105 utils
.writeInt(st
, Byte(FFragCombo
));
6106 // Âðåìÿ ïîñëåäíåãî ôðàãà
6107 utils
.writeInt(st
, LongWord(FLastFrag
));
6109 utils
.writeInt(st
, LongInt(FDeath
));
6111 utils
.writeInt(st
, Byte(FFlag
));
6113 utils
.writeInt(st
, LongInt(FSecrets
));
6115 utils
.writeInt(st
, Byte(FCurrWeap
));
6117 utils
.writeInt(st
, Word(FNextWeap
));
6119 utils
.writeInt(st
, Byte(FNextWeapDelay
));
6120 // Âðåìÿ çàðÿäêè BFG
6121 utils
.writeInt(st
, SmallInt(FBFGFireCounter
));
6123 utils
.writeInt(st
, LongInt(FDamageBuffer
));
6124 // Ïîñëåäíèé óäàðèâøèé
6125 utils
.writeInt(st
, Word(FLastSpawnerUID
));
6126 // Òèï ïîñëåäíåãî ïîëó÷åííîãî óðîíà
6127 utils
.writeInt(st
, Byte(FLastHit
));
6129 Obj_SaveState(st
, @FObj
);
6130 // Òåêóùåå êîëè÷åñòâî ïàòðîíîâ
6131 for i
:= A_BULLETS
to A_HIGH
do utils
.writeInt(st
, Word(FAmmo
[i
]));
6132 // Ìàêñèìàëüíîå êîëè÷åñòâî ïàòðîíîâ
6133 for i
:= A_BULLETS
to A_HIGH
do utils
.writeInt(st
, Word(FMaxAmmo
[i
]));
6135 for i
:= WP_FIRST
to WP_LAST
do utils
.writeBool(st
, FWeapon
[i
]);
6136 // Âðåìÿ ïåðåçàðÿäêè îðóæèÿ
6137 for i
:= WP_FIRST
to WP_LAST
do utils
.writeInt(st
, Word(FReloading
[i
]));
6139 utils
.writeBool(st
, (R_ITEM_BACKPACK
in FRulez
));
6140 // Íàëè÷èå êðàñíîãî êëþ÷à
6141 utils
.writeBool(st
, (R_KEY_RED
in FRulez
));
6142 // Íàëè÷èå çåëåíîãî êëþ÷à
6143 utils
.writeBool(st
, (R_KEY_GREEN
in FRulez
));
6144 // Íàëè÷èå ñèíåãî êëþ÷à
6145 utils
.writeBool(st
, (R_KEY_BLUE
in FRulez
));
6147 utils
.writeBool(st
, (R_BERSERK
in FRulez
));
6148 // Âðåìÿ äåéñòâèÿ ñïåöèàëüíûõ ïðåäìåòîâ
6149 for i
:= MR_SUIT
to MR_MAX
do utils
.writeInt(st
, LongWord(FMegaRulez
[i
]));
6150 // Âðåìÿ äî ïîâòîðíîãî ðåñïàóíà, ñìåíû îðóæèÿ, èñîëüçîâàíèÿ, çàõâàòà ôëàãà
6151 for i
:= T_RESPAWN
to T_FLAGCAP
do utils
.writeInt(st
, LongWord(FTime
[i
]));
6153 utils
.writeStr(st
, FModel
.Name
);
6155 utils
.writeInt(st
, Byte(FColor
.R
));
6156 utils
.writeInt(st
, Byte(FColor
.G
));
6157 utils
.writeInt(st
, Byte(FColor
.B
));
6161 procedure TPlayer
.LoadState (st
: TStream
);
6170 if not utils
.checkSign(st
, 'PLYR') then raise XStreamError
.Create('invalid player signature');
6171 if (utils
.readByte(st
) <> PLR_SAVE_VERSION
) then raise XStreamError
.Create('invalid player version');
6173 FIamBot
:= utils
.readBool(st
);
6175 FUID
:= utils
.readWord(st
);
6177 str
:= utils
.readStr(st
);
6178 if (self
<> gPlayer1
) and (self
<> gPlayer2
) then FName
:= str
;
6180 FTeam
:= utils
.readByte(st
);
6182 FAlive
:= utils
.readBool(st
);
6183 // Èçðàñõîäîâàë ëè âñå æèçíè
6184 FNoRespawn
:= utils
.readBool(st
);
6186 b
:= utils
.readByte(st
);
6187 if b
= 1 then FDirection
:= TDirection
.D_LEFT
else FDirection
:= TDirection
.D_RIGHT
; // b = 2
6189 FHealth
:= utils
.readLongInt(st
);
6190 // Êîýôôèöèåíò èíâàëèäíîñòè
6191 FHandicap
:= utils
.readLongInt(st
);
6193 FLives
:= utils
.readByte(st
);
6195 FArmor
:= utils
.readLongInt(st
);
6197 FAir
:= utils
.readLongInt(st
);
6199 FJetFuel
:= utils
.readLongInt(st
);
6201 FPain
:= utils
.readLongInt(st
);
6203 FKills
:= utils
.readLongInt(st
);
6205 FMonsterKills
:= utils
.readLongInt(st
);
6207 FFrags
:= utils
.readLongInt(st
);
6209 FFragCombo
:= utils
.readByte(st
);
6210 // Âðåìÿ ïîñëåäíåãî ôðàãà
6211 FLastFrag
:= utils
.readLongWord(st
);
6213 FDeath
:= utils
.readLongInt(st
);
6215 FFlag
:= utils
.readByte(st
);
6217 FSecrets
:= utils
.readLongInt(st
);
6219 FCurrWeap
:= utils
.readByte(st
);
6221 FNextWeap
:= utils
.readWord(st
);
6223 FNextWeapDelay
:= utils
.readByte(st
);
6224 // Âðåìÿ çàðÿäêè BFG
6225 FBFGFireCounter
:= utils
.readSmallInt(st
);
6227 FDamageBuffer
:= utils
.readLongInt(st
);
6228 // Ïîñëåäíèé óäàðèâøèé
6229 FLastSpawnerUID
:= utils
.readWord(st
);
6230 // Òèï ïîñëåäíåãî ïîëó÷åííîãî óðîíà
6231 FLastHit
:= utils
.readByte(st
);
6233 Obj_LoadState(@FObj
, st
);
6234 // Òåêóùåå êîëè÷åñòâî ïàòðîíîâ
6235 for i
:= A_BULLETS
to A_HIGH
do FAmmo
[i
] := utils
.readWord(st
);
6236 // Ìàêñèìàëüíîå êîëè÷åñòâî ïàòðîíîâ
6237 for i
:= A_BULLETS
to A_HIGH
do FMaxAmmo
[i
] := utils
.readWord(st
);
6239 for i
:= WP_FIRST
to WP_LAST
do FWeapon
[i
] := utils
.readBool(st
);
6240 // Âðåìÿ ïåðåçàðÿäêè îðóæèÿ
6241 for i
:= WP_FIRST
to WP_LAST
do FReloading
[i
] := utils
.readWord(st
);
6243 if utils
.readBool(st
) then Include(FRulez
, R_ITEM_BACKPACK
);
6244 // Íàëè÷èå êðàñíîãî êëþ÷à
6245 if utils
.readBool(st
) then Include(FRulez
, R_KEY_RED
);
6246 // Íàëè÷èå çåëåíîãî êëþ÷à
6247 if utils
.readBool(st
) then Include(FRulez
, R_KEY_GREEN
);
6248 // Íàëè÷èå ñèíåãî êëþ÷à
6249 if utils
.readBool(st
) then Include(FRulez
, R_KEY_BLUE
);
6251 if utils
.readBool(st
) then Include(FRulez
, R_BERSERK
);
6252 // Âðåìÿ äåéñòâèÿ ñïåöèàëüíûõ ïðåäìåòîâ
6253 for i
:= MR_SUIT
to MR_MAX
do FMegaRulez
[i
] := utils
.readLongWord(st
);
6254 // Âðåìÿ äî ïîâòîðíîãî ðåñïàóíà, ñìåíû îðóæèÿ, èñîëüçîâàíèÿ, çàõâàòà ôëàãà
6255 for i
:= T_RESPAWN
to T_FLAGCAP
do FTime
[i
] := utils
.readLongWord(st
);
6257 str
:= utils
.readStr(st
);
6259 FColor
.R
:= utils
.readByte(st
);
6260 FColor
.G
:= utils
.readByte(st
);
6261 FColor
.B
:= utils
.readByte(st
);
6262 if (self
= gPlayer1
) then
6264 str
:= gPlayer1Settings
.Model
;
6265 FColor
:= gPlayer1Settings
.Color
;
6267 else if (self
= gPlayer2
) then
6269 str
:= gPlayer2Settings
.Model
;
6270 FColor
:= gPlayer2Settings
.Color
;
6272 // Îáíîâëÿåì ìîäåëü èãðîêà
6274 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
6275 FModel
.Color
:= TEAMCOLOR
[FTeam
]
6277 FModel
.Color
:= FColor
;
6281 procedure TPlayer
.AllRulez(Health
: Boolean);
6287 FHealth
:= PLAYER_HP_LIMIT
;
6288 FArmor
:= PLAYER_AP_LIMIT
;
6292 for a
:= WP_FIRST
to WP_LAST
do FWeapon
[a
] := True;
6293 for a
:= A_BULLETS
to A_HIGH
do FAmmo
[a
] := 30000;
6294 FRulez
:= FRulez
+[R_KEY_RED
, R_KEY_GREEN
, R_KEY_BLUE
];
6297 procedure TPlayer
.RestoreHealthArmor();
6299 FHealth
:= PLAYER_HP_LIMIT
;
6300 FArmor
:= PLAYER_AP_LIMIT
;
6303 procedure TPlayer
.FragCombo();
6307 if (gGameSettings
.GameMode
in [GM_COOP
, GM_SINGLE
]) or g_Game_IsClient
then
6309 if gTime
- FLastFrag
< FRAG_COMBO_TIME
then
6311 if FFragCombo
< 5 then
6313 Param
:= FUID
or (FFragCombo
shl 16);
6314 if (FComboEvnt
>= Low(gDelayedEvents
)) and
6315 (FComboEvnt
<= High(gDelayedEvents
)) and
6316 gDelayedEvents
[FComboEvnt
].Pending
and
6317 (gDelayedEvents
[FComboEvnt
].DEType
= DE_KILLCOMBO
) and
6318 (gDelayedEvents
[FComboEvnt
].DENum
and $FFFF = FUID
) then
6320 gDelayedEvents
[FComboEvnt
].Time
:= gTime
+ 500;
6321 gDelayedEvents
[FComboEvnt
].DENum
:= Param
;
6324 FComboEvnt
:= g_Game_DelayEvent(DE_KILLCOMBO
, 500, Param
);
6332 procedure TPlayer
.GiveItem(ItemType
: Byte);
6336 if FMegaRulez
[MR_SUIT
] < gTime
+PLAYER_SUIT_TIME
then
6338 FMegaRulez
[MR_SUIT
] := gTime
+PLAYER_SUIT_TIME
;
6342 if FAir
< AIR_MAX
then
6349 if not (R_BERSERK
in FRulez
) then
6351 Include(FRulez
, R_BERSERK
);
6352 if FBFGFireCounter
< 1 then
6354 FCurrWeap
:= WEAPON_KASTET
;
6356 FModel
.SetWeapon(WEAPON_KASTET
);
6360 FBerserk
:= gTime
+30000;
6362 if FHealth
< PLAYER_HP_SOFT
then
6364 FHealth
:= PLAYER_HP_SOFT
;
6365 FBerserk
:= gTime
+30000;
6370 if FMegaRulez
[MR_INVUL
] < gTime
+PLAYER_INVUL_TIME
then
6372 FMegaRulez
[MR_INVUL
] := gTime
+PLAYER_INVUL_TIME
;
6377 if FMegaRulez
[MR_INVIS
] < gTime
+PLAYER_INVIS_TIME
then
6379 FMegaRulez
[MR_INVIS
] := gTime
+PLAYER_INVIS_TIME
;
6383 if FJetFuel
< JET_MAX
then
6385 FJetFuel
:= JET_MAX
;
6388 ITEM_MEDKIT_SMALL
: if FHealth
< PLAYER_HP_SOFT
then IncMax(FHealth
, 10, PLAYER_HP_SOFT
);
6389 ITEM_MEDKIT_LARGE
: if FHealth
< PLAYER_HP_SOFT
then IncMax(FHealth
, 25, PLAYER_HP_SOFT
);
6391 ITEM_ARMOR_GREEN
: if FArmor
< PLAYER_AP_SOFT
then FArmor
:= PLAYER_AP_SOFT
;
6392 ITEM_ARMOR_BLUE
: if FArmor
< PLAYER_AP_LIMIT
then FArmor
:= PLAYER_AP_LIMIT
;
6394 ITEM_SPHERE_BLUE
: if FHealth
< PLAYER_HP_LIMIT
then IncMax(FHealth
, 100, PLAYER_HP_LIMIT
);
6396 if (FHealth
< PLAYER_HP_LIMIT
) or (FArmor
< PLAYER_AP_LIMIT
) then
6398 if FHealth
< PLAYER_HP_LIMIT
then FHealth
:= PLAYER_HP_LIMIT
;
6399 if FArmor
< PLAYER_AP_LIMIT
then FArmor
:= PLAYER_AP_LIMIT
;
6402 ITEM_WEAPON_SAW
: FWeapon
[WEAPON_SAW
] := True;
6403 ITEM_WEAPON_SHOTGUN1
: FWeapon
[WEAPON_SHOTGUN1
] := True;
6404 ITEM_WEAPON_SHOTGUN2
: FWeapon
[WEAPON_SHOTGUN2
] := True;
6405 ITEM_WEAPON_CHAINGUN
: FWeapon
[WEAPON_CHAINGUN
] := True;
6406 ITEM_WEAPON_ROCKETLAUNCHER
: FWeapon
[WEAPON_ROCKETLAUNCHER
] := True;
6407 ITEM_WEAPON_PLASMA
: FWeapon
[WEAPON_PLASMA
] := True;
6408 ITEM_WEAPON_BFG
: FWeapon
[WEAPON_BFG
] := True;
6409 ITEM_WEAPON_SUPERPULEMET
: FWeapon
[WEAPON_SUPERPULEMET
] := True;
6410 ITEM_WEAPON_FLAMETHROWER
: FWeapon
[WEAPON_FLAMETHROWER
] := True;
6412 ITEM_AMMO_BULLETS
: if FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
] then IncMax(FAmmo
[A_BULLETS
], 10, FMaxAmmo
[A_BULLETS
]);
6413 ITEM_AMMO_BULLETS_BOX
: if FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
] then IncMax(FAmmo
[A_BULLETS
], 50, FMaxAmmo
[A_BULLETS
]);
6414 ITEM_AMMO_SHELLS
: if FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
] then IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
6415 ITEM_AMMO_SHELLS_BOX
: if FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
] then IncMax(FAmmo
[A_SHELLS
], 25, FMaxAmmo
[A_SHELLS
]);
6416 ITEM_AMMO_ROCKET
: if FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
] then IncMax(FAmmo
[A_ROCKETS
], 1, FMaxAmmo
[A_ROCKETS
]);
6417 ITEM_AMMO_ROCKET_BOX
: if FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
] then IncMax(FAmmo
[A_ROCKETS
], 5, FMaxAmmo
[A_ROCKETS
]);
6418 ITEM_AMMO_CELL
: if FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
] then IncMax(FAmmo
[A_CELLS
], 40, FMaxAmmo
[A_CELLS
]);
6419 ITEM_AMMO_CELL_BIG
: if FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
] then IncMax(FAmmo
[A_CELLS
], 100, FMaxAmmo
[A_CELLS
]);
6420 ITEM_AMMO_FUELCAN
: if FAmmo
[A_FUEL
] < FMaxAmmo
[A_FUEL
] then IncMax(FAmmo
[A_FUEL
], 100, FMaxAmmo
[A_FUEL
]);
6423 if (FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
]) or
6424 (FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
]) or
6425 (FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
]) or
6426 (FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
]) or
6427 (FMaxAmmo
[A_FUEL
] < AmmoLimits
[1, A_FUEL
]) then
6429 FMaxAmmo
[A_BULLETS
] := AmmoLimits
[1, A_BULLETS
];
6430 FMaxAmmo
[A_SHELLS
] := AmmoLimits
[1, A_SHELLS
];
6431 FMaxAmmo
[A_ROCKETS
] := AmmoLimits
[1, A_ROCKETS
];
6432 FMaxAmmo
[A_CELLS
] := AmmoLimits
[1, A_CELLS
];
6433 FMaxAmmo
[A_FUEL
] := AmmoLimits
[1, A_FUEL
];
6435 if FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
] then IncMax(FAmmo
[A_BULLETS
], 10, FMaxAmmo
[A_BULLETS
]);
6436 if FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
] then IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
6437 if FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
] then IncMax(FAmmo
[A_ROCKETS
], 1, FMaxAmmo
[A_ROCKETS
]);
6438 if FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
] then IncMax(FAmmo
[A_CELLS
], 40, FMaxAmmo
[A_CELLS
]);
6440 FRulez
:= FRulez
+ [R_ITEM_BACKPACK
];
6443 ITEM_KEY_RED
: if not (R_KEY_RED
in FRulez
) then Include(FRulez
, R_KEY_RED
);
6444 ITEM_KEY_GREEN
: if not (R_KEY_GREEN
in FRulez
) then Include(FRulez
, R_KEY_GREEN
);
6445 ITEM_KEY_BLUE
: if not (R_KEY_BLUE
in FRulez
) then Include(FRulez
, R_KEY_BLUE
);
6447 ITEM_BOTTLE
: if FHealth
< PLAYER_HP_LIMIT
then IncMax(FHealth
, 4, PLAYER_HP_LIMIT
);
6448 ITEM_HELMET
: if FArmor
< PLAYER_AP_LIMIT
then IncMax(FArmor
, 5, PLAYER_AP_LIMIT
);
6453 if g_Game_IsNet
and g_Game_IsServer
then
6454 MH_SEND_PlayerStats(FUID
);
6457 procedure TPlayer
.FlySmoke(Times
: DWORD
= 1);
6462 if (Random(5) = 1) and (Times
= 1) then
6465 if BodyInLiquid(0, 0) then
6467 g_GFX_Bubbles(Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2)+Random(3)-1,
6468 Obj
.Y
+Obj
.Rect
.Height
+8, 1, 8, 4);
6469 if Random(2) = 0 then
6470 g_Sound_PlayExAt('SOUND_GAME_BUBBLE1', FObj
.X
, FObj
.Y
)
6472 g_Sound_PlayExAt('SOUND_GAME_BUBBLE2', FObj
.X
, FObj
.Y
);
6476 if g_Frames_Get(id
, 'FRAMES_SMOKE') then
6478 for i
:= 1 to Times
do
6480 Anim
:= TAnimation
.Create(id
, False, 3);
6482 g_GFX_OnceAnim(Obj
.X
+Obj
.Rect
.X
+Random(Obj
.Rect
.Width
+Times
*2)-(Anim
.Width
div 2),
6483 Obj
.Y
+Obj
.Rect
.Height
-4+Random(8+Times
*2), Anim
, ONCEANIM_SMOKE
);
6489 procedure TPlayer
.OnFireFlame(Times
: DWORD
= 1);
6494 if (Random(10) = 1) and (Times
= 1) then
6497 if g_Frames_Get(id
, 'FRAMES_FLAME') then
6499 for i
:= 1 to Times
do
6501 Anim
:= TAnimation
.Create(id
, False, 3);
6503 g_GFX_OnceAnim(Obj
.X
+Obj
.Rect
.X
+Random(Obj
.Rect
.Width
+Times
*2)-(Anim
.Width
div 2),
6504 Obj
.Y
+8+Random(8+Times
*2), Anim
, ONCEANIM_SMOKE
);
6510 procedure TPlayer
.PauseSounds(Enable
: Boolean);
6512 FSawSound
.Pause(Enable
);
6513 FSawSoundIdle
.Pause(Enable
);
6514 FSawSoundHit
.Pause(Enable
);
6515 FSawSoundSelect
.Pause(Enable
);
6516 FFlameSoundOn
.Pause(Enable
);
6517 FFlameSoundOff
.Pause(Enable
);
6518 FFlameSoundWork
.Pause(Enable
);
6519 FJetSoundFly
.Pause(Enable
);
6520 FJetSoundOn
.Pause(Enable
);
6521 FJetSoundOff
.Pause(Enable
);
6526 constructor TCorpse
.Create(X
, Y
: Integer; ModelName
: String; aMess
: Boolean);
6531 FObj
.Rect
:= PLAYER_CORPSERECT
;
6532 FModelName
:= ModelName
;
6537 FState
:= CORPSE_STATE_MESS
;
6538 g_PlayerModel_GetAnim(ModelName
, A_DIE2
, FAnimation
, FAnimationMask
);
6542 FState
:= CORPSE_STATE_NORMAL
;
6543 g_PlayerModel_GetAnim(ModelName
, A_DIE1
, FAnimation
, FAnimationMask
);
6547 destructor TCorpse
.Destroy();
6554 function TCorpse
.ObjPtr (): PObj
; inline; begin result
:= @FObj
; end;
6556 procedure TCorpse
.positionChanged (); inline; begin end;
6558 procedure TCorpse
.moveBy (dx
, dy
: Integer); inline;
6560 if (dx
<> 0) or (dy
<> 0) then
6569 procedure TCorpse
.getMapBox (out x
, y
, w
, h
: Integer); inline;
6571 x
:= FObj
.X
+PLAYER_CORPSERECT
.X
;
6572 y
:= FObj
.Y
+PLAYER_CORPSERECT
.Y
;
6573 w
:= PLAYER_CORPSERECT
.Width
;
6574 h
:= PLAYER_CORPSERECT
.Height
;
6578 procedure TCorpse
.Damage(Value
: Word; SpawnerUID
: Word; vx
, vy
: Integer);
6583 if FState
= CORPSE_STATE_REMOVEME
then
6586 FDamage
:= FDamage
+ Value
;
6588 if FDamage
> 150 then
6590 if FAnimation
<> nil then
6595 FState
:= CORPSE_STATE_REMOVEME
;
6597 g_Player_CreateGibs(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
6598 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2),
6599 FModelName
, FColor
);
6600 // Çâóê ìÿñà îò òðóïà:
6601 pm
:= g_PlayerModel_Get(FModelName
);
6602 pm
.PlaySound(MODELSOUND_DIE
, 5, FObj
.X
, FObj
.Y
);
6606 if (gBodyKillEvent
<> -1)
6607 and gDelayedEvents
[gBodyKillEvent
].Pending
then
6608 gDelayedEvents
[gBodyKillEvent
].Pending
:= False;
6609 gBodyKillEvent
:= g_Game_DelayEvent(DE_BODYKILL
, 1050, SpawnerUID
);
6614 Blood
:= g_PlayerModel_GetBlood(FModelName
);
6615 FObj
.Vel
.X
:= FObj
.Vel
.X
+ vx
;
6616 FObj
.Vel
.Y
:= FObj
.Vel
.Y
+ vy
;
6617 g_GFX_Blood(FObj
.X
+PLAYER_CORPSERECT
.X
+(PLAYER_CORPSERECT
.Width
div 2),
6618 FObj
.Y
+PLAYER_CORPSERECT
.Y
+(PLAYER_CORPSERECT
.Height
div 2),
6619 Value
, vx
, vy
, 16, (PLAYER_CORPSERECT
.Height
*2) div 3,
6620 Blood
.R
, Blood
.G
, Blood
.B
, Blood
.Kind
);
6624 procedure TCorpse
.Draw();
6628 if FState
= CORPSE_STATE_REMOVEME
then
6631 FObj
.lerp(gLerpFactor
, fX
, fY
);
6633 if FAnimation
<> nil then
6634 FAnimation
.Draw(fX
, fY
, TMirrorType
.None
);
6636 if FAnimationMask
<> nil then
6639 FAnimationMask
.Draw(fX
, fY
, TMirrorType
.None
);
6646 procedure TCorpse
.Update();
6650 if FState
= CORPSE_STATE_REMOVEME
then
6653 FObj
.oldX
:= FObj
.X
;
6654 FObj
.oldY
:= FObj
.Y
;
6656 if gTime
mod (GAME_TICK
*2) <> 0 then
6658 g_Obj_Move(@FObj
, True, True, True);
6659 positionChanged(); // this updates spatial accelerators
6663 // Ñîïðîòèâëåíèå âîçäóõà äëÿ òðóïà:
6664 FObj
.Vel
.X
:= z_dec(FObj
.Vel
.X
, 1);
6666 st
:= g_Obj_Move(@FObj
, True, True, True);
6667 positionChanged(); // this updates spatial accelerators
6669 if WordBool(st
and MOVE_FALLOUT
) then
6671 FState
:= CORPSE_STATE_REMOVEME
;
6675 if FAnimation
<> nil then
6676 FAnimation
.Update();
6677 if FAnimationMask
<> nil then
6678 FAnimationMask
.Update();
6682 procedure TCorpse
.SaveState (st
: TStream
);
6689 utils
.writeSign(st
, 'CORP');
6690 utils
.writeInt(st
, Byte(0));
6692 utils
.writeInt(st
, Byte(FState
));
6694 utils
.writeInt(st
, Byte(FDamage
));
6696 utils
.writeInt(st
, Byte(FColor
.R
));
6697 utils
.writeInt(st
, Byte(FColor
.G
));
6698 utils
.writeInt(st
, Byte(FColor
.B
));
6700 Obj_SaveState(st
, @FObj
);
6701 utils
.writeInt(st
, Word(FPlayerUID
));
6703 anim
:= (FAnimation
<> nil);
6704 utils
.writeBool(st
, anim
);
6705 // Åñëè åñòü - ñîõðàíÿåì
6706 if anim
then FAnimation
.SaveState(st
);
6707 // Åñòü ëè ìàñêà àíèìàöèè
6708 anim
:= (FAnimationMask
<> nil);
6709 utils
.writeBool(st
, anim
);
6710 // Åñëè åñòü - ñîõðàíÿåì
6711 if anim
then FAnimationMask
.SaveState(st
);
6715 procedure TCorpse
.LoadState (st
: TStream
);
6722 if not utils
.checkSign(st
, 'CORP') then raise XStreamError
.Create('invalid corpse signature');
6723 if (utils
.readByte(st
) <> 0) then raise XStreamError
.Create('invalid corpse version');
6725 FState
:= utils
.readByte(st
);
6727 FDamage
:= utils
.readByte(st
);
6729 FColor
.R
:= utils
.readByte(st
);
6730 FColor
.G
:= utils
.readByte(st
);
6731 FColor
.B
:= utils
.readByte(st
);
6733 Obj_LoadState(@FObj
, st
);
6734 FPlayerUID
:= utils
.readWord(st
);
6736 anim
:= utils
.readBool(st
);
6737 // Åñëè åñòü - çàãðóæàåì
6740 Assert(FAnimation
<> nil, 'TCorpse.LoadState: no FAnimation');
6741 FAnimation
.LoadState(st
);
6743 // Åñòü ëè ìàñêà àíèìàöèè
6744 anim
:= utils
.readBool(st
);
6745 // Åñëè åñòü - çàãðóæàåì
6748 Assert(FAnimationMask
<> nil, 'TCorpse.LoadState: no FAnimationMask');
6749 FAnimationMask
.LoadState(st
);
6755 constructor TBot
.Create();
6762 FSpectator
:= False;
6769 for a
:= WP_FIRST
to WP_LAST
do
6771 FDifficult
.WeaponPrior
[a
] := WEAPON_PRIOR1
[a
];
6772 FDifficult
.CloseWeaponPrior
[a
] := WEAPON_PRIOR2
[a
];
6773 //FDifficult.SafeWeaponPrior[a] := WEAPON_PRIOR3[a];
6777 destructor TBot
.Destroy();
6780 inherited Destroy();
6783 procedure TBot
.Draw();
6787 //if FTargetUID <> 0 then e_DrawLine(1, FObj.X, FObj.Y, g_Player_Get(FTargetUID).FObj.X,
6788 // g_Player_Get(FTargetUID).FObj.Y, 255, 0, 0);
6791 procedure TBot
.Respawn(Silent
: Boolean; Force
: Boolean = False);
6793 inherited Respawn(Silent
, Force
);
6796 FSelectedWeapon
:= FCurrWeap
;
6801 procedure TBot
.UpdateCombat();
6814 TTargetRecord
= array of TTarget
;
6816 function Compare(a
, b
: TTarget
): Integer;
6818 if a
.Line
and not b
.Line
then // A íà ëèíèè îãíÿ
6821 if not a
.Line
and b
.Line
then // B íà ëèíèè îãíÿ
6823 else // È A, è B íà ëèíèè èëè íå íà ëèíèè îãíÿ
6824 if (a
.Line
and b
.Line
) or ((not a
.Line
) and (not b
.Line
)) then
6826 if a
.Dist
> b
.Dist
then // B áëèæå
6828 else // A áëèæå èëè ðàâíîóäàëåííî ñ B
6831 else // Ñòðàííî -> A
6836 a
, x1
, y1
, x2
, y2
: Integer;
6837 targets
: TTargetRecord
;
6839 Target
, BestTarget
: TTarget
;
6840 firew
, fireh
: Integer;
6844 vsPlayer
, vsMonster
, ok
: Boolean;
6847 function monsUpdate (mon
: TMonster
): Boolean;
6849 result
:= false; // don't stop
6850 if mon
.alive
and (mon
.MonsterType
<> MONSTER_BARREL
) then
6852 if not TargetOnScreen(mon
.Obj
.X
+mon
.Obj
.Rect
.X
, mon
.Obj
.Y
+mon
.Obj
.Rect
.Y
) then exit
;
6854 x2
:= mon
.Obj
.X
+mon
.Obj
.Rect
.X
+(mon
.Obj
.Rect
.Width
div 2);
6855 y2
:= mon
.Obj
.Y
+mon
.Obj
.Rect
.Y
+(mon
.Obj
.Rect
.Height
div 2);
6857 // Åñëè ìîíñòð íà ýêðàíå è íå ïðèêðûò ñòåíîé
6858 if g_TraceVector(x1
, y1
, x2
, y2
) then
6860 // Äîáàâëÿåì ê ñïèñêó âîçìîæíûõ öåëåé
6861 SetLength(targets
, Length(targets
)+1);
6862 with targets
[High(targets
)] do
6869 Rect
:= mon
.Obj
.Rect
;
6870 Dist
:= g_PatchLength(x1
, y1
, x2
, y2
);
6871 Line
:= (y1
+4 < Target
.Y
+ mon
.Obj
.Rect
.Y
+ mon
.Obj
.Rect
.Height
) and
6872 (y1
-4 > Target
.Y
+ mon
.Obj
.Rect
.Y
);
6881 vsPlayer
:= LongBool(gGameSettings
.Options
and GAME_OPTION_BOTVSPLAYER
);
6882 vsMonster
:= LongBool(gGameSettings
.Options
and GAME_OPTION_BOTVSMONSTER
);
6884 // Åñëè òåêóùåå îðóæèå íå òî, ÷òî íóæíî, òî ìåíÿåì:
6885 if FCurrWeap
<> FSelectedWeapon
then
6888 // Åñëè íóæíî ñòðåëÿòü è íóæíîå îðóæèå, òî íàæàòü "Ñòðåëÿòü":
6889 if (GetAIFlag('NEEDFIRE') <> '') and (FCurrWeap
= FSelectedWeapon
) then
6891 RemoveAIFlag('NEEDFIRE');
6894 WEAPON_PLASMA
, WEAPON_SUPERPULEMET
, WEAPON_CHAINGUN
: PressKey(KEY_FIRE
, 20);
6895 WEAPON_SAW
, WEAPON_KASTET
, WEAPON_FLAMETHROWER
: PressKey(KEY_FIRE
, 40);
6896 else PressKey(KEY_FIRE
);
6900 // Êîîðäèíàòû ñòâîëà:
6901 x1
:= FObj
.X
+ WEAPONPOINT
[FDirection
].X
;
6902 y1
:= FObj
.Y
+ WEAPONPOINT
[FDirection
].Y
;
6904 Target
.UID
:= FTargetUID
;
6907 if Target
.UID
<> 0 then
6908 begin // Öåëü åñòü - íàñòðàèâàåì
6909 if (g_GetUIDType(Target
.UID
) = UID_PLAYER
) and
6912 tpla
:= g_Player_Get(Target
.UID
);
6916 if (@FObj
) <> nil then
6923 Target
.cX
:= Target
.X
+ PLAYER_RECT_CX
;
6924 Target
.cY
:= Target
.Y
+ PLAYER_RECT_CY
;
6925 Target
.Rect
:= PLAYER_RECT
;
6926 Target
.Visible
:= g_TraceVector(x1
, y1
, Target
.cX
, Target
.cY
);
6927 Target
.Line
:= (y1
+4 < Target
.Y
+PLAYER_RECT
.Y
+PLAYER_RECT
.Height
) and
6928 (y1
-4 > Target
.Y
+PLAYER_RECT
.Y
);
6929 Target
.IsPlayer
:= True;
6933 if (g_GetUIDType(Target
.UID
) = UID_MONSTER
) and
6936 mon
:= g_Monsters_ByUID(Target
.UID
);
6939 Target
.X
:= mon
.Obj
.X
;
6940 Target
.Y
:= mon
.Obj
.Y
;
6942 Target
.cX
:= Target
.X
+ mon
.Obj
.Rect
.X
+ (mon
.Obj
.Rect
.Width
div 2);
6943 Target
.cY
:= Target
.Y
+ mon
.Obj
.Rect
.Y
+ (mon
.Obj
.Rect
.Height
div 2);
6944 Target
.Rect
:= mon
.Obj
.Rect
;
6945 Target
.Visible
:= g_TraceVector(x1
, y1
, Target
.cX
, Target
.cY
);
6946 Target
.Line
:= (y1
+4 < Target
.Y
+ mon
.Obj
.Rect
.Y
+ mon
.Obj
.Rect
.Height
) and
6947 (y1
-4 > Target
.Y
+ mon
.Obj
.Rect
.Y
);
6948 Target
.IsPlayer
:= False;
6955 begin // Öåëè íåò - îáíóëÿåì
6960 Target
.Visible
:= False;
6961 Target
.Line
:= False;
6962 Target
.IsPlayer
:= False;
6967 // Åñëè öåëü íå âèäèìà èëè íå íà ëèíèè îãíÿ, òî èùåì âñå âîçìîæíûå öåëè:
6968 if (not Target
.Line
) or (not Target
.Visible
) then
6972 for a
:= 0 to High(gPlayers
) do
6973 if (gPlayers
[a
] <> nil) and (gPlayers
[a
].alive
) and
6974 (gPlayers
[a
].FUID
<> FUID
) and
6975 (not SameTeam(FUID
, gPlayers
[a
].FUID
)) and
6976 (not gPlayers
[a
].NoTarget
) and
6977 (gPlayers
[a
].FMegaRulez
[MR_INVIS
] < gTime
) then
6979 if not TargetOnScreen(gPlayers
[a
].FObj
.X
+ PLAYER_RECT
.X
,
6980 gPlayers
[a
].FObj
.Y
+ PLAYER_RECT
.Y
) then
6983 x2
:= gPlayers
[a
].FObj
.X
+ PLAYER_RECT_CX
;
6984 y2
:= gPlayers
[a
].FObj
.Y
+ PLAYER_RECT_CY
;
6986 // Åñëè èãðîê íà ýêðàíå è íå ïðèêðûò ñòåíîé:
6987 if g_TraceVector(x1
, y1
, x2
, y2
) then
6989 // Äîáàâëÿåì ê ñïèñêó âîçìîæíûõ öåëåé:
6990 SetLength(targets
, Length(targets
)+1);
6991 with targets
[High(targets
)] do
6993 UID
:= gPlayers
[a
].FUID
;
6994 X
:= gPlayers
[a
].FObj
.X
;
6995 Y
:= gPlayers
[a
].FObj
.Y
;
6998 Rect
:= PLAYER_RECT
;
6999 Dist
:= g_PatchLength(x1
, y1
, x2
, y2
);
7000 Line
:= (y1
+4 < Target
.Y
+PLAYER_RECT
.Y
+PLAYER_RECT
.Height
) and
7001 (y1
-4 > Target
.Y
+PLAYER_RECT
.Y
);
7009 if vsMonster
then g_Mons_ForEach(monsUpdate
);
7012 // Åñëè åñòü âîçìîæíûå öåëè:
7013 // (Âûáèðàåì ëó÷øóþ, ìåíÿåì îðóæèå è áåæèì ê íåé/îò íåå)
7014 if targets
<> nil then
7016 // Âûáèðàåì íàèëó÷øóþ öåëü:
7017 BestTarget
:= targets
[0];
7018 if Length(targets
) > 1 then
7019 for a
:= 1 to High(targets
) do
7020 if Compare(BestTarget
, targets
[a
]) = 1 then
7021 BestTarget
:= targets
[a
];
7023 // Åñëè ëó÷øàÿ öåëü "âèäíåå" òåêóùåé, òî òåêóùàÿ := ëó÷øàÿ:
7024 if ((not Target
.Visible
) and BestTarget
.Visible
and (Target
.UID
<> BestTarget
.UID
)) or
7025 ((not Target
.Line
) and BestTarget
.Line
and BestTarget
.Visible
) then
7027 Target
:= BestTarget
;
7029 if (Healthy() = 3) or ((Healthy() = 2)) then
7030 begin // Åñëè çäîðîâû - äîãîíÿåì
7031 if ((RunDirection() = TDirection
.D_LEFT
) and (Target
.X
> FObj
.X
)) then
7032 SetAIFlag('GORIGHT', '1');
7033 if ((RunDirection() = TDirection
.D_RIGHT
) and (Target
.X
< FObj
.X
)) then
7034 SetAIFlag('GOLEFT', '1');
7037 begin // Åñëè ïîáèòû - óáåãàåì
7038 if ((RunDirection() = TDirection
.D_LEFT
) and (Target
.X
< FObj
.X
)) then
7039 SetAIFlag('GORIGHT', '1');
7040 if ((RunDirection() = TDirection
.D_RIGHT
) and (Target
.X
> FObj
.X
)) then
7041 SetAIFlag('GOLEFT', '1');
7044 // Âûáèðàåì îðóæèå íà îñíîâå ðàññòîÿíèÿ è ïðèîðèòåòîâ:
7045 SelectWeapon(Abs(x1
-Target
.cX
));
7050 // (Äîãîíÿåì/óáåãàåì, ñòðåëÿåì ïî íàïðàâëåíèþ ê öåëè)
7051 // (Åñëè öåëü äàëåêî, òî õâàòèò ñëåäèòü çà íåé)
7052 if Target
.UID
<> 0 then
7054 if not TargetOnScreen(Target
.X
+ Target
.Rect
.X
,
7055 Target
.Y
+ Target
.Rect
.Y
) then
7056 begin // Öåëü ñáåæàëà ñ "ýêðàíà"
7057 if (Healthy() = 3) or ((Healthy() = 2)) then
7058 begin // Åñëè çäîðîâû - äîãîíÿåì
7059 if ((RunDirection() = TDirection
.D_LEFT
) and (Target
.X
> FObj
.X
)) then
7060 SetAIFlag('GORIGHT', '1');
7061 if ((RunDirection() = TDirection
.D_RIGHT
) and (Target
.X
< FObj
.X
)) then
7062 SetAIFlag('GOLEFT', '1');
7065 begin // Åñëè ïîáèòû - çàáûâàåì î öåëè è óáåãàåì
7067 if ((RunDirection() = TDirection
.D_LEFT
) and (Target
.X
< FObj
.X
)) then
7068 SetAIFlag('GORIGHT', '1');
7069 if ((RunDirection() = TDirection
.D_RIGHT
) and (Target
.X
> FObj
.X
)) then
7070 SetAIFlag('GOLEFT', '1');
7074 begin // Öåëü ïîêà íà "ýêðàíå"
7075 // Åñëè öåëü íå çàãîðîæåíà ñòåíîé, òî îòìå÷àåì, êîãäà åå âèäåëè:
7076 if g_TraceVector(x1
, y1
, Target
.cX
, Target
.cY
) then
7077 FLastVisible
:= gTime
;
7078 // Åñëè ðàçíèöà âûñîò íå âåëèêà, òî äîãîíÿåì:
7079 if (Abs(FObj
.Y
-Target
.Y
) <= 128) then
7081 if ((RunDirection() = TDirection
.D_LEFT
) and (Target
.X
> FObj
.X
)) then
7082 SetAIFlag('GORIGHT', '1');
7083 if ((RunDirection() = TDirection
.D_RIGHT
) and (Target
.X
< FObj
.X
)) then
7084 SetAIFlag('GOLEFT', '1');
7088 // Âûáèðàåì óãîë ââåðõ:
7089 if FDirection
= TDirection
.D_LEFT
then
7090 angle
:= ANGLE_LEFTUP
7092 angle
:= ANGLE_RIGHTUP
;
7094 firew
:= Trunc(Cos(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
7095 fireh
:= Trunc(Sin(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
7097 // Åñëè ïðè óãëå ââåðõ ìîæíî ïîïàñòü â ïðèáëèçèòåëüíîå ïîëîæåíèå öåëè:
7098 if g_CollideLine(x1
, y1
, x1
+firew
, y1
+fireh
,
7099 Target
.X
+Target
.Rect
.X
+GetInterval(FDifficult
.DiagPrecision
, 128), //96
7100 Target
.Y
+Target
.Rect
.Y
+GetInterval(FDifficult
.DiagPrecision
, 128),
7101 Target
.Rect
.Width
, Target
.Rect
.Height
) and
7102 g_TraceVector(x1
, y1
, Target
.cX
, Target
.cY
) then
7103 begin // òî íóæíî ñòðåëÿòü ââåðõ
7104 SetAIFlag('NEEDFIRE', '1');
7105 SetAIFlag('NEEDSEEUP', '1');
7108 // Âûáèðàåì óãîë âíèç:
7109 if FDirection
= TDirection
.D_LEFT
then
7110 angle
:= ANGLE_LEFTDOWN
7112 angle
:= ANGLE_RIGHTDOWN
;
7114 firew
:= Trunc(Cos(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
7115 fireh
:= Trunc(Sin(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
7117 // Åñëè ïðè óãëå âíèç ìîæíî ïîïàñòü â ïðèáëèçèòåëüíîå ïîëîæåíèå öåëè:
7118 if g_CollideLine(x1
, y1
, x1
+firew
, y1
+fireh
,
7119 Target
.X
+Target
.Rect
.X
+GetInterval(FDifficult
.DiagPrecision
, 128),
7120 Target
.Y
+Target
.Rect
.Y
+GetInterval(FDifficult
.DiagPrecision
, 128),
7121 Target
.Rect
.Width
, Target
.Rect
.Height
) and
7122 g_TraceVector(x1
, y1
, Target
.cX
, Target
.cY
) then
7123 begin // òî íóæíî ñòðåëÿòü âíèç
7124 SetAIFlag('NEEDFIRE', '1');
7125 SetAIFlag('NEEDSEEDOWN', '1');
7128 // Åñëè öåëü âèäíî è îíà íà òàêîé æå âûñîòå:
7129 if Target
.Visible
and
7130 (y1
+4 < Target
.Y
+Target
.Rect
.Y
+Target
.Rect
.Height
) and
7131 (y1
-4 > Target
.Y
+Target
.Rect
.Y
) then
7133 // Åñëè èäåì â ñòîðîíó öåëè, òî íàäî ñòðåëÿòü:
7134 if ((FDirection
= TDirection
.D_LEFT
) and (Target
.X
< FObj
.X
)) or
7135 ((FDirection
= TDirection
.D_RIGHT
) and (Target
.X
> FObj
.X
)) then
7136 begin // òî íóæíî ñòðåëÿòü âïåðåä
7137 SetAIFlag('NEEDFIRE', '1');
7138 SetAIFlag('NEEDSEEDOWN', '');
7139 SetAIFlag('NEEDSEEUP', '');
7141 // Åñëè öåëü â ïðåäåëàõ "ýêðàíà" è ñëîæíîñòü ïîçâîëÿåò ïðûæêè ñáëèæåíèÿ:
7142 if Abs(FObj
.X
-Target
.X
) < Trunc(gPlayerScreenSize
.X
*0.75) then
7143 if GetRnd(FDifficult
.CloseJump
) then
7144 begin // òî åñëè ïîâåçåò - ïðûãàåì (îñîáåííî, åñëè áëèçêî)
7145 if Abs(FObj
.X
-Target
.X
) < 128 then
7149 if Random(a
) = 0 then
7150 SetAIFlag('NEEDJUMP', '1');
7154 // Åñëè öåëü âñå åùå åñòü:
7155 if Target
.UID
<> 0 then
7156 if gTime
-FLastVisible
> 2000 then // Åñëè âèäåëè äàâíî
7157 Target
.UID
:= 0 // òî çàáûòü öåëü
7158 else // Åñëè âèäåëè íåäàâíî
7159 begin // íî öåëü óáèëè
7160 if Target
.IsPlayer
then
7161 begin // Öåëü - èãðîê
7162 pla
:= g_Player_Get(Target
.UID
);
7163 if (pla
= nil) or (not pla
.alive
) or pla
.NoTarget
or
7164 (pla
.FMegaRulez
[MR_INVIS
] >= gTime
) then
7165 Target
.UID
:= 0; // òî çàáûòü öåëü
7168 begin // Öåëü - ìîíñòð
7169 mon
:= g_Monsters_ByUID(Target
.UID
);
7170 if (mon
= nil) or (not mon
.alive
) then
7171 Target
.UID
:= 0; // òî çàáûòü öåëü
7174 end; // if Target.UID <> 0
7176 FTargetUID
:= Target
.UID
;
7178 // Åñëè âîçìîæíûõ öåëåé íåò:
7179 // (Àòàêà ÷åãî-íèáóäü ñëåâà èëè ñïðàâà)
7180 if targets
= nil then
7181 if GetAIFlag('ATTACKLEFT') <> '' then
7182 begin // Åñëè íóæíî àòàêîâàòü íàëåâî
7183 RemoveAIFlag('ATTACKLEFT');
7185 SetAIFlag('NEEDJUMP', '1');
7187 if RunDirection() = TDirection
.D_RIGHT
then
7188 begin // Èäåì íå â òó ñòîðîíó
7189 if (Healthy() > 1) and GetRnd(FDifficult
.InvisFire
) then
7190 begin // Åñëè çäîðîâû, òî, âîçìîæíî, ñòðåëÿåì áåæèì âëåâî è ñòðåëÿåì
7191 SetAIFlag('NEEDFIRE', '1');
7192 SetAIFlag('GOLEFT', '1');
7196 begin // Èäåì â íóæíóþ ñòîðîíó
7197 if GetRnd(FDifficult
.InvisFire
) then // Âîçìîæíî, ñòðåëÿåì âñëåïóþ
7198 SetAIFlag('NEEDFIRE', '1');
7199 if Healthy() <= 1 then // Ïîáèòû - óáåãàåì
7200 SetAIFlag('GORIGHT', '1');
7204 if GetAIFlag('ATTACKRIGHT') <> '' then
7205 begin // Åñëè íóæíî àòàêîâàòü íàïðàâî
7206 RemoveAIFlag('ATTACKRIGHT');
7208 SetAIFlag('NEEDJUMP', '1');
7210 if RunDirection() = TDirection
.D_LEFT
then
7211 begin // Èäåì íå â òó ñòîðîíó
7212 if (Healthy() > 1) and GetRnd(FDifficult
.InvisFire
) then
7213 begin // Åñëè çäîðîâû, òî, âîçìîæíî, áåæèì âïðàâî è ñòðåëÿåì
7214 SetAIFlag('NEEDFIRE', '1');
7215 SetAIFlag('GORIGHT', '1');
7220 if GetRnd(FDifficult
.InvisFire
) then // Âîçìîæíî, ñòðåëÿåì âñëåïóþ
7221 SetAIFlag('NEEDFIRE', '1');
7222 if Healthy() <= 1 then // Ïîáèòû - óáåãàåì
7223 SetAIFlag('GOLEFT', '1');
7227 //HACK! (does it belongs there?)
7228 RealizeCurrentWeapon();
7230 // Åñëè åñòü âîçìîæíûå öåëè:
7231 // (Ñòðåëÿåì ïî íàïðàâëåíèþ ê öåëÿì)
7232 if (targets
<> nil) and (GetAIFlag('NEEDFIRE') <> '') then
7233 for a
:= 0 to High(targets
) do
7235 // Åñëè ìîæåì ñòðåëÿòü ïî äèàãîíàëè:
7236 if GetRnd(FDifficult
.DiagFire
) then
7238 // Èùåì öåëü ñâåðõó è ñòðåëÿåì, åñëè åñòü:
7239 if FDirection
= TDirection
.D_LEFT
then
7240 angle
:= ANGLE_LEFTUP
7242 angle
:= ANGLE_RIGHTUP
;
7244 firew
:= Trunc(Cos(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
7245 fireh
:= Trunc(Sin(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
7247 if g_CollideLine(x1
, y1
, x1
+firew
, y1
+fireh
,
7248 targets
[a
].X
+targets
[a
].Rect
.X
+GetInterval(FDifficult
.DiagPrecision
, 128),
7249 targets
[a
].Y
+targets
[a
].Rect
.Y
+GetInterval(FDifficult
.DiagPrecision
, 128),
7250 targets
[a
].Rect
.Width
, targets
[a
].Rect
.Height
) and
7251 g_TraceVector(x1
, y1
, targets
[a
].cX
, targets
[a
].cY
) then
7253 SetAIFlag('NEEDFIRE', '1');
7254 SetAIFlag('NEEDSEEUP', '1');
7257 // Èùåì öåëü ñíèçó è ñòðåëÿåì, åñëè åñòü:
7258 if FDirection
= TDirection
.D_LEFT
then
7259 angle
:= ANGLE_LEFTDOWN
7261 angle
:= ANGLE_RIGHTDOWN
;
7263 firew
:= Trunc(Cos(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
7264 fireh
:= Trunc(Sin(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
7266 if g_CollideLine(x1
, y1
, x1
+firew
, y1
+fireh
,
7267 targets
[a
].X
+targets
[a
].Rect
.X
+GetInterval(FDifficult
.DiagPrecision
, 128),
7268 targets
[a
].Y
+targets
[a
].Rect
.Y
+GetInterval(FDifficult
.DiagPrecision
, 128),
7269 targets
[a
].Rect
.Width
, targets
[a
].Rect
.Height
) and
7270 g_TraceVector(x1
, y1
, targets
[a
].cX
, targets
[a
].cY
) then
7272 SetAIFlag('NEEDFIRE', '1');
7273 SetAIFlag('NEEDSEEDOWN', '1');
7277 // Åñëè öåëü "ïåðåä íîñîì", òî ñòðåëÿåì:
7278 if targets
[a
].Line
and targets
[a
].Visible
and
7279 (((FDirection
= TDirection
.D_LEFT
) and (targets
[a
].X
< FObj
.X
)) or
7280 ((FDirection
= TDirection
.D_RIGHT
) and (targets
[a
].X
> FObj
.X
))) then
7282 SetAIFlag('NEEDFIRE', '1');
7287 // Åñëè ëåòèò ïóëÿ, òî, âîçìîæíî, ïîäïðûãèâàåì:
7288 if g_Weapon_Danger(FUID
, FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+PLAYER_RECT
.Y
,
7289 PLAYER_RECT
.Width
, PLAYER_RECT
.Height
,
7290 40+GetInterval(FDifficult
.Cover
, 40)) then
7291 SetAIFlag('NEEDJUMP', '1');
7293 // Åñëè êîí÷èëèñü ïàòîðíû, òî íóæíî ñìåíèòü îðóæèå:
7294 ammo
:= GetAmmoByWeapon(FCurrWeap
);
7295 if ((FCurrWeap
= WEAPON_SHOTGUN2
) and (ammo
< 2)) or
7296 ((FCurrWeap
= WEAPON_BFG
) and (ammo
< 40)) or
7298 SetAIFlag('SELECTWEAPON', '1');
7300 // Åñëè íóæíî ñìåíèòü îðóæèå, òî âûáèðàåì íóæíîå:
7301 if GetAIFlag('SELECTWEAPON') = '1' then
7304 RemoveAIFlag('SELECTWEAPON');
7308 procedure TBot
.Update();
7321 // Ïðîâåðÿåì, îòêëþ÷¸í ëè AI áîòîâ
7322 if (g_debug_BotAIOff
= 1) and (Team
= TEAM_RED
) then
7324 if (g_debug_BotAIOff
= 2) and (Team
= TEAM_BLUE
) then
7326 if g_debug_BotAIOff
= 3 then
7336 RealizeCurrentWeapon();
7343 procedure TBot
.ReleaseKey(Key
: Byte);
7352 function TBot
.KeyPressed(Key
: Word): Boolean;
7354 Result
:= FKeys
[Key
].Pressed
;
7357 function TBot
.GetAIFlag(aName
: String20
): String20
;
7363 aName
:= LowerCase(aName
);
7365 if FAIFlags
<> nil then
7366 for a
:= 0 to High(FAIFlags
) do
7367 if LowerCase(FAIFlags
[a
].Name
) = aName
then
7369 Result
:= FAIFlags
[a
].Value
;
7374 procedure TBot
.RemoveAIFlag(aName
: String20
);
7378 if FAIFlags
= nil then Exit
;
7380 aName
:= LowerCase(aName
);
7382 for a
:= 0 to High(FAIFlags
) do
7383 if LowerCase(FAIFlags
[a
].Name
) = aName
then
7385 if a
<> High(FAIFlags
) then
7386 for b
:= a
to High(FAIFlags
)-1 do
7387 FAIFlags
[b
] := FAIFlags
[b
+1];
7389 SetLength(FAIFlags
, Length(FAIFlags
)-1);
7394 procedure TBot
.SetAIFlag(aName
, fValue
: String20
);
7402 aName
:= LowerCase(aName
);
7404 if FAIFlags
<> nil then
7405 for a
:= 0 to High(FAIFlags
) do
7406 if LowerCase(FAIFlags
[a
].Name
) = aName
then
7412 if ok
then FAIFlags
[a
].Value
:= fValue
7415 SetLength(FAIFlags
, Length(FAIFlags
)+1);
7416 with FAIFlags
[High(FAIFlags
)] do
7424 procedure TBot
.UpdateMove
;
7426 procedure GoLeft(Time
: Word = 1);
7428 ReleaseKey(KEY_LEFT
);
7429 ReleaseKey(KEY_RIGHT
);
7430 PressKey(KEY_LEFT
, Time
);
7431 SetDirection(TDirection
.D_LEFT
);
7434 procedure GoRight(Time
: Word = 1);
7436 ReleaseKey(KEY_LEFT
);
7437 ReleaseKey(KEY_RIGHT
);
7438 PressKey(KEY_RIGHT
, Time
);
7439 SetDirection(TDirection
.D_RIGHT
);
7442 function Rnd(a
: Word): Boolean;
7444 Result
:= Random(a
) = 0;
7447 procedure Turn(Time
: Word = 1200);
7449 if RunDirection() = TDirection
.D_LEFT
then GoRight(Time
) else GoLeft(Time
);
7454 ReleaseKey(KEY_LEFT
);
7455 ReleaseKey(KEY_RIGHT
);
7458 function CanRunLeft(): Boolean;
7460 Result
:= not CollideLevel(-1, 0);
7463 function CanRunRight(): Boolean;
7465 Result
:= not CollideLevel(1, 0);
7468 function CanRun(): Boolean;
7470 if RunDirection() = TDirection
.D_LEFT
then Result
:= CanRunLeft() else Result
:= CanRunRight();
7473 procedure Jump(Time
: Word = 30);
7475 PressKey(KEY_JUMP
, Time
);
7478 function NearHole(): Boolean;
7482 { TODO 5 : Ëåñòíèöû }
7483 sx
:= IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1);
7484 for x
:= 1 to PLAYER_RECT
.Width
do
7485 if (not StayOnStep(x
*sx
, 0)) and
7486 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
)) and
7487 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
*2)) then
7496 function BorderHole(): Boolean;
7500 { TODO 5 : Ëåñòíèöû }
7501 sx
:= IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1);
7502 for x
:= 1 to PLAYER_RECT
.Width
do
7503 if (not StayOnStep(x
*sx
, 0)) and
7504 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
)) and
7505 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
*2)) then
7507 for xx
:= x
to x
+32 do
7508 if CollideLevel(xx
*sx
, PLAYER_RECT
.Height
) then
7518 function NearDeepHole(): Boolean;
7524 sx
:= IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1);
7527 for x
:= 1 to PLAYER_RECT
.Width
do
7528 if (not StayOnStep(x
*sx
, 0)) and
7529 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
)) and
7530 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
*2)) then
7532 while FObj
.Y
+y
*PLAYER_RECT
.Height
< gMapInfo
.Height
do
7534 if CollideLevel(x
*sx
, PLAYER_RECT
.Height
*y
) then Exit
;
7539 end else Result
:= False;
7542 function OverDeepHole(): Boolean;
7549 while FObj
.Y
+y
*PLAYER_RECT
.Height
< gMapInfo
.Height
do
7551 if CollideLevel(0, PLAYER_RECT
.Height
*y
) then Exit
;
7558 function OnGround(): Boolean;
7560 Result
:= StayOnStep(0, 0) or CollideLevel(0, 1);
7563 function OnLadder(): Boolean;
7565 Result
:= FullInStep(0, 0);
7568 function BelowLadder(): Boolean;
7570 Result
:= (FullInStep(IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -PLAYER_RECT
.Height
) and
7571 not CollideLevel(IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -PLAYER_RECT
.Height
)) or
7572 (FullInStep(IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -BOT_MAXJUMP
) and
7573 not CollideLevel(IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -BOT_MAXJUMP
));
7576 function BelowLiftUp(): Boolean;
7578 Result
:= ((FullInLift(IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -PLAYER_RECT
.Height
) = -1) and
7579 not CollideLevel(IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -PLAYER_RECT
.Height
)) or
7580 ((FullInLift(IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -BOT_MAXJUMP
) = -1) and
7581 not CollideLevel(IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -BOT_MAXJUMP
));
7584 function OnTopLift(): Boolean;
7586 Result
:= (FullInLift(0, 0) = -1) and (FullInLift(0, -32) = 0);
7589 function CanJumpOver(): Boolean;
7593 sx
:= IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1);
7597 if not CollideLevel(sx
, 0) then Exit
;
7599 for y
:= 1 to BOT_MAXJUMP
do
7600 if CollideLevel(0, -y
) then Exit
else
7601 if not CollideLevel(sx
, -y
) then
7608 function CanJumpUp(Dist
: ShortInt): Boolean;
7615 if CollideLevel(Dist
, 0) then Exit
;
7618 for y
:= 0 to BOT_MAXJUMP
do
7619 if CollideLevel(Dist
, -y
) then
7628 for yy
:= y
+1 to BOT_MAXJUMP
do
7629 if not CollideLevel(Dist
, -yy
) then
7638 for y
:= 0 to BOT_MAXJUMP
do
7639 if CollideLevel(0, -y
) then
7647 if y
< yy
then Exit
;
7652 function IsSafeTrigger(): Boolean;
7657 if gTriggers
= nil then
7659 for a
:= 0 to High(gTriggers
) do
7660 if Collide(gTriggers
[a
].X
,
7663 gTriggers
[a
].Height
) and
7664 (gTriggers
[a
].TriggerType
in [TRIGGER_EXIT
, TRIGGER_CLOSEDOOR
,
7665 TRIGGER_CLOSETRAP
, TRIGGER_TRAP
,
7666 TRIGGER_PRESS
, TRIGGER_ON
, TRIGGER_OFF
,
7667 TRIGGER_ONOFF
, TRIGGER_SPAWNMONSTER
,
7668 TRIGGER_DAMAGE
, TRIGGER_SHOT
]) then
7673 // Âîçìîæíî, íàæèìàåì êíîïêó:
7674 if Rnd(16) and IsSafeTrigger() then
7677 // Åñëè ïîä ëèôòîì èëè ñòóïåíüêàìè, òî, âîçìîæíî, ïðûãàåì:
7678 if OnLadder() or ((BelowLadder() or BelowLiftUp()) and Rnd(8)) then
7680 ReleaseKey(KEY_LEFT
);
7681 ReleaseKey(KEY_RIGHT
);
7685 // Èäåì âëåâî, åñëè íàäî áûëî:
7686 if GetAIFlag('GOLEFT') <> '' then
7688 RemoveAIFlag('GOLEFT');
7689 if CanRunLeft() then
7693 // Èäåì âïðàâî, åñëè íàäî áûëî:
7694 if GetAIFlag('GORIGHT') <> '' then
7696 RemoveAIFlag('GORIGHT');
7697 if CanRunRight() then
7701 // Åñëè âûëåòåëè çà êàðòó, òî ïðîáóåì âåðíóòüñÿ:
7702 if FObj
.X
< -32 then
7705 if FObj
.X
+32 > gMapInfo
.Width
then
7708 // Ïðûãàåì, åñëè íàäî áûëî:
7709 if GetAIFlag('NEEDJUMP') <> '' then
7712 RemoveAIFlag('NEEDJUMP');
7715 // Ñìîòðèì ââåðõ, åñëè íàäî áûëî:
7716 if GetAIFlag('NEEDSEEUP') <> '' then
7719 ReleaseKey(KEY_DOWN
);
7720 PressKey(KEY_UP
, 20);
7721 RemoveAIFlag('NEEDSEEUP');
7724 // Ñìîòðèì âíèç, åñëè íàäî áûëî:
7725 if GetAIFlag('NEEDSEEDOWN') <> '' then
7728 ReleaseKey(KEY_DOWN
);
7729 PressKey(KEY_DOWN
, 20);
7730 RemoveAIFlag('NEEDSEEDOWN');
7733 // Åñëè íóæíî áûëî â äûðó è ìû íå íà çåìëå, òî ïîêîðíî ëåòèì:
7734 if GetAIFlag('GOINHOLE') <> '' then
7735 if not OnGround() then
7737 ReleaseKey(KEY_LEFT
);
7738 ReleaseKey(KEY_RIGHT
);
7739 RemoveAIFlag('GOINHOLE');
7740 SetAIFlag('FALLINHOLE', '1');
7743 // Åñëè ïàäàëè è äîñòèãëè çåìëè, òî õâàòèò ïàäàòü:
7744 if GetAIFlag('FALLINHOLE') <> '' then
7746 RemoveAIFlag('FALLINHOLE');
7748 // Åñëè ëåòåëè ïðÿìî è ñåé÷àñ íå íà ëåñòíèöå èëè íà âåðøèíå ëèôòà, òî îòõîäèì â ñòîðîíó:
7749 if not (KeyPressed(KEY_LEFT
) or KeyPressed(KEY_RIGHT
)) then
7750 if GetAIFlag('FALLINHOLE') = '' then
7751 if (not OnLadder()) or (FObj
.Vel
.Y
>= 0) or (OnTopLift()) then
7757 // Åñëè íà çåìëå è ìîæíî ïîäïðûãíóòü, òî, âîçìîæíî, ïðûãàåì:
7759 CanJumpUp(IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1)*32) and
7763 // Åñëè íà çåìëå è âîçëå äûðû (ãëóáèíà > 2 ðîñòîâ èãðîêà):
7764 if OnGround() and NearHole() then
7765 if NearDeepHole() then // Åñëè ýòî áåçäíà
7767 0..3: Turn(); // Áåæèì îáðàòíî
7768 4: Jump(); // Ïðûãàåì
7769 5: begin // Ïðûãàåì îáðàòíî
7774 else // Ýòî íå áåçäíà è ìû åùå íå ëåòèì òóäà
7775 if GetAIFlag('GOINHOLE') = '' then
7777 0: Turn(); // Íå íóæíî òóäà
7778 1: Jump(); // Âäðóã ïîâåçåò - ïðûãàåì
7779 else // Åñëè ÿìà ñ ãðàíèöåé, òî ïðè ñëó÷àå ìîæíî òóäà ïðûãíóòü
7780 if BorderHole() then
7781 SetAIFlag('GOINHOLE', '1');
7784 // Åñëè íà çåìëå, íî íåêóäà èäòè:
7785 if (not CanRun()) and OnGround() then
7787 // Åñëè ìû íà ëåñòíèöå èëè ìîæíî ïåðåïðûãíóòü, òî ïðûãàåì:
7788 if CanJumpOver() or OnLadder() then
7790 else // èíà÷å ïîïûòàåìñÿ â äðóãóþ ñòîðîíó
7791 if Random(2) = 0 then
7793 if IsSafeTrigger() then
7799 // Îñòàëîñü ìàëî âîçäóõà:
7800 if FAir
< 36 * 2 then
7803 // Âûáèðàåìñÿ èç êèñëîòû, åñëè íåò êîñòþìà, îáîæãëèñü, èëè ìàëî çäîðîâüÿ:
7804 if (FMegaRulez
[MR_SUIT
] < gTime
) and ((FLastHit
= HIT_ACID
) or (Healthy() <= 1)) then
7805 if BodyInAcid(0, 0) then
7809 function TBot
.FullInStep(XInc
, YInc
: Integer): Boolean;
7811 Result
:= g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
,
7812 PLAYER_RECT
.Width
, PLAYER_RECT
.Height
, PANEL_STEP
, False);
7815 {function TBot.NeedItem(Item: Byte): Byte;
7820 procedure TBot
.SelectWeapon(Dist
: Integer);
7824 function HaveAmmo(weapon
: Byte): Boolean;
7827 WEAPON_PISTOL
: Result
:= FAmmo
[A_BULLETS
] >= 1;
7828 WEAPON_SHOTGUN1
: Result
:= FAmmo
[A_SHELLS
] >= 1;
7829 WEAPON_SHOTGUN2
: Result
:= FAmmo
[A_SHELLS
] >= 2;
7830 WEAPON_CHAINGUN
: Result
:= FAmmo
[A_BULLETS
] >= 10;
7831 WEAPON_ROCKETLAUNCHER
: Result
:= FAmmo
[A_ROCKETS
] >= 1;
7832 WEAPON_PLASMA
: Result
:= FAmmo
[A_CELLS
] >= 10;
7833 WEAPON_BFG
: Result
:= FAmmo
[A_CELLS
] >= 40;
7834 WEAPON_SUPERPULEMET
: Result
:= FAmmo
[A_SHELLS
] >= 1;
7835 WEAPON_FLAMETHROWER
: Result
:= FAmmo
[A_FUEL
] >= 1;
7836 else Result
:= True;
7841 if Dist
= -1 then Dist
:= BOT_LONGDIST
;
7843 if Dist
> BOT_LONGDIST
then
7844 begin // Äàëüíèé áîé
7846 if FWeapon
[FDifficult
.WeaponPrior
[a
]] and HaveAmmo(FDifficult
.WeaponPrior
[a
]) then
7848 FSelectedWeapon
:= FDifficult
.WeaponPrior
[a
];
7852 else //if Dist > BOT_UNSAFEDIST then
7853 begin // Áëèæíèé áîé
7855 if FWeapon
[FDifficult
.CloseWeaponPrior
[a
]] and HaveAmmo(FDifficult
.CloseWeaponPrior
[a
]) then
7857 FSelectedWeapon
:= FDifficult
.CloseWeaponPrior
[a
];
7864 if FWeapon[FDifficult.SafeWeaponPrior[a]] and HaveAmmo(FDifficult.SafeWeaponPrior[a]) then
7866 FSelectedWeapon := FDifficult.SafeWeaponPrior[a];
7872 function TBot
.PickItem(ItemType
: Byte; force
: Boolean; var remove
: Boolean): Boolean;
7874 Result
:= inherited PickItem(ItemType
, force
, remove
);
7876 if Result
then SetAIFlag('SELECTWEAPON', '1');
7879 function TBot
.Heal(value
: Word; Soft
: Boolean): Boolean;
7881 Result
:= inherited Heal(value
, Soft
);
7884 function TBot
.Healthy(): Byte;
7886 if FMegaRulez
[MR_INVUL
] >= gTime
then Result
:= 3
7887 else if (FHealth
> 80) or ((FHealth
> 50) and (FArmor
> 20)) then Result
:= 3
7888 else if (FHealth
> 50) then Result
:= 2
7889 else if (FHealth
> 20) then Result
:= 1
7893 function TBot
.TargetOnScreen(TX
, TY
: Integer): Boolean;
7895 Result
:= (Abs(FObj
.X
-TX
) <= Trunc(gPlayerScreenSize
.X
*0.6)) and
7896 (Abs(FObj
.Y
-TY
) <= Trunc(gPlayerScreenSize
.Y
*0.6));
7899 procedure TBot
.OnDamage(Angle
: SmallInt);
7907 if (Angle
= 0) or (Angle
= 180) then
7910 if (g_GetUIDType(FLastSpawnerUID
) = UID_PLAYER
) and
7911 LongBool(gGameSettings
.Options
and GAME_OPTION_BOTVSPLAYER
) then
7913 pla
:= g_Player_Get(FLastSpawnerUID
);
7914 ok
:= not TargetOnScreen(pla
.FObj
.X
+ PLAYER_RECT
.X
,
7915 pla
.FObj
.Y
+ PLAYER_RECT
.Y
);
7918 if (g_GetUIDType(FLastSpawnerUID
) = UID_MONSTER
) and
7919 LongBool(gGameSettings
.Options
and GAME_OPTION_BOTVSMONSTER
) then
7921 mon
:= g_Monsters_ByUID(FLastSpawnerUID
);
7922 ok
:= not TargetOnScreen(mon
.Obj
.X
+ mon
.Obj
.Rect
.X
,
7923 mon
.Obj
.Y
+ mon
.Obj
.Rect
.Y
);
7928 SetAIFlag('ATTACKLEFT', '1')
7930 SetAIFlag('ATTACKRIGHT', '1');
7934 function TBot
.RunDirection(): TDirection
;
7936 if Abs(Vel
.X
) >= 1 then
7938 if Vel
.X
> 0 then Result
:= TDirection
.D_RIGHT
else Result
:= TDirection
.D_LEFT
;
7940 Result
:= FDirection
;
7943 function TBot
.GetRnd(a
: Byte): Boolean;
7945 if a
= 0 then Result
:= False
7946 else if a
= 255 then Result
:= True
7947 else Result
:= Random(256) > 255-a
;
7950 function TBot
.GetInterval(a
: Byte; radius
: SmallInt): SmallInt;
7952 Result
:= Round((255-a
)/255*radius
*(Random(2)-1));
7956 procedure TDifficult
.save (st
: TStream
);
7958 utils
.writeInt(st
, Byte(DiagFire
));
7959 utils
.writeInt(st
, Byte(InvisFire
));
7960 utils
.writeInt(st
, Byte(DiagPrecision
));
7961 utils
.writeInt(st
, Byte(FlyPrecision
));
7962 utils
.writeInt(st
, Byte(Cover
));
7963 utils
.writeInt(st
, Byte(CloseJump
));
7964 st
.WriteBuffer(WeaponPrior
[Low(WeaponPrior
)], sizeof(WeaponPrior
));
7965 st
.WriteBuffer(CloseWeaponPrior
[Low(CloseWeaponPrior
)], sizeof(CloseWeaponPrior
));
7968 procedure TDifficult
.load (st
: TStream
);
7970 DiagFire
:= utils
.readByte(st
);
7971 InvisFire
:= utils
.readByte(st
);
7972 DiagPrecision
:= utils
.readByte(st
);
7973 FlyPrecision
:= utils
.readByte(st
);
7974 Cover
:= utils
.readByte(st
);
7975 CloseJump
:= utils
.readByte(st
);
7976 st
.ReadBuffer(WeaponPrior
[Low(WeaponPrior
)], sizeof(WeaponPrior
));
7977 st
.ReadBuffer(CloseWeaponPrior
[Low(CloseWeaponPrior
)], sizeof(CloseWeaponPrior
));
7981 procedure TBot
.SaveState (st
: TStream
);
7986 inherited SaveState(st
);
7987 utils
.writeSign(st
, 'BOT0');
7989 utils
.writeInt(st
, Byte(FSelectedWeapon
));
7991 utils
.writeInt(st
, Word(FTargetUID
));
7992 // Âðåìÿ ïîòåðè öåëè
7993 utils
.writeInt(st
, LongWord(FLastVisible
));
7994 // Êîëè÷åñòâî ôëàãîâ ÈÈ
7995 dw
:= Length(FAIFlags
);
7996 utils
.writeInt(st
, LongInt(dw
));
7998 for i
:= 0 to dw
-1 do
8000 utils
.writeStr(st
, FAIFlags
[i
].Name
, 20);
8001 utils
.writeStr(st
, FAIFlags
[i
].Value
, 20);
8003 // Íàñòðîéêè ñëîæíîñòè
8004 FDifficult
.save(st
);
8008 procedure TBot
.LoadState (st
: TStream
);
8013 inherited LoadState(st
);
8014 if not utils
.checkSign(st
, 'BOT0') then raise XStreamError
.Create('invalid bot signature');
8016 FSelectedWeapon
:= utils
.readByte(st
);
8018 FTargetUID
:= utils
.readWord(st
);
8019 // Âðåìÿ ïîòåðè öåëè
8020 FLastVisible
:= utils
.readLongWord(st
);
8021 // Êîëè÷åñòâî ôëàãîâ ÈÈ
8022 dw
:= utils
.readLongInt(st
);
8023 if (dw
< 0) or (dw
> 16384) then raise XStreamError
.Create('invalid number of bot AI flags');
8024 SetLength(FAIFlags
, dw
);
8026 for i
:= 0 to dw
-1 do
8028 FAIFlags
[i
].Name
:= utils
.readStr(st
, 20);
8029 FAIFlags
[i
].Value
:= utils
.readStr(st
, 20);
8031 // Íàñòðîéêè ñëîæíîñòè
8032 FDifficult
.load(st
);
8037 conRegVar('player_indicator', @gPlayerIndicator
, 'Draw indicator only for current player, also for teammates, or not at all', 'Draw indicator only for current player, also for teammates, or not at all');
8038 conRegVar('player_indicator_style', @gPlayerIndicatorStyle
, 'Visual appearance of indicator', 'Visual appearance of indicator');