Add a wrapper for item sounds, so they can be easily replaced like weapon sounds...
authorMario <mario@smbclan.net>
Wed, 14 Dec 2016 10:22:58 +0000 (20:22 +1000)
committerMario <mario@smbclan.net>
Wed, 14 Dec 2016 10:22:58 +0000 (20:22 +1000)
qcsrc/common/items/all.qc
qcsrc/common/items/item/armor.qh
qcsrc/common/items/item/health.qh
qcsrc/common/items/item/powerup.qh
qcsrc/common/mutators/mutator/instagib/items.qh
qcsrc/common/sounds/all.inc
qcsrc/server/mutators/events.qh

index 7782cda..0a26a75 100644 (file)
@@ -14,3 +14,14 @@ string Item_Model(string item_mdl)
 #endif
     return output;
 }
+
+string Item_Sound(string it_snd)
+{
+       string output = strcat("misc/", it_snd);
+#ifdef SVQC
+               MUTATOR_CALLHOOK(ItemSound, it_snd, output);
+               return M_ARGV(1, string);
+#else
+               return output;
+#endif
+}
index 93e76bf..b222ca6 100644 (file)
@@ -15,7 +15,7 @@ ENDCLASS(Armor)
 
 #ifdef GAMEQC
 MODEL(ArmorSmall_ITEM, Item_Model("item_armor_small.md3"));
-SOUND(ArmorSmall, "misc/armor1");
+SOUND(ArmorSmall, Item_Sound("armor1"));
 #endif
 
 REGISTER_ITEM(ArmorSmall, Armor) {
@@ -35,7 +35,7 @@ REGISTER_ITEM(ArmorSmall, Armor) {
 
 #ifdef GAMEQC
 MODEL(ArmorMedium_ITEM, Item_Model("item_armor_medium.md3"));
-SOUND(ArmorMedium, "misc/armor10");
+SOUND(ArmorMedium, Item_Sound("armor10"));
 #endif
 
 REGISTER_ITEM(ArmorMedium, Armor) {
@@ -55,7 +55,7 @@ REGISTER_ITEM(ArmorMedium, Armor) {
 
 #ifdef GAMEQC
 MODEL(ArmorBig_ITEM, Item_Model("item_armor_big.md3"));
-SOUND(ArmorBig, "misc/armor17_5");
+SOUND(ArmorBig, Item_Sound("armor17_5"));
 #endif
 
 REGISTER_ITEM(ArmorBig, Armor) {
@@ -77,7 +77,7 @@ REGISTER_ITEM(ArmorBig, Armor) {
 
 #ifdef GAMEQC
 MODEL(ArmorMega_ITEM, Item_Model("item_armor_large.md3"));
-SOUND(ArmorMega, "misc/armor25");
+SOUND(ArmorMega, Item_Sound("armor25"));
 #endif
 
 REGISTER_ITEM(ArmorMega, Armor) {
index bd2f61f..f791598 100644 (file)
@@ -15,7 +15,7 @@ ENDCLASS(Health)
 
 #ifdef GAMEQC
 MODEL(HealthSmall_ITEM, Item_Model("g_h1.md3"));
-SOUND(HealthSmall, "misc/minihealth");
+SOUND(HealthSmall, Item_Sound("minihealth"));
 #endif
 
 REGISTER_ITEM(HealthSmall, Health) {
@@ -35,7 +35,7 @@ REGISTER_ITEM(HealthSmall, Health) {
 
 #ifdef GAMEQC
 MODEL(HealthMedium_ITEM, Item_Model("g_h25.md3"));
-SOUND(HealthMedium, "misc/mediumhealth");
+SOUND(HealthMedium, Item_Sound("mediumhealth"));
 #endif
 
 REGISTER_ITEM(HealthMedium, Health) {
@@ -55,7 +55,7 @@ REGISTER_ITEM(HealthMedium, Health) {
 
 #ifdef GAMEQC
 MODEL(HealthBig_ITEM, Item_Model("g_h50.md3"));
-SOUND(HealthBig, "misc/mediumhealth");
+SOUND(HealthBig, Item_Sound("mediumhealth"));
 #endif
 
 REGISTER_ITEM(HealthBig, Health) {
@@ -77,7 +77,7 @@ REGISTER_ITEM(HealthBig, Health) {
 
 #ifdef GAMEQC
 MODEL(HealthMega_ITEM, Item_Model("g_h100.md3"));
-SOUND(HealthMega, "misc/megahealth");
+SOUND(HealthMega, Item_Sound("megahealth"));
 #endif
 
 REGISTER_ITEM(HealthMega, Health) {
index df9315e..80b1e6a 100644 (file)
@@ -19,7 +19,7 @@ ENDCLASS(Powerup)
 
 #ifdef GAMEQC
 MODEL(Strength_ITEM, Item_Model("g_strength.md3"));
-SOUND(Strength, "misc/powerup");
+SOUND(Strength, Item_Sound("powerup"));
 #endif
 
 REGISTER_ITEM(Strength, Powerup) {
@@ -39,7 +39,7 @@ REGISTER_ITEM(Strength, Powerup) {
 
 #ifdef GAMEQC
 MODEL(Shield_ITEM, Item_Model("g_invincible.md3"));
-SOUND(Shield, "misc/powerup_shield");
+SOUND(Shield, Item_Sound("powerup_shield"));
 #endif
 
 REGISTER_ITEM(Shield, Powerup) {
index 7736fa7..1efa4cb 100644 (file)
@@ -11,7 +11,7 @@ GETTER(float, instagib_respawntimejitter_ammo)
 
 #ifdef GAMEQC
 MODEL(VaporizerCells_ITEM, Item_Model("a_cells.md3"));
-SOUND(VaporizerCells, "misc/itempickup");
+SOUND(VaporizerCells, Item_Sound("itempickup"));
 #endif
 
 REGISTER_ITEM(VaporizerCells, Ammo) {
@@ -31,7 +31,7 @@ REGISTER_ITEM(VaporizerCells, Ammo) {
 
 #ifdef GAMEQC
 MODEL(ExtraLife_ITEM, Item_Model("g_h100.md3"));
-SOUND(ExtraLife, "misc/megahealth");
+SOUND(ExtraLife, Item_Sound("megahealth"));
 #endif
 
 REGISTER_ITEM(ExtraLife, Powerup) {
@@ -49,7 +49,7 @@ REGISTER_ITEM(ExtraLife, Powerup) {
 
 #ifdef GAMEQC
 MODEL(Invisibility_ITEM, Item_Model("g_strength.md3"));
-SOUND(Invisibility, "misc/powerup");
+SOUND(Invisibility, Item_Sound("powerup"));
 #endif
 
 REGISTER_ITEM(Invisibility, Powerup) {
@@ -67,7 +67,7 @@ REGISTER_ITEM(Invisibility, Powerup) {
 
 #ifdef GAMEQC
 MODEL(Speed_ITEM, Item_Model("g_invincible.md3"));
-SOUND(Speed, "misc/powerup_shield");
+SOUND(Speed, Item_Sound("powerup_shield"));
 #endif
 
 REGISTER_ITEM(Speed, Powerup) {
index 69a95be..4394e17 100644 (file)
@@ -3,6 +3,7 @@
 
 #include "../teams.qh"
 string W_Sound(string w_snd);
+string Item_Sound(string it_snd);
 
 SOUND(ARC_FIRE, W_Sound("arc_fire"));
 SOUND(ARC_LOOP, W_Sound("arc_loop"));
@@ -236,20 +237,20 @@ SOUND(NADE_BEEP, "overkill/grenadebip");
 
 SOUND(BUFF_LOST, "relics/relic_effect");
 
-SOUND(POWEROFF, "misc/poweroff");
-SOUND(POWERUP, "misc/powerup");
-SOUND(SHIELD_RESPAWN, "misc/shield_respawn");
-SOUND(STRENGTH_RESPAWN, "misc/strength_respawn");
+SOUND(POWEROFF, Item_Sound("poweroff"));
+SOUND(POWERUP, Item_Sound("powerup"));
+SOUND(SHIELD_RESPAWN, Item_Sound("shield_respawn"));
+SOUND(STRENGTH_RESPAWN, Item_Sound("strength_respawn"));
 
-SOUND(ARMOR25, "misc/armor25");
+SOUND(ARMOR25, Item_Sound("armor25"));
 SOUND(ARMORIMPACT, "misc/armorimpact");
 SOUND(BODYIMPACT1, "misc/bodyimpact1");
 SOUND(BODYIMPACT2, "misc/bodyimpact2");
 
-SOUND(ITEMPICKUP, "misc/itempickup");
-SOUND(ITEMRESPAWNCOUNTDOWN, "misc/itemrespawncountdown");
-SOUND(ITEMRESPAWN, "misc/itemrespawn");
-SOUND(MEGAHEALTH, "misc/megahealth");
+SOUND(ITEMPICKUP, Item_Sound("itempickup"));
+SOUND(ITEMRESPAWNCOUNTDOWN, Item_Sound("itemrespawncountdown"));
+SOUND(ITEMRESPAWN, Item_Sound("itemrespawn"));
+SOUND(MEGAHEALTH, Item_Sound("megahealth"));
 
 SOUND(LAVA, "player/lava");
 SOUND(SLIME, "player/slime");
index cab67d0..1ba2c78 100644 (file)
@@ -96,6 +96,14 @@ MUTATOR_HOOKABLE(WeaponSound, EV_WeaponSound);
     /**/
 MUTATOR_HOOKABLE(ItemModel, EV_ItemModel);
 
+/** called when an item sound is about to be played, allows custom paths etc. */
+#define EV_ItemSound(i, o) \
+    /** sound       */ i(string, MUTATOR_ARGV_0_string) \
+    /** output      */ i(string, MUTATOR_ARGV_1_string) \
+    /**/               o(string, MUTATOR_ARGV_1_string) \
+    /**/
+MUTATOR_HOOKABLE(ItemSound, EV_ItemSound);
+
 /** called when someone was fragged by "self", and is expected to change frag_score to adjust scoring for the kill */
 #define EV_GiveFragsForKill(i, o) \
     /** attacker   */ i(entity, MUTATOR_ARGV_0_entity) \