]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/t_items.qc
Experimental 'available' mode for weaponarena, includes spawn weapons and falls back...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / t_items.qc
index 9edea4fb698cc3aaece7449bbb2d47e9c96f25f9..8573e4af0f9ba26f37e19ed7d84fb81f552ce3eb 100644 (file)
@@ -743,17 +743,16 @@ bool Item_GiveAmmoTo(entity item, entity player, int res_type, float ammomax)
        if (item.spawnshieldtime)
        {
                if ((player_amount >= ammomax) && (item.pickup_anyway <= 0))
-               {
                        return false;
-               }
-               GiveOrTakeResourceWithLimit(player, res_type, amount, ammomax);
-               return true;
        }
-       if (g_weapon_stay != 2)
-       {
+       else if (g_weapon_stay == 2)
+               ammomax = min(amount, ammomax);
+       else
                return false;
-       }
-       GiveOrTakeResourceWithLimit(player, res_type, amount, min(amount, ammomax));
+       if (amount < 0)
+               TakeResourceWithLimit(player, res_type, -amount, ammomax);
+       else
+               GiveResourceWithLimit(player, res_type, amount, ammomax);
        return true;
 }
 
@@ -781,14 +780,14 @@ bool Item_GiveTo(entity item, entity player)
                }
        }
        bool pickedup = false;
-       pickedup = pickedup || Item_GiveAmmoTo(item, player, RES_HEALTH, item.max_health);
-       pickedup = pickedup || Item_GiveAmmoTo(item, player, RES_ARMOR, item.max_armorvalue);
-       pickedup = pickedup || Item_GiveAmmoTo(item, player, RES_SHELLS, g_pickup_shells_max);
-       pickedup = pickedup || Item_GiveAmmoTo(item, player, RES_BULLETS, g_pickup_nails_max);
-       pickedup = pickedup || Item_GiveAmmoTo(item, player, RES_ROCKETS, g_pickup_rockets_max);
-       pickedup = pickedup || Item_GiveAmmoTo(item, player, RES_CELLS, g_pickup_cells_max);
-       pickedup = pickedup || Item_GiveAmmoTo(item, player, RES_PLASMA, g_pickup_plasma_max);
-       pickedup = pickedup || Item_GiveAmmoTo(item, player, RES_FUEL, g_pickup_fuel_max);
+       pickedup = (pickedup || Item_GiveAmmoTo(item, player, RES_HEALTH, item.max_health));
+       pickedup = (pickedup || Item_GiveAmmoTo(item, player, RES_ARMOR, item.max_armorvalue));
+       pickedup = (pickedup || Item_GiveAmmoTo(item, player, RES_SHELLS, g_pickup_shells_max));
+       pickedup = (pickedup || Item_GiveAmmoTo(item, player, RES_BULLETS, g_pickup_nails_max));
+       pickedup = (pickedup || Item_GiveAmmoTo(item, player, RES_ROCKETS, g_pickup_rockets_max));
+       pickedup = (pickedup || Item_GiveAmmoTo(item, player, RES_CELLS, g_pickup_cells_max));
+       pickedup = (pickedup || Item_GiveAmmoTo(item, player, RES_PLASMA, g_pickup_plasma_max));
+       pickedup = (pickedup || Item_GiveAmmoTo(item, player, RES_FUEL, g_pickup_fuel_max));
        if (item.itemdef.instanceOfWeaponPickup)
        {
                WepSet w;
@@ -1216,6 +1215,9 @@ void _StartItem(entity this, entity def, float defaultrespawntime, float default
                return;
        }
 
+       precache_model(this.model);
+       precache_sound(this.item_pickupsound);
+
        if (Item_IsLoot(this))
        {
                this.reset = SUB_Remove;
@@ -1247,6 +1249,8 @@ void _StartItem(entity this, entity def, float defaultrespawntime, float default
        {
                if(!have_pickup_item(this))
                {
+                       if(g_weaponarena == 2 && weaponid)
+                               weaponsInMap |= WepSet_FromWeapon(Weapons_from(weaponid));
                        startitem_failed = true;
                        delete(this);
                        return;
@@ -1307,9 +1311,6 @@ void _StartItem(entity this, entity def, float defaultrespawntime, float default
 
                weaponsInMap |= WepSet_FromWeapon(Weapons_from(weaponid));
 
-               precache_model(this.model);
-               precache_sound(this.item_pickupsound);
-
                if (   def.instanceOfPowerup
                        || def.instanceOfWeaponPickup
                        || (def.instanceOfHealth && def != ITEM_HealthSmall)
@@ -1341,12 +1342,13 @@ void _StartItem(entity this, entity def, float defaultrespawntime, float default
                        this.ItemStatus |= ITS_ANIMATE2;
        }
 
+       if(Item_IsLoot(this))
+               this.gravity = 1;
+
        if(def.instanceOfWeaponPickup)
        {
                if (!Item_IsLoot(this)) // if dropped, colormap is already set up nicely
                        this.colormap = 1024; // color shirt=0 pants=0 grey
-               else
-                       this.gravity = 1;
                if (!(this.spawnflags & 1024))
                        this.ItemStatus |= ITS_ANIMATE1;
                this.SendFlags |= ISF_COLORMAP;
@@ -1858,7 +1860,7 @@ float GiveItems(entity e, float beginarg, float endarg)
        POSTGIVE_RES_ROT(e, RES_HEALTH, 1, pauserothealth_finished, autocvar_g_balance_pause_health_rot, pauseregen_finished, autocvar_g_balance_pause_health_regen, SND_MEGAHEALTH, SND_Null);
 
        if(e.superweapons_finished <= 0)
-               if(STAT(WEAPONS, e) & WEPSET_SUPERWEAPONS)
+               if(!g_weaponarena && (STAT(WEAPONS, e) & WEPSET_SUPERWEAPONS))
                        e.superweapons_finished = autocvar_g_balance_superweapons_time;
 
        if(e.strength_finished <= 0)