]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/client/tuba.qc
WAY better tuba thanks to CSQC magic.
[divverent/nexuiz.git] / data / qcsrc / client / tuba.qc
1 //#define TUBA_STARTNOTE(n) strcat("weapons/tuba_startnote", ftos(n), ".wav")
2 //#define TUBA_STOPNOTE(n) strcat("weapons/tuba_stopnote", ftos(n), ".wav")
3 #define TUBA_STARTNOTE(n) strcat("weapons/tuba_note", ftos(n), ".wav")
4 #define TUBA_STOPNOTE(n) ""
5 .float cnt; // note
6
7 void Ent_TubaNote_UpdateSound()
8 {
9         sound(self, CHAN_PROJECTILE, TUBA_STARTNOTE(self.cnt), bound(0, VOL_BASE * cvar("g_balance_tuba_volume"), 1), cvar("g_balance_tuba_attenuation"));
10 }
11
12 void Ent_TubaNote_StopSound()
13 {
14         sound(self, CHAN_PROJECTILE, TUBA_STOPNOTE(self.cnt), bound(0, VOL_BASE * cvar("g_balance_tuba_volume"), 1), cvar("g_balance_tuba_attenuation"));
15 }
16
17 void Ent_TubaNote(float bIsNew)
18 {
19         float f, n;
20         f = ReadByte();
21         n = floor(f / 2) - 42;
22         if(f & 1)
23         {
24                 self.origin_x = ReadCoord();
25                 self.origin_y = ReadCoord();
26                 self.origin_z = ReadCoord();
27                 setorigin(self, self.origin);
28         }
29         self.think = Ent_TubaNote_StopSound;
30         self.entremove = Ent_TubaNote_StopSound;
31         self.nextthink = time + 10;
32         if(n != self.cnt || bIsNew)
33         {
34                 self.cnt = n;
35                 Ent_TubaNote_UpdateSound();
36         }
37 }
38
39 void Tuba_Precache()
40 {
41         float i;
42         for(i = -18; i <= +27; ++i)
43         {
44                 precache_sound(TUBA_STARTNOTE(i));
45                 //precache_sound(TUBA_STOPNOTE(i));
46         }
47 }