X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fgame%2Fg_player.pas;h=e90398276756262f8eb5272e2015fae609deae20;hb=d4ac1c7881f735f123cd5ffd2355c8c701c34289;hp=558edf291005ae96e782a5a526694dc9b57bb8b5;hpb=dcfda4339af6e1c6fe217cb1e7cbc5d9e09dae6c;p=d2df-sdl.git diff --git a/src/game/g_player.pas b/src/game/g_player.pas index 558edf2..e903982 100644 --- a/src/game/g_player.pas +++ b/src/game/g_player.pas @@ -212,6 +212,7 @@ type procedure cycleWeapon (dir: Integer); function getNextWeaponIndex (): Byte; // return 255 for "no switch" procedure resetWeaponQueue (); + function hasAmmoForWeapon (weapon: Byte): Boolean; public FDamageBuffer: Integer; @@ -3279,6 +3280,19 @@ begin FNextWeapDelay := 0; end; +function TPlayer.hasAmmoForWeapon (weapon: Byte): Boolean; +begin + 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_ROCKETLAUNCHER: result := (FAmmo[A_ROCKETS] > 0); + WEAPON_PLASMA, WEAPON_BFG: result := (FAmmo[A_CELLS] > 0); + else result := (weapon < length(FWeapon)); + end; +end; + // return 255 for "no switch" function TPlayer.getNextWeaponIndex (): Byte; var @@ -3289,6 +3303,7 @@ begin result := 255; // default result: "no switch" for i := 0 to High(wantThisWeapon) do wantThisWeapon[i] := false; for i := 0 to High(FWeapon) do if (FNextWeap and (1 shl i)) <> 0 then begin wantThisWeapon[i] := true; Inc(wwc); end; + (* if wantThisWeapon[FCurrWeap] then begin // these hacks implements alternating between SG and SSG; sorry @@ -3298,6 +3313,7 @@ begin if FCurrWeap = WEAPON_KASTET then begin wantThisWeapon[WEAPON_SAW] := true; Inc(wwc); end; if FCurrWeap = WEAPON_SAW then begin wantThisWeapon[WEAPON_KASTET] := true; Inc(wwc); end; end; + *) // exclude currently selected weapon from the set wantThisWeapon[FCurrWeap] := false; // slow down alterations a little @@ -3306,12 +3322,11 @@ begin // more than one weapon requested, assume "alteration" and check alteration delay if FNextWeapDelay > 0 then begin FNextWeap := 0; exit; end; // yeah end; - // no more hacks (yet) // do not reset weapon queue, it will be done in `RealizeCurrentWeapon()` // try weapons in descending order for i := High(FWeapon) downto 0 do begin - if wantThisWeapon[i] and FWeapon[i] then + if wantThisWeapon[i] and FWeapon[i] and ((wwc = 1) or hasAmmoForWeapon(i)) then begin // i found her! result := Byte(i);