]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/w_fireball.qc
Testcase for netlinked bug
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / w_fireball.qc
index 29fdab1819713b4c775e628ab3c305091b93fa0c..4408ccf88f202ec907dc5252f9bb4545a8a5fa35 100644 (file)
@@ -6,21 +6,6 @@ REGISTER_WEAPON(FIREBALL, w_fireball, IT_FUEL, 9, WEP_FLAG_RELOADABLE | WEP_TYPE
 .vector fireball_impactvec;
 .float fireball_primarytime;
 
-void W_Fireball_Reload()
-{
-       // fuel can be a non-whole number, which brakes stuff here when between 0 and 1
-       if(self.ammo_fuel < 1)
-               self.ammo_fuel = 0;
-
-       self.reload_ammo_player = ammo_fuel;
-       self.reload_ammo_min = min(autocvar_g_balance_fireball_primary_ammo, autocvar_g_balance_fireball_secondary_ammo);
-       self.reload_ammo_amount = autocvar_g_balance_fireball_reload_ammo;
-       self.reload_time = autocvar_g_balance_fireball_reload_time;
-       self.reload_sound = "weapons/reload.wav";
-
-       W_Reload();
-}
-
 void W_Fireball_Explode (void)
 {
        entity e;
@@ -209,17 +194,7 @@ void W_Fireball_Attack1_Frame1()
 
 void W_Fireball_Attack1_Frame0()
 {
-       // 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_fireball_reload_ammo)
-               {
-                       self.clip_load -= autocvar_g_balance_fireball_primary_ammo;
-                       self.weapon_load[WEP_FIREBALL] = self.clip_load;
-               }
-               else
-                       self.ammo_fuel -= autocvar_g_balance_fireball_primary_ammo;
-       }
+       W_DecreaseAmmo(ammo_fuel, autocvar_g_balance_fireball_primary_ammo, autocvar_g_balance_fireball_reload_ammo);
 
        W_Fireball_AttackEffect(0, '-1.25 -3.75 0');
        sound (self, CHAN_WEAPON, "weapons/fireball_prefire2.wav", VOL_BASE, ATTN_NORM);
@@ -270,17 +245,7 @@ void W_Fireball_Attack2()
        vector f_diff;
        float c;
 
-       // 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_fireball_reload_ammo)
-               {
-                       self.clip_load -= autocvar_g_balance_fireball_secondary_ammo;
-                       self.weapon_load[WEP_FIREBALL] = self.clip_load;
-               }
-               else
-                       self.ammo_fuel -= autocvar_g_balance_fireball_secondary_ammo;
-       }
+       W_DecreaseAmmo(ammo_fuel, autocvar_g_balance_fireball_secondary_ammo, autocvar_g_balance_fireball_reload_ammo);
 
        c = mod(self.bulletcounter, 4);
        switch(c)
@@ -362,7 +327,7 @@ float w_fireball(float req)
        else if (req == WR_THINK)
        {
                if(autocvar_g_balance_fireball_reload_ammo && self.clip_load < min(autocvar_g_balance_fireball_primary_ammo, autocvar_g_balance_fireball_secondary_ammo)) // forced reload
-                       W_Fireball_Reload();
+                       weapon_action(self.weapon, WR_RELOAD);
                else if (self.BUTTON_ATCK)
                {
                        if (time >= self.fireball_primarytime)
@@ -390,11 +355,12 @@ float w_fireball(float req)
                precache_sound ("weapons/fireball_fire.wav");
                precache_sound ("weapons/fireball_fire2.wav");
                precache_sound ("weapons/fireball_prefire2.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_FIREBALL);
+               self.current_ammo = ammo_fuel;
        }
        else if (req == WR_CHECKAMMO1)
        {
@@ -414,7 +380,11 @@ float w_fireball(float req)
        }
        else if (req == WR_RELOAD)
        {
-               W_Fireball_Reload();
+               // fuel can be a non-whole number, which brakes stuff here when between 0 and 1
+               if(self.ammo_fuel < 1)
+                       self.ammo_fuel = 0;
+
+               W_Reload(min(autocvar_g_balance_fireball_primary_ammo, autocvar_g_balance_fireball_secondary_ammo), autocvar_g_balance_fireball_reload_ammo, autocvar_g_balance_fireball_reload_time, "weapons/reload.wav");
        }
        return TRUE;
 };