Xonotic
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
8 
9  bool autocvar_g_debug_globalsounds = false;
10  bool autocvar_sv_taunt;
11  bool autocvar_sv_autotaunt;
12 #endif
13 
14 // player sounds, voice messages
15 
18 
19 REPLICATE_INIT(float, cvar_cl_autotaunt);
20 REPLICATE_INIT(int, cvar_cl_voice_directional);
21 REPLICATE_INIT(float, cvar_cl_voice_directional_taunt_attenuation);
22 
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)) \
27  { \
28  this.m_playersoundstr = #id; \
29  this.m_playersoundfld = _playersound_##id; \
30  }
31 REGISTER_REGISTRY(PlayerSounds)
32 REGISTRY_SORT(PlayerSounds)
33 
34 REGISTRY_DEFINE_GET(PlayerSounds, NULL)
35 STATIC_INIT(PlayerSounds_renumber)
36 {
37  FOREACH(PlayerSounds, true, it.m_id = i);
38 }
39 REGISTRY_CHECK(PlayerSounds)
40 
44 REGISTER_PLAYERSOUND(falling)
47 REGISTER_PLAYERSOUND(pain100)
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 
64 const int VOICETYPE_PLAYERSOUND = 10;
65 const int VOICETYPE_TEAMRADIO = 11;
66 const int VOICETYPE_LASTATTACKER = 12;
68 const int VOICETYPE_AUTOTAUNT = 14;
69 const int VOICETYPE_TAUNT = 15;
70 
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)
82 
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)
95 
97 REGISTRY(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  }
103 REGISTER_REGISTRY(GlobalSounds)
104 REGISTRY_SORT(GlobalSounds)
105 
106 REGISTRY_DEFINE_GET(GlobalSounds, NULL)
107 STATIC_INIT(GlobalSounds_renumber)
108 {
109  FOREACH(GlobalSounds, true, it.m_id = i);
110 }
111 REGISTRY_CHECK(GlobalSounds)
112 void PrecacheGlobalSound(string samplestring);
113 PRECACHE(GlobalSounds)
114 {
115  FOREACH(GlobalSounds, true, PrecacheGlobalSound(it.m_globalsoundstr));
116 }
117 
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")
122 
124 void 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);
130  void UpdatePlayerSounds(entity this);
131 //#endif
132 entity GetVoiceMessage(string type);
133 
134 string GlobalSound_sample(string pair, float r);
135 
136 float 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 
160 STATIC_INIT(allvoicesamples)
161 {
162  FOREACH(PlayerSounds, it.instanceOfVoiceMessage, allvoicesamples = strcat(allvoicesamples, " ", it.m_playersoundstr));
163  allvoicesamples = strzone(substring(allvoicesamples, 1, -1));
164 }
REPLICATE_INIT(float, cvar_cl_autotaunt)
float LoadPlayerSounds(entity this, string f, bool strict)
Definition: globalsound.qc:263
const int VOICETYPE_PLAYERSOUND
Definition: globalsound.qh:64
#define REGISTER_PLAYERSOUND(id)
Definition: globalsound.qh:24
string m_playersoundstr
Definition: globalsound.qh:16
void PrecachePlayerSounds(string f)
Definition: globalsound.qc:222
int m_playersoundvt
Definition: globalsound.qh:53
string GetVoiceMessageSampleField(string type)
Definition: globalsound.qc:217
const int VOICETYPE_TAUNT
Definition: globalsound.qh:69
bool instanceOfVoiceMessage
Definition: globalsound.qh:52
entity() spawn
string GlobalSound_sample(string pair, float r)
Definition: globalsound.qc:150
#define REGISTER_VOICEMSG(id, vt, listed)
Definition: globalsound.qh:54
#define REGISTER_GLOBALSOUND(id, str)
Definition: globalsound.qh:98
#define false
Definition: csprogsdefs.qh:6
#define REGISTRY_CHECK(id)
Definition: registry.qh:175
const int VOICETYPE_AUTOTAUNT
Definition: globalsound.qh:68
#define REGISTRY_SORT(...)
Definition: registry.qh:128
#define bool
Definition: _all.inc:24
void ClearPlayerSounds(entity this)
Definition: globalsound.qc:252
#define REGISTER_REGISTRY(id)
Definition: registry.qh:212
#define REGISTRY_DEFINE_GET(id, null)
Definition: registry.qh:40
const int VOICETYPE_LASTATTACKER
Definition: globalsound.qh:66
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
bool GetPlayerSoundSampleField_notFound
Definition: globalsound.qh:123
float GlobalSound_pitch(float _pitch)
Definition: globalsound.qc:164
#define REGISTRY(id, max)
Declare a new registry.
Definition: registry.qh:26
#define NULL
Definition: post.qh:17
entity this
Definition: self.qh:83
void PrecacheGlobalSound(string samplestring)
Definition: globalsound.qc:176
STATIC_INIT(PlayerSounds_renumber)
Definition: globalsound.qh:35
string allvoicesamples
Definition: globalsound.qh:159
void UpdatePlayerSounds(entity this)
Definition: globalsound.qc:300
string m_playersoundfld
Definition: globalsound.qh:17
string GetPlayerSoundSampleField(string type)
Definition: globalsound.qc:247
string m_globalsoundstr
Definition: globalsound.qh:96
entity GetVoiceMessage(string type)
Definition: globalsound.qc:196
#define FOREACH(list, cond, body)
Definition: iter.qh:19
const int VOICETYPE_LASTATTACKER_ONLY
Definition: globalsound.qh:67
const int VOICETYPE_TEAMRADIO
Definition: globalsound.qh:65
#define BITS(n)
Definition: bits.qh:9
#define true
Definition: csprogsdefs.qh:5
PRECACHE(GlobalSounds)
Definition: globalsound.qh:113