]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/mutators/mutator_new_toys.qc
Use the sound list
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / mutators / mutator_new_toys.qc
index 3e41c42fe022215ae6152a92b0eb7a7a0ff48065..9b51d9abb8640fbcaf4f3bbcf5ef83d5f652f760 100644 (file)
@@ -1,3 +1,7 @@
+#include "../_all.qh"
+
+#include "mutator.qh"
+
 /*
 
 CORE    laser   vortex     lg      rl      cry     gl      elec    hagar   fireb   hook
@@ -69,9 +73,10 @@ roflsound "New toys, new toys!" sound.
 .string new_toys;
 
 float autocvar_g_new_toys_autoreplace;
-#define NT_AUTOREPLACE_NEVER 0
-#define NT_AUTOREPLACE_ALWAYS 1
-#define NT_AUTOREPLACE_RANDOM 2
+bool autocvar_g_new_toys_use_pickupsound = true;
+const float NT_AUTOREPLACE_NEVER = 0;
+const float NT_AUTOREPLACE_ALWAYS = 1;
+const float NT_AUTOREPLACE_RANDOM = 2;
 
 MUTATOR_HOOKFUNCTION(nt_SetModname)
 {
@@ -83,14 +88,14 @@ float nt_IsNewToy(float w)
 {
        switch(w)
        {
-               case WEP_SEEKER:
-               case WEP_MINE_LAYER:
-               case WEP_HLAC:
-               case WEP_RIFLE:
-               case WEP_SHOCKWAVE:
-                       return TRUE;
+               case WEP_SEEKER.m_id:
+               case WEP_MINE_LAYER.m_id:
+               case WEP_HLAC.m_id:
+               case WEP_RIFLE.m_id:
+               case WEP_SHOCKWAVE.m_id:
+                       return true;
                default:
-                       return FALSE;
+                       return false;
        }
 }
 
@@ -102,7 +107,7 @@ string nt_GetFullReplacement(string w)
                case "devastator": return "minelayer";
                case "machinegun": return "hlac";
                case "vortex": return "rifle";
-               case "shotgun": return "shockwave";
+               //case "shotgun": return "shockwave";
                default: return string_null;
        }
 }
@@ -164,7 +169,7 @@ MUTATOR_HOOKFUNCTION(nt_SetStartItems)
 }
 
 MUTATOR_HOOKFUNCTION(nt_SetWeaponreplace)
-{
+{SELFPARAM();
        // otherwise, we do replace
        if(self.new_toys)
        {
@@ -184,9 +189,11 @@ MUTATOR_HOOKFUNCTION(nt_SetWeaponreplace)
 }
 
 MUTATOR_HOOKFUNCTION(nt_FilterItem)
-{
-       if(nt_IsNewToy(self.weapon))
-               self.item_pickupsound = "weapons/weaponpickup_new_toys.wav";
+{SELFPARAM();
+       if(nt_IsNewToy(self.weapon) && autocvar_g_new_toys_use_pickupsound) {
+               self.item_pickupsound = string_null;
+               self.item_pickupsound_ent = SND_WEAPONPICKUP_NEW_TOYS;
+       }
        return 0;
 }
 
@@ -202,8 +209,6 @@ MUTATOR_DEFINITION(mutator_new_toys)
                if(time > 1) // game loads at time 1
                        error("This cannot be added at runtime\n");
 
-               precache_sound("weapons/weaponpickup_new_toys.wav");
-
                // mark the guns as ok to use by e.g. impulse 99
                float i;
                for(i = WEP_FIRST; i <= WEP_LAST; ++i)
@@ -221,7 +226,7 @@ MUTATOR_DEFINITION(mutator_new_toys)
 
        MUTATOR_ONREMOVE
        {
-               print("This cannot be removed at runtime\n");
+               LOG_INFO("This cannot be removed at runtime\n");
                return -1;
        }