*
* Known contributors to this file:
* Ken Stevens, 1995
+ * Markus Armbruster, 2005-2016
*/
#ifndef COMBAT_H
/* src/lib/subs/attsub.c */
extern double att_combat_eff(struct combat *);
+extern void att_move_land(int, struct combat *, struct emp_qelem *,
+ struct combat *);
extern void att_move_in_off(int, struct combat *, struct emp_qelem *,
struct combat *);
extern int att_combat_init(struct combat *, int);
#include "unit.h"
static int only_spies(struct combat[], struct emp_qelem *);
-static void sneak_ashore(struct emp_qelem *, struct combat *);
+static void sneak_ashore(struct combat[], struct emp_qelem *,
+ struct combat *);
int
assa(void)
/* If no attacking forces (i.e. we got here with only spies)
* then try to sneak on-land. */
if (only_spies(off, &olist)) {
- sneak_ashore(&olist, def);
+ sneak_ashore(off, &olist, def);
return RET_OK;
}
}
static void
-sneak_ashore(struct emp_qelem *olist, struct combat *def)
+sneak_ashore(struct combat off[], struct emp_qelem *olist,
+ struct combat *def)
{
struct emp_qelem *qp;
struct ulist *llp;
pr("Trying to sneak on shore...\n");
+ att_move_land(A_ASSAULT, off, olist, def);
+
for (qp = olist->q_forw; qp != olist; qp = qp->q_forw) {
llp = (struct ulist *)qp;
lp = &llp->unit.land;
rel = relations_with(def->own, player->cnum);
if (chance(0.10) || rel == ALLIED || !def->own) {
pr("%s made it on shore safely.\n", prland(lp));
- lp->lnd_x = def->x;
- lp->lnd_y = def->y;
- lp->lnd_ship = -1;
} else {
pr("%s was spotted", prland(lp));
if (rel <= HOSTILE) {
cname(player->cnum), xyas(def->x, def->y,
def->own));
pr(" but made it ok.\n");
- lp->lnd_x = def->x;
- lp->lnd_y = def->y;
- lp->lnd_ship = -1;
}
}
}
move_in_land(A_ATTACK, off, olist, def);
}
-/* Move offensive land units to the conquered sector or ship */
-
-static void
-move_in_land(int combat_mode, struct combat *off, struct emp_qelem *olist,
- struct combat *def)
+void
+att_move_land(int combat_mode, struct combat *off, struct emp_qelem *olist,
+ struct combat *def)
{
struct emp_qelem *qp, *next;
struct ulist *llp;
- char buf[512];
for (qp = olist->q_forw; qp != olist; qp = next) {
next = qp->q_forw;
else
llp->unit.land.lnd_ship = -1;
}
+}
+
+/* Move offensive land units to the conquered sector or ship */
+
+static void
+move_in_land(int combat_mode, struct combat *off, struct emp_qelem *olist,
+ struct combat *def)
+{
+ struct emp_qelem *qp, *next;
+ struct ulist *llp;
+ char buf[512];
+
+ att_move_land(combat_mode, off, olist, def);
if (def->type == EF_SECTOR) {
if (opt_INTERDICT_ATT) {