From b8d1818720e24f8d6b70806e6e62956c755e4dd8 Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 14 Dec 2016 20:22:58 +1000 Subject: [PATCH] Add a wrapper for item sounds, so they can be easily replaced like weapon sounds by mods --- qcsrc/common/items/all.qc | 11 +++++++++++ qcsrc/common/items/item/armor.qh | 8 ++++---- qcsrc/common/items/item/health.qh | 8 ++++---- qcsrc/common/items/item/powerup.qh | 4 ++-- .../common/mutators/mutator/instagib/items.qh | 8 ++++---- qcsrc/common/sounds/all.inc | 19 ++++++++++--------- qcsrc/server/mutators/events.qh | 8 ++++++++ 7 files changed, 43 insertions(+), 23 deletions(-) diff --git a/qcsrc/common/items/all.qc b/qcsrc/common/items/all.qc index 7782cda0d6..0a26a75b5a 100644 --- a/qcsrc/common/items/all.qc +++ b/qcsrc/common/items/all.qc @@ -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 +} diff --git a/qcsrc/common/items/item/armor.qh b/qcsrc/common/items/item/armor.qh index 93e76bf884..b222ca6289 100644 --- a/qcsrc/common/items/item/armor.qh +++ b/qcsrc/common/items/item/armor.qh @@ -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) { diff --git a/qcsrc/common/items/item/health.qh b/qcsrc/common/items/item/health.qh index bd2f61f15c..f7915987e3 100644 --- a/qcsrc/common/items/item/health.qh +++ b/qcsrc/common/items/item/health.qh @@ -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) { diff --git a/qcsrc/common/items/item/powerup.qh b/qcsrc/common/items/item/powerup.qh index df9315e2c8..80b1e6affc 100644 --- a/qcsrc/common/items/item/powerup.qh +++ b/qcsrc/common/items/item/powerup.qh @@ -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) { diff --git a/qcsrc/common/mutators/mutator/instagib/items.qh b/qcsrc/common/mutators/mutator/instagib/items.qh index 7736fa7b30..1efa4cbdc1 100644 --- a/qcsrc/common/mutators/mutator/instagib/items.qh +++ b/qcsrc/common/mutators/mutator/instagib/items.qh @@ -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) { diff --git a/qcsrc/common/sounds/all.inc b/qcsrc/common/sounds/all.inc index 69a95be0cc..4394e17406 100644 --- a/qcsrc/common/sounds/all.inc +++ b/qcsrc/common/sounds/all.inc @@ -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"); diff --git a/qcsrc/server/mutators/events.qh b/qcsrc/server/mutators/events.qh index cab67d0c65..1ba2c785c9 100644 --- a/qcsrc/server/mutators/events.qh +++ b/qcsrc/server/mutators/events.qh @@ -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) \ -- 2.39.2