4 /** Use new sound handling. TODO: use when sounds play correctly on clients */
5 bool autocvar_g_debug_globalsounds = false;
8 // player sounds, voice messages
10 .string m_playersoundstr;
11 ..string m_playersoundfld;
13 REGISTRY(PlayerSounds, BITS(8) - 1)
14 #define PlayerSounds_from(i) _PlayerSounds_from(i, NULL)
15 #define REGISTER_PLAYERSOUND(id) \
16 .string _playersound_##id; \
17 REGISTER(PlayerSounds, playersound, id, m_id, new_pure(PlayerSound)) \
19 this.m_playersoundstr = #id; \
20 this.m_playersoundfld = _playersound_##id; \
22 REGISTER_REGISTRY(PlayerSounds)
23 REGISTRY_SORT(PlayerSounds)
24 STATIC_INIT(PlayerSounds_renumber)
26 FOREACH(PlayerSounds, true, it.m_id = i);
28 REGISTRY_CHECK(PlayerSounds)
30 REGISTER_PLAYERSOUND(death)
31 REGISTER_PLAYERSOUND(drown)
32 REGISTER_PLAYERSOUND(fall)
33 REGISTER_PLAYERSOUND(falling)
34 REGISTER_PLAYERSOUND(gasp)
35 REGISTER_PLAYERSOUND(jump)
36 REGISTER_PLAYERSOUND(pain100)
37 REGISTER_PLAYERSOUND(pain25)
38 REGISTER_PLAYERSOUND(pain50)
39 REGISTER_PLAYERSOUND(pain75)
41 .bool instanceOfVoiceMessage;
43 #define REGISTER_VOICEMSG(id, vt) \
44 .string _playersound_##id; \
45 REGISTER(PlayerSounds, playersound, id, m_id, new_pure(VoiceMessage)) \
47 this.instanceOfVoiceMessage = true; \
48 this.m_playersoundstr = #id; \
49 this.m_playersoundfld = _playersound_##id; \
50 this.m_playersoundvt = vt; \
53 const int VOICETYPE_PLAYERSOUND = 10;
54 const int VOICETYPE_TEAMRADIO = 11;
55 const int VOICETYPE_LASTATTACKER = 12;
56 const int VOICETYPE_LASTATTACKER_ONLY = 13;
57 const int VOICETYPE_AUTOTAUNT = 14;
58 const int VOICETYPE_TAUNT = 15;
60 REGISTER_VOICEMSG(attack, VOICETYPE_TEAMRADIO)
61 REGISTER_VOICEMSG(attackinfive, VOICETYPE_TEAMRADIO)
62 REGISTER_VOICEMSG(coverme, VOICETYPE_TEAMRADIO)
63 REGISTER_VOICEMSG(defend, VOICETYPE_TEAMRADIO)
64 REGISTER_VOICEMSG(freelance, VOICETYPE_TEAMRADIO)
65 REGISTER_VOICEMSG(incoming, VOICETYPE_TEAMRADIO)
66 REGISTER_VOICEMSG(meet, VOICETYPE_TEAMRADIO)
67 REGISTER_VOICEMSG(needhelp, VOICETYPE_TEAMRADIO)
68 REGISTER_VOICEMSG(seenflag, VOICETYPE_TEAMRADIO)
69 REGISTER_VOICEMSG(taunt, VOICETYPE_TAUNT)
70 REGISTER_VOICEMSG(teamshoot, VOICETYPE_LASTATTACKER)
72 // reserved sound names for the future (some models lack sounds for them):
73 // _VOICEMSG(flagcarriertakingdamage)
75 // reserved sound names for the future (ALL models lack sounds for them):
76 // _VOICEMSG(affirmative)
77 // _VOICEMSG(attacking)
78 // _VOICEMSG(defending)
81 // _VOICEMSG(droppedflag)
82 // _VOICEMSG(negative)
83 // _VOICEMSG(seenenemy)
85 .string m_globalsoundstr;
86 REGISTRY(GlobalSounds, BITS(8) - 1)
87 #define GlobalSounds_from(i) _GlobalSounds_from(i, NULL)
88 #define REGISTER_GLOBALSOUND(id, str) \
89 REGISTER(GlobalSounds, GS, id, m_id, new_pure(GlobalSound)) \
91 this.m_globalsoundstr = str; \
93 REGISTER_REGISTRY(GlobalSounds)
94 REGISTRY_SORT(GlobalSounds)
95 STATIC_INIT(GlobalSounds_renumber)
97 FOREACH(GlobalSounds, true, it.m_id = i);
99 REGISTRY_CHECK(GlobalSounds)
100 void PrecacheGlobalSound(string samplestring);
101 PRECACHE(GlobalSounds)
103 FOREACH(GlobalSounds, true, PrecacheGlobalSound(it.m_globalsoundstr));
106 REGISTER_GLOBALSOUND(STEP, "misc/footstep0 6")
107 REGISTER_GLOBALSOUND(STEP_METAL, "misc/metalfootstep0 6")
108 REGISTER_GLOBALSOUND(FALL, "misc/hitground 4")
109 REGISTER_GLOBALSOUND(FALL_METAL, "misc/metalhitground 4")
111 bool GetPlayerSoundSampleField_notFound;
112 void PrecachePlayerSounds(string f);
114 .string GetVoiceMessageSampleField(string type);
115 .string GetPlayerSoundSampleField(string type);
116 void ClearPlayerSounds(entity this);
117 float LoadPlayerSounds(entity this, string f, bool strict);
118 void UpdatePlayerSounds(entity this);
120 entity GetVoiceMessage(string type);
124 void _GlobalSound(entity this, entity gs, entity ps, string sample, float chan, float vol, float voicetype, bool fake);
125 #define GlobalSound(this, def, chan, vol, voicetype) _GlobalSound(this, def, NULL, string_null, chan, vol, voicetype, false)
126 #define GlobalSound_string(this, def, chan, vol, voicetype) _GlobalSound(this, NULL, NULL, def, chan, vol, voicetype, false)
127 #define PlayerSound(this, def, chan, vol, voicetype) _GlobalSound(this, NULL, def, string_null, chan, vol, voicetype, false)
128 #define VoiceMessage(this, def, msg) \
131 int voicetype = VM.m_playersoundvt; \
132 bool ownteam = (voicetype == VOICETYPE_TEAMRADIO); \
133 int flood = Say(this, ownteam, NULL, msg, true); \
135 if (IS_SPEC(this) || IS_OBSERVER(this) || flood < 0) fake = true; \
136 else if (flood > 0) fake = false; \
138 _GlobalSound(this, NULL, VM, string_null, CH_VOICE, VOL_BASEVOICE, voicetype, fake); \
143 string allvoicesamples;
144 STATIC_INIT(allvoicesamples)
146 FOREACH(PlayerSounds, it.instanceOfVoiceMessage, allvoicesamples = strcat(allvoicesamples, " ", it.m_playersoundstr));
147 allvoicesamples = strzone(substring(allvoicesamples, 1, -1));