-/* SCCS Id: @(#)trap.c 3.5 2004/12/21 */
+/* SCCS Id: @(#)trap.c 3.5 2005/03/16 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
blow_up_landmine(trap)
struct trap *trap;
{
- (void)scatter(trap->tx, trap->ty, 4,
- MAY_DESTROY | MAY_HIT | MAY_FRACTURE | VIS_EFFECTS,
- (struct obj *)0);
- del_engr_at(trap->tx, trap->ty);
- wake_nearto(trap->tx, trap->ty, 400);
- if (IS_DOOR(levl[trap->tx][trap->ty].typ))
- levl[trap->tx][trap->ty].doormask = D_BROKEN;
- /* TODO: destroy drawbridge if present */
- /* caller may subsequently fill pit, e.g. with a boulder */
+ int x = trap->tx, y = trap->ty, dbx, dby;
+ struct rm *lev = &levl[x][y];
+
+ (void)scatter(x, y, 4,
+ MAY_DESTROY | MAY_HIT | MAY_FRACTURE | VIS_EFFECTS,
+ (struct obj *)0);
+ del_engr_at(x, y);
+ wake_nearto(x, y, 400);
+ if (IS_DOOR(lev->typ))
+ lev->doormask = D_BROKEN;
+ /* destroy drawbridge if present */
+ if (lev->typ == DRAWBRIDGE_DOWN || is_drawbridge_wall(x, y) >= 0) {
+ dbx = x, dby = y;
+ /* if under the portcullis, the bridge is adjacent */
+ if (find_drawbridge(&dbx, &dby))
+ destroy_drawbridge(dbx, dby);
+ trap = t_at(x, y); /* expected to be null after destruction */
+ }
+ /* convert landmine into pit */
+ if (trap) {
trap->ttyp = PIT; /* explosion creates a pit */
trap->madeby_u = FALSE; /* resulting pit isn't yours */
seetrap(trap); /* and it isn't concealed */
+ }
}
/*
if (!in_sight)
pline("Kaablamm! You hear an explosion in the distance!");
blow_up_landmine(trap);
- if (thitm(0, mtmp, (struct obj *)0, rnd(16), FALSE))
+ /* explosion might have destroyed a drawbridge; don't
+ dish out more damage if monster is already dead */
+ if (mtmp->mhp <= 0 ||
+ thitm(0, mtmp, (struct obj *)0, rnd(16), FALSE))
trapkilled = TRUE;
else {
/* monsters recursively fall into new pit */