+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;
+}