]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/effects/qc/globalsound.qh
Merge branch 'master' into terencehill/hud_fixes
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / effects / qc / globalsound.qh
1 #ifndef GLOBALSOUND_H
2 #define GLOBALSOUND_H
3
4 // player sounds, voice messages
5
6 .string m_playersoundstr;
7 ..string m_playersoundfld;
8
9 REGISTRY(PlayerSounds, BITS(8) - 1)
10 #define PlayerSounds_from(i) _PlayerSounds_from(i, NULL)
11 #define REGISTER_PLAYERSOUND(id) \
12         .string _playersound_##id; \
13         REGISTER(PlayerSounds, playersound, id, m_id, new_pure(PlayerSound)) \
14         { \
15                 this.m_playersoundstr = #id; \
16                 this.m_playersoundfld = _playersound_##id; \
17         }
18 REGISTER_REGISTRY(PlayerSounds)
19 REGISTRY_SORT(PlayerSounds)
20 STATIC_INIT(PlayerSounds_renumber)
21 {
22         FOREACH(PlayerSounds, true, it.m_id = i);
23 }
24 REGISTRY_CHECK(PlayerSounds)
25
26 REGISTER_PLAYERSOUND(death)
27 REGISTER_PLAYERSOUND(drown)
28 REGISTER_PLAYERSOUND(fall)
29 REGISTER_PLAYERSOUND(falling)
30 REGISTER_PLAYERSOUND(gasp)
31 REGISTER_PLAYERSOUND(jump)
32 REGISTER_PLAYERSOUND(pain100)
33 REGISTER_PLAYERSOUND(pain25)
34 REGISTER_PLAYERSOUND(pain50)
35 REGISTER_PLAYERSOUND(pain75)
36
37 .bool instanceOfVoiceMessage;
38 .int m_playersoundvt;
39 #define REGISTER_VOICEMSG(id, vt) \
40         .string _playersound_##id; \
41         REGISTER(PlayerSounds, playersound, id, m_id, new_pure(VoiceMessage)) \
42         { \
43                 this.instanceOfVoiceMessage = true; \
44                 this.m_playersoundstr = #id; \
45                 this.m_playersoundfld = _playersound_##id; \
46                 this.m_playersoundvt = vt; \
47         }
48
49 const int VOICETYPE_PLAYERSOUND = 10;
50 const int VOICETYPE_TEAMRADIO = 11;
51 const int VOICETYPE_LASTATTACKER = 12;
52 const int VOICETYPE_LASTATTACKER_ONLY = 13;
53 const int VOICETYPE_AUTOTAUNT = 14;
54 const int VOICETYPE_TAUNT = 15;
55
56 REGISTER_VOICEMSG(attack, VOICETYPE_TEAMRADIO)
57 REGISTER_VOICEMSG(attackinfive, VOICETYPE_TEAMRADIO)
58 REGISTER_VOICEMSG(coverme, VOICETYPE_TEAMRADIO)
59 REGISTER_VOICEMSG(defend, VOICETYPE_TEAMRADIO)
60 REGISTER_VOICEMSG(freelance, VOICETYPE_TEAMRADIO)
61 REGISTER_VOICEMSG(incoming, VOICETYPE_TEAMRADIO)
62 REGISTER_VOICEMSG(meet, VOICETYPE_TEAMRADIO)
63 REGISTER_VOICEMSG(needhelp, VOICETYPE_TEAMRADIO)
64 REGISTER_VOICEMSG(seenflag, VOICETYPE_TEAMRADIO)
65 REGISTER_VOICEMSG(taunt, VOICETYPE_TAUNT)
66 REGISTER_VOICEMSG(teamshoot, VOICETYPE_LASTATTACKER)
67
68 // reserved sound names for the future (some models lack sounds for them):
69 // _VOICEMSG(flagcarriertakingdamage)
70 // _VOICEMSG(getflag)
71 // reserved sound names for the future (ALL models lack sounds for them):
72 // _VOICEMSG(affirmative)
73 // _VOICEMSG(attacking)
74 // _VOICEMSG(defending)
75 // _VOICEMSG(roaming)
76 // _VOICEMSG(onmyway)
77 // _VOICEMSG(droppedflag)
78 // _VOICEMSG(negative)
79 // _VOICEMSG(seenenemy)
80
81 .string m_globalsoundstr;
82 REGISTRY(GlobalSounds, BITS(8) - 1)
83 #define GlobalSounds_from(i) _GlobalSounds_from(i, NULL)
84 #define REGISTER_GLOBALSOUND(id, str) \
85         REGISTER(GlobalSounds, GS, id, m_id, new_pure(GlobalSound)) \
86         { \
87                 this.m_globalsoundstr = str; \
88         }
89 REGISTER_REGISTRY(GlobalSounds)
90 REGISTRY_SORT(GlobalSounds)
91 STATIC_INIT(GlobalSounds_renumber)
92 {
93         FOREACH(GlobalSounds, true, it.m_id = i);
94 }
95 REGISTRY_CHECK(GlobalSounds)
96 void PrecacheGlobalSound(string samplestring);
97 PRECACHE(GlobalSounds)
98 {
99         FOREACH(GlobalSounds, true, PrecacheGlobalSound(it.m_globalsoundstr));
100 }
101
102 REGISTER_GLOBALSOUND(STEP, "misc/footstep0 6")
103 REGISTER_GLOBALSOUND(STEP_METAL, "misc/metalfootstep0 6")
104 REGISTER_GLOBALSOUND(FALL, "misc/hitground 4")
105 REGISTER_GLOBALSOUND(FALL_METAL, "misc/metalhitground 4")
106
107 bool GetPlayerSoundSampleField_notFound;
108 void PrecachePlayerSounds(string f);
109 //#ifdef CSQC
110         .string GetVoiceMessageSampleField(string type);
111         .string GetPlayerSoundSampleField(string type);
112         void ClearPlayerSounds(entity this);
113         float LoadPlayerSounds(entity this, string f, bool strict);
114         void UpdatePlayerSounds(entity this);
115 //#endif
116
117 #ifdef SVQC
118
119         void _GlobalSound(entity this, entity gs, entity ps, string sample, float chan, float voicetype, bool fake);
120         #define GlobalSound(this, def, chan, voicetype) _GlobalSound(this, def, NULL, string_null, chan, voicetype, false)
121         #define GlobalSound_string(this, def, chan, voicetype) _GlobalSound(this, NULL, NULL, def, chan, voicetype, false)
122         #define PlayerSound(this, def, chan, voicetype) _GlobalSound(this, NULL, def, string_null, chan, voicetype, false)
123         #define VoiceMessage(this, def, msg) \
124                 MACRO_BEGIN \
125                 { \
126                         entity VM = def; \
127                         int voicetype = VM.m_playersoundvt; \
128                         bool ownteam = (voicetype == VOICETYPE_TEAMRADIO); \
129                         int flood = Say(this, ownteam, world, msg, true); \
130                         bool fake; \
131                         if (IS_SPEC(this) || IS_OBSERVER(this) || flood < 0) fake = true; \
132                         else if (flood > 0) fake = false; \
133                         else break; \
134                         _GlobalSound(this, NULL, VM, string_null, CH_VOICE, voicetype, fake); \
135                 } MACRO_END
136
137 #endif
138
139 #endif