6 e_graphics
, g_playermodel
, g_basic
, g_textures
,
7 g_weapons
, g_phys
, g_sound
, g_saveload
, MAPSTRUCT
,
57 ANGLE_NONE
= Low(SmallInt);
59 CORPSE_STATE_REMOVEME
= 0;
60 CORPSE_STATE_NORMAL
= 1;
61 CORPSE_STATE_MESS
= 2;
63 PLAYER_RECT
: TRectWH
= (X
:15; Y
:12; Width
:34; Height
:52);
64 PLAYER_RECT_CX
= 15+(34 div 2);
65 PLAYER_RECT_CY
= 12+(52 div 2);
66 PLAYER_CORPSERECT
: TRectWH
= (X
:15; Y
:48; Width
:34; Height
:16);
69 PLAYER_HP_LIMIT
= 200;
71 PLAYER_AP_LIMIT
= 200;
74 PLAYER1_DEF_COLOR
: TRGB
= (R
:64; G
:175; B
:48);
75 PLAYER2_DEF_COLOR
: TRGB
= (R
:96; G
:96; B
:96);
91 TPlayerStatArray
= Array of TPlayerStat
;
93 TPlayerSavedState
= record
99 Ammo
: Array [A_BULLETS
..A_CELLS
] of Word;
100 MaxAmmo
: Array [A_BULLETS
..A_CELLS
] of Word;
101 Weapon
: Array [WEAPON_KASTET
..WEAPON_SUPERPULEMET
] of Boolean;
102 Rulez
: Set of R_ITEM_BACKPACK
..R_BERSERK
;
111 TPlayer
= class (TObject
)
119 FDirection
: TDirection
;
127 FMonsterKills
: Integer;
133 FCanJetpack
: Boolean;
138 FBFGFireCounter
: SmallInt;
139 FLastSpawnerUID
: Word;
143 FSpectatePlayer
: Integer;
145 FSavedState
: TPlayerSavedState
;
147 FModel
: TPlayerModel
;
150 FActionForce
: Boolean;
151 FActionChanged
: Boolean;
153 FFireAngle
: SmallInt;
155 FShellTimer
: Integer;
157 FSawSound
: TPlayableSound
;
158 FSawSoundIdle
: TPlayableSound
;
159 FSawSoundHit
: TPlayableSound
;
160 FSawSoundSelect
: TPlayableSound
;
161 FJetSoundOn
: TPlayableSound
;
162 FJetSoundOff
: TPlayableSound
;
163 FJetSoundFly
: TPlayableSound
;
167 FJustTeleported
: Boolean;
170 function CollideLevel(XInc
, YInc
: Integer): Boolean;
171 function StayOnStep(XInc
, YInc
: Integer): Boolean;
172 function HeadInLiquid(XInc
, YInc
: Integer): Boolean;
173 function BodyInLiquid(XInc
, YInc
: Integer): Boolean;
174 function BodyInAcid(XInc
, YInc
: Integer): Boolean;
175 function FullInLift(XInc
, YInc
: Integer): Integer;
176 {procedure CollideItem();}
177 procedure FlySmoke(Times
: DWORD
= 1);
178 function GetAmmoByWeapon(Weapon
: Byte): Word;
179 procedure SetAction(Action
: Byte; Force
: Boolean = False);
180 procedure OnDamage(Angle
: SmallInt); virtual;
181 function firediry(): Integer;
183 procedure Run(Direction
: TDirection
);
184 procedure NextWeapon();
185 procedure PrevWeapon();
193 FDamageBuffer
: Integer;
195 FAmmo
: Array [A_BULLETS
..A_CELLS
] of Word;
196 FMaxAmmo
: Array [A_BULLETS
..A_CELLS
] of Word;
197 FWeapon
: Array [WEAPON_KASTET
..WEAPON_SUPERPULEMET
] of Boolean;
198 FRulez
: Set of R_ITEM_BACKPACK
..R_BERSERK
;
200 FMegaRulez
: Array [MR_SUIT
..MR_MAX
] of DWORD
;
201 FReloading
: Array [WEAPON_KASTET
..WEAPON_SUPERPULEMET
] of Word;
202 FTime
: Array [T_RESPAWN
..T_FLAGCAP
] of DWORD
;
203 FKeys
: Array [KEY_LEFT
..KEY_CHAT
] of TKeyState
;
205 FPreferredTeam
: Byte;
208 FWantsInGame
: Boolean;
212 FActualModelName
: string;
218 constructor Create(); virtual;
219 destructor Destroy(); override;
220 procedure Respawn(Silent
: Boolean; Force
: Boolean = False); virtual;
221 function GetRespawnPoint(): Byte;
222 procedure PressKey(Key
: Byte; Time
: Word = 1);
223 procedure ReleaseKeys();
224 procedure SetModel(ModelName
: String);
225 procedure SetColor(Color
: TRGB
);
226 procedure SetWeapon(W
: Byte);
227 function IsKeyPressed(K
: Byte): Boolean;
228 function GetKeys(): Byte;
229 function PickItem(ItemType
: Byte; respawn
: Boolean; var remove
: Boolean): Boolean; virtual;
230 function Collide(X
, Y
: Integer; Width
, Height
: Word): Boolean; overload
;
231 function Collide(Panel
: TPanel
): Boolean; overload
;
232 function Collide(X
, Y
: Integer): Boolean; overload
;
233 procedure SetDirection(Direction
: TDirection
);
234 procedure GetSecret();
235 function TeleportTo(X
, Y
: Integer; silent
: Boolean; dir
: Byte): Boolean;
237 procedure Push(vx
, vy
: Integer);
238 procedure ChangeModel(ModelName
: String);
239 procedure SwitchTeam
;
240 procedure ChangeTeam(Team
: Byte);
242 function GetFlag(Flag
: Byte): Boolean;
243 procedure SetFlag(Flag
: Byte);
244 function DropFlag(): Boolean;
245 procedure AllRulez(Health
: Boolean);
246 procedure FragCombo();
247 procedure GiveItem(ItemType
: Byte);
248 procedure Damage(value
: Word; SpawnerUID
: Word; vx
, vy
: Integer; t
: Byte); virtual;
249 function Heal(value
: Word; Soft
: Boolean): Boolean; virtual;
250 procedure MakeBloodVector(Count
: Word; VelX
, VelY
: Integer);
251 procedure MakeBloodSimple(Count
: Word);
252 procedure Kill(KillType
: Byte; SpawnerUID
: Word; t
: Byte);
253 procedure Reset(Force
: Boolean);
254 procedure Spectate(NoMove
: Boolean = False);
255 procedure SwitchNoClip
;
256 procedure SoftReset();
257 procedure Draw(); virtual;
258 procedure DrawPain();
259 procedure DrawPickup();
260 procedure DrawRulez();
262 procedure DrawBubble();
264 procedure Update(); virtual;
265 procedure RememberState();
266 procedure RecallState();
267 procedure SaveState(var Mem
: TBinMemoryWriter
); virtual;
268 procedure LoadState(var Mem
: TBinMemoryReader
); virtual;
269 procedure PauseSounds(Enable
: Boolean);
270 procedure NetFire(Wpn
: Byte; X
, Y
, AX
, AY
: Integer; WID
: Integer = -1);
271 procedure DoLerp(Level
: Integer = 2);
272 procedure SetLerp(XTo
, YTo
: Integer);
274 procedure JetpackOff
;
276 property Name
: String read FName write FName
;
277 property Model
: TPlayerModel read FModel
;
278 property Health
: Integer read FHealth write FHealth
;
279 property Lives
: Byte read FLives write FLives
;
280 property Armor
: Integer read FArmor write FArmor
;
281 property Air
: Integer read FAir write FAir
;
282 property JetFuel
: Integer read FJetFuel write FJetFuel
;
283 property Frags
: Integer read FFrags write FFrags
;
284 property Death
: Integer read FDeath write FDeath
;
285 property Kills
: Integer read FKills write FKills
;
286 property CurrWeap
: Byte read FCurrWeap write FCurrWeap
;
287 property MonsterKills
: Integer read FMonsterKills write FMonsterKills
;
288 property Secrets
: Integer read FSecrets
;
289 property GodMode
: Boolean read FGodMode write FGodMode
;
290 property NoTarget
: Boolean read FNoTarget write FNoTarget
;
291 property NoReload
: Boolean read FNoReload write FNoReload
;
292 property Live
: Boolean read FLive write FLive
;
293 property Flag
: Byte read FFlag
;
294 property Team
: Byte read FTeam write FTeam
;
295 property Direction
: TDirection read FDirection
;
296 property GameX
: Integer read FObj
.X write FObj
.X
;
297 property GameY
: Integer read FObj
.Y write FObj
.Y
;
298 property GameVelX
: Integer read FObj
.Vel
.X write FObj
.Vel
.X
;
299 property GameVelY
: Integer read FObj
.Vel
.Y write FObj
.Vel
.Y
;
300 property GameAccelX
: Integer read FObj
.Accel
.X write FObj
.Accel
.X
;
301 property GameAccelY
: Integer read FObj
.Accel
.Y write FObj
.Accel
.Y
;
302 property Vel
: TPoint2i read FObj
.Vel
;
303 property Obj
: TObj read FObj
;
304 property IncCam
: Integer read FIncCam write FIncCam
;
305 property UID
: Word read FUID write FUID
;
306 property JustTeleported
: Boolean read FJustTeleported write FJustTeleported
;
307 property NetTime
: LongWord read FNetTime write FNetTime
;
317 WeaponPrior
: Array [WEAPON_KASTET
..WEAPON_SUPERPULEMET
] of Byte;
318 CloseWeaponPrior
: Array [WEAPON_KASTET
..WEAPON_SUPERPULEMET
] of Byte;
319 //SafeWeaponPrior: Array [WEAPON_KASTET..WEAPON_SUPERPULEMET] of Byte;
327 TBot
= class (TPlayer
)
329 FSelectedWeapon
: Byte;
332 FAIFlags
: Array of TAIFlag
;
333 FDifficult
: TDifficult
;
335 function GetRnd(a
: Byte): Boolean;
336 function GetInterval(a
: Byte; radius
: SmallInt): SmallInt;
337 function RunDirection(): TDirection
;
338 function FullInStep(XInc
, YInc
: Integer): Boolean;
339 //function NeedItem(Item: Byte): Byte;
340 procedure SelectWeapon(Dist
: Integer);
341 procedure SetAIFlag(fName
, fValue
: String20
);
342 function GetAIFlag(fName
: String20
): String20
;
343 procedure RemoveAIFlag(fName
: String20
);
344 function Healthy(): Byte;
345 procedure UpdateMove();
346 procedure UpdateCombat();
347 function KeyPressed(Key
: Word): Boolean;
348 procedure ReleaseKey(Key
: Byte);
349 function TargetOnScreen(TX
, TY
: Integer): Boolean;
350 procedure OnDamage(Angle
: SmallInt); override;
353 procedure Respawn(Silent
: Boolean; Force
: Boolean = False); override;
354 constructor Create(); override;
355 destructor Destroy(); override;
356 procedure Draw(); override;
357 function PickItem(ItemType
: Byte; force
: Boolean; var remove
: Boolean): Boolean; override;
358 function Heal(value
: Word; Soft
: Boolean): Boolean; override;
359 procedure Update(); override;
360 procedure SaveState(var Mem
: TBinMemoryWriter
); override;
361 procedure LoadState(var Mem
: TBinMemoryReader
); override;
383 TCorpse
= class (TObject
)
391 FAnimation
: TAnimation
;
392 FAnimationMask
: TAnimation
;
395 constructor Create(X
, Y
: Integer; ModelName
: String; aMess
: Boolean);
396 destructor Destroy(); override;
397 procedure Damage(Value
: Word; vx
, vy
: Integer);
400 procedure SaveState(var Mem
: TBinMemoryWriter
);
401 procedure LoadState(var Mem
: TBinMemoryReader
);
403 property Obj
: TObj read FObj
;
404 property State
: Byte read FState
;
405 property Mess
: Boolean read FMess
;
408 TTeamStat
= Array [TEAM_RED
..TEAM_BLUE
] of
414 gPlayers
: Array of TPlayer
;
415 gCorpses
: Array of TCorpse
;
416 gGibs
: Array of TGib
;
417 gShells
: Array of TShell
;
418 gTeamStat
: TTeamStat
;
419 gFly
: Boolean = False;
420 gAimLine
: Boolean = False;
421 gChatBubble
: Byte = 0;
425 MAX_RUNVEL
: Integer = 8;
426 VEL_JUMP
: Integer = 10;
427 SHELL_TIMEOUT
: Cardinal = 60000;
429 function Lerp(X
, Y
, Factor
: Integer): Integer;
431 procedure g_Gibs_SetMax(Count
: Word);
432 function g_Gibs_GetMax(): Word;
433 procedure g_Corpses_SetMax(Count
: Word);
434 function g_Corpses_GetMax(): Word;
435 procedure g_Shells_SetMax(Count
: Word);
436 function g_Shells_GetMax(): Word;
438 procedure g_Player_Init();
439 procedure g_Player_Free();
440 function g_Player_Create(ModelName
: String; Color
: TRGB
; Team
: Byte; Bot
: Boolean): Word;
441 function g_Player_CreateFromState(var Mem
: TBinMemoryReader
): Word;
442 procedure g_Player_Remove(UID
: Word);
443 procedure g_Player_ResetTeams();
444 procedure g_Player_UpdateAll();
445 procedure g_Player_DrawAll();
446 procedure g_Player_DrawDebug(p
: TPlayer
);
447 procedure g_Player_DrawHealth();
448 procedure g_Player_RememberAll();
449 procedure g_Player_ResetAll(Force
, Silent
: Boolean);
450 function g_Player_Get(UID
: Word): TPlayer
;
451 function g_Player_GetCount(): Byte;
452 function g_Player_GetStats(): TPlayerStatArray
;
453 function g_Player_ValidName(Name
: String): Boolean;
454 procedure g_Player_CreateCorpse(Player
: TPlayer
);
455 procedure g_Player_CreateGibs(fX
, fY
: Integer; ModelName
: String; fColor
: TRGB
);
456 procedure g_Player_CreateShell(fX
, fY
, dX
, dY
: Integer; T
: Byte);
457 procedure g_Player_UpdatePhysicalObjects();
458 procedure g_Player_DrawCorpses();
459 procedure g_Player_DrawShells();
460 procedure g_Player_RemoveAllCorpses();
461 procedure g_Player_Corpses_SaveState(var Mem
: TBinMemoryWriter
);
462 procedure g_Player_Corpses_LoadState(var Mem
: TBinMemoryReader
);
463 procedure g_Bot_Add(Team
, Difficult
: Byte);
464 procedure g_Bot_AddList(Team
: Byte; lname
: ShortString; num
: Integer = -1);
465 procedure g_Bot_MixNames();
466 procedure g_Bot_RemoveAll();
471 e_log
, g_map
, g_items
, g_console
, SysUtils
, g_gfx
, Math
,
472 g_options
, g_triggers
, g_menu
, MAPDEF
, g_game
,
473 WADEDITOR
, g_main
, g_monsters
, CONFIG
, g_language
, g_net
, g_netmsg
;
483 diag_precision
: Byte;
487 w_prior1
: Array [WEAPON_KASTET
..WEAPON_SUPERPULEMET
] of Byte;
488 w_prior2
: Array [WEAPON_KASTET
..WEAPON_SUPERPULEMET
] of Byte;
489 w_prior3
: Array [WEAPON_KASTET
..WEAPON_SUPERPULEMET
] of Byte;
493 TIME_RESPAWN1
= 1500;
494 TIME_RESPAWN2
= 2000;
495 TIME_RESPAWN3
= 3000;
498 JET_MAX
= 540; // ~30 sec
499 PLAYER_SUIT_TIME
= 30000;
500 PLAYER_INVUL_TIME
= 30000;
501 PLAYER_INVIS_TIME
= 35000;
502 FRAG_COMBO_TIME
= 3000;
506 ANGLE_RIGHTDOWN
= -35;
508 ANGLE_LEFTDOWN
= -145;
509 PLAYER_HEADRECT
: TRectWH
= (X
:24; Y
:12; Width
:20; Height
:12);
510 WEAPONPOINT
: Array [TDirection
] of TPoint
= ((X
:16; Y
:32), (X
:47; Y
:32));
513 BOT_UNSAFEDIST
= 128;
514 TEAMCOLOR
: Array [TEAM_RED
..TEAM_BLUE
] of TRGB
= ((R
:255; G
:0; B
:0),
516 DIFFICULT_EASY
: TDifficult
= (DiagFire
: 32; InvisFire
: 32; DiagPrecision
: 32;
517 FlyPrecision
: 32; Cover
: 32; CloseJump
: 32;
518 WeaponPrior
:(0,0,0,0,0,0,0,0,0,0); CloseWeaponPrior
:(0,0,0,0,0,0,0,0,0,0));
519 DIFFICULT_MEDIUM
: TDifficult
= (DiagFire
: 127; InvisFire
: 127; DiagPrecision
: 127;
520 FlyPrecision
: 127; Cover
: 127; CloseJump
: 127;
521 WeaponPrior
:(0,0,0,0,0,0,0,0,0,0); CloseWeaponPrior
:(0,0,0,0,0,0,0,0,0,0));
522 DIFFICULT_HARD
: TDifficult
= (DiagFire
: 255; InvisFire
: 255; DiagPrecision
: 255;
523 FlyPrecision
: 255; Cover
: 255; CloseJump
: 255;
524 WeaponPrior
:(0,0,0,0,0,0,0,0,0,0); CloseWeaponPrior
:(0,0,0,0,0,0,0,0,0,0));
525 WEAPON_PRIOR1
: Array [WEAPON_KASTET
..WEAPON_SUPERPULEMET
] of Byte =
526 (WEAPON_SUPERPULEMET
, WEAPON_SHOTGUN2
, WEAPON_SHOTGUN1
,
527 WEAPON_CHAINGUN
, WEAPON_PLASMA
, WEAPON_ROCKETLAUNCHER
,
528 WEAPON_BFG
, WEAPON_PISTOL
, WEAPON_SAW
, WEAPON_KASTET
);
529 WEAPON_PRIOR2
: Array [WEAPON_KASTET
..WEAPON_SUPERPULEMET
] of Byte =
530 (WEAPON_SUPERPULEMET
, WEAPON_BFG
, WEAPON_ROCKETLAUNCHER
,
531 WEAPON_SHOTGUN2
, WEAPON_PLASMA
, WEAPON_SHOTGUN1
,
532 WEAPON_CHAINGUN
, WEAPON_PISTOL
, WEAPON_SAW
, WEAPON_KASTET
);
533 //WEAPON_PRIOR3: Array [WEAPON_KASTET..WEAPON_SUPERPULEMET] of Byte =
534 // (WEAPON_SUPERPULEMET, WEAPON_BFG, WEAPON_PLASMA,
535 // WEAPON_SHOTGUN2, WEAPON_CHAINGUN, WEAPON_SHOTGUN1,
536 // WEAPON_SAW, WEAPON_ROCKETLAUNCHER, WEAPON_PISTOL, WEAPON_KASTET);
537 WEAPON_RELOAD
: Array [WEAPON_KASTET
..WEAPON_SUPERPULEMET
] of Byte =
538 (5, 2, 6, 18, 36, 2, 12, 2, 14, 2);
540 PLAYER_SIGNATURE
= $52594C50; // 'PLYR'
541 CORPSE_SIGNATURE
= $50524F43; // 'CORP'
543 BOTNAMES_FILENAME
= 'botnames.txt';
544 BOTLIST_FILENAME
= 'botlist.txt';
548 MaxCorpses
: Word = 20;
549 MaxShells
: Word = 300;
550 CurrentGib
: Integer = 0;
551 CurrentShell
: Integer = 0;
552 BotNames
: Array of String;
553 BotList
: Array of TBotProfile
;
555 function Lerp(X
, Y
, Factor
: Integer): Integer;
557 Result
:= X
+ ((Y
- X
) div Factor
);
560 function SameTeam(UID1
, UID2
: Word): Boolean;
564 if (UID1
> UID_MAX_PLAYER
) or (UID1
<= UID_MAX_GAME
) or
565 (UID2
> UID_MAX_PLAYER
) or (UID2
<= UID_MAX_GAME
) then Exit
;
567 if (g_Player_Get(UID1
) = nil) or (g_Player_Get(UID2
) = nil) then Exit
;
569 if ((g_Player_Get(UID1
).Team
= TEAM_NONE
) or
570 (g_Player_Get(UID2
).Team
= TEAM_NONE
)) then Exit
;
572 Result
:= g_Player_Get(UID1
).FTeam
= g_Player_Get(UID2
).FTeam
;
575 procedure g_Gibs_SetMax(Count
: Word);
578 SetLength(gGibs
, Count
);
580 if CurrentGib
>= Count
then
584 function g_Gibs_GetMax(): Word;
589 procedure g_Shells_SetMax(Count
: Word);
592 SetLength(gShells
, Count
);
594 if CurrentShell
>= Count
then
598 function g_Shells_GetMax(): Word;
604 procedure g_Corpses_SetMax(Count
: Word);
607 SetLength(gCorpses
, Count
);
610 function g_Corpses_GetMax(): Word;
612 Result
:= MaxCorpses
;
615 function g_Player_Create(ModelName
: String; Color
: TRGB
; Team
: Byte; Bot
: Boolean): Word;
625 // Åñòü ëè ìåñòî â gPlayers:
626 if gPlayers
<> nil then
627 for a
:= 0 to High(gPlayers
) do
628 if gPlayers
[a
] = nil then
634 // Íåò ìåñòà - ðàñøèðÿåì gPlayers:
637 SetLength(gPlayers
, Length(gPlayers
)+1);
641 // Ñîçäàåì îáúåêò èãðîêà:
643 gPlayers
[a
] := TBot
.Create()
645 gPlayers
[a
] := TPlayer
.Create();
648 gPlayers
[a
].FActualModelName
:= ModelName
;
649 gPlayers
[a
].SetModel(ModelName
);
651 // Íåò ìîäåëè - ñîçäàíèå íå âîçìîæíî:
652 if gPlayers
[a
].FModel
= nil then
656 g_FatalError(Format(_lc
[I_GAME_ERROR_MODEL
], [ModelName
]));
660 if not (Team
in [TEAM_RED
, TEAM_BLUE
]) then
661 if Random(2) = 0 then
665 gPlayers
[a
].FPreferredTeam
:= Team
;
667 case gGameSettings
.GameMode
of
668 GM_DM
: gPlayers
[a
].FTeam
:= TEAM_NONE
;
670 GM_CTF
: gPlayers
[a
].FTeam
:= gPlayers
[a
].FPreferredTeam
;
672 GM_COOP
: gPlayers
[a
].FTeam
:= TEAM_COOP
;
675 // Åñëè êîìàíäíàÿ èãðà - êðàñèì ìîäåëü â öâåò êîìàíäû:
676 gPlayers
[a
].FColor
:= Color
;
677 if gPlayers
[a
].FTeam
in [TEAM_RED
, TEAM_BLUE
] then
678 gPlayers
[a
].FModel
.Color
:= TEAMCOLOR
[gPlayers
[a
].FTeam
]
680 gPlayers
[a
].FModel
.Color
:= Color
;
682 gPlayers
[a
].FUID
:= g_CreateUID(UID_PLAYER
);
683 gPlayers
[a
].FLive
:= False;
685 Result
:= gPlayers
[a
].FUID
;
688 function g_Player_CreateFromState(var Mem
: TBinMemoryReader
): Word;
701 if sig
<> PLAYER_SIGNATURE
then // 'PLYR'
703 raise EBinSizeError
.Create('g_Player_CreateFromState: Wrong Player Signature');
707 Mem
.ReadBoolean(Bot
);
712 // Åñòü ëè ìåñòî â gPlayers:
713 if gPlayers
<> nil then
714 for a
:= 0 to High(gPlayers
) do
715 if gPlayers
[a
] = nil then
721 // Íåò ìåñòà - ðàñøèðÿåì gPlayers:
724 SetLength(gPlayers
, Length(gPlayers
)+1);
728 // Ñîçäàåì îáúåêò èãðîêà:
730 gPlayers
[a
] := TBot
.Create()
732 gPlayers
[a
] := TPlayer
.Create();
733 gPlayers
[a
].FIamBot
:= Bot
;
734 gPlayers
[a
].FPhysics
:= True;
737 Mem
.ReadWord(gPlayers
[a
].FUID
);
739 Mem
.ReadString(gPlayers
[a
].FName
);
741 Mem
.ReadByte(gPlayers
[a
].FTeam
);
742 gPlayers
[a
].FPreferredTeam
:= gPlayers
[a
].FTeam
;
744 Mem
.ReadBoolean(gPlayers
[a
].FLive
);
745 // Èçðàñõîäîâàë ëè âñå æèçíè:
746 Mem
.ReadBoolean(gPlayers
[a
].FNoRespawn
);
750 gPlayers
[a
].FDirection
:= D_LEFT
752 gPlayers
[a
].FDirection
:= D_RIGHT
;
754 Mem
.ReadInt(gPlayers
[a
].FHealth
);
756 Mem
.ReadByte(gPlayers
[a
].FLives
);
758 Mem
.ReadInt(gPlayers
[a
].FArmor
);
760 Mem
.ReadInt(gPlayers
[a
].FAir
);
762 Mem
.ReadInt(gPlayers
[a
].FJetFuel
);
764 Mem
.ReadInt(gPlayers
[a
].FPain
);
766 Mem
.ReadInt(gPlayers
[a
].FKills
);
768 Mem
.ReadInt(gPlayers
[a
].FMonsterKills
);
770 Mem
.ReadInt(gPlayers
[a
].FFrags
);
772 Mem
.ReadByte(gPlayers
[a
].FFragCombo
);
773 // Âðåìÿ ïîñëåäíåãî ôðàãà:
774 Mem
.ReadDWORD(gPlayers
[a
].FLastFrag
);
776 Mem
.ReadInt(gPlayers
[a
].FDeath
);
778 Mem
.ReadByte(gPlayers
[a
].FFlag
);
780 Mem
.ReadInt(gPlayers
[a
].FSecrets
);
782 Mem
.ReadByte(gPlayers
[a
].FCurrWeap
);
783 // Âðåìÿ çàðÿäêè BFG:
784 Mem
.ReadSmallInt(gPlayers
[a
].FBFGFireCounter
);
786 Mem
.ReadInt(gPlayers
[a
].FDamageBuffer
);
787 // Ïîñëåäíèé óäàðèâøèé:
788 Mem
.ReadWord(gPlayers
[a
].FLastSpawnerUID
);
789 // Òèï ïîñëåäíåãî ïîëó÷åííîãî óðîíà:
790 Mem
.ReadByte(gPlayers
[a
].FLastHit
);
792 Obj_LoadState(@gPlayers
[a
].FObj
, Mem
);
793 // Òåêóùåå êîëè÷åñòâî ïàòðîíîâ:
794 for i
:= A_BULLETS
to A_CELLS
do
795 Mem
.ReadWord(gPlayers
[a
].FAmmo
[i
]);
796 // Ìàêñèìàëüíîå êîëè÷åñòâî ïàòðîíîâ:
797 for i
:= A_BULLETS
to A_CELLS
do
798 Mem
.ReadWord(gPlayers
[a
].FMaxAmmo
[i
]);
800 for i
:= WEAPON_KASTET
to WEAPON_SUPERPULEMET
do
801 Mem
.ReadBoolean(gPlayers
[a
].FWeapon
[i
]);
802 // Âðåìÿ ïåðåçàðÿäêè îðóæèÿ:
803 for i
:= WEAPON_KASTET
to WEAPON_SUPERPULEMET
do
804 Mem
.ReadWord(gPlayers
[a
].FReloading
[i
]);
808 Include(gPlayers
[a
].FRulez
, R_ITEM_BACKPACK
);
809 // Íàëè÷èå êðàñíîãî êëþ÷à:
812 Include(gPlayers
[a
].FRulez
, R_KEY_RED
);
813 // Íàëè÷èå çåëåíîãî êëþ÷à:
816 Include(gPlayers
[a
].FRulez
, R_KEY_GREEN
);
817 // Íàëè÷èå ñèíåãî êëþ÷à:
820 Include(gPlayers
[a
].FRulez
, R_KEY_BLUE
);
824 Include(gPlayers
[a
].FRulez
, R_BERSERK
);
825 // Âðåìÿ äåéñòâèÿ ñïåöèàëüíûõ ïðåäìåòîâ:
826 for i
:= MR_SUIT
to MR_MAX
do
827 Mem
.ReadDWORD(gPlayers
[a
].FMegaRulez
[i
]);
828 // Âðåìÿ äî ïîâòîðíîãî ðåñïàóíà, ñìåíû îðóæèÿ, èñîëüçîâàíèÿ, çàõâàòà ôëàãà:
829 for i
:= T_RESPAWN
to T_FLAGCAP
do
830 Mem
.ReadDWORD(gPlayers
[a
].FTime
[i
]);
833 Mem
.ReadString(gPlayers
[a
].FActualModelName
);
835 Mem
.ReadByte(gPlayers
[a
].FColor
.R
);
836 Mem
.ReadByte(gPlayers
[a
].FColor
.G
);
837 Mem
.ReadByte(gPlayers
[a
].FColor
.B
);
838 // Îáíîâëÿåì ìîäåëü èãðîêà:
839 gPlayers
[a
].SetModel(gPlayers
[a
].FActualModelName
);
841 // Íåò ìîäåëè - ñîçäàíèå íå âîçìîæíî:
842 if gPlayers
[a
].FModel
= nil then
846 g_FatalError(Format(_lc
[I_GAME_ERROR_MODEL
], [gPlayers
[a
].FActualModelName
]));
850 // Åñëè êîìàíäíàÿ èãðà - êðàñèì ìîäåëü â öâåò êîìàíäû:
851 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
852 gPlayers
[a
].FModel
.Color
:= TEAMCOLOR
[gPlayers
[a
].FTeam
]
854 gPlayers
[a
].FModel
.Color
:= gPlayers
[a
].FColor
;
856 Result
:= gPlayers
[a
].FUID
;
859 procedure g_Player_ResetTeams();
863 if g_Game_IsClient
then
865 if gPlayers
= nil then
867 for a
:= Low(gPlayers
) to High(gPlayers
) do
868 if gPlayers
[a
] <> nil then
869 case gGameSettings
.GameMode
of
871 gPlayers
[a
].ChangeTeam(TEAM_NONE
);
873 if not (gPlayers
[a
].Team
in [TEAM_RED
, TEAM_BLUE
]) then
874 if gPlayers
[a
].FPreferredTeam
in [TEAM_RED
, TEAM_BLUE
] then
875 gPlayers
[a
].ChangeTeam(gPlayers
[a
].FPreferredTeam
)
878 gPlayers
[a
].ChangeTeam(TEAM_RED
)
880 gPlayers
[a
].ChangeTeam(TEAM_BLUE
);
883 gPlayers
[a
].ChangeTeam(TEAM_COOP
);
887 procedure g_Bot_Add(Team
, Difficult
: Byte);
890 _name
, _model
: String;
893 if not g_Game_IsServer
then Exit
;
895 // Ñïèñîê íàçâàíèé ìîäåëåé:
896 m
:= g_PlayerModel_GetNames();
901 if (gGameSettings
.GameType
= GT_SINGLE
) or (gGameSettings
.GameMode
= GM_COOP
) then
902 Team
:= TEAM_COOP
// COOP
904 if gGameSettings
.GameMode
= GM_DM
then
905 Team
:= TEAM_NONE
// DM
907 if Team
= TEAM_NONE
then // CTF / TDM
909 // Àâòîáàëàíñ êîìàíä:
913 for a
:= 0 to High(gPlayers
) do
914 if gPlayers
[a
] <> nil then
916 if gPlayers
[a
].Team
= TEAM_RED
then
919 if gPlayers
[a
].Team
= TEAM_BLUE
then
929 if Random(2) = 0 then
935 // Âûáèðàåì áîòó èìÿ:
937 if BotNames
<> nil then
938 for a
:= 0 to High(BotNames
) do
939 if g_Player_ValidName(BotNames
[a
]) then
941 _name
:= BotNames
[a
];
945 // Èìåíè íåò, çàäàåì ñëó÷àéíîå:
948 _name
:= Format('DFBOT%.2d', [Random(100)]);
949 until g_Player_ValidName(_name
);
951 // Âûáèðàåì ñëó÷àéíóþ ìîäåëü:
952 _model
:= m
[Random(Length(m
))];
955 with g_Player_Get(g_Player_Create(_model
,
956 _RGB(Min(Random(9)*32, 255),
957 Min(Random(9)*32, 255),
958 Min(Random(9)*32, 255)),
959 Team
, True)) as TBot
do
964 1: FDifficult
:= DIFFICULT_EASY
;
965 2: FDifficult
:= DIFFICULT_MEDIUM
;
966 else FDifficult
:= DIFFICULT_HARD
;
969 for a
:= WEAPON_KASTET
to WEAPON_SUPERPULEMET
do
971 FDifficult
.WeaponPrior
[a
] := WEAPON_PRIOR1
[a
];
972 FDifficult
.CloseWeaponPrior
[a
] := WEAPON_PRIOR2
[a
];
973 //FDifficult.SafeWeaponPrior[a] := WEAPON_PRIOR3[a];
976 g_Console_Add(Format(_lc
[I_PLAYER_JOIN
], [Name
]), True);
978 if g_Game_IsNet
then MH_SEND_PlayerCreate(UID
);
979 if g_Game_IsServer
and (gGameSettings
.MaxLives
> 0) then
984 procedure g_Bot_AddList(Team
: Byte; lName
: ShortString; num
: Integer = -1);
987 _name
, _model
: String;
990 if not g_Game_IsServer
then Exit
;
992 // Ñïèñîê íàçâàíèé ìîäåëåé:
993 m
:= g_PlayerModel_GetNames();
998 if (gGameSettings
.GameType
= GT_SINGLE
) or (gGameSettings
.GameMode
= GM_COOP
) then
999 Team
:= TEAM_COOP
// COOP
1001 if gGameSettings
.GameMode
= GM_DM
then
1002 Team
:= TEAM_NONE
// DM
1004 if Team
= TEAM_NONE
then
1005 Team
:= BotList
[num
].team
; // CTF / TDM
1007 // Âûáèðàåì íàñòðîéêè áîòà èç ñïèñêà ïî íîìåðó èëè èìåíè:
1008 lName
:= AnsiLowerCase(lName
);
1009 if (num
< 0) or (num
> Length(BotList
)-1) then
1011 if (num
= -1) and (lName
<> '') and (BotList
<> nil) then
1012 for a
:= 0 to High(BotList
) do
1013 if AnsiLowerCase(BotList
[a
].name
) = lName
then
1022 _name
:= BotList
[num
].name
;
1023 // Çàíÿòî - âûáèðàåì ñëó÷àéíîå:
1024 if not g_Player_ValidName(_name
) then
1026 _name
:= Format('DFBOT%.2d', [Random(100)]);
1027 until g_Player_ValidName(_name
);
1030 _model
:= BotList
[num
].model
;
1031 // Íåò òàêîé - âûáèðàåì ñëó÷àéíóþ:
1032 if not InSArray(_model
, m
) then
1033 _model
:= m
[Random(Length(m
))];
1036 with g_Player_Get(g_Player_Create(_model
, BotList
[num
].color
, Team
, True)) as TBot
do
1040 FDifficult
.DiagFire
:= BotList
[num
].diag_fire
;
1041 FDifficult
.InvisFire
:= BotList
[num
].invis_fire
;
1042 FDifficult
.DiagPrecision
:= BotList
[num
].diag_precision
;
1043 FDifficult
.FlyPrecision
:= BotList
[num
].fly_precision
;
1044 FDifficult
.Cover
:= BotList
[num
].cover
;
1045 FDifficult
.CloseJump
:= BotList
[num
].close_jump
;
1047 for a
:= WEAPON_KASTET
to WEAPON_SUPERPULEMET
do
1049 FDifficult
.WeaponPrior
[a
] := BotList
[num
].w_prior1
[a
];
1050 FDifficult
.CloseWeaponPrior
[a
] := BotList
[num
].w_prior2
[a
];
1051 //FDifficult.SafeWeaponPrior[a] := BotList[num].w_prior3[a];
1054 g_Console_Add(Format(_lc
[I_PLAYER_JOIN
], [Name
]), True);
1056 if g_Game_IsNet
then MH_SEND_PlayerCreate(UID
);
1060 procedure g_Bot_RemoveAll();
1064 if not g_Game_IsServer
then Exit
;
1065 if gPlayers
= nil then Exit
;
1067 for a
:= 0 to High(gPlayers
) do
1068 if gPlayers
[a
] <> nil then
1069 if gPlayers
[a
] is TBot
then
1071 gPlayers
[a
].Lives
:= 0;
1072 gPlayers
[a
].Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
1073 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [gPlayers
[a
].Name
]), True);
1074 g_Player_Remove(gPlayers
[a
].FUID
);
1080 procedure g_Bot_MixNames();
1085 if BotNames
<> nil then
1086 for a
:= 0 to High(BotNames
) do
1088 b
:= Random(Length(BotNames
));
1090 Botnames
[a
] := BotNames
[b
];
1095 procedure g_Player_Remove(UID
: Word);
1099 if gPlayers
= nil then Exit
;
1101 if g_Game_IsServer
and g_Game_IsNet
then
1102 MH_SEND_PlayerDelete(UID
);
1104 for i
:= 0 to High(gPlayers
) do
1105 if gPlayers
[i
] <> nil then
1106 if gPlayers
[i
].FUID
= UID
then
1108 if gPlayers
[i
] is TPlayer
then
1109 TPlayer(gPlayers
[i
]).Free()
1111 TBot(gPlayers
[i
]).Free();
1117 procedure g_Player_Init();
1127 if not FileExists(DataDir
+ BOTNAMES_FILENAME
) then
1130 // ×èòàåì âîçìîæíûå èìåíà áîòîâ èç ôàéëà:
1131 AssignFile(F
, DataDir
+ BOTNAMES_FILENAME
);
1142 SetLength(BotNames
, Length(BotNames
)+1);
1143 BotNames
[High(BotNames
)] := s
;
1151 // ×èòàåì ôàéë ñ ïàðàìåòðàìè áîòîâ:
1152 config
:= TConfig
.CreateFile(DataDir
+ BOTLIST_FILENAME
);
1156 while config
.SectionExists(IntToStr(a
)) do
1158 SetLength(BotList
, Length(BotList
)+1);
1160 with BotList
[High(BotList
)] do
1163 name
:= config
.ReadStr(IntToStr(a
), 'name', '');
1165 model
:= config
.ReadStr(IntToStr(a
), 'model', '');
1167 if config
.ReadStr(IntToStr(a
), 'team', 'red') = 'red' then
1172 sa
:= parse(config
.ReadStr(IntToStr(a
), 'color', ''));
1173 color
.R
:= StrToIntDef(sa
[0], 0);
1174 color
.G
:= StrToIntDef(sa
[1], 0);
1175 color
.B
:= StrToIntDef(sa
[2], 0);
1176 // Âåðîÿòíîñòü ñòðåëüáû ïîä óãëîì:
1177 diag_fire
:= config
.ReadInt(IntToStr(a
), 'diag_fire', 0);
1178 // Âåðîÿòíîñòü îòâåòíîãî îãíÿ ïî íåâèäèìîìó ñîïåðíèêó:
1179 invis_fire
:= config
.ReadInt(IntToStr(a
), 'invis_fire', 0);
1180 // Òî÷íîñòü ñòðåëüáû ïîä óãëîì:
1181 diag_precision
:= config
.ReadInt(IntToStr(a
), 'diag_precision', 0);
1182 // Òî÷íîñòü ñòðåëüáû â ïîëåòå:
1183 fly_precision
:= config
.ReadInt(IntToStr(a
), 'fly_precision', 0);
1184 // Òî÷íîñòü óêëîíåíèÿ îò ñíàðÿäîâ:
1185 cover
:= config
.ReadInt(IntToStr(a
), 'cover', 0);
1186 // Âåðîÿòíîñòü ïðûæêà ïðè ïðèáëèæåíèè ñîïåðíèêà:
1187 close_jump
:= config
.ReadInt(IntToStr(a
), 'close_jump', 0);
1188 // Ïðèîðèòåòû îðóæèÿ äëÿ äàëüíåãî áîÿ:
1189 sa
:= parse(config
.ReadStr(IntToStr(a
), 'w_prior1', ''));
1190 if Length(sa
) = 10 then
1192 w_prior1
[b
] := EnsureRange(StrToInt(sa
[b
]), 0, 9);
1193 // Ïðèîðèòåòû îðóæèÿ äëÿ áëèæíåãî áîÿ:
1194 sa
:= parse(config
.ReadStr(IntToStr(a
), 'w_prior2', ''));
1195 if Length(sa
) = 10 then
1197 w_prior2
[b
] := EnsureRange(StrToInt(sa
[b
]), 0, 9);
1199 {sa := parse(config.ReadStr(IntToStr(a), 'w_prior3', ''));
1200 if Length(sa) = 10 then
1202 w_prior3[b] := EnsureRange(StrToInt(sa[b]), 0, 9);}
1211 procedure g_Player_Free();
1215 if gPlayers
<> nil then
1217 for i
:= 0 to High(gPlayers
) do
1218 if gPlayers
[i
] <> nil then
1220 if gPlayers
[i
] is TPlayer
then
1221 TPlayer(gPlayers
[i
]).Free()
1223 TBot(gPlayers
[i
]).Free();
1234 procedure g_Player_UpdateAll();
1238 if gPlayers
= nil then Exit
;
1240 for i
:= 0 to High(gPlayers
) do
1241 if gPlayers
[i
] <> nil then
1242 if gPlayers
[i
] is TPlayer
then gPlayers
[i
].Update()
1243 else TBot(gPlayers
[i
]).Update();
1246 procedure g_Player_DrawAll();
1250 if gPlayers
= nil then Exit
;
1252 for i
:= 0 to High(gPlayers
) do
1253 if gPlayers
[i
] <> nil then
1254 if gPlayers
[i
] is TPlayer
then gPlayers
[i
].Draw()
1255 else TBot(gPlayers
[i
]).Draw();
1258 procedure g_Player_DrawDebug(p
: TPlayer
);
1262 if p
= nil then Exit
;
1263 if (@p
.FObj
) = nil then Exit
;
1265 e_TextureFontGetSize(gStdFont
, fW
, fH
);
1267 e_TextureFontPrint(0, 0 , 'Pos X: ' + IntToStr(p
.FObj
.X
), gStdFont
);
1268 e_TextureFontPrint(0, fH
, 'Pos Y: ' + IntToStr(p
.FObj
.Y
), gStdFont
);
1269 e_TextureFontPrint(0, fH
* 2, 'Vel X: ' + IntToStr(p
.FObj
.Vel
.X
), gStdFont
);
1270 e_TextureFontPrint(0, fH
* 3, 'Vel Y: ' + IntToStr(p
.FObj
.Vel
.Y
), gStdFont
);
1271 e_TextureFontPrint(0, fH
* 4, 'Acc X: ' + IntToStr(p
.FObj
.Accel
.X
), gStdFont
);
1272 e_TextureFontPrint(0, fH
* 5, 'Acc Y: ' + IntToStr(p
.FObj
.Accel
.Y
), gStdFont
);
1275 procedure g_Player_DrawHealth();
1280 if gPlayers
= nil then Exit
;
1281 e_TextureFontGetSize(gStdFont
, fW
, fH
);
1283 for i
:= 0 to High(gPlayers
) do
1284 if gPlayers
[i
] <> nil then
1286 e_TextureFontPrint(gPlayers
[i
].FObj
.X
+ gPlayers
[i
].FObj
.Rect
.X
,
1287 gPlayers
[i
].FObj
.Y
+ gPlayers
[i
].FObj
.Rect
.Y
+ gPlayers
[i
].FObj
.Rect
.Height
- fH
* 2,
1288 IntToStr(gPlayers
[i
].FHealth
), gStdFont
);
1289 e_TextureFontPrint(gPlayers
[i
].FObj
.X
+ gPlayers
[i
].FObj
.Rect
.X
,
1290 gPlayers
[i
].FObj
.Y
+ gPlayers
[i
].FObj
.Rect
.Y
+ gPlayers
[i
].FObj
.Rect
.Height
- fH
,
1291 IntToStr(gPlayers
[i
].FArmor
), gStdFont
);
1295 function g_Player_Get(UID
: Word): TPlayer
;
1301 if gPlayers
= nil then
1304 for a
:= 0 to High(gPlayers
) do
1305 if gPlayers
[a
] <> nil then
1306 if gPlayers
[a
].FUID
= UID
then
1308 Result
:= gPlayers
[a
];
1313 function g_Player_GetCount(): Byte;
1319 if gPlayers
= nil then
1322 for a
:= 0 to High(gPlayers
) do
1323 if gPlayers
[a
] <> nil then
1324 Result
:= Result
+ 1;
1327 function g_Player_GetStats(): TPlayerStatArray
;
1333 if gPlayers
= nil then Exit
;
1335 for a
:= 0 to High(gPlayers
) do
1336 if gPlayers
[a
] <> nil then
1338 SetLength(Result
, Length(Result
)+1);
1339 with Result
[High(Result
)] do
1341 Ping
:= gPlayers
[a
].FPing
;
1342 Loss
:= gPlayers
[a
].FLoss
;
1343 Name
:= gPlayers
[a
].FName
;
1344 Team
:= gPlayers
[a
].FTeam
;
1345 Frags
:= gPlayers
[a
].FFrags
;
1346 Deaths
:= gPlayers
[a
].FDeath
;
1347 Kills
:= gPlayers
[a
].FKills
;
1348 Color
:= gPlayers
[a
].FModel
.Color
;
1349 Lives
:= gPlayers
[a
].FLives
;
1350 Spectator
:= gPlayers
[a
].FSpectator
;
1355 procedure g_Player_RememberAll
;
1359 for i
:= Low(gPlayers
) to High(gPlayers
) do
1360 if (gPlayers
[i
] <> nil) and gPlayers
[i
].Live
then
1361 gPlayers
[i
].RememberState
;
1364 procedure g_Player_ResetAll(Force
, Silent
: Boolean);
1368 gTeamStat
[TEAM_RED
].Goals
:= 0;
1369 gTeamStat
[TEAM_BLUE
].Goals
:= 0;
1371 if gPlayers
<> nil then
1372 for i
:= 0 to High(gPlayers
) do
1373 if gPlayers
[i
] <> nil then
1375 gPlayers
[i
].Reset(Force
);
1377 if gPlayers
[i
] is TPlayer
then
1379 if (not gPlayers
[i
].FSpectator
) or gPlayers
[i
].FWantsInGame
then
1380 gPlayers
[i
].Respawn(Silent
)
1382 gPlayers
[i
].Spectate();
1385 TBot(gPlayers
[i
]).Respawn(Silent
);
1389 procedure g_Player_CreateCorpse(Player
: TPlayer
);
1396 if Player
.FObj
.Y
>= gMapInfo
.Height
+128 then
1401 if (FHealth
>= -50) or (gGibsCount
= 0) then
1403 if (gCorpses
= nil) or (Length(gCorpses
) = 0) then
1407 for find_id
:= 0 to High(gCorpses
) do
1408 if gCorpses
[find_id
] = nil then
1415 find_id
:= Random(Length(gCorpses
));
1417 gCorpses
[find_id
] := TCorpse
.Create(FObj
.X
, FObj
.Y
, FModel
.Name
, FHealth
< -20);
1418 gCorpses
[find_id
].FColor
:= FModel
.Color
;
1419 gCorpses
[find_id
].FObj
.Vel
:= FObj
.Vel
;
1420 gCorpses
[find_id
].FObj
.Accel
:= FObj
.Accel
;
1423 g_Player_CreateGibs(FObj
.X
+ PLAYER_RECT_CX
,
1424 FObj
.Y
+ PLAYER_RECT_CY
,
1425 FModel
.Name
, FModel
.Color
);
1429 procedure g_Player_CreateShell(fX
, fY
, dX
, dY
: Integer; T
: Byte);
1433 if (gShells
= nil) or (Length(gShells
) = 0) then
1436 with gShells
[CurrentShell
] do
1442 if T
= SHELL_BULLET
then
1444 if g_Texture_Get('TEXTURE_SHELL_BULLET', SID
) then
1448 Obj
.Rect
.Width
:= 4;
1449 Obj
.Rect
.Height
:= 2;
1453 if g_Texture_Get('TEXTURE_SHELL_SHELL', SID
) then
1457 Obj
.Rect
.Width
:= 7;
1458 Obj
.Rect
.Height
:= 3;
1464 g_Obj_Push(@Obj
, dX
+ Random(4)-Random(4), dY
-Random(4));
1465 RAngle
:= Random(360);
1466 Timeout
:= gTime
+ SHELL_TIMEOUT
;
1468 if CurrentShell
>= High(gShells
) then
1475 procedure g_Player_CreateGibs(fX
, fY
: Integer; ModelName
: string; fColor
: TRGB
);
1478 GibsArray
: TGibsArray
;
1480 if (gGibs
= nil) or (Length(gGibs
) = 0) then
1482 if not g_PlayerModel_GetGibs(ModelName
, GibsArray
) then
1485 for a
:= 0 to High(GibsArray
) do
1486 with gGibs
[CurrentGib
] do
1489 ID
:= GibsArray
[a
].ID
;
1490 MaskID
:= GibsArray
[a
].MaskID
;
1493 Obj
.Rect
:= GibsArray
[a
].Rect
;
1494 Obj
.X
:= fX
-GibsArray
[a
].Rect
.X
-(GibsArray
[a
].Rect
.Width
div 2);
1495 Obj
.Y
:= fY
-GibsArray
[a
].Rect
.Y
-(GibsArray
[a
].Rect
.Height
div 2);
1496 g_Obj_PushA(@Obj
, 25 + Random(10), Random(361));
1497 RAngle
:= Random(360);
1499 if gBloodCount
> 0 then
1500 g_GFX_Blood(fX
, fY
, 16*gBloodCount
+Random(5*gBloodCount
), -16+Random(33), -16+Random(33),
1501 Random(48), Random(48), 150, 0, 0);
1503 if CurrentGib
>= High(gGibs
) then
1510 procedure g_Player_UpdatePhysicalObjects();
1516 procedure ShellSound_Bounce(X
, Y
: Integer; T
: Byte);
1521 if T
= SHELL_BULLET
then
1522 g_Sound_PlayExAt('SOUND_PLAYER_CASING' + IntToStr(k
), X
, Y
)
1524 g_Sound_PlayExAt('SOUND_PLAYER_SHELL' + IntToStr(k
), X
, Y
);
1529 if gGibs
<> nil then
1530 for i
:= 0 to High(gGibs
) do
1531 if gGibs
[i
].Live
then
1535 mr
:= g_Obj_Move(@Obj
, True, False, True);
1537 if WordBool(mr
and MOVE_FALLOUT
) then
1543 // Îòëåòàåò îò óäàðà î ñòåíó/ïîòîëîê/ïîë:
1544 if WordBool(mr
and MOVE_HITWALL
) then
1545 Obj
.Vel
.X
:= -(vel
.X
div 2);
1546 if WordBool(mr
and (MOVE_HITCEIL
or MOVE_HITLAND
)) then
1547 Obj
.Vel
.Y
:= -(vel
.Y
div 2);
1549 if (Obj
.Vel
.X
>= 0) then
1551 RAngle
:= RAngle
+ Abs(Obj
.Vel
.X
)*6 + Abs(Obj
.Vel
.Y
);
1552 if RAngle
>= 360 then
1553 RAngle
:= RAngle
mod 360;
1554 end else begin // Counter-clockwise
1555 RAngle
:= RAngle
- Abs(Obj
.Vel
.X
)*6 - Abs(Obj
.Vel
.Y
);
1557 RAngle
:= (360 - (Abs(RAngle
) mod 360)) mod 360;
1560 // Ñîïðîòèâëåíèå âîçäóõà äëÿ êóñêà òðóïà:
1561 if gTime
mod (GAME_TICK
*3) = 0 then
1562 Obj
.Vel
.X
:= z_dec(Obj
.Vel
.X
, 1);
1566 if gCorpses
<> nil then
1567 for i
:= 0 to High(gCorpses
) do
1568 if gCorpses
[i
] <> nil then
1569 if gCorpses
[i
].State
= CORPSE_STATE_REMOVEME
then
1575 gCorpses
[i
].Update();
1578 if gShells
<> nil then
1579 for i
:= 0 to High(gShells
) do
1580 if gShells
[i
].Live
then
1584 mr
:= g_Obj_Move(@Obj
, True, False, True);
1586 if WordBool(mr
and MOVE_FALLOUT
) or (gShells
[i
].Timeout
< gTime
) then
1592 // Îòëåòàåò îò óäàðà î ñòåíó/ïîòîëîê/ïîë:
1593 if WordBool(mr
and MOVE_HITWALL
) then
1595 Obj
.Vel
.X
:= -(vel
.X
div 2);
1596 if not WordBool(mr
and MOVE_INWATER
) then
1597 ShellSound_Bounce(Obj
.X
, Obj
.Y
, SType
);
1599 if WordBool(mr
and (MOVE_HITCEIL
or MOVE_HITLAND
)) then
1601 Obj
.Vel
.Y
:= -(vel
.Y
div 2);
1602 if Obj
.Vel
.X
<> 0 then Obj
.Vel
.X
:= Obj
.Vel
.X
div 2;
1603 if (Obj
.Vel
.X
= 0) and (Obj
.Vel
.Y
= 0) then
1605 if RAngle
mod 90 <> 0 then
1606 RAngle
:= (RAngle
div 90) * 90;
1608 else if not WordBool(mr
and MOVE_INWATER
) then
1609 ShellSound_Bounce(Obj
.X
, Obj
.Y
, SType
);
1612 if (Obj
.Vel
.X
>= 0) then
1614 RAngle
:= RAngle
+ Abs(Obj
.Vel
.X
)*8 + Abs(Obj
.Vel
.Y
);
1615 if RAngle
>= 360 then
1616 RAngle
:= RAngle
mod 360;
1617 end else begin // Counter-clockwise
1618 RAngle
:= RAngle
- Abs(Obj
.Vel
.X
)*8 - Abs(Obj
.Vel
.Y
);
1620 RAngle
:= (360 - (Abs(RAngle
) mod 360)) mod 360;
1625 procedure g_Player_DrawCorpses();
1630 if gGibs
<> nil then
1631 for i
:= 0 to High(gGibs
) do
1632 if gGibs
[i
].Live
then
1635 if not g_Obj_Collide(sX
, sY
, sWidth
, sHeight
, @Obj
) then
1638 a
.X
:= Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2);
1639 a
.y
:= Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2);
1641 e_DrawAdv(ID
, Obj
.X
, Obj
.Y
, 0, True, False, RAngle
, @a
, M_NONE
);
1644 e_DrawAdv(MaskID
, Obj
.X
, Obj
.Y
, 0, True, False, RAngle
, @a
, M_NONE
);
1650 if gCorpses
<> nil then
1651 for i
:= 0 to High(gCorpses
) do
1652 if gCorpses
[i
] <> nil then
1656 procedure g_Player_DrawShells();
1661 if gShells
<> nil then
1662 for i
:= 0 to High(gShells
) do
1663 if gShells
[i
].Live
then
1666 if not g_Obj_Collide(sX
, sY
, sWidth
, sHeight
, @Obj
) then
1672 e_DrawAdv(SpriteID
, Obj
.X
, Obj
.Y
, 0, True, False, RAngle
, @a
, M_NONE
);
1676 procedure g_Player_RemoveAllCorpses();
1682 SetLength(gGibs
, MaxGibs
);
1683 SetLength(gShells
, MaxGibs
);
1687 if gCorpses
<> nil then
1688 for i
:= 0 to High(gCorpses
) do
1692 SetLength(gCorpses
, MaxCorpses
);
1695 procedure g_Player_Corpses_SaveState(var Mem
: TBinMemoryWriter
);
1700 // Ñ÷èòàåì êîëè÷åñòâî ñóùåñòâóþùèõ òðóïîâ:
1702 if gCorpses
<> nil then
1703 for i
:= 0 to High(gCorpses
) do
1704 if gCorpses
[i
] <> nil then
1707 Mem
:= TBinMemoryWriter
.Create((count
+1) * 128);
1709 // Êîëè÷åñòâî òðóïîâ:
1710 Mem
.WriteInt(count
);
1716 for i
:= 0 to High(gCorpses
) do
1717 if gCorpses
[i
] <> nil then
1720 Mem
.WriteString(gCorpses
[i
].FModelName
);
1722 b
:= gCorpses
[i
].Mess
;
1723 Mem
.WriteBoolean(b
);
1724 // Ñîõðàíÿåì äàííûå òðóïà:
1725 gCorpses
[i
].SaveState(Mem
);
1729 procedure g_Player_Corpses_LoadState(var Mem
: TBinMemoryReader
);
1738 g_Player_RemoveAllCorpses();
1740 // Êîëè÷åñòâî òðóïîâ:
1743 if count
> Length(gCorpses
) then
1745 raise EBinSizeError
.Create('g_Player_Corpses_LoadState: Too Many Corpses');
1752 for i
:= 0 to count
-1 do
1755 Mem
.ReadString(str
);
1759 gCorpses
[i
] := TCorpse
.Create(0, 0, str
, b
);
1760 // Çàãðóæàåì äàííûå òðóïà:
1761 gCorpses
[i
].LoadState(Mem
);
1767 procedure TPlayer
.BFGHit();
1769 g_Weapon_BFGHit(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
1770 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2));
1771 if g_Game_IsServer
and g_Game_IsNet
then
1772 MH_SEND_Effect(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
1773 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2),
1777 procedure TPlayer
.ChangeModel(ModelName
: string);
1779 Model
: TPlayerModel
;
1781 Model
:= g_PlayerModel_Get(ModelName
);
1782 if Model
= nil then Exit
;
1788 procedure TPlayer
.SetModel(ModelName
: string);
1792 m
:= g_PlayerModel_Get(ModelName
);
1795 g_SimpleError(Format(_lc
[I_GAME_ERROR_MODEL_FALLBACK
], [ModelName
]));
1796 m
:= g_PlayerModel_Get('doomer');
1799 g_FatalError(Format(_lc
[I_GAME_ERROR_MODEL
], ['doomer']));
1804 if FModel
<> nil then
1809 if not (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then
1810 FModel
.Color
:= FColor
1812 FModel
.Color
:= TEAMCOLOR
[FTeam
];
1813 FModel
.SetWeapon(FCurrWeap
);
1814 FModel
.SetFlag(FFlag
);
1815 SetDirection(FDirection
);
1818 procedure TPlayer
.SetColor(Color
: TRGB
);
1821 if not (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then
1822 if FModel
<> nil then FModel
.Color
:= Color
;
1825 procedure TPlayer
.SwitchTeam
;
1827 if g_Game_IsClient
then
1829 if not (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then Exit
;
1831 if gGameOn
and FLive
then
1832 Kill(K_SIMPLEKILL
, FUID
, HIT_SELF
);
1834 if FTeam
= TEAM_RED
then
1836 ChangeTeam(TEAM_BLUE
);
1837 g_Console_Add(Format(_lc
[I_PLAYER_CHTEAM_BLUE
], [FName
]), True);
1838 if g_Game_IsNet
then
1839 MH_SEND_GameEvent(NET_EV_CHANGE_TEAM
, TEAM_BLUE
, FName
);
1843 ChangeTeam(TEAM_RED
);
1844 g_Console_Add(Format(_lc
[I_PLAYER_CHTEAM_RED
], [FName
]), True);
1845 if g_Game_IsNet
then
1846 MH_SEND_GameEvent(NET_EV_CHANGE_TEAM
, TEAM_RED
, FName
);
1848 FPreferredTeam
:= FTeam
;
1851 procedure TPlayer
.ChangeTeam(Team
: Byte);
1858 TEAM_RED
, TEAM_BLUE
:
1859 FModel
.Color
:= TEAMCOLOR
[Team
];
1861 FModel
.Color
:= FColor
;
1863 if (FTeam
<> OldTeam
) and g_Game_IsNet
and g_Game_IsServer
then
1864 MH_SEND_PlayerStats(FUID
);
1868 procedure TPlayer.CollideItem();
1873 if gItems = nil then Exit;
1874 if not FLive then Exit;
1876 for i := 0 to High(gItems) do
1879 if (ItemType <> ITEM_NONE) and Live then
1880 if g_Obj_Collide(FObj.X+PLAYER_RECT.X, FObj.Y+PLAYER_RECT.Y, PLAYER_RECT.Width,
1881 PLAYER_RECT.Height, @Obj) then
1883 if not PickItem(ItemType, gItems[i].Respawnable, r) then Continue;
1885 if ItemType in [ITEM_SPHERE_BLUE, ITEM_SPHERE_WHITE, ITEM_INVUL] then
1886 g_Sound_PlayExAt('SOUND_ITEM_GETRULEZ', FObj.X, FObj.Y)
1887 else if ItemType in [ITEM_MEDKIT_SMALL, ITEM_MEDKIT_LARGE, ITEM_MEDKIT_BLACK] then
1888 g_Sound_PlayExAt('SOUND_ITEM_GETMED', FObj.X, FObj.Y)
1889 else g_Sound_PlayExAt('SOUND_ITEM_GETITEM', FObj.X, FObj.Y);
1891 // Íàäî óáðàòü ñ êàðòû, åñëè ýòî íå êëþ÷, êîòîðûì íóæíî ïîäåëèòñÿ ñ äðóãèì èãðîêîì:
1892 if r and not ((ItemType in [ITEM_KEY_RED, ITEM_KEY_GREEN, ITEM_KEY_BLUE]) and
1893 (gGameSettings.GameType = GT_SINGLE) and
1894 (g_Player_GetCount() > 1)) then
1895 if not Respawnable then g_Items_Remove(i) else g_Items_Pick(i);
1901 function TPlayer
.CollideLevel(XInc
, YInc
: Integer): Boolean;
1903 Result
:= g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
,
1904 PLAYER_RECT
.Width
, PLAYER_RECT
.Height
, PANEL_WALL
,
1908 constructor TPlayer
.Create();
1914 FSawSound
:= TPlayableSound
.Create();
1915 FSawSoundIdle
:= TPlayableSound
.Create();
1916 FSawSoundHit
:= TPlayableSound
.Create();
1917 FSawSoundSelect
:= TPlayableSound
.Create();
1918 FJetSoundFly
:= TPlayableSound
.Create();
1919 FJetSoundOn
:= TPlayableSound
.Create();
1920 FJetSoundOff
:= TPlayableSound
.Create();
1922 FSawSound
.SetByName('SOUND_WEAPON_FIRESAW');
1923 FSawSoundIdle
.SetByName('SOUND_WEAPON_IDLESAW');
1924 FSawSoundHit
.SetByName('SOUND_WEAPON_HITSAW');
1925 FSawSoundSelect
.SetByName('SOUND_WEAPON_SELECTSAW');
1926 FJetSoundFly
.SetByName('SOUND_PLAYER_JETFLY');
1927 FJetSoundOn
.SetByName('SOUND_PLAYER_JETON');
1928 FJetSoundOff
.SetByName('SOUND_PLAYER_JETOFF');
1930 FSpectatePlayer
:= -1;
1934 FSavedState
.WaitRecall
:= False;
1937 FActualModelName
:= 'doomer';
1940 FObj
.Rect
:= PLAYER_RECT
;
1942 FBFGFireCounter
:= -1;
1943 FJustTeleported
:= False;
1947 procedure TPlayer
.Damage(value
: Word; SpawnerUID
: Word; vx
, vy
: Integer; t
: Byte);
1951 if (not g_Game_IsClient
) and (not FLive
) then
1956 // Íåóÿçâèìîñòü íå ñïàñàåò îò ëîâóøåê:
1957 if ((t
= HIT_TRAP
) or (t
= HIT_SELF
)) and (not FGodMode
) then
1959 if not g_Game_IsClient
then
1962 if t
= HIT_TRAP
then
1964 // Ëîâóøêà óáèâàåò ñðàçó:
1966 Kill(K_EXTRAHARDKILL
, SpawnerUID
, t
);
1968 if t
= HIT_SELF
then
1972 Kill(K_SIMPLEKILL
, SpawnerUID
, t
);
1975 // Îáíóëèòü äåéñòâèÿ ïðèìî÷åê, ÷òîáû ôîí ïðîïàë
1976 FMegaRulez
[MR_SUIT
] := 0;
1977 FMegaRulez
[MR_INVUL
] := 0;
1978 FMegaRulez
[MR_INVIS
] := 0;
1982 // Íî îò îñòàëüíîãî ñïàñàåò:
1983 if FMegaRulez
[MR_INVUL
] >= gTime
then
1990 // Åñëè åñòü óðîí ñâîèì, èëè ðàíèë ñàì ñåáÿ, èëè òåáÿ ðàíèë ïðîòèâíèê:
1991 if LongBool(gGameSettings
.Options
and GAME_OPTION_TEAMDAMAGE
) or
1992 (SpawnerUID
= FUID
) or
1993 (not SameTeam(FUID
, SpawnerUID
)) then
1995 FLastSpawnerUID
:= SpawnerUID
;
1997 // Êðîâü (ïóçûðüêè, åñëè â âîäå):
1998 if gBloodCount
> 0 then
2000 c
:= Min(value
, 200)*gBloodCount
+ Random(Min(value
, 200) div 2);
2001 if value
div 4 <= c
then
2002 c
:= c
- (value
div 4)
2006 if (t
= HIT_SOME
) and (vx
= 0) and (vy
= 0) then
2010 HIT_TRAP
, HIT_ACID
, HIT_FLAME
, HIT_SELF
: MakeBloodSimple(c
);
2011 HIT_BFG
, HIT_ROCKET
, HIT_SOME
: MakeBloodVector(c
, vx
, vy
);
2014 if t
= HIT_WATER
then
2015 g_GFX_Bubbles(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2),
2016 FObj
.Y
+PLAYER_RECT
.Y
-4, value
div 2, 8, 4);
2021 Inc(FDamageBuffer
, value
);
2025 FPain
:= FPain
+ value
;
2028 if g_Game_IsServer
and g_Game_IsNet
then
2030 MH_SEND_PlayerDamage(FUID
, t
, SpawnerUID
, value
, vx
, vy
);
2031 MH_SEND_PlayerStats(FUID
);
2032 MH_SEND_PlayerPos(False, FUID
);
2036 function TPlayer
.Heal(value
: Word; Soft
: Boolean): Boolean;
2039 if g_Game_IsClient
then
2044 if Soft
and (FHealth
< PLAYER_HP_SOFT
) then
2046 IncMax(FHealth
, value
, PLAYER_HP_SOFT
);
2049 if (not Soft
) and (FHealth
< PLAYER_HP_LIMIT
) then
2051 IncMax(FHealth
, value
, PLAYER_HP_LIMIT
);
2055 if Result
and g_Game_IsServer
and g_Game_IsNet
then
2056 MH_SEND_PlayerStats(FUID
);
2059 destructor TPlayer
.Destroy();
2061 if (gPlayer1
<> nil) and (gPlayer1
.FUID
= FUID
) then
2063 if (gPlayer2
<> nil) and (gPlayer2
.FUID
= FUID
) then
2067 FSawSoundIdle
.Free();
2068 FSawSoundHit
.Free();
2069 FJetSoundFly
.Free();
2071 FJetSoundOff
.Free();
2077 procedure TPlayer
.DrawBubble();
2079 bubX
, bubY
: Integer;
2082 Rw
, Gw
, Bw
: SmallInt;
2085 bubX
:= FObj
.X
+FObj
.Rect
.X
+ IfThen(FDirection
= D_LEFT
, -4, 18);
2086 bubY
:= FObj
.Y
+FObj
.Rect
.Y
- 18;
2094 1: // simple textual non-bubble
2096 bubX
:= FObj
.X
+FObj
.Rect
.X
- 11;
2097 bubY
:= FObj
.Y
+FObj
.Rect
.Y
- 17;
2098 e_TextureFontPrint(bubX
, bubY
, '[...]', gStdFont
);
2101 2: // advanced pixel-perfect bubble
2103 if FTeam
= TEAM_RED
then
2106 if FTeam
= TEAM_BLUE
then
2109 3: // colored bubble
2111 Rb
:= FModel
.Color
.R
;
2112 Gb
:= FModel
.Color
.G
;
2113 Bb
:= FModel
.Color
.B
;
2114 Rw
:= Min(Rb
* 2 + 64, 255);
2115 Gw
:= Min(Gb
* 2 + 64, 255);
2116 Bw
:= Min(Bb
* 2 + 64, 255);
2117 if (Abs(Rw
- Rb
) < 32)
2118 or (Abs(Gw
- Gb
) < 32)
2119 or (Abs(Bw
- Bb
) < 32) then
2121 Rb
:= Max(Rw
div 2 - 16, 0);
2122 Gb
:= Max(Gw
div 2 - 16, 0);
2123 Bb
:= Max(Bw
div 2 - 16, 0);
2126 4: // custom textured bubble
2128 if g_Texture_Get('TEXTURE_PLAYER_TALKBUBBLE', ID
) then
2129 if FDirection
= D_RIGHT
then
2130 e_Draw(ID
, bubX
- 6, bubY
- 7, 0, True, False)
2132 e_Draw(ID
, bubX
- 6, bubY
- 7, 0, True, False, M_HORIZONTAL
);
2138 e_DrawQuad(bubX
+ 1, bubY
, bubX
+ 18, bubY
+ 13, Rb
, Gb
, Bb
);
2139 e_DrawQuad(bubX
, bubY
+ 1, bubX
+ 19, bubY
+ 12, Rb
, Gb
, Bb
);
2141 e_DrawFillQuad(bubX
+ 1, bubY
+ 1, bubX
+ 18, bubY
+ 12, Rw
, Gw
, Bw
, 0);
2144 Dot
:= IfThen(FDirection
= D_LEFT
, 14, 5);
2145 e_DrawLine(1, bubX
+ Dot
, bubY
+ 14, bubX
+ Dot
, bubY
+ 16, Rb
, Gb
, Bb
);
2146 e_DrawLine(1, bubX
+ IfThen(FDirection
= D_LEFT
, Dot
- 1, Dot
+ 1), bubY
+ 13, bubX
+ IfThen(FDirection
= D_LEFT
, Dot
- 1, Dot
+ 1), bubY
+ 15, Rw
, Gw
, Bw
);
2147 e_DrawLine(1, bubX
+ IfThen(FDirection
= D_LEFT
, Dot
- 2, Dot
+ 2), bubY
+ 13, bubX
+ IfThen(FDirection
= D_LEFT
, Dot
- 2, Dot
+ 2), bubY
+ 14, Rw
, Gw
, Bw
);
2148 e_DrawLine(1, bubX
+ IfThen(FDirection
= D_LEFT
, Dot
- 3, Dot
+ 3), bubY
+ 13, bubX
+ IfThen(FDirection
= D_LEFT
, Dot
- 3, Dot
+ 3), bubY
+ 13, Rw
, Gw
, Bw
);
2149 e_DrawLine(1, bubX
+ IfThen(FDirection
= D_LEFT
, Dot
- 3, Dot
+ 3), bubY
+ 14, bubX
+ IfThen(FDirection
= D_LEFT
, Dot
- 1, Dot
+ 1), bubY
+ 16, Rb
, Gb
, Bb
);
2153 e_DrawFillQuad(bubX
+ Dot
, bubY
+ 8, bubX
+ Dot
+ 1, bubY
+ 9, Rb
, Gb
, Bb
, 0);
2154 e_DrawFillQuad(bubX
+ Dot
+ 3, bubY
+ 8, bubX
+ Dot
+ 4, bubY
+ 9, Rb
, Gb
, Bb
, 0);
2155 e_DrawFillQuad(bubX
+ Dot
+ 6, bubY
+ 8, bubX
+ Dot
+ 7, bubY
+ 9, Rb
, Gb
, Bb
, 0);
2158 procedure TPlayer
.Draw();
2165 if (FMegaRulez
[MR_INVUL
] > gTime
) and (gPlayerDrawn
<> Self
) then
2166 if g_Texture_Get('TEXTURE_PLAYER_INVULPENTA', ID
) then
2168 e_GetTextureSize(ID
, @w
, @h
);
2169 if FDirection
= D_LEFT
then
2170 e_Draw(ID
, FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2)-(w
div 2)+4,
2171 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2)-(h
div 2)-7, 0, True, False)
2173 e_Draw(ID
, FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2)-(w
div 2)-2,
2174 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2)-(h
div 2)-7, 0, True, False);
2177 if FMegaRulez
[MR_INVIS
] > gTime
then
2179 if (gPlayerDrawn
<> nil) and ((Self
= gPlayerDrawn
) or
2180 ((FTeam
= gPlayerDrawn
.Team
) and (gGameSettings
.GameMode
<> GM_DM
))) then
2181 FModel
.Draw(FObj
.X
, FObj
.Y
, 200)
2183 FModel
.Draw(FObj
.X
, FObj
.Y
, 254);
2186 FModel
.Draw(FObj
.X
, FObj
.Y
);
2189 if g_debug_Frames
then
2191 e_DrawQuad(FObj
.X
+FObj
.Rect
.X
,
2193 FObj
.X
+FObj
.Rect
.X
+FObj
.Rect
.Width
-1,
2194 FObj
.Y
+FObj
.Rect
.Y
+FObj
.Rect
.Height
-1,
2198 if (gChatBubble
> 0) and (FKeys
[KEY_CHAT
].Pressed
) and not FGhost
then
2200 // e_DrawPoint(5, 335, 288, 255, 0, 0); // DL, UR, DL, UR
2201 if gAimLine
and Live
and
2202 ((Self
= gPlayer1
) or (Self
= gPlayer2
)) then
2206 procedure TPlayer
.DrawAim();
2208 wx
, wy
, xx
, yy
: Integer;
2212 wx
:= FObj
.X
+ WEAPONPOINT
[FDirection
].X
+ IfThen(FDirection
= D_LEFT
, 7, -7);
2213 wy
:= FObj
.Y
+ WEAPONPOINT
[FDirection
].Y
;
2222 1: begin // Chainsaw
2229 if angle
= ANGLE_RIGHTUP
then Dec(angle
, 2);
2230 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 4);
2231 if angle
= ANGLE_LEFTUP
then Inc(angle
, 2);
2232 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 4);
2237 if angle
= ANGLE_RIGHTUP
then Dec(angle
, 2);
2238 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 4);
2239 if angle
= ANGLE_LEFTUP
then Inc(angle
, 2);
2240 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 4);
2242 4: begin // Double Shotgun
2245 if angle
= ANGLE_RIGHTUP
then Dec(angle
, 2);
2246 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 4);
2247 if angle
= ANGLE_LEFTUP
then Inc(angle
, 2);
2248 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 4);
2250 5: begin // Chaingun
2253 if angle
= ANGLE_RIGHTUP
then Dec(angle
, 2);
2254 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 4);
2255 if angle
= ANGLE_LEFTUP
then Inc(angle
, 2);
2256 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 4);
2258 6: begin // Rocket Launcher
2261 if angle
= ANGLE_RIGHTUP
then Inc(angle
, 2);
2262 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 4);
2263 if angle
= ANGLE_LEFTUP
then Dec(angle
, 2);
2264 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 4);
2266 7: begin // Plasmagun
2269 if angle
= ANGLE_RIGHTUP
then Inc(angle
);
2270 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 3);
2271 if angle
= ANGLE_LEFTUP
then Dec(angle
);
2272 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 3);
2277 if angle
= ANGLE_RIGHTUP
then Inc(angle
, 1);
2278 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 2);
2279 if angle
= ANGLE_LEFTUP
then Dec(angle
, 1);
2280 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 2);
2282 9: begin // Super Chaingun
2285 if angle
= ANGLE_RIGHTUP
then Dec(angle
, 2);
2286 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 4);
2287 if angle
= ANGLE_LEFTUP
then Inc(angle
, 2);
2288 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 4);
2291 xx
:= Trunc(Cos(-DegToRad(angle
)) * len
) + wx
;
2292 yy
:= Trunc(Sin(-DegToRad(angle
)) * len
) + wy
;
2293 e_DrawLine(sz
, wx
, wy
, xx
, yy
, 255, 0, 0, 96);
2296 procedure TPlayer
.DrawGUI();
2299 X
, Y
, SY
, a
, p
, m
: Integer;
2303 stat
: TPlayerStatArray
;
2305 X
:= gPlayerScreenSize
.X
;
2306 SY
:= gPlayerScreenSize
.Y
;
2309 if gShowGoals
and (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then
2311 if gGameSettings
.GameMode
= GM_CTF
then
2315 if gGameSettings
.GameMode
= GM_CTF
then
2317 s
:= 'TEXTURE_PLAYER_REDFLAG';
2318 if gFlags
[FLAG_RED
].State
= FLAG_STATE_CAPTURED
then
2319 s
:= 'TEXTURE_PLAYER_REDFLAG_S';
2320 if gFlags
[FLAG_RED
].State
= FLAG_STATE_DROPPED
then
2321 s
:= 'TEXTURE_PLAYER_REDFLAG_D';
2322 if g_Texture_Get(s
, ID
) then
2323 e_Draw(ID
, X
-16-32, 240-72-4, 0, True, False);
2326 s
:= IntToStr(gTeamStat
[TEAM_RED
].Goals
);
2327 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2328 e_CharFont_PrintEx(gMenuFont
, X
-16-a
-tw
, 240-72-4, s
, TEAMCOLOR
[TEAM_RED
]);
2330 if gGameSettings
.GameMode
= GM_CTF
then
2332 s
:= 'TEXTURE_PLAYER_BLUEFLAG';
2333 if gFlags
[FLAG_BLUE
].State
= FLAG_STATE_CAPTURED
then
2334 s
:= 'TEXTURE_PLAYER_BLUEFLAG_S';
2335 if gFlags
[FLAG_BLUE
].State
= FLAG_STATE_DROPPED
then
2336 s
:= 'TEXTURE_PLAYER_BLUEFLAG_D';
2337 if g_Texture_Get(s
, ID
) then
2338 e_Draw(ID
, X
-16-32, 240-32-4, 0, True, False);
2341 s
:= IntToStr(gTeamStat
[TEAM_BLUE
].Goals
);
2342 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2343 e_CharFont_PrintEx(gMenuFont
, X
-16-a
-tw
, 240-32-4, s
, TEAMCOLOR
[TEAM_BLUE
]);
2346 if g_Texture_Get('TEXTURE_PLAYER_HUDBG', ID
) then
2347 e_DrawFill(ID
, X
, 0, 1, (gPlayerScreenSize
.Y
div 256)+IfThen(gPlayerScreenSize
.Y
mod 256 > 0, 1, 0),
2350 if g_Texture_Get('TEXTURE_PLAYER_HUD', ID
) then
2351 e_Draw(ID
, X
+2, Y
, 0, True, False);
2353 if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
2357 s
:= IntToStr(Frags
);
2358 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2359 e_CharFont_PrintEx(gMenuFont
, X
-16-tw
, Y
, s
, _RGB(255, 0, 0));
2364 stat
:= g_Player_GetStats();
2369 for a
:= 0 to High(stat
) do
2370 if stat
[a
].Name
<> Name
then
2372 if stat
[a
].Frags
> m
then m
:= stat
[a
].Frags
;
2373 if stat
[a
].Frags
> Frags
then p
:= p
+1;
2377 s
:= IntToStr(p
)+' / '+IntToStr(Length(stat
))+' ';
2378 if Frags
>= m
then s
:= s
+'+' else s
:= s
+'-';
2379 s
:= s
+IntToStr(Abs(Frags
-m
));
2381 e_CharFont_GetSize(gMenuSmallFont
, s
, tw
, th
);
2382 e_CharFont_PrintEx(gMenuSmallFont
, X
-16-tw
, Y
+32, s
, _RGB(255, 0, 0));
2385 if gShowLives
and (gGameSettings
.MaxLives
> 0) then
2387 s
:= IntToStr(Lives
);
2388 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2389 e_CharFont_PrintEx(gMenuFont
, X
-16-tw
, SY
-32, s
, _RGB(0, 255, 0));
2393 e_CharFont_GetSize(gMenuSmallFont
, FName
, tw
, th
);
2394 e_CharFont_PrintEx(gMenuSmallFont
, X
+98-(tw
div 2), Y
+8, FName
, _RGB(255, 0, 0));
2396 if R_BERSERK
in FRulez
then
2397 e_Draw(gItemsTexturesID
[ITEM_MEDKIT_BLACK
], X
+37, Y
+45, 0, True, False)
2399 e_Draw(gItemsTexturesID
[ITEM_MEDKIT_LARGE
], X
+37, Y
+45, 0, True, False);
2401 if g_Texture_Get('TEXTURE_PLAYER_ARMORHUD', ID
) then
2402 e_Draw(ID
, X
+36, Y
+77, 0, True, False);
2404 s
:= IntToStr(IfThen(FHealth
> 0, FHealth
, 0));
2405 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2406 e_CharFont_PrintEx(gMenuFont
, X
+178-tw
, Y
+40, s
, _RGB(255, 0, 0));
2408 s
:= IntToStr(FArmor
);
2409 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2410 e_CharFont_PrintEx(gMenuFont
, X
+178-tw
, Y
+68, s
, _RGB(255, 0, 0));
2412 s
:= IntToStr(GetAmmoByWeapon(FCurrWeap
));
2418 ID
:= gItemsTexturesID
[ITEM_WEAPON_KASTET
];
2423 ID
:= gItemsTexturesID
[ITEM_WEAPON_SAW
];
2425 WEAPON_PISTOL
: ID
:= gItemsTexturesID
[ITEM_WEAPON_PISTOL
];
2426 WEAPON_CHAINGUN
: ID
:= gItemsTexturesID
[ITEM_WEAPON_CHAINGUN
];
2427 WEAPON_SHOTGUN1
: ID
:= gItemsTexturesID
[ITEM_WEAPON_SHOTGUN1
];
2428 WEAPON_SHOTGUN2
: ID
:= gItemsTexturesID
[ITEM_WEAPON_SHOTGUN2
];
2429 WEAPON_SUPERPULEMET
: ID
:= gItemsTexturesID
[ITEM_WEAPON_SUPERPULEMET
];
2430 WEAPON_ROCKETLAUNCHER
: ID
:= gItemsTexturesID
[ITEM_WEAPON_ROCKETLAUNCHER
];
2431 WEAPON_PLASMA
: ID
:= gItemsTexturesID
[ITEM_WEAPON_PLASMA
];
2432 WEAPON_BFG
: ID
:= gItemsTexturesID
[ITEM_WEAPON_BFG
];
2435 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2436 e_CharFont_PrintEx(gMenuFont
, X
+178-tw
, Y
+158, s
, _RGB(255, 0, 0));
2437 e_Draw(ID
, X
+20, Y
+160, 0, True, False);
2439 if R_KEY_RED
in FRulez
then
2440 e_Draw(gItemsTexturesID
[ITEM_KEY_RED
], X
+78, Y
+214, 0, True, False);
2442 if R_KEY_GREEN
in FRulez
then
2443 e_Draw(gItemsTexturesID
[ITEM_KEY_GREEN
], X
+95, Y
+214, 0, True, False);
2445 if R_KEY_BLUE
in FRulez
then
2446 e_Draw(gItemsTexturesID
[ITEM_KEY_BLUE
], X
+112, Y
+214, 0, True, False);
2448 if FJetFuel
> 0 then
2450 if g_Texture_Get('TEXTURE_PLAYER_HUDAIR', ID
) then
2451 e_Draw(ID
, X
+2, Y
+116, 0, True, False);
2452 if g_Texture_Get('TEXTURE_PLAYER_HUDJET', ID
) then
2453 e_Draw(ID
, X
+2, Y
+126, 0, True, False);
2454 e_DrawLine(4, X
+16, Y
+122, X
+16+Trunc(168*IfThen(FAir
> 0, FAir
, 0)/AIR_MAX
), Y
+122, 0, 0, 196);
2455 e_DrawLine(4, X
+16, Y
+132, X
+16+Trunc(168*FJetFuel
/JET_MAX
), Y
+132, 208, 0, 0);
2459 if g_Texture_Get('TEXTURE_PLAYER_HUDAIR', ID
) then
2460 e_Draw(ID
, X
+2, Y
+124, 0, True, False);
2461 e_DrawLine(4, X
+16, Y
+130, X
+16+Trunc(168*IfThen(FAir
> 0, FAir
, 0)/AIR_MAX
), Y
+130, 0, 0, 196);
2464 if gShowPing
and g_Game_IsClient
then
2466 s
:= _lc
[I_GAME_PING_HUD
] + IntToStr(NetPeer
.lastRoundTripTime
) + _lc
[I_NET_SLIST_PING_MS
];
2467 e_TextureFontPrint(X
+ 4, Y
+ 242, s
, gStdFont
);
2473 e_TextureFontPrint(X
+ 4, Y
+ 242, _lc
[I_PLAYER_SPECT
], gStdFont
);
2474 e_TextureFontPrint(X
+ 4, Y
+ 258, _lc
[I_PLAYER_SPECT2
], gStdFont
);
2475 e_TextureFontPrint(X
+ 4, Y
+ 274, _lc
[I_PLAYER_SPECT1
], gStdFont
);
2478 e_TextureFontGetSize(gStdFont
, cw
, ch
);
2479 s
:= _lc
[I_PLAYER_SPECT4
];
2480 e_TextureFontPrintEx(gScreenWidth
div 2 - cw
*(Length(s
) div 2),
2481 gScreenHeight
-4-ch
, s
, gStdFont
, 255, 255, 255, 1, True);
2482 e_TextureFontPrint(X
+ 4, Y
+ 290, _lc
[I_PLAYER_SPECT1S
], gStdFont
);
2488 procedure TPlayer
.DrawRulez();
2492 // Ïðè âçÿòèè íåóÿçâèìîñòè ðèñóåòñÿ èíâåðñèîííûé áåëûé ôîí
2493 if FMegaRulez
[MR_INVUL
] >= gTime
then
2495 if (FMegaRulez
[MR_INVUL
]-gTime
) <= 2100 then
2496 dr
:= not Odd((FMegaRulez
[MR_INVUL
]-gTime
) div 300)
2501 e_DrawFillQuad(0, 0, gPlayerScreenSize
.X
-1, gPlayerScreenSize
.Y
-1,
2502 191, 191, 191, 0, B_INVERT
);
2505 // Ïðè âçÿòèè çàùèòíîãî êîñòþìà ðèñóåòñÿ çåëåíîâàòûé ôîí
2506 if FMegaRulez
[MR_SUIT
] >= gTime
then
2508 if (FMegaRulez
[MR_SUIT
]-gTime
) <= 2100 then
2509 dr
:= not Odd((FMegaRulez
[MR_SUIT
]-gTime
) div 300)
2514 e_DrawFillQuad(0, 0, gPlayerScreenSize
.X
-1, gPlayerScreenSize
.Y
-1,
2515 0, 96, 0, 200, B_NONE
);
2518 // Ïðè âçÿòèè áåðñåðêà ðèñóåòñÿ êðàñíîâàòûé ôîí
2519 if (FBerserk
>= 0) and (LongWord(FBerserk
) >= gTime
) and (gFlash
= 2) then
2521 e_DrawFillQuad(0, 0, gPlayerScreenSize
.X
-1, gPlayerScreenSize
.Y
-1,
2522 255, 0, 0, 200, B_NONE
);
2526 procedure TPlayer
.DrawPain();
2530 if FPain
= 0 then Exit
;
2534 if a
< 15 then h
:= 0
2535 else if a
< 35 then h
:= 1
2536 else if a
< 55 then h
:= 2
2537 else if a
< 75 then h
:= 3
2538 else if a
< 95 then h
:= 4
2541 //if a > 255 then a := 255;
2543 e_DrawFillQuad(0, 0, gPlayerScreenSize
.X
-1, gPlayerScreenSize
.Y
-1, 255, 0, 0, 255-h
*50);
2544 //e_DrawFillQuad(0, 0, gPlayerScreenSize.X-1, gPlayerScreenSize.Y-1, 255-min(128, a), 255-a, 255-a, 0, B_FILTER);
2547 procedure TPlayer
.DrawPickup();
2551 if FPickup
= 0 then Exit
;
2555 if a
< 15 then h
:= 1
2556 else if a
< 35 then h
:= 2
2557 else if a
< 55 then h
:= 3
2558 else if a
< 75 then h
:= 4
2561 e_DrawFillQuad(0, 0, gPlayerScreenSize
.X
-1, gPlayerScreenSize
.Y
-1, 150, 200, 150, 255-h
*50);
2564 procedure TPlayer
.Fire();
2566 f
, DidFire
: Boolean;
2567 wx
, wy
, xd
, yd
: Integer;
2570 if g_Game_IsClient
then Exit
;
2571 // FBFGFireCounter - âðåìÿ ïåðåä âûñòðåëîì (äëÿ BFG)
2572 // FReloading - âðåìÿ ïîñëå âûñòðåëà (äëÿ âñåãî)
2580 if FReloading
[FCurrWeap
] <> 0 then Exit
;
2585 wx
:= FObj
.X
+WEAPONPOINT
[FDirection
].X
;
2586 wy
:= FObj
.Y
+WEAPONPOINT
[FDirection
].Y
;
2587 xd
:= wx
+IfThen(FDirection
= D_LEFT
, -30, 30);
2588 yd
:= wy
+firediry();
2593 if R_BERSERK
in FRulez
then
2595 //g_Weapon_punch(FObj.X+FObj.Rect.X, FObj.Y+FObj.Rect.Y, 75, FUID);
2596 obj
.X
:= FObj
.X
+FObj
.Rect
.X
;
2597 obj
.Y
:= FObj
.Y
+FObj
.Rect
.Y
;
2600 obj
.rect
.Width
:= 39;
2601 obj
.rect
.Height
:= 52;
2602 obj
.Vel
.X
:= (xd
-wx
) div 2;
2603 obj
.Vel
.Y
:= (yd
-wy
) div 2;
2604 obj
.Accel
.X
:= xd
-wx
;
2605 obj
.Accel
.y
:= yd
-wy
;
2607 if g_Weapon_Hit(@obj
, 50, FUID
, HIT_SOME
) <> 0 then
2608 g_Sound_PlayExAt('SOUND_WEAPON_HITBERSERK', FObj
.X
, FObj
.Y
)
2610 g_Sound_PlayExAt('SOUND_WEAPON_MISSBERSERK', FObj
.X
, FObj
.Y
);
2614 FPain
:= min(FPain
+ 25, 50);
2615 end else g_Weapon_punch(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
, 3, FUID
);
2618 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
2623 if g_Weapon_chainsaw(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
,
2624 IfThen(gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
], 9, 3), FUID
) <> 0 then
2626 FSawSoundSelect
.Stop();
2628 FSawSoundHit
.PlayAt(FObj
.X
, FObj
.Y
);
2630 else if not FSawSoundHit
.IsPlaying() then
2632 FSawSoundSelect
.Stop();
2633 FSawSound
.PlayAt(FObj
.X
, FObj
.Y
);
2636 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
2642 if FAmmo
[A_BULLETS
] > 0 then
2644 g_Weapon_pistol(wx
, wy
, xd
, yd
, FUID
);
2645 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
2646 Dec(FAmmo
[A_BULLETS
]);
2647 FFireAngle
:= FAngle
;
2650 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
2651 GameVelX
, GameVelY
-2, SHELL_BULLET
);
2655 if FAmmo
[A_SHELLS
] > 0 then
2657 g_Weapon_shotgun(wx
, wy
, xd
, yd
, FUID
);
2658 if not gSoundEffectsDF
then g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN', wx
, wy
);
2659 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
2660 Dec(FAmmo
[A_SHELLS
]);
2661 FFireAngle
:= FAngle
;
2665 FShellType
:= SHELL_SHELL
;
2669 if FAmmo
[A_SHELLS
] >= 2 then
2671 g_Weapon_dshotgun(wx
, wy
, xd
, yd
, FUID
);
2672 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
2673 Dec(FAmmo
[A_SHELLS
], 2);
2674 FFireAngle
:= FAngle
;
2678 FShellType
:= SHELL_DBLSHELL
;
2682 if FAmmo
[A_BULLETS
] > 0 then
2684 g_Weapon_mgun(wx
, wy
, xd
, yd
, FUID
);
2685 if not gSoundEffectsDF
then g_Sound_PlayExAt('SOUND_WEAPON_FIREPISTOL', wx
, wy
);
2686 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
2687 Dec(FAmmo
[A_BULLETS
]);
2688 FFireAngle
:= FAngle
;
2691 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
2692 GameVelX
, GameVelY
-2, SHELL_BULLET
);
2695 WEAPON_ROCKETLAUNCHER
:
2696 if FAmmo
[A_ROCKETS
] > 0 then
2698 g_Weapon_rocket(wx
, wy
, xd
, yd
, FUID
);
2699 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
2700 Dec(FAmmo
[A_ROCKETS
]);
2701 FFireAngle
:= FAngle
;
2707 if FAmmo
[A_CELLS
] > 0 then
2709 g_Weapon_plasma(wx
, wy
, xd
, yd
, FUID
);
2710 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
2711 Dec(FAmmo
[A_CELLS
]);
2712 FFireAngle
:= FAngle
;
2718 if (FAmmo
[A_CELLS
] >= 40) and (FBFGFireCounter
= -1) then
2720 FBFGFireCounter
:= 17;
2721 if not FNoReload
then
2722 g_Sound_PlayExAt('SOUND_WEAPON_STARTFIREBFG', FObj
.X
, FObj
.Y
);
2723 Dec(FAmmo
[A_CELLS
], 40);
2727 WEAPON_SUPERPULEMET
:
2728 if FAmmo
[A_SHELLS
] > 0 then
2730 g_Weapon_shotgun(wx
, wy
, xd
, yd
, FUID
);
2731 if not gSoundEffectsDF
then g_Sound_PlayExAt('SOUND_WEAPON_FIRECGUN', wx
, wy
);
2732 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
2733 Dec(FAmmo
[A_SHELLS
]);
2734 FFireAngle
:= FAngle
;
2737 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
2738 GameVelX
, GameVelY
-2, SHELL_SHELL
);
2742 if g_Game_IsNet
then
2746 if FCurrWeap
<> WEAPON_BFG
then
2747 MH_SEND_PlayerFire(FUID
, FCurrWeap
, wx
, wy
, xd
, yd
, LastShotID
)
2749 if not FNoReload
then
2750 MH_SEND_Sound(FObj
.X
, FObj
.Y
, 'SOUND_WEAPON_STARTFIREBFG');
2753 MH_SEND_PlayerStats(FUID
);
2758 if (FAngle
= 0) or (FAngle
= 180) then SetAction(A_ATTACK
)
2759 else if (FAngle
= ANGLE_LEFTDOWN
) or (FAngle
= ANGLE_RIGHTDOWN
) then SetAction(A_ATTACKDOWN
)
2760 else if (FAngle
= ANGLE_LEFTUP
) or (FAngle
= ANGLE_RIGHTUP
) then SetAction(A_ATTACKUP
);
2763 function TPlayer
.GetAmmoByWeapon(Weapon
: Byte): Word;
2766 WEAPON_PISTOL
, WEAPON_CHAINGUN
: Result
:= FAmmo
[A_BULLETS
];
2767 WEAPON_SHOTGUN1
, WEAPON_SHOTGUN2
, WEAPON_SUPERPULEMET
: Result
:= FAmmo
[A_SHELLS
];
2768 WEAPON_ROCKETLAUNCHER
: Result
:= FAmmo
[A_ROCKETS
];
2769 WEAPON_PLASMA
, WEAPON_BFG
: Result
:= FAmmo
[A_CELLS
];
2774 function TPlayer
.HeadInLiquid(XInc
, YInc
: Integer): Boolean;
2776 Result
:= g_Map_CollidePanel(FObj
.X
+PLAYER_HEADRECT
.X
+XInc
, FObj
.Y
+PLAYER_HEADRECT
.Y
+YInc
,
2777 PLAYER_HEADRECT
.Width
, PLAYER_HEADRECT
.Height
,
2778 PANEL_WATER
or PANEL_ACID1
or PANEL_ACID2
, True);
2781 procedure TPlayer
.JetpackOn
;
2785 FJetSoundOn
.SetPosition(0);
2786 FJetSoundOn
.PlayAt(FObj
.X
, FObj
.Y
);
2790 procedure TPlayer
.JetpackOff
;
2794 FJetSoundOff
.SetPosition(0);
2795 FJetSoundOff
.PlayAt(FObj
.X
, FObj
.Y
);
2798 procedure TPlayer
.Jump();
2800 if gFly
or FJetpack
then
2802 // Ïîëåò (÷èò-êîä èëè äæåòïàê):
2803 if FObj
.Vel
.Y
> -VEL_FLY
then
2804 FObj
.Vel
.Y
:= FObj
.Vel
.Y
- 3;
2807 if FJetFuel
> 0 then
2809 if (FJetFuel
< 1) and g_Game_IsServer
then
2813 if g_Game_IsNet
then
2814 MH_SEND_PlayerStats(FUID
);
2820 // Íå âêëþ÷àòü äæåòïàê â ðåæèìå ïðîõîæäåíèÿ ñêâîçü ñòåíû
2822 FCanJetpack
:= False;
2824 // Ïðûãàåì èëè âñïëûâàåì:
2825 if (CollideLevel(0, 1) or
2826 g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+PLAYER_RECT
.Y
+36, PLAYER_RECT
.Width
,
2827 PLAYER_RECT
.Height
-33, PANEL_STEP
, False)
2828 ) and (FObj
.Accel
.Y
= 0) then // Íå ïðûãàòü, åñëè åñòü âåðòèêàëüíîå óñêîðåíèå
2830 FObj
.Vel
.Y
:= -VEL_JUMP
;
2831 FCanJetpack
:= False;
2835 if BodyInLiquid(0, 0) then
2836 FObj
.Vel
.Y
:= -VEL_SW
2837 else if (FJetFuel
> 0) and FCanJetpack
and
2838 g_Game_IsServer
and (not g_Obj_CollideLiquid(@FObj
, 0, 0)) then
2842 if g_Game_IsNet
then
2843 MH_SEND_PlayerStats(FUID
);
2848 procedure TPlayer
.Kill(KillType
: Byte; SpawnerUID
: Word; t
: Byte);
2850 a
, i
, k
, ab
, ar
: Byte;
2854 srv
, netsrv
: Boolean;
2859 procedure PushItem(t
: Byte);
2863 id
:= g_Items_Create(FObj
.X
, FObj
.Y
, t
, True, False);
2864 if KillType
= K_EXTRAHARDKILL
then // -7..+7; -8..0
2865 g_Obj_Push(@gItems
[id
].Obj
, (FObj
.Vel
.X
div 2)-7+Random(15),
2866 (FObj
.Vel
.Y
div 2)-Random(9))
2868 if KillType
= K_HARDKILL
then // -5..+5; -5..0
2869 g_Obj_Push(@gItems
[id
].Obj
, (FObj
.Vel
.X
div 2)-5+Random(11),
2870 (FObj
.Vel
.Y
div 2)-Random(6))
2871 else // -3..+3; -3..0
2872 g_Obj_Push(@gItems
[id
].Obj
, (FObj
.Vel
.X
div 2)-3+Random(7),
2873 (FObj
.Vel
.Y
div 2)-Random(4));
2875 if g_Game_IsNet
and g_Game_IsServer
then
2876 MH_SEND_ItemSpawn(True, id
);
2880 DoFrags
:= (gGameSettings
.MaxLives
= 0) or (gGameSettings
.GameMode
= GM_COOP
);
2881 Srv
:= g_Game_IsServer
;
2882 Netsrv
:= g_Game_IsServer
and g_Game_IsNet
;
2883 if Srv
then FDeath
:= FDeath
+ 1;
2888 if not FPhysics
then
2894 if (gGameSettings
.MaxLives
> 0) and Srv
and (gLMSRespawn
= LMS_RESPAWN_NONE
) then
2896 if FLives
> 0 then FLives
:= FLives
- 1;
2897 if FLives
= 0 then FNoRespawn
:= True;
2900 // Íîìåð òèïà ñìåðòè:
2903 K_SIMPLEKILL
: a
:= 1;
2905 K_EXTRAHARDKILL
: a
:= 3;
2910 if not FModel
.PlaySound(MODELSOUND_DIE
, a
, FObj
.X
, FObj
.Y
) then
2912 if FModel
.PlaySound(MODELSOUND_DIE
, i
, FObj
.X
, FObj
.Y
) then
2919 FTime
[T_RESPAWN
] := gTime
+ TIME_RESPAWN1
;
2921 FTime
[T_RESPAWN
] := gTime
+ TIME_RESPAWN2
;
2922 K_EXTRAHARDKILL
, K_FALLKILL
:
2923 FTime
[T_RESPAWN
] := gTime
+ TIME_RESPAWN3
;
2926 // Ïåðåêëþ÷àåì ñîñòîÿíèå:
2930 K_HARDKILL
, K_EXTRAHARDKILL
:
2934 // Ðåàêöèÿ ìîíñòðîâ íà ñìåðòü èãðîêà:
2935 if (KillType
<> K_FALLKILL
) and (Srv
) then
2936 g_Monsters_killedp();
2938 if SpawnerUID
= FUID
then
2940 if Srv
and (DoFrags
or (gGameSettings
.GameMode
= GM_TDM
)) then
2945 g_Console_Add(Format(_lc
[I_PLAYER_KILL_SELF
], [FName
]), True);
2948 if g_GetUIDType(SpawnerUID
) = UID_PLAYER
then
2949 begin // Óáèò äðóãèì èãðîêîì
2950 KP
:= g_Player_Get(SpawnerUID
);
2951 if (KP
<> nil) and Srv
then
2953 if (DoFrags
or (gGameSettings
.GameMode
= GM_TDM
)) then
2954 if SameTeam(FUID
, SpawnerUID
) then
2964 if (gGameSettings
.GameMode
= GM_TDM
) and DoFrags
then
2965 Inc(gTeamStat
[KP
.Team
].Goals
,
2966 IfThen(SameTeam(FUID
, SpawnerUID
), -1, 1));
2968 if netsrv
then MH_SEND_PlayerStats(SpawnerUID
);
2971 plr
:= g_Player_Get(SpawnerUID
);
2979 g_Console_Add(Format(_lc
[I_PLAYER_KILL_EXTRAHARD_2
],
2983 g_Console_Add(Format(_lc
[I_PLAYER_KILL_EXTRAHARD_1
],
2987 g_Console_Add(Format(_lc
[I_PLAYER_KILL
],
2992 else if g_GetUIDType(SpawnerUID
) = UID_MONSTER
then
2993 begin // Óáèò ìîíñòðîì
2994 mon
:= g_Monsters_Get(SpawnerUID
);
2998 s
:= g_Monsters_GetKilledBy(mon
.MonsterType
);
3002 g_Console_Add(Format(_lc
[I_PLAYER_KILL_EXTRAHARD_2
],
3006 g_Console_Add(Format(_lc
[I_PLAYER_KILL_EXTRAHARD_1
],
3010 g_Console_Add(Format(_lc
[I_PLAYER_KILL
],
3015 else // Îñîáûå òèïû ñìåðòè
3018 HIT_SELF
: g_Console_Add(Format(_lc
[I_PLAYER_KILL_SELF
], [FName
]), True);
3019 HIT_FALL
: g_Console_Add(Format(_lc
[I_PLAYER_KILL_FALL
], [FName
]), True);
3020 HIT_WATER
: g_Console_Add(Format(_lc
[I_PLAYER_KILL_WATER
], [FName
]), True);
3021 HIT_ACID
: g_Console_Add(Format(_lc
[I_PLAYER_KILL_ACID
], [FName
]), True);
3022 HIT_TRAP
: g_Console_Add(Format(_lc
[I_PLAYER_KILL_TRAP
], [FName
]), True);
3023 else g_Console_Add(Format(_lc
[I_PLAYER_DIED
], [FName
]), True);
3029 for a
:= WEAPON_KASTET
to WEAPON_SUPERPULEMET
do
3033 WEAPON_SAW
: i
:= ITEM_WEAPON_SAW
;
3034 WEAPON_SHOTGUN1
: i
:= ITEM_WEAPON_SHOTGUN1
;
3035 WEAPON_SHOTGUN2
: i
:= ITEM_WEAPON_SHOTGUN2
;
3036 WEAPON_CHAINGUN
: i
:= ITEM_WEAPON_CHAINGUN
;
3037 WEAPON_ROCKETLAUNCHER
: i
:= ITEM_WEAPON_ROCKETLAUNCHER
;
3038 WEAPON_PLASMA
: i
:= ITEM_WEAPON_PLASMA
;
3039 WEAPON_BFG
: i
:= ITEM_WEAPON_BFG
;
3040 WEAPON_SUPERPULEMET
: i
:= ITEM_WEAPON_SUPERPULEMET
;
3049 if R_ITEM_BACKPACK
in FRulez
then
3050 PushItem(ITEM_AMMO_BACKPACK
);
3052 // Âûáðîñ ðàêåòíîãî ðàíöà:
3053 if FJetFuel
> 0 then
3054 PushItem(ITEM_JETPACK
);
3057 if not (gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
]) then
3059 if R_KEY_RED
in FRulez
then
3060 PushItem(ITEM_KEY_RED
);
3062 if R_KEY_GREEN
in FRulez
then
3063 PushItem(ITEM_KEY_GREEN
);
3065 if R_KEY_BLUE
in FRulez
then
3066 PushItem(ITEM_KEY_BLUE
);
3073 g_Player_CreateCorpse(Self
);
3075 if Srv
and (gGameSettings
.MaxLives
> 0) and FNoRespawn
and
3076 (gLMSRespawn
= LMS_RESPAWN_NONE
) then
3082 for i
:= Low(gPlayers
) to High(gPlayers
) do
3084 if gPlayers
[i
] = nil then continue
;
3085 if (not gPlayers
[i
].FNoRespawn
) and (not gPlayers
[i
].FSpectator
) then
3088 if gPlayers
[i
].FTeam
= TEAM_RED
then Inc(ar
)
3089 else if gPlayers
[i
].FTeam
= TEAM_BLUE
then Inc(ab
);
3094 OldLR
:= gLMSRespawn
;
3095 if (gGameSettings
.GameMode
= GM_COOP
) then
3099 // everyone is dead, restart the map
3100 g_Game_Message(_lc
[I_MESSAGE_LMS_LOSE
], 144);
3102 MH_SEND_GameEvent(NET_EV_LMS_LOSE
);
3103 gLMSRespawn
:= LMS_RESPAWN_FINAL
;
3104 gLMSRespawnTime
:= gTime
+ 5000;
3106 else if (a
= 1) then
3108 if (gPlayers
[k
] <> nil) and not (gPlayers
[k
] is TBot
) then
3109 if (gPlayers
[k
] = gPlayer1
) or
3110 (gPlayers
[k
] = gPlayer2
) then
3111 g_Console_Add('*** ' + _lc
[I_MESSAGE_LMS_SURVIVOR
] + ' ***', True)
3112 else if Netsrv
and (gPlayers
[k
].FClientID
>= 0) then
3113 MH_SEND_GameEvent(NET_EV_LMS_SURVIVOR
, 0, 'N', gPlayers
[k
].FClientID
);
3116 else if (gGameSettings
.GameMode
= GM_TDM
) then
3118 if (ab
= 0) and (ar
<> 0) then
3121 g_Game_Message(Format(_lc
[I_MESSAGE_TLMS_WIN
], [AnsiUpperCase(_lc
[I_GAME_TEAM_RED
])]), 144);
3123 MH_SEND_GameEvent(NET_EV_TLMS_WIN
, TEAM_RED
);
3124 Inc(gTeamStat
[TEAM_RED
].Goals
);
3125 gLMSRespawn
:= LMS_RESPAWN_FINAL
;
3126 gLMSRespawnTime
:= gTime
+ 5000;
3128 else if (ar
= 0) and (ab
<> 0) then
3131 g_Game_Message(Format(_lc
[I_MESSAGE_TLMS_WIN
], [AnsiUpperCase(_lc
[I_GAME_TEAM_BLUE
])]), 144);
3133 MH_SEND_GameEvent(NET_EV_TLMS_WIN
, TEAM_BLUE
);
3134 Inc(gTeamStat
[TEAM_BLUE
].Goals
);
3135 gLMSRespawn
:= LMS_RESPAWN_FINAL
;
3136 gLMSRespawnTime
:= gTime
+ 5000;
3138 else if (ar
= 0) and (ab
= 0) then
3141 g_Game_Message(_lc
[I_GAME_WIN_DRAW
], 144);
3143 MH_SEND_GameEvent(NET_EV_LMS_DRAW
, 0, FName
);
3144 gLMSRespawn
:= LMS_RESPAWN_FINAL
;
3145 gLMSRespawnTime
:= gTime
+ 5000;
3148 else if (gGameSettings
.GameMode
= GM_DM
) then
3152 if gPlayers
[k
] <> nil then
3155 // survivor is the winner
3156 g_Game_Message(Format(_lc
[I_MESSAGE_LMS_WIN
], [AnsiUpperCase(FName
)]), 144);
3158 MH_SEND_GameEvent(NET_EV_LMS_WIN
, 0, FName
);
3161 gLMSRespawn
:= LMS_RESPAWN_FINAL
;
3162 gLMSRespawnTime
:= gTime
+ 5000;
3164 else if (a
= 0) then
3166 // everyone is dead, restart the map
3167 g_Game_Message(_lc
[I_GAME_WIN_DRAW
], 144);
3169 MH_SEND_GameEvent(NET_EV_LMS_DRAW
, 0, FName
);
3170 gLMSRespawn
:= LMS_RESPAWN_FINAL
;
3171 gLMSRespawnTime
:= gTime
+ 5000;
3174 if srv
and (OldLR
= LMS_RESPAWN_NONE
) and (gLMSRespawn
> LMS_RESPAWN_NONE
) then
3176 if NetMode
= NET_SERVER
then
3177 MH_SEND_GameEvent(NET_EV_LMS_WARMUP
, (gLMSRespawnTime
- gTime
) div 1000)
3179 g_Console_Add(Format(_lc
[I_MSG_WARMUP_START
], [(gLMSRespawnTime
- gTime
) div 1000]), True);
3185 MH_SEND_PlayerStats(FUID
);
3186 MH_SEND_PlayerDeath(FUID
, KillType
, t
, SpawnerUID
);
3187 if gGameSettings
.GameMode
= GM_TDM
then MH_SEND_GameStats
;
3190 if srv
and FNoRespawn
then Spectate(True);
3191 FWantsInGame
:= True;
3194 function TPlayer
.BodyInLiquid(XInc
, YInc
: Integer): Boolean;
3196 Result
:= g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
, PLAYER_RECT
.Width
,
3197 PLAYER_RECT
.Height
-20, PANEL_WATER
or PANEL_ACID1
or PANEL_ACID2
, False);
3200 function TPlayer
.BodyInAcid(XInc
, YInc
: Integer): Boolean;
3202 Result
:= g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
, PLAYER_RECT
.Width
,
3203 PLAYER_RECT
.Height
-20, PANEL_ACID1
or PANEL_ACID2
, False);
3206 procedure TPlayer
.MakeBloodSimple(Count
: Word);
3208 g_GFX_Blood(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)+8,
3209 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2),
3210 Count
div 2, 3, -1, 16, (PLAYER_RECT
.Height
*2 div 3),
3212 g_GFX_Blood(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-8,
3213 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2),
3214 Count
div 2, -3, -1, 16, (PLAYER_RECT
.Height
*2) div 3,
3218 procedure TPlayer
.MakeBloodVector(Count
: Word; VelX
, VelY
: Integer);
3220 g_GFX_Blood(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2),
3221 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2),
3222 Count
, VelX
, VelY
, 16, (PLAYER_RECT
.Height
*2) div 3,
3226 procedure TPlayer
.NextWeapon();
3231 if g_Game_IsClient
then Exit
;
3232 if FBFGFireCounter
<> -1 then Exit
;
3234 if FTime
[T_SWITCH
] > gTime
then Exit
;
3236 for i
:= WEAPON_KASTET
to WEAPON_SUPERPULEMET
do
3237 if FReloading
[i
] > 0 then Exit
;
3241 for i
:= FCurrWeap
+1 to WEAPON_SUPERPULEMET
do
3250 for i
:= WEAPON_KASTET
to FCurrWeap
-1 do
3257 FTime
[T_SWITCH
] := gTime
+156;
3259 if FCurrWeap
= WEAPON_SAW
then
3260 FSawSoundSelect
.PlayAt(FObj
.X
, FObj
.Y
);
3262 FModel
.SetWeapon(FCurrWeap
);
3264 if g_Game_IsNet
then MH_SEND_PlayerStats(FUID
);
3267 procedure TPlayer
.PrevWeapon();
3272 if g_Game_IsClient
then Exit
;
3273 if FBFGFireCounter
<> -1 then Exit
;
3275 if FTime
[T_SWITCH
] > gTime
then Exit
;
3277 for i
:= WEAPON_KASTET
to WEAPON_SUPERPULEMET
do
3278 if FReloading
[i
] > 0 then Exit
;
3282 if FCurrWeap
> 0 then
3283 for i
:= FCurrWeap
-1 downto WEAPON_KASTET
do
3292 for i
:= WEAPON_SUPERPULEMET
downto FCurrWeap
+1 do
3299 FTime
[T_SWITCH
] := gTime
+156;
3301 if FCurrWeap
= WEAPON_SAW
then
3302 FSawSoundSelect
.PlayAt(FObj
.X
, FObj
.Y
);
3304 FModel
.SetWeapon(FCurrWeap
);
3306 if g_Game_IsNet
then MH_SEND_PlayerStats(FUID
);
3309 procedure TPlayer
.SetWeapon(W
: Byte);
3311 if FCurrWeap
<> W
then
3312 if W
= WEAPON_SAW
then
3313 FSawSoundSelect
.PlayAt(FObj
.X
, FObj
.Y
);
3316 FModel
.SetWeapon(CurrWeap
);
3319 function TPlayer
.PickItem(ItemType
: Byte; respawn
: Boolean; var remove
: Boolean): Boolean;
3324 if g_Game_IsClient
then Exit
;
3326 // a = true - ìåñòî ñïàâíà ïðåäìåòà:
3327 a
:= LongBool(gGameSettings
.Options
and GAME_OPTION_WEAPONSTAY
) and respawn
;
3332 if FHealth
< PLAYER_HP_SOFT
then
3334 IncMax(FHealth
, 10, PLAYER_HP_SOFT
);
3337 if gFlash
= 2 then Inc(FPickup
, 5);
3341 if FHealth
< PLAYER_HP_SOFT
then
3343 IncMax(FHealth
, 25, PLAYER_HP_SOFT
);
3346 if gFlash
= 2 then Inc(FPickup
, 5);
3350 if FArmor
< PLAYER_AP_SOFT
then
3352 FArmor
:= PLAYER_AP_SOFT
;
3355 if gFlash
= 2 then Inc(FPickup
, 5);
3359 if FArmor
< PLAYER_AP_LIMIT
then
3361 FArmor
:= PLAYER_AP_LIMIT
;
3364 if gFlash
= 2 then Inc(FPickup
, 5);
3368 if FHealth
< PLAYER_HP_LIMIT
then
3370 IncMax(FHealth
, 100, PLAYER_HP_LIMIT
);
3373 if gFlash
= 2 then Inc(FPickup
, 5);
3377 if (FHealth
< PLAYER_HP_LIMIT
) or (FArmor
< PLAYER_AP_LIMIT
) then
3379 if FHealth
< PLAYER_HP_LIMIT
then
3380 FHealth
:= PLAYER_HP_LIMIT
;
3381 if FArmor
< PLAYER_AP_LIMIT
then
3382 FArmor
:= PLAYER_AP_LIMIT
;
3385 if gFlash
= 2 then Inc(FPickup
, 5);
3389 if (not FWeapon
[WEAPON_SAW
]) or ((not respawn
) and (gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
])) then
3391 FWeapon
[WEAPON_SAW
] := True;
3393 if gFlash
= 2 then Inc(FPickup
, 5);
3394 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
3397 ITEM_WEAPON_SHOTGUN1
:
3398 if (FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
]) or not FWeapon
[WEAPON_SHOTGUN1
] then
3400 // Íóæíî, ÷òîáû íå âçÿòü âñå ïóëè ñðàçó:
3401 if a
and FWeapon
[WEAPON_SHOTGUN1
] then Exit
;
3403 IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
3404 FWeapon
[WEAPON_SHOTGUN1
] := True;
3406 if gFlash
= 2 then Inc(FPickup
, 5);
3407 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
3410 ITEM_WEAPON_SHOTGUN2
:
3411 if (FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
]) or not FWeapon
[WEAPON_SHOTGUN2
] then
3413 if a
and FWeapon
[WEAPON_SHOTGUN2
] then Exit
;
3415 IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
3416 FWeapon
[WEAPON_SHOTGUN2
] := True;
3418 if gFlash
= 2 then Inc(FPickup
, 5);
3419 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
3422 ITEM_WEAPON_CHAINGUN
:
3423 if (FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
]) or not FWeapon
[WEAPON_CHAINGUN
] then
3425 if a
and FWeapon
[WEAPON_CHAINGUN
] then Exit
;
3427 IncMax(FAmmo
[A_BULLETS
], 50, FMaxAmmo
[A_BULLETS
]);
3428 FWeapon
[WEAPON_CHAINGUN
] := True;
3430 if gFlash
= 2 then Inc(FPickup
, 5);
3431 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
3434 ITEM_WEAPON_ROCKETLAUNCHER
:
3435 if (FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
]) or not FWeapon
[WEAPON_ROCKETLAUNCHER
] then
3437 if a
and FWeapon
[WEAPON_ROCKETLAUNCHER
] then Exit
;
3439 IncMax(FAmmo
[A_ROCKETS
], 2, FMaxAmmo
[A_ROCKETS
]);
3440 FWeapon
[WEAPON_ROCKETLAUNCHER
] := True;
3442 if gFlash
= 2 then Inc(FPickup
, 5);
3443 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
3447 if (FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
]) or not FWeapon
[WEAPON_PLASMA
] then
3449 if a
and FWeapon
[WEAPON_PLASMA
] then Exit
;
3451 IncMax(FAmmo
[A_CELLS
], 40, FMaxAmmo
[A_CELLS
]);
3452 FWeapon
[WEAPON_PLASMA
] := True;
3454 if gFlash
= 2 then Inc(FPickup
, 5);
3455 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
3459 if (FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
]) or not FWeapon
[WEAPON_BFG
] then
3461 if a
and FWeapon
[WEAPON_BFG
] then Exit
;
3463 IncMax(FAmmo
[A_CELLS
], 40, FMaxAmmo
[A_CELLS
]);
3464 FWeapon
[WEAPON_BFG
] := True;
3466 if gFlash
= 2 then Inc(FPickup
, 5);
3467 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
3470 ITEM_WEAPON_SUPERPULEMET
:
3471 if (FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
]) or not FWeapon
[WEAPON_SUPERPULEMET
] then
3473 if a
and FWeapon
[WEAPON_SUPERPULEMET
] then Exit
;
3475 IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
3476 FWeapon
[WEAPON_SUPERPULEMET
] := True;
3478 if gFlash
= 2 then Inc(FPickup
, 5);
3479 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
3483 if FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
] then
3485 IncMax(FAmmo
[A_BULLETS
], 10, FMaxAmmo
[A_BULLETS
]);
3488 if gFlash
= 2 then Inc(FPickup
, 5);
3491 ITEM_AMMO_BULLETS_BOX
:
3492 if FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
] then
3494 IncMax(FAmmo
[A_BULLETS
], 50, FMaxAmmo
[A_BULLETS
]);
3497 if gFlash
= 2 then Inc(FPickup
, 5);
3501 if FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
] then
3503 IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
3506 if gFlash
= 2 then Inc(FPickup
, 5);
3509 ITEM_AMMO_SHELLS_BOX
:
3510 if FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
] then
3512 IncMax(FAmmo
[A_SHELLS
], 25, FMaxAmmo
[A_SHELLS
]);
3515 if gFlash
= 2 then Inc(FPickup
, 5);
3519 if FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
] then
3521 IncMax(FAmmo
[A_ROCKETS
], 1, FMaxAmmo
[A_ROCKETS
]);
3524 if gFlash
= 2 then Inc(FPickup
, 5);
3527 ITEM_AMMO_ROCKET_BOX
:
3528 if FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
] then
3530 IncMax(FAmmo
[A_ROCKETS
], 5, FMaxAmmo
[A_ROCKETS
]);
3533 if gFlash
= 2 then Inc(FPickup
, 5);
3537 if FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
] then
3539 IncMax(FAmmo
[A_CELLS
], 40, FMaxAmmo
[A_CELLS
]);
3542 if gFlash
= 2 then Inc(FPickup
, 5);
3546 if FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
] then
3548 IncMax(FAmmo
[A_CELLS
], 100, FMaxAmmo
[A_CELLS
]);
3551 if gFlash
= 2 then Inc(FPickup
, 5);
3555 if not(R_ITEM_BACKPACK
in FRulez
) or
3556 (FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
]) or
3557 (FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
]) or
3558 (FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
]) or
3559 (FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
]) then
3561 FMaxAmmo
[A_BULLETS
] := 400;
3562 FMaxAmmo
[A_SHELLS
] := 100;
3563 FMaxAmmo
[A_ROCKETS
] := 100;
3564 FMaxAmmo
[A_CELLS
] := 600;
3566 if FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
] then
3567 IncMax(FAmmo
[A_BULLETS
], 10, FMaxAmmo
[A_BULLETS
]);
3568 if FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
] then
3569 IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
3570 if FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
] then
3571 IncMax(FAmmo
[A_ROCKETS
], 1, FMaxAmmo
[A_ROCKETS
]);
3572 if FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
] then
3573 IncMax(FAmmo
[A_CELLS
], 40, FMaxAmmo
[A_CELLS
]);
3575 FRulez
:= FRulez
+ [R_ITEM_BACKPACK
];
3578 if gFlash
= 2 then Inc(FPickup
, 5);
3582 if not(R_KEY_RED
in FRulez
) then
3584 Include(FRulez
, R_KEY_RED
);
3586 remove
:= (gGameSettings
.GameMode
<> GM_COOP
) and (g_Player_GetCount() < 2);
3587 if gFlash
= 2 then Inc(FPickup
, 5);
3588 if (not remove
) and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETITEM');
3592 if not(R_KEY_GREEN
in FRulez
) then
3594 Include(FRulez
, R_KEY_GREEN
);
3596 remove
:= (gGameSettings
.GameMode
<> GM_COOP
) and (g_Player_GetCount() < 2);
3597 if gFlash
= 2 then Inc(FPickup
, 5);
3598 if (not remove
) and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETITEM');
3602 if not(R_KEY_BLUE
in FRulez
) then
3604 Include(FRulez
, R_KEY_BLUE
);
3606 remove
:= (gGameSettings
.GameMode
<> GM_COOP
) and (g_Player_GetCount() < 2);
3607 if gFlash
= 2 then Inc(FPickup
, 5);
3608 if (not remove
) and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETITEM');
3612 if FMegaRulez
[MR_SUIT
] < gTime
+PLAYER_SUIT_TIME
then
3614 FMegaRulez
[MR_SUIT
] := gTime
+PLAYER_SUIT_TIME
;
3617 if gFlash
= 2 then Inc(FPickup
, 5);
3621 if FAir
< AIR_MAX
then
3626 if gFlash
= 2 then Inc(FPickup
, 5);
3631 if not (R_BERSERK
in FRulez
) then
3633 Include(FRulez
, R_BERSERK
);
3634 if FBFGFireCounter
= -1 then
3636 FCurrWeap
:= WEAPON_KASTET
;
3637 FModel
.SetWeapon(WEAPON_KASTET
);
3641 if gFlash
= 2 then Inc(FPickup
, 5);
3642 FBerserk
:= gTime
+30000;
3646 if FHealth
< PLAYER_HP_SOFT
then
3648 FHealth
:= PLAYER_HP_SOFT
;
3649 FBerserk
:= gTime
+30000;
3656 if FMegaRulez
[MR_INVUL
] < gTime
+PLAYER_INVUL_TIME
then
3658 FMegaRulez
[MR_INVUL
] := gTime
+PLAYER_INVUL_TIME
;
3661 if gFlash
= 2 then Inc(FPickup
, 5);
3665 if FHealth
< PLAYER_HP_LIMIT
then
3667 IncMax(FHealth
, 4, PLAYER_HP_LIMIT
);
3670 if gFlash
= 2 then Inc(FPickup
, 5);
3674 if FArmor
< PLAYER_AP_LIMIT
then
3676 IncMax(FArmor
, 5, PLAYER_AP_LIMIT
);
3679 if gFlash
= 2 then Inc(FPickup
, 5);
3683 if FJetFuel
< JET_MAX
then
3685 FJetFuel
:= JET_MAX
;
3688 if gFlash
= 2 then Inc(FPickup
, 5);
3692 if FMegaRulez
[MR_INVIS
] < gTime
+PLAYER_INVIS_TIME
then
3694 FMegaRulez
[MR_INVIS
] := gTime
+PLAYER_INVIS_TIME
;
3697 if gFlash
= 2 then Inc(FPickup
, 5);
3702 procedure TPlayer
.Touch();
3706 //FModel.PlaySound(MODELSOUND_PAIN, 1, FObj.X, FObj.Y);
3709 // Áðîñèòü ôëàã òîâàðèùó:
3710 if gGameSettings
.GameMode
= GM_CTF
then
3715 procedure TPlayer
.Push(vx
, vy
: Integer);
3717 if (not FPhysics
) and FGhost
then
3719 FObj
.Accel
.X
:= FObj
.Accel
.X
+ vx
;
3720 FObj
.Accel
.Y
:= FObj
.Accel
.Y
+ vy
;
3721 if g_Game_IsNet
and g_Game_IsServer
then
3722 MH_SEND_PlayerPos(True, FUID
, NET_EVERYONE
);
3725 procedure TPlayer
.Reset(Force
: Boolean);
3731 FTime
[T_RESPAWN
] := 0;
3732 FTime
[T_FLAGCAP
] := 0;
3745 FSpectator
:= False;
3748 FSpectatePlayer
:= -1;
3749 FNoRespawn
:= False;
3751 FLives
:= gGameSettings
.MaxLives
;
3756 procedure TPlayer
.SoftReset();
3762 FBFGFireCounter
:= -1;
3770 SetAction(A_STAND
, True);
3773 function TPlayer
.GetRespawnPoint(): Byte;
3778 // Íà áóäóùåå: FSpawn - èãðîê óæå èãðàë è ïåðåðîæäàåòñÿ
3780 // Îäèíî÷íàÿ èãðà/êîîïåðàòèâ
3781 if gGameSettings
.GameMode
in [GM_COOP
, GM_SINGLE
] then
3783 if (Self
= gPlayer1
) or (Self
= gPlayer2
) then
3785 // Òî÷êà ïîÿâëåíèÿ ñâîåãî èãðîêà
3786 if Self
= gPlayer1
then
3787 c
:= RESPAWNPOINT_PLAYER1
3789 c
:= RESPAWNPOINT_PLAYER2
;
3790 if g_Map_GetPointCount(c
) > 0 then
3796 // Òî÷êà ïîÿâëåíèÿ äðóãîãî èãðîêà
3797 if Self
= gPlayer1
then
3798 c
:= RESPAWNPOINT_PLAYER2
3800 c
:= RESPAWNPOINT_PLAYER1
;
3801 if g_Map_GetPointCount(c
) > 0 then
3808 // Òî÷êà ïîÿâëåíèÿ ëþáîãî èãðîêà (áîòà)
3809 if Random(2) = 0 then
3810 c
:= RESPAWNPOINT_PLAYER1
3812 c
:= RESPAWNPOINT_PLAYER2
;
3813 if g_Map_GetPointCount(c
) > 0 then
3820 // Òî÷êà ëþáîé èç êîìàíä
3821 if Random(2) = 0 then
3822 c
:= RESPAWNPOINT_RED
3824 c
:= RESPAWNPOINT_BLUE
;
3825 if g_Map_GetPointCount(c
) > 0 then
3832 c
:= RESPAWNPOINT_DM
;
3833 if g_Map_GetPointCount(c
) > 0 then
3841 if gGameSettings
.GameMode
= GM_DM
then
3844 c
:= RESPAWNPOINT_DM
;
3845 if g_Map_GetPointCount(c
) > 0 then
3851 // Òî÷êà ïîÿâëåíèÿ ëþáîãî èãðîêà
3852 if Random(2) = 0 then
3853 c
:= RESPAWNPOINT_PLAYER1
3855 c
:= RESPAWNPOINT_PLAYER2
;
3856 if g_Map_GetPointCount(c
) > 0 then
3862 // Òî÷êà ëþáîé èç êîìàíä
3863 if Random(2) = 0 then
3864 c
:= RESPAWNPOINT_RED
3866 c
:= RESPAWNPOINT_BLUE
;
3867 if g_Map_GetPointCount(c
) > 0 then
3875 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
3877 // Òî÷êà ñâîåé êîìàíäû
3878 c
:= RESPAWNPOINT_DM
;
3879 if FTeam
= TEAM_RED
then
3880 c
:= RESPAWNPOINT_RED
;
3881 if FTeam
= TEAM_BLUE
then
3882 c
:= RESPAWNPOINT_BLUE
;
3883 if g_Map_GetPointCount(c
) > 0 then
3890 c
:= RESPAWNPOINT_DM
;
3891 if g_Map_GetPointCount(c
) > 0 then
3897 // Òî÷êà ïîÿâëåíèÿ ëþáîãî èãðîêà
3898 if Random(2) = 0 then
3899 c
:= RESPAWNPOINT_PLAYER1
3901 c
:= RESPAWNPOINT_PLAYER2
;
3902 if g_Map_GetPointCount(c
) > 0 then
3908 // Òî÷êà äðóãîé êîìàíäû
3909 c
:= RESPAWNPOINT_DM
;
3910 if FTeam
= TEAM_RED
then
3911 c
:= RESPAWNPOINT_BLUE
;
3912 if FTeam
= TEAM_BLUE
then
3913 c
:= RESPAWNPOINT_RED
;
3914 if g_Map_GetPointCount(c
) > 0 then
3922 procedure TPlayer
.Respawn(Silent
: Boolean; Force
: Boolean = False);
3924 RespawnPoint
: TRespawnPoint
;
3929 if not g_Game_IsServer
then
3933 FWantsInGame
:= True;
3934 FJustTeleported
:= True;
3937 FTime
[T_RESPAWN
] := 0;
3941 // if server changes MaxLives we gotta be ready
3942 if gGameSettings
.MaxLives
= 0 then FNoRespawn
:= False;
3944 // Åùå íåëüçÿ âîçðîäèòüñÿ:
3945 if FTime
[T_RESPAWN
] > gTime
then
3948 // Ïðîñðàë âñå æèçíè:
3951 if not FSpectator
then Spectate(True);
3952 FWantsInGame
:= True;
3956 if (gGameSettings
.GameType
<> GT_SINGLE
) and (gGameSettings
.GameMode
<> GM_COOP
) then
3957 begin // "Ñâîÿ èãðà"
3958 // Áåðñåðê íå ñîõðàíÿåòñÿ ìåæäó óðîâíÿìè:
3959 FRulez
:= FRulez
-[R_BERSERK
];
3961 else // "Îäèíî÷íàÿ èãðà"/"Êîîï"
3963 // Áåðñåðê è êëþ÷è íå ñîõðàíÿþòñÿ ìåæäó óðîâíÿìè:
3964 FRulez
:= FRulez
-[R_KEY_RED
, R_KEY_GREEN
, R_KEY_BLUE
, R_BERSERK
];
3967 // Ïîëó÷àåì òî÷êó ñïàóíà èãðîêà:
3968 c
:= GetRespawnPoint();
3973 // Âîñêðåøåíèå áåç îðóæèÿ:
3976 FHealth
:= PLAYER_HP_SOFT
;
3982 for a
:= WEAPON_KASTET
to WEAPON_SUPERPULEMET
do
3984 FWeapon
[a
] := False;
3988 FWeapon
[WEAPON_PISTOL
] := True;
3989 FWeapon
[WEAPON_KASTET
] := True;
3990 FCurrWeap
:= WEAPON_PISTOL
;
3992 FModel
.SetWeapon(FCurrWeap
);
3994 for b
:= A_BULLETS
to A_CELLS
do
3997 FAmmo
[A_BULLETS
] := 50;
3999 FMaxAmmo
[A_BULLETS
] := 200;
4000 FMaxAmmo
[A_SHELLS
] := 50;
4001 FMaxAmmo
[A_ROCKETS
] := 50;
4002 FMaxAmmo
[A_CELLS
] := 300;
4004 if gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
] then
4005 FRulez
:= [R_KEY_RED
, R_KEY_GREEN
, R_KEY_BLUE
]
4010 // Ïîëó÷àåì êîîðäèíàòû òî÷êè âîçðîæäåíèÿ:
4011 if not g_Map_GetPoint(c
, RespawnPoint
) then
4013 g_FatalError(_lc
[I_GAME_ERROR_GET_SPAWN
]);
4017 // Óñòàíîâêà êîîðäèíàò è ñáðîñ âñåõ ïàðàìåòðîâ:
4018 FObj
.X
:= RespawnPoint
.X
-PLAYER_RECT
.X
;
4019 FObj
.Y
:= RespawnPoint
.Y
-PLAYER_RECT
.Y
;
4025 FDirection
:= RespawnPoint
.Direction
;
4026 if FDirection
= D_LEFT
then
4032 FBFGFireCounter
:= -1;
4037 SetAction(A_STAND
, True);
4038 FModel
.Direction
:= FDirection
;
4040 for a
:= Low(FTime
) to High(FTime
) do
4043 for a
:= Low(FMegaRulez
) to High(FMegaRulez
) do
4048 FCanJetpack
:= False;
4050 // Àíèìàöèÿ âîçðîæäåíèÿ:
4051 if (not gLoadGameMode
) and (not Silent
) then
4052 if g_Frames_Get(ID
, 'FRAMES_TELEPORT') then
4054 Anim
:= TAnimation
.Create(ID
, False, 3);
4055 g_GFX_OnceAnim(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-32,
4056 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)-32, Anim
);
4060 FSpectator
:= False;
4063 FSpectatePlayer
:= -1;
4066 if g_Game_IsNet
then
4068 MH_SEND_PlayerPos(True, FUID
, NET_EVERYONE
);
4069 MH_SEND_PlayerStats(FUID
, NET_EVERYONE
);
4071 MH_SEND_Effect(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-32,
4072 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)-32,
4077 procedure TPlayer
.Spectate(NoMove
: Boolean = False);
4080 Kill(K_EXTRAHARDKILL
, FUID
, HIT_SOME
)
4081 else if (not NoMove
) then
4083 GameX
:= gMapInfo
.Width
div 2;
4084 GameY
:= gMapInfo
.Height
div 2;
4093 FWantsInGame
:= False;
4098 if Self
= gPlayer1
then
4103 if Self
= gPlayer2
then
4110 if g_Game_IsNet
then
4111 MH_SEND_PlayerStats(FUID
);
4114 procedure TPlayer
.SwitchNoClip
;
4118 FGhost
:= not FGhost
;
4119 FPhysics
:= not FGhost
;
4131 procedure TPlayer
.Run(Direction
: TDirection
);
4135 if MAX_RUNVEL
> 8 then
4139 if Direction
= D_LEFT
then
4141 if FObj
.Vel
.X
> -MAX_RUNVEL
then
4142 FObj
.Vel
.X
:= FObj
.Vel
.X
- (MAX_RUNVEL
shr 3);
4145 if FObj
.Vel
.X
< MAX_RUNVEL
then
4146 FObj
.Vel
.X
:= FObj
.Vel
.X
+ (MAX_RUNVEL
shr 3);
4148 // Âîçìîæíî, ïèíàåì êóñêè:
4149 if (FObj
.Vel
.X
<> 0) and (gGibs
<> nil) then
4151 b
:= Abs(FObj
.Vel
.X
);
4152 if b
> 1 then b
:= b
* (Random(8 div b
) + 1);
4153 for a
:= 0 to High(gGibs
) do
4154 if gGibs
[a
].Live
and
4155 g_Obj_Collide(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
+FObj
.Rect
.Height
-4,
4156 FObj
.Rect
.Width
, 8, @gGibs
[a
].Obj
) and (Random(3) = 0) then
4158 if FObj
.Vel
.X
< 0 then
4159 g_Obj_PushA(@gGibs
[a
].Obj
, b
, Random(61)+120) // íàëåâî
4161 g_Obj_PushA(@gGibs
[a
].Obj
, b
, Random(61)); // íàïðàâî
4167 procedure TPlayer
.SeeDown();
4169 SetAction(A_SEEDOWN
);
4171 if FDirection
= D_LEFT
then FAngle
:= ANGLE_LEFTDOWN
else FAngle
:= ANGLE_RIGHTDOWN
;
4173 if FIncCam
> -120 then DecMin(FIncCam
, 5, -120);
4176 procedure TPlayer
.SeeUp();
4180 if FDirection
= D_LEFT
then FAngle
:= ANGLE_LEFTUP
else FAngle
:= ANGLE_RIGHTUP
;
4182 if FIncCam
< 120 then IncMax(FIncCam
, 5, 120);
4185 procedure TPlayer
.SetAction(Action
: Byte; Force
: Boolean = False);
4193 A_ATTACK
: Prior
:= 2;
4194 A_SEEUP
: Prior
:= 1;
4195 A_SEEDOWN
: Prior
:= 1;
4196 A_ATTACKUP
: Prior
:= 2;
4197 A_ATTACKDOWN
: Prior
:= 2;
4202 if (Prior
> FActionPrior
) or Force
then
4203 if not ((Prior
= 2) and (FCurrWeap
= WEAPON_SAW
)) then
4205 FActionPrior
:= Prior
;
4206 FActionAnim
:= Action
;
4207 FActionForce
:= Force
;
4208 FActionChanged
:= True;
4211 if Action
in [A_ATTACK
, A_ATTACKUP
, A_ATTACKDOWN
] then FModel
.SetFire(True);
4214 function TPlayer
.StayOnStep(XInc
, YInc
: Integer): Boolean;
4216 Result
:= not g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+YInc
+PLAYER_RECT
.Y
+PLAYER_RECT
.Height
-1,
4217 PLAYER_RECT
.Width
, 1, PANEL_STEP
, False)
4218 and g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+YInc
+PLAYER_RECT
.Y
+PLAYER_RECT
.Height
,
4219 PLAYER_RECT
.Width
, 1, PANEL_STEP
, False);
4222 function TPlayer
.TeleportTo(X
, Y
: Integer; silent
: Boolean; dir
: Byte): Boolean;
4229 if g_CollideLevel(X
, Y
, PLAYER_RECT
.Width
, PLAYER_RECT
.Height
) then
4231 g_Sound_PlayExAt('SOUND_GAME_NOTELEPORT', FObj
.X
, FObj
.Y
);
4232 if g_Game_IsServer
and g_Game_IsNet
then
4233 MH_SEND_Sound(FObj
.X
, FObj
.Y
, 'SOUND_GAME_NOTELEPORT');
4237 FJustTeleported
:= True;
4242 if g_Frames_Get(ID
, 'FRAMES_TELEPORT') then
4244 Anim
:= TAnimation
.Create(ID
, False, 3);
4247 g_Sound_PlayExAt('SOUND_GAME_TELEPORT', FObj
.X
, FObj
.Y
);
4248 g_GFX_OnceAnim(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-32,
4249 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)-32, Anim
);
4250 if g_Game_IsServer
and g_Game_IsNet
then
4251 MH_SEND_Effect(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-32,
4252 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)-32, 1,
4256 FObj
.X
:= X
-PLAYER_RECT
.X
;
4257 FObj
.Y
:= Y
-PLAYER_RECT
.Y
;
4258 if FLive
and FGhost
then
4264 if not g_Game_IsNet
then
4268 SetDirection(D_LEFT
);
4274 SetDirection(D_RIGHT
);
4280 if FDirection
= D_RIGHT
then
4282 SetDirection(D_LEFT
);
4287 SetDirection(D_RIGHT
);
4293 if not silent
and (Anim
<> nil) then
4295 g_GFX_OnceAnim(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-32,
4296 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)-32, Anim
);
4299 if g_Game_IsServer
and g_Game_IsNet
then
4300 MH_SEND_Effect(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-32,
4301 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)-32, 0,
4308 function nonz(a
: Single): Single;
4316 procedure TPlayer
.Update();
4319 i
, ii
, wx
, wy
, xd
, yd
, k
: Integer;
4320 blockmon
, headwater
, dospawn
: Boolean;
4325 NetServer
:= g_Game_IsNet
and g_Game_IsServer
;
4326 AnyServer
:= g_Game_IsServer
;
4328 if g_Game_IsClient
and (NetInterpLevel
> 0) then
4329 DoLerp(NetInterpLevel
+ 1)
4335 if FClientID
>= 0 then
4337 FPing
:= NetClients
[FClientID
].Peer
^.lastRoundTripTime
;
4338 if NetClients
[FClientID
].Peer
^.packetsSent
> 0 then
4339 FLoss
:= Round(100*NetClients
[FClientID
].Peer
^.packetsLost
/NetClients
[FClientID
].Peer
^.packetsSent
)
4348 if FLive
and (gFly
or FJetpack
) then
4351 if FDirection
= D_LEFT
then
4356 if FLive
and (not FGhost
) then
4358 if FKeys
[KEY_UP
].Pressed
then
4360 if FKeys
[KEY_DOWN
].Pressed
then
4364 if (not (FKeys
[KEY_UP
].Pressed
or FKeys
[KEY_DOWN
].Pressed
)) and
4367 i
:= g_basic
.Sign(FIncCam
);
4368 FIncCam
:= Abs(FIncCam
);
4369 DecMin(FIncCam
, 5, 0);
4370 FIncCam
:= FIncCam
*i
;
4373 if gTime
mod (GAME_TICK
*2) <> 0 then
4375 if (FObj
.Vel
.X
= 0) and FLive
then
4377 if FKeys
[KEY_LEFT
].Pressed
then
4379 if FKeys
[KEY_RIGHT
].Pressed
then
4384 g_Obj_Move(@FObj
, True, True, True);
4389 FActionChanged
:= False;
4393 // Let alive player do some actions
4394 if FKeys
[KEY_LEFT
].Pressed
then Run(D_LEFT
);
4395 if FKeys
[KEY_RIGHT
].Pressed
then Run(D_RIGHT
);
4396 if FKeys
[KEY_NEXTWEAPON
].Pressed
and AnyServer
then NextWeapon();
4397 if FKeys
[KEY_PREVWEAPON
].Pressed
and AnyServer
then PrevWeapon();
4398 if FKeys
[KEY_FIRE
].Pressed
and AnyServer
then Fire();
4399 if FKeys
[KEY_OPEN
].Pressed
and AnyServer
then Use();
4400 if FKeys
[KEY_JUMP
].Pressed
then Jump()
4403 if AnyServer
and FJetpack
then
4407 if NetServer
then MH_SEND_PlayerStats(FUID
);
4409 FCanJetpack
:= True;
4416 for k
:= Low(FKeys
) to KEY_CHAT
-1 do
4418 if FKeys
[k
].Pressed
then
4426 if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
4429 if (FTime
[T_RESPAWN
] <= gTime
) and
4430 gGameOn
and (not FLive
) then
4432 if (g_Player_GetCount() > 1) then
4436 gExit
:= EXIT_RESTART
;
4441 // Dead spectator actions
4444 if FKeys
[KEY_OPEN
].Pressed
and AnyServer
then Fire();
4445 if FKeys
[KEY_FIRE
].Pressed
and AnyServer
then
4449 if (FSpectatePlayer
>= High(gPlayers
)) then
4450 FSpectatePlayer
:= -1
4454 for I
:= FSpectatePlayer
+ 1 to High(gPlayers
) do
4455 if gPlayers
[I
] <> nil then
4456 if gPlayers
[I
].Live
then
4457 if gPlayers
[I
].UID
<> FUID
then
4459 FSpectatePlayer
:= I
;
4464 if not SetSpect
then FSpectatePlayer
:= -1;
4475 if FKeys
[KEY_UP
].Pressed
or FKeys
[KEY_JUMP
].Pressed
then
4477 FYTo
:= FObj
.Y
- 32;
4478 FSpectatePlayer
:= -1;
4480 if FKeys
[KEY_DOWN
].Pressed
then
4482 FYTo
:= FObj
.Y
+ 32;
4483 FSpectatePlayer
:= -1;
4485 if FKeys
[KEY_LEFT
].Pressed
then
4487 FXTo
:= FObj
.X
- 32;
4488 FSpectatePlayer
:= -1;
4490 if FKeys
[KEY_RIGHT
].Pressed
then
4492 FXTo
:= FObj
.X
+ 32;
4493 FSpectatePlayer
:= -1;
4496 if (FXTo
< -64) then
4498 else if (FXTo
> gMapInfo
.Width
+ 32) then
4499 FXTo
:= gMapInfo
.Width
+ 32;
4500 if (FYTo
< -72) then
4502 else if (FYTo
> gMapInfo
.Height
+ 32) then
4503 FYTo
:= gMapInfo
.Height
+ 32;
4507 g_Obj_Move(@FObj
, True, True, True)
4513 if (FSpectatePlayer
<= High(gPlayers
)) and (FSpectatePlayer
>= 0) then
4514 if gPlayers
[FSpectatePlayer
] <> nil then
4515 if gPlayers
[FSpectatePlayer
].Live
then
4517 FXTo
:= gPlayers
[FSpectatePlayer
].GameX
;
4518 FYTo
:= gPlayers
[FSpectatePlayer
].GameY
;
4522 blockmon
:= g_Map_CollidePanel(FObj
.X
+PLAYER_HEADRECT
.X
, FObj
.Y
+PLAYER_HEADRECT
.Y
,
4523 PLAYER_HEADRECT
.Width
, PLAYER_HEADRECT
.Height
,
4524 PANEL_BLOCKMON
, True);
4525 headwater
:= HeadInLiquid(0, 0);
4527 // Ñîïðîòèâëåíèå âîçäóõà:
4528 if (not FLive
) or not (FKeys
[KEY_LEFT
].Pressed
or FKeys
[KEY_RIGHT
].Pressed
) then
4529 if FObj
.Vel
.X
<> 0 then
4530 FObj
.Vel
.X
:= z_dec(FObj
.Vel
.X
, 1);
4532 if (FLastHit
= HIT_TRAP
) and (FPain
> 90) then FPain
:= 90;
4533 DecMin(FPain
, 5, 0);
4534 DecMin(FPickup
, 1, 0);
4536 if FLive
and (FObj
.Y
> gMapInfo
.Height
+128) and AnyServer
then
4538 // Îáíóëèòü äåéñòâèÿ ïðèìî÷åê, ÷òîáû ôîí ïðîïàë
4539 FMegaRulez
[MR_SUIT
] := 0;
4540 FMegaRulez
[MR_INVUL
] := 0;
4541 FMegaRulez
[MR_INVIS
] := 0;
4542 Kill(K_FALLKILL
, 0, HIT_FALL
);
4549 if FCurrWeap
= WEAPON_SAW
then
4550 if not (FSawSound
.IsPlaying() or FSawSoundHit
.IsPlaying() or
4551 FSawSoundSelect
.IsPlaying()) then
4552 FSawSoundIdle
.PlayAt(FObj
.X
, FObj
.Y
);
4555 if (not FJetSoundFly
.IsPlaying()) and (not FJetSoundOn
.IsPlaying()) and
4556 (not FJetSoundOff
.IsPlaying()) then
4558 FJetSoundFly
.SetPosition(0);
4559 FJetSoundFly
.PlayAt(FObj
.X
, FObj
.Y
);
4562 for b
:= WEAPON_KASTET
to WEAPON_SUPERPULEMET
do
4563 if FReloading
[b
] > 0 then
4569 if FShellTimer
> -1 then
4570 if FShellTimer
= 0 then
4572 if FShellType
= SHELL_SHELL
then
4573 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
4574 GameVelX
, GameVelY
-2, SHELL_SHELL
)
4575 else if FShellType
= SHELL_DBLSHELL
then
4577 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
4578 GameVelX
+1, GameVelY
-2, SHELL_SHELL
);
4579 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
4580 GameVelX
-1, GameVelY
-2, SHELL_SHELL
);
4583 end else Dec(FShellTimer
);
4585 if (FBFGFireCounter
> -1) then
4586 if FBFGFireCounter
= 0 then
4590 wx
:= FObj
.X
+WEAPONPOINT
[FDirection
].X
;
4591 wy
:= FObj
.Y
+WEAPONPOINT
[FDirection
].Y
;
4592 xd
:= wx
+IfThen(FDirection
= D_LEFT
, -30, 30);
4593 yd
:= wy
+firediry();
4594 g_Weapon_bfgshot(wx
, wy
, xd
, yd
, FUID
);
4595 if NetServer
then MH_SEND_PlayerFire(FUID
, WEAPON_BFG
, wx
, wy
, xd
, yd
);
4596 if (FAngle
= 0) or (FAngle
= 180) then SetAction(A_ATTACK
)
4597 else if (FAngle
= ANGLE_LEFTDOWN
) or (FAngle
= ANGLE_RIGHTDOWN
) then SetAction(A_ATTACKDOWN
)
4598 else if (FAngle
= ANGLE_LEFTUP
) or (FAngle
= ANGLE_RIGHTUP
) then SetAction(A_ATTACKUP
);
4601 FReloading
[WEAPON_BFG
] := WEAPON_RELOAD
[WEAPON_BFG
];
4602 FBFGFireCounter
:= -1;
4605 FBFGFireCounter
:= 0
4607 Dec(FBFGFireCounter
);
4609 if (FMegaRulez
[MR_SUIT
] < gTime
) and AnyServer
then
4611 b
:= g_GetAcidHit(FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+PLAYER_RECT
.Y
, PLAYER_RECT
.Width
, PLAYER_RECT
.Height
);
4613 if (b
> 0) and (gTime
mod (15*GAME_TICK
) = 0) then Damage(b
, 0, 0, 0, HIT_ACID
);
4616 if (headwater
or blockmon
) then
4622 if AnyServer
then Damage(10, 0, 0, 0, HIT_WATER
);
4625 else if (FAir
mod 31 = 0) and not blockmon
then
4627 g_GFX_Bubbles(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2), FObj
.Y
+PLAYER_RECT
.Y
-4, 5+Random(6), 8, 4);
4628 if Random(2) = 0 then
4629 g_Sound_PlayExAt('SOUND_GAME_BUBBLE1', FObj
.X
, FObj
.Y
)
4631 g_Sound_PlayExAt('SOUND_GAME_BUBBLE2', FObj
.X
, FObj
.Y
);
4633 end else if FAir
< AIR_DEF
then
4636 if FDamageBuffer
> 0 then
4638 if FDamageBuffer
>= 9 then
4642 if FDamageBuffer
< 30 then i
:= 9
4643 else if FDamageBuffer
< 100 then i
:= 18
4647 ii
:= Round(FDamageBuffer
*FHealth
/ nonz(FArmor
*(3/4)+FHealth
));
4648 FArmor
:= FArmor
-(FDamageBuffer
-ii
);
4649 FHealth
:= FHealth
-ii
;
4652 FHealth
:= FHealth
+FArmor
;
4657 if FHealth
<= 0 then
4658 if FHealth
> -30 then Kill(K_SIMPLEKILL
, FLastSpawnerUID
, FLastHit
)
4659 else if FHealth
> -50 then Kill(K_HARDKILL
, FLastSpawnerUID
, FLastHit
)
4660 else Kill(K_EXTRAHARDKILL
, FLastSpawnerUID
, FLastHit
);
4664 if FDamageBuffer
<= 20 then FModel
.PlaySound(MODELSOUND_PAIN
, 1, FObj
.X
, FObj
.Y
)
4665 else if FDamageBuffer
<= 55 then FModel
.PlaySound(MODELSOUND_PAIN
, 2, FObj
.X
, FObj
.Y
)
4666 else if FDamageBuffer
<= 120 then FModel
.PlaySound(MODELSOUND_PAIN
, 3, FObj
.X
, FObj
.Y
)
4667 else FModel
.PlaySound(MODELSOUND_PAIN
, 4, FObj
.X
, FObj
.Y
);
4674 end; // if FLive then ...
4676 if (FActionAnim
= A_PAIN
) and (FModel
.Animation
<> A_PAIN
) then
4678 FModel
.ChangeAnimation(FActionAnim
, FActionForce
);
4679 FModel
.GetCurrentAnimation
.MinLength
:= i
;
4680 FModel
.GetCurrentAnimationMask
.MinLength
:= i
;
4681 end else FModel
.ChangeAnimation(FActionAnim
, FActionForce
and (FModel
.Animation
<> A_STAND
));
4683 if (FModel
.GetCurrentAnimation
.Played
or ((not FActionChanged
) and (FModel
.Animation
= A_WALK
)))
4684 then SetAction(A_STAND
, True);
4686 if not ((FModel
.Animation
= A_WALK
) and (Abs(FObj
.Vel
.X
) < 4) and not FModel
.Fire
) then FModel
.Update
;
4688 for b
:= Low(FKeys
) to High(FKeys
) do
4689 if FKeys
[b
].Time
= 0 then FKeys
[b
].Pressed
:= False else Dec(FKeys
[b
].Time
);
4692 function TPlayer
.Collide(X
, Y
: Integer; Width
, Height
: Word): Boolean;
4694 Result
:= g_Collide(FObj
.X
+PLAYER_RECT
.X
,
4695 FObj
.Y
+PLAYER_RECT
.Y
,
4702 function TPlayer
.Collide(Panel
: TPanel
): Boolean;
4704 Result
:= g_Collide(FObj
.X
+PLAYER_RECT
.X
,
4705 FObj
.Y
+PLAYER_RECT
.Y
,
4709 Panel
.Width
, Panel
.Height
);
4712 function TPlayer
.Collide(X
, Y
: Integer): Boolean;
4714 X
:= X
-FObj
.X
-PLAYER_RECT
.X
;
4715 Y
:= Y
-FObj
.Y
-PLAYER_RECT
.Y
;
4716 Result
:= (x
>= 0) and (x
<= PLAYER_RECT
.Width
) and
4717 (y
>= 0) and (y
<= PLAYER_RECT
.Height
);
4720 function g_Player_ValidName(Name
: string): Boolean;
4726 if gPlayers
= nil then Exit
;
4728 for a
:= 0 to High(gPlayers
) do
4729 if gPlayers
[a
] <> nil then
4730 if LowerCase(Name
) = LowerCase(gPlayers
[a
].FName
) then
4737 procedure TPlayer
.SetDirection(Direction
: TDirection
);
4741 d
:= FModel
.Direction
;
4743 FModel
.Direction
:= Direction
;
4744 if d
<> Direction
then FModel
.ChangeAnimation(FModel
.Animation
, True);
4746 FDirection
:= Direction
;
4749 function TPlayer
.GetKeys(): Byte;
4753 if R_KEY_RED
in FRulez
then Result
:= KEY_RED
;
4754 if R_KEY_GREEN
in FRulez
then Result
:= Result
or KEY_GREEN
;
4755 if R_KEY_BLUE
in FRulez
then Result
:= Result
or KEY_BLUE
;
4757 if FTeam
= TEAM_RED
then Result
:= Result
or KEY_REDTEAM
;
4758 if FTeam
= TEAM_BLUE
then Result
:= Result
or KEY_BLUETEAM
;
4761 procedure TPlayer
.Use();
4765 if FTime
[T_USE
] > gTime
then Exit
;
4767 g_Triggers_PressR(FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+PLAYER_RECT
.Y
, PLAYER_RECT
.Width
,
4768 PLAYER_RECT
.Height
, FUID
, ACTIVATE_PLAYERPRESS
);
4770 for a
:= 0 to High(gPlayers
) do
4771 if (gPlayers
[a
] <> nil) and (gPlayers
[a
] <> Self
) and
4772 gPlayers
[a
].Live
and SameTeam(FUID
, gPlayers
[a
].FUID
) and
4773 g_Obj_Collide(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
,
4774 FObj
.Rect
.Width
, FObj
.Rect
.Height
, @gPlayers
[a
].FObj
) then
4776 gPlayers
[a
].Touch();
4777 if g_Game_IsNet
and g_Game_IsServer
then
4778 MH_SEND_GameEvent(NET_EV_PLAYER_TOUCH
, gPlayers
[a
].FUID
);
4781 FTime
[T_USE
] := gTime
+120;
4784 procedure TPlayer
.NetFire(Wpn
: Byte; X
, Y
, AX
, AY
: Integer; WID
: Integer = -1);
4788 WX
, WY
, XD
, YD
: Integer;
4799 if R_BERSERK
in FRulez
then
4801 //g_Weapon_punch(FObj.X+FObj.Rect.X, FObj.Y+FObj.Rect.Y, 75, FUID);
4802 obj
.X
:= FObj
.X
+FObj
.Rect
.X
;
4803 obj
.Y
:= FObj
.Y
+FObj
.Rect
.Y
;
4806 obj
.rect
.Width
:= 39;
4807 obj
.rect
.Height
:= 52;
4808 obj
.Vel
.X
:= (xd
-wx
) div 2;
4809 obj
.Vel
.Y
:= (yd
-wy
) div 2;
4810 obj
.Accel
.X
:= xd
-wx
;
4811 obj
.Accel
.y
:= yd
-wy
;
4813 if g_Weapon_Hit(@obj
, 50, FUID
, HIT_SOME
) <> 0 then
4814 g_Sound_PlayExAt('SOUND_WEAPON_HITBERSERK', FObj
.X
, FObj
.Y
)
4816 g_Sound_PlayExAt('SOUND_WEAPON_MISSBERSERK', FObj
.X
, FObj
.Y
);
4820 FPain
:= min(FPain
+ 25, 50);
4822 g_Weapon_punch(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
, 3, FUID
);
4827 if g_Weapon_chainsaw(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
,
4828 IfThen(gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
], 9, 3), FUID
) <> 0 then
4830 FSawSoundSelect
.Stop();
4832 FSawSoundHit
.PlayAt(FObj
.X
, FObj
.Y
);
4834 else if not FSawSoundHit
.IsPlaying() then
4836 FSawSoundSelect
.Stop();
4837 FSawSound
.PlayAt(FObj
.X
, FObj
.Y
);
4844 g_Sound_PlayExAt('SOUND_WEAPON_FIREPISTOL', GameX
, Gamey
);
4845 FFireAngle
:= FAngle
;
4847 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
4848 GameVelX
, GameVelY
-2, SHELL_BULLET
);
4853 g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN', Gamex
, Gamey
);
4854 FFireAngle
:= FAngle
;
4857 FShellType
:= SHELL_SHELL
;
4862 g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN2', Gamex
, Gamey
);
4863 FFireAngle
:= FAngle
;
4866 FShellType
:= SHELL_DBLSHELL
;
4871 g_Sound_PlayExAt('SOUND_WEAPON_FIRECGUN', Gamex
, Gamey
);
4872 FFireAngle
:= FAngle
;
4874 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
4875 GameVelX
, GameVelY
-2, SHELL_BULLET
);
4878 WEAPON_ROCKETLAUNCHER
:
4880 g_Weapon_Rocket(wx
, wy
, xd
, yd
, FUID
, WID
);
4881 FFireAngle
:= FAngle
;
4887 g_Weapon_Plasma(wx
, wy
, xd
, yd
, FUID
, WID
);
4888 FFireAngle
:= FAngle
;
4894 g_Weapon_BFGShot(wx
, wy
, xd
, yd
, FUID
, WID
);
4895 FFireAngle
:= FAngle
;
4899 WEAPON_SUPERPULEMET
:
4901 g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN', Gamex
, Gamey
);
4902 FFireAngle
:= FAngle
;
4904 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
4905 GameVelX
, GameVelY
-2, SHELL_SHELL
);
4911 if (FAngle
= 0) or (FAngle
= 180) then SetAction(A_ATTACK
)
4912 else if (FAngle
= ANGLE_LEFTDOWN
) or (FAngle
= ANGLE_RIGHTDOWN
) then SetAction(A_ATTACKDOWN
)
4913 else if (FAngle
= ANGLE_LEFTUP
) or (FAngle
= ANGLE_RIGHTUP
) then SetAction(A_ATTACKUP
);
4916 procedure TPlayer
.DoLerp(Level
: Integer = 2);
4918 if FObj
.X
<> FXTo
then FObj
.X
:= Lerp(FObj
.X
, FXTo
, Level
);
4919 if FObj
.Y
<> FYTo
then FObj
.Y
:= Lerp(FObj
.Y
, FYTo
, Level
);
4922 procedure TPlayer
.SetLerp(XTo
, YTo
: Integer);
4926 if NetInterpLevel
< 1 then
4936 AX
:= Abs(FXTo
- FObj
.X
);
4937 AY
:= Abs(FYTo
- FObj
.Y
);
4938 if (AX
> 32) or (AX
<= NetInterpLevel
) then
4940 if (AY
> 32) or (AY
<= NetInterpLevel
) then
4945 function TPlayer
.FullInLift(XInc
, YInc
: Integer): Integer;
4947 if g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
,
4948 PLAYER_RECT
.Width
, PLAYER_RECT
.Height
-8,
4949 PANEL_LIFTUP
, False) then Result
:= -1
4951 if g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
,
4952 PLAYER_RECT
.Width
, PLAYER_RECT
.Height
-8,
4953 PANEL_LIFTDOWN
, False) then Result
:= 1
4957 function TPlayer
.GetFlag(Flag
: Byte): Boolean;
4964 if Flag
= FLAG_NONE
then
4967 if not g_Game_IsServer
then Exit
;
4969 // Ïðèíåñ ÷óæîé ôëàã íà ñâîþ áàçó:
4970 if (Flag
= FTeam
) and
4971 (gFlags
[Flag
].State
= FLAG_STATE_NORMAL
) and
4972 (FFlag
<> FLAG_NONE
) then
4974 if FFlag
= FLAG_RED
then
4975 s
:= _lc
[I_PLAYER_FLAG_RED
]
4977 s
:= _lc
[I_PLAYER_FLAG_BLUE
];
4979 evtype
:= FLAG_STATE_SCORED
;
4981 ts
:= Format('%.4d', [gFlags
[FFlag
].CaptureTime
]);
4982 Insert('.', ts
, Length(ts
) + 1 - 3);
4983 g_Console_Add(Format(_lc
[I_PLAYER_FLAG_CAPTURE
], [FName
, s
, ts
]), True);
4985 g_Map_ResetFlag(FFlag
);
4986 g_Game_Message(Format(_lc
[I_MESSAGE_FLAG_CAPTURE
], [AnsiUpperCase(s
)]), 144);
4988 gTeamStat
[FTeam
].Goals
:= gTeamStat
[FTeam
].Goals
+ 1;
4991 if g_Game_IsNet
then
4993 MH_SEND_FlagEvent(evtype
, FFlag
, FUID
, False);
4997 gFlags
[FFlag
].CaptureTime
:= 0;
5002 // Ïîäîáðàë ñâîé ôëàã - âåðíóë åãî íà áàçó:
5003 if (Flag
= FTeam
) and
5004 (gFlags
[Flag
].State
= FLAG_STATE_DROPPED
) then
5006 if Flag
= FLAG_RED
then
5007 s
:= _lc
[I_PLAYER_FLAG_RED
]
5009 s
:= _lc
[I_PLAYER_FLAG_BLUE
];
5011 evtype
:= FLAG_STATE_RETURNED
;
5012 gFlags
[Flag
].CaptureTime
:= 0;
5014 g_Console_Add(Format(_lc
[I_PLAYER_FLAG_RETURN
], [FName
, s
]), True);
5016 g_Map_ResetFlag(Flag
);
5017 g_Game_Message(Format(_lc
[I_MESSAGE_FLAG_RETURN
], [AnsiUpperCase(s
)]), 144);
5020 if g_Game_IsNet
then
5022 MH_SEND_FlagEvent(evtype
, Flag
, FUID
, False);
5028 // Ïîäîáðàë ÷óæîé ôëàã:
5029 if (Flag
<> FTeam
) and (FTime
[T_FLAGCAP
] <= gTime
) then
5033 if Flag
= FLAG_RED
then
5034 s
:= _lc
[I_PLAYER_FLAG_RED
]
5036 s
:= _lc
[I_PLAYER_FLAG_BLUE
];
5038 evtype
:= FLAG_STATE_CAPTURED
;
5040 g_Console_Add(Format(_lc
[I_PLAYER_FLAG_GET
], [FName
, s
]), True);
5042 g_Game_Message(Format(_lc
[I_MESSAGE_FLAG_GET
], [AnsiUpperCase(s
)]), 144);
5044 gFlags
[Flag
].State
:= FLAG_STATE_CAPTURED
;
5047 if g_Game_IsNet
then
5049 MH_SEND_FlagEvent(evtype
, Flag
, FUID
, False);
5055 procedure TPlayer
.SetFlag(Flag
: Byte);
5058 if FModel
<> nil then
5059 FModel
.SetFlag(FFlag
);
5062 function TPlayer
.DropFlag(): Boolean;
5067 if (not g_Game_IsServer
) or (FFlag
= FLAG_NONE
) then
5069 FTime
[T_FLAGCAP
] := gTime
+ 2000;
5070 with gFlags
[FFlag
] do
5074 Direction
:= FDirection
;
5075 State
:= FLAG_STATE_DROPPED
;
5077 g_Obj_Push(@Obj
, (FObj
.Vel
.X
div 2)-2+Random(5),
5078 (FObj
.Vel
.Y
div 2)-2+Random(5));
5080 if FFlag
= FLAG_RED
then
5081 s
:= _lc
[I_PLAYER_FLAG_RED
]
5083 s
:= _lc
[I_PLAYER_FLAG_BLUE
];
5085 g_Console_Add(Format(_lc
[I_PLAYER_FLAG_DROP
], [FName
, s
]), True);
5086 g_Game_Message(Format(_lc
[I_MESSAGE_FLAG_DROP
], [AnsiUpperCase(s
)]), 144);
5088 if g_Game_IsNet
then
5089 MH_SEND_FlagEvent(FLAG_STATE_DROPPED
, Flag
, FUID
, False);
5095 procedure TPlayer
.GetSecret();
5100 procedure TPlayer
.PressKey(Key
: Byte; Time
: Word = 1);
5102 Assert(Key
<= High(FKeys
));
5104 FKeys
[Key
].Pressed
:= True;
5105 FKeys
[Key
].Time
:= Time
;
5108 function TPlayer
.IsKeyPressed(K
: Byte): Boolean;
5110 Result
:= FKeys
[K
].Pressed
;
5113 procedure TPlayer
.ReleaseKeys();
5117 for a
:= Low(FKeys
) to High(FKeys
) do
5119 FKeys
[a
].Pressed
:= False;
5124 procedure TPlayer
.OnDamage(Angle
: SmallInt);
5128 function TPlayer
.firediry(): Integer;
5130 if FKeys
[KEY_UP
].Pressed
then Result
:= -42
5131 else if FKeys
[KEY_DOWN
].Pressed
then Result
:= 19
5135 procedure TPlayer
.RememberState();
5139 FSavedState
.Health
:= FHealth
;
5140 FSavedState
.Armor
:= FArmor
;
5141 FSavedState
.Air
:= FAir
;
5142 FSavedState
.JetFuel
:= FJetFuel
;
5143 FSavedState
.CurrWeap
:= FCurrWeap
;
5146 FSavedState
.Ammo
[i
] := FAmmo
[i
];
5148 FSavedState
.MaxAmmo
[i
] := FMaxAmmo
[i
];
5150 FSavedState
.Rulez
:= FRulez
;
5151 FSavedState
.WaitRecall
:= True;
5154 procedure TPlayer
.RecallState();
5158 if not FSavedState
.WaitRecall
then Exit
;
5160 FHealth
:= FSavedState
.Health
;
5161 FArmor
:= FSavedState
.Armor
;
5162 FAir
:= FSavedState
.Air
;
5163 FJetFuel
:= FSavedState
.JetFuel
;
5164 FCurrWeap
:= FSavedState
.CurrWeap
;
5167 FAmmo
[i
] := FSavedState
.Ammo
[i
];
5169 FMaxAmmo
[i
] := FSavedState
.MaxAmmo
[i
];
5171 FRulez
:= FSavedState
.Rulez
;
5172 FSavedState
.WaitRecall
:= False;
5174 if gGameSettings
.GameType
= GT_SERVER
then
5175 MH_SEND_PlayerStats(FUID
);
5178 procedure TPlayer
.SaveState(var Mem
: TBinMemoryWriter
);
5190 Mem
:= TBinMemoryWriter
.Create(i
);
5192 // Ñèãíàòóðà èãðîêà:
5193 sig
:= PLAYER_SIGNATURE
; // 'PLYR'
5194 Mem
.WriteDWORD(sig
);
5196 Mem
.WriteBoolean(FIamBot
);
5198 Mem
.WriteWord(FUID
);
5200 Mem
.WriteString(FName
, 32);
5202 Mem
.WriteByte(FTeam
);
5204 Mem
.WriteBoolean(FLive
);
5205 // Èçðàñõîäîâàë ëè âñå æèçíè:
5206 Mem
.WriteBoolean(FNoRespawn
);
5208 if FDirection
= D_LEFT
then
5214 Mem
.WriteInt(FHealth
);
5216 Mem
.WriteByte(FLives
);
5218 Mem
.WriteInt(FArmor
);
5222 Mem
.WriteInt(FJetFuel
);
5224 Mem
.WriteInt(FPain
);
5226 Mem
.WriteInt(FKills
);
5228 Mem
.WriteInt(FMonsterKills
);
5230 Mem
.WriteInt(FFrags
);
5232 Mem
.WriteByte(FFragCombo
);
5233 // Âðåìÿ ïîñëåäíåãî ôðàãà:
5234 Mem
.WriteDWORD(FLastFrag
);
5236 Mem
.WriteInt(FDeath
);
5237 // Êàêîé ôëàã íåñåò:
5238 Mem
.WriteByte(FFlag
);
5240 Mem
.WriteInt(FSecrets
);
5242 Mem
.WriteByte(FCurrWeap
);
5243 // Âðåìÿ çàðÿäêè BFG:
5244 Mem
.WriteSmallInt(FBFGFireCounter
);
5246 Mem
.WriteInt(FDamageBuffer
);
5247 // Ïîñëåäíèé óäàðèâøèé:
5248 Mem
.WriteWord(FLastSpawnerUID
);
5249 // Òèï ïîñëåäíåãî ïîëó÷åííîãî óðîíà:
5250 Mem
.WriteByte(FLastHit
);
5252 Obj_SaveState(@FObj
, Mem
);
5253 // Òåêóùåå êîëè÷åñòâî ïàòðîíîâ:
5254 for i
:= A_BULLETS
to A_CELLS
do
5255 Mem
.WriteWord(FAmmo
[i
]);
5256 // Ìàêñèìàëüíîå êîëè÷åñòâî ïàòðîíîâ:
5257 for i
:= A_BULLETS
to A_CELLS
do
5258 Mem
.WriteWord(FMaxAmmo
[i
]);
5260 for i
:= WEAPON_KASTET
to WEAPON_SUPERPULEMET
do
5261 Mem
.WriteBoolean(FWeapon
[i
]);
5262 // Âðåìÿ ïåðåçàðÿäêè îðóæèÿ:
5263 for i
:= WEAPON_KASTET
to WEAPON_SUPERPULEMET
do
5264 Mem
.WriteWord(FReloading
[i
]);
5266 if R_ITEM_BACKPACK
in FRulez
then
5271 // Íàëè÷èå êðàñíîãî êëþ÷à:
5272 if R_KEY_RED
in FRulez
then
5277 // Íàëè÷èå çåëåíîãî êëþ÷à:
5278 if R_KEY_GREEN
in FRulez
then
5283 // Íàëè÷èå ñèíåãî êëþ÷à:
5284 if R_KEY_BLUE
in FRulez
then
5289 // Íàëè÷èå áåðñåðêà:
5290 if R_BERSERK
in FRulez
then
5295 // Âðåìÿ äåéñòâèÿ ñïåöèàëüíûõ ïðåäìåòîâ:
5296 for i
:= MR_SUIT
to MR_MAX
do
5297 Mem
.WriteDWORD(FMegaRulez
[i
]);
5298 // Âðåìÿ äî ïîâòîðíîãî ðåñïàóíà, ñìåíû îðóæèÿ, èñîëüçîâàíèÿ, çàõâàòà ôëàãà:
5299 for i
:= T_RESPAWN
to T_FLAGCAP
do
5300 Mem
.WriteDWORD(FTime
[i
]);
5303 Mem
.WriteString(str
);
5313 procedure TPlayer
.LoadState(var Mem
: TBinMemoryReader
);
5323 // Ñèãíàòóðà èãðîêà:
5325 if sig
<> PLAYER_SIGNATURE
then // 'PLYR'
5327 raise EBinSizeError
.Create('TPlayer.LoadState: Wrong Player Signature');
5330 Mem
.ReadBoolean(FIamBot
);
5334 Mem
.ReadString(str
);
5335 if (Self
<> gPlayer1
) and (Self
<> gPlayer2
) then
5338 Mem
.ReadByte(FTeam
);
5340 Mem
.ReadBoolean(FLive
);
5341 // Èçðàñõîäîâàë ëè âñå æèçíè:
5342 Mem
.ReadBoolean(FNoRespawn
);
5346 FDirection
:= D_LEFT
5348 FDirection
:= D_RIGHT
;
5350 Mem
.ReadInt(FHealth
);
5352 Mem
.ReadByte(FLives
);
5354 Mem
.ReadInt(FArmor
);
5358 Mem
.ReadInt(FJetFuel
);
5362 Mem
.ReadInt(FKills
);
5364 Mem
.ReadInt(FMonsterKills
);
5366 Mem
.ReadInt(FFrags
);
5368 Mem
.ReadByte(FFragCombo
);
5369 // Âðåìÿ ïîñëåäíåãî ôðàãà:
5370 Mem
.ReadDWORD(FLastFrag
);
5372 Mem
.ReadInt(FDeath
);
5373 // Êàêîé ôëàã íåñåò:
5374 Mem
.ReadByte(FFlag
);
5376 Mem
.ReadInt(FSecrets
);
5378 Mem
.ReadByte(FCurrWeap
);
5379 // Âðåìÿ çàðÿäêè BFG:
5380 Mem
.ReadSmallInt(FBFGFireCounter
);
5382 Mem
.ReadInt(FDamageBuffer
);
5383 // Ïîñëåäíèé óäàðèâøèé:
5384 Mem
.ReadWord(FLastSpawnerUID
);
5385 // Òèï ïîñëåäíåãî ïîëó÷åííîãî óðîíà:
5386 Mem
.ReadByte(FLastHit
);
5388 Obj_LoadState(@FObj
, Mem
);
5389 // Òåêóùåå êîëè÷åñòâî ïàòðîíîâ:
5390 for i
:= A_BULLETS
to A_CELLS
do
5391 Mem
.ReadWord(FAmmo
[i
]);
5392 // Ìàêñèìàëüíîå êîëè÷åñòâî ïàòðîíîâ:
5393 for i
:= A_BULLETS
to A_CELLS
do
5394 Mem
.ReadWord(FMaxAmmo
[i
]);
5396 for i
:= WEAPON_KASTET
to WEAPON_SUPERPULEMET
do
5397 Mem
.ReadBoolean(FWeapon
[i
]);
5398 // Âðåìÿ ïåðåçàðÿäêè îðóæèÿ:
5399 for i
:= WEAPON_KASTET
to WEAPON_SUPERPULEMET
do
5400 Mem
.ReadWord(FReloading
[i
]);
5404 Include(FRulez
, R_ITEM_BACKPACK
);
5405 // Íàëè÷èå êðàñíîãî êëþ÷à:
5408 Include(FRulez
, R_KEY_RED
);
5409 // Íàëè÷èå çåëåíîãî êëþ÷à:
5412 Include(FRulez
, R_KEY_GREEN
);
5413 // Íàëè÷èå ñèíåãî êëþ÷à:
5416 Include(FRulez
, R_KEY_BLUE
);
5417 // Íàëè÷èå áåðñåðêà:
5420 Include(FRulez
, R_BERSERK
);
5421 // Âðåìÿ äåéñòâèÿ ñïåöèàëüíûõ ïðåäìåòîâ:
5422 for i
:= MR_SUIT
to MR_MAX
do
5423 Mem
.ReadDWORD(FMegaRulez
[i
]);
5424 // Âðåìÿ äî ïîâòîðíîãî ðåñïàóíà, ñìåíû îðóæèÿ, èñîëüçîâàíèÿ, çàõâàòà ôëàãà:
5425 for i
:= T_RESPAWN
to T_FLAGCAP
do
5426 Mem
.ReadDWORD(FTime
[i
]);
5428 Mem
.ReadString(str
);
5430 Mem
.ReadByte(FColor
.R
);
5431 Mem
.ReadByte(FColor
.G
);
5432 Mem
.ReadByte(FColor
.B
);
5433 if Self
= gPlayer1
then
5435 str
:= gPlayer1Settings
.Model
;
5436 FColor
:= gPlayer1Settings
.Color
;
5438 if Self
= gPlayer2
then
5440 str
:= gPlayer2Settings
.Model
;
5441 FColor
:= gPlayer2Settings
.Color
;
5443 // Îáíîâëÿåì ìîäåëü èãðîêà:
5445 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
5446 FModel
.Color
:= TEAMCOLOR
[FTeam
]
5448 FModel
.Color
:= FColor
;
5451 procedure TPlayer
.AllRulez(Health
: Boolean);
5457 FHealth
:= PLAYER_HP_LIMIT
;
5458 FArmor
:= PLAYER_AP_LIMIT
;
5462 for a
:= WEAPON_KASTET
to WEAPON_SUPERPULEMET
do FWeapon
[a
] := True;
5463 for a
:= A_BULLETS
to A_CELLS
do FAmmo
[a
] := 30000;
5464 FRulez
:= FRulez
+[R_KEY_RED
, R_KEY_GREEN
, R_KEY_BLUE
];
5467 procedure TPlayer
.FragCombo();
5471 if (gGameSettings
.GameMode
in [GM_COOP
, GM_SINGLE
]) or g_Game_IsClient
then
5473 if gTime
- FLastFrag
< FRAG_COMBO_TIME
then
5475 if FFragCombo
< 5 then
5477 Param
:= FUID
or (FFragCombo
shl 16);
5478 if (FComboEvnt
>= Low(gDelayedEvents
)) and
5479 (FComboEvnt
<= High(gDelayedEvents
)) and
5480 gDelayedEvents
[FComboEvnt
].Pending
and
5481 (gDelayedEvents
[FComboEvnt
].DEType
= DE_KILLCOMBO
) and
5482 (gDelayedEvents
[FComboEvnt
].DENum
and $FFFF = FUID
) then
5484 gDelayedEvents
[FComboEvnt
].Time
:= gTime
+ 500;
5485 gDelayedEvents
[FComboEvnt
].DENum
:= Param
;
5488 FComboEvnt
:= g_Game_DelayEvent(DE_KILLCOMBO
, 500, Param
);
5496 procedure TPlayer
.GiveItem(ItemType
: Byte);
5500 if FMegaRulez
[MR_SUIT
] < gTime
+PLAYER_SUIT_TIME
then
5502 FMegaRulez
[MR_SUIT
] := gTime
+PLAYER_SUIT_TIME
;
5506 if FAir
< AIR_MAX
then
5513 if not (R_BERSERK
in FRulez
) then
5515 Include(FRulez
, R_BERSERK
);
5516 if FBFGFireCounter
< 1 then
5518 FCurrWeap
:= WEAPON_KASTET
;
5519 FModel
.SetWeapon(WEAPON_KASTET
);
5523 FBerserk
:= gTime
+30000;
5525 if FHealth
< PLAYER_HP_SOFT
then
5527 FHealth
:= PLAYER_HP_SOFT
;
5528 FBerserk
:= gTime
+30000;
5533 if FMegaRulez
[MR_INVUL
] < gTime
+PLAYER_INVUL_TIME
then
5535 FMegaRulez
[MR_INVUL
] := gTime
+PLAYER_INVUL_TIME
;
5539 if FMegaRulez
[MR_INVIS
] < gTime
+PLAYER_INVIS_TIME
then
5541 FMegaRulez
[MR_INVIS
] := gTime
+PLAYER_INVIS_TIME
;
5545 if FJetFuel
< JET_MAX
then
5547 FJetFuel
:= JET_MAX
;
5553 if g_Game_IsNet
and g_Game_IsServer
then
5554 MH_SEND_PlayerStats(FUID
);
5557 procedure TPlayer
.FlySmoke(Times
: DWORD
= 1);
5562 if (Random(5) = 1) and (Times
= 1) then
5565 if BodyInLiquid(0, 0) then
5567 g_GFX_Bubbles(Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2)+Random(3)-1,
5568 Obj
.Y
+Obj
.Rect
.Height
+8, 1, 8, 4);
5569 if Random(2) = 0 then
5570 g_Sound_PlayExAt('SOUND_GAME_BUBBLE1', FObj
.X
, FObj
.Y
)
5572 g_Sound_PlayExAt('SOUND_GAME_BUBBLE2', FObj
.X
, FObj
.Y
);
5576 if g_Frames_Get(id
, 'FRAMES_SMOKE') then
5578 for i
:= 1 to Times
do
5580 Anim
:= TAnimation
.Create(id
, False, 3);
5582 g_GFX_OnceAnim(Obj
.X
+Obj
.Rect
.X
+Random(Obj
.Rect
.Width
+Times
*2)-(Anim
.Width
div 2),
5583 Obj
.Y
+Obj
.Rect
.Height
-4+Random(8+Times
*2), Anim
, ONCEANIM_SMOKE
);
5589 procedure TPlayer
.PauseSounds(Enable
: Boolean);
5591 FSawSound
.Pause(Enable
);
5592 FSawSoundIdle
.Pause(Enable
);
5593 FSawSoundHit
.Pause(Enable
);
5594 FSawSoundSelect
.Pause(Enable
);
5599 constructor TCorpse
.Create(X
, Y
: Integer; ModelName
: String; aMess
: Boolean);
5604 FObj
.Rect
:= PLAYER_CORPSERECT
;
5605 FModelName
:= ModelName
;
5610 FState
:= CORPSE_STATE_MESS
;
5611 g_PlayerModel_GetAnim(ModelName
, A_DIE2
, FAnimation
, FAnimationMask
);
5615 FState
:= CORPSE_STATE_NORMAL
;
5616 g_PlayerModel_GetAnim(ModelName
, A_DIE1
, FAnimation
, FAnimationMask
);
5620 destructor TCorpse
.Destroy();
5627 procedure TCorpse
.Damage(Value
: Word; vx
, vy
: Integer);
5631 if FState
= CORPSE_STATE_REMOVEME
then
5634 FDamage
:= FDamage
+ Value
;
5636 if FDamage
> 150 then
5638 if FAnimation
<> nil then
5643 FState
:= CORPSE_STATE_REMOVEME
;
5645 g_Player_CreateGibs(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
5646 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2),
5647 FModelName
, FColor
);
5648 pm
:= g_PlayerModel_Get(FModelName
);
5649 pm
.PlaySound(MODELSOUND_DIE
, 3, FObj
.X
, FObj
.Y
);
5655 FObj
.Vel
.X
:= FObj
.Vel
.X
+ vx
;
5656 FObj
.Vel
.Y
:= FObj
.Vel
.Y
+ vy
;
5657 g_GFX_Blood(FObj
.X
+PLAYER_CORPSERECT
.X
+(PLAYER_CORPSERECT
.Width
div 2),
5658 FObj
.Y
+PLAYER_CORPSERECT
.Y
+(PLAYER_CORPSERECT
.Height
div 2),
5659 Value
, vx
, vy
, 16, (PLAYER_CORPSERECT
.Height
*2) div 3,
5664 procedure TCorpse
.Draw();
5666 if FState
= CORPSE_STATE_REMOVEME
then
5669 if FAnimation
<> nil then
5670 FAnimation
.Draw(FObj
.X
, FObj
.Y
, M_NONE
);
5672 if FAnimationMask
<> nil then
5675 FAnimationMask
.Draw(FObj
.X
, FObj
.Y
, M_NONE
);
5682 procedure TCorpse
.Update();
5686 if FState
= CORPSE_STATE_REMOVEME
then
5689 if gTime
mod (GAME_TICK
*2) <> 0 then
5691 g_Obj_Move(@FObj
, True, True, True);
5696 // Ñîïðîòèâëåíèå âîçäóõà äëÿ òðóïà:
5697 FObj
.Vel
.X
:= z_dec(FObj
.Vel
.X
, 1);
5699 st
:= g_Obj_Move(@FObj
, True, True, True);
5701 if WordBool(st
and MOVE_FALLOUT
) then
5703 FState
:= CORPSE_STATE_REMOVEME
;
5707 if FAnimation
<> nil then
5708 FAnimation
.Update();
5709 if FAnimationMask
<> nil then
5710 FAnimationMask
.Update();
5713 procedure TCorpse
.SaveState(var Mem
: TBinMemoryWriter
);
5722 sig
:= CORPSE_SIGNATURE
; // 'CORP'
5723 Mem
.WriteDWORD(sig
);
5725 Mem
.WriteByte(FState
);
5726 // Íàêîïëåííûé óðîí:
5727 Mem
.WriteByte(FDamage
);
5729 Mem
.WriteByte(FColor
.R
);
5730 Mem
.WriteByte(FColor
.G
);
5731 Mem
.WriteByte(FColor
.B
);
5733 Obj_SaveState(@FObj
, Mem
);
5734 // Åñòü ëè àíèìàöèÿ:
5735 anim
:= FAnimation
<> nil;
5736 Mem
.WriteBoolean(anim
);
5737 // Åñëè åñòü - ñîõðàíÿåì:
5739 FAnimation
.SaveState(Mem
);
5740 // Åñòü ëè ìàñêà àíèìàöèè:
5741 anim
:= FAnimationMask
<> nil;
5742 Mem
.WriteBoolean(anim
);
5743 // Åñëè åñòü - ñîõðàíÿåì:
5745 FAnimationMask
.SaveState(Mem
);
5748 procedure TCorpse
.LoadState(var Mem
: TBinMemoryReader
);
5758 if sig
<> CORPSE_SIGNATURE
then // 'CORP'
5760 raise EBinSizeError
.Create('TCorpse.LoadState: Wrong Corpse Signature');
5763 Mem
.ReadByte(FState
);
5764 // Íàêîïëåííûé óðîí:
5765 Mem
.ReadByte(FDamage
);
5767 Mem
.ReadByte(FColor
.R
);
5768 Mem
.ReadByte(FColor
.G
);
5769 Mem
.ReadByte(FColor
.B
);
5771 Obj_LoadState(@FObj
, Mem
);
5772 // Åñòü ëè àíèìàöèÿ:
5773 Mem
.ReadBoolean(anim
);
5774 // Åñëè åñòü - çàãðóæàåì:
5777 Assert(FAnimation
<> nil, 'TCorpse.LoadState: no FAnimation');
5778 FAnimation
.LoadState(Mem
);
5780 // Åñòü ëè ìàñêà àíèìàöèè:
5781 Mem
.ReadBoolean(anim
);
5782 // Åñëè åñòü - çàãðóæàåì:
5785 Assert(FAnimationMask
<> nil, 'TCorpse.LoadState: no FAnimationMask');
5786 FAnimationMask
.LoadState(Mem
);
5792 constructor TBot
.Create();
5799 FSpectator
:= False;
5806 for a
:= WEAPON_KASTET
to WEAPON_SUPERPULEMET
do
5808 FDifficult
.WeaponPrior
[a
] := WEAPON_PRIOR1
[a
];
5809 FDifficult
.CloseWeaponPrior
[a
] := WEAPON_PRIOR2
[a
];
5810 //FDifficult.SafeWeaponPrior[a] := WEAPON_PRIOR3[a];
5814 destructor TBot
.Destroy();
5817 inherited Destroy();
5820 procedure TBot
.Draw();
5824 //if FTargetUID <> 0 then e_DrawLine(1, FObj.X, FObj.Y, g_Player_Get(FTargetUID).FObj.X,
5825 // g_Player_Get(FTargetUID).FObj.Y, 255, 0, 0);
5828 procedure TBot
.Respawn(Silent
: Boolean; Force
: Boolean = False);
5830 inherited Respawn(Silent
, Force
);
5833 FSelectedWeapon
:= FCurrWeap
;
5837 procedure TBot
.UpdateCombat();
5850 TTargetRecord
= array of TTarget
;
5852 function Compare(a
, b
: TTarget
): Integer;
5854 if a
.Line
and not b
.Line
then // A íà ëèíèè îãíÿ
5857 if not a
.Line
and b
.Line
then // B íà ëèíèè îãíÿ
5859 else // È A, è B íà ëèíèè èëè íå íà ëèíèè îãíÿ
5860 if (a
.Line
and b
.Line
) or ((not a
.Line
) and (not b
.Line
)) then
5862 if a
.Dist
> b
.Dist
then // B áëèæå
5864 else // A áëèæå èëè ðàâíîóäàëåííî ñ B
5867 else // Ñòðàííî -> A
5872 a
, x1
, y1
, x2
, y2
: Integer;
5873 targets
: TTargetRecord
;
5875 Target
, BestTarget
: TTarget
;
5876 firew
, fireh
: Integer;
5880 vsPlayer
, vsMonster
, ok
: Boolean;
5882 vsPlayer
:= LongBool(gGameSettings
.Options
and GAME_OPTION_BOTVSPLAYER
);
5883 vsMonster
:= LongBool(gGameSettings
.Options
and GAME_OPTION_BOTVSMONSTER
);
5885 // Åñëè òåêóùåå îðóæèå íå òî, ÷òî íóæíî, òî ìåíÿåì:
5886 if FCurrWeap
<> FSelectedWeapon
then
5889 // Åñëè íóæíî ñòðåëÿòü è íóæíîå îðóæèå, òî íàæàòü "Ñòðåëÿòü":
5890 if (GetAIFlag('NEEDFIRE') <> '') and (FCurrWeap
= FSelectedWeapon
) then
5892 RemoveAIFlag('NEEDFIRE');
5895 WEAPON_PLASMA
, WEAPON_SUPERPULEMET
, WEAPON_CHAINGUN
: PressKey(KEY_FIRE
, 20);
5896 WEAPON_SAW
, WEAPON_KASTET
, WEAPON_MEGAKASTET
: PressKey(KEY_FIRE
, 40);
5897 else PressKey(KEY_FIRE
);
5901 // Êîîðäèíàòû ñòâîëà:
5902 x1
:= FObj
.X
+ WEAPONPOINT
[FDirection
].X
;
5903 y1
:= FObj
.Y
+ WEAPONPOINT
[FDirection
].Y
;
5905 Target
.UID
:= FTargetUID
;
5908 if Target
.UID
<> 0 then
5909 begin // Öåëü åñòü - íàñòðàèâàåì
5910 if (g_GetUIDType(Target
.UID
) = UID_PLAYER
) and
5913 with g_Player_Get(Target
.UID
) do
5915 if (@FObj
) <> nil then
5922 Target
.cX
:= Target
.X
+ PLAYER_RECT_CX
;
5923 Target
.cY
:= Target
.Y
+ PLAYER_RECT_CY
;
5924 Target
.Rect
:= PLAYER_RECT
;
5925 Target
.Visible
:= g_TraceVector(x1
, y1
, Target
.cX
, Target
.cY
);
5926 Target
.Line
:= (y1
+4 < Target
.Y
+PLAYER_RECT
.Y
+PLAYER_RECT
.Height
) and
5927 (y1
-4 > Target
.Y
+PLAYER_RECT
.Y
);
5928 Target
.IsPlayer
:= True;
5932 if (g_GetUIDType(Target
.UID
) = UID_MONSTER
) and
5935 mon
:= g_Monsters_Get(Target
.UID
);
5938 Target
.X
:= mon
.Obj
.X
;
5939 Target
.Y
:= mon
.Obj
.Y
;
5941 Target
.cX
:= Target
.X
+ mon
.Obj
.Rect
.X
+ (mon
.Obj
.Rect
.Width
div 2);
5942 Target
.cY
:= Target
.Y
+ mon
.Obj
.Rect
.Y
+ (mon
.Obj
.Rect
.Height
div 2);
5943 Target
.Rect
:= mon
.Obj
.Rect
;
5944 Target
.Visible
:= g_TraceVector(x1
, y1
, Target
.cX
, Target
.cY
);
5945 Target
.Line
:= (y1
+4 < Target
.Y
+ mon
.Obj
.Rect
.Y
+ mon
.Obj
.Rect
.Height
) and
5946 (y1
-4 > Target
.Y
+ mon
.Obj
.Rect
.Y
);
5947 Target
.IsPlayer
:= False;
5954 begin // Öåëè íåò - îáíóëÿåì
5959 Target
.Visible
:= False;
5960 Target
.Line
:= False;
5961 Target
.IsPlayer
:= False;
5966 // Åñëè öåëü íå âèäèìà èëè íå íà ëèíèè îãíÿ, òî èùåì âñå âîçìîæíûå öåëè:
5967 if (not Target
.Line
) or (not Target
.Visible
) then
5971 for a
:= 0 to High(gPlayers
) do
5972 if (gPlayers
[a
] <> nil) and (gPlayers
[a
].Live
) and
5973 (gPlayers
[a
].FUID
<> FUID
) and
5974 (not SameTeam(FUID
, gPlayers
[a
].FUID
)) and
5975 (not gPlayers
[a
].NoTarget
) and
5976 (gPlayers
[a
].FMegaRulez
[MR_INVIS
] < gTime
) then
5978 if not TargetOnScreen(gPlayers
[a
].FObj
.X
+ PLAYER_RECT
.X
,
5979 gPlayers
[a
].FObj
.Y
+ PLAYER_RECT
.Y
) then
5982 x2
:= gPlayers
[a
].FObj
.X
+ PLAYER_RECT_CX
;
5983 y2
:= gPlayers
[a
].FObj
.Y
+ PLAYER_RECT_CY
;
5985 // Åñëè èãðîê íà ýêðàíå è íå ïðèêðûò ñòåíîé:
5986 if g_TraceVector(x1
, y1
, x2
, y2
) then
5988 // Äîáàâëÿåì ê ñïèñêó âîçìîæíûõ öåëåé:
5989 SetLength(targets
, Length(targets
)+1);
5990 with targets
[High(targets
)] do
5992 UID
:= gPlayers
[a
].FUID
;
5993 X
:= gPlayers
[a
].FObj
.X
;
5994 Y
:= gPlayers
[a
].FObj
.Y
;
5997 Rect
:= PLAYER_RECT
;
5998 Dist
:= g_PatchLength(x1
, y1
, x2
, y2
);
5999 Line
:= (y1
+4 < Target
.Y
+PLAYER_RECT
.Y
+PLAYER_RECT
.Height
) and
6000 (y1
-4 > Target
.Y
+PLAYER_RECT
.Y
);
6008 if vsMonster
and (gMonsters
<> nil) then
6009 for a
:= 0 to High(gMonsters
) do
6010 if (gMonsters
[a
] <> nil) and (gMonsters
[a
].Live
) and
6011 (gMonsters
[a
].MonsterType
<> MONSTER_BARREL
) then
6013 mon
:= gMonsters
[a
];
6015 if not TargetOnScreen(mon
.Obj
.X
+ mon
.Obj
.Rect
.X
,
6016 mon
.Obj
.Y
+ mon
.Obj
.Rect
.Y
) then
6019 x2
:= mon
.Obj
.X
+ mon
.Obj
.Rect
.X
+ (mon
.Obj
.Rect
.Width
div 2);
6020 y2
:= mon
.Obj
.Y
+ mon
.Obj
.Rect
.Y
+ (mon
.Obj
.Rect
.Height
div 2);
6022 // Åñëè ìîíñòð íà ýêðàíå è íå ïðèêðûò ñòåíîé:
6023 if g_TraceVector(x1
, y1
, x2
, y2
) then
6025 // Äîáàâëÿåì ê ñïèñêó âîçìîæíûõ öåëåé:
6026 SetLength(targets
, Length(targets
)+1);
6027 with targets
[High(targets
)] do
6034 Rect
:= mon
.Obj
.Rect
;
6035 Dist
:= g_PatchLength(x1
, y1
, x2
, y2
);
6036 Line
:= (y1
+4 < Target
.Y
+ mon
.Obj
.Rect
.Y
+ mon
.Obj
.Rect
.Height
) and
6037 (y1
-4 > Target
.Y
+ mon
.Obj
.Rect
.Y
);
6045 // Åñëè åñòü âîçìîæíûå öåëè:
6046 // (Âûáèðàåì ëó÷øóþ, ìåíÿåì îðóæèå è áåæèì ê íåé/îò íåå)
6047 if targets
<> nil then
6049 // Âûáèðàåì íàèëó÷øóþ öåëü:
6050 BestTarget
:= targets
[0];
6051 if Length(targets
) > 1 then
6052 for a
:= 1 to High(targets
) do
6053 if Compare(BestTarget
, targets
[a
]) = 1 then
6054 BestTarget
:= targets
[a
];
6056 // Åñëè ëó÷øàÿ öåëü "âèäíåå" òåêóùåé, òî òåêóùàÿ := ëó÷øàÿ:
6057 if ((not Target
.Visible
) and BestTarget
.Visible
and (Target
.UID
<> BestTarget
.UID
)) or
6058 ((not Target
.Line
) and BestTarget
.Line
and BestTarget
.Visible
) then
6060 Target
:= BestTarget
;
6062 if (Healthy() = 3) or ((Healthy() = 2)) then
6063 begin // Åñëè çäîðîâû - äîãîíÿåì
6064 if ((RunDirection() = D_LEFT
) and (Target
.X
> FObj
.X
)) then
6065 SetAIFlag('GORIGHT', '1');
6066 if ((RunDirection() = D_RIGHT
) and (Target
.X
< FObj
.X
)) then
6067 SetAIFlag('GOLEFT', '1');
6070 begin // Åñëè ïîáèòû - óáåãàåì
6071 if ((RunDirection() = D_LEFT
) and (Target
.X
< FObj
.X
)) then
6072 SetAIFlag('GORIGHT', '1');
6073 if ((RunDirection() = D_RIGHT
) and (Target
.X
> FObj
.X
)) then
6074 SetAIFlag('GOLEFT', '1');
6077 // Âûáèðàåì îðóæèå íà îñíîâå ðàññòîÿíèÿ è ïðèîðèòåòîâ:
6078 SelectWeapon(Abs(x1
-Target
.cX
));
6083 // (Äîãîíÿåì/óáåãàåì, ñòðåëÿåì ïî íàïðàâëåíèþ ê öåëè)
6084 // (Åñëè öåëü äàëåêî, òî õâàòèò ñëåäèòü çà íåé)
6085 if Target
.UID
<> 0 then
6087 if not TargetOnScreen(Target
.X
+ Target
.Rect
.X
,
6088 Target
.Y
+ Target
.Rect
.Y
) then
6089 begin // Öåëü ñáåæàëà ñ "ýêðàíà"
6090 if (Healthy() = 3) or ((Healthy() = 2)) then
6091 begin // Åñëè çäîðîâû - äîãîíÿåì
6092 if ((RunDirection() = D_LEFT
) and (Target
.X
> FObj
.X
)) then
6093 SetAIFlag('GORIGHT', '1');
6094 if ((RunDirection() = D_RIGHT
) and (Target
.X
< FObj
.X
)) then
6095 SetAIFlag('GOLEFT', '1');
6098 begin // Åñëè ïîáèòû - çàáûâàåì î öåëè è óáåãàåì
6100 if ((RunDirection() = D_LEFT
) and (Target
.X
< FObj
.X
)) then
6101 SetAIFlag('GORIGHT', '1');
6102 if ((RunDirection() = D_RIGHT
) and (Target
.X
> FObj
.X
)) then
6103 SetAIFlag('GOLEFT', '1');
6107 begin // Öåëü ïîêà íà "ýêðàíå"
6108 // Åñëè öåëü íå çàãîðîæåíà ñòåíîé, òî îòìå÷àåì, êîãäà åå âèäåëè:
6109 if g_TraceVector(x1
, y1
, Target
.cX
, Target
.cY
) then
6110 FLastVisible
:= gTime
;
6111 // Åñëè ðàçíèöà âûñîò íå âåëèêà, òî äîãîíÿåì:
6112 if (Abs(FObj
.Y
-Target
.Y
) <= 128) then
6114 if ((RunDirection() = D_LEFT
) and (Target
.X
> FObj
.X
)) then
6115 SetAIFlag('GORIGHT', '1');
6116 if ((RunDirection() = D_RIGHT
) and (Target
.X
< FObj
.X
)) then
6117 SetAIFlag('GOLEFT', '1');
6121 // Âûáèðàåì óãîë ââåðõ:
6122 if FDirection
= D_LEFT
then
6123 angle
:= ANGLE_LEFTUP
6125 angle
:= ANGLE_RIGHTUP
;
6127 firew
:= Trunc(Cos(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
6128 fireh
:= Trunc(Sin(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
6130 // Åñëè ïðè óãëå ââåðõ ìîæíî ïîïàñòü â ïðèáëèçèòåëüíîå ïîëîæåíèå öåëè:
6131 if g_CollideLine(x1
, y1
, x1
+firew
, y1
+fireh
,
6132 Target
.X
+Target
.Rect
.X
+GetInterval(FDifficult
.DiagPrecision
, 128), //96
6133 Target
.Y
+Target
.Rect
.Y
+GetInterval(FDifficult
.DiagPrecision
, 128),
6134 Target
.Rect
.Width
, Target
.Rect
.Height
) and
6135 g_TraceVector(x1
, y1
, Target
.cX
, Target
.cY
) then
6136 begin // òî íóæíî ñòðåëÿòü ââåðõ
6137 SetAIFlag('NEEDFIRE', '1');
6138 SetAIFlag('NEEDSEEUP', '1');
6141 // Âûáèðàåì óãîë âíèç:
6142 if FDirection
= D_LEFT
then
6143 angle
:= ANGLE_LEFTDOWN
6145 angle
:= ANGLE_RIGHTDOWN
;
6147 firew
:= Trunc(Cos(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
6148 fireh
:= Trunc(Sin(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
6150 // Åñëè ïðè óãëå âíèç ìîæíî ïîïàñòü â ïðèáëèçèòåëüíîå ïîëîæåíèå öåëè:
6151 if g_CollideLine(x1
, y1
, x1
+firew
, y1
+fireh
,
6152 Target
.X
+Target
.Rect
.X
+GetInterval(FDifficult
.DiagPrecision
, 128),
6153 Target
.Y
+Target
.Rect
.Y
+GetInterval(FDifficult
.DiagPrecision
, 128),
6154 Target
.Rect
.Width
, Target
.Rect
.Height
) and
6155 g_TraceVector(x1
, y1
, Target
.cX
, Target
.cY
) then
6156 begin // òî íóæíî ñòðåëÿòü âíèç
6157 SetAIFlag('NEEDFIRE', '1');
6158 SetAIFlag('NEEDSEEDOWN', '1');
6161 // Åñëè öåëü âèäíî è îíà íà òàêîé æå âûñîòå:
6162 if Target
.Visible
and
6163 (y1
+4 < Target
.Y
+Target
.Rect
.Y
+Target
.Rect
.Height
) and
6164 (y1
-4 > Target
.Y
+Target
.Rect
.Y
) then
6166 // Åñëè èäåì â ñòîðîíó öåëè, òî íàäî ñòðåëÿòü:
6167 if ((FDirection
= D_LEFT
) and (Target
.X
< FObj
.X
)) or
6168 ((FDirection
= D_RIGHT
) and (Target
.X
> FObj
.X
)) then
6169 begin // òî íóæíî ñòðåëÿòü âïåðåä
6170 SetAIFlag('NEEDFIRE', '1');
6171 SetAIFlag('NEEDSEEDOWN', '');
6172 SetAIFlag('NEEDSEEUP', '');
6174 // Åñëè öåëü â ïðåäåëàõ "ýêðàíà" è ñëîæíîñòü ïîçâîëÿåò ïðûæêè ñáëèæåíèÿ:
6175 if Abs(FObj
.X
-Target
.X
) < Trunc(gPlayerScreenSize
.X
*0.75) then
6176 if GetRnd(FDifficult
.CloseJump
) then
6177 begin // òî åñëè ïîâåçåò - ïðûãàåì (îñîáåííî, åñëè áëèçêî)
6178 if Abs(FObj
.X
-Target
.X
) < 128 then
6182 if Random(a
) = 0 then
6183 SetAIFlag('NEEDJUMP', '1');
6187 // Åñëè öåëü âñå åùå åñòü:
6188 if Target
.UID
<> 0 then
6189 if gTime
-FLastVisible
> 2000 then // Åñëè âèäåëè äàâíî
6190 Target
.UID
:= 0 // òî çàáûòü öåëü
6191 else // Åñëè âèäåëè íåäàâíî
6192 begin // íî öåëü óáèëè
6193 if Target
.IsPlayer
then
6194 begin // Öåëü - èãðîê
6195 pla
:= g_Player_Get(Target
.UID
);
6196 if (pla
= nil) or (not pla
.Live
) or pla
.NoTarget
or
6197 (pla
.FMegaRulez
[MR_INVIS
] >= gTime
) then
6198 Target
.UID
:= 0; // òî çàáûòü öåëü
6201 begin // Öåëü - ìîíñòð
6202 mon
:= g_Monsters_Get(Target
.UID
);
6203 if (mon
= nil) or (not mon
.Live
) then
6204 Target
.UID
:= 0; // òî çàáûòü öåëü
6207 end; // if Target.UID <> 0
6209 FTargetUID
:= Target
.UID
;
6211 // Åñëè âîçìîæíûõ öåëåé íåò:
6212 // (Àòàêà ÷åãî-íèáóäü ñëåâà èëè ñïðàâà)
6213 if targets
= nil then
6214 if GetAIFlag('ATTACKLEFT') <> '' then
6215 begin // Åñëè íóæíî àòàêîâàòü íàëåâî
6216 RemoveAIFlag('ATTACKLEFT');
6218 SetAIFlag('NEEDJUMP', '1');
6220 if RunDirection() = D_RIGHT
then
6221 begin // Èäåì íå â òó ñòîðîíó
6222 if (Healthy() > 1) and GetRnd(FDifficult
.InvisFire
) then
6223 begin // Åñëè çäîðîâû, òî, âîçìîæíî, ñòðåëÿåì áåæèì âëåâî è ñòðåëÿåì
6224 SetAIFlag('NEEDFIRE', '1');
6225 SetAIFlag('GOLEFT', '1');
6229 begin // Èäåì â íóæíóþ ñòîðîíó
6230 if GetRnd(FDifficult
.InvisFire
) then // Âîçìîæíî, ñòðåëÿåì âñëåïóþ
6231 SetAIFlag('NEEDFIRE', '1');
6232 if Healthy() <= 1 then // Ïîáèòû - óáåãàåì
6233 SetAIFlag('GORIGHT', '1');
6237 if GetAIFlag('ATTACKRIGHT') <> '' then
6238 begin // Åñëè íóæíî àòàêîâàòü íàïðàâî
6239 RemoveAIFlag('ATTACKRIGHT');
6241 SetAIFlag('NEEDJUMP', '1');
6243 if RunDirection() = D_LEFT
then
6244 begin // Èäåì íå â òó ñòîðîíó
6245 if (Healthy() > 1) and GetRnd(FDifficult
.InvisFire
) then
6246 begin // Åñëè çäîðîâû, òî, âîçìîæíî, áåæèì âïðàâî è ñòðåëÿåì
6247 SetAIFlag('NEEDFIRE', '1');
6248 SetAIFlag('GORIGHT', '1');
6253 if GetRnd(FDifficult
.InvisFire
) then // Âîçìîæíî, ñòðåëÿåì âñëåïóþ
6254 SetAIFlag('NEEDFIRE', '1');
6255 if Healthy() <= 1 then // Ïîáèòû - óáåãàåì
6256 SetAIFlag('GOLEFT', '1');
6260 // Åñëè åñòü âîçìîæíûå öåëè:
6261 // (Ñòðåëÿåì ïî íàïðàâëåíèþ ê öåëÿì)
6262 if (targets
<> nil) and (GetAIFlag('NEEDFIRE') <> '') then
6263 for a
:= 0 to High(targets
) do
6265 // Åñëè ìîæåì ñòðåëÿòü ïî äèàãîíàëè:
6266 if GetRnd(FDifficult
.DiagFire
) then
6268 // Èùåì öåëü ñâåðõó è ñòðåëÿåì, åñëè åñòü:
6269 if FDirection
= D_LEFT
then
6270 angle
:= ANGLE_LEFTUP
6272 angle
:= ANGLE_RIGHTUP
;
6274 firew
:= Trunc(Cos(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
6275 fireh
:= Trunc(Sin(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
6277 if g_CollideLine(x1
, y1
, x1
+firew
, y1
+fireh
,
6278 targets
[a
].X
+targets
[a
].Rect
.X
+GetInterval(FDifficult
.DiagPrecision
, 128),
6279 targets
[a
].Y
+targets
[a
].Rect
.Y
+GetInterval(FDifficult
.DiagPrecision
, 128),
6280 targets
[a
].Rect
.Width
, targets
[a
].Rect
.Height
) and
6281 g_TraceVector(x1
, y1
, targets
[a
].cX
, targets
[a
].cY
) then
6283 SetAIFlag('NEEDFIRE', '1');
6284 SetAIFlag('NEEDSEEUP', '1');
6287 // Èùåì öåëü ñíèçó è ñòðåëÿåì, åñëè åñòü:
6288 if FDirection
= D_LEFT
then
6289 angle
:= ANGLE_LEFTDOWN
6291 angle
:= ANGLE_RIGHTDOWN
;
6293 firew
:= Trunc(Cos(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
6294 fireh
:= Trunc(Sin(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
6296 if g_CollideLine(x1
, y1
, x1
+firew
, y1
+fireh
,
6297 targets
[a
].X
+targets
[a
].Rect
.X
+GetInterval(FDifficult
.DiagPrecision
, 128),
6298 targets
[a
].Y
+targets
[a
].Rect
.Y
+GetInterval(FDifficult
.DiagPrecision
, 128),
6299 targets
[a
].Rect
.Width
, targets
[a
].Rect
.Height
) and
6300 g_TraceVector(x1
, y1
, targets
[a
].cX
, targets
[a
].cY
) then
6302 SetAIFlag('NEEDFIRE', '1');
6303 SetAIFlag('NEEDSEEDOWN', '1');
6307 // Åñëè öåëü "ïåðåä íîñîì", òî ñòðåëÿåì:
6308 if targets
[a
].Line
and targets
[a
].Visible
and
6309 (((FDirection
= D_LEFT
) and (targets
[a
].X
< FObj
.X
)) or
6310 ((FDirection
= D_RIGHT
) and (targets
[a
].X
> FObj
.X
))) then
6312 SetAIFlag('NEEDFIRE', '1');
6317 // Åñëè ëåòèò ïóëÿ, òî, âîçìîæíî, ïîäïðûãèâàåì:
6318 if g_Weapon_Danger(FUID
, FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+PLAYER_RECT
.Y
,
6319 PLAYER_RECT
.Width
, PLAYER_RECT
.Height
,
6320 40+GetInterval(FDifficult
.Cover
, 40)) then
6321 SetAIFlag('NEEDJUMP', '1');
6323 // Åñëè êîí÷èëèñü ïàòîðíû, òî íóæíî ñìåíèòü îðóæèå:
6324 ammo
:= GetAmmoByWeapon(FCurrWeap
);
6325 if ((FCurrWeap
= WEAPON_SHOTGUN2
) and (ammo
< 2)) or
6326 ((FCurrWeap
= WEAPON_BFG
) and (ammo
< 40)) or
6328 SetAIFlag('SELECTWEAPON', '1');
6330 // Åñëè íóæíî ñìåíèòü îðóæèå, òî âûáèðàåì íóæíîå:
6331 if GetAIFlag('SELECTWEAPON') = '1' then
6334 RemoveAIFlag('SELECTWEAPON');
6338 procedure TBot
.Update();
6351 // Ïðîâåðÿåì, îòêëþ÷¸í ëè AI áîòîâ
6352 if (g_debug_BotAIOff
= 1) and (Team
= TEAM_RED
) then
6354 if (g_debug_BotAIOff
= 2) and (Team
= TEAM_BLUE
) then
6356 if g_debug_BotAIOff
= 3 then
6369 procedure TBot
.ReleaseKey(Key
: Byte);
6378 function TBot
.KeyPressed(Key
: Word): Boolean;
6380 Result
:= FKeys
[Key
].Pressed
;
6383 function TBot
.GetAIFlag(fName
: String20
): String20
;
6389 fName
:= LowerCase(fName
);
6391 if FAIFlags
<> nil then
6392 for a
:= 0 to High(FAIFlags
) do
6393 if LowerCase(FAIFlags
[a
].Name
) = fName
then
6395 Result
:= FAIFlags
[a
].Value
;
6400 procedure TBot
.RemoveAIFlag(fName
: String20
);
6404 if FAIFlags
= nil then Exit
;
6406 fName
:= LowerCase(fName
);
6408 for a
:= 0 to High(FAIFlags
) do
6409 if LowerCase(FAIFlags
[a
].Name
) = fName
then
6411 if a
<> High(FAIFlags
) then
6412 for b
:= a
to High(FAIFlags
)-1 do
6413 FAIFlags
[b
] := FAIFlags
[b
+1];
6415 SetLength(FAIFlags
, Length(FAIFlags
)-1);
6420 procedure TBot
.SetAIFlag(fName
, fValue
: String20
);
6428 fName
:= LowerCase(fName
);
6430 if FAIFlags
<> nil then
6431 for a
:= 0 to High(FAIFlags
) do
6432 if LowerCase(FAIFlags
[a
].Name
) = fName
then
6438 if ok
then FAIFlags
[a
].Value
:= fValue
6441 SetLength(FAIFlags
, Length(FAIFlags
)+1);
6442 with FAIFlags
[High(FAIFlags
)] do
6450 procedure TBot
.UpdateMove
;
6452 procedure GoLeft(Time
: Word = 1);
6454 ReleaseKey(KEY_LEFT
);
6455 ReleaseKey(KEY_RIGHT
);
6456 PressKey(KEY_LEFT
, Time
);
6457 SetDirection(D_LEFT
);
6460 procedure GoRight(Time
: Word = 1);
6462 ReleaseKey(KEY_LEFT
);
6463 ReleaseKey(KEY_RIGHT
);
6464 PressKey(KEY_RIGHT
, Time
);
6465 SetDirection(D_RIGHT
);
6468 function Rnd(a
: Word): Boolean;
6470 Result
:= Random(a
) = 0;
6473 procedure Turn(Time
: Word = 1200);
6475 if RunDirection() = D_LEFT
then GoRight(Time
) else GoLeft(Time
);
6480 ReleaseKey(KEY_LEFT
);
6481 ReleaseKey(KEY_RIGHT
);
6484 function CanRunLeft(): Boolean;
6486 Result
:= not CollideLevel(-1, 0);
6489 function CanRunRight(): Boolean;
6491 Result
:= not CollideLevel(1, 0);
6494 function CanRun(): Boolean;
6496 if RunDirection() = D_LEFT
then Result
:= CanRunLeft() else Result
:= CanRunRight();
6499 procedure Jump(Time
: Word = 30);
6501 PressKey(KEY_JUMP
, Time
);
6504 function NearHole(): Boolean;
6508 { TODO 5 : Ëåñòíèöû }
6509 sx
:= IfThen(RunDirection() = D_LEFT
, -1, 1);
6510 for x
:= 1 to PLAYER_RECT
.Width
do
6511 if (not StayOnStep(x
*sx
, 0)) and
6512 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
)) and
6513 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
*2)) then
6522 function BorderHole(): Boolean;
6526 { TODO 5 : Ëåñòíèöû }
6527 sx
:= IfThen(RunDirection() = D_LEFT
, -1, 1);
6528 for x
:= 1 to PLAYER_RECT
.Width
do
6529 if (not StayOnStep(x
*sx
, 0)) and
6530 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
)) and
6531 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
*2)) then
6533 for xx
:= x
to x
+32 do
6534 if CollideLevel(xx
*sx
, PLAYER_RECT
.Height
) then
6544 function NearDeepHole(): Boolean;
6550 sx
:= IfThen(RunDirection() = D_LEFT
, -1, 1);
6553 for x
:= 1 to PLAYER_RECT
.Width
do
6554 if (not StayOnStep(x
*sx
, 0)) and
6555 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
)) and
6556 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
*2)) then
6558 while FObj
.Y
+y
*PLAYER_RECT
.Height
< gMapInfo
.Height
do
6560 if CollideLevel(x
*sx
, PLAYER_RECT
.Height
*y
) then Exit
;
6565 end else Result
:= False;
6568 function OverDeepHole(): Boolean;
6575 while FObj
.Y
+y
*PLAYER_RECT
.Height
< gMapInfo
.Height
do
6577 if CollideLevel(0, PLAYER_RECT
.Height
*y
) then Exit
;
6584 function OnGround(): Boolean;
6586 Result
:= StayOnStep(0, 0) or CollideLevel(0, 1);
6589 function OnLadder(): Boolean;
6591 Result
:= FullInStep(0, 0);
6594 function BelowLadder(): Boolean;
6596 Result
:= (FullInStep(IfThen(RunDirection() = D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -PLAYER_RECT
.Height
) and
6597 not CollideLevel(IfThen(RunDirection() = D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -PLAYER_RECT
.Height
)) or
6598 (FullInStep(IfThen(RunDirection() = D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -BOT_MAXJUMP
) and
6599 not CollideLevel(IfThen(RunDirection() = D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -BOT_MAXJUMP
));
6602 function BelowLiftUp(): Boolean;
6604 Result
:= ((FullInLift(IfThen(RunDirection() = D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -PLAYER_RECT
.Height
) = -1) and
6605 not CollideLevel(IfThen(RunDirection() = D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -PLAYER_RECT
.Height
)) or
6606 ((FullInLift(IfThen(RunDirection() = D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -BOT_MAXJUMP
) = -1) and
6607 not CollideLevel(IfThen(RunDirection() = D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -BOT_MAXJUMP
));
6610 function OnTopLift(): Boolean;
6612 Result
:= (FullInLift(0, 0) = -1) and (FullInLift(0, -32) = 0);
6615 function CanJumpOver(): Boolean;
6619 sx
:= IfThen(RunDirection() = D_LEFT
, -1, 1);
6623 if not CollideLevel(sx
, 0) then Exit
;
6625 for y
:= 1 to BOT_MAXJUMP
do
6626 if CollideLevel(0, -y
) then Exit
else
6627 if not CollideLevel(sx
, -y
) then
6634 function CanJumpUp(Dist
: ShortInt): Boolean;
6641 if CollideLevel(Dist
, 0) then Exit
;
6644 for y
:= 0 to BOT_MAXJUMP
do
6645 if CollideLevel(Dist
, -y
) then
6654 for yy
:= y
+1 to BOT_MAXJUMP
do
6655 if not CollideLevel(Dist
, -yy
) then
6664 for y
:= 0 to BOT_MAXJUMP
do
6665 if CollideLevel(0, -y
) then
6673 if y
< yy
then Exit
;
6678 function IsSafeTrigger(): Boolean;
6683 if gTriggers
= nil then
6685 for a
:= 0 to High(gTriggers
) do
6686 if Collide(gTriggers
[a
].X
,
6689 gTriggers
[a
].Height
) and
6690 (gTriggers
[a
].TriggerType
in [TRIGGER_EXIT
, TRIGGER_CLOSEDOOR
,
6691 TRIGGER_CLOSETRAP
, TRIGGER_TRAP
,
6692 TRIGGER_PRESS
, TRIGGER_ON
, TRIGGER_OFF
,
6693 TRIGGER_ONOFF
, TRIGGER_SPAWNMONSTER
,
6694 TRIGGER_DAMAGE
, TRIGGER_SHOT
]) then
6699 // Âîçìîæíî, íàæèìàåì êíîïêó:
6700 if Rnd(16) and IsSafeTrigger() then
6703 // Åñëè ïîä ëèôòîì èëè ñòóïåíüêàìè, òî, âîçìîæíî, ïðûãàåì:
6704 if OnLadder() or ((BelowLadder() or BelowLiftUp()) and Rnd(8)) then
6706 ReleaseKey(KEY_LEFT
);
6707 ReleaseKey(KEY_RIGHT
);
6711 // Èäåì âëåâî, åñëè íàäî áûëî:
6712 if GetAIFlag('GOLEFT') <> '' then
6714 RemoveAIFlag('GOLEFT');
6715 if CanRunLeft() then
6719 // Èäåì âïðàâî, åñëè íàäî áûëî:
6720 if GetAIFlag('GORIGHT') <> '' then
6722 RemoveAIFlag('GORIGHT');
6723 if CanRunRight() then
6727 // Åñëè âûëåòåëè çà êàðòó, òî ïðîáóåì âåðíóòüñÿ:
6728 if FObj
.X
< -32 then
6731 if FObj
.X
+32 > gMapInfo
.Width
then
6734 // Ïðûãàåì, åñëè íàäî áûëî:
6735 if GetAIFlag('NEEDJUMP') <> '' then
6738 RemoveAIFlag('NEEDJUMP');
6741 // Ñìîòðèì ââåðõ, åñëè íàäî áûëî:
6742 if GetAIFlag('NEEDSEEUP') <> '' then
6745 ReleaseKey(KEY_DOWN
);
6746 PressKey(KEY_UP
, 20);
6747 RemoveAIFlag('NEEDSEEUP');
6750 // Ñìîòðèì âíèç, åñëè íàäî áûëî:
6751 if GetAIFlag('NEEDSEEDOWN') <> '' then
6754 ReleaseKey(KEY_DOWN
);
6755 PressKey(KEY_DOWN
, 20);
6756 RemoveAIFlag('NEEDSEEDOWN');
6759 // Åñëè íóæíî áûëî â äûðó è ìû íå íà çåìëå, òî ïîêîðíî ëåòèì:
6760 if GetAIFlag('GOINHOLE') <> '' then
6761 if not OnGround() then
6763 ReleaseKey(KEY_LEFT
);
6764 ReleaseKey(KEY_RIGHT
);
6765 RemoveAIFlag('GOINHOLE');
6766 SetAIFlag('FALLINHOLE', '1');
6769 // Åñëè ïàäàëè è äîñòèãëè çåìëè, òî õâàòèò ïàäàòü:
6770 if GetAIFlag('FALLINHOLE') <> '' then
6772 RemoveAIFlag('FALLINHOLE');
6774 // Åñëè ëåòåëè ïðÿìî è ñåé÷àñ íå íà ëåñòíèöå èëè íà âåðøèíå ëèôòà, òî îòõîäèì â ñòîðîíó:
6775 if not (KeyPressed(KEY_LEFT
) or KeyPressed(KEY_RIGHT
)) then
6776 if GetAIFlag('FALLINHOLE') = '' then
6777 if (not OnLadder()) or (FObj
.Vel
.Y
>= 0) or (OnTopLift()) then
6783 // Åñëè íà çåìëå è ìîæíî ïîäïðûãíóòü, òî, âîçìîæíî, ïðûãàåì:
6785 CanJumpUp(IfThen(RunDirection() = D_LEFT
, -1, 1)*32) and
6789 // Åñëè íà çåìëå è âîçëå äûðû (ãëóáèíà > 2 ðîñòîâ èãðîêà):
6790 if OnGround() and NearHole() then
6791 if NearDeepHole() then // Åñëè ýòî áåçäíà
6793 0..3: Turn(); // Áåæèì îáðàòíî
6794 4: Jump(); // Ïðûãàåì
6795 5: begin // Ïðûãàåì îáðàòíî
6800 else // Ýòî íå áåçäíà è ìû åùå íå ëåòèì òóäà
6801 if GetAIFlag('GOINHOLE') = '' then
6803 0: Turn(); // Íå íóæíî òóäà
6804 1: Jump(); // Âäðóã ïîâåçåò - ïðûãàåì
6805 else // Åñëè ÿìà ñ ãðàíèöåé, òî ïðè ñëó÷àå ìîæíî òóäà ïðûãíóòü
6806 if BorderHole() then
6807 SetAIFlag('GOINHOLE', '1');
6810 // Åñëè íà çåìëå, íî íåêóäà èäòè:
6811 if (not CanRun()) and OnGround() then
6813 // Åñëè ìû íà ëåñòíèöå èëè ìîæíî ïåðåïðûãíóòü, òî ïðûãàåì:
6814 if CanJumpOver() or OnLadder() then
6816 else // èíà÷å ïîïûòàåìñÿ â äðóãóþ ñòîðîíó
6817 if Random(2) = 0 then
6819 if IsSafeTrigger() then
6825 // Îñòàëîñü ìàëî âîçäóõà:
6826 if FAir
< 36 * 2 then
6829 // Âûáèðàåìñÿ èç êèñëîòû, åñëè íåò êîñòþìà, îáîæãëèñü, èëè ìàëî çäîðîâüÿ:
6830 if (FMegaRulez
[MR_SUIT
] < gTime
) and ((FLastHit
= HIT_ACID
) or (Healthy() <= 1)) then
6831 if BodyInAcid(0, 0) then
6835 function TBot
.FullInStep(XInc
, YInc
: Integer): Boolean;
6837 Result
:= g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
,
6838 PLAYER_RECT
.Width
, PLAYER_RECT
.Height
, PANEL_STEP
, False);
6841 {function TBot.NeedItem(Item: Byte): Byte;
6846 procedure TBot
.SelectWeapon(Dist
: Integer);
6850 function HaveAmmo(weapon
: Byte): Boolean;
6853 WEAPON_PISTOL
: Result
:= FAmmo
[A_BULLETS
] >= 1;
6854 WEAPON_SHOTGUN1
: Result
:= FAmmo
[A_SHELLS
] >= 1;
6855 WEAPON_SHOTGUN2
: Result
:= FAmmo
[A_SHELLS
] >= 2;
6856 WEAPON_CHAINGUN
: Result
:= FAmmo
[A_BULLETS
] >= 10;
6857 WEAPON_ROCKETLAUNCHER
: Result
:= FAmmo
[A_ROCKETS
] >= 1;
6858 WEAPON_PLASMA
: Result
:= FAmmo
[A_CELLS
] >= 10;
6859 WEAPON_BFG
: Result
:= FAmmo
[A_CELLS
] >= 40;
6860 WEAPON_SUPERPULEMET
: Result
:= FAmmo
[A_SHELLS
] >= 1;
6861 else Result
:= True;
6866 if Dist
= -1 then Dist
:= BOT_LONGDIST
;
6868 if Dist
> BOT_LONGDIST
then
6869 begin // Äàëüíèé áîé
6871 if FWeapon
[FDifficult
.WeaponPrior
[a
]] and HaveAmmo(FDifficult
.WeaponPrior
[a
]) then
6873 FSelectedWeapon
:= FDifficult
.WeaponPrior
[a
];
6877 else //if Dist > BOT_UNSAFEDIST then
6878 begin // Áëèæíèé áîé
6880 if FWeapon
[FDifficult
.CloseWeaponPrior
[a
]] and HaveAmmo(FDifficult
.CloseWeaponPrior
[a
]) then
6882 FSelectedWeapon
:= FDifficult
.CloseWeaponPrior
[a
];
6889 if FWeapon[FDifficult.SafeWeaponPrior[a]] and HaveAmmo(FDifficult.SafeWeaponPrior[a]) then
6891 FSelectedWeapon := FDifficult.SafeWeaponPrior[a];
6897 function TBot
.PickItem(ItemType
: Byte; force
: Boolean; var remove
: Boolean): Boolean;
6899 Result
:= inherited PickItem(ItemType
, force
, remove
);
6901 if Result
then SetAIFlag('SELECTWEAPON', '1');
6904 function TBot
.Heal(value
: Word; Soft
: Boolean): Boolean;
6906 Result
:= inherited Heal(value
, Soft
);
6909 function TBot
.Healthy(): Byte;
6911 if FMegaRulez
[MR_INVUL
] >= gTime
then Result
:= 3
6912 else if (FHealth
> 80) or ((FHealth
> 50) and (FArmor
> 20)) then Result
:= 3
6913 else if (FHealth
> 50) then Result
:= 2
6914 else if (FHealth
> 20) then Result
:= 1
6918 function TBot
.TargetOnScreen(TX
, TY
: Integer): Boolean;
6920 Result
:= (Abs(FObj
.X
-TX
) <= Trunc(gPlayerScreenSize
.X
*0.6)) and
6921 (Abs(FObj
.Y
-TY
) <= Trunc(gPlayerScreenSize
.Y
*0.6));
6924 procedure TBot
.OnDamage(Angle
: SmallInt);
6932 if (Angle
= 0) or (Angle
= 180) then
6935 if (g_GetUIDType(FLastSpawnerUID
) = UID_PLAYER
) and
6936 LongBool(gGameSettings
.Options
and GAME_OPTION_BOTVSPLAYER
) then
6938 pla
:= g_Player_Get(FLastSpawnerUID
);
6939 ok
:= not TargetOnScreen(pla
.FObj
.X
+ PLAYER_RECT
.X
,
6940 pla
.FObj
.Y
+ PLAYER_RECT
.Y
);
6943 if (g_GetUIDType(FLastSpawnerUID
) = UID_MONSTER
) and
6944 LongBool(gGameSettings
.Options
and GAME_OPTION_BOTVSMONSTER
) then
6946 mon
:= g_Monsters_Get(FLastSpawnerUID
);
6947 ok
:= not TargetOnScreen(mon
.Obj
.X
+ mon
.Obj
.Rect
.X
,
6948 mon
.Obj
.Y
+ mon
.Obj
.Rect
.Y
);
6953 SetAIFlag('ATTACKLEFT', '1')
6955 SetAIFlag('ATTACKRIGHT', '1');
6959 function TBot
.RunDirection(): TDirection
;
6961 if Abs(Vel
.X
) >= 1 then
6963 if Vel
.X
> 0 then Result
:= D_RIGHT
else Result
:= D_LEFT
;
6965 Result
:= FDirection
;
6968 function TBot
.GetRnd(a
: Byte): Boolean;
6970 if a
= 0 then Result
:= False
6971 else if a
= 255 then Result
:= True
6972 else Result
:= Random(256) > 255-a
;
6975 function TBot
.GetInterval(a
: Byte; radius
: SmallInt): SmallInt;
6977 Result
:= Round((255-a
)/255*radius
*(Random(2)-1));
6980 procedure TBot
.SaveState(var Mem
: TBinMemoryWriter
);
6986 inherited SaveState(Mem
);
6988 // Âûáðàííîå îðóæèå:
6989 Mem
.WriteByte(FSelectedWeapon
);
6991 Mem
.WriteWord(FTargetUID
);
6992 // Âðåìÿ ïîòåðè öåëè:
6993 Mem
.WriteDWORD(FLastVisible
);
6994 // Êîëè÷åñòâî ôëàãîâ ÈÈ:
6995 dw
:= Length(FAIFlags
);
6998 for i
:= 0 to Integer(dw
)-1 do
7000 Mem
.WriteString(FAIFlags
[i
].Name
, 20);
7001 Mem
.WriteString(FAIFlags
[i
].Value
, 20);
7003 // Íàñòðîéêè ñëîæíîñòè:
7005 Mem
.WriteMemory(p
, SizeOf(TDifficult
));
7008 procedure TBot
.LoadState(var Mem
: TBinMemoryReader
);
7014 inherited LoadState(Mem
);
7016 // Âûáðàííîå îðóæèå:
7017 Mem
.ReadByte(FSelectedWeapon
);
7019 Mem
.ReadWord(FTargetUID
);
7020 // Âðåìÿ ïîòåðè öåëè:
7021 Mem
.ReadDWORD(FLastVisible
);
7022 // Êîëè÷åñòâî ôëàãîâ ÈÈ:
7024 SetLength(FAIFlags
, dw
);
7026 for i
:= 0 to Integer(dw
)-1 do
7028 Mem
.ReadString(FAIFlags
[i
].Name
);
7029 Mem
.ReadString(FAIFlags
[i
].Value
);
7031 // Íàñòðîéêè ñëîæíîñòè:
7032 Mem
.ReadMemory(p
, dw
);
7033 if dw
<> SizeOf(TDifficult
) then
7035 raise EBinSizeError
.Create('TBot.LoadState: Wrong FDifficult Size');
7037 FDifficult
:= TDifficult(p
^);