]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/weapons/w_machinegun.qc
No need for that extra prefix
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / weapons / w_machinegun.qc
index 6afeb4ef27975708f920928735203072f714ded1..db222260e805c6e66487e55ccb6a5622bee4051f 100644 (file)
@@ -2,46 +2,50 @@
 REGISTER_WEAPON(
 /* WEP_##id */ UZI,
 /* function */ w_uzi,
-/* ammotype */ IT_NAILS,
+/* ammotype */ ammo_nails,
 /* impulse  */ 3,
-/* flags    */ WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WEP_TYPE_HITSCAN,
+/* flags    */ WEP_FLAG_RELOADABLE | WEP_TYPE_HITSCAN,
 /* rating   */ BOT_PICKUP_RATING_MID,
 /* model    */ "uzi",
 /* netname  */ "uzi",
 /* fullname */ _("Machine Gun")
 );
 
-#define UZI_SETTINGS(weapon) \
-       WEP_ADD_CVAR(weapon, MO_NONE, speed) \
-       WEP_ADD_CVAR(weapon, MO_NONE, spread_min) \
-       WEP_ADD_CVAR(weapon, MO_NONE, spread_max) \
-       WEP_ADD_CVAR(weapon, MO_NONE, spread_add) \
-       WEP_ADD_CVAR(weapon, MO_NONE, mode) \
-       WEP_ADD_CVAR(weapon, MO_NONE, bulletconstant) \
-       WEP_ADD_CVAR(weapon, MO_NONE, first) \
-       WEP_ADD_CVAR(weapon, MO_NONE, first_damage) \
-       WEP_ADD_CVAR(weapon, MO_NONE, first_force) \
-       WEP_ADD_CVAR(weapon, MO_NONE, first_refire) \
-       WEP_ADD_CVAR(weapon, MO_NONE, first_spread) \
-       WEP_ADD_CVAR(weapon, MO_NONE, first_ammo) \
-       WEP_ADD_CVAR(weapon, MO_NONE, sustained_damage) \
-       WEP_ADD_CVAR(weapon, MO_NONE, sustained_force) \
-       WEP_ADD_CVAR(weapon, MO_NONE, sustained_refire) \
-       WEP_ADD_CVAR(weapon, MO_NONE, sustained_spread) \
-       WEP_ADD_CVAR(weapon, MO_NONE, sustained_ammo) \
-       WEP_ADD_CVAR(weapon, MO_NONE, burst) \
-       WEP_ADD_CVAR(weapon, MO_NONE, burst_refire) \
-       WEP_ADD_CVAR(weapon, MO_NONE, burst_refire2) \
-       WEP_ADD_CVAR(weapon, MO_NONE, burst_animtime) \
-       WEP_ADD_CVAR(weapon, MO_NONE, burst_speed) \
-       WEP_ADD_CVAR(weapon, MO_NONE, burst_ammo) \
-       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 UZI_SETTINGS(w_cvar,w_prop) UZI_SETTINGS_LIST(w_cvar, w_prop, UZI, uzi)
+#define UZI_SETTINGS_LIST(w_cvar,w_prop,id,sn) \
+       w_cvar(id, sn, NONE, speed) \
+       w_cvar(id, sn, NONE, spread_min) \
+       w_cvar(id, sn, NONE, spread_max) \
+       w_cvar(id, sn, NONE, spread_add) \
+       w_cvar(id, sn, NONE, mode) \
+       w_cvar(id, sn, NONE, bulletconstant) \
+       w_cvar(id, sn, NONE, first) \
+       w_cvar(id, sn, NONE, first_damage) \
+       w_cvar(id, sn, NONE, first_force) \
+       w_cvar(id, sn, NONE, first_refire) \
+       w_cvar(id, sn, NONE, first_spread) \
+       w_cvar(id, sn, NONE, first_ammo) \
+       w_cvar(id, sn, NONE, sustained_damage) \
+       w_cvar(id, sn, NONE, sustained_force) \
+       w_cvar(id, sn, NONE, sustained_refire) \
+       w_cvar(id, sn, NONE, sustained_spread) \
+       w_cvar(id, sn, NONE, sustained_ammo) \
+       w_cvar(id, sn, NONE, burst) \
+       w_cvar(id, sn, NONE, burst_refire) \
+       w_cvar(id, sn, NONE, burst_refire2) \
+       w_cvar(id, sn, NONE, burst_animtime) \
+       w_cvar(id, sn, NONE, burst_speed) \
+       w_cvar(id, sn, NONE, burst_ammo) \
+       w_prop(id, sn, float,  reloading_ammo, reload_ammo) \
+       w_prop(id, sn, float,  reloading_time, reload_time) \
+       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)
 
 #ifdef SVQC
-UZI_SETTINGS(uzi)
+UZI_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
 #endif
 #else
 #ifdef SVQC
@@ -95,7 +99,7 @@ void UziFlash()
 
 void W_UZI_Attack (float deathtype)
 {
-       W_SetupShot (self, autocvar_g_antilag_bullets && WEP_CVAR(uzi, speed) >= autocvar_g_antilag_bullets, 0, "weapons/uzi_fire.wav", CH_WEAPON_A, ((self.misc_bulletcounter == 1) ? WEP_CVAR(uzi, first_damage) : WEP_CVAR(uzi, sustained_damage)));
+       W_SetupShot (self, TRUE, 0, "weapons/uzi_fire.wav", CH_WEAPON_A, ((self.misc_bulletcounter == 1) ? WEP_CVAR(uzi, first_damage) : WEP_CVAR(uzi, sustained_damage)));
        if (!autocvar_g_norecoil)
        {
                self.punchangle_x = random () - 0.5;
@@ -106,9 +110,9 @@ void W_UZI_Attack (float deathtype)
        ATTACK_FINISHED(self) = time + WEP_CVAR(uzi, first_refire) * W_WeaponRateFactor();
 
        if (self.misc_bulletcounter == 1)
-               fireBallisticBullet(w_shotorg, w_shotdir, WEP_CVAR(uzi, first_spread), WEP_CVAR(uzi, speed), 5, WEP_CVAR(uzi, first_damage), WEP_CVAR(uzi, first_force), deathtype, 0, 1, WEP_CVAR(uzi, bulletconstant));
+               fireBallisticBullet(w_shotorg, w_shotdir, WEP_CVAR(uzi, first_spread), WEP_CVAR(uzi, speed), 5, WEP_CVAR(uzi, first_damage), WEP_CVAR(uzi, first_force), deathtype, 0, WEP_CVAR(uzi, bulletconstant));
        else
-               fireBallisticBullet(w_shotorg, w_shotdir, WEP_CVAR(uzi, sustained_spread), WEP_CVAR(uzi, speed), 5, WEP_CVAR(uzi, sustained_damage), WEP_CVAR(uzi, sustained_force), deathtype, 0, 1, WEP_CVAR(uzi, bulletconstant));
+               fireBallisticBullet(w_shotorg, w_shotdir, WEP_CVAR(uzi, sustained_spread), WEP_CVAR(uzi, speed), 5, WEP_CVAR(uzi, sustained_damage), WEP_CVAR(uzi, sustained_force), deathtype, 0, WEP_CVAR(uzi, bulletconstant));
        endFireBallisticBullet();
 
        pointparticles(particleeffectnum("uzi_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
@@ -121,9 +125,9 @@ void W_UZI_Attack (float deathtype)
                SpawnCasing (((random () * 50 + 50) * v_right) - (v_forward * (random () * 25 + 25)) - ((random () * 5 - 70) * v_up), 2, vectoangles(v_forward),'0 250 0', 100, 3, self);
 
        if (self.misc_bulletcounter == 1)
-               W_DecreaseAmmo(ammo_nails, WEP_CVAR(uzi, first_ammo), autocvar_g_balance_uzi_reload_ammo);
+               W_DecreaseAmmo(WEP_CVAR(uzi, first_ammo));
        else
-               W_DecreaseAmmo(ammo_nails, WEP_CVAR(uzi, sustained_ammo), autocvar_g_balance_uzi_reload_ammo);
+               W_DecreaseAmmo(WEP_CVAR(uzi, sustained_ammo));
 }
 
 // weapon frames
@@ -137,7 +141,7 @@ void uzi_fire1_02()
        if (self.BUTTON_ATCK)
        {
                if (!WEP_ACTION(self.weapon, WR_CHECKAMMO2))
-               if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
+               if (!(self.items & IT_UNLIMITED_WEAPON_AMMO))
                {
                        W_SwitchWeapon_Force(self, w_getbestweapon(self));
                        w_ready();
@@ -163,16 +167,16 @@ void uzi_mode1_fire_auto()
        }
 
        if (!WEP_ACTION(self.weapon, WR_CHECKAMMO1))
-       if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
+       if (!(self.items & IT_UNLIMITED_WEAPON_AMMO))
        {
                W_SwitchWeapon_Force(self, w_getbestweapon(self));
                w_ready();
                return;
        }
 
-       W_DecreaseAmmo(ammo_nails, WEP_CVAR(uzi, sustained_ammo), autocvar_g_balance_uzi_reload_ammo);
+       W_DecreaseAmmo(WEP_CVAR(uzi, sustained_ammo));
 
-       W_SetupShot (self, autocvar_g_antilag_bullets && WEP_CVAR(uzi, speed) >= autocvar_g_antilag_bullets, 0, "weapons/uzi_fire.wav", CH_WEAPON_A, WEP_CVAR(uzi, sustained_damage));
+       W_SetupShot (self, TRUE, 0, "weapons/uzi_fire.wav", CH_WEAPON_A, WEP_CVAR(uzi, sustained_damage));
        if (!autocvar_g_norecoil)
        {
                self.punchangle_x = random () - 0.5;
@@ -180,7 +184,7 @@ void uzi_mode1_fire_auto()
        }
 
        uzi_spread = bound(WEP_CVAR(uzi, spread_min), WEP_CVAR(uzi, spread_min) + (WEP_CVAR(uzi, spread_add) * self.misc_bulletcounter), WEP_CVAR(uzi, spread_max));
-       fireBallisticBullet(w_shotorg, w_shotdir, uzi_spread, WEP_CVAR(uzi, speed), 5, WEP_CVAR(uzi, sustained_damage), WEP_CVAR(uzi, sustained_force), WEP_UZI, 0, 1, WEP_CVAR(uzi, bulletconstant));
+       fireBallisticBullet(w_shotorg, w_shotdir, uzi_spread, WEP_CVAR(uzi, speed), 5, WEP_CVAR(uzi, sustained_damage), WEP_CVAR(uzi, sustained_force), WEP_UZI, 0, WEP_CVAR(uzi, bulletconstant));
        endFireBallisticBullet();
 
        self.misc_bulletcounter = self.misc_bulletcounter + 1;
@@ -199,14 +203,14 @@ void uzi_mode1_fire_auto()
 
 void uzi_mode1_fire_burst()
 {
-       W_SetupShot (self, autocvar_g_antilag_bullets && WEP_CVAR(uzi, speed) >= autocvar_g_antilag_bullets, 0, "weapons/uzi_fire.wav", CH_WEAPON_A, WEP_CVAR(uzi, sustained_damage));
+       W_SetupShot (self, TRUE, 0, "weapons/uzi_fire.wav", CH_WEAPON_A, WEP_CVAR(uzi, sustained_damage));
        if (!autocvar_g_norecoil)
        {
                self.punchangle_x = random () - 0.5;
                self.punchangle_y = random () - 0.5;
        }
 
-       fireBallisticBullet(w_shotorg, w_shotdir, WEP_CVAR(uzi, burst_speed), WEP_CVAR(uzi, speed), 5, WEP_CVAR(uzi, sustained_damage), WEP_CVAR(uzi, sustained_force), WEP_UZI, 0, 1, WEP_CVAR(uzi, bulletconstant));
+       fireBallisticBullet(w_shotorg, w_shotdir, WEP_CVAR(uzi, burst_speed), WEP_CVAR(uzi, speed), 5, WEP_CVAR(uzi, sustained_damage), WEP_CVAR(uzi, sustained_force), WEP_UZI, 0, WEP_CVAR(uzi, bulletconstant));
        endFireBallisticBullet();
 
 
@@ -262,14 +266,14 @@ float w_uzi(float req)
                                if(weapon_prepareattack(1, 0))
                                {
                                        if (!WEP_ACTION(self.weapon, WR_CHECKAMMO2))
-                                       if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
+                                       if (!(self.items & IT_UNLIMITED_WEAPON_AMMO))
                                        {
                                                W_SwitchWeapon_Force(self, w_getbestweapon(self));
                                                w_ready();
                                                return FALSE;
                                        }
 
-                                       W_DecreaseAmmo(ammo_nails, WEP_CVAR(uzi, burst_ammo), autocvar_g_balance_uzi_reload_ammo);
+                                       W_DecreaseAmmo(WEP_CVAR(uzi, burst_ammo));
 
                                        self.misc_bulletcounter = WEP_CVAR(uzi, burst) * -1;
                                        uzi_mode1_fire_burst();
@@ -304,7 +308,7 @@ float w_uzi(float req)
                        precache_model ("models/weapons/v_uzi.md3");
                        precache_model ("models/weapons/h_uzi.iqm");
                        precache_sound ("weapons/uzi_fire.wav");
-                       WEP_SET_PROPS(UZI_SETTINGS(uzi), WEP_UZI)
+                       UZI_SETTINGS(WEP_SKIPCVAR, WEP_SET_PROP)
                        return TRUE;
                }
                case WR_SETUP:
@@ -346,7 +350,7 @@ float w_uzi(float req)
                }
                case WR_CONFIG:
                {
-                       WEP_CONFIG_SETTINGS(UZI_SETTINGS(uzi))
+                       UZI_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS)
                        return TRUE;
                }
                case WR_RELOAD: