(effrange, torprange, fortrange): New.
(multifire, quiet_bigdef, torp, anti_torp, sd, sb) (lnd_fort_interdiction, lnd_support, perform_mission, oprange) (shp_fort_interdiction): Use them. This fixes forts shooting below FORTEFF in quiet_bigdef(), lnd_fort_interdiction() and shp_fort_interdiction(). Change variables for rounded ranges to int. (quiet_bigdef, sd): Don't scale ship firing range by efficiency. (dd, sb): Simplify. (sb): Internal linkage. (perform_mission): Rename range2 to vrange.
This commit is contained in:
parent
5b4b3a13cb
commit
a50ae4a3d8
8 changed files with 107 additions and 143 deletions
|
@ -34,6 +34,9 @@
|
|||
#include <config.h>
|
||||
|
||||
#include "misc.h"
|
||||
#include "file.h"
|
||||
#include "nat.h"
|
||||
#include "optlist.h"
|
||||
#include "prototypes.h"
|
||||
|
||||
double
|
||||
|
@ -74,6 +77,44 @@ landunitgun(int effic, int shots, int guns, int ammo, int shells)
|
|||
return d;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return effective firing range for range factor RNG at tech TLEV.
|
||||
*/
|
||||
double
|
||||
effrange(int rng, double tlev)
|
||||
{
|
||||
/* FIXME don't truncate TLEV */
|
||||
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.
|
||||
*/
|
||||
double
|
||||
fortrange(struct sctstr *sp)
|
||||
{
|
||||
struct natstr *np = getnatp(sp->sct_own);
|
||||
double rng;
|
||||
|
||||
if (sp->sct_type != SCT_FORTR || sp->sct_effic < FORTEFF)
|
||||
return -1.0;
|
||||
|
||||
rng = effrange(14.0 * fire_range_factor, np->nat_level[NAT_TLEV]);
|
||||
if (sp->sct_effic > 59)
|
||||
rng++;
|
||||
return rng;
|
||||
}
|
||||
|
||||
int
|
||||
roundrange(double r)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue