1 (* Copyright (C) Doom 2D: Forever Developers
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, version 3 of the License ONLY.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 {$INCLUDE ../shared/a_modes.inc}
23 {$IFDEF USE_MEMPOOL}mempool
,{$ENDIF}
24 e_graphics
, g_playermodel
, g_basic
, g_textures
,
25 g_weapons
, g_phys
, g_sound
, g_saveload
, MAPDEF
,
58 AmmoLimits
: Array [0..1] of Array [A_BULLETS
..A_HIGH
] of Word =
59 ((200, 50, 50, 300, 100),
60 (400, 100, 100, 600, 200));
81 ANGLE_NONE
= Low(SmallInt);
83 CORPSE_STATE_REMOVEME
= 0;
84 CORPSE_STATE_NORMAL
= 1;
85 CORPSE_STATE_MESS
= 2;
87 PLAYER_RECT
: TRectWH
= (X
:15; Y
:12; Width
:34; Height
:52);
88 PLAYER_RECT_CX
= 15+(34 div 2);
89 PLAYER_RECT_CY
= 12+(52 div 2);
90 PLAYER_CORPSERECT
: TRectWH
= (X
:15; Y
:48; Width
:34; Height
:16);
93 PLAYER_HP_LIMIT
= 200;
95 PLAYER_AP_LIMIT
= 200;
99 PLAYER_BURN_TIME
= 110;
101 PLAYER1_DEF_COLOR
: TRGB
= (R
:64; G
:175; B
:48);
102 PLAYER2_DEF_COLOR
: TRGB
= (R
:96; G
:96; B
:96);
119 TPlayerStatArray
= Array of TPlayerStat
;
121 TPlayerSavedState
= record
129 Ammo
: Array [A_BULLETS
..A_HIGH
] of Word;
130 MaxAmmo
: Array [A_BULLETS
..A_HIGH
] of Word;
131 Weapon
: Array [WP_FIRST
..WP_LAST
] of Boolean;
132 Rulez
: Set of R_ITEM_BACKPACK
..R_BERSERK
;
141 TPlayer
= class{$IFDEF USE_MEMPOOL}(TPoolObject
){$ENDIF}
149 FDirection
: TDirection
;
157 FMonsterKills
: Integer;
163 FCanJetpack
: Boolean;
169 FNextWeapDelay
: Byte; // frames
170 FBFGFireCounter
: SmallInt;
171 FLastSpawnerUID
: Word;
175 FSpectatePlayer
: Integer;
176 FFirePainTime
: Integer;
179 FSavedStateNum
: Integer;
181 FModel
: TPlayerModel
;
182 FPunchAnim
: TAnimation
;
185 FActionForce
: Boolean;
186 FActionChanged
: Boolean;
188 FFireAngle
: SmallInt;
192 FShellTimer
: Integer;
194 FSawSound
: TPlayableSound
;
195 FSawSoundIdle
: TPlayableSound
;
196 FSawSoundHit
: TPlayableSound
;
197 FSawSoundSelect
: TPlayableSound
;
198 FFlameSoundOn
: TPlayableSound
;
199 FFlameSoundOff
: TPlayableSound
;
200 FFlameSoundWork
: TPlayableSound
;
201 FJetSoundOn
: TPlayableSound
;
202 FJetSoundOff
: TPlayableSound
;
203 FJetSoundFly
: TPlayableSound
;
207 FJustTeleported
: Boolean;
209 mEDamageType
: Integer;
212 function CollideLevel(XInc
, YInc
: Integer): Boolean;
213 function StayOnStep(XInc
, YInc
: Integer): Boolean;
214 function HeadInLiquid(XInc
, YInc
: Integer): Boolean;
215 function BodyInLiquid(XInc
, YInc
: Integer): Boolean;
216 function BodyInAcid(XInc
, YInc
: Integer): Boolean;
217 function FullInLift(XInc
, YInc
: Integer): Integer;
218 {procedure CollideItem();}
219 procedure FlySmoke(Times
: DWORD
= 1);
220 procedure OnFireFlame(Times
: DWORD
= 1);
221 function GetAmmoByWeapon(Weapon
: Byte): Word;
222 procedure SetAction(Action
: Byte; Force
: Boolean = False);
223 procedure OnDamage(Angle
: SmallInt); virtual;
224 function firediry(): Integer;
227 procedure Run(Direction
: TDirection
);
228 procedure NextWeapon();
229 procedure PrevWeapon();
236 function getNextWeaponIndex (): Byte; // return 255 for "no switch"
237 procedure resetWeaponQueue ();
238 function hasAmmoForWeapon (weapon
: Byte): Boolean;
240 procedure doDamage (v
: Integer);
242 function followCorpse(): Boolean;
245 FDamageBuffer
: Integer;
247 FAmmo
: Array [A_BULLETS
..A_HIGH
] of Word;
248 FMaxAmmo
: Array [A_BULLETS
..A_HIGH
] of Word;
249 FWeapon
: Array [WP_FIRST
..WP_LAST
] of Boolean;
250 FRulez
: Set of R_ITEM_BACKPACK
..R_BERSERK
;
252 FMegaRulez
: Array [MR_SUIT
..MR_MAX
] of DWORD
;
253 FReloading
: Array [WP_FIRST
..WP_LAST
] of Word;
254 FTime
: Array [T_RESPAWN
..T_FLAGCAP
] of DWORD
;
255 FKeys
: Array [KEY_LEFT
..KEY_CHAT
] of TKeyState
;
257 FPreferredTeam
: Byte;
260 FWantsInGame
: Boolean;
265 FActualModelName
: string;
272 FSpawnInvul
: Integer;
274 FWaitForFirstSpawn
: Boolean; // set to `true` in server, used to spawn a player on first full state request
276 // debug: viewport offset
277 viewPortX
, viewPortY
, viewPortW
, viewPortH
: Integer;
279 function isValidViewPort (): Boolean; inline;
281 constructor Create(); virtual;
282 destructor Destroy(); override;
283 procedure Respawn(Silent
: Boolean; Force
: Boolean = False); virtual;
284 function GetRespawnPoint(): Byte;
285 procedure PressKey(Key
: Byte; Time
: Word = 1);
286 procedure ReleaseKeys();
287 procedure SetModel(ModelName
: String);
288 procedure SetColor(Color
: TRGB
);
289 function GetColor(): TRGB
;
290 procedure SetWeapon(W
: Byte);
291 function IsKeyPressed(K
: Byte): Boolean;
292 function GetKeys(): Byte;
293 function PickItem(ItemType
: Byte; arespawn
: Boolean; var remove
: Boolean): Boolean; virtual;
294 function Collide(X
, Y
: Integer; Width
, Height
: Word): Boolean; overload
;
295 function Collide(Panel
: TPanel
): Boolean; overload
;
296 function Collide(X
, Y
: Integer): Boolean; overload
;
297 procedure SetDirection(Direction
: TDirection
);
298 procedure GetSecret();
299 function TeleportTo(X
, Y
: Integer; silent
: Boolean; dir
: Byte): Boolean;
301 procedure Push(vx
, vy
: Integer);
302 procedure ChangeModel(ModelName
: String);
303 procedure SwitchTeam
;
304 procedure ChangeTeam(Team
: Byte);
306 function GetFlag(Flag
: Byte): Boolean;
307 procedure SetFlag(Flag
: Byte);
308 function DropFlag(Silent
: Boolean = True): Boolean;
309 procedure AllRulez(Health
: Boolean);
310 procedure RestoreHealthArmor();
311 procedure FragCombo();
312 procedure GiveItem(ItemType
: Byte);
313 procedure Damage(value
: Word; SpawnerUID
: Word; vx
, vy
: Integer; t
: Byte); virtual;
314 function Heal(value
: Word; Soft
: Boolean): Boolean; virtual;
315 procedure MakeBloodVector(Count
: Word; VelX
, VelY
: Integer);
316 procedure MakeBloodSimple(Count
: Word);
317 procedure Kill(KillType
: Byte; SpawnerUID
: Word; t
: Byte);
318 procedure Reset(Force
: Boolean);
319 procedure Spectate(NoMove
: Boolean = False);
320 procedure SwitchNoClip
;
321 procedure SoftReset();
322 procedure Draw(); virtual;
323 procedure DrawPain();
324 procedure DrawPickup();
325 procedure DrawRulez();
327 procedure DrawIndicator(Color
: TRGB
);
328 procedure DrawBubble();
330 procedure PreUpdate();
331 procedure Update(); virtual;
332 procedure RememberState();
333 procedure RecallState();
334 procedure SaveState (st
: TStream
); virtual;
335 procedure LoadState (st
: TStream
); virtual;
336 procedure PauseSounds(Enable
: Boolean);
337 procedure NetFire(Wpn
: Byte; X
, Y
, AX
, AY
: Integer; WID
: Integer = -1);
338 procedure DoLerp(Level
: Integer = 2);
339 procedure SetLerp(XTo
, YTo
: Integer);
340 procedure QueueWeaponSwitch(Weapon
: Byte);
341 procedure RealizeCurrentWeapon();
345 procedure JetpackOff
;
346 procedure CatchFire(Attacker
: Word; Timeout
: Integer = PLAYER_BURN_TIME
);
348 //WARNING! this does nothing for now, but still call it!
349 procedure positionChanged (); //WARNING! call this after entity position was changed, or coldet will not work right!
351 procedure getMapBox (out x
, y
, w
, h
: Integer); inline;
352 procedure moveBy (dx
, dy
: Integer); inline;
355 property Vel
: TPoint2i read FObj
.Vel
;
356 property Obj
: TObj read FObj
;
358 property Name
: String read FName write FName
;
359 property Model
: TPlayerModel read FModel
;
360 property Health
: Integer read FHealth write FHealth
;
361 property Lives
: Byte read FLives write FLives
;
362 property Armor
: Integer read FArmor write FArmor
;
363 property Air
: Integer read FAir write FAir
;
364 property JetFuel
: Integer read FJetFuel write FJetFuel
;
365 property Frags
: Integer read FFrags write FFrags
;
366 property Death
: Integer read FDeath write FDeath
;
367 property Kills
: Integer read FKills write FKills
;
368 property CurrWeap
: Byte read FCurrWeap write FCurrWeap
;
369 property MonsterKills
: Integer read FMonsterKills write FMonsterKills
;
370 property Secrets
: Integer read FSecrets
;
371 property GodMode
: Boolean read FGodMode write FGodMode
;
372 property NoTarget
: Boolean read FNoTarget write FNoTarget
;
373 property NoReload
: Boolean read FNoReload write FNoReload
;
374 property alive
: Boolean read FAlive write FAlive
;
375 property Flag
: Byte read FFlag
;
376 property Team
: Byte read FTeam write FTeam
;
377 property Direction
: TDirection read FDirection
;
378 property GameX
: Integer read FObj
.X write FObj
.X
;
379 property GameY
: Integer read FObj
.Y write FObj
.Y
;
380 property GameVelX
: Integer read FObj
.Vel
.X write FObj
.Vel
.X
;
381 property GameVelY
: Integer read FObj
.Vel
.Y write FObj
.Vel
.Y
;
382 property GameAccelX
: Integer read FObj
.Accel
.X write FObj
.Accel
.X
;
383 property GameAccelY
: Integer read FObj
.Accel
.Y write FObj
.Accel
.Y
;
384 property IncCam
: Integer read FIncCam write FIncCam
;
385 property IncCamOld
: Integer read FIncCamOld write FIncCamOld
;
386 property SlopeOld
: Integer read FSlopeOld write FSlopeOld
;
387 property UID
: Word read FUID write FUID
;
388 property JustTeleported
: Boolean read FJustTeleported write FJustTeleported
;
389 property NetTime
: LongWord read FNetTime write FNetTime
;
392 property eName
: String read FName write FName
;
393 property eHealth
: Integer read FHealth write FHealth
;
394 property eLives
: Byte read FLives write FLives
;
395 property eArmor
: Integer read FArmor write FArmor
;
396 property eAir
: Integer read FAir write FAir
;
397 property eJetFuel
: Integer read FJetFuel write FJetFuel
;
398 property eFrags
: Integer read FFrags write FFrags
;
399 property eDeath
: Integer read FDeath write FDeath
;
400 property eKills
: Integer read FKills write FKills
;
401 property eCurrWeap
: Byte read FCurrWeap write FCurrWeap
;
402 property eMonsterKills
: Integer read FMonsterKills write FMonsterKills
;
403 property eSecrets
: Integer read FSecrets write FSecrets
;
404 property eGodMode
: Boolean read FGodMode write FGodMode
;
405 property eNoTarget
: Boolean read FNoTarget write FNoTarget
;
406 property eNoReload
: Boolean read FNoReload write FNoReload
;
407 property eAlive
: Boolean read FAlive write FAlive
;
408 property eFlag
: Byte read FFlag
;
409 property eTeam
: Byte read FTeam write FTeam
;
410 property eDirection
: TDirection read FDirection
;
411 property eGameX
: Integer read FObj
.X write FObj
.X
;
412 property eGameY
: Integer read FObj
.Y write FObj
.Y
;
413 property eGameVelX
: Integer read FObj
.Vel
.X write FObj
.Vel
.X
;
414 property eGameVelY
: Integer read FObj
.Vel
.Y write FObj
.Vel
.Y
;
415 property eGameAccelX
: Integer read FObj
.Accel
.X write FObj
.Accel
.X
;
416 property eGameAccelY
: Integer read FObj
.Accel
.Y write FObj
.Accel
.Y
;
417 property eIncCam
: Integer read FIncCam write FIncCam
;
418 property eUID
: Word read FUID
;
419 property eJustTeleported
: Boolean read FJustTeleported
;
420 property eNetTime
: LongWord read FNetTime
;
422 // set this before assigning something to `eDamage`
423 property eDamageType
: Integer read mEDamageType write mEDamageType
;
424 property eDamage
: Integer write doDamage
;
435 WeaponPrior
: packed array [WP_FIRST
..WP_LAST
] of Byte;
436 CloseWeaponPrior
: packed array [WP_FIRST
..WP_LAST
] of Byte;
437 //SafeWeaponPrior: Array [WP_FIRST..WP_LAST] of Byte;
440 procedure save (st
: TStream
);
441 procedure load (st
: TStream
);
449 TBot
= class(TPlayer
)
451 FSelectedWeapon
: Byte;
454 FAIFlags
: Array of TAIFlag
;
455 FDifficult
: TDifficult
;
457 function GetRnd(a
: Byte): Boolean;
458 function GetInterval(a
: Byte; radius
: SmallInt): SmallInt;
459 function RunDirection(): TDirection
;
460 function FullInStep(XInc
, YInc
: Integer): Boolean;
461 //function NeedItem(Item: Byte): Byte;
462 procedure SelectWeapon(Dist
: Integer);
463 procedure SetAIFlag(aName
, fValue
: String20
);
464 function GetAIFlag(aName
: String20
): String20
;
465 procedure RemoveAIFlag(aName
: String20
);
466 function Healthy(): Byte;
467 procedure UpdateMove();
468 procedure UpdateCombat();
469 function KeyPressed(Key
: Word): Boolean;
470 procedure ReleaseKey(Key
: Byte);
471 function TargetOnScreen(TX
, TY
: Integer): Boolean;
472 procedure OnDamage(Angle
: SmallInt); override;
475 procedure Respawn(Silent
: Boolean; Force
: Boolean = False); override;
476 constructor Create(); override;
477 destructor Destroy(); override;
478 procedure Draw(); override;
479 function PickItem(ItemType
: Byte; force
: Boolean; var remove
: Boolean): Boolean; override;
480 function Heal(value
: Word; Soft
: Boolean): Boolean; override;
481 procedure Update(); override;
482 procedure SaveState (st
: TStream
); override;
483 procedure LoadState (st
: TStream
); override;
495 procedure getMapBox (out x
, y
, w
, h
: Integer); inline;
496 procedure moveBy (dx
, dy
: Integer); inline;
498 procedure positionChanged (); inline; //WARNING! call this after entity position was changed, or coldet will not work right!
512 procedure getMapBox (out x
, y
, w
, h
: Integer); inline;
513 procedure moveBy (dx
, dy
: Integer); inline;
515 procedure positionChanged (); inline; //WARNING! call this after entity position was changed, or coldet will not work right!
518 TCorpse
= class{$IFDEF USE_MEMPOOL}(TPoolObject
){$ENDIF}
527 FAnimation
: TAnimation
;
528 FAnimationMask
: TAnimation
;
531 constructor Create(X
, Y
: Integer; ModelName
: String; aMess
: Boolean);
532 destructor Destroy(); override;
533 procedure Damage(Value
: Word; vx
, vy
: Integer);
536 procedure SaveState (st
: TStream
);
537 procedure LoadState (st
: TStream
);
539 procedure getMapBox (out x
, y
, w
, h
: Integer); inline;
540 procedure moveBy (dx
, dy
: Integer); inline;
542 procedure positionChanged (); inline; //WARNING! call this after entity position was changed, or coldet will not work right!
544 function ObjPtr (): PObj
; inline;
546 property Obj
: TObj read FObj
; // copies object
547 property State
: Byte read FState
;
548 property Mess
: Boolean read FMess
;
551 TTeamStat
= Array [TEAM_RED
..TEAM_BLUE
] of
557 gPlayers
: Array of TPlayer
;
558 gCorpses
: Array of TCorpse
;
559 gGibs
: Array of TGib
;
560 gShells
: Array of TShell
;
561 gTeamStat
: TTeamStat
;
562 gFly
: Boolean = False;
563 gAimLine
: Boolean = False;
564 gChatBubble
: Integer = 0;
565 gPlayerIndicator
: Integer = 1;
566 gPlayerIndicatorStyle
: Integer = 0;
568 gSpectLatchPID1
: Word = 0;
569 gSpectLatchPID2
: Word = 0;
570 MAX_RUNVEL
: Integer = 8;
571 VEL_JUMP
: Integer = 10;
572 SHELL_TIMEOUT
: Cardinal = 60000;
574 function Lerp(X
, Y
, Factor
: Integer): Integer;
576 procedure g_Gibs_SetMax(Count
: Word);
577 function g_Gibs_GetMax(): Word;
578 procedure g_Corpses_SetMax(Count
: Word);
579 function g_Corpses_GetMax(): Word;
580 procedure g_Shells_SetMax(Count
: Word);
581 function g_Shells_GetMax(): Word;
583 procedure g_Player_Init();
584 procedure g_Player_Free();
585 function g_Player_Create(ModelName
: String; Color
: TRGB
; Team
: Byte; Bot
: Boolean): Word;
586 function g_Player_CreateFromState (st
: TStream
): Word;
587 procedure g_Player_Remove(UID
: Word);
588 procedure g_Player_ResetTeams();
589 procedure g_Player_PreUpdate();
590 procedure g_Player_UpdateAll();
591 procedure g_Player_DrawAll();
592 procedure g_Player_DrawDebug(p
: TPlayer
);
593 procedure g_Player_DrawHealth();
594 procedure g_Player_RememberAll();
595 procedure g_Player_ResetAll(Force
, Silent
: Boolean);
596 function g_Player_Get(UID
: Word): TPlayer
;
597 function g_Player_GetCount(): Byte;
598 function g_Player_GetStats(): TPlayerStatArray
;
599 function g_Player_ValidName(Name
: String): Boolean;
600 procedure g_Player_CreateCorpse(Player
: TPlayer
);
601 procedure g_Player_CreateGibs(fX
, fY
: Integer; ModelName
: String; fColor
: TRGB
);
602 procedure g_Player_CreateShell(fX
, fY
, dX
, dY
: Integer; T
: Byte);
603 procedure g_Player_UpdatePhysicalObjects();
604 procedure g_Player_DrawCorpses();
605 procedure g_Player_DrawShells();
606 procedure g_Player_RemoveAllCorpses();
607 procedure g_Player_Corpses_SaveState (st
: TStream
);
608 procedure g_Player_Corpses_LoadState (st
: TStream
);
609 procedure g_Player_ResetReady();
610 procedure g_Bot_Add(Team
, Difficult
: Byte; Handicap
: Integer = 100);
611 procedure g_Bot_AddList(Team
: Byte; lname
: ShortString; num
: Integer = -1; Handicap
: Integer = 100);
612 procedure g_Bot_MixNames();
613 procedure g_Bot_RemoveAll();
618 {$INCLUDE ../nogl/noGLuses.inc}
619 {$IFDEF ENABLE_HOLMES}
622 e_log
, g_map
, g_items
, g_console
, g_gfx
, Math
,
623 g_options
, g_triggers
, g_menu
, g_game
, g_grid
, e_res
,
624 wadreader
, g_main
, g_monsters
, CONFIG
, g_language
,
625 g_net
, g_netmsg
, g_window
,
628 const PLR_SAVE_VERSION
= 0;
638 diag_precision
: Byte;
642 w_prior1
: Array [WP_FIRST
..WP_LAST
] of Byte;
643 w_prior2
: Array [WP_FIRST
..WP_LAST
] of Byte;
644 w_prior3
: Array [WP_FIRST
..WP_LAST
] of Byte;
648 TIME_RESPAWN1
= 1500;
649 TIME_RESPAWN2
= 2000;
650 TIME_RESPAWN3
= 3000;
653 JET_MAX
= 540; // ~30 sec
654 PLAYER_SUIT_TIME
= 30000;
655 PLAYER_INVUL_TIME
= 30000;
656 PLAYER_INVIS_TIME
= 35000;
657 FRAG_COMBO_TIME
= 3000;
661 ANGLE_RIGHTDOWN
= -35;
663 ANGLE_LEFTDOWN
= -145;
664 PLAYER_HEADRECT
: TRectWH
= (X
:24; Y
:12; Width
:20; Height
:12);
665 WEAPONPOINT
: Array [TDirection
] of TDFPoint
= ((X
:16; Y
:32), (X
:47; Y
:32));
668 BOT_UNSAFEDIST
= 128;
669 TEAMCOLOR
: Array [TEAM_RED
..TEAM_BLUE
] of TRGB
= ((R
:255; G
:0; B
:0),
671 DIFFICULT_EASY
: TDifficult
= (DiagFire
: 32; InvisFire
: 32; DiagPrecision
: 32;
672 FlyPrecision
: 32; Cover
: 32; CloseJump
: 32;
673 WeaponPrior
:(0,0,0,0,0,0,0,0,0,0,0); CloseWeaponPrior
:(0,0,0,0,0,0,0,0,0,0,0));
674 DIFFICULT_MEDIUM
: TDifficult
= (DiagFire
: 127; InvisFire
: 127; DiagPrecision
: 127;
675 FlyPrecision
: 127; Cover
: 127; CloseJump
: 127;
676 WeaponPrior
:(0,0,0,0,0,0,0,0,0,0,0); CloseWeaponPrior
:(0,0,0,0,0,0,0,0,0,0,0));
677 DIFFICULT_HARD
: TDifficult
= (DiagFire
: 255; InvisFire
: 255; DiagPrecision
: 255;
678 FlyPrecision
: 255; Cover
: 255; CloseJump
: 255;
679 WeaponPrior
:(0,0,0,0,0,0,0,0,0,0,0); CloseWeaponPrior
:(0,0,0,0,0,0,0,0,0,0,0));
680 WEAPON_PRIOR1
: Array [WP_FIRST
..WP_LAST
] of Byte =
681 (WEAPON_FLAMETHROWER
, WEAPON_SUPERPULEMET
,
682 WEAPON_SHOTGUN2
, WEAPON_SHOTGUN1
,
683 WEAPON_CHAINGUN
, WEAPON_PLASMA
, WEAPON_ROCKETLAUNCHER
,
684 WEAPON_BFG
, WEAPON_PISTOL
, WEAPON_SAW
, WEAPON_KASTET
);
685 WEAPON_PRIOR2
: Array [WP_FIRST
..WP_LAST
] of Byte =
686 (WEAPON_FLAMETHROWER
, WEAPON_SUPERPULEMET
,
687 WEAPON_BFG
, WEAPON_ROCKETLAUNCHER
,
688 WEAPON_SHOTGUN2
, WEAPON_PLASMA
, WEAPON_SHOTGUN1
,
689 WEAPON_CHAINGUN
, WEAPON_PISTOL
, WEAPON_SAW
, WEAPON_KASTET
);
690 //WEAPON_PRIOR3: Array [WP_FIRST..WP_LAST] of Byte =
691 // (WEAPON_FLAMETHROWER, WEAPON_SUPERPULEMET,
692 // WEAPON_BFG, WEAPON_PLASMA, WEAPON_SHOTGUN2,
693 // WEAPON_CHAINGUN, WEAPON_SHOTGUN1, WEAPON_SAW,
694 // WEAPON_ROCKETLAUNCHER, WEAPON_PISTOL, WEAPON_KASTET);
695 WEAPON_RELOAD
: Array [WP_FIRST
..WP_LAST
] of Byte =
696 (5, 2, 6, 18, 36, 2, 12, 2, 14, 2, 2);
698 PLAYER_SIGNATURE
= $52594C50; // 'PLYR'
699 CORPSE_SIGNATURE
= $50524F43; // 'CORP'
701 BOTNAMES_FILENAME
= 'botnames.txt';
702 BOTLIST_FILENAME
= 'botlist.txt';
706 MaxCorpses
: Word = 20;
707 MaxShells
: Word = 300;
708 CurrentGib
: Integer = 0;
709 CurrentShell
: Integer = 0;
710 BotNames
: Array of String;
711 BotList
: Array of TBotProfile
;
712 SavedStates
: Array of TPlayerSavedState
;
715 function Lerp(X
, Y
, Factor
: Integer): Integer;
717 Result
:= X
+ ((Y
- X
) div Factor
);
720 function SameTeam(UID1
, UID2
: Word): Boolean;
724 if (UID1
> UID_MAX_PLAYER
) or (UID1
<= UID_MAX_GAME
) or
725 (UID2
> UID_MAX_PLAYER
) or (UID2
<= UID_MAX_GAME
) then Exit
;
727 if (g_Player_Get(UID1
) = nil) or (g_Player_Get(UID2
) = nil) then Exit
;
729 if ((g_Player_Get(UID1
).Team
= TEAM_NONE
) or
730 (g_Player_Get(UID2
).Team
= TEAM_NONE
)) then Exit
;
732 Result
:= g_Player_Get(UID1
).FTeam
= g_Player_Get(UID2
).FTeam
;
735 procedure g_Gibs_SetMax(Count
: Word);
738 SetLength(gGibs
, Count
);
740 if CurrentGib
>= Count
then
744 function g_Gibs_GetMax(): Word;
749 procedure g_Shells_SetMax(Count
: Word);
752 SetLength(gShells
, Count
);
754 if CurrentShell
>= Count
then
758 function g_Shells_GetMax(): Word;
764 procedure g_Corpses_SetMax(Count
: Word);
767 SetLength(gCorpses
, Count
);
770 function g_Corpses_GetMax(): Word;
772 Result
:= MaxCorpses
;
775 function g_Player_Create(ModelName
: String; Color
: TRGB
; Team
: Byte; Bot
: Boolean): Word;
785 // Åñòü ëè ìåñòî â gPlayers:
786 if gPlayers
<> nil then
787 for a
:= 0 to High(gPlayers
) do
788 if gPlayers
[a
] = nil then
794 // Íåò ìåñòà - ðàñøèðÿåì gPlayers:
797 SetLength(gPlayers
, Length(gPlayers
)+1);
801 // Ñîçäàåì îáúåêò èãðîêà:
803 gPlayers
[a
] := TBot
.Create()
805 gPlayers
[a
] := TPlayer
.Create();
808 gPlayers
[a
].FActualModelName
:= ModelName
;
809 gPlayers
[a
].SetModel(ModelName
);
811 // Íåò ìîäåëè - ñîçäàíèå íå âîçìîæíî:
812 if gPlayers
[a
].FModel
= nil then
816 g_FatalError(Format(_lc
[I_GAME_ERROR_MODEL
], [ModelName
]));
820 if not (Team
in [TEAM_RED
, TEAM_BLUE
]) then
821 if Random(2) = 0 then
825 gPlayers
[a
].FPreferredTeam
:= Team
;
827 case gGameSettings
.GameMode
of
828 GM_DM
: gPlayers
[a
].FTeam
:= TEAM_NONE
;
830 GM_CTF
: gPlayers
[a
].FTeam
:= gPlayers
[a
].FPreferredTeam
;
832 GM_COOP
: gPlayers
[a
].FTeam
:= TEAM_COOP
;
835 // Åñëè êîìàíäíàÿ èãðà - êðàñèì ìîäåëü â öâåò êîìàíäû:
836 gPlayers
[a
].FColor
:= Color
;
837 if gPlayers
[a
].FTeam
in [TEAM_RED
, TEAM_BLUE
] then
838 gPlayers
[a
].FModel
.Color
:= TEAMCOLOR
[gPlayers
[a
].FTeam
]
840 gPlayers
[a
].FModel
.Color
:= Color
;
842 gPlayers
[a
].FUID
:= g_CreateUID(UID_PLAYER
);
843 gPlayers
[a
].FAlive
:= False;
845 Result
:= gPlayers
[a
].FUID
;
848 function g_Player_CreateFromState (st
: TStream
): Word;
855 if (st
= nil) then exit
; //???
858 if not utils
.checkSign(st
, 'PLYR') then raise XStreamError
.Create('invalid player signature');
859 if (utils
.readByte(st
) <> PLR_SAVE_VERSION
) then raise XStreamError
.Create('invalid player version');
862 Bot
:= utils
.readBool(st
);
867 // Åñòü ëè ìåñòî â gPlayers:
868 for a
:= 0 to High(gPlayers
) do if (gPlayers
[a
] = nil) then begin ok
:= true; break
; end;
870 // Íåò ìåñòà - ðàñøèðÿåì gPlayers
873 SetLength(gPlayers
, Length(gPlayers
)+1);
877 // Ñîçäàåì îáúåêò èãðîêà
879 gPlayers
[a
] := TBot
.Create()
881 gPlayers
[a
] := TPlayer
.Create();
882 gPlayers
[a
].FIamBot
:= Bot
;
883 gPlayers
[a
].FPhysics
:= True;
886 gPlayers
[a
].FUID
:= utils
.readWord(st
);
888 gPlayers
[a
].FName
:= utils
.readStr(st
);
890 gPlayers
[a
].FTeam
:= utils
.readByte(st
);
891 gPlayers
[a
].FPreferredTeam
:= gPlayers
[a
].FTeam
;
893 gPlayers
[a
].FAlive
:= utils
.readBool(st
);
894 // Èçðàñõîäîâàë ëè âñå æèçíè
895 gPlayers
[a
].FNoRespawn
:= utils
.readBool(st
);
897 b
:= utils
.readByte(st
);
898 if b
= 1 then gPlayers
[a
].FDirection
:= TDirection
.D_LEFT
else gPlayers
[a
].FDirection
:= TDirection
.D_RIGHT
; // b = 2
900 gPlayers
[a
].FHealth
:= utils
.readLongInt(st
);
902 gPlayers
[a
].FHandicap
:= utils
.readLongInt(st
);
904 gPlayers
[a
].FLives
:= utils
.readByte(st
);
906 gPlayers
[a
].FArmor
:= utils
.readLongInt(st
);
908 gPlayers
[a
].FAir
:= utils
.readLongInt(st
);
910 gPlayers
[a
].FJetFuel
:= utils
.readLongInt(st
);
912 gPlayers
[a
].FPain
:= utils
.readLongInt(st
);
914 gPlayers
[a
].FKills
:= utils
.readLongInt(st
);
916 gPlayers
[a
].FMonsterKills
:= utils
.readLongInt(st
);
918 gPlayers
[a
].FFrags
:= utils
.readLongInt(st
);
920 gPlayers
[a
].FFragCombo
:= utils
.readByte(st
);
921 // Âðåìÿ ïîñëåäíåãî ôðàãà
922 gPlayers
[a
].FLastFrag
:= utils
.readLongWord(st
);
924 gPlayers
[a
].FDeath
:= utils
.readLongInt(st
);
926 gPlayers
[a
].FFlag
:= utils
.readByte(st
);
928 gPlayers
[a
].FSecrets
:= utils
.readLongInt(st
);
930 gPlayers
[a
].FCurrWeap
:= utils
.readByte(st
);
931 // Ñëåäóþùåå æåëàåìîå îðóæèå
932 gPlayers
[a
].FNextWeap
:= utils
.readWord(st
);
934 gPlayers
[a
].FNextWeapDelay
:= utils
.readByte(st
);
936 gPlayers
[a
].FBFGFireCounter
:= utils
.readSmallInt(st
);
938 gPlayers
[a
].FDamageBuffer
:= utils
.readLongInt(st
);
939 // Ïîñëåäíèé óäàðèâøèé
940 gPlayers
[a
].FLastSpawnerUID
:= utils
.readWord(st
);
941 // Òèï ïîñëåäíåãî ïîëó÷åííîãî óðîíà
942 gPlayers
[a
].FLastHit
:= utils
.readByte(st
);
944 Obj_LoadState(@gPlayers
[a
].FObj
, st
);
945 // Òåêóùåå êîëè÷åñòâî ïàòðîíîâ
946 for i
:= A_BULLETS
to A_HIGH
do gPlayers
[a
].FAmmo
[i
] := utils
.readWord(st
);
947 // Ìàêñèìàëüíîå êîëè÷åñòâî ïàòðîíîâ
948 for i
:= A_BULLETS
to A_HIGH
do gPlayers
[a
].FMaxAmmo
[i
] := utils
.readWord(st
);
950 for i
:= WP_FIRST
to WP_LAST
do gPlayers
[a
].FWeapon
[i
] := utils
.readBool(st
);
951 // Âðåìÿ ïåðåçàðÿäêè îðóæèÿ
952 for i
:= WP_FIRST
to WP_LAST
do gPlayers
[a
].FReloading
[i
] := utils
.readWord(st
);
954 if utils
.readBool(st
) then Include(gPlayers
[a
].FRulez
, R_ITEM_BACKPACK
);
955 // Íàëè÷èå êðàñíîãî êëþ÷à
956 if utils
.readBool(st
) then Include(gPlayers
[a
].FRulez
, R_KEY_RED
);
957 // Íàëè÷èå çåëåíîãî êëþ÷à
958 if utils
.readBool(st
) then Include(gPlayers
[a
].FRulez
, R_KEY_GREEN
);
959 // Íàëè÷èå ñèíåãî êëþ÷à
960 if utils
.readBool(st
) then Include(gPlayers
[a
].FRulez
, R_KEY_BLUE
);
962 if utils
.readBool(st
) then Include(gPlayers
[a
].FRulez
, R_BERSERK
);
963 // Âðåìÿ äåéñòâèÿ ñïåöèàëüíûõ ïðåäìåòîâ
964 for i
:= MR_SUIT
to MR_MAX
do gPlayers
[a
].FMegaRulez
[i
] := utils
.readLongWord(st
);
965 // Âðåìÿ äî ïîâòîðíîãî ðåñïàóíà, ñìåíû îðóæèÿ, èñîëüçîâàíèÿ, çàõâàòà ôëàãà
966 for i
:= T_RESPAWN
to T_FLAGCAP
do gPlayers
[a
].FTime
[i
] := utils
.readLongWord(st
);
969 gPlayers
[a
].FActualModelName
:= utils
.readStr(st
);
971 gPlayers
[a
].FColor
.R
:= utils
.readByte(st
);
972 gPlayers
[a
].FColor
.G
:= utils
.readByte(st
);
973 gPlayers
[a
].FColor
.B
:= utils
.readByte(st
);
974 // Îáíîâëÿåì ìîäåëü èãðîêà
975 gPlayers
[a
].SetModel(gPlayers
[a
].FActualModelName
);
977 // Íåò ìîäåëè - ñîçäàíèå íåâîçìîæíî
978 if (gPlayers
[a
].FModel
= nil) then
982 g_FatalError(Format(_lc
[I_GAME_ERROR_MODEL
], [gPlayers
[a
].FActualModelName
]));
986 // Åñëè êîìàíäíàÿ èãðà - êðàñèì ìîäåëü â öâåò êîìàíäû
987 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
988 gPlayers
[a
].FModel
.Color
:= TEAMCOLOR
[gPlayers
[a
].FTeam
]
990 gPlayers
[a
].FModel
.Color
:= gPlayers
[a
].FColor
;
992 result
:= gPlayers
[a
].FUID
;
996 procedure g_Player_ResetTeams();
1000 if g_Game_IsClient
then
1002 if gPlayers
= nil then
1004 for a
:= Low(gPlayers
) to High(gPlayers
) do
1005 if gPlayers
[a
] <> nil then
1006 case gGameSettings
.GameMode
of
1008 gPlayers
[a
].ChangeTeam(TEAM_NONE
);
1010 if not (gPlayers
[a
].Team
in [TEAM_RED
, TEAM_BLUE
]) then
1011 if gPlayers
[a
].FPreferredTeam
in [TEAM_RED
, TEAM_BLUE
] then
1012 gPlayers
[a
].ChangeTeam(gPlayers
[a
].FPreferredTeam
)
1015 gPlayers
[a
].ChangeTeam(TEAM_RED
)
1017 gPlayers
[a
].ChangeTeam(TEAM_BLUE
);
1020 gPlayers
[a
].ChangeTeam(TEAM_COOP
);
1024 procedure g_Bot_Add(Team
, Difficult
: Byte; Handicap
: Integer = 100);
1027 _name
, _model
: String;
1030 if not g_Game_IsServer
then Exit
;
1032 // Ñïèñîê íàçâàíèé ìîäåëåé:
1033 m
:= g_PlayerModel_GetNames();
1038 if (gGameSettings
.GameType
= GT_SINGLE
) or (gGameSettings
.GameMode
= GM_COOP
) then
1039 Team
:= TEAM_COOP
// COOP
1041 if gGameSettings
.GameMode
= GM_DM
then
1042 Team
:= TEAM_NONE
// DM
1044 if Team
= TEAM_NONE
then // CTF / TDM
1046 // Àâòîáàëàíñ êîìàíä:
1050 for a
:= 0 to High(gPlayers
) do
1051 if gPlayers
[a
] <> nil then
1053 if gPlayers
[a
].Team
= TEAM_RED
then
1056 if gPlayers
[a
].Team
= TEAM_BLUE
then
1066 if Random(2) = 0 then
1072 // Âûáèðàåì áîòó èìÿ:
1074 if BotNames
<> nil then
1075 for a
:= 0 to High(BotNames
) do
1076 if g_Player_ValidName(BotNames
[a
]) then
1078 _name
:= BotNames
[a
];
1082 // Âûáèðàåì ñëó÷àéíóþ ìîäåëü:
1083 _model
:= m
[Random(Length(m
))];
1086 with g_Player_Get(g_Player_Create(_model
,
1087 _RGB(Min(Random(9)*32, 255),
1088 Min(Random(9)*32, 255),
1089 Min(Random(9)*32, 255)),
1090 Team
, True)) as TBot
do
1092 // Åñëè èìåíè íåò, äåëàåì åãî èç UID áîòà
1094 Name
:= Format('DFBOT%.5d', [UID
])
1099 1: FDifficult
:= DIFFICULT_EASY
;
1100 2: FDifficult
:= DIFFICULT_MEDIUM
;
1101 else FDifficult
:= DIFFICULT_HARD
;
1104 for a
:= WP_FIRST
to WP_LAST
do
1106 FDifficult
.WeaponPrior
[a
] := WEAPON_PRIOR1
[a
];
1107 FDifficult
.CloseWeaponPrior
[a
] := WEAPON_PRIOR2
[a
];
1108 //FDifficult.SafeWeaponPrior[a] := WEAPON_PRIOR3[a];
1111 FHandicap
:= Handicap
;
1113 g_Console_Add(Format(_lc
[I_PLAYER_JOIN
], [Name
]), True);
1115 if g_Game_IsNet
then MH_SEND_PlayerCreate(UID
);
1116 if g_Game_IsServer
and (gGameSettings
.MaxLives
> 0) then
1121 procedure g_Bot_AddList(Team
: Byte; lName
: ShortString; num
: Integer = -1; Handicap
: Integer = 100);
1124 _name
, _model
: String;
1127 if not g_Game_IsServer
then Exit
;
1129 // Ñïèñîê íàçâàíèé ìîäåëåé:
1130 m
:= g_PlayerModel_GetNames();
1135 if (gGameSettings
.GameType
= GT_SINGLE
) or (gGameSettings
.GameMode
= GM_COOP
) then
1136 Team
:= TEAM_COOP
// COOP
1138 if gGameSettings
.GameMode
= GM_DM
then
1139 Team
:= TEAM_NONE
// DM
1141 if Team
= TEAM_NONE
then
1142 Team
:= BotList
[num
].team
; // CTF / TDM
1144 // Âûáèðàåì íàñòðîéêè áîòà èç ñïèñêà ïî íîìåðó èëè èìåíè:
1145 lName
:= AnsiLowerCase(lName
);
1146 if (num
< 0) or (num
> Length(BotList
)-1) then
1148 if (num
= -1) and (lName
<> '') and (BotList
<> nil) then
1149 for a
:= 0 to High(BotList
) do
1150 if AnsiLowerCase(BotList
[a
].name
) = lName
then
1159 _name
:= BotList
[num
].name
;
1160 // Çàíÿòî - âûáèðàåì ñëó÷àéíîå:
1161 if not g_Player_ValidName(_name
) then
1163 _name
:= Format('DFBOT%.2d', [Random(100)]);
1164 until g_Player_ValidName(_name
);
1167 _model
:= BotList
[num
].model
;
1168 // Íåò òàêîé - âûáèðàåì ñëó÷àéíóþ:
1169 if not InSArray(_model
, m
) then
1170 _model
:= m
[Random(Length(m
))];
1173 with g_Player_Get(g_Player_Create(_model
, BotList
[num
].color
, Team
, True)) as TBot
do
1177 FDifficult
.DiagFire
:= BotList
[num
].diag_fire
;
1178 FDifficult
.InvisFire
:= BotList
[num
].invis_fire
;
1179 FDifficult
.DiagPrecision
:= BotList
[num
].diag_precision
;
1180 FDifficult
.FlyPrecision
:= BotList
[num
].fly_precision
;
1181 FDifficult
.Cover
:= BotList
[num
].cover
;
1182 FDifficult
.CloseJump
:= BotList
[num
].close_jump
;
1184 FHandicap
:= Handicap
;
1186 for a
:= WP_FIRST
to WP_LAST
do
1188 FDifficult
.WeaponPrior
[a
] := BotList
[num
].w_prior1
[a
];
1189 FDifficult
.CloseWeaponPrior
[a
] := BotList
[num
].w_prior2
[a
];
1190 //FDifficult.SafeWeaponPrior[a] := BotList[num].w_prior3[a];
1193 g_Console_Add(Format(_lc
[I_PLAYER_JOIN
], [Name
]), True);
1195 if g_Game_IsNet
then MH_SEND_PlayerCreate(UID
);
1199 procedure g_Bot_RemoveAll();
1203 if not g_Game_IsServer
then Exit
;
1204 if gPlayers
= nil then Exit
;
1206 for a
:= 0 to High(gPlayers
) do
1207 if gPlayers
[a
] <> nil then
1208 if gPlayers
[a
] is TBot
then
1210 gPlayers
[a
].Lives
:= 0;
1211 gPlayers
[a
].Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
1212 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [gPlayers
[a
].Name
]), True);
1213 g_Player_Remove(gPlayers
[a
].FUID
);
1219 procedure g_Bot_MixNames();
1224 if BotNames
<> nil then
1225 for a
:= 0 to High(BotNames
) do
1227 b
:= Random(Length(BotNames
));
1229 Botnames
[a
] := BotNames
[b
];
1234 procedure g_Player_Remove(UID
: Word);
1238 if gPlayers
= nil then Exit
;
1240 if g_Game_IsServer
and g_Game_IsNet
then
1241 MH_SEND_PlayerDelete(UID
);
1243 for i
:= 0 to High(gPlayers
) do
1244 if gPlayers
[i
] <> nil then
1245 if gPlayers
[i
].FUID
= UID
then
1247 if gPlayers
[i
] is TPlayer
then
1248 TPlayer(gPlayers
[i
]).Free()
1250 TBot(gPlayers
[i
]).Free();
1256 procedure g_Player_Init();
1267 path
:= BOTNAMES_FILENAME
;
1268 if e_FindResource(DataDirs
, path
) = false then
1271 // ×èòàåì âîçìîæíûå èìåíà áîòîâ èç ôàéëà:
1272 AssignFile(F
, path
);
1283 SetLength(BotNames
, Length(BotNames
)+1);
1284 BotNames
[High(BotNames
)] := s
;
1292 // ×èòàåì ôàéë ñ ïàðàìåòðàìè áîòîâ:
1293 config
:= TConfig
.CreateFile(path
);
1297 while config
.SectionExists(IntToStr(a
)) do
1299 SetLength(BotList
, Length(BotList
)+1);
1301 with BotList
[High(BotList
)] do
1304 name
:= config
.ReadStr(IntToStr(a
), 'name', '');
1306 model
:= config
.ReadStr(IntToStr(a
), 'model', '');
1308 if config
.ReadStr(IntToStr(a
), 'team', 'red') = 'red' then
1313 sa
:= parse(config
.ReadStr(IntToStr(a
), 'color', ''));
1314 color
.R
:= StrToIntDef(sa
[0], 0);
1315 color
.G
:= StrToIntDef(sa
[1], 0);
1316 color
.B
:= StrToIntDef(sa
[2], 0);
1317 // Âåðîÿòíîñòü ñòðåëüáû ïîä óãëîì:
1318 diag_fire
:= config
.ReadInt(IntToStr(a
), 'diag_fire', 0);
1319 // Âåðîÿòíîñòü îòâåòíîãî îãíÿ ïî íåâèäèìîìó ñîïåðíèêó:
1320 invis_fire
:= config
.ReadInt(IntToStr(a
), 'invis_fire', 0);
1321 // Òî÷íîñòü ñòðåëüáû ïîä óãëîì:
1322 diag_precision
:= config
.ReadInt(IntToStr(a
), 'diag_precision', 0);
1323 // Òî÷íîñòü ñòðåëüáû â ïîëåòå:
1324 fly_precision
:= config
.ReadInt(IntToStr(a
), 'fly_precision', 0);
1325 // Òî÷íîñòü óêëîíåíèÿ îò ñíàðÿäîâ:
1326 cover
:= config
.ReadInt(IntToStr(a
), 'cover', 0);
1327 // Âåðîÿòíîñòü ïðûæêà ïðè ïðèáëèæåíèè ñîïåðíèêà:
1328 close_jump
:= config
.ReadInt(IntToStr(a
), 'close_jump', 0);
1329 // Ïðèîðèòåòû îðóæèÿ äëÿ äàëüíåãî áîÿ:
1330 sa
:= parse(config
.ReadStr(IntToStr(a
), 'w_prior1', ''));
1331 if Length(sa
) = 10 then
1333 w_prior1
[b
] := EnsureRange(StrToInt(sa
[b
]), 0, 9);
1334 // Ïðèîðèòåòû îðóæèÿ äëÿ áëèæíåãî áîÿ:
1335 sa
:= parse(config
.ReadStr(IntToStr(a
), 'w_prior2', ''));
1336 if Length(sa
) = 10 then
1338 w_prior2
[b
] := EnsureRange(StrToInt(sa
[b
]), 0, 9);
1340 {sa := parse(config.ReadStr(IntToStr(a), 'w_prior3', ''));
1341 if Length(sa) = 10 then
1343 w_prior3[b] := EnsureRange(StrToInt(sa[b]), 0, 9);}
1350 SetLength(SavedStates
, 0);
1353 procedure g_Player_Free();
1357 if gPlayers
<> nil then
1359 for i
:= 0 to High(gPlayers
) do
1360 if gPlayers
[i
] <> nil then
1362 if gPlayers
[i
] is TPlayer
then
1363 TPlayer(gPlayers
[i
]).Free()
1365 TBot(gPlayers
[i
]).Free();
1374 SetLength(SavedStates
, 0);
1377 procedure g_Player_PreUpdate();
1381 if gPlayers
= nil then Exit
;
1382 for i
:= 0 to High(gPlayers
) do
1383 if gPlayers
[i
] <> nil then
1384 gPlayers
[i
].PreUpdate();
1387 procedure g_Player_UpdateAll();
1391 if gPlayers
= nil then Exit
;
1393 //e_WriteLog('***g_Player_UpdateAll: ENTER', MSG_WARNING);
1394 for i
:= 0 to High(gPlayers
) do
1396 if gPlayers
[i
] <> nil then
1398 if gPlayers
[i
] is TPlayer
then
1400 gPlayers
[i
].Update();
1401 gPlayers
[i
].RealizeCurrentWeapon(); // WARNING! DO NOT MOVE THIS INTO `Update()`!
1405 // bot updates weapons in `UpdateCombat()`
1406 TBot(gPlayers
[i
]).Update();
1410 //e_WriteLog('***g_Player_UpdateAll: EXIT', MSG_WARNING);
1413 procedure g_Player_DrawAll();
1417 if gPlayers
= nil then Exit
;
1419 for i
:= 0 to High(gPlayers
) do
1420 if gPlayers
[i
] <> nil then
1421 if gPlayers
[i
] is TPlayer
then gPlayers
[i
].Draw()
1422 else TBot(gPlayers
[i
]).Draw();
1425 procedure g_Player_DrawDebug(p
: TPlayer
);
1429 if p
= nil then Exit
;
1430 if (@p
.FObj
) = nil then Exit
;
1432 e_TextureFontGetSize(gStdFont
, fW
, fH
);
1434 e_TextureFontPrint(0, 0 , 'Pos X: ' + IntToStr(p
.FObj
.X
), gStdFont
);
1435 e_TextureFontPrint(0, fH
, 'Pos Y: ' + IntToStr(p
.FObj
.Y
), gStdFont
);
1436 e_TextureFontPrint(0, fH
* 2, 'Vel X: ' + IntToStr(p
.FObj
.Vel
.X
), gStdFont
);
1437 e_TextureFontPrint(0, fH
* 3, 'Vel Y: ' + IntToStr(p
.FObj
.Vel
.Y
), gStdFont
);
1438 e_TextureFontPrint(0, fH
* 4, 'Acc X: ' + IntToStr(p
.FObj
.Accel
.X
), gStdFont
);
1439 e_TextureFontPrint(0, fH
* 5, 'Acc Y: ' + IntToStr(p
.FObj
.Accel
.Y
), gStdFont
);
1442 procedure g_Player_DrawHealth();
1447 if gPlayers
= nil then Exit
;
1448 e_TextureFontGetSize(gStdFont
, fW
, fH
);
1450 for i
:= 0 to High(gPlayers
) do
1451 if gPlayers
[i
] <> nil then
1453 e_TextureFontPrint(gPlayers
[i
].FObj
.X
+ gPlayers
[i
].FObj
.Rect
.X
,
1454 gPlayers
[i
].FObj
.Y
+ gPlayers
[i
].FObj
.Rect
.Y
+ gPlayers
[i
].FObj
.Rect
.Height
- fH
* 2,
1455 IntToStr(gPlayers
[i
].FHealth
), gStdFont
);
1456 e_TextureFontPrint(gPlayers
[i
].FObj
.X
+ gPlayers
[i
].FObj
.Rect
.X
,
1457 gPlayers
[i
].FObj
.Y
+ gPlayers
[i
].FObj
.Rect
.Y
+ gPlayers
[i
].FObj
.Rect
.Height
- fH
,
1458 IntToStr(gPlayers
[i
].FArmor
), gStdFont
);
1462 function g_Player_Get(UID
: Word): TPlayer
;
1468 if gPlayers
= nil then
1471 for a
:= 0 to High(gPlayers
) do
1472 if gPlayers
[a
] <> nil then
1473 if gPlayers
[a
].FUID
= UID
then
1475 Result
:= gPlayers
[a
];
1480 function g_Player_GetCount(): Byte;
1486 if gPlayers
= nil then
1489 for a
:= 0 to High(gPlayers
) do
1490 if gPlayers
[a
] <> nil then
1491 Result
:= Result
+ 1;
1494 function g_Player_GetStats(): TPlayerStatArray
;
1500 if gPlayers
= nil then Exit
;
1502 for a
:= 0 to High(gPlayers
) do
1503 if gPlayers
[a
] <> nil then
1505 SetLength(Result
, Length(Result
)+1);
1506 with Result
[High(Result
)] do
1509 Ping
:= gPlayers
[a
].FPing
;
1510 Loss
:= gPlayers
[a
].FLoss
;
1511 Name
:= gPlayers
[a
].FName
;
1512 Team
:= gPlayers
[a
].FTeam
;
1513 Frags
:= gPlayers
[a
].FFrags
;
1514 Deaths
:= gPlayers
[a
].FDeath
;
1515 Kills
:= gPlayers
[a
].FKills
;
1516 Color
:= gPlayers
[a
].FModel
.Color
;
1517 Lives
:= gPlayers
[a
].FLives
;
1518 Spectator
:= gPlayers
[a
].FSpectator
;
1523 procedure g_Player_ResetReady();
1527 if not g_Game_IsServer
then Exit
;
1528 if gPlayers
= nil then Exit
;
1530 for a
:= 0 to High(gPlayers
) do
1531 if gPlayers
[a
] <> nil then
1533 gPlayers
[a
].FReady
:= False;
1534 if g_Game_IsNet
then
1535 MH_SEND_GameEvent(NET_EV_INTER_READY
, gPlayers
[a
].UID
, 'N');
1539 procedure g_Player_RememberAll
;
1543 for i
:= Low(gPlayers
) to High(gPlayers
) do
1544 if (gPlayers
[i
] <> nil) and gPlayers
[i
].alive
then
1545 gPlayers
[i
].RememberState
;
1548 procedure g_Player_ResetAll(Force
, Silent
: Boolean);
1552 gTeamStat
[TEAM_RED
].Goals
:= 0;
1553 gTeamStat
[TEAM_BLUE
].Goals
:= 0;
1555 if gPlayers
<> nil then
1556 for i
:= 0 to High(gPlayers
) do
1557 if gPlayers
[i
] <> nil then
1559 gPlayers
[i
].Reset(Force
);
1561 if gPlayers
[i
] is TPlayer
then
1563 if (not gPlayers
[i
].FSpectator
) or gPlayers
[i
].FWantsInGame
then
1564 gPlayers
[i
].Respawn(Silent
)
1566 gPlayers
[i
].Spectate();
1569 TBot(gPlayers
[i
]).Respawn(Silent
);
1573 procedure g_Player_CreateCorpse(Player
: TPlayer
);
1579 if Player
.alive
then
1582 // Ðàçðûâàåì ñâÿçü ñ ïðåæíèì òðóïîì:
1583 if gCorpses
<> nil then
1584 for i
:= 0 to High(gCorpses
) do
1585 if gCorpses
[i
] <> nil then
1586 if gCorpses
[i
].FPlayerUID
= Player
.FUID
then
1587 gCorpses
[i
].FPlayerUID
:= 0;
1589 if Player
.FObj
.Y
>= gMapInfo
.Height
+128 then
1594 if (FHealth
>= -50) or (gGibsCount
= 0) then
1596 if (gCorpses
= nil) or (Length(gCorpses
) = 0) then
1600 for find_id
:= 0 to High(gCorpses
) do
1601 if gCorpses
[find_id
] = nil then
1608 find_id
:= Random(Length(gCorpses
));
1610 gCorpses
[find_id
] := TCorpse
.Create(FObj
.X
, FObj
.Y
, FModel
.Name
, FHealth
< -20);
1611 gCorpses
[find_id
].FColor
:= FModel
.Color
;
1612 gCorpses
[find_id
].FObj
.Vel
:= FObj
.Vel
;
1613 gCorpses
[find_id
].FObj
.Accel
:= FObj
.Accel
;
1614 gCorpses
[find_id
].FPlayerUID
:= FUID
;
1617 g_Player_CreateGibs(FObj
.X
+ PLAYER_RECT_CX
,
1618 FObj
.Y
+ PLAYER_RECT_CY
,
1619 FModel
.Name
, FModel
.Color
);
1623 procedure g_Player_CreateShell(fX
, fY
, dX
, dY
: Integer; T
: Byte);
1627 if (gShells
= nil) or (Length(gShells
) = 0) then
1630 with gShells
[CurrentShell
] do
1636 if T
= SHELL_BULLET
then
1638 if g_Texture_Get('TEXTURE_SHELL_BULLET', SID
) then
1642 Obj
.Rect
.Width
:= 4;
1643 Obj
.Rect
.Height
:= 2;
1647 if g_Texture_Get('TEXTURE_SHELL_SHELL', SID
) then
1651 Obj
.Rect
.Width
:= 7;
1652 Obj
.Rect
.Height
:= 3;
1658 g_Obj_Push(@Obj
, dX
+ Random(4)-Random(4), dY
-Random(4));
1659 positionChanged(); // this updates spatial accelerators
1660 RAngle
:= Random(360);
1661 Timeout
:= gTime
+ SHELL_TIMEOUT
;
1663 if CurrentShell
>= High(gShells
) then
1670 procedure g_Player_CreateGibs(fX
, fY
: Integer; ModelName
: string; fColor
: TRGB
);
1673 GibsArray
: TGibsArray
;
1676 if (gGibs
= nil) or (Length(gGibs
) = 0) then
1678 if not g_PlayerModel_GetGibs(ModelName
, GibsArray
) then
1680 Blood
:= g_PlayerModel_GetBlood(ModelName
);
1682 for a
:= 0 to High(GibsArray
) do
1683 with gGibs
[CurrentGib
] do
1686 ID
:= GibsArray
[a
].ID
;
1687 MaskID
:= GibsArray
[a
].MaskID
;
1690 Obj
.Rect
:= GibsArray
[a
].Rect
;
1691 Obj
.X
:= fX
-GibsArray
[a
].Rect
.X
-(GibsArray
[a
].Rect
.Width
div 2);
1692 Obj
.Y
:= fY
-GibsArray
[a
].Rect
.Y
-(GibsArray
[a
].Rect
.Height
div 2);
1693 g_Obj_PushA(@Obj
, 25 + Random(10), Random(361));
1694 positionChanged(); // this updates spatial accelerators
1695 RAngle
:= Random(360);
1697 if gBloodCount
> 0 then
1698 g_GFX_Blood(fX
, fY
, 16*gBloodCount
+Random(5*gBloodCount
), -16+Random(33), -16+Random(33),
1699 Random(48), Random(48), Blood
.R
, Blood
.G
, Blood
.B
, Blood
.Kind
);
1701 if CurrentGib
>= High(gGibs
) then
1708 procedure g_Player_UpdatePhysicalObjects();
1714 procedure ShellSound_Bounce(X
, Y
: Integer; T
: Byte);
1719 if T
= SHELL_BULLET
then
1720 g_Sound_PlayExAt('SOUND_PLAYER_CASING' + IntToStr(k
), X
, Y
)
1722 g_Sound_PlayExAt('SOUND_PLAYER_SHELL' + IntToStr(k
), X
, Y
);
1727 if gGibs
<> nil then
1728 for i
:= 0 to High(gGibs
) do
1729 if gGibs
[i
].alive
then
1736 mr
:= g_Obj_Move(@Obj
, True, False, True);
1737 positionChanged(); // this updates spatial accelerators
1739 if WordBool(mr
and MOVE_FALLOUT
) then
1745 // Îòëåòàåò îò óäàðà î ñòåíó/ïîòîëîê/ïîë:
1746 if WordBool(mr
and MOVE_HITWALL
) then
1747 Obj
.Vel
.X
:= -(vel
.X
div 2);
1748 if WordBool(mr
and (MOVE_HITCEIL
or MOVE_HITLAND
)) then
1749 Obj
.Vel
.Y
:= -(vel
.Y
div 2);
1751 if (Obj
.Vel
.X
>= 0) then
1753 RAngle
:= RAngle
+ Abs(Obj
.Vel
.X
)*6 + Abs(Obj
.Vel
.Y
);
1754 if RAngle
>= 360 then
1755 RAngle
:= RAngle
mod 360;
1756 end else begin // Counter-clockwise
1757 RAngle
:= RAngle
- Abs(Obj
.Vel
.X
)*6 - Abs(Obj
.Vel
.Y
);
1759 RAngle
:= (360 - (Abs(RAngle
) mod 360)) mod 360;
1762 // Ñîïðîòèâëåíèå âîçäóõà äëÿ êóñêà òðóïà:
1763 if gTime
mod (GAME_TICK
*3) = 0 then
1764 Obj
.Vel
.X
:= z_dec(Obj
.Vel
.X
, 1);
1768 if gCorpses
<> nil then
1769 for i
:= 0 to High(gCorpses
) do
1770 if gCorpses
[i
] <> nil then
1771 if gCorpses
[i
].State
= CORPSE_STATE_REMOVEME
then
1777 gCorpses
[i
].Update();
1780 if gShells
<> nil then
1781 for i
:= 0 to High(gShells
) do
1782 if gShells
[i
].alive
then
1789 mr
:= g_Obj_Move(@Obj
, True, False, True);
1790 positionChanged(); // this updates spatial accelerators
1792 if WordBool(mr
and MOVE_FALLOUT
) or (gShells
[i
].Timeout
< gTime
) then
1798 // Îòëåòàåò îò óäàðà î ñòåíó/ïîòîëîê/ïîë:
1799 if WordBool(mr
and MOVE_HITWALL
) then
1801 Obj
.Vel
.X
:= -(vel
.X
div 2);
1802 if not WordBool(mr
and MOVE_INWATER
) then
1803 ShellSound_Bounce(Obj
.X
, Obj
.Y
, SType
);
1805 if WordBool(mr
and (MOVE_HITCEIL
or MOVE_HITLAND
)) then
1807 Obj
.Vel
.Y
:= -(vel
.Y
div 2);
1808 if Obj
.Vel
.X
<> 0 then Obj
.Vel
.X
:= Obj
.Vel
.X
div 2;
1809 if (Obj
.Vel
.X
= 0) and (Obj
.Vel
.Y
= 0) then
1811 if RAngle
mod 90 <> 0 then
1812 RAngle
:= (RAngle
div 90) * 90;
1814 else if not WordBool(mr
and MOVE_INWATER
) then
1815 ShellSound_Bounce(Obj
.X
, Obj
.Y
, SType
);
1818 if (Obj
.Vel
.X
>= 0) then
1820 RAngle
:= RAngle
+ Abs(Obj
.Vel
.X
)*8 + Abs(Obj
.Vel
.Y
);
1821 if RAngle
>= 360 then
1822 RAngle
:= RAngle
mod 360;
1823 end else begin // Counter-clockwise
1824 RAngle
:= RAngle
- Abs(Obj
.Vel
.X
)*8 - Abs(Obj
.Vel
.Y
);
1826 RAngle
:= (360 - (Abs(RAngle
) mod 360)) mod 360;
1832 procedure TGib
.getMapBox (out x
, y
, w
, h
: Integer); inline;
1834 x
:= Obj
.X
+Obj
.Rect
.X
;
1835 y
:= Obj
.Y
+Obj
.Rect
.Y
;
1836 w
:= Obj
.Rect
.Width
;
1837 h
:= Obj
.Rect
.Height
;
1840 procedure TGib
.moveBy (dx
, dy
: Integer); inline;
1842 if (dx
<> 0) or (dy
<> 0) then
1851 procedure TShell
.getMapBox (out x
, y
, w
, h
: Integer); inline;
1855 w
:= Obj
.Rect
.Width
;
1856 h
:= Obj
.Rect
.Height
;
1859 procedure TShell
.moveBy (dx
, dy
: Integer); inline;
1861 if (dx
<> 0) or (dy
<> 0) then
1870 procedure TGib
.positionChanged (); inline; begin end;
1871 procedure TShell
.positionChanged (); inline; begin end;
1874 procedure g_Player_DrawCorpses();
1879 if gGibs
<> nil then
1880 for i
:= 0 to High(gGibs
) do
1881 if gGibs
[i
].alive
then
1884 if not g_Obj_Collide(sX
, sY
, sWidth
, sHeight
, @Obj
) then
1887 Obj
.lerp(gLerpFactor
, fX
, fY
);
1889 a
.X
:= Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2);
1890 a
.y
:= Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2);
1892 e_DrawAdv(ID
, fX
, fY
, 0, True, False, RAngle
, @a
, TMirrorType
.None
);
1895 e_DrawAdv(MaskID
, fX
, fY
, 0, True, False, RAngle
, @a
, TMirrorType
.None
);
1901 if gCorpses
<> nil then
1902 for i
:= 0 to High(gCorpses
) do
1903 if gCorpses
[i
] <> nil then
1907 procedure g_Player_DrawShells();
1912 if gShells
<> nil then
1913 for i
:= 0 to High(gShells
) do
1914 if gShells
[i
].alive
then
1917 if not g_Obj_Collide(sX
, sY
, sWidth
, sHeight
, @Obj
) then
1920 Obj
.lerp(gLerpFactor
, fX
, fY
);
1925 e_DrawAdv(SpriteID
, fX
, fY
, 0, True, False, RAngle
, @a
, TMirrorType
.None
);
1929 procedure g_Player_RemoveAllCorpses();
1935 SetLength(gGibs
, MaxGibs
);
1936 SetLength(gShells
, MaxGibs
);
1940 if gCorpses
<> nil then
1941 for i
:= 0 to High(gCorpses
) do
1945 SetLength(gCorpses
, MaxCorpses
);
1948 procedure g_Player_Corpses_SaveState (st
: TStream
);
1952 // Ñ÷èòàåì êîëè÷åñòâî ñóùåñòâóþùèõ òðóïîâ
1954 for i
:= 0 to High(gCorpses
) do if (gCorpses
[i
] <> nil) then Inc(count
);
1956 // Êîëè÷åñòâî òðóïîâ
1957 utils
.writeInt(st
, LongInt(count
));
1959 if (count
= 0) then exit
;
1962 for i
:= 0 to High(gCorpses
) do
1964 if gCorpses
[i
] <> nil then
1967 utils
.writeStr(st
, gCorpses
[i
].FModelName
);
1969 utils
.writeBool(st
, gCorpses
[i
].Mess
);
1970 // Ñîõðàíÿåì äàííûå òðóïà:
1971 gCorpses
[i
].SaveState(st
);
1977 procedure g_Player_Corpses_LoadState (st
: TStream
);
1985 g_Player_RemoveAllCorpses();
1987 // Êîëè÷åñòâî òðóïîâ:
1988 count
:= utils
.readLongInt(st
);
1989 if (count
< 0) or (count
> Length(gCorpses
)) then raise XStreamError
.Create('invalid number of corpses');
1991 if (count
= 0) then exit
;
1994 for i
:= 0 to count
-1 do
1997 str
:= utils
.readStr(st
);
1999 b
:= utils
.readBool(st
);
2001 gCorpses
[i
] := TCorpse
.Create(0, 0, str
, b
);
2002 // Çàãðóæàåì äàííûå òðóïà
2003 gCorpses
[i
].LoadState(st
);
2010 function TPlayer
.isValidViewPort (): Boolean; inline; begin result
:= (viewPortW
> 0) and (viewPortH
> 0); end;
2012 procedure TPlayer
.BFGHit();
2014 g_Weapon_BFGHit(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
2015 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2));
2016 if g_Game_IsServer
and g_Game_IsNet
then
2017 MH_SEND_Effect(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
2018 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2),
2022 procedure TPlayer
.ChangeModel(ModelName
: string);
2024 locModel
: TPlayerModel
;
2026 locModel
:= g_PlayerModel_Get(ModelName
);
2027 if locModel
= nil then Exit
;
2033 procedure TPlayer
.SetModel(ModelName
: string);
2037 m
:= g_PlayerModel_Get(ModelName
);
2040 g_SimpleError(Format(_lc
[I_GAME_ERROR_MODEL_FALLBACK
], [ModelName
]));
2041 m
:= g_PlayerModel_Get('doomer');
2044 g_FatalError(Format(_lc
[I_GAME_ERROR_MODEL
], ['doomer']));
2049 if FModel
<> nil then
2054 if not (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then
2055 FModel
.Color
:= FColor
2057 FModel
.Color
:= TEAMCOLOR
[FTeam
];
2058 FModel
.SetWeapon(FCurrWeap
);
2059 FModel
.SetFlag(FFlag
);
2060 SetDirection(FDirection
);
2063 procedure TPlayer
.SetColor(Color
: TRGB
);
2066 if not (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then
2067 if FModel
<> nil then FModel
.Color
:= Color
;
2070 function TPlayer
.GetColor(): TRGB
;
2072 result
:= FModel
.Color
;
2075 procedure TPlayer
.SwitchTeam
;
2077 if g_Game_IsClient
then
2079 if not (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then Exit
;
2081 if gGameOn
and FAlive
then
2082 Kill(K_SIMPLEKILL
, FUID
, HIT_SELF
);
2084 if FTeam
= TEAM_RED
then
2086 ChangeTeam(TEAM_BLUE
);
2087 g_Console_Add(Format(_lc
[I_PLAYER_CHTEAM_BLUE
], [FName
]), True);
2088 if g_Game_IsNet
then
2089 MH_SEND_GameEvent(NET_EV_CHANGE_TEAM
, TEAM_BLUE
, FName
);
2093 ChangeTeam(TEAM_RED
);
2094 g_Console_Add(Format(_lc
[I_PLAYER_CHTEAM_RED
], [FName
]), True);
2095 if g_Game_IsNet
then
2096 MH_SEND_GameEvent(NET_EV_CHANGE_TEAM
, TEAM_RED
, FName
);
2098 FPreferredTeam
:= FTeam
;
2101 procedure TPlayer
.ChangeTeam(Team
: Byte);
2108 TEAM_RED
, TEAM_BLUE
:
2109 FModel
.Color
:= TEAMCOLOR
[Team
];
2111 FModel
.Color
:= FColor
;
2113 if (FTeam
<> OldTeam
) and g_Game_IsNet
and g_Game_IsServer
then
2114 MH_SEND_PlayerStats(FUID
);
2118 procedure TPlayer.CollideItem();
2123 if gItems = nil then Exit;
2124 if not FAlive then Exit;
2126 for i := 0 to High(gItems) do
2129 if (ItemType <> ITEM_NONE) and alive then
2130 if g_Obj_Collide(FObj.X+PLAYER_RECT.X, FObj.Y+PLAYER_RECT.Y, PLAYER_RECT.Width,
2131 PLAYER_RECT.Height, @Obj) then
2133 if not PickItem(ItemType, gItems[i].Respawnable, r) then Continue;
2135 if ItemType in [ITEM_SPHERE_BLUE, ITEM_SPHERE_WHITE, ITEM_INVUL] then
2136 g_Sound_PlayExAt('SOUND_ITEM_GETRULEZ', FObj.X, FObj.Y)
2137 else if ItemType in [ITEM_MEDKIT_SMALL, ITEM_MEDKIT_LARGE, ITEM_MEDKIT_BLACK] then
2138 g_Sound_PlayExAt('SOUND_ITEM_GETMED', FObj.X, FObj.Y)
2139 else g_Sound_PlayExAt('SOUND_ITEM_GETITEM', FObj.X, FObj.Y);
2141 // Íàäî óáðàòü ñ êàðòû, åñëè ýòî íå êëþ÷, êîòîðûì íóæíî ïîäåëèòñÿ ñ äðóãèì èãðîêîì:
2142 if r and not ((ItemType in [ITEM_KEY_RED, ITEM_KEY_GREEN, ITEM_KEY_BLUE]) and
2143 (gGameSettings.GameType = GT_SINGLE) and
2144 (g_Player_GetCount() > 1)) then
2145 if not Respawnable then g_Items_Remove(i) else g_Items_Pick(i);
2151 function TPlayer
.CollideLevel(XInc
, YInc
: Integer): Boolean;
2153 Result
:= g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
,
2154 PLAYER_RECT
.Width
, PLAYER_RECT
.Height
, PANEL_WALL
,
2158 constructor TPlayer
.Create();
2164 mEDamageType
:= HIT_SOME
;
2170 FSawSound
:= TPlayableSound
.Create();
2171 FSawSoundIdle
:= TPlayableSound
.Create();
2172 FSawSoundHit
:= TPlayableSound
.Create();
2173 FSawSoundSelect
:= TPlayableSound
.Create();
2174 FFlameSoundOn
:= TPlayableSound
.Create();
2175 FFlameSoundOff
:= TPlayableSound
.Create();
2176 FFlameSoundWork
:= TPlayableSound
.Create();
2177 FJetSoundFly
:= TPlayableSound
.Create();
2178 FJetSoundOn
:= TPlayableSound
.Create();
2179 FJetSoundOff
:= TPlayableSound
.Create();
2181 FSawSound
.SetByName('SOUND_WEAPON_FIRESAW');
2182 FSawSoundIdle
.SetByName('SOUND_WEAPON_IDLESAW');
2183 FSawSoundHit
.SetByName('SOUND_WEAPON_HITSAW');
2184 FSawSoundSelect
.SetByName('SOUND_WEAPON_SELECTSAW');
2185 FFlameSoundOn
.SetByName('SOUND_WEAPON_FLAMEON');
2186 FFlameSoundOff
.SetByName('SOUND_WEAPON_FLAMEOFF');
2187 FFlameSoundWork
.SetByName('SOUND_WEAPON_FLAMEWORK');
2188 FJetSoundFly
.SetByName('SOUND_PLAYER_JETFLY');
2189 FJetSoundOn
.SetByName('SOUND_PLAYER_JETON');
2190 FJetSoundOff
.SetByName('SOUND_PLAYER_JETOFF');
2192 FSpectatePlayer
:= -1;
2196 FSavedStateNum
:= -1;
2203 FActualModelName
:= 'doomer';
2206 FObj
.Rect
:= PLAYER_RECT
;
2208 FBFGFireCounter
:= -1;
2209 FJustTeleported
:= False;
2212 FWaitForFirstSpawn
:= false;
2217 procedure TPlayer
.positionChanged (); inline;
2221 procedure TPlayer
.doDamage (v
: Integer);
2223 if (v
<= 0) then exit
;
2224 if (v
> 32767) then v
:= 32767;
2225 Damage(v
, 0, 0, 0, mEDamageType
);
2228 procedure TPlayer
.Damage(value
: Word; SpawnerUID
: Word; vx
, vy
: Integer; t
: Byte);
2232 if (not g_Game_IsClient
) and (not FAlive
) then
2237 // Íåóÿçâèìîñòü íå ñïàñàåò îò ëîâóøåê:
2238 if ((t
= HIT_TRAP
) or (t
= HIT_SELF
)) and (not FGodMode
) then
2240 if not g_Game_IsClient
then
2243 if t
= HIT_TRAP
then
2245 // Ëîâóøêà óáèâàåò ñðàçó:
2247 Kill(K_EXTRAHARDKILL
, SpawnerUID
, t
);
2249 if t
= HIT_SELF
then
2253 Kill(K_SIMPLEKILL
, SpawnerUID
, t
);
2256 // Îáíóëèòü äåéñòâèÿ ïðèìî÷åê, ÷òîáû ôîí ïðîïàë
2257 FMegaRulez
[MR_SUIT
] := 0;
2258 FMegaRulez
[MR_INVUL
] := 0;
2259 FMegaRulez
[MR_INVIS
] := 0;
2264 // Íî îò îñòàëüíîãî ñïàñàåò:
2265 if FMegaRulez
[MR_INVUL
] >= gTime
then
2272 // Åñëè åñòü óðîí ñâîèì, èëè ðàíèë ñàì ñåáÿ, èëè òåáÿ ðàíèë ïðîòèâíèê:
2273 if LongBool(gGameSettings
.Options
and GAME_OPTION_TEAMDAMAGE
) or
2274 (SpawnerUID
= FUID
) or
2275 (not SameTeam(FUID
, SpawnerUID
)) then
2277 FLastSpawnerUID
:= SpawnerUID
;
2279 // Êðîâü (ïóçûðüêè, åñëè â âîäå):
2280 if gBloodCount
> 0 then
2282 c
:= Min(value
, 200)*gBloodCount
+ Random(Min(value
, 200) div 2);
2283 if value
div 4 <= c
then
2284 c
:= c
- (value
div 4)
2288 if (t
= HIT_SOME
) and (vx
= 0) and (vy
= 0) then
2292 HIT_TRAP
, HIT_ACID
, HIT_FLAME
, HIT_SELF
: MakeBloodSimple(c
);
2293 HIT_BFG
, HIT_ROCKET
, HIT_SOME
: MakeBloodVector(c
, vx
, vy
);
2296 if t
= HIT_WATER
then
2297 g_GFX_Bubbles(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2),
2298 FObj
.Y
+PLAYER_RECT
.Y
-4, value
div 2, 8, 4);
2303 Inc(FDamageBuffer
, value
);
2307 FPain
:= FPain
+ value
;
2310 if g_Game_IsServer
and g_Game_IsNet
then
2312 MH_SEND_PlayerDamage(FUID
, t
, SpawnerUID
, value
, vx
, vy
);
2313 MH_SEND_PlayerStats(FUID
);
2314 MH_SEND_PlayerPos(False, FUID
);
2318 function TPlayer
.Heal(value
: Word; Soft
: Boolean): Boolean;
2321 if g_Game_IsClient
then
2326 if Soft
and (FHealth
< PLAYER_HP_SOFT
) then
2328 IncMax(FHealth
, value
, PLAYER_HP_SOFT
);
2331 if (not Soft
) and (FHealth
< PLAYER_HP_LIMIT
) then
2333 IncMax(FHealth
, value
, PLAYER_HP_LIMIT
);
2337 if Result
and g_Game_IsServer
and g_Game_IsNet
then
2338 MH_SEND_PlayerStats(FUID
);
2341 destructor TPlayer
.Destroy();
2343 if (gPlayer1
<> nil) and (gPlayer1
.FUID
= FUID
) then
2345 if (gPlayer2
<> nil) and (gPlayer2
.FUID
= FUID
) then
2349 FSawSoundIdle
.Free();
2350 FSawSoundHit
.Free();
2351 FSawSoundSelect
.Free();
2352 FFlameSoundOn
.Free();
2353 FFlameSoundOff
.Free();
2354 FFlameSoundWork
.Free();
2355 FJetSoundFly
.Free();
2357 FJetSoundOff
.Free();
2359 if FPunchAnim
<> nil then
2365 procedure TPlayer
.DrawIndicator(Color
: TRGB
);
2367 indX
, indY
, fX
, fY
, fSlope
: Integer;
2377 FObj
.lerp(gLerpFactor
, fX
, fY
);
2378 fSlope
:= nlerp(FSlopeOld
, FObj
.slopeUpLeft
, gLerpFactor
);
2380 case gPlayerIndicatorStyle
of
2383 if g_Texture_Get('TEXTURE_PLAYER_INDICATOR', ID
) then
2385 e_GetTextureSize(ID
, @indW
, @indH
);
2389 if (FObj
.X
+ FObj
.Rect
.X
) < 0 then
2392 indX
:= fX
+ FObj
.Rect
.X
+ FObj
.Rect
.Width
;
2393 indY
:= fY
+ FObj
.Rect
.Y
+ (FObj
.Rect
.Height
- indW
) div 2;
2396 else if (FObj
.X
+ FObj
.Rect
.X
+ FObj
.Rect
.Width
) > Max(gMapInfo
.Width
, gPlayerScreenSize
.X
) then
2399 indX
:= fX
+ FObj
.Rect
.X
- indH
;
2400 indY
:= fY
+ FObj
.Rect
.Y
+ (FObj
.Rect
.Height
- indW
) div 2;
2403 else if (FObj
.Y
- indH
) < 0 then
2406 indX
:= fX
+ FObj
.Rect
.X
+ (FObj
.Rect
.Width
- indW
) div 2;
2407 indY
:= fY
+ FObj
.Rect
.Y
+ FObj
.Rect
.Height
;
2413 indX
:= fX
+ FObj
.Rect
.X
+ (FObj
.Rect
.Width
- indW
) div 2;
2417 indY
:= indY
+ fSlope
;
2418 indX
:= EnsureRange(indX
, 0, Max(gMapInfo
.Width
, gPlayerScreenSize
.X
) - indW
);
2419 indY
:= EnsureRange(indY
, 0, Max(gMapInfo
.Height
, gPlayerScreenSize
.Y
) - indH
);
2423 e_DrawAdv(ID
, indX
, indY
, 0, True, False, indA
, @a
);
2430 e_TextureFontGetSize(gStdFont
, nW
, nH
);
2431 indX
:= fX
+ FObj
.Rect
.X
+ (FObj
.Rect
.Width
- Length(FName
) * nW
) div 2;
2432 indY
:= fY
- nH
+ fSlope
;
2433 e_TextureFontPrintEx(indX
, indY
, FName
, gStdFont
, Color
.R
, Color
.G
, Color
.B
, 1.0, True);
2439 procedure TPlayer
.DrawBubble();
2441 bubX
, bubY
, fX
, fY
: Integer;
2444 Rw
, Gw
, Bw
: SmallInt;
2447 FObj
.lerp(gLerpFactor
, fX
, fY
);
2448 bubX
:= fX
+FObj
.Rect
.X
+ IfThen(FDirection
= TDirection
.D_LEFT
, -4, 18);
2449 bubY
:= fY
+FObj
.Rect
.Y
- 18;
2457 1: // simple textual non-bubble
2459 bubX
:= fX
+FObj
.Rect
.X
- 11;
2460 bubY
:= fY
+FObj
.Rect
.Y
- 17;
2461 e_TextureFontPrint(bubX
, bubY
, '[...]', gStdFont
);
2464 2: // advanced pixel-perfect bubble
2466 if FTeam
= TEAM_RED
then
2469 if FTeam
= TEAM_BLUE
then
2472 3: // colored bubble
2474 Rb
:= FModel
.Color
.R
;
2475 Gb
:= FModel
.Color
.G
;
2476 Bb
:= FModel
.Color
.B
;
2477 Rw
:= Min(Rb
* 2 + 64, 255);
2478 Gw
:= Min(Gb
* 2 + 64, 255);
2479 Bw
:= Min(Bb
* 2 + 64, 255);
2480 if (Abs(Rw
- Rb
) < 32)
2481 or (Abs(Gw
- Gb
) < 32)
2482 or (Abs(Bw
- Bb
) < 32) then
2484 Rb
:= Max(Rw
div 2 - 16, 0);
2485 Gb
:= Max(Gw
div 2 - 16, 0);
2486 Bb
:= Max(Bw
div 2 - 16, 0);
2489 4: // custom textured bubble
2491 if g_Texture_Get('TEXTURE_PLAYER_TALKBUBBLE', ID
) then
2492 if FDirection
= TDirection
.D_RIGHT
then
2493 e_Draw(ID
, bubX
- 6, bubY
- 7, 0, True, False)
2495 e_Draw(ID
, bubX
- 6, bubY
- 7, 0, True, False, TMirrorType
.Horizontal
);
2501 e_DrawQuad(bubX
+ 1, bubY
, bubX
+ 18, bubY
+ 13, Rb
, Gb
, Bb
);
2502 e_DrawQuad(bubX
, bubY
+ 1, bubX
+ 19, bubY
+ 12, Rb
, Gb
, Bb
);
2504 e_DrawFillQuad(bubX
+ 1, bubY
+ 1, bubX
+ 18, bubY
+ 12, Rw
, Gw
, Bw
, 0);
2507 Dot
:= IfThen(FDirection
= TDirection
.D_LEFT
, 14, 5);
2508 e_DrawLine(1, bubX
+ Dot
, bubY
+ 14, bubX
+ Dot
, bubY
+ 16, Rb
, Gb
, Bb
);
2509 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
);
2510 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
);
2511 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
);
2512 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
);
2516 e_DrawFillQuad(bubX
+ Dot
, bubY
+ 8, bubX
+ Dot
+ 1, bubY
+ 9, Rb
, Gb
, Bb
, 0);
2517 e_DrawFillQuad(bubX
+ Dot
+ 3, bubY
+ 8, bubX
+ Dot
+ 4, bubY
+ 9, Rb
, Gb
, Bb
, 0);
2518 e_DrawFillQuad(bubX
+ Dot
+ 6, bubY
+ 8, bubX
+ Dot
+ 7, bubY
+ 9, Rb
, Gb
, Bb
, 0);
2521 procedure TPlayer
.Draw();
2526 Mirror
: TMirrorType
;
2527 fX
, fY
, fSlope
: Integer;
2529 FObj
.lerp(gLerpFactor
, fX
, fY
);
2530 fSlope
:= nlerp(FSlopeOld
, FObj
.slopeUpLeft
, gLerpFactor
);
2534 if Direction
= TDirection
.D_RIGHT
then
2535 Mirror
:= TMirrorType
.None
2537 Mirror
:= TMirrorType
.Horizontal
;
2539 if FPunchAnim
<> nil then
2541 FPunchAnim
.Draw(fX
+IfThen(Direction
= TDirection
.D_LEFT
, 15-FObj
.Rect
.X
, FObj
.Rect
.X
-15),
2542 fY
+fSlope
+FObj
.Rect
.Y
-11, Mirror
);
2543 if FPunchAnim
.played
then
2550 if (FMegaRulez
[MR_INVUL
] > gTime
) and ((gPlayerDrawn
<> Self
) or (FSpawnInvul
>= gTime
)) then
2551 if g_Texture_Get('TEXTURE_PLAYER_INVULPENTA', ID
) then
2553 e_GetTextureSize(ID
, @w
, @h
);
2554 if FDirection
= TDirection
.D_LEFT
then
2555 e_Draw(ID
, fX
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2)-(w
div 2)+4,
2556 fY
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2)-(h
div 2)-7+fSlope
, 0, True, False)
2558 e_Draw(ID
, fX
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2)-(w
div 2)-2,
2559 fY
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2)-(h
div 2)-7+fSlope
, 0, True, False);
2562 if FMegaRulez
[MR_INVIS
] > gTime
then
2564 if (gPlayerDrawn
<> nil) and ((Self
= gPlayerDrawn
) or
2565 ((FTeam
= gPlayerDrawn
.Team
) and (gGameSettings
.GameMode
<> GM_DM
))) then
2567 if (FMegaRulez
[MR_INVIS
] - gTime
) <= 2100 then
2568 dr
:= not Odd((FMegaRulez
[MR_INVIS
] - gTime
) div 300)
2572 FModel
.Draw(fX
, fY
+fSlope
, 200)
2574 FModel
.Draw(fX
, fY
+fSlope
);
2577 FModel
.Draw(fX
, fY
+fSlope
, 254);
2580 FModel
.Draw(fX
, fY
+fSlope
);
2583 if g_debug_Frames
then
2585 e_DrawQuad(FObj
.X
+FObj
.Rect
.X
,
2587 FObj
.X
+FObj
.Rect
.X
+FObj
.Rect
.Width
-1,
2588 FObj
.Y
+FObj
.Rect
.Y
+FObj
.Rect
.Height
-1,
2592 if (gChatBubble
> 0) and (FKeys
[KEY_CHAT
].Pressed
) and not FGhost
then
2593 if (FMegaRulez
[MR_INVIS
] <= gTime
) or ((gPlayerDrawn
<> nil) and ((Self
= gPlayerDrawn
) or
2594 ((FTeam
= gPlayerDrawn
.Team
) and (gGameSettings
.GameMode
<> GM_DM
)))) then
2596 // e_DrawPoint(5, 335, 288, 255, 0, 0); // DL, UR, DL, UR
2597 if gAimLine
and alive
and
2598 ((Self
= gPlayer1
) or (Self
= gPlayer2
)) then
2603 procedure TPlayer
.DrawAim();
2604 procedure drawCast (sz
: Integer; ax0
, ay0
, ax1
, ay1
: Integer);
2609 {$IFDEF ENABLE_HOLMES}
2610 if isValidViewPort
and (self
= gPlayer1
) then
2612 g_Holmes_plrLaser(ax0
, ay0
, ax1
, ay1
);
2616 e_DrawLine(sz
, ax0
, ay0
, ax1
, ay1
, 255, 0, 0, 96);
2617 if (g_Map_traceToNearestWall(ax0
, ay0
, ax1
, ay1
, @ex
, @ey
) <> nil) then
2619 e_DrawLine(sz
, ax0
, ay0
, ex
, ey
, 0, 255, 0, 96);
2623 e_DrawLine(sz
, ax0
, ay0
, ex
, ey
, 0, 0, 255, 96);
2628 wx
, wy
, xx
, yy
: Integer;
2632 wx
:= FObj
.X
+ WEAPONPOINT
[FDirection
].X
+ IfThen(FDirection
= TDirection
.D_LEFT
, 7, -7);
2633 wy
:= FObj
.Y
+ WEAPONPOINT
[FDirection
].Y
;
2642 1: begin // Chainsaw
2649 if angle
= ANGLE_RIGHTUP
then Dec(angle
, 2);
2650 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 4);
2651 if angle
= ANGLE_LEFTUP
then Inc(angle
, 2);
2652 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 4);
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);
2662 4: begin // Double Shotgun
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 5: begin // Chaingun
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 6: begin // Rocket Launcher
2681 if angle
= ANGLE_RIGHTUP
then Inc(angle
, 2);
2682 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 4);
2683 if angle
= ANGLE_LEFTUP
then Dec(angle
, 2);
2684 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 4);
2686 7: begin // Plasmagun
2689 if angle
= ANGLE_RIGHTUP
then Inc(angle
);
2690 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 3);
2691 if angle
= ANGLE_LEFTUP
then Dec(angle
);
2692 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 3);
2697 if angle
= ANGLE_RIGHTUP
then Inc(angle
, 1);
2698 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 2);
2699 if angle
= ANGLE_LEFTUP
then Dec(angle
, 1);
2700 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 2);
2702 9: begin // Super Chaingun
2705 if angle
= ANGLE_RIGHTUP
then Dec(angle
, 2);
2706 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 4);
2707 if angle
= ANGLE_LEFTUP
then Inc(angle
, 2);
2708 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 4);
2711 xx
:= Trunc(Cos(-DegToRad(angle
)) * len
) + wx
;
2712 yy
:= Trunc(Sin(-DegToRad(angle
)) * len
) + wy
;
2713 {$IF DEFINED(D2F_DEBUG)}
2714 drawCast(sz
, wx
, wy
, xx
, yy
);
2716 e_DrawLine(sz
, wx
, wy
, xx
, yy
, 255, 0, 0, 96);
2720 procedure TPlayer
.DrawGUI();
2723 X
, Y
, SY
, a
, p
, m
: Integer;
2727 stat
: TPlayerStatArray
;
2729 X
:= gPlayerScreenSize
.X
;
2730 SY
:= gPlayerScreenSize
.Y
;
2733 if gShowGoals
and (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then
2735 if gGameSettings
.GameMode
= GM_CTF
then
2739 if gGameSettings
.GameMode
= GM_CTF
then
2741 s
:= 'TEXTURE_PLAYER_REDFLAG';
2742 if gFlags
[FLAG_RED
].State
= FLAG_STATE_CAPTURED
then
2743 s
:= 'TEXTURE_PLAYER_REDFLAG_S';
2744 if gFlags
[FLAG_RED
].State
= FLAG_STATE_DROPPED
then
2745 s
:= 'TEXTURE_PLAYER_REDFLAG_D';
2746 if g_Texture_Get(s
, ID
) then
2747 e_Draw(ID
, X
-16-32, 240-72-4, 0, True, False);
2750 s
:= IntToStr(gTeamStat
[TEAM_RED
].Goals
);
2751 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2752 e_CharFont_PrintEx(gMenuFont
, X
-16-a
-tw
, 240-72-4, s
, TEAMCOLOR
[TEAM_RED
]);
2754 if gGameSettings
.GameMode
= GM_CTF
then
2756 s
:= 'TEXTURE_PLAYER_BLUEFLAG';
2757 if gFlags
[FLAG_BLUE
].State
= FLAG_STATE_CAPTURED
then
2758 s
:= 'TEXTURE_PLAYER_BLUEFLAG_S';
2759 if gFlags
[FLAG_BLUE
].State
= FLAG_STATE_DROPPED
then
2760 s
:= 'TEXTURE_PLAYER_BLUEFLAG_D';
2761 if g_Texture_Get(s
, ID
) then
2762 e_Draw(ID
, X
-16-32, 240-32-4, 0, True, False);
2765 s
:= IntToStr(gTeamStat
[TEAM_BLUE
].Goals
);
2766 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2767 e_CharFont_PrintEx(gMenuFont
, X
-16-a
-tw
, 240-32-4, s
, TEAMCOLOR
[TEAM_BLUE
]);
2770 if g_Texture_Get('TEXTURE_PLAYER_HUDBG', ID
) then
2771 e_DrawFill(ID
, X
, 0, 1, (gPlayerScreenSize
.Y
div 256)+IfThen(gPlayerScreenSize
.Y
mod 256 > 0, 1, 0),
2774 if g_Texture_Get('TEXTURE_PLAYER_HUD', ID
) then
2775 e_Draw(ID
, X
+2, Y
, 0, True, False);
2777 if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
2781 s
:= IntToStr(Frags
);
2782 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2783 e_CharFont_PrintEx(gMenuFont
, X
-16-tw
, Y
, s
, _RGB(255, 0, 0));
2788 stat
:= g_Player_GetStats();
2793 for a
:= 0 to High(stat
) do
2794 if stat
[a
].Name
<> Name
then
2796 if stat
[a
].Frags
> m
then m
:= stat
[a
].Frags
;
2797 if stat
[a
].Frags
> Frags
then p
:= p
+1;
2801 s
:= IntToStr(p
)+' / '+IntToStr(Length(stat
))+' ';
2802 if Frags
>= m
then s
:= s
+'+' else s
:= s
+'-';
2803 s
:= s
+IntToStr(Abs(Frags
-m
));
2805 e_CharFont_GetSize(gMenuSmallFont
, s
, tw
, th
);
2806 e_CharFont_PrintEx(gMenuSmallFont
, X
-16-tw
, Y
+32, s
, _RGB(255, 0, 0));
2809 if gLMSRespawn
> LMS_RESPAWN_NONE
then
2811 s
:= _lc
[I_GAME_WARMUP
];
2812 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2813 s
:= s
+ ': ' + IntToStr((gLMSRespawnTime
- gTime
) div 1000);
2814 e_CharFont_PrintEx(gMenuFont
, X
-64-tw
, SY
-32, s
, _RGB(0, 255, 0));
2816 else if gShowLives
and (gGameSettings
.MaxLives
> 0) then
2818 s
:= IntToStr(Lives
);
2819 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2820 e_CharFont_PrintEx(gMenuFont
, X
-16-tw
, SY
-32, s
, _RGB(0, 255, 0));
2824 e_CharFont_GetSize(gMenuSmallFont
, FName
, tw
, th
);
2825 e_CharFont_PrintEx(gMenuSmallFont
, X
+98-(tw
div 2), Y
+8, FName
, _RGB(255, 0, 0));
2827 if R_BERSERK
in FRulez
then
2828 e_Draw(gItemsTexturesID
[ITEM_MEDKIT_BLACK
], X
+37, Y
+45, 0, True, False)
2830 e_Draw(gItemsTexturesID
[ITEM_MEDKIT_LARGE
], X
+37, Y
+45, 0, True, False);
2832 if g_Texture_Get('TEXTURE_PLAYER_ARMORHUD', ID
) then
2833 e_Draw(ID
, X
+36, Y
+77, 0, True, False);
2835 s
:= IntToStr(IfThen(FHealth
> 0, FHealth
, 0));
2836 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2837 e_CharFont_PrintEx(gMenuFont
, X
+178-tw
, Y
+40, s
, _RGB(255, 0, 0));
2839 s
:= IntToStr(FArmor
);
2840 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2841 e_CharFont_PrintEx(gMenuFont
, X
+178-tw
, Y
+68, s
, _RGB(255, 0, 0));
2843 s
:= IntToStr(GetAmmoByWeapon(FCurrWeap
));
2849 ID
:= gItemsTexturesID
[ITEM_WEAPON_KASTET
];
2854 ID
:= gItemsTexturesID
[ITEM_WEAPON_SAW
];
2856 WEAPON_PISTOL
: ID
:= gItemsTexturesID
[ITEM_WEAPON_PISTOL
];
2857 WEAPON_CHAINGUN
: ID
:= gItemsTexturesID
[ITEM_WEAPON_CHAINGUN
];
2858 WEAPON_SHOTGUN1
: ID
:= gItemsTexturesID
[ITEM_WEAPON_SHOTGUN1
];
2859 WEAPON_SHOTGUN2
: ID
:= gItemsTexturesID
[ITEM_WEAPON_SHOTGUN2
];
2860 WEAPON_SUPERPULEMET
: ID
:= gItemsTexturesID
[ITEM_WEAPON_SUPERPULEMET
];
2861 WEAPON_ROCKETLAUNCHER
: ID
:= gItemsTexturesID
[ITEM_WEAPON_ROCKETLAUNCHER
];
2862 WEAPON_PLASMA
: ID
:= gItemsTexturesID
[ITEM_WEAPON_PLASMA
];
2863 WEAPON_BFG
: ID
:= gItemsTexturesID
[ITEM_WEAPON_BFG
];
2864 WEAPON_FLAMETHROWER
: ID
:= gItemsTexturesID
[ITEM_WEAPON_FLAMETHROWER
];
2867 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2868 e_CharFont_PrintEx(gMenuFont
, X
+178-tw
, Y
+158, s
, _RGB(255, 0, 0));
2869 e_Draw(ID
, X
+20, Y
+160, 0, True, False);
2871 if R_KEY_RED
in FRulez
then
2872 e_Draw(gItemsTexturesID
[ITEM_KEY_RED
], X
+78, Y
+214, 0, True, False);
2874 if R_KEY_GREEN
in FRulez
then
2875 e_Draw(gItemsTexturesID
[ITEM_KEY_GREEN
], X
+95, Y
+214, 0, True, False);
2877 if R_KEY_BLUE
in FRulez
then
2878 e_Draw(gItemsTexturesID
[ITEM_KEY_BLUE
], X
+112, Y
+214, 0, True, False);
2880 if FJetFuel
> 0 then
2882 if g_Texture_Get('TEXTURE_PLAYER_HUDAIR', ID
) then
2883 e_Draw(ID
, X
+2, Y
+116, 0, True, False);
2884 if g_Texture_Get('TEXTURE_PLAYER_HUDJET', ID
) then
2885 e_Draw(ID
, X
+2, Y
+126, 0, True, False);
2886 e_DrawLine(4, X
+16, Y
+122, X
+16+Trunc(168*IfThen(FAir
> 0, FAir
, 0)/AIR_MAX
), Y
+122, 0, 0, 196);
2887 e_DrawLine(4, X
+16, Y
+132, X
+16+Trunc(168*FJetFuel
/JET_MAX
), Y
+132, 208, 0, 0);
2891 if g_Texture_Get('TEXTURE_PLAYER_HUDAIR', ID
) then
2892 e_Draw(ID
, X
+2, Y
+124, 0, True, False);
2893 e_DrawLine(4, X
+16, Y
+130, X
+16+Trunc(168*IfThen(FAir
> 0, FAir
, 0)/AIR_MAX
), Y
+130, 0, 0, 196);
2896 if gShowPing
and g_Game_IsClient
then
2898 s
:= _lc
[I_GAME_PING_HUD
] + IntToStr(NetPeer
.lastRoundTripTime
) + _lc
[I_NET_SLIST_PING_MS
];
2899 e_TextureFontPrint(X
+ 4, Y
+ 242, s
, gStdFont
);
2905 e_TextureFontPrint(X
+ 4, Y
+ 242, _lc
[I_PLAYER_SPECT
], gStdFont
);
2906 e_TextureFontPrint(X
+ 4, Y
+ 258, _lc
[I_PLAYER_SPECT2
], gStdFont
);
2907 e_TextureFontPrint(X
+ 4, Y
+ 274, _lc
[I_PLAYER_SPECT1
], gStdFont
);
2910 e_TextureFontGetSize(gStdFont
, cw
, ch
);
2911 s
:= _lc
[I_PLAYER_SPECT4
];
2912 e_TextureFontPrintEx(gScreenWidth
div 2 - cw
*(Length(s
) div 2),
2913 gScreenHeight
-4-ch
, s
, gStdFont
, 255, 255, 255, 1, True);
2914 e_TextureFontPrint(X
+ 4, Y
+ 290, _lc
[I_PLAYER_SPECT1S
], gStdFont
);
2920 procedure TPlayer
.DrawRulez();
2924 // Ïðè âçÿòèè íåóÿçâèìîñòè ðèñóåòñÿ èíâåðñèîííûé áåëûé ôîí
2925 if (FMegaRulez
[MR_INVUL
] >= gTime
) and (FSpawnInvul
< gTime
) then
2927 if (FMegaRulez
[MR_INVUL
]-gTime
) <= 2100 then
2928 dr
:= not Odd((FMegaRulez
[MR_INVUL
]-gTime
) div 300)
2933 e_DrawFillQuad(0, 0, gPlayerScreenSize
.X
-1, gPlayerScreenSize
.Y
-1,
2934 191, 191, 191, 0, TBlending
.Invert
);
2937 // Ïðè âçÿòèè çàùèòíîãî êîñòþìà ðèñóåòñÿ çåëåíîâàòûé ôîí
2938 if FMegaRulez
[MR_SUIT
] >= gTime
then
2940 if (FMegaRulez
[MR_SUIT
]-gTime
) <= 2100 then
2941 dr
:= not Odd((FMegaRulez
[MR_SUIT
]-gTime
) div 300)
2946 e_DrawFillQuad(0, 0, gPlayerScreenSize
.X
-1, gPlayerScreenSize
.Y
-1,
2947 0, 96, 0, 200, TBlending
.None
);
2950 // Ïðè âçÿòèè áåðñåðêà ðèñóåòñÿ êðàñíîâàòûé ôîí
2951 if (FBerserk
>= 0) and (LongWord(FBerserk
) >= gTime
) and (gFlash
= 2) then
2953 e_DrawFillQuad(0, 0, gPlayerScreenSize
.X
-1, gPlayerScreenSize
.Y
-1,
2954 255, 0, 0, 200, TBlending
.None
);
2958 procedure TPlayer
.DrawPain();
2962 if FPain
= 0 then Exit
;
2966 if a
< 15 then h
:= 0
2967 else if a
< 35 then h
:= 1
2968 else if a
< 55 then h
:= 2
2969 else if a
< 75 then h
:= 3
2970 else if a
< 95 then h
:= 4
2973 //if a > 255 then a := 255;
2975 e_DrawFillQuad(0, 0, gPlayerScreenSize
.X
-1, gPlayerScreenSize
.Y
-1, 255, 0, 0, 255-h
*50);
2976 //e_DrawFillQuad(0, 0, gPlayerScreenSize.X-1, gPlayerScreenSize.Y-1, 255-min(128, a), 255-a, 255-a, 0, B_FILTER);
2979 procedure TPlayer
.DrawPickup();
2983 if FPickup
= 0 then Exit
;
2987 if a
< 15 then h
:= 1
2988 else if a
< 35 then h
:= 2
2989 else if a
< 55 then h
:= 3
2990 else if a
< 75 then h
:= 4
2993 e_DrawFillQuad(0, 0, gPlayerScreenSize
.X
-1, gPlayerScreenSize
.Y
-1, 150, 200, 150, 255-h
*50);
2996 procedure TPlayer
.DoPunch();
3001 if FPunchAnim
<> nil then begin
3006 st
:= 'FRAMES_PUNCH';
3007 if R_BERSERK
in FRulez
then
3008 st
:= st
+ '_BERSERK';
3009 if FKeys
[KEY_UP
].Pressed
then
3011 else if FKeys
[KEY_DOWN
].Pressed
then
3013 g_Frames_Get(id
, st
);
3014 FPunchAnim
:= TAnimation
.Create(id
, False, 1);
3017 procedure TPlayer
.Fire();
3019 f
, DidFire
: Boolean;
3020 wx
, wy
, xd
, yd
: Integer;
3023 if g_Game_IsClient
then Exit
;
3024 // FBFGFireCounter - âðåìÿ ïåðåä âûñòðåëîì (äëÿ BFG)
3025 // FReloading - âðåìÿ ïîñëå âûñòðåëà (äëÿ âñåãî)
3033 if FReloading
[FCurrWeap
] <> 0 then Exit
;
3038 wx
:= FObj
.X
+WEAPONPOINT
[FDirection
].X
;
3039 wy
:= FObj
.Y
+WEAPONPOINT
[FDirection
].Y
;
3040 xd
:= wx
+IfThen(FDirection
= TDirection
.D_LEFT
, -30, 30);
3041 yd
:= wy
+firediry();
3047 if R_BERSERK
in FRulez
then
3049 //g_Weapon_punch(FObj.X+FObj.Rect.X, FObj.Y+FObj.Rect.Y, 75, FUID);
3050 locobj
.X
:= FObj
.X
+FObj
.Rect
.X
;
3051 locobj
.Y
:= FObj
.Y
+FObj
.Rect
.Y
;
3054 locobj
.rect
.Width
:= 39;
3055 locobj
.rect
.Height
:= 52;
3056 locobj
.Vel
.X
:= (xd
-wx
) div 2;
3057 locobj
.Vel
.Y
:= (yd
-wy
) div 2;
3058 locobj
.Accel
.X
:= xd
-wx
;
3059 locobj
.Accel
.y
:= yd
-wy
;
3061 if g_Weapon_Hit(@locobj
, 50, FUID
, HIT_SOME
) <> 0 then
3062 g_Sound_PlayExAt('SOUND_WEAPON_HITBERSERK', FObj
.X
, FObj
.Y
)
3064 g_Sound_PlayExAt('SOUND_WEAPON_MISSBERSERK', FObj
.X
, FObj
.Y
);
3066 if (gFlash
= 1) and (FPain
< 50) then FPain
:= min(FPain
+ 25, 50);
3070 g_Weapon_punch(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
, 3, FUID
);
3074 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
3079 if g_Weapon_chainsaw(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
,
3080 IfThen(gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
], 9, 3), FUID
) <> 0 then
3082 FSawSoundSelect
.Stop();
3084 FSawSoundHit
.PlayAt(FObj
.X
, FObj
.Y
);
3086 else if not FSawSoundHit
.IsPlaying() then
3088 FSawSoundSelect
.Stop();
3089 FSawSound
.PlayAt(FObj
.X
, FObj
.Y
);
3092 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
3098 if FAmmo
[A_BULLETS
] > 0 then
3100 g_Weapon_pistol(wx
, wy
, xd
, yd
, FUID
);
3101 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
3102 Dec(FAmmo
[A_BULLETS
]);
3103 FFireAngle
:= FAngle
;
3106 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
3107 GameVelX
, GameVelY
-2, SHELL_BULLET
);
3111 if FAmmo
[A_SHELLS
] > 0 then
3113 g_Weapon_shotgun(wx
, wy
, xd
, yd
, FUID
);
3114 if not gSoundEffectsDF
then g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN', wx
, wy
);
3115 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
3116 Dec(FAmmo
[A_SHELLS
]);
3117 FFireAngle
:= FAngle
;
3121 FShellType
:= SHELL_SHELL
;
3125 if FAmmo
[A_SHELLS
] >= 2 then
3127 g_Weapon_dshotgun(wx
, wy
, xd
, yd
, FUID
);
3128 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
3129 Dec(FAmmo
[A_SHELLS
], 2);
3130 FFireAngle
:= FAngle
;
3134 FShellType
:= SHELL_DBLSHELL
;
3138 if FAmmo
[A_BULLETS
] > 0 then
3140 g_Weapon_mgun(wx
, wy
, xd
, yd
, FUID
);
3141 if not gSoundEffectsDF
then g_Sound_PlayExAt('SOUND_WEAPON_FIREPISTOL', wx
, wy
);
3142 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
3143 Dec(FAmmo
[A_BULLETS
]);
3144 FFireAngle
:= FAngle
;
3147 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
3148 GameVelX
, GameVelY
-2, SHELL_BULLET
);
3151 WEAPON_ROCKETLAUNCHER
:
3152 if FAmmo
[A_ROCKETS
] > 0 then
3154 g_Weapon_rocket(wx
, wy
, xd
, yd
, FUID
);
3155 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
3156 Dec(FAmmo
[A_ROCKETS
]);
3157 FFireAngle
:= FAngle
;
3163 if FAmmo
[A_CELLS
] > 0 then
3165 g_Weapon_plasma(wx
, wy
, xd
, yd
, FUID
);
3166 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
3167 Dec(FAmmo
[A_CELLS
]);
3168 FFireAngle
:= FAngle
;
3174 if (FAmmo
[A_CELLS
] >= 40) and (FBFGFireCounter
= -1) then
3176 FBFGFireCounter
:= 17;
3177 if not FNoReload
then
3178 g_Sound_PlayExAt('SOUND_WEAPON_STARTFIREBFG', FObj
.X
, FObj
.Y
);
3179 Dec(FAmmo
[A_CELLS
], 40);
3183 WEAPON_SUPERPULEMET
:
3184 if FAmmo
[A_SHELLS
] > 0 then
3186 g_Weapon_shotgun(wx
, wy
, xd
, yd
, FUID
);
3187 if not gSoundEffectsDF
then g_Sound_PlayExAt('SOUND_WEAPON_FIRECGUN', wx
, wy
);
3188 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
3189 Dec(FAmmo
[A_SHELLS
]);
3190 FFireAngle
:= FAngle
;
3193 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
3194 GameVelX
, GameVelY
-2, SHELL_SHELL
);
3197 WEAPON_FLAMETHROWER
:
3198 if FAmmo
[A_FUEL
] > 0 then
3200 g_Weapon_flame(wx
, wy
, xd
, yd
, FUID
);
3202 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
3204 FFireAngle
:= FAngle
;
3211 if g_Game_IsNet
and g_Game_IsServer
then MH_SEND_PlayerStats(FUID
);
3215 if g_Game_IsNet
then
3219 if FCurrWeap
<> WEAPON_BFG
then
3220 MH_SEND_PlayerFire(FUID
, FCurrWeap
, wx
, wy
, xd
, yd
, LastShotID
)
3222 if not FNoReload
then
3223 MH_SEND_Sound(FObj
.X
, FObj
.Y
, 'SOUND_WEAPON_STARTFIREBFG');
3226 MH_SEND_PlayerStats(FUID
);
3231 if (FAngle
= 0) or (FAngle
= 180) then SetAction(A_ATTACK
)
3232 else if (FAngle
= ANGLE_LEFTDOWN
) or (FAngle
= ANGLE_RIGHTDOWN
) then SetAction(A_ATTACKDOWN
)
3233 else if (FAngle
= ANGLE_LEFTUP
) or (FAngle
= ANGLE_RIGHTUP
) then SetAction(A_ATTACKUP
);
3236 function TPlayer
.GetAmmoByWeapon(Weapon
: Byte): Word;
3239 WEAPON_PISTOL
, WEAPON_CHAINGUN
: Result
:= FAmmo
[A_BULLETS
];
3240 WEAPON_SHOTGUN1
, WEAPON_SHOTGUN2
, WEAPON_SUPERPULEMET
: Result
:= FAmmo
[A_SHELLS
];
3241 WEAPON_ROCKETLAUNCHER
: Result
:= FAmmo
[A_ROCKETS
];
3242 WEAPON_PLASMA
, WEAPON_BFG
: Result
:= FAmmo
[A_CELLS
];
3243 WEAPON_FLAMETHROWER
: Result
:= FAmmo
[A_FUEL
];
3248 function TPlayer
.HeadInLiquid(XInc
, YInc
: Integer): Boolean;
3250 Result
:= g_Map_CollidePanel(FObj
.X
+PLAYER_HEADRECT
.X
+XInc
, FObj
.Y
+PLAYER_HEADRECT
.Y
+YInc
,
3251 PLAYER_HEADRECT
.Width
, PLAYER_HEADRECT
.Height
,
3252 PANEL_WATER
or PANEL_ACID1
or PANEL_ACID2
, True);
3255 procedure TPlayer
.FlamerOn
;
3257 FFlameSoundOff
.Stop();
3258 FFlameSoundOff
.SetPosition(0);
3261 if (not FFlameSoundOn
.IsPlaying()) and (not FFlameSoundWork
.IsPlaying()) then
3262 FFlameSoundWork
.PlayAt(FObj
.X
, FObj
.Y
);
3266 FFlameSoundOn
.PlayAt(FObj
.X
, FObj
.Y
);
3271 procedure TPlayer
.FlamerOff
;
3275 FFlameSoundOn
.Stop();
3276 FFlameSoundOn
.SetPosition(0);
3277 FFlameSoundWork
.Stop();
3278 FFlameSoundWork
.SetPosition(0);
3279 FFlameSoundOff
.PlayAt(FObj
.X
, FObj
.Y
);
3284 procedure TPlayer
.JetpackOn
;
3288 FJetSoundOn
.SetPosition(0);
3289 FJetSoundOn
.PlayAt(FObj
.X
, FObj
.Y
);
3293 procedure TPlayer
.JetpackOff
;
3297 FJetSoundOff
.SetPosition(0);
3298 FJetSoundOff
.PlayAt(FObj
.X
, FObj
.Y
);
3301 procedure TPlayer
.CatchFire(Attacker
: Word; Timeout
: Integer = PLAYER_BURN_TIME
);
3303 if Timeout
<= 0 then
3305 if (FMegaRulez
[MR_SUIT
] > gTime
) or (FMegaRulez
[MR_INVUL
] > gTime
) then
3306 exit
; // Íå çàãîðàåìñÿ êîãäà åñòü çàùèòà
3307 if g_Obj_CollidePanel(@FObj
, 0, 0, PANEL_WATER
or PANEL_ACID1
or PANEL_ACID2
) then
3308 exit
; // Íå ïîäãîðàåì â âîäå íà âñÿêèé ñëó÷àé
3309 if FFireTime
<= 0 then
3310 g_Sound_PlayExAt('SOUND_IGNITE', FObj
.X
, FObj
.Y
);
3311 FFireTime
:= Timeout
;
3312 FFireAttacker
:= Attacker
;
3313 if g_Game_IsNet
and g_Game_IsServer
then
3314 MH_SEND_PlayerStats(FUID
);
3317 procedure TPlayer
.Jump();
3319 if gFly
or FJetpack
then
3321 // Ïîëåò (÷èò-êîä èëè äæåòïàê):
3322 if FObj
.Vel
.Y
> -VEL_FLY
then
3323 FObj
.Vel
.Y
:= FObj
.Vel
.Y
- 3;
3326 if FJetFuel
> 0 then
3328 if (FJetFuel
< 1) and g_Game_IsServer
then
3332 if g_Game_IsNet
then
3333 MH_SEND_PlayerStats(FUID
);
3339 // Íå âêëþ÷àòü äæåòïàê â ðåæèìå ïðîõîæäåíèÿ ñêâîçü ñòåíû
3341 FCanJetpack
:= False;
3343 // Ïðûãàåì èëè âñïëûâàåì:
3344 if (CollideLevel(0, 1) or
3345 g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+PLAYER_RECT
.Y
+36, PLAYER_RECT
.Width
,
3346 PLAYER_RECT
.Height
-33, PANEL_STEP
, False)
3347 ) and (FObj
.Accel
.Y
= 0) then // Íå ïðûãàòü, åñëè åñòü âåðòèêàëüíîå óñêîðåíèå
3349 FObj
.Vel
.Y
:= -VEL_JUMP
;
3350 FCanJetpack
:= False;
3354 if BodyInLiquid(0, 0) then
3355 FObj
.Vel
.Y
:= -VEL_SW
3356 else if (FJetFuel
> 0) and FCanJetpack
and
3357 g_Game_IsServer
and (not g_Obj_CollideLiquid(@FObj
, 0, 0)) then
3361 if g_Game_IsNet
then
3362 MH_SEND_PlayerStats(FUID
);
3367 procedure TPlayer
.Kill(KillType
: Byte; SpawnerUID
: Word; t
: Byte);
3369 a
, i
, k
, ab
, ar
: Byte;
3373 srv
, netsrv
: Boolean;
3379 procedure PushItem(t
: Byte);
3383 id
:= g_Items_Create(FObj
.X
, FObj
.Y
, t
, True, False);
3384 it
:= g_Items_ByIdx(id
);
3385 if KillType
= K_EXTRAHARDKILL
then // -7..+7; -8..0
3387 g_Obj_Push(@it
.Obj
, (FObj
.Vel
.X
div 2)-7+Random(15),
3388 (FObj
.Vel
.Y
div 2)-Random(9));
3389 it
.positionChanged(); // this updates spatial accelerators
3393 if KillType
= K_HARDKILL
then // -5..+5; -5..0
3395 g_Obj_Push(@it
.Obj
, (FObj
.Vel
.X
div 2)-5+Random(11),
3396 (FObj
.Vel
.Y
div 2)-Random(6));
3398 else // -3..+3; -3..0
3400 g_Obj_Push(@it
.Obj
, (FObj
.Vel
.X
div 2)-3+Random(7),
3401 (FObj
.Vel
.Y
div 2)-Random(4));
3403 it
.positionChanged(); // this updates spatial accelerators
3406 if g_Game_IsNet
and g_Game_IsServer
then
3407 MH_SEND_ItemSpawn(True, id
);
3411 DoFrags
:= (gGameSettings
.MaxLives
= 0) or (gGameSettings
.GameMode
= GM_COOP
);
3412 Srv
:= g_Game_IsServer
;
3413 Netsrv
:= g_Game_IsServer
and g_Game_IsNet
;
3414 if Srv
then FDeath
:= FDeath
+ 1;
3419 if not FPhysics
then
3425 if (gGameSettings
.MaxLives
> 0) and Srv
and (gLMSRespawn
= LMS_RESPAWN_NONE
) then
3427 if FLives
> 0 then FLives
:= FLives
- 1;
3428 if FLives
= 0 then FNoRespawn
:= True;
3431 // Íîìåð òèïà ñìåðòè:
3434 K_SIMPLEKILL
: a
:= 1;
3436 K_EXTRAHARDKILL
: a
:= 3;
3441 if not FModel
.PlaySound(MODELSOUND_DIE
, a
, FObj
.X
, FObj
.Y
) then
3443 if FModel
.PlaySound(MODELSOUND_DIE
, i
, FObj
.X
, FObj
.Y
) then
3450 FTime
[T_RESPAWN
] := gTime
+ TIME_RESPAWN1
;
3452 FTime
[T_RESPAWN
] := gTime
+ TIME_RESPAWN2
;
3453 K_EXTRAHARDKILL
, K_FALLKILL
:
3454 FTime
[T_RESPAWN
] := gTime
+ TIME_RESPAWN3
;
3457 // Ïåðåêëþ÷àåì ñîñòîÿíèå:
3461 K_HARDKILL
, K_EXTRAHARDKILL
:
3465 // Ðåàêöèÿ ìîíñòðîâ íà ñìåðòü èãðîêà:
3466 if (KillType
<> K_FALLKILL
) and (Srv
) then
3467 g_Monsters_killedp();
3469 if SpawnerUID
= FUID
then
3471 if Srv
and (DoFrags
or (gGameSettings
.GameMode
= GM_TDM
)) then
3476 g_Console_Add(Format(_lc
[I_PLAYER_KILL_SELF
], [FName
]), True);
3479 if g_GetUIDType(SpawnerUID
) = UID_PLAYER
then
3480 begin // Óáèò äðóãèì èãðîêîì
3481 KP
:= g_Player_Get(SpawnerUID
);
3482 if (KP
<> nil) and Srv
then
3484 if (DoFrags
or (gGameSettings
.GameMode
= GM_TDM
)) then
3485 if SameTeam(FUID
, SpawnerUID
) then
3495 if (gGameSettings
.GameMode
= GM_TDM
) and DoFrags
then
3496 Inc(gTeamStat
[KP
.Team
].Goals
,
3497 IfThen(SameTeam(FUID
, SpawnerUID
), -1, 1));
3499 if netsrv
then MH_SEND_PlayerStats(SpawnerUID
);
3502 plr
:= g_Player_Get(SpawnerUID
);
3510 g_Console_Add(Format(_lc
[I_PLAYER_KILL_EXTRAHARD_2
],
3514 g_Console_Add(Format(_lc
[I_PLAYER_KILL_EXTRAHARD_1
],
3518 g_Console_Add(Format(_lc
[I_PLAYER_KILL
],
3523 else if g_GetUIDType(SpawnerUID
) = UID_MONSTER
then
3524 begin // Óáèò ìîíñòðîì
3525 mon
:= g_Monsters_ByUID(SpawnerUID
);
3529 s
:= g_Mons_GetKilledByTypeId(mon
.MonsterType
);
3533 g_Console_Add(Format(_lc
[I_PLAYER_KILL_EXTRAHARD_2
],
3537 g_Console_Add(Format(_lc
[I_PLAYER_KILL_EXTRAHARD_1
],
3541 g_Console_Add(Format(_lc
[I_PLAYER_KILL
],
3546 else // Îñîáûå òèïû ñìåðòè
3549 HIT_SELF
: g_Console_Add(Format(_lc
[I_PLAYER_KILL_SELF
], [FName
]), True);
3550 HIT_FALL
: g_Console_Add(Format(_lc
[I_PLAYER_KILL_FALL
], [FName
]), True);
3551 HIT_WATER
: g_Console_Add(Format(_lc
[I_PLAYER_KILL_WATER
], [FName
]), True);
3552 HIT_ACID
: g_Console_Add(Format(_lc
[I_PLAYER_KILL_ACID
], [FName
]), True);
3553 HIT_TRAP
: g_Console_Add(Format(_lc
[I_PLAYER_KILL_TRAP
], [FName
]), True);
3554 else g_Console_Add(Format(_lc
[I_PLAYER_DIED
], [FName
]), True);
3560 for a
:= WP_FIRST
to WP_LAST
do
3564 WEAPON_SAW
: i
:= ITEM_WEAPON_SAW
;
3565 WEAPON_SHOTGUN1
: i
:= ITEM_WEAPON_SHOTGUN1
;
3566 WEAPON_SHOTGUN2
: i
:= ITEM_WEAPON_SHOTGUN2
;
3567 WEAPON_CHAINGUN
: i
:= ITEM_WEAPON_CHAINGUN
;
3568 WEAPON_ROCKETLAUNCHER
: i
:= ITEM_WEAPON_ROCKETLAUNCHER
;
3569 WEAPON_PLASMA
: i
:= ITEM_WEAPON_PLASMA
;
3570 WEAPON_BFG
: i
:= ITEM_WEAPON_BFG
;
3571 WEAPON_SUPERPULEMET
: i
:= ITEM_WEAPON_SUPERPULEMET
;
3572 WEAPON_FLAMETHROWER
: i
:= ITEM_WEAPON_FLAMETHROWER
;
3581 if R_ITEM_BACKPACK
in FRulez
then
3582 PushItem(ITEM_AMMO_BACKPACK
);
3584 // Âûáðîñ ðàêåòíîãî ðàíöà:
3585 if FJetFuel
> 0 then
3586 PushItem(ITEM_JETPACK
);
3589 if (not (gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
])) or
3590 (not LongBool(gGameSettings
.Options
and GAME_OPTION_DMKEYS
)) then
3592 if R_KEY_RED
in FRulez
then
3593 PushItem(ITEM_KEY_RED
);
3595 if R_KEY_GREEN
in FRulez
then
3596 PushItem(ITEM_KEY_GREEN
);
3598 if R_KEY_BLUE
in FRulez
then
3599 PushItem(ITEM_KEY_BLUE
);
3603 DropFlag(KillType
= K_FALLKILL
);
3606 g_Player_CreateCorpse(Self
);
3608 if Srv
and (gGameSettings
.MaxLives
> 0) and FNoRespawn
and
3609 (gLMSRespawn
= LMS_RESPAWN_NONE
) then
3615 for i
:= Low(gPlayers
) to High(gPlayers
) do
3617 if gPlayers
[i
] = nil then continue
;
3618 if (not gPlayers
[i
].FNoRespawn
) and (not gPlayers
[i
].FSpectator
) then
3621 if gPlayers
[i
].FTeam
= TEAM_RED
then Inc(ar
)
3622 else if gPlayers
[i
].FTeam
= TEAM_BLUE
then Inc(ab
);
3627 OldLR
:= gLMSRespawn
;
3628 if (gGameSettings
.GameMode
= GM_COOP
) then
3632 // everyone is dead, restart the map
3633 g_Game_Message(_lc
[I_MESSAGE_LMS_LOSE
], 144);
3635 MH_SEND_GameEvent(NET_EV_LMS_LOSE
);
3636 gLMSRespawn
:= LMS_RESPAWN_FINAL
;
3637 gLMSRespawnTime
:= gTime
+ 5000;
3639 else if (a
= 1) then
3641 if (gPlayers
[k
] <> nil) and not (gPlayers
[k
] is TBot
) then
3642 if (gPlayers
[k
] = gPlayer1
) or
3643 (gPlayers
[k
] = gPlayer2
) then
3644 g_Console_Add('*** ' + _lc
[I_MESSAGE_LMS_SURVIVOR
] + ' ***', True)
3645 else if Netsrv
and (gPlayers
[k
].FClientID
>= 0) then
3646 MH_SEND_GameEvent(NET_EV_LMS_SURVIVOR
, 0, 'N', gPlayers
[k
].FClientID
);
3649 else if (gGameSettings
.GameMode
= GM_TDM
) then
3651 if (ab
= 0) and (ar
<> 0) then
3654 g_Game_Message(Format(_lc
[I_MESSAGE_TLMS_WIN
], [AnsiUpperCase(_lc
[I_GAME_TEAM_RED
])]), 144);
3656 MH_SEND_GameEvent(NET_EV_TLMS_WIN
, TEAM_RED
);
3657 Inc(gTeamStat
[TEAM_RED
].Goals
);
3658 gLMSRespawn
:= LMS_RESPAWN_FINAL
;
3659 gLMSRespawnTime
:= gTime
+ 5000;
3661 else if (ar
= 0) and (ab
<> 0) then
3664 g_Game_Message(Format(_lc
[I_MESSAGE_TLMS_WIN
], [AnsiUpperCase(_lc
[I_GAME_TEAM_BLUE
])]), 144);
3666 MH_SEND_GameEvent(NET_EV_TLMS_WIN
, TEAM_BLUE
);
3667 Inc(gTeamStat
[TEAM_BLUE
].Goals
);
3668 gLMSRespawn
:= LMS_RESPAWN_FINAL
;
3669 gLMSRespawnTime
:= gTime
+ 5000;
3671 else if (ar
= 0) and (ab
= 0) then
3674 g_Game_Message(_lc
[I_GAME_WIN_DRAW
], 144);
3676 MH_SEND_GameEvent(NET_EV_LMS_DRAW
, 0, FName
);
3677 gLMSRespawn
:= LMS_RESPAWN_FINAL
;
3678 gLMSRespawnTime
:= gTime
+ 5000;
3681 else if (gGameSettings
.GameMode
= GM_DM
) then
3685 if gPlayers
[k
] <> nil then
3688 // survivor is the winner
3689 g_Game_Message(Format(_lc
[I_MESSAGE_LMS_WIN
], [AnsiUpperCase(FName
)]), 144);
3691 MH_SEND_GameEvent(NET_EV_LMS_WIN
, 0, FName
);
3694 gLMSRespawn
:= LMS_RESPAWN_FINAL
;
3695 gLMSRespawnTime
:= gTime
+ 5000;
3697 else if (a
= 0) then
3699 // everyone is dead, restart the map
3700 g_Game_Message(_lc
[I_GAME_WIN_DRAW
], 144);
3702 MH_SEND_GameEvent(NET_EV_LMS_DRAW
, 0, FName
);
3703 gLMSRespawn
:= LMS_RESPAWN_FINAL
;
3704 gLMSRespawnTime
:= gTime
+ 5000;
3707 if srv
and (OldLR
= LMS_RESPAWN_NONE
) and (gLMSRespawn
> LMS_RESPAWN_NONE
) then
3709 if NetMode
= NET_SERVER
then
3710 MH_SEND_GameEvent(NET_EV_LMS_WARMUP
, gLMSRespawnTime
- gTime
)
3712 g_Console_Add(Format(_lc
[I_MSG_WARMUP_START
], [(gLMSRespawnTime
- gTime
) div 1000]), True);
3718 MH_SEND_PlayerStats(FUID
);
3719 MH_SEND_PlayerDeath(FUID
, KillType
, t
, SpawnerUID
);
3720 if gGameSettings
.GameMode
= GM_TDM
then MH_SEND_GameStats
;
3723 if srv
and FNoRespawn
then Spectate(True);
3724 FWantsInGame
:= True;
3727 function TPlayer
.BodyInLiquid(XInc
, YInc
: Integer): Boolean;
3729 Result
:= g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
, PLAYER_RECT
.Width
,
3730 PLAYER_RECT
.Height
-20, PANEL_WATER
or PANEL_ACID1
or PANEL_ACID2
, False);
3733 function TPlayer
.BodyInAcid(XInc
, YInc
: Integer): Boolean;
3735 Result
:= g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
, PLAYER_RECT
.Width
,
3736 PLAYER_RECT
.Height
-20, PANEL_ACID1
or PANEL_ACID2
, False);
3739 procedure TPlayer
.MakeBloodSimple(Count
: Word);
3741 g_GFX_Blood(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)+8,
3742 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2),
3743 Count
div 2, 3, -1, 16, (PLAYER_RECT
.Height
*2 div 3),
3744 FModel
.Blood
.R
, FModel
.Blood
.G
, FModel
.Blood
.B
, FModel
.Blood
.Kind
);
3745 g_GFX_Blood(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-8,
3746 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2),
3747 Count
div 2, -3, -1, 16, (PLAYER_RECT
.Height
*2) div 3,
3748 FModel
.Blood
.R
, FModel
.Blood
.G
, FModel
.Blood
.B
, FModel
.Blood
.Kind
);
3751 procedure TPlayer
.MakeBloodVector(Count
: Word; VelX
, VelY
: Integer);
3753 g_GFX_Blood(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2),
3754 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2),
3755 Count
, VelX
, VelY
, 16, (PLAYER_RECT
.Height
*2) div 3,
3756 FModel
.Blood
.R
, FModel
.Blood
.G
, FModel
.Blood
.B
, FModel
.Blood
.Kind
);
3759 procedure TPlayer
.QueueWeaponSwitch(Weapon
: Byte);
3761 if g_Game_IsClient
then Exit
;
3762 if Weapon
> High(FWeapon
) then Exit
;
3763 FNextWeap
:= FNextWeap
or (1 shl Weapon
);
3766 procedure TPlayer
.resetWeaponQueue ();
3769 FNextWeapDelay
:= 0;
3772 function TPlayer
.hasAmmoForWeapon (weapon
: Byte): Boolean;
3776 WEAPON_KASTET
, WEAPON_SAW
: result
:= true;
3777 WEAPON_SHOTGUN1
, WEAPON_SHOTGUN2
, WEAPON_SUPERPULEMET
: result
:= (FAmmo
[A_SHELLS
] > 0);
3778 WEAPON_PISTOL
, WEAPON_CHAINGUN
: result
:= (FAmmo
[A_BULLETS
] > 0);
3779 WEAPON_ROCKETLAUNCHER
: result
:= (FAmmo
[A_ROCKETS
] > 0);
3780 WEAPON_PLASMA
, WEAPON_BFG
: result
:= (FAmmo
[A_CELLS
] > 0);
3781 WEAPON_FLAMETHROWER
: result
:= (FAmmo
[A_FUEL
] > 0);
3782 else result
:= (weapon
< length(FWeapon
));
3786 // return 255 for "no switch"
3787 function TPlayer
.getNextWeaponIndex (): Byte;
3790 wantThisWeapon
: array[0..64] of Boolean;
3791 wwc
: Integer = 0; //HACK!
3794 result
:= 255; // default result: "no switch"
3795 // had weapon cycling on previous frame? remove that flag
3796 if (FNextWeap
and $2000) <> 0 then
3798 FNextWeap
:= FNextWeap
and $1FFF;
3799 FNextWeapDelay
:= 0;
3801 // cycling has priority
3802 if (FNextWeap
and $C000) <> 0 then
3804 if (FNextWeap
and $8000) <> 0 then
3808 FNextWeap
:= FNextWeap
or $2000; // we need this
3809 if FNextWeapDelay
> 0 then
3810 exit
; // cooldown time
3812 for i
:= 0 to High(FWeapon
) do
3814 cwi
:= (cwi
+length(FWeapon
)+dir
) mod length(FWeapon
);
3815 if FWeapon
[cwi
] then
3817 //e_WriteLog(Format(' SWITCH: cur=%d; new=%d', [FCurrWeap, cwi]), MSG_WARNING);
3818 result
:= Byte(cwi
);
3819 FNextWeapDelay
:= WEAPON_DELAY
;
3827 for i
:= 0 to High(wantThisWeapon
) do
3828 wantThisWeapon
[i
] := false;
3829 for i
:= 0 to High(FWeapon
) do
3830 if (FNextWeap
and (1 shl i
)) <> 0 then
3832 wantThisWeapon
[i
] := true;
3835 // exclude currently selected weapon from the set
3836 wantThisWeapon
[FCurrWeap
] := false;
3837 // slow down alterations a little
3840 //e_WriteLog(Format(' FNextWeap=%x; delay=%d', [FNextWeap, FNextWeapDelay]), MSG_WARNING);
3841 // more than one weapon requested, assume "alteration" and check alteration delay
3842 if FNextWeapDelay
> 0 then
3848 // do not reset weapon queue, it will be done in `RealizeCurrentWeapon()`
3849 // but clear all counters if no weapon should be switched
3855 //e_WriteLog(Format('wwc=%d', [wwc]), MSG_WARNING);
3856 // try weapons in descending order
3857 for i
:= High(FWeapon
) downto 0 do
3859 if wantThisWeapon
[i
] and FWeapon
[i
] and ((wwc
= 1) or hasAmmoForWeapon(i
)) then
3864 FNextWeapDelay
:= WEAPON_DELAY
* 2; // anyway, 'cause why not
3868 // no suitable weapon found, so reset the queue, to avoid accidental "queuing" of weapon w/o ammo
3872 procedure TPlayer
.RealizeCurrentWeapon();
3873 function switchAllowed (): Boolean;
3878 if FBFGFireCounter
<> -1 then
3880 if FTime
[T_SWITCH
] > gTime
then
3882 for i
:= WP_FIRST
to WP_LAST
do
3883 if FReloading
[i
] > 0 then
3891 //e_WriteLog(Format('***RealizeCurrentWeapon: FNextWeap=%x; FNextWeapDelay=%d', [FNextWeap, FNextWeapDelay]), MSG_WARNING);
3892 //FNextWeap := FNextWeap and $1FFF;
3893 if FNextWeapDelay
> 0 then Dec(FNextWeapDelay
); // "alteration delay"
3895 if not switchAllowed
then
3897 //HACK for weapon cycling
3898 if (FNextWeap
and $E000) <> 0 then FNextWeap
:= 0;
3902 nw
:= getNextWeaponIndex();
3903 if nw
= 255 then exit
; // don't reset anything here
3904 if nw
> High(FWeapon
) then
3906 // don't forget to reset queue here!
3907 //e_WriteLog(' RealizeCurrentWeapon: WUTAFUUUU', MSG_WARNING);
3915 FTime
[T_SWITCH
] := gTime
+156;
3916 if FCurrWeap
= WEAPON_SAW
then FSawSoundSelect
.PlayAt(FObj
.X
, FObj
.Y
);
3917 FModel
.SetWeapon(FCurrWeap
);
3918 if g_Game_IsNet
then MH_SEND_PlayerStats(FUID
);
3922 procedure TPlayer
.NextWeapon();
3924 if g_Game_IsClient
then Exit
;
3928 procedure TPlayer
.PrevWeapon();
3930 if g_Game_IsClient
then Exit
;
3934 procedure TPlayer
.SetWeapon(W
: Byte);
3936 if FCurrWeap
<> W
then
3937 if W
= WEAPON_SAW
then
3938 FSawSoundSelect
.PlayAt(FObj
.X
, FObj
.Y
);
3941 FModel
.SetWeapon(CurrWeap
);
3945 function TPlayer
.PickItem(ItemType
: Byte; arespawn
: Boolean; var remove
: Boolean): Boolean;
3947 function allowBerserkSwitching (): Boolean;
3949 if (FBFGFireCounter
<> -1) then begin result
:= false; exit
; end;
3951 if gBerserkAutoswitch
then exit
;
3952 if not conIsCheatsEnabled
then exit
;
3960 if g_Game_IsClient
then Exit
;
3962 // a = true - ìåñòî ñïàâíà ïðåäìåòà:
3963 a
:= LongBool(gGameSettings
.Options
and GAME_OPTION_WEAPONSTAY
) and arespawn
;
3968 if (FHealth
< PLAYER_HP_SOFT
) or (FFireTime
> 0) then
3970 if FHealth
< PLAYER_HP_SOFT
then IncMax(FHealth
, 10, PLAYER_HP_SOFT
);
3974 if gFlash
= 2 then Inc(FPickup
, 5);
3978 if (FHealth
< PLAYER_HP_SOFT
) or (FFireTime
> 0) then
3980 if FHealth
< PLAYER_HP_SOFT
then IncMax(FHealth
, 25, PLAYER_HP_SOFT
);
3984 if gFlash
= 2 then Inc(FPickup
, 5);
3988 if FArmor
< PLAYER_AP_SOFT
then
3990 FArmor
:= PLAYER_AP_SOFT
;
3993 if gFlash
= 2 then Inc(FPickup
, 5);
3997 if FArmor
< PLAYER_AP_LIMIT
then
3999 FArmor
:= PLAYER_AP_LIMIT
;
4002 if gFlash
= 2 then Inc(FPickup
, 5);
4006 if (FHealth
< PLAYER_HP_LIMIT
) or (FFireTime
> 0) then
4008 if FHealth
< PLAYER_HP_LIMIT
then IncMax(FHealth
, 100, PLAYER_HP_LIMIT
);
4012 if gFlash
= 2 then Inc(FPickup
, 5);
4016 if (FHealth
< PLAYER_HP_LIMIT
) or (FArmor
< PLAYER_AP_LIMIT
) or (FFireTime
> 0) then
4018 if FHealth
< PLAYER_HP_LIMIT
then
4019 FHealth
:= PLAYER_HP_LIMIT
;
4020 if FArmor
< PLAYER_AP_LIMIT
then
4021 FArmor
:= PLAYER_AP_LIMIT
;
4025 if gFlash
= 2 then Inc(FPickup
, 5);
4029 if (not FWeapon
[WEAPON_SAW
]) or ((not arespawn
) and (gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
])) then
4031 FWeapon
[WEAPON_SAW
] := True;
4033 if gFlash
= 2 then Inc(FPickup
, 5);
4034 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
4037 ITEM_WEAPON_SHOTGUN1
:
4038 if (FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
]) or not FWeapon
[WEAPON_SHOTGUN1
] then
4040 // Íóæíî, ÷òîáû íå âçÿòü âñå ïóëè ñðàçó:
4041 if a
and FWeapon
[WEAPON_SHOTGUN1
] then Exit
;
4043 IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
4044 FWeapon
[WEAPON_SHOTGUN1
] := True;
4046 if gFlash
= 2 then Inc(FPickup
, 5);
4047 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
4050 ITEM_WEAPON_SHOTGUN2
:
4051 if (FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
]) or not FWeapon
[WEAPON_SHOTGUN2
] then
4053 if a
and FWeapon
[WEAPON_SHOTGUN2
] then Exit
;
4055 IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
4056 FWeapon
[WEAPON_SHOTGUN2
] := True;
4058 if gFlash
= 2 then Inc(FPickup
, 5);
4059 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
4062 ITEM_WEAPON_CHAINGUN
:
4063 if (FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
]) or not FWeapon
[WEAPON_CHAINGUN
] then
4065 if a
and FWeapon
[WEAPON_CHAINGUN
] then Exit
;
4067 IncMax(FAmmo
[A_BULLETS
], 50, FMaxAmmo
[A_BULLETS
]);
4068 FWeapon
[WEAPON_CHAINGUN
] := True;
4070 if gFlash
= 2 then Inc(FPickup
, 5);
4071 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
4074 ITEM_WEAPON_ROCKETLAUNCHER
:
4075 if (FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
]) or not FWeapon
[WEAPON_ROCKETLAUNCHER
] then
4077 if a
and FWeapon
[WEAPON_ROCKETLAUNCHER
] then Exit
;
4079 IncMax(FAmmo
[A_ROCKETS
], 2, FMaxAmmo
[A_ROCKETS
]);
4080 FWeapon
[WEAPON_ROCKETLAUNCHER
] := 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');
4087 if (FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
]) or not FWeapon
[WEAPON_PLASMA
] then
4089 if a
and FWeapon
[WEAPON_PLASMA
] then Exit
;
4091 IncMax(FAmmo
[A_CELLS
], 40, FMaxAmmo
[A_CELLS
]);
4092 FWeapon
[WEAPON_PLASMA
] := True;
4094 if gFlash
= 2 then Inc(FPickup
, 5);
4095 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
4099 if (FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
]) or not FWeapon
[WEAPON_BFG
] then
4101 if a
and FWeapon
[WEAPON_BFG
] then Exit
;
4103 IncMax(FAmmo
[A_CELLS
], 40, FMaxAmmo
[A_CELLS
]);
4104 FWeapon
[WEAPON_BFG
] := True;
4106 if gFlash
= 2 then Inc(FPickup
, 5);
4107 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
4110 ITEM_WEAPON_SUPERPULEMET
:
4111 if (FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
]) or not FWeapon
[WEAPON_SUPERPULEMET
] then
4113 if a
and FWeapon
[WEAPON_SUPERPULEMET
] then Exit
;
4115 IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
4116 FWeapon
[WEAPON_SUPERPULEMET
] := True;
4118 if gFlash
= 2 then Inc(FPickup
, 5);
4119 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
4122 ITEM_WEAPON_FLAMETHROWER
:
4123 if (FAmmo
[A_FUEL
] < FMaxAmmo
[A_FUEL
]) or not FWeapon
[WEAPON_FLAMETHROWER
] then
4125 if a
and FWeapon
[WEAPON_FLAMETHROWER
] then Exit
;
4127 IncMax(FAmmo
[A_FUEL
], 100, FMaxAmmo
[A_FUEL
]);
4128 FWeapon
[WEAPON_FLAMETHROWER
] := True;
4130 if gFlash
= 2 then Inc(FPickup
, 5);
4131 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
4135 if FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
] then
4137 IncMax(FAmmo
[A_BULLETS
], 10, FMaxAmmo
[A_BULLETS
]);
4140 if gFlash
= 2 then Inc(FPickup
, 5);
4143 ITEM_AMMO_BULLETS_BOX
:
4144 if FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
] then
4146 IncMax(FAmmo
[A_BULLETS
], 50, FMaxAmmo
[A_BULLETS
]);
4149 if gFlash
= 2 then Inc(FPickup
, 5);
4153 if FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
] then
4155 IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
4158 if gFlash
= 2 then Inc(FPickup
, 5);
4161 ITEM_AMMO_SHELLS_BOX
:
4162 if FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
] then
4164 IncMax(FAmmo
[A_SHELLS
], 25, FMaxAmmo
[A_SHELLS
]);
4167 if gFlash
= 2 then Inc(FPickup
, 5);
4171 if FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
] then
4173 IncMax(FAmmo
[A_ROCKETS
], 1, FMaxAmmo
[A_ROCKETS
]);
4176 if gFlash
= 2 then Inc(FPickup
, 5);
4179 ITEM_AMMO_ROCKET_BOX
:
4180 if FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
] then
4182 IncMax(FAmmo
[A_ROCKETS
], 5, FMaxAmmo
[A_ROCKETS
]);
4185 if gFlash
= 2 then Inc(FPickup
, 5);
4189 if FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
] then
4191 IncMax(FAmmo
[A_CELLS
], 40, FMaxAmmo
[A_CELLS
]);
4194 if gFlash
= 2 then Inc(FPickup
, 5);
4198 if FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
] then
4200 IncMax(FAmmo
[A_CELLS
], 100, FMaxAmmo
[A_CELLS
]);
4203 if gFlash
= 2 then Inc(FPickup
, 5);
4207 if FAmmo
[A_FUEL
] < FMaxAmmo
[A_FUEL
] then
4209 IncMax(FAmmo
[A_FUEL
], 100, FMaxAmmo
[A_FUEL
]);
4212 if gFlash
= 2 then Inc(FPickup
, 5);
4216 if not(R_ITEM_BACKPACK
in FRulez
) or
4217 (FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
]) or
4218 (FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
]) or
4219 (FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
]) or
4220 (FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
]) or
4221 (FAmmo
[A_FUEL
] < FMaxAmmo
[A_FUEL
]) then
4223 FMaxAmmo
[A_BULLETS
] := AmmoLimits
[1, A_BULLETS
];
4224 FMaxAmmo
[A_SHELLS
] := AmmoLimits
[1, A_SHELLS
];
4225 FMaxAmmo
[A_ROCKETS
] := AmmoLimits
[1, A_ROCKETS
];
4226 FMaxAmmo
[A_CELLS
] := AmmoLimits
[1, A_CELLS
];
4227 FMaxAmmo
[A_FUEL
] := AmmoLimits
[1, A_FUEL
];
4229 if FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
] then
4230 IncMax(FAmmo
[A_BULLETS
], 10, FMaxAmmo
[A_BULLETS
]);
4231 if FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
] then
4232 IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
4233 if FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
] then
4234 IncMax(FAmmo
[A_ROCKETS
], 1, FMaxAmmo
[A_ROCKETS
]);
4235 if FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
] then
4236 IncMax(FAmmo
[A_CELLS
], 40, FMaxAmmo
[A_CELLS
]);
4237 if FAmmo
[A_FUEL
] < FMaxAmmo
[A_FUEL
] then
4238 IncMax(FAmmo
[A_FUEL
], 50, FMaxAmmo
[A_FUEL
]);
4240 FRulez
:= FRulez
+ [R_ITEM_BACKPACK
];
4243 if gFlash
= 2 then Inc(FPickup
, 5);
4247 if not(R_KEY_RED
in FRulez
) then
4249 Include(FRulez
, R_KEY_RED
);
4251 remove
:= (gGameSettings
.GameMode
<> GM_COOP
) and (g_Player_GetCount() < 2);
4252 if gFlash
= 2 then Inc(FPickup
, 5);
4253 if (not remove
) and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETITEM');
4257 if not(R_KEY_GREEN
in FRulez
) then
4259 Include(FRulez
, R_KEY_GREEN
);
4261 remove
:= (gGameSettings
.GameMode
<> GM_COOP
) and (g_Player_GetCount() < 2);
4262 if gFlash
= 2 then Inc(FPickup
, 5);
4263 if (not remove
) and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETITEM');
4267 if not(R_KEY_BLUE
in FRulez
) then
4269 Include(FRulez
, R_KEY_BLUE
);
4271 remove
:= (gGameSettings
.GameMode
<> GM_COOP
) and (g_Player_GetCount() < 2);
4272 if gFlash
= 2 then Inc(FPickup
, 5);
4273 if (not remove
) and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETITEM');
4277 if FMegaRulez
[MR_SUIT
] < gTime
+PLAYER_SUIT_TIME
then
4279 FMegaRulez
[MR_SUIT
] := gTime
+PLAYER_SUIT_TIME
;
4283 if gFlash
= 2 then Inc(FPickup
, 5);
4287 if FAir
< AIR_MAX
then
4292 if gFlash
= 2 then Inc(FPickup
, 5);
4297 if not (R_BERSERK
in FRulez
) then
4299 Include(FRulez
, R_BERSERK
);
4300 if allowBerserkSwitching
then
4302 FCurrWeap
:= WEAPON_KASTET
;
4304 FModel
.SetWeapon(WEAPON_KASTET
);
4309 if gFlash
= 2 then Inc(FPickup
, 5);
4311 FBerserk
:= gTime
+30000;
4316 if (FHealth
< PLAYER_HP_SOFT
) or (FFireTime
> 0) then
4318 if FHealth
< PLAYER_HP_SOFT
then FHealth
:= PLAYER_HP_SOFT
;
4319 FBerserk
:= gTime
+30000;
4327 if FMegaRulez
[MR_INVUL
] < gTime
+PLAYER_INVUL_TIME
then
4329 FMegaRulez
[MR_INVUL
] := gTime
+PLAYER_INVUL_TIME
;
4333 if gFlash
= 2 then Inc(FPickup
, 5);
4337 if (FHealth
< PLAYER_HP_LIMIT
) or (FFireTime
> 0) then
4339 if FHealth
< PLAYER_HP_LIMIT
then IncMax(FHealth
, 4, PLAYER_HP_LIMIT
);
4343 if gFlash
= 2 then Inc(FPickup
, 5);
4347 if FArmor
< PLAYER_AP_LIMIT
then
4349 IncMax(FArmor
, 5, PLAYER_AP_LIMIT
);
4352 if gFlash
= 2 then Inc(FPickup
, 5);
4356 if FJetFuel
< JET_MAX
then
4358 FJetFuel
:= JET_MAX
;
4361 if gFlash
= 2 then Inc(FPickup
, 5);
4365 if FMegaRulez
[MR_INVIS
] < gTime
+PLAYER_INVIS_TIME
then
4367 FMegaRulez
[MR_INVIS
] := gTime
+PLAYER_INVIS_TIME
;
4370 if gFlash
= 2 then Inc(FPickup
, 5);
4375 procedure TPlayer
.Touch();
4379 //FModel.PlaySound(MODELSOUND_PAIN, 1, FObj.X, FObj.Y);
4382 // Áðîñèòü ôëàã òîâàðèùó:
4383 if gGameSettings
.GameMode
= GM_CTF
then
4388 procedure TPlayer
.Push(vx
, vy
: Integer);
4390 if (not FPhysics
) and FGhost
then
4392 FObj
.Accel
.X
:= FObj
.Accel
.X
+ vx
;
4393 FObj
.Accel
.Y
:= FObj
.Accel
.Y
+ vy
;
4394 if g_Game_IsNet
and g_Game_IsServer
then
4395 MH_SEND_PlayerPos(True, FUID
, NET_EVERYONE
);
4398 procedure TPlayer
.Reset(Force
: Boolean);
4404 FTime
[T_RESPAWN
] := 0;
4405 FTime
[T_FLAGCAP
] := 0;
4420 FSpectator
:= False;
4423 FSpectatePlayer
:= -1;
4424 FNoRespawn
:= False;
4426 FLives
:= gGameSettings
.MaxLives
;
4431 procedure TPlayer
.SoftReset();
4439 FBFGFireCounter
:= -1;
4447 SetAction(A_STAND
, True);
4450 function TPlayer
.GetRespawnPoint(): Byte;
4455 // Íà áóäóùåå: FSpawn - èãðîê óæå èãðàë è ïåðåðîæäàåòñÿ
4457 // Îäèíî÷íàÿ èãðà/êîîïåðàòèâ
4458 if gGameSettings
.GameMode
in [GM_COOP
, GM_SINGLE
] then
4460 if (Self
= gPlayer1
) or (Self
= gPlayer2
) then
4462 // Òî÷êà ïîÿâëåíèÿ ñâîåãî èãðîêà
4463 if Self
= gPlayer1
then
4464 c
:= RESPAWNPOINT_PLAYER1
4466 c
:= RESPAWNPOINT_PLAYER2
;
4467 if g_Map_GetPointCount(c
) > 0 then
4473 // Òî÷êà ïîÿâëåíèÿ äðóãîãî èãðîêà
4474 if Self
= gPlayer1
then
4475 c
:= RESPAWNPOINT_PLAYER2
4477 c
:= RESPAWNPOINT_PLAYER1
;
4478 if g_Map_GetPointCount(c
) > 0 then
4485 // Òî÷êà ïîÿâëåíèÿ ëþáîãî èãðîêà (áîòà)
4486 if Random(2) = 0 then
4487 c
:= RESPAWNPOINT_PLAYER1
4489 c
:= RESPAWNPOINT_PLAYER2
;
4490 if g_Map_GetPointCount(c
) > 0 then
4497 // Òî÷êà ëþáîé èç êîìàíä
4498 if Random(2) = 0 then
4499 c
:= RESPAWNPOINT_RED
4501 c
:= RESPAWNPOINT_BLUE
;
4502 if g_Map_GetPointCount(c
) > 0 then
4509 c
:= RESPAWNPOINT_DM
;
4510 if g_Map_GetPointCount(c
) > 0 then
4518 if gGameSettings
.GameMode
= GM_DM
then
4521 c
:= RESPAWNPOINT_DM
;
4522 if g_Map_GetPointCount(c
) > 0 then
4528 // Òî÷êà ïîÿâëåíèÿ ëþáîãî èãðîêà
4529 if Random(2) = 0 then
4530 c
:= RESPAWNPOINT_PLAYER1
4532 c
:= RESPAWNPOINT_PLAYER2
;
4533 if g_Map_GetPointCount(c
) > 0 then
4539 // Òî÷êà ëþáîé èç êîìàíä
4540 if Random(2) = 0 then
4541 c
:= RESPAWNPOINT_RED
4543 c
:= RESPAWNPOINT_BLUE
;
4544 if g_Map_GetPointCount(c
) > 0 then
4552 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
4554 // Òî÷êà ñâîåé êîìàíäû
4555 c
:= RESPAWNPOINT_DM
;
4556 if FTeam
= TEAM_RED
then
4557 c
:= RESPAWNPOINT_RED
;
4558 if FTeam
= TEAM_BLUE
then
4559 c
:= RESPAWNPOINT_BLUE
;
4560 if g_Map_GetPointCount(c
) > 0 then
4567 c
:= RESPAWNPOINT_DM
;
4568 if g_Map_GetPointCount(c
) > 0 then
4574 // Òî÷êà ïîÿâëåíèÿ ëþáîãî èãðîêà
4575 if Random(2) = 0 then
4576 c
:= RESPAWNPOINT_PLAYER1
4578 c
:= RESPAWNPOINT_PLAYER2
;
4579 if g_Map_GetPointCount(c
) > 0 then
4585 // Òî÷êà äðóãîé êîìàíäû
4586 c
:= RESPAWNPOINT_DM
;
4587 if FTeam
= TEAM_RED
then
4588 c
:= RESPAWNPOINT_BLUE
;
4589 if FTeam
= TEAM_BLUE
then
4590 c
:= RESPAWNPOINT_RED
;
4591 if g_Map_GetPointCount(c
) > 0 then
4599 procedure TPlayer
.Respawn(Silent
: Boolean; Force
: Boolean = False);
4601 RespawnPoint
: TRespawnPoint
;
4609 FBFGFireCounter
:= -1;
4615 if not g_Game_IsServer
then
4619 FWantsInGame
:= True;
4620 FJustTeleported
:= True;
4623 FTime
[T_RESPAWN
] := 0;
4627 // if server changes MaxLives we gotta be ready
4628 if gGameSettings
.MaxLives
= 0 then FNoRespawn
:= False;
4630 // Åùå íåëüçÿ âîçðîäèòüñÿ:
4631 if FTime
[T_RESPAWN
] > gTime
then
4634 // Ïðîñðàë âñå æèçíè:
4637 if not FSpectator
then Spectate(True);
4638 FWantsInGame
:= True;
4642 if (gGameSettings
.GameType
<> GT_SINGLE
) and (gGameSettings
.GameMode
<> GM_COOP
) then
4643 begin // "Ñâîÿ èãðà"
4644 // Áåðñåðê íå ñîõðàíÿåòñÿ ìåæäó óðîâíÿìè:
4645 FRulez
:= FRulez
-[R_BERSERK
];
4647 else // "Îäèíî÷íàÿ èãðà"/"Êîîï"
4649 // Áåðñåðê è êëþ÷è íå ñîõðàíÿþòñÿ ìåæäó óðîâíÿìè:
4650 FRulez
:= FRulez
-[R_KEY_RED
, R_KEY_GREEN
, R_KEY_BLUE
, R_BERSERK
];
4653 // Ïîëó÷àåì òî÷êó ñïàóíà èãðîêà:
4654 c
:= GetRespawnPoint();
4659 // Âîñêðåøåíèå áåç îðóæèÿ:
4662 FHealth
:= Round(PLAYER_HP_SOFT
* (FHandicap
/ 100));
4668 for a
:= WP_FIRST
to WP_LAST
do
4670 FWeapon
[a
] := False;
4674 FWeapon
[WEAPON_PISTOL
] := True;
4675 FWeapon
[WEAPON_KASTET
] := True;
4676 FCurrWeap
:= WEAPON_PISTOL
;
4679 FModel
.SetWeapon(FCurrWeap
);
4681 for b
:= A_BULLETS
to A_HIGH
do
4684 FAmmo
[A_BULLETS
] := 50;
4686 FMaxAmmo
[A_BULLETS
] := AmmoLimits
[0, A_BULLETS
];
4687 FMaxAmmo
[A_SHELLS
] := AmmoLimits
[0, A_SHELLS
];
4688 FMaxAmmo
[A_ROCKETS
] := AmmoLimits
[0, A_SHELLS
];
4689 FMaxAmmo
[A_CELLS
] := AmmoLimits
[0, A_CELLS
];
4690 FMaxAmmo
[A_FUEL
] := AmmoLimits
[0, A_FUEL
];
4692 if (gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
]) and
4693 LongBool(gGameSettings
.Options
and GAME_OPTION_DMKEYS
) then
4694 FRulez
:= [R_KEY_RED
, R_KEY_GREEN
, R_KEY_BLUE
]
4699 // Ïîëó÷àåì êîîðäèíàòû òî÷êè âîçðîæäåíèÿ:
4700 if not g_Map_GetPoint(c
, RespawnPoint
) then
4702 g_FatalError(_lc
[I_GAME_ERROR_GET_SPAWN
]);
4706 // Óñòàíîâêà êîîðäèíàò è ñáðîñ âñåõ ïàðàìåòðîâ:
4707 FObj
.X
:= RespawnPoint
.X
-PLAYER_RECT
.X
;
4708 FObj
.Y
:= RespawnPoint
.Y
-PLAYER_RECT
.Y
;
4709 FObj
.oldX
:= FObj
.X
; // don't interpolate after respawn
4710 FObj
.oldY
:= FObj
.Y
;
4716 FDirection
:= RespawnPoint
.Direction
;
4717 if FDirection
= TDirection
.D_LEFT
then
4722 SetAction(A_STAND
, True);
4723 FModel
.Direction
:= FDirection
;
4725 for a
:= Low(FTime
) to High(FTime
) do
4728 for a
:= Low(FMegaRulez
) to High(FMegaRulez
) do
4731 // Respawn invulnerability
4732 if (gGameSettings
.GameType
<> GT_SINGLE
) and (gGameSettings
.SpawnInvul
> 0) then
4734 FMegaRulez
[MR_INVUL
] := gTime
+ gGameSettings
.SpawnInvul
* 1000;
4735 FSpawnInvul
:= FMegaRulez
[MR_INVUL
];
4740 FCanJetpack
:= False;
4746 // Àíèìàöèÿ âîçðîæäåíèÿ:
4747 if (not gLoadGameMode
) and (not Silent
) then
4748 if g_Frames_Get(ID
, 'FRAMES_TELEPORT') then
4750 Anim
:= TAnimation
.Create(ID
, False, 3);
4751 g_GFX_OnceAnim(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-32,
4752 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)-32, Anim
);
4756 FSpectator
:= False;
4759 FSpectatePlayer
:= -1;
4762 if (gPlayer1
= nil) and (gSpectLatchPID1
= FUID
) then
4764 if (gPlayer2
= nil) and (gSpectLatchPID2
= FUID
) then
4767 if g_Game_IsNet
then
4769 MH_SEND_PlayerPos(True, FUID
, NET_EVERYONE
);
4770 MH_SEND_PlayerStats(FUID
, NET_EVERYONE
);
4772 MH_SEND_Effect(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-32,
4773 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)-32,
4778 procedure TPlayer
.Spectate(NoMove
: Boolean = False);
4781 Kill(K_EXTRAHARDKILL
, FUID
, HIT_SOME
)
4782 else if (not NoMove
) then
4784 GameX
:= gMapInfo
.Width
div 2;
4785 GameY
:= gMapInfo
.Height
div 2;
4794 FWantsInGame
:= False;
4799 if Self
= gPlayer1
then
4801 gSpectLatchPID1
:= FUID
;
4804 else if Self
= gPlayer2
then
4806 gSpectLatchPID2
:= FUID
;
4811 if g_Game_IsNet
then
4812 MH_SEND_PlayerStats(FUID
);
4815 procedure TPlayer
.SwitchNoClip
;
4819 FGhost
:= not FGhost
;
4820 FPhysics
:= not FGhost
;
4832 procedure TPlayer
.Run(Direction
: TDirection
);
4836 if MAX_RUNVEL
> 8 then
4840 if Direction
= TDirection
.D_LEFT
then
4842 if FObj
.Vel
.X
> -MAX_RUNVEL
then
4843 FObj
.Vel
.X
:= FObj
.Vel
.X
- (MAX_RUNVEL
shr 3);
4846 if FObj
.Vel
.X
< MAX_RUNVEL
then
4847 FObj
.Vel
.X
:= FObj
.Vel
.X
+ (MAX_RUNVEL
shr 3);
4849 // Âîçìîæíî, ïèíàåì êóñêè:
4850 if (FObj
.Vel
.X
<> 0) and (gGibs
<> nil) then
4852 b
:= Abs(FObj
.Vel
.X
);
4853 if b
> 1 then b
:= b
* (Random(8 div b
) + 1);
4854 for a
:= 0 to High(gGibs
) do
4856 if gGibs
[a
].alive
and
4857 g_Obj_Collide(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
+FObj
.Rect
.Height
-4,
4858 FObj
.Rect
.Width
, 8, @gGibs
[a
].Obj
) and (Random(3) = 0) then
4861 if FObj
.Vel
.X
< 0 then
4863 g_Obj_PushA(@gGibs
[a
].Obj
, b
, Random(61)+120) // íàëåâî
4867 g_Obj_PushA(@gGibs
[a
].Obj
, b
, Random(61)); // íàïðàâî
4869 gGibs
[a
].positionChanged(); // this updates spatial accelerators
4877 procedure TPlayer
.SeeDown();
4879 SetAction(A_SEEDOWN
);
4881 if FDirection
= TDirection
.D_LEFT
then FAngle
:= ANGLE_LEFTDOWN
else FAngle
:= ANGLE_RIGHTDOWN
;
4883 if FIncCam
> -120 then DecMin(FIncCam
, 5, -120);
4886 procedure TPlayer
.SeeUp();
4890 if FDirection
= TDirection
.D_LEFT
then FAngle
:= ANGLE_LEFTUP
else FAngle
:= ANGLE_RIGHTUP
;
4892 if FIncCam
< 120 then IncMax(FIncCam
, 5, 120);
4895 procedure TPlayer
.SetAction(Action
: Byte; Force
: Boolean = False);
4903 A_ATTACK
: Prior
:= 2;
4904 A_SEEUP
: Prior
:= 1;
4905 A_SEEDOWN
: Prior
:= 1;
4906 A_ATTACKUP
: Prior
:= 2;
4907 A_ATTACKDOWN
: Prior
:= 2;
4912 if (Prior
> FActionPrior
) or Force
then
4913 if not ((Prior
= 2) and (FCurrWeap
= WEAPON_SAW
)) then
4915 FActionPrior
:= Prior
;
4916 FActionAnim
:= Action
;
4917 FActionForce
:= Force
;
4918 FActionChanged
:= True;
4921 if Action
in [A_ATTACK
, A_ATTACKUP
, A_ATTACKDOWN
] then FModel
.SetFire(True);
4924 function TPlayer
.StayOnStep(XInc
, YInc
: Integer): Boolean;
4926 Result
:= not g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+YInc
+PLAYER_RECT
.Y
+PLAYER_RECT
.Height
-1,
4927 PLAYER_RECT
.Width
, 1, PANEL_STEP
, False)
4928 and g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+YInc
+PLAYER_RECT
.Y
+PLAYER_RECT
.Height
,
4929 PLAYER_RECT
.Width
, 1, PANEL_STEP
, False);
4932 function TPlayer
.TeleportTo(X
, Y
: Integer; silent
: Boolean; dir
: Byte): Boolean;
4939 if g_CollideLevel(X
, Y
, PLAYER_RECT
.Width
, PLAYER_RECT
.Height
) then
4941 g_Sound_PlayExAt('SOUND_GAME_NOTELEPORT', FObj
.X
, FObj
.Y
);
4942 if g_Game_IsServer
and g_Game_IsNet
then
4943 MH_SEND_Sound(FObj
.X
, FObj
.Y
, 'SOUND_GAME_NOTELEPORT');
4947 FJustTeleported
:= True;
4952 if g_Frames_Get(ID
, 'FRAMES_TELEPORT') then
4954 Anim
:= TAnimation
.Create(ID
, False, 3);
4957 g_Sound_PlayExAt('SOUND_GAME_TELEPORT', FObj
.X
, FObj
.Y
);
4958 g_GFX_OnceAnim(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-32,
4959 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)-32, Anim
);
4960 if g_Game_IsServer
and g_Game_IsNet
then
4961 MH_SEND_Effect(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-32,
4962 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)-32, 1,
4966 FObj
.X
:= X
-PLAYER_RECT
.X
;
4967 FObj
.Y
:= Y
-PLAYER_RECT
.Y
;
4968 FObj
.oldX
:= FObj
.X
; // don't interpolate after respawn
4969 FObj
.oldY
:= FObj
.Y
;
4970 if FAlive
and FGhost
then
4976 if not g_Game_IsNet
then
4980 SetDirection(TDirection
.D_LEFT
);
4986 SetDirection(TDirection
.D_RIGHT
);
4992 if FDirection
= TDirection
.D_RIGHT
then
4994 SetDirection(TDirection
.D_LEFT
);
4999 SetDirection(TDirection
.D_RIGHT
);
5005 if not silent
and (Anim
<> nil) then
5007 g_GFX_OnceAnim(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-32,
5008 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)-32, Anim
);
5011 if g_Game_IsServer
and g_Game_IsNet
then
5012 MH_SEND_Effect(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-32,
5013 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)-32, 0,
5020 function nonz(a
: Single): Single;
5028 function TPlayer
.followCorpse(): Boolean;
5033 if FAlive
or FSpectator
then
5035 if (gCorpses
= nil) or (Length(gCorpses
) = 0) then
5037 for i
:= 0 to High(gCorpses
) do
5038 if gCorpses
[i
] <> nil then
5039 if gCorpses
[i
].FPlayerUID
= FUID
then
5042 FObj
.X
:= gCorpses
[i
].FObj
.X
;
5043 FObj
.Y
:= gCorpses
[i
].FObj
.Y
;
5044 FObj
.Vel
.X
:= gCorpses
[i
].FObj
.Vel
.X
;
5045 FObj
.Vel
.Y
:= gCorpses
[i
].FObj
.Vel
.Y
;
5046 FObj
.Accel
.X
:= gCorpses
[i
].FObj
.Accel
.X
;
5047 FObj
.Accel
.Y
:= gCorpses
[i
].FObj
.Accel
.Y
;
5052 procedure TPlayer
.PreUpdate();
5054 FSlopeOld
:= FObj
.slopeUpLeft
;
5055 FIncCamOld
:= FIncCam
;
5056 FObj
.oldX
:= FObj
.X
;
5057 FObj
.oldY
:= FObj
.Y
;
5060 procedure TPlayer
.Update();
5063 i
, ii
, wx
, wy
, xd
, yd
, k
: Integer;
5064 blockmon
, headwater
, dospawn
: Boolean;
5069 NetServer
:= g_Game_IsNet
and g_Game_IsServer
;
5070 AnyServer
:= g_Game_IsServer
;
5076 if FClientID
>= 0 then
5078 FPing
:= NetClients
[FClientID
].Peer
^.lastRoundTripTime
;
5079 if NetClients
[FClientID
].Peer
^.packetsSent
> 0 then
5080 FLoss
:= Round(100*NetClients
[FClientID
].Peer
^.packetsLost
/NetClients
[FClientID
].Peer
^.packetsSent
)
5089 if FAlive
and (FPunchAnim
<> nil) then
5090 FPunchAnim
.Update();
5092 if FAlive
and (gFly
or FJetpack
) then
5095 if FDirection
= TDirection
.D_LEFT
then
5100 if FAlive
and (not FGhost
) then
5102 if FKeys
[KEY_UP
].Pressed
then
5104 if FKeys
[KEY_DOWN
].Pressed
then
5108 if (not (FKeys
[KEY_UP
].Pressed
or FKeys
[KEY_DOWN
].Pressed
)) and
5111 i
:= g_basic
.Sign(FIncCam
);
5112 FIncCam
:= Abs(FIncCam
);
5113 DecMin(FIncCam
, 5, 0);
5114 FIncCam
:= FIncCam
*i
;
5117 // no need to do that each second frame, weapon queue will take care of it
5118 if FAlive
and FKeys
[KEY_NEXTWEAPON
].Pressed
and AnyServer
then NextWeapon();
5119 if FAlive
and FKeys
[KEY_PREVWEAPON
].Pressed
and AnyServer
then PrevWeapon();
5121 if gTime
mod (GAME_TICK
*2) <> 0 then
5123 if (FObj
.Vel
.X
= 0) and FAlive
then
5125 if FKeys
[KEY_LEFT
].Pressed
then
5126 Run(TDirection
.D_LEFT
);
5127 if FKeys
[KEY_RIGHT
].Pressed
then
5128 Run(TDirection
.D_RIGHT
);
5133 if not followCorpse() then
5134 g_Obj_Move(@FObj
, True, True, True);
5135 positionChanged(); // this updates spatial accelerators
5141 FActionChanged
:= False;
5145 // Let alive player do some actions
5146 if FKeys
[KEY_LEFT
].Pressed
then Run(TDirection
.D_LEFT
);
5147 if FKeys
[KEY_RIGHT
].Pressed
then Run(TDirection
.D_RIGHT
);
5148 //if FKeys[KEY_NEXTWEAPON].Pressed and AnyServer then NextWeapon();
5149 //if FKeys[KEY_PREVWEAPON].Pressed and AnyServer then PrevWeapon();
5150 if FKeys
[KEY_FIRE
].Pressed
and AnyServer
then Fire()
5156 if NetServer
then MH_SEND_PlayerStats(FUID
);
5159 if FKeys
[KEY_OPEN
].Pressed
and AnyServer
then Use();
5160 if FKeys
[KEY_JUMP
].Pressed
then Jump()
5163 if AnyServer
and FJetpack
then
5167 if NetServer
then MH_SEND_PlayerStats(FUID
);
5169 FCanJetpack
:= True;
5176 for k
:= Low(FKeys
) to KEY_CHAT
-1 do
5178 if FKeys
[k
].Pressed
then
5186 if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
5189 if (FTime
[T_RESPAWN
] <= gTime
) and
5190 gGameOn
and (not FAlive
) then
5192 if (g_Player_GetCount() > 1) then
5196 gExit
:= EXIT_RESTART
;
5201 // Dead spectator actions
5204 if FKeys
[KEY_OPEN
].Pressed
and AnyServer
then Fire();
5205 if FKeys
[KEY_FIRE
].Pressed
and AnyServer
then
5209 if (FSpectatePlayer
>= High(gPlayers
)) then
5210 FSpectatePlayer
:= -1
5214 for I
:= FSpectatePlayer
+ 1 to High(gPlayers
) do
5215 if gPlayers
[I
] <> nil then
5216 if gPlayers
[I
].alive
then
5217 if gPlayers
[I
].UID
<> FUID
then
5219 FSpectatePlayer
:= I
;
5224 if not SetSpect
then FSpectatePlayer
:= -1;
5235 if FKeys
[KEY_UP
].Pressed
or FKeys
[KEY_JUMP
].Pressed
then
5237 FYTo
:= FObj
.Y
- 32;
5238 FSpectatePlayer
:= -1;
5240 if FKeys
[KEY_DOWN
].Pressed
then
5242 FYTo
:= FObj
.Y
+ 32;
5243 FSpectatePlayer
:= -1;
5245 if FKeys
[KEY_LEFT
].Pressed
then
5247 FXTo
:= FObj
.X
- 32;
5248 FSpectatePlayer
:= -1;
5250 if FKeys
[KEY_RIGHT
].Pressed
then
5252 FXTo
:= FObj
.X
+ 32;
5253 FSpectatePlayer
:= -1;
5256 if (FXTo
< -64) then
5258 else if (FXTo
> gMapInfo
.Width
+ 32) then
5259 FXTo
:= gMapInfo
.Width
+ 32;
5260 if (FYTo
< -72) then
5262 else if (FYTo
> gMapInfo
.Height
+ 32) then
5263 FYTo
:= gMapInfo
.Height
+ 32;
5268 if not followCorpse() then
5269 g_Obj_Move(@FObj
, True, True, True);
5270 positionChanged(); // this updates spatial accelerators
5277 if (FSpectatePlayer
<= High(gPlayers
)) and (FSpectatePlayer
>= 0) then
5278 if gPlayers
[FSpectatePlayer
] <> nil then
5279 if gPlayers
[FSpectatePlayer
].alive
then
5281 FXTo
:= gPlayers
[FSpectatePlayer
].GameX
;
5282 FYTo
:= gPlayers
[FSpectatePlayer
].GameY
;
5286 blockmon
:= g_Map_CollidePanel(FObj
.X
+PLAYER_HEADRECT
.X
, FObj
.Y
+PLAYER_HEADRECT
.Y
,
5287 PLAYER_HEADRECT
.Width
, PLAYER_HEADRECT
.Height
,
5288 PANEL_BLOCKMON
, True);
5289 headwater
:= HeadInLiquid(0, 0);
5291 // Ñîïðîòèâëåíèå âîçäóõà:
5292 if (not FAlive
) or not (FKeys
[KEY_LEFT
].Pressed
or FKeys
[KEY_RIGHT
].Pressed
) then
5293 if FObj
.Vel
.X
<> 0 then
5294 FObj
.Vel
.X
:= z_dec(FObj
.Vel
.X
, 1);
5296 if (FLastHit
= HIT_TRAP
) and (FPain
> 90) then FPain
:= 90;
5297 DecMin(FPain
, 5, 0);
5298 DecMin(FPickup
, 1, 0);
5300 if FAlive
and (FObj
.Y
> Integer(gMapInfo
.Height
)+128) and AnyServer
then
5302 // Îáíóëèòü äåéñòâèÿ ïðèìî÷åê, ÷òîáû ôîí ïðîïàë
5303 FMegaRulez
[MR_SUIT
] := 0;
5304 FMegaRulez
[MR_INVUL
] := 0;
5305 FMegaRulez
[MR_INVIS
] := 0;
5306 Kill(K_FALLKILL
, 0, HIT_FALL
);
5313 if FCurrWeap
= WEAPON_SAW
then
5314 if not (FSawSound
.IsPlaying() or FSawSoundHit
.IsPlaying() or
5315 FSawSoundSelect
.IsPlaying()) then
5316 FSawSoundIdle
.PlayAt(FObj
.X
, FObj
.Y
);
5319 if (not FJetSoundFly
.IsPlaying()) and (not FJetSoundOn
.IsPlaying()) and
5320 (not FJetSoundOff
.IsPlaying()) then
5322 FJetSoundFly
.SetPosition(0);
5323 FJetSoundFly
.PlayAt(FObj
.X
, FObj
.Y
);
5326 for b
:= WP_FIRST
to WP_LAST
do
5327 if FReloading
[b
] > 0 then
5333 if FShellTimer
> -1 then
5334 if FShellTimer
= 0 then
5336 if FShellType
= SHELL_SHELL
then
5337 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
5338 GameVelX
, GameVelY
-2, SHELL_SHELL
)
5339 else if FShellType
= SHELL_DBLSHELL
then
5341 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
5342 GameVelX
+1, GameVelY
-2, SHELL_SHELL
);
5343 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
5344 GameVelX
-1, GameVelY
-2, SHELL_SHELL
);
5347 end else Dec(FShellTimer
);
5349 if (FBFGFireCounter
> -1) then
5350 if FBFGFireCounter
= 0 then
5354 wx
:= FObj
.X
+WEAPONPOINT
[FDirection
].X
;
5355 wy
:= FObj
.Y
+WEAPONPOINT
[FDirection
].Y
;
5356 xd
:= wx
+IfThen(FDirection
= TDirection
.D_LEFT
, -30, 30);
5357 yd
:= wy
+firediry();
5358 g_Weapon_bfgshot(wx
, wy
, xd
, yd
, FUID
);
5359 if NetServer
then MH_SEND_PlayerFire(FUID
, WEAPON_BFG
, wx
, wy
, xd
, yd
);
5360 if (FAngle
= 0) or (FAngle
= 180) then SetAction(A_ATTACK
)
5361 else if (FAngle
= ANGLE_LEFTDOWN
) or (FAngle
= ANGLE_RIGHTDOWN
) then SetAction(A_ATTACKDOWN
)
5362 else if (FAngle
= ANGLE_LEFTUP
) or (FAngle
= ANGLE_RIGHTUP
) then SetAction(A_ATTACKUP
);
5365 FReloading
[WEAPON_BFG
] := WEAPON_RELOAD
[WEAPON_BFG
];
5366 FBFGFireCounter
:= -1;
5369 FBFGFireCounter
:= 0
5371 Dec(FBFGFireCounter
);
5373 if (FMegaRulez
[MR_SUIT
] < gTime
) and AnyServer
then
5375 b
:= g_GetAcidHit(FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+PLAYER_RECT
.Y
, PLAYER_RECT
.Width
, PLAYER_RECT
.Height
);
5377 if (b
> 0) and (gTime
mod (15*GAME_TICK
) = 0) then Damage(b
, 0, 0, 0, HIT_ACID
);
5380 if (headwater
or blockmon
) then
5386 if AnyServer
then Damage(10, 0, 0, 0, HIT_WATER
);
5389 else if (FAir
mod 31 = 0) and not blockmon
then
5391 g_GFX_Bubbles(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2), FObj
.Y
+PLAYER_RECT
.Y
-4, 5+Random(6), 8, 4);
5392 if Random(2) = 0 then
5393 g_Sound_PlayExAt('SOUND_GAME_BUBBLE1', FObj
.X
, FObj
.Y
)
5395 g_Sound_PlayExAt('SOUND_GAME_BUBBLE2', FObj
.X
, FObj
.Y
);
5397 end else if FAir
< AIR_DEF
then
5400 if FFireTime
> 0 then
5402 if BodyInLiquid(0, 0) then
5407 else if FMegaRulez
[MR_SUIT
] >= gTime
then
5409 if FMegaRulez
[MR_SUIT
] = gTime
then
5416 if FFirePainTime
<= 0 then
5418 if g_Game_IsServer
then
5419 Damage(2, FFireAttacker
, 0, 0, HIT_FLAME
);
5420 FFirePainTime
:= 12 - FFireTime
div 12;
5422 FFirePainTime
:= FFirePainTime
- 1;
5423 FFireTime
:= FFireTime
- 1;
5424 if ((FFireTime
mod 33) = 0) and (FMegaRulez
[MR_INVUL
] < gTime
) then
5425 FModel
.PlaySound(MODELSOUND_PAIN
, 1, FObj
.X
, FObj
.Y
);
5426 if (FFireTime
= 0) and g_Game_IsNet
and g_Game_IsServer
then
5427 MH_SEND_PlayerStats(FUID
);
5431 if FDamageBuffer
> 0 then
5433 if FDamageBuffer
>= 9 then
5437 if FDamageBuffer
< 30 then i
:= 9
5438 else if FDamageBuffer
< 100 then i
:= 18
5442 ii
:= Round(FDamageBuffer
*FHealth
/ nonz(FArmor
*(3/4)+FHealth
));
5443 FArmor
:= FArmor
-(FDamageBuffer
-ii
);
5444 FHealth
:= FHealth
-ii
;
5447 FHealth
:= FHealth
+FArmor
;
5452 if FHealth
<= 0 then
5453 if FHealth
> -30 then Kill(K_SIMPLEKILL
, FLastSpawnerUID
, FLastHit
)
5454 else if FHealth
> -50 then Kill(K_HARDKILL
, FLastSpawnerUID
, FLastHit
)
5455 else Kill(K_EXTRAHARDKILL
, FLastSpawnerUID
, FLastHit
);
5457 if FAlive
and ((FLastHit
<> HIT_FLAME
) or (FFireTime
<= 0)) then
5459 if FDamageBuffer
<= 20 then FModel
.PlaySound(MODELSOUND_PAIN
, 1, FObj
.X
, FObj
.Y
)
5460 else if FDamageBuffer
<= 55 then FModel
.PlaySound(MODELSOUND_PAIN
, 2, FObj
.X
, FObj
.Y
)
5461 else if FDamageBuffer
<= 120 then FModel
.PlaySound(MODELSOUND_PAIN
, 3, FObj
.X
, FObj
.Y
)
5462 else FModel
.PlaySound(MODELSOUND_PAIN
, 4, FObj
.X
, FObj
.Y
);
5469 end; // if FAlive then ...
5471 if (FActionAnim
= A_PAIN
) and (FModel
.Animation
<> A_PAIN
) then
5473 FModel
.ChangeAnimation(FActionAnim
, FActionForce
);
5474 FModel
.GetCurrentAnimation
.MinLength
:= i
;
5475 FModel
.GetCurrentAnimationMask
.MinLength
:= i
;
5476 end else FModel
.ChangeAnimation(FActionAnim
, FActionForce
and (FModel
.Animation
<> A_STAND
));
5478 if (FModel
.GetCurrentAnimation
.Played
or ((not FActionChanged
) and (FModel
.Animation
= A_WALK
)))
5479 then SetAction(A_STAND
, True);
5481 if not ((FModel
.Animation
= A_WALK
) and (Abs(FObj
.Vel
.X
) < 4) and not FModel
.Fire
) then FModel
.Update
;
5483 for b
:= Low(FKeys
) to High(FKeys
) do
5484 if FKeys
[b
].Time
= 0 then FKeys
[b
].Pressed
:= False else Dec(FKeys
[b
].Time
);
5488 procedure TPlayer
.getMapBox (out x
, y
, w
, h
: Integer); inline;
5490 x
:= FObj
.X
+PLAYER_RECT
.X
;
5491 y
:= FObj
.Y
+PLAYER_RECT
.Y
;
5492 w
:= PLAYER_RECT
.Width
;
5493 h
:= PLAYER_RECT
.Height
;
5497 procedure TPlayer
.moveBy (dx
, dy
: Integer); inline;
5499 if (dx
<> 0) or (dy
<> 0) then
5508 function TPlayer
.Collide(X
, Y
: Integer; Width
, Height
: Word): Boolean;
5510 Result
:= g_Collide(FObj
.X
+PLAYER_RECT
.X
,
5511 FObj
.Y
+PLAYER_RECT
.Y
,
5518 function TPlayer
.Collide(Panel
: TPanel
): Boolean;
5520 Result
:= g_Collide(FObj
.X
+PLAYER_RECT
.X
,
5521 FObj
.Y
+PLAYER_RECT
.Y
,
5525 Panel
.Width
, Panel
.Height
);
5528 function TPlayer
.Collide(X
, Y
: Integer): Boolean;
5530 X
:= X
-FObj
.X
-PLAYER_RECT
.X
;
5531 Y
:= Y
-FObj
.Y
-PLAYER_RECT
.Y
;
5532 Result
:= (x
>= 0) and (x
<= PLAYER_RECT
.Width
) and
5533 (y
>= 0) and (y
<= PLAYER_RECT
.Height
);
5536 function g_Player_ValidName(Name
: string): Boolean;
5542 if gPlayers
= nil then Exit
;
5544 for a
:= 0 to High(gPlayers
) do
5545 if gPlayers
[a
] <> nil then
5546 if LowerCase(Name
) = LowerCase(gPlayers
[a
].FName
) then
5553 procedure TPlayer
.SetDirection(Direction
: TDirection
);
5557 d
:= FModel
.Direction
;
5559 FModel
.Direction
:= Direction
;
5560 if d
<> Direction
then FModel
.ChangeAnimation(FModel
.Animation
, True);
5562 FDirection
:= Direction
;
5565 function TPlayer
.GetKeys(): Byte;
5569 if R_KEY_RED
in FRulez
then Result
:= KEY_RED
;
5570 if R_KEY_GREEN
in FRulez
then Result
:= Result
or KEY_GREEN
;
5571 if R_KEY_BLUE
in FRulez
then Result
:= Result
or KEY_BLUE
;
5573 if FTeam
= TEAM_RED
then Result
:= Result
or KEY_REDTEAM
;
5574 if FTeam
= TEAM_BLUE
then Result
:= Result
or KEY_BLUETEAM
;
5577 procedure TPlayer
.Use();
5581 if FTime
[T_USE
] > gTime
then Exit
;
5583 g_Triggers_PressR(FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+PLAYER_RECT
.Y
, PLAYER_RECT
.Width
,
5584 PLAYER_RECT
.Height
, FUID
, ACTIVATE_PLAYERPRESS
);
5586 for a
:= 0 to High(gPlayers
) do
5587 if (gPlayers
[a
] <> nil) and (gPlayers
[a
] <> Self
) and
5588 gPlayers
[a
].alive
and SameTeam(FUID
, gPlayers
[a
].FUID
) and
5589 g_Obj_Collide(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
,
5590 FObj
.Rect
.Width
, FObj
.Rect
.Height
, @gPlayers
[a
].FObj
) then
5592 gPlayers
[a
].Touch();
5593 if g_Game_IsNet
and g_Game_IsServer
then
5594 MH_SEND_GameEvent(NET_EV_PLAYER_TOUCH
, gPlayers
[a
].FUID
);
5597 FTime
[T_USE
] := gTime
+120;
5600 procedure TPlayer
.NetFire(Wpn
: Byte; X
, Y
, AX
, AY
: Integer; WID
: Integer = -1);
5604 WX
, WY
, XD
, YD
: Integer;
5616 if R_BERSERK
in FRulez
then
5618 //g_Weapon_punch(FObj.X+FObj.Rect.X, FObj.Y+FObj.Rect.Y, 75, FUID);
5619 locobj
.X
:= FObj
.X
+FObj
.Rect
.X
;
5620 locobj
.Y
:= FObj
.Y
+FObj
.Rect
.Y
;
5623 locobj
.rect
.Width
:= 39;
5624 locobj
.rect
.Height
:= 52;
5625 locobj
.Vel
.X
:= (xd
-wx
) div 2;
5626 locobj
.Vel
.Y
:= (yd
-wy
) div 2;
5627 locobj
.Accel
.X
:= xd
-wx
;
5628 locobj
.Accel
.y
:= yd
-wy
;
5630 if g_Weapon_Hit(@locobj
, 50, FUID
, HIT_SOME
) <> 0 then
5631 g_Sound_PlayExAt('SOUND_WEAPON_HITBERSERK', FObj
.X
, FObj
.Y
)
5633 g_Sound_PlayExAt('SOUND_WEAPON_MISSBERSERK', FObj
.X
, FObj
.Y
);
5637 FPain
:= min(FPain
+ 25, 50);
5639 g_Weapon_punch(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
, 3, FUID
);
5644 if g_Weapon_chainsaw(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
,
5645 IfThen(gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
], 9, 3), FUID
) <> 0 then
5647 FSawSoundSelect
.Stop();
5649 FSawSoundHit
.PlayAt(FObj
.X
, FObj
.Y
);
5651 else if not FSawSoundHit
.IsPlaying() then
5653 FSawSoundSelect
.Stop();
5654 FSawSound
.PlayAt(FObj
.X
, FObj
.Y
);
5661 g_Sound_PlayExAt('SOUND_WEAPON_FIREPISTOL', GameX
, Gamey
);
5662 FFireAngle
:= FAngle
;
5664 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
5665 GameVelX
, GameVelY
-2, SHELL_BULLET
);
5670 g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN', Gamex
, Gamey
);
5671 FFireAngle
:= FAngle
;
5674 FShellType
:= SHELL_SHELL
;
5679 g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN2', Gamex
, Gamey
);
5680 FFireAngle
:= FAngle
;
5683 FShellType
:= SHELL_DBLSHELL
;
5688 g_Sound_PlayExAt('SOUND_WEAPON_FIRECGUN', Gamex
, Gamey
);
5689 FFireAngle
:= FAngle
;
5691 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
5692 GameVelX
, GameVelY
-2, SHELL_BULLET
);
5695 WEAPON_ROCKETLAUNCHER
:
5697 g_Weapon_Rocket(wx
, wy
, xd
, yd
, FUID
, WID
);
5698 FFireAngle
:= FAngle
;
5704 g_Weapon_Plasma(wx
, wy
, xd
, yd
, FUID
, WID
);
5705 FFireAngle
:= FAngle
;
5711 g_Weapon_BFGShot(wx
, wy
, xd
, yd
, FUID
, WID
);
5712 FFireAngle
:= FAngle
;
5716 WEAPON_SUPERPULEMET
:
5718 g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN', Gamex
, Gamey
);
5719 FFireAngle
:= FAngle
;
5721 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
5722 GameVelX
, GameVelY
-2, SHELL_SHELL
);
5725 WEAPON_FLAMETHROWER
:
5727 g_Weapon_flame(wx
, wy
, xd
, yd
, FUID
, WID
);
5729 FFireAngle
:= FAngle
;
5736 if (FAngle
= 0) or (FAngle
= 180) then SetAction(A_ATTACK
)
5737 else if (FAngle
= ANGLE_LEFTDOWN
) or (FAngle
= ANGLE_RIGHTDOWN
) then SetAction(A_ATTACKDOWN
)
5738 else if (FAngle
= ANGLE_LEFTUP
) or (FAngle
= ANGLE_RIGHTUP
) then SetAction(A_ATTACKUP
);
5741 procedure TPlayer
.DoLerp(Level
: Integer = 2);
5743 if FObj
.X
<> FXTo
then FObj
.X
:= Lerp(FObj
.X
, FXTo
, Level
);
5744 if FObj
.Y
<> FYTo
then FObj
.Y
:= Lerp(FObj
.Y
, FYTo
, Level
);
5747 procedure TPlayer
.SetLerp(XTo
, YTo
: Integer);
5751 if NetInterpLevel
< 1 then
5761 AX
:= Abs(FXTo
- FObj
.X
);
5762 AY
:= Abs(FYTo
- FObj
.Y
);
5763 if (AX
> 32) or (AX
<= NetInterpLevel
) then
5765 if (AY
> 32) or (AY
<= NetInterpLevel
) then
5770 function TPlayer
.FullInLift(XInc
, YInc
: Integer): Integer;
5772 if g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
,
5773 PLAYER_RECT
.Width
, PLAYER_RECT
.Height
-8,
5774 PANEL_LIFTUP
, False) then Result
:= -1
5776 if g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
,
5777 PLAYER_RECT
.Width
, PLAYER_RECT
.Height
-8,
5778 PANEL_LIFTDOWN
, False) then Result
:= 1
5782 function TPlayer
.GetFlag(Flag
: Byte): Boolean;
5789 if Flag
= FLAG_NONE
then
5792 if not g_Game_IsServer
then Exit
;
5794 // Ïðèíåñ ÷óæîé ôëàã íà ñâîþ áàçó:
5795 if (Flag
= FTeam
) and
5796 (gFlags
[Flag
].State
= FLAG_STATE_NORMAL
) and
5797 (FFlag
<> FLAG_NONE
) then
5799 if FFlag
= FLAG_RED
then
5800 s
:= _lc
[I_PLAYER_FLAG_RED
]
5802 s
:= _lc
[I_PLAYER_FLAG_BLUE
];
5804 evtype
:= FLAG_STATE_SCORED
;
5806 ts
:= Format('%.4d', [gFlags
[FFlag
].CaptureTime
]);
5807 Insert('.', ts
, Length(ts
) + 1 - 3);
5808 g_Console_Add(Format(_lc
[I_PLAYER_FLAG_CAPTURE
], [FName
, s
, ts
]), True);
5810 g_Map_ResetFlag(FFlag
);
5811 g_Game_Message(Format(_lc
[I_MESSAGE_FLAG_CAPTURE
], [AnsiUpperCase(s
)]), 144);
5813 if ((Self
= gPlayer1
) or (Self
= gPlayer2
)
5814 or ((gPlayer1
<> nil) and (gPlayer1
.Team
= FTeam
))
5815 or ((gPlayer2
<> nil) and (gPlayer2
.Team
= FTeam
))) then
5820 if not sound_cap_flag
[a
].IsPlaying() then
5821 sound_cap_flag
[a
].Play();
5823 gTeamStat
[FTeam
].Goals
:= gTeamStat
[FTeam
].Goals
+ 1;
5826 if g_Game_IsNet
then
5828 MH_SEND_FlagEvent(evtype
, FFlag
, FUID
, False);
5832 gFlags
[FFlag
].CaptureTime
:= 0;
5837 // Ïîäîáðàë ñâîé ôëàã - âåðíóë åãî íà áàçó:
5838 if (Flag
= FTeam
) and
5839 (gFlags
[Flag
].State
= FLAG_STATE_DROPPED
) then
5841 if Flag
= FLAG_RED
then
5842 s
:= _lc
[I_PLAYER_FLAG_RED
]
5844 s
:= _lc
[I_PLAYER_FLAG_BLUE
];
5846 evtype
:= FLAG_STATE_RETURNED
;
5847 gFlags
[Flag
].CaptureTime
:= 0;
5849 g_Console_Add(Format(_lc
[I_PLAYER_FLAG_RETURN
], [FName
, s
]), True);
5851 g_Map_ResetFlag(Flag
);
5852 g_Game_Message(Format(_lc
[I_MESSAGE_FLAG_RETURN
], [AnsiUpperCase(s
)]), 144);
5854 if ((Self
= gPlayer1
) or (Self
= gPlayer2
)
5855 or ((gPlayer1
<> nil) and (gPlayer1
.Team
= FTeam
))
5856 or ((gPlayer2
<> nil) and (gPlayer2
.Team
= FTeam
))) then
5861 if not sound_ret_flag
[a
].IsPlaying() then
5862 sound_ret_flag
[a
].Play();
5865 if g_Game_IsNet
then
5867 MH_SEND_FlagEvent(evtype
, Flag
, FUID
, False);
5873 // Ïîäîáðàë ÷óæîé ôëàã:
5874 if (Flag
<> FTeam
) and (FTime
[T_FLAGCAP
] <= gTime
) then
5878 if Flag
= FLAG_RED
then
5879 s
:= _lc
[I_PLAYER_FLAG_RED
]
5881 s
:= _lc
[I_PLAYER_FLAG_BLUE
];
5883 evtype
:= FLAG_STATE_CAPTURED
;
5885 g_Console_Add(Format(_lc
[I_PLAYER_FLAG_GET
], [FName
, s
]), True);
5887 g_Game_Message(Format(_lc
[I_MESSAGE_FLAG_GET
], [AnsiUpperCase(s
)]), 144);
5889 gFlags
[Flag
].State
:= FLAG_STATE_CAPTURED
;
5891 if ((Self
= gPlayer1
) or (Self
= gPlayer2
)
5892 or ((gPlayer1
<> nil) and (gPlayer1
.Team
= FTeam
))
5893 or ((gPlayer2
<> nil) and (gPlayer2
.Team
= FTeam
))) then
5898 if not sound_get_flag
[a
].IsPlaying() then
5899 sound_get_flag
[a
].Play();
5902 if g_Game_IsNet
then
5904 MH_SEND_FlagEvent(evtype
, Flag
, FUID
, False);
5910 procedure TPlayer
.SetFlag(Flag
: Byte);
5913 if FModel
<> nil then
5914 FModel
.SetFlag(FFlag
);
5917 function TPlayer
.DropFlag(Silent
: Boolean = True): Boolean;
5923 if (not g_Game_IsServer
) or (FFlag
= FLAG_NONE
) then
5925 FTime
[T_FLAGCAP
] := gTime
+ 2000;
5926 with gFlags
[FFlag
] do
5930 Direction
:= FDirection
;
5931 State
:= FLAG_STATE_DROPPED
;
5933 g_Obj_Push(@Obj
, (FObj
.Vel
.X
div 2)-2+Random(5),
5934 (FObj
.Vel
.Y
div 2)-2+Random(5));
5935 positionChanged(); // this updates spatial accelerators
5937 if FFlag
= FLAG_RED
then
5938 s
:= _lc
[I_PLAYER_FLAG_RED
]
5940 s
:= _lc
[I_PLAYER_FLAG_BLUE
];
5942 g_Console_Add(Format(_lc
[I_PLAYER_FLAG_DROP
], [FName
, s
]), True);
5943 g_Game_Message(Format(_lc
[I_MESSAGE_FLAG_DROP
], [AnsiUpperCase(s
)]), 144);
5945 if ((Self
= gPlayer1
) or (Self
= gPlayer2
)
5946 or ((gPlayer1
<> nil) and (gPlayer1
.Team
= FTeam
))
5947 or ((gPlayer2
<> nil) and (gPlayer2
.Team
= FTeam
))) then
5952 if (not Silent
) and (not sound_lost_flag
[a
].IsPlaying()) then
5953 sound_lost_flag
[a
].Play();
5955 if g_Game_IsNet
then
5956 MH_SEND_FlagEvent(FLAG_STATE_DROPPED
, Flag
, FUID
, False);
5962 procedure TPlayer
.GetSecret();
5964 if (self
= gPlayer1
) or (self
= gPlayer2
) then
5966 g_Console_Add(Format(_lc
[I_PLAYER_SECRET
], [FName
]), True);
5967 g_Sound_PlayEx('SOUND_GAME_SECRET');
5972 procedure TPlayer
.PressKey(Key
: Byte; Time
: Word = 1);
5974 Assert(Key
<= High(FKeys
));
5976 FKeys
[Key
].Pressed
:= True;
5977 FKeys
[Key
].Time
:= Time
;
5980 function TPlayer
.IsKeyPressed(K
: Byte): Boolean;
5982 Result
:= FKeys
[K
].Pressed
;
5985 procedure TPlayer
.ReleaseKeys();
5989 for a
:= Low(FKeys
) to High(FKeys
) do
5991 FKeys
[a
].Pressed
:= False;
5996 procedure TPlayer
.OnDamage(Angle
: SmallInt);
6000 function TPlayer
.firediry(): Integer;
6002 if FKeys
[KEY_UP
].Pressed
then Result
:= -42
6003 else if FKeys
[KEY_DOWN
].Pressed
then Result
:= 19
6007 procedure TPlayer
.RememberState();
6010 SavedState
: TPlayerSavedState
;
6012 SavedState
.Health
:= FHealth
;
6013 SavedState
.Armor
:= FArmor
;
6014 SavedState
.Air
:= FAir
;
6015 SavedState
.JetFuel
:= FJetFuel
;
6016 SavedState
.CurrWeap
:= FCurrWeap
;
6017 SavedState
.NextWeap
:= FNextWeap
;
6018 SavedState
.NextWeapDelay
:= FNextWeapDelay
;
6019 for i
:= Low(FWeapon
) to High(FWeapon
) do
6020 SavedState
.Weapon
[i
] := FWeapon
[i
];
6021 for i
:= Low(FAmmo
) to High(FAmmo
) do
6022 SavedState
.Ammo
[i
] := FAmmo
[i
];
6023 for i
:= Low(FMaxAmmo
) to High(FMaxAmmo
) do
6024 SavedState
.MaxAmmo
[i
] := FMaxAmmo
[i
];
6025 SavedState
.Rulez
:= FRulez
- [R_KEY_RED
, R_KEY_GREEN
, R_KEY_BLUE
];
6027 FSavedStateNum
:= -1;
6028 for i
:= Low(SavedStates
) to High(SavedStates
) do
6029 if not SavedStates
[i
].Used
then
6031 FSavedStateNum
:= i
;
6034 if FSavedStateNum
< 0 then
6036 SetLength(SavedStates
, Length(SavedStates
) + 1);
6037 FSavedStateNum
:= High(SavedStates
);
6040 SavedState
.Used
:= True;
6041 SavedStates
[FSavedStateNum
] := SavedState
;
6044 procedure TPlayer
.RecallState();
6047 SavedState
: TPlayerSavedState
;
6049 if(FSavedStateNum
< 0) or (FSavedStateNum
> High(SavedStates
)) then
6052 SavedState
:= SavedStates
[FSavedStateNum
];
6053 SavedStates
[FSavedStateNum
].Used
:= False;
6054 FSavedStateNum
:= -1;
6056 FHealth
:= SavedState
.Health
;
6057 FArmor
:= SavedState
.Armor
;
6058 FAir
:= SavedState
.Air
;
6059 FJetFuel
:= SavedState
.JetFuel
;
6060 FCurrWeap
:= SavedState
.CurrWeap
;
6061 FNextWeap
:= SavedState
.NextWeap
;
6062 FNextWeapDelay
:= SavedState
.NextWeapDelay
;
6063 for i
:= Low(FWeapon
) to High(FWeapon
) do
6064 FWeapon
[i
] := SavedState
.Weapon
[i
];
6065 for i
:= Low(FAmmo
) to High(FAmmo
) do
6066 FAmmo
[i
] := SavedState
.Ammo
[i
];
6067 for i
:= Low(FMaxAmmo
) to High(FMaxAmmo
) do
6068 FMaxAmmo
[i
] := SavedState
.MaxAmmo
[i
];
6069 FRulez
:= SavedState
.Rulez
;
6071 if gGameSettings
.GameType
= GT_SERVER
then
6072 MH_SEND_PlayerStats(FUID
);
6075 procedure TPlayer
.SaveState (st
: TStream
);
6081 utils
.writeSign(st
, 'PLYR');
6082 utils
.writeInt(st
, Byte(PLR_SAVE_VERSION
)); // version
6084 utils
.writeBool(st
, FIamBot
);
6086 utils
.writeInt(st
, Word(FUID
));
6088 utils
.writeStr(st
, FName
);
6090 utils
.writeInt(st
, Byte(FTeam
));
6092 utils
.writeBool(st
, FAlive
);
6093 // Èçðàñõîäîâàë ëè âñå æèçíè
6094 utils
.writeBool(st
, FNoRespawn
);
6096 if FDirection
= TDirection
.D_LEFT
then b
:= 1 else b
:= 2; // D_RIGHT
6097 utils
.writeInt(st
, Byte(b
));
6099 utils
.writeInt(st
, LongInt(FHealth
));
6100 // Êîýôôèöèåíò èíâàëèäíîñòè
6101 utils
.writeInt(st
, LongInt(FHandicap
));
6103 utils
.writeInt(st
, Byte(FLives
));
6105 utils
.writeInt(st
, LongInt(FArmor
));
6107 utils
.writeInt(st
, LongInt(FAir
));
6109 utils
.writeInt(st
, LongInt(FJetFuel
));
6111 utils
.writeInt(st
, LongInt(FPain
));
6113 utils
.writeInt(st
, LongInt(FKills
));
6115 utils
.writeInt(st
, LongInt(FMonsterKills
));
6117 utils
.writeInt(st
, LongInt(FFrags
));
6119 utils
.writeInt(st
, Byte(FFragCombo
));
6120 // Âðåìÿ ïîñëåäíåãî ôðàãà
6121 utils
.writeInt(st
, LongWord(FLastFrag
));
6123 utils
.writeInt(st
, LongInt(FDeath
));
6125 utils
.writeInt(st
, Byte(FFlag
));
6127 utils
.writeInt(st
, LongInt(FSecrets
));
6129 utils
.writeInt(st
, Byte(FCurrWeap
));
6131 utils
.writeInt(st
, Word(FNextWeap
));
6133 utils
.writeInt(st
, Byte(FNextWeapDelay
));
6134 // Âðåìÿ çàðÿäêè BFG
6135 utils
.writeInt(st
, SmallInt(FBFGFireCounter
));
6137 utils
.writeInt(st
, LongInt(FDamageBuffer
));
6138 // Ïîñëåäíèé óäàðèâøèé
6139 utils
.writeInt(st
, Word(FLastSpawnerUID
));
6140 // Òèï ïîñëåäíåãî ïîëó÷åííîãî óðîíà
6141 utils
.writeInt(st
, Byte(FLastHit
));
6143 Obj_SaveState(st
, @FObj
);
6144 // Òåêóùåå êîëè÷åñòâî ïàòðîíîâ
6145 for i
:= A_BULLETS
to A_HIGH
do utils
.writeInt(st
, Word(FAmmo
[i
]));
6146 // Ìàêñèìàëüíîå êîëè÷åñòâî ïàòðîíîâ
6147 for i
:= A_BULLETS
to A_HIGH
do utils
.writeInt(st
, Word(FMaxAmmo
[i
]));
6149 for i
:= WP_FIRST
to WP_LAST
do utils
.writeBool(st
, FWeapon
[i
]);
6150 // Âðåìÿ ïåðåçàðÿäêè îðóæèÿ
6151 for i
:= WP_FIRST
to WP_LAST
do utils
.writeInt(st
, Word(FReloading
[i
]));
6153 utils
.writeBool(st
, (R_ITEM_BACKPACK
in FRulez
));
6154 // Íàëè÷èå êðàñíîãî êëþ÷à
6155 utils
.writeBool(st
, (R_KEY_RED
in FRulez
));
6156 // Íàëè÷èå çåëåíîãî êëþ÷à
6157 utils
.writeBool(st
, (R_KEY_GREEN
in FRulez
));
6158 // Íàëè÷èå ñèíåãî êëþ÷à
6159 utils
.writeBool(st
, (R_KEY_BLUE
in FRulez
));
6161 utils
.writeBool(st
, (R_BERSERK
in FRulez
));
6162 // Âðåìÿ äåéñòâèÿ ñïåöèàëüíûõ ïðåäìåòîâ
6163 for i
:= MR_SUIT
to MR_MAX
do utils
.writeInt(st
, LongWord(FMegaRulez
[i
]));
6164 // Âðåìÿ äî ïîâòîðíîãî ðåñïàóíà, ñìåíû îðóæèÿ, èñîëüçîâàíèÿ, çàõâàòà ôëàãà
6165 for i
:= T_RESPAWN
to T_FLAGCAP
do utils
.writeInt(st
, LongWord(FTime
[i
]));
6167 utils
.writeStr(st
, FModel
.Name
);
6169 utils
.writeInt(st
, Byte(FColor
.R
));
6170 utils
.writeInt(st
, Byte(FColor
.G
));
6171 utils
.writeInt(st
, Byte(FColor
.B
));
6175 procedure TPlayer
.LoadState (st
: TStream
);
6184 if not utils
.checkSign(st
, 'PLYR') then raise XStreamError
.Create('invalid player signature');
6185 if (utils
.readByte(st
) <> PLR_SAVE_VERSION
) then raise XStreamError
.Create('invalid player version');
6187 FIamBot
:= utils
.readBool(st
);
6189 FUID
:= utils
.readWord(st
);
6191 str
:= utils
.readStr(st
);
6192 if (self
<> gPlayer1
) and (self
<> gPlayer2
) then FName
:= str
;
6194 FTeam
:= utils
.readByte(st
);
6196 FAlive
:= utils
.readBool(st
);
6197 // Èçðàñõîäîâàë ëè âñå æèçíè
6198 FNoRespawn
:= utils
.readBool(st
);
6200 b
:= utils
.readByte(st
);
6201 if b
= 1 then FDirection
:= TDirection
.D_LEFT
else FDirection
:= TDirection
.D_RIGHT
; // b = 2
6203 FHealth
:= utils
.readLongInt(st
);
6204 // Êîýôôèöèåíò èíâàëèäíîñòè
6205 FHandicap
:= utils
.readLongInt(st
);
6207 FLives
:= utils
.readByte(st
);
6209 FArmor
:= utils
.readLongInt(st
);
6211 FAir
:= utils
.readLongInt(st
);
6213 FJetFuel
:= utils
.readLongInt(st
);
6215 FPain
:= utils
.readLongInt(st
);
6217 FKills
:= utils
.readLongInt(st
);
6219 FMonsterKills
:= utils
.readLongInt(st
);
6221 FFrags
:= utils
.readLongInt(st
);
6223 FFragCombo
:= utils
.readByte(st
);
6224 // Âðåìÿ ïîñëåäíåãî ôðàãà
6225 FLastFrag
:= utils
.readLongWord(st
);
6227 FDeath
:= utils
.readLongInt(st
);
6229 FFlag
:= utils
.readByte(st
);
6231 FSecrets
:= utils
.readLongInt(st
);
6233 FCurrWeap
:= utils
.readByte(st
);
6235 FNextWeap
:= utils
.readWord(st
);
6237 FNextWeapDelay
:= utils
.readByte(st
);
6238 // Âðåìÿ çàðÿäêè BFG
6239 FBFGFireCounter
:= utils
.readSmallInt(st
);
6241 FDamageBuffer
:= utils
.readLongInt(st
);
6242 // Ïîñëåäíèé óäàðèâøèé
6243 FLastSpawnerUID
:= utils
.readWord(st
);
6244 // Òèï ïîñëåäíåãî ïîëó÷åííîãî óðîíà
6245 FLastHit
:= utils
.readByte(st
);
6247 Obj_LoadState(@FObj
, st
);
6248 // Òåêóùåå êîëè÷åñòâî ïàòðîíîâ
6249 for i
:= A_BULLETS
to A_HIGH
do FAmmo
[i
] := utils
.readWord(st
);
6250 // Ìàêñèìàëüíîå êîëè÷åñòâî ïàòðîíîâ
6251 for i
:= A_BULLETS
to A_HIGH
do FMaxAmmo
[i
] := utils
.readWord(st
);
6253 for i
:= WP_FIRST
to WP_LAST
do FWeapon
[i
] := utils
.readBool(st
);
6254 // Âðåìÿ ïåðåçàðÿäêè îðóæèÿ
6255 for i
:= WP_FIRST
to WP_LAST
do FReloading
[i
] := utils
.readWord(st
);
6257 if utils
.readBool(st
) then Include(FRulez
, R_ITEM_BACKPACK
);
6258 // Íàëè÷èå êðàñíîãî êëþ÷à
6259 if utils
.readBool(st
) then Include(FRulez
, R_KEY_RED
);
6260 // Íàëè÷èå çåëåíîãî êëþ÷à
6261 if utils
.readBool(st
) then Include(FRulez
, R_KEY_GREEN
);
6262 // Íàëè÷èå ñèíåãî êëþ÷à
6263 if utils
.readBool(st
) then Include(FRulez
, R_KEY_BLUE
);
6265 if utils
.readBool(st
) then Include(FRulez
, R_BERSERK
);
6266 // Âðåìÿ äåéñòâèÿ ñïåöèàëüíûõ ïðåäìåòîâ
6267 for i
:= MR_SUIT
to MR_MAX
do FMegaRulez
[i
] := utils
.readLongWord(st
);
6268 // Âðåìÿ äî ïîâòîðíîãî ðåñïàóíà, ñìåíû îðóæèÿ, èñîëüçîâàíèÿ, çàõâàòà ôëàãà
6269 for i
:= T_RESPAWN
to T_FLAGCAP
do FTime
[i
] := utils
.readLongWord(st
);
6271 str
:= utils
.readStr(st
);
6273 FColor
.R
:= utils
.readByte(st
);
6274 FColor
.G
:= utils
.readByte(st
);
6275 FColor
.B
:= utils
.readByte(st
);
6276 if (self
= gPlayer1
) then
6278 str
:= gPlayer1Settings
.Model
;
6279 FColor
:= gPlayer1Settings
.Color
;
6281 else if (self
= gPlayer2
) then
6283 str
:= gPlayer2Settings
.Model
;
6284 FColor
:= gPlayer2Settings
.Color
;
6286 // Îáíîâëÿåì ìîäåëü èãðîêà
6288 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
6289 FModel
.Color
:= TEAMCOLOR
[FTeam
]
6291 FModel
.Color
:= FColor
;
6295 procedure TPlayer
.AllRulez(Health
: Boolean);
6301 FHealth
:= PLAYER_HP_LIMIT
;
6302 FArmor
:= PLAYER_AP_LIMIT
;
6306 for a
:= WP_FIRST
to WP_LAST
do FWeapon
[a
] := True;
6307 for a
:= A_BULLETS
to A_HIGH
do FAmmo
[a
] := 30000;
6308 FRulez
:= FRulez
+[R_KEY_RED
, R_KEY_GREEN
, R_KEY_BLUE
];
6311 procedure TPlayer
.RestoreHealthArmor();
6313 FHealth
:= PLAYER_HP_LIMIT
;
6314 FArmor
:= PLAYER_AP_LIMIT
;
6317 procedure TPlayer
.FragCombo();
6321 if (gGameSettings
.GameMode
in [GM_COOP
, GM_SINGLE
]) or g_Game_IsClient
then
6323 if gTime
- FLastFrag
< FRAG_COMBO_TIME
then
6325 if FFragCombo
< 5 then
6327 Param
:= FUID
or (FFragCombo
shl 16);
6328 if (FComboEvnt
>= Low(gDelayedEvents
)) and
6329 (FComboEvnt
<= High(gDelayedEvents
)) and
6330 gDelayedEvents
[FComboEvnt
].Pending
and
6331 (gDelayedEvents
[FComboEvnt
].DEType
= DE_KILLCOMBO
) and
6332 (gDelayedEvents
[FComboEvnt
].DENum
and $FFFF = FUID
) then
6334 gDelayedEvents
[FComboEvnt
].Time
:= gTime
+ 500;
6335 gDelayedEvents
[FComboEvnt
].DENum
:= Param
;
6338 FComboEvnt
:= g_Game_DelayEvent(DE_KILLCOMBO
, 500, Param
);
6346 procedure TPlayer
.GiveItem(ItemType
: Byte);
6350 if FMegaRulez
[MR_SUIT
] < gTime
+PLAYER_SUIT_TIME
then
6352 FMegaRulez
[MR_SUIT
] := gTime
+PLAYER_SUIT_TIME
;
6356 if FAir
< AIR_MAX
then
6363 if not (R_BERSERK
in FRulez
) then
6365 Include(FRulez
, R_BERSERK
);
6366 if FBFGFireCounter
< 1 then
6368 FCurrWeap
:= WEAPON_KASTET
;
6370 FModel
.SetWeapon(WEAPON_KASTET
);
6374 FBerserk
:= gTime
+30000;
6376 if FHealth
< PLAYER_HP_SOFT
then
6378 FHealth
:= PLAYER_HP_SOFT
;
6379 FBerserk
:= gTime
+30000;
6384 if FMegaRulez
[MR_INVUL
] < gTime
+PLAYER_INVUL_TIME
then
6386 FMegaRulez
[MR_INVUL
] := gTime
+PLAYER_INVUL_TIME
;
6391 if FMegaRulez
[MR_INVIS
] < gTime
+PLAYER_INVIS_TIME
then
6393 FMegaRulez
[MR_INVIS
] := gTime
+PLAYER_INVIS_TIME
;
6397 if FJetFuel
< JET_MAX
then
6399 FJetFuel
:= JET_MAX
;
6402 ITEM_MEDKIT_SMALL
: if FHealth
< PLAYER_HP_SOFT
then IncMax(FHealth
, 10, PLAYER_HP_SOFT
);
6403 ITEM_MEDKIT_LARGE
: if FHealth
< PLAYER_HP_SOFT
then IncMax(FHealth
, 25, PLAYER_HP_SOFT
);
6405 ITEM_ARMOR_GREEN
: if FArmor
< PLAYER_AP_SOFT
then FArmor
:= PLAYER_AP_SOFT
;
6406 ITEM_ARMOR_BLUE
: if FArmor
< PLAYER_AP_LIMIT
then FArmor
:= PLAYER_AP_LIMIT
;
6408 ITEM_SPHERE_BLUE
: if FHealth
< PLAYER_HP_LIMIT
then IncMax(FHealth
, 100, PLAYER_HP_LIMIT
);
6410 if (FHealth
< PLAYER_HP_LIMIT
) or (FArmor
< PLAYER_AP_LIMIT
) then
6412 if FHealth
< PLAYER_HP_LIMIT
then FHealth
:= PLAYER_HP_LIMIT
;
6413 if FArmor
< PLAYER_AP_LIMIT
then FArmor
:= PLAYER_AP_LIMIT
;
6416 ITEM_WEAPON_SAW
: FWeapon
[WEAPON_SAW
] := True;
6417 ITEM_WEAPON_SHOTGUN1
: FWeapon
[WEAPON_SHOTGUN1
] := True;
6418 ITEM_WEAPON_SHOTGUN2
: FWeapon
[WEAPON_SHOTGUN2
] := True;
6419 ITEM_WEAPON_CHAINGUN
: FWeapon
[WEAPON_CHAINGUN
] := True;
6420 ITEM_WEAPON_ROCKETLAUNCHER
: FWeapon
[WEAPON_ROCKETLAUNCHER
] := True;
6421 ITEM_WEAPON_PLASMA
: FWeapon
[WEAPON_PLASMA
] := True;
6422 ITEM_WEAPON_BFG
: FWeapon
[WEAPON_BFG
] := True;
6423 ITEM_WEAPON_SUPERPULEMET
: FWeapon
[WEAPON_SUPERPULEMET
] := True;
6424 ITEM_WEAPON_FLAMETHROWER
: FWeapon
[WEAPON_FLAMETHROWER
] := True;
6426 ITEM_AMMO_BULLETS
: if FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
] then IncMax(FAmmo
[A_BULLETS
], 10, FMaxAmmo
[A_BULLETS
]);
6427 ITEM_AMMO_BULLETS_BOX
: if FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
] then IncMax(FAmmo
[A_BULLETS
], 50, FMaxAmmo
[A_BULLETS
]);
6428 ITEM_AMMO_SHELLS
: if FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
] then IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
6429 ITEM_AMMO_SHELLS_BOX
: if FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
] then IncMax(FAmmo
[A_SHELLS
], 25, FMaxAmmo
[A_SHELLS
]);
6430 ITEM_AMMO_ROCKET
: if FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
] then IncMax(FAmmo
[A_ROCKETS
], 1, FMaxAmmo
[A_ROCKETS
]);
6431 ITEM_AMMO_ROCKET_BOX
: if FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
] then IncMax(FAmmo
[A_ROCKETS
], 5, FMaxAmmo
[A_ROCKETS
]);
6432 ITEM_AMMO_CELL
: if FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
] then IncMax(FAmmo
[A_CELLS
], 40, FMaxAmmo
[A_CELLS
]);
6433 ITEM_AMMO_CELL_BIG
: if FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
] then IncMax(FAmmo
[A_CELLS
], 100, FMaxAmmo
[A_CELLS
]);
6434 ITEM_AMMO_FUELCAN
: if FAmmo
[A_FUEL
] < FMaxAmmo
[A_FUEL
] then IncMax(FAmmo
[A_FUEL
], 100, FMaxAmmo
[A_FUEL
]);
6437 if (FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
]) or
6438 (FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
]) or
6439 (FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
]) or
6440 (FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
]) or
6441 (FMaxAmmo
[A_FUEL
] < AmmoLimits
[1, A_FUEL
]) then
6443 FMaxAmmo
[A_BULLETS
] := AmmoLimits
[1, A_BULLETS
];
6444 FMaxAmmo
[A_SHELLS
] := AmmoLimits
[1, A_SHELLS
];
6445 FMaxAmmo
[A_ROCKETS
] := AmmoLimits
[1, A_ROCKETS
];
6446 FMaxAmmo
[A_CELLS
] := AmmoLimits
[1, A_CELLS
];
6447 FMaxAmmo
[A_FUEL
] := AmmoLimits
[1, A_FUEL
];
6449 if FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
] then IncMax(FAmmo
[A_BULLETS
], 10, FMaxAmmo
[A_BULLETS
]);
6450 if FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
] then IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
6451 if FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
] then IncMax(FAmmo
[A_ROCKETS
], 1, FMaxAmmo
[A_ROCKETS
]);
6452 if FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
] then IncMax(FAmmo
[A_CELLS
], 40, FMaxAmmo
[A_CELLS
]);
6454 FRulez
:= FRulez
+ [R_ITEM_BACKPACK
];
6457 ITEM_KEY_RED
: if not (R_KEY_RED
in FRulez
) then Include(FRulez
, R_KEY_RED
);
6458 ITEM_KEY_GREEN
: if not (R_KEY_GREEN
in FRulez
) then Include(FRulez
, R_KEY_GREEN
);
6459 ITEM_KEY_BLUE
: if not (R_KEY_BLUE
in FRulez
) then Include(FRulez
, R_KEY_BLUE
);
6461 ITEM_BOTTLE
: if FHealth
< PLAYER_HP_LIMIT
then IncMax(FHealth
, 4, PLAYER_HP_LIMIT
);
6462 ITEM_HELMET
: if FArmor
< PLAYER_AP_LIMIT
then IncMax(FArmor
, 5, PLAYER_AP_LIMIT
);
6467 if g_Game_IsNet
and g_Game_IsServer
then
6468 MH_SEND_PlayerStats(FUID
);
6471 procedure TPlayer
.FlySmoke(Times
: DWORD
= 1);
6476 if (Random(5) = 1) and (Times
= 1) then
6479 if BodyInLiquid(0, 0) then
6481 g_GFX_Bubbles(Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2)+Random(3)-1,
6482 Obj
.Y
+Obj
.Rect
.Height
+8, 1, 8, 4);
6483 if Random(2) = 0 then
6484 g_Sound_PlayExAt('SOUND_GAME_BUBBLE1', FObj
.X
, FObj
.Y
)
6486 g_Sound_PlayExAt('SOUND_GAME_BUBBLE2', FObj
.X
, FObj
.Y
);
6490 if g_Frames_Get(id
, 'FRAMES_SMOKE') then
6492 for i
:= 1 to Times
do
6494 Anim
:= TAnimation
.Create(id
, False, 3);
6496 g_GFX_OnceAnim(Obj
.X
+Obj
.Rect
.X
+Random(Obj
.Rect
.Width
+Times
*2)-(Anim
.Width
div 2),
6497 Obj
.Y
+Obj
.Rect
.Height
-4+Random(8+Times
*2), Anim
, ONCEANIM_SMOKE
);
6503 procedure TPlayer
.OnFireFlame(Times
: DWORD
= 1);
6508 if (Random(10) = 1) and (Times
= 1) then
6511 if g_Frames_Get(id
, 'FRAMES_FLAME') then
6513 for i
:= 1 to Times
do
6515 Anim
:= TAnimation
.Create(id
, False, 3);
6517 g_GFX_OnceAnim(Obj
.X
+Obj
.Rect
.X
+Random(Obj
.Rect
.Width
+Times
*2)-(Anim
.Width
div 2),
6518 Obj
.Y
+8+Random(8+Times
*2), Anim
, ONCEANIM_SMOKE
);
6524 procedure TPlayer
.PauseSounds(Enable
: Boolean);
6526 FSawSound
.Pause(Enable
);
6527 FSawSoundIdle
.Pause(Enable
);
6528 FSawSoundHit
.Pause(Enable
);
6529 FSawSoundSelect
.Pause(Enable
);
6530 FFlameSoundOn
.Pause(Enable
);
6531 FFlameSoundOff
.Pause(Enable
);
6532 FFlameSoundWork
.Pause(Enable
);
6533 FJetSoundFly
.Pause(Enable
);
6534 FJetSoundOn
.Pause(Enable
);
6535 FJetSoundOff
.Pause(Enable
);
6540 constructor TCorpse
.Create(X
, Y
: Integer; ModelName
: String; aMess
: Boolean);
6545 FObj
.Rect
:= PLAYER_CORPSERECT
;
6546 FModelName
:= ModelName
;
6551 FState
:= CORPSE_STATE_MESS
;
6552 g_PlayerModel_GetAnim(ModelName
, A_DIE2
, FAnimation
, FAnimationMask
);
6556 FState
:= CORPSE_STATE_NORMAL
;
6557 g_PlayerModel_GetAnim(ModelName
, A_DIE1
, FAnimation
, FAnimationMask
);
6561 destructor TCorpse
.Destroy();
6568 function TCorpse
.ObjPtr (): PObj
; inline; begin result
:= @FObj
; end;
6570 procedure TCorpse
.positionChanged (); inline; begin end;
6572 procedure TCorpse
.moveBy (dx
, dy
: Integer); inline;
6574 if (dx
<> 0) or (dy
<> 0) then
6583 procedure TCorpse
.getMapBox (out x
, y
, w
, h
: Integer); inline;
6585 x
:= FObj
.X
+PLAYER_CORPSERECT
.X
;
6586 y
:= FObj
.Y
+PLAYER_CORPSERECT
.Y
;
6587 w
:= PLAYER_CORPSERECT
.Width
;
6588 h
:= PLAYER_CORPSERECT
.Height
;
6592 procedure TCorpse
.Damage(Value
: Word; vx
, vy
: Integer);
6597 if FState
= CORPSE_STATE_REMOVEME
then
6600 FDamage
:= FDamage
+ Value
;
6602 if FDamage
> 150 then
6604 if FAnimation
<> nil then
6609 FState
:= CORPSE_STATE_REMOVEME
;
6611 g_Player_CreateGibs(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
6612 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2),
6613 FModelName
, FColor
);
6614 // Çâóê ìÿñà îò òðóïà:
6615 pm
:= g_PlayerModel_Get(FModelName
);
6616 pm
.PlaySound(MODELSOUND_DIE
, 5, FObj
.X
, FObj
.Y
);
6620 if (gBodyKillEvent
<> -1)
6621 and gDelayedEvents
[gBodyKillEvent
].Pending
then
6622 gDelayedEvents
[gBodyKillEvent
].Pending
:= False;
6623 gBodyKillEvent
:= g_Game_DelayEvent(DE_BODYKILL
, 1050, 0);
6628 Blood
:= g_PlayerModel_GetBlood(FModelName
);
6629 FObj
.Vel
.X
:= FObj
.Vel
.X
+ vx
;
6630 FObj
.Vel
.Y
:= FObj
.Vel
.Y
+ vy
;
6631 g_GFX_Blood(FObj
.X
+PLAYER_CORPSERECT
.X
+(PLAYER_CORPSERECT
.Width
div 2),
6632 FObj
.Y
+PLAYER_CORPSERECT
.Y
+(PLAYER_CORPSERECT
.Height
div 2),
6633 Value
, vx
, vy
, 16, (PLAYER_CORPSERECT
.Height
*2) div 3,
6634 Blood
.R
, Blood
.G
, Blood
.B
, Blood
.Kind
);
6638 procedure TCorpse
.Draw();
6642 if FState
= CORPSE_STATE_REMOVEME
then
6645 FObj
.lerp(gLerpFactor
, fX
, fY
);
6647 if FAnimation
<> nil then
6648 FAnimation
.Draw(fX
, fY
, TMirrorType
.None
);
6650 if FAnimationMask
<> nil then
6653 FAnimationMask
.Draw(fX
, fY
, TMirrorType
.None
);
6660 procedure TCorpse
.Update();
6664 if FState
= CORPSE_STATE_REMOVEME
then
6667 FObj
.oldX
:= FObj
.X
;
6668 FObj
.oldY
:= FObj
.Y
;
6670 if gTime
mod (GAME_TICK
*2) <> 0 then
6672 g_Obj_Move(@FObj
, True, True, True);
6673 positionChanged(); // this updates spatial accelerators
6677 // Ñîïðîòèâëåíèå âîçäóõà äëÿ òðóïà:
6678 FObj
.Vel
.X
:= z_dec(FObj
.Vel
.X
, 1);
6680 st
:= g_Obj_Move(@FObj
, True, True, True);
6681 positionChanged(); // this updates spatial accelerators
6683 if WordBool(st
and MOVE_FALLOUT
) then
6685 FState
:= CORPSE_STATE_REMOVEME
;
6689 if FAnimation
<> nil then
6690 FAnimation
.Update();
6691 if FAnimationMask
<> nil then
6692 FAnimationMask
.Update();
6696 procedure TCorpse
.SaveState (st
: TStream
);
6703 utils
.writeSign(st
, 'CORP');
6704 utils
.writeInt(st
, Byte(0));
6706 utils
.writeInt(st
, Byte(FState
));
6708 utils
.writeInt(st
, Byte(FDamage
));
6710 utils
.writeInt(st
, Byte(FColor
.R
));
6711 utils
.writeInt(st
, Byte(FColor
.G
));
6712 utils
.writeInt(st
, Byte(FColor
.B
));
6714 Obj_SaveState(st
, @FObj
);
6715 utils
.writeInt(st
, Word(FPlayerUID
));
6717 anim
:= (FAnimation
<> nil);
6718 utils
.writeBool(st
, anim
);
6719 // Åñëè åñòü - ñîõðàíÿåì
6720 if anim
then FAnimation
.SaveState(st
);
6721 // Åñòü ëè ìàñêà àíèìàöèè
6722 anim
:= (FAnimationMask
<> nil);
6723 utils
.writeBool(st
, anim
);
6724 // Åñëè åñòü - ñîõðàíÿåì
6725 if anim
then FAnimationMask
.SaveState(st
);
6729 procedure TCorpse
.LoadState (st
: TStream
);
6736 if not utils
.checkSign(st
, 'CORP') then raise XStreamError
.Create('invalid corpse signature');
6737 if (utils
.readByte(st
) <> 0) then raise XStreamError
.Create('invalid corpse version');
6739 FState
:= utils
.readByte(st
);
6741 FDamage
:= utils
.readByte(st
);
6743 FColor
.R
:= utils
.readByte(st
);
6744 FColor
.G
:= utils
.readByte(st
);
6745 FColor
.B
:= utils
.readByte(st
);
6747 Obj_LoadState(@FObj
, st
);
6748 FPlayerUID
:= utils
.readWord(st
);
6750 anim
:= utils
.readBool(st
);
6751 // Åñëè åñòü - çàãðóæàåì
6754 Assert(FAnimation
<> nil, 'TCorpse.LoadState: no FAnimation');
6755 FAnimation
.LoadState(st
);
6757 // Åñòü ëè ìàñêà àíèìàöèè
6758 anim
:= utils
.readBool(st
);
6759 // Åñëè åñòü - çàãðóæàåì
6762 Assert(FAnimationMask
<> nil, 'TCorpse.LoadState: no FAnimationMask');
6763 FAnimationMask
.LoadState(st
);
6769 constructor TBot
.Create();
6776 FSpectator
:= False;
6783 for a
:= WP_FIRST
to WP_LAST
do
6785 FDifficult
.WeaponPrior
[a
] := WEAPON_PRIOR1
[a
];
6786 FDifficult
.CloseWeaponPrior
[a
] := WEAPON_PRIOR2
[a
];
6787 //FDifficult.SafeWeaponPrior[a] := WEAPON_PRIOR3[a];
6791 destructor TBot
.Destroy();
6794 inherited Destroy();
6797 procedure TBot
.Draw();
6801 //if FTargetUID <> 0 then e_DrawLine(1, FObj.X, FObj.Y, g_Player_Get(FTargetUID).FObj.X,
6802 // g_Player_Get(FTargetUID).FObj.Y, 255, 0, 0);
6805 procedure TBot
.Respawn(Silent
: Boolean; Force
: Boolean = False);
6807 inherited Respawn(Silent
, Force
);
6810 FSelectedWeapon
:= FCurrWeap
;
6815 procedure TBot
.UpdateCombat();
6828 TTargetRecord
= array of TTarget
;
6830 function Compare(a
, b
: TTarget
): Integer;
6832 if a
.Line
and not b
.Line
then // A íà ëèíèè îãíÿ
6835 if not a
.Line
and b
.Line
then // B íà ëèíèè îãíÿ
6837 else // È A, è B íà ëèíèè èëè íå íà ëèíèè îãíÿ
6838 if (a
.Line
and b
.Line
) or ((not a
.Line
) and (not b
.Line
)) then
6840 if a
.Dist
> b
.Dist
then // B áëèæå
6842 else // A áëèæå èëè ðàâíîóäàëåííî ñ B
6845 else // Ñòðàííî -> A
6850 a
, x1
, y1
, x2
, y2
: Integer;
6851 targets
: TTargetRecord
;
6853 Target
, BestTarget
: TTarget
;
6854 firew
, fireh
: Integer;
6858 vsPlayer
, vsMonster
, ok
: Boolean;
6861 function monsUpdate (mon
: TMonster
): Boolean;
6863 result
:= false; // don't stop
6864 if mon
.alive
and (mon
.MonsterType
<> MONSTER_BARREL
) then
6866 if not TargetOnScreen(mon
.Obj
.X
+mon
.Obj
.Rect
.X
, mon
.Obj
.Y
+mon
.Obj
.Rect
.Y
) then exit
;
6868 x2
:= mon
.Obj
.X
+mon
.Obj
.Rect
.X
+(mon
.Obj
.Rect
.Width
div 2);
6869 y2
:= mon
.Obj
.Y
+mon
.Obj
.Rect
.Y
+(mon
.Obj
.Rect
.Height
div 2);
6871 // Åñëè ìîíñòð íà ýêðàíå è íå ïðèêðûò ñòåíîé
6872 if g_TraceVector(x1
, y1
, x2
, y2
) then
6874 // Äîáàâëÿåì ê ñïèñêó âîçìîæíûõ öåëåé
6875 SetLength(targets
, Length(targets
)+1);
6876 with targets
[High(targets
)] do
6883 Rect
:= mon
.Obj
.Rect
;
6884 Dist
:= g_PatchLength(x1
, y1
, x2
, y2
);
6885 Line
:= (y1
+4 < Target
.Y
+ mon
.Obj
.Rect
.Y
+ mon
.Obj
.Rect
.Height
) and
6886 (y1
-4 > Target
.Y
+ mon
.Obj
.Rect
.Y
);
6895 vsPlayer
:= LongBool(gGameSettings
.Options
and GAME_OPTION_BOTVSPLAYER
);
6896 vsMonster
:= LongBool(gGameSettings
.Options
and GAME_OPTION_BOTVSMONSTER
);
6898 // Åñëè òåêóùåå îðóæèå íå òî, ÷òî íóæíî, òî ìåíÿåì:
6899 if FCurrWeap
<> FSelectedWeapon
then
6902 // Åñëè íóæíî ñòðåëÿòü è íóæíîå îðóæèå, òî íàæàòü "Ñòðåëÿòü":
6903 if (GetAIFlag('NEEDFIRE') <> '') and (FCurrWeap
= FSelectedWeapon
) then
6905 RemoveAIFlag('NEEDFIRE');
6908 WEAPON_PLASMA
, WEAPON_SUPERPULEMET
, WEAPON_CHAINGUN
: PressKey(KEY_FIRE
, 20);
6909 WEAPON_SAW
, WEAPON_KASTET
, WEAPON_FLAMETHROWER
: PressKey(KEY_FIRE
, 40);
6910 else PressKey(KEY_FIRE
);
6914 // Êîîðäèíàòû ñòâîëà:
6915 x1
:= FObj
.X
+ WEAPONPOINT
[FDirection
].X
;
6916 y1
:= FObj
.Y
+ WEAPONPOINT
[FDirection
].Y
;
6918 Target
.UID
:= FTargetUID
;
6921 if Target
.UID
<> 0 then
6922 begin // Öåëü åñòü - íàñòðàèâàåì
6923 if (g_GetUIDType(Target
.UID
) = UID_PLAYER
) and
6926 tpla
:= g_Player_Get(Target
.UID
);
6930 if (@FObj
) <> nil then
6937 Target
.cX
:= Target
.X
+ PLAYER_RECT_CX
;
6938 Target
.cY
:= Target
.Y
+ PLAYER_RECT_CY
;
6939 Target
.Rect
:= PLAYER_RECT
;
6940 Target
.Visible
:= g_TraceVector(x1
, y1
, Target
.cX
, Target
.cY
);
6941 Target
.Line
:= (y1
+4 < Target
.Y
+PLAYER_RECT
.Y
+PLAYER_RECT
.Height
) and
6942 (y1
-4 > Target
.Y
+PLAYER_RECT
.Y
);
6943 Target
.IsPlayer
:= True;
6947 if (g_GetUIDType(Target
.UID
) = UID_MONSTER
) and
6950 mon
:= g_Monsters_ByUID(Target
.UID
);
6953 Target
.X
:= mon
.Obj
.X
;
6954 Target
.Y
:= mon
.Obj
.Y
;
6956 Target
.cX
:= Target
.X
+ mon
.Obj
.Rect
.X
+ (mon
.Obj
.Rect
.Width
div 2);
6957 Target
.cY
:= Target
.Y
+ mon
.Obj
.Rect
.Y
+ (mon
.Obj
.Rect
.Height
div 2);
6958 Target
.Rect
:= mon
.Obj
.Rect
;
6959 Target
.Visible
:= g_TraceVector(x1
, y1
, Target
.cX
, Target
.cY
);
6960 Target
.Line
:= (y1
+4 < Target
.Y
+ mon
.Obj
.Rect
.Y
+ mon
.Obj
.Rect
.Height
) and
6961 (y1
-4 > Target
.Y
+ mon
.Obj
.Rect
.Y
);
6962 Target
.IsPlayer
:= False;
6969 begin // Öåëè íåò - îáíóëÿåì
6974 Target
.Visible
:= False;
6975 Target
.Line
:= False;
6976 Target
.IsPlayer
:= False;
6981 // Åñëè öåëü íå âèäèìà èëè íå íà ëèíèè îãíÿ, òî èùåì âñå âîçìîæíûå öåëè:
6982 if (not Target
.Line
) or (not Target
.Visible
) then
6986 for a
:= 0 to High(gPlayers
) do
6987 if (gPlayers
[a
] <> nil) and (gPlayers
[a
].alive
) and
6988 (gPlayers
[a
].FUID
<> FUID
) and
6989 (not SameTeam(FUID
, gPlayers
[a
].FUID
)) and
6990 (not gPlayers
[a
].NoTarget
) and
6991 (gPlayers
[a
].FMegaRulez
[MR_INVIS
] < gTime
) then
6993 if not TargetOnScreen(gPlayers
[a
].FObj
.X
+ PLAYER_RECT
.X
,
6994 gPlayers
[a
].FObj
.Y
+ PLAYER_RECT
.Y
) then
6997 x2
:= gPlayers
[a
].FObj
.X
+ PLAYER_RECT_CX
;
6998 y2
:= gPlayers
[a
].FObj
.Y
+ PLAYER_RECT_CY
;
7000 // Åñëè èãðîê íà ýêðàíå è íå ïðèêðûò ñòåíîé:
7001 if g_TraceVector(x1
, y1
, x2
, y2
) then
7003 // Äîáàâëÿåì ê ñïèñêó âîçìîæíûõ öåëåé:
7004 SetLength(targets
, Length(targets
)+1);
7005 with targets
[High(targets
)] do
7007 UID
:= gPlayers
[a
].FUID
;
7008 X
:= gPlayers
[a
].FObj
.X
;
7009 Y
:= gPlayers
[a
].FObj
.Y
;
7012 Rect
:= PLAYER_RECT
;
7013 Dist
:= g_PatchLength(x1
, y1
, x2
, y2
);
7014 Line
:= (y1
+4 < Target
.Y
+PLAYER_RECT
.Y
+PLAYER_RECT
.Height
) and
7015 (y1
-4 > Target
.Y
+PLAYER_RECT
.Y
);
7023 if vsMonster
then g_Mons_ForEach(monsUpdate
);
7026 // Åñëè åñòü âîçìîæíûå öåëè:
7027 // (Âûáèðàåì ëó÷øóþ, ìåíÿåì îðóæèå è áåæèì ê íåé/îò íåå)
7028 if targets
<> nil then
7030 // Âûáèðàåì íàèëó÷øóþ öåëü:
7031 BestTarget
:= targets
[0];
7032 if Length(targets
) > 1 then
7033 for a
:= 1 to High(targets
) do
7034 if Compare(BestTarget
, targets
[a
]) = 1 then
7035 BestTarget
:= targets
[a
];
7037 // Åñëè ëó÷øàÿ öåëü "âèäíåå" òåêóùåé, òî òåêóùàÿ := ëó÷øàÿ:
7038 if ((not Target
.Visible
) and BestTarget
.Visible
and (Target
.UID
<> BestTarget
.UID
)) or
7039 ((not Target
.Line
) and BestTarget
.Line
and BestTarget
.Visible
) then
7041 Target
:= BestTarget
;
7043 if (Healthy() = 3) or ((Healthy() = 2)) then
7044 begin // Åñëè çäîðîâû - äîãîíÿåì
7045 if ((RunDirection() = TDirection
.D_LEFT
) and (Target
.X
> FObj
.X
)) then
7046 SetAIFlag('GORIGHT', '1');
7047 if ((RunDirection() = TDirection
.D_RIGHT
) and (Target
.X
< FObj
.X
)) then
7048 SetAIFlag('GOLEFT', '1');
7051 begin // Åñëè ïîáèòû - óáåãàåì
7052 if ((RunDirection() = TDirection
.D_LEFT
) and (Target
.X
< FObj
.X
)) then
7053 SetAIFlag('GORIGHT', '1');
7054 if ((RunDirection() = TDirection
.D_RIGHT
) and (Target
.X
> FObj
.X
)) then
7055 SetAIFlag('GOLEFT', '1');
7058 // Âûáèðàåì îðóæèå íà îñíîâå ðàññòîÿíèÿ è ïðèîðèòåòîâ:
7059 SelectWeapon(Abs(x1
-Target
.cX
));
7064 // (Äîãîíÿåì/óáåãàåì, ñòðåëÿåì ïî íàïðàâëåíèþ ê öåëè)
7065 // (Åñëè öåëü äàëåêî, òî õâàòèò ñëåäèòü çà íåé)
7066 if Target
.UID
<> 0 then
7068 if not TargetOnScreen(Target
.X
+ Target
.Rect
.X
,
7069 Target
.Y
+ Target
.Rect
.Y
) then
7070 begin // Öåëü ñáåæàëà ñ "ýêðàíà"
7071 if (Healthy() = 3) or ((Healthy() = 2)) then
7072 begin // Åñëè çäîðîâû - äîãîíÿåì
7073 if ((RunDirection() = TDirection
.D_LEFT
) and (Target
.X
> FObj
.X
)) then
7074 SetAIFlag('GORIGHT', '1');
7075 if ((RunDirection() = TDirection
.D_RIGHT
) and (Target
.X
< FObj
.X
)) then
7076 SetAIFlag('GOLEFT', '1');
7079 begin // Åñëè ïîáèòû - çàáûâàåì î öåëè è óáåãàåì
7081 if ((RunDirection() = TDirection
.D_LEFT
) and (Target
.X
< FObj
.X
)) then
7082 SetAIFlag('GORIGHT', '1');
7083 if ((RunDirection() = TDirection
.D_RIGHT
) and (Target
.X
> FObj
.X
)) then
7084 SetAIFlag('GOLEFT', '1');
7088 begin // Öåëü ïîêà íà "ýêðàíå"
7089 // Åñëè öåëü íå çàãîðîæåíà ñòåíîé, òî îòìå÷àåì, êîãäà åå âèäåëè:
7090 if g_TraceVector(x1
, y1
, Target
.cX
, Target
.cY
) then
7091 FLastVisible
:= gTime
;
7092 // Åñëè ðàçíèöà âûñîò íå âåëèêà, òî äîãîíÿåì:
7093 if (Abs(FObj
.Y
-Target
.Y
) <= 128) then
7095 if ((RunDirection() = TDirection
.D_LEFT
) and (Target
.X
> FObj
.X
)) then
7096 SetAIFlag('GORIGHT', '1');
7097 if ((RunDirection() = TDirection
.D_RIGHT
) and (Target
.X
< FObj
.X
)) then
7098 SetAIFlag('GOLEFT', '1');
7102 // Âûáèðàåì óãîë ââåðõ:
7103 if FDirection
= TDirection
.D_LEFT
then
7104 angle
:= ANGLE_LEFTUP
7106 angle
:= ANGLE_RIGHTUP
;
7108 firew
:= Trunc(Cos(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
7109 fireh
:= Trunc(Sin(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
7111 // Åñëè ïðè óãëå ââåðõ ìîæíî ïîïàñòü â ïðèáëèçèòåëüíîå ïîëîæåíèå öåëè:
7112 if g_CollideLine(x1
, y1
, x1
+firew
, y1
+fireh
,
7113 Target
.X
+Target
.Rect
.X
+GetInterval(FDifficult
.DiagPrecision
, 128), //96
7114 Target
.Y
+Target
.Rect
.Y
+GetInterval(FDifficult
.DiagPrecision
, 128),
7115 Target
.Rect
.Width
, Target
.Rect
.Height
) and
7116 g_TraceVector(x1
, y1
, Target
.cX
, Target
.cY
) then
7117 begin // òî íóæíî ñòðåëÿòü ââåðõ
7118 SetAIFlag('NEEDFIRE', '1');
7119 SetAIFlag('NEEDSEEUP', '1');
7122 // Âûáèðàåì óãîë âíèç:
7123 if FDirection
= TDirection
.D_LEFT
then
7124 angle
:= ANGLE_LEFTDOWN
7126 angle
:= ANGLE_RIGHTDOWN
;
7128 firew
:= Trunc(Cos(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
7129 fireh
:= Trunc(Sin(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
7131 // Åñëè ïðè óãëå âíèç ìîæíî ïîïàñòü â ïðèáëèçèòåëüíîå ïîëîæåíèå öåëè:
7132 if g_CollideLine(x1
, y1
, x1
+firew
, y1
+fireh
,
7133 Target
.X
+Target
.Rect
.X
+GetInterval(FDifficult
.DiagPrecision
, 128),
7134 Target
.Y
+Target
.Rect
.Y
+GetInterval(FDifficult
.DiagPrecision
, 128),
7135 Target
.Rect
.Width
, Target
.Rect
.Height
) and
7136 g_TraceVector(x1
, y1
, Target
.cX
, Target
.cY
) then
7137 begin // òî íóæíî ñòðåëÿòü âíèç
7138 SetAIFlag('NEEDFIRE', '1');
7139 SetAIFlag('NEEDSEEDOWN', '1');
7142 // Åñëè öåëü âèäíî è îíà íà òàêîé æå âûñîòå:
7143 if Target
.Visible
and
7144 (y1
+4 < Target
.Y
+Target
.Rect
.Y
+Target
.Rect
.Height
) and
7145 (y1
-4 > Target
.Y
+Target
.Rect
.Y
) then
7147 // Åñëè èäåì â ñòîðîíó öåëè, òî íàäî ñòðåëÿòü:
7148 if ((FDirection
= TDirection
.D_LEFT
) and (Target
.X
< FObj
.X
)) or
7149 ((FDirection
= TDirection
.D_RIGHT
) and (Target
.X
> FObj
.X
)) then
7150 begin // òî íóæíî ñòðåëÿòü âïåðåä
7151 SetAIFlag('NEEDFIRE', '1');
7152 SetAIFlag('NEEDSEEDOWN', '');
7153 SetAIFlag('NEEDSEEUP', '');
7155 // Åñëè öåëü â ïðåäåëàõ "ýêðàíà" è ñëîæíîñòü ïîçâîëÿåò ïðûæêè ñáëèæåíèÿ:
7156 if Abs(FObj
.X
-Target
.X
) < Trunc(gPlayerScreenSize
.X
*0.75) then
7157 if GetRnd(FDifficult
.CloseJump
) then
7158 begin // òî åñëè ïîâåçåò - ïðûãàåì (îñîáåííî, åñëè áëèçêî)
7159 if Abs(FObj
.X
-Target
.X
) < 128 then
7163 if Random(a
) = 0 then
7164 SetAIFlag('NEEDJUMP', '1');
7168 // Åñëè öåëü âñå åùå åñòü:
7169 if Target
.UID
<> 0 then
7170 if gTime
-FLastVisible
> 2000 then // Åñëè âèäåëè äàâíî
7171 Target
.UID
:= 0 // òî çàáûòü öåëü
7172 else // Åñëè âèäåëè íåäàâíî
7173 begin // íî öåëü óáèëè
7174 if Target
.IsPlayer
then
7175 begin // Öåëü - èãðîê
7176 pla
:= g_Player_Get(Target
.UID
);
7177 if (pla
= nil) or (not pla
.alive
) or pla
.NoTarget
or
7178 (pla
.FMegaRulez
[MR_INVIS
] >= gTime
) then
7179 Target
.UID
:= 0; // òî çàáûòü öåëü
7182 begin // Öåëü - ìîíñòð
7183 mon
:= g_Monsters_ByUID(Target
.UID
);
7184 if (mon
= nil) or (not mon
.alive
) then
7185 Target
.UID
:= 0; // òî çàáûòü öåëü
7188 end; // if Target.UID <> 0
7190 FTargetUID
:= Target
.UID
;
7192 // Åñëè âîçìîæíûõ öåëåé íåò:
7193 // (Àòàêà ÷åãî-íèáóäü ñëåâà èëè ñïðàâà)
7194 if targets
= nil then
7195 if GetAIFlag('ATTACKLEFT') <> '' then
7196 begin // Åñëè íóæíî àòàêîâàòü íàëåâî
7197 RemoveAIFlag('ATTACKLEFT');
7199 SetAIFlag('NEEDJUMP', '1');
7201 if RunDirection() = TDirection
.D_RIGHT
then
7202 begin // Èäåì íå â òó ñòîðîíó
7203 if (Healthy() > 1) and GetRnd(FDifficult
.InvisFire
) then
7204 begin // Åñëè çäîðîâû, òî, âîçìîæíî, ñòðåëÿåì áåæèì âëåâî è ñòðåëÿåì
7205 SetAIFlag('NEEDFIRE', '1');
7206 SetAIFlag('GOLEFT', '1');
7210 begin // Èäåì â íóæíóþ ñòîðîíó
7211 if GetRnd(FDifficult
.InvisFire
) then // Âîçìîæíî, ñòðåëÿåì âñëåïóþ
7212 SetAIFlag('NEEDFIRE', '1');
7213 if Healthy() <= 1 then // Ïîáèòû - óáåãàåì
7214 SetAIFlag('GORIGHT', '1');
7218 if GetAIFlag('ATTACKRIGHT') <> '' then
7219 begin // Åñëè íóæíî àòàêîâàòü íàïðàâî
7220 RemoveAIFlag('ATTACKRIGHT');
7222 SetAIFlag('NEEDJUMP', '1');
7224 if RunDirection() = TDirection
.D_LEFT
then
7225 begin // Èäåì íå â òó ñòîðîíó
7226 if (Healthy() > 1) and GetRnd(FDifficult
.InvisFire
) then
7227 begin // Åñëè çäîðîâû, òî, âîçìîæíî, áåæèì âïðàâî è ñòðåëÿåì
7228 SetAIFlag('NEEDFIRE', '1');
7229 SetAIFlag('GORIGHT', '1');
7234 if GetRnd(FDifficult
.InvisFire
) then // Âîçìîæíî, ñòðåëÿåì âñëåïóþ
7235 SetAIFlag('NEEDFIRE', '1');
7236 if Healthy() <= 1 then // Ïîáèòû - óáåãàåì
7237 SetAIFlag('GOLEFT', '1');
7241 //HACK! (does it belongs there?)
7242 RealizeCurrentWeapon();
7244 // Åñëè åñòü âîçìîæíûå öåëè:
7245 // (Ñòðåëÿåì ïî íàïðàâëåíèþ ê öåëÿì)
7246 if (targets
<> nil) and (GetAIFlag('NEEDFIRE') <> '') then
7247 for a
:= 0 to High(targets
) do
7249 // Åñëè ìîæåì ñòðåëÿòü ïî äèàãîíàëè:
7250 if GetRnd(FDifficult
.DiagFire
) then
7252 // Èùåì öåëü ñâåðõó è ñòðåëÿåì, åñëè åñòü:
7253 if FDirection
= TDirection
.D_LEFT
then
7254 angle
:= ANGLE_LEFTUP
7256 angle
:= ANGLE_RIGHTUP
;
7258 firew
:= Trunc(Cos(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
7259 fireh
:= Trunc(Sin(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
7261 if g_CollideLine(x1
, y1
, x1
+firew
, y1
+fireh
,
7262 targets
[a
].X
+targets
[a
].Rect
.X
+GetInterval(FDifficult
.DiagPrecision
, 128),
7263 targets
[a
].Y
+targets
[a
].Rect
.Y
+GetInterval(FDifficult
.DiagPrecision
, 128),
7264 targets
[a
].Rect
.Width
, targets
[a
].Rect
.Height
) and
7265 g_TraceVector(x1
, y1
, targets
[a
].cX
, targets
[a
].cY
) then
7267 SetAIFlag('NEEDFIRE', '1');
7268 SetAIFlag('NEEDSEEUP', '1');
7271 // Èùåì öåëü ñíèçó è ñòðåëÿåì, åñëè åñòü:
7272 if FDirection
= TDirection
.D_LEFT
then
7273 angle
:= ANGLE_LEFTDOWN
7275 angle
:= ANGLE_RIGHTDOWN
;
7277 firew
:= Trunc(Cos(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
7278 fireh
:= Trunc(Sin(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
7280 if g_CollideLine(x1
, y1
, x1
+firew
, y1
+fireh
,
7281 targets
[a
].X
+targets
[a
].Rect
.X
+GetInterval(FDifficult
.DiagPrecision
, 128),
7282 targets
[a
].Y
+targets
[a
].Rect
.Y
+GetInterval(FDifficult
.DiagPrecision
, 128),
7283 targets
[a
].Rect
.Width
, targets
[a
].Rect
.Height
) and
7284 g_TraceVector(x1
, y1
, targets
[a
].cX
, targets
[a
].cY
) then
7286 SetAIFlag('NEEDFIRE', '1');
7287 SetAIFlag('NEEDSEEDOWN', '1');
7291 // Åñëè öåëü "ïåðåä íîñîì", òî ñòðåëÿåì:
7292 if targets
[a
].Line
and targets
[a
].Visible
and
7293 (((FDirection
= TDirection
.D_LEFT
) and (targets
[a
].X
< FObj
.X
)) or
7294 ((FDirection
= TDirection
.D_RIGHT
) and (targets
[a
].X
> FObj
.X
))) then
7296 SetAIFlag('NEEDFIRE', '1');
7301 // Åñëè ëåòèò ïóëÿ, òî, âîçìîæíî, ïîäïðûãèâàåì:
7302 if g_Weapon_Danger(FUID
, FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+PLAYER_RECT
.Y
,
7303 PLAYER_RECT
.Width
, PLAYER_RECT
.Height
,
7304 40+GetInterval(FDifficult
.Cover
, 40)) then
7305 SetAIFlag('NEEDJUMP', '1');
7307 // Åñëè êîí÷èëèñü ïàòîðíû, òî íóæíî ñìåíèòü îðóæèå:
7308 ammo
:= GetAmmoByWeapon(FCurrWeap
);
7309 if ((FCurrWeap
= WEAPON_SHOTGUN2
) and (ammo
< 2)) or
7310 ((FCurrWeap
= WEAPON_BFG
) and (ammo
< 40)) or
7312 SetAIFlag('SELECTWEAPON', '1');
7314 // Åñëè íóæíî ñìåíèòü îðóæèå, òî âûáèðàåì íóæíîå:
7315 if GetAIFlag('SELECTWEAPON') = '1' then
7318 RemoveAIFlag('SELECTWEAPON');
7322 procedure TBot
.Update();
7335 // Ïðîâåðÿåì, îòêëþ÷¸í ëè AI áîòîâ
7336 if (g_debug_BotAIOff
= 1) and (Team
= TEAM_RED
) then
7338 if (g_debug_BotAIOff
= 2) and (Team
= TEAM_BLUE
) then
7340 if g_debug_BotAIOff
= 3 then
7350 RealizeCurrentWeapon();
7357 procedure TBot
.ReleaseKey(Key
: Byte);
7366 function TBot
.KeyPressed(Key
: Word): Boolean;
7368 Result
:= FKeys
[Key
].Pressed
;
7371 function TBot
.GetAIFlag(aName
: String20
): String20
;
7377 aName
:= LowerCase(aName
);
7379 if FAIFlags
<> nil then
7380 for a
:= 0 to High(FAIFlags
) do
7381 if LowerCase(FAIFlags
[a
].Name
) = aName
then
7383 Result
:= FAIFlags
[a
].Value
;
7388 procedure TBot
.RemoveAIFlag(aName
: String20
);
7392 if FAIFlags
= nil then Exit
;
7394 aName
:= LowerCase(aName
);
7396 for a
:= 0 to High(FAIFlags
) do
7397 if LowerCase(FAIFlags
[a
].Name
) = aName
then
7399 if a
<> High(FAIFlags
) then
7400 for b
:= a
to High(FAIFlags
)-1 do
7401 FAIFlags
[b
] := FAIFlags
[b
+1];
7403 SetLength(FAIFlags
, Length(FAIFlags
)-1);
7408 procedure TBot
.SetAIFlag(aName
, fValue
: String20
);
7416 aName
:= LowerCase(aName
);
7418 if FAIFlags
<> nil then
7419 for a
:= 0 to High(FAIFlags
) do
7420 if LowerCase(FAIFlags
[a
].Name
) = aName
then
7426 if ok
then FAIFlags
[a
].Value
:= fValue
7429 SetLength(FAIFlags
, Length(FAIFlags
)+1);
7430 with FAIFlags
[High(FAIFlags
)] do
7438 procedure TBot
.UpdateMove
;
7440 procedure GoLeft(Time
: Word = 1);
7442 ReleaseKey(KEY_LEFT
);
7443 ReleaseKey(KEY_RIGHT
);
7444 PressKey(KEY_LEFT
, Time
);
7445 SetDirection(TDirection
.D_LEFT
);
7448 procedure GoRight(Time
: Word = 1);
7450 ReleaseKey(KEY_LEFT
);
7451 ReleaseKey(KEY_RIGHT
);
7452 PressKey(KEY_RIGHT
, Time
);
7453 SetDirection(TDirection
.D_RIGHT
);
7456 function Rnd(a
: Word): Boolean;
7458 Result
:= Random(a
) = 0;
7461 procedure Turn(Time
: Word = 1200);
7463 if RunDirection() = TDirection
.D_LEFT
then GoRight(Time
) else GoLeft(Time
);
7468 ReleaseKey(KEY_LEFT
);
7469 ReleaseKey(KEY_RIGHT
);
7472 function CanRunLeft(): Boolean;
7474 Result
:= not CollideLevel(-1, 0);
7477 function CanRunRight(): Boolean;
7479 Result
:= not CollideLevel(1, 0);
7482 function CanRun(): Boolean;
7484 if RunDirection() = TDirection
.D_LEFT
then Result
:= CanRunLeft() else Result
:= CanRunRight();
7487 procedure Jump(Time
: Word = 30);
7489 PressKey(KEY_JUMP
, Time
);
7492 function NearHole(): Boolean;
7496 { TODO 5 : Ëåñòíèöû }
7497 sx
:= IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1);
7498 for x
:= 1 to PLAYER_RECT
.Width
do
7499 if (not StayOnStep(x
*sx
, 0)) and
7500 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
)) and
7501 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
*2)) then
7510 function BorderHole(): Boolean;
7514 { TODO 5 : Ëåñòíèöû }
7515 sx
:= IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1);
7516 for x
:= 1 to PLAYER_RECT
.Width
do
7517 if (not StayOnStep(x
*sx
, 0)) and
7518 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
)) and
7519 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
*2)) then
7521 for xx
:= x
to x
+32 do
7522 if CollideLevel(xx
*sx
, PLAYER_RECT
.Height
) then
7532 function NearDeepHole(): Boolean;
7538 sx
:= IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1);
7541 for x
:= 1 to PLAYER_RECT
.Width
do
7542 if (not StayOnStep(x
*sx
, 0)) and
7543 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
)) and
7544 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
*2)) then
7546 while FObj
.Y
+y
*PLAYER_RECT
.Height
< gMapInfo
.Height
do
7548 if CollideLevel(x
*sx
, PLAYER_RECT
.Height
*y
) then Exit
;
7553 end else Result
:= False;
7556 function OverDeepHole(): Boolean;
7563 while FObj
.Y
+y
*PLAYER_RECT
.Height
< gMapInfo
.Height
do
7565 if CollideLevel(0, PLAYER_RECT
.Height
*y
) then Exit
;
7572 function OnGround(): Boolean;
7574 Result
:= StayOnStep(0, 0) or CollideLevel(0, 1);
7577 function OnLadder(): Boolean;
7579 Result
:= FullInStep(0, 0);
7582 function BelowLadder(): Boolean;
7584 Result
:= (FullInStep(IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -PLAYER_RECT
.Height
) and
7585 not CollideLevel(IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -PLAYER_RECT
.Height
)) or
7586 (FullInStep(IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -BOT_MAXJUMP
) and
7587 not CollideLevel(IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -BOT_MAXJUMP
));
7590 function BelowLiftUp(): Boolean;
7592 Result
:= ((FullInLift(IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -PLAYER_RECT
.Height
) = -1) and
7593 not CollideLevel(IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -PLAYER_RECT
.Height
)) or
7594 ((FullInLift(IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -BOT_MAXJUMP
) = -1) and
7595 not CollideLevel(IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -BOT_MAXJUMP
));
7598 function OnTopLift(): Boolean;
7600 Result
:= (FullInLift(0, 0) = -1) and (FullInLift(0, -32) = 0);
7603 function CanJumpOver(): Boolean;
7607 sx
:= IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1);
7611 if not CollideLevel(sx
, 0) then Exit
;
7613 for y
:= 1 to BOT_MAXJUMP
do
7614 if CollideLevel(0, -y
) then Exit
else
7615 if not CollideLevel(sx
, -y
) then
7622 function CanJumpUp(Dist
: ShortInt): Boolean;
7629 if CollideLevel(Dist
, 0) then Exit
;
7632 for y
:= 0 to BOT_MAXJUMP
do
7633 if CollideLevel(Dist
, -y
) then
7642 for yy
:= y
+1 to BOT_MAXJUMP
do
7643 if not CollideLevel(Dist
, -yy
) then
7652 for y
:= 0 to BOT_MAXJUMP
do
7653 if CollideLevel(0, -y
) then
7661 if y
< yy
then Exit
;
7666 function IsSafeTrigger(): Boolean;
7671 if gTriggers
= nil then
7673 for a
:= 0 to High(gTriggers
) do
7674 if Collide(gTriggers
[a
].X
,
7677 gTriggers
[a
].Height
) and
7678 (gTriggers
[a
].TriggerType
in [TRIGGER_EXIT
, TRIGGER_CLOSEDOOR
,
7679 TRIGGER_CLOSETRAP
, TRIGGER_TRAP
,
7680 TRIGGER_PRESS
, TRIGGER_ON
, TRIGGER_OFF
,
7681 TRIGGER_ONOFF
, TRIGGER_SPAWNMONSTER
,
7682 TRIGGER_DAMAGE
, TRIGGER_SHOT
]) then
7687 // Âîçìîæíî, íàæèìàåì êíîïêó:
7688 if Rnd(16) and IsSafeTrigger() then
7691 // Åñëè ïîä ëèôòîì èëè ñòóïåíüêàìè, òî, âîçìîæíî, ïðûãàåì:
7692 if OnLadder() or ((BelowLadder() or BelowLiftUp()) and Rnd(8)) then
7694 ReleaseKey(KEY_LEFT
);
7695 ReleaseKey(KEY_RIGHT
);
7699 // Èäåì âëåâî, åñëè íàäî áûëî:
7700 if GetAIFlag('GOLEFT') <> '' then
7702 RemoveAIFlag('GOLEFT');
7703 if CanRunLeft() then
7707 // Èäåì âïðàâî, åñëè íàäî áûëî:
7708 if GetAIFlag('GORIGHT') <> '' then
7710 RemoveAIFlag('GORIGHT');
7711 if CanRunRight() then
7715 // Åñëè âûëåòåëè çà êàðòó, òî ïðîáóåì âåðíóòüñÿ:
7716 if FObj
.X
< -32 then
7719 if FObj
.X
+32 > gMapInfo
.Width
then
7722 // Ïðûãàåì, åñëè íàäî áûëî:
7723 if GetAIFlag('NEEDJUMP') <> '' then
7726 RemoveAIFlag('NEEDJUMP');
7729 // Ñìîòðèì ââåðõ, åñëè íàäî áûëî:
7730 if GetAIFlag('NEEDSEEUP') <> '' then
7733 ReleaseKey(KEY_DOWN
);
7734 PressKey(KEY_UP
, 20);
7735 RemoveAIFlag('NEEDSEEUP');
7738 // Ñìîòðèì âíèç, åñëè íàäî áûëî:
7739 if GetAIFlag('NEEDSEEDOWN') <> '' then
7742 ReleaseKey(KEY_DOWN
);
7743 PressKey(KEY_DOWN
, 20);
7744 RemoveAIFlag('NEEDSEEDOWN');
7747 // Åñëè íóæíî áûëî â äûðó è ìû íå íà çåìëå, òî ïîêîðíî ëåòèì:
7748 if GetAIFlag('GOINHOLE') <> '' then
7749 if not OnGround() then
7751 ReleaseKey(KEY_LEFT
);
7752 ReleaseKey(KEY_RIGHT
);
7753 RemoveAIFlag('GOINHOLE');
7754 SetAIFlag('FALLINHOLE', '1');
7757 // Åñëè ïàäàëè è äîñòèãëè çåìëè, òî õâàòèò ïàäàòü:
7758 if GetAIFlag('FALLINHOLE') <> '' then
7760 RemoveAIFlag('FALLINHOLE');
7762 // Åñëè ëåòåëè ïðÿìî è ñåé÷àñ íå íà ëåñòíèöå èëè íà âåðøèíå ëèôòà, òî îòõîäèì â ñòîðîíó:
7763 if not (KeyPressed(KEY_LEFT
) or KeyPressed(KEY_RIGHT
)) then
7764 if GetAIFlag('FALLINHOLE') = '' then
7765 if (not OnLadder()) or (FObj
.Vel
.Y
>= 0) or (OnTopLift()) then
7771 // Åñëè íà çåìëå è ìîæíî ïîäïðûãíóòü, òî, âîçìîæíî, ïðûãàåì:
7773 CanJumpUp(IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1)*32) and
7777 // Åñëè íà çåìëå è âîçëå äûðû (ãëóáèíà > 2 ðîñòîâ èãðîêà):
7778 if OnGround() and NearHole() then
7779 if NearDeepHole() then // Åñëè ýòî áåçäíà
7781 0..3: Turn(); // Áåæèì îáðàòíî
7782 4: Jump(); // Ïðûãàåì
7783 5: begin // Ïðûãàåì îáðàòíî
7788 else // Ýòî íå áåçäíà è ìû åùå íå ëåòèì òóäà
7789 if GetAIFlag('GOINHOLE') = '' then
7791 0: Turn(); // Íå íóæíî òóäà
7792 1: Jump(); // Âäðóã ïîâåçåò - ïðûãàåì
7793 else // Åñëè ÿìà ñ ãðàíèöåé, òî ïðè ñëó÷àå ìîæíî òóäà ïðûãíóòü
7794 if BorderHole() then
7795 SetAIFlag('GOINHOLE', '1');
7798 // Åñëè íà çåìëå, íî íåêóäà èäòè:
7799 if (not CanRun()) and OnGround() then
7801 // Åñëè ìû íà ëåñòíèöå èëè ìîæíî ïåðåïðûãíóòü, òî ïðûãàåì:
7802 if CanJumpOver() or OnLadder() then
7804 else // èíà÷å ïîïûòàåìñÿ â äðóãóþ ñòîðîíó
7805 if Random(2) = 0 then
7807 if IsSafeTrigger() then
7813 // Îñòàëîñü ìàëî âîçäóõà:
7814 if FAir
< 36 * 2 then
7817 // Âûáèðàåìñÿ èç êèñëîòû, åñëè íåò êîñòþìà, îáîæãëèñü, èëè ìàëî çäîðîâüÿ:
7818 if (FMegaRulez
[MR_SUIT
] < gTime
) and ((FLastHit
= HIT_ACID
) or (Healthy() <= 1)) then
7819 if BodyInAcid(0, 0) then
7823 function TBot
.FullInStep(XInc
, YInc
: Integer): Boolean;
7825 Result
:= g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
,
7826 PLAYER_RECT
.Width
, PLAYER_RECT
.Height
, PANEL_STEP
, False);
7829 {function TBot.NeedItem(Item: Byte): Byte;
7834 procedure TBot
.SelectWeapon(Dist
: Integer);
7838 function HaveAmmo(weapon
: Byte): Boolean;
7841 WEAPON_PISTOL
: Result
:= FAmmo
[A_BULLETS
] >= 1;
7842 WEAPON_SHOTGUN1
: Result
:= FAmmo
[A_SHELLS
] >= 1;
7843 WEAPON_SHOTGUN2
: Result
:= FAmmo
[A_SHELLS
] >= 2;
7844 WEAPON_CHAINGUN
: Result
:= FAmmo
[A_BULLETS
] >= 10;
7845 WEAPON_ROCKETLAUNCHER
: Result
:= FAmmo
[A_ROCKETS
] >= 1;
7846 WEAPON_PLASMA
: Result
:= FAmmo
[A_CELLS
] >= 10;
7847 WEAPON_BFG
: Result
:= FAmmo
[A_CELLS
] >= 40;
7848 WEAPON_SUPERPULEMET
: Result
:= FAmmo
[A_SHELLS
] >= 1;
7849 WEAPON_FLAMETHROWER
: Result
:= FAmmo
[A_FUEL
] >= 1;
7850 else Result
:= True;
7855 if Dist
= -1 then Dist
:= BOT_LONGDIST
;
7857 if Dist
> BOT_LONGDIST
then
7858 begin // Äàëüíèé áîé
7860 if FWeapon
[FDifficult
.WeaponPrior
[a
]] and HaveAmmo(FDifficult
.WeaponPrior
[a
]) then
7862 FSelectedWeapon
:= FDifficult
.WeaponPrior
[a
];
7866 else //if Dist > BOT_UNSAFEDIST then
7867 begin // Áëèæíèé áîé
7869 if FWeapon
[FDifficult
.CloseWeaponPrior
[a
]] and HaveAmmo(FDifficult
.CloseWeaponPrior
[a
]) then
7871 FSelectedWeapon
:= FDifficult
.CloseWeaponPrior
[a
];
7878 if FWeapon[FDifficult.SafeWeaponPrior[a]] and HaveAmmo(FDifficult.SafeWeaponPrior[a]) then
7880 FSelectedWeapon := FDifficult.SafeWeaponPrior[a];
7886 function TBot
.PickItem(ItemType
: Byte; force
: Boolean; var remove
: Boolean): Boolean;
7888 Result
:= inherited PickItem(ItemType
, force
, remove
);
7890 if Result
then SetAIFlag('SELECTWEAPON', '1');
7893 function TBot
.Heal(value
: Word; Soft
: Boolean): Boolean;
7895 Result
:= inherited Heal(value
, Soft
);
7898 function TBot
.Healthy(): Byte;
7900 if FMegaRulez
[MR_INVUL
] >= gTime
then Result
:= 3
7901 else if (FHealth
> 80) or ((FHealth
> 50) and (FArmor
> 20)) then Result
:= 3
7902 else if (FHealth
> 50) then Result
:= 2
7903 else if (FHealth
> 20) then Result
:= 1
7907 function TBot
.TargetOnScreen(TX
, TY
: Integer): Boolean;
7909 Result
:= (Abs(FObj
.X
-TX
) <= Trunc(gPlayerScreenSize
.X
*0.6)) and
7910 (Abs(FObj
.Y
-TY
) <= Trunc(gPlayerScreenSize
.Y
*0.6));
7913 procedure TBot
.OnDamage(Angle
: SmallInt);
7921 if (Angle
= 0) or (Angle
= 180) then
7924 if (g_GetUIDType(FLastSpawnerUID
) = UID_PLAYER
) and
7925 LongBool(gGameSettings
.Options
and GAME_OPTION_BOTVSPLAYER
) then
7927 pla
:= g_Player_Get(FLastSpawnerUID
);
7928 ok
:= not TargetOnScreen(pla
.FObj
.X
+ PLAYER_RECT
.X
,
7929 pla
.FObj
.Y
+ PLAYER_RECT
.Y
);
7932 if (g_GetUIDType(FLastSpawnerUID
) = UID_MONSTER
) and
7933 LongBool(gGameSettings
.Options
and GAME_OPTION_BOTVSMONSTER
) then
7935 mon
:= g_Monsters_ByUID(FLastSpawnerUID
);
7936 ok
:= not TargetOnScreen(mon
.Obj
.X
+ mon
.Obj
.Rect
.X
,
7937 mon
.Obj
.Y
+ mon
.Obj
.Rect
.Y
);
7942 SetAIFlag('ATTACKLEFT', '1')
7944 SetAIFlag('ATTACKRIGHT', '1');
7948 function TBot
.RunDirection(): TDirection
;
7950 if Abs(Vel
.X
) >= 1 then
7952 if Vel
.X
> 0 then Result
:= TDirection
.D_RIGHT
else Result
:= TDirection
.D_LEFT
;
7954 Result
:= FDirection
;
7957 function TBot
.GetRnd(a
: Byte): Boolean;
7959 if a
= 0 then Result
:= False
7960 else if a
= 255 then Result
:= True
7961 else Result
:= Random(256) > 255-a
;
7964 function TBot
.GetInterval(a
: Byte; radius
: SmallInt): SmallInt;
7966 Result
:= Round((255-a
)/255*radius
*(Random(2)-1));
7970 procedure TDifficult
.save (st
: TStream
);
7972 utils
.writeInt(st
, Byte(DiagFire
));
7973 utils
.writeInt(st
, Byte(InvisFire
));
7974 utils
.writeInt(st
, Byte(DiagPrecision
));
7975 utils
.writeInt(st
, Byte(FlyPrecision
));
7976 utils
.writeInt(st
, Byte(Cover
));
7977 utils
.writeInt(st
, Byte(CloseJump
));
7978 st
.WriteBuffer(WeaponPrior
[Low(WeaponPrior
)], sizeof(WeaponPrior
));
7979 st
.WriteBuffer(CloseWeaponPrior
[Low(CloseWeaponPrior
)], sizeof(CloseWeaponPrior
));
7982 procedure TDifficult
.load (st
: TStream
);
7984 DiagFire
:= utils
.readByte(st
);
7985 InvisFire
:= utils
.readByte(st
);
7986 DiagPrecision
:= utils
.readByte(st
);
7987 FlyPrecision
:= utils
.readByte(st
);
7988 Cover
:= utils
.readByte(st
);
7989 CloseJump
:= utils
.readByte(st
);
7990 st
.ReadBuffer(WeaponPrior
[Low(WeaponPrior
)], sizeof(WeaponPrior
));
7991 st
.ReadBuffer(CloseWeaponPrior
[Low(CloseWeaponPrior
)], sizeof(CloseWeaponPrior
));
7995 procedure TBot
.SaveState (st
: TStream
);
8000 inherited SaveState(st
);
8001 utils
.writeSign(st
, 'BOT0');
8003 utils
.writeInt(st
, Byte(FSelectedWeapon
));
8005 utils
.writeInt(st
, Word(FTargetUID
));
8006 // Âðåìÿ ïîòåðè öåëè
8007 utils
.writeInt(st
, LongWord(FLastVisible
));
8008 // Êîëè÷åñòâî ôëàãîâ ÈÈ
8009 dw
:= Length(FAIFlags
);
8010 utils
.writeInt(st
, LongInt(dw
));
8012 for i
:= 0 to dw
-1 do
8014 utils
.writeStr(st
, FAIFlags
[i
].Name
, 20);
8015 utils
.writeStr(st
, FAIFlags
[i
].Value
, 20);
8017 // Íàñòðîéêè ñëîæíîñòè
8018 FDifficult
.save(st
);
8022 procedure TBot
.LoadState (st
: TStream
);
8027 inherited LoadState(st
);
8028 if not utils
.checkSign(st
, 'BOT0') then raise XStreamError
.Create('invalid bot signature');
8030 FSelectedWeapon
:= utils
.readByte(st
);
8032 FTargetUID
:= utils
.readWord(st
);
8033 // Âðåìÿ ïîòåðè öåëè
8034 FLastVisible
:= utils
.readLongWord(st
);
8035 // Êîëè÷åñòâî ôëàãîâ ÈÈ
8036 dw
:= utils
.readLongInt(st
);
8037 if (dw
< 0) or (dw
> 16384) then raise XStreamError
.Create('invalid number of bot AI flags');
8038 SetLength(FAIFlags
, dw
);
8040 for i
:= 0 to dw
-1 do
8042 FAIFlags
[i
].Name
:= utils
.readStr(st
, 20);
8043 FAIFlags
[i
].Value
:= utils
.readStr(st
, 20);
8045 // Íàñòðîéêè ñëîæíîñòè
8046 FDifficult
.load(st
);
8051 conRegVar('cheat_berserk_autoswitch', @gBerserkAutoswitch
, 'autoswitch to fist when berserk pack taken', '', true, true);
8052 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');
8053 conRegVar('player_indicator_style', @gPlayerIndicatorStyle
, 'Visual appearance of indicator', 'Visual appearance of indicator');