diff --git a/src/game/g_player.pas b/src/game/g_player.pas
index da7e6d2eea8f7a52fac7bb5dcdc366e3e20e50d9..ea2aea5d3dba7f8568d18fa7f17e894a745dc984 100644 (file)
--- a/src/game/g_player.pas
+++ b/src/game/g_player.pas
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
+ * the Free Software Foundation, version 3 of the License ONLY.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
uses
SysUtils, Classes,
{$IFDEF USE_MEMPOOL}mempool,{$ENDIF}
uses
SysUtils, Classes,
{$IFDEF USE_MEMPOOL}mempool,{$ENDIF}
- e_graphics, g_playermodel, g_basic, g_textures,
+ g_base, g_playermodel, g_basic, g_textures,
g_weapons, g_phys, g_sound, g_saveload, MAPDEF,
g_panel;
g_weapons, g_phys, g_sound, g_saveload, MAPDEF,
g_panel;
KEY_UP = 3;
KEY_DOWN = 4;
KEY_FIRE = 5;
KEY_UP = 3;
KEY_DOWN = 4;
KEY_FIRE = 5;
- KEY_NEXTWEAPON = 6;
- KEY_PREVWEAPON = 7;
- KEY_OPEN = 8;
- KEY_JUMP = 9;
- KEY_CHAT = 10;
+ KEY_OPEN = 6;
+ KEY_JUMP = 7;
+ KEY_CHAT = 8;
+
+ WP_PREV = 0;
+ WP_NEXT = 1;
+ WP_FACT = WP_PREV;
+ WP_LACT = WP_NEXT;
R_ITEM_BACKPACK = 0;
R_KEY_RED = 1;
R_ITEM_BACKPACK = 0;
R_KEY_RED = 1;
TEAM_BLUE = 2;
TEAM_COOP = 3;
TEAM_BLUE = 2;
TEAM_COOP = 3;
- SHELL_BULLET = 0;
- SHELL_SHELL = 1;
- SHELL_DBLSHELL = 2;
-
ANGLE_NONE = Low(SmallInt);
ANGLE_NONE = Low(SmallInt);
- CORPSE_STATE_REMOVEME = 0;
- CORPSE_STATE_NORMAL = 1;
- CORPSE_STATE_MESS = 2;
-
PLAYER_RECT: TRectWH = (X:15; Y:12; Width:34; Height:52);
PLAYER_RECT_CX = 15+(34 div 2);
PLAYER_RECT_CY = 12+(52 div 2);
PLAYER_RECT: TRectWH = (X:15; Y:12; Width:34; Height:52);
PLAYER_RECT_CX = 15+(34 div 2);
PLAYER_RECT_CY = 12+(52 div 2);
- PLAYER_CORPSERECT: TRectWH = (X:15; Y:48; Width:34; Height:16);
PLAYER_HP_SOFT = 100;
PLAYER_HP_LIMIT = 200;
PLAYER_AP_SOFT = 100;
PLAYER_AP_LIMIT = 200;
SUICIDE_DAMAGE = 112;
PLAYER_HP_SOFT = 100;
PLAYER_HP_LIMIT = 200;
PLAYER_AP_SOFT = 100;
PLAYER_AP_LIMIT = 200;
SUICIDE_DAMAGE = 112;
+ WEAPON_DELAY = 5;
+
+ PLAYER_BURN_TIME = 110;
PLAYER1_DEF_COLOR: TRGB = (R:64; G:175; B:48);
PLAYER2_DEF_COLOR: TRGB = (R:96; G:96; B:96);
PLAYER1_DEF_COLOR: TRGB = (R:64; G:175; B:48);
PLAYER2_DEF_COLOR: TRGB = (R:96; G:96; B:96);
+ AIR_DEF = 360;
+ AIR_MAX = 1091;
+ JET_MAX = 540; // ~30 sec
+ ANGLE_RIGHTUP = 55;
+ ANGLE_RIGHTDOWN = -35;
+ ANGLE_LEFTUP = 125;
+ ANGLE_LEFTDOWN = -145;
+ WEAPONPOINT: Array [TDirection] of TDFPoint = ((X:16; Y:32), (X:47; Y:32));
+ TEAMCOLOR: Array [TEAM_RED..TEAM_BLUE] of TRGB = ((R:255; G:0; B:0),
+ (R:0; G:0; B:255));
+
type
TPlayerStat = record
type
TPlayerStat = record
+ Num: Integer;
Ping: Word;
Loss: Byte;
Name: String;
Ping: Word;
Loss: Byte;
Name: String;
Kills: Word;
Color: TRGB;
Spectator: Boolean;
Kills: Word;
Color: TRGB;
Spectator: Boolean;
+ UID: Word;
end;
TPlayerStatArray = Array of TPlayerStat;
end;
TPlayerStatArray = Array of TPlayerStat;
MaxAmmo: Array [A_BULLETS..A_HIGH] of Word;
Weapon: Array [WP_FIRST..WP_LAST] of Boolean;
Rulez: Set of R_ITEM_BACKPACK..R_BERSERK;
MaxAmmo: Array [A_BULLETS..A_HIGH] of Word;
Weapon: Array [WP_FIRST..WP_LAST] of Boolean;
Rulez: Set of R_ITEM_BACKPACK..R_BERSERK;
- WaitRecall: Boolean;
+ Used: Boolean;
end;
TKeyState = record
end;
TKeyState = record
FFirePainTime: Integer;
FFireAttacker: Word;
FFirePainTime: Integer;
FFireAttacker: Word;
- FSavedState: TPlayerSavedState;
+ FSavedStateNum: Integer;
FModel: TPlayerModel;
FModel: TPlayerModel;
- FPunchAnim: TAnimation;
+ FPunchAnim: TAnimationState;
FActionPrior: Byte;
FActionAnim: Byte;
FActionForce: Boolean;
FActionChanged: Boolean;
FAngle: SmallInt;
FFireAngle: SmallInt;
FActionPrior: Byte;
FActionAnim: Byte;
FActionForce: Boolean;
FActionChanged: Boolean;
FAngle: SmallInt;
FFireAngle: SmallInt;
+ FIncCamOld: Integer;
FIncCam: Integer;
FIncCam: Integer;
- FShellTimer: Integer;
- FShellType: Byte;
+ FSlopeOld: Integer;
+ {$IFDEF ENABLE_SHELLS}
+ FShellTimer: Integer;
+ FShellType: Byte;
+ {$ENDIF}
FSawSound: TPlayableSound;
FSawSoundIdle: TPlayableSound;
FSawSoundHit: TPlayableSound;
FSawSoundSelect: TPlayableSound;
FSawSound: TPlayableSound;
FSawSoundIdle: TPlayableSound;
FSawSoundHit: TPlayableSound;
FSawSoundSelect: TPlayableSound;
+ FFlameSoundOn: TPlayableSound;
+ FFlameSoundOff: TPlayableSound;
+ FFlameSoundWork: TPlayableSound;
FJetSoundOn: TPlayableSound;
FJetSoundOff: TPlayableSound;
FJetSoundFly: TPlayableSound;
FJetSoundOn: TPlayableSound;
FJetSoundOff: TPlayableSound;
FJetSoundFly: TPlayableSound;
{procedure CollideItem();}
procedure FlySmoke(Times: DWORD = 1);
procedure OnFireFlame(Times: DWORD = 1);
{procedure CollideItem();}
procedure FlySmoke(Times: DWORD = 1);
procedure OnFireFlame(Times: DWORD = 1);
- function GetAmmoByWeapon(Weapon: Byte): Word;
procedure SetAction(Action: Byte; Force: Boolean = False);
procedure OnDamage(Angle: SmallInt); virtual;
function firediry(): Integer;
procedure SetAction(Action: Byte; Force: Boolean = False);
procedure OnDamage(Angle: SmallInt); virtual;
function firediry(): Integer;
function getNextWeaponIndex (): Byte; // return 255 for "no switch"
procedure resetWeaponQueue ();
function hasAmmoForWeapon (weapon: Byte): Boolean;
function getNextWeaponIndex (): Byte; // return 255 for "no switch"
procedure resetWeaponQueue ();
function hasAmmoForWeapon (weapon: Byte): Boolean;
+ function hasAmmoForShooting (weapon: Byte): Boolean;
+ function shouldSwitch (weapon: Byte; hadWeapon: Boolean) : Boolean;
procedure doDamage (v: Integer);
procedure doDamage (v: Integer);
- function followCorpse(): Boolean;
-
public
FDamageBuffer: Integer;
public
FDamageBuffer: Integer;
FReloading: Array [WP_FIRST..WP_LAST] of Word;
FTime: Array [T_RESPAWN..T_FLAGCAP] of DWORD;
FKeys: Array [KEY_LEFT..KEY_CHAT] of TKeyState;
FReloading: Array [WP_FIRST..WP_LAST] of Word;
FTime: Array [T_RESPAWN..T_FLAGCAP] of DWORD;
FKeys: Array [KEY_LEFT..KEY_CHAT] of TKeyState;
+ FWeapSwitchMode: Byte;
+ FWeapPreferences: Array [WP_FIRST .. WP_LAST+1] of Byte;
+ FSwitchToEmpty: Byte;
+ FSkipFist: Byte;
FColor: TRGB;
FPreferredTeam: Byte;
FSpectator: Boolean;
FColor: TRGB;
FPreferredTeam: Byte;
FSpectator: Boolean;
FWantsInGame: Boolean;
FGhost: Boolean;
FPhysics: Boolean;
FWantsInGame: Boolean;
FGhost: Boolean;
FPhysics: Boolean;
+ FFlaming: Boolean;
FJetpack: Boolean;
FActualModelName: string;
FClientID: SmallInt;
FPing: Word;
FLoss: Byte;
FJetpack: Boolean;
FActualModelName: string;
FClientID: SmallInt;
FPing: Word;
FLoss: Byte;
+ FReady: Boolean;
FDummy: Boolean;
FFireTime: Integer;
FDummy: Boolean;
FFireTime: Integer;
+ FSpawnInvul: Integer;
+ FHandicap: Integer;
+ FWaitForFirstSpawn: Boolean; // set to `true` in server, used to spawn a player on first full state request
+
+ {$IFDEF ENABLE_CORPSES}
+ FCorpse: Integer;
+ {$ENDIF}
// debug: viewport offset
viewPortX, viewPortY, viewPortW, viewPortH: Integer;
// debug: viewport offset
viewPortX, viewPortY, viewPortW, viewPortH: Integer;
procedure ReleaseKeys();
procedure SetModel(ModelName: String);
procedure SetColor(Color: TRGB);
procedure ReleaseKeys();
procedure SetModel(ModelName: String);
procedure SetColor(Color: TRGB);
+ function GetColor(): TRGB;
procedure SetWeapon(W: Byte);
function IsKeyPressed(K: Byte): Boolean;
function GetKeys(): Byte;
function PickItem(ItemType: Byte; arespawn: Boolean; var remove: Boolean): Boolean; virtual;
procedure SetWeapon(W: Byte);
function IsKeyPressed(K: Byte): Boolean;
function GetKeys(): Byte;
function PickItem(ItemType: Byte; arespawn: Boolean; var remove: Boolean): Boolean; virtual;
+ procedure SetWeaponPrefs(Prefs: Array of Byte);
+ procedure SetWeaponPref(Weapon, Pref: Byte);
+ function GetWeaponPref(Weapon: Byte) : Byte;
+ function GetMorePrefered() : Byte;
+ function MaySwitch(Weapon: Byte) : Boolean;
function Collide(X, Y: Integer; Width, Height: Word): Boolean; overload;
function Collide(Panel: TPanel): Boolean; overload;
function Collide(X, Y: Integer): Boolean; overload;
function Collide(X, Y: Integer; Width, Height: Word): Boolean; overload;
function Collide(Panel: TPanel): Boolean; overload;
function Collide(X, Y: Integer): Boolean; overload;
procedure BFGHit();
function GetFlag(Flag: Byte): Boolean;
procedure SetFlag(Flag: Byte);
procedure BFGHit();
function GetFlag(Flag: Byte): Boolean;
procedure SetFlag(Flag: Byte);
- function DropFlag(): Boolean;
+ function DropFlag(Silent: Boolean = True; DoThrow: Boolean = False): Boolean;
+ function TryDropFlag(): Boolean;
procedure AllRulez(Health: Boolean);
procedure RestoreHealthArmor();
procedure FragCombo();
procedure AllRulez(Health: Boolean);
procedure RestoreHealthArmor();
procedure FragCombo();
procedure Spectate(NoMove: Boolean = False);
procedure SwitchNoClip;
procedure SoftReset();
procedure Spectate(NoMove: Boolean = False);
procedure SwitchNoClip;
procedure SoftReset();
- procedure Draw(); virtual;
- procedure DrawPain();
- procedure DrawPickup();
- procedure DrawRulez();
- procedure DrawAim();
- procedure DrawBubble();
- procedure DrawGUI();
+ procedure PreUpdate();
procedure Update(); virtual;
procedure RememberState();
procedure RecallState();
procedure Update(); virtual;
procedure RememberState();
procedure RecallState();
procedure NetFire(Wpn: Byte; X, Y, AX, AY: Integer; WID: Integer = -1);
procedure DoLerp(Level: Integer = 2);
procedure SetLerp(XTo, YTo: Integer);
procedure NetFire(Wpn: Byte; X, Y, AX, AY: Integer; WID: Integer = -1);
procedure DoLerp(Level: Integer = 2);
procedure SetLerp(XTo, YTo: Integer);
+ procedure ProcessWeaponAction(Action: Byte);
procedure QueueWeaponSwitch(Weapon: Byte);
procedure RealizeCurrentWeapon();
procedure QueueWeaponSwitch(Weapon: Byte);
procedure RealizeCurrentWeapon();
+ procedure FlamerOn;
+ procedure FlamerOff;
procedure JetpackOn;
procedure JetpackOff;
procedure JetpackOn;
procedure JetpackOff;
- procedure CatchFire(Attacker: Word);
+ procedure CatchFire(Attacker: Word; Timeout: Integer = PLAYER_BURN_TIME);
//WARNING! this does nothing for now, but still call it!
procedure positionChanged (); //WARNING! call this after entity position was changed, or coldet will not work right!
//WARNING! this does nothing for now, but still call it!
procedure positionChanged (); //WARNING! call this after entity position was changed, or coldet will not work right!
procedure getMapBox (out x, y, w, h: Integer); inline;
procedure moveBy (dx, dy: Integer); inline;
procedure getMapBox (out x, y, w, h: Integer); inline;
procedure moveBy (dx, dy: Integer); inline;
+ function GetAmmoByWeapon(Weapon: Byte): Word; // private state
+
public
property Vel: TPoint2i read FObj.Vel;
property Obj: TObj read FObj;
public
property Vel: TPoint2i read FObj.Vel;
property Obj: TObj read FObj;
property Death: Integer read FDeath write FDeath;
property Kills: Integer read FKills write FKills;
property CurrWeap: Byte read FCurrWeap write FCurrWeap;
property Death: Integer read FDeath write FDeath;
property Kills: Integer read FKills write FKills;
property CurrWeap: Byte read FCurrWeap write FCurrWeap;
+ property WeapSwitchMode: Byte read FWeapSwitchMode write FWeapSwitchMode;
+ property SwitchToEmpty: Byte read FSwitchToEmpty write FSwitchToEmpty;
+ property SkipFist: Byte read FSkipFist write FSkipFist;
property MonsterKills: Integer read FMonsterKills write FMonsterKills;
property Secrets: Integer read FSecrets;
property GodMode: Boolean read FGodMode write FGodMode;
property MonsterKills: Integer read FMonsterKills write FMonsterKills;
property Secrets: Integer read FSecrets;
property GodMode: Boolean read FGodMode write FGodMode;
property GameAccelX: Integer read FObj.Accel.X write FObj.Accel.X;
property GameAccelY: Integer read FObj.Accel.Y write FObj.Accel.Y;
property IncCam: Integer read FIncCam write FIncCam;
property GameAccelX: Integer read FObj.Accel.X write FObj.Accel.X;
property GameAccelY: Integer read FObj.Accel.Y write FObj.Accel.Y;
property IncCam: Integer read FIncCam write FIncCam;
+ property IncCamOld: Integer read FIncCamOld write FIncCamOld;
+ property SlopeOld: Integer read FSlopeOld write FSlopeOld;
property UID: Word read FUID write FUID;
property JustTeleported: Boolean read FJustTeleported write FJustTeleported;
property NetTime: LongWord read FNetTime write FNetTime;
property UID: Word read FUID write FUID;
property JustTeleported: Boolean read FJustTeleported write FJustTeleported;
property NetTime: LongWord read FNetTime write FNetTime;
+ (* internal state *)
+ property Angle_: SmallInt read FAngle;
+ property Spectator: Boolean read FSpectator;
+ property NoRespawn: Boolean read FNoRespawn;
+ property Berserk: Integer read FBerserk;
+ property Pain: Integer read FPain;
+ property Pickup: Integer read FPickup;
+ property PunchAnim: TAnimationState read FPunchAnim write FPunchAnim;
+ property SpawnInvul: Integer read FSpawnInvul;
+ property Ghost: Boolean read FGhost;
+
published
property eName: String read FName write FName;
property eHealth: Integer read FHealth write FHealth;
published
property eName: String read FName write FName;
property eHealth: Integer read FHealth write FHealth;
// set this before assigning something to `eDamage`
property eDamageType: Integer read mEDamageType write mEDamageType;
property eDamage: Integer write doDamage;
// set this before assigning something to `eDamage`
property eDamageType: Integer read mEDamageType write mEDamageType;
property eDamage: Integer write doDamage;
+
+ {$IFDEF ENABLE_CORPSES}
+ property Corpse: Integer read FCorpse;
+ {$ENDIF}
end;
TDifficult = record
end;
TDifficult = record
procedure Respawn(Silent: Boolean; Force: Boolean = False); override;
constructor Create(); override;
destructor Destroy(); override;
procedure Respawn(Silent: Boolean; Force: Boolean = False); override;
constructor Create(); override;
destructor Destroy(); override;
- procedure Draw(); override;
function PickItem(ItemType: Byte; force: Boolean; var remove: Boolean): Boolean; override;
function Heal(value: Word; Soft: Boolean): Boolean; override;
procedure Update(); override;
function PickItem(ItemType: Byte; force: Boolean; var remove: Boolean): Boolean; override;
function Heal(value: Word; Soft: Boolean): Boolean; override;
procedure Update(); override;
procedure LoadState (st: TStream); override;
end;
procedure LoadState (st: TStream); override;
end;
- PGib = ^TGib;
- TGib = record
- alive: Boolean;
- ID: DWORD;
- MaskID: DWORD;
- RAngle: Integer;
- Color: TRGB;
- Obj: TObj;
-
- procedure getMapBox (out x, y, w, h: Integer); inline;
- procedure moveBy (dx, dy: Integer); inline;
-
- procedure positionChanged (); inline; //WARNING! call this after entity position was changed, or coldet will not work right!
- end;
-
-
- PShell = ^TShell;
- TShell = record
- SpriteID: DWORD;
- alive: Boolean;
- SType: Byte;
- RAngle: Integer;
- Timeout: Cardinal;
- CX, CY: Integer;
- Obj: TObj;
-
- procedure getMapBox (out x, y, w, h: Integer); inline;
- procedure moveBy (dx, dy: Integer); inline;
-
- procedure positionChanged (); inline; //WARNING! call this after entity position was changed, or coldet will not work right!
- end;
-
- TCorpse = class{$IFDEF USE_MEMPOOL}(TPoolObject){$ENDIF}
- private
- FModelName: String;
- FMess: Boolean;
- FState: Byte;
- FDamage: Byte;
- FColor: TRGB;
- FObj: TObj;
- FPlayerUID: Word;
- FAnimation: TAnimation;
- FAnimationMask: TAnimation;
-
- public
- constructor Create(X, Y: Integer; ModelName: String; aMess: Boolean);
- destructor Destroy(); override;
- procedure Damage(Value: Word; vx, vy: Integer);
- procedure Update();
- procedure Draw();
- procedure SaveState (st: TStream);
- procedure LoadState (st: TStream);
-
- procedure getMapBox (out x, y, w, h: Integer); inline;
- procedure moveBy (dx, dy: Integer); inline;
-
- procedure positionChanged (); inline; //WARNING! call this after entity position was changed, or coldet will not work right!
-
- function ObjPtr (): PObj; inline;
-
- property Obj: TObj read FObj; // copies object
- property State: Byte read FState;
- property Mess: Boolean read FMess;
- end;
-
TTeamStat = Array [TEAM_RED..TEAM_BLUE] of
record
TTeamStat = Array [TEAM_RED..TEAM_BLUE] of
record
- Goals: SmallInt;
+ Score: SmallInt;
end;
var
gPlayers: Array of TPlayer;
end;
var
gPlayers: Array of TPlayer;
- gCorpses: Array of TCorpse;
- gGibs: Array of TGib;
- gShells: Array of TShell;
gTeamStat: TTeamStat;
gFly: Boolean = False;
gAimLine: Boolean = False;
gTeamStat: TTeamStat;
gFly: Boolean = False;
gAimLine: Boolean = False;
- gChatBubble: Byte = 0;
+ gChatBubble: Integer = 0;
+ gPlayerIndicator: Integer = 1;
+ gPlayerIndicatorStyle: Integer = 0;
gNumBots: Word = 0;
gNumBots: Word = 0;
- gLMSPID1: Word = 0;
- gLMSPID2: Word = 0;
+ gSpectLatchPID1: Word = 0;
+ gSpectLatchPID2: Word = 0;
MAX_RUNVEL: Integer = 8;
VEL_JUMP: Integer = 10;
MAX_RUNVEL: Integer = 8;
VEL_JUMP: Integer = 10;
- SHELL_TIMEOUT: Cardinal = 60000;
function Lerp(X, Y, Factor: Integer): Integer;
function Lerp(X, Y, Factor: Integer): Integer;
-procedure g_Gibs_SetMax(Count: Word);
-function g_Gibs_GetMax(): Word;
-procedure g_Corpses_SetMax(Count: Word);
-function g_Corpses_GetMax(): Word;
-procedure g_Shells_SetMax(Count: Word);
-function g_Shells_GetMax(): Word;
+procedure g_Force_Model_Set(Mode: Word);
+function g_Force_Model_Get(): Word;
+procedure g_Forced_Model_SetName(Model: String);
+function g_Forced_Model_GetName(): String;
procedure g_Player_Init();
procedure g_Player_Free();
procedure g_Player_Init();
procedure g_Player_Free();
@@ -564,41 +548,49 @@ function g_Player_Create(ModelName: String; Color: TRGB; Team: Byte; Bot: Boole
function g_Player_CreateFromState (st: TStream): Word;
procedure g_Player_Remove(UID: Word);
procedure g_Player_ResetTeams();
function g_Player_CreateFromState (st: TStream): Word;
procedure g_Player_Remove(UID: Word);
procedure g_Player_ResetTeams();
+procedure g_Player_PreUpdate();
procedure g_Player_UpdateAll();
procedure g_Player_UpdateAll();
-procedure g_Player_DrawAll();
-procedure g_Player_DrawDebug(p: TPlayer);
-procedure g_Player_DrawHealth();
procedure g_Player_RememberAll();
procedure g_Player_ResetAll(Force, Silent: Boolean);
function g_Player_Get(UID: Word): TPlayer;
function g_Player_GetCount(): Byte;
function g_Player_GetStats(): TPlayerStatArray;
function g_Player_ValidName(Name: String): Boolean;
procedure g_Player_RememberAll();
procedure g_Player_ResetAll(Force, Silent: Boolean);
function g_Player_Get(UID: Word): TPlayer;
function g_Player_GetCount(): Byte;
function g_Player_GetStats(): TPlayerStatArray;
function g_Player_ValidName(Name: String): Boolean;
-procedure g_Player_CreateCorpse(Player: TPlayer);
-procedure g_Player_CreateGibs(fX, fY: Integer; ModelName: String; fColor: TRGB);
-procedure g_Player_CreateShell(fX, fY, dX, dY: Integer; T: Byte);
-procedure g_Player_UpdatePhysicalObjects();
-procedure g_Player_DrawCorpses();
-procedure g_Player_DrawShells();
-procedure g_Player_RemoveAllCorpses();
-procedure g_Player_Corpses_SaveState (st: TStream);
-procedure g_Player_Corpses_LoadState (st: TStream);
-procedure g_Bot_Add(Team, Difficult: Byte);
-procedure g_Bot_AddList(Team: Byte; lname: ShortString; num: Integer = -1);
+procedure g_Player_ResetReady();
+procedure g_Bot_Add(Team, Difficult: Byte; Handicap: Integer = 100);
+procedure g_Bot_AddList(Team: Byte; lname: ShortString; num: Integer = -1; Handicap: Integer = 100);
procedure g_Bot_MixNames();
procedure g_Bot_RemoveAll();
procedure g_Bot_MixNames();
procedure g_Bot_RemoveAll();
+function g_Bot_GetCount(): Integer;
implementation
uses
implementation
uses
-{$INCLUDE ../nogl/noGLuses.inc}
-{$IFDEF ENABLE_HOLMES}
- g_holmes,
-{$ENDIF}
- e_log, g_map, g_items, g_console, g_gfx, Math,
- g_options, g_triggers, g_menu, g_game, g_grid,
- wadreader, g_main, g_monsters, CONFIG, g_language,
- g_net, g_netmsg, g_window,
+ {$IFDEF ENABLE_HOLMES}
+ g_holmes,
+ {$ENDIF}
+ {$IFDEF ENABLE_MENU}
+ g_menu,
+ {$ENDIF}
+ {$IFDEF ENABLE_RENDER}
+ r_render,
+ {$ENDIF}
+ {$IFDEF ENABLE_GFX}
+ g_gfx,
+ {$ENDIF}
+ {$IFDEF ENABLE_GIBS}
+ g_gibs,
+ {$ENDIF}
+ {$IFDEF ENABLE_SHELLS}
+ g_shells,
+ {$ENDIF}
+ {$IFDEF ENABLE_CORPSES}
+ g_corpses,
+ {$ENDIF}
+ e_log, g_map, g_items, g_console, Math,
+ g_options, g_triggers, g_game, g_grid, e_res,
+ wadreader, g_monsters, CONFIG, g_language,
+ g_net, g_netmsg,
utils, xstreams;
const PLR_SAVE_VERSION = 0;
utils, xstreams;
const PLR_SAVE_VERSION = 0;
TIME_RESPAWN1 = 1500;
TIME_RESPAWN2 = 2000;
TIME_RESPAWN3 = 3000;
TIME_RESPAWN1 = 1500;
TIME_RESPAWN2 = 2000;
TIME_RESPAWN3 = 3000;
- AIR_DEF = 360;
- AIR_MAX = 1091;
- JET_MAX = 540; // ~30 sec
PLAYER_SUIT_TIME = 30000;
PLAYER_INVUL_TIME = 30000;
PLAYER_INVIS_TIME = 35000;
FRAG_COMBO_TIME = 3000;
VEL_SW = 4;
VEL_FLY = 6;
PLAYER_SUIT_TIME = 30000;
PLAYER_INVUL_TIME = 30000;
PLAYER_INVIS_TIME = 35000;
FRAG_COMBO_TIME = 3000;
VEL_SW = 4;
VEL_FLY = 6;
- ANGLE_RIGHTUP = 55;
- ANGLE_RIGHTDOWN = -35;
- ANGLE_LEFTUP = 125;
- ANGLE_LEFTDOWN = -145;
PLAYER_HEADRECT: TRectWH = (X:24; Y:12; Width:20; Height:12);
PLAYER_HEADRECT: TRectWH = (X:24; Y:12; Width:20; Height:12);
- WEAPONPOINT: Array [TDirection] of TDFPoint = ((X:16; Y:32), (X:47; Y:32));
BOT_MAXJUMP = 84;
BOT_LONGDIST = 300;
BOT_UNSAFEDIST = 128;
BOT_MAXJUMP = 84;
BOT_LONGDIST = 300;
BOT_UNSAFEDIST = 128;
- TEAMCOLOR: Array [TEAM_RED..TEAM_BLUE] of TRGB = ((R:255; G:0; B:0),
- (R:0; G:0; B:255));
DIFFICULT_EASY: TDifficult = (DiagFire: 32; InvisFire: 32; DiagPrecision: 32;
FlyPrecision: 32; Cover: 32; CloseJump: 32;
WeaponPrior:(0,0,0,0,0,0,0,0,0,0,0); CloseWeaponPrior:(0,0,0,0,0,0,0,0,0,0,0));
DIFFICULT_EASY: TDifficult = (DiagFire: 32; InvisFire: 32; DiagPrecision: 32;
FlyPrecision: 32; Cover: 32; CloseJump: 32;
WeaponPrior:(0,0,0,0,0,0,0,0,0,0,0); CloseWeaponPrior:(0,0,0,0,0,0,0,0,0,0,0));
BOTLIST_FILENAME = 'botlist.txt';
var
BOTLIST_FILENAME = 'botlist.txt';
var
- MaxGibs: Word = 150;
- MaxCorpses: Word = 20;
- MaxShells: Word = 300;
- CurrentGib: Integer = 0;
- CurrentShell: Integer = 0;
+ ForceModel: Word = 0;
+ ForcedModelName: String = STD_PLAYER_MODEL;
BotNames: Array of String;
BotList: Array of TBotProfile;
BotNames: Array of String;
BotList: Array of TBotProfile;
+ SavedStates: Array of TPlayerSavedState;
function Lerp(X, Y, Factor: Integer): Integer;
function Lerp(X, Y, Factor: Integer): Integer;
Result := g_Player_Get(UID1).FTeam = g_Player_Get(UID2).FTeam;
end;
Result := g_Player_Get(UID1).FTeam = g_Player_Get(UID2).FTeam;
end;
-procedure g_Gibs_SetMax(Count: Word);
+procedure g_Force_Model_Set(Mode: Word);
begin
begin
- MaxGibs := Count;
- SetLength(gGibs, Count);
-
- if CurrentGib >= Count then
- CurrentGib := 0;
-end;
-
-function g_Gibs_GetMax(): Word;
-begin
- Result := MaxGibs;
-end;
-
-procedure g_Shells_SetMax(Count: Word);
-begin
- MaxShells := Count;
- SetLength(gShells, Count);
-
- if CurrentShell >= Count then
- CurrentShell := 0;
+ ForceModel := Mode;
end;
end;
-function g_Shells_GetMax(): Word;
+function g_Force_Model_Get(): Word;
begin
begin
- Result := MaxShells;
+ Result := ForceModel;
end;
end;
-
-procedure g_Corpses_SetMax(Count: Word);
+procedure g_Forced_Model_SetName(Model: String);
begin
begin
- MaxCorpses := Count;
- SetLength(gCorpses, Count);
+ ForcedModelName := Model;
end;
end;
-function g_Corpses_GetMax(): Word;
+function g_Forced_Model_GetName(): String;
begin
begin
- Result := MaxCorpses;
+ Result := ForcedModelName;
end;
function g_Player_Create(ModelName: String; Color: TRGB; Team: Byte; Bot: Boolean): Word;
end;
function g_Player_Create(ModelName: String; Color: TRGB; Team: Byte; Bot: Boolean): Word;
ok := False;
a := 0;
ok := False;
a := 0;
-// Åñòü ëè ìåñòî â gPlayers:
+// Есть ли место в gPlayers:
if gPlayers <> nil then
for a := 0 to High(gPlayers) do
if gPlayers[a] = nil then
if gPlayers <> nil then
for a := 0 to High(gPlayers) do
if gPlayers[a] = nil then
Break;
end;
Break;
end;
-// Íåò ìåñòà - ðàñøèðÿåì gPlayers:
+// Нет места - расширяем gPlayers:
if not ok then
begin
SetLength(gPlayers, Length(gPlayers)+1);
a := High(gPlayers);
end;
if not ok then
begin
SetLength(gPlayers, Length(gPlayers)+1);
a := High(gPlayers);
end;
-// Ñîçäàåì îáúåêò èãðîêà:
+// Создаем объект игрока:
if Bot then
gPlayers[a] := TBot.Create()
else
if Bot then
gPlayers[a] := TBot.Create()
else
gPlayers[a].FActualModelName := ModelName;
gPlayers[a].SetModel(ModelName);
gPlayers[a].FActualModelName := ModelName;
gPlayers[a].SetModel(ModelName);
+ if Bot and (g_Force_Model_Get() <> 0) then
+ gPlayers[a].SetModel(g_Forced_Model_GetName());
-// Íåò ìîäåëè - ñîçäàíèå íå âîçìîæíî:
+// Нет модели - создание не возможно:
if gPlayers[a].FModel = nil then
begin
gPlayers[a].Free();
if gPlayers[a].FModel = nil then
begin
gPlayers[a].Free();
GM_COOP: gPlayers[a].FTeam := TEAM_COOP;
end;
GM_COOP: gPlayers[a].FTeam := TEAM_COOP;
end;
-// Åñëè êîìàíäíàÿ èãðà - êðàñèì ìîäåëü â öâåò êîìàíäû:
+// Если командная игра - красим модель в цвет команды:
gPlayers[a].FColor := Color;
if gPlayers[a].FTeam in [TEAM_RED, TEAM_BLUE] then
gPlayers[a].FModel.Color := TEAMCOLOR[gPlayers[a].FTeam]
gPlayers[a].FColor := Color;
if gPlayers[a].FTeam in [TEAM_RED, TEAM_BLUE] then
gPlayers[a].FModel.Color := TEAMCOLOR[gPlayers[a].FTeam]
end;
function g_Player_CreateFromState (st: TStream): Word;
end;
function g_Player_CreateFromState (st: TStream): Word;
-var
- a, i: Integer;
- ok, Bot: Boolean;
- b: Byte;
+ var a: Integer; ok, Bot: Boolean; pos: Int64;
begin
begin
- result := 0;
- if (st = nil) then exit; //???
+ assert(st <> nil);
- // Ñèãíàòóðà èãðîêà
+ // check signature and entity type
+ pos := st.Position;
if not utils.checkSign(st, 'PLYR') then raise XStreamError.Create('invalid player signature');
if (utils.readByte(st) <> PLR_SAVE_VERSION) then raise XStreamError.Create('invalid player version');
if not utils.checkSign(st, 'PLYR') then raise XStreamError.Create('invalid player signature');
if (utils.readByte(st) <> PLR_SAVE_VERSION) then raise XStreamError.Create('invalid player version');
-
- // Áîò èëè ÷åëîâåê:
Bot := utils.readBool(st);
Bot := utils.readBool(st);
+ st.Position := pos;
+ // find free player slot
ok := false;
ok := false;
- a := 0;
-
- // Åñòü ëè ìåñòî â gPlayers:
- for a := 0 to High(gPlayers) do if (gPlayers[a] = nil) then begin ok := true; break; end;
+ for a := 0 to High(gPlayers) do
+ if gPlayers[a] = nil then
+ begin
+ ok := true;
+ break;
+ end;
- // Íåò ìåñòà - ðàñøèðÿåì gPlayers
+ // allocate player slot
if not ok then
begin
SetLength(gPlayers, Length(gPlayers)+1);
a := High(gPlayers);
end;
if not ok then
begin
SetLength(gPlayers, Length(gPlayers)+1);
a := High(gPlayers);
end;
- // Ñîçäàåì îáúåêò èãðîêà
+ // create entity and load state
if Bot then
if Bot then
- gPlayers[a] := TBot.Create()
- else
- gPlayers[a] := TPlayer.Create();
- gPlayers[a].FIamBot := Bot;
- gPlayers[a].FPhysics := True;
-
- // UID èãðîêà
- gPlayers[a].FUID := utils.readWord(st);
- // Èìÿ èãðîêà
- gPlayers[a].FName := utils.readStr(st);
- // Êîìàíäà
- gPlayers[a].FTeam := utils.readByte(st);
- gPlayers[a].FPreferredTeam := gPlayers[a].FTeam;
- // Æèâ ëè
- gPlayers[a].FAlive := utils.readBool(st);
- // Èçðàñõîäîâàë ëè âñå æèçíè
- gPlayers[a].FNoRespawn := utils.readBool(st);
- // Íàïðàâëåíèå
- b := utils.readByte(st);
- if b = 1 then gPlayers[a].FDirection := TDirection.D_LEFT else gPlayers[a].FDirection := TDirection.D_RIGHT; // b = 2
- // Çäîðîâüå
- gPlayers[a].FHealth := utils.readLongInt(st);
- // Æèçíè
- gPlayers[a].FLives := utils.readByte(st);
- // Áðîíÿ
- gPlayers[a].FArmor := utils.readLongInt(st);
- // Çàïàñ âîçäóõà
- gPlayers[a].FAir := utils.readLongInt(st);
- // Çàïàñ ãîðþ÷åãî
- gPlayers[a].FJetFuel := utils.readLongInt(st);
- // Áîëü
- gPlayers[a].FPain := utils.readLongInt(st);
- // Óáèë
- gPlayers[a].FKills := utils.readLongInt(st);
- // Óáèë ìîíñòðîâ
- gPlayers[a].FMonsterKills := utils.readLongInt(st);
- // Ôðàãîâ
- gPlayers[a].FFrags := utils.readLongInt(st);
- // Ôðàãîâ ïîäðÿä
- gPlayers[a].FFragCombo := utils.readByte(st);
- // Âðåìÿ ïîñëåäíåãî ôðàãà
- gPlayers[a].FLastFrag := utils.readLongWord(st);
- // Ñìåðòåé
- gPlayers[a].FDeath := utils.readLongInt(st);
- // Êàêîé ôëàã íåñåò
- gPlayers[a].FFlag := utils.readByte(st);
- // Íàøåë ñåêðåòîâ
- gPlayers[a].FSecrets := utils.readLongInt(st);
- // Òåêóùåå îðóæèå
- gPlayers[a].FCurrWeap := utils.readByte(st);
- // Ñëåäóþùåå æåëàåìîå îðóæèå
- gPlayers[a].FNextWeap := utils.readWord(st);
- // ...è ïàóçà
- gPlayers[a].FNextWeapDelay := utils.readByte(st);
- // Âðåìÿ çàðÿäêè BFG
- gPlayers[a].FBFGFireCounter := utils.readSmallInt(st);
- // Áóôåð óðîíà
- gPlayers[a].FDamageBuffer := utils.readLongInt(st);
- // Ïîñëåäíèé óäàðèâøèé
- gPlayers[a].FLastSpawnerUID := utils.readWord(st);
- // Òèï ïîñëåäíåãî ïîëó÷åííîãî óðîíà
- gPlayers[a].FLastHit := utils.readByte(st);
- // Îáúåêò èãðîêà:
- Obj_LoadState(@gPlayers[a].FObj, st);
- // Òåêóùåå êîëè÷åñòâî ïàòðîíîâ
- for i := A_BULLETS to A_HIGH do gPlayers[a].FAmmo[i] := utils.readWord(st);
- // Ìàêñèìàëüíîå êîëè÷åñòâî ïàòðîíîâ
- for i := A_BULLETS to A_HIGH do gPlayers[a].FMaxAmmo[i] := utils.readWord(st);
- // Íàëè÷èå îðóæèÿ
- for i := WP_FIRST to WP_LAST do gPlayers[a].FWeapon[i] := utils.readBool(st);
- // Âðåìÿ ïåðåçàðÿäêè îðóæèÿ
- for i := WP_FIRST to WP_LAST do gPlayers[a].FReloading[i] := utils.readWord(st);
- // Íàëè÷èå ðþêçàêà
- if utils.readBool(st) then Include(gPlayers[a].FRulez, R_ITEM_BACKPACK);
- // Íàëè÷èå êðàñíîãî êëþ÷à
- if utils.readBool(st) then Include(gPlayers[a].FRulez, R_KEY_RED);
- // Íàëè÷èå çåëåíîãî êëþ÷à
- if utils.readBool(st) then Include(gPlayers[a].FRulez, R_KEY_GREEN);
- // Íàëè÷èå ñèíåãî êëþ÷à
- if utils.readBool(st) then Include(gPlayers[a].FRulez, R_KEY_BLUE);
- // Íàëè÷èå áåðñåðêà
- if utils.readBool(st) then Include(gPlayers[a].FRulez, R_BERSERK);
- // Âðåìÿ äåéñòâèÿ ñïåöèàëüíûõ ïðåäìåòîâ
- for i := MR_SUIT to MR_MAX do gPlayers[a].FMegaRulez[i] := utils.readLongWord(st);
- // Âðåìÿ äî ïîâòîðíîãî ðåñïàóíà, ñìåíû îðóæèÿ, èñîëüçîâàíèÿ, çàõâàòà ôëàãà
- for i := T_RESPAWN to T_FLAGCAP do gPlayers[a].FTime[i] := utils.readLongWord(st);
-
- // Íàçâàíèå ìîäåëè:
- gPlayers[a].FActualModelName := utils.readStr(st);
- // Öâåò ìîäåëè
- gPlayers[a].FColor.R := utils.readByte(st);
- gPlayers[a].FColor.G := utils.readByte(st);
- gPlayers[a].FColor.B := utils.readByte(st);
- // Îáíîâëÿåì ìîäåëü èãðîêà
- gPlayers[a].SetModel(gPlayers[a].FActualModelName);
-
- // Íåò ìîäåëè - ñîçäàíèå íåâîçìîæíî
- if (gPlayers[a].FModel = nil) then
begin
begin
- gPlayers[a].Free();
- gPlayers[a] := nil;
- g_FatalError(Format(_lc[I_GAME_ERROR_MODEL], [gPlayers[a].FActualModelName]));
- exit;
- end;
-
- // Åñëè êîìàíäíàÿ èãðà - êðàñèì ìîäåëü â öâåò êîìàíäû
- if gGameSettings.GameMode in [GM_TDM, GM_CTF] then
- gPlayers[a].FModel.Color := TEAMCOLOR[gPlayers[a].FTeam]
+ gPlayers[a] := TBot.Create();
+ if (g_Force_Model_Get() <> 0) then
+ gPlayers[a].SetModel(g_Forced_Model_GetName());
+ end
else
else
- gPlayers[a].FModel.Color := gPlayers[a].FColor;
+ gPlayers[a] := TPlayer.Create();
+ gPlayers[a].FPhysics := True; // ???
+ gPlayers[a].LoadState(st);
result := gPlayers[a].FUID;
end;
result := gPlayers[a].FUID;
end;
end;
end;
end;
end;
-procedure g_Bot_Add(Team, Difficult: Byte);
+procedure g_Bot_Add(Team, Difficult: Byte; Handicap: Integer = 100);
var
m: SSArray;
_name, _model: String;
var
m: SSArray;
_name, _model: String;
begin
if not g_Game_IsServer then Exit;
begin
if not g_Game_IsServer then Exit;
-// Ñïèñîê íàçâàíèé ìîäåëåé:
+ if (g_Bot_GetCount() >= gMaxBots) then Exit;
+
+// Список названий моделей:
m := g_PlayerModel_GetNames();
if m = nil then
Exit;
m := g_PlayerModel_GetNames();
if m = nil then
Exit;
-// Êîìàíäà:
+// Команда:
if (gGameSettings.GameType = GT_SINGLE) or (gGameSettings.GameMode = GM_COOP) then
Team := TEAM_COOP // COOP
else
if (gGameSettings.GameType = GT_SINGLE) or (gGameSettings.GameMode = GM_COOP) then
Team := TEAM_COOP // COOP
else
else
if Team = TEAM_NONE then // CTF / TDM
begin
else
if Team = TEAM_NONE then // CTF / TDM
begin
- // Àâòîáàëàíñ êîìàíä:
+ // Автобаланс команд:
tr := 0;
tb := 0;
tr := 0;
tb := 0;
Team := TEAM_BLUE;
end;
Team := TEAM_BLUE;
end;
-// Âûáèðàåì áîòó èìÿ:
+// Выбираем боту имя:
_name := '';
if BotNames <> nil then
for a := 0 to High(BotNames) do
_name := '';
if BotNames <> nil then
for a := 0 to High(BotNames) do
Break;
end;
Break;
end;
-// Èìåíè íåò, çàäàåì ñëó÷àéíîå:
- if _name = '' then
- repeat
- _name := Format('DFBOT%.2d', [Random(100)]);
- until g_Player_ValidName(_name);
-
-// Âûáèðàåì ñëó÷àéíóþ ìîäåëü:
+// Выбираем случайную модель:
_model := m[Random(Length(m))];
_model := m[Random(Length(m))];
-// Ñîçäàåì áîòà:
+// Создаем бота:
with g_Player_Get(g_Player_Create(_model,
_RGB(Min(Random(9)*32, 255),
Min(Random(9)*32, 255),
Min(Random(9)*32, 255)),
Team, True)) as TBot do
begin
with g_Player_Get(g_Player_Create(_model,
_RGB(Min(Random(9)*32, 255),
Min(Random(9)*32, 255),
Min(Random(9)*32, 255)),
Team, True)) as TBot do
begin
- Name := _name;
+ // Если имени нет, делаем его из UID бота
+ if _name = '' then
+ Name := Format('DFBOT%.5d', [UID])
+ else
+ Name := _name;
case Difficult of
1: FDifficult := DIFFICULT_EASY;
case Difficult of
1: FDifficult := DIFFICULT_EASY;
//FDifficult.SafeWeaponPrior[a] := WEAPON_PRIOR3[a];
end;
//FDifficult.SafeWeaponPrior[a] := WEAPON_PRIOR3[a];
end;
+ FHandicap := Handicap;
+
g_Console_Add(Format(_lc[I_PLAYER_JOIN], [Name]), True);
if g_Game_IsNet then MH_SEND_PlayerCreate(UID);
g_Console_Add(Format(_lc[I_PLAYER_JOIN], [Name]), True);
if g_Game_IsNet then MH_SEND_PlayerCreate(UID);
end;
end;
end;
end;
-procedure g_Bot_AddList(Team: Byte; lName: ShortString; num: Integer = -1);
+procedure g_Bot_AddList(Team: Byte; lName: ShortString; num: Integer = -1; Handicap: Integer = 100);
var
m: SSArray;
_name, _model: String;
var
m: SSArray;
_name, _model: String;
begin
if not g_Game_IsServer then Exit;
begin
if not g_Game_IsServer then Exit;
-// Ñïèñîê íàçâàíèé ìîäåëåé:
+ if (g_Bot_GetCount() >= gMaxBots) then Exit;
+
+// Список названий моделей:
m := g_PlayerModel_GetNames();
if m = nil then
Exit;
m := g_PlayerModel_GetNames();
if m = nil then
Exit;
-// Êîìàíäà:
+// Команда:
if (gGameSettings.GameType = GT_SINGLE) or (gGameSettings.GameMode = GM_COOP) then
Team := TEAM_COOP // COOP
else
if (gGameSettings.GameType = GT_SINGLE) or (gGameSettings.GameMode = GM_COOP) then
Team := TEAM_COOP // COOP
else
if Team = TEAM_NONE then
Team := BotList[num].team; // CTF / TDM
if Team = TEAM_NONE then
Team := BotList[num].team; // CTF / TDM
-// Âûáèðàåì íàñòðîéêè áîòà èç ñïèñêà ïî íîìåðó èëè èìåíè:
+// Выбираем настройки бота из списка по номеру или имени:
lName := AnsiLowerCase(lName);
if (num < 0) or (num > Length(BotList)-1) then
num := -1;
lName := AnsiLowerCase(lName);
if (num < 0) or (num > Length(BotList)-1) then
num := -1;
if num = -1 then
Exit;
if num = -1 then
Exit;
-// Èìÿ áîòà:
+// Имя бота:
_name := BotList[num].name;
_name := BotList[num].name;
-// Çàíÿòî - âûáèðàåì ñëó÷àéíîå:
+// Занято - выбираем случайное:
if not g_Player_ValidName(_name) then
repeat
_name := Format('DFBOT%.2d', [Random(100)]);
until g_Player_ValidName(_name);
if not g_Player_ValidName(_name) then
repeat
_name := Format('DFBOT%.2d', [Random(100)]);
until g_Player_ValidName(_name);
-// Ìîäåëü:
+// Модель:
_model := BotList[num].model;
_model := BotList[num].model;
-// Íåò òàêîé - âûáèðàåì ñëó÷àéíóþ:
+// Нет такой - выбираем случайную:
if not InSArray(_model, m) then
_model := m[Random(Length(m))];
if not InSArray(_model, m) then
_model := m[Random(Length(m))];
-// Ñîçäàåì áîòà:
+// Создаем бота:
with g_Player_Get(g_Player_Create(_model, BotList[num].color, Team, True)) as TBot do
begin
Name := _name;
with g_Player_Get(g_Player_Create(_model, BotList[num].color, Team, True)) as TBot do
begin
Name := _name;
FDifficult.Cover := BotList[num].cover;
FDifficult.CloseJump := BotList[num].close_jump;
FDifficult.Cover := BotList[num].cover;
FDifficult.CloseJump := BotList[num].close_jump;
+ FHandicap := Handicap;
+
for a := WP_FIRST to WP_LAST do
begin
FDifficult.WeaponPrior[a] := BotList[num].w_prior1[a];
for a := WP_FIRST to WP_LAST do
begin
FDifficult.WeaponPrior[a] := BotList[num].w_prior1[a];
a, b: Integer;
config: TConfig;
sa: SSArray;
a, b: Integer;
config: TConfig;
sa: SSArray;
+ path: AnsiString;
begin
BotNames := nil;
begin
BotNames := nil;
- if not FileExists(DataDir + BOTNAMES_FILENAME) then
+ path := BOTNAMES_FILENAME;
+ if e_FindResource(DataDirs, path) = false then
Exit;
Exit;
-// ×èòàåì âîçìîæíûå èìåíà áîòîâ èç ôàéëà:
- AssignFile(F, DataDir + BOTNAMES_FILENAME);
+// Читаем возможные имена ботов из файла:
+ AssignFile(F, path);
Reset(F);
while not EOF(F) do
Reset(F);
while not EOF(F) do
CloseFile(F);
CloseFile(F);
-// Ïåðåìåøèâàåì èõ:
+// Перемешиваем их:
g_Bot_MixNames();
g_Bot_MixNames();
-// ×èòàåì ôàéë ñ ïàðàìåòðàìè áîòîâ:
- config := TConfig.CreateFile(DataDir + BOTLIST_FILENAME);
+// Читаем файл с параметрами ботов:
+ config := TConfig.CreateFile(path);
BotList := nil;
a := 0;
BotList := nil;
a := 0;
with BotList[High(BotList)] do
begin
with BotList[High(BotList)] do
begin
- // Èìÿ áîòà:
+ // Имя бота:
name := config.ReadStr(IntToStr(a), 'name', '');
name := config.ReadStr(IntToStr(a), 'name', '');
- // Ìîäåëü:
+ // Модель:
model := config.ReadStr(IntToStr(a), 'model', '');
model := config.ReadStr(IntToStr(a), 'model', '');
- // Êîìàíäà:
+ // Команда:
if config.ReadStr(IntToStr(a), 'team', 'red') = 'red' then
team := TEAM_RED
else
team := TEAM_BLUE;
if config.ReadStr(IntToStr(a), 'team', 'red') = 'red' then
team := TEAM_RED
else
team := TEAM_BLUE;
- // Öâåò ìîäåëè:
+ // Цвет модели:
sa := parse(config.ReadStr(IntToStr(a), 'color', ''));
color.R := StrToIntDef(sa[0], 0);
color.G := StrToIntDef(sa[1], 0);
color.B := StrToIntDef(sa[2], 0);
sa := parse(config.ReadStr(IntToStr(a), 'color', ''));
color.R := StrToIntDef(sa[0], 0);
color.G := StrToIntDef(sa[1], 0);
color.B := StrToIntDef(sa[2], 0);
- // Âåðîÿòíîñòü ñòðåëüáû ïîä óãëîì:
+ // Вероятность стрельбы под углом:
diag_fire := config.ReadInt(IntToStr(a), 'diag_fire', 0);
diag_fire := config.ReadInt(IntToStr(a), 'diag_fire', 0);
- // Âåðîÿòíîñòü îòâåòíîãî îãíÿ ïî íåâèäèìîìó ñîïåðíèêó:
+ // Вероятность ответного огня по невидимому сопернику:
invis_fire := config.ReadInt(IntToStr(a), 'invis_fire', 0);
invis_fire := config.ReadInt(IntToStr(a), 'invis_fire', 0);
- // Òî÷íîñòü ñòðåëüáû ïîä óãëîì:
+ // Точность стрельбы под углом:
diag_precision := config.ReadInt(IntToStr(a), 'diag_precision', 0);
diag_precision := config.ReadInt(IntToStr(a), 'diag_precision', 0);
- // Òî÷íîñòü ñòðåëüáû â ïîëåòå:
+ // Точность стрельбы в полете:
fly_precision := config.ReadInt(IntToStr(a), 'fly_precision', 0);
fly_precision := config.ReadInt(IntToStr(a), 'fly_precision', 0);
- // Òî÷íîñòü óêëîíåíèÿ îò ñíàðÿäîâ:
+ // Точность уклонения от снарядов:
cover := config.ReadInt(IntToStr(a), 'cover', 0);
cover := config.ReadInt(IntToStr(a), 'cover', 0);
- // Âåðîÿòíîñòü ïðûæêà ïðè ïðèáëèæåíèè ñîïåðíèêà:
+ // Вероятность прыжка при приближении соперника:
close_jump := config.ReadInt(IntToStr(a), 'close_jump', 0);
close_jump := config.ReadInt(IntToStr(a), 'close_jump', 0);
- // Ïðèîðèòåòû îðóæèÿ äëÿ äàëüíåãî áîÿ:
+ // Приоритеты оружия для дальнего боя:
sa := parse(config.ReadStr(IntToStr(a), 'w_prior1', ''));
if Length(sa) = 10 then
for b := 0 to 9 do
w_prior1[b] := EnsureRange(StrToInt(sa[b]), 0, 9);
sa := parse(config.ReadStr(IntToStr(a), 'w_prior1', ''));
if Length(sa) = 10 then
for b := 0 to 9 do
w_prior1[b] := EnsureRange(StrToInt(sa[b]), 0, 9);
- // Ïðèîðèòåòû îðóæèÿ äëÿ áëèæíåãî áîÿ:
+ // Приоритеты оружия для ближнего боя:
sa := parse(config.ReadStr(IntToStr(a), 'w_prior2', ''));
if Length(sa) = 10 then
for b := 0 to 9 do
sa := parse(config.ReadStr(IntToStr(a), 'w_prior2', ''));
if Length(sa) = 10 then
for b := 0 to 9 do
end;
config.Free();
end;
config.Free();
+ SetLength(SavedStates, 0);
end;
procedure g_Player_Free();
end;
procedure g_Player_Free();
gPlayer1 := nil;
gPlayer2 := nil;
gPlayer1 := nil;
gPlayer2 := nil;
+ SetLength(SavedStates, 0);
+end;
+
+procedure g_Player_PreUpdate();
+var
+ i: Integer;
+begin
+ if gPlayers = nil then Exit;
+ for i := 0 to High(gPlayers) do
+ if gPlayers[i] <> nil then
+ gPlayers[i].PreUpdate();
end;
procedure g_Player_UpdateAll();
end;
procedure g_Player_UpdateAll();
//e_WriteLog('***g_Player_UpdateAll: EXIT', MSG_WARNING);
end;
//e_WriteLog('***g_Player_UpdateAll: EXIT', MSG_WARNING);
end;
-procedure g_Player_DrawAll();
-var
- i: Integer;
-begin
- if gPlayers = nil then Exit;
-
- for i := 0 to High(gPlayers) do
- if gPlayers[i] <> nil then
- if gPlayers[i] is TPlayer then gPlayers[i].Draw()
- else TBot(gPlayers[i]).Draw();
-end;
-
-procedure g_Player_DrawDebug(p: TPlayer);
-var
- fW, fH: Byte;
-begin
- if p = nil then Exit;
- if (@p.FObj) = nil then Exit;
-
- e_TextureFontGetSize(gStdFont, fW, fH);
-
- e_TextureFontPrint(0, 0 , 'Pos X: ' + IntToStr(p.FObj.X), gStdFont);
- e_TextureFontPrint(0, fH , 'Pos Y: ' + IntToStr(p.FObj.Y), gStdFont);
- e_TextureFontPrint(0, fH * 2, 'Vel X: ' + IntToStr(p.FObj.Vel.X), gStdFont);
- e_TextureFontPrint(0, fH * 3, 'Vel Y: ' + IntToStr(p.FObj.Vel.Y), gStdFont);
- e_TextureFontPrint(0, fH * 4, 'Acc X: ' + IntToStr(p.FObj.Accel.X), gStdFont);
- e_TextureFontPrint(0, fH * 5, 'Acc Y: ' + IntToStr(p.FObj.Accel.Y), gStdFont);
-end;
-
-procedure g_Player_DrawHealth();
-var
- i: Integer;
- fW, fH: Byte;
-begin
- if gPlayers = nil then Exit;
- e_TextureFontGetSize(gStdFont, fW, fH);
-
- for i := 0 to High(gPlayers) do
- if gPlayers[i] <> nil then
- begin
- e_TextureFontPrint(gPlayers[i].FObj.X + gPlayers[i].FObj.Rect.X,
- gPlayers[i].FObj.Y + gPlayers[i].FObj.Rect.Y + gPlayers[i].FObj.Rect.Height - fH * 2,
- IntToStr(gPlayers[i].FHealth), gStdFont);
- e_TextureFontPrint(gPlayers[i].FObj.X + gPlayers[i].FObj.Rect.X,
- gPlayers[i].FObj.Y + gPlayers[i].FObj.Rect.Y + gPlayers[i].FObj.Rect.Height - fH,
- IntToStr(gPlayers[i].FArmor), gStdFont);
- end;
-end;
-
function g_Player_Get(UID: Word): TPlayer;
var
a: Integer;
function g_Player_Get(UID: Word): TPlayer;
var
a: Integer;
Result := Result + 1;
end;
Result := Result + 1;
end;
+function g_Bot_GetCount(): Integer;
+var
+ a: Integer;
+begin
+ Result := 0;
+
+ if gPlayers = nil then
+ Exit;
+
+ for a := 0 to High(gPlayers) do
+ if (gPlayers[a] <> nil) and (gPlayers[a] is TBot) then
+ Result := Result + 1;
+end;
+
function g_Player_GetStats(): TPlayerStatArray;
var
a: Integer;
function g_Player_GetStats(): TPlayerStatArray;
var
a: Integer;
SetLength(Result, Length(Result)+1);
with Result[High(Result)] do
begin
SetLength(Result, Length(Result)+1);
with Result[High(Result)] do
begin
+ Num := a;
Ping := gPlayers[a].FPing;
Loss := gPlayers[a].FLoss;
Name := gPlayers[a].FName;
Ping := gPlayers[a].FPing;
Loss := gPlayers[a].FLoss;
Name := gPlayers[a].FName;
Color := gPlayers[a].FModel.Color;
Lives := gPlayers[a].FLives;
Spectator := gPlayers[a].FSpectator;
Color := gPlayers[a].FModel.Color;
Lives := gPlayers[a].FLives;
Spectator := gPlayers[a].FSpectator;
+ UID := gPlayers[a].FUID;
end;
end;
end;
end;
end;
end;
+procedure g_Player_ResetReady();
+var
+ a: Integer;
+begin
+ if not g_Game_IsServer then Exit;
+ if gPlayers = nil then Exit;
+
+ for a := 0 to High(gPlayers) do
+ if gPlayers[a] <> nil then
+ begin
+ gPlayers[a].FReady := False;
+ if g_Game_IsNet then
+ MH_SEND_GameEvent(NET_EV_INTER_READY, gPlayers[a].UID, 'N');
+ end;
+end;
+
procedure g_Player_RememberAll;
var
i: Integer;
procedure g_Player_RememberAll;
var
i: Integer;
var
i: Integer;
begin
var
i: Integer;
begin
- gTeamStat[TEAM_RED].Goals := 0;
- gTeamStat[TEAM_BLUE].Goals := 0;
+ gTeamStat[TEAM_RED].Score := 0;
+ gTeamStat[TEAM_BLUE].Score := 0;
if gPlayers <> nil then
for i := 0 to High(gPlayers) do
if gPlayers <> nil then
for i := 0 to High(gPlayers) do
end;
end;
end;
end;
-procedure g_Player_CreateCorpse(Player: TPlayer);
-var
- i: Integer;
- find_id: DWORD;
- ok: Boolean;
-begin
- if Player.alive then
- Exit;
-
-// Ðàçðûâàåì ñâÿçü ñ ïðåæíèì òðóïîì:
- if gCorpses <> nil then
- for i := 0 to High(gCorpses) do
- if gCorpses[i] <> nil then
- if gCorpses[i].FPlayerUID = Player.FUID then
- gCorpses[i].FPlayerUID := 0;
-
- if Player.FObj.Y >= gMapInfo.Height+128 then
- Exit;
+{ T P l a y e r : }
- with Player do
- begin
- if (FHealth >= -50) or (gGibsCount = 0) then
- begin
- if (gCorpses = nil) or (Length(gCorpses) = 0) then
- Exit;
+function TPlayer.isValidViewPort (): Boolean; inline; begin result := (viewPortW > 0) and (viewPortH > 0); end;
- ok := False;
- for find_id := 0 to High(gCorpses) do
- if gCorpses[find_id] = nil then
- begin
- ok := True;
- Break;
- end;
+procedure TPlayer.BFGHit();
+begin
+ g_Weapon_BFGHit(FObj.X+FObj.Rect.X+(FObj.Rect.Width div 2),
+ FObj.Y+FObj.Rect.Y+(FObj.Rect.Height div 2));
+ if g_Game_IsServer and g_Game_IsNet then
+ MH_SEND_Effect(FObj.X+FObj.Rect.X+(FObj.Rect.Width div 2),
+ FObj.Y+FObj.Rect.Y+(FObj.Rect.Height div 2),
+ 0, NET_GFX_BFGHIT);
+end;
- if not ok then
- find_id := Random(Length(gCorpses));
+procedure TPlayer.ChangeModel(ModelName: string);
+var
+ locModel: TPlayerModel;
+begin
+ locModel := g_PlayerModel_Get(ModelName);
+ if locModel = nil then Exit;
- gCorpses[find_id] := TCorpse.Create(FObj.X, FObj.Y, FModel.Name, FHealth < -20);
- gCorpses[find_id].FColor := FModel.Color;
- gCorpses[find_id].FObj.Vel := FObj.Vel;
- gCorpses[find_id].FObj.Accel := FObj.Accel;
- gCorpses[find_id].FPlayerUID := FUID;
- end
- else
- g_Player_CreateGibs(FObj.X + PLAYER_RECT_CX,
- FObj.Y + PLAYER_RECT_CY,
- FModel.Name, FModel.Color);
- end;
+ FModel.Free();
+ FModel := locModel;
end;
end;
-procedure g_Player_CreateShell(fX, fY, dX, dY: Integer; T: Byte);
+procedure TPlayer.SetModel(ModelName: string);
var
var
- SID: DWORD;
+ m: TPlayerModel;
begin
begin
- if (gShells = nil) or (Length(gShells) = 0) then
- Exit;
-
- with gShells[CurrentShell] do
+ m := g_PlayerModel_Get(ModelName);
+ if m = nil then
begin
begin
- SpriteID := 0;
- g_Obj_Init(@Obj);
- Obj.Rect.X := 0;
- Obj.Rect.Y := 0;
- if T = SHELL_BULLET then
- begin
- if g_Texture_Get('TEXTURE_SHELL_BULLET', SID) then
- SpriteID := SID;
- CX := 2;
- CY := 1;
- Obj.Rect.Width := 4;
- Obj.Rect.Height := 2;
- end
- else
+ g_SimpleError(Format(_lc[I_GAME_ERROR_MODEL_FALLBACK], [ModelName]));
+ m := g_PlayerModel_Get('doomer');
+ if m = nil then
begin
begin
- if g_Texture_Get('TEXTURE_SHELL_SHELL', SID) then
- SpriteID := SID;
- CX := 4;
- CY := 2;
- Obj.Rect.Width := 7;
- Obj.Rect.Height := 3;
+ g_FatalError(Format(_lc[I_GAME_ERROR_MODEL], ['doomer']));
+ Exit;
end;
end;
- SType := T;
- alive := True;
- Obj.X := fX;
- Obj.Y := fY;
- g_Obj_Push(@Obj, dX + Random(4)-Random(4), dY-Random(4));
- positionChanged(); // this updates spatial accelerators
- RAngle := Random(360);
- Timeout := gTime + SHELL_TIMEOUT;
-
- if CurrentShell >= High(gShells) then
- CurrentShell := 0
- else
- Inc(CurrentShell);
end;
end;
+
+ if FModel <> nil then
+ FModel.Free();
+
+ FModel := m;
+
+ if not (gGameSettings.GameMode in [GM_TDM, GM_CTF]) then
+ FModel.Color := FColor
+ else
+ FModel.Color := TEAMCOLOR[FTeam];
+ FModel.SetWeapon(FCurrWeap);
+ FModel.SetFlag(FFlag);
+ SetDirection(FDirection);
end;
end;
-procedure g_Player_CreateGibs(fX, fY: Integer; ModelName: string; fColor: TRGB);
-var
- a: Integer;
- GibsArray: TGibsArray;
- Blood: TModelBlood;
+procedure TPlayer.SetColor(Color: TRGB);
begin
begin
- if (gGibs = nil) or (Length(gGibs) = 0) then
- Exit;
- if not g_PlayerModel_GetGibs(ModelName, GibsArray) then
- Exit;
- Blood := g_PlayerModel_GetBlood(ModelName);
+ FColor := Color;
+ if not (gGameSettings.GameMode in [GM_TDM, GM_CTF]) then
+ if FModel <> nil then FModel.Color := Color;
+end;
- for a := 0 to High(GibsArray) do
- with gGibs[CurrentGib] do
- begin
- Color := fColor;
- ID := GibsArray[a].ID;
- MaskID := GibsArray[a].MaskID;
- alive := True;
- g_Obj_Init(@Obj);
- Obj.Rect := GibsArray[a].Rect;
- Obj.X := fX-GibsArray[a].Rect.X-(GibsArray[a].Rect.Width div 2);
- Obj.Y := fY-GibsArray[a].Rect.Y-(GibsArray[a].Rect.Height div 2);
- g_Obj_PushA(@Obj, 25 + Random(10), Random(361));
- positionChanged(); // this updates spatial accelerators
- RAngle := Random(360);
- if gBloodCount > 0 then
- g_GFX_Blood(fX, fY, 16*gBloodCount+Random(5*gBloodCount), -16+Random(33), -16+Random(33),
- Random(48), Random(48), Blood.R, Blood.G, Blood.B, Blood.Kind);
- if CurrentGib >= High(gGibs) then
- CurrentGib := 0
- else
- Inc(CurrentGib);
- end;
+function TPlayer.GetColor(): TRGB;
+begin
+ result := FModel.Color;
end;
end;
-procedure g_Player_UpdatePhysicalObjects();
+procedure TPlayer.SetWeaponPrefs(Prefs: Array of Byte);
var
i: Integer;
var
i: Integer;
- vel: TPoint2i;
- mr: Word;
+begin
+ for i := WP_FIRST to WP_LAST + 1 do
+ begin
+ if (Prefs[i] > WP_LAST + 1) then
+ FWeapPreferences[i] := 0
+ else
+ FWeapPreferences[i] := Prefs[i];
+ end;
+end;
- procedure ShellSound_Bounce(X, Y: Integer; T: Byte);
- var
- k: Integer;
- begin
- k := 1 + Random(2);
- if T = SHELL_BULLET then
- g_Sound_PlayExAt('SOUND_PLAYER_CASING' + IntToStr(k), X, Y)
- else
- g_Sound_PlayExAt('SOUND_PLAYER_SHELL' + IntToStr(k), X, Y);
- end;
+procedure TPlayer.SetWeaponPref(Weapon, Pref: Byte);
+begin
+ if (Weapon > WP_LAST + 1) then
+ exit
+ else if (Pref <= WP_LAST + 1) and (Weapon <= WP_LAST + 1) then
+ FWeapPreferences[Weapon] := Pref
+ else if (Weapon <= WP_LAST + 1) and (Pref > WP_LAST + 1) then
+ FWeapPreferences[Weapon] := 0;
+end;
+function TPlayer.GetWeaponPref(Weapon: Byte) : Byte;
begin
begin
-// Êóñêè ìÿñà:
- if gGibs <> nil then
- for i := 0 to High(gGibs) do
- if gGibs[i].alive then
- with gGibs[i] do
- begin
- vel := Obj.Vel;
- mr := g_Obj_Move(@Obj, True, False, True);
- positionChanged(); // this updates spatial accelerators
+ if (Weapon > WP_LAST + 1) then
+ result := 0
+ else if (FWeapPreferences[Weapon] > WP_LAST + 1) then
+ result := 0
+ else
+ result := FWeapPreferences[Weapon];
+end;
- if WordBool(mr and MOVE_FALLOUT) then
- begin
- alive := False;
- Continue;
- end;
-
- // Îòëåòàåò îò óäàðà î ñòåíó/ïîòîëîê/ïîë:
- if WordBool(mr and MOVE_HITWALL) then
- Obj.Vel.X := -(vel.X div 2);
- if WordBool(mr and (MOVE_HITCEIL or MOVE_HITLAND)) then
- Obj.Vel.Y := -(vel.Y div 2);
-
- if (Obj.Vel.X >= 0) then
- begin // Clockwise
- RAngle := RAngle + Abs(Obj.Vel.X)*6 + Abs(Obj.Vel.Y);
- if RAngle >= 360 then
- RAngle := RAngle mod 360;
- end else begin // Counter-clockwise
- RAngle := RAngle - Abs(Obj.Vel.X)*6 - Abs(Obj.Vel.Y);
- if RAngle < 0 then
- RAngle := (360 - (Abs(RAngle) mod 360)) mod 360;
- end;
-
- // Ñîïðîòèâëåíèå âîçäóõà äëÿ êóñêà òðóïà:
- if gTime mod (GAME_TICK*3) = 0 then
- Obj.Vel.X := z_dec(Obj.Vel.X, 1);
- end;
-
-// Òðóïû:
- if gCorpses <> nil then
- for i := 0 to High(gCorpses) do
- if gCorpses[i] <> nil then
- if gCorpses[i].State = CORPSE_STATE_REMOVEME then
- begin
- gCorpses[i].Free();
- gCorpses[i] := nil;
- end
- else
- gCorpses[i].Update();
-
-// Ãèëüçû:
- if gShells <> nil then
- for i := 0 to High(gShells) do
- if gShells[i].alive then
- with gShells[i] do
- begin
- vel := Obj.Vel;
- mr := g_Obj_Move(@Obj, True, False, True);
- positionChanged(); // this updates spatial accelerators
-
- if WordBool(mr and MOVE_FALLOUT) or (gShells[i].Timeout < gTime) then
- begin
- alive := False;
- Continue;
- end;
-
- // Îòëåòàåò îò óäàðà î ñòåíó/ïîòîëîê/ïîë:
- if WordBool(mr and MOVE_HITWALL) then
- begin
- Obj.Vel.X := -(vel.X div 2);
- if not WordBool(mr and MOVE_INWATER) then
- ShellSound_Bounce(Obj.X, Obj.Y, SType);
- end;
- if WordBool(mr and (MOVE_HITCEIL or MOVE_HITLAND)) then
- begin
- Obj.Vel.Y := -(vel.Y div 2);
- if Obj.Vel.X <> 0 then Obj.Vel.X := Obj.Vel.X div 2;
- if (Obj.Vel.X = 0) and (Obj.Vel.Y = 0) then
- begin
- if RAngle mod 90 <> 0 then
- RAngle := (RAngle div 90) * 90;
- end
- else if not WordBool(mr and MOVE_INWATER) then
- ShellSound_Bounce(Obj.X, Obj.Y, SType);
- end;
-
- if (Obj.Vel.X >= 0) then
- begin // Clockwise
- RAngle := RAngle + Abs(Obj.Vel.X)*8 + Abs(Obj.Vel.Y);
- if RAngle >= 360 then
- RAngle := RAngle mod 360;
- end else begin // Counter-clockwise
- RAngle := RAngle - Abs(Obj.Vel.X)*8 - Abs(Obj.Vel.Y);
- if RAngle < 0 then
- RAngle := (360 - (Abs(RAngle) mod 360)) mod 360;
- end;
- end;
-end;
-
-
-procedure TGib.getMapBox (out x, y, w, h: Integer); inline;
-begin
- x := Obj.X+Obj.Rect.X;
- y := Obj.Y+Obj.Rect.Y;
- w := Obj.Rect.Width;
- h := Obj.Rect.Height;
-end;
-
-procedure TGib.moveBy (dx, dy: Integer); inline;
-begin
- if (dx <> 0) or (dy <> 0) then
- begin
- Obj.X += dx;
- Obj.Y += dy;
- positionChanged();
- end;
-end;
-
-
-procedure TShell.getMapBox (out x, y, w, h: Integer); inline;
-begin
- x := Obj.X;
- y := Obj.Y;
- w := Obj.Rect.Width;
- h := Obj.Rect.Height;
-end;
-
-procedure TShell.moveBy (dx, dy: Integer); inline;
-begin
- if (dx <> 0) or (dy <> 0) then
- begin
- Obj.X += dx;
- Obj.Y += dy;
- positionChanged();
- end;
-end;
-
-
-procedure TGib.positionChanged (); inline; begin end;
-procedure TShell.positionChanged (); inline; begin end;
-
-
-procedure g_Player_DrawCorpses();
-var
- i: Integer;
- a: TDFPoint;
-begin
- if gGibs <> nil then
- for i := 0 to High(gGibs) do
- if gGibs[i].alive then
- with gGibs[i] do
- begin
- if not g_Obj_Collide(sX, sY, sWidth, sHeight, @Obj) then
- Continue;
-
- a.X := Obj.Rect.X+(Obj.Rect.Width div 2);
- a.y := Obj.Rect.Y+(Obj.Rect.Height div 2);
-
- e_DrawAdv(ID, Obj.X, Obj.Y, 0, True, False, RAngle, @a, TMirrorType.None);
-
- e_Colors := Color;
- e_DrawAdv(MaskID, Obj.X, Obj.Y, 0, True, False, RAngle, @a, TMirrorType.None);
- e_Colors.R := 255;
- e_Colors.G := 255;
- e_Colors.B := 255;
- end;
-
- if gCorpses <> nil then
- for i := 0 to High(gCorpses) do
- if gCorpses[i] <> nil then
- gCorpses[i].Draw();
-end;
-
-procedure g_Player_DrawShells();
-var
- i: Integer;
- a: TDFPoint;
-begin
- if gShells <> nil then
- for i := 0 to High(gShells) do
- if gShells[i].alive then
- with gShells[i] do
- begin
- if not g_Obj_Collide(sX, sY, sWidth, sHeight, @Obj) then
- Continue;
-
- a.X := CX;
- a.Y := CY;
-
- e_DrawAdv(SpriteID, Obj.X, Obj.Y, 0, True, False, RAngle, @a, TMirrorType.None);
- end;
-end;
-
-procedure g_Player_RemoveAllCorpses();
-var
- i: Integer;
-begin
- gGibs := nil;
- gShells := nil;
- SetLength(gGibs, MaxGibs);
- SetLength(gShells, MaxGibs);
- CurrentGib := 0;
- CurrentShell := 0;
-
- if gCorpses <> nil then
- for i := 0 to High(gCorpses) do
- gCorpses[i].Free();
-
- gCorpses := nil;
- SetLength(gCorpses, MaxCorpses);
-end;
-
-procedure g_Player_Corpses_SaveState (st: TStream);
-var
- count, i: Integer;
-begin
- // Ñ÷èòàåì êîëè÷åñòâî ñóùåñòâóþùèõ òðóïîâ
- count := 0;
- for i := 0 to High(gCorpses) do if (gCorpses[i] <> nil) then Inc(count);
-
- // Êîëè÷åñòâî òðóïîâ
- utils.writeInt(st, LongInt(count));
-
- if (count = 0) then exit;
-
- // Ñîõðàíÿåì òðóïû
- for i := 0 to High(gCorpses) do
- begin
- if gCorpses[i] <> nil then
- begin
- // Íàçâàíèå ìîäåëè
- utils.writeStr(st, gCorpses[i].FModelName);
- // Òèï ñìåðòè
- utils.writeBool(st, gCorpses[i].Mess);
- // Ñîõðàíÿåì äàííûå òðóïà:
- gCorpses[i].SaveState(st);
- end;
- end;
-end;
-
-
-procedure g_Player_Corpses_LoadState (st: TStream);
-var
- count, i: Integer;
- str: String;
- b: Boolean;
-begin
- assert(st <> nil);
-
- g_Player_RemoveAllCorpses();
-
- // Êîëè÷åñòâî òðóïîâ:
- count := utils.readLongInt(st);
- if (count < 0) or (count > Length(gCorpses)) then raise XStreamError.Create('invalid number of corpses');
-
- if (count = 0) then exit;
-
- // Çàãðóæàåì òðóïû
- for i := 0 to count-1 do
- begin
- // Íàçâàíèå ìîäåëè:
- str := utils.readStr(st);
- // Òèï ñìåðòè
- b := utils.readBool(st);
- // Ñîçäàåì òðóï
- gCorpses[i] := TCorpse.Create(0, 0, str, b);
- // Çàãðóæàåì äàííûå òðóïà
- gCorpses[i].LoadState(st);
- end;
-end;
-
-
-{ T P l a y e r : }
-
-function TPlayer.isValidViewPort (): Boolean; inline; begin result := (viewPortW > 0) and (viewPortH > 0); end;
-
-procedure TPlayer.BFGHit();
-begin
- g_Weapon_BFGHit(FObj.X+FObj.Rect.X+(FObj.Rect.Width div 2),
- FObj.Y+FObj.Rect.Y+(FObj.Rect.Height div 2));
- if g_Game_IsServer and g_Game_IsNet then
- MH_SEND_Effect(FObj.X+FObj.Rect.X+(FObj.Rect.Width div 2),
- FObj.Y+FObj.Rect.Y+(FObj.Rect.Height div 2),
- 0, NET_GFX_BFGHIT);
-end;
-
-procedure TPlayer.ChangeModel(ModelName: string);
+function TPlayer.GetMorePrefered() : Byte;
var
var
- locModel: TPlayerModel;
+ testedWeap, i: Byte;
begin
begin
- locModel := g_PlayerModel_Get(ModelName);
- if locModel = nil then Exit;
-
- FModel.Free();
- FModel := locModel;
+ testedWeap := FCurrWeap;
+ for i := WP_FIRST to WP_LAST do
+ if FWeapon[i] and maySwitch(i) and (FWeapPreferences[i] > FWeapPreferences[testedWeap]) then
+ testedWeap := i;
+ if (R_BERSERK in FRulez) and (FWeapPreferences[WP_LAST + 1] > FWeapPreferences[testedWeap]) then
+ testedWeap := WEAPON_KASTET;
+ result := testedWeap;
end;
end;
-procedure TPlayer.SetModel(ModelName: string);
-var
- m: TPlayerModel;
+function TPlayer.maySwitch(Weapon: Byte) : Boolean;
begin
begin
- m := g_PlayerModel_Get(ModelName);
- if m = nil then
+ result := true;
+ if (Weapon = WEAPON_KASTET) and (FSkipFist <> 0) then
begin
begin
- g_SimpleError(Format(_lc[I_GAME_ERROR_MODEL_FALLBACK], [ModelName]));
- m := g_PlayerModel_Get('doomer');
- if m = nil then
- begin
- g_FatalError(Format(_lc[I_GAME_ERROR_MODEL], ['doomer']));
- Exit;
- end;
- end;
-
- if FModel <> nil then
- FModel.Free();
-
- FModel := m;
-
- if not (gGameSettings.GameMode in [GM_TDM, GM_CTF]) then
- FModel.Color := FColor
- else
- FModel.Color := TEAMCOLOR[FTeam];
- FModel.SetWeapon(FCurrWeap);
- FModel.SetFlag(FFlag);
- SetDirection(FDirection);
-end;
-
-procedure TPlayer.SetColor(Color: TRGB);
-begin
- FColor := Color;
- if not (gGameSettings.GameMode in [GM_TDM, GM_CTF]) then
- if FModel <> nil then FModel.Color := Color;
+ if (FSkipFist = 1) and (not (R_BERSERK in FRulez)) then
+ result := false;
+ end
+ else if (FSwitchToEmpty = 0) and (not hasAmmoForShooting(Weapon)) then
+ result := false;
end;
procedure TPlayer.SwitchTeam;
end;
procedure TPlayer.SwitchTeam;
g_Sound_PlayExAt('SOUND_ITEM_GETMED', FObj.X, FObj.Y)
else g_Sound_PlayExAt('SOUND_ITEM_GETITEM', FObj.X, FObj.Y);
g_Sound_PlayExAt('SOUND_ITEM_GETMED', FObj.X, FObj.Y)
else g_Sound_PlayExAt('SOUND_ITEM_GETITEM', FObj.X, FObj.Y);
- // Íàäî óáðàòü ñ êàðòû, åñëè ýòî íå êëþ÷, êîòîðûì íóæíî ïîäåëèòñÿ ñ äðóãèì èãðîêîì:
+ // Надо убрать с карты, если это не ключ, которым нужно поделится с другим игроком:
if r and not ((ItemType in [ITEM_KEY_RED, ITEM_KEY_GREEN, ITEM_KEY_BLUE]) and
(gGameSettings.GameType = GT_SINGLE) and
(g_Player_GetCount() > 1)) then
if r and not ((ItemType in [ITEM_KEY_RED, ITEM_KEY_GREEN, ITEM_KEY_BLUE]) and
(gGameSettings.GameType = GT_SINGLE) and
(g_Player_GetCount() > 1)) then
FSawSoundIdle := TPlayableSound.Create();
FSawSoundHit := TPlayableSound.Create();
FSawSoundSelect := TPlayableSound.Create();
FSawSoundIdle := TPlayableSound.Create();
FSawSoundHit := TPlayableSound.Create();
FSawSoundSelect := TPlayableSound.Create();
+ FFlameSoundOn := TPlayableSound.Create();
+ FFlameSoundOff := TPlayableSound.Create();
+ FFlameSoundWork := TPlayableSound.Create();
FJetSoundFly := TPlayableSound.Create();
FJetSoundOn := TPlayableSound.Create();
FJetSoundOff := TPlayableSound.Create();
FJetSoundFly := TPlayableSound.Create();
FJetSoundOn := TPlayableSound.Create();
FJetSoundOff := TPlayableSound.Create();
FSawSoundIdle.SetByName('SOUND_WEAPON_IDLESAW');
FSawSoundHit.SetByName('SOUND_WEAPON_HITSAW');
FSawSoundSelect.SetByName('SOUND_WEAPON_SELECTSAW');
FSawSoundIdle.SetByName('SOUND_WEAPON_IDLESAW');
FSawSoundHit.SetByName('SOUND_WEAPON_HITSAW');
FSawSoundSelect.SetByName('SOUND_WEAPON_SELECTSAW');
+ FFlameSoundOn.SetByName('SOUND_WEAPON_FLAMEON');
+ FFlameSoundOff.SetByName('SOUND_WEAPON_FLAMEOFF');
+ FFlameSoundWork.SetByName('SOUND_WEAPON_FLAMEWORK');
FJetSoundFly.SetByName('SOUND_PLAYER_JETFLY');
FJetSoundOn.SetByName('SOUND_PLAYER_JETON');
FJetSoundOff.SetByName('SOUND_PLAYER_JETOFF');
FJetSoundFly.SetByName('SOUND_PLAYER_JETFLY');
FJetSoundOn.SetByName('SOUND_PLAYER_JETON');
FJetSoundOff.SetByName('SOUND_PLAYER_JETOFF');
FClientID := -1;
FPing := 0;
FLoss := 0;
FClientID := -1;
FPing := 0;
FLoss := 0;
- FSavedState.WaitRecall := False;
- FShellTimer := -1;
+ FSavedStateNum := -1;
+ {$IFDEF ENABLE_SHELLS}
+ FShellTimer := -1;
+ {$ENDIF}
FFireTime := 0;
FFirePainTime := 0;
FFireAttacker := 0;
FFireTime := 0;
FFirePainTime := 0;
FFireAttacker := 0;
+ FHandicap := 100;
+
+ {$IFDEF ENABLE_CORPSES}
+ FCorpse := -1;
+ {$ENDIF}
FActualModelName := 'doomer';
FActualModelName := 'doomer';
FJustTeleported := False;
FNetTime := 0;
FJustTeleported := False;
FNetTime := 0;
+ FWaitForFirstSpawn := false;
+ FPunchAnim := TAnimationState.Create(False, 1, 4);
+ FPunchAnim.Disable;
+
resetWeaponQueue();
end;
resetWeaponQueue();
end;
FLastHit := t;
FLastHit := t;
-// Íåóÿçâèìîñòü íå ñïàñàåò îò ëîâóøåê:
+// Неуязвимость не спасает от ловушек:
if ((t = HIT_TRAP) or (t = HIT_SELF)) and (not FGodMode) then
begin
if not g_Game_IsClient then
if ((t = HIT_TRAP) or (t = HIT_SELF)) and (not FGodMode) then
begin
if not g_Game_IsClient then
FArmor := 0;
if t = HIT_TRAP then
begin
FArmor := 0;
if t = HIT_TRAP then
begin
- // Ëîâóøêà óáèâàåò ñðàçó:
+ // Ловушка убивает сразу:
FHealth := -100;
Kill(K_EXTRAHARDKILL, SpawnerUID, t);
end;
if t = HIT_SELF then
begin
FHealth := -100;
Kill(K_EXTRAHARDKILL, SpawnerUID, t);
end;
if t = HIT_SELF then
begin
- // Ñàìîóáèéñòâî:
+ // Самоубийство:
FHealth := 0;
Kill(K_SIMPLEKILL, SpawnerUID, t);
end;
end;
FHealth := 0;
Kill(K_SIMPLEKILL, SpawnerUID, t);
end;
end;
- // Îáíóëèòü äåéñòâèÿ ïðèìî÷åê, ÷òîáû ôîí ïðîïàë
+ // Обнулить действия примочек, чтобы фон пропал
FMegaRulez[MR_SUIT] := 0;
FMegaRulez[MR_INVUL] := 0;
FMegaRulez[MR_INVIS] := 0;
FMegaRulez[MR_SUIT] := 0;
FMegaRulez[MR_INVUL] := 0;
FMegaRulez[MR_INVIS] := 0;
+ FSpawnInvul := 0;
FBerserk := 0;
end;
FBerserk := 0;
end;
-// Íî îò îñòàëüíîãî ñïàñàåò:
+// Но от остального спасает:
if FMegaRulez[MR_INVUL] >= gTime then
Exit;
if FMegaRulez[MR_INVUL] >= gTime then
Exit;
-// ×èò-êîä "ÃÎÐÅÖ":
+// Чит-код "ГОРЕЦ":
if FGodMode then
Exit;
if FGodMode then
Exit;
-// Åñëè åñòü óðîí ñâîèì, èëè ðàíèë ñàì ñåáÿ, èëè òåáÿ ðàíèë ïðîòèâíèê:
+// Если есть урон своим, или ранил сам себя, или тебя ранил противник:
if LongBool(gGameSettings.Options and GAME_OPTION_TEAMDAMAGE) or
(SpawnerUID = FUID) or
(not SameTeam(FUID, SpawnerUID)) then
if LongBool(gGameSettings.Options and GAME_OPTION_TEAMDAMAGE) or
(SpawnerUID = FUID) or
(not SameTeam(FUID, SpawnerUID)) then
- begin
- FLastSpawnerUID := SpawnerUID;
-
- // Êðîâü (ïóçûðüêè, åñëè â âîäå):
- if gBloodCount > 0 then
- begin
- c := Min(value, 200)*gBloodCount + Random(Min(value, 200) div 2);
- if value div 4 <= c then
- c := c - (value div 4)
- else
- c := 0;
-
- if (t = HIT_SOME) and (vx = 0) and (vy = 0) then
- MakeBloodSimple(c)
- else
- case t of
- HIT_TRAP, HIT_ACID, HIT_FLAME, HIT_SELF: MakeBloodSimple(c);
- HIT_BFG, HIT_ROCKET, HIT_SOME: MakeBloodVector(c, vx, vy);
- end;
-
- if t = HIT_WATER then
- g_GFX_Bubbles(FObj.X+PLAYER_RECT.X+(PLAYER_RECT.Width div 2),
- FObj.Y+PLAYER_RECT.Y-4, value div 2, 8, 4);
- end;
-
- // Áóôåð óðîíà:
- if FAlive then
- Inc(FDamageBuffer, value);
-
- // Âñïûøêà áîëè:
- if gFlash <> 0 then
- FPain := FPain + value;
- end;
-
- if g_Game_IsServer and g_Game_IsNet then
- begin
- MH_SEND_PlayerDamage(FUID, t, SpawnerUID, value, vx, vy);
- MH_SEND_PlayerStats(FUID);
- MH_SEND_PlayerPos(False, FUID);
- end;
-end;
-
-function TPlayer.Heal(value: Word; Soft: Boolean): Boolean;
-begin
- Result := False;
- if g_Game_IsClient then
- Exit;
- if not FAlive then
- Exit;
-
- if Soft and (FHealth < PLAYER_HP_SOFT) then
- begin
- IncMax(FHealth, value, PLAYER_HP_SOFT);
- Result := True;
- end;
- if (not Soft) and (FHealth < PLAYER_HP_LIMIT) then
- begin
- IncMax(FHealth, value, PLAYER_HP_LIMIT);
- Result := True;
- end;
-
- if Result and g_Game_IsServer and g_Game_IsNet then
- MH_SEND_PlayerStats(FUID);
-end;
-
-destructor TPlayer.Destroy();
-begin
- if (gPlayer1 <> nil) and (gPlayer1.FUID = FUID) then
- gPlayer1 := nil;
- if (gPlayer2 <> nil) and (gPlayer2.FUID = FUID) then
- gPlayer2 := nil;
-
- FSawSound.Free();
- FSawSoundIdle.Free();
- FSawSoundHit.Free();
- FJetSoundFly.Free();
- FJetSoundOn.Free();
- FJetSoundOff.Free();
- FModel.Free();
- if FPunchAnim <> nil then
- FPunchAnim.Free();
-
- inherited;
-end;
-
-procedure TPlayer.DrawBubble();
-var
- bubX, bubY: Integer;
- ID: LongWord;
- Rb, Gb, Bb,
- Rw, Gw, Bw: SmallInt;
- Dot: Byte;
-begin
- bubX := FObj.X+FObj.Rect.X + IfThen(FDirection = TDirection.D_LEFT, -4, 18);
- bubY := FObj.Y+FObj.Rect.Y - 18;
- Rb := 64;
- Gb := 64;
- Bb := 64;
- Rw := 240;
- Gw := 240;
- Bw := 240;
- case gChatBubble of
- 1: // simple textual non-bubble
- begin
- bubX := FObj.X+FObj.Rect.X - 11;
- bubY := FObj.Y+FObj.Rect.Y - 17;
- e_TextureFontPrint(bubX, bubY, '[...]', gStdFont);
- Exit;
- end;
- 2: // advanced pixel-perfect bubble
- begin
- if FTeam = TEAM_RED then
- Rb := 255
- else
- if FTeam = TEAM_BLUE then
- Bb := 255;
- end;
- 3: // colored bubble
- begin
- Rb := FModel.Color.R;
- Gb := FModel.Color.G;
- Bb := FModel.Color.B;
- Rw := Min(Rb * 2 + 64, 255);
- Gw := Min(Gb * 2 + 64, 255);
- Bw := Min(Bb * 2 + 64, 255);
- if (Abs(Rw - Rb) < 32)
- or (Abs(Gw - Gb) < 32)
- or (Abs(Bw - Bb) < 32) then
- begin
- Rb := Max(Rw div 2 - 16, 0);
- Gb := Max(Gw div 2 - 16, 0);
- Bb := Max(Bw div 2 - 16, 0);
- end;
- end;
- 4: // custom textured bubble
- begin
- if g_Texture_Get('TEXTURE_PLAYER_TALKBUBBLE', ID) then
- if FDirection = TDirection.D_RIGHT then
- e_Draw(ID, bubX - 6, bubY - 7, 0, True, False)
- else
- e_Draw(ID, bubX - 6, bubY - 7, 0, True, False, TMirrorType.Horizontal);
- Exit;
- end;
- end;
-
- // Outer borders
- e_DrawQuad(bubX + 1, bubY , bubX + 18, bubY + 13, Rb, Gb, Bb);
- e_DrawQuad(bubX , bubY + 1, bubX + 19, bubY + 12, Rb, Gb, Bb);
- // Inner box
- e_DrawFillQuad(bubX + 1, bubY + 1, bubX + 18, bubY + 12, Rw, Gw, Bw, 0);
-
- // Tail
- Dot := IfThen(FDirection = TDirection.D_LEFT, 14, 5);
- e_DrawLine(1, bubX + Dot, bubY + 14, bubX + Dot, bubY + 16, Rb, Gb, Bb);
- e_DrawLine(1, bubX + IfThen(FDirection = TDirection.D_LEFT, Dot - 1, Dot + 1), bubY + 13, bubX + IfThen(FDirection = TDirection.D_LEFT, Dot - 1, Dot + 1), bubY + 15, Rw, Gw, Bw);
- e_DrawLine(1, bubX + IfThen(FDirection = TDirection.D_LEFT, Dot - 2, Dot + 2), bubY + 13, bubX + IfThen(FDirection = TDirection.D_LEFT, Dot - 2, Dot + 2), bubY + 14, Rw, Gw, Bw);
- e_DrawLine(1, bubX + IfThen(FDirection = TDirection.D_LEFT, Dot - 3, Dot + 3), bubY + 13, bubX + IfThen(FDirection = TDirection.D_LEFT, Dot - 3, Dot + 3), bubY + 13, Rw, Gw, Bw);
- e_DrawLine(1, bubX + IfThen(FDirection = TDirection.D_LEFT, Dot - 3, Dot + 3), bubY + 14, bubX + IfThen(FDirection = TDirection.D_LEFT, Dot - 1, Dot + 1), bubY + 16, Rb, Gb, Bb);
-
- // Dots
- Dot := 6;
- e_DrawFillQuad(bubX + Dot, bubY + 8, bubX + Dot + 1, bubY + 9, Rb, Gb, Bb, 0);
- e_DrawFillQuad(bubX + Dot + 3, bubY + 8, bubX + Dot + 4, bubY + 9, Rb, Gb, Bb, 0);
- e_DrawFillQuad(bubX + Dot + 6, bubY + 8, bubX + Dot + 7, bubY + 9, Rb, Gb, Bb, 0);
-end;
-
-procedure TPlayer.Draw();
-var
- ID: DWORD;
- w, h: Word;
- dr: Boolean;
- Mirror: TMirrorType;
-begin
- if FAlive then
- begin
- if Direction = TDirection.D_RIGHT then
- Mirror := TMirrorType.None
- else
- Mirror := TMirrorType.Horizontal;
-
- if FPunchAnim <> nil then
- begin
- FPunchAnim.Draw(FObj.X+IfThen(Direction = TDirection.D_LEFT, 15-FObj.Rect.X, FObj.Rect.X-15),
- FObj.Y+FObj.Rect.Y-11, Mirror);
- if FPunchAnim.played then
- begin
- FPunchAnim.Free;
- FPunchAnim := nil;
- end;
- end;
-
- if (FMegaRulez[MR_INVUL] > gTime) and (gPlayerDrawn <> Self) then
- if g_Texture_Get('TEXTURE_PLAYER_INVULPENTA', ID) then
- begin
- e_GetTextureSize(ID, @w, @h);
- if FDirection = TDirection.D_LEFT then
- e_Draw(ID, FObj.X+FObj.Rect.X+(FObj.Rect.Width div 2)-(w div 2)+4,
- FObj.Y+FObj.Rect.Y+(FObj.Rect.Height div 2)-(h div 2)-7+FObj.slopeUpLeft, 0, True, False)
- else
- e_Draw(ID, FObj.X+FObj.Rect.X+(FObj.Rect.Width div 2)-(w div 2)-2,
- FObj.Y+FObj.Rect.Y+(FObj.Rect.Height div 2)-(h div 2)-7+FObj.slopeUpLeft, 0, True, False);
- end;
-
- if FMegaRulez[MR_INVIS] > gTime then
- begin
- if (gPlayerDrawn <> nil) and ((Self = gPlayerDrawn) or
- ((FTeam = gPlayerDrawn.Team) and (gGameSettings.GameMode <> GM_DM))) then
- begin
- if (FMegaRulez[MR_INVIS] - gTime) <= 2100 then
- dr := not Odd((FMegaRulez[MR_INVIS] - gTime) div 300)
- else
- dr := True;
- if dr then
- FModel.Draw(FObj.X, FObj.Y+FObj.slopeUpLeft, 200)
- else
- FModel.Draw(FObj.X, FObj.Y+FObj.slopeUpLeft);
- end
- else
- FModel.Draw(FObj.X, FObj.Y+FObj.slopeUpLeft, 254);
- end
- else
- FModel.Draw(FObj.X, FObj.Y+FObj.slopeUpLeft);
- end;
-
- if g_debug_Frames then
- begin
- e_DrawQuad(FObj.X+FObj.Rect.X,
- FObj.Y+FObj.Rect.Y,
- FObj.X+FObj.Rect.X+FObj.Rect.Width-1,
- FObj.Y+FObj.Rect.Y+FObj.Rect.Height-1,
- 0, 255, 0);
- end;
-
- if (gChatBubble > 0) and (FKeys[KEY_CHAT].Pressed) and not FGhost then
- DrawBubble();
- // e_DrawPoint(5, 335, 288, 255, 0, 0); // DL, UR, DL, UR
- if gAimLine and alive and
- ((Self = gPlayer1) or (Self = gPlayer2)) then
- DrawAim();
-end;
-
-
-procedure TPlayer.DrawAim();
- procedure drawCast (sz: Integer; ax0, ay0, ax1, ay1: Integer);
- var
- ex, ey: Integer;
- begin
-
-{$IFDEF ENABLE_HOLMES}
- if isValidViewPort and (self = gPlayer1) then
- begin
- g_Holmes_plrLaser(ax0, ay0, ax1, ay1);
- end;
-{$ENDIF}
-
- e_DrawLine(sz, ax0, ay0, ax1, ay1, 255, 0, 0, 96);
- if (g_Map_traceToNearestWall(ax0, ay0, ax1, ay1, @ex, @ey) <> nil) then
- begin
- e_DrawLine(sz, ax0, ay0, ex, ey, 0, 255, 0, 96);
- end
- else
- begin
- e_DrawLine(sz, ax0, ay0, ex, ey, 0, 0, 255, 96);
- end;
- end;
-
-var
- wx, wy, xx, yy: Integer;
- angle: SmallInt;
- sz, len: Word;
-begin
- wx := FObj.X + WEAPONPOINT[FDirection].X + IfThen(FDirection = TDirection.D_LEFT, 7, -7);
- wy := FObj.Y + WEAPONPOINT[FDirection].Y;
- angle := FAngle;
- len := 1024;
- sz := 2;
- case FCurrWeap of
- 0: begin // Punch
- len := 12;
- sz := 4;
- end;
- 1: begin // Chainsaw
- len := 24;
- sz := 6;
- end;
- 2: begin // Pistol
- len := 1024;
- sz := 2;
- if angle = ANGLE_RIGHTUP then Dec(angle, 2);
- if angle = ANGLE_RIGHTDOWN then Inc(angle, 4);
- if angle = ANGLE_LEFTUP then Inc(angle, 2);
- if angle = ANGLE_LEFTDOWN then Dec(angle, 4);
- end;
- 3: begin // Shotgun
- len := 1024;
- sz := 3;
- if angle = ANGLE_RIGHTUP then Dec(angle, 2);
- if angle = ANGLE_RIGHTDOWN then Inc(angle, 4);
- if angle = ANGLE_LEFTUP then Inc(angle, 2);
- if angle = ANGLE_LEFTDOWN then Dec(angle, 4);
- end;
- 4: begin // Double Shotgun
- len := 1024;
- sz := 4;
- if angle = ANGLE_RIGHTUP then Dec(angle, 2);
- if angle = ANGLE_RIGHTDOWN then Inc(angle, 4);
- if angle = ANGLE_LEFTUP then Inc(angle, 2);
- if angle = ANGLE_LEFTDOWN then Dec(angle, 4);
- end;
- 5: begin // Chaingun
- len := 1024;
- sz := 3;
- if angle = ANGLE_RIGHTUP then Dec(angle, 2);
- if angle = ANGLE_RIGHTDOWN then Inc(angle, 4);
- if angle = ANGLE_LEFTUP then Inc(angle, 2);
- if angle = ANGLE_LEFTDOWN then Dec(angle, 4);
- end;
- 6: begin // Rocket Launcher
- len := 1024;
- sz := 7;
- if angle = ANGLE_RIGHTUP then Inc(angle, 2);
- if angle = ANGLE_RIGHTDOWN then Inc(angle, 4);
- if angle = ANGLE_LEFTUP then Dec(angle, 2);
- if angle = ANGLE_LEFTDOWN then Dec(angle, 4);
- end;
- 7: begin // Plasmagun
- len := 1024;
- sz := 5;
- if angle = ANGLE_RIGHTUP then Inc(angle);
- if angle = ANGLE_RIGHTDOWN then Inc(angle, 3);
- if angle = ANGLE_LEFTUP then Dec(angle);
- if angle = ANGLE_LEFTDOWN then Dec(angle, 3);
- end;
- 8: begin // BFG
- len := 1024;
- sz := 12;
- if angle = ANGLE_RIGHTUP then Inc(angle, 1);
- if angle = ANGLE_RIGHTDOWN then Inc(angle, 2);
- if angle = ANGLE_LEFTUP then Dec(angle, 1);
- if angle = ANGLE_LEFTDOWN then Dec(angle, 2);
- end;
- 9: begin // Super Chaingun
- len := 1024;
- sz := 4;
- if angle = ANGLE_RIGHTUP then Dec(angle, 2);
- if angle = ANGLE_RIGHTDOWN then Inc(angle, 4);
- if angle = ANGLE_LEFTUP then Inc(angle, 2);
- if angle = ANGLE_LEFTDOWN then Dec(angle, 4);
- end;
- end;
- xx := Trunc(Cos(-DegToRad(angle)) * len) + wx;
- yy := Trunc(Sin(-DegToRad(angle)) * len) + wy;
- {$IF DEFINED(D2F_DEBUG)}
- drawCast(sz, wx, wy, xx, yy);
- {$ELSE}
- e_DrawLine(sz, wx, wy, xx, yy, 255, 0, 0, 96);
- {$ENDIF}
-end;
-
-procedure TPlayer.DrawGUI();
-var
- ID: DWORD;
- X, Y, SY, a, p, m: Integer;
- tw, th: Word;
- cw, ch: Byte;
- s: string;
- stat: TPlayerStatArray;
-begin
- X := gPlayerScreenSize.X;
- SY := gPlayerScreenSize.Y;
- Y := 0;
-
- if gShowGoals and (gGameSettings.GameMode in [GM_TDM, GM_CTF]) then
- begin
- if gGameSettings.GameMode = GM_CTF then
- a := 32 + 8
- else
- a := 0;
- if gGameSettings.GameMode = GM_CTF then
- begin
- s := 'TEXTURE_PLAYER_REDFLAG';
- if gFlags[FLAG_RED].State = FLAG_STATE_CAPTURED then
- s := 'TEXTURE_PLAYER_REDFLAG_S';
- if gFlags[FLAG_RED].State = FLAG_STATE_DROPPED then
- s := 'TEXTURE_PLAYER_REDFLAG_D';
- if g_Texture_Get(s, ID) then
- e_Draw(ID, X-16-32, 240-72-4, 0, True, False);
- end;
-
- s := IntToStr(gTeamStat[TEAM_RED].Goals);
- e_CharFont_GetSize(gMenuFont, s, tw, th);
- e_CharFont_PrintEx(gMenuFont, X-16-a-tw, 240-72-4, s, TEAMCOLOR[TEAM_RED]);
-
- if gGameSettings.GameMode = GM_CTF then
- begin
- s := 'TEXTURE_PLAYER_BLUEFLAG';
- if gFlags[FLAG_BLUE].State = FLAG_STATE_CAPTURED then
- s := 'TEXTURE_PLAYER_BLUEFLAG_S';
- if gFlags[FLAG_BLUE].State = FLAG_STATE_DROPPED then
- s := 'TEXTURE_PLAYER_BLUEFLAG_D';
- if g_Texture_Get(s, ID) then
- e_Draw(ID, X-16-32, 240-32-4, 0, True, False);
- end;
-
- s := IntToStr(gTeamStat[TEAM_BLUE].Goals);
- e_CharFont_GetSize(gMenuFont, s, tw, th);
- e_CharFont_PrintEx(gMenuFont, X-16-a-tw, 240-32-4, s, TEAMCOLOR[TEAM_BLUE]);
- end;
-
- if g_Texture_Get('TEXTURE_PLAYER_HUDBG', ID) then
- e_DrawFill(ID, X, 0, 1, (gPlayerScreenSize.Y div 256)+IfThen(gPlayerScreenSize.Y mod 256 > 0, 1, 0),
- 0, False, False);
-
- if g_Texture_Get('TEXTURE_PLAYER_HUD', ID) then
- e_Draw(ID, X+2, Y, 0, True, False);
-
- if gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT] then
- begin
- if gShowStat then
- begin
- s := IntToStr(Frags);
- e_CharFont_GetSize(gMenuFont, s, tw, th);
- e_CharFont_PrintEx(gMenuFont, X-16-tw, Y, s, _RGB(255, 0, 0));
-
- s := '';
- p := 1;
- m := 0;
- stat := g_Player_GetStats();
- if stat <> nil then
- begin
- p := 1;
-
- for a := 0 to High(stat) do
- if stat[a].Name <> Name then
- begin
- if stat[a].Frags > m then m := stat[a].Frags;
- if stat[a].Frags > Frags then p := p+1;
- end;
- end;
-
- s := IntToStr(p)+' / '+IntToStr(Length(stat))+' ';
- if Frags >= m then s := s+'+' else s := s+'-';
- s := s+IntToStr(Abs(Frags-m));
-
- e_CharFont_GetSize(gMenuSmallFont, s, tw, th);
- e_CharFont_PrintEx(gMenuSmallFont, X-16-tw, Y+32, s, _RGB(255, 0, 0));
- end;
-
- if gShowLives and (gGameSettings.MaxLives > 0) then
- begin
- s := IntToStr(Lives);
- e_CharFont_GetSize(gMenuFont, s, tw, th);
- e_CharFont_PrintEx(gMenuFont, X-16-tw, SY-32, s, _RGB(0, 255, 0));
- end;
- end;
-
- e_CharFont_GetSize(gMenuSmallFont, FName, tw, th);
- e_CharFont_PrintEx(gMenuSmallFont, X+98-(tw div 2), Y+8, FName, _RGB(255, 0, 0));
-
- if R_BERSERK in FRulez then
- e_Draw(gItemsTexturesID[ITEM_MEDKIT_BLACK], X+37, Y+45, 0, True, False)
- else
- e_Draw(gItemsTexturesID[ITEM_MEDKIT_LARGE], X+37, Y+45, 0, True, False);
-
- if g_Texture_Get('TEXTURE_PLAYER_ARMORHUD', ID) then
- e_Draw(ID, X+36, Y+77, 0, True, False);
-
- s := IntToStr(IfThen(FHealth > 0, FHealth, 0));
- e_CharFont_GetSize(gMenuFont, s, tw, th);
- e_CharFont_PrintEx(gMenuFont, X+178-tw, Y+40, s, _RGB(255, 0, 0));
-
- s := IntToStr(FArmor);
- e_CharFont_GetSize(gMenuFont, s, tw, th);
- e_CharFont_PrintEx(gMenuFont, X+178-tw, Y+68, s, _RGB(255, 0, 0));
-
- s := IntToStr(GetAmmoByWeapon(FCurrWeap));
-
- case FCurrWeap of
- WEAPON_KASTET:
- begin
- s := '--';
- ID := gItemsTexturesID[ITEM_WEAPON_KASTET];
- end;
- WEAPON_SAW:
- begin
- s := '--';
- ID := gItemsTexturesID[ITEM_WEAPON_SAW];
- end;
- WEAPON_PISTOL: ID := gItemsTexturesID[ITEM_WEAPON_PISTOL];
- WEAPON_CHAINGUN: ID := gItemsTexturesID[ITEM_WEAPON_CHAINGUN];
- WEAPON_SHOTGUN1: ID := gItemsTexturesID[ITEM_WEAPON_SHOTGUN1];
- WEAPON_SHOTGUN2: ID := gItemsTexturesID[ITEM_WEAPON_SHOTGUN2];
- WEAPON_SUPERPULEMET: ID := gItemsTexturesID[ITEM_WEAPON_SUPERPULEMET];
- WEAPON_ROCKETLAUNCHER: ID := gItemsTexturesID[ITEM_WEAPON_ROCKETLAUNCHER];
- WEAPON_PLASMA: ID := gItemsTexturesID[ITEM_WEAPON_PLASMA];
- WEAPON_BFG: ID := gItemsTexturesID[ITEM_WEAPON_BFG];
- WEAPON_FLAMETHROWER: ID := gItemsTexturesID[ITEM_WEAPON_FLAMETHROWER];
- end;
-
- e_CharFont_GetSize(gMenuFont, s, tw, th);
- e_CharFont_PrintEx(gMenuFont, X+178-tw, Y+158, s, _RGB(255, 0, 0));
- e_Draw(ID, X+20, Y+160, 0, True, False);
+ begin
+ FLastSpawnerUID := SpawnerUID;
- if R_KEY_RED in FRulez then
- e_Draw(gItemsTexturesID[ITEM_KEY_RED], X+78, Y+214, 0, True, False);
+ // Кровь (пузырьки, если в воде):
+ if gBloodCount > 0 then
+ begin
+ c := Min(value, 200)*gBloodCount + Random(Min(value, 200) div 2);
+ if value div 4 <= c then
+ c := c - (value div 4)
+ else
+ c := 0;
- if R_KEY_GREEN in FRulez then
- e_Draw(gItemsTexturesID[ITEM_KEY_GREEN], X+95, Y+214, 0, True, False);
+ if (t = HIT_SOME) and (vx = 0) and (vy = 0) then
+ MakeBloodSimple(c)
+ else
+ case t of
+ HIT_TRAP, HIT_ACID, HIT_FLAME, HIT_SELF: MakeBloodSimple(c);
+ HIT_BFG, HIT_ROCKET, HIT_SOME: MakeBloodVector(c, vx, vy);
+ end;
- if R_KEY_BLUE in FRulez then
- e_Draw(gItemsTexturesID[ITEM_KEY_BLUE], X+112, Y+214, 0, True, False);
+ {$IFDEF ENABLE_GFX}
+ if t = HIT_WATER then
+ begin
+ g_GFX_Bubbles(FObj.X+PLAYER_RECT.X+(PLAYER_RECT.Width div 2),
+ FObj.Y+PLAYER_RECT.Y-4, value div 2, 8, 4);
+ if Random(2) = 0
+ then g_Sound_PlayExAt('SOUND_GAME_BUBBLE1', FObj.X, FObj.Y)
+ else g_Sound_PlayExAt('SOUND_GAME_BUBBLE2', FObj.X, FObj.Y);
+ end;
+ {$ENDIF}
+ end;
- if FJetFuel > 0 then
- begin
- if g_Texture_Get('TEXTURE_PLAYER_HUDAIR', ID) then
- e_Draw(ID, X+2, Y+116, 0, True, False);
- if g_Texture_Get('TEXTURE_PLAYER_HUDJET', ID) then
- e_Draw(ID, X+2, Y+126, 0, True, False);
- e_DrawLine(4, X+16, Y+122, X+16+Trunc(168*IfThen(FAir > 0, FAir, 0)/AIR_MAX), Y+122, 0, 0, 196);
- e_DrawLine(4, X+16, Y+132, X+16+Trunc(168*FJetFuel/JET_MAX), Y+132, 208, 0, 0);
- end
- else
- begin
- if g_Texture_Get('TEXTURE_PLAYER_HUDAIR', ID) then
- e_Draw(ID, X+2, Y+124, 0, True, False);
- e_DrawLine(4, X+16, Y+130, X+16+Trunc(168*IfThen(FAir > 0, FAir, 0)/AIR_MAX), Y+130, 0, 0, 196);
- end;
+ // Буфер урона:
+ if FAlive then
+ Inc(FDamageBuffer, value);
- if gShowPing and g_Game_IsClient then
- begin
- s := _lc[I_GAME_PING_HUD] + IntToStr(NetPeer.lastRoundTripTime) + _lc[I_NET_SLIST_PING_MS];
- e_TextureFontPrint(X + 4, Y + 242, s, gStdFont);
- Y := Y + 16;
+ // Вспышка боли:
+ if gFlash <> 0 then
+ FPain := FPain + value;
end;
end;
- if FSpectator then
+ if g_Game_IsServer and g_Game_IsNet then
begin
begin
- e_TextureFontPrint(X + 4, Y + 242, _lc[I_PLAYER_SPECT], gStdFont);
- e_TextureFontPrint(X + 4, Y + 258, _lc[I_PLAYER_SPECT2], gStdFont);
- e_TextureFontPrint(X + 4, Y + 274, _lc[I_PLAYER_SPECT1], gStdFont);
- if FNoRespawn then
- begin
- e_TextureFontGetSize(gStdFont, cw, ch);
- s := _lc[I_PLAYER_SPECT4];
- e_TextureFontPrintEx(gScreenWidth div 2 - cw*(Length(s) div 2),
- gScreenHeight-4-ch, s, gStdFont, 255, 255, 255, 1, True);
- e_TextureFontPrint(X + 4, Y + 290, _lc[I_PLAYER_SPECT1S], gStdFont);
- end;
-
+ MH_SEND_PlayerDamage(FUID, t, SpawnerUID, value, vx, vy);
+ MH_SEND_PlayerStats(FUID);
+ MH_SEND_PlayerPos(False, FUID);
end;
end;
end;
end;
-procedure TPlayer.DrawRulez();
-var
- dr: Boolean;
+function TPlayer.Heal(value: Word; Soft: Boolean): Boolean;
begin
begin
- // Ïðè âçÿòèè íåóÿçâèìîñòè ðèñóåòñÿ èíâåðñèîííûé áåëûé ôîí
- if FMegaRulez[MR_INVUL] >= gTime then
- begin
- if (FMegaRulez[MR_INVUL]-gTime) <= 2100 then
- dr := not Odd((FMegaRulez[MR_INVUL]-gTime) div 300)
- else
- dr := True;
-
- if dr then
- e_DrawFillQuad(0, 0, gPlayerScreenSize.X-1, gPlayerScreenSize.Y-1,
- 191, 191, 191, 0, TBlending.Invert);
- end;
+ Result := False;
+ if g_Game_IsClient then
+ Exit;
+ if not FAlive then
+ Exit;
- // Ïðè âçÿòèè çàùèòíîãî êîñòþìà ðèñóåòñÿ çåëåíîâàòûé ôîí
- if FMegaRulez[MR_SUIT] >= gTime then
+ if Soft and (FHealth < PLAYER_HP_SOFT) then
begin
begin
- if (FMegaRulez[MR_SUIT]-gTime) <= 2100 then
- dr := not Odd((FMegaRulez[MR_SUIT]-gTime) div 300)
- else
- dr := True;
-
- if dr then
- e_DrawFillQuad(0, 0, gPlayerScreenSize.X-1, gPlayerScreenSize.Y-1,
- 0, 96, 0, 200, TBlending.None);
+ IncMax(FHealth, value, PLAYER_HP_SOFT);
+ Result := True;
end;
end;
-
- // Ïðè âçÿòèè áåðñåðêà ðèñóåòñÿ êðàñíîâàòûé ôîí
- if (FBerserk >= 0) and (LongWord(FBerserk) >= gTime) and (gFlash = 2) then
+ if (not Soft) and (FHealth < PLAYER_HP_LIMIT) then
begin
begin
- e_DrawFillQuad(0, 0, gPlayerScreenSize.X-1, gPlayerScreenSize.Y-1,
- 255, 0, 0, 200, TBlending.None);
+ IncMax(FHealth, value, PLAYER_HP_LIMIT);
+ Result := True;
end;
end;
-end;
-
-procedure TPlayer.DrawPain();
-var
- a, h: Integer;
-begin
- if FPain = 0 then Exit;
-
- a := FPain;
-
- if a < 15 then h := 0
- else if a < 35 then h := 1
- else if a < 55 then h := 2
- else if a < 75 then h := 3
- else if a < 95 then h := 4
- else h := 5;
- //if a > 255 then a := 255;
-
- e_DrawFillQuad(0, 0, gPlayerScreenSize.X-1, gPlayerScreenSize.Y-1, 255, 0, 0, 255-h*50);
- //e_DrawFillQuad(0, 0, gPlayerScreenSize.X-1, gPlayerScreenSize.Y-1, 255-min(128, a), 255-a, 255-a, 0, B_FILTER);
+ if Result and g_Game_IsServer and g_Game_IsNet then
+ MH_SEND_PlayerStats(FUID);
end;
end;
-procedure TPlayer.DrawPickup();
-var
- a, h: Integer;
+destructor TPlayer.Destroy();
begin
begin
- if FPickup = 0 then Exit;
-
- a := FPickup;
+ if (gPlayer1 <> nil) and (gPlayer1.FUID = FUID) then
+ gPlayer1 := nil;
+ if (gPlayer2 <> nil) and (gPlayer2.FUID = FUID) then
+ gPlayer2 := nil;
- if a < 15 then h := 1
- else if a < 35 then h := 2
- else if a < 55 then h := 3
- else if a < 75 then h := 4
- else h := 5;
+ FSawSound.Free();
+ FSawSoundIdle.Free();
+ FSawSoundHit.Free();
+ FSawSoundSelect.Free();
+ FFlameSoundOn.Free();
+ FFlameSoundOff.Free();
+ FFlameSoundWork.Free();
+ FJetSoundFly.Free();
+ FJetSoundOn.Free();
+ FJetSoundOff.Free();
+ FModel.Free();
+ FPunchAnim.Free();
- e_DrawFillQuad(0, 0, gPlayerScreenSize.X-1, gPlayerScreenSize.Y-1, 150, 200, 150, 255-h*50);
+ inherited;
end;
procedure TPlayer.DoPunch();
end;
procedure TPlayer.DoPunch();
-var
- id: DWORD;
- st: String;
begin
begin
- if FPunchAnim <> nil then begin
- FPunchAnim.reset();
- FPunchAnim.Free;
- FPunchAnim := nil;
- end;
- st := 'FRAMES_PUNCH';
- if R_BERSERK in FRulez then
- st := st + '_BERSERK';
- if FKeys[KEY_UP].Pressed then
- st := st + '_UP'
- else if FKeys[KEY_DOWN].Pressed then
- st := st + '_DN';
- g_Frames_Get(id, st);
- FPunchAnim := TAnimation.Create(id, False, 1);
+ FPunchAnim.Reset;
+ FPunchAnim.Enable;
end;
procedure TPlayer.Fire();
end;
procedure TPlayer.Fire();
locobj: TObj;
begin
if g_Game_IsClient then Exit;
locobj: TObj;
begin
if g_Game_IsClient then Exit;
-// FBFGFireCounter - âðåìÿ ïåðåä âûñòðåëîì (äëÿ BFG)
-// FReloading - âðåìÿ ïîñëå âûñòðåëà (äëÿ âñåãî)
+// FBFGFireCounter - время перед выстрелом (для BFG)
+// FReloading - время после выстрела (для всего)
if FSpectator then
begin
if FSpectator then
begin
FFireAngle := FAngle;
f := True;
DidFire := True;
FFireAngle := FAngle;
f := True;
DidFire := True;
- g_Player_CreateShell(GameX+PLAYER_RECT_CX, GameY+PLAYER_RECT_CX,
- GameVelX, GameVelY-2, SHELL_BULLET);
+ {$IFDEF ENABLE_SHELLS}
+ g_Shells_Create(GameX + PLAYER_RECT_CX, GameY + PLAYER_RECT_CX, GameVelX, GameVelY - 2, SHELL_BULLET);
+ {$ENDIF}
end;
WEAPON_SHOTGUN1:
end;
WEAPON_SHOTGUN1:
FFireAngle := FAngle;
f := True;
DidFire := True;
FFireAngle := FAngle;
f := True;
DidFire := True;
- FShellTimer := 10;
- FShellType := SHELL_SHELL;
+ {$IFDEF ENABLE_SHELLS}
+ FShellTimer := 10;
+ FShellType := SHELL_SHELL;
+ {$ENDIF}
end;
WEAPON_SHOTGUN2:
end;
WEAPON_SHOTGUN2:
FFireAngle := FAngle;
f := True;
DidFire := True;
FFireAngle := FAngle;
f := True;
DidFire := True;
- FShellTimer := 13;
- FShellType := SHELL_DBLSHELL;
+ {$IFDEF ENABLE_SHELLS}
+ FShellTimer := 13;
+ FShellType := SHELL_DBLSHELL;
+ {$ENDIF}
end;
WEAPON_CHAINGUN:
end;
WEAPON_CHAINGUN:
FFireAngle := FAngle;
f := True;
DidFire := True;
FFireAngle := FAngle;
f := True;
DidFire := True;
- g_Player_CreateShell(GameX+PLAYER_RECT_CX, GameY+PLAYER_RECT_CX,
- GameVelX, GameVelY-2, SHELL_BULLET);
+ {$IFDEF ENABLE_SHELLS}
+ g_Shells_Create(GameX + PLAYER_RECT_CX, GameY + PLAYER_RECT_CX, GameVelX, GameVelY - 2, SHELL_BULLET);
+ {$ENDIF}
end;
WEAPON_ROCKETLAUNCHER:
end;
WEAPON_ROCKETLAUNCHER:
FFireAngle := FAngle;
f := True;
DidFire := True;
FFireAngle := FAngle;
f := True;
DidFire := True;
- g_Player_CreateShell(GameX+PLAYER_RECT_CX, GameY+PLAYER_RECT_CX,
- GameVelX, GameVelY-2, SHELL_SHELL);
+ {$IFDEF ENABLE_SHELLS}
+ g_Shells_Create(GameX + PLAYER_RECT_CX, GameY + PLAYER_RECT_CX, GameVelX, GameVelY - 2, SHELL_SHELL);
+ {$ENDIF}
end;
WEAPON_FLAMETHROWER:
if FAmmo[A_FUEL] > 0 then
begin
g_Weapon_flame(wx, wy, xd, yd, FUID);
end;
WEAPON_FLAMETHROWER:
if FAmmo[A_FUEL] > 0 then
begin
g_Weapon_flame(wx, wy, xd, yd, FUID);
+ FlamerOn;
FReloading[FCurrWeap] := WEAPON_RELOAD[FCurrWeap];
Dec(FAmmo[A_FUEL]);
FFireAngle := FAngle;
f := True;
DidFire := True;
FReloading[FCurrWeap] := WEAPON_RELOAD[FCurrWeap];
Dec(FAmmo[A_FUEL]);
FFireAngle := FAngle;
f := True;
DidFire := True;
+ end
+ else
+ begin
+ FlamerOff;
+ if g_Game_IsNet and g_Game_IsServer then MH_SEND_PlayerStats(FUID);
end;
end;
end;
end;
PANEL_WATER or PANEL_ACID1 or PANEL_ACID2, True);
end;
PANEL_WATER or PANEL_ACID1 or PANEL_ACID2, True);
end;
+procedure TPlayer.FlamerOn;
+begin
+ FFlameSoundOff.Stop();
+ FFlameSoundOff.SetPosition(0);
+ if FFlaming then
+ begin
+ if (not FFlameSoundOn.IsPlaying()) and (not FFlameSoundWork.IsPlaying()) then
+ FFlameSoundWork.PlayAt(FObj.X, FObj.Y);
+ end
+ else
+ begin
+ FFlameSoundOn.PlayAt(FObj.X, FObj.Y);
+ FFlaming := True;
+ end;
+end;
+
+procedure TPlayer.FlamerOff;
+begin
+ if FFlaming then
+ begin
+ FFlameSoundOn.Stop();
+ FFlameSoundOn.SetPosition(0);
+ FFlameSoundWork.Stop();
+ FFlameSoundWork.SetPosition(0);
+ FFlameSoundOff.PlayAt(FObj.X, FObj.Y);
+ FFlaming := False;
+ end;
+end;
+
procedure TPlayer.JetpackOn;
begin
FJetSoundFly.Stop;
procedure TPlayer.JetpackOn;
begin
FJetSoundFly.Stop;
FJetSoundOff.PlayAt(FObj.X, FObj.Y);
end;
FJetSoundOff.PlayAt(FObj.X, FObj.Y);
end;
-procedure TPlayer.CatchFire(Attacker: Word);
+procedure TPlayer.CatchFire(Attacker: Word; Timeout: Integer = PLAYER_BURN_TIME);
begin
begin
- FFireTime := 100;
+ if Timeout <= 0 then
+ exit;
+ if (FMegaRulez[MR_SUIT] > gTime) or (FMegaRulez[MR_INVUL] > gTime) then
+ exit; // Не загораемся когда есть защита
+ if g_Obj_CollidePanel(@FObj, 0, 0, PANEL_WATER or PANEL_ACID1 or PANEL_ACID2) then
+ exit; // Не подгораем в воде на всякий случай
+ if FFireTime <= 0 then
+ g_Sound_PlayExAt('SOUND_IGNITE', FObj.X, FObj.Y);
+ FFireTime := Timeout;
FFireAttacker := Attacker;
if g_Game_IsNet and g_Game_IsServer then
MH_SEND_PlayerStats(FUID);
FFireAttacker := Attacker;
if g_Game_IsNet and g_Game_IsServer then
MH_SEND_PlayerStats(FUID);
begin
if gFly or FJetpack then
begin
begin
if gFly or FJetpack then
begin
- // Ïîëåò (÷èò-êîä èëè äæåòïàê):
+ // Полет (чит-код или джетпак):
if FObj.Vel.Y > -VEL_FLY then
FObj.Vel.Y := FObj.Vel.Y - 3;
if FJetpack then
if FObj.Vel.Y > -VEL_FLY then
FObj.Vel.Y := FObj.Vel.Y - 3;
if FJetpack then
Exit;
end;
Exit;
end;
-// Íå âêëþ÷àòü äæåòïàê â ðåæèìå ïðîõîæäåíèÿ ñêâîçü ñòåíû
+// Не включать джетпак в режиме прохождения сквозь стены
if FGhost then
FCanJetpack := False;
if FGhost then
FCanJetpack := False;
-// Ïðûãàåì èëè âñïëûâàåì:
+// Прыгаем или всплываем:
if (CollideLevel(0, 1) or
g_Map_CollidePanel(FObj.X+PLAYER_RECT.X, FObj.Y+PLAYER_RECT.Y+36, PLAYER_RECT.Width,
PLAYER_RECT.Height-33, PANEL_STEP, False)
if (CollideLevel(0, 1) or
g_Map_CollidePanel(FObj.X+PLAYER_RECT.X, FObj.Y+PLAYER_RECT.Y+36, PLAYER_RECT.Width,
PLAYER_RECT.Height-33, PANEL_STEP, False)
- ) and (FObj.Accel.Y = 0) then // Íå ïðûãàòü, åñëè åñòü âåðòèêàëüíîå óñêîðåíèå
+ ) and (FObj.Accel.Y = 0) then // Не прыгать, если есть вертикальное ускорение
begin
FObj.Vel.Y := -VEL_JUMP;
FCanJetpack := False;
begin
FObj.Vel.Y := -VEL_JUMP;
FCanJetpack := False;
FPhysics := True;
FAlive := False;
end;
FPhysics := True;
FAlive := False;
end;
- FShellTimer := -1;
+
+ {$IFDEF ENABLE_SHELLS}
+ FShellTimer := -1;
+ {$ENDIF}
if (gGameSettings.MaxLives > 0) and Srv and (gLMSRespawn = LMS_RESPAWN_NONE) then
begin
if (gGameSettings.MaxLives > 0) and Srv and (gLMSRespawn = LMS_RESPAWN_NONE) then
begin
if FLives = 0 then FNoRespawn := True;
end;
if FLives = 0 then FNoRespawn := True;
end;
-// Íîìåð òèïà ñìåðòè:
+// Номер типа смерти:
a := 1;
case KillType of
K_SIMPLEKILL: a := 1;
a := 1;
case KillType of
K_SIMPLEKILL: a := 1;
K_FALLKILL: a := 4;
end;
K_FALLKILL: a := 4;
end;
-// Çâóê ñìåðòè:
+// Звук смерти:
if not FModel.PlaySound(MODELSOUND_DIE, a, FObj.X, FObj.Y) then
for i := 1 to 3 do
if FModel.PlaySound(MODELSOUND_DIE, i, FObj.X, FObj.Y) then
Break;
if not FModel.PlaySound(MODELSOUND_DIE, a, FObj.X, FObj.Y) then
for i := 1 to 3 do
if FModel.PlaySound(MODELSOUND_DIE, i, FObj.X, FObj.Y) then
Break;
-// Âðåìÿ ðåñïàóíà:
+// Время респауна:
if Srv then
case KillType of
K_SIMPLEKILL:
if Srv then
case KillType of
K_SIMPLEKILL:
FTime[T_RESPAWN] := gTime + TIME_RESPAWN3;
end;
FTime[T_RESPAWN] := gTime + TIME_RESPAWN3;
end;
-// Ïåðåêëþ÷àåì ñîñòîÿíèå:
+// Переключаем состояние:
case KillType of
K_SIMPLEKILL:
SetAction(A_DIE1);
case KillType of
K_SIMPLEKILL:
SetAction(A_DIE1);
SetAction(A_DIE2);
end;
SetAction(A_DIE2);
end;
-// Ðåàêöèÿ ìîíñòðîâ íà ñìåðòü èãðîêà:
+// РеакÑ\86иÑ\8f монÑ\81Ñ\82Ñ\80ов на Ñ\81меÑ\80Ñ\82Ñ\8c игÑ\80ока:
if (KillType <> K_FALLKILL) and (Srv) then
g_Monsters_killedp();
if SpawnerUID = FUID then
if (KillType <> K_FALLKILL) and (Srv) then
g_Monsters_killedp();
if SpawnerUID = FUID then
- begin // Ñàìîóáèëñÿ
- if Srv and (DoFrags or (gGameSettings.GameMode = GM_TDM)) then
+ begin // Самоубился
+ if Srv then
begin
begin
- Dec(FFrags);
- FLastFrag := 0;
+ if gGameSettings.GameMode = GM_TDM then
+ Dec(gTeamStat[FTeam].Score);
+ if DoFrags or (gGameSettings.GameMode = GM_TDM) then
+ begin
+ Dec(FFrags);
+ FLastFrag := 0;
+ end;
end;
g_Console_Add(Format(_lc[I_PLAYER_KILL_SELF], [FName]), True);
end
else
if g_GetUIDType(SpawnerUID) = UID_PLAYER then
end;
g_Console_Add(Format(_lc[I_PLAYER_KILL_SELF], [FName]), True);
end
else
if g_GetUIDType(SpawnerUID) = UID_PLAYER then
- begin // Óáèò äðóãèì èãðîêîì
+ begin // Убит другим игроком
KP := g_Player_Get(SpawnerUID);
if (KP <> nil) and Srv then
begin
KP := g_Player_Get(SpawnerUID);
if (KP <> nil) and Srv then
begin
end;
if (gGameSettings.GameMode = GM_TDM) and DoFrags then
end;
if (gGameSettings.GameMode = GM_TDM) and DoFrags then
- Inc(gTeamStat[KP.Team].Goals,
+ Inc(gTeamStat[KP.Team].Score,
IfThen(SameTeam(FUID, SpawnerUID), -1, 1));
if netsrv then MH_SEND_PlayerStats(SpawnerUID);
IfThen(SameTeam(FUID, SpawnerUID), -1, 1));
if netsrv then MH_SEND_PlayerStats(SpawnerUID);
end;
end
else if g_GetUIDType(SpawnerUID) = UID_MONSTER then
end;
end
else if g_GetUIDType(SpawnerUID) = UID_MONSTER then
- begin // Óáèò ìîíñòðîì
+ begin // Убит монстром
mon := g_Monsters_ByUID(SpawnerUID);
if mon = nil then
s := '?'
mon := g_Monsters_ByUID(SpawnerUID);
if mon = nil then
s := '?'
gShowKillMsg);
end;
end
gShowKillMsg);
end;
end
- else // Îñîáûå òèïû ñìåðòè
+ else // Особые типы смерти
case t of
HIT_DISCON: ;
HIT_SELF: g_Console_Add(Format(_lc[I_PLAYER_KILL_SELF], [FName]), True);
case t of
HIT_DISCON: ;
HIT_SELF: g_Console_Add(Format(_lc[I_PLAYER_KILL_SELF], [FName]), True);
if Srv then
begin
if Srv then
begin
-// Âûáðîñ îðóæèÿ:
+// Выброс оружия:
for a := WP_FIRST to WP_LAST do
if FWeapon[a] then
begin
for a := WP_FIRST to WP_LAST do
if FWeapon[a] then
begin
PushItem(i);
end;
PushItem(i);
end;
-// Âûáðîñ ðþêçàêà:
+// Выброс рюкзака:
if R_ITEM_BACKPACK in FRulez then
PushItem(ITEM_AMMO_BACKPACK);
if R_ITEM_BACKPACK in FRulez then
PushItem(ITEM_AMMO_BACKPACK);
-// Âûáðîñ ðàêåòíîãî ðàíöà:
+// Выброс ракетного ранца:
if FJetFuel > 0 then
PushItem(ITEM_JETPACK);
if FJetFuel > 0 then
PushItem(ITEM_JETPACK);
-// Âûáðîñ êëþ÷åé:
- if not (gGameSettings.GameMode in [GM_DM, GM_TDM, GM_CTF]) then
+// Выброс ключей:
+ if (not (gGameSettings.GameMode in [GM_DM, GM_TDM, GM_CTF])) or
+ (not LongBool(gGameSettings.Options and GAME_OPTION_DMKEYS)) then
begin
if R_KEY_RED in FRulez then
PushItem(ITEM_KEY_RED);
begin
if R_KEY_RED in FRulez then
PushItem(ITEM_KEY_RED);
PushItem(ITEM_KEY_BLUE);
end;
PushItem(ITEM_KEY_BLUE);
end;
-// Âûáðîñ ôëàãà:
- DropFlag();
+// Выброс флага:
+ DropFlag(KillType = K_FALLKILL);
end;
end;
- g_Player_CreateCorpse(Self);
+ {$IFDEF ENABLE_CORPSES}
+ FCorpse := g_Corpses_Create(Self);
+ {$ENDIF}
if Srv and (gGameSettings.MaxLives > 0) and FNoRespawn and
(gLMSRespawn = LMS_RESPAWN_NONE) then
if Srv and (gGameSettings.MaxLives > 0) and FNoRespawn and
(gLMSRespawn = LMS_RESPAWN_NONE) then
g_Game_Message(Format(_lc[I_MESSAGE_TLMS_WIN], [AnsiUpperCase(_lc[I_GAME_TEAM_RED])]), 144);
if Netsrv then
MH_SEND_GameEvent(NET_EV_TLMS_WIN, TEAM_RED);
g_Game_Message(Format(_lc[I_MESSAGE_TLMS_WIN], [AnsiUpperCase(_lc[I_GAME_TEAM_RED])]), 144);
if Netsrv then
MH_SEND_GameEvent(NET_EV_TLMS_WIN, TEAM_RED);
- Inc(gTeamStat[TEAM_RED].Goals);
+ Inc(gTeamStat[TEAM_RED].Score);
gLMSRespawn := LMS_RESPAWN_FINAL;
gLMSRespawnTime := gTime + 5000;
end
gLMSRespawn := LMS_RESPAWN_FINAL;
gLMSRespawnTime := gTime + 5000;
end
g_Game_Message(Format(_lc[I_MESSAGE_TLMS_WIN], [AnsiUpperCase(_lc[I_GAME_TEAM_BLUE])]), 144);
if Netsrv then
MH_SEND_GameEvent(NET_EV_TLMS_WIN, TEAM_BLUE);
g_Game_Message(Format(_lc[I_MESSAGE_TLMS_WIN], [AnsiUpperCase(_lc[I_GAME_TEAM_BLUE])]), 144);
if Netsrv then
MH_SEND_GameEvent(NET_EV_TLMS_WIN, TEAM_BLUE);
- Inc(gTeamStat[TEAM_BLUE].Goals);
+ Inc(gTeamStat[TEAM_BLUE].Score);
gLMSRespawn := LMS_RESPAWN_FINAL;
gLMSRespawnTime := gTime + 5000;
end
gLMSRespawn := LMS_RESPAWN_FINAL;
gLMSRespawnTime := gTime + 5000;
end
if srv and (OldLR = LMS_RESPAWN_NONE) and (gLMSRespawn > LMS_RESPAWN_NONE) then
begin
if NetMode = NET_SERVER then
if srv and (OldLR = LMS_RESPAWN_NONE) and (gLMSRespawn > LMS_RESPAWN_NONE) then
begin
if NetMode = NET_SERVER then
- MH_SEND_GameEvent(NET_EV_LMS_WARMUP, (gLMSRespawnTime - gTime) div 1000)
+ MH_SEND_GameEvent(NET_EV_LMS_WARMUP, gLMSRespawnTime - gTime)
else
g_Console_Add(Format(_lc[I_MSG_WARMUP_START], [(gLMSRespawnTime - gTime) div 1000]), True);
end;
else
g_Console_Add(Format(_lc[I_MSG_WARMUP_START], [(gLMSRespawnTime - gTime) div 1000]), True);
end;
end;
procedure TPlayer.MakeBloodSimple(Count: Word);
end;
procedure TPlayer.MakeBloodSimple(Count: Word);
+ {$IFDEF ENABLE_GFX}
+ var Blood: TModelBlood;
+ {$ENDIF}
begin
begin
- g_GFX_Blood(FObj.X+PLAYER_RECT.X+(PLAYER_RECT.Width div 2)+8,
- FObj.Y+PLAYER_RECT.Y+(PLAYER_RECT.Height div 2),
- Count div 2, 3, -1, 16, (PLAYER_RECT.Height*2 div 3),
- FModel.Blood.R, FModel.Blood.G, FModel.Blood.B, FModel.Blood.Kind);
- g_GFX_Blood(FObj.X+PLAYER_RECT.X+(PLAYER_RECT.Width div 2)-8,
- FObj.Y+PLAYER_RECT.Y+(PLAYER_RECT.Height div 2),
- Count div 2, -3, -1, 16, (PLAYER_RECT.Height*2) div 3,
- FModel.Blood.R, FModel.Blood.G, FModel.Blood.B, FModel.Blood.Kind);
+ {$IFDEF ENABLE_GFX}
+ Blood := SELF.FModel.GetBlood();
+ g_GFX_Blood(FObj.X+PLAYER_RECT.X+(PLAYER_RECT.Width div 2)+8,
+ FObj.Y+PLAYER_RECT.Y+(PLAYER_RECT.Height div 2),
+ Count div 2, 3, -1, 16, (PLAYER_RECT.Height*2 div 3),
+ Blood.R, Blood.G, Blood.B, Blood.Kind);
+ g_GFX_Blood(FObj.X+PLAYER_RECT.X+(PLAYER_RECT.Width div 2)-8,
+ FObj.Y+PLAYER_RECT.Y+(PLAYER_RECT.Height div 2),
+ Count div 2, -3, -1, 16, (PLAYER_RECT.Height*2) div 3,
+ Blood.R, Blood.G, Blood.B, Blood.Kind);
+ {$ENDIF}
end;
procedure TPlayer.MakeBloodVector(Count: Word; VelX, VelY: Integer);
end;
procedure TPlayer.MakeBloodVector(Count: Word; VelX, VelY: Integer);
+ {$IFDEF ENABLE_GFX}
+ var Blood: TModelBlood;
+ {$ENDIF}
+begin
+ {$IFDEF ENABLE_GFX}
+ Blood := SELF.FModel.GetBlood();
+ g_GFX_Blood(FObj.X+PLAYER_RECT.X+(PLAYER_RECT.Width div 2),
+ FObj.Y+PLAYER_RECT.Y+(PLAYER_RECT.Height div 2),
+ Count, VelX, VelY, 16, (PLAYER_RECT.Height*2) div 3,
+ Blood.R, Blood.G, Blood.B, Blood.Kind);
+ {$ENDIF}
+end;
+
+procedure TPlayer.ProcessWeaponAction(Action: Byte);
begin
begin
- g_GFX_Blood(FObj.X+PLAYER_RECT.X+(PLAYER_RECT.Width div 2),
- FObj.Y+PLAYER_RECT.Y+(PLAYER_RECT.Height div 2),
- Count, VelX, VelY, 16, (PLAYER_RECT.Height*2) div 3,
- FModel.Blood.R, FModel.Blood.G, FModel.Blood.B, FModel.Blood.Kind);
+ if g_Game_IsClient then Exit;
+ case Action of
+ WP_PREV: PrevWeapon();
+ WP_NEXT: NextWeapon();
+ end;
end;
procedure TPlayer.QueueWeaponSwitch(Weapon: Byte);
end;
procedure TPlayer.QueueWeaponSwitch(Weapon: Byte);
result := false;
case weapon of
WEAPON_KASTET, WEAPON_SAW: result := true;
result := false;
case weapon of
WEAPON_KASTET, WEAPON_SAW: result := true;
- WEAPON_SHOTGUN1, WEAPON_SHOTGUN2: result := (FAmmo[A_SHELLS] > 0);
- WEAPON_PISTOL, WEAPON_CHAINGUN, WEAPON_SUPERPULEMET: result := (FAmmo[A_BULLETS] > 0);
+ WEAPON_SHOTGUN1, WEAPON_SHOTGUN2, WEAPON_SUPERPULEMET: result := (FAmmo[A_SHELLS] > 0);
+ WEAPON_PISTOL, WEAPON_CHAINGUN: result := (FAmmo[A_BULLETS] > 0);
WEAPON_ROCKETLAUNCHER: result := (FAmmo[A_ROCKETS] > 0);
WEAPON_PLASMA, WEAPON_BFG: result := (FAmmo[A_CELLS] > 0);
WEAPON_FLAMETHROWER: result := (FAmmo[A_FUEL] > 0);
WEAPON_ROCKETLAUNCHER: result := (FAmmo[A_ROCKETS] > 0);
WEAPON_PLASMA, WEAPON_BFG: result := (FAmmo[A_CELLS] > 0);
WEAPON_FLAMETHROWER: result := (FAmmo[A_FUEL] > 0);
end;
end;
end;
end;
+function TPlayer.hasAmmoForShooting (weapon: Byte): Boolean;
+begin
+ result := false;
+ case weapon of
+ WEAPON_KASTET, WEAPON_SAW: result := true;
+ WEAPON_SHOTGUN1, WEAPON_SUPERPULEMET: result := (FAmmo[A_SHELLS] > 0);
+ WEAPON_SHOTGUN2: result := (FAmmo[A_SHELLS] > 1);
+ WEAPON_PISTOL, WEAPON_CHAINGUN: result := (FAmmo[A_BULLETS] > 0);
+ WEAPON_ROCKETLAUNCHER: result := (FAmmo[A_ROCKETS] > 0);
+ WEAPON_PLASMA: result := (FAmmo[A_CELLS] > 0);
+ WEAPON_BFG: result := (FAmmo[A_CELLS] >= 40);
+ WEAPON_FLAMETHROWER: result := (FAmmo[A_FUEL] > 0);
+ else result := (weapon < length(FWeapon));
+ end;
+end;
+
+function TPlayer.shouldSwitch (weapon: Byte; hadWeapon: Boolean): Boolean;
+begin
+ result := false;
+ if (weapon > WP_LAST + 1) then
+ begin
+ result := false;
+ exit;
+ end;
+ if (FWeapSwitchMode = 1) and not hadWeapon then
+ result := true
+ else if (FWeapSwitchMode = 2) then
+ result := (FWeapPreferences[weapon] > FWeapPreferences[FCurrWeap]);
+end;
+
// return 255 for "no switch"
function TPlayer.getNextWeaponIndex (): Byte;
var
i: Word;
wantThisWeapon: array[0..64] of Boolean;
// return 255 for "no switch"
function TPlayer.getNextWeaponIndex (): Byte;
var
i: Word;
wantThisWeapon: array[0..64] of Boolean;
- weaponOrder: array[0..16] of Integer; // value: index in `FWeapon`
- wwc: Integer;
- f, dir, cwi, rwidx, curlidx: Integer;
-
- function real2log (ridx: Integer): Integer;
- var
- f: Integer;
- begin
- if (ridx >= 0) then
- begin
- for f := 0 to High(weaponOrder) do if (weaponOrder[f] = ridx) then begin result := f; exit; end;
- end;
- result := -1;
- end;
-
+ wwc: Integer = 0; //HACK!
+ dir, cwi: Integer;
begin
result := 255; // default result: "no switch"
begin
result := 255; // default result: "no switch"
-
+ //e_LogWriteFln('FSWITCHTOEMPTY: %s', [FSwitchToEmpty], TMsgType.Notify);
// had weapon cycling on previous frame? remove that flag
if (FNextWeap and $2000) <> 0 then
begin
FNextWeap := FNextWeap and $1FFF;
FNextWeapDelay := 0;
end;
// had weapon cycling on previous frame? remove that flag
if (FNextWeap and $2000) <> 0 then
begin
FNextWeap := FNextWeap and $1FFF;
FNextWeapDelay := 0;
end;
-
- for f := 0 to High(weaponOrder) do weaponOrder[f] := -1;
-
- // build weapon order (k8: i know, i know, learn how to do constants and such... gtfo, please!)
- // two knuckles are for "normal" and "berserk" (see `if` below -- it removes the one that is not needed)
- // priorities:
- // bfg, launcher, plasma, flamethrower, ssg, minigun, sg, pistol, berserk, chainsaw, fist
- weaponOrder[0] := WEAPON_SUPERPULEMET;
- weaponOrder[1] := WEAPON_BFG;
- weaponOrder[2] := WEAPON_ROCKETLAUNCHER;
- weaponOrder[3] := WEAPON_PLASMA;
- weaponOrder[4] := WEAPON_FLAMETHROWER;
- weaponOrder[5] := WEAPON_SHOTGUN2;
- weaponOrder[6] := WEAPON_CHAINGUN;
- weaponOrder[7] := WEAPON_SHOTGUN1;
- weaponOrder[8] := WEAPON_PISTOL;
- weaponOrder[9] := WEAPON_KASTET+666; // berserk fist
- weaponOrder[10] := WEAPON_SAW;
- weaponOrder[11] := WEAPON_KASTET; // normal fist
-
- for f := 0 to High(weaponOrder) do
- begin
- if (weaponOrder[f] = WEAPON_KASTET) then
- begin
- // normal fist: remove if we have a berserk pack
- if (R_BERSERK in FRulez) then weaponOrder[f] := -1;
- end
- else
- if (weaponOrder[f] = WEAPON_KASTET+666) then
- begin
- // berserk fist: remove if we don't have a berserk pack
- if (R_BERSERK in FRulez) then weaponOrder[f] := WEAPON_KASTET else weaponOrder[f] := -1;
- end;
- end;
-
- (*
- WEAPON_KASTET = 0;
- WEAPON_SAW = 1;
- WEAPON_PISTOL = 2;
- WEAPON_SHOTGUN1 = 3;
- WEAPON_SHOTGUN2 = 4;
- WEAPON_CHAINGUN = 5;
- WEAPON_ROCKETLAUNCHER = 6;
- WEAPON_PLASMA = 7;
- WEAPON_BFG = 8;
- WEAPON_SUPERPULEMET = 9;
- WEAPON_FLAMETHROWER = 10;
- *)
-
// cycling has priority
if (FNextWeap and $C000) <> 0 then
begin
// cycling has priority
if (FNextWeap and $C000) <> 0 then
begin
- if (FNextWeap and $8000) <> 0 then dir := 1 else dir := -1; // should be reversed if we want "priority-driven cycling"
+ if (FNextWeap and $8000) <> 0 then
+ dir := 1
+ else
+ dir := -1;
FNextWeap := FNextWeap or $2000; // we need this
FNextWeap := FNextWeap or $2000; // we need this
- if FNextWeapDelay > 0 then exit; // cooldown time
- //cwi := real2log(FCurrWeap);
- //if (cwi < 0) then cwi := 0;
+ if FNextWeapDelay > 0 then
+ exit; // cooldown time
cwi := FCurrWeap;
for i := 0 to High(FWeapon) do
begin
cwi := (cwi+length(FWeapon)+dir) mod length(FWeapon);
cwi := FCurrWeap;
for i := 0 to High(FWeapon) do
begin
cwi := (cwi+length(FWeapon)+dir) mod length(FWeapon);
- //rwidx := weaponOrder[cwi];
- rwidx := cwi; // sorry
- if (rwidx < 0) then continue;
- if FWeapon[rwidx] then
+ if FWeapon[cwi] and maySwitch(cwi) then
begin
begin
- //e_WriteLog(Format(' SWITCH: cur=%d; new=%d (dir=%d; log=%d)', [FCurrWeap, rwidx, dir, cwi]), TMsgType.Warning);
- result := Byte(rwidx);
- FNextWeapDelay := 10;
+ //e_LogWriteFln(' SWITCH: cur=%d; new=%d %s %s', [FCurrWeap, cwi, FSwitchToEmpty, hasAmmoForWeapon(cwi)], TMsgType.Notify);
+ result := Byte(cwi);
+ FNextWeapDelay := WEAPON_DELAY;
exit;
end;
end;
resetWeaponQueue();
exit;
end;
exit;
end;
end;
resetWeaponQueue();
exit;
end;
-
// no cycling
// no cycling
- for i := 0 to High(wantThisWeapon) do wantThisWeapon[i] := false;
- wwc := 0;
+ for i := 0 to High(wantThisWeapon) do
+ wantThisWeapon[i] := false;
for i := 0 to High(FWeapon) do
for i := 0 to High(FWeapon) do
- begin
if (FNextWeap and (1 shl i)) <> 0 then
begin
if (FNextWeap and (1 shl i)) <> 0 then
begin
- cwi := real2log(i);
- if (cwi >= 0) then wantThisWeapon[cwi] := true;
+ wantThisWeapon[i] := true;
Inc(wwc);
end;
Inc(wwc);
end;
- end;
+ // exclude currently selected weapon from the set
+ wantThisWeapon[FCurrWeap] := false;
// slow down alterations a little
// slow down alterations a little
- if (wwc > 1) then
+ if wwc > 1 then
begin
begin
- // more than one weapon requested, assume "alteration", and check alteration delay
+ //e_WriteLog(Format(' FNextWeap=%x; delay=%d', [FNextWeap, FNextWeapDelay]), MSG_WARNING);
+ // more than one weapon requested, assume "alteration" and check alteration delay
if FNextWeapDelay > 0 then
begin
if FNextWeapDelay > 0 then
begin
- //e_WriteLog(Format(' FNextWeap=%x; delay=%d', [FNextWeap, FNextWeapDelay]), TMsgType.Warning);
FNextWeap := 0;
exit;
end; // yeah
end;
FNextWeap := 0;
exit;
end; // yeah
end;
-
// do not reset weapon queue, it will be done in `RealizeCurrentWeapon()`
// but clear all counters if no weapon should be switched
// do not reset weapon queue, it will be done in `RealizeCurrentWeapon()`
// but clear all counters if no weapon should be switched
- if (wwc < 1) then
+ if wwc < 1 then
begin
resetWeaponQueue();
exit;
end;
begin
resetWeaponQueue();
exit;
end;
-
- // exclude currently selected weapon from the set
- curlidx := real2log(FCurrWeap);
- //e_WriteLog(Format('*** wwc=%d; currweap=%d; logweap=%d', [wwc, FCurrWeap, curlidx]), TMsgType.Warning);
- //e_WriteLog(Format('FCurrWeap=%d; curlidx=%d', [FCurrWeap, curlidx]), TMsgType.Warning);
- //if (curlidx >= 0) then wantThisWeapon[curlidx] := false;
- //if (wwc = 2) then begin Dec(wwc); end; // easy case: switch between two weapons
-
- // find next weapon to switch onto
- cwi := curlidx;
- for i := 0 to High(FWeapon) do
+ //e_WriteLog(Format('wwc=%d', [wwc]), MSG_WARNING);
+ // try weapons in descending order
+ for i := High(FWeapon) downto 0 do
begin
begin
- cwi := (cwi+length(FWeapon)+1) mod length(FWeapon);
- if (cwi = curlidx) then continue; // skip current weapon
- if not wantThisWeapon[cwi] then continue;
- rwidx := weaponOrder[cwi];
- if (rwidx < 0) then continue;
- //e_WriteLog(Format(' trying logical %d (real %d)', [cwi, rwidx]), TMsgType.Warning);
- if FWeapon[rwidx] and ((wwc = 1) or hasAmmoForWeapon(rwidx)) then
+ if wantThisWeapon[i] and FWeapon[i] and ((wwc = 1) or hasAmmoForWeapon(i)) then
begin
begin
- //e_WriteLog(' I FOUND HER!', TMsgType.Warning);
// i found her!
// i found her!
- result := Byte(rwidx);
+ result := Byte(i);
resetWeaponQueue();
resetWeaponQueue();
- FNextWeapDelay := 10; // anyway, 'cause why not
+ FNextWeapDelay := WEAPON_DELAY * 2; // anyway, 'cause why not
+ //e_LogWriteFln('FOUND %s %s %s', [result, FSwitchToEmpty, hasAmmoForWeapon(i)], TMsgType.Notify);
exit;
end;
end;
exit;
end;
end;
-
// no suitable weapon found, so reset the queue, to avoid accidental "queuing" of weapon w/o ammo
resetWeaponQueue();
end;
// no suitable weapon found, so reset the queue, to avoid accidental "queuing" of weapon w/o ammo
resetWeaponQueue();
end;
end;
nw := getNextWeaponIndex();
end;
nw := getNextWeaponIndex();
+ //
if nw = 255 then exit; // don't reset anything here
if nw > High(FWeapon) then
begin
// don't forget to reset queue here!
if nw = 255 then exit; // don't reset anything here
if nw > High(FWeapon) then
begin
// don't forget to reset queue here!
- //e_WriteLog(Format(' RealizeCurrentWeapon: WUTAFUUUU?! (%d)', [nw]), TMsgType.Warning);
+ //e_WriteLog(' RealizeCurrentWeapon: WUTAFUUUU', MSG_WARNING);
resetWeaponQueue();
exit;
end;
resetWeaponQueue();
exit;
end;
end;
function TPlayer.PickItem(ItemType: Byte; arespawn: Boolean; var remove: Boolean): Boolean;
end;
function TPlayer.PickItem(ItemType: Byte; arespawn: Boolean; var remove: Boolean): Boolean;
-
- function allowBerserkSwitching (): Boolean;
- begin
- if (FBFGFireCounter <> -1) then begin result := false; exit; end;
- result := true;
- if gBerserkAutoswitch then exit;
- if not conIsCheatsEnabled then exit;
- result := false;
- end;
-
var
a: Boolean;
var
a: Boolean;
+ switchWeapon: Byte = 255;
+ hadWeapon: Boolean = False;
begin
Result := False;
if g_Game_IsClient then Exit;
begin
Result := False;
if g_Game_IsClient then Exit;
- // a = true - ìåñòî ñïàâíà ïðåäìåòà:
+ // a = true - место спавна предмета:
a := LongBool(gGameSettings.Options and GAME_OPTION_WEAPONSTAY) and arespawn;
remove := not a;
a := LongBool(gGameSettings.Options and GAME_OPTION_WEAPONSTAY) and arespawn;
remove := not a;
-
case ItemType of
ITEM_MEDKIT_SMALL:
case ItemType of
ITEM_MEDKIT_SMALL:
- if FHealth < PLAYER_HP_SOFT then
+ if (FHealth < PLAYER_HP_SOFT) or (FFireTime > 0) then
begin
begin
- IncMax(FHealth, 10, PLAYER_HP_SOFT);
+ if FHealth < PLAYER_HP_SOFT then IncMax(FHealth, 10, PLAYER_HP_SOFT);
Result := True;
remove := True;
FFireTime := 0;
Result := True;
remove := True;
FFireTime := 0;
end;
ITEM_MEDKIT_LARGE:
end;
ITEM_MEDKIT_LARGE:
- if FHealth < PLAYER_HP_SOFT then
+ if (FHealth < PLAYER_HP_SOFT) or (FFireTime > 0) then
begin
begin
- IncMax(FHealth, 25, PLAYER_HP_SOFT);
+ if FHealth < PLAYER_HP_SOFT then IncMax(FHealth, 25, PLAYER_HP_SOFT);
Result := True;
remove := True;
FFireTime := 0;
Result := True;
remove := True;
FFireTime := 0;
end;
ITEM_SPHERE_BLUE:
end;
ITEM_SPHERE_BLUE:
- if FHealth < PLAYER_HP_LIMIT then
+ if (FHealth < PLAYER_HP_LIMIT) or (FFireTime > 0) then
begin
begin
- IncMax(FHealth, 100, PLAYER_HP_LIMIT);
+ if FHealth < PLAYER_HP_LIMIT then IncMax(FHealth, 100, PLAYER_HP_LIMIT);
Result := True;
remove := True;
FFireTime := 0;
Result := True;
remove := True;
FFireTime := 0;
end;
ITEM_SPHERE_WHITE:
end;
ITEM_SPHERE_WHITE:
- if (FHealth < PLAYER_HP_LIMIT) or (FArmor < PLAYER_AP_LIMIT) then
+ if (FHealth < PLAYER_HP_LIMIT) or (FArmor < PLAYER_AP_LIMIT) or (FFireTime > 0) then
begin
if FHealth < PLAYER_HP_LIMIT then
FHealth := PLAYER_HP_LIMIT;
begin
if FHealth < PLAYER_HP_LIMIT then
FHealth := PLAYER_HP_LIMIT;
ITEM_WEAPON_SAW:
if (not FWeapon[WEAPON_SAW]) or ((not arespawn) and (gGameSettings.GameMode in [GM_DM, GM_TDM, GM_CTF])) then
begin
ITEM_WEAPON_SAW:
if (not FWeapon[WEAPON_SAW]) or ((not arespawn) and (gGameSettings.GameMode in [GM_DM, GM_TDM, GM_CTF])) then
begin
+ hadWeapon := FWeapon[WEAPON_SAW];
+ switchWeapon := WEAPON_SAW;
FWeapon[WEAPON_SAW] := True;
Result := True;
if gFlash = 2 then Inc(FPickup, 5);
FWeapon[WEAPON_SAW] := True;
Result := True;
if gFlash = 2 then Inc(FPickup, 5);
ITEM_WEAPON_SHOTGUN1:
if (FAmmo[A_SHELLS] < FMaxAmmo[A_SHELLS]) or not FWeapon[WEAPON_SHOTGUN1] then
begin
ITEM_WEAPON_SHOTGUN1:
if (FAmmo[A_SHELLS] < FMaxAmmo[A_SHELLS]) or not FWeapon[WEAPON_SHOTGUN1] then
begin
- // Íóæíî, ÷òîáû íå âçÿòü âñå ïóëè ñðàçó:
+ // Нужно, чтобы не взять все пули сразу:
if a and FWeapon[WEAPON_SHOTGUN1] then Exit;
if a and FWeapon[WEAPON_SHOTGUN1] then Exit;
-
+ hadWeapon := FWeapon[WEAPON_SHOTGUN1];
+ switchWeapon := WEAPON_SHOTGUN1;
IncMax(FAmmo[A_SHELLS], 4, FMaxAmmo[A_SHELLS]);
FWeapon[WEAPON_SHOTGUN1] := True;
Result := True;
IncMax(FAmmo[A_SHELLS], 4, FMaxAmmo[A_SHELLS]);
FWeapon[WEAPON_SHOTGUN1] := True;
Result := True;
if (FAmmo[A_SHELLS] < FMaxAmmo[A_SHELLS]) or not FWeapon[WEAPON_SHOTGUN2] then
begin
if a and FWeapon[WEAPON_SHOTGUN2] then Exit;
if (FAmmo[A_SHELLS] < FMaxAmmo[A_SHELLS]) or not FWeapon[WEAPON_SHOTGUN2] then
begin
if a and FWeapon[WEAPON_SHOTGUN2] then Exit;
-
+ hadWeapon := FWeapon[WEAPON_SHOTGUN2];
+ switchWeapon := WEAPON_SHOTGUN2;
IncMax(FAmmo[A_SHELLS], 4, FMaxAmmo[A_SHELLS]);
FWeapon[WEAPON_SHOTGUN2] := True;
Result := True;
IncMax(FAmmo[A_SHELLS], 4, FMaxAmmo[A_SHELLS]);
FWeapon[WEAPON_SHOTGUN2] := True;
Result := True;
if (FAmmo[A_BULLETS] < FMaxAmmo[A_BULLETS]) or not FWeapon[WEAPON_CHAINGUN] then
begin
if a and FWeapon[WEAPON_CHAINGUN] then Exit;
if (FAmmo[A_BULLETS] < FMaxAmmo[A_BULLETS]) or not FWeapon[WEAPON_CHAINGUN] then
begin
if a and FWeapon[WEAPON_CHAINGUN] then Exit;
-
+ hadWeapon := FWeapon[WEAPON_CHAINGUN];
+ switchWeapon := WEAPON_CHAINGUN;
IncMax(FAmmo[A_BULLETS], 50, FMaxAmmo[A_BULLETS]);
FWeapon[WEAPON_CHAINGUN] := True;
Result := True;
IncMax(FAmmo[A_BULLETS], 50, FMaxAmmo[A_BULLETS]);
FWeapon[WEAPON_CHAINGUN] := True;
Result := True;
if (FAmmo[A_ROCKETS] < FMaxAmmo[A_ROCKETS]) or not FWeapon[WEAPON_ROCKETLAUNCHER] then
begin
if a and FWeapon[WEAPON_ROCKETLAUNCHER] then Exit;
if (FAmmo[A_ROCKETS] < FMaxAmmo[A_ROCKETS]) or not FWeapon[WEAPON_ROCKETLAUNCHER] then
begin
if a and FWeapon[WEAPON_ROCKETLAUNCHER] then Exit;
-
+ switchWeapon := WEAPON_ROCKETLAUNCHER;
+ hadWeapon := FWeapon[WEAPON_ROCKETLAUNCHER];
IncMax(FAmmo[A_ROCKETS], 2, FMaxAmmo[A_ROCKETS]);
FWeapon[WEAPON_ROCKETLAUNCHER] := True;
Result := True;
IncMax(FAmmo[A_ROCKETS], 2, FMaxAmmo[A_ROCKETS]);
FWeapon[WEAPON_ROCKETLAUNCHER] := True;
Result := True;
if (FAmmo[A_CELLS] < FMaxAmmo[A_CELLS]) or not FWeapon[WEAPON_PLASMA] then
begin
if a and FWeapon[WEAPON_PLASMA] then Exit;
if (FAmmo[A_CELLS] < FMaxAmmo[A_CELLS]) or not FWeapon[WEAPON_PLASMA] then
begin
if a and FWeapon[WEAPON_PLASMA] then Exit;
-
+ switchWeapon := WEAPON_PLASMA;
+ hadWeapon := FWeapon[WEAPON_PLASMA];
IncMax(FAmmo[A_CELLS], 40, FMaxAmmo[A_CELLS]);
FWeapon[WEAPON_PLASMA] := True;
Result := True;
IncMax(FAmmo[A_CELLS], 40, FMaxAmmo[A_CELLS]);
FWeapon[WEAPON_PLASMA] := True;
Result := True;
if (FAmmo[A_CELLS] < FMaxAmmo[A_CELLS]) or not FWeapon[WEAPON_BFG] then
begin
if a and FWeapon[WEAPON_BFG] then Exit;
if (FAmmo[A_CELLS] < FMaxAmmo[A_CELLS]) or not FWeapon[WEAPON_BFG] then
begin
if a and FWeapon[WEAPON_BFG] then Exit;
-
+ switchWeapon := WEAPON_BFG;
+ hadWeapon := FWeapon[WEAPON_BFG];
IncMax(FAmmo[A_CELLS], 40, FMaxAmmo[A_CELLS]);
FWeapon[WEAPON_BFG] := True;
Result := True;
IncMax(FAmmo[A_CELLS], 40, FMaxAmmo[A_CELLS]);
FWeapon[WEAPON_BFG] := True;
Result := True;
if (FAmmo[A_SHELLS] < FMaxAmmo[A_SHELLS]) or not FWeapon[WEAPON_SUPERPULEMET] then
begin
if a and FWeapon[WEAPON_SUPERPULEMET] then Exit;
if (FAmmo[A_SHELLS] < FMaxAmmo[A_SHELLS]) or not FWeapon[WEAPON_SUPERPULEMET] then
begin
if a and FWeapon[WEAPON_SUPERPULEMET] then Exit;
-
+ switchWeapon := WEAPON_SUPERPULEMET;
+ hadWeapon := FWeapon[WEAPON_SUPERPULEMET];
IncMax(FAmmo[A_SHELLS], 4, FMaxAmmo[A_SHELLS]);
FWeapon[WEAPON_SUPERPULEMET] := True;
Result := True;
IncMax(FAmmo[A_SHELLS], 4, FMaxAmmo[A_SHELLS]);
FWeapon[WEAPON_SUPERPULEMET] := True;
Result := True;
if (FAmmo[A_FUEL] < FMaxAmmo[A_FUEL]) or not FWeapon[WEAPON_FLAMETHROWER] then
begin
if a and FWeapon[WEAPON_FLAMETHROWER] then Exit;
if (FAmmo[A_FUEL] < FMaxAmmo[A_FUEL]) or not FWeapon[WEAPON_FLAMETHROWER] then
begin
if a and FWeapon[WEAPON_FLAMETHROWER] then Exit;
-
+ switchWeapon := WEAPON_FLAMETHROWER;
+ hadWeapon := FWeapon[WEAPON_FLAMETHROWER];
IncMax(FAmmo[A_FUEL], 100, FMaxAmmo[A_FUEL]);
FWeapon[WEAPON_FLAMETHROWER] := True;
Result := True;
IncMax(FAmmo[A_FUEL], 100, FMaxAmmo[A_FUEL]);
FWeapon[WEAPON_FLAMETHROWER] := True;
Result := True;
(FAmmo[A_SHELLS] < FMaxAmmo[A_SHELLS]) or
(FAmmo[A_ROCKETS] < FMaxAmmo[A_ROCKETS]) or
(FAmmo[A_CELLS] < FMaxAmmo[A_CELLS]) or
(FAmmo[A_SHELLS] < FMaxAmmo[A_SHELLS]) or
(FAmmo[A_ROCKETS] < FMaxAmmo[A_ROCKETS]) or
(FAmmo[A_CELLS] < FMaxAmmo[A_CELLS]) or
- (FMaxAmmo[A_FUEL] < AmmoLimits[1, A_FUEL]) then
+ (FAmmo[A_FUEL] < FMaxAmmo[A_FUEL]) then
begin
FMaxAmmo[A_BULLETS] := AmmoLimits[1, A_BULLETS];
FMaxAmmo[A_SHELLS] := AmmoLimits[1, A_SHELLS];
begin
FMaxAmmo[A_BULLETS] := AmmoLimits[1, A_BULLETS];
FMaxAmmo[A_SHELLS] := AmmoLimits[1, A_SHELLS];
IncMax(FAmmo[A_ROCKETS], 1, FMaxAmmo[A_ROCKETS]);
if FAmmo[A_CELLS] < FMaxAmmo[A_CELLS] then
IncMax(FAmmo[A_CELLS], 40, FMaxAmmo[A_CELLS]);
IncMax(FAmmo[A_ROCKETS], 1, FMaxAmmo[A_ROCKETS]);
if FAmmo[A_CELLS] < FMaxAmmo[A_CELLS] then
IncMax(FAmmo[A_CELLS], 40, FMaxAmmo[A_CELLS]);
+ if FAmmo[A_FUEL] < FMaxAmmo[A_FUEL] then
+ IncMax(FAmmo[A_FUEL], 50, FMaxAmmo[A_FUEL]);
FRulez := FRulez + [R_ITEM_BACKPACK];
Result := True;
FRulez := FRulez + [R_ITEM_BACKPACK];
Result := True;
if not (R_BERSERK in FRulez) then
begin
Include(FRulez, R_BERSERK);
if not (R_BERSERK in FRulez) then
begin
Include(FRulez, R_BERSERK);
- if allowBerserkSwitching then
+ if (FBFGFireCounter = -1) then
begin
FCurrWeap := WEAPON_KASTET;
resetWeaponQueue();
begin
FCurrWeap := WEAPON_KASTET;
resetWeaponQueue();
remove := True;
FFireTime := 0;
end;
remove := True;
FFireTime := 0;
end;
- if FHealth < PLAYER_HP_SOFT then
+ if (FHealth < PLAYER_HP_SOFT) or (FFireTime > 0) then
begin
begin
- FHealth := PLAYER_HP_SOFT;
+ if FHealth < PLAYER_HP_SOFT then FHealth := PLAYER_HP_SOFT;
FBerserk := gTime+30000;
Result := True;
remove := True;
FBerserk := gTime+30000;
Result := True;
remove := True;
if FMegaRulez[MR_INVUL] < gTime+PLAYER_INVUL_TIME then
begin
FMegaRulez[MR_INVUL] := gTime+PLAYER_INVUL_TIME;
if FMegaRulez[MR_INVUL] < gTime+PLAYER_INVUL_TIME then
begin
FMegaRulez[MR_INVUL] := gTime+PLAYER_INVUL_TIME;
+ FSpawnInvul := 0;
Result := True;
remove := True;
if gFlash = 2 then Inc(FPickup, 5);
end;
ITEM_BOTTLE:
Result := True;
remove := True;
if gFlash = 2 then Inc(FPickup, 5);
end;
ITEM_BOTTLE:
- if FHealth < PLAYER_HP_LIMIT then
+ if (FHealth < PLAYER_HP_LIMIT) or (FFireTime > 0) then
begin
begin
- IncMax(FHealth, 4, PLAYER_HP_LIMIT);
+ if FHealth < PLAYER_HP_LIMIT then IncMax(FHealth, 4, PLAYER_HP_LIMIT);
Result := True;
remove := True;
FFireTime := 0;
Result := True;
remove := True;
FFireTime := 0;
if gFlash = 2 then Inc(FPickup, 5);
end;
end;
if gFlash = 2 then Inc(FPickup, 5);
end;
end;
+
+ if (shouldSwitch(switchWeapon, hadWeapon)) then
+ QueueWeaponSwitch(switchWeapon);
end;
procedure TPlayer.Touch();
end;
procedure TPlayer.Touch();
//FModel.PlaySound(MODELSOUND_PAIN, 1, FObj.X, FObj.Y);
if FIamBot then
begin
//FModel.PlaySound(MODELSOUND_PAIN, 1, FObj.X, FObj.Y);
if FIamBot then
begin
- // Áðîñèòü ôëàã òîâàðèùó:
+ // Бросить флаг товарищу:
if gGameSettings.GameMode = GM_CTF then
DropFlag();
end;
if gGameSettings.GameMode = GM_CTF then
DropFlag();
end;
FMonsterKills := 0;
FDeath := 0;
FSecrets := 0;
FMonsterKills := 0;
FDeath := 0;
FSecrets := 0;
+ FSpawnInvul := 0;
+ {$IFDEF ENABLE_CORPSES}
+ FCorpse := -1;
+ {$ENDIF}
+ FReady := False;
if FNoRespawn then
begin
FSpectator := False;
if FNoRespawn then
begin
FSpectator := False;
ReleaseKeys();
FDamageBuffer := 0;
ReleaseKeys();
FDamageBuffer := 0;
+ FSlopeOld := 0;
+ FIncCamOld := 0;
FIncCam := 0;
FBFGFireCounter := -1;
FIncCam := 0;
FBFGFireCounter := -1;
- FShellTimer := -1;
+ {$IFDEF ENABLE_SHELLS}
+ FShellTimer := -1;
+ {$ENDIF}
FPain := 0;
FLastHit := 0;
FLastFrag := 0;
FPain := 0;
FLastHit := 0;
FLastFrag := 0;
SetAction(A_STAND, True);
end;
SetAction(A_STAND, True);
end;
-function TPlayer.GetRespawnPoint(): Byte;
-var
- c: Byte;
-begin
- Result := 255;
- // Íà áóäóùåå: FSpawn - èãðîê óæå èãðàë è ïåðåðîæäàåòñÿ
-
- // Îäèíî÷íàÿ èãðà/êîîïåðàòèâ
- if gGameSettings.GameMode in [GM_COOP, GM_SINGLE] then
- begin
- if (Self = gPlayer1) or (Self = gPlayer2) then
- begin
- // Òî÷êà ïîÿâëåíèÿ ñâîåãî èãðîêà
- if Self = gPlayer1 then
- c := RESPAWNPOINT_PLAYER1
- else
- c := RESPAWNPOINT_PLAYER2;
- if g_Map_GetPointCount(c) > 0 then
- begin
- Result := c;
- Exit;
- end;
-
- // Òî÷êà ïîÿâëåíèÿ äðóãîãî èãðîêà
- if Self = gPlayer1 then
- c := RESPAWNPOINT_PLAYER2
- else
- c := RESPAWNPOINT_PLAYER1;
- if g_Map_GetPointCount(c) > 0 then
- begin
- Result := c;
- Exit;
- end;
- end else
- begin
- // Òî÷êà ïîÿâëåíèÿ ëþáîãî èãðîêà (áîòà)
- if Random(2) = 0 then
- c := RESPAWNPOINT_PLAYER1
- else
- c := RESPAWNPOINT_PLAYER2;
- if g_Map_GetPointCount(c) > 0 then
- begin
- Result := c;
- Exit;
- end;
- end;
-
- // Òî÷êà ëþáîé èç êîìàíä
- if Random(2) = 0 then
- c := RESPAWNPOINT_RED
- else
- c := RESPAWNPOINT_BLUE;
- if g_Map_GetPointCount(c) > 0 then
- begin
- Result := c;
- Exit;
- end;
-
- // Òî÷êà DM
- c := RESPAWNPOINT_DM;
- if g_Map_GetPointCount(c) > 0 then
- begin
- Result := c;
- Exit;
- end;
- end;
-
- // Ìÿñîïîâàë
- if gGameSettings.GameMode = GM_DM then
- begin
- // Òî÷êà DM
- c := RESPAWNPOINT_DM;
- if g_Map_GetPointCount(c) > 0 then
- begin
- Result := c;
- Exit;
- end;
-
- // Òî÷êà ïîÿâëåíèÿ ëþáîãî èãðîêà
- if Random(2) = 0 then
- c := RESPAWNPOINT_PLAYER1
- else
- c := RESPAWNPOINT_PLAYER2;
- if g_Map_GetPointCount(c) > 0 then
- begin
- Result := c;
- Exit;
- end;
-
- // Òî÷êà ëþáîé èç êîìàíä
- if Random(2) = 0 then
- c := RESPAWNPOINT_RED
- else
- c := RESPAWNPOINT_BLUE;
- if g_Map_GetPointCount(c) > 0 then
- begin
- Result := c;
- Exit;
- end;
- end;
+function TPlayer.GetRespawnPoint(): Byte;
+var
+ c: Byte;
+begin
+ Result := 255;
+ // На будущее: FSpawn - игрок уже играл и перерождается
- // Êîìàíäíûå
- if gGameSettings.GameMode in [GM_TDM, GM_CTF] then
+ // Одиночная игра/кооператив
+ if gGameSettings.GameMode in [GM_COOP, GM_SINGLE] then
begin
begin
- // Òî÷êà ñâîåé êîìàíäû
- c := RESPAWNPOINT_DM;
- if FTeam = TEAM_RED then
- c := RESPAWNPOINT_RED;
- if FTeam = TEAM_BLUE then
- c := RESPAWNPOINT_BLUE;
- if g_Map_GetPointCount(c) > 0 then
+ if Self = gPlayer1 then
begin
begin
- Result := c;
- Exit;
- end;
-
- // Òî÷êà DM
- c := RESPAWNPOINT_DM;
- if g_Map_GetPointCount(c) > 0 then
+ // player 1 should try to spawn on the player 1 point
+ if g_Map_GetPointCount(RESPAWNPOINT_PLAYER1) > 0 then
+ Exit(RESPAWNPOINT_PLAYER1)
+ else if g_Map_GetPointCount(RESPAWNPOINT_PLAYER2) > 0 then
+ Exit(RESPAWNPOINT_PLAYER2);
+ end
+ else if Self = gPlayer2 then
begin
begin
- Result := c;
- Exit;
- end;
-
- // Òî÷êà ïîÿâëåíèÿ ëþáîãî èãðîêà
- if Random(2) = 0 then
- c := RESPAWNPOINT_PLAYER1
+ // player 2 should try to spawn on the player 2 point
+ if g_Map_GetPointCount(RESPAWNPOINT_PLAYER2) > 0 then
+ Exit(RESPAWNPOINT_PLAYER2)
+ else if g_Map_GetPointCount(RESPAWNPOINT_PLAYER1) > 0 then
+ Exit(RESPAWNPOINT_PLAYER1);
+ end
else
else
- c := RESPAWNPOINT_PLAYER2;
- if g_Map_GetPointCount(c) > 0 then
begin
begin
- Result := c;
- Exit;
+ // other players randomly pick either the first or the second point
+ c := IfThen((Random(2) = 0), RESPAWNPOINT_PLAYER1, RESPAWNPOINT_PLAYER2);
+ if g_Map_GetPointCount(c) > 0 then
+ Exit(c);
+ // try the other one
+ c := IfThen((c = RESPAWNPOINT_PLAYER1), RESPAWNPOINT_PLAYER2, RESPAWNPOINT_PLAYER1);
+ if g_Map_GetPointCount(c) > 0 then
+ Exit(c);
end;
end;
+ end;
+
+ // Мясоповал
+ if gGameSettings.GameMode = GM_DM then
+ begin
+ // try DM points first
+ if g_Map_GetPointCount(RESPAWNPOINT_DM) > 0 then
+ Exit(RESPAWNPOINT_DM);
+ end;
- // Òî÷êà äðóãîé êîìàíäû
+ // Командные
+ if gGameSettings.GameMode in [GM_TDM, GM_CTF] then
+ begin
+ // try team points first
c := RESPAWNPOINT_DM;
if FTeam = TEAM_RED then
c := RESPAWNPOINT_DM;
if FTeam = TEAM_RED then
+ c := RESPAWNPOINT_RED
+ else if FTeam = TEAM_BLUE then
c := RESPAWNPOINT_BLUE;
c := RESPAWNPOINT_BLUE;
- if FTeam = TEAM_BLUE then
- c := RESPAWNPOINT_RED;
if g_Map_GetPointCount(c) > 0 then
if g_Map_GetPointCount(c) > 0 then
- begin
- Result := c;
- Exit;
- end;
+ Exit(c);
end;
end;
+
+ // still haven't found a spawnpoint, try random shit
+ Result := g_Map_GetRandomPointType();
end;
procedure TPlayer.Respawn(Silent: Boolean; Force: Boolean = False);
var
RespawnPoint: TRespawnPoint;
a, b, c: Byte;
end;
procedure TPlayer.Respawn(Silent: Boolean; Force: Boolean = False);
var
RespawnPoint: TRespawnPoint;
a, b, c: Byte;
- Anim: TAnimation;
- ID: DWORD;
begin
begin
+ FSlopeOld := 0;
+ FIncCamOld := 0;
FIncCam := 0;
FBFGFireCounter := -1;
FIncCam := 0;
FBFGFireCounter := -1;
- FShellTimer := -1;
+ {$IFDEF ENABLE_SHELLS}
+ FShellTimer := -1;
+ {$ENDIF}
FPain := 0;
FLastHit := 0;
FPain := 0;
FLastHit := 0;
+ FSpawnInvul := 0;
+
+ {$IFDEF ENABLE_CORPSES}
+ FCorpse := -1;
+ {$ENDIF}
if not g_Game_IsServer then
Exit;
if not g_Game_IsServer then
Exit;
// if server changes MaxLives we gotta be ready
if gGameSettings.MaxLives = 0 then FNoRespawn := False;
// if server changes MaxLives we gotta be ready
if gGameSettings.MaxLives = 0 then FNoRespawn := False;
-// Åùå íåëüçÿ âîçðîäèòüñÿ:
+// Еще нельзя возродиться:
if FTime[T_RESPAWN] > gTime then
Exit;
if FTime[T_RESPAWN] > gTime then
Exit;
-// Ïðîñðàë âñå æèçíè:
+// Просрал все жизни:
if FNoRespawn then
begin
if not FSpectator then Spectate(True);
if FNoRespawn then
begin
if not FSpectator then Spectate(True);
end;
if (gGameSettings.GameType <> GT_SINGLE) and (gGameSettings.GameMode <> GM_COOP) then
end;
if (gGameSettings.GameType <> GT_SINGLE) and (gGameSettings.GameMode <> GM_COOP) then
- begin // "Ñâîÿ èãðà"
- // Áåðñåðê íå ñîõðàíÿåòñÿ ìåæäó óðîâíÿìè:
+ begin // "Своя игра"
+ // Берсерк не сохраняется между уровнями:
FRulez := FRulez-[R_BERSERK];
end
FRulez := FRulez-[R_BERSERK];
end
- else // "Îäèíî÷íàÿ èãðà"/"Êîîï"
+ else // "Одиночная игра"/"Кооп"
begin
begin
- // Áåðñåðê è êëþ÷è íå ñîõðàíÿþòñÿ ìåæäó óðîâíÿìè:
+ // Берсерк и ключи не сохраняются между уровнями:
FRulez := FRulez-[R_KEY_RED, R_KEY_GREEN, R_KEY_BLUE, R_BERSERK];
end;
FRulez := FRulez-[R_KEY_RED, R_KEY_GREEN, R_KEY_BLUE, R_BERSERK];
end;
-// Ïîëó÷àåì òî÷êó ñïàóíà èãðîêà:
+// Получаем точку спауна игрока:
c := GetRespawnPoint();
ReleaseKeys();
SetFlag(FLAG_NONE);
c := GetRespawnPoint();
ReleaseKeys();
SetFlag(FLAG_NONE);
-// Âîñêðåøåíèå áåç îðóæèÿ:
+// Воскрешение без оружия:
if not FAlive then
begin
if not FAlive then
begin
- FHealth := PLAYER_HP_SOFT;
+ FHealth := Round(PLAYER_HP_SOFT * (FHandicap / 100));
FArmor := 0;
FAlive := True;
FAir := AIR_DEF;
FArmor := 0;
FAlive := True;
FAir := AIR_DEF;
FMaxAmmo[A_CELLS] := AmmoLimits[0, A_CELLS];
FMaxAmmo[A_FUEL] := AmmoLimits[0, A_FUEL];
FMaxAmmo[A_CELLS] := AmmoLimits[0, A_CELLS];
FMaxAmmo[A_FUEL] := AmmoLimits[0, A_FUEL];
- if gGameSettings.GameMode in [GM_DM, GM_TDM, GM_CTF] then
+ if (gGameSettings.GameMode in [GM_DM, GM_TDM, GM_CTF]) and
+ LongBool(gGameSettings.Options and GAME_OPTION_DMKEYS) then
FRulez := [R_KEY_RED, R_KEY_GREEN, R_KEY_BLUE]
else
FRulez := [];
end;
FRulez := [R_KEY_RED, R_KEY_GREEN, R_KEY_BLUE]
else
FRulez := [];
end;
-// Ïîëó÷àåì êîîðäèíàòû òî÷êè âîçðîæäåíèÿ:
+// Получаем координаты точки возрождения:
if not g_Map_GetPoint(c, RespawnPoint) then
begin
g_FatalError(_lc[I_GAME_ERROR_GET_SPAWN]);
Exit;
end;
if not g_Map_GetPoint(c, RespawnPoint) then
begin
g_FatalError(_lc[I_GAME_ERROR_GET_SPAWN]);
Exit;
end;
-// Óñòàíîâêà êîîðäèíàò è ñáðîñ âñåõ ïàðàìåòðîâ:
+// Установка координат и сброс всех параметров:
FObj.X := RespawnPoint.X-PLAYER_RECT.X;
FObj.Y := RespawnPoint.Y-PLAYER_RECT.Y;
FObj.X := RespawnPoint.X-PLAYER_RECT.X;
FObj.Y := RespawnPoint.Y-PLAYER_RECT.Y;
+ FObj.oldX := FObj.X; // don't interpolate after respawn
+ FObj.oldY := FObj.Y;
FObj.Vel.X := 0;
FObj.Vel.Y := 0;
FObj.Accel.X := 0;
FObj.Vel.X := 0;
FObj.Vel.Y := 0;
FObj.Accel.X := 0;
for a := Low(FMegaRulez) to High(FMegaRulez) do
FMegaRulez[a] := 0;
for a := Low(FMegaRulez) to High(FMegaRulez) do
FMegaRulez[a] := 0;
+// Respawn invulnerability
+ if (gGameSettings.GameType <> GT_SINGLE) and (gGameSettings.SpawnInvul > 0) then
+ begin
+ FMegaRulez[MR_INVUL] := gTime + gGameSettings.SpawnInvul * 1000;
+ FSpawnInvul := FMegaRulez[MR_INVUL];
+ end;
+
FDamageBuffer := 0;
FJetpack := False;
FCanJetpack := False;
FDamageBuffer := 0;
FJetpack := False;
FCanJetpack := False;
+ FFlaming := False;
FFireTime := 0;
FFirePainTime := 0;
FFireAttacker := 0;
FFireTime := 0;
FFirePainTime := 0;
FFireAttacker := 0;
-// Àíèìàöèÿ âîçðîæäåíèÿ:
- if (not gLoadGameMode) and (not Silent) then
- if g_Frames_Get(ID, 'FRAMES_TELEPORT') then
+ {$IFDEF ENABLE_GFX}
+ // Анимация возрождения:
+ if (not gLoadGameMode) and (not Silent) then
begin
begin
- Anim := TAnimation.Create(ID, False, 3);
- g_GFX_OnceAnim(FObj.X+PLAYER_RECT.X+(PLAYER_RECT.Width div 2)-32,
- FObj.Y+PLAYER_RECT.Y+(PLAYER_RECT.Height div 2)-32, Anim);
- Anim.Free();
+ g_GFX_QueueEffect(
+ R_GFX_TELEPORT_FAST,
+ FObj.X + PLAYER_RECT.X + (PLAYER_RECT.Width div 2) - 32,
+ FObj.Y + PLAYER_RECT.Y + (PLAYER_RECT.Height div 2) - 32
+ );
end;
end;
+ {$ENDIF}
FSpectator := False;
FGhost := False;
FSpectator := False;
FGhost := False;
FSpectatePlayer := -1;
FSpawned := True;
FSpectatePlayer := -1;
FSpawned := True;
- if (gPlayer1 = nil) and (gLMSPID1 = FUID) then
+ if (gPlayer1 = nil) and (gSpectLatchPID1 = FUID) then
gPlayer1 := self;
gPlayer1 := self;
- if (gPlayer2 = nil) and (gLMSPID2 = FUID) then
+ if (gPlayer2 = nil) and (gSpectLatchPID2 = FUID) then
gPlayer2 := self;
if g_Game_IsNet then
gPlayer2 := self;
if g_Game_IsNet then
FWantsInGame := False;
FSpawned := False;
FWantsInGame := False;
FSpawned := False;
+ {$IFDEF ENABLE_CORPSES}
+ FCorpse := -1;
+ {$ENDIF}
+
if FNoRespawn then
begin
if Self = gPlayer1 then
begin
if FNoRespawn then
begin
if Self = gPlayer1 then
begin
- gLMSPID1 := FUID;
+ gSpectLatchPID1 := FUID;
gPlayer1 := nil;
gPlayer1 := nil;
- end;
- if Self = gPlayer2 then
+ end
+ else if Self = gPlayer2 then
begin
begin
- gLMSPID2 := FUID;
+ gSpectLatchPID2 := FUID;
gPlayer2 := nil;
end;
end;
gPlayer2 := nil;
end;
end;
end;
procedure TPlayer.Run(Direction: TDirection);
end;
procedure TPlayer.Run(Direction: TDirection);
-var
- a, b: Integer;
+ {$IFDEF ENABLE_GIBS}
+ var a, b: Integer;
+ {$ENDIF}
begin
if MAX_RUNVEL > 8 then
FlySmoke();
begin
if MAX_RUNVEL > 8 then
FlySmoke();
-// Áåæèì:
+// Бежим:
if Direction = TDirection.D_LEFT then
begin
if FObj.Vel.X > -MAX_RUNVEL then
if Direction = TDirection.D_LEFT then
begin
if FObj.Vel.X > -MAX_RUNVEL then
if FObj.Vel.X < MAX_RUNVEL then
FObj.Vel.X := FObj.Vel.X + (MAX_RUNVEL shr 3);
if FObj.Vel.X < MAX_RUNVEL then
FObj.Vel.X := FObj.Vel.X + (MAX_RUNVEL shr 3);
-// Âîçìîæíî, ïèíàåì êóñêè:
- if (FObj.Vel.X <> 0) and (gGibs <> nil) then
- begin
- b := Abs(FObj.Vel.X);
- if b > 1 then b := b * (Random(8 div b) + 1);
- for a := 0 to High(gGibs) do
+ {$IFDEF ENABLE_GIBS}
+ // Возможно, пинаем куски:
+ if (FObj.Vel.X <> 0) and (gGibs <> nil) then
begin
begin
- if gGibs[a].alive and
- g_Obj_Collide(FObj.X+FObj.Rect.X, FObj.Y+FObj.Rect.Y+FObj.Rect.Height-4,
- FObj.Rect.Width, 8, @gGibs[a].Obj) and (Random(3) = 0) then
+ b := Abs(FObj.Vel.X);
+ if b > 1 then b := b * (Random(8 div b) + 1);
+ for a := 0 to High(gGibs) do
begin
begin
- // Ïèíàåì êóñêè
- if FObj.Vel.X < 0 then
- begin
- g_Obj_PushA(@gGibs[a].Obj, b, Random(61)+120) // íàëåâî
- end
- else
+ if gGibs[a].alive and
+ g_Obj_Collide(FObj.X+FObj.Rect.X, FObj.Y+FObj.Rect.Y+FObj.Rect.Height-4,
+ FObj.Rect.Width, 8, @gGibs[a].Obj) and (Random(3) = 0) then
begin
begin
- g_Obj_PushA(@gGibs[a].Obj, b, Random(61)); // íàïðàâî
+ // Пинаем куски
+ if FObj.Vel.X < 0 then
+ begin
+ g_Obj_PushA(@gGibs[a].Obj, b, Random(61)+120) // налево
+ end
+ else
+ begin
+ g_Obj_PushA(@gGibs[a].Obj, b, Random(61)); // направо
+ end;
+ gGibs[a].positionChanged(); // this updates spatial accelerators
end;
end;
- gGibs[a].positionChanged(); // this updates spatial accelerators
end;
end;
end;
end;
- end;
+ {$ENDIF}
SetAction(A_WALK);
end;
SetAction(A_WALK);
end;
end;
function TPlayer.TeleportTo(X, Y: Integer; silent: Boolean; dir: Byte): Boolean;
end;
function TPlayer.TeleportTo(X, Y: Integer; silent: Boolean; dir: Byte): Boolean;
-var
- Anim: TAnimation;
- ID: DWORD;
begin
Result := False;
begin
Result := False;
FJustTeleported := True;
FJustTeleported := True;
- Anim := nil;
if not silent then
begin
if not silent then
begin
- if g_Frames_Get(ID, 'FRAMES_TELEPORT') then
- begin
- Anim := TAnimation.Create(ID, False, 3);
- end;
-
g_Sound_PlayExAt('SOUND_GAME_TELEPORT', FObj.X, FObj.Y);
g_Sound_PlayExAt('SOUND_GAME_TELEPORT', FObj.X, FObj.Y);
- g_GFX_OnceAnim(FObj.X+PLAYER_RECT.X+(PLAYER_RECT.Width div 2)-32,
- FObj.Y+PLAYER_RECT.Y+(PLAYER_RECT.Height div 2)-32, Anim);
+ {$IFDEF ENABLE_GFX}
+ g_GFX_QueueEffect(
+ R_GFX_TELEPORT_FAST,
+ FObj.X + PLAYER_RECT.X + (PLAYER_RECT.Width div 2) - 32,
+ FObj.Y + PLAYER_RECT.Y + (PLAYER_RECT.Height div 2) - 32
+ );
+ {$ENDIF}
if g_Game_IsServer and g_Game_IsNet then
MH_SEND_Effect(FObj.X+PLAYER_RECT.X+(PLAYER_RECT.Width div 2)-32,
FObj.Y+PLAYER_RECT.Y+(PLAYER_RECT.Height div 2)-32, 1,
if g_Game_IsServer and g_Game_IsNet then
MH_SEND_Effect(FObj.X+PLAYER_RECT.X+(PLAYER_RECT.Width div 2)-32,
FObj.Y+PLAYER_RECT.Y+(PLAYER_RECT.Height div 2)-32, 1,
FObj.X := X-PLAYER_RECT.X;
FObj.Y := Y-PLAYER_RECT.Y;
FObj.X := X-PLAYER_RECT.X;
FObj.Y := Y-PLAYER_RECT.Y;
+ FObj.oldX := FObj.X; // don't interpolate after respawn
+ FObj.oldY := FObj.Y;
if FAlive and FGhost then
begin
FXTo := FObj.X;
if FAlive and FGhost then
begin
FXTo := FObj.X;
end
else
if dir = 3 then
end
else
if dir = 3 then
- begin // îáðàòíîå
+ begin // обратное
if FDirection = TDirection.D_RIGHT then
begin
SetDirection(TDirection.D_LEFT);
if FDirection = TDirection.D_RIGHT then
begin
SetDirection(TDirection.D_LEFT);
end;
end;
end;
end;
- if not silent and (Anim <> nil) then
+ if not silent then
begin
begin
- g_GFX_OnceAnim(FObj.X+PLAYER_RECT.X+(PLAYER_RECT.Width div 2)-32,
- FObj.Y+PLAYER_RECT.Y+(PLAYER_RECT.Height div 2)-32, Anim);
- Anim.Free();
-
+ {$IFDEF ENABLE_GFX}
+ g_GFX_QueueEffect(
+ R_GFX_TELEPORT_FAST,
+ FObj.X + PLAYER_RECT.X + (PLAYER_RECT.Width div 2) - 32,
+ FObj.Y + PLAYER_RECT.Y + (PLAYER_RECT.Height div 2) - 32
+ );
+ {$ENDIF}
if g_Game_IsServer and g_Game_IsNet then
MH_SEND_Effect(FObj.X+PLAYER_RECT.X+(PLAYER_RECT.Width div 2)-32,
FObj.Y+PLAYER_RECT.Y+(PLAYER_RECT.Height div 2)-32, 0,
if g_Game_IsServer and g_Game_IsNet then
MH_SEND_Effect(FObj.X+PLAYER_RECT.X+(PLAYER_RECT.Width div 2)-32,
FObj.Y+PLAYER_RECT.Y+(PLAYER_RECT.Height div 2)-32, 0,
Result := 1;
end;
Result := 1;
end;
-function TPlayer.followCorpse(): Boolean;
-var
- i: Integer;
+procedure TPlayer.PreUpdate();
begin
begin
- Result := False;
- if FAlive or FSpectator then
- Exit;
- if (gCorpses = nil) or (Length(gCorpses) = 0) then
- Exit;
- for i := 0 to High(gCorpses) do
- if gCorpses[i] <> nil then
- if gCorpses[i].FPlayerUID = FUID then
- begin
- Result := True;
- FObj.X := gCorpses[i].FObj.X;
- FObj.Y := gCorpses[i].FObj.Y;
- FObj.Vel.X := gCorpses[i].FObj.Vel.X;
- FObj.Vel.Y := gCorpses[i].FObj.Vel.Y;
- FObj.Accel.X := gCorpses[i].FObj.Accel.X;
- FObj.Accel.Y := gCorpses[i].FObj.Accel.Y;
- break;
- end;
+ FSlopeOld := FObj.slopeUpLeft;
+ FIncCamOld := FIncCam;
+ FObj.oldX := FObj.X;
+ FObj.oldY := FObj.Y;
end;
procedure TPlayer.Update();
end;
procedure TPlayer.Update();
DoLerp(4);
if NetServer then
DoLerp(4);
if NetServer then
- if FClientID >= 0 then
+ if (FClientID >= 0) and (NetClients[FClientID].Peer <> nil) then
begin
FPing := NetClients[FClientID].Peer^.lastRoundTripTime;
if NetClients[FClientID].Peer^.packetsSent > 0 then
begin
FPing := NetClients[FClientID].Peer^.lastRoundTripTime;
if NetClients[FClientID].Peer^.packetsSent > 0 then
FLoss := 0;
end;
FLoss := 0;
end;
- if FAlive and (FPunchAnim <> nil) then
- FPunchAnim.Update();
+ if FAlive then
+ FPunchAnim.Update;
+ if FPunchAnim.played then
+ FPunchAnim.Disable;
if FAlive and (gFly or FJetpack) then
FlySmoke();
if FAlive and (gFly or FJetpack) then
FlySmoke();
FIncCam := FIncCam*i;
end;
FIncCam := FIncCam*i;
end;
- // no need to do that each second frame, weapon queue will take care of it
- if FAlive and FKeys[KEY_NEXTWEAPON].Pressed and AnyServer then NextWeapon();
- if FAlive and FKeys[KEY_PREVWEAPON].Pressed and AnyServer then PrevWeapon();
-
if gTime mod (GAME_TICK*2) <> 0 then
begin
if (FObj.Vel.X = 0) and FAlive then
if gTime mod (GAME_TICK*2) <> 0 then
begin
if (FObj.Vel.X = 0) and FAlive then
if FPhysics then
begin
if FPhysics then
begin
- if not followCorpse() then
- g_Obj_Move(@FObj, True, True, True);
+ g_Obj_Move(@FObj, True, True, True);
positionChanged(); // this updates spatial accelerators
end;
positionChanged(); // this updates spatial accelerators
end;
// Let alive player do some actions
if FKeys[KEY_LEFT].Pressed then Run(TDirection.D_LEFT);
if FKeys[KEY_RIGHT].Pressed then Run(TDirection.D_RIGHT);
// Let alive player do some actions
if FKeys[KEY_LEFT].Pressed then Run(TDirection.D_LEFT);
if FKeys[KEY_RIGHT].Pressed then Run(TDirection.D_RIGHT);
- //if FKeys[KEY_NEXTWEAPON].Pressed and AnyServer then NextWeapon();
- //if FKeys[KEY_PREVWEAPON].Pressed and AnyServer then PrevWeapon();
- if FKeys[KEY_FIRE].Pressed and AnyServer then Fire();
+ if FKeys[KEY_FIRE].Pressed and AnyServer then Fire()
+ else
+ begin
+ if AnyServer then
+ begin
+ FlamerOff;
+ if NetServer then MH_SEND_PlayerStats(FUID);
+ end;
+ end;
if FKeys[KEY_OPEN].Pressed and AnyServer then Use();
if FKeys[KEY_JUMP].Pressed then Jump()
else
if FKeys[KEY_OPEN].Pressed and AnyServer then Use();
if FKeys[KEY_JUMP].Pressed then Jump()
else
if FPhysics then
begin
if FPhysics then
begin
- if not followCorpse() then
- g_Obj_Move(@FObj, True, True, True);
+ g_Obj_Move(@FObj, True, True, True);
positionChanged(); // this updates spatial accelerators
end
else
positionChanged(); // this updates spatial accelerators
end
else
PANEL_BLOCKMON, True);
headwater := HeadInLiquid(0, 0);
PANEL_BLOCKMON, True);
headwater := HeadInLiquid(0, 0);
-// Ñîïðîòèâëåíèå âîçäóõà:
+// Сопротивление воздуха:
if (not FAlive) or not (FKeys[KEY_LEFT].Pressed or FKeys[KEY_RIGHT].Pressed) then
if FObj.Vel.X <> 0 then
FObj.Vel.X := z_dec(FObj.Vel.X, 1);
if (not FAlive) or not (FKeys[KEY_LEFT].Pressed or FKeys[KEY_RIGHT].Pressed) then
if FObj.Vel.X <> 0 then
FObj.Vel.X := z_dec(FObj.Vel.X, 1);
if FAlive and (FObj.Y > Integer(gMapInfo.Height)+128) and AnyServer then
begin
if FAlive and (FObj.Y > Integer(gMapInfo.Height)+128) and AnyServer then
begin
- // Îáíóëèòü äåéñòâèÿ ïðèìî÷åê, ÷òîáû ôîí ïðîïàë
+ // Обнулить действия примочек, чтобы фон пропал
FMegaRulez[MR_SUIT] := 0;
FMegaRulez[MR_INVUL] := 0;
FMegaRulez[MR_INVIS] := 0;
FMegaRulez[MR_SUIT] := 0;
FMegaRulez[MR_INVUL] := 0;
FMegaRulez[MR_INVIS] := 0;
else
Dec(FReloading[b]);
else
Dec(FReloading[b]);
+{$IFDEF ENABLE_SHELLS}
if FShellTimer > -1 then
if FShellTimer = 0 then
begin
if FShellType = SHELL_SHELL then
if FShellTimer > -1 then
if FShellTimer = 0 then
begin
if FShellType = SHELL_SHELL then
- g_Player_CreateShell(GameX+PLAYER_RECT_CX, GameY+PLAYER_RECT_CX,
+ g_Shells_Create(GameX+PLAYER_RECT_CX, GameY+PLAYER_RECT_CX,
GameVelX, GameVelY-2, SHELL_SHELL)
else if FShellType = SHELL_DBLSHELL then
begin
GameVelX, GameVelY-2, SHELL_SHELL)
else if FShellType = SHELL_DBLSHELL then
begin
- g_Player_CreateShell(GameX+PLAYER_RECT_CX, GameY+PLAYER_RECT_CX,
+ g_Shells_Create(GameX+PLAYER_RECT_CX, GameY+PLAYER_RECT_CX,
GameVelX+1, GameVelY-2, SHELL_SHELL);
GameVelX+1, GameVelY-2, SHELL_SHELL);
- g_Player_CreateShell(GameX+PLAYER_RECT_CX, GameY+PLAYER_RECT_CX,
+ g_Shells_Create(GameX+PLAYER_RECT_CX, GameY+PLAYER_RECT_CX,
GameVelX-1, GameVelY-2, SHELL_SHELL);
end;
FShellTimer := -1;
end else Dec(FShellTimer);
GameVelX-1, GameVelY-2, SHELL_SHELL);
end;
FShellTimer := -1;
end else Dec(FShellTimer);
+{$ENDIF}
if (FBFGFireCounter > -1) then
if FBFGFireCounter = 0 then
if (FBFGFireCounter > -1) then
if FBFGFireCounter = 0 then
end
else if (FAir mod 31 = 0) and not blockmon then
begin
end
else if (FAir mod 31 = 0) and not blockmon then
begin
- g_GFX_Bubbles(FObj.X+PLAYER_RECT.X+(PLAYER_RECT.Width div 2), FObj.Y+PLAYER_RECT.Y-4, 5+Random(6), 8, 4);
- if Random(2) = 0 then
- g_Sound_PlayExAt('SOUND_GAME_BUBBLE1', FObj.X, FObj.Y)
- else
- g_Sound_PlayExAt('SOUND_GAME_BUBBLE2', FObj.X, FObj.Y);
+ {$IFDEF ENABLE_GFX}
+ g_GFX_Bubbles(FObj.X+PLAYER_RECT.X+(PLAYER_RECT.Width div 2), FObj.Y+PLAYER_RECT.Y-4, 5+Random(6), 8, 4);
+ {$ENDIF}
+ if Random(2) = 0
+ then g_Sound_PlayExAt('SOUND_GAME_BUBBLE1', FObj.X, FObj.Y)
+ else g_Sound_PlayExAt('SOUND_GAME_BUBBLE2', FObj.X, FObj.Y);
end;
end else if FAir < AIR_DEF then
FAir := AIR_DEF;
end;
end else if FAir < AIR_DEF then
FAir := AIR_DEF;
if FFirePainTime <= 0 then
begin
if g_Game_IsServer then
if FFirePainTime <= 0 then
begin
if g_Game_IsServer then
- Damage(5, FFireAttacker, 0, 0, HIT_FLAME);
- FFirePainTime := 18;
+ Damage(2, FFireAttacker, 0, 0, HIT_FLAME);
+ FFirePainTime := 12 - FFireTime div 12;
end;
FFirePainTime := FFirePainTime - 1;
FFireTime := FFireTime - 1;
end;
FFirePainTime := FFirePainTime - 1;
FFireTime := FFireTime - 1;
+ if ((FFireTime mod 33) = 0) and (FMegaRulez[MR_INVUL] < gTime) then
+ FModel.PlaySound(MODELSOUND_PAIN, 1, FObj.X, FObj.Y);
if (FFireTime = 0) and g_Game_IsNet and g_Game_IsServer then
MH_SEND_PlayerStats(FUID);
end;
if (FFireTime = 0) and g_Game_IsNet and g_Game_IsServer then
MH_SEND_PlayerStats(FUID);
end;
else if FHealth > -50 then Kill(K_HARDKILL, FLastSpawnerUID, FLastHit)
else Kill(K_EXTRAHARDKILL, FLastSpawnerUID, FLastHit);
else if FHealth > -50 then Kill(K_HARDKILL, FLastSpawnerUID, FLastHit)
else Kill(K_EXTRAHARDKILL, FLastSpawnerUID, FLastHit);
- if FAlive then
+ if FAlive and ((FLastHit <> HIT_FLAME) or (FFireTime <= 0)) then
begin
if FDamageBuffer <= 20 then FModel.PlaySound(MODELSOUND_PAIN, 1, FObj.X, FObj.Y)
else if FDamageBuffer <= 55 then FModel.PlaySound(MODELSOUND_PAIN, 2, FObj.X, FObj.Y)
begin
if FDamageBuffer <= 20 then FModel.PlaySound(MODELSOUND_PAIN, 1, FObj.X, FObj.Y)
else if FDamageBuffer <= 55 then FModel.PlaySound(MODELSOUND_PAIN, 2, FObj.X, FObj.Y)
if (FActionAnim = A_PAIN) and (FModel.Animation <> A_PAIN) then
begin
FModel.ChangeAnimation(FActionAnim, FActionForce);
if (FActionAnim = A_PAIN) and (FModel.Animation <> A_PAIN) then
begin
FModel.ChangeAnimation(FActionAnim, FActionForce);
- FModel.GetCurrentAnimation.MinLength := i;
- FModel.GetCurrentAnimationMask.MinLength := i;
+ FModel.AnimState.MinLength := i;
end else FModel.ChangeAnimation(FActionAnim, FActionForce and (FModel.Animation <> A_STAND));
end else FModel.ChangeAnimation(FActionAnim, FActionForce and (FModel.Animation <> A_STAND));
- if (FModel.GetCurrentAnimation.Played or ((not FActionChanged) and (FModel.Animation = A_WALK)))
+ if (FModel.AnimState.Played or ((not FActionChanged) and (FModel.Animation = A_WALK)))
then SetAction(A_STAND, True);
then SetAction(A_STAND, True);
- if not ((FModel.Animation = A_WALK) and (Abs(FObj.Vel.X) < 4) and not FModel.Fire) then FModel.Update;
+ if not ((FModel.Animation = A_WALK) and (Abs(FObj.Vel.X) < 4) and not FModel.GetFire()) then FModel.Update;
for b := Low(FKeys) to High(FKeys) do
if FKeys[b].Time = 0 then FKeys[b].Pressed := False else Dec(FKeys[b].Time);
for b := Low(FKeys) to High(FKeys) do
if FKeys[b].Time = 0 then FKeys[b].Pressed := False else Dec(FKeys[b].Time);
procedure TPlayer.NetFire(Wpn: Byte; X, Y, AX, AY: Integer; WID: Integer = -1);
var
locObj: TObj;
procedure TPlayer.NetFire(Wpn: Byte; X, Y, AX, AY: Integer; WID: Integer = -1);
var
locObj: TObj;
- F: Boolean;
+ visible: Boolean = True;
WX, WY, XD, YD: Integer;
begin
WX, WY, XD, YD: Integer;
begin
- F := False;
WX := X;
WY := Y;
XD := AX;
WX := X;
WY := Y;
XD := AX;
case FCurrWeap of
WEAPON_KASTET:
begin
case FCurrWeap of
WEAPON_KASTET:
begin
+ visible := False;
DoPunch();
if R_BERSERK in FRulez then
begin
DoPunch();
if R_BERSERK in FRulez then
begin
FSawSoundSelect.Stop();
FSawSound.PlayAt(FObj.X, FObj.Y);
end;
FSawSoundSelect.Stop();
FSawSound.PlayAt(FObj.X, FObj.Y);
end;
- f := True;
end;
WEAPON_PISTOL:
begin
g_Sound_PlayExAt('SOUND_WEAPON_FIREPISTOL', GameX, Gamey);
FFireAngle := FAngle;
end;
WEAPON_PISTOL:
begin
g_Sound_PlayExAt('SOUND_WEAPON_FIREPISTOL', GameX, Gamey);
FFireAngle := FAngle;
- f := True;
- g_Player_CreateShell(GameX+PLAYER_RECT_CX, GameY+PLAYER_RECT_CX,
- GameVelX, GameVelY-2, SHELL_BULLET);
+ {$IFDEF ENABLE_SHELLS}
+ g_Shells_Create(GameX + PLAYER_RECT_CX, GameY + PLAYER_RECT_CX, GameVelX, GameVelY - 2, SHELL_BULLET);
+ {$ENDIF}
end;
WEAPON_SHOTGUN1:
begin
g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN', Gamex, Gamey);
FFireAngle := FAngle;
end;
WEAPON_SHOTGUN1:
begin
g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN', Gamex, Gamey);
FFireAngle := FAngle;
- f := True;
- FShellTimer := 10;
- FShellType := SHELL_SHELL;
+ {$IFDEF ENABLE_SHELLS}
+ FShellTimer := 10;
+ FShellType := SHELL_SHELL;
+ {$ENDIF}
end;
WEAPON_SHOTGUN2:
begin
g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN2', Gamex, Gamey);
FFireAngle := FAngle;
end;
WEAPON_SHOTGUN2:
begin
g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN2', Gamex, Gamey);
FFireAngle := FAngle;
- f := True;
- FShellTimer := 13;
- FShellType := SHELL_DBLSHELL;
+ {$IFDEF ENABLE_SHELLS}
+ FShellTimer := 13;
+ FShellType := SHELL_DBLSHELL;
+ {$ENDIF}
end;
WEAPON_CHAINGUN:
begin
g_Sound_PlayExAt('SOUND_WEAPON_FIRECGUN', Gamex, Gamey);
FFireAngle := FAngle;
end;
WEAPON_CHAINGUN:
begin
g_Sound_PlayExAt('SOUND_WEAPON_FIRECGUN', Gamex, Gamey);
FFireAngle := FAngle;
- f := True;
- g_Player_CreateShell(GameX+PLAYER_RECT_CX, GameY+PLAYER_RECT_CX,
- GameVelX, GameVelY-2, SHELL_BULLET);
+ {$IFDEF ENABLE_SHELLS}
+ g_Shells_Create(GameX + PLAYER_RECT_CX, GameY + PLAYER_RECT_CX, GameVelX, GameVelY - 2, SHELL_BULLET);
+ {$ENDIF}
end;
WEAPON_ROCKETLAUNCHER:
begin
g_Weapon_Rocket(wx, wy, xd, yd, FUID, WID);
FFireAngle := FAngle;
end;
WEAPON_ROCKETLAUNCHER:
begin
g_Weapon_Rocket(wx, wy, xd, yd, FUID, WID);
FFireAngle := FAngle;
- f := True;
end;
WEAPON_PLASMA:
begin
g_Weapon_Plasma(wx, wy, xd, yd, FUID, WID);
FFireAngle := FAngle;
end;
WEAPON_PLASMA:
begin
g_Weapon_Plasma(wx, wy, xd, yd, FUID, WID);
FFireAngle := FAngle;
- f := True;
end;
WEAPON_BFG:
begin
g_Weapon_BFGShot(wx, wy, xd, yd, FUID, WID);
FFireAngle := FAngle;
end;
WEAPON_BFG:
begin
g_Weapon_BFGShot(wx, wy, xd, yd, FUID, WID);
FFireAngle := FAngle;
- f := True;
end;
WEAPON_SUPERPULEMET:
begin
g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN', Gamex, Gamey);
FFireAngle := FAngle;
end;
WEAPON_SUPERPULEMET:
begin
g_Sound_PlayExAt('SOUND_WEAPON_FIRESHOTGUN', Gamex, Gamey);
FFireAngle := FAngle;
- f := True;
- g_Player_CreateShell(GameX+PLAYER_RECT_CX, GameY+PLAYER_RECT_CX,
- GameVelX, GameVelY-2, SHELL_SHELL);
+ {$IFDEF ENABLE_SHELLS}
+ g_Shells_Create(GameX + PLAYER_RECT_CX, GameY + PLAYER_RECT_CX, GameVelX, GameVelY - 2, SHELL_SHELL);
+ {$ENDIF}
end;
WEAPON_FLAMETHROWER:
begin
g_Weapon_flame(wx, wy, xd, yd, FUID, WID);
end;
WEAPON_FLAMETHROWER:
begin
g_Weapon_flame(wx, wy, xd, yd, FUID, WID);
+ FlamerOn;
FFireAngle := FAngle;
FFireAngle := FAngle;
- f := True;
end;
end;
end;
end;
- if not f then Exit;
+ if not visible then Exit;
if (FAngle = 0) or (FAngle = 180) then SetAction(A_ATTACK)
else if (FAngle = ANGLE_LEFTDOWN) or (FAngle = ANGLE_RIGHTDOWN) then SetAction(A_ATTACKDOWN)
if (FAngle = 0) or (FAngle = 180) then SetAction(A_ATTACK)
else if (FAngle = ANGLE_LEFTDOWN) or (FAngle = ANGLE_RIGHTDOWN) then SetAction(A_ATTACKDOWN)
var
AX, AY: Integer;
begin
var
AX, AY: Integer;
begin
- if NetInterpLevel < 1 then
+ FXTo := XTo;
+ FYTo := YTo;
+ if FJustTeleported or (NetInterpLevel < 1) then
begin
FObj.X := XTo;
FObj.Y := YTo;
begin
FObj.X := XTo;
FObj.Y := YTo;
+ if FJustTeleported then
+ begin
+ FObj.oldX := FObj.X;
+ FObj.oldY := FObj.Y;
+ end;
end
else
begin
end
else
begin
- FXTo := XTo;
- FYTo := YTo;
-
AX := Abs(FXTo - FObj.X);
AY := Abs(FYTo - FObj.Y);
if (AX > 32) or (AX <= NetInterpLevel) then
AX := Abs(FXTo - FObj.X);
AY := Abs(FYTo - FObj.Y);
if (AX > 32) or (AX <= NetInterpLevel) then
function TPlayer.GetFlag(Flag: Byte): Boolean;
var
s, ts: String;
function TPlayer.GetFlag(Flag: Byte): Boolean;
var
s, ts: String;
- evtype: Byte;
+ evtype, a: Byte;
begin
Result := False;
begin
Result := False;
if not g_Game_IsServer then Exit;
if not g_Game_IsServer then Exit;
-// Ïðèíåñ ÷óæîé ôëàã íà ñâîþ áàçó:
+// Принес чужой флаг на свою базу:
if (Flag = FTeam) and
(gFlags[Flag].State = FLAG_STATE_NORMAL) and
(FFlag <> FLAG_NONE) then
if (Flag = FTeam) and
(gFlags[Flag].State = FLAG_STATE_NORMAL) and
(FFlag <> FLAG_NONE) then
g_Map_ResetFlag(FFlag);
g_Game_Message(Format(_lc[I_MESSAGE_FLAG_CAPTURE], [AnsiUpperCase(s)]), 144);
g_Map_ResetFlag(FFlag);
g_Game_Message(Format(_lc[I_MESSAGE_FLAG_CAPTURE], [AnsiUpperCase(s)]), 144);
- gTeamStat[FTeam].Goals := gTeamStat[FTeam].Goals + 1;
+ if ((Self = gPlayer1) or (Self = gPlayer2)
+ or ((gPlayer1 <> nil) and (gPlayer1.Team = FTeam))
+ or ((gPlayer2 <> nil) and (gPlayer2.Team = FTeam))) then
+ a := 0
+ else
+ a := 1;
+
+ if not sound_cap_flag[a].IsPlaying() then
+ sound_cap_flag[a].Play();
+
+ gTeamStat[FTeam].Score += 1;
Result := True;
if g_Game_IsNet then
Result := True;
if g_Game_IsNet then
Exit;
end;
Exit;
end;
-// Ïîäîáðàë ñâîé ôëàã - âåðíóë åãî íà áàçó:
+// Подобрал свой флаг - вернул его на базу:
if (Flag = FTeam) and
(gFlags[Flag].State = FLAG_STATE_DROPPED) then
begin
if (Flag = FTeam) and
(gFlags[Flag].State = FLAG_STATE_DROPPED) then
begin
g_Map_ResetFlag(Flag);
g_Game_Message(Format(_lc[I_MESSAGE_FLAG_RETURN], [AnsiUpperCase(s)]), 144);
g_Map_ResetFlag(Flag);
g_Game_Message(Format(_lc[I_MESSAGE_FLAG_RETURN], [AnsiUpperCase(s)]), 144);
+ if ((Self = gPlayer1) or (Self = gPlayer2)
+ or ((gPlayer1 <> nil) and (gPlayer1.Team = FTeam))
+ or ((gPlayer2 <> nil) and (gPlayer2.Team = FTeam))) then
+ a := 0
+ else
+ a := 1;
+
+ if not sound_ret_flag[a].IsPlaying() then
+ sound_ret_flag[a].Play();
+
Result := True;
if g_Game_IsNet then
begin
Result := True;
if g_Game_IsNet then
begin
Exit;
end;
Exit;
end;
-// Ïîäîáðàë ÷óæîé ôëàã:
+// Подобрал чужой флаг:
if (Flag <> FTeam) and (FTime[T_FLAGCAP] <= gTime) then
begin
SetFlag(Flag);
if (Flag <> FTeam) and (FTime[T_FLAGCAP] <= gTime) then
begin
SetFlag(Flag);
gFlags[Flag].State := FLAG_STATE_CAPTURED;
gFlags[Flag].State := FLAG_STATE_CAPTURED;
+ if ((Self = gPlayer1) or (Self = gPlayer2)
+ or ((gPlayer1 <> nil) and (gPlayer1.Team = FTeam))
+ or ((gPlayer2 <> nil) and (gPlayer2.Team = FTeam))) then
+ a := 0
+ else
+ a := 1;
+
+ if not sound_get_flag[a].IsPlaying() then
+ sound_get_flag[a].Play();
+
Result := True;
if g_Game_IsNet then
begin
Result := True;
if g_Game_IsNet then
begin
FModel.SetFlag(FFlag);
end;
FModel.SetFlag(FFlag);
end;
-function TPlayer.DropFlag(): Boolean;
+function TPlayer.TryDropFlag(): Boolean;
+begin
+ if LongBool(gGameSettings.Options and GAME_OPTION_ALLOWDROPFLAG) then
+ Result := DropFlag(False, LongBool(gGameSettings.Options and GAME_OPTION_THROWFLAG))
+ else
+ Result := False;
+end;
+
+function TPlayer.DropFlag(Silent: Boolean = True; DoThrow: Boolean = False): Boolean;
var
s: String;
var
s: String;
+ a: Byte;
+ xv, yv: Integer;
begin
Result := False;
if (not g_Game_IsServer) or (FFlag = FLAG_NONE) then
begin
Result := False;
if (not g_Game_IsServer) or (FFlag = FLAG_NONE) then
Direction := FDirection;
State := FLAG_STATE_DROPPED;
Count := FLAG_TIME;
Direction := FDirection;
State := FLAG_STATE_DROPPED;
Count := FLAG_TIME;
- g_Obj_Push(@Obj, (FObj.Vel.X div 2)-2+Random(5),
- (FObj.Vel.Y div 2)-2+Random(5));
+ if DoThrow then
+ begin
+ xv := FObj.Vel.X + IfThen(Direction = TDirection.D_RIGHT, 10, -10);
+ yv := FObj.Vel.Y - 2;
+ end
+ else
+ begin
+ xv := (FObj.Vel.X div 2);
+ yv := (FObj.Vel.Y div 2) - 2;
+ end;
+ g_Obj_Push(@Obj, xv, yv);
+
positionChanged(); // this updates spatial accelerators
if FFlag = FLAG_RED then
positionChanged(); // this updates spatial accelerators
if FFlag = FLAG_RED then
g_Console_Add(Format(_lc[I_PLAYER_FLAG_DROP], [FName, s]), True);
g_Game_Message(Format(_lc[I_MESSAGE_FLAG_DROP], [AnsiUpperCase(s)]), 144);
g_Console_Add(Format(_lc[I_PLAYER_FLAG_DROP], [FName, s]), True);
g_Game_Message(Format(_lc[I_MESSAGE_FLAG_DROP], [AnsiUpperCase(s)]), 144);
+ if ((Self = gPlayer1) or (Self = gPlayer2)
+ or ((gPlayer1 <> nil) and (gPlayer1.Team = FTeam))
+ or ((gPlayer2 <> nil) and (gPlayer2.Team = FTeam))) then
+ a := 0
+ else
+ a := 1;
+
+ if (not Silent) and (not sound_lost_flag[a].IsPlaying()) then
+ sound_lost_flag[a].Play();
+
if g_Game_IsNet then
MH_SEND_FlagEvent(FLAG_STATE_DROPPED, Flag, FUID, False);
end;
if g_Game_IsNet then
MH_SEND_FlagEvent(FLAG_STATE_DROPPED, Flag, FUID, False);
end;
procedure TPlayer.GetSecret();
begin
procedure TPlayer.GetSecret();
begin
+ if (self = gPlayer1) or (self = gPlayer2) then
+ begin
+ g_Console_Add(Format(_lc[I_PLAYER_SECRET], [FName]), True);
+ g_Sound_PlayEx('SOUND_GAME_SECRET');
+ end;
Inc(FSecrets);
end;
Inc(FSecrets);
end;
procedure TPlayer.RememberState();
var
i: Integer;
procedure TPlayer.RememberState();
var
i: Integer;
-begin
- FSavedState.Health := FHealth;
- FSavedState.Armor := FArmor;
- FSavedState.Air := FAir;
- FSavedState.JetFuel := FJetFuel;
- FSavedState.CurrWeap := FCurrWeap;
- FSavedState.NextWeap := FNextWeap;
- FSavedState.NextWeapDelay := FNextWeapDelay;
-
- for i := 0 to 3 do
- FSavedState.Ammo[i] := FAmmo[i];
- for i := 0 to 3 do
- FSavedState.MaxAmmo[i] := FMaxAmmo[i];
+ SavedState: TPlayerSavedState;
+begin
+ SavedState.Health := FHealth;
+ SavedState.Armor := FArmor;
+ SavedState.Air := FAir;
+ SavedState.JetFuel := FJetFuel;
+ SavedState.CurrWeap := FCurrWeap;
+ SavedState.NextWeap := FNextWeap;
+ SavedState.NextWeapDelay := FNextWeapDelay;
+ for i := Low(FWeapon) to High(FWeapon) do
+ SavedState.Weapon[i] := FWeapon[i];
+ for i := Low(FAmmo) to High(FAmmo) do
+ SavedState.Ammo[i] := FAmmo[i];
+ for i := Low(FMaxAmmo) to High(FMaxAmmo) do
+ SavedState.MaxAmmo[i] := FMaxAmmo[i];
+ SavedState.Rulez := FRulez - [R_KEY_RED, R_KEY_GREEN, R_KEY_BLUE];
+
+ FSavedStateNum := -1;
+ for i := Low(SavedStates) to High(SavedStates) do
+ if not SavedStates[i].Used then
+ begin
+ FSavedStateNum := i;
+ break;
+ end;
+ if FSavedStateNum < 0 then
+ begin
+ SetLength(SavedStates, Length(SavedStates) + 1);
+ FSavedStateNum := High(SavedStates);
+ end;
- FSavedState.Rulez := FRulez;
- FSavedState.WaitRecall := True;
+ SavedState.Used := True;
+ SavedStates[FSavedStateNum] := SavedState;
end;
procedure TPlayer.RecallState();
var
i: Integer;
end;
procedure TPlayer.RecallState();
var
i: Integer;
+ SavedState: TPlayerSavedState;
begin
begin
- if not FSavedState.WaitRecall then Exit;
-
- FHealth := FSavedState.Health;
- FArmor := FSavedState.Armor;
- FAir := FSavedState.Air;
- FJetFuel := FSavedState.JetFuel;
- FCurrWeap := FSavedState.CurrWeap;
- FNextWeap := FSavedState.NextWeap;
- FNextWeapDelay := FSavedState.NextWeapDelay;
-
- for i := 0 to 3 do
- FAmmo[i] := FSavedState.Ammo[i];
- for i := 0 to 3 do
- FMaxAmmo[i] := FSavedState.MaxAmmo[i];
+ if(FSavedStateNum < 0) or (FSavedStateNum > High(SavedStates)) then
+ Exit;
- FRulez := FSavedState.Rulez;
- FSavedState.WaitRecall := False;
+ SavedState := SavedStates[FSavedStateNum];
+ SavedStates[FSavedStateNum].Used := False;
+ FSavedStateNum := -1;
+
+ FHealth := SavedState.Health;
+ FArmor := SavedState.Armor;
+ FAir := SavedState.Air;
+ FJetFuel := SavedState.JetFuel;
+ FCurrWeap := SavedState.CurrWeap;
+ FNextWeap := SavedState.NextWeap;
+ FNextWeapDelay := SavedState.NextWeapDelay;
+ for i := Low(FWeapon) to High(FWeapon) do
+ FWeapon[i] := SavedState.Weapon[i];
+ for i := Low(FAmmo) to High(FAmmo) do
+ FAmmo[i] := SavedState.Ammo[i];
+ for i := Low(FMaxAmmo) to High(FMaxAmmo) do
+ FMaxAmmo[i] := SavedState.MaxAmmo[i];
+ FRulez := SavedState.Rulez;
if gGameSettings.GameType = GT_SERVER then
MH_SEND_PlayerStats(FUID);
if gGameSettings.GameType = GT_SERVER then
MH_SEND_PlayerStats(FUID);
i: Integer;
b: Byte;
begin
i: Integer;
b: Byte;
begin
- // Ñèãíàòóðà èãðîêà
+ // Сигнатура игрока
utils.writeSign(st, 'PLYR');
utils.writeInt(st, Byte(PLR_SAVE_VERSION)); // version
utils.writeSign(st, 'PLYR');
utils.writeInt(st, Byte(PLR_SAVE_VERSION)); // version
- // Áîò èëè ÷åëîâåê
+ // Бот или человек
utils.writeBool(st, FIamBot);
utils.writeBool(st, FIamBot);
- // UID èãðîêà
+ // UID игрока
utils.writeInt(st, Word(FUID));
utils.writeInt(st, Word(FUID));
- // Èìÿ èãðîêà
+ // Имя игрока
utils.writeStr(st, FName);
utils.writeStr(st, FName);
- // Êîìàíäà
+ // Команда
utils.writeInt(st, Byte(FTeam));
utils.writeInt(st, Byte(FTeam));
- // Æèâ ëè
+ // Жив ли
utils.writeBool(st, FAlive);
utils.writeBool(st, FAlive);
- // Èçðàñõîäîâàë ëè âñå æèçíè
+ // Израсходовал ли все жизни
utils.writeBool(st, FNoRespawn);
utils.writeBool(st, FNoRespawn);
- // Íàïðàâëåíèå
+ // Направление
if FDirection = TDirection.D_LEFT then b := 1 else b := 2; // D_RIGHT
utils.writeInt(st, Byte(b));
if FDirection = TDirection.D_LEFT then b := 1 else b := 2; // D_RIGHT
utils.writeInt(st, Byte(b));
- // Çäîðîâüå
+ // Здоровье
utils.writeInt(st, LongInt(FHealth));
utils.writeInt(st, LongInt(FHealth));
- // Æèçíè
+ // Коэффициент инвалидности
+ utils.writeInt(st, LongInt(FHandicap));
+ // Жизни
utils.writeInt(st, Byte(FLives));
utils.writeInt(st, Byte(FLives));
- // Áðîíÿ
+ // Броня
utils.writeInt(st, LongInt(FArmor));
utils.writeInt(st, LongInt(FArmor));
- // Çàïàñ âîçäóõà
+ // Запас воздуха
utils.writeInt(st, LongInt(FAir));
utils.writeInt(st, LongInt(FAir));
- // Çàïàñ ãîðþ÷åãî
+ // Запас горючего
utils.writeInt(st, LongInt(FJetFuel));
utils.writeInt(st, LongInt(FJetFuel));
- // Áîëü
+ // Боль
utils.writeInt(st, LongInt(FPain));
utils.writeInt(st, LongInt(FPain));
- // Óáèë
+ // Убил
utils.writeInt(st, LongInt(FKills));
utils.writeInt(st, LongInt(FKills));
- // Óáèë ìîíñòðîâ
+ // Убил монстров
utils.writeInt(st, LongInt(FMonsterKills));
utils.writeInt(st, LongInt(FMonsterKills));
- // Ôðàãîâ
+ // Фрагов
utils.writeInt(st, LongInt(FFrags));
utils.writeInt(st, LongInt(FFrags));
- // Ôðàãîâ ïîäðÿä
+ // Фрагов подряд
utils.writeInt(st, Byte(FFragCombo));
utils.writeInt(st, Byte(FFragCombo));
- // Âðåìÿ ïîñëåäíåãî ôðàãà
+ // Время последнего фрага
utils.writeInt(st, LongWord(FLastFrag));
utils.writeInt(st, LongWord(FLastFrag));
- // Ñìåðòåé
+ // Смертей
utils.writeInt(st, LongInt(FDeath));
utils.writeInt(st, LongInt(FDeath));
- // Êàêîé ôëàã íåñåò
+ // Какой флаг несет
utils.writeInt(st, Byte(FFlag));
utils.writeInt(st, Byte(FFlag));
- // Íàøåë ñåêðåòîâ
+ // Нашел секретов
utils.writeInt(st, LongInt(FSecrets));
utils.writeInt(st, LongInt(FSecrets));
- // Òåêóùåå îðóæèå
+ // Текущее оружие
utils.writeInt(st, Byte(FCurrWeap));
utils.writeInt(st, Byte(FCurrWeap));
- // Æåëàåìîå îðóæèå
+ // Желаемое оружие
utils.writeInt(st, Word(FNextWeap));
utils.writeInt(st, Word(FNextWeap));
- // ...è ïàóçà
+ // ...и пауза
utils.writeInt(st, Byte(FNextWeapDelay));
utils.writeInt(st, Byte(FNextWeapDelay));
- // Âðåìÿ çàðÿäêè BFG
+ // Время зарядки BFG
utils.writeInt(st, SmallInt(FBFGFireCounter));
utils.writeInt(st, SmallInt(FBFGFireCounter));
- // Áóôåð óðîíà
+ // Буфер урона
utils.writeInt(st, LongInt(FDamageBuffer));
utils.writeInt(st, LongInt(FDamageBuffer));
- // Ïîñëåäíèé óäàðèâøèé
+ // Последний ударивший
utils.writeInt(st, Word(FLastSpawnerUID));
utils.writeInt(st, Word(FLastSpawnerUID));
- // Òèï ïîñëåäíåãî ïîëó÷åííîãî óðîíà
+ // Тип последнего полученного урона
utils.writeInt(st, Byte(FLastHit));
utils.writeInt(st, Byte(FLastHit));
- // Îáúåêò èãðîêà
+ // Объект игрока
Obj_SaveState(st, @FObj);
Obj_SaveState(st, @FObj);
- // Òåêóùåå êîëè÷åñòâî ïàòðîíîâ
+ // Текущее количество патронов
for i := A_BULLETS to A_HIGH do utils.writeInt(st, Word(FAmmo[i]));
for i := A_BULLETS to A_HIGH do utils.writeInt(st, Word(FAmmo[i]));
- // Ìàêñèìàëüíîå êîëè÷åñòâî ïàòðîíîâ
+ // Максимальное количество патронов
for i := A_BULLETS to A_HIGH do utils.writeInt(st, Word(FMaxAmmo[i]));
for i := A_BULLETS to A_HIGH do utils.writeInt(st, Word(FMaxAmmo[i]));
- // Íàëè÷èå îðóæèÿ
+ // Наличие оружия
for i := WP_FIRST to WP_LAST do utils.writeBool(st, FWeapon[i]);
for i := WP_FIRST to WP_LAST do utils.writeBool(st, FWeapon[i]);
- // Âðåìÿ ïåðåçàðÿäêè îðóæèÿ
+ // Время перезарядки оружия
for i := WP_FIRST to WP_LAST do utils.writeInt(st, Word(FReloading[i]));
for i := WP_FIRST to WP_LAST do utils.writeInt(st, Word(FReloading[i]));
- // Íàëè÷èå ðþêçàêà
+ // Наличие рюкзака
utils.writeBool(st, (R_ITEM_BACKPACK in FRulez));
utils.writeBool(st, (R_ITEM_BACKPACK in FRulez));
- // Íàëè÷èå êðàñíîãî êëþ÷à
+ // Наличие красного ключа
utils.writeBool(st, (R_KEY_RED in FRulez));
utils.writeBool(st, (R_KEY_RED in FRulez));
- // Íàëè÷èå çåëåíîãî êëþ÷à
+ // Наличие зеленого ключа
utils.writeBool(st, (R_KEY_GREEN in FRulez));
utils.writeBool(st, (R_KEY_GREEN in FRulez));
- // Íàëè÷èå ñèíåãî êëþ÷à
+ // Наличие синего ключа
utils.writeBool(st, (R_KEY_BLUE in FRulez));
utils.writeBool(st, (R_KEY_BLUE in FRulez));
- // Íàëè÷èå áåðñåðêà
+ // Наличие берсерка
utils.writeBool(st, (R_BERSERK in FRulez));
utils.writeBool(st, (R_BERSERK in FRulez));
- // Âðåìÿ äåéñòâèÿ ñïåöèàëüíûõ ïðåäìåòîâ
+ // Время действия специальных предметов
for i := MR_SUIT to MR_MAX do utils.writeInt(st, LongWord(FMegaRulez[i]));
for i := MR_SUIT to MR_MAX do utils.writeInt(st, LongWord(FMegaRulez[i]));
- // Âðåìÿ äî ïîâòîðíîãî ðåñïàóíà, ñìåíû îðóæèÿ, èñîëüçîâàíèÿ, çàõâàòà ôëàãà
+ // Время до повторного респауна, смены оружия, исользования, захвата флага
for i := T_RESPAWN to T_FLAGCAP do utils.writeInt(st, LongWord(FTime[i]));
for i := T_RESPAWN to T_FLAGCAP do utils.writeInt(st, LongWord(FTime[i]));
- // Íàçâàíèå ìîäåëè
- utils.writeStr(st, FModel.Name);
- // Öâåò ìîäåëè
+ // Название модели
+ utils.writeStr(st, FModel.GetName());
+ // Цвет модели
utils.writeInt(st, Byte(FColor.R));
utils.writeInt(st, Byte(FColor.G));
utils.writeInt(st, Byte(FColor.B));
utils.writeInt(st, Byte(FColor.R));
utils.writeInt(st, Byte(FColor.G));
utils.writeInt(st, Byte(FColor.B));
begin
assert(st <> nil);
begin
assert(st <> nil);
- // Ñèãíàòóðà èãðîêà
+ // Сигнатура игрока
if not utils.checkSign(st, 'PLYR') then raise XStreamError.Create('invalid player signature');
if (utils.readByte(st) <> PLR_SAVE_VERSION) then raise XStreamError.Create('invalid player version');
if not utils.checkSign(st, 'PLYR') then raise XStreamError.Create('invalid player signature');
if (utils.readByte(st) <> PLR_SAVE_VERSION) then raise XStreamError.Create('invalid player version');
- // Áîò èëè ÷åëîâåê:
+ // Бот или человек:
FIamBot := utils.readBool(st);
FIamBot := utils.readBool(st);
- // UID èãðîêà
+ // UID игрока
FUID := utils.readWord(st);
FUID := utils.readWord(st);
- // Èìÿ èãðîêà
+ // Имя игрока
str := utils.readStr(st);
if (self <> gPlayer1) and (self <> gPlayer2) then FName := str;
str := utils.readStr(st);
if (self <> gPlayer1) and (self <> gPlayer2) then FName := str;
- // Êîìàíäà
+ // Команда
FTeam := utils.readByte(st);
FTeam := utils.readByte(st);
- // Æèâ ëè
+ // Жив ли
FAlive := utils.readBool(st);
FAlive := utils.readBool(st);
- // Èçðàñõîäîâàë ëè âñå æèçíè
+ // Израсходовал ли все жизни
FNoRespawn := utils.readBool(st);
FNoRespawn := utils.readBool(st);
- // Íàïðàâëåíèå
+ // Направление
b := utils.readByte(st);
if b = 1 then FDirection := TDirection.D_LEFT else FDirection := TDirection.D_RIGHT; // b = 2
b := utils.readByte(st);
if b = 1 then FDirection := TDirection.D_LEFT else FDirection := TDirection.D_RIGHT; // b = 2
- // Çäîðîâüå
+ // Здоровье
FHealth := utils.readLongInt(st);
FHealth := utils.readLongInt(st);
- // Æèçíè
+ // Коэффициент инвалидности
+ FHandicap := utils.readLongInt(st);
+ // Жизни
FLives := utils.readByte(st);
FLives := utils.readByte(st);
- // Áðîíÿ
+ // Броня
FArmor := utils.readLongInt(st);
FArmor := utils.readLongInt(st);
- // Çàïàñ âîçäóõà
+ // Запас воздуха
FAir := utils.readLongInt(st);
FAir := utils.readLongInt(st);
- // Çàïàñ ãîðþ÷åãî
+ // Запас горючего
FJetFuel := utils.readLongInt(st);
FJetFuel := utils.readLongInt(st);
- // Áîëü
+ // Боль
FPain := utils.readLongInt(st);
FPain := utils.readLongInt(st);
- // Óáèë
+ // Убил
FKills := utils.readLongInt(st);
FKills := utils.readLongInt(st);
- // Óáèë ìîíñòðîâ
+ // Убил монстров
FMonsterKills := utils.readLongInt(st);
FMonsterKills := utils.readLongInt(st);
- // Ôðàãîâ
+ // Фрагов
FFrags := utils.readLongInt(st);
FFrags := utils.readLongInt(st);
- // Ôðàãîâ ïîäðÿä
+ // Фрагов подряд
FFragCombo := utils.readByte(st);
FFragCombo := utils.readByte(st);
- // Âðåìÿ ïîñëåäíåãî ôðàãà
+ // Время последнего фрага
FLastFrag := utils.readLongWord(st);
FLastFrag := utils.readLongWord(st);
- // Ñìåðòåé
+ // Смертей
FDeath := utils.readLongInt(st);
FDeath := utils.readLongInt(st);
- // Êàêîé ôëàã íåñåò
+ // Какой флаг несет
FFlag := utils.readByte(st);
FFlag := utils.readByte(st);
- // Íàøåë ñåêðåòîâ
+ // Нашел секретов
FSecrets := utils.readLongInt(st);
FSecrets := utils.readLongInt(st);
- // Òåêóùåå îðóæèå
+ // Текущее оружие
FCurrWeap := utils.readByte(st);
FCurrWeap := utils.readByte(st);
- // Æåëàåìîå îðóæèå
+ // Желаемое оружие
FNextWeap := utils.readWord(st);
FNextWeap := utils.readWord(st);
- // ...è ïàóçà
+ // ...и пауза
FNextWeapDelay := utils.readByte(st);
FNextWeapDelay := utils.readByte(st);
- // Âðåìÿ çàðÿäêè BFG
+ // Время зарядки BFG
FBFGFireCounter := utils.readSmallInt(st);
FBFGFireCounter := utils.readSmallInt(st);
- // Áóôåð óðîíà
+ // Буфер урона
FDamageBuffer := utils.readLongInt(st);
FDamageBuffer := utils.readLongInt(st);
- // Ïîñëåäíèé óäàðèâøèé
+ // Последний ударивший
FLastSpawnerUID := utils.readWord(st);
FLastSpawnerUID := utils.readWord(st);
- // Òèï ïîñëåäíåãî ïîëó÷åííîãî óðîíà
+ // Тип последнего полученного урона
FLastHit := utils.readByte(st);
FLastHit := utils.readByte(st);
- // Îáúåêò èãðîêà
+ // Объект игрока
Obj_LoadState(@FObj, st);
Obj_LoadState(@FObj, st);
- // Òåêóùåå êîëè÷åñòâî ïàòðîíîâ
+ // Текущее количество патронов
for i := A_BULLETS to A_HIGH do FAmmo[i] := utils.readWord(st);
for i := A_BULLETS to A_HIGH do FAmmo[i] := utils.readWord(st);
- // Ìàêñèìàëüíîå êîëè÷åñòâî ïàòðîíîâ
+ // Максимальное количество патронов
for i := A_BULLETS to A_HIGH do FMaxAmmo[i] := utils.readWord(st);
for i := A_BULLETS to A_HIGH do FMaxAmmo[i] := utils.readWord(st);
- // Íàëè÷èå îðóæèÿ
+ // Наличие оружия
for i := WP_FIRST to WP_LAST do FWeapon[i] := utils.readBool(st);
for i := WP_FIRST to WP_LAST do FWeapon[i] := utils.readBool(st);
- // Âðåìÿ ïåðåçàðÿäêè îðóæèÿ
+ // Время перезарядки оружия
for i := WP_FIRST to WP_LAST do FReloading[i] := utils.readWord(st);
for i := WP_FIRST to WP_LAST do FReloading[i] := utils.readWord(st);
- // Íàëè÷èå ðþêçàêà
+ // Наличие рюкзака
if utils.readBool(st) then Include(FRulez, R_ITEM_BACKPACK);
if utils.readBool(st) then Include(FRulez, R_ITEM_BACKPACK);
- // Íàëè÷èå êðàñíîãî êëþ÷à
+ // Наличие красного ключа
if utils.readBool(st) then Include(FRulez, R_KEY_RED);
if utils.readBool(st) then Include(FRulez, R_KEY_RED);
- // Íàëè÷èå çåëåíîãî êëþ÷à
+ // Наличие зеленого ключа
if utils.readBool(st) then Include(FRulez, R_KEY_GREEN);
if utils.readBool(st) then Include(FRulez, R_KEY_GREEN);
- // Íàëè÷èå ñèíåãî êëþ÷à
+ // Наличие синего ключа
if utils.readBool(st) then Include(FRulez, R_KEY_BLUE);
if utils.readBool(st) then Include(FRulez, R_KEY_BLUE);
- // Íàëè÷èå áåðñåðêà
+ // Наличие берсерка
if utils.readBool(st) then Include(FRulez, R_BERSERK);
if utils.readBool(st) then Include(FRulez, R_BERSERK);
- // Âðåìÿ äåéñòâèÿ ñïåöèàëüíûõ ïðåäìåòîâ
+ // Время действия специальных предметов
for i := MR_SUIT to MR_MAX do FMegaRulez[i] := utils.readLongWord(st);
for i := MR_SUIT to MR_MAX do FMegaRulez[i] := utils.readLongWord(st);
- // Âðåìÿ äî ïîâòîðíîãî ðåñïàóíà, ñìåíû îðóæèÿ, èñîëüçîâàíèÿ, çàõâàòà ôëàãà
+ // Время до повторного респауна, смены оружия, исользования, захвата флага
for i := T_RESPAWN to T_FLAGCAP do FTime[i] := utils.readLongWord(st);
for i := T_RESPAWN to T_FLAGCAP do FTime[i] := utils.readLongWord(st);
- // Íàçâàíèå ìîäåëè
+ // Название модели
str := utils.readStr(st);
str := utils.readStr(st);
- // Öâåò ìîäåëè
+ // Цвет модели
FColor.R := utils.readByte(st);
FColor.G := utils.readByte(st);
FColor.B := utils.readByte(st);
FColor.R := utils.readByte(st);
FColor.G := utils.readByte(st);
FColor.B := utils.readByte(st);
str := gPlayer2Settings.Model;
FColor := gPlayer2Settings.Color;
end;
str := gPlayer2Settings.Model;
FColor := gPlayer2Settings.Color;
end;
- // Îáíîâëÿåì ìîäåëü èãðîêà
+ // Обновляем модель игрока
SetModel(str);
if gGameSettings.GameMode in [GM_TDM, GM_CTF] then
FModel.Color := TEAMCOLOR[FTeam]
SetModel(str);
if gGameSettings.GameMode in [GM_TDM, GM_CTF] then
FModel.Color := TEAMCOLOR[FTeam]
if FMegaRulez[MR_INVUL] < gTime+PLAYER_INVUL_TIME then
begin
FMegaRulez[MR_INVUL] := gTime+PLAYER_INVUL_TIME;
if FMegaRulez[MR_INVUL] < gTime+PLAYER_INVUL_TIME then
begin
FMegaRulez[MR_INVUL] := gTime+PLAYER_INVUL_TIME;
+ FSpawnInvul := 0;
end;
ITEM_INVIS:
end;
ITEM_INVIS:
end;
procedure TPlayer.FlySmoke(Times: DWORD = 1);
end;
procedure TPlayer.FlySmoke(Times: DWORD = 1);
-var
- id, i: DWORD;
- Anim: TAnimation;
+ var i: DWORD;
begin
if (Random(5) = 1) and (Times = 1) then
Exit;
if BodyInLiquid(0, 0) then
begin
begin
if (Random(5) = 1) and (Times = 1) then
Exit;
if BodyInLiquid(0, 0) then
begin
- g_GFX_Bubbles(Obj.X+Obj.Rect.X+(Obj.Rect.Width div 2)+Random(3)-1,
- Obj.Y+Obj.Rect.Height+8, 1, 8, 4);
- if Random(2) = 0 then
- g_Sound_PlayExAt('SOUND_GAME_BUBBLE1', FObj.X, FObj.Y)
- else
- g_Sound_PlayExAt('SOUND_GAME_BUBBLE2', FObj.X, FObj.Y);
+ {$IFDEF ENABLE_GFX}
+ g_GFX_Bubbles(Obj.X+Obj.Rect.X+(Obj.Rect.Width div 2)+Random(3)-1,
+ Obj.Y+Obj.Rect.Height+8, 1, 8, 4);
+ {$ENDIF}
+ if Random(2) = 0
+ then g_Sound_PlayExAt('SOUND_GAME_BUBBLE1', FObj.X, FObj.Y)
+ else g_Sound_PlayExAt('SOUND_GAME_BUBBLE2', FObj.X, FObj.Y);
Exit;
end;
Exit;
end;
- if g_Frames_Get(id, 'FRAMES_SMOKE') then
+ for i := 1 to Times do
begin
begin
- for i := 1 to Times do
- begin
- Anim := TAnimation.Create(id, False, 3);
- Anim.Alpha := 150;
- g_GFX_OnceAnim(Obj.X+Obj.Rect.X+Random(Obj.Rect.Width+Times*2)-(Anim.Width div 2),
- Obj.Y+Obj.Rect.Height-4+Random(8+Times*2), Anim, ONCEANIM_SMOKE);
- Anim.Free();
- end;
+ {$IFDEF ENABLE_GFX}
+ g_GFX_QueueEffect(
+ R_GFX_SMOKE_TRANS,
+ Obj.X+Obj.Rect.X+Random(Obj.Rect.Width+Times*2)-(R_GFX_SMOKE_WIDTH div 2),
+ Obj.Y+Obj.Rect.Height-4+Random(8+Times*2)
+ );
+ {$ENDIF}
end;
end;
procedure TPlayer.OnFireFlame(Times: DWORD = 1);
end;
end;
procedure TPlayer.OnFireFlame(Times: DWORD = 1);
-var
- id, i: DWORD;
- Anim: TAnimation;
+ var i: DWORD;
begin
if (Random(10) = 1) and (Times = 1) then
Exit;
begin
if (Random(10) = 1) and (Times = 1) then
Exit;
- if g_Frames_Get(id, 'FRAMES_FLAME') then
+ for i := 1 to Times do
begin
begin
- for i := 1 to Times do
- begin
- Anim := TAnimation.Create(id, False, 3);
- Anim.Alpha := 0;
- g_GFX_OnceAnim(Obj.X+Obj.Rect.X+Random(Obj.Rect.Width+Times*2)-(Anim.Width div 2),
- Obj.Y+8+Random(8+Times*2), Anim, ONCEANIM_SMOKE);
- Anim.Free();
- end;
+ {$IFDEF ENABLE_GFX}
+ g_GFX_QueueEffect(
+ R_GFX_FLAME,
+ Obj.X+Obj.Rect.X+Random(Obj.Rect.Width+Times*2)-(R_GFX_FLAME_WIDTH div 2),
+ Obj.Y+8+Random(8+Times*2)
+ );
+ {$ENDIF}
end;
end;
end;
end;
FSawSoundIdle.Pause(Enable);
FSawSoundHit.Pause(Enable);
FSawSoundSelect.Pause(Enable);
FSawSoundIdle.Pause(Enable);
FSawSoundHit.Pause(Enable);
FSawSoundSelect.Pause(Enable);
-end;
-
-{ T C o r p s e : }
-
-constructor TCorpse.Create(X, Y: Integer; ModelName: String; aMess: Boolean);
-begin
- g_Obj_Init(@FObj);
- FObj.X := X;
- FObj.Y := Y;
- FObj.Rect := PLAYER_CORPSERECT;
- FModelName := ModelName;
- FMess := aMess;
-
- if FMess then
- begin
- FState := CORPSE_STATE_MESS;
- g_PlayerModel_GetAnim(ModelName, A_DIE2, FAnimation, FAnimationMask);
- end
- else
- begin
- FState := CORPSE_STATE_NORMAL;
- g_PlayerModel_GetAnim(ModelName, A_DIE1, FAnimation, FAnimationMask);
- end;
-end;
-
-destructor TCorpse.Destroy();
-begin
- FAnimation.Free();
-
- inherited;
-end;
-
-function TCorpse.ObjPtr (): PObj; inline; begin result := @FObj; end;
-
-procedure TCorpse.positionChanged (); inline; begin end;
-
-procedure TCorpse.moveBy (dx, dy: Integer); inline;
-begin
- if (dx <> 0) or (dy <> 0) then
- begin
- FObj.X += dx;
- FObj.Y += dy;
- positionChanged();
- end;
-end;
-
-
-procedure TCorpse.getMapBox (out x, y, w, h: Integer); inline;
-begin
- x := FObj.X+PLAYER_CORPSERECT.X;
- y := FObj.Y+PLAYER_CORPSERECT.Y;
- w := PLAYER_CORPSERECT.Width;
- h := PLAYER_CORPSERECT.Height;
-end;
-
-
-procedure TCorpse.Damage(Value: Word; vx, vy: Integer);
-var
- pm: TPlayerModel;
- Blood: TModelBlood;
-begin
- if FState = CORPSE_STATE_REMOVEME then
- Exit;
-
- FDamage := FDamage + Value;
-
- if FDamage > 150 then
- begin
- if FAnimation <> nil then
- begin
- FAnimation.Free();
- FAnimation := nil;
-
- FState := CORPSE_STATE_REMOVEME;
-
- g_Player_CreateGibs(FObj.X+FObj.Rect.X+(FObj.Rect.Width div 2),
- FObj.Y+FObj.Rect.Y+(FObj.Rect.Height div 2),
- FModelName, FColor);
- // Çâóê ìÿñà îò òðóïà:
- pm := g_PlayerModel_Get(FModelName);
- pm.PlaySound(MODELSOUND_DIE, 5, FObj.X, FObj.Y);
- pm.Free;
-
- // Çëîâåùèé ñìåõ:
- if (gBodyKillEvent <> -1)
- and gDelayedEvents[gBodyKillEvent].Pending then
- gDelayedEvents[gBodyKillEvent].Pending := False;
- gBodyKillEvent := g_Game_DelayEvent(DE_BODYKILL, 1050, 0);
- end;
- end
- else
- begin
- Blood := g_PlayerModel_GetBlood(FModelName);
- FObj.Vel.X := FObj.Vel.X + vx;
- FObj.Vel.Y := FObj.Vel.Y + vy;
- g_GFX_Blood(FObj.X+PLAYER_CORPSERECT.X+(PLAYER_CORPSERECT.Width div 2),
- FObj.Y+PLAYER_CORPSERECT.Y+(PLAYER_CORPSERECT.Height div 2),
- Value, vx, vy, 16, (PLAYER_CORPSERECT.Height*2) div 3,
- Blood.R, Blood.G, Blood.B, Blood.Kind);
- end;
-end;
-
-procedure TCorpse.Draw();
-begin
- if FState = CORPSE_STATE_REMOVEME then
- Exit;
-
- if FAnimation <> nil then
- FAnimation.Draw(FObj.X, FObj.Y, TMirrorType.None);
-
- if FAnimationMask <> nil then
- begin
- e_Colors := FColor;
- FAnimationMask.Draw(FObj.X, FObj.Y, TMirrorType.None);
- e_Colors.R := 255;
- e_Colors.G := 255;
- e_Colors.B := 255;
- end;
-end;
-
-procedure TCorpse.Update();
-var
- st: Word;
-begin
- if FState = CORPSE_STATE_REMOVEME then
- Exit;
-
- if gTime mod (GAME_TICK*2) <> 0 then
- begin
- g_Obj_Move(@FObj, True, True, True);
- positionChanged(); // this updates spatial accelerators
- Exit;
- end;
-
-// Ñîïðîòèâëåíèå âîçäóõà äëÿ òðóïà:
- FObj.Vel.X := z_dec(FObj.Vel.X, 1);
-
- st := g_Obj_Move(@FObj, True, True, True);
- positionChanged(); // this updates spatial accelerators
-
- if WordBool(st and MOVE_FALLOUT) then
- begin
- FState := CORPSE_STATE_REMOVEME;
- Exit;
- end;
-
- if FAnimation <> nil then
- FAnimation.Update();
- if FAnimationMask <> nil then
- FAnimationMask.Update();
-end;
-
-
-procedure TCorpse.SaveState (st: TStream);
-var
- anim: Boolean;
-begin
- assert(st <> nil);
-
- // Ñèãíàòóðà òðóïà
- utils.writeSign(st, 'CORP');
- utils.writeInt(st, Byte(0));
- // Ñîñòîÿíèå
- utils.writeInt(st, Byte(FState));
- // Íàêîïëåííûé óðîí
- utils.writeInt(st, Byte(FDamage));
- // Öâåò
- utils.writeInt(st, Byte(FColor.R));
- utils.writeInt(st, Byte(FColor.G));
- utils.writeInt(st, Byte(FColor.B));
- // Îáúåêò òðóïà
- Obj_SaveState(st, @FObj);
- utils.writeInt(st, Word(FPlayerUID));
- // Åñòü ëè àíèìàöèÿ
- anim := (FAnimation <> nil);
- utils.writeBool(st, anim);
- // Åñëè åñòü - ñîõðàíÿåì
- if anim then FAnimation.SaveState(st);
- // Åñòü ëè ìàñêà àíèìàöèè
- anim := (FAnimationMask <> nil);
- utils.writeBool(st, anim);
- // Åñëè åñòü - ñîõðàíÿåì
- if anim then FAnimationMask.SaveState(st);
-end;
-
-
-procedure TCorpse.LoadState (st: TStream);
-var
- anim: Boolean;
-begin
- assert(st <> nil);
-
- // Ñèãíàòóðà òðóïà
- if not utils.checkSign(st, 'CORP') then raise XStreamError.Create('invalid corpse signature');
- if (utils.readByte(st) <> 0) then raise XStreamError.Create('invalid corpse version');
- // Ñîñòîÿíèå
- FState := utils.readByte(st);
- // Íàêîïëåííûé óðîí
- FDamage := utils.readByte(st);
- // Öâåò
- FColor.R := utils.readByte(st);
- FColor.G := utils.readByte(st);
- FColor.B := utils.readByte(st);
- // Îáúåêò òðóïà
- Obj_LoadState(@FObj, st);
- FPlayerUID := utils.readWord(st);
- // Åñòü ëè àíèìàöèÿ
- anim := utils.readBool(st);
- // Åñëè åñòü - çàãðóæàåì
- if anim then
- begin
- Assert(FAnimation <> nil, 'TCorpse.LoadState: no FAnimation');
- FAnimation.LoadState(st);
- end;
- // Åñòü ëè ìàñêà àíèìàöèè
- anim := utils.readBool(st);
- // Åñëè åñòü - çàãðóæàåì
- if anim then
- begin
- Assert(FAnimationMask <> nil, 'TCorpse.LoadState: no FAnimationMask');
- FAnimationMask.LoadState(st);
- end;
+ FFlameSoundOn.Pause(Enable);
+ FFlameSoundOff.Pause(Enable);
+ FFlameSoundWork.Pause(Enable);
+ FJetSoundFly.Pause(Enable);
+ FJetSoundOn.Pause(Enable);
+ FJetSoundOff.Pause(Enable);
end;
{ T B o t : }
end;
{ T B o t : }
inherited Destroy();
end;
inherited Destroy();
end;
-procedure TBot.Draw();
-begin
- inherited Draw();
-
- //if FTargetUID <> 0 then e_DrawLine(1, FObj.X, FObj.Y, g_Player_Get(FTargetUID).FObj.X,
- // g_Player_Get(FTargetUID).FObj.Y, 255, 0, 0);
-end;
-
procedure TBot.Respawn(Silent: Boolean; Force: Boolean = False);
begin
inherited Respawn(Silent, Force);
procedure TBot.Respawn(Silent: Boolean; Force: Boolean = False);
begin
inherited Respawn(Silent, Force);
function Compare(a, b: TTarget): Integer;
begin
function Compare(a, b: TTarget): Integer;
begin
- if a.Line and not b.Line then // A íà ëèíèè îãíÿ
+ if a.Line and not b.Line then // A на линии огня
Result := -1
else
Result := -1
else
- if not a.Line and b.Line then // B íà ëèíèè îãíÿ
+ if not a.Line and b.Line then // B на линии огня
Result := 1
Result := 1
- else // È A, è B íà ëèíèè èëè íå íà ëèíèè îãíÿ
+ else // И A, и B на линии или не на линии огня
if (a.Line and b.Line) or ((not a.Line) and (not b.Line)) then
begin
if (a.Line and b.Line) or ((not a.Line) and (not b.Line)) then
begin
- if a.Dist > b.Dist then // B áëèæå
+ if a.Dist > b.Dist then // B ближе
Result := 1
Result := 1
- else // A áëèæå èëè ðàâíîóäàëåííî ñ B
+ else // A ближе или равноудаленно с B
Result := -1;
end
Result := -1;
end
- else // Ñòðàííî -> A
+ else // Странно -> A
Result := -1;
end;
Result := -1;
end;
x2 := mon.Obj.X+mon.Obj.Rect.X+(mon.Obj.Rect.Width div 2);
y2 := mon.Obj.Y+mon.Obj.Rect.Y+(mon.Obj.Rect.Height div 2);
x2 := mon.Obj.X+mon.Obj.Rect.X+(mon.Obj.Rect.Width div 2);
y2 := mon.Obj.Y+mon.Obj.Rect.Y+(mon.Obj.Rect.Height div 2);
- // Åñëè ìîíñòð íà ýêðàíå è íå ïðèêðûò ñòåíîé
+ // Если монстр на экране и не прикрыт стеной
if g_TraceVector(x1, y1, x2, y2) then
begin
if g_TraceVector(x1, y1, x2, y2) then
begin
- // Äîáàâëÿåì ê ñïèñêó âîçìîæíûõ öåëåé
+ // Добавляем к списку возможных целей
SetLength(targets, Length(targets)+1);
with targets[High(targets)] do
begin
SetLength(targets, Length(targets)+1);
with targets[High(targets)] do
begin
vsPlayer := LongBool(gGameSettings.Options and GAME_OPTION_BOTVSPLAYER);
vsMonster := LongBool(gGameSettings.Options and GAME_OPTION_BOTVSMONSTER);
vsPlayer := LongBool(gGameSettings.Options and GAME_OPTION_BOTVSPLAYER);
vsMonster := LongBool(gGameSettings.Options and GAME_OPTION_BOTVSMONSTER);
-// Åñëè òåêóùåå îðóæèå íå òî, ÷òî íóæíî, òî ìåíÿåì:
+// Если текущее оружие не то, что нужно, то меняем:
if FCurrWeap <> FSelectedWeapon then
NextWeapon();
if FCurrWeap <> FSelectedWeapon then
NextWeapon();
-// Åñëè íóæíî ñòðåëÿòü è íóæíîå îðóæèå, òî íàæàòü "Ñòðåëÿòü":
+// Если нужно стрелять и нужное оружие, то нажать "Стрелять":
if (GetAIFlag('NEEDFIRE') <> '') and (FCurrWeap = FSelectedWeapon) then
begin
RemoveAIFlag('NEEDFIRE');
if (GetAIFlag('NEEDFIRE') <> '') and (FCurrWeap = FSelectedWeapon) then
begin
RemoveAIFlag('NEEDFIRE');
end;
end;
end;
end;
-// Êîîðäèíàòû ñòâîëà:
+// Координаты ствола:
x1 := FObj.X + WEAPONPOINT[FDirection].X;
y1 := FObj.Y + WEAPONPOINT[FDirection].Y;
x1 := FObj.X + WEAPONPOINT[FDirection].X;
y1 := FObj.Y + WEAPONPOINT[FDirection].Y;
ok := False;
if Target.UID <> 0 then
ok := False;
if Target.UID <> 0 then
- begin // Öåëü åñòü - íàñòðàèâàåì
+ begin // Цель есть - настраиваем
if (g_GetUIDType(Target.UID) = UID_PLAYER) and
vsPlayer then
if (g_GetUIDType(Target.UID) = UID_PLAYER) and
vsPlayer then
- begin // Èãðîê
+ begin // Игрок
tpla := g_Player_Get(Target.UID);
if tpla <> nil then
with tpla do
tpla := g_Player_Get(Target.UID);
if tpla <> nil then
with tpla do
else
if (g_GetUIDType(Target.UID) = UID_MONSTER) and
vsMonster then
else
if (g_GetUIDType(Target.UID) = UID_MONSTER) and
vsMonster then
- begin // Ìîíñòð
+ begin // Монстр
mon := g_Monsters_ByUID(Target.UID);
if mon <> nil then
begin
mon := g_Monsters_ByUID(Target.UID);
if mon <> nil then
begin
end;
if not ok then
end;
if not ok then
- begin // Öåëè íåò - îáíóëÿåì
+ begin // Цели нет - обнуляем
Target.X := 0;
Target.Y := 0;
Target.cX := 0;
Target.X := 0;
Target.Y := 0;
Target.cX := 0;
targets := nil;
targets := nil;
-// Åñëè öåëü íå âèäèìà èëè íå íà ëèíèè îãíÿ, òî èùåì âñå âîçìîæíûå öåëè:
+// Если цель не видима или не на линии огня, то ищем все возможные цели:
if (not Target.Line) or (not Target.Visible) then
begin
if (not Target.Line) or (not Target.Visible) then
begin
- // Èãðîêè:
+ // Игроки:
if vsPlayer then
for a := 0 to High(gPlayers) do
if (gPlayers[a] <> nil) and (gPlayers[a].alive) and
if vsPlayer then
for a := 0 to High(gPlayers) do
if (gPlayers[a] <> nil) and (gPlayers[a].alive) and
x2 := gPlayers[a].FObj.X + PLAYER_RECT_CX;
y2 := gPlayers[a].FObj.Y + PLAYER_RECT_CY;
x2 := gPlayers[a].FObj.X + PLAYER_RECT_CX;
y2 := gPlayers[a].FObj.Y + PLAYER_RECT_CY;
- // Åñëè èãðîê íà ýêðàíå è íå ïðèêðûò ñòåíîé:
+ // Если игрок на экране и не прикрыт стеной:
if g_TraceVector(x1, y1, x2, y2) then
begin
if g_TraceVector(x1, y1, x2, y2) then
begin
- // Äîáàâëÿåì ê ñïèñêó âîçìîæíûõ öåëåé:
+ // Добавляем к списку возможных целей:
SetLength(targets, Length(targets)+1);
with targets[High(targets)] do
begin
SetLength(targets, Length(targets)+1);
with targets[High(targets)] do
begin
end;
end;
end;
end;
- // Ìîíñòðû:
+ // Монстры:
if vsMonster then g_Mons_ForEach(monsUpdate);
end;
if vsMonster then g_Mons_ForEach(monsUpdate);
end;
-// Åñëè åñòü âîçìîæíûå öåëè:
-// (Âûáèðàåì ëó÷øóþ, ìåíÿåì îðóæèå è áåæèì ê íåé/îò íåå)
+// Если есть возможные цели:
+// (Выбираем лучшую, меняем оружие и бежим к ней/от нее)
if targets <> nil then
begin
if targets <> nil then
begin
- // Âûáèðàåì íàèëó÷øóþ öåëü:
+ // Выбираем наилучшую цель:
BestTarget := targets[0];
if Length(targets) > 1 then
for a := 1 to High(targets) do
if Compare(BestTarget, targets[a]) = 1 then
BestTarget := targets[a];
BestTarget := targets[0];
if Length(targets) > 1 then
for a := 1 to High(targets) do
if Compare(BestTarget, targets[a]) = 1 then
BestTarget := targets[a];
- // Åñëè ëó÷øàÿ öåëü "âèäíåå" òåêóùåé, òî òåêóùàÿ := ëó÷øàÿ:
+ // Если лучшая цель "виднее" текущей, то текущая := лучшая:
if ((not Target.Visible) and BestTarget.Visible and (Target.UID <> BestTarget.UID)) or
((not Target.Line) and BestTarget.Line and BestTarget.Visible) then
begin
Target := BestTarget;
if (Healthy() = 3) or ((Healthy() = 2)) then
if ((not Target.Visible) and BestTarget.Visible and (Target.UID <> BestTarget.UID)) or
((not Target.Line) and BestTarget.Line and BestTarget.Visible) then
begin
Target := BestTarget;
if (Healthy() = 3) or ((Healthy() = 2)) then
- begin // Åñëè çäîðîâû - äîãîíÿåì
+ begin // Если здоровы - догоняем
if ((RunDirection() = TDirection.D_LEFT) and (Target.X > FObj.X)) then
SetAIFlag('GORIGHT', '1');
if ((RunDirection() = TDirection.D_RIGHT) and (Target.X < FObj.X)) then
SetAIFlag('GOLEFT', '1');
end
else
if ((RunDirection() = TDirection.D_LEFT) and (Target.X > FObj.X)) then
SetAIFlag('GORIGHT', '1');
if ((RunDirection() = TDirection.D_RIGHT) and (Target.X < FObj.X)) then
SetAIFlag('GOLEFT', '1');
end
else
- begin // Åñëè ïîáèòû - óáåãàåì
+ begin // Если побиты - убегаем
if ((RunDirection() = TDirection.D_LEFT) and (Target.X < FObj.X)) then
SetAIFlag('GORIGHT', '1');
if ((RunDirection() = TDirection.D_RIGHT) and (Target.X > FObj.X)) then
SetAIFlag('GOLEFT', '1');
end;
if ((RunDirection() = TDirection.D_LEFT) and (Target.X < FObj.X)) then
SetAIFlag('GORIGHT', '1');
if ((RunDirection() = TDirection.D_RIGHT) and (Target.X > FObj.X)) then
SetAIFlag('GOLEFT', '1');
end;
- // Âûáèðàåì îðóæèå íà îñíîâå ðàññòîÿíèÿ è ïðèîðèòåòîâ:
+ // Выбираем оружие на основе расстояния и приоритетов:
SelectWeapon(Abs(x1-Target.cX));
end;
end;
SelectWeapon(Abs(x1-Target.cX));
end;
end;
-// Åñëè åñòü öåëü:
-// (Äîãîíÿåì/óáåãàåì, ñòðåëÿåì ïî íàïðàâëåíèþ ê öåëè)
-// (Åñëè öåëü äàëåêî, òî õâàòèò ñëåäèòü çà íåé)
+// Если есть цель:
+// (Догоняем/убегаем, стреляем по направлению к цели)
+// (Если цель далеко, то хватит следить за ней)
if Target.UID <> 0 then
begin
if not TargetOnScreen(Target.X + Target.Rect.X,
Target.Y + Target.Rect.Y) then
if Target.UID <> 0 then
begin
if not TargetOnScreen(Target.X + Target.Rect.X,
Target.Y + Target.Rect.Y) then
- begin // Öåëü ñáåæàëà ñ "ýêðàíà"
+ begin // Цель сбежала с "экрана"
if (Healthy() = 3) or ((Healthy() = 2)) then
if (Healthy() = 3) or ((Healthy() = 2)) then
- begin // Åñëè çäîðîâû - äîãîíÿåì
+ begin // Если здоровы - догоняем
if ((RunDirection() = TDirection.D_LEFT) and (Target.X > FObj.X)) then
SetAIFlag('GORIGHT', '1');
if ((RunDirection() = TDirection.D_RIGHT) and (Target.X < FObj.X)) then
SetAIFlag('GOLEFT', '1');
end
else
if ((RunDirection() = TDirection.D_LEFT) and (Target.X > FObj.X)) then
SetAIFlag('GORIGHT', '1');
if ((RunDirection() = TDirection.D_RIGHT) and (Target.X < FObj.X)) then
SetAIFlag('GOLEFT', '1');
end
else
- begin // Åñëè ïîáèòû - çàáûâàåì î öåëè è óáåãàåì
+ begin // Если побиты - забываем о цели и убегаем
Target.UID := 0;
if ((RunDirection() = TDirection.D_LEFT) and (Target.X < FObj.X)) then
SetAIFlag('GORIGHT', '1');
Target.UID := 0;
if ((RunDirection() = TDirection.D_LEFT) and (Target.X < FObj.X)) then
SetAIFlag('GORIGHT', '1');
end;
end
else
end;
end
else
- begin // Öåëü ïîêà íà "ýêðàíå"
- // Åñëè öåëü íå çàãîðîæåíà ñòåíîé, òî îòìå÷àåì, êîãäà åå âèäåëè:
+ begin // Цель пока на "экране"
+ // Если цель не загорожена стеной, то отмечаем, когда ее видели:
if g_TraceVector(x1, y1, Target.cX, Target.cY) then
FLastVisible := gTime;
if g_TraceVector(x1, y1, Target.cX, Target.cY) then
FLastVisible := gTime;
- // Åñëè ðàçíèöà âûñîò íå âåëèêà, òî äîãîíÿåì:
+ // Если разница высот не велика, то догоняем:
if (Abs(FObj.Y-Target.Y) <= 128) then
begin
if ((RunDirection() = TDirection.D_LEFT) and (Target.X > FObj.X)) then
if (Abs(FObj.Y-Target.Y) <= 128) then
begin
if ((RunDirection() = TDirection.D_LEFT) and (Target.X > FObj.X)) then
end;
end;
end;
end;
- // Âûáèðàåì óãîë ââåðõ:
+ // Выбираем угол вверх:
if FDirection = TDirection.D_LEFT then
angle := ANGLE_LEFTUP
else
if FDirection = TDirection.D_LEFT then
angle := ANGLE_LEFTUP
else
firew := Trunc(Cos(DegToRad(-angle))*gPlayerScreenSize.X*0.6);
fireh := Trunc(Sin(DegToRad(-angle))*gPlayerScreenSize.X*0.6);
firew := Trunc(Cos(DegToRad(-angle))*gPlayerScreenSize.X*0.6);
fireh := Trunc(Sin(DegToRad(-angle))*gPlayerScreenSize.X*0.6);
- // Åñëè ïðè óãëå ââåðõ ìîæíî ïîïàñòü â ïðèáëèçèòåëüíîå ïîëîæåíèå öåëè:
+ // Если при угле вверх можно попасть в приблизительное положение цели:
if g_CollideLine(x1, y1, x1+firew, y1+fireh,
Target.X+Target.Rect.X+GetInterval(FDifficult.DiagPrecision, 128), //96
Target.Y+Target.Rect.Y+GetInterval(FDifficult.DiagPrecision, 128),
Target.Rect.Width, Target.Rect.Height) and
g_TraceVector(x1, y1, Target.cX, Target.cY) then
if g_CollideLine(x1, y1, x1+firew, y1+fireh,
Target.X+Target.Rect.X+GetInterval(FDifficult.DiagPrecision, 128), //96
Target.Y+Target.Rect.Y+GetInterval(FDifficult.DiagPrecision, 128),
Target.Rect.Width, Target.Rect.Height) and
g_TraceVector(x1, y1, Target.cX, Target.cY) then
- begin // òî íóæíî ñòðåëÿòü ââåðõ
+ begin // то нужно стрелять вверх
SetAIFlag('NEEDFIRE', '1');
SetAIFlag('NEEDSEEUP', '1');
end;
SetAIFlag('NEEDFIRE', '1');
SetAIFlag('NEEDSEEUP', '1');
end;
- // Âûáèðàåì óãîë âíèç:
+ // Выбираем угол вниз:
if FDirection = TDirection.D_LEFT then
angle := ANGLE_LEFTDOWN
else
if FDirection = TDirection.D_LEFT then
angle := ANGLE_LEFTDOWN
else
firew := Trunc(Cos(DegToRad(-angle))*gPlayerScreenSize.X*0.6);
fireh := Trunc(Sin(DegToRad(-angle))*gPlayerScreenSize.X*0.6);
firew := Trunc(Cos(DegToRad(-angle))*gPlayerScreenSize.X*0.6);
fireh := Trunc(Sin(DegToRad(-angle))*gPlayerScreenSize.X*0.6);
- // Åñëè ïðè óãëå âíèç ìîæíî ïîïàñòü â ïðèáëèçèòåëüíîå ïîëîæåíèå öåëè:
+ // Если при угле вниз можно попасть в приблизительное положение цели:
if g_CollideLine(x1, y1, x1+firew, y1+fireh,
Target.X+Target.Rect.X+GetInterval(FDifficult.DiagPrecision, 128),
Target.Y+Target.Rect.Y+GetInterval(FDifficult.DiagPrecision, 128),
Target.Rect.Width, Target.Rect.Height) and
g_TraceVector(x1, y1, Target.cX, Target.cY) then
if g_CollideLine(x1, y1, x1+firew, y1+fireh,
Target.X+Target.Rect.X+GetInterval(FDifficult.DiagPrecision, 128),
Target.Y+Target.Rect.Y+GetInterval(FDifficult.DiagPrecision, 128),
Target.Rect.Width, Target.Rect.Height) and
g_TraceVector(x1, y1, Target.cX, Target.cY) then
- begin // òî íóæíî ñòðåëÿòü âíèç
+ begin // то нужно стрелять вниз
SetAIFlag('NEEDFIRE', '1');
SetAIFlag('NEEDSEEDOWN', '1');
end;
SetAIFlag('NEEDFIRE', '1');
SetAIFlag('NEEDSEEDOWN', '1');
end;
- // Åñëè öåëü âèäíî è îíà íà òàêîé æå âûñîòå:
+ // Если цель видно и она на такой же высоте:
if Target.Visible and
(y1+4 < Target.Y+Target.Rect.Y+Target.Rect.Height) and
(y1-4 > Target.Y+Target.Rect.Y) then
begin
if Target.Visible and
(y1+4 < Target.Y+Target.Rect.Y+Target.Rect.Height) and
(y1-4 > Target.Y+Target.Rect.Y) then
begin
- // Åñëè èäåì â ñòîðîíó öåëè, òî íàäî ñòðåëÿòü:
+ // Если идем в сторону цели, то надо стрелять:
if ((FDirection = TDirection.D_LEFT) and (Target.X < FObj.X)) or
((FDirection = TDirection.D_RIGHT) and (Target.X > FObj.X)) then
if ((FDirection = TDirection.D_LEFT) and (Target.X < FObj.X)) or
((FDirection = TDirection.D_RIGHT) and (Target.X > FObj.X)) then
- begin // òî íóæíî ñòðåëÿòü âïåðåä
+ begin // то нужно стрелять вперед
SetAIFlag('NEEDFIRE', '1');
SetAIFlag('NEEDSEEDOWN', '');
SetAIFlag('NEEDSEEUP', '');
end;
SetAIFlag('NEEDFIRE', '1');
SetAIFlag('NEEDSEEDOWN', '');
SetAIFlag('NEEDSEEUP', '');
end;
- // Åñëè öåëü â ïðåäåëàõ "ýêðàíà" è ñëîæíîñòü ïîçâîëÿåò ïðûæêè ñáëèæåíèÿ:
+ // Если цель в пределах "экрана" и сложность позволяет прыжки сближения:
if Abs(FObj.X-Target.X) < Trunc(gPlayerScreenSize.X*0.75) then
if GetRnd(FDifficult.CloseJump) then
if Abs(FObj.X-Target.X) < Trunc(gPlayerScreenSize.X*0.75) then
if GetRnd(FDifficult.CloseJump) then
- begin // òî åñëè ïîâåçåò - ïðûãàåì (îñîáåííî, åñëè áëèçêî)
+ begin // то если повезет - прыгаем (особенно, если близко)
if Abs(FObj.X-Target.X) < 128 then
a := 4
else
if Abs(FObj.X-Target.X) < 128 then
a := 4
else
end;
end;
end;
end;
- // Åñëè öåëü âñå åùå åñòü:
+ // Если цель все еще есть:
if Target.UID <> 0 then
if Target.UID <> 0 then
- if gTime-FLastVisible > 2000 then // Åñëè âèäåëè äàâíî
- Target.UID := 0 // òî çàáûòü öåëü
- else // Åñëè âèäåëè íåäàâíî
- begin // íî öåëü óáèëè
+ if gTime-FLastVisible > 2000 then // Если видели давно
+ Target.UID := 0 // то забыть цель
+ else // Если видели недавно
+ begin // но цель убили
if Target.IsPlayer then
if Target.IsPlayer then
- begin // Öåëü - èãðîê
+ begin // Цель - игрок
pla := g_Player_Get(Target.UID);
if (pla = nil) or (not pla.alive) or pla.NoTarget or
(pla.FMegaRulez[MR_INVIS] >= gTime) then
pla := g_Player_Get(Target.UID);
if (pla = nil) or (not pla.alive) or pla.NoTarget or
(pla.FMegaRulez[MR_INVIS] >= gTime) then
- Target.UID := 0; // òî çàáûòü öåëü
+ Target.UID := 0; // то забыть цель
end
else
end
else
- begin // Öåëü - ìîíñòð
+ begin // Цель - монстр
mon := g_Monsters_ByUID(Target.UID);
if (mon = nil) or (not mon.alive) then
mon := g_Monsters_ByUID(Target.UID);
if (mon = nil) or (not mon.alive) then
- Target.UID := 0; // òî çàáûòü öåëü
+ Target.UID := 0; // то забыть цель
end;
end;
end; // if Target.UID <> 0
FTargetUID := Target.UID;
end;
end;
end; // if Target.UID <> 0
FTargetUID := Target.UID;
-// Åñëè âîçìîæíûõ öåëåé íåò:
-// (Àòàêà ÷åãî-íèáóäü ñëåâà èëè ñïðàâà)
+// Если возможных целей нет:
+// (Атака чего-нибудь слева или справа)
if targets = nil then
if GetAIFlag('ATTACKLEFT') <> '' then
if targets = nil then
if GetAIFlag('ATTACKLEFT') <> '' then
- begin // Åñëè íóæíî àòàêîâàòü íàëåâî
+ begin // Если нужно атаковать налево
RemoveAIFlag('ATTACKLEFT');
SetAIFlag('NEEDJUMP', '1');
if RunDirection() = TDirection.D_RIGHT then
RemoveAIFlag('ATTACKLEFT');
SetAIFlag('NEEDJUMP', '1');
if RunDirection() = TDirection.D_RIGHT then
- begin // Èäåì íå â òó ñòîðîíó
+ begin // Идем не в ту сторону
if (Healthy() > 1) and GetRnd(FDifficult.InvisFire) then
if (Healthy() > 1) and GetRnd(FDifficult.InvisFire) then
- begin // Åñëè çäîðîâû, òî, âîçìîæíî, ñòðåëÿåì áåæèì âëåâî è ñòðåëÿåì
+ begin // Если здоровы, то, возможно, стреляем бежим влево и стреляем
SetAIFlag('NEEDFIRE', '1');
SetAIFlag('GOLEFT', '1');
end;
end
else
SetAIFlag('NEEDFIRE', '1');
SetAIFlag('GOLEFT', '1');
end;
end
else
- begin // Èäåì â íóæíóþ ñòîðîíó
- if GetRnd(FDifficult.InvisFire) then // Âîçìîæíî, ñòðåëÿåì âñëåïóþ
+ begin // Идем в нужную сторону
+ if GetRnd(FDifficult.InvisFire) then // Возможно, стреляем вслепую
SetAIFlag('NEEDFIRE', '1');
SetAIFlag('NEEDFIRE', '1');
- if Healthy() <= 1 then // Ïîáèòû - óáåãàåì
+ if Healthy() <= 1 then // Побиты - убегаем
SetAIFlag('GORIGHT', '1');
end;
end
else
if GetAIFlag('ATTACKRIGHT') <> '' then
SetAIFlag('GORIGHT', '1');
end;
end
else
if GetAIFlag('ATTACKRIGHT') <> '' then
- begin // Åñëè íóæíî àòàêîâàòü íàïðàâî
+ begin // Если нужно атаковать направо
RemoveAIFlag('ATTACKRIGHT');
SetAIFlag('NEEDJUMP', '1');
if RunDirection() = TDirection.D_LEFT then
RemoveAIFlag('ATTACKRIGHT');
SetAIFlag('NEEDJUMP', '1');
if RunDirection() = TDirection.D_LEFT then
- begin // Èäåì íå â òó ñòîðîíó
+ begin // Идем не в ту сторону
if (Healthy() > 1) and GetRnd(FDifficult.InvisFire) then
if (Healthy() > 1) and GetRnd(FDifficult.InvisFire) then
- begin // Åñëè çäîðîâû, òî, âîçìîæíî, áåæèì âïðàâî è ñòðåëÿåì
+ begin // Если здоровы, то, возможно, бежим вправо и стреляем
SetAIFlag('NEEDFIRE', '1');
SetAIFlag('GORIGHT', '1');
end;
end
else
begin
SetAIFlag('NEEDFIRE', '1');
SetAIFlag('GORIGHT', '1');
end;
end
else
begin
- if GetRnd(FDifficult.InvisFire) then // Âîçìîæíî, ñòðåëÿåì âñëåïóþ
+ if GetRnd(FDifficult.InvisFire) then // Возможно, стреляем вслепую
SetAIFlag('NEEDFIRE', '1');
SetAIFlag('NEEDFIRE', '1');
- if Healthy() <= 1 then // Ïîáèòû - óáåãàåì
+ if Healthy() <= 1 then // Побиты - убегаем
SetAIFlag('GOLEFT', '1');
end;
end;
SetAIFlag('GOLEFT', '1');
end;
end;
//HACK! (does it belongs there?)
RealizeCurrentWeapon();
//HACK! (does it belongs there?)
RealizeCurrentWeapon();
-// Åñëè åñòü âîçìîæíûå öåëè:
-// (Ñòðåëÿåì ïî íàïðàâëåíèþ ê öåëÿì)
+// Если есть возможные цели:
+// (Стреляем по направлению к целям)
if (targets <> nil) and (GetAIFlag('NEEDFIRE') <> '') then
for a := 0 to High(targets) do
begin
if (targets <> nil) and (GetAIFlag('NEEDFIRE') <> '') then
for a := 0 to High(targets) do
begin
- // Åñëè ìîæåì ñòðåëÿòü ïî äèàãîíàëè:
+ // Если можем стрелять по диагонали:
if GetRnd(FDifficult.DiagFire) then
begin
if GetRnd(FDifficult.DiagFire) then
begin
- // Èùåì öåëü ñâåðõó è ñòðåëÿåì, åñëè åñòü:
+ // Ищем цель сверху и стреляем, если есть:
if FDirection = TDirection.D_LEFT then
angle := ANGLE_LEFTUP
else
if FDirection = TDirection.D_LEFT then
angle := ANGLE_LEFTUP
else
SetAIFlag('NEEDSEEUP', '1');
end;
SetAIFlag('NEEDSEEUP', '1');
end;
- // Èùåì öåëü ñíèçó è ñòðåëÿåì, åñëè åñòü:
+ // Ищем цель снизу и стреляем, если есть:
if FDirection = TDirection.D_LEFT then
angle := ANGLE_LEFTDOWN
else
if FDirection = TDirection.D_LEFT then
angle := ANGLE_LEFTDOWN
else
end;
end;
end;
end;
- // Åñëè öåëü "ïåðåä íîñîì", òî ñòðåëÿåì:
+ // Если цель "перед носом", то стреляем:
if targets[a].Line and targets[a].Visible and
(((FDirection = TDirection.D_LEFT) and (targets[a].X < FObj.X)) or
((FDirection = TDirection.D_RIGHT) and (targets[a].X > FObj.X))) then
if targets[a].Line and targets[a].Visible and
(((FDirection = TDirection.D_LEFT) and (targets[a].X < FObj.X)) or
((FDirection = TDirection.D_RIGHT) and (targets[a].X > FObj.X))) then
end;
end;
end;
end;
-// Åñëè ëåòèò ïóëÿ, òî, âîçìîæíî, ïîäïðûãèâàåì:
+// Если летит пуля, то, возможно, подпрыгиваем:
if g_Weapon_Danger(FUID, FObj.X+PLAYER_RECT.X, FObj.Y+PLAYER_RECT.Y,
PLAYER_RECT.Width, PLAYER_RECT.Height,
40+GetInterval(FDifficult.Cover, 40)) then
SetAIFlag('NEEDJUMP', '1');
if g_Weapon_Danger(FUID, FObj.X+PLAYER_RECT.X, FObj.Y+PLAYER_RECT.Y,
PLAYER_RECT.Width, PLAYER_RECT.Height,
40+GetInterval(FDifficult.Cover, 40)) then
SetAIFlag('NEEDJUMP', '1');
-// Åñëè êîí÷èëèñü ïàòîðíû, òî íóæíî ñìåíèòü îðóæèå:
+// Если кончились паторны, то нужно сменить оружие:
ammo := GetAmmoByWeapon(FCurrWeap);
if ((FCurrWeap = WEAPON_SHOTGUN2) and (ammo < 2)) or
((FCurrWeap = WEAPON_BFG) and (ammo < 40)) or
(ammo = 0) then
SetAIFlag('SELECTWEAPON', '1');
ammo := GetAmmoByWeapon(FCurrWeap);
if ((FCurrWeap = WEAPON_SHOTGUN2) and (ammo < 2)) or
((FCurrWeap = WEAPON_BFG) and (ammo < 40)) or
(ammo = 0) then
SetAIFlag('SELECTWEAPON', '1');
-// Åñëè íóæíî ñìåíèòü îðóæèå, òî âûáèðàåì íóæíîå:
+// Если нужно сменить оружие, то выбираем нужное:
if GetAIFlag('SELECTWEAPON') = '1' then
begin
SelectWeapon(-1);
if GetAIFlag('SELECTWEAPON') = '1' then
begin
SelectWeapon(-1);
begin
EnableAI := True;
begin
EnableAI := True;
- // Ïðîâåðÿåì, îòêëþ÷¸í ëè AI áîòîâ
+ // Проверяем, отключён ли AI ботов
if (g_debug_BotAIOff = 1) and (Team = TEAM_RED) then
EnableAI := False;
if (g_debug_BotAIOff = 2) and (Team = TEAM_BLUE) then
if (g_debug_BotAIOff = 1) and (Team = TEAM_RED) then
EnableAI := False;
if (g_debug_BotAIOff = 2) and (Team = TEAM_BLUE) then
var
x, sx: Integer;
begin
var
x, sx: Integer;
begin
- { TODO 5 : Ëåñòíèöû }
+ { TODO 5 : Лестницы }
sx := IfThen(RunDirection() = TDirection.D_LEFT, -1, 1);
for x := 1 to PLAYER_RECT.Width do
if (not StayOnStep(x*sx, 0)) and
sx := IfThen(RunDirection() = TDirection.D_LEFT, -1, 1);
for x := 1 to PLAYER_RECT.Width do
if (not StayOnStep(x*sx, 0)) and
var
x, sx, xx: Integer;
begin
var
x, sx, xx: Integer;
begin
- { TODO 5 : Ëåñòíèöû }
+ { TODO 5 : Лестницы }
sx := IfThen(RunDirection() = TDirection.D_LEFT, -1, 1);
for x := 1 to PLAYER_RECT.Width do
if (not StayOnStep(x*sx, 0)) and
sx := IfThen(RunDirection() = TDirection.D_LEFT, -1, 1);
for x := 1 to PLAYER_RECT.Width do
if (not StayOnStep(x*sx, 0)) and
end;
begin
end;
begin
-// Âîçìîæíî, íàæèìàåì êíîïêó:
+// Возможно, нажимаем кнопку:
if Rnd(16) and IsSafeTrigger() then
PressKey(KEY_OPEN);
if Rnd(16) and IsSafeTrigger() then
PressKey(KEY_OPEN);
-// Åñëè ïîä ëèôòîì èëè ñòóïåíüêàìè, òî, âîçìîæíî, ïðûãàåì:
+// Если под лифтом или ступеньками, то, возможно, прыгаем:
if OnLadder() or ((BelowLadder() or BelowLiftUp()) and Rnd(8)) then
begin
ReleaseKey(KEY_LEFT);
if OnLadder() or ((BelowLadder() or BelowLiftUp()) and Rnd(8)) then
begin
ReleaseKey(KEY_LEFT);
Jump();
end;
Jump();
end;
-// Èäåì âëåâî, åñëè íàäî áûëî:
+// Идем влево, если надо было:
if GetAIFlag('GOLEFT') <> '' then
begin
RemoveAIFlag('GOLEFT');
if GetAIFlag('GOLEFT') <> '' then
begin
RemoveAIFlag('GOLEFT');
GoLeft(360);
end;
GoLeft(360);
end;
-// Èäåì âïðàâî, åñëè íàäî áûëî:
+// Идем вправо, если надо было:
if GetAIFlag('GORIGHT') <> '' then
begin
RemoveAIFlag('GORIGHT');
if GetAIFlag('GORIGHT') <> '' then
begin
RemoveAIFlag('GORIGHT');
GoRight(360);
end;
GoRight(360);
end;
-// Åñëè âûëåòåëè çà êàðòó, òî ïðîáóåì âåðíóòüñÿ:
+// Если вылетели за карту, то пробуем вернуться:
if FObj.X < -32 then
GoRight(360)
else
if FObj.X+32 > gMapInfo.Width then
GoLeft(360);
if FObj.X < -32 then
GoRight(360)
else
if FObj.X+32 > gMapInfo.Width then
GoLeft(360);
-// Ïðûãàåì, åñëè íàäî áûëî:
+// Прыгаем, если надо было:
if GetAIFlag('NEEDJUMP') <> '' then
begin
Jump(0);
RemoveAIFlag('NEEDJUMP');
end;
if GetAIFlag('NEEDJUMP') <> '' then
begin
Jump(0);
RemoveAIFlag('NEEDJUMP');
end;
-// Ñìîòðèì ââåðõ, åñëè íàäî áûëî:
+// Смотрим вверх, если надо было:
if GetAIFlag('NEEDSEEUP') <> '' then
begin
ReleaseKey(KEY_UP);
if GetAIFlag('NEEDSEEUP') <> '' then
begin
ReleaseKey(KEY_UP);
RemoveAIFlag('NEEDSEEUP');
end;
RemoveAIFlag('NEEDSEEUP');
end;
-// Ñìîòðèì âíèç, åñëè íàäî áûëî:
+// Смотрим вниз, если надо было:
if GetAIFlag('NEEDSEEDOWN') <> '' then
begin
ReleaseKey(KEY_UP);
if GetAIFlag('NEEDSEEDOWN') <> '' then
begin
ReleaseKey(KEY_UP);
RemoveAIFlag('NEEDSEEDOWN');
end;
RemoveAIFlag('NEEDSEEDOWN');
end;
-// Åñëè íóæíî áûëî â äûðó è ìû íå íà çåìëå, òî ïîêîðíî ëåòèì:
+// Если нужно было в дыру и мы не на земле, то покорно летим:
if GetAIFlag('GOINHOLE') <> '' then
if not OnGround() then
begin
if GetAIFlag('GOINHOLE') <> '' then
if not OnGround() then
begin
SetAIFlag('FALLINHOLE', '1');
end;
SetAIFlag('FALLINHOLE', '1');
end;
-// Åñëè ïàäàëè è äîñòèãëè çåìëè, òî õâàòèò ïàäàòü:
+// Если падали и достигли земли, то хватит падать:
if GetAIFlag('FALLINHOLE') <> '' then
if OnGround() then
RemoveAIFlag('FALLINHOLE');
if GetAIFlag('FALLINHOLE') <> '' then
if OnGround() then
RemoveAIFlag('FALLINHOLE');
-// Åñëè ëåòåëè ïðÿìî è ñåé÷àñ íå íà ëåñòíèöå èëè íà âåðøèíå ëèôòà, òî îòõîäèì â ñòîðîíó:
+// Если летели прямо и сейчас не на лестнице или на вершине лифта, то отходим в сторону:
if not (KeyPressed(KEY_LEFT) or KeyPressed(KEY_RIGHT)) then
if GetAIFlag('FALLINHOLE') = '' then
if (not OnLadder()) or (FObj.Vel.Y >= 0) or (OnTopLift()) then
if not (KeyPressed(KEY_LEFT) or KeyPressed(KEY_RIGHT)) then
if GetAIFlag('FALLINHOLE') = '' then
if (not OnLadder()) or (FObj.Vel.Y >= 0) or (OnTopLift()) then
else
GoRight(360);
else
GoRight(360);
-// Åñëè íà çåìëå è ìîæíî ïîäïðûãíóòü, òî, âîçìîæíî, ïðûãàåì:
+// Если на земле и можно подпрыгнуть, то, возможно, прыгаем:
if OnGround() and
CanJumpUp(IfThen(RunDirection() = TDirection.D_LEFT, -1, 1)*32) and
Rnd(8) then
Jump();
if OnGround() and
CanJumpUp(IfThen(RunDirection() = TDirection.D_LEFT, -1, 1)*32) and
Rnd(8) then
Jump();
-// Åñëè íà çåìëå è âîçëå äûðû (ãëóáèíà > 2 ðîñòîâ èãðîêà):
+// Если на земле и возле дыры (глубина > 2 ростов игрока):
if OnGround() and NearHole() then
if OnGround() and NearHole() then
- if NearDeepHole() then // Åñëè ýòî áåçäíà
+ if NearDeepHole() then // Если это бездна
case Random(6) of
case Random(6) of
- 0..3: Turn(); // Áåæèì îáðàòíî
- 4: Jump(); // Ïðûãàåì
- 5: begin // Ïðûãàåì îáðàòíî
+ 0..3: Turn(); // Бежим обратно
+ 4: Jump(); // Прыгаем
+ 5: begin // Прыгаем обратно
Turn();
Jump();
end;
end
Turn();
Jump();
end;
end
- else // Ýòî íå áåçäíà è ìû åùå íå ëåòèì òóäà
+ else // Это не бездна и мы еще не летим туда
if GetAIFlag('GOINHOLE') = '' then
case Random(6) of
if GetAIFlag('GOINHOLE') = '' then
case Random(6) of
- 0: Turn(); // Íå íóæíî òóäà
- 1: Jump(); // Âäðóã ïîâåçåò - ïðûãàåì
- else // Åñëè ÿìà ñ ãðàíèöåé, òî ïðè ñëó÷àå ìîæíî òóäà ïðûãíóòü
+ 0: Turn(); // Не нужно туда
+ 1: Jump(); // Вдруг повезет - прыгаем
+ else // Если яма с границей, то при случае можно туда прыгнуть
if BorderHole() then
SetAIFlag('GOINHOLE', '1');
end;
if BorderHole() then
SetAIFlag('GOINHOLE', '1');
end;
-// Åñëè íà çåìëå, íî íåêóäà èäòè:
+// Если на земле, но некуда идти:
if (not CanRun()) and OnGround() then
begin
if (not CanRun()) and OnGround() then
begin
- // Åñëè ìû íà ëåñòíèöå èëè ìîæíî ïåðåïðûãíóòü, òî ïðûãàåì:
+ // Если мы на лестнице или можно перепрыгнуть, то прыгаем:
if CanJumpOver() or OnLadder() then
Jump()
if CanJumpOver() or OnLadder() then
Jump()
- else // èíà÷å ïîïûòàåìñÿ â äðóãóþ ñòîðîíó
+ else // иначе попытаемся в другую сторону
if Random(2) = 0 then
begin
if IsSafeTrigger() then
if Random(2) = 0 then
begin
if IsSafeTrigger() then
Turn();
end;
Turn();
end;
-// Îñòàëîñü ìàëî âîçäóõà:
+// Осталось мало воздуха:
if FAir < 36 * 2 then
Jump(20);
if FAir < 36 * 2 then
Jump(20);
-// Âûáèðàåìñÿ èç êèñëîòû, åñëè íåò êîñòþìà, îáîæãëèñü, èëè ìàëî çäîðîâüÿ:
+// Выбираемся из кислоты, если нет костюма, обожглись, или мало здоровья:
if (FMegaRulez[MR_SUIT] < gTime) and ((FLastHit = HIT_ACID) or (Healthy() <= 1)) then
if BodyInAcid(0, 0) then
Jump();
if (FMegaRulez[MR_SUIT] < gTime) and ((FLastHit = HIT_ACID) or (Healthy() <= 1)) then
if BodyInAcid(0, 0) then
Jump();
if Dist = -1 then Dist := BOT_LONGDIST;
if Dist > BOT_LONGDIST then
if Dist = -1 then Dist := BOT_LONGDIST;
if Dist > BOT_LONGDIST then
- begin // Äàëüíèé áîé
+ begin // Дальний бой
for a := 0 to 9 do
if FWeapon[FDifficult.WeaponPrior[a]] and HaveAmmo(FDifficult.WeaponPrior[a]) then
begin
for a := 0 to 9 do
if FWeapon[FDifficult.WeaponPrior[a]] and HaveAmmo(FDifficult.WeaponPrior[a]) then
begin
end;
end
else //if Dist > BOT_UNSAFEDIST then
end;
end
else //if Dist > BOT_UNSAFEDIST then
- begin // Áëèæíèé áîé
+ begin // Ближний бой
for a := 0 to 9 do
if FWeapon[FDifficult.CloseWeaponPrior[a]] and HaveAmmo(FDifficult.CloseWeaponPrior[a]) then
begin
for a := 0 to 9 do
if FWeapon[FDifficult.CloseWeaponPrior[a]] and HaveAmmo(FDifficult.CloseWeaponPrior[a]) then
begin
ok := False;
if (g_GetUIDType(FLastSpawnerUID) = UID_PLAYER) and
LongBool(gGameSettings.Options and GAME_OPTION_BOTVSPLAYER) then
ok := False;
if (g_GetUIDType(FLastSpawnerUID) = UID_PLAYER) and
LongBool(gGameSettings.Options and GAME_OPTION_BOTVSPLAYER) then
- begin // Èãðîê
+ begin // Игрок
pla := g_Player_Get(FLastSpawnerUID);
ok := not TargetOnScreen(pla.FObj.X + PLAYER_RECT.X,
pla.FObj.Y + PLAYER_RECT.Y);
pla := g_Player_Get(FLastSpawnerUID);
ok := not TargetOnScreen(pla.FObj.X + PLAYER_RECT.X,
pla.FObj.Y + PLAYER_RECT.Y);
else
if (g_GetUIDType(FLastSpawnerUID) = UID_MONSTER) and
LongBool(gGameSettings.Options and GAME_OPTION_BOTVSMONSTER) then
else
if (g_GetUIDType(FLastSpawnerUID) = UID_MONSTER) and
LongBool(gGameSettings.Options and GAME_OPTION_BOTVSMONSTER) then
- begin // Ìîíñòð
+ begin // Монстр
mon := g_Monsters_ByUID(FLastSpawnerUID);
ok := not TargetOnScreen(mon.Obj.X + mon.Obj.Rect.X,
mon.Obj.Y + mon.Obj.Rect.Y);
mon := g_Monsters_ByUID(FLastSpawnerUID);
ok := not TargetOnScreen(mon.Obj.X + mon.Obj.Rect.X,
mon.Obj.Y + mon.Obj.Rect.Y);
begin
inherited SaveState(st);
utils.writeSign(st, 'BOT0');
begin
inherited SaveState(st);
utils.writeSign(st, 'BOT0');
- // Âûáðàííîå îðóæèå
+ // Выбранное оружие
utils.writeInt(st, Byte(FSelectedWeapon));
utils.writeInt(st, Byte(FSelectedWeapon));
- // UID öåëè
+ // UID цели
utils.writeInt(st, Word(FTargetUID));
utils.writeInt(st, Word(FTargetUID));
- // Âðåìÿ ïîòåðè öåëè
+ // Время потери цели
utils.writeInt(st, LongWord(FLastVisible));
utils.writeInt(st, LongWord(FLastVisible));
- // Êîëè÷åñòâî ôëàãîâ ÈÈ
+ // Количество флагов ИИ
dw := Length(FAIFlags);
utils.writeInt(st, LongInt(dw));
dw := Length(FAIFlags);
utils.writeInt(st, LongInt(dw));
- // Ôëàãè ÈÈ
+ // Флаги ИИ
for i := 0 to dw-1 do
begin
utils.writeStr(st, FAIFlags[i].Name, 20);
utils.writeStr(st, FAIFlags[i].Value, 20);
end;
for i := 0 to dw-1 do
begin
utils.writeStr(st, FAIFlags[i].Name, 20);
utils.writeStr(st, FAIFlags[i].Value, 20);
end;
- // Íàñòðîéêè ñëîæíîñòè
+ // Настройки сложности
FDifficult.save(st);
end;
FDifficult.save(st);
end;
begin
inherited LoadState(st);
if not utils.checkSign(st, 'BOT0') then raise XStreamError.Create('invalid bot signature');
begin
inherited LoadState(st);
if not utils.checkSign(st, 'BOT0') then raise XStreamError.Create('invalid bot signature');
- // Âûáðàííîå îðóæèå
+ // Выбранное оружие
FSelectedWeapon := utils.readByte(st);
FSelectedWeapon := utils.readByte(st);
- // UID öåëè
+ // UID цели
FTargetUID := utils.readWord(st);
FTargetUID := utils.readWord(st);
- // Âðåìÿ ïîòåðè öåëè
+ // Время потери цели
FLastVisible := utils.readLongWord(st);
FLastVisible := utils.readLongWord(st);
- // Êîëè÷åñòâî ôëàãîâ ÈÈ
+ // Количество флагов ИИ
dw := utils.readLongInt(st);
if (dw < 0) or (dw > 16384) then raise XStreamError.Create('invalid number of bot AI flags');
SetLength(FAIFlags, dw);
dw := utils.readLongInt(st);
if (dw < 0) or (dw > 16384) then raise XStreamError.Create('invalid number of bot AI flags');
SetLength(FAIFlags, dw);
- // Ôëàãè ÈÈ
+ // Флаги ИИ
for i := 0 to dw-1 do
begin
FAIFlags[i].Name := utils.readStr(st, 20);
FAIFlags[i].Value := utils.readStr(st, 20);
end;
for i := 0 to dw-1 do
begin
FAIFlags[i].Name := utils.readStr(st, 20);
FAIFlags[i].Value := utils.readStr(st, 20);
end;
- // Íàñòðîéêè ñëîæíîñòè
+ // Настройки сложности
FDifficult.load(st);
end;
begin
FDifficult.load(st);
end;
begin
- conRegVar('cheat_berserk_autoswitch', @gBerserkAutoswitch, 'autoswitch to fist when berserk pack taken', '', true, true);
+ conRegVar('player_indicator', @gPlayerIndicator, 'Draw indicator only for current player, also for teammates, or not at all', 'Draw indicator only for current player, also for teammates, or not at all');
+ conRegVar('player_indicator_style', @gPlayerIndicatorStyle, 'Visual appearance of indicator', 'Visual appearance of indicator');
end.
end.