diff --git a/src/game/g_player.pas b/src/game/g_player.pas
index fbbd09af8b270a58deee364d75df247bf984a3bf..8f4331079506d89ee91e6c0b00d13701ad8c5153 100644 (file)
--- a/src/game/g_player.pas
+++ b/src/game/g_player.pas
FWeapSwitchMode: Byte;
FWeapPreferences: Array [WP_FIRST .. WP_LAST+1] of Byte;
FSwitchToEmpty: Byte;
+ FSkipFist: Byte;
FColor: TRGB;
FPreferredTeam: Byte;
FSpectator: Boolean;
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;
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;
result := FWeapPreferences[Weapon];
end;
+function TPlayer.GetMorePrefered() : Byte;
+var testedWeap, i: Byte;
+begin
+ testedWeap := FCurrWeap;
+ for i := WP_FIRST to WP_LAST do
+ if FWeapon[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;
+
+function TPlayer.maySwitch(Weapon: Byte) : Boolean;
+begin
+ result := true;
+ if (Weapon = WEAPON_KASTET) and (FSkipFist <> 0) then
+ if (FSkipFist = 1) and (not (R_BERSERK in FRulez)) then
+ result := false
+ else if (FSwitchToEmpty = 0) and not hasAmmoForWeapon(Weapon) then
+ result := false
+end;
+
procedure TPlayer.SwitchTeam;
begin
if g_Game_IsClient then
for i := 0 to High(FWeapon) do
begin
cwi := (cwi+length(FWeapon)+dir) mod length(FWeapon);
- if FWeapon[cwi] and ((FSwitchToEmpty = 1) or hasAmmoForWeapon(cwi)) then
+ if FWeapon[cwi] and maySwitch(cwi) then
begin
//e_LogWriteFln(' SWITCH: cur=%d; new=%d %s %s', [FCurrWeap, cwi, FSwitchToEmpty, hasAmmoForWeapon(cwi)], TMsgType.Notify);
result := Byte(cwi);