Indented with src/scripts/indent-emp.

This commit is contained in:
Markus Armbruster 2003-09-02 20:48:48 +00:00
parent 5f263a7753
commit 9b7adfbecc
437 changed files with 52211 additions and 51052 deletions

View file

@ -52,270 +52,265 @@ void kaboom(int x, int y, int rad, natid cn);
int
detonate(struct plnstr *pp, int x, int y)
{
int nuketype = pp->pln_nuketype;
natid bombown = pp->pln_own;
int airburst = (pp->pln_flags & PLN_AIRBURST);
struct nchrstr *ncp;
struct plnstr plane;
struct sctstr sect;
struct shpstr ship;
struct lndstr land;
struct nukstr nuke;
s_char *bp;
s_char buf[128];
s_char buf2[128];
natid own;
int type;
int damage;
int fallout;
int rad;
struct nstr_sect ns;
struct nstr_item ni;
int issea = 0;
int retval;
int nuketype = pp->pln_nuketype;
natid bombown = pp->pln_own;
int airburst = (pp->pln_flags & PLN_AIRBURST);
struct nchrstr *ncp;
struct plnstr plane;
struct sctstr sect;
struct shpstr ship;
struct lndstr land;
struct nukstr nuke;
s_char *bp;
s_char buf[128];
s_char buf2[128];
natid own;
int type;
int damage;
int fallout;
int rad;
struct nstr_sect ns;
struct nstr_item ni;
int issea = 0;
int retval;
pp->pln_nuketype = -1;
getsect(x,y,&sect);
if (sect.sct_type == SCT_WATER)
issea = 1;
ncp = &nchr[nuketype];
kaboom(x, y, ncp->n_blast, bombown);
rad = ncp->n_blast;
if (!airburst)
rad = rad * 2 / 3;
snxtsct_dist(&ns, x, y, rad);
while (nxtsct(&ns, &sect)) {
/* Nukes falling on water affect only 1 sector */
if ((sect.sct_x != x) && issea)
continue;
if ((sect.sct_y != y) && issea)
continue;
own = sect.sct_own;
type = sect.sct_type;
if ((damage = nukedamage(ncp, ns.curdist, airburst)) <= 0)
continue;
if (type == SCT_SANCT) {
mpr(bombown,"bounced off %s\n", xyas(ns.x, ns.y, bombown));
if(own != 0)
mpr(own, "%s nuclear device bounced off %s\n",
cname(bombown), xyas(ns.x, ns.y, bombown));
nreport(bombown, N_NUKE, own, 1);
continue;
}
if (opt_FALLOUT)
fallout = getvar(V_FALLOUT,(s_char *)&sect,EF_SECTOR);
sect_damage(&sect, damage, 0);
if (sect.sct_x == x && sect.sct_y == y)
retval = damage;
if (opt_FALLOUT) {
if (opt_NEUTRON && (ncp->n_flags & N_NEUT))
fallout += damage*30;
else
fallout += damage*3;
putvar(V_FALLOUT,fallout,(s_char *)&sect,EF_SECTOR);
}
if (damage > 100) {
makelost(EF_SECTOR, sect.sct_own, 0, sect.sct_x, sect.sct_y);
sect.sct_oldown = 0;
sect.sct_own = 0;
if (type == SCT_WATER || type == SCT_BSPAN ||
type == SCT_BTOWER) {
bp = "left nothing but water in %s\n";
if (type != SCT_WATER) {
sect.sct_newtype = SCT_WATER;
sect.sct_type = SCT_WATER;
}
} else {
sect.sct_newtype = SCT_WASTE;
sect.sct_type = SCT_WASTE;
bp = "turned %s into a radioactive wasteland\n";
pp->pln_nuketype = -1;
getsect(x, y, &sect);
if (sect.sct_type == SCT_WATER)
issea = 1;
ncp = &nchr[nuketype];
kaboom(x, y, ncp->n_blast, bombown);
rad = ncp->n_blast;
if (!airburst)
rad = rad * 2 / 3;
snxtsct_dist(&ns, x, y, rad);
while (nxtsct(&ns, &sect)) {
/* Nukes falling on water affect only 1 sector */
if ((sect.sct_x != x) && issea)
continue;
if ((sect.sct_y != y) && issea)
continue;
own = sect.sct_own;
type = sect.sct_type;
if ((damage = nukedamage(ncp, ns.curdist, airburst)) <= 0)
continue;
if (type == SCT_SANCT) {
mpr(bombown, "bounced off %s\n", xyas(ns.x, ns.y, bombown));
if (own != 0)
mpr(own, "%s nuclear device bounced off %s\n",
cname(bombown), xyas(ns.x, ns.y, bombown));
nreport(bombown, N_NUKE, own, 1);
continue;
}
if (opt_FALLOUT)
fallout = getvar(V_FALLOUT, (s_char *)&sect, EF_SECTOR);
sect_damage(&sect, damage, 0);
if (sect.sct_x == x && sect.sct_y == y)
retval = damage;
if (opt_FALLOUT) {
if (opt_NEUTRON && (ncp->n_flags & N_NEUT))
fallout += damage * 30;
else
fallout += damage * 3;
putvar(V_FALLOUT, fallout, (s_char *)&sect, EF_SECTOR);
}
if (damage > 100) {
makelost(EF_SECTOR, sect.sct_own, 0, sect.sct_x, sect.sct_y);
sect.sct_oldown = 0;
sect.sct_own = 0;
if (type == SCT_WATER || type == SCT_BSPAN ||
type == SCT_BTOWER) {
bp = "left nothing but water in %s\n";
if (type != SCT_WATER) {
sect.sct_newtype = SCT_WATER;
sect.sct_type = SCT_WATER;
}
} else {
sprintf(buf, "did %d%%%% damage in %%s\n", damage);
bp = buf;
}
if ((type == SCT_CAPIT || type == SCT_MOUNT) && damage >= 100)
caploss(&sect, own, "\n%s lost its capital!\n\n");
(void) putsect(&sect);
if (type != SCT_WATER)
nreport(bombown, N_NUKE, own, 1);
mpr(bombown,bp, xyas(ns.x, ns.y, bombown));
if (own != bombown && own != 0) {
(void) sprintf(buf2, bp, xyas(ns.x, ns.y, own));
mpr(own, "%s nuclear device %s\n",
cname(bombown), buf2);
sect.sct_newtype = SCT_WASTE;
sect.sct_type = SCT_WASTE;
bp = "turned %s into a radioactive wasteland\n";
}
} else {
sprintf(buf, "did %d%%%% damage in %%s\n", damage);
bp = buf;
}
snxtitem_dist(&ni, EF_PLANE, x, y, rad);
while (nxtitem(&ni, (caddr_t)&plane)) {
/* Nukes falling on water affect only 1 sector */
if ((plane.pln_x != x) && issea)
continue;
if ((plane.pln_y != y) && issea)
continue;
if ((own = plane.pln_own) == 0)
continue;
if ((plane.pln_flags & PLN_LAUNCHED) && (airburst != 2))
continue;
damage = nukedamage(ncp, ni.curdist, airburst) - plane.pln_harden;
if (damage <= 0)
continue;
if (plane.pln_ship >= 0) {
/* Are we on a sub? */
getship(plane.pln_ship, &ship);
if (mchr[(int)ship.shp_type].m_flags & M_SUB) {
struct sctstr sect1;
/* Should we damage this sub? */
getsect(ship.shp_x,ship.shp_y,&sect1);
if (sect1.sct_type == SCT_BSPAN ||
sect1.sct_type == SCT_BTOWER ||
sect1.sct_type == SCT_WATER) {
/* Ok, we're not in a harbor or trapped
inland. Now, did we get pasted
directly? */
if (ship.shp_x != x || ship.shp_y != y) {
/* Nope, so don't mess with it */
continue;
}
}
}
}
planedamage(&plane, damage);
if (own == bombown) {
mpr(bombown,"%s at %s reports %d%% damage\n",
prplane(&plane),
xyas(plane.pln_x, plane.pln_y, own),
damage);
} else {
if(own != 0)
mpr(own,
"%s nuclear device did %d%% damage to %s at %s\n",
cname(bombown), damage,
prplane(&plane),
xyas(plane.pln_x, plane.pln_y, own));
}
putplane(ni.cur, &plane);
if ((type == SCT_CAPIT || type == SCT_MOUNT) && damage >= 100)
caploss(&sect, own, "\n%s lost its capital!\n\n");
(void)putsect(&sect);
if (type != SCT_WATER)
nreport(bombown, N_NUKE, own, 1);
mpr(bombown, bp, xyas(ns.x, ns.y, bombown));
if (own != bombown && own != 0) {
(void)sprintf(buf2, bp, xyas(ns.x, ns.y, own));
mpr(own, "%s nuclear device %s\n", cname(bombown), buf2);
}
snxtitem_dist(&ni, EF_LAND, x, y, rad);
while (nxtitem(&ni, (caddr_t)&land)) {
/* Nukes falling on water affect only 1 sector */
if ((land.lnd_x != x) && issea)
continue;
if ((land.lnd_y != y) && issea)
continue;
if ((own = land.lnd_own) == 0)
continue;
if ((damage = nukedamage(ncp, ni.curdist, airburst)) <= 0)
continue;
}
snxtitem_dist(&ni, EF_PLANE, x, y, rad);
while (nxtitem(&ni, (caddr_t)&plane)) {
/* Nukes falling on water affect only 1 sector */
if ((plane.pln_x != x) && issea)
continue;
if ((plane.pln_y != y) && issea)
continue;
if ((own = plane.pln_own) == 0)
continue;
if ((plane.pln_flags & PLN_LAUNCHED) && (airburst != 2))
continue;
damage = nukedamage(ncp, ni.curdist, airburst) - plane.pln_harden;
if (damage <= 0)
continue;
if (plane.pln_ship >= 0) {
/* Are we on a sub? */
getship(plane.pln_ship, &ship);
if (land.lnd_ship >= 0) {
/* Are we on a sub? */
getship(land.lnd_ship, &ship);
if (mchr[(int)ship.shp_type].m_flags & M_SUB) {
struct sctstr sect1;
if (mchr[(int)ship.shp_type].m_flags & M_SUB) {
struct sctstr sect1;
/* Should we damage this sub? */
getsect(ship.shp_x,ship.shp_y,&sect1);
if (sect1.sct_type == SCT_BSPAN ||
sect1.sct_type == SCT_BTOWER ||
sect1.sct_type == SCT_WATER) {
/* Ok, we're not in a harbor or trapped
inland. Now, did we get pasted
directly? */
if (ship.shp_x != x || ship.shp_y != y) {
/* Nope, so don't mess with it */
continue;
}
}
}
}
land_damage(&land, damage);
if (own == bombown) {
mpr(bombown,"%s at %s reports %d%% damage\n",
prland(&land),
xyas(land.lnd_x, land.lnd_y, own), damage);
} else {
if(own != 0)
mpr(own, "%s nuclear device did %d%% damage to %s at %s\n",
cname(bombown), damage,
prland(&land),
xyas(land.lnd_x, land.lnd_y, own));
}
putland(land.lnd_uid, &land);
}
snxtitem_dist(&ni, EF_SHIP, x, y, rad);
while (nxtitem(&ni, (caddr_t)&ship)) {
/* Nukes falling on water affect only 1 sector */
if ((ship.shp_x != x) && issea)
continue;
if ((ship.shp_y != y) && issea)
continue;
if ((own = ship.shp_own) == 0)
continue;
if ((damage = nukedamage(ncp, ni.curdist, airburst)) <= 0)
continue;
if (mchr[(int)ship.shp_type].m_flags & M_SUB) {
struct sctstr sect1;
/* Should we damage this sub? */
getsect(ship.shp_x, ship.shp_y, &sect1);
/* Should we damage this sub? */
getsect(ship.shp_x,ship.shp_y,&sect1);
if (sect1.sct_type == SCT_BSPAN ||
sect1.sct_type == SCT_BTOWER ||
sect1.sct_type == SCT_WATER) {
if (sect1.sct_type == SCT_BSPAN ||
sect1.sct_type == SCT_BTOWER ||
sect1.sct_type == SCT_WATER) {
/* Ok, we're not in a harbor or trapped
inland. Now, did we get pasted
directly? */
if (ship.shp_x != x || ship.shp_y != y) {
/* Nope, so don't mess with it */
continue;
/* Nope, so don't mess with it */
continue;
}
}
}
ship_damage(&ship, damage);
if (own == bombown) {
mpr(bombown,"%s at %s reports %d%% damage\n",
prship(&ship),
xyas(ship.shp_x, ship.shp_y, own), damage);
} else {
if(own != 0)
mpr(own, "%s nuclear device did %d%% damage to %s at %s\n",
cname(bombown), damage, prship(&ship),
xyas(ship.shp_x, ship.shp_y, own));
}
putship(ship.shp_uid, &ship);
}
}
snxtitem_dist(&ni, EF_NUKE, x, y, rad);
while (nxtitem(&ni, (caddr_t)&nuke)) {
/* Nukes falling on water affect only 1 sector */
if ((nuke.nuk_x != x) && issea)
continue;
if ((nuke.nuk_y != y) && issea)
continue;
if ((own = nuke.nuk_own) == 0)
continue;
if ((damage = nukedamage(ncp, ni.curdist, airburst)) <= 0)
continue;
if (roll(100) >= damage)
continue;
makelost(EF_NUKE, nuke.nuk_own, nuke.nuk_uid, nuke.nuk_x, nuke.nuk_y);
nuke.nuk_own = 0;
if (own == bombown) {
mpr(bombown,"nuclear stockpile #%d at %s destroyed\n",
ni.cur, xyas(nuke.nuk_x, nuke.nuk_y, own));
} else {
if(own != 0)
mpr(own, "nuclear stockpile #%d at %s destroyed\n",
ni.cur, xyas(nuke.nuk_x, nuke.nuk_y, own));
}
putnuke(ni.cur, &nuke);
planedamage(&plane, damage);
if (own == bombown) {
mpr(bombown, "%s at %s reports %d%% damage\n",
prplane(&plane),
xyas(plane.pln_x, plane.pln_y, own), damage);
} else {
if (own != 0)
mpr(own,
"%s nuclear device did %d%% damage to %s at %s\n",
cname(bombown), damage,
prplane(&plane), xyas(plane.pln_x, plane.pln_y, own));
}
return retval;
putplane(ni.cur, &plane);
}
snxtitem_dist(&ni, EF_LAND, x, y, rad);
while (nxtitem(&ni, (caddr_t)&land)) {
/* Nukes falling on water affect only 1 sector */
if ((land.lnd_x != x) && issea)
continue;
if ((land.lnd_y != y) && issea)
continue;
if ((own = land.lnd_own) == 0)
continue;
if ((damage = nukedamage(ncp, ni.curdist, airburst)) <= 0)
continue;
if (land.lnd_ship >= 0) {
/* Are we on a sub? */
getship(land.lnd_ship, &ship);
if (mchr[(int)ship.shp_type].m_flags & M_SUB) {
struct sctstr sect1;
/* Should we damage this sub? */
getsect(ship.shp_x, ship.shp_y, &sect1);
if (sect1.sct_type == SCT_BSPAN ||
sect1.sct_type == SCT_BTOWER ||
sect1.sct_type == SCT_WATER) {
/* Ok, we're not in a harbor or trapped
inland. Now, did we get pasted
directly? */
if (ship.shp_x != x || ship.shp_y != y) {
/* Nope, so don't mess with it */
continue;
}
}
}
}
land_damage(&land, damage);
if (own == bombown) {
mpr(bombown, "%s at %s reports %d%% damage\n",
prland(&land), xyas(land.lnd_x, land.lnd_y, own), damage);
} else {
if (own != 0)
mpr(own, "%s nuclear device did %d%% damage to %s at %s\n",
cname(bombown), damage,
prland(&land), xyas(land.lnd_x, land.lnd_y, own));
}
putland(land.lnd_uid, &land);
}
snxtitem_dist(&ni, EF_SHIP, x, y, rad);
while (nxtitem(&ni, (caddr_t)&ship)) {
/* Nukes falling on water affect only 1 sector */
if ((ship.shp_x != x) && issea)
continue;
if ((ship.shp_y != y) && issea)
continue;
if ((own = ship.shp_own) == 0)
continue;
if ((damage = nukedamage(ncp, ni.curdist, airburst)) <= 0)
continue;
if (mchr[(int)ship.shp_type].m_flags & M_SUB) {
struct sctstr sect1;
/* Should we damage this sub? */
getsect(ship.shp_x, ship.shp_y, &sect1);
if (sect1.sct_type == SCT_BSPAN ||
sect1.sct_type == SCT_BTOWER ||
sect1.sct_type == SCT_WATER) {
/* Ok, we're not in a harbor or trapped
inland. Now, did we get pasted
directly? */
if (ship.shp_x != x || ship.shp_y != y) {
/* Nope, so don't mess with it */
continue;
}
}
}
ship_damage(&ship, damage);
if (own == bombown) {
mpr(bombown, "%s at %s reports %d%% damage\n",
prship(&ship), xyas(ship.shp_x, ship.shp_y, own), damage);
} else {
if (own != 0)
mpr(own, "%s nuclear device did %d%% damage to %s at %s\n",
cname(bombown), damage, prship(&ship),
xyas(ship.shp_x, ship.shp_y, own));
}
putship(ship.shp_uid, &ship);
}
snxtitem_dist(&ni, EF_NUKE, x, y, rad);
while (nxtitem(&ni, (caddr_t)&nuke)) {
/* Nukes falling on water affect only 1 sector */
if ((nuke.nuk_x != x) && issea)
continue;
if ((nuke.nuk_y != y) && issea)
continue;
if ((own = nuke.nuk_own) == 0)
continue;
if ((damage = nukedamage(ncp, ni.curdist, airburst)) <= 0)
continue;
if (roll(100) >= damage)
continue;
makelost(EF_NUKE, nuke.nuk_own, nuke.nuk_uid, nuke.nuk_x,
nuke.nuk_y);
nuke.nuk_own = 0;
if (own == bombown) {
mpr(bombown, "nuclear stockpile #%d at %s destroyed\n",
ni.cur, xyas(nuke.nuk_x, nuke.nuk_y, own));
} else {
if (own != 0)
mpr(own, "nuclear stockpile #%d at %s destroyed\n",
ni.cur, xyas(nuke.nuk_x, nuke.nuk_y, own));
}
putnuke(ni.cur, &nuke);
}
return retval;
}
@ -325,8 +320,8 @@ detonate(struct plnstr *pp, int x, int y)
void
kaboom(int x, int y, int rad, natid cn)
{
mpr(cn,"\n\nK A B ");
while (rad-- > 0)
mpr(cn,"O O ");
mpr(cn,"M ! in %s\n\n", xyas(x, y, cn));
mpr(cn, "\n\nK A B ");
while (rad-- > 0)
mpr(cn, "O O ");
mpr(cn, "M ! in %s\n\n", xyas(x, y, cn));
}