]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/weapons/w_tuba.qc
Remove some leftovers from merge
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / weapons / w_tuba.qc
index 4f777d72979893352842c4304cfa5bfcac8f0eb7..3c40519d6330b06d7b8cdfb4719f0884c7a69828 100644 (file)
@@ -1,32 +1,47 @@
 #ifdef REGISTER_WEAPON
 REGISTER_WEAPON(
-/* WEP_##id */ TUBA,
-/* function */ w_tuba,
-/* ammotype */ 0,
-/* impulse  */ 1,
-/* flags    */ WEP_FLAG_HIDDEN | WEP_TYPE_SPLASH,
-/* rating   */ BOT_PICKUP_RATING_MID,
-/* model    */ "tuba",
-/* netname  */ "tuba",
+/* WEP_##id  */ TUBA,
+/* function  */ W_Tuba,
+/* ammotype  */ ammo_none,
+/* impulse   */ 1,
+/* flags     */ WEP_FLAG_HIDDEN | WEP_TYPE_SPLASH,
+/* rating    */ BOT_PICKUP_RATING_MID,
+/* color     */ '0 1 0',
+/* modelname */ "tuba",
+/* simplemdl */ "foobar",
+/* crosshair */ "gfx/crosshairtuba",
+/* wepimg    */ "weapontuba",
+/* refname   */ "tuba",
 /* xgettext:no-c-format */
-/* fullname  */ _("@!#%'n Tuba")
+/* wepname   */ _("@!#%'n Tuba")
 );
 
-#define TUBA_SETTINGS(weapon) \
-       WEP_ADD_CVAR(weapon, MO_NONE, animtime) \
-       WEP_ADD_CVAR(weapon, MO_NONE, attenuation) \
-       WEP_ADD_CVAR(weapon, MO_NONE, damage) \
-       WEP_ADD_CVAR(weapon, MO_NONE, edgedamage) \
-       WEP_ADD_CVAR(weapon, MO_NONE, force) \
-       WEP_ADD_CVAR(weapon, MO_NONE, radius) \
-       WEP_ADD_CVAR(weapon, MO_NONE, refire) \
-       WEP_ADD_PROP(weapon, reloading_ammo, reload_ammo) \
-       WEP_ADD_PROP(weapon, reloading_time, reload_time) \
-       WEP_ADD_PROP(weapon, switchdelay_raise, switchdelay_raise) \
-       WEP_ADD_PROP(weapon, switchdelay_drop, switchdelay_drop)
+#define TUBA_SETTINGS(w_cvar,w_prop) TUBA_SETTINGS_LIST(w_cvar, w_prop, TUBA, tuba)
+#define TUBA_SETTINGS_LIST(w_cvar,w_prop,id,sn) \
+       w_cvar(id, sn, NONE, animtime) \
+       w_cvar(id, sn, NONE, attenuation) \
+       w_cvar(id, sn, NONE, damage) \
+       w_cvar(id, sn, NONE, edgedamage) \
+       w_cvar(id, sn, NONE, fadetime) \
+       w_cvar(id, sn, NONE, force) \
+       w_cvar(id, sn, NONE, pitchstep) \
+       w_cvar(id, sn, NONE, radius) \
+       w_cvar(id, sn, NONE, refire) \
+       w_cvar(id, sn, NONE, volume) \
+       w_prop(id, sn, float,  switchdelay_raise, switchdelay_raise) \
+       w_prop(id, sn, float,  switchdelay_drop, switchdelay_drop) \
+       w_prop(id, sn, string, weaponreplace, weaponreplace) \
+       w_prop(id, sn, float,  weaponstart, weaponstart) \
+       w_prop(id, sn, float,  weaponstartoverride, weaponstartoverride) \
+       w_prop(id, sn, float,  weaponthrowable, weaponthrowable)
 
 #ifdef SVQC
-TUBA_SETTINGS(tuba)
+TUBA_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
+float W_Tuba_MarkClientOnlyFieldsAsUsed() {
+       // These variables are only used by client/tuba.qc. TODO: move client/tuba.qc code here.
+       return WEP_CVAR(tuba, fadetime) + WEP_CVAR(tuba, pitchstep) + WEP_CVAR(tuba, volume);
+}
+
 .entity tuba_note;
 .float tuba_smoketime;
 .float tuba_instrument;
@@ -38,41 +53,41 @@ TUBA_SETTINGS(tuba)
 #endif
 #else
 #ifdef SVQC
-void spawnfunc_weapon_tuba (void) { weapon_defaultspawnfunc(WEP_TUBA); }
+void spawnfunc_weapon_tuba(void) { weapon_defaultspawnfunc(WEP_TUBA); }
 
-float W_Tuba_HasPlayed(entity pl, string melody, float instrument, float ignorepitch, float mintempo, float maxtempo)
+bool W_Tuba_HasPlayed(entity pl, string melody, int instrument, bool ignorepitch, float mintempo, float maxtempo)
 {
        float i, j, mmin, mmax, nolength;
        float n = tokenize_console(melody);
        if(n > pl.tuba_lastnotes_cnt)
-               return FALSE;
+               return false;
        float pitchshift = 0;
 
        if(instrument >= 0)
                if(pl.tuba_instrument != instrument)
-                       return FALSE;
+                       return false;
 
        // verify notes...
-       nolength = FALSE;
+       nolength = false;
        for(i = 0; i < n; ++i)
        {
-               vector v = pl.(tuba_lastnotes[mod(pl.tuba_lastnotes_last - i + MAX_TUBANOTES, MAX_TUBANOTES)]);
+               vector v = pl.(tuba_lastnotes[(pl.tuba_lastnotes_last - i + MAX_TUBANOTES) % MAX_TUBANOTES]);
                float ai = stof(argv(n - i - 1));
                float np = floor(ai);
                if(ai == np)
-                       nolength = TRUE;
+                       nolength = true;
                // n counts the last played notes BACKWARDS
                // _x is start
                // _y is end
                // _z is note pitch
                if(ignorepitch && i == 0)
                {
-                       pitchshift = np - v_z;
+                       pitchshift = np - v.z;
                }
                else
                {
-                       if(v_z + pitchshift != np)
-                               return FALSE;
+                       if(v.z + pitchshift != np)
+                               return false;
                }
        }
 
@@ -89,17 +104,17 @@ float W_Tuba_HasPlayed(entity pl, string melody, float instrument, float ignorep
                        mmax = 240 / mintempo; // 60 = "0.25 means 1 sec", at 120 0.5 means 1 sec, at 240 1 means 1 sec
                else
                        mmax = 240; // you won't try THAT hard... (tempo 1)
-               //print(sprintf("initial tempo rules: %f %f\n", mmin, mmax));
+               //printf("initial tempo rules: %f %f\n", mmin, mmax);
 
                for(i = 0; i < n; ++i)
                {
-                       vector vi = pl.(tuba_lastnotes[mod(pl.tuba_lastnotes_last - i + MAX_TUBANOTES, MAX_TUBANOTES)]);
+                       vector vi = pl.(tuba_lastnotes[(pl.tuba_lastnotes_last - i + MAX_TUBANOTES) % MAX_TUBANOTES]);
                        float ai = stof(argv(n - i - 1));
                        ti -= 1 / (ai - floor(ai));
                        float tj = ti;
                        for(j = i+1; j < n; ++j)
                        {
-                               vector vj = pl.(tuba_lastnotes[mod(pl.tuba_lastnotes_last - j + MAX_TUBANOTES, MAX_TUBANOTES)]);
+                               vector vj = pl.(tuba_lastnotes[(pl.tuba_lastnotes_last - j + MAX_TUBANOTES) % MAX_TUBANOTES]);
                                float aj = stof(argv(n - j - 1));
                                tj -= (aj - floor(aj));
 
@@ -113,25 +128,25 @@ float W_Tuba_HasPlayed(entity pl, string melody, float instrument, float ignorep
 
                                // vi_x <= vi_y <= vj_x <= vj_y
                                // ti <= tj
-                               //print(sprintf("first note: %f to %f, should be %f\n", vi_x, vi_y, ti));
-                               //print(sprintf("second note: %f to %f, should be %f\n", vj_x, vj_y, tj));
-                               //print(sprintf("m1 = %f\n", (vi_x - vj_y) / (ti - tj)));
-                               //print(sprintf("m2 = %f\n", (vi_y - vj_x) / (ti - tj)));
-                               mmin = max(mmin, (vi_x - vj_y) / (ti - tj)); // lower bound
-                               mmax = min(mmax, (vi_y - vj_x) / (ti - tj)); // upper bound
+                               //printf("first note: %f to %f, should be %f\n", vi_x, vi_y, ti);
+                               //printf("second note: %f to %f, should be %f\n", vj_x, vj_y, tj);
+                               //printf("m1 = %f\n", (vi_x - vj_y) / (ti - tj));
+                               //printf("m2 = %f\n", (vi_y - vj_x) / (ti - tj));
+                               mmin = max(mmin, (vi.x - vj.y) / (ti - tj)); // lower bound
+                               mmax = min(mmax, (vi.y - vj.x) / (ti - tj)); // upper bound
                        }
                }
 
                if(mmin > mmax) // rhythm fail
-                       return FALSE;
+                       return false;
        }
 
        pl.tuba_lastnotes_cnt = 0;
 
-       return TRUE;
+       return true;
 }
 
-void W_Tuba_NoteOff()
+void W_Tuba_NoteOff(void)
 {
        // we have a note:
        //   on: self.spawnshieldtime
@@ -139,7 +154,7 @@ void W_Tuba_NoteOff()
        //   note: self.cnt
        if(self.owner.tuba_note == self)
        {
-               self.owner.tuba_lastnotes_last = mod(self.owner.tuba_lastnotes_last + 1, MAX_TUBANOTES);
+               self.owner.tuba_lastnotes_last = (self.owner.tuba_lastnotes_last + 1) % MAX_TUBANOTES;
                self.owner.(tuba_lastnotes[self.owner.tuba_lastnotes_last]) = eX * self.spawnshieldtime + eY * time + eZ * self.cnt;
                self.owner.tuba_note = world;
                self.owner.tuba_lastnotes_cnt = bound(0, self.owner.tuba_lastnotes_cnt + 1, MAX_TUBANOTES);
@@ -167,18 +182,15 @@ void W_Tuba_NoteOff()
        remove(self);
 }
 
-float Tuba_GetNote(entity pl, float hittype)
+int W_Tuba_GetNote(entity pl, int hittype)
 {
-       float note;
-       float movestate;
-       movestate = 5;
-       if(pl.movement_x < 0) movestate -= 3;
-       if(pl.movement_x > 0) movestate += 3;
-       if(pl.movement_y < 0) movestate -= 1;
-       if(pl.movement_y > 0) movestate += 1;
-#ifdef GMQCC
-       note = 0;
-#endif
+       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;
+
+       int note = 0;
        switch(movestate)
        {
        // layout: originally I wanted
@@ -207,7 +219,7 @@ float Tuba_GetNote(entity pl, float hittype)
                note += 12;
        if(hittype & HITTYPE_SECONDARY)
                note += 7;
-       
+
        // we support two kinds of tubas, those tuned in Eb and those tuned in C
        // kind of tuba currently is player slot number, or team number if in
        // teamplay
@@ -222,7 +234,7 @@ float Tuba_GetNote(entity pl, float hittype)
                if(pl.clientcolors & 1)
                        note += 3;
        }
-       
+
        // total range of notes:
        //                       0
        //                 ***  ** ****
@@ -238,13 +250,13 @@ float Tuba_GetNote(entity pl, float hittype)
        return note;
 }
 
-float W_Tuba_NoteSendEntity(entity to, float sf)
+bool W_Tuba_NoteSendEntity(entity to, int sf)
 {
-       float f;
+       int f;
 
        msg_entity = to;
        if(!sound_allowed(MSG_ONE, self.realowner))
-               return FALSE;
+               return false;
 
        WriteByte(MSG_ENTITY, ENT_CLIENT_TUBANOTE);
        WriteByte(MSG_ENTITY, sf);
@@ -259,14 +271,14 @@ float W_Tuba_NoteSendEntity(entity to, float sf)
        }
        if(sf & 2)
        {
-               WriteCoord(MSG_ENTITY, self.origin_x);
-               WriteCoord(MSG_ENTITY, self.origin_y);
-               WriteCoord(MSG_ENTITY, self.origin_z);
+               WriteCoord(MSG_ENTITY, self.origin.x);
+               WriteCoord(MSG_ENTITY, self.origin.y);
+               WriteCoord(MSG_ENTITY, self.origin.z);
        }
-       return TRUE;
+       return true;
 }
 
-void W_Tuba_NoteThink()
+void W_Tuba_NoteThink(void)
 {
        float dist_mult;
        float vol0, vol1;
@@ -309,9 +321,9 @@ void W_Tuba_NoteOn(float hittype)
        vector o;
        float n;
 
-       W_SetupShot(self, FALSE, 2, "", 0, WEP_CVAR(tuba, damage));
+       W_SetupShot(self, false, 2, "", 0, WEP_CVAR(tuba, damage));
 
-       n = Tuba_GetNote(self, hittype);
+       n = W_Tuba_GetNote(self, hittype);
 
        hittype = 0;
        if(self.tuba_instrument & 1)
@@ -330,7 +342,7 @@ void W_Tuba_NoteOn(float hittype)
                }
        }
 
-       if not(self.tuba_note)
+       if(!self.tuba_note)
        {
                self.tuba_note = spawn();
                self.tuba_note.owner = self.tuba_note.realowner = self;
@@ -339,7 +351,7 @@ void W_Tuba_NoteOn(float hittype)
                self.tuba_note.think = W_Tuba_NoteThink;
                self.tuba_note.nextthink = time;
                self.tuba_note.spawnshieldtime = time;
-               Net_LinkEntity(self.tuba_note, FALSE, 0, W_Tuba_NoteSendEntity);
+               Net_LinkEntity(self.tuba_note, false, 0, W_Tuba_NoteSendEntity);
        }
 
        self.tuba_note.teleport_time = time + WEP_CVAR(tuba, refire) * 2 * W_WeaponRateFactor(); // so it can get prolonged safely
@@ -355,7 +367,7 @@ void W_Tuba_NoteOn(float hittype)
        }
 }
 
-float w_tuba(float req)
+bool W_Tuba(int req)
 {
        switch(req)
        {
@@ -370,20 +382,20 @@ float w_tuba(float req)
                                else
                                        self.BUTTON_ATCK2 = 1;
                        }
-                       
-                       return TRUE;
+
+                       return true;
                }
                case WR_THINK:
                {
-                       if (self.BUTTON_ATCK)
-                       if (weapon_prepareattack(0, WEP_CVAR(tuba, refire)))
+                       if(self.BUTTON_ATCK)
+                       if(weapon_prepareattack(0, WEP_CVAR(tuba, refire)))
                        {
                                W_Tuba_NoteOn(0);
                                //weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_tuba_animtime, w_ready);
                                weapon_thinkf(WFRAME_IDLE, WEP_CVAR(tuba, animtime), w_ready);
                        }
-                       if (self.BUTTON_ATCK2)
-                       if (weapon_prepareattack(1, WEP_CVAR(tuba, refire)))
+                       if(self.BUTTON_ATCK2)
+                       if(weapon_prepareattack(1, WEP_CVAR(tuba, refire)))
                        {
                                W_Tuba_NoteOn(HITTYPE_SECONDARY);
                                //weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_tuba_animtime, w_ready);
@@ -399,26 +411,26 @@ float w_tuba(float req)
                                        self = oldself;
                                }
                        }
-                       
-                       return TRUE;
+
+                       return true;
                }
                case WR_INIT:
                {
-                       precache_model ("models/weapons/g_tuba.md3");
-                       precache_model ("models/weapons/v_tuba.md3");
-                       precache_model ("models/weapons/h_tuba.iqm");
-                       precache_model ("models/weapons/v_akordeon.md3");
-                       precache_model ("models/weapons/h_akordeon.iqm");
-                       precache_model ("models/weapons/v_kleinbottle.md3");
-                       precache_model ("models/weapons/h_kleinbottle.iqm");
-                       WEP_SET_PROPS(TUBA_SETTINGS(tuba), WEP_TUBA)
-                       return TRUE;
+                       precache_model("models/weapons/g_tuba.md3");
+                       precache_model("models/weapons/v_tuba.md3");
+                       precache_model("models/weapons/h_tuba.iqm");
+                       precache_model("models/weapons/v_akordeon.md3");
+                       precache_model("models/weapons/h_akordeon.iqm");
+                       precache_model("models/weapons/v_kleinbottle.md3");
+                       precache_model("models/weapons/h_kleinbottle.iqm");
+                       TUBA_SETTINGS(WEP_SKIP_CVAR, WEP_SET_PROP);
+                       return true;
                }
                case WR_SETUP:
                {
-                       self.current_ammo = ammo_none;
+                       self.ammo_field = ammo_none;
                        self.tuba_instrument = 0;
-                       return TRUE;
+                       return true;
                }
                case WR_RELOAD:
                {
@@ -440,23 +452,23 @@ float w_tuba(float req)
                                                self.weaponname = "tuba";
                                                break;
                                }
-                               W_SetupShot(self, FALSE, 0, "", 0, 0);
+                               W_SetupShot(self, false, 0, "", 0, 0);
                                pointparticles(particleeffectnum("teleport"), w_shotorg, '0 0 0', 1);
                                self.weaponentity.state = WS_INUSE;
                                weapon_thinkf(WFRAME_RELOAD, 0.5, w_ready);
                        }
-                       
-                       return TRUE;
+
+                       return true;
                }
                case WR_CHECKAMMO1:
                case WR_CHECKAMMO2:
                {
-                       return TRUE; // tuba has infinite ammo
+                       return true; // tuba has infinite ammo
                }
                case WR_CONFIG:
                {
-                       WEP_CONFIG_SETTINGS(TUBA_SETTINGS(tuba))
-                       return TRUE;
+                       TUBA_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS);
+                       return true;
                }
                case WR_SUICIDEMESSAGE:
                {
@@ -477,15 +489,25 @@ float w_tuba(float req)
                                return WEAPON_TUBA_MURDER;
                }
        }
-       return TRUE;
+       return false;
 }
 #endif
 #ifdef CSQC
-float w_tuba(float req)
+bool W_Tuba(int req)
 {
        // nothing to do here; particles of tuba are handled differently
+       // WEAPONTODO
+
+       switch(req)
+       {
+               case WR_ZOOMRETICLE:
+               {
+                       // no weapon specific image for this weapon
+                       return false;
+               }
+       }
 
-       return TRUE;
+       return false;
 }
 #endif
 #endif