/*
* Empire - A multi-player, client/server Internet based war game.
- * Copyright (C) 1986-2006, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ * Copyright (C) 1986-2008, Dave Pare, Jeff Bailey, Thomas Ruschak,
* Ken Stevens, Steve McClure
*
* This program is free software; you can redistribute it and/or modify
#include <config.h>
-#include "misc.h"
-#include "sect.h"
-#include "nat.h"
-#include "news.h"
-#include "file.h"
-#include "path.h"
-#include "xy.h"
#include "land.h"
+#include "lost.h"
+#include "news.h"
#include "nsc.h"
+#include "path.h"
#include "plane.h"
#include "update.h"
-#include "common.h"
-#include "gen.h"
-#include "lost.h"
-#include "subs.h"
static void take_casualties(struct sctstr *, int);
if (lp->lnd_own != sp->sct_own)
continue;
- mil += lnd_getmil(lp);
+ mil += lp->lnd_item[I_MILIT];
- /* Security troops can now kill up to 1/2 their complement each
+ if (sp->sct_che_target != sp->sct_own)
+ continue;
+
+ /* Security troops can now kill up to 1/5 their complement each
update, before doing anything else. */
if (lchr[(int)lp->lnd_type].l_flags & L_SECURITY) {
int che_kill, r;
- mil += lnd_getmil(lp);
- r = (lnd_getmil(lp) * lp->lnd_effic) / 500;
+ mil += lp->lnd_item[I_MILIT];
+ r = (lp->lnd_item[I_MILIT] * lp->lnd_effic) / 500;
che_kill = r < 1 ? 0 : roll(r);
if (che_kill > che)
che_kill = che;
}
target = sp->sct_che_target;
- if (target == 0) {
- /* the deity can't be a target! */
+ if (CANT_HAPPEN(target == 0))
return;
- }
tnat = getnatp(target);
if (tnat->nat_stat == STAT_UNUSED) {
/* target nation has dissolved: che's retire. */
*/
if (chance(ratio * 0.10)) {
n = (mil / 5) + 1;
- if ((n + che) == 0) {
- logerror("n=%d che=%d\n", n, che);
- if (che == 0)
- return;
- }
odds = (double)che / (n + che);
odds /= hap_fact(tnat, getnatp(sp->sct_oldown));
while (che > 0 && n > 0) {
for (n = 1; n <= 6; n++) {
nsp = getsectp(sp->sct_x + diroff[n][0],
sp->sct_y + diroff[n][1]);
- if (dchr[nsp->sct_type].d_mcst == 0)
+ if (dchr[nsp->sct_type].d_mob0 < 0)
continue;
if (nsp->sct_own != target)
continue;
if (!(lchr[(int)lp->lnd_type].l_flags & L_SECURITY))
continue;
- cantake = (((float)(lp->lnd_effic - 40) / 100.0) *
- (float)lnd_getmil(lp)) * 2;
- /* (float)lchr[lp->lnd_type].l_mil)*2; */
+ cantake = ((lp->lnd_effic - 40) / 100.0) * lp->lnd_item[I_MILIT];
if (cantake >= each) {
- /* deq = (((float)each/(float)(lchr[lp->lnd_type].l_mil*2)) */
- deq = (((float)each / (float)(lnd_getmil(lp) * 2))
- * 100.0);
- mc -= each;
+ deq = ((double)each / lp->lnd_item[I_MILIT]) * 100.0;
+ mc -= 2 * each;
} else if (cantake > 0) {
- deq = (((float)cantake / (float)(lnd_getmil(lp) * 2)) * 100.0);
- /* (float)(lchr[lp->lnd_type].l_mil*2)) * 100.0); */
- mc -= (((float)deq / 100.0) * (float)lnd_getmil(lp)) * 2;
- /* (float)lchr[lp->lnd_type].l_mil)*2; */
+ deq = ((double)cantake / lp->lnd_item[I_MILIT]) * 100.0;
+ mc -= 2 * cantake;
} else
deq = 0;
lp->lnd_effic -= deq;
lp->lnd_mobil -= deq / 2;
- deq = (double)lchr[(int)lp->lnd_type].l_mil * (deq / 100.0);
+ deq = lchr[(int)lp->lnd_type].l_item[I_MILIT] * (deq / 100.0);
lnd_submil(lp, deq);
if (mc <= 0)
return;
if (lchr[(int)lp->lnd_type].l_flags & L_SECURITY)
continue;
- cantake = (((float)(lp->lnd_effic - 40) / 100.0) *
- (float)lnd_getmil(lp));
+ cantake = ((lp->lnd_effic - 40) / 100.0) * lp->lnd_item[I_MILIT];
if (cantake >= each) {
- deq = (((float)each / (float)(lnd_getmil(lp) * 2))
- * 100.0);
+ deq = ((double)each / lp->lnd_item[I_MILIT]) * 100.0;
mc -= each;
} else if (cantake > 0) {
- deq = (((float)cantake / (float)lnd_getmil(lp))
- * 100.0);
- mc -= (((float)deq / 100.0) * (float)lnd_getmil(lp));
+ deq = ((double)cantake / lp->lnd_item[I_MILIT]) * 100.0;
+ mc -= cantake;
} else
deq = 0;
+
lp->lnd_effic -= deq;
lp->lnd_mobil -= deq / 2;
- deq = (double)lchr[(int)lp->lnd_type].l_mil * (deq / 100.0);
+ deq = lchr[(int)lp->lnd_type].l_item[I_MILIT] * (deq / 100.0);
lnd_submil(lp, deq);
if (mc <= 0)
return;
if (lchr[(int)lp->lnd_type].l_flags & L_SECURITY)
continue;
- mc -= (((float)lp->lnd_effic / 100.0) * (float)lnd_getmil(lp));
+ mc -= (lp->lnd_effic / 100.0) * lp->lnd_item[I_MILIT];
lp->lnd_effic = 0;
lnd_submil(lp, 1000); /* Remove 'em all */
wu(0, lp->lnd_own, "%s dies fighting guerrillas in %s\n",
if (!(lchr[(int)lp->lnd_type].l_flags & L_SECURITY))
continue;
- mc -= (((float)lp->lnd_effic / 100.0) * (float)lnd_getmil(lp)) * 2;
+ mc -= (lp->lnd_effic / 100.0) * lp->lnd_item[I_MILIT] * 2.0;
lp->lnd_effic = 0;
lnd_submil(lp, 1000); /* Kill 'em all */
wu(0, lp->lnd_own, "%s dies fighting guerrillas in %s\n",