#define LND_MXL(b, t) (b)
#define LND_COST(b, t) ((b) * (1.0 + (sqrt((double)(t)) / 100.0)))
+/* Chance to detect L_SPY unit (percent) */
+#define LND_SPY_DETECT_CHANCE(eff) ((110-(eff))/100.0)
+
#define getland(n, p) \
ef_read(EF_LAND, n, (caddr_t)p)
#define putland(n, p) \
int i;
int dist;
double techfact(int, double);
- double odds;
drange = techfact(lookland->lnd_tech, (double)lookland->lnd_spy);
drange = (drange * ((double)lookland->lnd_effic / 100.0));
enough not to be seen */
if (lp->lnd_ship >= 0 || lp->lnd_land >= 0)
continue;
- odds = (double)(100 - lp->lnd_effic) + 0.10;
- if (!(chance(odds)))
+ if (!(chance(LND_SPY_DETECT_CHANCE(lp->lnd_effic))))
continue;
}
vrange = ldround((double)((lp->lnd_vis * range) / 20.0), 1);
}
putvar(V_SHELL, vec[I_SHELL] - 1, (s_char *)&land, EF_LAND);
- odds = (100 - land.lnd_effic) / 100.0 + .10;
+ odds = LND_SPY_DETECT_CHANCE(land.lnd_effic);
if (chance(odds)) {
wu(0, sect.sct_own,
"%s spy shot in %s during sabotage attempt.\n",
struct lndstr land;
struct nstr_item ni;
s_char report[128];
- double odds;
snxtitem_xy(&ni, EF_LAND, x, y);
while (nxtitem(&ni, (s_char *)&land)) {
continue;
/* Don't always see spies */
if (lchr[(int)land.lnd_type].l_flags & L_SPY) {
- odds = (double)(100 - land.lnd_effic) + 0.10;
- if (!(chance(odds)))
+ if (!(chance(LND_SPY_DETECT_CHANCE(land.lnd_effic))))
continue;
}
if ((land.lnd_own != player->cnum) && land.lnd_own) {
struct nstr_item ni;
struct lchrstr *lp;
struct lndstr land;
- double odds;
first = 1;
units = 0;
}
if (lp->l_flags & L_SPY) {
- odds = (double)(100 - land.lnd_effic) + 0.10;
- if (!(chance(odds)))
+ if (!(chance(LND_SPY_DETECT_CHANCE(land.lnd_effic))))
continue;
}
count_sect_units(struct sctstr *sp)
{
int count = 0;
- double odds;
struct nstr_item ni;
struct lndstr land;
continue;
/* Don't always see spies */
if (lchr[(int)land.lnd_type].l_flags & L_SPY) {
- odds = (double)(100 - land.lnd_effic) + 0.10;
- if (!(chance(odds)))
+ if (!(chance(LND_SPY_DETECT_CHANCE(land.lnd_effic))))
continue;
}
/* Got here, report it */
int stop;
s_char dp[80];
int rel;
- double odds;
int oldown;
if (dir <= DIR_STOP || dir >= DIR_VIEW) {
}
if (rel != ALLIED && sect.sct_own != actor && sect.sct_own) { /* must be a spy */
/* Always a 10% chance of getting caught. */
- odds = (100 - llp->land.lnd_effic) + .10;
- if (chance(odds)) {
+ if (chance(LND_SPY_DETECT_CHANCE(llp->land.lnd_effic))) {
if (rel == NEUTRAL || rel == FRIENDLY) {
wu(0, sect.sct_own,
"%s unit spotted in %s\n", cname(player->cnum),
int che_count;
int oldche;
int n, vec[I_MAX + 1];
- double odds;
struct nstr_item ni;
struct plnstr p;
struct lndstr land;
continue;
/* Spies get a chance to hide */
if (lchr[(int)lp->lnd_type].l_flags & L_SPY) {
- odds = (double)(100 - lp->lnd_effic) + 0.10;
- if (!(chance(odds)))
+ if (!(chance(LND_SPY_DETECT_CHANCE(lp->lnd_effic))))
continue;
}
n = lp->lnd_effic - (30 + (random() % 100));