subs/control: Grant bonus for capability security

Grant land units with security capability the same bonus as in convert
and shoot: multiply by (1 + eff/100).

military_control()'s code to count military is now functionally
equivalent to security_strength(), except it has no use for its second
parameter.  Change security_strength() to permit a null argument, and
reuse it in military_control().

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
Markus Armbruster 2016-09-19 20:45:56 +02:00
parent 19656b892b
commit c89161d496
3 changed files with 20 additions and 22 deletions

View file

@ -64,10 +64,12 @@ you must own the distribution sector, and there must be a path of owned
sectors to it. In order to export something from a sector, you must have sectors to it. In order to export something from a sector, you must have
military control of the sector. In order to import something from a military control of the sector. In order to import something from a
distribution sector, you must have military control of the distribution distribution sector, you must have military control of the distribution
sector. (Military control is defined as having mil in the sector equal sector.
to at least 1/10th the number of unconverted civilians there. Units count .s1
as if they were straight mil, i.e. a 100% unit that contained 50 mil would Military control is defined as having military in the sector equal to
count as 50 mil for the purposes of control) at least 1/10th the number of unconverted civilians there. Military
in land units count towards military control. Military in efficient
security units count double.
.s1 .s1
Mobility is used from the sector when sending \*Qto\*U the distribution sector. Mobility is used from the sector when sending \*Qto\*U the distribution sector.
When getting something \*Qfrom\*U the distribution sector, mobility is paid When getting something \*Qfrom\*U the distribution sector, mobility is paid

View file

@ -81,13 +81,16 @@ You can also supply additional parameters:
is equivalent to a \*Qmap\*U command, like is equivalent to a \*Qmap\*U command, like
this: this:
.EX map # ls .EX map # ls
.s1
.L "Military control" .L "Military control"
.s1 .s1
In order to move something (other than mil) out of a sector, you must have In order to move something (other than military) out of a sector, you
military control of the sector. Military control is defined as having mil in must have military control of the sector. Military control is defined
the sector equal to at least 1/10th the number of unconverted civilians there. as having military in the sector equal to at least 1/10th the number
Units count as if they were straight mil, i.e. a 100% unit that contained 50 of unconverted civilians there.
mil would count as 50 mil for the purposes of control) .s1
Military in land units count towards military control. Military in
efficient security units count double.
.s1 .s1
.L Mobility .L Mobility
See \*Qinfo Mobility\*U for a description of how much mobility it costs to See \*Qinfo Mobility\*U for a description of how much mobility it costs to

View file

@ -43,7 +43,7 @@
/* /*
* Return strength of security detail in @sp. * Return strength of security detail in @sp.
* Store sum of efficiency of land units with security capability in * Store sum of efficiency of land units with security capability in
* @seceffp. * @seceffp unless it is null.
*/ */
double double
security_strength(struct sctstr *sp, int *seceffp) security_strength(struct sctstr *sp, int *seceffp)
@ -68,7 +68,8 @@ security_strength(struct sctstr *sp, int *seceffp)
} }
} }
*seceffp = seceff; if (seceffp)
*seceffp = seceff;
return strength; return strength;
} }
@ -78,19 +79,11 @@ security_strength(struct sctstr *sp, int *seceffp)
int int
military_control(struct sctstr *sp) military_control(struct sctstr *sp)
{ {
int tot_mil = 0; int tot_mil;
struct nstr_item ni;
struct lndstr land;
if (sp->sct_oldown != sp->sct_own) { if (sp->sct_oldown != sp->sct_own) {
snxtitem_xy(&ni, EF_LAND, sp->sct_x, sp->sct_y); tot_mil = sp->sct_item[I_MILIT] + security_strength(sp, NULL);
while (nxtitem(&ni, &land)) { if (tot_mil * 10 < sp->sct_item[I_CIVIL])
if (land.lnd_ship >= 0 || land.lnd_land >= 0)
continue;
if (land.lnd_own == sp->sct_own)
tot_mil += land.lnd_item[I_MILIT];
}
if ((sp->sct_item[I_MILIT] + tot_mil) * 10 < sp->sct_item[I_CIVIL])
return 0; return 0;
} }