]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Cleanup ammofield stuff some more, fix handling in mutator_nix
authorSamual Lenks <samual@xonotic.org>
Mon, 30 Dec 2013 23:03:29 +0000 (18:03 -0500)
committerSamual Lenks <samual@xonotic.org>
Mon, 30 Dec 2013 23:03:29 +0000 (18:03 -0500)
qcsrc/common/weapons/weapons.qh
qcsrc/server/defs.qh
qcsrc/server/mutators/mutator_nix.qc
qcsrc/server/t_items.qh

index 3e5197fce2070e8cd7cffe30bf298507e8d64dc8..602f8f7330e3e8e27419b75201fd8ab2acc68492 100644 (file)
@@ -113,8 +113,6 @@ void W_RandomWeapons(entity e, float n);
 
 string W_Name(float weaponid);
 
-float W_AmmoItemCode(float wpn);
-
 
 // ammo types
 .float ammo_shells;
index cb46da326eeca192d2fb7df1d7ff44ee03939074..7634de6490d7a9551735bfbd3eb00468c49b5bbc 100644 (file)
@@ -286,10 +286,6 @@ string gamemode_name;
 
 float startitem_failed;
 
-typedef .float floatfield;
-floatfield Item_CounterField(float it);
-
-float W_AmmoItemCode(float wpn);
 string W_Name(float weaponid);
 string W_Apply_Weaponreplace(string in);
 
index 4aa7e44d5b2356a60bf2c06ae6742dffe3236f62..29153f1a1698d0a3b01c96e7544f07a1286b14b5 100644 (file)
@@ -1,10 +1,8 @@
 float g_nix_with_laser;
 // WEAPONTODO
 float nix_weapon;
-float nix_weapon_ammo;
 float nix_nextchange;
 float nix_nextweapon;
-float nix_nextweapon_ammo;
 .float nix_lastchange_id;
 .float nix_lastinfotime;
 .float nix_nextincr;
@@ -39,7 +37,6 @@ void NIX_ChooseNextWeapon()
                if(NIX_CanChooseWeapon(j))
                        RandomSelection_Add(world, j, string_null, 1, (j != nix_weapon));
        nix_nextweapon = RandomSelection_chosen_float;
-       nix_nextweapon_ammo = W_AmmoItemCode(nix_nextweapon);
 }
 
 void NIX_GiveCurrentWeapon()
@@ -54,7 +51,6 @@ void NIX_GiveCurrentWeapon()
        if(dt <= 0)
        {
                nix_weapon = nix_nextweapon;
-               nix_weapon_ammo = nix_nextweapon_ammo;
                nix_nextweapon = 0;
                if (!nix_nextchange) // no round played yet?
                        nix_nextchange = time; // start the first round now!
@@ -63,35 +59,36 @@ void NIX_GiveCurrentWeapon()
                //WEP_ACTION(nix_weapon, WR_INIT); // forget it, too slow
        }
 
+       // get weapon info
+       entity e = get_weaponinfo(nix_weapon);
+
        if(nix_nextchange != self.nix_lastchange_id) // this shall only be called once per round!
        {
-               self.nix_lastchange_id = nix_nextchange;
-               if (self.items & IT_UNLIMITED_WEAPON_AMMO)
+               self.ammo_shells = self.ammo_nails = self.ammo_rockets = self.ammo_cells = self.ammo_fuel = 0;
+               
+               if(self.items & IT_UNLIMITED_WEAPON_AMMO)
                {
-                       self.ammo_shells = (nix_weapon_ammo & IT_SHELLS) ?
-                               autocvar_g_pickup_shells_max : 0;
-                       self.ammo_nails = (nix_weapon_ammo & IT_NAILS) ?
-                               autocvar_g_pickup_nails_max : 0;
-                       self.ammo_rockets = (nix_weapon_ammo & IT_ROCKETS) ?
-                               autocvar_g_pickup_rockets_max : 0;
-                       self.ammo_cells = (nix_weapon_ammo & IT_CELLS) ?
-                               autocvar_g_pickup_cells_max : 0;
-                       self.ammo_fuel = (nix_weapon_ammo & IT_FUEL) ?
-                               autocvar_g_pickup_fuel_max : 0;
+                       switch(e.current_ammo)
+                       {
+                               case ammo_shells:  self.ammo_shells  = autocvar_g_pickup_shells_max;  break;
+                               case ammo_nails:   self.ammo_nails   = autocvar_g_pickup_nails_max;   break;
+                               case ammo_rockets: self.ammo_rockets = autocvar_g_pickup_rockets_max; break;
+                               case ammo_cells:   self.ammo_cells   = autocvar_g_pickup_cells_max;   break;
+                               case ammo_fuel:    self.ammo_fuel    = autocvar_g_pickup_fuel_max;    break;
+                       }
                }
                else
                {
-                       self.ammo_shells = (nix_weapon_ammo & IT_SHELLS) ?
-                               autocvar_g_balance_nix_ammo_shells : 0;
-                       self.ammo_nails = (nix_weapon_ammo & IT_NAILS) ?
-                               autocvar_g_balance_nix_ammo_nails : 0;
-                       self.ammo_rockets = (nix_weapon_ammo & IT_ROCKETS) ?
-                               autocvar_g_balance_nix_ammo_rockets : 0;
-                       self.ammo_cells = (nix_weapon_ammo & IT_CELLS) ?
-                               autocvar_g_balance_nix_ammo_cells : 0;
-                       self.ammo_fuel = (nix_weapon_ammo & IT_FUEL) ?
-                               autocvar_g_balance_nix_ammo_fuel : 0;
+                       switch(e.current_ammo)
+                       {
+                               case ammo_shells:  self.ammo_shells  = autocvar_g_balance_nix_ammo_shells;  break;
+                               case ammo_nails:   self.ammo_nails   = autocvar_g_balance_nix_ammo_nails;   break;
+                               case ammo_rockets: self.ammo_rockets = autocvar_g_balance_nix_ammo_rockets; break;
+                               case ammo_cells:   self.ammo_cells   = autocvar_g_balance_nix_ammo_cells;   break;
+                               case ammo_fuel:    self.ammo_fuel    = autocvar_g_balance_nix_ammo_fuel;    break;
+                       }
                }
+
                self.nix_nextincr = time + autocvar_g_balance_nix_incrtime;
                if(dt >= 1 && dt <= 5)
                        self.nix_lastinfotime = -42;
@@ -101,8 +98,6 @@ void NIX_GiveCurrentWeapon()
                WEP_ACTION(nix_weapon, WR_RESETPLAYER);
 
                // all weapons must be fully loaded when we spawn
-               entity e;
-               e = get_weaponinfo(nix_weapon);
                if(e.spawnflags & WEP_FLAG_RELOADABLE) // prevent accessing undefined cvars
                        self.(weapon_load[nix_weapon]) = e.reloading_ammo;
 
@@ -113,6 +108,9 @@ void NIX_GiveCurrentWeapon()
                                self.vortex_chargepool_ammo = 1;
                        self.vortex_charge = WEP_CVAR(vortex, charge_start);
                }
+
+               // set last change info
+               self.nix_lastchange_id = nix_nextchange;
        }
        if(self.nix_lastinfotime != dt)
        {
@@ -123,16 +121,15 @@ void NIX_GiveCurrentWeapon()
 
        if(!(self.items & IT_UNLIMITED_WEAPON_AMMO) && time > self.nix_nextincr)
        {
-               if (nix_weapon_ammo & IT_SHELLS)
-                       self.ammo_shells = self.ammo_shells + autocvar_g_balance_nix_ammoincr_shells;
-               else if (nix_weapon_ammo & IT_NAILS)
-                       self.ammo_nails = self.ammo_nails + autocvar_g_balance_nix_ammoincr_nails;
-               else if (nix_weapon_ammo & IT_ROCKETS)
-                       self.ammo_rockets = self.ammo_rockets + autocvar_g_balance_nix_ammoincr_rockets;
-               else if (nix_weapon_ammo & IT_CELLS)
-                       self.ammo_cells = self.ammo_cells + autocvar_g_balance_nix_ammoincr_cells;
-               if (nix_weapon_ammo & IT_FUEL) // hook uses cells and fuel
-                       self.ammo_fuel = self.ammo_fuel + autocvar_g_balance_nix_ammoincr_fuel;
+               switch(e.current_ammo)
+               {
+                       case ammo_shells:  self.ammo_shells  += autocvar_g_balance_nix_ammoincr_shells;  break;
+                       case ammo_nails:   self.ammo_nails   += autocvar_g_balance_nix_ammoincr_nails;   break;
+                       case ammo_rockets: self.ammo_rockets += autocvar_g_balance_nix_ammoincr_rockets; break;
+                       case ammo_cells:   self.ammo_cells   += autocvar_g_balance_nix_ammoincr_cells;   break;
+                       case ammo_fuel:    self.ammo_fuel    += autocvar_g_balance_nix_ammoincr_fuel;    break;
+               }
+
                self.nix_nextincr = time + autocvar_g_balance_nix_incrtime;
        }
 
index 0b9165c8ce519971fc2a431d21bf7175f50c016e..c787d631aef012f66383118f02813cb437514458 100644 (file)
@@ -50,8 +50,6 @@ float have_pickup_item(void);
 #define ITEM_RESPAWNTIME_INITIAL(i) (ITEM_RESPAWN_TICKS + random() * ((i).respawntime + (i).respawntimejitter - ITEM_RESPAWN_TICKS))
        // range: 10 .. respawntime + respawntimejitter
 
-string Item_CounterFieldName(float it);
-
 .float max_armorvalue;
 .float pickup_anyway;