From 269e9b4c56d5930e0721c91bbe74a6f2a352c7d5 Mon Sep 17 00:00:00 2001 From: TimePath Date: Sat, 7 Nov 2015 20:33:29 +1100 Subject: [PATCH] Player sounds: cleanup --- qcsrc/server/cl_client.qc | 17 +- qcsrc/server/cl_player.qc | 466 +++++++++++++++++--------------------- qcsrc/server/cl_player.qh | 96 +++++--- qcsrc/server/defs.qh | 57 ----- 4 files changed, 287 insertions(+), 349 deletions(-) diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc index 4994c1936..24a63d5aa 100644 --- a/qcsrc/server/cl_client.qc +++ b/qcsrc/server/cl_client.qc @@ -175,7 +175,7 @@ void setplayermodel(entity e, string modelname) precache_model(modelname); _setmodel(e, modelname); player_setupanimsformodel(); - UpdatePlayerSounds(); + UpdatePlayerSounds(e); } /* @@ -319,6 +319,15 @@ void PutObserverInServer() self.event_damage = func_null; } +int player_getspecies(entity this) +{ + get_model_parameters(this.model, this.skin); + int s = get_model_parameters_species; + get_model_parameters(string_null, 0); + if (s < 0) return SPECIES_HUMAN; + return s; +} + .float model_randomizer; void FixPlayermodel(entity player) { @@ -395,8 +404,8 @@ void FixPlayermodel(entity player) if(chmdl || oldskin != player.skin) // model or skin has changed { - player.species = player_getspecies(); // update species - UpdatePlayerSounds(); // update skin sounds + player.species = player_getspecies(player); // update species + UpdatePlayerSounds(player); // update skin sounds } if(!teamplay) @@ -1298,7 +1307,7 @@ void ClientDisconnect () if(self.weaponorder_byimpulse) strunzone(self.weaponorder_byimpulse); - ClearPlayerSounds(); + ClearPlayerSounds(self); if(self.personal) remove(self.personal); diff --git a/qcsrc/server/cl_player.qc b/qcsrc/server/cl_player.qc index 84e905e85..bf808d8e3 100644 --- a/qcsrc/server/cl_player.qc +++ b/qcsrc/server/cl_player.qc @@ -123,17 +123,6 @@ void CopyBody(float keepvelocity) setself(this); } -float player_getspecies() -{SELFPARAM(); - float s; - get_model_parameters(self.model, self.skin); - s = get_model_parameters_species; - get_model_parameters(string_null, 0); - if(s < 0) - return SPECIES_HUMAN; - return s; -} - void player_setupanimsformodel() {SELFPARAM(); // load animation info @@ -661,12 +650,25 @@ void PlayerDamage (entity inflictor, entity attacker, float damage, int deathtyp } } -float Say(entity source, float teamsay, entity privatesay, string msgin, float floodcontrol) -// message "": do not say, just test flood control -// return value: -// 1 = accept -// 0 = reject -// -1 = fake accept +void MoveToTeam(entity client, int team_colour, int type) +{ + int lockteams_backup = lockteams; // backup any team lock + lockteams = 0; // disable locked teams + TeamchangeFrags(client); // move the players frags + SetPlayerColors(client, team_colour - 1); // set the players colour + Damage(client, client, client, 100000, DEATH_AUTOTEAMCHANGE.m_id, client.origin, '0 0 0'); // kill the player + lockteams = lockteams_backup; // restore the team lock + LogTeamchange(client.playerid, client.team, type); +} + +/** + * message "": do not say, just test flood control + * return value: + * 1 = accept + * 0 = reject + * -1 = fake accept + */ +int Say(entity source, float teamsay, entity privatesay, string msgin, bool floodcontrol) { string msgstr, colorstr, cmsgstr, namestr, fullmsgstr, sourcemsgstr, fullcmsgstr, sourcecmsgstr, colorprefix; float flood; @@ -960,345 +962,303 @@ float Say(entity source, float teamsay, entity privatesay, string msgin, float f float GetVoiceMessageVoiceType(string type) { - if(type == "taunt") - return VOICETYPE_TAUNT; - if(type == "teamshoot") - return VOICETYPE_LASTATTACKER; + if (type == "taunt") return VOICETYPE_TAUNT; + if (type == "teamshoot") return VOICETYPE_LASTATTACKER; return VOICETYPE_TEAMRADIO; } .string GetVoiceMessageSampleField(string type) { - GetPlayerSoundSampleField_notFound = 0; - switch(type) + GetPlayerSoundSampleField_notFound = false; + switch (type) { -#define _VOICEMSG(m) case #m: return playersound_##m; - ALLVOICEMSGS -#undef _VOICEMSG +#define X(m) case #m: return playersound_##m; + ALLVOICEMSGS(X) +#undef X } - GetPlayerSoundSampleField_notFound = 1; + GetPlayerSoundSampleField_notFound = true; return playersound_taunt; } .string GetPlayerSoundSampleField(string type) { - GetPlayerSoundSampleField_notFound = 0; - switch(type) + GetPlayerSoundSampleField_notFound = false; + switch (type) { -#define _VOICEMSG(m) case #m: return playersound_##m; - ALLPLAYERSOUNDS -#undef _VOICEMSG +#define X(m) case #m: return playersound_##m; + ALLPLAYERSOUNDS(X) +#undef X } - GetPlayerSoundSampleField_notFound = 1; + GetPlayerSoundSampleField_notFound = true; return playersound_taunt; } -void PrecacheGlobalSound(string samplestring) +void PrecacheGlobalSound(string sample) { - float n, i; - tokenize_console(samplestring); - n = stof(argv(1)); - if(n > 0) + int n; { - for(i = 1; i <= n; ++i) - precache_sound(strcat(argv(0), ftos(i), ".wav")); + string s = cdr(sample); + if (s) n = stof(s); + else n = 0; + } + sample = car(sample); + if (n > 0) + { + for (int i = 1; i <= n; ++i) + precache_sound(sprintf("%s%d.wav", sample, i)); } else { - precache_sound(strcat(argv(0), ".wav")); + precache_sound(sprintf("%s.wav", sample)); } } +string allvoicesamples; + void PrecachePlayerSounds(string f) { int fh = fopen(f, FILE_READ); if (fh < 0) + { + LOG_WARNINGF("Player sound file not found: %s\n", f); return; + } for (string s; (s = fgets(fh)); ) { int n = tokenize_console(s); if (n != 3) { - if (n != 0) LOG_TRACEF("Invalid sound info line: %s\n", s); + if (n != 0) LOG_WARNINGF("Invalid sound info line: %s\n", s); continue; } - PrecacheGlobalSound(strcat(argv(1), " ", argv(2))); + string file = argv(1); + string variants = argv(2); + PrecacheGlobalSound(strcat(file, " ", variants)); } fclose(fh); if (!allvoicesamples) { -#define _VOICEMSG(m) allvoicesamples = strcat(allvoicesamples, " ", #m); - ALLVOICEMSGS -#undef _VOICEMSG - allvoicesamples = strzone(substring(allvoicesamples, 1, strlen(allvoicesamples) - 1)); +#define X(m) allvoicesamples = strcat(allvoicesamples, " ", #m); + ALLVOICEMSGS(X) +#undef X + allvoicesamples = strzone(substring(allvoicesamples, 1, -1)); } } -void ClearPlayerSounds() -{SELFPARAM(); -#define _VOICEMSG(m) if(self.playersound_##m) { strunzone(self.playersound_##m); self.playersound_##m = string_null; } - ALLPLAYERSOUNDS - ALLVOICEMSGS -#undef _VOICEMSG +void ClearPlayerSounds(entity this) +{ +#define X(m) if (this.playersound_##m) { strunzone(this.playersound_##m); this.playersound_##m = string_null; } + ALLPLAYERSOUNDS(X) + ALLVOICEMSGS(X) +#undef X } -float LoadPlayerSounds(string f, float first) -{SELFPARAM(); - float fh; - string s; - var .string field; - fh = fopen(f, FILE_READ); - if(fh < 0) +bool LoadPlayerSounds(string f, bool strict) +{ + SELFPARAM(); + int fh = fopen(f, FILE_READ); + if (fh < 0) { - LOG_TRACE("Player sound file not found: ", f, "\n"); - return 0; + if (strict) LOG_WARNINGF("Player sound file not found: %s\n", f); + return false; } - while((s = fgets(fh))) + for (string s; (s = fgets(fh)); ) { - if(tokenize_console(s) != 3) + int n = tokenize_console(s); + if (n != 3) + { + if (n != 0) LOG_WARNINGF("Invalid sound info line: %s\n", s); continue; - field = GetPlayerSoundSampleField(argv(0)); - if(GetPlayerSoundSampleField_notFound) - field = GetVoiceMessageSampleField(argv(0)); - if(GetPlayerSoundSampleField_notFound) + } + string key = argv(0); + var .string field = GetPlayerSoundSampleField(key); + if (GetPlayerSoundSampleField_notFound) field = GetVoiceMessageSampleField(key); + if (GetPlayerSoundSampleField_notFound) + { + LOG_TRACEF("Invalid sound info field: %s\n", key); continue; - if (self.(field)) - strunzone(self.(field)); - self.(field) = strzone(strcat(argv(1), " ", argv(2))); + } + string file = argv(1); + string variants = argv(2); + if (self.(field)) strunzone(self.(field)); + self.(field) = strzone(strcat(file, " ", variants)); } fclose(fh); - return 1; + return true; } -void UpdatePlayerSounds() -{SELFPARAM(); - if(self.modelindex == self.modelindex_for_playersound) - if(self.skin == self.skin_for_playersound) - return; - self.modelindex_for_playersound = self.modelindex; - self.skin_for_playersound = self.skin; - ClearPlayerSounds(); - LoadPlayerSounds("sound/player/default.sounds", 1); - if(!autocvar_g_debug_defaultsounds) - if(!LoadPlayerSounds(get_model_datafilename(self.model, self.skin, "sounds"), 0)) - LoadPlayerSounds(get_model_datafilename(self.model, 0, "sounds"), 0); -} - -void FakeGlobalSound(string sample, float chan, float voicetype) -{SELFPARAM(); - float n; - float tauntrand; - - if(sample == "") - return; +.int modelindex_for_playersound; +.int skin_for_playersound; - tokenize_console(sample); - n = stof(argv(1)); - if(n > 0) - sample = strcat(argv(0), ftos(floor(random() * n + 1)), ".wav"); // randomization - else - sample = strcat(argv(0), ".wav"); // randomization +void UpdatePlayerSounds(entity this) +{ + if (this.modelindex == this.modelindex_for_playersound && this.skin == this.skin_for_playersound) return; + this.modelindex_for_playersound = this.modelindex; + this.skin_for_playersound = this.skin; + ClearPlayerSounds(this); + LoadPlayerSounds("sound/player/default.sounds", true); + if (autocvar_g_debug_defaultsounds) return; + if (!LoadPlayerSounds(get_model_datafilename(this.model, this.skin, "sounds"), false)) + LoadPlayerSounds(get_model_datafilename(this.model, 0, "sounds"), true); +} - switch(voicetype) +void FakeGlobalSound(string sample, int chan, int voicetype) +{ + SELFPARAM(); + if (sample == "") return; + int n; + { + string s = cdr(sample); + if (s) n = stof(s); + else n = 0; + } + sample = car(sample); + if (n > 0) sample = sprintf("%s%d.wav", sample, floor(random() * n + 1)); // randomization + else sample = sprintf("%s.wav", sample); + switch (voicetype) { case VOICETYPE_LASTATTACKER_ONLY: - break; case VOICETYPE_LASTATTACKER: - if(self.pusher) - { - msg_entity = self; - if(IS_REAL_CLIENT(msg_entity)) - soundto(MSG_ONE, self, chan, sample, VOL_BASE, ATTEN_NONE); - } + { + if (voicetype == VOICETYPE_LASTATTACKER_ONLY) break; + msg_entity = this; + if (IS_REAL_CLIENT(msg_entity)) soundto(MSG_ONE, this, chan, sample, VOL_BASE, ATTEN_NONE); break; + } case VOICETYPE_TEAMRADIO: - msg_entity = self; - if(msg_entity.cvar_cl_voice_directional == 1) - soundto(MSG_ONE, self, chan, sample, VOL_BASEVOICE, ATTEN_MIN); - else - soundto(MSG_ONE, self, chan, sample, VOL_BASEVOICE, ATTEN_NONE); + { + msg_entity = this; + float atten = (msg_entity.cvar_cl_voice_directional == 1) ? ATTEN_MIN : ATTEN_NONE; + soundto(MSG_ONE, this, chan, sample, VOL_BASEVOICE, atten); break; + } case VOICETYPE_AUTOTAUNT: - if(!sv_autotaunt) - break; - if(!sv_taunt) - break; - if(autocvar_sv_gentle) - break; - tauntrand = random(); - msg_entity = self; - if (tauntrand < msg_entity.cvar_cl_autotaunt) + case VOICETYPE_TAUNT: + { + if (voicetype == VOICETYPE_AUTOTAUNT) if (!sv_autotaunt) break; else {} + else if (IS_PLAYER(this) && this.deadflag == DEAD_NO) animdecide_setaction(this, ANIMACTION_TAUNT, true); + if (!sv_taunt) break; + if (autocvar_sv_gentle) break; + float tauntrand = 0; + if (voicetype == VOICETYPE_AUTOTAUNT) tauntrand = random(); + msg_entity = this; + if (voicetype != VOICETYPE_AUTOTAUNT || tauntrand < msg_entity.cvar_cl_autotaunt) { - if (msg_entity.cvar_cl_voice_directional >= 1) - soundto(MSG_ONE, self, chan, sample, VOL_BASEVOICE, bound(ATTEN_MIN, msg_entity.cvar_cl_voice_directional_taunt_attenuation, ATTEN_MAX)); - else - soundto(MSG_ONE, self, chan, sample, VOL_BASEVOICE, ATTEN_NONE); + float atten = (msg_entity.cvar_cl_voice_directional >= 1) + ? bound(ATTEN_MIN, msg_entity.cvar_cl_voice_directional_taunt_attenuation, ATTEN_MAX) + : ATTEN_NONE; + soundto(MSG_ONE, this, chan, sample, VOL_BASEVOICE, atten); } break; - case VOICETYPE_TAUNT: - if(IS_PLAYER(self)) - if(self.deadflag == DEAD_NO) - animdecide_setaction(self, ANIMACTION_TAUNT, true); - if(!sv_taunt) - break; - if(autocvar_sv_gentle) - break; - msg_entity = self; - if (msg_entity.cvar_cl_voice_directional >= 1) - soundto(MSG_ONE, self, chan, sample, VOL_BASEVOICE, bound(ATTEN_MIN, msg_entity.cvar_cl_voice_directional_taunt_attenuation, ATTEN_MAX)); - else - soundto(MSG_ONE, self, chan, sample, VOL_BASEVOICE, ATTEN_NONE); - break; + } case VOICETYPE_PLAYERSOUND: - msg_entity = self; - soundto(MSG_ONE, self, chan, sample, VOL_BASE, ATTEN_NORM); + { + msg_entity = this; + soundto(MSG_ONE, this, chan, sample, VOL_BASE, ATTEN_NORM); break; + } default: + { backtrace("Invalid voice type!"); break; + } } } -void GlobalSound(string sample, float chan, float voicetype) -{SELFPARAM(); - float n; - float tauntrand; - - if(sample == "") - return; - - tokenize_console(sample); - n = stof(argv(1)); - if(n > 0) - sample = strcat(argv(0), ftos(floor(random() * n + 1)), ".wav"); // randomization - else - sample = strcat(argv(0), ".wav"); // randomization - - switch(voicetype) +void GlobalSound(string sample, int chan, int voicetype) +{ + SELFPARAM(); + if (sample == "") return; + int n; + { + string s = cdr(sample); + if (s) n = stof(s); + else n = 0; + } + sample = car(sample); + if (n > 0) sample = sprintf("%s%d.wav", sample, floor(random() * n + 1)); // randomization + else sample = sprintf("%s.wav", sample); + switch (voicetype) { case VOICETYPE_LASTATTACKER_ONLY: - if(self.pusher) - { - msg_entity = self.pusher; - if(IS_REAL_CLIENT(msg_entity)) - { - if(msg_entity.cvar_cl_voice_directional == 1) - soundto(MSG_ONE, self, chan, sample, VOL_BASEVOICE, ATTEN_MIN); - else - soundto(MSG_ONE, self, chan, sample, VOL_BASEVOICE, ATTEN_NONE); - } - } - break; case VOICETYPE_LASTATTACKER: - if(self.pusher) - { - msg_entity = self.pusher; - if(IS_REAL_CLIENT(msg_entity)) - { - if(msg_entity.cvar_cl_voice_directional == 1) - soundto(MSG_ONE, self, chan, sample, VOL_BASEVOICE, ATTEN_MIN); - else - soundto(MSG_ONE, self, chan, sample, VOL_BASEVOICE, ATTEN_NONE); - } - msg_entity = self; - if(IS_REAL_CLIENT(msg_entity)) - soundto(MSG_ONE, self, chan, sample, VOL_BASE, ATTEN_NONE); - } + { + if (!this.pusher) break; + msg_entity = this.pusher; + if (IS_REAL_CLIENT(msg_entity)) + { + float atten = (msg_entity.cvar_cl_voice_directional == 1) ? ATTEN_MIN : ATTEN_NONE; + soundto(MSG_ONE, this, chan, sample, VOL_BASEVOICE, atten); + } + if (voicetype == VOICETYPE_LASTATTACKER_ONLY) break; + msg_entity = this; + if (IS_REAL_CLIENT(msg_entity)) soundto(MSG_ONE, this, chan, sample, VOL_BASE, ATTEN_NONE); break; + } case VOICETYPE_TEAMRADIO: + { FOR_EACH_REALCLIENT(msg_entity) - if(!teamplay || msg_entity.team == self.team) - { - if(msg_entity.cvar_cl_voice_directional == 1) - soundto(MSG_ONE, self, chan, sample, VOL_BASEVOICE, ATTEN_MIN); - else - soundto(MSG_ONE, self, chan, sample, VOL_BASEVOICE, ATTEN_NONE); - } + if (!teamplay || msg_entity.team == this.team) + { + float atten = (msg_entity.cvar_cl_voice_directional == 1) ? ATTEN_MIN : ATTEN_NONE; + soundto(MSG_ONE, this, chan, sample, VOL_BASEVOICE, atten); + } break; + } case VOICETYPE_AUTOTAUNT: - if(!sv_autotaunt) - break; - if(!sv_taunt) - break; - if(autocvar_sv_gentle) - break; - tauntrand = random(); - FOR_EACH_REALCLIENT(msg_entity) - if (tauntrand < msg_entity.cvar_cl_autotaunt) - { - if (msg_entity.cvar_cl_voice_directional >= 1) - soundto(MSG_ONE, self, chan, sample, VOL_BASEVOICE, bound(ATTEN_MIN, msg_entity.cvar_cl_voice_directional_taunt_attenuation, ATTEN_MAX)); - else - soundto(MSG_ONE, self, chan, sample, VOL_BASEVOICE, ATTEN_NONE); - } - break; case VOICETYPE_TAUNT: - if(IS_PLAYER(self)) - if(self.deadflag == DEAD_NO) - animdecide_setaction(self, ANIMACTION_TAUNT, true); - if(!sv_taunt) - break; - if(autocvar_sv_gentle) - break; + { + if (voicetype == VOICETYPE_AUTOTAUNT) if (!sv_autotaunt) break; else {} + else if (IS_PLAYER(this) && this.deadflag == DEAD_NO) animdecide_setaction(this, ANIMACTION_TAUNT, true); + if (!sv_taunt) break; + if (autocvar_sv_gentle) break; + float tauntrand = 0; + if (voicetype == VOICETYPE_AUTOTAUNT) tauntrand = random(); FOR_EACH_REALCLIENT(msg_entity) + if (voicetype != VOICETYPE_AUTOTAUNT || tauntrand < msg_entity.cvar_cl_autotaunt) { - if (msg_entity.cvar_cl_voice_directional >= 1) - soundto(MSG_ONE, self, chan, sample, VOL_BASEVOICE, bound(ATTEN_MIN, msg_entity.cvar_cl_voice_directional_taunt_attenuation, ATTEN_MAX)); - else - soundto(MSG_ONE, self, chan, sample, VOL_BASEVOICE, ATTEN_NONE); + float atten = (msg_entity.cvar_cl_voice_directional >= 1) + ? bound(ATTEN_MIN, msg_entity.cvar_cl_voice_directional_taunt_attenuation, ATTEN_MAX) + : ATTEN_NONE; + soundto(MSG_ONE, this, chan, sample, VOL_BASEVOICE, atten); } break; + } case VOICETYPE_PLAYERSOUND: - _sound(self, chan, sample, VOL_BASE, ATTEN_NORM); + { + _sound(this, chan, sample, VOL_BASE, ATTEN_NORM); break; + } default: + { backtrace("Invalid voice type!"); break; + } } } void PlayerSound(.string samplefield, float chan, float voicetype) -{SELFPARAM(); - GlobalSound(self.(samplefield), chan, voicetype); +{ + SELFPARAM(); + GlobalSound(this.(samplefield), chan, voicetype); } void VoiceMessage(string type, string msg) -{SELFPARAM(); - float voicetype, ownteam; - float flood; +{ + SELFPARAM(); var .string sample = GetVoiceMessageSampleField(type); - - if(GetPlayerSoundSampleField_notFound) + if (GetPlayerSoundSampleField_notFound) { - sprint(self, strcat("Invalid voice. Use one of: ", allvoicesamples, "\n")); + sprint(this, sprintf("Invalid voice. Use one of: %s\n", allvoicesamples)); return; } - - voicetype = GetVoiceMessageVoiceType(type); - ownteam = (voicetype == VOICETYPE_TEAMRADIO); - - flood = Say(self, ownteam, world, msg, 1); - - if (IS_SPEC(self) || IS_OBSERVER(self) || flood < 0) - FakeGlobalSound(self.(sample), CH_VOICE, voicetype); - else if (flood > 0) - GlobalSound(self.(sample), CH_VOICE, voicetype); -} - -void MoveToTeam(entity client, float team_colour, float type) -{ - float lockteams_backup; - - lockteams_backup = lockteams; // backup any team lock - - lockteams = 0; // disable locked teams - - TeamchangeFrags(client); // move the players frags - SetPlayerColors(client, team_colour - 1); // set the players colour - Damage(client, client, client, 100000, DEATH_AUTOTEAMCHANGE.m_id, client.origin, '0 0 0'); // kill the player - - lockteams = lockteams_backup; // restore the team lock - - LogTeamchange(client.playerid, client.team, type); + int voicetype = GetVoiceMessageVoiceType(type); + bool ownteam = (voicetype == VOICETYPE_TEAMRADIO); + 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 + : func_null; + if (f) f(this.(sample), CH_VOICE, voicetype); } diff --git a/qcsrc/server/cl_player.qh b/qcsrc/server/cl_player.qh index c96399f19..83ca3282f 100644 --- a/qcsrc/server/cl_player.qh +++ b/qcsrc/server/cl_player.qh @@ -10,13 +10,11 @@ void CopyBody_Think(); void CopyBody(float keepvelocity); -float player_getspecies(); - void player_setupanimsformodel(); -void player_anim (); +void player_anim(); -void PlayerCorpseDamage (entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force); +void PlayerCorpseDamage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force); // g__str: // If 0, default is used. @@ -25,51 +23,79 @@ void PlayerCorpseDamage (entity inflictor, entity attacker, float damage, int de // For consistency, negative values there are mapped to zero too. #define GAMETYPE_DEFAULTED_SETTING(str) \ ((gametype_setting_tmp = cvar(strcat("g_", GetGametype(), "_" #str))), \ - (gametype_setting_tmp < 0) ? 0 : \ - (gametype_setting_tmp == 0 || autocvar_g_respawn_delay_forced) ? max(0, autocvar_g_##str) : \ - gametype_setting_tmp) - + (gametype_setting_tmp < 0) ? 0 \ + : (gametype_setting_tmp == 0 || autocvar_g_respawn_delay_forced) ? max(0, autocvar_g_##str) \ + : gametype_setting_tmp) void calculate_player_respawn_time(); void ClientKill_Now_TeamChange(); -void PlayerDamage (entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force); - -.float muted; // to be used by prvm_edictset server playernumber muted 1 -float Say(entity source, float teamsay, entity privatesay, string msgin, float floodcontrol); -// message "": do not say, just test flood control -// return value: -// 1 = accept -// 0 = reject -// -1 = fake accept +void MoveToTeam(entity client, float team_colour, float type); +void PlayerDamage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force); + +/** to be used by `prvm_edictset server playernumber muted 1` */ +.float muted; +int Say(entity source, float teamsay, entity privatesay, string msgin, float floodcontrol); + +// player sounds, voice messages +// TODO implemented fall and falling +#define ALLPLAYERSOUNDS(X) \ + X(death) \ + X(drown) \ + X(fall) \ + X(falling) \ + X(gasp) \ + X(jump) \ + X(pain100) \ + X(pain25) \ + X(pain50) \ + X(pain75) + +#define ALLVOICEMSGS(X) \ + X(attack) \ + X(attackinfive) \ + X(coverme) \ + X(defend) \ + X(freelance) \ + X(incoming) \ + X(meet) \ + X(needhelp) \ + X(seenflag) \ + X(taunt) \ + X(teamshoot) + +// reserved sound names for the future (some models lack sounds for them): +// _VOICEMSG(flagcarriertakingdamage) +// _VOICEMSG(getflag) +// reserved sound names for the future (ALL models lack sounds for them): +// _VOICEMSG(affirmative) +// _VOICEMSG(attacking) +// _VOICEMSG(defending) +// _VOICEMSG(roaming) +// _VOICEMSG(onmyway) +// _VOICEMSG(droppedflag) +// _VOICEMSG(negative) +// _VOICEMSG(seenenemy) + +#define X(m) .string playersound_##m; +ALLPLAYERSOUNDS(X) +ALLVOICEMSGS(X) +#undef X + +bool GetPlayerSoundSampleField_notFound; float GetVoiceMessageVoiceType(string type); - -string allvoicesamples; .string GetVoiceMessageSampleField(string type); - .string GetPlayerSoundSampleField(string type); - void PrecacheGlobalSound(string samplestring); - void PrecachePlayerSounds(string f); - -void ClearPlayerSounds(); - -float LoadPlayerSounds(string f, float first); - -.int modelindex_for_playersound; -.int skin_for_playersound; -void UpdatePlayerSounds(); - +void ClearPlayerSounds(entity this); +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 PlayerSound(.string samplefield, float chan, float voicetype); - void VoiceMessage(string type, string msg); -void MoveToTeam(entity client, float team_colour, float type); #endif diff --git a/qcsrc/server/defs.qh b/qcsrc/server/defs.qh index f4053cb33..2a4c93966 100644 --- a/qcsrc/server/defs.qh +++ b/qcsrc/server/defs.qh @@ -303,52 +303,6 @@ float tracebox_hits_trigger_hurt(vector start, vector mi, vector ma, vector end) float next_pingtime; -// player sounds, voice messages -// TODO implemented fall and falling -#define ALLPLAYERSOUNDS \ - _VOICEMSG(death) \ - _VOICEMSG(drown) \ - _VOICEMSG(fall) \ - _VOICEMSG(falling) \ - _VOICEMSG(gasp) \ - _VOICEMSG(jump) \ - _VOICEMSG(pain100) \ - _VOICEMSG(pain25) \ - _VOICEMSG(pain50) \ - _VOICEMSG(pain75) - -#define ALLVOICEMSGS \ - _VOICEMSG(attack) \ - _VOICEMSG(attackinfive) \ - _VOICEMSG(coverme) \ - _VOICEMSG(defend) \ - _VOICEMSG(freelance) \ - _VOICEMSG(incoming) \ - _VOICEMSG(meet) \ - _VOICEMSG(needhelp) \ - _VOICEMSG(seenflag) \ - _VOICEMSG(taunt) \ - _VOICEMSG(teamshoot) - -#define _VOICEMSG(m) .string playersound_##m; -ALLPLAYERSOUNDS -ALLVOICEMSGS -#undef _VOICEMSG - -// reserved sound names for the future (some models lack sounds for them): -// _VOICEMSG(flagcarriertakingdamage) \ -// _VOICEMSG(getflag) \ -// reserved sound names for the future (ALL models lack sounds for them): -// _VOICEMSG(affirmative) \ -// _VOICEMSG(attacking) \ -// _VOICEMSG(defending) \ -// _VOICEMSG(roaming) \ -// _VOICEMSG(onmyway) \ -// _VOICEMSG(droppedflag) \ -// _VOICEMSG(negative) \ -// _VOICEMSG(seenenemy) \ -// /**/ - string globalsound_fall; string globalsound_metalfall; string globalsound_step; @@ -361,17 +315,6 @@ const float VOICETYPE_LASTATTACKER_ONLY = 13; const float VOICETYPE_AUTOTAUNT = 14; const float VOICETYPE_TAUNT = 15; -void PrecachePlayerSounds(string f); -void PrecacheGlobalSound(string samplestring); -void UpdatePlayerSounds(); -void ClearPlayerSounds(); -void PlayerSound(.string samplefield, float channel, float voicetype); -void GlobalSound(string samplestring, float channel, float voicetype); -void FakeGlobalSound(string samplestring, float channel, float voicetype); -void VoiceMessage(string type, string message); -float GetPlayerSoundSampleField_notFound; -.string GetVoiceMessageSampleField(string type); - // autotaunt system .float cvar_cl_autotaunt; .float cvar_cl_voice_directional; -- 2.39.2