]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/w_shotgun.qc
Testcase for netlinked bug
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / w_shotgun.qc
index ff07f82b2f1e2c28eb6dfd068d466a1c87731af8..635b1ccf8b959ac753e4f06ef493605e9049b973 100644 (file)
@@ -3,17 +3,6 @@ REGISTER_WEAPON(SHOTGUN, w_shotgun, IT_SHELLS, 2, WEP_FLAG_NORMAL | WEP_FLAG_REL
 #else
 #ifdef SVQC
 
-void W_Shotgun_Reload()
-{
-       self.reload_ammo_player = ammo_shells;
-       self.reload_ammo_min = autocvar_g_balance_shotgun_primary_ammo;
-       self.reload_ammo_amount = autocvar_g_balance_shotgun_reload_ammo;
-       self.reload_time = autocvar_g_balance_shotgun_reload_time;
-       self.reload_sound = "weapons/reload.wav";
-
-       W_Reload();
-}
-
 void W_Shotgun_Attack (void)
 {
        float   sc;
@@ -34,17 +23,7 @@ void W_Shotgun_Attack (void)
        bulletspeed = autocvar_g_balance_shotgun_primary_speed;
        bulletconstant = autocvar_g_balance_shotgun_primary_bulletconstant;
 
-       // 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_shotgun_reload_ammo)
-               {
-                       self.clip_load -= ammoamount;
-                       self.weapon_load[WEP_SHOTGUN] = self.clip_load;
-               }
-               else
-                       self.ammo_shells -= ammoamount;
-       }
+       W_DecreaseAmmo(ammo_shells, ammoamount, autocvar_g_balance_shotgun_reload_ammo);
 
        W_SetupShot (self, autocvar_g_antilag_bullets && bulletspeed >= autocvar_g_antilag_bullets, 5, "weapons/shotgun_fire.wav", CHAN_WEAPON, d * bullets);
        for (sc = 0;sc < bullets;sc = sc + 1)
@@ -98,7 +77,7 @@ void shotgun_meleethink (void)
                Damage (trace_ent, self.owner, self.owner, autocvar_g_balance_shotgun_secondary_damage * min(1, f + 1), WEP_SHOTGUN | HITTYPE_SECONDARY , self.owner.origin + self.owner.view_ofs, force);
                remove(self);
        }
-       else if(time >= self.cnt + meleetime) // missed, remove ent
+       else if(time >= self.cnt + meleetime || (self.owner.deadflag != DEAD_NO && autocvar_g_balance_shotgun_secondary_melee_no_doubleslap)) // missed or owner died, remove ent
                remove(self);
        else // continue swinging the weapon in hope of hitting someone :)
                self.nextthink = time;
@@ -135,7 +114,7 @@ float w_shotgun(float req)
                {
                        // don't force reload an empty shotgun if its melee attack is active
                        if not(autocvar_g_balance_shotgun_secondary && self.ammo_shells < autocvar_g_balance_shotgun_primary_ammo)
-                               W_Shotgun_Reload();
+                               weapon_action(self.weapon, WR_RELOAD);
                }
                else
                {
@@ -152,6 +131,7 @@ float w_shotgun(float req)
                                }
                        }
                }
+               if (self.clip_load >= 0) // we are not currently reloading
                if (self.BUTTON_ATCK2 && autocvar_g_balance_shotgun_secondary)
                if (weapon_prepareattack(1, autocvar_g_balance_shotgun_secondary_refire))
                {
@@ -168,11 +148,12 @@ float w_shotgun(float req)
                precache_sound ("misc/itempickup.wav");
                precache_sound ("weapons/shotgun_fire.wav");
                precache_sound ("weapons/shotgun_melee.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_SHOTGUN);
+               self.current_ammo = ammo_shells;
        }
        else if (req == WR_CHECKAMMO1)
        {
@@ -187,7 +168,7 @@ float w_shotgun(float req)
        }
        else if (req == WR_RELOAD)
        {
-               W_Shotgun_Reload();
+               W_Reload(autocvar_g_balance_shotgun_primary_ammo, autocvar_g_balance_shotgun_reload_ammo, autocvar_g_balance_shotgun_reload_time, "weapons/reload.wav");
        }
        return TRUE;
 };