]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/tuba.qc
#include this
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / tuba.qc
index a22347fe3ca3f53ebea4acbd59eb01aa05bc684f..aeb4ebeb04cfe72e237c3713e03d6a8a04af1c5a 100644 (file)
@@ -1,15 +1,27 @@
-#define TUBA_MIN -18
-#define TUBA_MAX  27
-#define TUBA_INSTRUMENTS 3
+#if defined(CSQC)
+       #include "../dpdefs/csprogsdefs.qc"
+       #include "../common/constants.qh"
+       #include "../warpzonelib/mathlib.qh"
+       #include "../common/util.qh"
+       #include "autocvars.qh"
+       #include "main.qh"
+       #include "../csqcmodellib/cl_model.qh"
+#elif defined(MENUQC)
+#elif defined(SVQC)
+#endif
+
+const float TUBA_MIN = -18;
+const float TUBA_MAX =  27;
+const float TUBA_INSTRUMENTS = 3;
 
 #define TUBA_STARTNOTE(i,n) strcat("weapons/tuba", (i ? ftos(i) : ""), "_loopnote", ftos(n), ".wav")
-.float note; // note
+.int note; // note
 .float attenuate; // if set, attenuate it
 .float cnt; // current volume
 .float count; // initial volume
 .float tuba_instrument;
 
-float Tuba_PitchStep;
+int Tuba_PitchStep;
 
 void tubasound(entity e, float restart)
 {
@@ -30,7 +42,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 +75,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 +98,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,7 +129,8 @@ void Ent_TubaNote_StopSound()
 
 void Ent_TubaNote(float bIsNew)
 {
-       float f, n, i, att, upd;
+    int f, n, i;
+       float att, upd;
        f = ReadByte();
 
        upd = 0;
@@ -144,7 +157,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;
@@ -178,7 +191,8 @@ void Ent_TubaNote(float bIsNew)
 
 void Tuba_Precache()
 {
-       float i, n;
+       float i;
+    int n;
        Tuba_PitchStep = autocvar_g_balance_tuba_pitchstep;
        if(Tuba_PitchStep)
        {
@@ -190,7 +204,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));