Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
globalsound.qh
Go to the documentation of this file.
1#pragma once
2
3#if defined(SVQC)
4 #include <server/chat.qh>
5#endif
6
7#ifdef SVQC
12#endif
13
14// player sounds, voice messages
15
18
19REPLICATE_INIT(float, cvar_cl_autotaunt);
20REPLICATE_INIT(int, cvar_cl_voice_directional);
21REPLICATE_INIT(float, cvar_cl_voice_directional_taunt_attenuation);
22
23REGISTRY(PlayerSounds, BITS(8) - 1)
24#define REGISTER_PLAYERSOUND(id) \
25 .string _playersound_##id; \
26 REGISTER(PlayerSounds, playersound, id, m_id, new_pure(PlayerSound)) \
27 { \
28 this.m_playersoundstr = #id; \
29 this.m_playersoundfld = _playersound_##id; \
30 }
31REGISTER_REGISTRY(PlayerSounds)
32REGISTRY_SORT(PlayerSounds)
33
34REGISTRY_DEFINE_GET(PlayerSounds, NULL)
35STATIC_INIT(PlayerSounds_renumber)
36{
37 FOREACH(PlayerSounds, true, it.m_id = i);
38}
39REGISTRY_CHECK(PlayerSounds)
40
51
54#define REGISTER_VOICEMSG(id, vt, listed) \
55 .string _playersound_##id; \
56 REGISTER(PlayerSounds, playersound, id, m_id, new_pure(VoiceMessage)) \
57 { \
58 this.instanceOfVoiceMessage = listed; \
59 this.m_playersoundstr = #id; \
60 this.m_playersoundfld = _playersound_##id; \
61 this.m_playersoundvt = vt; \
62 }
63
64const int VOICETYPE_PLAYERSOUND = 10;
65const int VOICETYPE_TEAMRADIO = 11;
68const int VOICETYPE_AUTOTAUNT = 14;
69const int VOICETYPE_TAUNT = 15;
70
82
83//NOTE: some models lack sounds for these:
84REGISTER_VOICEMSG(flagcarriertakingdamage, VOICETYPE_TEAMRADIO, false)
86//NOTE: ALL models lack sounds for these (only available in default sounds currently):
95
97REGISTRY(GlobalSounds, BITS(8) - 1)
98#define REGISTER_GLOBALSOUND(id, str) \
99 REGISTER(GlobalSounds, GS, id, m_id, new_pure(GlobalSound)) \
100 { \
101 this.m_globalsoundstr = str; \
102 }
103REGISTER_REGISTRY(GlobalSounds)
104REGISTRY_SORT(GlobalSounds)
105
106REGISTRY_DEFINE_GET(GlobalSounds, NULL)
107STATIC_INIT(GlobalSounds_renumber)
108{
109 FOREACH(GlobalSounds, true, it.m_id = i);
110}
111REGISTRY_CHECK(GlobalSounds)
112void PrecacheGlobalSound(string samplestring);
113PRECACHE(GlobalSounds)
114{
115 FOREACH(GlobalSounds, true, PrecacheGlobalSound(it.m_globalsoundstr));
116}
117
118REGISTER_GLOBALSOUND(STEP, "misc/footstep0 6")
119REGISTER_GLOBALSOUND(STEP_METAL, "misc/metalfootstep0 6")
120REGISTER_GLOBALSOUND(FALL, "misc/hitground 4")
121REGISTER_GLOBALSOUND(FALL_METAL, "misc/metalhitground 4")
122
124void PrecachePlayerSounds(string f);
125//#ifdef CSQC
126 .string GetVoiceMessageSampleField(string type);
127 .string GetPlayerSoundSampleField(string type);
129 float LoadPlayerSounds(entity this, string f, bool strict);
131//#endif
132entity GetVoiceMessage(string type);
133
134string GlobalSound_sample(string pair, float r);
135
136float GlobalSound_pitch(float _pitch);
137
138#ifdef SVQC
139
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) \
145 MACRO_BEGIN \
146 entity VM = def; \
147 int voicetype = VM.m_playersoundvt; \
148 bool ownteam = (voicetype == VOICETYPE_TEAMRADIO); \
149 int flood = Say(this, ownteam, NULL, msg, true); \
150 bool fake; \
151 if (IS_SPEC(this) || IS_OBSERVER(this) || flood < 0) fake = true; \
152 else if (flood > 0) fake = false; \
153 else break; \
154 _GlobalSound(this, NULL, VM, string_null, CH_VOICE, VOL_BASEVOICE, voicetype, fake); \
155 MACRO_END
156
157#endif
158
161{
162 FOREACH(PlayerSounds, it.instanceOfVoiceMessage, allvoicesamples = strcat(allvoicesamples, " ", it.m_playersoundstr));
164}
#define BITS(n)
Definition bits.qh:9
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
#define true
Definition csprogsdefs.qh:5
#define false
Definition csprogsdefs.qh:6
entity GetVoiceMessage(string type)
void UpdatePlayerSounds(entity this)
bool LoadPlayerSounds(entity this, string f, bool strict)
string GetVoiceMessageSampleField(string type)
string GetPlayerSoundSampleField(string type)
float GlobalSound_pitch(float _pitch)
void ClearPlayerSounds(entity this)
string GlobalSound_sample(string pair, float r)
void PrecachePlayerSounds(string f)
void PrecacheGlobalSound(string samplestring)
const int VOICETYPE_LASTATTACKER
string m_globalsoundstr
bool GetPlayerSoundSampleField_notFound
#define REGISTER_VOICEMSG(id, vt, listed)
const int VOICETYPE_LASTATTACKER_ONLY
string m_playersoundfld
int m_playersoundvt
#define REGISTER_GLOBALSOUND(id, str)
bool autocvar_sv_taunt
string m_playersoundstr
string allvoicesamples
bool autocvar_g_debug_globalsounds
Use new sound handling.
Definition globalsound.qh:9
const int VOICETYPE_TAUNT
const int VOICETYPE_PLAYERSOUND
void _GlobalSound(entity this, entity gs, entity ps, string sample, float chan, float vol, float voicetype, bool fake)
const int VOICETYPE_AUTOTAUNT
bool autocvar_sv_autotaunt
bool instanceOfVoiceMessage
#define REGISTER_PLAYERSOUND(id)
const int VOICETYPE_TEAMRADIO
#define FOREACH(list, cond, body)
Definition iter.qh:19
#define REPLICATE_INIT(type, name)
Definition replicate.qh:7
string substring(string s, float start, float length)
string strzone(string s)
strcat(_("^F4Countdown stopped!"), "\n^BG", _("Teams are too unbalanced."))
#define NULL
Definition post.qh:14
#define REGISTRY_SORT(...)
Definition registry.qh:128
#define REGISTER_REGISTRY(id)
Definition registry.qh:229
#define REGISTRY(id, max)
Declare a new registry.
Definition registry.qh:26
#define REGISTRY_CHECK(id)
Definition registry.qh:175
#define REGISTRY_DEFINE_GET(id, null)
Definition registry.qh:40
entity this
Definition self.qh:72
#define STATIC_INIT(func)
during worldspawn
Definition static.qh:32
#define PRECACHE(func)
directly after STATIC_INIT_LATE
Definition static.qh:42