/*
* Empire - A multi-player, client/server Internet based war game.
- * Copyright (C) 1986-2012, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ * Copyright (C) 1986-2014, Dave Pare, Jeff Bailey, Thomas Ruschak,
* Ken Stevens, Steve McClure, Markus Armbruster
*
* Empire is free software: you can redistribute it and/or modify
* Known contributors to this file:
* Ken Stevens, 1995
* Steve McClure, 1998-2000
- * Markus Armbruster, 2004-2010
+ * Markus Armbruster, 2004-2012
*/
#include <config.h>
#include <math.h>
#include <stdlib.h>
+#include "chance.h"
#include "combat.h"
#include "damage.h"
#include "empobj.h"
int n;
int biggest;
int civs;
- int nowned;
coord ret_x, ret_y;
coord bx, by;
struct sctstr sect;
/* Have to make a retreat check */
ret_chance = llp->unit.land.lnd_retreat - llp->unit.land.lnd_effic;
- if (roll(100) < ret_chance) {
+ if (pct_chance(ret_chance)) {
pr("\n");
lnd_print(llp->unit.land.lnd_own, llp, "fails morale check!");
llp->unit.land.lnd_mission = 0;
* owner. Charge mob..
*/
biggest = -1;
- nowned = 0;
for (n = 1; n <= 6; ++n) {
ret_x = llp->unit.land.lnd_x + diroff[n][0];
ret_y = llp->unit.land.lnd_y + diroff[n][1];
mobcost = lnd_mobcost(&llp->unit.land, §);
if (mobcost < 0)
continue;
- ++nowned;
civs = sect.sct_item[I_CIVIL];
if (civs > biggest) {
biggest = civs;
bmcost = mobcost;
}
}
- if (!nowned)
+ if (biggest < 0)
nowhere_to_go = 1;
else {
/* retreat to bx,by */
}
}
+/*
+ * Sweep landmines with engineers in LAND_LIST for ACTOR.
+ * If EXPLICIT is non-zero, this is for an explicit sweep command from
+ * a player. Else it's an automatic "on the move" sweep.
+ * If TAKEMOB is non-zero, require and charge mobility.
+ */
void
-lnd_sweep(struct emp_qelem *land_list, int verbose, int takemob,
+lnd_sweep(struct emp_qelem *land_list, int explicit, int takemob,
natid actor)
{
struct emp_qelem *qp;
next = qp->q_back;
llp = (struct ulist *)qp;
if (!(((struct lchrstr *)llp->chrp)->l_flags & L_ENGINEER)) {
- if (verbose)
+ if (explicit)
mpr(actor, "%s is not an engineer!\n",
prland(&llp->unit.land));
continue;
}
if (takemob && llp->mobil < 0.0) {
- if (verbose)
+ if (explicit)
lnd_stays(actor, "is out of mobility", llp);
continue;
}
getsect(llp->unit.land.lnd_x, llp->unit.land.lnd_y, §);
- if (relations_with(sect.sct_oldown, actor) == ALLIED) {
- if (verbose)
- mpr(actor,
- "%s is in a sector completely owned by you or an ally. Don't bother digging up mines there!\n",
- prland(&llp->unit.land));
+ if (!explicit && relations_with(sect.sct_oldown, actor) == ALLIED)
continue;
- }
if (SCT_MINES_ARE_SEAMINES(§)) {
- if (verbose)
+ if (explicit)
mpr(actor, "%s is in a %s sector. No landmines there!\n",
prland(&llp->unit.land), dchr[sect.sct_type].d_name);
continue;
nreport(land.lnd_own, N_FIRE_BACK, victim, 1);
else
nreport(land.lnd_own, N_FIRE_L_ATTACK, victim, 1);
- if (roll(100) < lnd_acc(&land))
+ if (pct_chance(lnd_acc(&land) - 1))
dam2 /= 2;
dam += dam2;
if (land.lnd_own != attacker)