static int land_board_abort(struct combat *off, struct combat *def);
static int ask_off(int combat_mode, struct combat *off,
struct combat *def);
-static int get_dlist(struct combat *def, struct emp_qelem *list, int a_spy,
- int *d_spyp);
+static void get_dlist(struct combat *def, struct emp_qelem *list, int a_spy,
+ int *d_spyp);
static int get_ototal(int combat_mode, struct combat *off,
struct emp_qelem *olist, double osupport, int check);
static int get_dtotal(struct combat *def, struct emp_qelem *list,
double mobcost;
struct llist *llp;
struct lchrstr *lcp;
- int att_val;
+ double att_val;
int count = 0;
int maxland = 0;
int first_time = 1;
return;
}
att_val = attack_val(combat_mode, &land);
- if (!att_val) {
+ if (att_val < 1.0) {
pr("%s has no offensive strength\n", prland(&land));
continue;
}
first_time = 0;
pr("You may board with a maximum of %d land units\n", maxland);
}
- pr("%s has a base %s value of %d\n",
+ pr("%s has a base %s value of %.0f\n",
prland(&land), att_mode[combat_mode], att_val);
if (land_answer[(int)land.lnd_army] != 'Y') {
sprintf(prompt,
eff = 1.0 + ((str - 1.0) * eff);
} else
eff = sector_strength(getsectp(com->x, com->y));
-/* str = com->sct_dcp->d_dstr;*/
} else if (com->type == EF_SHIP && com->own != player->cnum) {
getship(com->shp_uid, &ship);
eff = 1.0 + ship.shp_armor / 100.0;
/* Get the defensive land units in the sector or on the ship */
-static int
+static void
get_dlist(struct combat *def, struct emp_qelem *list, int a_spy,
int *d_spyp)
{
struct nstr_item ni;
struct llist *llp;
struct lndstr land;
- int estimate = 0;
/* In here is where you need to take out spies and trains from the defending
lists. Spies try to hide, trains get trapped and can be boarded. */
if (def->type == EF_LAND && land.lnd_land != def->lnd_uid)
continue;
if (!list) { /* Just estimating the enemy strength */
- estimate += intelligence_report(player->cnum,
- &land, a_spy,
- "Scouts report defending unit:");
+ intelligence_report(player->cnum, &land, a_spy,
+ "Scouts report defending unit:");
continue;
}
if (!(llp = malloc(sizeof(struct llist)))) {
logerror("Malloc failed in attack!\n");
abort_attack();
- return 0;
+ return;
}
memset(llp, 0, sizeof(struct llist));
emp_insque(&llp->queue, list);
if (lnd_spyval(&land) > *d_spyp)
*d_spyp = lnd_spyval(&land);
}
- return estimate;
}
/* Calculate the total offensive strength */
for (qp = list->q_forw; qp != list; qp = next) {
next = qp->q_forw;
llp = (struct llist *)qp;
- d_unit = 0.0;
if (check && !get_land(A_DEFEND, def, llp->land.lnd_uid, llp, 1))
continue;
d_unit = defense_val(&llp->land);
* Note that the "strength" command also calls this routine.
*/
-int
+double
att_reacting_units(struct combat *def, struct emp_qelem *list, int a_spy,
int *d_spyp, int ototal)
{
struct sctstr sect, dsect;
struct llist *llp;
int dtotal;
- int new_land = 0;
+ double new_land = 0;
double mobcost;
double pathcost;
int dist;
double eff = att_combat_eff(def);
char buf[1024];
- /*
- *
- * All units that are within their reaction radius and not damaged
- * below their morale value now get to react to the threatened sect.
- * Once we've sent enough to counter the threat, stop sending them.
- *
- * Not anymore. All units get to react. :)
- */
-
if (list)
dtotal = get_dtotal(def, list, 1.0, 1);
else
dtotal = 0;
snxtitem_all(&ni, EF_LAND);
- while (nxtitem(&ni, &land) &&
- (dtotal + new_land * eff < (int)(1.2 * ototal))) {
+ while (nxtitem(&ni, &land) && dtotal + new_land * eff < 1.2 * ototal) {
if (!land.lnd_own)
continue;
if (!land.lnd_rad_max)
continue;
if (land.lnd_land >= 0)
continue;
- if (!defense_val(&land))
+ if (defense_val(&land) < 1.0)
continue;
-/*
- if (land.lnd_effic <= land.lnd_retreat)
- continue;
- */
if (!lnd_can_attack(&land))
continue;