]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/w_sniperrifle.qc
Precache the reload sound in one place only, until weapons have individual reload...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / w_sniperrifle.qc
index 6c2621f9f4c14025151984e8e0475918c75e5553..f634993f5ad7ea6c2565c4e60eb7fc9b56f54aaf 100644 (file)
@@ -10,17 +10,7 @@ REGISTER_WEAPON(SNIPERRIFLE, w_sniperrifle, IT_NAILS, 7, WEP_FLAG_NORMAL | WEP_F
 
 void W_SniperRifle_FireBullet(float pSpread, float pDamage, float pHeadshotAddedDamage, float pForce, float pSpeed, float pLifetime, float pAmmo, float deathtype, float pBulletConstant)
 {
-       // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
-       if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
-       {
-               if(autocvar_g_balance_sniperrifle_reload_ammo)
-               {
-                       self.clip_load -= pAmmo;
-                       self.weapon_load[WEP_SNIPERRIFLE] = self.clip_load;
-               }
-               else
-                       self.ammo_nails -= pAmmo;
-       }
+       W_DecreaseAmmo(ammo_nails, pAmmo, autocvar_g_balance_sniperrifle_reload_ammo);
 
        if(deathtype & HITTYPE_SECONDARY)
                W_SetupShot (self, autocvar_g_antilag_bullets && pSpeed >= autocvar_g_antilag_bullets, 2, "weapons/campingrifle_fire2.wav", CHAN_WEAPON, autocvar_g_balance_sniperrifle_secondary_damage + autocvar_g_balance_sniperrifle_secondary_headshotaddeddamage);
@@ -185,11 +175,12 @@ float w_sniperrifle(float req)
                precache_model ("models/weapons/h_campingrifle.iqm");
                precache_sound ("weapons/campingrifle_fire.wav");
                precache_sound ("weapons/campingrifle_fire2.wav");
-               precache_sound ("weapons/reload.wav");
+               //precache_sound ("weapons/reload.wav"); // until weapons have individual reload sounds, precache the reload sound somewhere else
        }
        else if (req == WR_SETUP)
        {
                weapon_setup(WEP_SNIPERRIFLE);
+               self.current_ammo = ammo_nails;
        }
        else if (req == WR_CHECKAMMO1)
        {
@@ -209,7 +200,7 @@ float w_sniperrifle(float req)
        }
        else if (req == WR_RELOAD)
        {
-               W_Reload(ammo_nails, min(autocvar_g_balance_sniperrifle_primary_ammo, autocvar_g_balance_sniperrifle_secondary_ammo), autocvar_g_balance_sniperrifle_reload_ammo, autocvar_g_balance_sniperrifle_reload_time, "weapons/reload.wav");
+               W_Reload(min(autocvar_g_balance_sniperrifle_primary_ammo, autocvar_g_balance_sniperrifle_secondary_ammo), autocvar_g_balance_sniperrifle_reload_ammo, autocvar_g_balance_sniperrifle_reload_time, "weapons/reload.wav");
        }
        return TRUE;
 };