]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/cl_weaponsystem.qc
Use only WR_SWITCHABLE to check if we can select our weapon. The ammo checks still...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / cl_weaponsystem.qc
index abeb9f6da4c6f379c8bb5a0263d910bb7a6dba57..a6841d2d785d5eed7f7976644e98032cf1c5b497 100644 (file)
@@ -925,15 +925,13 @@ float client_hasweapon(entity cl, float wpn, float andammo, float complain)
                        {
                                oldself = self;
                                self = cl;
-                               f = weapon_action(wpn, WR_CHECKAMMO1);
-                               f = f + weapon_action(wpn, WR_CHECKAMMO2);
+                               f = weapon_action(wpn, WR_SWITCHABLE);
 
                                // allow switching to reloadable weapons, even if we're out of ammo, since the weapon itself
                                // might still be loaded. The reload code takes care of complaining and forced switching
                                entity e;
-                               e = get_weaponinfo(self.weapon);
-                               if(cvar(strcat("g_balance_", e.netname, "_reload_ammo")))
-                                       f = 1;
+                               e = get_weaponinfo(wpn);
+                               if(wpn != WEP_TUBA && wpn != WEP_PORTO && wpn != WEP_HOOK) // skip non-reloadable weapons, or we access undefined cvars
 
                                // always allow selecting the Mine Layer if we placed mines, so that we can detonate them
                                local entity mine;
@@ -1054,11 +1052,9 @@ float weapon_prepareattack_checkammo(float secondary)
        if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
        if (!weapon_action(self.weapon, WR_CHECKAMMO1 + secondary))
        {
-               // allow switching to reloadable weapons, even if we're out of ammo, since the weapon itself
-               // might still be loaded. The reload code takes care of complaining and forced switching
-               entity e;
-               e = get_weaponinfo(self.weapon);
-               if(cvar(strcat("g_balance_", e.netname, "_reload_ammo")))
+               // always allow reloadable weapons, even if we're out of ammo, since the weapon itself
+               // could still be loaded. The reload code takes care of the rest
+               if(weapon_action(self.weapon, WR_SWITCHABLE))
                        return FALSE;
 
                // always keep the Mine Layer if we placed mines, so that we can detonate them
@@ -1628,7 +1624,7 @@ void W_SetupProjectileVelocity(entity missile, float pSpeed, float spread)
 
 // shared weapon reload code
 .float reload_complain;
-float W_ReloadCheck(float ammo_amount)
+float W_ReloadCheck(float ammo_amount, float ammo_shot)
 {
        entity e;
        e = get_weaponinfo(self.weapon);
@@ -1646,8 +1642,8 @@ float W_ReloadCheck(float ammo_amount)
                        sprint(self, strcat("You don't have enough ammo to reload the ^2", W_Name(self.weapon), "\n"));
                        self.reload_complain = time + 1;
                }
-               // is there's no more ammo to reload, only switch to another weapon if there's no more load in this one
-               if(!self.clip_load)
+               // switch away if the loaded amount of ammo is not enough to keep using this weapon
+               if(self.clip_load < ammo_shot)
                {
                        self.clip_load = -1; // reload later
                        W_SwitchToOtherWeapon(self);