static int dosupport(struct genlist *, coord, coord, natid, natid);
static int find_airport(struct emp_qelem *, coord, coord);
static int mission_pln_arm(struct emp_qelem *, coord, coord, int,
- int, struct ichrstr *, int, int, int *);
+ int, struct ichrstr *, int, int);
static void mission_pln_sel(struct emp_qelem *, int, int, int);
static int perform_mission(coord, coord, natid, struct emp_qelem *, int,
char *, int);
cname(cn), newdam);
}
if (dam) {
- collateral_damage(x, y, dam, 0);
+ collateral_damage(x, y, dam);
}
return dam;
}
int
-collateral_damage(coord x, coord y, int dam, struct emp_qelem *list)
+collateral_damage(coord x, coord y, int dam)
{
int coll;
struct sctstr sect;
return 0;
mpr(sect.sct_own, "%s takes %d%% collateral damage\n",
xyas(x, y, sect.sct_own), coll);
- sectdamage(§, coll, list);
+ sectdamage(§, coll);
putsect(§);
return coll;
}
}
}
if (dam) {
- collateral_damage(x, y, dam, 0);
+ collateral_damage(x, y, dam);
}
return dam;
}
if (getrel(getnatp(gp->own), sect.sct_own) > AT_WAR) {
/*
- * If the player->owner of the unit isn't at war
+ * If the owner of the unit isn't at war
* with the victim, and doesn't own the
* sect being acted upon, and isn't the
- * old player->owner of that sect, bounce them.
+ * old owner of that sect, bounce them.
*/
if (sect.sct_type != SCT_WATER &&
sect.sct_own != gp->own &&
struct sctstr sect;
struct mchrstr *mcp;
struct plchrstr *pcp;
- int dam = 0, dam2, mission_flags, tech;
+ int dam = 0, dam2, mission_flags;
natid plane_owner = 0;
int md, range, air_dam = 0;
double prb, hitchance, vrange;
+ int targeting_ships = *s == 's'; /* "subs" or "ships" FIXME gross! */
getsect(x, y, §);
(md > land_max_interdiction_range))
continue;
+ /* Too ponderous for interdiction fire */
+ if (lchr[(int)lp->lnd_type].l_flags & L_HEAVY)
+ continue;
+
range = roundrange(lnd_fire_range(lp));
if (md > range)
continue;
if (dam2 < 0)
continue;
- if (sect.sct_type == SCT_WATER) {
+ if (targeting_ships) {
if (chance(lnd_acc(lp) / 100.0))
dam2 = ldround(dam2 / 2.0, 1);
}
dam += dam2;
- if (sect.sct_type == SCT_WATER)
+ if (targeting_ships)
nreport(lp->lnd_own, N_SHP_SHELL, victim, 1);
else
nreport(lp->lnd_own, N_SCT_SHELL, victim, 1);
continue;
}
if (mcp->m_flags & M_SUB) {
-/* If we aren't shooting at "subs" or "ships" don't fire at all from
- a sub. */
- if (*s != 's')
- continue;
+ if (!targeting_ships)
+ continue; /* subs interdict only ships */
range = roundrange(torprange(sp));
if (md > range)
continue;
if (chance(prb))
dam2 /= 2;
dam += dam2;
- if (sect.sct_type == SCT_WATER)
+ if (targeting_ships)
nreport(sp->shp_own, N_SHP_SHELL, victim, 1);
else
nreport(sp->shp_own, N_SCT_SHELL, victim, 1);
/* Split off the escorts at this base into e */
divide(&escorts, &e, air->x, air->y);
- tech = 0;
mission_flags = 0;
mission_flags |= P_X; /* stealth (shhh) */
mission_flags |= P_H; /* gets turned off if not all choppers */
mission_flags = mission_pln_arm(&b, air->x, air->y, 2 * md, 'p', 0,
- 0, mission_flags, &tech);
+ 0, mission_flags);
if (QEMPTY(&b))
continue;
mission_flags = mission_pln_arm(&e, air->x, air->y, 2 * md, 'p', 0,
- P_F | P_ESC, mission_flags, &tech);
+ P_F | P_ESC, mission_flags);
pp = BestAirPath(buf, air->x, air->y, x, y);
if (CANT_HAPPEN(!pp))
xyas(air->x, air->y, air->own));
}
- ac_encounter(&b, &e, air->x, air->y, pp, mission_flags, 0, 0, 0);
+ ac_encounter(&b, &e, air->x, air->y, pp, mission_flags, 0);
if (!QEMPTY(&b))
air_dam +=
if (air_dam > 0) {
dam += air_dam;
- if (sect.sct_type == SCT_WATER)
+ if (targeting_ships)
nreport(plane_owner, N_SHP_BOMB, victim, 1);
else
nreport(plane_owner, N_SCT_BOMB, victim, 1);
static int
mission_pln_arm(struct emp_qelem *list, coord x, coord y, int dist,
int mission, struct ichrstr *ip, int flags,
- int mission_flags, int *tech)
+ int mission_flags)
{
struct emp_qelem *qp;
struct emp_qelem *next;
struct plist *plp;
+ struct plnstr *pp;
- if (*tech == 0)
- *tech = 9999;
for (qp = list->q_forw; qp != list; qp = next) {
next = qp->q_forw;
plp = (struct plist *)qp;
+ pp = &plp->plane;
- if (plp->plane.pln_x != x)
+ if (pp->pln_x != x)
continue;
- if (plp->plane.pln_y != y)
+ if (pp->pln_y != y)
continue;
- if (mission_pln_equip(plp, ip, flags, mission) < 0) {
+ if (CANT_HAPPEN(pp->pln_flags & PLN_LAUNCHED)
+ || mission_pln_equip(plp, ip, flags, mission) < 0) {
emp_remque(qp);
free(qp);
continue;
if (plp->pcp->pl_flags & P_I)
mission_flags |= P_I;
}
- if (*tech > plp->plane.pln_tech)
- *tech = plp->plane.pln_tech;
if (!(plp->pcp->pl_flags & P_H))
/* no stealth on this mission */
mission_flags &= ~P_H;
mission_flags &= ~P_MINE;
}
- /*
- * Mob costs for missions are 1/2 normal
- * Not anymore. :)
- */
-/* plp->plane.pln_mobil -= pln_mobcost(dist,&plp->plane,flags)/2;*/
- plp->plane.pln_mobil -= pln_mobcost(dist, &plp->plane, flags);
-
+ pp->pln_flags |= PLN_LAUNCHED;
+ pp->pln_mobil -= pln_mobcost(dist, pp, flags);
+ putplane(pp->pln_uid, pp);
}
return mission_flags;
}
struct shpstr ship;
struct sctstr sect;
i_type itype;
- int rval;
short *item;
pp = &plp->plane;
return -1;
}
item[I_PETROL] -= pcp->pl_fuel;
- rval = 0;
if (!(flags & P_F)) {
load = pln_load(pp);
itype = I_NONE;
needed = 0;
switch (mission) {
- case 's':
- case 'p':
+ case 's': /* strategic bomb */
+ case 'p': /* pinpoint bomb */
if (pp->pln_nuketype == -1) {
itype = I_SHELL;
needed = load;
}
break;
- case 't':
+ case 't': /* transport */
+ case 'd': /* drop */
if ((pcp->pl_flags & P_C) == 0 || ip == 0)
break;
itype = ip->i_uid;
needed = (load * 2) / ip->i_lbs;
break;
- case 'd':
- if ((pcp->pl_flags & P_C) == 0 || ip == 0)
- break;
- itype = ip->i_uid;
- needed = (load * 2) / ip->i_lbs;
- break;
- case 'a':
+ case 'a': /* paradrop */
if ((pcp->pl_flags & (P_V | P_C)) == 0)
break;
itype = I_MILIT;
needed = load / ip->i_lbs;
break;
- case 'n':
- if (pp->pln_nuketype == -1)
- rval = -1;
- break;
case 'i': /* missile interception */
if (load) {
itype = I_SHELL;
needed = load;
}
break;
+ case 'r': /* reconnaissance */
+ case 0: /* plane interception */
+ break;
default:
+ CANT_REACH();
break;
}
- if (rval < 0 || (itype != I_NONE && needed <= 0)) {
+ if (itype != I_NONE && needed <= 0)
return -1;
- }
if (itype != I_NONE) {
if (itype == I_SHELL && item[itype] < needed)
item[itype] += supply_commod(plp->plane.pln_own,
putland(land.lnd_uid, &land);
else
putsect(§);
- return rval;
+ return 0;
}
/*
}
/* Now, even though we missed, the bombs
land somewhere. */
- collateral_damage(x, y, newdam, bombers);
+ collateral_damage(x, y, newdam);
}
/* use up missiles */
struct emp_qelem *esc_list)
{
int dam = 0, cn;
- int mission_flags, tech, combat = 0, rel, dist, z;
+ int mission_flags, combat = 0, rel, dist, z;
struct emp_qelem *qp, interceptors, airp, i, empty, *next;
struct plist *plp;
struct genlist *glp;
/* Split off the interceptors at this base into i */
divide(&interceptors, &i, air->x, air->y);
- tech = 0;
mission_flags = 0;
mission_flags |= P_X; /* stealth (shhh) */
/* gets turned off if not all choppers */
continue;
}
mission_flags =
- mission_pln_arm(&i, air->x, air->y, 2 * dist, 'r', 0, P_F,
- mission_flags, &tech);
+ mission_pln_arm(&i, air->x, air->y, 2 * dist, 0, 0, P_F,
+ mission_flags);
/* Did we run out of interceptors? */
if (QEMPTY(&i))
}
path = BestAirPath(buf, air->x, air->y, x, y);
- if (CANT_HAPPEN(!path))
+ if (CANT_HAPPEN(!path)) {
+ pln_put(&i);
continue;
+ }
wu(0, cn, "Flying %s mission from %s\n",
mission_name(MI_AIR_DEFENSE), xyas(air->x, air->y, cn));
if (air->own && (air->own != cn)) {
/* Now, fly the planes to the sector */
emp_initque(&empty);
ac_encounter(&i, &empty, air->x, air->y,
- path, mission_flags, 1, bomb_list, esc_list);
+ path, mission_flags, 1);
/* If none made it, continue */
if (QEMPTY(&i))
pln_put(&i);
}
+ if (CANT_HAPPEN(!QEMPTY(&interceptors)))
+ pln_put(&interceptors);
}
/* We have to free all of these, if they are still there, otherwise they get