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
);
1440 e_TextureFontPrint(0, fH
* 6, 'Old X: ' + IntToStr(p
.FObj
.oldX
), gStdFont
);
1441 e_TextureFontPrint(0, fH
* 7, 'Old Y: ' + IntToStr(p
.FObj
.oldY
), gStdFont
);
1444 procedure g_Player_DrawHealth();
1449 if gPlayers
= nil then Exit
;
1450 e_TextureFontGetSize(gStdFont
, fW
, fH
);
1452 for i
:= 0 to High(gPlayers
) do
1453 if gPlayers
[i
] <> nil then
1455 e_TextureFontPrint(gPlayers
[i
].FObj
.X
+ gPlayers
[i
].FObj
.Rect
.X
,
1456 gPlayers
[i
].FObj
.Y
+ gPlayers
[i
].FObj
.Rect
.Y
+ gPlayers
[i
].FObj
.Rect
.Height
- fH
* 2,
1457 IntToStr(gPlayers
[i
].FHealth
), gStdFont
);
1458 e_TextureFontPrint(gPlayers
[i
].FObj
.X
+ gPlayers
[i
].FObj
.Rect
.X
,
1459 gPlayers
[i
].FObj
.Y
+ gPlayers
[i
].FObj
.Rect
.Y
+ gPlayers
[i
].FObj
.Rect
.Height
- fH
,
1460 IntToStr(gPlayers
[i
].FArmor
), gStdFont
);
1464 function g_Player_Get(UID
: Word): TPlayer
;
1470 if gPlayers
= nil then
1473 for a
:= 0 to High(gPlayers
) do
1474 if gPlayers
[a
] <> nil then
1475 if gPlayers
[a
].FUID
= UID
then
1477 Result
:= gPlayers
[a
];
1482 function g_Player_GetCount(): Byte;
1488 if gPlayers
= nil then
1491 for a
:= 0 to High(gPlayers
) do
1492 if gPlayers
[a
] <> nil then
1493 Result
:= Result
+ 1;
1496 function g_Player_GetStats(): TPlayerStatArray
;
1502 if gPlayers
= nil then Exit
;
1504 for a
:= 0 to High(gPlayers
) do
1505 if gPlayers
[a
] <> nil then
1507 SetLength(Result
, Length(Result
)+1);
1508 with Result
[High(Result
)] do
1511 Ping
:= gPlayers
[a
].FPing
;
1512 Loss
:= gPlayers
[a
].FLoss
;
1513 Name
:= gPlayers
[a
].FName
;
1514 Team
:= gPlayers
[a
].FTeam
;
1515 Frags
:= gPlayers
[a
].FFrags
;
1516 Deaths
:= gPlayers
[a
].FDeath
;
1517 Kills
:= gPlayers
[a
].FKills
;
1518 Color
:= gPlayers
[a
].FModel
.Color
;
1519 Lives
:= gPlayers
[a
].FLives
;
1520 Spectator
:= gPlayers
[a
].FSpectator
;
1525 procedure g_Player_ResetReady();
1529 if not g_Game_IsServer
then Exit
;
1530 if gPlayers
= nil then Exit
;
1532 for a
:= 0 to High(gPlayers
) do
1533 if gPlayers
[a
] <> nil then
1535 gPlayers
[a
].FReady
:= False;
1536 if g_Game_IsNet
then
1537 MH_SEND_GameEvent(NET_EV_INTER_READY
, gPlayers
[a
].UID
, 'N');
1541 procedure g_Player_RememberAll
;
1545 for i
:= Low(gPlayers
) to High(gPlayers
) do
1546 if (gPlayers
[i
] <> nil) and gPlayers
[i
].alive
then
1547 gPlayers
[i
].RememberState
;
1550 procedure g_Player_ResetAll(Force
, Silent
: Boolean);
1554 gTeamStat
[TEAM_RED
].Goals
:= 0;
1555 gTeamStat
[TEAM_BLUE
].Goals
:= 0;
1557 if gPlayers
<> nil then
1558 for i
:= 0 to High(gPlayers
) do
1559 if gPlayers
[i
] <> nil then
1561 gPlayers
[i
].Reset(Force
);
1563 if gPlayers
[i
] is TPlayer
then
1565 if (not gPlayers
[i
].FSpectator
) or gPlayers
[i
].FWantsInGame
then
1566 gPlayers
[i
].Respawn(Silent
)
1568 gPlayers
[i
].Spectate();
1571 TBot(gPlayers
[i
]).Respawn(Silent
);
1575 procedure g_Player_CreateCorpse(Player
: TPlayer
);
1581 if Player
.alive
then
1584 // Ðàçðûâàåì ñâÿçü ñ ïðåæíèì òðóïîì:
1585 if gCorpses
<> nil then
1586 for i
:= 0 to High(gCorpses
) do
1587 if gCorpses
[i
] <> nil then
1588 if gCorpses
[i
].FPlayerUID
= Player
.FUID
then
1589 gCorpses
[i
].FPlayerUID
:= 0;
1591 if Player
.FObj
.Y
>= gMapInfo
.Height
+128 then
1596 if (FHealth
>= -50) or (gGibsCount
= 0) then
1598 if (gCorpses
= nil) or (Length(gCorpses
) = 0) then
1602 for find_id
:= 0 to High(gCorpses
) do
1603 if gCorpses
[find_id
] = nil then
1610 find_id
:= Random(Length(gCorpses
));
1612 gCorpses
[find_id
] := TCorpse
.Create(FObj
.X
, FObj
.Y
, FModel
.Name
, FHealth
< -20);
1613 gCorpses
[find_id
].FColor
:= FModel
.Color
;
1614 gCorpses
[find_id
].FObj
.Vel
:= FObj
.Vel
;
1615 gCorpses
[find_id
].FObj
.Accel
:= FObj
.Accel
;
1616 gCorpses
[find_id
].FPlayerUID
:= FUID
;
1619 g_Player_CreateGibs(FObj
.X
+ PLAYER_RECT_CX
,
1620 FObj
.Y
+ PLAYER_RECT_CY
,
1621 FModel
.Name
, FModel
.Color
);
1625 procedure g_Player_CreateShell(fX
, fY
, dX
, dY
: Integer; T
: Byte);
1629 if (gShells
= nil) or (Length(gShells
) = 0) then
1632 with gShells
[CurrentShell
] do
1638 if T
= SHELL_BULLET
then
1640 if g_Texture_Get('TEXTURE_SHELL_BULLET', SID
) then
1644 Obj
.Rect
.Width
:= 4;
1645 Obj
.Rect
.Height
:= 2;
1649 if g_Texture_Get('TEXTURE_SHELL_SHELL', SID
) then
1653 Obj
.Rect
.Width
:= 7;
1654 Obj
.Rect
.Height
:= 3;
1660 g_Obj_Push(@Obj
, dX
+ Random(4)-Random(4), dY
-Random(4));
1661 positionChanged(); // this updates spatial accelerators
1662 RAngle
:= Random(360);
1663 Timeout
:= gTime
+ SHELL_TIMEOUT
;
1665 if CurrentShell
>= High(gShells
) then
1672 procedure g_Player_CreateGibs(fX
, fY
: Integer; ModelName
: string; fColor
: TRGB
);
1675 GibsArray
: TGibsArray
;
1678 if (gGibs
= nil) or (Length(gGibs
) = 0) then
1680 if not g_PlayerModel_GetGibs(ModelName
, GibsArray
) then
1682 Blood
:= g_PlayerModel_GetBlood(ModelName
);
1684 for a
:= 0 to High(GibsArray
) do
1685 with gGibs
[CurrentGib
] do
1688 ID
:= GibsArray
[a
].ID
;
1689 MaskID
:= GibsArray
[a
].MaskID
;
1692 Obj
.Rect
:= GibsArray
[a
].Rect
;
1693 Obj
.X
:= fX
-GibsArray
[a
].Rect
.X
-(GibsArray
[a
].Rect
.Width
div 2);
1694 Obj
.Y
:= fY
-GibsArray
[a
].Rect
.Y
-(GibsArray
[a
].Rect
.Height
div 2);
1695 g_Obj_PushA(@Obj
, 25 + Random(10), Random(361));
1696 positionChanged(); // this updates spatial accelerators
1697 RAngle
:= Random(360);
1699 if gBloodCount
> 0 then
1700 g_GFX_Blood(fX
, fY
, 16*gBloodCount
+Random(5*gBloodCount
), -16+Random(33), -16+Random(33),
1701 Random(48), Random(48), Blood
.R
, Blood
.G
, Blood
.B
, Blood
.Kind
);
1703 if CurrentGib
>= High(gGibs
) then
1710 procedure g_Player_UpdatePhysicalObjects();
1716 procedure ShellSound_Bounce(X
, Y
: Integer; T
: Byte);
1721 if T
= SHELL_BULLET
then
1722 g_Sound_PlayExAt('SOUND_PLAYER_CASING' + IntToStr(k
), X
, Y
)
1724 g_Sound_PlayExAt('SOUND_PLAYER_SHELL' + IntToStr(k
), X
, Y
);
1729 if gGibs
<> nil then
1730 for i
:= 0 to High(gGibs
) do
1731 if gGibs
[i
].alive
then
1738 mr
:= g_Obj_Move(@Obj
, True, False, True);
1739 positionChanged(); // this updates spatial accelerators
1741 if WordBool(mr
and MOVE_FALLOUT
) then
1747 // Îòëåòàåò îò óäàðà î ñòåíó/ïîòîëîê/ïîë:
1748 if WordBool(mr
and MOVE_HITWALL
) then
1749 Obj
.Vel
.X
:= -(vel
.X
div 2);
1750 if WordBool(mr
and (MOVE_HITCEIL
or MOVE_HITLAND
)) then
1751 Obj
.Vel
.Y
:= -(vel
.Y
div 2);
1753 if (Obj
.Vel
.X
>= 0) then
1755 RAngle
:= RAngle
+ Abs(Obj
.Vel
.X
)*6 + Abs(Obj
.Vel
.Y
);
1756 if RAngle
>= 360 then
1757 RAngle
:= RAngle
mod 360;
1758 end else begin // Counter-clockwise
1759 RAngle
:= RAngle
- Abs(Obj
.Vel
.X
)*6 - Abs(Obj
.Vel
.Y
);
1761 RAngle
:= (360 - (Abs(RAngle
) mod 360)) mod 360;
1764 // Ñîïðîòèâëåíèå âîçäóõà äëÿ êóñêà òðóïà:
1765 if gTime
mod (GAME_TICK
*3) = 0 then
1766 Obj
.Vel
.X
:= z_dec(Obj
.Vel
.X
, 1);
1770 if gCorpses
<> nil then
1771 for i
:= 0 to High(gCorpses
) do
1772 if gCorpses
[i
] <> nil then
1773 if gCorpses
[i
].State
= CORPSE_STATE_REMOVEME
then
1779 gCorpses
[i
].Update();
1782 if gShells
<> nil then
1783 for i
:= 0 to High(gShells
) do
1784 if gShells
[i
].alive
then
1791 mr
:= g_Obj_Move(@Obj
, True, False, True);
1792 positionChanged(); // this updates spatial accelerators
1794 if WordBool(mr
and MOVE_FALLOUT
) or (gShells
[i
].Timeout
< gTime
) then
1800 // Îòëåòàåò îò óäàðà î ñòåíó/ïîòîëîê/ïîë:
1801 if WordBool(mr
and MOVE_HITWALL
) then
1803 Obj
.Vel
.X
:= -(vel
.X
div 2);
1804 if not WordBool(mr
and MOVE_INWATER
) then
1805 ShellSound_Bounce(Obj
.X
, Obj
.Y
, SType
);
1807 if WordBool(mr
and (MOVE_HITCEIL
or MOVE_HITLAND
)) then
1809 Obj
.Vel
.Y
:= -(vel
.Y
div 2);
1810 if Obj
.Vel
.X
<> 0 then Obj
.Vel
.X
:= Obj
.Vel
.X
div 2;
1811 if (Obj
.Vel
.X
= 0) and (Obj
.Vel
.Y
= 0) then
1813 if RAngle
mod 90 <> 0 then
1814 RAngle
:= (RAngle
div 90) * 90;
1816 else if not WordBool(mr
and MOVE_INWATER
) then
1817 ShellSound_Bounce(Obj
.X
, Obj
.Y
, SType
);
1820 if (Obj
.Vel
.X
>= 0) then
1822 RAngle
:= RAngle
+ Abs(Obj
.Vel
.X
)*8 + Abs(Obj
.Vel
.Y
);
1823 if RAngle
>= 360 then
1824 RAngle
:= RAngle
mod 360;
1825 end else begin // Counter-clockwise
1826 RAngle
:= RAngle
- Abs(Obj
.Vel
.X
)*8 - Abs(Obj
.Vel
.Y
);
1828 RAngle
:= (360 - (Abs(RAngle
) mod 360)) mod 360;
1834 procedure TGib
.getMapBox (out x
, y
, w
, h
: Integer); inline;
1836 x
:= Obj
.X
+Obj
.Rect
.X
;
1837 y
:= Obj
.Y
+Obj
.Rect
.Y
;
1838 w
:= Obj
.Rect
.Width
;
1839 h
:= Obj
.Rect
.Height
;
1842 procedure TGib
.moveBy (dx
, dy
: Integer); inline;
1844 if (dx
<> 0) or (dy
<> 0) then
1853 procedure TShell
.getMapBox (out x
, y
, w
, h
: Integer); inline;
1857 w
:= Obj
.Rect
.Width
;
1858 h
:= Obj
.Rect
.Height
;
1861 procedure TShell
.moveBy (dx
, dy
: Integer); inline;
1863 if (dx
<> 0) or (dy
<> 0) then
1872 procedure TGib
.positionChanged (); inline; begin end;
1873 procedure TShell
.positionChanged (); inline; begin end;
1876 procedure g_Player_DrawCorpses();
1881 if gGibs
<> nil then
1882 for i
:= 0 to High(gGibs
) do
1883 if gGibs
[i
].alive
then
1886 if not g_Obj_Collide(sX
, sY
, sWidth
, sHeight
, @Obj
) then
1889 Obj
.lerp(gLerpFactor
, fX
, fY
);
1891 a
.X
:= Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2);
1892 a
.y
:= Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2);
1894 e_DrawAdv(ID
, fX
, fY
, 0, True, False, RAngle
, @a
, TMirrorType
.None
);
1897 e_DrawAdv(MaskID
, fX
, fY
, 0, True, False, RAngle
, @a
, TMirrorType
.None
);
1903 if gCorpses
<> nil then
1904 for i
:= 0 to High(gCorpses
) do
1905 if gCorpses
[i
] <> nil then
1909 procedure g_Player_DrawShells();
1914 if gShells
<> nil then
1915 for i
:= 0 to High(gShells
) do
1916 if gShells
[i
].alive
then
1919 if not g_Obj_Collide(sX
, sY
, sWidth
, sHeight
, @Obj
) then
1922 Obj
.lerp(gLerpFactor
, fX
, fY
);
1927 e_DrawAdv(SpriteID
, fX
, fY
, 0, True, False, RAngle
, @a
, TMirrorType
.None
);
1931 procedure g_Player_RemoveAllCorpses();
1937 SetLength(gGibs
, MaxGibs
);
1938 SetLength(gShells
, MaxGibs
);
1942 if gCorpses
<> nil then
1943 for i
:= 0 to High(gCorpses
) do
1947 SetLength(gCorpses
, MaxCorpses
);
1950 procedure g_Player_Corpses_SaveState (st
: TStream
);
1954 // Ñ÷èòàåì êîëè÷åñòâî ñóùåñòâóþùèõ òðóïîâ
1956 for i
:= 0 to High(gCorpses
) do if (gCorpses
[i
] <> nil) then Inc(count
);
1958 // Êîëè÷åñòâî òðóïîâ
1959 utils
.writeInt(st
, LongInt(count
));
1961 if (count
= 0) then exit
;
1964 for i
:= 0 to High(gCorpses
) do
1966 if gCorpses
[i
] <> nil then
1969 utils
.writeStr(st
, gCorpses
[i
].FModelName
);
1971 utils
.writeBool(st
, gCorpses
[i
].Mess
);
1972 // Ñîõðàíÿåì äàííûå òðóïà:
1973 gCorpses
[i
].SaveState(st
);
1979 procedure g_Player_Corpses_LoadState (st
: TStream
);
1987 g_Player_RemoveAllCorpses();
1989 // Êîëè÷åñòâî òðóïîâ:
1990 count
:= utils
.readLongInt(st
);
1991 if (count
< 0) or (count
> Length(gCorpses
)) then raise XStreamError
.Create('invalid number of corpses');
1993 if (count
= 0) then exit
;
1996 for i
:= 0 to count
-1 do
1999 str
:= utils
.readStr(st
);
2001 b
:= utils
.readBool(st
);
2003 gCorpses
[i
] := TCorpse
.Create(0, 0, str
, b
);
2004 // Çàãðóæàåì äàííûå òðóïà
2005 gCorpses
[i
].LoadState(st
);
2012 function TPlayer
.isValidViewPort (): Boolean; inline; begin result
:= (viewPortW
> 0) and (viewPortH
> 0); end;
2014 procedure TPlayer
.BFGHit();
2016 g_Weapon_BFGHit(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
2017 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2));
2018 if g_Game_IsServer
and g_Game_IsNet
then
2019 MH_SEND_Effect(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
2020 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2),
2024 procedure TPlayer
.ChangeModel(ModelName
: string);
2026 locModel
: TPlayerModel
;
2028 locModel
:= g_PlayerModel_Get(ModelName
);
2029 if locModel
= nil then Exit
;
2035 procedure TPlayer
.SetModel(ModelName
: string);
2039 m
:= g_PlayerModel_Get(ModelName
);
2042 g_SimpleError(Format(_lc
[I_GAME_ERROR_MODEL_FALLBACK
], [ModelName
]));
2043 m
:= g_PlayerModel_Get('doomer');
2046 g_FatalError(Format(_lc
[I_GAME_ERROR_MODEL
], ['doomer']));
2051 if FModel
<> nil then
2056 if not (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then
2057 FModel
.Color
:= FColor
2059 FModel
.Color
:= TEAMCOLOR
[FTeam
];
2060 FModel
.SetWeapon(FCurrWeap
);
2061 FModel
.SetFlag(FFlag
);
2062 SetDirection(FDirection
);
2065 procedure TPlayer
.SetColor(Color
: TRGB
);
2068 if not (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then
2069 if FModel
<> nil then FModel
.Color
:= Color
;
2072 function TPlayer
.GetColor(): TRGB
;
2074 result
:= FModel
.Color
;
2077 procedure TPlayer
.SwitchTeam
;
2079 if g_Game_IsClient
then
2081 if not (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then Exit
;
2083 if gGameOn
and FAlive
then
2084 Kill(K_SIMPLEKILL
, FUID
, HIT_SELF
);
2086 if FTeam
= TEAM_RED
then
2088 ChangeTeam(TEAM_BLUE
);
2089 g_Console_Add(Format(_lc
[I_PLAYER_CHTEAM_BLUE
], [FName
]), True);
2090 if g_Game_IsNet
then
2091 MH_SEND_GameEvent(NET_EV_CHANGE_TEAM
, TEAM_BLUE
, FName
);
2095 ChangeTeam(TEAM_RED
);
2096 g_Console_Add(Format(_lc
[I_PLAYER_CHTEAM_RED
], [FName
]), True);
2097 if g_Game_IsNet
then
2098 MH_SEND_GameEvent(NET_EV_CHANGE_TEAM
, TEAM_RED
, FName
);
2100 FPreferredTeam
:= FTeam
;
2103 procedure TPlayer
.ChangeTeam(Team
: Byte);
2110 TEAM_RED
, TEAM_BLUE
:
2111 FModel
.Color
:= TEAMCOLOR
[Team
];
2113 FModel
.Color
:= FColor
;
2115 if (FTeam
<> OldTeam
) and g_Game_IsNet
and g_Game_IsServer
then
2116 MH_SEND_PlayerStats(FUID
);
2120 procedure TPlayer.CollideItem();
2125 if gItems = nil then Exit;
2126 if not FAlive then Exit;
2128 for i := 0 to High(gItems) do
2131 if (ItemType <> ITEM_NONE) and alive then
2132 if g_Obj_Collide(FObj.X+PLAYER_RECT.X, FObj.Y+PLAYER_RECT.Y, PLAYER_RECT.Width,
2133 PLAYER_RECT.Height, @Obj) then
2135 if not PickItem(ItemType, gItems[i].Respawnable, r) then Continue;
2137 if ItemType in [ITEM_SPHERE_BLUE, ITEM_SPHERE_WHITE, ITEM_INVUL] then
2138 g_Sound_PlayExAt('SOUND_ITEM_GETRULEZ', FObj.X, FObj.Y)
2139 else if ItemType in [ITEM_MEDKIT_SMALL, ITEM_MEDKIT_LARGE, ITEM_MEDKIT_BLACK] then
2140 g_Sound_PlayExAt('SOUND_ITEM_GETMED', FObj.X, FObj.Y)
2141 else g_Sound_PlayExAt('SOUND_ITEM_GETITEM', FObj.X, FObj.Y);
2143 // Íàäî óáðàòü ñ êàðòû, åñëè ýòî íå êëþ÷, êîòîðûì íóæíî ïîäåëèòñÿ ñ äðóãèì èãðîêîì:
2144 if r and not ((ItemType in [ITEM_KEY_RED, ITEM_KEY_GREEN, ITEM_KEY_BLUE]) and
2145 (gGameSettings.GameType = GT_SINGLE) and
2146 (g_Player_GetCount() > 1)) then
2147 if not Respawnable then g_Items_Remove(i) else g_Items_Pick(i);
2153 function TPlayer
.CollideLevel(XInc
, YInc
: Integer): Boolean;
2155 Result
:= g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
,
2156 PLAYER_RECT
.Width
, PLAYER_RECT
.Height
, PANEL_WALL
,
2160 constructor TPlayer
.Create();
2166 mEDamageType
:= HIT_SOME
;
2172 FSawSound
:= TPlayableSound
.Create();
2173 FSawSoundIdle
:= TPlayableSound
.Create();
2174 FSawSoundHit
:= TPlayableSound
.Create();
2175 FSawSoundSelect
:= TPlayableSound
.Create();
2176 FFlameSoundOn
:= TPlayableSound
.Create();
2177 FFlameSoundOff
:= TPlayableSound
.Create();
2178 FFlameSoundWork
:= TPlayableSound
.Create();
2179 FJetSoundFly
:= TPlayableSound
.Create();
2180 FJetSoundOn
:= TPlayableSound
.Create();
2181 FJetSoundOff
:= TPlayableSound
.Create();
2183 FSawSound
.SetByName('SOUND_WEAPON_FIRESAW');
2184 FSawSoundIdle
.SetByName('SOUND_WEAPON_IDLESAW');
2185 FSawSoundHit
.SetByName('SOUND_WEAPON_HITSAW');
2186 FSawSoundSelect
.SetByName('SOUND_WEAPON_SELECTSAW');
2187 FFlameSoundOn
.SetByName('SOUND_WEAPON_FLAMEON');
2188 FFlameSoundOff
.SetByName('SOUND_WEAPON_FLAMEOFF');
2189 FFlameSoundWork
.SetByName('SOUND_WEAPON_FLAMEWORK');
2190 FJetSoundFly
.SetByName('SOUND_PLAYER_JETFLY');
2191 FJetSoundOn
.SetByName('SOUND_PLAYER_JETON');
2192 FJetSoundOff
.SetByName('SOUND_PLAYER_JETOFF');
2194 FSpectatePlayer
:= -1;
2198 FSavedStateNum
:= -1;
2205 FActualModelName
:= 'doomer';
2208 FObj
.Rect
:= PLAYER_RECT
;
2210 FBFGFireCounter
:= -1;
2211 FJustTeleported
:= False;
2214 FWaitForFirstSpawn
:= false;
2219 procedure TPlayer
.positionChanged (); inline;
2223 procedure TPlayer
.doDamage (v
: Integer);
2225 if (v
<= 0) then exit
;
2226 if (v
> 32767) then v
:= 32767;
2227 Damage(v
, 0, 0, 0, mEDamageType
);
2230 procedure TPlayer
.Damage(value
: Word; SpawnerUID
: Word; vx
, vy
: Integer; t
: Byte);
2234 if (not g_Game_IsClient
) and (not FAlive
) then
2239 // Íåóÿçâèìîñòü íå ñïàñàåò îò ëîâóøåê:
2240 if ((t
= HIT_TRAP
) or (t
= HIT_SELF
)) and (not FGodMode
) then
2242 if not g_Game_IsClient
then
2245 if t
= HIT_TRAP
then
2247 // Ëîâóøêà óáèâàåò ñðàçó:
2249 Kill(K_EXTRAHARDKILL
, SpawnerUID
, t
);
2251 if t
= HIT_SELF
then
2255 Kill(K_SIMPLEKILL
, SpawnerUID
, t
);
2258 // Îáíóëèòü äåéñòâèÿ ïðèìî÷åê, ÷òîáû ôîí ïðîïàë
2259 FMegaRulez
[MR_SUIT
] := 0;
2260 FMegaRulez
[MR_INVUL
] := 0;
2261 FMegaRulez
[MR_INVIS
] := 0;
2266 // Íî îò îñòàëüíîãî ñïàñàåò:
2267 if FMegaRulez
[MR_INVUL
] >= gTime
then
2274 // Åñëè åñòü óðîí ñâîèì, èëè ðàíèë ñàì ñåáÿ, èëè òåáÿ ðàíèë ïðîòèâíèê:
2275 if LongBool(gGameSettings
.Options
and GAME_OPTION_TEAMDAMAGE
) or
2276 (SpawnerUID
= FUID
) or
2277 (not SameTeam(FUID
, SpawnerUID
)) then
2279 FLastSpawnerUID
:= SpawnerUID
;
2281 // Êðîâü (ïóçûðüêè, åñëè â âîäå):
2282 if gBloodCount
> 0 then
2284 c
:= Min(value
, 200)*gBloodCount
+ Random(Min(value
, 200) div 2);
2285 if value
div 4 <= c
then
2286 c
:= c
- (value
div 4)
2290 if (t
= HIT_SOME
) and (vx
= 0) and (vy
= 0) then
2294 HIT_TRAP
, HIT_ACID
, HIT_FLAME
, HIT_SELF
: MakeBloodSimple(c
);
2295 HIT_BFG
, HIT_ROCKET
, HIT_SOME
: MakeBloodVector(c
, vx
, vy
);
2298 if t
= HIT_WATER
then
2299 g_GFX_Bubbles(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2),
2300 FObj
.Y
+PLAYER_RECT
.Y
-4, value
div 2, 8, 4);
2305 Inc(FDamageBuffer
, value
);
2309 FPain
:= FPain
+ value
;
2312 if g_Game_IsServer
and g_Game_IsNet
then
2314 MH_SEND_PlayerDamage(FUID
, t
, SpawnerUID
, value
, vx
, vy
);
2315 MH_SEND_PlayerStats(FUID
);
2316 MH_SEND_PlayerPos(False, FUID
);
2320 function TPlayer
.Heal(value
: Word; Soft
: Boolean): Boolean;
2323 if g_Game_IsClient
then
2328 if Soft
and (FHealth
< PLAYER_HP_SOFT
) then
2330 IncMax(FHealth
, value
, PLAYER_HP_SOFT
);
2333 if (not Soft
) and (FHealth
< PLAYER_HP_LIMIT
) then
2335 IncMax(FHealth
, value
, PLAYER_HP_LIMIT
);
2339 if Result
and g_Game_IsServer
and g_Game_IsNet
then
2340 MH_SEND_PlayerStats(FUID
);
2343 destructor TPlayer
.Destroy();
2345 if (gPlayer1
<> nil) and (gPlayer1
.FUID
= FUID
) then
2347 if (gPlayer2
<> nil) and (gPlayer2
.FUID
= FUID
) then
2351 FSawSoundIdle
.Free();
2352 FSawSoundHit
.Free();
2353 FSawSoundSelect
.Free();
2354 FFlameSoundOn
.Free();
2355 FFlameSoundOff
.Free();
2356 FFlameSoundWork
.Free();
2357 FJetSoundFly
.Free();
2359 FJetSoundOff
.Free();
2361 if FPunchAnim
<> nil then
2367 procedure TPlayer
.DrawIndicator(Color
: TRGB
);
2369 indX
, indY
, fX
, fY
, fSlope
: Integer;
2379 FObj
.lerp(gLerpFactor
, fX
, fY
);
2380 fSlope
:= nlerp(FSlopeOld
, FObj
.slopeUpLeft
, gLerpFactor
);
2382 case gPlayerIndicatorStyle
of
2385 if g_Texture_Get('TEXTURE_PLAYER_INDICATOR', ID
) then
2387 e_GetTextureSize(ID
, @indW
, @indH
);
2391 if (FObj
.X
+ FObj
.Rect
.X
) < 0 then
2394 indX
:= fX
+ FObj
.Rect
.X
+ FObj
.Rect
.Width
;
2395 indY
:= fY
+ FObj
.Rect
.Y
+ (FObj
.Rect
.Height
- indW
) div 2;
2398 else if (FObj
.X
+ FObj
.Rect
.X
+ FObj
.Rect
.Width
) > Max(gMapInfo
.Width
, gPlayerScreenSize
.X
) then
2401 indX
:= fX
+ FObj
.Rect
.X
- indH
;
2402 indY
:= fY
+ FObj
.Rect
.Y
+ (FObj
.Rect
.Height
- indW
) div 2;
2405 else if (FObj
.Y
- indH
) < 0 then
2408 indX
:= fX
+ FObj
.Rect
.X
+ (FObj
.Rect
.Width
- indW
) div 2;
2409 indY
:= fY
+ FObj
.Rect
.Y
+ FObj
.Rect
.Height
;
2415 indX
:= fX
+ FObj
.Rect
.X
+ (FObj
.Rect
.Width
- indW
) div 2;
2419 indY
:= indY
+ fSlope
;
2420 indX
:= EnsureRange(indX
, 0, Max(gMapInfo
.Width
, gPlayerScreenSize
.X
) - indW
);
2421 indY
:= EnsureRange(indY
, 0, Max(gMapInfo
.Height
, gPlayerScreenSize
.Y
) - indH
);
2425 e_DrawAdv(ID
, indX
, indY
, 0, True, False, indA
, @a
);
2432 e_TextureFontGetSize(gStdFont
, nW
, nH
);
2433 indX
:= fX
+ FObj
.Rect
.X
+ (FObj
.Rect
.Width
- Length(FName
) * nW
) div 2;
2434 indY
:= fY
- nH
+ fSlope
;
2435 e_TextureFontPrintEx(indX
, indY
, FName
, gStdFont
, Color
.R
, Color
.G
, Color
.B
, 1.0, True);
2441 procedure TPlayer
.DrawBubble();
2443 bubX
, bubY
, fX
, fY
: Integer;
2446 Rw
, Gw
, Bw
: SmallInt;
2449 FObj
.lerp(gLerpFactor
, fX
, fY
);
2450 bubX
:= fX
+FObj
.Rect
.X
+ IfThen(FDirection
= TDirection
.D_LEFT
, -4, 18);
2451 bubY
:= fY
+FObj
.Rect
.Y
- 18;
2459 1: // simple textual non-bubble
2461 bubX
:= fX
+FObj
.Rect
.X
- 11;
2462 bubY
:= fY
+FObj
.Rect
.Y
- 17;
2463 e_TextureFontPrint(bubX
, bubY
, '[...]', gStdFont
);
2466 2: // advanced pixel-perfect bubble
2468 if FTeam
= TEAM_RED
then
2471 if FTeam
= TEAM_BLUE
then
2474 3: // colored bubble
2476 Rb
:= FModel
.Color
.R
;
2477 Gb
:= FModel
.Color
.G
;
2478 Bb
:= FModel
.Color
.B
;
2479 Rw
:= Min(Rb
* 2 + 64, 255);
2480 Gw
:= Min(Gb
* 2 + 64, 255);
2481 Bw
:= Min(Bb
* 2 + 64, 255);
2482 if (Abs(Rw
- Rb
) < 32)
2483 or (Abs(Gw
- Gb
) < 32)
2484 or (Abs(Bw
- Bb
) < 32) then
2486 Rb
:= Max(Rw
div 2 - 16, 0);
2487 Gb
:= Max(Gw
div 2 - 16, 0);
2488 Bb
:= Max(Bw
div 2 - 16, 0);
2491 4: // custom textured bubble
2493 if g_Texture_Get('TEXTURE_PLAYER_TALKBUBBLE', ID
) then
2494 if FDirection
= TDirection
.D_RIGHT
then
2495 e_Draw(ID
, bubX
- 6, bubY
- 7, 0, True, False)
2497 e_Draw(ID
, bubX
- 6, bubY
- 7, 0, True, False, TMirrorType
.Horizontal
);
2503 e_DrawQuad(bubX
+ 1, bubY
, bubX
+ 18, bubY
+ 13, Rb
, Gb
, Bb
);
2504 e_DrawQuad(bubX
, bubY
+ 1, bubX
+ 19, bubY
+ 12, Rb
, Gb
, Bb
);
2506 e_DrawFillQuad(bubX
+ 1, bubY
+ 1, bubX
+ 18, bubY
+ 12, Rw
, Gw
, Bw
, 0);
2509 Dot
:= IfThen(FDirection
= TDirection
.D_LEFT
, 14, 5);
2510 e_DrawLine(1, bubX
+ Dot
, bubY
+ 14, bubX
+ Dot
, bubY
+ 16, Rb
, Gb
, Bb
);
2511 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
);
2512 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
);
2513 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
);
2514 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
);
2518 e_DrawFillQuad(bubX
+ Dot
, bubY
+ 8, bubX
+ Dot
+ 1, bubY
+ 9, Rb
, Gb
, Bb
, 0);
2519 e_DrawFillQuad(bubX
+ Dot
+ 3, bubY
+ 8, bubX
+ Dot
+ 4, bubY
+ 9, Rb
, Gb
, Bb
, 0);
2520 e_DrawFillQuad(bubX
+ Dot
+ 6, bubY
+ 8, bubX
+ Dot
+ 7, bubY
+ 9, Rb
, Gb
, Bb
, 0);
2523 procedure TPlayer
.Draw();
2528 Mirror
: TMirrorType
;
2529 fX
, fY
, fSlope
: Integer;
2531 FObj
.lerp(gLerpFactor
, fX
, fY
);
2532 fSlope
:= nlerp(FSlopeOld
, FObj
.slopeUpLeft
, gLerpFactor
);
2536 if Direction
= TDirection
.D_RIGHT
then
2537 Mirror
:= TMirrorType
.None
2539 Mirror
:= TMirrorType
.Horizontal
;
2541 if FPunchAnim
<> nil then
2543 FPunchAnim
.Draw(fX
+IfThen(Direction
= TDirection
.D_LEFT
, 15-FObj
.Rect
.X
, FObj
.Rect
.X
-15),
2544 fY
+fSlope
+FObj
.Rect
.Y
-11, Mirror
);
2545 if FPunchAnim
.played
then
2552 if (FMegaRulez
[MR_INVUL
] > gTime
) and ((gPlayerDrawn
<> Self
) or (FSpawnInvul
>= gTime
)) then
2553 if g_Texture_Get('TEXTURE_PLAYER_INVULPENTA', ID
) then
2555 e_GetTextureSize(ID
, @w
, @h
);
2556 if FDirection
= TDirection
.D_LEFT
then
2557 e_Draw(ID
, fX
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2)-(w
div 2)+4,
2558 fY
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2)-(h
div 2)-7+fSlope
, 0, True, False)
2560 e_Draw(ID
, fX
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2)-(w
div 2)-2,
2561 fY
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2)-(h
div 2)-7+fSlope
, 0, True, False);
2564 if FMegaRulez
[MR_INVIS
] > gTime
then
2566 if (gPlayerDrawn
<> nil) and ((Self
= gPlayerDrawn
) or
2567 ((FTeam
= gPlayerDrawn
.Team
) and (gGameSettings
.GameMode
<> GM_DM
))) then
2569 if (FMegaRulez
[MR_INVIS
] - gTime
) <= 2100 then
2570 dr
:= not Odd((FMegaRulez
[MR_INVIS
] - gTime
) div 300)
2574 FModel
.Draw(fX
, fY
+fSlope
, 200)
2576 FModel
.Draw(fX
, fY
+fSlope
);
2579 FModel
.Draw(fX
, fY
+fSlope
, 254);
2582 FModel
.Draw(fX
, fY
+fSlope
);
2585 if g_debug_Frames
then
2587 e_DrawQuad(FObj
.X
+FObj
.Rect
.X
,
2589 FObj
.X
+FObj
.Rect
.X
+FObj
.Rect
.Width
-1,
2590 FObj
.Y
+FObj
.Rect
.Y
+FObj
.Rect
.Height
-1,
2594 if (gChatBubble
> 0) and (FKeys
[KEY_CHAT
].Pressed
) and not FGhost
then
2595 if (FMegaRulez
[MR_INVIS
] <= gTime
) or ((gPlayerDrawn
<> nil) and ((Self
= gPlayerDrawn
) or
2596 ((FTeam
= gPlayerDrawn
.Team
) and (gGameSettings
.GameMode
<> GM_DM
)))) then
2598 // e_DrawPoint(5, 335, 288, 255, 0, 0); // DL, UR, DL, UR
2599 if gAimLine
and alive
and
2600 ((Self
= gPlayer1
) or (Self
= gPlayer2
)) then
2605 procedure TPlayer
.DrawAim();
2606 procedure drawCast (sz
: Integer; ax0
, ay0
, ax1
, ay1
: Integer);
2611 {$IFDEF ENABLE_HOLMES}
2612 if isValidViewPort
and (self
= gPlayer1
) then
2614 g_Holmes_plrLaser(ax0
, ay0
, ax1
, ay1
);
2618 e_DrawLine(sz
, ax0
, ay0
, ax1
, ay1
, 255, 0, 0, 96);
2619 if (g_Map_traceToNearestWall(ax0
, ay0
, ax1
, ay1
, @ex
, @ey
) <> nil) then
2621 e_DrawLine(sz
, ax0
, ay0
, ex
, ey
, 0, 255, 0, 96);
2625 e_DrawLine(sz
, ax0
, ay0
, ex
, ey
, 0, 0, 255, 96);
2630 wx
, wy
, xx
, yy
: Integer;
2634 wx
:= FObj
.X
+ WEAPONPOINT
[FDirection
].X
+ IfThen(FDirection
= TDirection
.D_LEFT
, 7, -7);
2635 wy
:= FObj
.Y
+ WEAPONPOINT
[FDirection
].Y
;
2644 1: begin // Chainsaw
2651 if angle
= ANGLE_RIGHTUP
then Dec(angle
, 2);
2652 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 4);
2653 if angle
= ANGLE_LEFTUP
then Inc(angle
, 2);
2654 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 4);
2659 if angle
= ANGLE_RIGHTUP
then Dec(angle
, 2);
2660 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 4);
2661 if angle
= ANGLE_LEFTUP
then Inc(angle
, 2);
2662 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 4);
2664 4: begin // Double Shotgun
2667 if angle
= ANGLE_RIGHTUP
then Dec(angle
, 2);
2668 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 4);
2669 if angle
= ANGLE_LEFTUP
then Inc(angle
, 2);
2670 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 4);
2672 5: begin // Chaingun
2675 if angle
= ANGLE_RIGHTUP
then Dec(angle
, 2);
2676 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 4);
2677 if angle
= ANGLE_LEFTUP
then Inc(angle
, 2);
2678 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 4);
2680 6: begin // Rocket Launcher
2683 if angle
= ANGLE_RIGHTUP
then Inc(angle
, 2);
2684 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 4);
2685 if angle
= ANGLE_LEFTUP
then Dec(angle
, 2);
2686 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 4);
2688 7: begin // Plasmagun
2691 if angle
= ANGLE_RIGHTUP
then Inc(angle
);
2692 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 3);
2693 if angle
= ANGLE_LEFTUP
then Dec(angle
);
2694 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 3);
2699 if angle
= ANGLE_RIGHTUP
then Inc(angle
, 1);
2700 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 2);
2701 if angle
= ANGLE_LEFTUP
then Dec(angle
, 1);
2702 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 2);
2704 9: begin // Super Chaingun
2707 if angle
= ANGLE_RIGHTUP
then Dec(angle
, 2);
2708 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 4);
2709 if angle
= ANGLE_LEFTUP
then Inc(angle
, 2);
2710 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 4);
2713 xx
:= Trunc(Cos(-DegToRad(angle
)) * len
) + wx
;
2714 yy
:= Trunc(Sin(-DegToRad(angle
)) * len
) + wy
;
2715 {$IF DEFINED(D2F_DEBUG)}
2716 drawCast(sz
, wx
, wy
, xx
, yy
);
2718 e_DrawLine(sz
, wx
, wy
, xx
, yy
, 255, 0, 0, 96);
2722 procedure TPlayer
.DrawGUI();
2725 X
, Y
, SY
, a
, p
, m
: Integer;
2729 stat
: TPlayerStatArray
;
2731 X
:= gPlayerScreenSize
.X
;
2732 SY
:= gPlayerScreenSize
.Y
;
2735 if gShowGoals
and (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then
2737 if gGameSettings
.GameMode
= GM_CTF
then
2741 if gGameSettings
.GameMode
= GM_CTF
then
2743 s
:= 'TEXTURE_PLAYER_REDFLAG';
2744 if gFlags
[FLAG_RED
].State
= FLAG_STATE_CAPTURED
then
2745 s
:= 'TEXTURE_PLAYER_REDFLAG_S';
2746 if gFlags
[FLAG_RED
].State
= FLAG_STATE_DROPPED
then
2747 s
:= 'TEXTURE_PLAYER_REDFLAG_D';
2748 if g_Texture_Get(s
, ID
) then
2749 e_Draw(ID
, X
-16-32, 240-72-4, 0, True, False);
2752 s
:= IntToStr(gTeamStat
[TEAM_RED
].Goals
);
2753 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2754 e_CharFont_PrintEx(gMenuFont
, X
-16-a
-tw
, 240-72-4, s
, TEAMCOLOR
[TEAM_RED
]);
2756 if gGameSettings
.GameMode
= GM_CTF
then
2758 s
:= 'TEXTURE_PLAYER_BLUEFLAG';
2759 if gFlags
[FLAG_BLUE
].State
= FLAG_STATE_CAPTURED
then
2760 s
:= 'TEXTURE_PLAYER_BLUEFLAG_S';
2761 if gFlags
[FLAG_BLUE
].State
= FLAG_STATE_DROPPED
then
2762 s
:= 'TEXTURE_PLAYER_BLUEFLAG_D';
2763 if g_Texture_Get(s
, ID
) then
2764 e_Draw(ID
, X
-16-32, 240-32-4, 0, True, False);
2767 s
:= IntToStr(gTeamStat
[TEAM_BLUE
].Goals
);
2768 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2769 e_CharFont_PrintEx(gMenuFont
, X
-16-a
-tw
, 240-32-4, s
, TEAMCOLOR
[TEAM_BLUE
]);
2772 if g_Texture_Get('TEXTURE_PLAYER_HUDBG', ID
) then
2773 e_DrawFill(ID
, X
, 0, 1, (gPlayerScreenSize
.Y
div 256)+IfThen(gPlayerScreenSize
.Y
mod 256 > 0, 1, 0),
2776 if g_Texture_Get('TEXTURE_PLAYER_HUD', ID
) then
2777 e_Draw(ID
, X
+2, Y
, 0, True, False);
2779 if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
2783 s
:= IntToStr(Frags
);
2784 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2785 e_CharFont_PrintEx(gMenuFont
, X
-16-tw
, Y
, s
, _RGB(255, 0, 0));
2790 stat
:= g_Player_GetStats();
2795 for a
:= 0 to High(stat
) do
2796 if stat
[a
].Name
<> Name
then
2798 if stat
[a
].Frags
> m
then m
:= stat
[a
].Frags
;
2799 if stat
[a
].Frags
> Frags
then p
:= p
+1;
2803 s
:= IntToStr(p
)+' / '+IntToStr(Length(stat
))+' ';
2804 if Frags
>= m
then s
:= s
+'+' else s
:= s
+'-';
2805 s
:= s
+IntToStr(Abs(Frags
-m
));
2807 e_CharFont_GetSize(gMenuSmallFont
, s
, tw
, th
);
2808 e_CharFont_PrintEx(gMenuSmallFont
, X
-16-tw
, Y
+32, s
, _RGB(255, 0, 0));
2811 if gLMSRespawn
> LMS_RESPAWN_NONE
then
2813 s
:= _lc
[I_GAME_WARMUP
];
2814 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2815 s
:= s
+ ': ' + IntToStr((gLMSRespawnTime
- gTime
) div 1000);
2816 e_CharFont_PrintEx(gMenuFont
, X
-64-tw
, SY
-32, s
, _RGB(0, 255, 0));
2818 else if gShowLives
and (gGameSettings
.MaxLives
> 0) then
2820 s
:= IntToStr(Lives
);
2821 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2822 e_CharFont_PrintEx(gMenuFont
, X
-16-tw
, SY
-32, s
, _RGB(0, 255, 0));
2826 e_CharFont_GetSize(gMenuSmallFont
, FName
, tw
, th
);
2827 e_CharFont_PrintEx(gMenuSmallFont
, X
+98-(tw
div 2), Y
+8, FName
, _RGB(255, 0, 0));
2829 if R_BERSERK
in FRulez
then
2830 e_Draw(gItemsTexturesID
[ITEM_MEDKIT_BLACK
], X
+37, Y
+45, 0, True, False)
2832 e_Draw(gItemsTexturesID
[ITEM_MEDKIT_LARGE
], X
+37, Y
+45, 0, True, False);
2834 if g_Texture_Get('TEXTURE_PLAYER_ARMORHUD', ID
) then
2835 e_Draw(ID
, X
+36, Y
+77, 0, True, False);
2837 s
:= IntToStr(IfThen(FHealth
> 0, FHealth
, 0));
2838 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2839 e_CharFont_PrintEx(gMenuFont
, X
+178-tw
, Y
+40, s
, _RGB(255, 0, 0));
2841 s
:= IntToStr(FArmor
);
2842 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2843 e_CharFont_PrintEx(gMenuFont
, X
+178-tw
, Y
+68, s
, _RGB(255, 0, 0));
2845 s
:= IntToStr(GetAmmoByWeapon(FCurrWeap
));
2851 ID
:= gItemsTexturesID
[ITEM_WEAPON_KASTET
];
2856 ID
:= gItemsTexturesID
[ITEM_WEAPON_SAW
];
2858 WEAPON_PISTOL
: ID
:= gItemsTexturesID
[ITEM_WEAPON_PISTOL
];
2859 WEAPON_CHAINGUN
: ID
:= gItemsTexturesID
[ITEM_WEAPON_CHAINGUN
];
2860 WEAPON_SHOTGUN1
: ID
:= gItemsTexturesID
[ITEM_WEAPON_SHOTGUN1
];
2861 WEAPON_SHOTGUN2
: ID
:= gItemsTexturesID
[ITEM_WEAPON_SHOTGUN2
];
2862 WEAPON_SUPERPULEMET
: ID
:= gItemsTexturesID
[ITEM_WEAPON_SUPERPULEMET
];
2863 WEAPON_ROCKETLAUNCHER
: ID
:= gItemsTexturesID
[ITEM_WEAPON_ROCKETLAUNCHER
];
2864 WEAPON_PLASMA
: ID
:= gItemsTexturesID
[ITEM_WEAPON_PLASMA
];
2865 WEAPON_BFG
: ID
:= gItemsTexturesID
[ITEM_WEAPON_BFG
];
2866 WEAPON_FLAMETHROWER
: ID
:= gItemsTexturesID
[ITEM_WEAPON_FLAMETHROWER
];
2869 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2870 e_CharFont_PrintEx(gMenuFont
, X
+178-tw
, Y
+158, s
, _RGB(255, 0, 0));
2871 e_Draw(ID
, X
+20, Y
+160, 0, True, False);
2873 if R_KEY_RED
in FRulez
then
2874 e_Draw(gItemsTexturesID
[ITEM_KEY_RED
], X
+78, Y
+214, 0, True, False);
2876 if R_KEY_GREEN
in FRulez
then
2877 e_Draw(gItemsTexturesID
[ITEM_KEY_GREEN
], X
+95, Y
+214, 0, True, False);
2879 if R_KEY_BLUE
in FRulez
then
2880 e_Draw(gItemsTexturesID
[ITEM_KEY_BLUE
], X
+112, Y
+214, 0, True, False);
2882 if FJetFuel
> 0 then
2884 if g_Texture_Get('TEXTURE_PLAYER_HUDAIR', ID
) then
2885 e_Draw(ID
, X
+2, Y
+116, 0, True, False);
2886 if g_Texture_Get('TEXTURE_PLAYER_HUDJET', ID
) then
2887 e_Draw(ID
, X
+2, Y
+126, 0, True, False);
2888 e_DrawLine(4, X
+16, Y
+122, X
+16+Trunc(168*IfThen(FAir
> 0, FAir
, 0)/AIR_MAX
), Y
+122, 0, 0, 196);
2889 e_DrawLine(4, X
+16, Y
+132, X
+16+Trunc(168*FJetFuel
/JET_MAX
), Y
+132, 208, 0, 0);
2893 if g_Texture_Get('TEXTURE_PLAYER_HUDAIR', ID
) then
2894 e_Draw(ID
, X
+2, Y
+124, 0, True, False);
2895 e_DrawLine(4, X
+16, Y
+130, X
+16+Trunc(168*IfThen(FAir
> 0, FAir
, 0)/AIR_MAX
), Y
+130, 0, 0, 196);
2898 if gShowPing
and g_Game_IsClient
then
2900 s
:= _lc
[I_GAME_PING_HUD
] + IntToStr(NetPeer
.lastRoundTripTime
) + _lc
[I_NET_SLIST_PING_MS
];
2901 e_TextureFontPrint(X
+ 4, Y
+ 242, s
, gStdFont
);
2907 e_TextureFontPrint(X
+ 4, Y
+ 242, _lc
[I_PLAYER_SPECT
], gStdFont
);
2908 e_TextureFontPrint(X
+ 4, Y
+ 258, _lc
[I_PLAYER_SPECT2
], gStdFont
);
2909 e_TextureFontPrint(X
+ 4, Y
+ 274, _lc
[I_PLAYER_SPECT1
], gStdFont
);
2912 e_TextureFontGetSize(gStdFont
, cw
, ch
);
2913 s
:= _lc
[I_PLAYER_SPECT4
];
2914 e_TextureFontPrintEx(gScreenWidth
div 2 - cw
*(Length(s
) div 2),
2915 gScreenHeight
-4-ch
, s
, gStdFont
, 255, 255, 255, 1, True);
2916 e_TextureFontPrint(X
+ 4, Y
+ 290, _lc
[I_PLAYER_SPECT1S
], gStdFont
);
2922 procedure TPlayer
.DrawRulez();
2926 // Ïðè âçÿòèè íåóÿçâèìîñòè ðèñóåòñÿ èíâåðñèîííûé áåëûé ôîí
2927 if (FMegaRulez
[MR_INVUL
] >= gTime
) and (FSpawnInvul
< gTime
) then
2929 if (FMegaRulez
[MR_INVUL
]-gTime
) <= 2100 then
2930 dr
:= not Odd((FMegaRulez
[MR_INVUL
]-gTime
) div 300)
2935 e_DrawFillQuad(0, 0, gPlayerScreenSize
.X
-1, gPlayerScreenSize
.Y
-1,
2936 191, 191, 191, 0, TBlending
.Invert
);
2939 // Ïðè âçÿòèè çàùèòíîãî êîñòþìà ðèñóåòñÿ çåëåíîâàòûé ôîí
2940 if FMegaRulez
[MR_SUIT
] >= gTime
then
2942 if (FMegaRulez
[MR_SUIT
]-gTime
) <= 2100 then
2943 dr
:= not Odd((FMegaRulez
[MR_SUIT
]-gTime
) div 300)
2948 e_DrawFillQuad(0, 0, gPlayerScreenSize
.X
-1, gPlayerScreenSize
.Y
-1,
2949 0, 96, 0, 200, TBlending
.None
);
2952 // Ïðè âçÿòèè áåðñåðêà ðèñóåòñÿ êðàñíîâàòûé ôîí
2953 if (FBerserk
>= 0) and (LongWord(FBerserk
) >= gTime
) and (gFlash
= 2) then
2955 e_DrawFillQuad(0, 0, gPlayerScreenSize
.X
-1, gPlayerScreenSize
.Y
-1,
2956 255, 0, 0, 200, TBlending
.None
);
2960 procedure TPlayer
.DrawPain();
2964 if FPain
= 0 then Exit
;
2968 if a
< 15 then h
:= 0
2969 else if a
< 35 then h
:= 1
2970 else if a
< 55 then h
:= 2
2971 else if a
< 75 then h
:= 3
2972 else if a
< 95 then h
:= 4
2975 //if a > 255 then a := 255;
2977 e_DrawFillQuad(0, 0, gPlayerScreenSize
.X
-1, gPlayerScreenSize
.Y
-1, 255, 0, 0, 255-h
*50);
2978 //e_DrawFillQuad(0, 0, gPlayerScreenSize.X-1, gPlayerScreenSize.Y-1, 255-min(128, a), 255-a, 255-a, 0, B_FILTER);
2981 procedure TPlayer
.DrawPickup();
2985 if FPickup
= 0 then Exit
;
2989 if a
< 15 then h
:= 1
2990 else if a
< 35 then h
:= 2
2991 else if a
< 55 then h
:= 3
2992 else if a
< 75 then h
:= 4
2995 e_DrawFillQuad(0, 0, gPlayerScreenSize
.X
-1, gPlayerScreenSize
.Y
-1, 150, 200, 150, 255-h
*50);
2998 procedure TPlayer
.DoPunch();
3003 if FPunchAnim
<> nil then begin
3008 st
:= 'FRAMES_PUNCH';
3009 if R_BERSERK
in FRulez
then
3010 st
:= st
+ '_BERSERK';
3011 if FKeys
[KEY_UP
].Pressed
then
3013 else if FKeys
[KEY_DOWN
].Pressed
then
3015 g_Frames_Get(id
, st
);
3016 FPunchAnim
:= TAnimation
.Create(id
, False, 1);
3019 procedure TPlayer
.Fire();
3021 f
, DidFire
: Boolean;
3022 wx
, wy
, xd
, yd
: Integer;
3025 if g_Game_IsClient
then Exit
;
3026 // FBFGFireCounter - âðåìÿ ïåðåä âûñòðåëîì (äëÿ BFG)
3027 // FReloading - âðåìÿ ïîñëå âûñòðåëà (äëÿ âñåãî)
3035 if FReloading
[FCurrWeap
] <> 0 then Exit
;
3040 wx
:= FObj
.X
+WEAPONPOINT
[FDirection
].X
;
3041 wy
:= FObj
.Y
+WEAPONPOINT
[FDirection
].Y
;
3042 xd
:= wx
+IfThen(FDirection
= TDirection
.D_LEFT
, -30, 30);
3043 yd
:= wy
+firediry();
3049 if R_BERSERK
in FRulez
then
3051 //g_Weapon_punch(FObj.X+FObj.Rect.X, FObj.Y+FObj.Rect.Y, 75, FUID);
3052 locobj
.X
:= FObj
.X
+FObj
.Rect
.X
;
3053 locobj
.Y
:= FObj
.Y
+FObj
.Rect
.Y
;
3056 locobj
.rect
.Width
:= 39;
3057 locobj
.rect
.Height
:= 52;
3058 locobj
.Vel
.X
:= (xd
-wx
) div 2;
3059 locobj
.Vel
.Y
:= (yd
-wy
) div 2;
3060 locobj
.Accel
.X
:= xd
-wx
;
3061 locobj
.Accel
.y
:= yd
-wy
;
3063 if g_Weapon_Hit(@locobj
, 50, FUID
, HIT_SOME
) <> 0 then
3064 g_Sound_PlayExAt('SOUND_WEAPON_HITBERSERK', FObj
.X
, FObj
.Y
)
3066 g_Sound_PlayExAt('SOUND_WEAPON_MISSBERSERK', FObj
.X
, FObj
.Y
);
3068 if (gFlash
= 1) and (FPain
< 50) then FPain
:= min(FPain
+ 25, 50);
3072 g_Weapon_punch(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
, 3, FUID
);
3076 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
3081 if g_Weapon_chainsaw(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
,
3082 IfThen(gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
], 9, 3), FUID
) <> 0 then
3084 FSawSoundSelect
.Stop();
3086 FSawSoundHit
.PlayAt(FObj
.X
, FObj
.Y
);
3088 else if not FSawSoundHit
.IsPlaying() then
3090 FSawSoundSelect
.Stop();
3091 FSawSound
.PlayAt(FObj
.X
, FObj
.Y
);
3094 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
3100 if FAmmo
[A_BULLETS
] > 0 then
3102 g_Weapon_pistol(wx
, wy
, xd
, yd
, FUID
);
3103 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
3104 Dec(FAmmo
[A_BULLETS
]);
3105 FFireAngle
:= FAngle
;
3108 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
3109 GameVelX
, GameVelY
-2, SHELL_BULLET
);
3113 if FAmmo
[A_SHELLS
] > 0 then
3115 g_Weapon_shotgun(wx
, wy
, xd
, yd
, FUID
);
3116 if not gSoundEffectsDF
then g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN', wx
, wy
);
3117 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
3118 Dec(FAmmo
[A_SHELLS
]);
3119 FFireAngle
:= FAngle
;
3123 FShellType
:= SHELL_SHELL
;
3127 if FAmmo
[A_SHELLS
] >= 2 then
3129 g_Weapon_dshotgun(wx
, wy
, xd
, yd
, FUID
);
3130 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
3131 Dec(FAmmo
[A_SHELLS
], 2);
3132 FFireAngle
:= FAngle
;
3136 FShellType
:= SHELL_DBLSHELL
;
3140 if FAmmo
[A_BULLETS
] > 0 then
3142 g_Weapon_mgun(wx
, wy
, xd
, yd
, FUID
);
3143 if not gSoundEffectsDF
then g_Sound_PlayExAt('SOUND_WEAPON_FIREPISTOL', wx
, wy
);
3144 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
3145 Dec(FAmmo
[A_BULLETS
]);
3146 FFireAngle
:= FAngle
;
3149 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
3150 GameVelX
, GameVelY
-2, SHELL_BULLET
);
3153 WEAPON_ROCKETLAUNCHER
:
3154 if FAmmo
[A_ROCKETS
] > 0 then
3156 g_Weapon_rocket(wx
, wy
, xd
, yd
, FUID
);
3157 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
3158 Dec(FAmmo
[A_ROCKETS
]);
3159 FFireAngle
:= FAngle
;
3165 if FAmmo
[A_CELLS
] > 0 then
3167 g_Weapon_plasma(wx
, wy
, xd
, yd
, FUID
);
3168 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
3169 Dec(FAmmo
[A_CELLS
]);
3170 FFireAngle
:= FAngle
;
3176 if (FAmmo
[A_CELLS
] >= 40) and (FBFGFireCounter
= -1) then
3178 FBFGFireCounter
:= 17;
3179 if not FNoReload
then
3180 g_Sound_PlayExAt('SOUND_WEAPON_STARTFIREBFG', FObj
.X
, FObj
.Y
);
3181 Dec(FAmmo
[A_CELLS
], 40);
3185 WEAPON_SUPERPULEMET
:
3186 if FAmmo
[A_SHELLS
] > 0 then
3188 g_Weapon_shotgun(wx
, wy
, xd
, yd
, FUID
);
3189 if not gSoundEffectsDF
then g_Sound_PlayExAt('SOUND_WEAPON_FIRECGUN', wx
, wy
);
3190 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
3191 Dec(FAmmo
[A_SHELLS
]);
3192 FFireAngle
:= FAngle
;
3195 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
3196 GameVelX
, GameVelY
-2, SHELL_SHELL
);
3199 WEAPON_FLAMETHROWER
:
3200 if FAmmo
[A_FUEL
] > 0 then
3202 g_Weapon_flame(wx
, wy
, xd
, yd
, FUID
);
3204 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
3206 FFireAngle
:= FAngle
;
3213 if g_Game_IsNet
and g_Game_IsServer
then MH_SEND_PlayerStats(FUID
);
3217 if g_Game_IsNet
then
3221 if FCurrWeap
<> WEAPON_BFG
then
3222 MH_SEND_PlayerFire(FUID
, FCurrWeap
, wx
, wy
, xd
, yd
, LastShotID
)
3224 if not FNoReload
then
3225 MH_SEND_Sound(FObj
.X
, FObj
.Y
, 'SOUND_WEAPON_STARTFIREBFG');
3228 MH_SEND_PlayerStats(FUID
);
3233 if (FAngle
= 0) or (FAngle
= 180) then SetAction(A_ATTACK
)
3234 else if (FAngle
= ANGLE_LEFTDOWN
) or (FAngle
= ANGLE_RIGHTDOWN
) then SetAction(A_ATTACKDOWN
)
3235 else if (FAngle
= ANGLE_LEFTUP
) or (FAngle
= ANGLE_RIGHTUP
) then SetAction(A_ATTACKUP
);
3238 function TPlayer
.GetAmmoByWeapon(Weapon
: Byte): Word;
3241 WEAPON_PISTOL
, WEAPON_CHAINGUN
: Result
:= FAmmo
[A_BULLETS
];
3242 WEAPON_SHOTGUN1
, WEAPON_SHOTGUN2
, WEAPON_SUPERPULEMET
: Result
:= FAmmo
[A_SHELLS
];
3243 WEAPON_ROCKETLAUNCHER
: Result
:= FAmmo
[A_ROCKETS
];
3244 WEAPON_PLASMA
, WEAPON_BFG
: Result
:= FAmmo
[A_CELLS
];
3245 WEAPON_FLAMETHROWER
: Result
:= FAmmo
[A_FUEL
];
3250 function TPlayer
.HeadInLiquid(XInc
, YInc
: Integer): Boolean;
3252 Result
:= g_Map_CollidePanel(FObj
.X
+PLAYER_HEADRECT
.X
+XInc
, FObj
.Y
+PLAYER_HEADRECT
.Y
+YInc
,
3253 PLAYER_HEADRECT
.Width
, PLAYER_HEADRECT
.Height
,
3254 PANEL_WATER
or PANEL_ACID1
or PANEL_ACID2
, True);
3257 procedure TPlayer
.FlamerOn
;
3259 FFlameSoundOff
.Stop();
3260 FFlameSoundOff
.SetPosition(0);
3263 if (not FFlameSoundOn
.IsPlaying()) and (not FFlameSoundWork
.IsPlaying()) then
3264 FFlameSoundWork
.PlayAt(FObj
.X
, FObj
.Y
);
3268 FFlameSoundOn
.PlayAt(FObj
.X
, FObj
.Y
);
3273 procedure TPlayer
.FlamerOff
;
3277 FFlameSoundOn
.Stop();
3278 FFlameSoundOn
.SetPosition(0);
3279 FFlameSoundWork
.Stop();
3280 FFlameSoundWork
.SetPosition(0);
3281 FFlameSoundOff
.PlayAt(FObj
.X
, FObj
.Y
);
3286 procedure TPlayer
.JetpackOn
;
3290 FJetSoundOn
.SetPosition(0);
3291 FJetSoundOn
.PlayAt(FObj
.X
, FObj
.Y
);
3295 procedure TPlayer
.JetpackOff
;
3299 FJetSoundOff
.SetPosition(0);
3300 FJetSoundOff
.PlayAt(FObj
.X
, FObj
.Y
);
3303 procedure TPlayer
.CatchFire(Attacker
: Word; Timeout
: Integer = PLAYER_BURN_TIME
);
3305 if Timeout
<= 0 then
3307 if (FMegaRulez
[MR_SUIT
] > gTime
) or (FMegaRulez
[MR_INVUL
] > gTime
) then
3308 exit
; // Íå çàãîðàåìñÿ êîãäà åñòü çàùèòà
3309 if g_Obj_CollidePanel(@FObj
, 0, 0, PANEL_WATER
or PANEL_ACID1
or PANEL_ACID2
) then
3310 exit
; // Íå ïîäãîðàåì â âîäå íà âñÿêèé ñëó÷àé
3311 if FFireTime
<= 0 then
3312 g_Sound_PlayExAt('SOUND_IGNITE', FObj
.X
, FObj
.Y
);
3313 FFireTime
:= Timeout
;
3314 FFireAttacker
:= Attacker
;
3315 if g_Game_IsNet
and g_Game_IsServer
then
3316 MH_SEND_PlayerStats(FUID
);
3319 procedure TPlayer
.Jump();
3321 if gFly
or FJetpack
then
3323 // Ïîëåò (÷èò-êîä èëè äæåòïàê):
3324 if FObj
.Vel
.Y
> -VEL_FLY
then
3325 FObj
.Vel
.Y
:= FObj
.Vel
.Y
- 3;
3328 if FJetFuel
> 0 then
3330 if (FJetFuel
< 1) and g_Game_IsServer
then
3334 if g_Game_IsNet
then
3335 MH_SEND_PlayerStats(FUID
);
3341 // Íå âêëþ÷àòü äæåòïàê â ðåæèìå ïðîõîæäåíèÿ ñêâîçü ñòåíû
3343 FCanJetpack
:= False;
3345 // Ïðûãàåì èëè âñïëûâàåì:
3346 if (CollideLevel(0, 1) or
3347 g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+PLAYER_RECT
.Y
+36, PLAYER_RECT
.Width
,
3348 PLAYER_RECT
.Height
-33, PANEL_STEP
, False)
3349 ) and (FObj
.Accel
.Y
= 0) then // Íå ïðûãàòü, åñëè åñòü âåðòèêàëüíîå óñêîðåíèå
3351 FObj
.Vel
.Y
:= -VEL_JUMP
;
3352 FCanJetpack
:= False;
3356 if BodyInLiquid(0, 0) then
3357 FObj
.Vel
.Y
:= -VEL_SW
3358 else if (FJetFuel
> 0) and FCanJetpack
and
3359 g_Game_IsServer
and (not g_Obj_CollideLiquid(@FObj
, 0, 0)) then
3363 if g_Game_IsNet
then
3364 MH_SEND_PlayerStats(FUID
);
3369 procedure TPlayer
.Kill(KillType
: Byte; SpawnerUID
: Word; t
: Byte);
3371 a
, i
, k
, ab
, ar
: Byte;
3375 srv
, netsrv
: Boolean;
3381 procedure PushItem(t
: Byte);
3385 id
:= g_Items_Create(FObj
.X
, FObj
.Y
, t
, True, False);
3386 it
:= g_Items_ByIdx(id
);
3387 if KillType
= K_EXTRAHARDKILL
then // -7..+7; -8..0
3389 g_Obj_Push(@it
.Obj
, (FObj
.Vel
.X
div 2)-7+Random(15),
3390 (FObj
.Vel
.Y
div 2)-Random(9));
3391 it
.positionChanged(); // this updates spatial accelerators
3395 if KillType
= K_HARDKILL
then // -5..+5; -5..0
3397 g_Obj_Push(@it
.Obj
, (FObj
.Vel
.X
div 2)-5+Random(11),
3398 (FObj
.Vel
.Y
div 2)-Random(6));
3400 else // -3..+3; -3..0
3402 g_Obj_Push(@it
.Obj
, (FObj
.Vel
.X
div 2)-3+Random(7),
3403 (FObj
.Vel
.Y
div 2)-Random(4));
3405 it
.positionChanged(); // this updates spatial accelerators
3408 if g_Game_IsNet
and g_Game_IsServer
then
3409 MH_SEND_ItemSpawn(True, id
);
3413 DoFrags
:= (gGameSettings
.MaxLives
= 0) or (gGameSettings
.GameMode
= GM_COOP
);
3414 Srv
:= g_Game_IsServer
;
3415 Netsrv
:= g_Game_IsServer
and g_Game_IsNet
;
3416 if Srv
then FDeath
:= FDeath
+ 1;
3421 if not FPhysics
then
3427 if (gGameSettings
.MaxLives
> 0) and Srv
and (gLMSRespawn
= LMS_RESPAWN_NONE
) then
3429 if FLives
> 0 then FLives
:= FLives
- 1;
3430 if FLives
= 0 then FNoRespawn
:= True;
3433 // Íîìåð òèïà ñìåðòè:
3436 K_SIMPLEKILL
: a
:= 1;
3438 K_EXTRAHARDKILL
: a
:= 3;
3443 if not FModel
.PlaySound(MODELSOUND_DIE
, a
, FObj
.X
, FObj
.Y
) then
3445 if FModel
.PlaySound(MODELSOUND_DIE
, i
, FObj
.X
, FObj
.Y
) then
3452 FTime
[T_RESPAWN
] := gTime
+ TIME_RESPAWN1
;
3454 FTime
[T_RESPAWN
] := gTime
+ TIME_RESPAWN2
;
3455 K_EXTRAHARDKILL
, K_FALLKILL
:
3456 FTime
[T_RESPAWN
] := gTime
+ TIME_RESPAWN3
;
3459 // Ïåðåêëþ÷àåì ñîñòîÿíèå:
3463 K_HARDKILL
, K_EXTRAHARDKILL
:
3467 // Ðåàêöèÿ ìîíñòðîâ íà ñìåðòü èãðîêà:
3468 if (KillType
<> K_FALLKILL
) and (Srv
) then
3469 g_Monsters_killedp();
3471 if SpawnerUID
= FUID
then
3473 if Srv
and (DoFrags
or (gGameSettings
.GameMode
= GM_TDM
)) then
3478 g_Console_Add(Format(_lc
[I_PLAYER_KILL_SELF
], [FName
]), True);
3481 if g_GetUIDType(SpawnerUID
) = UID_PLAYER
then
3482 begin // Óáèò äðóãèì èãðîêîì
3483 KP
:= g_Player_Get(SpawnerUID
);
3484 if (KP
<> nil) and Srv
then
3486 if (DoFrags
or (gGameSettings
.GameMode
= GM_TDM
)) then
3487 if SameTeam(FUID
, SpawnerUID
) then
3497 if (gGameSettings
.GameMode
= GM_TDM
) and DoFrags
then
3498 Inc(gTeamStat
[KP
.Team
].Goals
,
3499 IfThen(SameTeam(FUID
, SpawnerUID
), -1, 1));
3501 if netsrv
then MH_SEND_PlayerStats(SpawnerUID
);
3504 plr
:= g_Player_Get(SpawnerUID
);
3512 g_Console_Add(Format(_lc
[I_PLAYER_KILL_EXTRAHARD_2
],
3516 g_Console_Add(Format(_lc
[I_PLAYER_KILL_EXTRAHARD_1
],
3520 g_Console_Add(Format(_lc
[I_PLAYER_KILL
],
3525 else if g_GetUIDType(SpawnerUID
) = UID_MONSTER
then
3526 begin // Óáèò ìîíñòðîì
3527 mon
:= g_Monsters_ByUID(SpawnerUID
);
3531 s
:= g_Mons_GetKilledByTypeId(mon
.MonsterType
);
3535 g_Console_Add(Format(_lc
[I_PLAYER_KILL_EXTRAHARD_2
],
3539 g_Console_Add(Format(_lc
[I_PLAYER_KILL_EXTRAHARD_1
],
3543 g_Console_Add(Format(_lc
[I_PLAYER_KILL
],
3548 else // Îñîáûå òèïû ñìåðòè
3551 HIT_SELF
: g_Console_Add(Format(_lc
[I_PLAYER_KILL_SELF
], [FName
]), True);
3552 HIT_FALL
: g_Console_Add(Format(_lc
[I_PLAYER_KILL_FALL
], [FName
]), True);
3553 HIT_WATER
: g_Console_Add(Format(_lc
[I_PLAYER_KILL_WATER
], [FName
]), True);
3554 HIT_ACID
: g_Console_Add(Format(_lc
[I_PLAYER_KILL_ACID
], [FName
]), True);
3555 HIT_TRAP
: g_Console_Add(Format(_lc
[I_PLAYER_KILL_TRAP
], [FName
]), True);
3556 else g_Console_Add(Format(_lc
[I_PLAYER_DIED
], [FName
]), True);
3562 for a
:= WP_FIRST
to WP_LAST
do
3566 WEAPON_SAW
: i
:= ITEM_WEAPON_SAW
;
3567 WEAPON_SHOTGUN1
: i
:= ITEM_WEAPON_SHOTGUN1
;
3568 WEAPON_SHOTGUN2
: i
:= ITEM_WEAPON_SHOTGUN2
;
3569 WEAPON_CHAINGUN
: i
:= ITEM_WEAPON_CHAINGUN
;
3570 WEAPON_ROCKETLAUNCHER
: i
:= ITEM_WEAPON_ROCKETLAUNCHER
;
3571 WEAPON_PLASMA
: i
:= ITEM_WEAPON_PLASMA
;
3572 WEAPON_BFG
: i
:= ITEM_WEAPON_BFG
;
3573 WEAPON_SUPERPULEMET
: i
:= ITEM_WEAPON_SUPERPULEMET
;
3574 WEAPON_FLAMETHROWER
: i
:= ITEM_WEAPON_FLAMETHROWER
;
3583 if R_ITEM_BACKPACK
in FRulez
then
3584 PushItem(ITEM_AMMO_BACKPACK
);
3586 // Âûáðîñ ðàêåòíîãî ðàíöà:
3587 if FJetFuel
> 0 then
3588 PushItem(ITEM_JETPACK
);
3591 if (not (gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
])) or
3592 (not LongBool(gGameSettings
.Options
and GAME_OPTION_DMKEYS
)) then
3594 if R_KEY_RED
in FRulez
then
3595 PushItem(ITEM_KEY_RED
);
3597 if R_KEY_GREEN
in FRulez
then
3598 PushItem(ITEM_KEY_GREEN
);
3600 if R_KEY_BLUE
in FRulez
then
3601 PushItem(ITEM_KEY_BLUE
);
3605 DropFlag(KillType
= K_FALLKILL
);
3608 g_Player_CreateCorpse(Self
);
3610 if Srv
and (gGameSettings
.MaxLives
> 0) and FNoRespawn
and
3611 (gLMSRespawn
= LMS_RESPAWN_NONE
) then
3617 for i
:= Low(gPlayers
) to High(gPlayers
) do
3619 if gPlayers
[i
] = nil then continue
;
3620 if (not gPlayers
[i
].FNoRespawn
) and (not gPlayers
[i
].FSpectator
) then
3623 if gPlayers
[i
].FTeam
= TEAM_RED
then Inc(ar
)
3624 else if gPlayers
[i
].FTeam
= TEAM_BLUE
then Inc(ab
);
3629 OldLR
:= gLMSRespawn
;
3630 if (gGameSettings
.GameMode
= GM_COOP
) then
3634 // everyone is dead, restart the map
3635 g_Game_Message(_lc
[I_MESSAGE_LMS_LOSE
], 144);
3637 MH_SEND_GameEvent(NET_EV_LMS_LOSE
);
3638 gLMSRespawn
:= LMS_RESPAWN_FINAL
;
3639 gLMSRespawnTime
:= gTime
+ 5000;
3641 else if (a
= 1) then
3643 if (gPlayers
[k
] <> nil) and not (gPlayers
[k
] is TBot
) then
3644 if (gPlayers
[k
] = gPlayer1
) or
3645 (gPlayers
[k
] = gPlayer2
) then
3646 g_Console_Add('*** ' + _lc
[I_MESSAGE_LMS_SURVIVOR
] + ' ***', True)
3647 else if Netsrv
and (gPlayers
[k
].FClientID
>= 0) then
3648 MH_SEND_GameEvent(NET_EV_LMS_SURVIVOR
, 0, 'N', gPlayers
[k
].FClientID
);
3651 else if (gGameSettings
.GameMode
= GM_TDM
) then
3653 if (ab
= 0) and (ar
<> 0) then
3656 g_Game_Message(Format(_lc
[I_MESSAGE_TLMS_WIN
], [AnsiUpperCase(_lc
[I_GAME_TEAM_RED
])]), 144);
3658 MH_SEND_GameEvent(NET_EV_TLMS_WIN
, TEAM_RED
);
3659 Inc(gTeamStat
[TEAM_RED
].Goals
);
3660 gLMSRespawn
:= LMS_RESPAWN_FINAL
;
3661 gLMSRespawnTime
:= gTime
+ 5000;
3663 else if (ar
= 0) and (ab
<> 0) then
3666 g_Game_Message(Format(_lc
[I_MESSAGE_TLMS_WIN
], [AnsiUpperCase(_lc
[I_GAME_TEAM_BLUE
])]), 144);
3668 MH_SEND_GameEvent(NET_EV_TLMS_WIN
, TEAM_BLUE
);
3669 Inc(gTeamStat
[TEAM_BLUE
].Goals
);
3670 gLMSRespawn
:= LMS_RESPAWN_FINAL
;
3671 gLMSRespawnTime
:= gTime
+ 5000;
3673 else if (ar
= 0) and (ab
= 0) then
3676 g_Game_Message(_lc
[I_GAME_WIN_DRAW
], 144);
3678 MH_SEND_GameEvent(NET_EV_LMS_DRAW
, 0, FName
);
3679 gLMSRespawn
:= LMS_RESPAWN_FINAL
;
3680 gLMSRespawnTime
:= gTime
+ 5000;
3683 else if (gGameSettings
.GameMode
= GM_DM
) then
3687 if gPlayers
[k
] <> nil then
3690 // survivor is the winner
3691 g_Game_Message(Format(_lc
[I_MESSAGE_LMS_WIN
], [AnsiUpperCase(FName
)]), 144);
3693 MH_SEND_GameEvent(NET_EV_LMS_WIN
, 0, FName
);
3696 gLMSRespawn
:= LMS_RESPAWN_FINAL
;
3697 gLMSRespawnTime
:= gTime
+ 5000;
3699 else if (a
= 0) then
3701 // everyone is dead, restart the map
3702 g_Game_Message(_lc
[I_GAME_WIN_DRAW
], 144);
3704 MH_SEND_GameEvent(NET_EV_LMS_DRAW
, 0, FName
);
3705 gLMSRespawn
:= LMS_RESPAWN_FINAL
;
3706 gLMSRespawnTime
:= gTime
+ 5000;
3709 if srv
and (OldLR
= LMS_RESPAWN_NONE
) and (gLMSRespawn
> LMS_RESPAWN_NONE
) then
3711 if NetMode
= NET_SERVER
then
3712 MH_SEND_GameEvent(NET_EV_LMS_WARMUP
, gLMSRespawnTime
- gTime
)
3714 g_Console_Add(Format(_lc
[I_MSG_WARMUP_START
], [(gLMSRespawnTime
- gTime
) div 1000]), True);
3720 MH_SEND_PlayerStats(FUID
);
3721 MH_SEND_PlayerDeath(FUID
, KillType
, t
, SpawnerUID
);
3722 if gGameSettings
.GameMode
= GM_TDM
then MH_SEND_GameStats
;
3725 if srv
and FNoRespawn
then Spectate(True);
3726 FWantsInGame
:= True;
3729 function TPlayer
.BodyInLiquid(XInc
, YInc
: Integer): Boolean;
3731 Result
:= g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
, PLAYER_RECT
.Width
,
3732 PLAYER_RECT
.Height
-20, PANEL_WATER
or PANEL_ACID1
or PANEL_ACID2
, False);
3735 function TPlayer
.BodyInAcid(XInc
, YInc
: Integer): Boolean;
3737 Result
:= g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
, PLAYER_RECT
.Width
,
3738 PLAYER_RECT
.Height
-20, PANEL_ACID1
or PANEL_ACID2
, False);
3741 procedure TPlayer
.MakeBloodSimple(Count
: Word);
3743 g_GFX_Blood(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)+8,
3744 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2),
3745 Count
div 2, 3, -1, 16, (PLAYER_RECT
.Height
*2 div 3),
3746 FModel
.Blood
.R
, FModel
.Blood
.G
, FModel
.Blood
.B
, FModel
.Blood
.Kind
);
3747 g_GFX_Blood(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-8,
3748 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2),
3749 Count
div 2, -3, -1, 16, (PLAYER_RECT
.Height
*2) div 3,
3750 FModel
.Blood
.R
, FModel
.Blood
.G
, FModel
.Blood
.B
, FModel
.Blood
.Kind
);
3753 procedure TPlayer
.MakeBloodVector(Count
: Word; VelX
, VelY
: Integer);
3755 g_GFX_Blood(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2),
3756 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2),
3757 Count
, VelX
, VelY
, 16, (PLAYER_RECT
.Height
*2) div 3,
3758 FModel
.Blood
.R
, FModel
.Blood
.G
, FModel
.Blood
.B
, FModel
.Blood
.Kind
);
3761 procedure TPlayer
.QueueWeaponSwitch(Weapon
: Byte);
3763 if g_Game_IsClient
then Exit
;
3764 if Weapon
> High(FWeapon
) then Exit
;
3765 FNextWeap
:= FNextWeap
or (1 shl Weapon
);
3768 procedure TPlayer
.resetWeaponQueue ();
3771 FNextWeapDelay
:= 0;
3774 function TPlayer
.hasAmmoForWeapon (weapon
: Byte): Boolean;
3778 WEAPON_KASTET
, WEAPON_SAW
: result
:= true;
3779 WEAPON_SHOTGUN1
, WEAPON_SHOTGUN2
, WEAPON_SUPERPULEMET
: result
:= (FAmmo
[A_SHELLS
] > 0);
3780 WEAPON_PISTOL
, WEAPON_CHAINGUN
: result
:= (FAmmo
[A_BULLETS
] > 0);
3781 WEAPON_ROCKETLAUNCHER
: result
:= (FAmmo
[A_ROCKETS
] > 0);
3782 WEAPON_PLASMA
, WEAPON_BFG
: result
:= (FAmmo
[A_CELLS
] > 0);
3783 WEAPON_FLAMETHROWER
: result
:= (FAmmo
[A_FUEL
] > 0);
3784 else result
:= (weapon
< length(FWeapon
));
3788 // return 255 for "no switch"
3789 function TPlayer
.getNextWeaponIndex (): Byte;
3792 wantThisWeapon
: array[0..64] of Boolean;
3793 wwc
: Integer = 0; //HACK!
3796 result
:= 255; // default result: "no switch"
3797 // had weapon cycling on previous frame? remove that flag
3798 if (FNextWeap
and $2000) <> 0 then
3800 FNextWeap
:= FNextWeap
and $1FFF;
3801 FNextWeapDelay
:= 0;
3803 // cycling has priority
3804 if (FNextWeap
and $C000) <> 0 then
3806 if (FNextWeap
and $8000) <> 0 then
3810 FNextWeap
:= FNextWeap
or $2000; // we need this
3811 if FNextWeapDelay
> 0 then
3812 exit
; // cooldown time
3814 for i
:= 0 to High(FWeapon
) do
3816 cwi
:= (cwi
+length(FWeapon
)+dir
) mod length(FWeapon
);
3817 if FWeapon
[cwi
] then
3819 //e_WriteLog(Format(' SWITCH: cur=%d; new=%d', [FCurrWeap, cwi]), MSG_WARNING);
3820 result
:= Byte(cwi
);
3821 FNextWeapDelay
:= WEAPON_DELAY
;
3829 for i
:= 0 to High(wantThisWeapon
) do
3830 wantThisWeapon
[i
] := false;
3831 for i
:= 0 to High(FWeapon
) do
3832 if (FNextWeap
and (1 shl i
)) <> 0 then
3834 wantThisWeapon
[i
] := true;
3837 // exclude currently selected weapon from the set
3838 wantThisWeapon
[FCurrWeap
] := false;
3839 // slow down alterations a little
3842 //e_WriteLog(Format(' FNextWeap=%x; delay=%d', [FNextWeap, FNextWeapDelay]), MSG_WARNING);
3843 // more than one weapon requested, assume "alteration" and check alteration delay
3844 if FNextWeapDelay
> 0 then
3850 // do not reset weapon queue, it will be done in `RealizeCurrentWeapon()`
3851 // but clear all counters if no weapon should be switched
3857 //e_WriteLog(Format('wwc=%d', [wwc]), MSG_WARNING);
3858 // try weapons in descending order
3859 for i
:= High(FWeapon
) downto 0 do
3861 if wantThisWeapon
[i
] and FWeapon
[i
] and ((wwc
= 1) or hasAmmoForWeapon(i
)) then
3866 FNextWeapDelay
:= WEAPON_DELAY
* 2; // anyway, 'cause why not
3870 // no suitable weapon found, so reset the queue, to avoid accidental "queuing" of weapon w/o ammo
3874 procedure TPlayer
.RealizeCurrentWeapon();
3875 function switchAllowed (): Boolean;
3880 if FBFGFireCounter
<> -1 then
3882 if FTime
[T_SWITCH
] > gTime
then
3884 for i
:= WP_FIRST
to WP_LAST
do
3885 if FReloading
[i
] > 0 then
3893 //e_WriteLog(Format('***RealizeCurrentWeapon: FNextWeap=%x; FNextWeapDelay=%d', [FNextWeap, FNextWeapDelay]), MSG_WARNING);
3894 //FNextWeap := FNextWeap and $1FFF;
3895 if FNextWeapDelay
> 0 then Dec(FNextWeapDelay
); // "alteration delay"
3897 if not switchAllowed
then
3899 //HACK for weapon cycling
3900 if (FNextWeap
and $E000) <> 0 then FNextWeap
:= 0;
3904 nw
:= getNextWeaponIndex();
3905 if nw
= 255 then exit
; // don't reset anything here
3906 if nw
> High(FWeapon
) then
3908 // don't forget to reset queue here!
3909 //e_WriteLog(' RealizeCurrentWeapon: WUTAFUUUU', MSG_WARNING);
3917 FTime
[T_SWITCH
] := gTime
+156;
3918 if FCurrWeap
= WEAPON_SAW
then FSawSoundSelect
.PlayAt(FObj
.X
, FObj
.Y
);
3919 FModel
.SetWeapon(FCurrWeap
);
3920 if g_Game_IsNet
then MH_SEND_PlayerStats(FUID
);
3924 procedure TPlayer
.NextWeapon();
3926 if g_Game_IsClient
then Exit
;
3930 procedure TPlayer
.PrevWeapon();
3932 if g_Game_IsClient
then Exit
;
3936 procedure TPlayer
.SetWeapon(W
: Byte);
3938 if FCurrWeap
<> W
then
3939 if W
= WEAPON_SAW
then
3940 FSawSoundSelect
.PlayAt(FObj
.X
, FObj
.Y
);
3943 FModel
.SetWeapon(CurrWeap
);
3947 function TPlayer
.PickItem(ItemType
: Byte; arespawn
: Boolean; var remove
: Boolean): Boolean;
3949 function allowBerserkSwitching (): Boolean;
3951 if (FBFGFireCounter
<> -1) then begin result
:= false; exit
; end;
3953 if gBerserkAutoswitch
then exit
;
3954 if not conIsCheatsEnabled
then exit
;
3962 if g_Game_IsClient
then Exit
;
3964 // a = true - ìåñòî ñïàâíà ïðåäìåòà:
3965 a
:= LongBool(gGameSettings
.Options
and GAME_OPTION_WEAPONSTAY
) and arespawn
;
3970 if (FHealth
< PLAYER_HP_SOFT
) or (FFireTime
> 0) then
3972 if FHealth
< PLAYER_HP_SOFT
then IncMax(FHealth
, 10, PLAYER_HP_SOFT
);
3976 if gFlash
= 2 then Inc(FPickup
, 5);
3980 if (FHealth
< PLAYER_HP_SOFT
) or (FFireTime
> 0) then
3982 if FHealth
< PLAYER_HP_SOFT
then IncMax(FHealth
, 25, PLAYER_HP_SOFT
);
3986 if gFlash
= 2 then Inc(FPickup
, 5);
3990 if FArmor
< PLAYER_AP_SOFT
then
3992 FArmor
:= PLAYER_AP_SOFT
;
3995 if gFlash
= 2 then Inc(FPickup
, 5);
3999 if FArmor
< PLAYER_AP_LIMIT
then
4001 FArmor
:= PLAYER_AP_LIMIT
;
4004 if gFlash
= 2 then Inc(FPickup
, 5);
4008 if (FHealth
< PLAYER_HP_LIMIT
) or (FFireTime
> 0) then
4010 if FHealth
< PLAYER_HP_LIMIT
then IncMax(FHealth
, 100, PLAYER_HP_LIMIT
);
4014 if gFlash
= 2 then Inc(FPickup
, 5);
4018 if (FHealth
< PLAYER_HP_LIMIT
) or (FArmor
< PLAYER_AP_LIMIT
) or (FFireTime
> 0) then
4020 if FHealth
< PLAYER_HP_LIMIT
then
4021 FHealth
:= PLAYER_HP_LIMIT
;
4022 if FArmor
< PLAYER_AP_LIMIT
then
4023 FArmor
:= PLAYER_AP_LIMIT
;
4027 if gFlash
= 2 then Inc(FPickup
, 5);
4031 if (not FWeapon
[WEAPON_SAW
]) or ((not arespawn
) and (gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
])) then
4033 FWeapon
[WEAPON_SAW
] := True;
4035 if gFlash
= 2 then Inc(FPickup
, 5);
4036 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
4039 ITEM_WEAPON_SHOTGUN1
:
4040 if (FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
]) or not FWeapon
[WEAPON_SHOTGUN1
] then
4042 // Íóæíî, ÷òîáû íå âçÿòü âñå ïóëè ñðàçó:
4043 if a
and FWeapon
[WEAPON_SHOTGUN1
] then Exit
;
4045 IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
4046 FWeapon
[WEAPON_SHOTGUN1
] := True;
4048 if gFlash
= 2 then Inc(FPickup
, 5);
4049 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
4052 ITEM_WEAPON_SHOTGUN2
:
4053 if (FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
]) or not FWeapon
[WEAPON_SHOTGUN2
] then
4055 if a
and FWeapon
[WEAPON_SHOTGUN2
] then Exit
;
4057 IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
4058 FWeapon
[WEAPON_SHOTGUN2
] := True;
4060 if gFlash
= 2 then Inc(FPickup
, 5);
4061 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
4064 ITEM_WEAPON_CHAINGUN
:
4065 if (FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
]) or not FWeapon
[WEAPON_CHAINGUN
] then
4067 if a
and FWeapon
[WEAPON_CHAINGUN
] then Exit
;
4069 IncMax(FAmmo
[A_BULLETS
], 50, FMaxAmmo
[A_BULLETS
]);
4070 FWeapon
[WEAPON_CHAINGUN
] := True;
4072 if gFlash
= 2 then Inc(FPickup
, 5);
4073 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
4076 ITEM_WEAPON_ROCKETLAUNCHER
:
4077 if (FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
]) or not FWeapon
[WEAPON_ROCKETLAUNCHER
] then
4079 if a
and FWeapon
[WEAPON_ROCKETLAUNCHER
] then Exit
;
4081 IncMax(FAmmo
[A_ROCKETS
], 2, FMaxAmmo
[A_ROCKETS
]);
4082 FWeapon
[WEAPON_ROCKETLAUNCHER
] := True;
4084 if gFlash
= 2 then Inc(FPickup
, 5);
4085 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
4089 if (FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
]) or not FWeapon
[WEAPON_PLASMA
] then
4091 if a
and FWeapon
[WEAPON_PLASMA
] then Exit
;
4093 IncMax(FAmmo
[A_CELLS
], 40, FMaxAmmo
[A_CELLS
]);
4094 FWeapon
[WEAPON_PLASMA
] := True;
4096 if gFlash
= 2 then Inc(FPickup
, 5);
4097 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
4101 if (FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
]) or not FWeapon
[WEAPON_BFG
] then
4103 if a
and FWeapon
[WEAPON_BFG
] then Exit
;
4105 IncMax(FAmmo
[A_CELLS
], 40, FMaxAmmo
[A_CELLS
]);
4106 FWeapon
[WEAPON_BFG
] := True;
4108 if gFlash
= 2 then Inc(FPickup
, 5);
4109 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
4112 ITEM_WEAPON_SUPERPULEMET
:
4113 if (FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
]) or not FWeapon
[WEAPON_SUPERPULEMET
] then
4115 if a
and FWeapon
[WEAPON_SUPERPULEMET
] then Exit
;
4117 IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
4118 FWeapon
[WEAPON_SUPERPULEMET
] := True;
4120 if gFlash
= 2 then Inc(FPickup
, 5);
4121 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
4124 ITEM_WEAPON_FLAMETHROWER
:
4125 if (FAmmo
[A_FUEL
] < FMaxAmmo
[A_FUEL
]) or not FWeapon
[WEAPON_FLAMETHROWER
] then
4127 if a
and FWeapon
[WEAPON_FLAMETHROWER
] then Exit
;
4129 IncMax(FAmmo
[A_FUEL
], 100, FMaxAmmo
[A_FUEL
]);
4130 FWeapon
[WEAPON_FLAMETHROWER
] := True;
4132 if gFlash
= 2 then Inc(FPickup
, 5);
4133 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
4137 if FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
] then
4139 IncMax(FAmmo
[A_BULLETS
], 10, FMaxAmmo
[A_BULLETS
]);
4142 if gFlash
= 2 then Inc(FPickup
, 5);
4145 ITEM_AMMO_BULLETS_BOX
:
4146 if FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
] then
4148 IncMax(FAmmo
[A_BULLETS
], 50, FMaxAmmo
[A_BULLETS
]);
4151 if gFlash
= 2 then Inc(FPickup
, 5);
4155 if FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
] then
4157 IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
4160 if gFlash
= 2 then Inc(FPickup
, 5);
4163 ITEM_AMMO_SHELLS_BOX
:
4164 if FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
] then
4166 IncMax(FAmmo
[A_SHELLS
], 25, FMaxAmmo
[A_SHELLS
]);
4169 if gFlash
= 2 then Inc(FPickup
, 5);
4173 if FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
] then
4175 IncMax(FAmmo
[A_ROCKETS
], 1, FMaxAmmo
[A_ROCKETS
]);
4178 if gFlash
= 2 then Inc(FPickup
, 5);
4181 ITEM_AMMO_ROCKET_BOX
:
4182 if FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
] then
4184 IncMax(FAmmo
[A_ROCKETS
], 5, FMaxAmmo
[A_ROCKETS
]);
4187 if gFlash
= 2 then Inc(FPickup
, 5);
4191 if FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
] then
4193 IncMax(FAmmo
[A_CELLS
], 40, FMaxAmmo
[A_CELLS
]);
4196 if gFlash
= 2 then Inc(FPickup
, 5);
4200 if FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
] then
4202 IncMax(FAmmo
[A_CELLS
], 100, FMaxAmmo
[A_CELLS
]);
4205 if gFlash
= 2 then Inc(FPickup
, 5);
4209 if FAmmo
[A_FUEL
] < FMaxAmmo
[A_FUEL
] then
4211 IncMax(FAmmo
[A_FUEL
], 100, FMaxAmmo
[A_FUEL
]);
4214 if gFlash
= 2 then Inc(FPickup
, 5);
4218 if not(R_ITEM_BACKPACK
in FRulez
) or
4219 (FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
]) or
4220 (FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
]) or
4221 (FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
]) or
4222 (FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
]) or
4223 (FAmmo
[A_FUEL
] < FMaxAmmo
[A_FUEL
]) then
4225 FMaxAmmo
[A_BULLETS
] := AmmoLimits
[1, A_BULLETS
];
4226 FMaxAmmo
[A_SHELLS
] := AmmoLimits
[1, A_SHELLS
];
4227 FMaxAmmo
[A_ROCKETS
] := AmmoLimits
[1, A_ROCKETS
];
4228 FMaxAmmo
[A_CELLS
] := AmmoLimits
[1, A_CELLS
];
4229 FMaxAmmo
[A_FUEL
] := AmmoLimits
[1, A_FUEL
];
4231 if FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
] then
4232 IncMax(FAmmo
[A_BULLETS
], 10, FMaxAmmo
[A_BULLETS
]);
4233 if FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
] then
4234 IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
4235 if FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
] then
4236 IncMax(FAmmo
[A_ROCKETS
], 1, FMaxAmmo
[A_ROCKETS
]);
4237 if FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
] then
4238 IncMax(FAmmo
[A_CELLS
], 40, FMaxAmmo
[A_CELLS
]);
4239 if FAmmo
[A_FUEL
] < FMaxAmmo
[A_FUEL
] then
4240 IncMax(FAmmo
[A_FUEL
], 50, FMaxAmmo
[A_FUEL
]);
4242 FRulez
:= FRulez
+ [R_ITEM_BACKPACK
];
4245 if gFlash
= 2 then Inc(FPickup
, 5);
4249 if not(R_KEY_RED
in FRulez
) then
4251 Include(FRulez
, R_KEY_RED
);
4253 remove
:= (gGameSettings
.GameMode
<> GM_COOP
) and (g_Player_GetCount() < 2);
4254 if gFlash
= 2 then Inc(FPickup
, 5);
4255 if (not remove
) and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETITEM');
4259 if not(R_KEY_GREEN
in FRulez
) then
4261 Include(FRulez
, R_KEY_GREEN
);
4263 remove
:= (gGameSettings
.GameMode
<> GM_COOP
) and (g_Player_GetCount() < 2);
4264 if gFlash
= 2 then Inc(FPickup
, 5);
4265 if (not remove
) and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETITEM');
4269 if not(R_KEY_BLUE
in FRulez
) then
4271 Include(FRulez
, R_KEY_BLUE
);
4273 remove
:= (gGameSettings
.GameMode
<> GM_COOP
) and (g_Player_GetCount() < 2);
4274 if gFlash
= 2 then Inc(FPickup
, 5);
4275 if (not remove
) and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETITEM');
4279 if FMegaRulez
[MR_SUIT
] < gTime
+PLAYER_SUIT_TIME
then
4281 FMegaRulez
[MR_SUIT
] := gTime
+PLAYER_SUIT_TIME
;
4285 if gFlash
= 2 then Inc(FPickup
, 5);
4289 if FAir
< AIR_MAX
then
4294 if gFlash
= 2 then Inc(FPickup
, 5);
4299 if not (R_BERSERK
in FRulez
) then
4301 Include(FRulez
, R_BERSERK
);
4302 if allowBerserkSwitching
then
4304 FCurrWeap
:= WEAPON_KASTET
;
4306 FModel
.SetWeapon(WEAPON_KASTET
);
4311 if gFlash
= 2 then Inc(FPickup
, 5);
4313 FBerserk
:= gTime
+30000;
4318 if (FHealth
< PLAYER_HP_SOFT
) or (FFireTime
> 0) then
4320 if FHealth
< PLAYER_HP_SOFT
then FHealth
:= PLAYER_HP_SOFT
;
4321 FBerserk
:= gTime
+30000;
4329 if FMegaRulez
[MR_INVUL
] < gTime
+PLAYER_INVUL_TIME
then
4331 FMegaRulez
[MR_INVUL
] := gTime
+PLAYER_INVUL_TIME
;
4335 if gFlash
= 2 then Inc(FPickup
, 5);
4339 if (FHealth
< PLAYER_HP_LIMIT
) or (FFireTime
> 0) then
4341 if FHealth
< PLAYER_HP_LIMIT
then IncMax(FHealth
, 4, PLAYER_HP_LIMIT
);
4345 if gFlash
= 2 then Inc(FPickup
, 5);
4349 if FArmor
< PLAYER_AP_LIMIT
then
4351 IncMax(FArmor
, 5, PLAYER_AP_LIMIT
);
4354 if gFlash
= 2 then Inc(FPickup
, 5);
4358 if FJetFuel
< JET_MAX
then
4360 FJetFuel
:= JET_MAX
;
4363 if gFlash
= 2 then Inc(FPickup
, 5);
4367 if FMegaRulez
[MR_INVIS
] < gTime
+PLAYER_INVIS_TIME
then
4369 FMegaRulez
[MR_INVIS
] := gTime
+PLAYER_INVIS_TIME
;
4372 if gFlash
= 2 then Inc(FPickup
, 5);
4377 procedure TPlayer
.Touch();
4381 //FModel.PlaySound(MODELSOUND_PAIN, 1, FObj.X, FObj.Y);
4384 // Áðîñèòü ôëàã òîâàðèùó:
4385 if gGameSettings
.GameMode
= GM_CTF
then
4390 procedure TPlayer
.Push(vx
, vy
: Integer);
4392 if (not FPhysics
) and FGhost
then
4394 FObj
.Accel
.X
:= FObj
.Accel
.X
+ vx
;
4395 FObj
.Accel
.Y
:= FObj
.Accel
.Y
+ vy
;
4396 if g_Game_IsNet
and g_Game_IsServer
then
4397 MH_SEND_PlayerPos(True, FUID
, NET_EVERYONE
);
4400 procedure TPlayer
.Reset(Force
: Boolean);
4406 FTime
[T_RESPAWN
] := 0;
4407 FTime
[T_FLAGCAP
] := 0;
4422 FSpectator
:= False;
4425 FSpectatePlayer
:= -1;
4426 FNoRespawn
:= False;
4428 FLives
:= gGameSettings
.MaxLives
;
4433 procedure TPlayer
.SoftReset();
4441 FBFGFireCounter
:= -1;
4449 SetAction(A_STAND
, True);
4452 function TPlayer
.GetRespawnPoint(): Byte;
4457 // Íà áóäóùåå: FSpawn - èãðîê óæå èãðàë è ïåðåðîæäàåòñÿ
4459 // Îäèíî÷íàÿ èãðà/êîîïåðàòèâ
4460 if gGameSettings
.GameMode
in [GM_COOP
, GM_SINGLE
] then
4462 if (Self
= gPlayer1
) or (Self
= gPlayer2
) then
4464 // Òî÷êà ïîÿâëåíèÿ ñâîåãî èãðîêà
4465 if Self
= gPlayer1
then
4466 c
:= RESPAWNPOINT_PLAYER1
4468 c
:= RESPAWNPOINT_PLAYER2
;
4469 if g_Map_GetPointCount(c
) > 0 then
4475 // Òî÷êà ïîÿâëåíèÿ äðóãîãî èãðîêà
4476 if Self
= gPlayer1
then
4477 c
:= RESPAWNPOINT_PLAYER2
4479 c
:= RESPAWNPOINT_PLAYER1
;
4480 if g_Map_GetPointCount(c
) > 0 then
4487 // Òî÷êà ïîÿâëåíèÿ ëþáîãî èãðîêà (áîòà)
4488 if Random(2) = 0 then
4489 c
:= RESPAWNPOINT_PLAYER1
4491 c
:= RESPAWNPOINT_PLAYER2
;
4492 if g_Map_GetPointCount(c
) > 0 then
4499 // Òî÷êà ëþáîé èç êîìàíä
4500 if Random(2) = 0 then
4501 c
:= RESPAWNPOINT_RED
4503 c
:= RESPAWNPOINT_BLUE
;
4504 if g_Map_GetPointCount(c
) > 0 then
4511 c
:= RESPAWNPOINT_DM
;
4512 if g_Map_GetPointCount(c
) > 0 then
4520 if gGameSettings
.GameMode
= GM_DM
then
4523 c
:= RESPAWNPOINT_DM
;
4524 if g_Map_GetPointCount(c
) > 0 then
4530 // Òî÷êà ïîÿâëåíèÿ ëþáîãî èãðîêà
4531 if Random(2) = 0 then
4532 c
:= RESPAWNPOINT_PLAYER1
4534 c
:= RESPAWNPOINT_PLAYER2
;
4535 if g_Map_GetPointCount(c
) > 0 then
4541 // Òî÷êà ëþáîé èç êîìàíä
4542 if Random(2) = 0 then
4543 c
:= RESPAWNPOINT_RED
4545 c
:= RESPAWNPOINT_BLUE
;
4546 if g_Map_GetPointCount(c
) > 0 then
4554 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
4556 // Òî÷êà ñâîåé êîìàíäû
4557 c
:= RESPAWNPOINT_DM
;
4558 if FTeam
= TEAM_RED
then
4559 c
:= RESPAWNPOINT_RED
;
4560 if FTeam
= TEAM_BLUE
then
4561 c
:= RESPAWNPOINT_BLUE
;
4562 if g_Map_GetPointCount(c
) > 0 then
4569 c
:= RESPAWNPOINT_DM
;
4570 if g_Map_GetPointCount(c
) > 0 then
4576 // Òî÷êà ïîÿâëåíèÿ ëþáîãî èãðîêà
4577 if Random(2) = 0 then
4578 c
:= RESPAWNPOINT_PLAYER1
4580 c
:= RESPAWNPOINT_PLAYER2
;
4581 if g_Map_GetPointCount(c
) > 0 then
4587 // Òî÷êà äðóãîé êîìàíäû
4588 c
:= RESPAWNPOINT_DM
;
4589 if FTeam
= TEAM_RED
then
4590 c
:= RESPAWNPOINT_BLUE
;
4591 if FTeam
= TEAM_BLUE
then
4592 c
:= RESPAWNPOINT_RED
;
4593 if g_Map_GetPointCount(c
) > 0 then
4601 procedure TPlayer
.Respawn(Silent
: Boolean; Force
: Boolean = False);
4603 RespawnPoint
: TRespawnPoint
;
4611 FBFGFireCounter
:= -1;
4617 if not g_Game_IsServer
then
4621 FWantsInGame
:= True;
4622 FJustTeleported
:= True;
4625 FTime
[T_RESPAWN
] := 0;
4629 // if server changes MaxLives we gotta be ready
4630 if gGameSettings
.MaxLives
= 0 then FNoRespawn
:= False;
4632 // Åùå íåëüçÿ âîçðîäèòüñÿ:
4633 if FTime
[T_RESPAWN
] > gTime
then
4636 // Ïðîñðàë âñå æèçíè:
4639 if not FSpectator
then Spectate(True);
4640 FWantsInGame
:= True;
4644 if (gGameSettings
.GameType
<> GT_SINGLE
) and (gGameSettings
.GameMode
<> GM_COOP
) then
4645 begin // "Ñâîÿ èãðà"
4646 // Áåðñåðê íå ñîõðàíÿåòñÿ ìåæäó óðîâíÿìè:
4647 FRulez
:= FRulez
-[R_BERSERK
];
4649 else // "Îäèíî÷íàÿ èãðà"/"Êîîï"
4651 // Áåðñåðê è êëþ÷è íå ñîõðàíÿþòñÿ ìåæäó óðîâíÿìè:
4652 FRulez
:= FRulez
-[R_KEY_RED
, R_KEY_GREEN
, R_KEY_BLUE
, R_BERSERK
];
4655 // Ïîëó÷àåì òî÷êó ñïàóíà èãðîêà:
4656 c
:= GetRespawnPoint();
4661 // Âîñêðåøåíèå áåç îðóæèÿ:
4664 FHealth
:= Round(PLAYER_HP_SOFT
* (FHandicap
/ 100));
4670 for a
:= WP_FIRST
to WP_LAST
do
4672 FWeapon
[a
] := False;
4676 FWeapon
[WEAPON_PISTOL
] := True;
4677 FWeapon
[WEAPON_KASTET
] := True;
4678 FCurrWeap
:= WEAPON_PISTOL
;
4681 FModel
.SetWeapon(FCurrWeap
);
4683 for b
:= A_BULLETS
to A_HIGH
do
4686 FAmmo
[A_BULLETS
] := 50;
4688 FMaxAmmo
[A_BULLETS
] := AmmoLimits
[0, A_BULLETS
];
4689 FMaxAmmo
[A_SHELLS
] := AmmoLimits
[0, A_SHELLS
];
4690 FMaxAmmo
[A_ROCKETS
] := AmmoLimits
[0, A_SHELLS
];
4691 FMaxAmmo
[A_CELLS
] := AmmoLimits
[0, A_CELLS
];
4692 FMaxAmmo
[A_FUEL
] := AmmoLimits
[0, A_FUEL
];
4694 if (gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
]) and
4695 LongBool(gGameSettings
.Options
and GAME_OPTION_DMKEYS
) then
4696 FRulez
:= [R_KEY_RED
, R_KEY_GREEN
, R_KEY_BLUE
]
4701 // Ïîëó÷àåì êîîðäèíàòû òî÷êè âîçðîæäåíèÿ:
4702 if not g_Map_GetPoint(c
, RespawnPoint
) then
4704 g_FatalError(_lc
[I_GAME_ERROR_GET_SPAWN
]);
4708 // Óñòàíîâêà êîîðäèíàò è ñáðîñ âñåõ ïàðàìåòðîâ:
4709 FObj
.X
:= RespawnPoint
.X
-PLAYER_RECT
.X
;
4710 FObj
.Y
:= RespawnPoint
.Y
-PLAYER_RECT
.Y
;
4711 FObj
.oldX
:= FObj
.X
; // don't interpolate after respawn
4712 FObj
.oldY
:= FObj
.Y
;
4718 FDirection
:= RespawnPoint
.Direction
;
4719 if FDirection
= TDirection
.D_LEFT
then
4724 SetAction(A_STAND
, True);
4725 FModel
.Direction
:= FDirection
;
4727 for a
:= Low(FTime
) to High(FTime
) do
4730 for a
:= Low(FMegaRulez
) to High(FMegaRulez
) do
4733 // Respawn invulnerability
4734 if (gGameSettings
.GameType
<> GT_SINGLE
) and (gGameSettings
.SpawnInvul
> 0) then
4736 FMegaRulez
[MR_INVUL
] := gTime
+ gGameSettings
.SpawnInvul
* 1000;
4737 FSpawnInvul
:= FMegaRulez
[MR_INVUL
];
4742 FCanJetpack
:= False;
4748 // Àíèìàöèÿ âîçðîæäåíèÿ:
4749 if (not gLoadGameMode
) and (not Silent
) then
4750 if g_Frames_Get(ID
, 'FRAMES_TELEPORT') then
4752 Anim
:= TAnimation
.Create(ID
, False, 3);
4753 g_GFX_OnceAnim(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-32,
4754 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)-32, Anim
);
4758 FSpectator
:= False;
4761 FSpectatePlayer
:= -1;
4764 if (gPlayer1
= nil) and (gSpectLatchPID1
= FUID
) then
4766 if (gPlayer2
= nil) and (gSpectLatchPID2
= FUID
) then
4769 if g_Game_IsNet
then
4771 MH_SEND_PlayerPos(True, FUID
, NET_EVERYONE
);
4772 MH_SEND_PlayerStats(FUID
, NET_EVERYONE
);
4774 MH_SEND_Effect(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-32,
4775 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)-32,
4780 procedure TPlayer
.Spectate(NoMove
: Boolean = False);
4783 Kill(K_EXTRAHARDKILL
, FUID
, HIT_SOME
)
4784 else if (not NoMove
) then
4786 GameX
:= gMapInfo
.Width
div 2;
4787 GameY
:= gMapInfo
.Height
div 2;
4796 FWantsInGame
:= False;
4801 if Self
= gPlayer1
then
4803 gSpectLatchPID1
:= FUID
;
4806 else if Self
= gPlayer2
then
4808 gSpectLatchPID2
:= FUID
;
4813 if g_Game_IsNet
then
4814 MH_SEND_PlayerStats(FUID
);
4817 procedure TPlayer
.SwitchNoClip
;
4821 FGhost
:= not FGhost
;
4822 FPhysics
:= not FGhost
;
4834 procedure TPlayer
.Run(Direction
: TDirection
);
4838 if MAX_RUNVEL
> 8 then
4842 if Direction
= TDirection
.D_LEFT
then
4844 if FObj
.Vel
.X
> -MAX_RUNVEL
then
4845 FObj
.Vel
.X
:= FObj
.Vel
.X
- (MAX_RUNVEL
shr 3);
4848 if FObj
.Vel
.X
< MAX_RUNVEL
then
4849 FObj
.Vel
.X
:= FObj
.Vel
.X
+ (MAX_RUNVEL
shr 3);
4851 // Âîçìîæíî, ïèíàåì êóñêè:
4852 if (FObj
.Vel
.X
<> 0) and (gGibs
<> nil) then
4854 b
:= Abs(FObj
.Vel
.X
);
4855 if b
> 1 then b
:= b
* (Random(8 div b
) + 1);
4856 for a
:= 0 to High(gGibs
) do
4858 if gGibs
[a
].alive
and
4859 g_Obj_Collide(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
+FObj
.Rect
.Height
-4,
4860 FObj
.Rect
.Width
, 8, @gGibs
[a
].Obj
) and (Random(3) = 0) then
4863 if FObj
.Vel
.X
< 0 then
4865 g_Obj_PushA(@gGibs
[a
].Obj
, b
, Random(61)+120) // íàëåâî
4869 g_Obj_PushA(@gGibs
[a
].Obj
, b
, Random(61)); // íàïðàâî
4871 gGibs
[a
].positionChanged(); // this updates spatial accelerators
4879 procedure TPlayer
.SeeDown();
4881 SetAction(A_SEEDOWN
);
4883 if FDirection
= TDirection
.D_LEFT
then FAngle
:= ANGLE_LEFTDOWN
else FAngle
:= ANGLE_RIGHTDOWN
;
4885 if FIncCam
> -120 then DecMin(FIncCam
, 5, -120);
4888 procedure TPlayer
.SeeUp();
4892 if FDirection
= TDirection
.D_LEFT
then FAngle
:= ANGLE_LEFTUP
else FAngle
:= ANGLE_RIGHTUP
;
4894 if FIncCam
< 120 then IncMax(FIncCam
, 5, 120);
4897 procedure TPlayer
.SetAction(Action
: Byte; Force
: Boolean = False);
4905 A_ATTACK
: Prior
:= 2;
4906 A_SEEUP
: Prior
:= 1;
4907 A_SEEDOWN
: Prior
:= 1;
4908 A_ATTACKUP
: Prior
:= 2;
4909 A_ATTACKDOWN
: Prior
:= 2;
4914 if (Prior
> FActionPrior
) or Force
then
4915 if not ((Prior
= 2) and (FCurrWeap
= WEAPON_SAW
)) then
4917 FActionPrior
:= Prior
;
4918 FActionAnim
:= Action
;
4919 FActionForce
:= Force
;
4920 FActionChanged
:= True;
4923 if Action
in [A_ATTACK
, A_ATTACKUP
, A_ATTACKDOWN
] then FModel
.SetFire(True);
4926 function TPlayer
.StayOnStep(XInc
, YInc
: Integer): Boolean;
4928 Result
:= not g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+YInc
+PLAYER_RECT
.Y
+PLAYER_RECT
.Height
-1,
4929 PLAYER_RECT
.Width
, 1, PANEL_STEP
, False)
4930 and g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+YInc
+PLAYER_RECT
.Y
+PLAYER_RECT
.Height
,
4931 PLAYER_RECT
.Width
, 1, PANEL_STEP
, False);
4934 function TPlayer
.TeleportTo(X
, Y
: Integer; silent
: Boolean; dir
: Byte): Boolean;
4941 if g_CollideLevel(X
, Y
, PLAYER_RECT
.Width
, PLAYER_RECT
.Height
) then
4943 g_Sound_PlayExAt('SOUND_GAME_NOTELEPORT', FObj
.X
, FObj
.Y
);
4944 if g_Game_IsServer
and g_Game_IsNet
then
4945 MH_SEND_Sound(FObj
.X
, FObj
.Y
, 'SOUND_GAME_NOTELEPORT');
4949 FJustTeleported
:= True;
4954 if g_Frames_Get(ID
, 'FRAMES_TELEPORT') then
4956 Anim
:= TAnimation
.Create(ID
, False, 3);
4959 g_Sound_PlayExAt('SOUND_GAME_TELEPORT', FObj
.X
, FObj
.Y
);
4960 g_GFX_OnceAnim(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-32,
4961 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)-32, Anim
);
4962 if g_Game_IsServer
and g_Game_IsNet
then
4963 MH_SEND_Effect(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-32,
4964 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)-32, 1,
4968 FObj
.X
:= X
-PLAYER_RECT
.X
;
4969 FObj
.Y
:= Y
-PLAYER_RECT
.Y
;
4970 FObj
.oldX
:= FObj
.X
; // don't interpolate after respawn
4971 FObj
.oldY
:= FObj
.Y
;
4972 if FAlive
and FGhost
then
4978 if not g_Game_IsNet
then
4982 SetDirection(TDirection
.D_LEFT
);
4988 SetDirection(TDirection
.D_RIGHT
);
4994 if FDirection
= TDirection
.D_RIGHT
then
4996 SetDirection(TDirection
.D_LEFT
);
5001 SetDirection(TDirection
.D_RIGHT
);
5007 if not silent
and (Anim
<> nil) then
5009 g_GFX_OnceAnim(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-32,
5010 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)-32, Anim
);
5013 if g_Game_IsServer
and g_Game_IsNet
then
5014 MH_SEND_Effect(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-32,
5015 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)-32, 0,
5022 function nonz(a
: Single): Single;
5030 function TPlayer
.followCorpse(): Boolean;
5035 if FAlive
or FSpectator
then
5037 if (gCorpses
= nil) or (Length(gCorpses
) = 0) then
5039 for i
:= 0 to High(gCorpses
) do
5040 if gCorpses
[i
] <> nil then
5041 if gCorpses
[i
].FPlayerUID
= FUID
then
5044 FObj
.X
:= gCorpses
[i
].FObj
.X
;
5045 FObj
.Y
:= gCorpses
[i
].FObj
.Y
;
5046 FObj
.Vel
.X
:= gCorpses
[i
].FObj
.Vel
.X
;
5047 FObj
.Vel
.Y
:= gCorpses
[i
].FObj
.Vel
.Y
;
5048 FObj
.Accel
.X
:= gCorpses
[i
].FObj
.Accel
.X
;
5049 FObj
.Accel
.Y
:= gCorpses
[i
].FObj
.Accel
.Y
;
5054 procedure TPlayer
.PreUpdate();
5056 FSlopeOld
:= FObj
.slopeUpLeft
;
5057 FIncCamOld
:= FIncCam
;
5058 FObj
.oldX
:= FObj
.X
;
5059 FObj
.oldY
:= FObj
.Y
;
5062 procedure TPlayer
.Update();
5065 i
, ii
, wx
, wy
, xd
, yd
, k
: Integer;
5066 blockmon
, headwater
, dospawn
: Boolean;
5071 NetServer
:= g_Game_IsNet
and g_Game_IsServer
;
5072 AnyServer
:= g_Game_IsServer
;
5074 if g_Game_IsClient
and (NetInterpLevel
> 0) then
5075 DoLerp(NetInterpLevel
+ 1)
5081 if FClientID
>= 0 then
5083 FPing
:= NetClients
[FClientID
].Peer
^.lastRoundTripTime
;
5084 if NetClients
[FClientID
].Peer
^.packetsSent
> 0 then
5085 FLoss
:= Round(100*NetClients
[FClientID
].Peer
^.packetsLost
/NetClients
[FClientID
].Peer
^.packetsSent
)
5094 if FAlive
and (FPunchAnim
<> nil) then
5095 FPunchAnim
.Update();
5097 if FAlive
and (gFly
or FJetpack
) then
5100 if FDirection
= TDirection
.D_LEFT
then
5105 if FAlive
and (not FGhost
) then
5107 if FKeys
[KEY_UP
].Pressed
then
5109 if FKeys
[KEY_DOWN
].Pressed
then
5113 if (not (FKeys
[KEY_UP
].Pressed
or FKeys
[KEY_DOWN
].Pressed
)) and
5116 i
:= g_basic
.Sign(FIncCam
);
5117 FIncCam
:= Abs(FIncCam
);
5118 DecMin(FIncCam
, 5, 0);
5119 FIncCam
:= FIncCam
*i
;
5122 // no need to do that each second frame, weapon queue will take care of it
5123 if FAlive
and FKeys
[KEY_NEXTWEAPON
].Pressed
and AnyServer
then NextWeapon();
5124 if FAlive
and FKeys
[KEY_PREVWEAPON
].Pressed
and AnyServer
then PrevWeapon();
5126 if gTime
mod (GAME_TICK
*2) <> 0 then
5128 if (FObj
.Vel
.X
= 0) and FAlive
then
5130 if FKeys
[KEY_LEFT
].Pressed
then
5131 Run(TDirection
.D_LEFT
);
5132 if FKeys
[KEY_RIGHT
].Pressed
then
5133 Run(TDirection
.D_RIGHT
);
5138 if not followCorpse() then
5139 g_Obj_Move(@FObj
, True, True, True);
5140 positionChanged(); // this updates spatial accelerators
5146 FActionChanged
:= False;
5150 // Let alive player do some actions
5151 if FKeys
[KEY_LEFT
].Pressed
then Run(TDirection
.D_LEFT
);
5152 if FKeys
[KEY_RIGHT
].Pressed
then Run(TDirection
.D_RIGHT
);
5153 //if FKeys[KEY_NEXTWEAPON].Pressed and AnyServer then NextWeapon();
5154 //if FKeys[KEY_PREVWEAPON].Pressed and AnyServer then PrevWeapon();
5155 if FKeys
[KEY_FIRE
].Pressed
and AnyServer
then Fire()
5161 if NetServer
then MH_SEND_PlayerStats(FUID
);
5164 if FKeys
[KEY_OPEN
].Pressed
and AnyServer
then Use();
5165 if FKeys
[KEY_JUMP
].Pressed
then Jump()
5168 if AnyServer
and FJetpack
then
5172 if NetServer
then MH_SEND_PlayerStats(FUID
);
5174 FCanJetpack
:= True;
5181 for k
:= Low(FKeys
) to KEY_CHAT
-1 do
5183 if FKeys
[k
].Pressed
then
5191 if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
5194 if (FTime
[T_RESPAWN
] <= gTime
) and
5195 gGameOn
and (not FAlive
) then
5197 if (g_Player_GetCount() > 1) then
5201 gExit
:= EXIT_RESTART
;
5206 // Dead spectator actions
5209 if FKeys
[KEY_OPEN
].Pressed
and AnyServer
then Fire();
5210 if FKeys
[KEY_FIRE
].Pressed
and AnyServer
then
5214 if (FSpectatePlayer
>= High(gPlayers
)) then
5215 FSpectatePlayer
:= -1
5219 for I
:= FSpectatePlayer
+ 1 to High(gPlayers
) do
5220 if gPlayers
[I
] <> nil then
5221 if gPlayers
[I
].alive
then
5222 if gPlayers
[I
].UID
<> FUID
then
5224 FSpectatePlayer
:= I
;
5229 if not SetSpect
then FSpectatePlayer
:= -1;
5240 if FKeys
[KEY_UP
].Pressed
or FKeys
[KEY_JUMP
].Pressed
then
5242 FYTo
:= FObj
.Y
- 32;
5243 FSpectatePlayer
:= -1;
5245 if FKeys
[KEY_DOWN
].Pressed
then
5247 FYTo
:= FObj
.Y
+ 32;
5248 FSpectatePlayer
:= -1;
5250 if FKeys
[KEY_LEFT
].Pressed
then
5252 FXTo
:= FObj
.X
- 32;
5253 FSpectatePlayer
:= -1;
5255 if FKeys
[KEY_RIGHT
].Pressed
then
5257 FXTo
:= FObj
.X
+ 32;
5258 FSpectatePlayer
:= -1;
5261 if (FXTo
< -64) then
5263 else if (FXTo
> gMapInfo
.Width
+ 32) then
5264 FXTo
:= gMapInfo
.Width
+ 32;
5265 if (FYTo
< -72) then
5267 else if (FYTo
> gMapInfo
.Height
+ 32) then
5268 FYTo
:= gMapInfo
.Height
+ 32;
5273 if not followCorpse() then
5274 g_Obj_Move(@FObj
, True, True, True);
5275 positionChanged(); // this updates spatial accelerators
5282 if (FSpectatePlayer
<= High(gPlayers
)) and (FSpectatePlayer
>= 0) then
5283 if gPlayers
[FSpectatePlayer
] <> nil then
5284 if gPlayers
[FSpectatePlayer
].alive
then
5286 FXTo
:= gPlayers
[FSpectatePlayer
].GameX
;
5287 FYTo
:= gPlayers
[FSpectatePlayer
].GameY
;
5291 blockmon
:= g_Map_CollidePanel(FObj
.X
+PLAYER_HEADRECT
.X
, FObj
.Y
+PLAYER_HEADRECT
.Y
,
5292 PLAYER_HEADRECT
.Width
, PLAYER_HEADRECT
.Height
,
5293 PANEL_BLOCKMON
, True);
5294 headwater
:= HeadInLiquid(0, 0);
5296 // Ñîïðîòèâëåíèå âîçäóõà:
5297 if (not FAlive
) or not (FKeys
[KEY_LEFT
].Pressed
or FKeys
[KEY_RIGHT
].Pressed
) then
5298 if FObj
.Vel
.X
<> 0 then
5299 FObj
.Vel
.X
:= z_dec(FObj
.Vel
.X
, 1);
5301 if (FLastHit
= HIT_TRAP
) and (FPain
> 90) then FPain
:= 90;
5302 DecMin(FPain
, 5, 0);
5303 DecMin(FPickup
, 1, 0);
5305 if FAlive
and (FObj
.Y
> Integer(gMapInfo
.Height
)+128) and AnyServer
then
5307 // Îáíóëèòü äåéñòâèÿ ïðèìî÷åê, ÷òîáû ôîí ïðîïàë
5308 FMegaRulez
[MR_SUIT
] := 0;
5309 FMegaRulez
[MR_INVUL
] := 0;
5310 FMegaRulez
[MR_INVIS
] := 0;
5311 Kill(K_FALLKILL
, 0, HIT_FALL
);
5318 if FCurrWeap
= WEAPON_SAW
then
5319 if not (FSawSound
.IsPlaying() or FSawSoundHit
.IsPlaying() or
5320 FSawSoundSelect
.IsPlaying()) then
5321 FSawSoundIdle
.PlayAt(FObj
.X
, FObj
.Y
);
5324 if (not FJetSoundFly
.IsPlaying()) and (not FJetSoundOn
.IsPlaying()) and
5325 (not FJetSoundOff
.IsPlaying()) then
5327 FJetSoundFly
.SetPosition(0);
5328 FJetSoundFly
.PlayAt(FObj
.X
, FObj
.Y
);
5331 for b
:= WP_FIRST
to WP_LAST
do
5332 if FReloading
[b
] > 0 then
5338 if FShellTimer
> -1 then
5339 if FShellTimer
= 0 then
5341 if FShellType
= SHELL_SHELL
then
5342 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
5343 GameVelX
, GameVelY
-2, SHELL_SHELL
)
5344 else if FShellType
= SHELL_DBLSHELL
then
5346 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
5347 GameVelX
+1, GameVelY
-2, SHELL_SHELL
);
5348 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
5349 GameVelX
-1, GameVelY
-2, SHELL_SHELL
);
5352 end else Dec(FShellTimer
);
5354 if (FBFGFireCounter
> -1) then
5355 if FBFGFireCounter
= 0 then
5359 wx
:= FObj
.X
+WEAPONPOINT
[FDirection
].X
;
5360 wy
:= FObj
.Y
+WEAPONPOINT
[FDirection
].Y
;
5361 xd
:= wx
+IfThen(FDirection
= TDirection
.D_LEFT
, -30, 30);
5362 yd
:= wy
+firediry();
5363 g_Weapon_bfgshot(wx
, wy
, xd
, yd
, FUID
);
5364 if NetServer
then MH_SEND_PlayerFire(FUID
, WEAPON_BFG
, wx
, wy
, xd
, yd
);
5365 if (FAngle
= 0) or (FAngle
= 180) then SetAction(A_ATTACK
)
5366 else if (FAngle
= ANGLE_LEFTDOWN
) or (FAngle
= ANGLE_RIGHTDOWN
) then SetAction(A_ATTACKDOWN
)
5367 else if (FAngle
= ANGLE_LEFTUP
) or (FAngle
= ANGLE_RIGHTUP
) then SetAction(A_ATTACKUP
);
5370 FReloading
[WEAPON_BFG
] := WEAPON_RELOAD
[WEAPON_BFG
];
5371 FBFGFireCounter
:= -1;
5374 FBFGFireCounter
:= 0
5376 Dec(FBFGFireCounter
);
5378 if (FMegaRulez
[MR_SUIT
] < gTime
) and AnyServer
then
5380 b
:= g_GetAcidHit(FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+PLAYER_RECT
.Y
, PLAYER_RECT
.Width
, PLAYER_RECT
.Height
);
5382 if (b
> 0) and (gTime
mod (15*GAME_TICK
) = 0) then Damage(b
, 0, 0, 0, HIT_ACID
);
5385 if (headwater
or blockmon
) then
5391 if AnyServer
then Damage(10, 0, 0, 0, HIT_WATER
);
5394 else if (FAir
mod 31 = 0) and not blockmon
then
5396 g_GFX_Bubbles(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2), FObj
.Y
+PLAYER_RECT
.Y
-4, 5+Random(6), 8, 4);
5397 if Random(2) = 0 then
5398 g_Sound_PlayExAt('SOUND_GAME_BUBBLE1', FObj
.X
, FObj
.Y
)
5400 g_Sound_PlayExAt('SOUND_GAME_BUBBLE2', FObj
.X
, FObj
.Y
);
5402 end else if FAir
< AIR_DEF
then
5405 if FFireTime
> 0 then
5407 if BodyInLiquid(0, 0) then
5412 else if FMegaRulez
[MR_SUIT
] >= gTime
then
5414 if FMegaRulez
[MR_SUIT
] = gTime
then
5421 if FFirePainTime
<= 0 then
5423 if g_Game_IsServer
then
5424 Damage(2, FFireAttacker
, 0, 0, HIT_FLAME
);
5425 FFirePainTime
:= 12 - FFireTime
div 12;
5427 FFirePainTime
:= FFirePainTime
- 1;
5428 FFireTime
:= FFireTime
- 1;
5429 if ((FFireTime
mod 33) = 0) and (FMegaRulez
[MR_INVUL
] < gTime
) then
5430 FModel
.PlaySound(MODELSOUND_PAIN
, 1, FObj
.X
, FObj
.Y
);
5431 if (FFireTime
= 0) and g_Game_IsNet
and g_Game_IsServer
then
5432 MH_SEND_PlayerStats(FUID
);
5436 if FDamageBuffer
> 0 then
5438 if FDamageBuffer
>= 9 then
5442 if FDamageBuffer
< 30 then i
:= 9
5443 else if FDamageBuffer
< 100 then i
:= 18
5447 ii
:= Round(FDamageBuffer
*FHealth
/ nonz(FArmor
*(3/4)+FHealth
));
5448 FArmor
:= FArmor
-(FDamageBuffer
-ii
);
5449 FHealth
:= FHealth
-ii
;
5452 FHealth
:= FHealth
+FArmor
;
5457 if FHealth
<= 0 then
5458 if FHealth
> -30 then Kill(K_SIMPLEKILL
, FLastSpawnerUID
, FLastHit
)
5459 else if FHealth
> -50 then Kill(K_HARDKILL
, FLastSpawnerUID
, FLastHit
)
5460 else Kill(K_EXTRAHARDKILL
, FLastSpawnerUID
, FLastHit
);
5462 if FAlive
and ((FLastHit
<> HIT_FLAME
) or (FFireTime
<= 0)) then
5464 if FDamageBuffer
<= 20 then FModel
.PlaySound(MODELSOUND_PAIN
, 1, FObj
.X
, FObj
.Y
)
5465 else if FDamageBuffer
<= 55 then FModel
.PlaySound(MODELSOUND_PAIN
, 2, FObj
.X
, FObj
.Y
)
5466 else if FDamageBuffer
<= 120 then FModel
.PlaySound(MODELSOUND_PAIN
, 3, FObj
.X
, FObj
.Y
)
5467 else FModel
.PlaySound(MODELSOUND_PAIN
, 4, FObj
.X
, FObj
.Y
);
5474 end; // if FAlive then ...
5476 if (FActionAnim
= A_PAIN
) and (FModel
.Animation
<> A_PAIN
) then
5478 FModel
.ChangeAnimation(FActionAnim
, FActionForce
);
5479 FModel
.GetCurrentAnimation
.MinLength
:= i
;
5480 FModel
.GetCurrentAnimationMask
.MinLength
:= i
;
5481 end else FModel
.ChangeAnimation(FActionAnim
, FActionForce
and (FModel
.Animation
<> A_STAND
));
5483 if (FModel
.GetCurrentAnimation
.Played
or ((not FActionChanged
) and (FModel
.Animation
= A_WALK
)))
5484 then SetAction(A_STAND
, True);
5486 if not ((FModel
.Animation
= A_WALK
) and (Abs(FObj
.Vel
.X
) < 4) and not FModel
.Fire
) then FModel
.Update
;
5488 for b
:= Low(FKeys
) to High(FKeys
) do
5489 if FKeys
[b
].Time
= 0 then FKeys
[b
].Pressed
:= False else Dec(FKeys
[b
].Time
);
5493 procedure TPlayer
.getMapBox (out x
, y
, w
, h
: Integer); inline;
5495 x
:= FObj
.X
+PLAYER_RECT
.X
;
5496 y
:= FObj
.Y
+PLAYER_RECT
.Y
;
5497 w
:= PLAYER_RECT
.Width
;
5498 h
:= PLAYER_RECT
.Height
;
5502 procedure TPlayer
.moveBy (dx
, dy
: Integer); inline;
5504 if (dx
<> 0) or (dy
<> 0) then
5513 function TPlayer
.Collide(X
, Y
: Integer; Width
, Height
: Word): Boolean;
5515 Result
:= g_Collide(FObj
.X
+PLAYER_RECT
.X
,
5516 FObj
.Y
+PLAYER_RECT
.Y
,
5523 function TPlayer
.Collide(Panel
: TPanel
): Boolean;
5525 Result
:= g_Collide(FObj
.X
+PLAYER_RECT
.X
,
5526 FObj
.Y
+PLAYER_RECT
.Y
,
5530 Panel
.Width
, Panel
.Height
);
5533 function TPlayer
.Collide(X
, Y
: Integer): Boolean;
5535 X
:= X
-FObj
.X
-PLAYER_RECT
.X
;
5536 Y
:= Y
-FObj
.Y
-PLAYER_RECT
.Y
;
5537 Result
:= (x
>= 0) and (x
<= PLAYER_RECT
.Width
) and
5538 (y
>= 0) and (y
<= PLAYER_RECT
.Height
);
5541 function g_Player_ValidName(Name
: string): Boolean;
5547 if gPlayers
= nil then Exit
;
5549 for a
:= 0 to High(gPlayers
) do
5550 if gPlayers
[a
] <> nil then
5551 if LowerCase(Name
) = LowerCase(gPlayers
[a
].FName
) then
5558 procedure TPlayer
.SetDirection(Direction
: TDirection
);
5562 d
:= FModel
.Direction
;
5564 FModel
.Direction
:= Direction
;
5565 if d
<> Direction
then FModel
.ChangeAnimation(FModel
.Animation
, True);
5567 FDirection
:= Direction
;
5570 function TPlayer
.GetKeys(): Byte;
5574 if R_KEY_RED
in FRulez
then Result
:= KEY_RED
;
5575 if R_KEY_GREEN
in FRulez
then Result
:= Result
or KEY_GREEN
;
5576 if R_KEY_BLUE
in FRulez
then Result
:= Result
or KEY_BLUE
;
5578 if FTeam
= TEAM_RED
then Result
:= Result
or KEY_REDTEAM
;
5579 if FTeam
= TEAM_BLUE
then Result
:= Result
or KEY_BLUETEAM
;
5582 procedure TPlayer
.Use();
5586 if FTime
[T_USE
] > gTime
then Exit
;
5588 g_Triggers_PressR(FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+PLAYER_RECT
.Y
, PLAYER_RECT
.Width
,
5589 PLAYER_RECT
.Height
, FUID
, ACTIVATE_PLAYERPRESS
);
5591 for a
:= 0 to High(gPlayers
) do
5592 if (gPlayers
[a
] <> nil) and (gPlayers
[a
] <> Self
) and
5593 gPlayers
[a
].alive
and SameTeam(FUID
, gPlayers
[a
].FUID
) and
5594 g_Obj_Collide(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
,
5595 FObj
.Rect
.Width
, FObj
.Rect
.Height
, @gPlayers
[a
].FObj
) then
5597 gPlayers
[a
].Touch();
5598 if g_Game_IsNet
and g_Game_IsServer
then
5599 MH_SEND_GameEvent(NET_EV_PLAYER_TOUCH
, gPlayers
[a
].FUID
);
5602 FTime
[T_USE
] := gTime
+120;
5605 procedure TPlayer
.NetFire(Wpn
: Byte; X
, Y
, AX
, AY
: Integer; WID
: Integer = -1);
5609 WX
, WY
, XD
, YD
: Integer;
5621 if R_BERSERK
in FRulez
then
5623 //g_Weapon_punch(FObj.X+FObj.Rect.X, FObj.Y+FObj.Rect.Y, 75, FUID);
5624 locobj
.X
:= FObj
.X
+FObj
.Rect
.X
;
5625 locobj
.Y
:= FObj
.Y
+FObj
.Rect
.Y
;
5628 locobj
.rect
.Width
:= 39;
5629 locobj
.rect
.Height
:= 52;
5630 locobj
.Vel
.X
:= (xd
-wx
) div 2;
5631 locobj
.Vel
.Y
:= (yd
-wy
) div 2;
5632 locobj
.Accel
.X
:= xd
-wx
;
5633 locobj
.Accel
.y
:= yd
-wy
;
5635 if g_Weapon_Hit(@locobj
, 50, FUID
, HIT_SOME
) <> 0 then
5636 g_Sound_PlayExAt('SOUND_WEAPON_HITBERSERK', FObj
.X
, FObj
.Y
)
5638 g_Sound_PlayExAt('SOUND_WEAPON_MISSBERSERK', FObj
.X
, FObj
.Y
);
5642 FPain
:= min(FPain
+ 25, 50);
5644 g_Weapon_punch(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
, 3, FUID
);
5649 if g_Weapon_chainsaw(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
,
5650 IfThen(gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
], 9, 3), FUID
) <> 0 then
5652 FSawSoundSelect
.Stop();
5654 FSawSoundHit
.PlayAt(FObj
.X
, FObj
.Y
);
5656 else if not FSawSoundHit
.IsPlaying() then
5658 FSawSoundSelect
.Stop();
5659 FSawSound
.PlayAt(FObj
.X
, FObj
.Y
);
5666 g_Sound_PlayExAt('SOUND_WEAPON_FIREPISTOL', GameX
, Gamey
);
5667 FFireAngle
:= FAngle
;
5669 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
5670 GameVelX
, GameVelY
-2, SHELL_BULLET
);
5675 g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN', Gamex
, Gamey
);
5676 FFireAngle
:= FAngle
;
5679 FShellType
:= SHELL_SHELL
;
5684 g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN2', Gamex
, Gamey
);
5685 FFireAngle
:= FAngle
;
5688 FShellType
:= SHELL_DBLSHELL
;
5693 g_Sound_PlayExAt('SOUND_WEAPON_FIRECGUN', Gamex
, Gamey
);
5694 FFireAngle
:= FAngle
;
5696 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
5697 GameVelX
, GameVelY
-2, SHELL_BULLET
);
5700 WEAPON_ROCKETLAUNCHER
:
5702 g_Weapon_Rocket(wx
, wy
, xd
, yd
, FUID
, WID
);
5703 FFireAngle
:= FAngle
;
5709 g_Weapon_Plasma(wx
, wy
, xd
, yd
, FUID
, WID
);
5710 FFireAngle
:= FAngle
;
5716 g_Weapon_BFGShot(wx
, wy
, xd
, yd
, FUID
, WID
);
5717 FFireAngle
:= FAngle
;
5721 WEAPON_SUPERPULEMET
:
5723 g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN', Gamex
, Gamey
);
5724 FFireAngle
:= FAngle
;
5726 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
5727 GameVelX
, GameVelY
-2, SHELL_SHELL
);
5730 WEAPON_FLAMETHROWER
:
5732 g_Weapon_flame(wx
, wy
, xd
, yd
, FUID
, WID
);
5734 FFireAngle
:= FAngle
;
5741 if (FAngle
= 0) or (FAngle
= 180) then SetAction(A_ATTACK
)
5742 else if (FAngle
= ANGLE_LEFTDOWN
) or (FAngle
= ANGLE_RIGHTDOWN
) then SetAction(A_ATTACKDOWN
)
5743 else if (FAngle
= ANGLE_LEFTUP
) or (FAngle
= ANGLE_RIGHTUP
) then SetAction(A_ATTACKUP
);
5746 procedure TPlayer
.DoLerp(Level
: Integer = 2);
5748 if FObj
.X
<> FXTo
then FObj
.X
:= Lerp(FObj
.X
, FXTo
, Level
);
5749 if FObj
.Y
<> FYTo
then FObj
.Y
:= Lerp(FObj
.Y
, FYTo
, Level
);
5752 procedure TPlayer
.SetLerp(XTo
, YTo
: Integer);
5758 if NetInterpLevel
< 1 then
5765 AX
:= Abs(FXTo
- FObj
.X
);
5766 AY
:= Abs(FYTo
- FObj
.Y
);
5767 if (AX
> 32) or (AX
<= NetInterpLevel
) then
5769 if (AY
> 32) or (AY
<= NetInterpLevel
) then
5774 function TPlayer
.FullInLift(XInc
, YInc
: Integer): Integer;
5776 if g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
,
5777 PLAYER_RECT
.Width
, PLAYER_RECT
.Height
-8,
5778 PANEL_LIFTUP
, False) then Result
:= -1
5780 if g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
,
5781 PLAYER_RECT
.Width
, PLAYER_RECT
.Height
-8,
5782 PANEL_LIFTDOWN
, False) then Result
:= 1
5786 function TPlayer
.GetFlag(Flag
: Byte): Boolean;
5793 if Flag
= FLAG_NONE
then
5796 if not g_Game_IsServer
then Exit
;
5798 // Ïðèíåñ ÷óæîé ôëàã íà ñâîþ áàçó:
5799 if (Flag
= FTeam
) and
5800 (gFlags
[Flag
].State
= FLAG_STATE_NORMAL
) and
5801 (FFlag
<> FLAG_NONE
) then
5803 if FFlag
= FLAG_RED
then
5804 s
:= _lc
[I_PLAYER_FLAG_RED
]
5806 s
:= _lc
[I_PLAYER_FLAG_BLUE
];
5808 evtype
:= FLAG_STATE_SCORED
;
5810 ts
:= Format('%.4d', [gFlags
[FFlag
].CaptureTime
]);
5811 Insert('.', ts
, Length(ts
) + 1 - 3);
5812 g_Console_Add(Format(_lc
[I_PLAYER_FLAG_CAPTURE
], [FName
, s
, ts
]), True);
5814 g_Map_ResetFlag(FFlag
);
5815 g_Game_Message(Format(_lc
[I_MESSAGE_FLAG_CAPTURE
], [AnsiUpperCase(s
)]), 144);
5817 if ((Self
= gPlayer1
) or (Self
= gPlayer2
)
5818 or ((gPlayer1
<> nil) and (gPlayer1
.Team
= FTeam
))
5819 or ((gPlayer2
<> nil) and (gPlayer2
.Team
= FTeam
))) then
5824 if not sound_cap_flag
[a
].IsPlaying() then
5825 sound_cap_flag
[a
].Play();
5827 gTeamStat
[FTeam
].Goals
:= gTeamStat
[FTeam
].Goals
+ 1;
5830 if g_Game_IsNet
then
5832 MH_SEND_FlagEvent(evtype
, FFlag
, FUID
, False);
5836 gFlags
[FFlag
].CaptureTime
:= 0;
5841 // Ïîäîáðàë ñâîé ôëàã - âåðíóë åãî íà áàçó:
5842 if (Flag
= FTeam
) and
5843 (gFlags
[Flag
].State
= FLAG_STATE_DROPPED
) then
5845 if Flag
= FLAG_RED
then
5846 s
:= _lc
[I_PLAYER_FLAG_RED
]
5848 s
:= _lc
[I_PLAYER_FLAG_BLUE
];
5850 evtype
:= FLAG_STATE_RETURNED
;
5851 gFlags
[Flag
].CaptureTime
:= 0;
5853 g_Console_Add(Format(_lc
[I_PLAYER_FLAG_RETURN
], [FName
, s
]), True);
5855 g_Map_ResetFlag(Flag
);
5856 g_Game_Message(Format(_lc
[I_MESSAGE_FLAG_RETURN
], [AnsiUpperCase(s
)]), 144);
5858 if ((Self
= gPlayer1
) or (Self
= gPlayer2
)
5859 or ((gPlayer1
<> nil) and (gPlayer1
.Team
= FTeam
))
5860 or ((gPlayer2
<> nil) and (gPlayer2
.Team
= FTeam
))) then
5865 if not sound_ret_flag
[a
].IsPlaying() then
5866 sound_ret_flag
[a
].Play();
5869 if g_Game_IsNet
then
5871 MH_SEND_FlagEvent(evtype
, Flag
, FUID
, False);
5877 // Ïîäîáðàë ÷óæîé ôëàã:
5878 if (Flag
<> FTeam
) and (FTime
[T_FLAGCAP
] <= gTime
) then
5882 if Flag
= FLAG_RED
then
5883 s
:= _lc
[I_PLAYER_FLAG_RED
]
5885 s
:= _lc
[I_PLAYER_FLAG_BLUE
];
5887 evtype
:= FLAG_STATE_CAPTURED
;
5889 g_Console_Add(Format(_lc
[I_PLAYER_FLAG_GET
], [FName
, s
]), True);
5891 g_Game_Message(Format(_lc
[I_MESSAGE_FLAG_GET
], [AnsiUpperCase(s
)]), 144);
5893 gFlags
[Flag
].State
:= FLAG_STATE_CAPTURED
;
5895 if ((Self
= gPlayer1
) or (Self
= gPlayer2
)
5896 or ((gPlayer1
<> nil) and (gPlayer1
.Team
= FTeam
))
5897 or ((gPlayer2
<> nil) and (gPlayer2
.Team
= FTeam
))) then
5902 if not sound_get_flag
[a
].IsPlaying() then
5903 sound_get_flag
[a
].Play();
5906 if g_Game_IsNet
then
5908 MH_SEND_FlagEvent(evtype
, Flag
, FUID
, False);
5914 procedure TPlayer
.SetFlag(Flag
: Byte);
5917 if FModel
<> nil then
5918 FModel
.SetFlag(FFlag
);
5921 function TPlayer
.DropFlag(Silent
: Boolean = True): Boolean;
5927 if (not g_Game_IsServer
) or (FFlag
= FLAG_NONE
) then
5929 FTime
[T_FLAGCAP
] := gTime
+ 2000;
5930 with gFlags
[FFlag
] do
5934 Direction
:= FDirection
;
5935 State
:= FLAG_STATE_DROPPED
;
5937 g_Obj_Push(@Obj
, (FObj
.Vel
.X
div 2)-2+Random(5),
5938 (FObj
.Vel
.Y
div 2)-2+Random(5));
5939 positionChanged(); // this updates spatial accelerators
5941 if FFlag
= FLAG_RED
then
5942 s
:= _lc
[I_PLAYER_FLAG_RED
]
5944 s
:= _lc
[I_PLAYER_FLAG_BLUE
];
5946 g_Console_Add(Format(_lc
[I_PLAYER_FLAG_DROP
], [FName
, s
]), True);
5947 g_Game_Message(Format(_lc
[I_MESSAGE_FLAG_DROP
], [AnsiUpperCase(s
)]), 144);
5949 if ((Self
= gPlayer1
) or (Self
= gPlayer2
)
5950 or ((gPlayer1
<> nil) and (gPlayer1
.Team
= FTeam
))
5951 or ((gPlayer2
<> nil) and (gPlayer2
.Team
= FTeam
))) then
5956 if (not Silent
) and (not sound_lost_flag
[a
].IsPlaying()) then
5957 sound_lost_flag
[a
].Play();
5959 if g_Game_IsNet
then
5960 MH_SEND_FlagEvent(FLAG_STATE_DROPPED
, Flag
, FUID
, False);
5966 procedure TPlayer
.GetSecret();
5968 if (self
= gPlayer1
) or (self
= gPlayer2
) then
5970 g_Console_Add(Format(_lc
[I_PLAYER_SECRET
], [FName
]), True);
5971 g_Sound_PlayEx('SOUND_GAME_SECRET');
5976 procedure TPlayer
.PressKey(Key
: Byte; Time
: Word = 1);
5978 Assert(Key
<= High(FKeys
));
5980 FKeys
[Key
].Pressed
:= True;
5981 FKeys
[Key
].Time
:= Time
;
5984 function TPlayer
.IsKeyPressed(K
: Byte): Boolean;
5986 Result
:= FKeys
[K
].Pressed
;
5989 procedure TPlayer
.ReleaseKeys();
5993 for a
:= Low(FKeys
) to High(FKeys
) do
5995 FKeys
[a
].Pressed
:= False;
6000 procedure TPlayer
.OnDamage(Angle
: SmallInt);
6004 function TPlayer
.firediry(): Integer;
6006 if FKeys
[KEY_UP
].Pressed
then Result
:= -42
6007 else if FKeys
[KEY_DOWN
].Pressed
then Result
:= 19
6011 procedure TPlayer
.RememberState();
6014 SavedState
: TPlayerSavedState
;
6016 SavedState
.Health
:= FHealth
;
6017 SavedState
.Armor
:= FArmor
;
6018 SavedState
.Air
:= FAir
;
6019 SavedState
.JetFuel
:= FJetFuel
;
6020 SavedState
.CurrWeap
:= FCurrWeap
;
6021 SavedState
.NextWeap
:= FNextWeap
;
6022 SavedState
.NextWeapDelay
:= FNextWeapDelay
;
6023 for i
:= Low(FWeapon
) to High(FWeapon
) do
6024 SavedState
.Weapon
[i
] := FWeapon
[i
];
6025 for i
:= Low(FAmmo
) to High(FAmmo
) do
6026 SavedState
.Ammo
[i
] := FAmmo
[i
];
6027 for i
:= Low(FMaxAmmo
) to High(FMaxAmmo
) do
6028 SavedState
.MaxAmmo
[i
] := FMaxAmmo
[i
];
6029 SavedState
.Rulez
:= FRulez
- [R_KEY_RED
, R_KEY_GREEN
, R_KEY_BLUE
];
6031 FSavedStateNum
:= -1;
6032 for i
:= Low(SavedStates
) to High(SavedStates
) do
6033 if not SavedStates
[i
].Used
then
6035 FSavedStateNum
:= i
;
6038 if FSavedStateNum
< 0 then
6040 SetLength(SavedStates
, Length(SavedStates
) + 1);
6041 FSavedStateNum
:= High(SavedStates
);
6044 SavedState
.Used
:= True;
6045 SavedStates
[FSavedStateNum
] := SavedState
;
6048 procedure TPlayer
.RecallState();
6051 SavedState
: TPlayerSavedState
;
6053 if(FSavedStateNum
< 0) or (FSavedStateNum
> High(SavedStates
)) then
6056 SavedState
:= SavedStates
[FSavedStateNum
];
6057 SavedStates
[FSavedStateNum
].Used
:= False;
6058 FSavedStateNum
:= -1;
6060 FHealth
:= SavedState
.Health
;
6061 FArmor
:= SavedState
.Armor
;
6062 FAir
:= SavedState
.Air
;
6063 FJetFuel
:= SavedState
.JetFuel
;
6064 FCurrWeap
:= SavedState
.CurrWeap
;
6065 FNextWeap
:= SavedState
.NextWeap
;
6066 FNextWeapDelay
:= SavedState
.NextWeapDelay
;
6067 for i
:= Low(FWeapon
) to High(FWeapon
) do
6068 FWeapon
[i
] := SavedState
.Weapon
[i
];
6069 for i
:= Low(FAmmo
) to High(FAmmo
) do
6070 FAmmo
[i
] := SavedState
.Ammo
[i
];
6071 for i
:= Low(FMaxAmmo
) to High(FMaxAmmo
) do
6072 FMaxAmmo
[i
] := SavedState
.MaxAmmo
[i
];
6073 FRulez
:= SavedState
.Rulez
;
6075 if gGameSettings
.GameType
= GT_SERVER
then
6076 MH_SEND_PlayerStats(FUID
);
6079 procedure TPlayer
.SaveState (st
: TStream
);
6085 utils
.writeSign(st
, 'PLYR');
6086 utils
.writeInt(st
, Byte(PLR_SAVE_VERSION
)); // version
6088 utils
.writeBool(st
, FIamBot
);
6090 utils
.writeInt(st
, Word(FUID
));
6092 utils
.writeStr(st
, FName
);
6094 utils
.writeInt(st
, Byte(FTeam
));
6096 utils
.writeBool(st
, FAlive
);
6097 // Èçðàñõîäîâàë ëè âñå æèçíè
6098 utils
.writeBool(st
, FNoRespawn
);
6100 if FDirection
= TDirection
.D_LEFT
then b
:= 1 else b
:= 2; // D_RIGHT
6101 utils
.writeInt(st
, Byte(b
));
6103 utils
.writeInt(st
, LongInt(FHealth
));
6104 // Êîýôôèöèåíò èíâàëèäíîñòè
6105 utils
.writeInt(st
, LongInt(FHandicap
));
6107 utils
.writeInt(st
, Byte(FLives
));
6109 utils
.writeInt(st
, LongInt(FArmor
));
6111 utils
.writeInt(st
, LongInt(FAir
));
6113 utils
.writeInt(st
, LongInt(FJetFuel
));
6115 utils
.writeInt(st
, LongInt(FPain
));
6117 utils
.writeInt(st
, LongInt(FKills
));
6119 utils
.writeInt(st
, LongInt(FMonsterKills
));
6121 utils
.writeInt(st
, LongInt(FFrags
));
6123 utils
.writeInt(st
, Byte(FFragCombo
));
6124 // Âðåìÿ ïîñëåäíåãî ôðàãà
6125 utils
.writeInt(st
, LongWord(FLastFrag
));
6127 utils
.writeInt(st
, LongInt(FDeath
));
6129 utils
.writeInt(st
, Byte(FFlag
));
6131 utils
.writeInt(st
, LongInt(FSecrets
));
6133 utils
.writeInt(st
, Byte(FCurrWeap
));
6135 utils
.writeInt(st
, Word(FNextWeap
));
6137 utils
.writeInt(st
, Byte(FNextWeapDelay
));
6138 // Âðåìÿ çàðÿäêè BFG
6139 utils
.writeInt(st
, SmallInt(FBFGFireCounter
));
6141 utils
.writeInt(st
, LongInt(FDamageBuffer
));
6142 // Ïîñëåäíèé óäàðèâøèé
6143 utils
.writeInt(st
, Word(FLastSpawnerUID
));
6144 // Òèï ïîñëåäíåãî ïîëó÷åííîãî óðîíà
6145 utils
.writeInt(st
, Byte(FLastHit
));
6147 Obj_SaveState(st
, @FObj
);
6148 // Òåêóùåå êîëè÷åñòâî ïàòðîíîâ
6149 for i
:= A_BULLETS
to A_HIGH
do utils
.writeInt(st
, Word(FAmmo
[i
]));
6150 // Ìàêñèìàëüíîå êîëè÷åñòâî ïàòðîíîâ
6151 for i
:= A_BULLETS
to A_HIGH
do utils
.writeInt(st
, Word(FMaxAmmo
[i
]));
6153 for i
:= WP_FIRST
to WP_LAST
do utils
.writeBool(st
, FWeapon
[i
]);
6154 // Âðåìÿ ïåðåçàðÿäêè îðóæèÿ
6155 for i
:= WP_FIRST
to WP_LAST
do utils
.writeInt(st
, Word(FReloading
[i
]));
6157 utils
.writeBool(st
, (R_ITEM_BACKPACK
in FRulez
));
6158 // Íàëè÷èå êðàñíîãî êëþ÷à
6159 utils
.writeBool(st
, (R_KEY_RED
in FRulez
));
6160 // Íàëè÷èå çåëåíîãî êëþ÷à
6161 utils
.writeBool(st
, (R_KEY_GREEN
in FRulez
));
6162 // Íàëè÷èå ñèíåãî êëþ÷à
6163 utils
.writeBool(st
, (R_KEY_BLUE
in FRulez
));
6165 utils
.writeBool(st
, (R_BERSERK
in FRulez
));
6166 // Âðåìÿ äåéñòâèÿ ñïåöèàëüíûõ ïðåäìåòîâ
6167 for i
:= MR_SUIT
to MR_MAX
do utils
.writeInt(st
, LongWord(FMegaRulez
[i
]));
6168 // Âðåìÿ äî ïîâòîðíîãî ðåñïàóíà, ñìåíû îðóæèÿ, èñîëüçîâàíèÿ, çàõâàòà ôëàãà
6169 for i
:= T_RESPAWN
to T_FLAGCAP
do utils
.writeInt(st
, LongWord(FTime
[i
]));
6171 utils
.writeStr(st
, FModel
.Name
);
6173 utils
.writeInt(st
, Byte(FColor
.R
));
6174 utils
.writeInt(st
, Byte(FColor
.G
));
6175 utils
.writeInt(st
, Byte(FColor
.B
));
6179 procedure TPlayer
.LoadState (st
: TStream
);
6188 if not utils
.checkSign(st
, 'PLYR') then raise XStreamError
.Create('invalid player signature');
6189 if (utils
.readByte(st
) <> PLR_SAVE_VERSION
) then raise XStreamError
.Create('invalid player version');
6191 FIamBot
:= utils
.readBool(st
);
6193 FUID
:= utils
.readWord(st
);
6195 str
:= utils
.readStr(st
);
6196 if (self
<> gPlayer1
) and (self
<> gPlayer2
) then FName
:= str
;
6198 FTeam
:= utils
.readByte(st
);
6200 FAlive
:= utils
.readBool(st
);
6201 // Èçðàñõîäîâàë ëè âñå æèçíè
6202 FNoRespawn
:= utils
.readBool(st
);
6204 b
:= utils
.readByte(st
);
6205 if b
= 1 then FDirection
:= TDirection
.D_LEFT
else FDirection
:= TDirection
.D_RIGHT
; // b = 2
6207 FHealth
:= utils
.readLongInt(st
);
6208 // Êîýôôèöèåíò èíâàëèäíîñòè
6209 FHandicap
:= utils
.readLongInt(st
);
6211 FLives
:= utils
.readByte(st
);
6213 FArmor
:= utils
.readLongInt(st
);
6215 FAir
:= utils
.readLongInt(st
);
6217 FJetFuel
:= utils
.readLongInt(st
);
6219 FPain
:= utils
.readLongInt(st
);
6221 FKills
:= utils
.readLongInt(st
);
6223 FMonsterKills
:= utils
.readLongInt(st
);
6225 FFrags
:= utils
.readLongInt(st
);
6227 FFragCombo
:= utils
.readByte(st
);
6228 // Âðåìÿ ïîñëåäíåãî ôðàãà
6229 FLastFrag
:= utils
.readLongWord(st
);
6231 FDeath
:= utils
.readLongInt(st
);
6233 FFlag
:= utils
.readByte(st
);
6235 FSecrets
:= utils
.readLongInt(st
);
6237 FCurrWeap
:= utils
.readByte(st
);
6239 FNextWeap
:= utils
.readWord(st
);
6241 FNextWeapDelay
:= utils
.readByte(st
);
6242 // Âðåìÿ çàðÿäêè BFG
6243 FBFGFireCounter
:= utils
.readSmallInt(st
);
6245 FDamageBuffer
:= utils
.readLongInt(st
);
6246 // Ïîñëåäíèé óäàðèâøèé
6247 FLastSpawnerUID
:= utils
.readWord(st
);
6248 // Òèï ïîñëåäíåãî ïîëó÷åííîãî óðîíà
6249 FLastHit
:= utils
.readByte(st
);
6251 Obj_LoadState(@FObj
, st
);
6252 // Òåêóùåå êîëè÷åñòâî ïàòðîíîâ
6253 for i
:= A_BULLETS
to A_HIGH
do FAmmo
[i
] := utils
.readWord(st
);
6254 // Ìàêñèìàëüíîå êîëè÷åñòâî ïàòðîíîâ
6255 for i
:= A_BULLETS
to A_HIGH
do FMaxAmmo
[i
] := utils
.readWord(st
);
6257 for i
:= WP_FIRST
to WP_LAST
do FWeapon
[i
] := utils
.readBool(st
);
6258 // Âðåìÿ ïåðåçàðÿäêè îðóæèÿ
6259 for i
:= WP_FIRST
to WP_LAST
do FReloading
[i
] := utils
.readWord(st
);
6261 if utils
.readBool(st
) then Include(FRulez
, R_ITEM_BACKPACK
);
6262 // Íàëè÷èå êðàñíîãî êëþ÷à
6263 if utils
.readBool(st
) then Include(FRulez
, R_KEY_RED
);
6264 // Íàëè÷èå çåëåíîãî êëþ÷à
6265 if utils
.readBool(st
) then Include(FRulez
, R_KEY_GREEN
);
6266 // Íàëè÷èå ñèíåãî êëþ÷à
6267 if utils
.readBool(st
) then Include(FRulez
, R_KEY_BLUE
);
6269 if utils
.readBool(st
) then Include(FRulez
, R_BERSERK
);
6270 // Âðåìÿ äåéñòâèÿ ñïåöèàëüíûõ ïðåäìåòîâ
6271 for i
:= MR_SUIT
to MR_MAX
do FMegaRulez
[i
] := utils
.readLongWord(st
);
6272 // Âðåìÿ äî ïîâòîðíîãî ðåñïàóíà, ñìåíû îðóæèÿ, èñîëüçîâàíèÿ, çàõâàòà ôëàãà
6273 for i
:= T_RESPAWN
to T_FLAGCAP
do FTime
[i
] := utils
.readLongWord(st
);
6275 str
:= utils
.readStr(st
);
6277 FColor
.R
:= utils
.readByte(st
);
6278 FColor
.G
:= utils
.readByte(st
);
6279 FColor
.B
:= utils
.readByte(st
);
6280 if (self
= gPlayer1
) then
6282 str
:= gPlayer1Settings
.Model
;
6283 FColor
:= gPlayer1Settings
.Color
;
6285 else if (self
= gPlayer2
) then
6287 str
:= gPlayer2Settings
.Model
;
6288 FColor
:= gPlayer2Settings
.Color
;
6290 // Îáíîâëÿåì ìîäåëü èãðîêà
6292 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
6293 FModel
.Color
:= TEAMCOLOR
[FTeam
]
6295 FModel
.Color
:= FColor
;
6299 procedure TPlayer
.AllRulez(Health
: Boolean);
6305 FHealth
:= PLAYER_HP_LIMIT
;
6306 FArmor
:= PLAYER_AP_LIMIT
;
6310 for a
:= WP_FIRST
to WP_LAST
do FWeapon
[a
] := True;
6311 for a
:= A_BULLETS
to A_HIGH
do FAmmo
[a
] := 30000;
6312 FRulez
:= FRulez
+[R_KEY_RED
, R_KEY_GREEN
, R_KEY_BLUE
];
6315 procedure TPlayer
.RestoreHealthArmor();
6317 FHealth
:= PLAYER_HP_LIMIT
;
6318 FArmor
:= PLAYER_AP_LIMIT
;
6321 procedure TPlayer
.FragCombo();
6325 if (gGameSettings
.GameMode
in [GM_COOP
, GM_SINGLE
]) or g_Game_IsClient
then
6327 if gTime
- FLastFrag
< FRAG_COMBO_TIME
then
6329 if FFragCombo
< 5 then
6331 Param
:= FUID
or (FFragCombo
shl 16);
6332 if (FComboEvnt
>= Low(gDelayedEvents
)) and
6333 (FComboEvnt
<= High(gDelayedEvents
)) and
6334 gDelayedEvents
[FComboEvnt
].Pending
and
6335 (gDelayedEvents
[FComboEvnt
].DEType
= DE_KILLCOMBO
) and
6336 (gDelayedEvents
[FComboEvnt
].DENum
and $FFFF = FUID
) then
6338 gDelayedEvents
[FComboEvnt
].Time
:= gTime
+ 500;
6339 gDelayedEvents
[FComboEvnt
].DENum
:= Param
;
6342 FComboEvnt
:= g_Game_DelayEvent(DE_KILLCOMBO
, 500, Param
);
6350 procedure TPlayer
.GiveItem(ItemType
: Byte);
6354 if FMegaRulez
[MR_SUIT
] < gTime
+PLAYER_SUIT_TIME
then
6356 FMegaRulez
[MR_SUIT
] := gTime
+PLAYER_SUIT_TIME
;
6360 if FAir
< AIR_MAX
then
6367 if not (R_BERSERK
in FRulez
) then
6369 Include(FRulez
, R_BERSERK
);
6370 if FBFGFireCounter
< 1 then
6372 FCurrWeap
:= WEAPON_KASTET
;
6374 FModel
.SetWeapon(WEAPON_KASTET
);
6378 FBerserk
:= gTime
+30000;
6380 if FHealth
< PLAYER_HP_SOFT
then
6382 FHealth
:= PLAYER_HP_SOFT
;
6383 FBerserk
:= gTime
+30000;
6388 if FMegaRulez
[MR_INVUL
] < gTime
+PLAYER_INVUL_TIME
then
6390 FMegaRulez
[MR_INVUL
] := gTime
+PLAYER_INVUL_TIME
;
6395 if FMegaRulez
[MR_INVIS
] < gTime
+PLAYER_INVIS_TIME
then
6397 FMegaRulez
[MR_INVIS
] := gTime
+PLAYER_INVIS_TIME
;
6401 if FJetFuel
< JET_MAX
then
6403 FJetFuel
:= JET_MAX
;
6406 ITEM_MEDKIT_SMALL
: if FHealth
< PLAYER_HP_SOFT
then IncMax(FHealth
, 10, PLAYER_HP_SOFT
);
6407 ITEM_MEDKIT_LARGE
: if FHealth
< PLAYER_HP_SOFT
then IncMax(FHealth
, 25, PLAYER_HP_SOFT
);
6409 ITEM_ARMOR_GREEN
: if FArmor
< PLAYER_AP_SOFT
then FArmor
:= PLAYER_AP_SOFT
;
6410 ITEM_ARMOR_BLUE
: if FArmor
< PLAYER_AP_LIMIT
then FArmor
:= PLAYER_AP_LIMIT
;
6412 ITEM_SPHERE_BLUE
: if FHealth
< PLAYER_HP_LIMIT
then IncMax(FHealth
, 100, PLAYER_HP_LIMIT
);
6414 if (FHealth
< PLAYER_HP_LIMIT
) or (FArmor
< PLAYER_AP_LIMIT
) then
6416 if FHealth
< PLAYER_HP_LIMIT
then FHealth
:= PLAYER_HP_LIMIT
;
6417 if FArmor
< PLAYER_AP_LIMIT
then FArmor
:= PLAYER_AP_LIMIT
;
6420 ITEM_WEAPON_SAW
: FWeapon
[WEAPON_SAW
] := True;
6421 ITEM_WEAPON_SHOTGUN1
: FWeapon
[WEAPON_SHOTGUN1
] := True;
6422 ITEM_WEAPON_SHOTGUN2
: FWeapon
[WEAPON_SHOTGUN2
] := True;
6423 ITEM_WEAPON_CHAINGUN
: FWeapon
[WEAPON_CHAINGUN
] := True;
6424 ITEM_WEAPON_ROCKETLAUNCHER
: FWeapon
[WEAPON_ROCKETLAUNCHER
] := True;
6425 ITEM_WEAPON_PLASMA
: FWeapon
[WEAPON_PLASMA
] := True;
6426 ITEM_WEAPON_BFG
: FWeapon
[WEAPON_BFG
] := True;
6427 ITEM_WEAPON_SUPERPULEMET
: FWeapon
[WEAPON_SUPERPULEMET
] := True;
6428 ITEM_WEAPON_FLAMETHROWER
: FWeapon
[WEAPON_FLAMETHROWER
] := True;
6430 ITEM_AMMO_BULLETS
: if FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
] then IncMax(FAmmo
[A_BULLETS
], 10, FMaxAmmo
[A_BULLETS
]);
6431 ITEM_AMMO_BULLETS_BOX
: if FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
] then IncMax(FAmmo
[A_BULLETS
], 50, FMaxAmmo
[A_BULLETS
]);
6432 ITEM_AMMO_SHELLS
: if FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
] then IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
6433 ITEM_AMMO_SHELLS_BOX
: if FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
] then IncMax(FAmmo
[A_SHELLS
], 25, FMaxAmmo
[A_SHELLS
]);
6434 ITEM_AMMO_ROCKET
: if FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
] then IncMax(FAmmo
[A_ROCKETS
], 1, FMaxAmmo
[A_ROCKETS
]);
6435 ITEM_AMMO_ROCKET_BOX
: if FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
] then IncMax(FAmmo
[A_ROCKETS
], 5, FMaxAmmo
[A_ROCKETS
]);
6436 ITEM_AMMO_CELL
: if FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
] then IncMax(FAmmo
[A_CELLS
], 40, FMaxAmmo
[A_CELLS
]);
6437 ITEM_AMMO_CELL_BIG
: if FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
] then IncMax(FAmmo
[A_CELLS
], 100, FMaxAmmo
[A_CELLS
]);
6438 ITEM_AMMO_FUELCAN
: if FAmmo
[A_FUEL
] < FMaxAmmo
[A_FUEL
] then IncMax(FAmmo
[A_FUEL
], 100, FMaxAmmo
[A_FUEL
]);
6441 if (FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
]) or
6442 (FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
]) or
6443 (FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
]) or
6444 (FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
]) or
6445 (FMaxAmmo
[A_FUEL
] < AmmoLimits
[1, A_FUEL
]) then
6447 FMaxAmmo
[A_BULLETS
] := AmmoLimits
[1, A_BULLETS
];
6448 FMaxAmmo
[A_SHELLS
] := AmmoLimits
[1, A_SHELLS
];
6449 FMaxAmmo
[A_ROCKETS
] := AmmoLimits
[1, A_ROCKETS
];
6450 FMaxAmmo
[A_CELLS
] := AmmoLimits
[1, A_CELLS
];
6451 FMaxAmmo
[A_FUEL
] := AmmoLimits
[1, A_FUEL
];
6453 if FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
] then IncMax(FAmmo
[A_BULLETS
], 10, FMaxAmmo
[A_BULLETS
]);
6454 if FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
] then IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
6455 if FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
] then IncMax(FAmmo
[A_ROCKETS
], 1, FMaxAmmo
[A_ROCKETS
]);
6456 if FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
] then IncMax(FAmmo
[A_CELLS
], 40, FMaxAmmo
[A_CELLS
]);
6458 FRulez
:= FRulez
+ [R_ITEM_BACKPACK
];
6461 ITEM_KEY_RED
: if not (R_KEY_RED
in FRulez
) then Include(FRulez
, R_KEY_RED
);
6462 ITEM_KEY_GREEN
: if not (R_KEY_GREEN
in FRulez
) then Include(FRulez
, R_KEY_GREEN
);
6463 ITEM_KEY_BLUE
: if not (R_KEY_BLUE
in FRulez
) then Include(FRulez
, R_KEY_BLUE
);
6465 ITEM_BOTTLE
: if FHealth
< PLAYER_HP_LIMIT
then IncMax(FHealth
, 4, PLAYER_HP_LIMIT
);
6466 ITEM_HELMET
: if FArmor
< PLAYER_AP_LIMIT
then IncMax(FArmor
, 5, PLAYER_AP_LIMIT
);
6471 if g_Game_IsNet
and g_Game_IsServer
then
6472 MH_SEND_PlayerStats(FUID
);
6475 procedure TPlayer
.FlySmoke(Times
: DWORD
= 1);
6480 if (Random(5) = 1) and (Times
= 1) then
6483 if BodyInLiquid(0, 0) then
6485 g_GFX_Bubbles(Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2)+Random(3)-1,
6486 Obj
.Y
+Obj
.Rect
.Height
+8, 1, 8, 4);
6487 if Random(2) = 0 then
6488 g_Sound_PlayExAt('SOUND_GAME_BUBBLE1', FObj
.X
, FObj
.Y
)
6490 g_Sound_PlayExAt('SOUND_GAME_BUBBLE2', FObj
.X
, FObj
.Y
);
6494 if g_Frames_Get(id
, 'FRAMES_SMOKE') then
6496 for i
:= 1 to Times
do
6498 Anim
:= TAnimation
.Create(id
, False, 3);
6500 g_GFX_OnceAnim(Obj
.X
+Obj
.Rect
.X
+Random(Obj
.Rect
.Width
+Times
*2)-(Anim
.Width
div 2),
6501 Obj
.Y
+Obj
.Rect
.Height
-4+Random(8+Times
*2), Anim
, ONCEANIM_SMOKE
);
6507 procedure TPlayer
.OnFireFlame(Times
: DWORD
= 1);
6512 if (Random(10) = 1) and (Times
= 1) then
6515 if g_Frames_Get(id
, 'FRAMES_FLAME') then
6517 for i
:= 1 to Times
do
6519 Anim
:= TAnimation
.Create(id
, False, 3);
6521 g_GFX_OnceAnim(Obj
.X
+Obj
.Rect
.X
+Random(Obj
.Rect
.Width
+Times
*2)-(Anim
.Width
div 2),
6522 Obj
.Y
+8+Random(8+Times
*2), Anim
, ONCEANIM_SMOKE
);
6528 procedure TPlayer
.PauseSounds(Enable
: Boolean);
6530 FSawSound
.Pause(Enable
);
6531 FSawSoundIdle
.Pause(Enable
);
6532 FSawSoundHit
.Pause(Enable
);
6533 FSawSoundSelect
.Pause(Enable
);
6534 FFlameSoundOn
.Pause(Enable
);
6535 FFlameSoundOff
.Pause(Enable
);
6536 FFlameSoundWork
.Pause(Enable
);
6537 FJetSoundFly
.Pause(Enable
);
6538 FJetSoundOn
.Pause(Enable
);
6539 FJetSoundOff
.Pause(Enable
);
6544 constructor TCorpse
.Create(X
, Y
: Integer; ModelName
: String; aMess
: Boolean);
6549 FObj
.Rect
:= PLAYER_CORPSERECT
;
6550 FModelName
:= ModelName
;
6555 FState
:= CORPSE_STATE_MESS
;
6556 g_PlayerModel_GetAnim(ModelName
, A_DIE2
, FAnimation
, FAnimationMask
);
6560 FState
:= CORPSE_STATE_NORMAL
;
6561 g_PlayerModel_GetAnim(ModelName
, A_DIE1
, FAnimation
, FAnimationMask
);
6565 destructor TCorpse
.Destroy();
6572 function TCorpse
.ObjPtr (): PObj
; inline; begin result
:= @FObj
; end;
6574 procedure TCorpse
.positionChanged (); inline; begin end;
6576 procedure TCorpse
.moveBy (dx
, dy
: Integer); inline;
6578 if (dx
<> 0) or (dy
<> 0) then
6587 procedure TCorpse
.getMapBox (out x
, y
, w
, h
: Integer); inline;
6589 x
:= FObj
.X
+PLAYER_CORPSERECT
.X
;
6590 y
:= FObj
.Y
+PLAYER_CORPSERECT
.Y
;
6591 w
:= PLAYER_CORPSERECT
.Width
;
6592 h
:= PLAYER_CORPSERECT
.Height
;
6596 procedure TCorpse
.Damage(Value
: Word; vx
, vy
: Integer);
6601 if FState
= CORPSE_STATE_REMOVEME
then
6604 FDamage
:= FDamage
+ Value
;
6606 if FDamage
> 150 then
6608 if FAnimation
<> nil then
6613 FState
:= CORPSE_STATE_REMOVEME
;
6615 g_Player_CreateGibs(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
6616 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2),
6617 FModelName
, FColor
);
6618 // Çâóê ìÿñà îò òðóïà:
6619 pm
:= g_PlayerModel_Get(FModelName
);
6620 pm
.PlaySound(MODELSOUND_DIE
, 5, FObj
.X
, FObj
.Y
);
6624 if (gBodyKillEvent
<> -1)
6625 and gDelayedEvents
[gBodyKillEvent
].Pending
then
6626 gDelayedEvents
[gBodyKillEvent
].Pending
:= False;
6627 gBodyKillEvent
:= g_Game_DelayEvent(DE_BODYKILL
, 1050, 0);
6632 Blood
:= g_PlayerModel_GetBlood(FModelName
);
6633 FObj
.Vel
.X
:= FObj
.Vel
.X
+ vx
;
6634 FObj
.Vel
.Y
:= FObj
.Vel
.Y
+ vy
;
6635 g_GFX_Blood(FObj
.X
+PLAYER_CORPSERECT
.X
+(PLAYER_CORPSERECT
.Width
div 2),
6636 FObj
.Y
+PLAYER_CORPSERECT
.Y
+(PLAYER_CORPSERECT
.Height
div 2),
6637 Value
, vx
, vy
, 16, (PLAYER_CORPSERECT
.Height
*2) div 3,
6638 Blood
.R
, Blood
.G
, Blood
.B
, Blood
.Kind
);
6642 procedure TCorpse
.Draw();
6646 if FState
= CORPSE_STATE_REMOVEME
then
6649 FObj
.lerp(gLerpFactor
, fX
, fY
);
6651 if FAnimation
<> nil then
6652 FAnimation
.Draw(fX
, fY
, TMirrorType
.None
);
6654 if FAnimationMask
<> nil then
6657 FAnimationMask
.Draw(fX
, fY
, TMirrorType
.None
);
6664 procedure TCorpse
.Update();
6668 if FState
= CORPSE_STATE_REMOVEME
then
6671 FObj
.oldX
:= FObj
.X
;
6672 FObj
.oldY
:= FObj
.Y
;
6674 if gTime
mod (GAME_TICK
*2) <> 0 then
6676 g_Obj_Move(@FObj
, True, True, True);
6677 positionChanged(); // this updates spatial accelerators
6681 // Ñîïðîòèâëåíèå âîçäóõà äëÿ òðóïà:
6682 FObj
.Vel
.X
:= z_dec(FObj
.Vel
.X
, 1);
6684 st
:= g_Obj_Move(@FObj
, True, True, True);
6685 positionChanged(); // this updates spatial accelerators
6687 if WordBool(st
and MOVE_FALLOUT
) then
6689 FState
:= CORPSE_STATE_REMOVEME
;
6693 if FAnimation
<> nil then
6694 FAnimation
.Update();
6695 if FAnimationMask
<> nil then
6696 FAnimationMask
.Update();
6700 procedure TCorpse
.SaveState (st
: TStream
);
6707 utils
.writeSign(st
, 'CORP');
6708 utils
.writeInt(st
, Byte(0));
6710 utils
.writeInt(st
, Byte(FState
));
6712 utils
.writeInt(st
, Byte(FDamage
));
6714 utils
.writeInt(st
, Byte(FColor
.R
));
6715 utils
.writeInt(st
, Byte(FColor
.G
));
6716 utils
.writeInt(st
, Byte(FColor
.B
));
6718 Obj_SaveState(st
, @FObj
);
6719 utils
.writeInt(st
, Word(FPlayerUID
));
6721 anim
:= (FAnimation
<> nil);
6722 utils
.writeBool(st
, anim
);
6723 // Åñëè åñòü - ñîõðàíÿåì
6724 if anim
then FAnimation
.SaveState(st
);
6725 // Åñòü ëè ìàñêà àíèìàöèè
6726 anim
:= (FAnimationMask
<> nil);
6727 utils
.writeBool(st
, anim
);
6728 // Åñëè åñòü - ñîõðàíÿåì
6729 if anim
then FAnimationMask
.SaveState(st
);
6733 procedure TCorpse
.LoadState (st
: TStream
);
6740 if not utils
.checkSign(st
, 'CORP') then raise XStreamError
.Create('invalid corpse signature');
6741 if (utils
.readByte(st
) <> 0) then raise XStreamError
.Create('invalid corpse version');
6743 FState
:= utils
.readByte(st
);
6745 FDamage
:= utils
.readByte(st
);
6747 FColor
.R
:= utils
.readByte(st
);
6748 FColor
.G
:= utils
.readByte(st
);
6749 FColor
.B
:= utils
.readByte(st
);
6751 Obj_LoadState(@FObj
, st
);
6752 FPlayerUID
:= utils
.readWord(st
);
6754 anim
:= utils
.readBool(st
);
6755 // Åñëè åñòü - çàãðóæàåì
6758 Assert(FAnimation
<> nil, 'TCorpse.LoadState: no FAnimation');
6759 FAnimation
.LoadState(st
);
6761 // Åñòü ëè ìàñêà àíèìàöèè
6762 anim
:= utils
.readBool(st
);
6763 // Åñëè åñòü - çàãðóæàåì
6766 Assert(FAnimationMask
<> nil, 'TCorpse.LoadState: no FAnimationMask');
6767 FAnimationMask
.LoadState(st
);
6773 constructor TBot
.Create();
6780 FSpectator
:= False;
6787 for a
:= WP_FIRST
to WP_LAST
do
6789 FDifficult
.WeaponPrior
[a
] := WEAPON_PRIOR1
[a
];
6790 FDifficult
.CloseWeaponPrior
[a
] := WEAPON_PRIOR2
[a
];
6791 //FDifficult.SafeWeaponPrior[a] := WEAPON_PRIOR3[a];
6795 destructor TBot
.Destroy();
6798 inherited Destroy();
6801 procedure TBot
.Draw();
6805 //if FTargetUID <> 0 then e_DrawLine(1, FObj.X, FObj.Y, g_Player_Get(FTargetUID).FObj.X,
6806 // g_Player_Get(FTargetUID).FObj.Y, 255, 0, 0);
6809 procedure TBot
.Respawn(Silent
: Boolean; Force
: Boolean = False);
6811 inherited Respawn(Silent
, Force
);
6814 FSelectedWeapon
:= FCurrWeap
;
6819 procedure TBot
.UpdateCombat();
6832 TTargetRecord
= array of TTarget
;
6834 function Compare(a
, b
: TTarget
): Integer;
6836 if a
.Line
and not b
.Line
then // A íà ëèíèè îãíÿ
6839 if not a
.Line
and b
.Line
then // B íà ëèíèè îãíÿ
6841 else // È A, è B íà ëèíèè èëè íå íà ëèíèè îãíÿ
6842 if (a
.Line
and b
.Line
) or ((not a
.Line
) and (not b
.Line
)) then
6844 if a
.Dist
> b
.Dist
then // B áëèæå
6846 else // A áëèæå èëè ðàâíîóäàëåííî ñ B
6849 else // Ñòðàííî -> A
6854 a
, x1
, y1
, x2
, y2
: Integer;
6855 targets
: TTargetRecord
;
6857 Target
, BestTarget
: TTarget
;
6858 firew
, fireh
: Integer;
6862 vsPlayer
, vsMonster
, ok
: Boolean;
6865 function monsUpdate (mon
: TMonster
): Boolean;
6867 result
:= false; // don't stop
6868 if mon
.alive
and (mon
.MonsterType
<> MONSTER_BARREL
) then
6870 if not TargetOnScreen(mon
.Obj
.X
+mon
.Obj
.Rect
.X
, mon
.Obj
.Y
+mon
.Obj
.Rect
.Y
) then exit
;
6872 x2
:= mon
.Obj
.X
+mon
.Obj
.Rect
.X
+(mon
.Obj
.Rect
.Width
div 2);
6873 y2
:= mon
.Obj
.Y
+mon
.Obj
.Rect
.Y
+(mon
.Obj
.Rect
.Height
div 2);
6875 // Åñëè ìîíñòð íà ýêðàíå è íå ïðèêðûò ñòåíîé
6876 if g_TraceVector(x1
, y1
, x2
, y2
) then
6878 // Äîáàâëÿåì ê ñïèñêó âîçìîæíûõ öåëåé
6879 SetLength(targets
, Length(targets
)+1);
6880 with targets
[High(targets
)] do
6887 Rect
:= mon
.Obj
.Rect
;
6888 Dist
:= g_PatchLength(x1
, y1
, x2
, y2
);
6889 Line
:= (y1
+4 < Target
.Y
+ mon
.Obj
.Rect
.Y
+ mon
.Obj
.Rect
.Height
) and
6890 (y1
-4 > Target
.Y
+ mon
.Obj
.Rect
.Y
);
6899 vsPlayer
:= LongBool(gGameSettings
.Options
and GAME_OPTION_BOTVSPLAYER
);
6900 vsMonster
:= LongBool(gGameSettings
.Options
and GAME_OPTION_BOTVSMONSTER
);
6902 // Åñëè òåêóùåå îðóæèå íå òî, ÷òî íóæíî, òî ìåíÿåì:
6903 if FCurrWeap
<> FSelectedWeapon
then
6906 // Åñëè íóæíî ñòðåëÿòü è íóæíîå îðóæèå, òî íàæàòü "Ñòðåëÿòü":
6907 if (GetAIFlag('NEEDFIRE') <> '') and (FCurrWeap
= FSelectedWeapon
) then
6909 RemoveAIFlag('NEEDFIRE');
6912 WEAPON_PLASMA
, WEAPON_SUPERPULEMET
, WEAPON_CHAINGUN
: PressKey(KEY_FIRE
, 20);
6913 WEAPON_SAW
, WEAPON_KASTET
, WEAPON_FLAMETHROWER
: PressKey(KEY_FIRE
, 40);
6914 else PressKey(KEY_FIRE
);
6918 // Êîîðäèíàòû ñòâîëà:
6919 x1
:= FObj
.X
+ WEAPONPOINT
[FDirection
].X
;
6920 y1
:= FObj
.Y
+ WEAPONPOINT
[FDirection
].Y
;
6922 Target
.UID
:= FTargetUID
;
6925 if Target
.UID
<> 0 then
6926 begin // Öåëü åñòü - íàñòðàèâàåì
6927 if (g_GetUIDType(Target
.UID
) = UID_PLAYER
) and
6930 tpla
:= g_Player_Get(Target
.UID
);
6934 if (@FObj
) <> nil then
6941 Target
.cX
:= Target
.X
+ PLAYER_RECT_CX
;
6942 Target
.cY
:= Target
.Y
+ PLAYER_RECT_CY
;
6943 Target
.Rect
:= PLAYER_RECT
;
6944 Target
.Visible
:= g_TraceVector(x1
, y1
, Target
.cX
, Target
.cY
);
6945 Target
.Line
:= (y1
+4 < Target
.Y
+PLAYER_RECT
.Y
+PLAYER_RECT
.Height
) and
6946 (y1
-4 > Target
.Y
+PLAYER_RECT
.Y
);
6947 Target
.IsPlayer
:= True;
6951 if (g_GetUIDType(Target
.UID
) = UID_MONSTER
) and
6954 mon
:= g_Monsters_ByUID(Target
.UID
);
6957 Target
.X
:= mon
.Obj
.X
;
6958 Target
.Y
:= mon
.Obj
.Y
;
6960 Target
.cX
:= Target
.X
+ mon
.Obj
.Rect
.X
+ (mon
.Obj
.Rect
.Width
div 2);
6961 Target
.cY
:= Target
.Y
+ mon
.Obj
.Rect
.Y
+ (mon
.Obj
.Rect
.Height
div 2);
6962 Target
.Rect
:= mon
.Obj
.Rect
;
6963 Target
.Visible
:= g_TraceVector(x1
, y1
, Target
.cX
, Target
.cY
);
6964 Target
.Line
:= (y1
+4 < Target
.Y
+ mon
.Obj
.Rect
.Y
+ mon
.Obj
.Rect
.Height
) and
6965 (y1
-4 > Target
.Y
+ mon
.Obj
.Rect
.Y
);
6966 Target
.IsPlayer
:= False;
6973 begin // Öåëè íåò - îáíóëÿåì
6978 Target
.Visible
:= False;
6979 Target
.Line
:= False;
6980 Target
.IsPlayer
:= False;
6985 // Åñëè öåëü íå âèäèìà èëè íå íà ëèíèè îãíÿ, òî èùåì âñå âîçìîæíûå öåëè:
6986 if (not Target
.Line
) or (not Target
.Visible
) then
6990 for a
:= 0 to High(gPlayers
) do
6991 if (gPlayers
[a
] <> nil) and (gPlayers
[a
].alive
) and
6992 (gPlayers
[a
].FUID
<> FUID
) and
6993 (not SameTeam(FUID
, gPlayers
[a
].FUID
)) and
6994 (not gPlayers
[a
].NoTarget
) and
6995 (gPlayers
[a
].FMegaRulez
[MR_INVIS
] < gTime
) then
6997 if not TargetOnScreen(gPlayers
[a
].FObj
.X
+ PLAYER_RECT
.X
,
6998 gPlayers
[a
].FObj
.Y
+ PLAYER_RECT
.Y
) then
7001 x2
:= gPlayers
[a
].FObj
.X
+ PLAYER_RECT_CX
;
7002 y2
:= gPlayers
[a
].FObj
.Y
+ PLAYER_RECT_CY
;
7004 // Åñëè èãðîê íà ýêðàíå è íå ïðèêðûò ñòåíîé:
7005 if g_TraceVector(x1
, y1
, x2
, y2
) then
7007 // Äîáàâëÿåì ê ñïèñêó âîçìîæíûõ öåëåé:
7008 SetLength(targets
, Length(targets
)+1);
7009 with targets
[High(targets
)] do
7011 UID
:= gPlayers
[a
].FUID
;
7012 X
:= gPlayers
[a
].FObj
.X
;
7013 Y
:= gPlayers
[a
].FObj
.Y
;
7016 Rect
:= PLAYER_RECT
;
7017 Dist
:= g_PatchLength(x1
, y1
, x2
, y2
);
7018 Line
:= (y1
+4 < Target
.Y
+PLAYER_RECT
.Y
+PLAYER_RECT
.Height
) and
7019 (y1
-4 > Target
.Y
+PLAYER_RECT
.Y
);
7027 if vsMonster
then g_Mons_ForEach(monsUpdate
);
7030 // Åñëè åñòü âîçìîæíûå öåëè:
7031 // (Âûáèðàåì ëó÷øóþ, ìåíÿåì îðóæèå è áåæèì ê íåé/îò íåå)
7032 if targets
<> nil then
7034 // Âûáèðàåì íàèëó÷øóþ öåëü:
7035 BestTarget
:= targets
[0];
7036 if Length(targets
) > 1 then
7037 for a
:= 1 to High(targets
) do
7038 if Compare(BestTarget
, targets
[a
]) = 1 then
7039 BestTarget
:= targets
[a
];
7041 // Åñëè ëó÷øàÿ öåëü "âèäíåå" òåêóùåé, òî òåêóùàÿ := ëó÷øàÿ:
7042 if ((not Target
.Visible
) and BestTarget
.Visible
and (Target
.UID
<> BestTarget
.UID
)) or
7043 ((not Target
.Line
) and BestTarget
.Line
and BestTarget
.Visible
) then
7045 Target
:= BestTarget
;
7047 if (Healthy() = 3) or ((Healthy() = 2)) then
7048 begin // Åñëè çäîðîâû - äîãîíÿåì
7049 if ((RunDirection() = TDirection
.D_LEFT
) and (Target
.X
> FObj
.X
)) then
7050 SetAIFlag('GORIGHT', '1');
7051 if ((RunDirection() = TDirection
.D_RIGHT
) and (Target
.X
< FObj
.X
)) then
7052 SetAIFlag('GOLEFT', '1');
7055 begin // Åñëè ïîáèòû - óáåãàåì
7056 if ((RunDirection() = TDirection
.D_LEFT
) and (Target
.X
< FObj
.X
)) then
7057 SetAIFlag('GORIGHT', '1');
7058 if ((RunDirection() = TDirection
.D_RIGHT
) and (Target
.X
> FObj
.X
)) then
7059 SetAIFlag('GOLEFT', '1');
7062 // Âûáèðàåì îðóæèå íà îñíîâå ðàññòîÿíèÿ è ïðèîðèòåòîâ:
7063 SelectWeapon(Abs(x1
-Target
.cX
));
7068 // (Äîãîíÿåì/óáåãàåì, ñòðåëÿåì ïî íàïðàâëåíèþ ê öåëè)
7069 // (Åñëè öåëü äàëåêî, òî õâàòèò ñëåäèòü çà íåé)
7070 if Target
.UID
<> 0 then
7072 if not TargetOnScreen(Target
.X
+ Target
.Rect
.X
,
7073 Target
.Y
+ Target
.Rect
.Y
) then
7074 begin // Öåëü ñáåæàëà ñ "ýêðàíà"
7075 if (Healthy() = 3) or ((Healthy() = 2)) then
7076 begin // Åñëè çäîðîâû - äîãîíÿåì
7077 if ((RunDirection() = TDirection
.D_LEFT
) and (Target
.X
> FObj
.X
)) then
7078 SetAIFlag('GORIGHT', '1');
7079 if ((RunDirection() = TDirection
.D_RIGHT
) and (Target
.X
< FObj
.X
)) then
7080 SetAIFlag('GOLEFT', '1');
7083 begin // Åñëè ïîáèòû - çàáûâàåì î öåëè è óáåãàåì
7085 if ((RunDirection() = TDirection
.D_LEFT
) and (Target
.X
< FObj
.X
)) then
7086 SetAIFlag('GORIGHT', '1');
7087 if ((RunDirection() = TDirection
.D_RIGHT
) and (Target
.X
> FObj
.X
)) then
7088 SetAIFlag('GOLEFT', '1');
7092 begin // Öåëü ïîêà íà "ýêðàíå"
7093 // Åñëè öåëü íå çàãîðîæåíà ñòåíîé, òî îòìå÷àåì, êîãäà åå âèäåëè:
7094 if g_TraceVector(x1
, y1
, Target
.cX
, Target
.cY
) then
7095 FLastVisible
:= gTime
;
7096 // Åñëè ðàçíèöà âûñîò íå âåëèêà, òî äîãîíÿåì:
7097 if (Abs(FObj
.Y
-Target
.Y
) <= 128) then
7099 if ((RunDirection() = TDirection
.D_LEFT
) and (Target
.X
> FObj
.X
)) then
7100 SetAIFlag('GORIGHT', '1');
7101 if ((RunDirection() = TDirection
.D_RIGHT
) and (Target
.X
< FObj
.X
)) then
7102 SetAIFlag('GOLEFT', '1');
7106 // Âûáèðàåì óãîë ââåðõ:
7107 if FDirection
= TDirection
.D_LEFT
then
7108 angle
:= ANGLE_LEFTUP
7110 angle
:= ANGLE_RIGHTUP
;
7112 firew
:= Trunc(Cos(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
7113 fireh
:= Trunc(Sin(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
7115 // Åñëè ïðè óãëå ââåðõ ìîæíî ïîïàñòü â ïðèáëèçèòåëüíîå ïîëîæåíèå öåëè:
7116 if g_CollideLine(x1
, y1
, x1
+firew
, y1
+fireh
,
7117 Target
.X
+Target
.Rect
.X
+GetInterval(FDifficult
.DiagPrecision
, 128), //96
7118 Target
.Y
+Target
.Rect
.Y
+GetInterval(FDifficult
.DiagPrecision
, 128),
7119 Target
.Rect
.Width
, Target
.Rect
.Height
) and
7120 g_TraceVector(x1
, y1
, Target
.cX
, Target
.cY
) then
7121 begin // òî íóæíî ñòðåëÿòü ââåðõ
7122 SetAIFlag('NEEDFIRE', '1');
7123 SetAIFlag('NEEDSEEUP', '1');
7126 // Âûáèðàåì óãîë âíèç:
7127 if FDirection
= TDirection
.D_LEFT
then
7128 angle
:= ANGLE_LEFTDOWN
7130 angle
:= ANGLE_RIGHTDOWN
;
7132 firew
:= Trunc(Cos(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
7133 fireh
:= Trunc(Sin(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
7135 // Åñëè ïðè óãëå âíèç ìîæíî ïîïàñòü â ïðèáëèçèòåëüíîå ïîëîæåíèå öåëè:
7136 if g_CollideLine(x1
, y1
, x1
+firew
, y1
+fireh
,
7137 Target
.X
+Target
.Rect
.X
+GetInterval(FDifficult
.DiagPrecision
, 128),
7138 Target
.Y
+Target
.Rect
.Y
+GetInterval(FDifficult
.DiagPrecision
, 128),
7139 Target
.Rect
.Width
, Target
.Rect
.Height
) and
7140 g_TraceVector(x1
, y1
, Target
.cX
, Target
.cY
) then
7141 begin // òî íóæíî ñòðåëÿòü âíèç
7142 SetAIFlag('NEEDFIRE', '1');
7143 SetAIFlag('NEEDSEEDOWN', '1');
7146 // Åñëè öåëü âèäíî è îíà íà òàêîé æå âûñîòå:
7147 if Target
.Visible
and
7148 (y1
+4 < Target
.Y
+Target
.Rect
.Y
+Target
.Rect
.Height
) and
7149 (y1
-4 > Target
.Y
+Target
.Rect
.Y
) then
7151 // Åñëè èäåì â ñòîðîíó öåëè, òî íàäî ñòðåëÿòü:
7152 if ((FDirection
= TDirection
.D_LEFT
) and (Target
.X
< FObj
.X
)) or
7153 ((FDirection
= TDirection
.D_RIGHT
) and (Target
.X
> FObj
.X
)) then
7154 begin // òî íóæíî ñòðåëÿòü âïåðåä
7155 SetAIFlag('NEEDFIRE', '1');
7156 SetAIFlag('NEEDSEEDOWN', '');
7157 SetAIFlag('NEEDSEEUP', '');
7159 // Åñëè öåëü â ïðåäåëàõ "ýêðàíà" è ñëîæíîñòü ïîçâîëÿåò ïðûæêè ñáëèæåíèÿ:
7160 if Abs(FObj
.X
-Target
.X
) < Trunc(gPlayerScreenSize
.X
*0.75) then
7161 if GetRnd(FDifficult
.CloseJump
) then
7162 begin // òî åñëè ïîâåçåò - ïðûãàåì (îñîáåííî, åñëè áëèçêî)
7163 if Abs(FObj
.X
-Target
.X
) < 128 then
7167 if Random(a
) = 0 then
7168 SetAIFlag('NEEDJUMP', '1');
7172 // Åñëè öåëü âñå åùå åñòü:
7173 if Target
.UID
<> 0 then
7174 if gTime
-FLastVisible
> 2000 then // Åñëè âèäåëè äàâíî
7175 Target
.UID
:= 0 // òî çàáûòü öåëü
7176 else // Åñëè âèäåëè íåäàâíî
7177 begin // íî öåëü óáèëè
7178 if Target
.IsPlayer
then
7179 begin // Öåëü - èãðîê
7180 pla
:= g_Player_Get(Target
.UID
);
7181 if (pla
= nil) or (not pla
.alive
) or pla
.NoTarget
or
7182 (pla
.FMegaRulez
[MR_INVIS
] >= gTime
) then
7183 Target
.UID
:= 0; // òî çàáûòü öåëü
7186 begin // Öåëü - ìîíñòð
7187 mon
:= g_Monsters_ByUID(Target
.UID
);
7188 if (mon
= nil) or (not mon
.alive
) then
7189 Target
.UID
:= 0; // òî çàáûòü öåëü
7192 end; // if Target.UID <> 0
7194 FTargetUID
:= Target
.UID
;
7196 // Åñëè âîçìîæíûõ öåëåé íåò:
7197 // (Àòàêà ÷åãî-íèáóäü ñëåâà èëè ñïðàâà)
7198 if targets
= nil then
7199 if GetAIFlag('ATTACKLEFT') <> '' then
7200 begin // Åñëè íóæíî àòàêîâàòü íàëåâî
7201 RemoveAIFlag('ATTACKLEFT');
7203 SetAIFlag('NEEDJUMP', '1');
7205 if RunDirection() = TDirection
.D_RIGHT
then
7206 begin // Èäåì íå â òó ñòîðîíó
7207 if (Healthy() > 1) and GetRnd(FDifficult
.InvisFire
) then
7208 begin // Åñëè çäîðîâû, òî, âîçìîæíî, ñòðåëÿåì áåæèì âëåâî è ñòðåëÿåì
7209 SetAIFlag('NEEDFIRE', '1');
7210 SetAIFlag('GOLEFT', '1');
7214 begin // Èäåì â íóæíóþ ñòîðîíó
7215 if GetRnd(FDifficult
.InvisFire
) then // Âîçìîæíî, ñòðåëÿåì âñëåïóþ
7216 SetAIFlag('NEEDFIRE', '1');
7217 if Healthy() <= 1 then // Ïîáèòû - óáåãàåì
7218 SetAIFlag('GORIGHT', '1');
7222 if GetAIFlag('ATTACKRIGHT') <> '' then
7223 begin // Åñëè íóæíî àòàêîâàòü íàïðàâî
7224 RemoveAIFlag('ATTACKRIGHT');
7226 SetAIFlag('NEEDJUMP', '1');
7228 if RunDirection() = TDirection
.D_LEFT
then
7229 begin // Èäåì íå â òó ñòîðîíó
7230 if (Healthy() > 1) and GetRnd(FDifficult
.InvisFire
) then
7231 begin // Åñëè çäîðîâû, òî, âîçìîæíî, áåæèì âïðàâî è ñòðåëÿåì
7232 SetAIFlag('NEEDFIRE', '1');
7233 SetAIFlag('GORIGHT', '1');
7238 if GetRnd(FDifficult
.InvisFire
) then // Âîçìîæíî, ñòðåëÿåì âñëåïóþ
7239 SetAIFlag('NEEDFIRE', '1');
7240 if Healthy() <= 1 then // Ïîáèòû - óáåãàåì
7241 SetAIFlag('GOLEFT', '1');
7245 //HACK! (does it belongs there?)
7246 RealizeCurrentWeapon();
7248 // Åñëè åñòü âîçìîæíûå öåëè:
7249 // (Ñòðåëÿåì ïî íàïðàâëåíèþ ê öåëÿì)
7250 if (targets
<> nil) and (GetAIFlag('NEEDFIRE') <> '') then
7251 for a
:= 0 to High(targets
) do
7253 // Åñëè ìîæåì ñòðåëÿòü ïî äèàãîíàëè:
7254 if GetRnd(FDifficult
.DiagFire
) then
7256 // Èùåì öåëü ñâåðõó è ñòðåëÿåì, åñëè åñòü:
7257 if FDirection
= TDirection
.D_LEFT
then
7258 angle
:= ANGLE_LEFTUP
7260 angle
:= ANGLE_RIGHTUP
;
7262 firew
:= Trunc(Cos(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
7263 fireh
:= Trunc(Sin(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
7265 if g_CollideLine(x1
, y1
, x1
+firew
, y1
+fireh
,
7266 targets
[a
].X
+targets
[a
].Rect
.X
+GetInterval(FDifficult
.DiagPrecision
, 128),
7267 targets
[a
].Y
+targets
[a
].Rect
.Y
+GetInterval(FDifficult
.DiagPrecision
, 128),
7268 targets
[a
].Rect
.Width
, targets
[a
].Rect
.Height
) and
7269 g_TraceVector(x1
, y1
, targets
[a
].cX
, targets
[a
].cY
) then
7271 SetAIFlag('NEEDFIRE', '1');
7272 SetAIFlag('NEEDSEEUP', '1');
7275 // Èùåì öåëü ñíèçó è ñòðåëÿåì, åñëè åñòü:
7276 if FDirection
= TDirection
.D_LEFT
then
7277 angle
:= ANGLE_LEFTDOWN
7279 angle
:= ANGLE_RIGHTDOWN
;
7281 firew
:= Trunc(Cos(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
7282 fireh
:= Trunc(Sin(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
7284 if g_CollideLine(x1
, y1
, x1
+firew
, y1
+fireh
,
7285 targets
[a
].X
+targets
[a
].Rect
.X
+GetInterval(FDifficult
.DiagPrecision
, 128),
7286 targets
[a
].Y
+targets
[a
].Rect
.Y
+GetInterval(FDifficult
.DiagPrecision
, 128),
7287 targets
[a
].Rect
.Width
, targets
[a
].Rect
.Height
) and
7288 g_TraceVector(x1
, y1
, targets
[a
].cX
, targets
[a
].cY
) then
7290 SetAIFlag('NEEDFIRE', '1');
7291 SetAIFlag('NEEDSEEDOWN', '1');
7295 // Åñëè öåëü "ïåðåä íîñîì", òî ñòðåëÿåì:
7296 if targets
[a
].Line
and targets
[a
].Visible
and
7297 (((FDirection
= TDirection
.D_LEFT
) and (targets
[a
].X
< FObj
.X
)) or
7298 ((FDirection
= TDirection
.D_RIGHT
) and (targets
[a
].X
> FObj
.X
))) then
7300 SetAIFlag('NEEDFIRE', '1');
7305 // Åñëè ëåòèò ïóëÿ, òî, âîçìîæíî, ïîäïðûãèâàåì:
7306 if g_Weapon_Danger(FUID
, FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+PLAYER_RECT
.Y
,
7307 PLAYER_RECT
.Width
, PLAYER_RECT
.Height
,
7308 40+GetInterval(FDifficult
.Cover
, 40)) then
7309 SetAIFlag('NEEDJUMP', '1');
7311 // Åñëè êîí÷èëèñü ïàòîðíû, òî íóæíî ñìåíèòü îðóæèå:
7312 ammo
:= GetAmmoByWeapon(FCurrWeap
);
7313 if ((FCurrWeap
= WEAPON_SHOTGUN2
) and (ammo
< 2)) or
7314 ((FCurrWeap
= WEAPON_BFG
) and (ammo
< 40)) or
7316 SetAIFlag('SELECTWEAPON', '1');
7318 // Åñëè íóæíî ñìåíèòü îðóæèå, òî âûáèðàåì íóæíîå:
7319 if GetAIFlag('SELECTWEAPON') = '1' then
7322 RemoveAIFlag('SELECTWEAPON');
7326 procedure TBot
.Update();
7339 // Ïðîâåðÿåì, îòêëþ÷¸í ëè AI áîòîâ
7340 if (g_debug_BotAIOff
= 1) and (Team
= TEAM_RED
) then
7342 if (g_debug_BotAIOff
= 2) and (Team
= TEAM_BLUE
) then
7344 if g_debug_BotAIOff
= 3 then
7354 RealizeCurrentWeapon();
7361 procedure TBot
.ReleaseKey(Key
: Byte);
7370 function TBot
.KeyPressed(Key
: Word): Boolean;
7372 Result
:= FKeys
[Key
].Pressed
;
7375 function TBot
.GetAIFlag(aName
: String20
): String20
;
7381 aName
:= LowerCase(aName
);
7383 if FAIFlags
<> nil then
7384 for a
:= 0 to High(FAIFlags
) do
7385 if LowerCase(FAIFlags
[a
].Name
) = aName
then
7387 Result
:= FAIFlags
[a
].Value
;
7392 procedure TBot
.RemoveAIFlag(aName
: String20
);
7396 if FAIFlags
= nil then Exit
;
7398 aName
:= LowerCase(aName
);
7400 for a
:= 0 to High(FAIFlags
) do
7401 if LowerCase(FAIFlags
[a
].Name
) = aName
then
7403 if a
<> High(FAIFlags
) then
7404 for b
:= a
to High(FAIFlags
)-1 do
7405 FAIFlags
[b
] := FAIFlags
[b
+1];
7407 SetLength(FAIFlags
, Length(FAIFlags
)-1);
7412 procedure TBot
.SetAIFlag(aName
, fValue
: String20
);
7420 aName
:= LowerCase(aName
);
7422 if FAIFlags
<> nil then
7423 for a
:= 0 to High(FAIFlags
) do
7424 if LowerCase(FAIFlags
[a
].Name
) = aName
then
7430 if ok
then FAIFlags
[a
].Value
:= fValue
7433 SetLength(FAIFlags
, Length(FAIFlags
)+1);
7434 with FAIFlags
[High(FAIFlags
)] do
7442 procedure TBot
.UpdateMove
;
7444 procedure GoLeft(Time
: Word = 1);
7446 ReleaseKey(KEY_LEFT
);
7447 ReleaseKey(KEY_RIGHT
);
7448 PressKey(KEY_LEFT
, Time
);
7449 SetDirection(TDirection
.D_LEFT
);
7452 procedure GoRight(Time
: Word = 1);
7454 ReleaseKey(KEY_LEFT
);
7455 ReleaseKey(KEY_RIGHT
);
7456 PressKey(KEY_RIGHT
, Time
);
7457 SetDirection(TDirection
.D_RIGHT
);
7460 function Rnd(a
: Word): Boolean;
7462 Result
:= Random(a
) = 0;
7465 procedure Turn(Time
: Word = 1200);
7467 if RunDirection() = TDirection
.D_LEFT
then GoRight(Time
) else GoLeft(Time
);
7472 ReleaseKey(KEY_LEFT
);
7473 ReleaseKey(KEY_RIGHT
);
7476 function CanRunLeft(): Boolean;
7478 Result
:= not CollideLevel(-1, 0);
7481 function CanRunRight(): Boolean;
7483 Result
:= not CollideLevel(1, 0);
7486 function CanRun(): Boolean;
7488 if RunDirection() = TDirection
.D_LEFT
then Result
:= CanRunLeft() else Result
:= CanRunRight();
7491 procedure Jump(Time
: Word = 30);
7493 PressKey(KEY_JUMP
, Time
);
7496 function NearHole(): Boolean;
7500 { TODO 5 : Ëåñòíèöû }
7501 sx
:= IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1);
7502 for x
:= 1 to PLAYER_RECT
.Width
do
7503 if (not StayOnStep(x
*sx
, 0)) and
7504 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
)) and
7505 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
*2)) then
7514 function BorderHole(): Boolean;
7518 { TODO 5 : Ëåñòíèöû }
7519 sx
:= IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1);
7520 for x
:= 1 to PLAYER_RECT
.Width
do
7521 if (not StayOnStep(x
*sx
, 0)) and
7522 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
)) and
7523 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
*2)) then
7525 for xx
:= x
to x
+32 do
7526 if CollideLevel(xx
*sx
, PLAYER_RECT
.Height
) then
7536 function NearDeepHole(): Boolean;
7542 sx
:= IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1);
7545 for x
:= 1 to PLAYER_RECT
.Width
do
7546 if (not StayOnStep(x
*sx
, 0)) and
7547 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
)) and
7548 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
*2)) then
7550 while FObj
.Y
+y
*PLAYER_RECT
.Height
< gMapInfo
.Height
do
7552 if CollideLevel(x
*sx
, PLAYER_RECT
.Height
*y
) then Exit
;
7557 end else Result
:= False;
7560 function OverDeepHole(): Boolean;
7567 while FObj
.Y
+y
*PLAYER_RECT
.Height
< gMapInfo
.Height
do
7569 if CollideLevel(0, PLAYER_RECT
.Height
*y
) then Exit
;
7576 function OnGround(): Boolean;
7578 Result
:= StayOnStep(0, 0) or CollideLevel(0, 1);
7581 function OnLadder(): Boolean;
7583 Result
:= FullInStep(0, 0);
7586 function BelowLadder(): Boolean;
7588 Result
:= (FullInStep(IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -PLAYER_RECT
.Height
) and
7589 not CollideLevel(IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -PLAYER_RECT
.Height
)) or
7590 (FullInStep(IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -BOT_MAXJUMP
) and
7591 not CollideLevel(IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -BOT_MAXJUMP
));
7594 function BelowLiftUp(): Boolean;
7596 Result
:= ((FullInLift(IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -PLAYER_RECT
.Height
) = -1) and
7597 not CollideLevel(IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -PLAYER_RECT
.Height
)) or
7598 ((FullInLift(IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -BOT_MAXJUMP
) = -1) and
7599 not CollideLevel(IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -BOT_MAXJUMP
));
7602 function OnTopLift(): Boolean;
7604 Result
:= (FullInLift(0, 0) = -1) and (FullInLift(0, -32) = 0);
7607 function CanJumpOver(): Boolean;
7611 sx
:= IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1);
7615 if not CollideLevel(sx
, 0) then Exit
;
7617 for y
:= 1 to BOT_MAXJUMP
do
7618 if CollideLevel(0, -y
) then Exit
else
7619 if not CollideLevel(sx
, -y
) then
7626 function CanJumpUp(Dist
: ShortInt): Boolean;
7633 if CollideLevel(Dist
, 0) then Exit
;
7636 for y
:= 0 to BOT_MAXJUMP
do
7637 if CollideLevel(Dist
, -y
) then
7646 for yy
:= y
+1 to BOT_MAXJUMP
do
7647 if not CollideLevel(Dist
, -yy
) then
7656 for y
:= 0 to BOT_MAXJUMP
do
7657 if CollideLevel(0, -y
) then
7665 if y
< yy
then Exit
;
7670 function IsSafeTrigger(): Boolean;
7675 if gTriggers
= nil then
7677 for a
:= 0 to High(gTriggers
) do
7678 if Collide(gTriggers
[a
].X
,
7681 gTriggers
[a
].Height
) and
7682 (gTriggers
[a
].TriggerType
in [TRIGGER_EXIT
, TRIGGER_CLOSEDOOR
,
7683 TRIGGER_CLOSETRAP
, TRIGGER_TRAP
,
7684 TRIGGER_PRESS
, TRIGGER_ON
, TRIGGER_OFF
,
7685 TRIGGER_ONOFF
, TRIGGER_SPAWNMONSTER
,
7686 TRIGGER_DAMAGE
, TRIGGER_SHOT
]) then
7691 // Âîçìîæíî, íàæèìàåì êíîïêó:
7692 if Rnd(16) and IsSafeTrigger() then
7695 // Åñëè ïîä ëèôòîì èëè ñòóïåíüêàìè, òî, âîçìîæíî, ïðûãàåì:
7696 if OnLadder() or ((BelowLadder() or BelowLiftUp()) and Rnd(8)) then
7698 ReleaseKey(KEY_LEFT
);
7699 ReleaseKey(KEY_RIGHT
);
7703 // Èäåì âëåâî, åñëè íàäî áûëî:
7704 if GetAIFlag('GOLEFT') <> '' then
7706 RemoveAIFlag('GOLEFT');
7707 if CanRunLeft() then
7711 // Èäåì âïðàâî, åñëè íàäî áûëî:
7712 if GetAIFlag('GORIGHT') <> '' then
7714 RemoveAIFlag('GORIGHT');
7715 if CanRunRight() then
7719 // Åñëè âûëåòåëè çà êàðòó, òî ïðîáóåì âåðíóòüñÿ:
7720 if FObj
.X
< -32 then
7723 if FObj
.X
+32 > gMapInfo
.Width
then
7726 // Ïðûãàåì, åñëè íàäî áûëî:
7727 if GetAIFlag('NEEDJUMP') <> '' then
7730 RemoveAIFlag('NEEDJUMP');
7733 // Ñìîòðèì ââåðõ, åñëè íàäî áûëî:
7734 if GetAIFlag('NEEDSEEUP') <> '' then
7737 ReleaseKey(KEY_DOWN
);
7738 PressKey(KEY_UP
, 20);
7739 RemoveAIFlag('NEEDSEEUP');
7742 // Ñìîòðèì âíèç, åñëè íàäî áûëî:
7743 if GetAIFlag('NEEDSEEDOWN') <> '' then
7746 ReleaseKey(KEY_DOWN
);
7747 PressKey(KEY_DOWN
, 20);
7748 RemoveAIFlag('NEEDSEEDOWN');
7751 // Åñëè íóæíî áûëî â äûðó è ìû íå íà çåìëå, òî ïîêîðíî ëåòèì:
7752 if GetAIFlag('GOINHOLE') <> '' then
7753 if not OnGround() then
7755 ReleaseKey(KEY_LEFT
);
7756 ReleaseKey(KEY_RIGHT
);
7757 RemoveAIFlag('GOINHOLE');
7758 SetAIFlag('FALLINHOLE', '1');
7761 // Åñëè ïàäàëè è äîñòèãëè çåìëè, òî õâàòèò ïàäàòü:
7762 if GetAIFlag('FALLINHOLE') <> '' then
7764 RemoveAIFlag('FALLINHOLE');
7766 // Åñëè ëåòåëè ïðÿìî è ñåé÷àñ íå íà ëåñòíèöå èëè íà âåðøèíå ëèôòà, òî îòõîäèì â ñòîðîíó:
7767 if not (KeyPressed(KEY_LEFT
) or KeyPressed(KEY_RIGHT
)) then
7768 if GetAIFlag('FALLINHOLE') = '' then
7769 if (not OnLadder()) or (FObj
.Vel
.Y
>= 0) or (OnTopLift()) then
7775 // Åñëè íà çåìëå è ìîæíî ïîäïðûãíóòü, òî, âîçìîæíî, ïðûãàåì:
7777 CanJumpUp(IfThen(RunDirection() = TDirection
.D_LEFT
, -1, 1)*32) and
7781 // Åñëè íà çåìëå è âîçëå äûðû (ãëóáèíà > 2 ðîñòîâ èãðîêà):
7782 if OnGround() and NearHole() then
7783 if NearDeepHole() then // Åñëè ýòî áåçäíà
7785 0..3: Turn(); // Áåæèì îáðàòíî
7786 4: Jump(); // Ïðûãàåì
7787 5: begin // Ïðûãàåì îáðàòíî
7792 else // Ýòî íå áåçäíà è ìû åùå íå ëåòèì òóäà
7793 if GetAIFlag('GOINHOLE') = '' then
7795 0: Turn(); // Íå íóæíî òóäà
7796 1: Jump(); // Âäðóã ïîâåçåò - ïðûãàåì
7797 else // Åñëè ÿìà ñ ãðàíèöåé, òî ïðè ñëó÷àå ìîæíî òóäà ïðûãíóòü
7798 if BorderHole() then
7799 SetAIFlag('GOINHOLE', '1');
7802 // Åñëè íà çåìëå, íî íåêóäà èäòè:
7803 if (not CanRun()) and OnGround() then
7805 // Åñëè ìû íà ëåñòíèöå èëè ìîæíî ïåðåïðûãíóòü, òî ïðûãàåì:
7806 if CanJumpOver() or OnLadder() then
7808 else // èíà÷å ïîïûòàåìñÿ â äðóãóþ ñòîðîíó
7809 if Random(2) = 0 then
7811 if IsSafeTrigger() then
7817 // Îñòàëîñü ìàëî âîçäóõà:
7818 if FAir
< 36 * 2 then
7821 // Âûáèðàåìñÿ èç êèñëîòû, åñëè íåò êîñòþìà, îáîæãëèñü, èëè ìàëî çäîðîâüÿ:
7822 if (FMegaRulez
[MR_SUIT
] < gTime
) and ((FLastHit
= HIT_ACID
) or (Healthy() <= 1)) then
7823 if BodyInAcid(0, 0) then
7827 function TBot
.FullInStep(XInc
, YInc
: Integer): Boolean;
7829 Result
:= g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
,
7830 PLAYER_RECT
.Width
, PLAYER_RECT
.Height
, PANEL_STEP
, False);
7833 {function TBot.NeedItem(Item: Byte): Byte;
7838 procedure TBot
.SelectWeapon(Dist
: Integer);
7842 function HaveAmmo(weapon
: Byte): Boolean;
7845 WEAPON_PISTOL
: Result
:= FAmmo
[A_BULLETS
] >= 1;
7846 WEAPON_SHOTGUN1
: Result
:= FAmmo
[A_SHELLS
] >= 1;
7847 WEAPON_SHOTGUN2
: Result
:= FAmmo
[A_SHELLS
] >= 2;
7848 WEAPON_CHAINGUN
: Result
:= FAmmo
[A_BULLETS
] >= 10;
7849 WEAPON_ROCKETLAUNCHER
: Result
:= FAmmo
[A_ROCKETS
] >= 1;
7850 WEAPON_PLASMA
: Result
:= FAmmo
[A_CELLS
] >= 10;
7851 WEAPON_BFG
: Result
:= FAmmo
[A_CELLS
] >= 40;
7852 WEAPON_SUPERPULEMET
: Result
:= FAmmo
[A_SHELLS
] >= 1;
7853 WEAPON_FLAMETHROWER
: Result
:= FAmmo
[A_FUEL
] >= 1;
7854 else Result
:= True;
7859 if Dist
= -1 then Dist
:= BOT_LONGDIST
;
7861 if Dist
> BOT_LONGDIST
then
7862 begin // Äàëüíèé áîé
7864 if FWeapon
[FDifficult
.WeaponPrior
[a
]] and HaveAmmo(FDifficult
.WeaponPrior
[a
]) then
7866 FSelectedWeapon
:= FDifficult
.WeaponPrior
[a
];
7870 else //if Dist > BOT_UNSAFEDIST then
7871 begin // Áëèæíèé áîé
7873 if FWeapon
[FDifficult
.CloseWeaponPrior
[a
]] and HaveAmmo(FDifficult
.CloseWeaponPrior
[a
]) then
7875 FSelectedWeapon
:= FDifficult
.CloseWeaponPrior
[a
];
7882 if FWeapon[FDifficult.SafeWeaponPrior[a]] and HaveAmmo(FDifficult.SafeWeaponPrior[a]) then
7884 FSelectedWeapon := FDifficult.SafeWeaponPrior[a];
7890 function TBot
.PickItem(ItemType
: Byte; force
: Boolean; var remove
: Boolean): Boolean;
7892 Result
:= inherited PickItem(ItemType
, force
, remove
);
7894 if Result
then SetAIFlag('SELECTWEAPON', '1');
7897 function TBot
.Heal(value
: Word; Soft
: Boolean): Boolean;
7899 Result
:= inherited Heal(value
, Soft
);
7902 function TBot
.Healthy(): Byte;
7904 if FMegaRulez
[MR_INVUL
] >= gTime
then Result
:= 3
7905 else if (FHealth
> 80) or ((FHealth
> 50) and (FArmor
> 20)) then Result
:= 3
7906 else if (FHealth
> 50) then Result
:= 2
7907 else if (FHealth
> 20) then Result
:= 1
7911 function TBot
.TargetOnScreen(TX
, TY
: Integer): Boolean;
7913 Result
:= (Abs(FObj
.X
-TX
) <= Trunc(gPlayerScreenSize
.X
*0.6)) and
7914 (Abs(FObj
.Y
-TY
) <= Trunc(gPlayerScreenSize
.Y
*0.6));
7917 procedure TBot
.OnDamage(Angle
: SmallInt);
7925 if (Angle
= 0) or (Angle
= 180) then
7928 if (g_GetUIDType(FLastSpawnerUID
) = UID_PLAYER
) and
7929 LongBool(gGameSettings
.Options
and GAME_OPTION_BOTVSPLAYER
) then
7931 pla
:= g_Player_Get(FLastSpawnerUID
);
7932 ok
:= not TargetOnScreen(pla
.FObj
.X
+ PLAYER_RECT
.X
,
7933 pla
.FObj
.Y
+ PLAYER_RECT
.Y
);
7936 if (g_GetUIDType(FLastSpawnerUID
) = UID_MONSTER
) and
7937 LongBool(gGameSettings
.Options
and GAME_OPTION_BOTVSMONSTER
) then
7939 mon
:= g_Monsters_ByUID(FLastSpawnerUID
);
7940 ok
:= not TargetOnScreen(mon
.Obj
.X
+ mon
.Obj
.Rect
.X
,
7941 mon
.Obj
.Y
+ mon
.Obj
.Rect
.Y
);
7946 SetAIFlag('ATTACKLEFT', '1')
7948 SetAIFlag('ATTACKRIGHT', '1');
7952 function TBot
.RunDirection(): TDirection
;
7954 if Abs(Vel
.X
) >= 1 then
7956 if Vel
.X
> 0 then Result
:= TDirection
.D_RIGHT
else Result
:= TDirection
.D_LEFT
;
7958 Result
:= FDirection
;
7961 function TBot
.GetRnd(a
: Byte): Boolean;
7963 if a
= 0 then Result
:= False
7964 else if a
= 255 then Result
:= True
7965 else Result
:= Random(256) > 255-a
;
7968 function TBot
.GetInterval(a
: Byte; radius
: SmallInt): SmallInt;
7970 Result
:= Round((255-a
)/255*radius
*(Random(2)-1));
7974 procedure TDifficult
.save (st
: TStream
);
7976 utils
.writeInt(st
, Byte(DiagFire
));
7977 utils
.writeInt(st
, Byte(InvisFire
));
7978 utils
.writeInt(st
, Byte(DiagPrecision
));
7979 utils
.writeInt(st
, Byte(FlyPrecision
));
7980 utils
.writeInt(st
, Byte(Cover
));
7981 utils
.writeInt(st
, Byte(CloseJump
));
7982 st
.WriteBuffer(WeaponPrior
[Low(WeaponPrior
)], sizeof(WeaponPrior
));
7983 st
.WriteBuffer(CloseWeaponPrior
[Low(CloseWeaponPrior
)], sizeof(CloseWeaponPrior
));
7986 procedure TDifficult
.load (st
: TStream
);
7988 DiagFire
:= utils
.readByte(st
);
7989 InvisFire
:= utils
.readByte(st
);
7990 DiagPrecision
:= utils
.readByte(st
);
7991 FlyPrecision
:= utils
.readByte(st
);
7992 Cover
:= utils
.readByte(st
);
7993 CloseJump
:= utils
.readByte(st
);
7994 st
.ReadBuffer(WeaponPrior
[Low(WeaponPrior
)], sizeof(WeaponPrior
));
7995 st
.ReadBuffer(CloseWeaponPrior
[Low(CloseWeaponPrior
)], sizeof(CloseWeaponPrior
));
7999 procedure TBot
.SaveState (st
: TStream
);
8004 inherited SaveState(st
);
8005 utils
.writeSign(st
, 'BOT0');
8007 utils
.writeInt(st
, Byte(FSelectedWeapon
));
8009 utils
.writeInt(st
, Word(FTargetUID
));
8010 // Âðåìÿ ïîòåðè öåëè
8011 utils
.writeInt(st
, LongWord(FLastVisible
));
8012 // Êîëè÷åñòâî ôëàãîâ ÈÈ
8013 dw
:= Length(FAIFlags
);
8014 utils
.writeInt(st
, LongInt(dw
));
8016 for i
:= 0 to dw
-1 do
8018 utils
.writeStr(st
, FAIFlags
[i
].Name
, 20);
8019 utils
.writeStr(st
, FAIFlags
[i
].Value
, 20);
8021 // Íàñòðîéêè ñëîæíîñòè
8022 FDifficult
.save(st
);
8026 procedure TBot
.LoadState (st
: TStream
);
8031 inherited LoadState(st
);
8032 if not utils
.checkSign(st
, 'BOT0') then raise XStreamError
.Create('invalid bot signature');
8034 FSelectedWeapon
:= utils
.readByte(st
);
8036 FTargetUID
:= utils
.readWord(st
);
8037 // Âðåìÿ ïîòåðè öåëè
8038 FLastVisible
:= utils
.readLongWord(st
);
8039 // Êîëè÷åñòâî ôëàãîâ ÈÈ
8040 dw
:= utils
.readLongInt(st
);
8041 if (dw
< 0) or (dw
> 16384) then raise XStreamError
.Create('invalid number of bot AI flags');
8042 SetLength(FAIFlags
, dw
);
8044 for i
:= 0 to dw
-1 do
8046 FAIFlags
[i
].Name
:= utils
.readStr(st
, 20);
8047 FAIFlags
[i
].Value
:= utils
.readStr(st
, 20);
8049 // Íàñòðîéêè ñëîæíîñòè
8050 FDifficult
.load(st
);
8055 conRegVar('cheat_berserk_autoswitch', @gBerserkAutoswitch
, 'autoswitch to fist when berserk pack taken', '', true, true);
8056 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');
8057 conRegVar('player_indicator_style', @gPlayerIndicatorStyle
, 'Visual appearance of indicator', 'Visual appearance of indicator');