if(delaytoo)
if(time < self.msound_delay)
return; // too early
- GlobalSound(self.(samplefield), chan, VOICETYPE_PLAYERSOUND);
+ _GlobalSound(self.(samplefield), chan, VOICETYPE_PLAYERSOUND);
self.msound_delay = time + sound_delay;
}
if (!(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOSTEPS))
{
if (trace_dphitq3surfaceflags & Q3SURFACEFLAG_METALSTEPS)
- GlobalSound(globalsound_metalfall, CH_PLAYER, VOICETYPE_PLAYERSOUND);
+ GlobalSound(GS_FALL_METAL, CH_PLAYER, VOICETYPE_PLAYERSOUND);
else
- GlobalSound(globalsound_fall, CH_PLAYER, VOICETYPE_PLAYERSOUND);
+ GlobalSound(GS_FALL, CH_PLAYER, VOICETYPE_PLAYERSOUND);
}
}
}
return ret;
}
-float GetVoiceMessageVoiceType(string type)
+int GetVoiceMessageVoiceType(string type)
{
if (type == "taunt") return VOICETYPE_TAUNT;
if (type == "teamshoot") return VOICETYPE_LASTATTACKER;
}
}
-void GlobalSound(string sample, int chan, int voicetype)
+void _GlobalSound(string sample, int chan, int voicetype)
{
SELFPARAM();
if (sample == "") return;
}
}
-void PlayerSound(.string samplefield, float chan, float voicetype)
+void PlayerSound(.string samplefield, int chan, float voicetype)
{
SELFPARAM();
- GlobalSound(this.(samplefield), chan, voicetype);
+ _GlobalSound(this.(samplefield), chan, voicetype);
}
void VoiceMessage(string type, string msg)
int flood = Say(this, ownteam, world, msg, true);
void(string sample, int chan, int voicetype) f;
f = (IS_SPEC(this) || IS_OBSERVER(this) || flood < 0) ? FakeGlobalSound
- : (flood > 0) ? GlobalSound
+ : (flood > 0) ? _GlobalSound
: func_null;
if (f) f(this.(sample), CH_VOICE, voicetype);
}
float LoadPlayerSounds(string f, bool strict);
void UpdatePlayerSounds(entity this);
void FakeGlobalSound(string sample, float chan, float voicetype);
-void GlobalSound(string sample, float chan, float voicetype);
+void _GlobalSound(string sample, float chan, float voicetype);
+#define GlobalSound(def, chan, voicetype) _GlobalSound((def).m_globalsoundstr, chan, voicetype)
void PlayerSound(.string samplefield, float chan, float voicetype);
void VoiceMessage(string type, string msg);
+.string m_globalsoundstr;
+REGISTRY(GlobalSounds, BITS(8) - 1)
+#define GlobalSounds_from(i) _GlobalSounds_from(i, NULL)
+#define REGISTER_GLOBALSOUND(id, str) \
+ REGISTER(RegisterGlobalSounds, GS, GlobalSounds, id, m_id, new(GlobalSound)) \
+ { \
+ make_pure(this); \
+ this.m_globalsoundstr = str; \
+ }
+REGISTER_REGISTRY(RegisterGlobalSounds)
+REGISTRY_SORT(GlobalSounds, 0)
+REGISTRY_CHECK(GlobalSounds)
+PRECACHE(GlobalSounds)
+{
+ FOREACH(GlobalSounds, true, LAMBDA(PrecacheGlobalSound(it.m_globalsoundstr)));
+}
+
+REGISTER_GLOBALSOUND(STEP, "misc/footstep0 6")
+REGISTER_GLOBALSOUND(STEP_METAL, "misc/metalfootstep0 6")
+REGISTER_GLOBALSOUND(FALL, "misc/hitground 4")
+REGISTER_GLOBALSOUND(FALL_METAL, "misc/metalhitground 4")
+
#endif
float next_pingtime;
-string globalsound_fall;
-string globalsound_metalfall;
-string globalsound_step;
-string globalsound_metalstep;
-
const float VOICETYPE_PLAYERSOUND = 10;
const float VOICETYPE_TEAMRADIO = 11;
const float VOICETYPE_LASTATTACKER = 12;
precache_playermodels(autocvar_sv_defaultplayermodel);
}
- if (g_footsteps)
- {
- PrecacheGlobalSound((globalsound_step = "misc/footstep0 6"));
- PrecacheGlobalSound((globalsound_metalstep = "misc/metalfootstep0 6"));
- }
-
- // gore and miscellaneous sounds
- PrecacheGlobalSound((globalsound_fall = "misc/hitground 4"));
- PrecacheGlobalSound((globalsound_metalfall = "misc/metalhitground 4"));
-
#if 0
// Disabled this code because it simply does not work (e.g. ignores bgmvolume, overlaps with "cd loop" controlled tracks).
if (!(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOSTEPS))
{
if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_METALSTEPS)
- GlobalSound(globalsound_metalstep, CH_PLAYER, VOICETYPE_PLAYERSOUND);
+ GlobalSound(GS_STEP_METAL, CH_PLAYER, VOICETYPE_PLAYERSOUND);
else
- GlobalSound(globalsound_step, CH_PLAYER, VOICETYPE_PLAYERSOUND);
+ GlobalSound(GS_STEP, CH_PLAYER, VOICETYPE_PLAYERSOUND);
}
}
}