#else
#ifdef SVQC
+// weapon load persistence, for weapons that support reloading
+.float shotgun_load;
+
void W_Shotgun_SetAmmoCounter()
{
// set clip_load to the weapon we have switched to, if the gun uses reloading
float w_shotgun(float req)
{
+ float ammo_amount;
if (req == WR_AIM)
if(vlen(self.origin-self.enemy.origin) <= autocvar_g_balance_shotgun_secondary_melee_range)
self.BUTTON_ATCK2 = bot_aim(1000000, 0, 0.001, FALSE);
}
else if (req == WR_CHECKAMMO1)
{
- if(autocvar_g_balance_shotgun_reload_ammo)
- return self.shotgun_load >= autocvar_g_balance_shotgun_primary_ammo;
- else
- return self.ammo_shells >= autocvar_g_balance_shotgun_primary_ammo;
+ ammo_amount = self.ammo_shells >= autocvar_g_balance_shotgun_primary_ammo;
+ ammo_amount += (autocvar_g_balance_shotgun_reload_ammo && self.shotgun_load >= autocvar_g_balance_shotgun_primary_ammo);
+ return ammo_amount;
}
else if (req == WR_CHECKAMMO2)
{
+ // melee attack is always available
return TRUE;
}
- else if (req == WR_RELOAD)
+ else if (req == WR_RESETPLAYER)
{
- W_Shotgun_Reload();
+ // all weapons must be fully loaded when we spawn
+ self.shotgun_load = autocvar_g_balance_shotgun_reload_ammo;
}
- else if (req == WR_SWITCHABLE)
+ else if (req == WR_RELOAD)
{
- // checks if this weapon can be switched to, when reloading is enabled
- // returns true if there's either enough load in the weapon to use it,
- // or we have enough ammo to reload the weapon to a usable point
- float ammo_amount;
- ammo_amount = autocvar_g_balance_shotgun_primary_ammo;
- return (autocvar_g_balance_shotgun_reload_ammo && self.shotgun_load >= ammo_amount) || self.ammo_shells >= ammo_amount;
+ W_Shotgun_Reload();
}
return TRUE;
};