void W_Reload()
{
- weapon_action(self.switchweapon, WR_RELOAD);
+ self.wish_reload = 1;
}
// switch between weapons
{
oldself = self;
self = cl;
- f = weapon_action(wpn, WR_SWITCHABLE);
-
- // allow switching to reloadable weapons, even if we're out of ammo, since the weapon itself
- // might still be loaded. The reload code takes care of complaining and forced switching
- entity e;
- e = get_weaponinfo(wpn);
- if(wpn != WEP_TUBA && wpn != WEP_PORTO && wpn != WEP_HOOK) // skip non-reloadable weapons, or we access undefined cvars
+ f = weapon_action(wpn, WR_CHECKAMMO1);
+ f = f + weapon_action(wpn, WR_CHECKAMMO2);
// always allow selecting the Mine Layer if we placed mines, so that we can detonate them
local entity mine;
#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)
-// shared weapon reload code
.float reload_complain;
float W_ReloadCheck(float ammo_amount, float ammo_shot)
{
.float clip_load;
.float old_clip_load;
.float clip_size;
+.float wish_reload;
// weapon load persistence, for weapons that support reloading
.float laser_load;
}
}
}
+ if(self.wish_reload)
+ {
+ if(self.switchweapon == self.weapon)
+ {
+ if(self.weaponentity.state == WS_READY)
+ {
+ self.wish_reload = 0;
+ W_Crylink_Reload();
+ }
+ }
+ }
}
else if (req == WR_PRECACHE)
{
{
W_Crylink_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_crylink_primary_ammo, autocvar_g_balance_crylink_secondary_ammo);
- return (autocvar_g_balance_crylink_reload_ammo && self.crylink_load >= ammo_amount) || self.ammo_cells >= ammo_amount;
- }
return TRUE;
};
#endif
}
}
}
+
+ 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)
{
{
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
weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_fireball_secondary_animtime, w_ready);
}
}
+ if(self.wish_reload)
+ {
+ if(self.switchweapon == self.weapon)
+ {
+ if(self.weaponentity.state == WS_READY)
+ {
+ self.wish_reload = 0;
+ W_Fireball_Reload();
+ }
+ }
+ }
}
else if (req == WR_PRECACHE)
{
{
W_Fireball_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_fireball_primary_ammo, autocvar_g_balance_fireball_secondary_ammo);
- return (autocvar_g_balance_fireball_reload_ammo && self.fireball_load >= ammo_amount) || self.ammo_fuel >= ammo_amount;
- }
return TRUE;
};
#endif
weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_grenadelauncher_secondary_animtime, w_ready);
}
}
+ if(self.wish_reload)
+ {
+ if(self.switchweapon == self.weapon)
+ {
+ if(self.weaponentity.state == WS_READY)
+ {
+ self.wish_reload = 0;
+ W_GrenadeLauncher_Reload();
+ }
+ }
+ }
}
else if (req == WR_PRECACHE)
{
{
W_GrenadeLauncher_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_grenadelauncher_primary_ammo, autocvar_g_balance_grenadelauncher_secondary_ammo);
- return (autocvar_g_balance_grenadelauncher_reload_ammo && self.grenadelauncher_load) >= ammo_amount || self.ammo_rockets >= ammo_amount;
- }
return TRUE;
};
#endif
weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_hagar_secondary_refire, w_ready);
}
}
+ if(self.wish_reload)
+ {
+ if(self.switchweapon == self.weapon)
+ {
+ if(self.weaponentity.state == WS_READY)
+ {
+ self.wish_reload = 0;
+ W_Hagar_Reload();
+ }
+ }
+ }
}
else if (req == WR_PRECACHE)
{
{
W_Hagar_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_hagar_primary_ammo, autocvar_g_balance_hagar_secondary_ammo);
- return (autocvar_g_balance_hagar_reload_ammo && self.hagar_load >= ammo_amount) || self.ammo_rockets >= ammo_amount;
- }
return TRUE;
};
#endif
weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_hlac_secondary_animtime, w_ready);
}
}
+ if(self.wish_reload)
+ {
+ if(self.switchweapon == self.weapon)
+ {
+ if(self.weaponentity.state == WS_READY)
+ {
+ self.wish_reload = 0;
+ W_HLAC_Reload();
+ }
+ }
+ }
}
else if (req == WR_PRECACHE)
{
{
W_HLAC_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_hlac_primary_ammo, autocvar_g_balance_hlac_secondary_ammo);
- return (autocvar_g_balance_hlac_reload_ammo && self.hlac_load >= ammo_amount) || self.ammo_cells >= ammo_amount;
- }
return TRUE;
};
#endif
{
self.hook_refire = time;
}
- else if (req == WR_SWITCHABLE)
- {
- // no reloading system, return true
- return TRUE;
- }
return TRUE;
};
#endif
W_SwitchWeapon (self.cnt);
}
}
+ if(self.wish_reload)
+ {
+ if(self.switchweapon == self.weapon)
+ {
+ if(self.weaponentity.state == WS_READY)
+ {
+ self.wish_reload = 0;
+ W_Laser_Reload();
+ }
+ }
+ }
}
else if (req == WR_PRECACHE)
{
return TRUE;
else if (req == WR_RELOAD)
W_Laser_Reload();
- else if (req == WR_SWITCHABLE)
- {
- // laser uses no ammo, always switchable
- return TRUE;
- }
return TRUE;
};
#endif
if(minfound)
sound (self, CHAN_WEAPON2, "weapons/mine_det.wav", VOL_BASE, ATTN_NORM);
}
+
+ if(self.wish_reload)
+ {
+ if(self.switchweapon == self.weapon)
+ {
+ if(self.weaponentity.state == WS_READY)
+ {
+ self.wish_reload = 0;
+ W_MineLayer_Reload();
+ }
+ }
+ }
}
else if (req == WR_PRECACHE)
{
{
W_MineLayer_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 = autocvar_g_balance_minelayer_ammo;
- return (autocvar_g_balance_minelayer_reload_ammo && self.minelayer_load >= ammo_amount) || self.ammo_rockets >= ammo_amount;
- }
return TRUE;
};
#endif
self.weapon = w;
}
}
+ if(self.wish_reload)
+ {
+ if(self.switchweapon == self.weapon)
+ {
+ if(self.weaponentity.state == WS_READY)
+ {
+ self.wish_reload = 0;
+ W_Minstanex_Reload();
+ }
+ }
+ }
}
else if (req == WR_PRECACHE)
{
{
W_Minstanex_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;
- if(g_minstagib)
- ammo_amount = 1;
- else
- ammo_amount = autocvar_g_balance_minstanex_ammo;
- if(autocvar_g_balance_minstanex_laser_ammo)
- ammo_amount = min(ammo_amount, autocvar_g_balance_minstanex_laser_ammo);
-
- return (autocvar_g_balance_minstanex_reload_ammo && self.minstanex_load >= ammo_amount) || self.ammo_cells >= ammo_amount;
- }
return TRUE;
};
#endif
self.weaponentity_glowmod_z = self.weaponentity_glowmod_z + autocvar_g_weapon_charge_colormod_hdrmultiplier * autocvar_g_weapon_charge_colormod_blue_full * (self.nex_charge - autocvar_g_balance_nex_charge_limit) / (1 - autocvar_g_balance_nex_charge_limit);
}
}
+
+ if(self.wish_reload)
+ {
+ if(self.switchweapon == self.weapon)
+ {
+ if(self.weaponentity.state == WS_READY)
+ {
+ self.wish_reload = 0;
+ W_Nex_Reload();
+ }
+ }
+ }
}
else if (req == WR_PRECACHE)
{
{
W_Nex_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_nex_primary_ammo, autocvar_g_balance_nex_secondary_ammo);
- return (autocvar_g_balance_nex_reload_ammo && self.nex_load >= ammo_amount) || self.ammo_cells >= ammo_amount;
- }
return TRUE;
};
{
self.porto_current = world;
}
- else if (req == WR_SWITCHABLE)
- {
- // no reloading system, return true
- return TRUE;
- }
return TRUE;
};
#endif
sound (self, CHAN_WEAPON2, "weapons/rocket_det.wav", VOL_BASE, ATTN_NORM);
}
}
+ if(self.wish_reload)
+ {
+ if(self.switchweapon == self.weapon)
+ {
+ if(self.weaponentity.state == WS_READY)
+ {
+ self.wish_reload = 0;
+ W_RocketLauncher_Reload();
+ }
+ }
+ }
}
else if (req == WR_PRECACHE)
{
{
W_RocketLauncher_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 = autocvar_g_balance_rocketlauncher_ammo;
- return (autocvar_g_balance_rocketlauncher_reload_ammo && self.rocketlauncher_load >= ammo_amount) || self.ammo_rockets >= ammo_amount;
- }
return TRUE;
};
#endif
weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_seeker_flac_animtime, w_ready);
}
}
+
+ if(self.wish_reload)
+ {
+ if(self.switchweapon == self.weapon)
+ {
+ if(self.weaponentity.state == WS_READY)
+ {
+ self.wish_reload = 0;
+ W_Seeker_Reload();
+ }
+ }
+ }
}
else if (req == WR_PRECACHE)
{
{
W_Seeker_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_seeker_missile_ammo, autocvar_g_balance_seeker_tag_ammo);
- return (autocvar_g_balance_seeker_reload_ammo && self.seeker_load >= ammo_amount) || self.ammo_rockets >= ammo_amount;
- }
return TRUE;
};
#endif
float w_shotgun(float req)
{
+ float ammo_amount;
if (req == WR_AIM)
if(vlen(self.origin-self.enemy.origin) <= autocvar_g_balance_shotgun_secondary_melee_range)
self.BUTTON_ATCK2 = bot_aim(1000000, 0, 0.001, FALSE);
weapon_thinkf(WFRAME_FIRE1, 0, W_Shotgun_Attack2);
}
}
+ if(self.wish_reload)
+ {
+ if(self.switchweapon == self.weapon)
+ {
+ if(self.weaponentity.state == WS_READY)
+ {
+ self.wish_reload = 0;
+ W_Shotgun_Reload();
+ }
+ }
+ }
}
else if (req == WR_PRECACHE)
{
}
else if (req == WR_CHECKAMMO1)
{
- if(autocvar_g_balance_shotgun_reload_ammo)
- return self.shotgun_load >= autocvar_g_balance_shotgun_primary_ammo;
- else
- return self.ammo_shells >= autocvar_g_balance_shotgun_primary_ammo;
+ ammo_amount = self.ammo_shells >= autocvar_g_balance_shotgun_primary_ammo;
+ ammo_amount += (autocvar_g_balance_shotgun_reload_ammo && self.shotgun_load >= autocvar_g_balance_shotgun_primary_ammo);
+ return ammo_amount;
}
else if (req == WR_CHECKAMMO2)
{
- return TRUE;
+ return FALSE;
}
else if (req == WR_RELOAD)
{
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 = autocvar_g_balance_shotgun_primary_ammo;
- return (autocvar_g_balance_shotgun_reload_ammo && self.shotgun_load >= ammo_amount) || self.ammo_shells >= ammo_amount;
- }
return TRUE;
};
#endif
}
}
}
+ if(self.wish_reload)
+ {
+ if(self.switchweapon == self.weapon)
+ {
+ if(self.weaponentity.state == WS_READY)
+ {
+ self.wish_reload = 0;
+ W_SniperRifle_Reload();
+ }
+ }
+ }
}
else if (req == WR_PRECACHE)
{
self.sniperrifle_accumulator = time - autocvar_g_balance_sniperrifle_bursttime;
self.clip_load = autocvar_g_balance_sniperrifle_reload_ammo;
}
- 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_sniperrifle_primary_ammo, autocvar_g_balance_sniperrifle_secondary_ammo);
- return (autocvar_g_balance_sniperrifle_reload_ammo && self.sniperrifle_load >= ammo_amount) || self.ammo_nails >= ammo_amount;
- }
return TRUE;
};
#endif
return TRUE; // TODO use fuel?
else if (req == WR_CHECKAMMO2)
return TRUE; // TODO use fuel?
- else if (req == WR_SWITCHABLE)
- {
- // no reloading system, return true
- return TRUE;
- }
return TRUE;
};
#endif
weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_uzi_first_refire, w_ready);
}
}
+ if(self.wish_reload)
+ {
+ if(self.switchweapon == self.weapon)
+ {
+ if(self.weaponentity.state == WS_READY)
+ {
+ self.wish_reload = 0;
+ W_UZI_Reload();
+ }
+ }
+ }
}
else if (req == WR_PRECACHE)
{
{
W_UZI_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(max(autocvar_g_balance_uzi_sustained_ammo, autocvar_g_balance_uzi_first_ammo), autocvar_g_balance_uzi_burst_ammo);
- return (autocvar_g_balance_uzi_reload_ammo && self.uzi_load >= ammo_amount) || self.ammo_nails >= ammo_amount;
- }
return TRUE;
};
#endif