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;
10 bool autocvar_sv_taunt;
11 bool autocvar_sv_autotaunt;
14 // player sounds, voice messages
16 .string m_playersoundstr;
17 ..string m_playersoundfld;
19 REPLICATE_FIELD(float, cvar_cl_autotaunt);
20 REPLICATE_FIELD(int, cvar_cl_voice_directional);
21 REPLICATE_FIELD(float, cvar_cl_voice_directional_taunt_attenuation);
23 REGISTRY(PlayerSounds, BITS(8) - 1)
24 #define REGISTER_PLAYERSOUND(id) \
25 .string _playersound_##id; \
26 REGISTER(PlayerSounds, playersound, id, m_id, new_pure(PlayerSound)) \
28 this.m_playersoundstr = #id; \
29 this.m_playersoundfld = _playersound_##id; \
31 REGISTER_REGISTRY(PlayerSounds)
32 REGISTRY_SORT(PlayerSounds)
34 REGISTRY_DEFINE_GET(PlayerSounds, NULL)
35 STATIC_INIT(PlayerSounds_renumber)
37 FOREACH(PlayerSounds, true, it.m_id = i);
39 REGISTRY_CHECK(PlayerSounds)
41 REGISTER_PLAYERSOUND(death)
42 REGISTER_PLAYERSOUND(drown)
43 REGISTER_PLAYERSOUND(fall)
44 REGISTER_PLAYERSOUND(falling)
45 REGISTER_PLAYERSOUND(gasp)
46 REGISTER_PLAYERSOUND(jump)
47 REGISTER_PLAYERSOUND(pain100)
48 REGISTER_PLAYERSOUND(pain25)
49 REGISTER_PLAYERSOUND(pain50)
50 REGISTER_PLAYERSOUND(pain75)
52 .bool instanceOfVoiceMessage;
54 #define REGISTER_VOICEMSG(id, vt, listed) \
55 .string _playersound_##id; \
56 REGISTER(PlayerSounds, playersound, id, m_id, new_pure(VoiceMessage)) \
58 this.instanceOfVoiceMessage = listed; \
59 this.m_playersoundstr = #id; \
60 this.m_playersoundfld = _playersound_##id; \
61 this.m_playersoundvt = vt; \
64 const int VOICETYPE_PLAYERSOUND = 10;
65 const int VOICETYPE_TEAMRADIO = 11;
66 const int VOICETYPE_LASTATTACKER = 12;
67 const int VOICETYPE_LASTATTACKER_ONLY = 13;
68 const int VOICETYPE_AUTOTAUNT = 14;
69 const int VOICETYPE_TAUNT = 15;
71 REGISTER_VOICEMSG(attack, VOICETYPE_TEAMRADIO, true)
72 REGISTER_VOICEMSG(attackinfive, VOICETYPE_TEAMRADIO, true)
73 REGISTER_VOICEMSG(coverme, VOICETYPE_TEAMRADIO, true)
74 REGISTER_VOICEMSG(defend, VOICETYPE_TEAMRADIO, true)
75 REGISTER_VOICEMSG(freelance, VOICETYPE_TEAMRADIO, true)
76 REGISTER_VOICEMSG(incoming, VOICETYPE_TEAMRADIO, true)
77 REGISTER_VOICEMSG(meet, VOICETYPE_TEAMRADIO, true)
78 REGISTER_VOICEMSG(needhelp, VOICETYPE_TEAMRADIO, true)
79 REGISTER_VOICEMSG(seenflag, VOICETYPE_TEAMRADIO, true)
80 REGISTER_VOICEMSG(taunt, VOICETYPE_TAUNT, true)
81 REGISTER_VOICEMSG(teamshoot, VOICETYPE_LASTATTACKER, true)
83 //NOTE: some models lack sounds for these:
84 REGISTER_VOICEMSG(flagcarriertakingdamage, VOICETYPE_TEAMRADIO, false)
85 REGISTER_VOICEMSG(getflag, VOICETYPE_TEAMRADIO, false)
86 //NOTE: ALL models lack sounds for these (only available in default sounds currently):
87 REGISTER_VOICEMSG(affirmative, VOICETYPE_TEAMRADIO, false)
88 REGISTER_VOICEMSG(attacking, VOICETYPE_TEAMRADIO, false)
89 REGISTER_VOICEMSG(defending, VOICETYPE_TEAMRADIO, false)
90 REGISTER_VOICEMSG(roaming, VOICETYPE_TEAMRADIO, false)
91 REGISTER_VOICEMSG(onmyway, VOICETYPE_TEAMRADIO, false)
92 REGISTER_VOICEMSG(droppedflag, VOICETYPE_TEAMRADIO, false)
93 REGISTER_VOICEMSG(negative, VOICETYPE_TEAMRADIO, false)
94 REGISTER_VOICEMSG(seenenemy, VOICETYPE_TEAMRADIO, false)
96 .string m_globalsoundstr;
97 REGISTRY(GlobalSounds, BITS(8) - 1)
98 #define REGISTER_GLOBALSOUND(id, str) \
99 REGISTER(GlobalSounds, GS, id, m_id, new_pure(GlobalSound)) \
101 this.m_globalsoundstr = str; \
103 REGISTER_REGISTRY(GlobalSounds)
104 REGISTRY_SORT(GlobalSounds)
106 REGISTRY_DEFINE_GET(GlobalSounds, NULL)
107 STATIC_INIT(GlobalSounds_renumber)
109 FOREACH(GlobalSounds, true, it.m_id = i);
111 REGISTRY_CHECK(GlobalSounds)
112 void PrecacheGlobalSound(string samplestring);
113 PRECACHE(GlobalSounds)
115 FOREACH(GlobalSounds, true, PrecacheGlobalSound(it.m_globalsoundstr));
118 REGISTER_GLOBALSOUND(STEP, "misc/footstep0 6")
119 REGISTER_GLOBALSOUND(STEP_METAL, "misc/metalfootstep0 6")
120 REGISTER_GLOBALSOUND(FALL, "misc/hitground 4")
121 REGISTER_GLOBALSOUND(FALL_METAL, "misc/metalhitground 4")
123 bool GetPlayerSoundSampleField_notFound;
124 void PrecachePlayerSounds(string f);
126 .string GetVoiceMessageSampleField(string type);
127 .string GetPlayerSoundSampleField(string type);
128 void ClearPlayerSounds(entity this);
129 float LoadPlayerSounds(entity this, string f, bool strict);
130 void UpdatePlayerSounds(entity this);
132 entity GetVoiceMessage(string type);
134 string GlobalSound_sample(string pair, float r);
136 float GlobalSound_pitch(float _pitch);
140 void _GlobalSound(entity this, entity gs, entity ps, string sample, float chan, float vol, float voicetype, bool fake);
141 #define GlobalSound(this, def, chan, vol, voicetype) _GlobalSound(this, def, NULL, string_null, chan, vol, voicetype, false)
142 #define GlobalSound_string(this, def, chan, vol, voicetype) _GlobalSound(this, NULL, NULL, def, chan, vol, voicetype, false)
143 #define PlayerSound(this, def, chan, vol, voicetype) _GlobalSound(this, NULL, def, string_null, chan, vol, voicetype, false)
144 #define VoiceMessage(this, def, msg) \
147 int voicetype = VM.m_playersoundvt; \
148 bool ownteam = (voicetype == VOICETYPE_TEAMRADIO); \
149 int flood = Say(this, ownteam, NULL, msg, true); \
151 if (IS_SPEC(this) || IS_OBSERVER(this) || flood < 0) fake = true; \
152 else if (flood > 0) fake = false; \
154 _GlobalSound(this, NULL, VM, string_null, CH_VOICE, VOL_BASEVOICE, voicetype, fake); \
159 string allvoicesamples;
160 STATIC_INIT(allvoicesamples)
162 FOREACH(PlayerSounds, it.instanceOfVoiceMessage, allvoicesamples = strcat(allvoicesamples, " ", it.m_playersoundstr));
163 allvoicesamples = strzone(substring(allvoicesamples, 1, -1));