/* 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 *);
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]))
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)
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)
*
* Known contributors to this file:
* Dave Pare, 1986
+ * Markus Armbruster, 2004-2016
*/
#include <config.h>
{
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];
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)
/*
* 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;
}