extern int shp_fire(struct shpstr *);
extern int shp_torp(struct shpstr *, int);
extern double shp_fire_range(struct shpstr *);
+extern int shp_usable_guns(struct shpstr *);
#endif
if ((plp->pcp->pl_flags & P_A) && !on_shiplist(shipno, head))
continue;
- shell = gun = 0;
- gun = MIN(ship.shp_item[I_GUN], ship.shp_glim);
+ shell = 0;
+ gun = shp_usable_guns(&ship);
if (gun > 0) {
shell = ship.shp_item[I_SHELL];
if (shell <= 0)
rel = getrel(getnatp(ship.shp_own), plane_owner);
if (rel > HOSTILE)
continue;
- shell = gun = 0;
- gun = MIN(ship.shp_item[I_GUN], ship.shp_glim);
+ shell = 0;
+ gun = shp_usable_guns(&ship);
if (gun) {
shell = ship.shp_item[I_SHELL];
if (shell <= 0) {
if (sp->shp_effic < 60)
return -1;
- guns = sp->shp_glim;
- guns = MIN(guns, sp->shp_item[I_GUN]);
+ guns = shp_usable_guns(sp);
guns = MIN(guns, (sp->shp_item[I_MILIT] + 1) / 2);
if (guns == 0)
return -1;
return d;
}
+/*
+ * Return number of guns ship SP can fire.
+ */
+int
+shp_usable_guns(struct shpstr *sp)
+{
+ return MIN(sp->shp_glim, sp->shp_item[I_GUN]);
+}
+
/*
* Return effective firing range for range factor RNG at tech TLEV.
*/
continue;
/* now calculate the odds */
- gun = MIN(ship.shp_item[I_GUN], ship.shp_glim);
+ gun = shp_usable_guns(&ship);
eff = ship.shp_effic / 100.0;
teff = ship.shp_tech / (ship.shp_tech + 200.0);
/* raise 4.5 for better interception -KHS */