]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/mutators/mutator_new_toys.qc
Mapinfo: decentralise mapinfo parsing
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / mutators / mutator_new_toys.qc
index 9b51d9abb8640fbcaf4f3bbcf5ef83d5f652f760..d7fc5257e9af15c4972bcb8414acfb39626d0f1a 100644 (file)
@@ -1,4 +1,3 @@
-#include "../_all.qh"
 
 #include "mutator.qh"
 
@@ -70,6 +69,37 @@ roflsound "New toys, new toys!" sound.
 
 */
 
+bool nt_IsNewToy(int w);
+
+REGISTER_MUTATOR(nt, cvar("g_new_toys") && !cvar("g_instagib") && !cvar("g_overkill"))
+{
+       MUTATOR_ONADD
+       {
+               if(time > 1) // game loads at time 1
+                       error("This cannot be added at runtime\n");
+
+               // mark the guns as ok to use by e.g. impulse 99
+               for(int i = WEP_FIRST; i <= WEP_LAST; ++i)
+                       if(nt_IsNewToy(i))
+                               get_weaponinfo(i).spawnflags &= ~WEP_FLAG_MUTATORBLOCKED;
+       }
+
+       MUTATOR_ONROLLBACK_OR_REMOVE
+       {
+               for(int i = WEP_FIRST; i <= WEP_LAST; ++i)
+                       if(nt_IsNewToy(i))
+                               get_weaponinfo(i).spawnflags |= WEP_FLAG_MUTATORBLOCKED;
+       }
+
+       MUTATOR_ONREMOVE
+       {
+               LOG_INFO("This cannot be removed at runtime\n");
+               return -1;
+       }
+
+       return 0;
+}
+
 .string new_toys;
 
 float autocvar_g_new_toys_autoreplace;
@@ -78,13 +108,13 @@ const float NT_AUTOREPLACE_NEVER = 0;
 const float NT_AUTOREPLACE_ALWAYS = 1;
 const float NT_AUTOREPLACE_RANDOM = 2;
 
-MUTATOR_HOOKFUNCTION(nt_SetModname)
+MUTATOR_HOOKFUNCTION(ntSetModname)
 {
        modname = "NewToys";
        return 0;
 }
 
-float nt_IsNewToy(float w)
+bool nt_IsNewToy(int w)
 {
        switch(w)
        {
@@ -124,7 +154,7 @@ string nt_GetReplacement(string w, float m)
        return s;
 }
 
-MUTATOR_HOOKFUNCTION(nt_SetStartItems)
+MUTATOR_HOOKFUNCTION(ntSetStartItems)
 {
        // rearrange start_weapon_default
        // apply those bits that are set by start_weapon_defaultmask
@@ -168,7 +198,7 @@ MUTATOR_HOOKFUNCTION(nt_SetStartItems)
        return 0;
 }
 
-MUTATOR_HOOKFUNCTION(nt_SetWeaponreplace)
+MUTATOR_HOOKFUNCTION(ntSetWeaponreplace)
 {SELFPARAM();
        // otherwise, we do replace
        if(self.new_toys)
@@ -188,7 +218,7 @@ MUTATOR_HOOKFUNCTION(nt_SetWeaponreplace)
        return 0;
 }
 
-MUTATOR_HOOKFUNCTION(nt_FilterItem)
+MUTATOR_HOOKFUNCTION(ntFilterItem)
 {SELFPARAM();
        if(nt_IsNewToy(self.weapon) && autocvar_g_new_toys_use_pickupsound) {
                self.item_pickupsound = string_null;
@@ -196,39 +226,3 @@ MUTATOR_HOOKFUNCTION(nt_FilterItem)
        }
        return 0;
 }
-
-MUTATOR_DEFINITION(mutator_new_toys)
-{
-       MUTATOR_HOOK(SetModname, nt_SetModname, CBC_ORDER_ANY);
-       MUTATOR_HOOK(SetStartItems, nt_SetStartItems, CBC_ORDER_ANY);
-       MUTATOR_HOOK(SetWeaponreplace, nt_SetWeaponreplace, CBC_ORDER_LAST);
-       MUTATOR_HOOK(FilterItem, nt_FilterItem, CBC_ORDER_ANY);
-
-       MUTATOR_ONADD
-       {
-               if(time > 1) // game loads at time 1
-                       error("This cannot be added at runtime\n");
-
-               // mark the guns as ok to use by e.g. impulse 99
-               float i;
-               for(i = WEP_FIRST; i <= WEP_LAST; ++i)
-                       if(nt_IsNewToy(i))
-                               get_weaponinfo(i).spawnflags &= ~WEP_FLAG_MUTATORBLOCKED;
-       }
-
-       MUTATOR_ONROLLBACK_OR_REMOVE
-       {
-               float i;
-               for(i = WEP_FIRST; i <= WEP_LAST; ++i)
-                       if(nt_IsNewToy(i))
-                               get_weaponinfo(i).spawnflags |= WEP_FLAG_MUTATORBLOCKED;
-       }
-
-       MUTATOR_ONREMOVE
-       {
-               LOG_INFO("This cannot be removed at runtime\n");
-               return -1;
-       }
-
-       return 0;
-}