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")
10 void W_Tuba_SetAmmoCounter()
12 // this weapon doesn't have a reload system, so always set the clip to 0 when switching to it
13 self.clip_load = self.clip_size = 0; // also keeps crosshair ammo from displaying
16 float Tuba_GetNote(entity pl, float hittype)
21 if(pl.movement_x < 0) movestate -= 3;
22 if(pl.movement_x > 0) movestate += 3;
23 if(pl.movement_y < 0) movestate -= 1;
24 if(pl.movement_y > 0) movestate += 1;
27 // layout: originally I wanted
31 // but then you only use forward and right key. So to make things more
32 // interesting, I swapped B with e#. Har har har...
36 case 1: note = -6; break; // Gb
37 case 2: note = -5; break; // G
38 case 3: note = -4; break; // G#
39 case 4: note = +5; break; // e#
40 case 5: note = 0; break; // c
41 case 6: note = +2; break; // d
42 case 7: note = +3; break; // eb
43 case 8: note = +4; break; // e
44 case 9: note = -1; break; // B
50 if(hittype & HITTYPE_SECONDARY)
53 // we support two kinds of tubas, those tuned in Eb and those tuned in C
54 // kind of tuba currently is player slot number, or team number if in
56 // that way, holes in the range of notes are "plugged"
59 if(pl.team == COLOR_TEAM2 || pl.team == COLOR_TEAM4)
64 if(pl.clientcolors & 1)
68 // total range of notes:
74 // *** ********************* ****
75 // -18.........................+12
76 // *** ********************* ****
77 // -18............................+15
83 float W_Tuba_NoteSendEntity(entity to, float sf)
85 WriteByte(MSG_ENTITY, ENT_CLIENT_TUBANOTE);
86 WriteByte(MSG_ENTITY, (sf & 1) | ((self.cnt + 42) * 2));
89 WriteCoord(MSG_ENTITY, self.origin_x);
90 WriteCoord(MSG_ENTITY, self.origin_y);
91 WriteCoord(MSG_ENTITY, self.origin_z);
92 WriteByte(MSG_ENTITY, self.owner != to);
97 void W_Tuba_NoteThink()
104 if(time > self.teleport_time)
106 self.owner.tuba_note = world;
110 self.nextthink = time;
111 dist_mult = autocvar_g_balance_tuba_attenuation / autocvar_snd_soundradius;
112 FOR_EACH_REALCLIENT(e)
115 v = self.origin - (e.origin + e.view_ofs);
116 vol0 = max(0, 1 - vlen(v) * dist_mult);
118 v = self.owner.origin - (e.origin + e.view_ofs);
119 vol1 = max(0, 1 - vlen(v) * dist_mult);
121 if(fabs(vol0 - vol1) > 0.005) // 0.5 percent change in volume
123 setorigin(self, self.owner.origin);
127 if(dir0 * dir1 < 0.9994) // 2 degrees change in angle
129 setorigin(self, self.owner.origin);
136 void W_Tuba_Attack(float hittype)
140 W_SetupShot(self, FALSE, 2, "", 0, autocvar_g_balance_tuba_damage);
141 if(self.tuba_notecount)
143 self.tuba_notecount = FALSE;
148 self.tuba_notecount = TRUE;
152 n = Tuba_GetNote(self, hittype);
156 if(self.tuba_note.cnt != n)
159 self.tuba_note.cnt = n;
160 self.tuba_note.SendFlags |= 2;
162 remove(self.tuba_note);
163 self.tuba_note = world;
167 if not(self.tuba_note)
169 self.tuba_note = spawn();
170 self.tuba_note.owner = self;
171 self.tuba_note.cnt = n;
172 self.tuba_note.think = W_Tuba_NoteThink;
173 self.tuba_note.nextthink = time;
174 Net_LinkEntity(self.tuba_note, FALSE, 0, W_Tuba_NoteSendEntity);
177 self.tuba_note.teleport_time = time + autocvar_g_balance_tuba_refire * 2; // so it can get prolonged safely
179 //sound(self, c, TUBA_NOTE(n), bound(0, VOL_BASE * cvar("g_balance_tuba_volume"), 1), autocvar_g_balance_tuba_attenuation);
180 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);
182 o = gettaginfo(self.exteriorweaponentity, 0);
183 if(time > self.tuba_smoketime)
185 pointparticles(particleeffectnum("smoke_ring"), o + v_up * 45 + v_right * -6 + v_forward * 8, v_up * 100, 1);
186 self.tuba_smoketime = time + 0.25;
190 void spawnfunc_weapon_tuba (void)
192 weapon_defaultspawnfunc(WEP_TUBA);
195 float w_tuba(float req)
199 // bots cannot play the Tuba well yet
200 // I think they should start with the recorder first
201 if(vlen(self.origin - self.enemy.origin) < autocvar_g_balance_tuba_radius)
204 self.BUTTON_ATCK = 1;
206 self.BUTTON_ATCK2 = 1;
209 else if (req == WR_THINK)
211 if (self.BUTTON_ATCK)
212 if (weapon_prepareattack(0, autocvar_g_balance_tuba_refire))
215 //weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_tuba_animtime, w_ready);
216 weapon_thinkf(WFRAME_IDLE, autocvar_g_balance_tuba_animtime, w_ready);
218 if (self.BUTTON_ATCK2)
219 if (weapon_prepareattack(1, autocvar_g_balance_tuba_refire))
221 W_Tuba_Attack(HITTYPE_SECONDARY);
222 //weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_tuba_animtime, w_ready);
223 weapon_thinkf(WFRAME_IDLE, autocvar_g_balance_tuba_animtime, w_ready);
227 if(!self.BUTTON_ATCK && !self.BUTTON_ATCK2)
229 remove(self.tuba_note);
230 self.tuba_note = world;
234 else if (req == WR_PRECACHE)
236 precache_model ("models/weapons/g_tuba.md3");
237 precache_model ("models/weapons/v_tuba.md3");
238 precache_model ("models/weapons/h_tuba.iqm");
241 //for(i = -18; i <= +27; ++i)
242 // precache_sound(TUBA_NOTE(i));
244 else if (req == WR_SETUP)
246 weapon_setup(WEP_TUBA);
247 W_Porto_SetAmmoCounter();
249 else if (req == WR_CHECKAMMO1)
250 return TRUE; // TODO use fuel?
251 else if (req == WR_CHECKAMMO2)
252 return TRUE; // TODO use fuel?
257 float w_tuba(float req)
259 if(req == WR_IMPACTEFFECT)
261 // nothing to do here; particles of tuba are handled differently
263 else if(req == WR_PRECACHE)
267 else if (req == WR_SUICIDEMESSAGE)
269 w_deathtypestring = _("%s hurt his own ears with the @!#%%'n Tuba");
271 else if (req == WR_KILLMESSAGE)
273 w_deathtypestring = _("%s died of %s's great playing on the @!#%%'n Tuba");