#define W_SETUPPROJECTILEVELOCITY_UP(m,s) W_SetupProjectileVelocityEx(m, w_shotdir, v_up, cvar(#s "_speed"), cvar(#s "_speed_up"), cvar(#s "_speed_z"), cvar(#s "_spread"), FALSE)
#define W_SETUPPROJECTILEVELOCITY(m,s) W_SetupProjectileVelocityEx(m, w_shotdir, v_up, cvar(#s "_speed"), 0, 0, cvar(#s "_spread"), FALSE)
+void W_DecreaseAmmo(.float ammo_type, float ammo_use, float ammo_reload)
+{
+ // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
+ if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
+ {
+ if(ammo_reload)
+ {
+ self.clip_load -= ammo_use;
+ self.weapon_load[self.weapon] = self.clip_load;
+ }
+ else
+ {
+ self.current_ammo = ammo_type;
+ self.(self.current_ammo) -= ammo_use;
+ }
+ }
+}
+
// weapon reloading code
-..float reload_ammo_player;
.float reload_ammo_amount, reload_ammo_min, reload_time;
.float reload_complain;
.string reload_sound;
self.clip_load = self.reload_ammo_amount;
else
{
- while(self.clip_load < self.reload_ammo_amount && self.(self.reload_ammo_player)) // make sure we don't add more ammo than we have
+ while(self.clip_load < self.reload_ammo_amount && self.(self.current_ammo)) // make sure we don't add more ammo than we have
{
self.clip_load += 1;
- self.(self.reload_ammo_player) -= 1;
+ self.(self.current_ammo) -= 1;
}
}
self.weapon_load[self.weapon] = self.clip_load;
if(!self.reload_ammo_amount)
return;
- if(!W_ReloadCheck(self.(self.reload_ammo_player), self.reload_ammo_min))
+ if(!W_ReloadCheck(self.(self.current_ammo), self.reload_ammo_min))
return;
float t;
void W_Reload(.float sent_ammo_player, float sent_ammo_min, float sent_ammo_amount, float sent_time, string sent_sound)
{
- self.reload_ammo_player = sent_ammo_player;
+ self.current_ammo = sent_ammo_player;
self.reload_ammo_min = sent_ammo_min;
self.reload_ammo_amount = sent_ammo_amount;
self.reload_time = sent_time;
float client_cefc_accumulatortime;
#endif
+..float current_ammo;
+
.float weapon_load[WEP_MAXCOUNT]; FTEQCC_YOU_SUCK_THIS_IS_NOT_UNREFERENCED(weapon_load);
.float zero_ammo; // used by the reloading system, must always be 0
.float clip_load;
vector forward, right, up;
float maxdmg;
- // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
- if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
- {
- if(autocvar_g_balance_crylink_reload_ammo)
- {
- self.clip_load -= autocvar_g_balance_crylink_primary_ammo;
- self.weapon_load[WEP_CRYLINK] = self.clip_load;
- }
- else
- self.ammo_cells -= autocvar_g_balance_crylink_primary_ammo;
- }
+ W_DecreaseAmmo(ammo_cells, autocvar_g_balance_crylink_primary_ammo, autocvar_g_balance_crylink_reload_ammo);
maxdmg = autocvar_g_balance_crylink_primary_damage*autocvar_g_balance_crylink_primary_shots;
maxdmg *= 1 + autocvar_g_balance_crylink_primary_bouncedamagefactor * autocvar_g_balance_crylink_primary_bounces;
local entity proj, prevproj, firstproj;
float maxdmg;
- // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
- if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
- {
- if(autocvar_g_balance_crylink_reload_ammo)
- {
- self.clip_load -= autocvar_g_balance_crylink_secondary_ammo;
- self.weapon_load[WEP_CRYLINK] = self.clip_load;
- }
- else
- self.ammo_cells -= autocvar_g_balance_crylink_secondary_ammo;
- }
+ W_DecreaseAmmo(ammo_cells, autocvar_g_balance_crylink_secondary_ammo, autocvar_g_balance_crylink_reload_ammo);
maxdmg = autocvar_g_balance_crylink_secondary_damage*autocvar_g_balance_crylink_secondary_shots;
maxdmg *= 1 + autocvar_g_balance_crylink_secondary_bouncedamagefactor * autocvar_g_balance_crylink_secondary_bounces;
{
local entity proj;
- // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
- if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
- {
- if(autocvar_g_balance_electro_reload_ammo)
- {
- self.clip_load -= autocvar_g_balance_electro_primary_ammo;
- self.weapon_load[WEP_ELECTRO] = self.clip_load;
- }
- else
- self.ammo_cells -= autocvar_g_balance_electro_primary_ammo;
- }
+ W_DecreaseAmmo(ammo_cells, autocvar_g_balance_electro_primary_ammo, autocvar_g_balance_electro_reload_ammo);
W_SetupShot_ProjectileSize (self, '0 0 -3', '0 0 -3', FALSE, 2, "weapons/electro_fire.wav", CHAN_WEAPON, autocvar_g_balance_electro_primary_damage);
{
local entity proj;
- // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
- if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
- {
- if(autocvar_g_balance_electro_reload_ammo)
- {
- self.clip_load -= autocvar_g_balance_electro_secondary_ammo;
- self.weapon_load[WEP_ELECTRO] = self.clip_load;
- }
- else
- self.ammo_cells -= autocvar_g_balance_electro_secondary_ammo;
- }
+ W_DecreaseAmmo(ammo_cells, autocvar_g_balance_electro_secondary_ammo, autocvar_g_balance_electro_reload_ammo);
W_SetupShot_ProjectileSize (self, '0 0 -4', '0 0 -4', FALSE, 2, "weapons/electro_fire2.wav", CHAN_WEAPON, autocvar_g_balance_electro_secondary_damage);
void W_Fireball_Attack1_Frame0()
{
- // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
- if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
- {
- if(autocvar_g_balance_fireball_reload_ammo)
- {
- self.clip_load -= autocvar_g_balance_fireball_primary_ammo;
- self.weapon_load[WEP_FIREBALL] = self.clip_load;
- }
- else
- self.ammo_fuel -= autocvar_g_balance_fireball_primary_ammo;
- }
+ W_DecreaseAmmo(ammo_fuel, autocvar_g_balance_fireball_primary_ammo, autocvar_g_balance_fireball_reload_ammo);
W_Fireball_AttackEffect(0, '-1.25 -3.75 0');
sound (self, CHAN_WEAPON, "weapons/fireball_prefire2.wav", VOL_BASE, ATTN_NORM);
vector f_diff;
float c;
- // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
- if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
- {
- if(autocvar_g_balance_fireball_reload_ammo)
- {
- self.clip_load -= autocvar_g_balance_fireball_secondary_ammo;
- self.weapon_load[WEP_FIREBALL] = self.clip_load;
- }
- else
- self.ammo_fuel -= autocvar_g_balance_fireball_secondary_ammo;
- }
+ W_DecreaseAmmo(ammo_fuel, autocvar_g_balance_fireball_secondary_ammo, autocvar_g_balance_fireball_reload_ammo);
c = mod(self.bulletcounter, 4);
switch(c)
{
local entity gren;
- // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
- if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
- {
- if(autocvar_g_balance_grenadelauncher_reload_ammo)
- {
- self.clip_load -= autocvar_g_balance_grenadelauncher_primary_ammo;
- self.weapon_load[WEP_GRENADE_LAUNCHER] = self.clip_load;
- }
- else
- self.ammo_rockets -= autocvar_g_balance_grenadelauncher_primary_ammo;
- }
+ W_DecreaseAmmo(ammo_rockets, autocvar_g_balance_grenadelauncher_primary_ammo, autocvar_g_balance_grenadelauncher_reload_ammo);
W_SetupShot_ProjectileSize (self, '-3 -3 -3', '3 3 3', FALSE, 4, "weapons/grenade_fire.wav", CHAN_WEAPON, autocvar_g_balance_grenadelauncher_primary_damage);
w_shotdir = v_forward; // no TrueAim for grenades please
{
local entity gren;
- // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
- if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
- {
- if(autocvar_g_balance_grenadelauncher_reload_ammo)
- {
- self.clip_load -= autocvar_g_balance_grenadelauncher_secondary_ammo;
- self.weapon_load[WEP_GRENADE_LAUNCHER] = self.clip_load;
- }
- else
- self.ammo_rockets -= autocvar_g_balance_grenadelauncher_secondary_ammo;
- }
+ W_DecreaseAmmo(ammo_rockets, autocvar_g_balance_grenadelauncher_secondary_ammo, autocvar_g_balance_grenadelauncher_reload_ammo);
W_SetupShot_ProjectileSize (self, '-3 -3 -3', '3 3 3', FALSE, 4, "weapons/grenade_fire.wav", CHAN_WEAPON, autocvar_g_balance_grenadelauncher_secondary_damage);
w_shotdir = v_forward; // no TrueAim for grenades please
{
local entity missile;
- // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
- if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
- {
- if(autocvar_g_balance_hagar_reload_ammo)
- {
- self.clip_load -= autocvar_g_balance_hagar_primary_ammo;
- self.weapon_load[WEP_HAGAR] = self.clip_load;
- }
- else
- self.ammo_rockets -= autocvar_g_balance_hagar_primary_ammo;
- }
+ W_DecreaseAmmo(ammo_rockets, autocvar_g_balance_hagar_primary_ammo, autocvar_g_balance_hagar_reload_ammo);
W_SetupShot (self, FALSE, 2, "weapons/hagar_fire.wav", CHAN_WEAPON, autocvar_g_balance_hagar_primary_damage);
{
local entity missile;
- // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
- if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
- {
- if(autocvar_g_balance_hagar_reload_ammo)
- {
- self.clip_load -= autocvar_g_balance_hagar_secondary_ammo;
- self.weapon_load[WEP_HAGAR] = self.clip_load;
- }
- else
- self.ammo_rockets -= autocvar_g_balance_hagar_secondary_ammo;
- }
+ W_DecreaseAmmo(ammo_rockets, autocvar_g_balance_hagar_secondary_ammo, autocvar_g_balance_hagar_reload_ammo);
W_SetupShot (self, FALSE, 2, "weapons/hagar_fire.wav", CHAN_WEAPON, autocvar_g_balance_hagar_secondary_damage);
local entity missile;
float spread;
- // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
- if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
- {
- if(autocvar_g_balance_hlac_reload_ammo)
- {
- self.clip_load -= autocvar_g_balance_hlac_primary_ammo;
- self.weapon_load[WEP_HLAC] = self.clip_load;
- }
- else
- self.ammo_cells -= autocvar_g_balance_hlac_primary_ammo;
- }
+ W_DecreaseAmmo(ammo_cells, autocvar_g_balance_hlac_primary_ammo, autocvar_g_balance_hlac_reload_ammo);
spread = autocvar_g_balance_hlac_primary_spread_min + (autocvar_g_balance_hlac_primary_spread_add * self.misc_bulletcounter);
spread = min(spread,autocvar_g_balance_hlac_primary_spread_max);
{
float i;
- // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
- if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
- {
- if(autocvar_g_balance_hlac_reload_ammo)
- {
- self.clip_load -= autocvar_g_balance_hlac_secondary_ammo;
- self.weapon_load[WEP_HLAC] = self.clip_load;
- }
- else
- self.ammo_cells -= autocvar_g_balance_hlac_secondary_ammo;
- }
+ W_DecreaseAmmo(ammo_cells, autocvar_g_balance_hlac_secondary_ammo, autocvar_g_balance_hlac_reload_ammo);
for(i=autocvar_g_balance_hlac_secondary_shots;i>0;--i)
W_HLAC_Attack2f();
}
}
- // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
- if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
- {
- if(autocvar_g_balance_minelayer_reload_ammo)
- {
- self.clip_load -= autocvar_g_balance_minelayer_ammo;
- self.weapon_load[WEP_MINE_LAYER] = self.clip_load;
- }
- else
- self.ammo_rockets -= autocvar_g_balance_minelayer_ammo;
- }
+ W_DecreaseAmmo(ammo_rockets, autocvar_g_balance_minelayer_ammo, autocvar_g_balance_minelayer_reload_ammo);
W_SetupShot_ProjectileSize (self, '-4 -4 -4', '4 4 4', FALSE, 5, "weapons/mine_fire.wav", CHAN_WEAPON, autocvar_g_balance_minelayer_damage);
pointparticles(particleeffectnum("rocketlauncher_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
if (trace_ent.solid == SOLID_BSP && !(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT))
Damage_DamageInfo(trace_endpos, 10000, 0, 0, 800 * w_shotdir, WEP_MINSTANEX, self);
- // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
- if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
- {
- if(autocvar_g_balance_minstanex_reload_ammo)
- {
- if (g_minstagib)
- self.clip_load -= - 1;
- else
- self.clip_load -= autocvar_g_balance_minstanex_ammo;
- self.weapon_load[WEP_MINSTANEX] = self.clip_load;
- }
- else
- {
- if (g_minstagib)
- self.ammo_cells -= - 1;
- else
- self.ammo_cells -= autocvar_g_balance_minstanex_ammo;
- }
- }
+ if (g_minstagib)
+ W_DecreaseAmmo(ammo_cells, 1, autocvar_g_balance_minstanex_reload_ammo);
+ else
+ W_DecreaseAmmo(ammo_cells, autocvar_g_balance_minstanex_ammo, autocvar_g_balance_minstanex_reload_ammo);
}
// decrease ammo for the laser?
if(autocvar_g_balance_minstanex_laser_ammo)
- {
- if(autocvar_g_balance_minstanex_reload_ammo)
- self.clip_load -= autocvar_g_balance_minstanex_laser_ammo;
- else
- self.ammo_cells -= autocvar_g_balance_minstanex_laser_ammo;
- }
+ W_DecreaseAmmo(ammo_cells, autocvar_g_balance_minstanex_laser_ammo, autocvar_g_balance_minstanex_reload_ammo);
// ugly minstagib hack to reuse the fire mode of the laser
float w;
if (trace_ent.solid == SOLID_BSP && !(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT))
Damage_DamageInfo(trace_endpos, mydmg, 0, 0, myforce * w_shotdir, WEP_NEX, self);
- // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
- if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
- {
- if(autocvar_g_balance_nex_reload_ammo)
- {
- self.clip_load -= myammo;
- self.weapon_load[WEP_NEX] = self.clip_load;
- }
- else
- self.ammo_cells -= myammo;
- }
+ W_DecreaseAmmo(ammo_cells, myammo, autocvar_g_balance_nex_reload_ammo);
}
void spawnfunc_weapon_nex (void); // defined in t_items.qc
local entity missile;
local entity flash;
- // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
- if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
- {
- if(autocvar_g_balance_rocketlauncher_reload_ammo)
- {
- self.clip_load -= autocvar_g_balance_rocketlauncher_ammo;
- self.weapon_load[WEP_ROCKET_LAUNCHER] = self.clip_load;
- }
- else
- self.ammo_rockets -= autocvar_g_balance_rocketlauncher_ammo;
- }
+ W_DecreaseAmmo(ammo_rockets, autocvar_g_balance_rocketlauncher_ammo, autocvar_g_balance_rocketlauncher_reload_ammo);
W_SetupShot_ProjectileSize (self, '-3 -3 -3', '3 3 3', FALSE, 5, "weapons/rocket_fire.wav", CHAN_WEAPON, autocvar_g_balance_rocketlauncher_damage);
pointparticles(particleeffectnum("rocketlauncher_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
{
local entity missile;
- // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
- if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
- {
- if(autocvar_g_balance_seeker_reload_ammo)
- {
- self.clip_load -= autocvar_g_balance_seeker_missile_ammo;
- self.weapon_load[WEP_SEEKER] = self.clip_load;
- }
- else
- self.ammo_rockets -= autocvar_g_balance_seeker_missile_ammo;
- }
+ W_DecreaseAmmo(ammo_rockets, autocvar_g_balance_seeker_missile_ammo, autocvar_g_balance_seeker_reload_ammo);
makevectors(self.v_angle);
W_SetupShot_ProjectileSize (self, '-2 -2 -2', '2 2 2', FALSE, 2, "weapons/seeker_fire.wav", CHAN_WEAPON, 0);
void Seeker_Fire_Tag()
{
local entity missile;
- // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
- if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
- {
- if(autocvar_g_balance_seeker_reload_ammo)
- {
- self.clip_load -= autocvar_g_balance_seeker_tag_ammo;
- self.weapon_load[WEP_SEEKER] = self.clip_load;
- }
- else
- self.ammo_rockets -= autocvar_g_balance_seeker_tag_ammo;
- }
+ W_DecreaseAmmo(ammo_rockets, autocvar_g_balance_seeker_tag_ammo, autocvar_g_balance_seeker_reload_ammo);
W_SetupShot_ProjectileSize (self, '-2 -2 -2', '2 2 2', FALSE, 2, "weapons/tag_fire.wav", CHAN_WEAPON, autocvar_g_balance_seeker_missile_damage * autocvar_g_balance_seeker_missile_count);
vector f_diff;
float c;
- // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
- if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
- {
- if(autocvar_g_balance_seeker_reload_ammo)
- {
- self.clip_load -= autocvar_g_balance_seeker_flac_ammo;
- self.weapon_load[WEP_SEEKER] = self.clip_load;
- }
- else
- self.ammo_rockets -= autocvar_g_balance_seeker_flac_ammo;
- }
+ W_DecreaseAmmo(ammo_rockets, autocvar_g_balance_seeker_flac_ammo, autocvar_g_balance_seeker_reload_ammo);
c = mod(self.bulletcounter, 4);
switch(c)
bulletspeed = autocvar_g_balance_shotgun_primary_speed;
bulletconstant = autocvar_g_balance_shotgun_primary_bulletconstant;
- // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
- if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
- {
- if(autocvar_g_balance_shotgun_reload_ammo)
- {
- self.clip_load -= ammoamount;
- self.weapon_load[WEP_SHOTGUN] = self.clip_load;
- }
- else
- self.ammo_shells -= ammoamount;
- }
+ W_DecreaseAmmo(ammo_shells, ammoamount, autocvar_g_balance_shotgun_reload_ammo);
W_SetupShot (self, autocvar_g_antilag_bullets && bulletspeed >= autocvar_g_antilag_bullets, 5, "weapons/shotgun_fire.wav", CHAN_WEAPON, d * bullets);
for (sc = 0;sc < bullets;sc = sc + 1)
void W_SniperRifle_FireBullet(float pSpread, float pDamage, float pHeadshotAddedDamage, float pForce, float pSpeed, float pLifetime, float pAmmo, float deathtype, float pBulletConstant)
{
- // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
- if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
- {
- if(autocvar_g_balance_sniperrifle_reload_ammo)
- {
- self.clip_load -= pAmmo;
- self.weapon_load[WEP_SNIPERRIFLE] = self.clip_load;
- }
- else
- self.ammo_nails -= pAmmo;
- }
+ W_DecreaseAmmo(ammo_nails, pAmmo, autocvar_g_balance_sniperrifle_reload_ammo);
if(deathtype & HITTYPE_SECONDARY)
W_SetupShot (self, autocvar_g_antilag_bullets && pSpeed >= autocvar_g_antilag_bullets, 2, "weapons/campingrifle_fire2.wav", CHAN_WEAPON, autocvar_g_balance_sniperrifle_secondary_damage + autocvar_g_balance_sniperrifle_secondary_headshotaddeddamage);