#ifdef REGISTER_WEAPON
REGISTER_WEAPON(
-/* WEP_##id */ RIFLE,
-/* function */ w_rifle,
-/* ammotype */ IT_NAILS,
-/* impulse */ 7,
-/* flags */ WEP_FLAG_MUTATORBLOCKED | WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WEP_TYPE_HITSCAN,
-/* rating */ BOT_PICKUP_RATING_MID,
-/* model */ "campingrifle",
-/* shortname */ "rifle",
-/* fullname */ _("Rifle")
+/* WEP_##id */ RIFLE,
+/* function */ w_rifle,
+/* ammotype */ IT_NAILS,
+/* impulse */ 7,
+/* flags */ WEP_FLAG_MUTATORBLOCKED | WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WEP_TYPE_HITSCAN,
+/* rating */ BOT_PICKUP_RATING_MID,
+/* model */ "campingrifle",
+/* netname */ "rifle",
+/* fullname */ _("Rifle")
);
-#else
-#ifdef SVQC
+#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(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)
{
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);
}
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)
void W_Rifle_Attack()
{
- W_Rifle_FireBullet(autocvar_g_balance_rifle_primary_spread, autocvar_g_balance_rifle_primary_damage, autocvar_g_balance_rifle_primary_force, autocvar_g_balance_rifle_primary_speed, autocvar_g_balance_rifle_primary_lifetime, autocvar_g_balance_rifle_primary_ammo, WEP_RIFLE, autocvar_g_balance_rifle_primary_bulletconstant, autocvar_g_balance_rifle_primary_tracer, autocvar_g_balance_rifle_primary_shots, "weapons/campingrifle_fire.wav");
+ W_Rifle_FireBullet(WEP_CVAR_PRI(rifle, spread), WEP_CVAR_PRI(rifle, damage), WEP_CVAR_PRI(rifle, force), WEP_CVAR_PRI(rifle, speed), WEP_CVAR_PRI(rifle, lifetime), WEP_CVAR_PRI(rifle, ammo), WEP_RIFLE, WEP_CVAR_PRI(rifle, bulletconstant), WEP_CVAR_PRI(rifle, tracer), WEP_CVAR_PRI(rifle, shots), "weapons/campingrifle_fire.wav");
}
void W_Rifle_Attack2()
{
- W_Rifle_FireBullet(autocvar_g_balance_rifle_secondary_spread, autocvar_g_balance_rifle_secondary_damage, autocvar_g_balance_rifle_secondary_force, autocvar_g_balance_rifle_secondary_speed, autocvar_g_balance_rifle_secondary_lifetime, autocvar_g_balance_rifle_secondary_ammo, WEP_RIFLE | HITTYPE_SECONDARY, autocvar_g_balance_rifle_secondary_bulletconstant, autocvar_g_balance_rifle_secondary_tracer, autocvar_g_balance_rifle_secondary_shots, "weapons/campingrifle_fire2.wav");
-}
-
-void spawnfunc_weapon_rifle (void)
-{
- weapon_defaultspawnfunc(WEP_RIFLE);
-}
-
-// compatibility alias
-void spawnfunc_weapon_campingrifle (void)
-{
- spawnfunc_weapon_rifle();
-}
-void spawnfunc_weapon_sniperrifle (void)
-{
- spawnfunc_weapon_rifle();
+ W_Rifle_FireBullet(WEP_CVAR_SEC(rifle, spread), WEP_CVAR_SEC(rifle, damage), WEP_CVAR_SEC(rifle, force), WEP_CVAR_SEC(rifle, speed), WEP_CVAR_SEC(rifle, lifetime), WEP_CVAR_SEC(rifle, ammo), WEP_RIFLE | HITTYPE_SECONDARY, WEP_CVAR_SEC(rifle, bulletconstant), WEP_CVAR_SEC(rifle, tracer), WEP_CVAR_SEC(rifle, shots), "weapons/campingrifle_fire2.wav");
}
.void(void) rifle_bullethail_attackfunc;
self.bot_secondary_riflemooth = 0;
if(self.bot_secondary_riflemooth == 0)
{
- if(bot_aim(autocvar_g_balance_rifle_primary_speed, 0, autocvar_g_balance_rifle_primary_lifetime, FALSE))
+ if(bot_aim(WEP_CVAR_PRI(rifle, speed), 0, WEP_CVAR_PRI(rifle, lifetime), FALSE))
{
self.BUTTON_ATCK = TRUE;
if(random() < 0.01) self.bot_secondary_riflemooth = 1;
}
else
{
- if(bot_aim(autocvar_g_balance_rifle_secondary_speed, 0, autocvar_g_balance_rifle_secondary_lifetime, FALSE))
+ if(bot_aim(WEP_CVAR_SEC(rifle, speed), 0, WEP_CVAR_SEC(rifle, lifetime), FALSE))
{
self.BUTTON_ATCK2 = TRUE;
if(random() < 0.03) self.bot_secondary_riflemooth = 0;
}
case WR_THINK:
{
- if(autocvar_g_balance_rifle_reload_ammo && self.clip_load < min(autocvar_g_balance_rifle_primary_ammo, autocvar_g_balance_rifle_secondary_ammo)) // forced reload
- weapon_action(self.weapon, WR_RELOAD);
+ if(autocvar_g_balance_rifle_reload_ammo && self.clip_load < min(WEP_CVAR_PRI(rifle, ammo), WEP_CVAR_SEC(rifle, ammo))) // forced reload
+ WEP_ACTION(self.weapon, WR_RELOAD);
else
{
- self.rifle_accumulator = bound(time - autocvar_g_balance_rifle_bursttime, self.rifle_accumulator, time);
+ self.rifle_accumulator = bound(time - WEP_CVAR(rifle, bursttime), self.rifle_accumulator, time);
if (self.BUTTON_ATCK)
- if (weapon_prepareattack_check(0, autocvar_g_balance_rifle_primary_refire))
- if (time >= self.rifle_accumulator + autocvar_g_balance_rifle_primary_burstcost)
+ if (weapon_prepareattack_check(0, WEP_CVAR_PRI(rifle, refire)))
+ if (time >= self.rifle_accumulator + WEP_CVAR_PRI(rifle, burstcost))
{
- weapon_prepareattack_do(0, autocvar_g_balance_rifle_primary_refire);
- W_Rifle_BulletHail(autocvar_g_balance_rifle_primary_bullethail, W_Rifle_Attack, WFRAME_FIRE1, autocvar_g_balance_rifle_primary_animtime, autocvar_g_balance_rifle_primary_refire);
- self.rifle_accumulator += autocvar_g_balance_rifle_primary_burstcost;
+ weapon_prepareattack_do(0, WEP_CVAR_PRI(rifle, refire));
+ W_Rifle_BulletHail(WEP_CVAR_PRI(rifle, bullethail), W_Rifle_Attack, WFRAME_FIRE1, WEP_CVAR_PRI(rifle, animtime), WEP_CVAR_PRI(rifle, refire));
+ self.rifle_accumulator += WEP_CVAR_PRI(rifle, burstcost);
}
if (self.BUTTON_ATCK2)
{
- if (autocvar_g_balance_rifle_secondary)
+ if (WEP_CVAR(rifle, secondary))
{
- if(autocvar_g_balance_rifle_secondary_reload)
- weapon_action(self.weapon, WR_RELOAD);
+ if(WEP_CVAR_SEC(rifle, reload))
+ WEP_ACTION(self.weapon, WR_RELOAD);
else
{
- if (weapon_prepareattack_check(1, autocvar_g_balance_rifle_secondary_refire))
- if (time >= self.rifle_accumulator + autocvar_g_balance_rifle_secondary_burstcost)
+ if (weapon_prepareattack_check(1, WEP_CVAR_SEC(rifle, refire)))
+ if (time >= self.rifle_accumulator + WEP_CVAR_SEC(rifle, burstcost))
{
- weapon_prepareattack_do(1, autocvar_g_balance_rifle_secondary_refire);
- W_Rifle_BulletHail(autocvar_g_balance_rifle_secondary_bullethail, W_Rifle_Attack2, WFRAME_FIRE2, autocvar_g_balance_rifle_secondary_animtime, autocvar_g_balance_rifle_primary_refire);
- self.rifle_accumulator += autocvar_g_balance_rifle_secondary_burstcost;
+ weapon_prepareattack_do(1, WEP_CVAR_SEC(rifle, refire));
+ W_Rifle_BulletHail(WEP_CVAR_SEC(rifle, bullethail), W_Rifle_Attack2, WFRAME_FIRE2, WEP_CVAR_SEC(rifle, animtime), WEP_CVAR_PRI(rifle, refire));
+ self.rifle_accumulator += WEP_CVAR_SEC(rifle, burstcost);
}
}
}
return TRUE;
}
- case WR_PRECACHE:
+ case WR_INIT:
{
precache_model ("models/weapons/g_campingrifle.md3");
precache_model ("models/weapons/v_campingrifle.md3");
precache_model ("models/weapons/h_campingrifle.iqm");
precache_sound ("weapons/campingrifle_fire.wav");
precache_sound ("weapons/campingrifle_fire2.wav");
+ RIFLE_SETTINGS(WEP_SKIPCVAR, WEP_SET_PROP)
return TRUE;
}
case WR_SETUP:
{
- weapon_setup(WEP_RIFLE);
self.current_ammo = ammo_nails;
return TRUE;
}
case WR_CHECKAMMO1:
{
- ammo_amount = self.ammo_nails >= autocvar_g_balance_rifle_primary_ammo;
- ammo_amount += self.(weapon_load[WEP_RIFLE]) >= autocvar_g_balance_rifle_primary_ammo;
+ ammo_amount = self.ammo_nails >= WEP_CVAR_PRI(rifle, ammo);
+ ammo_amount += self.(weapon_load[WEP_RIFLE]) >= WEP_CVAR_PRI(rifle, ammo);
return ammo_amount;
}
case WR_CHECKAMMO2:
{
- ammo_amount = self.ammo_nails >= autocvar_g_balance_rifle_secondary_ammo;
- ammo_amount += self.(weapon_load[WEP_RIFLE]) >= autocvar_g_balance_rifle_secondary_ammo;
+ ammo_amount = self.ammo_nails >= WEP_CVAR_SEC(rifle, ammo);
+ ammo_amount += self.(weapon_load[WEP_RIFLE]) >= WEP_CVAR_SEC(rifle, ammo);
return ammo_amount;
}
+ case WR_CONFIG:
+ {
+ RIFLE_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS)
+ return TRUE;
+ }
case WR_RESETPLAYER:
{
- self.rifle_accumulator = time - autocvar_g_balance_rifle_bursttime;
+ self.rifle_accumulator = time - WEP_CVAR(rifle, bursttime);
return TRUE;
}
case WR_RELOAD:
{
- W_Reload(min(autocvar_g_balance_rifle_primary_ammo, autocvar_g_balance_rifle_secondary_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:
return TRUE;
}
- case WR_PRECACHE:
+ case WR_INIT:
{
precache_sound("weapons/ric1.wav");
precache_sound("weapons/ric2.wav");