]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
refactor and fix FilterItem handling powerups
authordrjaska <drjaska83@gmail.com>
Thu, 18 Nov 2021 10:05:18 +0000 (12:05 +0200)
committerdrjaska <drjaska83@gmail.com>
Thu, 18 Nov 2021 10:05:18 +0000 (12:05 +0200)
I'd wish to add buff handling to the hookfunction but I don't know how

qcsrc/common/gamemodes/gamemode/mayhem/sv_mayhem.qc
qcsrc/common/gamemodes/gamemode/tmayhem/sv_tmayhem.qc

index b0c9774fa7959dd777d5277a2192f42c560b892b..2759f9bbec62859298fdd71552c16c221cfccc4d 100644 (file)
@@ -71,18 +71,20 @@ MUTATOR_HOOKFUNCTION(mayhem, SetWeaponArena)
 MUTATOR_HOOKFUNCTION(mayhem, FilterItem)
 {
        entity item = M_ARGV(0, entity);
-       if (autocvar_g_powerups == 1){
+       
+       //enable powerups if forced globally or global accepts gamemodes to have powerups according to their own settings
+       if (autocvar_g_powerups == 1 || (autocvar_g_powerups == -1 && autocvar_g_mayhem_powerups == 1)){
                if (item.itemdef.instanceOfPowerup){
                        return false;
                } 
        }
-       else if (autocvar_g_powerups == -1){
+       //disabled powerups if forced off globally or in this gamemode
+       if (autocvar_g_powerups == 0 || autocvar_g_mayhem_powerups == 0){
                if (item.itemdef.instanceOfPowerup){
-                       if (autocvar_g_mayhem_powerups){
-                               return false;
-                       } 
+                       return true; 
                } 
        }
+       //handle other items, remove unless globally forced on
        if (autocvar_g_pickup_items <= 0)
                return true;
 }
index a80b88f61beaece78a5d0decea68a8114816d369..f86384b5be0a4637fc8b30a553638a859b19b545 100644 (file)
@@ -111,18 +111,20 @@ MUTATOR_HOOKFUNCTION(tmayhem, SetWeaponArena)
 MUTATOR_HOOKFUNCTION(tmayhem, FilterItem)
 {
        entity item = M_ARGV(0, entity);
-       if (autocvar_g_powerups == 1){
+       
+       //enable powerups if forced globally or global accepts gamemodes to have powerups according to their own settings
+       if (autocvar_g_powerups == 1 || (autocvar_g_powerups == -1 && autocvar_g_tmayhem_powerups == 1)){
                if (item.itemdef.instanceOfPowerup){
                        return false;
                } 
        }
-       else if (autocvar_g_powerups == -1){
+       //disabled powerups if forced off globally or in this gamemode
+       if (autocvar_g_powerups == 0 || autocvar_g_tmayhem_powerups == 0){
                if (item.itemdef.instanceOfPowerup){
-                       if (autocvar_g_tmayhem_powerups){
-                               return false;
-                       } 
+                       return true; 
                } 
        }
+       //handle other items, remove unless globally forced on
        if (autocvar_g_pickup_items <= 0)
                return true;
 }