-/* NetHack 3.6 dig.c $NHDT-Date: 1517913682 2018/02/06 10:41:22 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.108 $ */
+/* NetHack 3.6 dig.c $NHDT-Date: 1547421446 2019/01/13 23:17:26 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.117 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Michael Allison, 2012. */
/* NetHack may be freely redistributed. See license for details. */
lev->horizontal = FALSE;
/* short-circuit vision recalc */
viz_array[y][x] = (dist < 3) ? (IN_SIGHT | COULD_SEE) : COULD_SEE;
- lev->typ = (rockit ? STONE : ROOM);
+ lev->typ = (rockit ? STONE : ROOM); /* flags set via doormask above */
if (dist >= 3)
impossible("mkcavepos called with dist %d", dist);
feel_newsym(x, y);
}
if (!rockit && levl[u.ux][u.uy].typ == CORR) {
- levl[u.ux][u.uy].typ = ROOM;
+ levl[u.ux][u.uy].typ = ROOM; /* flags for CORR already 0 */
if (waslit)
levl[u.ux][u.uy].waslit = TRUE;
newsym(u.ux, u.uy); /* in case player is invisible */
}
if (context.digging.effort <= 50
- || (ttmp && (ttmp->ttyp == TRAPDOOR || ttmp->ttyp == PIT
- || ttmp->ttyp == SPIKED_PIT))) {
+ || (ttmp && (ttmp->ttyp == TRAPDOOR || is_pit(ttmp->ttyp)))) {
return 1;
} else if (ttmp && (ttmp->ttyp == LANDMINE
|| (ttmp->ttyp == BEAR_TRAP && !u.utrap))) {
Sprintf(kbuf, "chopping off %s own %s", uhis(),
body_part(FOOT));
#else
- Sprintf(kbuf, "\8e©\95ª\82Ì%s\82ð\90Ø\82è\97\8e\82Æ\82µ\82Ä", body_part(FOOT));
+ Sprintf(kbuf, "\8e©\95ª\82Ì%s\82ð\90Ø\82è\97\8e\82Æ\82µ\82Ä",
+ body_part(FOOT));
#endif
losehp(Maybe_Half_Phys(dmg), kbuf, KILLED_BY);
} else {
#else
You("%s\82Å\8cF\82Ìã©\82ð\89ó\82µ\82½\81D", xname(uwep));
#endif
- u.utrap = 0; /* release from trap */
deltrap(ttmp);
+ reset_utrap(TRUE); /* release from trap, maybe Lev or Fly */
}
/* we haven't made any progress toward a pit yet */
context.digging.effort = 0;
}
if (context.digging.effort > 100) {
- register const char *digtxt, *dmgtxt = (const char *) 0;
- register struct obj *obj;
- register boolean shopedge = *in_rooms(dpx, dpy, SHOPBASE);
+ const char *digtxt, *dmgtxt = (const char *) 0;
+ struct obj *obj;
+ boolean shopedge = *in_rooms(dpx, dpy, SHOPBASE);
if ((obj = sobj_at(STATUE, dpx, dpy)) != 0) {
if (break_statue(obj))
digtxt = "You cut down the tree.";
*/
digtxt = "\96Ø\82ð\90Ø\82è\93|\82µ\82½\81D";
- lev->typ = ROOM;
+ lev->typ = ROOM, lev->flags = 0;
if (!rn2(5))
(void) rnd_treefruit_at(dpx, dpy);
} else {
digtxt = "You succeed in cutting away some rock.";
*/
digtxt = "\8aâ\82ð\8f\82µ\90Ø\82è\82Æ\82Á\82½\81D";
- lev->typ = CORR;
+ lev->typ = CORR, lev->flags = 0;
}
} else if (IS_WALL(lev->typ)) {
if (shopedge) {
dmgtxt = "\8f\9d\82Â\82¯\82é";
}
if (level.flags.is_maze_lev) {
- lev->typ = ROOM;
+ lev->typ = ROOM, lev->flags = 0;
} else if (level.flags.is_cavernous_lev && !in_town(dpx, dpy)) {
- lev->typ = CORR;
+ lev->typ = CORR, lev->flags = 0;
} else {
- lev->typ = DOOR;
- lev->doormask = D_NODOOR;
+ lev->typ = DOOR, lev->doormask = D_NODOOR;
}
/*JP
digtxt = "You make an opening in the wall.";
if (u.utraptype == TT_BURIEDBALL)
buried_ball_to_punishment();
else if (u.utraptype == TT_INFLOOR)
- u.utrap = 0;
+ reset_utrap(FALSE);
}
/* these furniture checks were in dighole(), but wand
} else if (lev->typ == DRAWBRIDGE_DOWN
|| (is_drawbridge_wall(x, y) >= 0)) {
int bx = x, by = y;
+
/* if under the portcullis, the bridge is adjacent */
(void) find_drawbridge(&bx, &by);
destroy_drawbridge(bx, by);
pay_for_damage("ruin", FALSE);
*/
pay_for_damage("\89ó\82·", FALSE);
- } else if (!madeby_obj && canseemon(madeby))
+ } else if (!madeby_obj && canseemon(madeby)) {
/*JP
pline("%s digs a pit in the %s.", Monnam(madeby), surface_type);
*/
pline("%s\82Í%s\82É\97\8e\82µ\8c\8a\82ð\8c@\82Á\82½\81D", Monnam(madeby), surface_type);
- else if (cansee(x, y) && flags.verbose)
+ } else if (cansee(x, y) && flags.verbose) {
/*JP
pline("A pit appears in the %s.", surface_type);
*/
pline("\97\8e\82µ\8c\8a\82ª%s\82É\8c»\82í\82ê\82½\81D", surface_type);
+ }
+ /* in case we're digging down while encased in solid rock
+ which is blocking levitation or flight */
+ switch_terrain();
+ if (Levitation || Flying)
+ wont_fall = TRUE;
if (at_u) {
if (!wont_fall) {
- u.utrap = rn1(4, 2);
- u.utraptype = TT_PIT;
+ set_utrap(rn1(4, 2), TT_PIT);
vision_full_recalc = 1; /* vision limits change */
} else
- u.utrap = 0;
+ reset_utrap(TRUE);
if (oldobjs != newobjs) /* something unearthed */
(void) pickup(1); /* detects pit */
} else if (mtmp) {
pline("%s\82É\8c\8a\82ª\8c»\82í\82ê\82½\81D", surface_type);
if (at_u) {
+ /* in case we're digging down while encased in solid rock
+ which is blocking levitation or flight */
+ switch_terrain();
+ if (Levitation || Flying)
+ wont_fall = TRUE;
+
+ /* check for leashed pet that can't fall right now */
if (!u.ustuck && !wont_fall && !next_to_u()) {
/*JP
You("are jerked back by your pet!");
}
} else if ((boulder_here = sobj_at(BOULDER, dig_x, dig_y)) != 0) {
- if (ttmp && (ttmp->ttyp == PIT || ttmp->ttyp == SPIKED_PIT)
+ if (ttmp && is_pit(ttmp->ttyp)
&& rn2(2)) {
#if 0 /*JP*/
pline_The("boulder settles into the %spit.",
* fills it. Final outcome: no hole, no boulder.
*/
/*JP
- pline("KADOOM! The boulder falls in!");
+ pline("KADOOM! The boulder falls in!");
*/
pline("\82Ç\82Ç\81[\82ñ\81I\8aâ\82Í\97\8e\82¿\82½\81I");
(void) delfloortrap(ttmp);
} else {
typ = fillholetyp(dig_x, dig_y, FALSE);
+ lev->flags = 0;
if (typ != ROOM) {
lev->typ = typ;
#if 0 /*JP*/
pline("\82±\82Ì\95æ\82Í\96¢\8eg\97p\82Ì\82æ\82¤\82¾\81D\8aï\96\82¾\81D\81D\81D");
break;
}
- levl[dig_x][dig_y].typ = ROOM;
+ levl[dig_x][dig_y].typ = ROOM, levl[dig_x][dig_y].flags = 0;
del_engr_at(dig_x, dig_y);
newsym(dig_x, dig_y);
return;
KILLED_BY);
} else if (u.utrap && u.utraptype == TT_PIT && trap
&& (trap_with_u = t_at(u.ux, u.uy))
- && (trap->ttyp == PIT || trap->ttyp == SPIKED_PIT)
+ && is_pit(trap->ttyp)
&& !conjoined_pits(trap, trap_with_u, FALSE)) {
int idx;
pline("\82 \82È\82½\82Í\97\8e\82µ\8c\8a\82Ì\8aÔ\82©\82ç\82²\82Ý\82ð\8eæ\82è\82Ì\82¼\82¢\82½\81D");
}
} else if (u.utrap && u.utraptype == TT_PIT
- && (trap_with_u = t_at(u.ux, u.uy))) {
+ && (trap_with_u = t_at(u.ux, u.uy)) != 0) {
#if 0 /*JP*/
You("swing %s, but the rubble has no place to go.",
yobjnam(obj, (char *) 0));
newsym(mtmp->mx, mtmp->my);
return FALSE;
} else if (here->typ == SCORR) {
- here->typ = CORR;
+ here->typ = CORR, here->flags = 0;
unblock_point(mtmp->mx, mtmp->my);
newsym(mtmp->mx, mtmp->my);
draft_message(FALSE); /* "You feel a draft." */
if (*in_rooms(mtmp->mx, mtmp->my, SHOPBASE))
add_damage(mtmp->mx, mtmp->my, 0L);
if (level.flags.is_maze_lev) {
- here->typ = ROOM;
+ here->typ = ROOM, here->flags = 0;
} else if (level.flags.is_cavernous_lev
&& !in_town(mtmp->mx, mtmp->my)) {
- here->typ = CORR;
+ here->typ = CORR, here->flags = 0;
} else {
- here->typ = DOOR;
- here->doormask = D_NODOOR;
+ here->typ = DOOR, here->doormask = D_NODOOR;
}
} else if (IS_TREE(here->typ)) {
- here->typ = ROOM;
+ here->typ = ROOM, here->flags = 0;
if (pile && pile < 5)
(void) rnd_treefruit_at(mtmp->mx, mtmp->my);
} else {
- here->typ = CORR;
+ here->typ = CORR, here->flags = 0;
if (pile && pile < 5)
(void) mksobj_at((pile == 1) ? BOULDER : ROCK, mtmp->mx, mtmp->my,
TRUE, FALSE);
struct trap *adjpit = t_at(zx, zy);
if ((diridx < 8) && !conjoined_pits(adjpit, trap_with_u, FALSE)) {
digdepth = 0; /* limited to the adjacent location only */
- if (!(adjpit && (adjpit->ttyp == PIT
- || adjpit->ttyp == SPIKED_PIT))) {
+ if (!(adjpit && is_pit(adjpit->ttyp))) {
char buf[BUFSZ];
cc.x = zx;
cc.y = zy;
}
}
if (adjpit
- && (adjpit->ttyp == PIT || adjpit->ttyp == SPIKED_PIT)) {
+ && is_pit(adjpit->ttyp)) {
int adjidx = (diridx + 4) % 8;
trap_with_u->conjoined |= (1 << diridx);
adjpit->conjoined |= (1 << adjidx);
shopdoor = TRUE;
}
if (room->typ == SDOOR)
- room->typ = DOOR;
+ room->typ = DOOR; /* doormask set below */
else if (cansee(zx, zy))
/*JP
pline_The("door is razed!");
add_damage(zx, zy, SHOP_WALL_COST);
shopwall = TRUE;
}
- room->typ = ROOM;
+ room->typ = ROOM, room->flags = 0;
unblock_point(zx, zy); /* vision */
} else if (!Blind)
/*JP
break;
} else if (IS_TREE(room->typ)) { /* check trees before stone */
if (!(room->wall_info & W_NONDIGGABLE)) {
- room->typ = ROOM;
+ room->typ = ROOM, room->flags = 0;
unblock_point(zx, zy); /* vision */
} else if (!Blind)
/*JP
break;
} else if (room->typ == STONE || room->typ == SCORR) {
if (!(room->wall_info & W_NONDIGGABLE)) {
- room->typ = CORR;
+ room->typ = CORR, room->flags = 0;
unblock_point(zx, zy); /* vision */
} else if (!Blind)
/*JP
}
watch_dig((struct monst *) 0, zx, zy, TRUE);
if (level.flags.is_cavernous_lev && !in_town(zx, zy)) {
- room->typ = CORR;
+ room->typ = CORR, room->flags = 0;
} else {
- room->typ = DOOR;
- room->doormask = D_NODOOR;
+ room->typ = DOOR, room->doormask = D_NODOOR;
}
digdepth -= 2;
} else if (IS_TREE(room->typ)) {
- room->typ = ROOM;
+ room->typ = ROOM, room->flags = 0;
digdepth -= 2;
} else { /* IS_ROCK but not IS_WALL or SDOOR */
- room->typ = CORR;
+ room->typ = CORR, room->flags = 0;
digdepth--;
}
unblock_point(zx, zy); /* vision */
if (pitflow && isok(flow_x, flow_y)) {
struct trap *ttmp = t_at(flow_x, flow_y);
- if (ttmp && (ttmp->ttyp == PIT || ttmp->ttyp == SPIKED_PIT)) {
+
+ if (ttmp && is_pit(ttmp->ttyp)) {
schar filltyp = fillholetyp(ttmp->tx, ttmp->ty, TRUE);
+
if (filltyp != ROOM)
pit_flow(ttmp, filltyp);
}
return FALSE;
*msg = '\0';
room = &levl[cc->x][cc->y];
- ltyp = room->typ;
+ ltyp = room->typ, room->flags = 0;
if (is_pool(cc->x, cc->y) || is_lava(cc->x, cc->y)) {
/* this is handled by the caller after we return FALSE */
struct trap *trap;
schar filltyp;
{
- if (trap && (filltyp != ROOM)
- && (trap->ttyp == PIT || trap->ttyp == SPIKED_PIT)) {
+ if (trap && filltyp != ROOM && is_pit(trap->ttyp)) {
struct trap t;
int idx;
t = *trap;
- levl[trap->tx][trap->ty].typ = filltyp;
- liquid_flow(trap->tx, trap->ty, filltyp, trap,
- (trap->tx == u.ux && trap->ty == u.uy)
+ levl[t.tx][t.ty].typ = filltyp, levl[t.tx][t.ty].flags = 0;
+ liquid_flow(t.tx, t.ty, filltyp, trap,
+ (t.tx == u.ux && t.ty == u.uy)
/*JP
? "Suddenly %s flows in from the adjacent pit!"
*/
(void) stop_timer(RUST_METAL, obj_to_any(ball));
#endif
punish(ball); /* use ball as flag for unearthed buried ball */
- u.utrap = 0;
- u.utraptype = 0;
+ reset_utrap(FALSE);
del_engr_at(cc.x, cc.y);
newsym(cc.x, cc.y);
}
#endif
place_object(ball, cc.x, cc.y);
stackobj(ball);
- u.utrap = 0;
- u.utraptype = 0;
+ reset_utrap(TRUE);
del_engr_at(cc.x, cc.y);
newsym(cc.x, cc.y);
}
You("attempt a teleport spell.");
*/
You("\8fu\8aÔ\88Ú\93®\82ð\8e\8e\82Ý\82½\81D");
- (void) dotele(); /* calls unearth_you() */
+ (void) dotele(FALSE); /* calls unearth_you() */
} else if (u.uburied) { /* still buried after 'port attempt */
boolean good;