]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Random items: Better weapon handling.
authorLyberta <lyberta@lyberta.net>
Mon, 16 Oct 2017 14:11:30 +0000 (17:11 +0300)
committerLyberta <lyberta@lyberta.net>
Mon, 16 Oct 2017 14:11:30 +0000 (17:11 +0300)
qcsrc/common/mutators/mutator/random_items/sv_random_items.qc

index eb3696c335aa557f008e6e66a989b7c56a337f8c..b0c49d64d959d82343167a77c5c2ec52a5c0197f 100644 (file)
@@ -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;
                }