]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
refined FilterItem and copied unlimited ammo option from CA/LMS/FT
authordrjaska <drjaska83@gmail.com>
Wed, 24 Nov 2021 19:52:36 +0000 (21:52 +0200)
committerdrjaska <drjaska83@gmail.com>
Wed, 24 Nov 2021 19:52:36 +0000 (21:52 +0200)
added cvars to remove items from mayhem or just weapons and ammo
added cvars so mayhems can locally have unlimited ammo

gamemodes-server.cfg
qcsrc/common/gamemodes/gamemode/mayhem/sv_mayhem.qc
qcsrc/common/gamemodes/gamemode/tmayhem/sv_tmayhem.qc

index 277ab31c46f43eb465c801afcacaa76117cf7ce3..4ad27e58f221d4f3a5be2b5ab907dcee6afabc59 100644 (file)
@@ -600,6 +600,10 @@ set g_tmayhem_weaponarena "most_available" "starting weapons - takes the same op
 
 set g_mayhem_powerups 1 "Allow powerups in mayhem. Only checked if g_powerups is -1 therefore this will be overridden by g_powerups 1 or 0"
 set g_tmayhem_powerups 1 "Allow powerups in team mayhem. Only checked if g_powerups is -1 therefore this will be overridden by g_powerups 1 or 0"
+set g_mayhem_pickup_items 0 "spawn pickup items in mayhem"
+set g_tmayhem_pickup_items 0 "spawn pickup items in team mayhem"
+set g_mayhem_pickup_items_remove_weapons_and_ammo 1 "when pickup items are enabled in mayhem still remove weapons and ammo pickups"
+set g_tmayhem_pickup_items_remove_weapons_and_ammo 1 "when pickup items are enabled in team mayhem still remove weapons and ammo pickups"
 
 set g_mayhem_selfdamage 0 "0 = disable selfdamage in mayhem, 1 = enable selfdamage in mayhem"
 set g_tmayhem_selfdamage 0 "0 = disable selfdamage in tmayhem, 1 = enable selfdamage in tmayhem"
index 2759f9bbec62859298fdd71552c16c221cfccc4d..6d8a06544b3ec90ca00b2550d32c752fbb10a9c8 100644 (file)
@@ -5,6 +5,9 @@ string autocvar_g_mayhem_weaponarena;
 bool autocvar_g_mayhem_powerups;
 bool autocvar_g_mayhem_selfdamage;
 int autocvar_g_mayhem_scoringmethod;
+bool autocvar_g_mayhem_pickup_items;
+bool autocvar_g_mayhem_pickup_items_remove_weapons_and_ammo;
+bool autocvar_g_mayhem_unlimited_ammo;
 
 float autocvar_g_mayhem_start_health = 200;
 float autocvar_g_mayhem_start_armor = 200;
@@ -39,6 +42,9 @@ MUTATOR_HOOKFUNCTION(mayhem, Scores_CountFragsRemaining)
 MUTATOR_HOOKFUNCTION(mayhem, SetStartItems)
 {
        start_items       &= ~(IT_UNLIMITED_AMMO | IT_UNLIMITED_SUPERWEAPONS);
+       if(!cvar("g_use_ammunition") || autocvar_g_mayhem_unlimited_ammo)
+               start_items |= IT_UNLIMITED_AMMO;
+
        start_health       = warmup_start_health       = autocvar_g_mayhem_start_health;
        start_armorvalue   = warmup_start_armorvalue   = autocvar_g_mayhem_start_armor;
        start_ammo_shells  = warmup_start_ammo_shells  = autocvar_g_mayhem_start_ammo_shells;
@@ -84,9 +90,21 @@ MUTATOR_HOOKFUNCTION(mayhem, FilterItem)
                        return true; 
                } 
        }
-       //handle other items, remove unless globally forced on
-       if (autocvar_g_pickup_items <= 0)
+       //remove all items if items are forced off globally
+       if (autocvar_g_pickup_items == 0){
                return true;
+       }
+       //if items are switched on in this gamemode allow the removal of weapons and ammo still
+       if ((autocvar_g_mayhem_pickup_items == 1 && autocvar_g_mayhem_pickup_items_remove_weapons_and_ammo == 1) && autocvar_g_pickup_items <= 0){
+               if (item.itemdef.instanceOfAmmo || item.itemdef.instanceOfWeaponPickup){
+                       return true;
+               }
+       }
+       //remove items if not globally set to follow mode's settings and locally set off
+       if (autocvar_g_pickup_items == -1 && autocvar_g_mayhem_pickup_items == 0){
+               return true;
+       }
+       return false;
 }
 
 MUTATOR_HOOKFUNCTION(mayhem, Damage_Calculate)
index f86384b5be0a4637fc8b30a553638a859b19b545..36db8b91c1cb2a73cf362005f4ff3ec5824e63c4 100644 (file)
@@ -9,6 +9,9 @@ string autocvar_g_tmayhem_weaponarena;
 bool autocvar_g_tmayhem_powerups;
 bool autocvar_g_tmayhem_selfdamage;
 int autocvar_g_tmayhem_scoringmethod;
+bool autocvar_g_tmayhem_pickup_items;
+bool autocvar_g_tmayhem_pickup_items_remove_weapons_and_ammo;
+bool autocvar_g_tmayhem_unlimited_ammo;
 
 float autocvar_g_tmayhem_start_health = 200;
 float autocvar_g_tmayhem_start_armor = 200;
@@ -79,6 +82,9 @@ MUTATOR_HOOKFUNCTION(tmayhem, Scores_CountFragsRemaining)
 MUTATOR_HOOKFUNCTION(tmayhem, SetStartItems)
 {
        start_items       &= ~(IT_UNLIMITED_AMMO | IT_UNLIMITED_SUPERWEAPONS);
+       if(!cvar("g_use_ammunition") || autocvar_g_tmayhem_unlimited_ammo)
+               start_items |= IT_UNLIMITED_AMMO;
+
        start_health       = warmup_start_health       = autocvar_g_tmayhem_start_health;
        start_armorvalue   = warmup_start_armorvalue   = autocvar_g_tmayhem_start_armor;
        start_ammo_shells  = warmup_start_ammo_shells  = autocvar_g_tmayhem_start_ammo_shells;
@@ -124,9 +130,21 @@ MUTATOR_HOOKFUNCTION(tmayhem, FilterItem)
                        return true; 
                } 
        }
-       //handle other items, remove unless globally forced on
-       if (autocvar_g_pickup_items <= 0)
+       //remove all items if items are forced off globally
+       if (autocvar_g_pickup_items == 0){
                return true;
+       }
+       //if items are switched on in this gamemode allow the removal of weapons and ammo still
+       if ((autocvar_g_tmayhem_pickup_items == 1 && autocvar_g_tmayhem_pickup_items_remove_weapons_and_ammo == 1) && autocvar_g_pickup_items <= 0){
+               if (item.itemdef.instanceOfAmmo || item.itemdef.instanceOfWeaponPickup){
+                       return true;
+               }
+       }
+       //remove items if not globally set to follow mode's settings and locally set off
+       if (autocvar_g_pickup_items == -1 && autocvar_g_tmayhem_pickup_items == 0){
+               return true;
+       }
+       return false;
 }
 
 MUTATOR_HOOKFUNCTION(tmayhem, Damage_Calculate)