- if(fire & 1)
- if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR(tuba, refire)))
- {
- W_Tuba_NoteOn(0);
- //weapon_thinkf(actor, WFRAME_FIRE1, autocvar_g_balance_tuba_animtime, w_ready);
- weapon_thinkf(actor, weaponentity, WFRAME_IDLE, WEP_CVAR(tuba, animtime), w_ready);
- }
- if(fire & 2)
- if(weapon_prepareattack(thiswep, actor, weaponentity, true, WEP_CVAR(tuba, refire)))
- {
- W_Tuba_NoteOn(HITTYPE_SECONDARY);
- //weapon_thinkf(actor, WFRAME_FIRE2, autocvar_g_balance_tuba_animtime, w_ready);
- weapon_thinkf(actor, weaponentity, WFRAME_IDLE, WEP_CVAR(tuba, animtime), w_ready);
- }
- if(actor.tuba_note)
- {
- if(!(fire & 1) && !(fire & 2))
- {
- WITH(entity, self, actor.tuba_note, W_Tuba_NoteOff());
+ case 0:
+ actor.(weaponentity).tuba_instrument = 1;
+ actor.(weaponentity).weaponname = "akordeon";
+ break;
+ case 1:
+ actor.(weaponentity).tuba_instrument = 2;
+ actor.(weaponentity).weaponname = "kleinbottle";
+ break;
+ case 2:
+ actor.(weaponentity).tuba_instrument = 0;
+ actor.(weaponentity).weaponname = "tuba";
+ break;
+ }
+ W_SetupShot(actor, weaponentity, false, 0, SND_Null, 0, 0);
+ Send_Effect(EFFECT_TELEPORT, w_shotorg, '0 0 0', 1);
+ actor.(weaponentity).state = WS_INUSE;
+ weapon_thinkf(actor, weaponentity, WFRAME_RELOAD, 0.5, w_ready);
+ }
+}
+#endif
+
+#ifdef SVQC
+
+// infinite ammo
+METHOD(Tuba, wr_checkammo1, bool(Tuba this, entity actor, .entity weaponentity)) { return true; }
+METHOD(Tuba, wr_checkammo2, bool(Tuba this, entity actor, .entity weaponentity)) { return true; }
+
+METHOD(Tuba, wr_suicidemessage, Notification(Tuba this))
+{
+ if (w_deathtype & HITTYPE_BOUNCE)
+ return WEAPON_KLEINBOTTLE_SUICIDE;
+ else if (w_deathtype & HITTYPE_SECONDARY)
+ return WEAPON_ACCORDEON_SUICIDE;
+ else
+ return WEAPON_TUBA_SUICIDE;
+}
+METHOD(Tuba, wr_killmessage, Notification(Tuba this))
+{
+ if (w_deathtype & HITTYPE_BOUNCE)
+ return WEAPON_KLEINBOTTLE_MURDER;
+ else if (w_deathtype & HITTYPE_SECONDARY)
+ return WEAPON_ACCORDEON_MURDER;
+ else
+ return WEAPON_TUBA_MURDER;
+}
+
+#endif
+
+#ifdef CSQC
+
+#define TUBA_STARTNOTE(i, n) _Sound_fixpath(W_Sound(strcat("tuba", (i ? ftos(i) : ""), "_loopnote", ftos(n))))
+
+const int TUBA_MIN = -18;
+const int TUBA_MAX = 27;
+const int TUBA_INSTRUMENTS = 3;
+
+entityclass(Tuba);
+class(Tuba) .int note;
+class(Tuba) .bool tuba_attenuate;
+class(Tuba) .float tuba_volume;
+class(Tuba) .float tuba_volume_initial;
+
+int Tuba_PitchStep;
+
+void tubasound(entity e, bool restart)
+{
+ string snd1 = string_null;
+ if (Tuba_PitchStep) {
+ float vol1 = 1;
+ float speed1 = 1;
+ string snd2 = string_null;
+ float vol2 = 0;
+ float speed2 = 1;
+
+ int m = pymod(e.note, Tuba_PitchStep);
+ if (m) {
+ if (e.note - m < TUBA_MIN) {
+ if (restart) {
+ snd1 = TUBA_STARTNOTE(e.tuba_instrument, e.note - m + Tuba_PitchStep);
+ }
+ speed1 = pow(2.0, (m - Tuba_PitchStep) / 12.0);
+ } else if (e.note - m + Tuba_PitchStep > TUBA_MAX) {
+ if (restart) {
+ snd1 = TUBA_STARTNOTE(e.tuba_instrument, e.note - m);
+ }
+ speed1 = pow(2.0, m / 12.0);
+ } else {
+ if (restart) {
+ snd1 = TUBA_STARTNOTE(e.tuba_instrument, e.note - m);