]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/mutators/mutator/new_toys/sv_new_toys.qc
Fixed random items check in new toys.
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / mutators / mutator / new_toys / sv_new_toys.qc
index 6c0647b1e62f40f9c0719df49b42f1cdd5d238be..540edc69d9c6578c7ef4277a9f35b1a2f37cfb4b 100644 (file)
@@ -1,5 +1,7 @@
 #include "sv_new_toys.qh"
 
+#include "../random_items/sv_random_items.qh"
+
 /*
 
 CORE    laser   vortex     lg      rl      cry     gl      elec    hagar   fireb   hook
@@ -68,9 +70,11 @@ roflsound "New toys, new toys!" sound.
 
 */
 
+//string autocvar_g_new_toys;
+
 bool nt_IsNewToy(int w);
 
-REGISTER_MUTATOR(nt, cvar("g_new_toys") && !cvar("g_instagib") && !cvar("g_overkill"))
+REGISTER_MUTATOR(nt, expr_evaluate(cvar_string("g_new_toys")) && !MUTATOR_IS_ENABLED(mutator_instagib) && !MUTATOR_IS_ENABLED(ok))
 {
        MUTATOR_ONADD
        {
@@ -78,23 +82,23 @@ REGISTER_MUTATOR(nt, cvar("g_new_toys") && !cvar("g_instagib") && !cvar("g_overk
                        error("This cannot be added at runtime\n");
 
                // mark the guns as ok to use by e.g. impulse 99
-               FOREACH(Weapons, it != WEP_Null, LAMBDA(
+               FOREACH(Weapons, it != WEP_Null, {
                        if(nt_IsNewToy(it.m_id))
                                it.spawnflags &= ~WEP_FLAG_MUTATORBLOCKED;
-               ));
+               });
        }
 
        MUTATOR_ONROLLBACK_OR_REMOVE
        {
-               FOREACH(Weapons, it != WEP_Null, LAMBDA(
+               FOREACH(Weapons, it != WEP_Null, {
                        if(nt_IsNewToy(it.m_id))
                                it.spawnflags |= WEP_FLAG_MUTATORBLOCKED;
-               ));
+               });
        }
 
        MUTATOR_ONREMOVE
        {
-               LOG_INFO("This cannot be removed at runtime\n");
+               LOG_INFO("This cannot be removed at runtime");
                return -1;
        }
 
@@ -109,11 +113,6 @@ const float NT_AUTOREPLACE_NEVER = 0;
 const float NT_AUTOREPLACE_ALWAYS = 1;
 const float NT_AUTOREPLACE_RANDOM = 2;
 
-MUTATOR_HOOKFUNCTION(nt, SetModname)
-{
-       M_ARGV(0, string) = "NewToys";
-}
-
 bool nt_IsNewToy(int w)
 {
        switch(w)
@@ -170,20 +169,20 @@ MUTATOR_HOOKFUNCTION(nt, SetStartItems)
 
        WepSet seti = '0 0 0';
 
-       FOREACH(Weapons, it != WEP_Null, LAMBDA(
+       FOREACH(Weapons, it != WEP_Null, {
                seti = it.m_wepset;
                n = tokenize_console(nt_GetReplacement(it.netname, autocvar_g_new_toys_autoreplace));
 
                for(j = 0; j < n; ++j)
-                       FOREACH(Weapons, it != WEP_Null, LAMBDA(
+                       FOREACH(Weapons, it != WEP_Null, {
                                if(it.netname == argv(j))
                                {
                                        WepSet setk = it.m_wepset;
                                        if(start_weapons & seti) newdefault |= setk;
                                        if(warmup_start_weapons & seti) warmup_newdefault |= setk;
                                }
-                       ));
-       ));
+                       });
+       });
 
        newdefault &= start_weapons_defaultmask;
        start_weapons &= ~start_weapons_defaultmask;
@@ -196,6 +195,11 @@ MUTATOR_HOOKFUNCTION(nt, SetStartItems)
 
 MUTATOR_HOOKFUNCTION(nt, SetWeaponreplace)
 {
+       if (MUTATOR_IS_ENABLED(random_items))
+       {
+               // Do not replace weapons when random items are enabled.
+               return;
+       }
        entity wep = M_ARGV(0, entity);
        entity wepinfo = M_ARGV(1, entity);
        string ret_string = M_ARGV(2, string);