1 (* Copyright (C) Doom 2D: Forever Developers
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, version 3 of the License ONLY.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 {$INCLUDE ../shared/a_modes.inc}
23 {$IFDEF USE_MEMPOOL}mempool
,{$ENDIF}
24 e_graphics
, g_playermodel
, g_basic
, g_textures
,
25 g_weapons
, g_phys
, g_sound
, g_saveload
, MAPDEF
,
58 AmmoLimits
: Array [0..1] of Array [A_BULLETS
..A_HIGH
] of Word =
59 ((200, 50, 50, 300, 100),
60 (400, 100, 100, 600, 200));
81 ANGLE_NONE
= Low(SmallInt);
83 CORPSE_STATE_REMOVEME
= 0;
84 CORPSE_STATE_NORMAL
= 1;
85 CORPSE_STATE_MESS
= 2;
87 PLAYER_RECT
: TRectWH
= (X
:15; Y
:12; Width
:34; Height
:52);
88 PLAYER_RECT_CX
= 15+(34 div 2);
89 PLAYER_RECT_CY
= 12+(52 div 2);
90 PLAYER_CORPSERECT
: TRectWH
= (X
:15; Y
:48; Width
:34; Height
:16);
93 PLAYER_HP_LIMIT
= 200;
95 PLAYER_AP_LIMIT
= 200;
99 PLAYER_BURN_TIME
= 110;
101 PLAYER1_DEF_COLOR
: TRGB
= (R
:64; G
:175; B
:48);
102 PLAYER2_DEF_COLOR
: TRGB
= (R
:96; G
:96; B
:96);
119 TPlayerStatArray
= Array of TPlayerStat
;
121 TPlayerSavedState
= record
129 Ammo
: Array [A_BULLETS
..A_HIGH
] of Word;
130 MaxAmmo
: Array [A_BULLETS
..A_HIGH
] of Word;
131 Weapon
: Array [WP_FIRST
..WP_LAST
] of Boolean;
132 Rulez
: Set of R_ITEM_BACKPACK
..R_BERSERK
;
141 TPlayer
= class{$IFDEF USE_MEMPOOL}(TPoolObject
){$ENDIF}
149 FDirection
: TDirection
;
157 FMonsterKills
: Integer;
163 FCanJetpack
: Boolean;
169 FNextWeapDelay
: Byte; // frames
170 FBFGFireCounter
: SmallInt;
171 FLastSpawnerUID
: Word;
175 FSpectatePlayer
: Integer;
176 FFirePainTime
: Integer;
179 FSavedStateNum
: Integer;
181 FModel
: TPlayerModel
;
182 FPunchAnim
: TAnimation
;
185 FActionForce
: Boolean;
186 FActionChanged
: Boolean;
188 FFireAngle
: SmallInt;
192 FShellTimer
: Integer;
194 FSawSound
: TPlayableSound
;
195 FSawSoundIdle
: TPlayableSound
;
196 FSawSoundHit
: TPlayableSound
;
197 FSawSoundSelect
: TPlayableSound
;
198 FFlameSoundOn
: TPlayableSound
;
199 FFlameSoundOff
: TPlayableSound
;
200 FFlameSoundWork
: TPlayableSound
;
201 FJetSoundOn
: TPlayableSound
;
202 FJetSoundOff
: TPlayableSound
;
203 FJetSoundFly
: TPlayableSound
;
207 FJustTeleported
: Boolean;
209 mEDamageType
: Integer;
212 function CollideLevel(XInc
, YInc
: Integer): Boolean;
213 function StayOnStep(XInc
, YInc
: Integer): Boolean;
214 function HeadInLiquid(XInc
, YInc
: Integer): Boolean;
215 function BodyInLiquid(XInc
, YInc
: Integer): Boolean;
216 function BodyInAcid(XInc
, YInc
: Integer): Boolean;
217 function FullInLift(XInc
, YInc
: Integer): Integer;
218 {procedure CollideItem();}
219 procedure FlySmoke(Times
: DWORD
= 1);
220 procedure OnFireFlame(Times
: DWORD
= 1);
221 function GetAmmoByWeapon(Weapon
: Byte): Word;
222 procedure SetAction(Action
: Byte; Force
: Boolean = False);
223 procedure OnDamage(Angle
: SmallInt); virtual;
224 function firediry(): Integer;
227 procedure Run(Direction
: TDirection
);
228 procedure NextWeapon();
229 procedure PrevWeapon();
236 function getNextWeaponIndex (): Byte; // return 255 for "no switch"
237 procedure resetWeaponQueue ();
238 function hasAmmoForWeapon (weapon
: Byte): Boolean;
240 procedure doDamage (v
: Integer);
242 function refreshCorpse(): Boolean;
245 FDamageBuffer
: Integer;
247 FAmmo
: Array [A_BULLETS
..A_HIGH
] of Word;
248 FMaxAmmo
: Array [A_BULLETS
..A_HIGH
] of Word;
249 FWeapon
: Array [WP_FIRST
..WP_LAST
] of Boolean;
250 FRulez
: Set of R_ITEM_BACKPACK
..R_BERSERK
;
252 FMegaRulez
: Array [MR_SUIT
..MR_MAX
] of DWORD
;
253 FReloading
: Array [WP_FIRST
..WP_LAST
] of Word;
254 FTime
: Array [T_RESPAWN
..T_FLAGCAP
] of DWORD
;
255 FKeys
: Array [KEY_LEFT
..KEY_CHAT
] of TKeyState
;
257 FPreferredTeam
: Byte;
260 FWantsInGame
: Boolean;
265 FActualModelName
: string;
272 FSpawnInvul
: Integer;
274 FWaitForFirstSpawn
: Boolean; // set to `true` in server, used to spawn a player on first full state request
277 // debug: viewport offset
278 viewPortX
, viewPortY
, viewPortW
, viewPortH
: Integer;
280 function isValidViewPort (): Boolean; inline;
282 constructor Create(); virtual;
283 destructor Destroy(); override;
284 procedure Respawn(Silent
: Boolean; Force
: Boolean = False); virtual;
285 function GetRespawnPoint(): Byte;
286 procedure PressKey(Key
: Byte; Time
: Word = 1);
287 procedure ReleaseKeys();
288 procedure SetModel(ModelName
: String);
289 procedure SetColor(Color
: TRGB
);
290 function GetColor(): TRGB
;
291 procedure SetWeapon(W
: Byte);
292 function IsKeyPressed(K
: Byte): Boolean;
293 function GetKeys(): Byte;
294 function PickItem(ItemType
: Byte; arespawn
: Boolean; var remove
: Boolean): Boolean; virtual;
295 function Collide(X
, Y
: Integer; Width
, Height
: Word): Boolean; overload
;
296 function Collide(Panel
: TPanel
): Boolean; overload
;
297 function Collide(X
, Y
: Integer): Boolean; overload
;
298 procedure SetDirection(Direction
: TDirection
);
299 procedure GetSecret();
300 function TeleportTo(X
, Y
: Integer; silent
: Boolean; dir
: Byte): Boolean;
302 procedure Push(vx
, vy
: Integer);
303 procedure ChangeModel(ModelName
: String);
304 procedure SwitchTeam
;
305 procedure ChangeTeam(Team
: Byte);
307 function GetFlag(Flag
: Byte): Boolean;
308 procedure SetFlag(Flag
: Byte);
309 function DropFlag(Silent
: Boolean = True): Boolean;
310 procedure AllRulez(Health
: Boolean);
311 procedure RestoreHealthArmor();
312 procedure FragCombo();
313 procedure GiveItem(ItemType
: Byte);
314 procedure Damage(value
: Word; SpawnerUID
: Word; vx
, vy
: Integer; t
: Byte); virtual;
315 function Heal(value
: Word; Soft
: Boolean): Boolean; virtual;
316 procedure MakeBloodVector(Count
: Word; VelX
, VelY
: Integer);
317 procedure MakeBloodSimple(Count
: Word);
318 procedure Kill(KillType
: Byte; SpawnerUID
: Word; t
: Byte);
319 procedure Reset(Force
: Boolean);
320 procedure Spectate(NoMove
: Boolean = False);
321 procedure SwitchNoClip
;
322 procedure SoftReset();
323 procedure Draw(); virtual;
324 procedure DrawPain();
325 procedure DrawPickup();
326 procedure DrawRulez();
328 procedure DrawIndicator(Color
: TRGB
);
329 procedure DrawBubble();
331 procedure PreUpdate();
332 procedure Update(); virtual;
333 procedure RememberState();
334 procedure RecallState();
335 procedure SaveState (st
: TStream
); virtual;
336 procedure LoadState (st
: TStream
); virtual;
337 procedure PauseSounds(Enable
: Boolean);
338 procedure NetFire(Wpn
: Byte; X
, Y
, AX
, AY
: Integer; WID
: Integer = -1);
339 procedure DoLerp(Level
: Integer = 2);
340 procedure SetLerp(XTo
, YTo
: Integer);
341 procedure QueueWeaponSwitch(Weapon
: Byte);
342 procedure RealizeCurrentWeapon();
346 procedure JetpackOff
;
347 procedure CatchFire(Attacker
: Word; Timeout
: Integer = PLAYER_BURN_TIME
);
349 //WARNING! this does nothing for now, but still call it!
350 procedure positionChanged (); //WARNING! call this after entity position was changed, or coldet will not work right!
352 procedure getMapBox (out x
, y
, w
, h
: Integer); inline;
353 procedure moveBy (dx
, dy
: Integer); inline;
355 function getCameraObj(): TObj
;
358 property Vel
: TPoint2i read FObj
.Vel
;
359 property Obj
: TObj read FObj
;
361 property Name
: String read FName write FName
;
362 property Model
: TPlayerModel read FModel
;
363 property Health
: Integer read FHealth write FHealth
;
364 property Lives
: Byte read FLives write FLives
;
365 property Armor
: Integer read FArmor write FArmor
;
366 property Air
: Integer read FAir write FAir
;
367 property JetFuel
: Integer read FJetFuel write FJetFuel
;
368 property Frags
: Integer read FFrags write FFrags
;
369 property Death
: Integer read FDeath write FDeath
;
370 property Kills
: Integer read FKills write FKills
;
371 property CurrWeap
: Byte read FCurrWeap write FCurrWeap
;
372 property MonsterKills
: Integer read FMonsterKills write FMonsterKills
;
373 property Secrets
: Integer read FSecrets
;
374 property GodMode
: Boolean read FGodMode write FGodMode
;
375 property NoTarget
: Boolean read FNoTarget write FNoTarget
;
376 property NoReload
: Boolean read FNoReload write FNoReload
;
377 property alive
: Boolean read FAlive write FAlive
;
378 property Flag
: Byte read FFlag
;
379 property Team
: Byte read FTeam write FTeam
;
380 property Direction
: TDirection read FDirection
;
381 property GameX
: Integer read FObj
.X write FObj
.X
;
382 property GameY
: Integer read FObj
.Y write FObj
.Y
;
383 property GameVelX
: Integer read FObj
.Vel
.X write FObj
.Vel
.X
;
384 property GameVelY
: Integer read FObj
.Vel
.Y write FObj
.Vel
.Y
;
385 property GameAccelX
: Integer read FObj
.Accel
.X write FObj
.Accel
.X
;
386 property GameAccelY
: Integer read FObj
.Accel
.Y write FObj
.Accel
.Y
;
387 property IncCam
: Integer read FIncCam write FIncCam
;
388 property IncCamOld
: Integer read FIncCamOld write FIncCamOld
;
389 property SlopeOld
: Integer read FSlopeOld write FSlopeOld
;
390 property UID
: Word read FUID write FUID
;
391 property JustTeleported
: Boolean read FJustTeleported write FJustTeleported
;
392 property NetTime
: LongWord read FNetTime write FNetTime
;
395 property eName
: String read FName write FName
;
396 property eHealth
: Integer read FHealth write FHealth
;
397 property eLives
: Byte read FLives write FLives
;
398 property eArmor
: Integer read FArmor write FArmor
;
399 property eAir
: Integer read FAir write FAir
;
400 property eJetFuel
: Integer read FJetFuel write FJetFuel
;
401 property eFrags
: Integer read FFrags write FFrags
;
402 property eDeath
: Integer read FDeath write FDeath
;
403 property eKills
: Integer read FKills write FKills
;
404 property eCurrWeap
: Byte read FCurrWeap write FCurrWeap
;
405 property eMonsterKills
: Integer read FMonsterKills write FMonsterKills
;
406 property eSecrets
: Integer read FSecrets write FSecrets
;
407 property eGodMode
: Boolean read FGodMode write FGodMode
;
408 property eNoTarget
: Boolean read FNoTarget write FNoTarget
;
409 property eNoReload
: Boolean read FNoReload write FNoReload
;
410 property eAlive
: Boolean read FAlive write FAlive
;
411 property eFlag
: Byte read FFlag
;
412 property eTeam
: Byte read FTeam write FTeam
;
413 property eDirection
: TDirection read FDirection
;
414 property eGameX
: Integer read FObj
.X write FObj
.X
;
415 property eGameY
: Integer read FObj
.Y write FObj
.Y
;
416 property eGameVelX
: Integer read FObj
.Vel
.X write FObj
.Vel
.X
;
417 property eGameVelY
: Integer read FObj
.Vel
.Y write FObj
.Vel
.Y
;
418 property eGameAccelX
: Integer read FObj
.Accel
.X write FObj
.Accel
.X
;
419 property eGameAccelY
: Integer read FObj
.Accel
.Y write FObj
.Accel
.Y
;
420 property eIncCam
: Integer read FIncCam write FIncCam
;
421 property eUID
: Word read FUID
;
422 property eJustTeleported
: Boolean read FJustTeleported
;
423 property eNetTime
: LongWord read FNetTime
;
425 // set this before assigning something to `eDamage`
426 property eDamageType
: Integer read mEDamageType write mEDamageType
;
427 property eDamage
: Integer write doDamage
;
438 WeaponPrior
: packed array [WP_FIRST
..WP_LAST
] of Byte;
439 CloseWeaponPrior
: packed array [WP_FIRST
..WP_LAST
] of Byte;
440 //SafeWeaponPrior: Array [WP_FIRST..WP_LAST] of Byte;
443 procedure save (st
: TStream
);
444 procedure load (st
: TStream
);
452 TBot
= class(TPlayer
)
454 FSelectedWeapon
: Byte;
457 FAIFlags
: Array of TAIFlag
;
458 FDifficult
: TDifficult
;
460 function GetRnd(a
: Byte): Boolean;
461 function GetInterval(a
: Byte; radius
: SmallInt): SmallInt;
462 function RunDirection(): TDirection
;
463 function FullInStep(XInc
, YInc
: Integer): Boolean;
464 //function NeedItem(Item: Byte): Byte;
465 procedure SelectWeapon(Dist
: Integer);
466 procedure SetAIFlag(aName
, fValue
: String20
);
467 function GetAIFlag(aName
: String20
): String20
;
468 procedure RemoveAIFlag(aName
: String20
);
469 function Healthy(): Byte;
470 procedure UpdateMove();
471 procedure UpdateCombat();
472 function KeyPressed(Key
: Word): Boolean;
473 procedure ReleaseKey(Key
: Byte);
474 function TargetOnScreen(TX
, TY
: Integer): Boolean;
475 procedure OnDamage(Angle
: SmallInt); override;
478 procedure Respawn(Silent
: Boolean; Force
: Boolean = False); override;
479 constructor Create(); override;
480 destructor Destroy(); override;
481 procedure Draw(); override;
482 function PickItem(ItemType
: Byte; force
: Boolean; var remove
: Boolean): Boolean; override;
483 function Heal(value
: Word; Soft
: Boolean): Boolean; override;
484 procedure Update(); override;
485 procedure SaveState (st
: TStream
); override;
486 procedure LoadState (st
: TStream
); override;
498 procedure getMapBox (out x
, y
, w
, h
: Integer); inline;
499 procedure moveBy (dx
, dy
: Integer); inline;
501 procedure positionChanged (); inline; //WARNING! call this after entity position was changed, or coldet will not work right!
515 procedure getMapBox (out x
, y
, w
, h
: Integer); inline;
516 procedure moveBy (dx
, dy
: Integer); inline;
518 procedure positionChanged (); inline; //WARNING! call this after entity position was changed, or coldet will not work right!
521 TCorpse
= class{$IFDEF USE_MEMPOOL}(TPoolObject
){$ENDIF}
530 FAnimation
: TAnimation
;
531 FAnimationMask
: TAnimation
;
534 constructor Create(X
, Y
: Integer; ModelName
: String; aMess
: Boolean);
535 destructor Destroy(); override;
536 procedure Damage(Value
: Word; SpawnerUID
: Word; vx
, vy
: Integer);
539 procedure SaveState (st
: TStream
);
540 procedure LoadState (st
: TStream
);
542 procedure getMapBox (out x
, y
, w
, h
: Integer); inline;
543 procedure moveBy (dx
, dy
: Integer); inline;
545 procedure positionChanged (); inline; //WARNING! call this after entity position was changed, or coldet will not work right!
547 function ObjPtr (): PObj
; inline;
549 property Obj
: TObj read FObj
; // copies object
550 property State
: Byte read FState
;
551 property Mess
: Boolean read FMess
;
554 TTeamStat
= Array [TEAM_RED
..TEAM_BLUE
] of
560 gPlayers
: Array of TPlayer
;
561 gCorpses
: Array of TCorpse
;
562 gGibs
: Array of TGib
;
563 gShells
: Array of TShell
;
564 gTeamStat
: TTeamStat
;
565 gFly
: Boolean = False;
566 gAimLine
: Boolean = False;
567 gChatBubble
: Integer = 0;
568 gPlayerIndicator
: Integer = 1;
569 gPlayerIndicatorStyle
: Integer = 0;
571 gSpectLatchPID1
: Word = 0;
572 gSpectLatchPID2
: Word = 0;
573 MAX_RUNVEL
: Integer = 8;
574 VEL_JUMP
: Integer = 10;
575 SHELL_TIMEOUT
: Cardinal = 60000;
577 function Lerp(X
, Y
, Factor
: Integer): Integer;
579 procedure g_Gibs_SetMax(Count
: Word);
580 function g_Gibs_GetMax(): Word;
581 procedure g_Corpses_SetMax(Count
: Word);
582 function g_Corpses_GetMax(): Word;
583 procedure g_Shells_SetMax(Count
: Word);
584 function g_Shells_GetMax(): Word;
586 procedure g_Player_Init();
587 procedure g_Player_Free();
588 function g_Player_Create(ModelName
: String; Color
: TRGB
; Team
: Byte; Bot
: Boolean): Word;
589 function g_Player_CreateFromState (st
: TStream
): Word;
590 procedure g_Player_Remove(UID
: Word);
591 procedure g_Player_ResetTeams();
592 procedure g_Player_PreUpdate();
593 procedure g_Player_UpdateAll();
594 procedure g_Player_DrawAll();
595 procedure g_Player_DrawDebug(p
: TPlayer
);
596 procedure g_Player_DrawHealth();
597 procedure g_Player_RememberAll();
598 procedure g_Player_ResetAll(Force
, Silent
: Boolean);
599 function g_Player_Get(UID
: Word): TPlayer
;
600 function g_Player_GetCount(): Byte;
601 function g_Player_GetStats(): TPlayerStatArray
;
602 function g_Player_ValidName(Name
: String): Boolean;
603 function g_Player_CreateCorpse(Player
: TPlayer
): Integer;
604 procedure g_Player_CreateGibs(fX
, fY
: Integer; ModelName
: String; fColor
: TRGB
);
605 procedure g_Player_CreateShell(fX
, fY
, dX
, dY
: Integer; T
: Byte);
606 procedure g_Player_UpdatePhysicalObjects();
607 procedure g_Player_DrawCorpses();
608 procedure g_Player_DrawShells();
609 procedure g_Player_RemoveAllCorpses();
610 procedure g_Player_Corpses_SaveState (st
: TStream
);
611 procedure g_Player_Corpses_LoadState (st
: TStream
);
612 procedure g_Player_ResetReady();
613 procedure g_Bot_Add(Team
, Difficult
: Byte; Handicap
: Integer = 100);
614 procedure g_Bot_AddList(Team
: Byte; lname
: ShortString; num
: Integer = -1; Handicap
: Integer = 100);
615 procedure g_Bot_MixNames();
616 procedure g_Bot_RemoveAll();
621 {$INCLUDE ../nogl/noGLuses.inc}
622 {$IFDEF ENABLE_HOLMES}
625 e_log
, g_map
, g_items
, g_console
, g_gfx
, Math
,
626 g_options
, g_triggers
, g_menu
, g_game
, g_grid
, e_res
,
627 wadreader
, g_main
, g_monsters
, CONFIG
, g_language
,
628 g_net
, g_netmsg
, g_window
,
631 const PLR_SAVE_VERSION
= 0;
641 diag_precision
: Byte;
645 w_prior1
: Array [WP_FIRST
..WP_LAST
] of Byte;
646 w_prior2
: Array [WP_FIRST
..WP_LAST
] of Byte;
647 w_prior3
: Array [WP_FIRST
..WP_LAST
] of Byte;
651 TIME_RESPAWN1
= 1500;
652 TIME_RESPAWN2
= 2000;
653 TIME_RESPAWN3
= 3000;
656 JET_MAX
= 540; // ~30 sec
657 PLAYER_SUIT_TIME
= 30000;
658 PLAYER_INVUL_TIME
= 30000;
659 PLAYER_INVIS_TIME
= 35000;
660 FRAG_COMBO_TIME
= 3000;
664 ANGLE_RIGHTDOWN
= -35;
666 ANGLE_LEFTDOWN
= -145;
667 PLAYER_HEADRECT
: TRectWH
= (X
:24; Y
:12; Width
:20; Height
:12);
668 WEAPONPOINT
: Array [TDirection
] of TDFPoint
= ((X
:16; Y
:32), (X
:47; Y
:32));
671 BOT_UNSAFEDIST
= 128;
672 TEAMCOLOR
: Array [TEAM_RED
..TEAM_BLUE
] of TRGB
= ((R
:255; G
:0; B
:0),
674 DIFFICULT_EASY
: TDifficult
= (DiagFire
: 32; InvisFire
: 32; DiagPrecision
: 32;
675 FlyPrecision
: 32; Cover
: 32; CloseJump
: 32;
676 WeaponPrior
:(0,0,0,0,0,0,0,0,0,0,0); CloseWeaponPrior
:(0,0,0,0,0,0,0,0,0,0,0));
677 DIFFICULT_MEDIUM
: TDifficult
= (DiagFire
: 127; InvisFire
: 127; DiagPrecision
: 127;
678 FlyPrecision
: 127; Cover
: 127; CloseJump
: 127;
679 WeaponPrior
:(0,0,0,0,0,0,0,0,0,0,0); CloseWeaponPrior
:(0,0,0,0,0,0,0,0,0,0,0));
680 DIFFICULT_HARD
: TDifficult
= (DiagFire
: 255; InvisFire
: 255; DiagPrecision
: 255;
681 FlyPrecision
: 255; Cover
: 255; CloseJump
: 255;
682 WeaponPrior
:(0,0,0,0,0,0,0,0,0,0,0); CloseWeaponPrior
:(0,0,0,0,0,0,0,0,0,0,0));
683 WEAPON_PRIOR1
: Array [WP_FIRST
..WP_LAST
] of Byte =
684 (WEAPON_FLAMETHROWER
, WEAPON_SUPERPULEMET
,
685 WEAPON_SHOTGUN2
, WEAPON_SHOTGUN1
,
686 WEAPON_CHAINGUN
, WEAPON_PLASMA
, WEAPON_ROCKETLAUNCHER
,
687 WEAPON_BFG
, WEAPON_PISTOL
, WEAPON_SAW
, WEAPON_KASTET
);
688 WEAPON_PRIOR2
: Array [WP_FIRST
..WP_LAST
] of Byte =
689 (WEAPON_FLAMETHROWER
, WEAPON_SUPERPULEMET
,
690 WEAPON_BFG
, WEAPON_ROCKETLAUNCHER
,
691 WEAPON_SHOTGUN2
, WEAPON_PLASMA
, WEAPON_SHOTGUN1
,
692 WEAPON_CHAINGUN
, WEAPON_PISTOL
, WEAPON_SAW
, WEAPON_KASTET
);
693 //WEAPON_PRIOR3: Array [WP_FIRST..WP_LAST] of Byte =
694 // (WEAPON_FLAMETHROWER, WEAPON_SUPERPULEMET,
695 // WEAPON_BFG, WEAPON_PLASMA, WEAPON_SHOTGUN2,
696 // WEAPON_CHAINGUN, WEAPON_SHOTGUN1, WEAPON_SAW,
697 // WEAPON_ROCKETLAUNCHER, WEAPON_PISTOL, WEAPON_KASTET);
698 WEAPON_RELOAD
: Array [WP_FIRST
..WP_LAST
] of Byte =
699 (5, 2, 6, 18, 36, 2, 12, 2, 14, 2, 2);
701 PLAYER_SIGNATURE
= $52594C50; // 'PLYR'
702 CORPSE_SIGNATURE
= $50524F43; // 'CORP'
704 BOTNAMES_FILENAME
= 'botnames.txt';
705 BOTLIST_FILENAME
= 'botlist.txt';
709 MaxCorpses
: Word = 20;
710 MaxShells
: Word = 300;
711 CurrentGib
: Integer = 0;
712 CurrentShell
: Integer = 0;
713 BotNames
: Array of String;
714 BotList
: Array of TBotProfile
;
715 SavedStates
: Array of TPlayerSavedState
;
718 function Lerp(X
, Y
, Factor
: Integer): Integer;
720 Result
:= X
+ ((Y
- X
) div Factor
);
723 function SameTeam(UID1
, UID2
: Word): Boolean;
727 if (UID1
> UID_MAX_PLAYER
) or (UID1
<= UID_MAX_GAME
) or
728 (UID2
> UID_MAX_PLAYER
) or (UID2
<= UID_MAX_GAME
) then Exit
;
730 if (g_Player_Get(UID1
) = nil) or (g_Player_Get(UID2
) = nil) then Exit
;
732 if ((g_Player_Get(UID1
).Team
= TEAM_NONE
) or
733 (g_Player_Get(UID2
).Team
= TEAM_NONE
)) then Exit
;
735 Result
:= g_Player_Get(UID1
).FTeam
= g_Player_Get(UID2
).FTeam
;
738 procedure g_Gibs_SetMax(Count
: Word);
741 SetLength(gGibs
, Count
);
743 if CurrentGib
>= Count
then
747 function g_Gibs_GetMax(): Word;
752 procedure g_Shells_SetMax(Count
: Word);
755 SetLength(gShells
, Count
);
757 if CurrentShell
>= Count
then
761 function g_Shells_GetMax(): Word;
767 procedure g_Corpses_SetMax(Count
: Word);
770 SetLength(gCorpses
, Count
);
773 function g_Corpses_GetMax(): Word;
775 Result
:= MaxCorpses
;
778 function g_Player_Create(ModelName
: String; Color
: TRGB
; Team
: Byte; Bot
: Boolean): Word;
788 // Åñòü ëè ìåñòî â gPlayers:
789 if gPlayers
<> nil then
790 for a
:= 0 to High(gPlayers
) do
791 if gPlayers
[a
] = nil then
797 // Íåò ìåñòà - ðàñøèðÿåì gPlayers:
800 SetLength(gPlayers
, Length(gPlayers
)+1);
804 // Ñîçäàåì îáúåêò èãðîêà:
806 gPlayers
[a
] := TBot
.Create()
808 gPlayers
[a
] := TPlayer
.Create();
811 gPlayers
[a
].FActualModelName
:= ModelName
;
812 gPlayers
[a
].SetModel(ModelName
);
814 // Íåò ìîäåëè - ñîçäàíèå íå âîçìîæíî:
815 if gPlayers
[a
].FModel
= nil then
819 g_FatalError(Format(_lc
[I_GAME_ERROR_MODEL
], [ModelName
]));
823 if not (Team
in [TEAM_RED
, TEAM_BLUE
]) then
824 if Random(2) = 0 then
828 gPlayers
[a
].FPreferredTeam
:= Team
;
830 case gGameSettings
.GameMode
of
831 GM_DM
: gPlayers
[a
].FTeam
:= TEAM_NONE
;
833 GM_CTF
: gPlayers
[a
].FTeam
:= gPlayers
[a
].FPreferredTeam
;
835 GM_COOP
: gPlayers
[a
].FTeam
:= TEAM_COOP
;
838 // Åñëè êîìàíäíàÿ èãðà - êðàñèì ìîäåëü â öâåò êîìàíäû:
839 gPlayers
[a
].FColor
:= Color
;
840 if gPlayers
[a
].FTeam
in [TEAM_RED
, TEAM_BLUE
] then
841 gPlayers
[a
].FModel
.Color
:= TEAMCOLOR
[gPlayers
[a
].FTeam
]
843 gPlayers
[a
].FModel
.Color
:= Color
;
845 gPlayers
[a
].FUID
:= g_CreateUID(UID_PLAYER
);
846 gPlayers
[a
].FAlive
:= False;
848 Result
:= gPlayers
[a
].FUID
;
851 function g_Player_CreateFromState (st
: TStream
): Word;
858 if (st
= nil) then exit
; //???
861 if not utils
.checkSign(st
, 'PLYR') then raise XStreamError
.Create('invalid player signature');
862 if (utils
.readByte(st
) <> PLR_SAVE_VERSION
) then raise XStreamError
.Create('invalid player version');
865 Bot
:= utils
.readBool(st
);
870 // Åñòü ëè ìåñòî â gPlayers:
871 for a
:= 0 to High(gPlayers
) do if (gPlayers
[a
] = nil) then begin ok
:= true; break
; end;
873 // Íåò ìåñòà - ðàñøèðÿåì gPlayers
876 SetLength(gPlayers
, Length(gPlayers
)+1);
880 // Ñîçäàåì îáúåêò èãðîêà
882 gPlayers
[a
] := TBot
.Create()
884 gPlayers
[a
] := TPlayer
.Create();
885 gPlayers
[a
].FIamBot
:= Bot
;
886 gPlayers
[a
].FPhysics
:= True;
889 gPlayers
[a
].FUID
:= utils
.readWord(st
);
891 gPlayers
[a
].FName
:= utils
.readStr(st
);
893 gPlayers
[a
].FTeam
:= utils
.readByte(st
);
894 gPlayers
[a
].FPreferredTeam
:= gPlayers
[a
].FTeam
;
896 gPlayers
[a
].FAlive
:= utils
.readBool(st
);
897 // Èçðàñõîäîâàë ëè âñå æèçíè
898 gPlayers
[a
].FNoRespawn
:= utils
.readBool(st
);
900 b
:= utils
.readByte(st
);
901 if b
= 1 then gPlayers
[a
].FDirection
:= TDirection
.D_LEFT
else gPlayers
[a
].FDirection
:= TDirection
.D_RIGHT
; // b = 2
903 gPlayers
[a
].FHealth
:= utils
.readLongInt(st
);
905 gPlayers
[a
].FHandicap
:= utils
.readLongInt(st
);
907 gPlayers
[a
].FLives
:= utils
.readByte(st
);
909 gPlayers
[a
].FArmor
:= utils
.readLongInt(st
);
911 gPlayers
[a
].FAir
:= utils
.readLongInt(st
);
913 gPlayers
[a
].FJetFuel
:= utils
.readLongInt(st
);
915 gPlayers
[a
].FPain
:= utils
.readLongInt(st
);
917 gPlayers
[a
].FKills
:= utils
.readLongInt(st
);
919 gPlayers
[a
].FMonsterKills
:= utils
.readLongInt(st
);
921 gPlayers
[a
].FFrags
:= utils
.readLongInt(st
);
923 gPlayers
[a
].FFragCombo
:= utils
.readByte(st
);
924 // Âðåìÿ ïîñëåäíåãî ôðàãà
925 gPlayers
[a
].FLastFrag
:= utils
.readLongWord(st
);
927 gPlayers
[a
].FDeath
:= utils
.readLongInt(st
);
929 gPlayers
[a
].FFlag
:= utils
.readByte(st
);
931 gPlayers
[a
].FSecrets
:= utils
.readLongInt(st
);
933 gPlayers
[a
].FCurrWeap
:= utils
.readByte(st
);
934 // Ñëåäóþùåå æåëàåìîå îðóæèå
935 gPlayers
[a
].FNextWeap
:= utils
.readWord(st
);
937 gPlayers
[a
].FNextWeapDelay
:= utils
.readByte(st
);
939 gPlayers
[a
].FBFGFireCounter
:= utils
.readSmallInt(st
);
941 gPlayers
[a
].FDamageBuffer
:= utils
.readLongInt(st
);
942 // Ïîñëåäíèé óäàðèâøèé
943 gPlayers
[a
].FLastSpawnerUID
:= utils
.readWord(st
);
944 // Òèï ïîñëåäíåãî ïîëó÷åííîãî óðîíà
945 gPlayers
[a
].FLastHit
:= utils
.readByte(st
);
947 Obj_LoadState(@gPlayers
[a
].FObj
, st
);
948 // Òåêóùåå êîëè÷åñòâî ïàòðîíîâ
949 for i
:= A_BULLETS
to A_HIGH
do gPlayers
[a
].FAmmo
[i
] := utils
.readWord(st
);
950 // Ìàêñèìàëüíîå êîëè÷åñòâî ïàòðîíîâ
951 for i
:= A_BULLETS
to A_HIGH
do gPlayers
[a
].FMaxAmmo
[i
] := utils
.readWord(st
);
953 for i
:= WP_FIRST
to WP_LAST
do gPlayers
[a
].FWeapon
[i
] := utils
.readBool(st
);
954 // Âðåìÿ ïåðåçàðÿäêè îðóæèÿ
955 for i
:= WP_FIRST
to WP_LAST
do gPlayers
[a
].FReloading
[i
] := utils
.readWord(st
);
957 if utils
.readBool(st
) then Include(gPlayers
[a
].FRulez
, R_ITEM_BACKPACK
);
958 // Íàëè÷èå êðàñíîãî êëþ÷à
959 if utils
.readBool(st
) then Include(gPlayers
[a
].FRulez
, R_KEY_RED
);
960 // Íàëè÷èå çåëåíîãî êëþ÷à
961 if utils
.readBool(st
) then Include(gPlayers
[a
].FRulez
, R_KEY_GREEN
);
962 // Íàëè÷èå ñèíåãî êëþ÷à
963 if utils
.readBool(st
) then Include(gPlayers
[a
].FRulez
, R_KEY_BLUE
);
965 if utils
.readBool(st
) then Include(gPlayers
[a
].FRulez
, R_BERSERK
);
966 // Âðåìÿ äåéñòâèÿ ñïåöèàëüíûõ ïðåäìåòîâ
967 for i
:= MR_SUIT
to MR_MAX
do gPlayers
[a
].FMegaRulez
[i
] := utils
.readLongWord(st
);
968 // Âðåìÿ äî ïîâòîðíîãî ðåñïàóíà, ñìåíû îðóæèÿ, èñîëüçîâàíèÿ, çàõâàòà ôëàãà
969 for i
:= T_RESPAWN
to T_FLAGCAP
do gPlayers
[a
].FTime
[i
] := utils
.readLongWord(st
);
972 gPlayers
[a
].FActualModelName
:= utils
.readStr(st
);
974 gPlayers
[a
].FColor
.R
:= utils
.readByte(st
);
975 gPlayers
[a
].FColor
.G
:= utils
.readByte(st
);
976 gPlayers
[a
].FColor
.B
:= utils
.readByte(st
);
977 // Îáíîâëÿåì ìîäåëü èãðîêà
978 gPlayers
[a
].SetModel(gPlayers
[a
].FActualModelName
);
980 // Íåò ìîäåëè - ñîçäàíèå íåâîçìîæíî
981 if (gPlayers
[a
].FModel
= nil) then
985 g_FatalError(Format(_lc
[I_GAME_ERROR_MODEL
], [gPlayers
[a
].FActualModelName
]));
989 // Åñëè êîìàíäíàÿ èãðà - êðàñèì ìîäåëü â öâåò êîìàíäû
990 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
991 gPlayers
[a
].FModel
.Color
:= TEAMCOLOR
[gPlayers
[a
].FTeam
]
993 gPlayers
[a
].FModel
.Color
:= gPlayers
[a
].FColor
;
995 result
:= gPlayers
[a
].FUID
;
999 procedure g_Player_ResetTeams();
1003 if g_Game_IsClient
then
1005 if gPlayers
= nil then
1007 for a
:= Low(gPlayers
) to High(gPlayers
) do
1008 if gPlayers
[a
] <> nil then
1009 case gGameSettings
.GameMode
of
1011 gPlayers
[a
].ChangeTeam(TEAM_NONE
);
1013 if not (gPlayers
[a
].Team
in [TEAM_RED
, TEAM_BLUE
]) then
1014 if gPlayers
[a
].FPreferredTeam
in [TEAM_RED
, TEAM_BLUE
] then
1015 gPlayers
[a
].ChangeTeam(gPlayers
[a
].FPreferredTeam
)
1018 gPlayers
[a
].ChangeTeam(TEAM_RED
)
1020 gPlayers
[a
].ChangeTeam(TEAM_BLUE
);
1023 gPlayers
[a
].ChangeTeam(TEAM_COOP
);
1027 procedure g_Bot_Add(Team
, Difficult
: Byte; Handicap
: Integer = 100);
1030 _name
, _model
: String;
1033 if not g_Game_IsServer
then Exit
;
1035 // Ñïèñîê íàçâàíèé ìîäåëåé:
1036 m
:= g_PlayerModel_GetNames();
1041 if (gGameSettings
.GameType
= GT_SINGLE
) or (gGameSettings
.GameMode
= GM_COOP
) then
1042 Team
:= TEAM_COOP
// COOP
1044 if gGameSettings
.GameMode
= GM_DM
then
1045 Team
:= TEAM_NONE
// DM
1047 if Team
= TEAM_NONE
then // CTF / TDM
1049 // Àâòîáàëàíñ êîìàíä:
1053 for a
:= 0 to High(gPlayers
) do
1054 if gPlayers
[a
] <> nil then
1056 if gPlayers
[a
].Team
= TEAM_RED
then
1059 if gPlayers
[a
].Team
= TEAM_BLUE
then
1069 if Random(2) = 0 then
1075 // Âûáèðàåì áîòó èìÿ:
1077 if BotNames
<> nil then
1078 for a
:= 0 to High(BotNames
) do
1079 if g_Player_ValidName(BotNames
[a
]) then
1081 _name
:= BotNames
[a
];
1085 // Âûáèðàåì ñëó÷àéíóþ ìîäåëü:
1086 _model
:= m
[Random(Length(m
))];
1089 with g_Player_Get(g_Player_Create(_model
,
1090 _RGB(Min(Random(9)*32, 255),
1091 Min(Random(9)*32, 255),
1092 Min(Random(9)*32, 255)),
1093 Team
, True)) as TBot
do
1095 // Åñëè èìåíè íåò, äåëàåì åãî èç UID áîòà
1097 Name
:= Format('DFBOT%.5d', [UID
])
1102 1: FDifficult
:= DIFFICULT_EASY
;
1103 2: FDifficult
:= DIFFICULT_MEDIUM
;
1104 else FDifficult
:= DIFFICULT_HARD
;
1107 for a
:= WP_FIRST
to WP_LAST
do
1109 FDifficult
.WeaponPrior
[a
] := WEAPON_PRIOR1
[a
];
1110 FDifficult
.CloseWeaponPrior
[a
] := WEAPON_PRIOR2
[a
];
1111 //FDifficult.SafeWeaponPrior[a] := WEAPON_PRIOR3[a];
1114 FHandicap
:= Handicap
;
1116 g_Console_Add(Format(_lc
[I_PLAYER_JOIN
], [Name
]), True);
1118 if g_Game_IsNet
then MH_SEND_PlayerCreate(UID
);
1119 if g_Game_IsServer
and (gGameSettings
.MaxLives
> 0) then
1124 procedure g_Bot_AddList(Team
: Byte; lName
: ShortString; num
: Integer = -1; Handicap
: Integer = 100);
1127 _name
, _model
: String;
1130 if not g_Game_IsServer
then Exit
;
1132 // Ñïèñîê íàçâàíèé ìîäåëåé:
1133 m
:= g_PlayerModel_GetNames();
1138 if (gGameSettings
.GameType
= GT_SINGLE
) or (gGameSettings
.GameMode
= GM_COOP
) then
1139 Team
:= TEAM_COOP
// COOP
1141 if gGameSettings
.GameMode
= GM_DM
then
1142 Team
:= TEAM_NONE
// DM
1144 if Team
= TEAM_NONE
then
1145 Team
:= BotList
[num
].team
; // CTF / TDM
1147 // Âûáèðàåì íàñòðîéêè áîòà èç ñïèñêà ïî íîìåðó èëè èìåíè:
1148 lName
:= AnsiLowerCase(lName
);
1149 if (num
< 0) or (num
> Length(BotList
)-1) then
1151 if (num
= -1) and (lName
<> '') and (BotList
<> nil) then
1152 for a
:= 0 to High(BotList
) do
1153 if AnsiLowerCase(BotList
[a
].name
) = lName
then
1162 _name
:= BotList
[num
].name
;
1163 // Çàíÿòî - âûáèðàåì ñëó÷àéíîå:
1164 if not g_Player_ValidName(_name
) then
1166 _name
:= Format('DFBOT%.2d', [Random(100)]);
1167 until g_Player_ValidName(_name
);
1170 _model
:= BotList
[num
].model
;
1171 // Íåò òàêîé - âûáèðàåì ñëó÷àéíóþ:
1172 if not InSArray(_model
, m
) then
1173 _model
:= m
[Random(Length(m
))];
1176 with g_Player_Get(g_Player_Create(_model
, BotList
[num
].color
, Team
, True)) as TBot
do
1180 FDifficult
.DiagFire
:= BotList
[num
].diag_fire
;
1181 FDifficult
.InvisFire
:= BotList
[num
].invis_fire
;
1182 FDifficult
.DiagPrecision
:= BotList
[num
].diag_precision
;
1183 FDifficult
.FlyPrecision
:= BotList
[num
].fly_precision
;
1184 FDifficult
.Cover
:= BotList
[num
].cover
;
1185 FDifficult
.CloseJump
:= BotList
[num
].close_jump
;
1187 FHandicap
:= Handicap
;
1189 for a
:= WP_FIRST
to WP_LAST
do
1191 FDifficult
.WeaponPrior
[a
] := BotList
[num
].w_prior1
[a
];
1192 FDifficult
.CloseWeaponPrior
[a
] := BotList
[num
].w_prior2
[a
];
1193 //FDifficult.SafeWeaponPrior[a] := BotList[num].w_prior3[a];
1196 g_Console_Add(Format(_lc
[I_PLAYER_JOIN
], [Name
]), True);
1198 if g_Game_IsNet
then MH_SEND_PlayerCreate(UID
);
1202 procedure g_Bot_RemoveAll();
1206 if not g_Game_IsServer
then Exit
;
1207 if gPlayers
= nil then Exit
;
1209 for a
:= 0 to High(gPlayers
) do
1210 if gPlayers
[a
] <> nil then
1211 if gPlayers
[a
] is TBot
then
1213 gPlayers
[a
].Lives
:= 0;
1214 gPlayers
[a
].Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
1215 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [gPlayers
[a
].Name
]), True);
1216 g_Player_Remove(gPlayers
[a
].FUID
);
1222 procedure g_Bot_MixNames();
1227 if BotNames
<> nil then
1228 for a
:= 0 to High(BotNames
) do
1230 b
:= Random(Length(BotNames
));
1232 Botnames
[a
] := BotNames
[b
];
1237 procedure g_Player_Remove(UID
: Word);
1241 if gPlayers
= nil then Exit
;
1243 if g_Game_IsServer
and g_Game_IsNet
then
1244 MH_SEND_PlayerDelete(UID
);
1246 for i
:= 0 to High(gPlayers
) do
1247 if gPlayers
[i
] <> nil then
1248 if gPlayers
[i
].FUID
= UID
then
1250 if gPlayers
[i
] is TPlayer
then
1251 TPlayer(gPlayers
[i
]).Free()
1253 TBot(gPlayers
[i
]).Free();
1259 procedure g_Player_Init();
1270 path
:= BOTNAMES_FILENAME
;
1271 if e_FindResource(DataDirs
, path
) = false then
1274 // ×èòàåì âîçìîæíûå èìåíà áîòîâ èç ôàéëà:
1275 AssignFile(F
, path
);
1286 SetLength(BotNames
, Length(BotNames
)+1);
1287 BotNames
[High(BotNames
)] := s
;
1295 // ×èòàåì ôàéë ñ ïàðàìåòðàìè áîòîâ:
1296 config
:= TConfig
.CreateFile(path
);
1300 while config
.SectionExists(IntToStr(a
)) do
1302 SetLength(BotList
, Length(BotList
)+1);
1304 with BotList
[High(BotList
)] do
1307 name
:= config
.ReadStr(IntToStr(a
), 'name', '');
1309 model
:= config
.ReadStr(IntToStr(a
), 'model', '');
1311 if config
.ReadStr(IntToStr(a
), 'team', 'red') = 'red' then
1316 sa
:= parse(config
.ReadStr(IntToStr(a
), 'color', ''));
1317 color
.R
:= StrToIntDef(sa
[0], 0);
1318 color
.G
:= StrToIntDef(sa
[1], 0);
1319 color
.B
:= StrToIntDef(sa
[2], 0);
1320 // Âåðîÿòíîñòü ñòðåëüáû ïîä óãëîì:
1321 diag_fire
:= config
.ReadInt(IntToStr(a
), 'diag_fire', 0);
1322 // Âåðîÿòíîñòü îòâåòíîãî îãíÿ ïî íåâèäèìîìó ñîïåðíèêó:
1323 invis_fire
:= config
.ReadInt(IntToStr(a
), 'invis_fire', 0);
1324 // Òî÷íîñòü ñòðåëüáû ïîä óãëîì:
1325 diag_precision
:= config
.ReadInt(IntToStr(a
), 'diag_precision', 0);
1326 // Òî÷íîñòü ñòðåëüáû â ïîëåòå:
1327 fly_precision
:= config
.ReadInt(IntToStr(a
), 'fly_precision', 0);
1328 // Òî÷íîñòü óêëîíåíèÿ îò ñíàðÿäîâ:
1329 cover
:= config
.ReadInt(IntToStr(a
), 'cover', 0);
1330 // Âåðîÿòíîñòü ïðûæêà ïðè ïðèáëèæåíèè ñîïåðíèêà:
1331 close_jump
:= config
.ReadInt(IntToStr(a
), 'close_jump', 0);
1332 // Ïðèîðèòåòû îðóæèÿ äëÿ äàëüíåãî áîÿ:
1333 sa
:= parse(config
.ReadStr(IntToStr(a
), 'w_prior1', ''));
1334 if Length(sa
) = 10 then
1336 w_prior1
[b
] := EnsureRange(StrToInt(sa
[b
]), 0, 9);
1337 // Ïðèîðèòåòû îðóæèÿ äëÿ áëèæíåãî áîÿ:
1338 sa
:= parse(config
.ReadStr(IntToStr(a
), 'w_prior2', ''));
1339 if Length(sa
) = 10 then
1341 w_prior2
[b
] := EnsureRange(StrToInt(sa
[b
]), 0, 9);
1343 {sa := parse(config.ReadStr(IntToStr(a), 'w_prior3', ''));
1344 if Length(sa) = 10 then
1346 w_prior3[b] := EnsureRange(StrToInt(sa[b]), 0, 9);}
1353 SetLength(SavedStates
, 0);
1356 procedure g_Player_Free();
1360 if gPlayers
<> nil then
1362 for i
:= 0 to High(gPlayers
) do
1363 if gPlayers
[i
] <> nil then
1365 if gPlayers
[i
] is TPlayer
then
1366 TPlayer(gPlayers
[i
]).Free()
1368 TBot(gPlayers
[i
]).Free();
1377 SetLength(SavedStates
, 0);
1380 procedure g_Player_PreUpdate();
1384 if gPlayers
= nil then Exit
;
1385 for i
:= 0 to High(gPlayers
) do
1386 if gPlayers
[i
] <> nil then
1387 gPlayers
[i
].PreUpdate();
1390 procedure g_Player_UpdateAll();
1394 if gPlayers
= nil then Exit
;
1396 //e_WriteLog('***g_Player_UpdateAll: ENTER', MSG_WARNING);
1397 for i
:= 0 to High(gPlayers
) do
1399 if gPlayers
[i
] <> nil then
1401 if gPlayers
[i
] is TPlayer
then
1403 gPlayers
[i
].Update();
1404 gPlayers
[i
].RealizeCurrentWeapon(); // WARNING! DO NOT MOVE THIS INTO `Update()`!
1408 // bot updates weapons in `UpdateCombat()`
1409 TBot(gPlayers
[i
]).Update();
1413 //e_WriteLog('***g_Player_UpdateAll: EXIT', MSG_WARNING);
1416 procedure g_Player_DrawAll();
1420 if gPlayers
= nil then Exit
;
1422 for i
:= 0 to High(gPlayers
) do
1423 if gPlayers
[i
] <> nil then
1424 if gPlayers
[i
] is TPlayer
then gPlayers
[i
].Draw()
1425 else TBot(gPlayers
[i
]).Draw();
1428 procedure g_Player_DrawDebug(p
: TPlayer
);
1432 if p
= nil then Exit
;
1433 if (@p
.FObj
) = nil then Exit
;
1435 e_TextureFontGetSize(gStdFont
, fW
, fH
);
1437 e_TextureFontPrint(0, 0 , 'Pos X: ' + IntToStr(p
.FObj
.X
), gStdFont
);
1438 e_TextureFontPrint(0, fH
, 'Pos Y: ' + IntToStr(p
.FObj
.Y
), gStdFont
);
1439 e_TextureFontPrint(0, fH
* 2, 'Vel X: ' + IntToStr(p
.FObj
.Vel
.X
), gStdFont
);
1440 e_TextureFontPrint(0, fH
* 3, 'Vel Y: ' + IntToStr(p
.FObj
.Vel
.Y
), gStdFont
);
1441 e_TextureFontPrint(0, fH
* 4, 'Acc X: ' + IntToStr(p
.FObj
.Accel
.X
), gStdFont
);
1442 e_TextureFontPrint(0, fH
* 5, 'Acc Y: ' + IntToStr(p
.FObj
.Accel
.Y
), gStdFont
);
1443 e_TextureFontPrint(0, fH
* 6, 'Old X: ' + IntToStr(p
.FObj
.oldX
), gStdFont
);
1444 e_TextureFontPrint(0, fH
* 7, 'Old Y: ' + IntToStr(p
.FObj
.oldY
), gStdFont
);
1447 procedure g_Player_DrawHealth();
1452 if gPlayers
= nil then Exit
;
1453 e_TextureFontGetSize(gStdFont
, fW
, fH
);
1455 for i
:= 0 to High(gPlayers
) do
1456 if gPlayers
[i
] <> nil then
1458 e_TextureFontPrint(gPlayers
[i
].FObj
.X
+ gPlayers
[i
].FObj
.Rect
.X
,
1459 gPlayers
[i
].FObj
.Y
+ gPlayers
[i
].FObj
.Rect
.Y
+ gPlayers
[i
].FObj
.Rect
.Height
- fH
* 2,
1460 IntToStr(gPlayers
[i
].FHealth
), gStdFont
);
1461 e_TextureFontPrint(gPlayers
[i
].FObj
.X
+ gPlayers
[i
].FObj
.Rect
.X
,
1462 gPlayers
[i
].FObj
.Y
+ gPlayers
[i
].FObj
.Rect
.Y
+ gPlayers
[i
].FObj
.Rect
.Height
- fH
,
1463 IntToStr(gPlayers
[i
].FArmor
), gStdFont
);
1467 function g_Player_Get(UID
: Word): TPlayer
;
1473 if gPlayers
= nil then
1476 for a
:= 0 to High(gPlayers
) do
1477 if gPlayers
[a
] <> nil then
1478 if gPlayers
[a
].FUID
= UID
then
1480 Result
:= gPlayers
[a
];
1485 function g_Player_GetCount(): Byte;
1491 if gPlayers
= nil then
1494 for a
:= 0 to High(gPlayers
) do
1495 if gPlayers
[a
] <> nil then
1496 Result
:= Result
+ 1;
1499 function g_Player_GetStats(): TPlayerStatArray
;
1505 if gPlayers
= nil then Exit
;
1507 for a
:= 0 to High(gPlayers
) do
1508 if gPlayers
[a
] <> nil then
1510 SetLength(Result
, Length(Result
)+1);
1511 with Result
[High(Result
)] do
1514 Ping
:= gPlayers
[a
].FPing
;
1515 Loss
:= gPlayers
[a
].FLoss
;
1516 Name
:= gPlayers
[a
].FName
;
1517 Team
:= gPlayers
[a
].FTeam
;
1518 Frags
:= gPlayers
[a
].FFrags
;
1519 Deaths
:= gPlayers
[a
].FDeath
;
1520 Kills
:= gPlayers
[a
].FKills
;
1521 Color
:= gPlayers
[a
].FModel
.Color
;
1522 Lives
:= gPlayers
[a
].FLives
;
1523 Spectator
:= gPlayers
[a
].FSpectator
;
1528 procedure g_Player_ResetReady();
1532 if not g_Game_IsServer
then Exit
;
1533 if gPlayers
= nil then Exit
;
1535 for a
:= 0 to High(gPlayers
) do
1536 if gPlayers
[a
] <> nil then
1538 gPlayers
[a
].FReady
:= False;
1539 if g_Game_IsNet
then
1540 MH_SEND_GameEvent(NET_EV_INTER_READY
, gPlayers
[a
].UID
, 'N');
1544 procedure g_Player_RememberAll
;
1548 for i
:= Low(gPlayers
) to High(gPlayers
) do
1549 if (gPlayers
[i
] <> nil) and gPlayers
[i
].alive
then
1550 gPlayers
[i
].RememberState
;
1553 procedure g_Player_ResetAll(Force
, Silent
: Boolean);
1557 gTeamStat
[TEAM_RED
].Goals
:= 0;
1558 gTeamStat
[TEAM_BLUE
].Goals
:= 0;
1560 if gPlayers
<> nil then
1561 for i
:= 0 to High(gPlayers
) do
1562 if gPlayers
[i
] <> nil then
1564 gPlayers
[i
].Reset(Force
);
1566 if gPlayers
[i
] is TPlayer
then
1568 if (not gPlayers
[i
].FSpectator
) or gPlayers
[i
].FWantsInGame
then
1569 gPlayers
[i
].Respawn(Silent
)
1571 gPlayers
[i
].Spectate();
1574 TBot(gPlayers
[i
]).Respawn(Silent
);
1578 function g_Player_CreateCorpse(Player
: TPlayer
): Integer;
1586 if Player
.alive
then
1589 // Ðàçðûâàåì ñâÿçü ñ ïðåæíèì òðóïîì:
1590 i
:= Player
.FCorpse
;
1591 if (i
>= 0) and (i
< Length(gCorpses
)) then
1593 if (gCorpses
[i
] <> nil) and (gCorpses
[i
].FPlayerUID
= Player
.FUID
) then
1594 gCorpses
[i
].FPlayerUID
:= 0;
1597 if Player
.FObj
.Y
>= gMapInfo
.Height
+128 then
1602 if (FHealth
>= -50) or (gGibsCount
= 0) then
1604 if (gCorpses
= nil) or (Length(gCorpses
) = 0) then
1608 for find_id
:= 0 to High(gCorpses
) do
1609 if gCorpses
[find_id
] = nil then
1616 find_id
:= Random(Length(gCorpses
));
1618 gCorpses
[find_id
] := TCorpse
.Create(FObj
.X
, FObj
.Y
, FModel
.Name
, FHealth
< -20);
1619 gCorpses
[find_id
].FColor
:= FModel
.Color
;
1620 gCorpses
[find_id
].FObj
.Vel
:= FObj
.Vel
;
1621 gCorpses
[find_id
].FObj
.Accel
:= FObj
.Accel
;
1622 gCorpses
[find_id
].FPlayerUID
:= FUID
;
1627 g_Player_CreateGibs(FObj
.X
+ PLAYER_RECT_CX
,
1628 FObj
.Y
+ PLAYER_RECT_CY
,
1629 FModel
.Name
, FModel
.Color
);
1633 procedure g_Player_CreateShell(fX
, fY
, dX
, dY
: Integer; T
: Byte);
1637 if (gShells
= nil) or (Length(gShells
) = 0) then
1640 with gShells
[CurrentShell
] do
1646 if T
= SHELL_BULLET
then
1648 if g_Texture_Get('TEXTURE_SHELL_BULLET', SID
) then
1652 Obj
.Rect
.Width
:= 4;
1653 Obj
.Rect
.Height
:= 2;
1657 if g_Texture_Get('TEXTURE_SHELL_SHELL', SID
) then
1661 Obj
.Rect
.Width
:= 7;
1662 Obj
.Rect
.Height
:= 3;
1668 g_Obj_Push(@Obj
, dX
+ Random(4)-Random(4), dY
-Random(4));
1669 positionChanged(); // this updates spatial accelerators
1670 RAngle
:= Random(360);
1671 Timeout
:= gTime
+ SHELL_TIMEOUT
;
1673 if CurrentShell
>= High(gShells
) then
1680 procedure g_Player_CreateGibs(fX
, fY
: Integer; ModelName
: string; fColor
: TRGB
);
1683 GibsArray
: TGibsArray
;
1686 if (gGibs
= nil) or (Length(gGibs
) = 0) then
1688 if not g_PlayerModel_GetGibs(ModelName
, GibsArray
) then
1690 Blood
:= g_PlayerModel_GetBlood(ModelName
);
1692 for a
:= 0 to High(GibsArray
) do
1693 with gGibs
[CurrentGib
] do
1696 ID
:= GibsArray
[a
].ID
;
1697 MaskID
:= GibsArray
[a
].MaskID
;
1700 Obj
.Rect
:= GibsArray
[a
].Rect
;
1701 Obj
.X
:= fX
-GibsArray
[a
].Rect
.X
-(GibsArray
[a
].Rect
.Width
div 2);
1702 Obj
.Y
:= fY
-GibsArray
[a
].Rect
.Y
-(GibsArray
[a
].Rect
.Height
div 2);
1703 g_Obj_PushA(@Obj
, 25 + Random(10), Random(361));
1704 positionChanged(); // this updates spatial accelerators
1705 RAngle
:= Random(360);
1707 if gBloodCount
> 0 then
1708 g_GFX_Blood(fX
, fY
, 16*gBloodCount
+Random(5*gBloodCount
), -16+Random(33), -16+Random(33),
1709 Random(48), Random(48), Blood
.R
, Blood
.G
, Blood
.B
, Blood
.Kind
);
1711 if CurrentGib
>= High(gGibs
) then
1718 procedure g_Player_UpdatePhysicalObjects();
1724 procedure ShellSound_Bounce(X
, Y
: Integer; T
: Byte);
1729 if T
= SHELL_BULLET
then
1730 g_Sound_PlayExAt('SOUND_PLAYER_CASING' + IntToStr(k
), X
, Y
)
1732 g_Sound_PlayExAt('SOUND_PLAYER_SHELL' + IntToStr(k
), X
, Y
);
1737 if gGibs
<> nil then
1738 for i
:= 0 to High(gGibs
) do
1739 if gGibs
[i
].alive
then
1746 mr
:= g_Obj_Move(@Obj
, True, False, True);
1747 positionChanged(); // this updates spatial accelerators
1749 if WordBool(mr
and MOVE_FALLOUT
) then
1755 // Îòëåòàåò îò óäàðà î ñòåíó/ïîòîëîê/ïîë:
1756 if WordBool(mr
and MOVE_HITWALL
) then
1757 Obj
.Vel
.X
:= -(vel
.X
div 2);
1758 if WordBool(mr
and (MOVE_HITCEIL
or MOVE_HITLAND
)) then
1759 Obj
.Vel
.Y
:= -(vel
.Y
div 2);
1761 if (Obj
.Vel
.X
>= 0) then
1763 RAngle
:= RAngle
+ Abs(Obj
.Vel
.X
)*6 + Abs(Obj
.Vel
.Y
);
1764 if RAngle
>= 360 then
1765 RAngle
:= RAngle
mod 360;
1766 end else begin // Counter-clockwise
1767 RAngle
:= RAngle
- Abs(Obj
.Vel
.X
)*6 - Abs(Obj
.Vel
.Y
);
1769 RAngle
:= (360 - (Abs(RAngle
) mod 360)) mod 360;
1772 // Ñîïðîòèâëåíèå âîçäóõà äëÿ êóñêà òðóïà:
1773 if gTime
mod (GAME_TICK
*3) = 0 then
1774 Obj
.Vel
.X
:= z_dec(Obj
.Vel
.X
, 1);
1778 if gCorpses
<> nil then
1779 for i
:= 0 to High(gCorpses
) do
1780 if gCorpses
[i
] <> nil then
1781 if gCorpses
[i
].State
= CORPSE_STATE_REMOVEME
then
1787 gCorpses
[i
].Update();
1790 if gShells
<> nil then
1791 for i
:= 0 to High(gShells
) do
1792 if gShells
[i
].alive
then
1799 mr
:= g_Obj_Move(@Obj
, True, False, True);
1800 positionChanged(); // this updates spatial accelerators
1802 if WordBool(mr
and MOVE_FALLOUT
) or (gShells
[i
].Timeout
< gTime
) then
1808 // Îòëåòàåò îò óäàðà î ñòåíó/ïîòîëîê/ïîë:
1809 if WordBool(mr
and MOVE_HITWALL
) then
1811 Obj
.Vel
.X
:= -(vel
.X
div 2);
1812 if not WordBool(mr
and MOVE_INWATER
) then
1813 ShellSound_Bounce(Obj
.X
, Obj
.Y
, SType
);
1815 if WordBool(mr
and (MOVE_HITCEIL
or MOVE_HITLAND
)) then
1817 Obj
.Vel
.Y
:= -(vel
.Y
div 2);
1818 if Obj
.Vel
.X
<> 0 then Obj
.Vel
.X
:= Obj
.Vel
.X
div 2;
1819 if (Obj
.Vel
.X
= 0) and (Obj
.Vel
.Y
= 0) then
1821 if RAngle
mod 90 <> 0 then
1822 RAngle
:= (RAngle
div 90) * 90;
1824 else if not WordBool(mr
and MOVE_INWATER
) then
1825 ShellSound_Bounce(Obj
.X
, Obj
.Y
, SType
);
1828 if (Obj
.Vel
.X
>= 0) then
1830 RAngle
:= RAngle
+ Abs(Obj
.Vel
.X
)*8 + Abs(Obj
.Vel
.Y
);
1831 if RAngle
>= 360 then
1832 RAngle
:= RAngle
mod 360;
1833 end else begin // Counter-clockwise
1834 RAngle
:= RAngle
- Abs(Obj
.Vel
.X
)*8 - Abs(Obj
.Vel
.Y
);
1836 RAngle
:= (360 - (Abs(RAngle
) mod 360)) mod 360;
1842 procedure TGib
.getMapBox (out x
, y
, w
, h
: Integer); inline;
1844 x
:= Obj
.X
+Obj
.Rect
.X
;
1845 y
:= Obj
.Y
+Obj
.Rect
.Y
;
1846 w
:= Obj
.Rect
.Width
;
1847 h
:= Obj
.Rect
.Height
;
1850 procedure TGib
.moveBy (dx
, dy
: Integer); inline;
1852 if (dx
<> 0) or (dy
<> 0) then
1861 procedure TShell
.getMapBox (out x
, y
, w
, h
: Integer); inline;
1865 w
:= Obj
.Rect
.Width
;
1866 h
:= Obj
.Rect
.Height
;
1869 procedure TShell
.moveBy (dx
, dy
: Integer); inline;
1871 if (dx
<> 0) or (dy
<> 0) then
1880 procedure TGib
.positionChanged (); inline; begin end;
1881 procedure TShell
.positionChanged (); inline; begin end;
1884 procedure g_Player_DrawCorpses();
1889 if gGibs
<> nil then
1890 for i
:= 0 to High(gGibs
) do
1891 if gGibs
[i
].alive
then
1894 if not g_Obj_Collide(sX
, sY
, sWidth
, sHeight
, @Obj
) then
1897 Obj
.lerp(gLerpFactor
, fX
, fY
);
1899 a
.X
:= Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2);
1900 a
.y
:= Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2);
1902 e_DrawAdv(ID
, fX
, fY
, 0, True, False, RAngle
, @a
, TMirrorType
.None
);
1905 e_DrawAdv(MaskID
, fX
, fY
, 0, True, False, RAngle
, @a
, TMirrorType
.None
);
1911 if gCorpses
<> nil then
1912 for i
:= 0 to High(gCorpses
) do
1913 if gCorpses
[i
] <> nil then
1917 procedure g_Player_DrawShells();
1922 if gShells
<> nil then
1923 for i
:= 0 to High(gShells
) do
1924 if gShells
[i
].alive
then
1927 if not g_Obj_Collide(sX
, sY
, sWidth
, sHeight
, @Obj
) then
1930 Obj
.lerp(gLerpFactor
, fX
, fY
);
1935 e_DrawAdv(SpriteID
, fX
, fY
, 0, True, False, RAngle
, @a
, TMirrorType
.None
);
1939 procedure g_Player_RemoveAllCorpses();
1945 SetLength(gGibs
, MaxGibs
);
1946 SetLength(gShells
, MaxGibs
);
1950 if gCorpses
<> nil then
1951 for i
:= 0 to High(gCorpses
) do
1955 SetLength(gCorpses
, MaxCorpses
);
1958 procedure g_Player_Corpses_SaveState (st
: TStream
);
1962 // Ñ÷èòàåì êîëè÷åñòâî ñóùåñòâóþùèõ òðóïîâ
1964 for i
:= 0 to High(gCorpses
) do if (gCorpses
[i
] <> nil) then Inc(count
);
1966 // Êîëè÷åñòâî òðóïîâ
1967 utils
.writeInt(st
, LongInt(count
));
1969 if (count
= 0) then exit
;
1972 for i
:= 0 to High(gCorpses
) do
1974 if gCorpses
[i
] <> nil then
1977 utils
.writeStr(st
, gCorpses
[i
].FModelName
);
1979 utils
.writeBool(st
, gCorpses
[i
].Mess
);
1980 // Ñîõðàíÿåì äàííûå òðóïà:
1981 gCorpses
[i
].SaveState(st
);
1987 procedure g_Player_Corpses_LoadState (st
: TStream
);
1995 g_Player_RemoveAllCorpses();
1997 // Êîëè÷åñòâî òðóïîâ:
1998 count
:= utils
.readLongInt(st
);
1999 if (count
< 0) or (count
> Length(gCorpses
)) then raise XStreamError
.Create('invalid number of corpses');
2001 if (count
= 0) then exit
;
2004 for i
:= 0 to count
-1 do
2007 str
:= utils
.readStr(st
);
2009 b
:= utils
.readBool(st
);
2011 gCorpses
[i
] := TCorpse
.Create(0, 0, str
, b
);
2012 // Çàãðóæàåì äàííûå òðóïà
2013 gCorpses
[i
].LoadState(st
);
2020 function TPlayer
.isValidViewPort (): Boolean; inline; begin result
:= (viewPortW
> 0) and (viewPortH
> 0); end;
2022 procedure TPlayer
.BFGHit();
2024 g_Weapon_BFGHit(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
2025 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2));
2026 if g_Game_IsServer
and g_Game_IsNet
then
2027 MH_SEND_Effect(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
2028 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2),
2032 procedure TPlayer
.ChangeModel(ModelName
: string);
2034 locModel
: TPlayerModel
;
2036 locModel
:= g_PlayerModel_Get(ModelName
);
2037 if locModel
= nil then Exit
;
2043 procedure TPlayer
.SetModel(ModelName
: string);
2047 m
:= g_PlayerModel_Get(ModelName
);
2050 g_SimpleError(Format(_lc
[I_GAME_ERROR_MODEL_FALLBACK
], [ModelName
]));
2051 m
:= g_PlayerModel_Get('doomer');
2054 g_FatalError(Format(_lc
[I_GAME_ERROR_MODEL
], ['doomer']));
2059 if FModel
<> nil then
2064 if not (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then
2065 FModel
.Color
:= FColor
2067 FModel
.Color
:= TEAMCOLOR
[FTeam
];
2068 FModel
.SetWeapon(FCurrWeap
);
2069 FModel
.SetFlag(FFlag
);
2070 SetDirection(FDirection
);
2073 procedure TPlayer
.SetColor(Color
: TRGB
);
2076 if not (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then
2077 if FModel
<> nil then FModel
.Color
:= Color
;
2080 function TPlayer
.GetColor(): TRGB
;
2082 result
:= FModel
.Color
;
2085 procedure TPlayer
.SwitchTeam
;
2087 if g_Game_IsClient
then
2089 if not (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then Exit
;
2091 if gGameOn
and FAlive
then
2092 Kill(K_SIMPLEKILL
, FUID
, HIT_SELF
);
2094 if FTeam
= TEAM_RED
then
2096 ChangeTeam(TEAM_BLUE
);
2097 g_Console_Add(Format(_lc
[I_PLAYER_CHTEAM_BLUE
], [FName
]), True);
2098 if g_Game_IsNet
then
2099 MH_SEND_GameEvent(NET_EV_CHANGE_TEAM
, TEAM_BLUE
, FName
);
2103 ChangeTeam(TEAM_RED
);
2104 g_Console_Add(Format(_lc
[I_PLAYER_CHTEAM_RED
], [FName
]), True);
2105 if g_Game_IsNet
then
2106 MH_SEND_GameEvent(NET_EV_CHANGE_TEAM
, TEAM_RED
, FName
);
2108 FPreferredTeam
:= FTeam
;
2111 procedure TPlayer
.ChangeTeam(Team
: Byte);
2118 TEAM_RED
, TEAM_BLUE
:
2119 FModel
.Color
:= TEAMCOLOR
[Team
];
2121 FModel
.Color
:= FColor
;
2123 if (FTeam
<> OldTeam
) and g_Game_IsNet
and g_Game_IsServer
then
2124 MH_SEND_PlayerStats(FUID
);
2128 procedure TPlayer.CollideItem();
2133 if gItems = nil then Exit;
2134 if not FAlive then Exit;
2136 for i := 0 to High(gItems) do
2139 if (ItemType <> ITEM_NONE) and alive then
2140 if g_Obj_Collide(FObj.X+PLAYER_RECT.X, FObj.Y+PLAYER_RECT.Y, PLAYER_RECT.Width,
2141 PLAYER_RECT.Height, @Obj) then
2143 if not PickItem(ItemType, gItems[i].Respawnable, r) then Continue;
2145 if ItemType in [ITEM_SPHERE_BLUE, ITEM_SPHERE_WHITE, ITEM_INVUL] then
2146 g_Sound_PlayExAt('SOUND_ITEM_GETRULEZ', FObj.X, FObj.Y)
2147 else if ItemType in [ITEM_MEDKIT_SMALL, ITEM_MEDKIT_LARGE, ITEM_MEDKIT_BLACK] then
2148 g_Sound_PlayExAt('SOUND_ITEM_GETMED', FObj.X, FObj.Y)
2149 else g_Sound_PlayExAt('SOUND_ITEM_GETITEM', FObj.X, FObj.Y);
2151 // Íàäî óáðàòü ñ êàðòû, åñëè ýòî íå êëþ÷, êîòîðûì íóæíî ïîäåëèòñÿ ñ äðóãèì èãðîêîì:
2152 if r and not ((ItemType in [ITEM_KEY_RED, ITEM_KEY_GREEN, ITEM_KEY_BLUE]) and
2153 (gGameSettings.GameType = GT_SINGLE) and
2154 (g_Player_GetCount() > 1)) then
2155 if not Respawnable then g_Items_Remove(i) else g_Items_Pick(i);
2161 function TPlayer
.CollideLevel(XInc
, YInc
: Integer): Boolean;
2163 Result
:= g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
,
2164 PLAYER_RECT
.Width
, PLAYER_RECT
.Height
, PANEL_WALL
,
2168 constructor TPlayer
.Create();
2174 mEDamageType
:= HIT_SOME
;
2180 FSawSound
:= TPlayableSound
.Create();
2181 FSawSoundIdle
:= TPlayableSound
.Create();
2182 FSawSoundHit
:= TPlayableSound
.Create();
2183 FSawSoundSelect
:= TPlayableSound
.Create();
2184 FFlameSoundOn
:= TPlayableSound
.Create();
2185 FFlameSoundOff
:= TPlayableSound
.Create();
2186 FFlameSoundWork
:= TPlayableSound
.Create();
2187 FJetSoundFly
:= TPlayableSound
.Create();
2188 FJetSoundOn
:= TPlayableSound
.Create();
2189 FJetSoundOff
:= TPlayableSound
.Create();
2191 FSawSound
.SetByName('SOUND_WEAPON_FIRESAW');
2192 FSawSoundIdle
.SetByName('SOUND_WEAPON_IDLESAW');
2193 FSawSoundHit
.SetByName('SOUND_WEAPON_HITSAW');
2194 FSawSoundSelect
.SetByName('SOUND_WEAPON_SELECTSAW');
2195 FFlameSoundOn
.SetByName('SOUND_WEAPON_FLAMEON');
2196 FFlameSoundOff
.SetByName('SOUND_WEAPON_FLAMEOFF');
2197 FFlameSoundWork
.SetByName('SOUND_WEAPON_FLAMEWORK');
2198 FJetSoundFly
.SetByName('SOUND_PLAYER_JETFLY');
2199 FJetSoundOn
.SetByName('SOUND_PLAYER_JETON');
2200 FJetSoundOff
.SetByName('SOUND_PLAYER_JETOFF');
2202 FSpectatePlayer
:= -1;
2206 FSavedStateNum
:= -1;
2214 FActualModelName
:= 'doomer';
2217 FObj
.Rect
:= PLAYER_RECT
;
2219 FBFGFireCounter
:= -1;
2220 FJustTeleported
:= False;
2223 FWaitForFirstSpawn
:= false;
2228 procedure TPlayer
.positionChanged (); inline;
2232 procedure TPlayer
.doDamage (v
: Integer);
2234 if (v
<= 0) then exit
;
2235 if (v
> 32767) then v
:= 32767;
2236 Damage(v
, 0, 0, 0, mEDamageType
);
2239 procedure TPlayer
.Damage(value
: Word; SpawnerUID
: Word; vx
, vy
: Integer; t
: Byte);
2243 if (not g_Game_IsClient
) and (not FAlive
) then
2248 // Íåóÿçâèìîñòü íå ñïàñàåò îò ëîâóøåê:
2249 if ((t
= HIT_TRAP
) or (t
= HIT_SELF
)) and (not FGodMode
) then
2251 if not g_Game_IsClient
then
2254 if t
= HIT_TRAP
then
2256 // Ëîâóøêà óáèâàåò ñðàçó:
2258 Kill(K_EXTRAHARDKILL
, SpawnerUID
, t
);
2260 if t
= HIT_SELF
then
2264 Kill(K_SIMPLEKILL
, SpawnerUID
, t
);
2267 // Îáíóëèòü äåéñòâèÿ ïðèìî÷åê, ÷òîáû ôîí ïðîïàë
2268 FMegaRulez
[MR_SUIT
] := 0;
2269 FMegaRulez
[MR_INVUL
] := 0;
2270 FMegaRulez
[MR_INVIS
] := 0;
2275 // Íî îò îñòàëüíîãî ñïàñàåò:
2276 if FMegaRulez
[MR_INVUL
] >= gTime
then
2283 // Åñëè åñòü óðîí ñâîèì, èëè ðàíèë ñàì ñåáÿ, èëè òåáÿ ðàíèë ïðîòèâíèê:
2284 if LongBool(gGameSettings
.Options
and GAME_OPTION_TEAMDAMAGE
) or
2285 (SpawnerUID
= FUID
) or
2286 (not SameTeam(FUID
, SpawnerUID
)) then
2288 FLastSpawnerUID
:= SpawnerUID
;
2290 // Êðîâü (ïóçûðüêè, åñëè â âîäå):
2291 if gBloodCount
> 0 then
2293 c
:= Min(value
, 200)*gBloodCount
+ Random(Min(value
, 200) div 2);
2294 if value
div 4 <= c
then
2295 c
:= c
- (value
div 4)
2299 if (t
= HIT_SOME
) and (vx
= 0) and (vy
= 0) then
2303 HIT_TRAP
, HIT_ACID
, HIT_FLAME
, HIT_SELF
: MakeBloodSimple(c
);
2304 HIT_BFG
, HIT_ROCKET
, HIT_SOME
: MakeBloodVector(c
, vx
, vy
);
2307 if t
= HIT_WATER
then
2308 g_GFX_Bubbles(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2),
2309 FObj
.Y
+PLAYER_RECT
.Y
-4, value
div 2, 8, 4);
2314 Inc(FDamageBuffer
, value
);
2318 FPain
:= FPain
+ value
;
2321 if g_Game_IsServer
and g_Game_IsNet
then
2323 MH_SEND_PlayerDamage(FUID
, t
, SpawnerUID
, value
, vx
, vy
);
2324 MH_SEND_PlayerStats(FUID
);
2325 MH_SEND_PlayerPos(False, FUID
);
2329 function TPlayer
.Heal(value
: Word; Soft
: Boolean): Boolean;
2332 if g_Game_IsClient
then
2337 if Soft
and (FHealth
< PLAYER_HP_SOFT
) then
2339 IncMax(FHealth
, value
, PLAYER_HP_SOFT
);
2342 if (not Soft
) and (FHealth
< PLAYER_HP_LIMIT
) then
2344 IncMax(FHealth
, value
, PLAYER_HP_LIMIT
);
2348 if Result
and g_Game_IsServer
and g_Game_IsNet
then
2349 MH_SEND_PlayerStats(FUID
);
2352 destructor TPlayer
.Destroy();
2354 if (gPlayer1
<> nil) and (gPlayer1
.FUID
= FUID
) then
2356 if (gPlayer2
<> nil) and (gPlayer2
.FUID
= FUID
) then
2360 FSawSoundIdle
.Free();
2361 FSawSoundHit
.Free();
2362 FSawSoundSelect
.Free();
2363 FFlameSoundOn
.Free();
2364 FFlameSoundOff
.Free();
2365 FFlameSoundWork
.Free();
2366 FJetSoundFly
.Free();
2368 FJetSoundOff
.Free();
2370 if FPunchAnim
<> nil then
2376 procedure TPlayer
.DrawIndicator(Color
: TRGB
);
2378 indX
, indY
, fX
, fY
, fSlope
: Integer;
2388 FObj
.lerp(gLerpFactor
, fX
, fY
);
2389 fSlope
:= nlerp(FSlopeOld
, FObj
.slopeUpLeft
, gLerpFactor
);
2391 case gPlayerIndicatorStyle
of
2394 if g_Texture_Get('TEXTURE_PLAYER_INDICATOR', ID
) then
2396 e_GetTextureSize(ID
, @indW
, @indH
);
2400 if (FObj
.X
+ FObj
.Rect
.X
) < 0 then
2403 indX
:= fX
+ FObj
.Rect
.X
+ FObj
.Rect
.Width
;
2404 indY
:= fY
+ FObj
.Rect
.Y
+ (FObj
.Rect
.Height
- indW
) div 2;
2407 else if (FObj
.X
+ FObj
.Rect
.X
+ FObj
.Rect
.Width
) > Max(gMapInfo
.Width
, gPlayerScreenSize
.X
) then
2410 indX
:= fX
+ FObj
.Rect
.X
- indH
;
2411 indY
:= fY
+ FObj
.Rect
.Y
+ (FObj
.Rect
.Height
- indW
) div 2;
2414 else if (FObj
.Y
- indH
) < 0 then
2417 indX
:= fX
+ FObj
.Rect
.X
+ (FObj
.Rect
.Width
- indW
) div 2;
2418 indY
:= fY
+ FObj
.Rect
.Y
+ FObj
.Rect
.Height
;
2424 indX
:= fX
+ FObj
.Rect
.X
+ (FObj
.Rect
.Width
- indW
) div 2;
2428 indY
:= indY
+ fSlope
;
2429 indX
:= EnsureRange(indX
, 0, Max(gMapInfo
.Width
, gPlayerScreenSize
.X
) - indW
);
2430 indY
:= EnsureRange(indY
, 0, Max(gMapInfo
.Height
, gPlayerScreenSize
.Y
) - indH
);
2434 e_DrawAdv(ID
, indX
, indY
, 0, True, False, indA
, @a
);
2441 e_TextureFontGetSize(gStdFont
, nW
, nH
);
2442 indX
:= fX
+ FObj
.Rect
.X
+ (FObj
.Rect
.Width
- Length(FName
) * nW
) div 2;
2443 indY
:= fY
- nH
+ fSlope
;
2444 e_TextureFontPrintEx(indX
, indY
, FName
, gStdFont
, Color
.R
, Color
.G
, Color
.B
, 1.0, True);
2450 procedure TPlayer
.DrawBubble();
2452 bubX
, bubY
, fX
, fY
: Integer;
2455 Rw
, Gw
, Bw
: SmallInt;
2459 CObj
:= getCameraObj();
2460 CObj
.lerp(gLerpFactor
, fX
, fY
);
2461 // NB: _F_Obj.Rect is used to keep the bubble higher; this is not a mistake
2462 bubX
:= fX
+FObj
.Rect
.X
+ IfThen(FDirection
= TDirection
.D_LEFT
, -4, 18);
2463 bubY
:= fY
+FObj
.Rect
.Y
- 18;
2471 1: // simple textual non-bubble
2473 bubX
:= fX
+FObj
.Rect
.X
- 11;
2474 bubY
:= fY
+FObj
.Rect
.Y
- 17;
2475 e_TextureFontPrint(bubX
, bubY
, '[...]', gStdFont
);
2478 2: // advanced pixel-perfect bubble
2480 if FTeam
= TEAM_RED
then
2483 if FTeam
= TEAM_BLUE
then
2486 3: // colored bubble
2488 Rb
:= FModel
.Color
.R
;
2489 Gb
:= FModel
.Color
.G
;
2490 Bb
:= FModel
.Color
.B
;
2491 Rw
:= Min(Rb
* 2 + 64, 255);
2492 Gw
:= Min(Gb
* 2 + 64, 255);
2493 Bw
:= Min(Bb
* 2 + 64, 255);
2494 if (Abs(Rw
- Rb
) < 32)
2495 or (Abs(Gw
- Gb
) < 32)
2496 or (Abs(Bw
- Bb
) < 32) then
2498 Rb
:= Max(Rw
div 2 - 16, 0);
2499 Gb
:= Max(Gw
div 2 - 16, 0);
2500 Bb
:= Max(Bw
div 2 - 16, 0);
2503 4: // custom textured bubble
2505 if g_Texture_Get('TEXTURE_PLAYER_TALKBUBBLE', ID
) then
2506 if FDirection
= TDirection
.D_RIGHT
then
2507 e_Draw(ID
, bubX
- 6, bubY
- 7, 0, True, False)
2509 e_Draw(ID
, bubX
- 6, bubY
- 7, 0, True, False, TMirrorType
.Horizontal
);
2515 e_DrawQuad(bubX
+ 1, bubY
, bubX
+ 18, bubY
+ 13, Rb
, Gb
, Bb
);
2516 e_DrawQuad(bubX
, bubY
+ 1, bubX
+ 19, bubY
+ 12, Rb
, Gb
, Bb
);
2518 e_DrawFillQuad(bubX
+ 1, bubY
+ 1, bubX
+ 18, bubY
+ 12, Rw
, Gw
, Bw
, 0);
2521 Dot
:= IfThen(FDirection
= TDirection
.D_LEFT
, 14, 5);
2522 e_DrawLine(1, bubX
+ Dot
, bubY
+ 14, bubX
+ Dot
, bubY
+ 16, Rb
, Gb
, Bb
);
2523 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
);
2524 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
);
2525 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
);
2526 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
);
2530 e_DrawFillQuad(bubX
+ Dot
, bubY
+ 8, bubX
+ Dot
+ 1, bubY
+ 9, Rb
, Gb
, Bb
, 0);
2531 e_DrawFillQuad(bubX
+ Dot
+ 3, bubY
+ 8, bubX
+ Dot
+ 4, bubY
+ 9, Rb
, Gb
, Bb
, 0);
2532 e_DrawFillQuad(bubX
+ Dot
+ 6, bubY
+ 8, bubX
+ Dot
+ 7, bubY
+ 9, Rb
, Gb
, Bb
, 0);
2535 procedure TPlayer
.Draw();
2540 Mirror
: TMirrorType
;
2541 fX
, fY
, fSlope
: Integer;
2543 FObj
.lerp(gLerpFactor
, fX
, fY
);
2544 fSlope
:= nlerp(FSlopeOld
, FObj
.slopeUpLeft
, gLerpFactor
);
2548 if Direction
= TDirection
.D_RIGHT
then
2549 Mirror
:= TMirrorType
.None
2551 Mirror
:= TMirrorType
.Horizontal
;
2553 if FPunchAnim
<> nil then
2555 FPunchAnim
.Draw(fX
+IfThen(Direction
= TDirection
.D_LEFT
, 15-FObj
.Rect
.X
, FObj
.Rect
.X
-15),
2556 fY
+fSlope
+FObj
.Rect
.Y
-11, Mirror
);
2557 if FPunchAnim
.played
then
2564 if (FMegaRulez
[MR_INVUL
] > gTime
) and ((gPlayerDrawn
<> Self
) or (FSpawnInvul
>= gTime
)) then
2565 if g_Texture_Get('TEXTURE_PLAYER_INVULPENTA', ID
) then
2567 e_GetTextureSize(ID
, @w
, @h
);
2568 if FDirection
= TDirection
.D_LEFT
then
2569 e_Draw(ID
, fX
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2)-(w
div 2)+4,
2570 fY
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2)-(h
div 2)-7+fSlope
, 0, True, False)
2572 e_Draw(ID
, fX
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2)-(w
div 2)-2,
2573 fY
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2)-(h
div 2)-7+fSlope
, 0, True, False);
2576 if FMegaRulez
[MR_INVIS
] > gTime
then
2578 if (gPlayerDrawn
<> nil) and ((Self
= gPlayerDrawn
) or
2579 ((FTeam
= gPlayerDrawn
.Team
) and (gGameSettings
.GameMode
<> GM_DM
))) then
2581 if (FMegaRulez
[MR_INVIS
] - gTime
) <= 2100 then
2582 dr
:= not Odd((FMegaRulez
[MR_INVIS
] - gTime
) div 300)
2586 FModel
.Draw(fX
, fY
+fSlope
, 200)
2588 FModel
.Draw(fX
, fY
+fSlope
);
2591 FModel
.Draw(fX
, fY
+fSlope
, 254);
2594 FModel
.Draw(fX
, fY
+fSlope
);
2597 if g_debug_Frames
then
2599 e_DrawQuad(FObj
.X
+FObj
.Rect
.X
,
2601 FObj
.X
+FObj
.Rect
.X
+FObj
.Rect
.Width
-1,
2602 FObj
.Y
+FObj
.Rect
.Y
+FObj
.Rect
.Height
-1,
2606 if (gChatBubble
> 0) and (FKeys
[KEY_CHAT
].Pressed
) and not FGhost
then
2607 if (FMegaRulez
[MR_INVIS
] <= gTime
) or ((gPlayerDrawn
<> nil) and ((Self
= gPlayerDrawn
) or
2608 ((FTeam
= gPlayerDrawn
.Team
) and (gGameSettings
.GameMode
<> GM_DM
)))) then
2610 // e_DrawPoint(5, 335, 288, 255, 0, 0); // DL, UR, DL, UR
2611 if gAimLine
and alive
and
2612 ((Self
= gPlayer1
) or (Self
= gPlayer2
)) then
2617 procedure TPlayer
.DrawAim();
2618 procedure drawCast (sz
: Integer; ax0
, ay0
, ax1
, ay1
: Integer);
2623 {$IFDEF ENABLE_HOLMES}
2624 if isValidViewPort
and (self
= gPlayer1
) then
2626 g_Holmes_plrLaser(ax0
, ay0
, ax1
, ay1
);
2630 e_DrawLine(sz
, ax0
, ay0
, ax1
, ay1
, 255, 0, 0, 96);
2631 if (g_Map_traceToNearestWall(ax0
, ay0
, ax1
, ay1
, @ex
, @ey
) <> nil) then
2633 e_DrawLine(sz
, ax0
, ay0
, ex
, ey
, 0, 255, 0, 96);
2637 e_DrawLine(sz
, ax0
, ay0
, ex
, ey
, 0, 0, 255, 96);
2642 wx
, wy
, xx
, yy
: Integer;
2646 wx
:= FObj
.X
+ WEAPONPOINT
[FDirection
].X
+ IfThen(FDirection
= TDirection
.D_LEFT
, 7, -7);
2647 wy
:= FObj
.Y
+ WEAPONPOINT
[FDirection
].Y
;
2656 1: begin // Chainsaw
2663 if angle
= ANGLE_RIGHTUP
then Dec(angle
, 2);
2664 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 4);
2665 if angle
= ANGLE_LEFTUP
then Inc(angle
, 2);
2666 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 4);
2671 if angle
= ANGLE_RIGHTUP
then Dec(angle
, 2);
2672 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 4);
2673 if angle
= ANGLE_LEFTUP
then Inc(angle
, 2);
2674 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 4);
2676 4: begin // Double Shotgun
2679 if angle
= ANGLE_RIGHTUP
then Dec(angle
, 2);
2680 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 4);
2681 if angle
= ANGLE_LEFTUP
then Inc(angle
, 2);
2682 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 4);
2684 5: begin // Chaingun
2687 if angle
= ANGLE_RIGHTUP
then Dec(angle
, 2);
2688 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 4);
2689 if angle
= ANGLE_LEFTUP
then Inc(angle
, 2);
2690 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 4);
2692 6: begin // Rocket Launcher
2695 if angle
= ANGLE_RIGHTUP
then Inc(angle
, 2);
2696 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 4);
2697 if angle
= ANGLE_LEFTUP
then Dec(angle
, 2);
2698 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 4);
2700 7: begin // Plasmagun
2703 if angle
= ANGLE_RIGHTUP
then Inc(angle
);
2704 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 3);
2705 if angle
= ANGLE_LEFTUP
then Dec(angle
);
2706 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 3);
2711 if angle
= ANGLE_RIGHTUP
then Inc(angle
, 1);
2712 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 2);
2713 if angle
= ANGLE_LEFTUP
then Dec(angle
, 1);
2714 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 2);
2716 9: begin // Super Chaingun
2719 if angle
= ANGLE_RIGHTUP
then Dec(angle
, 2);
2720 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 4);
2721 if angle
= ANGLE_LEFTUP
then Inc(angle
, 2);
2722 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 4);
2725 xx
:= Trunc(Cos(-DegToRad(angle
)) * len
) + wx
;
2726 yy
:= Trunc(Sin(-DegToRad(angle
)) * len
) + wy
;
2727 {$IF DEFINED(D2F_DEBUG)}
2728 drawCast(sz
, wx
, wy
, xx
, yy
);
2730 e_DrawLine(sz
, wx
, wy
, xx
, yy
, 255, 0, 0, 96);
2734 procedure TPlayer
.DrawGUI();
2737 X
, Y
, SY
, a
, p
, m
: Integer;
2741 stat
: TPlayerStatArray
;
2743 X
:= gPlayerScreenSize
.X
;
2744 SY
:= gPlayerScreenSize
.Y
;
2747 if gShowGoals
and (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then
2749 if gGameSettings
.GameMode
= GM_CTF
then
2753 if gGameSettings
.GameMode
= GM_CTF
then
2755 s
:= 'TEXTURE_PLAYER_REDFLAG';
2756 if gFlags
[FLAG_RED
].State
= FLAG_STATE_CAPTURED
then
2757 s
:= 'TEXTURE_PLAYER_REDFLAG_S';
2758 if gFlags
[FLAG_RED
].State
= FLAG_STATE_DROPPED
then
2759 s
:= 'TEXTURE_PLAYER_REDFLAG_D';
2760 if g_Texture_Get(s
, ID
) then
2761 e_Draw(ID
, X
-16-32, 240-72-4, 0, True, False);
2764 s
:= IntToStr(gTeamStat
[TEAM_RED
].Goals
);
2765 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2766 e_CharFont_PrintEx(gMenuFont
, X
-16-a
-tw
, 240-72-4, s
, TEAMCOLOR
[TEAM_RED
]);
2768 if gGameSettings
.GameMode
= GM_CTF
then
2770 s
:= 'TEXTURE_PLAYER_BLUEFLAG';
2771 if gFlags
[FLAG_BLUE
].State
= FLAG_STATE_CAPTURED
then
2772 s
:= 'TEXTURE_PLAYER_BLUEFLAG_S';
2773 if gFlags
[FLAG_BLUE
].State
= FLAG_STATE_DROPPED
then
2774 s
:= 'TEXTURE_PLAYER_BLUEFLAG_D';
2775 if g_Texture_Get(s
, ID
) then
2776 e_Draw(ID
, X
-16-32, 240-32-4, 0, True, False);
2779 s
:= IntToStr(gTeamStat
[TEAM_BLUE
].Goals
);
2780 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2781 e_CharFont_PrintEx(gMenuFont
, X
-16-a
-tw
, 240-32-4, s
, TEAMCOLOR
[TEAM_BLUE
]);
2784 if g_Texture_Get('TEXTURE_PLAYER_HUDBG', ID
) then
2785 e_DrawFill(ID
, X
, 0, 1, (gPlayerScreenSize
.Y
div 256)+IfThen(gPlayerScreenSize
.Y
mod 256 > 0, 1, 0),
2788 if g_Texture_Get('TEXTURE_PLAYER_HUD', ID
) then
2789 e_Draw(ID
, X
+2, Y
, 0, True, False);
2791 if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
2795 s
:= IntToStr(Frags
);
2796 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2797 e_CharFont_PrintEx(gMenuFont
, X
-16-tw
, Y
, s
, _RGB(255, 0, 0));
2802 stat
:= g_Player_GetStats();
2807 for a
:= 0 to High(stat
) do
2808 if stat
[a
].Name
<> Name
then
2810 if stat
[a
].Frags
> m
then m
:= stat
[a
].Frags
;
2811 if stat
[a
].Frags
> Frags
then p
:= p
+1;
2815 s
:= IntToStr(p
)+' / '+IntToStr(Length(stat
))+' ';
2816 if Frags
>= m
then s
:= s
+'+' else s
:= s
+'-';
2817 s
:= s
+IntToStr(Abs(Frags
-m
));
2819 e_CharFont_GetSize(gMenuSmallFont
, s
, tw
, th
);
2820 e_CharFont_PrintEx(gMenuSmallFont
, X
-16-tw
, Y
+32, s
, _RGB(255, 0, 0));
2823 if gLMSRespawn
> LMS_RESPAWN_NONE
then
2825 s
:= _lc
[I_GAME_WARMUP
];
2826 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2827 s
:= s
+ ': ' + IntToStr((gLMSRespawnTime
- gTime
) div 1000);
2828 e_CharFont_PrintEx(gMenuFont
, X
-64-tw
, SY
-32, s
, _RGB(0, 255, 0));
2830 else if gShowLives
and (gGameSettings
.MaxLives
> 0) then
2832 s
:= IntToStr(Lives
);
2833 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2834 e_CharFont_PrintEx(gMenuFont
, X
-16-tw
, SY
-32, s
, _RGB(0, 255, 0));
2838 e_CharFont_GetSize(gMenuSmallFont
, FName
, tw
, th
);
2839 e_CharFont_PrintEx(gMenuSmallFont
, X
+98-(tw
div 2), Y
+8, FName
, _RGB(255, 0, 0));
2841 if R_BERSERK
in FRulez
then
2842 e_Draw(gItemsTexturesID
[ITEM_MEDKIT_BLACK
], X
+37, Y
+45, 0, True, False)
2844 e_Draw(gItemsTexturesID
[ITEM_MEDKIT_LARGE
], X
+37, Y
+45, 0, True, False);
2846 if g_Texture_Get('TEXTURE_PLAYER_ARMORHUD', ID
) then
2847 e_Draw(ID
, X
+36, Y
+77, 0, True, False);
2849 s
:= IntToStr(IfThen(FHealth
> 0, FHealth
, 0));
2850 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2851 e_CharFont_PrintEx(gMenuFont
, X
+178-tw
, Y
+40, s
, _RGB(255, 0, 0));
2853 s
:= IntToStr(FArmor
);
2854 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2855 e_CharFont_PrintEx(gMenuFont
, X
+178-tw
, Y
+68, s
, _RGB(255, 0, 0));
2857 s
:= IntToStr(GetAmmoByWeapon(FCurrWeap
));
2863 ID
:= gItemsTexturesID
[ITEM_WEAPON_KASTET
];
2868 ID
:= gItemsTexturesID
[ITEM_WEAPON_SAW
];
2870 WEAPON_PISTOL
: ID
:= gItemsTexturesID
[ITEM_WEAPON_PISTOL
];
2871 WEAPON_CHAINGUN
: ID
:= gItemsTexturesID
[ITEM_WEAPON_CHAINGUN
];
2872 WEAPON_SHOTGUN1
: ID
:= gItemsTexturesID
[ITEM_WEAPON_SHOTGUN1
];
2873 WEAPON_SHOTGUN2
: ID
:= gItemsTexturesID
[ITEM_WEAPON_SHOTGUN2
];
2874 WEAPON_SUPERPULEMET
: ID
:= gItemsTexturesID
[ITEM_WEAPON_SUPERPULEMET
];
2875 WEAPON_ROCKETLAUNCHER
: ID
:= gItemsTexturesID
[ITEM_WEAPON_ROCKETLAUNCHER
];
2876 WEAPON_PLASMA
: ID
:= gItemsTexturesID
[ITEM_WEAPON_PLASMA
];
2877 WEAPON_BFG
: ID
:= gItemsTexturesID
[ITEM_WEAPON_BFG
];
2878 WEAPON_FLAMETHROWER
: ID
:= gItemsTexturesID
[ITEM_WEAPON_FLAMETHROWER
];
2881 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2882 e_CharFont_PrintEx(gMenuFont
, X
+178-tw
, Y
+158, s
, _RGB(255, 0, 0));
2883 e_Draw(ID
, X
+20, Y
+160, 0, True, False);
2885 if R_KEY_RED
in FRulez
then
2886 e_Draw(gItemsTexturesID
[ITEM_KEY_RED
], X
+78, Y
+214, 0, True, False);
2888 if R_KEY_GREEN
in FRulez
then
2889 e_Draw(gItemsTexturesID
[ITEM_KEY_GREEN
], X
+95, Y
+214, 0, True, False);
2891 if R_KEY_BLUE
in FRulez
then
2892 e_Draw(gItemsTexturesID
[ITEM_KEY_BLUE
], X
+112, Y
+214, 0, True, False);
2894 if FJetFuel
> 0 then
2896 if g_Texture_Get('TEXTURE_PLAYER_HUDAIR', ID
) then
2897 e_Draw(ID
, X
+2, Y
+116, 0, True, False);
2898 if g_Texture_Get('TEXTURE_PLAYER_HUDJET', ID
) then
2899 e_Draw(ID
, X
+2, Y
+126, 0, True, False);
2900 e_DrawLine(4, X
+16, Y
+122, X
+16+Trunc(168*IfThen(FAir
> 0, FAir
, 0)/AIR_MAX
), Y
+122, 0, 0, 196);
2901 e_DrawLine(4, X
+16, Y
+132, X
+16+Trunc(168*FJetFuel
/JET_MAX
), Y
+132, 208, 0, 0);
2905 if g_Texture_Get('TEXTURE_PLAYER_HUDAIR', ID
) then
2906 e_Draw(ID
, X
+2, Y
+124, 0, True, False);
2907 e_DrawLine(4, X
+16, Y
+130, X
+16+Trunc(168*IfThen(FAir
> 0, FAir
, 0)/AIR_MAX
), Y
+130, 0, 0, 196);
2910 if gShowPing
and g_Game_IsClient
then
2912 s
:= _lc
[I_GAME_PING_HUD
] + IntToStr(NetPeer
.lastRoundTripTime
) + _lc
[I_NET_SLIST_PING_MS
];
2913 e_TextureFontPrint(X
+ 4, Y
+ 242, s
, gStdFont
);
2919 e_TextureFontPrint(X
+ 4, Y
+ 242, _lc
[I_PLAYER_SPECT
], gStdFont
);
2920 e_TextureFontPrint(X
+ 4, Y
+ 258, _lc
[I_PLAYER_SPECT2
], gStdFont
);
2921 e_TextureFontPrint(X
+ 4, Y
+ 274, _lc
[I_PLAYER_SPECT1
], gStdFont
);
2924 e_TextureFontGetSize(gStdFont
, cw
, ch
);
2925 s
:= _lc
[I_PLAYER_SPECT4
];
2926 e_TextureFontPrintEx(gScreenWidth
div 2 - cw
*(Length(s
) div 2),
2927 gScreenHeight
-4-ch
, s
, gStdFont
, 255, 255, 255, 1, True);
2928 e_TextureFontPrint(X
+ 4, Y
+ 290, _lc
[I_PLAYER_SPECT1S
], gStdFont
);
2934 procedure TPlayer
.DrawRulez();
2938 // Ïðè âçÿòèè íåóÿçâèìîñòè ðèñóåòñÿ èíâåðñèîííûé áåëûé ôîí
2939 if (FMegaRulez
[MR_INVUL
] >= gTime
) and (FSpawnInvul
< gTime
) then
2941 if (FMegaRulez
[MR_INVUL
]-gTime
) <= 2100 then
2942 dr
:= not Odd((FMegaRulez
[MR_INVUL
]-gTime
) div 300)
2947 e_DrawFillQuad(0, 0, gPlayerScreenSize
.X
-1, gPlayerScreenSize
.Y
-1,
2948 191, 191, 191, 0, TBlending
.Invert
);
2951 // Ïðè âçÿòèè çàùèòíîãî êîñòþìà ðèñóåòñÿ çåëåíîâàòûé ôîí
2952 if FMegaRulez
[MR_SUIT
] >= gTime
then
2954 if (FMegaRulez
[MR_SUIT
]-gTime
) <= 2100 then
2955 dr
:= not Odd((FMegaRulez
[MR_SUIT
]-gTime
) div 300)
2960 e_DrawFillQuad(0, 0, gPlayerScreenSize
.X
-1, gPlayerScreenSize
.Y
-1,
2961 0, 96, 0, 200, TBlending
.None
);
2964 // Ïðè âçÿòèè áåðñåðêà ðèñóåòñÿ êðàñíîâàòûé ôîí
2965 if (FBerserk
>= 0) and (LongWord(FBerserk
) >= gTime
) and (gFlash
= 2) then
2967 e_DrawFillQuad(0, 0, gPlayerScreenSize
.X
-1, gPlayerScreenSize
.Y
-1,
2968 255, 0, 0, 200, TBlending
.None
);
2972 procedure TPlayer
.DrawPain();
2976 if FPain
= 0 then Exit
;
2980 if a
< 15 then h
:= 0
2981 else if a
< 35 then h
:= 1
2982 else if a
< 55 then h
:= 2
2983 else if a
< 75 then h
:= 3
2984 else if a
< 95 then h
:= 4
2987 //if a > 255 then a := 255;
2989 e_DrawFillQuad(0, 0, gPlayerScreenSize
.X
-1, gPlayerScreenSize
.Y
-1, 255, 0, 0, 255-h
*50);
2990 //e_DrawFillQuad(0, 0, gPlayerScreenSize.X-1, gPlayerScreenSize.Y-1, 255-min(128, a), 255-a, 255-a, 0, B_FILTER);
2993 procedure TPlayer
.DrawPickup();
2997 if FPickup
= 0 then Exit
;
3001 if a
< 15 then h
:= 1
3002 else if a
< 35 then h
:= 2
3003 else if a
< 55 then h
:= 3
3004 else if a
< 75 then h
:= 4
3007 e_DrawFillQuad(0, 0, gPlayerScreenSize
.X
-1, gPlayerScreenSize
.Y
-1, 150, 200, 150, 255-h
*50);
3010 procedure TPlayer
.DoPunch();
3015 if FPunchAnim
<> nil then begin
3020 st
:= 'FRAMES_PUNCH';
3021 if R_BERSERK
in FRulez
then
3022 st
:= st
+ '_BERSERK';
3023 if FKeys
[KEY_UP
].Pressed
then
3025 else if FKeys
[KEY_DOWN
].Pressed
then
3027 g_Frames_Get(id
, st
);
3028 FPunchAnim
:= TAnimation
.Create(id
, False, 1);
3031 procedure TPlayer
.Fire();
3033 f
, DidFire
: Boolean;
3034 wx
, wy
, xd
, yd
: Integer;
3037 if g_Game_IsClient
then Exit
;
3038 // FBFGFireCounter - âðåìÿ ïåðåä âûñòðåëîì (äëÿ BFG)
3039 // FReloading - âðåìÿ ïîñëå âûñòðåëà (äëÿ âñåãî)
3047 if FReloading
[FCurrWeap
] <> 0 then Exit
;
3052 wx
:= FObj
.X
+WEAPONPOINT
[FDirection
].X
;
3053 wy
:= FObj
.Y
+WEAPONPOINT
[FDirection
].Y
;
3054 xd
:= wx
+IfThen(FDirection
= TDirection
.D_LEFT
, -30, 30);
3055 yd
:= wy
+firediry();
3061 if R_BERSERK
in FRulez
then
3063 //g_Weapon_punch(FObj.X+FObj.Rect.X, FObj.Y+FObj.Rect.Y, 75, FUID);
3064 locobj
.X
:= FObj
.X
+FObj
.Rect
.X
;
3065 locobj
.Y
:= FObj
.Y
+FObj
.Rect
.Y
;
3068 locobj
.rect
.Width
:= 39;
3069 locobj
.rect
.Height
:= 52;
3070 locobj
.Vel
.X
:= (xd
-wx
) div 2;
3071 locobj
.Vel
.Y
:= (yd
-wy
) div 2;
3072 locobj
.Accel
.X
:= xd
-wx
;
3073 locobj
.Accel
.y
:= yd
-wy
;
3075 if g_Weapon_Hit(@locobj
, 50, FUID
, HIT_SOME
) <> 0 then
3076 g_Sound_PlayExAt('SOUND_WEAPON_HITBERSERK', FObj
.X
, FObj
.Y
)
3078 g_Sound_PlayExAt('SOUND_WEAPON_MISSBERSERK', FObj
.X
, FObj
.Y
);
3080 if (gFlash
= 1) and (FPain
< 50) then FPain
:= min(FPain
+ 25, 50);
3084 g_Weapon_punch(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
, 3, FUID
);
3088 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
3093 if g_Weapon_chainsaw(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
,
3094 IfThen(gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
], 9, 3), FUID
) <> 0 then
3096 FSawSoundSelect
.Stop();
3098 FSawSoundHit
.PlayAt(FObj
.X
, FObj
.Y
);
3100 else if not FSawSoundHit
.IsPlaying() then
3102 FSawSoundSelect
.Stop();
3103 FSawSound
.PlayAt(FObj
.X
, FObj
.Y
);
3106 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
3112 if FAmmo
[A_BULLETS
] > 0 then
3114 g_Weapon_pistol(wx
, wy
, xd
, yd
, FUID
);
3115 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
3116 Dec(FAmmo
[A_BULLETS
]);
3117 FFireAngle
:= FAngle
;
3120 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
3121 GameVelX
, GameVelY
-2, SHELL_BULLET
);
3125 if FAmmo
[A_SHELLS
] > 0 then
3127 g_Weapon_shotgun(wx
, wy
, xd
, yd
, FUID
);
3128 if not gSoundEffectsDF
then g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN', wx
, wy
);
3129 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
3130 Dec(FAmmo
[A_SHELLS
]);
3131 FFireAngle
:= FAngle
;
3135 FShellType
:= SHELL_SHELL
;
3139 if FAmmo
[A_SHELLS
] >= 2 then
3141 g_Weapon_dshotgun(wx
, wy
, xd
, yd
, FUID
);
3142 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
3143 Dec(FAmmo
[A_SHELLS
], 2);
3144 FFireAngle
:= FAngle
;
3148 FShellType
:= SHELL_DBLSHELL
;
3152 if FAmmo
[A_BULLETS
] > 0 then
3154 g_Weapon_mgun(wx
, wy
, xd
, yd
, FUID
);
3155 if not gSoundEffectsDF
then g_Sound_PlayExAt('SOUND_WEAPON_FIREPISTOL', wx
, wy
);
3156 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
3157 Dec(FAmmo
[A_BULLETS
]);
3158 FFireAngle
:= FAngle
;
3161 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
3162 GameVelX
, GameVelY
-2, SHELL_BULLET
);
3165 WEAPON_ROCKETLAUNCHER
:
3166 if FAmmo
[A_ROCKETS
] > 0 then
3168 g_Weapon_rocket(wx
, wy
, xd
, yd
, FUID
);
3169 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
3170 Dec(FAmmo
[A_ROCKETS
]);
3171 FFireAngle
:= FAngle
;
3177 if FAmmo
[A_CELLS
] > 0 then
3179 g_Weapon_plasma(wx
, wy
, xd
, yd
, FUID
);
3180 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
3181 Dec(FAmmo
[A_CELLS
]);
3182 FFireAngle
:= FAngle
;
3188 if (FAmmo
[A_CELLS
] >= 40) and (FBFGFireCounter
= -1) then
3190 FBFGFireCounter
:= 17;
3191 if not FNoReload
then
3192 g_Sound_PlayExAt('SOUND_WEAPON_STARTFIREBFG', FObj
.X
, FObj
.Y
);
3193 Dec(FAmmo
[A_CELLS
], 40);
3197 WEAPON_SUPERPULEMET
:
3198 if FAmmo
[A_SHELLS
] > 0 then
3200 g_Weapon_shotgun(wx
, wy
, xd
, yd
, FUID
);
3201 if not gSoundEffectsDF
then g_Sound_PlayExAt('SOUND_WEAPON_FIRECGUN', wx
, wy
);
3202 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
3203 Dec(FAmmo
[A_SHELLS
]);
3204 FFireAngle
:= FAngle
;
3207 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
3208 GameVelX
, GameVelY
-2, SHELL_SHELL
);
3211 WEAPON_FLAMETHROWER
:
3212 if FAmmo
[A_FUEL
] > 0 then
3214 g_Weapon_flame(wx
, wy
, xd
, yd
, FUID
);
3216 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
3218 FFireAngle
:= FAngle
;
3225 if g_Game_IsNet
and g_Game_IsServer
then MH_SEND_PlayerStats(FUID
);
3229 if g_Game_IsNet
then
3233 if FCurrWeap
<> WEAPON_BFG
then
3234 MH_SEND_PlayerFire(FUID
, FCurrWeap
, wx
, wy
, xd
, yd
, LastShotID
)
3236 if not FNoReload
then
3237 MH_SEND_Sound(FObj
.X
, FObj
.Y
, 'SOUND_WEAPON_STARTFIREBFG');
3240 MH_SEND_PlayerStats(FUID
);
3245 if (FAngle
= 0) or (FAngle
= 180) then SetAction(A_ATTACK
)
3246 else if (FAngle
= ANGLE_LEFTDOWN
) or (FAngle
= ANGLE_RIGHTDOWN
) then SetAction(A_ATTACKDOWN
)
3247 else if (FAngle
= ANGLE_LEFTUP
) or (FAngle
= ANGLE_RIGHTUP
) then SetAction(A_ATTACKUP
);
3250 function TPlayer
.GetAmmoByWeapon(Weapon
: Byte): Word;
3253 WEAPON_PISTOL
, WEAPON_CHAINGUN
: Result
:= FAmmo
[A_BULLETS
];
3254 WEAPON_SHOTGUN1
, WEAPON_SHOTGUN2
, WEAPON_SUPERPULEMET
: Result
:= FAmmo
[A_SHELLS
];
3255 WEAPON_ROCKETLAUNCHER
: Result
:= FAmmo
[A_ROCKETS
];
3256 WEAPON_PLASMA
, WEAPON_BFG
: Result
:= FAmmo
[A_CELLS
];
3257 WEAPON_FLAMETHROWER
: Result
:= FAmmo
[A_FUEL
];
3262 function TPlayer
.HeadInLiquid(XInc
, YInc
: Integer): Boolean;
3264 Result
:= g_Map_CollidePanel(FObj
.X
+PLAYER_HEADRECT
.X
+XInc
, FObj
.Y
+PLAYER_HEADRECT
.Y
+YInc
,
3265 PLAYER_HEADRECT
.Width
, PLAYER_HEADRECT
.Height
,
3266 PANEL_WATER
or PANEL_ACID1
or PANEL_ACID2
, True);
3269 procedure TPlayer
.FlamerOn
;
3271 FFlameSoundOff
.Stop();
3272 FFlameSoundOff
.SetPosition(0);
3275 if (not FFlameSoundOn
.IsPlaying()) and (not FFlameSoundWork
.IsPlaying()) then
3276 FFlameSoundWork
.PlayAt(FObj
.X
, FObj
.Y
);
3280 FFlameSoundOn
.PlayAt(FObj
.X
, FObj
.Y
);
3285 procedure TPlayer
.FlamerOff
;
3289 FFlameSoundOn
.Stop();
3290 FFlameSoundOn
.SetPosition(0);
3291 FFlameSoundWork
.Stop();
3292 FFlameSoundWork
.SetPosition(0);
3293 FFlameSoundOff
.PlayAt(FObj
.X
, FObj
.Y
);
3298 procedure TPlayer
.JetpackOn
;
3302 FJetSoundOn
.SetPosition(0);
3303 FJetSoundOn
.PlayAt(FObj
.X
, FObj
.Y
);
3307 procedure TPlayer
.JetpackOff
;
3311 FJetSoundOff
.SetPosition(0);
3312 FJetSoundOff
.PlayAt(FObj
.X
, FObj
.Y
);
3315 procedure TPlayer
.CatchFire(Attacker
: Word; Timeout
: Integer = PLAYER_BURN_TIME
);
3317 if Timeout
<= 0 then
3319 if (FMegaRulez
[MR_SUIT
] > gTime
) or (FMegaRulez
[MR_INVUL
] > gTime
) then
3320 exit
; // Íå çàãîðàåìñÿ êîãäà åñòü çàùèòà
3321 if g_Obj_CollidePanel(@FObj
, 0, 0, PANEL_WATER
or PANEL_ACID1
or PANEL_ACID2
) then
3322 exit
; // Íå ïîäãîðàåì â âîäå íà âñÿêèé ñëó÷àé
3323 if FFireTime
<= 0 then
3324 g_Sound_PlayExAt('SOUND_IGNITE', FObj
.X
, FObj
.Y
);
3325 FFireTime
:= Timeout
;
3326 FFireAttacker
:= Attacker
;
3327 if g_Game_IsNet
and g_Game_IsServer
then
3328 MH_SEND_PlayerStats(FUID
);
3331 procedure TPlayer
.Jump();
3333 if gFly
or FJetpack
then
3335 // Ïîëåò (÷èò-êîä èëè äæåòïàê):
3336 if FObj
.Vel
.Y
> -VEL_FLY
then
3337 FObj
.Vel
.Y
:= FObj
.Vel
.Y
- 3;
3340 if FJetFuel
> 0 then
3342 if (FJetFuel
< 1) and g_Game_IsServer
then
3346 if g_Game_IsNet
then
3347 MH_SEND_PlayerStats(FUID
);
3353 // Íå âêëþ÷àòü äæåòïàê â ðåæèìå ïðîõîæäåíèÿ ñêâîçü ñòåíû
3355 FCanJetpack
:= False;
3357 // Ïðûãàåì èëè âñïëûâàåì:
3358 if (CollideLevel(0, 1) or
3359 g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+PLAYER_RECT
.Y
+36, PLAYER_RECT
.Width
,
3360 PLAYER_RECT
.Height
-33, PANEL_STEP
, False)
3361 ) and (FObj
.Accel
.Y
= 0) then // Íå ïðûãàòü, åñëè åñòü âåðòèêàëüíîå óñêîðåíèå
3363 FObj
.Vel
.Y
:= -VEL_JUMP
;
3364 FCanJetpack
:= False;
3368 if BodyInLiquid(0, 0) then
3369 FObj
.Vel
.Y
:= -VEL_SW
3370 else if (FJetFuel
> 0) and FCanJetpack
and
3371 g_Game_IsServer
and (not g_Obj_CollideLiquid(@FObj
, 0, 0)) then
3375 if g_Game_IsNet
then
3376 MH_SEND_PlayerStats(FUID
);
3381 procedure TPlayer
.Kill(KillType
: Byte; SpawnerUID
: Word; t
: Byte);
3383 a
, i
, k
, ab
, ar
: Byte;
3387 srv
, netsrv
: Boolean;
3393 procedure PushItem(t
: Byte);
3397 id
:= g_Items_Create(FObj
.X
, FObj
.Y
, t
, True, False);
3398 it
:= g_Items_ByIdx(id
);
3399 if KillType
= K_EXTRAHARDKILL
then // -7..+7; -8..0
3401 g_Obj_Push(@it
.Obj
, (FObj
.Vel
.X
div 2)-7+Random(15),
3402 (FObj
.Vel
.Y
div 2)-Random(9));
3403 it
.positionChanged(); // this updates spatial accelerators
3407 if KillType
= K_HARDKILL
then // -5..+5; -5..0
3409 g_Obj_Push(@it
.Obj
, (FObj
.Vel
.X
div 2)-5+Random(11),
3410 (FObj
.Vel
.Y
div 2)-Random(6));
3412 else // -3..+3; -3..0
3414 g_Obj_Push(@it
.Obj
, (FObj
.Vel
.X
div 2)-3+Random(7),
3415 (FObj
.Vel
.Y
div 2)-Random(4));
3417 it
.positionChanged(); // this updates spatial accelerators
3420 if g_Game_IsNet
and g_Game_IsServer
then
3421 MH_SEND_ItemSpawn(True, id
);
3425 DoFrags
:= (gGameSettings
.MaxLives
= 0) or (gGameSettings
.GameMode
= GM_COOP
);
3426 Srv
:= g_Game_IsServer
;
3427 Netsrv
:= g_Game_IsServer
and g_Game_IsNet
;
3428 if Srv
then FDeath
:= FDeath
+ 1;
3433 if not FPhysics
then
3439 if (gGameSettings
.MaxLives
> 0) and Srv
and (gLMSRespawn
= LMS_RESPAWN_NONE
) then
3441 if FLives
> 0 then FLives
:= FLives
- 1;
3442 if FLives
= 0 then FNoRespawn
:= True;
3445 // Íîìåð òèïà ñìåðòè:
3448 K_SIMPLEKILL
: a
:= 1;
3450 K_EXTRAHARDKILL
: a
:= 3;
3455 if not FModel
.PlaySound(MODELSOUND_DIE
, a
, FObj
.X
, FObj
.Y
) then
3457 if FModel
.PlaySound(MODELSOUND_DIE
, i
, FObj
.X
, FObj
.Y
) then
3464 FTime
[T_RESPAWN
] := gTime
+ TIME_RESPAWN1
;
3466 FTime
[T_RESPAWN
] := gTime
+ TIME_RESPAWN2
;
3467 K_EXTRAHARDKILL
, K_FALLKILL
:
3468 FTime
[T_RESPAWN
] := gTime
+ TIME_RESPAWN3
;
3471 // Ïåðåêëþ÷àåì ñîñòîÿíèå:
3475 K_HARDKILL
, K_EXTRAHARDKILL
:
3479 // Ðåàêöèÿ ìîíñòðîâ íà ñìåðòü èãðîêà:
3480 if (KillType
<> K_FALLKILL
) and (Srv
) then
3481 g_Monsters_killedp();
3483 if SpawnerUID
= FUID
then
3485 if Srv
and (DoFrags
or (gGameSettings
.GameMode
= GM_TDM
)) then
3490 g_Console_Add(Format(_lc
[I_PLAYER_KILL_SELF
], [FName
]), True);
3493 if g_GetUIDType(SpawnerUID
) = UID_PLAYER
then
3494 begin // Óáèò äðóãèì èãðîêîì
3495 KP
:= g_Player_Get(SpawnerUID
);
3496 if (KP
<> nil) and Srv
then
3498 if (DoFrags
or (gGameSettings
.GameMode
= GM_TDM
)) then
3499 if SameTeam(FUID
, SpawnerUID
) then
3509 if (gGameSettings
.GameMode
= GM_TDM
) and DoFrags
then
3510 Inc(gTeamStat
[KP
.Team
].Goals
,
3511 IfThen(SameTeam(FUID
, SpawnerUID
), -1, 1));
3513 if netsrv
then MH_SEND_PlayerStats(SpawnerUID
);
3516 plr
:= g_Player_Get(SpawnerUID
);
3524 g_Console_Add(Format(_lc
[I_PLAYER_KILL_EXTRAHARD_2
],
3528 g_Console_Add(Format(_lc
[I_PLAYER_KILL_EXTRAHARD_1
],
3532 g_Console_Add(Format(_lc
[I_PLAYER_KILL
],
3537 else if g_GetUIDType(SpawnerUID
) = UID_MONSTER
then
3538 begin // Óáèò ìîíñòðîì
3539 mon
:= g_Monsters_ByUID(SpawnerUID
);
3543 s
:= g_Mons_GetKilledByTypeId(mon
.MonsterType
);
3547 g_Console_Add(Format(_lc
[I_PLAYER_KILL_EXTRAHARD_2
],
3551 g_Console_Add(Format(_lc
[I_PLAYER_KILL_EXTRAHARD_1
],
3555 g_Console_Add(Format(_lc
[I_PLAYER_KILL
],
3560 else // Îñîáûå òèïû ñìåðòè
3563 HIT_SELF
: g_Console_Add(Format(_lc
[I_PLAYER_KILL_SELF
], [FName
]), True);
3564 HIT_FALL
: g_Console_Add(Format(_lc
[I_PLAYER_KILL_FALL
], [FName
]), True);
3565 HIT_WATER
: g_Console_Add(Format(_lc
[I_PLAYER_KILL_WATER
], [FName
]), True);
3566 HIT_ACID
: g_Console_Add(Format(_lc
[I_PLAYER_KILL_ACID
], [FName
]), True);
3567 HIT_TRAP
: g_Console_Add(Format(_lc
[I_PLAYER_KILL_TRAP
], [FName
]), True);
3568 else g_Console_Add(Format(_lc
[I_PLAYER_DIED
], [FName
]), True);
3574 for a
:= WP_FIRST
to WP_LAST
do
3578 WEAPON_SAW
: i
:= ITEM_WEAPON_SAW
;
3579 WEAPON_SHOTGUN1
: i
:= ITEM_WEAPON_SHOTGUN1
;
3580 WEAPON_SHOTGUN2
: i
:= ITEM_WEAPON_SHOTGUN2
;
3581 WEAPON_CHAINGUN
: i
:= ITEM_WEAPON_CHAINGUN
;
3582 WEAPON_ROCKETLAUNCHER
: i
:= ITEM_WEAPON_ROCKETLAUNCHER
;
3583 WEAPON_PLASMA
: i
:= ITEM_WEAPON_PLASMA
;
3584 WEAPON_BFG
: i
:= ITEM_WEAPON_BFG
;
3585 WEAPON_SUPERPULEMET
: i
:= ITEM_WEAPON_SUPERPULEMET
;
3586 WEAPON_FLAMETHROWER
: i
:= ITEM_WEAPON_FLAMETHROWER
;
3595 if R_ITEM_BACKPACK
in FRulez
then
3596 PushItem(ITEM_AMMO_BACKPACK
);
3598 // Âûáðîñ ðàêåòíîãî ðàíöà:
3599 if FJetFuel
> 0 then
3600 PushItem(ITEM_JETPACK
);
3603 if (not (gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
])) or
3604 (not LongBool(gGameSettings
.Options
and GAME_OPTION_DMKEYS
)) then
3606 if R_KEY_RED
in FRulez
then
3607 PushItem(ITEM_KEY_RED
);
3609 if R_KEY_GREEN
in FRulez
then
3610 PushItem(ITEM_KEY_GREEN
);
3612 if R_KEY_BLUE
in FRulez
then
3613 PushItem(ITEM_KEY_BLUE
);
3617 DropFlag(KillType
= K_FALLKILL
);
3620 FCorpse
:= g_Player_CreateCorpse(Self
);
3622 if Srv
and (gGameSettings
.MaxLives
> 0) and FNoRespawn
and
3623 (gLMSRespawn
= LMS_RESPAWN_NONE
) then
3629 for i
:= Low(gPlayers
) to High(gPlayers
) do
3631 if gPlayers
[i
] = nil then continue
;
3632 if (not gPlayers
[i
].FNoRespawn
) and (not gPlayers
[i
].FSpectator
) then
3635 if gPlayers
[i
].FTeam
= TEAM_RED
then Inc(ar
)
3636 else if gPlayers
[i
].FTeam
= TEAM_BLUE
then Inc(ab
);
3641 OldLR
:= gLMSRespawn
;
3642 if (gGameSettings
.GameMode
= GM_COOP
) then
3646 // everyone is dead, restart the map
3647 g_Game_Message(_lc
[I_MESSAGE_LMS_LOSE
], 144);
3649 MH_SEND_GameEvent(NET_EV_LMS_LOSE
);
3650 gLMSRespawn
:= LMS_RESPAWN_FINAL
;
3651 gLMSRespawnTime
:= gTime
+ 5000;
3653 else if (a
= 1) then
3655 if (gPlayers
[k
] <> nil) and not (gPlayers
[k
] is TBot
) then
3656 if (gPlayers
[k
] = gPlayer1
) or
3657 (gPlayers
[k
] = gPlayer2
) then
3658 g_Console_Add('*** ' + _lc
[I_MESSAGE_LMS_SURVIVOR
] + ' ***', True)
3659 else if Netsrv
and (gPlayers
[k
].FClientID
>= 0) then
3660 MH_SEND_GameEvent(NET_EV_LMS_SURVIVOR
, 0, 'N', gPlayers
[k
].FClientID
);
3663 else if (gGameSettings
.GameMode
= GM_TDM
) then
3665 if (ab
= 0) and (ar
<> 0) then
3668 g_Game_Message(Format(_lc
[I_MESSAGE_TLMS_WIN
], [AnsiUpperCase(_lc
[I_GAME_TEAM_RED
])]), 144);
3670 MH_SEND_GameEvent(NET_EV_TLMS_WIN
, TEAM_RED
);
3671 Inc(gTeamStat
[TEAM_RED
].Goals
);
3672 gLMSRespawn
:= LMS_RESPAWN_FINAL
;
3673 gLMSRespawnTime
:= gTime
+ 5000;
3675 else if (ar
= 0) and (ab
<> 0) then
3678 g_Game_Message(Format(_lc
[I_MESSAGE_TLMS_WIN
], [AnsiUpperCase(_lc
[I_GAME_TEAM_BLUE
])]), 144);
3680 MH_SEND_GameEvent(NET_EV_TLMS_WIN
, TEAM_BLUE
);
3681 Inc(gTeamStat
[TEAM_BLUE
].Goals
);
3682 gLMSRespawn
:= LMS_RESPAWN_FINAL
;
3683 gLMSRespawnTime
:= gTime
+ 5000;
3685 else if (ar
= 0) and (ab
= 0) then
3688 g_Game_Message(_lc
[I_GAME_WIN_DRAW
], 144);
3690 MH_SEND_GameEvent(NET_EV_LMS_DRAW
, 0, FName
);
3691 gLMSRespawn
:= LMS_RESPAWN_FINAL
;
3692 gLMSRespawnTime
:= gTime
+ 5000;
3695 else if (gGameSettings
.GameMode
= GM_DM
) then
3699 if gPlayers
[k
] <> nil then
3702 // survivor is the winner
3703 g_Game_Message(Format(_lc
[I_MESSAGE_LMS_WIN
], [AnsiUpperCase(FName
)]), 144);
3705 MH_SEND_GameEvent(NET_EV_LMS_WIN
, 0, FName
);
3708 gLMSRespawn
:= LMS_RESPAWN_FINAL
;
3709 gLMSRespawnTime
:= gTime
+ 5000;
3711 else if (a
= 0) then
3713 // everyone is dead, restart the map
3714 g_Game_Message(_lc
[I_GAME_WIN_DRAW
], 144);
3716 MH_SEND_GameEvent(NET_EV_LMS_DRAW
, 0, FName
);
3717 gLMSRespawn
:= LMS_RESPAWN_FINAL
;
3718 gLMSRespawnTime
:= gTime
+ 5000;
3721 if srv
and (OldLR
= LMS_RESPAWN_NONE
) and (gLMSRespawn
> LMS_RESPAWN_NONE
) then
3723 if NetMode
= NET_SERVER
then
3724 MH_SEND_GameEvent(NET_EV_LMS_WARMUP
, gLMSRespawnTime
- gTime
)
3726 g_Console_Add(Format(_lc
[I_MSG_WARMUP_START
], [(gLMSRespawnTime
- gTime
) div 1000]), True);
3732 MH_SEND_PlayerStats(FUID
);
3733 MH_SEND_PlayerDeath(FUID
, KillType
, t
, SpawnerUID
);
3734 if gGameSettings
.GameMode
= GM_TDM
then MH_SEND_GameStats
;
3737 if srv
and FNoRespawn
then Spectate(True);
3738 FWantsInGame
:= True;
3741 function TPlayer
.BodyInLiquid(XInc
, YInc
: Integer): Boolean;
3743 Result
:= g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
, PLAYER_RECT
.Width
,
3744 PLAYER_RECT
.Height
-20, PANEL_WATER
or PANEL_ACID1
or PANEL_ACID2
, False);
3747 function TPlayer
.BodyInAcid(XInc
, YInc
: Integer): Boolean;
3749 Result
:= g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
, PLAYER_RECT
.Width
,
3750 PLAYER_RECT
.Height
-20, PANEL_ACID1
or PANEL_ACID2
, False);
3753 procedure TPlayer
.MakeBloodSimple(Count
: Word);
3755 g_GFX_Blood(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)+8,
3756 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2),
3757 Count
div 2, 3, -1, 16, (PLAYER_RECT
.Height
*2 div 3),
3758 FModel
.Blood
.R
, FModel
.Blood
.G
, FModel
.Blood
.B
, FModel
.Blood
.Kind
);
3759 g_GFX_Blood(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-8,
3760 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2),
3761 Count
div 2, -3, -1, 16, (PLAYER_RECT
.Height
*2) div 3,
3762 FModel
.Blood
.R
, FModel
.Blood
.G
, FModel
.Blood
.B
, FModel
.Blood
.Kind
);
3765 procedure TPlayer
.MakeBloodVector(Count
: Word; VelX
, VelY
: Integer);
3767 g_GFX_Blood(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2),
3768 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2),
3769 Count
, VelX
, VelY
, 16, (PLAYER_RECT
.Height
*2) div 3,
3770 FModel
.Blood
.R
, FModel
.Blood
.G
, FModel
.Blood
.B
, FModel
.Blood
.Kind
);
3773 procedure TPlayer
.QueueWeaponSwitch(Weapon
: Byte);
3775 if g_Game_IsClient
then Exit
;
3776 if Weapon
> High(FWeapon
) then Exit
;
3777 FNextWeap
:= FNextWeap
or (1 shl Weapon
);
3780 procedure TPlayer
.resetWeaponQueue ();
3783 FNextWeapDelay
:= 0;
3786 function TPlayer
.hasAmmoForWeapon (weapon
: Byte): Boolean;
3790 WEAPON_KASTET
, WEAPON_SAW
: result
:= true;
3791 WEAPON_SHOTGUN1
, WEAPON_SHOTGUN2
, WEAPON_SUPERPULEMET
: result
:= (FAmmo
[A_SHELLS
] > 0);
3792 WEAPON_PISTOL
, WEAPON_CHAINGUN
: result
:= (FAmmo
[A_BULLETS
] > 0);
3793 WEAPON_ROCKETLAUNCHER
: result
:= (FAmmo
[A_ROCKETS
] > 0);
3794 WEAPON_PLASMA
, WEAPON_BFG
: result
:= (FAmmo
[A_CELLS
] > 0);
3795 WEAPON_FLAMETHROWER
: result
:= (FAmmo
[A_FUEL
] > 0);
3796 else result
:= (weapon
< length(FWeapon
));
3800 // return 255 for "no switch"
3801 function TPlayer
.getNextWeaponIndex (): Byte;
3804 wantThisWeapon
: array[0..64] of Boolean;
3805 wwc
: Integer = 0; //HACK!
3808 result
:= 255; // default result: "no switch"
3809 // had weapon cycling on previous frame? remove that flag
3810 if (FNextWeap
and $2000) <> 0 then
3812 FNextWeap
:= FNextWeap
and $1FFF;
3813 FNextWeapDelay
:= 0;
3815 // cycling has priority
3816 if (FNextWeap
and $C000) <> 0 then
3818 if (FNextWeap
and $8000) <> 0 then
3822 FNextWeap
:= FNextWeap
or $2000; // we need this
3823 if FNextWeapDelay
> 0 then
3824 exit
; // cooldown time
3826 for i
:= 0 to High(FWeapon
) do
3828 cwi
:= (cwi
+length(FWeapon
)+dir
) mod length(FWeapon
);
3829 if FWeapon
[cwi
] then
3831 //e_WriteLog(Format(' SWITCH: cur=%d; new=%d', [FCurrWeap, cwi]), MSG_WARNING);
3832 result
:= Byte(cwi
);
3833 FNextWeapDelay
:= WEAPON_DELAY
;
3841 for i
:= 0 to High(wantThisWeapon
) do
3842 wantThisWeapon
[i
] := false;
3843 for i
:= 0 to High(FWeapon
) do
3844 if (FNextWeap
and (1 shl i
)) <> 0 then
3846 wantThisWeapon
[i
] := true;
3849 // exclude currently selected weapon from the set
3850 wantThisWeapon
[FCurrWeap
] := false;
3851 // slow down alterations a little
3854 //e_WriteLog(Format(' FNextWeap=%x; delay=%d', [FNextWeap, FNextWeapDelay]), MSG_WARNING);
3855 // more than one weapon requested, assume "alteration" and check alteration delay
3856 if FNextWeapDelay
> 0 then
3862 // do not reset weapon queue, it will be done in `RealizeCurrentWeapon()`
3863 // but clear all counters if no weapon should be switched
3869 //e_WriteLog(Format('wwc=%d', [wwc]), MSG_WARNING);
3870 // try weapons in descending order
3871 for i
:= High(FWeapon
) downto 0 do
3873 if wantThisWeapon
[i
] and FWeapon
[i
] and ((wwc
= 1) or hasAmmoForWeapon(i
)) then
3878 FNextWeapDelay
:= WEAPON_DELAY
* 2; // anyway, 'cause why not
3882 // no suitable weapon found, so reset the queue, to avoid accidental "queuing" of weapon w/o ammo
3886 procedure TPlayer
.RealizeCurrentWeapon();
3887 function switchAllowed (): Boolean;
3892 if FBFGFireCounter
<> -1 then
3894 if FTime
[T_SWITCH
] > gTime
then
3896 for i
:= WP_FIRST
to WP_LAST
do
3897 if FReloading
[i
] > 0 then
3905 //e_WriteLog(Format('***RealizeCurrentWeapon: FNextWeap=%x; FNextWeapDelay=%d', [FNextWeap, FNextWeapDelay]), MSG_WARNING);
3906 //FNextWeap := FNextWeap and $1FFF;
3907 if FNextWeapDelay
> 0 then Dec(FNextWeapDelay
); // "alteration delay"
3909 if not switchAllowed
then
3911 //HACK for weapon cycling
3912 if (FNextWeap
and $E000) <> 0 then FNextWeap
:= 0;
3916 nw
:= getNextWeaponIndex();
3917 if nw
= 255 then exit
; // don't reset anything here
3918 if nw
> High(FWeapon
) then
3920 // don't forget to reset queue here!
3921 //e_WriteLog(' RealizeCurrentWeapon: WUTAFUUUU', MSG_WARNING);
3929 FTime
[T_SWITCH
] := gTime
+156;
3930 if FCurrWeap
= WEAPON_SAW
then FSawSoundSelect
.PlayAt(FObj
.X
, FObj
.Y
);
3931 FModel
.SetWeapon(FCurrWeap
);
3932 if g_Game_IsNet
then MH_SEND_PlayerStats(FUID
);
3936 procedure TPlayer
.NextWeapon();
3938 if g_Game_IsClient
then Exit
;
3942 procedure TPlayer
.PrevWeapon();
3944 if g_Game_IsClient
then Exit
;
3948 procedure TPlayer
.SetWeapon(W
: Byte);
3950 if FCurrWeap
<> W
then
3951 if W
= WEAPON_SAW
then
3952 FSawSoundSelect
.PlayAt(FObj
.X
, FObj
.Y
);
3955 FModel
.SetWeapon(CurrWeap
);
3959 function TPlayer
.PickItem(ItemType
: Byte; arespawn
: Boolean; var remove
: Boolean): Boolean;
3961 function allowBerserkSwitching (): Boolean;
3963 if (FBFGFireCounter
<> -1) then begin result
:= false; exit
; end;
3965 if gBerserkAutoswitch
then exit
;
3966 if not conIsCheatsEnabled
then exit
;
3974 if g_Game_IsClient
then Exit
;
3976 // a = true - ìåñòî ñïàâíà ïðåäìåòà:
3977 a
:= LongBool(gGameSettings
.Options
and GAME_OPTION_WEAPONSTAY
) and arespawn
;
3982 if (FHealth
< PLAYER_HP_SOFT
) or (FFireTime
> 0) then
3984 if FHealth
< PLAYER_HP_SOFT
then IncMax(FHealth
, 10, PLAYER_HP_SOFT
);
3988 if gFlash
= 2 then Inc(FPickup
, 5);
3992 if (FHealth
< PLAYER_HP_SOFT
) or (FFireTime
> 0) then
3994 if FHealth
< PLAYER_HP_SOFT
then IncMax(FHealth
, 25, PLAYER_HP_SOFT
);
3998 if gFlash
= 2 then Inc(FPickup
, 5);
4002 if FArmor
< PLAYER_AP_SOFT
then
4004 FArmor
:= PLAYER_AP_SOFT
;
4007 if gFlash
= 2 then Inc(FPickup
, 5);
4011 if FArmor
< PLAYER_AP_LIMIT
then
4013 FArmor
:= PLAYER_AP_LIMIT
;
4016 if gFlash
= 2 then Inc(FPickup
, 5);
4020 if (FHealth
< PLAYER_HP_LIMIT
) or (FFireTime
> 0) then
4022 if FHealth
< PLAYER_HP_LIMIT
then IncMax(FHealth
, 100, PLAYER_HP_LIMIT
);
4026 if gFlash
= 2 then Inc(FPickup
, 5);
4030 if (FHealth
< PLAYER_HP_LIMIT
) or (FArmor
< PLAYER_AP_LIMIT
) or (FFireTime
> 0) then
4032 if FHealth
< PLAYER_HP_LIMIT
then
4033 FHealth
:= PLAYER_HP_LIMIT
;
4034 if FArmor
< PLAYER_AP_LIMIT
then
4035 FArmor
:= PLAYER_AP_LIMIT
;
4039 if gFlash
= 2 then Inc(FPickup
, 5);
4043 if (not FWeapon
[WEAPON_SAW
]) or ((not arespawn
) and (gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
])) then
4045 FWeapon
[WEAPON_SAW
] := True;
4047 if gFlash
= 2 then Inc(FPickup
, 5);
4048 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
4051 ITEM_WEAPON_SHOTGUN1
:
4052 if (FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
]) or not FWeapon
[WEAPON_SHOTGUN1
] then
4054 // Íóæíî, ÷òîáû íå âçÿòü âñå ïóëè ñðàçó:
4055 if a
and FWeapon
[WEAPON_SHOTGUN1
] then Exit
;
4057 IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
4058 FWeapon
[WEAPON_SHOTGUN1
] := True;
4060 if gFlash
= 2 then Inc(FPickup
, 5);
4061 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
4064 ITEM_WEAPON_SHOTGUN2
:
4065 if (FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
]) or not FWeapon
[WEAPON_SHOTGUN2
] then
4067 if a
and FWeapon
[WEAPON_SHOTGUN2
] then Exit
;
4069 IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
4070 FWeapon
[WEAPON_SHOTGUN2
] := True;
4072 if gFlash
= 2 then Inc(FPickup
, 5);
4073 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
4076 ITEM_WEAPON_CHAINGUN
:
4077 if (FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
]) or not FWeapon
[WEAPON_CHAINGUN
] then
4079 if a
and FWeapon
[WEAPON_CHAINGUN
] then Exit
;
4081 IncMax(FAmmo
[A_BULLETS
], 50, FMaxAmmo
[A_BULLETS
]);
4082 FWeapon
[WEAPON_CHAINGUN
] := True;
4084 if gFlash
= 2 then Inc(FPickup
, 5);
4085 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
4088 ITEM_WEAPON_ROCKETLAUNCHER
:
4089 if (FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
]) or not FWeapon
[WEAPON_ROCKETLAUNCHER
] then
4091 if a
and FWeapon
[WEAPON_ROCKETLAUNCHER
] then Exit
;
4093 IncMax(FAmmo
[A_ROCKETS
], 2, FMaxAmmo
[A_ROCKETS
]);
4094 FWeapon
[WEAPON_ROCKETLAUNCHER
] := True;
4096 if gFlash
= 2 then Inc(FPickup
, 5);
4097 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
4101 if (FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
]) or not FWeapon
[WEAPON_PLASMA
] then
4103 if a
and FWeapon
[WEAPON_PLASMA
] then Exit
;
4105 IncMax(FAmmo
[A_CELLS
], 40, FMaxAmmo
[A_CELLS
]);
4106 FWeapon
[WEAPON_PLASMA
] := True;
4108 if gFlash
= 2 then Inc(FPickup
, 5);
4109 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
4113 if (FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
]) or not FWeapon
[WEAPON_BFG
] then
4115 if a
and FWeapon
[WEAPON_BFG
] then Exit
;
4117 IncMax(FAmmo
[A_CELLS
], 40, FMaxAmmo
[A_CELLS
]);
4118 FWeapon
[WEAPON_BFG
] := True;
4120 if gFlash
= 2 then Inc(FPickup
, 5);
4121 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
4124 ITEM_WEAPON_SUPERPULEMET
:
4125 if (FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
]) or not FWeapon
[WEAPON_SUPERPULEMET
] then
4127 if a
and FWeapon
[WEAPON_SUPERPULEMET
] then Exit
;
4129 IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
4130 FWeapon
[WEAPON_SUPERPULEMET
] := True;
4132 if gFlash
= 2 then Inc(FPickup
, 5);
4133 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
4136 ITEM_WEAPON_FLAMETHROWER
:
4137 if (FAmmo
[A_FUEL
] < FMaxAmmo
[A_FUEL
]) or not FWeapon
[WEAPON_FLAMETHROWER
] then
4139 if a
and FWeapon
[WEAPON_FLAMETHROWER
] then Exit
;
4141 IncMax(FAmmo
[A_FUEL
], 100, FMaxAmmo
[A_FUEL
]);
4142 FWeapon
[WEAPON_FLAMETHROWER
] := True;
4144 if gFlash
= 2 then Inc(FPickup
, 5);
4145 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
4149 if FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
] then
4151 IncMax(FAmmo
[A_BULLETS
], 10, FMaxAmmo
[A_BULLETS
]);
4154 if gFlash
= 2 then Inc(FPickup
, 5);
4157 ITEM_AMMO_BULLETS_BOX
:
4158 if FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
] then
4160 IncMax(FAmmo
[A_BULLETS
], 50, FMaxAmmo
[A_BULLETS
]);
4163 if gFlash
= 2 then Inc(FPickup
, 5);
4167 if FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
] then
4169 IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
4172 if gFlash
= 2 then Inc(FPickup
, 5);
4175 ITEM_AMMO_SHELLS_BOX
:
4176 if FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
] then
4178 IncMax(FAmmo
[A_SHELLS
], 25, FMaxAmmo
[A_SHELLS
]);
4181 if gFlash
= 2 then Inc(FPickup
, 5);
4185 if FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
] then
4187 IncMax(FAmmo
[A_ROCKETS
], 1, FMaxAmmo
[A_ROCKETS
]);
4190 if gFlash
= 2 then Inc(FPickup
, 5);
4193 ITEM_AMMO_ROCKET_BOX
:
4194 if FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
] then
4196 IncMax(FAmmo
[A_ROCKETS
], 5, FMaxAmmo
[A_ROCKETS
]);
4199 if gFlash
= 2 then Inc(FPickup
, 5);
4203 if FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
] then
4205 IncMax(FAmmo
[A_CELLS
], 40, FMaxAmmo
[A_CELLS
]);
4208 if gFlash
= 2 then Inc(FPickup
, 5);
4212 if FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
] then
4214 IncMax(FAmmo
[A_CELLS
], 100, FMaxAmmo
[A_CELLS
]);
4217 if gFlash
= 2 then Inc(FPickup
, 5);
4221 if FAmmo
[A_FUEL
] < FMaxAmmo
[A_FUEL
] then
4223 IncMax(FAmmo
[A_FUEL
], 100, FMaxAmmo
[A_FUEL
]);
4226 if gFlash
= 2 then Inc(FPickup
, 5);
4230 if not(R_ITEM_BACKPACK
in FRulez
) or
4231 (FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
]) or
4232 (FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
]) or
4233 (FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
]) or
4234 (FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
]) or
4235 (FAmmo
[A_FUEL
] < FMaxAmmo
[A_FUEL
]) then
4237 FMaxAmmo
[A_BULLETS
] := AmmoLimits
[1, A_BULLETS
];
4238 FMaxAmmo
[A_SHELLS
] := AmmoLimits
[1, A_SHELLS
];
4239 FMaxAmmo
[A_ROCKETS
] := AmmoLimits
[1, A_ROCKETS
];
4240 FMaxAmmo
[A_CELLS
] := AmmoLimits
[1, A_CELLS
];
4241 FMaxAmmo
[A_FUEL
] := AmmoLimits
[1, A_FUEL
];
4243 if FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
] then
4244 IncMax(FAmmo
[A_BULLETS
], 10, FMaxAmmo
[A_BULLETS
]);
4245 if FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
] then
4246 IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
4247 if FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
] then
4248 IncMax(FAmmo
[A_ROCKETS
], 1, FMaxAmmo
[A_ROCKETS
]);
4249 if FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
] then
4250 IncMax(FAmmo
[A_CELLS
], 40, FMaxAmmo
[A_CELLS
]);
4251 if FAmmo
[A_FUEL
] < FMaxAmmo
[A_FUEL
] then
4252 IncMax(FAmmo
[A_FUEL
], 50, FMaxAmmo
[A_FUEL
]);
4254 FRulez
:= FRulez
+ [R_ITEM_BACKPACK
];
4257 if gFlash
= 2 then Inc(FPickup
, 5);
4261 if not(R_KEY_RED
in FRulez
) then
4263 Include(FRulez
, R_KEY_RED
);
4265 remove
:= (gGameSettings
.GameMode
<> GM_COOP
) and (g_Player_GetCount() < 2);
4266 if gFlash
= 2 then Inc(FPickup
, 5);
4267 if (not remove
) and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETITEM');
4271 if not(R_KEY_GREEN
in FRulez
) then
4273 Include(FRulez
, R_KEY_GREEN
);
4275 remove
:= (gGameSettings
.GameMode
<> GM_COOP
) and (g_Player_GetCount() < 2);
4276 if gFlash
= 2 then Inc(FPickup
, 5);
4277 if (not remove
) and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETITEM');
4281 if not(R_KEY_BLUE
in FRulez
) then
4283 Include(FRulez
, R_KEY_BLUE
);
4285 remove
:= (gGameSettings
.GameMode
<> GM_COOP
) and (g_Player_GetCount() < 2);
4286 if gFlash
= 2 then Inc(FPickup
, 5);
4287 if (not remove
) and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETITEM');
4291 if FMegaRulez
[MR_SUIT
] < gTime
+PLAYER_SUIT_TIME
then
4293 FMegaRulez
[MR_SUIT
] := gTime
+PLAYER_SUIT_TIME
;
4297 if gFlash
= 2 then Inc(FPickup
, 5);
4301 if FAir
< AIR_MAX
then
4306 if gFlash
= 2 then Inc(FPickup
, 5);
4311 if not (R_BERSERK
in FRulez
) then
4313 Include(FRulez
, R_BERSERK
);
4314 if allowBerserkSwitching
then
4316 FCurrWeap
:= WEAPON_KASTET
;
4318 FModel
.SetWeapon(WEAPON_KASTET
);
4323 if gFlash
= 2 then Inc(FPickup
, 5);
4325 FBerserk
:= gTime
+30000;
4330 if (FHealth
< PLAYER_HP_SOFT
) or (FFireTime
> 0) then
4332 if FHealth
< PLAYER_HP_SOFT
then FHealth
:= PLAYER_HP_SOFT
;
4333 FBerserk
:= gTime
+30000;
4341 if FMegaRulez
[MR_INVUL
] < gTime
+PLAYER_INVUL_TIME
then
4343 FMegaRulez
[MR_INVUL
] := gTime
+PLAYER_INVUL_TIME
;
4347 if gFlash
= 2 then Inc(FPickup
, 5);
4351 if (FHealth
< PLAYER_HP_LIMIT
) or (FFireTime
> 0) then
4353 if FHealth
< PLAYER_HP_LIMIT
then IncMax(FHealth
, 4, PLAYER_HP_LIMIT
);
4357 if gFlash
= 2 then Inc(FPickup
, 5);
4361 if FArmor
< PLAYER_AP_LIMIT
then
4363 IncMax(FArmor
, 5, PLAYER_AP_LIMIT
);
4366 if gFlash
= 2 then Inc(FPickup
, 5);
4370 if FJetFuel
< JET_MAX
then
4372 FJetFuel
:= JET_MAX
;
4375 if gFlash
= 2 then Inc(FPickup
, 5);
4379 if FMegaRulez
[MR_INVIS
] < gTime
+PLAYER_INVIS_TIME
then
4381 FMegaRulez
[MR_INVIS
] := gTime
+PLAYER_INVIS_TIME
;
4384 if gFlash
= 2 then Inc(FPickup
, 5);
4389 procedure TPlayer
.Touch();
4393 //FModel.PlaySound(MODELSOUND_PAIN, 1, FObj.X, FObj.Y);
4396 // Áðîñèòü ôëàã òîâàðèùó:
4397 if gGameSettings
.GameMode
= GM_CTF
then
4402 procedure TPlayer
.Push(vx
, vy
: Integer);
4404 if (not FPhysics
) and FGhost
then
4406 FObj
.Accel
.X
:= FObj
.Accel
.X
+ vx
;
4407 FObj
.Accel
.Y
:= FObj
.Accel
.Y
+ vy
;
4408 if g_Game_IsNet
and g_Game_IsServer
then
4409 MH_SEND_PlayerPos(True, FUID
, NET_EVERYONE
);
4412 procedure TPlayer
.Reset(Force
: Boolean);
4418 FTime
[T_RESPAWN
] := 0;
4419 FTime
[T_FLAGCAP
] := 0;
4435 FSpectator
:= False;
4438 FSpectatePlayer
:= -1;
4439 FNoRespawn
:= False;
4441 FLives
:= gGameSettings
.MaxLives
;
4446 procedure TPlayer
.SoftReset();
4454 FBFGFireCounter
:= -1;
4462 SetAction(A_STAND
, True);
4465 function TPlayer
.GetRespawnPoint(): Byte;
4470 // Íà áóäóùåå: FSpawn - èãðîê óæå èãðàë è ïåðåðîæäàåòñÿ
4472 // Îäèíî÷íàÿ èãðà/êîîïåðàòèâ
4473 if gGameSettings
.GameMode
in [GM_COOP
, GM_SINGLE
] then
4475 if (Self
= gPlayer1
) or (Self
= gPlayer2
) then
4477 // Òî÷êà ïîÿâëåíèÿ ñâîåãî èãðîêà
4478 if Self
= gPlayer1
then
4479 c
:= RESPAWNPOINT_PLAYER1
4481 c
:= RESPAWNPOINT_PLAYER2
;
4482 if g_Map_GetPointCount(c
) > 0 then
4488 // Òî÷êà ïîÿâëåíèÿ äðóãîãî èãðîêà
4489 if Self
= gPlayer1
then
4490 c
:= RESPAWNPOINT_PLAYER2
4492 c
:= RESPAWNPOINT_PLAYER1
;
4493 if g_Map_GetPointCount(c
) > 0 then
4500 // Òî÷êà ïîÿâëåíèÿ ëþáîãî èãðîêà (áîòà)
4501 if Random(2) = 0 then
4502 c
:= RESPAWNPOINT_PLAYER1
4504 c
:= RESPAWNPOINT_PLAYER2
;
4505 if g_Map_GetPointCount(c
) > 0 then
4512 // Òî÷êà ëþáîé èç êîìàíä
4513 if Random(2) = 0 then
4514 c
:= RESPAWNPOINT_RED
4516 c
:= RESPAWNPOINT_BLUE
;
4517 if g_Map_GetPointCount(c
) > 0 then
4524 c
:= RESPAWNPOINT_DM
;
4525 if g_Map_GetPointCount(c
) > 0 then
4533 if gGameSettings
.GameMode
= GM_DM
then
4536 c
:= RESPAWNPOINT_DM
;
4537 if g_Map_GetPointCount(c
) > 0 then
4543 // Òî÷êà ïîÿâëåíèÿ ëþáîãî èãðîêà
4544 if Random(2) = 0 then
4545 c
:= RESPAWNPOINT_PLAYER1
4547 c
:= RESPAWNPOINT_PLAYER2
;
4548 if g_Map_GetPointCount(c
) > 0 then
4554 // Òî÷êà ëþáîé èç êîìàíä
4555 if Random(2) = 0 then
4556 c
:= RESPAWNPOINT_RED
4558 c
:= RESPAWNPOINT_BLUE
;
4559 if g_Map_GetPointCount(c
) > 0 then
4567 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
4569 // Òî÷êà ñâîåé êîìàíäû
4570 c
:= RESPAWNPOINT_DM
;
4571 if FTeam
= TEAM_RED
then
4572 c
:= RESPAWNPOINT_RED
;
4573 if FTeam
= TEAM_BLUE
then
4574 c
:= RESPAWNPOINT_BLUE
;
4575 if g_Map_GetPointCount(c
) > 0 then
4582 c
:= RESPAWNPOINT_DM
;
4583 if g_Map_GetPointCount(c
) > 0 then
4589 // Òî÷êà ïîÿâëåíèÿ ëþáîãî èãðîêà
4590 if Random(2) = 0 then
4591 c
:= RESPAWNPOINT_PLAYER1
4593 c
:= RESPAWNPOINT_PLAYER2
;
4594 if g_Map_GetPointCount(c
) > 0 then
4600 // Òî÷êà äðóãîé êîìàíäû
4601 c
:= RESPAWNPOINT_DM
;
4602 if FTeam
= TEAM_RED
then
4603 c
:= RESPAWNPOINT_BLUE
;
4604 if FTeam
= TEAM_BLUE
then
4605 c
:= RESPAWNPOINT_RED
;
4606 if g_Map_GetPointCount(c
) > 0 then
4614 procedure TPlayer
.Respawn(Silent
: Boolean; Force
: Boolean = False);
4616 RespawnPoint
: TRespawnPoint
;
4624 FBFGFireCounter
:= -1;
4631 if not g_Game_IsServer
then
4635 FWantsInGame
:= True;
4636 FJustTeleported
:= True;
4639 FTime
[T_RESPAWN
] := 0;
4643 // if server changes MaxLives we gotta be ready
4644 if gGameSettings
.MaxLives
= 0 then FNoRespawn
:= False;
4646 // Åùå íåëüçÿ âîçðîäèòüñÿ:
4647 if FTime
[T_RESPAWN
] > gTime
then
4650 // Ïðîñðàë âñå æèçíè:
4653 if not FSpectator
then Spectate(True);
4654 FWantsInGame
:= True;
4658 if (gGameSettings
.GameType
<> GT_SINGLE
) and (gGameSettings
.GameMode
<> GM_COOP
) then
4659 begin // "Ñâîÿ èãðà"
4660 // Áåðñåðê íå ñîõðàíÿåòñÿ ìåæäó óðîâíÿìè:
4661 FRulez
:= FRulez
-[R_BERSERK
];
4663 else // "Îäèíî÷íàÿ èãðà"/"Êîîï"
4665 // Áåðñåðê è êëþ÷è íå ñîõðàíÿþòñÿ ìåæäó óðîâíÿìè:
4666 FRulez
:= FRulez
-[R_KEY_RED
, R_KEY_GREEN
, R_KEY_BLUE
, R_BERSERK
];
4669 // Ïîëó÷àåì òî÷êó ñïàóíà èãðîêà:
4670 c
:= GetRespawnPoint();
4675 // Âîñêðåøåíèå áåç îðóæèÿ:
4678 FHealth
:= Round(PLAYER_HP_SOFT
* (FHandicap
/ 100));
4684 for a
:= WP_FIRST
to WP_LAST
do
4686 FWeapon
[a
] := False;
4690 FWeapon
[WEAPON_PISTOL
] := True;
4691 FWeapon
[WEAPON_KASTET
] := True;
4692 FCurrWeap
:= WEAPON_PISTOL
;
4695 FModel
.SetWeapon(FCurrWeap
);
4697 for b
:= A_BULLETS
to A_HIGH
do
4700 FAmmo
[A_BULLETS
] := 50;
4702 FMaxAmmo
[A_BULLETS
] := AmmoLimits
[0, A_BULLETS
];
4703 FMaxAmmo
[A_SHELLS
] := AmmoLimits
[0, A_SHELLS
];
4704 FMaxAmmo
[A_ROCKETS
] := AmmoLimits
[0, A_SHELLS
];
4705 FMaxAmmo
[A_CELLS
] := AmmoLimits
[0, A_CELLS
];
4706 FMaxAmmo
[A_FUEL
] := AmmoLimits
[0, A_FUEL
];
4708 if (gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
]) and
4709 LongBool(gGameSettings
.Options
and GAME_OPTION_DMKEYS
) then
4710 FRulez
:= [R_KEY_RED
, R_KEY_GREEN
, R_KEY_BLUE
]
4715 // Ïîëó÷àåì êîîðäèíàòû òî÷êè âîçðîæäåíèÿ:
4716 if not g_Map_GetPoint(c
, RespawnPoint
) then
4718 g_FatalError(_lc
[I_GAME_ERROR_GET_SPAWN
]);
4722 // Óñòàíîâêà êîîðäèíàò è ñáðîñ âñåõ ïàðàìåòðîâ:
4723 FObj
.X
:= RespawnPoint
.X
-PLAYER_RECT
.X
;
4724 FObj
.Y
:= RespawnPoint
.Y
-PLAYER_RECT
.Y
;
4725 FObj
.oldX
:= FObj
.X
; // don't interpolate after respawn
4726 FObj
.oldY
:= FObj
.Y
;
4732 FDirection
:= RespawnPoint
.Direction
;
4733 if FDirection
= TDirection
.D_LEFT
then
4738 SetAction(A_STAND
, True);
4739 FModel
.Direction
:= FDirection
;
4741 for a
:= Low(FTime
) to High(FTime
) do
4744 for a
:= Low(FMegaRulez
) to High(FMegaRulez
) do
4747 // Respawn invulnerability
4748 if (gGameSettings
.GameType
<> GT_SINGLE
) and (gGameSettings
.SpawnInvul
> 0) then
4750 FMegaRulez
[MR_INVUL
] := gTime
+ gGameSettings
.SpawnInvul
* 1000;
4751 FSpawnInvul
:= FMegaRulez
[MR_INVUL
];
4756 FCanJetpack
:= False;
4762 // Àíèìàöèÿ âîçðîæäåíèÿ:
4763 if (not gLoadGameMode
) and (not Silent
) then
4764 if g_Frames_Get(ID
, 'FRAMES_TELEPORT') then
4766 Anim
:= TAnimation
.Create(ID
, False, 3);
4767 g_GFX_OnceAnim(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-32,
4768 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)-32, Anim
);
4772 FSpectator
:= False;
4775 FSpectatePlayer
:= -1;
4778 if (gPlayer1
= nil) and (gSpectLatchPID1
= FUID
) then
4780 if (gPlayer2
= nil) and (gSpectLatchPID2
= FUID
) then
4783 if g_Game_IsNet
then
4785 MH_SEND_PlayerPos(True, FUID
, NET_EVERYONE
);
4786 MH_SEND_PlayerStats(FUID
, NET_EVERYONE
);
4788 MH_SEND_Effect(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-32,
4789 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)-32,
4794 procedure TPlayer
.Spectate(NoMove
: Boolean = False);
4797 Kill(K_EXTRAHARDKILL
, FUID
, HIT_SOME
)
4798 else if (not NoMove
) then
4800 GameX
:= gMapInfo
.Width
div 2;
4801 GameY
:= gMapInfo
.Height
div 2;
4810 FWantsInGame
:= False;
4816 if Self
= gPlayer1
then
4818 gSpectLatchPID1
:= FUID
;
4821 else if Self
= gPlayer2
then
4823 gSpectLatchPID2
:= FUID
;
4828 if g_Game_IsNet
then
4829 MH_SEND_PlayerStats(FUID
);
4832 procedure TPlayer
.SwitchNoClip
;
4836 FGhost
:= not FGhost
;
4837 FPhysics
:= not FGhost
;
4849 procedure TPlayer
.Run(Direction
: TDirection
);
4853 if MAX_RUNVEL
> 8 then
4857 if Direction
= TDirection
.D_LEFT
then
4859 if FObj
.Vel
.X
> -MAX_RUNVEL
then
4860 FObj
.Vel
.X
:= FObj
.Vel
.X
- (MAX_RUNVEL
shr 3);
4863 if FObj
.Vel
.X
< MAX_RUNVEL
then
4864 FObj
.Vel
.X
:= FObj
.Vel
.X
+ (MAX_RUNVEL
shr 3);
4866 // Âîçìîæíî, ïèíàåì êóñêè:
4867 if (FObj
.Vel
.X
<> 0) and (gGibs
<> nil) then
4869 b
:= Abs(FObj
.Vel
.X
);
4870 if b
> 1 then b
:= b
* (Random(8 div b
) + 1);
4871 for a
:= 0 to High(gGibs
) do
4873 if gGibs
[a
].alive
and
4874 g_Obj_Collide(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
+FObj
.Rect
.Height
-4,
4875 FObj
.Rect
.Width
, 8, @gGibs
[a
].Obj
) and (Random(3) = 0) then
4878 if FObj
.Vel
.X
< 0 then
4880 g_Obj_PushA(@gGibs
[a
].Obj
, b
, Random(61)+120) // íàëåâî
4884 g_Obj_PushA(@gGibs
[a
].Obj
, b
, Random(61)); // íàïðàâî
4886 gGibs
[a
].positionChanged(); // this updates spatial accelerators
4894 procedure TPlayer
.SeeDown();
4896 SetAction(A_SEEDOWN
);
4898 if FDirection
= TDirection
.D_LEFT
then FAngle
:= ANGLE_LEFTDOWN
else FAngle
:= ANGLE_RIGHTDOWN
;
4900 if FIncCam
> -120 then DecMin(FIncCam
, 5, -120);
4903 procedure TPlayer
.SeeUp();
4907 if FDirection
= TDirection
.D_LEFT
then FAngle
:= ANGLE_LEFTUP
else FAngle
:= ANGLE_RIGHTUP
;
4909 if FIncCam
< 120 then IncMax(FIncCam
, 5, 120);
4912 procedure TPlayer
.SetAction(Action
: Byte; Force
: Boolean = False);
4920 A_ATTACK
: Prior
:= 2;
4921 A_SEEUP
: Prior
:= 1;
4922 A_SEEDOWN
: Prior
:= 1;
4923 A_ATTACKUP
: Prior
:= 2;
4924 A_ATTACKDOWN
: Prior
:= 2;
4929 if (Prior
> FActionPrior
) or Force
then
4930 if not ((Prior
= 2) and (FCurrWeap
= WEAPON_SAW
)) then
4932 FActionPrior
:= Prior
;
4933 FActionAnim
:= Action
;
4934 FActionForce
:= Force
;
4935 FActionChanged
:= True;
4938 if Action
in [A_ATTACK
, A_ATTACKUP
, A_ATTACKDOWN
] then FModel
.SetFire(True);
4941 function TPlayer
.StayOnStep(XInc
, YInc
: Integer): Boolean;
4943 Result
:= not g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+YInc
+PLAYER_RECT
.Y
+PLAYER_RECT
.Height
-1,
4944 PLAYER_RECT
.Width
, 1, PANEL_STEP
, False)
4945 and g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+YInc
+PLAYER_RECT
.Y
+PLAYER_RECT
.Height
,
4946 PLAYER_RECT
.Width
, 1, PANEL_STEP
, False);
4949 function TPlayer
.TeleportTo(X
, Y
: Integer; silent
: Boolean; dir
: Byte): Boolean;
4956 if g_CollideLevel(X
, Y
, PLAYER_RECT
.Width
, PLAYER_RECT
.Height
) then
4958 g_Sound_PlayExAt('SOUND_GAME_NOTELEPORT', FObj
.X
, FObj
.Y
);
4959 if g_Game_IsServer
and g_Game_IsNet
then
4960 MH_SEND_Sound(FObj
.X
, FObj
.Y
, 'SOUND_GAME_NOTELEPORT');
4964 FJustTeleported
:= True;
4969 if g_Frames_Get(ID
, 'FRAMES_TELEPORT') then
4971 Anim
:= TAnimation
.Create(ID
, False, 3);
4974 g_Sound_PlayExAt('SOUND_GAME_TELEPORT', FObj
.X
, FObj
.Y
);
4975 g_GFX_OnceAnim(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-32,
4976 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)-32, Anim
);
4977 if g_Game_IsServer
and g_Game_IsNet
then
4978 MH_SEND_Effect(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-32,
4979 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)-32, 1,
4983 FObj
.X
:= X
-PLAYER_RECT
.X
;
4984 FObj
.Y
:= Y
-PLAYER_RECT
.Y
;
4985 FObj
.oldX
:= FObj
.X
; // don't interpolate after respawn
4986 FObj
.oldY
:= FObj
.Y
;
4987 if FAlive
and FGhost
then
4993 if not g_Game_IsNet
then
4997 SetDirection(TDirection
.D_LEFT
);
5003 SetDirection(TDirection
.D_RIGHT
);
5009 if FDirection
= TDirection
.D_RIGHT
then
5011 SetDirection(TDirection
.D_LEFT
);
5016 SetDirection(TDirection
.D_RIGHT
);
5022 if not silent
and (Anim
<> nil) then
5024 g_GFX_OnceAnim(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-32,
5025 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)-32, Anim
);
5028 if g_Game_IsServer
and g_Game_IsNet
then
5029 MH_SEND_Effect(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-32,
5030 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)-32, 0,
5037 function nonz(a
: Single): Single;
5045 function TPlayer
.refreshCorpse(): Boolean;
5051 if FAlive
or FSpectator
then
5053 if (gCorpses
= nil) or (Length(gCorpses
) = 0) then
5055 for i
:= 0 to High(gCorpses
) do
5056 if gCorpses
[i
] <> nil then
5057 if gCorpses
[i
].FPlayerUID
= FUID
then
5065 function TPlayer
.getCameraObj(): TObj
;
5067 if (not FAlive
) and (not FSpectator
) and
5068 (FCorpse
>= 0) and (FCorpse
< Length(gCorpses
)) and
5069 (gCorpses
[FCorpse
] <> nil) and (gCorpses
[FCorpse
].FPlayerUID
= FUID
) then
5071 gCorpses
[FCorpse
].FObj
.slopeUpLeft
:= FObj
.slopeUpLeft
;
5072 Result
:= gCorpses
[FCorpse
].FObj
;
5080 procedure TPlayer
.PreUpdate();
5082 FSlopeOld
:= FObj
.slopeUpLeft
;
5083 FIncCamOld
:= FIncCam
;
5084 FObj
.oldX
:= FObj
.X
;
5085 FObj
.oldY
:= FObj
.Y
;
5088 procedure TPlayer
.Update();
5091 i
, ii
, wx
, wy
, xd
, yd
, k
: Integer;
5092 blockmon
, headwater
, dospawn
: Boolean;
5097 NetServer
:= g_Game_IsNet
and g_Game_IsServer
;
5098 AnyServer
:= g_Game_IsServer
;
5100 if g_Game_IsClient
and (NetInterpLevel
> 0) then
5101 DoLerp(NetInterpLevel
+ 1)
5107 if FClientID
>= 0 then
5109 FPing
:= NetClients
[FClientID
].Peer
^.lastRoundTripTime
;
5110 if NetClients
[FClientID
].Peer
^.packetsSent
> 0 then
5111 FLoss
:= Round(100*NetClients
[FClientID
].Peer
^.packetsLost
/NetClients
[FClientID
].Peer
^.packetsSent
)
5120 if FAlive
and (FPunchAnim
<> nil) then
5121 FPunchAnim
.Update();
5123 if FAlive
and (gFly
or FJetpack
) then
5126 if FDirection
= TDirection
.D_LEFT
then
5131 if FAlive
and (not FGhost
) then
5133 if FKeys
[KEY_UP
].Pressed
then
5135 if FKeys
[KEY_DOWN
].Pressed
then
5139 if (not (FKeys
[KEY_UP
].Pressed
or FKeys
[KEY_DOWN
].Pressed
)) and
5142 i
:= g_basic
.Sign(FIncCam
);
5143 FIncCam
:= Abs(FIncCam
);
5144 DecMin(FIncCam
, 5, 0);
5145 FIncCam
:= FIncCam
*i
;
5148 // no need to do that each second frame, weapon queue will take care of it
5149 if FAlive
and FKeys
[KEY_NEXTWEAPON
].Pressed
and AnyServer
then NextWeapon();
5150 if FAlive
and FKeys
[KEY_PREVWEAPON
].Pressed
and AnyServer
then PrevWeapon();
5152 if gTime
mod (GAME_TICK
*2) <> 0 then
5154 if (FObj
.Vel
.X
= 0) and FAlive
then
5156 if FKeys
[KEY_LEFT
].Pressed
then
5157 Run(TDirection
.D_LEFT
);
5158 if FKeys
[KEY_RIGHT
].Pressed
then
5159 Run(TDirection
.D_RIGHT
);
5164 g_Obj_Move(@FObj
, True, True, True);
5165 positionChanged(); // this updates spatial accelerators
5171 FActionChanged
:= False;
5175 // Let alive player do some actions
5176 if FKeys
[KEY_LEFT
].Pressed
then Run(TDirection
.D_LEFT
);
5177 if FKeys
[KEY_RIGHT
].Pressed
then Run(TDirection
.D_RIGHT
);
5178 //if FKeys[KEY_NEXTWEAPON].Pressed and AnyServer then NextWeapon();
5179 //if FKeys[KEY_PREVWEAPON].Pressed and AnyServer then PrevWeapon();
5180 if FKeys
[KEY_FIRE
].Pressed
and AnyServer
then Fire()
5186 if NetServer
then MH_SEND_PlayerStats(FUID
);
5189 if FKeys
[KEY_OPEN
].Pressed
and AnyServer
then Use();
5190 if FKeys
[KEY_JUMP
].Pressed
then Jump()
5193 if AnyServer
and FJetpack
then
5197 if NetServer
then MH_SEND_PlayerStats(FUID
);
5199 FCanJetpack
:= True;
5206 for k
:= Low(FKeys
) to KEY_CHAT
-1 do
5208 if FKeys
[k
].Pressed
then
5216 if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
5219 if (FTime
[T_RESPAWN
] <= gTime
) and
5220 gGameOn
and (not FAlive
) then
5222 if (g_Player_GetCount() > 1) then
5226 gExit
:= EXIT_RESTART
;
5231 // Dead spectator actions
5234 if FKeys
[KEY_OPEN
].Pressed
and AnyServer
then Fire();
5235 if FKeys
[KEY_FIRE
].Pressed
and AnyServer
then
5239 if (FSpectatePlayer
>= High(gPlayers
)) then
5240 FSpectatePlayer
:= -1
5244 for I
:= FSpectatePlayer
+ 1 to High(gPlayers
) do
5245 if gPlayers
[I
] <> nil then
5246 if gPlayers
[I
].alive
then
5247 if gPlayers
[I
].UID
<> FUID
then
5249 FSpectatePlayer
:= I
;
5254 if not SetSpect
then FSpectatePlayer
:= -1;
5265 if FKeys
[KEY_UP
].Pressed
or FKeys
[KEY_JUMP
].Pressed
then
5267 FYTo
:= FObj
.Y
- 32;
5268 FSpectatePlayer
:= -1;
5270 if FKeys
[KEY_DOWN
].Pressed
then
5272 FYTo
:= FObj
.Y
+ 32;
5273 FSpectatePlayer
:= -1;
5275 if FKeys
[KEY_LEFT
].Pressed
then
5277 FXTo
:= FObj
.X
- 32;
5278 FSpectatePlayer
:= -1;
5280 if FKeys
[KEY_RIGHT
].Pressed
then
5282 FXTo
:= FObj
.X
+ 32;
5283 FSpectatePlayer
:= -1;
5286 if (FXTo
< -64) then
5288 else if (FXTo
> gMapInfo
.Width
+ 32) then
5289 FXTo
:= gMapInfo
.Width
+ 32;
5290 if (FYTo
< -72) then
5292 else if (FYTo
> gMapInfo
.Height
+ 32) then
5293 FYTo
:= gMapInfo
.Height
+ 32;
5298 g_Obj_Move(@FObj
, True, True, True);
5299 positionChanged(); // this updates spatial accelerators
5306 if (FSpectatePlayer
<= High(gPlayers
)) and (FSpectatePlayer
>= 0) then
5307 if gPlayers
[FSpectatePlayer
] <> nil then
5308 if gPlayers
[FSpectatePlayer
].alive
then
5310 FXTo
:= gPlayers
[FSpectatePlayer
].GameX
;
5311 FYTo
:= gPlayers
[FSpectatePlayer
].GameY
;
5315 blockmon
:= g_Map_CollidePanel(FObj
.X
+PLAYER_HEADRECT
.X
, FObj
.Y
+PLAYER_HEADRECT
.Y
,
5316 PLAYER_HEADRECT
.Width
, PLAYER_HEADRECT
.Height
,
5317 PANEL_BLOCKMON
, True);
5318 headwater
:= HeadInLiquid(0, 0);
5320 // Ñîïðîòèâëåíèå âîçäóõà:
5321 if (not FAlive
) or not (FKeys
[KEY_LEFT
].Pressed
or FKeys
[KEY_RIGHT
].Pressed
) then
5322 if FObj
.Vel
.X
<> 0 then
5323 FObj
.Vel
.X
:= z_dec(FObj
.Vel
.X
, 1);
5325 if (FLastHit
= HIT_TRAP
) and (FPain
> 90) then FPain
:= 90;
5326 DecMin(FPain
, 5, 0);
5327 DecMin(FPickup
, 1, 0);
5329 if FAlive
and (FObj
.Y
> Integer(gMapInfo
.Height
)+128) and AnyServer
then
5331 // Îáíóëèòü äåéñòâèÿ ïðèìî÷åê, ÷òîáû ôîí ïðîïàë
5332 FMegaRulez
[MR_SUIT
] := 0;
5333 FMegaRulez
[MR_INVUL
] := 0;
5334 FMegaRulez
[MR_INVIS
] := 0;
5335 Kill(K_FALLKILL
, 0, HIT_FALL
);
5342 if FCurrWeap
= WEAPON_SAW
then
5343 if not (FSawSound
.IsPlaying() or FSawSoundHit
.IsPlaying() or
5344 FSawSoundSelect
.IsPlaying()) then
5345 FSawSoundIdle
.PlayAt(FObj
.X
, FObj
.Y
);
5348 if (not FJetSoundFly
.IsPlaying()) and (not FJetSoundOn
.IsPlaying()) and
5349 (not FJetSoundOff
.IsPlaying()) then
5351 FJetSoundFly
.SetPosition(0);
5352 FJetSoundFly
.PlayAt(FObj
.X
, FObj
.Y
);
5355 for b
:= WP_FIRST
to WP_LAST
do
5356 if FReloading
[b
] > 0 then
5362 if FShellTimer
> -1 then
5363 if FShellTimer
= 0 then
5365 if FShellType
= SHELL_SHELL
then
5366 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
5367 GameVelX
, GameVelY
-2, SHELL_SHELL
)
5368 else if FShellType
= SHELL_DBLSHELL
then
5370 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
5371 GameVelX
+1, GameVelY
-2, SHELL_SHELL
);
5372 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
5373 GameVelX
-1, GameVelY
-2, SHELL_SHELL
);
5376 end else Dec(FShellTimer
);
5378 if (FBFGFireCounter
> -1) then
5379 if FBFGFireCounter
= 0 then
5383 wx
:= FObj
.X
+WEAPONPOINT
[FDirection
].X
;
5384 wy
:= FObj
.Y
+WEAPONPOINT
[FDirection
].Y
;
5385 xd
:= wx
+IfThen(FDirection
= TDirection
.D_LEFT
, -30, 30);
5386 yd
:= wy
+firediry();
5387 g_Weapon_bfgshot(wx
, wy
, xd
, yd
, FUID
);
5388 if NetServer
then MH_SEND_PlayerFire(FUID
, WEAPON_BFG
, wx
, wy
, xd
, yd
);
5389 if (FAngle
= 0) or (FAngle
= 180) then SetAction(A_ATTACK
)
5390 else if (FAngle
= ANGLE_LEFTDOWN
) or (FAngle
= ANGLE_RIGHTDOWN
) then SetAction(A_ATTACKDOWN
)
5391 else if (FAngle
= ANGLE_LEFTUP
) or (FAngle
= ANGLE_RIGHTUP
) then SetAction(A_ATTACKUP
);
5394 FReloading
[WEAPON_BFG
] := WEAPON_RELOAD
[WEAPON_BFG
];
5395 FBFGFireCounter
:= -1;
5398 FBFGFireCounter
:= 0
5400 Dec(FBFGFireCounter
);
5402 if (FMegaRulez
[MR_SUIT
] < gTime
) and AnyServer
then
5404 b
:= g_GetAcidHit(FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+PLAYER_RECT
.Y
, PLAYER_RECT
.Width
, PLAYER_RECT
.Height
);
5406 if (b
> 0) and (gTime
mod (15*GAME_TICK
) = 0) then Damage(b
, 0, 0, 0, HIT_ACID
);
5409 if (headwater
or blockmon
) then
5415 if AnyServer
then Damage(10, 0, 0, 0, HIT_WATER
);
5418 else if (FAir
mod 31 = 0) and not blockmon
then
5420 g_GFX_Bubbles(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2), FObj
.Y
+PLAYER_RECT
.Y
-4, 5+Random(6), 8, 4);
5421 if Random(2) = 0 then
5422 g_Sound_PlayExAt('SOUND_GAME_BUBBLE1', FObj
.X
, FObj
.Y
)
5424 g_Sound_PlayExAt('SOUND_GAME_BUBBLE2', FObj
.X
, FObj
.Y
);
5426 end else if FAir
< AIR_DEF
then
5429 if FFireTime
> 0 then
5431 if BodyInLiquid(0, 0) then
5436 else if FMegaRulez
[MR_SUIT
] >= gTime
then
5438 if FMegaRulez
[MR_SUIT
] = gTime
then
5445 if FFirePainTime
<= 0 then
5447 if g_Game_IsServer
then
5448 Damage(2, FFireAttacker
, 0, 0, HIT_FLAME
);
5449 FFirePainTime
:= 12 - FFireTime
div 12;
5451 FFirePainTime
:= FFirePainTime
- 1;
5452 FFireTime
:= FFireTime
- 1;
5453 if ((FFireTime
mod 33) = 0) and (FMegaRulez
[MR_INVUL
] < gTime
) then
5454 FModel
.PlaySound(MODELSOUND_PAIN
, 1, FObj
.X
, FObj
.Y
);
5455 if (FFireTime
= 0) and g_Game_IsNet
and g_Game_IsServer
then
5456 MH_SEND_PlayerStats(FUID
);
5460 if FDamageBuffer
> 0 then
5462 if FDamageBuffer
>= 9 then
5466 if FDamageBuffer
< 30 then i
:= 9
5467 else if FDamageBuffer
< 100 then i
:= 18
5471 ii
:= Round(FDamageBuffer
*FHealth
/ nonz(FArmor
*(3/4)+FHealth
));
5472 FArmor
:= FArmor
-(FDamageBuffer
-ii
);
5473 FHealth
:= FHealth
-ii
;
5476 FHealth
:= FHealth
+FArmor
;
5481 if FHealth
<= 0 then
5482 if FHealth
> -30 then Kill(K_SIMPLEKILL
, FLastSpawnerUID
, FLastHit
)
5483 else if FHealth
> -50 then Kill(K_HARDKILL
, FLastSpawnerUID
, FLastHit
)
5484 else Kill(K_EXTRAHARDKILL
, FLastSpawnerUID
, FLastHit
);
5486 if FAlive
and ((FLastHit
<> HIT_FLAME
) or (FFireTime
<= 0)) then
5488 if FDamageBuffer
<= 20 then FModel
.PlaySound(MODELSOUND_PAIN
, 1, FObj
.X
, FObj
.Y
)
5489 else if FDamageBuffer
<= 55 then FModel
.PlaySound(MODELSOUND_PAIN
, 2, FObj
.X
, FObj
.Y
)
5490 else if FDamageBuffer
<= 120 then FModel
.PlaySound(MODELSOUND_PAIN
, 3, FObj
.X
, FObj
.Y
)
5491 else FModel
.PlaySound(MODELSOUND_PAIN
, 4, FObj
.X
, FObj
.Y
);
5498 end; // if FAlive then ...
5500 if (FActionAnim
= A_PAIN
) and (FModel
.Animation
<> A_PAIN
) then
5502 FModel
.ChangeAnimation(FActionAnim
, FActionForce
);
5503 FModel
.GetCurrentAnimation
.MinLength
:= i
;
5504 FModel
.GetCurrentAnimationMask
.MinLength
:= i
;
5505 end else FModel
.ChangeAnimation(FActionAnim
, FActionForce
and (FModel
.Animation
<> A_STAND
));
5507 if (FModel
.GetCurrentAnimation
.Played
or ((not FActionChanged
) and (FModel
.Animation
= A_WALK
)))
5508 then SetAction(A_STAND
, True);
5510 if not ((FModel
.Animation
= A_WALK
) and (Abs(FObj
.Vel
.X
) < 4) and not FModel
.Fire
) then FModel
.Update
;
5512 for b
:= Low(FKeys
) to High(FKeys
) do
5513 if FKeys
[b
].Time
= 0 then FKeys
[b
].Pressed
:= False else Dec(FKeys
[b
].Time
);
5517 procedure TPlayer
.getMapBox (out x
, y
, w
, h
: Integer); inline;
5519 x
:= FObj
.X
+PLAYER_RECT
.X
;
5520 y
:= FObj
.Y
+PLAYER_RECT
.Y
;
5521 w
:= PLAYER_RECT
.Width
;
5522 h
:= PLAYER_RECT
.Height
;
5526 procedure TPlayer
.moveBy (dx
, dy
: Integer); inline;
5528 if (dx
<> 0) or (dy
<> 0) then
5537 function TPlayer
.Collide(X
, Y
: Integer; Width
, Height
: Word): Boolean;
5539 Result
:= g_Collide(FObj
.X
+PLAYER_RECT
.X
,
5540 FObj
.Y
+PLAYER_RECT
.Y
,
5547 function TPlayer
.Collide(Panel
: TPanel
): Boolean;
5549 Result
:= g_Collide(FObj
.X
+PLAYER_RECT
.X
,
5550 FObj
.Y
+PLAYER_RECT
.Y
,
5554 Panel
.Width
, Panel
.Height
);
5557 function TPlayer
.Collide(X
, Y
: Integer): Boolean;
5559 X
:= X
-FObj
.X
-PLAYER_RECT
.X
;
5560 Y
:= Y
-FObj
.Y
-PLAYER_RECT
.Y
;
5561 Result
:= (x
>= 0) and (x
<= PLAYER_RECT
.Width
) and
5562 (y
>= 0) and (y
<= PLAYER_RECT
.Height
);
5565 function g_Player_ValidName(Name
: string): Boolean;
5571 if gPlayers
= nil then Exit
;
5573 for a
:= 0 to High(gPlayers
) do
5574 if gPlayers
[a
] <> nil then
5575 if LowerCase(Name
) = LowerCase(gPlayers
[a
].FName
) then
5582 procedure TPlayer
.SetDirection(Direction
: TDirection
);
5586 d
:= FModel
.Direction
;
5588 FModel
.Direction
:= Direction
;
5589 if d
<> Direction
then FModel
.ChangeAnimation(FModel
.Animation
, True);
5591 FDirection
:= Direction
;
5594 function TPlayer
.GetKeys(): Byte;
5598 if R_KEY_RED
in FRulez
then Result
:= KEY_RED
;
5599 if R_KEY_GREEN
in FRulez
then Result
:= Result
or KEY_GREEN
;
5600 if R_KEY_BLUE
in FRulez
then Result
:= Result
or KEY_BLUE
;
5602 if FTeam
= TEAM_RED
then Result
:= Result
or KEY_REDTEAM
;
5603 if FTeam
= TEAM_BLUE
then Result
:= Result
or KEY_BLUETEAM
;
5606 procedure TPlayer
.Use();
5610 if FTime
[T_USE
] > gTime
then Exit
;
5612 g_Triggers_PressR(FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+PLAYER_RECT
.Y
, PLAYER_RECT
.Width
,
5613 PLAYER_RECT
.Height
, FUID
, ACTIVATE_PLAYERPRESS
);
5615 for a
:= 0 to High(gPlayers
) do
5616 if (gPlayers
[a
] <> nil) and (gPlayers
[a
] <> Self
) and
5617 gPlayers
[a
].alive
and SameTeam(FUID
, gPlayers
[a
].FUID
) and
5618 g_Obj_Collide(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
,
5619 FObj
.Rect
.Width
, FObj
.Rect
.Height
, @gPlayers
[a
].FObj
) then
5621 gPlayers
[a
].Touch();
5622 if g_Game_IsNet
and g_Game_IsServer
then
5623 MH_SEND_GameEvent(NET_EV_PLAYER_TOUCH
, gPlayers
[a
].FUID
);
5626 FTime
[T_USE
] := gTime
+120;
5629 procedure TPlayer
.NetFire(Wpn
: Byte; X
, Y
, AX
, AY
: Integer; WID
: Integer = -1);
5633 WX
, WY
, XD
, YD
: Integer;
5645 if R_BERSERK
in FRulez
then
5647 //g_Weapon_punch(FObj.X+FObj.Rect.X, FObj.Y+FObj.Rect.Y, 75, FUID);
5648 locobj
.X
:= FObj
.X
+FObj
.Rect
.X
;
5649 locobj
.Y
:= FObj
.Y
+FObj
.Rect
.Y
;
5652 locobj
.rect
.Width
:= 39;
5653 locobj
.rect
.Height
:= 52;
5654 locobj
.Vel
.X
:= (xd
-wx
) div 2;
5655 locobj
.Vel
.Y
:= (yd
-wy
) div 2;
5656 locobj
.Accel
.X
:= xd
-wx
;
5657 locobj
.Accel
.y
:= yd
-wy
;
5659 if g_Weapon_Hit(@locobj
, 50, FUID
, HIT_SOME
) <> 0 then
5660 g_Sound_PlayExAt('SOUND_WEAPON_HITBERSERK', FObj
.X
, FObj
.Y
)
5662 g_Sound_PlayExAt('SOUND_WEAPON_MISSBERSERK', FObj
.X
, FObj
.Y
);
5666 FPain
:= min(FPain
+ 25, 50);
5668 g_Weapon_punch(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
, 3, FUID
);
5673 if g_Weapon_chainsaw(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
,
5674 IfThen(gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
], 9, 3), FUID
) <> 0 then
5676 FSawSoundSelect
.Stop();
5678 FSawSoundHit
.PlayAt(FObj
.X
, FObj
.Y
);
5680 else if not FSawSoundHit
.IsPlaying() then
5682 FSawSoundSelect
.Stop();
5683 FSawSound
.PlayAt(FObj
.X
, FObj
.Y
);
5690 g_Sound_PlayExAt('SOUND_WEAPON_FIREPISTOL', GameX
, Gamey
);
5691 FFireAngle
:= FAngle
;
5693 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
5694 GameVelX
, GameVelY
-2, SHELL_BULLET
);
5699 g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN', Gamex
, Gamey
);
5700 FFireAngle
:= FAngle
;
5703 FShellType
:= SHELL_SHELL
;
5708 g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN2', Gamex
, Gamey
);
5709 FFireAngle
:= FAngle
;
5712 FShellType
:= SHELL_DBLSHELL
;
5717 g_Sound_PlayExAt('SOUND_WEAPON_FIRECGUN', Gamex
, Gamey
);
5718 FFireAngle
:= FAngle
;
5720 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
5721 GameVelX
, GameVelY
-2, SHELL_BULLET
);
5724 WEAPON_ROCKETLAUNCHER
:
5726 g_Weapon_Rocket(wx
, wy
, xd
, yd
, FUID
, WID
);
5727 FFireAngle
:= FAngle
;
5733 g_Weapon_Plasma(wx
, wy
, xd
, yd
, FUID
, WID
);
5734 FFireAngle
:= FAngle
;
5740 g_Weapon_BFGShot(wx
, wy
, xd
, yd
, FUID
, WID
);
5741 FFireAngle
:= FAngle
;
5745 WEAPON_SUPERPULEMET
:
5747 g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN', Gamex
, Gamey
);
5748 FFireAngle
:= FAngle
;
5750 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
5751 GameVelX
, GameVelY
-2, SHELL_SHELL
);
5754 WEAPON_FLAMETHROWER
:
5756 g_Weapon_flame(wx
, wy
, xd
, yd
, FUID
, WID
);
5758 FFireAngle
:= FAngle
;
5765 if (FAngle
= 0) or (FAngle
= 180) then SetAction(A_ATTACK
)
5766 else if (FAngle
= ANGLE_LEFTDOWN
) or (FAngle
= ANGLE_RIGHTDOWN
) then SetAction(A_ATTACKDOWN
)
5767 else if (FAngle
= ANGLE_LEFTUP
) or (FAngle
= ANGLE_RIGHTUP
) then SetAction(A_ATTACKUP
);
5770 procedure TPlayer
.DoLerp(Level
: Integer = 2);
5772 if FObj
.X
<> FXTo
then FObj
.X
:= Lerp(FObj
.X
, FXTo
, Level
);
5773 if FObj
.Y
<> FYTo
then FObj
.Y
:= Lerp(FObj
.Y
, FYTo
, Level
);
5776 procedure TPlayer
.SetLerp(XTo
, YTo
: Integer);
5782 if NetInterpLevel
< 1 then
5789 AX
:= Abs(FXTo
- FObj
.X
);
5790 AY
:= Abs(FYTo
- FObj
.Y
);
5791 if (AX
> 32) or (AX
<= NetInterpLevel
) then
5793 if (AY
> 32) or (AY
<= NetInterpLevel
) then
5798 function TPlayer
.FullInLift(XInc
, YInc
: Integer): Integer;
5800 if g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
,
5801 PLAYER_RECT
.Width
, PLAYER_RECT
.Height
-8,
5802 PANEL_LIFTUP
, False) then Result
:= -1
5804 if g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
,
5805 PLAYER_RECT
.Width
, PLAYER_RECT
.Height
-8,
5806 PANEL_LIFTDOWN
, False) then Result
:= 1
5810 function TPlayer
.GetFlag(Flag
: Byte): Boolean;
5817 if Flag
= FLAG_NONE
then
5820 if not g_Game_IsServer
then Exit
;
5822 // Ïðèíåñ ÷óæîé ôëàã íà ñâîþ áàçó:
5823 if (Flag
= FTeam
) and
5824 (gFlags
[Flag
].State
= FLAG_STATE_NORMAL
) and
5825 (FFlag
<> FLAG_NONE
) then
5827 if FFlag
= FLAG_RED
then
5828 s
:= _lc
[I_PLAYER_FLAG_RED
]
5830 s
:= _lc
[I_PLAYER_FLAG_BLUE
];
5832 evtype
:= FLAG_STATE_SCORED
;
5834 ts
:= Format('%.4d', [gFlags
[FFlag
].CaptureTime
]);
5835 Insert('.', ts
, Length(ts
) + 1 - 3);
5836 g_Console_Add(Format(_lc
[I_PLAYER_FLAG_CAPTURE
], [FName
, s
, ts
]), True);
5838 g_Map_ResetFlag(FFlag
);
5839 g_Game_Message(Format(_lc
[I_MESSAGE_FLAG_CAPTURE
], [AnsiUpperCase(s
)]), 144);
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_cap_flag
[a
].IsPlaying() then
5849 sound_cap_flag
[a
].Play();
5851 gTeamStat
[FTeam
].Goals
:= gTeamStat
[FTeam
].Goals
+ 1;
5854 if g_Game_IsNet
then
5856 MH_SEND_FlagEvent(evtype
, FFlag
, FUID
, False);
5860 gFlags
[FFlag
].CaptureTime
:= 0;
5865 // Ïîäîáðàë ñâîé ôëàã - âåðíóë åãî íà áàçó:
5866 if (Flag
= FTeam
) and
5867 (gFlags
[Flag
].State
= FLAG_STATE_DROPPED
) then
5869 if Flag
= FLAG_RED
then
5870 s
:= _lc
[I_PLAYER_FLAG_RED
]
5872 s
:= _lc
[I_PLAYER_FLAG_BLUE
];
5874 evtype
:= FLAG_STATE_RETURNED
;
5875 gFlags
[Flag
].CaptureTime
:= 0;
5877 g_Console_Add(Format(_lc
[I_PLAYER_FLAG_RETURN
], [FName
, s
]), True);
5879 g_Map_ResetFlag(Flag
);
5880 g_Game_Message(Format(_lc
[I_MESSAGE_FLAG_RETURN
], [AnsiUpperCase(s
)]), 144);
5882 if ((Self
= gPlayer1
) or (Self
= gPlayer2
)
5883 or ((gPlayer1
<> nil) and (gPlayer1
.Team
= FTeam
))
5884 or ((gPlayer2
<> nil) and (gPlayer2
.Team
= FTeam
))) then
5889 if not sound_ret_flag
[a
].IsPlaying() then
5890 sound_ret_flag
[a
].Play();
5893 if g_Game_IsNet
then
5895 MH_SEND_FlagEvent(evtype
, Flag
, FUID
, False);
5901 // Ïîäîáðàë ÷óæîé ôëàã:
5902 if (Flag
<> FTeam
) and (FTime
[T_FLAGCAP
] <= gTime
) then
5906 if Flag
= FLAG_RED
then
5907 s
:= _lc
[I_PLAYER_FLAG_RED
]
5909 s
:= _lc
[I_PLAYER_FLAG_BLUE
];
5911 evtype
:= FLAG_STATE_CAPTURED
;
5913 g_Console_Add(Format(_lc
[I_PLAYER_FLAG_GET
], [FName
, s
]), True);
5915 g_Game_Message(Format(_lc
[I_MESSAGE_FLAG_GET
], [AnsiUpperCase(s
)]), 144);
5917 gFlags
[Flag
].State
:= FLAG_STATE_CAPTURED
;
5919 if ((Self
= gPlayer1
) or (Self
= gPlayer2
)
5920 or ((gPlayer1
<> nil) and (gPlayer1
.Team
= FTeam
))
5921 or ((gPlayer2
<> nil) and (gPlayer2
.Team
= FTeam
))) then
5926 if not sound_get_flag
[a
].IsPlaying() then
5927 sound_get_flag
[a
].Play();
5930 if g_Game_IsNet
then
5932 MH_SEND_FlagEvent(evtype
, Flag
, FUID
, False);
5938 procedure TPlayer
.SetFlag(Flag
: Byte);
5941 if FModel
<> nil then
5942 FModel
.SetFlag(FFlag
);
5945 function TPlayer
.DropFlag(Silent
: Boolean = True): Boolean;
5951 if (not g_Game_IsServer
) or (FFlag
= FLAG_NONE
) then
5953 FTime
[T_FLAGCAP
] := gTime
+ 2000;
5954 with gFlags
[FFlag
] do
5958 Direction
:= FDirection
;
5959 State
:= FLAG_STATE_DROPPED
;
5961 g_Obj_Push(@Obj
, (FObj
.Vel
.X
div 2)-2+Random(5),
5962 (FObj
.Vel
.Y
div 2)-2+Random(5));
5963 positionChanged(); // this updates spatial accelerators
5965 if FFlag
= FLAG_RED
then
5966 s
:= _lc
[I_PLAYER_FLAG_RED
]
5968 s
:= _lc
[I_PLAYER_FLAG_BLUE
];
5970 g_Console_Add(Format(_lc
[I_PLAYER_FLAG_DROP
], [FName
, s
]), True);
5971 g_Game_Message(Format(_lc
[I_MESSAGE_FLAG_DROP
], [AnsiUpperCase(s
)]), 144);
5973 if ((Self
= gPlayer1
) or (Self
= gPlayer2
)
5974 or ((gPlayer1
<> nil) and (gPlayer1
.Team
= FTeam
))
5975 or ((gPlayer2
<> nil) and (gPlayer2
.Team
= FTeam
))) then
5980 if (not Silent
) and (not sound_lost_flag
[a
].IsPlaying()) then
5981 sound_lost_flag
[a
].Play();
5983 if g_Game_IsNet
then
5984 MH_SEND_FlagEvent(FLAG_STATE_DROPPED
, Flag
, FUID
, False);
5990 procedure TPlayer
.GetSecret();
5992 if (self
= gPlayer1
) or (self
= gPlayer2
) then
5994 g_Console_Add(Format(_lc
[I_PLAYER_SECRET
], [FName
]), True);
5995 g_Sound_PlayEx('SOUND_GAME_SECRET');
6000 procedure TPlayer
.PressKey(Key
: Byte; Time
: Word = 1);
6002 Assert(Key
<= High(FKeys
));
6004 FKeys
[Key
].Pressed
:= True;
6005 FKeys
[Key
].Time
:= Time
;
6008 function TPlayer
.IsKeyPressed(K
: Byte): Boolean;
6010 Result
:= FKeys
[K
].Pressed
;
6013 procedure TPlayer
.ReleaseKeys();
6017 for a
:= Low(FKeys
) to High(FKeys
) do
6019 FKeys
[a
].Pressed
:= False;
6024 procedure TPlayer
.OnDamage(Angle
: SmallInt);
6028 function TPlayer
.firediry(): Integer;
6030 if FKeys
[KEY_UP
].Pressed
then Result
:= -42
6031 else if FKeys
[KEY_DOWN
].Pressed
then Result
:= 19
6035 procedure TPlayer
.RememberState();
6038 SavedState
: TPlayerSavedState
;
6040 SavedState
.Health
:= FHealth
;
6041 SavedState
.Armor
:= FArmor
;
6042 SavedState
.Air
:= FAir
;
6043 SavedState
.JetFuel
:= FJetFuel
;
6044 SavedState
.CurrWeap
:= FCurrWeap
;
6045 SavedState
.NextWeap
:= FNextWeap
;
6046 SavedState
.NextWeapDelay
:= FNextWeapDelay
;
6047 for i
:= Low(FWeapon
) to High(FWeapon
) do
6048 SavedState
.Weapon
[i
] := FWeapon
[i
];
6049 for i
:= Low(FAmmo
) to High(FAmmo
) do
6050 SavedState
.Ammo
[i
] := FAmmo
[i
];
6051 for i
:= Low(FMaxAmmo
) to High(FMaxAmmo
) do
6052 SavedState
.MaxAmmo
[i
] := FMaxAmmo
[i
];
6053 SavedState
.Rulez
:= FRulez
- [R_KEY_RED
, R_KEY_GREEN
, R_KEY_BLUE
];
6055 FSavedStateNum
:= -1;
6056 for i
:= Low(SavedStates
) to High(SavedStates
) do
6057 if not SavedStates
[i
].Used
then
6059 FSavedStateNum
:= i
;
6062 if FSavedStateNum
< 0 then
6064 SetLength(SavedStates
, Length(SavedStates
) + 1);
6065 FSavedStateNum
:= High(SavedStates
);
6068 SavedState
.Used
:= True;
6069 SavedStates
[FSavedStateNum
] := SavedState
;
6072 procedure TPlayer
.RecallState();
6075 SavedState
: TPlayerSavedState
;
6077 if(FSavedStateNum
< 0) or (FSavedStateNum
> High(SavedStates
)) then
6080 SavedState
:= SavedStates
[FSavedStateNum
];
6081 SavedStates
[FSavedStateNum
].Used
:= False;
6082 FSavedStateNum
:= -1;
6084 FHealth
:= SavedState
.Health
;
6085 FArmor
:= SavedState
.Armor
;
6086 FAir
:= SavedState
.Air
;
6087 FJetFuel
:= SavedState
.JetFuel
;
6088 FCurrWeap
:= SavedState
.CurrWeap
;
6089 FNextWeap
:= SavedState
.NextWeap
;
6090 FNextWeapDelay
:= SavedState
.NextWeapDelay
;
6091 for i
:= Low(FWeapon
) to High(FWeapon
) do
6092 FWeapon
[i
] := SavedState
.Weapon
[i
];
6093 for i
:= Low(FAmmo
) to High(FAmmo
) do
6094 FAmmo
[i
] := SavedState
.Ammo
[i
];
6095 for i
:= Low(FMaxAmmo
) to High(FMaxAmmo
) do
6096 FMaxAmmo
[i
] := SavedState
.MaxAmmo
[i
];
6097 FRulez
:= SavedState
.Rulez
;
6099 if gGameSettings
.GameType
= GT_SERVER
then
6100 MH_SEND_PlayerStats(FUID
);
6103 procedure TPlayer
.SaveState (st
: TStream
);
6109 utils
.writeSign(st
, 'PLYR');
6110 utils
.writeInt(st
, Byte(PLR_SAVE_VERSION
)); // version
6112 utils
.writeBool(st
, FIamBot
);
6114 utils
.writeInt(st
, Word(FUID
));
6116 utils
.writeStr(st
, FName
);
6118 utils
.writeInt(st
, Byte(FTeam
));
6120 utils
.writeBool(st
, FAlive
);
6121 // Èçðàñõîäîâàë ëè âñå æèçíè
6122 utils
.writeBool(st
, FNoRespawn
);
6124 if FDirection
= TDirection
.D_LEFT
then b
:= 1 else b
:= 2; // D_RIGHT
6125 utils
.writeInt(st
, Byte(b
));
6127 utils
.writeInt(st
, LongInt(FHealth
));
6128 // Êîýôôèöèåíò èíâàëèäíîñòè
6129 utils
.writeInt(st
, LongInt(FHandicap
));
6131 utils
.writeInt(st
, Byte(FLives
));
6133 utils
.writeInt(st
, LongInt(FArmor
));
6135 utils
.writeInt(st
, LongInt(FAir
));
6137 utils
.writeInt(st
, LongInt(FJetFuel
));
6139 utils
.writeInt(st
, LongInt(FPain
));
6141 utils
.writeInt(st
, LongInt(FKills
));
6143 utils
.writeInt(st
, LongInt(FMonsterKills
));
6145 utils
.writeInt(st
, LongInt(FFrags
));
6147 utils
.writeInt(st
, Byte(FFragCombo
));
6148 // Âðåìÿ ïîñëåäíåãî ôðàãà
6149 utils
.writeInt(st
, LongWord(FLastFrag
));
6151 utils
.writeInt(st
, LongInt(FDeath
));
6153 utils
.writeInt(st
, Byte(FFlag
));
6155 utils
.writeInt(st
, LongInt(FSecrets
));
6157 utils
.writeInt(st
, Byte(FCurrWeap
));
6159 utils
.writeInt(st
, Word(FNextWeap
));
6161 utils
.writeInt(st
, Byte(FNextWeapDelay
));
6162 // Âðåìÿ çàðÿäêè BFG
6163 utils
.writeInt(st
, SmallInt(FBFGFireCounter
));
6165 utils
.writeInt(st
, LongInt(FDamageBuffer
));
6166 // Ïîñëåäíèé óäàðèâøèé
6167 utils
.writeInt(st
, Word(FLastSpawnerUID
));
6168 // Òèï ïîñëåäíåãî ïîëó÷åííîãî óðîíà
6169 utils
.writeInt(st
, Byte(FLastHit
));
6171 Obj_SaveState(st
, @FObj
);
6172 // Òåêóùåå êîëè÷åñòâî ïàòðîíîâ
6173 for i
:= A_BULLETS
to A_HIGH
do utils
.writeInt(st
, Word(FAmmo
[i
]));
6174 // Ìàêñèìàëüíîå êîëè÷åñòâî ïàòðîíîâ
6175 for i
:= A_BULLETS
to A_HIGH
do utils
.writeInt(st
, Word(FMaxAmmo
[i
]));
6177 for i
:= WP_FIRST
to WP_LAST
do utils
.writeBool(st
, FWeapon
[i
]);
6178 // Âðåìÿ ïåðåçàðÿäêè îðóæèÿ
6179 for i
:= WP_FIRST
to WP_LAST
do utils
.writeInt(st
, Word(FReloading
[i
]));
6181 utils
.writeBool(st
, (R_ITEM_BACKPACK
in FRulez
));
6182 // Íàëè÷èå êðàñíîãî êëþ÷à
6183 utils
.writeBool(st
, (R_KEY_RED
in FRulez
));
6184 // Íàëè÷èå çåëåíîãî êëþ÷à
6185 utils
.writeBool(st
, (R_KEY_GREEN
in FRulez
));
6186 // Íàëè÷èå ñèíåãî êëþ÷à
6187 utils
.writeBool(st
, (R_KEY_BLUE
in FRulez
));
6189 utils
.writeBool(st
, (R_BERSERK
in FRulez
));
6190 // Âðåìÿ äåéñòâèÿ ñïåöèàëüíûõ ïðåäìåòîâ
6191 for i
:= MR_SUIT
to MR_MAX
do utils
.writeInt(st
, LongWord(FMegaRulez
[i
]));
6192 // Âðåìÿ äî ïîâòîðíîãî ðåñïàóíà, ñìåíû îðóæèÿ, èñîëüçîâàíèÿ, çàõâàòà ôëàãà
6193 for i
:= T_RESPAWN
to T_FLAGCAP
do utils
.writeInt(st
, LongWord(FTime
[i
]));
6195 utils
.writeStr(st
, FModel
.Name
);
6197 utils
.writeInt(st
, Byte(FColor
.R
));
6198 utils
.writeInt(st
, Byte(FColor
.G
));
6199 utils
.writeInt(st
, Byte(FColor
.B
));
6203 procedure TPlayer
.LoadState (st
: TStream
);
6212 if not utils
.checkSign(st
, 'PLYR') then raise XStreamError
.Create('invalid player signature');
6213 if (utils
.readByte(st
) <> PLR_SAVE_VERSION
) then raise XStreamError
.Create('invalid player version');
6215 FIamBot
:= utils
.readBool(st
);
6217 FUID
:= utils
.readWord(st
);
6219 str
:= utils
.readStr(st
);
6220 if (self
<> gPlayer1
) and (self
<> gPlayer2
) then FName
:= str
;
6222 FTeam
:= utils
.readByte(st
);
6224 FAlive
:= utils
.readBool(st
);
6225 // Èçðàñõîäîâàë ëè âñå æèçíè
6226 FNoRespawn
:= utils
.readBool(st
);
6228 b
:= utils
.readByte(st
);
6229 if b
= 1 then FDirection
:= TDirection
.D_LEFT
else FDirection
:= TDirection
.D_RIGHT
; // b = 2
6231 FHealth
:= utils
.readLongInt(st
);
6232 // Êîýôôèöèåíò èíâàëèäíîñòè
6233 FHandicap
:= utils
.readLongInt(st
);
6235 FLives
:= utils
.readByte(st
);
6237 FArmor
:= utils
.readLongInt(st
);
6239 FAir
:= utils
.readLongInt(st
);
6241 FJetFuel
:= utils
.readLongInt(st
);
6243 FPain
:= utils
.readLongInt(st
);
6245 FKills
:= utils
.readLongInt(st
);
6247 FMonsterKills
:= utils
.readLongInt(st
);
6249 FFrags
:= utils
.readLongInt(st
);
6251 FFragCombo
:= utils
.readByte(st
);
6252 // Âðåìÿ ïîñëåäíåãî ôðàãà
6253 FLastFrag
:= utils
.readLongWord(st
);
6255 FDeath
:= utils
.readLongInt(st
);
6257 FFlag
:= utils
.readByte(st
);
6259 FSecrets
:= utils
.readLongInt(st
);
6261 FCurrWeap
:= utils
.readByte(st
);
6263 FNextWeap
:= utils
.readWord(st
);
6265 FNextWeapDelay
:= utils
.readByte(st
);
6266 // Âðåìÿ çàðÿäêè BFG
6267 FBFGFireCounter
:= utils
.readSmallInt(st
);
6269 FDamageBuffer
:= utils
.readLongInt(st
);
6270 // Ïîñëåäíèé óäàðèâøèé
6271 FLastSpawnerUID
:= utils
.readWord(st
);
6272 // Òèï ïîñëåäíåãî ïîëó÷åííîãî óðîíà
6273 FLastHit
:= utils
.readByte(st
);
6275 Obj_LoadState(@FObj
, st
);
6276 // Òåêóùåå êîëè÷åñòâî ïàòðîíîâ
6277 for i
:= A_BULLETS
to A_HIGH
do FAmmo
[i
] := utils
.readWord(st
);
6278 // Ìàêñèìàëüíîå êîëè÷åñòâî ïàòðîíîâ
6279 for i
:= A_BULLETS
to A_HIGH
do FMaxAmmo
[i
] := utils
.readWord(st
);
6281 for i
:= WP_FIRST
to WP_LAST
do FWeapon
[i
] := utils
.readBool(st
);
6282 // Âðåìÿ ïåðåçàðÿäêè îðóæèÿ
6283 for i
:= WP_FIRST
to WP_LAST
do FReloading
[i
] := utils
.readWord(st
);
6285 if utils
.readBool(st
) then Include(FRulez
, R_ITEM_BACKPACK
);
6286 // Íàëè÷èå êðàñíîãî êëþ÷à
6287 if utils
.readBool(st
) then Include(FRulez
, R_KEY_RED
);
6288 // Íàëè÷èå çåëåíîãî êëþ÷à
6289 if utils
.readBool(st
) then Include(FRulez
, R_KEY_GREEN
);
6290 // Íàëè÷èå ñèíåãî êëþ÷à
6291 if utils
.readBool(st
) then Include(FRulez
, R_KEY_BLUE
);
6293 if utils
.readBool(st
) then Include(FRulez
, R_BERSERK
);
6294 // Âðåìÿ äåéñòâèÿ ñïåöèàëüíûõ ïðåäìåòîâ
6295 for i
:= MR_SUIT
to MR_MAX
do FMegaRulez
[i
] := utils
.readLongWord(st
);
6296 // Âðåìÿ äî ïîâòîðíîãî ðåñïàóíà, ñìåíû îðóæèÿ, èñîëüçîâàíèÿ, çàõâàòà ôëàãà
6297 for i
:= T_RESPAWN
to T_FLAGCAP
do FTime
[i
] := utils
.readLongWord(st
);
6299 str
:= utils
.readStr(st
);
6301 FColor
.R
:= utils
.readByte(st
);
6302 FColor
.G
:= utils
.readByte(st
);
6303 FColor
.B
:= utils
.readByte(st
);
6304 if (self
= gPlayer1
) then
6306 str
:= gPlayer1Settings
.Model
;
6307 FColor
:= gPlayer1Settings
.Color
;
6309 else if (self
= gPlayer2
) then
6311 str
:= gPlayer2Settings
.Model
;
6312 FColor
:= gPlayer2Settings
.Color
;
6314 // Îáíîâëÿåì ìîäåëü èãðîêà
6316 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
6317 FModel
.Color
:= TEAMCOLOR
[FTeam
]
6319 FModel
.Color
:= FColor
;
6323 procedure TPlayer
.AllRulez(Health
: Boolean);
6329 FHealth
:= PLAYER_HP_LIMIT
;
6330 FArmor
:= PLAYER_AP_LIMIT
;
6334 for a
:= WP_FIRST
to WP_LAST
do FWeapon
[a
] := True;
6335 for a
:= A_BULLETS
to A_HIGH
do FAmmo
[a
] := 30000;
6336 FRulez
:= FRulez
+[R_KEY_RED
, R_KEY_GREEN
, R_KEY_BLUE
];
6339 procedure TPlayer
.RestoreHealthArmor();
6341 FHealth
:= PLAYER_HP_LIMIT
;
6342 FArmor
:= PLAYER_AP_LIMIT
;
6345 procedure TPlayer
.FragCombo();
6349 if (gGameSettings
.GameMode
in [GM_COOP
, GM_SINGLE
]) or g_Game_IsClient
then
6351 if gTime
- FLastFrag
< FRAG_COMBO_TIME
then
6353 if FFragCombo
< 5 then
6355 Param
:= FUID
or (FFragCombo
shl 16);
6356 if (FComboEvnt
>= Low(gDelayedEvents
)) and
6357 (FComboEvnt
<= High(gDelayedEvents
)) and
6358 gDelayedEvents
[FComboEvnt
].Pending
and
6359 (gDelayedEvents
[FComboEvnt
].DEType
= DE_KILLCOMBO
) and
6360 (gDelayedEvents
[FComboEvnt
].DENum
and $FFFF = FUID
) then
6362 gDelayedEvents
[FComboEvnt
].Time
:= gTime
+ 500;
6363 gDelayedEvents
[FComboEvnt
].DENum
:= Param
;
6366 FComboEvnt
:= g_Game_DelayEvent(DE_KILLCOMBO
, 500, Param
);
6374 procedure TPlayer
.GiveItem(ItemType
: Byte);
6378 if FMegaRulez
[MR_SUIT
] < gTime
+PLAYER_SUIT_TIME
then
6380 FMegaRulez
[MR_SUIT
] := gTime
+PLAYER_SUIT_TIME
;
6384 if FAir
< AIR_MAX
then
6391 if not (R_BERSERK
in FRulez
) then
6393 Include(FRulez
, R_BERSERK
);
6394 if FBFGFireCounter
< 1 then
6396 FCurrWeap
:= WEAPON_KASTET
;
6398 FModel
.SetWeapon(WEAPON_KASTET
);
6402 FBerserk
:= gTime
+30000;
6404 if FHealth
< PLAYER_HP_SOFT
then
6406 FHealth
:= PLAYER_HP_SOFT
;
6407 FBerserk
:= gTime
+30000;
6412 if FMegaRulez
[MR_INVUL
] < gTime
+PLAYER_INVUL_TIME
then
6414 FMegaRulez
[MR_INVUL
] := gTime
+PLAYER_INVUL_TIME
;
6419 if FMegaRulez
[MR_INVIS
] < gTime
+PLAYER_INVIS_TIME
then
6421 FMegaRulez
[MR_INVIS
] := gTime
+PLAYER_INVIS_TIME
;
6425 if FJetFuel
< JET_MAX
then
6427 FJetFuel
:= JET_MAX
;
6430 ITEM_MEDKIT_SMALL
: if FHealth
< PLAYER_HP_SOFT
then IncMax(FHealth
, 10, PLAYER_HP_SOFT
);
6431 ITEM_MEDKIT_LARGE
: if FHealth
< PLAYER_HP_SOFT
then IncMax(FHealth
, 25, PLAYER_HP_SOFT
);
6433 ITEM_ARMOR_GREEN
: if FArmor
< PLAYER_AP_SOFT
then FArmor
:= PLAYER_AP_SOFT
;
6434 ITEM_ARMOR_BLUE
: if FArmor
< PLAYER_AP_LIMIT
then FArmor
:= PLAYER_AP_LIMIT
;
6436 ITEM_SPHERE_BLUE
: if FHealth
< PLAYER_HP_LIMIT
then IncMax(FHealth
, 100, PLAYER_HP_LIMIT
);
6438 if (FHealth
< PLAYER_HP_LIMIT
) or (FArmor
< PLAYER_AP_LIMIT
) then
6440 if FHealth
< PLAYER_HP_LIMIT
then FHealth
:= PLAYER_HP_LIMIT
;
6441 if FArmor
< PLAYER_AP_LIMIT
then FArmor
:= PLAYER_AP_LIMIT
;
6444 ITEM_WEAPON_SAW
: FWeapon
[WEAPON_SAW
] := True;
6445 ITEM_WEAPON_SHOTGUN1
: FWeapon
[WEAPON_SHOTGUN1
] := True;
6446 ITEM_WEAPON_SHOTGUN2
: FWeapon
[WEAPON_SHOTGUN2
] := True;
6447 ITEM_WEAPON_CHAINGUN
: FWeapon
[WEAPON_CHAINGUN
] := True;
6448 ITEM_WEAPON_ROCKETLAUNCHER
: FWeapon
[WEAPON_ROCKETLAUNCHER
] := True;
6449 ITEM_WEAPON_PLASMA
: FWeapon
[WEAPON_PLASMA
] := True;
6450 ITEM_WEAPON_BFG
: FWeapon
[WEAPON_BFG
] := True;
6451 ITEM_WEAPON_SUPERPULEMET
: FWeapon
[WEAPON_SUPERPULEMET
] := True;
6452 ITEM_WEAPON_FLAMETHROWER
: FWeapon
[WEAPON_FLAMETHROWER
] := True;
6454 ITEM_AMMO_BULLETS
: if FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
] then IncMax(FAmmo
[A_BULLETS
], 10, FMaxAmmo
[A_BULLETS
]);
6455 ITEM_AMMO_BULLETS_BOX
: if FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
] then IncMax(FAmmo
[A_BULLETS
], 50, FMaxAmmo
[A_BULLETS
]);
6456 ITEM_AMMO_SHELLS
: if FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
] then IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
6457 ITEM_AMMO_SHELLS_BOX
: if FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
] then IncMax(FAmmo
[A_SHELLS
], 25, FMaxAmmo
[A_SHELLS
]);
6458 ITEM_AMMO_ROCKET
: if FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
] then IncMax(FAmmo
[A_ROCKETS
], 1, FMaxAmmo
[A_ROCKETS
]);
6459 ITEM_AMMO_ROCKET_BOX
: if FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
] then IncMax(FAmmo
[A_ROCKETS
], 5, FMaxAmmo
[A_ROCKETS
]);
6460 ITEM_AMMO_CELL
: if FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
] then IncMax(FAmmo
[A_CELLS
], 40, FMaxAmmo
[A_CELLS
]);
6461 ITEM_AMMO_CELL_BIG
: if FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
] then IncMax(FAmmo
[A_CELLS
], 100, FMaxAmmo
[A_CELLS
]);
6462 ITEM_AMMO_FUELCAN
: if FAmmo
[A_FUEL
] < FMaxAmmo
[A_FUEL
] then IncMax(FAmmo
[A_FUEL
], 100, FMaxAmmo
[A_FUEL
]);
6465 if (FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
]) or
6466 (FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
]) or
6467 (FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
]) or
6468 (FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
]) or
6469 (FMaxAmmo
[A_FUEL
] < AmmoLimits
[1, A_FUEL
]) then
6471 FMaxAmmo
[A_BULLETS
] := AmmoLimits
[1, A_BULLETS
];
6472 FMaxAmmo
[A_SHELLS
] := AmmoLimits
[1, A_SHELLS
];
6473 FMaxAmmo
[A_ROCKETS
] := AmmoLimits
[1, A_ROCKETS
];
6474 FMaxAmmo
[A_CELLS
] := AmmoLimits
[1, A_CELLS
];
6475 FMaxAmmo
[A_FUEL
] := AmmoLimits
[1, A_FUEL
];
6477 if FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
] then IncMax(FAmmo
[A_BULLETS
], 10, FMaxAmmo
[A_BULLETS
]);
6478 if FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
] then IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
6479 if FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
] then IncMax(FAmmo
[A_ROCKETS
], 1, FMaxAmmo
[A_ROCKETS
]);
6480 if FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
] then IncMax(FAmmo
[A_CELLS
], 40, FMaxAmmo
[A_CELLS
]);
6482 FRulez
:= FRulez
+ [R_ITEM_BACKPACK
];
6485 ITEM_KEY_RED
: if not (R_KEY_RED
in FRulez
) then Include(FRulez
, R_KEY_RED
);
6486 ITEM_KEY_GREEN
: if not (R_KEY_GREEN
in FRulez
) then Include(FRulez
, R_KEY_GREEN
);
6487 ITEM_KEY_BLUE
: if not (R_KEY_BLUE
in FRulez
) then Include(FRulez
, R_KEY_BLUE
);
6489 ITEM_BOTTLE
: if FHealth
< PLAYER_HP_LIMIT
then IncMax(FHealth
, 4, PLAYER_HP_LIMIT
);
6490 ITEM_HELMET
: if FArmor
< PLAYER_AP_LIMIT
then IncMax(FArmor
, 5, PLAYER_AP_LIMIT
);
6495 if g_Game_IsNet
and g_Game_IsServer
then
6496 MH_SEND_PlayerStats(FUID
);
6499 procedure TPlayer
.FlySmoke(Times
: DWORD
= 1);
6504 if (Random(5) = 1) and (Times
= 1) then
6507 if BodyInLiquid(0, 0) then
6509 g_GFX_Bubbles(Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2)+Random(3)-1,
6510 Obj
.Y
+Obj
.Rect
.Height
+8, 1, 8, 4);
6511 if Random(2) = 0 then
6512 g_Sound_PlayExAt('SOUND_GAME_BUBBLE1', FObj
.X
, FObj
.Y
)
6514 g_Sound_PlayExAt('SOUND_GAME_BUBBLE2', FObj
.X
, FObj
.Y
);
6518 if g_Frames_Get(id
, 'FRAMES_SMOKE') then
6520 for i
:= 1 to Times
do
6522 Anim
:= TAnimation
.Create(id
, False, 3);
6524 g_GFX_OnceAnim(Obj
.X
+Obj
.Rect
.X
+Random(Obj
.Rect
.Width
+Times
*2)-(Anim
.Width
div 2),
6525 Obj
.Y
+Obj
.Rect
.Height
-4+Random(8+Times
*2), Anim
, ONCEANIM_SMOKE
);
6531 procedure TPlayer
.OnFireFlame(Times
: DWORD
= 1);
6536 if (Random(10) = 1) and (Times
= 1) then
6539 if g_Frames_Get(id
, 'FRAMES_FLAME') then
6541 for i
:= 1 to Times
do
6543 Anim
:= TAnimation
.Create(id
, False, 3);
6545 g_GFX_OnceAnim(Obj
.X
+Obj
.Rect
.X
+Random(Obj
.Rect
.Width
+Times
*2)-(Anim
.Width
div 2),
6546 Obj
.Y
+8+Random(8+Times
*2), Anim
, ONCEANIM_SMOKE
);
6552 procedure TPlayer
.PauseSounds(Enable
: Boolean);
6554 FSawSound
.Pause(Enable
);
6555 FSawSoundIdle
.Pause(Enable
);
6556 FSawSoundHit
.Pause(Enable
);
6557 FSawSoundSelect
.Pause(Enable
);
6558 FFlameSoundOn
.Pause(Enable
);
6559 FFlameSoundOff
.Pause(Enable
);
6560 FFlameSoundWork
.Pause(Enable
);
6561 FJetSoundFly
.Pause(Enable
);
6562 FJetSoundOn
.Pause(Enable
);
6563 FJetSoundOff
.Pause(Enable
);
6568 constructor TCorpse
.Create(X
, Y
: Integer; ModelName
: String; aMess
: Boolean);
6573 FObj
.Rect
:= PLAYER_CORPSERECT
;
6574 FModelName
:= ModelName
;
6579 FState
:= CORPSE_STATE_MESS
;
6580 g_PlayerModel_GetAnim(ModelName
, A_DIE2
, FAnimation
, FAnimationMask
);
6584 FState
:= CORPSE_STATE_NORMAL
;
6585 g_PlayerModel_GetAnim(ModelName
, A_DIE1
, FAnimation
, FAnimationMask
);
6589 destructor TCorpse
.Destroy();
6596 function TCorpse
.ObjPtr (): PObj
; inline; begin result
:= @FObj
; end;
6598 procedure TCorpse
.positionChanged (); inline; begin end;
6600 procedure TCorpse
.moveBy (dx
, dy
: Integer); inline;
6602 if (dx
<> 0) or (dy
<> 0) then
6611 procedure TCorpse
.getMapBox (out x
, y
, w
, h
: Integer); inline;
6613 x
:= FObj
.X
+PLAYER_CORPSERECT
.X
;
6614 y
:= FObj
.Y
+PLAYER_CORPSERECT
.Y
;
6615 w
:= PLAYER_CORPSERECT
.Width
;
6616 h
:= PLAYER_CORPSERECT
.Height
;
6620 procedure TCorpse
.Damage(Value
: Word; SpawnerUID
: Word; vx
, vy
: Integer);
6625 if FState
= CORPSE_STATE_REMOVEME
then
6628 FDamage
:= FDamage
+ Value
;
6630 if FDamage
> 150 then
6632 if FAnimation
<> nil then
6637 FState
:= CORPSE_STATE_REMOVEME
;
6639 g_Player_CreateGibs(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
6640 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2),
6641 FModelName
, FColor
);
6642 // Çâóê ìÿñà îò òðóïà:
6643 pm
:= g_PlayerModel_Get(FModelName
);
6644 pm
.PlaySound(MODELSOUND_DIE
, 5, FObj
.X
, FObj
.Y
);
6648 if (gBodyKillEvent
<> -1)
6649 and gDelayedEvents
[gBodyKillEvent
].Pending
then
6650 gDelayedEvents
[gBodyKillEvent
].Pending
:= False;
6651 gBodyKillEvent
:= g_Game_DelayEvent(DE_BODYKILL
, 1050, SpawnerUID
);
6656 Blood
:= g_PlayerModel_GetBlood(FModelName
);
6657 FObj
.Vel
.X
:= FObj
.Vel
.X
+ vx
;
6658 FObj
.Vel
.Y
:= FObj
.Vel
.Y
+ vy
;
6659 g_GFX_Blood(FObj
.X
+PLAYER_CORPSERECT
.X
+(PLAYER_CORPSERECT
.Width
div 2),
6660 FObj
.Y
+PLAYER_CORPSERECT
.Y
+(PLAYER_CORPSERECT
.Height
div 2),
6661 Value
, vx
, vy
, 16, (PLAYER_CORPSERECT
.Height
*2) div 3,
6662 Blood
.R
, Blood
.G
, Blood
.B
, Blood
.Kind
);
6666 procedure TCorpse
.Draw();
6670 if FState
= CORPSE_STATE_REMOVEME
then
6673 FObj
.lerp(gLerpFactor
, fX
, fY
);
6675 if FAnimation
<> nil then
6676 FAnimation
.Draw(fX
, fY
, TMirrorType
.None
);
6678 if FAnimationMask
<> nil then
6681 FAnimationMask
.Draw(fX
, fY
, TMirrorType
.None
);
6688 procedure TCorpse
.Update();
6692 if FState
= CORPSE_STATE_REMOVEME
then
6695 FObj
.oldX
:= FObj
.X
;
6696 FObj
.oldY
:= FObj
.Y
;
6698 if gTime
mod (GAME_TICK
*2) <> 0 then
6700 g_Obj_Move(@FObj
, True, True, True);
6701 positionChanged(); // this updates spatial accelerators
6705 // Ñîïðîòèâëåíèå âîçäóõà äëÿ òðóïà:
6706 FObj
.Vel
.X
:= z_dec(FObj
.Vel
.X
, 1);
6708 st
:= g_Obj_Move(@FObj
, True, True, True);
6709 positionChanged(); // this updates spatial accelerators
6711 if WordBool(st
and MOVE_FALLOUT
) then
6713 FState
:= CORPSE_STATE_REMOVEME
;
6717 if FAnimation
<> nil then
6718 FAnimation
.Update();
6719 if FAnimationMask
<> nil then
6720 FAnimationMask
.Update();
6724 procedure TCorpse
.SaveState (st
: TStream
);
6731 utils
.writeSign(st
, 'CORP');
6732 utils
.writeInt(st
, Byte(0));
6734 utils
.writeInt(st
, Byte(FState
));
6736 utils
.writeInt(st
, Byte(FDamage
));
6738 utils
.writeInt(st
, Byte(FColor
.R
));
6739 utils
.writeInt(st
, Byte(FColor
.G
));
6740 utils
.writeInt(st
, Byte(FColor
.B
));
6742 Obj_SaveState(st
, @FObj
);
6743 utils
.writeInt(st
, Word(FPlayerUID
));
6745 anim
:= (FAnimation
<> nil);
6746 utils
.writeBool(st
, anim
);
6747 // Åñëè åñòü - ñîõðàíÿåì
6748 if anim
then FAnimation
.SaveState(st
);
6749 // Åñòü ëè ìàñêà àíèìàöèè
6750 anim
:= (FAnimationMask
<> nil);
6751 utils
.writeBool(st
, anim
);
6752 // Åñëè åñòü - ñîõðàíÿåì
6753 if anim
then FAnimationMask
.SaveState(st
);
6757 procedure TCorpse
.LoadState (st
: TStream
);
6764 if not utils
.checkSign(st
, 'CORP') then raise XStreamError
.Create('invalid corpse signature');
6765 if (utils
.readByte(st
) <> 0) then raise XStreamError
.Create('invalid corpse version');
6767 FState
:= utils
.readByte(st
);
6769 FDamage
:= utils
.readByte(st
);
6771 FColor
.R
:= utils
.readByte(st
);
6772 FColor
.G
:= utils
.readByte(st
);
6773 FColor
.B
:= utils
.readByte(st
);
6775 Obj_LoadState(@FObj
, st
);
6776 FPlayerUID
:= utils
.readWord(st
);
6778 anim
:= utils
.readBool(st
);
6779 // Åñëè åñòü - çàãðóæàåì
6782 Assert(FAnimation
<> nil, 'TCorpse.LoadState: no FAnimation');
6783 FAnimation
.LoadState(st
);
6785 // Åñòü ëè ìàñêà àíèìàöèè
6786 anim
:= utils
.readBool(st
);
6787 // Åñëè åñòü - çàãðóæàåì
6790 Assert(FAnimationMask
<> nil, 'TCorpse.LoadState: no FAnimationMask');
6791 FAnimationMask
.LoadState(st
);
6797 constructor TBot
.Create();
6804 FSpectator
:= False;
6811 for a
:= WP_FIRST
to WP_LAST
do
6813 FDifficult
.WeaponPrior
[a
] := WEAPON_PRIOR1
[a
];
6814 FDifficult
.CloseWeaponPrior
[a
] := WEAPON_PRIOR2
[a
];
6815 //FDifficult.SafeWeaponPrior[a] := WEAPON_PRIOR3[a];
6819 destructor TBot
.Destroy();
6822 inherited Destroy();
6825 procedure TBot
.Draw();
6829 //if FTargetUID <> 0 then e_DrawLine(1, FObj.X, FObj.Y, g_Player_Get(FTargetUID).FObj.X,
6830 // g_Player_Get(FTargetUID).FObj.Y, 255, 0, 0);
6833 procedure TBot
.Respawn(Silent
: Boolean; Force
: Boolean = False);
6835 inherited Respawn(Silent
, Force
);
6838 FSelectedWeapon
:= FCurrWeap
;
6843 procedure TBot
.UpdateCombat();
6856 TTargetRecord
= array of TTarget
;
6858 function Compare(a
, b
: TTarget
): Integer;
6860 if a
.Line
and not b
.Line
then // A íà ëèíèè îãíÿ
6863 if not a
.Line
and b
.Line
then // B íà ëèíèè îãíÿ
6865 else // È A, è B íà ëèíèè èëè íå íà ëèíèè îãíÿ
6866 if (a
.Line
and b
.Line
) or ((not a
.Line
) and (not b
.Line
)) then
6868 if a
.Dist
> b
.Dist
then // B áëèæå
6870 else // A áëèæå èëè ðàâíîóäàëåííî ñ B
6873 else // Ñòðàííî -> A
6878 a
, x1
, y1
, x2
, y2
: Integer;
6879 targets
: TTargetRecord
;
6881 Target
, BestTarget
: TTarget
;
6882 firew
, fireh
: Integer;
6886 vsPlayer
, vsMonster
, ok
: Boolean;
6889 function monsUpdate (mon
: TMonster
): Boolean;
6891 result
:= false; // don't stop
6892 if mon
.alive
and (mon
.MonsterType
<> MONSTER_BARREL
) then
6894 if not TargetOnScreen(mon
.Obj
.X
+mon
.Obj
.Rect
.X
, mon
.Obj
.Y
+mon
.Obj
.Rect
.Y
) then exit
;
6896 x2
:= mon
.Obj
.X
+mon
.Obj
.Rect
.X
+(mon
.Obj
.Rect
.Width
div 2);
6897 y2
:= mon
.Obj
.Y
+mon
.Obj
.Rect
.Y
+(mon
.Obj
.Rect
.Height
div 2);
6899 // Åñëè ìîíñòð íà ýêðàíå è íå ïðèêðûò ñòåíîé
6900 if g_TraceVector(x1
, y1
, x2
, y2
) then
6902 // Äîáàâëÿåì ê ñïèñêó âîçìîæíûõ öåëåé
6903 SetLength(targets
, Length(targets
)+1);
6904 with targets
[High(targets
)] do
6911 Rect
:= mon
.Obj
.Rect
;
6912 Dist
:= g_PatchLength(x1
, y1
, x2
, y2
);
6913 Line
:= (y1
+4 < Target
.Y
+ mon
.Obj
.Rect
.Y
+ mon
.Obj
.Rect
.Height
) and
6914 (y1
-4 > Target
.Y
+ mon
.Obj
.Rect
.Y
);
6923 vsPlayer
:= LongBool(gGameSettings
.Options
and GAME_OPTION_BOTVSPLAYER
);
6924 vsMonster
:= LongBool(gGameSettings
.Options
and GAME_OPTION_BOTVSMONSTER
);
6926 // Åñëè òåêóùåå îðóæèå íå òî, ÷òî íóæíî, òî ìåíÿåì:
6927 if FCurrWeap
<> FSelectedWeapon
then
6930 // Åñëè íóæíî ñòðåëÿòü è íóæíîå îðóæèå, òî íàæàòü "Ñòðåëÿòü":
6931 if (GetAIFlag('NEEDFIRE') <> '') and (FCurrWeap
= FSelectedWeapon
) then
6933 RemoveAIFlag('NEEDFIRE');
6936 WEAPON_PLASMA
, WEAPON_SUPERPULEMET
, WEAPON_CHAINGUN
: PressKey(KEY_FIRE
, 20);
6937 WEAPON_SAW
, WEAPON_KASTET
, WEAPON_FLAMETHROWER
: PressKey(KEY_FIRE
, 40);
6938 else PressKey(KEY_FIRE
);
6942 // Êîîðäèíàòû ñòâîëà:
6943 x1
:= FObj
.X
+ WEAPONPOINT
[FDirection
].X
;
6944 y1
:= FObj
.Y
+ WEAPONPOINT
[FDirection
].Y
;
6946 Target
.UID
:= FTargetUID
;
6949 if Target
.UID
<> 0 then
6950 begin // Öåëü åñòü - íàñòðàèâàåì
6951 if (g_GetUIDType(Target
.UID
) = UID_PLAYER
) and
6954 tpla
:= g_Player_Get(Target
.UID
);
6958 if (@FObj
) <> nil then
6965 Target
.cX
:= Target
.X
+ PLAYER_RECT_CX
;
6966 Target
.cY
:= Target
.Y
+ PLAYER_RECT_CY
;
6967 Target
.Rect
:= PLAYER_RECT
;
6968 Target
.Visible
:= g_TraceVector(x1
, y1
, Target
.cX
, Target
.cY
);
6969 Target
.Line
:= (y1
+4 < Target
.Y
+PLAYER_RECT
.Y
+PLAYER_RECT
.Height
) and
6970 (y1
-4 > Target
.Y
+PLAYER_RECT
.Y
);
6971 Target
.IsPlayer
:= True;
6975 if (g_GetUIDType(Target
.UID
) = UID_MONSTER
) and
6978 mon
:= g_Monsters_ByUID(Target
.UID
);
6981 Target
.X
:= mon
.Obj
.X
;
6982 Target
.Y
:= mon
.Obj
.Y
;
6984 Target
.cX
:= Target
.X
+ mon
.Obj
.Rect
.X
+ (mon
.Obj
.Rect
.Width
div 2);
6985 Target
.cY
:= Target
.Y
+ mon
.Obj
.Rect
.Y
+ (mon
.Obj
.Rect
.Height
div 2);
6986 Target
.Rect
:= mon
.Obj
.Rect
;
6987 Target
.Visible
:= g_TraceVector(x1
, y1
, Target
.cX
, Target
.cY
);
6988 Target
.Line
:= (y1
+4 < Target
.Y
+ mon
.Obj
.Rect
.Y
+ mon
.Obj
.Rect
.Height
) and
6989 (y1
-4 > Target
.Y
+ mon
.Obj
.Rect
.Y
);
6990 Target
.IsPlayer
:= False;
6997 begin // Öåëè íåò - îáíóëÿåì
7002 Target
.Visible
:= False;
7003 Target
.Line
:= False;
7004 Target
.IsPlayer
:= False;
7009 // Åñëè öåëü íå âèäèìà èëè íå íà ëèíèè îãíÿ, òî èùåì âñå âîçìîæíûå öåëè:
7010 if (not Target
.Line
) or (not Target
.Visible
) then
7014 for a
:= 0 to High(gPlayers
) do
7015 if (gPlayers
[a
] <> nil) and (gPlayers
[a
].alive
) and
7016 (gPlayers
[a
].FUID
<> FUID
) and
7017 (not SameTeam(FUID
, gPlayers
[a
].FUID
)) and
7018 (not gPlayers
[a
].NoTarget
) and
7019 (gPlayers
[a
].FMegaRulez
[MR_INVIS
] < gTime
) then
7021 if not TargetOnScreen(gPlayers
[a
].FObj
.X
+ PLAYER_RECT
.X
,
7022 gPlayers
[a
].FObj
.Y
+ PLAYER_RECT
.Y
) then
7025 x2
:= gPlayers
[a
].FObj
.X
+ PLAYER_RECT_CX
;
7026 y2
:= gPlayers
[a
].FObj
.Y
+ PLAYER_RECT_CY
;
7028 // Åñëè èãðîê íà ýêðàíå è íå ïðèêðûò ñòåíîé:
7029 if g_TraceVector(x1
, y1
, x2
, y2
) then
7031 // Äîáàâëÿåì ê ñïèñêó âîçìîæíûõ öåëåé:
7032 SetLength(targets
, Length(targets
)+1);
7033 with targets
[High(targets
)] do
7035 UID
:= gPlayers
[a
].FUID
;
7036 X
:= gPlayers
[a
].FObj
.X
;
7037 Y
:= gPlayers
[a
].FObj
.Y
;
7040 Rect
:= PLAYER_RECT
;
7041 Dist
:= g_PatchLength(x1
, y1
, x2
, y2
);
7042 Line
:= (y1
+4 < Target
.Y
+PLAYER_RECT
.Y
+PLAYER_RECT
.Height
) and
7043 (y1
-4 > Target
.Y
+PLAYER_RECT
.Y
);
7051 if vsMonster
then g_Mons_ForEach(monsUpdate
);
7054 // Åñëè åñòü âîçìîæíûå öåëè:
7055 // (Âûáèðàåì ëó÷øóþ, ìåíÿåì îðóæèå è áåæèì ê íåé/îò íåå)
7056 if targets
<> nil then
7058 // Âûáèðàåì íàèëó÷øóþ öåëü:
7059 BestTarget
:= targets
[0];
7060 if Length(targets
) > 1 then
7061 for a
:= 1 to High(targets
) do
7062 if Compare(BestTarget
, targets
[a
]) = 1 then
7063 BestTarget
:= targets
[a
];
7065 // Åñëè ëó÷øàÿ öåëü "âèäíåå" òåêóùåé, òî òåêóùàÿ := ëó÷øàÿ:
7066 if ((not Target
.Visible
) and BestTarget
.Visible
and (Target
.UID
<> BestTarget
.UID
)) or
7067 ((not Target
.Line
) and BestTarget
.Line
and BestTarget
.Visible
) then
7069 Target
:= BestTarget
;
7071 if (Healthy() = 3) or ((Healthy() = 2)) then
7072 begin // Åñëè çäîðîâû - äîãîíÿåì
7073 if ((RunDirection() = TDirection
.D_LEFT
) and (Target
.X
> FObj
.X
)) then
7074 SetAIFlag('GORIGHT', '1');
7075 if ((RunDirection() = TDirection
.D_RIGHT
) and (Target
.X
< FObj
.X
)) then
7076 SetAIFlag('GOLEFT', '1');
7079 begin // Åñëè ïîáèòû - óáåãàåì
7080 if ((RunDirection() = TDirection
.D_LEFT
) and (Target
.X
< FObj
.X
)) then
7081 SetAIFlag('GORIGHT', '1');
7082 if ((RunDirection() = TDirection
.D_RIGHT
) and (Target
.X
> FObj
.X
)) then
7083 SetAIFlag('GOLEFT', '1');
7086 // Âûáèðàåì îðóæèå íà îñíîâå ðàññòîÿíèÿ è ïðèîðèòåòîâ:
7087 SelectWeapon(Abs(x1
-Target
.cX
));
7092 // (Äîãîíÿåì/óáåãàåì, ñòðåëÿåì ïî íàïðàâëåíèþ ê öåëè)
7093 // (Åñëè öåëü äàëåêî, òî õâàòèò ñëåäèòü çà íåé)
7094 if Target
.UID
<> 0 then
7096 if not TargetOnScreen(Target
.X
+ Target
.Rect
.X
,
7097 Target
.Y
+ Target
.Rect
.Y
) then
7098 begin // Öåëü ñáåæàëà ñ "ýêðàíà"
7099 if (Healthy() = 3) or ((Healthy() = 2)) then
7100 begin // Åñëè çäîðîâû - äîãîíÿåì
7101 if ((RunDirection() = TDirection
.D_LEFT
) and (Target
.X
> FObj
.X
)) then
7102 SetAIFlag('GORIGHT', '1');
7103 if ((RunDirection() = TDirection
.D_RIGHT
) and (Target
.X
< FObj
.X
)) then
7104 SetAIFlag('GOLEFT', '1');
7107 begin // Åñëè ïîáèòû - çàáûâàåì î öåëè è óáåãàåì
7109 if ((RunDirection() = TDirection
.D_LEFT
) and (Target
.X
< FObj
.X
)) then
7110 SetAIFlag('GORIGHT', '1');
7111 if ((RunDirection() = TDirection
.D_RIGHT
) and (Target
.X
> FObj
.X
)) then
7112 SetAIFlag('GOLEFT', '1');
7116 begin // Öåëü ïîêà íà "ýêðàíå"
7117 // Åñëè öåëü íå çàãîðîæåíà ñòåíîé, òî îòìå÷àåì, êîãäà åå âèäåëè:
7118 if g_TraceVector(x1
, y1
, Target
.cX
, Target
.cY
) then
7119 FLastVisible
:= gTime
;
7120 // Åñëè ðàçíèöà âûñîò íå âåëèêà, òî äîãîíÿåì:
7121 if (Abs(FObj
.Y
-Target
.Y
) <= 128) then
7123 if ((RunDirection() = TDirection
.D_LEFT
) and (Target
.X
> FObj
.X
)) then
7124 SetAIFlag('GORIGHT', '1');
7125 if ((RunDirection() = TDirection
.D_RIGHT
) and (Target
.X
< FObj
.X
)) then
7126 SetAIFlag('GOLEFT', '1');
7130 // Âûáèðàåì óãîë ââåðõ:
7131 if FDirection
= TDirection
.D_LEFT
then
7132 angle
:= ANGLE_LEFTUP
7134 angle
:= ANGLE_RIGHTUP
;
7136 firew
:= Trunc(Cos(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
7137 fireh
:= Trunc(Sin(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
7139 // Åñëè ïðè óãëå ââåðõ ìîæíî ïîïàñòü â ïðèáëèçèòåëüíîå ïîëîæåíèå öåëè:
7140 if g_CollideLine(x1
, y1
, x1
+firew
, y1
+fireh
,
7141 Target
.X
+Target
.Rect
.X
+GetInterval(FDifficult
.DiagPrecision
, 128), //96
7142 Target
.Y
+Target
.Rect
.Y
+GetInterval(FDifficult
.DiagPrecision
, 128),
7143 Target
.Rect
.Width
, Target
.Rect
.Height
) and
7144 g_TraceVector(x1
, y1
, Target
.cX
, Target
.cY
) then
7145 begin // òî íóæíî ñòðåëÿòü ââåðõ
7146 SetAIFlag('NEEDFIRE', '1');
7147 SetAIFlag('NEEDSEEUP', '1');
7150 // Âûáèðàåì óãîë âíèç:
7151 if FDirection
= TDirection
.D_LEFT
then
7152 angle
:= ANGLE_LEFTDOWN
7154 angle
:= ANGLE_RIGHTDOWN
;
7156 firew
:= Trunc(Cos(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
7157 fireh
:= Trunc(Sin(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
7159 // Åñëè ïðè óãëå âíèç ìîæíî ïîïàñòü â ïðèáëèçèòåëüíîå ïîëîæåíèå öåëè:
7160 if g_CollideLine(x1
, y1
, x1
+firew
, y1
+fireh
,
7161 Target
.X
+Target
.Rect
.X
+GetInterval(FDifficult
.DiagPrecision
, 128),
7162 Target
.Y
+Target
.Rect
.Y
+GetInterval(FDifficult
.DiagPrecision
, 128),
7163 Target
.Rect
.Width
, Target
.Rect
.Height
) and
7164 g_TraceVector(x1
, y1
, Target
.cX
, Target
.cY
) then
7165 begin // òî íóæíî ñòðåëÿòü âíèç
7166 SetAIFlag('NEEDFIRE', '1');
7167 SetAIFlag('NEEDSEEDOWN', '1');
7170 // Åñëè öåëü âèäíî è îíà íà òàêîé æå âûñîòå:
7171 if Target
.Visible
and
7172 (y1
+4 < Target
.Y
+Target
.Rect
.Y
+Target
.Rect
.Height
) and
7173 (y1
-4 > Target
.Y
+Target
.Rect
.Y
) then
7175 // Åñëè èäåì â ñòîðîíó öåëè, òî íàäî ñòðåëÿòü:
7176 if ((FDirection
= TDirection
.D_LEFT
) and (Target
.X
< FObj
.X
)) or
7177 ((FDirection
= TDirection
.D_RIGHT
) and (Target
.X
> FObj
.X
)) then
7178 begin // òî íóæíî ñòðåëÿòü âïåðåä
7179 SetAIFlag('NEEDFIRE', '1');
7180 SetAIFlag('NEEDSEEDOWN', '');
7181 SetAIFlag('NEEDSEEUP', '');
7183 // Åñëè öåëü â ïðåäåëàõ "ýêðàíà" è ñëîæíîñòü ïîçâîëÿåò ïðûæêè ñáëèæåíèÿ:
7184 if Abs(FObj
.X
-Target
.X
) < Trunc(gPlayerScreenSize
.X
*0.75) then
7185 if GetRnd(FDifficult
.CloseJump
) then
7186 begin // òî åñëè ïîâåçåò - ïðûãàåì (îñîáåííî, åñëè áëèçêî)
7187 if Abs(FObj
.X
-Target
.X
) < 128 then
7191 if Random(a
) = 0 then
7192 SetAIFlag('NEEDJUMP', '1');
7196 // Åñëè öåëü âñå åùå åñòü:
7197 if Target
.UID
<> 0 then
7198 if gTime
-FLastVisible
> 2000 then // Åñëè âèäåëè äàâíî
7199 Target
.UID
:= 0 // òî çàáûòü öåëü
7200 else // Åñëè âèäåëè íåäàâíî
7201 begin // íî öåëü óáèëè
7202 if Target
.IsPlayer
then
7203 begin // Öåëü - èãðîê
7204 pla
:= g_Player_Get(Target
.UID
);
7205 if (pla
= nil) or (not pla
.alive
) or pla
.NoTarget
or
7206 (pla
.FMegaRulez
[MR_INVIS
] >= gTime
) then
7207 Target
.UID
:= 0; // òî çàáûòü öåëü
7210 begin // Öåëü - ìîíñòð
7211 mon
:= g_Monsters_ByUID(Target
.UID
);
7212 if (mon
= nil) or (not mon
.alive
) then
7213 Target
.UID
:= 0; // òî çàáûòü öåëü
7216 end; // if Target.UID <> 0
7218 FTargetUID
:= Target
.UID
;
7220 // Åñëè âîçìîæíûõ öåëåé íåò:
7221 // (Àòàêà ÷åãî-íèáóäü ñëåâà èëè ñïðàâà)
7222 if targets
= nil then
7223 if GetAIFlag('ATTACKLEFT') <> '' then
7224 begin // Åñëè íóæíî àòàêîâàòü íàëåâî
7225 RemoveAIFlag('ATTACKLEFT');
7227 SetAIFlag('NEEDJUMP', '1');
7229 if RunDirection() = TDirection
.D_RIGHT
then
7230 begin // Èäåì íå â òó ñòîðîíó
7231 if (Healthy() > 1) and GetRnd(FDifficult
.InvisFire
) then
7232 begin // Åñëè çäîðîâû, òî, âîçìîæíî, ñòðåëÿåì áåæèì âëåâî è ñòðåëÿåì
7233 SetAIFlag('NEEDFIRE', '1');
7234 SetAIFlag('GOLEFT', '1');
7238 begin // Èäåì â íóæíóþ ñòîðîíó
7239 if GetRnd(FDifficult
.InvisFire
) then // Âîçìîæíî, ñòðåëÿåì âñëåïóþ
7240 SetAIFlag('NEEDFIRE', '1');
7241 if Healthy() <= 1 then // Ïîáèòû - óáåãàåì
7242 SetAIFlag('GORIGHT', '1');
7246 if GetAIFlag('ATTACKRIGHT') <> '' then
7247 begin // Åñëè íóæíî àòàêîâàòü íàïðàâî
7248 RemoveAIFlag('ATTACKRIGHT');
7250 SetAIFlag('NEEDJUMP', '1');
7252 if RunDirection() = TDirection
.D_LEFT
then
7253 begin // Èäåì íå â òó ñòîðîíó
7254 if (Healthy() > 1) and GetRnd(FDifficult
.InvisFire
) then
7255 begin // Åñëè çäîðîâû, òî, âîçìîæíî, áåæèì âïðàâî è ñòðåëÿåì
7256 SetAIFlag('NEEDFIRE', '1');
7257 SetAIFlag('GORIGHT', '1');
7262 if GetRnd(FDifficult
.InvisFire
) then // Âîçìîæíî, ñòðåëÿåì âñëåïóþ
7263 SetAIFlag('NEEDFIRE', '1');
7264 if Healthy() <= 1 then // Ïîáèòû - óáåãàåì
7265 SetAIFlag('GOLEFT', '1');
7269 //HACK! (does it belongs there?)
7270 RealizeCurrentWeapon();
7272 // Åñëè åñòü âîçìîæíûå öåëè:
7273 // (Ñòðåëÿåì ïî íàïðàâëåíèþ ê öåëÿì)
7274 if (targets
<> nil) and (GetAIFlag('NEEDFIRE') <> '') then
7275 for a
:= 0 to High(targets
) do
7277 // Åñëè ìîæåì ñòðåëÿòü ïî äèàãîíàëè:
7278 if GetRnd(FDifficult
.DiagFire
) then
7280 // Èùåì öåëü ñâåðõó è ñòðåëÿåì, åñëè åñòü:
7281 if FDirection
= TDirection
.D_LEFT
then
7282 angle
:= ANGLE_LEFTUP
7284 angle
:= ANGLE_RIGHTUP
;
7286 firew
:= Trunc(Cos(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
7287 fireh
:= Trunc(Sin(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
7289 if g_CollideLine(x1
, y1
, x1
+firew
, y1
+fireh
,
7290 targets
[a
].X
+targets
[a
].Rect
.X
+GetInterval(FDifficult
.DiagPrecision
, 128),
7291 targets
[a
].Y
+targets
[a
].Rect
.Y
+GetInterval(FDifficult
.DiagPrecision
, 128),
7292 targets
[a
].Rect
.Width
, targets
[a
].Rect
.Height
) and
7293 g_TraceVector(x1
, y1
, targets
[a
].cX
, targets
[a
].cY
) then
7295 SetAIFlag('NEEDFIRE', '1');
7296 SetAIFlag('NEEDSEEUP', '1');
7299 // Èùåì öåëü ñíèçó è ñòðåëÿåì, åñëè åñòü:
7300 if FDirection
= TDirection
.D_LEFT
then
7301 angle
:= ANGLE_LEFTDOWN
7303 angle
:= ANGLE_RIGHTDOWN
;
7305 firew
:= Trunc(Cos(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
7306 fireh
:= Trunc(Sin(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
7308 if g_CollideLine(x1
, y1
, x1
+firew
, y1
+fireh
,
7309 targets
[a
].X
+targets
[a
].Rect
.X
+GetInterval(FDifficult
.DiagPrecision
, 128),
7310 targets
[a
].Y
+targets
[a
].Rect
.Y
+GetInterval(FDifficult
.DiagPrecision
, 128),
7311 targets
[a
].Rect
.Width
, targets
[a
].Rect
.Height
) and
7312 g_TraceVector(x1
, y1
, targets
[a
].cX
, targets
[a
].cY
) then
7314 SetAIFlag('NEEDFIRE', '1');
7315 SetAIFlag('NEEDSEEDOWN', '1');
7319 // Åñëè öåëü "ïåðåä íîñîì", òî ñòðåëÿåì:
7320 if targets
[a
].Line
and targets
[a
].Visible
and
7321 (((FDirection
= TDirection
.D_LEFT
) and (targets
[a
].X
< FObj
.X
)) or
7322 ((FDirection
= TDirection
.D_RIGHT
) and (targets
[a
].X
> FObj
.X
))) then
7324 SetAIFlag('NEEDFIRE', '1');
7329 // Åñëè ëåòèò ïóëÿ, òî, âîçìîæíî, ïîäïðûãèâàåì:
7330 if g_Weapon_Danger(FUID
, FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+PLAYER_RECT
.Y
,
7331 PLAYER_RECT
.Width
, PLAYER_RECT
.Height
,
7332 40+GetInterval(FDifficult
.Cover
, 40)) then
7333 SetAIFlag('NEEDJUMP', '1');
7335 // Åñëè êîí÷èëèñü ïàòîðíû, òî íóæíî ñìåíèòü îðóæèå:
7336 ammo
:= GetAmmoByWeapon(FCurrWeap
);
7337 if ((FCurrWeap
= WEAPON_SHOTGUN2
) and (ammo
< 2)) or
7338 ((FCurrWeap
= WEAPON_BFG
) and (ammo
< 40)) or
7340 SetAIFlag('SELECTWEAPON', '1');
7342 // Åñëè íóæíî ñìåíèòü îðóæèå, òî âûáèðàåì íóæíîå:
7343 if GetAIFlag('SELECTWEAPON') = '1' then
7346 RemoveAIFlag('SELECTWEAPON');
7350 procedure TBot
.Update();
7363 // Ïðîâåðÿåì, îòêëþ÷¸í ëè AI áîòîâ
7364 if (g_debug_BotAIOff
= 1) and (Team
= TEAM_RED
) then
7366 if (g_debug_BotAIOff
= 2) and (Team
= TEAM_BLUE
) then
7368 if g_debug_BotAIOff
= 3 then
7378 RealizeCurrentWeapon();
7385 procedure TBot
.ReleaseKey(Key
: Byte);
7394 function TBot
.KeyPressed(Key
: Word): Boolean;
7396 Result
:= FKeys
[Key
].Pressed
;
7399 function TBot
.GetAIFlag(aName
: String20
): String20
;
7405 aName
:= LowerCase(aName
);
7407 if FAIFlags
<> nil then
7408 for a
:= 0 to High(FAIFlags
) do
7409 if LowerCase(FAIFlags
[a
].Name
) = aName
then
7411 Result
:= FAIFlags
[a
].Value
;
7416 procedure TBot
.RemoveAIFlag(aName
: String20
);
7420 if FAIFlags
= nil then Exit
;
7422 aName
:= LowerCase(aName
);
7424 for a
:= 0 to High(FAIFlags
) do
7425 if LowerCase(FAIFlags
[a
].Name
) = aName
then
7427 if a
<> High(FAIFlags
) then
7428 for b
:= a
to High(FAIFlags
)-1 do
7429 FAIFlags
[b
] := FAIFlags
[b
+1];
7431 SetLength(FAIFlags
, Length(FAIFlags
)-1);
7436 procedure TBot
.SetAIFlag(aName
, fValue
: String20
);
7444 aName
:= LowerCase(aName
);
7446 if FAIFlags
<> nil then
7447 for a
:= 0 to High(FAIFlags
) do
7448 if LowerCase(FAIFlags
[a
].Name
) = aName
then
7454 if ok
then FAIFlags
[a
].Value
:= fValue
7457 SetLength(FAIFlags
, Length(FAIFlags
)+1);
7458 with FAIFlags
[High(FAIFlags
)] do
7466 procedure TBot
.UpdateMove
;
7468 procedure GoLeft(Time
: Word = 1);
7470 ReleaseKey(KEY_LEFT
);
7471 ReleaseKey(KEY_RIGHT
);
7472 PressKey(KEY_LEFT
, Time
);
7473 SetDirection(TDirection
.D_LEFT
);
7476 procedure GoRight(Time
: Word = 1);
7478 ReleaseKey(KEY_LEFT
);
7479 ReleaseKey(KEY_RIGHT
);
7480 PressKey(KEY_RIGHT
, Time
);
7481 SetDirection(TDirection
.D_RIGHT
);
7484 function Rnd(a
: Word): Boolean;
7486 Result
:= Random(a
) = 0;
7489 procedure Turn(Time
: Word = 1200);
7491 if RunDirection() = TDirection
.D_LEFT
then GoRight(Time
) else GoLeft(Time
);
7496 ReleaseKey(KEY_LEFT
);
7497 ReleaseKey(KEY_RIGHT
);
7500 function CanRunLeft(): Boolean;
7502 Result
:= not CollideLevel(-1, 0);
7505 function CanRunRight(): Boolean;
7507 Result
:= not CollideLevel(1, 0);
7510 function CanRun(): Boolean;
7512 if RunDirection() = TDirection
.D_LEFT
then Result
:= CanRunLeft() else Result
:= CanRunRight();
7515 procedure Jump(Time
: Word = 30);
7517 PressKey(KEY_JUMP
, Time
);
7520 function NearHole(): Boolean;
7524 { TODO 5 : Ëåñòíèöû }
7525 sx
:= IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1);
7526 for x
:= 1 to PLAYER_RECT
.Width
do
7527 if (not StayOnStep(x
*sx
, 0)) and
7528 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
)) and
7529 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
*2)) then
7538 function BorderHole(): Boolean;
7542 { TODO 5 : Ëåñòíèöû }
7543 sx
:= IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1);
7544 for x
:= 1 to PLAYER_RECT
.Width
do
7545 if (not StayOnStep(x
*sx
, 0)) and
7546 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
)) and
7547 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
*2)) then
7549 for xx
:= x
to x
+32 do
7550 if CollideLevel(xx
*sx
, PLAYER_RECT
.Height
) then
7560 function NearDeepHole(): Boolean;
7566 sx
:= IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1);
7569 for x
:= 1 to PLAYER_RECT
.Width
do
7570 if (not StayOnStep(x
*sx
, 0)) and
7571 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
)) and
7572 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
*2)) then
7574 while FObj
.Y
+y
*PLAYER_RECT
.Height
< gMapInfo
.Height
do
7576 if CollideLevel(x
*sx
, PLAYER_RECT
.Height
*y
) then Exit
;
7581 end else Result
:= False;
7584 function OverDeepHole(): Boolean;
7591 while FObj
.Y
+y
*PLAYER_RECT
.Height
< gMapInfo
.Height
do
7593 if CollideLevel(0, PLAYER_RECT
.Height
*y
) then Exit
;
7600 function OnGround(): Boolean;
7602 Result
:= StayOnStep(0, 0) or CollideLevel(0, 1);
7605 function OnLadder(): Boolean;
7607 Result
:= FullInStep(0, 0);
7610 function BelowLadder(): Boolean;
7612 Result
:= (FullInStep(IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -PLAYER_RECT
.Height
) and
7613 not CollideLevel(IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -PLAYER_RECT
.Height
)) or
7614 (FullInStep(IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -BOT_MAXJUMP
) and
7615 not CollideLevel(IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -BOT_MAXJUMP
));
7618 function BelowLiftUp(): Boolean;
7620 Result
:= ((FullInLift(IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -PLAYER_RECT
.Height
) = -1) and
7621 not CollideLevel(IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -PLAYER_RECT
.Height
)) or
7622 ((FullInLift(IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -BOT_MAXJUMP
) = -1) and
7623 not CollideLevel(IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -BOT_MAXJUMP
));
7626 function OnTopLift(): Boolean;
7628 Result
:= (FullInLift(0, 0) = -1) and (FullInLift(0, -32) = 0);
7631 function CanJumpOver(): Boolean;
7635 sx
:= IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1);
7639 if not CollideLevel(sx
, 0) then Exit
;
7641 for y
:= 1 to BOT_MAXJUMP
do
7642 if CollideLevel(0, -y
) then Exit
else
7643 if not CollideLevel(sx
, -y
) then
7650 function CanJumpUp(Dist
: ShortInt): Boolean;
7657 if CollideLevel(Dist
, 0) then Exit
;
7660 for y
:= 0 to BOT_MAXJUMP
do
7661 if CollideLevel(Dist
, -y
) then
7670 for yy
:= y
+1 to BOT_MAXJUMP
do
7671 if not CollideLevel(Dist
, -yy
) then
7680 for y
:= 0 to BOT_MAXJUMP
do
7681 if CollideLevel(0, -y
) then
7689 if y
< yy
then Exit
;
7694 function IsSafeTrigger(): Boolean;
7699 if gTriggers
= nil then
7701 for a
:= 0 to High(gTriggers
) do
7702 if Collide(gTriggers
[a
].X
,
7705 gTriggers
[a
].Height
) and
7706 (gTriggers
[a
].TriggerType
in [TRIGGER_EXIT
, TRIGGER_CLOSEDOOR
,
7707 TRIGGER_CLOSETRAP
, TRIGGER_TRAP
,
7708 TRIGGER_PRESS
, TRIGGER_ON
, TRIGGER_OFF
,
7709 TRIGGER_ONOFF
, TRIGGER_SPAWNMONSTER
,
7710 TRIGGER_DAMAGE
, TRIGGER_SHOT
]) then
7715 // Âîçìîæíî, íàæèìàåì êíîïêó:
7716 if Rnd(16) and IsSafeTrigger() then
7719 // Åñëè ïîä ëèôòîì èëè ñòóïåíüêàìè, òî, âîçìîæíî, ïðûãàåì:
7720 if OnLadder() or ((BelowLadder() or BelowLiftUp()) and Rnd(8)) then
7722 ReleaseKey(KEY_LEFT
);
7723 ReleaseKey(KEY_RIGHT
);
7727 // Èäåì âëåâî, åñëè íàäî áûëî:
7728 if GetAIFlag('GOLEFT') <> '' then
7730 RemoveAIFlag('GOLEFT');
7731 if CanRunLeft() then
7735 // Èäåì âïðàâî, åñëè íàäî áûëî:
7736 if GetAIFlag('GORIGHT') <> '' then
7738 RemoveAIFlag('GORIGHT');
7739 if CanRunRight() then
7743 // Åñëè âûëåòåëè çà êàðòó, òî ïðîáóåì âåðíóòüñÿ:
7744 if FObj
.X
< -32 then
7747 if FObj
.X
+32 > gMapInfo
.Width
then
7750 // Ïðûãàåì, åñëè íàäî áûëî:
7751 if GetAIFlag('NEEDJUMP') <> '' then
7754 RemoveAIFlag('NEEDJUMP');
7757 // Ñìîòðèì ââåðõ, åñëè íàäî áûëî:
7758 if GetAIFlag('NEEDSEEUP') <> '' then
7761 ReleaseKey(KEY_DOWN
);
7762 PressKey(KEY_UP
, 20);
7763 RemoveAIFlag('NEEDSEEUP');
7766 // Ñìîòðèì âíèç, åñëè íàäî áûëî:
7767 if GetAIFlag('NEEDSEEDOWN') <> '' then
7770 ReleaseKey(KEY_DOWN
);
7771 PressKey(KEY_DOWN
, 20);
7772 RemoveAIFlag('NEEDSEEDOWN');
7775 // Åñëè íóæíî áûëî â äûðó è ìû íå íà çåìëå, òî ïîêîðíî ëåòèì:
7776 if GetAIFlag('GOINHOLE') <> '' then
7777 if not OnGround() then
7779 ReleaseKey(KEY_LEFT
);
7780 ReleaseKey(KEY_RIGHT
);
7781 RemoveAIFlag('GOINHOLE');
7782 SetAIFlag('FALLINHOLE', '1');
7785 // Åñëè ïàäàëè è äîñòèãëè çåìëè, òî õâàòèò ïàäàòü:
7786 if GetAIFlag('FALLINHOLE') <> '' then
7788 RemoveAIFlag('FALLINHOLE');
7790 // Åñëè ëåòåëè ïðÿìî è ñåé÷àñ íå íà ëåñòíèöå èëè íà âåðøèíå ëèôòà, òî îòõîäèì â ñòîðîíó:
7791 if not (KeyPressed(KEY_LEFT
) or KeyPressed(KEY_RIGHT
)) then
7792 if GetAIFlag('FALLINHOLE') = '' then
7793 if (not OnLadder()) or (FObj
.Vel
.Y
>= 0) or (OnTopLift()) then
7799 // Åñëè íà çåìëå è ìîæíî ïîäïðûãíóòü, òî, âîçìîæíî, ïðûãàåì:
7801 CanJumpUp(IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1)*32) and
7805 // Åñëè íà çåìëå è âîçëå äûðû (ãëóáèíà > 2 ðîñòîâ èãðîêà):
7806 if OnGround() and NearHole() then
7807 if NearDeepHole() then // Åñëè ýòî áåçäíà
7809 0..3: Turn(); // Áåæèì îáðàòíî
7810 4: Jump(); // Ïðûãàåì
7811 5: begin // Ïðûãàåì îáðàòíî
7816 else // Ýòî íå áåçäíà è ìû åùå íå ëåòèì òóäà
7817 if GetAIFlag('GOINHOLE') = '' then
7819 0: Turn(); // Íå íóæíî òóäà
7820 1: Jump(); // Âäðóã ïîâåçåò - ïðûãàåì
7821 else // Åñëè ÿìà ñ ãðàíèöåé, òî ïðè ñëó÷àå ìîæíî òóäà ïðûãíóòü
7822 if BorderHole() then
7823 SetAIFlag('GOINHOLE', '1');
7826 // Åñëè íà çåìëå, íî íåêóäà èäòè:
7827 if (not CanRun()) and OnGround() then
7829 // Åñëè ìû íà ëåñòíèöå èëè ìîæíî ïåðåïðûãíóòü, òî ïðûãàåì:
7830 if CanJumpOver() or OnLadder() then
7832 else // èíà÷å ïîïûòàåìñÿ â äðóãóþ ñòîðîíó
7833 if Random(2) = 0 then
7835 if IsSafeTrigger() then
7841 // Îñòàëîñü ìàëî âîçäóõà:
7842 if FAir
< 36 * 2 then
7845 // Âûáèðàåìñÿ èç êèñëîòû, åñëè íåò êîñòþìà, îáîæãëèñü, èëè ìàëî çäîðîâüÿ:
7846 if (FMegaRulez
[MR_SUIT
] < gTime
) and ((FLastHit
= HIT_ACID
) or (Healthy() <= 1)) then
7847 if BodyInAcid(0, 0) then
7851 function TBot
.FullInStep(XInc
, YInc
: Integer): Boolean;
7853 Result
:= g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
,
7854 PLAYER_RECT
.Width
, PLAYER_RECT
.Height
, PANEL_STEP
, False);
7857 {function TBot.NeedItem(Item: Byte): Byte;
7862 procedure TBot
.SelectWeapon(Dist
: Integer);
7866 function HaveAmmo(weapon
: Byte): Boolean;
7869 WEAPON_PISTOL
: Result
:= FAmmo
[A_BULLETS
] >= 1;
7870 WEAPON_SHOTGUN1
: Result
:= FAmmo
[A_SHELLS
] >= 1;
7871 WEAPON_SHOTGUN2
: Result
:= FAmmo
[A_SHELLS
] >= 2;
7872 WEAPON_CHAINGUN
: Result
:= FAmmo
[A_BULLETS
] >= 10;
7873 WEAPON_ROCKETLAUNCHER
: Result
:= FAmmo
[A_ROCKETS
] >= 1;
7874 WEAPON_PLASMA
: Result
:= FAmmo
[A_CELLS
] >= 10;
7875 WEAPON_BFG
: Result
:= FAmmo
[A_CELLS
] >= 40;
7876 WEAPON_SUPERPULEMET
: Result
:= FAmmo
[A_SHELLS
] >= 1;
7877 WEAPON_FLAMETHROWER
: Result
:= FAmmo
[A_FUEL
] >= 1;
7878 else Result
:= True;
7883 if Dist
= -1 then Dist
:= BOT_LONGDIST
;
7885 if Dist
> BOT_LONGDIST
then
7886 begin // Äàëüíèé áîé
7888 if FWeapon
[FDifficult
.WeaponPrior
[a
]] and HaveAmmo(FDifficult
.WeaponPrior
[a
]) then
7890 FSelectedWeapon
:= FDifficult
.WeaponPrior
[a
];
7894 else //if Dist > BOT_UNSAFEDIST then
7895 begin // Áëèæíèé áîé
7897 if FWeapon
[FDifficult
.CloseWeaponPrior
[a
]] and HaveAmmo(FDifficult
.CloseWeaponPrior
[a
]) then
7899 FSelectedWeapon
:= FDifficult
.CloseWeaponPrior
[a
];
7906 if FWeapon[FDifficult.SafeWeaponPrior[a]] and HaveAmmo(FDifficult.SafeWeaponPrior[a]) then
7908 FSelectedWeapon := FDifficult.SafeWeaponPrior[a];
7914 function TBot
.PickItem(ItemType
: Byte; force
: Boolean; var remove
: Boolean): Boolean;
7916 Result
:= inherited PickItem(ItemType
, force
, remove
);
7918 if Result
then SetAIFlag('SELECTWEAPON', '1');
7921 function TBot
.Heal(value
: Word; Soft
: Boolean): Boolean;
7923 Result
:= inherited Heal(value
, Soft
);
7926 function TBot
.Healthy(): Byte;
7928 if FMegaRulez
[MR_INVUL
] >= gTime
then Result
:= 3
7929 else if (FHealth
> 80) or ((FHealth
> 50) and (FArmor
> 20)) then Result
:= 3
7930 else if (FHealth
> 50) then Result
:= 2
7931 else if (FHealth
> 20) then Result
:= 1
7935 function TBot
.TargetOnScreen(TX
, TY
: Integer): Boolean;
7937 Result
:= (Abs(FObj
.X
-TX
) <= Trunc(gPlayerScreenSize
.X
*0.6)) and
7938 (Abs(FObj
.Y
-TY
) <= Trunc(gPlayerScreenSize
.Y
*0.6));
7941 procedure TBot
.OnDamage(Angle
: SmallInt);
7949 if (Angle
= 0) or (Angle
= 180) then
7952 if (g_GetUIDType(FLastSpawnerUID
) = UID_PLAYER
) and
7953 LongBool(gGameSettings
.Options
and GAME_OPTION_BOTVSPLAYER
) then
7955 pla
:= g_Player_Get(FLastSpawnerUID
);
7956 ok
:= not TargetOnScreen(pla
.FObj
.X
+ PLAYER_RECT
.X
,
7957 pla
.FObj
.Y
+ PLAYER_RECT
.Y
);
7960 if (g_GetUIDType(FLastSpawnerUID
) = UID_MONSTER
) and
7961 LongBool(gGameSettings
.Options
and GAME_OPTION_BOTVSMONSTER
) then
7963 mon
:= g_Monsters_ByUID(FLastSpawnerUID
);
7964 ok
:= not TargetOnScreen(mon
.Obj
.X
+ mon
.Obj
.Rect
.X
,
7965 mon
.Obj
.Y
+ mon
.Obj
.Rect
.Y
);
7970 SetAIFlag('ATTACKLEFT', '1')
7972 SetAIFlag('ATTACKRIGHT', '1');
7976 function TBot
.RunDirection(): TDirection
;
7978 if Abs(Vel
.X
) >= 1 then
7980 if Vel
.X
> 0 then Result
:= TDirection
.D_RIGHT
else Result
:= TDirection
.D_LEFT
;
7982 Result
:= FDirection
;
7985 function TBot
.GetRnd(a
: Byte): Boolean;
7987 if a
= 0 then Result
:= False
7988 else if a
= 255 then Result
:= True
7989 else Result
:= Random(256) > 255-a
;
7992 function TBot
.GetInterval(a
: Byte; radius
: SmallInt): SmallInt;
7994 Result
:= Round((255-a
)/255*radius
*(Random(2)-1));
7998 procedure TDifficult
.save (st
: TStream
);
8000 utils
.writeInt(st
, Byte(DiagFire
));
8001 utils
.writeInt(st
, Byte(InvisFire
));
8002 utils
.writeInt(st
, Byte(DiagPrecision
));
8003 utils
.writeInt(st
, Byte(FlyPrecision
));
8004 utils
.writeInt(st
, Byte(Cover
));
8005 utils
.writeInt(st
, Byte(CloseJump
));
8006 st
.WriteBuffer(WeaponPrior
[Low(WeaponPrior
)], sizeof(WeaponPrior
));
8007 st
.WriteBuffer(CloseWeaponPrior
[Low(CloseWeaponPrior
)], sizeof(CloseWeaponPrior
));
8010 procedure TDifficult
.load (st
: TStream
);
8012 DiagFire
:= utils
.readByte(st
);
8013 InvisFire
:= utils
.readByte(st
);
8014 DiagPrecision
:= utils
.readByte(st
);
8015 FlyPrecision
:= utils
.readByte(st
);
8016 Cover
:= utils
.readByte(st
);
8017 CloseJump
:= utils
.readByte(st
);
8018 st
.ReadBuffer(WeaponPrior
[Low(WeaponPrior
)], sizeof(WeaponPrior
));
8019 st
.ReadBuffer(CloseWeaponPrior
[Low(CloseWeaponPrior
)], sizeof(CloseWeaponPrior
));
8023 procedure TBot
.SaveState (st
: TStream
);
8028 inherited SaveState(st
);
8029 utils
.writeSign(st
, 'BOT0');
8031 utils
.writeInt(st
, Byte(FSelectedWeapon
));
8033 utils
.writeInt(st
, Word(FTargetUID
));
8034 // Âðåìÿ ïîòåðè öåëè
8035 utils
.writeInt(st
, LongWord(FLastVisible
));
8036 // Êîëè÷åñòâî ôëàãîâ ÈÈ
8037 dw
:= Length(FAIFlags
);
8038 utils
.writeInt(st
, LongInt(dw
));
8040 for i
:= 0 to dw
-1 do
8042 utils
.writeStr(st
, FAIFlags
[i
].Name
, 20);
8043 utils
.writeStr(st
, FAIFlags
[i
].Value
, 20);
8045 // Íàñòðîéêè ñëîæíîñòè
8046 FDifficult
.save(st
);
8050 procedure TBot
.LoadState (st
: TStream
);
8055 inherited LoadState(st
);
8056 if not utils
.checkSign(st
, 'BOT0') then raise XStreamError
.Create('invalid bot signature');
8058 FSelectedWeapon
:= utils
.readByte(st
);
8060 FTargetUID
:= utils
.readWord(st
);
8061 // Âðåìÿ ïîòåðè öåëè
8062 FLastVisible
:= utils
.readLongWord(st
);
8063 // Êîëè÷åñòâî ôëàãîâ ÈÈ
8064 dw
:= utils
.readLongInt(st
);
8065 if (dw
< 0) or (dw
> 16384) then raise XStreamError
.Create('invalid number of bot AI flags');
8066 SetLength(FAIFlags
, dw
);
8068 for i
:= 0 to dw
-1 do
8070 FAIFlags
[i
].Name
:= utils
.readStr(st
, 20);
8071 FAIFlags
[i
].Value
:= utils
.readStr(st
, 20);
8073 // Íàñòðîéêè ñëîæíîñòè
8074 FDifficult
.load(st
);
8079 conRegVar('cheat_berserk_autoswitch', @gBerserkAutoswitch
, 'autoswitch to fist when berserk pack taken', '', true, true);
8080 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');
8081 conRegVar('player_indicator_style', @gPlayerIndicatorStyle
, 'Visual appearance of indicator', 'Visual appearance of indicator');