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