]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
2 new features: Don't switch away from a weapon if one of its modes can still fire...
authorSamual <samual@xonotic.org>
Thu, 5 Jan 2012 21:33:20 +0000 (16:33 -0500)
committerSamual <samual@xonotic.org>
Thu, 5 Jan 2012 21:33:20 +0000 (16:33 -0500)
balance25.cfg
balanceFruitieX.cfg
balanceXPM.cfg
balanceXonotic.cfg
qcsrc/server/autocvars.qh
qcsrc/server/cl_weaponsystem.qc
qcsrc/server/w_electro.qc
qcsrc/server/w_minelayer.qc
qcsrc/server/w_nex.qc

index 8dc874e7fe4796394c197b71f44a9f8576ebfcf3..2374897b7a96321293da169f00756d951fca8eae 100644 (file)
@@ -437,6 +437,7 @@ set g_balance_electro_combo_force 200
 set g_balance_electro_combo_radius 250
 set g_balance_electro_combo_comboradius 0
 set g_balance_electro_combo_speed 2000
+set g_balance_electro_combo_safeammocheck 0
 set g_balance_electro_reload_ammo 0 //default: 20
 set g_balance_electro_reload_time 2
 // }}}
index 8568cc41aaa8bc9bad4688c5843ebe2251417e61..8a0bbc0435cc48c47270461571394c87ebac77f4 100644 (file)
@@ -437,6 +437,7 @@ set g_balance_electro_combo_force 80
 set g_balance_electro_combo_radius 250
 set g_balance_electro_combo_comboradius 0
 set g_balance_electro_combo_speed 400
+set g_balance_electro_combo_safeammocheck 1
 set g_balance_electro_reload_ammo 0 //default: 20
 set g_balance_electro_reload_time 2
 // }}}
index 4bc6d041fb2494801f2cb91f5d87a5d4d0ad446e..a866d75245fb85bd2a4a43a49b9c50fdcc5a1bf5 100644 (file)
@@ -437,6 +437,7 @@ set g_balance_electro_combo_force 120
 set g_balance_electro_combo_radius 175
 set g_balance_electro_combo_comboradius 275
 set g_balance_electro_combo_speed 2000
+set g_balance_electro_combo_safeammocheck 0
 set g_balance_electro_reload_ammo 0 //default: 20
 set g_balance_electro_reload_time 2
 // }}}
index 4bea6c3b189e8127f5d6344ccf57482e0edaae35..b4e368a28ed36ec8b45ab8ff88e6386243515d72 100644 (file)
@@ -437,6 +437,7 @@ set g_balance_electro_combo_force 120
 set g_balance_electro_combo_radius 175
 set g_balance_electro_combo_comboradius 275
 set g_balance_electro_combo_speed 2000
+set g_balance_electro_combo_safeammocheck 1
 set g_balance_electro_reload_ammo 0 //default: 20
 set g_balance_electro_reload_time 2
 // }}}
index 0d794da2ec92acb88326d16ca561e2a88e53545a..a5759020463d988a0817691052dc924aa1140f44 100644 (file)
@@ -197,6 +197,7 @@ float autocvar_g_balance_electro_combo_edgedamage;
 float autocvar_g_balance_electro_combo_force;
 float autocvar_g_balance_electro_combo_radius;
 float autocvar_g_balance_electro_combo_speed;
+float autocvar_g_balance_electro_combo_safeammocheck;
 float autocvar_g_balance_electro_lightning;
 float autocvar_g_balance_electro_primary_ammo;
 float autocvar_g_balance_electro_primary_animtime;
index e049ef8588e2ca97501451d092149e9b037c7679..4a35f481b57c8a88abf53b714b0f6e2762571e6c 100644 (file)
@@ -878,7 +878,17 @@ void W_SwitchToOtherWeapon(entity pl)
        if(ww)
                W_SwitchWeapon_Force(pl, ww);
 }
+
+string PrimaryOrSecondary(float secondary)
+{
+       if(secondary)
+               return "secondary";
+       else
+               return "primary";
+}
+
 .float prevdryfire;
+.float prevwarntime;
 float weapon_prepareattack_checkammo(float secondary)
 {
        if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
@@ -896,7 +906,19 @@ float weapon_prepareattack_checkammo(float secondary)
                        self.prevdryfire = time;
                }
 
-               W_SwitchToOtherWeapon(self);
+               if(weapon_action(self.weapon, WR_CHECKAMMO2 - secondary)) // check if the other firing mode has enough ammo
+               {
+                       if(time - self.prevwarntime > 1)
+                       {
+                               sprint(self, strcat("^2", W_Name(self.weapon), " ", PrimaryOrSecondary(secondary), "^7 is unable to fire, but its ^2", PrimaryOrSecondary(1 - secondary), "^7 can.\n"));
+                       }
+                       self.prevwarntime = time;
+               }
+               else // this weapon is totally unable to fire, switch to another one
+               {
+                       W_SwitchToOtherWeapon(self);
+               }
+               
                return FALSE;
        }
        return TRUE;
index ec333cc724d1291abcd11285b391037181c784e5..9b1b96e56547abaf3d4bbff42c89a41bde6c781f 100644 (file)
@@ -525,8 +525,16 @@ float w_electro(float req)
        }
        else if (req == WR_CHECKAMMO2)
        {
-               ammo_amount = self.ammo_cells >= autocvar_g_balance_electro_secondary_ammo;
-               ammo_amount += self.(weapon_load[WEP_ELECTRO]) >= autocvar_g_balance_electro_secondary_ammo;
+               if(autocvar_g_balance_electro_combo_safeammocheck) // true if you can fire at least one secondary blob AND one primary shot after it, otherwise false.
+               {
+                       ammo_amount = self.ammo_cells >= autocvar_g_balance_electro_secondary_ammo + autocvar_g_balance_electro_primary_ammo;
+                       ammo_amount += self.(weapon_load[WEP_ELECTRO]) >= autocvar_g_balance_electro_secondary_ammo + autocvar_g_balance_electro_primary_ammo;
+               }
+               else
+               {
+                       ammo_amount = self.ammo_cells >= autocvar_g_balance_electro_secondary_ammo;
+                       ammo_amount += self.(weapon_load[WEP_ELECTRO]) >= autocvar_g_balance_electro_secondary_ammo;
+               }
                return ammo_amount;
        }
        else if (req == WR_RESETPLAYER)
index afe37b56f7b6680bcd143f88d0a460288b11481c..3ec50da50d633cc59679dd5087595726d1ab6f1b 100644 (file)
@@ -267,7 +267,7 @@ void W_Mine_Attack (void)
                if(W_Mine_Count(self) >= autocvar_g_balance_minelayer_limit)
                {
                        // the refire delay keeps this message from being spammed
-                       sprint(self, strcat("You cannot place more than ^2", ftos(autocvar_g_balance_minelayer_limit), " ^7mines at a time\n") );
+                       sprint(self, strcat("minelayer: You cannot place more than ^2", ftos(autocvar_g_balance_minelayer_limit), " ^7mines at a time\n") );
                        play2(self, "weapons/unavailable.wav");
                        return;
                }
index 3f47b48fd073b149cfdb6b386f226442badd668a..cdcabc86688996cde0ce04f43dd94816ab9eb88e 100644 (file)
@@ -221,10 +221,17 @@ float w_nex(float req)
        }
        else if (req == WR_CHECKAMMO2)
        {
-               // don't allow charging if we don't have enough ammo
-               ammo_amount = self.ammo_cells >= autocvar_g_balance_nex_secondary_ammo;
-               ammo_amount += self.(weapon_load[WEP_NEX]) >= autocvar_g_balance_nex_secondary_ammo;
-               return ammo_amount;
+               if(autocvar_g_balance_nex_secondary)
+               {
+                       // don't allow charging if we don't have enough ammo
+                       ammo_amount = self.ammo_cells >= autocvar_g_balance_nex_secondary_ammo;
+                       ammo_amount += self.(weapon_load[WEP_NEX]) >= autocvar_g_balance_nex_secondary_ammo;    
+                       return ammo_amount;
+               }
+               else
+               {
+                       return FALSE; // zoom is not a fire mode
+               }
        }
        else if (req == WR_RELOAD)
        {