From 58e69d911c59e5ec6be504b1110cce3895967309 Mon Sep 17 00:00:00 2001 From: Lyberta Date: Sun, 8 Oct 2017 17:02:00 +0300 Subject: [PATCH] Random items: Cvar fixes. --- mutators.cfg | 104 +++++++++--------- .../mutator/random_items/sv_random_items.qc | 90 +++++++-------- 2 files changed, 98 insertions(+), 96 deletions(-) diff --git a/mutators.cfg b/mutators.cfg index e67735ea3..2597d518b 100644 --- a/mutators.cfg +++ b/mutators.cfg @@ -478,14 +478,14 @@ set g_dynamic_handicap_max 0 "The maximum value of the handicap." // random items // ============== set g_random_items 0 "Whether to enable random items." -set g_random_items_replace_health_small "random" "Classnames to replace small health with." -set g_random_items_replace_health_medium "random" "Classnames to replace medium health with." -set g_random_items_replace_health_big "random" "Classnames to replace big health with." -set g_random_items_replace_health_mega "random" "Classnames to replace mega health with." -set g_random_items_replace_armor_small "random" "Classnames to replace small armor with." -set g_random_items_replace_armor_medium "random" "Classnames to replace medium armor with." -set g_random_items_replace_armor_big "random" "Classnames to replace big armor with." -set g_random_items_replace_armor_mega "random" "Classnames to replace mega armor with." +set g_random_items_replace_item_health_small "random" "Classnames to replace small health with." +set g_random_items_replace_item_health_medium "random" "Classnames to replace medium health with." +set g_random_items_replace_item_health_big "random" "Classnames to replace big health with." +set g_random_items_replace_item_health_mega "random" "Classnames to replace mega health with." +set g_random_items_replace_item_armor_small "random" "Classnames to replace small armor with." +set g_random_items_replace_item_armor_medium "random" "Classnames to replace medium armor with." +set g_random_items_replace_item_armor_big "random" "Classnames to replace big armor with." +set g_random_items_replace_item_armor_mega "random" "Classnames to replace mega armor with." set g_random_items_replace_item_shells "random" "Classnames to replace shells with." set g_random_items_replace_item_bullets "random" "Classnames to replace bullets with." set g_random_items_replace_item_rockets "random" "Classnames to replace rockets with." @@ -527,20 +527,20 @@ set g_random_items_armor_probability 1 "Probability of random armor items spawni set g_random_items_resource_probability 1 "Probability of random resource items spawning in the map." set g_random_items_weapon_probability 1 "Probability of random weapons spawning in the map." set g_random_items_powerup_probability 0.15 "Probability of random powerups spawning in the map." -set g_random_items_health_small_probability 10 "Probability of random small health spawning in the map." -set g_random_items_health_medium_probability 4 "Probability of random medium health spawning in the map." -set g_random_items_health_big_probability 2 "Probability of random big health spawning in the map." -set g_random_items_health_mega_probability 1 "Probability of random mega health spawning in the map." -set g_random_items_armor_small_probability 10 "Probability of random small armor spawning in the map." -set g_random_items_armor_medium_probability 4 "Probability of random medium armor spawning in the map." -set g_random_items_armor_big_probability 2 "Probability of random big armor spawning in the map." -set g_random_items_armor_mega_probability 1 "Probability of random mega armor spawning in the map." -set g_random_items_resource_shells_probability 1 "Probability of random shells spawning in the map." -set g_random_items_resource_bullets_probability 1 "Probability of random bullets spawning in the map." -set g_random_items_resource_rockets_probability 1 "Probability of random rockets spawning in the map." -set g_random_items_resource_cells_probability 1 "Probability of random cells spawning in the map." -set g_random_items_resource_plasma_probability 0 "Probability of random plasma spawning in the map." -set g_random_items_resource_fuel_probability 0 "Probability of random fuel spawning in the map." +set g_random_items_item_health_small_probability 10 "Probability of random small health spawning in the map." +set g_random_items_item_health_medium_probability 4 "Probability of random medium health spawning in the map." +set g_random_items_item_health_big_probability 2 "Probability of random big health spawning in the map." +set g_random_items_item_health_mega_probability 1 "Probability of random mega health spawning in the map." +set g_random_items_item_armor_small_probability 10 "Probability of random small armor spawning in the map." +set g_random_items_item_armor_medium_probability 4 "Probability of random medium armor spawning in the map." +set g_random_items_item_armor_big_probability 2 "Probability of random big armor spawning in the map." +set g_random_items_item_armor_mega_probability 1 "Probability of random mega armor spawning in the map." +set g_random_items_item_shells_probability 1 "Probability of random shells spawning in the map." +set g_random_items_item_bullets_probability 1 "Probability of random bullets spawning in the map." +set g_random_items_item_rockets_probability 1 "Probability of random rockets spawning in the map." +set g_random_items_item_cells_probability 1 "Probability of random cells spawning in the map." +set g_random_items_item_plasma_probability 0 "Probability of random plasma spawning in the map." +set g_random_items_item_fuel_probability 0 "Probability of random fuel spawning in the map." set g_random_items_weapon_blaster_probability 0 "Probability of random blaster spawning in the map." set g_random_items_weapon_shotgun_probability 0 "Probability of random shotgun spawning in the map." set g_random_items_weapon_machinegun_probability 1 "Probability of random machinegun spawning in the map." @@ -561,14 +561,14 @@ set g_random_items_weapon_hlac_probability 0 "Probability of random HLAC spawnin set g_random_items_weapon_rifle_probability 0 "Probability of random rifle spawning in the map." set g_random_items_weapon_seeker_probability 0 "Probability of random TAG seeker spawning in the map." set g_random_items_weapon_vaporizer_probability 0 "Probability of random vaporizer spawning in the map." -set g_random_items_strength_probability 1 "Probability of random strength spawning in the map." -set g_random_items_shield_probability 1 "Probability of random shield spawning in the map." -set g_random_items_fuel_regen_probability 0 "Probability of random fuel regeneration spawning in the map." -set g_random_items_jetpack_probability 0 "Probability of random jetpack spawning in the map." -set g_random_items_vaporizer_cells_probability 20 "Probability of random vaporizer cells spawning in the map." -set g_random_items_invisibility_probability 1 "Probability of random invisibility spawning in the map." -set g_random_items_extralife_probability 1 "Probability of random extra life spawning in the map." -set g_random_items_speed_probability 1 "Probability of random speed spawning in the map." +set g_random_items_item_strength_probability 1 "Probability of random strength spawning in the map." +set g_random_items_item_shield_probability 1 "Probability of random shield spawning in the map." +set g_random_items_item_fuel_regen_probability 0 "Probability of random fuel regeneration spawning in the map." +set g_random_items_item_jetpack_probability 0 "Probability of random jetpack spawning in the map." +set g_random_items_item_vaporizer_cells_probability 20 "Probability of random vaporizer cells spawning in the map." +set g_random_items_item_invisibility_probability 1 "Probability of random invisibility spawning in the map." +set g_random_items_item_extralife_probability 1 "Probability of random extra life spawning in the map." +set g_random_items_item_speed_probability 1 "Probability of random speed spawning in the map." set g_random_items_overkill_health_mega_probability 1 "Probability of random mega health spawning in the map during overkill." set g_random_items_overkill_armor_small_probability 10 "Probability of random small armor spawning in the map during overkill." set g_random_items_overkill_armor_medium_probability 4 "Probability of random medium armor spawning in the map during overkill." @@ -586,20 +586,20 @@ set g_random_loot_armor_probability 1 "Probability of random armor items spawnin set g_random_loot_resource_probability 1 "Probability of random ammo items spawning as loot." set g_random_loot_weapon_probability 1 "Probability of random weapons spawning as loot." set g_random_loot_powerup_probability 0.2 "Probability of random powerups spawning as loot." -set g_random_loot_health_small_probability 4 "Probability of random small health spawning as loot." -set g_random_loot_health_medium_probability 3 "Probability of random medium health spawning as loot." -set g_random_loot_health_big_probability 2 "Probability of random big health spawning as loot." -set g_random_loot_health_mega_probability 1 "Probability of random mega health spawning as loot." -set g_random_loot_armor_small_probability 4 "Probability of random small armor spawning as loot." -set g_random_loot_armor_medium_probability 3 "Probability of random medium armor spawning as loot." -set g_random_loot_armor_big_probability 2 "Probability of random big armor spawning as loot." -set g_random_loot_armor_mega_probability 1 "Probability of random mega armor spawning as loot." -set g_random_loot_resource_shells_probability 1 "Probability of random shells spawning as loot." -set g_random_loot_resource_bullets_probability 1 "Probability of random bullets spawning as loot." -set g_random_loot_resource_rockets_probability 1 "Probability of random rockets spawning as loot." -set g_random_loot_resource_cells_probability 1 "Probability of random cells spawning as loot." -set g_random_loot_resource_plasma_probability 0 "Probability of random plasma spawning as loot." -set g_random_loot_resource_fuel_probability 0 "Probability of random fuel spawning as loot." +set g_random_loot_item_health_small_probability 4 "Probability of random small health spawning as loot." +set g_random_loot_item_health_medium_probability 3 "Probability of random medium health spawning as loot." +set g_random_loot_item_health_big_probability 2 "Probability of random big health spawning as loot." +set g_random_loot_item_health_mega_probability 1 "Probability of random mega health spawning as loot." +set g_random_loot_item_armor_small_probability 4 "Probability of random small armor spawning as loot." +set g_random_loot_item_armor_medium_probability 3 "Probability of random medium armor spawning as loot." +set g_random_loot_item_armor_big_probability 2 "Probability of random big armor spawning as loot." +set g_random_loot_item_armor_mega_probability 1 "Probability of random mega armor spawning as loot." +set g_random_loot_item_shells_probability 1 "Probability of random shells spawning as loot." +set g_random_loot_item_bullets_probability 1 "Probability of random bullets spawning as loot." +set g_random_loot_item_rockets_probability 1 "Probability of random rockets spawning as loot." +set g_random_loot_item_cells_probability 1 "Probability of random cells spawning as loot." +set g_random_loot_item_plasma_probability 0 "Probability of random plasma spawning as loot." +set g_random_loot_item_fuel_probability 0 "Probability of random fuel spawning as loot." set g_random_loot_weapon_blaster_probability 0 "Probability of random blaster spawning as loot." set g_random_loot_weapon_shotgun_probability 0 "Probability of random shotgun spawning as loot." set g_random_loot_weapon_machinegun_probability 1 "Probability of random machinegun spawning as loot." @@ -620,14 +620,14 @@ set g_random_loot_weapon_hlac_probability 0 "Probability of random HLAC spawning set g_random_loot_weapon_rifle_probability 0 "Probability of random rifle spawning as loot." set g_random_loot_weapon_seeker_probability 0 "Probability of random TAG seeker spawning as loot." set g_random_loot_weapon_vaporizer_probability 0 "Probability of random vaporizer spawning as loot." -set g_random_loot_strength_probability 1 "Probability of random strength spawning as loot." -set g_random_loot_shield_probability 1 "Probability of random shield spawning as loot." -set g_random_loot_fuel_regen_probability 0 "Probability of random fuel regeneration spawning as loot." -set g_random_loot_jetpack_probability 0 "Probability of random jetpack spawning as loot." -set g_random_loot_vaporizer_cells_probability 20 "Probability of random vaporizer cells spawning as loot." -set g_random_loot_invisibility_probability 1 "Probability of random invisibility spawning as loot." -set g_random_loot_extralife_probability 1 "Probability of random extra life spawning as loot." -set g_random_loot_speed_probability 1 "Probability of random speed spawning as loot." +set g_random_loot_item_strength_probability 1 "Probability of random strength spawning as loot." +set g_random_loot_item_shield_probability 1 "Probability of random shield spawning as loot." +set g_random_loot_item_fuel_regen_probability 0 "Probability of random fuel regeneration spawning as loot." +set g_random_loot_item_jetpack_probability 0 "Probability of random jetpack spawning as loot." +set g_random_loot_item_vaporizer_cells_probability 20 "Probability of random vaporizer cells spawning as loot." +set g_random_loot_item_invisibility_probability 1 "Probability of random invisibility spawning as loot." +set g_random_loot_item_extralife_probability 1 "Probability of random extra life spawning as loot." +set g_random_loot_item_speed_probability 1 "Probability of random speed spawning as loot." set g_random_loot_overkill_health_mega_probability 1 "Probability of random mega health spawning as loot during overkill." set g_random_loot_overkill_armor_small_probability 10 "Probability of random small armor spawning as loot during overkill." set g_random_loot_overkill_armor_medium_probability 4 "Probability of random medium armor spawning as loot during overkill." diff --git a/qcsrc/common/mutators/mutator/random_items/sv_random_items.qc b/qcsrc/common/mutators/mutator/random_items/sv_random_items.qc index 2665bd4e1..32f4e6b53 100644 --- a/qcsrc/common/mutators/mutator/random_items/sv_random_items.qc +++ b/qcsrc/common/mutators/mutator/random_items/sv_random_items.qc @@ -94,32 +94,32 @@ string RandomItems_GetItemVarName(string class_name) { #define X(classname, var) case #classname: return #var #define XCOND(classname, var, expr) case #classname: if (expr) return #var; else break - X(item_health_small, health_small); - X(item_health_medium, health_medium); - X(item_health_big, health_big); - XCOND(item_health_mega, health_mega, !is_ok || !autocvar_g_overkill_filter_healthmega); - - X(item_armor_small, armor_small); - XCOND(item_armor_medium, armor_medium, !is_ok || !autocvar_g_overkill_filter_armormedium); - XCOND(item_armor_big, armor_big, !is_ok || !autocvar_g_overkill_filter_armorbig); - XCOND(item_armor_mega, armor_mega, !is_ok || !autocvar_g_overkill_filter_armormega); - - X(item_shells, resource_shells); - X(item_bullets, resource_bullets); - X(item_rockets, resource_rockets); - X(item_cells, resource_cells); - X(item_plasma, resource_plasma); - X(item_fuel, resource_fuel); - - X(item_strength, strength); - X(item_invincible, shield); - X(item_fuel_regen, fuel_regen); - X(item_jetpack, jetpack); - - X(item_vaporizer_cells, vaporizer_cells); - X(item_invisibility, invisibility); - X(item_extralife, extralife); - X(item_speed, speed); + X(item_health_small, item_health_small); + X(item_health_medium, item_health_medium); + X(item_health_big, item_health_big); + XCOND(item_health_mega, item_health_mega, !is_ok || !autocvar_g_overkill_filter_healthmega); + + X(item_armor_small, item_armor_small); + XCOND(item_armor_medium, item_armor_medium, !is_ok || !autocvar_g_overkill_filter_armormedium); + XCOND(item_armor_big, item_armor_big, !is_ok || !autocvar_g_overkill_filter_armorbig); + XCOND(item_armor_mega, item_armor_mega, !is_ok || !autocvar_g_overkill_filter_armormega); + + X(item_shells, item_shells); + X(item_bullets, item_bullets); + X(item_rockets, item_rockets); + X(item_cells, item_cells); + X(item_plasma, item_plasma); + X(item_fuel, item_fuel); + + X(item_strength, item_strength); + X(item_invincible, item_shield); + X(item_fuel_regen, item_fuel_regen); + X(item_jetpack, item_jetpack); + + X(item_vaporizer_cells, item_vaporizer_cells); + X(item_invisibility, item_invisibility); + X(item_extralife, item_extralife); + X(item_speed, item_speed); #undef X #undef XCOND @@ -270,16 +270,17 @@ string RandomItems_GetRandomMapItemClassName() case RANDOM_ITEM_TYPE_WEAPON: { RandomSelection_Init(); - #define X(classname) \ - RandomSelection_AddString( \ - classname, \ - cvar(sprintf("g_random_items_%s_probability", RandomItems_GetItemVarName(classname))), \ - 1 \ - ) - FOREACH(Weapons, !(it.spawnflags & WEP_FLAG_MUTATORBLOCKED), { - X(sprintf("weapon_%s", it.netname)); + FOREACH(Weapons, !(it.spawnflags & WEP_FLAG_MUTATORBLOCKED), + { + string class_name = strcat("weapon_", it.netname); + string cvar_name = sprintf( + "g_random_items_%s_probability", class_name); + if (!(cvar_type(cvar_name) & CVAR_TYPEFLAG_EXISTS)) + { + continue; + } + RandomSelection_AddString(class_name, cvar(cvar_name), 1); }); - #undef X return RandomSelection_chosen_string; } case RANDOM_ITEM_TYPE_POWERUP: @@ -485,16 +486,17 @@ string RandomItems_GetRandomLootItemClassName() case RANDOM_ITEM_TYPE_WEAPON: { RandomSelection_Init(); - #define X(classname) \ - RandomSelection_AddString( \ - classname, \ - cvar(sprintf("g_random_loot_%s_probability", RandomItems_GetItemVarName(classname))), \ - 1 \ - ) - FOREACH(Weapons, !(it.spawnflags & WEP_FLAG_MUTATORBLOCKED), { - X(sprintf("weapon_%s", it.netname)); + FOREACH(Weapons, !(it.spawnflags & WEP_FLAG_MUTATORBLOCKED), + { + string class_name = strcat("weapon_", it.netname); + string cvar_name = sprintf( + "g_random_loot_%s_probability", class_name); + if (!(cvar_type(cvar_name) & CVAR_TYPEFLAG_EXISTS)) + { + continue; + } + RandomSelection_AddString(class_name, cvar(cvar_name), 1); }); - #undef X return RandomSelection_chosen_string; } case RANDOM_ITEM_TYPE_POWERUP: -- 2.39.2