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 REGISTRY(PlayerSounds, BITS(8) - 1)
20 #define REGISTER_PLAYERSOUND(id) \
21 .string _playersound_##id; \
22 REGISTER(PlayerSounds, playersound, id, m_id, new_pure(PlayerSound)) \
24 this.m_playersoundstr = #id; \
25 this.m_playersoundfld = _playersound_##id; \
27 REGISTER_REGISTRY(PlayerSounds)
28 REGISTRY_SORT(PlayerSounds)
30 REGISTRY_DEFINE_GET(PlayerSounds, NULL)
31 STATIC_INIT(PlayerSounds_renumber)
33 FOREACH(PlayerSounds, true, it.m_id = i);
35 REGISTRY_CHECK(PlayerSounds)
37 REGISTER_PLAYERSOUND(death)
38 REGISTER_PLAYERSOUND(drown)
39 REGISTER_PLAYERSOUND(fall)
40 REGISTER_PLAYERSOUND(falling)
41 REGISTER_PLAYERSOUND(gasp)
42 REGISTER_PLAYERSOUND(jump)
43 REGISTER_PLAYERSOUND(pain100)
44 REGISTER_PLAYERSOUND(pain25)
45 REGISTER_PLAYERSOUND(pain50)
46 REGISTER_PLAYERSOUND(pain75)
48 .bool instanceOfVoiceMessage;
50 #define REGISTER_VOICEMSG(id, vt, listed) \
51 .string _playersound_##id; \
52 REGISTER(PlayerSounds, playersound, id, m_id, new_pure(VoiceMessage)) \
54 this.instanceOfVoiceMessage = listed; \
55 this.m_playersoundstr = #id; \
56 this.m_playersoundfld = _playersound_##id; \
57 this.m_playersoundvt = vt; \
60 const int VOICETYPE_PLAYERSOUND = 10;
61 const int VOICETYPE_TEAMRADIO = 11;
62 const int VOICETYPE_LASTATTACKER = 12;
63 const int VOICETYPE_LASTATTACKER_ONLY = 13;
64 const int VOICETYPE_AUTOTAUNT = 14;
65 const int VOICETYPE_TAUNT = 15;
67 REGISTER_VOICEMSG(attack, VOICETYPE_TEAMRADIO, true)
68 REGISTER_VOICEMSG(attackinfive, VOICETYPE_TEAMRADIO, true)
69 REGISTER_VOICEMSG(coverme, VOICETYPE_TEAMRADIO, true)
70 REGISTER_VOICEMSG(defend, VOICETYPE_TEAMRADIO, true)
71 REGISTER_VOICEMSG(freelance, VOICETYPE_TEAMRADIO, true)
72 REGISTER_VOICEMSG(incoming, VOICETYPE_TEAMRADIO, true)
73 REGISTER_VOICEMSG(meet, VOICETYPE_TEAMRADIO, true)
74 REGISTER_VOICEMSG(needhelp, VOICETYPE_TEAMRADIO, true)
75 REGISTER_VOICEMSG(seenflag, VOICETYPE_TEAMRADIO, true)
76 REGISTER_VOICEMSG(taunt, VOICETYPE_TAUNT, true)
77 REGISTER_VOICEMSG(teamshoot, VOICETYPE_LASTATTACKER, true)
79 //NOTE: some models lack sounds for these:
80 REGISTER_VOICEMSG(flagcarriertakingdamage, VOICETYPE_TEAMRADIO, false)
81 REGISTER_VOICEMSG(getflag, VOICETYPE_TEAMRADIO, false)
82 //NOTE: ALL models lack sounds for these (only available in default sounds currently):
83 REGISTER_VOICEMSG(affirmative, VOICETYPE_TEAMRADIO, false)
84 REGISTER_VOICEMSG(attacking, VOICETYPE_TEAMRADIO, false)
85 REGISTER_VOICEMSG(defending, VOICETYPE_TEAMRADIO, false)
86 REGISTER_VOICEMSG(roaming, VOICETYPE_TEAMRADIO, false)
87 REGISTER_VOICEMSG(onmyway, VOICETYPE_TEAMRADIO, false)
88 REGISTER_VOICEMSG(droppedflag, VOICETYPE_TEAMRADIO, false)
89 REGISTER_VOICEMSG(negative, VOICETYPE_TEAMRADIO, false)
90 REGISTER_VOICEMSG(seenenemy, VOICETYPE_TEAMRADIO, false)
92 .string m_globalsoundstr;
93 REGISTRY(GlobalSounds, BITS(8) - 1)
94 #define REGISTER_GLOBALSOUND(id, str) \
95 REGISTER(GlobalSounds, GS, id, m_id, new_pure(GlobalSound)) \
97 this.m_globalsoundstr = str; \
99 REGISTER_REGISTRY(GlobalSounds)
100 REGISTRY_SORT(GlobalSounds)
102 REGISTRY_DEFINE_GET(GlobalSounds, NULL)
103 STATIC_INIT(GlobalSounds_renumber)
105 FOREACH(GlobalSounds, true, it.m_id = i);
107 REGISTRY_CHECK(GlobalSounds)
108 void PrecacheGlobalSound(string samplestring);
109 PRECACHE(GlobalSounds)
111 FOREACH(GlobalSounds, true, PrecacheGlobalSound(it.m_globalsoundstr));
114 REGISTER_GLOBALSOUND(STEP, "misc/footstep0 6")
115 REGISTER_GLOBALSOUND(STEP_METAL, "misc/metalfootstep0 6")
116 REGISTER_GLOBALSOUND(FALL, "misc/hitground 4")
117 REGISTER_GLOBALSOUND(FALL_METAL, "misc/metalhitground 4")
119 bool GetPlayerSoundSampleField_notFound;
120 void PrecachePlayerSounds(string f);
122 .string GetVoiceMessageSampleField(string type);
123 .string GetPlayerSoundSampleField(string type);
124 void ClearPlayerSounds(entity this);
125 float LoadPlayerSounds(entity this, string f, bool strict);
126 void UpdatePlayerSounds(entity this);
128 entity GetVoiceMessage(string type);
130 string GlobalSound_sample(string pair, float r);
132 float GlobalSound_pitch(float _pitch);
136 void _GlobalSound(entity this, entity gs, entity ps, string sample, float chan, float vol, float voicetype, bool fake);
137 #define GlobalSound(this, def, chan, vol, voicetype) _GlobalSound(this, def, NULL, string_null, chan, vol, voicetype, false)
138 #define GlobalSound_string(this, def, chan, vol, voicetype) _GlobalSound(this, NULL, NULL, def, chan, vol, voicetype, false)
139 #define PlayerSound(this, def, chan, vol, voicetype) _GlobalSound(this, NULL, def, string_null, chan, vol, voicetype, false)
140 #define VoiceMessage(this, def, msg) \
143 int voicetype = VM.m_playersoundvt; \
144 bool ownteam = (voicetype == VOICETYPE_TEAMRADIO); \
145 int flood = Say(this, ownteam, NULL, msg, true); \
147 if (IS_SPEC(this) || IS_OBSERVER(this) || flood < 0) fake = true; \
148 else if (flood > 0) fake = false; \
150 _GlobalSound(this, NULL, VM, string_null, CH_VOICE, VOL_BASEVOICE, voicetype, fake); \
155 string allvoicesamples;
156 STATIC_INIT(allvoicesamples)
158 FOREACH(PlayerSounds, it.instanceOfVoiceMessage, allvoicesamples = strcat(allvoicesamples, " ", it.m_playersoundstr));
159 allvoicesamples = strzone(substring(allvoicesamples, 1, -1));