]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/weapons/w_rifle.qc
Further cleanup of laser, plus remove useless mode declarations
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / weapons / w_rifle.qc
index a7c7e262e94031106ee4b53965a820128f68a372..96f755183ca5040a0983bfb1adb61598244c3b4e 100644 (file)
@@ -11,40 +11,37 @@ REGISTER_WEAPON(
 /* fullname */ _("Rifle")
 );
 
-#define RIFLE_SETTINGS(weapon) \
-       WEP_ADD_CVAR(weapon, MO_BOTH, ammo) \
-       WEP_ADD_CVAR(weapon, MO_BOTH, animtime) \
-       WEP_ADD_CVAR(weapon, MO_BOTH, bulletconstant) \
-       WEP_ADD_CVAR(weapon, MO_BOTH, bullethail) \
-       WEP_ADD_CVAR(weapon, MO_BOTH, burstcost) \
-       WEP_ADD_CVAR(weapon, MO_BOTH, damage) \
-       WEP_ADD_CVAR(weapon, MO_BOTH, force) \
-       WEP_ADD_CVAR(weapon, MO_BOTH, lifetime) \
-       WEP_ADD_CVAR(weapon, MO_BOTH, refire) \
-       WEP_ADD_CVAR(weapon, MO_BOTH, shots) \
-       WEP_ADD_CVAR(weapon, MO_BOTH, speed) \
-       WEP_ADD_CVAR(weapon, MO_BOTH, spread) \
-       WEP_ADD_CVAR(weapon, MO_BOTH, tracer) \
-       WEP_ADD_CVAR(weapon, MO_NONE, bursttime) \
-       WEP_ADD_CVAR(weapon, MO_NONE, secondary) \
-       WEP_ADD_CVAR(weapon, MO_SEC,  reload) \
-       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 RIFLE_SETTINGS(w_cvar,w_prop) \
+       w_cvar(WEP_RIFLE, rifle, MO_BOTH, ammo) \
+       w_cvar(WEP_RIFLE, rifle, MO_BOTH, animtime) \
+       w_cvar(WEP_RIFLE, rifle, MO_BOTH, bulletconstant) \
+       w_cvar(WEP_RIFLE, rifle, MO_BOTH, bullethail) \
+       w_cvar(WEP_RIFLE, rifle, MO_BOTH, burstcost) \
+       w_cvar(WEP_RIFLE, rifle, MO_BOTH, damage) \
+       w_cvar(WEP_RIFLE, rifle, MO_BOTH, force) \
+       w_cvar(WEP_RIFLE, rifle, MO_BOTH, lifetime) \
+       w_cvar(WEP_RIFLE, rifle, MO_BOTH, refire) \
+       w_cvar(WEP_RIFLE, rifle, MO_BOTH, shots) \
+       w_cvar(WEP_RIFLE, rifle, MO_BOTH, speed) \
+       w_cvar(WEP_RIFLE, rifle, MO_BOTH, spread) \
+       w_cvar(WEP_RIFLE, rifle, MO_BOTH, tracer) \
+       w_cvar(WEP_RIFLE, rifle, MO_NONE, bursttime) \
+       w_cvar(WEP_RIFLE, rifle, MO_NONE, secondary) \
+       w_cvar(WEP_RIFLE, rifle, MO_SEC,  reload) \
+       w_prop(WEP_RIFLE, rifle, reloading_ammo, reload_ammo) \
+       w_prop(WEP_RIFLE, rifle, reloading_time, reload_time) \
+       w_prop(WEP_RIFLE, rifle, switchdelay_raise, switchdelay_raise) \
+       w_prop(WEP_RIFLE, rifle, switchdelay_drop, switchdelay_drop)
 
 #ifdef SVQC
-RIFLE_SETTINGS(rifle)
-void spawnfunc_weapon_rifle (void) { weapon_defaultspawnfunc(WEP_RIFLE); }
-
-// compatibility aliases
-void spawnfunc_weapon_campingrifle (void) { spawnfunc_weapon_rifle(); }
-void spawnfunc_weapon_sniperrifle (void) { spawnfunc_weapon_rifle(); }
-
+RIFLE_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
 .float rifle_accumulator;
 #endif
 #else
 #ifdef SVQC
+void spawnfunc_weapon_rifle (void) { weapon_defaultspawnfunc(WEP_RIFLE); }
+void spawnfunc_weapon_campingrifle (void) { spawnfunc_weapon_rifle(); }
+void spawnfunc_weapon_sniperrifle (void) { spawnfunc_weapon_rifle(); }
 
 void W_Rifle_FireBullet(float pSpread, float pDamage, float pForce, float pSpeed, float pLifetime, float pAmmo, float deathtype, float pBulletConstant, float pTracer, float pShots, string pSound)
 {
@@ -52,7 +49,7 @@ void W_Rifle_FireBullet(float pSpread, float pDamage, float pForce, float pSpeed
 
        W_DecreaseAmmo(ammo_nails, pAmmo, autocvar_g_balance_rifle_reload_ammo);
 
-       W_SetupShot (self, autocvar_g_antilag_bullets && pSpeed >= autocvar_g_antilag_bullets, 2, pSound, CH_WEAPON_A, pDamage * pShots);
+       W_SetupShot (self, TRUE, 2, pSound, CH_WEAPON_A, pDamage * pShots);
 
        pointparticles(particleeffectnum("rifle_muzzleflash"), w_shotorg, w_shotdir * 2000, 1);
 
@@ -63,7 +60,7 @@ void W_Rifle_FireBullet(float pSpread, float pDamage, float pForce, float pSpeed
        }
 
        for(i = 0; i < pShots; ++i)
-               fireBallisticBullet(w_shotorg, w_shotdir, pSpread, pSpeed, pLifetime, pDamage, pForce, deathtype, (pTracer ? EF_RED : EF_BLUE), 1, pBulletConstant);
+               fireBallisticBullet(w_shotorg, w_shotdir, pSpread, pSpeed, pLifetime, pDamage, pForce, deathtype, (pTracer ? EF_RED : EF_BLUE), pBulletConstant);
        endFireBallisticBullet();
 
        if (autocvar_g_casings >= 2)
@@ -205,16 +202,11 @@ float w_rifle(float req)
                        precache_model ("models/weapons/h_campingrifle.iqm");
                        precache_sound ("weapons/campingrifle_fire.wav");
                        precache_sound ("weapons/campingrifle_fire2.wav");
-                       #define WEP_ADD_CVAR(weapon,mode,name) /*nothing*/
-                       #define WEP_ADD_PROP(weapon,prop,name) WEP_SET_PROP(WEP_RIFLE,weapon,prop,name)
-                       RIFLE_SETTINGS(rifle)
-                       #undef WEP_ADD_CVAR
-                       #undef WEP_ADD_PROP
+                       RIFLE_SETTINGS(WEP_SKIPCVAR, WEP_SET_PROP)
                        return TRUE;
                }
                case WR_SETUP:
                {
-                       weapon_setup(WEP_RIFLE);
                        self.current_ammo = ammo_nails;
                        return TRUE;
                }
@@ -232,11 +224,7 @@ float w_rifle(float req)
                }
                case WR_CONFIG:
                {
-                       #define WEP_ADD_CVAR(weapon,mode,name) WEP_CONFIG_WRITE_CVARS(weapon,mode,name)
-                       #define WEP_ADD_PROP(weapon,prop,name) WEP_CONFIG_WRITE_PROPS(weapon,prop,name)
-                       RIFLE_SETTINGS(rifle)
-                       #undef WEP_ADD_CVAR
-                       #undef WEP_ADD_PROP
+                       RIFLE_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS)
                        return TRUE;
                }
                case WR_RESETPLAYER:
@@ -246,7 +234,7 @@ float w_rifle(float req)
                }
                case WR_RELOAD:
                {
-                       W_Reload(min(WEP_CVAR_PRI(rifle, ammo), WEP_CVAR_SEC(rifle, ammo)), autocvar_g_balance_rifle_reload_ammo, autocvar_g_balance_rifle_reload_time, "weapons/reload.wav");
+                       W_Reload(min(WEP_CVAR_PRI(rifle, ammo), WEP_CVAR_SEC(rifle, ammo)), "weapons/reload.wav");
                        return TRUE;
                }
                case WR_SUICIDEMESSAGE: