]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Do the ammo maths at the beginning again, more correct and safe
authorMircea Kitsune <sonichedgehog_hyperblast00@yahoo.com>
Sat, 22 Jan 2011 00:01:28 +0000 (02:01 +0200)
committerMircea Kitsune <sonichedgehog_hyperblast00@yahoo.com>
Sat, 22 Jan 2011 00:01:28 +0000 (02:01 +0200)
qcsrc/server/w_crylink.qc
qcsrc/server/w_electro.qc
qcsrc/server/w_grenadelauncher.qc
qcsrc/server/w_hlac.qc
qcsrc/server/w_minelayer.qc
qcsrc/server/w_shotgun.qc
qcsrc/server/w_sniperrifle.qc
qcsrc/server/w_uzi.qc

index e73600eaeeb1ed16b9d7c0d852c6ca512157e6a1..54bbf3652e8f9b98dd03be0f111c06f1a0f1f404 100644 (file)
@@ -373,6 +373,18 @@ void W_Crylink_Attack (void)
        vector forward, right, up;
        float maxdmg;
 
+       // 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_crylink_reload_ammo)
+               {
+                       self.clip_load -= autocvar_g_balance_crylink_primary_ammo;
+                       self.crylink_load = self.clip_load;
+               }
+               else
+                       self.ammo_cells -= autocvar_g_balance_crylink_primary_ammo;
+       }
+
        maxdmg = autocvar_g_balance_crylink_primary_damage*autocvar_g_balance_crylink_primary_shots;
        maxdmg *= 1 + autocvar_g_balance_crylink_primary_bouncedamagefactor * autocvar_g_balance_crylink_primary_bounces;
        if(autocvar_g_balance_crylink_primary_joinexplode)
@@ -465,25 +477,25 @@ void W_Crylink_Attack (void)
                counter = counter + 1;
        }
        self.crylink_lastgroup = proj;
+}
+
+void W_Crylink_Attack2 (void)
+{
+       local float counter, shots;
+       local entity proj, prevproj, firstproj;
+       float maxdmg;
 
        // 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_crylink_reload_ammo)
                {
-                       self.clip_load -= autocvar_g_balance_crylink_primary_ammo;
+                       self.clip_load -= autocvar_g_balance_crylink_secondary_ammo;
                        self.crylink_load = self.clip_load;
                }
                else
-                       self.ammo_cells -= autocvar_g_balance_crylink_primary_ammo;
+                       self.ammo_cells -= autocvar_g_balance_crylink_secondary_ammo;
        }
-}
-
-void W_Crylink_Attack2 (void)
-{
-       local float counter, shots;
-       local entity proj, prevproj, firstproj;
-       float maxdmg;
 
        maxdmg = autocvar_g_balance_crylink_secondary_damage*autocvar_g_balance_crylink_secondary_shots;
        maxdmg *= 1 + autocvar_g_balance_crylink_secondary_bouncedamagefactor * autocvar_g_balance_crylink_secondary_bounces;
@@ -562,18 +574,6 @@ void W_Crylink_Attack2 (void)
                counter = counter + 1;
        }
        self.crylink_lastgroup = proj;
-
-       // 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_crylink_reload_ammo)
-               {
-                       self.clip_load -= autocvar_g_balance_crylink_secondary_ammo;
-                       self.crylink_load = self.clip_load;
-               }
-               else
-                       self.ammo_cells -= autocvar_g_balance_crylink_secondary_ammo;
-       }
 }
 
 void spawnfunc_weapon_crylink (void)
index 73ebfced76c452098c15c3a59d961d27e236ce8c..1b67d040895a0a116dcc726b3be72192f9e55ce1 100644 (file)
@@ -164,6 +164,18 @@ void W_Electro_Attack()
 {
        local entity proj;
 
+       // 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_electro_reload_ammo)
+               {
+                       self.clip_load -= autocvar_g_balance_electro_primary_ammo;
+                       self.electro_load = self.clip_load;
+               }
+               else
+                       self.ammo_cells -= autocvar_g_balance_electro_primary_ammo;
+       }
+
        W_SetupShot_ProjectileSize (self, '0 0 -3', '0 0 -3', FALSE, 2, "weapons/electro_fire.wav", CHAN_WEAPON, autocvar_g_balance_electro_primary_damage);
 
        pointparticles(particleeffectnum("electro_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
@@ -193,23 +205,23 @@ void W_Electro_Attack()
        CSQCProjectile(proj, TRUE, PROJECTILE_ELECTRO_BEAM, TRUE);
 
        other = proj; MUTATOR_CALLHOOK(EditProjectile);
+}
+
+void W_Electro_Attack2()
+{
+       local entity proj;
 
        // 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_electro_reload_ammo)
                {
-                       self.clip_load -= autocvar_g_balance_electro_primary_ammo;
+                       self.clip_load -= autocvar_g_balance_electro_secondary_ammo;
                        self.electro_load = self.clip_load;
                }
                else
-                       self.ammo_cells -= autocvar_g_balance_electro_primary_ammo;
+                       self.ammo_cells -= autocvar_g_balance_electro_secondary_ammo;
        }
-}
-
-void W_Electro_Attack2()
-{
-       local entity proj;
 
        W_SetupShot_ProjectileSize (self, '0 0 -4', '0 0 -4', FALSE, 2, "weapons/electro_fire2.wav", CHAN_WEAPON, autocvar_g_balance_electro_secondary_damage);
 
@@ -255,18 +267,6 @@ void W_Electro_Attack2()
        CSQCProjectile(proj, TRUE, PROJECTILE_ELECTRO, FALSE); // no culling, it has sound
 
        other = proj; MUTATOR_CALLHOOK(EditProjectile);
-
-       // 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_electro_reload_ammo)
-               {
-                       self.clip_load -= autocvar_g_balance_electro_secondary_ammo;
-                       self.electro_load = self.clip_load;
-               }
-               else
-                       self.ammo_cells -= autocvar_g_balance_electro_secondary_ammo;
-       }
 }
 
 .vector hook_start, hook_end;
@@ -331,9 +331,9 @@ void lgbeam_think()
 
        float dt, f;
        dt = frametime;
+       // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
        if not(self.owner.items & IT_UNLIMITED_WEAPON_AMMO)
        {
-               // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
                if(autocvar_g_balance_electro_primary_ammo)
                {
                        if(autocvar_g_balance_electro_reload_ammo)
index d252c1f1ca2421f566e11d65292ad41cdd469862..e803ac77f294dedf5f0a0f14232982032eda97d9 100644 (file)
@@ -215,6 +215,18 @@ void W_Grenade_Attack (void)
 {
        local entity gren;
 
+       // 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_grenadelauncher_reload_ammo)
+               {
+                       self.clip_load -= autocvar_g_balance_grenadelauncher_primary_ammo;
+                       self.grenadelauncher_load = self.clip_load;
+               }
+               else
+                       self.ammo_rockets -= autocvar_g_balance_grenadelauncher_primary_ammo;
+       }
+
        W_SetupShot_ProjectileSize (self, '-3 -3 -3', '3 3 3', FALSE, 4, "weapons/grenade_fire.wav", CHAN_WEAPON, autocvar_g_balance_grenadelauncher_primary_damage);
        w_shotdir = v_forward; // no TrueAim for grenades please
 
@@ -254,23 +266,23 @@ void W_Grenade_Attack (void)
                CSQCProjectile(gren, TRUE, PROJECTILE_GRENADE_BOUNCING, TRUE);
 
        other = gren; MUTATOR_CALLHOOK(EditProjectile);
+}
+
+void W_Grenade_Attack2 (void)
+{
+       local entity gren;
 
        // 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_grenadelauncher_reload_ammo)
                {
-                       self.clip_load -= autocvar_g_balance_grenadelauncher_primary_ammo;
+                       self.clip_load -= autocvar_g_balance_grenadelauncher_secondary_ammo;
                        self.grenadelauncher_load = self.clip_load;
                }
                else
-                       self.ammo_rockets -= autocvar_g_balance_grenadelauncher_primary_ammo;
+                       self.ammo_rockets -= autocvar_g_balance_grenadelauncher_secondary_ammo;
        }
-}
-
-void W_Grenade_Attack2 (void)
-{
-       local entity gren;
 
        W_SetupShot_ProjectileSize (self, '-3 -3 -3', '3 3 3', FALSE, 4, "weapons/grenade_fire.wav", CHAN_WEAPON, autocvar_g_balance_grenadelauncher_secondary_damage);
        w_shotdir = v_forward; // no TrueAim for grenades please
@@ -310,18 +322,6 @@ void W_Grenade_Attack2 (void)
                CSQCProjectile(gren, TRUE, PROJECTILE_GRENADE_BOUNCING, TRUE);
 
        other = gren; MUTATOR_CALLHOOK(EditProjectile);
-
-       // 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_grenadelauncher_reload_ammo)
-               {
-                       self.clip_load -= autocvar_g_balance_grenadelauncher_secondary_ammo;
-                       self.grenadelauncher_load = self.clip_load;
-               }
-               else
-                       self.ammo_rockets -= autocvar_g_balance_grenadelauncher_secondary_ammo;
-       }
 }
 
 void spawnfunc_weapon_grenadelauncher (void)
index 5385101e7e299381041b80c7e6b972eb8dff8f1f..218045d718ae9fce472fbd1f0c6f1d0eec4174ba 100644 (file)
@@ -76,6 +76,18 @@ void W_HLAC_Attack (void)
        local entity missile;
     float spread;
 
+       // 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_hlac_reload_ammo)
+               {
+                       self.clip_load -= autocvar_g_balance_hlac_primary_ammo;
+                       self.hlac_load = self.clip_load;
+               }
+               else
+                       self.ammo_cells -= autocvar_g_balance_hlac_primary_ammo;
+       }
+
     spread = autocvar_g_balance_hlac_primary_spread_min + (autocvar_g_balance_hlac_primary_spread_add * self.misc_bulletcounter);
     spread = min(spread,autocvar_g_balance_hlac_primary_spread_max);
     if(self.crouch)
@@ -116,18 +128,6 @@ void W_HLAC_Attack (void)
        CSQCProjectile(missile, TRUE, PROJECTILE_HLAC, TRUE);
 
        other = missile; MUTATOR_CALLHOOK(EditProjectile);
-
-       // 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_hlac_reload_ammo)
-               {
-                       self.clip_load -= autocvar_g_balance_hlac_primary_ammo;
-                       self.hlac_load = self.clip_load;
-               }
-               else
-                       self.ammo_cells -= autocvar_g_balance_hlac_primary_ammo;
-       }
 }
 
 void W_HLAC_Attack2f (void)
@@ -177,15 +177,6 @@ void W_HLAC_Attack2 (void)
 {
     float i;
 
-    for(i=autocvar_g_balance_hlac_secondary_shots;i>0;--i)
-        W_HLAC_Attack2f();
-
-       if (!g_norecoil)
-       {
-               self.punchangle_x = random () - 0.5;
-               self.punchangle_y = random () - 0.5;
-       }
-
        // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
        if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
        {
@@ -197,6 +188,15 @@ void W_HLAC_Attack2 (void)
                else
                        self.ammo_cells -= autocvar_g_balance_hlac_secondary_ammo;
        }
+
+    for(i=autocvar_g_balance_hlac_secondary_shots;i>0;--i)
+        W_HLAC_Attack2f();
+
+       if (!g_norecoil)
+       {
+               self.punchangle_x = random () - 0.5;
+               self.punchangle_y = random () - 0.5;
+       }
 }
 
 // weapon frames
index 691eccfe1cef2cf78f4d1d450ae19935e8f2c1fd..dfef721953d46ad2d95dc16d426733ff374d4155 100644 (file)
@@ -268,6 +268,18 @@ void W_Mine_Attack (void)
                }
        }
 
+       // 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_minelayer_reload_ammo)
+               {
+                       self.clip_load -= autocvar_g_balance_minelayer_ammo;
+                       self.minelayer_load = self.clip_load;
+               }
+               else
+                       self.ammo_rockets -= autocvar_g_balance_minelayer_ammo;
+       }
+
        W_SetupShot_ProjectileSize (self, '-4 -4 -4', '4 4 4', FALSE, 5, "weapons/mine_fire.wav", CHAN_WEAPON, autocvar_g_balance_minelayer_damage);
        pointparticles(particleeffectnum("rocketlauncher_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
 
@@ -313,18 +325,6 @@ void W_Mine_Attack (void)
        // common properties
 
        other = mine; MUTATOR_CALLHOOK(EditProjectile);
-
-       // 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_minelayer_reload_ammo)
-               {
-                       self.clip_load -= autocvar_g_balance_minelayer_ammo;
-                       self.minelayer_load = self.clip_load;
-               }
-               else
-                       self.ammo_rockets -= autocvar_g_balance_minelayer_ammo;
-       }
 }
 
 void spawnfunc_weapon_minelayer (void); // defined in t_items.qc
index 2bee7080d19caa7666d60bdf553af7a1d68cd8c0..a8e4bb47c4e8c0286e59db57c7c710fde41c2314 100644 (file)
@@ -77,6 +77,18 @@ 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.shotgun_load = self.clip_load;
+               }
+               else
+                       self.ammo_shells -= ammoamount;
+       }
+
        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)
                fireBallisticBullet(w_shotorg, w_shotdir, spread, bulletspeed, 5, d, 0, f, WEP_SHOTGUN, 0, 1, bulletconstant);
@@ -96,18 +108,6 @@ void W_Shotgun_Attack (void)
        flash.nextthink = time + 0.06;
        flash.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION;
        W_AttachToShotorg(flash, '5 0 0');
-
-       // 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.shotgun_load = self.clip_load;
-               }
-               else
-                       self.ammo_shells -= ammoamount;
-       }
 }
 
 void shotgun_meleethink (void)
index 469b2db0b140505c4ce684fd588ec16852622778..7cfea7d2a40f6e232820ba41ef85de519d0ac7d2 100644 (file)
@@ -63,6 +63,18 @@ void W_SniperRifle_Reload()
 
 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.sniperrifle_load = self.clip_load;
+               }
+               else
+                       self.ammo_nails -= pAmmo;
+       }
+
        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);
        else
@@ -84,18 +96,6 @@ void W_SniperRifle_FireBullet(float pSpread, float pDamage, float pHeadshotAdded
 
        if (autocvar_g_casings >= 2)
                SpawnCasing (((random () * 50 + 50) * v_right) - (v_forward * (random () * 25 + 25)) - ((random () * 5 - 70) * v_up), 2, vectoangles(v_forward),'0 250 0', 100, 3, self);
-
-       // 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.sniperrifle_load = self.clip_load;
-               }
-               else
-                       self.ammo_nails -= pAmmo;
-       }
 }
 
 void W_SniperRifle_Attack()
index 4693b584227136fb484441e5b6d205c817fd18fc..ebeedc2ec632b3f4fa3a8d40ffa085c5753be978 100644 (file)
@@ -149,6 +149,18 @@ void uzi_fire1_02()
 void uzi_mode1_fire_auto()
 {
        float uzi_spread;
+
+       // 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_uzi_reload_ammo)
+               {
+                       self.clip_load -= autocvar_g_balance_uzi_sustained_ammo;
+                       self.uzi_load = self.clip_load;
+               }
+               else
+                       self.ammo_nails -= autocvar_g_balance_uzi_sustained_ammo;
+       }
        
        if (self.BUTTON_ATCK)
                weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_uzi_sustained_refire, uzi_mode1_fire_auto);
@@ -186,18 +198,6 @@ void uzi_mode1_fire_auto()
        
        if (autocvar_g_casings >= 2) // casing code
                SpawnCasing (((random () * 50 + 50) * v_right) - (v_forward * (random () * 25 + 25)) - ((random () * 5 - 70) * v_up), 2, vectoangles(v_forward),'0 250 0', 100, 3, self);
-
-       // 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_uzi_reload_ammo)
-               {
-                       self.clip_load -= autocvar_g_balance_uzi_sustained_ammo;
-                       self.uzi_load = self.clip_load;
-               }
-               else
-                       self.ammo_nails -= autocvar_g_balance_uzi_sustained_ammo;
-       }
 }
 
 void uzi_mode1_fire_burst()