diff --git a/src/game/g_player.pas b/src/game/g_player.pas
index 3025ea549a1fe28480c9588c30c2094a1eee4f39..ee0655c223c9c39231669ce7d1f39d75858e0d3f 100644 (file)
--- a/src/game/g_player.pas
+++ b/src/game/g_player.pas
procedure BFGHit();
function GetFlag(Flag: Byte): Boolean;
procedure SetFlag(Flag: Byte);
procedure BFGHit();
function GetFlag(Flag: Byte): Boolean;
procedure SetFlag(Flag: Byte);
- function DropFlag(Silent: Boolean = True): 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();
@@ -3876,6 +3877,8 @@ function TPlayer.PickItem(ItemType: Byte; arespawn: Boolean; var remove: Boolean
var
a: Boolean;
var
a: Boolean;
+ switchWeapon: Byte;
+ hadWeapon: Boolean;
begin
Result := False;
if g_Game_IsClient then Exit;
begin
Result := False;
if g_Game_IsClient then Exit;
// a = true - ìåñòî ñïàâíà ïðåäìåòà:
a := LongBool(gGameSettings.Options and GAME_OPTION_WEAPONSTAY) and arespawn;
remove := not a;
// a = true - ìåñòî ñïàâíà ïðåäìåòà:
a := LongBool(gGameSettings.Options and GAME_OPTION_WEAPONSTAY) and arespawn;
remove := not a;
-
case ItemType of
ITEM_MEDKIT_SMALL:
if (FHealth < PLAYER_HP_SOFT) or (FFireTime > 0) then
case ItemType of
ITEM_MEDKIT_SMALL:
if (FHealth < PLAYER_HP_SOFT) or (FFireTime > 0) then
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);
begin
// Íóæíî, ÷òîáû íå âçÿòü âñå ïóëè ñðàçó:
if a and FWeapon[WEAPON_SHOTGUN1] then Exit;
begin
// Íóæíî, ÷òîáû íå âçÿòü âñå ïóëè ñðàçó:
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;
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
begin
FCurrWeap := WEAPON_KASTET;
resetWeaponQueue();
FModel.SetWeapon(WEAPON_KASTET);
if allowBerserkSwitching then
begin
FCurrWeap := WEAPON_KASTET;
resetWeaponQueue();
FModel.SetWeapon(WEAPON_KASTET);
+ end; *)
+ if ( (g_Game_IsNet = False) or (NetMode = NET_SERVER) ) and ( ( (Self = gPlayer1) and (gPlayer1Settings.WeaponSwitch <> 0) ) or ( (gPlayer2 <> nil) and (Self = gPlayer2) and (gPlayer2Settings.WeaponSwitch <> 0) )) then
+ begin
+ if (Self = gPlayer1) then
+ begin
+ if (gPlayer1Settings.WeaponSwitch = 1) or ( (gPlayer1Settings.WeaponSwitch = 2) and (gPlayer1Settings.WeaponPreferences[WP_LAST+1] > gPlayer1Settings.WeaponPreferences[FCurrWeap]) ) then
+ begin
+ FCurrWeap := WEAPON_KASTET;
+ resetWeaponQueue();
+ FModel.SetWeapon(WEAPON_KASTET);
+ end;
+ end
+ else
+ begin
+ if (gPlayer2Settings.WeaponSwitch = 1) or ( (gPlayer2Settings.WeaponSwitch = 2) and (gPlayer2Settings.WeaponPreferences[WP_LAST+1] > gPlayer2Settings.WeaponPreferences[FCurrWeap]) ) then
+ begin
+ FCurrWeap := WEAPON_KASTET;
+ resetWeaponQueue();
+ FModel.SetWeapon(WEAPON_KASTET);
+ end;
+ end;
end;
if gFlash <> 0 then
begin
end;
if gFlash <> 0 then
begin
if gFlash = 2 then Inc(FPickup, 5);
end;
end;
if gFlash = 2 then Inc(FPickup, 5);
end;
end;
+ if ( (g_Game_IsNet = False) or (NetMode = NET_SERVER) ) and ( ( (Self = gPlayer1) and (gPlayer1Settings.WeaponSwitch <> 0) ) or ( (gPlayer2 <> nil) and (Self = gPlayer2) and (gPlayer2Settings.WeaponSwitch <> 0) )) then
+ begin
+ if (hadWeapon = False) then
+ begin
+ if (Self = gPlayer1) and ( (gPlayer1Settings.WeaponSwitch = 1) or ( (gPlayer1Settings.WeaponSwitch = 2)
+ and (gPlayer1Settings.WeaponPreferences[switchWeapon] > gPlayer1Settings.WeaponPreferences[FCurrWeap]) ) ) then
+ begin
+ FCurrWeap := switchWeapon;
+ resetWeaponQueue();
+ FModel.SetWeapon(switchWeapon);
+ end
+ else if (Self = gPlayer2) and ( (gPlayer2Settings.WeaponSwitch = 1) or ( (gPlayer2Settings.WeaponSwitch = 2)
+ and (gPlayer2Settings.WeaponPreferences[switchWeapon] > gPlayer2Settings.WeaponPreferences[FCurrWeap]) ) ) then
+ begin
+ FCurrWeap := switchWeapon;
+ resetWeaponQueue();
+ FModel.SetWeapon(switchWeapon);
+ end;
+ end;
+ end;
end;
procedure TPlayer.Touch();
end;
procedure TPlayer.Touch();
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
FModel.SetFlag(FFlag);
end;
FModel.SetFlag(FFlag);
end;
-function TPlayer.DropFlag(Silent: Boolean = True): 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;
a: Byte;
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