From b74fbfd642f74f8c7af43540d46eaba430de48a1 Mon Sep 17 00:00:00 2001 From: Lyberta Date: Mon, 16 Oct 2017 17:11:30 +0300 Subject: [PATCH] Random items: Better weapon handling. --- .../mutator/random_items/sv_random_items.qc | 25 ++++++++----------- 1 file changed, 10 insertions(+), 15 deletions(-) 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 eb3696c33..b0c49d64d 100644 --- a/qcsrc/common/mutators/mutator/random_items/sv_random_items.qc +++ b/qcsrc/common/mutators/mutator/random_items/sv_random_items.qc @@ -250,15 +250,13 @@ string RandomItems_GetRandomMapItemClassName() case RANDOM_ITEM_TYPE_WEAPON: { RandomSelection_Init(); - FOREACH(Weapons, !(it.spawnflags & WEP_FLAG_MUTATORBLOCKED), + FOREACH(Weapons, it != WEP_Null && + !(it.spawnflags & WEP_FLAG_MUTATORBLOCKED), { string cvar_name = sprintf("g_random_items_%s_probability", it.m_canonical_spawnfunc); - if (!(cvar_type(cvar_name) & CVAR_TYPEFLAG_EXISTS)) - { - continue; - } - RandomSelection_AddString(it.m_canonical_spawnfunc, cvar(cvar_name), 1); + RandomSelection_AddString(it.m_canonical_spawnfunc, + cvar(cvar_name), 1); }); return RandomSelection_chosen_string; } @@ -462,16 +460,13 @@ string RandomItems_GetRandomLootItemClassName() case RANDOM_ITEM_TYPE_WEAPON: { RandomSelection_Init(); - FOREACH(Weapons, !(it.spawnflags & WEP_FLAG_MUTATORBLOCKED), + FOREACH(Weapons, it != WEP_Null && + !(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); + string cvar_name = sprintf("g_random_loot_%s_probability", + it.m_canonical_spawnfunc); + RandomSelection_AddString(it.m_canonical_spawnfunc, + cvar(cvar_name), 1); }); return RandomSelection_chosen_string; } -- 2.39.2