From: MirceaKitsune Date: Sat, 3 Mar 2012 21:36:46 +0000 (+0200) Subject: Implement engine framework in the gamecode for changing the pitch of sounds. soundto... X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=0d0d6fcfda8598396da3c0f33e41f707827f3d25;p=voretournament%2Fvoretournament.git Implement engine framework in the gamecode for changing the pitch of sounds. soundto now supports a pitch parameter, which will be used in the commits to follow --- diff --git a/data/qcsrc/server/builtins.qh b/data/qcsrc/server/builtins.qh index 454574f7..59a1fb3e 100644 --- a/data/qcsrc/server/builtins.qh +++ b/data/qcsrc/server/builtins.qh @@ -6,7 +6,7 @@ void setsize (entity e, vector min, vector max) = #4; void crash (void) = #6; float random (void) = #7; -//void(entity e, float chan, string samp, float vol, float atten) sound = #8; +void (entity e, float chan, string samp, float vol, float atten, float pitchshift, float flags) sound7 = #8; vector normalize (vector v) = #9; void error (string e) = #10; void objerror_builtin (string e) = #11; // do not call, use objerror wrapper diff --git a/data/qcsrc/server/cl_client.qc b/data/qcsrc/server/cl_client.qc index 6f4a06ae..098f5be6 100644 --- a/data/qcsrc/server/cl_client.qc +++ b/data/qcsrc/server/cl_client.qc @@ -1961,7 +1961,7 @@ float CalcRotRegen(float current, float regenstable, float regenfactor, float re { msg_entity = self; if(clienttype(msg_entity) == CLIENTTYPE_REAL) - soundto(MSG_ONE, self, CHAN_AUTO, regensound, VOL_BASE, ATTN_NONE); + soundto(MSG_ONE, self, CHAN_AUTO, regensound, VOL_BASE, ATTN_NONE, 0); } self.regen_soundtime = time + 1; // only replay the sound if regen was paused for one second } diff --git a/data/qcsrc/server/cl_player.qc b/data/qcsrc/server/cl_player.qc index 5fccaf30..70a28021 100644 --- a/data/qcsrc/server/cl_player.qc +++ b/data/qcsrc/server/cl_player.qc @@ -1257,10 +1257,10 @@ void GlobalSound(string sample, float chan, float voicetype, float vol) { vol_apply = vol; vol_apply *= (self.predator != msg_entity.predator && self != msg_entity) ? vol_scale * vol_prey : vol_scale; - soundto(MSG_ONE, self, chan, sample, vol_apply, ATTN_MIN); + soundto(MSG_ONE, self, chan, sample, vol_apply, ATTN_MIN, 0); } else - soundto(MSG_ONE, self, chan, sample, vol, ATTN_NONE); + soundto(MSG_ONE, self, chan, sample, vol, ATTN_NONE, 0); } } break; @@ -1275,14 +1275,14 @@ void GlobalSound(string sample, float chan, float voicetype, float vol) { vol_apply = vol; vol_apply *= (self.predator != msg_entity.predator && self != msg_entity) ? vol_scale * vol_prey : vol_scale; - soundto(MSG_ONE, self, chan, sample, vol_apply, ATTN_MIN); + soundto(MSG_ONE, self, chan, sample, vol_apply, ATTN_MIN, 0); } else - soundto(MSG_ONE, self, chan, sample, vol, ATTN_NONE); + soundto(MSG_ONE, self, chan, sample, vol, ATTN_NONE, 0); } msg_entity = self; if(clienttype(msg_entity) == CLIENTTYPE_REAL) - soundto(MSG_ONE, self, chan, sample, VOL_BASE, ATTN_NONE); + soundto(MSG_ONE, self, chan, sample, VOL_BASE, ATTN_NONE, 0); } break; case VOICETYPE_TEAMRADIO: @@ -1293,10 +1293,10 @@ void GlobalSound(string sample, float chan, float voicetype, float vol) { vol_apply = vol; vol_apply *= (self.predator != msg_entity.predator && self != msg_entity) ? vol_scale * vol_prey : vol_scale; - soundto(MSG_ONE, self, chan, sample, vol_apply, ATTN_MIN); + soundto(MSG_ONE, self, chan, sample, vol_apply, ATTN_MIN, 0); } else - soundto(MSG_ONE, self, chan, sample, vol, ATTN_NONE); + soundto(MSG_ONE, self, chan, sample, vol, ATTN_NONE, 0); } break; case VOICETYPE_AUTOTAUNT: @@ -1314,10 +1314,10 @@ void GlobalSound(string sample, float chan, float voicetype, float vol) { vol_apply = vol; vol_apply *= (self.predator != msg_entity.predator && self != msg_entity) ? vol_scale * vol_prey : vol_scale; - soundto(MSG_ONE, self, chan, sample, vol_apply, bound(ATTN_MIN, msg_entity.cvar_cl_voice_directional_taunt_attenuation, ATTN_MAX)); + soundto(MSG_ONE, self, chan, sample, vol_apply, bound(ATTN_MIN, msg_entity.cvar_cl_voice_directional_taunt_attenuation, ATTN_MAX), 0); } else - soundto(MSG_ONE, self, chan, sample, vol, ATTN_NONE); + soundto(MSG_ONE, self, chan, sample, vol, ATTN_NONE, 0); } break; case VOICETYPE_TAUNT: @@ -1334,17 +1334,17 @@ void GlobalSound(string sample, float chan, float voicetype, float vol) { vol_apply = vol; vol_apply *= (self.predator != msg_entity.predator && self != msg_entity) ? vol_scale * vol_prey : vol_scale; - soundto(MSG_ONE, self, chan, sample, vol_apply, bound(ATTN_MIN, msg_entity.cvar_cl_voice_directional_taunt_attenuation, ATTN_MAX)); + soundto(MSG_ONE, self, chan, sample, vol_apply, bound(ATTN_MIN, msg_entity.cvar_cl_voice_directional_taunt_attenuation, ATTN_MAX), 0); } else - soundto(MSG_ONE, self, chan, sample, vol, ATTN_NONE); + soundto(MSG_ONE, self, chan, sample, vol, ATTN_NONE, 0); } case VOICETYPE_PLAYERSOUND: FOR_EACH_REALCLIENT(msg_entity) { vol_apply = vol; vol_apply *= (self.predator != msg_entity.predator && self != msg_entity) ? vol_scale * vol_prey : vol_scale; - soundto(MSG_ONE, self, chan, sample, vol_apply, ATTN_NORM); + soundto(MSG_ONE, self, chan, sample, vol_apply, ATTN_NORM, 0); } break; case VOICETYPE_GURGLE: diff --git a/data/qcsrc/server/miscfunctions.qc b/data/qcsrc/server/miscfunctions.qc index 4ccf1e26..2c3fff3f 100644 --- a/data/qcsrc/server/miscfunctions.qc +++ b/data/qcsrc/server/miscfunctions.qc @@ -1132,6 +1132,7 @@ float precache_sound_index (string s) = #19; #define SND_ATTENUATION 2 #define SND_LARGEENTITY 8 #define SND_LARGESOUND 16 +#define SND_SPEEDUSHORT4000 32 float sound_allowed(float dest, entity e) { @@ -1163,7 +1164,7 @@ void sound(entity e, float chan, string samp, float vol, float atten) return; sound_builtin(e, chan, samp, vol, atten); } -void soundtoat(float dest, entity e, vector o, float chan, string samp, float vol, float atten) +void soundtoat(float dest, entity e, vector o, float chan, string samp, float vol, float atten, float spd) { float entno, idx; @@ -1183,6 +1184,8 @@ void soundtoat(float dest, entity e, vector o, float chan, string samp, float vo sflags |= SND_VOLUME; if (atten != 64) sflags |= SND_ATTENUATION; + if (spd) + sflags |= SND_SPEEDUSHORT4000; if (entno >= 8192) sflags |= SND_LARGEENTITY; if (idx >= 256) @@ -1194,6 +1197,8 @@ void soundtoat(float dest, entity e, vector o, float chan, string samp, float vo WriteByte(dest, vol); if (sflags & SND_ATTENUATION) WriteByte(dest, atten); + if(sflags & SND_SPEEDUSHORT4000) + WriteShort(dest, 4000 * spd); if (sflags & SND_LARGEENTITY) { WriteShort(dest, entno); @@ -1212,7 +1217,7 @@ void soundtoat(float dest, entity e, vector o, float chan, string samp, float vo WriteCoord(dest, o_y); WriteCoord(dest, o_z); } -void soundto(float dest, entity e, float chan, string samp, float vol, float atten) +void soundto(float dest, entity e, float chan, string samp, float vol, float atten, float spd) { vector o; @@ -1220,11 +1225,11 @@ void soundto(float dest, entity e, float chan, string samp, float vol, float att return; o = e.origin + 0.5 * (e.mins + e.maxs); - soundtoat(dest, e, o, chan, samp, vol, atten); + soundtoat(dest, e, o, chan, samp, vol, atten, spd); } -void soundat(entity e, vector o, float chan, string samp, float vol, float atten) +void soundat(entity e, vector o, float chan, string samp, float vol, float atten, float spd) { - soundtoat(MSG_BROADCAST, e, o, chan, samp, vol, atten); + soundtoat(MSG_BROADCAST, e, o, chan, samp, vol, atten, spd); } void stopsoundto(float dest, entity e, float chan) { @@ -1275,7 +1280,7 @@ void play2(entity e, string filename) if (clienttype(e) == CLIENTTYPE_REAL) { msg_entity = e; - soundtoat(MSG_ONE, world, '0 0 0', CHAN_AUTO, filename, VOL_BASE, ATTN_NONE); + soundtoat(MSG_ONE, world, '0 0 0', CHAN_AUTO, filename, VOL_BASE, ATTN_NONE, 0); } } @@ -2289,7 +2294,7 @@ void SoundEntity_StartSound(entity pl, float chan, string samp, float vol, float p = pow(2, chan); if (pl.soundentity.cnt & p) return; - soundtoat(MSG_ALL, pl.soundentity, gettaginfo(pl.soundentity, 0), chan, samp, vol, attn); + soundtoat(MSG_ALL, pl.soundentity, gettaginfo(pl.soundentity, 0), chan, samp, vol, attn, 0); pl.soundentity.cnt |= p; } diff --git a/data/qcsrc/server/t_plats.qc b/data/qcsrc/server/t_plats.qc index 4a71a49a..e7ac9151 100644 --- a/data/qcsrc/server/t_plats.qc +++ b/data/qcsrc/server/t_plats.qc @@ -412,7 +412,7 @@ void spawnfunc_func_bobbing() if (self.noise != "") { precache_sound(self.noise); - soundto(MSG_INIT, self, CHAN_TRIGGER, self.noise, VOL_BASE, ATTN_IDLE); + soundto(MSG_INIT, self, CHAN_TRIGGER, self.noise, VOL_BASE, ATTN_IDLE, 0); } if (!self.speed) self.speed = 4; @@ -1660,7 +1660,7 @@ void spawnfunc_func_fourier() if (self.noise != "") { precache_sound(self.noise); - soundto(MSG_INIT, self, CHAN_TRIGGER, self.noise, VOL_BASE, ATTN_IDLE); + soundto(MSG_INIT, self, CHAN_TRIGGER, self.noise, VOL_BASE, ATTN_IDLE, 0); } if (!self.speed) @@ -1797,7 +1797,7 @@ void spawnfunc_func_vectormamamam() if (self.noise != "") { precache_sound(self.noise); - soundto(MSG_INIT, self, CHAN_TRIGGER, self.noise, VOL_BASE, ATTN_IDLE); + soundto(MSG_INIT, self, CHAN_TRIGGER, self.noise, VOL_BASE, ATTN_IDLE, 0); } if(!self.targetfactor) diff --git a/data/qcsrc/server/tturrets/units/unit_phaser.qc b/data/qcsrc/server/tturrets/units/unit_phaser.qc index 13f89e43..090b1d40 100644 --- a/data/qcsrc/server/tturrets/units/unit_phaser.qc +++ b/data/qcsrc/server/tturrets/units/unit_phaser.qc @@ -102,7 +102,7 @@ void turret_phaser_attack() setattachment(beam,self.tur_head,"tag_fire"); - soundat (self, trace_endpos, CHAN_PROJECTILE, "weapons/neximpact.wav", VOL_BASE, ATTN_NORM); + soundat (self, trace_endpos, CHAN_PROJECTILE, "weapons/neximpact.wav", VOL_BASE, ATTN_NORM, 0); if (self.tur_head.frame == 0) self.tur_head.frame = 1; diff --git a/docs/TODO.txt b/docs/TODO.txt index dbb6609a..f89bd569 100644 --- a/docs/TODO.txt +++ b/docs/TODO.txt @@ -134,4 +134,8 @@ - 0.7 BUG: Disabling g_healthsize gives a different field of view, even at 100 heatlh -- 0.7: Make sure all effects work for spectators too (such as the macro earthquake effect) \ No newline at end of file +- 0.7: Make sure all effects work for spectators too (such as the macro earthquake effect) + +- 0.7 | 0.8: Make display digits red when ammo or load are too low + +- 0.7: Precache macro hitground sound (make sure footstep one is precached too) \ No newline at end of file