-float weapon_prepareattack_checkammo(float secondary)
-{SELFPARAM();
- if (!(self.items & IT_UNLIMITED_WEAPON_AMMO))
- if (!WEP_ACTION(self.weapon, WR_CHECKAMMO1 + secondary))
- {
- // always keep the Mine Layer if we placed mines, so that we can detonate them
- entity mine;
- if(self.weapon == WEP_MINE_LAYER.m_id)
- for(mine = world; (mine = find(mine, classname, "mine")); ) if(mine.owner == self)
- return false;
-
- if(self.weapon == WEP_SHOTGUN.m_id)
- if(!secondary && WEP_CVAR(shotgun, secondary) == 1)
- return false; // no clicking, just allow
-
- if(self.weapon == self.switchweapon && time - self.prevdryfire > 1) // only play once BEFORE starting to switch weapons
- {
- sound (self, CH_WEAPON_A, W_Sound("dryfire"), VOL_BASE, ATTEN_NORM);
- self.prevdryfire = time;
- }
+bool weapon_prepareattack_checkammo(Weapon thiswep, entity actor, bool secondary)
+{
+ if ((actor.items & IT_UNLIMITED_WEAPON_AMMO)) return true;
+ bool ammo = false;
+ if (secondary) WITH(entity, self, actor, ammo = thiswep.wr_checkammo2(thiswep));
+ else WITH(entity, self, actor, ammo = thiswep.wr_checkammo1(thiswep));
+ if (ammo) return true;
+ // always keep the Mine Layer if we placed mines, so that we can detonate them
+ if (thiswep == WEP_MINE_LAYER)
+ for (entity mine; (mine = find(mine, classname, "mine")); )
+ if (mine.owner == actor) return false;
+
+ if (thiswep == WEP_SHOTGUN)
+ if (!secondary && WEP_CVAR(shotgun, secondary) == 1) return false; // no clicking, just allow
+
+ if (thiswep == Weapons_from(actor.switchweapon) && time - actor.prevdryfire > 1) // only play once BEFORE starting to switch weapons
+ {
+ sound(actor, CH_WEAPON_A, SND_DRYFIRE, VOL_BASE, ATTEN_NORM);
+ actor.prevdryfire = time;
+ }