]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add an option to turn off replacing disabled buffs with an available type
authorMario <mario.mario@y7mail.com>
Sun, 24 Nov 2024 01:45:04 +0000 (01:45 +0000)
committerDr. Jaska <drjaska83@gmail.com>
Sun, 24 Nov 2024 01:45:04 +0000 (01:45 +0000)
mutators.cfg
qcsrc/common/mutators/mutator/buffs/sv_buffs.qc
qcsrc/common/mutators/mutator/buffs/sv_buffs.qh

index 61e19ccb2bf60d8760d8b55d489136e65a4464c8..f2d477a16c373260bff7c81405f250e14313a8ee 100644 (file)
@@ -345,6 +345,7 @@ set g_buffs_random_location 0 "randomize buff location on start and when reset"
 set g_buffs_random_location_attempts 10 "number of random locations a single buff will attempt to respawn at before giving up"
 set g_buffs_spawn_count 0 "how many buffs to spawn on the map if none exist already"
 set g_buffs_replace_powerups 0 "replace powerups on the map with random buffs"
+set g_buffs_replace_available 1 "if a buff type is disabled replace it with another buff type, with this option disabled the buff will be deleted instead"
 set g_buffs_drop 0 "allow dropping buffs"
 set g_buffs_cooldown_activate 5 "cooldown period when buff is first activated"
 set g_buffs_cooldown_respawn 3 "cooldown period when buff is reloading"
index 0822d07cce3451f4d2899a2b563b614f51faefd3..1ea676dd9424ada8aca007b7b6a0f4052dcc60e9 100644 (file)
@@ -425,8 +425,20 @@ void buff_Init(entity this)
 
        entity buff = this.buffdef;
 
-       if(!buff || !buff_Available(buff))
+       // item_buff_random provides a null type so force randomization in that case
+       // otherwise replace the buff type if it's unavailable and the option is enabled
+       if(!buff || (autocvar_g_buffs_replace_available && !buff_Available(buff)))
+       {
                buff_NewType(this);
+               buff = this.buffdef;
+       }
+
+       // the buff type is still invalid or unavailable, simply delete the item
+       if(!buff || !buff_Available(buff))
+       {
+               delete(this);
+               return;
+       }
 
        this.classname = "item_buff";
        this.solid = SOLID_TRIGGER;
index c8281a003372bf8f909df8632c8e3f0d9323e6ee..838ac668ee7c88ad0f23a627f2207483eb3bc7fe 100644 (file)
@@ -27,6 +27,7 @@ bool autocvar_g_buffs_random_location;
 int autocvar_g_buffs_random_location_attempts;
 int autocvar_g_buffs_spawn_count;
 bool autocvar_g_buffs_replace_powerups;
+bool autocvar_g_buffs_replace_available = true;
 bool autocvar_g_buffs_drop = false;
 float autocvar_g_buffs_cooldown_activate;
 float autocvar_g_buffs_cooldown_respawn;