]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/weapons/w_tuba.qc
Add weaponthrowable property to weapons
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / weapons / w_tuba.qc
index 51a6120fbdb90b86d43aa15c8f9ecdd770978465..ec673b7a8ce7005a1964714aa0bf7b03146bba69 100644 (file)
@@ -1,18 +1,39 @@
 #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",
-/* fullname */ _("@!#%'n 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 */
+/* wepname   */ _("@!#%'n Tuba")
 );
-#else
+
+#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, force) \
+       w_cvar(id, sn, NONE, radius) \
+       w_cvar(id, sn, NONE, refire) \
+       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
-//#define TUBA_NOTE(n) strcat("weapons/tuba_note", ftos(n), ".wav")
+TUBA_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
 .entity tuba_note;
 .float tuba_smoketime;
 .float tuba_instrument;
@@ -21,6 +42,10 @@ REGISTER_WEAPON(
 .float tuba_lastnotes_last;
 .float tuba_lastnotes_cnt; // over
 .vector tuba_lastnotes[MAX_TUBANOTES];
+#endif
+#else
+#ifdef SVQC
+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)
 {
@@ -71,7 +96,7 @@ 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)
                {
@@ -95,10 +120,10 @@ 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)));
+                               //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
                        }
@@ -149,7 +174,7 @@ void W_Tuba_NoteOff()
        remove(self);
 }
 
-float Tuba_GetNote(entity pl, float hittype)
+float W_Tuba_GetNote(entity pl, float hittype)
 {
        float note;
        float movestate;
@@ -189,7 +214,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
@@ -204,7 +229,7 @@ float Tuba_GetNote(entity pl, float hittype)
                if(pl.clientcolors & 1)
                        note += 3;
        }
-       
+
        // total range of notes:
        //                       0
        //                 ***  ** ****
@@ -261,7 +286,7 @@ void W_Tuba_NoteThink()
                return;
        }
        self.nextthink = time;
-       dist_mult = autocvar_g_balance_tuba_attenuation / autocvar_snd_soundradius;
+       dist_mult = WEP_CVAR(tuba, attenuation) / autocvar_snd_soundradius;
        FOR_EACH_REALCLIENT(e)
        if(e != self.realowner)
        {
@@ -291,9 +316,9 @@ void W_Tuba_NoteOn(float hittype)
        vector o;
        float n;
 
-       W_SetupShot(self, FALSE, 2, "", 0, autocvar_g_balance_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)
@@ -312,7 +337,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;
@@ -324,10 +349,10 @@ void W_Tuba_NoteOn(float hittype)
                Net_LinkEntity(self.tuba_note, FALSE, 0, W_Tuba_NoteSendEntity);
        }
 
-       self.tuba_note.teleport_time = time + autocvar_g_balance_tuba_refire * 2 * W_WeaponRateFactor(); // so it can get prolonged safely
+       self.tuba_note.teleport_time = time + WEP_CVAR(tuba, refire) * 2 * W_WeaponRateFactor(); // so it can get prolonged safely
 
        //sound(self, c, TUBA_NOTE(n), bound(0, VOL_BASE * cvar("g_balance_tuba_volume"), 1), autocvar_g_balance_tuba_attenuation);
-       RadiusDamage(self, self, autocvar_g_balance_tuba_damage, autocvar_g_balance_tuba_edgedamage, autocvar_g_balance_tuba_radius, world, world, autocvar_g_balance_tuba_force, hittype | WEP_TUBA, world);
+       RadiusDamage(self, self, WEP_CVAR(tuba, damage), WEP_CVAR(tuba, edgedamage), WEP_CVAR(tuba, radius), world, world, WEP_CVAR(tuba, force), hittype | WEP_TUBA, world);
 
        o = gettaginfo(self.exteriorweaponentity, 0);
        if(time > self.tuba_smoketime)
@@ -337,12 +362,7 @@ void W_Tuba_NoteOn(float hittype)
        }
 }
 
-void spawnfunc_weapon_tuba (void)
-{
-       weapon_defaultspawnfunc(WEP_TUBA);
-}
-
-float w_tuba(float req)
+float W_Tuba(float req)
 {
        switch(req)
        {
@@ -350,7 +370,7 @@ float w_tuba(float req)
                {
                        // bots cannot play the Tuba well yet
                        // I think they should start with the recorder first
-                       if(vlen(self.origin - self.enemy.origin) < autocvar_g_balance_tuba_radius)
+                       if(vlen(self.origin - self.enemy.origin) < WEP_CVAR(tuba, radius))
                        {
                                if(random() > 0.5)
                                        self.BUTTON_ATCK = 1;
@@ -363,18 +383,18 @@ float w_tuba(float req)
                case WR_THINK:
                {
                        if (self.BUTTON_ATCK)
-                       if (weapon_prepareattack(0, autocvar_g_balance_tuba_refire))
+                       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, 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, autocvar_g_balance_tuba_refire))
+                       if (weapon_prepareattack(1, WEP_CVAR(tuba, refire)))
                        {
                                W_Tuba_NoteOn(HITTYPE_SECONDARY);
                                //weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_tuba_animtime, w_ready);
-                               weapon_thinkf(WFRAME_IDLE, autocvar_g_balance_tuba_animtime, w_ready);
+                               weapon_thinkf(WFRAME_IDLE, WEP_CVAR(tuba, animtime), w_ready);
                        }
                        if(self.tuba_note)
                        {
@@ -398,13 +418,12 @@ float w_tuba(float req)
                        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:
                {
-                       weapon_setup(WEP_TUBA);
-                       self.current_ammo = ammo_none;
+                       self.ammo_field = ammo_none;
                        self.tuba_instrument = 0;
                        return TRUE;
                }
@@ -441,6 +460,11 @@ float w_tuba(float req)
                {
                        return TRUE; // tuba has infinite ammo
                }
+               case WR_CONFIG:
+               {
+                       TUBA_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS)
+                       return TRUE;
+               }
                case WR_SUICIDEMESSAGE:
                {
                        if(w_deathtype & HITTYPE_BOUNCE)
@@ -460,15 +484,25 @@ float w_tuba(float req)
                                return WEAPON_TUBA_MURDER;
                }
        }
-       return TRUE;
+       return FALSE;
 }
 #endif
 #ifdef CSQC
-float w_tuba(float req)
+float W_Tuba(float req)
 {
        // nothing to do here; particles of tuba are handled differently
+       // WEAPONTODO
 
-       return TRUE;
+       switch(req)
+       {
+               case WR_ZOOMRETICLE:
+               {
+                       // no weapon specific image for this weapon
+                       return FALSE;
+               }
+       }
+
+       return FALSE;
 }
 #endif
 #endif