// ----------------------------------------------------------------
float ammo_amount;
-void W_SniperRifle_Ammo(string ammo_string, float ammo_reduce)
-{
- // sets ammo_amount to our current ammo level, and can optionally reduce ammo
- switch(ammo_string)
- {
- case "shells":
- ammo_amount = self.ammo_shells;
- self.ammo_shells -= ammo_reduce;
- return;
- case "nails":
- ammo_amount = self.ammo_nails;
- self.ammo_nails -= ammo_reduce;
- return;
- case "cells":
- ammo_amount = self.ammo_cells;
- self.ammo_cells -= ammo_reduce;
- return;
- case "rockets":
- ammo_amount = self.ammo_rockets;
- self.ammo_rockets -= ammo_reduce;
- return;
- case "fuel":
- ammo_amount = self.ammo_fuel;
- self.ammo_fuel -= ammo_reduce;
- return;
- default:
- return;
- }
-}
float W_SniperRifle_CheckMaxBullets(float checkammo)
{
w_ready();
}
-float W_SniperRifle_Reload(string ammo_type)
+float W_SniperRifle_Reload(float ammo_value)
{
float t;
W_SniperRifle_CheckMaxBullets(TRUE);
- W_SniperRifle_Ammo(ammo_type, 0); // set ammo_amount to the ammo type specified
+ ammo_amount = ammo_value; // save ammo to a global float
if(ammo_amount < min(autocvar_g_balance_sniperrifle_primary_ammo, autocvar_g_balance_sniperrifle_secondary_ammo)) // when we get here, bulletcounter must be 0 or -1
{
print("cannot reload... not enough bullets\n");
#else
#ifdef SVQC
-void W_Shotgun_CheckReloadAndReady()
+void W_Shotgun_DoReload()
{
w_ready();
- if(self.sniperrifle_bulletcounter <= 0)
- if(W_SniperRifle_Reload("shells"))
- return;
+ if(W_SniperRifle_Reload(self.ammo_shells))
+ return;
}
void W_Shotgun_Attack (void)
float bulletconstant;
local entity flash;
- W_Shotgun_CheckReloadAndReady();
+ if(self.sniperrifle_bulletcounter <= 0)
+ W_Shotgun_DoReload();
if(self.sniperrifle_bulletcounter < 0)
return; // reloading, so we are done
if(self.weaponentity.state == WS_READY)
{
self.wish_reload = 0;
- W_SniperRifle_Reload("shells");
+ W_SniperRifle_Reload(self.ammo_shells);
}
}
}
.float sniperrifle_accumulator;
-void W_SniperRifle_CheckReloadAndReady()
+void W_SniperRifle_DoReload()
{
w_ready();
- if(self.sniperrifle_bulletcounter <= 0)
- if(W_SniperRifle_Reload("nails"))
- return;
+ if(W_SniperRifle_Reload(self.ammo_nails))
+ return;
}
void W_SniperRifle_FireBullet(float pSpread, float pDamage, float pHeadshotAddedDamage, float pForce, float pSpeed, float pLifetime, float pAmmo, float deathtype, float pBulletConstant)
void W_SniperRifle_BulletHail_Continue()
{
float r, sw, af;
- W_SniperRifle_CheckReloadAndReady();
+ if(self.sniperrifle_bulletcounter <= 0)
+ W_SniperRifle_DoReload();
if(self.sniperrifle_bulletcounter < 0)
return; // reloading, so we are done
sw = self.switchweapon; // make it not detect weapon changes as reason to abort firing
else
{
// just one shot
- weapon_thinkf(fr, animtime, W_SniperRifle_CheckReloadAndReady);
+ weapon_thinkf(fr, animtime, w_ready);
}
}
if(self.weaponentity.state == WS_READY)
{
self.wish_reload = 0;
- W_SniperRifle_Reload("nails");
+ W_SniperRifle_Reload(self.ammo_nails);
}
}
}