]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/weapons/weapon/tuba.qc
Give W_SetupShot a deathtype parameter, fixes some ugly hacks
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / weapons / weapon / tuba.qc
index 09d050833b46de6323e9cf880cce3c80b2b2cd44..5d9abce339ef5b5b909831f3de44defb55c974ab 100644 (file)
@@ -1,47 +1,4 @@
 #include "tuba.qh"
-#ifndef IMPLEMENTATION
-CLASS(Tuba, Weapon)
-/* impulse   */ ATTRIB(Tuba, impulse, int, 1);
-/* flags     */ ATTRIB(Tuba, spawnflags, int, WEP_FLAG_HIDDEN | WEP_TYPE_SPLASH);
-/* rating    */ ATTRIB(Tuba, bot_pickupbasevalue, float, BOT_PICKUP_RATING_MID);
-/* color     */ ATTRIB(Tuba, wpcolor, vector, '0 1 0');
-/* modelname */ ATTRIB(Tuba, mdl, string, "tuba");
-#ifdef GAMEQC
-/* model     */ ATTRIB(Tuba, m_model, Model, MDL_TUBA_ITEM);
-#endif
-/* crosshair */ ATTRIB(Tuba, w_crosshair, string, "gfx/crosshairtuba");
-/* crosshair */ //ATTRIB(Tuba, w_crosshair_size, float, 0.65);
-/* wepimg    */ ATTRIB(Tuba, model2, string, "weapontuba");
-/* refname   */ ATTRIB(Tuba, netname, string, "tuba");
-/* xgettext:no-c-format */
-/* wepname   */ ATTRIB(Tuba, m_name, string, _("@!#%'n Tuba"));
-
-#define X(BEGIN, P, END, class, prefix) \
-       BEGIN(class) \
-               P(class, prefix, animtime, float, NONE) \
-               P(class, prefix, attenuation, float, NONE) \
-               P(class, prefix, damage, float, NONE) \
-               P(class, prefix, edgedamage, float, NONE) \
-               P(class, prefix, fadetime, float, NONE) \
-               P(class, prefix, force, float, NONE) \
-               P(class, prefix, pitchstep, float, NONE) \
-               P(class, prefix, radius, float, NONE) \
-               P(class, prefix, refire, float, NONE) \
-               P(class, prefix, switchdelay_drop, float, NONE) \
-               P(class, prefix, switchdelay_raise, float, NONE) \
-               P(class, prefix, volume, float, NONE) \
-               P(class, prefix, weaponreplace, string, NONE) \
-               P(class, prefix, weaponstartoverride, float, NONE) \
-               P(class, prefix, weaponstart, float, NONE) \
-               P(class, prefix, weaponthrowable, float, NONE) \
-       END()
-    W_PROPS(X, Tuba, tuba)
-#undef X
-ENDCLASS(Tuba)
-REGISTER_WEAPON(TUBA, tuba, NEW(Tuba));
-#endif
-
-#ifdef IMPLEMENTATION
 
 #ifdef SVQC
 
@@ -53,8 +10,6 @@ REGISTER_WEAPON(TUBA, tuba, NEW(Tuba));
 .float tuba_lastnotes_cnt; // over
 .vector tuba_lastnotes[MAX_TUBANOTES];
 
-spawnfunc(weapon_tuba) { weapon_defaultspawnfunc(this, WEP_TUBA); }
-
 bool W_Tuba_HasPlayed(entity pl, .entity weaponentity, string melody, int instrument, bool ignorepitch, float mintempo, float maxtempo)
 {
        float i, j, mmin, mmax, nolength;
@@ -157,7 +112,7 @@ void W_Tuba_NoteOff(entity this)
        if (actor.(weaponentity).tuba_note == this)
        {
                actor.(weaponentity).tuba_lastnotes_last = (actor.(weaponentity).tuba_lastnotes_last + 1) % MAX_TUBANOTES;
-               actor.(weaponentity).(tuba_lastnotes[actor.(weaponentity).tuba_lastnotes_last]) = eX * this.spawnshieldtime + eY * time + eZ * this.cnt;
+               actor.(weaponentity).(tuba_lastnotes[actor.(weaponentity).tuba_lastnotes_last]) = vec3(this.spawnshieldtime, time, this.cnt);
                actor.(weaponentity).tuba_note = NULL;
                actor.(weaponentity).tuba_lastnotes_cnt = bound(0, actor.(weaponentity).tuba_lastnotes_cnt + 1, MAX_TUBANOTES);
 
@@ -186,10 +141,10 @@ void W_Tuba_NoteOff(entity this)
 int W_Tuba_GetNote(entity pl, int hittype)
 {
        float movestate = 5;
-       if (pl.movement.x < 0)          movestate -= 3;
-       else if (pl.movement.x > 0)     movestate += 3;
-       if (pl.movement.y < 0)          movestate -= 1;
-       else if (pl.movement.y > 0)     movestate += 1;
+       if (CS(pl).movement.x < 0)              movestate -= 3;
+       else if (CS(pl).movement.x > 0) movestate += 3;
+       if (CS(pl).movement.y < 0)              movestate -= 1;
+       else if (CS(pl).movement.y > 0) movestate += 1;
 
        int note = 0;
        switch (movestate)
@@ -313,11 +268,7 @@ void W_Tuba_NoteThink(entity this)
 void W_Tuba_NoteOn(entity actor, .entity weaponentity, float hittype)
 {
        vector o;
-       float n;
-
-       W_SetupShot(actor, weaponentity, false, 2, SND_Null, 0, WEP_CVAR(tuba, damage));
-
-       n = W_Tuba_GetNote(actor, hittype);
+       float n = W_Tuba_GetNote(actor, hittype);
 
        hittype = 0;
        if(actor.(weaponentity).tuba_instrument & 1)
@@ -325,6 +276,8 @@ void W_Tuba_NoteOn(entity actor, .entity weaponentity, float hittype)
        if(actor.(weaponentity).tuba_instrument & 2)
                hittype |= HITTYPE_BOUNCE;
 
+       W_SetupShot(actor, weaponentity, false, 2, SND_Null, 0, WEP_CVAR(tuba, damage), hittype | WEP_TUBA.m_id);
+
        if(actor.(weaponentity).tuba_note)
        {
                if(actor.(weaponentity).tuba_note.cnt != n || actor.(weaponentity).tuba_note.tuba_instrument != actor.(weaponentity).tuba_instrument)
@@ -350,7 +303,7 @@ void W_Tuba_NoteOn(entity actor, .entity weaponentity, float hittype)
        actor.(weaponentity).tuba_note.teleport_time = time + WEP_CVAR(tuba, refire) * 2 * W_WeaponRateFactor(actor); // so it can get prolonged safely
 
        //sound(actor, c, TUBA_NOTE(n), bound(0, VOL_BASE * cvar("g_balance_tuba_volume"), 1), autocvar_g_balance_tuba_attenuation);
-       RadiusDamage(actor, actor, WEP_CVAR(tuba, damage), WEP_CVAR(tuba, edgedamage), WEP_CVAR(tuba, radius), NULL, NULL, WEP_CVAR(tuba, force), hittype | WEP_TUBA.m_id, NULL);
+       RadiusDamage(actor, actor, WEP_CVAR(tuba, damage), WEP_CVAR(tuba, edgedamage), WEP_CVAR(tuba, radius), NULL, NULL, WEP_CVAR(tuba, force), hittype | WEP_TUBA.m_id, weaponentity, NULL);
 
        o = gettaginfo(actor.exteriorweaponentity, 0);
        if(time > actor.(weaponentity).tuba_smoketime)
@@ -423,7 +376,12 @@ METHOD(Tuba, wr_reload, void(Tuba this, entity actor, .entity weaponentity))
                                actor.(weaponentity).weaponname = "tuba";
                                break;
                }
-               W_SetupShot(actor, weaponentity, false, 0, SND_Null, 0, 0);
+               int hittype = 0;
+               if(actor.(weaponentity).tuba_instrument & 1)
+                       hittype |= HITTYPE_SECONDARY;
+               if(actor.(weaponentity).tuba_instrument & 2)
+                       hittype |= HITTYPE_BOUNCE;
+               W_SetupShot(actor, weaponentity, false, 0, SND_Null, 0, 0, hittype | WEP_TUBA.m_id);
                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);
@@ -493,23 +451,23 @@ void tubasound(entity e, bool restart)
                                if (restart) {
                                        snd1 = TUBA_STARTNOTE(e.tuba_instrument, e.note - m + Tuba_PitchStep);
                                }
-                               speed1 = pow(2.0, (m - Tuba_PitchStep) / 12.0);
+                               speed1 = (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);
+                               speed1 = (2.0 ** (m / 12.0));
                        } else {
                                if (restart) {
                                        snd1 = TUBA_STARTNOTE(e.tuba_instrument, e.note - m);
                                }
                                vol1 = cos(M_PI_2 * m / Tuba_PitchStep);
-                               speed1 = pow(2.0, m / 12.0);
+                               speed1 = (2.0 ** (m / 12.0));
                                if (restart) {
                                        snd2 = TUBA_STARTNOTE(e.tuba_instrument, e.note - m + Tuba_PitchStep);
                                }
                                vol2 = sin(M_PI_2 * m / Tuba_PitchStep);
-                               speed2 = pow(2.0, (m - Tuba_PitchStep) / 12.0);
+                               speed2 = (2.0 ** ((m - Tuba_PitchStep) / 12.0));
                        }
                } else if (restart) {
                        snd1 = TUBA_STARTNOTE(e.tuba_instrument, e.note);
@@ -634,4 +592,3 @@ PRECACHE(Tuba)
 }
 
 #endif
-#endif