X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fgame%2Fg_player.pas;h=f80d72195105d1d96dcbffd5a0f7a63dd8efb2fd;hb=888edf84e9dcca93ffd056846e492942c1a18e38;hp=fbbd09af8b270a58deee364d75df247bf984a3bf;hpb=4204edd3c7df01198a2289af4896be0575fff15c;p=d2df-sdl.git diff --git a/src/game/g_player.pas b/src/game/g_player.pas index fbbd09a..f80d721 100644 --- a/src/game/g_player.pas +++ b/src/game/g_player.pas @@ -261,6 +261,7 @@ type FWeapSwitchMode: Byte; FWeapPreferences: Array [WP_FIRST .. WP_LAST+1] of Byte; FSwitchToEmpty: Byte; + FSkipFist: Byte; FColor: TRGB; FPreferredTeam: Byte; FSpectator: Boolean; @@ -303,6 +304,8 @@ type 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; @@ -384,6 +387,7 @@ type 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; @@ -2023,6 +2027,30 @@ begin 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 + begin + if (FSkipFist = 1) and (not (R_BERSERK in FRulez)) then + result := false; + end + else if (FSwitchToEmpty = 0) and (not hasAmmoForWeapon(Weapon)) then + result := false +end; + procedure TPlayer.SwitchTeam; begin if g_Game_IsClient then @@ -3796,7 +3824,7 @@ begin 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);