]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/client/tuba.qc
Merge remote branch 'refs/remotes/origin/mirceakitsune/menu_bob_slider'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / tuba.qc
1 #define TUBA_STARTNOTE(n) strcat((checkextension("DP_SND_SETPARAMS") ? "weapons/tuba_loopnote" : "weapons/tuba_note"), ftos(n), ".wav")
2 .float cnt; // note
3 .float attenuate; // if set, attenuate it
4
5 void Ent_TubaNote_Think()
6 {
7         float f;
8         f = cvar("g_balance_tuba_fadetime");
9         if(f > 0)
10                 self.cnt -= frametime * self.count / f;
11         else
12                 self.cnt = 0;
13         self.nextthink = time;
14         if(self.cnt <= 0)
15         {
16                 sound(self, CHAN_PROJECTILE, "misc/null.wav", 0, 0);
17                 remove(self);
18         }
19         else
20                 sound(self, CHAN_PROJECTILE, "", self.cnt, self.attenuate * cvar("g_balance_tuba_attenuation"));
21 }
22
23 void Ent_TubaNote_UpdateSound()
24 {
25         self.enemy.cnt = bound(0, VOL_BASE * cvar("g_balance_tuba_volume"), 1);
26         self.enemy.count = self.enemy.cnt;
27         sound(self.enemy, CHAN_PROJECTILE, TUBA_STARTNOTE(self.cnt), self.enemy.cnt, self.enemy.attenuate * cvar("g_balance_tuba_attenuation"));
28 }
29
30 void Ent_TubaNote_StopSound()
31 {
32         self.enemy.nextthink = time;
33         self.enemy = world;
34 }
35
36 void Ent_TubaNote(float bIsNew)
37 {
38         float f, n;
39         f = ReadByte();
40         n = floor(f / 2) - 42;
41         if(n != self.cnt || bIsNew)
42                 if(self.enemy)
43                         Ent_TubaNote_StopSound();
44         if(!self.enemy)
45         {
46                 self.enemy = spawn();
47                 self.enemy.classname = "tuba_note";
48                 bIsNew = TRUE;
49         }
50         if(f & 1)
51         {
52                 self.enemy.origin_x = ReadCoord();
53                 self.enemy.origin_y = ReadCoord();
54                 self.enemy.origin_z = ReadCoord();
55                 setorigin(self.enemy, self.enemy.origin);
56                 self.enemy.attenuate = ReadByte();
57         }
58         self.think = Ent_TubaNote_StopSound;
59         self.entremove = Ent_TubaNote_StopSound;
60         self.enemy.think = Ent_TubaNote_Think;
61         self.enemy.nextthink = time + 10;
62         if(bIsNew)
63         {
64                 self.cnt = n;
65                 Ent_TubaNote_UpdateSound();
66         }
67 }
68
69 void Tuba_Precache()
70 {
71         float i;
72         for(i = -18; i <= +27; ++i)
73         {
74                 precache_sound(TUBA_STARTNOTE(i));
75         }
76         //precache_sound(""); // we want to change volume of existing sounds
77 }