/*
* Empire - A multi-player, client/server Internet based war game.
- * Copyright (C) 1986-2006, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ * Copyright (C) 1986-2009, Dave Pare, Jeff Bailey, Thomas Ruschak,
* Ken Stevens, Steve McClure
*
* This program is free software; you can redistribute it and/or modify
* ---
*
* mslsub.c: Missile subroutine stuff
- *
+ *
* Known contributors to this file:
* Ken Stevens, 1995
* Steve McClure, 1996-2000
#include <config.h>
-#include "misc.h"
-#include "queue.h"
-#include "player.h"
-#include "sect.h"
-#include "ship.h"
-#include "optlist.h"
-#include "plane.h"
+#include <stdlib.h>
+#include "file.h"
#include "land.h"
+#include "misc.h"
+#include "mission.h"
+#include "nat.h"
#include "news.h"
-#include "xy.h"
#include "nsc.h"
-#include "file.h"
-#include "nat.h"
+#include "nuke.h"
+#include "optlist.h"
#include "path.h"
-#include "mission.h"
+#include "plane.h"
+#include "player.h"
#include "prototypes.h"
+#include "queue.h"
+#include "sect.h"
+#include "ship.h"
+#include "xy.h"
int
-msl_equip(struct plnstr *pp)
+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, 0, 0, 'p');
+ return pln_equip(&pl, NULL, mission);
}
int
struct sctstr sect;
int sublaunch = 0;
struct plchrstr *pcp = plchr + pp->pln_type;
- int hitchance = pln_hitchance(pp, hardtarget, type);
+ int hitchance;
char *from;
int dam, dummyi;
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, 0);
+ sectdamage(§, dam);
putsect(§);
}
}
return 0;
}
+ CANT_HAPPEN(pp->pln_flags & PLN_LAUNCHED);
+ pp->pln_flags |= PLN_LAUNCHED;
+ putplane(pp->pln_uid, pp);
mpr(pp->pln_own, "\tSHWOOOOOSH! Missile launched!\n");
- if (pp->pln_nuketype != -1)
- mpr(pp->pln_own, "\tArming nuclear warheads...\n");
-
if (pcp->pl_flags & P_T)
mpr(victim, "Incoming %s missile sighted at %s...\n",
sublaunch ? "sub-launched" : cname(pp->pln_own),
xyas(x, y, victim));
- if (opt_PINPOINTMISSILE == 0 ||
- (pcp->pl_flags & P_T && !(pcp->pl_flags & P_MAR))) {
+ if ((pcp->pl_flags & P_T && !(pcp->pl_flags & P_MAR))) {
if (msl_intercept(x, y, pp->pln_own, pcp->pl_def,
sublaunch, P_N, P_O)) {
return 0;
}
}
- if (pp->pln_nuketype != -1)
- hitchance = 100;
-
- mpr(pp->pln_own, "\t%d%% hitchance...", hitchance);
- hit = (roll(100) <= hitchance);
+ if (nuk_on_plane(pp) >= 0) {
+ mpr(pp->pln_own, "\tArming nuclear warheads...\n");
+ hit = 1;
+ } else {
+ hitchance = pln_hitchance(pp, hardtarget, type);
+ hit = (roll(100) <= hitchance);
+ mpr(pp->pln_own, "\t%d%% hitchance...%s\n", hitchance,
+ hit ? "HIT!" : "miss");
+ }
- mpr(pp->pln_own, hit ? "HIT!\n" : "miss\n");
if (pcp->pl_flags & P_T)
mpr(victim, "...Incoming %s missile %s\n",
sublaunch ? "" : cname(pp->pln_own),
continue;
if (mission && plane.pln_mission != mission)
continue;
+ if (mission &&
+ plane.pln_radius < mapdist(x, y, plane.pln_opx, plane.pln_opy))
+ continue;
if (getrel(getnatp(plane.pln_own), victim) >= NEUTRAL)
continue;
/* missiles go one way, so we can use all the range */
continue;
if (plane.pln_effic < 100)
continue;
+ if (!pln_airbase_ok(&plane, 1, 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);
att_name = "satellite";
def_name = "a-sat missile";
news_item = N_SAT_KILL;
- if (sect.sct_own) {
- mpr(sect.sct_own, "%s has positioned a satellite over %s\n",
- sublaunch ? "someone" : cname(bombown),
- xyas(x, y, sect.sct_own));
- }
+ mpr(sect.sct_own, "%s has positioned a satellite over %s\n",
+ sublaunch ? "someone" : 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, 0, 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, 0, 0, 'i') < 0) {
+ if (mission_pln_equip(ip, NULL, 'i') < 0) {
emp_remque(qp);
free(qp);
continue;
free(qp);
}
if (icount == 0) {
- if (sect.sct_own != 0)
- mpr(sect.sct_own, "No %ss launched to intercept.\n", def_name);
+ mpr(sect.sct_own, "No %ss launched to intercept.\n", def_name);
return destroyed;
}
mpr(sect.sct_own, "%s launched to intercept %s %s!\n",
def_name, who, att_name);
} else {
- if (sect.sct_own)
- mpr(sect.sct_own,
- "%s launched an %s to intercept the %s %s!\n",
- cname(pp->pln_own), def_name, who, att_name);
+ mpr(sect.sct_own,
+ "%s launched an %s to intercept the %s %s!\n",
+ cname(pp->pln_own), def_name, who, att_name);
mpr(pp->pln_own,
"%s launched to intercept %s %s arcing towards %s territory!\n",
def_name, who, att_name, cname(sect.sct_own));
att_name, x, y, bombown)) {
mpr(bombown, "%s destroyed by %s %s!\n",
att_name, cname(pp->pln_own), def_name);
- if (sect.sct_own)
- mpr(sect.sct_own, "%s %s intercepted!\n", who, att_name);
+ mpr(sect.sct_own, "%s %s intercepted!\n", who, att_name);
if (sect.sct_own != pp->pln_own)
mpr(pp->pln_own, "%s %s intercepted!\n", who, att_name);
destroyed = 1;
}
/* zap the missile */
- makelost(EF_PLANE, pp->pln_own, pp->pln_uid, pp->pln_x, pp->pln_y);
- pp->pln_own = 0;
+ pp->pln_effic = 0;
putplane(pp->pln_uid, pp);
emp_remque(qp);
free(qp);
if (icount) {
mpr(bombown, "%s made it through %s defenses!\n",
att_name, def_name);
- if (sect.sct_own)
- mpr(sect.sct_own, "%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;
}
next = qp->q_back;
plp = (struct plist *)qp;
- if (mission_pln_equip(plp, 0, 0, 'p') >= 0) {
+ if (mission_pln_equip(plp, NULL, 'p') >= 0) {
if (msl_hit(&plp->plane,
hardtarget, type, news_item, snews_item,
whatp, x, y, victim)) {
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, 0);
+ collateral_damage(x, y, newdam);
+#endif
}
- makelost(EF_PLANE, plp->plane.pln_own, plp->plane.pln_uid,
- plp->plane.pln_x, plp->plane.pln_y);
- plp->plane.pln_own = 0;
+ plp->plane.pln_effic = 0;
putplane(plp->plane.pln_uid, &plp->plane);
emp_remque(qp);
free(qp);