From cd8889d5abe6c13203361ad2a303c361979bb3fd Mon Sep 17 00:00:00 2001 From: drjaska Date: Wed, 24 Nov 2021 21:52:36 +0200 Subject: [PATCH] refined FilterItem and copied unlimited ammo option from CA/LMS/FT added cvars to remove items from mayhem or just weapons and ammo added cvars so mayhems can locally have unlimited ammo --- gamemodes-server.cfg | 4 ++++ .../gamemodes/gamemode/mayhem/sv_mayhem.qc | 22 +++++++++++++++++-- .../gamemodes/gamemode/tmayhem/sv_tmayhem.qc | 22 +++++++++++++++++-- 3 files changed, 44 insertions(+), 4 deletions(-) diff --git a/gamemodes-server.cfg b/gamemodes-server.cfg index 277ab31c4..4ad27e58f 100644 --- a/gamemodes-server.cfg +++ b/gamemodes-server.cfg @@ -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" diff --git a/qcsrc/common/gamemodes/gamemode/mayhem/sv_mayhem.qc b/qcsrc/common/gamemodes/gamemode/mayhem/sv_mayhem.qc index 2759f9bbe..6d8a06544 100644 --- a/qcsrc/common/gamemodes/gamemode/mayhem/sv_mayhem.qc +++ b/qcsrc/common/gamemodes/gamemode/mayhem/sv_mayhem.qc @@ -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) diff --git a/qcsrc/common/gamemodes/gamemode/tmayhem/sv_tmayhem.qc b/qcsrc/common/gamemodes/gamemode/tmayhem/sv_tmayhem.qc index f86384b5b..36db8b91c 100644 --- a/qcsrc/common/gamemodes/gamemode/tmayhem/sv_tmayhem.qc +++ b/qcsrc/common/gamemodes/gamemode/tmayhem/sv_tmayhem.qc @@ -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) -- 2.39.2