4 #include <server/chat.qh>
8 /** Use new sound handling. TODO: use when sounds play correctly on clients */
9 bool autocvar_g_debug_globalsounds = false;
12 // player sounds, voice messages
14 .string m_playersoundstr;
15 ..string m_playersoundfld;
17 REGISTRY(PlayerSounds, BITS(8) - 1)
18 #define REGISTER_PLAYERSOUND(id) \
19 .string _playersound_##id; \
20 REGISTER(PlayerSounds, playersound, id, m_id, new_pure(PlayerSound)) \
22 this.m_playersoundstr = #id; \
23 this.m_playersoundfld = _playersound_##id; \
25 REGISTER_REGISTRY(PlayerSounds)
26 REGISTRY_SORT(PlayerSounds)
28 REGISTRY_DEFINE_GET(PlayerSounds, NULL)
29 STATIC_INIT(PlayerSounds_renumber)
31 FOREACH(PlayerSounds, true, it.m_id = i);
33 REGISTRY_CHECK(PlayerSounds)
35 REGISTER_PLAYERSOUND(death)
36 REGISTER_PLAYERSOUND(drown)
37 REGISTER_PLAYERSOUND(fall)
38 REGISTER_PLAYERSOUND(falling)
39 REGISTER_PLAYERSOUND(gasp)
40 REGISTER_PLAYERSOUND(jump)
41 REGISTER_PLAYERSOUND(pain100)
42 REGISTER_PLAYERSOUND(pain25)
43 REGISTER_PLAYERSOUND(pain50)
44 REGISTER_PLAYERSOUND(pain75)
46 .bool instanceOfVoiceMessage;
48 #define REGISTER_VOICEMSG(id, vt, listed) \
49 .string _playersound_##id; \
50 REGISTER(PlayerSounds, playersound, id, m_id, new_pure(VoiceMessage)) \
52 this.instanceOfVoiceMessage = listed; \
53 this.m_playersoundstr = #id; \
54 this.m_playersoundfld = _playersound_##id; \
55 this.m_playersoundvt = vt; \
58 const int VOICETYPE_PLAYERSOUND = 10;
59 const int VOICETYPE_TEAMRADIO = 11;
60 const int VOICETYPE_LASTATTACKER = 12;
61 const int VOICETYPE_LASTATTACKER_ONLY = 13;
62 const int VOICETYPE_AUTOTAUNT = 14;
63 const int VOICETYPE_TAUNT = 15;
65 REGISTER_VOICEMSG(attack, VOICETYPE_TEAMRADIO, true)
66 REGISTER_VOICEMSG(attackinfive, VOICETYPE_TEAMRADIO, true)
67 REGISTER_VOICEMSG(coverme, VOICETYPE_TEAMRADIO, true)
68 REGISTER_VOICEMSG(defend, VOICETYPE_TEAMRADIO, true)
69 REGISTER_VOICEMSG(freelance, VOICETYPE_TEAMRADIO, true)
70 REGISTER_VOICEMSG(incoming, VOICETYPE_TEAMRADIO, true)
71 REGISTER_VOICEMSG(meet, VOICETYPE_TEAMRADIO, true)
72 REGISTER_VOICEMSG(needhelp, VOICETYPE_TEAMRADIO, true)
73 REGISTER_VOICEMSG(seenflag, VOICETYPE_TEAMRADIO, true)
74 REGISTER_VOICEMSG(taunt, VOICETYPE_TAUNT, true)
75 REGISTER_VOICEMSG(teamshoot, VOICETYPE_LASTATTACKER, true)
77 //NOTE: some models lack sounds for these:
78 REGISTER_VOICEMSG(flagcarriertakingdamage, VOICETYPE_TEAMRADIO, false)
79 REGISTER_VOICEMSG(getflag, VOICETYPE_TEAMRADIO, false)
80 //NOTE: ALL models lack sounds for these (only available in default sounds currently):
81 REGISTER_VOICEMSG(affirmative, VOICETYPE_TEAMRADIO, false)
82 REGISTER_VOICEMSG(attacking, VOICETYPE_TEAMRADIO, false)
83 REGISTER_VOICEMSG(defending, VOICETYPE_TEAMRADIO, false)
84 REGISTER_VOICEMSG(roaming, VOICETYPE_TEAMRADIO, false)
85 REGISTER_VOICEMSG(onmyway, VOICETYPE_TEAMRADIO, false)
86 REGISTER_VOICEMSG(droppedflag, VOICETYPE_TEAMRADIO, false)
87 REGISTER_VOICEMSG(negative, VOICETYPE_TEAMRADIO, false)
88 REGISTER_VOICEMSG(seenenemy, VOICETYPE_TEAMRADIO, false)
90 .string m_globalsoundstr;
91 REGISTRY(GlobalSounds, BITS(8) - 1)
92 #define REGISTER_GLOBALSOUND(id, str) \
93 REGISTER(GlobalSounds, GS, id, m_id, new_pure(GlobalSound)) \
95 this.m_globalsoundstr = str; \
97 REGISTER_REGISTRY(GlobalSounds)
98 REGISTRY_SORT(GlobalSounds)
100 REGISTRY_DEFINE_GET(GlobalSounds, NULL)
101 STATIC_INIT(GlobalSounds_renumber)
103 FOREACH(GlobalSounds, true, it.m_id = i);
105 REGISTRY_CHECK(GlobalSounds)
106 void PrecacheGlobalSound(string samplestring);
107 PRECACHE(GlobalSounds)
109 FOREACH(GlobalSounds, true, PrecacheGlobalSound(it.m_globalsoundstr));
112 REGISTER_GLOBALSOUND(STEP, "misc/footstep0 6")
113 REGISTER_GLOBALSOUND(STEP_METAL, "misc/metalfootstep0 6")
114 REGISTER_GLOBALSOUND(FALL, "misc/hitground 4")
115 REGISTER_GLOBALSOUND(FALL_METAL, "misc/metalhitground 4")
117 bool GetPlayerSoundSampleField_notFound;
118 void PrecachePlayerSounds(string f);
120 .string GetVoiceMessageSampleField(string type);
121 .string GetPlayerSoundSampleField(string type);
122 void ClearPlayerSounds(entity this);
123 float LoadPlayerSounds(entity this, string f, bool strict);
124 void UpdatePlayerSounds(entity this);
126 entity GetVoiceMessage(string type);
128 string GlobalSound_sample(string pair, float r);
130 float GlobalSound_pitch(float _pitch);
134 void _GlobalSound(entity this, entity gs, entity ps, string sample, float chan, float vol, float voicetype, bool fake);
135 #define GlobalSound(this, def, chan, vol, voicetype) _GlobalSound(this, def, NULL, string_null, chan, vol, voicetype, false)
136 #define GlobalSound_string(this, def, chan, vol, voicetype) _GlobalSound(this, NULL, NULL, def, chan, vol, voicetype, false)
137 #define PlayerSound(this, def, chan, vol, voicetype) _GlobalSound(this, NULL, def, string_null, chan, vol, voicetype, false)
138 #define VoiceMessage(this, def, msg) \
141 int voicetype = VM.m_playersoundvt; \
142 bool ownteam = (voicetype == VOICETYPE_TEAMRADIO); \
143 int flood = Say(this, ownteam, NULL, msg, true); \
145 if (IS_SPEC(this) || IS_OBSERVER(this) || flood < 0) fake = true; \
146 else if (flood > 0) fake = false; \
148 _GlobalSound(this, NULL, VM, string_null, CH_VOICE, VOL_BASEVOICE, voicetype, fake); \
153 string allvoicesamples;
154 STATIC_INIT(allvoicesamples)
156 FOREACH(PlayerSounds, it.instanceOfVoiceMessage, allvoicesamples = strcat(allvoicesamples, " ", it.m_playersoundstr));
157 allvoicesamples = strzone(substring(allvoicesamples, 1, -1));