1 (* Copyright (C) Doom 2D: Forever Developers
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, version 3 of the License ONLY.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 {$INCLUDE ../shared/a_modes.inc}
23 {$IFDEF USE_MEMPOOL}mempool
,{$ENDIF}
24 e_graphics
, g_playermodel
, g_basic
, g_textures
,
25 g_weapons
, g_phys
, g_sound
, g_saveload
, MAPDEF
,
61 AmmoLimits
: Array [0..1] of Array [A_BULLETS
..A_HIGH
] of Word =
62 ((200, 50, 50, 300, 100),
63 (400, 100, 100, 600, 200));
84 ANGLE_NONE
= Low(SmallInt);
86 CORPSE_STATE_REMOVEME
= 0;
87 CORPSE_STATE_NORMAL
= 1;
88 CORPSE_STATE_MESS
= 2;
90 PLAYER_RECT
: TRectWH
= (X
:15; Y
:12; Width
:34; Height
:52);
91 PLAYER_RECT_CX
= 15+(34 div 2);
92 PLAYER_RECT_CY
= 12+(52 div 2);
93 PLAYER_CORPSERECT
: TRectWH
= (X
:15; Y
:48; Width
:34; Height
:16);
96 PLAYER_HP_LIMIT
= 200;
98 PLAYER_AP_LIMIT
= 200;
102 PLAYER_BURN_TIME
= 110;
104 PLAYER1_DEF_COLOR
: TRGB
= (R
:64; G
:175; B
:48);
105 PLAYER2_DEF_COLOR
: TRGB
= (R
:96; G
:96; B
:96);
123 TPlayerStatArray
= Array of TPlayerStat
;
125 TPlayerSavedState
= record
133 Ammo
: Array [A_BULLETS
..A_HIGH
] of Word;
134 MaxAmmo
: Array [A_BULLETS
..A_HIGH
] of Word;
135 Weapon
: Array [WP_FIRST
..WP_LAST
] of Boolean;
136 Rulez
: Set of R_ITEM_BACKPACK
..R_BERSERK
;
145 TPlayer
= class{$IFDEF USE_MEMPOOL}(TPoolObject
){$ENDIF}
153 FDirection
: TDirection
;
161 FMonsterKills
: Integer;
167 FCanJetpack
: Boolean;
173 FNextWeapDelay
: Byte; // frames
174 FBFGFireCounter
: SmallInt;
175 FLastSpawnerUID
: Word;
179 FSpectatePlayer
: Integer;
180 FFirePainTime
: Integer;
183 FSavedStateNum
: Integer;
185 FModel
: TPlayerModel
;
186 FPunchAnim
: TAnimation
;
189 FActionForce
: Boolean;
190 FActionChanged
: Boolean;
192 FFireAngle
: SmallInt;
196 FShellTimer
: Integer;
198 FSawSound
: TPlayableSound
;
199 FSawSoundIdle
: TPlayableSound
;
200 FSawSoundHit
: TPlayableSound
;
201 FSawSoundSelect
: TPlayableSound
;
202 FFlameSoundOn
: TPlayableSound
;
203 FFlameSoundOff
: TPlayableSound
;
204 FFlameSoundWork
: TPlayableSound
;
205 FJetSoundOn
: TPlayableSound
;
206 FJetSoundOff
: TPlayableSound
;
207 FJetSoundFly
: TPlayableSound
;
211 FJustTeleported
: Boolean;
213 mEDamageType
: Integer;
216 function CollideLevel(XInc
, YInc
: Integer): Boolean;
217 function StayOnStep(XInc
, YInc
: Integer): Boolean;
218 function HeadInLiquid(XInc
, YInc
: Integer): Boolean;
219 function BodyInLiquid(XInc
, YInc
: Integer): Boolean;
220 function BodyInAcid(XInc
, YInc
: Integer): Boolean;
221 function FullInLift(XInc
, YInc
: Integer): Integer;
222 {procedure CollideItem();}
223 procedure FlySmoke(Times
: DWORD
= 1);
224 procedure OnFireFlame(Times
: DWORD
= 1);
225 function GetAmmoByWeapon(Weapon
: Byte): Word;
226 procedure SetAction(Action
: Byte; Force
: Boolean = False);
227 procedure OnDamage(Angle
: SmallInt); virtual;
228 function firediry(): Integer;
231 procedure Run(Direction
: TDirection
);
232 procedure NextWeapon();
233 procedure PrevWeapon();
240 function getNextWeaponIndex (): Byte; // return 255 for "no switch"
241 procedure resetWeaponQueue ();
242 function hasAmmoForWeapon (weapon
: Byte): Boolean;
243 function hasAmmoForShooting (weapon
: Byte): Boolean;
244 function shouldSwitch (weapon
: Byte; hadWeapon
: Boolean) : Boolean;
246 procedure doDamage (v
: Integer);
248 function refreshCorpse(): Boolean;
251 FDamageBuffer
: Integer;
253 FAmmo
: Array [A_BULLETS
..A_HIGH
] of Word;
254 FMaxAmmo
: Array [A_BULLETS
..A_HIGH
] of Word;
255 FWeapon
: Array [WP_FIRST
..WP_LAST
] of Boolean;
256 FRulez
: Set of R_ITEM_BACKPACK
..R_BERSERK
;
258 FMegaRulez
: Array [MR_SUIT
..MR_MAX
] of DWORD
;
259 FReloading
: Array [WP_FIRST
..WP_LAST
] of Word;
260 FTime
: Array [T_RESPAWN
..T_FLAGCAP
] of DWORD
;
261 FKeys
: Array [KEY_LEFT
..KEY_CHAT
] of TKeyState
;
262 FWeapSwitchMode
: Byte;
263 FWeapPreferences
: Array [WP_FIRST
.. WP_LAST
+1] of Byte;
264 FSwitchToEmpty
: Byte;
267 FPreferredTeam
: Byte;
270 FWantsInGame
: Boolean;
275 FActualModelName
: string;
282 FSpawnInvul
: Integer;
284 FWaitForFirstSpawn
: Boolean; // set to `true` in server, used to spawn a player on first full state request
287 // debug: viewport offset
288 viewPortX
, viewPortY
, viewPortW
, viewPortH
: Integer;
290 function isValidViewPort (): Boolean; inline;
292 constructor Create(); virtual;
293 destructor Destroy(); override;
294 procedure Respawn(Silent
: Boolean; Force
: Boolean = False); virtual;
295 function GetRespawnPoint(): Byte;
296 procedure PressKey(Key
: Byte; Time
: Word = 1);
297 procedure ReleaseKeys();
298 procedure SetModel(ModelName
: String);
299 procedure SetColor(Color
: TRGB
);
300 function GetColor(): TRGB
;
301 procedure SetWeapon(W
: Byte);
302 function IsKeyPressed(K
: Byte): Boolean;
303 function GetKeys(): Byte;
304 function PickItem(ItemType
: Byte; arespawn
: Boolean; var remove
: Boolean): Boolean; virtual;
305 procedure SetWeaponPrefs(Prefs
: Array of Byte);
306 procedure SetWeaponPref(Weapon
, Pref
: Byte);
307 function GetWeaponPref(Weapon
: Byte) : Byte;
308 function GetMorePrefered() : Byte;
309 function MaySwitch(Weapon
: Byte) : Boolean;
310 function Collide(X
, Y
: Integer; Width
, Height
: Word): Boolean; overload
;
311 function Collide(Panel
: TPanel
): Boolean; overload
;
312 function Collide(X
, Y
: Integer): Boolean; overload
;
313 procedure SetDirection(Direction
: TDirection
);
314 procedure GetSecret();
315 function TeleportTo(X
, Y
: Integer; silent
: Boolean; dir
: Byte): Boolean;
317 procedure Push(vx
, vy
: Integer);
318 procedure ChangeModel(ModelName
: String);
319 procedure SwitchTeam
;
320 procedure ChangeTeam(Team
: Byte);
322 function GetFlag(Flag
: Byte): Boolean;
323 procedure SetFlag(Flag
: Byte);
324 function DropFlag(Silent
: Boolean = True; DoThrow
: Boolean = False): Boolean;
325 function TryDropFlag(): Boolean;
326 procedure AllRulez(Health
: Boolean);
327 procedure RestoreHealthArmor();
328 procedure FragCombo();
329 procedure GiveItem(ItemType
: Byte);
330 procedure Damage(value
: Word; SpawnerUID
: Word; vx
, vy
: Integer; t
: Byte); virtual;
331 function Heal(value
: Word; Soft
: Boolean): Boolean; virtual;
332 procedure MakeBloodVector(Count
: Word; VelX
, VelY
: Integer);
333 procedure MakeBloodSimple(Count
: Word);
334 procedure Kill(KillType
: Byte; SpawnerUID
: Word; t
: Byte);
335 procedure Reset(Force
: Boolean);
336 procedure Spectate(NoMove
: Boolean = False);
337 procedure SwitchNoClip
;
338 procedure SoftReset();
339 procedure Draw(); virtual;
340 procedure DrawPain();
341 procedure DrawPickup();
342 procedure DrawRulez();
344 procedure DrawIndicator(Color
: TRGB
);
345 procedure DrawBubble();
347 procedure PreUpdate();
348 procedure Update(); virtual;
349 procedure RememberState();
350 procedure RecallState();
351 procedure SaveState (st
: TStream
); virtual;
352 procedure LoadState (st
: TStream
); virtual;
353 procedure PauseSounds(Enable
: Boolean);
354 procedure NetFire(Wpn
: Byte; X
, Y
, AX
, AY
: Integer; WID
: Integer = -1);
355 procedure DoLerp(Level
: Integer = 2);
356 procedure SetLerp(XTo
, YTo
: Integer);
357 procedure ProcessWeaponAction(Action
: Byte);
358 procedure QueueWeaponSwitch(Weapon
: Byte);
359 procedure RealizeCurrentWeapon();
363 procedure JetpackOff
;
364 procedure CatchFire(Attacker
: Word; Timeout
: Integer = PLAYER_BURN_TIME
);
366 //WARNING! this does nothing for now, but still call it!
367 procedure positionChanged (); //WARNING! call this after entity position was changed, or coldet will not work right!
369 procedure getMapBox (out x
, y
, w
, h
: Integer); inline;
370 procedure moveBy (dx
, dy
: Integer); inline;
372 function getCameraObj(): TObj
;
375 property Vel
: TPoint2i read FObj
.Vel
;
376 property Obj
: TObj read FObj
;
378 property Name
: String read FName write FName
;
379 property Model
: TPlayerModel read FModel
;
380 property Health
: Integer read FHealth write FHealth
;
381 property Lives
: Byte read FLives write FLives
;
382 property Armor
: Integer read FArmor write FArmor
;
383 property Air
: Integer read FAir write FAir
;
384 property JetFuel
: Integer read FJetFuel write FJetFuel
;
385 property Frags
: Integer read FFrags write FFrags
;
386 property Death
: Integer read FDeath write FDeath
;
387 property Kills
: Integer read FKills write FKills
;
388 property CurrWeap
: Byte read FCurrWeap write FCurrWeap
;
389 property WeapSwitchMode
: Byte read FWeapSwitchMode write FWeapSwitchMode
;
390 property SwitchToEmpty
: Byte read FSwitchToEmpty write FSwitchToEmpty
;
391 property SkipFist
: Byte read FSkipFist write FSkipFist
;
392 property MonsterKills
: Integer read FMonsterKills write FMonsterKills
;
393 property Secrets
: Integer read FSecrets
;
394 property GodMode
: Boolean read FGodMode write FGodMode
;
395 property NoTarget
: Boolean read FNoTarget write FNoTarget
;
396 property NoReload
: Boolean read FNoReload write FNoReload
;
397 property alive
: Boolean read FAlive write FAlive
;
398 property Flag
: Byte read FFlag
;
399 property Team
: Byte read FTeam write FTeam
;
400 property Direction
: TDirection read FDirection
;
401 property GameX
: Integer read FObj
.X write FObj
.X
;
402 property GameY
: Integer read FObj
.Y write FObj
.Y
;
403 property GameVelX
: Integer read FObj
.Vel
.X write FObj
.Vel
.X
;
404 property GameVelY
: Integer read FObj
.Vel
.Y write FObj
.Vel
.Y
;
405 property GameAccelX
: Integer read FObj
.Accel
.X write FObj
.Accel
.X
;
406 property GameAccelY
: Integer read FObj
.Accel
.Y write FObj
.Accel
.Y
;
407 property IncCam
: Integer read FIncCam write FIncCam
;
408 property IncCamOld
: Integer read FIncCamOld write FIncCamOld
;
409 property SlopeOld
: Integer read FSlopeOld write FSlopeOld
;
410 property UID
: Word read FUID write FUID
;
411 property JustTeleported
: Boolean read FJustTeleported write FJustTeleported
;
412 property NetTime
: LongWord read FNetTime write FNetTime
;
415 property eName
: String read FName write FName
;
416 property eHealth
: Integer read FHealth write FHealth
;
417 property eLives
: Byte read FLives write FLives
;
418 property eArmor
: Integer read FArmor write FArmor
;
419 property eAir
: Integer read FAir write FAir
;
420 property eJetFuel
: Integer read FJetFuel write FJetFuel
;
421 property eFrags
: Integer read FFrags write FFrags
;
422 property eDeath
: Integer read FDeath write FDeath
;
423 property eKills
: Integer read FKills write FKills
;
424 property eCurrWeap
: Byte read FCurrWeap write FCurrWeap
;
425 property eMonsterKills
: Integer read FMonsterKills write FMonsterKills
;
426 property eSecrets
: Integer read FSecrets write FSecrets
;
427 property eGodMode
: Boolean read FGodMode write FGodMode
;
428 property eNoTarget
: Boolean read FNoTarget write FNoTarget
;
429 property eNoReload
: Boolean read FNoReload write FNoReload
;
430 property eAlive
: Boolean read FAlive write FAlive
;
431 property eFlag
: Byte read FFlag
;
432 property eTeam
: Byte read FTeam write FTeam
;
433 property eDirection
: TDirection read FDirection
;
434 property eGameX
: Integer read FObj
.X write FObj
.X
;
435 property eGameY
: Integer read FObj
.Y write FObj
.Y
;
436 property eGameVelX
: Integer read FObj
.Vel
.X write FObj
.Vel
.X
;
437 property eGameVelY
: Integer read FObj
.Vel
.Y write FObj
.Vel
.Y
;
438 property eGameAccelX
: Integer read FObj
.Accel
.X write FObj
.Accel
.X
;
439 property eGameAccelY
: Integer read FObj
.Accel
.Y write FObj
.Accel
.Y
;
440 property eIncCam
: Integer read FIncCam write FIncCam
;
441 property eUID
: Word read FUID
;
442 property eJustTeleported
: Boolean read FJustTeleported
;
443 property eNetTime
: LongWord read FNetTime
;
445 // set this before assigning something to `eDamage`
446 property eDamageType
: Integer read mEDamageType write mEDamageType
;
447 property eDamage
: Integer write doDamage
;
458 WeaponPrior
: packed array [WP_FIRST
..WP_LAST
] of Byte;
459 CloseWeaponPrior
: packed array [WP_FIRST
..WP_LAST
] of Byte;
460 //SafeWeaponPrior: Array [WP_FIRST..WP_LAST] of Byte;
463 procedure save (st
: TStream
);
464 procedure load (st
: TStream
);
472 TBot
= class(TPlayer
)
474 FSelectedWeapon
: Byte;
477 FAIFlags
: Array of TAIFlag
;
478 FDifficult
: TDifficult
;
480 function GetRnd(a
: Byte): Boolean;
481 function GetInterval(a
: Byte; radius
: SmallInt): SmallInt;
482 function RunDirection(): TDirection
;
483 function FullInStep(XInc
, YInc
: Integer): Boolean;
484 //function NeedItem(Item: Byte): Byte;
485 procedure SelectWeapon(Dist
: Integer);
486 procedure SetAIFlag(aName
, fValue
: String20
);
487 function GetAIFlag(aName
: String20
): String20
;
488 procedure RemoveAIFlag(aName
: String20
);
489 function Healthy(): Byte;
490 procedure UpdateMove();
491 procedure UpdateCombat();
492 function KeyPressed(Key
: Word): Boolean;
493 procedure ReleaseKey(Key
: Byte);
494 function TargetOnScreen(TX
, TY
: Integer): Boolean;
495 procedure OnDamage(Angle
: SmallInt); override;
498 procedure Respawn(Silent
: Boolean; Force
: Boolean = False); override;
499 constructor Create(); override;
500 destructor Destroy(); override;
501 procedure Draw(); override;
502 function PickItem(ItemType
: Byte; force
: Boolean; var remove
: Boolean): Boolean; override;
503 function Heal(value
: Word; Soft
: Boolean): Boolean; override;
504 procedure Update(); override;
505 procedure SaveState (st
: TStream
); override;
506 procedure LoadState (st
: TStream
); override;
518 procedure getMapBox (out x
, y
, w
, h
: Integer); inline;
519 procedure moveBy (dx
, dy
: Integer); inline;
521 procedure positionChanged (); inline; //WARNING! call this after entity position was changed, or coldet will not work right!
535 procedure getMapBox (out x
, y
, w
, h
: Integer); inline;
536 procedure moveBy (dx
, dy
: Integer); inline;
538 procedure positionChanged (); inline; //WARNING! call this after entity position was changed, or coldet will not work right!
541 TCorpse
= class{$IFDEF USE_MEMPOOL}(TPoolObject
){$ENDIF}
550 FAnimation
: TAnimation
;
551 FAnimationMask
: TAnimation
;
554 constructor Create(X
, Y
: Integer; ModelName
: String; aMess
: Boolean);
555 destructor Destroy(); override;
556 procedure Damage(Value
: Word; SpawnerUID
: Word; vx
, vy
: Integer);
559 procedure SaveState (st
: TStream
);
560 procedure LoadState (st
: TStream
);
562 procedure getMapBox (out x
, y
, w
, h
: Integer); inline;
563 procedure moveBy (dx
, dy
: Integer); inline;
565 procedure positionChanged (); inline; //WARNING! call this after entity position was changed, or coldet will not work right!
567 function ObjPtr (): PObj
; inline;
569 property Obj
: TObj read FObj
; // copies object
570 property State
: Byte read FState
;
571 property Mess
: Boolean read FMess
;
574 TTeamStat
= Array [TEAM_RED
..TEAM_BLUE
] of
580 gPlayers
: Array of TPlayer
;
581 gCorpses
: Array of TCorpse
;
582 gGibs
: Array of TGib
;
583 gShells
: Array of TShell
;
584 gTeamStat
: TTeamStat
;
585 gFly
: Boolean = False;
586 gAimLine
: Boolean = False;
587 gChatBubble
: Integer = 0;
588 gPlayerIndicator
: Integer = 1;
589 gPlayerIndicatorStyle
: Integer = 0;
591 gSpectLatchPID1
: Word = 0;
592 gSpectLatchPID2
: Word = 0;
593 MAX_RUNVEL
: Integer = 8;
594 VEL_JUMP
: Integer = 10;
595 SHELL_TIMEOUT
: Cardinal = 60000;
597 function Lerp(X
, Y
, Factor
: Integer): Integer;
599 procedure g_Gibs_SetMax(Count
: Word);
600 function g_Gibs_GetMax(): Word;
601 procedure g_Corpses_SetMax(Count
: Word);
602 function g_Corpses_GetMax(): Word;
603 procedure g_Shells_SetMax(Count
: Word);
604 function g_Shells_GetMax(): Word;
606 procedure g_Player_Init();
607 procedure g_Player_Free();
608 function g_Player_Create(ModelName
: String; Color
: TRGB
; Team
: Byte; Bot
: Boolean): Word;
609 function g_Player_CreateFromState (st
: TStream
): Word;
610 procedure g_Player_Remove(UID
: Word);
611 procedure g_Player_ResetTeams();
612 procedure g_Player_PreUpdate();
613 procedure g_Player_UpdateAll();
614 procedure g_Player_DrawAll();
615 procedure g_Player_DrawDebug(p
: TPlayer
);
616 procedure g_Player_DrawHealth();
617 procedure g_Player_RememberAll();
618 procedure g_Player_ResetAll(Force
, Silent
: Boolean);
619 function g_Player_Get(UID
: Word): TPlayer
;
620 function g_Player_GetCount(): Byte;
621 function g_Player_GetStats(): TPlayerStatArray
;
622 function g_Player_ValidName(Name
: String): Boolean;
623 function g_Player_CreateCorpse(Player
: TPlayer
): Integer;
624 procedure g_Player_CreateGibs(fX
, fY
: Integer; ModelName
: String; fColor
: TRGB
);
625 procedure g_Player_CreateShell(fX
, fY
, dX
, dY
: Integer; T
: Byte);
626 procedure g_Player_UpdatePhysicalObjects();
627 procedure g_Player_DrawCorpses();
628 procedure g_Player_DrawShells();
629 procedure g_Player_RemoveAllCorpses();
630 procedure g_Player_Corpses_SaveState (st
: TStream
);
631 procedure g_Player_Corpses_LoadState (st
: TStream
);
632 procedure g_Player_ResetReady();
633 procedure g_Bot_Add(Team
, Difficult
: Byte; Handicap
: Integer = 100);
634 procedure g_Bot_AddList(Team
: Byte; lname
: ShortString; num
: Integer = -1; Handicap
: Integer = 100);
635 procedure g_Bot_MixNames();
636 procedure g_Bot_RemoveAll();
637 function g_Bot_GetCount(): Integer;
642 {$INCLUDE ../nogl/noGLuses.inc}
643 {$IFDEF ENABLE_HOLMES}
646 e_log
, g_map
, g_items
, g_console
, g_gfx
, Math
,
647 g_options
, g_triggers
, g_menu
, g_game
, g_grid
, e_res
,
648 wadreader
, g_main
, g_monsters
, CONFIG
, g_language
,
649 g_net
, g_netmsg
, g_window
,
652 const PLR_SAVE_VERSION
= 0;
662 diag_precision
: Byte;
666 w_prior1
: Array [WP_FIRST
..WP_LAST
] of Byte;
667 w_prior2
: Array [WP_FIRST
..WP_LAST
] of Byte;
668 w_prior3
: Array [WP_FIRST
..WP_LAST
] of Byte;
672 TIME_RESPAWN1
= 1500;
673 TIME_RESPAWN2
= 2000;
674 TIME_RESPAWN3
= 3000;
677 JET_MAX
= 540; // ~30 sec
678 PLAYER_SUIT_TIME
= 30000;
679 PLAYER_INVUL_TIME
= 30000;
680 PLAYER_INVIS_TIME
= 35000;
681 FRAG_COMBO_TIME
= 3000;
685 ANGLE_RIGHTDOWN
= -35;
687 ANGLE_LEFTDOWN
= -145;
688 PLAYER_HEADRECT
: TRectWH
= (X
:24; Y
:12; Width
:20; Height
:12);
689 WEAPONPOINT
: Array [TDirection
] of TDFPoint
= ((X
:16; Y
:32), (X
:47; Y
:32));
692 BOT_UNSAFEDIST
= 128;
693 TEAMCOLOR
: Array [TEAM_RED
..TEAM_BLUE
] of TRGB
= ((R
:255; G
:0; B
:0),
695 DIFFICULT_EASY
: TDifficult
= (DiagFire
: 32; InvisFire
: 32; DiagPrecision
: 32;
696 FlyPrecision
: 32; Cover
: 32; CloseJump
: 32;
697 WeaponPrior
:(0,0,0,0,0,0,0,0,0,0,0); CloseWeaponPrior
:(0,0,0,0,0,0,0,0,0,0,0));
698 DIFFICULT_MEDIUM
: TDifficult
= (DiagFire
: 127; InvisFire
: 127; DiagPrecision
: 127;
699 FlyPrecision
: 127; Cover
: 127; CloseJump
: 127;
700 WeaponPrior
:(0,0,0,0,0,0,0,0,0,0,0); CloseWeaponPrior
:(0,0,0,0,0,0,0,0,0,0,0));
701 DIFFICULT_HARD
: TDifficult
= (DiagFire
: 255; InvisFire
: 255; DiagPrecision
: 255;
702 FlyPrecision
: 255; Cover
: 255; CloseJump
: 255;
703 WeaponPrior
:(0,0,0,0,0,0,0,0,0,0,0); CloseWeaponPrior
:(0,0,0,0,0,0,0,0,0,0,0));
704 WEAPON_PRIOR1
: Array [WP_FIRST
..WP_LAST
] of Byte =
705 (WEAPON_FLAMETHROWER
, WEAPON_SUPERPULEMET
,
706 WEAPON_SHOTGUN2
, WEAPON_SHOTGUN1
,
707 WEAPON_CHAINGUN
, WEAPON_PLASMA
, WEAPON_ROCKETLAUNCHER
,
708 WEAPON_BFG
, WEAPON_PISTOL
, WEAPON_SAW
, WEAPON_KASTET
);
709 WEAPON_PRIOR2
: Array [WP_FIRST
..WP_LAST
] of Byte =
710 (WEAPON_FLAMETHROWER
, WEAPON_SUPERPULEMET
,
711 WEAPON_BFG
, WEAPON_ROCKETLAUNCHER
,
712 WEAPON_SHOTGUN2
, WEAPON_PLASMA
, WEAPON_SHOTGUN1
,
713 WEAPON_CHAINGUN
, WEAPON_PISTOL
, WEAPON_SAW
, WEAPON_KASTET
);
714 //WEAPON_PRIOR3: Array [WP_FIRST..WP_LAST] of Byte =
715 // (WEAPON_FLAMETHROWER, WEAPON_SUPERPULEMET,
716 // WEAPON_BFG, WEAPON_PLASMA, WEAPON_SHOTGUN2,
717 // WEAPON_CHAINGUN, WEAPON_SHOTGUN1, WEAPON_SAW,
718 // WEAPON_ROCKETLAUNCHER, WEAPON_PISTOL, WEAPON_KASTET);
719 WEAPON_RELOAD
: Array [WP_FIRST
..WP_LAST
] of Byte =
720 (5, 2, 6, 18, 36, 2, 12, 2, 14, 2, 2);
722 PLAYER_SIGNATURE
= $52594C50; // 'PLYR'
723 CORPSE_SIGNATURE
= $50524F43; // 'CORP'
725 BOTNAMES_FILENAME
= 'botnames.txt';
726 BOTLIST_FILENAME
= 'botlist.txt';
730 MaxCorpses
: Word = 20;
731 MaxShells
: Word = 300;
732 CurrentGib
: Integer = 0;
733 CurrentShell
: Integer = 0;
734 BotNames
: Array of String;
735 BotList
: Array of TBotProfile
;
736 SavedStates
: Array of TPlayerSavedState
;
739 function Lerp(X
, Y
, Factor
: Integer): Integer;
741 Result
:= X
+ ((Y
- X
) div Factor
);
744 function SameTeam(UID1
, UID2
: Word): Boolean;
748 if (UID1
> UID_MAX_PLAYER
) or (UID1
<= UID_MAX_GAME
) or
749 (UID2
> UID_MAX_PLAYER
) or (UID2
<= UID_MAX_GAME
) then Exit
;
751 if (g_Player_Get(UID1
) = nil) or (g_Player_Get(UID2
) = nil) then Exit
;
753 if ((g_Player_Get(UID1
).Team
= TEAM_NONE
) or
754 (g_Player_Get(UID2
).Team
= TEAM_NONE
)) then Exit
;
756 Result
:= g_Player_Get(UID1
).FTeam
= g_Player_Get(UID2
).FTeam
;
759 procedure g_Gibs_SetMax(Count
: Word);
762 SetLength(gGibs
, Count
);
764 if CurrentGib
>= Count
then
768 function g_Gibs_GetMax(): Word;
773 procedure g_Shells_SetMax(Count
: Word);
776 SetLength(gShells
, Count
);
778 if CurrentShell
>= Count
then
782 function g_Shells_GetMax(): Word;
788 procedure g_Corpses_SetMax(Count
: Word);
791 SetLength(gCorpses
, Count
);
794 function g_Corpses_GetMax(): Word;
796 Result
:= MaxCorpses
;
799 function g_Player_Create(ModelName
: String; Color
: TRGB
; Team
: Byte; Bot
: Boolean): Word;
809 // Åñòü ëè ìåñòî â gPlayers:
810 if gPlayers
<> nil then
811 for a
:= 0 to High(gPlayers
) do
812 if gPlayers
[a
] = nil then
818 // Íåò ìåñòà - ðàñøèðÿåì gPlayers:
821 SetLength(gPlayers
, Length(gPlayers
)+1);
825 // Ñîçäàåì îáúåêò èãðîêà:
827 gPlayers
[a
] := TBot
.Create()
829 gPlayers
[a
] := TPlayer
.Create();
832 gPlayers
[a
].FActualModelName
:= ModelName
;
833 gPlayers
[a
].SetModel(ModelName
);
835 // Íåò ìîäåëè - ñîçäàíèå íå âîçìîæíî:
836 if gPlayers
[a
].FModel
= nil then
840 g_FatalError(Format(_lc
[I_GAME_ERROR_MODEL
], [ModelName
]));
844 if not (Team
in [TEAM_RED
, TEAM_BLUE
]) then
845 if Random(2) = 0 then
849 gPlayers
[a
].FPreferredTeam
:= Team
;
851 case gGameSettings
.GameMode
of
852 GM_DM
: gPlayers
[a
].FTeam
:= TEAM_NONE
;
854 GM_CTF
: gPlayers
[a
].FTeam
:= gPlayers
[a
].FPreferredTeam
;
856 GM_COOP
: gPlayers
[a
].FTeam
:= TEAM_COOP
;
859 // Åñëè êîìàíäíàÿ èãðà - êðàñèì ìîäåëü â öâåò êîìàíäû:
860 gPlayers
[a
].FColor
:= Color
;
861 if gPlayers
[a
].FTeam
in [TEAM_RED
, TEAM_BLUE
] then
862 gPlayers
[a
].FModel
.Color
:= TEAMCOLOR
[gPlayers
[a
].FTeam
]
864 gPlayers
[a
].FModel
.Color
:= Color
;
866 gPlayers
[a
].FUID
:= g_CreateUID(UID_PLAYER
);
867 gPlayers
[a
].FAlive
:= False;
869 Result
:= gPlayers
[a
].FUID
;
872 function g_Player_CreateFromState (st
: TStream
): Word;
873 var a
: Integer; ok
, Bot
: Boolean; pos
: Int64;
877 // check signature and entity type
879 if not utils
.checkSign(st
, 'PLYR') then raise XStreamError
.Create('invalid player signature');
880 if (utils
.readByte(st
) <> PLR_SAVE_VERSION
) then raise XStreamError
.Create('invalid player version');
881 Bot
:= utils
.readBool(st
);
884 // find free player slot
886 for a
:= 0 to High(gPlayers
) do
887 if gPlayers
[a
] = nil then
893 // allocate player slot
896 SetLength(gPlayers
, Length(gPlayers
)+1);
900 // create entity and load state
902 gPlayers
[a
] := TBot
.Create()
904 gPlayers
[a
] := TPlayer
.Create();
905 gPlayers
[a
].FPhysics
:= True; // ???
906 gPlayers
[a
].LoadState(st
);
908 result
:= gPlayers
[a
].FUID
;
912 procedure g_Player_ResetTeams();
916 if g_Game_IsClient
then
918 if gPlayers
= nil then
920 for a
:= Low(gPlayers
) to High(gPlayers
) do
921 if gPlayers
[a
] <> nil then
922 case gGameSettings
.GameMode
of
924 gPlayers
[a
].ChangeTeam(TEAM_NONE
);
926 if not (gPlayers
[a
].Team
in [TEAM_RED
, TEAM_BLUE
]) then
927 if gPlayers
[a
].FPreferredTeam
in [TEAM_RED
, TEAM_BLUE
] then
928 gPlayers
[a
].ChangeTeam(gPlayers
[a
].FPreferredTeam
)
931 gPlayers
[a
].ChangeTeam(TEAM_RED
)
933 gPlayers
[a
].ChangeTeam(TEAM_BLUE
);
936 gPlayers
[a
].ChangeTeam(TEAM_COOP
);
940 procedure g_Bot_Add(Team
, Difficult
: Byte; Handicap
: Integer = 100);
943 _name
, _model
: String;
946 if not g_Game_IsServer
then Exit
;
948 // Íå äîáàâëÿåì áîòîâ åñëè ëèìèò óæå äîñòèãíóò
949 if (g_Bot_GetCount() >= gMaxBots
) then Exit
;
951 // Ñïèñîê íàçâàíèé ìîäåëåé:
952 m
:= g_PlayerModel_GetNames();
957 if (gGameSettings
.GameType
= GT_SINGLE
) or (gGameSettings
.GameMode
= GM_COOP
) then
958 Team
:= TEAM_COOP
// COOP
960 if gGameSettings
.GameMode
= GM_DM
then
961 Team
:= TEAM_NONE
// DM
963 if Team
= TEAM_NONE
then // CTF / TDM
965 // Àâòîáàëàíñ êîìàíä:
969 for a
:= 0 to High(gPlayers
) do
970 if gPlayers
[a
] <> nil then
972 if gPlayers
[a
].Team
= TEAM_RED
then
975 if gPlayers
[a
].Team
= TEAM_BLUE
then
985 if Random(2) = 0 then
991 // Âûáèðàåì áîòó èìÿ:
993 if BotNames
<> nil then
994 for a
:= 0 to High(BotNames
) do
995 if g_Player_ValidName(BotNames
[a
]) then
997 _name
:= BotNames
[a
];
1001 // Âûáèðàåì ñëó÷àéíóþ ìîäåëü:
1002 _model
:= m
[Random(Length(m
))];
1005 with g_Player_Get(g_Player_Create(_model
,
1006 _RGB(Min(Random(9)*32, 255),
1007 Min(Random(9)*32, 255),
1008 Min(Random(9)*32, 255)),
1009 Team
, True)) as TBot
do
1011 // Åñëè èìåíè íåò, äåëàåì åãî èç UID áîòà
1013 Name
:= Format('DFBOT%.5d', [UID
])
1018 1: FDifficult
:= DIFFICULT_EASY
;
1019 2: FDifficult
:= DIFFICULT_MEDIUM
;
1020 else FDifficult
:= DIFFICULT_HARD
;
1023 for a
:= WP_FIRST
to WP_LAST
do
1025 FDifficult
.WeaponPrior
[a
] := WEAPON_PRIOR1
[a
];
1026 FDifficult
.CloseWeaponPrior
[a
] := WEAPON_PRIOR2
[a
];
1027 //FDifficult.SafeWeaponPrior[a] := WEAPON_PRIOR3[a];
1030 FHandicap
:= Handicap
;
1032 g_Console_Add(Format(_lc
[I_PLAYER_JOIN
], [Name
]), True);
1034 if g_Game_IsNet
then MH_SEND_PlayerCreate(UID
);
1035 if g_Game_IsServer
and (gGameSettings
.MaxLives
> 0) then
1040 procedure g_Bot_AddList(Team
: Byte; lName
: ShortString; num
: Integer = -1; Handicap
: Integer = 100);
1043 _name
, _model
: String;
1046 if not g_Game_IsServer
then Exit
;
1048 // Íå äîáàâëÿåì áîòîâ åñëè ëèìèò óæå äîñòèãíóò
1049 if (g_Bot_GetCount() >= gMaxBots
) then Exit
;
1051 // Ñïèñîê íàçâàíèé ìîäåëåé:
1052 m
:= g_PlayerModel_GetNames();
1057 if (gGameSettings
.GameType
= GT_SINGLE
) or (gGameSettings
.GameMode
= GM_COOP
) then
1058 Team
:= TEAM_COOP
// COOP
1060 if gGameSettings
.GameMode
= GM_DM
then
1061 Team
:= TEAM_NONE
// DM
1063 if Team
= TEAM_NONE
then
1064 Team
:= BotList
[num
].team
; // CTF / TDM
1066 // Âûáèðàåì íàñòðîéêè áîòà èç ñïèñêà ïî íîìåðó èëè èìåíè:
1067 lName
:= AnsiLowerCase(lName
);
1068 if (num
< 0) or (num
> Length(BotList
)-1) then
1070 if (num
= -1) and (lName
<> '') and (BotList
<> nil) then
1071 for a
:= 0 to High(BotList
) do
1072 if AnsiLowerCase(BotList
[a
].name
) = lName
then
1081 _name
:= BotList
[num
].name
;
1082 // Çàíÿòî - âûáèðàåì ñëó÷àéíîå:
1083 if not g_Player_ValidName(_name
) then
1085 _name
:= Format('DFBOT%.2d', [Random(100)]);
1086 until g_Player_ValidName(_name
);
1089 _model
:= BotList
[num
].model
;
1090 // Íåò òàêîé - âûáèðàåì ñëó÷àéíóþ:
1091 if not InSArray(_model
, m
) then
1092 _model
:= m
[Random(Length(m
))];
1095 with g_Player_Get(g_Player_Create(_model
, BotList
[num
].color
, Team
, True)) as TBot
do
1099 FDifficult
.DiagFire
:= BotList
[num
].diag_fire
;
1100 FDifficult
.InvisFire
:= BotList
[num
].invis_fire
;
1101 FDifficult
.DiagPrecision
:= BotList
[num
].diag_precision
;
1102 FDifficult
.FlyPrecision
:= BotList
[num
].fly_precision
;
1103 FDifficult
.Cover
:= BotList
[num
].cover
;
1104 FDifficult
.CloseJump
:= BotList
[num
].close_jump
;
1106 FHandicap
:= Handicap
;
1108 for a
:= WP_FIRST
to WP_LAST
do
1110 FDifficult
.WeaponPrior
[a
] := BotList
[num
].w_prior1
[a
];
1111 FDifficult
.CloseWeaponPrior
[a
] := BotList
[num
].w_prior2
[a
];
1112 //FDifficult.SafeWeaponPrior[a] := BotList[num].w_prior3[a];
1115 g_Console_Add(Format(_lc
[I_PLAYER_JOIN
], [Name
]), True);
1117 if g_Game_IsNet
then MH_SEND_PlayerCreate(UID
);
1121 procedure g_Bot_RemoveAll();
1125 if not g_Game_IsServer
then Exit
;
1126 if gPlayers
= nil then Exit
;
1128 for a
:= 0 to High(gPlayers
) do
1129 if gPlayers
[a
] <> nil then
1130 if gPlayers
[a
] is TBot
then
1132 gPlayers
[a
].Lives
:= 0;
1133 gPlayers
[a
].Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
1134 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [gPlayers
[a
].Name
]), True);
1135 g_Player_Remove(gPlayers
[a
].FUID
);
1141 procedure g_Bot_MixNames();
1146 if BotNames
<> nil then
1147 for a
:= 0 to High(BotNames
) do
1149 b
:= Random(Length(BotNames
));
1151 Botnames
[a
] := BotNames
[b
];
1156 procedure g_Player_Remove(UID
: Word);
1160 if gPlayers
= nil then Exit
;
1162 if g_Game_IsServer
and g_Game_IsNet
then
1163 MH_SEND_PlayerDelete(UID
);
1165 for i
:= 0 to High(gPlayers
) do
1166 if gPlayers
[i
] <> nil then
1167 if gPlayers
[i
].FUID
= UID
then
1169 if gPlayers
[i
] is TPlayer
then
1170 TPlayer(gPlayers
[i
]).Free()
1172 TBot(gPlayers
[i
]).Free();
1178 procedure g_Player_Init();
1189 path
:= BOTNAMES_FILENAME
;
1190 if e_FindResource(DataDirs
, path
) = false then
1193 // ×èòàåì âîçìîæíûå èìåíà áîòîâ èç ôàéëà:
1194 AssignFile(F
, path
);
1205 SetLength(BotNames
, Length(BotNames
)+1);
1206 BotNames
[High(BotNames
)] := s
;
1214 // ×èòàåì ôàéë ñ ïàðàìåòðàìè áîòîâ:
1215 config
:= TConfig
.CreateFile(path
);
1219 while config
.SectionExists(IntToStr(a
)) do
1221 SetLength(BotList
, Length(BotList
)+1);
1223 with BotList
[High(BotList
)] do
1226 name
:= config
.ReadStr(IntToStr(a
), 'name', '');
1228 model
:= config
.ReadStr(IntToStr(a
), 'model', '');
1230 if config
.ReadStr(IntToStr(a
), 'team', 'red') = 'red' then
1235 sa
:= parse(config
.ReadStr(IntToStr(a
), 'color', ''));
1236 color
.R
:= StrToIntDef(sa
[0], 0);
1237 color
.G
:= StrToIntDef(sa
[1], 0);
1238 color
.B
:= StrToIntDef(sa
[2], 0);
1239 // Âåðîÿòíîñòü ñòðåëüáû ïîä óãëîì:
1240 diag_fire
:= config
.ReadInt(IntToStr(a
), 'diag_fire', 0);
1241 // Âåðîÿòíîñòü îòâåòíîãî îãíÿ ïî íåâèäèìîìó ñîïåðíèêó:
1242 invis_fire
:= config
.ReadInt(IntToStr(a
), 'invis_fire', 0);
1243 // Òî÷íîñòü ñòðåëüáû ïîä óãëîì:
1244 diag_precision
:= config
.ReadInt(IntToStr(a
), 'diag_precision', 0);
1245 // Òî÷íîñòü ñòðåëüáû â ïîëåòå:
1246 fly_precision
:= config
.ReadInt(IntToStr(a
), 'fly_precision', 0);
1247 // Òî÷íîñòü óêëîíåíèÿ îò ñíàðÿäîâ:
1248 cover
:= config
.ReadInt(IntToStr(a
), 'cover', 0);
1249 // Âåðîÿòíîñòü ïðûæêà ïðè ïðèáëèæåíèè ñîïåðíèêà:
1250 close_jump
:= config
.ReadInt(IntToStr(a
), 'close_jump', 0);
1251 // Ïðèîðèòåòû îðóæèÿ äëÿ äàëüíåãî áîÿ:
1252 sa
:= parse(config
.ReadStr(IntToStr(a
), 'w_prior1', ''));
1253 if Length(sa
) = 10 then
1255 w_prior1
[b
] := EnsureRange(StrToInt(sa
[b
]), 0, 9);
1256 // Ïðèîðèòåòû îðóæèÿ äëÿ áëèæíåãî áîÿ:
1257 sa
:= parse(config
.ReadStr(IntToStr(a
), 'w_prior2', ''));
1258 if Length(sa
) = 10 then
1260 w_prior2
[b
] := EnsureRange(StrToInt(sa
[b
]), 0, 9);
1262 {sa := parse(config.ReadStr(IntToStr(a), 'w_prior3', ''));
1263 if Length(sa) = 10 then
1265 w_prior3[b] := EnsureRange(StrToInt(sa[b]), 0, 9);}
1272 SetLength(SavedStates
, 0);
1275 procedure g_Player_Free();
1279 if gPlayers
<> nil then
1281 for i
:= 0 to High(gPlayers
) do
1282 if gPlayers
[i
] <> nil then
1284 if gPlayers
[i
] is TPlayer
then
1285 TPlayer(gPlayers
[i
]).Free()
1287 TBot(gPlayers
[i
]).Free();
1296 SetLength(SavedStates
, 0);
1299 procedure g_Player_PreUpdate();
1303 if gPlayers
= nil then Exit
;
1304 for i
:= 0 to High(gPlayers
) do
1305 if gPlayers
[i
] <> nil then
1306 gPlayers
[i
].PreUpdate();
1309 procedure g_Player_UpdateAll();
1313 if gPlayers
= nil then Exit
;
1315 //e_WriteLog('***g_Player_UpdateAll: ENTER', MSG_WARNING);
1316 for i
:= 0 to High(gPlayers
) do
1318 if gPlayers
[i
] <> nil then
1320 if gPlayers
[i
] is TPlayer
then
1322 gPlayers
[i
].Update();
1323 gPlayers
[i
].RealizeCurrentWeapon(); // WARNING! DO NOT MOVE THIS INTO `Update()`!
1327 // bot updates weapons in `UpdateCombat()`
1328 TBot(gPlayers
[i
]).Update();
1332 //e_WriteLog('***g_Player_UpdateAll: EXIT', MSG_WARNING);
1335 procedure g_Player_DrawAll();
1339 if gPlayers
= nil then Exit
;
1341 for i
:= 0 to High(gPlayers
) do
1342 if gPlayers
[i
] <> nil then
1343 if gPlayers
[i
] is TPlayer
then gPlayers
[i
].Draw()
1344 else TBot(gPlayers
[i
]).Draw();
1347 procedure g_Player_DrawDebug(p
: TPlayer
);
1351 if p
= nil then Exit
;
1352 if (@p
.FObj
) = nil then Exit
;
1354 e_TextureFontGetSize(gStdFont
, fW
, fH
);
1356 e_TextureFontPrint(0, 0 , 'Pos X: ' + IntToStr(p
.FObj
.X
), gStdFont
);
1357 e_TextureFontPrint(0, fH
, 'Pos Y: ' + IntToStr(p
.FObj
.Y
), gStdFont
);
1358 e_TextureFontPrint(0, fH
* 2, 'Vel X: ' + IntToStr(p
.FObj
.Vel
.X
), gStdFont
);
1359 e_TextureFontPrint(0, fH
* 3, 'Vel Y: ' + IntToStr(p
.FObj
.Vel
.Y
), gStdFont
);
1360 e_TextureFontPrint(0, fH
* 4, 'Acc X: ' + IntToStr(p
.FObj
.Accel
.X
), gStdFont
);
1361 e_TextureFontPrint(0, fH
* 5, 'Acc Y: ' + IntToStr(p
.FObj
.Accel
.Y
), gStdFont
);
1362 e_TextureFontPrint(0, fH
* 6, 'Old X: ' + IntToStr(p
.FObj
.oldX
), gStdFont
);
1363 e_TextureFontPrint(0, fH
* 7, 'Old Y: ' + IntToStr(p
.FObj
.oldY
), gStdFont
);
1366 procedure g_Player_DrawHealth();
1371 if gPlayers
= nil then Exit
;
1372 e_TextureFontGetSize(gStdFont
, fW
, fH
);
1374 for i
:= 0 to High(gPlayers
) do
1375 if gPlayers
[i
] <> nil then
1377 e_TextureFontPrint(gPlayers
[i
].FObj
.X
+ gPlayers
[i
].FObj
.Rect
.X
,
1378 gPlayers
[i
].FObj
.Y
+ gPlayers
[i
].FObj
.Rect
.Y
+ gPlayers
[i
].FObj
.Rect
.Height
- fH
* 2,
1379 IntToStr(gPlayers
[i
].FHealth
), gStdFont
);
1380 e_TextureFontPrint(gPlayers
[i
].FObj
.X
+ gPlayers
[i
].FObj
.Rect
.X
,
1381 gPlayers
[i
].FObj
.Y
+ gPlayers
[i
].FObj
.Rect
.Y
+ gPlayers
[i
].FObj
.Rect
.Height
- fH
,
1382 IntToStr(gPlayers
[i
].FArmor
), gStdFont
);
1386 function g_Player_Get(UID
: Word): TPlayer
;
1392 if gPlayers
= nil then
1395 for a
:= 0 to High(gPlayers
) do
1396 if gPlayers
[a
] <> nil then
1397 if gPlayers
[a
].FUID
= UID
then
1399 Result
:= gPlayers
[a
];
1404 function g_Player_GetCount(): Byte;
1410 if gPlayers
= nil then
1413 for a
:= 0 to High(gPlayers
) do
1414 if gPlayers
[a
] <> nil then
1415 Result
:= Result
+ 1;
1418 function g_Bot_GetCount(): Integer;
1424 if gPlayers
= nil then
1427 for a
:= 0 to High(gPlayers
) do
1428 if (gPlayers
[a
] <> nil) and (gPlayers
[a
] is TBot
) then
1429 Result
:= Result
+ 1;
1432 function g_Player_GetStats(): TPlayerStatArray
;
1438 if gPlayers
= nil then Exit
;
1440 for a
:= 0 to High(gPlayers
) do
1441 if gPlayers
[a
] <> nil then
1443 SetLength(Result
, Length(Result
)+1);
1444 with Result
[High(Result
)] do
1447 Ping
:= gPlayers
[a
].FPing
;
1448 Loss
:= gPlayers
[a
].FLoss
;
1449 Name
:= gPlayers
[a
].FName
;
1450 Team
:= gPlayers
[a
].FTeam
;
1451 Frags
:= gPlayers
[a
].FFrags
;
1452 Deaths
:= gPlayers
[a
].FDeath
;
1453 Kills
:= gPlayers
[a
].FKills
;
1454 Color
:= gPlayers
[a
].FModel
.Color
;
1455 Lives
:= gPlayers
[a
].FLives
;
1456 Spectator
:= gPlayers
[a
].FSpectator
;
1457 UID
:= gPlayers
[a
].FUID
;
1462 procedure g_Player_ResetReady();
1466 if not g_Game_IsServer
then Exit
;
1467 if gPlayers
= nil then Exit
;
1469 for a
:= 0 to High(gPlayers
) do
1470 if gPlayers
[a
] <> nil then
1472 gPlayers
[a
].FReady
:= False;
1473 if g_Game_IsNet
then
1474 MH_SEND_GameEvent(NET_EV_INTER_READY
, gPlayers
[a
].UID
, 'N');
1478 procedure g_Player_RememberAll
;
1482 for i
:= Low(gPlayers
) to High(gPlayers
) do
1483 if (gPlayers
[i
] <> nil) and gPlayers
[i
].alive
then
1484 gPlayers
[i
].RememberState
;
1487 procedure g_Player_ResetAll(Force
, Silent
: Boolean);
1491 gTeamStat
[TEAM_RED
].Goals
:= 0;
1492 gTeamStat
[TEAM_BLUE
].Goals
:= 0;
1494 if gPlayers
<> nil then
1495 for i
:= 0 to High(gPlayers
) do
1496 if gPlayers
[i
] <> nil then
1498 gPlayers
[i
].Reset(Force
);
1500 if gPlayers
[i
] is TPlayer
then
1502 if (not gPlayers
[i
].FSpectator
) or gPlayers
[i
].FWantsInGame
then
1503 gPlayers
[i
].Respawn(Silent
)
1505 gPlayers
[i
].Spectate();
1508 TBot(gPlayers
[i
]).Respawn(Silent
);
1512 function g_Player_CreateCorpse(Player
: TPlayer
): Integer;
1520 if Player
.alive
then
1523 // Ðàçðûâàåì ñâÿçü ñ ïðåæíèì òðóïîì:
1524 i
:= Player
.FCorpse
;
1525 if (i
>= 0) and (i
< Length(gCorpses
)) then
1527 if (gCorpses
[i
] <> nil) and (gCorpses
[i
].FPlayerUID
= Player
.FUID
) then
1528 gCorpses
[i
].FPlayerUID
:= 0;
1531 if Player
.FObj
.Y
>= gMapInfo
.Height
+128 then
1536 if (FHealth
>= -50) or (gGibsCount
= 0) then
1538 if (gCorpses
= nil) or (Length(gCorpses
) = 0) then
1542 for find_id
:= 0 to High(gCorpses
) do
1543 if gCorpses
[find_id
] = nil then
1550 find_id
:= Random(Length(gCorpses
));
1552 gCorpses
[find_id
] := TCorpse
.Create(FObj
.X
, FObj
.Y
, FModel
.Name
, FHealth
< -20);
1553 gCorpses
[find_id
].FColor
:= FModel
.Color
;
1554 gCorpses
[find_id
].FObj
.Vel
:= FObj
.Vel
;
1555 gCorpses
[find_id
].FObj
.Accel
:= FObj
.Accel
;
1556 gCorpses
[find_id
].FPlayerUID
:= FUID
;
1561 g_Player_CreateGibs(FObj
.X
+ PLAYER_RECT_CX
,
1562 FObj
.Y
+ PLAYER_RECT_CY
,
1563 FModel
.Name
, FModel
.Color
);
1567 procedure g_Player_CreateShell(fX
, fY
, dX
, dY
: Integer; T
: Byte);
1571 if (gShells
= nil) or (Length(gShells
) = 0) then
1574 with gShells
[CurrentShell
] do
1580 if T
= SHELL_BULLET
then
1582 if g_Texture_Get('TEXTURE_SHELL_BULLET', SID
) then
1586 Obj
.Rect
.Width
:= 4;
1587 Obj
.Rect
.Height
:= 2;
1591 if g_Texture_Get('TEXTURE_SHELL_SHELL', SID
) then
1595 Obj
.Rect
.Width
:= 7;
1596 Obj
.Rect
.Height
:= 3;
1602 g_Obj_Push(@Obj
, dX
+ Random(4)-Random(4), dY
-Random(4));
1603 positionChanged(); // this updates spatial accelerators
1604 RAngle
:= Random(360);
1605 Timeout
:= gTime
+ SHELL_TIMEOUT
;
1607 if CurrentShell
>= High(gShells
) then
1614 procedure g_Player_CreateGibs(fX
, fY
: Integer; ModelName
: string; fColor
: TRGB
);
1617 GibsArray
: TGibsArray
;
1620 if (gGibs
= nil) or (Length(gGibs
) = 0) then
1622 if not g_PlayerModel_GetGibs(ModelName
, GibsArray
) then
1624 Blood
:= g_PlayerModel_GetBlood(ModelName
);
1626 for a
:= 0 to High(GibsArray
) do
1627 with gGibs
[CurrentGib
] do
1630 ID
:= GibsArray
[a
].ID
;
1631 MaskID
:= GibsArray
[a
].MaskID
;
1634 Obj
.Rect
:= GibsArray
[a
].Rect
;
1635 Obj
.X
:= fX
-GibsArray
[a
].Rect
.X
-(GibsArray
[a
].Rect
.Width
div 2);
1636 Obj
.Y
:= fY
-GibsArray
[a
].Rect
.Y
-(GibsArray
[a
].Rect
.Height
div 2);
1637 g_Obj_PushA(@Obj
, 25 + Random(10), Random(361));
1638 positionChanged(); // this updates spatial accelerators
1639 RAngle
:= Random(360);
1641 if gBloodCount
> 0 then
1642 g_GFX_Blood(fX
, fY
, 16*gBloodCount
+Random(5*gBloodCount
), -16+Random(33), -16+Random(33),
1643 Random(48), Random(48), Blood
.R
, Blood
.G
, Blood
.B
, Blood
.Kind
);
1645 if CurrentGib
>= High(gGibs
) then
1652 procedure g_Player_UpdatePhysicalObjects();
1658 procedure ShellSound_Bounce(X
, Y
: Integer; T
: Byte);
1663 if T
= SHELL_BULLET
then
1664 g_Sound_PlayExAt('SOUND_PLAYER_CASING' + IntToStr(k
), X
, Y
)
1666 g_Sound_PlayExAt('SOUND_PLAYER_SHELL' + IntToStr(k
), X
, Y
);
1671 if gGibs
<> nil then
1672 for i
:= 0 to High(gGibs
) do
1673 if gGibs
[i
].alive
then
1680 mr
:= g_Obj_Move(@Obj
, True, False, True);
1681 positionChanged(); // this updates spatial accelerators
1683 if WordBool(mr
and MOVE_FALLOUT
) then
1689 // Îòëåòàåò îò óäàðà î ñòåíó/ïîòîëîê/ïîë:
1690 if WordBool(mr
and MOVE_HITWALL
) then
1691 Obj
.Vel
.X
:= -(vel
.X
div 2);
1692 if WordBool(mr
and (MOVE_HITCEIL
or MOVE_HITLAND
)) then
1693 Obj
.Vel
.Y
:= -(vel
.Y
div 2);
1695 if (Obj
.Vel
.X
>= 0) then
1697 RAngle
:= RAngle
+ Abs(Obj
.Vel
.X
)*6 + Abs(Obj
.Vel
.Y
);
1698 if RAngle
>= 360 then
1699 RAngle
:= RAngle
mod 360;
1700 end else begin // Counter-clockwise
1701 RAngle
:= RAngle
- Abs(Obj
.Vel
.X
)*6 - Abs(Obj
.Vel
.Y
);
1703 RAngle
:= (360 - (Abs(RAngle
) mod 360)) mod 360;
1706 // Ñîïðîòèâëåíèå âîçäóõà äëÿ êóñêà òðóïà:
1707 if gTime
mod (GAME_TICK
*3) = 0 then
1708 Obj
.Vel
.X
:= z_dec(Obj
.Vel
.X
, 1);
1712 if gCorpses
<> nil then
1713 for i
:= 0 to High(gCorpses
) do
1714 if gCorpses
[i
] <> nil then
1715 if gCorpses
[i
].State
= CORPSE_STATE_REMOVEME
then
1721 gCorpses
[i
].Update();
1724 if gShells
<> nil then
1725 for i
:= 0 to High(gShells
) do
1726 if gShells
[i
].alive
then
1733 mr
:= g_Obj_Move(@Obj
, True, False, True);
1734 positionChanged(); // this updates spatial accelerators
1736 if WordBool(mr
and MOVE_FALLOUT
) or (gShells
[i
].Timeout
< gTime
) then
1742 // Îòëåòàåò îò óäàðà î ñòåíó/ïîòîëîê/ïîë:
1743 if WordBool(mr
and MOVE_HITWALL
) then
1745 Obj
.Vel
.X
:= -(vel
.X
div 2);
1746 if not WordBool(mr
and MOVE_INWATER
) then
1747 ShellSound_Bounce(Obj
.X
, Obj
.Y
, SType
);
1749 if WordBool(mr
and (MOVE_HITCEIL
or MOVE_HITLAND
)) then
1751 Obj
.Vel
.Y
:= -(vel
.Y
div 2);
1752 if Obj
.Vel
.X
<> 0 then Obj
.Vel
.X
:= Obj
.Vel
.X
div 2;
1753 if (Obj
.Vel
.X
= 0) and (Obj
.Vel
.Y
= 0) then
1755 if RAngle
mod 90 <> 0 then
1756 RAngle
:= (RAngle
div 90) * 90;
1758 else if not WordBool(mr
and MOVE_INWATER
) then
1759 ShellSound_Bounce(Obj
.X
, Obj
.Y
, SType
);
1762 if (Obj
.Vel
.X
>= 0) then
1764 RAngle
:= RAngle
+ Abs(Obj
.Vel
.X
)*8 + Abs(Obj
.Vel
.Y
);
1765 if RAngle
>= 360 then
1766 RAngle
:= RAngle
mod 360;
1767 end else begin // Counter-clockwise
1768 RAngle
:= RAngle
- Abs(Obj
.Vel
.X
)*8 - Abs(Obj
.Vel
.Y
);
1770 RAngle
:= (360 - (Abs(RAngle
) mod 360)) mod 360;
1776 procedure TGib
.getMapBox (out x
, y
, w
, h
: Integer); inline;
1778 x
:= Obj
.X
+Obj
.Rect
.X
;
1779 y
:= Obj
.Y
+Obj
.Rect
.Y
;
1780 w
:= Obj
.Rect
.Width
;
1781 h
:= Obj
.Rect
.Height
;
1784 procedure TGib
.moveBy (dx
, dy
: Integer); inline;
1786 if (dx
<> 0) or (dy
<> 0) then
1795 procedure TShell
.getMapBox (out x
, y
, w
, h
: Integer); inline;
1799 w
:= Obj
.Rect
.Width
;
1800 h
:= Obj
.Rect
.Height
;
1803 procedure TShell
.moveBy (dx
, dy
: Integer); inline;
1805 if (dx
<> 0) or (dy
<> 0) then
1814 procedure TGib
.positionChanged (); inline; begin end;
1815 procedure TShell
.positionChanged (); inline; begin end;
1818 procedure g_Player_DrawCorpses();
1823 if gGibs
<> nil then
1824 for i
:= 0 to High(gGibs
) do
1825 if gGibs
[i
].alive
then
1828 if not g_Obj_Collide(sX
, sY
, sWidth
, sHeight
, @Obj
) then
1831 Obj
.lerp(gLerpFactor
, fX
, fY
);
1833 a
.X
:= Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2);
1834 a
.y
:= Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2);
1836 e_DrawAdv(ID
, fX
, fY
, 0, True, False, RAngle
, @a
, TMirrorType
.None
);
1839 e_DrawAdv(MaskID
, fX
, fY
, 0, True, False, RAngle
, @a
, TMirrorType
.None
);
1845 if gCorpses
<> nil then
1846 for i
:= 0 to High(gCorpses
) do
1847 if gCorpses
[i
] <> nil then
1851 procedure g_Player_DrawShells();
1856 if gShells
<> nil then
1857 for i
:= 0 to High(gShells
) do
1858 if gShells
[i
].alive
then
1861 if not g_Obj_Collide(sX
, sY
, sWidth
, sHeight
, @Obj
) then
1864 Obj
.lerp(gLerpFactor
, fX
, fY
);
1869 e_DrawAdv(SpriteID
, fX
, fY
, 0, True, False, RAngle
, @a
, TMirrorType
.None
);
1873 procedure g_Player_RemoveAllCorpses();
1879 SetLength(gGibs
, MaxGibs
);
1880 SetLength(gShells
, MaxGibs
);
1884 if gCorpses
<> nil then
1885 for i
:= 0 to High(gCorpses
) do
1889 SetLength(gCorpses
, MaxCorpses
);
1892 procedure g_Player_Corpses_SaveState (st
: TStream
);
1896 // Ñ÷èòàåì êîëè÷åñòâî ñóùåñòâóþùèõ òðóïîâ
1898 for i
:= 0 to High(gCorpses
) do if (gCorpses
[i
] <> nil) then Inc(count
);
1900 // Êîëè÷åñòâî òðóïîâ
1901 utils
.writeInt(st
, LongInt(count
));
1903 if (count
= 0) then exit
;
1906 for i
:= 0 to High(gCorpses
) do
1908 if gCorpses
[i
] <> nil then
1911 utils
.writeStr(st
, gCorpses
[i
].FModelName
);
1913 utils
.writeBool(st
, gCorpses
[i
].Mess
);
1914 // Ñîõðàíÿåì äàííûå òðóïà:
1915 gCorpses
[i
].SaveState(st
);
1921 procedure g_Player_Corpses_LoadState (st
: TStream
);
1929 g_Player_RemoveAllCorpses();
1931 // Êîëè÷åñòâî òðóïîâ:
1932 count
:= utils
.readLongInt(st
);
1933 if (count
< 0) or (count
> Length(gCorpses
)) then raise XStreamError
.Create('invalid number of corpses');
1935 if (count
= 0) then exit
;
1938 for i
:= 0 to count
-1 do
1941 str
:= utils
.readStr(st
);
1943 b
:= utils
.readBool(st
);
1945 gCorpses
[i
] := TCorpse
.Create(0, 0, str
, b
);
1946 // Çàãðóæàåì äàííûå òðóïà
1947 gCorpses
[i
].LoadState(st
);
1954 function TPlayer
.isValidViewPort (): Boolean; inline; begin result
:= (viewPortW
> 0) and (viewPortH
> 0); end;
1956 procedure TPlayer
.BFGHit();
1958 g_Weapon_BFGHit(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
1959 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2));
1960 if g_Game_IsServer
and g_Game_IsNet
then
1961 MH_SEND_Effect(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
1962 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2),
1966 procedure TPlayer
.ChangeModel(ModelName
: string);
1968 locModel
: TPlayerModel
;
1970 locModel
:= g_PlayerModel_Get(ModelName
);
1971 if locModel
= nil then Exit
;
1977 procedure TPlayer
.SetModel(ModelName
: string);
1981 m
:= g_PlayerModel_Get(ModelName
);
1984 g_SimpleError(Format(_lc
[I_GAME_ERROR_MODEL_FALLBACK
], [ModelName
]));
1985 m
:= g_PlayerModel_Get('doomer');
1988 g_FatalError(Format(_lc
[I_GAME_ERROR_MODEL
], ['doomer']));
1993 if FModel
<> nil then
1998 if not (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then
1999 FModel
.Color
:= FColor
2001 FModel
.Color
:= TEAMCOLOR
[FTeam
];
2002 FModel
.SetWeapon(FCurrWeap
);
2003 FModel
.SetFlag(FFlag
);
2004 SetDirection(FDirection
);
2007 procedure TPlayer
.SetColor(Color
: TRGB
);
2010 if not (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then
2011 if FModel
<> nil then FModel
.Color
:= Color
;
2016 function TPlayer
.GetColor(): TRGB
;
2018 result
:= FModel
.Color
;
2021 procedure TPlayer
.SetWeaponPrefs(Prefs
: Array of Byte);
2025 for i
:= WP_FIRST
to WP_LAST
+ 1 do
2027 if (Prefs
[i
] > WP_LAST
+ 1) then
2028 FWeapPreferences
[i
] := 0
2030 FWeapPreferences
[i
] := Prefs
[i
];
2034 procedure TPlayer
.SetWeaponPref(Weapon
, Pref
: Byte);
2036 if (Weapon
> WP_LAST
+ 1) then
2038 else if (Pref
<= WP_LAST
+ 1) and (Weapon
<= WP_LAST
+ 1) then
2039 FWeapPreferences
[Weapon
] := Pref
2040 else if (Weapon
<= WP_LAST
+ 1) and (Pref
> WP_LAST
+ 1) then
2041 FWeapPreferences
[Weapon
] := 0;
2044 function TPlayer
.GetWeaponPref(Weapon
: Byte) : Byte;
2046 if (Weapon
> WP_LAST
+ 1) then
2048 else if (FWeapPreferences
[Weapon
] > WP_LAST
+ 1) then
2051 result
:= FWeapPreferences
[Weapon
];
2054 function TPlayer
.GetMorePrefered() : Byte;
2056 testedWeap
, i
: Byte;
2058 testedWeap
:= FCurrWeap
;
2059 for i
:= WP_FIRST
to WP_LAST
do
2060 if FWeapon
[i
] and maySwitch(i
) and (FWeapPreferences
[i
] > FWeapPreferences
[testedWeap
]) then
2062 if (R_BERSERK
in FRulez
) and (FWeapPreferences
[WP_LAST
+ 1] > FWeapPreferences
[testedWeap
]) then
2063 testedWeap
:= WEAPON_KASTET
;
2064 result
:= testedWeap
;
2067 function TPlayer
.maySwitch(Weapon
: Byte) : Boolean;
2070 if (Weapon
= WEAPON_KASTET
) and (FSkipFist
<> 0) then
2072 if (FSkipFist
= 1) and (not (R_BERSERK
in FRulez
)) then
2075 else if (FSwitchToEmpty
= 0) and (not hasAmmoForShooting(Weapon
)) then
2079 procedure TPlayer
.SwitchTeam
;
2081 if g_Game_IsClient
then
2083 if not (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then Exit
;
2085 if gGameOn
and FAlive
then
2086 Kill(K_SIMPLEKILL
, FUID
, HIT_SELF
);
2088 if FTeam
= TEAM_RED
then
2090 ChangeTeam(TEAM_BLUE
);
2091 g_Console_Add(Format(_lc
[I_PLAYER_CHTEAM_BLUE
], [FName
]), True);
2092 if g_Game_IsNet
then
2093 MH_SEND_GameEvent(NET_EV_CHANGE_TEAM
, TEAM_BLUE
, FName
);
2097 ChangeTeam(TEAM_RED
);
2098 g_Console_Add(Format(_lc
[I_PLAYER_CHTEAM_RED
], [FName
]), True);
2099 if g_Game_IsNet
then
2100 MH_SEND_GameEvent(NET_EV_CHANGE_TEAM
, TEAM_RED
, FName
);
2102 FPreferredTeam
:= FTeam
;
2105 procedure TPlayer
.ChangeTeam(Team
: Byte);
2112 TEAM_RED
, TEAM_BLUE
:
2113 FModel
.Color
:= TEAMCOLOR
[Team
];
2115 FModel
.Color
:= FColor
;
2117 if (FTeam
<> OldTeam
) and g_Game_IsNet
and g_Game_IsServer
then
2118 MH_SEND_PlayerStats(FUID
);
2122 procedure TPlayer.CollideItem();
2127 if gItems = nil then Exit;
2128 if not FAlive then Exit;
2130 for i := 0 to High(gItems) do
2133 if (ItemType <> ITEM_NONE) and alive then
2134 if g_Obj_Collide(FObj.X+PLAYER_RECT.X, FObj.Y+PLAYER_RECT.Y, PLAYER_RECT.Width,
2135 PLAYER_RECT.Height, @Obj) then
2137 if not PickItem(ItemType, gItems[i].Respawnable, r) then Continue;
2139 if ItemType in [ITEM_SPHERE_BLUE, ITEM_SPHERE_WHITE, ITEM_INVUL] then
2140 g_Sound_PlayExAt('SOUND_ITEM_GETRULEZ', FObj.X, FObj.Y)
2141 else if ItemType in [ITEM_MEDKIT_SMALL, ITEM_MEDKIT_LARGE, ITEM_MEDKIT_BLACK] then
2142 g_Sound_PlayExAt('SOUND_ITEM_GETMED', FObj.X, FObj.Y)
2143 else g_Sound_PlayExAt('SOUND_ITEM_GETITEM', FObj.X, FObj.Y);
2145 // Íàäî óáðàòü ñ êàðòû, åñëè ýòî íå êëþ÷, êîòîðûì íóæíî ïîäåëèòñÿ ñ äðóãèì èãðîêîì:
2146 if r and not ((ItemType in [ITEM_KEY_RED, ITEM_KEY_GREEN, ITEM_KEY_BLUE]) and
2147 (gGameSettings.GameType = GT_SINGLE) and
2148 (g_Player_GetCount() > 1)) then
2149 if not Respawnable then g_Items_Remove(i) else g_Items_Pick(i);
2155 function TPlayer
.CollideLevel(XInc
, YInc
: Integer): Boolean;
2157 Result
:= g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
,
2158 PLAYER_RECT
.Width
, PLAYER_RECT
.Height
, PANEL_WALL
,
2162 constructor TPlayer
.Create();
2168 mEDamageType
:= HIT_SOME
;
2174 FSawSound
:= TPlayableSound
.Create();
2175 FSawSoundIdle
:= TPlayableSound
.Create();
2176 FSawSoundHit
:= TPlayableSound
.Create();
2177 FSawSoundSelect
:= TPlayableSound
.Create();
2178 FFlameSoundOn
:= TPlayableSound
.Create();
2179 FFlameSoundOff
:= TPlayableSound
.Create();
2180 FFlameSoundWork
:= TPlayableSound
.Create();
2181 FJetSoundFly
:= TPlayableSound
.Create();
2182 FJetSoundOn
:= TPlayableSound
.Create();
2183 FJetSoundOff
:= TPlayableSound
.Create();
2185 FSawSound
.SetByName('SOUND_WEAPON_FIRESAW');
2186 FSawSoundIdle
.SetByName('SOUND_WEAPON_IDLESAW');
2187 FSawSoundHit
.SetByName('SOUND_WEAPON_HITSAW');
2188 FSawSoundSelect
.SetByName('SOUND_WEAPON_SELECTSAW');
2189 FFlameSoundOn
.SetByName('SOUND_WEAPON_FLAMEON');
2190 FFlameSoundOff
.SetByName('SOUND_WEAPON_FLAMEOFF');
2191 FFlameSoundWork
.SetByName('SOUND_WEAPON_FLAMEWORK');
2192 FJetSoundFly
.SetByName('SOUND_PLAYER_JETFLY');
2193 FJetSoundOn
.SetByName('SOUND_PLAYER_JETON');
2194 FJetSoundOff
.SetByName('SOUND_PLAYER_JETOFF');
2196 FSpectatePlayer
:= -1;
2200 FSavedStateNum
:= -1;
2208 FActualModelName
:= 'doomer';
2211 FObj
.Rect
:= PLAYER_RECT
;
2213 FBFGFireCounter
:= -1;
2214 FJustTeleported
:= False;
2217 FWaitForFirstSpawn
:= false;
2222 procedure TPlayer
.positionChanged (); inline;
2226 procedure TPlayer
.doDamage (v
: Integer);
2228 if (v
<= 0) then exit
;
2229 if (v
> 32767) then v
:= 32767;
2230 Damage(v
, 0, 0, 0, mEDamageType
);
2233 procedure TPlayer
.Damage(value
: Word; SpawnerUID
: Word; vx
, vy
: Integer; t
: Byte);
2237 if (not g_Game_IsClient
) and (not FAlive
) then
2242 // Íåóÿçâèìîñòü íå ñïàñàåò îò ëîâóøåê:
2243 if ((t
= HIT_TRAP
) or (t
= HIT_SELF
)) and (not FGodMode
) then
2245 if not g_Game_IsClient
then
2248 if t
= HIT_TRAP
then
2250 // Ëîâóøêà óáèâàåò ñðàçó:
2252 Kill(K_EXTRAHARDKILL
, SpawnerUID
, t
);
2254 if t
= HIT_SELF
then
2258 Kill(K_SIMPLEKILL
, SpawnerUID
, t
);
2261 // Îáíóëèòü äåéñòâèÿ ïðèìî÷åê, ÷òîáû ôîí ïðîïàë
2262 FMegaRulez
[MR_SUIT
] := 0;
2263 FMegaRulez
[MR_INVUL
] := 0;
2264 FMegaRulez
[MR_INVIS
] := 0;
2269 // Íî îò îñòàëüíîãî ñïàñàåò:
2270 if FMegaRulez
[MR_INVUL
] >= gTime
then
2277 // Åñëè åñòü óðîí ñâîèì, èëè ðàíèë ñàì ñåáÿ, èëè òåáÿ ðàíèë ïðîòèâíèê:
2278 if LongBool(gGameSettings
.Options
and GAME_OPTION_TEAMDAMAGE
) or
2279 (SpawnerUID
= FUID
) or
2280 (not SameTeam(FUID
, SpawnerUID
)) then
2282 FLastSpawnerUID
:= SpawnerUID
;
2284 // Êðîâü (ïóçûðüêè, åñëè â âîäå):
2285 if gBloodCount
> 0 then
2287 c
:= Min(value
, 200)*gBloodCount
+ Random(Min(value
, 200) div 2);
2288 if value
div 4 <= c
then
2289 c
:= c
- (value
div 4)
2293 if (t
= HIT_SOME
) and (vx
= 0) and (vy
= 0) then
2297 HIT_TRAP
, HIT_ACID
, HIT_FLAME
, HIT_SELF
: MakeBloodSimple(c
);
2298 HIT_BFG
, HIT_ROCKET
, HIT_SOME
: MakeBloodVector(c
, vx
, vy
);
2301 if t
= HIT_WATER
then
2302 g_GFX_Bubbles(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2),
2303 FObj
.Y
+PLAYER_RECT
.Y
-4, value
div 2, 8, 4);
2308 Inc(FDamageBuffer
, value
);
2312 FPain
:= FPain
+ value
;
2315 if g_Game_IsServer
and g_Game_IsNet
then
2317 MH_SEND_PlayerDamage(FUID
, t
, SpawnerUID
, value
, vx
, vy
);
2318 MH_SEND_PlayerStats(FUID
);
2319 MH_SEND_PlayerPos(False, FUID
);
2323 function TPlayer
.Heal(value
: Word; Soft
: Boolean): Boolean;
2326 if g_Game_IsClient
then
2331 if Soft
and (FHealth
< PLAYER_HP_SOFT
) then
2333 IncMax(FHealth
, value
, PLAYER_HP_SOFT
);
2336 if (not Soft
) and (FHealth
< PLAYER_HP_LIMIT
) then
2338 IncMax(FHealth
, value
, PLAYER_HP_LIMIT
);
2342 if Result
and g_Game_IsServer
and g_Game_IsNet
then
2343 MH_SEND_PlayerStats(FUID
);
2346 destructor TPlayer
.Destroy();
2348 if (gPlayer1
<> nil) and (gPlayer1
.FUID
= FUID
) then
2350 if (gPlayer2
<> nil) and (gPlayer2
.FUID
= FUID
) then
2354 FSawSoundIdle
.Free();
2355 FSawSoundHit
.Free();
2356 FSawSoundSelect
.Free();
2357 FFlameSoundOn
.Free();
2358 FFlameSoundOff
.Free();
2359 FFlameSoundWork
.Free();
2360 FJetSoundFly
.Free();
2362 FJetSoundOff
.Free();
2364 if FPunchAnim
<> nil then
2370 procedure TPlayer
.DrawIndicator(Color
: TRGB
);
2372 indX
, indY
, fX
, fY
, fSlope
: Integer;
2382 FObj
.lerp(gLerpFactor
, fX
, fY
);
2383 fSlope
:= nlerp(FSlopeOld
, FObj
.slopeUpLeft
, gLerpFactor
);
2385 case gPlayerIndicatorStyle
of
2388 if g_Texture_Get('TEXTURE_PLAYER_INDICATOR', ID
) then
2390 e_GetTextureSize(ID
, @indW
, @indH
);
2394 if (FObj
.X
+ FObj
.Rect
.X
) < 0 then
2397 indX
:= fX
+ FObj
.Rect
.X
+ FObj
.Rect
.Width
;
2398 indY
:= fY
+ FObj
.Rect
.Y
+ (FObj
.Rect
.Height
- indW
) div 2;
2401 else if (FObj
.X
+ FObj
.Rect
.X
+ FObj
.Rect
.Width
) > Max(gMapInfo
.Width
, gPlayerScreenSize
.X
) then
2404 indX
:= fX
+ FObj
.Rect
.X
- indH
;
2405 indY
:= fY
+ FObj
.Rect
.Y
+ (FObj
.Rect
.Height
- indW
) div 2;
2408 else if (FObj
.Y
- indH
) < 0 then
2411 indX
:= fX
+ FObj
.Rect
.X
+ (FObj
.Rect
.Width
- indW
) div 2;
2412 indY
:= fY
+ FObj
.Rect
.Y
+ FObj
.Rect
.Height
;
2418 indX
:= fX
+ FObj
.Rect
.X
+ (FObj
.Rect
.Width
- indW
) div 2;
2422 indY
:= indY
+ fSlope
;
2423 indX
:= EnsureRange(indX
, 0, Max(gMapInfo
.Width
, gPlayerScreenSize
.X
) - indW
);
2424 indY
:= EnsureRange(indY
, 0, Max(gMapInfo
.Height
, gPlayerScreenSize
.Y
) - indH
);
2428 e_DrawAdv(ID
, indX
, indY
, 0, True, False, indA
, @a
);
2435 e_TextureFontGetSize(gStdFont
, nW
, nH
);
2436 indX
:= fX
+ FObj
.Rect
.X
+ (FObj
.Rect
.Width
- Length(FName
) * nW
) div 2;
2437 indY
:= fY
- nH
+ fSlope
;
2438 e_TextureFontPrintEx(indX
, indY
, FName
, gStdFont
, Color
.R
, Color
.G
, Color
.B
, 1.0, True);
2444 procedure TPlayer
.DrawBubble();
2446 bubX
, bubY
, fX
, fY
: Integer;
2449 Rw
, Gw
, Bw
: SmallInt;
2453 CObj
:= getCameraObj();
2454 CObj
.lerp(gLerpFactor
, fX
, fY
);
2455 // NB: _F_Obj.Rect is used to keep the bubble higher; this is not a mistake
2456 bubX
:= fX
+FObj
.Rect
.X
+ IfThen(FDirection
= TDirection
.D_LEFT
, -4, 18);
2457 bubY
:= fY
+FObj
.Rect
.Y
- 18;
2465 1: // simple textual non-bubble
2467 bubX
:= fX
+FObj
.Rect
.X
- 11;
2468 bubY
:= fY
+FObj
.Rect
.Y
- 17;
2469 e_TextureFontPrint(bubX
, bubY
, '[...]', gStdFont
);
2472 2: // advanced pixel-perfect bubble
2474 if FTeam
= TEAM_RED
then
2477 if FTeam
= TEAM_BLUE
then
2480 3: // colored bubble
2482 Rb
:= FModel
.Color
.R
;
2483 Gb
:= FModel
.Color
.G
;
2484 Bb
:= FModel
.Color
.B
;
2485 Rw
:= Min(Rb
* 2 + 64, 255);
2486 Gw
:= Min(Gb
* 2 + 64, 255);
2487 Bw
:= Min(Bb
* 2 + 64, 255);
2488 if (Abs(Rw
- Rb
) < 32)
2489 or (Abs(Gw
- Gb
) < 32)
2490 or (Abs(Bw
- Bb
) < 32) then
2492 Rb
:= Max(Rw
div 2 - 16, 0);
2493 Gb
:= Max(Gw
div 2 - 16, 0);
2494 Bb
:= Max(Bw
div 2 - 16, 0);
2497 4: // custom textured bubble
2499 if g_Texture_Get('TEXTURE_PLAYER_TALKBUBBLE', ID
) then
2500 if FDirection
= TDirection
.D_RIGHT
then
2501 e_Draw(ID
, bubX
- 6, bubY
- 7, 0, True, False)
2503 e_Draw(ID
, bubX
- 6, bubY
- 7, 0, True, False, TMirrorType
.Horizontal
);
2509 e_DrawQuad(bubX
+ 1, bubY
, bubX
+ 18, bubY
+ 13, Rb
, Gb
, Bb
);
2510 e_DrawQuad(bubX
, bubY
+ 1, bubX
+ 19, bubY
+ 12, Rb
, Gb
, Bb
);
2512 e_DrawFillQuad(bubX
+ 1, bubY
+ 1, bubX
+ 18, bubY
+ 12, Rw
, Gw
, Bw
, 0);
2515 Dot
:= IfThen(FDirection
= TDirection
.D_LEFT
, 14, 5);
2516 e_DrawLine(1, bubX
+ Dot
, bubY
+ 14, bubX
+ Dot
, bubY
+ 16, Rb
, Gb
, Bb
);
2517 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
);
2518 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
);
2519 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
);
2520 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
);
2524 e_DrawFillQuad(bubX
+ Dot
, bubY
+ 8, bubX
+ Dot
+ 1, bubY
+ 9, Rb
, Gb
, Bb
, 0);
2525 e_DrawFillQuad(bubX
+ Dot
+ 3, bubY
+ 8, bubX
+ Dot
+ 4, bubY
+ 9, Rb
, Gb
, Bb
, 0);
2526 e_DrawFillQuad(bubX
+ Dot
+ 6, bubY
+ 8, bubX
+ Dot
+ 7, bubY
+ 9, Rb
, Gb
, Bb
, 0);
2529 procedure TPlayer
.Draw();
2534 Mirror
: TMirrorType
;
2535 fX
, fY
, fSlope
: Integer;
2537 FObj
.lerp(gLerpFactor
, fX
, fY
);
2538 fSlope
:= nlerp(FSlopeOld
, FObj
.slopeUpLeft
, gLerpFactor
);
2542 if Direction
= TDirection
.D_RIGHT
then
2543 Mirror
:= TMirrorType
.None
2545 Mirror
:= TMirrorType
.Horizontal
;
2547 if FPunchAnim
<> nil then
2549 FPunchAnim
.Draw(fX
+IfThen(Direction
= TDirection
.D_LEFT
, 15-FObj
.Rect
.X
, FObj
.Rect
.X
-15),
2550 fY
+fSlope
+FObj
.Rect
.Y
-11, Mirror
);
2551 if FPunchAnim
.played
then
2558 if (FMegaRulez
[MR_INVUL
] > gTime
) and ((gPlayerDrawn
<> Self
) or (FSpawnInvul
>= gTime
)) then
2559 if g_Texture_Get('TEXTURE_PLAYER_INVULPENTA', ID
) then
2561 e_GetTextureSize(ID
, @w
, @h
);
2562 if FDirection
= TDirection
.D_LEFT
then
2563 e_Draw(ID
, fX
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2)-(w
div 2)+4,
2564 fY
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2)-(h
div 2)-7+fSlope
, 0, True, False)
2566 e_Draw(ID
, fX
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2)-(w
div 2)-2,
2567 fY
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2)-(h
div 2)-7+fSlope
, 0, True, False);
2570 if FMegaRulez
[MR_INVIS
] > gTime
then
2572 if (gPlayerDrawn
<> nil) and ((Self
= gPlayerDrawn
) or
2573 ((FTeam
= gPlayerDrawn
.Team
) and (gGameSettings
.GameMode
<> GM_DM
))) then
2575 if (FMegaRulez
[MR_INVIS
] - gTime
) <= 2100 then
2576 dr
:= not Odd((FMegaRulez
[MR_INVIS
] - gTime
) div 300)
2580 FModel
.Draw(fX
, fY
+fSlope
, 200)
2582 FModel
.Draw(fX
, fY
+fSlope
);
2585 FModel
.Draw(fX
, fY
+fSlope
, 254);
2588 FModel
.Draw(fX
, fY
+fSlope
);
2591 if g_debug_Frames
then
2593 e_DrawQuad(FObj
.X
+FObj
.Rect
.X
,
2595 FObj
.X
+FObj
.Rect
.X
+FObj
.Rect
.Width
-1,
2596 FObj
.Y
+FObj
.Rect
.Y
+FObj
.Rect
.Height
-1,
2600 if (gChatBubble
> 0) and (FKeys
[KEY_CHAT
].Pressed
) and not FGhost
then
2601 if (FMegaRulez
[MR_INVIS
] <= gTime
) or ((gPlayerDrawn
<> nil) and ((Self
= gPlayerDrawn
) or
2602 ((FTeam
= gPlayerDrawn
.Team
) and (gGameSettings
.GameMode
<> GM_DM
)))) then
2604 // e_DrawPoint(5, 335, 288, 255, 0, 0); // DL, UR, DL, UR
2605 if gAimLine
and alive
and
2606 ((Self
= gPlayer1
) or (Self
= gPlayer2
)) then
2611 procedure TPlayer
.DrawAim();
2612 procedure drawCast (sz
: Integer; ax0
, ay0
, ax1
, ay1
: Integer);
2617 {$IFDEF ENABLE_HOLMES}
2618 if isValidViewPort
and (self
= gPlayer1
) then
2620 g_Holmes_plrLaser(ax0
, ay0
, ax1
, ay1
);
2624 e_DrawLine(sz
, ax0
, ay0
, ax1
, ay1
, 255, 0, 0, 96);
2625 if (g_Map_traceToNearestWall(ax0
, ay0
, ax1
, ay1
, @ex
, @ey
) <> nil) then
2627 e_DrawLine(sz
, ax0
, ay0
, ex
, ey
, 0, 255, 0, 96);
2631 e_DrawLine(sz
, ax0
, ay0
, ex
, ey
, 0, 0, 255, 96);
2636 wx
, wy
, xx
, yy
: Integer;
2640 wx
:= FObj
.X
+ WEAPONPOINT
[FDirection
].X
+ IfThen(FDirection
= TDirection
.D_LEFT
, 7, -7);
2641 wy
:= FObj
.Y
+ WEAPONPOINT
[FDirection
].Y
;
2650 1: begin // Chainsaw
2657 if angle
= ANGLE_RIGHTUP
then Dec(angle
, 2);
2658 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 4);
2659 if angle
= ANGLE_LEFTUP
then Inc(angle
, 2);
2660 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 4);
2665 if angle
= ANGLE_RIGHTUP
then Dec(angle
, 2);
2666 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 4);
2667 if angle
= ANGLE_LEFTUP
then Inc(angle
, 2);
2668 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 4);
2670 4: begin // Double Shotgun
2673 if angle
= ANGLE_RIGHTUP
then Dec(angle
, 2);
2674 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 4);
2675 if angle
= ANGLE_LEFTUP
then Inc(angle
, 2);
2676 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 4);
2678 5: begin // Chaingun
2681 if angle
= ANGLE_RIGHTUP
then Dec(angle
, 2);
2682 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 4);
2683 if angle
= ANGLE_LEFTUP
then Inc(angle
, 2);
2684 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 4);
2686 6: begin // Rocket Launcher
2689 if angle
= ANGLE_RIGHTUP
then Inc(angle
, 2);
2690 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 4);
2691 if angle
= ANGLE_LEFTUP
then Dec(angle
, 2);
2692 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 4);
2694 7: begin // Plasmagun
2697 if angle
= ANGLE_RIGHTUP
then Inc(angle
);
2698 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 3);
2699 if angle
= ANGLE_LEFTUP
then Dec(angle
);
2700 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 3);
2705 if angle
= ANGLE_RIGHTUP
then Inc(angle
, 1);
2706 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 2);
2707 if angle
= ANGLE_LEFTUP
then Dec(angle
, 1);
2708 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 2);
2710 9: begin // Super Chaingun
2713 if angle
= ANGLE_RIGHTUP
then Dec(angle
, 2);
2714 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 4);
2715 if angle
= ANGLE_LEFTUP
then Inc(angle
, 2);
2716 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 4);
2719 xx
:= Trunc(Cos(-DegToRad(angle
)) * len
) + wx
;
2720 yy
:= Trunc(Sin(-DegToRad(angle
)) * len
) + wy
;
2721 {$IF DEFINED(D2F_DEBUG)}
2722 drawCast(sz
, wx
, wy
, xx
, yy
);
2724 e_DrawLine(sz
, wx
, wy
, xx
, yy
, 255, 0, 0, 96);
2728 procedure TPlayer
.DrawGUI();
2731 X
, Y
, SY
, a
, p
, m
: Integer;
2735 stat
: TPlayerStatArray
;
2737 X
:= gPlayerScreenSize
.X
;
2738 SY
:= gPlayerScreenSize
.Y
;
2741 if gShowGoals
and (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then
2743 if gGameSettings
.GameMode
= GM_CTF
then
2747 if gGameSettings
.GameMode
= GM_CTF
then
2749 s
:= 'TEXTURE_PLAYER_REDFLAG';
2750 if gFlags
[FLAG_RED
].State
= FLAG_STATE_CAPTURED
then
2751 s
:= 'TEXTURE_PLAYER_REDFLAG_S';
2752 if gFlags
[FLAG_RED
].State
= FLAG_STATE_DROPPED
then
2753 s
:= 'TEXTURE_PLAYER_REDFLAG_D';
2754 if g_Texture_Get(s
, ID
) then
2755 e_Draw(ID
, X
-16-32, 240-72-4, 0, True, False);
2758 s
:= IntToStr(gTeamStat
[TEAM_RED
].Goals
);
2759 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2760 e_CharFont_PrintEx(gMenuFont
, X
-16-a
-tw
, 240-72-4, s
, TEAMCOLOR
[TEAM_RED
]);
2762 if gGameSettings
.GameMode
= GM_CTF
then
2764 s
:= 'TEXTURE_PLAYER_BLUEFLAG';
2765 if gFlags
[FLAG_BLUE
].State
= FLAG_STATE_CAPTURED
then
2766 s
:= 'TEXTURE_PLAYER_BLUEFLAG_S';
2767 if gFlags
[FLAG_BLUE
].State
= FLAG_STATE_DROPPED
then
2768 s
:= 'TEXTURE_PLAYER_BLUEFLAG_D';
2769 if g_Texture_Get(s
, ID
) then
2770 e_Draw(ID
, X
-16-32, 240-32-4, 0, True, False);
2773 s
:= IntToStr(gTeamStat
[TEAM_BLUE
].Goals
);
2774 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2775 e_CharFont_PrintEx(gMenuFont
, X
-16-a
-tw
, 240-32-4, s
, TEAMCOLOR
[TEAM_BLUE
]);
2778 if g_Texture_Get('TEXTURE_PLAYER_HUDBG', ID
) then
2779 e_DrawFill(ID
, X
, 0, 1, (gPlayerScreenSize
.Y
div 256)+IfThen(gPlayerScreenSize
.Y
mod 256 > 0, 1, 0),
2782 if g_Texture_Get('TEXTURE_PLAYER_HUD', ID
) then
2783 e_Draw(ID
, X
+2, Y
, 0, True, False);
2785 if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
2789 s
:= IntToStr(Frags
);
2790 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2791 e_CharFont_PrintEx(gMenuFont
, X
-16-tw
, Y
, s
, _RGB(255, 0, 0));
2796 stat
:= g_Player_GetStats();
2801 for a
:= 0 to High(stat
) do
2802 if stat
[a
].Name
<> Name
then
2804 if stat
[a
].Frags
> m
then m
:= stat
[a
].Frags
;
2805 if stat
[a
].Frags
> Frags
then p
:= p
+1;
2809 s
:= IntToStr(p
)+' / '+IntToStr(Length(stat
))+' ';
2810 if Frags
>= m
then s
:= s
+'+' else s
:= s
+'-';
2811 s
:= s
+IntToStr(Abs(Frags
-m
));
2813 e_CharFont_GetSize(gMenuSmallFont
, s
, tw
, th
);
2814 e_CharFont_PrintEx(gMenuSmallFont
, X
-16-tw
, Y
+32, s
, _RGB(255, 0, 0));
2817 if gLMSRespawn
> LMS_RESPAWN_NONE
then
2819 s
:= _lc
[I_GAME_WARMUP
];
2820 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2821 s
:= s
+ ': ' + IntToStr((gLMSRespawnTime
- gTime
) div 1000);
2822 e_CharFont_PrintEx(gMenuFont
, X
-64-tw
, SY
-32, s
, _RGB(0, 255, 0));
2824 else if gShowLives
and (gGameSettings
.MaxLives
> 0) then
2826 s
:= IntToStr(Lives
);
2827 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2828 e_CharFont_PrintEx(gMenuFont
, X
-16-tw
, SY
-32, s
, _RGB(0, 255, 0));
2832 e_CharFont_GetSize(gMenuSmallFont
, FName
, tw
, th
);
2833 e_CharFont_PrintEx(gMenuSmallFont
, X
+98-(tw
div 2), Y
+8, FName
, _RGB(255, 0, 0));
2835 if R_BERSERK
in FRulez
then
2836 e_Draw(gItemsTexturesID
[ITEM_MEDKIT_BLACK
], X
+37, Y
+45, 0, True, False)
2838 e_Draw(gItemsTexturesID
[ITEM_MEDKIT_LARGE
], X
+37, Y
+45, 0, True, False);
2840 if g_Texture_Get('TEXTURE_PLAYER_ARMORHUD', ID
) then
2841 e_Draw(ID
, X
+36, Y
+77, 0, True, False);
2843 s
:= IntToStr(IfThen(FHealth
> 0, FHealth
, 0));
2844 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2845 e_CharFont_PrintEx(gMenuFont
, X
+178-tw
, Y
+40, s
, _RGB(255, 0, 0));
2847 s
:= IntToStr(FArmor
);
2848 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2849 e_CharFont_PrintEx(gMenuFont
, X
+178-tw
, Y
+68, s
, _RGB(255, 0, 0));
2851 s
:= IntToStr(GetAmmoByWeapon(FCurrWeap
));
2857 ID
:= gItemsTexturesID
[ITEM_WEAPON_KASTET
];
2862 ID
:= gItemsTexturesID
[ITEM_WEAPON_SAW
];
2864 WEAPON_PISTOL
: ID
:= gItemsTexturesID
[ITEM_WEAPON_PISTOL
];
2865 WEAPON_CHAINGUN
: ID
:= gItemsTexturesID
[ITEM_WEAPON_CHAINGUN
];
2866 WEAPON_SHOTGUN1
: ID
:= gItemsTexturesID
[ITEM_WEAPON_SHOTGUN1
];
2867 WEAPON_SHOTGUN2
: ID
:= gItemsTexturesID
[ITEM_WEAPON_SHOTGUN2
];
2868 WEAPON_SUPERPULEMET
: ID
:= gItemsTexturesID
[ITEM_WEAPON_SUPERPULEMET
];
2869 WEAPON_ROCKETLAUNCHER
: ID
:= gItemsTexturesID
[ITEM_WEAPON_ROCKETLAUNCHER
];
2870 WEAPON_PLASMA
: ID
:= gItemsTexturesID
[ITEM_WEAPON_PLASMA
];
2871 WEAPON_BFG
: ID
:= gItemsTexturesID
[ITEM_WEAPON_BFG
];
2872 WEAPON_FLAMETHROWER
: ID
:= gItemsTexturesID
[ITEM_WEAPON_FLAMETHROWER
];
2875 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2876 e_CharFont_PrintEx(gMenuFont
, X
+178-tw
, Y
+158, s
, _RGB(255, 0, 0));
2877 e_Draw(ID
, X
+20, Y
+160, 0, True, False);
2879 if R_KEY_RED
in FRulez
then
2880 e_Draw(gItemsTexturesID
[ITEM_KEY_RED
], X
+78, Y
+214, 0, True, False);
2882 if R_KEY_GREEN
in FRulez
then
2883 e_Draw(gItemsTexturesID
[ITEM_KEY_GREEN
], X
+95, Y
+214, 0, True, False);
2885 if R_KEY_BLUE
in FRulez
then
2886 e_Draw(gItemsTexturesID
[ITEM_KEY_BLUE
], X
+112, Y
+214, 0, True, False);
2888 if FJetFuel
> 0 then
2890 if g_Texture_Get('TEXTURE_PLAYER_HUDAIR', ID
) then
2891 e_Draw(ID
, X
+2, Y
+116, 0, True, False);
2892 if g_Texture_Get('TEXTURE_PLAYER_HUDJET', ID
) then
2893 e_Draw(ID
, X
+2, Y
+126, 0, True, False);
2894 e_DrawLine(4, X
+16, Y
+122, X
+16+Trunc(168*IfThen(FAir
> 0, FAir
, 0)/AIR_MAX
), Y
+122, 0, 0, 196);
2895 e_DrawLine(4, X
+16, Y
+132, X
+16+Trunc(168*FJetFuel
/JET_MAX
), Y
+132, 208, 0, 0);
2899 if g_Texture_Get('TEXTURE_PLAYER_HUDAIR', ID
) then
2900 e_Draw(ID
, X
+2, Y
+124, 0, True, False);
2901 e_DrawLine(4, X
+16, Y
+130, X
+16+Trunc(168*IfThen(FAir
> 0, FAir
, 0)/AIR_MAX
), Y
+130, 0, 0, 196);
2904 if gShowPing
and g_Game_IsClient
then
2906 s
:= _lc
[I_GAME_PING_HUD
] + IntToStr(NetPeer
.lastRoundTripTime
) + _lc
[I_NET_SLIST_PING_MS
];
2907 e_TextureFontPrint(X
+ 4, Y
+ 242, s
, gStdFont
);
2913 e_TextureFontPrint(X
+ 4, Y
+ 242, _lc
[I_PLAYER_SPECT
], gStdFont
);
2914 e_TextureFontPrint(X
+ 4, Y
+ 258, _lc
[I_PLAYER_SPECT2
], gStdFont
);
2915 e_TextureFontPrint(X
+ 4, Y
+ 274, _lc
[I_PLAYER_SPECT1
], gStdFont
);
2918 e_TextureFontGetSize(gStdFont
, cw
, ch
);
2919 s
:= _lc
[I_PLAYER_SPECT4
];
2920 e_TextureFontPrintEx(gScreenWidth
div 2 - cw
*(Length(s
) div 2),
2921 gScreenHeight
-4-ch
, s
, gStdFont
, 255, 255, 255, 1, True);
2922 e_TextureFontPrint(X
+ 4, Y
+ 290, _lc
[I_PLAYER_SPECT1S
], gStdFont
);
2928 procedure TPlayer
.DrawRulez();
2932 // Ïðè âçÿòèè íåóÿçâèìîñòè ðèñóåòñÿ èíâåðñèîííûé áåëûé ôîí
2933 if (FMegaRulez
[MR_INVUL
] >= gTime
) and (FSpawnInvul
< gTime
) then
2935 if (FMegaRulez
[MR_INVUL
]-gTime
) <= 2100 then
2936 dr
:= not Odd((FMegaRulez
[MR_INVUL
]-gTime
) div 300)
2941 e_DrawFillQuad(0, 0, gPlayerScreenSize
.X
-1, gPlayerScreenSize
.Y
-1,
2942 191, 191, 191, 0, TBlending
.Invert
);
2945 // Ïðè âçÿòèè çàùèòíîãî êîñòþìà ðèñóåòñÿ çåëåíîâàòûé ôîí
2946 if FMegaRulez
[MR_SUIT
] >= gTime
then
2948 if (FMegaRulez
[MR_SUIT
]-gTime
) <= 2100 then
2949 dr
:= not Odd((FMegaRulez
[MR_SUIT
]-gTime
) div 300)
2954 e_DrawFillQuad(0, 0, gPlayerScreenSize
.X
-1, gPlayerScreenSize
.Y
-1,
2955 0, 96, 0, 200, TBlending
.None
);
2958 // Ïðè âçÿòèè áåðñåðêà ðèñóåòñÿ êðàñíîâàòûé ôîí
2959 if (FBerserk
>= 0) and (LongWord(FBerserk
) >= gTime
) and (gFlash
= 2) then
2961 e_DrawFillQuad(0, 0, gPlayerScreenSize
.X
-1, gPlayerScreenSize
.Y
-1,
2962 255, 0, 0, 200, TBlending
.None
);
2966 procedure TPlayer
.DrawPain();
2970 if FPain
= 0 then Exit
;
2974 if a
< 15 then h
:= 0
2975 else if a
< 35 then h
:= 1
2976 else if a
< 55 then h
:= 2
2977 else if a
< 75 then h
:= 3
2978 else if a
< 95 then h
:= 4
2981 //if a > 255 then a := 255;
2983 e_DrawFillQuad(0, 0, gPlayerScreenSize
.X
-1, gPlayerScreenSize
.Y
-1, 255, 0, 0, 255-h
*50);
2984 //e_DrawFillQuad(0, 0, gPlayerScreenSize.X-1, gPlayerScreenSize.Y-1, 255-min(128, a), 255-a, 255-a, 0, B_FILTER);
2987 procedure TPlayer
.DrawPickup();
2991 if FPickup
= 0 then Exit
;
2995 if a
< 15 then h
:= 1
2996 else if a
< 35 then h
:= 2
2997 else if a
< 55 then h
:= 3
2998 else if a
< 75 then h
:= 4
3001 e_DrawFillQuad(0, 0, gPlayerScreenSize
.X
-1, gPlayerScreenSize
.Y
-1, 150, 200, 150, 255-h
*50);
3004 procedure TPlayer
.DoPunch();
3009 if FPunchAnim
<> nil then begin
3014 st
:= 'FRAMES_PUNCH';
3015 if R_BERSERK
in FRulez
then
3016 st
:= st
+ '_BERSERK';
3017 if FKeys
[KEY_UP
].Pressed
then
3019 else if FKeys
[KEY_DOWN
].Pressed
then
3021 g_Frames_Get(id
, st
);
3022 FPunchAnim
:= TAnimation
.Create(id
, False, 1);
3025 procedure TPlayer
.Fire();
3027 f
, DidFire
: Boolean;
3028 wx
, wy
, xd
, yd
: Integer;
3031 if g_Game_IsClient
then Exit
;
3032 // FBFGFireCounter - âðåìÿ ïåðåä âûñòðåëîì (äëÿ BFG)
3033 // FReloading - âðåìÿ ïîñëå âûñòðåëà (äëÿ âñåãî)
3041 if FReloading
[FCurrWeap
] <> 0 then Exit
;
3046 wx
:= FObj
.X
+WEAPONPOINT
[FDirection
].X
;
3047 wy
:= FObj
.Y
+WEAPONPOINT
[FDirection
].Y
;
3048 xd
:= wx
+IfThen(FDirection
= TDirection
.D_LEFT
, -30, 30);
3049 yd
:= wy
+firediry();
3055 if R_BERSERK
in FRulez
then
3057 //g_Weapon_punch(FObj.X+FObj.Rect.X, FObj.Y+FObj.Rect.Y, 75, FUID);
3058 locobj
.X
:= FObj
.X
+FObj
.Rect
.X
;
3059 locobj
.Y
:= FObj
.Y
+FObj
.Rect
.Y
;
3062 locobj
.rect
.Width
:= 39;
3063 locobj
.rect
.Height
:= 52;
3064 locobj
.Vel
.X
:= (xd
-wx
) div 2;
3065 locobj
.Vel
.Y
:= (yd
-wy
) div 2;
3066 locobj
.Accel
.X
:= xd
-wx
;
3067 locobj
.Accel
.y
:= yd
-wy
;
3069 if g_Weapon_Hit(@locobj
, 50, FUID
, HIT_SOME
) <> 0 then
3070 g_Sound_PlayExAt('SOUND_WEAPON_HITBERSERK', FObj
.X
, FObj
.Y
)
3072 g_Sound_PlayExAt('SOUND_WEAPON_MISSBERSERK', FObj
.X
, FObj
.Y
);
3074 if (gFlash
= 1) and (FPain
< 50) then FPain
:= min(FPain
+ 25, 50);
3078 g_Weapon_punch(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
, 3, FUID
);
3082 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
3087 if g_Weapon_chainsaw(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
,
3088 IfThen(gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
], 9, 3), FUID
) <> 0 then
3090 FSawSoundSelect
.Stop();
3092 FSawSoundHit
.PlayAt(FObj
.X
, FObj
.Y
);
3094 else if not FSawSoundHit
.IsPlaying() then
3096 FSawSoundSelect
.Stop();
3097 FSawSound
.PlayAt(FObj
.X
, FObj
.Y
);
3100 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
3106 if FAmmo
[A_BULLETS
] > 0 then
3108 g_Weapon_pistol(wx
, wy
, xd
, yd
, FUID
);
3109 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
3110 Dec(FAmmo
[A_BULLETS
]);
3111 FFireAngle
:= FAngle
;
3114 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
3115 GameVelX
, GameVelY
-2, SHELL_BULLET
);
3119 if FAmmo
[A_SHELLS
] > 0 then
3121 g_Weapon_shotgun(wx
, wy
, xd
, yd
, FUID
);
3122 if not gSoundEffectsDF
then g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN', wx
, wy
);
3123 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
3124 Dec(FAmmo
[A_SHELLS
]);
3125 FFireAngle
:= FAngle
;
3129 FShellType
:= SHELL_SHELL
;
3133 if FAmmo
[A_SHELLS
] >= 2 then
3135 g_Weapon_dshotgun(wx
, wy
, xd
, yd
, FUID
);
3136 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
3137 Dec(FAmmo
[A_SHELLS
], 2);
3138 FFireAngle
:= FAngle
;
3142 FShellType
:= SHELL_DBLSHELL
;
3146 if FAmmo
[A_BULLETS
] > 0 then
3148 g_Weapon_mgun(wx
, wy
, xd
, yd
, FUID
);
3149 if not gSoundEffectsDF
then g_Sound_PlayExAt('SOUND_WEAPON_FIREPISTOL', wx
, wy
);
3150 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
3151 Dec(FAmmo
[A_BULLETS
]);
3152 FFireAngle
:= FAngle
;
3155 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
3156 GameVelX
, GameVelY
-2, SHELL_BULLET
);
3159 WEAPON_ROCKETLAUNCHER
:
3160 if FAmmo
[A_ROCKETS
] > 0 then
3162 g_Weapon_rocket(wx
, wy
, xd
, yd
, FUID
);
3163 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
3164 Dec(FAmmo
[A_ROCKETS
]);
3165 FFireAngle
:= FAngle
;
3171 if FAmmo
[A_CELLS
] > 0 then
3173 g_Weapon_plasma(wx
, wy
, xd
, yd
, FUID
);
3174 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
3175 Dec(FAmmo
[A_CELLS
]);
3176 FFireAngle
:= FAngle
;
3182 if (FAmmo
[A_CELLS
] >= 40) and (FBFGFireCounter
= -1) then
3184 FBFGFireCounter
:= 17;
3185 if not FNoReload
then
3186 g_Sound_PlayExAt('SOUND_WEAPON_STARTFIREBFG', FObj
.X
, FObj
.Y
);
3187 Dec(FAmmo
[A_CELLS
], 40);
3191 WEAPON_SUPERPULEMET
:
3192 if FAmmo
[A_SHELLS
] > 0 then
3194 g_Weapon_shotgun(wx
, wy
, xd
, yd
, FUID
);
3195 if not gSoundEffectsDF
then g_Sound_PlayExAt('SOUND_WEAPON_FIRECGUN', wx
, wy
);
3196 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
3197 Dec(FAmmo
[A_SHELLS
]);
3198 FFireAngle
:= FAngle
;
3201 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
3202 GameVelX
, GameVelY
-2, SHELL_SHELL
);
3205 WEAPON_FLAMETHROWER
:
3206 if FAmmo
[A_FUEL
] > 0 then
3208 g_Weapon_flame(wx
, wy
, xd
, yd
, FUID
);
3210 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
3212 FFireAngle
:= FAngle
;
3219 if g_Game_IsNet
and g_Game_IsServer
then MH_SEND_PlayerStats(FUID
);
3223 if g_Game_IsNet
then
3227 if FCurrWeap
<> WEAPON_BFG
then
3228 MH_SEND_PlayerFire(FUID
, FCurrWeap
, wx
, wy
, xd
, yd
, LastShotID
)
3230 if not FNoReload
then
3231 MH_SEND_Sound(FObj
.X
, FObj
.Y
, 'SOUND_WEAPON_STARTFIREBFG');
3234 MH_SEND_PlayerStats(FUID
);
3239 if (FAngle
= 0) or (FAngle
= 180) then SetAction(A_ATTACK
)
3240 else if (FAngle
= ANGLE_LEFTDOWN
) or (FAngle
= ANGLE_RIGHTDOWN
) then SetAction(A_ATTACKDOWN
)
3241 else if (FAngle
= ANGLE_LEFTUP
) or (FAngle
= ANGLE_RIGHTUP
) then SetAction(A_ATTACKUP
);
3244 function TPlayer
.GetAmmoByWeapon(Weapon
: Byte): Word;
3247 WEAPON_PISTOL
, WEAPON_CHAINGUN
: Result
:= FAmmo
[A_BULLETS
];
3248 WEAPON_SHOTGUN1
, WEAPON_SHOTGUN2
, WEAPON_SUPERPULEMET
: Result
:= FAmmo
[A_SHELLS
];
3249 WEAPON_ROCKETLAUNCHER
: Result
:= FAmmo
[A_ROCKETS
];
3250 WEAPON_PLASMA
, WEAPON_BFG
: Result
:= FAmmo
[A_CELLS
];
3251 WEAPON_FLAMETHROWER
: Result
:= FAmmo
[A_FUEL
];
3256 function TPlayer
.HeadInLiquid(XInc
, YInc
: Integer): Boolean;
3258 Result
:= g_Map_CollidePanel(FObj
.X
+PLAYER_HEADRECT
.X
+XInc
, FObj
.Y
+PLAYER_HEADRECT
.Y
+YInc
,
3259 PLAYER_HEADRECT
.Width
, PLAYER_HEADRECT
.Height
,
3260 PANEL_WATER
or PANEL_ACID1
or PANEL_ACID2
, True);
3263 procedure TPlayer
.FlamerOn
;
3265 FFlameSoundOff
.Stop();
3266 FFlameSoundOff
.SetPosition(0);
3269 if (not FFlameSoundOn
.IsPlaying()) and (not FFlameSoundWork
.IsPlaying()) then
3270 FFlameSoundWork
.PlayAt(FObj
.X
, FObj
.Y
);
3274 FFlameSoundOn
.PlayAt(FObj
.X
, FObj
.Y
);
3279 procedure TPlayer
.FlamerOff
;
3283 FFlameSoundOn
.Stop();
3284 FFlameSoundOn
.SetPosition(0);
3285 FFlameSoundWork
.Stop();
3286 FFlameSoundWork
.SetPosition(0);
3287 FFlameSoundOff
.PlayAt(FObj
.X
, FObj
.Y
);
3292 procedure TPlayer
.JetpackOn
;
3296 FJetSoundOn
.SetPosition(0);
3297 FJetSoundOn
.PlayAt(FObj
.X
, FObj
.Y
);
3301 procedure TPlayer
.JetpackOff
;
3305 FJetSoundOff
.SetPosition(0);
3306 FJetSoundOff
.PlayAt(FObj
.X
, FObj
.Y
);
3309 procedure TPlayer
.CatchFire(Attacker
: Word; Timeout
: Integer = PLAYER_BURN_TIME
);
3311 if Timeout
<= 0 then
3313 if (FMegaRulez
[MR_SUIT
] > gTime
) or (FMegaRulez
[MR_INVUL
] > gTime
) then
3314 exit
; // Íå çàãîðàåìñÿ êîãäà åñòü çàùèòà
3315 if g_Obj_CollidePanel(@FObj
, 0, 0, PANEL_WATER
or PANEL_ACID1
or PANEL_ACID2
) then
3316 exit
; // Íå ïîäãîðàåì â âîäå íà âñÿêèé ñëó÷àé
3317 if FFireTime
<= 0 then
3318 g_Sound_PlayExAt('SOUND_IGNITE', FObj
.X
, FObj
.Y
);
3319 FFireTime
:= Timeout
;
3320 FFireAttacker
:= Attacker
;
3321 if g_Game_IsNet
and g_Game_IsServer
then
3322 MH_SEND_PlayerStats(FUID
);
3325 procedure TPlayer
.Jump();
3327 if gFly
or FJetpack
then
3329 // Ïîëåò (÷èò-êîä èëè äæåòïàê):
3330 if FObj
.Vel
.Y
> -VEL_FLY
then
3331 FObj
.Vel
.Y
:= FObj
.Vel
.Y
- 3;
3334 if FJetFuel
> 0 then
3336 if (FJetFuel
< 1) and g_Game_IsServer
then
3340 if g_Game_IsNet
then
3341 MH_SEND_PlayerStats(FUID
);
3347 // Íå âêëþ÷àòü äæåòïàê â ðåæèìå ïðîõîæäåíèÿ ñêâîçü ñòåíû
3349 FCanJetpack
:= False;
3351 // Ïðûãàåì èëè âñïëûâàåì:
3352 if (CollideLevel(0, 1) or
3353 g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+PLAYER_RECT
.Y
+36, PLAYER_RECT
.Width
,
3354 PLAYER_RECT
.Height
-33, PANEL_STEP
, False)
3355 ) and (FObj
.Accel
.Y
= 0) then // Íå ïðûãàòü, åñëè åñòü âåðòèêàëüíîå óñêîðåíèå
3357 FObj
.Vel
.Y
:= -VEL_JUMP
;
3358 FCanJetpack
:= False;
3362 if BodyInLiquid(0, 0) then
3363 FObj
.Vel
.Y
:= -VEL_SW
3364 else if (FJetFuel
> 0) and FCanJetpack
and
3365 g_Game_IsServer
and (not g_Obj_CollideLiquid(@FObj
, 0, 0)) then
3369 if g_Game_IsNet
then
3370 MH_SEND_PlayerStats(FUID
);
3375 procedure TPlayer
.Kill(KillType
: Byte; SpawnerUID
: Word; t
: Byte);
3377 a
, i
, k
, ab
, ar
: Byte;
3381 srv
, netsrv
: Boolean;
3387 procedure PushItem(t
: Byte);
3391 id
:= g_Items_Create(FObj
.X
, FObj
.Y
, t
, True, False);
3392 it
:= g_Items_ByIdx(id
);
3393 if KillType
= K_EXTRAHARDKILL
then // -7..+7; -8..0
3395 g_Obj_Push(@it
.Obj
, (FObj
.Vel
.X
div 2)-7+Random(15),
3396 (FObj
.Vel
.Y
div 2)-Random(9));
3397 it
.positionChanged(); // this updates spatial accelerators
3401 if KillType
= K_HARDKILL
then // -5..+5; -5..0
3403 g_Obj_Push(@it
.Obj
, (FObj
.Vel
.X
div 2)-5+Random(11),
3404 (FObj
.Vel
.Y
div 2)-Random(6));
3406 else // -3..+3; -3..0
3408 g_Obj_Push(@it
.Obj
, (FObj
.Vel
.X
div 2)-3+Random(7),
3409 (FObj
.Vel
.Y
div 2)-Random(4));
3411 it
.positionChanged(); // this updates spatial accelerators
3414 if g_Game_IsNet
and g_Game_IsServer
then
3415 MH_SEND_ItemSpawn(True, id
);
3419 DoFrags
:= (gGameSettings
.MaxLives
= 0) or (gGameSettings
.GameMode
= GM_COOP
);
3420 Srv
:= g_Game_IsServer
;
3421 Netsrv
:= g_Game_IsServer
and g_Game_IsNet
;
3422 if Srv
then FDeath
:= FDeath
+ 1;
3427 if not FPhysics
then
3433 if (gGameSettings
.MaxLives
> 0) and Srv
and (gLMSRespawn
= LMS_RESPAWN_NONE
) then
3435 if FLives
> 0 then FLives
:= FLives
- 1;
3436 if FLives
= 0 then FNoRespawn
:= True;
3439 // Íîìåð òèïà ñìåðòè:
3442 K_SIMPLEKILL
: a
:= 1;
3444 K_EXTRAHARDKILL
: a
:= 3;
3449 if not FModel
.PlaySound(MODELSOUND_DIE
, a
, FObj
.X
, FObj
.Y
) then
3451 if FModel
.PlaySound(MODELSOUND_DIE
, i
, FObj
.X
, FObj
.Y
) then
3458 FTime
[T_RESPAWN
] := gTime
+ TIME_RESPAWN1
;
3460 FTime
[T_RESPAWN
] := gTime
+ TIME_RESPAWN2
;
3461 K_EXTRAHARDKILL
, K_FALLKILL
:
3462 FTime
[T_RESPAWN
] := gTime
+ TIME_RESPAWN3
;
3465 // Ïåðåêëþ÷àåì ñîñòîÿíèå:
3469 K_HARDKILL
, K_EXTRAHARDKILL
:
3473 // Ðåàêöèÿ ìîíñòðîâ íà ñìåðòü èãðîêà:
3474 if (KillType
<> K_FALLKILL
) and (Srv
) then
3475 g_Monsters_killedp();
3477 if SpawnerUID
= FUID
then
3481 if gGameSettings
.GameMode
= GM_TDM
then
3482 Dec(gTeamStat
[FTeam
].Goals
);
3483 if DoFrags
or (gGameSettings
.GameMode
= GM_TDM
) then
3489 g_Console_Add(Format(_lc
[I_PLAYER_KILL_SELF
], [FName
]), True);
3492 if g_GetUIDType(SpawnerUID
) = UID_PLAYER
then
3493 begin // Óáèò äðóãèì èãðîêîì
3494 KP
:= g_Player_Get(SpawnerUID
);
3495 if (KP
<> nil) and Srv
then
3497 if (DoFrags
or (gGameSettings
.GameMode
= GM_TDM
)) then
3498 if SameTeam(FUID
, SpawnerUID
) then
3508 if (gGameSettings
.GameMode
= GM_TDM
) and DoFrags
then
3509 Inc(gTeamStat
[KP
.Team
].Goals
,
3510 IfThen(SameTeam(FUID
, SpawnerUID
), -1, 1));
3512 if netsrv
then MH_SEND_PlayerStats(SpawnerUID
);
3515 plr
:= g_Player_Get(SpawnerUID
);
3523 g_Console_Add(Format(_lc
[I_PLAYER_KILL_EXTRAHARD_2
],
3527 g_Console_Add(Format(_lc
[I_PLAYER_KILL_EXTRAHARD_1
],
3531 g_Console_Add(Format(_lc
[I_PLAYER_KILL
],
3536 else if g_GetUIDType(SpawnerUID
) = UID_MONSTER
then
3537 begin // Óáèò ìîíñòðîì
3538 mon
:= g_Monsters_ByUID(SpawnerUID
);
3542 s
:= g_Mons_GetKilledByTypeId(mon
.MonsterType
);
3546 g_Console_Add(Format(_lc
[I_PLAYER_KILL_EXTRAHARD_2
],
3550 g_Console_Add(Format(_lc
[I_PLAYER_KILL_EXTRAHARD_1
],
3554 g_Console_Add(Format(_lc
[I_PLAYER_KILL
],
3559 else // Îñîáûå òèïû ñìåðòè
3562 HIT_SELF
: g_Console_Add(Format(_lc
[I_PLAYER_KILL_SELF
], [FName
]), True);
3563 HIT_FALL
: g_Console_Add(Format(_lc
[I_PLAYER_KILL_FALL
], [FName
]), True);
3564 HIT_WATER
: g_Console_Add(Format(_lc
[I_PLAYER_KILL_WATER
], [FName
]), True);
3565 HIT_ACID
: g_Console_Add(Format(_lc
[I_PLAYER_KILL_ACID
], [FName
]), True);
3566 HIT_TRAP
: g_Console_Add(Format(_lc
[I_PLAYER_KILL_TRAP
], [FName
]), True);
3567 else g_Console_Add(Format(_lc
[I_PLAYER_DIED
], [FName
]), True);
3573 for a
:= WP_FIRST
to WP_LAST
do
3577 WEAPON_SAW
: i
:= ITEM_WEAPON_SAW
;
3578 WEAPON_SHOTGUN1
: i
:= ITEM_WEAPON_SHOTGUN1
;
3579 WEAPON_SHOTGUN2
: i
:= ITEM_WEAPON_SHOTGUN2
;
3580 WEAPON_CHAINGUN
: i
:= ITEM_WEAPON_CHAINGUN
;
3581 WEAPON_ROCKETLAUNCHER
: i
:= ITEM_WEAPON_ROCKETLAUNCHER
;
3582 WEAPON_PLASMA
: i
:= ITEM_WEAPON_PLASMA
;
3583 WEAPON_BFG
: i
:= ITEM_WEAPON_BFG
;
3584 WEAPON_SUPERPULEMET
: i
:= ITEM_WEAPON_SUPERPULEMET
;
3585 WEAPON_FLAMETHROWER
: i
:= ITEM_WEAPON_FLAMETHROWER
;
3594 if R_ITEM_BACKPACK
in FRulez
then
3595 PushItem(ITEM_AMMO_BACKPACK
);
3597 // Âûáðîñ ðàêåòíîãî ðàíöà:
3598 if FJetFuel
> 0 then
3599 PushItem(ITEM_JETPACK
);
3602 if (not (gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
])) or
3603 (not LongBool(gGameSettings
.Options
and GAME_OPTION_DMKEYS
)) then
3605 if R_KEY_RED
in FRulez
then
3606 PushItem(ITEM_KEY_RED
);
3608 if R_KEY_GREEN
in FRulez
then
3609 PushItem(ITEM_KEY_GREEN
);
3611 if R_KEY_BLUE
in FRulez
then
3612 PushItem(ITEM_KEY_BLUE
);
3616 DropFlag(KillType
= K_FALLKILL
);
3619 FCorpse
:= g_Player_CreateCorpse(Self
);
3621 if Srv
and (gGameSettings
.MaxLives
> 0) and FNoRespawn
and
3622 (gLMSRespawn
= LMS_RESPAWN_NONE
) then
3628 for i
:= Low(gPlayers
) to High(gPlayers
) do
3630 if gPlayers
[i
] = nil then continue
;
3631 if (not gPlayers
[i
].FNoRespawn
) and (not gPlayers
[i
].FSpectator
) then
3634 if gPlayers
[i
].FTeam
= TEAM_RED
then Inc(ar
)
3635 else if gPlayers
[i
].FTeam
= TEAM_BLUE
then Inc(ab
);
3640 OldLR
:= gLMSRespawn
;
3641 if (gGameSettings
.GameMode
= GM_COOP
) then
3645 // everyone is dead, restart the map
3646 g_Game_Message(_lc
[I_MESSAGE_LMS_LOSE
], 144);
3648 MH_SEND_GameEvent(NET_EV_LMS_LOSE
);
3649 gLMSRespawn
:= LMS_RESPAWN_FINAL
;
3650 gLMSRespawnTime
:= gTime
+ 5000;
3652 else if (a
= 1) then
3654 if (gPlayers
[k
] <> nil) and not (gPlayers
[k
] is TBot
) then
3655 if (gPlayers
[k
] = gPlayer1
) or
3656 (gPlayers
[k
] = gPlayer2
) then
3657 g_Console_Add('*** ' + _lc
[I_MESSAGE_LMS_SURVIVOR
] + ' ***', True)
3658 else if Netsrv
and (gPlayers
[k
].FClientID
>= 0) then
3659 MH_SEND_GameEvent(NET_EV_LMS_SURVIVOR
, 0, 'N', gPlayers
[k
].FClientID
);
3662 else if (gGameSettings
.GameMode
= GM_TDM
) then
3664 if (ab
= 0) and (ar
<> 0) then
3667 g_Game_Message(Format(_lc
[I_MESSAGE_TLMS_WIN
], [AnsiUpperCase(_lc
[I_GAME_TEAM_RED
])]), 144);
3669 MH_SEND_GameEvent(NET_EV_TLMS_WIN
, TEAM_RED
);
3670 Inc(gTeamStat
[TEAM_RED
].Goals
);
3671 gLMSRespawn
:= LMS_RESPAWN_FINAL
;
3672 gLMSRespawnTime
:= gTime
+ 5000;
3674 else if (ar
= 0) and (ab
<> 0) then
3677 g_Game_Message(Format(_lc
[I_MESSAGE_TLMS_WIN
], [AnsiUpperCase(_lc
[I_GAME_TEAM_BLUE
])]), 144);
3679 MH_SEND_GameEvent(NET_EV_TLMS_WIN
, TEAM_BLUE
);
3680 Inc(gTeamStat
[TEAM_BLUE
].Goals
);
3681 gLMSRespawn
:= LMS_RESPAWN_FINAL
;
3682 gLMSRespawnTime
:= gTime
+ 5000;
3684 else if (ar
= 0) and (ab
= 0) then
3687 g_Game_Message(_lc
[I_GAME_WIN_DRAW
], 144);
3689 MH_SEND_GameEvent(NET_EV_LMS_DRAW
, 0, FName
);
3690 gLMSRespawn
:= LMS_RESPAWN_FINAL
;
3691 gLMSRespawnTime
:= gTime
+ 5000;
3694 else if (gGameSettings
.GameMode
= GM_DM
) then
3698 if gPlayers
[k
] <> nil then
3701 // survivor is the winner
3702 g_Game_Message(Format(_lc
[I_MESSAGE_LMS_WIN
], [AnsiUpperCase(FName
)]), 144);
3704 MH_SEND_GameEvent(NET_EV_LMS_WIN
, 0, FName
);
3707 gLMSRespawn
:= LMS_RESPAWN_FINAL
;
3708 gLMSRespawnTime
:= gTime
+ 5000;
3710 else if (a
= 0) then
3712 // everyone is dead, restart the map
3713 g_Game_Message(_lc
[I_GAME_WIN_DRAW
], 144);
3715 MH_SEND_GameEvent(NET_EV_LMS_DRAW
, 0, FName
);
3716 gLMSRespawn
:= LMS_RESPAWN_FINAL
;
3717 gLMSRespawnTime
:= gTime
+ 5000;
3720 if srv
and (OldLR
= LMS_RESPAWN_NONE
) and (gLMSRespawn
> LMS_RESPAWN_NONE
) then
3722 if NetMode
= NET_SERVER
then
3723 MH_SEND_GameEvent(NET_EV_LMS_WARMUP
, gLMSRespawnTime
- gTime
)
3725 g_Console_Add(Format(_lc
[I_MSG_WARMUP_START
], [(gLMSRespawnTime
- gTime
) div 1000]), True);
3731 MH_SEND_PlayerStats(FUID
);
3732 MH_SEND_PlayerDeath(FUID
, KillType
, t
, SpawnerUID
);
3733 if gGameSettings
.GameMode
= GM_TDM
then MH_SEND_GameStats
;
3736 if srv
and FNoRespawn
then Spectate(True);
3737 FWantsInGame
:= True;
3740 function TPlayer
.BodyInLiquid(XInc
, YInc
: Integer): Boolean;
3742 Result
:= g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
, PLAYER_RECT
.Width
,
3743 PLAYER_RECT
.Height
-20, PANEL_WATER
or PANEL_ACID1
or PANEL_ACID2
, False);
3746 function TPlayer
.BodyInAcid(XInc
, YInc
: Integer): Boolean;
3748 Result
:= g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
, PLAYER_RECT
.Width
,
3749 PLAYER_RECT
.Height
-20, PANEL_ACID1
or PANEL_ACID2
, False);
3752 procedure TPlayer
.MakeBloodSimple(Count
: Word);
3754 g_GFX_Blood(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)+8,
3755 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2),
3756 Count
div 2, 3, -1, 16, (PLAYER_RECT
.Height
*2 div 3),
3757 FModel
.Blood
.R
, FModel
.Blood
.G
, FModel
.Blood
.B
, FModel
.Blood
.Kind
);
3758 g_GFX_Blood(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-8,
3759 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2),
3760 Count
div 2, -3, -1, 16, (PLAYER_RECT
.Height
*2) div 3,
3761 FModel
.Blood
.R
, FModel
.Blood
.G
, FModel
.Blood
.B
, FModel
.Blood
.Kind
);
3764 procedure TPlayer
.MakeBloodVector(Count
: Word; VelX
, VelY
: Integer);
3766 g_GFX_Blood(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2),
3767 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2),
3768 Count
, VelX
, VelY
, 16, (PLAYER_RECT
.Height
*2) div 3,
3769 FModel
.Blood
.R
, FModel
.Blood
.G
, FModel
.Blood
.B
, FModel
.Blood
.Kind
);
3772 procedure TPlayer
.ProcessWeaponAction(Action
: Byte);
3774 if g_Game_IsClient
then Exit
;
3776 WP_PREV
: PrevWeapon();
3777 WP_NEXT
: NextWeapon();
3781 procedure TPlayer
.QueueWeaponSwitch(Weapon
: Byte);
3783 if g_Game_IsClient
then Exit
;
3784 if Weapon
> High(FWeapon
) then Exit
;
3785 FNextWeap
:= FNextWeap
or (1 shl Weapon
);
3788 procedure TPlayer
.resetWeaponQueue ();
3791 FNextWeapDelay
:= 0;
3794 function TPlayer
.hasAmmoForWeapon (weapon
: Byte): Boolean;
3798 WEAPON_KASTET
, WEAPON_SAW
: result
:= true;
3799 WEAPON_SHOTGUN1
, WEAPON_SHOTGUN2
, WEAPON_SUPERPULEMET
: result
:= (FAmmo
[A_SHELLS
] > 0);
3800 WEAPON_PISTOL
, WEAPON_CHAINGUN
: result
:= (FAmmo
[A_BULLETS
] > 0);
3801 WEAPON_ROCKETLAUNCHER
: result
:= (FAmmo
[A_ROCKETS
] > 0);
3802 WEAPON_PLASMA
, WEAPON_BFG
: result
:= (FAmmo
[A_CELLS
] > 0);
3803 WEAPON_FLAMETHROWER
: result
:= (FAmmo
[A_FUEL
] > 0);
3804 else result
:= (weapon
< length(FWeapon
));
3808 function TPlayer
.hasAmmoForShooting (weapon
: Byte): Boolean;
3812 WEAPON_KASTET
, WEAPON_SAW
: result
:= true;
3813 WEAPON_SHOTGUN1
, WEAPON_SUPERPULEMET
: result
:= (FAmmo
[A_SHELLS
] > 0);
3814 WEAPON_SHOTGUN2
: result
:= (FAmmo
[A_SHELLS
] > 1);
3815 WEAPON_PISTOL
, WEAPON_CHAINGUN
: result
:= (FAmmo
[A_BULLETS
] > 0);
3816 WEAPON_ROCKETLAUNCHER
: result
:= (FAmmo
[A_ROCKETS
] > 0);
3817 WEAPON_PLASMA
: result
:= (FAmmo
[A_CELLS
] > 0);
3818 WEAPON_BFG
: result
:= (FAmmo
[A_CELLS
] >= 40);
3819 WEAPON_FLAMETHROWER
: result
:= (FAmmo
[A_FUEL
] > 0);
3820 else result
:= (weapon
< length(FWeapon
));
3824 function TPlayer
.shouldSwitch (weapon
: Byte; hadWeapon
: Boolean): Boolean;
3827 if (weapon
> WP_LAST
+ 1) then
3832 if (FWeapSwitchMode
= 1) and not hadWeapon
then
3834 else if (FWeapSwitchMode
= 2) then
3835 result
:= (FWeapPreferences
[weapon
] > FWeapPreferences
[FCurrWeap
]);
3838 // return 255 for "no switch"
3839 function TPlayer
.getNextWeaponIndex (): Byte;
3842 wantThisWeapon
: array[0..64] of Boolean;
3843 wwc
: Integer = 0; //HACK!
3846 result
:= 255; // default result: "no switch"
3847 //e_LogWriteFln('FSWITCHTOEMPTY: %s', [FSwitchToEmpty], TMsgType.Notify);
3848 // had weapon cycling on previous frame? remove that flag
3849 if (FNextWeap
and $2000) <> 0 then
3851 FNextWeap
:= FNextWeap
and $1FFF;
3852 FNextWeapDelay
:= 0;
3854 // cycling has priority
3855 if (FNextWeap
and $C000) <> 0 then
3857 if (FNextWeap
and $8000) <> 0 then
3861 FNextWeap
:= FNextWeap
or $2000; // we need this
3862 if FNextWeapDelay
> 0 then
3863 exit
; // cooldown time
3865 for i
:= 0 to High(FWeapon
) do
3867 cwi
:= (cwi
+length(FWeapon
)+dir
) mod length(FWeapon
);
3868 if FWeapon
[cwi
] and maySwitch(cwi
) then
3870 //e_LogWriteFln(' SWITCH: cur=%d; new=%d %s %s', [FCurrWeap, cwi, FSwitchToEmpty, hasAmmoForWeapon(cwi)], TMsgType.Notify);
3871 result
:= Byte(cwi
);
3872 FNextWeapDelay
:= WEAPON_DELAY
;
3880 for i
:= 0 to High(wantThisWeapon
) do
3881 wantThisWeapon
[i
] := false;
3882 for i
:= 0 to High(FWeapon
) do
3883 if (FNextWeap
and (1 shl i
)) <> 0 then
3885 wantThisWeapon
[i
] := true;
3889 // exclude currently selected weapon from the set
3890 wantThisWeapon
[FCurrWeap
] := false;
3891 // slow down alterations a little
3894 //e_WriteLog(Format(' FNextWeap=%x; delay=%d', [FNextWeap, FNextWeapDelay]), MSG_WARNING);
3895 // more than one weapon requested, assume "alteration" and check alteration delay
3896 if FNextWeapDelay
> 0 then
3902 // do not reset weapon queue, it will be done in `RealizeCurrentWeapon()`
3903 // but clear all counters if no weapon should be switched
3909 //e_WriteLog(Format('wwc=%d', [wwc]), MSG_WARNING);
3910 // try weapons in descending order
3911 for i
:= High(FWeapon
) downto 0 do
3913 if wantThisWeapon
[i
] and FWeapon
[i
] and ((wwc
= 1) or hasAmmoForWeapon(i
)) then
3918 FNextWeapDelay
:= WEAPON_DELAY
* 2; // anyway, 'cause why not
3919 //e_LogWriteFln('FOUND %s %s %s', [result, FSwitchToEmpty, hasAmmoForWeapon(i)], TMsgType.Notify);
3923 // no suitable weapon found, so reset the queue, to avoid accidental "queuing" of weapon w/o ammo
3927 procedure TPlayer
.RealizeCurrentWeapon();
3928 function switchAllowed (): Boolean;
3933 if FBFGFireCounter
<> -1 then
3935 if FTime
[T_SWITCH
] > gTime
then
3937 for i
:= WP_FIRST
to WP_LAST
do
3938 if FReloading
[i
] > 0 then
3946 //e_WriteLog(Format('***RealizeCurrentWeapon: FNextWeap=%x; FNextWeapDelay=%d', [FNextWeap, FNextWeapDelay]), MSG_WARNING);
3947 //FNextWeap := FNextWeap and $1FFF;
3948 if FNextWeapDelay
> 0 then Dec(FNextWeapDelay
); // "alteration delay"
3950 if not switchAllowed
then
3952 //HACK for weapon cycling
3953 if (FNextWeap
and $E000) <> 0 then FNextWeap
:= 0;
3957 nw
:= getNextWeaponIndex();
3959 if nw
= 255 then exit
; // don't reset anything here
3960 if nw
> High(FWeapon
) then
3962 // don't forget to reset queue here!
3963 //e_WriteLog(' RealizeCurrentWeapon: WUTAFUUUU', MSG_WARNING);
3971 FTime
[T_SWITCH
] := gTime
+156;
3972 if FCurrWeap
= WEAPON_SAW
then FSawSoundSelect
.PlayAt(FObj
.X
, FObj
.Y
);
3973 FModel
.SetWeapon(FCurrWeap
);
3974 if g_Game_IsNet
then MH_SEND_PlayerStats(FUID
);
3978 procedure TPlayer
.NextWeapon();
3980 if g_Game_IsClient
then Exit
;
3984 procedure TPlayer
.PrevWeapon();
3986 if g_Game_IsClient
then Exit
;
3990 procedure TPlayer
.SetWeapon(W
: Byte);
3992 if FCurrWeap
<> W
then
3993 if W
= WEAPON_SAW
then
3994 FSawSoundSelect
.PlayAt(FObj
.X
, FObj
.Y
);
3997 FModel
.SetWeapon(CurrWeap
);
4001 function TPlayer
.PickItem(ItemType
: Byte; arespawn
: Boolean; var remove
: Boolean): Boolean;
4004 switchWeapon
: Byte = 255;
4005 hadWeapon
: Boolean = False;
4008 if g_Game_IsClient
then Exit
;
4010 // a = true - ìåñòî ñïàâíà ïðåäìåòà:
4011 a
:= LongBool(gGameSettings
.Options
and GAME_OPTION_WEAPONSTAY
) and arespawn
;
4015 if (FHealth
< PLAYER_HP_SOFT
) or (FFireTime
> 0) then
4017 if FHealth
< PLAYER_HP_SOFT
then IncMax(FHealth
, 10, PLAYER_HP_SOFT
);
4021 if gFlash
= 2 then Inc(FPickup
, 5);
4025 if (FHealth
< PLAYER_HP_SOFT
) or (FFireTime
> 0) then
4027 if FHealth
< PLAYER_HP_SOFT
then IncMax(FHealth
, 25, PLAYER_HP_SOFT
);
4031 if gFlash
= 2 then Inc(FPickup
, 5);
4035 if FArmor
< PLAYER_AP_SOFT
then
4037 FArmor
:= PLAYER_AP_SOFT
;
4040 if gFlash
= 2 then Inc(FPickup
, 5);
4044 if FArmor
< PLAYER_AP_LIMIT
then
4046 FArmor
:= PLAYER_AP_LIMIT
;
4049 if gFlash
= 2 then Inc(FPickup
, 5);
4053 if (FHealth
< PLAYER_HP_LIMIT
) or (FFireTime
> 0) then
4055 if FHealth
< PLAYER_HP_LIMIT
then IncMax(FHealth
, 100, PLAYER_HP_LIMIT
);
4059 if gFlash
= 2 then Inc(FPickup
, 5);
4063 if (FHealth
< PLAYER_HP_LIMIT
) or (FArmor
< PLAYER_AP_LIMIT
) or (FFireTime
> 0) then
4065 if FHealth
< PLAYER_HP_LIMIT
then
4066 FHealth
:= PLAYER_HP_LIMIT
;
4067 if FArmor
< PLAYER_AP_LIMIT
then
4068 FArmor
:= PLAYER_AP_LIMIT
;
4072 if gFlash
= 2 then Inc(FPickup
, 5);
4076 if (not FWeapon
[WEAPON_SAW
]) or ((not arespawn
) and (gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
])) then
4078 hadWeapon
:= FWeapon
[WEAPON_SAW
];
4079 switchWeapon
:= WEAPON_SAW
;
4080 FWeapon
[WEAPON_SAW
] := True;
4082 if gFlash
= 2 then Inc(FPickup
, 5);
4083 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
4086 ITEM_WEAPON_SHOTGUN1
:
4087 if (FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
]) or not FWeapon
[WEAPON_SHOTGUN1
] then
4089 // Íóæíî, ÷òîáû íå âçÿòü âñå ïóëè ñðàçó:
4090 if a
and FWeapon
[WEAPON_SHOTGUN1
] then Exit
;
4091 hadWeapon
:= FWeapon
[WEAPON_SHOTGUN1
];
4092 switchWeapon
:= WEAPON_SHOTGUN1
;
4093 IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
4094 FWeapon
[WEAPON_SHOTGUN1
] := 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');
4100 ITEM_WEAPON_SHOTGUN2
:
4101 if (FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
]) or not FWeapon
[WEAPON_SHOTGUN2
] then
4103 if a
and FWeapon
[WEAPON_SHOTGUN2
] then Exit
;
4104 hadWeapon
:= FWeapon
[WEAPON_SHOTGUN2
];
4105 switchWeapon
:= WEAPON_SHOTGUN2
;
4106 IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
4107 FWeapon
[WEAPON_SHOTGUN2
] := True;
4109 if gFlash
= 2 then Inc(FPickup
, 5);
4110 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
4113 ITEM_WEAPON_CHAINGUN
:
4114 if (FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
]) or not FWeapon
[WEAPON_CHAINGUN
] then
4116 if a
and FWeapon
[WEAPON_CHAINGUN
] then Exit
;
4117 hadWeapon
:= FWeapon
[WEAPON_CHAINGUN
];
4118 switchWeapon
:= WEAPON_CHAINGUN
;
4119 IncMax(FAmmo
[A_BULLETS
], 50, FMaxAmmo
[A_BULLETS
]);
4120 FWeapon
[WEAPON_CHAINGUN
] := True;
4122 if gFlash
= 2 then Inc(FPickup
, 5);
4123 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
4126 ITEM_WEAPON_ROCKETLAUNCHER
:
4127 if (FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
]) or not FWeapon
[WEAPON_ROCKETLAUNCHER
] then
4129 if a
and FWeapon
[WEAPON_ROCKETLAUNCHER
] then Exit
;
4130 switchWeapon
:= WEAPON_ROCKETLAUNCHER
;
4131 hadWeapon
:= FWeapon
[WEAPON_ROCKETLAUNCHER
];
4132 IncMax(FAmmo
[A_ROCKETS
], 2, FMaxAmmo
[A_ROCKETS
]);
4133 FWeapon
[WEAPON_ROCKETLAUNCHER
] := True;
4135 if gFlash
= 2 then Inc(FPickup
, 5);
4136 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
4140 if (FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
]) or not FWeapon
[WEAPON_PLASMA
] then
4142 if a
and FWeapon
[WEAPON_PLASMA
] then Exit
;
4143 switchWeapon
:= WEAPON_PLASMA
;
4144 hadWeapon
:= FWeapon
[WEAPON_PLASMA
];
4145 IncMax(FAmmo
[A_CELLS
], 40, FMaxAmmo
[A_CELLS
]);
4146 FWeapon
[WEAPON_PLASMA
] := True;
4148 if gFlash
= 2 then Inc(FPickup
, 5);
4149 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
4153 if (FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
]) or not FWeapon
[WEAPON_BFG
] then
4155 if a
and FWeapon
[WEAPON_BFG
] then Exit
;
4156 switchWeapon
:= WEAPON_BFG
;
4157 hadWeapon
:= FWeapon
[WEAPON_BFG
];
4158 IncMax(FAmmo
[A_CELLS
], 40, FMaxAmmo
[A_CELLS
]);
4159 FWeapon
[WEAPON_BFG
] := True;
4161 if gFlash
= 2 then Inc(FPickup
, 5);
4162 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
4165 ITEM_WEAPON_SUPERPULEMET
:
4166 if (FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
]) or not FWeapon
[WEAPON_SUPERPULEMET
] then
4168 if a
and FWeapon
[WEAPON_SUPERPULEMET
] then Exit
;
4169 switchWeapon
:= WEAPON_SUPERPULEMET
;
4170 hadWeapon
:= FWeapon
[WEAPON_SUPERPULEMET
];
4171 IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
4172 FWeapon
[WEAPON_SUPERPULEMET
] := True;
4174 if gFlash
= 2 then Inc(FPickup
, 5);
4175 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
4178 ITEM_WEAPON_FLAMETHROWER
:
4179 if (FAmmo
[A_FUEL
] < FMaxAmmo
[A_FUEL
]) or not FWeapon
[WEAPON_FLAMETHROWER
] then
4181 if a
and FWeapon
[WEAPON_FLAMETHROWER
] then Exit
;
4182 switchWeapon
:= WEAPON_FLAMETHROWER
;
4183 hadWeapon
:= FWeapon
[WEAPON_FLAMETHROWER
];
4184 IncMax(FAmmo
[A_FUEL
], 100, FMaxAmmo
[A_FUEL
]);
4185 FWeapon
[WEAPON_FLAMETHROWER
] := True;
4187 if gFlash
= 2 then Inc(FPickup
, 5);
4188 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
4192 if FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
] then
4194 IncMax(FAmmo
[A_BULLETS
], 10, FMaxAmmo
[A_BULLETS
]);
4197 if gFlash
= 2 then Inc(FPickup
, 5);
4200 ITEM_AMMO_BULLETS_BOX
:
4201 if FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
] then
4203 IncMax(FAmmo
[A_BULLETS
], 50, FMaxAmmo
[A_BULLETS
]);
4206 if gFlash
= 2 then Inc(FPickup
, 5);
4210 if FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
] then
4212 IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
4215 if gFlash
= 2 then Inc(FPickup
, 5);
4218 ITEM_AMMO_SHELLS_BOX
:
4219 if FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
] then
4221 IncMax(FAmmo
[A_SHELLS
], 25, FMaxAmmo
[A_SHELLS
]);
4224 if gFlash
= 2 then Inc(FPickup
, 5);
4228 if FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
] then
4230 IncMax(FAmmo
[A_ROCKETS
], 1, FMaxAmmo
[A_ROCKETS
]);
4233 if gFlash
= 2 then Inc(FPickup
, 5);
4236 ITEM_AMMO_ROCKET_BOX
:
4237 if FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
] then
4239 IncMax(FAmmo
[A_ROCKETS
], 5, FMaxAmmo
[A_ROCKETS
]);
4242 if gFlash
= 2 then Inc(FPickup
, 5);
4246 if FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
] then
4248 IncMax(FAmmo
[A_CELLS
], 40, FMaxAmmo
[A_CELLS
]);
4251 if gFlash
= 2 then Inc(FPickup
, 5);
4255 if FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
] then
4257 IncMax(FAmmo
[A_CELLS
], 100, FMaxAmmo
[A_CELLS
]);
4260 if gFlash
= 2 then Inc(FPickup
, 5);
4264 if FAmmo
[A_FUEL
] < FMaxAmmo
[A_FUEL
] then
4266 IncMax(FAmmo
[A_FUEL
], 100, FMaxAmmo
[A_FUEL
]);
4269 if gFlash
= 2 then Inc(FPickup
, 5);
4273 if not(R_ITEM_BACKPACK
in FRulez
) or
4274 (FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
]) or
4275 (FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
]) or
4276 (FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
]) or
4277 (FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
]) or
4278 (FAmmo
[A_FUEL
] < FMaxAmmo
[A_FUEL
]) then
4280 FMaxAmmo
[A_BULLETS
] := AmmoLimits
[1, A_BULLETS
];
4281 FMaxAmmo
[A_SHELLS
] := AmmoLimits
[1, A_SHELLS
];
4282 FMaxAmmo
[A_ROCKETS
] := AmmoLimits
[1, A_ROCKETS
];
4283 FMaxAmmo
[A_CELLS
] := AmmoLimits
[1, A_CELLS
];
4284 FMaxAmmo
[A_FUEL
] := AmmoLimits
[1, A_FUEL
];
4286 if FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
] then
4287 IncMax(FAmmo
[A_BULLETS
], 10, FMaxAmmo
[A_BULLETS
]);
4288 if FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
] then
4289 IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
4290 if FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
] then
4291 IncMax(FAmmo
[A_ROCKETS
], 1, FMaxAmmo
[A_ROCKETS
]);
4292 if FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
] then
4293 IncMax(FAmmo
[A_CELLS
], 40, FMaxAmmo
[A_CELLS
]);
4294 if FAmmo
[A_FUEL
] < FMaxAmmo
[A_FUEL
] then
4295 IncMax(FAmmo
[A_FUEL
], 50, FMaxAmmo
[A_FUEL
]);
4297 FRulez
:= FRulez
+ [R_ITEM_BACKPACK
];
4300 if gFlash
= 2 then Inc(FPickup
, 5);
4304 if not(R_KEY_RED
in FRulez
) then
4306 Include(FRulez
, R_KEY_RED
);
4308 remove
:= (gGameSettings
.GameMode
<> GM_COOP
) and (g_Player_GetCount() < 2);
4309 if gFlash
= 2 then Inc(FPickup
, 5);
4310 if (not remove
) and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETITEM');
4314 if not(R_KEY_GREEN
in FRulez
) then
4316 Include(FRulez
, R_KEY_GREEN
);
4318 remove
:= (gGameSettings
.GameMode
<> GM_COOP
) and (g_Player_GetCount() < 2);
4319 if gFlash
= 2 then Inc(FPickup
, 5);
4320 if (not remove
) and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETITEM');
4324 if not(R_KEY_BLUE
in FRulez
) then
4326 Include(FRulez
, R_KEY_BLUE
);
4328 remove
:= (gGameSettings
.GameMode
<> GM_COOP
) and (g_Player_GetCount() < 2);
4329 if gFlash
= 2 then Inc(FPickup
, 5);
4330 if (not remove
) and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETITEM');
4334 if FMegaRulez
[MR_SUIT
] < gTime
+PLAYER_SUIT_TIME
then
4336 FMegaRulez
[MR_SUIT
] := gTime
+PLAYER_SUIT_TIME
;
4340 if gFlash
= 2 then Inc(FPickup
, 5);
4344 if FAir
< AIR_MAX
then
4349 if gFlash
= 2 then Inc(FPickup
, 5);
4354 if not (R_BERSERK
in FRulez
) then
4356 Include(FRulez
, R_BERSERK
);
4357 if (FBFGFireCounter
= -1) then
4359 FCurrWeap
:= WEAPON_KASTET
;
4361 FModel
.SetWeapon(WEAPON_KASTET
);
4366 if gFlash
= 2 then Inc(FPickup
, 5);
4368 FBerserk
:= gTime
+30000;
4373 if (FHealth
< PLAYER_HP_SOFT
) or (FFireTime
> 0) then
4375 if FHealth
< PLAYER_HP_SOFT
then FHealth
:= PLAYER_HP_SOFT
;
4376 FBerserk
:= gTime
+30000;
4384 if FMegaRulez
[MR_INVUL
] < gTime
+PLAYER_INVUL_TIME
then
4386 FMegaRulez
[MR_INVUL
] := gTime
+PLAYER_INVUL_TIME
;
4390 if gFlash
= 2 then Inc(FPickup
, 5);
4394 if (FHealth
< PLAYER_HP_LIMIT
) or (FFireTime
> 0) then
4396 if FHealth
< PLAYER_HP_LIMIT
then IncMax(FHealth
, 4, PLAYER_HP_LIMIT
);
4400 if gFlash
= 2 then Inc(FPickup
, 5);
4404 if FArmor
< PLAYER_AP_LIMIT
then
4406 IncMax(FArmor
, 5, PLAYER_AP_LIMIT
);
4409 if gFlash
= 2 then Inc(FPickup
, 5);
4413 if FJetFuel
< JET_MAX
then
4415 FJetFuel
:= JET_MAX
;
4418 if gFlash
= 2 then Inc(FPickup
, 5);
4422 if FMegaRulez
[MR_INVIS
] < gTime
+PLAYER_INVIS_TIME
then
4424 FMegaRulez
[MR_INVIS
] := gTime
+PLAYER_INVIS_TIME
;
4427 if gFlash
= 2 then Inc(FPickup
, 5);
4431 if (shouldSwitch(switchWeapon
, hadWeapon
)) then
4432 QueueWeaponSwitch(switchWeapon
);
4435 procedure TPlayer
.Touch();
4439 //FModel.PlaySound(MODELSOUND_PAIN, 1, FObj.X, FObj.Y);
4442 // Áðîñèòü ôëàã òîâàðèùó:
4443 if gGameSettings
.GameMode
= GM_CTF
then
4448 procedure TPlayer
.Push(vx
, vy
: Integer);
4450 if (not FPhysics
) and FGhost
then
4452 FObj
.Accel
.X
:= FObj
.Accel
.X
+ vx
;
4453 FObj
.Accel
.Y
:= FObj
.Accel
.Y
+ vy
;
4454 if g_Game_IsNet
and g_Game_IsServer
then
4455 MH_SEND_PlayerPos(True, FUID
, NET_EVERYONE
);
4458 procedure TPlayer
.Reset(Force
: Boolean);
4464 FTime
[T_RESPAWN
] := 0;
4465 FTime
[T_FLAGCAP
] := 0;
4481 FSpectator
:= False;
4484 FSpectatePlayer
:= -1;
4485 FNoRespawn
:= False;
4487 FLives
:= gGameSettings
.MaxLives
;
4492 procedure TPlayer
.SoftReset();
4500 FBFGFireCounter
:= -1;
4508 SetAction(A_STAND
, True);
4511 function TPlayer
.GetRespawnPoint(): Byte;
4516 // Íà áóäóùåå: FSpawn - èãðîê óæå èãðàë è ïåðåðîæäàåòñÿ
4518 // Îäèíî÷íàÿ èãðà/êîîïåðàòèâ
4519 if gGameSettings
.GameMode
in [GM_COOP
, GM_SINGLE
] then
4521 if Self
= gPlayer1
then
4523 // player 1 should try to spawn on the player 1 point
4524 if g_Map_GetPointCount(RESPAWNPOINT_PLAYER1
) > 0 then
4525 Exit(RESPAWNPOINT_PLAYER1
)
4526 else if g_Map_GetPointCount(RESPAWNPOINT_PLAYER2
) > 0 then
4527 Exit(RESPAWNPOINT_PLAYER2
);
4529 else if Self
= gPlayer2
then
4531 // player 2 should try to spawn on the player 2 point
4532 if g_Map_GetPointCount(RESPAWNPOINT_PLAYER2
) > 0 then
4533 Exit(RESPAWNPOINT_PLAYER2
)
4534 else if g_Map_GetPointCount(RESPAWNPOINT_PLAYER1
) > 0 then
4535 Exit(RESPAWNPOINT_PLAYER1
);
4539 // other players randomly pick either the first or the second point
4540 c
:= IfThen((Random(2) = 0), RESPAWNPOINT_PLAYER1
, RESPAWNPOINT_PLAYER2
);
4541 if g_Map_GetPointCount(c
) > 0 then
4543 // try the other one
4544 c
:= IfThen((c
= RESPAWNPOINT_PLAYER1
), RESPAWNPOINT_PLAYER2
, RESPAWNPOINT_PLAYER1
);
4545 if g_Map_GetPointCount(c
) > 0 then
4551 if gGameSettings
.GameMode
= GM_DM
then
4553 // try DM points first
4554 if g_Map_GetPointCount(RESPAWNPOINT_DM
) > 0 then
4555 Exit(RESPAWNPOINT_DM
);
4559 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
4561 // try team points first
4562 c
:= RESPAWNPOINT_DM
;
4563 if FTeam
= TEAM_RED
then
4564 c
:= RESPAWNPOINT_RED
4565 else if FTeam
= TEAM_BLUE
then
4566 c
:= RESPAWNPOINT_BLUE
;
4567 if g_Map_GetPointCount(c
) > 0 then
4571 // still haven't found a spawnpoint, try random shit
4572 Result
:= g_Map_GetRandomPointType();
4575 procedure TPlayer
.Respawn(Silent
: Boolean; Force
: Boolean = False);
4577 RespawnPoint
: TRespawnPoint
;
4585 FBFGFireCounter
:= -1;
4592 if not g_Game_IsServer
then
4596 FWantsInGame
:= True;
4597 FJustTeleported
:= True;
4600 FTime
[T_RESPAWN
] := 0;
4604 // if server changes MaxLives we gotta be ready
4605 if gGameSettings
.MaxLives
= 0 then FNoRespawn
:= False;
4607 // Åùå íåëüçÿ âîçðîäèòüñÿ:
4608 if FTime
[T_RESPAWN
] > gTime
then
4611 // Ïðîñðàë âñå æèçíè:
4614 if not FSpectator
then Spectate(True);
4615 FWantsInGame
:= True;
4619 if (gGameSettings
.GameType
<> GT_SINGLE
) and (gGameSettings
.GameMode
<> GM_COOP
) then
4620 begin // "Ñâîÿ èãðà"
4621 // Áåðñåðê íå ñîõðàíÿåòñÿ ìåæäó óðîâíÿìè:
4622 FRulez
:= FRulez
-[R_BERSERK
];
4624 else // "Îäèíî÷íàÿ èãðà"/"Êîîï"
4626 // Áåðñåðê è êëþ÷è íå ñîõðàíÿþòñÿ ìåæäó óðîâíÿìè:
4627 FRulez
:= FRulez
-[R_KEY_RED
, R_KEY_GREEN
, R_KEY_BLUE
, R_BERSERK
];
4630 // Ïîëó÷àåì òî÷êó ñïàóíà èãðîêà:
4631 c
:= GetRespawnPoint();
4636 // Âîñêðåøåíèå áåç îðóæèÿ:
4639 FHealth
:= Round(PLAYER_HP_SOFT
* (FHandicap
/ 100));
4645 for a
:= WP_FIRST
to WP_LAST
do
4647 FWeapon
[a
] := False;
4651 FWeapon
[WEAPON_PISTOL
] := True;
4652 FWeapon
[WEAPON_KASTET
] := True;
4653 FCurrWeap
:= WEAPON_PISTOL
;
4656 FModel
.SetWeapon(FCurrWeap
);
4658 for b
:= A_BULLETS
to A_HIGH
do
4661 FAmmo
[A_BULLETS
] := 50;
4663 FMaxAmmo
[A_BULLETS
] := AmmoLimits
[0, A_BULLETS
];
4664 FMaxAmmo
[A_SHELLS
] := AmmoLimits
[0, A_SHELLS
];
4665 FMaxAmmo
[A_ROCKETS
] := AmmoLimits
[0, A_SHELLS
];
4666 FMaxAmmo
[A_CELLS
] := AmmoLimits
[0, A_CELLS
];
4667 FMaxAmmo
[A_FUEL
] := AmmoLimits
[0, A_FUEL
];
4669 if (gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
]) and
4670 LongBool(gGameSettings
.Options
and GAME_OPTION_DMKEYS
) then
4671 FRulez
:= [R_KEY_RED
, R_KEY_GREEN
, R_KEY_BLUE
]
4676 // Ïîëó÷àåì êîîðäèíàòû òî÷êè âîçðîæäåíèÿ:
4677 if not g_Map_GetPoint(c
, RespawnPoint
) then
4679 g_FatalError(_lc
[I_GAME_ERROR_GET_SPAWN
]);
4683 // Óñòàíîâêà êîîðäèíàò è ñáðîñ âñåõ ïàðàìåòðîâ:
4684 FObj
.X
:= RespawnPoint
.X
-PLAYER_RECT
.X
;
4685 FObj
.Y
:= RespawnPoint
.Y
-PLAYER_RECT
.Y
;
4686 FObj
.oldX
:= FObj
.X
; // don't interpolate after respawn
4687 FObj
.oldY
:= FObj
.Y
;
4693 FDirection
:= RespawnPoint
.Direction
;
4694 if FDirection
= TDirection
.D_LEFT
then
4699 SetAction(A_STAND
, True);
4700 FModel
.Direction
:= FDirection
;
4702 for a
:= Low(FTime
) to High(FTime
) do
4705 for a
:= Low(FMegaRulez
) to High(FMegaRulez
) do
4708 // Respawn invulnerability
4709 if (gGameSettings
.GameType
<> GT_SINGLE
) and (gGameSettings
.SpawnInvul
> 0) then
4711 FMegaRulez
[MR_INVUL
] := gTime
+ gGameSettings
.SpawnInvul
* 1000;
4712 FSpawnInvul
:= FMegaRulez
[MR_INVUL
];
4717 FCanJetpack
:= False;
4723 // Àíèìàöèÿ âîçðîæäåíèÿ:
4724 if (not gLoadGameMode
) and (not Silent
) then
4725 if g_Frames_Get(ID
, 'FRAMES_TELEPORT') then
4727 Anim
:= TAnimation
.Create(ID
, False, 3);
4728 g_GFX_OnceAnim(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-32,
4729 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)-32, Anim
);
4733 FSpectator
:= False;
4736 FSpectatePlayer
:= -1;
4739 if (gPlayer1
= nil) and (gSpectLatchPID1
= FUID
) then
4741 if (gPlayer2
= nil) and (gSpectLatchPID2
= FUID
) then
4744 if g_Game_IsNet
then
4746 MH_SEND_PlayerPos(True, FUID
, NET_EVERYONE
);
4747 MH_SEND_PlayerStats(FUID
, NET_EVERYONE
);
4749 MH_SEND_Effect(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-32,
4750 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)-32,
4755 procedure TPlayer
.Spectate(NoMove
: Boolean = False);
4758 Kill(K_EXTRAHARDKILL
, FUID
, HIT_SOME
)
4759 else if (not NoMove
) then
4761 GameX
:= gMapInfo
.Width
div 2;
4762 GameY
:= gMapInfo
.Height
div 2;
4771 FWantsInGame
:= False;
4777 if Self
= gPlayer1
then
4779 gSpectLatchPID1
:= FUID
;
4782 else if Self
= gPlayer2
then
4784 gSpectLatchPID2
:= FUID
;
4789 if g_Game_IsNet
then
4790 MH_SEND_PlayerStats(FUID
);
4793 procedure TPlayer
.SwitchNoClip
;
4797 FGhost
:= not FGhost
;
4798 FPhysics
:= not FGhost
;
4810 procedure TPlayer
.Run(Direction
: TDirection
);
4814 if MAX_RUNVEL
> 8 then
4818 if Direction
= TDirection
.D_LEFT
then
4820 if FObj
.Vel
.X
> -MAX_RUNVEL
then
4821 FObj
.Vel
.X
:= FObj
.Vel
.X
- (MAX_RUNVEL
shr 3);
4824 if FObj
.Vel
.X
< MAX_RUNVEL
then
4825 FObj
.Vel
.X
:= FObj
.Vel
.X
+ (MAX_RUNVEL
shr 3);
4827 // Âîçìîæíî, ïèíàåì êóñêè:
4828 if (FObj
.Vel
.X
<> 0) and (gGibs
<> nil) then
4830 b
:= Abs(FObj
.Vel
.X
);
4831 if b
> 1 then b
:= b
* (Random(8 div b
) + 1);
4832 for a
:= 0 to High(gGibs
) do
4834 if gGibs
[a
].alive
and
4835 g_Obj_Collide(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
+FObj
.Rect
.Height
-4,
4836 FObj
.Rect
.Width
, 8, @gGibs
[a
].Obj
) and (Random(3) = 0) then
4839 if FObj
.Vel
.X
< 0 then
4841 g_Obj_PushA(@gGibs
[a
].Obj
, b
, Random(61)+120) // íàëåâî
4845 g_Obj_PushA(@gGibs
[a
].Obj
, b
, Random(61)); // íàïðàâî
4847 gGibs
[a
].positionChanged(); // this updates spatial accelerators
4855 procedure TPlayer
.SeeDown();
4857 SetAction(A_SEEDOWN
);
4859 if FDirection
= TDirection
.D_LEFT
then FAngle
:= ANGLE_LEFTDOWN
else FAngle
:= ANGLE_RIGHTDOWN
;
4861 if FIncCam
> -120 then DecMin(FIncCam
, 5, -120);
4864 procedure TPlayer
.SeeUp();
4868 if FDirection
= TDirection
.D_LEFT
then FAngle
:= ANGLE_LEFTUP
else FAngle
:= ANGLE_RIGHTUP
;
4870 if FIncCam
< 120 then IncMax(FIncCam
, 5, 120);
4873 procedure TPlayer
.SetAction(Action
: Byte; Force
: Boolean = False);
4881 A_ATTACK
: Prior
:= 2;
4882 A_SEEUP
: Prior
:= 1;
4883 A_SEEDOWN
: Prior
:= 1;
4884 A_ATTACKUP
: Prior
:= 2;
4885 A_ATTACKDOWN
: Prior
:= 2;
4890 if (Prior
> FActionPrior
) or Force
then
4891 if not ((Prior
= 2) and (FCurrWeap
= WEAPON_SAW
)) then
4893 FActionPrior
:= Prior
;
4894 FActionAnim
:= Action
;
4895 FActionForce
:= Force
;
4896 FActionChanged
:= True;
4899 if Action
in [A_ATTACK
, A_ATTACKUP
, A_ATTACKDOWN
] then FModel
.SetFire(True);
4902 function TPlayer
.StayOnStep(XInc
, YInc
: Integer): Boolean;
4904 Result
:= not g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+YInc
+PLAYER_RECT
.Y
+PLAYER_RECT
.Height
-1,
4905 PLAYER_RECT
.Width
, 1, PANEL_STEP
, False)
4906 and g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+YInc
+PLAYER_RECT
.Y
+PLAYER_RECT
.Height
,
4907 PLAYER_RECT
.Width
, 1, PANEL_STEP
, False);
4910 function TPlayer
.TeleportTo(X
, Y
: Integer; silent
: Boolean; dir
: Byte): Boolean;
4917 if g_CollideLevel(X
, Y
, PLAYER_RECT
.Width
, PLAYER_RECT
.Height
) then
4919 g_Sound_PlayExAt('SOUND_GAME_NOTELEPORT', FObj
.X
, FObj
.Y
);
4920 if g_Game_IsServer
and g_Game_IsNet
then
4921 MH_SEND_Sound(FObj
.X
, FObj
.Y
, 'SOUND_GAME_NOTELEPORT');
4925 FJustTeleported
:= True;
4930 if g_Frames_Get(ID
, 'FRAMES_TELEPORT') then
4932 Anim
:= TAnimation
.Create(ID
, False, 3);
4935 g_Sound_PlayExAt('SOUND_GAME_TELEPORT', FObj
.X
, FObj
.Y
);
4936 g_GFX_OnceAnim(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-32,
4937 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)-32, Anim
);
4938 if g_Game_IsServer
and g_Game_IsNet
then
4939 MH_SEND_Effect(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-32,
4940 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)-32, 1,
4944 FObj
.X
:= X
-PLAYER_RECT
.X
;
4945 FObj
.Y
:= Y
-PLAYER_RECT
.Y
;
4946 FObj
.oldX
:= FObj
.X
; // don't interpolate after respawn
4947 FObj
.oldY
:= FObj
.Y
;
4948 if FAlive
and FGhost
then
4954 if not g_Game_IsNet
then
4958 SetDirection(TDirection
.D_LEFT
);
4964 SetDirection(TDirection
.D_RIGHT
);
4970 if FDirection
= TDirection
.D_RIGHT
then
4972 SetDirection(TDirection
.D_LEFT
);
4977 SetDirection(TDirection
.D_RIGHT
);
4983 if not silent
and (Anim
<> nil) then
4985 g_GFX_OnceAnim(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-32,
4986 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)-32, Anim
);
4989 if g_Game_IsServer
and g_Game_IsNet
then
4990 MH_SEND_Effect(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-32,
4991 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)-32, 0,
4998 function nonz(a
: Single): Single;
5006 function TPlayer
.refreshCorpse(): Boolean;
5012 if FAlive
or FSpectator
then
5014 if (gCorpses
= nil) or (Length(gCorpses
) = 0) then
5016 for i
:= 0 to High(gCorpses
) do
5017 if gCorpses
[i
] <> nil then
5018 if gCorpses
[i
].FPlayerUID
= FUID
then
5026 function TPlayer
.getCameraObj(): TObj
;
5028 if (not FAlive
) and (not FSpectator
) and
5029 (FCorpse
>= 0) and (FCorpse
< Length(gCorpses
)) and
5030 (gCorpses
[FCorpse
] <> nil) and (gCorpses
[FCorpse
].FPlayerUID
= FUID
) then
5032 gCorpses
[FCorpse
].FObj
.slopeUpLeft
:= FObj
.slopeUpLeft
;
5033 Result
:= gCorpses
[FCorpse
].FObj
;
5041 procedure TPlayer
.PreUpdate();
5043 FSlopeOld
:= FObj
.slopeUpLeft
;
5044 FIncCamOld
:= FIncCam
;
5045 FObj
.oldX
:= FObj
.X
;
5046 FObj
.oldY
:= FObj
.Y
;
5049 procedure TPlayer
.Update();
5052 i
, ii
, wx
, wy
, xd
, yd
, k
: Integer;
5053 blockmon
, headwater
, dospawn
: Boolean;
5058 NetServer
:= g_Game_IsNet
and g_Game_IsServer
;
5059 AnyServer
:= g_Game_IsServer
;
5061 if g_Game_IsClient
and (NetInterpLevel
> 0) then
5062 DoLerp(NetInterpLevel
+ 1)
5068 if (FClientID
>= 0) and (NetClients
[FClientID
].Peer
<> nil) then
5070 FPing
:= NetClients
[FClientID
].Peer
^.lastRoundTripTime
;
5071 if NetClients
[FClientID
].Peer
^.packetsSent
> 0 then
5072 FLoss
:= Round(100*NetClients
[FClientID
].Peer
^.packetsLost
/NetClients
[FClientID
].Peer
^.packetsSent
)
5081 if FAlive
and (FPunchAnim
<> nil) then
5082 FPunchAnim
.Update();
5084 if FAlive
and (gFly
or FJetpack
) then
5087 if FDirection
= TDirection
.D_LEFT
then
5092 if FAlive
and (not FGhost
) then
5094 if FKeys
[KEY_UP
].Pressed
then
5096 if FKeys
[KEY_DOWN
].Pressed
then
5100 if (not (FKeys
[KEY_UP
].Pressed
or FKeys
[KEY_DOWN
].Pressed
)) and
5103 i
:= g_basic
.Sign(FIncCam
);
5104 FIncCam
:= Abs(FIncCam
);
5105 DecMin(FIncCam
, 5, 0);
5106 FIncCam
:= FIncCam
*i
;
5109 if gTime
mod (GAME_TICK
*2) <> 0 then
5111 if (FObj
.Vel
.X
= 0) and FAlive
then
5113 if FKeys
[KEY_LEFT
].Pressed
then
5114 Run(TDirection
.D_LEFT
);
5115 if FKeys
[KEY_RIGHT
].Pressed
then
5116 Run(TDirection
.D_RIGHT
);
5121 g_Obj_Move(@FObj
, True, True, True);
5122 positionChanged(); // this updates spatial accelerators
5128 FActionChanged
:= False;
5132 // Let alive player do some actions
5133 if FKeys
[KEY_LEFT
].Pressed
then Run(TDirection
.D_LEFT
);
5134 if FKeys
[KEY_RIGHT
].Pressed
then Run(TDirection
.D_RIGHT
);
5135 if FKeys
[KEY_FIRE
].Pressed
and AnyServer
then Fire()
5141 if NetServer
then MH_SEND_PlayerStats(FUID
);
5144 if FKeys
[KEY_OPEN
].Pressed
and AnyServer
then Use();
5145 if FKeys
[KEY_JUMP
].Pressed
then Jump()
5148 if AnyServer
and FJetpack
then
5152 if NetServer
then MH_SEND_PlayerStats(FUID
);
5154 FCanJetpack
:= True;
5161 for k
:= Low(FKeys
) to KEY_CHAT
-1 do
5163 if FKeys
[k
].Pressed
then
5171 if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
5174 if (FTime
[T_RESPAWN
] <= gTime
) and
5175 gGameOn
and (not FAlive
) then
5177 if (g_Player_GetCount() > 1) then
5181 gExit
:= EXIT_RESTART
;
5186 // Dead spectator actions
5189 if FKeys
[KEY_OPEN
].Pressed
and AnyServer
then Fire();
5190 if FKeys
[KEY_FIRE
].Pressed
and AnyServer
then
5194 if (FSpectatePlayer
>= High(gPlayers
)) then
5195 FSpectatePlayer
:= -1
5199 for I
:= FSpectatePlayer
+ 1 to High(gPlayers
) do
5200 if gPlayers
[I
] <> nil then
5201 if gPlayers
[I
].alive
then
5202 if gPlayers
[I
].UID
<> FUID
then
5204 FSpectatePlayer
:= I
;
5209 if not SetSpect
then FSpectatePlayer
:= -1;
5220 if FKeys
[KEY_UP
].Pressed
or FKeys
[KEY_JUMP
].Pressed
then
5222 FYTo
:= FObj
.Y
- 32;
5223 FSpectatePlayer
:= -1;
5225 if FKeys
[KEY_DOWN
].Pressed
then
5227 FYTo
:= FObj
.Y
+ 32;
5228 FSpectatePlayer
:= -1;
5230 if FKeys
[KEY_LEFT
].Pressed
then
5232 FXTo
:= FObj
.X
- 32;
5233 FSpectatePlayer
:= -1;
5235 if FKeys
[KEY_RIGHT
].Pressed
then
5237 FXTo
:= FObj
.X
+ 32;
5238 FSpectatePlayer
:= -1;
5241 if (FXTo
< -64) then
5243 else if (FXTo
> gMapInfo
.Width
+ 32) then
5244 FXTo
:= gMapInfo
.Width
+ 32;
5245 if (FYTo
< -72) then
5247 else if (FYTo
> gMapInfo
.Height
+ 32) then
5248 FYTo
:= gMapInfo
.Height
+ 32;
5253 g_Obj_Move(@FObj
, True, True, True);
5254 positionChanged(); // this updates spatial accelerators
5261 if (FSpectatePlayer
<= High(gPlayers
)) and (FSpectatePlayer
>= 0) then
5262 if gPlayers
[FSpectatePlayer
] <> nil then
5263 if gPlayers
[FSpectatePlayer
].alive
then
5265 FXTo
:= gPlayers
[FSpectatePlayer
].GameX
;
5266 FYTo
:= gPlayers
[FSpectatePlayer
].GameY
;
5270 blockmon
:= g_Map_CollidePanel(FObj
.X
+PLAYER_HEADRECT
.X
, FObj
.Y
+PLAYER_HEADRECT
.Y
,
5271 PLAYER_HEADRECT
.Width
, PLAYER_HEADRECT
.Height
,
5272 PANEL_BLOCKMON
, True);
5273 headwater
:= HeadInLiquid(0, 0);
5275 // Ñîïðîòèâëåíèå âîçäóõà:
5276 if (not FAlive
) or not (FKeys
[KEY_LEFT
].Pressed
or FKeys
[KEY_RIGHT
].Pressed
) then
5277 if FObj
.Vel
.X
<> 0 then
5278 FObj
.Vel
.X
:= z_dec(FObj
.Vel
.X
, 1);
5280 if (FLastHit
= HIT_TRAP
) and (FPain
> 90) then FPain
:= 90;
5281 DecMin(FPain
, 5, 0);
5282 DecMin(FPickup
, 1, 0);
5284 if FAlive
and (FObj
.Y
> Integer(gMapInfo
.Height
)+128) and AnyServer
then
5286 // Îáíóëèòü äåéñòâèÿ ïðèìî÷åê, ÷òîáû ôîí ïðîïàë
5287 FMegaRulez
[MR_SUIT
] := 0;
5288 FMegaRulez
[MR_INVUL
] := 0;
5289 FMegaRulez
[MR_INVIS
] := 0;
5290 Kill(K_FALLKILL
, 0, HIT_FALL
);
5297 if FCurrWeap
= WEAPON_SAW
then
5298 if not (FSawSound
.IsPlaying() or FSawSoundHit
.IsPlaying() or
5299 FSawSoundSelect
.IsPlaying()) then
5300 FSawSoundIdle
.PlayAt(FObj
.X
, FObj
.Y
);
5303 if (not FJetSoundFly
.IsPlaying()) and (not FJetSoundOn
.IsPlaying()) and
5304 (not FJetSoundOff
.IsPlaying()) then
5306 FJetSoundFly
.SetPosition(0);
5307 FJetSoundFly
.PlayAt(FObj
.X
, FObj
.Y
);
5310 for b
:= WP_FIRST
to WP_LAST
do
5311 if FReloading
[b
] > 0 then
5317 if FShellTimer
> -1 then
5318 if FShellTimer
= 0 then
5320 if FShellType
= SHELL_SHELL
then
5321 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
5322 GameVelX
, GameVelY
-2, SHELL_SHELL
)
5323 else if FShellType
= SHELL_DBLSHELL
then
5325 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
5326 GameVelX
+1, GameVelY
-2, SHELL_SHELL
);
5327 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
5328 GameVelX
-1, GameVelY
-2, SHELL_SHELL
);
5331 end else Dec(FShellTimer
);
5333 if (FBFGFireCounter
> -1) then
5334 if FBFGFireCounter
= 0 then
5338 wx
:= FObj
.X
+WEAPONPOINT
[FDirection
].X
;
5339 wy
:= FObj
.Y
+WEAPONPOINT
[FDirection
].Y
;
5340 xd
:= wx
+IfThen(FDirection
= TDirection
.D_LEFT
, -30, 30);
5341 yd
:= wy
+firediry();
5342 g_Weapon_bfgshot(wx
, wy
, xd
, yd
, FUID
);
5343 if NetServer
then MH_SEND_PlayerFire(FUID
, WEAPON_BFG
, wx
, wy
, xd
, yd
);
5344 if (FAngle
= 0) or (FAngle
= 180) then SetAction(A_ATTACK
)
5345 else if (FAngle
= ANGLE_LEFTDOWN
) or (FAngle
= ANGLE_RIGHTDOWN
) then SetAction(A_ATTACKDOWN
)
5346 else if (FAngle
= ANGLE_LEFTUP
) or (FAngle
= ANGLE_RIGHTUP
) then SetAction(A_ATTACKUP
);
5349 FReloading
[WEAPON_BFG
] := WEAPON_RELOAD
[WEAPON_BFG
];
5350 FBFGFireCounter
:= -1;
5353 FBFGFireCounter
:= 0
5355 Dec(FBFGFireCounter
);
5357 if (FMegaRulez
[MR_SUIT
] < gTime
) and AnyServer
then
5359 b
:= g_GetAcidHit(FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+PLAYER_RECT
.Y
, PLAYER_RECT
.Width
, PLAYER_RECT
.Height
);
5361 if (b
> 0) and (gTime
mod (15*GAME_TICK
) = 0) then Damage(b
, 0, 0, 0, HIT_ACID
);
5364 if (headwater
or blockmon
) then
5370 if AnyServer
then Damage(10, 0, 0, 0, HIT_WATER
);
5373 else if (FAir
mod 31 = 0) and not blockmon
then
5375 g_GFX_Bubbles(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2), FObj
.Y
+PLAYER_RECT
.Y
-4, 5+Random(6), 8, 4);
5376 if Random(2) = 0 then
5377 g_Sound_PlayExAt('SOUND_GAME_BUBBLE1', FObj
.X
, FObj
.Y
)
5379 g_Sound_PlayExAt('SOUND_GAME_BUBBLE2', FObj
.X
, FObj
.Y
);
5381 end else if FAir
< AIR_DEF
then
5384 if FFireTime
> 0 then
5386 if BodyInLiquid(0, 0) then
5391 else if FMegaRulez
[MR_SUIT
] >= gTime
then
5393 if FMegaRulez
[MR_SUIT
] = gTime
then
5400 if FFirePainTime
<= 0 then
5402 if g_Game_IsServer
then
5403 Damage(2, FFireAttacker
, 0, 0, HIT_FLAME
);
5404 FFirePainTime
:= 12 - FFireTime
div 12;
5406 FFirePainTime
:= FFirePainTime
- 1;
5407 FFireTime
:= FFireTime
- 1;
5408 if ((FFireTime
mod 33) = 0) and (FMegaRulez
[MR_INVUL
] < gTime
) then
5409 FModel
.PlaySound(MODELSOUND_PAIN
, 1, FObj
.X
, FObj
.Y
);
5410 if (FFireTime
= 0) and g_Game_IsNet
and g_Game_IsServer
then
5411 MH_SEND_PlayerStats(FUID
);
5415 if FDamageBuffer
> 0 then
5417 if FDamageBuffer
>= 9 then
5421 if FDamageBuffer
< 30 then i
:= 9
5422 else if FDamageBuffer
< 100 then i
:= 18
5426 ii
:= Round(FDamageBuffer
*FHealth
/ nonz(FArmor
*(3/4)+FHealth
));
5427 FArmor
:= FArmor
-(FDamageBuffer
-ii
);
5428 FHealth
:= FHealth
-ii
;
5431 FHealth
:= FHealth
+FArmor
;
5436 if FHealth
<= 0 then
5437 if FHealth
> -30 then Kill(K_SIMPLEKILL
, FLastSpawnerUID
, FLastHit
)
5438 else if FHealth
> -50 then Kill(K_HARDKILL
, FLastSpawnerUID
, FLastHit
)
5439 else Kill(K_EXTRAHARDKILL
, FLastSpawnerUID
, FLastHit
);
5441 if FAlive
and ((FLastHit
<> HIT_FLAME
) or (FFireTime
<= 0)) then
5443 if FDamageBuffer
<= 20 then FModel
.PlaySound(MODELSOUND_PAIN
, 1, FObj
.X
, FObj
.Y
)
5444 else if FDamageBuffer
<= 55 then FModel
.PlaySound(MODELSOUND_PAIN
, 2, FObj
.X
, FObj
.Y
)
5445 else if FDamageBuffer
<= 120 then FModel
.PlaySound(MODELSOUND_PAIN
, 3, FObj
.X
, FObj
.Y
)
5446 else FModel
.PlaySound(MODELSOUND_PAIN
, 4, FObj
.X
, FObj
.Y
);
5453 end; // if FAlive then ...
5455 if (FActionAnim
= A_PAIN
) and (FModel
.Animation
<> A_PAIN
) then
5457 FModel
.ChangeAnimation(FActionAnim
, FActionForce
);
5458 FModel
.GetCurrentAnimation
.MinLength
:= i
;
5459 FModel
.GetCurrentAnimationMask
.MinLength
:= i
;
5460 end else FModel
.ChangeAnimation(FActionAnim
, FActionForce
and (FModel
.Animation
<> A_STAND
));
5462 if (FModel
.GetCurrentAnimation
.Played
or ((not FActionChanged
) and (FModel
.Animation
= A_WALK
)))
5463 then SetAction(A_STAND
, True);
5465 if not ((FModel
.Animation
= A_WALK
) and (Abs(FObj
.Vel
.X
) < 4) and not FModel
.Fire
) then FModel
.Update
;
5467 for b
:= Low(FKeys
) to High(FKeys
) do
5468 if FKeys
[b
].Time
= 0 then FKeys
[b
].Pressed
:= False else Dec(FKeys
[b
].Time
);
5472 procedure TPlayer
.getMapBox (out x
, y
, w
, h
: Integer); inline;
5474 x
:= FObj
.X
+PLAYER_RECT
.X
;
5475 y
:= FObj
.Y
+PLAYER_RECT
.Y
;
5476 w
:= PLAYER_RECT
.Width
;
5477 h
:= PLAYER_RECT
.Height
;
5481 procedure TPlayer
.moveBy (dx
, dy
: Integer); inline;
5483 if (dx
<> 0) or (dy
<> 0) then
5492 function TPlayer
.Collide(X
, Y
: Integer; Width
, Height
: Word): Boolean;
5494 Result
:= g_Collide(FObj
.X
+PLAYER_RECT
.X
,
5495 FObj
.Y
+PLAYER_RECT
.Y
,
5502 function TPlayer
.Collide(Panel
: TPanel
): Boolean;
5504 Result
:= g_Collide(FObj
.X
+PLAYER_RECT
.X
,
5505 FObj
.Y
+PLAYER_RECT
.Y
,
5509 Panel
.Width
, Panel
.Height
);
5512 function TPlayer
.Collide(X
, Y
: Integer): Boolean;
5514 X
:= X
-FObj
.X
-PLAYER_RECT
.X
;
5515 Y
:= Y
-FObj
.Y
-PLAYER_RECT
.Y
;
5516 Result
:= (x
>= 0) and (x
<= PLAYER_RECT
.Width
) and
5517 (y
>= 0) and (y
<= PLAYER_RECT
.Height
);
5520 function g_Player_ValidName(Name
: string): Boolean;
5526 if gPlayers
= nil then Exit
;
5528 for a
:= 0 to High(gPlayers
) do
5529 if gPlayers
[a
] <> nil then
5530 if LowerCase(Name
) = LowerCase(gPlayers
[a
].FName
) then
5537 procedure TPlayer
.SetDirection(Direction
: TDirection
);
5541 d
:= FModel
.Direction
;
5543 FModel
.Direction
:= Direction
;
5544 if d
<> Direction
then FModel
.ChangeAnimation(FModel
.Animation
, True);
5546 FDirection
:= Direction
;
5549 function TPlayer
.GetKeys(): Byte;
5553 if R_KEY_RED
in FRulez
then Result
:= KEY_RED
;
5554 if R_KEY_GREEN
in FRulez
then Result
:= Result
or KEY_GREEN
;
5555 if R_KEY_BLUE
in FRulez
then Result
:= Result
or KEY_BLUE
;
5557 if FTeam
= TEAM_RED
then Result
:= Result
or KEY_REDTEAM
;
5558 if FTeam
= TEAM_BLUE
then Result
:= Result
or KEY_BLUETEAM
;
5561 procedure TPlayer
.Use();
5565 if FTime
[T_USE
] > gTime
then Exit
;
5567 g_Triggers_PressR(FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+PLAYER_RECT
.Y
, PLAYER_RECT
.Width
,
5568 PLAYER_RECT
.Height
, FUID
, ACTIVATE_PLAYERPRESS
);
5570 for a
:= 0 to High(gPlayers
) do
5571 if (gPlayers
[a
] <> nil) and (gPlayers
[a
] <> Self
) and
5572 gPlayers
[a
].alive
and SameTeam(FUID
, gPlayers
[a
].FUID
) and
5573 g_Obj_Collide(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
,
5574 FObj
.Rect
.Width
, FObj
.Rect
.Height
, @gPlayers
[a
].FObj
) then
5576 gPlayers
[a
].Touch();
5577 if g_Game_IsNet
and g_Game_IsServer
then
5578 MH_SEND_GameEvent(NET_EV_PLAYER_TOUCH
, gPlayers
[a
].FUID
);
5581 FTime
[T_USE
] := gTime
+120;
5584 procedure TPlayer
.NetFire(Wpn
: Byte; X
, Y
, AX
, AY
: Integer; WID
: Integer = -1);
5587 visible
: Boolean = True;
5588 WX
, WY
, XD
, YD
: Integer;
5600 if R_BERSERK
in FRulez
then
5602 //g_Weapon_punch(FObj.X+FObj.Rect.X, FObj.Y+FObj.Rect.Y, 75, FUID);
5603 locobj
.X
:= FObj
.X
+FObj
.Rect
.X
;
5604 locobj
.Y
:= FObj
.Y
+FObj
.Rect
.Y
;
5607 locobj
.rect
.Width
:= 39;
5608 locobj
.rect
.Height
:= 52;
5609 locobj
.Vel
.X
:= (xd
-wx
) div 2;
5610 locobj
.Vel
.Y
:= (yd
-wy
) div 2;
5611 locobj
.Accel
.X
:= xd
-wx
;
5612 locobj
.Accel
.y
:= yd
-wy
;
5614 if g_Weapon_Hit(@locobj
, 50, FUID
, HIT_SOME
) <> 0 then
5615 g_Sound_PlayExAt('SOUND_WEAPON_HITBERSERK', FObj
.X
, FObj
.Y
)
5617 g_Sound_PlayExAt('SOUND_WEAPON_MISSBERSERK', FObj
.X
, FObj
.Y
);
5621 FPain
:= min(FPain
+ 25, 50);
5623 g_Weapon_punch(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
, 3, FUID
);
5628 if g_Weapon_chainsaw(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
,
5629 IfThen(gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
], 9, 3), FUID
) <> 0 then
5631 FSawSoundSelect
.Stop();
5633 FSawSoundHit
.PlayAt(FObj
.X
, FObj
.Y
);
5635 else if not FSawSoundHit
.IsPlaying() then
5637 FSawSoundSelect
.Stop();
5638 FSawSound
.PlayAt(FObj
.X
, FObj
.Y
);
5644 g_Sound_PlayExAt('SOUND_WEAPON_FIREPISTOL', GameX
, Gamey
);
5645 FFireAngle
:= FAngle
;
5646 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
5647 GameVelX
, GameVelY
-2, SHELL_BULLET
);
5652 g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN', Gamex
, Gamey
);
5653 FFireAngle
:= FAngle
;
5655 FShellType
:= SHELL_SHELL
;
5660 g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN2', Gamex
, Gamey
);
5661 FFireAngle
:= FAngle
;
5663 FShellType
:= SHELL_DBLSHELL
;
5668 g_Sound_PlayExAt('SOUND_WEAPON_FIRECGUN', Gamex
, Gamey
);
5669 FFireAngle
:= FAngle
;
5670 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
5671 GameVelX
, GameVelY
-2, SHELL_BULLET
);
5674 WEAPON_ROCKETLAUNCHER
:
5676 g_Weapon_Rocket(wx
, wy
, xd
, yd
, FUID
, WID
);
5677 FFireAngle
:= FAngle
;
5682 g_Weapon_Plasma(wx
, wy
, xd
, yd
, FUID
, WID
);
5683 FFireAngle
:= FAngle
;
5688 g_Weapon_BFGShot(wx
, wy
, xd
, yd
, FUID
, WID
);
5689 FFireAngle
:= FAngle
;
5692 WEAPON_SUPERPULEMET
:
5694 g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN', Gamex
, Gamey
);
5695 FFireAngle
:= FAngle
;
5696 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
5697 GameVelX
, GameVelY
-2, SHELL_SHELL
);
5700 WEAPON_FLAMETHROWER
:
5702 g_Weapon_flame(wx
, wy
, xd
, yd
, FUID
, WID
);
5704 FFireAngle
:= FAngle
;
5708 if not visible
then Exit
;
5710 if (FAngle
= 0) or (FAngle
= 180) then SetAction(A_ATTACK
)
5711 else if (FAngle
= ANGLE_LEFTDOWN
) or (FAngle
= ANGLE_RIGHTDOWN
) then SetAction(A_ATTACKDOWN
)
5712 else if (FAngle
= ANGLE_LEFTUP
) or (FAngle
= ANGLE_RIGHTUP
) then SetAction(A_ATTACKUP
);
5715 procedure TPlayer
.DoLerp(Level
: Integer = 2);
5717 if FObj
.X
<> FXTo
then FObj
.X
:= Lerp(FObj
.X
, FXTo
, Level
);
5718 if FObj
.Y
<> FYTo
then FObj
.Y
:= Lerp(FObj
.Y
, FYTo
, Level
);
5721 procedure TPlayer
.SetLerp(XTo
, YTo
: Integer);
5727 if FJustTeleported
or (NetInterpLevel
< 1) then
5731 if FJustTeleported
then
5733 FObj
.oldX
:= FObj
.X
;
5734 FObj
.oldY
:= FObj
.Y
;
5739 AX
:= Abs(FXTo
- FObj
.X
);
5740 AY
:= Abs(FYTo
- FObj
.Y
);
5741 if (AX
> 32) or (AX
<= NetInterpLevel
) then
5743 if (AY
> 32) or (AY
<= NetInterpLevel
) then
5748 function TPlayer
.FullInLift(XInc
, YInc
: Integer): Integer;
5750 if g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
,
5751 PLAYER_RECT
.Width
, PLAYER_RECT
.Height
-8,
5752 PANEL_LIFTUP
, False) then Result
:= -1
5754 if g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
,
5755 PLAYER_RECT
.Width
, PLAYER_RECT
.Height
-8,
5756 PANEL_LIFTDOWN
, False) then Result
:= 1
5760 function TPlayer
.GetFlag(Flag
: Byte): Boolean;
5767 if Flag
= FLAG_NONE
then
5770 if not g_Game_IsServer
then Exit
;
5772 // Ïðèíåñ ÷óæîé ôëàã íà ñâîþ áàçó:
5773 if (Flag
= FTeam
) and
5774 (gFlags
[Flag
].State
= FLAG_STATE_NORMAL
) and
5775 (FFlag
<> FLAG_NONE
) then
5777 if FFlag
= FLAG_RED
then
5778 s
:= _lc
[I_PLAYER_FLAG_RED
]
5780 s
:= _lc
[I_PLAYER_FLAG_BLUE
];
5782 evtype
:= FLAG_STATE_SCORED
;
5784 ts
:= Format('%.4d', [gFlags
[FFlag
].CaptureTime
]);
5785 Insert('.', ts
, Length(ts
) + 1 - 3);
5786 g_Console_Add(Format(_lc
[I_PLAYER_FLAG_CAPTURE
], [FName
, s
, ts
]), True);
5788 g_Map_ResetFlag(FFlag
);
5789 g_Game_Message(Format(_lc
[I_MESSAGE_FLAG_CAPTURE
], [AnsiUpperCase(s
)]), 144);
5791 if ((Self
= gPlayer1
) or (Self
= gPlayer2
)
5792 or ((gPlayer1
<> nil) and (gPlayer1
.Team
= FTeam
))
5793 or ((gPlayer2
<> nil) and (gPlayer2
.Team
= FTeam
))) then
5798 if not sound_cap_flag
[a
].IsPlaying() then
5799 sound_cap_flag
[a
].Play();
5801 gTeamStat
[FTeam
].Goals
:= gTeamStat
[FTeam
].Goals
+ 1;
5804 if g_Game_IsNet
then
5806 MH_SEND_FlagEvent(evtype
, FFlag
, FUID
, False);
5810 gFlags
[FFlag
].CaptureTime
:= 0;
5815 // Ïîäîáðàë ñâîé ôëàã - âåðíóë åãî íà áàçó:
5816 if (Flag
= FTeam
) and
5817 (gFlags
[Flag
].State
= FLAG_STATE_DROPPED
) then
5819 if Flag
= FLAG_RED
then
5820 s
:= _lc
[I_PLAYER_FLAG_RED
]
5822 s
:= _lc
[I_PLAYER_FLAG_BLUE
];
5824 evtype
:= FLAG_STATE_RETURNED
;
5825 gFlags
[Flag
].CaptureTime
:= 0;
5827 g_Console_Add(Format(_lc
[I_PLAYER_FLAG_RETURN
], [FName
, s
]), True);
5829 g_Map_ResetFlag(Flag
);
5830 g_Game_Message(Format(_lc
[I_MESSAGE_FLAG_RETURN
], [AnsiUpperCase(s
)]), 144);
5832 if ((Self
= gPlayer1
) or (Self
= gPlayer2
)
5833 or ((gPlayer1
<> nil) and (gPlayer1
.Team
= FTeam
))
5834 or ((gPlayer2
<> nil) and (gPlayer2
.Team
= FTeam
))) then
5839 if not sound_ret_flag
[a
].IsPlaying() then
5840 sound_ret_flag
[a
].Play();
5843 if g_Game_IsNet
then
5845 MH_SEND_FlagEvent(evtype
, Flag
, FUID
, False);
5851 // Ïîäîáðàë ÷óæîé ôëàã:
5852 if (Flag
<> FTeam
) and (FTime
[T_FLAGCAP
] <= gTime
) then
5856 if Flag
= FLAG_RED
then
5857 s
:= _lc
[I_PLAYER_FLAG_RED
]
5859 s
:= _lc
[I_PLAYER_FLAG_BLUE
];
5861 evtype
:= FLAG_STATE_CAPTURED
;
5863 g_Console_Add(Format(_lc
[I_PLAYER_FLAG_GET
], [FName
, s
]), True);
5865 g_Game_Message(Format(_lc
[I_MESSAGE_FLAG_GET
], [AnsiUpperCase(s
)]), 144);
5867 gFlags
[Flag
].State
:= FLAG_STATE_CAPTURED
;
5869 if ((Self
= gPlayer1
) or (Self
= gPlayer2
)
5870 or ((gPlayer1
<> nil) and (gPlayer1
.Team
= FTeam
))
5871 or ((gPlayer2
<> nil) and (gPlayer2
.Team
= FTeam
))) then
5876 if not sound_get_flag
[a
].IsPlaying() then
5877 sound_get_flag
[a
].Play();
5880 if g_Game_IsNet
then
5882 MH_SEND_FlagEvent(evtype
, Flag
, FUID
, False);
5888 procedure TPlayer
.SetFlag(Flag
: Byte);
5891 if FModel
<> nil then
5892 FModel
.SetFlag(FFlag
);
5895 function TPlayer
.TryDropFlag(): Boolean;
5897 if LongBool(gGameSettings
.Options
and GAME_OPTION_ALLOWDROPFLAG
) then
5898 Result
:= DropFlag(False, LongBool(gGameSettings
.Options
and GAME_OPTION_THROWFLAG
))
5903 function TPlayer
.DropFlag(Silent
: Boolean = True; DoThrow
: Boolean = False): Boolean;
5910 if (not g_Game_IsServer
) or (FFlag
= FLAG_NONE
) then
5912 FTime
[T_FLAGCAP
] := gTime
+ 2000;
5913 with gFlags
[FFlag
] do
5917 Direction
:= FDirection
;
5918 State
:= FLAG_STATE_DROPPED
;
5922 xv
:= FObj
.Vel
.X
+ IfThen(Direction
= TDirection
.D_RIGHT
, 10, -10);
5923 yv
:= FObj
.Vel
.Y
- 2;
5927 xv
:= (FObj
.Vel
.X
div 2);
5928 yv
:= (FObj
.Vel
.Y
div 2) - 2;
5930 g_Obj_Push(@Obj
, xv
, yv
);
5932 positionChanged(); // this updates spatial accelerators
5934 if FFlag
= FLAG_RED
then
5935 s
:= _lc
[I_PLAYER_FLAG_RED
]
5937 s
:= _lc
[I_PLAYER_FLAG_BLUE
];
5939 g_Console_Add(Format(_lc
[I_PLAYER_FLAG_DROP
], [FName
, s
]), True);
5940 g_Game_Message(Format(_lc
[I_MESSAGE_FLAG_DROP
], [AnsiUpperCase(s
)]), 144);
5942 if ((Self
= gPlayer1
) or (Self
= gPlayer2
)
5943 or ((gPlayer1
<> nil) and (gPlayer1
.Team
= FTeam
))
5944 or ((gPlayer2
<> nil) and (gPlayer2
.Team
= FTeam
))) then
5949 if (not Silent
) and (not sound_lost_flag
[a
].IsPlaying()) then
5950 sound_lost_flag
[a
].Play();
5952 if g_Game_IsNet
then
5953 MH_SEND_FlagEvent(FLAG_STATE_DROPPED
, Flag
, FUID
, False);
5959 procedure TPlayer
.GetSecret();
5961 if (self
= gPlayer1
) or (self
= gPlayer2
) then
5963 g_Console_Add(Format(_lc
[I_PLAYER_SECRET
], [FName
]), True);
5964 g_Sound_PlayEx('SOUND_GAME_SECRET');
5969 procedure TPlayer
.PressKey(Key
: Byte; Time
: Word = 1);
5971 Assert(Key
<= High(FKeys
));
5973 FKeys
[Key
].Pressed
:= True;
5974 FKeys
[Key
].Time
:= Time
;
5977 function TPlayer
.IsKeyPressed(K
: Byte): Boolean;
5979 Result
:= FKeys
[K
].Pressed
;
5982 procedure TPlayer
.ReleaseKeys();
5986 for a
:= Low(FKeys
) to High(FKeys
) do
5988 FKeys
[a
].Pressed
:= False;
5993 procedure TPlayer
.OnDamage(Angle
: SmallInt);
5997 function TPlayer
.firediry(): Integer;
5999 if FKeys
[KEY_UP
].Pressed
then Result
:= -42
6000 else if FKeys
[KEY_DOWN
].Pressed
then Result
:= 19
6004 procedure TPlayer
.RememberState();
6007 SavedState
: TPlayerSavedState
;
6009 SavedState
.Health
:= FHealth
;
6010 SavedState
.Armor
:= FArmor
;
6011 SavedState
.Air
:= FAir
;
6012 SavedState
.JetFuel
:= FJetFuel
;
6013 SavedState
.CurrWeap
:= FCurrWeap
;
6014 SavedState
.NextWeap
:= FNextWeap
;
6015 SavedState
.NextWeapDelay
:= FNextWeapDelay
;
6016 for i
:= Low(FWeapon
) to High(FWeapon
) do
6017 SavedState
.Weapon
[i
] := FWeapon
[i
];
6018 for i
:= Low(FAmmo
) to High(FAmmo
) do
6019 SavedState
.Ammo
[i
] := FAmmo
[i
];
6020 for i
:= Low(FMaxAmmo
) to High(FMaxAmmo
) do
6021 SavedState
.MaxAmmo
[i
] := FMaxAmmo
[i
];
6022 SavedState
.Rulez
:= FRulez
- [R_KEY_RED
, R_KEY_GREEN
, R_KEY_BLUE
];
6024 FSavedStateNum
:= -1;
6025 for i
:= Low(SavedStates
) to High(SavedStates
) do
6026 if not SavedStates
[i
].Used
then
6028 FSavedStateNum
:= i
;
6031 if FSavedStateNum
< 0 then
6033 SetLength(SavedStates
, Length(SavedStates
) + 1);
6034 FSavedStateNum
:= High(SavedStates
);
6037 SavedState
.Used
:= True;
6038 SavedStates
[FSavedStateNum
] := SavedState
;
6041 procedure TPlayer
.RecallState();
6044 SavedState
: TPlayerSavedState
;
6046 if(FSavedStateNum
< 0) or (FSavedStateNum
> High(SavedStates
)) then
6049 SavedState
:= SavedStates
[FSavedStateNum
];
6050 SavedStates
[FSavedStateNum
].Used
:= False;
6051 FSavedStateNum
:= -1;
6053 FHealth
:= SavedState
.Health
;
6054 FArmor
:= SavedState
.Armor
;
6055 FAir
:= SavedState
.Air
;
6056 FJetFuel
:= SavedState
.JetFuel
;
6057 FCurrWeap
:= SavedState
.CurrWeap
;
6058 FNextWeap
:= SavedState
.NextWeap
;
6059 FNextWeapDelay
:= SavedState
.NextWeapDelay
;
6060 for i
:= Low(FWeapon
) to High(FWeapon
) do
6061 FWeapon
[i
] := SavedState
.Weapon
[i
];
6062 for i
:= Low(FAmmo
) to High(FAmmo
) do
6063 FAmmo
[i
] := SavedState
.Ammo
[i
];
6064 for i
:= Low(FMaxAmmo
) to High(FMaxAmmo
) do
6065 FMaxAmmo
[i
] := SavedState
.MaxAmmo
[i
];
6066 FRulez
:= SavedState
.Rulez
;
6068 if gGameSettings
.GameType
= GT_SERVER
then
6069 MH_SEND_PlayerStats(FUID
);
6072 procedure TPlayer
.SaveState (st
: TStream
);
6078 utils
.writeSign(st
, 'PLYR');
6079 utils
.writeInt(st
, Byte(PLR_SAVE_VERSION
)); // version
6081 utils
.writeBool(st
, FIamBot
);
6083 utils
.writeInt(st
, Word(FUID
));
6085 utils
.writeStr(st
, FName
);
6087 utils
.writeInt(st
, Byte(FTeam
));
6089 utils
.writeBool(st
, FAlive
);
6090 // Èçðàñõîäîâàë ëè âñå æèçíè
6091 utils
.writeBool(st
, FNoRespawn
);
6093 if FDirection
= TDirection
.D_LEFT
then b
:= 1 else b
:= 2; // D_RIGHT
6094 utils
.writeInt(st
, Byte(b
));
6096 utils
.writeInt(st
, LongInt(FHealth
));
6097 // Êîýôôèöèåíò èíâàëèäíîñòè
6098 utils
.writeInt(st
, LongInt(FHandicap
));
6100 utils
.writeInt(st
, Byte(FLives
));
6102 utils
.writeInt(st
, LongInt(FArmor
));
6104 utils
.writeInt(st
, LongInt(FAir
));
6106 utils
.writeInt(st
, LongInt(FJetFuel
));
6108 utils
.writeInt(st
, LongInt(FPain
));
6110 utils
.writeInt(st
, LongInt(FKills
));
6112 utils
.writeInt(st
, LongInt(FMonsterKills
));
6114 utils
.writeInt(st
, LongInt(FFrags
));
6116 utils
.writeInt(st
, Byte(FFragCombo
));
6117 // Âðåìÿ ïîñëåäíåãî ôðàãà
6118 utils
.writeInt(st
, LongWord(FLastFrag
));
6120 utils
.writeInt(st
, LongInt(FDeath
));
6122 utils
.writeInt(st
, Byte(FFlag
));
6124 utils
.writeInt(st
, LongInt(FSecrets
));
6126 utils
.writeInt(st
, Byte(FCurrWeap
));
6128 utils
.writeInt(st
, Word(FNextWeap
));
6130 utils
.writeInt(st
, Byte(FNextWeapDelay
));
6131 // Âðåìÿ çàðÿäêè BFG
6132 utils
.writeInt(st
, SmallInt(FBFGFireCounter
));
6134 utils
.writeInt(st
, LongInt(FDamageBuffer
));
6135 // Ïîñëåäíèé óäàðèâøèé
6136 utils
.writeInt(st
, Word(FLastSpawnerUID
));
6137 // Òèï ïîñëåäíåãî ïîëó÷åííîãî óðîíà
6138 utils
.writeInt(st
, Byte(FLastHit
));
6140 Obj_SaveState(st
, @FObj
);
6141 // Òåêóùåå êîëè÷åñòâî ïàòðîíîâ
6142 for i
:= A_BULLETS
to A_HIGH
do utils
.writeInt(st
, Word(FAmmo
[i
]));
6143 // Ìàêñèìàëüíîå êîëè÷åñòâî ïàòðîíîâ
6144 for i
:= A_BULLETS
to A_HIGH
do utils
.writeInt(st
, Word(FMaxAmmo
[i
]));
6146 for i
:= WP_FIRST
to WP_LAST
do utils
.writeBool(st
, FWeapon
[i
]);
6147 // Âðåìÿ ïåðåçàðÿäêè îðóæèÿ
6148 for i
:= WP_FIRST
to WP_LAST
do utils
.writeInt(st
, Word(FReloading
[i
]));
6150 utils
.writeBool(st
, (R_ITEM_BACKPACK
in FRulez
));
6151 // Íàëè÷èå êðàñíîãî êëþ÷à
6152 utils
.writeBool(st
, (R_KEY_RED
in FRulez
));
6153 // Íàëè÷èå çåëåíîãî êëþ÷à
6154 utils
.writeBool(st
, (R_KEY_GREEN
in FRulez
));
6155 // Íàëè÷èå ñèíåãî êëþ÷à
6156 utils
.writeBool(st
, (R_KEY_BLUE
in FRulez
));
6158 utils
.writeBool(st
, (R_BERSERK
in FRulez
));
6159 // Âðåìÿ äåéñòâèÿ ñïåöèàëüíûõ ïðåäìåòîâ
6160 for i
:= MR_SUIT
to MR_MAX
do utils
.writeInt(st
, LongWord(FMegaRulez
[i
]));
6161 // Âðåìÿ äî ïîâòîðíîãî ðåñïàóíà, ñìåíû îðóæèÿ, èñîëüçîâàíèÿ, çàõâàòà ôëàãà
6162 for i
:= T_RESPAWN
to T_FLAGCAP
do utils
.writeInt(st
, LongWord(FTime
[i
]));
6164 utils
.writeStr(st
, FModel
.Name
);
6166 utils
.writeInt(st
, Byte(FColor
.R
));
6167 utils
.writeInt(st
, Byte(FColor
.G
));
6168 utils
.writeInt(st
, Byte(FColor
.B
));
6172 procedure TPlayer
.LoadState (st
: TStream
);
6181 if not utils
.checkSign(st
, 'PLYR') then raise XStreamError
.Create('invalid player signature');
6182 if (utils
.readByte(st
) <> PLR_SAVE_VERSION
) then raise XStreamError
.Create('invalid player version');
6184 FIamBot
:= utils
.readBool(st
);
6186 FUID
:= utils
.readWord(st
);
6188 str
:= utils
.readStr(st
);
6189 if (self
<> gPlayer1
) and (self
<> gPlayer2
) then FName
:= str
;
6191 FTeam
:= utils
.readByte(st
);
6193 FAlive
:= utils
.readBool(st
);
6194 // Èçðàñõîäîâàë ëè âñå æèçíè
6195 FNoRespawn
:= utils
.readBool(st
);
6197 b
:= utils
.readByte(st
);
6198 if b
= 1 then FDirection
:= TDirection
.D_LEFT
else FDirection
:= TDirection
.D_RIGHT
; // b = 2
6200 FHealth
:= utils
.readLongInt(st
);
6201 // Êîýôôèöèåíò èíâàëèäíîñòè
6202 FHandicap
:= utils
.readLongInt(st
);
6204 FLives
:= utils
.readByte(st
);
6206 FArmor
:= utils
.readLongInt(st
);
6208 FAir
:= utils
.readLongInt(st
);
6210 FJetFuel
:= utils
.readLongInt(st
);
6212 FPain
:= utils
.readLongInt(st
);
6214 FKills
:= utils
.readLongInt(st
);
6216 FMonsterKills
:= utils
.readLongInt(st
);
6218 FFrags
:= utils
.readLongInt(st
);
6220 FFragCombo
:= utils
.readByte(st
);
6221 // Âðåìÿ ïîñëåäíåãî ôðàãà
6222 FLastFrag
:= utils
.readLongWord(st
);
6224 FDeath
:= utils
.readLongInt(st
);
6226 FFlag
:= utils
.readByte(st
);
6228 FSecrets
:= utils
.readLongInt(st
);
6230 FCurrWeap
:= utils
.readByte(st
);
6232 FNextWeap
:= utils
.readWord(st
);
6234 FNextWeapDelay
:= utils
.readByte(st
);
6235 // Âðåìÿ çàðÿäêè BFG
6236 FBFGFireCounter
:= utils
.readSmallInt(st
);
6238 FDamageBuffer
:= utils
.readLongInt(st
);
6239 // Ïîñëåäíèé óäàðèâøèé
6240 FLastSpawnerUID
:= utils
.readWord(st
);
6241 // Òèï ïîñëåäíåãî ïîëó÷åííîãî óðîíà
6242 FLastHit
:= utils
.readByte(st
);
6244 Obj_LoadState(@FObj
, st
);
6245 // Òåêóùåå êîëè÷åñòâî ïàòðîíîâ
6246 for i
:= A_BULLETS
to A_HIGH
do FAmmo
[i
] := utils
.readWord(st
);
6247 // Ìàêñèìàëüíîå êîëè÷åñòâî ïàòðîíîâ
6248 for i
:= A_BULLETS
to A_HIGH
do FMaxAmmo
[i
] := utils
.readWord(st
);
6250 for i
:= WP_FIRST
to WP_LAST
do FWeapon
[i
] := utils
.readBool(st
);
6251 // Âðåìÿ ïåðåçàðÿäêè îðóæèÿ
6252 for i
:= WP_FIRST
to WP_LAST
do FReloading
[i
] := utils
.readWord(st
);
6254 if utils
.readBool(st
) then Include(FRulez
, R_ITEM_BACKPACK
);
6255 // Íàëè÷èå êðàñíîãî êëþ÷à
6256 if utils
.readBool(st
) then Include(FRulez
, R_KEY_RED
);
6257 // Íàëè÷èå çåëåíîãî êëþ÷à
6258 if utils
.readBool(st
) then Include(FRulez
, R_KEY_GREEN
);
6259 // Íàëè÷èå ñèíåãî êëþ÷à
6260 if utils
.readBool(st
) then Include(FRulez
, R_KEY_BLUE
);
6262 if utils
.readBool(st
) then Include(FRulez
, R_BERSERK
);
6263 // Âðåìÿ äåéñòâèÿ ñïåöèàëüíûõ ïðåäìåòîâ
6264 for i
:= MR_SUIT
to MR_MAX
do FMegaRulez
[i
] := utils
.readLongWord(st
);
6265 // Âðåìÿ äî ïîâòîðíîãî ðåñïàóíà, ñìåíû îðóæèÿ, èñîëüçîâàíèÿ, çàõâàòà ôëàãà
6266 for i
:= T_RESPAWN
to T_FLAGCAP
do FTime
[i
] := utils
.readLongWord(st
);
6268 str
:= utils
.readStr(st
);
6270 FColor
.R
:= utils
.readByte(st
);
6271 FColor
.G
:= utils
.readByte(st
);
6272 FColor
.B
:= utils
.readByte(st
);
6273 if (self
= gPlayer1
) then
6275 str
:= gPlayer1Settings
.Model
;
6276 FColor
:= gPlayer1Settings
.Color
;
6278 else if (self
= gPlayer2
) then
6280 str
:= gPlayer2Settings
.Model
;
6281 FColor
:= gPlayer2Settings
.Color
;
6283 // Îáíîâëÿåì ìîäåëü èãðîêà
6285 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
6286 FModel
.Color
:= TEAMCOLOR
[FTeam
]
6288 FModel
.Color
:= FColor
;
6292 procedure TPlayer
.AllRulez(Health
: Boolean);
6298 FHealth
:= PLAYER_HP_LIMIT
;
6299 FArmor
:= PLAYER_AP_LIMIT
;
6303 for a
:= WP_FIRST
to WP_LAST
do FWeapon
[a
] := True;
6304 for a
:= A_BULLETS
to A_HIGH
do FAmmo
[a
] := 30000;
6305 FRulez
:= FRulez
+[R_KEY_RED
, R_KEY_GREEN
, R_KEY_BLUE
];
6308 procedure TPlayer
.RestoreHealthArmor();
6310 FHealth
:= PLAYER_HP_LIMIT
;
6311 FArmor
:= PLAYER_AP_LIMIT
;
6314 procedure TPlayer
.FragCombo();
6318 if (gGameSettings
.GameMode
in [GM_COOP
, GM_SINGLE
]) or g_Game_IsClient
then
6320 if gTime
- FLastFrag
< FRAG_COMBO_TIME
then
6322 if FFragCombo
< 5 then
6324 Param
:= FUID
or (FFragCombo
shl 16);
6325 if (FComboEvnt
>= Low(gDelayedEvents
)) and
6326 (FComboEvnt
<= High(gDelayedEvents
)) and
6327 gDelayedEvents
[FComboEvnt
].Pending
and
6328 (gDelayedEvents
[FComboEvnt
].DEType
= DE_KILLCOMBO
) and
6329 (gDelayedEvents
[FComboEvnt
].DENum
and $FFFF = FUID
) then
6331 gDelayedEvents
[FComboEvnt
].Time
:= gTime
+ 500;
6332 gDelayedEvents
[FComboEvnt
].DENum
:= Param
;
6335 FComboEvnt
:= g_Game_DelayEvent(DE_KILLCOMBO
, 500, Param
);
6343 procedure TPlayer
.GiveItem(ItemType
: Byte);
6347 if FMegaRulez
[MR_SUIT
] < gTime
+PLAYER_SUIT_TIME
then
6349 FMegaRulez
[MR_SUIT
] := gTime
+PLAYER_SUIT_TIME
;
6353 if FAir
< AIR_MAX
then
6360 if not (R_BERSERK
in FRulez
) then
6362 Include(FRulez
, R_BERSERK
);
6363 if FBFGFireCounter
< 1 then
6365 FCurrWeap
:= WEAPON_KASTET
;
6367 FModel
.SetWeapon(WEAPON_KASTET
);
6371 FBerserk
:= gTime
+30000;
6373 if FHealth
< PLAYER_HP_SOFT
then
6375 FHealth
:= PLAYER_HP_SOFT
;
6376 FBerserk
:= gTime
+30000;
6381 if FMegaRulez
[MR_INVUL
] < gTime
+PLAYER_INVUL_TIME
then
6383 FMegaRulez
[MR_INVUL
] := gTime
+PLAYER_INVUL_TIME
;
6388 if FMegaRulez
[MR_INVIS
] < gTime
+PLAYER_INVIS_TIME
then
6390 FMegaRulez
[MR_INVIS
] := gTime
+PLAYER_INVIS_TIME
;
6394 if FJetFuel
< JET_MAX
then
6396 FJetFuel
:= JET_MAX
;
6399 ITEM_MEDKIT_SMALL
: if FHealth
< PLAYER_HP_SOFT
then IncMax(FHealth
, 10, PLAYER_HP_SOFT
);
6400 ITEM_MEDKIT_LARGE
: if FHealth
< PLAYER_HP_SOFT
then IncMax(FHealth
, 25, PLAYER_HP_SOFT
);
6402 ITEM_ARMOR_GREEN
: if FArmor
< PLAYER_AP_SOFT
then FArmor
:= PLAYER_AP_SOFT
;
6403 ITEM_ARMOR_BLUE
: if FArmor
< PLAYER_AP_LIMIT
then FArmor
:= PLAYER_AP_LIMIT
;
6405 ITEM_SPHERE_BLUE
: if FHealth
< PLAYER_HP_LIMIT
then IncMax(FHealth
, 100, PLAYER_HP_LIMIT
);
6407 if (FHealth
< PLAYER_HP_LIMIT
) or (FArmor
< PLAYER_AP_LIMIT
) then
6409 if FHealth
< PLAYER_HP_LIMIT
then FHealth
:= PLAYER_HP_LIMIT
;
6410 if FArmor
< PLAYER_AP_LIMIT
then FArmor
:= PLAYER_AP_LIMIT
;
6413 ITEM_WEAPON_SAW
: FWeapon
[WEAPON_SAW
] := True;
6414 ITEM_WEAPON_SHOTGUN1
: FWeapon
[WEAPON_SHOTGUN1
] := True;
6415 ITEM_WEAPON_SHOTGUN2
: FWeapon
[WEAPON_SHOTGUN2
] := True;
6416 ITEM_WEAPON_CHAINGUN
: FWeapon
[WEAPON_CHAINGUN
] := True;
6417 ITEM_WEAPON_ROCKETLAUNCHER
: FWeapon
[WEAPON_ROCKETLAUNCHER
] := True;
6418 ITEM_WEAPON_PLASMA
: FWeapon
[WEAPON_PLASMA
] := True;
6419 ITEM_WEAPON_BFG
: FWeapon
[WEAPON_BFG
] := True;
6420 ITEM_WEAPON_SUPERPULEMET
: FWeapon
[WEAPON_SUPERPULEMET
] := True;
6421 ITEM_WEAPON_FLAMETHROWER
: FWeapon
[WEAPON_FLAMETHROWER
] := True;
6423 ITEM_AMMO_BULLETS
: if FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
] then IncMax(FAmmo
[A_BULLETS
], 10, FMaxAmmo
[A_BULLETS
]);
6424 ITEM_AMMO_BULLETS_BOX
: if FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
] then IncMax(FAmmo
[A_BULLETS
], 50, FMaxAmmo
[A_BULLETS
]);
6425 ITEM_AMMO_SHELLS
: if FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
] then IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
6426 ITEM_AMMO_SHELLS_BOX
: if FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
] then IncMax(FAmmo
[A_SHELLS
], 25, FMaxAmmo
[A_SHELLS
]);
6427 ITEM_AMMO_ROCKET
: if FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
] then IncMax(FAmmo
[A_ROCKETS
], 1, FMaxAmmo
[A_ROCKETS
]);
6428 ITEM_AMMO_ROCKET_BOX
: if FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
] then IncMax(FAmmo
[A_ROCKETS
], 5, FMaxAmmo
[A_ROCKETS
]);
6429 ITEM_AMMO_CELL
: if FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
] then IncMax(FAmmo
[A_CELLS
], 40, FMaxAmmo
[A_CELLS
]);
6430 ITEM_AMMO_CELL_BIG
: if FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
] then IncMax(FAmmo
[A_CELLS
], 100, FMaxAmmo
[A_CELLS
]);
6431 ITEM_AMMO_FUELCAN
: if FAmmo
[A_FUEL
] < FMaxAmmo
[A_FUEL
] then IncMax(FAmmo
[A_FUEL
], 100, FMaxAmmo
[A_FUEL
]);
6434 if (FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
]) or
6435 (FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
]) or
6436 (FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
]) or
6437 (FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
]) or
6438 (FMaxAmmo
[A_FUEL
] < AmmoLimits
[1, A_FUEL
]) then
6440 FMaxAmmo
[A_BULLETS
] := AmmoLimits
[1, A_BULLETS
];
6441 FMaxAmmo
[A_SHELLS
] := AmmoLimits
[1, A_SHELLS
];
6442 FMaxAmmo
[A_ROCKETS
] := AmmoLimits
[1, A_ROCKETS
];
6443 FMaxAmmo
[A_CELLS
] := AmmoLimits
[1, A_CELLS
];
6444 FMaxAmmo
[A_FUEL
] := AmmoLimits
[1, A_FUEL
];
6446 if FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
] then IncMax(FAmmo
[A_BULLETS
], 10, FMaxAmmo
[A_BULLETS
]);
6447 if FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
] then IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
6448 if FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
] then IncMax(FAmmo
[A_ROCKETS
], 1, FMaxAmmo
[A_ROCKETS
]);
6449 if FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
] then IncMax(FAmmo
[A_CELLS
], 40, FMaxAmmo
[A_CELLS
]);
6451 FRulez
:= FRulez
+ [R_ITEM_BACKPACK
];
6454 ITEM_KEY_RED
: if not (R_KEY_RED
in FRulez
) then Include(FRulez
, R_KEY_RED
);
6455 ITEM_KEY_GREEN
: if not (R_KEY_GREEN
in FRulez
) then Include(FRulez
, R_KEY_GREEN
);
6456 ITEM_KEY_BLUE
: if not (R_KEY_BLUE
in FRulez
) then Include(FRulez
, R_KEY_BLUE
);
6458 ITEM_BOTTLE
: if FHealth
< PLAYER_HP_LIMIT
then IncMax(FHealth
, 4, PLAYER_HP_LIMIT
);
6459 ITEM_HELMET
: if FArmor
< PLAYER_AP_LIMIT
then IncMax(FArmor
, 5, PLAYER_AP_LIMIT
);
6464 if g_Game_IsNet
and g_Game_IsServer
then
6465 MH_SEND_PlayerStats(FUID
);
6468 procedure TPlayer
.FlySmoke(Times
: DWORD
= 1);
6473 if (Random(5) = 1) and (Times
= 1) then
6476 if BodyInLiquid(0, 0) then
6478 g_GFX_Bubbles(Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2)+Random(3)-1,
6479 Obj
.Y
+Obj
.Rect
.Height
+8, 1, 8, 4);
6480 if Random(2) = 0 then
6481 g_Sound_PlayExAt('SOUND_GAME_BUBBLE1', FObj
.X
, FObj
.Y
)
6483 g_Sound_PlayExAt('SOUND_GAME_BUBBLE2', FObj
.X
, FObj
.Y
);
6487 if g_Frames_Get(id
, 'FRAMES_SMOKE') then
6489 for i
:= 1 to Times
do
6491 Anim
:= TAnimation
.Create(id
, False, 3);
6493 g_GFX_OnceAnim(Obj
.X
+Obj
.Rect
.X
+Random(Obj
.Rect
.Width
+Times
*2)-(Anim
.Width
div 2),
6494 Obj
.Y
+Obj
.Rect
.Height
-4+Random(8+Times
*2), Anim
, ONCEANIM_SMOKE
);
6500 procedure TPlayer
.OnFireFlame(Times
: DWORD
= 1);
6505 if (Random(10) = 1) and (Times
= 1) then
6508 if g_Frames_Get(id
, 'FRAMES_FLAME') then
6510 for i
:= 1 to Times
do
6512 Anim
:= TAnimation
.Create(id
, False, 3);
6514 g_GFX_OnceAnim(Obj
.X
+Obj
.Rect
.X
+Random(Obj
.Rect
.Width
+Times
*2)-(Anim
.Width
div 2),
6515 Obj
.Y
+8+Random(8+Times
*2), Anim
, ONCEANIM_SMOKE
);
6521 procedure TPlayer
.PauseSounds(Enable
: Boolean);
6523 FSawSound
.Pause(Enable
);
6524 FSawSoundIdle
.Pause(Enable
);
6525 FSawSoundHit
.Pause(Enable
);
6526 FSawSoundSelect
.Pause(Enable
);
6527 FFlameSoundOn
.Pause(Enable
);
6528 FFlameSoundOff
.Pause(Enable
);
6529 FFlameSoundWork
.Pause(Enable
);
6530 FJetSoundFly
.Pause(Enable
);
6531 FJetSoundOn
.Pause(Enable
);
6532 FJetSoundOff
.Pause(Enable
);
6537 constructor TCorpse
.Create(X
, Y
: Integer; ModelName
: String; aMess
: Boolean);
6542 FObj
.Rect
:= PLAYER_CORPSERECT
;
6543 FModelName
:= ModelName
;
6548 FState
:= CORPSE_STATE_MESS
;
6549 g_PlayerModel_GetAnim(ModelName
, A_DIE2
, FAnimation
, FAnimationMask
);
6553 FState
:= CORPSE_STATE_NORMAL
;
6554 g_PlayerModel_GetAnim(ModelName
, A_DIE1
, FAnimation
, FAnimationMask
);
6558 destructor TCorpse
.Destroy();
6565 function TCorpse
.ObjPtr (): PObj
; inline; begin result
:= @FObj
; end;
6567 procedure TCorpse
.positionChanged (); inline; begin end;
6569 procedure TCorpse
.moveBy (dx
, dy
: Integer); inline;
6571 if (dx
<> 0) or (dy
<> 0) then
6580 procedure TCorpse
.getMapBox (out x
, y
, w
, h
: Integer); inline;
6582 x
:= FObj
.X
+PLAYER_CORPSERECT
.X
;
6583 y
:= FObj
.Y
+PLAYER_CORPSERECT
.Y
;
6584 w
:= PLAYER_CORPSERECT
.Width
;
6585 h
:= PLAYER_CORPSERECT
.Height
;
6589 procedure TCorpse
.Damage(Value
: Word; SpawnerUID
: Word; vx
, vy
: Integer);
6594 if FState
= CORPSE_STATE_REMOVEME
then
6597 FDamage
:= FDamage
+ Value
;
6599 if FDamage
> 150 then
6601 if FAnimation
<> nil then
6606 FState
:= CORPSE_STATE_REMOVEME
;
6608 g_Player_CreateGibs(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
6609 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2),
6610 FModelName
, FColor
);
6611 // Çâóê ìÿñà îò òðóïà:
6612 pm
:= g_PlayerModel_Get(FModelName
);
6613 pm
.PlaySound(MODELSOUND_DIE
, 5, FObj
.X
, FObj
.Y
);
6617 if (gBodyKillEvent
<> -1)
6618 and gDelayedEvents
[gBodyKillEvent
].Pending
then
6619 gDelayedEvents
[gBodyKillEvent
].Pending
:= False;
6620 gBodyKillEvent
:= g_Game_DelayEvent(DE_BODYKILL
, 1050, SpawnerUID
);
6625 Blood
:= g_PlayerModel_GetBlood(FModelName
);
6626 FObj
.Vel
.X
:= FObj
.Vel
.X
+ vx
;
6627 FObj
.Vel
.Y
:= FObj
.Vel
.Y
+ vy
;
6628 g_GFX_Blood(FObj
.X
+PLAYER_CORPSERECT
.X
+(PLAYER_CORPSERECT
.Width
div 2),
6629 FObj
.Y
+PLAYER_CORPSERECT
.Y
+(PLAYER_CORPSERECT
.Height
div 2),
6630 Value
, vx
, vy
, 16, (PLAYER_CORPSERECT
.Height
*2) div 3,
6631 Blood
.R
, Blood
.G
, Blood
.B
, Blood
.Kind
);
6635 procedure TCorpse
.Draw();
6639 if FState
= CORPSE_STATE_REMOVEME
then
6642 FObj
.lerp(gLerpFactor
, fX
, fY
);
6644 if FAnimation
<> nil then
6645 FAnimation
.Draw(fX
, fY
, TMirrorType
.None
);
6647 if FAnimationMask
<> nil then
6650 FAnimationMask
.Draw(fX
, fY
, TMirrorType
.None
);
6657 procedure TCorpse
.Update();
6661 if FState
= CORPSE_STATE_REMOVEME
then
6664 FObj
.oldX
:= FObj
.X
;
6665 FObj
.oldY
:= FObj
.Y
;
6667 if gTime
mod (GAME_TICK
*2) <> 0 then
6669 g_Obj_Move(@FObj
, True, True, True);
6670 positionChanged(); // this updates spatial accelerators
6674 // Ñîïðîòèâëåíèå âîçäóõà äëÿ òðóïà:
6675 FObj
.Vel
.X
:= z_dec(FObj
.Vel
.X
, 1);
6677 st
:= g_Obj_Move(@FObj
, True, True, True);
6678 positionChanged(); // this updates spatial accelerators
6680 if WordBool(st
and MOVE_FALLOUT
) then
6682 FState
:= CORPSE_STATE_REMOVEME
;
6686 if FAnimation
<> nil then
6687 FAnimation
.Update();
6688 if FAnimationMask
<> nil then
6689 FAnimationMask
.Update();
6693 procedure TCorpse
.SaveState (st
: TStream
);
6700 utils
.writeSign(st
, 'CORP');
6701 utils
.writeInt(st
, Byte(0));
6703 utils
.writeInt(st
, Byte(FState
));
6705 utils
.writeInt(st
, Byte(FDamage
));
6707 utils
.writeInt(st
, Byte(FColor
.R
));
6708 utils
.writeInt(st
, Byte(FColor
.G
));
6709 utils
.writeInt(st
, Byte(FColor
.B
));
6711 Obj_SaveState(st
, @FObj
);
6712 utils
.writeInt(st
, Word(FPlayerUID
));
6714 anim
:= (FAnimation
<> nil);
6715 utils
.writeBool(st
, anim
);
6716 // Åñëè åñòü - ñîõðàíÿåì
6717 if anim
then FAnimation
.SaveState(st
);
6718 // Åñòü ëè ìàñêà àíèìàöèè
6719 anim
:= (FAnimationMask
<> nil);
6720 utils
.writeBool(st
, anim
);
6721 // Åñëè åñòü - ñîõðàíÿåì
6722 if anim
then FAnimationMask
.SaveState(st
);
6726 procedure TCorpse
.LoadState (st
: TStream
);
6733 if not utils
.checkSign(st
, 'CORP') then raise XStreamError
.Create('invalid corpse signature');
6734 if (utils
.readByte(st
) <> 0) then raise XStreamError
.Create('invalid corpse version');
6736 FState
:= utils
.readByte(st
);
6738 FDamage
:= utils
.readByte(st
);
6740 FColor
.R
:= utils
.readByte(st
);
6741 FColor
.G
:= utils
.readByte(st
);
6742 FColor
.B
:= utils
.readByte(st
);
6744 Obj_LoadState(@FObj
, st
);
6745 FPlayerUID
:= utils
.readWord(st
);
6747 anim
:= utils
.readBool(st
);
6748 // Åñëè åñòü - çàãðóæàåì
6751 Assert(FAnimation
<> nil, 'TCorpse.LoadState: no FAnimation');
6752 FAnimation
.LoadState(st
);
6754 // Åñòü ëè ìàñêà àíèìàöèè
6755 anim
:= utils
.readBool(st
);
6756 // Åñëè åñòü - çàãðóæàåì
6759 Assert(FAnimationMask
<> nil, 'TCorpse.LoadState: no FAnimationMask');
6760 FAnimationMask
.LoadState(st
);
6766 constructor TBot
.Create();
6773 FSpectator
:= False;
6780 for a
:= WP_FIRST
to WP_LAST
do
6782 FDifficult
.WeaponPrior
[a
] := WEAPON_PRIOR1
[a
];
6783 FDifficult
.CloseWeaponPrior
[a
] := WEAPON_PRIOR2
[a
];
6784 //FDifficult.SafeWeaponPrior[a] := WEAPON_PRIOR3[a];
6788 destructor TBot
.Destroy();
6791 inherited Destroy();
6794 procedure TBot
.Draw();
6798 //if FTargetUID <> 0 then e_DrawLine(1, FObj.X, FObj.Y, g_Player_Get(FTargetUID).FObj.X,
6799 // g_Player_Get(FTargetUID).FObj.Y, 255, 0, 0);
6802 procedure TBot
.Respawn(Silent
: Boolean; Force
: Boolean = False);
6804 inherited Respawn(Silent
, Force
);
6807 FSelectedWeapon
:= FCurrWeap
;
6812 procedure TBot
.UpdateCombat();
6825 TTargetRecord
= array of TTarget
;
6827 function Compare(a
, b
: TTarget
): Integer;
6829 if a
.Line
and not b
.Line
then // A íà ëèíèè îãíÿ
6832 if not a
.Line
and b
.Line
then // B íà ëèíèè îãíÿ
6834 else // È A, è B íà ëèíèè èëè íå íà ëèíèè îãíÿ
6835 if (a
.Line
and b
.Line
) or ((not a
.Line
) and (not b
.Line
)) then
6837 if a
.Dist
> b
.Dist
then // B áëèæå
6839 else // A áëèæå èëè ðàâíîóäàëåííî ñ B
6842 else // Ñòðàííî -> A
6847 a
, x1
, y1
, x2
, y2
: Integer;
6848 targets
: TTargetRecord
;
6850 Target
, BestTarget
: TTarget
;
6851 firew
, fireh
: Integer;
6855 vsPlayer
, vsMonster
, ok
: Boolean;
6858 function monsUpdate (mon
: TMonster
): Boolean;
6860 result
:= false; // don't stop
6861 if mon
.alive
and (mon
.MonsterType
<> MONSTER_BARREL
) then
6863 if not TargetOnScreen(mon
.Obj
.X
+mon
.Obj
.Rect
.X
, mon
.Obj
.Y
+mon
.Obj
.Rect
.Y
) then exit
;
6865 x2
:= mon
.Obj
.X
+mon
.Obj
.Rect
.X
+(mon
.Obj
.Rect
.Width
div 2);
6866 y2
:= mon
.Obj
.Y
+mon
.Obj
.Rect
.Y
+(mon
.Obj
.Rect
.Height
div 2);
6868 // Åñëè ìîíñòð íà ýêðàíå è íå ïðèêðûò ñòåíîé
6869 if g_TraceVector(x1
, y1
, x2
, y2
) then
6871 // Äîáàâëÿåì ê ñïèñêó âîçìîæíûõ öåëåé
6872 SetLength(targets
, Length(targets
)+1);
6873 with targets
[High(targets
)] do
6880 Rect
:= mon
.Obj
.Rect
;
6881 Dist
:= g_PatchLength(x1
, y1
, x2
, y2
);
6882 Line
:= (y1
+4 < Target
.Y
+ mon
.Obj
.Rect
.Y
+ mon
.Obj
.Rect
.Height
) and
6883 (y1
-4 > Target
.Y
+ mon
.Obj
.Rect
.Y
);
6892 vsPlayer
:= LongBool(gGameSettings
.Options
and GAME_OPTION_BOTVSPLAYER
);
6893 vsMonster
:= LongBool(gGameSettings
.Options
and GAME_OPTION_BOTVSMONSTER
);
6895 // Åñëè òåêóùåå îðóæèå íå òî, ÷òî íóæíî, òî ìåíÿåì:
6896 if FCurrWeap
<> FSelectedWeapon
then
6899 // Åñëè íóæíî ñòðåëÿòü è íóæíîå îðóæèå, òî íàæàòü "Ñòðåëÿòü":
6900 if (GetAIFlag('NEEDFIRE') <> '') and (FCurrWeap
= FSelectedWeapon
) then
6902 RemoveAIFlag('NEEDFIRE');
6905 WEAPON_PLASMA
, WEAPON_SUPERPULEMET
, WEAPON_CHAINGUN
: PressKey(KEY_FIRE
, 20);
6906 WEAPON_SAW
, WEAPON_KASTET
, WEAPON_FLAMETHROWER
: PressKey(KEY_FIRE
, 40);
6907 else PressKey(KEY_FIRE
);
6911 // Êîîðäèíàòû ñòâîëà:
6912 x1
:= FObj
.X
+ WEAPONPOINT
[FDirection
].X
;
6913 y1
:= FObj
.Y
+ WEAPONPOINT
[FDirection
].Y
;
6915 Target
.UID
:= FTargetUID
;
6918 if Target
.UID
<> 0 then
6919 begin // Öåëü åñòü - íàñòðàèâàåì
6920 if (g_GetUIDType(Target
.UID
) = UID_PLAYER
) and
6923 tpla
:= g_Player_Get(Target
.UID
);
6927 if (@FObj
) <> nil then
6934 Target
.cX
:= Target
.X
+ PLAYER_RECT_CX
;
6935 Target
.cY
:= Target
.Y
+ PLAYER_RECT_CY
;
6936 Target
.Rect
:= PLAYER_RECT
;
6937 Target
.Visible
:= g_TraceVector(x1
, y1
, Target
.cX
, Target
.cY
);
6938 Target
.Line
:= (y1
+4 < Target
.Y
+PLAYER_RECT
.Y
+PLAYER_RECT
.Height
) and
6939 (y1
-4 > Target
.Y
+PLAYER_RECT
.Y
);
6940 Target
.IsPlayer
:= True;
6944 if (g_GetUIDType(Target
.UID
) = UID_MONSTER
) and
6947 mon
:= g_Monsters_ByUID(Target
.UID
);
6950 Target
.X
:= mon
.Obj
.X
;
6951 Target
.Y
:= mon
.Obj
.Y
;
6953 Target
.cX
:= Target
.X
+ mon
.Obj
.Rect
.X
+ (mon
.Obj
.Rect
.Width
div 2);
6954 Target
.cY
:= Target
.Y
+ mon
.Obj
.Rect
.Y
+ (mon
.Obj
.Rect
.Height
div 2);
6955 Target
.Rect
:= mon
.Obj
.Rect
;
6956 Target
.Visible
:= g_TraceVector(x1
, y1
, Target
.cX
, Target
.cY
);
6957 Target
.Line
:= (y1
+4 < Target
.Y
+ mon
.Obj
.Rect
.Y
+ mon
.Obj
.Rect
.Height
) and
6958 (y1
-4 > Target
.Y
+ mon
.Obj
.Rect
.Y
);
6959 Target
.IsPlayer
:= False;
6966 begin // Öåëè íåò - îáíóëÿåì
6971 Target
.Visible
:= False;
6972 Target
.Line
:= False;
6973 Target
.IsPlayer
:= False;
6978 // Åñëè öåëü íå âèäèìà èëè íå íà ëèíèè îãíÿ, òî èùåì âñå âîçìîæíûå öåëè:
6979 if (not Target
.Line
) or (not Target
.Visible
) then
6983 for a
:= 0 to High(gPlayers
) do
6984 if (gPlayers
[a
] <> nil) and (gPlayers
[a
].alive
) and
6985 (gPlayers
[a
].FUID
<> FUID
) and
6986 (not SameTeam(FUID
, gPlayers
[a
].FUID
)) and
6987 (not gPlayers
[a
].NoTarget
) and
6988 (gPlayers
[a
].FMegaRulez
[MR_INVIS
] < gTime
) then
6990 if not TargetOnScreen(gPlayers
[a
].FObj
.X
+ PLAYER_RECT
.X
,
6991 gPlayers
[a
].FObj
.Y
+ PLAYER_RECT
.Y
) then
6994 x2
:= gPlayers
[a
].FObj
.X
+ PLAYER_RECT_CX
;
6995 y2
:= gPlayers
[a
].FObj
.Y
+ PLAYER_RECT_CY
;
6997 // Åñëè èãðîê íà ýêðàíå è íå ïðèêðûò ñòåíîé:
6998 if g_TraceVector(x1
, y1
, x2
, y2
) then
7000 // Äîáàâëÿåì ê ñïèñêó âîçìîæíûõ öåëåé:
7001 SetLength(targets
, Length(targets
)+1);
7002 with targets
[High(targets
)] do
7004 UID
:= gPlayers
[a
].FUID
;
7005 X
:= gPlayers
[a
].FObj
.X
;
7006 Y
:= gPlayers
[a
].FObj
.Y
;
7009 Rect
:= PLAYER_RECT
;
7010 Dist
:= g_PatchLength(x1
, y1
, x2
, y2
);
7011 Line
:= (y1
+4 < Target
.Y
+PLAYER_RECT
.Y
+PLAYER_RECT
.Height
) and
7012 (y1
-4 > Target
.Y
+PLAYER_RECT
.Y
);
7020 if vsMonster
then g_Mons_ForEach(monsUpdate
);
7023 // Åñëè åñòü âîçìîæíûå öåëè:
7024 // (Âûáèðàåì ëó÷øóþ, ìåíÿåì îðóæèå è áåæèì ê íåé/îò íåå)
7025 if targets
<> nil then
7027 // Âûáèðàåì íàèëó÷øóþ öåëü:
7028 BestTarget
:= targets
[0];
7029 if Length(targets
) > 1 then
7030 for a
:= 1 to High(targets
) do
7031 if Compare(BestTarget
, targets
[a
]) = 1 then
7032 BestTarget
:= targets
[a
];
7034 // Åñëè ëó÷øàÿ öåëü "âèäíåå" òåêóùåé, òî òåêóùàÿ := ëó÷øàÿ:
7035 if ((not Target
.Visible
) and BestTarget
.Visible
and (Target
.UID
<> BestTarget
.UID
)) or
7036 ((not Target
.Line
) and BestTarget
.Line
and BestTarget
.Visible
) then
7038 Target
:= BestTarget
;
7040 if (Healthy() = 3) or ((Healthy() = 2)) then
7041 begin // Åñëè çäîðîâû - äîãîíÿåì
7042 if ((RunDirection() = TDirection
.D_LEFT
) and (Target
.X
> FObj
.X
)) then
7043 SetAIFlag('GORIGHT', '1');
7044 if ((RunDirection() = TDirection
.D_RIGHT
) and (Target
.X
< FObj
.X
)) then
7045 SetAIFlag('GOLEFT', '1');
7048 begin // Åñëè ïîáèòû - óáåãàåì
7049 if ((RunDirection() = TDirection
.D_LEFT
) and (Target
.X
< FObj
.X
)) then
7050 SetAIFlag('GORIGHT', '1');
7051 if ((RunDirection() = TDirection
.D_RIGHT
) and (Target
.X
> FObj
.X
)) then
7052 SetAIFlag('GOLEFT', '1');
7055 // Âûáèðàåì îðóæèå íà îñíîâå ðàññòîÿíèÿ è ïðèîðèòåòîâ:
7056 SelectWeapon(Abs(x1
-Target
.cX
));
7061 // (Äîãîíÿåì/óáåãàåì, ñòðåëÿåì ïî íàïðàâëåíèþ ê öåëè)
7062 // (Åñëè öåëü äàëåêî, òî õâàòèò ñëåäèòü çà íåé)
7063 if Target
.UID
<> 0 then
7065 if not TargetOnScreen(Target
.X
+ Target
.Rect
.X
,
7066 Target
.Y
+ Target
.Rect
.Y
) then
7067 begin // Öåëü ñáåæàëà ñ "ýêðàíà"
7068 if (Healthy() = 3) or ((Healthy() = 2)) then
7069 begin // Åñëè çäîðîâû - äîãîíÿåì
7070 if ((RunDirection() = TDirection
.D_LEFT
) and (Target
.X
> FObj
.X
)) then
7071 SetAIFlag('GORIGHT', '1');
7072 if ((RunDirection() = TDirection
.D_RIGHT
) and (Target
.X
< FObj
.X
)) then
7073 SetAIFlag('GOLEFT', '1');
7076 begin // Åñëè ïîáèòû - çàáûâàåì î öåëè è óáåãàåì
7078 if ((RunDirection() = TDirection
.D_LEFT
) and (Target
.X
< FObj
.X
)) then
7079 SetAIFlag('GORIGHT', '1');
7080 if ((RunDirection() = TDirection
.D_RIGHT
) and (Target
.X
> FObj
.X
)) then
7081 SetAIFlag('GOLEFT', '1');
7085 begin // Öåëü ïîêà íà "ýêðàíå"
7086 // Åñëè öåëü íå çàãîðîæåíà ñòåíîé, òî îòìå÷àåì, êîãäà åå âèäåëè:
7087 if g_TraceVector(x1
, y1
, Target
.cX
, Target
.cY
) then
7088 FLastVisible
:= gTime
;
7089 // Åñëè ðàçíèöà âûñîò íå âåëèêà, òî äîãîíÿåì:
7090 if (Abs(FObj
.Y
-Target
.Y
) <= 128) then
7092 if ((RunDirection() = TDirection
.D_LEFT
) and (Target
.X
> FObj
.X
)) then
7093 SetAIFlag('GORIGHT', '1');
7094 if ((RunDirection() = TDirection
.D_RIGHT
) and (Target
.X
< FObj
.X
)) then
7095 SetAIFlag('GOLEFT', '1');
7099 // Âûáèðàåì óãîë ââåðõ:
7100 if FDirection
= TDirection
.D_LEFT
then
7101 angle
:= ANGLE_LEFTUP
7103 angle
:= ANGLE_RIGHTUP
;
7105 firew
:= Trunc(Cos(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
7106 fireh
:= Trunc(Sin(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
7108 // Åñëè ïðè óãëå ââåðõ ìîæíî ïîïàñòü â ïðèáëèçèòåëüíîå ïîëîæåíèå öåëè:
7109 if g_CollideLine(x1
, y1
, x1
+firew
, y1
+fireh
,
7110 Target
.X
+Target
.Rect
.X
+GetInterval(FDifficult
.DiagPrecision
, 128), //96
7111 Target
.Y
+Target
.Rect
.Y
+GetInterval(FDifficult
.DiagPrecision
, 128),
7112 Target
.Rect
.Width
, Target
.Rect
.Height
) and
7113 g_TraceVector(x1
, y1
, Target
.cX
, Target
.cY
) then
7114 begin // òî íóæíî ñòðåëÿòü ââåðõ
7115 SetAIFlag('NEEDFIRE', '1');
7116 SetAIFlag('NEEDSEEUP', '1');
7119 // Âûáèðàåì óãîë âíèç:
7120 if FDirection
= TDirection
.D_LEFT
then
7121 angle
:= ANGLE_LEFTDOWN
7123 angle
:= ANGLE_RIGHTDOWN
;
7125 firew
:= Trunc(Cos(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
7126 fireh
:= Trunc(Sin(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
7128 // Åñëè ïðè óãëå âíèç ìîæíî ïîïàñòü â ïðèáëèçèòåëüíîå ïîëîæåíèå öåëè:
7129 if g_CollideLine(x1
, y1
, x1
+firew
, y1
+fireh
,
7130 Target
.X
+Target
.Rect
.X
+GetInterval(FDifficult
.DiagPrecision
, 128),
7131 Target
.Y
+Target
.Rect
.Y
+GetInterval(FDifficult
.DiagPrecision
, 128),
7132 Target
.Rect
.Width
, Target
.Rect
.Height
) and
7133 g_TraceVector(x1
, y1
, Target
.cX
, Target
.cY
) then
7134 begin // òî íóæíî ñòðåëÿòü âíèç
7135 SetAIFlag('NEEDFIRE', '1');
7136 SetAIFlag('NEEDSEEDOWN', '1');
7139 // Åñëè öåëü âèäíî è îíà íà òàêîé æå âûñîòå:
7140 if Target
.Visible
and
7141 (y1
+4 < Target
.Y
+Target
.Rect
.Y
+Target
.Rect
.Height
) and
7142 (y1
-4 > Target
.Y
+Target
.Rect
.Y
) then
7144 // Åñëè èäåì â ñòîðîíó öåëè, òî íàäî ñòðåëÿòü:
7145 if ((FDirection
= TDirection
.D_LEFT
) and (Target
.X
< FObj
.X
)) or
7146 ((FDirection
= TDirection
.D_RIGHT
) and (Target
.X
> FObj
.X
)) then
7147 begin // òî íóæíî ñòðåëÿòü âïåðåä
7148 SetAIFlag('NEEDFIRE', '1');
7149 SetAIFlag('NEEDSEEDOWN', '');
7150 SetAIFlag('NEEDSEEUP', '');
7152 // Åñëè öåëü â ïðåäåëàõ "ýêðàíà" è ñëîæíîñòü ïîçâîëÿåò ïðûæêè ñáëèæåíèÿ:
7153 if Abs(FObj
.X
-Target
.X
) < Trunc(gPlayerScreenSize
.X
*0.75) then
7154 if GetRnd(FDifficult
.CloseJump
) then
7155 begin // òî åñëè ïîâåçåò - ïðûãàåì (îñîáåííî, åñëè áëèçêî)
7156 if Abs(FObj
.X
-Target
.X
) < 128 then
7160 if Random(a
) = 0 then
7161 SetAIFlag('NEEDJUMP', '1');
7165 // Åñëè öåëü âñå åùå åñòü:
7166 if Target
.UID
<> 0 then
7167 if gTime
-FLastVisible
> 2000 then // Åñëè âèäåëè äàâíî
7168 Target
.UID
:= 0 // òî çàáûòü öåëü
7169 else // Åñëè âèäåëè íåäàâíî
7170 begin // íî öåëü óáèëè
7171 if Target
.IsPlayer
then
7172 begin // Öåëü - èãðîê
7173 pla
:= g_Player_Get(Target
.UID
);
7174 if (pla
= nil) or (not pla
.alive
) or pla
.NoTarget
or
7175 (pla
.FMegaRulez
[MR_INVIS
] >= gTime
) then
7176 Target
.UID
:= 0; // òî çàáûòü öåëü
7179 begin // Öåëü - ìîíñòð
7180 mon
:= g_Monsters_ByUID(Target
.UID
);
7181 if (mon
= nil) or (not mon
.alive
) then
7182 Target
.UID
:= 0; // òî çàáûòü öåëü
7185 end; // if Target.UID <> 0
7187 FTargetUID
:= Target
.UID
;
7189 // Åñëè âîçìîæíûõ öåëåé íåò:
7190 // (Àòàêà ÷åãî-íèáóäü ñëåâà èëè ñïðàâà)
7191 if targets
= nil then
7192 if GetAIFlag('ATTACKLEFT') <> '' then
7193 begin // Åñëè íóæíî àòàêîâàòü íàëåâî
7194 RemoveAIFlag('ATTACKLEFT');
7196 SetAIFlag('NEEDJUMP', '1');
7198 if RunDirection() = TDirection
.D_RIGHT
then
7199 begin // Èäåì íå â òó ñòîðîíó
7200 if (Healthy() > 1) and GetRnd(FDifficult
.InvisFire
) then
7201 begin // Åñëè çäîðîâû, òî, âîçìîæíî, ñòðåëÿåì áåæèì âëåâî è ñòðåëÿåì
7202 SetAIFlag('NEEDFIRE', '1');
7203 SetAIFlag('GOLEFT', '1');
7207 begin // Èäåì â íóæíóþ ñòîðîíó
7208 if GetRnd(FDifficult
.InvisFire
) then // Âîçìîæíî, ñòðåëÿåì âñëåïóþ
7209 SetAIFlag('NEEDFIRE', '1');
7210 if Healthy() <= 1 then // Ïîáèòû - óáåãàåì
7211 SetAIFlag('GORIGHT', '1');
7215 if GetAIFlag('ATTACKRIGHT') <> '' then
7216 begin // Åñëè íóæíî àòàêîâàòü íàïðàâî
7217 RemoveAIFlag('ATTACKRIGHT');
7219 SetAIFlag('NEEDJUMP', '1');
7221 if RunDirection() = TDirection
.D_LEFT
then
7222 begin // Èäåì íå â òó ñòîðîíó
7223 if (Healthy() > 1) and GetRnd(FDifficult
.InvisFire
) then
7224 begin // Åñëè çäîðîâû, òî, âîçìîæíî, áåæèì âïðàâî è ñòðåëÿåì
7225 SetAIFlag('NEEDFIRE', '1');
7226 SetAIFlag('GORIGHT', '1');
7231 if GetRnd(FDifficult
.InvisFire
) then // Âîçìîæíî, ñòðåëÿåì âñëåïóþ
7232 SetAIFlag('NEEDFIRE', '1');
7233 if Healthy() <= 1 then // Ïîáèòû - óáåãàåì
7234 SetAIFlag('GOLEFT', '1');
7238 //HACK! (does it belongs there?)
7239 RealizeCurrentWeapon();
7241 // Åñëè åñòü âîçìîæíûå öåëè:
7242 // (Ñòðåëÿåì ïî íàïðàâëåíèþ ê öåëÿì)
7243 if (targets
<> nil) and (GetAIFlag('NEEDFIRE') <> '') then
7244 for a
:= 0 to High(targets
) do
7246 // Åñëè ìîæåì ñòðåëÿòü ïî äèàãîíàëè:
7247 if GetRnd(FDifficult
.DiagFire
) then
7249 // Èùåì öåëü ñâåðõó è ñòðåëÿåì, åñëè åñòü:
7250 if FDirection
= TDirection
.D_LEFT
then
7251 angle
:= ANGLE_LEFTUP
7253 angle
:= ANGLE_RIGHTUP
;
7255 firew
:= Trunc(Cos(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
7256 fireh
:= Trunc(Sin(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
7258 if g_CollideLine(x1
, y1
, x1
+firew
, y1
+fireh
,
7259 targets
[a
].X
+targets
[a
].Rect
.X
+GetInterval(FDifficult
.DiagPrecision
, 128),
7260 targets
[a
].Y
+targets
[a
].Rect
.Y
+GetInterval(FDifficult
.DiagPrecision
, 128),
7261 targets
[a
].Rect
.Width
, targets
[a
].Rect
.Height
) and
7262 g_TraceVector(x1
, y1
, targets
[a
].cX
, targets
[a
].cY
) then
7264 SetAIFlag('NEEDFIRE', '1');
7265 SetAIFlag('NEEDSEEUP', '1');
7268 // Èùåì öåëü ñíèçó è ñòðåëÿåì, åñëè åñòü:
7269 if FDirection
= TDirection
.D_LEFT
then
7270 angle
:= ANGLE_LEFTDOWN
7272 angle
:= ANGLE_RIGHTDOWN
;
7274 firew
:= Trunc(Cos(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
7275 fireh
:= Trunc(Sin(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
7277 if g_CollideLine(x1
, y1
, x1
+firew
, y1
+fireh
,
7278 targets
[a
].X
+targets
[a
].Rect
.X
+GetInterval(FDifficult
.DiagPrecision
, 128),
7279 targets
[a
].Y
+targets
[a
].Rect
.Y
+GetInterval(FDifficult
.DiagPrecision
, 128),
7280 targets
[a
].Rect
.Width
, targets
[a
].Rect
.Height
) and
7281 g_TraceVector(x1
, y1
, targets
[a
].cX
, targets
[a
].cY
) then
7283 SetAIFlag('NEEDFIRE', '1');
7284 SetAIFlag('NEEDSEEDOWN', '1');
7288 // Åñëè öåëü "ïåðåä íîñîì", òî ñòðåëÿåì:
7289 if targets
[a
].Line
and targets
[a
].Visible
and
7290 (((FDirection
= TDirection
.D_LEFT
) and (targets
[a
].X
< FObj
.X
)) or
7291 ((FDirection
= TDirection
.D_RIGHT
) and (targets
[a
].X
> FObj
.X
))) then
7293 SetAIFlag('NEEDFIRE', '1');
7298 // Åñëè ëåòèò ïóëÿ, òî, âîçìîæíî, ïîäïðûãèâàåì:
7299 if g_Weapon_Danger(FUID
, FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+PLAYER_RECT
.Y
,
7300 PLAYER_RECT
.Width
, PLAYER_RECT
.Height
,
7301 40+GetInterval(FDifficult
.Cover
, 40)) then
7302 SetAIFlag('NEEDJUMP', '1');
7304 // Åñëè êîí÷èëèñü ïàòîðíû, òî íóæíî ñìåíèòü îðóæèå:
7305 ammo
:= GetAmmoByWeapon(FCurrWeap
);
7306 if ((FCurrWeap
= WEAPON_SHOTGUN2
) and (ammo
< 2)) or
7307 ((FCurrWeap
= WEAPON_BFG
) and (ammo
< 40)) or
7309 SetAIFlag('SELECTWEAPON', '1');
7311 // Åñëè íóæíî ñìåíèòü îðóæèå, òî âûáèðàåì íóæíîå:
7312 if GetAIFlag('SELECTWEAPON') = '1' then
7315 RemoveAIFlag('SELECTWEAPON');
7319 procedure TBot
.Update();
7332 // Ïðîâåðÿåì, îòêëþ÷¸í ëè AI áîòîâ
7333 if (g_debug_BotAIOff
= 1) and (Team
= TEAM_RED
) then
7335 if (g_debug_BotAIOff
= 2) and (Team
= TEAM_BLUE
) then
7337 if g_debug_BotAIOff
= 3 then
7347 RealizeCurrentWeapon();
7354 procedure TBot
.ReleaseKey(Key
: Byte);
7363 function TBot
.KeyPressed(Key
: Word): Boolean;
7365 Result
:= FKeys
[Key
].Pressed
;
7368 function TBot
.GetAIFlag(aName
: String20
): String20
;
7374 aName
:= LowerCase(aName
);
7376 if FAIFlags
<> nil then
7377 for a
:= 0 to High(FAIFlags
) do
7378 if LowerCase(FAIFlags
[a
].Name
) = aName
then
7380 Result
:= FAIFlags
[a
].Value
;
7385 procedure TBot
.RemoveAIFlag(aName
: String20
);
7389 if FAIFlags
= nil then Exit
;
7391 aName
:= LowerCase(aName
);
7393 for a
:= 0 to High(FAIFlags
) do
7394 if LowerCase(FAIFlags
[a
].Name
) = aName
then
7396 if a
<> High(FAIFlags
) then
7397 for b
:= a
to High(FAIFlags
)-1 do
7398 FAIFlags
[b
] := FAIFlags
[b
+1];
7400 SetLength(FAIFlags
, Length(FAIFlags
)-1);
7405 procedure TBot
.SetAIFlag(aName
, fValue
: String20
);
7413 aName
:= LowerCase(aName
);
7415 if FAIFlags
<> nil then
7416 for a
:= 0 to High(FAIFlags
) do
7417 if LowerCase(FAIFlags
[a
].Name
) = aName
then
7423 if ok
then FAIFlags
[a
].Value
:= fValue
7426 SetLength(FAIFlags
, Length(FAIFlags
)+1);
7427 with FAIFlags
[High(FAIFlags
)] do
7435 procedure TBot
.UpdateMove
;
7437 procedure GoLeft(Time
: Word = 1);
7439 ReleaseKey(KEY_LEFT
);
7440 ReleaseKey(KEY_RIGHT
);
7441 PressKey(KEY_LEFT
, Time
);
7442 SetDirection(TDirection
.D_LEFT
);
7445 procedure GoRight(Time
: Word = 1);
7447 ReleaseKey(KEY_LEFT
);
7448 ReleaseKey(KEY_RIGHT
);
7449 PressKey(KEY_RIGHT
, Time
);
7450 SetDirection(TDirection
.D_RIGHT
);
7453 function Rnd(a
: Word): Boolean;
7455 Result
:= Random(a
) = 0;
7458 procedure Turn(Time
: Word = 1200);
7460 if RunDirection() = TDirection
.D_LEFT
then GoRight(Time
) else GoLeft(Time
);
7465 ReleaseKey(KEY_LEFT
);
7466 ReleaseKey(KEY_RIGHT
);
7469 function CanRunLeft(): Boolean;
7471 Result
:= not CollideLevel(-1, 0);
7474 function CanRunRight(): Boolean;
7476 Result
:= not CollideLevel(1, 0);
7479 function CanRun(): Boolean;
7481 if RunDirection() = TDirection
.D_LEFT
then Result
:= CanRunLeft() else Result
:= CanRunRight();
7484 procedure Jump(Time
: Word = 30);
7486 PressKey(KEY_JUMP
, Time
);
7489 function NearHole(): Boolean;
7493 { TODO 5 : Ëåñòíèöû }
7494 sx
:= IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1);
7495 for x
:= 1 to PLAYER_RECT
.Width
do
7496 if (not StayOnStep(x
*sx
, 0)) and
7497 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
)) and
7498 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
*2)) then
7507 function BorderHole(): Boolean;
7511 { TODO 5 : Ëåñòíèöû }
7512 sx
:= IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1);
7513 for x
:= 1 to PLAYER_RECT
.Width
do
7514 if (not StayOnStep(x
*sx
, 0)) and
7515 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
)) and
7516 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
*2)) then
7518 for xx
:= x
to x
+32 do
7519 if CollideLevel(xx
*sx
, PLAYER_RECT
.Height
) then
7529 function NearDeepHole(): Boolean;
7535 sx
:= IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1);
7538 for x
:= 1 to PLAYER_RECT
.Width
do
7539 if (not StayOnStep(x
*sx
, 0)) and
7540 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
)) and
7541 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
*2)) then
7543 while FObj
.Y
+y
*PLAYER_RECT
.Height
< gMapInfo
.Height
do
7545 if CollideLevel(x
*sx
, PLAYER_RECT
.Height
*y
) then Exit
;
7550 end else Result
:= False;
7553 function OverDeepHole(): Boolean;
7560 while FObj
.Y
+y
*PLAYER_RECT
.Height
< gMapInfo
.Height
do
7562 if CollideLevel(0, PLAYER_RECT
.Height
*y
) then Exit
;
7569 function OnGround(): Boolean;
7571 Result
:= StayOnStep(0, 0) or CollideLevel(0, 1);
7574 function OnLadder(): Boolean;
7576 Result
:= FullInStep(0, 0);
7579 function BelowLadder(): Boolean;
7581 Result
:= (FullInStep(IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -PLAYER_RECT
.Height
) and
7582 not CollideLevel(IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -PLAYER_RECT
.Height
)) or
7583 (FullInStep(IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -BOT_MAXJUMP
) and
7584 not CollideLevel(IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -BOT_MAXJUMP
));
7587 function BelowLiftUp(): Boolean;
7589 Result
:= ((FullInLift(IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -PLAYER_RECT
.Height
) = -1) and
7590 not CollideLevel(IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -PLAYER_RECT
.Height
)) or
7591 ((FullInLift(IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -BOT_MAXJUMP
) = -1) and
7592 not CollideLevel(IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -BOT_MAXJUMP
));
7595 function OnTopLift(): Boolean;
7597 Result
:= (FullInLift(0, 0) = -1) and (FullInLift(0, -32) = 0);
7600 function CanJumpOver(): Boolean;
7604 sx
:= IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1);
7608 if not CollideLevel(sx
, 0) then Exit
;
7610 for y
:= 1 to BOT_MAXJUMP
do
7611 if CollideLevel(0, -y
) then Exit
else
7612 if not CollideLevel(sx
, -y
) then
7619 function CanJumpUp(Dist
: ShortInt): Boolean;
7626 if CollideLevel(Dist
, 0) then Exit
;
7629 for y
:= 0 to BOT_MAXJUMP
do
7630 if CollideLevel(Dist
, -y
) then
7639 for yy
:= y
+1 to BOT_MAXJUMP
do
7640 if not CollideLevel(Dist
, -yy
) then
7649 for y
:= 0 to BOT_MAXJUMP
do
7650 if CollideLevel(0, -y
) then
7658 if y
< yy
then Exit
;
7663 function IsSafeTrigger(): Boolean;
7668 if gTriggers
= nil then
7670 for a
:= 0 to High(gTriggers
) do
7671 if Collide(gTriggers
[a
].X
,
7674 gTriggers
[a
].Height
) and
7675 (gTriggers
[a
].TriggerType
in [TRIGGER_EXIT
, TRIGGER_CLOSEDOOR
,
7676 TRIGGER_CLOSETRAP
, TRIGGER_TRAP
,
7677 TRIGGER_PRESS
, TRIGGER_ON
, TRIGGER_OFF
,
7678 TRIGGER_ONOFF
, TRIGGER_SPAWNMONSTER
,
7679 TRIGGER_DAMAGE
, TRIGGER_SHOT
]) then
7684 // Âîçìîæíî, íàæèìàåì êíîïêó:
7685 if Rnd(16) and IsSafeTrigger() then
7688 // Åñëè ïîä ëèôòîì èëè ñòóïåíüêàìè, òî, âîçìîæíî, ïðûãàåì:
7689 if OnLadder() or ((BelowLadder() or BelowLiftUp()) and Rnd(8)) then
7691 ReleaseKey(KEY_LEFT
);
7692 ReleaseKey(KEY_RIGHT
);
7696 // Èäåì âëåâî, åñëè íàäî áûëî:
7697 if GetAIFlag('GOLEFT') <> '' then
7699 RemoveAIFlag('GOLEFT');
7700 if CanRunLeft() then
7704 // Èäåì âïðàâî, åñëè íàäî áûëî:
7705 if GetAIFlag('GORIGHT') <> '' then
7707 RemoveAIFlag('GORIGHT');
7708 if CanRunRight() then
7712 // Åñëè âûëåòåëè çà êàðòó, òî ïðîáóåì âåðíóòüñÿ:
7713 if FObj
.X
< -32 then
7716 if FObj
.X
+32 > gMapInfo
.Width
then
7719 // Ïðûãàåì, åñëè íàäî áûëî:
7720 if GetAIFlag('NEEDJUMP') <> '' then
7723 RemoveAIFlag('NEEDJUMP');
7726 // Ñìîòðèì ââåðõ, åñëè íàäî áûëî:
7727 if GetAIFlag('NEEDSEEUP') <> '' then
7730 ReleaseKey(KEY_DOWN
);
7731 PressKey(KEY_UP
, 20);
7732 RemoveAIFlag('NEEDSEEUP');
7735 // Ñìîòðèì âíèç, åñëè íàäî áûëî:
7736 if GetAIFlag('NEEDSEEDOWN') <> '' then
7739 ReleaseKey(KEY_DOWN
);
7740 PressKey(KEY_DOWN
, 20);
7741 RemoveAIFlag('NEEDSEEDOWN');
7744 // Åñëè íóæíî áûëî â äûðó è ìû íå íà çåìëå, òî ïîêîðíî ëåòèì:
7745 if GetAIFlag('GOINHOLE') <> '' then
7746 if not OnGround() then
7748 ReleaseKey(KEY_LEFT
);
7749 ReleaseKey(KEY_RIGHT
);
7750 RemoveAIFlag('GOINHOLE');
7751 SetAIFlag('FALLINHOLE', '1');
7754 // Åñëè ïàäàëè è äîñòèãëè çåìëè, òî õâàòèò ïàäàòü:
7755 if GetAIFlag('FALLINHOLE') <> '' then
7757 RemoveAIFlag('FALLINHOLE');
7759 // Åñëè ëåòåëè ïðÿìî è ñåé÷àñ íå íà ëåñòíèöå èëè íà âåðøèíå ëèôòà, òî îòõîäèì â ñòîðîíó:
7760 if not (KeyPressed(KEY_LEFT
) or KeyPressed(KEY_RIGHT
)) then
7761 if GetAIFlag('FALLINHOLE') = '' then
7762 if (not OnLadder()) or (FObj
.Vel
.Y
>= 0) or (OnTopLift()) then
7768 // Åñëè íà çåìëå è ìîæíî ïîäïðûãíóòü, òî, âîçìîæíî, ïðûãàåì:
7770 CanJumpUp(IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1)*32) and
7774 // Åñëè íà çåìëå è âîçëå äûðû (ãëóáèíà > 2 ðîñòîâ èãðîêà):
7775 if OnGround() and NearHole() then
7776 if NearDeepHole() then // Åñëè ýòî áåçäíà
7778 0..3: Turn(); // Áåæèì îáðàòíî
7779 4: Jump(); // Ïðûãàåì
7780 5: begin // Ïðûãàåì îáðàòíî
7785 else // Ýòî íå áåçäíà è ìû åùå íå ëåòèì òóäà
7786 if GetAIFlag('GOINHOLE') = '' then
7788 0: Turn(); // Íå íóæíî òóäà
7789 1: Jump(); // Âäðóã ïîâåçåò - ïðûãàåì
7790 else // Åñëè ÿìà ñ ãðàíèöåé, òî ïðè ñëó÷àå ìîæíî òóäà ïðûãíóòü
7791 if BorderHole() then
7792 SetAIFlag('GOINHOLE', '1');
7795 // Åñëè íà çåìëå, íî íåêóäà èäòè:
7796 if (not CanRun()) and OnGround() then
7798 // Åñëè ìû íà ëåñòíèöå èëè ìîæíî ïåðåïðûãíóòü, òî ïðûãàåì:
7799 if CanJumpOver() or OnLadder() then
7801 else // èíà÷å ïîïûòàåìñÿ â äðóãóþ ñòîðîíó
7802 if Random(2) = 0 then
7804 if IsSafeTrigger() then
7810 // Îñòàëîñü ìàëî âîçäóõà:
7811 if FAir
< 36 * 2 then
7814 // Âûáèðàåìñÿ èç êèñëîòû, åñëè íåò êîñòþìà, îáîæãëèñü, èëè ìàëî çäîðîâüÿ:
7815 if (FMegaRulez
[MR_SUIT
] < gTime
) and ((FLastHit
= HIT_ACID
) or (Healthy() <= 1)) then
7816 if BodyInAcid(0, 0) then
7820 function TBot
.FullInStep(XInc
, YInc
: Integer): Boolean;
7822 Result
:= g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
,
7823 PLAYER_RECT
.Width
, PLAYER_RECT
.Height
, PANEL_STEP
, False);
7826 {function TBot.NeedItem(Item: Byte): Byte;
7831 procedure TBot
.SelectWeapon(Dist
: Integer);
7835 function HaveAmmo(weapon
: Byte): Boolean;
7838 WEAPON_PISTOL
: Result
:= FAmmo
[A_BULLETS
] >= 1;
7839 WEAPON_SHOTGUN1
: Result
:= FAmmo
[A_SHELLS
] >= 1;
7840 WEAPON_SHOTGUN2
: Result
:= FAmmo
[A_SHELLS
] >= 2;
7841 WEAPON_CHAINGUN
: Result
:= FAmmo
[A_BULLETS
] >= 10;
7842 WEAPON_ROCKETLAUNCHER
: Result
:= FAmmo
[A_ROCKETS
] >= 1;
7843 WEAPON_PLASMA
: Result
:= FAmmo
[A_CELLS
] >= 10;
7844 WEAPON_BFG
: Result
:= FAmmo
[A_CELLS
] >= 40;
7845 WEAPON_SUPERPULEMET
: Result
:= FAmmo
[A_SHELLS
] >= 1;
7846 WEAPON_FLAMETHROWER
: Result
:= FAmmo
[A_FUEL
] >= 1;
7847 else Result
:= True;
7852 if Dist
= -1 then Dist
:= BOT_LONGDIST
;
7854 if Dist
> BOT_LONGDIST
then
7855 begin // Äàëüíèé áîé
7857 if FWeapon
[FDifficult
.WeaponPrior
[a
]] and HaveAmmo(FDifficult
.WeaponPrior
[a
]) then
7859 FSelectedWeapon
:= FDifficult
.WeaponPrior
[a
];
7863 else //if Dist > BOT_UNSAFEDIST then
7864 begin // Áëèæíèé áîé
7866 if FWeapon
[FDifficult
.CloseWeaponPrior
[a
]] and HaveAmmo(FDifficult
.CloseWeaponPrior
[a
]) then
7868 FSelectedWeapon
:= FDifficult
.CloseWeaponPrior
[a
];
7875 if FWeapon[FDifficult.SafeWeaponPrior[a]] and HaveAmmo(FDifficult.SafeWeaponPrior[a]) then
7877 FSelectedWeapon := FDifficult.SafeWeaponPrior[a];
7883 function TBot
.PickItem(ItemType
: Byte; force
: Boolean; var remove
: Boolean): Boolean;
7885 Result
:= inherited PickItem(ItemType
, force
, remove
);
7887 if Result
then SetAIFlag('SELECTWEAPON', '1');
7890 function TBot
.Heal(value
: Word; Soft
: Boolean): Boolean;
7892 Result
:= inherited Heal(value
, Soft
);
7895 function TBot
.Healthy(): Byte;
7897 if FMegaRulez
[MR_INVUL
] >= gTime
then Result
:= 3
7898 else if (FHealth
> 80) or ((FHealth
> 50) and (FArmor
> 20)) then Result
:= 3
7899 else if (FHealth
> 50) then Result
:= 2
7900 else if (FHealth
> 20) then Result
:= 1
7904 function TBot
.TargetOnScreen(TX
, TY
: Integer): Boolean;
7906 Result
:= (Abs(FObj
.X
-TX
) <= Trunc(gPlayerScreenSize
.X
*0.6)) and
7907 (Abs(FObj
.Y
-TY
) <= Trunc(gPlayerScreenSize
.Y
*0.6));
7910 procedure TBot
.OnDamage(Angle
: SmallInt);
7918 if (Angle
= 0) or (Angle
= 180) then
7921 if (g_GetUIDType(FLastSpawnerUID
) = UID_PLAYER
) and
7922 LongBool(gGameSettings
.Options
and GAME_OPTION_BOTVSPLAYER
) then
7924 pla
:= g_Player_Get(FLastSpawnerUID
);
7925 ok
:= not TargetOnScreen(pla
.FObj
.X
+ PLAYER_RECT
.X
,
7926 pla
.FObj
.Y
+ PLAYER_RECT
.Y
);
7929 if (g_GetUIDType(FLastSpawnerUID
) = UID_MONSTER
) and
7930 LongBool(gGameSettings
.Options
and GAME_OPTION_BOTVSMONSTER
) then
7932 mon
:= g_Monsters_ByUID(FLastSpawnerUID
);
7933 ok
:= not TargetOnScreen(mon
.Obj
.X
+ mon
.Obj
.Rect
.X
,
7934 mon
.Obj
.Y
+ mon
.Obj
.Rect
.Y
);
7939 SetAIFlag('ATTACKLEFT', '1')
7941 SetAIFlag('ATTACKRIGHT', '1');
7945 function TBot
.RunDirection(): TDirection
;
7947 if Abs(Vel
.X
) >= 1 then
7949 if Vel
.X
> 0 then Result
:= TDirection
.D_RIGHT
else Result
:= TDirection
.D_LEFT
;
7951 Result
:= FDirection
;
7954 function TBot
.GetRnd(a
: Byte): Boolean;
7956 if a
= 0 then Result
:= False
7957 else if a
= 255 then Result
:= True
7958 else Result
:= Random(256) > 255-a
;
7961 function TBot
.GetInterval(a
: Byte; radius
: SmallInt): SmallInt;
7963 Result
:= Round((255-a
)/255*radius
*(Random(2)-1));
7967 procedure TDifficult
.save (st
: TStream
);
7969 utils
.writeInt(st
, Byte(DiagFire
));
7970 utils
.writeInt(st
, Byte(InvisFire
));
7971 utils
.writeInt(st
, Byte(DiagPrecision
));
7972 utils
.writeInt(st
, Byte(FlyPrecision
));
7973 utils
.writeInt(st
, Byte(Cover
));
7974 utils
.writeInt(st
, Byte(CloseJump
));
7975 st
.WriteBuffer(WeaponPrior
[Low(WeaponPrior
)], sizeof(WeaponPrior
));
7976 st
.WriteBuffer(CloseWeaponPrior
[Low(CloseWeaponPrior
)], sizeof(CloseWeaponPrior
));
7979 procedure TDifficult
.load (st
: TStream
);
7981 DiagFire
:= utils
.readByte(st
);
7982 InvisFire
:= utils
.readByte(st
);
7983 DiagPrecision
:= utils
.readByte(st
);
7984 FlyPrecision
:= utils
.readByte(st
);
7985 Cover
:= utils
.readByte(st
);
7986 CloseJump
:= utils
.readByte(st
);
7987 st
.ReadBuffer(WeaponPrior
[Low(WeaponPrior
)], sizeof(WeaponPrior
));
7988 st
.ReadBuffer(CloseWeaponPrior
[Low(CloseWeaponPrior
)], sizeof(CloseWeaponPrior
));
7992 procedure TBot
.SaveState (st
: TStream
);
7997 inherited SaveState(st
);
7998 utils
.writeSign(st
, 'BOT0');
8000 utils
.writeInt(st
, Byte(FSelectedWeapon
));
8002 utils
.writeInt(st
, Word(FTargetUID
));
8003 // Âðåìÿ ïîòåðè öåëè
8004 utils
.writeInt(st
, LongWord(FLastVisible
));
8005 // Êîëè÷åñòâî ôëàãîâ ÈÈ
8006 dw
:= Length(FAIFlags
);
8007 utils
.writeInt(st
, LongInt(dw
));
8009 for i
:= 0 to dw
-1 do
8011 utils
.writeStr(st
, FAIFlags
[i
].Name
, 20);
8012 utils
.writeStr(st
, FAIFlags
[i
].Value
, 20);
8014 // Íàñòðîéêè ñëîæíîñòè
8015 FDifficult
.save(st
);
8019 procedure TBot
.LoadState (st
: TStream
);
8024 inherited LoadState(st
);
8025 if not utils
.checkSign(st
, 'BOT0') then raise XStreamError
.Create('invalid bot signature');
8027 FSelectedWeapon
:= utils
.readByte(st
);
8029 FTargetUID
:= utils
.readWord(st
);
8030 // Âðåìÿ ïîòåðè öåëè
8031 FLastVisible
:= utils
.readLongWord(st
);
8032 // Êîëè÷åñòâî ôëàãîâ ÈÈ
8033 dw
:= utils
.readLongInt(st
);
8034 if (dw
< 0) or (dw
> 16384) then raise XStreamError
.Create('invalid number of bot AI flags');
8035 SetLength(FAIFlags
, dw
);
8037 for i
:= 0 to dw
-1 do
8039 FAIFlags
[i
].Name
:= utils
.readStr(st
, 20);
8040 FAIFlags
[i
].Value
:= utils
.readStr(st
, 20);
8042 // Íàñòðîéêè ñëîæíîñòè
8043 FDifficult
.load(st
);
8048 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');
8049 conRegVar('player_indicator_style', @gPlayerIndicatorStyle
, 'Visual appearance of indicator', 'Visual appearance of indicator');