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
,
58 AmmoLimits
: Array [0..1] of Array [A_BULLETS
..A_HIGH
] of Word =
59 ((200, 50, 50, 300, 100),
60 (400, 100, 100, 600, 200));
81 ANGLE_NONE
= Low(SmallInt);
83 CORPSE_STATE_REMOVEME
= 0;
84 CORPSE_STATE_NORMAL
= 1;
85 CORPSE_STATE_MESS
= 2;
87 PLAYER_RECT
: TRectWH
= (X
:15; Y
:12; Width
:34; Height
:52);
88 PLAYER_RECT_CX
= 15+(34 div 2);
89 PLAYER_RECT_CY
= 12+(52 div 2);
90 PLAYER_CORPSERECT
: TRectWH
= (X
:15; Y
:48; Width
:34; Height
:16);
93 PLAYER_HP_LIMIT
= 200;
95 PLAYER_AP_LIMIT
= 200;
99 PLAYER_BURN_TIME
= 110;
101 PLAYER1_DEF_COLOR
: TRGB
= (R
:64; G
:175; B
:48);
102 PLAYER2_DEF_COLOR
: TRGB
= (R
:96; G
:96; B
:96);
119 TPlayerStatArray
= Array of TPlayerStat
;
121 TPlayerSavedState
= record
129 Ammo
: Array [A_BULLETS
..A_HIGH
] of Word;
130 MaxAmmo
: Array [A_BULLETS
..A_HIGH
] of Word;
131 Weapon
: Array [WP_FIRST
..WP_LAST
] of Boolean;
132 Rulez
: Set of R_ITEM_BACKPACK
..R_BERSERK
;
141 TPlayer
= class{$IFDEF USE_MEMPOOL}(TPoolObject
){$ENDIF}
149 FDirection
: TDirection
;
157 FMonsterKills
: Integer;
163 FCanJetpack
: Boolean;
169 FNextWeapDelay
: Byte; // frames
170 FBFGFireCounter
: SmallInt;
171 FLastSpawnerUID
: Word;
175 FSpectatePlayer
: Integer;
176 FFirePainTime
: Integer;
179 FSavedStateNum
: Integer;
181 FModel
: TPlayerModel
;
182 FPunchAnim
: TAnimation
;
185 FActionForce
: Boolean;
186 FActionChanged
: Boolean;
188 FFireAngle
: SmallInt;
191 FShellTimer
: Integer;
193 FSawSound
: TPlayableSound
;
194 FSawSoundIdle
: TPlayableSound
;
195 FSawSoundHit
: TPlayableSound
;
196 FSawSoundSelect
: TPlayableSound
;
197 FFlameSoundOn
: TPlayableSound
;
198 FFlameSoundOff
: TPlayableSound
;
199 FFlameSoundWork
: TPlayableSound
;
200 FJetSoundOn
: TPlayableSound
;
201 FJetSoundOff
: TPlayableSound
;
202 FJetSoundFly
: TPlayableSound
;
206 FJustTeleported
: Boolean;
208 mEDamageType
: Integer;
211 function CollideLevel(XInc
, YInc
: Integer): Boolean;
212 function StayOnStep(XInc
, YInc
: Integer): Boolean;
213 function HeadInLiquid(XInc
, YInc
: Integer): Boolean;
214 function BodyInLiquid(XInc
, YInc
: Integer): Boolean;
215 function BodyInAcid(XInc
, YInc
: Integer): Boolean;
216 function FullInLift(XInc
, YInc
: Integer): Integer;
217 {procedure CollideItem();}
218 procedure FlySmoke(Times
: DWORD
= 1);
219 procedure OnFireFlame(Times
: DWORD
= 1);
220 function GetAmmoByWeapon(Weapon
: Byte): Word;
221 procedure SetAction(Action
: Byte; Force
: Boolean = False);
222 procedure OnDamage(Angle
: SmallInt); virtual;
223 function firediry(): Integer;
226 procedure Run(Direction
: TDirection
);
227 procedure NextWeapon();
228 procedure PrevWeapon();
235 function getNextWeaponIndex (): Byte; // return 255 for "no switch"
236 procedure resetWeaponQueue ();
237 function hasAmmoForWeapon (weapon
: Byte): Boolean;
239 procedure doDamage (v
: Integer);
241 function followCorpse(): Boolean;
244 FDamageBuffer
: Integer;
246 FAmmo
: Array [A_BULLETS
..A_HIGH
] of Word;
247 FMaxAmmo
: Array [A_BULLETS
..A_HIGH
] of Word;
248 FWeapon
: Array [WP_FIRST
..WP_LAST
] of Boolean;
249 FRulez
: Set of R_ITEM_BACKPACK
..R_BERSERK
;
251 FMegaRulez
: Array [MR_SUIT
..MR_MAX
] of DWORD
;
252 FReloading
: Array [WP_FIRST
..WP_LAST
] of Word;
253 FTime
: Array [T_RESPAWN
..T_FLAGCAP
] of DWORD
;
254 FKeys
: Array [KEY_LEFT
..KEY_CHAT
] of TKeyState
;
256 FPreferredTeam
: Byte;
259 FWantsInGame
: Boolean;
264 FActualModelName
: string;
271 FSpawnInvul
: Integer;
273 FWaitForFirstSpawn
: Boolean; // set to `true` in server, used to spawn a player on first full state request
275 // debug: viewport offset
276 viewPortX
, viewPortY
, viewPortW
, viewPortH
: Integer;
278 function isValidViewPort (): Boolean; inline;
280 constructor Create(); virtual;
281 destructor Destroy(); override;
282 procedure Respawn(Silent
: Boolean; Force
: Boolean = False); virtual;
283 function GetRespawnPoint(): Byte;
284 procedure PressKey(Key
: Byte; Time
: Word = 1);
285 procedure ReleaseKeys();
286 procedure SetModel(ModelName
: String);
287 procedure SetColor(Color
: TRGB
);
288 function GetColor(): TRGB
;
289 procedure SetWeapon(W
: Byte);
290 function IsKeyPressed(K
: Byte): Boolean;
291 function GetKeys(): Byte;
292 function PickItem(ItemType
: Byte; arespawn
: Boolean; var remove
: Boolean): Boolean; virtual;
293 function Collide(X
, Y
: Integer; Width
, Height
: Word): Boolean; overload
;
294 function Collide(Panel
: TPanel
): Boolean; overload
;
295 function Collide(X
, Y
: Integer): Boolean; overload
;
296 procedure SetDirection(Direction
: TDirection
);
297 procedure GetSecret();
298 function TeleportTo(X
, Y
: Integer; silent
: Boolean; dir
: Byte): Boolean;
300 procedure Push(vx
, vy
: Integer);
301 procedure ChangeModel(ModelName
: String);
302 procedure SwitchTeam
;
303 procedure ChangeTeam(Team
: Byte);
305 function GetFlag(Flag
: Byte): Boolean;
306 procedure SetFlag(Flag
: Byte);
307 function DropFlag(Silent
: Boolean = True): Boolean;
308 procedure AllRulez(Health
: Boolean);
309 procedure RestoreHealthArmor();
310 procedure FragCombo();
311 procedure GiveItem(ItemType
: Byte);
312 procedure Damage(value
: Word; SpawnerUID
: Word; vx
, vy
: Integer; t
: Byte); virtual;
313 function Heal(value
: Word; Soft
: Boolean): Boolean; virtual;
314 procedure MakeBloodVector(Count
: Word; VelX
, VelY
: Integer);
315 procedure MakeBloodSimple(Count
: Word);
316 procedure Kill(KillType
: Byte; SpawnerUID
: Word; t
: Byte);
317 procedure Reset(Force
: Boolean);
318 procedure Spectate(NoMove
: Boolean = False);
319 procedure SwitchNoClip
;
320 procedure SoftReset();
321 procedure Draw(); virtual;
322 procedure DrawPain();
323 procedure DrawPickup();
324 procedure DrawRulez();
326 procedure DrawIndicator(Color
: TRGB
);
327 procedure DrawBubble();
329 procedure PreUpdate();
330 procedure Update(); virtual;
331 procedure RememberState();
332 procedure RecallState();
333 procedure SaveState (st
: TStream
); virtual;
334 procedure LoadState (st
: TStream
); virtual;
335 procedure PauseSounds(Enable
: Boolean);
336 procedure NetFire(Wpn
: Byte; X
, Y
, AX
, AY
: Integer; WID
: Integer = -1);
337 procedure DoLerp(Level
: Integer = 2);
338 procedure SetLerp(XTo
, YTo
: Integer);
339 procedure QueueWeaponSwitch(Weapon
: Byte);
340 procedure RealizeCurrentWeapon();
344 procedure JetpackOff
;
345 procedure CatchFire(Attacker
: Word; Timeout
: Integer = PLAYER_BURN_TIME
);
347 //WARNING! this does nothing for now, but still call it!
348 procedure positionChanged (); //WARNING! call this after entity position was changed, or coldet will not work right!
350 procedure getMapBox (out x
, y
, w
, h
: Integer); inline;
351 procedure moveBy (dx
, dy
: Integer); inline;
354 property Vel
: TPoint2i read FObj
.Vel
;
355 property Obj
: TObj read FObj
;
357 property Name
: String read FName write FName
;
358 property Model
: TPlayerModel read FModel
;
359 property Health
: Integer read FHealth write FHealth
;
360 property Lives
: Byte read FLives write FLives
;
361 property Armor
: Integer read FArmor write FArmor
;
362 property Air
: Integer read FAir write FAir
;
363 property JetFuel
: Integer read FJetFuel write FJetFuel
;
364 property Frags
: Integer read FFrags write FFrags
;
365 property Death
: Integer read FDeath write FDeath
;
366 property Kills
: Integer read FKills write FKills
;
367 property CurrWeap
: Byte read FCurrWeap write FCurrWeap
;
368 property MonsterKills
: Integer read FMonsterKills write FMonsterKills
;
369 property Secrets
: Integer read FSecrets
;
370 property GodMode
: Boolean read FGodMode write FGodMode
;
371 property NoTarget
: Boolean read FNoTarget write FNoTarget
;
372 property NoReload
: Boolean read FNoReload write FNoReload
;
373 property alive
: Boolean read FAlive write FAlive
;
374 property Flag
: Byte read FFlag
;
375 property Team
: Byte read FTeam write FTeam
;
376 property Direction
: TDirection read FDirection
;
377 property GameX
: Integer read FObj
.X write FObj
.X
;
378 property GameY
: Integer read FObj
.Y write FObj
.Y
;
379 property GameVelX
: Integer read FObj
.Vel
.X write FObj
.Vel
.X
;
380 property GameVelY
: Integer read FObj
.Vel
.Y write FObj
.Vel
.Y
;
381 property GameAccelX
: Integer read FObj
.Accel
.X write FObj
.Accel
.X
;
382 property GameAccelY
: Integer read FObj
.Accel
.Y write FObj
.Accel
.Y
;
383 property IncCam
: Integer read FIncCam write FIncCam
;
384 property IncCamOld
: Integer read FIncCamOld write FIncCamOld
;
385 property UID
: Word read FUID write FUID
;
386 property JustTeleported
: Boolean read FJustTeleported write FJustTeleported
;
387 property NetTime
: LongWord read FNetTime write FNetTime
;
390 property eName
: String read FName write FName
;
391 property eHealth
: Integer read FHealth write FHealth
;
392 property eLives
: Byte read FLives write FLives
;
393 property eArmor
: Integer read FArmor write FArmor
;
394 property eAir
: Integer read FAir write FAir
;
395 property eJetFuel
: Integer read FJetFuel write FJetFuel
;
396 property eFrags
: Integer read FFrags write FFrags
;
397 property eDeath
: Integer read FDeath write FDeath
;
398 property eKills
: Integer read FKills write FKills
;
399 property eCurrWeap
: Byte read FCurrWeap write FCurrWeap
;
400 property eMonsterKills
: Integer read FMonsterKills write FMonsterKills
;
401 property eSecrets
: Integer read FSecrets write FSecrets
;
402 property eGodMode
: Boolean read FGodMode write FGodMode
;
403 property eNoTarget
: Boolean read FNoTarget write FNoTarget
;
404 property eNoReload
: Boolean read FNoReload write FNoReload
;
405 property eAlive
: Boolean read FAlive write FAlive
;
406 property eFlag
: Byte read FFlag
;
407 property eTeam
: Byte read FTeam write FTeam
;
408 property eDirection
: TDirection read FDirection
;
409 property eGameX
: Integer read FObj
.X write FObj
.X
;
410 property eGameY
: Integer read FObj
.Y write FObj
.Y
;
411 property eGameVelX
: Integer read FObj
.Vel
.X write FObj
.Vel
.X
;
412 property eGameVelY
: Integer read FObj
.Vel
.Y write FObj
.Vel
.Y
;
413 property eGameAccelX
: Integer read FObj
.Accel
.X write FObj
.Accel
.X
;
414 property eGameAccelY
: Integer read FObj
.Accel
.Y write FObj
.Accel
.Y
;
415 property eIncCam
: Integer read FIncCam write FIncCam
;
416 property eUID
: Word read FUID
;
417 property eJustTeleported
: Boolean read FJustTeleported
;
418 property eNetTime
: LongWord read FNetTime
;
420 // set this before assigning something to `eDamage`
421 property eDamageType
: Integer read mEDamageType write mEDamageType
;
422 property eDamage
: Integer write doDamage
;
433 WeaponPrior
: packed array [WP_FIRST
..WP_LAST
] of Byte;
434 CloseWeaponPrior
: packed array [WP_FIRST
..WP_LAST
] of Byte;
435 //SafeWeaponPrior: Array [WP_FIRST..WP_LAST] of Byte;
438 procedure save (st
: TStream
);
439 procedure load (st
: TStream
);
447 TBot
= class(TPlayer
)
449 FSelectedWeapon
: Byte;
452 FAIFlags
: Array of TAIFlag
;
453 FDifficult
: TDifficult
;
455 function GetRnd(a
: Byte): Boolean;
456 function GetInterval(a
: Byte; radius
: SmallInt): SmallInt;
457 function RunDirection(): TDirection
;
458 function FullInStep(XInc
, YInc
: Integer): Boolean;
459 //function NeedItem(Item: Byte): Byte;
460 procedure SelectWeapon(Dist
: Integer);
461 procedure SetAIFlag(aName
, fValue
: String20
);
462 function GetAIFlag(aName
: String20
): String20
;
463 procedure RemoveAIFlag(aName
: String20
);
464 function Healthy(): Byte;
465 procedure UpdateMove();
466 procedure UpdateCombat();
467 function KeyPressed(Key
: Word): Boolean;
468 procedure ReleaseKey(Key
: Byte);
469 function TargetOnScreen(TX
, TY
: Integer): Boolean;
470 procedure OnDamage(Angle
: SmallInt); override;
473 procedure Respawn(Silent
: Boolean; Force
: Boolean = False); override;
474 constructor Create(); override;
475 destructor Destroy(); override;
476 procedure Draw(); override;
477 function PickItem(ItemType
: Byte; force
: Boolean; var remove
: Boolean): Boolean; override;
478 function Heal(value
: Word; Soft
: Boolean): Boolean; override;
479 procedure Update(); override;
480 procedure SaveState (st
: TStream
); override;
481 procedure LoadState (st
: TStream
); override;
493 procedure getMapBox (out x
, y
, w
, h
: Integer); inline;
494 procedure moveBy (dx
, dy
: Integer); inline;
496 procedure positionChanged (); inline; //WARNING! call this after entity position was changed, or coldet will not work right!
510 procedure getMapBox (out x
, y
, w
, h
: Integer); inline;
511 procedure moveBy (dx
, dy
: Integer); inline;
513 procedure positionChanged (); inline; //WARNING! call this after entity position was changed, or coldet will not work right!
516 TCorpse
= class{$IFDEF USE_MEMPOOL}(TPoolObject
){$ENDIF}
525 FAnimation
: TAnimation
;
526 FAnimationMask
: TAnimation
;
529 constructor Create(X
, Y
: Integer; ModelName
: String; aMess
: Boolean);
530 destructor Destroy(); override;
531 procedure Damage(Value
: Word; vx
, vy
: Integer);
534 procedure SaveState (st
: TStream
);
535 procedure LoadState (st
: TStream
);
537 procedure getMapBox (out x
, y
, w
, h
: Integer); inline;
538 procedure moveBy (dx
, dy
: Integer); inline;
540 procedure positionChanged (); inline; //WARNING! call this after entity position was changed, or coldet will not work right!
542 function ObjPtr (): PObj
; inline;
544 property Obj
: TObj read FObj
; // copies object
545 property State
: Byte read FState
;
546 property Mess
: Boolean read FMess
;
549 TTeamStat
= Array [TEAM_RED
..TEAM_BLUE
] of
555 gPlayers
: Array of TPlayer
;
556 gCorpses
: Array of TCorpse
;
557 gGibs
: Array of TGib
;
558 gShells
: Array of TShell
;
559 gTeamStat
: TTeamStat
;
560 gFly
: Boolean = False;
561 gAimLine
: Boolean = False;
562 gChatBubble
: Integer = 0;
563 gPlayerIndicator
: Integer = 1;
564 gPlayerIndicatorStyle
: Integer = 0;
566 gSpectLatchPID1
: Word = 0;
567 gSpectLatchPID2
: Word = 0;
568 MAX_RUNVEL
: Integer = 8;
569 VEL_JUMP
: Integer = 10;
570 SHELL_TIMEOUT
: Cardinal = 60000;
572 function Lerp(X
, Y
, Factor
: Integer): Integer;
574 procedure g_Gibs_SetMax(Count
: Word);
575 function g_Gibs_GetMax(): Word;
576 procedure g_Corpses_SetMax(Count
: Word);
577 function g_Corpses_GetMax(): Word;
578 procedure g_Shells_SetMax(Count
: Word);
579 function g_Shells_GetMax(): Word;
581 procedure g_Player_Init();
582 procedure g_Player_Free();
583 function g_Player_Create(ModelName
: String; Color
: TRGB
; Team
: Byte; Bot
: Boolean): Word;
584 function g_Player_CreateFromState (st
: TStream
): Word;
585 procedure g_Player_Remove(UID
: Word);
586 procedure g_Player_ResetTeams();
587 procedure g_Player_PreUpdate();
588 procedure g_Player_UpdateAll();
589 procedure g_Player_DrawAll();
590 procedure g_Player_DrawDebug(p
: TPlayer
);
591 procedure g_Player_DrawHealth();
592 procedure g_Player_RememberAll();
593 procedure g_Player_ResetAll(Force
, Silent
: Boolean);
594 function g_Player_Get(UID
: Word): TPlayer
;
595 function g_Player_GetCount(): Byte;
596 function g_Player_GetStats(): TPlayerStatArray
;
597 function g_Player_ValidName(Name
: String): Boolean;
598 procedure g_Player_CreateCorpse(Player
: TPlayer
);
599 procedure g_Player_CreateGibs(fX
, fY
: Integer; ModelName
: String; fColor
: TRGB
);
600 procedure g_Player_CreateShell(fX
, fY
, dX
, dY
: Integer; T
: Byte);
601 procedure g_Player_UpdatePhysicalObjects();
602 procedure g_Player_DrawCorpses();
603 procedure g_Player_DrawShells();
604 procedure g_Player_RemoveAllCorpses();
605 procedure g_Player_Corpses_SaveState (st
: TStream
);
606 procedure g_Player_Corpses_LoadState (st
: TStream
);
607 procedure g_Player_ResetReady();
608 procedure g_Bot_Add(Team
, Difficult
: Byte; Handicap
: Integer = 100);
609 procedure g_Bot_AddList(Team
: Byte; lname
: ShortString; num
: Integer = -1; Handicap
: Integer = 100);
610 procedure g_Bot_MixNames();
611 procedure g_Bot_RemoveAll();
616 {$INCLUDE ../nogl/noGLuses.inc}
617 {$IFDEF ENABLE_HOLMES}
620 e_log
, g_map
, g_items
, g_console
, g_gfx
, Math
,
621 g_options
, g_triggers
, g_menu
, g_game
, g_grid
, e_res
,
622 wadreader
, g_main
, g_monsters
, CONFIG
, g_language
,
623 g_net
, g_netmsg
, g_window
,
626 const PLR_SAVE_VERSION
= 0;
636 diag_precision
: Byte;
640 w_prior1
: Array [WP_FIRST
..WP_LAST
] of Byte;
641 w_prior2
: Array [WP_FIRST
..WP_LAST
] of Byte;
642 w_prior3
: Array [WP_FIRST
..WP_LAST
] of Byte;
646 TIME_RESPAWN1
= 1500;
647 TIME_RESPAWN2
= 2000;
648 TIME_RESPAWN3
= 3000;
651 JET_MAX
= 540; // ~30 sec
652 PLAYER_SUIT_TIME
= 30000;
653 PLAYER_INVUL_TIME
= 30000;
654 PLAYER_INVIS_TIME
= 35000;
655 FRAG_COMBO_TIME
= 3000;
659 ANGLE_RIGHTDOWN
= -35;
661 ANGLE_LEFTDOWN
= -145;
662 PLAYER_HEADRECT
: TRectWH
= (X
:24; Y
:12; Width
:20; Height
:12);
663 WEAPONPOINT
: Array [TDirection
] of TDFPoint
= ((X
:16; Y
:32), (X
:47; Y
:32));
666 BOT_UNSAFEDIST
= 128;
667 TEAMCOLOR
: Array [TEAM_RED
..TEAM_BLUE
] of TRGB
= ((R
:255; G
:0; B
:0),
669 DIFFICULT_EASY
: TDifficult
= (DiagFire
: 32; InvisFire
: 32; DiagPrecision
: 32;
670 FlyPrecision
: 32; Cover
: 32; CloseJump
: 32;
671 WeaponPrior
:(0,0,0,0,0,0,0,0,0,0,0); CloseWeaponPrior
:(0,0,0,0,0,0,0,0,0,0,0));
672 DIFFICULT_MEDIUM
: TDifficult
= (DiagFire
: 127; InvisFire
: 127; DiagPrecision
: 127;
673 FlyPrecision
: 127; Cover
: 127; CloseJump
: 127;
674 WeaponPrior
:(0,0,0,0,0,0,0,0,0,0,0); CloseWeaponPrior
:(0,0,0,0,0,0,0,0,0,0,0));
675 DIFFICULT_HARD
: TDifficult
= (DiagFire
: 255; InvisFire
: 255; DiagPrecision
: 255;
676 FlyPrecision
: 255; Cover
: 255; CloseJump
: 255;
677 WeaponPrior
:(0,0,0,0,0,0,0,0,0,0,0); CloseWeaponPrior
:(0,0,0,0,0,0,0,0,0,0,0));
678 WEAPON_PRIOR1
: Array [WP_FIRST
..WP_LAST
] of Byte =
679 (WEAPON_FLAMETHROWER
, WEAPON_SUPERPULEMET
,
680 WEAPON_SHOTGUN2
, WEAPON_SHOTGUN1
,
681 WEAPON_CHAINGUN
, WEAPON_PLASMA
, WEAPON_ROCKETLAUNCHER
,
682 WEAPON_BFG
, WEAPON_PISTOL
, WEAPON_SAW
, WEAPON_KASTET
);
683 WEAPON_PRIOR2
: Array [WP_FIRST
..WP_LAST
] of Byte =
684 (WEAPON_FLAMETHROWER
, WEAPON_SUPERPULEMET
,
685 WEAPON_BFG
, WEAPON_ROCKETLAUNCHER
,
686 WEAPON_SHOTGUN2
, WEAPON_PLASMA
, WEAPON_SHOTGUN1
,
687 WEAPON_CHAINGUN
, WEAPON_PISTOL
, WEAPON_SAW
, WEAPON_KASTET
);
688 //WEAPON_PRIOR3: Array [WP_FIRST..WP_LAST] of Byte =
689 // (WEAPON_FLAMETHROWER, WEAPON_SUPERPULEMET,
690 // WEAPON_BFG, WEAPON_PLASMA, WEAPON_SHOTGUN2,
691 // WEAPON_CHAINGUN, WEAPON_SHOTGUN1, WEAPON_SAW,
692 // WEAPON_ROCKETLAUNCHER, WEAPON_PISTOL, WEAPON_KASTET);
693 WEAPON_RELOAD
: Array [WP_FIRST
..WP_LAST
] of Byte =
694 (5, 2, 6, 18, 36, 2, 12, 2, 14, 2, 2);
696 PLAYER_SIGNATURE
= $52594C50; // 'PLYR'
697 CORPSE_SIGNATURE
= $50524F43; // 'CORP'
699 BOTNAMES_FILENAME
= 'botnames.txt';
700 BOTLIST_FILENAME
= 'botlist.txt';
704 MaxCorpses
: Word = 20;
705 MaxShells
: Word = 300;
706 CurrentGib
: Integer = 0;
707 CurrentShell
: Integer = 0;
708 BotNames
: Array of String;
709 BotList
: Array of TBotProfile
;
710 SavedStates
: Array of TPlayerSavedState
;
713 function Lerp(X
, Y
, Factor
: Integer): Integer;
715 Result
:= X
+ ((Y
- X
) div Factor
);
718 function SameTeam(UID1
, UID2
: Word): Boolean;
722 if (UID1
> UID_MAX_PLAYER
) or (UID1
<= UID_MAX_GAME
) or
723 (UID2
> UID_MAX_PLAYER
) or (UID2
<= UID_MAX_GAME
) then Exit
;
725 if (g_Player_Get(UID1
) = nil) or (g_Player_Get(UID2
) = nil) then Exit
;
727 if ((g_Player_Get(UID1
).Team
= TEAM_NONE
) or
728 (g_Player_Get(UID2
).Team
= TEAM_NONE
)) then Exit
;
730 Result
:= g_Player_Get(UID1
).FTeam
= g_Player_Get(UID2
).FTeam
;
733 procedure g_Gibs_SetMax(Count
: Word);
736 SetLength(gGibs
, Count
);
738 if CurrentGib
>= Count
then
742 function g_Gibs_GetMax(): Word;
747 procedure g_Shells_SetMax(Count
: Word);
750 SetLength(gShells
, Count
);
752 if CurrentShell
>= Count
then
756 function g_Shells_GetMax(): Word;
762 procedure g_Corpses_SetMax(Count
: Word);
765 SetLength(gCorpses
, Count
);
768 function g_Corpses_GetMax(): Word;
770 Result
:= MaxCorpses
;
773 function g_Player_Create(ModelName
: String; Color
: TRGB
; Team
: Byte; Bot
: Boolean): Word;
783 // Åñòü ëè ìåñòî â gPlayers:
784 if gPlayers
<> nil then
785 for a
:= 0 to High(gPlayers
) do
786 if gPlayers
[a
] = nil then
792 // Íåò ìåñòà - ðàñøèðÿåì gPlayers:
795 SetLength(gPlayers
, Length(gPlayers
)+1);
799 // Ñîçäàåì îáúåêò èãðîêà:
801 gPlayers
[a
] := TBot
.Create()
803 gPlayers
[a
] := TPlayer
.Create();
806 gPlayers
[a
].FActualModelName
:= ModelName
;
807 gPlayers
[a
].SetModel(ModelName
);
809 // Íåò ìîäåëè - ñîçäàíèå íå âîçìîæíî:
810 if gPlayers
[a
].FModel
= nil then
814 g_FatalError(Format(_lc
[I_GAME_ERROR_MODEL
], [ModelName
]));
818 if not (Team
in [TEAM_RED
, TEAM_BLUE
]) then
819 if Random(2) = 0 then
823 gPlayers
[a
].FPreferredTeam
:= Team
;
825 case gGameSettings
.GameMode
of
826 GM_DM
: gPlayers
[a
].FTeam
:= TEAM_NONE
;
828 GM_CTF
: gPlayers
[a
].FTeam
:= gPlayers
[a
].FPreferredTeam
;
830 GM_COOP
: gPlayers
[a
].FTeam
:= TEAM_COOP
;
833 // Åñëè êîìàíäíàÿ èãðà - êðàñèì ìîäåëü â öâåò êîìàíäû:
834 gPlayers
[a
].FColor
:= Color
;
835 if gPlayers
[a
].FTeam
in [TEAM_RED
, TEAM_BLUE
] then
836 gPlayers
[a
].FModel
.Color
:= TEAMCOLOR
[gPlayers
[a
].FTeam
]
838 gPlayers
[a
].FModel
.Color
:= Color
;
840 gPlayers
[a
].FUID
:= g_CreateUID(UID_PLAYER
);
841 gPlayers
[a
].FAlive
:= False;
843 Result
:= gPlayers
[a
].FUID
;
846 function g_Player_CreateFromState (st
: TStream
): Word;
853 if (st
= nil) then exit
; //???
856 if not utils
.checkSign(st
, 'PLYR') then raise XStreamError
.Create('invalid player signature');
857 if (utils
.readByte(st
) <> PLR_SAVE_VERSION
) then raise XStreamError
.Create('invalid player version');
860 Bot
:= utils
.readBool(st
);
865 // Åñòü ëè ìåñòî â gPlayers:
866 for a
:= 0 to High(gPlayers
) do if (gPlayers
[a
] = nil) then begin ok
:= true; break
; end;
868 // Íåò ìåñòà - ðàñøèðÿåì gPlayers
871 SetLength(gPlayers
, Length(gPlayers
)+1);
875 // Ñîçäàåì îáúåêò èãðîêà
877 gPlayers
[a
] := TBot
.Create()
879 gPlayers
[a
] := TPlayer
.Create();
880 gPlayers
[a
].FIamBot
:= Bot
;
881 gPlayers
[a
].FPhysics
:= True;
884 gPlayers
[a
].FUID
:= utils
.readWord(st
);
886 gPlayers
[a
].FName
:= utils
.readStr(st
);
888 gPlayers
[a
].FTeam
:= utils
.readByte(st
);
889 gPlayers
[a
].FPreferredTeam
:= gPlayers
[a
].FTeam
;
891 gPlayers
[a
].FAlive
:= utils
.readBool(st
);
892 // Èçðàñõîäîâàë ëè âñå æèçíè
893 gPlayers
[a
].FNoRespawn
:= utils
.readBool(st
);
895 b
:= utils
.readByte(st
);
896 if b
= 1 then gPlayers
[a
].FDirection
:= TDirection
.D_LEFT
else gPlayers
[a
].FDirection
:= TDirection
.D_RIGHT
; // b = 2
898 gPlayers
[a
].FHealth
:= utils
.readLongInt(st
);
900 gPlayers
[a
].FHandicap
:= utils
.readLongInt(st
);
902 gPlayers
[a
].FLives
:= utils
.readByte(st
);
904 gPlayers
[a
].FArmor
:= utils
.readLongInt(st
);
906 gPlayers
[a
].FAir
:= utils
.readLongInt(st
);
908 gPlayers
[a
].FJetFuel
:= utils
.readLongInt(st
);
910 gPlayers
[a
].FPain
:= utils
.readLongInt(st
);
912 gPlayers
[a
].FKills
:= utils
.readLongInt(st
);
914 gPlayers
[a
].FMonsterKills
:= utils
.readLongInt(st
);
916 gPlayers
[a
].FFrags
:= utils
.readLongInt(st
);
918 gPlayers
[a
].FFragCombo
:= utils
.readByte(st
);
919 // Âðåìÿ ïîñëåäíåãî ôðàãà
920 gPlayers
[a
].FLastFrag
:= utils
.readLongWord(st
);
922 gPlayers
[a
].FDeath
:= utils
.readLongInt(st
);
924 gPlayers
[a
].FFlag
:= utils
.readByte(st
);
926 gPlayers
[a
].FSecrets
:= utils
.readLongInt(st
);
928 gPlayers
[a
].FCurrWeap
:= utils
.readByte(st
);
929 // Ñëåäóþùåå æåëàåìîå îðóæèå
930 gPlayers
[a
].FNextWeap
:= utils
.readWord(st
);
932 gPlayers
[a
].FNextWeapDelay
:= utils
.readByte(st
);
934 gPlayers
[a
].FBFGFireCounter
:= utils
.readSmallInt(st
);
936 gPlayers
[a
].FDamageBuffer
:= utils
.readLongInt(st
);
937 // Ïîñëåäíèé óäàðèâøèé
938 gPlayers
[a
].FLastSpawnerUID
:= utils
.readWord(st
);
939 // Òèï ïîñëåäíåãî ïîëó÷åííîãî óðîíà
940 gPlayers
[a
].FLastHit
:= utils
.readByte(st
);
942 Obj_LoadState(@gPlayers
[a
].FObj
, st
);
943 // Òåêóùåå êîëè÷åñòâî ïàòðîíîâ
944 for i
:= A_BULLETS
to A_HIGH
do gPlayers
[a
].FAmmo
[i
] := utils
.readWord(st
);
945 // Ìàêñèìàëüíîå êîëè÷åñòâî ïàòðîíîâ
946 for i
:= A_BULLETS
to A_HIGH
do gPlayers
[a
].FMaxAmmo
[i
] := utils
.readWord(st
);
948 for i
:= WP_FIRST
to WP_LAST
do gPlayers
[a
].FWeapon
[i
] := utils
.readBool(st
);
949 // Âðåìÿ ïåðåçàðÿäêè îðóæèÿ
950 for i
:= WP_FIRST
to WP_LAST
do gPlayers
[a
].FReloading
[i
] := utils
.readWord(st
);
952 if utils
.readBool(st
) then Include(gPlayers
[a
].FRulez
, R_ITEM_BACKPACK
);
953 // Íàëè÷èå êðàñíîãî êëþ÷à
954 if utils
.readBool(st
) then Include(gPlayers
[a
].FRulez
, R_KEY_RED
);
955 // Íàëè÷èå çåëåíîãî êëþ÷à
956 if utils
.readBool(st
) then Include(gPlayers
[a
].FRulez
, R_KEY_GREEN
);
957 // Íàëè÷èå ñèíåãî êëþ÷à
958 if utils
.readBool(st
) then Include(gPlayers
[a
].FRulez
, R_KEY_BLUE
);
960 if utils
.readBool(st
) then Include(gPlayers
[a
].FRulez
, R_BERSERK
);
961 // Âðåìÿ äåéñòâèÿ ñïåöèàëüíûõ ïðåäìåòîâ
962 for i
:= MR_SUIT
to MR_MAX
do gPlayers
[a
].FMegaRulez
[i
] := utils
.readLongWord(st
);
963 // Âðåìÿ äî ïîâòîðíîãî ðåñïàóíà, ñìåíû îðóæèÿ, èñîëüçîâàíèÿ, çàõâàòà ôëàãà
964 for i
:= T_RESPAWN
to T_FLAGCAP
do gPlayers
[a
].FTime
[i
] := utils
.readLongWord(st
);
967 gPlayers
[a
].FActualModelName
:= utils
.readStr(st
);
969 gPlayers
[a
].FColor
.R
:= utils
.readByte(st
);
970 gPlayers
[a
].FColor
.G
:= utils
.readByte(st
);
971 gPlayers
[a
].FColor
.B
:= utils
.readByte(st
);
972 // Îáíîâëÿåì ìîäåëü èãðîêà
973 gPlayers
[a
].SetModel(gPlayers
[a
].FActualModelName
);
975 // Íåò ìîäåëè - ñîçäàíèå íåâîçìîæíî
976 if (gPlayers
[a
].FModel
= nil) then
980 g_FatalError(Format(_lc
[I_GAME_ERROR_MODEL
], [gPlayers
[a
].FActualModelName
]));
984 // Åñëè êîìàíäíàÿ èãðà - êðàñèì ìîäåëü â öâåò êîìàíäû
985 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
986 gPlayers
[a
].FModel
.Color
:= TEAMCOLOR
[gPlayers
[a
].FTeam
]
988 gPlayers
[a
].FModel
.Color
:= gPlayers
[a
].FColor
;
990 result
:= gPlayers
[a
].FUID
;
994 procedure g_Player_ResetTeams();
998 if g_Game_IsClient
then
1000 if gPlayers
= nil then
1002 for a
:= Low(gPlayers
) to High(gPlayers
) do
1003 if gPlayers
[a
] <> nil then
1004 case gGameSettings
.GameMode
of
1006 gPlayers
[a
].ChangeTeam(TEAM_NONE
);
1008 if not (gPlayers
[a
].Team
in [TEAM_RED
, TEAM_BLUE
]) then
1009 if gPlayers
[a
].FPreferredTeam
in [TEAM_RED
, TEAM_BLUE
] then
1010 gPlayers
[a
].ChangeTeam(gPlayers
[a
].FPreferredTeam
)
1013 gPlayers
[a
].ChangeTeam(TEAM_RED
)
1015 gPlayers
[a
].ChangeTeam(TEAM_BLUE
);
1018 gPlayers
[a
].ChangeTeam(TEAM_COOP
);
1022 procedure g_Bot_Add(Team
, Difficult
: Byte; Handicap
: Integer = 100);
1025 _name
, _model
: String;
1028 if not g_Game_IsServer
then Exit
;
1030 // Ñïèñîê íàçâàíèé ìîäåëåé:
1031 m
:= g_PlayerModel_GetNames();
1036 if (gGameSettings
.GameType
= GT_SINGLE
) or (gGameSettings
.GameMode
= GM_COOP
) then
1037 Team
:= TEAM_COOP
// COOP
1039 if gGameSettings
.GameMode
= GM_DM
then
1040 Team
:= TEAM_NONE
// DM
1042 if Team
= TEAM_NONE
then // CTF / TDM
1044 // Àâòîáàëàíñ êîìàíä:
1048 for a
:= 0 to High(gPlayers
) do
1049 if gPlayers
[a
] <> nil then
1051 if gPlayers
[a
].Team
= TEAM_RED
then
1054 if gPlayers
[a
].Team
= TEAM_BLUE
then
1064 if Random(2) = 0 then
1070 // Âûáèðàåì áîòó èìÿ:
1072 if BotNames
<> nil then
1073 for a
:= 0 to High(BotNames
) do
1074 if g_Player_ValidName(BotNames
[a
]) then
1076 _name
:= BotNames
[a
];
1080 // Âûáèðàåì ñëó÷àéíóþ ìîäåëü:
1081 _model
:= m
[Random(Length(m
))];
1084 with g_Player_Get(g_Player_Create(_model
,
1085 _RGB(Min(Random(9)*32, 255),
1086 Min(Random(9)*32, 255),
1087 Min(Random(9)*32, 255)),
1088 Team
, True)) as TBot
do
1090 // Åñëè èìåíè íåò, äåëàåì åãî èç UID áîòà
1092 Name
:= Format('DFBOT%.5d', [UID
])
1097 1: FDifficult
:= DIFFICULT_EASY
;
1098 2: FDifficult
:= DIFFICULT_MEDIUM
;
1099 else FDifficult
:= DIFFICULT_HARD
;
1102 for a
:= WP_FIRST
to WP_LAST
do
1104 FDifficult
.WeaponPrior
[a
] := WEAPON_PRIOR1
[a
];
1105 FDifficult
.CloseWeaponPrior
[a
] := WEAPON_PRIOR2
[a
];
1106 //FDifficult.SafeWeaponPrior[a] := WEAPON_PRIOR3[a];
1109 FHandicap
:= Handicap
;
1111 g_Console_Add(Format(_lc
[I_PLAYER_JOIN
], [Name
]), True);
1113 if g_Game_IsNet
then MH_SEND_PlayerCreate(UID
);
1114 if g_Game_IsServer
and (gGameSettings
.MaxLives
> 0) then
1119 procedure g_Bot_AddList(Team
: Byte; lName
: ShortString; num
: Integer = -1; Handicap
: Integer = 100);
1122 _name
, _model
: String;
1125 if not g_Game_IsServer
then Exit
;
1127 // Ñïèñîê íàçâàíèé ìîäåëåé:
1128 m
:= g_PlayerModel_GetNames();
1133 if (gGameSettings
.GameType
= GT_SINGLE
) or (gGameSettings
.GameMode
= GM_COOP
) then
1134 Team
:= TEAM_COOP
// COOP
1136 if gGameSettings
.GameMode
= GM_DM
then
1137 Team
:= TEAM_NONE
// DM
1139 if Team
= TEAM_NONE
then
1140 Team
:= BotList
[num
].team
; // CTF / TDM
1142 // Âûáèðàåì íàñòðîéêè áîòà èç ñïèñêà ïî íîìåðó èëè èìåíè:
1143 lName
:= AnsiLowerCase(lName
);
1144 if (num
< 0) or (num
> Length(BotList
)-1) then
1146 if (num
= -1) and (lName
<> '') and (BotList
<> nil) then
1147 for a
:= 0 to High(BotList
) do
1148 if AnsiLowerCase(BotList
[a
].name
) = lName
then
1157 _name
:= BotList
[num
].name
;
1158 // Çàíÿòî - âûáèðàåì ñëó÷àéíîå:
1159 if not g_Player_ValidName(_name
) then
1161 _name
:= Format('DFBOT%.2d', [Random(100)]);
1162 until g_Player_ValidName(_name
);
1165 _model
:= BotList
[num
].model
;
1166 // Íåò òàêîé - âûáèðàåì ñëó÷àéíóþ:
1167 if not InSArray(_model
, m
) then
1168 _model
:= m
[Random(Length(m
))];
1171 with g_Player_Get(g_Player_Create(_model
, BotList
[num
].color
, Team
, True)) as TBot
do
1175 FDifficult
.DiagFire
:= BotList
[num
].diag_fire
;
1176 FDifficult
.InvisFire
:= BotList
[num
].invis_fire
;
1177 FDifficult
.DiagPrecision
:= BotList
[num
].diag_precision
;
1178 FDifficult
.FlyPrecision
:= BotList
[num
].fly_precision
;
1179 FDifficult
.Cover
:= BotList
[num
].cover
;
1180 FDifficult
.CloseJump
:= BotList
[num
].close_jump
;
1182 FHandicap
:= Handicap
;
1184 for a
:= WP_FIRST
to WP_LAST
do
1186 FDifficult
.WeaponPrior
[a
] := BotList
[num
].w_prior1
[a
];
1187 FDifficult
.CloseWeaponPrior
[a
] := BotList
[num
].w_prior2
[a
];
1188 //FDifficult.SafeWeaponPrior[a] := BotList[num].w_prior3[a];
1191 g_Console_Add(Format(_lc
[I_PLAYER_JOIN
], [Name
]), True);
1193 if g_Game_IsNet
then MH_SEND_PlayerCreate(UID
);
1197 procedure g_Bot_RemoveAll();
1201 if not g_Game_IsServer
then Exit
;
1202 if gPlayers
= nil then Exit
;
1204 for a
:= 0 to High(gPlayers
) do
1205 if gPlayers
[a
] <> nil then
1206 if gPlayers
[a
] is TBot
then
1208 gPlayers
[a
].Lives
:= 0;
1209 gPlayers
[a
].Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
1210 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [gPlayers
[a
].Name
]), True);
1211 g_Player_Remove(gPlayers
[a
].FUID
);
1217 procedure g_Bot_MixNames();
1222 if BotNames
<> nil then
1223 for a
:= 0 to High(BotNames
) do
1225 b
:= Random(Length(BotNames
));
1227 Botnames
[a
] := BotNames
[b
];
1232 procedure g_Player_Remove(UID
: Word);
1236 if gPlayers
= nil then Exit
;
1238 if g_Game_IsServer
and g_Game_IsNet
then
1239 MH_SEND_PlayerDelete(UID
);
1241 for i
:= 0 to High(gPlayers
) do
1242 if gPlayers
[i
] <> nil then
1243 if gPlayers
[i
].FUID
= UID
then
1245 if gPlayers
[i
] is TPlayer
then
1246 TPlayer(gPlayers
[i
]).Free()
1248 TBot(gPlayers
[i
]).Free();
1254 procedure g_Player_Init();
1265 path
:= BOTNAMES_FILENAME
;
1266 if e_FindResource(DataDirs
, path
) = false then
1269 // ×èòàåì âîçìîæíûå èìåíà áîòîâ èç ôàéëà:
1270 AssignFile(F
, path
);
1281 SetLength(BotNames
, Length(BotNames
)+1);
1282 BotNames
[High(BotNames
)] := s
;
1290 // ×èòàåì ôàéë ñ ïàðàìåòðàìè áîòîâ:
1291 config
:= TConfig
.CreateFile(path
);
1295 while config
.SectionExists(IntToStr(a
)) do
1297 SetLength(BotList
, Length(BotList
)+1);
1299 with BotList
[High(BotList
)] do
1302 name
:= config
.ReadStr(IntToStr(a
), 'name', '');
1304 model
:= config
.ReadStr(IntToStr(a
), 'model', '');
1306 if config
.ReadStr(IntToStr(a
), 'team', 'red') = 'red' then
1311 sa
:= parse(config
.ReadStr(IntToStr(a
), 'color', ''));
1312 color
.R
:= StrToIntDef(sa
[0], 0);
1313 color
.G
:= StrToIntDef(sa
[1], 0);
1314 color
.B
:= StrToIntDef(sa
[2], 0);
1315 // Âåðîÿòíîñòü ñòðåëüáû ïîä óãëîì:
1316 diag_fire
:= config
.ReadInt(IntToStr(a
), 'diag_fire', 0);
1317 // Âåðîÿòíîñòü îòâåòíîãî îãíÿ ïî íåâèäèìîìó ñîïåðíèêó:
1318 invis_fire
:= config
.ReadInt(IntToStr(a
), 'invis_fire', 0);
1319 // Òî÷íîñòü ñòðåëüáû ïîä óãëîì:
1320 diag_precision
:= config
.ReadInt(IntToStr(a
), 'diag_precision', 0);
1321 // Òî÷íîñòü ñòðåëüáû â ïîëåòå:
1322 fly_precision
:= config
.ReadInt(IntToStr(a
), 'fly_precision', 0);
1323 // Òî÷íîñòü óêëîíåíèÿ îò ñíàðÿäîâ:
1324 cover
:= config
.ReadInt(IntToStr(a
), 'cover', 0);
1325 // Âåðîÿòíîñòü ïðûæêà ïðè ïðèáëèæåíèè ñîïåðíèêà:
1326 close_jump
:= config
.ReadInt(IntToStr(a
), 'close_jump', 0);
1327 // Ïðèîðèòåòû îðóæèÿ äëÿ äàëüíåãî áîÿ:
1328 sa
:= parse(config
.ReadStr(IntToStr(a
), 'w_prior1', ''));
1329 if Length(sa
) = 10 then
1331 w_prior1
[b
] := EnsureRange(StrToInt(sa
[b
]), 0, 9);
1332 // Ïðèîðèòåòû îðóæèÿ äëÿ áëèæíåãî áîÿ:
1333 sa
:= parse(config
.ReadStr(IntToStr(a
), 'w_prior2', ''));
1334 if Length(sa
) = 10 then
1336 w_prior2
[b
] := EnsureRange(StrToInt(sa
[b
]), 0, 9);
1338 {sa := parse(config.ReadStr(IntToStr(a), 'w_prior3', ''));
1339 if Length(sa) = 10 then
1341 w_prior3[b] := EnsureRange(StrToInt(sa[b]), 0, 9);}
1348 SetLength(SavedStates
, 0);
1351 procedure g_Player_Free();
1355 if gPlayers
<> nil then
1357 for i
:= 0 to High(gPlayers
) do
1358 if gPlayers
[i
] <> nil then
1360 if gPlayers
[i
] is TPlayer
then
1361 TPlayer(gPlayers
[i
]).Free()
1363 TBot(gPlayers
[i
]).Free();
1372 SetLength(SavedStates
, 0);
1375 procedure g_Player_PreUpdate();
1379 if gPlayers
= nil then Exit
;
1380 for i
:= 0 to High(gPlayers
) do
1381 if gPlayers
[i
] <> nil then
1382 gPlayers
[i
].PreUpdate();
1385 procedure g_Player_UpdateAll();
1389 if gPlayers
= nil then Exit
;
1391 //e_WriteLog('***g_Player_UpdateAll: ENTER', MSG_WARNING);
1392 for i
:= 0 to High(gPlayers
) do
1394 if gPlayers
[i
] <> nil then
1396 if gPlayers
[i
] is TPlayer
then
1398 gPlayers
[i
].Update();
1399 gPlayers
[i
].RealizeCurrentWeapon(); // WARNING! DO NOT MOVE THIS INTO `Update()`!
1403 // bot updates weapons in `UpdateCombat()`
1404 TBot(gPlayers
[i
]).Update();
1408 //e_WriteLog('***g_Player_UpdateAll: EXIT', MSG_WARNING);
1411 procedure g_Player_DrawAll();
1415 if gPlayers
= nil then Exit
;
1417 for i
:= 0 to High(gPlayers
) do
1418 if gPlayers
[i
] <> nil then
1419 if gPlayers
[i
] is TPlayer
then gPlayers
[i
].Draw()
1420 else TBot(gPlayers
[i
]).Draw();
1423 procedure g_Player_DrawDebug(p
: TPlayer
);
1427 if p
= nil then Exit
;
1428 if (@p
.FObj
) = nil then Exit
;
1430 e_TextureFontGetSize(gStdFont
, fW
, fH
);
1432 e_TextureFontPrint(0, 0 , 'Pos X: ' + IntToStr(p
.FObj
.X
), gStdFont
);
1433 e_TextureFontPrint(0, fH
, 'Pos Y: ' + IntToStr(p
.FObj
.Y
), gStdFont
);
1434 e_TextureFontPrint(0, fH
* 2, 'Vel X: ' + IntToStr(p
.FObj
.Vel
.X
), gStdFont
);
1435 e_TextureFontPrint(0, fH
* 3, 'Vel Y: ' + IntToStr(p
.FObj
.Vel
.Y
), gStdFont
);
1436 e_TextureFontPrint(0, fH
* 4, 'Acc X: ' + IntToStr(p
.FObj
.Accel
.X
), gStdFont
);
1437 e_TextureFontPrint(0, fH
* 5, 'Acc Y: ' + IntToStr(p
.FObj
.Accel
.Y
), gStdFont
);
1440 procedure g_Player_DrawHealth();
1445 if gPlayers
= nil then Exit
;
1446 e_TextureFontGetSize(gStdFont
, fW
, fH
);
1448 for i
:= 0 to High(gPlayers
) do
1449 if gPlayers
[i
] <> nil then
1451 e_TextureFontPrint(gPlayers
[i
].FObj
.X
+ gPlayers
[i
].FObj
.Rect
.X
,
1452 gPlayers
[i
].FObj
.Y
+ gPlayers
[i
].FObj
.Rect
.Y
+ gPlayers
[i
].FObj
.Rect
.Height
- fH
* 2,
1453 IntToStr(gPlayers
[i
].FHealth
), gStdFont
);
1454 e_TextureFontPrint(gPlayers
[i
].FObj
.X
+ gPlayers
[i
].FObj
.Rect
.X
,
1455 gPlayers
[i
].FObj
.Y
+ gPlayers
[i
].FObj
.Rect
.Y
+ gPlayers
[i
].FObj
.Rect
.Height
- fH
,
1456 IntToStr(gPlayers
[i
].FArmor
), gStdFont
);
1460 function g_Player_Get(UID
: Word): TPlayer
;
1466 if gPlayers
= nil then
1469 for a
:= 0 to High(gPlayers
) do
1470 if gPlayers
[a
] <> nil then
1471 if gPlayers
[a
].FUID
= UID
then
1473 Result
:= gPlayers
[a
];
1478 function g_Player_GetCount(): Byte;
1484 if gPlayers
= nil then
1487 for a
:= 0 to High(gPlayers
) do
1488 if gPlayers
[a
] <> nil then
1489 Result
:= Result
+ 1;
1492 function g_Player_GetStats(): TPlayerStatArray
;
1498 if gPlayers
= nil then Exit
;
1500 for a
:= 0 to High(gPlayers
) do
1501 if gPlayers
[a
] <> nil then
1503 SetLength(Result
, Length(Result
)+1);
1504 with Result
[High(Result
)] do
1507 Ping
:= gPlayers
[a
].FPing
;
1508 Loss
:= gPlayers
[a
].FLoss
;
1509 Name
:= gPlayers
[a
].FName
;
1510 Team
:= gPlayers
[a
].FTeam
;
1511 Frags
:= gPlayers
[a
].FFrags
;
1512 Deaths
:= gPlayers
[a
].FDeath
;
1513 Kills
:= gPlayers
[a
].FKills
;
1514 Color
:= gPlayers
[a
].FModel
.Color
;
1515 Lives
:= gPlayers
[a
].FLives
;
1516 Spectator
:= gPlayers
[a
].FSpectator
;
1521 procedure g_Player_ResetReady();
1525 if not g_Game_IsServer
then Exit
;
1526 if gPlayers
= nil then Exit
;
1528 for a
:= 0 to High(gPlayers
) do
1529 if gPlayers
[a
] <> nil then
1531 gPlayers
[a
].FReady
:= False;
1532 if g_Game_IsNet
then
1533 MH_SEND_GameEvent(NET_EV_INTER_READY
, gPlayers
[a
].UID
, 'N');
1537 procedure g_Player_RememberAll
;
1541 for i
:= Low(gPlayers
) to High(gPlayers
) do
1542 if (gPlayers
[i
] <> nil) and gPlayers
[i
].alive
then
1543 gPlayers
[i
].RememberState
;
1546 procedure g_Player_ResetAll(Force
, Silent
: Boolean);
1550 gTeamStat
[TEAM_RED
].Goals
:= 0;
1551 gTeamStat
[TEAM_BLUE
].Goals
:= 0;
1553 if gPlayers
<> nil then
1554 for i
:= 0 to High(gPlayers
) do
1555 if gPlayers
[i
] <> nil then
1557 gPlayers
[i
].Reset(Force
);
1559 if gPlayers
[i
] is TPlayer
then
1561 if (not gPlayers
[i
].FSpectator
) or gPlayers
[i
].FWantsInGame
then
1562 gPlayers
[i
].Respawn(Silent
)
1564 gPlayers
[i
].Spectate();
1567 TBot(gPlayers
[i
]).Respawn(Silent
);
1571 procedure g_Player_CreateCorpse(Player
: TPlayer
);
1577 if Player
.alive
then
1580 // Ðàçðûâàåì ñâÿçü ñ ïðåæíèì òðóïîì:
1581 if gCorpses
<> nil then
1582 for i
:= 0 to High(gCorpses
) do
1583 if gCorpses
[i
] <> nil then
1584 if gCorpses
[i
].FPlayerUID
= Player
.FUID
then
1585 gCorpses
[i
].FPlayerUID
:= 0;
1587 if Player
.FObj
.Y
>= gMapInfo
.Height
+128 then
1592 if (FHealth
>= -50) or (gGibsCount
= 0) then
1594 if (gCorpses
= nil) or (Length(gCorpses
) = 0) then
1598 for find_id
:= 0 to High(gCorpses
) do
1599 if gCorpses
[find_id
] = nil then
1606 find_id
:= Random(Length(gCorpses
));
1608 gCorpses
[find_id
] := TCorpse
.Create(FObj
.X
, FObj
.Y
, FModel
.Name
, FHealth
< -20);
1609 gCorpses
[find_id
].FColor
:= FModel
.Color
;
1610 gCorpses
[find_id
].FObj
.Vel
:= FObj
.Vel
;
1611 gCorpses
[find_id
].FObj
.Accel
:= FObj
.Accel
;
1612 gCorpses
[find_id
].FPlayerUID
:= FUID
;
1615 g_Player_CreateGibs(FObj
.X
+ PLAYER_RECT_CX
,
1616 FObj
.Y
+ PLAYER_RECT_CY
,
1617 FModel
.Name
, FModel
.Color
);
1621 procedure g_Player_CreateShell(fX
, fY
, dX
, dY
: Integer; T
: Byte);
1625 if (gShells
= nil) or (Length(gShells
) = 0) then
1628 with gShells
[CurrentShell
] do
1634 if T
= SHELL_BULLET
then
1636 if g_Texture_Get('TEXTURE_SHELL_BULLET', SID
) then
1640 Obj
.Rect
.Width
:= 4;
1641 Obj
.Rect
.Height
:= 2;
1645 if g_Texture_Get('TEXTURE_SHELL_SHELL', SID
) then
1649 Obj
.Rect
.Width
:= 7;
1650 Obj
.Rect
.Height
:= 3;
1656 g_Obj_Push(@Obj
, dX
+ Random(4)-Random(4), dY
-Random(4));
1657 positionChanged(); // this updates spatial accelerators
1658 RAngle
:= Random(360);
1659 Timeout
:= gTime
+ SHELL_TIMEOUT
;
1661 if CurrentShell
>= High(gShells
) then
1668 procedure g_Player_CreateGibs(fX
, fY
: Integer; ModelName
: string; fColor
: TRGB
);
1671 GibsArray
: TGibsArray
;
1674 if (gGibs
= nil) or (Length(gGibs
) = 0) then
1676 if not g_PlayerModel_GetGibs(ModelName
, GibsArray
) then
1678 Blood
:= g_PlayerModel_GetBlood(ModelName
);
1680 for a
:= 0 to High(GibsArray
) do
1681 with gGibs
[CurrentGib
] do
1684 ID
:= GibsArray
[a
].ID
;
1685 MaskID
:= GibsArray
[a
].MaskID
;
1688 Obj
.Rect
:= GibsArray
[a
].Rect
;
1689 Obj
.X
:= fX
-GibsArray
[a
].Rect
.X
-(GibsArray
[a
].Rect
.Width
div 2);
1690 Obj
.Y
:= fY
-GibsArray
[a
].Rect
.Y
-(GibsArray
[a
].Rect
.Height
div 2);
1691 g_Obj_PushA(@Obj
, 25 + Random(10), Random(361));
1692 positionChanged(); // this updates spatial accelerators
1693 RAngle
:= Random(360);
1695 if gBloodCount
> 0 then
1696 g_GFX_Blood(fX
, fY
, 16*gBloodCount
+Random(5*gBloodCount
), -16+Random(33), -16+Random(33),
1697 Random(48), Random(48), Blood
.R
, Blood
.G
, Blood
.B
, Blood
.Kind
);
1699 if CurrentGib
>= High(gGibs
) then
1706 procedure g_Player_UpdatePhysicalObjects();
1712 procedure ShellSound_Bounce(X
, Y
: Integer; T
: Byte);
1717 if T
= SHELL_BULLET
then
1718 g_Sound_PlayExAt('SOUND_PLAYER_CASING' + IntToStr(k
), X
, Y
)
1720 g_Sound_PlayExAt('SOUND_PLAYER_SHELL' + IntToStr(k
), X
, Y
);
1725 if gGibs
<> nil then
1726 for i
:= 0 to High(gGibs
) do
1727 if gGibs
[i
].alive
then
1734 mr
:= g_Obj_Move(@Obj
, True, False, True);
1735 positionChanged(); // this updates spatial accelerators
1737 if WordBool(mr
and MOVE_FALLOUT
) then
1743 // Îòëåòàåò îò óäàðà î ñòåíó/ïîòîëîê/ïîë:
1744 if WordBool(mr
and MOVE_HITWALL
) then
1745 Obj
.Vel
.X
:= -(vel
.X
div 2);
1746 if WordBool(mr
and (MOVE_HITCEIL
or MOVE_HITLAND
)) then
1747 Obj
.Vel
.Y
:= -(vel
.Y
div 2);
1749 if (Obj
.Vel
.X
>= 0) then
1751 RAngle
:= RAngle
+ Abs(Obj
.Vel
.X
)*6 + Abs(Obj
.Vel
.Y
);
1752 if RAngle
>= 360 then
1753 RAngle
:= RAngle
mod 360;
1754 end else begin // Counter-clockwise
1755 RAngle
:= RAngle
- Abs(Obj
.Vel
.X
)*6 - Abs(Obj
.Vel
.Y
);
1757 RAngle
:= (360 - (Abs(RAngle
) mod 360)) mod 360;
1760 // Ñîïðîòèâëåíèå âîçäóõà äëÿ êóñêà òðóïà:
1761 if gTime
mod (GAME_TICK
*3) = 0 then
1762 Obj
.Vel
.X
:= z_dec(Obj
.Vel
.X
, 1);
1766 if gCorpses
<> nil then
1767 for i
:= 0 to High(gCorpses
) do
1768 if gCorpses
[i
] <> nil then
1769 if gCorpses
[i
].State
= CORPSE_STATE_REMOVEME
then
1775 gCorpses
[i
].Update();
1778 if gShells
<> nil then
1779 for i
:= 0 to High(gShells
) do
1780 if gShells
[i
].alive
then
1787 mr
:= g_Obj_Move(@Obj
, True, False, True);
1788 positionChanged(); // this updates spatial accelerators
1790 if WordBool(mr
and MOVE_FALLOUT
) or (gShells
[i
].Timeout
< gTime
) then
1796 // Îòëåòàåò îò óäàðà î ñòåíó/ïîòîëîê/ïîë:
1797 if WordBool(mr
and MOVE_HITWALL
) then
1799 Obj
.Vel
.X
:= -(vel
.X
div 2);
1800 if not WordBool(mr
and MOVE_INWATER
) then
1801 ShellSound_Bounce(Obj
.X
, Obj
.Y
, SType
);
1803 if WordBool(mr
and (MOVE_HITCEIL
or MOVE_HITLAND
)) then
1805 Obj
.Vel
.Y
:= -(vel
.Y
div 2);
1806 if Obj
.Vel
.X
<> 0 then Obj
.Vel
.X
:= Obj
.Vel
.X
div 2;
1807 if (Obj
.Vel
.X
= 0) and (Obj
.Vel
.Y
= 0) then
1809 if RAngle
mod 90 <> 0 then
1810 RAngle
:= (RAngle
div 90) * 90;
1812 else if not WordBool(mr
and MOVE_INWATER
) then
1813 ShellSound_Bounce(Obj
.X
, Obj
.Y
, SType
);
1816 if (Obj
.Vel
.X
>= 0) then
1818 RAngle
:= RAngle
+ Abs(Obj
.Vel
.X
)*8 + Abs(Obj
.Vel
.Y
);
1819 if RAngle
>= 360 then
1820 RAngle
:= RAngle
mod 360;
1821 end else begin // Counter-clockwise
1822 RAngle
:= RAngle
- Abs(Obj
.Vel
.X
)*8 - Abs(Obj
.Vel
.Y
);
1824 RAngle
:= (360 - (Abs(RAngle
) mod 360)) mod 360;
1830 procedure TGib
.getMapBox (out x
, y
, w
, h
: Integer); inline;
1832 x
:= Obj
.X
+Obj
.Rect
.X
;
1833 y
:= Obj
.Y
+Obj
.Rect
.Y
;
1834 w
:= Obj
.Rect
.Width
;
1835 h
:= Obj
.Rect
.Height
;
1838 procedure TGib
.moveBy (dx
, dy
: Integer); inline;
1840 if (dx
<> 0) or (dy
<> 0) then
1849 procedure TShell
.getMapBox (out x
, y
, w
, h
: Integer); inline;
1853 w
:= Obj
.Rect
.Width
;
1854 h
:= Obj
.Rect
.Height
;
1857 procedure TShell
.moveBy (dx
, dy
: Integer); inline;
1859 if (dx
<> 0) or (dy
<> 0) then
1868 procedure TGib
.positionChanged (); inline; begin end;
1869 procedure TShell
.positionChanged (); inline; begin end;
1872 procedure g_Player_DrawCorpses();
1877 if gGibs
<> nil then
1878 for i
:= 0 to High(gGibs
) do
1879 if gGibs
[i
].alive
then
1882 if not g_Obj_Collide(sX
, sY
, sWidth
, sHeight
, @Obj
) then
1885 Obj
.lerp(gLerpFactor
, fX
, fY
);
1887 a
.X
:= Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2);
1888 a
.y
:= Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2);
1890 e_DrawAdv(ID
, fX
, fY
, 0, True, False, RAngle
, @a
, TMirrorType
.None
);
1893 e_DrawAdv(MaskID
, fX
, fY
, 0, True, False, RAngle
, @a
, TMirrorType
.None
);
1899 if gCorpses
<> nil then
1900 for i
:= 0 to High(gCorpses
) do
1901 if gCorpses
[i
] <> nil then
1905 procedure g_Player_DrawShells();
1910 if gShells
<> nil then
1911 for i
:= 0 to High(gShells
) do
1912 if gShells
[i
].alive
then
1915 if not g_Obj_Collide(sX
, sY
, sWidth
, sHeight
, @Obj
) then
1918 Obj
.lerp(gLerpFactor
, fX
, fY
);
1923 e_DrawAdv(SpriteID
, fX
, fY
, 0, True, False, RAngle
, @a
, TMirrorType
.None
);
1927 procedure g_Player_RemoveAllCorpses();
1933 SetLength(gGibs
, MaxGibs
);
1934 SetLength(gShells
, MaxGibs
);
1938 if gCorpses
<> nil then
1939 for i
:= 0 to High(gCorpses
) do
1943 SetLength(gCorpses
, MaxCorpses
);
1946 procedure g_Player_Corpses_SaveState (st
: TStream
);
1950 // Ñ÷èòàåì êîëè÷åñòâî ñóùåñòâóþùèõ òðóïîâ
1952 for i
:= 0 to High(gCorpses
) do if (gCorpses
[i
] <> nil) then Inc(count
);
1954 // Êîëè÷åñòâî òðóïîâ
1955 utils
.writeInt(st
, LongInt(count
));
1957 if (count
= 0) then exit
;
1960 for i
:= 0 to High(gCorpses
) do
1962 if gCorpses
[i
] <> nil then
1965 utils
.writeStr(st
, gCorpses
[i
].FModelName
);
1967 utils
.writeBool(st
, gCorpses
[i
].Mess
);
1968 // Ñîõðàíÿåì äàííûå òðóïà:
1969 gCorpses
[i
].SaveState(st
);
1975 procedure g_Player_Corpses_LoadState (st
: TStream
);
1983 g_Player_RemoveAllCorpses();
1985 // Êîëè÷åñòâî òðóïîâ:
1986 count
:= utils
.readLongInt(st
);
1987 if (count
< 0) or (count
> Length(gCorpses
)) then raise XStreamError
.Create('invalid number of corpses');
1989 if (count
= 0) then exit
;
1992 for i
:= 0 to count
-1 do
1995 str
:= utils
.readStr(st
);
1997 b
:= utils
.readBool(st
);
1999 gCorpses
[i
] := TCorpse
.Create(0, 0, str
, b
);
2000 // Çàãðóæàåì äàííûå òðóïà
2001 gCorpses
[i
].LoadState(st
);
2008 function TPlayer
.isValidViewPort (): Boolean; inline; begin result
:= (viewPortW
> 0) and (viewPortH
> 0); end;
2010 procedure TPlayer
.BFGHit();
2012 g_Weapon_BFGHit(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
2013 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2));
2014 if g_Game_IsServer
and g_Game_IsNet
then
2015 MH_SEND_Effect(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
2016 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2),
2020 procedure TPlayer
.ChangeModel(ModelName
: string);
2022 locModel
: TPlayerModel
;
2024 locModel
:= g_PlayerModel_Get(ModelName
);
2025 if locModel
= nil then Exit
;
2031 procedure TPlayer
.SetModel(ModelName
: string);
2035 m
:= g_PlayerModel_Get(ModelName
);
2038 g_SimpleError(Format(_lc
[I_GAME_ERROR_MODEL_FALLBACK
], [ModelName
]));
2039 m
:= g_PlayerModel_Get('doomer');
2042 g_FatalError(Format(_lc
[I_GAME_ERROR_MODEL
], ['doomer']));
2047 if FModel
<> nil then
2052 if not (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then
2053 FModel
.Color
:= FColor
2055 FModel
.Color
:= TEAMCOLOR
[FTeam
];
2056 FModel
.SetWeapon(FCurrWeap
);
2057 FModel
.SetFlag(FFlag
);
2058 SetDirection(FDirection
);
2061 procedure TPlayer
.SetColor(Color
: TRGB
);
2064 if not (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then
2065 if FModel
<> nil then FModel
.Color
:= Color
;
2068 function TPlayer
.GetColor(): TRGB
;
2070 result
:= FModel
.Color
;
2073 procedure TPlayer
.SwitchTeam
;
2075 if g_Game_IsClient
then
2077 if not (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then Exit
;
2079 if gGameOn
and FAlive
then
2080 Kill(K_SIMPLEKILL
, FUID
, HIT_SELF
);
2082 if FTeam
= TEAM_RED
then
2084 ChangeTeam(TEAM_BLUE
);
2085 g_Console_Add(Format(_lc
[I_PLAYER_CHTEAM_BLUE
], [FName
]), True);
2086 if g_Game_IsNet
then
2087 MH_SEND_GameEvent(NET_EV_CHANGE_TEAM
, TEAM_BLUE
, FName
);
2091 ChangeTeam(TEAM_RED
);
2092 g_Console_Add(Format(_lc
[I_PLAYER_CHTEAM_RED
], [FName
]), True);
2093 if g_Game_IsNet
then
2094 MH_SEND_GameEvent(NET_EV_CHANGE_TEAM
, TEAM_RED
, FName
);
2096 FPreferredTeam
:= FTeam
;
2099 procedure TPlayer
.ChangeTeam(Team
: Byte);
2106 TEAM_RED
, TEAM_BLUE
:
2107 FModel
.Color
:= TEAMCOLOR
[Team
];
2109 FModel
.Color
:= FColor
;
2111 if (FTeam
<> OldTeam
) and g_Game_IsNet
and g_Game_IsServer
then
2112 MH_SEND_PlayerStats(FUID
);
2116 procedure TPlayer.CollideItem();
2121 if gItems = nil then Exit;
2122 if not FAlive then Exit;
2124 for i := 0 to High(gItems) do
2127 if (ItemType <> ITEM_NONE) and alive then
2128 if g_Obj_Collide(FObj.X+PLAYER_RECT.X, FObj.Y+PLAYER_RECT.Y, PLAYER_RECT.Width,
2129 PLAYER_RECT.Height, @Obj) then
2131 if not PickItem(ItemType, gItems[i].Respawnable, r) then Continue;
2133 if ItemType in [ITEM_SPHERE_BLUE, ITEM_SPHERE_WHITE, ITEM_INVUL] then
2134 g_Sound_PlayExAt('SOUND_ITEM_GETRULEZ', FObj.X, FObj.Y)
2135 else if ItemType in [ITEM_MEDKIT_SMALL, ITEM_MEDKIT_LARGE, ITEM_MEDKIT_BLACK] then
2136 g_Sound_PlayExAt('SOUND_ITEM_GETMED', FObj.X, FObj.Y)
2137 else g_Sound_PlayExAt('SOUND_ITEM_GETITEM', FObj.X, FObj.Y);
2139 // Íàäî óáðàòü ñ êàðòû, åñëè ýòî íå êëþ÷, êîòîðûì íóæíî ïîäåëèòñÿ ñ äðóãèì èãðîêîì:
2140 if r and not ((ItemType in [ITEM_KEY_RED, ITEM_KEY_GREEN, ITEM_KEY_BLUE]) and
2141 (gGameSettings.GameType = GT_SINGLE) and
2142 (g_Player_GetCount() > 1)) then
2143 if not Respawnable then g_Items_Remove(i) else g_Items_Pick(i);
2149 function TPlayer
.CollideLevel(XInc
, YInc
: Integer): Boolean;
2151 Result
:= g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
,
2152 PLAYER_RECT
.Width
, PLAYER_RECT
.Height
, PANEL_WALL
,
2156 constructor TPlayer
.Create();
2162 mEDamageType
:= HIT_SOME
;
2168 FSawSound
:= TPlayableSound
.Create();
2169 FSawSoundIdle
:= TPlayableSound
.Create();
2170 FSawSoundHit
:= TPlayableSound
.Create();
2171 FSawSoundSelect
:= TPlayableSound
.Create();
2172 FFlameSoundOn
:= TPlayableSound
.Create();
2173 FFlameSoundOff
:= TPlayableSound
.Create();
2174 FFlameSoundWork
:= TPlayableSound
.Create();
2175 FJetSoundFly
:= TPlayableSound
.Create();
2176 FJetSoundOn
:= TPlayableSound
.Create();
2177 FJetSoundOff
:= TPlayableSound
.Create();
2179 FSawSound
.SetByName('SOUND_WEAPON_FIRESAW');
2180 FSawSoundIdle
.SetByName('SOUND_WEAPON_IDLESAW');
2181 FSawSoundHit
.SetByName('SOUND_WEAPON_HITSAW');
2182 FSawSoundSelect
.SetByName('SOUND_WEAPON_SELECTSAW');
2183 FFlameSoundOn
.SetByName('SOUND_WEAPON_FLAMEON');
2184 FFlameSoundOff
.SetByName('SOUND_WEAPON_FLAMEOFF');
2185 FFlameSoundWork
.SetByName('SOUND_WEAPON_FLAMEWORK');
2186 FJetSoundFly
.SetByName('SOUND_PLAYER_JETFLY');
2187 FJetSoundOn
.SetByName('SOUND_PLAYER_JETON');
2188 FJetSoundOff
.SetByName('SOUND_PLAYER_JETOFF');
2190 FSpectatePlayer
:= -1;
2194 FSavedStateNum
:= -1;
2201 FActualModelName
:= 'doomer';
2204 FObj
.Rect
:= PLAYER_RECT
;
2206 FBFGFireCounter
:= -1;
2207 FJustTeleported
:= False;
2210 FWaitForFirstSpawn
:= false;
2215 procedure TPlayer
.positionChanged (); inline;
2219 procedure TPlayer
.doDamage (v
: Integer);
2221 if (v
<= 0) then exit
;
2222 if (v
> 32767) then v
:= 32767;
2223 Damage(v
, 0, 0, 0, mEDamageType
);
2226 procedure TPlayer
.Damage(value
: Word; SpawnerUID
: Word; vx
, vy
: Integer; t
: Byte);
2230 if (not g_Game_IsClient
) and (not FAlive
) then
2235 // Íåóÿçâèìîñòü íå ñïàñàåò îò ëîâóøåê:
2236 if ((t
= HIT_TRAP
) or (t
= HIT_SELF
)) and (not FGodMode
) then
2238 if not g_Game_IsClient
then
2241 if t
= HIT_TRAP
then
2243 // Ëîâóøêà óáèâàåò ñðàçó:
2245 Kill(K_EXTRAHARDKILL
, SpawnerUID
, t
);
2247 if t
= HIT_SELF
then
2251 Kill(K_SIMPLEKILL
, SpawnerUID
, t
);
2254 // Îáíóëèòü äåéñòâèÿ ïðèìî÷åê, ÷òîáû ôîí ïðîïàë
2255 FMegaRulez
[MR_SUIT
] := 0;
2256 FMegaRulez
[MR_INVUL
] := 0;
2257 FMegaRulez
[MR_INVIS
] := 0;
2262 // Íî îò îñòàëüíîãî ñïàñàåò:
2263 if FMegaRulez
[MR_INVUL
] >= gTime
then
2270 // Åñëè åñòü óðîí ñâîèì, èëè ðàíèë ñàì ñåáÿ, èëè òåáÿ ðàíèë ïðîòèâíèê:
2271 if LongBool(gGameSettings
.Options
and GAME_OPTION_TEAMDAMAGE
) or
2272 (SpawnerUID
= FUID
) or
2273 (not SameTeam(FUID
, SpawnerUID
)) then
2275 FLastSpawnerUID
:= SpawnerUID
;
2277 // Êðîâü (ïóçûðüêè, åñëè â âîäå):
2278 if gBloodCount
> 0 then
2280 c
:= Min(value
, 200)*gBloodCount
+ Random(Min(value
, 200) div 2);
2281 if value
div 4 <= c
then
2282 c
:= c
- (value
div 4)
2286 if (t
= HIT_SOME
) and (vx
= 0) and (vy
= 0) then
2290 HIT_TRAP
, HIT_ACID
, HIT_FLAME
, HIT_SELF
: MakeBloodSimple(c
);
2291 HIT_BFG
, HIT_ROCKET
, HIT_SOME
: MakeBloodVector(c
, vx
, vy
);
2294 if t
= HIT_WATER
then
2295 g_GFX_Bubbles(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2),
2296 FObj
.Y
+PLAYER_RECT
.Y
-4, value
div 2, 8, 4);
2301 Inc(FDamageBuffer
, value
);
2305 FPain
:= FPain
+ value
;
2308 if g_Game_IsServer
and g_Game_IsNet
then
2310 MH_SEND_PlayerDamage(FUID
, t
, SpawnerUID
, value
, vx
, vy
);
2311 MH_SEND_PlayerStats(FUID
);
2312 MH_SEND_PlayerPos(False, FUID
);
2316 function TPlayer
.Heal(value
: Word; Soft
: Boolean): Boolean;
2319 if g_Game_IsClient
then
2324 if Soft
and (FHealth
< PLAYER_HP_SOFT
) then
2326 IncMax(FHealth
, value
, PLAYER_HP_SOFT
);
2329 if (not Soft
) and (FHealth
< PLAYER_HP_LIMIT
) then
2331 IncMax(FHealth
, value
, PLAYER_HP_LIMIT
);
2335 if Result
and g_Game_IsServer
and g_Game_IsNet
then
2336 MH_SEND_PlayerStats(FUID
);
2339 destructor TPlayer
.Destroy();
2341 if (gPlayer1
<> nil) and (gPlayer1
.FUID
= FUID
) then
2343 if (gPlayer2
<> nil) and (gPlayer2
.FUID
= FUID
) then
2347 FSawSoundIdle
.Free();
2348 FSawSoundHit
.Free();
2349 FSawSoundSelect
.Free();
2350 FFlameSoundOn
.Free();
2351 FFlameSoundOff
.Free();
2352 FFlameSoundWork
.Free();
2353 FJetSoundFly
.Free();
2355 FJetSoundOff
.Free();
2357 if FPunchAnim
<> nil then
2363 procedure TPlayer
.DrawIndicator(Color
: TRGB
);
2365 indX
, indY
, fX
, fY
: Integer;
2375 FObj
.lerp(gLerpFactor
, fX
, fY
);
2376 case gPlayerIndicatorStyle
of
2379 if g_Texture_Get('TEXTURE_PLAYER_INDICATOR', ID
) then
2381 e_GetTextureSize(ID
, @indW
, @indH
);
2385 if (FObj
.X
+ FObj
.Rect
.X
) < 0 then
2388 indX
:= fX
+ FObj
.Rect
.X
+ FObj
.Rect
.Width
;
2389 indY
:= fY
+ FObj
.Rect
.Y
+ (FObj
.Rect
.Height
- indW
) div 2;
2392 else if (FObj
.X
+ FObj
.Rect
.X
+ FObj
.Rect
.Width
) > Max(gMapInfo
.Width
, gPlayerScreenSize
.X
) then
2395 indX
:= fX
+ FObj
.Rect
.X
- indH
;
2396 indY
:= fY
+ FObj
.Rect
.Y
+ (FObj
.Rect
.Height
- indW
) div 2;
2399 else if (FObj
.Y
- indH
) < 0 then
2402 indX
:= fX
+ FObj
.Rect
.X
+ (FObj
.Rect
.Width
- indW
) div 2;
2403 indY
:= fY
+ FObj
.Rect
.Y
+ FObj
.Rect
.Height
;
2409 indX
:= fX
+ FObj
.Rect
.X
+ (FObj
.Rect
.Width
- indW
) div 2;
2413 indX
:= EnsureRange(indX
, 0, Max(gMapInfo
.Width
, gPlayerScreenSize
.X
) - indW
);
2414 indY
:= EnsureRange(indY
, 0, Max(gMapInfo
.Height
, gPlayerScreenSize
.Y
) - indH
);
2418 e_DrawAdv(ID
, indX
, indY
, 0, True, False, indA
, @a
);
2425 e_TextureFontGetSize(gStdFont
, nW
, nH
);
2426 indX
:= fX
+ FObj
.Rect
.X
+ (FObj
.Rect
.Width
- Length(FName
) * nW
) div 2;
2428 e_TextureFontPrintEx(indX
, indY
, FName
, gStdFont
, Color
.R
, Color
.G
, Color
.B
, 1.0, True);
2434 procedure TPlayer
.DrawBubble();
2436 bubX
, bubY
, fX
, fY
: Integer;
2439 Rw
, Gw
, Bw
: SmallInt;
2442 FObj
.lerp(gLerpFactor
, fX
, fY
);
2443 bubX
:= fX
+FObj
.Rect
.X
+ IfThen(FDirection
= TDirection
.D_LEFT
, -4, 18);
2444 bubY
:= fY
+FObj
.Rect
.Y
- 18;
2452 1: // simple textual non-bubble
2454 bubX
:= fX
+FObj
.Rect
.X
- 11;
2455 bubY
:= fY
+FObj
.Rect
.Y
- 17;
2456 e_TextureFontPrint(bubX
, bubY
, '[...]', gStdFont
);
2459 2: // advanced pixel-perfect bubble
2461 if FTeam
= TEAM_RED
then
2464 if FTeam
= TEAM_BLUE
then
2467 3: // colored bubble
2469 Rb
:= FModel
.Color
.R
;
2470 Gb
:= FModel
.Color
.G
;
2471 Bb
:= FModel
.Color
.B
;
2472 Rw
:= Min(Rb
* 2 + 64, 255);
2473 Gw
:= Min(Gb
* 2 + 64, 255);
2474 Bw
:= Min(Bb
* 2 + 64, 255);
2475 if (Abs(Rw
- Rb
) < 32)
2476 or (Abs(Gw
- Gb
) < 32)
2477 or (Abs(Bw
- Bb
) < 32) then
2479 Rb
:= Max(Rw
div 2 - 16, 0);
2480 Gb
:= Max(Gw
div 2 - 16, 0);
2481 Bb
:= Max(Bw
div 2 - 16, 0);
2484 4: // custom textured bubble
2486 if g_Texture_Get('TEXTURE_PLAYER_TALKBUBBLE', ID
) then
2487 if FDirection
= TDirection
.D_RIGHT
then
2488 e_Draw(ID
, bubX
- 6, bubY
- 7, 0, True, False)
2490 e_Draw(ID
, bubX
- 6, bubY
- 7, 0, True, False, TMirrorType
.Horizontal
);
2496 e_DrawQuad(bubX
+ 1, bubY
, bubX
+ 18, bubY
+ 13, Rb
, Gb
, Bb
);
2497 e_DrawQuad(bubX
, bubY
+ 1, bubX
+ 19, bubY
+ 12, Rb
, Gb
, Bb
);
2499 e_DrawFillQuad(bubX
+ 1, bubY
+ 1, bubX
+ 18, bubY
+ 12, Rw
, Gw
, Bw
, 0);
2502 Dot
:= IfThen(FDirection
= TDirection
.D_LEFT
, 14, 5);
2503 e_DrawLine(1, bubX
+ Dot
, bubY
+ 14, bubX
+ Dot
, bubY
+ 16, Rb
, Gb
, Bb
);
2504 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
);
2505 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
);
2506 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
);
2507 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
);
2511 e_DrawFillQuad(bubX
+ Dot
, bubY
+ 8, bubX
+ Dot
+ 1, bubY
+ 9, Rb
, Gb
, Bb
, 0);
2512 e_DrawFillQuad(bubX
+ Dot
+ 3, bubY
+ 8, bubX
+ Dot
+ 4, bubY
+ 9, Rb
, Gb
, Bb
, 0);
2513 e_DrawFillQuad(bubX
+ Dot
+ 6, bubY
+ 8, bubX
+ Dot
+ 7, bubY
+ 9, Rb
, Gb
, Bb
, 0);
2516 procedure TPlayer
.Draw();
2521 Mirror
: TMirrorType
;
2524 FObj
.lerp(gLerpFactor
, fX
, fY
);
2528 if Direction
= TDirection
.D_RIGHT
then
2529 Mirror
:= TMirrorType
.None
2531 Mirror
:= TMirrorType
.Horizontal
;
2533 if FPunchAnim
<> nil then
2535 FPunchAnim
.Draw(fX
+IfThen(Direction
= TDirection
.D_LEFT
, 15-FObj
.Rect
.X
, FObj
.Rect
.X
-15),
2536 fY
+FObj
.Rect
.Y
-11, Mirror
);
2537 if FPunchAnim
.played
then
2544 if (FMegaRulez
[MR_INVUL
] > gTime
) and ((gPlayerDrawn
<> Self
) or (FSpawnInvul
>= gTime
)) then
2545 if g_Texture_Get('TEXTURE_PLAYER_INVULPENTA', ID
) then
2547 e_GetTextureSize(ID
, @w
, @h
);
2548 if FDirection
= TDirection
.D_LEFT
then
2549 e_Draw(ID
, fX
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2)-(w
div 2)+4,
2550 fY
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2)-(h
div 2)-7+FObj
.slopeUpLeft
, 0, True, False)
2552 e_Draw(ID
, fX
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2)-(w
div 2)-2,
2553 fY
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2)-(h
div 2)-7+FObj
.slopeUpLeft
, 0, True, False);
2556 if FMegaRulez
[MR_INVIS
] > gTime
then
2558 if (gPlayerDrawn
<> nil) and ((Self
= gPlayerDrawn
) or
2559 ((FTeam
= gPlayerDrawn
.Team
) and (gGameSettings
.GameMode
<> GM_DM
))) then
2561 if (FMegaRulez
[MR_INVIS
] - gTime
) <= 2100 then
2562 dr
:= not Odd((FMegaRulez
[MR_INVIS
] - gTime
) div 300)
2566 FModel
.Draw(fX
, fY
+FObj
.slopeUpLeft
, 200)
2568 FModel
.Draw(fX
, fY
+FObj
.slopeUpLeft
);
2571 FModel
.Draw(fX
, fY
+FObj
.slopeUpLeft
, 254);
2574 FModel
.Draw(fX
, fY
+FObj
.slopeUpLeft
);
2577 if g_debug_Frames
then
2579 e_DrawQuad(FObj
.X
+FObj
.Rect
.X
,
2581 FObj
.X
+FObj
.Rect
.X
+FObj
.Rect
.Width
-1,
2582 FObj
.Y
+FObj
.Rect
.Y
+FObj
.Rect
.Height
-1,
2586 if (gChatBubble
> 0) and (FKeys
[KEY_CHAT
].Pressed
) and not FGhost
then
2587 if (FMegaRulez
[MR_INVIS
] <= gTime
) or ((gPlayerDrawn
<> nil) and ((Self
= gPlayerDrawn
) or
2588 ((FTeam
= gPlayerDrawn
.Team
) and (gGameSettings
.GameMode
<> GM_DM
)))) then
2590 // e_DrawPoint(5, 335, 288, 255, 0, 0); // DL, UR, DL, UR
2591 if gAimLine
and alive
and
2592 ((Self
= gPlayer1
) or (Self
= gPlayer2
)) then
2597 procedure TPlayer
.DrawAim();
2598 procedure drawCast (sz
: Integer; ax0
, ay0
, ax1
, ay1
: Integer);
2603 {$IFDEF ENABLE_HOLMES}
2604 if isValidViewPort
and (self
= gPlayer1
) then
2606 g_Holmes_plrLaser(ax0
, ay0
, ax1
, ay1
);
2610 e_DrawLine(sz
, ax0
, ay0
, ax1
, ay1
, 255, 0, 0, 96);
2611 if (g_Map_traceToNearestWall(ax0
, ay0
, ax1
, ay1
, @ex
, @ey
) <> nil) then
2613 e_DrawLine(sz
, ax0
, ay0
, ex
, ey
, 0, 255, 0, 96);
2617 e_DrawLine(sz
, ax0
, ay0
, ex
, ey
, 0, 0, 255, 96);
2622 wx
, wy
, xx
, yy
: Integer;
2626 wx
:= FObj
.X
+ WEAPONPOINT
[FDirection
].X
+ IfThen(FDirection
= TDirection
.D_LEFT
, 7, -7);
2627 wy
:= FObj
.Y
+ WEAPONPOINT
[FDirection
].Y
;
2636 1: begin // Chainsaw
2643 if angle
= ANGLE_RIGHTUP
then Dec(angle
, 2);
2644 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 4);
2645 if angle
= ANGLE_LEFTUP
then Inc(angle
, 2);
2646 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 4);
2651 if angle
= ANGLE_RIGHTUP
then Dec(angle
, 2);
2652 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 4);
2653 if angle
= ANGLE_LEFTUP
then Inc(angle
, 2);
2654 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 4);
2656 4: begin // Double Shotgun
2659 if angle
= ANGLE_RIGHTUP
then Dec(angle
, 2);
2660 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 4);
2661 if angle
= ANGLE_LEFTUP
then Inc(angle
, 2);
2662 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 4);
2664 5: begin // Chaingun
2667 if angle
= ANGLE_RIGHTUP
then Dec(angle
, 2);
2668 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 4);
2669 if angle
= ANGLE_LEFTUP
then Inc(angle
, 2);
2670 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 4);
2672 6: begin // Rocket Launcher
2675 if angle
= ANGLE_RIGHTUP
then Inc(angle
, 2);
2676 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 4);
2677 if angle
= ANGLE_LEFTUP
then Dec(angle
, 2);
2678 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 4);
2680 7: begin // Plasmagun
2683 if angle
= ANGLE_RIGHTUP
then Inc(angle
);
2684 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 3);
2685 if angle
= ANGLE_LEFTUP
then Dec(angle
);
2686 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 3);
2691 if angle
= ANGLE_RIGHTUP
then Inc(angle
, 1);
2692 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 2);
2693 if angle
= ANGLE_LEFTUP
then Dec(angle
, 1);
2694 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 2);
2696 9: begin // Super Chaingun
2699 if angle
= ANGLE_RIGHTUP
then Dec(angle
, 2);
2700 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 4);
2701 if angle
= ANGLE_LEFTUP
then Inc(angle
, 2);
2702 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 4);
2705 xx
:= Trunc(Cos(-DegToRad(angle
)) * len
) + wx
;
2706 yy
:= Trunc(Sin(-DegToRad(angle
)) * len
) + wy
;
2707 {$IF DEFINED(D2F_DEBUG)}
2708 drawCast(sz
, wx
, wy
, xx
, yy
);
2710 e_DrawLine(sz
, wx
, wy
, xx
, yy
, 255, 0, 0, 96);
2714 procedure TPlayer
.DrawGUI();
2717 X
, Y
, SY
, a
, p
, m
: Integer;
2721 stat
: TPlayerStatArray
;
2723 X
:= gPlayerScreenSize
.X
;
2724 SY
:= gPlayerScreenSize
.Y
;
2727 if gShowGoals
and (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then
2729 if gGameSettings
.GameMode
= GM_CTF
then
2733 if gGameSettings
.GameMode
= GM_CTF
then
2735 s
:= 'TEXTURE_PLAYER_REDFLAG';
2736 if gFlags
[FLAG_RED
].State
= FLAG_STATE_CAPTURED
then
2737 s
:= 'TEXTURE_PLAYER_REDFLAG_S';
2738 if gFlags
[FLAG_RED
].State
= FLAG_STATE_DROPPED
then
2739 s
:= 'TEXTURE_PLAYER_REDFLAG_D';
2740 if g_Texture_Get(s
, ID
) then
2741 e_Draw(ID
, X
-16-32, 240-72-4, 0, True, False);
2744 s
:= IntToStr(gTeamStat
[TEAM_RED
].Goals
);
2745 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2746 e_CharFont_PrintEx(gMenuFont
, X
-16-a
-tw
, 240-72-4, s
, TEAMCOLOR
[TEAM_RED
]);
2748 if gGameSettings
.GameMode
= GM_CTF
then
2750 s
:= 'TEXTURE_PLAYER_BLUEFLAG';
2751 if gFlags
[FLAG_BLUE
].State
= FLAG_STATE_CAPTURED
then
2752 s
:= 'TEXTURE_PLAYER_BLUEFLAG_S';
2753 if gFlags
[FLAG_BLUE
].State
= FLAG_STATE_DROPPED
then
2754 s
:= 'TEXTURE_PLAYER_BLUEFLAG_D';
2755 if g_Texture_Get(s
, ID
) then
2756 e_Draw(ID
, X
-16-32, 240-32-4, 0, True, False);
2759 s
:= IntToStr(gTeamStat
[TEAM_BLUE
].Goals
);
2760 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2761 e_CharFont_PrintEx(gMenuFont
, X
-16-a
-tw
, 240-32-4, s
, TEAMCOLOR
[TEAM_BLUE
]);
2764 if g_Texture_Get('TEXTURE_PLAYER_HUDBG', ID
) then
2765 e_DrawFill(ID
, X
, 0, 1, (gPlayerScreenSize
.Y
div 256)+IfThen(gPlayerScreenSize
.Y
mod 256 > 0, 1, 0),
2768 if g_Texture_Get('TEXTURE_PLAYER_HUD', ID
) then
2769 e_Draw(ID
, X
+2, Y
, 0, True, False);
2771 if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
2775 s
:= IntToStr(Frags
);
2776 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2777 e_CharFont_PrintEx(gMenuFont
, X
-16-tw
, Y
, s
, _RGB(255, 0, 0));
2782 stat
:= g_Player_GetStats();
2787 for a
:= 0 to High(stat
) do
2788 if stat
[a
].Name
<> Name
then
2790 if stat
[a
].Frags
> m
then m
:= stat
[a
].Frags
;
2791 if stat
[a
].Frags
> Frags
then p
:= p
+1;
2795 s
:= IntToStr(p
)+' / '+IntToStr(Length(stat
))+' ';
2796 if Frags
>= m
then s
:= s
+'+' else s
:= s
+'-';
2797 s
:= s
+IntToStr(Abs(Frags
-m
));
2799 e_CharFont_GetSize(gMenuSmallFont
, s
, tw
, th
);
2800 e_CharFont_PrintEx(gMenuSmallFont
, X
-16-tw
, Y
+32, s
, _RGB(255, 0, 0));
2803 if gLMSRespawn
> LMS_RESPAWN_NONE
then
2805 s
:= _lc
[I_GAME_WARMUP
];
2806 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2807 s
:= s
+ ': ' + IntToStr((gLMSRespawnTime
- gTime
) div 1000);
2808 e_CharFont_PrintEx(gMenuFont
, X
-64-tw
, SY
-32, s
, _RGB(0, 255, 0));
2810 else if gShowLives
and (gGameSettings
.MaxLives
> 0) then
2812 s
:= IntToStr(Lives
);
2813 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2814 e_CharFont_PrintEx(gMenuFont
, X
-16-tw
, SY
-32, s
, _RGB(0, 255, 0));
2818 e_CharFont_GetSize(gMenuSmallFont
, FName
, tw
, th
);
2819 e_CharFont_PrintEx(gMenuSmallFont
, X
+98-(tw
div 2), Y
+8, FName
, _RGB(255, 0, 0));
2821 if R_BERSERK
in FRulez
then
2822 e_Draw(gItemsTexturesID
[ITEM_MEDKIT_BLACK
], X
+37, Y
+45, 0, True, False)
2824 e_Draw(gItemsTexturesID
[ITEM_MEDKIT_LARGE
], X
+37, Y
+45, 0, True, False);
2826 if g_Texture_Get('TEXTURE_PLAYER_ARMORHUD', ID
) then
2827 e_Draw(ID
, X
+36, Y
+77, 0, True, False);
2829 s
:= IntToStr(IfThen(FHealth
> 0, FHealth
, 0));
2830 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2831 e_CharFont_PrintEx(gMenuFont
, X
+178-tw
, Y
+40, s
, _RGB(255, 0, 0));
2833 s
:= IntToStr(FArmor
);
2834 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2835 e_CharFont_PrintEx(gMenuFont
, X
+178-tw
, Y
+68, s
, _RGB(255, 0, 0));
2837 s
:= IntToStr(GetAmmoByWeapon(FCurrWeap
));
2843 ID
:= gItemsTexturesID
[ITEM_WEAPON_KASTET
];
2848 ID
:= gItemsTexturesID
[ITEM_WEAPON_SAW
];
2850 WEAPON_PISTOL
: ID
:= gItemsTexturesID
[ITEM_WEAPON_PISTOL
];
2851 WEAPON_CHAINGUN
: ID
:= gItemsTexturesID
[ITEM_WEAPON_CHAINGUN
];
2852 WEAPON_SHOTGUN1
: ID
:= gItemsTexturesID
[ITEM_WEAPON_SHOTGUN1
];
2853 WEAPON_SHOTGUN2
: ID
:= gItemsTexturesID
[ITEM_WEAPON_SHOTGUN2
];
2854 WEAPON_SUPERPULEMET
: ID
:= gItemsTexturesID
[ITEM_WEAPON_SUPERPULEMET
];
2855 WEAPON_ROCKETLAUNCHER
: ID
:= gItemsTexturesID
[ITEM_WEAPON_ROCKETLAUNCHER
];
2856 WEAPON_PLASMA
: ID
:= gItemsTexturesID
[ITEM_WEAPON_PLASMA
];
2857 WEAPON_BFG
: ID
:= gItemsTexturesID
[ITEM_WEAPON_BFG
];
2858 WEAPON_FLAMETHROWER
: ID
:= gItemsTexturesID
[ITEM_WEAPON_FLAMETHROWER
];
2861 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2862 e_CharFont_PrintEx(gMenuFont
, X
+178-tw
, Y
+158, s
, _RGB(255, 0, 0));
2863 e_Draw(ID
, X
+20, Y
+160, 0, True, False);
2865 if R_KEY_RED
in FRulez
then
2866 e_Draw(gItemsTexturesID
[ITEM_KEY_RED
], X
+78, Y
+214, 0, True, False);
2868 if R_KEY_GREEN
in FRulez
then
2869 e_Draw(gItemsTexturesID
[ITEM_KEY_GREEN
], X
+95, Y
+214, 0, True, False);
2871 if R_KEY_BLUE
in FRulez
then
2872 e_Draw(gItemsTexturesID
[ITEM_KEY_BLUE
], X
+112, Y
+214, 0, True, False);
2874 if FJetFuel
> 0 then
2876 if g_Texture_Get('TEXTURE_PLAYER_HUDAIR', ID
) then
2877 e_Draw(ID
, X
+2, Y
+116, 0, True, False);
2878 if g_Texture_Get('TEXTURE_PLAYER_HUDJET', ID
) then
2879 e_Draw(ID
, X
+2, Y
+126, 0, True, False);
2880 e_DrawLine(4, X
+16, Y
+122, X
+16+Trunc(168*IfThen(FAir
> 0, FAir
, 0)/AIR_MAX
), Y
+122, 0, 0, 196);
2881 e_DrawLine(4, X
+16, Y
+132, X
+16+Trunc(168*FJetFuel
/JET_MAX
), Y
+132, 208, 0, 0);
2885 if g_Texture_Get('TEXTURE_PLAYER_HUDAIR', ID
) then
2886 e_Draw(ID
, X
+2, Y
+124, 0, True, False);
2887 e_DrawLine(4, X
+16, Y
+130, X
+16+Trunc(168*IfThen(FAir
> 0, FAir
, 0)/AIR_MAX
), Y
+130, 0, 0, 196);
2890 if gShowPing
and g_Game_IsClient
then
2892 s
:= _lc
[I_GAME_PING_HUD
] + IntToStr(NetPeer
.lastRoundTripTime
) + _lc
[I_NET_SLIST_PING_MS
];
2893 e_TextureFontPrint(X
+ 4, Y
+ 242, s
, gStdFont
);
2899 e_TextureFontPrint(X
+ 4, Y
+ 242, _lc
[I_PLAYER_SPECT
], gStdFont
);
2900 e_TextureFontPrint(X
+ 4, Y
+ 258, _lc
[I_PLAYER_SPECT2
], gStdFont
);
2901 e_TextureFontPrint(X
+ 4, Y
+ 274, _lc
[I_PLAYER_SPECT1
], gStdFont
);
2904 e_TextureFontGetSize(gStdFont
, cw
, ch
);
2905 s
:= _lc
[I_PLAYER_SPECT4
];
2906 e_TextureFontPrintEx(gScreenWidth
div 2 - cw
*(Length(s
) div 2),
2907 gScreenHeight
-4-ch
, s
, gStdFont
, 255, 255, 255, 1, True);
2908 e_TextureFontPrint(X
+ 4, Y
+ 290, _lc
[I_PLAYER_SPECT1S
], gStdFont
);
2914 procedure TPlayer
.DrawRulez();
2918 // Ïðè âçÿòèè íåóÿçâèìîñòè ðèñóåòñÿ èíâåðñèîííûé áåëûé ôîí
2919 if (FMegaRulez
[MR_INVUL
] >= gTime
) and (FSpawnInvul
< gTime
) then
2921 if (FMegaRulez
[MR_INVUL
]-gTime
) <= 2100 then
2922 dr
:= not Odd((FMegaRulez
[MR_INVUL
]-gTime
) div 300)
2927 e_DrawFillQuad(0, 0, gPlayerScreenSize
.X
-1, gPlayerScreenSize
.Y
-1,
2928 191, 191, 191, 0, TBlending
.Invert
);
2931 // Ïðè âçÿòèè çàùèòíîãî êîñòþìà ðèñóåòñÿ çåëåíîâàòûé ôîí
2932 if FMegaRulez
[MR_SUIT
] >= gTime
then
2934 if (FMegaRulez
[MR_SUIT
]-gTime
) <= 2100 then
2935 dr
:= not Odd((FMegaRulez
[MR_SUIT
]-gTime
) div 300)
2940 e_DrawFillQuad(0, 0, gPlayerScreenSize
.X
-1, gPlayerScreenSize
.Y
-1,
2941 0, 96, 0, 200, TBlending
.None
);
2944 // Ïðè âçÿòèè áåðñåðêà ðèñóåòñÿ êðàñíîâàòûé ôîí
2945 if (FBerserk
>= 0) and (LongWord(FBerserk
) >= gTime
) and (gFlash
= 2) then
2947 e_DrawFillQuad(0, 0, gPlayerScreenSize
.X
-1, gPlayerScreenSize
.Y
-1,
2948 255, 0, 0, 200, TBlending
.None
);
2952 procedure TPlayer
.DrawPain();
2956 if FPain
= 0 then Exit
;
2960 if a
< 15 then h
:= 0
2961 else if a
< 35 then h
:= 1
2962 else if a
< 55 then h
:= 2
2963 else if a
< 75 then h
:= 3
2964 else if a
< 95 then h
:= 4
2967 //if a > 255 then a := 255;
2969 e_DrawFillQuad(0, 0, gPlayerScreenSize
.X
-1, gPlayerScreenSize
.Y
-1, 255, 0, 0, 255-h
*50);
2970 //e_DrawFillQuad(0, 0, gPlayerScreenSize.X-1, gPlayerScreenSize.Y-1, 255-min(128, a), 255-a, 255-a, 0, B_FILTER);
2973 procedure TPlayer
.DrawPickup();
2977 if FPickup
= 0 then Exit
;
2981 if a
< 15 then h
:= 1
2982 else if a
< 35 then h
:= 2
2983 else if a
< 55 then h
:= 3
2984 else if a
< 75 then h
:= 4
2987 e_DrawFillQuad(0, 0, gPlayerScreenSize
.X
-1, gPlayerScreenSize
.Y
-1, 150, 200, 150, 255-h
*50);
2990 procedure TPlayer
.DoPunch();
2995 if FPunchAnim
<> nil then begin
3000 st
:= 'FRAMES_PUNCH';
3001 if R_BERSERK
in FRulez
then
3002 st
:= st
+ '_BERSERK';
3003 if FKeys
[KEY_UP
].Pressed
then
3005 else if FKeys
[KEY_DOWN
].Pressed
then
3007 g_Frames_Get(id
, st
);
3008 FPunchAnim
:= TAnimation
.Create(id
, False, 1);
3011 procedure TPlayer
.Fire();
3013 f
, DidFire
: Boolean;
3014 wx
, wy
, xd
, yd
: Integer;
3017 if g_Game_IsClient
then Exit
;
3018 // FBFGFireCounter - âðåìÿ ïåðåä âûñòðåëîì (äëÿ BFG)
3019 // FReloading - âðåìÿ ïîñëå âûñòðåëà (äëÿ âñåãî)
3027 if FReloading
[FCurrWeap
] <> 0 then Exit
;
3032 wx
:= FObj
.X
+WEAPONPOINT
[FDirection
].X
;
3033 wy
:= FObj
.Y
+WEAPONPOINT
[FDirection
].Y
;
3034 xd
:= wx
+IfThen(FDirection
= TDirection
.D_LEFT
, -30, 30);
3035 yd
:= wy
+firediry();
3041 if R_BERSERK
in FRulez
then
3043 //g_Weapon_punch(FObj.X+FObj.Rect.X, FObj.Y+FObj.Rect.Y, 75, FUID);
3044 locobj
.X
:= FObj
.X
+FObj
.Rect
.X
;
3045 locobj
.Y
:= FObj
.Y
+FObj
.Rect
.Y
;
3048 locobj
.rect
.Width
:= 39;
3049 locobj
.rect
.Height
:= 52;
3050 locobj
.Vel
.X
:= (xd
-wx
) div 2;
3051 locobj
.Vel
.Y
:= (yd
-wy
) div 2;
3052 locobj
.Accel
.X
:= xd
-wx
;
3053 locobj
.Accel
.y
:= yd
-wy
;
3055 if g_Weapon_Hit(@locobj
, 50, FUID
, HIT_SOME
) <> 0 then
3056 g_Sound_PlayExAt('SOUND_WEAPON_HITBERSERK', FObj
.X
, FObj
.Y
)
3058 g_Sound_PlayExAt('SOUND_WEAPON_MISSBERSERK', FObj
.X
, FObj
.Y
);
3060 if (gFlash
= 1) and (FPain
< 50) then FPain
:= min(FPain
+ 25, 50);
3064 g_Weapon_punch(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
, 3, FUID
);
3068 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
3073 if g_Weapon_chainsaw(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
,
3074 IfThen(gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
], 9, 3), FUID
) <> 0 then
3076 FSawSoundSelect
.Stop();
3078 FSawSoundHit
.PlayAt(FObj
.X
, FObj
.Y
);
3080 else if not FSawSoundHit
.IsPlaying() then
3082 FSawSoundSelect
.Stop();
3083 FSawSound
.PlayAt(FObj
.X
, FObj
.Y
);
3086 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
3092 if FAmmo
[A_BULLETS
] > 0 then
3094 g_Weapon_pistol(wx
, wy
, xd
, yd
, FUID
);
3095 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
3096 Dec(FAmmo
[A_BULLETS
]);
3097 FFireAngle
:= FAngle
;
3100 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
3101 GameVelX
, GameVelY
-2, SHELL_BULLET
);
3105 if FAmmo
[A_SHELLS
] > 0 then
3107 g_Weapon_shotgun(wx
, wy
, xd
, yd
, FUID
);
3108 if not gSoundEffectsDF
then g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN', wx
, wy
);
3109 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
3110 Dec(FAmmo
[A_SHELLS
]);
3111 FFireAngle
:= FAngle
;
3115 FShellType
:= SHELL_SHELL
;
3119 if FAmmo
[A_SHELLS
] >= 2 then
3121 g_Weapon_dshotgun(wx
, wy
, xd
, yd
, FUID
);
3122 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
3123 Dec(FAmmo
[A_SHELLS
], 2);
3124 FFireAngle
:= FAngle
;
3128 FShellType
:= SHELL_DBLSHELL
;
3132 if FAmmo
[A_BULLETS
] > 0 then
3134 g_Weapon_mgun(wx
, wy
, xd
, yd
, FUID
);
3135 if not gSoundEffectsDF
then g_Sound_PlayExAt('SOUND_WEAPON_FIREPISTOL', wx
, wy
);
3136 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
3137 Dec(FAmmo
[A_BULLETS
]);
3138 FFireAngle
:= FAngle
;
3141 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
3142 GameVelX
, GameVelY
-2, SHELL_BULLET
);
3145 WEAPON_ROCKETLAUNCHER
:
3146 if FAmmo
[A_ROCKETS
] > 0 then
3148 g_Weapon_rocket(wx
, wy
, xd
, yd
, FUID
);
3149 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
3150 Dec(FAmmo
[A_ROCKETS
]);
3151 FFireAngle
:= FAngle
;
3157 if FAmmo
[A_CELLS
] > 0 then
3159 g_Weapon_plasma(wx
, wy
, xd
, yd
, FUID
);
3160 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
3161 Dec(FAmmo
[A_CELLS
]);
3162 FFireAngle
:= FAngle
;
3168 if (FAmmo
[A_CELLS
] >= 40) and (FBFGFireCounter
= -1) then
3170 FBFGFireCounter
:= 17;
3171 if not FNoReload
then
3172 g_Sound_PlayExAt('SOUND_WEAPON_STARTFIREBFG', FObj
.X
, FObj
.Y
);
3173 Dec(FAmmo
[A_CELLS
], 40);
3177 WEAPON_SUPERPULEMET
:
3178 if FAmmo
[A_SHELLS
] > 0 then
3180 g_Weapon_shotgun(wx
, wy
, xd
, yd
, FUID
);
3181 if not gSoundEffectsDF
then g_Sound_PlayExAt('SOUND_WEAPON_FIRECGUN', wx
, wy
);
3182 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
3183 Dec(FAmmo
[A_SHELLS
]);
3184 FFireAngle
:= FAngle
;
3187 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
3188 GameVelX
, GameVelY
-2, SHELL_SHELL
);
3191 WEAPON_FLAMETHROWER
:
3192 if FAmmo
[A_FUEL
] > 0 then
3194 g_Weapon_flame(wx
, wy
, xd
, yd
, FUID
);
3196 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
3198 FFireAngle
:= FAngle
;
3205 if g_Game_IsNet
and g_Game_IsServer
then MH_SEND_PlayerStats(FUID
);
3209 if g_Game_IsNet
then
3213 if FCurrWeap
<> WEAPON_BFG
then
3214 MH_SEND_PlayerFire(FUID
, FCurrWeap
, wx
, wy
, xd
, yd
, LastShotID
)
3216 if not FNoReload
then
3217 MH_SEND_Sound(FObj
.X
, FObj
.Y
, 'SOUND_WEAPON_STARTFIREBFG');
3220 MH_SEND_PlayerStats(FUID
);
3225 if (FAngle
= 0) or (FAngle
= 180) then SetAction(A_ATTACK
)
3226 else if (FAngle
= ANGLE_LEFTDOWN
) or (FAngle
= ANGLE_RIGHTDOWN
) then SetAction(A_ATTACKDOWN
)
3227 else if (FAngle
= ANGLE_LEFTUP
) or (FAngle
= ANGLE_RIGHTUP
) then SetAction(A_ATTACKUP
);
3230 function TPlayer
.GetAmmoByWeapon(Weapon
: Byte): Word;
3233 WEAPON_PISTOL
, WEAPON_CHAINGUN
: Result
:= FAmmo
[A_BULLETS
];
3234 WEAPON_SHOTGUN1
, WEAPON_SHOTGUN2
, WEAPON_SUPERPULEMET
: Result
:= FAmmo
[A_SHELLS
];
3235 WEAPON_ROCKETLAUNCHER
: Result
:= FAmmo
[A_ROCKETS
];
3236 WEAPON_PLASMA
, WEAPON_BFG
: Result
:= FAmmo
[A_CELLS
];
3237 WEAPON_FLAMETHROWER
: Result
:= FAmmo
[A_FUEL
];
3242 function TPlayer
.HeadInLiquid(XInc
, YInc
: Integer): Boolean;
3244 Result
:= g_Map_CollidePanel(FObj
.X
+PLAYER_HEADRECT
.X
+XInc
, FObj
.Y
+PLAYER_HEADRECT
.Y
+YInc
,
3245 PLAYER_HEADRECT
.Width
, PLAYER_HEADRECT
.Height
,
3246 PANEL_WATER
or PANEL_ACID1
or PANEL_ACID2
, True);
3249 procedure TPlayer
.FlamerOn
;
3251 FFlameSoundOff
.Stop();
3252 FFlameSoundOff
.SetPosition(0);
3255 if (not FFlameSoundOn
.IsPlaying()) and (not FFlameSoundWork
.IsPlaying()) then
3256 FFlameSoundWork
.PlayAt(FObj
.X
, FObj
.Y
);
3260 FFlameSoundOn
.PlayAt(FObj
.X
, FObj
.Y
);
3265 procedure TPlayer
.FlamerOff
;
3269 FFlameSoundOn
.Stop();
3270 FFlameSoundOn
.SetPosition(0);
3271 FFlameSoundWork
.Stop();
3272 FFlameSoundWork
.SetPosition(0);
3273 FFlameSoundOff
.PlayAt(FObj
.X
, FObj
.Y
);
3278 procedure TPlayer
.JetpackOn
;
3282 FJetSoundOn
.SetPosition(0);
3283 FJetSoundOn
.PlayAt(FObj
.X
, FObj
.Y
);
3287 procedure TPlayer
.JetpackOff
;
3291 FJetSoundOff
.SetPosition(0);
3292 FJetSoundOff
.PlayAt(FObj
.X
, FObj
.Y
);
3295 procedure TPlayer
.CatchFire(Attacker
: Word; Timeout
: Integer = PLAYER_BURN_TIME
);
3297 if Timeout
<= 0 then
3299 if (FMegaRulez
[MR_SUIT
] > gTime
) or (FMegaRulez
[MR_INVUL
] > gTime
) then
3300 exit
; // Íå çàãîðàåìñÿ êîãäà åñòü çàùèòà
3301 if g_Obj_CollidePanel(@FObj
, 0, 0, PANEL_WATER
or PANEL_ACID1
or PANEL_ACID2
) then
3302 exit
; // Íå ïîäãîðàåì â âîäå íà âñÿêèé ñëó÷àé
3303 if FFireTime
<= 0 then
3304 g_Sound_PlayExAt('SOUND_IGNITE', FObj
.X
, FObj
.Y
);
3305 FFireTime
:= Timeout
;
3306 FFireAttacker
:= Attacker
;
3307 if g_Game_IsNet
and g_Game_IsServer
then
3308 MH_SEND_PlayerStats(FUID
);
3311 procedure TPlayer
.Jump();
3313 if gFly
or FJetpack
then
3315 // Ïîëåò (÷èò-êîä èëè äæåòïàê):
3316 if FObj
.Vel
.Y
> -VEL_FLY
then
3317 FObj
.Vel
.Y
:= FObj
.Vel
.Y
- 3;
3320 if FJetFuel
> 0 then
3322 if (FJetFuel
< 1) and g_Game_IsServer
then
3326 if g_Game_IsNet
then
3327 MH_SEND_PlayerStats(FUID
);
3333 // Íå âêëþ÷àòü äæåòïàê â ðåæèìå ïðîõîæäåíèÿ ñêâîçü ñòåíû
3335 FCanJetpack
:= False;
3337 // Ïðûãàåì èëè âñïëûâàåì:
3338 if (CollideLevel(0, 1) or
3339 g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+PLAYER_RECT
.Y
+36, PLAYER_RECT
.Width
,
3340 PLAYER_RECT
.Height
-33, PANEL_STEP
, False)
3341 ) and (FObj
.Accel
.Y
= 0) then // Íå ïðûãàòü, åñëè åñòü âåðòèêàëüíîå óñêîðåíèå
3343 FObj
.Vel
.Y
:= -VEL_JUMP
;
3344 FCanJetpack
:= False;
3348 if BodyInLiquid(0, 0) then
3349 FObj
.Vel
.Y
:= -VEL_SW
3350 else if (FJetFuel
> 0) and FCanJetpack
and
3351 g_Game_IsServer
and (not g_Obj_CollideLiquid(@FObj
, 0, 0)) then
3355 if g_Game_IsNet
then
3356 MH_SEND_PlayerStats(FUID
);
3361 procedure TPlayer
.Kill(KillType
: Byte; SpawnerUID
: Word; t
: Byte);
3363 a
, i
, k
, ab
, ar
: Byte;
3367 srv
, netsrv
: Boolean;
3373 procedure PushItem(t
: Byte);
3377 id
:= g_Items_Create(FObj
.X
, FObj
.Y
, t
, True, False);
3378 it
:= g_Items_ByIdx(id
);
3379 if KillType
= K_EXTRAHARDKILL
then // -7..+7; -8..0
3381 g_Obj_Push(@it
.Obj
, (FObj
.Vel
.X
div 2)-7+Random(15),
3382 (FObj
.Vel
.Y
div 2)-Random(9));
3383 it
.positionChanged(); // this updates spatial accelerators
3387 if KillType
= K_HARDKILL
then // -5..+5; -5..0
3389 g_Obj_Push(@it
.Obj
, (FObj
.Vel
.X
div 2)-5+Random(11),
3390 (FObj
.Vel
.Y
div 2)-Random(6));
3392 else // -3..+3; -3..0
3394 g_Obj_Push(@it
.Obj
, (FObj
.Vel
.X
div 2)-3+Random(7),
3395 (FObj
.Vel
.Y
div 2)-Random(4));
3397 it
.positionChanged(); // this updates spatial accelerators
3400 if g_Game_IsNet
and g_Game_IsServer
then
3401 MH_SEND_ItemSpawn(True, id
);
3405 DoFrags
:= (gGameSettings
.MaxLives
= 0) or (gGameSettings
.GameMode
= GM_COOP
);
3406 Srv
:= g_Game_IsServer
;
3407 Netsrv
:= g_Game_IsServer
and g_Game_IsNet
;
3408 if Srv
then FDeath
:= FDeath
+ 1;
3413 if not FPhysics
then
3419 if (gGameSettings
.MaxLives
> 0) and Srv
and (gLMSRespawn
= LMS_RESPAWN_NONE
) then
3421 if FLives
> 0 then FLives
:= FLives
- 1;
3422 if FLives
= 0 then FNoRespawn
:= True;
3425 // Íîìåð òèïà ñìåðòè:
3428 K_SIMPLEKILL
: a
:= 1;
3430 K_EXTRAHARDKILL
: a
:= 3;
3435 if not FModel
.PlaySound(MODELSOUND_DIE
, a
, FObj
.X
, FObj
.Y
) then
3437 if FModel
.PlaySound(MODELSOUND_DIE
, i
, FObj
.X
, FObj
.Y
) then
3444 FTime
[T_RESPAWN
] := gTime
+ TIME_RESPAWN1
;
3446 FTime
[T_RESPAWN
] := gTime
+ TIME_RESPAWN2
;
3447 K_EXTRAHARDKILL
, K_FALLKILL
:
3448 FTime
[T_RESPAWN
] := gTime
+ TIME_RESPAWN3
;
3451 // Ïåðåêëþ÷àåì ñîñòîÿíèå:
3455 K_HARDKILL
, K_EXTRAHARDKILL
:
3459 // Ðåàêöèÿ ìîíñòðîâ íà ñìåðòü èãðîêà:
3460 if (KillType
<> K_FALLKILL
) and (Srv
) then
3461 g_Monsters_killedp();
3463 if SpawnerUID
= FUID
then
3465 if Srv
and (DoFrags
or (gGameSettings
.GameMode
= GM_TDM
)) then
3470 g_Console_Add(Format(_lc
[I_PLAYER_KILL_SELF
], [FName
]), True);
3473 if g_GetUIDType(SpawnerUID
) = UID_PLAYER
then
3474 begin // Óáèò äðóãèì èãðîêîì
3475 KP
:= g_Player_Get(SpawnerUID
);
3476 if (KP
<> nil) and Srv
then
3478 if (DoFrags
or (gGameSettings
.GameMode
= GM_TDM
)) then
3479 if SameTeam(FUID
, SpawnerUID
) then
3489 if (gGameSettings
.GameMode
= GM_TDM
) and DoFrags
then
3490 Inc(gTeamStat
[KP
.Team
].Goals
,
3491 IfThen(SameTeam(FUID
, SpawnerUID
), -1, 1));
3493 if netsrv
then MH_SEND_PlayerStats(SpawnerUID
);
3496 plr
:= g_Player_Get(SpawnerUID
);
3504 g_Console_Add(Format(_lc
[I_PLAYER_KILL_EXTRAHARD_2
],
3508 g_Console_Add(Format(_lc
[I_PLAYER_KILL_EXTRAHARD_1
],
3512 g_Console_Add(Format(_lc
[I_PLAYER_KILL
],
3517 else if g_GetUIDType(SpawnerUID
) = UID_MONSTER
then
3518 begin // Óáèò ìîíñòðîì
3519 mon
:= g_Monsters_ByUID(SpawnerUID
);
3523 s
:= g_Mons_GetKilledByTypeId(mon
.MonsterType
);
3527 g_Console_Add(Format(_lc
[I_PLAYER_KILL_EXTRAHARD_2
],
3531 g_Console_Add(Format(_lc
[I_PLAYER_KILL_EXTRAHARD_1
],
3535 g_Console_Add(Format(_lc
[I_PLAYER_KILL
],
3540 else // Îñîáûå òèïû ñìåðòè
3543 HIT_SELF
: g_Console_Add(Format(_lc
[I_PLAYER_KILL_SELF
], [FName
]), True);
3544 HIT_FALL
: g_Console_Add(Format(_lc
[I_PLAYER_KILL_FALL
], [FName
]), True);
3545 HIT_WATER
: g_Console_Add(Format(_lc
[I_PLAYER_KILL_WATER
], [FName
]), True);
3546 HIT_ACID
: g_Console_Add(Format(_lc
[I_PLAYER_KILL_ACID
], [FName
]), True);
3547 HIT_TRAP
: g_Console_Add(Format(_lc
[I_PLAYER_KILL_TRAP
], [FName
]), True);
3548 else g_Console_Add(Format(_lc
[I_PLAYER_DIED
], [FName
]), True);
3554 for a
:= WP_FIRST
to WP_LAST
do
3558 WEAPON_SAW
: i
:= ITEM_WEAPON_SAW
;
3559 WEAPON_SHOTGUN1
: i
:= ITEM_WEAPON_SHOTGUN1
;
3560 WEAPON_SHOTGUN2
: i
:= ITEM_WEAPON_SHOTGUN2
;
3561 WEAPON_CHAINGUN
: i
:= ITEM_WEAPON_CHAINGUN
;
3562 WEAPON_ROCKETLAUNCHER
: i
:= ITEM_WEAPON_ROCKETLAUNCHER
;
3563 WEAPON_PLASMA
: i
:= ITEM_WEAPON_PLASMA
;
3564 WEAPON_BFG
: i
:= ITEM_WEAPON_BFG
;
3565 WEAPON_SUPERPULEMET
: i
:= ITEM_WEAPON_SUPERPULEMET
;
3566 WEAPON_FLAMETHROWER
: i
:= ITEM_WEAPON_FLAMETHROWER
;
3575 if R_ITEM_BACKPACK
in FRulez
then
3576 PushItem(ITEM_AMMO_BACKPACK
);
3578 // Âûáðîñ ðàêåòíîãî ðàíöà:
3579 if FJetFuel
> 0 then
3580 PushItem(ITEM_JETPACK
);
3583 if (not (gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
])) or
3584 (not LongBool(gGameSettings
.Options
and GAME_OPTION_DMKEYS
)) then
3586 if R_KEY_RED
in FRulez
then
3587 PushItem(ITEM_KEY_RED
);
3589 if R_KEY_GREEN
in FRulez
then
3590 PushItem(ITEM_KEY_GREEN
);
3592 if R_KEY_BLUE
in FRulez
then
3593 PushItem(ITEM_KEY_BLUE
);
3597 DropFlag(KillType
= K_FALLKILL
);
3600 g_Player_CreateCorpse(Self
);
3602 if Srv
and (gGameSettings
.MaxLives
> 0) and FNoRespawn
and
3603 (gLMSRespawn
= LMS_RESPAWN_NONE
) then
3609 for i
:= Low(gPlayers
) to High(gPlayers
) do
3611 if gPlayers
[i
] = nil then continue
;
3612 if (not gPlayers
[i
].FNoRespawn
) and (not gPlayers
[i
].FSpectator
) then
3615 if gPlayers
[i
].FTeam
= TEAM_RED
then Inc(ar
)
3616 else if gPlayers
[i
].FTeam
= TEAM_BLUE
then Inc(ab
);
3621 OldLR
:= gLMSRespawn
;
3622 if (gGameSettings
.GameMode
= GM_COOP
) then
3626 // everyone is dead, restart the map
3627 g_Game_Message(_lc
[I_MESSAGE_LMS_LOSE
], 144);
3629 MH_SEND_GameEvent(NET_EV_LMS_LOSE
);
3630 gLMSRespawn
:= LMS_RESPAWN_FINAL
;
3631 gLMSRespawnTime
:= gTime
+ 5000;
3633 else if (a
= 1) then
3635 if (gPlayers
[k
] <> nil) and not (gPlayers
[k
] is TBot
) then
3636 if (gPlayers
[k
] = gPlayer1
) or
3637 (gPlayers
[k
] = gPlayer2
) then
3638 g_Console_Add('*** ' + _lc
[I_MESSAGE_LMS_SURVIVOR
] + ' ***', True)
3639 else if Netsrv
and (gPlayers
[k
].FClientID
>= 0) then
3640 MH_SEND_GameEvent(NET_EV_LMS_SURVIVOR
, 0, 'N', gPlayers
[k
].FClientID
);
3643 else if (gGameSettings
.GameMode
= GM_TDM
) then
3645 if (ab
= 0) and (ar
<> 0) then
3648 g_Game_Message(Format(_lc
[I_MESSAGE_TLMS_WIN
], [AnsiUpperCase(_lc
[I_GAME_TEAM_RED
])]), 144);
3650 MH_SEND_GameEvent(NET_EV_TLMS_WIN
, TEAM_RED
);
3651 Inc(gTeamStat
[TEAM_RED
].Goals
);
3652 gLMSRespawn
:= LMS_RESPAWN_FINAL
;
3653 gLMSRespawnTime
:= gTime
+ 5000;
3655 else if (ar
= 0) and (ab
<> 0) then
3658 g_Game_Message(Format(_lc
[I_MESSAGE_TLMS_WIN
], [AnsiUpperCase(_lc
[I_GAME_TEAM_BLUE
])]), 144);
3660 MH_SEND_GameEvent(NET_EV_TLMS_WIN
, TEAM_BLUE
);
3661 Inc(gTeamStat
[TEAM_BLUE
].Goals
);
3662 gLMSRespawn
:= LMS_RESPAWN_FINAL
;
3663 gLMSRespawnTime
:= gTime
+ 5000;
3665 else if (ar
= 0) and (ab
= 0) then
3668 g_Game_Message(_lc
[I_GAME_WIN_DRAW
], 144);
3670 MH_SEND_GameEvent(NET_EV_LMS_DRAW
, 0, FName
);
3671 gLMSRespawn
:= LMS_RESPAWN_FINAL
;
3672 gLMSRespawnTime
:= gTime
+ 5000;
3675 else if (gGameSettings
.GameMode
= GM_DM
) then
3679 if gPlayers
[k
] <> nil then
3682 // survivor is the winner
3683 g_Game_Message(Format(_lc
[I_MESSAGE_LMS_WIN
], [AnsiUpperCase(FName
)]), 144);
3685 MH_SEND_GameEvent(NET_EV_LMS_WIN
, 0, FName
);
3688 gLMSRespawn
:= LMS_RESPAWN_FINAL
;
3689 gLMSRespawnTime
:= gTime
+ 5000;
3691 else if (a
= 0) then
3693 // everyone is dead, restart the map
3694 g_Game_Message(_lc
[I_GAME_WIN_DRAW
], 144);
3696 MH_SEND_GameEvent(NET_EV_LMS_DRAW
, 0, FName
);
3697 gLMSRespawn
:= LMS_RESPAWN_FINAL
;
3698 gLMSRespawnTime
:= gTime
+ 5000;
3701 if srv
and (OldLR
= LMS_RESPAWN_NONE
) and (gLMSRespawn
> LMS_RESPAWN_NONE
) then
3703 if NetMode
= NET_SERVER
then
3704 MH_SEND_GameEvent(NET_EV_LMS_WARMUP
, gLMSRespawnTime
- gTime
)
3706 g_Console_Add(Format(_lc
[I_MSG_WARMUP_START
], [(gLMSRespawnTime
- gTime
) div 1000]), True);
3712 MH_SEND_PlayerStats(FUID
);
3713 MH_SEND_PlayerDeath(FUID
, KillType
, t
, SpawnerUID
);
3714 if gGameSettings
.GameMode
= GM_TDM
then MH_SEND_GameStats
;
3717 if srv
and FNoRespawn
then Spectate(True);
3718 FWantsInGame
:= True;
3721 function TPlayer
.BodyInLiquid(XInc
, YInc
: Integer): Boolean;
3723 Result
:= g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
, PLAYER_RECT
.Width
,
3724 PLAYER_RECT
.Height
-20, PANEL_WATER
or PANEL_ACID1
or PANEL_ACID2
, False);
3727 function TPlayer
.BodyInAcid(XInc
, YInc
: Integer): Boolean;
3729 Result
:= g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
, PLAYER_RECT
.Width
,
3730 PLAYER_RECT
.Height
-20, PANEL_ACID1
or PANEL_ACID2
, False);
3733 procedure TPlayer
.MakeBloodSimple(Count
: Word);
3735 g_GFX_Blood(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)+8,
3736 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2),
3737 Count
div 2, 3, -1, 16, (PLAYER_RECT
.Height
*2 div 3),
3738 FModel
.Blood
.R
, FModel
.Blood
.G
, FModel
.Blood
.B
, FModel
.Blood
.Kind
);
3739 g_GFX_Blood(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-8,
3740 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2),
3741 Count
div 2, -3, -1, 16, (PLAYER_RECT
.Height
*2) div 3,
3742 FModel
.Blood
.R
, FModel
.Blood
.G
, FModel
.Blood
.B
, FModel
.Blood
.Kind
);
3745 procedure TPlayer
.MakeBloodVector(Count
: Word; VelX
, VelY
: Integer);
3747 g_GFX_Blood(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2),
3748 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2),
3749 Count
, VelX
, VelY
, 16, (PLAYER_RECT
.Height
*2) div 3,
3750 FModel
.Blood
.R
, FModel
.Blood
.G
, FModel
.Blood
.B
, FModel
.Blood
.Kind
);
3753 procedure TPlayer
.QueueWeaponSwitch(Weapon
: Byte);
3755 if g_Game_IsClient
then Exit
;
3756 if Weapon
> High(FWeapon
) then Exit
;
3757 FNextWeap
:= FNextWeap
or (1 shl Weapon
);
3760 procedure TPlayer
.resetWeaponQueue ();
3763 FNextWeapDelay
:= 0;
3766 function TPlayer
.hasAmmoForWeapon (weapon
: Byte): Boolean;
3770 WEAPON_KASTET
, WEAPON_SAW
: result
:= true;
3771 WEAPON_SHOTGUN1
, WEAPON_SHOTGUN2
, WEAPON_SUPERPULEMET
: result
:= (FAmmo
[A_SHELLS
] > 0);
3772 WEAPON_PISTOL
, WEAPON_CHAINGUN
: result
:= (FAmmo
[A_BULLETS
] > 0);
3773 WEAPON_ROCKETLAUNCHER
: result
:= (FAmmo
[A_ROCKETS
] > 0);
3774 WEAPON_PLASMA
, WEAPON_BFG
: result
:= (FAmmo
[A_CELLS
] > 0);
3775 WEAPON_FLAMETHROWER
: result
:= (FAmmo
[A_FUEL
] > 0);
3776 else result
:= (weapon
< length(FWeapon
));
3780 // return 255 for "no switch"
3781 function TPlayer
.getNextWeaponIndex (): Byte;
3784 wantThisWeapon
: array[0..64] of Boolean;
3785 wwc
: Integer = 0; //HACK!
3788 result
:= 255; // default result: "no switch"
3789 // had weapon cycling on previous frame? remove that flag
3790 if (FNextWeap
and $2000) <> 0 then
3792 FNextWeap
:= FNextWeap
and $1FFF;
3793 FNextWeapDelay
:= 0;
3795 // cycling has priority
3796 if (FNextWeap
and $C000) <> 0 then
3798 if (FNextWeap
and $8000) <> 0 then
3802 FNextWeap
:= FNextWeap
or $2000; // we need this
3803 if FNextWeapDelay
> 0 then
3804 exit
; // cooldown time
3806 for i
:= 0 to High(FWeapon
) do
3808 cwi
:= (cwi
+length(FWeapon
)+dir
) mod length(FWeapon
);
3809 if FWeapon
[cwi
] then
3811 //e_WriteLog(Format(' SWITCH: cur=%d; new=%d', [FCurrWeap, cwi]), MSG_WARNING);
3812 result
:= Byte(cwi
);
3813 FNextWeapDelay
:= WEAPON_DELAY
;
3821 for i
:= 0 to High(wantThisWeapon
) do
3822 wantThisWeapon
[i
] := false;
3823 for i
:= 0 to High(FWeapon
) do
3824 if (FNextWeap
and (1 shl i
)) <> 0 then
3826 wantThisWeapon
[i
] := true;
3829 // exclude currently selected weapon from the set
3830 wantThisWeapon
[FCurrWeap
] := false;
3831 // slow down alterations a little
3834 //e_WriteLog(Format(' FNextWeap=%x; delay=%d', [FNextWeap, FNextWeapDelay]), MSG_WARNING);
3835 // more than one weapon requested, assume "alteration" and check alteration delay
3836 if FNextWeapDelay
> 0 then
3842 // do not reset weapon queue, it will be done in `RealizeCurrentWeapon()`
3843 // but clear all counters if no weapon should be switched
3849 //e_WriteLog(Format('wwc=%d', [wwc]), MSG_WARNING);
3850 // try weapons in descending order
3851 for i
:= High(FWeapon
) downto 0 do
3853 if wantThisWeapon
[i
] and FWeapon
[i
] and ((wwc
= 1) or hasAmmoForWeapon(i
)) then
3858 FNextWeapDelay
:= WEAPON_DELAY
* 2; // anyway, 'cause why not
3862 // no suitable weapon found, so reset the queue, to avoid accidental "queuing" of weapon w/o ammo
3866 procedure TPlayer
.RealizeCurrentWeapon();
3867 function switchAllowed (): Boolean;
3872 if FBFGFireCounter
<> -1 then
3874 if FTime
[T_SWITCH
] > gTime
then
3876 for i
:= WP_FIRST
to WP_LAST
do
3877 if FReloading
[i
] > 0 then
3885 //e_WriteLog(Format('***RealizeCurrentWeapon: FNextWeap=%x; FNextWeapDelay=%d', [FNextWeap, FNextWeapDelay]), MSG_WARNING);
3886 //FNextWeap := FNextWeap and $1FFF;
3887 if FNextWeapDelay
> 0 then Dec(FNextWeapDelay
); // "alteration delay"
3889 if not switchAllowed
then
3891 //HACK for weapon cycling
3892 if (FNextWeap
and $E000) <> 0 then FNextWeap
:= 0;
3896 nw
:= getNextWeaponIndex();
3897 if nw
= 255 then exit
; // don't reset anything here
3898 if nw
> High(FWeapon
) then
3900 // don't forget to reset queue here!
3901 //e_WriteLog(' RealizeCurrentWeapon: WUTAFUUUU', MSG_WARNING);
3909 FTime
[T_SWITCH
] := gTime
+156;
3910 if FCurrWeap
= WEAPON_SAW
then FSawSoundSelect
.PlayAt(FObj
.X
, FObj
.Y
);
3911 FModel
.SetWeapon(FCurrWeap
);
3912 if g_Game_IsNet
then MH_SEND_PlayerStats(FUID
);
3916 procedure TPlayer
.NextWeapon();
3918 if g_Game_IsClient
then Exit
;
3922 procedure TPlayer
.PrevWeapon();
3924 if g_Game_IsClient
then Exit
;
3928 procedure TPlayer
.SetWeapon(W
: Byte);
3930 if FCurrWeap
<> W
then
3931 if W
= WEAPON_SAW
then
3932 FSawSoundSelect
.PlayAt(FObj
.X
, FObj
.Y
);
3935 FModel
.SetWeapon(CurrWeap
);
3939 function TPlayer
.PickItem(ItemType
: Byte; arespawn
: Boolean; var remove
: Boolean): Boolean;
3941 function allowBerserkSwitching (): Boolean;
3943 if (FBFGFireCounter
<> -1) then begin result
:= false; exit
; end;
3945 if gBerserkAutoswitch
then exit
;
3946 if not conIsCheatsEnabled
then exit
;
3954 if g_Game_IsClient
then Exit
;
3956 // a = true - ìåñòî ñïàâíà ïðåäìåòà:
3957 a
:= LongBool(gGameSettings
.Options
and GAME_OPTION_WEAPONSTAY
) and arespawn
;
3962 if (FHealth
< PLAYER_HP_SOFT
) or (FFireTime
> 0) then
3964 if FHealth
< PLAYER_HP_SOFT
then IncMax(FHealth
, 10, PLAYER_HP_SOFT
);
3968 if gFlash
= 2 then Inc(FPickup
, 5);
3972 if (FHealth
< PLAYER_HP_SOFT
) or (FFireTime
> 0) then
3974 if FHealth
< PLAYER_HP_SOFT
then IncMax(FHealth
, 25, PLAYER_HP_SOFT
);
3978 if gFlash
= 2 then Inc(FPickup
, 5);
3982 if FArmor
< PLAYER_AP_SOFT
then
3984 FArmor
:= PLAYER_AP_SOFT
;
3987 if gFlash
= 2 then Inc(FPickup
, 5);
3991 if FArmor
< PLAYER_AP_LIMIT
then
3993 FArmor
:= PLAYER_AP_LIMIT
;
3996 if gFlash
= 2 then Inc(FPickup
, 5);
4000 if (FHealth
< PLAYER_HP_LIMIT
) or (FFireTime
> 0) then
4002 if FHealth
< PLAYER_HP_LIMIT
then IncMax(FHealth
, 100, PLAYER_HP_LIMIT
);
4006 if gFlash
= 2 then Inc(FPickup
, 5);
4010 if (FHealth
< PLAYER_HP_LIMIT
) or (FArmor
< PLAYER_AP_LIMIT
) or (FFireTime
> 0) then
4012 if FHealth
< PLAYER_HP_LIMIT
then
4013 FHealth
:= PLAYER_HP_LIMIT
;
4014 if FArmor
< PLAYER_AP_LIMIT
then
4015 FArmor
:= PLAYER_AP_LIMIT
;
4019 if gFlash
= 2 then Inc(FPickup
, 5);
4023 if (not FWeapon
[WEAPON_SAW
]) or ((not arespawn
) and (gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
])) then
4025 FWeapon
[WEAPON_SAW
] := True;
4027 if gFlash
= 2 then Inc(FPickup
, 5);
4028 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
4031 ITEM_WEAPON_SHOTGUN1
:
4032 if (FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
]) or not FWeapon
[WEAPON_SHOTGUN1
] then
4034 // Íóæíî, ÷òîáû íå âçÿòü âñå ïóëè ñðàçó:
4035 if a
and FWeapon
[WEAPON_SHOTGUN1
] then Exit
;
4037 IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
4038 FWeapon
[WEAPON_SHOTGUN1
] := True;
4040 if gFlash
= 2 then Inc(FPickup
, 5);
4041 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
4044 ITEM_WEAPON_SHOTGUN2
:
4045 if (FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
]) or not FWeapon
[WEAPON_SHOTGUN2
] then
4047 if a
and FWeapon
[WEAPON_SHOTGUN2
] then Exit
;
4049 IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
4050 FWeapon
[WEAPON_SHOTGUN2
] := True;
4052 if gFlash
= 2 then Inc(FPickup
, 5);
4053 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
4056 ITEM_WEAPON_CHAINGUN
:
4057 if (FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
]) or not FWeapon
[WEAPON_CHAINGUN
] then
4059 if a
and FWeapon
[WEAPON_CHAINGUN
] then Exit
;
4061 IncMax(FAmmo
[A_BULLETS
], 50, FMaxAmmo
[A_BULLETS
]);
4062 FWeapon
[WEAPON_CHAINGUN
] := True;
4064 if gFlash
= 2 then Inc(FPickup
, 5);
4065 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
4068 ITEM_WEAPON_ROCKETLAUNCHER
:
4069 if (FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
]) or not FWeapon
[WEAPON_ROCKETLAUNCHER
] then
4071 if a
and FWeapon
[WEAPON_ROCKETLAUNCHER
] then Exit
;
4073 IncMax(FAmmo
[A_ROCKETS
], 2, FMaxAmmo
[A_ROCKETS
]);
4074 FWeapon
[WEAPON_ROCKETLAUNCHER
] := True;
4076 if gFlash
= 2 then Inc(FPickup
, 5);
4077 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
4081 if (FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
]) or not FWeapon
[WEAPON_PLASMA
] then
4083 if a
and FWeapon
[WEAPON_PLASMA
] then Exit
;
4085 IncMax(FAmmo
[A_CELLS
], 40, FMaxAmmo
[A_CELLS
]);
4086 FWeapon
[WEAPON_PLASMA
] := 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');
4093 if (FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
]) or not FWeapon
[WEAPON_BFG
] then
4095 if a
and FWeapon
[WEAPON_BFG
] then Exit
;
4097 IncMax(FAmmo
[A_CELLS
], 40, FMaxAmmo
[A_CELLS
]);
4098 FWeapon
[WEAPON_BFG
] := True;
4100 if gFlash
= 2 then Inc(FPickup
, 5);
4101 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
4104 ITEM_WEAPON_SUPERPULEMET
:
4105 if (FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
]) or not FWeapon
[WEAPON_SUPERPULEMET
] then
4107 if a
and FWeapon
[WEAPON_SUPERPULEMET
] then Exit
;
4109 IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
4110 FWeapon
[WEAPON_SUPERPULEMET
] := True;
4112 if gFlash
= 2 then Inc(FPickup
, 5);
4113 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
4116 ITEM_WEAPON_FLAMETHROWER
:
4117 if (FAmmo
[A_FUEL
] < FMaxAmmo
[A_FUEL
]) or not FWeapon
[WEAPON_FLAMETHROWER
] then
4119 if a
and FWeapon
[WEAPON_FLAMETHROWER
] then Exit
;
4121 IncMax(FAmmo
[A_FUEL
], 100, FMaxAmmo
[A_FUEL
]);
4122 FWeapon
[WEAPON_FLAMETHROWER
] := True;
4124 if gFlash
= 2 then Inc(FPickup
, 5);
4125 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
4129 if FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
] then
4131 IncMax(FAmmo
[A_BULLETS
], 10, FMaxAmmo
[A_BULLETS
]);
4134 if gFlash
= 2 then Inc(FPickup
, 5);
4137 ITEM_AMMO_BULLETS_BOX
:
4138 if FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
] then
4140 IncMax(FAmmo
[A_BULLETS
], 50, FMaxAmmo
[A_BULLETS
]);
4143 if gFlash
= 2 then Inc(FPickup
, 5);
4147 if FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
] then
4149 IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
4152 if gFlash
= 2 then Inc(FPickup
, 5);
4155 ITEM_AMMO_SHELLS_BOX
:
4156 if FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
] then
4158 IncMax(FAmmo
[A_SHELLS
], 25, FMaxAmmo
[A_SHELLS
]);
4161 if gFlash
= 2 then Inc(FPickup
, 5);
4165 if FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
] then
4167 IncMax(FAmmo
[A_ROCKETS
], 1, FMaxAmmo
[A_ROCKETS
]);
4170 if gFlash
= 2 then Inc(FPickup
, 5);
4173 ITEM_AMMO_ROCKET_BOX
:
4174 if FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
] then
4176 IncMax(FAmmo
[A_ROCKETS
], 5, FMaxAmmo
[A_ROCKETS
]);
4179 if gFlash
= 2 then Inc(FPickup
, 5);
4183 if FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
] then
4185 IncMax(FAmmo
[A_CELLS
], 40, FMaxAmmo
[A_CELLS
]);
4188 if gFlash
= 2 then Inc(FPickup
, 5);
4192 if FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
] then
4194 IncMax(FAmmo
[A_CELLS
], 100, FMaxAmmo
[A_CELLS
]);
4197 if gFlash
= 2 then Inc(FPickup
, 5);
4201 if FAmmo
[A_FUEL
] < FMaxAmmo
[A_FUEL
] then
4203 IncMax(FAmmo
[A_FUEL
], 100, FMaxAmmo
[A_FUEL
]);
4206 if gFlash
= 2 then Inc(FPickup
, 5);
4210 if not(R_ITEM_BACKPACK
in FRulez
) or
4211 (FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
]) or
4212 (FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
]) or
4213 (FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
]) or
4214 (FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
]) or
4215 (FAmmo
[A_FUEL
] < FMaxAmmo
[A_FUEL
]) then
4217 FMaxAmmo
[A_BULLETS
] := AmmoLimits
[1, A_BULLETS
];
4218 FMaxAmmo
[A_SHELLS
] := AmmoLimits
[1, A_SHELLS
];
4219 FMaxAmmo
[A_ROCKETS
] := AmmoLimits
[1, A_ROCKETS
];
4220 FMaxAmmo
[A_CELLS
] := AmmoLimits
[1, A_CELLS
];
4221 FMaxAmmo
[A_FUEL
] := AmmoLimits
[1, A_FUEL
];
4223 if FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
] then
4224 IncMax(FAmmo
[A_BULLETS
], 10, FMaxAmmo
[A_BULLETS
]);
4225 if FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
] then
4226 IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
4227 if FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
] then
4228 IncMax(FAmmo
[A_ROCKETS
], 1, FMaxAmmo
[A_ROCKETS
]);
4229 if FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
] then
4230 IncMax(FAmmo
[A_CELLS
], 40, FMaxAmmo
[A_CELLS
]);
4231 if FAmmo
[A_FUEL
] < FMaxAmmo
[A_FUEL
] then
4232 IncMax(FAmmo
[A_FUEL
], 50, FMaxAmmo
[A_FUEL
]);
4234 FRulez
:= FRulez
+ [R_ITEM_BACKPACK
];
4237 if gFlash
= 2 then Inc(FPickup
, 5);
4241 if not(R_KEY_RED
in FRulez
) then
4243 Include(FRulez
, R_KEY_RED
);
4245 remove
:= (gGameSettings
.GameMode
<> GM_COOP
) and (g_Player_GetCount() < 2);
4246 if gFlash
= 2 then Inc(FPickup
, 5);
4247 if (not remove
) and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETITEM');
4251 if not(R_KEY_GREEN
in FRulez
) then
4253 Include(FRulez
, R_KEY_GREEN
);
4255 remove
:= (gGameSettings
.GameMode
<> GM_COOP
) and (g_Player_GetCount() < 2);
4256 if gFlash
= 2 then Inc(FPickup
, 5);
4257 if (not remove
) and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETITEM');
4261 if not(R_KEY_BLUE
in FRulez
) then
4263 Include(FRulez
, R_KEY_BLUE
);
4265 remove
:= (gGameSettings
.GameMode
<> GM_COOP
) and (g_Player_GetCount() < 2);
4266 if gFlash
= 2 then Inc(FPickup
, 5);
4267 if (not remove
) and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETITEM');
4271 if FMegaRulez
[MR_SUIT
] < gTime
+PLAYER_SUIT_TIME
then
4273 FMegaRulez
[MR_SUIT
] := gTime
+PLAYER_SUIT_TIME
;
4277 if gFlash
= 2 then Inc(FPickup
, 5);
4281 if FAir
< AIR_MAX
then
4286 if gFlash
= 2 then Inc(FPickup
, 5);
4291 if not (R_BERSERK
in FRulez
) then
4293 Include(FRulez
, R_BERSERK
);
4294 if allowBerserkSwitching
then
4296 FCurrWeap
:= WEAPON_KASTET
;
4298 FModel
.SetWeapon(WEAPON_KASTET
);
4303 if gFlash
= 2 then Inc(FPickup
, 5);
4305 FBerserk
:= gTime
+30000;
4310 if (FHealth
< PLAYER_HP_SOFT
) or (FFireTime
> 0) then
4312 if FHealth
< PLAYER_HP_SOFT
then FHealth
:= PLAYER_HP_SOFT
;
4313 FBerserk
:= gTime
+30000;
4321 if FMegaRulez
[MR_INVUL
] < gTime
+PLAYER_INVUL_TIME
then
4323 FMegaRulez
[MR_INVUL
] := gTime
+PLAYER_INVUL_TIME
;
4327 if gFlash
= 2 then Inc(FPickup
, 5);
4331 if (FHealth
< PLAYER_HP_LIMIT
) or (FFireTime
> 0) then
4333 if FHealth
< PLAYER_HP_LIMIT
then IncMax(FHealth
, 4, PLAYER_HP_LIMIT
);
4337 if gFlash
= 2 then Inc(FPickup
, 5);
4341 if FArmor
< PLAYER_AP_LIMIT
then
4343 IncMax(FArmor
, 5, PLAYER_AP_LIMIT
);
4346 if gFlash
= 2 then Inc(FPickup
, 5);
4350 if FJetFuel
< JET_MAX
then
4352 FJetFuel
:= JET_MAX
;
4355 if gFlash
= 2 then Inc(FPickup
, 5);
4359 if FMegaRulez
[MR_INVIS
] < gTime
+PLAYER_INVIS_TIME
then
4361 FMegaRulez
[MR_INVIS
] := gTime
+PLAYER_INVIS_TIME
;
4364 if gFlash
= 2 then Inc(FPickup
, 5);
4369 procedure TPlayer
.Touch();
4373 //FModel.PlaySound(MODELSOUND_PAIN, 1, FObj.X, FObj.Y);
4376 // Áðîñèòü ôëàã òîâàðèùó:
4377 if gGameSettings
.GameMode
= GM_CTF
then
4382 procedure TPlayer
.Push(vx
, vy
: Integer);
4384 if (not FPhysics
) and FGhost
then
4386 FObj
.Accel
.X
:= FObj
.Accel
.X
+ vx
;
4387 FObj
.Accel
.Y
:= FObj
.Accel
.Y
+ vy
;
4388 if g_Game_IsNet
and g_Game_IsServer
then
4389 MH_SEND_PlayerPos(True, FUID
, NET_EVERYONE
);
4392 procedure TPlayer
.Reset(Force
: Boolean);
4398 FTime
[T_RESPAWN
] := 0;
4399 FTime
[T_FLAGCAP
] := 0;
4414 FSpectator
:= False;
4417 FSpectatePlayer
:= -1;
4418 FNoRespawn
:= False;
4420 FLives
:= gGameSettings
.MaxLives
;
4425 procedure TPlayer
.SoftReset();
4432 FBFGFireCounter
:= -1;
4440 SetAction(A_STAND
, True);
4443 function TPlayer
.GetRespawnPoint(): Byte;
4448 // Íà áóäóùåå: FSpawn - èãðîê óæå èãðàë è ïåðåðîæäàåòñÿ
4450 // Îäèíî÷íàÿ èãðà/êîîïåðàòèâ
4451 if gGameSettings
.GameMode
in [GM_COOP
, GM_SINGLE
] then
4453 if (Self
= gPlayer1
) or (Self
= gPlayer2
) then
4455 // Òî÷êà ïîÿâëåíèÿ ñâîåãî èãðîêà
4456 if Self
= gPlayer1
then
4457 c
:= RESPAWNPOINT_PLAYER1
4459 c
:= RESPAWNPOINT_PLAYER2
;
4460 if g_Map_GetPointCount(c
) > 0 then
4466 // Òî÷êà ïîÿâëåíèÿ äðóãîãî èãðîêà
4467 if Self
= gPlayer1
then
4468 c
:= RESPAWNPOINT_PLAYER2
4470 c
:= RESPAWNPOINT_PLAYER1
;
4471 if g_Map_GetPointCount(c
) > 0 then
4478 // Òî÷êà ïîÿâëåíèÿ ëþáîãî èãðîêà (áîòà)
4479 if Random(2) = 0 then
4480 c
:= RESPAWNPOINT_PLAYER1
4482 c
:= RESPAWNPOINT_PLAYER2
;
4483 if g_Map_GetPointCount(c
) > 0 then
4490 // Òî÷êà ëþáîé èç êîìàíä
4491 if Random(2) = 0 then
4492 c
:= RESPAWNPOINT_RED
4494 c
:= RESPAWNPOINT_BLUE
;
4495 if g_Map_GetPointCount(c
) > 0 then
4502 c
:= RESPAWNPOINT_DM
;
4503 if g_Map_GetPointCount(c
) > 0 then
4511 if gGameSettings
.GameMode
= GM_DM
then
4514 c
:= RESPAWNPOINT_DM
;
4515 if g_Map_GetPointCount(c
) > 0 then
4521 // Òî÷êà ïîÿâëåíèÿ ëþáîãî èãðîêà
4522 if Random(2) = 0 then
4523 c
:= RESPAWNPOINT_PLAYER1
4525 c
:= RESPAWNPOINT_PLAYER2
;
4526 if g_Map_GetPointCount(c
) > 0 then
4532 // Òî÷êà ëþáîé èç êîìàíä
4533 if Random(2) = 0 then
4534 c
:= RESPAWNPOINT_RED
4536 c
:= RESPAWNPOINT_BLUE
;
4537 if g_Map_GetPointCount(c
) > 0 then
4545 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
4547 // Òî÷êà ñâîåé êîìàíäû
4548 c
:= RESPAWNPOINT_DM
;
4549 if FTeam
= TEAM_RED
then
4550 c
:= RESPAWNPOINT_RED
;
4551 if FTeam
= TEAM_BLUE
then
4552 c
:= RESPAWNPOINT_BLUE
;
4553 if g_Map_GetPointCount(c
) > 0 then
4560 c
:= RESPAWNPOINT_DM
;
4561 if g_Map_GetPointCount(c
) > 0 then
4567 // Òî÷êà ïîÿâëåíèÿ ëþáîãî èãðîêà
4568 if Random(2) = 0 then
4569 c
:= RESPAWNPOINT_PLAYER1
4571 c
:= RESPAWNPOINT_PLAYER2
;
4572 if g_Map_GetPointCount(c
) > 0 then
4578 // Òî÷êà äðóãîé êîìàíäû
4579 c
:= RESPAWNPOINT_DM
;
4580 if FTeam
= TEAM_RED
then
4581 c
:= RESPAWNPOINT_BLUE
;
4582 if FTeam
= TEAM_BLUE
then
4583 c
:= RESPAWNPOINT_RED
;
4584 if g_Map_GetPointCount(c
) > 0 then
4592 procedure TPlayer
.Respawn(Silent
: Boolean; Force
: Boolean = False);
4594 RespawnPoint
: TRespawnPoint
;
4601 FBFGFireCounter
:= -1;
4607 if not g_Game_IsServer
then
4611 FWantsInGame
:= True;
4612 FJustTeleported
:= True;
4615 FTime
[T_RESPAWN
] := 0;
4619 // if server changes MaxLives we gotta be ready
4620 if gGameSettings
.MaxLives
= 0 then FNoRespawn
:= False;
4622 // Åùå íåëüçÿ âîçðîäèòüñÿ:
4623 if FTime
[T_RESPAWN
] > gTime
then
4626 // Ïðîñðàë âñå æèçíè:
4629 if not FSpectator
then Spectate(True);
4630 FWantsInGame
:= True;
4634 if (gGameSettings
.GameType
<> GT_SINGLE
) and (gGameSettings
.GameMode
<> GM_COOP
) then
4635 begin // "Ñâîÿ èãðà"
4636 // Áåðñåðê íå ñîõðàíÿåòñÿ ìåæäó óðîâíÿìè:
4637 FRulez
:= FRulez
-[R_BERSERK
];
4639 else // "Îäèíî÷íàÿ èãðà"/"Êîîï"
4641 // Áåðñåðê è êëþ÷è íå ñîõðàíÿþòñÿ ìåæäó óðîâíÿìè:
4642 FRulez
:= FRulez
-[R_KEY_RED
, R_KEY_GREEN
, R_KEY_BLUE
, R_BERSERK
];
4645 // Ïîëó÷àåì òî÷êó ñïàóíà èãðîêà:
4646 c
:= GetRespawnPoint();
4651 // Âîñêðåøåíèå áåç îðóæèÿ:
4654 FHealth
:= Round(PLAYER_HP_SOFT
* (FHandicap
/ 100));
4660 for a
:= WP_FIRST
to WP_LAST
do
4662 FWeapon
[a
] := False;
4666 FWeapon
[WEAPON_PISTOL
] := True;
4667 FWeapon
[WEAPON_KASTET
] := True;
4668 FCurrWeap
:= WEAPON_PISTOL
;
4671 FModel
.SetWeapon(FCurrWeap
);
4673 for b
:= A_BULLETS
to A_HIGH
do
4676 FAmmo
[A_BULLETS
] := 50;
4678 FMaxAmmo
[A_BULLETS
] := AmmoLimits
[0, A_BULLETS
];
4679 FMaxAmmo
[A_SHELLS
] := AmmoLimits
[0, A_SHELLS
];
4680 FMaxAmmo
[A_ROCKETS
] := AmmoLimits
[0, A_SHELLS
];
4681 FMaxAmmo
[A_CELLS
] := AmmoLimits
[0, A_CELLS
];
4682 FMaxAmmo
[A_FUEL
] := AmmoLimits
[0, A_FUEL
];
4684 if (gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
]) and
4685 LongBool(gGameSettings
.Options
and GAME_OPTION_DMKEYS
) then
4686 FRulez
:= [R_KEY_RED
, R_KEY_GREEN
, R_KEY_BLUE
]
4691 // Ïîëó÷àåì êîîðäèíàòû òî÷êè âîçðîæäåíèÿ:
4692 if not g_Map_GetPoint(c
, RespawnPoint
) then
4694 g_FatalError(_lc
[I_GAME_ERROR_GET_SPAWN
]);
4698 // Óñòàíîâêà êîîðäèíàò è ñáðîñ âñåõ ïàðàìåòðîâ:
4699 FObj
.X
:= RespawnPoint
.X
-PLAYER_RECT
.X
;
4700 FObj
.Y
:= RespawnPoint
.Y
-PLAYER_RECT
.Y
;
4701 FObj
.oldX
:= FObj
.X
; // don't interpolate after respawn
4702 FObj
.oldY
:= FObj
.Y
;
4708 FDirection
:= RespawnPoint
.Direction
;
4709 if FDirection
= TDirection
.D_LEFT
then
4714 SetAction(A_STAND
, True);
4715 FModel
.Direction
:= FDirection
;
4717 for a
:= Low(FTime
) to High(FTime
) do
4720 for a
:= Low(FMegaRulez
) to High(FMegaRulez
) do
4723 // Respawn invulnerability
4724 if (gGameSettings
.GameType
<> GT_SINGLE
) and (gGameSettings
.SpawnInvul
> 0) then
4726 FMegaRulez
[MR_INVUL
] := gTime
+ gGameSettings
.SpawnInvul
* 1000;
4727 FSpawnInvul
:= FMegaRulez
[MR_INVUL
];
4732 FCanJetpack
:= False;
4738 // Àíèìàöèÿ âîçðîæäåíèÿ:
4739 if (not gLoadGameMode
) and (not Silent
) then
4740 if g_Frames_Get(ID
, 'FRAMES_TELEPORT') then
4742 Anim
:= TAnimation
.Create(ID
, False, 3);
4743 g_GFX_OnceAnim(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-32,
4744 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)-32, Anim
);
4748 FSpectator
:= False;
4751 FSpectatePlayer
:= -1;
4754 if (gPlayer1
= nil) and (gSpectLatchPID1
= FUID
) then
4756 if (gPlayer2
= nil) and (gSpectLatchPID2
= FUID
) then
4759 if g_Game_IsNet
then
4761 MH_SEND_PlayerPos(True, FUID
, NET_EVERYONE
);
4762 MH_SEND_PlayerStats(FUID
, NET_EVERYONE
);
4764 MH_SEND_Effect(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-32,
4765 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)-32,
4770 procedure TPlayer
.Spectate(NoMove
: Boolean = False);
4773 Kill(K_EXTRAHARDKILL
, FUID
, HIT_SOME
)
4774 else if (not NoMove
) then
4776 GameX
:= gMapInfo
.Width
div 2;
4777 GameY
:= gMapInfo
.Height
div 2;
4786 FWantsInGame
:= False;
4791 if Self
= gPlayer1
then
4793 gSpectLatchPID1
:= FUID
;
4796 else if Self
= gPlayer2
then
4798 gSpectLatchPID2
:= FUID
;
4803 if g_Game_IsNet
then
4804 MH_SEND_PlayerStats(FUID
);
4807 procedure TPlayer
.SwitchNoClip
;
4811 FGhost
:= not FGhost
;
4812 FPhysics
:= not FGhost
;
4824 procedure TPlayer
.Run(Direction
: TDirection
);
4828 if MAX_RUNVEL
> 8 then
4832 if Direction
= TDirection
.D_LEFT
then
4834 if FObj
.Vel
.X
> -MAX_RUNVEL
then
4835 FObj
.Vel
.X
:= FObj
.Vel
.X
- (MAX_RUNVEL
shr 3);
4838 if FObj
.Vel
.X
< MAX_RUNVEL
then
4839 FObj
.Vel
.X
:= FObj
.Vel
.X
+ (MAX_RUNVEL
shr 3);
4841 // Âîçìîæíî, ïèíàåì êóñêè:
4842 if (FObj
.Vel
.X
<> 0) and (gGibs
<> nil) then
4844 b
:= Abs(FObj
.Vel
.X
);
4845 if b
> 1 then b
:= b
* (Random(8 div b
) + 1);
4846 for a
:= 0 to High(gGibs
) do
4848 if gGibs
[a
].alive
and
4849 g_Obj_Collide(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
+FObj
.Rect
.Height
-4,
4850 FObj
.Rect
.Width
, 8, @gGibs
[a
].Obj
) and (Random(3) = 0) then
4853 if FObj
.Vel
.X
< 0 then
4855 g_Obj_PushA(@gGibs
[a
].Obj
, b
, Random(61)+120) // íàëåâî
4859 g_Obj_PushA(@gGibs
[a
].Obj
, b
, Random(61)); // íàïðàâî
4861 gGibs
[a
].positionChanged(); // this updates spatial accelerators
4869 procedure TPlayer
.SeeDown();
4871 SetAction(A_SEEDOWN
);
4873 if FDirection
= TDirection
.D_LEFT
then FAngle
:= ANGLE_LEFTDOWN
else FAngle
:= ANGLE_RIGHTDOWN
;
4875 if FIncCam
> -120 then DecMin(FIncCam
, 5, -120);
4878 procedure TPlayer
.SeeUp();
4882 if FDirection
= TDirection
.D_LEFT
then FAngle
:= ANGLE_LEFTUP
else FAngle
:= ANGLE_RIGHTUP
;
4884 if FIncCam
< 120 then IncMax(FIncCam
, 5, 120);
4887 procedure TPlayer
.SetAction(Action
: Byte; Force
: Boolean = False);
4895 A_ATTACK
: Prior
:= 2;
4896 A_SEEUP
: Prior
:= 1;
4897 A_SEEDOWN
: Prior
:= 1;
4898 A_ATTACKUP
: Prior
:= 2;
4899 A_ATTACKDOWN
: Prior
:= 2;
4904 if (Prior
> FActionPrior
) or Force
then
4905 if not ((Prior
= 2) and (FCurrWeap
= WEAPON_SAW
)) then
4907 FActionPrior
:= Prior
;
4908 FActionAnim
:= Action
;
4909 FActionForce
:= Force
;
4910 FActionChanged
:= True;
4913 if Action
in [A_ATTACK
, A_ATTACKUP
, A_ATTACKDOWN
] then FModel
.SetFire(True);
4916 function TPlayer
.StayOnStep(XInc
, YInc
: Integer): Boolean;
4918 Result
:= not g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+YInc
+PLAYER_RECT
.Y
+PLAYER_RECT
.Height
-1,
4919 PLAYER_RECT
.Width
, 1, PANEL_STEP
, False)
4920 and g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+YInc
+PLAYER_RECT
.Y
+PLAYER_RECT
.Height
,
4921 PLAYER_RECT
.Width
, 1, PANEL_STEP
, False);
4924 function TPlayer
.TeleportTo(X
, Y
: Integer; silent
: Boolean; dir
: Byte): Boolean;
4931 if g_CollideLevel(X
, Y
, PLAYER_RECT
.Width
, PLAYER_RECT
.Height
) then
4933 g_Sound_PlayExAt('SOUND_GAME_NOTELEPORT', FObj
.X
, FObj
.Y
);
4934 if g_Game_IsServer
and g_Game_IsNet
then
4935 MH_SEND_Sound(FObj
.X
, FObj
.Y
, 'SOUND_GAME_NOTELEPORT');
4939 FJustTeleported
:= True;
4944 if g_Frames_Get(ID
, 'FRAMES_TELEPORT') then
4946 Anim
:= TAnimation
.Create(ID
, False, 3);
4949 g_Sound_PlayExAt('SOUND_GAME_TELEPORT', FObj
.X
, FObj
.Y
);
4950 g_GFX_OnceAnim(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-32,
4951 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)-32, Anim
);
4952 if g_Game_IsServer
and g_Game_IsNet
then
4953 MH_SEND_Effect(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-32,
4954 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)-32, 1,
4958 FObj
.X
:= X
-PLAYER_RECT
.X
;
4959 FObj
.Y
:= Y
-PLAYER_RECT
.Y
;
4960 FObj
.oldX
:= FObj
.X
; // don't interpolate after respawn
4961 FObj
.oldY
:= FObj
.Y
;
4962 if FAlive
and FGhost
then
4968 if not g_Game_IsNet
then
4972 SetDirection(TDirection
.D_LEFT
);
4978 SetDirection(TDirection
.D_RIGHT
);
4984 if FDirection
= TDirection
.D_RIGHT
then
4986 SetDirection(TDirection
.D_LEFT
);
4991 SetDirection(TDirection
.D_RIGHT
);
4997 if not silent
and (Anim
<> nil) then
4999 g_GFX_OnceAnim(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-32,
5000 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)-32, Anim
);
5003 if g_Game_IsServer
and g_Game_IsNet
then
5004 MH_SEND_Effect(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-32,
5005 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)-32, 0,
5012 function nonz(a
: Single): Single;
5020 function TPlayer
.followCorpse(): Boolean;
5025 if FAlive
or FSpectator
then
5027 if (gCorpses
= nil) or (Length(gCorpses
) = 0) then
5029 for i
:= 0 to High(gCorpses
) do
5030 if gCorpses
[i
] <> nil then
5031 if gCorpses
[i
].FPlayerUID
= FUID
then
5034 FObj
.X
:= gCorpses
[i
].FObj
.X
;
5035 FObj
.Y
:= gCorpses
[i
].FObj
.Y
;
5036 FObj
.Vel
.X
:= gCorpses
[i
].FObj
.Vel
.X
;
5037 FObj
.Vel
.Y
:= gCorpses
[i
].FObj
.Vel
.Y
;
5038 FObj
.Accel
.X
:= gCorpses
[i
].FObj
.Accel
.X
;
5039 FObj
.Accel
.Y
:= gCorpses
[i
].FObj
.Accel
.Y
;
5044 procedure TPlayer
.PreUpdate();
5046 FIncCamOld
:= FIncCam
;
5047 FObj
.oldX
:= FObj
.X
;
5048 FObj
.oldY
:= FObj
.Y
;
5051 procedure TPlayer
.Update();
5054 i
, ii
, wx
, wy
, xd
, yd
, k
: Integer;
5055 blockmon
, headwater
, dospawn
: Boolean;
5060 NetServer
:= g_Game_IsNet
and g_Game_IsServer
;
5061 AnyServer
:= g_Game_IsServer
;
5067 if FClientID
>= 0 then
5069 FPing
:= NetClients
[FClientID
].Peer
^.lastRoundTripTime
;
5070 if NetClients
[FClientID
].Peer
^.packetsSent
> 0 then
5071 FLoss
:= Round(100*NetClients
[FClientID
].Peer
^.packetsLost
/NetClients
[FClientID
].Peer
^.packetsSent
)
5080 if FAlive
and (FPunchAnim
<> nil) then
5081 FPunchAnim
.Update();
5083 if FAlive
and (gFly
or FJetpack
) then
5086 if FDirection
= TDirection
.D_LEFT
then
5091 if FAlive
and (not FGhost
) then
5093 if FKeys
[KEY_UP
].Pressed
then
5095 if FKeys
[KEY_DOWN
].Pressed
then
5099 if (not (FKeys
[KEY_UP
].Pressed
or FKeys
[KEY_DOWN
].Pressed
)) and
5102 i
:= g_basic
.Sign(FIncCam
);
5103 FIncCam
:= Abs(FIncCam
);
5104 DecMin(FIncCam
, 5, 0);
5105 FIncCam
:= FIncCam
*i
;
5108 // no need to do that each second frame, weapon queue will take care of it
5109 if FAlive
and FKeys
[KEY_NEXTWEAPON
].Pressed
and AnyServer
then NextWeapon();
5110 if FAlive
and FKeys
[KEY_PREVWEAPON
].Pressed
and AnyServer
then PrevWeapon();
5112 if gTime
mod (GAME_TICK
*2) <> 0 then
5114 if (FObj
.Vel
.X
= 0) and FAlive
then
5116 if FKeys
[KEY_LEFT
].Pressed
then
5117 Run(TDirection
.D_LEFT
);
5118 if FKeys
[KEY_RIGHT
].Pressed
then
5119 Run(TDirection
.D_RIGHT
);
5124 if not followCorpse() then
5125 g_Obj_Move(@FObj
, True, True, True);
5126 positionChanged(); // this updates spatial accelerators
5132 FActionChanged
:= False;
5136 // Let alive player do some actions
5137 if FKeys
[KEY_LEFT
].Pressed
then Run(TDirection
.D_LEFT
);
5138 if FKeys
[KEY_RIGHT
].Pressed
then Run(TDirection
.D_RIGHT
);
5139 //if FKeys[KEY_NEXTWEAPON].Pressed and AnyServer then NextWeapon();
5140 //if FKeys[KEY_PREVWEAPON].Pressed and AnyServer then PrevWeapon();
5141 if FKeys
[KEY_FIRE
].Pressed
and AnyServer
then Fire()
5147 if NetServer
then MH_SEND_PlayerStats(FUID
);
5150 if FKeys
[KEY_OPEN
].Pressed
and AnyServer
then Use();
5151 if FKeys
[KEY_JUMP
].Pressed
then Jump()
5154 if AnyServer
and FJetpack
then
5158 if NetServer
then MH_SEND_PlayerStats(FUID
);
5160 FCanJetpack
:= True;
5167 for k
:= Low(FKeys
) to KEY_CHAT
-1 do
5169 if FKeys
[k
].Pressed
then
5177 if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
5180 if (FTime
[T_RESPAWN
] <= gTime
) and
5181 gGameOn
and (not FAlive
) then
5183 if (g_Player_GetCount() > 1) then
5187 gExit
:= EXIT_RESTART
;
5192 // Dead spectator actions
5195 if FKeys
[KEY_OPEN
].Pressed
and AnyServer
then Fire();
5196 if FKeys
[KEY_FIRE
].Pressed
and AnyServer
then
5200 if (FSpectatePlayer
>= High(gPlayers
)) then
5201 FSpectatePlayer
:= -1
5205 for I
:= FSpectatePlayer
+ 1 to High(gPlayers
) do
5206 if gPlayers
[I
] <> nil then
5207 if gPlayers
[I
].alive
then
5208 if gPlayers
[I
].UID
<> FUID
then
5210 FSpectatePlayer
:= I
;
5215 if not SetSpect
then FSpectatePlayer
:= -1;
5226 if FKeys
[KEY_UP
].Pressed
or FKeys
[KEY_JUMP
].Pressed
then
5228 FYTo
:= FObj
.Y
- 32;
5229 FSpectatePlayer
:= -1;
5231 if FKeys
[KEY_DOWN
].Pressed
then
5233 FYTo
:= FObj
.Y
+ 32;
5234 FSpectatePlayer
:= -1;
5236 if FKeys
[KEY_LEFT
].Pressed
then
5238 FXTo
:= FObj
.X
- 32;
5239 FSpectatePlayer
:= -1;
5241 if FKeys
[KEY_RIGHT
].Pressed
then
5243 FXTo
:= FObj
.X
+ 32;
5244 FSpectatePlayer
:= -1;
5247 if (FXTo
< -64) then
5249 else if (FXTo
> gMapInfo
.Width
+ 32) then
5250 FXTo
:= gMapInfo
.Width
+ 32;
5251 if (FYTo
< -72) then
5253 else if (FYTo
> gMapInfo
.Height
+ 32) then
5254 FYTo
:= gMapInfo
.Height
+ 32;
5259 if not followCorpse() then
5260 g_Obj_Move(@FObj
, True, True, True);
5261 positionChanged(); // this updates spatial accelerators
5268 if (FSpectatePlayer
<= High(gPlayers
)) and (FSpectatePlayer
>= 0) then
5269 if gPlayers
[FSpectatePlayer
] <> nil then
5270 if gPlayers
[FSpectatePlayer
].alive
then
5272 FXTo
:= gPlayers
[FSpectatePlayer
].GameX
;
5273 FYTo
:= gPlayers
[FSpectatePlayer
].GameY
;
5277 blockmon
:= g_Map_CollidePanel(FObj
.X
+PLAYER_HEADRECT
.X
, FObj
.Y
+PLAYER_HEADRECT
.Y
,
5278 PLAYER_HEADRECT
.Width
, PLAYER_HEADRECT
.Height
,
5279 PANEL_BLOCKMON
, True);
5280 headwater
:= HeadInLiquid(0, 0);
5282 // Ñîïðîòèâëåíèå âîçäóõà:
5283 if (not FAlive
) or not (FKeys
[KEY_LEFT
].Pressed
or FKeys
[KEY_RIGHT
].Pressed
) then
5284 if FObj
.Vel
.X
<> 0 then
5285 FObj
.Vel
.X
:= z_dec(FObj
.Vel
.X
, 1);
5287 if (FLastHit
= HIT_TRAP
) and (FPain
> 90) then FPain
:= 90;
5288 DecMin(FPain
, 5, 0);
5289 DecMin(FPickup
, 1, 0);
5291 if FAlive
and (FObj
.Y
> Integer(gMapInfo
.Height
)+128) and AnyServer
then
5293 // Îáíóëèòü äåéñòâèÿ ïðèìî÷åê, ÷òîáû ôîí ïðîïàë
5294 FMegaRulez
[MR_SUIT
] := 0;
5295 FMegaRulez
[MR_INVUL
] := 0;
5296 FMegaRulez
[MR_INVIS
] := 0;
5297 Kill(K_FALLKILL
, 0, HIT_FALL
);
5304 if FCurrWeap
= WEAPON_SAW
then
5305 if not (FSawSound
.IsPlaying() or FSawSoundHit
.IsPlaying() or
5306 FSawSoundSelect
.IsPlaying()) then
5307 FSawSoundIdle
.PlayAt(FObj
.X
, FObj
.Y
);
5310 if (not FJetSoundFly
.IsPlaying()) and (not FJetSoundOn
.IsPlaying()) and
5311 (not FJetSoundOff
.IsPlaying()) then
5313 FJetSoundFly
.SetPosition(0);
5314 FJetSoundFly
.PlayAt(FObj
.X
, FObj
.Y
);
5317 for b
:= WP_FIRST
to WP_LAST
do
5318 if FReloading
[b
] > 0 then
5324 if FShellTimer
> -1 then
5325 if FShellTimer
= 0 then
5327 if FShellType
= SHELL_SHELL
then
5328 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
5329 GameVelX
, GameVelY
-2, SHELL_SHELL
)
5330 else if FShellType
= SHELL_DBLSHELL
then
5332 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
5333 GameVelX
+1, GameVelY
-2, SHELL_SHELL
);
5334 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
5335 GameVelX
-1, GameVelY
-2, SHELL_SHELL
);
5338 end else Dec(FShellTimer
);
5340 if (FBFGFireCounter
> -1) then
5341 if FBFGFireCounter
= 0 then
5345 wx
:= FObj
.X
+WEAPONPOINT
[FDirection
].X
;
5346 wy
:= FObj
.Y
+WEAPONPOINT
[FDirection
].Y
;
5347 xd
:= wx
+IfThen(FDirection
= TDirection
.D_LEFT
, -30, 30);
5348 yd
:= wy
+firediry();
5349 g_Weapon_bfgshot(wx
, wy
, xd
, yd
, FUID
);
5350 if NetServer
then MH_SEND_PlayerFire(FUID
, WEAPON_BFG
, wx
, wy
, xd
, yd
);
5351 if (FAngle
= 0) or (FAngle
= 180) then SetAction(A_ATTACK
)
5352 else if (FAngle
= ANGLE_LEFTDOWN
) or (FAngle
= ANGLE_RIGHTDOWN
) then SetAction(A_ATTACKDOWN
)
5353 else if (FAngle
= ANGLE_LEFTUP
) or (FAngle
= ANGLE_RIGHTUP
) then SetAction(A_ATTACKUP
);
5356 FReloading
[WEAPON_BFG
] := WEAPON_RELOAD
[WEAPON_BFG
];
5357 FBFGFireCounter
:= -1;
5360 FBFGFireCounter
:= 0
5362 Dec(FBFGFireCounter
);
5364 if (FMegaRulez
[MR_SUIT
] < gTime
) and AnyServer
then
5366 b
:= g_GetAcidHit(FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+PLAYER_RECT
.Y
, PLAYER_RECT
.Width
, PLAYER_RECT
.Height
);
5368 if (b
> 0) and (gTime
mod (15*GAME_TICK
) = 0) then Damage(b
, 0, 0, 0, HIT_ACID
);
5371 if (headwater
or blockmon
) then
5377 if AnyServer
then Damage(10, 0, 0, 0, HIT_WATER
);
5380 else if (FAir
mod 31 = 0) and not blockmon
then
5382 g_GFX_Bubbles(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2), FObj
.Y
+PLAYER_RECT
.Y
-4, 5+Random(6), 8, 4);
5383 if Random(2) = 0 then
5384 g_Sound_PlayExAt('SOUND_GAME_BUBBLE1', FObj
.X
, FObj
.Y
)
5386 g_Sound_PlayExAt('SOUND_GAME_BUBBLE2', FObj
.X
, FObj
.Y
);
5388 end else if FAir
< AIR_DEF
then
5391 if FFireTime
> 0 then
5393 if BodyInLiquid(0, 0) then
5398 else if FMegaRulez
[MR_SUIT
] >= gTime
then
5400 if FMegaRulez
[MR_SUIT
] = gTime
then
5407 if FFirePainTime
<= 0 then
5409 if g_Game_IsServer
then
5410 Damage(2, FFireAttacker
, 0, 0, HIT_FLAME
);
5411 FFirePainTime
:= 12 - FFireTime
div 12;
5413 FFirePainTime
:= FFirePainTime
- 1;
5414 FFireTime
:= FFireTime
- 1;
5415 if ((FFireTime
mod 33) = 0) and (FMegaRulez
[MR_INVUL
] < gTime
) then
5416 FModel
.PlaySound(MODELSOUND_PAIN
, 1, FObj
.X
, FObj
.Y
);
5417 if (FFireTime
= 0) and g_Game_IsNet
and g_Game_IsServer
then
5418 MH_SEND_PlayerStats(FUID
);
5422 if FDamageBuffer
> 0 then
5424 if FDamageBuffer
>= 9 then
5428 if FDamageBuffer
< 30 then i
:= 9
5429 else if FDamageBuffer
< 100 then i
:= 18
5433 ii
:= Round(FDamageBuffer
*FHealth
/ nonz(FArmor
*(3/4)+FHealth
));
5434 FArmor
:= FArmor
-(FDamageBuffer
-ii
);
5435 FHealth
:= FHealth
-ii
;
5438 FHealth
:= FHealth
+FArmor
;
5443 if FHealth
<= 0 then
5444 if FHealth
> -30 then Kill(K_SIMPLEKILL
, FLastSpawnerUID
, FLastHit
)
5445 else if FHealth
> -50 then Kill(K_HARDKILL
, FLastSpawnerUID
, FLastHit
)
5446 else Kill(K_EXTRAHARDKILL
, FLastSpawnerUID
, FLastHit
);
5448 if FAlive
and ((FLastHit
<> HIT_FLAME
) or (FFireTime
<= 0)) then
5450 if FDamageBuffer
<= 20 then FModel
.PlaySound(MODELSOUND_PAIN
, 1, FObj
.X
, FObj
.Y
)
5451 else if FDamageBuffer
<= 55 then FModel
.PlaySound(MODELSOUND_PAIN
, 2, FObj
.X
, FObj
.Y
)
5452 else if FDamageBuffer
<= 120 then FModel
.PlaySound(MODELSOUND_PAIN
, 3, FObj
.X
, FObj
.Y
)
5453 else FModel
.PlaySound(MODELSOUND_PAIN
, 4, FObj
.X
, FObj
.Y
);
5460 end; // if FAlive then ...
5462 if (FActionAnim
= A_PAIN
) and (FModel
.Animation
<> A_PAIN
) then
5464 FModel
.ChangeAnimation(FActionAnim
, FActionForce
);
5465 FModel
.GetCurrentAnimation
.MinLength
:= i
;
5466 FModel
.GetCurrentAnimationMask
.MinLength
:= i
;
5467 end else FModel
.ChangeAnimation(FActionAnim
, FActionForce
and (FModel
.Animation
<> A_STAND
));
5469 if (FModel
.GetCurrentAnimation
.Played
or ((not FActionChanged
) and (FModel
.Animation
= A_WALK
)))
5470 then SetAction(A_STAND
, True);
5472 if not ((FModel
.Animation
= A_WALK
) and (Abs(FObj
.Vel
.X
) < 4) and not FModel
.Fire
) then FModel
.Update
;
5474 for b
:= Low(FKeys
) to High(FKeys
) do
5475 if FKeys
[b
].Time
= 0 then FKeys
[b
].Pressed
:= False else Dec(FKeys
[b
].Time
);
5479 procedure TPlayer
.getMapBox (out x
, y
, w
, h
: Integer); inline;
5481 x
:= FObj
.X
+PLAYER_RECT
.X
;
5482 y
:= FObj
.Y
+PLAYER_RECT
.Y
;
5483 w
:= PLAYER_RECT
.Width
;
5484 h
:= PLAYER_RECT
.Height
;
5488 procedure TPlayer
.moveBy (dx
, dy
: Integer); inline;
5490 if (dx
<> 0) or (dy
<> 0) then
5499 function TPlayer
.Collide(X
, Y
: Integer; Width
, Height
: Word): Boolean;
5501 Result
:= g_Collide(FObj
.X
+PLAYER_RECT
.X
,
5502 FObj
.Y
+PLAYER_RECT
.Y
,
5509 function TPlayer
.Collide(Panel
: TPanel
): Boolean;
5511 Result
:= g_Collide(FObj
.X
+PLAYER_RECT
.X
,
5512 FObj
.Y
+PLAYER_RECT
.Y
,
5516 Panel
.Width
, Panel
.Height
);
5519 function TPlayer
.Collide(X
, Y
: Integer): Boolean;
5521 X
:= X
-FObj
.X
-PLAYER_RECT
.X
;
5522 Y
:= Y
-FObj
.Y
-PLAYER_RECT
.Y
;
5523 Result
:= (x
>= 0) and (x
<= PLAYER_RECT
.Width
) and
5524 (y
>= 0) and (y
<= PLAYER_RECT
.Height
);
5527 function g_Player_ValidName(Name
: string): Boolean;
5533 if gPlayers
= nil then Exit
;
5535 for a
:= 0 to High(gPlayers
) do
5536 if gPlayers
[a
] <> nil then
5537 if LowerCase(Name
) = LowerCase(gPlayers
[a
].FName
) then
5544 procedure TPlayer
.SetDirection(Direction
: TDirection
);
5548 d
:= FModel
.Direction
;
5550 FModel
.Direction
:= Direction
;
5551 if d
<> Direction
then FModel
.ChangeAnimation(FModel
.Animation
, True);
5553 FDirection
:= Direction
;
5556 function TPlayer
.GetKeys(): Byte;
5560 if R_KEY_RED
in FRulez
then Result
:= KEY_RED
;
5561 if R_KEY_GREEN
in FRulez
then Result
:= Result
or KEY_GREEN
;
5562 if R_KEY_BLUE
in FRulez
then Result
:= Result
or KEY_BLUE
;
5564 if FTeam
= TEAM_RED
then Result
:= Result
or KEY_REDTEAM
;
5565 if FTeam
= TEAM_BLUE
then Result
:= Result
or KEY_BLUETEAM
;
5568 procedure TPlayer
.Use();
5572 if FTime
[T_USE
] > gTime
then Exit
;
5574 g_Triggers_PressR(FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+PLAYER_RECT
.Y
, PLAYER_RECT
.Width
,
5575 PLAYER_RECT
.Height
, FUID
, ACTIVATE_PLAYERPRESS
);
5577 for a
:= 0 to High(gPlayers
) do
5578 if (gPlayers
[a
] <> nil) and (gPlayers
[a
] <> Self
) and
5579 gPlayers
[a
].alive
and SameTeam(FUID
, gPlayers
[a
].FUID
) and
5580 g_Obj_Collide(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
,
5581 FObj
.Rect
.Width
, FObj
.Rect
.Height
, @gPlayers
[a
].FObj
) then
5583 gPlayers
[a
].Touch();
5584 if g_Game_IsNet
and g_Game_IsServer
then
5585 MH_SEND_GameEvent(NET_EV_PLAYER_TOUCH
, gPlayers
[a
].FUID
);
5588 FTime
[T_USE
] := gTime
+120;
5591 procedure TPlayer
.NetFire(Wpn
: Byte; X
, Y
, AX
, AY
: Integer; WID
: Integer = -1);
5595 WX
, WY
, XD
, YD
: Integer;
5607 if R_BERSERK
in FRulez
then
5609 //g_Weapon_punch(FObj.X+FObj.Rect.X, FObj.Y+FObj.Rect.Y, 75, FUID);
5610 locobj
.X
:= FObj
.X
+FObj
.Rect
.X
;
5611 locobj
.Y
:= FObj
.Y
+FObj
.Rect
.Y
;
5614 locobj
.rect
.Width
:= 39;
5615 locobj
.rect
.Height
:= 52;
5616 locobj
.Vel
.X
:= (xd
-wx
) div 2;
5617 locobj
.Vel
.Y
:= (yd
-wy
) div 2;
5618 locobj
.Accel
.X
:= xd
-wx
;
5619 locobj
.Accel
.y
:= yd
-wy
;
5621 if g_Weapon_Hit(@locobj
, 50, FUID
, HIT_SOME
) <> 0 then
5622 g_Sound_PlayExAt('SOUND_WEAPON_HITBERSERK', FObj
.X
, FObj
.Y
)
5624 g_Sound_PlayExAt('SOUND_WEAPON_MISSBERSERK', FObj
.X
, FObj
.Y
);
5628 FPain
:= min(FPain
+ 25, 50);
5630 g_Weapon_punch(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
, 3, FUID
);
5635 if g_Weapon_chainsaw(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
,
5636 IfThen(gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
], 9, 3), FUID
) <> 0 then
5638 FSawSoundSelect
.Stop();
5640 FSawSoundHit
.PlayAt(FObj
.X
, FObj
.Y
);
5642 else if not FSawSoundHit
.IsPlaying() then
5644 FSawSoundSelect
.Stop();
5645 FSawSound
.PlayAt(FObj
.X
, FObj
.Y
);
5652 g_Sound_PlayExAt('SOUND_WEAPON_FIREPISTOL', GameX
, Gamey
);
5653 FFireAngle
:= FAngle
;
5655 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
5656 GameVelX
, GameVelY
-2, SHELL_BULLET
);
5661 g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN', Gamex
, Gamey
);
5662 FFireAngle
:= FAngle
;
5665 FShellType
:= SHELL_SHELL
;
5670 g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN2', Gamex
, Gamey
);
5671 FFireAngle
:= FAngle
;
5674 FShellType
:= SHELL_DBLSHELL
;
5679 g_Sound_PlayExAt('SOUND_WEAPON_FIRECGUN', Gamex
, Gamey
);
5680 FFireAngle
:= FAngle
;
5682 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
5683 GameVelX
, GameVelY
-2, SHELL_BULLET
);
5686 WEAPON_ROCKETLAUNCHER
:
5688 g_Weapon_Rocket(wx
, wy
, xd
, yd
, FUID
, WID
);
5689 FFireAngle
:= FAngle
;
5695 g_Weapon_Plasma(wx
, wy
, xd
, yd
, FUID
, WID
);
5696 FFireAngle
:= FAngle
;
5702 g_Weapon_BFGShot(wx
, wy
, xd
, yd
, FUID
, WID
);
5703 FFireAngle
:= FAngle
;
5707 WEAPON_SUPERPULEMET
:
5709 g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN', Gamex
, Gamey
);
5710 FFireAngle
:= FAngle
;
5712 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
5713 GameVelX
, GameVelY
-2, SHELL_SHELL
);
5716 WEAPON_FLAMETHROWER
:
5718 g_Weapon_flame(wx
, wy
, xd
, yd
, FUID
, WID
);
5720 FFireAngle
:= FAngle
;
5727 if (FAngle
= 0) or (FAngle
= 180) then SetAction(A_ATTACK
)
5728 else if (FAngle
= ANGLE_LEFTDOWN
) or (FAngle
= ANGLE_RIGHTDOWN
) then SetAction(A_ATTACKDOWN
)
5729 else if (FAngle
= ANGLE_LEFTUP
) or (FAngle
= ANGLE_RIGHTUP
) then SetAction(A_ATTACKUP
);
5732 procedure TPlayer
.DoLerp(Level
: Integer = 2);
5734 if FObj
.X
<> FXTo
then FObj
.X
:= Lerp(FObj
.X
, FXTo
, Level
);
5735 if FObj
.Y
<> FYTo
then FObj
.Y
:= Lerp(FObj
.Y
, FYTo
, Level
);
5738 procedure TPlayer
.SetLerp(XTo
, YTo
: Integer);
5742 if NetInterpLevel
< 1 then
5752 AX
:= Abs(FXTo
- FObj
.X
);
5753 AY
:= Abs(FYTo
- FObj
.Y
);
5754 if (AX
> 32) or (AX
<= NetInterpLevel
) then
5756 if (AY
> 32) or (AY
<= NetInterpLevel
) then
5761 function TPlayer
.FullInLift(XInc
, YInc
: Integer): Integer;
5763 if g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
,
5764 PLAYER_RECT
.Width
, PLAYER_RECT
.Height
-8,
5765 PANEL_LIFTUP
, False) then Result
:= -1
5767 if g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
,
5768 PLAYER_RECT
.Width
, PLAYER_RECT
.Height
-8,
5769 PANEL_LIFTDOWN
, False) then Result
:= 1
5773 function TPlayer
.GetFlag(Flag
: Byte): Boolean;
5780 if Flag
= FLAG_NONE
then
5783 if not g_Game_IsServer
then Exit
;
5785 // Ïðèíåñ ÷óæîé ôëàã íà ñâîþ áàçó:
5786 if (Flag
= FTeam
) and
5787 (gFlags
[Flag
].State
= FLAG_STATE_NORMAL
) and
5788 (FFlag
<> FLAG_NONE
) then
5790 if FFlag
= FLAG_RED
then
5791 s
:= _lc
[I_PLAYER_FLAG_RED
]
5793 s
:= _lc
[I_PLAYER_FLAG_BLUE
];
5795 evtype
:= FLAG_STATE_SCORED
;
5797 ts
:= Format('%.4d', [gFlags
[FFlag
].CaptureTime
]);
5798 Insert('.', ts
, Length(ts
) + 1 - 3);
5799 g_Console_Add(Format(_lc
[I_PLAYER_FLAG_CAPTURE
], [FName
, s
, ts
]), True);
5801 g_Map_ResetFlag(FFlag
);
5802 g_Game_Message(Format(_lc
[I_MESSAGE_FLAG_CAPTURE
], [AnsiUpperCase(s
)]), 144);
5804 if ((Self
= gPlayer1
) or (Self
= gPlayer2
)
5805 or ((gPlayer1
<> nil) and (gPlayer1
.Team
= FTeam
))
5806 or ((gPlayer2
<> nil) and (gPlayer2
.Team
= FTeam
))) then
5811 if not sound_cap_flag
[a
].IsPlaying() then
5812 sound_cap_flag
[a
].Play();
5814 gTeamStat
[FTeam
].Goals
:= gTeamStat
[FTeam
].Goals
+ 1;
5817 if g_Game_IsNet
then
5819 MH_SEND_FlagEvent(evtype
, FFlag
, FUID
, False);
5823 gFlags
[FFlag
].CaptureTime
:= 0;
5828 // Ïîäîáðàë ñâîé ôëàã - âåðíóë åãî íà áàçó:
5829 if (Flag
= FTeam
) and
5830 (gFlags
[Flag
].State
= FLAG_STATE_DROPPED
) then
5832 if Flag
= FLAG_RED
then
5833 s
:= _lc
[I_PLAYER_FLAG_RED
]
5835 s
:= _lc
[I_PLAYER_FLAG_BLUE
];
5837 evtype
:= FLAG_STATE_RETURNED
;
5838 gFlags
[Flag
].CaptureTime
:= 0;
5840 g_Console_Add(Format(_lc
[I_PLAYER_FLAG_RETURN
], [FName
, s
]), True);
5842 g_Map_ResetFlag(Flag
);
5843 g_Game_Message(Format(_lc
[I_MESSAGE_FLAG_RETURN
], [AnsiUpperCase(s
)]), 144);
5845 if ((Self
= gPlayer1
) or (Self
= gPlayer2
)
5846 or ((gPlayer1
<> nil) and (gPlayer1
.Team
= FTeam
))
5847 or ((gPlayer2
<> nil) and (gPlayer2
.Team
= FTeam
))) then
5852 if not sound_ret_flag
[a
].IsPlaying() then
5853 sound_ret_flag
[a
].Play();
5856 if g_Game_IsNet
then
5858 MH_SEND_FlagEvent(evtype
, Flag
, FUID
, False);
5864 // Ïîäîáðàë ÷óæîé ôëàã:
5865 if (Flag
<> FTeam
) and (FTime
[T_FLAGCAP
] <= gTime
) then
5869 if Flag
= FLAG_RED
then
5870 s
:= _lc
[I_PLAYER_FLAG_RED
]
5872 s
:= _lc
[I_PLAYER_FLAG_BLUE
];
5874 evtype
:= FLAG_STATE_CAPTURED
;
5876 g_Console_Add(Format(_lc
[I_PLAYER_FLAG_GET
], [FName
, s
]), True);
5878 g_Game_Message(Format(_lc
[I_MESSAGE_FLAG_GET
], [AnsiUpperCase(s
)]), 144);
5880 gFlags
[Flag
].State
:= FLAG_STATE_CAPTURED
;
5882 if ((Self
= gPlayer1
) or (Self
= gPlayer2
)
5883 or ((gPlayer1
<> nil) and (gPlayer1
.Team
= FTeam
))
5884 or ((gPlayer2
<> nil) and (gPlayer2
.Team
= FTeam
))) then
5889 if not sound_get_flag
[a
].IsPlaying() then
5890 sound_get_flag
[a
].Play();
5893 if g_Game_IsNet
then
5895 MH_SEND_FlagEvent(evtype
, Flag
, FUID
, False);
5901 procedure TPlayer
.SetFlag(Flag
: Byte);
5904 if FModel
<> nil then
5905 FModel
.SetFlag(FFlag
);
5908 function TPlayer
.DropFlag(Silent
: Boolean = True): Boolean;
5914 if (not g_Game_IsServer
) or (FFlag
= FLAG_NONE
) then
5916 FTime
[T_FLAGCAP
] := gTime
+ 2000;
5917 with gFlags
[FFlag
] do
5921 Direction
:= FDirection
;
5922 State
:= FLAG_STATE_DROPPED
;
5924 g_Obj_Push(@Obj
, (FObj
.Vel
.X
div 2)-2+Random(5),
5925 (FObj
.Vel
.Y
div 2)-2+Random(5));
5926 positionChanged(); // this updates spatial accelerators
5928 if FFlag
= FLAG_RED
then
5929 s
:= _lc
[I_PLAYER_FLAG_RED
]
5931 s
:= _lc
[I_PLAYER_FLAG_BLUE
];
5933 g_Console_Add(Format(_lc
[I_PLAYER_FLAG_DROP
], [FName
, s
]), True);
5934 g_Game_Message(Format(_lc
[I_MESSAGE_FLAG_DROP
], [AnsiUpperCase(s
)]), 144);
5936 if ((Self
= gPlayer1
) or (Self
= gPlayer2
)
5937 or ((gPlayer1
<> nil) and (gPlayer1
.Team
= FTeam
))
5938 or ((gPlayer2
<> nil) and (gPlayer2
.Team
= FTeam
))) then
5943 if (not Silent
) and (not sound_lost_flag
[a
].IsPlaying()) then
5944 sound_lost_flag
[a
].Play();
5946 if g_Game_IsNet
then
5947 MH_SEND_FlagEvent(FLAG_STATE_DROPPED
, Flag
, FUID
, False);
5953 procedure TPlayer
.GetSecret();
5955 if (self
= gPlayer1
) or (self
= gPlayer2
) then
5957 g_Console_Add(Format(_lc
[I_PLAYER_SECRET
], [FName
]), True);
5958 g_Sound_PlayEx('SOUND_GAME_SECRET');
5963 procedure TPlayer
.PressKey(Key
: Byte; Time
: Word = 1);
5965 Assert(Key
<= High(FKeys
));
5967 FKeys
[Key
].Pressed
:= True;
5968 FKeys
[Key
].Time
:= Time
;
5971 function TPlayer
.IsKeyPressed(K
: Byte): Boolean;
5973 Result
:= FKeys
[K
].Pressed
;
5976 procedure TPlayer
.ReleaseKeys();
5980 for a
:= Low(FKeys
) to High(FKeys
) do
5982 FKeys
[a
].Pressed
:= False;
5987 procedure TPlayer
.OnDamage(Angle
: SmallInt);
5991 function TPlayer
.firediry(): Integer;
5993 if FKeys
[KEY_UP
].Pressed
then Result
:= -42
5994 else if FKeys
[KEY_DOWN
].Pressed
then Result
:= 19
5998 procedure TPlayer
.RememberState();
6001 SavedState
: TPlayerSavedState
;
6003 SavedState
.Health
:= FHealth
;
6004 SavedState
.Armor
:= FArmor
;
6005 SavedState
.Air
:= FAir
;
6006 SavedState
.JetFuel
:= FJetFuel
;
6007 SavedState
.CurrWeap
:= FCurrWeap
;
6008 SavedState
.NextWeap
:= FNextWeap
;
6009 SavedState
.NextWeapDelay
:= FNextWeapDelay
;
6010 for i
:= Low(FWeapon
) to High(FWeapon
) do
6011 SavedState
.Weapon
[i
] := FWeapon
[i
];
6012 for i
:= Low(FAmmo
) to High(FAmmo
) do
6013 SavedState
.Ammo
[i
] := FAmmo
[i
];
6014 for i
:= Low(FMaxAmmo
) to High(FMaxAmmo
) do
6015 SavedState
.MaxAmmo
[i
] := FMaxAmmo
[i
];
6016 SavedState
.Rulez
:= FRulez
- [R_KEY_RED
, R_KEY_GREEN
, R_KEY_BLUE
];
6018 FSavedStateNum
:= -1;
6019 for i
:= Low(SavedStates
) to High(SavedStates
) do
6020 if not SavedStates
[i
].Used
then
6022 FSavedStateNum
:= i
;
6025 if FSavedStateNum
< 0 then
6027 SetLength(SavedStates
, Length(SavedStates
) + 1);
6028 FSavedStateNum
:= High(SavedStates
);
6031 SavedState
.Used
:= True;
6032 SavedStates
[FSavedStateNum
] := SavedState
;
6035 procedure TPlayer
.RecallState();
6038 SavedState
: TPlayerSavedState
;
6040 if(FSavedStateNum
< 0) or (FSavedStateNum
> High(SavedStates
)) then
6043 SavedState
:= SavedStates
[FSavedStateNum
];
6044 SavedStates
[FSavedStateNum
].Used
:= False;
6045 FSavedStateNum
:= -1;
6047 FHealth
:= SavedState
.Health
;
6048 FArmor
:= SavedState
.Armor
;
6049 FAir
:= SavedState
.Air
;
6050 FJetFuel
:= SavedState
.JetFuel
;
6051 FCurrWeap
:= SavedState
.CurrWeap
;
6052 FNextWeap
:= SavedState
.NextWeap
;
6053 FNextWeapDelay
:= SavedState
.NextWeapDelay
;
6054 for i
:= Low(FWeapon
) to High(FWeapon
) do
6055 FWeapon
[i
] := SavedState
.Weapon
[i
];
6056 for i
:= Low(FAmmo
) to High(FAmmo
) do
6057 FAmmo
[i
] := SavedState
.Ammo
[i
];
6058 for i
:= Low(FMaxAmmo
) to High(FMaxAmmo
) do
6059 FMaxAmmo
[i
] := SavedState
.MaxAmmo
[i
];
6060 FRulez
:= SavedState
.Rulez
;
6062 if gGameSettings
.GameType
= GT_SERVER
then
6063 MH_SEND_PlayerStats(FUID
);
6066 procedure TPlayer
.SaveState (st
: TStream
);
6072 utils
.writeSign(st
, 'PLYR');
6073 utils
.writeInt(st
, Byte(PLR_SAVE_VERSION
)); // version
6075 utils
.writeBool(st
, FIamBot
);
6077 utils
.writeInt(st
, Word(FUID
));
6079 utils
.writeStr(st
, FName
);
6081 utils
.writeInt(st
, Byte(FTeam
));
6083 utils
.writeBool(st
, FAlive
);
6084 // Èçðàñõîäîâàë ëè âñå æèçíè
6085 utils
.writeBool(st
, FNoRespawn
);
6087 if FDirection
= TDirection
.D_LEFT
then b
:= 1 else b
:= 2; // D_RIGHT
6088 utils
.writeInt(st
, Byte(b
));
6090 utils
.writeInt(st
, LongInt(FHealth
));
6091 // Êîýôôèöèåíò èíâàëèäíîñòè
6092 utils
.writeInt(st
, LongInt(FHandicap
));
6094 utils
.writeInt(st
, Byte(FLives
));
6096 utils
.writeInt(st
, LongInt(FArmor
));
6098 utils
.writeInt(st
, LongInt(FAir
));
6100 utils
.writeInt(st
, LongInt(FJetFuel
));
6102 utils
.writeInt(st
, LongInt(FPain
));
6104 utils
.writeInt(st
, LongInt(FKills
));
6106 utils
.writeInt(st
, LongInt(FMonsterKills
));
6108 utils
.writeInt(st
, LongInt(FFrags
));
6110 utils
.writeInt(st
, Byte(FFragCombo
));
6111 // Âðåìÿ ïîñëåäíåãî ôðàãà
6112 utils
.writeInt(st
, LongWord(FLastFrag
));
6114 utils
.writeInt(st
, LongInt(FDeath
));
6116 utils
.writeInt(st
, Byte(FFlag
));
6118 utils
.writeInt(st
, LongInt(FSecrets
));
6120 utils
.writeInt(st
, Byte(FCurrWeap
));
6122 utils
.writeInt(st
, Word(FNextWeap
));
6124 utils
.writeInt(st
, Byte(FNextWeapDelay
));
6125 // Âðåìÿ çàðÿäêè BFG
6126 utils
.writeInt(st
, SmallInt(FBFGFireCounter
));
6128 utils
.writeInt(st
, LongInt(FDamageBuffer
));
6129 // Ïîñëåäíèé óäàðèâøèé
6130 utils
.writeInt(st
, Word(FLastSpawnerUID
));
6131 // Òèï ïîñëåäíåãî ïîëó÷åííîãî óðîíà
6132 utils
.writeInt(st
, Byte(FLastHit
));
6134 Obj_SaveState(st
, @FObj
);
6135 // Òåêóùåå êîëè÷åñòâî ïàòðîíîâ
6136 for i
:= A_BULLETS
to A_HIGH
do utils
.writeInt(st
, Word(FAmmo
[i
]));
6137 // Ìàêñèìàëüíîå êîëè÷åñòâî ïàòðîíîâ
6138 for i
:= A_BULLETS
to A_HIGH
do utils
.writeInt(st
, Word(FMaxAmmo
[i
]));
6140 for i
:= WP_FIRST
to WP_LAST
do utils
.writeBool(st
, FWeapon
[i
]);
6141 // Âðåìÿ ïåðåçàðÿäêè îðóæèÿ
6142 for i
:= WP_FIRST
to WP_LAST
do utils
.writeInt(st
, Word(FReloading
[i
]));
6144 utils
.writeBool(st
, (R_ITEM_BACKPACK
in FRulez
));
6145 // Íàëè÷èå êðàñíîãî êëþ÷à
6146 utils
.writeBool(st
, (R_KEY_RED
in FRulez
));
6147 // Íàëè÷èå çåëåíîãî êëþ÷à
6148 utils
.writeBool(st
, (R_KEY_GREEN
in FRulez
));
6149 // Íàëè÷èå ñèíåãî êëþ÷à
6150 utils
.writeBool(st
, (R_KEY_BLUE
in FRulez
));
6152 utils
.writeBool(st
, (R_BERSERK
in FRulez
));
6153 // Âðåìÿ äåéñòâèÿ ñïåöèàëüíûõ ïðåäìåòîâ
6154 for i
:= MR_SUIT
to MR_MAX
do utils
.writeInt(st
, LongWord(FMegaRulez
[i
]));
6155 // Âðåìÿ äî ïîâòîðíîãî ðåñïàóíà, ñìåíû îðóæèÿ, èñîëüçîâàíèÿ, çàõâàòà ôëàãà
6156 for i
:= T_RESPAWN
to T_FLAGCAP
do utils
.writeInt(st
, LongWord(FTime
[i
]));
6158 utils
.writeStr(st
, FModel
.Name
);
6160 utils
.writeInt(st
, Byte(FColor
.R
));
6161 utils
.writeInt(st
, Byte(FColor
.G
));
6162 utils
.writeInt(st
, Byte(FColor
.B
));
6166 procedure TPlayer
.LoadState (st
: TStream
);
6175 if not utils
.checkSign(st
, 'PLYR') then raise XStreamError
.Create('invalid player signature');
6176 if (utils
.readByte(st
) <> PLR_SAVE_VERSION
) then raise XStreamError
.Create('invalid player version');
6178 FIamBot
:= utils
.readBool(st
);
6180 FUID
:= utils
.readWord(st
);
6182 str
:= utils
.readStr(st
);
6183 if (self
<> gPlayer1
) and (self
<> gPlayer2
) then FName
:= str
;
6185 FTeam
:= utils
.readByte(st
);
6187 FAlive
:= utils
.readBool(st
);
6188 // Èçðàñõîäîâàë ëè âñå æèçíè
6189 FNoRespawn
:= utils
.readBool(st
);
6191 b
:= utils
.readByte(st
);
6192 if b
= 1 then FDirection
:= TDirection
.D_LEFT
else FDirection
:= TDirection
.D_RIGHT
; // b = 2
6194 FHealth
:= utils
.readLongInt(st
);
6195 // Êîýôôèöèåíò èíâàëèäíîñòè
6196 FHandicap
:= utils
.readLongInt(st
);
6198 FLives
:= utils
.readByte(st
);
6200 FArmor
:= utils
.readLongInt(st
);
6202 FAir
:= utils
.readLongInt(st
);
6204 FJetFuel
:= utils
.readLongInt(st
);
6206 FPain
:= utils
.readLongInt(st
);
6208 FKills
:= utils
.readLongInt(st
);
6210 FMonsterKills
:= utils
.readLongInt(st
);
6212 FFrags
:= utils
.readLongInt(st
);
6214 FFragCombo
:= utils
.readByte(st
);
6215 // Âðåìÿ ïîñëåäíåãî ôðàãà
6216 FLastFrag
:= utils
.readLongWord(st
);
6218 FDeath
:= utils
.readLongInt(st
);
6220 FFlag
:= utils
.readByte(st
);
6222 FSecrets
:= utils
.readLongInt(st
);
6224 FCurrWeap
:= utils
.readByte(st
);
6226 FNextWeap
:= utils
.readWord(st
);
6228 FNextWeapDelay
:= utils
.readByte(st
);
6229 // Âðåìÿ çàðÿäêè BFG
6230 FBFGFireCounter
:= utils
.readSmallInt(st
);
6232 FDamageBuffer
:= utils
.readLongInt(st
);
6233 // Ïîñëåäíèé óäàðèâøèé
6234 FLastSpawnerUID
:= utils
.readWord(st
);
6235 // Òèï ïîñëåäíåãî ïîëó÷åííîãî óðîíà
6236 FLastHit
:= utils
.readByte(st
);
6238 Obj_LoadState(@FObj
, st
);
6239 // Òåêóùåå êîëè÷åñòâî ïàòðîíîâ
6240 for i
:= A_BULLETS
to A_HIGH
do FAmmo
[i
] := utils
.readWord(st
);
6241 // Ìàêñèìàëüíîå êîëè÷åñòâî ïàòðîíîâ
6242 for i
:= A_BULLETS
to A_HIGH
do FMaxAmmo
[i
] := utils
.readWord(st
);
6244 for i
:= WP_FIRST
to WP_LAST
do FWeapon
[i
] := utils
.readBool(st
);
6245 // Âðåìÿ ïåðåçàðÿäêè îðóæèÿ
6246 for i
:= WP_FIRST
to WP_LAST
do FReloading
[i
] := utils
.readWord(st
);
6248 if utils
.readBool(st
) then Include(FRulez
, R_ITEM_BACKPACK
);
6249 // Íàëè÷èå êðàñíîãî êëþ÷à
6250 if utils
.readBool(st
) then Include(FRulez
, R_KEY_RED
);
6251 // Íàëè÷èå çåëåíîãî êëþ÷à
6252 if utils
.readBool(st
) then Include(FRulez
, R_KEY_GREEN
);
6253 // Íàëè÷èå ñèíåãî êëþ÷à
6254 if utils
.readBool(st
) then Include(FRulez
, R_KEY_BLUE
);
6256 if utils
.readBool(st
) then Include(FRulez
, R_BERSERK
);
6257 // Âðåìÿ äåéñòâèÿ ñïåöèàëüíûõ ïðåäìåòîâ
6258 for i
:= MR_SUIT
to MR_MAX
do FMegaRulez
[i
] := utils
.readLongWord(st
);
6259 // Âðåìÿ äî ïîâòîðíîãî ðåñïàóíà, ñìåíû îðóæèÿ, èñîëüçîâàíèÿ, çàõâàòà ôëàãà
6260 for i
:= T_RESPAWN
to T_FLAGCAP
do FTime
[i
] := utils
.readLongWord(st
);
6262 str
:= utils
.readStr(st
);
6264 FColor
.R
:= utils
.readByte(st
);
6265 FColor
.G
:= utils
.readByte(st
);
6266 FColor
.B
:= utils
.readByte(st
);
6267 if (self
= gPlayer1
) then
6269 str
:= gPlayer1Settings
.Model
;
6270 FColor
:= gPlayer1Settings
.Color
;
6272 else if (self
= gPlayer2
) then
6274 str
:= gPlayer2Settings
.Model
;
6275 FColor
:= gPlayer2Settings
.Color
;
6277 // Îáíîâëÿåì ìîäåëü èãðîêà
6279 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
6280 FModel
.Color
:= TEAMCOLOR
[FTeam
]
6282 FModel
.Color
:= FColor
;
6286 procedure TPlayer
.AllRulez(Health
: Boolean);
6292 FHealth
:= PLAYER_HP_LIMIT
;
6293 FArmor
:= PLAYER_AP_LIMIT
;
6297 for a
:= WP_FIRST
to WP_LAST
do FWeapon
[a
] := True;
6298 for a
:= A_BULLETS
to A_HIGH
do FAmmo
[a
] := 30000;
6299 FRulez
:= FRulez
+[R_KEY_RED
, R_KEY_GREEN
, R_KEY_BLUE
];
6302 procedure TPlayer
.RestoreHealthArmor();
6304 FHealth
:= PLAYER_HP_LIMIT
;
6305 FArmor
:= PLAYER_AP_LIMIT
;
6308 procedure TPlayer
.FragCombo();
6312 if (gGameSettings
.GameMode
in [GM_COOP
, GM_SINGLE
]) or g_Game_IsClient
then
6314 if gTime
- FLastFrag
< FRAG_COMBO_TIME
then
6316 if FFragCombo
< 5 then
6318 Param
:= FUID
or (FFragCombo
shl 16);
6319 if (FComboEvnt
>= Low(gDelayedEvents
)) and
6320 (FComboEvnt
<= High(gDelayedEvents
)) and
6321 gDelayedEvents
[FComboEvnt
].Pending
and
6322 (gDelayedEvents
[FComboEvnt
].DEType
= DE_KILLCOMBO
) and
6323 (gDelayedEvents
[FComboEvnt
].DENum
and $FFFF = FUID
) then
6325 gDelayedEvents
[FComboEvnt
].Time
:= gTime
+ 500;
6326 gDelayedEvents
[FComboEvnt
].DENum
:= Param
;
6329 FComboEvnt
:= g_Game_DelayEvent(DE_KILLCOMBO
, 500, Param
);
6337 procedure TPlayer
.GiveItem(ItemType
: Byte);
6341 if FMegaRulez
[MR_SUIT
] < gTime
+PLAYER_SUIT_TIME
then
6343 FMegaRulez
[MR_SUIT
] := gTime
+PLAYER_SUIT_TIME
;
6347 if FAir
< AIR_MAX
then
6354 if not (R_BERSERK
in FRulez
) then
6356 Include(FRulez
, R_BERSERK
);
6357 if FBFGFireCounter
< 1 then
6359 FCurrWeap
:= WEAPON_KASTET
;
6361 FModel
.SetWeapon(WEAPON_KASTET
);
6365 FBerserk
:= gTime
+30000;
6367 if FHealth
< PLAYER_HP_SOFT
then
6369 FHealth
:= PLAYER_HP_SOFT
;
6370 FBerserk
:= gTime
+30000;
6375 if FMegaRulez
[MR_INVUL
] < gTime
+PLAYER_INVUL_TIME
then
6377 FMegaRulez
[MR_INVUL
] := gTime
+PLAYER_INVUL_TIME
;
6382 if FMegaRulez
[MR_INVIS
] < gTime
+PLAYER_INVIS_TIME
then
6384 FMegaRulez
[MR_INVIS
] := gTime
+PLAYER_INVIS_TIME
;
6388 if FJetFuel
< JET_MAX
then
6390 FJetFuel
:= JET_MAX
;
6393 ITEM_MEDKIT_SMALL
: if FHealth
< PLAYER_HP_SOFT
then IncMax(FHealth
, 10, PLAYER_HP_SOFT
);
6394 ITEM_MEDKIT_LARGE
: if FHealth
< PLAYER_HP_SOFT
then IncMax(FHealth
, 25, PLAYER_HP_SOFT
);
6396 ITEM_ARMOR_GREEN
: if FArmor
< PLAYER_AP_SOFT
then FArmor
:= PLAYER_AP_SOFT
;
6397 ITEM_ARMOR_BLUE
: if FArmor
< PLAYER_AP_LIMIT
then FArmor
:= PLAYER_AP_LIMIT
;
6399 ITEM_SPHERE_BLUE
: if FHealth
< PLAYER_HP_LIMIT
then IncMax(FHealth
, 100, PLAYER_HP_LIMIT
);
6401 if (FHealth
< PLAYER_HP_LIMIT
) or (FArmor
< PLAYER_AP_LIMIT
) then
6403 if FHealth
< PLAYER_HP_LIMIT
then FHealth
:= PLAYER_HP_LIMIT
;
6404 if FArmor
< PLAYER_AP_LIMIT
then FArmor
:= PLAYER_AP_LIMIT
;
6407 ITEM_WEAPON_SAW
: FWeapon
[WEAPON_SAW
] := True;
6408 ITEM_WEAPON_SHOTGUN1
: FWeapon
[WEAPON_SHOTGUN1
] := True;
6409 ITEM_WEAPON_SHOTGUN2
: FWeapon
[WEAPON_SHOTGUN2
] := True;
6410 ITEM_WEAPON_CHAINGUN
: FWeapon
[WEAPON_CHAINGUN
] := True;
6411 ITEM_WEAPON_ROCKETLAUNCHER
: FWeapon
[WEAPON_ROCKETLAUNCHER
] := True;
6412 ITEM_WEAPON_PLASMA
: FWeapon
[WEAPON_PLASMA
] := True;
6413 ITEM_WEAPON_BFG
: FWeapon
[WEAPON_BFG
] := True;
6414 ITEM_WEAPON_SUPERPULEMET
: FWeapon
[WEAPON_SUPERPULEMET
] := True;
6415 ITEM_WEAPON_FLAMETHROWER
: FWeapon
[WEAPON_FLAMETHROWER
] := True;
6417 ITEM_AMMO_BULLETS
: if FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
] then IncMax(FAmmo
[A_BULLETS
], 10, FMaxAmmo
[A_BULLETS
]);
6418 ITEM_AMMO_BULLETS_BOX
: if FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
] then IncMax(FAmmo
[A_BULLETS
], 50, FMaxAmmo
[A_BULLETS
]);
6419 ITEM_AMMO_SHELLS
: if FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
] then IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
6420 ITEM_AMMO_SHELLS_BOX
: if FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
] then IncMax(FAmmo
[A_SHELLS
], 25, FMaxAmmo
[A_SHELLS
]);
6421 ITEM_AMMO_ROCKET
: if FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
] then IncMax(FAmmo
[A_ROCKETS
], 1, FMaxAmmo
[A_ROCKETS
]);
6422 ITEM_AMMO_ROCKET_BOX
: if FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
] then IncMax(FAmmo
[A_ROCKETS
], 5, FMaxAmmo
[A_ROCKETS
]);
6423 ITEM_AMMO_CELL
: if FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
] then IncMax(FAmmo
[A_CELLS
], 40, FMaxAmmo
[A_CELLS
]);
6424 ITEM_AMMO_CELL_BIG
: if FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
] then IncMax(FAmmo
[A_CELLS
], 100, FMaxAmmo
[A_CELLS
]);
6425 ITEM_AMMO_FUELCAN
: if FAmmo
[A_FUEL
] < FMaxAmmo
[A_FUEL
] then IncMax(FAmmo
[A_FUEL
], 100, FMaxAmmo
[A_FUEL
]);
6428 if (FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
]) or
6429 (FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
]) or
6430 (FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
]) or
6431 (FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
]) or
6432 (FMaxAmmo
[A_FUEL
] < AmmoLimits
[1, A_FUEL
]) then
6434 FMaxAmmo
[A_BULLETS
] := AmmoLimits
[1, A_BULLETS
];
6435 FMaxAmmo
[A_SHELLS
] := AmmoLimits
[1, A_SHELLS
];
6436 FMaxAmmo
[A_ROCKETS
] := AmmoLimits
[1, A_ROCKETS
];
6437 FMaxAmmo
[A_CELLS
] := AmmoLimits
[1, A_CELLS
];
6438 FMaxAmmo
[A_FUEL
] := AmmoLimits
[1, A_FUEL
];
6440 if FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
] then IncMax(FAmmo
[A_BULLETS
], 10, FMaxAmmo
[A_BULLETS
]);
6441 if FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
] then IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
6442 if FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
] then IncMax(FAmmo
[A_ROCKETS
], 1, FMaxAmmo
[A_ROCKETS
]);
6443 if FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
] then IncMax(FAmmo
[A_CELLS
], 40, FMaxAmmo
[A_CELLS
]);
6445 FRulez
:= FRulez
+ [R_ITEM_BACKPACK
];
6448 ITEM_KEY_RED
: if not (R_KEY_RED
in FRulez
) then Include(FRulez
, R_KEY_RED
);
6449 ITEM_KEY_GREEN
: if not (R_KEY_GREEN
in FRulez
) then Include(FRulez
, R_KEY_GREEN
);
6450 ITEM_KEY_BLUE
: if not (R_KEY_BLUE
in FRulez
) then Include(FRulez
, R_KEY_BLUE
);
6452 ITEM_BOTTLE
: if FHealth
< PLAYER_HP_LIMIT
then IncMax(FHealth
, 4, PLAYER_HP_LIMIT
);
6453 ITEM_HELMET
: if FArmor
< PLAYER_AP_LIMIT
then IncMax(FArmor
, 5, PLAYER_AP_LIMIT
);
6458 if g_Game_IsNet
and g_Game_IsServer
then
6459 MH_SEND_PlayerStats(FUID
);
6462 procedure TPlayer
.FlySmoke(Times
: DWORD
= 1);
6467 if (Random(5) = 1) and (Times
= 1) then
6470 if BodyInLiquid(0, 0) then
6472 g_GFX_Bubbles(Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2)+Random(3)-1,
6473 Obj
.Y
+Obj
.Rect
.Height
+8, 1, 8, 4);
6474 if Random(2) = 0 then
6475 g_Sound_PlayExAt('SOUND_GAME_BUBBLE1', FObj
.X
, FObj
.Y
)
6477 g_Sound_PlayExAt('SOUND_GAME_BUBBLE2', FObj
.X
, FObj
.Y
);
6481 if g_Frames_Get(id
, 'FRAMES_SMOKE') then
6483 for i
:= 1 to Times
do
6485 Anim
:= TAnimation
.Create(id
, False, 3);
6487 g_GFX_OnceAnim(Obj
.X
+Obj
.Rect
.X
+Random(Obj
.Rect
.Width
+Times
*2)-(Anim
.Width
div 2),
6488 Obj
.Y
+Obj
.Rect
.Height
-4+Random(8+Times
*2), Anim
, ONCEANIM_SMOKE
);
6494 procedure TPlayer
.OnFireFlame(Times
: DWORD
= 1);
6499 if (Random(10) = 1) and (Times
= 1) then
6502 if g_Frames_Get(id
, 'FRAMES_FLAME') then
6504 for i
:= 1 to Times
do
6506 Anim
:= TAnimation
.Create(id
, False, 3);
6508 g_GFX_OnceAnim(Obj
.X
+Obj
.Rect
.X
+Random(Obj
.Rect
.Width
+Times
*2)-(Anim
.Width
div 2),
6509 Obj
.Y
+8+Random(8+Times
*2), Anim
, ONCEANIM_SMOKE
);
6515 procedure TPlayer
.PauseSounds(Enable
: Boolean);
6517 FSawSound
.Pause(Enable
);
6518 FSawSoundIdle
.Pause(Enable
);
6519 FSawSoundHit
.Pause(Enable
);
6520 FSawSoundSelect
.Pause(Enable
);
6521 FFlameSoundOn
.Pause(Enable
);
6522 FFlameSoundOff
.Pause(Enable
);
6523 FFlameSoundWork
.Pause(Enable
);
6524 FJetSoundFly
.Pause(Enable
);
6525 FJetSoundOn
.Pause(Enable
);
6526 FJetSoundOff
.Pause(Enable
);
6531 constructor TCorpse
.Create(X
, Y
: Integer; ModelName
: String; aMess
: Boolean);
6536 FObj
.Rect
:= PLAYER_CORPSERECT
;
6537 FModelName
:= ModelName
;
6542 FState
:= CORPSE_STATE_MESS
;
6543 g_PlayerModel_GetAnim(ModelName
, A_DIE2
, FAnimation
, FAnimationMask
);
6547 FState
:= CORPSE_STATE_NORMAL
;
6548 g_PlayerModel_GetAnim(ModelName
, A_DIE1
, FAnimation
, FAnimationMask
);
6552 destructor TCorpse
.Destroy();
6559 function TCorpse
.ObjPtr (): PObj
; inline; begin result
:= @FObj
; end;
6561 procedure TCorpse
.positionChanged (); inline; begin end;
6563 procedure TCorpse
.moveBy (dx
, dy
: Integer); inline;
6565 if (dx
<> 0) or (dy
<> 0) then
6574 procedure TCorpse
.getMapBox (out x
, y
, w
, h
: Integer); inline;
6576 x
:= FObj
.X
+PLAYER_CORPSERECT
.X
;
6577 y
:= FObj
.Y
+PLAYER_CORPSERECT
.Y
;
6578 w
:= PLAYER_CORPSERECT
.Width
;
6579 h
:= PLAYER_CORPSERECT
.Height
;
6583 procedure TCorpse
.Damage(Value
: Word; vx
, vy
: Integer);
6588 if FState
= CORPSE_STATE_REMOVEME
then
6591 FDamage
:= FDamage
+ Value
;
6593 if FDamage
> 150 then
6595 if FAnimation
<> nil then
6600 FState
:= CORPSE_STATE_REMOVEME
;
6602 g_Player_CreateGibs(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
6603 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2),
6604 FModelName
, FColor
);
6605 // Çâóê ìÿñà îò òðóïà:
6606 pm
:= g_PlayerModel_Get(FModelName
);
6607 pm
.PlaySound(MODELSOUND_DIE
, 5, FObj
.X
, FObj
.Y
);
6611 if (gBodyKillEvent
<> -1)
6612 and gDelayedEvents
[gBodyKillEvent
].Pending
then
6613 gDelayedEvents
[gBodyKillEvent
].Pending
:= False;
6614 gBodyKillEvent
:= g_Game_DelayEvent(DE_BODYKILL
, 1050, 0);
6619 Blood
:= g_PlayerModel_GetBlood(FModelName
);
6620 FObj
.Vel
.X
:= FObj
.Vel
.X
+ vx
;
6621 FObj
.Vel
.Y
:= FObj
.Vel
.Y
+ vy
;
6622 g_GFX_Blood(FObj
.X
+PLAYER_CORPSERECT
.X
+(PLAYER_CORPSERECT
.Width
div 2),
6623 FObj
.Y
+PLAYER_CORPSERECT
.Y
+(PLAYER_CORPSERECT
.Height
div 2),
6624 Value
, vx
, vy
, 16, (PLAYER_CORPSERECT
.Height
*2) div 3,
6625 Blood
.R
, Blood
.G
, Blood
.B
, Blood
.Kind
);
6629 procedure TCorpse
.Draw();
6633 if FState
= CORPSE_STATE_REMOVEME
then
6636 FObj
.lerp(gLerpFactor
, fX
, fY
);
6638 if FAnimation
<> nil then
6639 FAnimation
.Draw(fX
, fY
, TMirrorType
.None
);
6641 if FAnimationMask
<> nil then
6644 FAnimationMask
.Draw(fX
, fY
, TMirrorType
.None
);
6651 procedure TCorpse
.Update();
6655 if FState
= CORPSE_STATE_REMOVEME
then
6658 FObj
.oldX
:= FObj
.X
;
6659 FObj
.oldY
:= FObj
.Y
;
6661 if gTime
mod (GAME_TICK
*2) <> 0 then
6663 g_Obj_Move(@FObj
, True, True, True);
6664 positionChanged(); // this updates spatial accelerators
6668 // Ñîïðîòèâëåíèå âîçäóõà äëÿ òðóïà:
6669 FObj
.Vel
.X
:= z_dec(FObj
.Vel
.X
, 1);
6671 st
:= g_Obj_Move(@FObj
, True, True, True);
6672 positionChanged(); // this updates spatial accelerators
6674 if WordBool(st
and MOVE_FALLOUT
) then
6676 FState
:= CORPSE_STATE_REMOVEME
;
6680 if FAnimation
<> nil then
6681 FAnimation
.Update();
6682 if FAnimationMask
<> nil then
6683 FAnimationMask
.Update();
6687 procedure TCorpse
.SaveState (st
: TStream
);
6694 utils
.writeSign(st
, 'CORP');
6695 utils
.writeInt(st
, Byte(0));
6697 utils
.writeInt(st
, Byte(FState
));
6699 utils
.writeInt(st
, Byte(FDamage
));
6701 utils
.writeInt(st
, Byte(FColor
.R
));
6702 utils
.writeInt(st
, Byte(FColor
.G
));
6703 utils
.writeInt(st
, Byte(FColor
.B
));
6705 Obj_SaveState(st
, @FObj
);
6706 utils
.writeInt(st
, Word(FPlayerUID
));
6708 anim
:= (FAnimation
<> nil);
6709 utils
.writeBool(st
, anim
);
6710 // Åñëè åñòü - ñîõðàíÿåì
6711 if anim
then FAnimation
.SaveState(st
);
6712 // Åñòü ëè ìàñêà àíèìàöèè
6713 anim
:= (FAnimationMask
<> nil);
6714 utils
.writeBool(st
, anim
);
6715 // Åñëè åñòü - ñîõðàíÿåì
6716 if anim
then FAnimationMask
.SaveState(st
);
6720 procedure TCorpse
.LoadState (st
: TStream
);
6727 if not utils
.checkSign(st
, 'CORP') then raise XStreamError
.Create('invalid corpse signature');
6728 if (utils
.readByte(st
) <> 0) then raise XStreamError
.Create('invalid corpse version');
6730 FState
:= utils
.readByte(st
);
6732 FDamage
:= utils
.readByte(st
);
6734 FColor
.R
:= utils
.readByte(st
);
6735 FColor
.G
:= utils
.readByte(st
);
6736 FColor
.B
:= utils
.readByte(st
);
6738 Obj_LoadState(@FObj
, st
);
6739 FPlayerUID
:= utils
.readWord(st
);
6741 anim
:= utils
.readBool(st
);
6742 // Åñëè åñòü - çàãðóæàåì
6745 Assert(FAnimation
<> nil, 'TCorpse.LoadState: no FAnimation');
6746 FAnimation
.LoadState(st
);
6748 // Åñòü ëè ìàñêà àíèìàöèè
6749 anim
:= utils
.readBool(st
);
6750 // Åñëè åñòü - çàãðóæàåì
6753 Assert(FAnimationMask
<> nil, 'TCorpse.LoadState: no FAnimationMask');
6754 FAnimationMask
.LoadState(st
);
6760 constructor TBot
.Create();
6767 FSpectator
:= False;
6774 for a
:= WP_FIRST
to WP_LAST
do
6776 FDifficult
.WeaponPrior
[a
] := WEAPON_PRIOR1
[a
];
6777 FDifficult
.CloseWeaponPrior
[a
] := WEAPON_PRIOR2
[a
];
6778 //FDifficult.SafeWeaponPrior[a] := WEAPON_PRIOR3[a];
6782 destructor TBot
.Destroy();
6785 inherited Destroy();
6788 procedure TBot
.Draw();
6792 //if FTargetUID <> 0 then e_DrawLine(1, FObj.X, FObj.Y, g_Player_Get(FTargetUID).FObj.X,
6793 // g_Player_Get(FTargetUID).FObj.Y, 255, 0, 0);
6796 procedure TBot
.Respawn(Silent
: Boolean; Force
: Boolean = False);
6798 inherited Respawn(Silent
, Force
);
6801 FSelectedWeapon
:= FCurrWeap
;
6806 procedure TBot
.UpdateCombat();
6819 TTargetRecord
= array of TTarget
;
6821 function Compare(a
, b
: TTarget
): Integer;
6823 if a
.Line
and not b
.Line
then // A íà ëèíèè îãíÿ
6826 if not a
.Line
and b
.Line
then // B íà ëèíèè îãíÿ
6828 else // È A, è B íà ëèíèè èëè íå íà ëèíèè îãíÿ
6829 if (a
.Line
and b
.Line
) or ((not a
.Line
) and (not b
.Line
)) then
6831 if a
.Dist
> b
.Dist
then // B áëèæå
6833 else // A áëèæå èëè ðàâíîóäàëåííî ñ B
6836 else // Ñòðàííî -> A
6841 a
, x1
, y1
, x2
, y2
: Integer;
6842 targets
: TTargetRecord
;
6844 Target
, BestTarget
: TTarget
;
6845 firew
, fireh
: Integer;
6849 vsPlayer
, vsMonster
, ok
: Boolean;
6852 function monsUpdate (mon
: TMonster
): Boolean;
6854 result
:= false; // don't stop
6855 if mon
.alive
and (mon
.MonsterType
<> MONSTER_BARREL
) then
6857 if not TargetOnScreen(mon
.Obj
.X
+mon
.Obj
.Rect
.X
, mon
.Obj
.Y
+mon
.Obj
.Rect
.Y
) then exit
;
6859 x2
:= mon
.Obj
.X
+mon
.Obj
.Rect
.X
+(mon
.Obj
.Rect
.Width
div 2);
6860 y2
:= mon
.Obj
.Y
+mon
.Obj
.Rect
.Y
+(mon
.Obj
.Rect
.Height
div 2);
6862 // Åñëè ìîíñòð íà ýêðàíå è íå ïðèêðûò ñòåíîé
6863 if g_TraceVector(x1
, y1
, x2
, y2
) then
6865 // Äîáàâëÿåì ê ñïèñêó âîçìîæíûõ öåëåé
6866 SetLength(targets
, Length(targets
)+1);
6867 with targets
[High(targets
)] do
6874 Rect
:= mon
.Obj
.Rect
;
6875 Dist
:= g_PatchLength(x1
, y1
, x2
, y2
);
6876 Line
:= (y1
+4 < Target
.Y
+ mon
.Obj
.Rect
.Y
+ mon
.Obj
.Rect
.Height
) and
6877 (y1
-4 > Target
.Y
+ mon
.Obj
.Rect
.Y
);
6886 vsPlayer
:= LongBool(gGameSettings
.Options
and GAME_OPTION_BOTVSPLAYER
);
6887 vsMonster
:= LongBool(gGameSettings
.Options
and GAME_OPTION_BOTVSMONSTER
);
6889 // Åñëè òåêóùåå îðóæèå íå òî, ÷òî íóæíî, òî ìåíÿåì:
6890 if FCurrWeap
<> FSelectedWeapon
then
6893 // Åñëè íóæíî ñòðåëÿòü è íóæíîå îðóæèå, òî íàæàòü "Ñòðåëÿòü":
6894 if (GetAIFlag('NEEDFIRE') <> '') and (FCurrWeap
= FSelectedWeapon
) then
6896 RemoveAIFlag('NEEDFIRE');
6899 WEAPON_PLASMA
, WEAPON_SUPERPULEMET
, WEAPON_CHAINGUN
: PressKey(KEY_FIRE
, 20);
6900 WEAPON_SAW
, WEAPON_KASTET
, WEAPON_FLAMETHROWER
: PressKey(KEY_FIRE
, 40);
6901 else PressKey(KEY_FIRE
);
6905 // Êîîðäèíàòû ñòâîëà:
6906 x1
:= FObj
.X
+ WEAPONPOINT
[FDirection
].X
;
6907 y1
:= FObj
.Y
+ WEAPONPOINT
[FDirection
].Y
;
6909 Target
.UID
:= FTargetUID
;
6912 if Target
.UID
<> 0 then
6913 begin // Öåëü åñòü - íàñòðàèâàåì
6914 if (g_GetUIDType(Target
.UID
) = UID_PLAYER
) and
6917 tpla
:= g_Player_Get(Target
.UID
);
6921 if (@FObj
) <> nil then
6928 Target
.cX
:= Target
.X
+ PLAYER_RECT_CX
;
6929 Target
.cY
:= Target
.Y
+ PLAYER_RECT_CY
;
6930 Target
.Rect
:= PLAYER_RECT
;
6931 Target
.Visible
:= g_TraceVector(x1
, y1
, Target
.cX
, Target
.cY
);
6932 Target
.Line
:= (y1
+4 < Target
.Y
+PLAYER_RECT
.Y
+PLAYER_RECT
.Height
) and
6933 (y1
-4 > Target
.Y
+PLAYER_RECT
.Y
);
6934 Target
.IsPlayer
:= True;
6938 if (g_GetUIDType(Target
.UID
) = UID_MONSTER
) and
6941 mon
:= g_Monsters_ByUID(Target
.UID
);
6944 Target
.X
:= mon
.Obj
.X
;
6945 Target
.Y
:= mon
.Obj
.Y
;
6947 Target
.cX
:= Target
.X
+ mon
.Obj
.Rect
.X
+ (mon
.Obj
.Rect
.Width
div 2);
6948 Target
.cY
:= Target
.Y
+ mon
.Obj
.Rect
.Y
+ (mon
.Obj
.Rect
.Height
div 2);
6949 Target
.Rect
:= mon
.Obj
.Rect
;
6950 Target
.Visible
:= g_TraceVector(x1
, y1
, Target
.cX
, Target
.cY
);
6951 Target
.Line
:= (y1
+4 < Target
.Y
+ mon
.Obj
.Rect
.Y
+ mon
.Obj
.Rect
.Height
) and
6952 (y1
-4 > Target
.Y
+ mon
.Obj
.Rect
.Y
);
6953 Target
.IsPlayer
:= False;
6960 begin // Öåëè íåò - îáíóëÿåì
6965 Target
.Visible
:= False;
6966 Target
.Line
:= False;
6967 Target
.IsPlayer
:= False;
6972 // Åñëè öåëü íå âèäèìà èëè íå íà ëèíèè îãíÿ, òî èùåì âñå âîçìîæíûå öåëè:
6973 if (not Target
.Line
) or (not Target
.Visible
) then
6977 for a
:= 0 to High(gPlayers
) do
6978 if (gPlayers
[a
] <> nil) and (gPlayers
[a
].alive
) and
6979 (gPlayers
[a
].FUID
<> FUID
) and
6980 (not SameTeam(FUID
, gPlayers
[a
].FUID
)) and
6981 (not gPlayers
[a
].NoTarget
) and
6982 (gPlayers
[a
].FMegaRulez
[MR_INVIS
] < gTime
) then
6984 if not TargetOnScreen(gPlayers
[a
].FObj
.X
+ PLAYER_RECT
.X
,
6985 gPlayers
[a
].FObj
.Y
+ PLAYER_RECT
.Y
) then
6988 x2
:= gPlayers
[a
].FObj
.X
+ PLAYER_RECT_CX
;
6989 y2
:= gPlayers
[a
].FObj
.Y
+ PLAYER_RECT_CY
;
6991 // Åñëè èãðîê íà ýêðàíå è íå ïðèêðûò ñòåíîé:
6992 if g_TraceVector(x1
, y1
, x2
, y2
) then
6994 // Äîáàâëÿåì ê ñïèñêó âîçìîæíûõ öåëåé:
6995 SetLength(targets
, Length(targets
)+1);
6996 with targets
[High(targets
)] do
6998 UID
:= gPlayers
[a
].FUID
;
6999 X
:= gPlayers
[a
].FObj
.X
;
7000 Y
:= gPlayers
[a
].FObj
.Y
;
7003 Rect
:= PLAYER_RECT
;
7004 Dist
:= g_PatchLength(x1
, y1
, x2
, y2
);
7005 Line
:= (y1
+4 < Target
.Y
+PLAYER_RECT
.Y
+PLAYER_RECT
.Height
) and
7006 (y1
-4 > Target
.Y
+PLAYER_RECT
.Y
);
7014 if vsMonster
then g_Mons_ForEach(monsUpdate
);
7017 // Åñëè åñòü âîçìîæíûå öåëè:
7018 // (Âûáèðàåì ëó÷øóþ, ìåíÿåì îðóæèå è áåæèì ê íåé/îò íåå)
7019 if targets
<> nil then
7021 // Âûáèðàåì íàèëó÷øóþ öåëü:
7022 BestTarget
:= targets
[0];
7023 if Length(targets
) > 1 then
7024 for a
:= 1 to High(targets
) do
7025 if Compare(BestTarget
, targets
[a
]) = 1 then
7026 BestTarget
:= targets
[a
];
7028 // Åñëè ëó÷øàÿ öåëü "âèäíåå" òåêóùåé, òî òåêóùàÿ := ëó÷øàÿ:
7029 if ((not Target
.Visible
) and BestTarget
.Visible
and (Target
.UID
<> BestTarget
.UID
)) or
7030 ((not Target
.Line
) and BestTarget
.Line
and BestTarget
.Visible
) then
7032 Target
:= BestTarget
;
7034 if (Healthy() = 3) or ((Healthy() = 2)) then
7035 begin // Åñëè çäîðîâû - äîãîíÿåì
7036 if ((RunDirection() = TDirection
.D_LEFT
) and (Target
.X
> FObj
.X
)) then
7037 SetAIFlag('GORIGHT', '1');
7038 if ((RunDirection() = TDirection
.D_RIGHT
) and (Target
.X
< FObj
.X
)) then
7039 SetAIFlag('GOLEFT', '1');
7042 begin // Åñëè ïîáèòû - óáåãàåì
7043 if ((RunDirection() = TDirection
.D_LEFT
) and (Target
.X
< FObj
.X
)) then
7044 SetAIFlag('GORIGHT', '1');
7045 if ((RunDirection() = TDirection
.D_RIGHT
) and (Target
.X
> FObj
.X
)) then
7046 SetAIFlag('GOLEFT', '1');
7049 // Âûáèðàåì îðóæèå íà îñíîâå ðàññòîÿíèÿ è ïðèîðèòåòîâ:
7050 SelectWeapon(Abs(x1
-Target
.cX
));
7055 // (Äîãîíÿåì/óáåãàåì, ñòðåëÿåì ïî íàïðàâëåíèþ ê öåëè)
7056 // (Åñëè öåëü äàëåêî, òî õâàòèò ñëåäèòü çà íåé)
7057 if Target
.UID
<> 0 then
7059 if not TargetOnScreen(Target
.X
+ Target
.Rect
.X
,
7060 Target
.Y
+ Target
.Rect
.Y
) then
7061 begin // Öåëü ñáåæàëà ñ "ýêðàíà"
7062 if (Healthy() = 3) or ((Healthy() = 2)) then
7063 begin // Åñëè çäîðîâû - äîãîíÿåì
7064 if ((RunDirection() = TDirection
.D_LEFT
) and (Target
.X
> FObj
.X
)) then
7065 SetAIFlag('GORIGHT', '1');
7066 if ((RunDirection() = TDirection
.D_RIGHT
) and (Target
.X
< FObj
.X
)) then
7067 SetAIFlag('GOLEFT', '1');
7070 begin // Åñëè ïîáèòû - çàáûâàåì î öåëè è óáåãàåì
7072 if ((RunDirection() = TDirection
.D_LEFT
) and (Target
.X
< FObj
.X
)) then
7073 SetAIFlag('GORIGHT', '1');
7074 if ((RunDirection() = TDirection
.D_RIGHT
) and (Target
.X
> FObj
.X
)) then
7075 SetAIFlag('GOLEFT', '1');
7079 begin // Öåëü ïîêà íà "ýêðàíå"
7080 // Åñëè öåëü íå çàãîðîæåíà ñòåíîé, òî îòìå÷àåì, êîãäà åå âèäåëè:
7081 if g_TraceVector(x1
, y1
, Target
.cX
, Target
.cY
) then
7082 FLastVisible
:= gTime
;
7083 // Åñëè ðàçíèöà âûñîò íå âåëèêà, òî äîãîíÿåì:
7084 if (Abs(FObj
.Y
-Target
.Y
) <= 128) then
7086 if ((RunDirection() = TDirection
.D_LEFT
) and (Target
.X
> FObj
.X
)) then
7087 SetAIFlag('GORIGHT', '1');
7088 if ((RunDirection() = TDirection
.D_RIGHT
) and (Target
.X
< FObj
.X
)) then
7089 SetAIFlag('GOLEFT', '1');
7093 // Âûáèðàåì óãîë ââåðõ:
7094 if FDirection
= TDirection
.D_LEFT
then
7095 angle
:= ANGLE_LEFTUP
7097 angle
:= ANGLE_RIGHTUP
;
7099 firew
:= Trunc(Cos(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
7100 fireh
:= Trunc(Sin(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
7102 // Åñëè ïðè óãëå ââåðõ ìîæíî ïîïàñòü â ïðèáëèçèòåëüíîå ïîëîæåíèå öåëè:
7103 if g_CollideLine(x1
, y1
, x1
+firew
, y1
+fireh
,
7104 Target
.X
+Target
.Rect
.X
+GetInterval(FDifficult
.DiagPrecision
, 128), //96
7105 Target
.Y
+Target
.Rect
.Y
+GetInterval(FDifficult
.DiagPrecision
, 128),
7106 Target
.Rect
.Width
, Target
.Rect
.Height
) and
7107 g_TraceVector(x1
, y1
, Target
.cX
, Target
.cY
) then
7108 begin // òî íóæíî ñòðåëÿòü ââåðõ
7109 SetAIFlag('NEEDFIRE', '1');
7110 SetAIFlag('NEEDSEEUP', '1');
7113 // Âûáèðàåì óãîë âíèç:
7114 if FDirection
= TDirection
.D_LEFT
then
7115 angle
:= ANGLE_LEFTDOWN
7117 angle
:= ANGLE_RIGHTDOWN
;
7119 firew
:= Trunc(Cos(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
7120 fireh
:= Trunc(Sin(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
7122 // Åñëè ïðè óãëå âíèç ìîæíî ïîïàñòü â ïðèáëèçèòåëüíîå ïîëîæåíèå öåëè:
7123 if g_CollideLine(x1
, y1
, x1
+firew
, y1
+fireh
,
7124 Target
.X
+Target
.Rect
.X
+GetInterval(FDifficult
.DiagPrecision
, 128),
7125 Target
.Y
+Target
.Rect
.Y
+GetInterval(FDifficult
.DiagPrecision
, 128),
7126 Target
.Rect
.Width
, Target
.Rect
.Height
) and
7127 g_TraceVector(x1
, y1
, Target
.cX
, Target
.cY
) then
7128 begin // òî íóæíî ñòðåëÿòü âíèç
7129 SetAIFlag('NEEDFIRE', '1');
7130 SetAIFlag('NEEDSEEDOWN', '1');
7133 // Åñëè öåëü âèäíî è îíà íà òàêîé æå âûñîòå:
7134 if Target
.Visible
and
7135 (y1
+4 < Target
.Y
+Target
.Rect
.Y
+Target
.Rect
.Height
) and
7136 (y1
-4 > Target
.Y
+Target
.Rect
.Y
) then
7138 // Åñëè èäåì â ñòîðîíó öåëè, òî íàäî ñòðåëÿòü:
7139 if ((FDirection
= TDirection
.D_LEFT
) and (Target
.X
< FObj
.X
)) or
7140 ((FDirection
= TDirection
.D_RIGHT
) and (Target
.X
> FObj
.X
)) then
7141 begin // òî íóæíî ñòðåëÿòü âïåðåä
7142 SetAIFlag('NEEDFIRE', '1');
7143 SetAIFlag('NEEDSEEDOWN', '');
7144 SetAIFlag('NEEDSEEUP', '');
7146 // Åñëè öåëü â ïðåäåëàõ "ýêðàíà" è ñëîæíîñòü ïîçâîëÿåò ïðûæêè ñáëèæåíèÿ:
7147 if Abs(FObj
.X
-Target
.X
) < Trunc(gPlayerScreenSize
.X
*0.75) then
7148 if GetRnd(FDifficult
.CloseJump
) then
7149 begin // òî åñëè ïîâåçåò - ïðûãàåì (îñîáåííî, åñëè áëèçêî)
7150 if Abs(FObj
.X
-Target
.X
) < 128 then
7154 if Random(a
) = 0 then
7155 SetAIFlag('NEEDJUMP', '1');
7159 // Åñëè öåëü âñå åùå åñòü:
7160 if Target
.UID
<> 0 then
7161 if gTime
-FLastVisible
> 2000 then // Åñëè âèäåëè äàâíî
7162 Target
.UID
:= 0 // òî çàáûòü öåëü
7163 else // Åñëè âèäåëè íåäàâíî
7164 begin // íî öåëü óáèëè
7165 if Target
.IsPlayer
then
7166 begin // Öåëü - èãðîê
7167 pla
:= g_Player_Get(Target
.UID
);
7168 if (pla
= nil) or (not pla
.alive
) or pla
.NoTarget
or
7169 (pla
.FMegaRulez
[MR_INVIS
] >= gTime
) then
7170 Target
.UID
:= 0; // òî çàáûòü öåëü
7173 begin // Öåëü - ìîíñòð
7174 mon
:= g_Monsters_ByUID(Target
.UID
);
7175 if (mon
= nil) or (not mon
.alive
) then
7176 Target
.UID
:= 0; // òî çàáûòü öåëü
7179 end; // if Target.UID <> 0
7181 FTargetUID
:= Target
.UID
;
7183 // Åñëè âîçìîæíûõ öåëåé íåò:
7184 // (Àòàêà ÷åãî-íèáóäü ñëåâà èëè ñïðàâà)
7185 if targets
= nil then
7186 if GetAIFlag('ATTACKLEFT') <> '' then
7187 begin // Åñëè íóæíî àòàêîâàòü íàëåâî
7188 RemoveAIFlag('ATTACKLEFT');
7190 SetAIFlag('NEEDJUMP', '1');
7192 if RunDirection() = TDirection
.D_RIGHT
then
7193 begin // Èäåì íå â òó ñòîðîíó
7194 if (Healthy() > 1) and GetRnd(FDifficult
.InvisFire
) then
7195 begin // Åñëè çäîðîâû, òî, âîçìîæíî, ñòðåëÿåì áåæèì âëåâî è ñòðåëÿåì
7196 SetAIFlag('NEEDFIRE', '1');
7197 SetAIFlag('GOLEFT', '1');
7201 begin // Èäåì â íóæíóþ ñòîðîíó
7202 if GetRnd(FDifficult
.InvisFire
) then // Âîçìîæíî, ñòðåëÿåì âñëåïóþ
7203 SetAIFlag('NEEDFIRE', '1');
7204 if Healthy() <= 1 then // Ïîáèòû - óáåãàåì
7205 SetAIFlag('GORIGHT', '1');
7209 if GetAIFlag('ATTACKRIGHT') <> '' then
7210 begin // Åñëè íóæíî àòàêîâàòü íàïðàâî
7211 RemoveAIFlag('ATTACKRIGHT');
7213 SetAIFlag('NEEDJUMP', '1');
7215 if RunDirection() = TDirection
.D_LEFT
then
7216 begin // Èäåì íå â òó ñòîðîíó
7217 if (Healthy() > 1) and GetRnd(FDifficult
.InvisFire
) then
7218 begin // Åñëè çäîðîâû, òî, âîçìîæíî, áåæèì âïðàâî è ñòðåëÿåì
7219 SetAIFlag('NEEDFIRE', '1');
7220 SetAIFlag('GORIGHT', '1');
7225 if GetRnd(FDifficult
.InvisFire
) then // Âîçìîæíî, ñòðåëÿåì âñëåïóþ
7226 SetAIFlag('NEEDFIRE', '1');
7227 if Healthy() <= 1 then // Ïîáèòû - óáåãàåì
7228 SetAIFlag('GOLEFT', '1');
7232 //HACK! (does it belongs there?)
7233 RealizeCurrentWeapon();
7235 // Åñëè åñòü âîçìîæíûå öåëè:
7236 // (Ñòðåëÿåì ïî íàïðàâëåíèþ ê öåëÿì)
7237 if (targets
<> nil) and (GetAIFlag('NEEDFIRE') <> '') then
7238 for a
:= 0 to High(targets
) do
7240 // Åñëè ìîæåì ñòðåëÿòü ïî äèàãîíàëè:
7241 if GetRnd(FDifficult
.DiagFire
) then
7243 // Èùåì öåëü ñâåðõó è ñòðåëÿåì, åñëè åñòü:
7244 if FDirection
= TDirection
.D_LEFT
then
7245 angle
:= ANGLE_LEFTUP
7247 angle
:= ANGLE_RIGHTUP
;
7249 firew
:= Trunc(Cos(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
7250 fireh
:= Trunc(Sin(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
7252 if g_CollideLine(x1
, y1
, x1
+firew
, y1
+fireh
,
7253 targets
[a
].X
+targets
[a
].Rect
.X
+GetInterval(FDifficult
.DiagPrecision
, 128),
7254 targets
[a
].Y
+targets
[a
].Rect
.Y
+GetInterval(FDifficult
.DiagPrecision
, 128),
7255 targets
[a
].Rect
.Width
, targets
[a
].Rect
.Height
) and
7256 g_TraceVector(x1
, y1
, targets
[a
].cX
, targets
[a
].cY
) then
7258 SetAIFlag('NEEDFIRE', '1');
7259 SetAIFlag('NEEDSEEUP', '1');
7262 // Èùåì öåëü ñíèçó è ñòðåëÿåì, åñëè åñòü:
7263 if FDirection
= TDirection
.D_LEFT
then
7264 angle
:= ANGLE_LEFTDOWN
7266 angle
:= ANGLE_RIGHTDOWN
;
7268 firew
:= Trunc(Cos(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
7269 fireh
:= Trunc(Sin(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
7271 if g_CollideLine(x1
, y1
, x1
+firew
, y1
+fireh
,
7272 targets
[a
].X
+targets
[a
].Rect
.X
+GetInterval(FDifficult
.DiagPrecision
, 128),
7273 targets
[a
].Y
+targets
[a
].Rect
.Y
+GetInterval(FDifficult
.DiagPrecision
, 128),
7274 targets
[a
].Rect
.Width
, targets
[a
].Rect
.Height
) and
7275 g_TraceVector(x1
, y1
, targets
[a
].cX
, targets
[a
].cY
) then
7277 SetAIFlag('NEEDFIRE', '1');
7278 SetAIFlag('NEEDSEEDOWN', '1');
7282 // Åñëè öåëü "ïåðåä íîñîì", òî ñòðåëÿåì:
7283 if targets
[a
].Line
and targets
[a
].Visible
and
7284 (((FDirection
= TDirection
.D_LEFT
) and (targets
[a
].X
< FObj
.X
)) or
7285 ((FDirection
= TDirection
.D_RIGHT
) and (targets
[a
].X
> FObj
.X
))) then
7287 SetAIFlag('NEEDFIRE', '1');
7292 // Åñëè ëåòèò ïóëÿ, òî, âîçìîæíî, ïîäïðûãèâàåì:
7293 if g_Weapon_Danger(FUID
, FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+PLAYER_RECT
.Y
,
7294 PLAYER_RECT
.Width
, PLAYER_RECT
.Height
,
7295 40+GetInterval(FDifficult
.Cover
, 40)) then
7296 SetAIFlag('NEEDJUMP', '1');
7298 // Åñëè êîí÷èëèñü ïàòîðíû, òî íóæíî ñìåíèòü îðóæèå:
7299 ammo
:= GetAmmoByWeapon(FCurrWeap
);
7300 if ((FCurrWeap
= WEAPON_SHOTGUN2
) and (ammo
< 2)) or
7301 ((FCurrWeap
= WEAPON_BFG
) and (ammo
< 40)) or
7303 SetAIFlag('SELECTWEAPON', '1');
7305 // Åñëè íóæíî ñìåíèòü îðóæèå, òî âûáèðàåì íóæíîå:
7306 if GetAIFlag('SELECTWEAPON') = '1' then
7309 RemoveAIFlag('SELECTWEAPON');
7313 procedure TBot
.Update();
7326 // Ïðîâåðÿåì, îòêëþ÷¸í ëè AI áîòîâ
7327 if (g_debug_BotAIOff
= 1) and (Team
= TEAM_RED
) then
7329 if (g_debug_BotAIOff
= 2) and (Team
= TEAM_BLUE
) then
7331 if g_debug_BotAIOff
= 3 then
7341 RealizeCurrentWeapon();
7348 procedure TBot
.ReleaseKey(Key
: Byte);
7357 function TBot
.KeyPressed(Key
: Word): Boolean;
7359 Result
:= FKeys
[Key
].Pressed
;
7362 function TBot
.GetAIFlag(aName
: String20
): String20
;
7368 aName
:= LowerCase(aName
);
7370 if FAIFlags
<> nil then
7371 for a
:= 0 to High(FAIFlags
) do
7372 if LowerCase(FAIFlags
[a
].Name
) = aName
then
7374 Result
:= FAIFlags
[a
].Value
;
7379 procedure TBot
.RemoveAIFlag(aName
: String20
);
7383 if FAIFlags
= nil then Exit
;
7385 aName
:= LowerCase(aName
);
7387 for a
:= 0 to High(FAIFlags
) do
7388 if LowerCase(FAIFlags
[a
].Name
) = aName
then
7390 if a
<> High(FAIFlags
) then
7391 for b
:= a
to High(FAIFlags
)-1 do
7392 FAIFlags
[b
] := FAIFlags
[b
+1];
7394 SetLength(FAIFlags
, Length(FAIFlags
)-1);
7399 procedure TBot
.SetAIFlag(aName
, fValue
: String20
);
7407 aName
:= LowerCase(aName
);
7409 if FAIFlags
<> nil then
7410 for a
:= 0 to High(FAIFlags
) do
7411 if LowerCase(FAIFlags
[a
].Name
) = aName
then
7417 if ok
then FAIFlags
[a
].Value
:= fValue
7420 SetLength(FAIFlags
, Length(FAIFlags
)+1);
7421 with FAIFlags
[High(FAIFlags
)] do
7429 procedure TBot
.UpdateMove
;
7431 procedure GoLeft(Time
: Word = 1);
7433 ReleaseKey(KEY_LEFT
);
7434 ReleaseKey(KEY_RIGHT
);
7435 PressKey(KEY_LEFT
, Time
);
7436 SetDirection(TDirection
.D_LEFT
);
7439 procedure GoRight(Time
: Word = 1);
7441 ReleaseKey(KEY_LEFT
);
7442 ReleaseKey(KEY_RIGHT
);
7443 PressKey(KEY_RIGHT
, Time
);
7444 SetDirection(TDirection
.D_RIGHT
);
7447 function Rnd(a
: Word): Boolean;
7449 Result
:= Random(a
) = 0;
7452 procedure Turn(Time
: Word = 1200);
7454 if RunDirection() = TDirection
.D_LEFT
then GoRight(Time
) else GoLeft(Time
);
7459 ReleaseKey(KEY_LEFT
);
7460 ReleaseKey(KEY_RIGHT
);
7463 function CanRunLeft(): Boolean;
7465 Result
:= not CollideLevel(-1, 0);
7468 function CanRunRight(): Boolean;
7470 Result
:= not CollideLevel(1, 0);
7473 function CanRun(): Boolean;
7475 if RunDirection() = TDirection
.D_LEFT
then Result
:= CanRunLeft() else Result
:= CanRunRight();
7478 procedure Jump(Time
: Word = 30);
7480 PressKey(KEY_JUMP
, Time
);
7483 function NearHole(): Boolean;
7487 { TODO 5 : Ëåñòíèöû }
7488 sx
:= IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1);
7489 for x
:= 1 to PLAYER_RECT
.Width
do
7490 if (not StayOnStep(x
*sx
, 0)) and
7491 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
)) and
7492 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
*2)) then
7501 function BorderHole(): Boolean;
7505 { TODO 5 : Ëåñòíèöû }
7506 sx
:= IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1);
7507 for x
:= 1 to PLAYER_RECT
.Width
do
7508 if (not StayOnStep(x
*sx
, 0)) and
7509 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
)) and
7510 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
*2)) then
7512 for xx
:= x
to x
+32 do
7513 if CollideLevel(xx
*sx
, PLAYER_RECT
.Height
) then
7523 function NearDeepHole(): Boolean;
7529 sx
:= IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1);
7532 for x
:= 1 to PLAYER_RECT
.Width
do
7533 if (not StayOnStep(x
*sx
, 0)) and
7534 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
)) and
7535 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
*2)) then
7537 while FObj
.Y
+y
*PLAYER_RECT
.Height
< gMapInfo
.Height
do
7539 if CollideLevel(x
*sx
, PLAYER_RECT
.Height
*y
) then Exit
;
7544 end else Result
:= False;
7547 function OverDeepHole(): Boolean;
7554 while FObj
.Y
+y
*PLAYER_RECT
.Height
< gMapInfo
.Height
do
7556 if CollideLevel(0, PLAYER_RECT
.Height
*y
) then Exit
;
7563 function OnGround(): Boolean;
7565 Result
:= StayOnStep(0, 0) or CollideLevel(0, 1);
7568 function OnLadder(): Boolean;
7570 Result
:= FullInStep(0, 0);
7573 function BelowLadder(): Boolean;
7575 Result
:= (FullInStep(IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -PLAYER_RECT
.Height
) and
7576 not CollideLevel(IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -PLAYER_RECT
.Height
)) or
7577 (FullInStep(IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -BOT_MAXJUMP
) and
7578 not CollideLevel(IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -BOT_MAXJUMP
));
7581 function BelowLiftUp(): Boolean;
7583 Result
:= ((FullInLift(IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -PLAYER_RECT
.Height
) = -1) and
7584 not CollideLevel(IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -PLAYER_RECT
.Height
)) or
7585 ((FullInLift(IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -BOT_MAXJUMP
) = -1) and
7586 not CollideLevel(IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -BOT_MAXJUMP
));
7589 function OnTopLift(): Boolean;
7591 Result
:= (FullInLift(0, 0) = -1) and (FullInLift(0, -32) = 0);
7594 function CanJumpOver(): Boolean;
7598 sx
:= IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1);
7602 if not CollideLevel(sx
, 0) then Exit
;
7604 for y
:= 1 to BOT_MAXJUMP
do
7605 if CollideLevel(0, -y
) then Exit
else
7606 if not CollideLevel(sx
, -y
) then
7613 function CanJumpUp(Dist
: ShortInt): Boolean;
7620 if CollideLevel(Dist
, 0) then Exit
;
7623 for y
:= 0 to BOT_MAXJUMP
do
7624 if CollideLevel(Dist
, -y
) then
7633 for yy
:= y
+1 to BOT_MAXJUMP
do
7634 if not CollideLevel(Dist
, -yy
) then
7643 for y
:= 0 to BOT_MAXJUMP
do
7644 if CollideLevel(0, -y
) then
7652 if y
< yy
then Exit
;
7657 function IsSafeTrigger(): Boolean;
7662 if gTriggers
= nil then
7664 for a
:= 0 to High(gTriggers
) do
7665 if Collide(gTriggers
[a
].X
,
7668 gTriggers
[a
].Height
) and
7669 (gTriggers
[a
].TriggerType
in [TRIGGER_EXIT
, TRIGGER_CLOSEDOOR
,
7670 TRIGGER_CLOSETRAP
, TRIGGER_TRAP
,
7671 TRIGGER_PRESS
, TRIGGER_ON
, TRIGGER_OFF
,
7672 TRIGGER_ONOFF
, TRIGGER_SPAWNMONSTER
,
7673 TRIGGER_DAMAGE
, TRIGGER_SHOT
]) then
7678 // Âîçìîæíî, íàæèìàåì êíîïêó:
7679 if Rnd(16) and IsSafeTrigger() then
7682 // Åñëè ïîä ëèôòîì èëè ñòóïåíüêàìè, òî, âîçìîæíî, ïðûãàåì:
7683 if OnLadder() or ((BelowLadder() or BelowLiftUp()) and Rnd(8)) then
7685 ReleaseKey(KEY_LEFT
);
7686 ReleaseKey(KEY_RIGHT
);
7690 // Èäåì âëåâî, åñëè íàäî áûëî:
7691 if GetAIFlag('GOLEFT') <> '' then
7693 RemoveAIFlag('GOLEFT');
7694 if CanRunLeft() then
7698 // Èäåì âïðàâî, åñëè íàäî áûëî:
7699 if GetAIFlag('GORIGHT') <> '' then
7701 RemoveAIFlag('GORIGHT');
7702 if CanRunRight() then
7706 // Åñëè âûëåòåëè çà êàðòó, òî ïðîáóåì âåðíóòüñÿ:
7707 if FObj
.X
< -32 then
7710 if FObj
.X
+32 > gMapInfo
.Width
then
7713 // Ïðûãàåì, åñëè íàäî áûëî:
7714 if GetAIFlag('NEEDJUMP') <> '' then
7717 RemoveAIFlag('NEEDJUMP');
7720 // Ñìîòðèì ââåðõ, åñëè íàäî áûëî:
7721 if GetAIFlag('NEEDSEEUP') <> '' then
7724 ReleaseKey(KEY_DOWN
);
7725 PressKey(KEY_UP
, 20);
7726 RemoveAIFlag('NEEDSEEUP');
7729 // Ñìîòðèì âíèç, åñëè íàäî áûëî:
7730 if GetAIFlag('NEEDSEEDOWN') <> '' then
7733 ReleaseKey(KEY_DOWN
);
7734 PressKey(KEY_DOWN
, 20);
7735 RemoveAIFlag('NEEDSEEDOWN');
7738 // Åñëè íóæíî áûëî â äûðó è ìû íå íà çåìëå, òî ïîêîðíî ëåòèì:
7739 if GetAIFlag('GOINHOLE') <> '' then
7740 if not OnGround() then
7742 ReleaseKey(KEY_LEFT
);
7743 ReleaseKey(KEY_RIGHT
);
7744 RemoveAIFlag('GOINHOLE');
7745 SetAIFlag('FALLINHOLE', '1');
7748 // Åñëè ïàäàëè è äîñòèãëè çåìëè, òî õâàòèò ïàäàòü:
7749 if GetAIFlag('FALLINHOLE') <> '' then
7751 RemoveAIFlag('FALLINHOLE');
7753 // Åñëè ëåòåëè ïðÿìî è ñåé÷àñ íå íà ëåñòíèöå èëè íà âåðøèíå ëèôòà, òî îòõîäèì â ñòîðîíó:
7754 if not (KeyPressed(KEY_LEFT
) or KeyPressed(KEY_RIGHT
)) then
7755 if GetAIFlag('FALLINHOLE') = '' then
7756 if (not OnLadder()) or (FObj
.Vel
.Y
>= 0) or (OnTopLift()) then
7762 // Åñëè íà çåìëå è ìîæíî ïîäïðûãíóòü, òî, âîçìîæíî, ïðûãàåì:
7764 CanJumpUp(IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1)*32) and
7768 // Åñëè íà çåìëå è âîçëå äûðû (ãëóáèíà > 2 ðîñòîâ èãðîêà):
7769 if OnGround() and NearHole() then
7770 if NearDeepHole() then // Åñëè ýòî áåçäíà
7772 0..3: Turn(); // Áåæèì îáðàòíî
7773 4: Jump(); // Ïðûãàåì
7774 5: begin // Ïðûãàåì îáðàòíî
7779 else // Ýòî íå áåçäíà è ìû åùå íå ëåòèì òóäà
7780 if GetAIFlag('GOINHOLE') = '' then
7782 0: Turn(); // Íå íóæíî òóäà
7783 1: Jump(); // Âäðóã ïîâåçåò - ïðûãàåì
7784 else // Åñëè ÿìà ñ ãðàíèöåé, òî ïðè ñëó÷àå ìîæíî òóäà ïðûãíóòü
7785 if BorderHole() then
7786 SetAIFlag('GOINHOLE', '1');
7789 // Åñëè íà çåìëå, íî íåêóäà èäòè:
7790 if (not CanRun()) and OnGround() then
7792 // Åñëè ìû íà ëåñòíèöå èëè ìîæíî ïåðåïðûãíóòü, òî ïðûãàåì:
7793 if CanJumpOver() or OnLadder() then
7795 else // èíà÷å ïîïûòàåìñÿ â äðóãóþ ñòîðîíó
7796 if Random(2) = 0 then
7798 if IsSafeTrigger() then
7804 // Îñòàëîñü ìàëî âîçäóõà:
7805 if FAir
< 36 * 2 then
7808 // Âûáèðàåìñÿ èç êèñëîòû, åñëè íåò êîñòþìà, îáîæãëèñü, èëè ìàëî çäîðîâüÿ:
7809 if (FMegaRulez
[MR_SUIT
] < gTime
) and ((FLastHit
= HIT_ACID
) or (Healthy() <= 1)) then
7810 if BodyInAcid(0, 0) then
7814 function TBot
.FullInStep(XInc
, YInc
: Integer): Boolean;
7816 Result
:= g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
,
7817 PLAYER_RECT
.Width
, PLAYER_RECT
.Height
, PANEL_STEP
, False);
7820 {function TBot.NeedItem(Item: Byte): Byte;
7825 procedure TBot
.SelectWeapon(Dist
: Integer);
7829 function HaveAmmo(weapon
: Byte): Boolean;
7832 WEAPON_PISTOL
: Result
:= FAmmo
[A_BULLETS
] >= 1;
7833 WEAPON_SHOTGUN1
: Result
:= FAmmo
[A_SHELLS
] >= 1;
7834 WEAPON_SHOTGUN2
: Result
:= FAmmo
[A_SHELLS
] >= 2;
7835 WEAPON_CHAINGUN
: Result
:= FAmmo
[A_BULLETS
] >= 10;
7836 WEAPON_ROCKETLAUNCHER
: Result
:= FAmmo
[A_ROCKETS
] >= 1;
7837 WEAPON_PLASMA
: Result
:= FAmmo
[A_CELLS
] >= 10;
7838 WEAPON_BFG
: Result
:= FAmmo
[A_CELLS
] >= 40;
7839 WEAPON_SUPERPULEMET
: Result
:= FAmmo
[A_SHELLS
] >= 1;
7840 WEAPON_FLAMETHROWER
: Result
:= FAmmo
[A_FUEL
] >= 1;
7841 else Result
:= True;
7846 if Dist
= -1 then Dist
:= BOT_LONGDIST
;
7848 if Dist
> BOT_LONGDIST
then
7849 begin // Äàëüíèé áîé
7851 if FWeapon
[FDifficult
.WeaponPrior
[a
]] and HaveAmmo(FDifficult
.WeaponPrior
[a
]) then
7853 FSelectedWeapon
:= FDifficult
.WeaponPrior
[a
];
7857 else //if Dist > BOT_UNSAFEDIST then
7858 begin // Áëèæíèé áîé
7860 if FWeapon
[FDifficult
.CloseWeaponPrior
[a
]] and HaveAmmo(FDifficult
.CloseWeaponPrior
[a
]) then
7862 FSelectedWeapon
:= FDifficult
.CloseWeaponPrior
[a
];
7869 if FWeapon[FDifficult.SafeWeaponPrior[a]] and HaveAmmo(FDifficult.SafeWeaponPrior[a]) then
7871 FSelectedWeapon := FDifficult.SafeWeaponPrior[a];
7877 function TBot
.PickItem(ItemType
: Byte; force
: Boolean; var remove
: Boolean): Boolean;
7879 Result
:= inherited PickItem(ItemType
, force
, remove
);
7881 if Result
then SetAIFlag('SELECTWEAPON', '1');
7884 function TBot
.Heal(value
: Word; Soft
: Boolean): Boolean;
7886 Result
:= inherited Heal(value
, Soft
);
7889 function TBot
.Healthy(): Byte;
7891 if FMegaRulez
[MR_INVUL
] >= gTime
then Result
:= 3
7892 else if (FHealth
> 80) or ((FHealth
> 50) and (FArmor
> 20)) then Result
:= 3
7893 else if (FHealth
> 50) then Result
:= 2
7894 else if (FHealth
> 20) then Result
:= 1
7898 function TBot
.TargetOnScreen(TX
, TY
: Integer): Boolean;
7900 Result
:= (Abs(FObj
.X
-TX
) <= Trunc(gPlayerScreenSize
.X
*0.6)) and
7901 (Abs(FObj
.Y
-TY
) <= Trunc(gPlayerScreenSize
.Y
*0.6));
7904 procedure TBot
.OnDamage(Angle
: SmallInt);
7912 if (Angle
= 0) or (Angle
= 180) then
7915 if (g_GetUIDType(FLastSpawnerUID
) = UID_PLAYER
) and
7916 LongBool(gGameSettings
.Options
and GAME_OPTION_BOTVSPLAYER
) then
7918 pla
:= g_Player_Get(FLastSpawnerUID
);
7919 ok
:= not TargetOnScreen(pla
.FObj
.X
+ PLAYER_RECT
.X
,
7920 pla
.FObj
.Y
+ PLAYER_RECT
.Y
);
7923 if (g_GetUIDType(FLastSpawnerUID
) = UID_MONSTER
) and
7924 LongBool(gGameSettings
.Options
and GAME_OPTION_BOTVSMONSTER
) then
7926 mon
:= g_Monsters_ByUID(FLastSpawnerUID
);
7927 ok
:= not TargetOnScreen(mon
.Obj
.X
+ mon
.Obj
.Rect
.X
,
7928 mon
.Obj
.Y
+ mon
.Obj
.Rect
.Y
);
7933 SetAIFlag('ATTACKLEFT', '1')
7935 SetAIFlag('ATTACKRIGHT', '1');
7939 function TBot
.RunDirection(): TDirection
;
7941 if Abs(Vel
.X
) >= 1 then
7943 if Vel
.X
> 0 then Result
:= TDirection
.D_RIGHT
else Result
:= TDirection
.D_LEFT
;
7945 Result
:= FDirection
;
7948 function TBot
.GetRnd(a
: Byte): Boolean;
7950 if a
= 0 then Result
:= False
7951 else if a
= 255 then Result
:= True
7952 else Result
:= Random(256) > 255-a
;
7955 function TBot
.GetInterval(a
: Byte; radius
: SmallInt): SmallInt;
7957 Result
:= Round((255-a
)/255*radius
*(Random(2)-1));
7961 procedure TDifficult
.save (st
: TStream
);
7963 utils
.writeInt(st
, Byte(DiagFire
));
7964 utils
.writeInt(st
, Byte(InvisFire
));
7965 utils
.writeInt(st
, Byte(DiagPrecision
));
7966 utils
.writeInt(st
, Byte(FlyPrecision
));
7967 utils
.writeInt(st
, Byte(Cover
));
7968 utils
.writeInt(st
, Byte(CloseJump
));
7969 st
.WriteBuffer(WeaponPrior
[Low(WeaponPrior
)], sizeof(WeaponPrior
));
7970 st
.WriteBuffer(CloseWeaponPrior
[Low(CloseWeaponPrior
)], sizeof(CloseWeaponPrior
));
7973 procedure TDifficult
.load (st
: TStream
);
7975 DiagFire
:= utils
.readByte(st
);
7976 InvisFire
:= utils
.readByte(st
);
7977 DiagPrecision
:= utils
.readByte(st
);
7978 FlyPrecision
:= utils
.readByte(st
);
7979 Cover
:= utils
.readByte(st
);
7980 CloseJump
:= utils
.readByte(st
);
7981 st
.ReadBuffer(WeaponPrior
[Low(WeaponPrior
)], sizeof(WeaponPrior
));
7982 st
.ReadBuffer(CloseWeaponPrior
[Low(CloseWeaponPrior
)], sizeof(CloseWeaponPrior
));
7986 procedure TBot
.SaveState (st
: TStream
);
7991 inherited SaveState(st
);
7992 utils
.writeSign(st
, 'BOT0');
7994 utils
.writeInt(st
, Byte(FSelectedWeapon
));
7996 utils
.writeInt(st
, Word(FTargetUID
));
7997 // Âðåìÿ ïîòåðè öåëè
7998 utils
.writeInt(st
, LongWord(FLastVisible
));
7999 // Êîëè÷åñòâî ôëàãîâ ÈÈ
8000 dw
:= Length(FAIFlags
);
8001 utils
.writeInt(st
, LongInt(dw
));
8003 for i
:= 0 to dw
-1 do
8005 utils
.writeStr(st
, FAIFlags
[i
].Name
, 20);
8006 utils
.writeStr(st
, FAIFlags
[i
].Value
, 20);
8008 // Íàñòðîéêè ñëîæíîñòè
8009 FDifficult
.save(st
);
8013 procedure TBot
.LoadState (st
: TStream
);
8018 inherited LoadState(st
);
8019 if not utils
.checkSign(st
, 'BOT0') then raise XStreamError
.Create('invalid bot signature');
8021 FSelectedWeapon
:= utils
.readByte(st
);
8023 FTargetUID
:= utils
.readWord(st
);
8024 // Âðåìÿ ïîòåðè öåëè
8025 FLastVisible
:= utils
.readLongWord(st
);
8026 // Êîëè÷åñòâî ôëàãîâ ÈÈ
8027 dw
:= utils
.readLongInt(st
);
8028 if (dw
< 0) or (dw
> 16384) then raise XStreamError
.Create('invalid number of bot AI flags');
8029 SetLength(FAIFlags
, dw
);
8031 for i
:= 0 to dw
-1 do
8033 FAIFlags
[i
].Name
:= utils
.readStr(st
, 20);
8034 FAIFlags
[i
].Value
:= utils
.readStr(st
, 20);
8036 // Íàñòðîéêè ñëîæíîñòè
8037 FDifficult
.load(st
);
8042 conRegVar('cheat_berserk_autoswitch', @gBerserkAutoswitch
, 'autoswitch to fist when berserk pack taken', '', true, true);
8043 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');
8044 conRegVar('player_indicator_style', @gPlayerIndicatorStyle
, 'Visual appearance of indicator', 'Visual appearance of indicator');