]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/w_minstanex.qc
Remove the switchable check and do all checks in the WR_CHECKAMMO checks. Only fixed...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / w_minstanex.qc
index 3fdec0d06d88f95436721ec1dd6cb413727000b3..8b01ceee849ff4cf48605b17ac8bb77809e73db0 100644 (file)
@@ -4,8 +4,6 @@ REGISTER_WEAPON(MINSTANEX, w_minstanex, IT_CELLS, 7, WEP_FLAG_HIDDEN | WEP_FLAG_
 #ifdef SVQC
 .float minstanex_lasthit;
 
-.float minstanex_load;
-
 void W_Minstanex_SetAmmoCounter()
 {
        // set clip_load to the weapon we have switched to, if the gun uses reloading
@@ -42,7 +40,12 @@ void W_Minstanex_Reload()
        if(!autocvar_g_balance_minstanex_reload_ammo)
                return;
 
-       if(!W_ReloadCheck(self.ammo_cells, autocvar_g_balance_minstanex_ammo))
+       if(autocvar_g_balance_minstanex_laser_ammo)
+       {
+               if(!W_ReloadCheck(self.ammo_cells, min(autocvar_g_balance_minstanex_ammo, autocvar_g_balance_minstanex_laser_ammo)))
+                       return;
+       }
+       else if(!W_ReloadCheck(self.ammo_cells, autocvar_g_balance_minstanex_ammo))
                return;
 
        float t;
@@ -237,18 +240,27 @@ void minstagib_ammocheck (void)
 
 void spawnfunc_weapon_minstanex (void); // defined in t_items.qc
 
+float minstanex_ammo;
 float w_minstanex(float req)
 {
        if (req == WR_AIM)
        {
-               if(self.ammo_cells>0)
+               if(self.ammo_cells > 0)
                        self.BUTTON_ATCK = bot_aim(1000000, 0, 1, FALSE);
                else
                        self.BUTTON_ATCK2 = bot_aim(autocvar_g_balance_laser_primary_speed, 0, autocvar_g_balance_laser_primary_lifetime, FALSE);
        }
        else if (req == WR_THINK)
        {
-               if(autocvar_g_balance_minstanex_reload_ammo && ((g_minstagib && self.clip_load < 1) || (!g_minstagib && self.clip_load < autocvar_g_balance_minstanex_ammo))) // forced reload
+               if(g_minstagib)
+                       minstanex_ammo = 1;
+               else
+                       minstanex_ammo = autocvar_g_balance_minstanex_ammo;
+
+               // if the laser uses load, we also consider its ammo for reloading
+               if(autocvar_g_balance_minstanex_reload_ammo && autocvar_g_balance_minstanex_laser_ammo && self.clip_load < min(minstanex_ammo, autocvar_g_balance_minstanex_laser_ammo)) // forced reload
+                       W_Minstanex_Reload();
+               else if(autocvar_g_balance_minstanex_reload_ammo && self.clip_load < minstanex_ammo) // forced reload
                        W_Minstanex_Reload();
                else if (self.BUTTON_ATCK)
                {
@@ -264,6 +276,15 @@ float w_minstanex(float req)
                        {
                                self.jump_interval = time + autocvar_g_balance_laser_primary_refire * W_WeaponRateFactor();
 
+                               // decrease ammo for the laser?
+                               if(autocvar_g_balance_minstanex_laser_ammo)
+                               {
+                                       if(autocvar_g_balance_minstanex_reload_ammo)
+                                               self.clip_load -= autocvar_g_balance_minstanex_laser_ammo;
+                                       else
+                                               self.ammo_cells -= autocvar_g_balance_minstanex_laser_ammo;
+                               }
+
                                // ugly minstagib hack to reuse the fire mode of the laser
                                float w;
                                w = self.weapon;
@@ -294,6 +315,7 @@ float w_minstanex(float req)
                precache_sound ("weapons/nexwhoosh1.wav");
                precache_sound ("weapons/nexwhoosh2.wav");
                precache_sound ("weapons/nexwhoosh3.wav");
+               precache_sound ("weapons/reload.wav");
                w_laser(WR_PRECACHE);
        }
        else if (req == WR_SETUP)
@@ -305,22 +327,19 @@ float w_minstanex(float req)
        else if (req == WR_CHECKAMMO1)
        {
                if(autocvar_g_balance_minstanex_reload_ammo)
-               {
-                       if (g_minstagib)
-                               return self.clip_load >= 1;
-                       else
-                               return self.clip_load >= autocvar_g_balance_minstanex_ammo;
-               }
+                       return self.clip_load >= minstanex_ammo;
                else
-               {
-                       if (g_minstagib)
-                               return self.ammo_cells >= 1;
-                       else
-                               return self.ammo_cells >= autocvar_g_balance_minstanex_ammo;
-               }
+                       return self.ammo_cells >= minstanex_ammo;
        }
        else if (req == WR_CHECKAMMO2)
-               return TRUE;
+       {
+               if(!autocvar_g_balance_minstanex_laser_ammo)
+                       return TRUE;
+               if(autocvar_g_balance_minstanex_reload_ammo)
+                       return self.clip_load >= autocvar_g_balance_minstanex_laser_ammo;
+               else
+                       return self.ammo_cells >= autocvar_g_balance_minstanex_laser_ammo;
+       }
        else if (req == WR_RESETPLAYER)
        {
                self.minstanex_lasthit = 0;