#include "ship.h"
#include "xy.h"
-int
-msl_equip(struct plnstr *pp, char mission)
-{
- struct plist pl;
-
- memset(&pl, 0, sizeof(struct plist));
- pl.pcp = plchr + pp->pln_type;
- pl.plane = *pp;
- return mission_pln_equip(&pl, NULL, 0, mission);
-}
-
int
msl_hit(struct plnstr *pp, int hardtarget, int type, int news_item,
int snews_item, char *what, coord x, coord y, int victim)
struct plchrstr *pcp = plchr + pp->pln_type;
int hitchance;
char *from;
- int dam, dummyi;
+ int dam;
mpr(pp->pln_own, "Preparing to launch %s at %s %s %s%s\n",
prplane(pp),
* (1 - techfact(pp->pln_tech, 1.0)))) {
mpr(pp->pln_own, "KABOOOOM! Missile explodes %s!\n", from);
if (chance(0.33)) {
- dam = pln_damage(pp, pp->pln_x, pp->pln_y,
- 'p', &dummyi, 1) / 2;
- if (dam) {
- if (pp->pln_ship >= 0) {
- shipdamage(&ship, dam);
- putship(ship.shp_uid, &ship);
- } else {
- pr("Explosion damages %s %d%%",
- xyas(pp->pln_x, pp->pln_y, pp->pln_own), dam);
- getsect(pp->pln_x, pp->pln_y, §);
- sectdamage(§, dam);
- putsect(§);
- }
+ dam = pln_damage(pp, 'p', 1) / 2;
+ if (pp->pln_ship >= 0) {
+ shipdamage(&ship, dam);
+ putship(ship.shp_uid, &ship);
+ } else {
+ pr("Explosion damages %s %d%%",
+ xyas(pp->pln_x, pp->pln_y, pp->pln_own), dam);
+ getsect(pp->pln_x, pp->pln_y, §);
+ sectdamage(§, dam);
+ putsect(§);
}
}
return 0;
continue;
/* got a valid interceptor */
irv = malloc(sizeof(*irv));
- irv->bombs = 0;
- irv->misc = 0;
+ irv->load = 0;
irv->pcp = &plchr[(int)plane.pln_type];
irv->plane = plane;
emp_insque(&irv->queue, list);
struct emp_qelem *next;
struct plist *ip;
int icount = 0;
- short destroyed = 0;
+ short destroyed;
char *att_name;
char *def_name;
int news_item;
att_name = "satellite";
def_name = "a-sat missile";
news_item = N_SAT_KILL;
+ CANT_HAPPEN(sublaunch);
mpr(sect.sct_own, "%s has positioned a satellite over %s\n",
- sublaunch ? "someone" : cname(bombown),
- xyas(x, y, sect.sct_own));
+ cname(bombown), xyas(x, y, sect.sct_own));
} else if (wantflags == P_N && nowantflags == P_O) {
att_name = "warhead";
def_name = "abm";
if (pp->pln_own != sect.sct_own)
continue;
pcp = ip->pcp;
- if (mission_pln_equip(ip, NULL, 0, 'i') < 0) {
+ if (mission_pln_equip(ip, NULL, 'i') < 0) {
emp_remque(qp);
free(qp);
continue;
ip = (struct plist *)qp;
pp = &ip->plane;
pcp = ip->pcp;
- if (mission_pln_equip(ip, NULL, 0, 'i') < 0) {
+ if (mission_pln_equip(ip, NULL, 'i') < 0) {
emp_remque(qp);
free(qp);
continue;
}
if (icount == 0) {
mpr(sect.sct_own, "No %ss launched to intercept.\n", def_name);
- return destroyed;
+ return 0;
}
/* attempt to destroy incoming missile */
- while (!QEMPTY(intlist)) {
+ destroyed = 0;
+ while (!destroyed && !QEMPTY(intlist)) {
qp = intlist->q_forw;
ip = (struct plist *)qp;
pp = &ip->plane;
def_name, who, att_name, cname(sect.sct_own));
}
- if (!destroyed &&
- msl_hit(pp, hardtarget, EF_PLANE, news_item, news_item,
+ if (msl_hit(pp, hardtarget, EF_PLANE, news_item, news_item,
att_name, x, y, bombown)) {
mpr(bombown, "%s destroyed by %s %s!\n",
att_name, cname(pp->pln_own), def_name);
putplane(pp->pln_uid, pp);
emp_remque(qp);
free(qp);
- if (destroyed)
- break;
}
/* Clean out what is left in the list */
while (!QEMPTY(intlist)) {
free(qp);
}
if (destroyed)
- return destroyed;
+ return 1;
if (icount) {
mpr(bombown, "%s made it through %s defenses!\n",
att_name, def_name);
mpr(sect.sct_own, "%s made it through %s defenses!\n",
att_name, def_name);
}
- return destroyed;
-}
-
-/* Keep launching missiles on list until mindam damage has been done */
-int
-msl_launch_mindam(struct emp_qelem *list, coord x, coord y, int hardtarget,
- int type, int mindam, char *whatp, int victim,
- int mission)
-{
- struct emp_qelem *qp;
- struct emp_qelem *next;
- struct plist *plp;
- int newdam, dam = 0;
- int nukedam = 0;
- int news_item;
- int snews_item;
-
- if (type == EF_SHIP) {
- news_item = N_SHP_MISS;
- snews_item = N_SHP_SMISS;
- } else if (type == EF_LAND) {
- news_item = N_LND_MISS;
- snews_item = N_LND_SMISS;
- } else {
- news_item = N_SCT_MISS;
- snews_item = N_SCT_SMISS;
- }
-
- for (qp = list->q_back; qp != list && dam < mindam && !nukedam;
- qp = next) {
- next = qp->q_back;
- plp = (struct plist *)qp;
-
- if (mission_pln_equip(plp, NULL, 0, 'p') >= 0) {
- if (msl_hit(&plp->plane,
- hardtarget, type, news_item, snews_item,
- whatp, x, y, victim)) {
- newdam = pln_damage(&plp->plane, x, y, 'p', &nukedam, 1);
- if (nukedam) {
- if (mission == MI_INTERDICT && type == EF_SECTOR)
- dam += nukedam;
- } else
- dam += newdam;
-#if 0
- /*
- * FIXME want collateral damage on miss (which can't
- * happen for nuclear war heads), but we get here too when
- * launch fails or missile is intercepted
- */
- } else {
- /* Missiles that miss have to hit somewhere! */
- newdam = pln_damage(&plp->plane, x, y, 'p', &nukedam, 0);
- collateral_damage(x, y, newdam);
-#endif
- }
- plp->plane.pln_effic = 0;
- putplane(plp->plane.pln_uid, &plp->plane);
- emp_remque(qp);
- free(qp);
- }
- }
- return dam;
+ return 0;
}