1 //#define TUBA_NOTE(n) strcat("weapons/tuba_note", ftos(n), ".wav")
6 float Tuba_GetNote(entity pl, float hittype)
11 if(pl.movement_x < 0) movestate -= 3;
12 if(pl.movement_x > 0) movestate += 3;
13 if(pl.movement_y < 0) movestate -= 1;
14 if(pl.movement_y > 0) movestate += 1;
17 // layout: originally I wanted
21 // but then you only use forward and right key. So to make things more
22 // interesting, I swapped B with e#. Har har har...
26 case 1: note = -6; break; // Gb
27 case 2: note = -5; break; // G
28 case 3: note = -4; break; // G#
29 case 4: note = +5; break; // e#
30 case 5: note = 0; break; // c
31 case 6: note = +2; break; // d
32 case 7: note = +3; break; // eb
33 case 8: note = +4; break; // e
34 case 9: note = -1; break; // B
40 if(hittype & HITTYPE_SECONDARY)
43 // we support two kinds of tubas, those tuned in Eb and those tuned in C
44 // kind of tuba currently is player slot number, or team number if in
46 // that way, holes in the range of notes are "plugged"
49 if(pl.team == COLOR_TEAM2 || pl.team == COLOR_TEAM4)
54 if(pl.clientcolors & 1)
58 // total range of notes:
64 // *** ********************* ****
65 // -18.........................+12
66 // *** ********************* ****
67 // -18............................+15
73 float W_Tuba_NoteSendEntity(entity to, float sf)
75 WriteByte(MSG_ENTITY, ENT_CLIENT_TUBANOTE);
76 WriteByte(MSG_ENTITY, (sf & 1) | ((self.cnt + 42) * 2));
79 WriteCoord(MSG_ENTITY, self.origin_x);
80 WriteCoord(MSG_ENTITY, self.origin_y);
81 WriteCoord(MSG_ENTITY, self.origin_z);
86 void W_Tuba_NoteThink()
88 self.owner.tuba_note = world;
92 void W_Tuba_Attack(float hittype)
96 W_SetupShot(self, FALSE, 2, "", cvar("g_balance_tuba_damage"));
97 if(self.tuba_notecount)
99 self.tuba_notecount = FALSE;
104 self.tuba_notecount = TRUE;
108 n = Tuba_GetNote(self, hittype);
112 if(self.tuba_note.cnt != n)
115 self.tuba_note.cnt = n;
116 self.tuba_note.SendFlags |= 2;
118 remove(self.tuba_note);
119 self.tuba_note = world;
123 if not(self.tuba_note)
125 self.tuba_note = spawn();
126 self.tuba_note.owner = self;
127 self.tuba_note.cnt = n;
128 self.tuba_note.think = W_Tuba_NoteThink;
129 Net_LinkEntity(self.tuba_note, FALSE, 0, W_Tuba_NoteSendEntity);
132 self.tuba_note.nextthink = time + cvar("g_balance_tuba_refire") * 2; // so it can get prolonged safely
133 if(self.origin != self.tuba_note.origin)
135 setorigin(self.tuba_note, self.origin);
136 self.tuba_note.SendFlags |= 1;
139 //sound(self, c, TUBA_NOTE(n), bound(0, VOL_BASE * cvar("g_balance_tuba_volume"), 1), cvar("g_balance_tuba_attenuation"));
140 RadiusDamage(self, self, cvar("g_balance_tuba_damage"), cvar("g_balance_tuba_edgedamage"), cvar("g_balance_tuba_radius"), world, cvar("g_balance_tuba_force"), hittype | WEP_TUBA, world);
142 o = gettaginfo(self.exteriorweaponentity, 0);
143 if(time > self.tuba_smoketime)
145 pointparticles(particleeffectnum("smoke_ring"), o + v_up * 45 + v_right * -6 + v_forward * 8, v_up * 100, 1);
146 self.tuba_smoketime = time + 0.25;
150 void spawnfunc_weapon_tuba (void)
152 if(!sv_cheats && !cvar("developer"))
154 print("The @!#%'n Tuba awaits you... not.\n");
158 weapon_defaultspawnfunc(WEP_TUBA);
161 float w_tuba(float req)
165 // bots cannot play the Tuba well yet
166 // I think they should start with the recorder first
167 if(vlen(self.origin - self.enemy.origin) < cvar("g_balance_tuba_radius"))
170 self.BUTTON_ATCK = 1;
172 self.BUTTON_ATCK2 = 1;
175 else if (req == WR_THINK)
177 if (self.BUTTON_ATCK)
178 if (weapon_prepareattack(0, cvar("g_balance_tuba_refire")))
181 //weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_tuba_animtime"), w_ready);
182 weapon_thinkf(WFRAME_IDLE, cvar("g_balance_tuba_animtime"), w_ready);
184 if (self.BUTTON_ATCK2)
185 if (weapon_prepareattack(1, cvar("g_balance_tuba_refire")))
187 W_Tuba_Attack(HITTYPE_SECONDARY);
188 //weapon_thinkf(WFRAME_FIRE2, cvar("g_balance_tuba_animtime"), w_ready);
189 weapon_thinkf(WFRAME_IDLE, cvar("g_balance_tuba_animtime"), w_ready);
193 if(!self.BUTTON_ATCK && !self.BUTTON_ATCK2)
195 remove(self.tuba_note);
196 self.tuba_note = world;
200 else if (req == WR_PRECACHE)
202 precache_model ("models/weapons/g_tuba.md3");
203 precache_model ("models/weapons/v_tuba.md3");
204 precache_model ("models/weapons/h_tuba.dpm");
207 //for(i = -18; i <= +27; ++i)
208 // precache_sound(TUBA_NOTE(i));
210 else if (req == WR_SETUP)
211 weapon_setup(WEP_TUBA);
212 else if (req == WR_CHECKAMMO1)
213 return TRUE; // TODO use fuel?
214 else if (req == WR_CHECKAMMO2)
215 return TRUE; // TODO use fuel?
216 else if (req == WR_SUICIDEMESSAGE)
218 w_deathtypestring = "hurt his own ears with the @!#%'n Tuba";
220 else if (req == WR_KILLMESSAGE)
222 w_deathtypestring = "died of #'s great playing on the @!#%'n Tuba";