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 RestoreHealthArmor();
247 procedure FragCombo();
248 procedure GiveItem(ItemType
: Byte);
249 procedure Damage(value
: Word; SpawnerUID
: Word; vx
, vy
: Integer; t
: Byte); virtual;
250 function Heal(value
: Word; Soft
: Boolean): Boolean; virtual;
251 procedure MakeBloodVector(Count
: Word; VelX
, VelY
: Integer);
252 procedure MakeBloodSimple(Count
: Word);
253 procedure Kill(KillType
: Byte; SpawnerUID
: Word; t
: Byte);
254 procedure Reset(Force
: Boolean);
255 procedure Spectate(NoMove
: Boolean = False);
256 procedure SwitchNoClip
;
257 procedure SoftReset();
258 procedure Draw(); virtual;
259 procedure DrawPain();
260 procedure DrawPickup();
261 procedure DrawRulez();
263 procedure DrawBubble();
265 procedure Update(); virtual;
266 procedure RememberState();
267 procedure RecallState();
268 procedure SaveState(var Mem
: TBinMemoryWriter
); virtual;
269 procedure LoadState(var Mem
: TBinMemoryReader
); virtual;
270 procedure PauseSounds(Enable
: Boolean);
271 procedure NetFire(Wpn
: Byte; X
, Y
, AX
, AY
: Integer; WID
: Integer = -1);
272 procedure DoLerp(Level
: Integer = 2);
273 procedure SetLerp(XTo
, YTo
: Integer);
275 procedure JetpackOff
;
277 property Name
: String read FName write FName
;
278 property Model
: TPlayerModel read FModel
;
279 property Health
: Integer read FHealth write FHealth
;
280 property Lives
: Byte read FLives write FLives
;
281 property Armor
: Integer read FArmor write FArmor
;
282 property Air
: Integer read FAir write FAir
;
283 property JetFuel
: Integer read FJetFuel write FJetFuel
;
284 property Frags
: Integer read FFrags write FFrags
;
285 property Death
: Integer read FDeath write FDeath
;
286 property Kills
: Integer read FKills write FKills
;
287 property CurrWeap
: Byte read FCurrWeap write FCurrWeap
;
288 property MonsterKills
: Integer read FMonsterKills write FMonsterKills
;
289 property Secrets
: Integer read FSecrets
;
290 property GodMode
: Boolean read FGodMode write FGodMode
;
291 property NoTarget
: Boolean read FNoTarget write FNoTarget
;
292 property NoReload
: Boolean read FNoReload write FNoReload
;
293 property Live
: Boolean read FLive write FLive
;
294 property Flag
: Byte read FFlag
;
295 property Team
: Byte read FTeam write FTeam
;
296 property Direction
: TDirection read FDirection
;
297 property GameX
: Integer read FObj
.X write FObj
.X
;
298 property GameY
: Integer read FObj
.Y write FObj
.Y
;
299 property GameVelX
: Integer read FObj
.Vel
.X write FObj
.Vel
.X
;
300 property GameVelY
: Integer read FObj
.Vel
.Y write FObj
.Vel
.Y
;
301 property GameAccelX
: Integer read FObj
.Accel
.X write FObj
.Accel
.X
;
302 property GameAccelY
: Integer read FObj
.Accel
.Y write FObj
.Accel
.Y
;
303 property Vel
: TPoint2i read FObj
.Vel
;
304 property Obj
: TObj read FObj
;
305 property IncCam
: Integer read FIncCam write FIncCam
;
306 property UID
: Word read FUID write FUID
;
307 property JustTeleported
: Boolean read FJustTeleported write FJustTeleported
;
308 property NetTime
: LongWord read FNetTime write FNetTime
;
318 WeaponPrior
: Array [WEAPON_KASTET
..WEAPON_SUPERPULEMET
] of Byte;
319 CloseWeaponPrior
: Array [WEAPON_KASTET
..WEAPON_SUPERPULEMET
] of Byte;
320 //SafeWeaponPrior: Array [WEAPON_KASTET..WEAPON_SUPERPULEMET] of Byte;
328 TBot
= class (TPlayer
)
330 FSelectedWeapon
: Byte;
333 FAIFlags
: Array of TAIFlag
;
334 FDifficult
: TDifficult
;
336 function GetRnd(a
: Byte): Boolean;
337 function GetInterval(a
: Byte; radius
: SmallInt): SmallInt;
338 function RunDirection(): TDirection
;
339 function FullInStep(XInc
, YInc
: Integer): Boolean;
340 //function NeedItem(Item: Byte): Byte;
341 procedure SelectWeapon(Dist
: Integer);
342 procedure SetAIFlag(fName
, fValue
: String20
);
343 function GetAIFlag(fName
: String20
): String20
;
344 procedure RemoveAIFlag(fName
: String20
);
345 function Healthy(): Byte;
346 procedure UpdateMove();
347 procedure UpdateCombat();
348 function KeyPressed(Key
: Word): Boolean;
349 procedure ReleaseKey(Key
: Byte);
350 function TargetOnScreen(TX
, TY
: Integer): Boolean;
351 procedure OnDamage(Angle
: SmallInt); override;
354 procedure Respawn(Silent
: Boolean; Force
: Boolean = False); override;
355 constructor Create(); override;
356 destructor Destroy(); override;
357 procedure Draw(); override;
358 function PickItem(ItemType
: Byte; force
: Boolean; var remove
: Boolean): Boolean; override;
359 function Heal(value
: Word; Soft
: Boolean): Boolean; override;
360 procedure Update(); override;
361 procedure SaveState(var Mem
: TBinMemoryWriter
); override;
362 procedure LoadState(var Mem
: TBinMemoryReader
); override;
384 TCorpse
= class (TObject
)
392 FAnimation
: TAnimation
;
393 FAnimationMask
: TAnimation
;
396 constructor Create(X
, Y
: Integer; ModelName
: String; aMess
: Boolean);
397 destructor Destroy(); override;
398 procedure Damage(Value
: Word; vx
, vy
: Integer);
401 procedure SaveState(var Mem
: TBinMemoryWriter
);
402 procedure LoadState(var Mem
: TBinMemoryReader
);
404 property Obj
: TObj read FObj
;
405 property State
: Byte read FState
;
406 property Mess
: Boolean read FMess
;
409 TTeamStat
= Array [TEAM_RED
..TEAM_BLUE
] of
415 gPlayers
: Array of TPlayer
;
416 gCorpses
: Array of TCorpse
;
417 gGibs
: Array of TGib
;
418 gShells
: Array of TShell
;
419 gTeamStat
: TTeamStat
;
420 gFly
: Boolean = False;
421 gAimLine
: Boolean = False;
422 gChatBubble
: Byte = 0;
426 MAX_RUNVEL
: Integer = 8;
427 VEL_JUMP
: Integer = 10;
428 SHELL_TIMEOUT
: Cardinal = 60000;
430 function Lerp(X
, Y
, Factor
: Integer): Integer;
432 procedure g_Gibs_SetMax(Count
: Word);
433 function g_Gibs_GetMax(): Word;
434 procedure g_Corpses_SetMax(Count
: Word);
435 function g_Corpses_GetMax(): Word;
436 procedure g_Shells_SetMax(Count
: Word);
437 function g_Shells_GetMax(): Word;
439 procedure g_Player_Init();
440 procedure g_Player_Free();
441 function g_Player_Create(ModelName
: String; Color
: TRGB
; Team
: Byte; Bot
: Boolean): Word;
442 function g_Player_CreateFromState(var Mem
: TBinMemoryReader
): Word;
443 procedure g_Player_Remove(UID
: Word);
444 procedure g_Player_ResetTeams();
445 procedure g_Player_UpdateAll();
446 procedure g_Player_DrawAll();
447 procedure g_Player_DrawDebug(p
: TPlayer
);
448 procedure g_Player_DrawHealth();
449 procedure g_Player_RememberAll();
450 procedure g_Player_ResetAll(Force
, Silent
: Boolean);
451 function g_Player_Get(UID
: Word): TPlayer
;
452 function g_Player_GetCount(): Byte;
453 function g_Player_GetStats(): TPlayerStatArray
;
454 function g_Player_ValidName(Name
: String): Boolean;
455 procedure g_Player_CreateCorpse(Player
: TPlayer
);
456 procedure g_Player_CreateGibs(fX
, fY
: Integer; ModelName
: String; fColor
: TRGB
);
457 procedure g_Player_CreateShell(fX
, fY
, dX
, dY
: Integer; T
: Byte);
458 procedure g_Player_UpdatePhysicalObjects();
459 procedure g_Player_DrawCorpses();
460 procedure g_Player_DrawShells();
461 procedure g_Player_RemoveAllCorpses();
462 procedure g_Player_Corpses_SaveState(var Mem
: TBinMemoryWriter
);
463 procedure g_Player_Corpses_LoadState(var Mem
: TBinMemoryReader
);
464 procedure g_Bot_Add(Team
, Difficult
: Byte);
465 procedure g_Bot_AddList(Team
: Byte; lname
: ShortString; num
: Integer = -1);
466 procedure g_Bot_MixNames();
467 procedure g_Bot_RemoveAll();
472 e_log
, g_map
, g_items
, g_console
, SysUtils
, g_gfx
, Math
,
473 g_options
, g_triggers
, g_menu
, MAPDEF
, g_game
,
474 wadreader
, g_main
, g_monsters
, CONFIG
, g_language
, g_net
, g_netmsg
;
484 diag_precision
: Byte;
488 w_prior1
: Array [WEAPON_KASTET
..WEAPON_SUPERPULEMET
] of Byte;
489 w_prior2
: Array [WEAPON_KASTET
..WEAPON_SUPERPULEMET
] of Byte;
490 w_prior3
: Array [WEAPON_KASTET
..WEAPON_SUPERPULEMET
] of Byte;
494 TIME_RESPAWN1
= 1500;
495 TIME_RESPAWN2
= 2000;
496 TIME_RESPAWN3
= 3000;
499 JET_MAX
= 540; // ~30 sec
500 PLAYER_SUIT_TIME
= 30000;
501 PLAYER_INVUL_TIME
= 30000;
502 PLAYER_INVIS_TIME
= 35000;
503 FRAG_COMBO_TIME
= 3000;
507 ANGLE_RIGHTDOWN
= -35;
509 ANGLE_LEFTDOWN
= -145;
510 PLAYER_HEADRECT
: TRectWH
= (X
:24; Y
:12; Width
:20; Height
:12);
511 WEAPONPOINT
: Array [TDirection
] of TPoint
= ((X
:16; Y
:32), (X
:47; Y
:32));
514 BOT_UNSAFEDIST
= 128;
515 TEAMCOLOR
: Array [TEAM_RED
..TEAM_BLUE
] of TRGB
= ((R
:255; G
:0; B
:0),
517 DIFFICULT_EASY
: TDifficult
= (DiagFire
: 32; InvisFire
: 32; DiagPrecision
: 32;
518 FlyPrecision
: 32; Cover
: 32; CloseJump
: 32;
519 WeaponPrior
:(0,0,0,0,0,0,0,0,0,0); CloseWeaponPrior
:(0,0,0,0,0,0,0,0,0,0));
520 DIFFICULT_MEDIUM
: TDifficult
= (DiagFire
: 127; InvisFire
: 127; DiagPrecision
: 127;
521 FlyPrecision
: 127; Cover
: 127; CloseJump
: 127;
522 WeaponPrior
:(0,0,0,0,0,0,0,0,0,0); CloseWeaponPrior
:(0,0,0,0,0,0,0,0,0,0));
523 DIFFICULT_HARD
: TDifficult
= (DiagFire
: 255; InvisFire
: 255; DiagPrecision
: 255;
524 FlyPrecision
: 255; Cover
: 255; CloseJump
: 255;
525 WeaponPrior
:(0,0,0,0,0,0,0,0,0,0); CloseWeaponPrior
:(0,0,0,0,0,0,0,0,0,0));
526 WEAPON_PRIOR1
: Array [WEAPON_KASTET
..WEAPON_SUPERPULEMET
] of Byte =
527 (WEAPON_SUPERPULEMET
, WEAPON_SHOTGUN2
, WEAPON_SHOTGUN1
,
528 WEAPON_CHAINGUN
, WEAPON_PLASMA
, WEAPON_ROCKETLAUNCHER
,
529 WEAPON_BFG
, WEAPON_PISTOL
, WEAPON_SAW
, WEAPON_KASTET
);
530 WEAPON_PRIOR2
: Array [WEAPON_KASTET
..WEAPON_SUPERPULEMET
] of Byte =
531 (WEAPON_SUPERPULEMET
, WEAPON_BFG
, WEAPON_ROCKETLAUNCHER
,
532 WEAPON_SHOTGUN2
, WEAPON_PLASMA
, WEAPON_SHOTGUN1
,
533 WEAPON_CHAINGUN
, WEAPON_PISTOL
, WEAPON_SAW
, WEAPON_KASTET
);
534 //WEAPON_PRIOR3: Array [WEAPON_KASTET..WEAPON_SUPERPULEMET] of Byte =
535 // (WEAPON_SUPERPULEMET, WEAPON_BFG, WEAPON_PLASMA,
536 // WEAPON_SHOTGUN2, WEAPON_CHAINGUN, WEAPON_SHOTGUN1,
537 // WEAPON_SAW, WEAPON_ROCKETLAUNCHER, WEAPON_PISTOL, WEAPON_KASTET);
538 WEAPON_RELOAD
: Array [WEAPON_KASTET
..WEAPON_SUPERPULEMET
] of Byte =
539 (5, 2, 6, 18, 36, 2, 12, 2, 14, 2);
541 PLAYER_SIGNATURE
= $52594C50; // 'PLYR'
542 CORPSE_SIGNATURE
= $50524F43; // 'CORP'
544 BOTNAMES_FILENAME
= 'botnames.txt';
545 BOTLIST_FILENAME
= 'botlist.txt';
549 MaxCorpses
: Word = 20;
550 MaxShells
: Word = 300;
551 CurrentGib
: Integer = 0;
552 CurrentShell
: Integer = 0;
553 BotNames
: Array of String;
554 BotList
: Array of TBotProfile
;
556 function Lerp(X
, Y
, Factor
: Integer): Integer;
558 Result
:= X
+ ((Y
- X
) div Factor
);
561 function SameTeam(UID1
, UID2
: Word): Boolean;
565 if (UID1
> UID_MAX_PLAYER
) or (UID1
<= UID_MAX_GAME
) or
566 (UID2
> UID_MAX_PLAYER
) or (UID2
<= UID_MAX_GAME
) then Exit
;
568 if (g_Player_Get(UID1
) = nil) or (g_Player_Get(UID2
) = nil) then Exit
;
570 if ((g_Player_Get(UID1
).Team
= TEAM_NONE
) or
571 (g_Player_Get(UID2
).Team
= TEAM_NONE
)) then Exit
;
573 Result
:= g_Player_Get(UID1
).FTeam
= g_Player_Get(UID2
).FTeam
;
576 procedure g_Gibs_SetMax(Count
: Word);
579 SetLength(gGibs
, Count
);
581 if CurrentGib
>= Count
then
585 function g_Gibs_GetMax(): Word;
590 procedure g_Shells_SetMax(Count
: Word);
593 SetLength(gShells
, Count
);
595 if CurrentShell
>= Count
then
599 function g_Shells_GetMax(): Word;
605 procedure g_Corpses_SetMax(Count
: Word);
608 SetLength(gCorpses
, Count
);
611 function g_Corpses_GetMax(): Word;
613 Result
:= MaxCorpses
;
616 function g_Player_Create(ModelName
: String; Color
: TRGB
; Team
: Byte; Bot
: Boolean): Word;
626 // Åñòü ëè ìåñòî â gPlayers:
627 if gPlayers
<> nil then
628 for a
:= 0 to High(gPlayers
) do
629 if gPlayers
[a
] = nil then
635 // Íåò ìåñòà - ðàñøèðÿåì gPlayers:
638 SetLength(gPlayers
, Length(gPlayers
)+1);
642 // Ñîçäàåì îáúåêò èãðîêà:
644 gPlayers
[a
] := TBot
.Create()
646 gPlayers
[a
] := TPlayer
.Create();
649 gPlayers
[a
].FActualModelName
:= ModelName
;
650 gPlayers
[a
].SetModel(ModelName
);
652 // Íåò ìîäåëè - ñîçäàíèå íå âîçìîæíî:
653 if gPlayers
[a
].FModel
= nil then
657 g_FatalError(Format(_lc
[I_GAME_ERROR_MODEL
], [ModelName
]));
661 if not (Team
in [TEAM_RED
, TEAM_BLUE
]) then
662 if Random(2) = 0 then
666 gPlayers
[a
].FPreferredTeam
:= Team
;
668 case gGameSettings
.GameMode
of
669 GM_DM
: gPlayers
[a
].FTeam
:= TEAM_NONE
;
671 GM_CTF
: gPlayers
[a
].FTeam
:= gPlayers
[a
].FPreferredTeam
;
673 GM_COOP
: gPlayers
[a
].FTeam
:= TEAM_COOP
;
676 // Åñëè êîìàíäíàÿ èãðà - êðàñèì ìîäåëü â öâåò êîìàíäû:
677 gPlayers
[a
].FColor
:= Color
;
678 if gPlayers
[a
].FTeam
in [TEAM_RED
, TEAM_BLUE
] then
679 gPlayers
[a
].FModel
.Color
:= TEAMCOLOR
[gPlayers
[a
].FTeam
]
681 gPlayers
[a
].FModel
.Color
:= Color
;
683 gPlayers
[a
].FUID
:= g_CreateUID(UID_PLAYER
);
684 gPlayers
[a
].FLive
:= False;
686 Result
:= gPlayers
[a
].FUID
;
689 function g_Player_CreateFromState(var Mem
: TBinMemoryReader
): Word;
702 if sig
<> PLAYER_SIGNATURE
then // 'PLYR'
704 raise EBinSizeError
.Create('g_Player_CreateFromState: Wrong Player Signature');
708 Mem
.ReadBoolean(Bot
);
713 // Åñòü ëè ìåñòî â gPlayers:
714 if gPlayers
<> nil then
715 for a
:= 0 to High(gPlayers
) do
716 if gPlayers
[a
] = nil then
722 // Íåò ìåñòà - ðàñøèðÿåì gPlayers:
725 SetLength(gPlayers
, Length(gPlayers
)+1);
729 // Ñîçäàåì îáúåêò èãðîêà:
731 gPlayers
[a
] := TBot
.Create()
733 gPlayers
[a
] := TPlayer
.Create();
734 gPlayers
[a
].FIamBot
:= Bot
;
735 gPlayers
[a
].FPhysics
:= True;
738 Mem
.ReadWord(gPlayers
[a
].FUID
);
740 Mem
.ReadString(gPlayers
[a
].FName
);
742 Mem
.ReadByte(gPlayers
[a
].FTeam
);
743 gPlayers
[a
].FPreferredTeam
:= gPlayers
[a
].FTeam
;
745 Mem
.ReadBoolean(gPlayers
[a
].FLive
);
746 // Èçðàñõîäîâàë ëè âñå æèçíè:
747 Mem
.ReadBoolean(gPlayers
[a
].FNoRespawn
);
751 gPlayers
[a
].FDirection
:= D_LEFT
753 gPlayers
[a
].FDirection
:= D_RIGHT
;
755 Mem
.ReadInt(gPlayers
[a
].FHealth
);
757 Mem
.ReadByte(gPlayers
[a
].FLives
);
759 Mem
.ReadInt(gPlayers
[a
].FArmor
);
761 Mem
.ReadInt(gPlayers
[a
].FAir
);
763 Mem
.ReadInt(gPlayers
[a
].FJetFuel
);
765 Mem
.ReadInt(gPlayers
[a
].FPain
);
767 Mem
.ReadInt(gPlayers
[a
].FKills
);
769 Mem
.ReadInt(gPlayers
[a
].FMonsterKills
);
771 Mem
.ReadInt(gPlayers
[a
].FFrags
);
773 Mem
.ReadByte(gPlayers
[a
].FFragCombo
);
774 // Âðåìÿ ïîñëåäíåãî ôðàãà:
775 Mem
.ReadDWORD(gPlayers
[a
].FLastFrag
);
777 Mem
.ReadInt(gPlayers
[a
].FDeath
);
779 Mem
.ReadByte(gPlayers
[a
].FFlag
);
781 Mem
.ReadInt(gPlayers
[a
].FSecrets
);
783 Mem
.ReadByte(gPlayers
[a
].FCurrWeap
);
784 // Âðåìÿ çàðÿäêè BFG:
785 Mem
.ReadSmallInt(gPlayers
[a
].FBFGFireCounter
);
787 Mem
.ReadInt(gPlayers
[a
].FDamageBuffer
);
788 // Ïîñëåäíèé óäàðèâøèé:
789 Mem
.ReadWord(gPlayers
[a
].FLastSpawnerUID
);
790 // Òèï ïîñëåäíåãî ïîëó÷åííîãî óðîíà:
791 Mem
.ReadByte(gPlayers
[a
].FLastHit
);
793 Obj_LoadState(@gPlayers
[a
].FObj
, Mem
);
794 // Òåêóùåå êîëè÷åñòâî ïàòðîíîâ:
795 for i
:= A_BULLETS
to A_CELLS
do
796 Mem
.ReadWord(gPlayers
[a
].FAmmo
[i
]);
797 // Ìàêñèìàëüíîå êîëè÷åñòâî ïàòðîíîâ:
798 for i
:= A_BULLETS
to A_CELLS
do
799 Mem
.ReadWord(gPlayers
[a
].FMaxAmmo
[i
]);
801 for i
:= WEAPON_KASTET
to WEAPON_SUPERPULEMET
do
802 Mem
.ReadBoolean(gPlayers
[a
].FWeapon
[i
]);
803 // Âðåìÿ ïåðåçàðÿäêè îðóæèÿ:
804 for i
:= WEAPON_KASTET
to WEAPON_SUPERPULEMET
do
805 Mem
.ReadWord(gPlayers
[a
].FReloading
[i
]);
809 Include(gPlayers
[a
].FRulez
, R_ITEM_BACKPACK
);
810 // Íàëè÷èå êðàñíîãî êëþ÷à:
813 Include(gPlayers
[a
].FRulez
, R_KEY_RED
);
814 // Íàëè÷èå çåëåíîãî êëþ÷à:
817 Include(gPlayers
[a
].FRulez
, R_KEY_GREEN
);
818 // Íàëè÷èå ñèíåãî êëþ÷à:
821 Include(gPlayers
[a
].FRulez
, R_KEY_BLUE
);
825 Include(gPlayers
[a
].FRulez
, R_BERSERK
);
826 // Âðåìÿ äåéñòâèÿ ñïåöèàëüíûõ ïðåäìåòîâ:
827 for i
:= MR_SUIT
to MR_MAX
do
828 Mem
.ReadDWORD(gPlayers
[a
].FMegaRulez
[i
]);
829 // Âðåìÿ äî ïîâòîðíîãî ðåñïàóíà, ñìåíû îðóæèÿ, èñîëüçîâàíèÿ, çàõâàòà ôëàãà:
830 for i
:= T_RESPAWN
to T_FLAGCAP
do
831 Mem
.ReadDWORD(gPlayers
[a
].FTime
[i
]);
834 Mem
.ReadString(gPlayers
[a
].FActualModelName
);
836 Mem
.ReadByte(gPlayers
[a
].FColor
.R
);
837 Mem
.ReadByte(gPlayers
[a
].FColor
.G
);
838 Mem
.ReadByte(gPlayers
[a
].FColor
.B
);
839 // Îáíîâëÿåì ìîäåëü èãðîêà:
840 gPlayers
[a
].SetModel(gPlayers
[a
].FActualModelName
);
842 // Íåò ìîäåëè - ñîçäàíèå íå âîçìîæíî:
843 if gPlayers
[a
].FModel
= nil then
847 g_FatalError(Format(_lc
[I_GAME_ERROR_MODEL
], [gPlayers
[a
].FActualModelName
]));
851 // Åñëè êîìàíäíàÿ èãðà - êðàñèì ìîäåëü â öâåò êîìàíäû:
852 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
853 gPlayers
[a
].FModel
.Color
:= TEAMCOLOR
[gPlayers
[a
].FTeam
]
855 gPlayers
[a
].FModel
.Color
:= gPlayers
[a
].FColor
;
857 Result
:= gPlayers
[a
].FUID
;
860 procedure g_Player_ResetTeams();
864 if g_Game_IsClient
then
866 if gPlayers
= nil then
868 for a
:= Low(gPlayers
) to High(gPlayers
) do
869 if gPlayers
[a
] <> nil then
870 case gGameSettings
.GameMode
of
872 gPlayers
[a
].ChangeTeam(TEAM_NONE
);
874 if not (gPlayers
[a
].Team
in [TEAM_RED
, TEAM_BLUE
]) then
875 if gPlayers
[a
].FPreferredTeam
in [TEAM_RED
, TEAM_BLUE
] then
876 gPlayers
[a
].ChangeTeam(gPlayers
[a
].FPreferredTeam
)
879 gPlayers
[a
].ChangeTeam(TEAM_RED
)
881 gPlayers
[a
].ChangeTeam(TEAM_BLUE
);
884 gPlayers
[a
].ChangeTeam(TEAM_COOP
);
888 procedure g_Bot_Add(Team
, Difficult
: Byte);
891 _name
, _model
: String;
894 if not g_Game_IsServer
then Exit
;
896 // Ñïèñîê íàçâàíèé ìîäåëåé:
897 m
:= g_PlayerModel_GetNames();
902 if (gGameSettings
.GameType
= GT_SINGLE
) or (gGameSettings
.GameMode
= GM_COOP
) then
903 Team
:= TEAM_COOP
// COOP
905 if gGameSettings
.GameMode
= GM_DM
then
906 Team
:= TEAM_NONE
// DM
908 if Team
= TEAM_NONE
then // CTF / TDM
910 // Àâòîáàëàíñ êîìàíä:
914 for a
:= 0 to High(gPlayers
) do
915 if gPlayers
[a
] <> nil then
917 if gPlayers
[a
].Team
= TEAM_RED
then
920 if gPlayers
[a
].Team
= TEAM_BLUE
then
930 if Random(2) = 0 then
936 // Âûáèðàåì áîòó èìÿ:
938 if BotNames
<> nil then
939 for a
:= 0 to High(BotNames
) do
940 if g_Player_ValidName(BotNames
[a
]) then
942 _name
:= BotNames
[a
];
946 // Èìåíè íåò, çàäàåì ñëó÷àéíîå:
949 _name
:= Format('DFBOT%.2d', [Random(100)]);
950 until g_Player_ValidName(_name
);
952 // Âûáèðàåì ñëó÷àéíóþ ìîäåëü:
953 _model
:= m
[Random(Length(m
))];
956 with g_Player_Get(g_Player_Create(_model
,
957 _RGB(Min(Random(9)*32, 255),
958 Min(Random(9)*32, 255),
959 Min(Random(9)*32, 255)),
960 Team
, True)) as TBot
do
965 1: FDifficult
:= DIFFICULT_EASY
;
966 2: FDifficult
:= DIFFICULT_MEDIUM
;
967 else FDifficult
:= DIFFICULT_HARD
;
970 for a
:= WEAPON_KASTET
to WEAPON_SUPERPULEMET
do
972 FDifficult
.WeaponPrior
[a
] := WEAPON_PRIOR1
[a
];
973 FDifficult
.CloseWeaponPrior
[a
] := WEAPON_PRIOR2
[a
];
974 //FDifficult.SafeWeaponPrior[a] := WEAPON_PRIOR3[a];
977 g_Console_Add(Format(_lc
[I_PLAYER_JOIN
], [Name
]), True);
979 if g_Game_IsNet
then MH_SEND_PlayerCreate(UID
);
980 if g_Game_IsServer
and (gGameSettings
.MaxLives
> 0) then
985 procedure g_Bot_AddList(Team
: Byte; lName
: ShortString; num
: Integer = -1);
988 _name
, _model
: String;
991 if not g_Game_IsServer
then Exit
;
993 // Ñïèñîê íàçâàíèé ìîäåëåé:
994 m
:= g_PlayerModel_GetNames();
999 if (gGameSettings
.GameType
= GT_SINGLE
) or (gGameSettings
.GameMode
= GM_COOP
) then
1000 Team
:= TEAM_COOP
// COOP
1002 if gGameSettings
.GameMode
= GM_DM
then
1003 Team
:= TEAM_NONE
// DM
1005 if Team
= TEAM_NONE
then
1006 Team
:= BotList
[num
].team
; // CTF / TDM
1008 // Âûáèðàåì íàñòðîéêè áîòà èç ñïèñêà ïî íîìåðó èëè èìåíè:
1009 lName
:= AnsiLowerCase(lName
);
1010 if (num
< 0) or (num
> Length(BotList
)-1) then
1012 if (num
= -1) and (lName
<> '') and (BotList
<> nil) then
1013 for a
:= 0 to High(BotList
) do
1014 if AnsiLowerCase(BotList
[a
].name
) = lName
then
1023 _name
:= BotList
[num
].name
;
1024 // Çàíÿòî - âûáèðàåì ñëó÷àéíîå:
1025 if not g_Player_ValidName(_name
) then
1027 _name
:= Format('DFBOT%.2d', [Random(100)]);
1028 until g_Player_ValidName(_name
);
1031 _model
:= BotList
[num
].model
;
1032 // Íåò òàêîé - âûáèðàåì ñëó÷àéíóþ:
1033 if not InSArray(_model
, m
) then
1034 _model
:= m
[Random(Length(m
))];
1037 with g_Player_Get(g_Player_Create(_model
, BotList
[num
].color
, Team
, True)) as TBot
do
1041 FDifficult
.DiagFire
:= BotList
[num
].diag_fire
;
1042 FDifficult
.InvisFire
:= BotList
[num
].invis_fire
;
1043 FDifficult
.DiagPrecision
:= BotList
[num
].diag_precision
;
1044 FDifficult
.FlyPrecision
:= BotList
[num
].fly_precision
;
1045 FDifficult
.Cover
:= BotList
[num
].cover
;
1046 FDifficult
.CloseJump
:= BotList
[num
].close_jump
;
1048 for a
:= WEAPON_KASTET
to WEAPON_SUPERPULEMET
do
1050 FDifficult
.WeaponPrior
[a
] := BotList
[num
].w_prior1
[a
];
1051 FDifficult
.CloseWeaponPrior
[a
] := BotList
[num
].w_prior2
[a
];
1052 //FDifficult.SafeWeaponPrior[a] := BotList[num].w_prior3[a];
1055 g_Console_Add(Format(_lc
[I_PLAYER_JOIN
], [Name
]), True);
1057 if g_Game_IsNet
then MH_SEND_PlayerCreate(UID
);
1061 procedure g_Bot_RemoveAll();
1065 if not g_Game_IsServer
then Exit
;
1066 if gPlayers
= nil then Exit
;
1068 for a
:= 0 to High(gPlayers
) do
1069 if gPlayers
[a
] <> nil then
1070 if gPlayers
[a
] is TBot
then
1072 gPlayers
[a
].Lives
:= 0;
1073 gPlayers
[a
].Kill(K_SIMPLEKILL
, 0, HIT_DISCON
);
1074 g_Console_Add(Format(_lc
[I_PLAYER_LEAVE
], [gPlayers
[a
].Name
]), True);
1075 g_Player_Remove(gPlayers
[a
].FUID
);
1081 procedure g_Bot_MixNames();
1086 if BotNames
<> nil then
1087 for a
:= 0 to High(BotNames
) do
1089 b
:= Random(Length(BotNames
));
1091 Botnames
[a
] := BotNames
[b
];
1096 procedure g_Player_Remove(UID
: Word);
1100 if gPlayers
= nil then Exit
;
1102 if g_Game_IsServer
and g_Game_IsNet
then
1103 MH_SEND_PlayerDelete(UID
);
1105 for i
:= 0 to High(gPlayers
) do
1106 if gPlayers
[i
] <> nil then
1107 if gPlayers
[i
].FUID
= UID
then
1109 if gPlayers
[i
] is TPlayer
then
1110 TPlayer(gPlayers
[i
]).Free()
1112 TBot(gPlayers
[i
]).Free();
1118 procedure g_Player_Init();
1128 if not FileExists(DataDir
+ BOTNAMES_FILENAME
) then
1131 // ×èòàåì âîçìîæíûå èìåíà áîòîâ èç ôàéëà:
1132 AssignFile(F
, DataDir
+ BOTNAMES_FILENAME
);
1143 SetLength(BotNames
, Length(BotNames
)+1);
1144 BotNames
[High(BotNames
)] := s
;
1152 // ×èòàåì ôàéë ñ ïàðàìåòðàìè áîòîâ:
1153 config
:= TConfig
.CreateFile(DataDir
+ BOTLIST_FILENAME
);
1157 while config
.SectionExists(IntToStr(a
)) do
1159 SetLength(BotList
, Length(BotList
)+1);
1161 with BotList
[High(BotList
)] do
1164 name
:= config
.ReadStr(IntToStr(a
), 'name', '');
1166 model
:= config
.ReadStr(IntToStr(a
), 'model', '');
1168 if config
.ReadStr(IntToStr(a
), 'team', 'red') = 'red' then
1173 sa
:= parse(config
.ReadStr(IntToStr(a
), 'color', ''));
1174 color
.R
:= StrToIntDef(sa
[0], 0);
1175 color
.G
:= StrToIntDef(sa
[1], 0);
1176 color
.B
:= StrToIntDef(sa
[2], 0);
1177 // Âåðîÿòíîñòü ñòðåëüáû ïîä óãëîì:
1178 diag_fire
:= config
.ReadInt(IntToStr(a
), 'diag_fire', 0);
1179 // Âåðîÿòíîñòü îòâåòíîãî îãíÿ ïî íåâèäèìîìó ñîïåðíèêó:
1180 invis_fire
:= config
.ReadInt(IntToStr(a
), 'invis_fire', 0);
1181 // Òî÷íîñòü ñòðåëüáû ïîä óãëîì:
1182 diag_precision
:= config
.ReadInt(IntToStr(a
), 'diag_precision', 0);
1183 // Òî÷íîñòü ñòðåëüáû â ïîëåòå:
1184 fly_precision
:= config
.ReadInt(IntToStr(a
), 'fly_precision', 0);
1185 // Òî÷íîñòü óêëîíåíèÿ îò ñíàðÿäîâ:
1186 cover
:= config
.ReadInt(IntToStr(a
), 'cover', 0);
1187 // Âåðîÿòíîñòü ïðûæêà ïðè ïðèáëèæåíèè ñîïåðíèêà:
1188 close_jump
:= config
.ReadInt(IntToStr(a
), 'close_jump', 0);
1189 // Ïðèîðèòåòû îðóæèÿ äëÿ äàëüíåãî áîÿ:
1190 sa
:= parse(config
.ReadStr(IntToStr(a
), 'w_prior1', ''));
1191 if Length(sa
) = 10 then
1193 w_prior1
[b
] := EnsureRange(StrToInt(sa
[b
]), 0, 9);
1194 // Ïðèîðèòåòû îðóæèÿ äëÿ áëèæíåãî áîÿ:
1195 sa
:= parse(config
.ReadStr(IntToStr(a
), 'w_prior2', ''));
1196 if Length(sa
) = 10 then
1198 w_prior2
[b
] := EnsureRange(StrToInt(sa
[b
]), 0, 9);
1200 {sa := parse(config.ReadStr(IntToStr(a), 'w_prior3', ''));
1201 if Length(sa) = 10 then
1203 w_prior3[b] := EnsureRange(StrToInt(sa[b]), 0, 9);}
1212 procedure g_Player_Free();
1216 if gPlayers
<> nil then
1218 for i
:= 0 to High(gPlayers
) do
1219 if gPlayers
[i
] <> nil then
1221 if gPlayers
[i
] is TPlayer
then
1222 TPlayer(gPlayers
[i
]).Free()
1224 TBot(gPlayers
[i
]).Free();
1235 procedure g_Player_UpdateAll();
1239 if gPlayers
= nil then Exit
;
1241 for i
:= 0 to High(gPlayers
) do
1242 if gPlayers
[i
] <> nil then
1243 if gPlayers
[i
] is TPlayer
then gPlayers
[i
].Update()
1244 else TBot(gPlayers
[i
]).Update();
1247 procedure g_Player_DrawAll();
1251 if gPlayers
= nil then Exit
;
1253 for i
:= 0 to High(gPlayers
) do
1254 if gPlayers
[i
] <> nil then
1255 if gPlayers
[i
] is TPlayer
then gPlayers
[i
].Draw()
1256 else TBot(gPlayers
[i
]).Draw();
1259 procedure g_Player_DrawDebug(p
: TPlayer
);
1263 if p
= nil then Exit
;
1264 if (@p
.FObj
) = nil then Exit
;
1266 e_TextureFontGetSize(gStdFont
, fW
, fH
);
1268 e_TextureFontPrint(0, 0 , 'Pos X: ' + IntToStr(p
.FObj
.X
), gStdFont
);
1269 e_TextureFontPrint(0, fH
, 'Pos Y: ' + IntToStr(p
.FObj
.Y
), gStdFont
);
1270 e_TextureFontPrint(0, fH
* 2, 'Vel X: ' + IntToStr(p
.FObj
.Vel
.X
), gStdFont
);
1271 e_TextureFontPrint(0, fH
* 3, 'Vel Y: ' + IntToStr(p
.FObj
.Vel
.Y
), gStdFont
);
1272 e_TextureFontPrint(0, fH
* 4, 'Acc X: ' + IntToStr(p
.FObj
.Accel
.X
), gStdFont
);
1273 e_TextureFontPrint(0, fH
* 5, 'Acc Y: ' + IntToStr(p
.FObj
.Accel
.Y
), gStdFont
);
1276 procedure g_Player_DrawHealth();
1281 if gPlayers
= nil then Exit
;
1282 e_TextureFontGetSize(gStdFont
, fW
, fH
);
1284 for i
:= 0 to High(gPlayers
) do
1285 if gPlayers
[i
] <> nil then
1287 e_TextureFontPrint(gPlayers
[i
].FObj
.X
+ gPlayers
[i
].FObj
.Rect
.X
,
1288 gPlayers
[i
].FObj
.Y
+ gPlayers
[i
].FObj
.Rect
.Y
+ gPlayers
[i
].FObj
.Rect
.Height
- fH
* 2,
1289 IntToStr(gPlayers
[i
].FHealth
), gStdFont
);
1290 e_TextureFontPrint(gPlayers
[i
].FObj
.X
+ gPlayers
[i
].FObj
.Rect
.X
,
1291 gPlayers
[i
].FObj
.Y
+ gPlayers
[i
].FObj
.Rect
.Y
+ gPlayers
[i
].FObj
.Rect
.Height
- fH
,
1292 IntToStr(gPlayers
[i
].FArmor
), gStdFont
);
1296 function g_Player_Get(UID
: Word): TPlayer
;
1302 if gPlayers
= nil then
1305 for a
:= 0 to High(gPlayers
) do
1306 if gPlayers
[a
] <> nil then
1307 if gPlayers
[a
].FUID
= UID
then
1309 Result
:= gPlayers
[a
];
1314 function g_Player_GetCount(): Byte;
1320 if gPlayers
= nil then
1323 for a
:= 0 to High(gPlayers
) do
1324 if gPlayers
[a
] <> nil then
1325 Result
:= Result
+ 1;
1328 function g_Player_GetStats(): TPlayerStatArray
;
1334 if gPlayers
= nil then Exit
;
1336 for a
:= 0 to High(gPlayers
) do
1337 if gPlayers
[a
] <> nil then
1339 SetLength(Result
, Length(Result
)+1);
1340 with Result
[High(Result
)] do
1342 Ping
:= gPlayers
[a
].FPing
;
1343 Loss
:= gPlayers
[a
].FLoss
;
1344 Name
:= gPlayers
[a
].FName
;
1345 Team
:= gPlayers
[a
].FTeam
;
1346 Frags
:= gPlayers
[a
].FFrags
;
1347 Deaths
:= gPlayers
[a
].FDeath
;
1348 Kills
:= gPlayers
[a
].FKills
;
1349 Color
:= gPlayers
[a
].FModel
.Color
;
1350 Lives
:= gPlayers
[a
].FLives
;
1351 Spectator
:= gPlayers
[a
].FSpectator
;
1356 procedure g_Player_RememberAll
;
1360 for i
:= Low(gPlayers
) to High(gPlayers
) do
1361 if (gPlayers
[i
] <> nil) and gPlayers
[i
].Live
then
1362 gPlayers
[i
].RememberState
;
1365 procedure g_Player_ResetAll(Force
, Silent
: Boolean);
1369 gTeamStat
[TEAM_RED
].Goals
:= 0;
1370 gTeamStat
[TEAM_BLUE
].Goals
:= 0;
1372 if gPlayers
<> nil then
1373 for i
:= 0 to High(gPlayers
) do
1374 if gPlayers
[i
] <> nil then
1376 gPlayers
[i
].Reset(Force
);
1378 if gPlayers
[i
] is TPlayer
then
1380 if (not gPlayers
[i
].FSpectator
) or gPlayers
[i
].FWantsInGame
then
1381 gPlayers
[i
].Respawn(Silent
)
1383 gPlayers
[i
].Spectate();
1386 TBot(gPlayers
[i
]).Respawn(Silent
);
1390 procedure g_Player_CreateCorpse(Player
: TPlayer
);
1397 if Player
.FObj
.Y
>= gMapInfo
.Height
+128 then
1402 if (FHealth
>= -50) or (gGibsCount
= 0) then
1404 if (gCorpses
= nil) or (Length(gCorpses
) = 0) then
1408 for find_id
:= 0 to High(gCorpses
) do
1409 if gCorpses
[find_id
] = nil then
1416 find_id
:= Random(Length(gCorpses
));
1418 gCorpses
[find_id
] := TCorpse
.Create(FObj
.X
, FObj
.Y
, FModel
.Name
, FHealth
< -20);
1419 gCorpses
[find_id
].FColor
:= FModel
.Color
;
1420 gCorpses
[find_id
].FObj
.Vel
:= FObj
.Vel
;
1421 gCorpses
[find_id
].FObj
.Accel
:= FObj
.Accel
;
1424 g_Player_CreateGibs(FObj
.X
+ PLAYER_RECT_CX
,
1425 FObj
.Y
+ PLAYER_RECT_CY
,
1426 FModel
.Name
, FModel
.Color
);
1430 procedure g_Player_CreateShell(fX
, fY
, dX
, dY
: Integer; T
: Byte);
1434 if (gShells
= nil) or (Length(gShells
) = 0) then
1437 with gShells
[CurrentShell
] do
1443 if T
= SHELL_BULLET
then
1445 if g_Texture_Get('TEXTURE_SHELL_BULLET', SID
) then
1449 Obj
.Rect
.Width
:= 4;
1450 Obj
.Rect
.Height
:= 2;
1454 if g_Texture_Get('TEXTURE_SHELL_SHELL', SID
) then
1458 Obj
.Rect
.Width
:= 7;
1459 Obj
.Rect
.Height
:= 3;
1465 g_Obj_Push(@Obj
, dX
+ Random(4)-Random(4), dY
-Random(4));
1466 RAngle
:= Random(360);
1467 Timeout
:= gTime
+ SHELL_TIMEOUT
;
1469 if CurrentShell
>= High(gShells
) then
1476 procedure g_Player_CreateGibs(fX
, fY
: Integer; ModelName
: string; fColor
: TRGB
);
1479 GibsArray
: TGibsArray
;
1481 if (gGibs
= nil) or (Length(gGibs
) = 0) then
1483 if not g_PlayerModel_GetGibs(ModelName
, GibsArray
) then
1486 for a
:= 0 to High(GibsArray
) do
1487 with gGibs
[CurrentGib
] do
1490 ID
:= GibsArray
[a
].ID
;
1491 MaskID
:= GibsArray
[a
].MaskID
;
1494 Obj
.Rect
:= GibsArray
[a
].Rect
;
1495 Obj
.X
:= fX
-GibsArray
[a
].Rect
.X
-(GibsArray
[a
].Rect
.Width
div 2);
1496 Obj
.Y
:= fY
-GibsArray
[a
].Rect
.Y
-(GibsArray
[a
].Rect
.Height
div 2);
1497 g_Obj_PushA(@Obj
, 25 + Random(10), Random(361));
1498 RAngle
:= Random(360);
1500 if gBloodCount
> 0 then
1501 g_GFX_Blood(fX
, fY
, 16*gBloodCount
+Random(5*gBloodCount
), -16+Random(33), -16+Random(33),
1502 Random(48), Random(48), 150, 0, 0);
1504 if CurrentGib
>= High(gGibs
) then
1511 procedure g_Player_UpdatePhysicalObjects();
1517 procedure ShellSound_Bounce(X
, Y
: Integer; T
: Byte);
1522 if T
= SHELL_BULLET
then
1523 g_Sound_PlayExAt('SOUND_PLAYER_CASING' + IntToStr(k
), X
, Y
)
1525 g_Sound_PlayExAt('SOUND_PLAYER_SHELL' + IntToStr(k
), X
, Y
);
1530 if gGibs
<> nil then
1531 for i
:= 0 to High(gGibs
) do
1532 if gGibs
[i
].Live
then
1536 mr
:= g_Obj_Move(@Obj
, True, False, True);
1538 if WordBool(mr
and MOVE_FALLOUT
) then
1544 // Îòëåòàåò îò óäàðà î ñòåíó/ïîòîëîê/ïîë:
1545 if WordBool(mr
and MOVE_HITWALL
) then
1546 Obj
.Vel
.X
:= -(vel
.X
div 2);
1547 if WordBool(mr
and (MOVE_HITCEIL
or MOVE_HITLAND
)) then
1548 Obj
.Vel
.Y
:= -(vel
.Y
div 2);
1550 if (Obj
.Vel
.X
>= 0) then
1552 RAngle
:= RAngle
+ Abs(Obj
.Vel
.X
)*6 + Abs(Obj
.Vel
.Y
);
1553 if RAngle
>= 360 then
1554 RAngle
:= RAngle
mod 360;
1555 end else begin // Counter-clockwise
1556 RAngle
:= RAngle
- Abs(Obj
.Vel
.X
)*6 - Abs(Obj
.Vel
.Y
);
1558 RAngle
:= (360 - (Abs(RAngle
) mod 360)) mod 360;
1561 // Ñîïðîòèâëåíèå âîçäóõà äëÿ êóñêà òðóïà:
1562 if gTime
mod (GAME_TICK
*3) = 0 then
1563 Obj
.Vel
.X
:= z_dec(Obj
.Vel
.X
, 1);
1567 if gCorpses
<> nil then
1568 for i
:= 0 to High(gCorpses
) do
1569 if gCorpses
[i
] <> nil then
1570 if gCorpses
[i
].State
= CORPSE_STATE_REMOVEME
then
1576 gCorpses
[i
].Update();
1579 if gShells
<> nil then
1580 for i
:= 0 to High(gShells
) do
1581 if gShells
[i
].Live
then
1585 mr
:= g_Obj_Move(@Obj
, True, False, True);
1587 if WordBool(mr
and MOVE_FALLOUT
) or (gShells
[i
].Timeout
< gTime
) then
1593 // Îòëåòàåò îò óäàðà î ñòåíó/ïîòîëîê/ïîë:
1594 if WordBool(mr
and MOVE_HITWALL
) then
1596 Obj
.Vel
.X
:= -(vel
.X
div 2);
1597 if not WordBool(mr
and MOVE_INWATER
) then
1598 ShellSound_Bounce(Obj
.X
, Obj
.Y
, SType
);
1600 if WordBool(mr
and (MOVE_HITCEIL
or MOVE_HITLAND
)) then
1602 Obj
.Vel
.Y
:= -(vel
.Y
div 2);
1603 if Obj
.Vel
.X
<> 0 then Obj
.Vel
.X
:= Obj
.Vel
.X
div 2;
1604 if (Obj
.Vel
.X
= 0) and (Obj
.Vel
.Y
= 0) then
1606 if RAngle
mod 90 <> 0 then
1607 RAngle
:= (RAngle
div 90) * 90;
1609 else if not WordBool(mr
and MOVE_INWATER
) then
1610 ShellSound_Bounce(Obj
.X
, Obj
.Y
, SType
);
1613 if (Obj
.Vel
.X
>= 0) then
1615 RAngle
:= RAngle
+ Abs(Obj
.Vel
.X
)*8 + Abs(Obj
.Vel
.Y
);
1616 if RAngle
>= 360 then
1617 RAngle
:= RAngle
mod 360;
1618 end else begin // Counter-clockwise
1619 RAngle
:= RAngle
- Abs(Obj
.Vel
.X
)*8 - Abs(Obj
.Vel
.Y
);
1621 RAngle
:= (360 - (Abs(RAngle
) mod 360)) mod 360;
1626 procedure g_Player_DrawCorpses();
1631 if gGibs
<> nil then
1632 for i
:= 0 to High(gGibs
) do
1633 if gGibs
[i
].Live
then
1636 if not g_Obj_Collide(sX
, sY
, sWidth
, sHeight
, @Obj
) then
1639 a
.X
:= Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2);
1640 a
.y
:= Obj
.Rect
.Y
+(Obj
.Rect
.Height
div 2);
1642 e_DrawAdv(ID
, Obj
.X
, Obj
.Y
, 0, True, False, RAngle
, @a
, M_NONE
);
1645 e_DrawAdv(MaskID
, Obj
.X
, Obj
.Y
, 0, True, False, RAngle
, @a
, M_NONE
);
1651 if gCorpses
<> nil then
1652 for i
:= 0 to High(gCorpses
) do
1653 if gCorpses
[i
] <> nil then
1657 procedure g_Player_DrawShells();
1662 if gShells
<> nil then
1663 for i
:= 0 to High(gShells
) do
1664 if gShells
[i
].Live
then
1667 if not g_Obj_Collide(sX
, sY
, sWidth
, sHeight
, @Obj
) then
1673 e_DrawAdv(SpriteID
, Obj
.X
, Obj
.Y
, 0, True, False, RAngle
, @a
, M_NONE
);
1677 procedure g_Player_RemoveAllCorpses();
1683 SetLength(gGibs
, MaxGibs
);
1684 SetLength(gShells
, MaxGibs
);
1688 if gCorpses
<> nil then
1689 for i
:= 0 to High(gCorpses
) do
1693 SetLength(gCorpses
, MaxCorpses
);
1696 procedure g_Player_Corpses_SaveState(var Mem
: TBinMemoryWriter
);
1701 // Ñ÷èòàåì êîëè÷åñòâî ñóùåñòâóþùèõ òðóïîâ:
1703 if gCorpses
<> nil then
1704 for i
:= 0 to High(gCorpses
) do
1705 if gCorpses
[i
] <> nil then
1708 Mem
:= TBinMemoryWriter
.Create((count
+1) * 128);
1710 // Êîëè÷åñòâî òðóïîâ:
1711 Mem
.WriteInt(count
);
1717 for i
:= 0 to High(gCorpses
) do
1718 if gCorpses
[i
] <> nil then
1721 Mem
.WriteString(gCorpses
[i
].FModelName
);
1723 b
:= gCorpses
[i
].Mess
;
1724 Mem
.WriteBoolean(b
);
1725 // Ñîõðàíÿåì äàííûå òðóïà:
1726 gCorpses
[i
].SaveState(Mem
);
1730 procedure g_Player_Corpses_LoadState(var Mem
: TBinMemoryReader
);
1739 g_Player_RemoveAllCorpses();
1741 // Êîëè÷åñòâî òðóïîâ:
1744 if count
> Length(gCorpses
) then
1746 raise EBinSizeError
.Create('g_Player_Corpses_LoadState: Too Many Corpses');
1753 for i
:= 0 to count
-1 do
1756 Mem
.ReadString(str
);
1760 gCorpses
[i
] := TCorpse
.Create(0, 0, str
, b
);
1761 // Çàãðóæàåì äàííûå òðóïà:
1762 gCorpses
[i
].LoadState(Mem
);
1768 procedure TPlayer
.BFGHit();
1770 g_Weapon_BFGHit(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
1771 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2));
1772 if g_Game_IsServer
and g_Game_IsNet
then
1773 MH_SEND_Effect(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
1774 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2),
1778 procedure TPlayer
.ChangeModel(ModelName
: string);
1780 Model
: TPlayerModel
;
1782 Model
:= g_PlayerModel_Get(ModelName
);
1783 if Model
= nil then Exit
;
1789 procedure TPlayer
.SetModel(ModelName
: string);
1793 m
:= g_PlayerModel_Get(ModelName
);
1796 g_SimpleError(Format(_lc
[I_GAME_ERROR_MODEL_FALLBACK
], [ModelName
]));
1797 m
:= g_PlayerModel_Get('doomer');
1800 g_FatalError(Format(_lc
[I_GAME_ERROR_MODEL
], ['doomer']));
1805 if FModel
<> nil then
1810 if not (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then
1811 FModel
.Color
:= FColor
1813 FModel
.Color
:= TEAMCOLOR
[FTeam
];
1814 FModel
.SetWeapon(FCurrWeap
);
1815 FModel
.SetFlag(FFlag
);
1816 SetDirection(FDirection
);
1819 procedure TPlayer
.SetColor(Color
: TRGB
);
1822 if not (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then
1823 if FModel
<> nil then FModel
.Color
:= Color
;
1826 procedure TPlayer
.SwitchTeam
;
1828 if g_Game_IsClient
then
1830 if not (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then Exit
;
1832 if gGameOn
and FLive
then
1833 Kill(K_SIMPLEKILL
, FUID
, HIT_SELF
);
1835 if FTeam
= TEAM_RED
then
1837 ChangeTeam(TEAM_BLUE
);
1838 g_Console_Add(Format(_lc
[I_PLAYER_CHTEAM_BLUE
], [FName
]), True);
1839 if g_Game_IsNet
then
1840 MH_SEND_GameEvent(NET_EV_CHANGE_TEAM
, TEAM_BLUE
, FName
);
1844 ChangeTeam(TEAM_RED
);
1845 g_Console_Add(Format(_lc
[I_PLAYER_CHTEAM_RED
], [FName
]), True);
1846 if g_Game_IsNet
then
1847 MH_SEND_GameEvent(NET_EV_CHANGE_TEAM
, TEAM_RED
, FName
);
1849 FPreferredTeam
:= FTeam
;
1852 procedure TPlayer
.ChangeTeam(Team
: Byte);
1859 TEAM_RED
, TEAM_BLUE
:
1860 FModel
.Color
:= TEAMCOLOR
[Team
];
1862 FModel
.Color
:= FColor
;
1864 if (FTeam
<> OldTeam
) and g_Game_IsNet
and g_Game_IsServer
then
1865 MH_SEND_PlayerStats(FUID
);
1869 procedure TPlayer.CollideItem();
1874 if gItems = nil then Exit;
1875 if not FLive then Exit;
1877 for i := 0 to High(gItems) do
1880 if (ItemType <> ITEM_NONE) and Live then
1881 if g_Obj_Collide(FObj.X+PLAYER_RECT.X, FObj.Y+PLAYER_RECT.Y, PLAYER_RECT.Width,
1882 PLAYER_RECT.Height, @Obj) then
1884 if not PickItem(ItemType, gItems[i].Respawnable, r) then Continue;
1886 if ItemType in [ITEM_SPHERE_BLUE, ITEM_SPHERE_WHITE, ITEM_INVUL] then
1887 g_Sound_PlayExAt('SOUND_ITEM_GETRULEZ', FObj.X, FObj.Y)
1888 else if ItemType in [ITEM_MEDKIT_SMALL, ITEM_MEDKIT_LARGE, ITEM_MEDKIT_BLACK] then
1889 g_Sound_PlayExAt('SOUND_ITEM_GETMED', FObj.X, FObj.Y)
1890 else g_Sound_PlayExAt('SOUND_ITEM_GETITEM', FObj.X, FObj.Y);
1892 // Íàäî óáðàòü ñ êàðòû, åñëè ýòî íå êëþ÷, êîòîðûì íóæíî ïîäåëèòñÿ ñ äðóãèì èãðîêîì:
1893 if r and not ((ItemType in [ITEM_KEY_RED, ITEM_KEY_GREEN, ITEM_KEY_BLUE]) and
1894 (gGameSettings.GameType = GT_SINGLE) and
1895 (g_Player_GetCount() > 1)) then
1896 if not Respawnable then g_Items_Remove(i) else g_Items_Pick(i);
1902 function TPlayer
.CollideLevel(XInc
, YInc
: Integer): Boolean;
1904 Result
:= g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
,
1905 PLAYER_RECT
.Width
, PLAYER_RECT
.Height
, PANEL_WALL
,
1909 constructor TPlayer
.Create();
1915 FSawSound
:= TPlayableSound
.Create();
1916 FSawSoundIdle
:= TPlayableSound
.Create();
1917 FSawSoundHit
:= TPlayableSound
.Create();
1918 FSawSoundSelect
:= TPlayableSound
.Create();
1919 FJetSoundFly
:= TPlayableSound
.Create();
1920 FJetSoundOn
:= TPlayableSound
.Create();
1921 FJetSoundOff
:= TPlayableSound
.Create();
1923 FSawSound
.SetByName('SOUND_WEAPON_FIRESAW');
1924 FSawSoundIdle
.SetByName('SOUND_WEAPON_IDLESAW');
1925 FSawSoundHit
.SetByName('SOUND_WEAPON_HITSAW');
1926 FSawSoundSelect
.SetByName('SOUND_WEAPON_SELECTSAW');
1927 FJetSoundFly
.SetByName('SOUND_PLAYER_JETFLY');
1928 FJetSoundOn
.SetByName('SOUND_PLAYER_JETON');
1929 FJetSoundOff
.SetByName('SOUND_PLAYER_JETOFF');
1931 FSpectatePlayer
:= -1;
1935 FSavedState
.WaitRecall
:= False;
1938 FActualModelName
:= 'doomer';
1941 FObj
.Rect
:= PLAYER_RECT
;
1943 FBFGFireCounter
:= -1;
1944 FJustTeleported
:= False;
1948 procedure TPlayer
.Damage(value
: Word; SpawnerUID
: Word; vx
, vy
: Integer; t
: Byte);
1952 if (not g_Game_IsClient
) and (not FLive
) then
1957 // Íåóÿçâèìîñòü íå ñïàñàåò îò ëîâóøåê:
1958 if ((t
= HIT_TRAP
) or (t
= HIT_SELF
)) and (not FGodMode
) then
1960 if not g_Game_IsClient
then
1963 if t
= HIT_TRAP
then
1965 // Ëîâóøêà óáèâàåò ñðàçó:
1967 Kill(K_EXTRAHARDKILL
, SpawnerUID
, t
);
1969 if t
= HIT_SELF
then
1973 Kill(K_SIMPLEKILL
, SpawnerUID
, t
);
1976 // Îáíóëèòü äåéñòâèÿ ïðèìî÷åê, ÷òîáû ôîí ïðîïàë
1977 FMegaRulez
[MR_SUIT
] := 0;
1978 FMegaRulez
[MR_INVUL
] := 0;
1979 FMegaRulez
[MR_INVIS
] := 0;
1983 // Íî îò îñòàëüíîãî ñïàñàåò:
1984 if FMegaRulez
[MR_INVUL
] >= gTime
then
1991 // Åñëè åñòü óðîí ñâîèì, èëè ðàíèë ñàì ñåáÿ, èëè òåáÿ ðàíèë ïðîòèâíèê:
1992 if LongBool(gGameSettings
.Options
and GAME_OPTION_TEAMDAMAGE
) or
1993 (SpawnerUID
= FUID
) or
1994 (not SameTeam(FUID
, SpawnerUID
)) then
1996 FLastSpawnerUID
:= SpawnerUID
;
1998 // Êðîâü (ïóçûðüêè, åñëè â âîäå):
1999 if gBloodCount
> 0 then
2001 c
:= Min(value
, 200)*gBloodCount
+ Random(Min(value
, 200) div 2);
2002 if value
div 4 <= c
then
2003 c
:= c
- (value
div 4)
2007 if (t
= HIT_SOME
) and (vx
= 0) and (vy
= 0) then
2011 HIT_TRAP
, HIT_ACID
, HIT_FLAME
, HIT_SELF
: MakeBloodSimple(c
);
2012 HIT_BFG
, HIT_ROCKET
, HIT_SOME
: MakeBloodVector(c
, vx
, vy
);
2015 if t
= HIT_WATER
then
2016 g_GFX_Bubbles(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2),
2017 FObj
.Y
+PLAYER_RECT
.Y
-4, value
div 2, 8, 4);
2022 Inc(FDamageBuffer
, value
);
2026 FPain
:= FPain
+ value
;
2029 if g_Game_IsServer
and g_Game_IsNet
then
2031 MH_SEND_PlayerDamage(FUID
, t
, SpawnerUID
, value
, vx
, vy
);
2032 MH_SEND_PlayerStats(FUID
);
2033 MH_SEND_PlayerPos(False, FUID
);
2037 function TPlayer
.Heal(value
: Word; Soft
: Boolean): Boolean;
2040 if g_Game_IsClient
then
2045 if Soft
and (FHealth
< PLAYER_HP_SOFT
) then
2047 IncMax(FHealth
, value
, PLAYER_HP_SOFT
);
2050 if (not Soft
) and (FHealth
< PLAYER_HP_LIMIT
) then
2052 IncMax(FHealth
, value
, PLAYER_HP_LIMIT
);
2056 if Result
and g_Game_IsServer
and g_Game_IsNet
then
2057 MH_SEND_PlayerStats(FUID
);
2060 destructor TPlayer
.Destroy();
2062 if (gPlayer1
<> nil) and (gPlayer1
.FUID
= FUID
) then
2064 if (gPlayer2
<> nil) and (gPlayer2
.FUID
= FUID
) then
2068 FSawSoundIdle
.Free();
2069 FSawSoundHit
.Free();
2070 FJetSoundFly
.Free();
2072 FJetSoundOff
.Free();
2078 procedure TPlayer
.DrawBubble();
2080 bubX
, bubY
: Integer;
2083 Rw
, Gw
, Bw
: SmallInt;
2086 bubX
:= FObj
.X
+FObj
.Rect
.X
+ IfThen(FDirection
= D_LEFT
, -4, 18);
2087 bubY
:= FObj
.Y
+FObj
.Rect
.Y
- 18;
2095 1: // simple textual non-bubble
2097 bubX
:= FObj
.X
+FObj
.Rect
.X
- 11;
2098 bubY
:= FObj
.Y
+FObj
.Rect
.Y
- 17;
2099 e_TextureFontPrint(bubX
, bubY
, '[...]', gStdFont
);
2102 2: // advanced pixel-perfect bubble
2104 if FTeam
= TEAM_RED
then
2107 if FTeam
= TEAM_BLUE
then
2110 3: // colored bubble
2112 Rb
:= FModel
.Color
.R
;
2113 Gb
:= FModel
.Color
.G
;
2114 Bb
:= FModel
.Color
.B
;
2115 Rw
:= Min(Rb
* 2 + 64, 255);
2116 Gw
:= Min(Gb
* 2 + 64, 255);
2117 Bw
:= Min(Bb
* 2 + 64, 255);
2118 if (Abs(Rw
- Rb
) < 32)
2119 or (Abs(Gw
- Gb
) < 32)
2120 or (Abs(Bw
- Bb
) < 32) then
2122 Rb
:= Max(Rw
div 2 - 16, 0);
2123 Gb
:= Max(Gw
div 2 - 16, 0);
2124 Bb
:= Max(Bw
div 2 - 16, 0);
2127 4: // custom textured bubble
2129 if g_Texture_Get('TEXTURE_PLAYER_TALKBUBBLE', ID
) then
2130 if FDirection
= D_RIGHT
then
2131 e_Draw(ID
, bubX
- 6, bubY
- 7, 0, True, False)
2133 e_Draw(ID
, bubX
- 6, bubY
- 7, 0, True, False, M_HORIZONTAL
);
2139 e_DrawQuad(bubX
+ 1, bubY
, bubX
+ 18, bubY
+ 13, Rb
, Gb
, Bb
);
2140 e_DrawQuad(bubX
, bubY
+ 1, bubX
+ 19, bubY
+ 12, Rb
, Gb
, Bb
);
2142 e_DrawFillQuad(bubX
+ 1, bubY
+ 1, bubX
+ 18, bubY
+ 12, Rw
, Gw
, Bw
, 0);
2145 Dot
:= IfThen(FDirection
= D_LEFT
, 14, 5);
2146 e_DrawLine(1, bubX
+ Dot
, bubY
+ 14, bubX
+ Dot
, bubY
+ 16, Rb
, Gb
, Bb
);
2147 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
);
2148 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
);
2149 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
);
2150 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
);
2154 e_DrawFillQuad(bubX
+ Dot
, bubY
+ 8, bubX
+ Dot
+ 1, bubY
+ 9, Rb
, Gb
, Bb
, 0);
2155 e_DrawFillQuad(bubX
+ Dot
+ 3, bubY
+ 8, bubX
+ Dot
+ 4, bubY
+ 9, Rb
, Gb
, Bb
, 0);
2156 e_DrawFillQuad(bubX
+ Dot
+ 6, bubY
+ 8, bubX
+ Dot
+ 7, bubY
+ 9, Rb
, Gb
, Bb
, 0);
2159 procedure TPlayer
.Draw();
2166 if (FMegaRulez
[MR_INVUL
] > gTime
) and (gPlayerDrawn
<> Self
) then
2167 if g_Texture_Get('TEXTURE_PLAYER_INVULPENTA', ID
) then
2169 e_GetTextureSize(ID
, @w
, @h
);
2170 if FDirection
= D_LEFT
then
2171 e_Draw(ID
, FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2)-(w
div 2)+4,
2172 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2)-(h
div 2)-7, 0, True, False)
2174 e_Draw(ID
, FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2)-(w
div 2)-2,
2175 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2)-(h
div 2)-7, 0, True, False);
2178 if FMegaRulez
[MR_INVIS
] > gTime
then
2180 if (gPlayerDrawn
<> nil) and ((Self
= gPlayerDrawn
) or
2181 ((FTeam
= gPlayerDrawn
.Team
) and (gGameSettings
.GameMode
<> GM_DM
))) then
2182 FModel
.Draw(FObj
.X
, FObj
.Y
, 200)
2184 FModel
.Draw(FObj
.X
, FObj
.Y
, 254);
2187 FModel
.Draw(FObj
.X
, FObj
.Y
);
2190 if g_debug_Frames
then
2192 e_DrawQuad(FObj
.X
+FObj
.Rect
.X
,
2194 FObj
.X
+FObj
.Rect
.X
+FObj
.Rect
.Width
-1,
2195 FObj
.Y
+FObj
.Rect
.Y
+FObj
.Rect
.Height
-1,
2199 if (gChatBubble
> 0) and (FKeys
[KEY_CHAT
].Pressed
) and not FGhost
then
2201 // e_DrawPoint(5, 335, 288, 255, 0, 0); // DL, UR, DL, UR
2202 if gAimLine
and Live
and
2203 ((Self
= gPlayer1
) or (Self
= gPlayer2
)) then
2207 procedure TPlayer
.DrawAim();
2209 wx
, wy
, xx
, yy
: Integer;
2213 wx
:= FObj
.X
+ WEAPONPOINT
[FDirection
].X
+ IfThen(FDirection
= D_LEFT
, 7, -7);
2214 wy
:= FObj
.Y
+ WEAPONPOINT
[FDirection
].Y
;
2223 1: begin // Chainsaw
2230 if angle
= ANGLE_RIGHTUP
then Dec(angle
, 2);
2231 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 4);
2232 if angle
= ANGLE_LEFTUP
then Inc(angle
, 2);
2233 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 4);
2238 if angle
= ANGLE_RIGHTUP
then Dec(angle
, 2);
2239 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 4);
2240 if angle
= ANGLE_LEFTUP
then Inc(angle
, 2);
2241 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 4);
2243 4: begin // Double Shotgun
2246 if angle
= ANGLE_RIGHTUP
then Dec(angle
, 2);
2247 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 4);
2248 if angle
= ANGLE_LEFTUP
then Inc(angle
, 2);
2249 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 4);
2251 5: begin // Chaingun
2254 if angle
= ANGLE_RIGHTUP
then Dec(angle
, 2);
2255 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 4);
2256 if angle
= ANGLE_LEFTUP
then Inc(angle
, 2);
2257 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 4);
2259 6: begin // Rocket Launcher
2262 if angle
= ANGLE_RIGHTUP
then Inc(angle
, 2);
2263 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 4);
2264 if angle
= ANGLE_LEFTUP
then Dec(angle
, 2);
2265 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 4);
2267 7: begin // Plasmagun
2270 if angle
= ANGLE_RIGHTUP
then Inc(angle
);
2271 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 3);
2272 if angle
= ANGLE_LEFTUP
then Dec(angle
);
2273 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 3);
2278 if angle
= ANGLE_RIGHTUP
then Inc(angle
, 1);
2279 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 2);
2280 if angle
= ANGLE_LEFTUP
then Dec(angle
, 1);
2281 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 2);
2283 9: begin // Super Chaingun
2286 if angle
= ANGLE_RIGHTUP
then Dec(angle
, 2);
2287 if angle
= ANGLE_RIGHTDOWN
then Inc(angle
, 4);
2288 if angle
= ANGLE_LEFTUP
then Inc(angle
, 2);
2289 if angle
= ANGLE_LEFTDOWN
then Dec(angle
, 4);
2292 xx
:= Trunc(Cos(-DegToRad(angle
)) * len
) + wx
;
2293 yy
:= Trunc(Sin(-DegToRad(angle
)) * len
) + wy
;
2294 e_DrawLine(sz
, wx
, wy
, xx
, yy
, 255, 0, 0, 96);
2297 procedure TPlayer
.DrawGUI();
2300 X
, Y
, SY
, a
, p
, m
: Integer;
2304 stat
: TPlayerStatArray
;
2306 X
:= gPlayerScreenSize
.X
;
2307 SY
:= gPlayerScreenSize
.Y
;
2310 if gShowGoals
and (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then
2312 if gGameSettings
.GameMode
= GM_CTF
then
2316 if gGameSettings
.GameMode
= GM_CTF
then
2318 s
:= 'TEXTURE_PLAYER_REDFLAG';
2319 if gFlags
[FLAG_RED
].State
= FLAG_STATE_CAPTURED
then
2320 s
:= 'TEXTURE_PLAYER_REDFLAG_S';
2321 if gFlags
[FLAG_RED
].State
= FLAG_STATE_DROPPED
then
2322 s
:= 'TEXTURE_PLAYER_REDFLAG_D';
2323 if g_Texture_Get(s
, ID
) then
2324 e_Draw(ID
, X
-16-32, 240-72-4, 0, True, False);
2327 s
:= IntToStr(gTeamStat
[TEAM_RED
].Goals
);
2328 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2329 e_CharFont_PrintEx(gMenuFont
, X
-16-a
-tw
, 240-72-4, s
, TEAMCOLOR
[TEAM_RED
]);
2331 if gGameSettings
.GameMode
= GM_CTF
then
2333 s
:= 'TEXTURE_PLAYER_BLUEFLAG';
2334 if gFlags
[FLAG_BLUE
].State
= FLAG_STATE_CAPTURED
then
2335 s
:= 'TEXTURE_PLAYER_BLUEFLAG_S';
2336 if gFlags
[FLAG_BLUE
].State
= FLAG_STATE_DROPPED
then
2337 s
:= 'TEXTURE_PLAYER_BLUEFLAG_D';
2338 if g_Texture_Get(s
, ID
) then
2339 e_Draw(ID
, X
-16-32, 240-32-4, 0, True, False);
2342 s
:= IntToStr(gTeamStat
[TEAM_BLUE
].Goals
);
2343 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2344 e_CharFont_PrintEx(gMenuFont
, X
-16-a
-tw
, 240-32-4, s
, TEAMCOLOR
[TEAM_BLUE
]);
2347 if g_Texture_Get('TEXTURE_PLAYER_HUDBG', ID
) then
2348 e_DrawFill(ID
, X
, 0, 1, (gPlayerScreenSize
.Y
div 256)+IfThen(gPlayerScreenSize
.Y
mod 256 > 0, 1, 0),
2351 if g_Texture_Get('TEXTURE_PLAYER_HUD', ID
) then
2352 e_Draw(ID
, X
+2, Y
, 0, True, False);
2354 if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
2358 s
:= IntToStr(Frags
);
2359 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2360 e_CharFont_PrintEx(gMenuFont
, X
-16-tw
, Y
, s
, _RGB(255, 0, 0));
2365 stat
:= g_Player_GetStats();
2370 for a
:= 0 to High(stat
) do
2371 if stat
[a
].Name
<> Name
then
2373 if stat
[a
].Frags
> m
then m
:= stat
[a
].Frags
;
2374 if stat
[a
].Frags
> Frags
then p
:= p
+1;
2378 s
:= IntToStr(p
)+' / '+IntToStr(Length(stat
))+' ';
2379 if Frags
>= m
then s
:= s
+'+' else s
:= s
+'-';
2380 s
:= s
+IntToStr(Abs(Frags
-m
));
2382 e_CharFont_GetSize(gMenuSmallFont
, s
, tw
, th
);
2383 e_CharFont_PrintEx(gMenuSmallFont
, X
-16-tw
, Y
+32, s
, _RGB(255, 0, 0));
2386 if gShowLives
and (gGameSettings
.MaxLives
> 0) then
2388 s
:= IntToStr(Lives
);
2389 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2390 e_CharFont_PrintEx(gMenuFont
, X
-16-tw
, SY
-32, s
, _RGB(0, 255, 0));
2394 e_CharFont_GetSize(gMenuSmallFont
, FName
, tw
, th
);
2395 e_CharFont_PrintEx(gMenuSmallFont
, X
+98-(tw
div 2), Y
+8, FName
, _RGB(255, 0, 0));
2397 if R_BERSERK
in FRulez
then
2398 e_Draw(gItemsTexturesID
[ITEM_MEDKIT_BLACK
], X
+37, Y
+45, 0, True, False)
2400 e_Draw(gItemsTexturesID
[ITEM_MEDKIT_LARGE
], X
+37, Y
+45, 0, True, False);
2402 if g_Texture_Get('TEXTURE_PLAYER_ARMORHUD', ID
) then
2403 e_Draw(ID
, X
+36, Y
+77, 0, True, False);
2405 s
:= IntToStr(IfThen(FHealth
> 0, FHealth
, 0));
2406 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2407 e_CharFont_PrintEx(gMenuFont
, X
+178-tw
, Y
+40, s
, _RGB(255, 0, 0));
2409 s
:= IntToStr(FArmor
);
2410 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2411 e_CharFont_PrintEx(gMenuFont
, X
+178-tw
, Y
+68, s
, _RGB(255, 0, 0));
2413 s
:= IntToStr(GetAmmoByWeapon(FCurrWeap
));
2419 ID
:= gItemsTexturesID
[ITEM_WEAPON_KASTET
];
2424 ID
:= gItemsTexturesID
[ITEM_WEAPON_SAW
];
2426 WEAPON_PISTOL
: ID
:= gItemsTexturesID
[ITEM_WEAPON_PISTOL
];
2427 WEAPON_CHAINGUN
: ID
:= gItemsTexturesID
[ITEM_WEAPON_CHAINGUN
];
2428 WEAPON_SHOTGUN1
: ID
:= gItemsTexturesID
[ITEM_WEAPON_SHOTGUN1
];
2429 WEAPON_SHOTGUN2
: ID
:= gItemsTexturesID
[ITEM_WEAPON_SHOTGUN2
];
2430 WEAPON_SUPERPULEMET
: ID
:= gItemsTexturesID
[ITEM_WEAPON_SUPERPULEMET
];
2431 WEAPON_ROCKETLAUNCHER
: ID
:= gItemsTexturesID
[ITEM_WEAPON_ROCKETLAUNCHER
];
2432 WEAPON_PLASMA
: ID
:= gItemsTexturesID
[ITEM_WEAPON_PLASMA
];
2433 WEAPON_BFG
: ID
:= gItemsTexturesID
[ITEM_WEAPON_BFG
];
2436 e_CharFont_GetSize(gMenuFont
, s
, tw
, th
);
2437 e_CharFont_PrintEx(gMenuFont
, X
+178-tw
, Y
+158, s
, _RGB(255, 0, 0));
2438 e_Draw(ID
, X
+20, Y
+160, 0, True, False);
2440 if R_KEY_RED
in FRulez
then
2441 e_Draw(gItemsTexturesID
[ITEM_KEY_RED
], X
+78, Y
+214, 0, True, False);
2443 if R_KEY_GREEN
in FRulez
then
2444 e_Draw(gItemsTexturesID
[ITEM_KEY_GREEN
], X
+95, Y
+214, 0, True, False);
2446 if R_KEY_BLUE
in FRulez
then
2447 e_Draw(gItemsTexturesID
[ITEM_KEY_BLUE
], X
+112, Y
+214, 0, True, False);
2449 if FJetFuel
> 0 then
2451 if g_Texture_Get('TEXTURE_PLAYER_HUDAIR', ID
) then
2452 e_Draw(ID
, X
+2, Y
+116, 0, True, False);
2453 if g_Texture_Get('TEXTURE_PLAYER_HUDJET', ID
) then
2454 e_Draw(ID
, X
+2, Y
+126, 0, True, False);
2455 e_DrawLine(4, X
+16, Y
+122, X
+16+Trunc(168*IfThen(FAir
> 0, FAir
, 0)/AIR_MAX
), Y
+122, 0, 0, 196);
2456 e_DrawLine(4, X
+16, Y
+132, X
+16+Trunc(168*FJetFuel
/JET_MAX
), Y
+132, 208, 0, 0);
2460 if g_Texture_Get('TEXTURE_PLAYER_HUDAIR', ID
) then
2461 e_Draw(ID
, X
+2, Y
+124, 0, True, False);
2462 e_DrawLine(4, X
+16, Y
+130, X
+16+Trunc(168*IfThen(FAir
> 0, FAir
, 0)/AIR_MAX
), Y
+130, 0, 0, 196);
2465 if gShowPing
and g_Game_IsClient
then
2467 s
:= _lc
[I_GAME_PING_HUD
] + IntToStr(NetPeer
.lastRoundTripTime
) + _lc
[I_NET_SLIST_PING_MS
];
2468 e_TextureFontPrint(X
+ 4, Y
+ 242, s
, gStdFont
);
2474 e_TextureFontPrint(X
+ 4, Y
+ 242, _lc
[I_PLAYER_SPECT
], gStdFont
);
2475 e_TextureFontPrint(X
+ 4, Y
+ 258, _lc
[I_PLAYER_SPECT2
], gStdFont
);
2476 e_TextureFontPrint(X
+ 4, Y
+ 274, _lc
[I_PLAYER_SPECT1
], gStdFont
);
2479 e_TextureFontGetSize(gStdFont
, cw
, ch
);
2480 s
:= _lc
[I_PLAYER_SPECT4
];
2481 e_TextureFontPrintEx(gScreenWidth
div 2 - cw
*(Length(s
) div 2),
2482 gScreenHeight
-4-ch
, s
, gStdFont
, 255, 255, 255, 1, True);
2483 e_TextureFontPrint(X
+ 4, Y
+ 290, _lc
[I_PLAYER_SPECT1S
], gStdFont
);
2489 procedure TPlayer
.DrawRulez();
2493 // Ïðè âçÿòèè íåóÿçâèìîñòè ðèñóåòñÿ èíâåðñèîííûé áåëûé ôîí
2494 if FMegaRulez
[MR_INVUL
] >= gTime
then
2496 if (FMegaRulez
[MR_INVUL
]-gTime
) <= 2100 then
2497 dr
:= not Odd((FMegaRulez
[MR_INVUL
]-gTime
) div 300)
2502 e_DrawFillQuad(0, 0, gPlayerScreenSize
.X
-1, gPlayerScreenSize
.Y
-1,
2503 191, 191, 191, 0, B_INVERT
);
2506 // Ïðè âçÿòèè çàùèòíîãî êîñòþìà ðèñóåòñÿ çåëåíîâàòûé ôîí
2507 if FMegaRulez
[MR_SUIT
] >= gTime
then
2509 if (FMegaRulez
[MR_SUIT
]-gTime
) <= 2100 then
2510 dr
:= not Odd((FMegaRulez
[MR_SUIT
]-gTime
) div 300)
2515 e_DrawFillQuad(0, 0, gPlayerScreenSize
.X
-1, gPlayerScreenSize
.Y
-1,
2516 0, 96, 0, 200, B_NONE
);
2519 // Ïðè âçÿòèè áåðñåðêà ðèñóåòñÿ êðàñíîâàòûé ôîí
2520 if (FBerserk
>= 0) and (LongWord(FBerserk
) >= gTime
) and (gFlash
= 2) then
2522 e_DrawFillQuad(0, 0, gPlayerScreenSize
.X
-1, gPlayerScreenSize
.Y
-1,
2523 255, 0, 0, 200, B_NONE
);
2527 procedure TPlayer
.DrawPain();
2531 if FPain
= 0 then Exit
;
2535 if a
< 15 then h
:= 0
2536 else if a
< 35 then h
:= 1
2537 else if a
< 55 then h
:= 2
2538 else if a
< 75 then h
:= 3
2539 else if a
< 95 then h
:= 4
2542 //if a > 255 then a := 255;
2544 e_DrawFillQuad(0, 0, gPlayerScreenSize
.X
-1, gPlayerScreenSize
.Y
-1, 255, 0, 0, 255-h
*50);
2545 //e_DrawFillQuad(0, 0, gPlayerScreenSize.X-1, gPlayerScreenSize.Y-1, 255-min(128, a), 255-a, 255-a, 0, B_FILTER);
2548 procedure TPlayer
.DrawPickup();
2552 if FPickup
= 0 then Exit
;
2556 if a
< 15 then h
:= 1
2557 else if a
< 35 then h
:= 2
2558 else if a
< 55 then h
:= 3
2559 else if a
< 75 then h
:= 4
2562 e_DrawFillQuad(0, 0, gPlayerScreenSize
.X
-1, gPlayerScreenSize
.Y
-1, 150, 200, 150, 255-h
*50);
2565 procedure TPlayer
.Fire();
2567 f
, DidFire
: Boolean;
2568 wx
, wy
, xd
, yd
: Integer;
2571 if g_Game_IsClient
then Exit
;
2572 // FBFGFireCounter - âðåìÿ ïåðåä âûñòðåëîì (äëÿ BFG)
2573 // FReloading - âðåìÿ ïîñëå âûñòðåëà (äëÿ âñåãî)
2581 if FReloading
[FCurrWeap
] <> 0 then Exit
;
2586 wx
:= FObj
.X
+WEAPONPOINT
[FDirection
].X
;
2587 wy
:= FObj
.Y
+WEAPONPOINT
[FDirection
].Y
;
2588 xd
:= wx
+IfThen(FDirection
= D_LEFT
, -30, 30);
2589 yd
:= wy
+firediry();
2594 if R_BERSERK
in FRulez
then
2596 //g_Weapon_punch(FObj.X+FObj.Rect.X, FObj.Y+FObj.Rect.Y, 75, FUID);
2597 obj
.X
:= FObj
.X
+FObj
.Rect
.X
;
2598 obj
.Y
:= FObj
.Y
+FObj
.Rect
.Y
;
2601 obj
.rect
.Width
:= 39;
2602 obj
.rect
.Height
:= 52;
2603 obj
.Vel
.X
:= (xd
-wx
) div 2;
2604 obj
.Vel
.Y
:= (yd
-wy
) div 2;
2605 obj
.Accel
.X
:= xd
-wx
;
2606 obj
.Accel
.y
:= yd
-wy
;
2608 if g_Weapon_Hit(@obj
, 50, FUID
, HIT_SOME
) <> 0 then
2609 g_Sound_PlayExAt('SOUND_WEAPON_HITBERSERK', FObj
.X
, FObj
.Y
)
2611 g_Sound_PlayExAt('SOUND_WEAPON_MISSBERSERK', FObj
.X
, FObj
.Y
);
2615 FPain
:= min(FPain
+ 25, 50);
2616 end else g_Weapon_punch(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
, 3, FUID
);
2619 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
2624 if g_Weapon_chainsaw(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
,
2625 IfThen(gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
], 9, 3), FUID
) <> 0 then
2627 FSawSoundSelect
.Stop();
2629 FSawSoundHit
.PlayAt(FObj
.X
, FObj
.Y
);
2631 else if not FSawSoundHit
.IsPlaying() then
2633 FSawSoundSelect
.Stop();
2634 FSawSound
.PlayAt(FObj
.X
, FObj
.Y
);
2637 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
2643 if FAmmo
[A_BULLETS
] > 0 then
2645 g_Weapon_pistol(wx
, wy
, xd
, yd
, FUID
);
2646 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
2647 Dec(FAmmo
[A_BULLETS
]);
2648 FFireAngle
:= FAngle
;
2651 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
2652 GameVelX
, GameVelY
-2, SHELL_BULLET
);
2656 if FAmmo
[A_SHELLS
] > 0 then
2658 g_Weapon_shotgun(wx
, wy
, xd
, yd
, FUID
);
2659 if not gSoundEffectsDF
then g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN', wx
, wy
);
2660 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
2661 Dec(FAmmo
[A_SHELLS
]);
2662 FFireAngle
:= FAngle
;
2666 FShellType
:= SHELL_SHELL
;
2670 if FAmmo
[A_SHELLS
] >= 2 then
2672 g_Weapon_dshotgun(wx
, wy
, xd
, yd
, FUID
);
2673 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
2674 Dec(FAmmo
[A_SHELLS
], 2);
2675 FFireAngle
:= FAngle
;
2679 FShellType
:= SHELL_DBLSHELL
;
2683 if FAmmo
[A_BULLETS
] > 0 then
2685 g_Weapon_mgun(wx
, wy
, xd
, yd
, FUID
);
2686 if not gSoundEffectsDF
then g_Sound_PlayExAt('SOUND_WEAPON_FIREPISTOL', wx
, wy
);
2687 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
2688 Dec(FAmmo
[A_BULLETS
]);
2689 FFireAngle
:= FAngle
;
2692 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
2693 GameVelX
, GameVelY
-2, SHELL_BULLET
);
2696 WEAPON_ROCKETLAUNCHER
:
2697 if FAmmo
[A_ROCKETS
] > 0 then
2699 g_Weapon_rocket(wx
, wy
, xd
, yd
, FUID
);
2700 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
2701 Dec(FAmmo
[A_ROCKETS
]);
2702 FFireAngle
:= FAngle
;
2708 if FAmmo
[A_CELLS
] > 0 then
2710 g_Weapon_plasma(wx
, wy
, xd
, yd
, FUID
);
2711 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
2712 Dec(FAmmo
[A_CELLS
]);
2713 FFireAngle
:= FAngle
;
2719 if (FAmmo
[A_CELLS
] >= 40) and (FBFGFireCounter
= -1) then
2721 FBFGFireCounter
:= 17;
2722 if not FNoReload
then
2723 g_Sound_PlayExAt('SOUND_WEAPON_STARTFIREBFG', FObj
.X
, FObj
.Y
);
2724 Dec(FAmmo
[A_CELLS
], 40);
2728 WEAPON_SUPERPULEMET
:
2729 if FAmmo
[A_SHELLS
] > 0 then
2731 g_Weapon_shotgun(wx
, wy
, xd
, yd
, FUID
);
2732 if not gSoundEffectsDF
then g_Sound_PlayExAt('SOUND_WEAPON_FIRECGUN', wx
, wy
);
2733 FReloading
[FCurrWeap
] := WEAPON_RELOAD
[FCurrWeap
];
2734 Dec(FAmmo
[A_SHELLS
]);
2735 FFireAngle
:= FAngle
;
2738 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
2739 GameVelX
, GameVelY
-2, SHELL_SHELL
);
2743 if g_Game_IsNet
then
2747 if FCurrWeap
<> WEAPON_BFG
then
2748 MH_SEND_PlayerFire(FUID
, FCurrWeap
, wx
, wy
, xd
, yd
, LastShotID
)
2750 if not FNoReload
then
2751 MH_SEND_Sound(FObj
.X
, FObj
.Y
, 'SOUND_WEAPON_STARTFIREBFG');
2754 MH_SEND_PlayerStats(FUID
);
2759 if (FAngle
= 0) or (FAngle
= 180) then SetAction(A_ATTACK
)
2760 else if (FAngle
= ANGLE_LEFTDOWN
) or (FAngle
= ANGLE_RIGHTDOWN
) then SetAction(A_ATTACKDOWN
)
2761 else if (FAngle
= ANGLE_LEFTUP
) or (FAngle
= ANGLE_RIGHTUP
) then SetAction(A_ATTACKUP
);
2764 function TPlayer
.GetAmmoByWeapon(Weapon
: Byte): Word;
2767 WEAPON_PISTOL
, WEAPON_CHAINGUN
: Result
:= FAmmo
[A_BULLETS
];
2768 WEAPON_SHOTGUN1
, WEAPON_SHOTGUN2
, WEAPON_SUPERPULEMET
: Result
:= FAmmo
[A_SHELLS
];
2769 WEAPON_ROCKETLAUNCHER
: Result
:= FAmmo
[A_ROCKETS
];
2770 WEAPON_PLASMA
, WEAPON_BFG
: Result
:= FAmmo
[A_CELLS
];
2775 function TPlayer
.HeadInLiquid(XInc
, YInc
: Integer): Boolean;
2777 Result
:= g_Map_CollidePanel(FObj
.X
+PLAYER_HEADRECT
.X
+XInc
, FObj
.Y
+PLAYER_HEADRECT
.Y
+YInc
,
2778 PLAYER_HEADRECT
.Width
, PLAYER_HEADRECT
.Height
,
2779 PANEL_WATER
or PANEL_ACID1
or PANEL_ACID2
, True);
2782 procedure TPlayer
.JetpackOn
;
2786 FJetSoundOn
.SetPosition(0);
2787 FJetSoundOn
.PlayAt(FObj
.X
, FObj
.Y
);
2791 procedure TPlayer
.JetpackOff
;
2795 FJetSoundOff
.SetPosition(0);
2796 FJetSoundOff
.PlayAt(FObj
.X
, FObj
.Y
);
2799 procedure TPlayer
.Jump();
2801 if gFly
or FJetpack
then
2803 // Ïîëåò (÷èò-êîä èëè äæåòïàê):
2804 if FObj
.Vel
.Y
> -VEL_FLY
then
2805 FObj
.Vel
.Y
:= FObj
.Vel
.Y
- 3;
2808 if FJetFuel
> 0 then
2810 if (FJetFuel
< 1) and g_Game_IsServer
then
2814 if g_Game_IsNet
then
2815 MH_SEND_PlayerStats(FUID
);
2821 // Íå âêëþ÷àòü äæåòïàê â ðåæèìå ïðîõîæäåíèÿ ñêâîçü ñòåíû
2823 FCanJetpack
:= False;
2825 // Ïðûãàåì èëè âñïëûâàåì:
2826 if (CollideLevel(0, 1) or
2827 g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+PLAYER_RECT
.Y
+36, PLAYER_RECT
.Width
,
2828 PLAYER_RECT
.Height
-33, PANEL_STEP
, False)
2829 ) and (FObj
.Accel
.Y
= 0) then // Íå ïðûãàòü, åñëè åñòü âåðòèêàëüíîå óñêîðåíèå
2831 FObj
.Vel
.Y
:= -VEL_JUMP
;
2832 FCanJetpack
:= False;
2836 if BodyInLiquid(0, 0) then
2837 FObj
.Vel
.Y
:= -VEL_SW
2838 else if (FJetFuel
> 0) and FCanJetpack
and
2839 g_Game_IsServer
and (not g_Obj_CollideLiquid(@FObj
, 0, 0)) then
2843 if g_Game_IsNet
then
2844 MH_SEND_PlayerStats(FUID
);
2849 procedure TPlayer
.Kill(KillType
: Byte; SpawnerUID
: Word; t
: Byte);
2851 a
, i
, k
, ab
, ar
: Byte;
2855 srv
, netsrv
: Boolean;
2860 procedure PushItem(t
: Byte);
2864 id
:= g_Items_Create(FObj
.X
, FObj
.Y
, t
, True, False);
2865 if KillType
= K_EXTRAHARDKILL
then // -7..+7; -8..0
2866 g_Obj_Push(@gItems
[id
].Obj
, (FObj
.Vel
.X
div 2)-7+Random(15),
2867 (FObj
.Vel
.Y
div 2)-Random(9))
2869 if KillType
= K_HARDKILL
then // -5..+5; -5..0
2870 g_Obj_Push(@gItems
[id
].Obj
, (FObj
.Vel
.X
div 2)-5+Random(11),
2871 (FObj
.Vel
.Y
div 2)-Random(6))
2872 else // -3..+3; -3..0
2873 g_Obj_Push(@gItems
[id
].Obj
, (FObj
.Vel
.X
div 2)-3+Random(7),
2874 (FObj
.Vel
.Y
div 2)-Random(4));
2876 if g_Game_IsNet
and g_Game_IsServer
then
2877 MH_SEND_ItemSpawn(True, id
);
2881 DoFrags
:= (gGameSettings
.MaxLives
= 0) or (gGameSettings
.GameMode
= GM_COOP
);
2882 Srv
:= g_Game_IsServer
;
2883 Netsrv
:= g_Game_IsServer
and g_Game_IsNet
;
2884 if Srv
then FDeath
:= FDeath
+ 1;
2889 if not FPhysics
then
2895 if (gGameSettings
.MaxLives
> 0) and Srv
and (gLMSRespawn
= LMS_RESPAWN_NONE
) then
2897 if FLives
> 0 then FLives
:= FLives
- 1;
2898 if FLives
= 0 then FNoRespawn
:= True;
2901 // Íîìåð òèïà ñìåðòè:
2904 K_SIMPLEKILL
: a
:= 1;
2906 K_EXTRAHARDKILL
: a
:= 3;
2911 if not FModel
.PlaySound(MODELSOUND_DIE
, a
, FObj
.X
, FObj
.Y
) then
2913 if FModel
.PlaySound(MODELSOUND_DIE
, i
, FObj
.X
, FObj
.Y
) then
2920 FTime
[T_RESPAWN
] := gTime
+ TIME_RESPAWN1
;
2922 FTime
[T_RESPAWN
] := gTime
+ TIME_RESPAWN2
;
2923 K_EXTRAHARDKILL
, K_FALLKILL
:
2924 FTime
[T_RESPAWN
] := gTime
+ TIME_RESPAWN3
;
2927 // Ïåðåêëþ÷àåì ñîñòîÿíèå:
2931 K_HARDKILL
, K_EXTRAHARDKILL
:
2935 // Ðåàêöèÿ ìîíñòðîâ íà ñìåðòü èãðîêà:
2936 if (KillType
<> K_FALLKILL
) and (Srv
) then
2937 g_Monsters_killedp();
2939 if SpawnerUID
= FUID
then
2941 if Srv
and (DoFrags
or (gGameSettings
.GameMode
= GM_TDM
)) then
2946 g_Console_Add(Format(_lc
[I_PLAYER_KILL_SELF
], [FName
]), True);
2949 if g_GetUIDType(SpawnerUID
) = UID_PLAYER
then
2950 begin // Óáèò äðóãèì èãðîêîì
2951 KP
:= g_Player_Get(SpawnerUID
);
2952 if (KP
<> nil) and Srv
then
2954 if (DoFrags
or (gGameSettings
.GameMode
= GM_TDM
)) then
2955 if SameTeam(FUID
, SpawnerUID
) then
2965 if (gGameSettings
.GameMode
= GM_TDM
) and DoFrags
then
2966 Inc(gTeamStat
[KP
.Team
].Goals
,
2967 IfThen(SameTeam(FUID
, SpawnerUID
), -1, 1));
2969 if netsrv
then MH_SEND_PlayerStats(SpawnerUID
);
2972 plr
:= g_Player_Get(SpawnerUID
);
2980 g_Console_Add(Format(_lc
[I_PLAYER_KILL_EXTRAHARD_2
],
2984 g_Console_Add(Format(_lc
[I_PLAYER_KILL_EXTRAHARD_1
],
2988 g_Console_Add(Format(_lc
[I_PLAYER_KILL
],
2993 else if g_GetUIDType(SpawnerUID
) = UID_MONSTER
then
2994 begin // Óáèò ìîíñòðîì
2995 mon
:= g_Monsters_Get(SpawnerUID
);
2999 s
:= g_Monsters_GetKilledBy(mon
.MonsterType
);
3003 g_Console_Add(Format(_lc
[I_PLAYER_KILL_EXTRAHARD_2
],
3007 g_Console_Add(Format(_lc
[I_PLAYER_KILL_EXTRAHARD_1
],
3011 g_Console_Add(Format(_lc
[I_PLAYER_KILL
],
3016 else // Îñîáûå òèïû ñìåðòè
3019 HIT_SELF
: g_Console_Add(Format(_lc
[I_PLAYER_KILL_SELF
], [FName
]), True);
3020 HIT_FALL
: g_Console_Add(Format(_lc
[I_PLAYER_KILL_FALL
], [FName
]), True);
3021 HIT_WATER
: g_Console_Add(Format(_lc
[I_PLAYER_KILL_WATER
], [FName
]), True);
3022 HIT_ACID
: g_Console_Add(Format(_lc
[I_PLAYER_KILL_ACID
], [FName
]), True);
3023 HIT_TRAP
: g_Console_Add(Format(_lc
[I_PLAYER_KILL_TRAP
], [FName
]), True);
3024 else g_Console_Add(Format(_lc
[I_PLAYER_DIED
], [FName
]), True);
3030 for a
:= WEAPON_KASTET
to WEAPON_SUPERPULEMET
do
3034 WEAPON_SAW
: i
:= ITEM_WEAPON_SAW
;
3035 WEAPON_SHOTGUN1
: i
:= ITEM_WEAPON_SHOTGUN1
;
3036 WEAPON_SHOTGUN2
: i
:= ITEM_WEAPON_SHOTGUN2
;
3037 WEAPON_CHAINGUN
: i
:= ITEM_WEAPON_CHAINGUN
;
3038 WEAPON_ROCKETLAUNCHER
: i
:= ITEM_WEAPON_ROCKETLAUNCHER
;
3039 WEAPON_PLASMA
: i
:= ITEM_WEAPON_PLASMA
;
3040 WEAPON_BFG
: i
:= ITEM_WEAPON_BFG
;
3041 WEAPON_SUPERPULEMET
: i
:= ITEM_WEAPON_SUPERPULEMET
;
3050 if R_ITEM_BACKPACK
in FRulez
then
3051 PushItem(ITEM_AMMO_BACKPACK
);
3053 // Âûáðîñ ðàêåòíîãî ðàíöà:
3054 if FJetFuel
> 0 then
3055 PushItem(ITEM_JETPACK
);
3058 if not (gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
]) then
3060 if R_KEY_RED
in FRulez
then
3061 PushItem(ITEM_KEY_RED
);
3063 if R_KEY_GREEN
in FRulez
then
3064 PushItem(ITEM_KEY_GREEN
);
3066 if R_KEY_BLUE
in FRulez
then
3067 PushItem(ITEM_KEY_BLUE
);
3074 g_Player_CreateCorpse(Self
);
3076 if Srv
and (gGameSettings
.MaxLives
> 0) and FNoRespawn
and
3077 (gLMSRespawn
= LMS_RESPAWN_NONE
) then
3083 for i
:= Low(gPlayers
) to High(gPlayers
) do
3085 if gPlayers
[i
] = nil then continue
;
3086 if (not gPlayers
[i
].FNoRespawn
) and (not gPlayers
[i
].FSpectator
) then
3089 if gPlayers
[i
].FTeam
= TEAM_RED
then Inc(ar
)
3090 else if gPlayers
[i
].FTeam
= TEAM_BLUE
then Inc(ab
);
3095 OldLR
:= gLMSRespawn
;
3096 if (gGameSettings
.GameMode
= GM_COOP
) then
3100 // everyone is dead, restart the map
3101 g_Game_Message(_lc
[I_MESSAGE_LMS_LOSE
], 144);
3103 MH_SEND_GameEvent(NET_EV_LMS_LOSE
);
3104 gLMSRespawn
:= LMS_RESPAWN_FINAL
;
3105 gLMSRespawnTime
:= gTime
+ 5000;
3107 else if (a
= 1) then
3109 if (gPlayers
[k
] <> nil) and not (gPlayers
[k
] is TBot
) then
3110 if (gPlayers
[k
] = gPlayer1
) or
3111 (gPlayers
[k
] = gPlayer2
) then
3112 g_Console_Add('*** ' + _lc
[I_MESSAGE_LMS_SURVIVOR
] + ' ***', True)
3113 else if Netsrv
and (gPlayers
[k
].FClientID
>= 0) then
3114 MH_SEND_GameEvent(NET_EV_LMS_SURVIVOR
, 0, 'N', gPlayers
[k
].FClientID
);
3117 else if (gGameSettings
.GameMode
= GM_TDM
) then
3119 if (ab
= 0) and (ar
<> 0) then
3122 g_Game_Message(Format(_lc
[I_MESSAGE_TLMS_WIN
], [AnsiUpperCase(_lc
[I_GAME_TEAM_RED
])]), 144);
3124 MH_SEND_GameEvent(NET_EV_TLMS_WIN
, TEAM_RED
);
3125 Inc(gTeamStat
[TEAM_RED
].Goals
);
3126 gLMSRespawn
:= LMS_RESPAWN_FINAL
;
3127 gLMSRespawnTime
:= gTime
+ 5000;
3129 else if (ar
= 0) and (ab
<> 0) then
3132 g_Game_Message(Format(_lc
[I_MESSAGE_TLMS_WIN
], [AnsiUpperCase(_lc
[I_GAME_TEAM_BLUE
])]), 144);
3134 MH_SEND_GameEvent(NET_EV_TLMS_WIN
, TEAM_BLUE
);
3135 Inc(gTeamStat
[TEAM_BLUE
].Goals
);
3136 gLMSRespawn
:= LMS_RESPAWN_FINAL
;
3137 gLMSRespawnTime
:= gTime
+ 5000;
3139 else if (ar
= 0) and (ab
= 0) then
3142 g_Game_Message(_lc
[I_GAME_WIN_DRAW
], 144);
3144 MH_SEND_GameEvent(NET_EV_LMS_DRAW
, 0, FName
);
3145 gLMSRespawn
:= LMS_RESPAWN_FINAL
;
3146 gLMSRespawnTime
:= gTime
+ 5000;
3149 else if (gGameSettings
.GameMode
= GM_DM
) then
3153 if gPlayers
[k
] <> nil then
3156 // survivor is the winner
3157 g_Game_Message(Format(_lc
[I_MESSAGE_LMS_WIN
], [AnsiUpperCase(FName
)]), 144);
3159 MH_SEND_GameEvent(NET_EV_LMS_WIN
, 0, FName
);
3162 gLMSRespawn
:= LMS_RESPAWN_FINAL
;
3163 gLMSRespawnTime
:= gTime
+ 5000;
3165 else if (a
= 0) then
3167 // everyone is dead, restart the map
3168 g_Game_Message(_lc
[I_GAME_WIN_DRAW
], 144);
3170 MH_SEND_GameEvent(NET_EV_LMS_DRAW
, 0, FName
);
3171 gLMSRespawn
:= LMS_RESPAWN_FINAL
;
3172 gLMSRespawnTime
:= gTime
+ 5000;
3175 if srv
and (OldLR
= LMS_RESPAWN_NONE
) and (gLMSRespawn
> LMS_RESPAWN_NONE
) then
3177 if NetMode
= NET_SERVER
then
3178 MH_SEND_GameEvent(NET_EV_LMS_WARMUP
, (gLMSRespawnTime
- gTime
) div 1000)
3180 g_Console_Add(Format(_lc
[I_MSG_WARMUP_START
], [(gLMSRespawnTime
- gTime
) div 1000]), True);
3186 MH_SEND_PlayerStats(FUID
);
3187 MH_SEND_PlayerDeath(FUID
, KillType
, t
, SpawnerUID
);
3188 if gGameSettings
.GameMode
= GM_TDM
then MH_SEND_GameStats
;
3191 if srv
and FNoRespawn
then Spectate(True);
3192 FWantsInGame
:= True;
3195 function TPlayer
.BodyInLiquid(XInc
, YInc
: Integer): Boolean;
3197 Result
:= g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
, PLAYER_RECT
.Width
,
3198 PLAYER_RECT
.Height
-20, PANEL_WATER
or PANEL_ACID1
or PANEL_ACID2
, False);
3201 function TPlayer
.BodyInAcid(XInc
, YInc
: Integer): Boolean;
3203 Result
:= g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
, PLAYER_RECT
.Width
,
3204 PLAYER_RECT
.Height
-20, PANEL_ACID1
or PANEL_ACID2
, False);
3207 procedure TPlayer
.MakeBloodSimple(Count
: Word);
3209 g_GFX_Blood(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)+8,
3210 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2),
3211 Count
div 2, 3, -1, 16, (PLAYER_RECT
.Height
*2 div 3),
3213 g_GFX_Blood(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-8,
3214 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2),
3215 Count
div 2, -3, -1, 16, (PLAYER_RECT
.Height
*2) div 3,
3219 procedure TPlayer
.MakeBloodVector(Count
: Word; VelX
, VelY
: Integer);
3221 g_GFX_Blood(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2),
3222 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2),
3223 Count
, VelX
, VelY
, 16, (PLAYER_RECT
.Height
*2) div 3,
3227 procedure TPlayer
.NextWeapon();
3232 if g_Game_IsClient
then Exit
;
3233 if FBFGFireCounter
<> -1 then Exit
;
3235 if FTime
[T_SWITCH
] > gTime
then Exit
;
3237 for i
:= WEAPON_KASTET
to WEAPON_SUPERPULEMET
do
3238 if FReloading
[i
] > 0 then Exit
;
3242 for i
:= FCurrWeap
+1 to WEAPON_SUPERPULEMET
do
3251 for i
:= WEAPON_KASTET
to FCurrWeap
-1 do
3258 FTime
[T_SWITCH
] := gTime
+156;
3260 if FCurrWeap
= WEAPON_SAW
then
3261 FSawSoundSelect
.PlayAt(FObj
.X
, FObj
.Y
);
3263 FModel
.SetWeapon(FCurrWeap
);
3265 if g_Game_IsNet
then MH_SEND_PlayerStats(FUID
);
3268 procedure TPlayer
.PrevWeapon();
3273 if g_Game_IsClient
then Exit
;
3274 if FBFGFireCounter
<> -1 then Exit
;
3276 if FTime
[T_SWITCH
] > gTime
then Exit
;
3278 for i
:= WEAPON_KASTET
to WEAPON_SUPERPULEMET
do
3279 if FReloading
[i
] > 0 then Exit
;
3283 if FCurrWeap
> 0 then
3284 for i
:= FCurrWeap
-1 downto WEAPON_KASTET
do
3293 for i
:= WEAPON_SUPERPULEMET
downto FCurrWeap
+1 do
3300 FTime
[T_SWITCH
] := gTime
+156;
3302 if FCurrWeap
= WEAPON_SAW
then
3303 FSawSoundSelect
.PlayAt(FObj
.X
, FObj
.Y
);
3305 FModel
.SetWeapon(FCurrWeap
);
3307 if g_Game_IsNet
then MH_SEND_PlayerStats(FUID
);
3310 procedure TPlayer
.SetWeapon(W
: Byte);
3312 if FCurrWeap
<> W
then
3313 if W
= WEAPON_SAW
then
3314 FSawSoundSelect
.PlayAt(FObj
.X
, FObj
.Y
);
3317 FModel
.SetWeapon(CurrWeap
);
3320 function TPlayer
.PickItem(ItemType
: Byte; respawn
: Boolean; var remove
: Boolean): Boolean;
3325 if g_Game_IsClient
then Exit
;
3327 // a = true - ìåñòî ñïàâíà ïðåäìåòà:
3328 a
:= LongBool(gGameSettings
.Options
and GAME_OPTION_WEAPONSTAY
) and respawn
;
3333 if FHealth
< PLAYER_HP_SOFT
then
3335 IncMax(FHealth
, 10, PLAYER_HP_SOFT
);
3338 if gFlash
= 2 then Inc(FPickup
, 5);
3342 if FHealth
< PLAYER_HP_SOFT
then
3344 IncMax(FHealth
, 25, PLAYER_HP_SOFT
);
3347 if gFlash
= 2 then Inc(FPickup
, 5);
3351 if FArmor
< PLAYER_AP_SOFT
then
3353 FArmor
:= PLAYER_AP_SOFT
;
3356 if gFlash
= 2 then Inc(FPickup
, 5);
3360 if FArmor
< PLAYER_AP_LIMIT
then
3362 FArmor
:= PLAYER_AP_LIMIT
;
3365 if gFlash
= 2 then Inc(FPickup
, 5);
3369 if FHealth
< PLAYER_HP_LIMIT
then
3371 IncMax(FHealth
, 100, PLAYER_HP_LIMIT
);
3374 if gFlash
= 2 then Inc(FPickup
, 5);
3378 if (FHealth
< PLAYER_HP_LIMIT
) or (FArmor
< PLAYER_AP_LIMIT
) then
3380 if FHealth
< PLAYER_HP_LIMIT
then
3381 FHealth
:= PLAYER_HP_LIMIT
;
3382 if FArmor
< PLAYER_AP_LIMIT
then
3383 FArmor
:= PLAYER_AP_LIMIT
;
3386 if gFlash
= 2 then Inc(FPickup
, 5);
3390 if (not FWeapon
[WEAPON_SAW
]) or ((not respawn
) and (gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
])) then
3392 FWeapon
[WEAPON_SAW
] := True;
3394 if gFlash
= 2 then Inc(FPickup
, 5);
3395 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
3398 ITEM_WEAPON_SHOTGUN1
:
3399 if (FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
]) or not FWeapon
[WEAPON_SHOTGUN1
] then
3401 // Íóæíî, ÷òîáû íå âçÿòü âñå ïóëè ñðàçó:
3402 if a
and FWeapon
[WEAPON_SHOTGUN1
] then Exit
;
3404 IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
3405 FWeapon
[WEAPON_SHOTGUN1
] := True;
3407 if gFlash
= 2 then Inc(FPickup
, 5);
3408 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
3411 ITEM_WEAPON_SHOTGUN2
:
3412 if (FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
]) or not FWeapon
[WEAPON_SHOTGUN2
] then
3414 if a
and FWeapon
[WEAPON_SHOTGUN2
] then Exit
;
3416 IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
3417 FWeapon
[WEAPON_SHOTGUN2
] := True;
3419 if gFlash
= 2 then Inc(FPickup
, 5);
3420 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
3423 ITEM_WEAPON_CHAINGUN
:
3424 if (FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
]) or not FWeapon
[WEAPON_CHAINGUN
] then
3426 if a
and FWeapon
[WEAPON_CHAINGUN
] then Exit
;
3428 IncMax(FAmmo
[A_BULLETS
], 50, FMaxAmmo
[A_BULLETS
]);
3429 FWeapon
[WEAPON_CHAINGUN
] := True;
3431 if gFlash
= 2 then Inc(FPickup
, 5);
3432 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
3435 ITEM_WEAPON_ROCKETLAUNCHER
:
3436 if (FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
]) or not FWeapon
[WEAPON_ROCKETLAUNCHER
] then
3438 if a
and FWeapon
[WEAPON_ROCKETLAUNCHER
] then Exit
;
3440 IncMax(FAmmo
[A_ROCKETS
], 2, FMaxAmmo
[A_ROCKETS
]);
3441 FWeapon
[WEAPON_ROCKETLAUNCHER
] := True;
3443 if gFlash
= 2 then Inc(FPickup
, 5);
3444 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
3448 if (FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
]) or not FWeapon
[WEAPON_PLASMA
] then
3450 if a
and FWeapon
[WEAPON_PLASMA
] then Exit
;
3452 IncMax(FAmmo
[A_CELLS
], 40, FMaxAmmo
[A_CELLS
]);
3453 FWeapon
[WEAPON_PLASMA
] := True;
3455 if gFlash
= 2 then Inc(FPickup
, 5);
3456 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
3460 if (FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
]) or not FWeapon
[WEAPON_BFG
] then
3462 if a
and FWeapon
[WEAPON_BFG
] then Exit
;
3464 IncMax(FAmmo
[A_CELLS
], 40, FMaxAmmo
[A_CELLS
]);
3465 FWeapon
[WEAPON_BFG
] := True;
3467 if gFlash
= 2 then Inc(FPickup
, 5);
3468 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
3471 ITEM_WEAPON_SUPERPULEMET
:
3472 if (FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
]) or not FWeapon
[WEAPON_SUPERPULEMET
] then
3474 if a
and FWeapon
[WEAPON_SUPERPULEMET
] then Exit
;
3476 IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
3477 FWeapon
[WEAPON_SUPERPULEMET
] := True;
3479 if gFlash
= 2 then Inc(FPickup
, 5);
3480 if a
and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETWEAPON');
3484 if FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
] then
3486 IncMax(FAmmo
[A_BULLETS
], 10, FMaxAmmo
[A_BULLETS
]);
3489 if gFlash
= 2 then Inc(FPickup
, 5);
3492 ITEM_AMMO_BULLETS_BOX
:
3493 if FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
] then
3495 IncMax(FAmmo
[A_BULLETS
], 50, FMaxAmmo
[A_BULLETS
]);
3498 if gFlash
= 2 then Inc(FPickup
, 5);
3502 if FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
] then
3504 IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
3507 if gFlash
= 2 then Inc(FPickup
, 5);
3510 ITEM_AMMO_SHELLS_BOX
:
3511 if FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
] then
3513 IncMax(FAmmo
[A_SHELLS
], 25, FMaxAmmo
[A_SHELLS
]);
3516 if gFlash
= 2 then Inc(FPickup
, 5);
3520 if FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
] then
3522 IncMax(FAmmo
[A_ROCKETS
], 1, FMaxAmmo
[A_ROCKETS
]);
3525 if gFlash
= 2 then Inc(FPickup
, 5);
3528 ITEM_AMMO_ROCKET_BOX
:
3529 if FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
] then
3531 IncMax(FAmmo
[A_ROCKETS
], 5, FMaxAmmo
[A_ROCKETS
]);
3534 if gFlash
= 2 then Inc(FPickup
, 5);
3538 if FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
] then
3540 IncMax(FAmmo
[A_CELLS
], 40, FMaxAmmo
[A_CELLS
]);
3543 if gFlash
= 2 then Inc(FPickup
, 5);
3547 if FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
] then
3549 IncMax(FAmmo
[A_CELLS
], 100, FMaxAmmo
[A_CELLS
]);
3552 if gFlash
= 2 then Inc(FPickup
, 5);
3556 if not(R_ITEM_BACKPACK
in FRulez
) or
3557 (FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
]) or
3558 (FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
]) or
3559 (FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
]) or
3560 (FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
]) then
3562 FMaxAmmo
[A_BULLETS
] := 400;
3563 FMaxAmmo
[A_SHELLS
] := 100;
3564 FMaxAmmo
[A_ROCKETS
] := 100;
3565 FMaxAmmo
[A_CELLS
] := 600;
3567 if FAmmo
[A_BULLETS
] < FMaxAmmo
[A_BULLETS
] then
3568 IncMax(FAmmo
[A_BULLETS
], 10, FMaxAmmo
[A_BULLETS
]);
3569 if FAmmo
[A_SHELLS
] < FMaxAmmo
[A_SHELLS
] then
3570 IncMax(FAmmo
[A_SHELLS
], 4, FMaxAmmo
[A_SHELLS
]);
3571 if FAmmo
[A_ROCKETS
] < FMaxAmmo
[A_ROCKETS
] then
3572 IncMax(FAmmo
[A_ROCKETS
], 1, FMaxAmmo
[A_ROCKETS
]);
3573 if FAmmo
[A_CELLS
] < FMaxAmmo
[A_CELLS
] then
3574 IncMax(FAmmo
[A_CELLS
], 40, FMaxAmmo
[A_CELLS
]);
3576 FRulez
:= FRulez
+ [R_ITEM_BACKPACK
];
3579 if gFlash
= 2 then Inc(FPickup
, 5);
3583 if not(R_KEY_RED
in FRulez
) then
3585 Include(FRulez
, R_KEY_RED
);
3587 remove
:= (gGameSettings
.GameMode
<> GM_COOP
) and (g_Player_GetCount() < 2);
3588 if gFlash
= 2 then Inc(FPickup
, 5);
3589 if (not remove
) and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETITEM');
3593 if not(R_KEY_GREEN
in FRulez
) then
3595 Include(FRulez
, R_KEY_GREEN
);
3597 remove
:= (gGameSettings
.GameMode
<> GM_COOP
) and (g_Player_GetCount() < 2);
3598 if gFlash
= 2 then Inc(FPickup
, 5);
3599 if (not remove
) and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETITEM');
3603 if not(R_KEY_BLUE
in FRulez
) then
3605 Include(FRulez
, R_KEY_BLUE
);
3607 remove
:= (gGameSettings
.GameMode
<> GM_COOP
) and (g_Player_GetCount() < 2);
3608 if gFlash
= 2 then Inc(FPickup
, 5);
3609 if (not remove
) and g_Game_IsNet
then MH_SEND_Sound(GameX
, GameY
, 'SOUND_ITEM_GETITEM');
3613 if FMegaRulez
[MR_SUIT
] < gTime
+PLAYER_SUIT_TIME
then
3615 FMegaRulez
[MR_SUIT
] := gTime
+PLAYER_SUIT_TIME
;
3618 if gFlash
= 2 then Inc(FPickup
, 5);
3622 if FAir
< AIR_MAX
then
3627 if gFlash
= 2 then Inc(FPickup
, 5);
3632 if not (R_BERSERK
in FRulez
) then
3634 Include(FRulez
, R_BERSERK
);
3635 if FBFGFireCounter
= -1 then
3637 FCurrWeap
:= WEAPON_KASTET
;
3638 FModel
.SetWeapon(WEAPON_KASTET
);
3642 if gFlash
= 2 then Inc(FPickup
, 5);
3643 FBerserk
:= gTime
+30000;
3647 if FHealth
< PLAYER_HP_SOFT
then
3649 FHealth
:= PLAYER_HP_SOFT
;
3650 FBerserk
:= gTime
+30000;
3657 if FMegaRulez
[MR_INVUL
] < gTime
+PLAYER_INVUL_TIME
then
3659 FMegaRulez
[MR_INVUL
] := gTime
+PLAYER_INVUL_TIME
;
3662 if gFlash
= 2 then Inc(FPickup
, 5);
3666 if FHealth
< PLAYER_HP_LIMIT
then
3668 IncMax(FHealth
, 4, PLAYER_HP_LIMIT
);
3671 if gFlash
= 2 then Inc(FPickup
, 5);
3675 if FArmor
< PLAYER_AP_LIMIT
then
3677 IncMax(FArmor
, 5, PLAYER_AP_LIMIT
);
3680 if gFlash
= 2 then Inc(FPickup
, 5);
3684 if FJetFuel
< JET_MAX
then
3686 FJetFuel
:= JET_MAX
;
3689 if gFlash
= 2 then Inc(FPickup
, 5);
3693 if FMegaRulez
[MR_INVIS
] < gTime
+PLAYER_INVIS_TIME
then
3695 FMegaRulez
[MR_INVIS
] := gTime
+PLAYER_INVIS_TIME
;
3698 if gFlash
= 2 then Inc(FPickup
, 5);
3703 procedure TPlayer
.Touch();
3707 //FModel.PlaySound(MODELSOUND_PAIN, 1, FObj.X, FObj.Y);
3710 // Áðîñèòü ôëàã òîâàðèùó:
3711 if gGameSettings
.GameMode
= GM_CTF
then
3716 procedure TPlayer
.Push(vx
, vy
: Integer);
3718 if (not FPhysics
) and FGhost
then
3720 FObj
.Accel
.X
:= FObj
.Accel
.X
+ vx
;
3721 FObj
.Accel
.Y
:= FObj
.Accel
.Y
+ vy
;
3722 if g_Game_IsNet
and g_Game_IsServer
then
3723 MH_SEND_PlayerPos(True, FUID
, NET_EVERYONE
);
3726 procedure TPlayer
.Reset(Force
: Boolean);
3732 FTime
[T_RESPAWN
] := 0;
3733 FTime
[T_FLAGCAP
] := 0;
3746 FSpectator
:= False;
3749 FSpectatePlayer
:= -1;
3750 FNoRespawn
:= False;
3752 FLives
:= gGameSettings
.MaxLives
;
3757 procedure TPlayer
.SoftReset();
3763 FBFGFireCounter
:= -1;
3771 SetAction(A_STAND
, True);
3774 function TPlayer
.GetRespawnPoint(): Byte;
3779 // Íà áóäóùåå: FSpawn - èãðîê óæå èãðàë è ïåðåðîæäàåòñÿ
3781 // Îäèíî÷íàÿ èãðà/êîîïåðàòèâ
3782 if gGameSettings
.GameMode
in [GM_COOP
, GM_SINGLE
] then
3784 if (Self
= gPlayer1
) or (Self
= gPlayer2
) then
3786 // Òî÷êà ïîÿâëåíèÿ ñâîåãî èãðîêà
3787 if Self
= gPlayer1
then
3788 c
:= RESPAWNPOINT_PLAYER1
3790 c
:= RESPAWNPOINT_PLAYER2
;
3791 if g_Map_GetPointCount(c
) > 0 then
3797 // Òî÷êà ïîÿâëåíèÿ äðóãîãî èãðîêà
3798 if Self
= gPlayer1
then
3799 c
:= RESPAWNPOINT_PLAYER2
3801 c
:= RESPAWNPOINT_PLAYER1
;
3802 if g_Map_GetPointCount(c
) > 0 then
3809 // Òî÷êà ïîÿâëåíèÿ ëþáîãî èãðîêà (áîòà)
3810 if Random(2) = 0 then
3811 c
:= RESPAWNPOINT_PLAYER1
3813 c
:= RESPAWNPOINT_PLAYER2
;
3814 if g_Map_GetPointCount(c
) > 0 then
3821 // Òî÷êà ëþáîé èç êîìàíä
3822 if Random(2) = 0 then
3823 c
:= RESPAWNPOINT_RED
3825 c
:= RESPAWNPOINT_BLUE
;
3826 if g_Map_GetPointCount(c
) > 0 then
3833 c
:= RESPAWNPOINT_DM
;
3834 if g_Map_GetPointCount(c
) > 0 then
3842 if gGameSettings
.GameMode
= GM_DM
then
3845 c
:= RESPAWNPOINT_DM
;
3846 if g_Map_GetPointCount(c
) > 0 then
3852 // Òî÷êà ïîÿâëåíèÿ ëþáîãî èãðîêà
3853 if Random(2) = 0 then
3854 c
:= RESPAWNPOINT_PLAYER1
3856 c
:= RESPAWNPOINT_PLAYER2
;
3857 if g_Map_GetPointCount(c
) > 0 then
3863 // Òî÷êà ëþáîé èç êîìàíä
3864 if Random(2) = 0 then
3865 c
:= RESPAWNPOINT_RED
3867 c
:= RESPAWNPOINT_BLUE
;
3868 if g_Map_GetPointCount(c
) > 0 then
3876 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
3878 // Òî÷êà ñâîåé êîìàíäû
3879 c
:= RESPAWNPOINT_DM
;
3880 if FTeam
= TEAM_RED
then
3881 c
:= RESPAWNPOINT_RED
;
3882 if FTeam
= TEAM_BLUE
then
3883 c
:= RESPAWNPOINT_BLUE
;
3884 if g_Map_GetPointCount(c
) > 0 then
3891 c
:= RESPAWNPOINT_DM
;
3892 if g_Map_GetPointCount(c
) > 0 then
3898 // Òî÷êà ïîÿâëåíèÿ ëþáîãî èãðîêà
3899 if Random(2) = 0 then
3900 c
:= RESPAWNPOINT_PLAYER1
3902 c
:= RESPAWNPOINT_PLAYER2
;
3903 if g_Map_GetPointCount(c
) > 0 then
3909 // Òî÷êà äðóãîé êîìàíäû
3910 c
:= RESPAWNPOINT_DM
;
3911 if FTeam
= TEAM_RED
then
3912 c
:= RESPAWNPOINT_BLUE
;
3913 if FTeam
= TEAM_BLUE
then
3914 c
:= RESPAWNPOINT_RED
;
3915 if g_Map_GetPointCount(c
) > 0 then
3923 procedure TPlayer
.Respawn(Silent
: Boolean; Force
: Boolean = False);
3925 RespawnPoint
: TRespawnPoint
;
3930 if not g_Game_IsServer
then
3934 FWantsInGame
:= True;
3935 FJustTeleported
:= True;
3938 FTime
[T_RESPAWN
] := 0;
3942 // if server changes MaxLives we gotta be ready
3943 if gGameSettings
.MaxLives
= 0 then FNoRespawn
:= False;
3945 // Åùå íåëüçÿ âîçðîäèòüñÿ:
3946 if FTime
[T_RESPAWN
] > gTime
then
3949 // Ïðîñðàë âñå æèçíè:
3952 if not FSpectator
then Spectate(True);
3953 FWantsInGame
:= True;
3957 if (gGameSettings
.GameType
<> GT_SINGLE
) and (gGameSettings
.GameMode
<> GM_COOP
) then
3958 begin // "Ñâîÿ èãðà"
3959 // Áåðñåðê íå ñîõðàíÿåòñÿ ìåæäó óðîâíÿìè:
3960 FRulez
:= FRulez
-[R_BERSERK
];
3962 else // "Îäèíî÷íàÿ èãðà"/"Êîîï"
3964 // Áåðñåðê è êëþ÷è íå ñîõðàíÿþòñÿ ìåæäó óðîâíÿìè:
3965 FRulez
:= FRulez
-[R_KEY_RED
, R_KEY_GREEN
, R_KEY_BLUE
, R_BERSERK
];
3968 // Ïîëó÷àåì òî÷êó ñïàóíà èãðîêà:
3969 c
:= GetRespawnPoint();
3974 // Âîñêðåøåíèå áåç îðóæèÿ:
3977 FHealth
:= PLAYER_HP_SOFT
;
3983 for a
:= WEAPON_KASTET
to WEAPON_SUPERPULEMET
do
3985 FWeapon
[a
] := False;
3989 FWeapon
[WEAPON_PISTOL
] := True;
3990 FWeapon
[WEAPON_KASTET
] := True;
3991 FCurrWeap
:= WEAPON_PISTOL
;
3993 FModel
.SetWeapon(FCurrWeap
);
3995 for b
:= A_BULLETS
to A_CELLS
do
3998 FAmmo
[A_BULLETS
] := 50;
4000 FMaxAmmo
[A_BULLETS
] := 200;
4001 FMaxAmmo
[A_SHELLS
] := 50;
4002 FMaxAmmo
[A_ROCKETS
] := 50;
4003 FMaxAmmo
[A_CELLS
] := 300;
4005 if gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
] then
4006 FRulez
:= [R_KEY_RED
, R_KEY_GREEN
, R_KEY_BLUE
]
4011 // Ïîëó÷àåì êîîðäèíàòû òî÷êè âîçðîæäåíèÿ:
4012 if not g_Map_GetPoint(c
, RespawnPoint
) then
4014 g_FatalError(_lc
[I_GAME_ERROR_GET_SPAWN
]);
4018 // Óñòàíîâêà êîîðäèíàò è ñáðîñ âñåõ ïàðàìåòðîâ:
4019 FObj
.X
:= RespawnPoint
.X
-PLAYER_RECT
.X
;
4020 FObj
.Y
:= RespawnPoint
.Y
-PLAYER_RECT
.Y
;
4026 FDirection
:= RespawnPoint
.Direction
;
4027 if FDirection
= D_LEFT
then
4033 FBFGFireCounter
:= -1;
4038 SetAction(A_STAND
, True);
4039 FModel
.Direction
:= FDirection
;
4041 for a
:= Low(FTime
) to High(FTime
) do
4044 for a
:= Low(FMegaRulez
) to High(FMegaRulez
) do
4049 FCanJetpack
:= False;
4051 // Àíèìàöèÿ âîçðîæäåíèÿ:
4052 if (not gLoadGameMode
) and (not Silent
) then
4053 if g_Frames_Get(ID
, 'FRAMES_TELEPORT') then
4055 Anim
:= TAnimation
.Create(ID
, False, 3);
4056 g_GFX_OnceAnim(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-32,
4057 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)-32, Anim
);
4061 FSpectator
:= False;
4064 FSpectatePlayer
:= -1;
4067 if g_Game_IsNet
then
4069 MH_SEND_PlayerPos(True, FUID
, NET_EVERYONE
);
4070 MH_SEND_PlayerStats(FUID
, NET_EVERYONE
);
4072 MH_SEND_Effect(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-32,
4073 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)-32,
4078 procedure TPlayer
.Spectate(NoMove
: Boolean = False);
4081 Kill(K_EXTRAHARDKILL
, FUID
, HIT_SOME
)
4082 else if (not NoMove
) then
4084 GameX
:= gMapInfo
.Width
div 2;
4085 GameY
:= gMapInfo
.Height
div 2;
4094 FWantsInGame
:= False;
4099 if Self
= gPlayer1
then
4104 if Self
= gPlayer2
then
4111 if g_Game_IsNet
then
4112 MH_SEND_PlayerStats(FUID
);
4115 procedure TPlayer
.SwitchNoClip
;
4119 FGhost
:= not FGhost
;
4120 FPhysics
:= not FGhost
;
4132 procedure TPlayer
.Run(Direction
: TDirection
);
4136 if MAX_RUNVEL
> 8 then
4140 if Direction
= D_LEFT
then
4142 if FObj
.Vel
.X
> -MAX_RUNVEL
then
4143 FObj
.Vel
.X
:= FObj
.Vel
.X
- (MAX_RUNVEL
shr 3);
4146 if FObj
.Vel
.X
< MAX_RUNVEL
then
4147 FObj
.Vel
.X
:= FObj
.Vel
.X
+ (MAX_RUNVEL
shr 3);
4149 // Âîçìîæíî, ïèíàåì êóñêè:
4150 if (FObj
.Vel
.X
<> 0) and (gGibs
<> nil) then
4152 b
:= Abs(FObj
.Vel
.X
);
4153 if b
> 1 then b
:= b
* (Random(8 div b
) + 1);
4154 for a
:= 0 to High(gGibs
) do
4155 if gGibs
[a
].Live
and
4156 g_Obj_Collide(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
+FObj
.Rect
.Height
-4,
4157 FObj
.Rect
.Width
, 8, @gGibs
[a
].Obj
) and (Random(3) = 0) then
4159 if FObj
.Vel
.X
< 0 then
4160 g_Obj_PushA(@gGibs
[a
].Obj
, b
, Random(61)+120) // íàëåâî
4162 g_Obj_PushA(@gGibs
[a
].Obj
, b
, Random(61)); // íàïðàâî
4168 procedure TPlayer
.SeeDown();
4170 SetAction(A_SEEDOWN
);
4172 if FDirection
= D_LEFT
then FAngle
:= ANGLE_LEFTDOWN
else FAngle
:= ANGLE_RIGHTDOWN
;
4174 if FIncCam
> -120 then DecMin(FIncCam
, 5, -120);
4177 procedure TPlayer
.SeeUp();
4181 if FDirection
= D_LEFT
then FAngle
:= ANGLE_LEFTUP
else FAngle
:= ANGLE_RIGHTUP
;
4183 if FIncCam
< 120 then IncMax(FIncCam
, 5, 120);
4186 procedure TPlayer
.SetAction(Action
: Byte; Force
: Boolean = False);
4194 A_ATTACK
: Prior
:= 2;
4195 A_SEEUP
: Prior
:= 1;
4196 A_SEEDOWN
: Prior
:= 1;
4197 A_ATTACKUP
: Prior
:= 2;
4198 A_ATTACKDOWN
: Prior
:= 2;
4203 if (Prior
> FActionPrior
) or Force
then
4204 if not ((Prior
= 2) and (FCurrWeap
= WEAPON_SAW
)) then
4206 FActionPrior
:= Prior
;
4207 FActionAnim
:= Action
;
4208 FActionForce
:= Force
;
4209 FActionChanged
:= True;
4212 if Action
in [A_ATTACK
, A_ATTACKUP
, A_ATTACKDOWN
] then FModel
.SetFire(True);
4215 function TPlayer
.StayOnStep(XInc
, YInc
: Integer): Boolean;
4217 Result
:= not g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+YInc
+PLAYER_RECT
.Y
+PLAYER_RECT
.Height
-1,
4218 PLAYER_RECT
.Width
, 1, PANEL_STEP
, False)
4219 and g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+YInc
+PLAYER_RECT
.Y
+PLAYER_RECT
.Height
,
4220 PLAYER_RECT
.Width
, 1, PANEL_STEP
, False);
4223 function TPlayer
.TeleportTo(X
, Y
: Integer; silent
: Boolean; dir
: Byte): Boolean;
4230 if g_CollideLevel(X
, Y
, PLAYER_RECT
.Width
, PLAYER_RECT
.Height
) then
4232 g_Sound_PlayExAt('SOUND_GAME_NOTELEPORT', FObj
.X
, FObj
.Y
);
4233 if g_Game_IsServer
and g_Game_IsNet
then
4234 MH_SEND_Sound(FObj
.X
, FObj
.Y
, 'SOUND_GAME_NOTELEPORT');
4238 FJustTeleported
:= True;
4243 if g_Frames_Get(ID
, 'FRAMES_TELEPORT') then
4245 Anim
:= TAnimation
.Create(ID
, False, 3);
4248 g_Sound_PlayExAt('SOUND_GAME_TELEPORT', FObj
.X
, FObj
.Y
);
4249 g_GFX_OnceAnim(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-32,
4250 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)-32, Anim
);
4251 if g_Game_IsServer
and g_Game_IsNet
then
4252 MH_SEND_Effect(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-32,
4253 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)-32, 1,
4257 FObj
.X
:= X
-PLAYER_RECT
.X
;
4258 FObj
.Y
:= Y
-PLAYER_RECT
.Y
;
4259 if FLive
and FGhost
then
4265 if not g_Game_IsNet
then
4269 SetDirection(D_LEFT
);
4275 SetDirection(D_RIGHT
);
4281 if FDirection
= D_RIGHT
then
4283 SetDirection(D_LEFT
);
4288 SetDirection(D_RIGHT
);
4294 if not silent
and (Anim
<> nil) then
4296 g_GFX_OnceAnim(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-32,
4297 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)-32, Anim
);
4300 if g_Game_IsServer
and g_Game_IsNet
then
4301 MH_SEND_Effect(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2)-32,
4302 FObj
.Y
+PLAYER_RECT
.Y
+(PLAYER_RECT
.Height
div 2)-32, 0,
4309 function nonz(a
: Single): Single;
4317 procedure TPlayer
.Update();
4320 i
, ii
, wx
, wy
, xd
, yd
, k
: Integer;
4321 blockmon
, headwater
, dospawn
: Boolean;
4326 NetServer
:= g_Game_IsNet
and g_Game_IsServer
;
4327 AnyServer
:= g_Game_IsServer
;
4329 if g_Game_IsClient
and (NetInterpLevel
> 0) then
4330 DoLerp(NetInterpLevel
+ 1)
4336 if FClientID
>= 0 then
4338 FPing
:= NetClients
[FClientID
].Peer
^.lastRoundTripTime
;
4339 if NetClients
[FClientID
].Peer
^.packetsSent
> 0 then
4340 FLoss
:= Round(100*NetClients
[FClientID
].Peer
^.packetsLost
/NetClients
[FClientID
].Peer
^.packetsSent
)
4349 if FLive
and (gFly
or FJetpack
) then
4352 if FDirection
= D_LEFT
then
4357 if FLive
and (not FGhost
) then
4359 if FKeys
[KEY_UP
].Pressed
then
4361 if FKeys
[KEY_DOWN
].Pressed
then
4365 if (not (FKeys
[KEY_UP
].Pressed
or FKeys
[KEY_DOWN
].Pressed
)) and
4368 i
:= g_basic
.Sign(FIncCam
);
4369 FIncCam
:= Abs(FIncCam
);
4370 DecMin(FIncCam
, 5, 0);
4371 FIncCam
:= FIncCam
*i
;
4374 if gTime
mod (GAME_TICK
*2) <> 0 then
4376 if (FObj
.Vel
.X
= 0) and FLive
then
4378 if FKeys
[KEY_LEFT
].Pressed
then
4380 if FKeys
[KEY_RIGHT
].Pressed
then
4385 g_Obj_Move(@FObj
, True, True, True);
4390 FActionChanged
:= False;
4394 // Let alive player do some actions
4395 if FKeys
[KEY_LEFT
].Pressed
then Run(D_LEFT
);
4396 if FKeys
[KEY_RIGHT
].Pressed
then Run(D_RIGHT
);
4397 if FKeys
[KEY_NEXTWEAPON
].Pressed
and AnyServer
then NextWeapon();
4398 if FKeys
[KEY_PREVWEAPON
].Pressed
and AnyServer
then PrevWeapon();
4399 if FKeys
[KEY_FIRE
].Pressed
and AnyServer
then Fire();
4400 if FKeys
[KEY_OPEN
].Pressed
and AnyServer
then Use();
4401 if FKeys
[KEY_JUMP
].Pressed
then Jump()
4404 if AnyServer
and FJetpack
then
4408 if NetServer
then MH_SEND_PlayerStats(FUID
);
4410 FCanJetpack
:= True;
4417 for k
:= Low(FKeys
) to KEY_CHAT
-1 do
4419 if FKeys
[k
].Pressed
then
4427 if gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
] then
4430 if (FTime
[T_RESPAWN
] <= gTime
) and
4431 gGameOn
and (not FLive
) then
4433 if (g_Player_GetCount() > 1) then
4437 gExit
:= EXIT_RESTART
;
4442 // Dead spectator actions
4445 if FKeys
[KEY_OPEN
].Pressed
and AnyServer
then Fire();
4446 if FKeys
[KEY_FIRE
].Pressed
and AnyServer
then
4450 if (FSpectatePlayer
>= High(gPlayers
)) then
4451 FSpectatePlayer
:= -1
4455 for I
:= FSpectatePlayer
+ 1 to High(gPlayers
) do
4456 if gPlayers
[I
] <> nil then
4457 if gPlayers
[I
].Live
then
4458 if gPlayers
[I
].UID
<> FUID
then
4460 FSpectatePlayer
:= I
;
4465 if not SetSpect
then FSpectatePlayer
:= -1;
4476 if FKeys
[KEY_UP
].Pressed
or FKeys
[KEY_JUMP
].Pressed
then
4478 FYTo
:= FObj
.Y
- 32;
4479 FSpectatePlayer
:= -1;
4481 if FKeys
[KEY_DOWN
].Pressed
then
4483 FYTo
:= FObj
.Y
+ 32;
4484 FSpectatePlayer
:= -1;
4486 if FKeys
[KEY_LEFT
].Pressed
then
4488 FXTo
:= FObj
.X
- 32;
4489 FSpectatePlayer
:= -1;
4491 if FKeys
[KEY_RIGHT
].Pressed
then
4493 FXTo
:= FObj
.X
+ 32;
4494 FSpectatePlayer
:= -1;
4497 if (FXTo
< -64) then
4499 else if (FXTo
> gMapInfo
.Width
+ 32) then
4500 FXTo
:= gMapInfo
.Width
+ 32;
4501 if (FYTo
< -72) then
4503 else if (FYTo
> gMapInfo
.Height
+ 32) then
4504 FYTo
:= gMapInfo
.Height
+ 32;
4508 g_Obj_Move(@FObj
, True, True, True)
4514 if (FSpectatePlayer
<= High(gPlayers
)) and (FSpectatePlayer
>= 0) then
4515 if gPlayers
[FSpectatePlayer
] <> nil then
4516 if gPlayers
[FSpectatePlayer
].Live
then
4518 FXTo
:= gPlayers
[FSpectatePlayer
].GameX
;
4519 FYTo
:= gPlayers
[FSpectatePlayer
].GameY
;
4523 blockmon
:= g_Map_CollidePanel(FObj
.X
+PLAYER_HEADRECT
.X
, FObj
.Y
+PLAYER_HEADRECT
.Y
,
4524 PLAYER_HEADRECT
.Width
, PLAYER_HEADRECT
.Height
,
4525 PANEL_BLOCKMON
, True);
4526 headwater
:= HeadInLiquid(0, 0);
4528 // Ñîïðîòèâëåíèå âîçäóõà:
4529 if (not FLive
) or not (FKeys
[KEY_LEFT
].Pressed
or FKeys
[KEY_RIGHT
].Pressed
) then
4530 if FObj
.Vel
.X
<> 0 then
4531 FObj
.Vel
.X
:= z_dec(FObj
.Vel
.X
, 1);
4533 if (FLastHit
= HIT_TRAP
) and (FPain
> 90) then FPain
:= 90;
4534 DecMin(FPain
, 5, 0);
4535 DecMin(FPickup
, 1, 0);
4537 if FLive
and (FObj
.Y
> gMapInfo
.Height
+128) and AnyServer
then
4539 // Îáíóëèòü äåéñòâèÿ ïðèìî÷åê, ÷òîáû ôîí ïðîïàë
4540 FMegaRulez
[MR_SUIT
] := 0;
4541 FMegaRulez
[MR_INVUL
] := 0;
4542 FMegaRulez
[MR_INVIS
] := 0;
4543 Kill(K_FALLKILL
, 0, HIT_FALL
);
4550 if FCurrWeap
= WEAPON_SAW
then
4551 if not (FSawSound
.IsPlaying() or FSawSoundHit
.IsPlaying() or
4552 FSawSoundSelect
.IsPlaying()) then
4553 FSawSoundIdle
.PlayAt(FObj
.X
, FObj
.Y
);
4556 if (not FJetSoundFly
.IsPlaying()) and (not FJetSoundOn
.IsPlaying()) and
4557 (not FJetSoundOff
.IsPlaying()) then
4559 FJetSoundFly
.SetPosition(0);
4560 FJetSoundFly
.PlayAt(FObj
.X
, FObj
.Y
);
4563 for b
:= WEAPON_KASTET
to WEAPON_SUPERPULEMET
do
4564 if FReloading
[b
] > 0 then
4570 if FShellTimer
> -1 then
4571 if FShellTimer
= 0 then
4573 if FShellType
= SHELL_SHELL
then
4574 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
4575 GameVelX
, GameVelY
-2, SHELL_SHELL
)
4576 else if FShellType
= SHELL_DBLSHELL
then
4578 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
4579 GameVelX
+1, GameVelY
-2, SHELL_SHELL
);
4580 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
4581 GameVelX
-1, GameVelY
-2, SHELL_SHELL
);
4584 end else Dec(FShellTimer
);
4586 if (FBFGFireCounter
> -1) then
4587 if FBFGFireCounter
= 0 then
4591 wx
:= FObj
.X
+WEAPONPOINT
[FDirection
].X
;
4592 wy
:= FObj
.Y
+WEAPONPOINT
[FDirection
].Y
;
4593 xd
:= wx
+IfThen(FDirection
= D_LEFT
, -30, 30);
4594 yd
:= wy
+firediry();
4595 g_Weapon_bfgshot(wx
, wy
, xd
, yd
, FUID
);
4596 if NetServer
then MH_SEND_PlayerFire(FUID
, WEAPON_BFG
, wx
, wy
, xd
, yd
);
4597 if (FAngle
= 0) or (FAngle
= 180) then SetAction(A_ATTACK
)
4598 else if (FAngle
= ANGLE_LEFTDOWN
) or (FAngle
= ANGLE_RIGHTDOWN
) then SetAction(A_ATTACKDOWN
)
4599 else if (FAngle
= ANGLE_LEFTUP
) or (FAngle
= ANGLE_RIGHTUP
) then SetAction(A_ATTACKUP
);
4602 FReloading
[WEAPON_BFG
] := WEAPON_RELOAD
[WEAPON_BFG
];
4603 FBFGFireCounter
:= -1;
4606 FBFGFireCounter
:= 0
4608 Dec(FBFGFireCounter
);
4610 if (FMegaRulez
[MR_SUIT
] < gTime
) and AnyServer
then
4612 b
:= g_GetAcidHit(FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+PLAYER_RECT
.Y
, PLAYER_RECT
.Width
, PLAYER_RECT
.Height
);
4614 if (b
> 0) and (gTime
mod (15*GAME_TICK
) = 0) then Damage(b
, 0, 0, 0, HIT_ACID
);
4617 if (headwater
or blockmon
) then
4623 if AnyServer
then Damage(10, 0, 0, 0, HIT_WATER
);
4626 else if (FAir
mod 31 = 0) and not blockmon
then
4628 g_GFX_Bubbles(FObj
.X
+PLAYER_RECT
.X
+(PLAYER_RECT
.Width
div 2), FObj
.Y
+PLAYER_RECT
.Y
-4, 5+Random(6), 8, 4);
4629 if Random(2) = 0 then
4630 g_Sound_PlayExAt('SOUND_GAME_BUBBLE1', FObj
.X
, FObj
.Y
)
4632 g_Sound_PlayExAt('SOUND_GAME_BUBBLE2', FObj
.X
, FObj
.Y
);
4634 end else if FAir
< AIR_DEF
then
4637 if FDamageBuffer
> 0 then
4639 if FDamageBuffer
>= 9 then
4643 if FDamageBuffer
< 30 then i
:= 9
4644 else if FDamageBuffer
< 100 then i
:= 18
4648 ii
:= Round(FDamageBuffer
*FHealth
/ nonz(FArmor
*(3/4)+FHealth
));
4649 FArmor
:= FArmor
-(FDamageBuffer
-ii
);
4650 FHealth
:= FHealth
-ii
;
4653 FHealth
:= FHealth
+FArmor
;
4658 if FHealth
<= 0 then
4659 if FHealth
> -30 then Kill(K_SIMPLEKILL
, FLastSpawnerUID
, FLastHit
)
4660 else if FHealth
> -50 then Kill(K_HARDKILL
, FLastSpawnerUID
, FLastHit
)
4661 else Kill(K_EXTRAHARDKILL
, FLastSpawnerUID
, FLastHit
);
4665 if FDamageBuffer
<= 20 then FModel
.PlaySound(MODELSOUND_PAIN
, 1, FObj
.X
, FObj
.Y
)
4666 else if FDamageBuffer
<= 55 then FModel
.PlaySound(MODELSOUND_PAIN
, 2, FObj
.X
, FObj
.Y
)
4667 else if FDamageBuffer
<= 120 then FModel
.PlaySound(MODELSOUND_PAIN
, 3, FObj
.X
, FObj
.Y
)
4668 else FModel
.PlaySound(MODELSOUND_PAIN
, 4, FObj
.X
, FObj
.Y
);
4675 end; // if FLive then ...
4677 if (FActionAnim
= A_PAIN
) and (FModel
.Animation
<> A_PAIN
) then
4679 FModel
.ChangeAnimation(FActionAnim
, FActionForce
);
4680 FModel
.GetCurrentAnimation
.MinLength
:= i
;
4681 FModel
.GetCurrentAnimationMask
.MinLength
:= i
;
4682 end else FModel
.ChangeAnimation(FActionAnim
, FActionForce
and (FModel
.Animation
<> A_STAND
));
4684 if (FModel
.GetCurrentAnimation
.Played
or ((not FActionChanged
) and (FModel
.Animation
= A_WALK
)))
4685 then SetAction(A_STAND
, True);
4687 if not ((FModel
.Animation
= A_WALK
) and (Abs(FObj
.Vel
.X
) < 4) and not FModel
.Fire
) then FModel
.Update
;
4689 for b
:= Low(FKeys
) to High(FKeys
) do
4690 if FKeys
[b
].Time
= 0 then FKeys
[b
].Pressed
:= False else Dec(FKeys
[b
].Time
);
4693 function TPlayer
.Collide(X
, Y
: Integer; Width
, Height
: Word): Boolean;
4695 Result
:= g_Collide(FObj
.X
+PLAYER_RECT
.X
,
4696 FObj
.Y
+PLAYER_RECT
.Y
,
4703 function TPlayer
.Collide(Panel
: TPanel
): Boolean;
4705 Result
:= g_Collide(FObj
.X
+PLAYER_RECT
.X
,
4706 FObj
.Y
+PLAYER_RECT
.Y
,
4710 Panel
.Width
, Panel
.Height
);
4713 function TPlayer
.Collide(X
, Y
: Integer): Boolean;
4715 X
:= X
-FObj
.X
-PLAYER_RECT
.X
;
4716 Y
:= Y
-FObj
.Y
-PLAYER_RECT
.Y
;
4717 Result
:= (x
>= 0) and (x
<= PLAYER_RECT
.Width
) and
4718 (y
>= 0) and (y
<= PLAYER_RECT
.Height
);
4721 function g_Player_ValidName(Name
: string): Boolean;
4727 if gPlayers
= nil then Exit
;
4729 for a
:= 0 to High(gPlayers
) do
4730 if gPlayers
[a
] <> nil then
4731 if LowerCase(Name
) = LowerCase(gPlayers
[a
].FName
) then
4738 procedure TPlayer
.SetDirection(Direction
: TDirection
);
4742 d
:= FModel
.Direction
;
4744 FModel
.Direction
:= Direction
;
4745 if d
<> Direction
then FModel
.ChangeAnimation(FModel
.Animation
, True);
4747 FDirection
:= Direction
;
4750 function TPlayer
.GetKeys(): Byte;
4754 if R_KEY_RED
in FRulez
then Result
:= KEY_RED
;
4755 if R_KEY_GREEN
in FRulez
then Result
:= Result
or KEY_GREEN
;
4756 if R_KEY_BLUE
in FRulez
then Result
:= Result
or KEY_BLUE
;
4758 if FTeam
= TEAM_RED
then Result
:= Result
or KEY_REDTEAM
;
4759 if FTeam
= TEAM_BLUE
then Result
:= Result
or KEY_BLUETEAM
;
4762 procedure TPlayer
.Use();
4766 if FTime
[T_USE
] > gTime
then Exit
;
4768 g_Triggers_PressR(FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+PLAYER_RECT
.Y
, PLAYER_RECT
.Width
,
4769 PLAYER_RECT
.Height
, FUID
, ACTIVATE_PLAYERPRESS
);
4771 for a
:= 0 to High(gPlayers
) do
4772 if (gPlayers
[a
] <> nil) and (gPlayers
[a
] <> Self
) and
4773 gPlayers
[a
].Live
and SameTeam(FUID
, gPlayers
[a
].FUID
) and
4774 g_Obj_Collide(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
,
4775 FObj
.Rect
.Width
, FObj
.Rect
.Height
, @gPlayers
[a
].FObj
) then
4777 gPlayers
[a
].Touch();
4778 if g_Game_IsNet
and g_Game_IsServer
then
4779 MH_SEND_GameEvent(NET_EV_PLAYER_TOUCH
, gPlayers
[a
].FUID
);
4782 FTime
[T_USE
] := gTime
+120;
4785 procedure TPlayer
.NetFire(Wpn
: Byte; X
, Y
, AX
, AY
: Integer; WID
: Integer = -1);
4789 WX
, WY
, XD
, YD
: Integer;
4800 if R_BERSERK
in FRulez
then
4802 //g_Weapon_punch(FObj.X+FObj.Rect.X, FObj.Y+FObj.Rect.Y, 75, FUID);
4803 obj
.X
:= FObj
.X
+FObj
.Rect
.X
;
4804 obj
.Y
:= FObj
.Y
+FObj
.Rect
.Y
;
4807 obj
.rect
.Width
:= 39;
4808 obj
.rect
.Height
:= 52;
4809 obj
.Vel
.X
:= (xd
-wx
) div 2;
4810 obj
.Vel
.Y
:= (yd
-wy
) div 2;
4811 obj
.Accel
.X
:= xd
-wx
;
4812 obj
.Accel
.y
:= yd
-wy
;
4814 if g_Weapon_Hit(@obj
, 50, FUID
, HIT_SOME
) <> 0 then
4815 g_Sound_PlayExAt('SOUND_WEAPON_HITBERSERK', FObj
.X
, FObj
.Y
)
4817 g_Sound_PlayExAt('SOUND_WEAPON_MISSBERSERK', FObj
.X
, FObj
.Y
);
4821 FPain
:= min(FPain
+ 25, 50);
4823 g_Weapon_punch(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
, 3, FUID
);
4828 if g_Weapon_chainsaw(FObj
.X
+FObj
.Rect
.X
, FObj
.Y
+FObj
.Rect
.Y
,
4829 IfThen(gGameSettings
.GameMode
in [GM_DM
, GM_TDM
, GM_CTF
], 9, 3), FUID
) <> 0 then
4831 FSawSoundSelect
.Stop();
4833 FSawSoundHit
.PlayAt(FObj
.X
, FObj
.Y
);
4835 else if not FSawSoundHit
.IsPlaying() then
4837 FSawSoundSelect
.Stop();
4838 FSawSound
.PlayAt(FObj
.X
, FObj
.Y
);
4845 g_Sound_PlayExAt('SOUND_WEAPON_FIREPISTOL', GameX
, Gamey
);
4846 FFireAngle
:= FAngle
;
4848 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
4849 GameVelX
, GameVelY
-2, SHELL_BULLET
);
4854 g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN', Gamex
, Gamey
);
4855 FFireAngle
:= FAngle
;
4858 FShellType
:= SHELL_SHELL
;
4863 g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN2', Gamex
, Gamey
);
4864 FFireAngle
:= FAngle
;
4867 FShellType
:= SHELL_DBLSHELL
;
4872 g_Sound_PlayExAt('SOUND_WEAPON_FIRECGUN', Gamex
, Gamey
);
4873 FFireAngle
:= FAngle
;
4875 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
4876 GameVelX
, GameVelY
-2, SHELL_BULLET
);
4879 WEAPON_ROCKETLAUNCHER
:
4881 g_Weapon_Rocket(wx
, wy
, xd
, yd
, FUID
, WID
);
4882 FFireAngle
:= FAngle
;
4888 g_Weapon_Plasma(wx
, wy
, xd
, yd
, FUID
, WID
);
4889 FFireAngle
:= FAngle
;
4895 g_Weapon_BFGShot(wx
, wy
, xd
, yd
, FUID
, WID
);
4896 FFireAngle
:= FAngle
;
4900 WEAPON_SUPERPULEMET
:
4902 g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN', Gamex
, Gamey
);
4903 FFireAngle
:= FAngle
;
4905 g_Player_CreateShell(GameX
+PLAYER_RECT_CX
, GameY
+PLAYER_RECT_CX
,
4906 GameVelX
, GameVelY
-2, SHELL_SHELL
);
4912 if (FAngle
= 0) or (FAngle
= 180) then SetAction(A_ATTACK
)
4913 else if (FAngle
= ANGLE_LEFTDOWN
) or (FAngle
= ANGLE_RIGHTDOWN
) then SetAction(A_ATTACKDOWN
)
4914 else if (FAngle
= ANGLE_LEFTUP
) or (FAngle
= ANGLE_RIGHTUP
) then SetAction(A_ATTACKUP
);
4917 procedure TPlayer
.DoLerp(Level
: Integer = 2);
4919 if FObj
.X
<> FXTo
then FObj
.X
:= Lerp(FObj
.X
, FXTo
, Level
);
4920 if FObj
.Y
<> FYTo
then FObj
.Y
:= Lerp(FObj
.Y
, FYTo
, Level
);
4923 procedure TPlayer
.SetLerp(XTo
, YTo
: Integer);
4927 if NetInterpLevel
< 1 then
4937 AX
:= Abs(FXTo
- FObj
.X
);
4938 AY
:= Abs(FYTo
- FObj
.Y
);
4939 if (AX
> 32) or (AX
<= NetInterpLevel
) then
4941 if (AY
> 32) or (AY
<= NetInterpLevel
) then
4946 function TPlayer
.FullInLift(XInc
, YInc
: Integer): Integer;
4948 if g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
,
4949 PLAYER_RECT
.Width
, PLAYER_RECT
.Height
-8,
4950 PANEL_LIFTUP
, False) then Result
:= -1
4952 if g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
,
4953 PLAYER_RECT
.Width
, PLAYER_RECT
.Height
-8,
4954 PANEL_LIFTDOWN
, False) then Result
:= 1
4958 function TPlayer
.GetFlag(Flag
: Byte): Boolean;
4965 if Flag
= FLAG_NONE
then
4968 if not g_Game_IsServer
then Exit
;
4970 // Ïðèíåñ ÷óæîé ôëàã íà ñâîþ áàçó:
4971 if (Flag
= FTeam
) and
4972 (gFlags
[Flag
].State
= FLAG_STATE_NORMAL
) and
4973 (FFlag
<> FLAG_NONE
) then
4975 if FFlag
= FLAG_RED
then
4976 s
:= _lc
[I_PLAYER_FLAG_RED
]
4978 s
:= _lc
[I_PLAYER_FLAG_BLUE
];
4980 evtype
:= FLAG_STATE_SCORED
;
4982 ts
:= Format('%.4d', [gFlags
[FFlag
].CaptureTime
]);
4983 Insert('.', ts
, Length(ts
) + 1 - 3);
4984 g_Console_Add(Format(_lc
[I_PLAYER_FLAG_CAPTURE
], [FName
, s
, ts
]), True);
4986 g_Map_ResetFlag(FFlag
);
4987 g_Game_Message(Format(_lc
[I_MESSAGE_FLAG_CAPTURE
], [AnsiUpperCase(s
)]), 144);
4989 gTeamStat
[FTeam
].Goals
:= gTeamStat
[FTeam
].Goals
+ 1;
4992 if g_Game_IsNet
then
4994 MH_SEND_FlagEvent(evtype
, FFlag
, FUID
, False);
4998 gFlags
[FFlag
].CaptureTime
:= 0;
5003 // Ïîäîáðàë ñâîé ôëàã - âåðíóë åãî íà áàçó:
5004 if (Flag
= FTeam
) and
5005 (gFlags
[Flag
].State
= FLAG_STATE_DROPPED
) then
5007 if Flag
= FLAG_RED
then
5008 s
:= _lc
[I_PLAYER_FLAG_RED
]
5010 s
:= _lc
[I_PLAYER_FLAG_BLUE
];
5012 evtype
:= FLAG_STATE_RETURNED
;
5013 gFlags
[Flag
].CaptureTime
:= 0;
5015 g_Console_Add(Format(_lc
[I_PLAYER_FLAG_RETURN
], [FName
, s
]), True);
5017 g_Map_ResetFlag(Flag
);
5018 g_Game_Message(Format(_lc
[I_MESSAGE_FLAG_RETURN
], [AnsiUpperCase(s
)]), 144);
5021 if g_Game_IsNet
then
5023 MH_SEND_FlagEvent(evtype
, Flag
, FUID
, False);
5029 // Ïîäîáðàë ÷óæîé ôëàã:
5030 if (Flag
<> FTeam
) and (FTime
[T_FLAGCAP
] <= gTime
) then
5034 if Flag
= FLAG_RED
then
5035 s
:= _lc
[I_PLAYER_FLAG_RED
]
5037 s
:= _lc
[I_PLAYER_FLAG_BLUE
];
5039 evtype
:= FLAG_STATE_CAPTURED
;
5041 g_Console_Add(Format(_lc
[I_PLAYER_FLAG_GET
], [FName
, s
]), True);
5043 g_Game_Message(Format(_lc
[I_MESSAGE_FLAG_GET
], [AnsiUpperCase(s
)]), 144);
5045 gFlags
[Flag
].State
:= FLAG_STATE_CAPTURED
;
5048 if g_Game_IsNet
then
5050 MH_SEND_FlagEvent(evtype
, Flag
, FUID
, False);
5056 procedure TPlayer
.SetFlag(Flag
: Byte);
5059 if FModel
<> nil then
5060 FModel
.SetFlag(FFlag
);
5063 function TPlayer
.DropFlag(): Boolean;
5068 if (not g_Game_IsServer
) or (FFlag
= FLAG_NONE
) then
5070 FTime
[T_FLAGCAP
] := gTime
+ 2000;
5071 with gFlags
[FFlag
] do
5075 Direction
:= FDirection
;
5076 State
:= FLAG_STATE_DROPPED
;
5078 g_Obj_Push(@Obj
, (FObj
.Vel
.X
div 2)-2+Random(5),
5079 (FObj
.Vel
.Y
div 2)-2+Random(5));
5081 if FFlag
= FLAG_RED
then
5082 s
:= _lc
[I_PLAYER_FLAG_RED
]
5084 s
:= _lc
[I_PLAYER_FLAG_BLUE
];
5086 g_Console_Add(Format(_lc
[I_PLAYER_FLAG_DROP
], [FName
, s
]), True);
5087 g_Game_Message(Format(_lc
[I_MESSAGE_FLAG_DROP
], [AnsiUpperCase(s
)]), 144);
5089 if g_Game_IsNet
then
5090 MH_SEND_FlagEvent(FLAG_STATE_DROPPED
, Flag
, FUID
, False);
5096 procedure TPlayer
.GetSecret();
5101 procedure TPlayer
.PressKey(Key
: Byte; Time
: Word = 1);
5103 Assert(Key
<= High(FKeys
));
5105 FKeys
[Key
].Pressed
:= True;
5106 FKeys
[Key
].Time
:= Time
;
5109 function TPlayer
.IsKeyPressed(K
: Byte): Boolean;
5111 Result
:= FKeys
[K
].Pressed
;
5114 procedure TPlayer
.ReleaseKeys();
5118 for a
:= Low(FKeys
) to High(FKeys
) do
5120 FKeys
[a
].Pressed
:= False;
5125 procedure TPlayer
.OnDamage(Angle
: SmallInt);
5129 function TPlayer
.firediry(): Integer;
5131 if FKeys
[KEY_UP
].Pressed
then Result
:= -42
5132 else if FKeys
[KEY_DOWN
].Pressed
then Result
:= 19
5136 procedure TPlayer
.RememberState();
5140 FSavedState
.Health
:= FHealth
;
5141 FSavedState
.Armor
:= FArmor
;
5142 FSavedState
.Air
:= FAir
;
5143 FSavedState
.JetFuel
:= FJetFuel
;
5144 FSavedState
.CurrWeap
:= FCurrWeap
;
5147 FSavedState
.Ammo
[i
] := FAmmo
[i
];
5149 FSavedState
.MaxAmmo
[i
] := FMaxAmmo
[i
];
5151 FSavedState
.Rulez
:= FRulez
;
5152 FSavedState
.WaitRecall
:= True;
5155 procedure TPlayer
.RecallState();
5159 if not FSavedState
.WaitRecall
then Exit
;
5161 FHealth
:= FSavedState
.Health
;
5162 FArmor
:= FSavedState
.Armor
;
5163 FAir
:= FSavedState
.Air
;
5164 FJetFuel
:= FSavedState
.JetFuel
;
5165 FCurrWeap
:= FSavedState
.CurrWeap
;
5168 FAmmo
[i
] := FSavedState
.Ammo
[i
];
5170 FMaxAmmo
[i
] := FSavedState
.MaxAmmo
[i
];
5172 FRulez
:= FSavedState
.Rulez
;
5173 FSavedState
.WaitRecall
:= False;
5175 if gGameSettings
.GameType
= GT_SERVER
then
5176 MH_SEND_PlayerStats(FUID
);
5179 procedure TPlayer
.SaveState(var Mem
: TBinMemoryWriter
);
5191 Mem
:= TBinMemoryWriter
.Create(i
);
5193 // Ñèãíàòóðà èãðîêà:
5194 sig
:= PLAYER_SIGNATURE
; // 'PLYR'
5195 Mem
.WriteDWORD(sig
);
5197 Mem
.WriteBoolean(FIamBot
);
5199 Mem
.WriteWord(FUID
);
5201 Mem
.WriteString(FName
, 32);
5203 Mem
.WriteByte(FTeam
);
5205 Mem
.WriteBoolean(FLive
);
5206 // Èçðàñõîäîâàë ëè âñå æèçíè:
5207 Mem
.WriteBoolean(FNoRespawn
);
5209 if FDirection
= D_LEFT
then
5215 Mem
.WriteInt(FHealth
);
5217 Mem
.WriteByte(FLives
);
5219 Mem
.WriteInt(FArmor
);
5223 Mem
.WriteInt(FJetFuel
);
5225 Mem
.WriteInt(FPain
);
5227 Mem
.WriteInt(FKills
);
5229 Mem
.WriteInt(FMonsterKills
);
5231 Mem
.WriteInt(FFrags
);
5233 Mem
.WriteByte(FFragCombo
);
5234 // Âðåìÿ ïîñëåäíåãî ôðàãà:
5235 Mem
.WriteDWORD(FLastFrag
);
5237 Mem
.WriteInt(FDeath
);
5238 // Êàêîé ôëàã íåñåò:
5239 Mem
.WriteByte(FFlag
);
5241 Mem
.WriteInt(FSecrets
);
5243 Mem
.WriteByte(FCurrWeap
);
5244 // Âðåìÿ çàðÿäêè BFG:
5245 Mem
.WriteSmallInt(FBFGFireCounter
);
5247 Mem
.WriteInt(FDamageBuffer
);
5248 // Ïîñëåäíèé óäàðèâøèé:
5249 Mem
.WriteWord(FLastSpawnerUID
);
5250 // Òèï ïîñëåäíåãî ïîëó÷åííîãî óðîíà:
5251 Mem
.WriteByte(FLastHit
);
5253 Obj_SaveState(@FObj
, Mem
);
5254 // Òåêóùåå êîëè÷åñòâî ïàòðîíîâ:
5255 for i
:= A_BULLETS
to A_CELLS
do
5256 Mem
.WriteWord(FAmmo
[i
]);
5257 // Ìàêñèìàëüíîå êîëè÷åñòâî ïàòðîíîâ:
5258 for i
:= A_BULLETS
to A_CELLS
do
5259 Mem
.WriteWord(FMaxAmmo
[i
]);
5261 for i
:= WEAPON_KASTET
to WEAPON_SUPERPULEMET
do
5262 Mem
.WriteBoolean(FWeapon
[i
]);
5263 // Âðåìÿ ïåðåçàðÿäêè îðóæèÿ:
5264 for i
:= WEAPON_KASTET
to WEAPON_SUPERPULEMET
do
5265 Mem
.WriteWord(FReloading
[i
]);
5267 if R_ITEM_BACKPACK
in FRulez
then
5272 // Íàëè÷èå êðàñíîãî êëþ÷à:
5273 if R_KEY_RED
in FRulez
then
5278 // Íàëè÷èå çåëåíîãî êëþ÷à:
5279 if R_KEY_GREEN
in FRulez
then
5284 // Íàëè÷èå ñèíåãî êëþ÷à:
5285 if R_KEY_BLUE
in FRulez
then
5290 // Íàëè÷èå áåðñåðêà:
5291 if R_BERSERK
in FRulez
then
5296 // Âðåìÿ äåéñòâèÿ ñïåöèàëüíûõ ïðåäìåòîâ:
5297 for i
:= MR_SUIT
to MR_MAX
do
5298 Mem
.WriteDWORD(FMegaRulez
[i
]);
5299 // Âðåìÿ äî ïîâòîðíîãî ðåñïàóíà, ñìåíû îðóæèÿ, èñîëüçîâàíèÿ, çàõâàòà ôëàãà:
5300 for i
:= T_RESPAWN
to T_FLAGCAP
do
5301 Mem
.WriteDWORD(FTime
[i
]);
5304 Mem
.WriteString(str
);
5314 procedure TPlayer
.LoadState(var Mem
: TBinMemoryReader
);
5324 // Ñèãíàòóðà èãðîêà:
5326 if sig
<> PLAYER_SIGNATURE
then // 'PLYR'
5328 raise EBinSizeError
.Create('TPlayer.LoadState: Wrong Player Signature');
5331 Mem
.ReadBoolean(FIamBot
);
5335 Mem
.ReadString(str
);
5336 if (Self
<> gPlayer1
) and (Self
<> gPlayer2
) then
5339 Mem
.ReadByte(FTeam
);
5341 Mem
.ReadBoolean(FLive
);
5342 // Èçðàñõîäîâàë ëè âñå æèçíè:
5343 Mem
.ReadBoolean(FNoRespawn
);
5347 FDirection
:= D_LEFT
5349 FDirection
:= D_RIGHT
;
5351 Mem
.ReadInt(FHealth
);
5353 Mem
.ReadByte(FLives
);
5355 Mem
.ReadInt(FArmor
);
5359 Mem
.ReadInt(FJetFuel
);
5363 Mem
.ReadInt(FKills
);
5365 Mem
.ReadInt(FMonsterKills
);
5367 Mem
.ReadInt(FFrags
);
5369 Mem
.ReadByte(FFragCombo
);
5370 // Âðåìÿ ïîñëåäíåãî ôðàãà:
5371 Mem
.ReadDWORD(FLastFrag
);
5373 Mem
.ReadInt(FDeath
);
5374 // Êàêîé ôëàã íåñåò:
5375 Mem
.ReadByte(FFlag
);
5377 Mem
.ReadInt(FSecrets
);
5379 Mem
.ReadByte(FCurrWeap
);
5380 // Âðåìÿ çàðÿäêè BFG:
5381 Mem
.ReadSmallInt(FBFGFireCounter
);
5383 Mem
.ReadInt(FDamageBuffer
);
5384 // Ïîñëåäíèé óäàðèâøèé:
5385 Mem
.ReadWord(FLastSpawnerUID
);
5386 // Òèï ïîñëåäíåãî ïîëó÷åííîãî óðîíà:
5387 Mem
.ReadByte(FLastHit
);
5389 Obj_LoadState(@FObj
, Mem
);
5390 // Òåêóùåå êîëè÷åñòâî ïàòðîíîâ:
5391 for i
:= A_BULLETS
to A_CELLS
do
5392 Mem
.ReadWord(FAmmo
[i
]);
5393 // Ìàêñèìàëüíîå êîëè÷åñòâî ïàòðîíîâ:
5394 for i
:= A_BULLETS
to A_CELLS
do
5395 Mem
.ReadWord(FMaxAmmo
[i
]);
5397 for i
:= WEAPON_KASTET
to WEAPON_SUPERPULEMET
do
5398 Mem
.ReadBoolean(FWeapon
[i
]);
5399 // Âðåìÿ ïåðåçàðÿäêè îðóæèÿ:
5400 for i
:= WEAPON_KASTET
to WEAPON_SUPERPULEMET
do
5401 Mem
.ReadWord(FReloading
[i
]);
5405 Include(FRulez
, R_ITEM_BACKPACK
);
5406 // Íàëè÷èå êðàñíîãî êëþ÷à:
5409 Include(FRulez
, R_KEY_RED
);
5410 // Íàëè÷èå çåëåíîãî êëþ÷à:
5413 Include(FRulez
, R_KEY_GREEN
);
5414 // Íàëè÷èå ñèíåãî êëþ÷à:
5417 Include(FRulez
, R_KEY_BLUE
);
5418 // Íàëè÷èå áåðñåðêà:
5421 Include(FRulez
, R_BERSERK
);
5422 // Âðåìÿ äåéñòâèÿ ñïåöèàëüíûõ ïðåäìåòîâ:
5423 for i
:= MR_SUIT
to MR_MAX
do
5424 Mem
.ReadDWORD(FMegaRulez
[i
]);
5425 // Âðåìÿ äî ïîâòîðíîãî ðåñïàóíà, ñìåíû îðóæèÿ, èñîëüçîâàíèÿ, çàõâàòà ôëàãà:
5426 for i
:= T_RESPAWN
to T_FLAGCAP
do
5427 Mem
.ReadDWORD(FTime
[i
]);
5429 Mem
.ReadString(str
);
5431 Mem
.ReadByte(FColor
.R
);
5432 Mem
.ReadByte(FColor
.G
);
5433 Mem
.ReadByte(FColor
.B
);
5434 if Self
= gPlayer1
then
5436 str
:= gPlayer1Settings
.Model
;
5437 FColor
:= gPlayer1Settings
.Color
;
5439 if Self
= gPlayer2
then
5441 str
:= gPlayer2Settings
.Model
;
5442 FColor
:= gPlayer2Settings
.Color
;
5444 // Îáíîâëÿåì ìîäåëü èãðîêà:
5446 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
5447 FModel
.Color
:= TEAMCOLOR
[FTeam
]
5449 FModel
.Color
:= FColor
;
5452 procedure TPlayer
.AllRulez(Health
: Boolean);
5458 FHealth
:= PLAYER_HP_LIMIT
;
5459 FArmor
:= PLAYER_AP_LIMIT
;
5463 for a
:= WEAPON_KASTET
to WEAPON_SUPERPULEMET
do FWeapon
[a
] := True;
5464 for a
:= A_BULLETS
to A_CELLS
do FAmmo
[a
] := 30000;
5465 FRulez
:= FRulez
+[R_KEY_RED
, R_KEY_GREEN
, R_KEY_BLUE
];
5468 procedure TPlayer
.RestoreHealthArmor();
5470 FHealth
:= PLAYER_HP_LIMIT
;
5471 FArmor
:= PLAYER_AP_LIMIT
;
5474 procedure TPlayer
.FragCombo();
5478 if (gGameSettings
.GameMode
in [GM_COOP
, GM_SINGLE
]) or g_Game_IsClient
then
5480 if gTime
- FLastFrag
< FRAG_COMBO_TIME
then
5482 if FFragCombo
< 5 then
5484 Param
:= FUID
or (FFragCombo
shl 16);
5485 if (FComboEvnt
>= Low(gDelayedEvents
)) and
5486 (FComboEvnt
<= High(gDelayedEvents
)) and
5487 gDelayedEvents
[FComboEvnt
].Pending
and
5488 (gDelayedEvents
[FComboEvnt
].DEType
= DE_KILLCOMBO
) and
5489 (gDelayedEvents
[FComboEvnt
].DENum
and $FFFF = FUID
) then
5491 gDelayedEvents
[FComboEvnt
].Time
:= gTime
+ 500;
5492 gDelayedEvents
[FComboEvnt
].DENum
:= Param
;
5495 FComboEvnt
:= g_Game_DelayEvent(DE_KILLCOMBO
, 500, Param
);
5503 procedure TPlayer
.GiveItem(ItemType
: Byte);
5507 if FMegaRulez
[MR_SUIT
] < gTime
+PLAYER_SUIT_TIME
then
5509 FMegaRulez
[MR_SUIT
] := gTime
+PLAYER_SUIT_TIME
;
5513 if FAir
< AIR_MAX
then
5520 if not (R_BERSERK
in FRulez
) then
5522 Include(FRulez
, R_BERSERK
);
5523 if FBFGFireCounter
< 1 then
5525 FCurrWeap
:= WEAPON_KASTET
;
5526 FModel
.SetWeapon(WEAPON_KASTET
);
5530 FBerserk
:= gTime
+30000;
5532 if FHealth
< PLAYER_HP_SOFT
then
5534 FHealth
:= PLAYER_HP_SOFT
;
5535 FBerserk
:= gTime
+30000;
5540 if FMegaRulez
[MR_INVUL
] < gTime
+PLAYER_INVUL_TIME
then
5542 FMegaRulez
[MR_INVUL
] := gTime
+PLAYER_INVUL_TIME
;
5546 if FMegaRulez
[MR_INVIS
] < gTime
+PLAYER_INVIS_TIME
then
5548 FMegaRulez
[MR_INVIS
] := gTime
+PLAYER_INVIS_TIME
;
5552 if FJetFuel
< JET_MAX
then
5554 FJetFuel
:= JET_MAX
;
5560 if g_Game_IsNet
and g_Game_IsServer
then
5561 MH_SEND_PlayerStats(FUID
);
5564 procedure TPlayer
.FlySmoke(Times
: DWORD
= 1);
5569 if (Random(5) = 1) and (Times
= 1) then
5572 if BodyInLiquid(0, 0) then
5574 g_GFX_Bubbles(Obj
.X
+Obj
.Rect
.X
+(Obj
.Rect
.Width
div 2)+Random(3)-1,
5575 Obj
.Y
+Obj
.Rect
.Height
+8, 1, 8, 4);
5576 if Random(2) = 0 then
5577 g_Sound_PlayExAt('SOUND_GAME_BUBBLE1', FObj
.X
, FObj
.Y
)
5579 g_Sound_PlayExAt('SOUND_GAME_BUBBLE2', FObj
.X
, FObj
.Y
);
5583 if g_Frames_Get(id
, 'FRAMES_SMOKE') then
5585 for i
:= 1 to Times
do
5587 Anim
:= TAnimation
.Create(id
, False, 3);
5589 g_GFX_OnceAnim(Obj
.X
+Obj
.Rect
.X
+Random(Obj
.Rect
.Width
+Times
*2)-(Anim
.Width
div 2),
5590 Obj
.Y
+Obj
.Rect
.Height
-4+Random(8+Times
*2), Anim
, ONCEANIM_SMOKE
);
5596 procedure TPlayer
.PauseSounds(Enable
: Boolean);
5598 FSawSound
.Pause(Enable
);
5599 FSawSoundIdle
.Pause(Enable
);
5600 FSawSoundHit
.Pause(Enable
);
5601 FSawSoundSelect
.Pause(Enable
);
5606 constructor TCorpse
.Create(X
, Y
: Integer; ModelName
: String; aMess
: Boolean);
5611 FObj
.Rect
:= PLAYER_CORPSERECT
;
5612 FModelName
:= ModelName
;
5617 FState
:= CORPSE_STATE_MESS
;
5618 g_PlayerModel_GetAnim(ModelName
, A_DIE2
, FAnimation
, FAnimationMask
);
5622 FState
:= CORPSE_STATE_NORMAL
;
5623 g_PlayerModel_GetAnim(ModelName
, A_DIE1
, FAnimation
, FAnimationMask
);
5627 destructor TCorpse
.Destroy();
5634 procedure TCorpse
.Damage(Value
: Word; vx
, vy
: Integer);
5638 if FState
= CORPSE_STATE_REMOVEME
then
5641 FDamage
:= FDamage
+ Value
;
5643 if FDamage
> 150 then
5645 if FAnimation
<> nil then
5650 FState
:= CORPSE_STATE_REMOVEME
;
5652 g_Player_CreateGibs(FObj
.X
+FObj
.Rect
.X
+(FObj
.Rect
.Width
div 2),
5653 FObj
.Y
+FObj
.Rect
.Y
+(FObj
.Rect
.Height
div 2),
5654 FModelName
, FColor
);
5655 pm
:= g_PlayerModel_Get(FModelName
);
5656 pm
.PlaySound(MODELSOUND_DIE
, 3, FObj
.X
, FObj
.Y
);
5662 FObj
.Vel
.X
:= FObj
.Vel
.X
+ vx
;
5663 FObj
.Vel
.Y
:= FObj
.Vel
.Y
+ vy
;
5664 g_GFX_Blood(FObj
.X
+PLAYER_CORPSERECT
.X
+(PLAYER_CORPSERECT
.Width
div 2),
5665 FObj
.Y
+PLAYER_CORPSERECT
.Y
+(PLAYER_CORPSERECT
.Height
div 2),
5666 Value
, vx
, vy
, 16, (PLAYER_CORPSERECT
.Height
*2) div 3,
5671 procedure TCorpse
.Draw();
5673 if FState
= CORPSE_STATE_REMOVEME
then
5676 if FAnimation
<> nil then
5677 FAnimation
.Draw(FObj
.X
, FObj
.Y
, M_NONE
);
5679 if FAnimationMask
<> nil then
5682 FAnimationMask
.Draw(FObj
.X
, FObj
.Y
, M_NONE
);
5689 procedure TCorpse
.Update();
5693 if FState
= CORPSE_STATE_REMOVEME
then
5696 if gTime
mod (GAME_TICK
*2) <> 0 then
5698 g_Obj_Move(@FObj
, True, True, True);
5703 // Ñîïðîòèâëåíèå âîçäóõà äëÿ òðóïà:
5704 FObj
.Vel
.X
:= z_dec(FObj
.Vel
.X
, 1);
5706 st
:= g_Obj_Move(@FObj
, True, True, True);
5708 if WordBool(st
and MOVE_FALLOUT
) then
5710 FState
:= CORPSE_STATE_REMOVEME
;
5714 if FAnimation
<> nil then
5715 FAnimation
.Update();
5716 if FAnimationMask
<> nil then
5717 FAnimationMask
.Update();
5720 procedure TCorpse
.SaveState(var Mem
: TBinMemoryWriter
);
5729 sig
:= CORPSE_SIGNATURE
; // 'CORP'
5730 Mem
.WriteDWORD(sig
);
5732 Mem
.WriteByte(FState
);
5733 // Íàêîïëåííûé óðîí:
5734 Mem
.WriteByte(FDamage
);
5736 Mem
.WriteByte(FColor
.R
);
5737 Mem
.WriteByte(FColor
.G
);
5738 Mem
.WriteByte(FColor
.B
);
5740 Obj_SaveState(@FObj
, Mem
);
5741 // Åñòü ëè àíèìàöèÿ:
5742 anim
:= FAnimation
<> nil;
5743 Mem
.WriteBoolean(anim
);
5744 // Åñëè åñòü - ñîõðàíÿåì:
5746 FAnimation
.SaveState(Mem
);
5747 // Åñòü ëè ìàñêà àíèìàöèè:
5748 anim
:= FAnimationMask
<> nil;
5749 Mem
.WriteBoolean(anim
);
5750 // Åñëè åñòü - ñîõðàíÿåì:
5752 FAnimationMask
.SaveState(Mem
);
5755 procedure TCorpse
.LoadState(var Mem
: TBinMemoryReader
);
5765 if sig
<> CORPSE_SIGNATURE
then // 'CORP'
5767 raise EBinSizeError
.Create('TCorpse.LoadState: Wrong Corpse Signature');
5770 Mem
.ReadByte(FState
);
5771 // Íàêîïëåííûé óðîí:
5772 Mem
.ReadByte(FDamage
);
5774 Mem
.ReadByte(FColor
.R
);
5775 Mem
.ReadByte(FColor
.G
);
5776 Mem
.ReadByte(FColor
.B
);
5778 Obj_LoadState(@FObj
, Mem
);
5779 // Åñòü ëè àíèìàöèÿ:
5780 Mem
.ReadBoolean(anim
);
5781 // Åñëè åñòü - çàãðóæàåì:
5784 Assert(FAnimation
<> nil, 'TCorpse.LoadState: no FAnimation');
5785 FAnimation
.LoadState(Mem
);
5787 // Åñòü ëè ìàñêà àíèìàöèè:
5788 Mem
.ReadBoolean(anim
);
5789 // Åñëè åñòü - çàãðóæàåì:
5792 Assert(FAnimationMask
<> nil, 'TCorpse.LoadState: no FAnimationMask');
5793 FAnimationMask
.LoadState(Mem
);
5799 constructor TBot
.Create();
5806 FSpectator
:= False;
5813 for a
:= WEAPON_KASTET
to WEAPON_SUPERPULEMET
do
5815 FDifficult
.WeaponPrior
[a
] := WEAPON_PRIOR1
[a
];
5816 FDifficult
.CloseWeaponPrior
[a
] := WEAPON_PRIOR2
[a
];
5817 //FDifficult.SafeWeaponPrior[a] := WEAPON_PRIOR3[a];
5821 destructor TBot
.Destroy();
5824 inherited Destroy();
5827 procedure TBot
.Draw();
5831 //if FTargetUID <> 0 then e_DrawLine(1, FObj.X, FObj.Y, g_Player_Get(FTargetUID).FObj.X,
5832 // g_Player_Get(FTargetUID).FObj.Y, 255, 0, 0);
5835 procedure TBot
.Respawn(Silent
: Boolean; Force
: Boolean = False);
5837 inherited Respawn(Silent
, Force
);
5840 FSelectedWeapon
:= FCurrWeap
;
5844 procedure TBot
.UpdateCombat();
5857 TTargetRecord
= array of TTarget
;
5859 function Compare(a
, b
: TTarget
): Integer;
5861 if a
.Line
and not b
.Line
then // A íà ëèíèè îãíÿ
5864 if not a
.Line
and b
.Line
then // B íà ëèíèè îãíÿ
5866 else // È A, è B íà ëèíèè èëè íå íà ëèíèè îãíÿ
5867 if (a
.Line
and b
.Line
) or ((not a
.Line
) and (not b
.Line
)) then
5869 if a
.Dist
> b
.Dist
then // B áëèæå
5871 else // A áëèæå èëè ðàâíîóäàëåííî ñ B
5874 else // Ñòðàííî -> A
5879 a
, x1
, y1
, x2
, y2
: Integer;
5880 targets
: TTargetRecord
;
5882 Target
, BestTarget
: TTarget
;
5883 firew
, fireh
: Integer;
5887 vsPlayer
, vsMonster
, ok
: Boolean;
5889 vsPlayer
:= LongBool(gGameSettings
.Options
and GAME_OPTION_BOTVSPLAYER
);
5890 vsMonster
:= LongBool(gGameSettings
.Options
and GAME_OPTION_BOTVSMONSTER
);
5892 // Åñëè òåêóùåå îðóæèå íå òî, ÷òî íóæíî, òî ìåíÿåì:
5893 if FCurrWeap
<> FSelectedWeapon
then
5896 // Åñëè íóæíî ñòðåëÿòü è íóæíîå îðóæèå, òî íàæàòü "Ñòðåëÿòü":
5897 if (GetAIFlag('NEEDFIRE') <> '') and (FCurrWeap
= FSelectedWeapon
) then
5899 RemoveAIFlag('NEEDFIRE');
5902 WEAPON_PLASMA
, WEAPON_SUPERPULEMET
, WEAPON_CHAINGUN
: PressKey(KEY_FIRE
, 20);
5903 WEAPON_SAW
, WEAPON_KASTET
, WEAPON_MEGAKASTET
: PressKey(KEY_FIRE
, 40);
5904 else PressKey(KEY_FIRE
);
5908 // Êîîðäèíàòû ñòâîëà:
5909 x1
:= FObj
.X
+ WEAPONPOINT
[FDirection
].X
;
5910 y1
:= FObj
.Y
+ WEAPONPOINT
[FDirection
].Y
;
5912 Target
.UID
:= FTargetUID
;
5915 if Target
.UID
<> 0 then
5916 begin // Öåëü åñòü - íàñòðàèâàåì
5917 if (g_GetUIDType(Target
.UID
) = UID_PLAYER
) and
5920 with g_Player_Get(Target
.UID
) do
5922 if (@FObj
) <> nil then
5929 Target
.cX
:= Target
.X
+ PLAYER_RECT_CX
;
5930 Target
.cY
:= Target
.Y
+ PLAYER_RECT_CY
;
5931 Target
.Rect
:= PLAYER_RECT
;
5932 Target
.Visible
:= g_TraceVector(x1
, y1
, Target
.cX
, Target
.cY
);
5933 Target
.Line
:= (y1
+4 < Target
.Y
+PLAYER_RECT
.Y
+PLAYER_RECT
.Height
) and
5934 (y1
-4 > Target
.Y
+PLAYER_RECT
.Y
);
5935 Target
.IsPlayer
:= True;
5939 if (g_GetUIDType(Target
.UID
) = UID_MONSTER
) and
5942 mon
:= g_Monsters_Get(Target
.UID
);
5945 Target
.X
:= mon
.Obj
.X
;
5946 Target
.Y
:= mon
.Obj
.Y
;
5948 Target
.cX
:= Target
.X
+ mon
.Obj
.Rect
.X
+ (mon
.Obj
.Rect
.Width
div 2);
5949 Target
.cY
:= Target
.Y
+ mon
.Obj
.Rect
.Y
+ (mon
.Obj
.Rect
.Height
div 2);
5950 Target
.Rect
:= mon
.Obj
.Rect
;
5951 Target
.Visible
:= g_TraceVector(x1
, y1
, Target
.cX
, Target
.cY
);
5952 Target
.Line
:= (y1
+4 < Target
.Y
+ mon
.Obj
.Rect
.Y
+ mon
.Obj
.Rect
.Height
) and
5953 (y1
-4 > Target
.Y
+ mon
.Obj
.Rect
.Y
);
5954 Target
.IsPlayer
:= False;
5961 begin // Öåëè íåò - îáíóëÿåì
5966 Target
.Visible
:= False;
5967 Target
.Line
:= False;
5968 Target
.IsPlayer
:= False;
5973 // Åñëè öåëü íå âèäèìà èëè íå íà ëèíèè îãíÿ, òî èùåì âñå âîçìîæíûå öåëè:
5974 if (not Target
.Line
) or (not Target
.Visible
) then
5978 for a
:= 0 to High(gPlayers
) do
5979 if (gPlayers
[a
] <> nil) and (gPlayers
[a
].Live
) and
5980 (gPlayers
[a
].FUID
<> FUID
) and
5981 (not SameTeam(FUID
, gPlayers
[a
].FUID
)) and
5982 (not gPlayers
[a
].NoTarget
) and
5983 (gPlayers
[a
].FMegaRulez
[MR_INVIS
] < gTime
) then
5985 if not TargetOnScreen(gPlayers
[a
].FObj
.X
+ PLAYER_RECT
.X
,
5986 gPlayers
[a
].FObj
.Y
+ PLAYER_RECT
.Y
) then
5989 x2
:= gPlayers
[a
].FObj
.X
+ PLAYER_RECT_CX
;
5990 y2
:= gPlayers
[a
].FObj
.Y
+ PLAYER_RECT_CY
;
5992 // Åñëè èãðîê íà ýêðàíå è íå ïðèêðûò ñòåíîé:
5993 if g_TraceVector(x1
, y1
, x2
, y2
) then
5995 // Äîáàâëÿåì ê ñïèñêó âîçìîæíûõ öåëåé:
5996 SetLength(targets
, Length(targets
)+1);
5997 with targets
[High(targets
)] do
5999 UID
:= gPlayers
[a
].FUID
;
6000 X
:= gPlayers
[a
].FObj
.X
;
6001 Y
:= gPlayers
[a
].FObj
.Y
;
6004 Rect
:= PLAYER_RECT
;
6005 Dist
:= g_PatchLength(x1
, y1
, x2
, y2
);
6006 Line
:= (y1
+4 < Target
.Y
+PLAYER_RECT
.Y
+PLAYER_RECT
.Height
) and
6007 (y1
-4 > Target
.Y
+PLAYER_RECT
.Y
);
6015 if vsMonster
and (gMonsters
<> nil) then
6016 for a
:= 0 to High(gMonsters
) do
6017 if (gMonsters
[a
] <> nil) and (gMonsters
[a
].Live
) and
6018 (gMonsters
[a
].MonsterType
<> MONSTER_BARREL
) then
6020 mon
:= gMonsters
[a
];
6022 if not TargetOnScreen(mon
.Obj
.X
+ mon
.Obj
.Rect
.X
,
6023 mon
.Obj
.Y
+ mon
.Obj
.Rect
.Y
) then
6026 x2
:= mon
.Obj
.X
+ mon
.Obj
.Rect
.X
+ (mon
.Obj
.Rect
.Width
div 2);
6027 y2
:= mon
.Obj
.Y
+ mon
.Obj
.Rect
.Y
+ (mon
.Obj
.Rect
.Height
div 2);
6029 // Åñëè ìîíñòð íà ýêðàíå è íå ïðèêðûò ñòåíîé:
6030 if g_TraceVector(x1
, y1
, x2
, y2
) then
6032 // Äîáàâëÿåì ê ñïèñêó âîçìîæíûõ öåëåé:
6033 SetLength(targets
, Length(targets
)+1);
6034 with targets
[High(targets
)] do
6041 Rect
:= mon
.Obj
.Rect
;
6042 Dist
:= g_PatchLength(x1
, y1
, x2
, y2
);
6043 Line
:= (y1
+4 < Target
.Y
+ mon
.Obj
.Rect
.Y
+ mon
.Obj
.Rect
.Height
) and
6044 (y1
-4 > Target
.Y
+ mon
.Obj
.Rect
.Y
);
6052 // Åñëè åñòü âîçìîæíûå öåëè:
6053 // (Âûáèðàåì ëó÷øóþ, ìåíÿåì îðóæèå è áåæèì ê íåé/îò íåå)
6054 if targets
<> nil then
6056 // Âûáèðàåì íàèëó÷øóþ öåëü:
6057 BestTarget
:= targets
[0];
6058 if Length(targets
) > 1 then
6059 for a
:= 1 to High(targets
) do
6060 if Compare(BestTarget
, targets
[a
]) = 1 then
6061 BestTarget
:= targets
[a
];
6063 // Åñëè ëó÷øàÿ öåëü "âèäíåå" òåêóùåé, òî òåêóùàÿ := ëó÷øàÿ:
6064 if ((not Target
.Visible
) and BestTarget
.Visible
and (Target
.UID
<> BestTarget
.UID
)) or
6065 ((not Target
.Line
) and BestTarget
.Line
and BestTarget
.Visible
) then
6067 Target
:= BestTarget
;
6069 if (Healthy() = 3) or ((Healthy() = 2)) then
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 begin // Åñëè ïîáèòû - óáåãàåì
6078 if ((RunDirection() = D_LEFT
) and (Target
.X
< FObj
.X
)) then
6079 SetAIFlag('GORIGHT', '1');
6080 if ((RunDirection() = D_RIGHT
) and (Target
.X
> FObj
.X
)) then
6081 SetAIFlag('GOLEFT', '1');
6084 // Âûáèðàåì îðóæèå íà îñíîâå ðàññòîÿíèÿ è ïðèîðèòåòîâ:
6085 SelectWeapon(Abs(x1
-Target
.cX
));
6090 // (Äîãîíÿåì/óáåãàåì, ñòðåëÿåì ïî íàïðàâëåíèþ ê öåëè)
6091 // (Åñëè öåëü äàëåêî, òî õâàòèò ñëåäèòü çà íåé)
6092 if Target
.UID
<> 0 then
6094 if not TargetOnScreen(Target
.X
+ Target
.Rect
.X
,
6095 Target
.Y
+ Target
.Rect
.Y
) then
6096 begin // Öåëü ñáåæàëà ñ "ýêðàíà"
6097 if (Healthy() = 3) or ((Healthy() = 2)) then
6098 begin // Åñëè çäîðîâû - äîãîíÿåì
6099 if ((RunDirection() = D_LEFT
) and (Target
.X
> FObj
.X
)) then
6100 SetAIFlag('GORIGHT', '1');
6101 if ((RunDirection() = D_RIGHT
) and (Target
.X
< FObj
.X
)) then
6102 SetAIFlag('GOLEFT', '1');
6105 begin // Åñëè ïîáèòû - çàáûâàåì î öåëè è óáåãàåì
6107 if ((RunDirection() = D_LEFT
) and (Target
.X
< FObj
.X
)) then
6108 SetAIFlag('GORIGHT', '1');
6109 if ((RunDirection() = D_RIGHT
) and (Target
.X
> FObj
.X
)) then
6110 SetAIFlag('GOLEFT', '1');
6114 begin // Öåëü ïîêà íà "ýêðàíå"
6115 // Åñëè öåëü íå çàãîðîæåíà ñòåíîé, òî îòìå÷àåì, êîãäà åå âèäåëè:
6116 if g_TraceVector(x1
, y1
, Target
.cX
, Target
.cY
) then
6117 FLastVisible
:= gTime
;
6118 // Åñëè ðàçíèöà âûñîò íå âåëèêà, òî äîãîíÿåì:
6119 if (Abs(FObj
.Y
-Target
.Y
) <= 128) then
6121 if ((RunDirection() = D_LEFT
) and (Target
.X
> FObj
.X
)) then
6122 SetAIFlag('GORIGHT', '1');
6123 if ((RunDirection() = D_RIGHT
) and (Target
.X
< FObj
.X
)) then
6124 SetAIFlag('GOLEFT', '1');
6128 // Âûáèðàåì óãîë ââåðõ:
6129 if FDirection
= D_LEFT
then
6130 angle
:= ANGLE_LEFTUP
6132 angle
:= ANGLE_RIGHTUP
;
6134 firew
:= Trunc(Cos(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
6135 fireh
:= Trunc(Sin(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
6137 // Åñëè ïðè óãëå ââåðõ ìîæíî ïîïàñòü â ïðèáëèçèòåëüíîå ïîëîæåíèå öåëè:
6138 if g_CollideLine(x1
, y1
, x1
+firew
, y1
+fireh
,
6139 Target
.X
+Target
.Rect
.X
+GetInterval(FDifficult
.DiagPrecision
, 128), //96
6140 Target
.Y
+Target
.Rect
.Y
+GetInterval(FDifficult
.DiagPrecision
, 128),
6141 Target
.Rect
.Width
, Target
.Rect
.Height
) and
6142 g_TraceVector(x1
, y1
, Target
.cX
, Target
.cY
) then
6143 begin // òî íóæíî ñòðåëÿòü ââåðõ
6144 SetAIFlag('NEEDFIRE', '1');
6145 SetAIFlag('NEEDSEEUP', '1');
6148 // Âûáèðàåì óãîë âíèç:
6149 if FDirection
= D_LEFT
then
6150 angle
:= ANGLE_LEFTDOWN
6152 angle
:= ANGLE_RIGHTDOWN
;
6154 firew
:= Trunc(Cos(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
6155 fireh
:= Trunc(Sin(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
6157 // Åñëè ïðè óãëå âíèç ìîæíî ïîïàñòü â ïðèáëèçèòåëüíîå ïîëîæåíèå öåëè:
6158 if g_CollideLine(x1
, y1
, x1
+firew
, y1
+fireh
,
6159 Target
.X
+Target
.Rect
.X
+GetInterval(FDifficult
.DiagPrecision
, 128),
6160 Target
.Y
+Target
.Rect
.Y
+GetInterval(FDifficult
.DiagPrecision
, 128),
6161 Target
.Rect
.Width
, Target
.Rect
.Height
) and
6162 g_TraceVector(x1
, y1
, Target
.cX
, Target
.cY
) then
6163 begin // òî íóæíî ñòðåëÿòü âíèç
6164 SetAIFlag('NEEDFIRE', '1');
6165 SetAIFlag('NEEDSEEDOWN', '1');
6168 // Åñëè öåëü âèäíî è îíà íà òàêîé æå âûñîòå:
6169 if Target
.Visible
and
6170 (y1
+4 < Target
.Y
+Target
.Rect
.Y
+Target
.Rect
.Height
) and
6171 (y1
-4 > Target
.Y
+Target
.Rect
.Y
) then
6173 // Åñëè èäåì â ñòîðîíó öåëè, òî íàäî ñòðåëÿòü:
6174 if ((FDirection
= D_LEFT
) and (Target
.X
< FObj
.X
)) or
6175 ((FDirection
= D_RIGHT
) and (Target
.X
> FObj
.X
)) then
6176 begin // òî íóæíî ñòðåëÿòü âïåðåä
6177 SetAIFlag('NEEDFIRE', '1');
6178 SetAIFlag('NEEDSEEDOWN', '');
6179 SetAIFlag('NEEDSEEUP', '');
6181 // Åñëè öåëü â ïðåäåëàõ "ýêðàíà" è ñëîæíîñòü ïîçâîëÿåò ïðûæêè ñáëèæåíèÿ:
6182 if Abs(FObj
.X
-Target
.X
) < Trunc(gPlayerScreenSize
.X
*0.75) then
6183 if GetRnd(FDifficult
.CloseJump
) then
6184 begin // òî åñëè ïîâåçåò - ïðûãàåì (îñîáåííî, åñëè áëèçêî)
6185 if Abs(FObj
.X
-Target
.X
) < 128 then
6189 if Random(a
) = 0 then
6190 SetAIFlag('NEEDJUMP', '1');
6194 // Åñëè öåëü âñå åùå åñòü:
6195 if Target
.UID
<> 0 then
6196 if gTime
-FLastVisible
> 2000 then // Åñëè âèäåëè äàâíî
6197 Target
.UID
:= 0 // òî çàáûòü öåëü
6198 else // Åñëè âèäåëè íåäàâíî
6199 begin // íî öåëü óáèëè
6200 if Target
.IsPlayer
then
6201 begin // Öåëü - èãðîê
6202 pla
:= g_Player_Get(Target
.UID
);
6203 if (pla
= nil) or (not pla
.Live
) or pla
.NoTarget
or
6204 (pla
.FMegaRulez
[MR_INVIS
] >= gTime
) then
6205 Target
.UID
:= 0; // òî çàáûòü öåëü
6208 begin // Öåëü - ìîíñòð
6209 mon
:= g_Monsters_Get(Target
.UID
);
6210 if (mon
= nil) or (not mon
.Live
) then
6211 Target
.UID
:= 0; // òî çàáûòü öåëü
6214 end; // if Target.UID <> 0
6216 FTargetUID
:= Target
.UID
;
6218 // Åñëè âîçìîæíûõ öåëåé íåò:
6219 // (Àòàêà ÷åãî-íèáóäü ñëåâà èëè ñïðàâà)
6220 if targets
= nil then
6221 if GetAIFlag('ATTACKLEFT') <> '' then
6222 begin // Åñëè íóæíî àòàêîâàòü íàëåâî
6223 RemoveAIFlag('ATTACKLEFT');
6225 SetAIFlag('NEEDJUMP', '1');
6227 if RunDirection() = D_RIGHT
then
6228 begin // Èäåì íå â òó ñòîðîíó
6229 if (Healthy() > 1) and GetRnd(FDifficult
.InvisFire
) then
6230 begin // Åñëè çäîðîâû, òî, âîçìîæíî, ñòðåëÿåì áåæèì âëåâî è ñòðåëÿåì
6231 SetAIFlag('NEEDFIRE', '1');
6232 SetAIFlag('GOLEFT', '1');
6236 begin // Èäåì â íóæíóþ ñòîðîíó
6237 if GetRnd(FDifficult
.InvisFire
) then // Âîçìîæíî, ñòðåëÿåì âñëåïóþ
6238 SetAIFlag('NEEDFIRE', '1');
6239 if Healthy() <= 1 then // Ïîáèòû - óáåãàåì
6240 SetAIFlag('GORIGHT', '1');
6244 if GetAIFlag('ATTACKRIGHT') <> '' then
6245 begin // Åñëè íóæíî àòàêîâàòü íàïðàâî
6246 RemoveAIFlag('ATTACKRIGHT');
6248 SetAIFlag('NEEDJUMP', '1');
6250 if RunDirection() = D_LEFT
then
6251 begin // Èäåì íå â òó ñòîðîíó
6252 if (Healthy() > 1) and GetRnd(FDifficult
.InvisFire
) then
6253 begin // Åñëè çäîðîâû, òî, âîçìîæíî, áåæèì âïðàâî è ñòðåëÿåì
6254 SetAIFlag('NEEDFIRE', '1');
6255 SetAIFlag('GORIGHT', '1');
6260 if GetRnd(FDifficult
.InvisFire
) then // Âîçìîæíî, ñòðåëÿåì âñëåïóþ
6261 SetAIFlag('NEEDFIRE', '1');
6262 if Healthy() <= 1 then // Ïîáèòû - óáåãàåì
6263 SetAIFlag('GOLEFT', '1');
6267 // Åñëè åñòü âîçìîæíûå öåëè:
6268 // (Ñòðåëÿåì ïî íàïðàâëåíèþ ê öåëÿì)
6269 if (targets
<> nil) and (GetAIFlag('NEEDFIRE') <> '') then
6270 for a
:= 0 to High(targets
) do
6272 // Åñëè ìîæåì ñòðåëÿòü ïî äèàãîíàëè:
6273 if GetRnd(FDifficult
.DiagFire
) then
6275 // Èùåì öåëü ñâåðõó è ñòðåëÿåì, åñëè åñòü:
6276 if FDirection
= D_LEFT
then
6277 angle
:= ANGLE_LEFTUP
6279 angle
:= ANGLE_RIGHTUP
;
6281 firew
:= Trunc(Cos(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
6282 fireh
:= Trunc(Sin(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
6284 if g_CollideLine(x1
, y1
, x1
+firew
, y1
+fireh
,
6285 targets
[a
].X
+targets
[a
].Rect
.X
+GetInterval(FDifficult
.DiagPrecision
, 128),
6286 targets
[a
].Y
+targets
[a
].Rect
.Y
+GetInterval(FDifficult
.DiagPrecision
, 128),
6287 targets
[a
].Rect
.Width
, targets
[a
].Rect
.Height
) and
6288 g_TraceVector(x1
, y1
, targets
[a
].cX
, targets
[a
].cY
) then
6290 SetAIFlag('NEEDFIRE', '1');
6291 SetAIFlag('NEEDSEEUP', '1');
6294 // Èùåì öåëü ñíèçó è ñòðåëÿåì, åñëè åñòü:
6295 if FDirection
= D_LEFT
then
6296 angle
:= ANGLE_LEFTDOWN
6298 angle
:= ANGLE_RIGHTDOWN
;
6300 firew
:= Trunc(Cos(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
6301 fireh
:= Trunc(Sin(DegToRad(-angle
))*gPlayerScreenSize
.X
*0.6);
6303 if g_CollideLine(x1
, y1
, x1
+firew
, y1
+fireh
,
6304 targets
[a
].X
+targets
[a
].Rect
.X
+GetInterval(FDifficult
.DiagPrecision
, 128),
6305 targets
[a
].Y
+targets
[a
].Rect
.Y
+GetInterval(FDifficult
.DiagPrecision
, 128),
6306 targets
[a
].Rect
.Width
, targets
[a
].Rect
.Height
) and
6307 g_TraceVector(x1
, y1
, targets
[a
].cX
, targets
[a
].cY
) then
6309 SetAIFlag('NEEDFIRE', '1');
6310 SetAIFlag('NEEDSEEDOWN', '1');
6314 // Åñëè öåëü "ïåðåä íîñîì", òî ñòðåëÿåì:
6315 if targets
[a
].Line
and targets
[a
].Visible
and
6316 (((FDirection
= D_LEFT
) and (targets
[a
].X
< FObj
.X
)) or
6317 ((FDirection
= D_RIGHT
) and (targets
[a
].X
> FObj
.X
))) then
6319 SetAIFlag('NEEDFIRE', '1');
6324 // Åñëè ëåòèò ïóëÿ, òî, âîçìîæíî, ïîäïðûãèâàåì:
6325 if g_Weapon_Danger(FUID
, FObj
.X
+PLAYER_RECT
.X
, FObj
.Y
+PLAYER_RECT
.Y
,
6326 PLAYER_RECT
.Width
, PLAYER_RECT
.Height
,
6327 40+GetInterval(FDifficult
.Cover
, 40)) then
6328 SetAIFlag('NEEDJUMP', '1');
6330 // Åñëè êîí÷èëèñü ïàòîðíû, òî íóæíî ñìåíèòü îðóæèå:
6331 ammo
:= GetAmmoByWeapon(FCurrWeap
);
6332 if ((FCurrWeap
= WEAPON_SHOTGUN2
) and (ammo
< 2)) or
6333 ((FCurrWeap
= WEAPON_BFG
) and (ammo
< 40)) or
6335 SetAIFlag('SELECTWEAPON', '1');
6337 // Åñëè íóæíî ñìåíèòü îðóæèå, òî âûáèðàåì íóæíîå:
6338 if GetAIFlag('SELECTWEAPON') = '1' then
6341 RemoveAIFlag('SELECTWEAPON');
6345 procedure TBot
.Update();
6358 // Ïðîâåðÿåì, îòêëþ÷¸í ëè AI áîòîâ
6359 if (g_debug_BotAIOff
= 1) and (Team
= TEAM_RED
) then
6361 if (g_debug_BotAIOff
= 2) and (Team
= TEAM_BLUE
) then
6363 if g_debug_BotAIOff
= 3 then
6376 procedure TBot
.ReleaseKey(Key
: Byte);
6385 function TBot
.KeyPressed(Key
: Word): Boolean;
6387 Result
:= FKeys
[Key
].Pressed
;
6390 function TBot
.GetAIFlag(fName
: String20
): String20
;
6396 fName
:= LowerCase(fName
);
6398 if FAIFlags
<> nil then
6399 for a
:= 0 to High(FAIFlags
) do
6400 if LowerCase(FAIFlags
[a
].Name
) = fName
then
6402 Result
:= FAIFlags
[a
].Value
;
6407 procedure TBot
.RemoveAIFlag(fName
: String20
);
6411 if FAIFlags
= nil then Exit
;
6413 fName
:= LowerCase(fName
);
6415 for a
:= 0 to High(FAIFlags
) do
6416 if LowerCase(FAIFlags
[a
].Name
) = fName
then
6418 if a
<> High(FAIFlags
) then
6419 for b
:= a
to High(FAIFlags
)-1 do
6420 FAIFlags
[b
] := FAIFlags
[b
+1];
6422 SetLength(FAIFlags
, Length(FAIFlags
)-1);
6427 procedure TBot
.SetAIFlag(fName
, fValue
: String20
);
6435 fName
:= LowerCase(fName
);
6437 if FAIFlags
<> nil then
6438 for a
:= 0 to High(FAIFlags
) do
6439 if LowerCase(FAIFlags
[a
].Name
) = fName
then
6445 if ok
then FAIFlags
[a
].Value
:= fValue
6448 SetLength(FAIFlags
, Length(FAIFlags
)+1);
6449 with FAIFlags
[High(FAIFlags
)] do
6457 procedure TBot
.UpdateMove
;
6459 procedure GoLeft(Time
: Word = 1);
6461 ReleaseKey(KEY_LEFT
);
6462 ReleaseKey(KEY_RIGHT
);
6463 PressKey(KEY_LEFT
, Time
);
6464 SetDirection(D_LEFT
);
6467 procedure GoRight(Time
: Word = 1);
6469 ReleaseKey(KEY_LEFT
);
6470 ReleaseKey(KEY_RIGHT
);
6471 PressKey(KEY_RIGHT
, Time
);
6472 SetDirection(D_RIGHT
);
6475 function Rnd(a
: Word): Boolean;
6477 Result
:= Random(a
) = 0;
6480 procedure Turn(Time
: Word = 1200);
6482 if RunDirection() = D_LEFT
then GoRight(Time
) else GoLeft(Time
);
6487 ReleaseKey(KEY_LEFT
);
6488 ReleaseKey(KEY_RIGHT
);
6491 function CanRunLeft(): Boolean;
6493 Result
:= not CollideLevel(-1, 0);
6496 function CanRunRight(): Boolean;
6498 Result
:= not CollideLevel(1, 0);
6501 function CanRun(): Boolean;
6503 if RunDirection() = D_LEFT
then Result
:= CanRunLeft() else Result
:= CanRunRight();
6506 procedure Jump(Time
: Word = 30);
6508 PressKey(KEY_JUMP
, Time
);
6511 function NearHole(): Boolean;
6515 { TODO 5 : Ëåñòíèöû }
6516 sx
:= IfThen(RunDirection() = D_LEFT
, -1, 1);
6517 for x
:= 1 to PLAYER_RECT
.Width
do
6518 if (not StayOnStep(x
*sx
, 0)) and
6519 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
)) and
6520 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
*2)) then
6529 function BorderHole(): Boolean;
6533 { TODO 5 : Ëåñòíèöû }
6534 sx
:= IfThen(RunDirection() = D_LEFT
, -1, 1);
6535 for x
:= 1 to PLAYER_RECT
.Width
do
6536 if (not StayOnStep(x
*sx
, 0)) and
6537 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
)) and
6538 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
*2)) then
6540 for xx
:= x
to x
+32 do
6541 if CollideLevel(xx
*sx
, PLAYER_RECT
.Height
) then
6551 function NearDeepHole(): Boolean;
6557 sx
:= IfThen(RunDirection() = D_LEFT
, -1, 1);
6560 for x
:= 1 to PLAYER_RECT
.Width
do
6561 if (not StayOnStep(x
*sx
, 0)) and
6562 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
)) and
6563 (not CollideLevel(x
*sx
, PLAYER_RECT
.Height
*2)) then
6565 while FObj
.Y
+y
*PLAYER_RECT
.Height
< gMapInfo
.Height
do
6567 if CollideLevel(x
*sx
, PLAYER_RECT
.Height
*y
) then Exit
;
6572 end else Result
:= False;
6575 function OverDeepHole(): Boolean;
6582 while FObj
.Y
+y
*PLAYER_RECT
.Height
< gMapInfo
.Height
do
6584 if CollideLevel(0, PLAYER_RECT
.Height
*y
) then Exit
;
6591 function OnGround(): Boolean;
6593 Result
:= StayOnStep(0, 0) or CollideLevel(0, 1);
6596 function OnLadder(): Boolean;
6598 Result
:= FullInStep(0, 0);
6601 function BelowLadder(): Boolean;
6603 Result
:= (FullInStep(IfThen(RunDirection() = D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -PLAYER_RECT
.Height
) and
6604 not CollideLevel(IfThen(RunDirection() = D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -PLAYER_RECT
.Height
)) or
6605 (FullInStep(IfThen(RunDirection() = D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -BOT_MAXJUMP
) and
6606 not CollideLevel(IfThen(RunDirection() = D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -BOT_MAXJUMP
));
6609 function BelowLiftUp(): Boolean;
6611 Result
:= ((FullInLift(IfThen(RunDirection() = D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -PLAYER_RECT
.Height
) = -1) and
6612 not CollideLevel(IfThen(RunDirection() = D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -PLAYER_RECT
.Height
)) or
6613 ((FullInLift(IfThen(RunDirection() = D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -BOT_MAXJUMP
) = -1) and
6614 not CollideLevel(IfThen(RunDirection() = D_LEFT
, -1, 1)*(PLAYER_RECT
.Width
div 2), -BOT_MAXJUMP
));
6617 function OnTopLift(): Boolean;
6619 Result
:= (FullInLift(0, 0) = -1) and (FullInLift(0, -32) = 0);
6622 function CanJumpOver(): Boolean;
6626 sx
:= IfThen(RunDirection() = D_LEFT
, -1, 1);
6630 if not CollideLevel(sx
, 0) then Exit
;
6632 for y
:= 1 to BOT_MAXJUMP
do
6633 if CollideLevel(0, -y
) then Exit
else
6634 if not CollideLevel(sx
, -y
) then
6641 function CanJumpUp(Dist
: ShortInt): Boolean;
6648 if CollideLevel(Dist
, 0) then Exit
;
6651 for y
:= 0 to BOT_MAXJUMP
do
6652 if CollideLevel(Dist
, -y
) then
6661 for yy
:= y
+1 to BOT_MAXJUMP
do
6662 if not CollideLevel(Dist
, -yy
) then
6671 for y
:= 0 to BOT_MAXJUMP
do
6672 if CollideLevel(0, -y
) then
6680 if y
< yy
then Exit
;
6685 function IsSafeTrigger(): Boolean;
6690 if gTriggers
= nil then
6692 for a
:= 0 to High(gTriggers
) do
6693 if Collide(gTriggers
[a
].X
,
6696 gTriggers
[a
].Height
) and
6697 (gTriggers
[a
].TriggerType
in [TRIGGER_EXIT
, TRIGGER_CLOSEDOOR
,
6698 TRIGGER_CLOSETRAP
, TRIGGER_TRAP
,
6699 TRIGGER_PRESS
, TRIGGER_ON
, TRIGGER_OFF
,
6700 TRIGGER_ONOFF
, TRIGGER_SPAWNMONSTER
,
6701 TRIGGER_DAMAGE
, TRIGGER_SHOT
]) then
6706 // Âîçìîæíî, íàæèìàåì êíîïêó:
6707 if Rnd(16) and IsSafeTrigger() then
6710 // Åñëè ïîä ëèôòîì èëè ñòóïåíüêàìè, òî, âîçìîæíî, ïðûãàåì:
6711 if OnLadder() or ((BelowLadder() or BelowLiftUp()) and Rnd(8)) then
6713 ReleaseKey(KEY_LEFT
);
6714 ReleaseKey(KEY_RIGHT
);
6718 // Èäåì âëåâî, åñëè íàäî áûëî:
6719 if GetAIFlag('GOLEFT') <> '' then
6721 RemoveAIFlag('GOLEFT');
6722 if CanRunLeft() then
6726 // Èäåì âïðàâî, åñëè íàäî áûëî:
6727 if GetAIFlag('GORIGHT') <> '' then
6729 RemoveAIFlag('GORIGHT');
6730 if CanRunRight() then
6734 // Åñëè âûëåòåëè çà êàðòó, òî ïðîáóåì âåðíóòüñÿ:
6735 if FObj
.X
< -32 then
6738 if FObj
.X
+32 > gMapInfo
.Width
then
6741 // Ïðûãàåì, åñëè íàäî áûëî:
6742 if GetAIFlag('NEEDJUMP') <> '' then
6745 RemoveAIFlag('NEEDJUMP');
6748 // Ñìîòðèì ââåðõ, åñëè íàäî áûëî:
6749 if GetAIFlag('NEEDSEEUP') <> '' then
6752 ReleaseKey(KEY_DOWN
);
6753 PressKey(KEY_UP
, 20);
6754 RemoveAIFlag('NEEDSEEUP');
6757 // Ñìîòðèì âíèç, åñëè íàäî áûëî:
6758 if GetAIFlag('NEEDSEEDOWN') <> '' then
6761 ReleaseKey(KEY_DOWN
);
6762 PressKey(KEY_DOWN
, 20);
6763 RemoveAIFlag('NEEDSEEDOWN');
6766 // Åñëè íóæíî áûëî â äûðó è ìû íå íà çåìëå, òî ïîêîðíî ëåòèì:
6767 if GetAIFlag('GOINHOLE') <> '' then
6768 if not OnGround() then
6770 ReleaseKey(KEY_LEFT
);
6771 ReleaseKey(KEY_RIGHT
);
6772 RemoveAIFlag('GOINHOLE');
6773 SetAIFlag('FALLINHOLE', '1');
6776 // Åñëè ïàäàëè è äîñòèãëè çåìëè, òî õâàòèò ïàäàòü:
6777 if GetAIFlag('FALLINHOLE') <> '' then
6779 RemoveAIFlag('FALLINHOLE');
6781 // Åñëè ëåòåëè ïðÿìî è ñåé÷àñ íå íà ëåñòíèöå èëè íà âåðøèíå ëèôòà, òî îòõîäèì â ñòîðîíó:
6782 if not (KeyPressed(KEY_LEFT
) or KeyPressed(KEY_RIGHT
)) then
6783 if GetAIFlag('FALLINHOLE') = '' then
6784 if (not OnLadder()) or (FObj
.Vel
.Y
>= 0) or (OnTopLift()) then
6790 // Åñëè íà çåìëå è ìîæíî ïîäïðûãíóòü, òî, âîçìîæíî, ïðûãàåì:
6792 CanJumpUp(IfThen(RunDirection() = D_LEFT
, -1, 1)*32) and
6796 // Åñëè íà çåìëå è âîçëå äûðû (ãëóáèíà > 2 ðîñòîâ èãðîêà):
6797 if OnGround() and NearHole() then
6798 if NearDeepHole() then // Åñëè ýòî áåçäíà
6800 0..3: Turn(); // Áåæèì îáðàòíî
6801 4: Jump(); // Ïðûãàåì
6802 5: begin // Ïðûãàåì îáðàòíî
6807 else // Ýòî íå áåçäíà è ìû åùå íå ëåòèì òóäà
6808 if GetAIFlag('GOINHOLE') = '' then
6810 0: Turn(); // Íå íóæíî òóäà
6811 1: Jump(); // Âäðóã ïîâåçåò - ïðûãàåì
6812 else // Åñëè ÿìà ñ ãðàíèöåé, òî ïðè ñëó÷àå ìîæíî òóäà ïðûãíóòü
6813 if BorderHole() then
6814 SetAIFlag('GOINHOLE', '1');
6817 // Åñëè íà çåìëå, íî íåêóäà èäòè:
6818 if (not CanRun()) and OnGround() then
6820 // Åñëè ìû íà ëåñòíèöå èëè ìîæíî ïåðåïðûãíóòü, òî ïðûãàåì:
6821 if CanJumpOver() or OnLadder() then
6823 else // èíà÷å ïîïûòàåìñÿ â äðóãóþ ñòîðîíó
6824 if Random(2) = 0 then
6826 if IsSafeTrigger() then
6832 // Îñòàëîñü ìàëî âîçäóõà:
6833 if FAir
< 36 * 2 then
6836 // Âûáèðàåìñÿ èç êèñëîòû, åñëè íåò êîñòþìà, îáîæãëèñü, èëè ìàëî çäîðîâüÿ:
6837 if (FMegaRulez
[MR_SUIT
] < gTime
) and ((FLastHit
= HIT_ACID
) or (Healthy() <= 1)) then
6838 if BodyInAcid(0, 0) then
6842 function TBot
.FullInStep(XInc
, YInc
: Integer): Boolean;
6844 Result
:= g_Map_CollidePanel(FObj
.X
+PLAYER_RECT
.X
+XInc
, FObj
.Y
+PLAYER_RECT
.Y
+YInc
,
6845 PLAYER_RECT
.Width
, PLAYER_RECT
.Height
, PANEL_STEP
, False);
6848 {function TBot.NeedItem(Item: Byte): Byte;
6853 procedure TBot
.SelectWeapon(Dist
: Integer);
6857 function HaveAmmo(weapon
: Byte): Boolean;
6860 WEAPON_PISTOL
: Result
:= FAmmo
[A_BULLETS
] >= 1;
6861 WEAPON_SHOTGUN1
: Result
:= FAmmo
[A_SHELLS
] >= 1;
6862 WEAPON_SHOTGUN2
: Result
:= FAmmo
[A_SHELLS
] >= 2;
6863 WEAPON_CHAINGUN
: Result
:= FAmmo
[A_BULLETS
] >= 10;
6864 WEAPON_ROCKETLAUNCHER
: Result
:= FAmmo
[A_ROCKETS
] >= 1;
6865 WEAPON_PLASMA
: Result
:= FAmmo
[A_CELLS
] >= 10;
6866 WEAPON_BFG
: Result
:= FAmmo
[A_CELLS
] >= 40;
6867 WEAPON_SUPERPULEMET
: Result
:= FAmmo
[A_SHELLS
] >= 1;
6868 else Result
:= True;
6873 if Dist
= -1 then Dist
:= BOT_LONGDIST
;
6875 if Dist
> BOT_LONGDIST
then
6876 begin // Äàëüíèé áîé
6878 if FWeapon
[FDifficult
.WeaponPrior
[a
]] and HaveAmmo(FDifficult
.WeaponPrior
[a
]) then
6880 FSelectedWeapon
:= FDifficult
.WeaponPrior
[a
];
6884 else //if Dist > BOT_UNSAFEDIST then
6885 begin // Áëèæíèé áîé
6887 if FWeapon
[FDifficult
.CloseWeaponPrior
[a
]] and HaveAmmo(FDifficult
.CloseWeaponPrior
[a
]) then
6889 FSelectedWeapon
:= FDifficult
.CloseWeaponPrior
[a
];
6896 if FWeapon[FDifficult.SafeWeaponPrior[a]] and HaveAmmo(FDifficult.SafeWeaponPrior[a]) then
6898 FSelectedWeapon := FDifficult.SafeWeaponPrior[a];
6904 function TBot
.PickItem(ItemType
: Byte; force
: Boolean; var remove
: Boolean): Boolean;
6906 Result
:= inherited PickItem(ItemType
, force
, remove
);
6908 if Result
then SetAIFlag('SELECTWEAPON', '1');
6911 function TBot
.Heal(value
: Word; Soft
: Boolean): Boolean;
6913 Result
:= inherited Heal(value
, Soft
);
6916 function TBot
.Healthy(): Byte;
6918 if FMegaRulez
[MR_INVUL
] >= gTime
then Result
:= 3
6919 else if (FHealth
> 80) or ((FHealth
> 50) and (FArmor
> 20)) then Result
:= 3
6920 else if (FHealth
> 50) then Result
:= 2
6921 else if (FHealth
> 20) then Result
:= 1
6925 function TBot
.TargetOnScreen(TX
, TY
: Integer): Boolean;
6927 Result
:= (Abs(FObj
.X
-TX
) <= Trunc(gPlayerScreenSize
.X
*0.6)) and
6928 (Abs(FObj
.Y
-TY
) <= Trunc(gPlayerScreenSize
.Y
*0.6));
6931 procedure TBot
.OnDamage(Angle
: SmallInt);
6939 if (Angle
= 0) or (Angle
= 180) then
6942 if (g_GetUIDType(FLastSpawnerUID
) = UID_PLAYER
) and
6943 LongBool(gGameSettings
.Options
and GAME_OPTION_BOTVSPLAYER
) then
6945 pla
:= g_Player_Get(FLastSpawnerUID
);
6946 ok
:= not TargetOnScreen(pla
.FObj
.X
+ PLAYER_RECT
.X
,
6947 pla
.FObj
.Y
+ PLAYER_RECT
.Y
);
6950 if (g_GetUIDType(FLastSpawnerUID
) = UID_MONSTER
) and
6951 LongBool(gGameSettings
.Options
and GAME_OPTION_BOTVSMONSTER
) then
6953 mon
:= g_Monsters_Get(FLastSpawnerUID
);
6954 ok
:= not TargetOnScreen(mon
.Obj
.X
+ mon
.Obj
.Rect
.X
,
6955 mon
.Obj
.Y
+ mon
.Obj
.Rect
.Y
);
6960 SetAIFlag('ATTACKLEFT', '1')
6962 SetAIFlag('ATTACKRIGHT', '1');
6966 function TBot
.RunDirection(): TDirection
;
6968 if Abs(Vel
.X
) >= 1 then
6970 if Vel
.X
> 0 then Result
:= D_RIGHT
else Result
:= D_LEFT
;
6972 Result
:= FDirection
;
6975 function TBot
.GetRnd(a
: Byte): Boolean;
6977 if a
= 0 then Result
:= False
6978 else if a
= 255 then Result
:= True
6979 else Result
:= Random(256) > 255-a
;
6982 function TBot
.GetInterval(a
: Byte; radius
: SmallInt): SmallInt;
6984 Result
:= Round((255-a
)/255*radius
*(Random(2)-1));
6987 procedure TBot
.SaveState(var Mem
: TBinMemoryWriter
);
6993 inherited SaveState(Mem
);
6995 // Âûáðàííîå îðóæèå:
6996 Mem
.WriteByte(FSelectedWeapon
);
6998 Mem
.WriteWord(FTargetUID
);
6999 // Âðåìÿ ïîòåðè öåëè:
7000 Mem
.WriteDWORD(FLastVisible
);
7001 // Êîëè÷åñòâî ôëàãîâ ÈÈ:
7002 dw
:= Length(FAIFlags
);
7005 for i
:= 0 to Integer(dw
)-1 do
7007 Mem
.WriteString(FAIFlags
[i
].Name
, 20);
7008 Mem
.WriteString(FAIFlags
[i
].Value
, 20);
7010 // Íàñòðîéêè ñëîæíîñòè:
7012 Mem
.WriteMemory(p
, SizeOf(TDifficult
));
7015 procedure TBot
.LoadState(var Mem
: TBinMemoryReader
);
7021 inherited LoadState(Mem
);
7023 // Âûáðàííîå îðóæèå:
7024 Mem
.ReadByte(FSelectedWeapon
);
7026 Mem
.ReadWord(FTargetUID
);
7027 // Âðåìÿ ïîòåðè öåëè:
7028 Mem
.ReadDWORD(FLastVisible
);
7029 // Êîëè÷åñòâî ôëàãîâ ÈÈ:
7031 SetLength(FAIFlags
, dw
);
7033 for i
:= 0 to Integer(dw
)-1 do
7035 Mem
.ReadString(FAIFlags
[i
].Name
);
7036 Mem
.ReadString(FAIFlags
[i
].Value
);
7038 // Íàñòðîéêè ñëîæíîñòè:
7039 Mem
.ReadMemory(p
, dw
);
7040 if dw
<> SizeOf(TDifficult
) then
7042 raise EBinSizeError
.Create('TBot.LoadState: Wrong FDifficult Size');
7044 FDifficult
:= TDifficult(p
^);