#include "sect.h"
#include "update.h"
-static void take_casualties(struct sctstr *, int);
+static int take_casualties(struct sctstr *, int);
static void lnd_dies_fighting_che(struct lndstr *);
void
* If loyalty bad enough, then take the sector over,
* and enlist 5% of civ as military force.
*/
- while (che > 0 && mil > 0) {
- if (chance(odds)) {
+ while (che > cc && mil > mc) {
+ if (chance(odds))
mc++;
- mil--;
- } else {
+ else
cc++;
- che--;
- }
}
- if (mil > 0) {
+ if (mil > mc) {
/* military won. */
n = sp->sct_loyal - roll0(15);
if (n < 0)
convert++;
recruit++;
}
- take_casualties(sp, mc);
+ mc = take_casualties(sp, mc);
+ che -= cc;
+ mil -= mc;
} else if (ratio < 5) {
/*
* guerrillas have to resort to blowing things up.
n = (mil / 5) + 1;
odds = (double)che / (n + security_bonus / 5 + che);
odds /= hap_fact(tnat, getnatp(sp->sct_oldown));
- while (che > 0 && n > 0) {
- if (chance(odds)) {
+ while (che > cc && n > mc) {
+ if (chance(odds))
mc++;
- n--;
- } else {
+ else
cc++;
- che--;
- }
}
- take_casualties(sp, mc);
+ mc = take_casualties(sp, mc);
+ che -= cc;
mil -= mc;
recruit = 0;
}
xyas(sp->sct_x, sp->sct_y, victim));
}
-static void
+static int
take_casualties(struct sctstr *sp, int mc)
{
- int orig_mil;
+ int orig_mil, taken;
int cantake;
int nunits = 0, each, deq;
struct lndstr *lp;
if (mc <= orig_mil) {
sp->sct_item[I_MILIT] = orig_mil - mc;
- return;
+ return mc;
}
sp->sct_item[I_MILIT] = 0;
/* remaining casualites */
mc -= orig_mil;
+ taken = orig_mil;
/*
* Need to take total_casualties and divide
}
if (nunits == 0)
- return;
+ return taken;
each = (mc / nunits) + 2;
lp->lnd_effic -= deq;
lp->lnd_mobil -= deq / 2;
deq = lchr[(int)lp->lnd_type].l_item[I_MILIT] * (deq / 100.0);
+ taken += MIN(deq, lp->lnd_item[I_MILIT]);
lnd_submil(lp, deq);
if (mc <= 0)
- return;
+ return taken;
}
/* kill some normal troops */
lp->lnd_effic -= deq;
lp->lnd_mobil -= deq / 2;
deq = lchr[(int)lp->lnd_type].l_item[I_MILIT] * (deq / 100.0);
+ taken += MIN(deq, lp->lnd_item[I_MILIT]);
lnd_submil(lp, deq);
if (mc <= 0)
- return;
+ return taken;
}
/* Hmm.. still some left.. kill off units now */
continue;
mc -= (lp->lnd_effic / 100.0) * lp->lnd_item[I_MILIT];
+ taken += lp->lnd_item[I_MILIT];
lnd_dies_fighting_che(lp);
if (mc <= 0)
- return;
+ return taken;
}
/* Hmm.. still some left.. kill off units now */
continue;
mc -= (lp->lnd_effic / 100.0) * lp->lnd_item[I_MILIT];
+ taken += lp->lnd_item[I_MILIT];
lnd_dies_fighting_che(lp);
if (mc <= 0)
- return;
+ return taken;
}
/* Hmm.. everyone dead.. too bad */
+ return taken;
}
static void
| BUG: "Sector -12,-8 has been retaken!" instead of takeover
| -10,-8 che win, don't take over
| -8,-8 che lose
-| BUG: body count off, claims 7m, actually 11m
| BUG: che kill 4m more than they should
| -6,-8 che lose
-| BUG: body count off, claims 26m, actually 50m
| BUG: inf#29 shouldn't die
| plague stage 4 (dying) -16:-1,-6 ship#10 land#10
| -16,-6 reverts to deity
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 Guerrilla warfare in -8,-8
- Play#0 output Play#0 1 body count: troops: 7, rebels: 22
+ Play#0 output Play#0 1 body count: troops: 11, rebels: 22
Play#0 output Play#0 1 inf infantry #29 dies fighting guerrillas in -6,-8
Play#0 output Play#0 1 Guerrilla warfare in -6,-8
- Play#0 output Play#0 1 body count: troops: 26, rebels: 52
+ Play#0 output Play#0 1 body count: troops: 50, rebels: 52
Play#0 output Play#0 1 Revolutionary subversion reported in -13,-7!
Play#0 output Play#0 1 PLAGUE deaths reported in -16,-6
Play#0 output Play#0 1 PLAGUE deaths reported in -14,-6