X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fclient%2Ftuba.qc;h=dec00043f9baf0300382d7867f0476a15ebf28c6;hb=dc647e251ac9cce3239475da19cf24cfdd24bc56;hp=6e1c1f9bd78b2ab3480a1054020fbec475edbc86;hpb=c7a28837f2a255a7cddfa46ac986b2baacaada6b;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/client/tuba.qc b/qcsrc/client/tuba.qc index 6e1c1f9bd..dec00043f 100644 --- a/qcsrc/client/tuba.qc +++ b/qcsrc/client/tuba.qc @@ -1,15 +1,4 @@ -#define TUBA_MIN -18 -#define TUBA_MAX 27 -#define TUBA_INSTRUMENTS 1 - -#define TUBA_STARTNOTE(i,n) strcat("weapons/tuba", (i ? ftos(i) : ""), "_loopnote", ftos(n), ".wav") -.float note; // note -.float attenuate; // if set, attenuate it -.float cnt; // current volume -.float count; // initial volume -.float tuba_instrument; - -float Tuba_PitchStep; +#include "tuba.qh" void tubasound(entity e, float restart) { @@ -30,7 +19,7 @@ void tubasound(entity e, float restart) f2 = 0; p2 = 1; - m = mod(e.note, Tuba_PitchStep); + m = e.note % Tuba_PitchStep; if(m) { if(e.note - m < TUBA_MIN) @@ -63,15 +52,15 @@ void tubasound(entity e, float restart) snd1 = TUBA_STARTNOTE(e.tuba_instrument, e.note); } - sound7(e, CH_TUBA, snd1, e.cnt * f1, e.attenuate * autocvar_g_balance_tuba_attenuation, 100 * p1, 0); + sound7(e, CH_TUBA_SINGLE, snd1, e.cnt * f1, e.attenuate * autocvar_g_balance_tuba_attenuation, 100 * p1, 0); if(f2) - sound7(e.enemy, CH_TUBA, snd2, e.cnt * f2, e.attenuate * autocvar_g_balance_tuba_attenuation, 100 * p2, 0); + sound7(e.enemy, CH_TUBA_SINGLE, snd2, e.cnt * f2, e.attenuate * autocvar_g_balance_tuba_attenuation, 100 * p2, 0); } else { if(restart) snd1 = TUBA_STARTNOTE(e.tuba_instrument, e.note); - sound(e, CH_TUBA, snd1, e.cnt, e.attenuate * autocvar_g_balance_tuba_attenuation); + sound(e, CH_TUBA_SINGLE, snd1, e.cnt, e.attenuate * autocvar_g_balance_tuba_attenuation); } } @@ -86,10 +75,10 @@ void Ent_TubaNote_Think() self.nextthink = time; if(self.cnt <= 0) { - sound(self, CH_TUBA, "misc/null.wav", 0, 0); + sound(self, CH_TUBA_SINGLE, "misc/null.wav", 0, 0); if(self.enemy) { - sound(self.enemy, CH_TUBA, "misc/null.wav", 0, 0); + sound(self.enemy, CH_TUBA_SINGLE, "misc/null.wav", 0, 0); remove(self.enemy); } remove(self); @@ -117,9 +106,12 @@ void Ent_TubaNote_StopSound() void Ent_TubaNote(float bIsNew) { - float f, n, i, att; + int f, n, i; + float att, upd; f = ReadByte(); + upd = 0; + if(f & 1) { n = ReadChar(); @@ -142,7 +134,7 @@ void Ent_TubaNote(float bIsNew) self.enemy.enemy = spawn(); self.enemy.enemy.classname = "tuba_note_2"; } - bIsNew = TRUE; + bIsNew = true; } self.enemy.attenuate = att; @@ -151,7 +143,7 @@ void Ent_TubaNote(float bIsNew) { self.note = n; self.tuba_instrument = i; - Ent_TubaNote_UpdateSound(); + upd = 1; } } @@ -169,11 +161,15 @@ void Ent_TubaNote(float bIsNew) self.entremove = Ent_TubaNote_StopSound; self.enemy.think = Ent_TubaNote_Think; self.enemy.nextthink = time + 10; + + if(upd) + Ent_TubaNote_UpdateSound(); } void Tuba_Precache() { - float i, n; + float i; + int n; Tuba_PitchStep = autocvar_g_balance_tuba_pitchstep; if(Tuba_PitchStep) { @@ -185,7 +181,7 @@ void Tuba_Precache() } for(n = TUBA_MIN; n <= TUBA_MAX; ++n) { - if(!Tuba_PitchStep || (mod(n, Tuba_PitchStep) == 0)) + if(!Tuba_PitchStep || ((n % Tuba_PitchStep) == 0)) { for(i = 0; i < TUBA_INSTRUMENTS; ++i) precache_sound(TUBA_STARTNOTE(i, n));