diff --git a/include/prototypes.h b/include/prototypes.h index d31ed61d..5ea7a47a 100644 --- a/include/prototypes.h +++ b/include/prototypes.h @@ -399,7 +399,7 @@ extern int check_trade_ok(struct trdstr *); /* coastal.c */ extern void set_coastal(struct sctstr *, int, int); /* control.c */ -extern int security_strength(struct sctstr *, int *); +extern double security_strength(struct sctstr *, int *); extern int military_control(struct sctstr *); extern int abandon_askyn(struct sctstr *, i_type, int, struct ulist *); extern int would_abandon(struct sctstr *, i_type, int, struct ulist *); diff --git a/src/lib/commands/conv.c b/src/lib/commands/conv.c index 76a1523a..c6175110 100644 --- a/src/lib/commands/conv.c +++ b/src/lib/commands/conv.c @@ -48,7 +48,8 @@ conv(void) struct sctstr sect; struct nstr_sect nstr; int uwtoconvert, newuw, totaluw, uw; - int maxpop, civ, mil, nsec, adj_mob, mob; + int maxpop, civ, seceff, adj_mob, mob; + double secstr; double security_extra = 1.0; if (!snxtsct(&nstr, player->argp[1])) @@ -66,11 +67,11 @@ conv(void) natp = getnatp(sect.sct_own); maxpop = max_pop(natp->nat_level[NAT_RLEV], §); civ = sect.sct_item[I_CIVIL]; - mil = security_strength(§, &nsec); + secstr = security_strength(§, &seceff); /* * Must have military control to convert captured civs. */ - if (mil * 10 < civ) + if (secstr * 10 < civ) continue; newuw = civ; if (newuw > uwtoconvert) @@ -88,7 +89,7 @@ conv(void) mob = sect.sct_mobil * 5; /* security troops make conversion more effective */ - security_extra = 1.0 + nsec / 10.0; + security_extra = 1.0 + seceff / 1000.0; adj_mob = ldround(((double)mob * security_extra), 1); if (adj_mob < newuw) diff --git a/src/lib/commands/shoo.c b/src/lib/commands/shoo.c index 45f9e329..28821a6a 100644 --- a/src/lib/commands/shoo.c +++ b/src/lib/commands/shoo.c @@ -28,6 +28,7 @@ * * Known contributors to this file: * Dave Pare, 1986 + * Markus Armbruster, 2004-2016 */ #include @@ -43,13 +44,12 @@ shoo(void) { struct sctstr sect; struct nstr_sect nstr; - int nshot; - double m; + int seceff, nshot; + double secstr, m; i_type item; struct ichrstr *ip; int targets; char *p; - int mil, nsec; char prompt[128]; char buf[1024]; @@ -66,21 +66,20 @@ shoo(void) while (nxtsct(&nstr, §)) { if (!player->owner) continue; - mil = security_strength(§, &nsec); - if (sect.sct_item[item] == 0 || sect.sct_item[I_CIVIL] > mil * 10) + secstr = security_strength(§, &seceff); + if (sect.sct_item[item] == 0 || sect.sct_item[I_CIVIL] > secstr * 10) continue; nshot = sect.sct_item[item] > targets ? targets : sect.sct_item[item]; if (nshot > sect.sct_mobil * 5) nshot = sect.sct_mobil * 5; m = nshot / 5.0; /* - * Each security unit lowers the cost of - * shooting a person by 10%. However, you - * can't go lower than 50% of normal cost + * Security units reduce mobility cost of shooting people by + * 10% per 100% unit efficiency, up to a 50% reduction. */ - if (nsec > 5) - nsec = 5; - m *= 1.0 - nsec * 0.1; + if (seceff > 500) + seceff = 500; + m *= 1.0 - seceff / 1000.0; if (nshot <= 0) continue; if (m < 0) diff --git a/src/lib/subs/control.c b/src/lib/subs/control.c index 3fc5b1f9..a2df3a3f 100644 --- a/src/lib/subs/control.c +++ b/src/lib/subs/control.c @@ -42,28 +42,29 @@ /* * Return strength of security detail in @sp. - * Store number of land units with security capability in @nsecurity. + * Store sum of efficiency of land units with security capability in + * @seceffp. */ -int -security_strength(struct sctstr *sp, int *nsecurity) +double +security_strength(struct sctstr *sp, int *seceffp) { - int strength; - int nsec; + double strength; + int seceff; struct nstr_item ni; struct lndstr land; strength = sp->sct_item[I_MILIT]; - nsec = 0; + seceff = 0; snxtitem_xy(&ni, EF_LAND, sp->sct_x, sp->sct_y); while (nxtitem(&ni, &land)) { strength += land.lnd_item[I_MILIT]; if (lchr[land.lnd_type].l_flags & L_SECURITY) { - strength += land.lnd_item[I_MILIT]; - nsec++; + strength += land.lnd_item[I_MILIT] * land.lnd_effic / 100.0; + seceff += land.lnd_effic; } } - *nsecurity = nsec; + *seceffp = seceff; return strength; }