static int dosupport(struct genlist *, coord, coord, natid, natid);
static int find_airport(struct emp_qelem *, coord, coord);
static void mission_pln_arm(struct emp_qelem *, coord, coord, int,
- int, struct ichrstr *, int);
+ int, struct ichrstr *);
static void mission_pln_sel(struct emp_qelem *, int, int, int);
static int perform_mission(coord, coord, natid, struct emp_qelem *, int,
char *, int);
struct plchrstr *pcp;
int dam = 0, dam2;
natid plane_owner = 0;
- int md, range, air_dam = 0;
+ int md, range, air_dam, sublaunch;
double hitchance, vrange;
int targeting_ships = *s == 's'; /* "subs" or "ships" FIXME gross! */
break;
}
}
- if (!QEMPTY(&missiles)) {
- /* I arbitrarily chose 100 mindam -KHS */
- dam +=
- msl_launch_mindam(&missiles, x, y, hardtarget, EF_SECTOR, 100,
- "sector", victim, mission);
- qp = missiles.q_forw;
- while (qp != (&missiles)) {
- newqp = qp->q_forw;
- emp_remque(qp);
- free(qp);
- qp = newqp;
+
+ /*
+ * Missiles, except for interdiction of ships or land units,
+ * because that happens elsewhere, in shp_missile_interdiction()
+ * and lnd_missile_interdiction().
+ */
+ air_dam = 0;
+ for (qp = missiles.q_back; qp != &missiles; qp = newqp) {
+ newqp = qp->q_back;
+ plp = (struct plist *)qp;
+
+ if (air_dam < 100
+ && !CANT_HAPPEN(hardtarget != SECT_HARDTARGET
+ || (plp->pcp->pl_flags & P_MAR))
+ && mission_pln_equip(plp, NULL, 'p') >= 0) {
+ if (msl_launch(&plp->plane, EF_SECTOR, "sector", x, y, victim,
+ &sublaunch) < 0)
+ goto use_up_msl;
+ if (!msl_hit(&plp->plane, SECT_HARDTARGET, EF_SECTOR,
+ N_SCT_MISS, N_SCT_SMISS, sublaunch, victim))
+ CANT_REACH();
+ dam2 = pln_damage(&plp->plane, 'p', 1);
+ air_dam += dam2;
+ use_up_msl:
+ plp->plane.pln_effic = 0;
+ putplane(plp->plane.pln_uid, &plp->plane);
}
+ emp_remque(qp);
+ free(qp);
}
+ dam += air_dam;
if (QEMPTY(&bombers)) {
qp = list->q_forw;
add_airport(&airp, plp->plane.pln_x, plp->plane.pln_y);
}
+ air_dam = 0;
for (qp = airp.q_forw; qp != (&airp); qp = qp->q_forw) {
struct airport *air;
char buf[512];
/* Split off the escorts at this base into e */
divide(&escorts, &e, air->x, air->y);
- mission_pln_arm(&b, air->x, air->y, 2 * md, 'p', NULL, 0);
+ mission_pln_arm(&b, air->x, air->y, 2 * md, 'p', NULL);
if (QEMPTY(&b))
continue;
- mission_pln_arm(&e, air->x, air->y, 2 * md, 'p', NULL, P_F | P_ESC);
+ mission_pln_arm(&e, air->x, air->y, 2 * md, 'e', NULL);
pp = BestAirPath(buf, air->x, air->y, x, y);
if (CANT_HAPPEN(!pp))
}
char *
-mission_name(short mission)
+mission_name(int mission)
{
switch (mission) {
case MI_INTERDICT:
*/
static void
mission_pln_arm(struct emp_qelem *list, coord x, coord y, int dist,
- int mission, struct ichrstr *ip, int flags)
+ int mission, struct ichrstr *ip)
{
struct emp_qelem *qp;
struct emp_qelem *next;
continue;
if (CANT_HAPPEN(pp->pln_flags & PLN_LAUNCHED)
- || mission_pln_equip(plp, ip, flags, mission) < 0) {
+ || mission_pln_equip(plp, ip, mission) < 0) {
emp_remque(qp);
free(qp);
continue;
}
pp->pln_flags |= PLN_LAUNCHED;
- pp->pln_mobil -= pln_mobcost(dist, pp, flags);
+ pp->pln_mobil -= pln_mobcost(dist, pp, mission);
putplane(pp->pln_uid, pp);
}
}
int
-mission_pln_equip(struct plist *plp, struct ichrstr *ip, int flags,
- char mission)
+mission_pln_equip(struct plist *plp, struct ichrstr *ip, char mission)
{
struct plchrstr *pcp;
struct plnstr *pp;
return -1;
}
item[I_PETROL] -= pcp->pl_fuel;
- if (!(flags & P_F)) {
- load = pln_load(pp);
- itype = I_NONE;
- needed = 0;
- switch (mission) {
- case 's': /* strategic bomb */
- case 'p': /* pinpoint bomb */
- if (nuk_on_plane(pp) < 0) {
- itype = I_SHELL;
- needed = load;
- }
- break;
- case 't': /* transport */
- case 'd': /* drop */
- if (!(pcp->pl_flags & P_C) || !ip)
- break;
- itype = ip->i_uid;
- needed = (load * 2) / ip->i_lbs;
- break;
- case 'a': /* paradrop */
- if ((pcp->pl_flags & (P_V | P_C)) == 0)
- break;
- itype = I_MILIT;
- needed = load / ip->i_lbs;
- 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 (itype != I_NONE && needed <= 0)
+ load = pln_load(pp);
+ itype = I_NONE;
+ switch (mission) {
+ case 'p': /* pinpoint bomb */
+ itype = I_SHELL;
+ break;
+ case 'i': /* missile interception */
+ if (load)
+ itype = I_SHELL;
+ break;
+ case 'e': /* escort */
+ case 0: /* plane interception */
+ load = 0;
+ break;
+ default:
+ CANT_REACH();
+ load = 0;
+ }
+
+ if (itype != I_NONE) {
+ needed = load / ichr[itype].i_lbs;
+ if (needed <= 0)
return -1;
- if (itype != I_NONE) {
- if (itype == I_SHELL && item[itype] < needed) {
- if (pp->pln_ship >= 0)
- shp_supply(&ship, I_SHELL, needed);
- else if (pp->pln_land >= 0)
- lnd_supply(&land, I_SHELL, needed);
- else
- sct_supply(§, I_SHELL, needed);
- }
- if (item[itype] < needed)
- return -1;
- item[itype] -= needed;
+ if (CANT_HAPPEN(nuk_on_plane(pp) >= 0))
+ return -1;
+ if (itype == I_SHELL && item[itype] < needed) {
+ if (pp->pln_ship >= 0)
+ shp_supply(&ship, I_SHELL, needed);
+ else if (pp->pln_land >= 0)
+ lnd_supply(&land, I_SHELL, needed);
+ else
+ sct_supply(§, I_SHELL, needed);
}
- if (itype == I_SHELL && (mission == 's' || mission == 'p'))
- plp->bombs = needed;
- else
- plp->misc = needed;
+ if (item[itype] < needed)
+ return -1;
+ item[itype] -= needed;
+ plp->load = needed;
}
+
if (pp->pln_ship >= 0)
putship(ship.shp_uid, &ship);
else if (pp->pln_land >= 0)
struct plnstr *pp;
int newdam, dam = 0;
int hitchance;
- int nukedam;
for (qp = bombers->q_forw; qp != bombers; qp = qp->q_forw) {
plp = (struct plist *)qp;
if ((mission == MI_SINTERDICT) && !(plp->pcp->pl_flags & P_A))
continue;
- if (!plp->bombs)
+ if (!plp->load)
continue;
newdam = 0;
hitchance = 100;
else if (hardtarget != SECT_HARDTARGET)
wu(0, pp->pln_own, "\t\t%d%% hitchance...", hitchance);
- /* Always calculate damage */
if (roll(100) <= hitchance) {
- newdam = pln_damage(&plp->plane, x, y, 'p', &nukedam, 1);
- if (nukedam) {
- if (mission == MI_INTERDICT) {
- wu(0, pp->pln_own,
- "\t\tnuclear warhead on plane %s does %d damage to %s %s\n",
- prplane(pp), nukedam, cname(victim), s);
- dam += nukedam;
- }
- } else {
- wu(0, pp->pln_own,
- "\t\thit %s %s for %d damage\n",
- cname(victim), s, newdam);
- dam += newdam;
- }
+ newdam = pln_damage(&plp->plane, 'p', 1);
+ wu(0, pp->pln_own,
+ "\t\thit %s %s for %d damage\n",
+ cname(victim), s, newdam);
+ dam += newdam;
} else {
- newdam = pln_damage(&plp->plane, x, y, 'p', &nukedam, 0);
+ newdam = pln_damage(&plp->plane, 'p', 0);
wu(0, pp->pln_own, "missed\n");
if (mission == MI_SINTERDICT) {
mpr(victim,