* ---
*
* bomb.c: Fly bombing missions
- *
+ *
* Known contributors to this file:
* Dave Pare, 1986
* Ken Stevens, 1995
#include "item.h"
#include "land.h"
#include "news.h"
+#include "nuke.h"
#include "optlist.h"
#include "path.h"
#include "plane.h"
plp = (struct plist *)qp;
if ((plp->pcp->pl_flags & P_C) && (!(plp->pcp->pl_flags & P_T)))
continue;
- if (plp->bombs || plp->plane.pln_nuketype != -1)
+ if (plp->bombs || nuk_on_plane(&plp->plane) >= 0)
dam += pln_damage(&plp->plane, target->sct_x, target->sct_y,
'p', &nukedam, 1);
}
plp = (struct plist *)qp;
if ((plp->pcp->pl_flags & P_C) && (!(plp->pcp->pl_flags & P_T)))
continue;
- if (plp->bombs || plp->plane.pln_nuketype != -1)
+ if (plp->bombs || nuk_on_plane(&plp->plane) >= 0)
dam += pln_damage(&plp->plane, target->sct_x, target->sct_y,
'p', &nukedam, 1);
}
int n;
struct emp_qelem *qp;
int shipno;
- int ignore;
struct shpstr ship;
int nships = 0;
struct shiplist *head = NULL;
int gun;
int shell;
- for (qp = list->q_forw; qp != list && !player->aborted;
- qp = qp->q_forw) {
+ for (qp = list->q_forw; qp != list; qp = qp->q_forw) {
free_shiplist(&head);
plp = (struct plist *)qp;
if ((plp->pcp->pl_flags & P_C) && (!(plp->pcp->pl_flags & P_T)))
}
(void)sprintf(prompt, "%s, %d bombs. Target ('~' to skip)? ",
prplane(&plp->plane), plp->bombs);
- ignore = 0;
shipno = -1;
- while (shipno < 0 && !player->aborted && !ignore) {
- if ((q = getstring(prompt, buf)) == 0 || *q == 0)
+ while (shipno < 0) {
+ if ((q = getstring(prompt, buf)) == 0)
+ goto out;
+ if (*q == 0)
continue;
- if (*q == '~') {
- ignore = 1;
- continue;
- }
+ if (*q == '~')
+ break;
if (*q == '?') {
if (plp->pcp->pl_flags & P_A)
print_shiplist(head);
shipsatxy(target->sct_x, target->sct_y, 0, M_SUB, 0);
continue;
}
- if (!isdigit(*q))
- continue;
n = atoi(q);
if (n < 0)
continue;
- if ((plp->pcp->pl_flags & P_A) && !on_shiplist(n, head))
- continue;
- if (getship(n, &ship) && ship.shp_own &&
+ if ((!(plp->pcp->pl_flags & P_A) || on_shiplist(n, head)) &&
+ getship(n, &ship) && ship.shp_own &&
ship.shp_x == target->sct_x && ship.shp_y == target->sct_y)
shipno = n;
+ else
+ pr("Ship #%d not spotted\n", n);
}
if (shipno < 0)
continue;
}
dam = 0;
- if (plp->plane.pln_nuketype != -1)
+ if (nuk_on_plane(&plp->plane) >= 0)
hitchance = 100;
else {
hitchance = pln_hitchance(&plp->plane,
}
collateral_damage(target->sct_x, target->sct_y, dam / 2);
}
+out:
free_shiplist(&head);
}
struct plnstr plane;
struct emp_qelem *qp;
int planeno;
- int ignore;
struct plist *plp;
char prompt[128];
char buf[1024];
(void)sprintf(prompt, "%s, %d bombs. Target ('~' to skip)? ",
prplane(&plp->plane), plp->bombs);
planeno = -1;
- ignore = 0;
- while (planeno < 0 && !player->aborted && !ignore) {
- if ((q = getstring(prompt, buf)) == 0 || *q == 0)
- continue;
- if (*q == '~') {
- ignore = 1;
+ while (planeno < 0) {
+ if ((q = getstring(prompt, buf)) == 0)
+ return;
+ if (*q == 0)
continue;
- }
+ if (*q == '~')
+ break;
if (*q == '?') {
planesatxy(target->sct_x, target->sct_y, 0, 0);
continue;
if (planeno < 0)
continue;
dam = 0;
- if (plp->plane.pln_nuketype != -1)
+ if (nuk_on_plane(&plp->plane) >= 0)
hitchance = 100;
else {
hitchance = pln_hitchance(&plp->plane, 0, EF_PLANE);
struct lndstr land;
struct emp_qelem *qp;
int unitno;
- int ignore, aaf, flak, hitchance;
+ int aaf, flak, hitchance;
struct plist *plp;
int nukedam;
int nunits;
(void)sprintf(prompt, "%s, %d bombs. Target ('~' to skip)? ",
prplane(&plp->plane), plp->bombs);
unitno = -1;
- ignore = 0;
- while (unitno < 0 && !player->aborted && !ignore) {
- if ((q = getstring(prompt, buf)) == 0 || *q == 0)
+ while (unitno < 0) {
+ if ((q = getstring(prompt, buf)) == 0)
+ return;
+ if (*q == 0)
continue;
- if (*q == '~') {
- ignore = 1;
- continue;
- }
+ if (*q == '~')
+ break;
if (*q == '?') {
unitsatxy(target->sct_x, target->sct_y, 0, 0);
continue;
}
dam = 0;
- if (plp->plane.pln_nuketype != -1)
+ if (nuk_on_plane(&plp->plane) >= 0)
hitchance = 100;
else {
hitchance = pln_hitchance(&plp->plane,
plp = (struct plist *)qp;
if ((plp->pcp->pl_flags & P_C) && (!(plp->pcp->pl_flags & P_T)))
continue;
- if (plp->bombs || plp->plane.pln_nuketype != -1)
+ if (plp->bombs || nuk_on_plane(&plp->plane) >= 0)
dam += pln_damage(&plp->plane, target->sct_x, target->sct_y,
's', &nukedam, 1);
}