diff --git a/src/game/g_player.pas b/src/game/g_player.pas
index 189d241aae564c6fcd0489e9c0f7f8e4a2105509..c9a640682a1d0cfea8ad3c6cfb6dcdd45a91155f 100644 (file)
--- a/src/game/g_player.pas
+++ b/src/game/g_player.pas
FFlag: Byte;
FSecrets: Integer;
FCurrWeap: Byte;
- FNetWeapCtr: LongWord; // spam server with our current weapon until we'll receive this in plrpos packet
+ //FNetForceWeap: Byte; // spam server with this -- this is new weapon we want to use
+ FNetForceWeapFIdx: LongWord; // frame index; ignore weapon change if it is lesser than this
+ //FCurrFrameIdx: LongWord; // increased in each `Update()`
FNextWeap: WORD;
FNextWeapDelay: Byte; // frames (unused)
FBFGFireCounter: SmallInt;
viewPortX, viewPortY, viewPortW, viewPortH: Integer;
function isValidViewPort (): Boolean; inline;
- procedure SetCurrWeapProp (newweap: Byte);
constructor Create(); virtual;
destructor Destroy(); override;
procedure ReleaseKeysNoWeapon();
procedure SetModel(ModelName: String);
procedure SetColor(Color: TRGB);
- procedure SetWeaponHost(W: Byte);
+ procedure SetWeapon(W: Byte);
function IsKeyPressed(K: Byte): Boolean;
function GetKeys(): Byte;
function PickItem(ItemType: Byte; arespawn: Boolean; var remove: Boolean): Boolean; virtual;
procedure DrawPickup();
procedure DrawRulez();
procedure DrawAim();
+ procedure DrawIndicator();
procedure DrawBubble();
procedure DrawGUI();
procedure Update(); virtual;
property Frags: Integer read FFrags write FFrags;
property Death: Integer read FDeath write FDeath;
property Kills: Integer read FKills write FKills;
- property CurrWeap: Byte read FCurrWeap write SetCurrWeapProp;
- property NetWeapCtr: LongWord read FNetWeapCtr write FNetWeapCtr;
+ property CurrWeap: Byte read FCurrWeap write FCurrWeap;
+ //property NetForceWeap: Byte read FNetForceWeap write FNetForceWeap;
+ property NetForceWeapFIdx: LongWord read FNetForceWeapFIdx write FNetForceWeapFIdx;
+ //property CurrFrameIdx: LongWord read FCurrFrameIdx write FCurrFrameIdx;
property MonsterKills: Integer read FMonsterKills write FMonsterKills;
property Secrets: Integer read FSecrets;
property GodMode: Boolean read FGodMode write FGodMode;
property eFrags: Integer read FFrags write FFrags;
property eDeath: Integer read FDeath write FDeath;
property eKills: Integer read FKills write FKills;
- property eCurrWeap: Byte read FCurrWeap write SetCurrWeapProp;
+ property eCurrWeap: Byte read FCurrWeap write FCurrWeap;
property eMonsterKills: Integer read FMonsterKills write FMonsterKills;
property eSecrets: Integer read FSecrets write FSecrets;
property eGodMode: Boolean read FGodMode write FGodMode;
gFly: Boolean = False;
gAimLine: Boolean = False;
gChatBubble: Byte = 0;
+ gPlayerIndicator: Boolean = True;
gNumBots: Word = 0;
gLMSPID1: Word = 0;
gLMSPID2: Word = 0;
gPlayers[a].FSecrets := utils.readLongInt(st);
// Òåêóùåå îðóæèå
gPlayers[a].FCurrWeap := utils.readByte(st);
- gPlayers[a].FNetWeapCtr := 0;
+ //gPlayers[a].FNetForceWeap := gPlayers[a].FCurrWeap;
// Ñëåäóþùåå æåëàåìîå îðóæèå
gPlayers[a].FNextWeap := utils.readWord(st);
// ...è ïàóçà
begin
if gPlayers[i] is TPlayer then
begin
+ //if (gPlayers[i].NetForceWeapFIdx > gTime) then writeln('*** PLAYER #', i, '; gTime=', gTime, '; nfwf=', gPlayers[i].NetForceWeapFIdx);
gPlayers[i].Update();
+ if (not gPlayers[i].alive) or (gPlayers[i].NetForceWeapFIdx >= gTime+15) then gPlayers[i].NetForceWeapFIdx := 0; // just in case
gPlayers[i].RealizeCurrentWeapon(); // WARNING! DO NOT MOVE THIS INTO `Update()`!
end
else
function TPlayer.isValidViewPort (): Boolean; inline; begin result := (viewPortW > 0) and (viewPortH > 0); end;
-procedure TPlayer.SetCurrWeapProp (newweap: Byte);
-begin
- if (newweap > High(FWeapon)) then exit;
- if (not FWeapon[newweap]) then exit;
- if not g_Game_IsClient then Inc(FNetWeapCtr, 2); // just in case, to really override client's counter
- if (FCurrWeap <> newweap) then
- begin
- if (newweap = WEAPON_SAW) then FSawSoundSelect.PlayAt(FObj.X, FObj.Y);
- end;
- FCurrWeap := newweap;
- FModel.SetWeapon(newweap);
-end;
-
procedure TPlayer.BFGHit();
begin
g_Weapon_BFGHit(FObj.X+FObj.Rect.X+(FObj.Rect.Width div 2),
FJustTeleported := False;
FNetTime := 0;
- FNetWeapCtr := 0;
+ //FNetForceWeap := FCurrWeap;
+ FNetForceWeapFIdx := 0;
+ //FCurrFrameIdx := 0;
resetWeaponQueue();
releaseAllWeaponSwitchKeys();
inherited;
end;
+procedure TPlayer.DrawIndicator();
+var
+ indX, indY: Integer;
+ indW, indH: Word;
+ ID: DWORD;
+begin
+ if FAlive then
+ begin
+ indX := FObj.X+FObj.Rect.X;
+ indY := FObj.Y - 12;
+ if g_Texture_Get('TEXTURE_PLAYER_INDICATOR', ID) then
+ begin
+ e_GetTextureSize(ID, @indW, @indH);
+ e_Draw(ID, indX + indW div 2, indY, 0, True, False);
+ end;
+ end;
+ //e_TextureFontPrint(indX, indY, FName, gStdFont); // Shows player name overhead
+end;
+
procedure TPlayer.DrawBubble();
var
bubX, bubY: Integer;
exit;
end;
+ if (FNetForceWeapFIdx >= gTime+15) then FNetForceWeapFIdx := 0;
+
nw := getNextWeaponIndex();
if nw = 255 then exit; // don't reset anything here
if nw > High(FWeapon) then
if FWeapon[nw] then
begin
//k8: emulate this on client immediately, or wait for server confirmation?
- Inc(FNetWeapCtr);
+ {
+ if g_Game_IsClient then
+ begin
+ FNetForceWeap := nw;
+ //FNetForceWeapFIdx := FCurrFrameIdx+5; // force for ~5 frames
+ FNetForceWeapFIdx := gTime+5; // force for ~5 frames
+ writeln('NETWEAPONSWITCH: fw=', NetForceWeap, '; fwfidx=', NetForceWeapFIdx, '; cfrm=', gTime);
+ end;
+ }
+ FNetForceWeapFIdx := gTime+5; // force for ~5 frames
FCurrWeap := nw;
- if (nw = WEAPON_SAW) then FSawSoundSelect.PlayAt(FObj.X, FObj.Y);
+ if nw = WEAPON_SAW then FSawSoundSelect.PlayAt(FObj.X, FObj.Y);
FModel.SetWeapon(nw);
FTime[T_SWITCH] := gTime+156;
if g_Game_IsNet then MH_SEND_PlayerStats(FUID);
+ //if g_Game_IsNet and g_Game_IsClient then
end;
end;
FNextWeap := $4000;
end;
-// used exclusively by network layer
-procedure TPlayer.SetWeaponHost(W: Byte);
+// used by network layer
+procedure TPlayer.SetWeapon(W: Byte);
begin
- if (W > High(FWeapon)) then exit;
- if (not FWeapon[W]) then exit; // server is authority!
-
if FCurrWeap <> W then
- begin
- if (W = WEAPON_SAW) then FSawSoundSelect.PlayAt(FObj.X, FObj.Y);
- end;
+ if (W = WEAPON_SAW) then
+ FSawSoundSelect.PlayAt(FObj.X, FObj.Y);
FCurrWeap := W;
- FModel.SetWeapon(W);
+ FModel.SetWeapon(CurrWeap);
//if g_Game_IsClient then resetWeaponQueue();
end;
Include(FRulez, R_BERSERK);
if allowBerserkSwitching then
begin
- CurrWeap := WEAPON_KASTET;
+ FCurrWeap := WEAPON_KASTET;
+ //FNetForceWeap := FCurrWeap;
resetWeaponQueue();
FModel.SetWeapon(WEAPON_KASTET);
end;
FMonsterKills := 0;
FDeath := 0;
FSecrets := 0;
- if g_Game_IsClient then FNetWeapCtr := 0 else Inc(FNetWeapCtr, 2);
+ //FCurrFrameIdx := 0;
+ //FNetForceWeap := FCurrWeap;
+ FNetForceWeapFIdx := 0;
resetWeaponQueue();
if FNoRespawn then
begin
FLastHit := 0;
FLastFrag := 0;
FComboEvnt := -1;
- if g_Game_IsClient then FNetWeapCtr := 0 else Inc(FNetWeapCtr, 2);
+ FNetForceWeapFIdx := 0;
resetWeaponQueue();
FBFGFireCounter := -1;
FShellTimer := -1;
FPain := 0;
FLastHit := 0;
- if g_Game_IsClient then FNetWeapCtr := 0 else Inc(FNetWeapCtr, 2);
+ //FNetForceWeap := FCurrWeap;
+ FNetForceWeapFIdx := 0;
resetWeaponQueue();
FBFGFireCounter := -1;
FWeapon[WEAPON_PISTOL] := True;
FWeapon[WEAPON_KASTET] := True;
- CurrWeap := WEAPON_PISTOL;
- if g_Game_IsClient then FNetWeapCtr := 0 else Inc(FNetWeapCtr, 2);
+ FCurrWeap := WEAPON_PISTOL;
+ //FNetForceWeap := FCurrWeap;
+ FNetForceWeapFIdx := 0;
resetWeaponQueue();
+ FModel.SetWeapon(FCurrWeap);
+
for b := A_BULLETS to A_HIGH do
FAmmo[b] := 0;
if (gPlayer2 = nil) and (gLMSPID2 = FUID) then
gPlayer2 := self;
+ //FNetForceWeap := FCurrWeap;
+
if g_Game_IsNet then
begin
MH_SEND_PlayerPos(True, FUID, NET_EVERYONE);
AnyServer: Boolean;
SetSpect: Boolean;
begin
+ //Inc(FCurrFrameIdx);
+
NetServer := g_Game_IsNet and g_Game_IsServer;
AnyServer := g_Game_IsServer;
FAir := FSavedState.Air;
FJetFuel := FSavedState.JetFuel;
FCurrWeap := FSavedState.CurrWeap;
- FModel.SetWeapon(FCurrWeap);
+ //FNetForceWeap := FCurrWeap;
FNextWeap := FSavedState.NextWeap;
FNextWeapDelay := FSavedState.NextWeapDelay;
FSecrets := utils.readLongInt(st);
// Òåêóùåå îðóæèå
FCurrWeap := utils.readByte(st);
- if not g_Game_IsClient then Inc(FNetWeapCtr, 2);
+ //FNetForceWeap := FCurrWeap;
// Æåëàåìîå îðóæèå
FNextWeap := utils.readWord(st);
// ...è ïàóçà
Include(FRulez, R_BERSERK);
if FBFGFireCounter < 1 then
begin
- CurrWeap := WEAPON_KASTET;
+ FCurrWeap := WEAPON_KASTET;
+ //FNetForceWeap := FCurrWeap;
+ FNetForceWeapFIdx := 0;
resetWeaponQueue();
FModel.SetWeapon(WEAPON_KASTET);
end;
FAIFlags := nil;
FSelectedWeapon := FCurrWeap;
- FNetWeapCtr := 0;
+ FNetForceWeapFIdx := 0;
resetWeaponQueue();
FTargetUID := 0;
end;