};
// perform weapon to attack (weaponstate and attack_finished check is here)
+void W_SwitchToOtherWeapon(entity pl)
+{
+ // hack to ensure it switches to an OTHER weapon (in case the other fire mode still has ammo, we want that anyway)
+ float w, ww;
+ w = W_WeaponBit(pl.weapon);
+ pl.weapons &~= w;
+ ww = w_getbestweapon(pl);
+ pl.weapons |= w;
+ if(ww)
+ W_SwitchWeapon_Force(pl, ww);
+}
+float weapon_prepareattack_checkammo(float secondary)
+{
+ if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
+ if (!weapon_action(self.weapon, WR_CHECKAMMO1 + secondary))
+ {
+ W_SwitchToOtherWeapon(self);
+ return FALSE;
+ }
+ return TRUE;
+}
.float race_penalty;
-float weapon_prepareattack(float secondary, float attacktime)
+float weapon_prepareattack_check(float secondary, float attacktime)
{
+ if(!weapon_prepareattack_checkammo(secondary))
+ return FALSE;
+
//if sv_ready_restart_after_countdown is set, don't allow the player to shoot
//if all players readied up and the countdown is running
if(time < game_starttime || time < self.race_penalty) {
return FALSE;
}
- if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
- if (!weapon_action(self.weapon, WR_CHECKAMMO1 + secondary))
- {
- // hack to ensure it switches to an OTHER weapon (in case the other fire mode still has ammo, we want that anyway)
- float w, ww;
- w = W_WeaponBit(self.weapon);
- self.weapons &~= w;
- ww = w_getbestweapon(self);
- self.weapons |= w;
- if(ww)
- W_SwitchWeapon_Force(self, ww);
- return FALSE;
- }
-
if (timeoutStatus == 2) //don't allow the player to shoot while game is paused
return FALSE;
if (self.weaponentity.state != WS_READY)
return FALSE;
}
+
+ return TRUE;
+}
+float weapon_prepareattack_do(float secondary, float attacktime)
+{
self.weaponentity.state = WS_INUSE;
self.spawnshieldtime = min(self.spawnshieldtime, time); // kill spawn shield when you fire
self.bulletcounter += 1;
//dprint("attack finished ", ftos(ATTACK_FINISHED(self)), "\n");
return TRUE;
-};
+}
+float weapon_prepareattack(float secondary, float attacktime)
+{
+ if(weapon_prepareattack_check(secondary, attacktime))
+ {
+ weapon_prepareattack_do(secondary, attacktime);
+ return TRUE;
+ }
+ else
+ return FALSE;
+}
void weapon_thinkf(float fr, float t, void() func)
{