extern int shp_torp(struct shpstr *, int);
extern double shp_fire_range(struct shpstr *);
extern int shp_usable_guns(struct shpstr *);
+extern double shp_torp_hitchance(struct shpstr *, int);
#endif
#include <config.h>
#include "commands.h"
-#include "damage.h"
#include "empobj.h"
#include "optlist.h"
#include "retreat.h"
fp->type = targ_ship;
fp->uid = ship.shp_uid;
add_to_fired_queue(&fp->queue, list);
- if (!chance(DTORP_HITCHANCE(range, ship.shp_visib)))
+ if (!chance(shp_torp_hitchance(&ship, range)))
continue;
dam += dam2;
} else {
#include <config.h>
#include "commands.h"
-#include "damage.h"
#include "news.h"
#include "optlist.h"
#include "retreat.h"
getship(victno, &vship);
vshipown = vship.shp_own;
range = mapdist(sub.shp_x, sub.shp_y, vship.shp_x, vship.shp_y);
- hitchance = DTORP_HITCHANCE(range, sub.shp_visib);
+ hitchance = shp_torp_hitchance(&sub, range);
if (range <= erange) {
pr("Hitchance = %d%%\n", (int)(hitchance * 100));
}
pr("Captain! Torpedoes sighted!\n");
- if (chance(DTORP_HITCHANCE(range, sp->shp_visib))) {
+ if (chance(shp_torp_hitchance(sp, range))) {
pr("BOOM!...\n");
if (sp->shp_own != 0)
wu(0, sp->shp_own, "%s @ %s torpedoed %s\n",
return techfact((int)tlev, rng / 2.0);
}
-/*
- * Return torpedo range for ship SP.
- */
-double
-torprange(struct shpstr *sp)
-{
- return effrange(sp->shp_frnge * 2, sp->shp_tech)
- * sp->shp_effic / 100.0;
-}
-
/*
* Return firing range for sector SP.
*/
return effrange(sp->shp_frnge, sp->shp_tech);
}
+/*
+ * Return torpedo range for ship SP.
+ */
+double
+torprange(struct shpstr *sp)
+{
+ return effrange(sp->shp_frnge * 2, sp->shp_tech)
+ * sp->shp_effic / 100.0;
+}
+
+/*
+ * Return hit chance for torpedo from ship SP at range RANGE.
+ */
+double
+shp_torp_hitchance(struct shpstr *sp, int range)
+{
+ return DTORP_HITCHANCE(range, sp->shp_visib);
+}
+
/*
* Return firing range for land unit SP.
*/
#include <config.h>
#include <stdlib.h>
-#include "damage.h"
#include "empobj.h"
#include "file.h"
#include "item.h"
putship(sp->shp_uid, sp);
if (dam2 < 0)
continue;
- hitchance = DTORP_HITCHANCE(md, sp->shp_visib);
+ hitchance = shp_torp_hitchance(sp, md);
wu(0, sp->shp_own,
"%s locking on %s %s in %s\n",