update/revolt: Change security unit bonus to fix body count

Both ordinary ground combat and guerrilla combat basically kill
combatants one by one randomly until one side is eliminated.  The odds
of each side taking a hit are computed from combat strengths.

Ordinary combat factors bonuses into the odds.  It doesn't mess with
the number of men.

Guerrilla combat does the same for the bonus due to relative
happiness.  It doesn't for land units with security capability: these
fight as if they had twice as many military.  Changes both odds and
number of men.  This inflates the body count reported to the sector
owner.  Visible in tests/update/journal.log, where rebels kill 110 out
of 70 military.  It also complicates take_casualties().  Has been that
way since security land units were added in Chainsaw 3.

To fix the body count and simplify take_casualties(), make capability
security affect only the odds, not the number of men.  Without further
adjustments, this would reduce guerrilla losses: fewer men mean fewer
combat rounds mean fewer chances for rebels to die.  To compensate,
increase the multiplier from two to four.  This should make security
units a bit tougher.  Document the bonus in "info Guerrilla".

More body count bugs remain.

Reusing ordinary combat rules and code for guerrilla combat would be
nice, but isn't feasible for me right now.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
Markus Armbruster 2016-09-17 11:24:55 +02:00
parent 3e59bf1d6a
commit 849af9e06c
5 changed files with 18 additions and 18 deletions

View file

@ -66,7 +66,8 @@ or a sector lost to guerrilla activities!
.s1 .s1
Land units present in a sector help to fight them, fighting without Land units present in a sector help to fight them, fighting without
any multiplier, either offensive or defensive and without any any multiplier, either offensive or defensive and without any
fortification bonus. Any units with the fortification bonus, except units units with the
\*Qsecurity\*U ability will also kill some che before anything else is \*Qsecurity\*U ability fight with a multiplier of four. They
will also kill some che before anything else is
done (commando raids). done (commando raids).
.SA "Populace, Occupation, Updates" .SA "Populace, Occupation, Updates"

View file

@ -29,7 +29,7 @@
* Known contributors to this file: * Known contributors to this file:
* Dave Pare, 1986 * Dave Pare, 1986
* Steve McClure, 1997-2000 * Steve McClure, 1997-2000
* Markus Armbruster, 2004-2012 * Markus Armbruster, 2004-2016
*/ */
#include <config.h> #include <config.h>
@ -131,6 +131,7 @@ guerrilla(struct sctstr *sp)
int ratio; int ratio;
int che; int che;
int mil; int mil;
int security_bonus;
int cc, mc; int cc, mc;
double odds; double odds;
int civ; int civ;
@ -160,6 +161,7 @@ guerrilla(struct sctstr *sp)
actor = sp->sct_oldown; actor = sp->sct_oldown;
che = sp->sct_che; che = sp->sct_che;
mil = sp->sct_item[I_MILIT]; mil = sp->sct_item[I_MILIT];
security_bonus = 0;
snxtitem_xy(&ni, EF_LAND, sp->sct_x, sp->sct_y); snxtitem_xy(&ni, EF_LAND, sp->sct_x, sp->sct_y);
@ -179,7 +181,7 @@ guerrilla(struct sctstr *sp)
if (lchr[(int)lp->lnd_type].l_flags & L_SECURITY) { if (lchr[(int)lp->lnd_type].l_flags & L_SECURITY) {
int che_kill, r; int che_kill, r;
mil += lp->lnd_item[I_MILIT]; security_bonus += lp->lnd_item[I_MILIT] * 3;
r = (lp->lnd_item[I_MILIT] * lp->lnd_effic) / 500; r = (lp->lnd_item[I_MILIT] * lp->lnd_effic) / 500;
che_kill = r < 1 ? 0 : roll(r); che_kill = r < 1 ? 0 : roll(r);
if (che_kill > che) if (che_kill > che)
@ -218,8 +220,8 @@ guerrilla(struct sctstr *sp)
goto domove; goto domove;
} }
ratio = mil / che; ratio = (mil + security_bonus) / che;
odds = (double)che / (mil + che); odds = (double)che / (mil + security_bonus + che);
odds /= hap_fact(tnat, getnatp(sp->sct_oldown)); odds /= hap_fact(tnat, getnatp(sp->sct_oldown));
if (mil == 0) { if (mil == 0) {
wu(0, sp->sct_own, "Revolutionary subversion reported in %s!\n", wu(0, sp->sct_own, "Revolutionary subversion reported in %s!\n",
@ -281,7 +283,7 @@ guerrilla(struct sctstr *sp)
*/ */
if (chance(ratio * 0.10)) { if (chance(ratio * 0.10)) {
n = (mil / 5) + 1; n = (mil / 5) + 1;
odds = (double)che / (n + che); odds = (double)che / (n + security_bonus / 5 + che);
odds /= hap_fact(tnat, getnatp(sp->sct_oldown)); odds /= hap_fact(tnat, getnatp(sp->sct_oldown));
while (che > 0 && n > 0) { while (che > 0 && n > 0) {
if (chance(odds)) { if (chance(odds)) {
@ -447,8 +449,6 @@ take_casualties(struct sctstr *sp, int mc)
if (lp->lnd_ship >= 0) if (lp->lnd_ship >= 0)
continue; continue;
nunits++; nunits++;
if (lchr[(int)lp->lnd_type].l_flags & L_SECURITY)
nunits++;
} }
if (nunits == 0) if (nunits == 0)
@ -470,10 +470,10 @@ take_casualties(struct sctstr *sp, int mc)
if (cantake >= each) { if (cantake >= each) {
deq = ((double)each / lp->lnd_item[I_MILIT]) * 100.0; deq = ((double)each / lp->lnd_item[I_MILIT]) * 100.0;
mc -= 2 * each; mc -= each;
} else if (cantake > 0) { } else if (cantake > 0) {
deq = ((double)cantake / lp->lnd_item[I_MILIT]) * 100.0; deq = ((double)cantake / lp->lnd_item[I_MILIT]) * 100.0;
mc -= 2 * cantake; mc -= cantake;
} else } else
deq = 0; deq = 0;
@ -542,7 +542,7 @@ take_casualties(struct sctstr *sp, int mc)
if (!(lchr[(int)lp->lnd_type].l_flags & L_SECURITY)) if (!(lchr[(int)lp->lnd_type].l_flags & L_SECURITY))
continue; continue;
mc -= (lp->lnd_effic / 100.0) * lp->lnd_item[I_MILIT] * 2.0; mc -= (lp->lnd_effic / 100.0) * lp->lnd_item[I_MILIT];
lnd_dies_fighting_che(lp); lnd_dies_fighting_che(lp);
if (mc <= 0) if (mc <= 0)
return; return;

View file

@ -179,7 +179,6 @@ land 0:31,-16:-1
| BUG: empty inf#21 dies fighting guerrillas | BUG: empty inf#21 dies fighting guerrillas
| -12,-8 sec#25 raids, #27 doesn't, che win, kill sec#25/27/inf#26, | -12,-8 sec#25 raids, #27 doesn't, che win, kill sec#25/27/inf#26,
| BUG: spy#24 dies fighting guerrillas | BUG: spy#24 dies fighting guerrillas
| BUG: body count off, claims 110m, actually 70m
| BUG: "Sector -12,-8 has been retaken!" instead of takeover | BUG: "Sector -12,-8 has been retaken!" instead of takeover
| -10,-8 che win, don't take over | -10,-8 che win, don't take over
| -8,-8 che lose | -8,-8 che lose

View file

@ -157,7 +157,7 @@ owner xloc yloc des effic mobil off loyal terr0 terr1 terr2 terr3 dterr xdist yd
3 14 -8 4 9 120 0 112 0 0 0 0 0 14 -8 9 0 34 1 4 0 0 0 0 0 3 130 0 0 0 0 0 0 0 97 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 0 0 0 0 0 0 3 14 -8 4 9 120 0 112 0 0 0 0 0 14 -8 9 0 34 1 4 0 0 0 0 0 3 130 0 0 0 0 0 0 0 97 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 0 0 0 0 0 0
5 -16 -8 4 0 120 0 0 0 0 0 0 0 -16 -8 0 0 100 1 4 0 0 0 0 0 5 124 5 0 0 0 0 0 0 96 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 0 0 0 0 0 0 5 -16 -8 4 0 120 0 0 0 0 0 0 0 -16 -8 0 0 100 1 4 0 0 0 0 0 5 124 5 0 0 0 0 0 0 96 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 0 0 0 0 0 0
5 -14 -8 29 100 120 0 0 0 0 0 0 0 -14 -8 0 0 100 1 29 0 0 0 0 0 5 124 5 0 0 0 0 20 100 97 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 0 0 0 0 0 0 5 -14 -8 29 100 120 0 0 0 0 0 0 0 -14 -8 0 0 100 1 29 0 0 0 0 0 5 124 5 0 0 0 0 20 100 97 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 0 0 0 0 0 0
4 -12 -8 4 37 120 0 35 0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 97 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 0 0 0 0 0 0 4 -6 -8 4 39 120 0 51 0 0 0 0 0 -6 -8 39 0 100 1 4 0 0 0 0 0 2 130 0 0 0 0 0 0 0 97 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 0 0 0 0 0 0
@ -172,7 +172,7 @@ owner xloc yloc des effic mobil off loyal terr0 terr1 terr2 terr3 dterr xdist yd
3 13 -7 4 11 120 0 112 0 0 0 0 0 13 -7 12 0 38 0 4 0 0 0 0 0 3 130 0 0 0 0 0 0 0 97 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 0 0 0 0 0 0 3 13 -7 4 11 120 0 112 0 0 0 0 0 13 -7 12 0 38 0 4 0 0 0 0 0 3 130 0 0 0 0 0 0 0 97 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 0 0 0 0 0 0
3 15 -7 4 14 120 0 112 0 0 0 0 0 15 -7 14 0 57 1 4 0 0 0 0 0 3 130 0 0 0 0 0 0 0 97 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 0 0 0 0 0 0 3 15 -7 4 14 120 0 112 0 0 0 0 0 15 -7 14 0 57 1 4 0 0 0 0 0 3 130 0 0 0 0 0 0 0 97 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 0 0 0 0 0 0
4 -15 -7 4 41 120 0 0 0 0 0 0 0 -15 -7 41 0 100 1 4 0 0 0 0 0 4 130 20 0 0 0 0 0 0 97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 0 0 0 0 0 0 0 0 healthy 0 0 0 0 0 0 0 0 4 -9 -7 4 39 120 0 0 0 0 0 0 0 -9 -7 39 0 100 0 4 0 0 0 0 0 4 130 0 0 0 0 0 0 0 97 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 0 0 0 0 0 0
4 -7 -7 4 39 120 0 0 0 0 0 0 0 -7 -7 39 0 100 0 4 0 0 0 0 0 4 130 0 0 0 0 0 0 0 96 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 0 0 0 0 0 0 4 -7 -7 4 39 120 0 0 0 0 0 0 0 -7 -7 39 0 100 0 4 0 0 0 0 0 4 130 0 0 0 0 0 0 0 96 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 0 0 0 0 0 0 0

View file

@ -1370,7 +1370,7 @@
Play#0 output Play#0 1 sec security #27 dies fighting guerrillas in -12,-8 Play#0 output Play#0 1 sec security #27 dies fighting guerrillas in -12,-8
Play#0 output Play#0 1 Sector -12,-8 has been retaken! Play#0 output Play#0 1 Sector -12,-8 has been retaken!
Play#0 output Play#0 1 Guerrilla warfare in -12,-8 Play#0 output Play#0 1 Guerrilla warfare in -12,-8
Play#0 output Play#0 1 body count: troops: 110, rebels: 71 Play#0 output Play#0 1 body count: troops: 70, rebels: 88
Play#0 output Play#0 1 Guerrilla warfare in -10,-8 Play#0 output Play#0 1 Guerrilla warfare in -10,-8
Play#0 output Play#0 1 body count: troops: 10, rebels: 5 Play#0 output Play#0 1 body count: troops: 10, rebels: 5
Play#0 output Play#0 1 Guerrilla warfare in -8,-8 Play#0 output Play#0 1 Guerrilla warfare in -8,-8
@ -1439,7 +1439,7 @@
Play#0 output Play#0 1 own sect eff prd mob uf uf old civ mil uw food work avail fall coa Play#0 output Play#0 1 own sect eff prd mob uf uf old civ mil uw food work avail fall coa
Play#0 output Play#0 1 5 -16,-8 - 0% 120 .. .. 124 5 0 96 100% 0 0 1 Play#0 output Play#0 1 5 -16,-8 - 0% 120 .. .. 124 5 0 96 100% 0 0 1
Play#0 output Play#0 1 5 -14,-8 b 100% 120 .. .. 124 5 0 97 100% 0 0 1 Play#0 output Play#0 1 5 -14,-8 b 100% 120 .. .. 124 5 0 97 100% 0 0 1
Play#0 output Play#0 1 4 -12,-8 - 37% 120 .. .. 0 123 5 0 97 100% 38 0 1 Play#0 output Play#0 1 4 -12,-8 - 37% 120 .. .. 0 123 5 0 96 100% 38 0 1
Play#0 output Play#0 1 4 -10,-8 - 39% 120 .. .. 130 0 0 97 100% 39 0 1 Play#0 output Play#0 1 4 -10,-8 - 39% 120 .. .. 130 0 0 97 100% 39 0 1
Play#0 output Play#0 1 4 -8,-8 - 39% 120 .. .. 2 130 0 0 97 100% 39 0 1 Play#0 output Play#0 1 4 -8,-8 - 39% 120 .. .. 2 130 0 0 97 100% 39 0 1
Play#0 output Play#0 1 4 -6,-8 - 39% 120 .. .. 2 130 0 0 97 100% 39 0 1 Play#0 output Play#0 1 4 -6,-8 - 39% 120 .. .. 2 130 0 0 97 100% 39 0 1
@ -1588,7 +1588,7 @@
Play#0 output Play#0 1 4 -4,-8 - 39% 0 0 0 0 0 0 Play#0 output Play#0 1 4 -4,-8 - 39% 0 0 0 0 0 0
Play#0 output Play#0 1 4 -2,-8 - 39% 0 0 0 0 0 0 Play#0 output Play#0 1 4 -2,-8 - 39% 0 0 0 0 0 0
Play#0 output Play#0 1 4 -15,-7 - 41% 0 0 0 0 0 0 Play#0 output Play#0 1 4 -15,-7 - 41% 0 0 0 0 0 0
Play#0 output Play#0 1 4 -13,-7 - 39% 0 4 133 0 0 0 Play#0 output Play#0 1 4 -13,-7 - 39% 0 4 116 0 0 0
Play#0 output Play#0 1 4 -11,-7 - 41% 0 0 0 0 0 0 Play#0 output Play#0 1 4 -11,-7 - 41% 0 0 0 0 0 0
Play#0 output Play#0 1 4 -9,-7 - 39% 0 0 0 0 0 0 Play#0 output Play#0 1 4 -9,-7 - 39% 0 0 0 0 0 0
Play#0 output Play#0 1 4 -7,-7 - 39% 0 0 0 0 0 0 Play#0 output Play#0 1 4 -7,-7 - 39% 0 0 0 0 0 0