extern int att_empty_attack(int, int, struct combat *);
extern int att_get_defense(struct emp_qelem *, struct combat *,
struct emp_qelem *, int, int);
-extern int att_reacting_units(struct combat *, struct emp_qelem *, int,
- int *, int);
+extern double att_reacting_units(struct combat *, struct emp_qelem *, int,
+ int *, int);
extern int att_get_support(int, int, int, int, int, struct emp_qelem *,
struct combat *, struct emp_qelem *,
struct combat *, double *, double *, int);
extern double lnd_mobcost(struct lndstr *, struct sctstr *);
extern char *lnd_path(int, struct lndstr *, char *);
-extern int attack_val(int, struct lndstr *);
-extern int defense_val(struct lndstr *);
+extern double attack_val(int, struct lndstr *);
+extern double defense_val(struct lndstr *);
extern void lnd_print(struct llist *, char *);
extern void lnd_delete(struct llist *, char *);
extern int lnd_take_casualty(int, struct llist *, int);
extern void lnd_submil(struct lndstr *, int);
extern void lnd_takemob(struct emp_qelem *, double);
extern int lnd_spyval(struct lndstr *);
-extern int intelligence_report(int, struct lndstr *, int, char *);
+extern double intelligence_report(int, struct lndstr *, int, char *);
extern int count_sect_units(struct sctstr *);
extern void count_units(struct shpstr *);
extern void lnd_count_units(struct lndstr *);
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;
static void lnd_mess(char *, struct llist *);
static int lnd_hit_mine(struct lndstr *, struct lchrstr *);
-int
+double
attack_val(int combat_mode, struct lndstr *lp)
{
int men;
switch (combat_mode) {
case A_ATTACK:
- return (int)value;
+ return value;
case A_ASSAULT:
if (!(lcp->l_flags & L_MARINE))
- return (int)(assault_penalty * value);
+ return assault_penalty * value;
break;
case A_BOARD:
if (!(lcp->l_flags & L_MARINE))
- return (int)(assault_penalty * men);
+ return assault_penalty * men;
}
- return (int)value;
+ return value;
}
-int
+double
defense_val(struct lndstr *lp)
{
int men;
if (value < 1.0 && men > 0 && !(lcp->l_flags & L_SPY))
return 1;
- return (int)value;
+ return value;
}
void
/* retreat to bx,by */
llp->land.lnd_x = bx;
llp->land.lnd_y = by;
+ /* FIXME landmines */
getsect(bx, by, &rsect);
mob = llp->land.lnd_mobil - (int)bmcost;
if (mob < -127)
return lp->lnd_spy * (lp->lnd_effic / 100.0);
}
-int
+double
intelligence_report(int destination, struct lndstr *lp, int spy,
char *mess)
{
if (lp->lnd_ship < 0 || lcp->l_flags & L_MARINE)
estimate *= lp->lnd_def;
- return (int)estimate;
+ return estimate;
}
/* Used by the spy command to count land units in a sector. If used