/*
* Empire - A multi-player, client/server Internet based war game.
- * Copyright (C) 1986-2013, 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 */
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)