4 // player sounds, voice messages
6 .string m_playersoundstr;
7 ..string m_playersoundfld;
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)) \
15 this.m_playersoundstr = #id; \
16 this.m_playersoundfld = _playersound_##id; \
18 REGISTER_REGISTRY(PlayerSounds)
19 REGISTRY_SORT(PlayerSounds)
20 STATIC_INIT(PlayerSounds_renumber)
22 FOREACH(PlayerSounds, true, it.m_id = i);
24 REGISTRY_CHECK(PlayerSounds)
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)
37 .bool instanceOfVoiceMessage;
39 #define REGISTER_VOICEMSG(id, vt) \
40 .string _playersound_##id; \
41 REGISTER(PlayerSounds, playersound, id, m_id, new_pure(VoiceMessage)) \
43 this.instanceOfVoiceMessage = true; \
44 this.m_playersoundstr = #id; \
45 this.m_playersoundfld = _playersound_##id; \
46 this.m_playersoundvt = vt; \
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;
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)
68 // reserved sound names for the future (some models lack sounds for them):
69 // _VOICEMSG(flagcarriertakingdamage)
71 // reserved sound names for the future (ALL models lack sounds for them):
72 // _VOICEMSG(affirmative)
73 // _VOICEMSG(attacking)
74 // _VOICEMSG(defending)
77 // _VOICEMSG(droppedflag)
78 // _VOICEMSG(negative)
79 // _VOICEMSG(seenenemy)
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)) \
87 this.m_globalsoundstr = str; \
89 REGISTER_REGISTRY(GlobalSounds)
90 REGISTRY_SORT(GlobalSounds)
91 STATIC_INIT(GlobalSounds_renumber)
93 FOREACH(GlobalSounds, true, it.m_id = i);
95 REGISTRY_CHECK(GlobalSounds)
96 void PrecacheGlobalSound(string samplestring);
97 PRECACHE(GlobalSounds)
99 FOREACH(GlobalSounds, true, PrecacheGlobalSound(it.m_globalsoundstr));
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")
107 bool GetPlayerSoundSampleField_notFound;
108 void PrecachePlayerSounds(string f);
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);
116 entity GetVoiceMessage(string type);
120 void _GlobalSound(entity this, entity gs, entity ps, string sample, float chan, float voicetype, bool fake);
121 #define GlobalSound(this, def, chan, voicetype) _GlobalSound(this, def, NULL, string_null, chan, voicetype, false)
122 #define GlobalSound_string(this, def, chan, voicetype) _GlobalSound(this, NULL, NULL, def, chan, voicetype, false)
123 #define PlayerSound(this, def, chan, voicetype) _GlobalSound(this, NULL, def, string_null, chan, voicetype, false)
124 #define VoiceMessage(this, def, msg) \
128 int voicetype = VM.m_playersoundvt; \
129 bool ownteam = (voicetype == VOICETYPE_TEAMRADIO); \
130 int flood = Say(this, ownteam, world, msg, true); \
132 if (IS_SPEC(this) || IS_OBSERVER(this) || flood < 0) fake = true; \
133 else if (flood > 0) fake = false; \
135 _GlobalSound(this, NULL, VM, string_null, CH_VOICE, voicetype, fake); \
140 string allvoicesamples;
141 STATIC_INIT(allvoicesamples)
143 FOREACH(PlayerSounds, it.instanceOfVoiceMessage, allvoicesamples = strcat(allvoicesamples, " ", it.m_playersoundstr));
144 allvoicesamples = strzone(substring(allvoicesamples, 1, -1));