2 REGISTER_WEAPON(TUBA, w_tuba, 0, 1, WEP_FLAG_HIDDEN | WEP_TYPE_SPLASH, BOT_PICKUP_RATING_MID, "tuba", "tuba", _("@!#%'n Tuba"))
5 //#define TUBA_NOTE(n) strcat("weapons/tuba_note", ftos(n), ".wav")
8 .float tuba_instrument;
10 float Tuba_GetNote(entity pl, float hittype)
15 if(pl.movement_x < 0) movestate -= 3;
16 if(pl.movement_x > 0) movestate += 3;
17 if(pl.movement_y < 0) movestate -= 1;
18 if(pl.movement_y > 0) movestate += 1;
21 // layout: originally I wanted
25 // but then you only use forward and right key. So to make things more
26 // interesting, I swapped B with e#. Har har har...
30 case 1: note = -6; break; // Gb
31 case 2: note = -5; break; // G
32 case 3: note = -4; break; // G#
33 case 4: note = +5; break; // e#
34 case 5: note = 0; break; // c
35 case 6: note = +2; break; // d
36 case 7: note = +3; break; // eb
37 case 8: note = +4; break; // e
38 case 9: note = -1; break; // B
44 if(hittype & HITTYPE_SECONDARY)
47 // we support two kinds of tubas, those tuned in Eb and those tuned in C
48 // kind of tuba currently is player slot number, or team number if in
50 // that way, holes in the range of notes are "plugged"
53 if(pl.team == COLOR_TEAM2 || pl.team == COLOR_TEAM4)
58 if(pl.clientcolors & 1)
62 // total range of notes:
68 // *** ********************* ****
69 // -18.........................+12
70 // *** ********************* ****
71 // -18............................+15
77 float W_Tuba_NoteSendEntity(entity to, float sf)
82 if(!sound_allowed(MSG_ONE, self.realowner))
85 WriteByte(MSG_ENTITY, ENT_CLIENT_TUBANOTE);
86 WriteByte(MSG_ENTITY, sf);
89 WriteChar(MSG_ENTITY, self.cnt);
91 if(self.realowner != to)
93 f |= 2 * self.tuba_instrument;
94 WriteByte(MSG_ENTITY, f);
98 WriteCoord(MSG_ENTITY, self.origin_x);
99 WriteCoord(MSG_ENTITY, self.origin_y);
100 WriteCoord(MSG_ENTITY, self.origin_z);
105 void W_Tuba_NoteThink()
112 if(time > self.teleport_time)
114 self.realowner.tuba_note = world;
118 self.nextthink = time;
119 dist_mult = autocvar_g_balance_tuba_attenuation / autocvar_snd_soundradius;
120 FOR_EACH_REALCLIENT(e)
121 if(e != self.realowner)
123 v = self.origin - (e.origin + e.view_ofs);
124 vol0 = max(0, 1 - vlen(v) * dist_mult);
126 v = self.realowner.origin - (e.origin + e.view_ofs);
127 vol1 = max(0, 1 - vlen(v) * dist_mult);
129 if(fabs(vol0 - vol1) > 0.005) // 0.5 percent change in volume
131 setorigin(self, self.realowner.origin);
135 if(dir0 * dir1 < 0.9994) // 2 degrees change in angle
137 setorigin(self, self.realowner.origin);
144 void W_Tuba_Attack(float hittype)
149 W_SetupShot(self, FALSE, 2, "", 0, autocvar_g_balance_tuba_damage);
151 n = Tuba_GetNote(self, hittype);
154 if(self.tuba_instrument & 1)
155 hittype |= HITTYPE_SECONDARY;
156 if(self.tuba_instrument & 2)
157 hittype |= HITTYPE_BOUNCE;
158 if(self.tuba_instrument & 4)
159 hittype |= HITTYPE_HEADSHOT;
163 if(self.tuba_note.cnt != n || self.tuba_note.tuba_instrument != self.tuba_instrument)
165 remove(self.tuba_note);
166 self.tuba_note = world;
170 if not(self.tuba_note)
172 self.tuba_note = spawn();
173 self.tuba_note.owner = self.tuba_note.realowner = self;
174 self.tuba_note.cnt = n;
175 self.tuba_note.tuba_instrument = self.tuba_instrument;
176 self.tuba_note.think = W_Tuba_NoteThink;
177 self.tuba_note.nextthink = time;
178 Net_LinkEntity(self.tuba_note, FALSE, 0, W_Tuba_NoteSendEntity);
181 self.tuba_note.teleport_time = time + autocvar_g_balance_tuba_refire * 2 * W_WeaponRateFactor(); // so it can get prolonged safely
183 //sound(self, c, TUBA_NOTE(n), bound(0, VOL_BASE * cvar("g_balance_tuba_volume"), 1), autocvar_g_balance_tuba_attenuation);
184 RadiusDamage(self, self, autocvar_g_balance_tuba_damage, autocvar_g_balance_tuba_edgedamage, autocvar_g_balance_tuba_radius, world, autocvar_g_balance_tuba_force, hittype | WEP_TUBA, world);
186 o = gettaginfo(self.exteriorweaponentity, 0);
187 if(time > self.tuba_smoketime)
189 pointparticles(particleeffectnum("smoke_ring"), o + v_up * 45 + v_right * -6 + v_forward * 8, v_up * 100, 1);
190 self.tuba_smoketime = time + 0.25;
194 void spawnfunc_weapon_tuba (void)
196 weapon_defaultspawnfunc(WEP_TUBA);
199 float w_tuba(float req)
203 // bots cannot play the Tuba well yet
204 // I think they should start with the recorder first
205 if(vlen(self.origin - self.enemy.origin) < autocvar_g_balance_tuba_radius)
208 self.BUTTON_ATCK = 1;
210 self.BUTTON_ATCK2 = 1;
213 else if (req == WR_THINK)
215 if (self.BUTTON_ATCK)
216 if (weapon_prepareattack(0, autocvar_g_balance_tuba_refire))
219 //weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_tuba_animtime, w_ready);
220 weapon_thinkf(WFRAME_IDLE, autocvar_g_balance_tuba_animtime, w_ready);
222 if (self.BUTTON_ATCK2)
223 if (weapon_prepareattack(1, autocvar_g_balance_tuba_refire))
225 W_Tuba_Attack(HITTYPE_SECONDARY);
226 //weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_tuba_animtime, w_ready);
227 weapon_thinkf(WFRAME_IDLE, autocvar_g_balance_tuba_animtime, w_ready);
231 if(!self.BUTTON_ATCK && !self.BUTTON_ATCK2)
233 remove(self.tuba_note);
234 self.tuba_note = world;
238 else if (req == WR_PRECACHE)
240 precache_model ("models/weapons/g_tuba.md3");
241 precache_model ("models/weapons/v_tuba.md3");
242 precache_model ("models/weapons/h_tuba.iqm");
243 precache_model ("models/weapons/g_akordeon.md3");
244 precache_model ("models/weapons/v_akordeon.md3");
245 precache_model ("models/weapons/h_akordeon.iqm");
248 //for(i = -18; i <= +27; ++i)
249 // precache_sound(TUBA_NOTE(i));
251 else if (req == WR_SETUP)
253 weapon_setup(WEP_TUBA);
254 self.current_ammo = ammo_none;
255 self.tuba_instrument = 0;
257 else if (req == WR_RELOAD)
259 // switch to alternate instruments :)
260 if(self.weaponentity.state == WS_READY)
262 switch(self.tuba_instrument)
265 self.tuba_instrument = 1;
266 self.weaponname = "akordeon";
269 self.tuba_instrument = 0;
270 self.weaponname = "tuba";
273 W_SetupShot(self, FALSE, 0, "", 0, 0);
274 pointparticles(particleeffectnum("teleport"), w_shotorg, '0 0 0', 1);
275 self.weaponentity.state = WS_INUSE;
276 weapon_thinkf(WFRAME_RELOAD, 0.5, w_ready);
279 else if (req == WR_CHECKAMMO1)
280 return TRUE; // TODO use fuel?
281 else if (req == WR_CHECKAMMO2)
282 return TRUE; // TODO use fuel?
287 float w_tuba(float req)
289 if(req == WR_IMPACTEFFECT)
291 // nothing to do here; particles of tuba are handled differently
293 else if(req == WR_PRECACHE)
297 else if (req == WR_SUICIDEMESSAGE)
301 if(w_deathtype & HITTYPE_SECONDARY)
303 if(w_deathtype & HITTYPE_BOUNCE)
305 if(w_deathtype & HITTYPE_HEADSHOT)
311 w_deathtypestring = _("%s hurt his own ears with the @!#%%'n Tuba");
314 w_deathtypestring = _("%s hurt his own ears with the @!#%%'n Accordeon");
318 else if (req == WR_KILLMESSAGE)
322 if(w_deathtype & HITTYPE_SECONDARY)
324 if(w_deathtype & HITTYPE_BOUNCE)
326 if(w_deathtype & HITTYPE_HEADSHOT)
332 w_deathtypestring = _("%s died of %s's great playing on the @!#%%'n Tuba");
335 w_deathtypestring = _("%s died of %s's great playing on the @!#%%'n Accordeon");