summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: dcfda43)
raw | patch | inline | side by side (parent: dcfda43)
author | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Sun, 6 Aug 2017 05:05:29 +0000 (08:05 +0300) | ||
committer | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Sun, 6 Aug 2017 05:05:49 +0000 (08:05 +0300) |
src/game/g_player.pas | patch | blob | history |
diff --git a/src/game/g_player.pas b/src/game/g_player.pas
index 558edf291005ae96e782a5a526694dc9b57bb8b5..5719d11d87cfe058314d818bb3b6eb83c5a890b0 100644 (file)
--- a/src/game/g_player.pas
+++ b/src/game/g_player.pas
procedure cycleWeapon (dir: Integer);
function getNextWeaponIndex (): Byte; // return 255 for "no switch"
procedure resetWeaponQueue ();
+ function hasAmmoForWeapon (weapon: Byte): Boolean;
public
FDamageBuffer: Integer;
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
// 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);