extern void msl_sel(struct emp_qelem *, coord, coord, natid, int,
int, int);
extern int msl_launch_mindam(struct emp_qelem *, coord, coord, int,
- int, int, char *, int, int);
+ int, int, char *, int);
/* mtch.c */
extern int comtch(char *, struct cmndstr *, int);
/* natarg.c */
extern void plane_sweep(struct emp_qelem *, coord, coord);
extern int put_plane_on_land(struct plnstr *, struct lndstr *);
extern int pln_hitchance(struct plnstr *, int, int);
-extern int pln_damage(struct plnstr *, coord, coord, char, int *, int);
+extern int pln_damage(struct plnstr *, char, int);
extern int pln_identchance(struct plnstr *, int, int);
extern int pln_is_in_orbit(struct plnstr *);
extern void pln_set_tech(struct plnstr *, int);
Plane and missile hitchance
-If the plane or missile is carrying a nuclear warhead or the target is
+If the target is
a sector, then the hitchance is 100%. Otherwise, the following
procedure is used to calculate hitchance.
Strategic missions damage all commodities in the entire target sector,
while not damaging any ships resident (similar to the
\*Qfire\*U command).
-If a plane is armed with a nuclear warhead, then it will drop the bomb
-rather than using conventional weapons.
-Nuclear devices damage everything in the sector; planes, ships, and
-commodities.
-Only missiles in hardened silos can avoid damage from a nuclear mission.
+.s1
+Nuclear bombs can only be used for strategic bombing. They damage
+everything in the sector; planes, ships, and commodities.
+Only missiles in hardened silos can avoid damage from a nuclear attack.
.s1
<SECT> represents an assembly point, where all of the planes in the
mission meet before proceeding on to the target sector.
Missiles launched from submarines are anonymous. The victim
is not notified of the identity of the launching country.
.s1
-Missiles on interdiction mission have the same chance of hitting and
-do the same damage as if they were launched by hand. Also, any
-nuclear armed missiles will detonate if they launch on an interdiction
-mission. You specify whether the nuclear warhead will airburst or
+Nuclear-tipped missiles can only be launched at sectors.
+You specify whether the nuclear warhead will airburst or
groundburst when you arm the missiles (see info arm).
In order to better destroy missiles on the ground (or in their silos),
the ground-burst technique is used.
but will not intercept one outside their op-area, even if it is within
their normal range. Be sure you understand this before using plane missions.)
.s1
-Nukes on missiles or planes flying missions DO detonate.
+Planes armed with nukes cannot be assigned missions.
.s1
"marine" missiles will keep launching to interdict ships until all of
the valuable ships in the fleet are sunk. A "valuable" ship is one
&& getrel(getnatp(pl.pln_own), player->cnum) != ALLIED)
continue;
plc = &plchr[(int)pl.pln_type];
- if ((plc->pl_flags & (P_O | P_N))
+ if ((plc->pl_flags & (P_O | P_N | P_MAR))
|| (plc->pl_flags & (P_M | P_F)) == (P_M | P_F)) {
pr("A %s cannot carry nuclear devices!\n", plc->pl_name);
return RET_FAIL;
pl.pln_flags |= PLN_AIRBURST;
else
pl.pln_flags &= ~PLN_AIRBURST;
+ pl.pln_mission = 0;
snprintf(buf, sizeof(buf), "armed on your %s in %s",
prplane(&pl), xyas(pl.pln_x, pl.pln_y, pl.pln_own));
struct emp_qelem *qp, *next;
struct sctstr sect;
int oldeff, dam = 0;
- int nukedam;
for (qp = list->q_forw; qp != list; qp = next) {
next = qp->q_forw;
plp = (struct plist *)qp;
if (changed_plane_aborts(plp))
continue;
- dam += pln_damage(&plp->plane, target->sct_x, target->sct_y,
- 'p', &nukedam, 1);
+ dam += pln_damage(&plp->plane, 'p', 1);
}
- if (dam <= 0) /* dam == 0 if only nukes were delivered */
+ if (dam <= 0)
return;
getsect(target->sct_x, target->sct_y, §);
target = §
struct emp_qelem *qp, *next;
struct sctstr sect;
int dam = 0;
- int nukedam;
for (i = 0; i < nbomb; i++) {
if (target->sct_item[bombcomm[i]] == 0)
plp = (struct plist *)qp;
if (changed_plane_aborts(plp))
continue;
- dam += pln_damage(&plp->plane, target->sct_x, target->sct_y,
- 'p', &nukedam, 1);
+ dam += pln_damage(&plp->plane, 'p', 1);
}
- if (dam <= 0) /* dam == 0 if only nukes were delivered */
+ if (dam <= 0)
return;
getsect(target->sct_x, target->sct_y, §);
target = §
char buf[1024];
char prompt[128];
int hitchance;
- int nukedam;
int flak;
int gun;
}
if (roll(100) <= hitchance) {
/* pinbombing is more accurate than normal bombing */
- dam = 2 * pln_damage(&plp->plane, target->sct_x, target->sct_y,
- 'p', &nukedam, 1);
+ dam = 2 * pln_damage(&plp->plane, 'p', 1);
} else {
pr("splash\n");
/* Bombs that miss have to land somewhere! */
- dam = pln_damage(&plp->plane, target->sct_x, target->sct_y,
- 'p', &nukedam, 0);
+ dam = pln_damage(&plp->plane, 'p', 0);
collateral_damage(target->sct_x, target->sct_y, dam);
dam = 0;
}
- if (dam <= 0) /* dam == 0 if only nukes were delivered */
+ if (dam <= 0)
continue;
if (mcp->m_flags & M_SUB)
nreport(player->cnum, N_SUB_BOMB, ship.shp_own, 1);
char prompt[128];
char buf[1024];
int hitchance;
- int nukedam;
int nplanes;
for (qp = list->q_forw; qp != list; qp = next) {
}
if (roll(100) <= hitchance) {
/* pinbombing is more accurate than normal bombing */
- dam = 2 * pln_damage(&plp->plane, target->sct_x, target->sct_y,
- 'p', &nukedam, 1);
+ dam = 2 * pln_damage(&plp->plane, 'p', 1);
} else {
pr("thud\n");
/* Bombs that miss have to land somewhere! */
- dam = pln_damage(&plp->plane, target->sct_x, target->sct_y,
- 'p', &nukedam, 0);
+ dam = pln_damage(&plp->plane, 'p', 0);
collateral_damage(target->sct_x, target->sct_y, dam);
dam = 0;
}
- if (dam <= 0) /* dam == 0 if only nukes were delivered */
+ if (dam <= 0)
continue;
if (dam > 100)
dam = 100;
int unitno;
int aaf, flak, hitchance;
struct plist *plp;
- int nukedam;
int nunits;
for (qp = list->q_forw; qp != list; qp = next) {
pr("%d%% hitchance...", hitchance);
}
if (roll(100) <= hitchance) {
- dam = 2 * pln_damage(&plp->plane, target->sct_x, target->sct_y,
- 'p', &nukedam, 1);
+ dam = 2 * pln_damage(&plp->plane, 'p', 1);
} else {
pr("thud\n");
/* Bombs that miss have to land somewhere! */
- dam = pln_damage(&plp->plane, target->sct_x, target->sct_y,
- 'p', &nukedam, 0);
+ dam = pln_damage(&plp->plane, 'p', 0);
collateral_damage(target->sct_x, target->sct_y, dam);
dam = 0;
}
- if (dam <= 0) /* dam == 0 if only nukes were delivered */
+ if (dam <= 0)
continue;
if (dam > 100)
dam = 100;
int dam = 0;
struct emp_qelem *qp;
struct sctstr sect;
- int nukedam;
+ struct nukstr nuke;
for (qp = list->q_forw; qp != list; qp = qp->q_forw) {
plp = (struct plist *)qp;
- dam += pln_damage(&plp->plane, target->sct_x, target->sct_y,
- 's', &nukedam, 1);
+ if (getnuke(nuk_on_plane(&plp->plane), &nuke)) {
+ mpr(plp->plane.pln_own,
+ "Releasing RV's for %s detonation...\n",
+ plp->plane.pln_flags & PLN_AIRBURST
+ ? "airburst" : "groundburst");
+ detonate(&nuke, target->sct_x, target->sct_y,
+ plp->plane.pln_flags & PLN_AIRBURST);
+ } else
+ dam += pln_damage(&plp->plane, 's', 1);
}
if (dam <= 0) /* dam == 0 if only nukes were delivered */
return;
#include "damage.h"
#include "mission.h"
#include "news.h"
+#include "nuke.h"
#include "optlist.h"
#include "path.h"
#include "plane.h"
struct mchrstr *mcp;
struct shpstr target_ship;
struct sctstr sect;
- int nukedam;
int rel;
struct natstr *natp;
+ struct nukstr nuke;
char buf[1024];
if (pcp->pl_flags & P_MAR)
pr("Range too great; try again!\n");
return RET_FAIL;
}
- if (msl_equip(pp, 'p') < 0)
- return RET_FAIL;
if (!(pcp->pl_flags & P_MAR)) {
+ if (msl_equip(pp, 's') < 0)
+ return RET_FAIL;
getsect(sx, sy, §);
if (opt_SLOW_WAR) {
natp = getnatp(player->cnum);
N_SCT_SMISS, "sector", sx, sy, sect.sct_own)) {
#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
+ * FIXME want collateral damage on miss, but we get here
+ * too when launch fails or missile is intercepted
*/
- dam = pln_damage(pp, sect.sct_x, sect.sct_y, 's', &nukedam, 0);
+ dam = pln_damage(pp, 's', 0);
collateral_damage(sect.sct_x, sect.sct_y, dam, 0);
#endif
return RET_OK;
}
- dam = pln_damage(pp, sect.sct_x, sect.sct_y, 's', &nukedam, 1);
- if (!nukedam) {
+ if (getnuke(nuk_on_plane(pp), &nuke)) {
+ mpr(pp->pln_own,
+ "Releasing RV's for %s detonation...\n",
+ pp->pln_flags & PLN_AIRBURST ? "airburst" : "groundburst");
+ detonate(&nuke, sx, sy, pp->pln_flags & PLN_AIRBURST);
+ } else {
+ dam = pln_damage(pp, 's', 1);
pr("did %d damage in %s\n", PERCENT_DAMAGE(dam),
xyas(sx, sy, player->cnum));
if (sect.sct_own != 0) {
putsect(§);
}
} else {
+ if (msl_equip(pp, 'p') < 0)
+ return RET_FAIL;
if (!msl_hit(pp, shp_hardtarget(&target_ship), EF_SHIP,
N_SHP_MISS, N_SHP_SMISS, prship(&target_ship),
target_ship.shp_x, target_ship.shp_y,
target_ship.shp_own)) {
pr("splash\n");
#if 0 /* FIXME see above */
- dam = pln_damage(pp,target_ship.shp_x,target_ship.shp_y,'p',&nukedam, 0);
+ dam = pln_damage(pp, 'p', 0);
collateral_damage(target_ship.shp_x, target_ship.shp_y, dam, 0);
#endif
return RET_OK;
}
- dam = pln_damage(pp, target_ship.shp_x, target_ship.shp_y, 'p',
- &nukedam, 1);
- if (!nukedam) {
- check_retreat_and_do_shipdamage(&target_ship, dam);
- putship(target_ship.shp_uid, &target_ship);
- }
+ dam = pln_damage(pp, 'p', 1);
+ check_retreat_and_do_shipdamage(&target_ship, dam);
+ putship(target_ship.shp_uid, &target_ship);
getship(target_ship.shp_uid, &target_ship);
if (!target_ship.shp_own)
pr("%s sunk!\n", prship(&target_ship));
}
}
+ if (type == EF_PLANE && nuk_on_plane((struct plnstr *)gp) >= 0) {
+ pr("%s can't perform a mission while it carries a nuclear weapon",
+ obj_nameof(gp));
+ continue;
+ }
+
if (*p == '.') {
x = gp->x;
y = gp->y;
dam = msl_launch_mindam(&msl_list, newx, newy,
lnd_easiest_target(list), EF_LAND,
- lnd_count(list) * 20, "troops", victim,
- MI_INTERDICT);
+ lnd_count(list) * 20, "troops", victim);
if (dam) {
mpr(victim, "missile interdiction mission does %d damage!\n", dam);
collateral_damage(newx, newy, dam);
/* I arbitrarily chose 100 mindam -KHS */
dam +=
msl_launch_mindam(&missiles, x, y, hardtarget, EF_SECTOR, 100,
- "sector", victim, mission);
+ "sector", victim);
qp = missiles.q_forw;
while (qp != (&missiles)) {
newqp = qp->q_forw;
itype = I_NONE;
switch (mission) {
case 'p': /* pinpoint bomb */
- if (nuk_on_plane(pp) >= 0)
- break;
itype = I_SHELL;
break;
case 'i': /* missile interception */
needed = load / ichr[itype].i_lbs;
if (needed <= 0)
return -1;
+ 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);
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;
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,
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;
/* 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)
+ int type, int mindam, char *whatp, int victim)
{
struct emp_qelem *qp;
struct emp_qelem *next;
struct plist *plp;
int newdam, dam = 0;
- int nukedam = 0;
int news_item;
int snews_item;
snews_item = N_SCT_SMISS;
}
- for (qp = list->q_back; qp != list && dam < mindam && !nukedam;
+ for (qp = list->q_back; qp != list && dam < mindam;
qp = next) {
next = qp->q_back;
plp = (struct plist *)qp;
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;
+ newdam = pln_damage(&plp->plane, 'p', 1);
+ 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
+ * FIXME want collateral damage on miss, 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);
+ newdam = pln_damage(&plp->plane, 'p', 0);
collateral_damage(x, y, newdam);
#endif
}
switch (mission) {
case 's': /* strategic bomb */
case 'p': /* pinpoint bomb */
- if (nuk_on_plane(pp) >= 0)
- break;
itype = I_SHELL;
break;
case 't': /* transport */
pr("%s can't contribute to mission\n", prplane(pp));
return -1;
}
+ if (nuk_on_plane(pp) >= 0) {
+ if (mission == 's' || mission == 't')
+ needed = 0;
+ else {
+ pr("%s can't fly this mission"
+ " while it is carrying a nuclear weapon",
+ prplane(pp));
+ return -1;
+ }
+ }
if (itype == I_CIVIL && pp->pln_own != own) {
pr("You don't control those civilians!\n");
return -1;
return hitchance;
}
-/* return 0 if there was a nuclear detonation */
-
int
-pln_damage(struct plnstr *pp, coord x, coord y, char type, int *nukedamp,
- int noisy)
+pln_damage(struct plnstr *pp, char type, int noisy)
{
- struct nukstr nuke;
struct plchrstr *pcp = plchr + pp->pln_type;
int load, i;
int hitroll;
int effective = 1;
int pinbomber = 0;
- if (getnuke(nuk_on_plane(pp), &nuke)) {
- mpr(pp->pln_own, "Releasing RV's for %s detonation...\n",
- pp->pln_flags & PLN_AIRBURST ? "airburst" : "groundburst");
- *nukedamp = detonate(&nuke, x, y,
- pp->pln_flags & PLN_AIRBURST);
+ if (CANT_HAPPEN(nuk_on_plane(pp) >= 0)) /* FIXME check uses! */
return 0;
- }
- *nukedamp = 0;
load = pln_load(pp);
if (!load) /* e.g. ab, blowing up on launch pad */
sprintf(what, "%s", prship(&mvs->unit.ship));
dam = msl_launch_mindam(&msl_list, newx, newy,
shp_hardtarget(&mvs->unit.ship),
- EF_SHIP, 1, what, victim, MI_INTERDICT);
+ EF_SHIP, 1, what, victim);
if (dam) {
mpr(victim,
"missile interdiction mission does %d damage to %s!\n",