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
;
5072 if g_Game_IsClient
and (NetInterpLevel
> 0) then
5073 DoLerp(NetInterpLevel
+ 1)
5079 if FClientID
>= 0 then
5081 FPing
:= NetClients
[FClientID
].Peer
^.lastRoundTripTime
;
5082 if NetClients
[FClientID
].Peer
^.packetsSent
> 0 then
5083 FLoss
:= Round(100*NetClients
[FClientID
].Peer
^.packetsLost
/NetClients
[FClientID
].Peer
^.packetsSent
)
5092 if FAlive
and (FPunchAnim
<> nil) then
5093 FPunchAnim
.Update();
5095 if FAlive
and (gFly
or FJetpack
) then
5098 if FDirection
= TDirection
.D_LEFT
then
5103 if FAlive
and (not FGhost
) then
5105 if FKeys
[KEY_UP
].Pressed
then
5107 if FKeys
[KEY_DOWN
].Pressed
then
5111 if (not (FKeys
[KEY_UP
].Pressed
or FKeys
[KEY_DOWN
].Pressed
)) and
5114 i
:= g_basic
.Sign(FIncCam
);
5115 FIncCam
:= Abs(FIncCam
);
5116 DecMin(FIncCam
, 5, 0);
5117 FIncCam
:= FIncCam
*i
;
5120 // no need to do that each second frame, weapon queue will take care of it
5121 if FAlive
and FKeys
[KEY_NEXTWEAPON
].Pressed
and AnyServer
then NextWeapon();
5122 if FAlive
and FKeys
[KEY_PREVWEAPON
].Pressed
and AnyServer
then PrevWeapon();
5124 if gTime
mod (GAME_TICK
*2) <> 0 then
5126 if (FObj
.Vel
.X
= 0) and FAlive
then
5128 if FKeys
[KEY_LEFT
].Pressed
then
5129 Run(TDirection
.D_LEFT
);
5130 if FKeys
[KEY_RIGHT
].Pressed
then
5131 Run(TDirection
.D_RIGHT
);
5136 if not followCorpse() then
5137 g_Obj_Move(@FObj
, True, True, True);
5138 positionChanged(); // this updates spatial accelerators
5144 FActionChanged
:= False;
5148 // Let alive player do some actions
5149 if FKeys
[KEY_LEFT
].Pressed
then Run(TDirection
.D_LEFT
);
5150 if FKeys
[KEY_RIGHT
].Pressed
then Run(TDirection
.D_RIGHT
);
5151 //if FKeys[KEY_NEXTWEAPON].Pressed and AnyServer then NextWeapon();
5152 //if FKeys[KEY_PREVWEAPON].Pressed and AnyServer then PrevWeapon();
5153 if FKeys
[KEY_FIRE
].Pressed
and AnyServer
then Fire()
5159 if NetServer
then MH_SEND_PlayerStats(FUID
);
5162 if FKeys
[KEY_OPEN
].Pressed
and AnyServer
then Use();
5163 if FKeys
[KEY_JUMP
].Pressed
then Jump()
5166 if AnyServer
and FJetpack
then
5170 if NetServer
then MH_SEND_PlayerStats(FUID
);
5172 FCanJetpack
:= True;
5179 for k
:= Low(FKeys
) to KEY_CHAT
-1 do
5181 if FKeys
[k
].Pressed
then
5189 if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
5192 if (FTime
[T_RESPAWN
] <= gTime
) and
5193 gGameOn
and (not FAlive
) then
5195 if (g_Player_GetCount() > 1) then
5199 gExit
:= EXIT_RESTART
;
5204 // Dead spectator actions
5207 if FKeys
[KEY_OPEN
].Pressed
and AnyServer
then Fire();
5208 if FKeys
[KEY_FIRE
].Pressed
and AnyServer
then
5212 if (FSpectatePlayer
>= High(gPlayers
)) then
5213 FSpectatePlayer
:= -1
5217 for I
:= FSpectatePlayer
+ 1 to High(gPlayers
) do
5218 if gPlayers
[I
] <> nil then
5219 if gPlayers
[I
].alive
then
5220 if gPlayers
[I
].UID
<> FUID
then
5222 FSpectatePlayer
:= I
;
5227 if not SetSpect
then FSpectatePlayer
:= -1;
5238 if FKeys
[KEY_UP
].Pressed
or FKeys
[KEY_JUMP
].Pressed
then
5240 FYTo
:= FObj
.Y
- 32;
5241 FSpectatePlayer
:= -1;
5243 if FKeys
[KEY_DOWN
].Pressed
then
5245 FYTo
:= FObj
.Y
+ 32;
5246 FSpectatePlayer
:= -1;
5248 if FKeys
[KEY_LEFT
].Pressed
then
5250 FXTo
:= FObj
.X
- 32;
5251 FSpectatePlayer
:= -1;
5253 if FKeys
[KEY_RIGHT
].Pressed
then
5255 FXTo
:= FObj
.X
+ 32;
5256 FSpectatePlayer
:= -1;
5259 if (FXTo
< -64) then
5261 else if (FXTo
> gMapInfo
.Width
+ 32) then
5262 FXTo
:= gMapInfo
.Width
+ 32;
5263 if (FYTo
< -72) then
5265 else if (FYTo
> gMapInfo
.Height
+ 32) then
5266 FYTo
:= gMapInfo
.Height
+ 32;
5271 if not followCorpse() then
5272 g_Obj_Move(@FObj
, True, True, True);
5273 positionChanged(); // this updates spatial accelerators
5280 if (FSpectatePlayer
<= High(gPlayers
)) and (FSpectatePlayer
>= 0) then
5281 if gPlayers
[FSpectatePlayer
] <> nil then
5282 if gPlayers
[FSpectatePlayer
].alive
then
5284 FXTo
:= gPlayers
[FSpectatePlayer
].GameX
;
5285 FYTo
:= gPlayers
[FSpectatePlayer
].GameY
;
5289 blockmon
:= g_Map_CollidePanel(FObj
.X
+PLAYER_HEADRECT
.X
, FObj
.Y
+PLAYER_HEADRECT
.Y
,
5290 PLAYER_HEADRECT
.Width
, PLAYER_HEADRECT
.Height
,
5291 PANEL_BLOCKMON
, True);
5292 headwater
:= HeadInLiquid(0, 0);
5294 // Ñîïðîòèâëåíèå âîçäóõà:
5295 if (not FAlive
) or not (FKeys
[KEY_LEFT
].Pressed
or FKeys
[KEY_RIGHT
].Pressed
) then
5296 if FObj
.Vel
.X
<> 0 then
5297 FObj
.Vel
.X
:= z_dec(FObj
.Vel
.X
, 1);
5299 if (FLastHit
= HIT_TRAP
) and (FPain
> 90) then FPain
:= 90;
5300 DecMin(FPain
, 5, 0);
5301 DecMin(FPickup
, 1, 0);
5303 if FAlive
and (FObj
.Y
> Integer(gMapInfo
.Height
)+128) and AnyServer
then
5305 // Îáíóëèòü äåéñòâèÿ ïðèìî÷åê, ÷òîáû ôîí ïðîïàë
5306 FMegaRulez
[MR_SUIT
] := 0;
5307 FMegaRulez
[MR_INVUL
] := 0;
5308 FMegaRulez
[MR_INVIS
] := 0;
5309 Kill(K_FALLKILL
, 0, HIT_FALL
);
5316 if FCurrWeap
= WEAPON_SAW
then
5317 if not (FSawSound
.IsPlaying() or FSawSoundHit
.IsPlaying() or
5318 FSawSoundSelect
.IsPlaying()) then
5319 FSawSoundIdle
.PlayAt(FObj
.X
, FObj
.Y
);
5322 if (not FJetSoundFly
.IsPlaying()) and (not FJetSoundOn
.IsPlaying()) and
5323 (not FJetSoundOff
.IsPlaying()) then
5325 FJetSoundFly
.SetPosition(0);
5326 FJetSoundFly
.PlayAt(FObj
.X
, FObj
.Y
);
5329 for b
:= WP_FIRST
to WP_LAST
do
5330 if FReloading
[b
] > 0 then
5336 if FShellTimer
> -1 then
5337 if FShellTimer
= 0 then
5339 if FShellType
= SHELL_SHELL
then
5340 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
5341 GameVelX
, GameVelY
-2, SHELL_SHELL
)
5342 else if FShellType
= SHELL_DBLSHELL
then
5344 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
5345 GameVelX
+1, GameVelY
-2, SHELL_SHELL
);
5346 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
5347 GameVelX
-1, GameVelY
-2, SHELL_SHELL
);
5350 end else Dec(FShellTimer
);
5352 if (FBFGFireCounter
> -1) then
5353 if FBFGFireCounter
= 0 then
5357 wx
:= FObj
.X
+WEAPONPOINT
[FDirection
].X
;
5358 wy
:= FObj
.Y
+WEAPONPOINT
[FDirection
].Y
;
5359 xd
:= wx
+IfThen(FDirection
= TDirection
.D_LEFT
, -30, 30);
5360 yd
:= wy
+firediry();
5361 g_Weapon_bfgshot(wx
, wy
, xd
, yd
, FUID
);
5362 if NetServer
then MH_SEND_PlayerFire(FUID
, WEAPON_BFG
, wx
, wy
, xd
, yd
);
5363 if (FAngle
= 0) or (FAngle
= 180) then SetAction(A_ATTACK
)
5364 else if (FAngle
= ANGLE_LEFTDOWN
) or (FAngle
= ANGLE_RIGHTDOWN
) then SetAction(A_ATTACKDOWN
)
5365 else if (FAngle
= ANGLE_LEFTUP
) or (FAngle
= ANGLE_RIGHTUP
) then SetAction(A_ATTACKUP
);
5368 FReloading
[WEAPON_BFG
] := WEAPON_RELOAD
[WEAPON_BFG
];
5369 FBFGFireCounter
:= -1;
5372 FBFGFireCounter
:= 0
5374 Dec(FBFGFireCounter
);
5376 if (FMegaRulez
[MR_SUIT
] < gTime
) and AnyServer
then
5378 b
:= g_GetAcidHit(FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+PLAYER_RECT
.Y
, PLAYER_RECT
.Width
, PLAYER_RECT
.Height
);
5380 if (b
> 0) and (gTime
mod (15*GAME_TICK
) = 0) then Damage(b
, 0, 0, 0, HIT_ACID
);
5383 if (headwater
or blockmon
) then
5389 if AnyServer
then Damage(10, 0, 0, 0, HIT_WATER
);
5392 else if (FAir
mod 31 = 0) and not blockmon
then
5394 g_GFX_Bubbles(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2), FObj
.Y
+PLAYER_RECT
.Y
-4, 5+Random(6), 8, 4);
5395 if Random(2) = 0 then
5396 g_Sound_PlayExAt('SOUND_GAME_BUBBLE1', FObj
.X
, FObj
.Y
)
5398 g_Sound_PlayExAt('SOUND_GAME_BUBBLE2', FObj
.X
, FObj
.Y
);
5400 end else if FAir
< AIR_DEF
then
5403 if FFireTime
> 0 then
5405 if BodyInLiquid(0, 0) then
5410 else if FMegaRulez
[MR_SUIT
] >= gTime
then
5412 if FMegaRulez
[MR_SUIT
] = gTime
then
5419 if FFirePainTime
<= 0 then
5421 if g_Game_IsServer
then
5422 Damage(2, FFireAttacker
, 0, 0, HIT_FLAME
);
5423 FFirePainTime
:= 12 - FFireTime
div 12;
5425 FFirePainTime
:= FFirePainTime
- 1;
5426 FFireTime
:= FFireTime
- 1;
5427 if ((FFireTime
mod 33) = 0) and (FMegaRulez
[MR_INVUL
] < gTime
) then
5428 FModel
.PlaySound(MODELSOUND_PAIN
, 1, FObj
.X
, FObj
.Y
);
5429 if (FFireTime
= 0) and g_Game_IsNet
and g_Game_IsServer
then
5430 MH_SEND_PlayerStats(FUID
);
5434 if FDamageBuffer
> 0 then
5436 if FDamageBuffer
>= 9 then
5440 if FDamageBuffer
< 30 then i
:= 9
5441 else if FDamageBuffer
< 100 then i
:= 18
5445 ii
:= Round(FDamageBuffer
*FHealth
/ nonz(FArmor
*(3/4)+FHealth
));
5446 FArmor
:= FArmor
-(FDamageBuffer
-ii
);
5447 FHealth
:= FHealth
-ii
;
5450 FHealth
:= FHealth
+FArmor
;
5455 if FHealth
<= 0 then
5456 if FHealth
> -30 then Kill(K_SIMPLEKILL
, FLastSpawnerUID
, FLastHit
)
5457 else if FHealth
> -50 then Kill(K_HARDKILL
, FLastSpawnerUID
, FLastHit
)
5458 else Kill(K_EXTRAHARDKILL
, FLastSpawnerUID
, FLastHit
);
5460 if FAlive
and ((FLastHit
<> HIT_FLAME
) or (FFireTime
<= 0)) then
5462 if FDamageBuffer
<= 20 then FModel
.PlaySound(MODELSOUND_PAIN
, 1, FObj
.X
, FObj
.Y
)
5463 else if FDamageBuffer
<= 55 then FModel
.PlaySound(MODELSOUND_PAIN
, 2, FObj
.X
, FObj
.Y
)
5464 else if FDamageBuffer
<= 120 then FModel
.PlaySound(MODELSOUND_PAIN
, 3, FObj
.X
, FObj
.Y
)
5465 else FModel
.PlaySound(MODELSOUND_PAIN
, 4, FObj
.X
, FObj
.Y
);
5472 end; // if FAlive then ...
5474 if (FActionAnim
= A_PAIN
) and (FModel
.Animation
<> A_PAIN
) then
5476 FModel
.ChangeAnimation(FActionAnim
, FActionForce
);
5477 FModel
.GetCurrentAnimation
.MinLength
:= i
;
5478 FModel
.GetCurrentAnimationMask
.MinLength
:= i
;
5479 end else FModel
.ChangeAnimation(FActionAnim
, FActionForce
and (FModel
.Animation
<> A_STAND
));
5481 if (FModel
.GetCurrentAnimation
.Played
or ((not FActionChanged
) and (FModel
.Animation
= A_WALK
)))
5482 then SetAction(A_STAND
, True);
5484 if not ((FModel
.Animation
= A_WALK
) and (Abs(FObj
.Vel
.X
) < 4) and not FModel
.Fire
) then FModel
.Update
;
5486 for b
:= Low(FKeys
) to High(FKeys
) do
5487 if FKeys
[b
].Time
= 0 then FKeys
[b
].Pressed
:= False else Dec(FKeys
[b
].Time
);
5491 procedure TPlayer
.getMapBox (out x
, y
, w
, h
: Integer); inline;
5493 x
:= FObj
.X
+PLAYER_RECT
.X
;
5494 y
:= FObj
.Y
+PLAYER_RECT
.Y
;
5495 w
:= PLAYER_RECT
.Width
;
5496 h
:= PLAYER_RECT
.Height
;
5500 procedure TPlayer
.moveBy (dx
, dy
: Integer); inline;
5502 if (dx
<> 0) or (dy
<> 0) then
5511 function TPlayer
.Collide(X
, Y
: Integer; Width
, Height
: Word): Boolean;
5513 Result
:= g_Collide(FObj
.X
+PLAYER_RECT
.X
,
5514 FObj
.Y
+PLAYER_RECT
.Y
,
5521 function TPlayer
.Collide(Panel
: TPanel
): Boolean;
5523 Result
:= g_Collide(FObj
.X
+PLAYER_RECT
.X
,
5524 FObj
.Y
+PLAYER_RECT
.Y
,
5528 Panel
.Width
, Panel
.Height
);
5531 function TPlayer
.Collide(X
, Y
: Integer): Boolean;
5533 X
:= X
-FObj
.X
-PLAYER_RECT
.X
;
5534 Y
:= Y
-FObj
.Y
-PLAYER_RECT
.Y
;
5535 Result
:= (x
>= 0) and (x
<= PLAYER_RECT
.Width
) and
5536 (y
>= 0) and (y
<= PLAYER_RECT
.Height
);
5539 function g_Player_ValidName(Name
: string): Boolean;
5545 if gPlayers
= nil then Exit
;
5547 for a
:= 0 to High(gPlayers
) do
5548 if gPlayers
[a
] <> nil then
5549 if LowerCase(Name
) = LowerCase(gPlayers
[a
].FName
) then
5556 procedure TPlayer
.SetDirection(Direction
: TDirection
);
5560 d
:= FModel
.Direction
;
5562 FModel
.Direction
:= Direction
;
5563 if d
<> Direction
then FModel
.ChangeAnimation(FModel
.Animation
, True);
5565 FDirection
:= Direction
;
5568 function TPlayer
.GetKeys(): Byte;
5572 if R_KEY_RED
in FRulez
then Result
:= KEY_RED
;
5573 if R_KEY_GREEN
in FRulez
then Result
:= Result
or KEY_GREEN
;
5574 if R_KEY_BLUE
in FRulez
then Result
:= Result
or KEY_BLUE
;
5576 if FTeam
= TEAM_RED
then Result
:= Result
or KEY_REDTEAM
;
5577 if FTeam
= TEAM_BLUE
then Result
:= Result
or KEY_BLUETEAM
;
5580 procedure TPlayer
.Use();
5584 if FTime
[T_USE
] > gTime
then Exit
;
5586 g_Triggers_PressR(FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+PLAYER_RECT
.Y
, PLAYER_RECT
.Width
,
5587 PLAYER_RECT
.Height
, FUID
, ACTIVATE_PLAYERPRESS
);
5589 for a
:= 0 to High(gPlayers
) do
5590 if (gPlayers
[a
] <> nil) and (gPlayers
[a
] <> Self
) and
5591 gPlayers
[a
].alive
and SameTeam(FUID
, gPlayers
[a
].FUID
) and
5592 g_Obj_Collide(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
,
5593 FObj
.Rect
.Width
, FObj
.Rect
.Height
, @gPlayers
[a
].FObj
) then
5595 gPlayers
[a
].Touch();
5596 if g_Game_IsNet
and g_Game_IsServer
then
5597 MH_SEND_GameEvent(NET_EV_PLAYER_TOUCH
, gPlayers
[a
].FUID
);
5600 FTime
[T_USE
] := gTime
+120;
5603 procedure TPlayer
.NetFire(Wpn
: Byte; X
, Y
, AX
, AY
: Integer; WID
: Integer = -1);
5607 WX
, WY
, XD
, YD
: Integer;
5619 if R_BERSERK
in FRulez
then
5621 //g_Weapon_punch(FObj.X+FObj.Rect.X, FObj.Y+FObj.Rect.Y, 75, FUID);
5622 locobj
.X
:= FObj
.X
+FObj
.Rect
.X
;
5623 locobj
.Y
:= FObj
.Y
+FObj
.Rect
.Y
;
5626 locobj
.rect
.Width
:= 39;
5627 locobj
.rect
.Height
:= 52;
5628 locobj
.Vel
.X
:= (xd
-wx
) div 2;
5629 locobj
.Vel
.Y
:= (yd
-wy
) div 2;
5630 locobj
.Accel
.X
:= xd
-wx
;
5631 locobj
.Accel
.y
:= yd
-wy
;
5633 if g_Weapon_Hit(@locobj
, 50, FUID
, HIT_SOME
) <> 0 then
5634 g_Sound_PlayExAt('SOUND_WEAPON_HITBERSERK', FObj
.X
, FObj
.Y
)
5636 g_Sound_PlayExAt('SOUND_WEAPON_MISSBERSERK', FObj
.X
, FObj
.Y
);
5640 FPain
:= min(FPain
+ 25, 50);
5642 g_Weapon_punch(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
, 3, FUID
);
5647 if g_Weapon_chainsaw(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
,
5648 IfThen(gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
], 9, 3), FUID
) <> 0 then
5650 FSawSoundSelect
.Stop();
5652 FSawSoundHit
.PlayAt(FObj
.X
, FObj
.Y
);
5654 else if not FSawSoundHit
.IsPlaying() then
5656 FSawSoundSelect
.Stop();
5657 FSawSound
.PlayAt(FObj
.X
, FObj
.Y
);
5664 g_Sound_PlayExAt('SOUND_WEAPON_FIREPISTOL', GameX
, Gamey
);
5665 FFireAngle
:= FAngle
;
5667 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
5668 GameVelX
, GameVelY
-2, SHELL_BULLET
);
5673 g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN', Gamex
, Gamey
);
5674 FFireAngle
:= FAngle
;
5677 FShellType
:= SHELL_SHELL
;
5682 g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN2', Gamex
, Gamey
);
5683 FFireAngle
:= FAngle
;
5686 FShellType
:= SHELL_DBLSHELL
;
5691 g_Sound_PlayExAt('SOUND_WEAPON_FIRECGUN', Gamex
, Gamey
);
5692 FFireAngle
:= FAngle
;
5694 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
5695 GameVelX
, GameVelY
-2, SHELL_BULLET
);
5698 WEAPON_ROCKETLAUNCHER
:
5700 g_Weapon_Rocket(wx
, wy
, xd
, yd
, FUID
, WID
);
5701 FFireAngle
:= FAngle
;
5707 g_Weapon_Plasma(wx
, wy
, xd
, yd
, FUID
, WID
);
5708 FFireAngle
:= FAngle
;
5714 g_Weapon_BFGShot(wx
, wy
, xd
, yd
, FUID
, WID
);
5715 FFireAngle
:= FAngle
;
5719 WEAPON_SUPERPULEMET
:
5721 g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN', Gamex
, Gamey
);
5722 FFireAngle
:= FAngle
;
5724 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
5725 GameVelX
, GameVelY
-2, SHELL_SHELL
);
5728 WEAPON_FLAMETHROWER
:
5730 g_Weapon_flame(wx
, wy
, xd
, yd
, FUID
, WID
);
5732 FFireAngle
:= FAngle
;
5739 if (FAngle
= 0) or (FAngle
= 180) then SetAction(A_ATTACK
)
5740 else if (FAngle
= ANGLE_LEFTDOWN
) or (FAngle
= ANGLE_RIGHTDOWN
) then SetAction(A_ATTACKDOWN
)
5741 else if (FAngle
= ANGLE_LEFTUP
) or (FAngle
= ANGLE_RIGHTUP
) then SetAction(A_ATTACKUP
);
5744 procedure TPlayer
.DoLerp(Level
: Integer = 2);
5746 if FObj
.X
<> FXTo
then FObj
.X
:= Lerp(FObj
.X
, FXTo
, Level
);
5747 if FObj
.Y
<> FYTo
then FObj
.Y
:= Lerp(FObj
.Y
, FYTo
, Level
);
5750 procedure TPlayer
.SetLerp(XTo
, YTo
: Integer);
5754 if NetInterpLevel
< 1 then
5764 AX
:= Abs(FXTo
- FObj
.X
);
5765 AY
:= Abs(FYTo
- FObj
.Y
);
5766 if (AX
> 32) or (AX
<= NetInterpLevel
) then
5768 if (AY
> 32) or (AY
<= NetInterpLevel
) then
5773 function TPlayer
.FullInLift(XInc
, YInc
: Integer): Integer;
5775 if g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
,
5776 PLAYER_RECT
.Width
, PLAYER_RECT
.Height
-8,
5777 PANEL_LIFTUP
, False) then Result
:= -1
5779 if g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
,
5780 PLAYER_RECT
.Width
, PLAYER_RECT
.Height
-8,
5781 PANEL_LIFTDOWN
, False) then Result
:= 1
5785 function TPlayer
.GetFlag(Flag
: Byte): Boolean;
5792 if Flag
= FLAG_NONE
then
5795 if not g_Game_IsServer
then Exit
;
5797 // Ïðèíåñ ÷óæîé ôëàã íà ñâîþ áàçó:
5798 if (Flag
= FTeam
) and
5799 (gFlags
[Flag
].State
= FLAG_STATE_NORMAL
) and
5800 (FFlag
<> FLAG_NONE
) then
5802 if FFlag
= FLAG_RED
then
5803 s
:= _lc
[I_PLAYER_FLAG_RED
]
5805 s
:= _lc
[I_PLAYER_FLAG_BLUE
];
5807 evtype
:= FLAG_STATE_SCORED
;
5809 ts
:= Format('%.4d', [gFlags
[FFlag
].CaptureTime
]);
5810 Insert('.', ts
, Length(ts
) + 1 - 3);
5811 g_Console_Add(Format(_lc
[I_PLAYER_FLAG_CAPTURE
], [FName
, s
, ts
]), True);
5813 g_Map_ResetFlag(FFlag
);
5814 g_Game_Message(Format(_lc
[I_MESSAGE_FLAG_CAPTURE
], [AnsiUpperCase(s
)]), 144);
5816 if ((Self
= gPlayer1
) or (Self
= gPlayer2
)
5817 or ((gPlayer1
<> nil) and (gPlayer1
.Team
= FTeam
))
5818 or ((gPlayer2
<> nil) and (gPlayer2
.Team
= FTeam
))) then
5823 if not sound_cap_flag
[a
].IsPlaying() then
5824 sound_cap_flag
[a
].Play();
5826 gTeamStat
[FTeam
].Goals
:= gTeamStat
[FTeam
].Goals
+ 1;
5829 if g_Game_IsNet
then
5831 MH_SEND_FlagEvent(evtype
, FFlag
, FUID
, False);
5835 gFlags
[FFlag
].CaptureTime
:= 0;
5840 // Ïîäîáðàë ñâîé ôëàã - âåðíóë åãî íà áàçó:
5841 if (Flag
= FTeam
) and
5842 (gFlags
[Flag
].State
= FLAG_STATE_DROPPED
) then
5844 if Flag
= FLAG_RED
then
5845 s
:= _lc
[I_PLAYER_FLAG_RED
]
5847 s
:= _lc
[I_PLAYER_FLAG_BLUE
];
5849 evtype
:= FLAG_STATE_RETURNED
;
5850 gFlags
[Flag
].CaptureTime
:= 0;
5852 g_Console_Add(Format(_lc
[I_PLAYER_FLAG_RETURN
], [FName
, s
]), True);
5854 g_Map_ResetFlag(Flag
);
5855 g_Game_Message(Format(_lc
[I_MESSAGE_FLAG_RETURN
], [AnsiUpperCase(s
)]), 144);
5857 if ((Self
= gPlayer1
) or (Self
= gPlayer2
)
5858 or ((gPlayer1
<> nil) and (gPlayer1
.Team
= FTeam
))
5859 or ((gPlayer2
<> nil) and (gPlayer2
.Team
= FTeam
))) then
5864 if not sound_ret_flag
[a
].IsPlaying() then
5865 sound_ret_flag
[a
].Play();
5868 if g_Game_IsNet
then
5870 MH_SEND_FlagEvent(evtype
, Flag
, FUID
, False);
5876 // Ïîäîáðàë ÷óæîé ôëàã:
5877 if (Flag
<> FTeam
) and (FTime
[T_FLAGCAP
] <= gTime
) then
5881 if Flag
= FLAG_RED
then
5882 s
:= _lc
[I_PLAYER_FLAG_RED
]
5884 s
:= _lc
[I_PLAYER_FLAG_BLUE
];
5886 evtype
:= FLAG_STATE_CAPTURED
;
5888 g_Console_Add(Format(_lc
[I_PLAYER_FLAG_GET
], [FName
, s
]), True);
5890 g_Game_Message(Format(_lc
[I_MESSAGE_FLAG_GET
], [AnsiUpperCase(s
)]), 144);
5892 gFlags
[Flag
].State
:= FLAG_STATE_CAPTURED
;
5894 if ((Self
= gPlayer1
) or (Self
= gPlayer2
)
5895 or ((gPlayer1
<> nil) and (gPlayer1
.Team
= FTeam
))
5896 or ((gPlayer2
<> nil) and (gPlayer2
.Team
= FTeam
))) then
5901 if not sound_get_flag
[a
].IsPlaying() then
5902 sound_get_flag
[a
].Play();
5905 if g_Game_IsNet
then
5907 MH_SEND_FlagEvent(evtype
, Flag
, FUID
, False);
5913 procedure TPlayer
.SetFlag(Flag
: Byte);
5916 if FModel
<> nil then
5917 FModel
.SetFlag(FFlag
);
5920 function TPlayer
.DropFlag(Silent
: Boolean = True): Boolean;
5926 if (not g_Game_IsServer
) or (FFlag
= FLAG_NONE
) then
5928 FTime
[T_FLAGCAP
] := gTime
+ 2000;
5929 with gFlags
[FFlag
] do
5933 Direction
:= FDirection
;
5934 State
:= FLAG_STATE_DROPPED
;
5936 g_Obj_Push(@Obj
, (FObj
.Vel
.X
div 2)-2+Random(5),
5937 (FObj
.Vel
.Y
div 2)-2+Random(5));
5938 positionChanged(); // this updates spatial accelerators
5940 if FFlag
= FLAG_RED
then
5941 s
:= _lc
[I_PLAYER_FLAG_RED
]
5943 s
:= _lc
[I_PLAYER_FLAG_BLUE
];
5945 g_Console_Add(Format(_lc
[I_PLAYER_FLAG_DROP
], [FName
, s
]), True);
5946 g_Game_Message(Format(_lc
[I_MESSAGE_FLAG_DROP
], [AnsiUpperCase(s
)]), 144);
5948 if ((Self
= gPlayer1
) or (Self
= gPlayer2
)
5949 or ((gPlayer1
<> nil) and (gPlayer1
.Team
= FTeam
))
5950 or ((gPlayer2
<> nil) and (gPlayer2
.Team
= FTeam
))) then
5955 if (not Silent
) and (not sound_lost_flag
[a
].IsPlaying()) then
5956 sound_lost_flag
[a
].Play();
5958 if g_Game_IsNet
then
5959 MH_SEND_FlagEvent(FLAG_STATE_DROPPED
, Flag
, FUID
, False);
5965 procedure TPlayer
.GetSecret();
5967 if (self
= gPlayer1
) or (self
= gPlayer2
) then
5969 g_Console_Add(Format(_lc
[I_PLAYER_SECRET
], [FName
]), True);
5970 g_Sound_PlayEx('SOUND_GAME_SECRET');
5975 procedure TPlayer
.PressKey(Key
: Byte; Time
: Word = 1);
5977 Assert(Key
<= High(FKeys
));
5979 FKeys
[Key
].Pressed
:= True;
5980 FKeys
[Key
].Time
:= Time
;
5983 function TPlayer
.IsKeyPressed(K
: Byte): Boolean;
5985 Result
:= FKeys
[K
].Pressed
;
5988 procedure TPlayer
.ReleaseKeys();
5992 for a
:= Low(FKeys
) to High(FKeys
) do
5994 FKeys
[a
].Pressed
:= False;
5999 procedure TPlayer
.OnDamage(Angle
: SmallInt);
6003 function TPlayer
.firediry(): Integer;
6005 if FKeys
[KEY_UP
].Pressed
then Result
:= -42
6006 else if FKeys
[KEY_DOWN
].Pressed
then Result
:= 19
6010 procedure TPlayer
.RememberState();
6013 SavedState
: TPlayerSavedState
;
6015 SavedState
.Health
:= FHealth
;
6016 SavedState
.Armor
:= FArmor
;
6017 SavedState
.Air
:= FAir
;
6018 SavedState
.JetFuel
:= FJetFuel
;
6019 SavedState
.CurrWeap
:= FCurrWeap
;
6020 SavedState
.NextWeap
:= FNextWeap
;
6021 SavedState
.NextWeapDelay
:= FNextWeapDelay
;
6022 for i
:= Low(FWeapon
) to High(FWeapon
) do
6023 SavedState
.Weapon
[i
] := FWeapon
[i
];
6024 for i
:= Low(FAmmo
) to High(FAmmo
) do
6025 SavedState
.Ammo
[i
] := FAmmo
[i
];
6026 for i
:= Low(FMaxAmmo
) to High(FMaxAmmo
) do
6027 SavedState
.MaxAmmo
[i
] := FMaxAmmo
[i
];
6028 SavedState
.Rulez
:= FRulez
- [R_KEY_RED
, R_KEY_GREEN
, R_KEY_BLUE
];
6030 FSavedStateNum
:= -1;
6031 for i
:= Low(SavedStates
) to High(SavedStates
) do
6032 if not SavedStates
[i
].Used
then
6034 FSavedStateNum
:= i
;
6037 if FSavedStateNum
< 0 then
6039 SetLength(SavedStates
, Length(SavedStates
) + 1);
6040 FSavedStateNum
:= High(SavedStates
);
6043 SavedState
.Used
:= True;
6044 SavedStates
[FSavedStateNum
] := SavedState
;
6047 procedure TPlayer
.RecallState();
6050 SavedState
: TPlayerSavedState
;
6052 if(FSavedStateNum
< 0) or (FSavedStateNum
> High(SavedStates
)) then
6055 SavedState
:= SavedStates
[FSavedStateNum
];
6056 SavedStates
[FSavedStateNum
].Used
:= False;
6057 FSavedStateNum
:= -1;
6059 FHealth
:= SavedState
.Health
;
6060 FArmor
:= SavedState
.Armor
;
6061 FAir
:= SavedState
.Air
;
6062 FJetFuel
:= SavedState
.JetFuel
;
6063 FCurrWeap
:= SavedState
.CurrWeap
;
6064 FNextWeap
:= SavedState
.NextWeap
;
6065 FNextWeapDelay
:= SavedState
.NextWeapDelay
;
6066 for i
:= Low(FWeapon
) to High(FWeapon
) do
6067 FWeapon
[i
] := SavedState
.Weapon
[i
];
6068 for i
:= Low(FAmmo
) to High(FAmmo
) do
6069 FAmmo
[i
] := SavedState
.Ammo
[i
];
6070 for i
:= Low(FMaxAmmo
) to High(FMaxAmmo
) do
6071 FMaxAmmo
[i
] := SavedState
.MaxAmmo
[i
];
6072 FRulez
:= SavedState
.Rulez
;
6074 if gGameSettings
.GameType
= GT_SERVER
then
6075 MH_SEND_PlayerStats(FUID
);
6078 procedure TPlayer
.SaveState (st
: TStream
);
6084 utils
.writeSign(st
, 'PLYR');
6085 utils
.writeInt(st
, Byte(PLR_SAVE_VERSION
)); // version
6087 utils
.writeBool(st
, FIamBot
);
6089 utils
.writeInt(st
, Word(FUID
));
6091 utils
.writeStr(st
, FName
);
6093 utils
.writeInt(st
, Byte(FTeam
));
6095 utils
.writeBool(st
, FAlive
);
6096 // Èçðàñõîäîâàë ëè âñå æèçíè
6097 utils
.writeBool(st
, FNoRespawn
);
6099 if FDirection
= TDirection
.D_LEFT
then b
:= 1 else b
:= 2; // D_RIGHT
6100 utils
.writeInt(st
, Byte(b
));
6102 utils
.writeInt(st
, LongInt(FHealth
));
6103 // Êîýôôèöèåíò èíâàëèäíîñòè
6104 utils
.writeInt(st
, LongInt(FHandicap
));
6106 utils
.writeInt(st
, Byte(FLives
));
6108 utils
.writeInt(st
, LongInt(FArmor
));
6110 utils
.writeInt(st
, LongInt(FAir
));
6112 utils
.writeInt(st
, LongInt(FJetFuel
));
6114 utils
.writeInt(st
, LongInt(FPain
));
6116 utils
.writeInt(st
, LongInt(FKills
));
6118 utils
.writeInt(st
, LongInt(FMonsterKills
));
6120 utils
.writeInt(st
, LongInt(FFrags
));
6122 utils
.writeInt(st
, Byte(FFragCombo
));
6123 // Âðåìÿ ïîñëåäíåãî ôðàãà
6124 utils
.writeInt(st
, LongWord(FLastFrag
));
6126 utils
.writeInt(st
, LongInt(FDeath
));
6128 utils
.writeInt(st
, Byte(FFlag
));
6130 utils
.writeInt(st
, LongInt(FSecrets
));
6132 utils
.writeInt(st
, Byte(FCurrWeap
));
6134 utils
.writeInt(st
, Word(FNextWeap
));
6136 utils
.writeInt(st
, Byte(FNextWeapDelay
));
6137 // Âðåìÿ çàðÿäêè BFG
6138 utils
.writeInt(st
, SmallInt(FBFGFireCounter
));
6140 utils
.writeInt(st
, LongInt(FDamageBuffer
));
6141 // Ïîñëåäíèé óäàðèâøèé
6142 utils
.writeInt(st
, Word(FLastSpawnerUID
));
6143 // Òèï ïîñëåäíåãî ïîëó÷åííîãî óðîíà
6144 utils
.writeInt(st
, Byte(FLastHit
));
6146 Obj_SaveState(st
, @FObj
);
6147 // Òåêóùåå êîëè÷åñòâî ïàòðîíîâ
6148 for i
:= A_BULLETS
to A_HIGH
do utils
.writeInt(st
, Word(FAmmo
[i
]));
6149 // Ìàêñèìàëüíîå êîëè÷åñòâî ïàòðîíîâ
6150 for i
:= A_BULLETS
to A_HIGH
do utils
.writeInt(st
, Word(FMaxAmmo
[i
]));
6152 for i
:= WP_FIRST
to WP_LAST
do utils
.writeBool(st
, FWeapon
[i
]);
6153 // Âðåìÿ ïåðåçàðÿäêè îðóæèÿ
6154 for i
:= WP_FIRST
to WP_LAST
do utils
.writeInt(st
, Word(FReloading
[i
]));
6156 utils
.writeBool(st
, (R_ITEM_BACKPACK
in FRulez
));
6157 // Íàëè÷èå êðàñíîãî êëþ÷à
6158 utils
.writeBool(st
, (R_KEY_RED
in FRulez
));
6159 // Íàëè÷èå çåëåíîãî êëþ÷à
6160 utils
.writeBool(st
, (R_KEY_GREEN
in FRulez
));
6161 // Íàëè÷èå ñèíåãî êëþ÷à
6162 utils
.writeBool(st
, (R_KEY_BLUE
in FRulez
));
6164 utils
.writeBool(st
, (R_BERSERK
in FRulez
));
6165 // Âðåìÿ äåéñòâèÿ ñïåöèàëüíûõ ïðåäìåòîâ
6166 for i
:= MR_SUIT
to MR_MAX
do utils
.writeInt(st
, LongWord(FMegaRulez
[i
]));
6167 // Âðåìÿ äî ïîâòîðíîãî ðåñïàóíà, ñìåíû îðóæèÿ, èñîëüçîâàíèÿ, çàõâàòà ôëàãà
6168 for i
:= T_RESPAWN
to T_FLAGCAP
do utils
.writeInt(st
, LongWord(FTime
[i
]));
6170 utils
.writeStr(st
, FModel
.Name
);
6172 utils
.writeInt(st
, Byte(FColor
.R
));
6173 utils
.writeInt(st
, Byte(FColor
.G
));
6174 utils
.writeInt(st
, Byte(FColor
.B
));
6178 procedure TPlayer
.LoadState (st
: TStream
);
6187 if not utils
.checkSign(st
, 'PLYR') then raise XStreamError
.Create('invalid player signature');
6188 if (utils
.readByte(st
) <> PLR_SAVE_VERSION
) then raise XStreamError
.Create('invalid player version');
6190 FIamBot
:= utils
.readBool(st
);
6192 FUID
:= utils
.readWord(st
);
6194 str
:= utils
.readStr(st
);
6195 if (self
<> gPlayer1
) and (self
<> gPlayer2
) then FName
:= str
;
6197 FTeam
:= utils
.readByte(st
);
6199 FAlive
:= utils
.readBool(st
);
6200 // Èçðàñõîäîâàë ëè âñå æèçíè
6201 FNoRespawn
:= utils
.readBool(st
);
6203 b
:= utils
.readByte(st
);
6204 if b
= 1 then FDirection
:= TDirection
.D_LEFT
else FDirection
:= TDirection
.D_RIGHT
; // b = 2
6206 FHealth
:= utils
.readLongInt(st
);
6207 // Êîýôôèöèåíò èíâàëèäíîñòè
6208 FHandicap
:= utils
.readLongInt(st
);
6210 FLives
:= utils
.readByte(st
);
6212 FArmor
:= utils
.readLongInt(st
);
6214 FAir
:= utils
.readLongInt(st
);
6216 FJetFuel
:= utils
.readLongInt(st
);
6218 FPain
:= utils
.readLongInt(st
);
6220 FKills
:= utils
.readLongInt(st
);
6222 FMonsterKills
:= utils
.readLongInt(st
);
6224 FFrags
:= utils
.readLongInt(st
);
6226 FFragCombo
:= utils
.readByte(st
);
6227 // Âðåìÿ ïîñëåäíåãî ôðàãà
6228 FLastFrag
:= utils
.readLongWord(st
);
6230 FDeath
:= utils
.readLongInt(st
);
6232 FFlag
:= utils
.readByte(st
);
6234 FSecrets
:= utils
.readLongInt(st
);
6236 FCurrWeap
:= utils
.readByte(st
);
6238 FNextWeap
:= utils
.readWord(st
);
6240 FNextWeapDelay
:= utils
.readByte(st
);
6241 // Âðåìÿ çàðÿäêè BFG
6242 FBFGFireCounter
:= utils
.readSmallInt(st
);
6244 FDamageBuffer
:= utils
.readLongInt(st
);
6245 // Ïîñëåäíèé óäàðèâøèé
6246 FLastSpawnerUID
:= utils
.readWord(st
);
6247 // Òèï ïîñëåäíåãî ïîëó÷åííîãî óðîíà
6248 FLastHit
:= utils
.readByte(st
);
6250 Obj_LoadState(@FObj
, st
);
6251 // Òåêóùåå êîëè÷åñòâî ïàòðîíîâ
6252 for i
:= A_BULLETS
to A_HIGH
do FAmmo
[i
] := utils
.readWord(st
);
6253 // Ìàêñèìàëüíîå êîëè÷åñòâî ïàòðîíîâ
6254 for i
:= A_BULLETS
to A_HIGH
do FMaxAmmo
[i
] := utils
.readWord(st
);
6256 for i
:= WP_FIRST
to WP_LAST
do FWeapon
[i
] := utils
.readBool(st
);
6257 // Âðåìÿ ïåðåçàðÿäêè îðóæèÿ
6258 for i
:= WP_FIRST
to WP_LAST
do FReloading
[i
] := utils
.readWord(st
);
6260 if utils
.readBool(st
) then Include(FRulez
, R_ITEM_BACKPACK
);
6261 // Íàëè÷èå êðàñíîãî êëþ÷à
6262 if utils
.readBool(st
) then Include(FRulez
, R_KEY_RED
);
6263 // Íàëè÷èå çåëåíîãî êëþ÷à
6264 if utils
.readBool(st
) then Include(FRulez
, R_KEY_GREEN
);
6265 // Íàëè÷èå ñèíåãî êëþ÷à
6266 if utils
.readBool(st
) then Include(FRulez
, R_KEY_BLUE
);
6268 if utils
.readBool(st
) then Include(FRulez
, R_BERSERK
);
6269 // Âðåìÿ äåéñòâèÿ ñïåöèàëüíûõ ïðåäìåòîâ
6270 for i
:= MR_SUIT
to MR_MAX
do FMegaRulez
[i
] := utils
.readLongWord(st
);
6271 // Âðåìÿ äî ïîâòîðíîãî ðåñïàóíà, ñìåíû îðóæèÿ, èñîëüçîâàíèÿ, çàõâàòà ôëàãà
6272 for i
:= T_RESPAWN
to T_FLAGCAP
do FTime
[i
] := utils
.readLongWord(st
);
6274 str
:= utils
.readStr(st
);
6276 FColor
.R
:= utils
.readByte(st
);
6277 FColor
.G
:= utils
.readByte(st
);
6278 FColor
.B
:= utils
.readByte(st
);
6279 if (self
= gPlayer1
) then
6281 str
:= gPlayer1Settings
.Model
;
6282 FColor
:= gPlayer1Settings
.Color
;
6284 else if (self
= gPlayer2
) then
6286 str
:= gPlayer2Settings
.Model
;
6287 FColor
:= gPlayer2Settings
.Color
;
6289 // Îáíîâëÿåì ìîäåëü èãðîêà
6291 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
6292 FModel
.Color
:= TEAMCOLOR
[FTeam
]
6294 FModel
.Color
:= FColor
;
6298 procedure TPlayer
.AllRulez(Health
: Boolean);
6304 FHealth
:= PLAYER_HP_LIMIT
;
6305 FArmor
:= PLAYER_AP_LIMIT
;
6309 for a
:= WP_FIRST
to WP_LAST
do FWeapon
[a
] := True;
6310 for a
:= A_BULLETS
to A_HIGH
do FAmmo
[a
] := 30000;
6311 FRulez
:= FRulez
+[R_KEY_RED
, R_KEY_GREEN
, R_KEY_BLUE
];
6314 procedure TPlayer
.RestoreHealthArmor();
6316 FHealth
:= PLAYER_HP_LIMIT
;
6317 FArmor
:= PLAYER_AP_LIMIT
;
6320 procedure TPlayer
.FragCombo();
6324 if (gGameSettings
.GameMode
in [GM_COOP
, GM_SINGLE
]) or g_Game_IsClient
then
6326 if gTime
- FLastFrag
< FRAG_COMBO_TIME
then
6328 if FFragCombo
< 5 then
6330 Param
:= FUID
or (FFragCombo
shl 16);
6331 if (FComboEvnt
>= Low(gDelayedEvents
)) and
6332 (FComboEvnt
<= High(gDelayedEvents
)) and
6333 gDelayedEvents
[FComboEvnt
].Pending
and
6334 (gDelayedEvents
[FComboEvnt
].DEType
= DE_KILLCOMBO
) and
6335 (gDelayedEvents
[FComboEvnt
].DENum
and $FFFF = FUID
) then
6337 gDelayedEvents
[FComboEvnt
].Time
:= gTime
+ 500;
6338 gDelayedEvents
[FComboEvnt
].DENum
:= Param
;
6341 FComboEvnt
:= g_Game_DelayEvent(DE_KILLCOMBO
, 500, Param
);
6349 procedure TPlayer
.GiveItem(ItemType
: Byte);
6353 if FMegaRulez
[MR_SUIT
] < gTime
+PLAYER_SUIT_TIME
then
6355 FMegaRulez
[MR_SUIT
] := gTime
+PLAYER_SUIT_TIME
;
6359 if FAir
< AIR_MAX
then
6366 if not (R_BERSERK
in FRulez
) then
6368 Include(FRulez
, R_BERSERK
);
6369 if FBFGFireCounter
< 1 then
6371 FCurrWeap
:= WEAPON_KASTET
;
6373 FModel
.SetWeapon(WEAPON_KASTET
);
6377 FBerserk
:= gTime
+30000;
6379 if FHealth
< PLAYER_HP_SOFT
then
6381 FHealth
:= PLAYER_HP_SOFT
;
6382 FBerserk
:= gTime
+30000;
6387 if FMegaRulez
[MR_INVUL
] < gTime
+PLAYER_INVUL_TIME
then
6389 FMegaRulez
[MR_INVUL
] := gTime
+PLAYER_INVUL_TIME
;
6394 if FMegaRulez
[MR_INVIS
] < gTime
+PLAYER_INVIS_TIME
then
6396 FMegaRulez
[MR_INVIS
] := gTime
+PLAYER_INVIS_TIME
;
6400 if FJetFuel
< JET_MAX
then
6402 FJetFuel
:= JET_MAX
;
6405 ITEM_MEDKIT_SMALL
: if FHealth
< PLAYER_HP_SOFT
then IncMax(FHealth
, 10, PLAYER_HP_SOFT
);
6406 ITEM_MEDKIT_LARGE
: if FHealth
< PLAYER_HP_SOFT
then IncMax(FHealth
, 25, PLAYER_HP_SOFT
);
6408 ITEM_ARMOR_GREEN
: if FArmor
< PLAYER_AP_SOFT
then FArmor
:= PLAYER_AP_SOFT
;
6409 ITEM_ARMOR_BLUE
: if FArmor
< PLAYER_AP_LIMIT
then FArmor
:= PLAYER_AP_LIMIT
;
6411 ITEM_SPHERE_BLUE
: if FHealth
< PLAYER_HP_LIMIT
then IncMax(FHealth
, 100, PLAYER_HP_LIMIT
);
6413 if (FHealth
< PLAYER_HP_LIMIT
) or (FArmor
< PLAYER_AP_LIMIT
) then
6415 if FHealth
< PLAYER_HP_LIMIT
then FHealth
:= PLAYER_HP_LIMIT
;
6416 if FArmor
< PLAYER_AP_LIMIT
then FArmor
:= PLAYER_AP_LIMIT
;
6419 ITEM_WEAPON_SAW
: FWeapon
[WEAPON_SAW
] := True;
6420 ITEM_WEAPON_SHOTGUN1
: FWeapon
[WEAPON_SHOTGUN1
] := True;
6421 ITEM_WEAPON_SHOTGUN2
: FWeapon
[WEAPON_SHOTGUN2
] := True;
6422 ITEM_WEAPON_CHAINGUN
: FWeapon
[WEAPON_CHAINGUN
] := True;
6423 ITEM_WEAPON_ROCKETLAUNCHER
: FWeapon
[WEAPON_ROCKETLAUNCHER
] := True;
6424 ITEM_WEAPON_PLASMA
: FWeapon
[WEAPON_PLASMA
] := True;
6425 ITEM_WEAPON_BFG
: FWeapon
[WEAPON_BFG
] := True;
6426 ITEM_WEAPON_SUPERPULEMET
: FWeapon
[WEAPON_SUPERPULEMET
] := True;
6427 ITEM_WEAPON_FLAMETHROWER
: FWeapon
[WEAPON_FLAMETHROWER
] := True;
6429 ITEM_AMMO_BULLETS
: if FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
] then IncMax(FAmmo
[A_BULLETS
], 10, FMaxAmmo
[A_BULLETS
]);
6430 ITEM_AMMO_BULLETS_BOX
: if FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
] then IncMax(FAmmo
[A_BULLETS
], 50, FMaxAmmo
[A_BULLETS
]);
6431 ITEM_AMMO_SHELLS
: if FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
] then IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
6432 ITEM_AMMO_SHELLS_BOX
: if FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
] then IncMax(FAmmo
[A_SHELLS
], 25, FMaxAmmo
[A_SHELLS
]);
6433 ITEM_AMMO_ROCKET
: if FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
] then IncMax(FAmmo
[A_ROCKETS
], 1, FMaxAmmo
[A_ROCKETS
]);
6434 ITEM_AMMO_ROCKET_BOX
: if FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
] then IncMax(FAmmo
[A_ROCKETS
], 5, FMaxAmmo
[A_ROCKETS
]);
6435 ITEM_AMMO_CELL
: if FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
] then IncMax(FAmmo
[A_CELLS
], 40, FMaxAmmo
[A_CELLS
]);
6436 ITEM_AMMO_CELL_BIG
: if FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
] then IncMax(FAmmo
[A_CELLS
], 100, FMaxAmmo
[A_CELLS
]);
6437 ITEM_AMMO_FUELCAN
: if FAmmo
[A_FUEL
] < FMaxAmmo
[A_FUEL
] then IncMax(FAmmo
[A_FUEL
], 100, FMaxAmmo
[A_FUEL
]);
6440 if (FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
]) or
6441 (FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
]) or
6442 (FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
]) or
6443 (FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
]) or
6444 (FMaxAmmo
[A_FUEL
] < AmmoLimits
[1, A_FUEL
]) then
6446 FMaxAmmo
[A_BULLETS
] := AmmoLimits
[1, A_BULLETS
];
6447 FMaxAmmo
[A_SHELLS
] := AmmoLimits
[1, A_SHELLS
];
6448 FMaxAmmo
[A_ROCKETS
] := AmmoLimits
[1, A_ROCKETS
];
6449 FMaxAmmo
[A_CELLS
] := AmmoLimits
[1, A_CELLS
];
6450 FMaxAmmo
[A_FUEL
] := AmmoLimits
[1, A_FUEL
];
6452 if FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
] then IncMax(FAmmo
[A_BULLETS
], 10, FMaxAmmo
[A_BULLETS
]);
6453 if FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
] then IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
6454 if FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
] then IncMax(FAmmo
[A_ROCKETS
], 1, FMaxAmmo
[A_ROCKETS
]);
6455 if FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
] then IncMax(FAmmo
[A_CELLS
], 40, FMaxAmmo
[A_CELLS
]);
6457 FRulez
:= FRulez
+ [R_ITEM_BACKPACK
];
6460 ITEM_KEY_RED
: if not (R_KEY_RED
in FRulez
) then Include(FRulez
, R_KEY_RED
);
6461 ITEM_KEY_GREEN
: if not (R_KEY_GREEN
in FRulez
) then Include(FRulez
, R_KEY_GREEN
);
6462 ITEM_KEY_BLUE
: if not (R_KEY_BLUE
in FRulez
) then Include(FRulez
, R_KEY_BLUE
);
6464 ITEM_BOTTLE
: if FHealth
< PLAYER_HP_LIMIT
then IncMax(FHealth
, 4, PLAYER_HP_LIMIT
);
6465 ITEM_HELMET
: if FArmor
< PLAYER_AP_LIMIT
then IncMax(FArmor
, 5, PLAYER_AP_LIMIT
);
6470 if g_Game_IsNet
and g_Game_IsServer
then
6471 MH_SEND_PlayerStats(FUID
);
6474 procedure TPlayer
.FlySmoke(Times
: DWORD
= 1);
6479 if (Random(5) = 1) and (Times
= 1) then
6482 if BodyInLiquid(0, 0) then
6484 g_GFX_Bubbles(Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2)+Random(3)-1,
6485 Obj
.Y
+Obj
.Rect
.Height
+8, 1, 8, 4);
6486 if Random(2) = 0 then
6487 g_Sound_PlayExAt('SOUND_GAME_BUBBLE1', FObj
.X
, FObj
.Y
)
6489 g_Sound_PlayExAt('SOUND_GAME_BUBBLE2', FObj
.X
, FObj
.Y
);
6493 if g_Frames_Get(id
, 'FRAMES_SMOKE') then
6495 for i
:= 1 to Times
do
6497 Anim
:= TAnimation
.Create(id
, False, 3);
6499 g_GFX_OnceAnim(Obj
.X
+Obj
.Rect
.X
+Random(Obj
.Rect
.Width
+Times
*2)-(Anim
.Width
div 2),
6500 Obj
.Y
+Obj
.Rect
.Height
-4+Random(8+Times
*2), Anim
, ONCEANIM_SMOKE
);
6506 procedure TPlayer
.OnFireFlame(Times
: DWORD
= 1);
6511 if (Random(10) = 1) and (Times
= 1) then
6514 if g_Frames_Get(id
, 'FRAMES_FLAME') then
6516 for i
:= 1 to Times
do
6518 Anim
:= TAnimation
.Create(id
, False, 3);
6520 g_GFX_OnceAnim(Obj
.X
+Obj
.Rect
.X
+Random(Obj
.Rect
.Width
+Times
*2)-(Anim
.Width
div 2),
6521 Obj
.Y
+8+Random(8+Times
*2), Anim
, ONCEANIM_SMOKE
);
6527 procedure TPlayer
.PauseSounds(Enable
: Boolean);
6529 FSawSound
.Pause(Enable
);
6530 FSawSoundIdle
.Pause(Enable
);
6531 FSawSoundHit
.Pause(Enable
);
6532 FSawSoundSelect
.Pause(Enable
);
6533 FFlameSoundOn
.Pause(Enable
);
6534 FFlameSoundOff
.Pause(Enable
);
6535 FFlameSoundWork
.Pause(Enable
);
6536 FJetSoundFly
.Pause(Enable
);
6537 FJetSoundOn
.Pause(Enable
);
6538 FJetSoundOff
.Pause(Enable
);
6543 constructor TCorpse
.Create(X
, Y
: Integer; ModelName
: String; aMess
: Boolean);
6548 FObj
.Rect
:= PLAYER_CORPSERECT
;
6549 FModelName
:= ModelName
;
6554 FState
:= CORPSE_STATE_MESS
;
6555 g_PlayerModel_GetAnim(ModelName
, A_DIE2
, FAnimation
, FAnimationMask
);
6559 FState
:= CORPSE_STATE_NORMAL
;
6560 g_PlayerModel_GetAnim(ModelName
, A_DIE1
, FAnimation
, FAnimationMask
);
6564 destructor TCorpse
.Destroy();
6571 function TCorpse
.ObjPtr (): PObj
; inline; begin result
:= @FObj
; end;
6573 procedure TCorpse
.positionChanged (); inline; begin end;
6575 procedure TCorpse
.moveBy (dx
, dy
: Integer); inline;
6577 if (dx
<> 0) or (dy
<> 0) then
6586 procedure TCorpse
.getMapBox (out x
, y
, w
, h
: Integer); inline;
6588 x
:= FObj
.X
+PLAYER_CORPSERECT
.X
;
6589 y
:= FObj
.Y
+PLAYER_CORPSERECT
.Y
;
6590 w
:= PLAYER_CORPSERECT
.Width
;
6591 h
:= PLAYER_CORPSERECT
.Height
;
6595 procedure TCorpse
.Damage(Value
: Word; vx
, vy
: Integer);
6600 if FState
= CORPSE_STATE_REMOVEME
then
6603 FDamage
:= FDamage
+ Value
;
6605 if FDamage
> 150 then
6607 if FAnimation
<> nil then
6612 FState
:= CORPSE_STATE_REMOVEME
;
6614 g_Player_CreateGibs(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
6615 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2),
6616 FModelName
, FColor
);
6617 // Çâóê ìÿñà îò òðóïà:
6618 pm
:= g_PlayerModel_Get(FModelName
);
6619 pm
.PlaySound(MODELSOUND_DIE
, 5, FObj
.X
, FObj
.Y
);
6623 if (gBodyKillEvent
<> -1)
6624 and gDelayedEvents
[gBodyKillEvent
].Pending
then
6625 gDelayedEvents
[gBodyKillEvent
].Pending
:= False;
6626 gBodyKillEvent
:= g_Game_DelayEvent(DE_BODYKILL
, 1050, 0);
6631 Blood
:= g_PlayerModel_GetBlood(FModelName
);
6632 FObj
.Vel
.X
:= FObj
.Vel
.X
+ vx
;
6633 FObj
.Vel
.Y
:= FObj
.Vel
.Y
+ vy
;
6634 g_GFX_Blood(FObj
.X
+PLAYER_CORPSERECT
.X
+(PLAYER_CORPSERECT
.Width
div 2),
6635 FObj
.Y
+PLAYER_CORPSERECT
.Y
+(PLAYER_CORPSERECT
.Height
div 2),
6636 Value
, vx
, vy
, 16, (PLAYER_CORPSERECT
.Height
*2) div 3,
6637 Blood
.R
, Blood
.G
, Blood
.B
, Blood
.Kind
);
6641 procedure TCorpse
.Draw();
6645 if FState
= CORPSE_STATE_REMOVEME
then
6648 FObj
.lerp(gLerpFactor
, fX
, fY
);
6650 if FAnimation
<> nil then
6651 FAnimation
.Draw(fX
, fY
, TMirrorType
.None
);
6653 if FAnimationMask
<> nil then
6656 FAnimationMask
.Draw(fX
, fY
, TMirrorType
.None
);
6663 procedure TCorpse
.Update();
6667 if FState
= CORPSE_STATE_REMOVEME
then
6670 FObj
.oldX
:= FObj
.X
;
6671 FObj
.oldY
:= FObj
.Y
;
6673 if gTime
mod (GAME_TICK
*2) <> 0 then
6675 g_Obj_Move(@FObj
, True, True, True);
6676 positionChanged(); // this updates spatial accelerators
6680 // Ñîïðîòèâëåíèå âîçäóõà äëÿ òðóïà:
6681 FObj
.Vel
.X
:= z_dec(FObj
.Vel
.X
, 1);
6683 st
:= g_Obj_Move(@FObj
, True, True, True);
6684 positionChanged(); // this updates spatial accelerators
6686 if WordBool(st
and MOVE_FALLOUT
) then
6688 FState
:= CORPSE_STATE_REMOVEME
;
6692 if FAnimation
<> nil then
6693 FAnimation
.Update();
6694 if FAnimationMask
<> nil then
6695 FAnimationMask
.Update();
6699 procedure TCorpse
.SaveState (st
: TStream
);
6706 utils
.writeSign(st
, 'CORP');
6707 utils
.writeInt(st
, Byte(0));
6709 utils
.writeInt(st
, Byte(FState
));
6711 utils
.writeInt(st
, Byte(FDamage
));
6713 utils
.writeInt(st
, Byte(FColor
.R
));
6714 utils
.writeInt(st
, Byte(FColor
.G
));
6715 utils
.writeInt(st
, Byte(FColor
.B
));
6717 Obj_SaveState(st
, @FObj
);
6718 utils
.writeInt(st
, Word(FPlayerUID
));
6720 anim
:= (FAnimation
<> nil);
6721 utils
.writeBool(st
, anim
);
6722 // Åñëè åñòü - ñîõðàíÿåì
6723 if anim
then FAnimation
.SaveState(st
);
6724 // Åñòü ëè ìàñêà àíèìàöèè
6725 anim
:= (FAnimationMask
<> nil);
6726 utils
.writeBool(st
, anim
);
6727 // Åñëè åñòü - ñîõðàíÿåì
6728 if anim
then FAnimationMask
.SaveState(st
);
6732 procedure TCorpse
.LoadState (st
: TStream
);
6739 if not utils
.checkSign(st
, 'CORP') then raise XStreamError
.Create('invalid corpse signature');
6740 if (utils
.readByte(st
) <> 0) then raise XStreamError
.Create('invalid corpse version');
6742 FState
:= utils
.readByte(st
);
6744 FDamage
:= utils
.readByte(st
);
6746 FColor
.R
:= utils
.readByte(st
);
6747 FColor
.G
:= utils
.readByte(st
);
6748 FColor
.B
:= utils
.readByte(st
);
6750 Obj_LoadState(@FObj
, st
);
6751 FPlayerUID
:= utils
.readWord(st
);
6753 anim
:= utils
.readBool(st
);
6754 // Åñëè åñòü - çàãðóæàåì
6757 Assert(FAnimation
<> nil, 'TCorpse.LoadState: no FAnimation');
6758 FAnimation
.LoadState(st
);
6760 // Åñòü ëè ìàñêà àíèìàöèè
6761 anim
:= utils
.readBool(st
);
6762 // Åñëè åñòü - çàãðóæàåì
6765 Assert(FAnimationMask
<> nil, 'TCorpse.LoadState: no FAnimationMask');
6766 FAnimationMask
.LoadState(st
);
6772 constructor TBot
.Create();
6779 FSpectator
:= False;
6786 for a
:= WP_FIRST
to WP_LAST
do
6788 FDifficult
.WeaponPrior
[a
] := WEAPON_PRIOR1
[a
];
6789 FDifficult
.CloseWeaponPrior
[a
] := WEAPON_PRIOR2
[a
];
6790 //FDifficult.SafeWeaponPrior[a] := WEAPON_PRIOR3[a];
6794 destructor TBot
.Destroy();
6797 inherited Destroy();
6800 procedure TBot
.Draw();
6804 //if FTargetUID <> 0 then e_DrawLine(1, FObj.X, FObj.Y, g_Player_Get(FTargetUID).FObj.X,
6805 // g_Player_Get(FTargetUID).FObj.Y, 255, 0, 0);
6808 procedure TBot
.Respawn(Silent
: Boolean; Force
: Boolean = False);
6810 inherited Respawn(Silent
, Force
);
6813 FSelectedWeapon
:= FCurrWeap
;
6818 procedure TBot
.UpdateCombat();
6831 TTargetRecord
= array of TTarget
;
6833 function Compare(a
, b
: TTarget
): Integer;
6835 if a
.Line
and not b
.Line
then // A íà ëèíèè îãíÿ
6838 if not a
.Line
and b
.Line
then // B íà ëèíèè îãíÿ
6840 else // È A, è B íà ëèíèè èëè íå íà ëèíèè îãíÿ
6841 if (a
.Line
and b
.Line
) or ((not a
.Line
) and (not b
.Line
)) then
6843 if a
.Dist
> b
.Dist
then // B áëèæå
6845 else // A áëèæå èëè ðàâíîóäàëåííî ñ B
6848 else // Ñòðàííî -> A
6853 a
, x1
, y1
, x2
, y2
: Integer;
6854 targets
: TTargetRecord
;
6856 Target
, BestTarget
: TTarget
;
6857 firew
, fireh
: Integer;
6861 vsPlayer
, vsMonster
, ok
: Boolean;
6864 function monsUpdate (mon
: TMonster
): Boolean;
6866 result
:= false; // don't stop
6867 if mon
.alive
and (mon
.MonsterType
<> MONSTER_BARREL
) then
6869 if not TargetOnScreen(mon
.Obj
.X
+mon
.Obj
.Rect
.X
, mon
.Obj
.Y
+mon
.Obj
.Rect
.Y
) then exit
;
6871 x2
:= mon
.Obj
.X
+mon
.Obj
.Rect
.X
+(mon
.Obj
.Rect
.Width
div 2);
6872 y2
:= mon
.Obj
.Y
+mon
.Obj
.Rect
.Y
+(mon
.Obj
.Rect
.Height
div 2);
6874 // Åñëè ìîíñòð íà ýêðàíå è íå ïðèêðûò ñòåíîé
6875 if g_TraceVector(x1
, y1
, x2
, y2
) then
6877 // Äîáàâëÿåì ê ñïèñêó âîçìîæíûõ öåëåé
6878 SetLength(targets
, Length(targets
)+1);
6879 with targets
[High(targets
)] do
6886 Rect
:= mon
.Obj
.Rect
;
6887 Dist
:= g_PatchLength(x1
, y1
, x2
, y2
);
6888 Line
:= (y1
+4 < Target
.Y
+ mon
.Obj
.Rect
.Y
+ mon
.Obj
.Rect
.Height
) and
6889 (y1
-4 > Target
.Y
+ mon
.Obj
.Rect
.Y
);
6898 vsPlayer
:= LongBool(gGameSettings
.Options
and GAME_OPTION_BOTVSPLAYER
);
6899 vsMonster
:= LongBool(gGameSettings
.Options
and GAME_OPTION_BOTVSMONSTER
);
6901 // Åñëè òåêóùåå îðóæèå íå òî, ÷òî íóæíî, òî ìåíÿåì:
6902 if FCurrWeap
<> FSelectedWeapon
then
6905 // Åñëè íóæíî ñòðåëÿòü è íóæíîå îðóæèå, òî íàæàòü "Ñòðåëÿòü":
6906 if (GetAIFlag('NEEDFIRE') <> '') and (FCurrWeap
= FSelectedWeapon
) then
6908 RemoveAIFlag('NEEDFIRE');
6911 WEAPON_PLASMA
, WEAPON_SUPERPULEMET
, WEAPON_CHAINGUN
: PressKey(KEY_FIRE
, 20);
6912 WEAPON_SAW
, WEAPON_KASTET
, WEAPON_FLAMETHROWER
: PressKey(KEY_FIRE
, 40);
6913 else PressKey(KEY_FIRE
);
6917 // Êîîðäèíàòû ñòâîëà:
6918 x1
:= FObj
.X
+ WEAPONPOINT
[FDirection
].X
;
6919 y1
:= FObj
.Y
+ WEAPONPOINT
[FDirection
].Y
;
6921 Target
.UID
:= FTargetUID
;
6924 if Target
.UID
<> 0 then
6925 begin // Öåëü åñòü - íàñòðàèâàåì
6926 if (g_GetUIDType(Target
.UID
) = UID_PLAYER
) and
6929 tpla
:= g_Player_Get(Target
.UID
);
6933 if (@FObj
) <> nil then
6940 Target
.cX
:= Target
.X
+ PLAYER_RECT_CX
;
6941 Target
.cY
:= Target
.Y
+ PLAYER_RECT_CY
;
6942 Target
.Rect
:= PLAYER_RECT
;
6943 Target
.Visible
:= g_TraceVector(x1
, y1
, Target
.cX
, Target
.cY
);
6944 Target
.Line
:= (y1
+4 < Target
.Y
+PLAYER_RECT
.Y
+PLAYER_RECT
.Height
) and
6945 (y1
-4 > Target
.Y
+PLAYER_RECT
.Y
);
6946 Target
.IsPlayer
:= True;
6950 if (g_GetUIDType(Target
.UID
) = UID_MONSTER
) and
6953 mon
:= g_Monsters_ByUID(Target
.UID
);
6956 Target
.X
:= mon
.Obj
.X
;
6957 Target
.Y
:= mon
.Obj
.Y
;
6959 Target
.cX
:= Target
.X
+ mon
.Obj
.Rect
.X
+ (mon
.Obj
.Rect
.Width
div 2);
6960 Target
.cY
:= Target
.Y
+ mon
.Obj
.Rect
.Y
+ (mon
.Obj
.Rect
.Height
div 2);
6961 Target
.Rect
:= mon
.Obj
.Rect
;
6962 Target
.Visible
:= g_TraceVector(x1
, y1
, Target
.cX
, Target
.cY
);
6963 Target
.Line
:= (y1
+4 < Target
.Y
+ mon
.Obj
.Rect
.Y
+ mon
.Obj
.Rect
.Height
) and
6964 (y1
-4 > Target
.Y
+ mon
.Obj
.Rect
.Y
);
6965 Target
.IsPlayer
:= False;
6972 begin // Öåëè íåò - îáíóëÿåì
6977 Target
.Visible
:= False;
6978 Target
.Line
:= False;
6979 Target
.IsPlayer
:= False;
6984 // Åñëè öåëü íå âèäèìà èëè íå íà ëèíèè îãíÿ, òî èùåì âñå âîçìîæíûå öåëè:
6985 if (not Target
.Line
) or (not Target
.Visible
) then
6989 for a
:= 0 to High(gPlayers
) do
6990 if (gPlayers
[a
] <> nil) and (gPlayers
[a
].alive
) and
6991 (gPlayers
[a
].FUID
<> FUID
) and
6992 (not SameTeam(FUID
, gPlayers
[a
].FUID
)) and
6993 (not gPlayers
[a
].NoTarget
) and
6994 (gPlayers
[a
].FMegaRulez
[MR_INVIS
] < gTime
) then
6996 if not TargetOnScreen(gPlayers
[a
].FObj
.X
+ PLAYER_RECT
.X
,
6997 gPlayers
[a
].FObj
.Y
+ PLAYER_RECT
.Y
) then
7000 x2
:= gPlayers
[a
].FObj
.X
+ PLAYER_RECT_CX
;
7001 y2
:= gPlayers
[a
].FObj
.Y
+ PLAYER_RECT_CY
;
7003 // Åñëè èãðîê íà ýêðàíå è íå ïðèêðûò ñòåíîé:
7004 if g_TraceVector(x1
, y1
, x2
, y2
) then
7006 // Äîáàâëÿåì ê ñïèñêó âîçìîæíûõ öåëåé:
7007 SetLength(targets
, Length(targets
)+1);
7008 with targets
[High(targets
)] do
7010 UID
:= gPlayers
[a
].FUID
;
7011 X
:= gPlayers
[a
].FObj
.X
;
7012 Y
:= gPlayers
[a
].FObj
.Y
;
7015 Rect
:= PLAYER_RECT
;
7016 Dist
:= g_PatchLength(x1
, y1
, x2
, y2
);
7017 Line
:= (y1
+4 < Target
.Y
+PLAYER_RECT
.Y
+PLAYER_RECT
.Height
) and
7018 (y1
-4 > Target
.Y
+PLAYER_RECT
.Y
);
7026 if vsMonster
then g_Mons_ForEach(monsUpdate
);
7029 // Åñëè åñòü âîçìîæíûå öåëè:
7030 // (Âûáèðàåì ëó÷øóþ, ìåíÿåì îðóæèå è áåæèì ê íåé/îò íåå)
7031 if targets
<> nil then
7033 // Âûáèðàåì íàèëó÷øóþ öåëü:
7034 BestTarget
:= targets
[0];
7035 if Length(targets
) > 1 then
7036 for a
:= 1 to High(targets
) do
7037 if Compare(BestTarget
, targets
[a
]) = 1 then
7038 BestTarget
:= targets
[a
];
7040 // Åñëè ëó÷øàÿ öåëü "âèäíåå" òåêóùåé, òî òåêóùàÿ := ëó÷øàÿ:
7041 if ((not Target
.Visible
) and BestTarget
.Visible
and (Target
.UID
<> BestTarget
.UID
)) or
7042 ((not Target
.Line
) and BestTarget
.Line
and BestTarget
.Visible
) then
7044 Target
:= BestTarget
;
7046 if (Healthy() = 3) or ((Healthy() = 2)) then
7047 begin // Åñëè çäîðîâû - äîãîíÿåì
7048 if ((RunDirection() = TDirection
.D_LEFT
) and (Target
.X
> FObj
.X
)) then
7049 SetAIFlag('GORIGHT', '1');
7050 if ((RunDirection() = TDirection
.D_RIGHT
) and (Target
.X
< FObj
.X
)) then
7051 SetAIFlag('GOLEFT', '1');
7054 begin // Åñëè ïîáèòû - óáåãàåì
7055 if ((RunDirection() = TDirection
.D_LEFT
) and (Target
.X
< FObj
.X
)) then
7056 SetAIFlag('GORIGHT', '1');
7057 if ((RunDirection() = TDirection
.D_RIGHT
) and (Target
.X
> FObj
.X
)) then
7058 SetAIFlag('GOLEFT', '1');
7061 // Âûáèðàåì îðóæèå íà îñíîâå ðàññòîÿíèÿ è ïðèîðèòåòîâ:
7062 SelectWeapon(Abs(x1
-Target
.cX
));
7067 // (Äîãîíÿåì/óáåãàåì, ñòðåëÿåì ïî íàïðàâëåíèþ ê öåëè)
7068 // (Åñëè öåëü äàëåêî, òî õâàòèò ñëåäèòü çà íåé)
7069 if Target
.UID
<> 0 then
7071 if not TargetOnScreen(Target
.X
+ Target
.Rect
.X
,
7072 Target
.Y
+ Target
.Rect
.Y
) then
7073 begin // Öåëü ñáåæàëà ñ "ýêðàíà"
7074 if (Healthy() = 3) or ((Healthy() = 2)) then
7075 begin // Åñëè çäîðîâû - äîãîíÿåì
7076 if ((RunDirection() = TDirection
.D_LEFT
) and (Target
.X
> FObj
.X
)) then
7077 SetAIFlag('GORIGHT', '1');
7078 if ((RunDirection() = TDirection
.D_RIGHT
) and (Target
.X
< FObj
.X
)) then
7079 SetAIFlag('GOLEFT', '1');
7082 begin // Åñëè ïîáèòû - çàáûâàåì î öåëè è óáåãàåì
7084 if ((RunDirection() = TDirection
.D_LEFT
) and (Target
.X
< FObj
.X
)) then
7085 SetAIFlag('GORIGHT', '1');
7086 if ((RunDirection() = TDirection
.D_RIGHT
) and (Target
.X
> FObj
.X
)) then
7087 SetAIFlag('GOLEFT', '1');
7091 begin // Öåëü ïîêà íà "ýêðàíå"
7092 // Åñëè öåëü íå çàãîðîæåíà ñòåíîé, òî îòìå÷àåì, êîãäà åå âèäåëè:
7093 if g_TraceVector(x1
, y1
, Target
.cX
, Target
.cY
) then
7094 FLastVisible
:= gTime
;
7095 // Åñëè ðàçíèöà âûñîò íå âåëèêà, òî äîãîíÿåì:
7096 if (Abs(FObj
.Y
-Target
.Y
) <= 128) then
7098 if ((RunDirection() = TDirection
.D_LEFT
) and (Target
.X
> FObj
.X
)) then
7099 SetAIFlag('GORIGHT', '1');
7100 if ((RunDirection() = TDirection
.D_RIGHT
) and (Target
.X
< FObj
.X
)) then
7101 SetAIFlag('GOLEFT', '1');
7105 // Âûáèðàåì óãîë ââåðõ:
7106 if FDirection
= TDirection
.D_LEFT
then
7107 angle
:= ANGLE_LEFTUP
7109 angle
:= ANGLE_RIGHTUP
;
7111 firew
:= Trunc(Cos(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
7112 fireh
:= Trunc(Sin(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
7114 // Åñëè ïðè óãëå ââåðõ ìîæíî ïîïàñòü â ïðèáëèçèòåëüíîå ïîëîæåíèå öåëè:
7115 if g_CollideLine(x1
, y1
, x1
+firew
, y1
+fireh
,
7116 Target
.X
+Target
.Rect
.X
+GetInterval(FDifficult
.DiagPrecision
, 128), //96
7117 Target
.Y
+Target
.Rect
.Y
+GetInterval(FDifficult
.DiagPrecision
, 128),
7118 Target
.Rect
.Width
, Target
.Rect
.Height
) and
7119 g_TraceVector(x1
, y1
, Target
.cX
, Target
.cY
) then
7120 begin // òî íóæíî ñòðåëÿòü ââåðõ
7121 SetAIFlag('NEEDFIRE', '1');
7122 SetAIFlag('NEEDSEEUP', '1');
7125 // Âûáèðàåì óãîë âíèç:
7126 if FDirection
= TDirection
.D_LEFT
then
7127 angle
:= ANGLE_LEFTDOWN
7129 angle
:= ANGLE_RIGHTDOWN
;
7131 firew
:= Trunc(Cos(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
7132 fireh
:= Trunc(Sin(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
7134 // Åñëè ïðè óãëå âíèç ìîæíî ïîïàñòü â ïðèáëèçèòåëüíîå ïîëîæåíèå öåëè:
7135 if g_CollideLine(x1
, y1
, x1
+firew
, y1
+fireh
,
7136 Target
.X
+Target
.Rect
.X
+GetInterval(FDifficult
.DiagPrecision
, 128),
7137 Target
.Y
+Target
.Rect
.Y
+GetInterval(FDifficult
.DiagPrecision
, 128),
7138 Target
.Rect
.Width
, Target
.Rect
.Height
) and
7139 g_TraceVector(x1
, y1
, Target
.cX
, Target
.cY
) then
7140 begin // òî íóæíî ñòðåëÿòü âíèç
7141 SetAIFlag('NEEDFIRE', '1');
7142 SetAIFlag('NEEDSEEDOWN', '1');
7145 // Åñëè öåëü âèäíî è îíà íà òàêîé æå âûñîòå:
7146 if Target
.Visible
and
7147 (y1
+4 < Target
.Y
+Target
.Rect
.Y
+Target
.Rect
.Height
) and
7148 (y1
-4 > Target
.Y
+Target
.Rect
.Y
) then
7150 // Åñëè èäåì â ñòîðîíó öåëè, òî íàäî ñòðåëÿòü:
7151 if ((FDirection
= TDirection
.D_LEFT
) and (Target
.X
< FObj
.X
)) or
7152 ((FDirection
= TDirection
.D_RIGHT
) and (Target
.X
> FObj
.X
)) then
7153 begin // òî íóæíî ñòðåëÿòü âïåðåä
7154 SetAIFlag('NEEDFIRE', '1');
7155 SetAIFlag('NEEDSEEDOWN', '');
7156 SetAIFlag('NEEDSEEUP', '');
7158 // Åñëè öåëü â ïðåäåëàõ "ýêðàíà" è ñëîæíîñòü ïîçâîëÿåò ïðûæêè ñáëèæåíèÿ:
7159 if Abs(FObj
.X
-Target
.X
) < Trunc(gPlayerScreenSize
.X
*0.75) then
7160 if GetRnd(FDifficult
.CloseJump
) then
7161 begin // òî åñëè ïîâåçåò - ïðûãàåì (îñîáåííî, åñëè áëèçêî)
7162 if Abs(FObj
.X
-Target
.X
) < 128 then
7166 if Random(a
) = 0 then
7167 SetAIFlag('NEEDJUMP', '1');
7171 // Åñëè öåëü âñå åùå åñòü:
7172 if Target
.UID
<> 0 then
7173 if gTime
-FLastVisible
> 2000 then // Åñëè âèäåëè äàâíî
7174 Target
.UID
:= 0 // òî çàáûòü öåëü
7175 else // Åñëè âèäåëè íåäàâíî
7176 begin // íî öåëü óáèëè
7177 if Target
.IsPlayer
then
7178 begin // Öåëü - èãðîê
7179 pla
:= g_Player_Get(Target
.UID
);
7180 if (pla
= nil) or (not pla
.alive
) or pla
.NoTarget
or
7181 (pla
.FMegaRulez
[MR_INVIS
] >= gTime
) then
7182 Target
.UID
:= 0; // òî çàáûòü öåëü
7185 begin // Öåëü - ìîíñòð
7186 mon
:= g_Monsters_ByUID(Target
.UID
);
7187 if (mon
= nil) or (not mon
.alive
) then
7188 Target
.UID
:= 0; // òî çàáûòü öåëü
7191 end; // if Target.UID <> 0
7193 FTargetUID
:= Target
.UID
;
7195 // Åñëè âîçìîæíûõ öåëåé íåò:
7196 // (Àòàêà ÷åãî-íèáóäü ñëåâà èëè ñïðàâà)
7197 if targets
= nil then
7198 if GetAIFlag('ATTACKLEFT') <> '' then
7199 begin // Åñëè íóæíî àòàêîâàòü íàëåâî
7200 RemoveAIFlag('ATTACKLEFT');
7202 SetAIFlag('NEEDJUMP', '1');
7204 if RunDirection() = TDirection
.D_RIGHT
then
7205 begin // Èäåì íå â òó ñòîðîíó
7206 if (Healthy() > 1) and GetRnd(FDifficult
.InvisFire
) then
7207 begin // Åñëè çäîðîâû, òî, âîçìîæíî, ñòðåëÿåì áåæèì âëåâî è ñòðåëÿåì
7208 SetAIFlag('NEEDFIRE', '1');
7209 SetAIFlag('GOLEFT', '1');
7213 begin // Èäåì â íóæíóþ ñòîðîíó
7214 if GetRnd(FDifficult
.InvisFire
) then // Âîçìîæíî, ñòðåëÿåì âñëåïóþ
7215 SetAIFlag('NEEDFIRE', '1');
7216 if Healthy() <= 1 then // Ïîáèòû - óáåãàåì
7217 SetAIFlag('GORIGHT', '1');
7221 if GetAIFlag('ATTACKRIGHT') <> '' then
7222 begin // Åñëè íóæíî àòàêîâàòü íàïðàâî
7223 RemoveAIFlag('ATTACKRIGHT');
7225 SetAIFlag('NEEDJUMP', '1');
7227 if RunDirection() = TDirection
.D_LEFT
then
7228 begin // Èäåì íå â òó ñòîðîíó
7229 if (Healthy() > 1) and GetRnd(FDifficult
.InvisFire
) then
7230 begin // Åñëè çäîðîâû, òî, âîçìîæíî, áåæèì âïðàâî è ñòðåëÿåì
7231 SetAIFlag('NEEDFIRE', '1');
7232 SetAIFlag('GORIGHT', '1');
7237 if GetRnd(FDifficult
.InvisFire
) then // Âîçìîæíî, ñòðåëÿåì âñëåïóþ
7238 SetAIFlag('NEEDFIRE', '1');
7239 if Healthy() <= 1 then // Ïîáèòû - óáåãàåì
7240 SetAIFlag('GOLEFT', '1');
7244 //HACK! (does it belongs there?)
7245 RealizeCurrentWeapon();
7247 // Åñëè åñòü âîçìîæíûå öåëè:
7248 // (Ñòðåëÿåì ïî íàïðàâëåíèþ ê öåëÿì)
7249 if (targets
<> nil) and (GetAIFlag('NEEDFIRE') <> '') then
7250 for a
:= 0 to High(targets
) do
7252 // Åñëè ìîæåì ñòðåëÿòü ïî äèàãîíàëè:
7253 if GetRnd(FDifficult
.DiagFire
) then
7255 // Èùåì öåëü ñâåðõó è ñòðåëÿåì, åñëè åñòü:
7256 if FDirection
= TDirection
.D_LEFT
then
7257 angle
:= ANGLE_LEFTUP
7259 angle
:= ANGLE_RIGHTUP
;
7261 firew
:= Trunc(Cos(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
7262 fireh
:= Trunc(Sin(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
7264 if g_CollideLine(x1
, y1
, x1
+firew
, y1
+fireh
,
7265 targets
[a
].X
+targets
[a
].Rect
.X
+GetInterval(FDifficult
.DiagPrecision
, 128),
7266 targets
[a
].Y
+targets
[a
].Rect
.Y
+GetInterval(FDifficult
.DiagPrecision
, 128),
7267 targets
[a
].Rect
.Width
, targets
[a
].Rect
.Height
) and
7268 g_TraceVector(x1
, y1
, targets
[a
].cX
, targets
[a
].cY
) then
7270 SetAIFlag('NEEDFIRE', '1');
7271 SetAIFlag('NEEDSEEUP', '1');
7274 // Èùåì öåëü ñíèçó è ñòðåëÿåì, åñëè åñòü:
7275 if FDirection
= TDirection
.D_LEFT
then
7276 angle
:= ANGLE_LEFTDOWN
7278 angle
:= ANGLE_RIGHTDOWN
;
7280 firew
:= Trunc(Cos(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
7281 fireh
:= Trunc(Sin(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
7283 if g_CollideLine(x1
, y1
, x1
+firew
, y1
+fireh
,
7284 targets
[a
].X
+targets
[a
].Rect
.X
+GetInterval(FDifficult
.DiagPrecision
, 128),
7285 targets
[a
].Y
+targets
[a
].Rect
.Y
+GetInterval(FDifficult
.DiagPrecision
, 128),
7286 targets
[a
].Rect
.Width
, targets
[a
].Rect
.Height
) and
7287 g_TraceVector(x1
, y1
, targets
[a
].cX
, targets
[a
].cY
) then
7289 SetAIFlag('NEEDFIRE', '1');
7290 SetAIFlag('NEEDSEEDOWN', '1');
7294 // Åñëè öåëü "ïåðåä íîñîì", òî ñòðåëÿåì:
7295 if targets
[a
].Line
and targets
[a
].Visible
and
7296 (((FDirection
= TDirection
.D_LEFT
) and (targets
[a
].X
< FObj
.X
)) or
7297 ((FDirection
= TDirection
.D_RIGHT
) and (targets
[a
].X
> FObj
.X
))) then
7299 SetAIFlag('NEEDFIRE', '1');
7304 // Åñëè ëåòèò ïóëÿ, òî, âîçìîæíî, ïîäïðûãèâàåì:
7305 if g_Weapon_Danger(FUID
, FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+PLAYER_RECT
.Y
,
7306 PLAYER_RECT
.Width
, PLAYER_RECT
.Height
,
7307 40+GetInterval(FDifficult
.Cover
, 40)) then
7308 SetAIFlag('NEEDJUMP', '1');
7310 // Åñëè êîí÷èëèñü ïàòîðíû, òî íóæíî ñìåíèòü îðóæèå:
7311 ammo
:= GetAmmoByWeapon(FCurrWeap
);
7312 if ((FCurrWeap
= WEAPON_SHOTGUN2
) and (ammo
< 2)) or
7313 ((FCurrWeap
= WEAPON_BFG
) and (ammo
< 40)) or
7315 SetAIFlag('SELECTWEAPON', '1');
7317 // Åñëè íóæíî ñìåíèòü îðóæèå, òî âûáèðàåì íóæíîå:
7318 if GetAIFlag('SELECTWEAPON') = '1' then
7321 RemoveAIFlag('SELECTWEAPON');
7325 procedure TBot
.Update();
7338 // Ïðîâåðÿåì, îòêëþ÷¸í ëè AI áîòîâ
7339 if (g_debug_BotAIOff
= 1) and (Team
= TEAM_RED
) then
7341 if (g_debug_BotAIOff
= 2) and (Team
= TEAM_BLUE
) then
7343 if g_debug_BotAIOff
= 3 then
7353 RealizeCurrentWeapon();
7360 procedure TBot
.ReleaseKey(Key
: Byte);
7369 function TBot
.KeyPressed(Key
: Word): Boolean;
7371 Result
:= FKeys
[Key
].Pressed
;
7374 function TBot
.GetAIFlag(aName
: String20
): String20
;
7380 aName
:= LowerCase(aName
);
7382 if FAIFlags
<> nil then
7383 for a
:= 0 to High(FAIFlags
) do
7384 if LowerCase(FAIFlags
[a
].Name
) = aName
then
7386 Result
:= FAIFlags
[a
].Value
;
7391 procedure TBot
.RemoveAIFlag(aName
: String20
);
7395 if FAIFlags
= nil then Exit
;
7397 aName
:= LowerCase(aName
);
7399 for a
:= 0 to High(FAIFlags
) do
7400 if LowerCase(FAIFlags
[a
].Name
) = aName
then
7402 if a
<> High(FAIFlags
) then
7403 for b
:= a
to High(FAIFlags
)-1 do
7404 FAIFlags
[b
] := FAIFlags
[b
+1];
7406 SetLength(FAIFlags
, Length(FAIFlags
)-1);
7411 procedure TBot
.SetAIFlag(aName
, fValue
: String20
);
7419 aName
:= LowerCase(aName
);
7421 if FAIFlags
<> nil then
7422 for a
:= 0 to High(FAIFlags
) do
7423 if LowerCase(FAIFlags
[a
].Name
) = aName
then
7429 if ok
then FAIFlags
[a
].Value
:= fValue
7432 SetLength(FAIFlags
, Length(FAIFlags
)+1);
7433 with FAIFlags
[High(FAIFlags
)] do
7441 procedure TBot
.UpdateMove
;
7443 procedure GoLeft(Time
: Word = 1);
7445 ReleaseKey(KEY_LEFT
);
7446 ReleaseKey(KEY_RIGHT
);
7447 PressKey(KEY_LEFT
, Time
);
7448 SetDirection(TDirection
.D_LEFT
);
7451 procedure GoRight(Time
: Word = 1);
7453 ReleaseKey(KEY_LEFT
);
7454 ReleaseKey(KEY_RIGHT
);
7455 PressKey(KEY_RIGHT
, Time
);
7456 SetDirection(TDirection
.D_RIGHT
);
7459 function Rnd(a
: Word): Boolean;
7461 Result
:= Random(a
) = 0;
7464 procedure Turn(Time
: Word = 1200);
7466 if RunDirection() = TDirection
.D_LEFT
then GoRight(Time
) else GoLeft(Time
);
7471 ReleaseKey(KEY_LEFT
);
7472 ReleaseKey(KEY_RIGHT
);
7475 function CanRunLeft(): Boolean;
7477 Result
:= not CollideLevel(-1, 0);
7480 function CanRunRight(): Boolean;
7482 Result
:= not CollideLevel(1, 0);
7485 function CanRun(): Boolean;
7487 if RunDirection() = TDirection
.D_LEFT
then Result
:= CanRunLeft() else Result
:= CanRunRight();
7490 procedure Jump(Time
: Word = 30);
7492 PressKey(KEY_JUMP
, Time
);
7495 function NearHole(): Boolean;
7499 { TODO 5 : Ëåñòíèöû }
7500 sx
:= IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1);
7501 for x
:= 1 to PLAYER_RECT
.Width
do
7502 if (not StayOnStep(x
*sx
, 0)) and
7503 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
)) and
7504 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
*2)) then
7513 function BorderHole(): Boolean;
7517 { TODO 5 : Ëåñòíèöû }
7518 sx
:= IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1);
7519 for x
:= 1 to PLAYER_RECT
.Width
do
7520 if (not StayOnStep(x
*sx
, 0)) and
7521 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
)) and
7522 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
*2)) then
7524 for xx
:= x
to x
+32 do
7525 if CollideLevel(xx
*sx
, PLAYER_RECT
.Height
) then
7535 function NearDeepHole(): Boolean;
7541 sx
:= IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1);
7544 for x
:= 1 to PLAYER_RECT
.Width
do
7545 if (not StayOnStep(x
*sx
, 0)) and
7546 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
)) and
7547 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
*2)) then
7549 while FObj
.Y
+y
*PLAYER_RECT
.Height
< gMapInfo
.Height
do
7551 if CollideLevel(x
*sx
, PLAYER_RECT
.Height
*y
) then Exit
;
7556 end else Result
:= False;
7559 function OverDeepHole(): Boolean;
7566 while FObj
.Y
+y
*PLAYER_RECT
.Height
< gMapInfo
.Height
do
7568 if CollideLevel(0, PLAYER_RECT
.Height
*y
) then Exit
;
7575 function OnGround(): Boolean;
7577 Result
:= StayOnStep(0, 0) or CollideLevel(0, 1);
7580 function OnLadder(): Boolean;
7582 Result
:= FullInStep(0, 0);
7585 function BelowLadder(): Boolean;
7587 Result
:= (FullInStep(IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -PLAYER_RECT
.Height
) and
7588 not CollideLevel(IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -PLAYER_RECT
.Height
)) or
7589 (FullInStep(IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -BOT_MAXJUMP
) and
7590 not CollideLevel(IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -BOT_MAXJUMP
));
7593 function BelowLiftUp(): Boolean;
7595 Result
:= ((FullInLift(IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -PLAYER_RECT
.Height
) = -1) and
7596 not CollideLevel(IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -PLAYER_RECT
.Height
)) or
7597 ((FullInLift(IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -BOT_MAXJUMP
) = -1) and
7598 not CollideLevel(IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -BOT_MAXJUMP
));
7601 function OnTopLift(): Boolean;
7603 Result
:= (FullInLift(0, 0) = -1) and (FullInLift(0, -32) = 0);
7606 function CanJumpOver(): Boolean;
7610 sx
:= IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1);
7614 if not CollideLevel(sx
, 0) then Exit
;
7616 for y
:= 1 to BOT_MAXJUMP
do
7617 if CollideLevel(0, -y
) then Exit
else
7618 if not CollideLevel(sx
, -y
) then
7625 function CanJumpUp(Dist
: ShortInt): Boolean;
7632 if CollideLevel(Dist
, 0) then Exit
;
7635 for y
:= 0 to BOT_MAXJUMP
do
7636 if CollideLevel(Dist
, -y
) then
7645 for yy
:= y
+1 to BOT_MAXJUMP
do
7646 if not CollideLevel(Dist
, -yy
) then
7655 for y
:= 0 to BOT_MAXJUMP
do
7656 if CollideLevel(0, -y
) then
7664 if y
< yy
then Exit
;
7669 function IsSafeTrigger(): Boolean;
7674 if gTriggers
= nil then
7676 for a
:= 0 to High(gTriggers
) do
7677 if Collide(gTriggers
[a
].X
,
7680 gTriggers
[a
].Height
) and
7681 (gTriggers
[a
].TriggerType
in [TRIGGER_EXIT
, TRIGGER_CLOSEDOOR
,
7682 TRIGGER_CLOSETRAP
, TRIGGER_TRAP
,
7683 TRIGGER_PRESS
, TRIGGER_ON
, TRIGGER_OFF
,
7684 TRIGGER_ONOFF
, TRIGGER_SPAWNMONSTER
,
7685 TRIGGER_DAMAGE
, TRIGGER_SHOT
]) then
7690 // Âîçìîæíî, íàæèìàåì êíîïêó:
7691 if Rnd(16) and IsSafeTrigger() then
7694 // Åñëè ïîä ëèôòîì èëè ñòóïåíüêàìè, òî, âîçìîæíî, ïðûãàåì:
7695 if OnLadder() or ((BelowLadder() or BelowLiftUp()) and Rnd(8)) then
7697 ReleaseKey(KEY_LEFT
);
7698 ReleaseKey(KEY_RIGHT
);
7702 // Èäåì âëåâî, åñëè íàäî áûëî:
7703 if GetAIFlag('GOLEFT') <> '' then
7705 RemoveAIFlag('GOLEFT');
7706 if CanRunLeft() then
7710 // Èäåì âïðàâî, åñëè íàäî áûëî:
7711 if GetAIFlag('GORIGHT') <> '' then
7713 RemoveAIFlag('GORIGHT');
7714 if CanRunRight() then
7718 // Åñëè âûëåòåëè çà êàðòó, òî ïðîáóåì âåðíóòüñÿ:
7719 if FObj
.X
< -32 then
7722 if FObj
.X
+32 > gMapInfo
.Width
then
7725 // Ïðûãàåì, åñëè íàäî áûëî:
7726 if GetAIFlag('NEEDJUMP') <> '' then
7729 RemoveAIFlag('NEEDJUMP');
7732 // Ñìîòðèì ââåðõ, åñëè íàäî áûëî:
7733 if GetAIFlag('NEEDSEEUP') <> '' then
7736 ReleaseKey(KEY_DOWN
);
7737 PressKey(KEY_UP
, 20);
7738 RemoveAIFlag('NEEDSEEUP');
7741 // Ñìîòðèì âíèç, åñëè íàäî áûëî:
7742 if GetAIFlag('NEEDSEEDOWN') <> '' then
7745 ReleaseKey(KEY_DOWN
);
7746 PressKey(KEY_DOWN
, 20);
7747 RemoveAIFlag('NEEDSEEDOWN');
7750 // Åñëè íóæíî áûëî â äûðó è ìû íå íà çåìëå, òî ïîêîðíî ëåòèì:
7751 if GetAIFlag('GOINHOLE') <> '' then
7752 if not OnGround() then
7754 ReleaseKey(KEY_LEFT
);
7755 ReleaseKey(KEY_RIGHT
);
7756 RemoveAIFlag('GOINHOLE');
7757 SetAIFlag('FALLINHOLE', '1');
7760 // Åñëè ïàäàëè è äîñòèãëè çåìëè, òî õâàòèò ïàäàòü:
7761 if GetAIFlag('FALLINHOLE') <> '' then
7763 RemoveAIFlag('FALLINHOLE');
7765 // Åñëè ëåòåëè ïðÿìî è ñåé÷àñ íå íà ëåñòíèöå èëè íà âåðøèíå ëèôòà, òî îòõîäèì â ñòîðîíó:
7766 if not (KeyPressed(KEY_LEFT
) or KeyPressed(KEY_RIGHT
)) then
7767 if GetAIFlag('FALLINHOLE') = '' then
7768 if (not OnLadder()) or (FObj
.Vel
.Y
>= 0) or (OnTopLift()) then
7774 // Åñëè íà çåìëå è ìîæíî ïîäïðûãíóòü, òî, âîçìîæíî, ïðûãàåì:
7776 CanJumpUp(IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1)*32) and
7780 // Åñëè íà çåìëå è âîçëå äûðû (ãëóáèíà > 2 ðîñòîâ èãðîêà):
7781 if OnGround() and NearHole() then
7782 if NearDeepHole() then // Åñëè ýòî áåçäíà
7784 0..3: Turn(); // Áåæèì îáðàòíî
7785 4: Jump(); // Ïðûãàåì
7786 5: begin // Ïðûãàåì îáðàòíî
7791 else // Ýòî íå áåçäíà è ìû åùå íå ëåòèì òóäà
7792 if GetAIFlag('GOINHOLE') = '' then
7794 0: Turn(); // Íå íóæíî òóäà
7795 1: Jump(); // Âäðóã ïîâåçåò - ïðûãàåì
7796 else // Åñëè ÿìà ñ ãðàíèöåé, òî ïðè ñëó÷àå ìîæíî òóäà ïðûãíóòü
7797 if BorderHole() then
7798 SetAIFlag('GOINHOLE', '1');
7801 // Åñëè íà çåìëå, íî íåêóäà èäòè:
7802 if (not CanRun()) and OnGround() then
7804 // Åñëè ìû íà ëåñòíèöå èëè ìîæíî ïåðåïðûãíóòü, òî ïðûãàåì:
7805 if CanJumpOver() or OnLadder() then
7807 else // èíà÷å ïîïûòàåìñÿ â äðóãóþ ñòîðîíó
7808 if Random(2) = 0 then
7810 if IsSafeTrigger() then
7816 // Îñòàëîñü ìàëî âîçäóõà:
7817 if FAir
< 36 * 2 then
7820 // Âûáèðàåìñÿ èç êèñëîòû, åñëè íåò êîñòþìà, îáîæãëèñü, èëè ìàëî çäîðîâüÿ:
7821 if (FMegaRulez
[MR_SUIT
] < gTime
) and ((FLastHit
= HIT_ACID
) or (Healthy() <= 1)) then
7822 if BodyInAcid(0, 0) then
7826 function TBot
.FullInStep(XInc
, YInc
: Integer): Boolean;
7828 Result
:= g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
,
7829 PLAYER_RECT
.Width
, PLAYER_RECT
.Height
, PANEL_STEP
, False);
7832 {function TBot.NeedItem(Item: Byte): Byte;
7837 procedure TBot
.SelectWeapon(Dist
: Integer);
7841 function HaveAmmo(weapon
: Byte): Boolean;
7844 WEAPON_PISTOL
: Result
:= FAmmo
[A_BULLETS
] >= 1;
7845 WEAPON_SHOTGUN1
: Result
:= FAmmo
[A_SHELLS
] >= 1;
7846 WEAPON_SHOTGUN2
: Result
:= FAmmo
[A_SHELLS
] >= 2;
7847 WEAPON_CHAINGUN
: Result
:= FAmmo
[A_BULLETS
] >= 10;
7848 WEAPON_ROCKETLAUNCHER
: Result
:= FAmmo
[A_ROCKETS
] >= 1;
7849 WEAPON_PLASMA
: Result
:= FAmmo
[A_CELLS
] >= 10;
7850 WEAPON_BFG
: Result
:= FAmmo
[A_CELLS
] >= 40;
7851 WEAPON_SUPERPULEMET
: Result
:= FAmmo
[A_SHELLS
] >= 1;
7852 WEAPON_FLAMETHROWER
: Result
:= FAmmo
[A_FUEL
] >= 1;
7853 else Result
:= True;
7858 if Dist
= -1 then Dist
:= BOT_LONGDIST
;
7860 if Dist
> BOT_LONGDIST
then
7861 begin // Äàëüíèé áîé
7863 if FWeapon
[FDifficult
.WeaponPrior
[a
]] and HaveAmmo(FDifficult
.WeaponPrior
[a
]) then
7865 FSelectedWeapon
:= FDifficult
.WeaponPrior
[a
];
7869 else //if Dist > BOT_UNSAFEDIST then
7870 begin // Áëèæíèé áîé
7872 if FWeapon
[FDifficult
.CloseWeaponPrior
[a
]] and HaveAmmo(FDifficult
.CloseWeaponPrior
[a
]) then
7874 FSelectedWeapon
:= FDifficult
.CloseWeaponPrior
[a
];
7881 if FWeapon[FDifficult.SafeWeaponPrior[a]] and HaveAmmo(FDifficult.SafeWeaponPrior[a]) then
7883 FSelectedWeapon := FDifficult.SafeWeaponPrior[a];
7889 function TBot
.PickItem(ItemType
: Byte; force
: Boolean; var remove
: Boolean): Boolean;
7891 Result
:= inherited PickItem(ItemType
, force
, remove
);
7893 if Result
then SetAIFlag('SELECTWEAPON', '1');
7896 function TBot
.Heal(value
: Word; Soft
: Boolean): Boolean;
7898 Result
:= inherited Heal(value
, Soft
);
7901 function TBot
.Healthy(): Byte;
7903 if FMegaRulez
[MR_INVUL
] >= gTime
then Result
:= 3
7904 else if (FHealth
> 80) or ((FHealth
> 50) and (FArmor
> 20)) then Result
:= 3
7905 else if (FHealth
> 50) then Result
:= 2
7906 else if (FHealth
> 20) then Result
:= 1
7910 function TBot
.TargetOnScreen(TX
, TY
: Integer): Boolean;
7912 Result
:= (Abs(FObj
.X
-TX
) <= Trunc(gPlayerScreenSize
.X
*0.6)) and
7913 (Abs(FObj
.Y
-TY
) <= Trunc(gPlayerScreenSize
.Y
*0.6));
7916 procedure TBot
.OnDamage(Angle
: SmallInt);
7924 if (Angle
= 0) or (Angle
= 180) then
7927 if (g_GetUIDType(FLastSpawnerUID
) = UID_PLAYER
) and
7928 LongBool(gGameSettings
.Options
and GAME_OPTION_BOTVSPLAYER
) then
7930 pla
:= g_Player_Get(FLastSpawnerUID
);
7931 ok
:= not TargetOnScreen(pla
.FObj
.X
+ PLAYER_RECT
.X
,
7932 pla
.FObj
.Y
+ PLAYER_RECT
.Y
);
7935 if (g_GetUIDType(FLastSpawnerUID
) = UID_MONSTER
) and
7936 LongBool(gGameSettings
.Options
and GAME_OPTION_BOTVSMONSTER
) then
7938 mon
:= g_Monsters_ByUID(FLastSpawnerUID
);
7939 ok
:= not TargetOnScreen(mon
.Obj
.X
+ mon
.Obj
.Rect
.X
,
7940 mon
.Obj
.Y
+ mon
.Obj
.Rect
.Y
);
7945 SetAIFlag('ATTACKLEFT', '1')
7947 SetAIFlag('ATTACKRIGHT', '1');
7951 function TBot
.RunDirection(): TDirection
;
7953 if Abs(Vel
.X
) >= 1 then
7955 if Vel
.X
> 0 then Result
:= TDirection
.D_RIGHT
else Result
:= TDirection
.D_LEFT
;
7957 Result
:= FDirection
;
7960 function TBot
.GetRnd(a
: Byte): Boolean;
7962 if a
= 0 then Result
:= False
7963 else if a
= 255 then Result
:= True
7964 else Result
:= Random(256) > 255-a
;
7967 function TBot
.GetInterval(a
: Byte; radius
: SmallInt): SmallInt;
7969 Result
:= Round((255-a
)/255*radius
*(Random(2)-1));
7973 procedure TDifficult
.save (st
: TStream
);
7975 utils
.writeInt(st
, Byte(DiagFire
));
7976 utils
.writeInt(st
, Byte(InvisFire
));
7977 utils
.writeInt(st
, Byte(DiagPrecision
));
7978 utils
.writeInt(st
, Byte(FlyPrecision
));
7979 utils
.writeInt(st
, Byte(Cover
));
7980 utils
.writeInt(st
, Byte(CloseJump
));
7981 st
.WriteBuffer(WeaponPrior
[Low(WeaponPrior
)], sizeof(WeaponPrior
));
7982 st
.WriteBuffer(CloseWeaponPrior
[Low(CloseWeaponPrior
)], sizeof(CloseWeaponPrior
));
7985 procedure TDifficult
.load (st
: TStream
);
7987 DiagFire
:= utils
.readByte(st
);
7988 InvisFire
:= utils
.readByte(st
);
7989 DiagPrecision
:= utils
.readByte(st
);
7990 FlyPrecision
:= utils
.readByte(st
);
7991 Cover
:= utils
.readByte(st
);
7992 CloseJump
:= utils
.readByte(st
);
7993 st
.ReadBuffer(WeaponPrior
[Low(WeaponPrior
)], sizeof(WeaponPrior
));
7994 st
.ReadBuffer(CloseWeaponPrior
[Low(CloseWeaponPrior
)], sizeof(CloseWeaponPrior
));
7998 procedure TBot
.SaveState (st
: TStream
);
8003 inherited SaveState(st
);
8004 utils
.writeSign(st
, 'BOT0');
8006 utils
.writeInt(st
, Byte(FSelectedWeapon
));
8008 utils
.writeInt(st
, Word(FTargetUID
));
8009 // Âðåìÿ ïîòåðè öåëè
8010 utils
.writeInt(st
, LongWord(FLastVisible
));
8011 // Êîëè÷åñòâî ôëàãîâ ÈÈ
8012 dw
:= Length(FAIFlags
);
8013 utils
.writeInt(st
, LongInt(dw
));
8015 for i
:= 0 to dw
-1 do
8017 utils
.writeStr(st
, FAIFlags
[i
].Name
, 20);
8018 utils
.writeStr(st
, FAIFlags
[i
].Value
, 20);
8020 // Íàñòðîéêè ñëîæíîñòè
8021 FDifficult
.save(st
);
8025 procedure TBot
.LoadState (st
: TStream
);
8030 inherited LoadState(st
);
8031 if not utils
.checkSign(st
, 'BOT0') then raise XStreamError
.Create('invalid bot signature');
8033 FSelectedWeapon
:= utils
.readByte(st
);
8035 FTargetUID
:= utils
.readWord(st
);
8036 // Âðåìÿ ïîòåðè öåëè
8037 FLastVisible
:= utils
.readLongWord(st
);
8038 // Êîëè÷åñòâî ôëàãîâ ÈÈ
8039 dw
:= utils
.readLongInt(st
);
8040 if (dw
< 0) or (dw
> 16384) then raise XStreamError
.Create('invalid number of bot AI flags');
8041 SetLength(FAIFlags
, dw
);
8043 for i
:= 0 to dw
-1 do
8045 FAIFlags
[i
].Name
:= utils
.readStr(st
, 20);
8046 FAIFlags
[i
].Value
:= utils
.readStr(st
, 20);
8048 // Íàñòðîéêè ñëîæíîñòè
8049 FDifficult
.load(st
);
8054 conRegVar('cheat_berserk_autoswitch', @gBerserkAutoswitch
, 'autoswitch to fist when berserk pack taken', '', true, true);
8055 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');
8056 conRegVar('player_indicator_style', @gPlayerIndicatorStyle
, 'Visual appearance of indicator', 'Visual appearance of indicator');