convert shoot: Make security bonus proportional to efficiency

Land units with capability security reduce the mobility cost and have
their military count double, regardless of efficiency.  This lets
players get the benefits of a security unit at a discount: just don't
build it beyond 10%.

Count security unit's military times 1 + eff/100 instead of double.
Change the mobility bonus term from number of security units to sum of
security unit efficiency / 100.  Partial fix for bug#64.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
Markus Armbruster 2016-09-16 13:30:47 +02:00
parent ffd6651f86
commit 3c1c68f16d
4 changed files with 26 additions and 25 deletions

View file

@ -399,7 +399,7 @@ extern int check_trade_ok(struct trdstr *);
/* coastal.c */ /* coastal.c */
extern void set_coastal(struct sctstr *, int, int); extern void set_coastal(struct sctstr *, int, int);
/* control.c */ /* control.c */
extern int security_strength(struct sctstr *, int *); extern double security_strength(struct sctstr *, int *);
extern int military_control(struct sctstr *); extern int military_control(struct sctstr *);
extern int abandon_askyn(struct sctstr *, i_type, int, struct ulist *); extern int abandon_askyn(struct sctstr *, i_type, int, struct ulist *);
extern int would_abandon(struct sctstr *, i_type, int, struct ulist *); extern int would_abandon(struct sctstr *, i_type, int, struct ulist *);

View file

@ -48,7 +48,8 @@ conv(void)
struct sctstr sect; struct sctstr sect;
struct nstr_sect nstr; struct nstr_sect nstr;
int uwtoconvert, newuw, totaluw, uw; 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; double security_extra = 1.0;
if (!snxtsct(&nstr, player->argp[1])) if (!snxtsct(&nstr, player->argp[1]))
@ -66,11 +67,11 @@ conv(void)
natp = getnatp(sect.sct_own); natp = getnatp(sect.sct_own);
maxpop = max_pop(natp->nat_level[NAT_RLEV], &sect); maxpop = max_pop(natp->nat_level[NAT_RLEV], &sect);
civ = sect.sct_item[I_CIVIL]; civ = sect.sct_item[I_CIVIL];
mil = security_strength(&sect, &nsec); secstr = security_strength(&sect, &seceff);
/* /*
* Must have military control to convert captured civs. * Must have military control to convert captured civs.
*/ */
if (mil * 10 < civ) if (secstr * 10 < civ)
continue; continue;
newuw = civ; newuw = civ;
if (newuw > uwtoconvert) if (newuw > uwtoconvert)
@ -88,7 +89,7 @@ conv(void)
mob = sect.sct_mobil * 5; mob = sect.sct_mobil * 5;
/* security troops make conversion more effective */ /* 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); adj_mob = ldround(((double)mob * security_extra), 1);
if (adj_mob < newuw) if (adj_mob < newuw)

View file

@ -28,6 +28,7 @@
* *
* Known contributors to this file: * Known contributors to this file:
* Dave Pare, 1986 * Dave Pare, 1986
* Markus Armbruster, 2004-2016
*/ */
#include <config.h> #include <config.h>
@ -43,13 +44,12 @@ shoo(void)
{ {
struct sctstr sect; struct sctstr sect;
struct nstr_sect nstr; struct nstr_sect nstr;
int nshot; int seceff, nshot;
double m; double secstr, m;
i_type item; i_type item;
struct ichrstr *ip; struct ichrstr *ip;
int targets; int targets;
char *p; char *p;
int mil, nsec;
char prompt[128]; char prompt[128];
char buf[1024]; char buf[1024];
@ -66,21 +66,20 @@ shoo(void)
while (nxtsct(&nstr, &sect)) { while (nxtsct(&nstr, &sect)) {
if (!player->owner) if (!player->owner)
continue; continue;
mil = security_strength(&sect, &nsec); secstr = security_strength(&sect, &seceff);
if (sect.sct_item[item] == 0 || sect.sct_item[I_CIVIL] > mil * 10) if (sect.sct_item[item] == 0 || sect.sct_item[I_CIVIL] > secstr * 10)
continue; continue;
nshot = sect.sct_item[item] > targets ? targets : sect.sct_item[item]; nshot = sect.sct_item[item] > targets ? targets : sect.sct_item[item];
if (nshot > sect.sct_mobil * 5) if (nshot > sect.sct_mobil * 5)
nshot = sect.sct_mobil * 5; nshot = sect.sct_mobil * 5;
m = nshot / 5.0; m = nshot / 5.0;
/* /*
* Each security unit lowers the cost of * Security units reduce mobility cost of shooting people by
* shooting a person by 10%. However, you * 10% per 100% unit efficiency, up to a 50% reduction.
* can't go lower than 50% of normal cost
*/ */
if (nsec > 5) if (seceff > 500)
nsec = 5; seceff = 500;
m *= 1.0 - nsec * 0.1; m *= 1.0 - seceff / 1000.0;
if (nshot <= 0) if (nshot <= 0)
continue; continue;
if (m < 0) if (m < 0)

View file

@ -42,28 +42,29 @@
/* /*
* Return strength of security detail in @sp. * 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 double
security_strength(struct sctstr *sp, int *nsecurity) security_strength(struct sctstr *sp, int *seceffp)
{ {
int strength; double strength;
int nsec; int seceff;
struct nstr_item ni; struct nstr_item ni;
struct lndstr land; struct lndstr land;
strength = sp->sct_item[I_MILIT]; strength = sp->sct_item[I_MILIT];
nsec = 0; seceff = 0;
snxtitem_xy(&ni, EF_LAND, sp->sct_x, sp->sct_y); snxtitem_xy(&ni, EF_LAND, sp->sct_x, sp->sct_y);
while (nxtitem(&ni, &land)) { while (nxtitem(&ni, &land)) {
strength += land.lnd_item[I_MILIT]; strength += land.lnd_item[I_MILIT];
if (lchr[land.lnd_type].l_flags & L_SECURITY) { if (lchr[land.lnd_type].l_flags & L_SECURITY) {
strength += land.lnd_item[I_MILIT]; strength += land.lnd_item[I_MILIT] * land.lnd_effic / 100.0;
nsec++; seceff += land.lnd_effic;
} }
} }
*nsecurity = nsec; *seceffp = seceff;
return strength; return strength;
} }