.float electro_count;
.float electro_secondarytime;
-.float electro_load;
-
void W_Electro_SetAmmoCounter()
{
// set clip_load to the weapon we have switched to, if the gun uses reloading
if(!autocvar_g_balance_electro_reload_ammo)
return;
- if(!W_ReloadCheck(self.ammo_cells))
+ if(!W_ReloadCheck(self.ammo_cells, min(autocvar_g_balance_electro_primary_ammo, autocvar_g_balance_electro_secondary_ammo)))
return;
float t;
{
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.electro_load = self.clip_load;
+ }
+ else
+ self.ammo_cells -= autocvar_g_balance_electro_primary_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);
pointparticles(particleeffectnum("electro_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
CSQCProjectile(proj, TRUE, PROJECTILE_ELECTRO_BEAM, TRUE);
other = proj; MUTATOR_CALLHOOK(EditProjectile);
+}
+
+void W_Electro_Attack2()
+{
+ 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.clip_load -= autocvar_g_balance_electro_secondary_ammo;
self.electro_load = self.clip_load;
}
else
- self.ammo_cells -= autocvar_g_balance_electro_primary_ammo;
+ self.ammo_cells -= autocvar_g_balance_electro_secondary_ammo;
}
-}
-
-void W_Electro_Attack2()
-{
- local entity proj;
W_SetupShot_ProjectileSize (self, '0 0 -4', '0 0 -4', FALSE, 2, "weapons/electro_fire2.wav", CHAN_WEAPON, autocvar_g_balance_electro_secondary_damage);
CSQCProjectile(proj, TRUE, PROJECTILE_ELECTRO, FALSE); // no culling, it has sound
other = proj; MUTATOR_CALLHOOK(EditProjectile);
-
- // 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.electro_load = self.clip_load;
- }
- else
- self.ammo_cells -= autocvar_g_balance_electro_secondary_ammo;
- }
}
.vector hook_start, hook_end;
float dt, f;
dt = frametime;
+ // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
if not(self.owner.items & IT_UNLIMITED_WEAPON_AMMO)
{
- // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
if(autocvar_g_balance_electro_primary_ammo)
{
if(autocvar_g_balance_electro_reload_ammo)
}
}
}
-
- if(self.wish_reload)
- {
- if(self.switchweapon == self.weapon)
- {
- if(self.weaponentity.state == WS_READY)
- {
- self.wish_reload = 0;
- W_Electro_Reload();
- }
- }
- }
}
else if (req == WR_PRECACHE)
{
precache_sound ("weapons/electro_fire2.wav");
precache_sound ("weapons/electro_impact.wav");
precache_sound ("weapons/electro_impact_combo.wav");
+ precache_sound ("weapons/reload.wav");
if(autocvar_g_balance_electro_lightning)
{
precache_sound ("weapons/lgbeam_fire.wav");
{
W_Shotgun_Reload();
}
+ else if (req == WR_SWITCHABLE)
+ {
+ // checks if this weapon can be switched to, when reloading is enabled
+ // returns true if there's either enough load in the weapon to use it,
+ // or we have enough ammo to reload the weapon to a usable point
+ float ammo_amount;
+ ammo_amount = min(autocvar_g_balance_electro_primary_ammo, autocvar_g_balance_electro_secondary_ammo);
+ return (autocvar_g_balance_electro_reload_ammo && self.electro_load >= ammo_amount) || self.ammo_cells >= ammo_amount;
+ }
return TRUE;
};
#endif