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);
120 TPlayerStatArray
= Array of TPlayerStat
;
122 TPlayerSavedState
= record
130 Ammo
: Array [A_BULLETS
..A_HIGH
] of Word;
131 MaxAmmo
: Array [A_BULLETS
..A_HIGH
] of Word;
132 Weapon
: Array [WP_FIRST
..WP_LAST
] of Boolean;
133 Rulez
: Set of R_ITEM_BACKPACK
..R_BERSERK
;
142 TPlayer
= class{$IFDEF USE_MEMPOOL}(TPoolObject
){$ENDIF}
150 FDirection
: TDirection
;
158 FMonsterKills
: Integer;
164 FCanJetpack
: Boolean;
170 FNextWeapDelay
: Byte; // frames
171 FBFGFireCounter
: SmallInt;
172 FLastSpawnerUID
: Word;
176 FSpectatePlayer
: Integer;
177 FFirePainTime
: Integer;
180 FSavedStateNum
: Integer;
182 FModel
: TPlayerModel
;
183 FPunchAnim
: TAnimation
;
186 FActionForce
: Boolean;
187 FActionChanged
: Boolean;
189 FFireAngle
: SmallInt;
193 FShellTimer
: Integer;
195 FSawSound
: TPlayableSound
;
196 FSawSoundIdle
: TPlayableSound
;
197 FSawSoundHit
: TPlayableSound
;
198 FSawSoundSelect
: TPlayableSound
;
199 FFlameSoundOn
: TPlayableSound
;
200 FFlameSoundOff
: TPlayableSound
;
201 FFlameSoundWork
: TPlayableSound
;
202 FJetSoundOn
: TPlayableSound
;
203 FJetSoundOff
: TPlayableSound
;
204 FJetSoundFly
: TPlayableSound
;
208 FJustTeleported
: Boolean;
210 mEDamageType
: Integer;
213 function CollideLevel(XInc
, YInc
: Integer): Boolean;
214 function StayOnStep(XInc
, YInc
: Integer): Boolean;
215 function HeadInLiquid(XInc
, YInc
: Integer): Boolean;
216 function BodyInLiquid(XInc
, YInc
: Integer): Boolean;
217 function BodyInAcid(XInc
, YInc
: Integer): Boolean;
218 function FullInLift(XInc
, YInc
: Integer): Integer;
219 {procedure CollideItem();}
220 procedure FlySmoke(Times
: DWORD
= 1);
221 procedure OnFireFlame(Times
: DWORD
= 1);
222 function GetAmmoByWeapon(Weapon
: Byte): Word;
223 procedure SetAction(Action
: Byte; Force
: Boolean = False);
224 procedure OnDamage(Angle
: SmallInt); virtual;
225 function firediry(): Integer;
228 procedure Run(Direction
: TDirection
);
229 procedure NextWeapon();
230 procedure PrevWeapon();
237 function getNextWeaponIndex (): Byte; // return 255 for "no switch"
238 procedure resetWeaponQueue ();
239 function hasAmmoForWeapon (weapon
: Byte): Boolean;
241 procedure doDamage (v
: Integer);
243 function refreshCorpse(): Boolean;
246 FDamageBuffer
: Integer;
248 FAmmo
: Array [A_BULLETS
..A_HIGH
] of Word;
249 FMaxAmmo
: Array [A_BULLETS
..A_HIGH
] of Word;
250 FWeapon
: Array [WP_FIRST
..WP_LAST
] of Boolean;
251 FRulez
: Set of R_ITEM_BACKPACK
..R_BERSERK
;
253 FMegaRulez
: Array [MR_SUIT
..MR_MAX
] of DWORD
;
254 FReloading
: Array [WP_FIRST
..WP_LAST
] of Word;
255 FTime
: Array [T_RESPAWN
..T_FLAGCAP
] of DWORD
;
256 FKeys
: Array [KEY_LEFT
..KEY_CHAT
] of TKeyState
;
258 FPreferredTeam
: Byte;
261 FWantsInGame
: Boolean;
266 FActualModelName
: string;
273 FSpawnInvul
: Integer;
275 FWaitForFirstSpawn
: Boolean; // set to `true` in server, used to spawn a player on first full state request
278 // debug: viewport offset
279 viewPortX
, viewPortY
, viewPortW
, viewPortH
: Integer;
281 function isValidViewPort (): Boolean; inline;
283 constructor Create(); virtual;
284 destructor Destroy(); override;
285 procedure Respawn(Silent
: Boolean; Force
: Boolean = False); virtual;
286 function GetRespawnPoint(): Byte;
287 procedure PressKey(Key
: Byte; Time
: Word = 1);
288 procedure ReleaseKeys();
289 procedure SetModel(ModelName
: String);
290 procedure SetColor(Color
: TRGB
);
291 function GetColor(): TRGB
;
292 procedure SetWeapon(W
: Byte);
293 function IsKeyPressed(K
: Byte): Boolean;
294 function GetKeys(): Byte;
295 function PickItem(ItemType
: Byte; arespawn
: Boolean; var remove
: Boolean): Boolean; virtual;
296 function Collide(X
, Y
: Integer; Width
, Height
: Word): Boolean; overload
;
297 function Collide(Panel
: TPanel
): Boolean; overload
;
298 function Collide(X
, Y
: Integer): Boolean; overload
;
299 procedure SetDirection(Direction
: TDirection
);
300 procedure GetSecret();
301 function TeleportTo(X
, Y
: Integer; silent
: Boolean; dir
: Byte): Boolean;
303 procedure Push(vx
, vy
: Integer);
304 procedure ChangeModel(ModelName
: String);
305 procedure SwitchTeam
;
306 procedure ChangeTeam(Team
: Byte);
308 function GetFlag(Flag
: Byte): Boolean;
309 procedure SetFlag(Flag
: Byte);
310 function DropFlag(Silent
: Boolean = True): Boolean;
311 procedure AllRulez(Health
: Boolean);
312 procedure RestoreHealthArmor();
313 procedure FragCombo();
314 procedure GiveItem(ItemType
: Byte);
315 procedure Damage(value
: Word; SpawnerUID
: Word; vx
, vy
: Integer; t
: Byte); virtual;
316 function Heal(value
: Word; Soft
: Boolean): Boolean; virtual;
317 procedure MakeBloodVector(Count
: Word; VelX
, VelY
: Integer);
318 procedure MakeBloodSimple(Count
: Word);
319 procedure Kill(KillType
: Byte; SpawnerUID
: Word; t
: Byte);
320 procedure Reset(Force
: Boolean);
321 procedure Spectate(NoMove
: Boolean = False);
322 procedure SwitchNoClip
;
323 procedure SoftReset();
324 procedure Draw(); virtual;
325 procedure DrawPain();
326 procedure DrawPickup();
327 procedure DrawRulez();
329 procedure DrawIndicator(Color
: TRGB
);
330 procedure DrawBubble();
332 procedure PreUpdate();
333 procedure Update(); virtual;
334 procedure RememberState();
335 procedure RecallState();
336 procedure SaveState (st
: TStream
); virtual;
337 procedure LoadState (st
: TStream
); virtual;
338 procedure PauseSounds(Enable
: Boolean);
339 procedure NetFire(Wpn
: Byte; X
, Y
, AX
, AY
: Integer; WID
: Integer = -1);
340 procedure DoLerp(Level
: Integer = 2);
341 procedure SetLerp(XTo
, YTo
: Integer);
342 procedure QueueWeaponSwitch(Weapon
: Byte);
343 procedure RealizeCurrentWeapon();
347 procedure JetpackOff
;
348 procedure CatchFire(Attacker
: Word; Timeout
: Integer = PLAYER_BURN_TIME
);
350 //WARNING! this does nothing for now, but still call it!
351 procedure positionChanged (); //WARNING! call this after entity position was changed, or coldet will not work right!
353 procedure getMapBox (out x
, y
, w
, h
: Integer); inline;
354 procedure moveBy (dx
, dy
: Integer); inline;
356 function getCameraObj(): TObj
;
359 property Vel
: TPoint2i read FObj
.Vel
;
360 property Obj
: TObj read FObj
;
362 property Name
: String read FName write FName
;
363 property Model
: TPlayerModel read FModel
;
364 property Health
: Integer read FHealth write FHealth
;
365 property Lives
: Byte read FLives write FLives
;
366 property Armor
: Integer read FArmor write FArmor
;
367 property Air
: Integer read FAir write FAir
;
368 property JetFuel
: Integer read FJetFuel write FJetFuel
;
369 property Frags
: Integer read FFrags write FFrags
;
370 property Death
: Integer read FDeath write FDeath
;
371 property Kills
: Integer read FKills write FKills
;
372 property CurrWeap
: Byte read FCurrWeap write FCurrWeap
;
373 property MonsterKills
: Integer read FMonsterKills write FMonsterKills
;
374 property Secrets
: Integer read FSecrets
;
375 property GodMode
: Boolean read FGodMode write FGodMode
;
376 property NoTarget
: Boolean read FNoTarget write FNoTarget
;
377 property NoReload
: Boolean read FNoReload write FNoReload
;
378 property alive
: Boolean read FAlive write FAlive
;
379 property Flag
: Byte read FFlag
;
380 property Team
: Byte read FTeam write FTeam
;
381 property Direction
: TDirection read FDirection
;
382 property GameX
: Integer read FObj
.X write FObj
.X
;
383 property GameY
: Integer read FObj
.Y write FObj
.Y
;
384 property GameVelX
: Integer read FObj
.Vel
.X write FObj
.Vel
.X
;
385 property GameVelY
: Integer read FObj
.Vel
.Y write FObj
.Vel
.Y
;
386 property GameAccelX
: Integer read FObj
.Accel
.X write FObj
.Accel
.X
;
387 property GameAccelY
: Integer read FObj
.Accel
.Y write FObj
.Accel
.Y
;
388 property IncCam
: Integer read FIncCam write FIncCam
;
389 property IncCamOld
: Integer read FIncCamOld write FIncCamOld
;
390 property SlopeOld
: Integer read FSlopeOld write FSlopeOld
;
391 property UID
: Word read FUID write FUID
;
392 property JustTeleported
: Boolean read FJustTeleported write FJustTeleported
;
393 property NetTime
: LongWord read FNetTime write FNetTime
;
396 property eName
: String read FName write FName
;
397 property eHealth
: Integer read FHealth write FHealth
;
398 property eLives
: Byte read FLives write FLives
;
399 property eArmor
: Integer read FArmor write FArmor
;
400 property eAir
: Integer read FAir write FAir
;
401 property eJetFuel
: Integer read FJetFuel write FJetFuel
;
402 property eFrags
: Integer read FFrags write FFrags
;
403 property eDeath
: Integer read FDeath write FDeath
;
404 property eKills
: Integer read FKills write FKills
;
405 property eCurrWeap
: Byte read FCurrWeap write FCurrWeap
;
406 property eMonsterKills
: Integer read FMonsterKills write FMonsterKills
;
407 property eSecrets
: Integer read FSecrets write FSecrets
;
408 property eGodMode
: Boolean read FGodMode write FGodMode
;
409 property eNoTarget
: Boolean read FNoTarget write FNoTarget
;
410 property eNoReload
: Boolean read FNoReload write FNoReload
;
411 property eAlive
: Boolean read FAlive write FAlive
;
412 property eFlag
: Byte read FFlag
;
413 property eTeam
: Byte read FTeam write FTeam
;
414 property eDirection
: TDirection read FDirection
;
415 property eGameX
: Integer read FObj
.X write FObj
.X
;
416 property eGameY
: Integer read FObj
.Y write FObj
.Y
;
417 property eGameVelX
: Integer read FObj
.Vel
.X write FObj
.Vel
.X
;
418 property eGameVelY
: Integer read FObj
.Vel
.Y write FObj
.Vel
.Y
;
419 property eGameAccelX
: Integer read FObj
.Accel
.X write FObj
.Accel
.X
;
420 property eGameAccelY
: Integer read FObj
.Accel
.Y write FObj
.Accel
.Y
;
421 property eIncCam
: Integer read FIncCam write FIncCam
;
422 property eUID
: Word read FUID
;
423 property eJustTeleported
: Boolean read FJustTeleported
;
424 property eNetTime
: LongWord read FNetTime
;
426 // set this before assigning something to `eDamage`
427 property eDamageType
: Integer read mEDamageType write mEDamageType
;
428 property eDamage
: Integer write doDamage
;
439 WeaponPrior
: packed array [WP_FIRST
..WP_LAST
] of Byte;
440 CloseWeaponPrior
: packed array [WP_FIRST
..WP_LAST
] of Byte;
441 //SafeWeaponPrior: Array [WP_FIRST..WP_LAST] of Byte;
444 procedure save (st
: TStream
);
445 procedure load (st
: TStream
);
453 TBot
= class(TPlayer
)
455 FSelectedWeapon
: Byte;
458 FAIFlags
: Array of TAIFlag
;
459 FDifficult
: TDifficult
;
461 function GetRnd(a
: Byte): Boolean;
462 function GetInterval(a
: Byte; radius
: SmallInt): SmallInt;
463 function RunDirection(): TDirection
;
464 function FullInStep(XInc
, YInc
: Integer): Boolean;
465 //function NeedItem(Item: Byte): Byte;
466 procedure SelectWeapon(Dist
: Integer);
467 procedure SetAIFlag(aName
, fValue
: String20
);
468 function GetAIFlag(aName
: String20
): String20
;
469 procedure RemoveAIFlag(aName
: String20
);
470 function Healthy(): Byte;
471 procedure UpdateMove();
472 procedure UpdateCombat();
473 function KeyPressed(Key
: Word): Boolean;
474 procedure ReleaseKey(Key
: Byte);
475 function TargetOnScreen(TX
, TY
: Integer): Boolean;
476 procedure OnDamage(Angle
: SmallInt); override;
479 procedure Respawn(Silent
: Boolean; Force
: Boolean = False); override;
480 constructor Create(); override;
481 destructor Destroy(); override;
482 procedure Draw(); override;
483 function PickItem(ItemType
: Byte; force
: Boolean; var remove
: Boolean): Boolean; override;
484 function Heal(value
: Word; Soft
: Boolean): Boolean; override;
485 procedure Update(); override;
486 procedure SaveState (st
: TStream
); override;
487 procedure LoadState (st
: TStream
); override;
499 procedure getMapBox (out x
, y
, w
, h
: Integer); inline;
500 procedure moveBy (dx
, dy
: Integer); inline;
502 procedure positionChanged (); inline; //WARNING! call this after entity position was changed, or coldet will not work right!
516 procedure getMapBox (out x
, y
, w
, h
: Integer); inline;
517 procedure moveBy (dx
, dy
: Integer); inline;
519 procedure positionChanged (); inline; //WARNING! call this after entity position was changed, or coldet will not work right!
522 TCorpse
= class{$IFDEF USE_MEMPOOL}(TPoolObject
){$ENDIF}
531 FAnimation
: TAnimation
;
532 FAnimationMask
: TAnimation
;
535 constructor Create(X
, Y
: Integer; ModelName
: String; aMess
: Boolean);
536 destructor Destroy(); override;
537 procedure Damage(Value
: Word; SpawnerUID
: Word; vx
, vy
: Integer);
540 procedure SaveState (st
: TStream
);
541 procedure LoadState (st
: TStream
);
543 procedure getMapBox (out x
, y
, w
, h
: Integer); inline;
544 procedure moveBy (dx
, dy
: Integer); inline;
546 procedure positionChanged (); inline; //WARNING! call this after entity position was changed, or coldet will not work right!
548 function ObjPtr (): PObj
; inline;
550 property Obj
: TObj read FObj
; // copies object
551 property State
: Byte read FState
;
552 property Mess
: Boolean read FMess
;
555 TTeamStat
= Array [TEAM_RED
..TEAM_BLUE
] of
561 gPlayers
: Array of TPlayer
;
562 gCorpses
: Array of TCorpse
;
563 gGibs
: Array of TGib
;
564 gShells
: Array of TShell
;
565 gTeamStat
: TTeamStat
;
566 gFly
: Boolean = False;
567 gAimLine
: Boolean = False;
568 gChatBubble
: Integer = 0;
569 gPlayerIndicator
: Integer = 1;
570 gPlayerIndicatorStyle
: Integer = 0;
572 gSpectLatchPID1
: Word = 0;
573 gSpectLatchPID2
: Word = 0;
574 MAX_RUNVEL
: Integer = 8;
575 VEL_JUMP
: Integer = 10;
576 SHELL_TIMEOUT
: Cardinal = 60000;
578 function Lerp(X
, Y
, Factor
: Integer): Integer;
580 procedure g_Gibs_SetMax(Count
: Word);
581 function g_Gibs_GetMax(): Word;
582 procedure g_Corpses_SetMax(Count
: Word);
583 function g_Corpses_GetMax(): Word;
584 procedure g_Shells_SetMax(Count
: Word);
585 function g_Shells_GetMax(): Word;
587 procedure g_Player_Init();
588 procedure g_Player_Free();
589 function g_Player_Create(ModelName
: String; Color
: TRGB
; Team
: Byte; Bot
: Boolean): Word;
590 function g_Player_CreateFromState (st
: TStream
): Word;
591 procedure g_Player_Remove(UID
: Word);
592 procedure g_Player_ResetTeams();
593 procedure g_Player_PreUpdate();
594 procedure g_Player_UpdateAll();
595 procedure g_Player_DrawAll();
596 procedure g_Player_DrawDebug(p
: TPlayer
);
597 procedure g_Player_DrawHealth();
598 procedure g_Player_RememberAll();
599 procedure g_Player_ResetAll(Force
, Silent
: Boolean);
600 function g_Player_Get(UID
: Word): TPlayer
;
601 function g_Player_GetCount(): Byte;
602 function g_Player_GetStats(): TPlayerStatArray
;
603 function g_Player_ValidName(Name
: String): Boolean;
604 function g_Player_CreateCorpse(Player
: TPlayer
): Integer;
605 procedure g_Player_CreateGibs(fX
, fY
: Integer; ModelName
: String; fColor
: TRGB
);
606 procedure g_Player_CreateShell(fX
, fY
, dX
, dY
: Integer; T
: Byte);
607 procedure g_Player_UpdatePhysicalObjects();
608 procedure g_Player_DrawCorpses();
609 procedure g_Player_DrawShells();
610 procedure g_Player_RemoveAllCorpses();
611 procedure g_Player_Corpses_SaveState (st
: TStream
);
612 procedure g_Player_Corpses_LoadState (st
: TStream
);
613 procedure g_Player_ResetReady();
614 procedure g_Bot_Add(Team
, Difficult
: Byte; Handicap
: Integer = 100);
615 procedure g_Bot_AddList(Team
: Byte; lname
: ShortString; num
: Integer = -1; Handicap
: Integer = 100);
616 procedure g_Bot_MixNames();
617 procedure g_Bot_RemoveAll();
622 {$INCLUDE ../nogl/noGLuses.inc}
623 {$IFDEF ENABLE_HOLMES}
626 e_log
, g_map
, g_items
, g_console
, g_gfx
, Math
,
627 g_options
, g_triggers
, g_menu
, g_game
, g_grid
, e_res
,
628 wadreader
, g_main
, g_monsters
, CONFIG
, g_language
,
629 g_net
, g_netmsg
, g_window
,
632 const PLR_SAVE_VERSION
= 0;
642 diag_precision
: Byte;
646 w_prior1
: Array [WP_FIRST
..WP_LAST
] of Byte;
647 w_prior2
: Array [WP_FIRST
..WP_LAST
] of Byte;
648 w_prior3
: Array [WP_FIRST
..WP_LAST
] of Byte;
652 TIME_RESPAWN1
= 1500;
653 TIME_RESPAWN2
= 2000;
654 TIME_RESPAWN3
= 3000;
657 JET_MAX
= 540; // ~30 sec
658 PLAYER_SUIT_TIME
= 30000;
659 PLAYER_INVUL_TIME
= 30000;
660 PLAYER_INVIS_TIME
= 35000;
661 FRAG_COMBO_TIME
= 3000;
665 ANGLE_RIGHTDOWN
= -35;
667 ANGLE_LEFTDOWN
= -145;
668 PLAYER_HEADRECT
: TRectWH
= (X
:24; Y
:12; Width
:20; Height
:12);
669 WEAPONPOINT
: Array [TDirection
] of TDFPoint
= ((X
:16; Y
:32), (X
:47; Y
:32));
672 BOT_UNSAFEDIST
= 128;
673 TEAMCOLOR
: Array [TEAM_RED
..TEAM_BLUE
] of TRGB
= ((R
:255; G
:0; B
:0),
675 DIFFICULT_EASY
: TDifficult
= (DiagFire
: 32; InvisFire
: 32; DiagPrecision
: 32;
676 FlyPrecision
: 32; Cover
: 32; CloseJump
: 32;
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 DIFFICULT_MEDIUM
: TDifficult
= (DiagFire
: 127; InvisFire
: 127; DiagPrecision
: 127;
679 FlyPrecision
: 127; Cover
: 127; CloseJump
: 127;
680 WeaponPrior
:(0,0,0,0,0,0,0,0,0,0,0); CloseWeaponPrior
:(0,0,0,0,0,0,0,0,0,0,0));
681 DIFFICULT_HARD
: TDifficult
= (DiagFire
: 255; InvisFire
: 255; DiagPrecision
: 255;
682 FlyPrecision
: 255; Cover
: 255; CloseJump
: 255;
683 WeaponPrior
:(0,0,0,0,0,0,0,0,0,0,0); CloseWeaponPrior
:(0,0,0,0,0,0,0,0,0,0,0));
684 WEAPON_PRIOR1
: Array [WP_FIRST
..WP_LAST
] of Byte =
685 (WEAPON_FLAMETHROWER
, WEAPON_SUPERPULEMET
,
686 WEAPON_SHOTGUN2
, WEAPON_SHOTGUN1
,
687 WEAPON_CHAINGUN
, WEAPON_PLASMA
, WEAPON_ROCKETLAUNCHER
,
688 WEAPON_BFG
, WEAPON_PISTOL
, WEAPON_SAW
, WEAPON_KASTET
);
689 WEAPON_PRIOR2
: Array [WP_FIRST
..WP_LAST
] of Byte =
690 (WEAPON_FLAMETHROWER
, WEAPON_SUPERPULEMET
,
691 WEAPON_BFG
, WEAPON_ROCKETLAUNCHER
,
692 WEAPON_SHOTGUN2
, WEAPON_PLASMA
, WEAPON_SHOTGUN1
,
693 WEAPON_CHAINGUN
, WEAPON_PISTOL
, WEAPON_SAW
, WEAPON_KASTET
);
694 //WEAPON_PRIOR3: Array [WP_FIRST..WP_LAST] of Byte =
695 // (WEAPON_FLAMETHROWER, WEAPON_SUPERPULEMET,
696 // WEAPON_BFG, WEAPON_PLASMA, WEAPON_SHOTGUN2,
697 // WEAPON_CHAINGUN, WEAPON_SHOTGUN1, WEAPON_SAW,
698 // WEAPON_ROCKETLAUNCHER, WEAPON_PISTOL, WEAPON_KASTET);
699 WEAPON_RELOAD
: Array [WP_FIRST
..WP_LAST
] of Byte =
700 (5, 2, 6, 18, 36, 2, 12, 2, 14, 2, 2);
702 PLAYER_SIGNATURE
= $52594C50; // 'PLYR'
703 CORPSE_SIGNATURE
= $50524F43; // 'CORP'
705 BOTNAMES_FILENAME
= 'botnames.txt';
706 BOTLIST_FILENAME
= 'botlist.txt';
710 MaxCorpses
: Word = 20;
711 MaxShells
: Word = 300;
712 CurrentGib
: Integer = 0;
713 CurrentShell
: Integer = 0;
714 BotNames
: Array of String;
715 BotList
: Array of TBotProfile
;
716 SavedStates
: Array of TPlayerSavedState
;
719 function Lerp(X
, Y
, Factor
: Integer): Integer;
721 Result
:= X
+ ((Y
- X
) div Factor
);
724 function SameTeam(UID1
, UID2
: Word): Boolean;
728 if (UID1
> UID_MAX_PLAYER
) or (UID1
<= UID_MAX_GAME
) or
729 (UID2
> UID_MAX_PLAYER
) or (UID2
<= UID_MAX_GAME
) then Exit
;
731 if (g_Player_Get(UID1
) = nil) or (g_Player_Get(UID2
) = nil) then Exit
;
733 if ((g_Player_Get(UID1
).Team
= TEAM_NONE
) or
734 (g_Player_Get(UID2
).Team
= TEAM_NONE
)) then Exit
;
736 Result
:= g_Player_Get(UID1
).FTeam
= g_Player_Get(UID2
).FTeam
;
739 procedure g_Gibs_SetMax(Count
: Word);
742 SetLength(gGibs
, Count
);
744 if CurrentGib
>= Count
then
748 function g_Gibs_GetMax(): Word;
753 procedure g_Shells_SetMax(Count
: Word);
756 SetLength(gShells
, Count
);
758 if CurrentShell
>= Count
then
762 function g_Shells_GetMax(): Word;
768 procedure g_Corpses_SetMax(Count
: Word);
771 SetLength(gCorpses
, Count
);
774 function g_Corpses_GetMax(): Word;
776 Result
:= MaxCorpses
;
779 function g_Player_Create(ModelName
: String; Color
: TRGB
; Team
: Byte; Bot
: Boolean): Word;
789 // Åñòü ëè ìåñòî â gPlayers:
790 if gPlayers
<> nil then
791 for a
:= 0 to High(gPlayers
) do
792 if gPlayers
[a
] = nil then
798 // Íåò ìåñòà - ðàñøèðÿåì gPlayers:
801 SetLength(gPlayers
, Length(gPlayers
)+1);
805 // Ñîçäàåì îáúåêò èãðîêà:
807 gPlayers
[a
] := TBot
.Create()
809 gPlayers
[a
] := TPlayer
.Create();
812 gPlayers
[a
].FActualModelName
:= ModelName
;
813 gPlayers
[a
].SetModel(ModelName
);
815 // Íåò ìîäåëè - ñîçäàíèå íå âîçìîæíî:
816 if gPlayers
[a
].FModel
= nil then
820 g_FatalError(Format(_lc
[I_GAME_ERROR_MODEL
], [ModelName
]));
824 if not (Team
in [TEAM_RED
, TEAM_BLUE
]) then
825 if Random(2) = 0 then
829 gPlayers
[a
].FPreferredTeam
:= Team
;
831 case gGameSettings
.GameMode
of
832 GM_DM
: gPlayers
[a
].FTeam
:= TEAM_NONE
;
834 GM_CTF
: gPlayers
[a
].FTeam
:= gPlayers
[a
].FPreferredTeam
;
836 GM_COOP
: gPlayers
[a
].FTeam
:= TEAM_COOP
;
839 // Åñëè êîìàíäíàÿ èãðà - êðàñèì ìîäåëü â öâåò êîìàíäû:
840 gPlayers
[a
].FColor
:= Color
;
841 if gPlayers
[a
].FTeam
in [TEAM_RED
, TEAM_BLUE
] then
842 gPlayers
[a
].FModel
.Color
:= TEAMCOLOR
[gPlayers
[a
].FTeam
]
844 gPlayers
[a
].FModel
.Color
:= Color
;
846 gPlayers
[a
].FUID
:= g_CreateUID(UID_PLAYER
);
847 gPlayers
[a
].FAlive
:= False;
849 Result
:= gPlayers
[a
].FUID
;
852 function g_Player_CreateFromState (st
: TStream
): Word;
859 if (st
= nil) then exit
; //???
862 if not utils
.checkSign(st
, 'PLYR') then raise XStreamError
.Create('invalid player signature');
863 if (utils
.readByte(st
) <> PLR_SAVE_VERSION
) then raise XStreamError
.Create('invalid player version');
866 Bot
:= utils
.readBool(st
);
871 // Åñòü ëè ìåñòî â gPlayers:
872 for a
:= 0 to High(gPlayers
) do if (gPlayers
[a
] = nil) then begin ok
:= true; break
; end;
874 // Íåò ìåñòà - ðàñøèðÿåì gPlayers
877 SetLength(gPlayers
, Length(gPlayers
)+1);
881 // Ñîçäàåì îáúåêò èãðîêà
883 gPlayers
[a
] := TBot
.Create()
885 gPlayers
[a
] := TPlayer
.Create();
886 gPlayers
[a
].FIamBot
:= Bot
;
887 gPlayers
[a
].FPhysics
:= True;
890 gPlayers
[a
].FUID
:= utils
.readWord(st
);
892 gPlayers
[a
].FName
:= utils
.readStr(st
);
894 gPlayers
[a
].FTeam
:= utils
.readByte(st
);
895 gPlayers
[a
].FPreferredTeam
:= gPlayers
[a
].FTeam
;
897 gPlayers
[a
].FAlive
:= utils
.readBool(st
);
898 // Èçðàñõîäîâàë ëè âñå æèçíè
899 gPlayers
[a
].FNoRespawn
:= utils
.readBool(st
);
901 b
:= utils
.readByte(st
);
902 if b
= 1 then gPlayers
[a
].FDirection
:= TDirection
.D_LEFT
else gPlayers
[a
].FDirection
:= TDirection
.D_RIGHT
; // b = 2
904 gPlayers
[a
].FHealth
:= utils
.readLongInt(st
);
906 gPlayers
[a
].FHandicap
:= utils
.readLongInt(st
);
908 gPlayers
[a
].FLives
:= utils
.readByte(st
);
910 gPlayers
[a
].FArmor
:= utils
.readLongInt(st
);
912 gPlayers
[a
].FAir
:= utils
.readLongInt(st
);
914 gPlayers
[a
].FJetFuel
:= utils
.readLongInt(st
);
916 gPlayers
[a
].FPain
:= utils
.readLongInt(st
);
918 gPlayers
[a
].FKills
:= utils
.readLongInt(st
);
920 gPlayers
[a
].FMonsterKills
:= utils
.readLongInt(st
);
922 gPlayers
[a
].FFrags
:= utils
.readLongInt(st
);
924 gPlayers
[a
].FFragCombo
:= utils
.readByte(st
);
925 // Âðåìÿ ïîñëåäíåãî ôðàãà
926 gPlayers
[a
].FLastFrag
:= utils
.readLongWord(st
);
928 gPlayers
[a
].FDeath
:= utils
.readLongInt(st
);
930 gPlayers
[a
].FFlag
:= utils
.readByte(st
);
932 gPlayers
[a
].FSecrets
:= utils
.readLongInt(st
);
934 gPlayers
[a
].FCurrWeap
:= utils
.readByte(st
);
935 // Ñëåäóþùåå æåëàåìîå îðóæèå
936 gPlayers
[a
].FNextWeap
:= utils
.readWord(st
);
938 gPlayers
[a
].FNextWeapDelay
:= utils
.readByte(st
);
940 gPlayers
[a
].FBFGFireCounter
:= utils
.readSmallInt(st
);
942 gPlayers
[a
].FDamageBuffer
:= utils
.readLongInt(st
);
943 // Ïîñëåäíèé óäàðèâøèé
944 gPlayers
[a
].FLastSpawnerUID
:= utils
.readWord(st
);
945 // Òèï ïîñëåäíåãî ïîëó÷åííîãî óðîíà
946 gPlayers
[a
].FLastHit
:= utils
.readByte(st
);
948 Obj_LoadState(@gPlayers
[a
].FObj
, st
);
949 // Òåêóùåå êîëè÷åñòâî ïàòðîíîâ
950 for i
:= A_BULLETS
to A_HIGH
do gPlayers
[a
].FAmmo
[i
] := utils
.readWord(st
);
951 // Ìàêñèìàëüíîå êîëè÷åñòâî ïàòðîíîâ
952 for i
:= A_BULLETS
to A_HIGH
do gPlayers
[a
].FMaxAmmo
[i
] := utils
.readWord(st
);
954 for i
:= WP_FIRST
to WP_LAST
do gPlayers
[a
].FWeapon
[i
] := utils
.readBool(st
);
955 // Âðåìÿ ïåðåçàðÿäêè îðóæèÿ
956 for i
:= WP_FIRST
to WP_LAST
do gPlayers
[a
].FReloading
[i
] := utils
.readWord(st
);
958 if utils
.readBool(st
) then Include(gPlayers
[a
].FRulez
, R_ITEM_BACKPACK
);
959 // Íàëè÷èå êðàñíîãî êëþ÷à
960 if utils
.readBool(st
) then Include(gPlayers
[a
].FRulez
, R_KEY_RED
);
961 // Íàëè÷èå çåëåíîãî êëþ÷à
962 if utils
.readBool(st
) then Include(gPlayers
[a
].FRulez
, R_KEY_GREEN
);
963 // Íàëè÷èå ñèíåãî êëþ÷à
964 if utils
.readBool(st
) then Include(gPlayers
[a
].FRulez
, R_KEY_BLUE
);
966 if utils
.readBool(st
) then Include(gPlayers
[a
].FRulez
, R_BERSERK
);
967 // Âðåìÿ äåéñòâèÿ ñïåöèàëüíûõ ïðåäìåòîâ
968 for i
:= MR_SUIT
to MR_MAX
do gPlayers
[a
].FMegaRulez
[i
] := utils
.readLongWord(st
);
969 // Âðåìÿ äî ïîâòîðíîãî ðåñïàóíà, ñìåíû îðóæèÿ, èñîëüçîâàíèÿ, çàõâàòà ôëàãà
970 for i
:= T_RESPAWN
to T_FLAGCAP
do gPlayers
[a
].FTime
[i
] := utils
.readLongWord(st
);
973 gPlayers
[a
].FActualModelName
:= utils
.readStr(st
);
975 gPlayers
[a
].FColor
.R
:= utils
.readByte(st
);
976 gPlayers
[a
].FColor
.G
:= utils
.readByte(st
);
977 gPlayers
[a
].FColor
.B
:= utils
.readByte(st
);
978 // Îáíîâëÿåì ìîäåëü èãðîêà
979 gPlayers
[a
].SetModel(gPlayers
[a
].FActualModelName
);
981 // Íåò ìîäåëè - ñîçäàíèå íåâîçìîæíî
982 if (gPlayers
[a
].FModel
= nil) then
986 g_FatalError(Format(_lc
[I_GAME_ERROR_MODEL
], [gPlayers
[a
].FActualModelName
]));
990 // Åñëè êîìàíäíàÿ èãðà - êðàñèì ìîäåëü â öâåò êîìàíäû
991 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
992 gPlayers
[a
].FModel
.Color
:= TEAMCOLOR
[gPlayers
[a
].FTeam
]
994 gPlayers
[a
].FModel
.Color
:= gPlayers
[a
].FColor
;
996 result
:= gPlayers
[a
].FUID
;
1000 procedure g_Player_ResetTeams();
1004 if g_Game_IsClient
then
1006 if gPlayers
= nil then
1008 for a
:= Low(gPlayers
) to High(gPlayers
) do
1009 if gPlayers
[a
] <> nil then
1010 case gGameSettings
.GameMode
of
1012 gPlayers
[a
].ChangeTeam(TEAM_NONE
);
1014 if not (gPlayers
[a
].Team
in [TEAM_RED
, TEAM_BLUE
]) then
1015 if gPlayers
[a
].FPreferredTeam
in [TEAM_RED
, TEAM_BLUE
] then
1016 gPlayers
[a
].ChangeTeam(gPlayers
[a
].FPreferredTeam
)
1019 gPlayers
[a
].ChangeTeam(TEAM_RED
)
1021 gPlayers
[a
].ChangeTeam(TEAM_BLUE
);
1024 gPlayers
[a
].ChangeTeam(TEAM_COOP
);
1028 procedure g_Bot_Add(Team
, Difficult
: Byte; Handicap
: Integer = 100);
1031 _name
, _model
: String;
1034 if not g_Game_IsServer
then Exit
;
1036 // Ñïèñîê íàçâàíèé ìîäåëåé:
1037 m
:= g_PlayerModel_GetNames();
1042 if (gGameSettings
.GameType
= GT_SINGLE
) or (gGameSettings
.GameMode
= GM_COOP
) then
1043 Team
:= TEAM_COOP
// COOP
1045 if gGameSettings
.GameMode
= GM_DM
then
1046 Team
:= TEAM_NONE
// DM
1048 if Team
= TEAM_NONE
then // CTF / TDM
1050 // Àâòîáàëàíñ êîìàíä:
1054 for a
:= 0 to High(gPlayers
) do
1055 if gPlayers
[a
] <> nil then
1057 if gPlayers
[a
].Team
= TEAM_RED
then
1060 if gPlayers
[a
].Team
= TEAM_BLUE
then
1070 if Random(2) = 0 then
1076 // Âûáèðàåì áîòó èìÿ:
1078 if BotNames
<> nil then
1079 for a
:= 0 to High(BotNames
) do
1080 if g_Player_ValidName(BotNames
[a
]) then
1082 _name
:= BotNames
[a
];
1086 // Âûáèðàåì ñëó÷àéíóþ ìîäåëü:
1087 _model
:= m
[Random(Length(m
))];
1090 with g_Player_Get(g_Player_Create(_model
,
1091 _RGB(Min(Random(9)*32, 255),
1092 Min(Random(9)*32, 255),
1093 Min(Random(9)*32, 255)),
1094 Team
, True)) as TBot
do
1096 // Åñëè èìåíè íåò, äåëàåì åãî èç UID áîòà
1098 Name
:= Format('DFBOT%.5d', [UID
])
1103 1: FDifficult
:= DIFFICULT_EASY
;
1104 2: FDifficult
:= DIFFICULT_MEDIUM
;
1105 else FDifficult
:= DIFFICULT_HARD
;
1108 for a
:= WP_FIRST
to WP_LAST
do
1110 FDifficult
.WeaponPrior
[a
] := WEAPON_PRIOR1
[a
];
1111 FDifficult
.CloseWeaponPrior
[a
] := WEAPON_PRIOR2
[a
];
1112 //FDifficult.SafeWeaponPrior[a] := WEAPON_PRIOR3[a];
1115 FHandicap
:= Handicap
;
1117 g_Console_Add(Format(_lc
[I_PLAYER_JOIN
], [Name
]), True);
1119 if g_Game_IsNet
then MH_SEND_PlayerCreate(UID
);
1120 if g_Game_IsServer
and (gGameSettings
.MaxLives
> 0) then
1125 procedure g_Bot_AddList(Team
: Byte; lName
: ShortString; num
: Integer = -1; Handicap
: Integer = 100);
1128 _name
, _model
: String;
1131 if not g_Game_IsServer
then Exit
;
1133 // Ñïèñîê íàçâàíèé ìîäåëåé:
1134 m
:= g_PlayerModel_GetNames();
1139 if (gGameSettings
.GameType
= GT_SINGLE
) or (gGameSettings
.GameMode
= GM_COOP
) then
1140 Team
:= TEAM_COOP
// COOP
1142 if gGameSettings
.GameMode
= GM_DM
then
1143 Team
:= TEAM_NONE
// DM
1145 if Team
= TEAM_NONE
then
1146 Team
:= BotList
[num
].team
; // CTF / TDM
1148 // Âûáèðàåì íàñòðîéêè áîòà èç ñïèñêà ïî íîìåðó èëè èìåíè:
1149 lName
:= AnsiLowerCase(lName
);
1150 if (num
< 0) or (num
> Length(BotList
)-1) then
1152 if (num
= -1) and (lName
<> '') and (BotList
<> nil) then
1153 for a
:= 0 to High(BotList
) do
1154 if AnsiLowerCase(BotList
[a
].name
) = lName
then
1163 _name
:= BotList
[num
].name
;
1164 // Çàíÿòî - âûáèðàåì ñëó÷àéíîå:
1165 if not g_Player_ValidName(_name
) then
1167 _name
:= Format('DFBOT%.2d', [Random(100)]);
1168 until g_Player_ValidName(_name
);
1171 _model
:= BotList
[num
].model
;
1172 // Íåò òàêîé - âûáèðàåì ñëó÷àéíóþ:
1173 if not InSArray(_model
, m
) then
1174 _model
:= m
[Random(Length(m
))];
1177 with g_Player_Get(g_Player_Create(_model
, BotList
[num
].color
, Team
, True)) as TBot
do
1181 FDifficult
.DiagFire
:= BotList
[num
].diag_fire
;
1182 FDifficult
.InvisFire
:= BotList
[num
].invis_fire
;
1183 FDifficult
.DiagPrecision
:= BotList
[num
].diag_precision
;
1184 FDifficult
.FlyPrecision
:= BotList
[num
].fly_precision
;
1185 FDifficult
.Cover
:= BotList
[num
].cover
;
1186 FDifficult
.CloseJump
:= BotList
[num
].close_jump
;
1188 FHandicap
:= Handicap
;
1190 for a
:= WP_FIRST
to WP_LAST
do
1192 FDifficult
.WeaponPrior
[a
] := BotList
[num
].w_prior1
[a
];
1193 FDifficult
.CloseWeaponPrior
[a
] := BotList
[num
].w_prior2
[a
];
1194 //FDifficult.SafeWeaponPrior[a] := BotList[num].w_prior3[a];
1197 g_Console_Add(Format(_lc
[I_PLAYER_JOIN
], [Name
]), True);
1199 if g_Game_IsNet
then MH_SEND_PlayerCreate(UID
);
1203 procedure g_Bot_RemoveAll();
1207 if not g_Game_IsServer
then Exit
;
1208 if gPlayers
= nil then Exit
;
1210 for a
:= 0 to High(gPlayers
) do
1211 if gPlayers
[a
] <> nil then
1212 if gPlayers
[a
] is TBot
then
1214 gPlayers
[a
].Lives
:= 0;
1215 gPlayers
[a
].Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
1216 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [gPlayers
[a
].Name
]), True);
1217 g_Player_Remove(gPlayers
[a
].FUID
);
1223 procedure g_Bot_MixNames();
1228 if BotNames
<> nil then
1229 for a
:= 0 to High(BotNames
) do
1231 b
:= Random(Length(BotNames
));
1233 Botnames
[a
] := BotNames
[b
];
1238 procedure g_Player_Remove(UID
: Word);
1242 if gPlayers
= nil then Exit
;
1244 if g_Game_IsServer
and g_Game_IsNet
then
1245 MH_SEND_PlayerDelete(UID
);
1247 for i
:= 0 to High(gPlayers
) do
1248 if gPlayers
[i
] <> nil then
1249 if gPlayers
[i
].FUID
= UID
then
1251 if gPlayers
[i
] is TPlayer
then
1252 TPlayer(gPlayers
[i
]).Free()
1254 TBot(gPlayers
[i
]).Free();
1260 procedure g_Player_Init();
1271 path
:= BOTNAMES_FILENAME
;
1272 if e_FindResource(DataDirs
, path
) = false then
1275 // ×èòàåì âîçìîæíûå èìåíà áîòîâ èç ôàéëà:
1276 AssignFile(F
, path
);
1287 SetLength(BotNames
, Length(BotNames
)+1);
1288 BotNames
[High(BotNames
)] := s
;
1296 // ×èòàåì ôàéë ñ ïàðàìåòðàìè áîòîâ:
1297 config
:= TConfig
.CreateFile(path
);
1301 while config
.SectionExists(IntToStr(a
)) do
1303 SetLength(BotList
, Length(BotList
)+1);
1305 with BotList
[High(BotList
)] do
1308 name
:= config
.ReadStr(IntToStr(a
), 'name', '');
1310 model
:= config
.ReadStr(IntToStr(a
), 'model', '');
1312 if config
.ReadStr(IntToStr(a
), 'team', 'red') = 'red' then
1317 sa
:= parse(config
.ReadStr(IntToStr(a
), 'color', ''));
1318 color
.R
:= StrToIntDef(sa
[0], 0);
1319 color
.G
:= StrToIntDef(sa
[1], 0);
1320 color
.B
:= StrToIntDef(sa
[2], 0);
1321 // Âåðîÿòíîñòü ñòðåëüáû ïîä óãëîì:
1322 diag_fire
:= config
.ReadInt(IntToStr(a
), 'diag_fire', 0);
1323 // Âåðîÿòíîñòü îòâåòíîãî îãíÿ ïî íåâèäèìîìó ñîïåðíèêó:
1324 invis_fire
:= config
.ReadInt(IntToStr(a
), 'invis_fire', 0);
1325 // Òî÷íîñòü ñòðåëüáû ïîä óãëîì:
1326 diag_precision
:= config
.ReadInt(IntToStr(a
), 'diag_precision', 0);
1327 // Òî÷íîñòü ñòðåëüáû â ïîëåòå:
1328 fly_precision
:= config
.ReadInt(IntToStr(a
), 'fly_precision', 0);
1329 // Òî÷íîñòü óêëîíåíèÿ îò ñíàðÿäîâ:
1330 cover
:= config
.ReadInt(IntToStr(a
), 'cover', 0);
1331 // Âåðîÿòíîñòü ïðûæêà ïðè ïðèáëèæåíèè ñîïåðíèêà:
1332 close_jump
:= config
.ReadInt(IntToStr(a
), 'close_jump', 0);
1333 // Ïðèîðèòåòû îðóæèÿ äëÿ äàëüíåãî áîÿ:
1334 sa
:= parse(config
.ReadStr(IntToStr(a
), 'w_prior1', ''));
1335 if Length(sa
) = 10 then
1337 w_prior1
[b
] := EnsureRange(StrToInt(sa
[b
]), 0, 9);
1338 // Ïðèîðèòåòû îðóæèÿ äëÿ áëèæíåãî áîÿ:
1339 sa
:= parse(config
.ReadStr(IntToStr(a
), 'w_prior2', ''));
1340 if Length(sa
) = 10 then
1342 w_prior2
[b
] := EnsureRange(StrToInt(sa
[b
]), 0, 9);
1344 {sa := parse(config.ReadStr(IntToStr(a), 'w_prior3', ''));
1345 if Length(sa) = 10 then
1347 w_prior3[b] := EnsureRange(StrToInt(sa[b]), 0, 9);}
1354 SetLength(SavedStates
, 0);
1357 procedure g_Player_Free();
1361 if gPlayers
<> nil then
1363 for i
:= 0 to High(gPlayers
) do
1364 if gPlayers
[i
] <> nil then
1366 if gPlayers
[i
] is TPlayer
then
1367 TPlayer(gPlayers
[i
]).Free()
1369 TBot(gPlayers
[i
]).Free();
1378 SetLength(SavedStates
, 0);
1381 procedure g_Player_PreUpdate();
1385 if gPlayers
= nil then Exit
;
1386 for i
:= 0 to High(gPlayers
) do
1387 if gPlayers
[i
] <> nil then
1388 gPlayers
[i
].PreUpdate();
1391 procedure g_Player_UpdateAll();
1395 if gPlayers
= nil then Exit
;
1397 //e_WriteLog('***g_Player_UpdateAll: ENTER', MSG_WARNING);
1398 for i
:= 0 to High(gPlayers
) do
1400 if gPlayers
[i
] <> nil then
1402 if gPlayers
[i
] is TPlayer
then
1404 gPlayers
[i
].Update();
1405 gPlayers
[i
].RealizeCurrentWeapon(); // WARNING! DO NOT MOVE THIS INTO `Update()`!
1409 // bot updates weapons in `UpdateCombat()`
1410 TBot(gPlayers
[i
]).Update();
1414 //e_WriteLog('***g_Player_UpdateAll: EXIT', MSG_WARNING);
1417 procedure g_Player_DrawAll();
1421 if gPlayers
= nil then Exit
;
1423 for i
:= 0 to High(gPlayers
) do
1424 if gPlayers
[i
] <> nil then
1425 if gPlayers
[i
] is TPlayer
then gPlayers
[i
].Draw()
1426 else TBot(gPlayers
[i
]).Draw();
1429 procedure g_Player_DrawDebug(p
: TPlayer
);
1433 if p
= nil then Exit
;
1434 if (@p
.FObj
) = nil then Exit
;
1436 e_TextureFontGetSize(gStdFont
, fW
, fH
);
1438 e_TextureFontPrint(0, 0 , 'Pos X: ' + IntToStr(p
.FObj
.X
), gStdFont
);
1439 e_TextureFontPrint(0, fH
, 'Pos Y: ' + IntToStr(p
.FObj
.Y
), gStdFont
);
1440 e_TextureFontPrint(0, fH
* 2, 'Vel X: ' + IntToStr(p
.FObj
.Vel
.X
), gStdFont
);
1441 e_TextureFontPrint(0, fH
* 3, 'Vel Y: ' + IntToStr(p
.FObj
.Vel
.Y
), gStdFont
);
1442 e_TextureFontPrint(0, fH
* 4, 'Acc X: ' + IntToStr(p
.FObj
.Accel
.X
), gStdFont
);
1443 e_TextureFontPrint(0, fH
* 5, 'Acc Y: ' + IntToStr(p
.FObj
.Accel
.Y
), gStdFont
);
1444 e_TextureFontPrint(0, fH
* 6, 'Old X: ' + IntToStr(p
.FObj
.oldX
), gStdFont
);
1445 e_TextureFontPrint(0, fH
* 7, 'Old Y: ' + IntToStr(p
.FObj
.oldY
), gStdFont
);
1448 procedure g_Player_DrawHealth();
1453 if gPlayers
= nil then Exit
;
1454 e_TextureFontGetSize(gStdFont
, fW
, fH
);
1456 for i
:= 0 to High(gPlayers
) do
1457 if gPlayers
[i
] <> nil then
1459 e_TextureFontPrint(gPlayers
[i
].FObj
.X
+ gPlayers
[i
].FObj
.Rect
.X
,
1460 gPlayers
[i
].FObj
.Y
+ gPlayers
[i
].FObj
.Rect
.Y
+ gPlayers
[i
].FObj
.Rect
.Height
- fH
* 2,
1461 IntToStr(gPlayers
[i
].FHealth
), gStdFont
);
1462 e_TextureFontPrint(gPlayers
[i
].FObj
.X
+ gPlayers
[i
].FObj
.Rect
.X
,
1463 gPlayers
[i
].FObj
.Y
+ gPlayers
[i
].FObj
.Rect
.Y
+ gPlayers
[i
].FObj
.Rect
.Height
- fH
,
1464 IntToStr(gPlayers
[i
].FArmor
), gStdFont
);
1468 function g_Player_Get(UID
: Word): TPlayer
;
1474 if gPlayers
= nil then
1477 for a
:= 0 to High(gPlayers
) do
1478 if gPlayers
[a
] <> nil then
1479 if gPlayers
[a
].FUID
= UID
then
1481 Result
:= gPlayers
[a
];
1486 function g_Player_GetCount(): Byte;
1492 if gPlayers
= nil then
1495 for a
:= 0 to High(gPlayers
) do
1496 if gPlayers
[a
] <> nil then
1497 Result
:= Result
+ 1;
1500 function g_Player_GetStats(): TPlayerStatArray
;
1506 if gPlayers
= nil then Exit
;
1508 for a
:= 0 to High(gPlayers
) do
1509 if gPlayers
[a
] <> nil then
1511 SetLength(Result
, Length(Result
)+1);
1512 with Result
[High(Result
)] do
1515 Ping
:= gPlayers
[a
].FPing
;
1516 Loss
:= gPlayers
[a
].FLoss
;
1517 Name
:= gPlayers
[a
].FName
;
1518 Team
:= gPlayers
[a
].FTeam
;
1519 Frags
:= gPlayers
[a
].FFrags
;
1520 Deaths
:= gPlayers
[a
].FDeath
;
1521 Kills
:= gPlayers
[a
].FKills
;
1522 Color
:= gPlayers
[a
].FModel
.Color
;
1523 Lives
:= gPlayers
[a
].FLives
;
1524 Spectator
:= gPlayers
[a
].FSpectator
;
1525 UID
:= gPlayers
[a
].FUID
;
1530 procedure g_Player_ResetReady();
1534 if not g_Game_IsServer
then Exit
;
1535 if gPlayers
= nil then Exit
;
1537 for a
:= 0 to High(gPlayers
) do
1538 if gPlayers
[a
] <> nil then
1540 gPlayers
[a
].FReady
:= False;
1541 if g_Game_IsNet
then
1542 MH_SEND_GameEvent(NET_EV_INTER_READY
, gPlayers
[a
].UID
, 'N');
1546 procedure g_Player_RememberAll
;
1550 for i
:= Low(gPlayers
) to High(gPlayers
) do
1551 if (gPlayers
[i
] <> nil) and gPlayers
[i
].alive
then
1552 gPlayers
[i
].RememberState
;
1555 procedure g_Player_ResetAll(Force
, Silent
: Boolean);
1559 gTeamStat
[TEAM_RED
].Goals
:= 0;
1560 gTeamStat
[TEAM_BLUE
].Goals
:= 0;
1562 if gPlayers
<> nil then
1563 for i
:= 0 to High(gPlayers
) do
1564 if gPlayers
[i
] <> nil then
1566 gPlayers
[i
].Reset(Force
);
1568 if gPlayers
[i
] is TPlayer
then
1570 if (not gPlayers
[i
].FSpectator
) or gPlayers
[i
].FWantsInGame
then
1571 gPlayers
[i
].Respawn(Silent
)
1573 gPlayers
[i
].Spectate();
1576 TBot(gPlayers
[i
]).Respawn(Silent
);
1580 function g_Player_CreateCorpse(Player
: TPlayer
): Integer;
1588 if Player
.alive
then
1591 // Ðàçðûâàåì ñâÿçü ñ ïðåæíèì òðóïîì:
1592 i
:= Player
.FCorpse
;
1593 if (i
>= 0) and (i
< Length(gCorpses
)) then
1595 if (gCorpses
[i
] <> nil) and (gCorpses
[i
].FPlayerUID
= Player
.FUID
) then
1596 gCorpses
[i
].FPlayerUID
:= 0;
1599 if Player
.FObj
.Y
>= gMapInfo
.Height
+128 then
1604 if (FHealth
>= -50) or (gGibsCount
= 0) then
1606 if (gCorpses
= nil) or (Length(gCorpses
) = 0) then
1610 for find_id
:= 0 to High(gCorpses
) do
1611 if gCorpses
[find_id
] = nil then
1618 find_id
:= Random(Length(gCorpses
));
1620 gCorpses
[find_id
] := TCorpse
.Create(FObj
.X
, FObj
.Y
, FModel
.Name
, FHealth
< -20);
1621 gCorpses
[find_id
].FColor
:= FModel
.Color
;
1622 gCorpses
[find_id
].FObj
.Vel
:= FObj
.Vel
;
1623 gCorpses
[find_id
].FObj
.Accel
:= FObj
.Accel
;
1624 gCorpses
[find_id
].FPlayerUID
:= FUID
;
1629 g_Player_CreateGibs(FObj
.X
+ PLAYER_RECT_CX
,
1630 FObj
.Y
+ PLAYER_RECT_CY
,
1631 FModel
.Name
, FModel
.Color
);
1635 procedure g_Player_CreateShell(fX
, fY
, dX
, dY
: Integer; T
: Byte);
1639 if (gShells
= nil) or (Length(gShells
) = 0) then
1642 with gShells
[CurrentShell
] do
1648 if T
= SHELL_BULLET
then
1650 if g_Texture_Get('TEXTURE_SHELL_BULLET', SID
) then
1654 Obj
.Rect
.Width
:= 4;
1655 Obj
.Rect
.Height
:= 2;
1659 if g_Texture_Get('TEXTURE_SHELL_SHELL', SID
) then
1663 Obj
.Rect
.Width
:= 7;
1664 Obj
.Rect
.Height
:= 3;
1670 g_Obj_Push(@Obj
, dX
+ Random(4)-Random(4), dY
-Random(4));
1671 positionChanged(); // this updates spatial accelerators
1672 RAngle
:= Random(360);
1673 Timeout
:= gTime
+ SHELL_TIMEOUT
;
1675 if CurrentShell
>= High(gShells
) then
1682 procedure g_Player_CreateGibs(fX
, fY
: Integer; ModelName
: string; fColor
: TRGB
);
1685 GibsArray
: TGibsArray
;
1688 if (gGibs
= nil) or (Length(gGibs
) = 0) then
1690 if not g_PlayerModel_GetGibs(ModelName
, GibsArray
) then
1692 Blood
:= g_PlayerModel_GetBlood(ModelName
);
1694 for a
:= 0 to High(GibsArray
) do
1695 with gGibs
[CurrentGib
] do
1698 ID
:= GibsArray
[a
].ID
;
1699 MaskID
:= GibsArray
[a
].MaskID
;
1702 Obj
.Rect
:= GibsArray
[a
].Rect
;
1703 Obj
.X
:= fX
-GibsArray
[a
].Rect
.X
-(GibsArray
[a
].Rect
.Width
div 2);
1704 Obj
.Y
:= fY
-GibsArray
[a
].Rect
.Y
-(GibsArray
[a
].Rect
.Height
div 2);
1705 g_Obj_PushA(@Obj
, 25 + Random(10), Random(361));
1706 positionChanged(); // this updates spatial accelerators
1707 RAngle
:= Random(360);
1709 if gBloodCount
> 0 then
1710 g_GFX_Blood(fX
, fY
, 16*gBloodCount
+Random(5*gBloodCount
), -16+Random(33), -16+Random(33),
1711 Random(48), Random(48), Blood
.R
, Blood
.G
, Blood
.B
, Blood
.Kind
);
1713 if CurrentGib
>= High(gGibs
) then
1720 procedure g_Player_UpdatePhysicalObjects();
1726 procedure ShellSound_Bounce(X
, Y
: Integer; T
: Byte);
1731 if T
= SHELL_BULLET
then
1732 g_Sound_PlayExAt('SOUND_PLAYER_CASING' + IntToStr(k
), X
, Y
)
1734 g_Sound_PlayExAt('SOUND_PLAYER_SHELL' + IntToStr(k
), X
, Y
);
1739 if gGibs
<> nil then
1740 for i
:= 0 to High(gGibs
) do
1741 if gGibs
[i
].alive
then
1748 mr
:= g_Obj_Move(@Obj
, True, False, True);
1749 positionChanged(); // this updates spatial accelerators
1751 if WordBool(mr
and MOVE_FALLOUT
) then
1757 // Îòëåòàåò îò óäàðà î ñòåíó/ïîòîëîê/ïîë:
1758 if WordBool(mr
and MOVE_HITWALL
) then
1759 Obj
.Vel
.X
:= -(vel
.X
div 2);
1760 if WordBool(mr
and (MOVE_HITCEIL
or MOVE_HITLAND
)) then
1761 Obj
.Vel
.Y
:= -(vel
.Y
div 2);
1763 if (Obj
.Vel
.X
>= 0) then
1765 RAngle
:= RAngle
+ Abs(Obj
.Vel
.X
)*6 + Abs(Obj
.Vel
.Y
);
1766 if RAngle
>= 360 then
1767 RAngle
:= RAngle
mod 360;
1768 end else begin // Counter-clockwise
1769 RAngle
:= RAngle
- Abs(Obj
.Vel
.X
)*6 - Abs(Obj
.Vel
.Y
);
1771 RAngle
:= (360 - (Abs(RAngle
) mod 360)) mod 360;
1774 // Ñîïðîòèâëåíèå âîçäóõà äëÿ êóñêà òðóïà:
1775 if gTime
mod (GAME_TICK
*3) = 0 then
1776 Obj
.Vel
.X
:= z_dec(Obj
.Vel
.X
, 1);
1780 if gCorpses
<> nil then
1781 for i
:= 0 to High(gCorpses
) do
1782 if gCorpses
[i
] <> nil then
1783 if gCorpses
[i
].State
= CORPSE_STATE_REMOVEME
then
1789 gCorpses
[i
].Update();
1792 if gShells
<> nil then
1793 for i
:= 0 to High(gShells
) do
1794 if gShells
[i
].alive
then
1801 mr
:= g_Obj_Move(@Obj
, True, False, True);
1802 positionChanged(); // this updates spatial accelerators
1804 if WordBool(mr
and MOVE_FALLOUT
) or (gShells
[i
].Timeout
< gTime
) then
1810 // Îòëåòàåò îò óäàðà î ñòåíó/ïîòîëîê/ïîë:
1811 if WordBool(mr
and MOVE_HITWALL
) then
1813 Obj
.Vel
.X
:= -(vel
.X
div 2);
1814 if not WordBool(mr
and MOVE_INWATER
) then
1815 ShellSound_Bounce(Obj
.X
, Obj
.Y
, SType
);
1817 if WordBool(mr
and (MOVE_HITCEIL
or MOVE_HITLAND
)) then
1819 Obj
.Vel
.Y
:= -(vel
.Y
div 2);
1820 if Obj
.Vel
.X
<> 0 then Obj
.Vel
.X
:= Obj
.Vel
.X
div 2;
1821 if (Obj
.Vel
.X
= 0) and (Obj
.Vel
.Y
= 0) then
1823 if RAngle
mod 90 <> 0 then
1824 RAngle
:= (RAngle
div 90) * 90;
1826 else if not WordBool(mr
and MOVE_INWATER
) then
1827 ShellSound_Bounce(Obj
.X
, Obj
.Y
, SType
);
1830 if (Obj
.Vel
.X
>= 0) then
1832 RAngle
:= RAngle
+ Abs(Obj
.Vel
.X
)*8 + Abs(Obj
.Vel
.Y
);
1833 if RAngle
>= 360 then
1834 RAngle
:= RAngle
mod 360;
1835 end else begin // Counter-clockwise
1836 RAngle
:= RAngle
- Abs(Obj
.Vel
.X
)*8 - Abs(Obj
.Vel
.Y
);
1838 RAngle
:= (360 - (Abs(RAngle
) mod 360)) mod 360;
1844 procedure TGib
.getMapBox (out x
, y
, w
, h
: Integer); inline;
1846 x
:= Obj
.X
+Obj
.Rect
.X
;
1847 y
:= Obj
.Y
+Obj
.Rect
.Y
;
1848 w
:= Obj
.Rect
.Width
;
1849 h
:= Obj
.Rect
.Height
;
1852 procedure TGib
.moveBy (dx
, dy
: Integer); inline;
1854 if (dx
<> 0) or (dy
<> 0) then
1863 procedure TShell
.getMapBox (out x
, y
, w
, h
: Integer); inline;
1867 w
:= Obj
.Rect
.Width
;
1868 h
:= Obj
.Rect
.Height
;
1871 procedure TShell
.moveBy (dx
, dy
: Integer); inline;
1873 if (dx
<> 0) or (dy
<> 0) then
1882 procedure TGib
.positionChanged (); inline; begin end;
1883 procedure TShell
.positionChanged (); inline; begin end;
1886 procedure g_Player_DrawCorpses();
1891 if gGibs
<> nil then
1892 for i
:= 0 to High(gGibs
) do
1893 if gGibs
[i
].alive
then
1896 if not g_Obj_Collide(sX
, sY
, sWidth
, sHeight
, @Obj
) then
1899 Obj
.lerp(gLerpFactor
, fX
, fY
);
1901 a
.X
:= Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2);
1902 a
.y
:= Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2);
1904 e_DrawAdv(ID
, fX
, fY
, 0, True, False, RAngle
, @a
, TMirrorType
.None
);
1907 e_DrawAdv(MaskID
, fX
, fY
, 0, True, False, RAngle
, @a
, TMirrorType
.None
);
1913 if gCorpses
<> nil then
1914 for i
:= 0 to High(gCorpses
) do
1915 if gCorpses
[i
] <> nil then
1919 procedure g_Player_DrawShells();
1924 if gShells
<> nil then
1925 for i
:= 0 to High(gShells
) do
1926 if gShells
[i
].alive
then
1929 if not g_Obj_Collide(sX
, sY
, sWidth
, sHeight
, @Obj
) then
1932 Obj
.lerp(gLerpFactor
, fX
, fY
);
1937 e_DrawAdv(SpriteID
, fX
, fY
, 0, True, False, RAngle
, @a
, TMirrorType
.None
);
1941 procedure g_Player_RemoveAllCorpses();
1947 SetLength(gGibs
, MaxGibs
);
1948 SetLength(gShells
, MaxGibs
);
1952 if gCorpses
<> nil then
1953 for i
:= 0 to High(gCorpses
) do
1957 SetLength(gCorpses
, MaxCorpses
);
1960 procedure g_Player_Corpses_SaveState (st
: TStream
);
1964 // Ñ÷èòàåì êîëè÷åñòâî ñóùåñòâóþùèõ òðóïîâ
1966 for i
:= 0 to High(gCorpses
) do if (gCorpses
[i
] <> nil) then Inc(count
);
1968 // Êîëè÷åñòâî òðóïîâ
1969 utils
.writeInt(st
, LongInt(count
));
1971 if (count
= 0) then exit
;
1974 for i
:= 0 to High(gCorpses
) do
1976 if gCorpses
[i
] <> nil then
1979 utils
.writeStr(st
, gCorpses
[i
].FModelName
);
1981 utils
.writeBool(st
, gCorpses
[i
].Mess
);
1982 // Ñîõðàíÿåì äàííûå òðóïà:
1983 gCorpses
[i
].SaveState(st
);
1989 procedure g_Player_Corpses_LoadState (st
: TStream
);
1997 g_Player_RemoveAllCorpses();
1999 // Êîëè÷åñòâî òðóïîâ:
2000 count
:= utils
.readLongInt(st
);
2001 if (count
< 0) or (count
> Length(gCorpses
)) then raise XStreamError
.Create('invalid number of corpses');
2003 if (count
= 0) then exit
;
2006 for i
:= 0 to count
-1 do
2009 str
:= utils
.readStr(st
);
2011 b
:= utils
.readBool(st
);
2013 gCorpses
[i
] := TCorpse
.Create(0, 0, str
, b
);
2014 // Çàãðóæàåì äàííûå òðóïà
2015 gCorpses
[i
].LoadState(st
);
2022 function TPlayer
.isValidViewPort (): Boolean; inline; begin result
:= (viewPortW
> 0) and (viewPortH
> 0); end;
2024 procedure TPlayer
.BFGHit();
2026 g_Weapon_BFGHit(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
2027 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2));
2028 if g_Game_IsServer
and g_Game_IsNet
then
2029 MH_SEND_Effect(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
2030 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2),
2034 procedure TPlayer
.ChangeModel(ModelName
: string);
2036 locModel
: TPlayerModel
;
2038 locModel
:= g_PlayerModel_Get(ModelName
);
2039 if locModel
= nil then Exit
;
2045 procedure TPlayer
.SetModel(ModelName
: string);
2049 m
:= g_PlayerModel_Get(ModelName
);
2052 g_SimpleError(Format(_lc
[I_GAME_ERROR_MODEL_FALLBACK
], [ModelName
]));
2053 m
:= g_PlayerModel_Get('doomer');
2056 g_FatalError(Format(_lc
[I_GAME_ERROR_MODEL
], ['doomer']));
2061 if FModel
<> nil then
2066 if not (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then
2067 FModel
.Color
:= FColor
2069 FModel
.Color
:= TEAMCOLOR
[FTeam
];
2070 FModel
.SetWeapon(FCurrWeap
);
2071 FModel
.SetFlag(FFlag
);
2072 SetDirection(FDirection
);
2075 procedure TPlayer
.SetColor(Color
: TRGB
);
2078 if not (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then
2079 if FModel
<> nil then FModel
.Color
:= Color
;
2082 function TPlayer
.GetColor(): TRGB
;
2084 result
:= FModel
.Color
;
2087 procedure TPlayer
.SwitchTeam
;
2089 if g_Game_IsClient
then
2091 if not (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then Exit
;
2093 if gGameOn
and FAlive
then
2094 Kill(K_SIMPLEKILL
, FUID
, HIT_SELF
);
2096 if FTeam
= TEAM_RED
then
2098 ChangeTeam(TEAM_BLUE
);
2099 g_Console_Add(Format(_lc
[I_PLAYER_CHTEAM_BLUE
], [FName
]), True);
2100 if g_Game_IsNet
then
2101 MH_SEND_GameEvent(NET_EV_CHANGE_TEAM
, TEAM_BLUE
, FName
);
2105 ChangeTeam(TEAM_RED
);
2106 g_Console_Add(Format(_lc
[I_PLAYER_CHTEAM_RED
], [FName
]), True);
2107 if g_Game_IsNet
then
2108 MH_SEND_GameEvent(NET_EV_CHANGE_TEAM
, TEAM_RED
, FName
);
2110 FPreferredTeam
:= FTeam
;
2113 procedure TPlayer
.ChangeTeam(Team
: Byte);
2120 TEAM_RED
, TEAM_BLUE
:
2121 FModel
.Color
:= TEAMCOLOR
[Team
];
2123 FModel
.Color
:= FColor
;
2125 if (FTeam
<> OldTeam
) and g_Game_IsNet
and g_Game_IsServer
then
2126 MH_SEND_PlayerStats(FUID
);
2130 procedure TPlayer.CollideItem();
2135 if gItems = nil then Exit;
2136 if not FAlive then Exit;
2138 for i := 0 to High(gItems) do
2141 if (ItemType <> ITEM_NONE) and alive then
2142 if g_Obj_Collide(FObj.X+PLAYER_RECT.X, FObj.Y+PLAYER_RECT.Y, PLAYER_RECT.Width,
2143 PLAYER_RECT.Height, @Obj) then
2145 if not PickItem(ItemType, gItems[i].Respawnable, r) then Continue;
2147 if ItemType in [ITEM_SPHERE_BLUE, ITEM_SPHERE_WHITE, ITEM_INVUL] then
2148 g_Sound_PlayExAt('SOUND_ITEM_GETRULEZ', FObj.X, FObj.Y)
2149 else if ItemType in [ITEM_MEDKIT_SMALL, ITEM_MEDKIT_LARGE, ITEM_MEDKIT_BLACK] then
2150 g_Sound_PlayExAt('SOUND_ITEM_GETMED', FObj.X, FObj.Y)
2151 else g_Sound_PlayExAt('SOUND_ITEM_GETITEM', FObj.X, FObj.Y);
2153 // Íàäî óáðàòü ñ êàðòû, åñëè ýòî íå êëþ÷, êîòîðûì íóæíî ïîäåëèòñÿ ñ äðóãèì èãðîêîì:
2154 if r and not ((ItemType in [ITEM_KEY_RED, ITEM_KEY_GREEN, ITEM_KEY_BLUE]) and
2155 (gGameSettings.GameType = GT_SINGLE) and
2156 (g_Player_GetCount() > 1)) then
2157 if not Respawnable then g_Items_Remove(i) else g_Items_Pick(i);
2163 function TPlayer
.CollideLevel(XInc
, YInc
: Integer): Boolean;
2165 Result
:= g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
,
2166 PLAYER_RECT
.Width
, PLAYER_RECT
.Height
, PANEL_WALL
,
2170 constructor TPlayer
.Create();
2176 mEDamageType
:= HIT_SOME
;
2182 FSawSound
:= TPlayableSound
.Create();
2183 FSawSoundIdle
:= TPlayableSound
.Create();
2184 FSawSoundHit
:= TPlayableSound
.Create();
2185 FSawSoundSelect
:= TPlayableSound
.Create();
2186 FFlameSoundOn
:= TPlayableSound
.Create();
2187 FFlameSoundOff
:= TPlayableSound
.Create();
2188 FFlameSoundWork
:= TPlayableSound
.Create();
2189 FJetSoundFly
:= TPlayableSound
.Create();
2190 FJetSoundOn
:= TPlayableSound
.Create();
2191 FJetSoundOff
:= TPlayableSound
.Create();
2193 FSawSound
.SetByName('SOUND_WEAPON_FIRESAW');
2194 FSawSoundIdle
.SetByName('SOUND_WEAPON_IDLESAW');
2195 FSawSoundHit
.SetByName('SOUND_WEAPON_HITSAW');
2196 FSawSoundSelect
.SetByName('SOUND_WEAPON_SELECTSAW');
2197 FFlameSoundOn
.SetByName('SOUND_WEAPON_FLAMEON');
2198 FFlameSoundOff
.SetByName('SOUND_WEAPON_FLAMEOFF');
2199 FFlameSoundWork
.SetByName('SOUND_WEAPON_FLAMEWORK');
2200 FJetSoundFly
.SetByName('SOUND_PLAYER_JETFLY');
2201 FJetSoundOn
.SetByName('SOUND_PLAYER_JETON');
2202 FJetSoundOff
.SetByName('SOUND_PLAYER_JETOFF');
2204 FSpectatePlayer
:= -1;
2208 FSavedStateNum
:= -1;
2216 FActualModelName
:= 'doomer';
2219 FObj
.Rect
:= PLAYER_RECT
;
2221 FBFGFireCounter
:= -1;
2222 FJustTeleported
:= False;
2225 FWaitForFirstSpawn
:= false;
2230 procedure TPlayer
.positionChanged (); inline;
2234 procedure TPlayer
.doDamage (v
: Integer);
2236 if (v
<= 0) then exit
;
2237 if (v
> 32767) then v
:= 32767;
2238 Damage(v
, 0, 0, 0, mEDamageType
);
2241 procedure TPlayer
.Damage(value
: Word; SpawnerUID
: Word; vx
, vy
: Integer; t
: Byte);
2245 if (not g_Game_IsClient
) and (not FAlive
) then
2250 // Íåóÿçâèìîñòü íå ñïàñàåò îò ëîâóøåê:
2251 if ((t
= HIT_TRAP
) or (t
= HIT_SELF
)) and (not FGodMode
) then
2253 if not g_Game_IsClient
then
2256 if t
= HIT_TRAP
then
2258 // Ëîâóøêà óáèâàåò ñðàçó:
2260 Kill(K_EXTRAHARDKILL
, SpawnerUID
, t
);
2262 if t
= HIT_SELF
then
2266 Kill(K_SIMPLEKILL
, SpawnerUID
, t
);
2269 // Îáíóëèòü äåéñòâèÿ ïðèìî÷åê, ÷òîáû ôîí ïðîïàë
2270 FMegaRulez
[MR_SUIT
] := 0;
2271 FMegaRulez
[MR_INVUL
] := 0;
2272 FMegaRulez
[MR_INVIS
] := 0;
2277 // Íî îò îñòàëüíîãî ñïàñàåò:
2278 if FMegaRulez
[MR_INVUL
] >= gTime
then
2285 // Åñëè åñòü óðîí ñâîèì, èëè ðàíèë ñàì ñåáÿ, èëè òåáÿ ðàíèë ïðîòèâíèê:
2286 if LongBool(gGameSettings
.Options
and GAME_OPTION_TEAMDAMAGE
) or
2287 (SpawnerUID
= FUID
) or
2288 (not SameTeam(FUID
, SpawnerUID
)) then
2290 FLastSpawnerUID
:= SpawnerUID
;
2292 // Êðîâü (ïóçûðüêè, åñëè â âîäå):
2293 if gBloodCount
> 0 then
2295 c
:= Min(value
, 200)*gBloodCount
+ Random(Min(value
, 200) div 2);
2296 if value
div 4 <= c
then
2297 c
:= c
- (value
div 4)
2301 if (t
= HIT_SOME
) and (vx
= 0) and (vy
= 0) then
2305 HIT_TRAP
, HIT_ACID
, HIT_FLAME
, HIT_SELF
: MakeBloodSimple(c
);
2306 HIT_BFG
, HIT_ROCKET
, HIT_SOME
: MakeBloodVector(c
, vx
, vy
);
2309 if t
= HIT_WATER
then
2310 g_GFX_Bubbles(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2),
2311 FObj
.Y
+PLAYER_RECT
.Y
-4, value
div 2, 8, 4);
2316 Inc(FDamageBuffer
, value
);
2320 FPain
:= FPain
+ value
;
2323 if g_Game_IsServer
and g_Game_IsNet
then
2325 MH_SEND_PlayerDamage(FUID
, t
, SpawnerUID
, value
, vx
, vy
);
2326 MH_SEND_PlayerStats(FUID
);
2327 MH_SEND_PlayerPos(False, FUID
);
2331 function TPlayer
.Heal(value
: Word; Soft
: Boolean): Boolean;
2334 if g_Game_IsClient
then
2339 if Soft
and (FHealth
< PLAYER_HP_SOFT
) then
2341 IncMax(FHealth
, value
, PLAYER_HP_SOFT
);
2344 if (not Soft
) and (FHealth
< PLAYER_HP_LIMIT
) then
2346 IncMax(FHealth
, value
, PLAYER_HP_LIMIT
);
2350 if Result
and g_Game_IsServer
and g_Game_IsNet
then
2351 MH_SEND_PlayerStats(FUID
);
2354 destructor TPlayer
.Destroy();
2356 if (gPlayer1
<> nil) and (gPlayer1
.FUID
= FUID
) then
2358 if (gPlayer2
<> nil) and (gPlayer2
.FUID
= FUID
) then
2362 FSawSoundIdle
.Free();
2363 FSawSoundHit
.Free();
2364 FSawSoundSelect
.Free();
2365 FFlameSoundOn
.Free();
2366 FFlameSoundOff
.Free();
2367 FFlameSoundWork
.Free();
2368 FJetSoundFly
.Free();
2370 FJetSoundOff
.Free();
2372 if FPunchAnim
<> nil then
2378 procedure TPlayer
.DrawIndicator(Color
: TRGB
);
2380 indX
, indY
, fX
, fY
, fSlope
: Integer;
2390 FObj
.lerp(gLerpFactor
, fX
, fY
);
2391 fSlope
:= nlerp(FSlopeOld
, FObj
.slopeUpLeft
, gLerpFactor
);
2393 case gPlayerIndicatorStyle
of
2396 if g_Texture_Get('TEXTURE_PLAYER_INDICATOR', ID
) then
2398 e_GetTextureSize(ID
, @indW
, @indH
);
2402 if (FObj
.X
+ FObj
.Rect
.X
) < 0 then
2405 indX
:= fX
+ FObj
.Rect
.X
+ FObj
.Rect
.Width
;
2406 indY
:= fY
+ FObj
.Rect
.Y
+ (FObj
.Rect
.Height
- indW
) div 2;
2409 else if (FObj
.X
+ FObj
.Rect
.X
+ FObj
.Rect
.Width
) > Max(gMapInfo
.Width
, gPlayerScreenSize
.X
) then
2412 indX
:= fX
+ FObj
.Rect
.X
- indH
;
2413 indY
:= fY
+ FObj
.Rect
.Y
+ (FObj
.Rect
.Height
- indW
) div 2;
2416 else if (FObj
.Y
- indH
) < 0 then
2419 indX
:= fX
+ FObj
.Rect
.X
+ (FObj
.Rect
.Width
- indW
) div 2;
2420 indY
:= fY
+ FObj
.Rect
.Y
+ FObj
.Rect
.Height
;
2426 indX
:= fX
+ FObj
.Rect
.X
+ (FObj
.Rect
.Width
- indW
) div 2;
2430 indY
:= indY
+ fSlope
;
2431 indX
:= EnsureRange(indX
, 0, Max(gMapInfo
.Width
, gPlayerScreenSize
.X
) - indW
);
2432 indY
:= EnsureRange(indY
, 0, Max(gMapInfo
.Height
, gPlayerScreenSize
.Y
) - indH
);
2436 e_DrawAdv(ID
, indX
, indY
, 0, True, False, indA
, @a
);
2443 e_TextureFontGetSize(gStdFont
, nW
, nH
);
2444 indX
:= fX
+ FObj
.Rect
.X
+ (FObj
.Rect
.Width
- Length(FName
) * nW
) div 2;
2445 indY
:= fY
- nH
+ fSlope
;
2446 e_TextureFontPrintEx(indX
, indY
, FName
, gStdFont
, Color
.R
, Color
.G
, Color
.B
, 1.0, True);
2452 procedure TPlayer
.DrawBubble();
2454 bubX
, bubY
, fX
, fY
: Integer;
2457 Rw
, Gw
, Bw
: SmallInt;
2461 CObj
:= getCameraObj();
2462 CObj
.lerp(gLerpFactor
, fX
, fY
);
2463 // NB: _F_Obj.Rect is used to keep the bubble higher; this is not a mistake
2464 bubX
:= fX
+FObj
.Rect
.X
+ IfThen(FDirection
= TDirection
.D_LEFT
, -4, 18);
2465 bubY
:= fY
+FObj
.Rect
.Y
- 18;
2473 1: // simple textual non-bubble
2475 bubX
:= fX
+FObj
.Rect
.X
- 11;
2476 bubY
:= fY
+FObj
.Rect
.Y
- 17;
2477 e_TextureFontPrint(bubX
, bubY
, '[...]', gStdFont
);
2480 2: // advanced pixel-perfect bubble
2482 if FTeam
= TEAM_RED
then
2485 if FTeam
= TEAM_BLUE
then
2488 3: // colored bubble
2490 Rb
:= FModel
.Color
.R
;
2491 Gb
:= FModel
.Color
.G
;
2492 Bb
:= FModel
.Color
.B
;
2493 Rw
:= Min(Rb
* 2 + 64, 255);
2494 Gw
:= Min(Gb
* 2 + 64, 255);
2495 Bw
:= Min(Bb
* 2 + 64, 255);
2496 if (Abs(Rw
- Rb
) < 32)
2497 or (Abs(Gw
- Gb
) < 32)
2498 or (Abs(Bw
- Bb
) < 32) then
2500 Rb
:= Max(Rw
div 2 - 16, 0);
2501 Gb
:= Max(Gw
div 2 - 16, 0);
2502 Bb
:= Max(Bw
div 2 - 16, 0);
2505 4: // custom textured bubble
2507 if g_Texture_Get('TEXTURE_PLAYER_TALKBUBBLE', ID
) then
2508 if FDirection
= TDirection
.D_RIGHT
then
2509 e_Draw(ID
, bubX
- 6, bubY
- 7, 0, True, False)
2511 e_Draw(ID
, bubX
- 6, bubY
- 7, 0, True, False, TMirrorType
.Horizontal
);
2517 e_DrawQuad(bubX
+ 1, bubY
, bubX
+ 18, bubY
+ 13, Rb
, Gb
, Bb
);
2518 e_DrawQuad(bubX
, bubY
+ 1, bubX
+ 19, bubY
+ 12, Rb
, Gb
, Bb
);
2520 e_DrawFillQuad(bubX
+ 1, bubY
+ 1, bubX
+ 18, bubY
+ 12, Rw
, Gw
, Bw
, 0);
2523 Dot
:= IfThen(FDirection
= TDirection
.D_LEFT
, 14, 5);
2524 e_DrawLine(1, bubX
+ Dot
, bubY
+ 14, bubX
+ Dot
, bubY
+ 16, Rb
, Gb
, Bb
);
2525 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
);
2526 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
);
2527 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
);
2528 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
);
2532 e_DrawFillQuad(bubX
+ Dot
, bubY
+ 8, bubX
+ Dot
+ 1, bubY
+ 9, Rb
, Gb
, Bb
, 0);
2533 e_DrawFillQuad(bubX
+ Dot
+ 3, bubY
+ 8, bubX
+ Dot
+ 4, bubY
+ 9, Rb
, Gb
, Bb
, 0);
2534 e_DrawFillQuad(bubX
+ Dot
+ 6, bubY
+ 8, bubX
+ Dot
+ 7, bubY
+ 9, Rb
, Gb
, Bb
, 0);
2537 procedure TPlayer
.Draw();
2542 Mirror
: TMirrorType
;
2543 fX
, fY
, fSlope
: Integer;
2545 FObj
.lerp(gLerpFactor
, fX
, fY
);
2546 fSlope
:= nlerp(FSlopeOld
, FObj
.slopeUpLeft
, gLerpFactor
);
2550 if Direction
= TDirection
.D_RIGHT
then
2551 Mirror
:= TMirrorType
.None
2553 Mirror
:= TMirrorType
.Horizontal
;
2555 if FPunchAnim
<> nil then
2557 FPunchAnim
.Draw(fX
+IfThen(Direction
= TDirection
.D_LEFT
, 15-FObj
.Rect
.X
, FObj
.Rect
.X
-15),
2558 fY
+fSlope
+FObj
.Rect
.Y
-11, Mirror
);
2559 if FPunchAnim
.played
then
2566 if (FMegaRulez
[MR_INVUL
] > gTime
) and ((gPlayerDrawn
<> Self
) or (FSpawnInvul
>= gTime
)) then
2567 if g_Texture_Get('TEXTURE_PLAYER_INVULPENTA', ID
) then
2569 e_GetTextureSize(ID
, @w
, @h
);
2570 if FDirection
= TDirection
.D_LEFT
then
2571 e_Draw(ID
, fX
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2)-(w
div 2)+4,
2572 fY
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2)-(h
div 2)-7+fSlope
, 0, True, False)
2574 e_Draw(ID
, fX
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2)-(w
div 2)-2,
2575 fY
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2)-(h
div 2)-7+fSlope
, 0, True, False);
2578 if FMegaRulez
[MR_INVIS
] > gTime
then
2580 if (gPlayerDrawn
<> nil) and ((Self
= gPlayerDrawn
) or
2581 ((FTeam
= gPlayerDrawn
.Team
) and (gGameSettings
.GameMode
<> GM_DM
))) then
2583 if (FMegaRulez
[MR_INVIS
] - gTime
) <= 2100 then
2584 dr
:= not Odd((FMegaRulez
[MR_INVIS
] - gTime
) div 300)
2588 FModel
.Draw(fX
, fY
+fSlope
, 200)
2590 FModel
.Draw(fX
, fY
+fSlope
);
2593 FModel
.Draw(fX
, fY
+fSlope
, 254);
2596 FModel
.Draw(fX
, fY
+fSlope
);
2599 if g_debug_Frames
then
2601 e_DrawQuad(FObj
.X
+FObj
.Rect
.X
,
2603 FObj
.X
+FObj
.Rect
.X
+FObj
.Rect
.Width
-1,
2604 FObj
.Y
+FObj
.Rect
.Y
+FObj
.Rect
.Height
-1,
2608 if (gChatBubble
> 0) and (FKeys
[KEY_CHAT
].Pressed
) and not FGhost
then
2609 if (FMegaRulez
[MR_INVIS
] <= gTime
) or ((gPlayerDrawn
<> nil) and ((Self
= gPlayerDrawn
) or
2610 ((FTeam
= gPlayerDrawn
.Team
) and (gGameSettings
.GameMode
<> GM_DM
)))) then
2612 // e_DrawPoint(5, 335, 288, 255, 0, 0); // DL, UR, DL, UR
2613 if gAimLine
and alive
and
2614 ((Self
= gPlayer1
) or (Self
= gPlayer2
)) then
2619 procedure TPlayer
.DrawAim();
2620 procedure drawCast (sz
: Integer; ax0
, ay0
, ax1
, ay1
: Integer);
2625 {$IFDEF ENABLE_HOLMES}
2626 if isValidViewPort
and (self
= gPlayer1
) then
2628 g_Holmes_plrLaser(ax0
, ay0
, ax1
, ay1
);
2632 e_DrawLine(sz
, ax0
, ay0
, ax1
, ay1
, 255, 0, 0, 96);
2633 if (g_Map_traceToNearestWall(ax0
, ay0
, ax1
, ay1
, @ex
, @ey
) <> nil) then
2635 e_DrawLine(sz
, ax0
, ay0
, ex
, ey
, 0, 255, 0, 96);
2639 e_DrawLine(sz
, ax0
, ay0
, ex
, ey
, 0, 0, 255, 96);
2644 wx
, wy
, xx
, yy
: Integer;
2648 wx
:= FObj
.X
+ WEAPONPOINT
[FDirection
].X
+ IfThen(FDirection
= TDirection
.D_LEFT
, 7, -7);
2649 wy
:= FObj
.Y
+ WEAPONPOINT
[FDirection
].Y
;
2658 1: begin // Chainsaw
2665 if angle
= ANGLE_RIGHTUP
then Dec(angle
, 2);
2666 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 4);
2667 if angle
= ANGLE_LEFTUP
then Inc(angle
, 2);
2668 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 4);
2673 if angle
= ANGLE_RIGHTUP
then Dec(angle
, 2);
2674 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 4);
2675 if angle
= ANGLE_LEFTUP
then Inc(angle
, 2);
2676 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 4);
2678 4: begin // Double Shotgun
2681 if angle
= ANGLE_RIGHTUP
then Dec(angle
, 2);
2682 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 4);
2683 if angle
= ANGLE_LEFTUP
then Inc(angle
, 2);
2684 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 4);
2686 5: begin // Chaingun
2689 if angle
= ANGLE_RIGHTUP
then Dec(angle
, 2);
2690 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 4);
2691 if angle
= ANGLE_LEFTUP
then Inc(angle
, 2);
2692 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 4);
2694 6: begin // Rocket Launcher
2697 if angle
= ANGLE_RIGHTUP
then Inc(angle
, 2);
2698 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 4);
2699 if angle
= ANGLE_LEFTUP
then Dec(angle
, 2);
2700 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 4);
2702 7: begin // Plasmagun
2705 if angle
= ANGLE_RIGHTUP
then Inc(angle
);
2706 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 3);
2707 if angle
= ANGLE_LEFTUP
then Dec(angle
);
2708 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 3);
2713 if angle
= ANGLE_RIGHTUP
then Inc(angle
, 1);
2714 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 2);
2715 if angle
= ANGLE_LEFTUP
then Dec(angle
, 1);
2716 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 2);
2718 9: begin // Super Chaingun
2721 if angle
= ANGLE_RIGHTUP
then Dec(angle
, 2);
2722 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 4);
2723 if angle
= ANGLE_LEFTUP
then Inc(angle
, 2);
2724 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 4);
2727 xx
:= Trunc(Cos(-DegToRad(angle
)) * len
) + wx
;
2728 yy
:= Trunc(Sin(-DegToRad(angle
)) * len
) + wy
;
2729 {$IF DEFINED(D2F_DEBUG)}
2730 drawCast(sz
, wx
, wy
, xx
, yy
);
2732 e_DrawLine(sz
, wx
, wy
, xx
, yy
, 255, 0, 0, 96);
2736 procedure TPlayer
.DrawGUI();
2739 X
, Y
, SY
, a
, p
, m
: Integer;
2743 stat
: TPlayerStatArray
;
2745 X
:= gPlayerScreenSize
.X
;
2746 SY
:= gPlayerScreenSize
.Y
;
2749 if gShowGoals
and (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then
2751 if gGameSettings
.GameMode
= GM_CTF
then
2755 if gGameSettings
.GameMode
= GM_CTF
then
2757 s
:= 'TEXTURE_PLAYER_REDFLAG';
2758 if gFlags
[FLAG_RED
].State
= FLAG_STATE_CAPTURED
then
2759 s
:= 'TEXTURE_PLAYER_REDFLAG_S';
2760 if gFlags
[FLAG_RED
].State
= FLAG_STATE_DROPPED
then
2761 s
:= 'TEXTURE_PLAYER_REDFLAG_D';
2762 if g_Texture_Get(s
, ID
) then
2763 e_Draw(ID
, X
-16-32, 240-72-4, 0, True, False);
2766 s
:= IntToStr(gTeamStat
[TEAM_RED
].Goals
);
2767 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2768 e_CharFont_PrintEx(gMenuFont
, X
-16-a
-tw
, 240-72-4, s
, TEAMCOLOR
[TEAM_RED
]);
2770 if gGameSettings
.GameMode
= GM_CTF
then
2772 s
:= 'TEXTURE_PLAYER_BLUEFLAG';
2773 if gFlags
[FLAG_BLUE
].State
= FLAG_STATE_CAPTURED
then
2774 s
:= 'TEXTURE_PLAYER_BLUEFLAG_S';
2775 if gFlags
[FLAG_BLUE
].State
= FLAG_STATE_DROPPED
then
2776 s
:= 'TEXTURE_PLAYER_BLUEFLAG_D';
2777 if g_Texture_Get(s
, ID
) then
2778 e_Draw(ID
, X
-16-32, 240-32-4, 0, True, False);
2781 s
:= IntToStr(gTeamStat
[TEAM_BLUE
].Goals
);
2782 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2783 e_CharFont_PrintEx(gMenuFont
, X
-16-a
-tw
, 240-32-4, s
, TEAMCOLOR
[TEAM_BLUE
]);
2786 if g_Texture_Get('TEXTURE_PLAYER_HUDBG', ID
) then
2787 e_DrawFill(ID
, X
, 0, 1, (gPlayerScreenSize
.Y
div 256)+IfThen(gPlayerScreenSize
.Y
mod 256 > 0, 1, 0),
2790 if g_Texture_Get('TEXTURE_PLAYER_HUD', ID
) then
2791 e_Draw(ID
, X
+2, Y
, 0, True, False);
2793 if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
2797 s
:= IntToStr(Frags
);
2798 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2799 e_CharFont_PrintEx(gMenuFont
, X
-16-tw
, Y
, s
, _RGB(255, 0, 0));
2804 stat
:= g_Player_GetStats();
2809 for a
:= 0 to High(stat
) do
2810 if stat
[a
].Name
<> Name
then
2812 if stat
[a
].Frags
> m
then m
:= stat
[a
].Frags
;
2813 if stat
[a
].Frags
> Frags
then p
:= p
+1;
2817 s
:= IntToStr(p
)+' / '+IntToStr(Length(stat
))+' ';
2818 if Frags
>= m
then s
:= s
+'+' else s
:= s
+'-';
2819 s
:= s
+IntToStr(Abs(Frags
-m
));
2821 e_CharFont_GetSize(gMenuSmallFont
, s
, tw
, th
);
2822 e_CharFont_PrintEx(gMenuSmallFont
, X
-16-tw
, Y
+32, s
, _RGB(255, 0, 0));
2825 if gLMSRespawn
> LMS_RESPAWN_NONE
then
2827 s
:= _lc
[I_GAME_WARMUP
];
2828 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2829 s
:= s
+ ': ' + IntToStr((gLMSRespawnTime
- gTime
) div 1000);
2830 e_CharFont_PrintEx(gMenuFont
, X
-64-tw
, SY
-32, s
, _RGB(0, 255, 0));
2832 else if gShowLives
and (gGameSettings
.MaxLives
> 0) then
2834 s
:= IntToStr(Lives
);
2835 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2836 e_CharFont_PrintEx(gMenuFont
, X
-16-tw
, SY
-32, s
, _RGB(0, 255, 0));
2840 e_CharFont_GetSize(gMenuSmallFont
, FName
, tw
, th
);
2841 e_CharFont_PrintEx(gMenuSmallFont
, X
+98-(tw
div 2), Y
+8, FName
, _RGB(255, 0, 0));
2843 if R_BERSERK
in FRulez
then
2844 e_Draw(gItemsTexturesID
[ITEM_MEDKIT_BLACK
], X
+37, Y
+45, 0, True, False)
2846 e_Draw(gItemsTexturesID
[ITEM_MEDKIT_LARGE
], X
+37, Y
+45, 0, True, False);
2848 if g_Texture_Get('TEXTURE_PLAYER_ARMORHUD', ID
) then
2849 e_Draw(ID
, X
+36, Y
+77, 0, True, False);
2851 s
:= IntToStr(IfThen(FHealth
> 0, FHealth
, 0));
2852 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2853 e_CharFont_PrintEx(gMenuFont
, X
+178-tw
, Y
+40, s
, _RGB(255, 0, 0));
2855 s
:= IntToStr(FArmor
);
2856 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2857 e_CharFont_PrintEx(gMenuFont
, X
+178-tw
, Y
+68, s
, _RGB(255, 0, 0));
2859 s
:= IntToStr(GetAmmoByWeapon(FCurrWeap
));
2865 ID
:= gItemsTexturesID
[ITEM_WEAPON_KASTET
];
2870 ID
:= gItemsTexturesID
[ITEM_WEAPON_SAW
];
2872 WEAPON_PISTOL
: ID
:= gItemsTexturesID
[ITEM_WEAPON_PISTOL
];
2873 WEAPON_CHAINGUN
: ID
:= gItemsTexturesID
[ITEM_WEAPON_CHAINGUN
];
2874 WEAPON_SHOTGUN1
: ID
:= gItemsTexturesID
[ITEM_WEAPON_SHOTGUN1
];
2875 WEAPON_SHOTGUN2
: ID
:= gItemsTexturesID
[ITEM_WEAPON_SHOTGUN2
];
2876 WEAPON_SUPERPULEMET
: ID
:= gItemsTexturesID
[ITEM_WEAPON_SUPERPULEMET
];
2877 WEAPON_ROCKETLAUNCHER
: ID
:= gItemsTexturesID
[ITEM_WEAPON_ROCKETLAUNCHER
];
2878 WEAPON_PLASMA
: ID
:= gItemsTexturesID
[ITEM_WEAPON_PLASMA
];
2879 WEAPON_BFG
: ID
:= gItemsTexturesID
[ITEM_WEAPON_BFG
];
2880 WEAPON_FLAMETHROWER
: ID
:= gItemsTexturesID
[ITEM_WEAPON_FLAMETHROWER
];
2883 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2884 e_CharFont_PrintEx(gMenuFont
, X
+178-tw
, Y
+158, s
, _RGB(255, 0, 0));
2885 e_Draw(ID
, X
+20, Y
+160, 0, True, False);
2887 if R_KEY_RED
in FRulez
then
2888 e_Draw(gItemsTexturesID
[ITEM_KEY_RED
], X
+78, Y
+214, 0, True, False);
2890 if R_KEY_GREEN
in FRulez
then
2891 e_Draw(gItemsTexturesID
[ITEM_KEY_GREEN
], X
+95, Y
+214, 0, True, False);
2893 if R_KEY_BLUE
in FRulez
then
2894 e_Draw(gItemsTexturesID
[ITEM_KEY_BLUE
], X
+112, Y
+214, 0, True, False);
2896 if FJetFuel
> 0 then
2898 if g_Texture_Get('TEXTURE_PLAYER_HUDAIR', ID
) then
2899 e_Draw(ID
, X
+2, Y
+116, 0, True, False);
2900 if g_Texture_Get('TEXTURE_PLAYER_HUDJET', ID
) then
2901 e_Draw(ID
, X
+2, Y
+126, 0, True, False);
2902 e_DrawLine(4, X
+16, Y
+122, X
+16+Trunc(168*IfThen(FAir
> 0, FAir
, 0)/AIR_MAX
), Y
+122, 0, 0, 196);
2903 e_DrawLine(4, X
+16, Y
+132, X
+16+Trunc(168*FJetFuel
/JET_MAX
), Y
+132, 208, 0, 0);
2907 if g_Texture_Get('TEXTURE_PLAYER_HUDAIR', ID
) then
2908 e_Draw(ID
, X
+2, Y
+124, 0, True, False);
2909 e_DrawLine(4, X
+16, Y
+130, X
+16+Trunc(168*IfThen(FAir
> 0, FAir
, 0)/AIR_MAX
), Y
+130, 0, 0, 196);
2912 if gShowPing
and g_Game_IsClient
then
2914 s
:= _lc
[I_GAME_PING_HUD
] + IntToStr(NetPeer
.lastRoundTripTime
) + _lc
[I_NET_SLIST_PING_MS
];
2915 e_TextureFontPrint(X
+ 4, Y
+ 242, s
, gStdFont
);
2921 e_TextureFontPrint(X
+ 4, Y
+ 242, _lc
[I_PLAYER_SPECT
], gStdFont
);
2922 e_TextureFontPrint(X
+ 4, Y
+ 258, _lc
[I_PLAYER_SPECT2
], gStdFont
);
2923 e_TextureFontPrint(X
+ 4, Y
+ 274, _lc
[I_PLAYER_SPECT1
], gStdFont
);
2926 e_TextureFontGetSize(gStdFont
, cw
, ch
);
2927 s
:= _lc
[I_PLAYER_SPECT4
];
2928 e_TextureFontPrintEx(gScreenWidth
div 2 - cw
*(Length(s
) div 2),
2929 gScreenHeight
-4-ch
, s
, gStdFont
, 255, 255, 255, 1, True);
2930 e_TextureFontPrint(X
+ 4, Y
+ 290, _lc
[I_PLAYER_SPECT1S
], gStdFont
);
2936 procedure TPlayer
.DrawRulez();
2940 // Ïðè âçÿòèè íåóÿçâèìîñòè ðèñóåòñÿ èíâåðñèîííûé áåëûé ôîí
2941 if (FMegaRulez
[MR_INVUL
] >= gTime
) and (FSpawnInvul
< gTime
) then
2943 if (FMegaRulez
[MR_INVUL
]-gTime
) <= 2100 then
2944 dr
:= not Odd((FMegaRulez
[MR_INVUL
]-gTime
) div 300)
2949 e_DrawFillQuad(0, 0, gPlayerScreenSize
.X
-1, gPlayerScreenSize
.Y
-1,
2950 191, 191, 191, 0, TBlending
.Invert
);
2953 // Ïðè âçÿòèè çàùèòíîãî êîñòþìà ðèñóåòñÿ çåëåíîâàòûé ôîí
2954 if FMegaRulez
[MR_SUIT
] >= gTime
then
2956 if (FMegaRulez
[MR_SUIT
]-gTime
) <= 2100 then
2957 dr
:= not Odd((FMegaRulez
[MR_SUIT
]-gTime
) div 300)
2962 e_DrawFillQuad(0, 0, gPlayerScreenSize
.X
-1, gPlayerScreenSize
.Y
-1,
2963 0, 96, 0, 200, TBlending
.None
);
2966 // Ïðè âçÿòèè áåðñåðêà ðèñóåòñÿ êðàñíîâàòûé ôîí
2967 if (FBerserk
>= 0) and (LongWord(FBerserk
) >= gTime
) and (gFlash
= 2) then
2969 e_DrawFillQuad(0, 0, gPlayerScreenSize
.X
-1, gPlayerScreenSize
.Y
-1,
2970 255, 0, 0, 200, TBlending
.None
);
2974 procedure TPlayer
.DrawPain();
2978 if FPain
= 0 then Exit
;
2982 if a
< 15 then h
:= 0
2983 else if a
< 35 then h
:= 1
2984 else if a
< 55 then h
:= 2
2985 else if a
< 75 then h
:= 3
2986 else if a
< 95 then h
:= 4
2989 //if a > 255 then a := 255;
2991 e_DrawFillQuad(0, 0, gPlayerScreenSize
.X
-1, gPlayerScreenSize
.Y
-1, 255, 0, 0, 255-h
*50);
2992 //e_DrawFillQuad(0, 0, gPlayerScreenSize.X-1, gPlayerScreenSize.Y-1, 255-min(128, a), 255-a, 255-a, 0, B_FILTER);
2995 procedure TPlayer
.DrawPickup();
2999 if FPickup
= 0 then Exit
;
3003 if a
< 15 then h
:= 1
3004 else if a
< 35 then h
:= 2
3005 else if a
< 55 then h
:= 3
3006 else if a
< 75 then h
:= 4
3009 e_DrawFillQuad(0, 0, gPlayerScreenSize
.X
-1, gPlayerScreenSize
.Y
-1, 150, 200, 150, 255-h
*50);
3012 procedure TPlayer
.DoPunch();
3017 if FPunchAnim
<> nil then begin
3022 st
:= 'FRAMES_PUNCH';
3023 if R_BERSERK
in FRulez
then
3024 st
:= st
+ '_BERSERK';
3025 if FKeys
[KEY_UP
].Pressed
then
3027 else if FKeys
[KEY_DOWN
].Pressed
then
3029 g_Frames_Get(id
, st
);
3030 FPunchAnim
:= TAnimation
.Create(id
, False, 1);
3033 procedure TPlayer
.Fire();
3035 f
, DidFire
: Boolean;
3036 wx
, wy
, xd
, yd
: Integer;
3039 if g_Game_IsClient
then Exit
;
3040 // FBFGFireCounter - âðåìÿ ïåðåä âûñòðåëîì (äëÿ BFG)
3041 // FReloading - âðåìÿ ïîñëå âûñòðåëà (äëÿ âñåãî)
3049 if FReloading
[FCurrWeap
] <> 0 then Exit
;
3054 wx
:= FObj
.X
+WEAPONPOINT
[FDirection
].X
;
3055 wy
:= FObj
.Y
+WEAPONPOINT
[FDirection
].Y
;
3056 xd
:= wx
+IfThen(FDirection
= TDirection
.D_LEFT
, -30, 30);
3057 yd
:= wy
+firediry();
3063 if R_BERSERK
in FRulez
then
3065 //g_Weapon_punch(FObj.X+FObj.Rect.X, FObj.Y+FObj.Rect.Y, 75, FUID);
3066 locobj
.X
:= FObj
.X
+FObj
.Rect
.X
;
3067 locobj
.Y
:= FObj
.Y
+FObj
.Rect
.Y
;
3070 locobj
.rect
.Width
:= 39;
3071 locobj
.rect
.Height
:= 52;
3072 locobj
.Vel
.X
:= (xd
-wx
) div 2;
3073 locobj
.Vel
.Y
:= (yd
-wy
) div 2;
3074 locobj
.Accel
.X
:= xd
-wx
;
3075 locobj
.Accel
.y
:= yd
-wy
;
3077 if g_Weapon_Hit(@locobj
, 50, FUID
, HIT_SOME
) <> 0 then
3078 g_Sound_PlayExAt('SOUND_WEAPON_HITBERSERK', FObj
.X
, FObj
.Y
)
3080 g_Sound_PlayExAt('SOUND_WEAPON_MISSBERSERK', FObj
.X
, FObj
.Y
);
3082 if (gFlash
= 1) and (FPain
< 50) then FPain
:= min(FPain
+ 25, 50);
3086 g_Weapon_punch(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
, 3, FUID
);
3090 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
3095 if g_Weapon_chainsaw(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
,
3096 IfThen(gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
], 9, 3), FUID
) <> 0 then
3098 FSawSoundSelect
.Stop();
3100 FSawSoundHit
.PlayAt(FObj
.X
, FObj
.Y
);
3102 else if not FSawSoundHit
.IsPlaying() then
3104 FSawSoundSelect
.Stop();
3105 FSawSound
.PlayAt(FObj
.X
, FObj
.Y
);
3108 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
3114 if FAmmo
[A_BULLETS
] > 0 then
3116 g_Weapon_pistol(wx
, wy
, xd
, yd
, FUID
);
3117 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
3118 Dec(FAmmo
[A_BULLETS
]);
3119 FFireAngle
:= FAngle
;
3122 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
3123 GameVelX
, GameVelY
-2, SHELL_BULLET
);
3127 if FAmmo
[A_SHELLS
] > 0 then
3129 g_Weapon_shotgun(wx
, wy
, xd
, yd
, FUID
);
3130 if not gSoundEffectsDF
then g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN', wx
, wy
);
3131 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
3132 Dec(FAmmo
[A_SHELLS
]);
3133 FFireAngle
:= FAngle
;
3137 FShellType
:= SHELL_SHELL
;
3141 if FAmmo
[A_SHELLS
] >= 2 then
3143 g_Weapon_dshotgun(wx
, wy
, xd
, yd
, FUID
);
3144 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
3145 Dec(FAmmo
[A_SHELLS
], 2);
3146 FFireAngle
:= FAngle
;
3150 FShellType
:= SHELL_DBLSHELL
;
3154 if FAmmo
[A_BULLETS
] > 0 then
3156 g_Weapon_mgun(wx
, wy
, xd
, yd
, FUID
);
3157 if not gSoundEffectsDF
then g_Sound_PlayExAt('SOUND_WEAPON_FIREPISTOL', wx
, wy
);
3158 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
3159 Dec(FAmmo
[A_BULLETS
]);
3160 FFireAngle
:= FAngle
;
3163 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
3164 GameVelX
, GameVelY
-2, SHELL_BULLET
);
3167 WEAPON_ROCKETLAUNCHER
:
3168 if FAmmo
[A_ROCKETS
] > 0 then
3170 g_Weapon_rocket(wx
, wy
, xd
, yd
, FUID
);
3171 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
3172 Dec(FAmmo
[A_ROCKETS
]);
3173 FFireAngle
:= FAngle
;
3179 if FAmmo
[A_CELLS
] > 0 then
3181 g_Weapon_plasma(wx
, wy
, xd
, yd
, FUID
);
3182 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
3183 Dec(FAmmo
[A_CELLS
]);
3184 FFireAngle
:= FAngle
;
3190 if (FAmmo
[A_CELLS
] >= 40) and (FBFGFireCounter
= -1) then
3192 FBFGFireCounter
:= 17;
3193 if not FNoReload
then
3194 g_Sound_PlayExAt('SOUND_WEAPON_STARTFIREBFG', FObj
.X
, FObj
.Y
);
3195 Dec(FAmmo
[A_CELLS
], 40);
3199 WEAPON_SUPERPULEMET
:
3200 if FAmmo
[A_SHELLS
] > 0 then
3202 g_Weapon_shotgun(wx
, wy
, xd
, yd
, FUID
);
3203 if not gSoundEffectsDF
then g_Sound_PlayExAt('SOUND_WEAPON_FIRECGUN', wx
, wy
);
3204 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
3205 Dec(FAmmo
[A_SHELLS
]);
3206 FFireAngle
:= FAngle
;
3209 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
3210 GameVelX
, GameVelY
-2, SHELL_SHELL
);
3213 WEAPON_FLAMETHROWER
:
3214 if FAmmo
[A_FUEL
] > 0 then
3216 g_Weapon_flame(wx
, wy
, xd
, yd
, FUID
);
3218 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
3220 FFireAngle
:= FAngle
;
3227 if g_Game_IsNet
and g_Game_IsServer
then MH_SEND_PlayerStats(FUID
);
3231 if g_Game_IsNet
then
3235 if FCurrWeap
<> WEAPON_BFG
then
3236 MH_SEND_PlayerFire(FUID
, FCurrWeap
, wx
, wy
, xd
, yd
, LastShotID
)
3238 if not FNoReload
then
3239 MH_SEND_Sound(FObj
.X
, FObj
.Y
, 'SOUND_WEAPON_STARTFIREBFG');
3242 MH_SEND_PlayerStats(FUID
);
3247 if (FAngle
= 0) or (FAngle
= 180) then SetAction(A_ATTACK
)
3248 else if (FAngle
= ANGLE_LEFTDOWN
) or (FAngle
= ANGLE_RIGHTDOWN
) then SetAction(A_ATTACKDOWN
)
3249 else if (FAngle
= ANGLE_LEFTUP
) or (FAngle
= ANGLE_RIGHTUP
) then SetAction(A_ATTACKUP
);
3252 function TPlayer
.GetAmmoByWeapon(Weapon
: Byte): Word;
3255 WEAPON_PISTOL
, WEAPON_CHAINGUN
: Result
:= FAmmo
[A_BULLETS
];
3256 WEAPON_SHOTGUN1
, WEAPON_SHOTGUN2
, WEAPON_SUPERPULEMET
: Result
:= FAmmo
[A_SHELLS
];
3257 WEAPON_ROCKETLAUNCHER
: Result
:= FAmmo
[A_ROCKETS
];
3258 WEAPON_PLASMA
, WEAPON_BFG
: Result
:= FAmmo
[A_CELLS
];
3259 WEAPON_FLAMETHROWER
: Result
:= FAmmo
[A_FUEL
];
3264 function TPlayer
.HeadInLiquid(XInc
, YInc
: Integer): Boolean;
3266 Result
:= g_Map_CollidePanel(FObj
.X
+PLAYER_HEADRECT
.X
+XInc
, FObj
.Y
+PLAYER_HEADRECT
.Y
+YInc
,
3267 PLAYER_HEADRECT
.Width
, PLAYER_HEADRECT
.Height
,
3268 PANEL_WATER
or PANEL_ACID1
or PANEL_ACID2
, True);
3271 procedure TPlayer
.FlamerOn
;
3273 FFlameSoundOff
.Stop();
3274 FFlameSoundOff
.SetPosition(0);
3277 if (not FFlameSoundOn
.IsPlaying()) and (not FFlameSoundWork
.IsPlaying()) then
3278 FFlameSoundWork
.PlayAt(FObj
.X
, FObj
.Y
);
3282 FFlameSoundOn
.PlayAt(FObj
.X
, FObj
.Y
);
3287 procedure TPlayer
.FlamerOff
;
3291 FFlameSoundOn
.Stop();
3292 FFlameSoundOn
.SetPosition(0);
3293 FFlameSoundWork
.Stop();
3294 FFlameSoundWork
.SetPosition(0);
3295 FFlameSoundOff
.PlayAt(FObj
.X
, FObj
.Y
);
3300 procedure TPlayer
.JetpackOn
;
3304 FJetSoundOn
.SetPosition(0);
3305 FJetSoundOn
.PlayAt(FObj
.X
, FObj
.Y
);
3309 procedure TPlayer
.JetpackOff
;
3313 FJetSoundOff
.SetPosition(0);
3314 FJetSoundOff
.PlayAt(FObj
.X
, FObj
.Y
);
3317 procedure TPlayer
.CatchFire(Attacker
: Word; Timeout
: Integer = PLAYER_BURN_TIME
);
3319 if Timeout
<= 0 then
3321 if (FMegaRulez
[MR_SUIT
] > gTime
) or (FMegaRulez
[MR_INVUL
] > gTime
) then
3322 exit
; // Íå çàãîðàåìñÿ êîãäà åñòü çàùèòà
3323 if g_Obj_CollidePanel(@FObj
, 0, 0, PANEL_WATER
or PANEL_ACID1
or PANEL_ACID2
) then
3324 exit
; // Íå ïîäãîðàåì â âîäå íà âñÿêèé ñëó÷àé
3325 if FFireTime
<= 0 then
3326 g_Sound_PlayExAt('SOUND_IGNITE', FObj
.X
, FObj
.Y
);
3327 FFireTime
:= Timeout
;
3328 FFireAttacker
:= Attacker
;
3329 if g_Game_IsNet
and g_Game_IsServer
then
3330 MH_SEND_PlayerStats(FUID
);
3333 procedure TPlayer
.Jump();
3335 if gFly
or FJetpack
then
3337 // Ïîëåò (÷èò-êîä èëè äæåòïàê):
3338 if FObj
.Vel
.Y
> -VEL_FLY
then
3339 FObj
.Vel
.Y
:= FObj
.Vel
.Y
- 3;
3342 if FJetFuel
> 0 then
3344 if (FJetFuel
< 1) and g_Game_IsServer
then
3348 if g_Game_IsNet
then
3349 MH_SEND_PlayerStats(FUID
);
3355 // Íå âêëþ÷àòü äæåòïàê â ðåæèìå ïðîõîæäåíèÿ ñêâîçü ñòåíû
3357 FCanJetpack
:= False;
3359 // Ïðûãàåì èëè âñïëûâàåì:
3360 if (CollideLevel(0, 1) or
3361 g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+PLAYER_RECT
.Y
+36, PLAYER_RECT
.Width
,
3362 PLAYER_RECT
.Height
-33, PANEL_STEP
, False)
3363 ) and (FObj
.Accel
.Y
= 0) then // Íå ïðûãàòü, åñëè åñòü âåðòèêàëüíîå óñêîðåíèå
3365 FObj
.Vel
.Y
:= -VEL_JUMP
;
3366 FCanJetpack
:= False;
3370 if BodyInLiquid(0, 0) then
3371 FObj
.Vel
.Y
:= -VEL_SW
3372 else if (FJetFuel
> 0) and FCanJetpack
and
3373 g_Game_IsServer
and (not g_Obj_CollideLiquid(@FObj
, 0, 0)) then
3377 if g_Game_IsNet
then
3378 MH_SEND_PlayerStats(FUID
);
3383 procedure TPlayer
.Kill(KillType
: Byte; SpawnerUID
: Word; t
: Byte);
3385 a
, i
, k
, ab
, ar
: Byte;
3389 srv
, netsrv
: Boolean;
3395 procedure PushItem(t
: Byte);
3399 id
:= g_Items_Create(FObj
.X
, FObj
.Y
, t
, True, False);
3400 it
:= g_Items_ByIdx(id
);
3401 if KillType
= K_EXTRAHARDKILL
then // -7..+7; -8..0
3403 g_Obj_Push(@it
.Obj
, (FObj
.Vel
.X
div 2)-7+Random(15),
3404 (FObj
.Vel
.Y
div 2)-Random(9));
3405 it
.positionChanged(); // this updates spatial accelerators
3409 if KillType
= K_HARDKILL
then // -5..+5; -5..0
3411 g_Obj_Push(@it
.Obj
, (FObj
.Vel
.X
div 2)-5+Random(11),
3412 (FObj
.Vel
.Y
div 2)-Random(6));
3414 else // -3..+3; -3..0
3416 g_Obj_Push(@it
.Obj
, (FObj
.Vel
.X
div 2)-3+Random(7),
3417 (FObj
.Vel
.Y
div 2)-Random(4));
3419 it
.positionChanged(); // this updates spatial accelerators
3422 if g_Game_IsNet
and g_Game_IsServer
then
3423 MH_SEND_ItemSpawn(True, id
);
3427 DoFrags
:= (gGameSettings
.MaxLives
= 0) or (gGameSettings
.GameMode
= GM_COOP
);
3428 Srv
:= g_Game_IsServer
;
3429 Netsrv
:= g_Game_IsServer
and g_Game_IsNet
;
3430 if Srv
then FDeath
:= FDeath
+ 1;
3435 if not FPhysics
then
3441 if (gGameSettings
.MaxLives
> 0) and Srv
and (gLMSRespawn
= LMS_RESPAWN_NONE
) then
3443 if FLives
> 0 then FLives
:= FLives
- 1;
3444 if FLives
= 0 then FNoRespawn
:= True;
3447 // Íîìåð òèïà ñìåðòè:
3450 K_SIMPLEKILL
: a
:= 1;
3452 K_EXTRAHARDKILL
: a
:= 3;
3457 if not FModel
.PlaySound(MODELSOUND_DIE
, a
, FObj
.X
, FObj
.Y
) then
3459 if FModel
.PlaySound(MODELSOUND_DIE
, i
, FObj
.X
, FObj
.Y
) then
3466 FTime
[T_RESPAWN
] := gTime
+ TIME_RESPAWN1
;
3468 FTime
[T_RESPAWN
] := gTime
+ TIME_RESPAWN2
;
3469 K_EXTRAHARDKILL
, K_FALLKILL
:
3470 FTime
[T_RESPAWN
] := gTime
+ TIME_RESPAWN3
;
3473 // Ïåðåêëþ÷àåì ñîñòîÿíèå:
3477 K_HARDKILL
, K_EXTRAHARDKILL
:
3481 // Ðåàêöèÿ ìîíñòðîâ íà ñìåðòü èãðîêà:
3482 if (KillType
<> K_FALLKILL
) and (Srv
) then
3483 g_Monsters_killedp();
3485 if SpawnerUID
= FUID
then
3487 if Srv
and (DoFrags
or (gGameSettings
.GameMode
= GM_TDM
)) then
3492 g_Console_Add(Format(_lc
[I_PLAYER_KILL_SELF
], [FName
]), True);
3495 if g_GetUIDType(SpawnerUID
) = UID_PLAYER
then
3496 begin // Óáèò äðóãèì èãðîêîì
3497 KP
:= g_Player_Get(SpawnerUID
);
3498 if (KP
<> nil) and Srv
then
3500 if (DoFrags
or (gGameSettings
.GameMode
= GM_TDM
)) then
3501 if SameTeam(FUID
, SpawnerUID
) then
3511 if (gGameSettings
.GameMode
= GM_TDM
) and DoFrags
then
3512 Inc(gTeamStat
[KP
.Team
].Goals
,
3513 IfThen(SameTeam(FUID
, SpawnerUID
), -1, 1));
3515 if netsrv
then MH_SEND_PlayerStats(SpawnerUID
);
3518 plr
:= g_Player_Get(SpawnerUID
);
3526 g_Console_Add(Format(_lc
[I_PLAYER_KILL_EXTRAHARD_2
],
3530 g_Console_Add(Format(_lc
[I_PLAYER_KILL_EXTRAHARD_1
],
3534 g_Console_Add(Format(_lc
[I_PLAYER_KILL
],
3539 else if g_GetUIDType(SpawnerUID
) = UID_MONSTER
then
3540 begin // Óáèò ìîíñòðîì
3541 mon
:= g_Monsters_ByUID(SpawnerUID
);
3545 s
:= g_Mons_GetKilledByTypeId(mon
.MonsterType
);
3549 g_Console_Add(Format(_lc
[I_PLAYER_KILL_EXTRAHARD_2
],
3553 g_Console_Add(Format(_lc
[I_PLAYER_KILL_EXTRAHARD_1
],
3557 g_Console_Add(Format(_lc
[I_PLAYER_KILL
],
3562 else // Îñîáûå òèïû ñìåðòè
3565 HIT_SELF
: g_Console_Add(Format(_lc
[I_PLAYER_KILL_SELF
], [FName
]), True);
3566 HIT_FALL
: g_Console_Add(Format(_lc
[I_PLAYER_KILL_FALL
], [FName
]), True);
3567 HIT_WATER
: g_Console_Add(Format(_lc
[I_PLAYER_KILL_WATER
], [FName
]), True);
3568 HIT_ACID
: g_Console_Add(Format(_lc
[I_PLAYER_KILL_ACID
], [FName
]), True);
3569 HIT_TRAP
: g_Console_Add(Format(_lc
[I_PLAYER_KILL_TRAP
], [FName
]), True);
3570 else g_Console_Add(Format(_lc
[I_PLAYER_DIED
], [FName
]), True);
3576 for a
:= WP_FIRST
to WP_LAST
do
3580 WEAPON_SAW
: i
:= ITEM_WEAPON_SAW
;
3581 WEAPON_SHOTGUN1
: i
:= ITEM_WEAPON_SHOTGUN1
;
3582 WEAPON_SHOTGUN2
: i
:= ITEM_WEAPON_SHOTGUN2
;
3583 WEAPON_CHAINGUN
: i
:= ITEM_WEAPON_CHAINGUN
;
3584 WEAPON_ROCKETLAUNCHER
: i
:= ITEM_WEAPON_ROCKETLAUNCHER
;
3585 WEAPON_PLASMA
: i
:= ITEM_WEAPON_PLASMA
;
3586 WEAPON_BFG
: i
:= ITEM_WEAPON_BFG
;
3587 WEAPON_SUPERPULEMET
: i
:= ITEM_WEAPON_SUPERPULEMET
;
3588 WEAPON_FLAMETHROWER
: i
:= ITEM_WEAPON_FLAMETHROWER
;
3597 if R_ITEM_BACKPACK
in FRulez
then
3598 PushItem(ITEM_AMMO_BACKPACK
);
3600 // Âûáðîñ ðàêåòíîãî ðàíöà:
3601 if FJetFuel
> 0 then
3602 PushItem(ITEM_JETPACK
);
3605 if (not (gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
])) or
3606 (not LongBool(gGameSettings
.Options
and GAME_OPTION_DMKEYS
)) then
3608 if R_KEY_RED
in FRulez
then
3609 PushItem(ITEM_KEY_RED
);
3611 if R_KEY_GREEN
in FRulez
then
3612 PushItem(ITEM_KEY_GREEN
);
3614 if R_KEY_BLUE
in FRulez
then
3615 PushItem(ITEM_KEY_BLUE
);
3619 DropFlag(KillType
= K_FALLKILL
);
3622 FCorpse
:= g_Player_CreateCorpse(Self
);
3624 if Srv
and (gGameSettings
.MaxLives
> 0) and FNoRespawn
and
3625 (gLMSRespawn
= LMS_RESPAWN_NONE
) then
3631 for i
:= Low(gPlayers
) to High(gPlayers
) do
3633 if gPlayers
[i
] = nil then continue
;
3634 if (not gPlayers
[i
].FNoRespawn
) and (not gPlayers
[i
].FSpectator
) then
3637 if gPlayers
[i
].FTeam
= TEAM_RED
then Inc(ar
)
3638 else if gPlayers
[i
].FTeam
= TEAM_BLUE
then Inc(ab
);
3643 OldLR
:= gLMSRespawn
;
3644 if (gGameSettings
.GameMode
= GM_COOP
) then
3648 // everyone is dead, restart the map
3649 g_Game_Message(_lc
[I_MESSAGE_LMS_LOSE
], 144);
3651 MH_SEND_GameEvent(NET_EV_LMS_LOSE
);
3652 gLMSRespawn
:= LMS_RESPAWN_FINAL
;
3653 gLMSRespawnTime
:= gTime
+ 5000;
3655 else if (a
= 1) then
3657 if (gPlayers
[k
] <> nil) and not (gPlayers
[k
] is TBot
) then
3658 if (gPlayers
[k
] = gPlayer1
) or
3659 (gPlayers
[k
] = gPlayer2
) then
3660 g_Console_Add('*** ' + _lc
[I_MESSAGE_LMS_SURVIVOR
] + ' ***', True)
3661 else if Netsrv
and (gPlayers
[k
].FClientID
>= 0) then
3662 MH_SEND_GameEvent(NET_EV_LMS_SURVIVOR
, 0, 'N', gPlayers
[k
].FClientID
);
3665 else if (gGameSettings
.GameMode
= GM_TDM
) then
3667 if (ab
= 0) and (ar
<> 0) then
3670 g_Game_Message(Format(_lc
[I_MESSAGE_TLMS_WIN
], [AnsiUpperCase(_lc
[I_GAME_TEAM_RED
])]), 144);
3672 MH_SEND_GameEvent(NET_EV_TLMS_WIN
, TEAM_RED
);
3673 Inc(gTeamStat
[TEAM_RED
].Goals
);
3674 gLMSRespawn
:= LMS_RESPAWN_FINAL
;
3675 gLMSRespawnTime
:= gTime
+ 5000;
3677 else if (ar
= 0) and (ab
<> 0) then
3680 g_Game_Message(Format(_lc
[I_MESSAGE_TLMS_WIN
], [AnsiUpperCase(_lc
[I_GAME_TEAM_BLUE
])]), 144);
3682 MH_SEND_GameEvent(NET_EV_TLMS_WIN
, TEAM_BLUE
);
3683 Inc(gTeamStat
[TEAM_BLUE
].Goals
);
3684 gLMSRespawn
:= LMS_RESPAWN_FINAL
;
3685 gLMSRespawnTime
:= gTime
+ 5000;
3687 else if (ar
= 0) and (ab
= 0) then
3690 g_Game_Message(_lc
[I_GAME_WIN_DRAW
], 144);
3692 MH_SEND_GameEvent(NET_EV_LMS_DRAW
, 0, FName
);
3693 gLMSRespawn
:= LMS_RESPAWN_FINAL
;
3694 gLMSRespawnTime
:= gTime
+ 5000;
3697 else if (gGameSettings
.GameMode
= GM_DM
) then
3701 if gPlayers
[k
] <> nil then
3704 // survivor is the winner
3705 g_Game_Message(Format(_lc
[I_MESSAGE_LMS_WIN
], [AnsiUpperCase(FName
)]), 144);
3707 MH_SEND_GameEvent(NET_EV_LMS_WIN
, 0, FName
);
3710 gLMSRespawn
:= LMS_RESPAWN_FINAL
;
3711 gLMSRespawnTime
:= gTime
+ 5000;
3713 else if (a
= 0) then
3715 // everyone is dead, restart the map
3716 g_Game_Message(_lc
[I_GAME_WIN_DRAW
], 144);
3718 MH_SEND_GameEvent(NET_EV_LMS_DRAW
, 0, FName
);
3719 gLMSRespawn
:= LMS_RESPAWN_FINAL
;
3720 gLMSRespawnTime
:= gTime
+ 5000;
3723 if srv
and (OldLR
= LMS_RESPAWN_NONE
) and (gLMSRespawn
> LMS_RESPAWN_NONE
) then
3725 if NetMode
= NET_SERVER
then
3726 MH_SEND_GameEvent(NET_EV_LMS_WARMUP
, gLMSRespawnTime
- gTime
)
3728 g_Console_Add(Format(_lc
[I_MSG_WARMUP_START
], [(gLMSRespawnTime
- gTime
) div 1000]), True);
3734 MH_SEND_PlayerStats(FUID
);
3735 MH_SEND_PlayerDeath(FUID
, KillType
, t
, SpawnerUID
);
3736 if gGameSettings
.GameMode
= GM_TDM
then MH_SEND_GameStats
;
3739 if srv
and FNoRespawn
then Spectate(True);
3740 FWantsInGame
:= True;
3743 function TPlayer
.BodyInLiquid(XInc
, YInc
: Integer): Boolean;
3745 Result
:= g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
, PLAYER_RECT
.Width
,
3746 PLAYER_RECT
.Height
-20, PANEL_WATER
or PANEL_ACID1
or PANEL_ACID2
, False);
3749 function TPlayer
.BodyInAcid(XInc
, YInc
: Integer): Boolean;
3751 Result
:= g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
, PLAYER_RECT
.Width
,
3752 PLAYER_RECT
.Height
-20, PANEL_ACID1
or PANEL_ACID2
, False);
3755 procedure TPlayer
.MakeBloodSimple(Count
: Word);
3757 g_GFX_Blood(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)+8,
3758 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2),
3759 Count
div 2, 3, -1, 16, (PLAYER_RECT
.Height
*2 div 3),
3760 FModel
.Blood
.R
, FModel
.Blood
.G
, FModel
.Blood
.B
, FModel
.Blood
.Kind
);
3761 g_GFX_Blood(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-8,
3762 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2),
3763 Count
div 2, -3, -1, 16, (PLAYER_RECT
.Height
*2) div 3,
3764 FModel
.Blood
.R
, FModel
.Blood
.G
, FModel
.Blood
.B
, FModel
.Blood
.Kind
);
3767 procedure TPlayer
.MakeBloodVector(Count
: Word; VelX
, VelY
: Integer);
3769 g_GFX_Blood(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2),
3770 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2),
3771 Count
, VelX
, VelY
, 16, (PLAYER_RECT
.Height
*2) div 3,
3772 FModel
.Blood
.R
, FModel
.Blood
.G
, FModel
.Blood
.B
, FModel
.Blood
.Kind
);
3775 procedure TPlayer
.QueueWeaponSwitch(Weapon
: Byte);
3777 if g_Game_IsClient
then Exit
;
3778 if Weapon
> High(FWeapon
) then Exit
;
3779 FNextWeap
:= FNextWeap
or (1 shl Weapon
);
3782 procedure TPlayer
.resetWeaponQueue ();
3785 FNextWeapDelay
:= 0;
3788 function TPlayer
.hasAmmoForWeapon (weapon
: Byte): Boolean;
3792 WEAPON_KASTET
, WEAPON_SAW
: result
:= true;
3793 WEAPON_SHOTGUN1
, WEAPON_SHOTGUN2
, WEAPON_SUPERPULEMET
: result
:= (FAmmo
[A_SHELLS
] > 0);
3794 WEAPON_PISTOL
, WEAPON_CHAINGUN
: result
:= (FAmmo
[A_BULLETS
] > 0);
3795 WEAPON_ROCKETLAUNCHER
: result
:= (FAmmo
[A_ROCKETS
] > 0);
3796 WEAPON_PLASMA
, WEAPON_BFG
: result
:= (FAmmo
[A_CELLS
] > 0);
3797 WEAPON_FLAMETHROWER
: result
:= (FAmmo
[A_FUEL
] > 0);
3798 else result
:= (weapon
< length(FWeapon
));
3802 // return 255 for "no switch"
3803 function TPlayer
.getNextWeaponIndex (): Byte;
3806 wantThisWeapon
: array[0..64] of Boolean;
3807 wwc
: Integer = 0; //HACK!
3810 result
:= 255; // default result: "no switch"
3811 // had weapon cycling on previous frame? remove that flag
3812 if (FNextWeap
and $2000) <> 0 then
3814 FNextWeap
:= FNextWeap
and $1FFF;
3815 FNextWeapDelay
:= 0;
3817 // cycling has priority
3818 if (FNextWeap
and $C000) <> 0 then
3820 if (FNextWeap
and $8000) <> 0 then
3824 FNextWeap
:= FNextWeap
or $2000; // we need this
3825 if FNextWeapDelay
> 0 then
3826 exit
; // cooldown time
3828 for i
:= 0 to High(FWeapon
) do
3830 cwi
:= (cwi
+length(FWeapon
)+dir
) mod length(FWeapon
);
3831 if FWeapon
[cwi
] then
3833 //e_WriteLog(Format(' SWITCH: cur=%d; new=%d', [FCurrWeap, cwi]), MSG_WARNING);
3834 result
:= Byte(cwi
);
3835 FNextWeapDelay
:= WEAPON_DELAY
;
3843 for i
:= 0 to High(wantThisWeapon
) do
3844 wantThisWeapon
[i
] := false;
3845 for i
:= 0 to High(FWeapon
) do
3846 if (FNextWeap
and (1 shl i
)) <> 0 then
3848 wantThisWeapon
[i
] := true;
3851 // exclude currently selected weapon from the set
3852 wantThisWeapon
[FCurrWeap
] := false;
3853 // slow down alterations a little
3856 //e_WriteLog(Format(' FNextWeap=%x; delay=%d', [FNextWeap, FNextWeapDelay]), MSG_WARNING);
3857 // more than one weapon requested, assume "alteration" and check alteration delay
3858 if FNextWeapDelay
> 0 then
3864 // do not reset weapon queue, it will be done in `RealizeCurrentWeapon()`
3865 // but clear all counters if no weapon should be switched
3871 //e_WriteLog(Format('wwc=%d', [wwc]), MSG_WARNING);
3872 // try weapons in descending order
3873 for i
:= High(FWeapon
) downto 0 do
3875 if wantThisWeapon
[i
] and FWeapon
[i
] and ((wwc
= 1) or hasAmmoForWeapon(i
)) then
3880 FNextWeapDelay
:= WEAPON_DELAY
* 2; // anyway, 'cause why not
3884 // no suitable weapon found, so reset the queue, to avoid accidental "queuing" of weapon w/o ammo
3888 procedure TPlayer
.RealizeCurrentWeapon();
3889 function switchAllowed (): Boolean;
3894 if FBFGFireCounter
<> -1 then
3896 if FTime
[T_SWITCH
] > gTime
then
3898 for i
:= WP_FIRST
to WP_LAST
do
3899 if FReloading
[i
] > 0 then
3907 //e_WriteLog(Format('***RealizeCurrentWeapon: FNextWeap=%x; FNextWeapDelay=%d', [FNextWeap, FNextWeapDelay]), MSG_WARNING);
3908 //FNextWeap := FNextWeap and $1FFF;
3909 if FNextWeapDelay
> 0 then Dec(FNextWeapDelay
); // "alteration delay"
3911 if not switchAllowed
then
3913 //HACK for weapon cycling
3914 if (FNextWeap
and $E000) <> 0 then FNextWeap
:= 0;
3918 nw
:= getNextWeaponIndex();
3919 if nw
= 255 then exit
; // don't reset anything here
3920 if nw
> High(FWeapon
) then
3922 // don't forget to reset queue here!
3923 //e_WriteLog(' RealizeCurrentWeapon: WUTAFUUUU', MSG_WARNING);
3931 FTime
[T_SWITCH
] := gTime
+156;
3932 if FCurrWeap
= WEAPON_SAW
then FSawSoundSelect
.PlayAt(FObj
.X
, FObj
.Y
);
3933 FModel
.SetWeapon(FCurrWeap
);
3934 if g_Game_IsNet
then MH_SEND_PlayerStats(FUID
);
3938 procedure TPlayer
.NextWeapon();
3940 if g_Game_IsClient
then Exit
;
3944 procedure TPlayer
.PrevWeapon();
3946 if g_Game_IsClient
then Exit
;
3950 procedure TPlayer
.SetWeapon(W
: Byte);
3952 if FCurrWeap
<> W
then
3953 if W
= WEAPON_SAW
then
3954 FSawSoundSelect
.PlayAt(FObj
.X
, FObj
.Y
);
3957 FModel
.SetWeapon(CurrWeap
);
3961 function TPlayer
.PickItem(ItemType
: Byte; arespawn
: Boolean; var remove
: Boolean): Boolean;
3963 function allowBerserkSwitching (): Boolean;
3965 if (FBFGFireCounter
<> -1) then begin result
:= false; exit
; end;
3967 if gBerserkAutoswitch
then exit
;
3968 if not conIsCheatsEnabled
then exit
;
3976 if g_Game_IsClient
then Exit
;
3978 // a = true - ìåñòî ñïàâíà ïðåäìåòà:
3979 a
:= LongBool(gGameSettings
.Options
and GAME_OPTION_WEAPONSTAY
) and arespawn
;
3984 if (FHealth
< PLAYER_HP_SOFT
) or (FFireTime
> 0) then
3986 if FHealth
< PLAYER_HP_SOFT
then IncMax(FHealth
, 10, PLAYER_HP_SOFT
);
3990 if gFlash
= 2 then Inc(FPickup
, 5);
3994 if (FHealth
< PLAYER_HP_SOFT
) or (FFireTime
> 0) then
3996 if FHealth
< PLAYER_HP_SOFT
then IncMax(FHealth
, 25, PLAYER_HP_SOFT
);
4000 if gFlash
= 2 then Inc(FPickup
, 5);
4004 if FArmor
< PLAYER_AP_SOFT
then
4006 FArmor
:= PLAYER_AP_SOFT
;
4009 if gFlash
= 2 then Inc(FPickup
, 5);
4013 if FArmor
< PLAYER_AP_LIMIT
then
4015 FArmor
:= PLAYER_AP_LIMIT
;
4018 if gFlash
= 2 then Inc(FPickup
, 5);
4022 if (FHealth
< PLAYER_HP_LIMIT
) or (FFireTime
> 0) then
4024 if FHealth
< PLAYER_HP_LIMIT
then IncMax(FHealth
, 100, PLAYER_HP_LIMIT
);
4028 if gFlash
= 2 then Inc(FPickup
, 5);
4032 if (FHealth
< PLAYER_HP_LIMIT
) or (FArmor
< PLAYER_AP_LIMIT
) or (FFireTime
> 0) then
4034 if FHealth
< PLAYER_HP_LIMIT
then
4035 FHealth
:= PLAYER_HP_LIMIT
;
4036 if FArmor
< PLAYER_AP_LIMIT
then
4037 FArmor
:= PLAYER_AP_LIMIT
;
4041 if gFlash
= 2 then Inc(FPickup
, 5);
4045 if (not FWeapon
[WEAPON_SAW
]) or ((not arespawn
) and (gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
])) then
4047 FWeapon
[WEAPON_SAW
] := True;
4049 if gFlash
= 2 then Inc(FPickup
, 5);
4050 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
4053 ITEM_WEAPON_SHOTGUN1
:
4054 if (FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
]) or not FWeapon
[WEAPON_SHOTGUN1
] then
4056 // Íóæíî, ÷òîáû íå âçÿòü âñå ïóëè ñðàçó:
4057 if a
and FWeapon
[WEAPON_SHOTGUN1
] then Exit
;
4059 IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
4060 FWeapon
[WEAPON_SHOTGUN1
] := True;
4062 if gFlash
= 2 then Inc(FPickup
, 5);
4063 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
4066 ITEM_WEAPON_SHOTGUN2
:
4067 if (FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
]) or not FWeapon
[WEAPON_SHOTGUN2
] then
4069 if a
and FWeapon
[WEAPON_SHOTGUN2
] then Exit
;
4071 IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
4072 FWeapon
[WEAPON_SHOTGUN2
] := True;
4074 if gFlash
= 2 then Inc(FPickup
, 5);
4075 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
4078 ITEM_WEAPON_CHAINGUN
:
4079 if (FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
]) or not FWeapon
[WEAPON_CHAINGUN
] then
4081 if a
and FWeapon
[WEAPON_CHAINGUN
] then Exit
;
4083 IncMax(FAmmo
[A_BULLETS
], 50, FMaxAmmo
[A_BULLETS
]);
4084 FWeapon
[WEAPON_CHAINGUN
] := True;
4086 if gFlash
= 2 then Inc(FPickup
, 5);
4087 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
4090 ITEM_WEAPON_ROCKETLAUNCHER
:
4091 if (FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
]) or not FWeapon
[WEAPON_ROCKETLAUNCHER
] then
4093 if a
and FWeapon
[WEAPON_ROCKETLAUNCHER
] then Exit
;
4095 IncMax(FAmmo
[A_ROCKETS
], 2, FMaxAmmo
[A_ROCKETS
]);
4096 FWeapon
[WEAPON_ROCKETLAUNCHER
] := True;
4098 if gFlash
= 2 then Inc(FPickup
, 5);
4099 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
4103 if (FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
]) or not FWeapon
[WEAPON_PLASMA
] then
4105 if a
and FWeapon
[WEAPON_PLASMA
] then Exit
;
4107 IncMax(FAmmo
[A_CELLS
], 40, FMaxAmmo
[A_CELLS
]);
4108 FWeapon
[WEAPON_PLASMA
] := True;
4110 if gFlash
= 2 then Inc(FPickup
, 5);
4111 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
4115 if (FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
]) or not FWeapon
[WEAPON_BFG
] then
4117 if a
and FWeapon
[WEAPON_BFG
] then Exit
;
4119 IncMax(FAmmo
[A_CELLS
], 40, FMaxAmmo
[A_CELLS
]);
4120 FWeapon
[WEAPON_BFG
] := True;
4122 if gFlash
= 2 then Inc(FPickup
, 5);
4123 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
4126 ITEM_WEAPON_SUPERPULEMET
:
4127 if (FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
]) or not FWeapon
[WEAPON_SUPERPULEMET
] then
4129 if a
and FWeapon
[WEAPON_SUPERPULEMET
] then Exit
;
4131 IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
4132 FWeapon
[WEAPON_SUPERPULEMET
] := True;
4134 if gFlash
= 2 then Inc(FPickup
, 5);
4135 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
4138 ITEM_WEAPON_FLAMETHROWER
:
4139 if (FAmmo
[A_FUEL
] < FMaxAmmo
[A_FUEL
]) or not FWeapon
[WEAPON_FLAMETHROWER
] then
4141 if a
and FWeapon
[WEAPON_FLAMETHROWER
] then Exit
;
4143 IncMax(FAmmo
[A_FUEL
], 100, FMaxAmmo
[A_FUEL
]);
4144 FWeapon
[WEAPON_FLAMETHROWER
] := True;
4146 if gFlash
= 2 then Inc(FPickup
, 5);
4147 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
4151 if FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
] then
4153 IncMax(FAmmo
[A_BULLETS
], 10, FMaxAmmo
[A_BULLETS
]);
4156 if gFlash
= 2 then Inc(FPickup
, 5);
4159 ITEM_AMMO_BULLETS_BOX
:
4160 if FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
] then
4162 IncMax(FAmmo
[A_BULLETS
], 50, FMaxAmmo
[A_BULLETS
]);
4165 if gFlash
= 2 then Inc(FPickup
, 5);
4169 if FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
] then
4171 IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
4174 if gFlash
= 2 then Inc(FPickup
, 5);
4177 ITEM_AMMO_SHELLS_BOX
:
4178 if FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
] then
4180 IncMax(FAmmo
[A_SHELLS
], 25, FMaxAmmo
[A_SHELLS
]);
4183 if gFlash
= 2 then Inc(FPickup
, 5);
4187 if FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
] then
4189 IncMax(FAmmo
[A_ROCKETS
], 1, FMaxAmmo
[A_ROCKETS
]);
4192 if gFlash
= 2 then Inc(FPickup
, 5);
4195 ITEM_AMMO_ROCKET_BOX
:
4196 if FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
] then
4198 IncMax(FAmmo
[A_ROCKETS
], 5, FMaxAmmo
[A_ROCKETS
]);
4201 if gFlash
= 2 then Inc(FPickup
, 5);
4205 if FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
] then
4207 IncMax(FAmmo
[A_CELLS
], 40, FMaxAmmo
[A_CELLS
]);
4210 if gFlash
= 2 then Inc(FPickup
, 5);
4214 if FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
] then
4216 IncMax(FAmmo
[A_CELLS
], 100, FMaxAmmo
[A_CELLS
]);
4219 if gFlash
= 2 then Inc(FPickup
, 5);
4223 if FAmmo
[A_FUEL
] < FMaxAmmo
[A_FUEL
] then
4225 IncMax(FAmmo
[A_FUEL
], 100, FMaxAmmo
[A_FUEL
]);
4228 if gFlash
= 2 then Inc(FPickup
, 5);
4232 if not(R_ITEM_BACKPACK
in FRulez
) or
4233 (FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
]) or
4234 (FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
]) or
4235 (FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
]) or
4236 (FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
]) or
4237 (FAmmo
[A_FUEL
] < FMaxAmmo
[A_FUEL
]) then
4239 FMaxAmmo
[A_BULLETS
] := AmmoLimits
[1, A_BULLETS
];
4240 FMaxAmmo
[A_SHELLS
] := AmmoLimits
[1, A_SHELLS
];
4241 FMaxAmmo
[A_ROCKETS
] := AmmoLimits
[1, A_ROCKETS
];
4242 FMaxAmmo
[A_CELLS
] := AmmoLimits
[1, A_CELLS
];
4243 FMaxAmmo
[A_FUEL
] := AmmoLimits
[1, A_FUEL
];
4245 if FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
] then
4246 IncMax(FAmmo
[A_BULLETS
], 10, FMaxAmmo
[A_BULLETS
]);
4247 if FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
] then
4248 IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
4249 if FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
] then
4250 IncMax(FAmmo
[A_ROCKETS
], 1, FMaxAmmo
[A_ROCKETS
]);
4251 if FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
] then
4252 IncMax(FAmmo
[A_CELLS
], 40, FMaxAmmo
[A_CELLS
]);
4253 if FAmmo
[A_FUEL
] < FMaxAmmo
[A_FUEL
] then
4254 IncMax(FAmmo
[A_FUEL
], 50, FMaxAmmo
[A_FUEL
]);
4256 FRulez
:= FRulez
+ [R_ITEM_BACKPACK
];
4259 if gFlash
= 2 then Inc(FPickup
, 5);
4263 if not(R_KEY_RED
in FRulez
) then
4265 Include(FRulez
, R_KEY_RED
);
4267 remove
:= (gGameSettings
.GameMode
<> GM_COOP
) and (g_Player_GetCount() < 2);
4268 if gFlash
= 2 then Inc(FPickup
, 5);
4269 if (not remove
) and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETITEM');
4273 if not(R_KEY_GREEN
in FRulez
) then
4275 Include(FRulez
, R_KEY_GREEN
);
4277 remove
:= (gGameSettings
.GameMode
<> GM_COOP
) and (g_Player_GetCount() < 2);
4278 if gFlash
= 2 then Inc(FPickup
, 5);
4279 if (not remove
) and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETITEM');
4283 if not(R_KEY_BLUE
in FRulez
) then
4285 Include(FRulez
, R_KEY_BLUE
);
4287 remove
:= (gGameSettings
.GameMode
<> GM_COOP
) and (g_Player_GetCount() < 2);
4288 if gFlash
= 2 then Inc(FPickup
, 5);
4289 if (not remove
) and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETITEM');
4293 if FMegaRulez
[MR_SUIT
] < gTime
+PLAYER_SUIT_TIME
then
4295 FMegaRulez
[MR_SUIT
] := gTime
+PLAYER_SUIT_TIME
;
4299 if gFlash
= 2 then Inc(FPickup
, 5);
4303 if FAir
< AIR_MAX
then
4308 if gFlash
= 2 then Inc(FPickup
, 5);
4313 if not (R_BERSERK
in FRulez
) then
4315 Include(FRulez
, R_BERSERK
);
4316 if allowBerserkSwitching
then
4318 FCurrWeap
:= WEAPON_KASTET
;
4320 FModel
.SetWeapon(WEAPON_KASTET
);
4325 if gFlash
= 2 then Inc(FPickup
, 5);
4327 FBerserk
:= gTime
+30000;
4332 if (FHealth
< PLAYER_HP_SOFT
) or (FFireTime
> 0) then
4334 if FHealth
< PLAYER_HP_SOFT
then FHealth
:= PLAYER_HP_SOFT
;
4335 FBerserk
:= gTime
+30000;
4343 if FMegaRulez
[MR_INVUL
] < gTime
+PLAYER_INVUL_TIME
then
4345 FMegaRulez
[MR_INVUL
] := gTime
+PLAYER_INVUL_TIME
;
4349 if gFlash
= 2 then Inc(FPickup
, 5);
4353 if (FHealth
< PLAYER_HP_LIMIT
) or (FFireTime
> 0) then
4355 if FHealth
< PLAYER_HP_LIMIT
then IncMax(FHealth
, 4, PLAYER_HP_LIMIT
);
4359 if gFlash
= 2 then Inc(FPickup
, 5);
4363 if FArmor
< PLAYER_AP_LIMIT
then
4365 IncMax(FArmor
, 5, PLAYER_AP_LIMIT
);
4368 if gFlash
= 2 then Inc(FPickup
, 5);
4372 if FJetFuel
< JET_MAX
then
4374 FJetFuel
:= JET_MAX
;
4377 if gFlash
= 2 then Inc(FPickup
, 5);
4381 if FMegaRulez
[MR_INVIS
] < gTime
+PLAYER_INVIS_TIME
then
4383 FMegaRulez
[MR_INVIS
] := gTime
+PLAYER_INVIS_TIME
;
4386 if gFlash
= 2 then Inc(FPickup
, 5);
4391 procedure TPlayer
.Touch();
4395 //FModel.PlaySound(MODELSOUND_PAIN, 1, FObj.X, FObj.Y);
4398 // Áðîñèòü ôëàã òîâàðèùó:
4399 if gGameSettings
.GameMode
= GM_CTF
then
4404 procedure TPlayer
.Push(vx
, vy
: Integer);
4406 if (not FPhysics
) and FGhost
then
4408 FObj
.Accel
.X
:= FObj
.Accel
.X
+ vx
;
4409 FObj
.Accel
.Y
:= FObj
.Accel
.Y
+ vy
;
4410 if g_Game_IsNet
and g_Game_IsServer
then
4411 MH_SEND_PlayerPos(True, FUID
, NET_EVERYONE
);
4414 procedure TPlayer
.Reset(Force
: Boolean);
4420 FTime
[T_RESPAWN
] := 0;
4421 FTime
[T_FLAGCAP
] := 0;
4437 FSpectator
:= False;
4440 FSpectatePlayer
:= -1;
4441 FNoRespawn
:= False;
4443 FLives
:= gGameSettings
.MaxLives
;
4448 procedure TPlayer
.SoftReset();
4456 FBFGFireCounter
:= -1;
4464 SetAction(A_STAND
, True);
4467 function TPlayer
.GetRespawnPoint(): Byte;
4472 // Íà áóäóùåå: FSpawn - èãðîê óæå èãðàë è ïåðåðîæäàåòñÿ
4474 // Îäèíî÷íàÿ èãðà/êîîïåðàòèâ
4475 if gGameSettings
.GameMode
in [GM_COOP
, GM_SINGLE
] then
4477 if Self
= gPlayer1
then
4479 // player 1 should try to spawn on the player 1 point
4480 if g_Map_GetPointCount(RESPAWNPOINT_PLAYER1
) > 0 then
4481 Exit(RESPAWNPOINT_PLAYER1
)
4482 else if g_Map_GetPointCount(RESPAWNPOINT_PLAYER2
) > 0 then
4483 Exit(RESPAWNPOINT_PLAYER2
);
4485 else if Self
= gPlayer2
then
4487 // player 2 should try to spawn on the player 2 point
4488 if g_Map_GetPointCount(RESPAWNPOINT_PLAYER2
) > 0 then
4489 Exit(RESPAWNPOINT_PLAYER2
)
4490 else if g_Map_GetPointCount(RESPAWNPOINT_PLAYER1
) > 0 then
4491 Exit(RESPAWNPOINT_PLAYER1
);
4495 // other players randomly pick either the first or the second point
4496 c
:= IfThen((Random(2) = 0), RESPAWNPOINT_PLAYER1
, RESPAWNPOINT_PLAYER2
);
4497 if g_Map_GetPointCount(c
) > 0 then
4499 // try the other one
4500 c
:= IfThen((c
= RESPAWNPOINT_PLAYER1
), RESPAWNPOINT_PLAYER2
, RESPAWNPOINT_PLAYER1
);
4501 if g_Map_GetPointCount(c
) > 0 then
4507 if gGameSettings
.GameMode
= GM_DM
then
4509 // try DM points first
4510 if g_Map_GetPointCount(RESPAWNPOINT_DM
) > 0 then
4511 Exit(RESPAWNPOINT_DM
);
4515 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
4517 // try team points first
4518 c
:= RESPAWNPOINT_DM
;
4519 if FTeam
= TEAM_RED
then
4520 c
:= RESPAWNPOINT_RED
4521 else if FTeam
= TEAM_BLUE
then
4522 c
:= RESPAWNPOINT_BLUE
;
4523 if g_Map_GetPointCount(c
) > 0 then
4527 // still haven't found a spawnpoint, try random shit
4528 Result
:= g_Map_GetRandomPointType();
4531 procedure TPlayer
.Respawn(Silent
: Boolean; Force
: Boolean = False);
4533 RespawnPoint
: TRespawnPoint
;
4541 FBFGFireCounter
:= -1;
4548 if not g_Game_IsServer
then
4552 FWantsInGame
:= True;
4553 FJustTeleported
:= True;
4556 FTime
[T_RESPAWN
] := 0;
4560 // if server changes MaxLives we gotta be ready
4561 if gGameSettings
.MaxLives
= 0 then FNoRespawn
:= False;
4563 // Åùå íåëüçÿ âîçðîäèòüñÿ:
4564 if FTime
[T_RESPAWN
] > gTime
then
4567 // Ïðîñðàë âñå æèçíè:
4570 if not FSpectator
then Spectate(True);
4571 FWantsInGame
:= True;
4575 if (gGameSettings
.GameType
<> GT_SINGLE
) and (gGameSettings
.GameMode
<> GM_COOP
) then
4576 begin // "Ñâîÿ èãðà"
4577 // Áåðñåðê íå ñîõðàíÿåòñÿ ìåæäó óðîâíÿìè:
4578 FRulez
:= FRulez
-[R_BERSERK
];
4580 else // "Îäèíî÷íàÿ èãðà"/"Êîîï"
4582 // Áåðñåðê è êëþ÷è íå ñîõðàíÿþòñÿ ìåæäó óðîâíÿìè:
4583 FRulez
:= FRulez
-[R_KEY_RED
, R_KEY_GREEN
, R_KEY_BLUE
, R_BERSERK
];
4586 // Ïîëó÷àåì òî÷êó ñïàóíà èãðîêà:
4587 c
:= GetRespawnPoint();
4592 // Âîñêðåøåíèå áåç îðóæèÿ:
4595 FHealth
:= Round(PLAYER_HP_SOFT
* (FHandicap
/ 100));
4601 for a
:= WP_FIRST
to WP_LAST
do
4603 FWeapon
[a
] := False;
4607 FWeapon
[WEAPON_PISTOL
] := True;
4608 FWeapon
[WEAPON_KASTET
] := True;
4609 FCurrWeap
:= WEAPON_PISTOL
;
4612 FModel
.SetWeapon(FCurrWeap
);
4614 for b
:= A_BULLETS
to A_HIGH
do
4617 FAmmo
[A_BULLETS
] := 50;
4619 FMaxAmmo
[A_BULLETS
] := AmmoLimits
[0, A_BULLETS
];
4620 FMaxAmmo
[A_SHELLS
] := AmmoLimits
[0, A_SHELLS
];
4621 FMaxAmmo
[A_ROCKETS
] := AmmoLimits
[0, A_SHELLS
];
4622 FMaxAmmo
[A_CELLS
] := AmmoLimits
[0, A_CELLS
];
4623 FMaxAmmo
[A_FUEL
] := AmmoLimits
[0, A_FUEL
];
4625 if (gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
]) and
4626 LongBool(gGameSettings
.Options
and GAME_OPTION_DMKEYS
) then
4627 FRulez
:= [R_KEY_RED
, R_KEY_GREEN
, R_KEY_BLUE
]
4632 // Ïîëó÷àåì êîîðäèíàòû òî÷êè âîçðîæäåíèÿ:
4633 if not g_Map_GetPoint(c
, RespawnPoint
) then
4635 g_FatalError(_lc
[I_GAME_ERROR_GET_SPAWN
]);
4639 // Óñòàíîâêà êîîðäèíàò è ñáðîñ âñåõ ïàðàìåòðîâ:
4640 FObj
.X
:= RespawnPoint
.X
-PLAYER_RECT
.X
;
4641 FObj
.Y
:= RespawnPoint
.Y
-PLAYER_RECT
.Y
;
4642 FObj
.oldX
:= FObj
.X
; // don't interpolate after respawn
4643 FObj
.oldY
:= FObj
.Y
;
4649 FDirection
:= RespawnPoint
.Direction
;
4650 if FDirection
= TDirection
.D_LEFT
then
4655 SetAction(A_STAND
, True);
4656 FModel
.Direction
:= FDirection
;
4658 for a
:= Low(FTime
) to High(FTime
) do
4661 for a
:= Low(FMegaRulez
) to High(FMegaRulez
) do
4664 // Respawn invulnerability
4665 if (gGameSettings
.GameType
<> GT_SINGLE
) and (gGameSettings
.SpawnInvul
> 0) then
4667 FMegaRulez
[MR_INVUL
] := gTime
+ gGameSettings
.SpawnInvul
* 1000;
4668 FSpawnInvul
:= FMegaRulez
[MR_INVUL
];
4673 FCanJetpack
:= False;
4679 // Àíèìàöèÿ âîçðîæäåíèÿ:
4680 if (not gLoadGameMode
) and (not Silent
) then
4681 if g_Frames_Get(ID
, 'FRAMES_TELEPORT') then
4683 Anim
:= TAnimation
.Create(ID
, False, 3);
4684 g_GFX_OnceAnim(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-32,
4685 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)-32, Anim
);
4689 FSpectator
:= False;
4692 FSpectatePlayer
:= -1;
4695 if (gPlayer1
= nil) and (gSpectLatchPID1
= FUID
) then
4697 if (gPlayer2
= nil) and (gSpectLatchPID2
= FUID
) then
4700 if g_Game_IsNet
then
4702 MH_SEND_PlayerPos(True, FUID
, NET_EVERYONE
);
4703 MH_SEND_PlayerStats(FUID
, NET_EVERYONE
);
4705 MH_SEND_Effect(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-32,
4706 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)-32,
4711 procedure TPlayer
.Spectate(NoMove
: Boolean = False);
4714 Kill(K_EXTRAHARDKILL
, FUID
, HIT_SOME
)
4715 else if (not NoMove
) then
4717 GameX
:= gMapInfo
.Width
div 2;
4718 GameY
:= gMapInfo
.Height
div 2;
4727 FWantsInGame
:= False;
4733 if Self
= gPlayer1
then
4735 gSpectLatchPID1
:= FUID
;
4738 else if Self
= gPlayer2
then
4740 gSpectLatchPID2
:= FUID
;
4745 if g_Game_IsNet
then
4746 MH_SEND_PlayerStats(FUID
);
4749 procedure TPlayer
.SwitchNoClip
;
4753 FGhost
:= not FGhost
;
4754 FPhysics
:= not FGhost
;
4766 procedure TPlayer
.Run(Direction
: TDirection
);
4770 if MAX_RUNVEL
> 8 then
4774 if Direction
= TDirection
.D_LEFT
then
4776 if FObj
.Vel
.X
> -MAX_RUNVEL
then
4777 FObj
.Vel
.X
:= FObj
.Vel
.X
- (MAX_RUNVEL
shr 3);
4780 if FObj
.Vel
.X
< MAX_RUNVEL
then
4781 FObj
.Vel
.X
:= FObj
.Vel
.X
+ (MAX_RUNVEL
shr 3);
4783 // Âîçìîæíî, ïèíàåì êóñêè:
4784 if (FObj
.Vel
.X
<> 0) and (gGibs
<> nil) then
4786 b
:= Abs(FObj
.Vel
.X
);
4787 if b
> 1 then b
:= b
* (Random(8 div b
) + 1);
4788 for a
:= 0 to High(gGibs
) do
4790 if gGibs
[a
].alive
and
4791 g_Obj_Collide(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
+FObj
.Rect
.Height
-4,
4792 FObj
.Rect
.Width
, 8, @gGibs
[a
].Obj
) and (Random(3) = 0) then
4795 if FObj
.Vel
.X
< 0 then
4797 g_Obj_PushA(@gGibs
[a
].Obj
, b
, Random(61)+120) // íàëåâî
4801 g_Obj_PushA(@gGibs
[a
].Obj
, b
, Random(61)); // íàïðàâî
4803 gGibs
[a
].positionChanged(); // this updates spatial accelerators
4811 procedure TPlayer
.SeeDown();
4813 SetAction(A_SEEDOWN
);
4815 if FDirection
= TDirection
.D_LEFT
then FAngle
:= ANGLE_LEFTDOWN
else FAngle
:= ANGLE_RIGHTDOWN
;
4817 if FIncCam
> -120 then DecMin(FIncCam
, 5, -120);
4820 procedure TPlayer
.SeeUp();
4824 if FDirection
= TDirection
.D_LEFT
then FAngle
:= ANGLE_LEFTUP
else FAngle
:= ANGLE_RIGHTUP
;
4826 if FIncCam
< 120 then IncMax(FIncCam
, 5, 120);
4829 procedure TPlayer
.SetAction(Action
: Byte; Force
: Boolean = False);
4837 A_ATTACK
: Prior
:= 2;
4838 A_SEEUP
: Prior
:= 1;
4839 A_SEEDOWN
: Prior
:= 1;
4840 A_ATTACKUP
: Prior
:= 2;
4841 A_ATTACKDOWN
: Prior
:= 2;
4846 if (Prior
> FActionPrior
) or Force
then
4847 if not ((Prior
= 2) and (FCurrWeap
= WEAPON_SAW
)) then
4849 FActionPrior
:= Prior
;
4850 FActionAnim
:= Action
;
4851 FActionForce
:= Force
;
4852 FActionChanged
:= True;
4855 if Action
in [A_ATTACK
, A_ATTACKUP
, A_ATTACKDOWN
] then FModel
.SetFire(True);
4858 function TPlayer
.StayOnStep(XInc
, YInc
: Integer): Boolean;
4860 Result
:= not g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+YInc
+PLAYER_RECT
.Y
+PLAYER_RECT
.Height
-1,
4861 PLAYER_RECT
.Width
, 1, PANEL_STEP
, False)
4862 and g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+YInc
+PLAYER_RECT
.Y
+PLAYER_RECT
.Height
,
4863 PLAYER_RECT
.Width
, 1, PANEL_STEP
, False);
4866 function TPlayer
.TeleportTo(X
, Y
: Integer; silent
: Boolean; dir
: Byte): Boolean;
4873 if g_CollideLevel(X
, Y
, PLAYER_RECT
.Width
, PLAYER_RECT
.Height
) then
4875 g_Sound_PlayExAt('SOUND_GAME_NOTELEPORT', FObj
.X
, FObj
.Y
);
4876 if g_Game_IsServer
and g_Game_IsNet
then
4877 MH_SEND_Sound(FObj
.X
, FObj
.Y
, 'SOUND_GAME_NOTELEPORT');
4881 FJustTeleported
:= True;
4886 if g_Frames_Get(ID
, 'FRAMES_TELEPORT') then
4888 Anim
:= TAnimation
.Create(ID
, False, 3);
4891 g_Sound_PlayExAt('SOUND_GAME_TELEPORT', FObj
.X
, FObj
.Y
);
4892 g_GFX_OnceAnim(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-32,
4893 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)-32, Anim
);
4894 if g_Game_IsServer
and g_Game_IsNet
then
4895 MH_SEND_Effect(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-32,
4896 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)-32, 1,
4900 FObj
.X
:= X
-PLAYER_RECT
.X
;
4901 FObj
.Y
:= Y
-PLAYER_RECT
.Y
;
4902 FObj
.oldX
:= FObj
.X
; // don't interpolate after respawn
4903 FObj
.oldY
:= FObj
.Y
;
4904 if FAlive
and FGhost
then
4910 if not g_Game_IsNet
then
4914 SetDirection(TDirection
.D_LEFT
);
4920 SetDirection(TDirection
.D_RIGHT
);
4926 if FDirection
= TDirection
.D_RIGHT
then
4928 SetDirection(TDirection
.D_LEFT
);
4933 SetDirection(TDirection
.D_RIGHT
);
4939 if not silent
and (Anim
<> nil) then
4941 g_GFX_OnceAnim(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-32,
4942 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)-32, Anim
);
4945 if g_Game_IsServer
and g_Game_IsNet
then
4946 MH_SEND_Effect(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-32,
4947 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)-32, 0,
4954 function nonz(a
: Single): Single;
4962 function TPlayer
.refreshCorpse(): Boolean;
4968 if FAlive
or FSpectator
then
4970 if (gCorpses
= nil) or (Length(gCorpses
) = 0) then
4972 for i
:= 0 to High(gCorpses
) do
4973 if gCorpses
[i
] <> nil then
4974 if gCorpses
[i
].FPlayerUID
= FUID
then
4982 function TPlayer
.getCameraObj(): TObj
;
4984 if (not FAlive
) and (not FSpectator
) and
4985 (FCorpse
>= 0) and (FCorpse
< Length(gCorpses
)) and
4986 (gCorpses
[FCorpse
] <> nil) and (gCorpses
[FCorpse
].FPlayerUID
= FUID
) then
4988 gCorpses
[FCorpse
].FObj
.slopeUpLeft
:= FObj
.slopeUpLeft
;
4989 Result
:= gCorpses
[FCorpse
].FObj
;
4997 procedure TPlayer
.PreUpdate();
4999 FSlopeOld
:= FObj
.slopeUpLeft
;
5000 FIncCamOld
:= FIncCam
;
5001 FObj
.oldX
:= FObj
.X
;
5002 FObj
.oldY
:= FObj
.Y
;
5005 procedure TPlayer
.Update();
5008 i
, ii
, wx
, wy
, xd
, yd
, k
: Integer;
5009 blockmon
, headwater
, dospawn
: Boolean;
5014 NetServer
:= g_Game_IsNet
and g_Game_IsServer
;
5015 AnyServer
:= g_Game_IsServer
;
5017 if g_Game_IsClient
and (NetInterpLevel
> 0) then
5018 DoLerp(NetInterpLevel
+ 1)
5024 if FClientID
>= 0 then
5026 FPing
:= NetClients
[FClientID
].Peer
^.lastRoundTripTime
;
5027 if NetClients
[FClientID
].Peer
^.packetsSent
> 0 then
5028 FLoss
:= Round(100*NetClients
[FClientID
].Peer
^.packetsLost
/NetClients
[FClientID
].Peer
^.packetsSent
)
5037 if FAlive
and (FPunchAnim
<> nil) then
5038 FPunchAnim
.Update();
5040 if FAlive
and (gFly
or FJetpack
) then
5043 if FDirection
= TDirection
.D_LEFT
then
5048 if FAlive
and (not FGhost
) then
5050 if FKeys
[KEY_UP
].Pressed
then
5052 if FKeys
[KEY_DOWN
].Pressed
then
5056 if (not (FKeys
[KEY_UP
].Pressed
or FKeys
[KEY_DOWN
].Pressed
)) and
5059 i
:= g_basic
.Sign(FIncCam
);
5060 FIncCam
:= Abs(FIncCam
);
5061 DecMin(FIncCam
, 5, 0);
5062 FIncCam
:= FIncCam
*i
;
5065 // no need to do that each second frame, weapon queue will take care of it
5066 if FAlive
and FKeys
[KEY_NEXTWEAPON
].Pressed
and AnyServer
then NextWeapon();
5067 if FAlive
and FKeys
[KEY_PREVWEAPON
].Pressed
and AnyServer
then PrevWeapon();
5069 if gTime
mod (GAME_TICK
*2) <> 0 then
5071 if (FObj
.Vel
.X
= 0) and FAlive
then
5073 if FKeys
[KEY_LEFT
].Pressed
then
5074 Run(TDirection
.D_LEFT
);
5075 if FKeys
[KEY_RIGHT
].Pressed
then
5076 Run(TDirection
.D_RIGHT
);
5081 g_Obj_Move(@FObj
, True, True, True);
5082 positionChanged(); // this updates spatial accelerators
5088 FActionChanged
:= False;
5092 // Let alive player do some actions
5093 if FKeys
[KEY_LEFT
].Pressed
then Run(TDirection
.D_LEFT
);
5094 if FKeys
[KEY_RIGHT
].Pressed
then Run(TDirection
.D_RIGHT
);
5095 //if FKeys[KEY_NEXTWEAPON].Pressed and AnyServer then NextWeapon();
5096 //if FKeys[KEY_PREVWEAPON].Pressed and AnyServer then PrevWeapon();
5097 if FKeys
[KEY_FIRE
].Pressed
and AnyServer
then Fire()
5103 if NetServer
then MH_SEND_PlayerStats(FUID
);
5106 if FKeys
[KEY_OPEN
].Pressed
and AnyServer
then Use();
5107 if FKeys
[KEY_JUMP
].Pressed
then Jump()
5110 if AnyServer
and FJetpack
then
5114 if NetServer
then MH_SEND_PlayerStats(FUID
);
5116 FCanJetpack
:= True;
5123 for k
:= Low(FKeys
) to KEY_CHAT
-1 do
5125 if FKeys
[k
].Pressed
then
5133 if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
5136 if (FTime
[T_RESPAWN
] <= gTime
) and
5137 gGameOn
and (not FAlive
) then
5139 if (g_Player_GetCount() > 1) then
5143 gExit
:= EXIT_RESTART
;
5148 // Dead spectator actions
5151 if FKeys
[KEY_OPEN
].Pressed
and AnyServer
then Fire();
5152 if FKeys
[KEY_FIRE
].Pressed
and AnyServer
then
5156 if (FSpectatePlayer
>= High(gPlayers
)) then
5157 FSpectatePlayer
:= -1
5161 for I
:= FSpectatePlayer
+ 1 to High(gPlayers
) do
5162 if gPlayers
[I
] <> nil then
5163 if gPlayers
[I
].alive
then
5164 if gPlayers
[I
].UID
<> FUID
then
5166 FSpectatePlayer
:= I
;
5171 if not SetSpect
then FSpectatePlayer
:= -1;
5182 if FKeys
[KEY_UP
].Pressed
or FKeys
[KEY_JUMP
].Pressed
then
5184 FYTo
:= FObj
.Y
- 32;
5185 FSpectatePlayer
:= -1;
5187 if FKeys
[KEY_DOWN
].Pressed
then
5189 FYTo
:= FObj
.Y
+ 32;
5190 FSpectatePlayer
:= -1;
5192 if FKeys
[KEY_LEFT
].Pressed
then
5194 FXTo
:= FObj
.X
- 32;
5195 FSpectatePlayer
:= -1;
5197 if FKeys
[KEY_RIGHT
].Pressed
then
5199 FXTo
:= FObj
.X
+ 32;
5200 FSpectatePlayer
:= -1;
5203 if (FXTo
< -64) then
5205 else if (FXTo
> gMapInfo
.Width
+ 32) then
5206 FXTo
:= gMapInfo
.Width
+ 32;
5207 if (FYTo
< -72) then
5209 else if (FYTo
> gMapInfo
.Height
+ 32) then
5210 FYTo
:= gMapInfo
.Height
+ 32;
5215 g_Obj_Move(@FObj
, True, True, True);
5216 positionChanged(); // this updates spatial accelerators
5223 if (FSpectatePlayer
<= High(gPlayers
)) and (FSpectatePlayer
>= 0) then
5224 if gPlayers
[FSpectatePlayer
] <> nil then
5225 if gPlayers
[FSpectatePlayer
].alive
then
5227 FXTo
:= gPlayers
[FSpectatePlayer
].GameX
;
5228 FYTo
:= gPlayers
[FSpectatePlayer
].GameY
;
5232 blockmon
:= g_Map_CollidePanel(FObj
.X
+PLAYER_HEADRECT
.X
, FObj
.Y
+PLAYER_HEADRECT
.Y
,
5233 PLAYER_HEADRECT
.Width
, PLAYER_HEADRECT
.Height
,
5234 PANEL_BLOCKMON
, True);
5235 headwater
:= HeadInLiquid(0, 0);
5237 // Ñîïðîòèâëåíèå âîçäóõà:
5238 if (not FAlive
) or not (FKeys
[KEY_LEFT
].Pressed
or FKeys
[KEY_RIGHT
].Pressed
) then
5239 if FObj
.Vel
.X
<> 0 then
5240 FObj
.Vel
.X
:= z_dec(FObj
.Vel
.X
, 1);
5242 if (FLastHit
= HIT_TRAP
) and (FPain
> 90) then FPain
:= 90;
5243 DecMin(FPain
, 5, 0);
5244 DecMin(FPickup
, 1, 0);
5246 if FAlive
and (FObj
.Y
> Integer(gMapInfo
.Height
)+128) and AnyServer
then
5248 // Îáíóëèòü äåéñòâèÿ ïðèìî÷åê, ÷òîáû ôîí ïðîïàë
5249 FMegaRulez
[MR_SUIT
] := 0;
5250 FMegaRulez
[MR_INVUL
] := 0;
5251 FMegaRulez
[MR_INVIS
] := 0;
5252 Kill(K_FALLKILL
, 0, HIT_FALL
);
5259 if FCurrWeap
= WEAPON_SAW
then
5260 if not (FSawSound
.IsPlaying() or FSawSoundHit
.IsPlaying() or
5261 FSawSoundSelect
.IsPlaying()) then
5262 FSawSoundIdle
.PlayAt(FObj
.X
, FObj
.Y
);
5265 if (not FJetSoundFly
.IsPlaying()) and (not FJetSoundOn
.IsPlaying()) and
5266 (not FJetSoundOff
.IsPlaying()) then
5268 FJetSoundFly
.SetPosition(0);
5269 FJetSoundFly
.PlayAt(FObj
.X
, FObj
.Y
);
5272 for b
:= WP_FIRST
to WP_LAST
do
5273 if FReloading
[b
] > 0 then
5279 if FShellTimer
> -1 then
5280 if FShellTimer
= 0 then
5282 if FShellType
= SHELL_SHELL
then
5283 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
5284 GameVelX
, GameVelY
-2, SHELL_SHELL
)
5285 else if FShellType
= SHELL_DBLSHELL
then
5287 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
5288 GameVelX
+1, GameVelY
-2, SHELL_SHELL
);
5289 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
5290 GameVelX
-1, GameVelY
-2, SHELL_SHELL
);
5293 end else Dec(FShellTimer
);
5295 if (FBFGFireCounter
> -1) then
5296 if FBFGFireCounter
= 0 then
5300 wx
:= FObj
.X
+WEAPONPOINT
[FDirection
].X
;
5301 wy
:= FObj
.Y
+WEAPONPOINT
[FDirection
].Y
;
5302 xd
:= wx
+IfThen(FDirection
= TDirection
.D_LEFT
, -30, 30);
5303 yd
:= wy
+firediry();
5304 g_Weapon_bfgshot(wx
, wy
, xd
, yd
, FUID
);
5305 if NetServer
then MH_SEND_PlayerFire(FUID
, WEAPON_BFG
, wx
, wy
, xd
, yd
);
5306 if (FAngle
= 0) or (FAngle
= 180) then SetAction(A_ATTACK
)
5307 else if (FAngle
= ANGLE_LEFTDOWN
) or (FAngle
= ANGLE_RIGHTDOWN
) then SetAction(A_ATTACKDOWN
)
5308 else if (FAngle
= ANGLE_LEFTUP
) or (FAngle
= ANGLE_RIGHTUP
) then SetAction(A_ATTACKUP
);
5311 FReloading
[WEAPON_BFG
] := WEAPON_RELOAD
[WEAPON_BFG
];
5312 FBFGFireCounter
:= -1;
5315 FBFGFireCounter
:= 0
5317 Dec(FBFGFireCounter
);
5319 if (FMegaRulez
[MR_SUIT
] < gTime
) and AnyServer
then
5321 b
:= g_GetAcidHit(FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+PLAYER_RECT
.Y
, PLAYER_RECT
.Width
, PLAYER_RECT
.Height
);
5323 if (b
> 0) and (gTime
mod (15*GAME_TICK
) = 0) then Damage(b
, 0, 0, 0, HIT_ACID
);
5326 if (headwater
or blockmon
) then
5332 if AnyServer
then Damage(10, 0, 0, 0, HIT_WATER
);
5335 else if (FAir
mod 31 = 0) and not blockmon
then
5337 g_GFX_Bubbles(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2), FObj
.Y
+PLAYER_RECT
.Y
-4, 5+Random(6), 8, 4);
5338 if Random(2) = 0 then
5339 g_Sound_PlayExAt('SOUND_GAME_BUBBLE1', FObj
.X
, FObj
.Y
)
5341 g_Sound_PlayExAt('SOUND_GAME_BUBBLE2', FObj
.X
, FObj
.Y
);
5343 end else if FAir
< AIR_DEF
then
5346 if FFireTime
> 0 then
5348 if BodyInLiquid(0, 0) then
5353 else if FMegaRulez
[MR_SUIT
] >= gTime
then
5355 if FMegaRulez
[MR_SUIT
] = gTime
then
5362 if FFirePainTime
<= 0 then
5364 if g_Game_IsServer
then
5365 Damage(2, FFireAttacker
, 0, 0, HIT_FLAME
);
5366 FFirePainTime
:= 12 - FFireTime
div 12;
5368 FFirePainTime
:= FFirePainTime
- 1;
5369 FFireTime
:= FFireTime
- 1;
5370 if ((FFireTime
mod 33) = 0) and (FMegaRulez
[MR_INVUL
] < gTime
) then
5371 FModel
.PlaySound(MODELSOUND_PAIN
, 1, FObj
.X
, FObj
.Y
);
5372 if (FFireTime
= 0) and g_Game_IsNet
and g_Game_IsServer
then
5373 MH_SEND_PlayerStats(FUID
);
5377 if FDamageBuffer
> 0 then
5379 if FDamageBuffer
>= 9 then
5383 if FDamageBuffer
< 30 then i
:= 9
5384 else if FDamageBuffer
< 100 then i
:= 18
5388 ii
:= Round(FDamageBuffer
*FHealth
/ nonz(FArmor
*(3/4)+FHealth
));
5389 FArmor
:= FArmor
-(FDamageBuffer
-ii
);
5390 FHealth
:= FHealth
-ii
;
5393 FHealth
:= FHealth
+FArmor
;
5398 if FHealth
<= 0 then
5399 if FHealth
> -30 then Kill(K_SIMPLEKILL
, FLastSpawnerUID
, FLastHit
)
5400 else if FHealth
> -50 then Kill(K_HARDKILL
, FLastSpawnerUID
, FLastHit
)
5401 else Kill(K_EXTRAHARDKILL
, FLastSpawnerUID
, FLastHit
);
5403 if FAlive
and ((FLastHit
<> HIT_FLAME
) or (FFireTime
<= 0)) then
5405 if FDamageBuffer
<= 20 then FModel
.PlaySound(MODELSOUND_PAIN
, 1, FObj
.X
, FObj
.Y
)
5406 else if FDamageBuffer
<= 55 then FModel
.PlaySound(MODELSOUND_PAIN
, 2, FObj
.X
, FObj
.Y
)
5407 else if FDamageBuffer
<= 120 then FModel
.PlaySound(MODELSOUND_PAIN
, 3, FObj
.X
, FObj
.Y
)
5408 else FModel
.PlaySound(MODELSOUND_PAIN
, 4, FObj
.X
, FObj
.Y
);
5415 end; // if FAlive then ...
5417 if (FActionAnim
= A_PAIN
) and (FModel
.Animation
<> A_PAIN
) then
5419 FModel
.ChangeAnimation(FActionAnim
, FActionForce
);
5420 FModel
.GetCurrentAnimation
.MinLength
:= i
;
5421 FModel
.GetCurrentAnimationMask
.MinLength
:= i
;
5422 end else FModel
.ChangeAnimation(FActionAnim
, FActionForce
and (FModel
.Animation
<> A_STAND
));
5424 if (FModel
.GetCurrentAnimation
.Played
or ((not FActionChanged
) and (FModel
.Animation
= A_WALK
)))
5425 then SetAction(A_STAND
, True);
5427 if not ((FModel
.Animation
= A_WALK
) and (Abs(FObj
.Vel
.X
) < 4) and not FModel
.Fire
) then FModel
.Update
;
5429 for b
:= Low(FKeys
) to High(FKeys
) do
5430 if FKeys
[b
].Time
= 0 then FKeys
[b
].Pressed
:= False else Dec(FKeys
[b
].Time
);
5434 procedure TPlayer
.getMapBox (out x
, y
, w
, h
: Integer); inline;
5436 x
:= FObj
.X
+PLAYER_RECT
.X
;
5437 y
:= FObj
.Y
+PLAYER_RECT
.Y
;
5438 w
:= PLAYER_RECT
.Width
;
5439 h
:= PLAYER_RECT
.Height
;
5443 procedure TPlayer
.moveBy (dx
, dy
: Integer); inline;
5445 if (dx
<> 0) or (dy
<> 0) then
5454 function TPlayer
.Collide(X
, Y
: Integer; Width
, Height
: Word): Boolean;
5456 Result
:= g_Collide(FObj
.X
+PLAYER_RECT
.X
,
5457 FObj
.Y
+PLAYER_RECT
.Y
,
5464 function TPlayer
.Collide(Panel
: TPanel
): Boolean;
5466 Result
:= g_Collide(FObj
.X
+PLAYER_RECT
.X
,
5467 FObj
.Y
+PLAYER_RECT
.Y
,
5471 Panel
.Width
, Panel
.Height
);
5474 function TPlayer
.Collide(X
, Y
: Integer): Boolean;
5476 X
:= X
-FObj
.X
-PLAYER_RECT
.X
;
5477 Y
:= Y
-FObj
.Y
-PLAYER_RECT
.Y
;
5478 Result
:= (x
>= 0) and (x
<= PLAYER_RECT
.Width
) and
5479 (y
>= 0) and (y
<= PLAYER_RECT
.Height
);
5482 function g_Player_ValidName(Name
: string): Boolean;
5488 if gPlayers
= nil then Exit
;
5490 for a
:= 0 to High(gPlayers
) do
5491 if gPlayers
[a
] <> nil then
5492 if LowerCase(Name
) = LowerCase(gPlayers
[a
].FName
) then
5499 procedure TPlayer
.SetDirection(Direction
: TDirection
);
5503 d
:= FModel
.Direction
;
5505 FModel
.Direction
:= Direction
;
5506 if d
<> Direction
then FModel
.ChangeAnimation(FModel
.Animation
, True);
5508 FDirection
:= Direction
;
5511 function TPlayer
.GetKeys(): Byte;
5515 if R_KEY_RED
in FRulez
then Result
:= KEY_RED
;
5516 if R_KEY_GREEN
in FRulez
then Result
:= Result
or KEY_GREEN
;
5517 if R_KEY_BLUE
in FRulez
then Result
:= Result
or KEY_BLUE
;
5519 if FTeam
= TEAM_RED
then Result
:= Result
or KEY_REDTEAM
;
5520 if FTeam
= TEAM_BLUE
then Result
:= Result
or KEY_BLUETEAM
;
5523 procedure TPlayer
.Use();
5527 if FTime
[T_USE
] > gTime
then Exit
;
5529 g_Triggers_PressR(FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+PLAYER_RECT
.Y
, PLAYER_RECT
.Width
,
5530 PLAYER_RECT
.Height
, FUID
, ACTIVATE_PLAYERPRESS
);
5532 for a
:= 0 to High(gPlayers
) do
5533 if (gPlayers
[a
] <> nil) and (gPlayers
[a
] <> Self
) and
5534 gPlayers
[a
].alive
and SameTeam(FUID
, gPlayers
[a
].FUID
) and
5535 g_Obj_Collide(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
,
5536 FObj
.Rect
.Width
, FObj
.Rect
.Height
, @gPlayers
[a
].FObj
) then
5538 gPlayers
[a
].Touch();
5539 if g_Game_IsNet
and g_Game_IsServer
then
5540 MH_SEND_GameEvent(NET_EV_PLAYER_TOUCH
, gPlayers
[a
].FUID
);
5543 FTime
[T_USE
] := gTime
+120;
5546 procedure TPlayer
.NetFire(Wpn
: Byte; X
, Y
, AX
, AY
: Integer; WID
: Integer = -1);
5550 WX
, WY
, XD
, YD
: Integer;
5562 if R_BERSERK
in FRulez
then
5564 //g_Weapon_punch(FObj.X+FObj.Rect.X, FObj.Y+FObj.Rect.Y, 75, FUID);
5565 locobj
.X
:= FObj
.X
+FObj
.Rect
.X
;
5566 locobj
.Y
:= FObj
.Y
+FObj
.Rect
.Y
;
5569 locobj
.rect
.Width
:= 39;
5570 locobj
.rect
.Height
:= 52;
5571 locobj
.Vel
.X
:= (xd
-wx
) div 2;
5572 locobj
.Vel
.Y
:= (yd
-wy
) div 2;
5573 locobj
.Accel
.X
:= xd
-wx
;
5574 locobj
.Accel
.y
:= yd
-wy
;
5576 if g_Weapon_Hit(@locobj
, 50, FUID
, HIT_SOME
) <> 0 then
5577 g_Sound_PlayExAt('SOUND_WEAPON_HITBERSERK', FObj
.X
, FObj
.Y
)
5579 g_Sound_PlayExAt('SOUND_WEAPON_MISSBERSERK', FObj
.X
, FObj
.Y
);
5583 FPain
:= min(FPain
+ 25, 50);
5585 g_Weapon_punch(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
, 3, FUID
);
5590 if g_Weapon_chainsaw(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
,
5591 IfThen(gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
], 9, 3), FUID
) <> 0 then
5593 FSawSoundSelect
.Stop();
5595 FSawSoundHit
.PlayAt(FObj
.X
, FObj
.Y
);
5597 else if not FSawSoundHit
.IsPlaying() then
5599 FSawSoundSelect
.Stop();
5600 FSawSound
.PlayAt(FObj
.X
, FObj
.Y
);
5607 g_Sound_PlayExAt('SOUND_WEAPON_FIREPISTOL', GameX
, Gamey
);
5608 FFireAngle
:= FAngle
;
5610 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
5611 GameVelX
, GameVelY
-2, SHELL_BULLET
);
5616 g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN', Gamex
, Gamey
);
5617 FFireAngle
:= FAngle
;
5620 FShellType
:= SHELL_SHELL
;
5625 g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN2', Gamex
, Gamey
);
5626 FFireAngle
:= FAngle
;
5629 FShellType
:= SHELL_DBLSHELL
;
5634 g_Sound_PlayExAt('SOUND_WEAPON_FIRECGUN', Gamex
, Gamey
);
5635 FFireAngle
:= FAngle
;
5637 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
5638 GameVelX
, GameVelY
-2, SHELL_BULLET
);
5641 WEAPON_ROCKETLAUNCHER
:
5643 g_Weapon_Rocket(wx
, wy
, xd
, yd
, FUID
, WID
);
5644 FFireAngle
:= FAngle
;
5650 g_Weapon_Plasma(wx
, wy
, xd
, yd
, FUID
, WID
);
5651 FFireAngle
:= FAngle
;
5657 g_Weapon_BFGShot(wx
, wy
, xd
, yd
, FUID
, WID
);
5658 FFireAngle
:= FAngle
;
5662 WEAPON_SUPERPULEMET
:
5664 g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN', Gamex
, Gamey
);
5665 FFireAngle
:= FAngle
;
5667 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
5668 GameVelX
, GameVelY
-2, SHELL_SHELL
);
5671 WEAPON_FLAMETHROWER
:
5673 g_Weapon_flame(wx
, wy
, xd
, yd
, FUID
, WID
);
5675 FFireAngle
:= FAngle
;
5682 if (FAngle
= 0) or (FAngle
= 180) then SetAction(A_ATTACK
)
5683 else if (FAngle
= ANGLE_LEFTDOWN
) or (FAngle
= ANGLE_RIGHTDOWN
) then SetAction(A_ATTACKDOWN
)
5684 else if (FAngle
= ANGLE_LEFTUP
) or (FAngle
= ANGLE_RIGHTUP
) then SetAction(A_ATTACKUP
);
5687 procedure TPlayer
.DoLerp(Level
: Integer = 2);
5689 if FObj
.X
<> FXTo
then FObj
.X
:= Lerp(FObj
.X
, FXTo
, Level
);
5690 if FObj
.Y
<> FYTo
then FObj
.Y
:= Lerp(FObj
.Y
, FYTo
, Level
);
5693 procedure TPlayer
.SetLerp(XTo
, YTo
: Integer);
5699 if FJustTeleported
or (NetInterpLevel
< 1) then
5703 if FJustTeleported
then
5705 FObj
.oldX
:= FObj
.X
;
5706 FObj
.oldY
:= FObj
.Y
;
5711 AX
:= Abs(FXTo
- FObj
.X
);
5712 AY
:= Abs(FYTo
- FObj
.Y
);
5713 if (AX
> 32) or (AX
<= NetInterpLevel
) then
5715 if (AY
> 32) or (AY
<= NetInterpLevel
) then
5720 function TPlayer
.FullInLift(XInc
, YInc
: Integer): Integer;
5722 if g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
,
5723 PLAYER_RECT
.Width
, PLAYER_RECT
.Height
-8,
5724 PANEL_LIFTUP
, False) then Result
:= -1
5726 if g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
,
5727 PLAYER_RECT
.Width
, PLAYER_RECT
.Height
-8,
5728 PANEL_LIFTDOWN
, False) then Result
:= 1
5732 function TPlayer
.GetFlag(Flag
: Byte): Boolean;
5739 if Flag
= FLAG_NONE
then
5742 if not g_Game_IsServer
then Exit
;
5744 // Ïðèíåñ ÷óæîé ôëàã íà ñâîþ áàçó:
5745 if (Flag
= FTeam
) and
5746 (gFlags
[Flag
].State
= FLAG_STATE_NORMAL
) and
5747 (FFlag
<> FLAG_NONE
) then
5749 if FFlag
= FLAG_RED
then
5750 s
:= _lc
[I_PLAYER_FLAG_RED
]
5752 s
:= _lc
[I_PLAYER_FLAG_BLUE
];
5754 evtype
:= FLAG_STATE_SCORED
;
5756 ts
:= Format('%.4d', [gFlags
[FFlag
].CaptureTime
]);
5757 Insert('.', ts
, Length(ts
) + 1 - 3);
5758 g_Console_Add(Format(_lc
[I_PLAYER_FLAG_CAPTURE
], [FName
, s
, ts
]), True);
5760 g_Map_ResetFlag(FFlag
);
5761 g_Game_Message(Format(_lc
[I_MESSAGE_FLAG_CAPTURE
], [AnsiUpperCase(s
)]), 144);
5763 if ((Self
= gPlayer1
) or (Self
= gPlayer2
)
5764 or ((gPlayer1
<> nil) and (gPlayer1
.Team
= FTeam
))
5765 or ((gPlayer2
<> nil) and (gPlayer2
.Team
= FTeam
))) then
5770 if not sound_cap_flag
[a
].IsPlaying() then
5771 sound_cap_flag
[a
].Play();
5773 gTeamStat
[FTeam
].Goals
:= gTeamStat
[FTeam
].Goals
+ 1;
5776 if g_Game_IsNet
then
5778 MH_SEND_FlagEvent(evtype
, FFlag
, FUID
, False);
5782 gFlags
[FFlag
].CaptureTime
:= 0;
5787 // Ïîäîáðàë ñâîé ôëàã - âåðíóë åãî íà áàçó:
5788 if (Flag
= FTeam
) and
5789 (gFlags
[Flag
].State
= FLAG_STATE_DROPPED
) then
5791 if Flag
= FLAG_RED
then
5792 s
:= _lc
[I_PLAYER_FLAG_RED
]
5794 s
:= _lc
[I_PLAYER_FLAG_BLUE
];
5796 evtype
:= FLAG_STATE_RETURNED
;
5797 gFlags
[Flag
].CaptureTime
:= 0;
5799 g_Console_Add(Format(_lc
[I_PLAYER_FLAG_RETURN
], [FName
, s
]), True);
5801 g_Map_ResetFlag(Flag
);
5802 g_Game_Message(Format(_lc
[I_MESSAGE_FLAG_RETURN
], [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_ret_flag
[a
].IsPlaying() then
5812 sound_ret_flag
[a
].Play();
5815 if g_Game_IsNet
then
5817 MH_SEND_FlagEvent(evtype
, Flag
, FUID
, False);
5823 // Ïîäîáðàë ÷óæîé ôëàã:
5824 if (Flag
<> FTeam
) and (FTime
[T_FLAGCAP
] <= gTime
) then
5828 if Flag
= FLAG_RED
then
5829 s
:= _lc
[I_PLAYER_FLAG_RED
]
5831 s
:= _lc
[I_PLAYER_FLAG_BLUE
];
5833 evtype
:= FLAG_STATE_CAPTURED
;
5835 g_Console_Add(Format(_lc
[I_PLAYER_FLAG_GET
], [FName
, s
]), True);
5837 g_Game_Message(Format(_lc
[I_MESSAGE_FLAG_GET
], [AnsiUpperCase(s
)]), 144);
5839 gFlags
[Flag
].State
:= FLAG_STATE_CAPTURED
;
5841 if ((Self
= gPlayer1
) or (Self
= gPlayer2
)
5842 or ((gPlayer1
<> nil) and (gPlayer1
.Team
= FTeam
))
5843 or ((gPlayer2
<> nil) and (gPlayer2
.Team
= FTeam
))) then
5848 if not sound_get_flag
[a
].IsPlaying() then
5849 sound_get_flag
[a
].Play();
5852 if g_Game_IsNet
then
5854 MH_SEND_FlagEvent(evtype
, Flag
, FUID
, False);
5860 procedure TPlayer
.SetFlag(Flag
: Byte);
5863 if FModel
<> nil then
5864 FModel
.SetFlag(FFlag
);
5867 function TPlayer
.DropFlag(Silent
: Boolean = True): Boolean;
5873 if (not g_Game_IsServer
) or (FFlag
= FLAG_NONE
) then
5875 FTime
[T_FLAGCAP
] := gTime
+ 2000;
5876 with gFlags
[FFlag
] do
5880 Direction
:= FDirection
;
5881 State
:= FLAG_STATE_DROPPED
;
5883 g_Obj_Push(@Obj
, (FObj
.Vel
.X
div 2)-2+Random(5),
5884 (FObj
.Vel
.Y
div 2)-2+Random(5));
5885 positionChanged(); // this updates spatial accelerators
5887 if FFlag
= FLAG_RED
then
5888 s
:= _lc
[I_PLAYER_FLAG_RED
]
5890 s
:= _lc
[I_PLAYER_FLAG_BLUE
];
5892 g_Console_Add(Format(_lc
[I_PLAYER_FLAG_DROP
], [FName
, s
]), True);
5893 g_Game_Message(Format(_lc
[I_MESSAGE_FLAG_DROP
], [AnsiUpperCase(s
)]), 144);
5895 if ((Self
= gPlayer1
) or (Self
= gPlayer2
)
5896 or ((gPlayer1
<> nil) and (gPlayer1
.Team
= FTeam
))
5897 or ((gPlayer2
<> nil) and (gPlayer2
.Team
= FTeam
))) then
5902 if (not Silent
) and (not sound_lost_flag
[a
].IsPlaying()) then
5903 sound_lost_flag
[a
].Play();
5905 if g_Game_IsNet
then
5906 MH_SEND_FlagEvent(FLAG_STATE_DROPPED
, Flag
, FUID
, False);
5912 procedure TPlayer
.GetSecret();
5914 if (self
= gPlayer1
) or (self
= gPlayer2
) then
5916 g_Console_Add(Format(_lc
[I_PLAYER_SECRET
], [FName
]), True);
5917 g_Sound_PlayEx('SOUND_GAME_SECRET');
5922 procedure TPlayer
.PressKey(Key
: Byte; Time
: Word = 1);
5924 Assert(Key
<= High(FKeys
));
5926 FKeys
[Key
].Pressed
:= True;
5927 FKeys
[Key
].Time
:= Time
;
5930 function TPlayer
.IsKeyPressed(K
: Byte): Boolean;
5932 Result
:= FKeys
[K
].Pressed
;
5935 procedure TPlayer
.ReleaseKeys();
5939 for a
:= Low(FKeys
) to High(FKeys
) do
5941 FKeys
[a
].Pressed
:= False;
5946 procedure TPlayer
.OnDamage(Angle
: SmallInt);
5950 function TPlayer
.firediry(): Integer;
5952 if FKeys
[KEY_UP
].Pressed
then Result
:= -42
5953 else if FKeys
[KEY_DOWN
].Pressed
then Result
:= 19
5957 procedure TPlayer
.RememberState();
5960 SavedState
: TPlayerSavedState
;
5962 SavedState
.Health
:= FHealth
;
5963 SavedState
.Armor
:= FArmor
;
5964 SavedState
.Air
:= FAir
;
5965 SavedState
.JetFuel
:= FJetFuel
;
5966 SavedState
.CurrWeap
:= FCurrWeap
;
5967 SavedState
.NextWeap
:= FNextWeap
;
5968 SavedState
.NextWeapDelay
:= FNextWeapDelay
;
5969 for i
:= Low(FWeapon
) to High(FWeapon
) do
5970 SavedState
.Weapon
[i
] := FWeapon
[i
];
5971 for i
:= Low(FAmmo
) to High(FAmmo
) do
5972 SavedState
.Ammo
[i
] := FAmmo
[i
];
5973 for i
:= Low(FMaxAmmo
) to High(FMaxAmmo
) do
5974 SavedState
.MaxAmmo
[i
] := FMaxAmmo
[i
];
5975 SavedState
.Rulez
:= FRulez
- [R_KEY_RED
, R_KEY_GREEN
, R_KEY_BLUE
];
5977 FSavedStateNum
:= -1;
5978 for i
:= Low(SavedStates
) to High(SavedStates
) do
5979 if not SavedStates
[i
].Used
then
5981 FSavedStateNum
:= i
;
5984 if FSavedStateNum
< 0 then
5986 SetLength(SavedStates
, Length(SavedStates
) + 1);
5987 FSavedStateNum
:= High(SavedStates
);
5990 SavedState
.Used
:= True;
5991 SavedStates
[FSavedStateNum
] := SavedState
;
5994 procedure TPlayer
.RecallState();
5997 SavedState
: TPlayerSavedState
;
5999 if(FSavedStateNum
< 0) or (FSavedStateNum
> High(SavedStates
)) then
6002 SavedState
:= SavedStates
[FSavedStateNum
];
6003 SavedStates
[FSavedStateNum
].Used
:= False;
6004 FSavedStateNum
:= -1;
6006 FHealth
:= SavedState
.Health
;
6007 FArmor
:= SavedState
.Armor
;
6008 FAir
:= SavedState
.Air
;
6009 FJetFuel
:= SavedState
.JetFuel
;
6010 FCurrWeap
:= SavedState
.CurrWeap
;
6011 FNextWeap
:= SavedState
.NextWeap
;
6012 FNextWeapDelay
:= SavedState
.NextWeapDelay
;
6013 for i
:= Low(FWeapon
) to High(FWeapon
) do
6014 FWeapon
[i
] := SavedState
.Weapon
[i
];
6015 for i
:= Low(FAmmo
) to High(FAmmo
) do
6016 FAmmo
[i
] := SavedState
.Ammo
[i
];
6017 for i
:= Low(FMaxAmmo
) to High(FMaxAmmo
) do
6018 FMaxAmmo
[i
] := SavedState
.MaxAmmo
[i
];
6019 FRulez
:= SavedState
.Rulez
;
6021 if gGameSettings
.GameType
= GT_SERVER
then
6022 MH_SEND_PlayerStats(FUID
);
6025 procedure TPlayer
.SaveState (st
: TStream
);
6031 utils
.writeSign(st
, 'PLYR');
6032 utils
.writeInt(st
, Byte(PLR_SAVE_VERSION
)); // version
6034 utils
.writeBool(st
, FIamBot
);
6036 utils
.writeInt(st
, Word(FUID
));
6038 utils
.writeStr(st
, FName
);
6040 utils
.writeInt(st
, Byte(FTeam
));
6042 utils
.writeBool(st
, FAlive
);
6043 // Èçðàñõîäîâàë ëè âñå æèçíè
6044 utils
.writeBool(st
, FNoRespawn
);
6046 if FDirection
= TDirection
.D_LEFT
then b
:= 1 else b
:= 2; // D_RIGHT
6047 utils
.writeInt(st
, Byte(b
));
6049 utils
.writeInt(st
, LongInt(FHealth
));
6050 // Êîýôôèöèåíò èíâàëèäíîñòè
6051 utils
.writeInt(st
, LongInt(FHandicap
));
6053 utils
.writeInt(st
, Byte(FLives
));
6055 utils
.writeInt(st
, LongInt(FArmor
));
6057 utils
.writeInt(st
, LongInt(FAir
));
6059 utils
.writeInt(st
, LongInt(FJetFuel
));
6061 utils
.writeInt(st
, LongInt(FPain
));
6063 utils
.writeInt(st
, LongInt(FKills
));
6065 utils
.writeInt(st
, LongInt(FMonsterKills
));
6067 utils
.writeInt(st
, LongInt(FFrags
));
6069 utils
.writeInt(st
, Byte(FFragCombo
));
6070 // Âðåìÿ ïîñëåäíåãî ôðàãà
6071 utils
.writeInt(st
, LongWord(FLastFrag
));
6073 utils
.writeInt(st
, LongInt(FDeath
));
6075 utils
.writeInt(st
, Byte(FFlag
));
6077 utils
.writeInt(st
, LongInt(FSecrets
));
6079 utils
.writeInt(st
, Byte(FCurrWeap
));
6081 utils
.writeInt(st
, Word(FNextWeap
));
6083 utils
.writeInt(st
, Byte(FNextWeapDelay
));
6084 // Âðåìÿ çàðÿäêè BFG
6085 utils
.writeInt(st
, SmallInt(FBFGFireCounter
));
6087 utils
.writeInt(st
, LongInt(FDamageBuffer
));
6088 // Ïîñëåäíèé óäàðèâøèé
6089 utils
.writeInt(st
, Word(FLastSpawnerUID
));
6090 // Òèï ïîñëåäíåãî ïîëó÷åííîãî óðîíà
6091 utils
.writeInt(st
, Byte(FLastHit
));
6093 Obj_SaveState(st
, @FObj
);
6094 // Òåêóùåå êîëè÷åñòâî ïàòðîíîâ
6095 for i
:= A_BULLETS
to A_HIGH
do utils
.writeInt(st
, Word(FAmmo
[i
]));
6096 // Ìàêñèìàëüíîå êîëè÷åñòâî ïàòðîíîâ
6097 for i
:= A_BULLETS
to A_HIGH
do utils
.writeInt(st
, Word(FMaxAmmo
[i
]));
6099 for i
:= WP_FIRST
to WP_LAST
do utils
.writeBool(st
, FWeapon
[i
]);
6100 // Âðåìÿ ïåðåçàðÿäêè îðóæèÿ
6101 for i
:= WP_FIRST
to WP_LAST
do utils
.writeInt(st
, Word(FReloading
[i
]));
6103 utils
.writeBool(st
, (R_ITEM_BACKPACK
in FRulez
));
6104 // Íàëè÷èå êðàñíîãî êëþ÷à
6105 utils
.writeBool(st
, (R_KEY_RED
in FRulez
));
6106 // Íàëè÷èå çåëåíîãî êëþ÷à
6107 utils
.writeBool(st
, (R_KEY_GREEN
in FRulez
));
6108 // Íàëè÷èå ñèíåãî êëþ÷à
6109 utils
.writeBool(st
, (R_KEY_BLUE
in FRulez
));
6111 utils
.writeBool(st
, (R_BERSERK
in FRulez
));
6112 // Âðåìÿ äåéñòâèÿ ñïåöèàëüíûõ ïðåäìåòîâ
6113 for i
:= MR_SUIT
to MR_MAX
do utils
.writeInt(st
, LongWord(FMegaRulez
[i
]));
6114 // Âðåìÿ äî ïîâòîðíîãî ðåñïàóíà, ñìåíû îðóæèÿ, èñîëüçîâàíèÿ, çàõâàòà ôëàãà
6115 for i
:= T_RESPAWN
to T_FLAGCAP
do utils
.writeInt(st
, LongWord(FTime
[i
]));
6117 utils
.writeStr(st
, FModel
.Name
);
6119 utils
.writeInt(st
, Byte(FColor
.R
));
6120 utils
.writeInt(st
, Byte(FColor
.G
));
6121 utils
.writeInt(st
, Byte(FColor
.B
));
6125 procedure TPlayer
.LoadState (st
: TStream
);
6134 if not utils
.checkSign(st
, 'PLYR') then raise XStreamError
.Create('invalid player signature');
6135 if (utils
.readByte(st
) <> PLR_SAVE_VERSION
) then raise XStreamError
.Create('invalid player version');
6137 FIamBot
:= utils
.readBool(st
);
6139 FUID
:= utils
.readWord(st
);
6141 str
:= utils
.readStr(st
);
6142 if (self
<> gPlayer1
) and (self
<> gPlayer2
) then FName
:= str
;
6144 FTeam
:= utils
.readByte(st
);
6146 FAlive
:= utils
.readBool(st
);
6147 // Èçðàñõîäîâàë ëè âñå æèçíè
6148 FNoRespawn
:= utils
.readBool(st
);
6150 b
:= utils
.readByte(st
);
6151 if b
= 1 then FDirection
:= TDirection
.D_LEFT
else FDirection
:= TDirection
.D_RIGHT
; // b = 2
6153 FHealth
:= utils
.readLongInt(st
);
6154 // Êîýôôèöèåíò èíâàëèäíîñòè
6155 FHandicap
:= utils
.readLongInt(st
);
6157 FLives
:= utils
.readByte(st
);
6159 FArmor
:= utils
.readLongInt(st
);
6161 FAir
:= utils
.readLongInt(st
);
6163 FJetFuel
:= utils
.readLongInt(st
);
6165 FPain
:= utils
.readLongInt(st
);
6167 FKills
:= utils
.readLongInt(st
);
6169 FMonsterKills
:= utils
.readLongInt(st
);
6171 FFrags
:= utils
.readLongInt(st
);
6173 FFragCombo
:= utils
.readByte(st
);
6174 // Âðåìÿ ïîñëåäíåãî ôðàãà
6175 FLastFrag
:= utils
.readLongWord(st
);
6177 FDeath
:= utils
.readLongInt(st
);
6179 FFlag
:= utils
.readByte(st
);
6181 FSecrets
:= utils
.readLongInt(st
);
6183 FCurrWeap
:= utils
.readByte(st
);
6185 FNextWeap
:= utils
.readWord(st
);
6187 FNextWeapDelay
:= utils
.readByte(st
);
6188 // Âðåìÿ çàðÿäêè BFG
6189 FBFGFireCounter
:= utils
.readSmallInt(st
);
6191 FDamageBuffer
:= utils
.readLongInt(st
);
6192 // Ïîñëåäíèé óäàðèâøèé
6193 FLastSpawnerUID
:= utils
.readWord(st
);
6194 // Òèï ïîñëåäíåãî ïîëó÷åííîãî óðîíà
6195 FLastHit
:= utils
.readByte(st
);
6197 Obj_LoadState(@FObj
, st
);
6198 // Òåêóùåå êîëè÷åñòâî ïàòðîíîâ
6199 for i
:= A_BULLETS
to A_HIGH
do FAmmo
[i
] := utils
.readWord(st
);
6200 // Ìàêñèìàëüíîå êîëè÷åñòâî ïàòðîíîâ
6201 for i
:= A_BULLETS
to A_HIGH
do FMaxAmmo
[i
] := utils
.readWord(st
);
6203 for i
:= WP_FIRST
to WP_LAST
do FWeapon
[i
] := utils
.readBool(st
);
6204 // Âðåìÿ ïåðåçàðÿäêè îðóæèÿ
6205 for i
:= WP_FIRST
to WP_LAST
do FReloading
[i
] := utils
.readWord(st
);
6207 if utils
.readBool(st
) then Include(FRulez
, R_ITEM_BACKPACK
);
6208 // Íàëè÷èå êðàñíîãî êëþ÷à
6209 if utils
.readBool(st
) then Include(FRulez
, R_KEY_RED
);
6210 // Íàëè÷èå çåëåíîãî êëþ÷à
6211 if utils
.readBool(st
) then Include(FRulez
, R_KEY_GREEN
);
6212 // Íàëè÷èå ñèíåãî êëþ÷à
6213 if utils
.readBool(st
) then Include(FRulez
, R_KEY_BLUE
);
6215 if utils
.readBool(st
) then Include(FRulez
, R_BERSERK
);
6216 // Âðåìÿ äåéñòâèÿ ñïåöèàëüíûõ ïðåäìåòîâ
6217 for i
:= MR_SUIT
to MR_MAX
do FMegaRulez
[i
] := utils
.readLongWord(st
);
6218 // Âðåìÿ äî ïîâòîðíîãî ðåñïàóíà, ñìåíû îðóæèÿ, èñîëüçîâàíèÿ, çàõâàòà ôëàãà
6219 for i
:= T_RESPAWN
to T_FLAGCAP
do FTime
[i
] := utils
.readLongWord(st
);
6221 str
:= utils
.readStr(st
);
6223 FColor
.R
:= utils
.readByte(st
);
6224 FColor
.G
:= utils
.readByte(st
);
6225 FColor
.B
:= utils
.readByte(st
);
6226 if (self
= gPlayer1
) then
6228 str
:= gPlayer1Settings
.Model
;
6229 FColor
:= gPlayer1Settings
.Color
;
6231 else if (self
= gPlayer2
) then
6233 str
:= gPlayer2Settings
.Model
;
6234 FColor
:= gPlayer2Settings
.Color
;
6236 // Îáíîâëÿåì ìîäåëü èãðîêà
6238 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
6239 FModel
.Color
:= TEAMCOLOR
[FTeam
]
6241 FModel
.Color
:= FColor
;
6245 procedure TPlayer
.AllRulez(Health
: Boolean);
6251 FHealth
:= PLAYER_HP_LIMIT
;
6252 FArmor
:= PLAYER_AP_LIMIT
;
6256 for a
:= WP_FIRST
to WP_LAST
do FWeapon
[a
] := True;
6257 for a
:= A_BULLETS
to A_HIGH
do FAmmo
[a
] := 30000;
6258 FRulez
:= FRulez
+[R_KEY_RED
, R_KEY_GREEN
, R_KEY_BLUE
];
6261 procedure TPlayer
.RestoreHealthArmor();
6263 FHealth
:= PLAYER_HP_LIMIT
;
6264 FArmor
:= PLAYER_AP_LIMIT
;
6267 procedure TPlayer
.FragCombo();
6271 if (gGameSettings
.GameMode
in [GM_COOP
, GM_SINGLE
]) or g_Game_IsClient
then
6273 if gTime
- FLastFrag
< FRAG_COMBO_TIME
then
6275 if FFragCombo
< 5 then
6277 Param
:= FUID
or (FFragCombo
shl 16);
6278 if (FComboEvnt
>= Low(gDelayedEvents
)) and
6279 (FComboEvnt
<= High(gDelayedEvents
)) and
6280 gDelayedEvents
[FComboEvnt
].Pending
and
6281 (gDelayedEvents
[FComboEvnt
].DEType
= DE_KILLCOMBO
) and
6282 (gDelayedEvents
[FComboEvnt
].DENum
and $FFFF = FUID
) then
6284 gDelayedEvents
[FComboEvnt
].Time
:= gTime
+ 500;
6285 gDelayedEvents
[FComboEvnt
].DENum
:= Param
;
6288 FComboEvnt
:= g_Game_DelayEvent(DE_KILLCOMBO
, 500, Param
);
6296 procedure TPlayer
.GiveItem(ItemType
: Byte);
6300 if FMegaRulez
[MR_SUIT
] < gTime
+PLAYER_SUIT_TIME
then
6302 FMegaRulez
[MR_SUIT
] := gTime
+PLAYER_SUIT_TIME
;
6306 if FAir
< AIR_MAX
then
6313 if not (R_BERSERK
in FRulez
) then
6315 Include(FRulez
, R_BERSERK
);
6316 if FBFGFireCounter
< 1 then
6318 FCurrWeap
:= WEAPON_KASTET
;
6320 FModel
.SetWeapon(WEAPON_KASTET
);
6324 FBerserk
:= gTime
+30000;
6326 if FHealth
< PLAYER_HP_SOFT
then
6328 FHealth
:= PLAYER_HP_SOFT
;
6329 FBerserk
:= gTime
+30000;
6334 if FMegaRulez
[MR_INVUL
] < gTime
+PLAYER_INVUL_TIME
then
6336 FMegaRulez
[MR_INVUL
] := gTime
+PLAYER_INVUL_TIME
;
6341 if FMegaRulez
[MR_INVIS
] < gTime
+PLAYER_INVIS_TIME
then
6343 FMegaRulez
[MR_INVIS
] := gTime
+PLAYER_INVIS_TIME
;
6347 if FJetFuel
< JET_MAX
then
6349 FJetFuel
:= JET_MAX
;
6352 ITEM_MEDKIT_SMALL
: if FHealth
< PLAYER_HP_SOFT
then IncMax(FHealth
, 10, PLAYER_HP_SOFT
);
6353 ITEM_MEDKIT_LARGE
: if FHealth
< PLAYER_HP_SOFT
then IncMax(FHealth
, 25, PLAYER_HP_SOFT
);
6355 ITEM_ARMOR_GREEN
: if FArmor
< PLAYER_AP_SOFT
then FArmor
:= PLAYER_AP_SOFT
;
6356 ITEM_ARMOR_BLUE
: if FArmor
< PLAYER_AP_LIMIT
then FArmor
:= PLAYER_AP_LIMIT
;
6358 ITEM_SPHERE_BLUE
: if FHealth
< PLAYER_HP_LIMIT
then IncMax(FHealth
, 100, PLAYER_HP_LIMIT
);
6360 if (FHealth
< PLAYER_HP_LIMIT
) or (FArmor
< PLAYER_AP_LIMIT
) then
6362 if FHealth
< PLAYER_HP_LIMIT
then FHealth
:= PLAYER_HP_LIMIT
;
6363 if FArmor
< PLAYER_AP_LIMIT
then FArmor
:= PLAYER_AP_LIMIT
;
6366 ITEM_WEAPON_SAW
: FWeapon
[WEAPON_SAW
] := True;
6367 ITEM_WEAPON_SHOTGUN1
: FWeapon
[WEAPON_SHOTGUN1
] := True;
6368 ITEM_WEAPON_SHOTGUN2
: FWeapon
[WEAPON_SHOTGUN2
] := True;
6369 ITEM_WEAPON_CHAINGUN
: FWeapon
[WEAPON_CHAINGUN
] := True;
6370 ITEM_WEAPON_ROCKETLAUNCHER
: FWeapon
[WEAPON_ROCKETLAUNCHER
] := True;
6371 ITEM_WEAPON_PLASMA
: FWeapon
[WEAPON_PLASMA
] := True;
6372 ITEM_WEAPON_BFG
: FWeapon
[WEAPON_BFG
] := True;
6373 ITEM_WEAPON_SUPERPULEMET
: FWeapon
[WEAPON_SUPERPULEMET
] := True;
6374 ITEM_WEAPON_FLAMETHROWER
: FWeapon
[WEAPON_FLAMETHROWER
] := True;
6376 ITEM_AMMO_BULLETS
: if FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
] then IncMax(FAmmo
[A_BULLETS
], 10, FMaxAmmo
[A_BULLETS
]);
6377 ITEM_AMMO_BULLETS_BOX
: if FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
] then IncMax(FAmmo
[A_BULLETS
], 50, FMaxAmmo
[A_BULLETS
]);
6378 ITEM_AMMO_SHELLS
: if FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
] then IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
6379 ITEM_AMMO_SHELLS_BOX
: if FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
] then IncMax(FAmmo
[A_SHELLS
], 25, FMaxAmmo
[A_SHELLS
]);
6380 ITEM_AMMO_ROCKET
: if FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
] then IncMax(FAmmo
[A_ROCKETS
], 1, FMaxAmmo
[A_ROCKETS
]);
6381 ITEM_AMMO_ROCKET_BOX
: if FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
] then IncMax(FAmmo
[A_ROCKETS
], 5, FMaxAmmo
[A_ROCKETS
]);
6382 ITEM_AMMO_CELL
: if FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
] then IncMax(FAmmo
[A_CELLS
], 40, FMaxAmmo
[A_CELLS
]);
6383 ITEM_AMMO_CELL_BIG
: if FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
] then IncMax(FAmmo
[A_CELLS
], 100, FMaxAmmo
[A_CELLS
]);
6384 ITEM_AMMO_FUELCAN
: if FAmmo
[A_FUEL
] < FMaxAmmo
[A_FUEL
] then IncMax(FAmmo
[A_FUEL
], 100, FMaxAmmo
[A_FUEL
]);
6387 if (FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
]) or
6388 (FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
]) or
6389 (FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
]) or
6390 (FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
]) or
6391 (FMaxAmmo
[A_FUEL
] < AmmoLimits
[1, A_FUEL
]) then
6393 FMaxAmmo
[A_BULLETS
] := AmmoLimits
[1, A_BULLETS
];
6394 FMaxAmmo
[A_SHELLS
] := AmmoLimits
[1, A_SHELLS
];
6395 FMaxAmmo
[A_ROCKETS
] := AmmoLimits
[1, A_ROCKETS
];
6396 FMaxAmmo
[A_CELLS
] := AmmoLimits
[1, A_CELLS
];
6397 FMaxAmmo
[A_FUEL
] := AmmoLimits
[1, A_FUEL
];
6399 if FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
] then IncMax(FAmmo
[A_BULLETS
], 10, FMaxAmmo
[A_BULLETS
]);
6400 if FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
] then IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
6401 if FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
] then IncMax(FAmmo
[A_ROCKETS
], 1, FMaxAmmo
[A_ROCKETS
]);
6402 if FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
] then IncMax(FAmmo
[A_CELLS
], 40, FMaxAmmo
[A_CELLS
]);
6404 FRulez
:= FRulez
+ [R_ITEM_BACKPACK
];
6407 ITEM_KEY_RED
: if not (R_KEY_RED
in FRulez
) then Include(FRulez
, R_KEY_RED
);
6408 ITEM_KEY_GREEN
: if not (R_KEY_GREEN
in FRulez
) then Include(FRulez
, R_KEY_GREEN
);
6409 ITEM_KEY_BLUE
: if not (R_KEY_BLUE
in FRulez
) then Include(FRulez
, R_KEY_BLUE
);
6411 ITEM_BOTTLE
: if FHealth
< PLAYER_HP_LIMIT
then IncMax(FHealth
, 4, PLAYER_HP_LIMIT
);
6412 ITEM_HELMET
: if FArmor
< PLAYER_AP_LIMIT
then IncMax(FArmor
, 5, PLAYER_AP_LIMIT
);
6417 if g_Game_IsNet
and g_Game_IsServer
then
6418 MH_SEND_PlayerStats(FUID
);
6421 procedure TPlayer
.FlySmoke(Times
: DWORD
= 1);
6426 if (Random(5) = 1) and (Times
= 1) then
6429 if BodyInLiquid(0, 0) then
6431 g_GFX_Bubbles(Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2)+Random(3)-1,
6432 Obj
.Y
+Obj
.Rect
.Height
+8, 1, 8, 4);
6433 if Random(2) = 0 then
6434 g_Sound_PlayExAt('SOUND_GAME_BUBBLE1', FObj
.X
, FObj
.Y
)
6436 g_Sound_PlayExAt('SOUND_GAME_BUBBLE2', FObj
.X
, FObj
.Y
);
6440 if g_Frames_Get(id
, 'FRAMES_SMOKE') then
6442 for i
:= 1 to Times
do
6444 Anim
:= TAnimation
.Create(id
, False, 3);
6446 g_GFX_OnceAnim(Obj
.X
+Obj
.Rect
.X
+Random(Obj
.Rect
.Width
+Times
*2)-(Anim
.Width
div 2),
6447 Obj
.Y
+Obj
.Rect
.Height
-4+Random(8+Times
*2), Anim
, ONCEANIM_SMOKE
);
6453 procedure TPlayer
.OnFireFlame(Times
: DWORD
= 1);
6458 if (Random(10) = 1) and (Times
= 1) then
6461 if g_Frames_Get(id
, 'FRAMES_FLAME') then
6463 for i
:= 1 to Times
do
6465 Anim
:= TAnimation
.Create(id
, False, 3);
6467 g_GFX_OnceAnim(Obj
.X
+Obj
.Rect
.X
+Random(Obj
.Rect
.Width
+Times
*2)-(Anim
.Width
div 2),
6468 Obj
.Y
+8+Random(8+Times
*2), Anim
, ONCEANIM_SMOKE
);
6474 procedure TPlayer
.PauseSounds(Enable
: Boolean);
6476 FSawSound
.Pause(Enable
);
6477 FSawSoundIdle
.Pause(Enable
);
6478 FSawSoundHit
.Pause(Enable
);
6479 FSawSoundSelect
.Pause(Enable
);
6480 FFlameSoundOn
.Pause(Enable
);
6481 FFlameSoundOff
.Pause(Enable
);
6482 FFlameSoundWork
.Pause(Enable
);
6483 FJetSoundFly
.Pause(Enable
);
6484 FJetSoundOn
.Pause(Enable
);
6485 FJetSoundOff
.Pause(Enable
);
6490 constructor TCorpse
.Create(X
, Y
: Integer; ModelName
: String; aMess
: Boolean);
6495 FObj
.Rect
:= PLAYER_CORPSERECT
;
6496 FModelName
:= ModelName
;
6501 FState
:= CORPSE_STATE_MESS
;
6502 g_PlayerModel_GetAnim(ModelName
, A_DIE2
, FAnimation
, FAnimationMask
);
6506 FState
:= CORPSE_STATE_NORMAL
;
6507 g_PlayerModel_GetAnim(ModelName
, A_DIE1
, FAnimation
, FAnimationMask
);
6511 destructor TCorpse
.Destroy();
6518 function TCorpse
.ObjPtr (): PObj
; inline; begin result
:= @FObj
; end;
6520 procedure TCorpse
.positionChanged (); inline; begin end;
6522 procedure TCorpse
.moveBy (dx
, dy
: Integer); inline;
6524 if (dx
<> 0) or (dy
<> 0) then
6533 procedure TCorpse
.getMapBox (out x
, y
, w
, h
: Integer); inline;
6535 x
:= FObj
.X
+PLAYER_CORPSERECT
.X
;
6536 y
:= FObj
.Y
+PLAYER_CORPSERECT
.Y
;
6537 w
:= PLAYER_CORPSERECT
.Width
;
6538 h
:= PLAYER_CORPSERECT
.Height
;
6542 procedure TCorpse
.Damage(Value
: Word; SpawnerUID
: Word; vx
, vy
: Integer);
6547 if FState
= CORPSE_STATE_REMOVEME
then
6550 FDamage
:= FDamage
+ Value
;
6552 if FDamage
> 150 then
6554 if FAnimation
<> nil then
6559 FState
:= CORPSE_STATE_REMOVEME
;
6561 g_Player_CreateGibs(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
6562 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2),
6563 FModelName
, FColor
);
6564 // Çâóê ìÿñà îò òðóïà:
6565 pm
:= g_PlayerModel_Get(FModelName
);
6566 pm
.PlaySound(MODELSOUND_DIE
, 5, FObj
.X
, FObj
.Y
);
6570 if (gBodyKillEvent
<> -1)
6571 and gDelayedEvents
[gBodyKillEvent
].Pending
then
6572 gDelayedEvents
[gBodyKillEvent
].Pending
:= False;
6573 gBodyKillEvent
:= g_Game_DelayEvent(DE_BODYKILL
, 1050, SpawnerUID
);
6578 Blood
:= g_PlayerModel_GetBlood(FModelName
);
6579 FObj
.Vel
.X
:= FObj
.Vel
.X
+ vx
;
6580 FObj
.Vel
.Y
:= FObj
.Vel
.Y
+ vy
;
6581 g_GFX_Blood(FObj
.X
+PLAYER_CORPSERECT
.X
+(PLAYER_CORPSERECT
.Width
div 2),
6582 FObj
.Y
+PLAYER_CORPSERECT
.Y
+(PLAYER_CORPSERECT
.Height
div 2),
6583 Value
, vx
, vy
, 16, (PLAYER_CORPSERECT
.Height
*2) div 3,
6584 Blood
.R
, Blood
.G
, Blood
.B
, Blood
.Kind
);
6588 procedure TCorpse
.Draw();
6592 if FState
= CORPSE_STATE_REMOVEME
then
6595 FObj
.lerp(gLerpFactor
, fX
, fY
);
6597 if FAnimation
<> nil then
6598 FAnimation
.Draw(fX
, fY
, TMirrorType
.None
);
6600 if FAnimationMask
<> nil then
6603 FAnimationMask
.Draw(fX
, fY
, TMirrorType
.None
);
6610 procedure TCorpse
.Update();
6614 if FState
= CORPSE_STATE_REMOVEME
then
6617 FObj
.oldX
:= FObj
.X
;
6618 FObj
.oldY
:= FObj
.Y
;
6620 if gTime
mod (GAME_TICK
*2) <> 0 then
6622 g_Obj_Move(@FObj
, True, True, True);
6623 positionChanged(); // this updates spatial accelerators
6627 // Ñîïðîòèâëåíèå âîçäóõà äëÿ òðóïà:
6628 FObj
.Vel
.X
:= z_dec(FObj
.Vel
.X
, 1);
6630 st
:= g_Obj_Move(@FObj
, True, True, True);
6631 positionChanged(); // this updates spatial accelerators
6633 if WordBool(st
and MOVE_FALLOUT
) then
6635 FState
:= CORPSE_STATE_REMOVEME
;
6639 if FAnimation
<> nil then
6640 FAnimation
.Update();
6641 if FAnimationMask
<> nil then
6642 FAnimationMask
.Update();
6646 procedure TCorpse
.SaveState (st
: TStream
);
6653 utils
.writeSign(st
, 'CORP');
6654 utils
.writeInt(st
, Byte(0));
6656 utils
.writeInt(st
, Byte(FState
));
6658 utils
.writeInt(st
, Byte(FDamage
));
6660 utils
.writeInt(st
, Byte(FColor
.R
));
6661 utils
.writeInt(st
, Byte(FColor
.G
));
6662 utils
.writeInt(st
, Byte(FColor
.B
));
6664 Obj_SaveState(st
, @FObj
);
6665 utils
.writeInt(st
, Word(FPlayerUID
));
6667 anim
:= (FAnimation
<> nil);
6668 utils
.writeBool(st
, anim
);
6669 // Åñëè åñòü - ñîõðàíÿåì
6670 if anim
then FAnimation
.SaveState(st
);
6671 // Åñòü ëè ìàñêà àíèìàöèè
6672 anim
:= (FAnimationMask
<> nil);
6673 utils
.writeBool(st
, anim
);
6674 // Åñëè åñòü - ñîõðàíÿåì
6675 if anim
then FAnimationMask
.SaveState(st
);
6679 procedure TCorpse
.LoadState (st
: TStream
);
6686 if not utils
.checkSign(st
, 'CORP') then raise XStreamError
.Create('invalid corpse signature');
6687 if (utils
.readByte(st
) <> 0) then raise XStreamError
.Create('invalid corpse version');
6689 FState
:= utils
.readByte(st
);
6691 FDamage
:= utils
.readByte(st
);
6693 FColor
.R
:= utils
.readByte(st
);
6694 FColor
.G
:= utils
.readByte(st
);
6695 FColor
.B
:= utils
.readByte(st
);
6697 Obj_LoadState(@FObj
, st
);
6698 FPlayerUID
:= utils
.readWord(st
);
6700 anim
:= utils
.readBool(st
);
6701 // Åñëè åñòü - çàãðóæàåì
6704 Assert(FAnimation
<> nil, 'TCorpse.LoadState: no FAnimation');
6705 FAnimation
.LoadState(st
);
6707 // Åñòü ëè ìàñêà àíèìàöèè
6708 anim
:= utils
.readBool(st
);
6709 // Åñëè åñòü - çàãðóæàåì
6712 Assert(FAnimationMask
<> nil, 'TCorpse.LoadState: no FAnimationMask');
6713 FAnimationMask
.LoadState(st
);
6719 constructor TBot
.Create();
6726 FSpectator
:= False;
6733 for a
:= WP_FIRST
to WP_LAST
do
6735 FDifficult
.WeaponPrior
[a
] := WEAPON_PRIOR1
[a
];
6736 FDifficult
.CloseWeaponPrior
[a
] := WEAPON_PRIOR2
[a
];
6737 //FDifficult.SafeWeaponPrior[a] := WEAPON_PRIOR3[a];
6741 destructor TBot
.Destroy();
6744 inherited Destroy();
6747 procedure TBot
.Draw();
6751 //if FTargetUID <> 0 then e_DrawLine(1, FObj.X, FObj.Y, g_Player_Get(FTargetUID).FObj.X,
6752 // g_Player_Get(FTargetUID).FObj.Y, 255, 0, 0);
6755 procedure TBot
.Respawn(Silent
: Boolean; Force
: Boolean = False);
6757 inherited Respawn(Silent
, Force
);
6760 FSelectedWeapon
:= FCurrWeap
;
6765 procedure TBot
.UpdateCombat();
6778 TTargetRecord
= array of TTarget
;
6780 function Compare(a
, b
: TTarget
): Integer;
6782 if a
.Line
and not b
.Line
then // A íà ëèíèè îãíÿ
6785 if not a
.Line
and b
.Line
then // B íà ëèíèè îãíÿ
6787 else // È A, è B íà ëèíèè èëè íå íà ëèíèè îãíÿ
6788 if (a
.Line
and b
.Line
) or ((not a
.Line
) and (not b
.Line
)) then
6790 if a
.Dist
> b
.Dist
then // B áëèæå
6792 else // A áëèæå èëè ðàâíîóäàëåííî ñ B
6795 else // Ñòðàííî -> A
6800 a
, x1
, y1
, x2
, y2
: Integer;
6801 targets
: TTargetRecord
;
6803 Target
, BestTarget
: TTarget
;
6804 firew
, fireh
: Integer;
6808 vsPlayer
, vsMonster
, ok
: Boolean;
6811 function monsUpdate (mon
: TMonster
): Boolean;
6813 result
:= false; // don't stop
6814 if mon
.alive
and (mon
.MonsterType
<> MONSTER_BARREL
) then
6816 if not TargetOnScreen(mon
.Obj
.X
+mon
.Obj
.Rect
.X
, mon
.Obj
.Y
+mon
.Obj
.Rect
.Y
) then exit
;
6818 x2
:= mon
.Obj
.X
+mon
.Obj
.Rect
.X
+(mon
.Obj
.Rect
.Width
div 2);
6819 y2
:= mon
.Obj
.Y
+mon
.Obj
.Rect
.Y
+(mon
.Obj
.Rect
.Height
div 2);
6821 // Åñëè ìîíñòð íà ýêðàíå è íå ïðèêðûò ñòåíîé
6822 if g_TraceVector(x1
, y1
, x2
, y2
) then
6824 // Äîáàâëÿåì ê ñïèñêó âîçìîæíûõ öåëåé
6825 SetLength(targets
, Length(targets
)+1);
6826 with targets
[High(targets
)] do
6833 Rect
:= mon
.Obj
.Rect
;
6834 Dist
:= g_PatchLength(x1
, y1
, x2
, y2
);
6835 Line
:= (y1
+4 < Target
.Y
+ mon
.Obj
.Rect
.Y
+ mon
.Obj
.Rect
.Height
) and
6836 (y1
-4 > Target
.Y
+ mon
.Obj
.Rect
.Y
);
6845 vsPlayer
:= LongBool(gGameSettings
.Options
and GAME_OPTION_BOTVSPLAYER
);
6846 vsMonster
:= LongBool(gGameSettings
.Options
and GAME_OPTION_BOTVSMONSTER
);
6848 // Åñëè òåêóùåå îðóæèå íå òî, ÷òî íóæíî, òî ìåíÿåì:
6849 if FCurrWeap
<> FSelectedWeapon
then
6852 // Åñëè íóæíî ñòðåëÿòü è íóæíîå îðóæèå, òî íàæàòü "Ñòðåëÿòü":
6853 if (GetAIFlag('NEEDFIRE') <> '') and (FCurrWeap
= FSelectedWeapon
) then
6855 RemoveAIFlag('NEEDFIRE');
6858 WEAPON_PLASMA
, WEAPON_SUPERPULEMET
, WEAPON_CHAINGUN
: PressKey(KEY_FIRE
, 20);
6859 WEAPON_SAW
, WEAPON_KASTET
, WEAPON_FLAMETHROWER
: PressKey(KEY_FIRE
, 40);
6860 else PressKey(KEY_FIRE
);
6864 // Êîîðäèíàòû ñòâîëà:
6865 x1
:= FObj
.X
+ WEAPONPOINT
[FDirection
].X
;
6866 y1
:= FObj
.Y
+ WEAPONPOINT
[FDirection
].Y
;
6868 Target
.UID
:= FTargetUID
;
6871 if Target
.UID
<> 0 then
6872 begin // Öåëü åñòü - íàñòðàèâàåì
6873 if (g_GetUIDType(Target
.UID
) = UID_PLAYER
) and
6876 tpla
:= g_Player_Get(Target
.UID
);
6880 if (@FObj
) <> nil then
6887 Target
.cX
:= Target
.X
+ PLAYER_RECT_CX
;
6888 Target
.cY
:= Target
.Y
+ PLAYER_RECT_CY
;
6889 Target
.Rect
:= PLAYER_RECT
;
6890 Target
.Visible
:= g_TraceVector(x1
, y1
, Target
.cX
, Target
.cY
);
6891 Target
.Line
:= (y1
+4 < Target
.Y
+PLAYER_RECT
.Y
+PLAYER_RECT
.Height
) and
6892 (y1
-4 > Target
.Y
+PLAYER_RECT
.Y
);
6893 Target
.IsPlayer
:= True;
6897 if (g_GetUIDType(Target
.UID
) = UID_MONSTER
) and
6900 mon
:= g_Monsters_ByUID(Target
.UID
);
6903 Target
.X
:= mon
.Obj
.X
;
6904 Target
.Y
:= mon
.Obj
.Y
;
6906 Target
.cX
:= Target
.X
+ mon
.Obj
.Rect
.X
+ (mon
.Obj
.Rect
.Width
div 2);
6907 Target
.cY
:= Target
.Y
+ mon
.Obj
.Rect
.Y
+ (mon
.Obj
.Rect
.Height
div 2);
6908 Target
.Rect
:= mon
.Obj
.Rect
;
6909 Target
.Visible
:= g_TraceVector(x1
, y1
, Target
.cX
, Target
.cY
);
6910 Target
.Line
:= (y1
+4 < Target
.Y
+ mon
.Obj
.Rect
.Y
+ mon
.Obj
.Rect
.Height
) and
6911 (y1
-4 > Target
.Y
+ mon
.Obj
.Rect
.Y
);
6912 Target
.IsPlayer
:= False;
6919 begin // Öåëè íåò - îáíóëÿåì
6924 Target
.Visible
:= False;
6925 Target
.Line
:= False;
6926 Target
.IsPlayer
:= False;
6931 // Åñëè öåëü íå âèäèìà èëè íå íà ëèíèè îãíÿ, òî èùåì âñå âîçìîæíûå öåëè:
6932 if (not Target
.Line
) or (not Target
.Visible
) then
6936 for a
:= 0 to High(gPlayers
) do
6937 if (gPlayers
[a
] <> nil) and (gPlayers
[a
].alive
) and
6938 (gPlayers
[a
].FUID
<> FUID
) and
6939 (not SameTeam(FUID
, gPlayers
[a
].FUID
)) and
6940 (not gPlayers
[a
].NoTarget
) and
6941 (gPlayers
[a
].FMegaRulez
[MR_INVIS
] < gTime
) then
6943 if not TargetOnScreen(gPlayers
[a
].FObj
.X
+ PLAYER_RECT
.X
,
6944 gPlayers
[a
].FObj
.Y
+ PLAYER_RECT
.Y
) then
6947 x2
:= gPlayers
[a
].FObj
.X
+ PLAYER_RECT_CX
;
6948 y2
:= gPlayers
[a
].FObj
.Y
+ PLAYER_RECT_CY
;
6950 // Åñëè èãðîê íà ýêðàíå è íå ïðèêðûò ñòåíîé:
6951 if g_TraceVector(x1
, y1
, x2
, y2
) then
6953 // Äîáàâëÿåì ê ñïèñêó âîçìîæíûõ öåëåé:
6954 SetLength(targets
, Length(targets
)+1);
6955 with targets
[High(targets
)] do
6957 UID
:= gPlayers
[a
].FUID
;
6958 X
:= gPlayers
[a
].FObj
.X
;
6959 Y
:= gPlayers
[a
].FObj
.Y
;
6962 Rect
:= PLAYER_RECT
;
6963 Dist
:= g_PatchLength(x1
, y1
, x2
, y2
);
6964 Line
:= (y1
+4 < Target
.Y
+PLAYER_RECT
.Y
+PLAYER_RECT
.Height
) and
6965 (y1
-4 > Target
.Y
+PLAYER_RECT
.Y
);
6973 if vsMonster
then g_Mons_ForEach(monsUpdate
);
6976 // Åñëè åñòü âîçìîæíûå öåëè:
6977 // (Âûáèðàåì ëó÷øóþ, ìåíÿåì îðóæèå è áåæèì ê íåé/îò íåå)
6978 if targets
<> nil then
6980 // Âûáèðàåì íàèëó÷øóþ öåëü:
6981 BestTarget
:= targets
[0];
6982 if Length(targets
) > 1 then
6983 for a
:= 1 to High(targets
) do
6984 if Compare(BestTarget
, targets
[a
]) = 1 then
6985 BestTarget
:= targets
[a
];
6987 // Åñëè ëó÷øàÿ öåëü "âèäíåå" òåêóùåé, òî òåêóùàÿ := ëó÷øàÿ:
6988 if ((not Target
.Visible
) and BestTarget
.Visible
and (Target
.UID
<> BestTarget
.UID
)) or
6989 ((not Target
.Line
) and BestTarget
.Line
and BestTarget
.Visible
) then
6991 Target
:= BestTarget
;
6993 if (Healthy() = 3) or ((Healthy() = 2)) then
6994 begin // Åñëè çäîðîâû - äîãîíÿåì
6995 if ((RunDirection() = TDirection
.D_LEFT
) and (Target
.X
> FObj
.X
)) then
6996 SetAIFlag('GORIGHT', '1');
6997 if ((RunDirection() = TDirection
.D_RIGHT
) and (Target
.X
< FObj
.X
)) then
6998 SetAIFlag('GOLEFT', '1');
7001 begin // Åñëè ïîáèòû - óáåãàåì
7002 if ((RunDirection() = TDirection
.D_LEFT
) and (Target
.X
< FObj
.X
)) then
7003 SetAIFlag('GORIGHT', '1');
7004 if ((RunDirection() = TDirection
.D_RIGHT
) and (Target
.X
> FObj
.X
)) then
7005 SetAIFlag('GOLEFT', '1');
7008 // Âûáèðàåì îðóæèå íà îñíîâå ðàññòîÿíèÿ è ïðèîðèòåòîâ:
7009 SelectWeapon(Abs(x1
-Target
.cX
));
7014 // (Äîãîíÿåì/óáåãàåì, ñòðåëÿåì ïî íàïðàâëåíèþ ê öåëè)
7015 // (Åñëè öåëü äàëåêî, òî õâàòèò ñëåäèòü çà íåé)
7016 if Target
.UID
<> 0 then
7018 if not TargetOnScreen(Target
.X
+ Target
.Rect
.X
,
7019 Target
.Y
+ Target
.Rect
.Y
) then
7020 begin // Öåëü ñáåæàëà ñ "ýêðàíà"
7021 if (Healthy() = 3) or ((Healthy() = 2)) then
7022 begin // Åñëè çäîðîâû - äîãîíÿåì
7023 if ((RunDirection() = TDirection
.D_LEFT
) and (Target
.X
> FObj
.X
)) then
7024 SetAIFlag('GORIGHT', '1');
7025 if ((RunDirection() = TDirection
.D_RIGHT
) and (Target
.X
< FObj
.X
)) then
7026 SetAIFlag('GOLEFT', '1');
7029 begin // Åñëè ïîáèòû - çàáûâàåì î öåëè è óáåãàåì
7031 if ((RunDirection() = TDirection
.D_LEFT
) and (Target
.X
< FObj
.X
)) then
7032 SetAIFlag('GORIGHT', '1');
7033 if ((RunDirection() = TDirection
.D_RIGHT
) and (Target
.X
> FObj
.X
)) then
7034 SetAIFlag('GOLEFT', '1');
7038 begin // Öåëü ïîêà íà "ýêðàíå"
7039 // Åñëè öåëü íå çàãîðîæåíà ñòåíîé, òî îòìå÷àåì, êîãäà åå âèäåëè:
7040 if g_TraceVector(x1
, y1
, Target
.cX
, Target
.cY
) then
7041 FLastVisible
:= gTime
;
7042 // Åñëè ðàçíèöà âûñîò íå âåëèêà, òî äîãîíÿåì:
7043 if (Abs(FObj
.Y
-Target
.Y
) <= 128) then
7045 if ((RunDirection() = TDirection
.D_LEFT
) and (Target
.X
> FObj
.X
)) then
7046 SetAIFlag('GORIGHT', '1');
7047 if ((RunDirection() = TDirection
.D_RIGHT
) and (Target
.X
< FObj
.X
)) then
7048 SetAIFlag('GOLEFT', '1');
7052 // Âûáèðàåì óãîë ââåðõ:
7053 if FDirection
= TDirection
.D_LEFT
then
7054 angle
:= ANGLE_LEFTUP
7056 angle
:= ANGLE_RIGHTUP
;
7058 firew
:= Trunc(Cos(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
7059 fireh
:= Trunc(Sin(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
7061 // Åñëè ïðè óãëå ââåðõ ìîæíî ïîïàñòü â ïðèáëèçèòåëüíîå ïîëîæåíèå öåëè:
7062 if g_CollideLine(x1
, y1
, x1
+firew
, y1
+fireh
,
7063 Target
.X
+Target
.Rect
.X
+GetInterval(FDifficult
.DiagPrecision
, 128), //96
7064 Target
.Y
+Target
.Rect
.Y
+GetInterval(FDifficult
.DiagPrecision
, 128),
7065 Target
.Rect
.Width
, Target
.Rect
.Height
) and
7066 g_TraceVector(x1
, y1
, Target
.cX
, Target
.cY
) then
7067 begin // òî íóæíî ñòðåëÿòü ââåðõ
7068 SetAIFlag('NEEDFIRE', '1');
7069 SetAIFlag('NEEDSEEUP', '1');
7072 // Âûáèðàåì óãîë âíèç:
7073 if FDirection
= TDirection
.D_LEFT
then
7074 angle
:= ANGLE_LEFTDOWN
7076 angle
:= ANGLE_RIGHTDOWN
;
7078 firew
:= Trunc(Cos(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
7079 fireh
:= Trunc(Sin(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
7081 // Åñëè ïðè óãëå âíèç ìîæíî ïîïàñòü â ïðèáëèçèòåëüíîå ïîëîæåíèå öåëè:
7082 if g_CollideLine(x1
, y1
, x1
+firew
, y1
+fireh
,
7083 Target
.X
+Target
.Rect
.X
+GetInterval(FDifficult
.DiagPrecision
, 128),
7084 Target
.Y
+Target
.Rect
.Y
+GetInterval(FDifficult
.DiagPrecision
, 128),
7085 Target
.Rect
.Width
, Target
.Rect
.Height
) and
7086 g_TraceVector(x1
, y1
, Target
.cX
, Target
.cY
) then
7087 begin // òî íóæíî ñòðåëÿòü âíèç
7088 SetAIFlag('NEEDFIRE', '1');
7089 SetAIFlag('NEEDSEEDOWN', '1');
7092 // Åñëè öåëü âèäíî è îíà íà òàêîé æå âûñîòå:
7093 if Target
.Visible
and
7094 (y1
+4 < Target
.Y
+Target
.Rect
.Y
+Target
.Rect
.Height
) and
7095 (y1
-4 > Target
.Y
+Target
.Rect
.Y
) then
7097 // Åñëè èäåì â ñòîðîíó öåëè, òî íàäî ñòðåëÿòü:
7098 if ((FDirection
= TDirection
.D_LEFT
) and (Target
.X
< FObj
.X
)) or
7099 ((FDirection
= TDirection
.D_RIGHT
) and (Target
.X
> FObj
.X
)) then
7100 begin // òî íóæíî ñòðåëÿòü âïåðåä
7101 SetAIFlag('NEEDFIRE', '1');
7102 SetAIFlag('NEEDSEEDOWN', '');
7103 SetAIFlag('NEEDSEEUP', '');
7105 // Åñëè öåëü â ïðåäåëàõ "ýêðàíà" è ñëîæíîñòü ïîçâîëÿåò ïðûæêè ñáëèæåíèÿ:
7106 if Abs(FObj
.X
-Target
.X
) < Trunc(gPlayerScreenSize
.X
*0.75) then
7107 if GetRnd(FDifficult
.CloseJump
) then
7108 begin // òî åñëè ïîâåçåò - ïðûãàåì (îñîáåííî, åñëè áëèçêî)
7109 if Abs(FObj
.X
-Target
.X
) < 128 then
7113 if Random(a
) = 0 then
7114 SetAIFlag('NEEDJUMP', '1');
7118 // Åñëè öåëü âñå åùå åñòü:
7119 if Target
.UID
<> 0 then
7120 if gTime
-FLastVisible
> 2000 then // Åñëè âèäåëè äàâíî
7121 Target
.UID
:= 0 // òî çàáûòü öåëü
7122 else // Åñëè âèäåëè íåäàâíî
7123 begin // íî öåëü óáèëè
7124 if Target
.IsPlayer
then
7125 begin // Öåëü - èãðîê
7126 pla
:= g_Player_Get(Target
.UID
);
7127 if (pla
= nil) or (not pla
.alive
) or pla
.NoTarget
or
7128 (pla
.FMegaRulez
[MR_INVIS
] >= gTime
) then
7129 Target
.UID
:= 0; // òî çàáûòü öåëü
7132 begin // Öåëü - ìîíñòð
7133 mon
:= g_Monsters_ByUID(Target
.UID
);
7134 if (mon
= nil) or (not mon
.alive
) then
7135 Target
.UID
:= 0; // òî çàáûòü öåëü
7138 end; // if Target.UID <> 0
7140 FTargetUID
:= Target
.UID
;
7142 // Åñëè âîçìîæíûõ öåëåé íåò:
7143 // (Àòàêà ÷åãî-íèáóäü ñëåâà èëè ñïðàâà)
7144 if targets
= nil then
7145 if GetAIFlag('ATTACKLEFT') <> '' then
7146 begin // Åñëè íóæíî àòàêîâàòü íàëåâî
7147 RemoveAIFlag('ATTACKLEFT');
7149 SetAIFlag('NEEDJUMP', '1');
7151 if RunDirection() = TDirection
.D_RIGHT
then
7152 begin // Èäåì íå â òó ñòîðîíó
7153 if (Healthy() > 1) and GetRnd(FDifficult
.InvisFire
) then
7154 begin // Åñëè çäîðîâû, òî, âîçìîæíî, ñòðåëÿåì áåæèì âëåâî è ñòðåëÿåì
7155 SetAIFlag('NEEDFIRE', '1');
7156 SetAIFlag('GOLEFT', '1');
7160 begin // Èäåì â íóæíóþ ñòîðîíó
7161 if GetRnd(FDifficult
.InvisFire
) then // Âîçìîæíî, ñòðåëÿåì âñëåïóþ
7162 SetAIFlag('NEEDFIRE', '1');
7163 if Healthy() <= 1 then // Ïîáèòû - óáåãàåì
7164 SetAIFlag('GORIGHT', '1');
7168 if GetAIFlag('ATTACKRIGHT') <> '' then
7169 begin // Åñëè íóæíî àòàêîâàòü íàïðàâî
7170 RemoveAIFlag('ATTACKRIGHT');
7172 SetAIFlag('NEEDJUMP', '1');
7174 if RunDirection() = TDirection
.D_LEFT
then
7175 begin // Èäåì íå â òó ñòîðîíó
7176 if (Healthy() > 1) and GetRnd(FDifficult
.InvisFire
) then
7177 begin // Åñëè çäîðîâû, òî, âîçìîæíî, áåæèì âïðàâî è ñòðåëÿåì
7178 SetAIFlag('NEEDFIRE', '1');
7179 SetAIFlag('GORIGHT', '1');
7184 if GetRnd(FDifficult
.InvisFire
) then // Âîçìîæíî, ñòðåëÿåì âñëåïóþ
7185 SetAIFlag('NEEDFIRE', '1');
7186 if Healthy() <= 1 then // Ïîáèòû - óáåãàåì
7187 SetAIFlag('GOLEFT', '1');
7191 //HACK! (does it belongs there?)
7192 RealizeCurrentWeapon();
7194 // Åñëè åñòü âîçìîæíûå öåëè:
7195 // (Ñòðåëÿåì ïî íàïðàâëåíèþ ê öåëÿì)
7196 if (targets
<> nil) and (GetAIFlag('NEEDFIRE') <> '') then
7197 for a
:= 0 to High(targets
) do
7199 // Åñëè ìîæåì ñòðåëÿòü ïî äèàãîíàëè:
7200 if GetRnd(FDifficult
.DiagFire
) then
7202 // Èùåì öåëü ñâåðõó è ñòðåëÿåì, åñëè åñòü:
7203 if FDirection
= TDirection
.D_LEFT
then
7204 angle
:= ANGLE_LEFTUP
7206 angle
:= ANGLE_RIGHTUP
;
7208 firew
:= Trunc(Cos(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
7209 fireh
:= Trunc(Sin(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
7211 if g_CollideLine(x1
, y1
, x1
+firew
, y1
+fireh
,
7212 targets
[a
].X
+targets
[a
].Rect
.X
+GetInterval(FDifficult
.DiagPrecision
, 128),
7213 targets
[a
].Y
+targets
[a
].Rect
.Y
+GetInterval(FDifficult
.DiagPrecision
, 128),
7214 targets
[a
].Rect
.Width
, targets
[a
].Rect
.Height
) and
7215 g_TraceVector(x1
, y1
, targets
[a
].cX
, targets
[a
].cY
) then
7217 SetAIFlag('NEEDFIRE', '1');
7218 SetAIFlag('NEEDSEEUP', '1');
7221 // Èùåì öåëü ñíèçó è ñòðåëÿåì, åñëè åñòü:
7222 if FDirection
= TDirection
.D_LEFT
then
7223 angle
:= ANGLE_LEFTDOWN
7225 angle
:= ANGLE_RIGHTDOWN
;
7227 firew
:= Trunc(Cos(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
7228 fireh
:= Trunc(Sin(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
7230 if g_CollideLine(x1
, y1
, x1
+firew
, y1
+fireh
,
7231 targets
[a
].X
+targets
[a
].Rect
.X
+GetInterval(FDifficult
.DiagPrecision
, 128),
7232 targets
[a
].Y
+targets
[a
].Rect
.Y
+GetInterval(FDifficult
.DiagPrecision
, 128),
7233 targets
[a
].Rect
.Width
, targets
[a
].Rect
.Height
) and
7234 g_TraceVector(x1
, y1
, targets
[a
].cX
, targets
[a
].cY
) then
7236 SetAIFlag('NEEDFIRE', '1');
7237 SetAIFlag('NEEDSEEDOWN', '1');
7241 // Åñëè öåëü "ïåðåä íîñîì", òî ñòðåëÿåì:
7242 if targets
[a
].Line
and targets
[a
].Visible
and
7243 (((FDirection
= TDirection
.D_LEFT
) and (targets
[a
].X
< FObj
.X
)) or
7244 ((FDirection
= TDirection
.D_RIGHT
) and (targets
[a
].X
> FObj
.X
))) then
7246 SetAIFlag('NEEDFIRE', '1');
7251 // Åñëè ëåòèò ïóëÿ, òî, âîçìîæíî, ïîäïðûãèâàåì:
7252 if g_Weapon_Danger(FUID
, FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+PLAYER_RECT
.Y
,
7253 PLAYER_RECT
.Width
, PLAYER_RECT
.Height
,
7254 40+GetInterval(FDifficult
.Cover
, 40)) then
7255 SetAIFlag('NEEDJUMP', '1');
7257 // Åñëè êîí÷èëèñü ïàòîðíû, òî íóæíî ñìåíèòü îðóæèå:
7258 ammo
:= GetAmmoByWeapon(FCurrWeap
);
7259 if ((FCurrWeap
= WEAPON_SHOTGUN2
) and (ammo
< 2)) or
7260 ((FCurrWeap
= WEAPON_BFG
) and (ammo
< 40)) or
7262 SetAIFlag('SELECTWEAPON', '1');
7264 // Åñëè íóæíî ñìåíèòü îðóæèå, òî âûáèðàåì íóæíîå:
7265 if GetAIFlag('SELECTWEAPON') = '1' then
7268 RemoveAIFlag('SELECTWEAPON');
7272 procedure TBot
.Update();
7285 // Ïðîâåðÿåì, îòêëþ÷¸í ëè AI áîòîâ
7286 if (g_debug_BotAIOff
= 1) and (Team
= TEAM_RED
) then
7288 if (g_debug_BotAIOff
= 2) and (Team
= TEAM_BLUE
) then
7290 if g_debug_BotAIOff
= 3 then
7300 RealizeCurrentWeapon();
7307 procedure TBot
.ReleaseKey(Key
: Byte);
7316 function TBot
.KeyPressed(Key
: Word): Boolean;
7318 Result
:= FKeys
[Key
].Pressed
;
7321 function TBot
.GetAIFlag(aName
: String20
): String20
;
7327 aName
:= LowerCase(aName
);
7329 if FAIFlags
<> nil then
7330 for a
:= 0 to High(FAIFlags
) do
7331 if LowerCase(FAIFlags
[a
].Name
) = aName
then
7333 Result
:= FAIFlags
[a
].Value
;
7338 procedure TBot
.RemoveAIFlag(aName
: String20
);
7342 if FAIFlags
= nil then Exit
;
7344 aName
:= LowerCase(aName
);
7346 for a
:= 0 to High(FAIFlags
) do
7347 if LowerCase(FAIFlags
[a
].Name
) = aName
then
7349 if a
<> High(FAIFlags
) then
7350 for b
:= a
to High(FAIFlags
)-1 do
7351 FAIFlags
[b
] := FAIFlags
[b
+1];
7353 SetLength(FAIFlags
, Length(FAIFlags
)-1);
7358 procedure TBot
.SetAIFlag(aName
, fValue
: String20
);
7366 aName
:= LowerCase(aName
);
7368 if FAIFlags
<> nil then
7369 for a
:= 0 to High(FAIFlags
) do
7370 if LowerCase(FAIFlags
[a
].Name
) = aName
then
7376 if ok
then FAIFlags
[a
].Value
:= fValue
7379 SetLength(FAIFlags
, Length(FAIFlags
)+1);
7380 with FAIFlags
[High(FAIFlags
)] do
7388 procedure TBot
.UpdateMove
;
7390 procedure GoLeft(Time
: Word = 1);
7392 ReleaseKey(KEY_LEFT
);
7393 ReleaseKey(KEY_RIGHT
);
7394 PressKey(KEY_LEFT
, Time
);
7395 SetDirection(TDirection
.D_LEFT
);
7398 procedure GoRight(Time
: Word = 1);
7400 ReleaseKey(KEY_LEFT
);
7401 ReleaseKey(KEY_RIGHT
);
7402 PressKey(KEY_RIGHT
, Time
);
7403 SetDirection(TDirection
.D_RIGHT
);
7406 function Rnd(a
: Word): Boolean;
7408 Result
:= Random(a
) = 0;
7411 procedure Turn(Time
: Word = 1200);
7413 if RunDirection() = TDirection
.D_LEFT
then GoRight(Time
) else GoLeft(Time
);
7418 ReleaseKey(KEY_LEFT
);
7419 ReleaseKey(KEY_RIGHT
);
7422 function CanRunLeft(): Boolean;
7424 Result
:= not CollideLevel(-1, 0);
7427 function CanRunRight(): Boolean;
7429 Result
:= not CollideLevel(1, 0);
7432 function CanRun(): Boolean;
7434 if RunDirection() = TDirection
.D_LEFT
then Result
:= CanRunLeft() else Result
:= CanRunRight();
7437 procedure Jump(Time
: Word = 30);
7439 PressKey(KEY_JUMP
, Time
);
7442 function NearHole(): Boolean;
7446 { TODO 5 : Ëåñòíèöû }
7447 sx
:= IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1);
7448 for x
:= 1 to PLAYER_RECT
.Width
do
7449 if (not StayOnStep(x
*sx
, 0)) and
7450 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
)) and
7451 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
*2)) then
7460 function BorderHole(): Boolean;
7464 { TODO 5 : Ëåñòíèöû }
7465 sx
:= IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1);
7466 for x
:= 1 to PLAYER_RECT
.Width
do
7467 if (not StayOnStep(x
*sx
, 0)) and
7468 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
)) and
7469 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
*2)) then
7471 for xx
:= x
to x
+32 do
7472 if CollideLevel(xx
*sx
, PLAYER_RECT
.Height
) then
7482 function NearDeepHole(): Boolean;
7488 sx
:= IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1);
7491 for x
:= 1 to PLAYER_RECT
.Width
do
7492 if (not StayOnStep(x
*sx
, 0)) and
7493 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
)) and
7494 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
*2)) then
7496 while FObj
.Y
+y
*PLAYER_RECT
.Height
< gMapInfo
.Height
do
7498 if CollideLevel(x
*sx
, PLAYER_RECT
.Height
*y
) then Exit
;
7503 end else Result
:= False;
7506 function OverDeepHole(): Boolean;
7513 while FObj
.Y
+y
*PLAYER_RECT
.Height
< gMapInfo
.Height
do
7515 if CollideLevel(0, PLAYER_RECT
.Height
*y
) then Exit
;
7522 function OnGround(): Boolean;
7524 Result
:= StayOnStep(0, 0) or CollideLevel(0, 1);
7527 function OnLadder(): Boolean;
7529 Result
:= FullInStep(0, 0);
7532 function BelowLadder(): Boolean;
7534 Result
:= (FullInStep(IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -PLAYER_RECT
.Height
) and
7535 not CollideLevel(IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -PLAYER_RECT
.Height
)) or
7536 (FullInStep(IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -BOT_MAXJUMP
) and
7537 not CollideLevel(IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -BOT_MAXJUMP
));
7540 function BelowLiftUp(): Boolean;
7542 Result
:= ((FullInLift(IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -PLAYER_RECT
.Height
) = -1) and
7543 not CollideLevel(IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -PLAYER_RECT
.Height
)) or
7544 ((FullInLift(IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -BOT_MAXJUMP
) = -1) and
7545 not CollideLevel(IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -BOT_MAXJUMP
));
7548 function OnTopLift(): Boolean;
7550 Result
:= (FullInLift(0, 0) = -1) and (FullInLift(0, -32) = 0);
7553 function CanJumpOver(): Boolean;
7557 sx
:= IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1);
7561 if not CollideLevel(sx
, 0) then Exit
;
7563 for y
:= 1 to BOT_MAXJUMP
do
7564 if CollideLevel(0, -y
) then Exit
else
7565 if not CollideLevel(sx
, -y
) then
7572 function CanJumpUp(Dist
: ShortInt): Boolean;
7579 if CollideLevel(Dist
, 0) then Exit
;
7582 for y
:= 0 to BOT_MAXJUMP
do
7583 if CollideLevel(Dist
, -y
) then
7592 for yy
:= y
+1 to BOT_MAXJUMP
do
7593 if not CollideLevel(Dist
, -yy
) then
7602 for y
:= 0 to BOT_MAXJUMP
do
7603 if CollideLevel(0, -y
) then
7611 if y
< yy
then Exit
;
7616 function IsSafeTrigger(): Boolean;
7621 if gTriggers
= nil then
7623 for a
:= 0 to High(gTriggers
) do
7624 if Collide(gTriggers
[a
].X
,
7627 gTriggers
[a
].Height
) and
7628 (gTriggers
[a
].TriggerType
in [TRIGGER_EXIT
, TRIGGER_CLOSEDOOR
,
7629 TRIGGER_CLOSETRAP
, TRIGGER_TRAP
,
7630 TRIGGER_PRESS
, TRIGGER_ON
, TRIGGER_OFF
,
7631 TRIGGER_ONOFF
, TRIGGER_SPAWNMONSTER
,
7632 TRIGGER_DAMAGE
, TRIGGER_SHOT
]) then
7637 // Âîçìîæíî, íàæèìàåì êíîïêó:
7638 if Rnd(16) and IsSafeTrigger() then
7641 // Åñëè ïîä ëèôòîì èëè ñòóïåíüêàìè, òî, âîçìîæíî, ïðûãàåì:
7642 if OnLadder() or ((BelowLadder() or BelowLiftUp()) and Rnd(8)) then
7644 ReleaseKey(KEY_LEFT
);
7645 ReleaseKey(KEY_RIGHT
);
7649 // Èäåì âëåâî, åñëè íàäî áûëî:
7650 if GetAIFlag('GOLEFT') <> '' then
7652 RemoveAIFlag('GOLEFT');
7653 if CanRunLeft() then
7657 // Èäåì âïðàâî, åñëè íàäî áûëî:
7658 if GetAIFlag('GORIGHT') <> '' then
7660 RemoveAIFlag('GORIGHT');
7661 if CanRunRight() then
7665 // Åñëè âûëåòåëè çà êàðòó, òî ïðîáóåì âåðíóòüñÿ:
7666 if FObj
.X
< -32 then
7669 if FObj
.X
+32 > gMapInfo
.Width
then
7672 // Ïðûãàåì, åñëè íàäî áûëî:
7673 if GetAIFlag('NEEDJUMP') <> '' then
7676 RemoveAIFlag('NEEDJUMP');
7679 // Ñìîòðèì ââåðõ, åñëè íàäî áûëî:
7680 if GetAIFlag('NEEDSEEUP') <> '' then
7683 ReleaseKey(KEY_DOWN
);
7684 PressKey(KEY_UP
, 20);
7685 RemoveAIFlag('NEEDSEEUP');
7688 // Ñìîòðèì âíèç, åñëè íàäî áûëî:
7689 if GetAIFlag('NEEDSEEDOWN') <> '' then
7692 ReleaseKey(KEY_DOWN
);
7693 PressKey(KEY_DOWN
, 20);
7694 RemoveAIFlag('NEEDSEEDOWN');
7697 // Åñëè íóæíî áûëî â äûðó è ìû íå íà çåìëå, òî ïîêîðíî ëåòèì:
7698 if GetAIFlag('GOINHOLE') <> '' then
7699 if not OnGround() then
7701 ReleaseKey(KEY_LEFT
);
7702 ReleaseKey(KEY_RIGHT
);
7703 RemoveAIFlag('GOINHOLE');
7704 SetAIFlag('FALLINHOLE', '1');
7707 // Åñëè ïàäàëè è äîñòèãëè çåìëè, òî õâàòèò ïàäàòü:
7708 if GetAIFlag('FALLINHOLE') <> '' then
7710 RemoveAIFlag('FALLINHOLE');
7712 // Åñëè ëåòåëè ïðÿìî è ñåé÷àñ íå íà ëåñòíèöå èëè íà âåðøèíå ëèôòà, òî îòõîäèì â ñòîðîíó:
7713 if not (KeyPressed(KEY_LEFT
) or KeyPressed(KEY_RIGHT
)) then
7714 if GetAIFlag('FALLINHOLE') = '' then
7715 if (not OnLadder()) or (FObj
.Vel
.Y
>= 0) or (OnTopLift()) then
7721 // Åñëè íà çåìëå è ìîæíî ïîäïðûãíóòü, òî, âîçìîæíî, ïðûãàåì:
7723 CanJumpUp(IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1)*32) and
7727 // Åñëè íà çåìëå è âîçëå äûðû (ãëóáèíà > 2 ðîñòîâ èãðîêà):
7728 if OnGround() and NearHole() then
7729 if NearDeepHole() then // Åñëè ýòî áåçäíà
7731 0..3: Turn(); // Áåæèì îáðàòíî
7732 4: Jump(); // Ïðûãàåì
7733 5: begin // Ïðûãàåì îáðàòíî
7738 else // Ýòî íå áåçäíà è ìû åùå íå ëåòèì òóäà
7739 if GetAIFlag('GOINHOLE') = '' then
7741 0: Turn(); // Íå íóæíî òóäà
7742 1: Jump(); // Âäðóã ïîâåçåò - ïðûãàåì
7743 else // Åñëè ÿìà ñ ãðàíèöåé, òî ïðè ñëó÷àå ìîæíî òóäà ïðûãíóòü
7744 if BorderHole() then
7745 SetAIFlag('GOINHOLE', '1');
7748 // Åñëè íà çåìëå, íî íåêóäà èäòè:
7749 if (not CanRun()) and OnGround() then
7751 // Åñëè ìû íà ëåñòíèöå èëè ìîæíî ïåðåïðûãíóòü, òî ïðûãàåì:
7752 if CanJumpOver() or OnLadder() then
7754 else // èíà÷å ïîïûòàåìñÿ â äðóãóþ ñòîðîíó
7755 if Random(2) = 0 then
7757 if IsSafeTrigger() then
7763 // Îñòàëîñü ìàëî âîçäóõà:
7764 if FAir
< 36 * 2 then
7767 // Âûáèðàåìñÿ èç êèñëîòû, åñëè íåò êîñòþìà, îáîæãëèñü, èëè ìàëî çäîðîâüÿ:
7768 if (FMegaRulez
[MR_SUIT
] < gTime
) and ((FLastHit
= HIT_ACID
) or (Healthy() <= 1)) then
7769 if BodyInAcid(0, 0) then
7773 function TBot
.FullInStep(XInc
, YInc
: Integer): Boolean;
7775 Result
:= g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
,
7776 PLAYER_RECT
.Width
, PLAYER_RECT
.Height
, PANEL_STEP
, False);
7779 {function TBot.NeedItem(Item: Byte): Byte;
7784 procedure TBot
.SelectWeapon(Dist
: Integer);
7788 function HaveAmmo(weapon
: Byte): Boolean;
7791 WEAPON_PISTOL
: Result
:= FAmmo
[A_BULLETS
] >= 1;
7792 WEAPON_SHOTGUN1
: Result
:= FAmmo
[A_SHELLS
] >= 1;
7793 WEAPON_SHOTGUN2
: Result
:= FAmmo
[A_SHELLS
] >= 2;
7794 WEAPON_CHAINGUN
: Result
:= FAmmo
[A_BULLETS
] >= 10;
7795 WEAPON_ROCKETLAUNCHER
: Result
:= FAmmo
[A_ROCKETS
] >= 1;
7796 WEAPON_PLASMA
: Result
:= FAmmo
[A_CELLS
] >= 10;
7797 WEAPON_BFG
: Result
:= FAmmo
[A_CELLS
] >= 40;
7798 WEAPON_SUPERPULEMET
: Result
:= FAmmo
[A_SHELLS
] >= 1;
7799 WEAPON_FLAMETHROWER
: Result
:= FAmmo
[A_FUEL
] >= 1;
7800 else Result
:= True;
7805 if Dist
= -1 then Dist
:= BOT_LONGDIST
;
7807 if Dist
> BOT_LONGDIST
then
7808 begin // Äàëüíèé áîé
7810 if FWeapon
[FDifficult
.WeaponPrior
[a
]] and HaveAmmo(FDifficult
.WeaponPrior
[a
]) then
7812 FSelectedWeapon
:= FDifficult
.WeaponPrior
[a
];
7816 else //if Dist > BOT_UNSAFEDIST then
7817 begin // Áëèæíèé áîé
7819 if FWeapon
[FDifficult
.CloseWeaponPrior
[a
]] and HaveAmmo(FDifficult
.CloseWeaponPrior
[a
]) then
7821 FSelectedWeapon
:= FDifficult
.CloseWeaponPrior
[a
];
7828 if FWeapon[FDifficult.SafeWeaponPrior[a]] and HaveAmmo(FDifficult.SafeWeaponPrior[a]) then
7830 FSelectedWeapon := FDifficult.SafeWeaponPrior[a];
7836 function TBot
.PickItem(ItemType
: Byte; force
: Boolean; var remove
: Boolean): Boolean;
7838 Result
:= inherited PickItem(ItemType
, force
, remove
);
7840 if Result
then SetAIFlag('SELECTWEAPON', '1');
7843 function TBot
.Heal(value
: Word; Soft
: Boolean): Boolean;
7845 Result
:= inherited Heal(value
, Soft
);
7848 function TBot
.Healthy(): Byte;
7850 if FMegaRulez
[MR_INVUL
] >= gTime
then Result
:= 3
7851 else if (FHealth
> 80) or ((FHealth
> 50) and (FArmor
> 20)) then Result
:= 3
7852 else if (FHealth
> 50) then Result
:= 2
7853 else if (FHealth
> 20) then Result
:= 1
7857 function TBot
.TargetOnScreen(TX
, TY
: Integer): Boolean;
7859 Result
:= (Abs(FObj
.X
-TX
) <= Trunc(gPlayerScreenSize
.X
*0.6)) and
7860 (Abs(FObj
.Y
-TY
) <= Trunc(gPlayerScreenSize
.Y
*0.6));
7863 procedure TBot
.OnDamage(Angle
: SmallInt);
7871 if (Angle
= 0) or (Angle
= 180) then
7874 if (g_GetUIDType(FLastSpawnerUID
) = UID_PLAYER
) and
7875 LongBool(gGameSettings
.Options
and GAME_OPTION_BOTVSPLAYER
) then
7877 pla
:= g_Player_Get(FLastSpawnerUID
);
7878 ok
:= not TargetOnScreen(pla
.FObj
.X
+ PLAYER_RECT
.X
,
7879 pla
.FObj
.Y
+ PLAYER_RECT
.Y
);
7882 if (g_GetUIDType(FLastSpawnerUID
) = UID_MONSTER
) and
7883 LongBool(gGameSettings
.Options
and GAME_OPTION_BOTVSMONSTER
) then
7885 mon
:= g_Monsters_ByUID(FLastSpawnerUID
);
7886 ok
:= not TargetOnScreen(mon
.Obj
.X
+ mon
.Obj
.Rect
.X
,
7887 mon
.Obj
.Y
+ mon
.Obj
.Rect
.Y
);
7892 SetAIFlag('ATTACKLEFT', '1')
7894 SetAIFlag('ATTACKRIGHT', '1');
7898 function TBot
.RunDirection(): TDirection
;
7900 if Abs(Vel
.X
) >= 1 then
7902 if Vel
.X
> 0 then Result
:= TDirection
.D_RIGHT
else Result
:= TDirection
.D_LEFT
;
7904 Result
:= FDirection
;
7907 function TBot
.GetRnd(a
: Byte): Boolean;
7909 if a
= 0 then Result
:= False
7910 else if a
= 255 then Result
:= True
7911 else Result
:= Random(256) > 255-a
;
7914 function TBot
.GetInterval(a
: Byte; radius
: SmallInt): SmallInt;
7916 Result
:= Round((255-a
)/255*radius
*(Random(2)-1));
7920 procedure TDifficult
.save (st
: TStream
);
7922 utils
.writeInt(st
, Byte(DiagFire
));
7923 utils
.writeInt(st
, Byte(InvisFire
));
7924 utils
.writeInt(st
, Byte(DiagPrecision
));
7925 utils
.writeInt(st
, Byte(FlyPrecision
));
7926 utils
.writeInt(st
, Byte(Cover
));
7927 utils
.writeInt(st
, Byte(CloseJump
));
7928 st
.WriteBuffer(WeaponPrior
[Low(WeaponPrior
)], sizeof(WeaponPrior
));
7929 st
.WriteBuffer(CloseWeaponPrior
[Low(CloseWeaponPrior
)], sizeof(CloseWeaponPrior
));
7932 procedure TDifficult
.load (st
: TStream
);
7934 DiagFire
:= utils
.readByte(st
);
7935 InvisFire
:= utils
.readByte(st
);
7936 DiagPrecision
:= utils
.readByte(st
);
7937 FlyPrecision
:= utils
.readByte(st
);
7938 Cover
:= utils
.readByte(st
);
7939 CloseJump
:= utils
.readByte(st
);
7940 st
.ReadBuffer(WeaponPrior
[Low(WeaponPrior
)], sizeof(WeaponPrior
));
7941 st
.ReadBuffer(CloseWeaponPrior
[Low(CloseWeaponPrior
)], sizeof(CloseWeaponPrior
));
7945 procedure TBot
.SaveState (st
: TStream
);
7950 inherited SaveState(st
);
7951 utils
.writeSign(st
, 'BOT0');
7953 utils
.writeInt(st
, Byte(FSelectedWeapon
));
7955 utils
.writeInt(st
, Word(FTargetUID
));
7956 // Âðåìÿ ïîòåðè öåëè
7957 utils
.writeInt(st
, LongWord(FLastVisible
));
7958 // Êîëè÷åñòâî ôëàãîâ ÈÈ
7959 dw
:= Length(FAIFlags
);
7960 utils
.writeInt(st
, LongInt(dw
));
7962 for i
:= 0 to dw
-1 do
7964 utils
.writeStr(st
, FAIFlags
[i
].Name
, 20);
7965 utils
.writeStr(st
, FAIFlags
[i
].Value
, 20);
7967 // Íàñòðîéêè ñëîæíîñòè
7968 FDifficult
.save(st
);
7972 procedure TBot
.LoadState (st
: TStream
);
7977 inherited LoadState(st
);
7978 if not utils
.checkSign(st
, 'BOT0') then raise XStreamError
.Create('invalid bot signature');
7980 FSelectedWeapon
:= utils
.readByte(st
);
7982 FTargetUID
:= utils
.readWord(st
);
7983 // Âðåìÿ ïîòåðè öåëè
7984 FLastVisible
:= utils
.readLongWord(st
);
7985 // Êîëè÷åñòâî ôëàãîâ ÈÈ
7986 dw
:= utils
.readLongInt(st
);
7987 if (dw
< 0) or (dw
> 16384) then raise XStreamError
.Create('invalid number of bot AI flags');
7988 SetLength(FAIFlags
, dw
);
7990 for i
:= 0 to dw
-1 do
7992 FAIFlags
[i
].Name
:= utils
.readStr(st
, 20);
7993 FAIFlags
[i
].Value
:= utils
.readStr(st
, 20);
7995 // Íàñòðîéêè ñëîæíîñòè
7996 FDifficult
.load(st
);
8001 conRegVar('cheat_berserk_autoswitch', @gBerserkAutoswitch
, 'autoswitch to fist when berserk pack taken', '', true, true);
8002 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');
8003 conRegVar('player_indicator_style', @gPlayerIndicatorStyle
, 'Visual appearance of indicator', 'Visual appearance of indicator');