-/* 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. */
/* JNetHack Copyright */
/* (c) Issei Numata, Naoki Hamada, Shigehiro Miyashita, 1994-2000 */
-/* For 3.4-, Copyright (c) SHIRAKATA Kentaro, 2002-2016 */
+/* For 3.4-, Copyright (c) SHIRAKATA Kentaro, 2002-2023 */
/* JNetHack may be freely redistributed. See license for details. */
#include "hack.h"
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);
*/
pline("\82°\82°\82ñ\81I\82 \82È\82½\82Ì\82Ü\82í\82è\82Ì\93V\88ä\82ª\95ö\82ê\82½\81I");
else
-#if 0 /*JP*/
+#if 0 /*JP:T*/
pline("A mysterious force %s cave around you!",
(levl[u.ux][u.uy].typ == CORR) ? "creates a" : "extends the");
#else
}
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 (IS_ROCK(lev->typ) && !may_dig(dpx, dpy)
&& dig_typ(uwep, dpx, dpy) == DIGTYP_ROCK) {
-#if 0 /*JP*/
+#if 0 /*JP:T*/
pline("This %s is too hard to %s.",
is_db_wall(dpx, dpy) ? "drawbridge" : "wall", verb);
#else
}
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))) {
You("hit yourself in the %s.", body_part(FOOT));
*/
pline("%s\82É\93\96\82½\82Á\82½\81D", body_part(FOOT));
-#if 0 /*JP*/
+#if 0 /*JP:T*/
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 {
-#if 0 /*JP*/
+#if 0 /*JP:T*/
You("destroy the bear trap with %s.",
yobjnam(uwep, (const char *) 0));
#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) {
if (is_flyer(mtmp->data) || is_floater(mtmp->data)) {
if (canseemon(mtmp))
-#if 0 /*JP*/
+#if 0 /*JP:T*/
pline("%s %s over the pit.", Monnam(mtmp),
(is_flyer(mtmp->data)) ? "flies" : "floats");
#else
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*/
+#if 0 /*JP:T*/
pline_The("boulder settles into the %spit.",
(dig_x != u.ux || dig_y != u.uy) ? "adjacent " : "");
#else
* 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);
* We can't dig a hole here since that will destroy
* the drawbridge. The following is a cop-out. --dlc
*/
-#if 0 /*JP*/
+#if 0 /*JP:T*/
pline_The("%s %shere is too hard to dig in.",
surface(dig_x, dig_y),
(dig_x != u.ux || dig_y != u.uy) ? "t" : "");
} else {
typ = fillholetyp(dig_x, dig_y, FALSE);
+ lev->flags = 0;
if (typ != ROOM) {
lev->typ = typ;
-#if 0 /*JP*/
+#if 0 /*JP:T*/
liquid_flow(dig_x, dig_y, typ, ttmp,
"As you dig, the hole fills with %s!");
#else
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;
!res ? "Unfortunately," : "But", verb);
#else
pline("%s\82\82à\82Ì\91\83\82É\82Ð\82Á\82©\82©\82Á\82Ä\82¢\82é\8aÔ\82Í%s\81D",
- !res ? "\8ec\94O\82È\82ª\82ç" : "\82µ\82©\82µ", jconj(verb, "\82È\82¢"));
+ !res ? "\8ec\94O\82È\82ª\82ç" : "\82µ\82©\82µ", jcannot(verb));
#endif
return res;
}
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))) {
-#if 0 /*JP*/
+ && (trap_with_u = t_at(u.ux, u.uy)) != 0) {
+#if 0 /*JP:T*/
You("swing %s, but the rubble has no place to go.",
yobjnam(obj, (char *) 0));
#else
is_pool(u.ux, u.uy) ? "\90\85\96Ê\89º" : "\97n\8aâ\82Ì\92\86");
#endif
} else if ((trap = t_at(u.ux, u.uy)) != 0
- && uteetering_at_seen_pit(trap)) {
+ && (uteetering_at_seen_pit(trap) || uescaped_shaft(trap))) {
dotrap(trap, FORCEBUNGLE);
/* might escape trap and still be teetering at brink */
if (!u.utrap)
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);
if (!is_whirly(mtmp->data)) {
if (is_animal(mtmp->data))
-#if 0 /*JP*/
+#if 0 /*JP:T*/
You("pierce %s %s wall!", s_suffix(mon_nam(mtmp)),
mbodypart(mtmp, STOMACH));
#else
if (u.dz < 0 || On_stairs(u.ux, u.uy)) {
int dmg;
if (On_stairs(u.ux, u.uy))
-#if 0 /*JP*/
+#if 0 /*JP:T*/
pline_The("beam bounces off the %s and hits the %s.",
(u.ux == xdnladder || u.ux == xupladder)
? "ladder"
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);
}
struct rm *room;
const char *foundation_msg =
/*JP
- "The foundation is too hard to dig through from this angle.";
+ "The foundation is too hard to dig through from this angle.";
*/
- "\8aî\91b\82Í\82±\82Ì\8ap\93x\82©\82ç\8c@\82é\82É\82Í\8cÅ\82·\82¬\82é\81D";
+ "\8aî\91b\82Í\82±\82Ì\8ap\93x\82©\82ç\8c@\82é\82É\82Í\8cÅ\82·\82¬\82é\81D";
if (!cc)
return FALSE;
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 */
supporting = "\92µ\82Ë\8b´";
if (supporting) {
-#if 0 /*JP*/
+#if 0 /*JP:T*/
Sprintf(msg, "The %s%ssupporting structures remain intact.",
supporting ? s_suffix(supporting) : "",
supporting ? " " : "");
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);
}
newsym(x, y);
if (costly && loss) {
-#if 0 /*JP*/
+#if 0 /*JP:T*/
You("owe %s %ld %s for burying merchandise.", mon_nam(shkp), loss,
currency(loss));
#else
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;
|| (unsolid(youmonst.data)
&& youmonst.data != &mons[PM_WATER_ELEMENTAL])
|| (tunnels(youmonst.data) && !needspick(youmonst.data))) {
-#if 0 /*JP*/
+#if 0 /*JP:T*/
You("%s up through the %s.",
(tunnels(youmonst.data) && !needspick(youmonst.data))
? "try to tunnel"