From 482cc25ce309d7fe635f520a4811b699dfdfcf69 Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 24 Nov 2024 01:45:04 +0000 Subject: [PATCH] Add an option to turn off replacing disabled buffs with an available type --- mutators.cfg | 1 + qcsrc/common/mutators/mutator/buffs/sv_buffs.qc | 14 +++++++++++++- qcsrc/common/mutators/mutator/buffs/sv_buffs.qh | 1 + 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/mutators.cfg b/mutators.cfg index 61e19ccb2..f2d477a16 100644 --- a/mutators.cfg +++ b/mutators.cfg @@ -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" diff --git a/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc b/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc index 0822d07cc..1ea676dd9 100644 --- a/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc +++ b/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc @@ -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; diff --git a/qcsrc/common/mutators/mutator/buffs/sv_buffs.qh b/qcsrc/common/mutators/mutator/buffs/sv_buffs.qh index c8281a003..838ac668e 100644 --- a/qcsrc/common/mutators/mutator/buffs/sv_buffs.qh +++ b/qcsrc/common/mutators/mutator/buffs/sv_buffs.qh @@ -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; -- 2.39.2