fix #K3231 - objects vs pits and holes

This got out of hand pretty quickly.  can_reach_floor() had
different criteria than trap activation.  Objects dropped at a
hole locations that don't fall through were treated as if they
were at the bottom of an abyss, so couldn't be examined or
picked up.

This a bunch of changes; it is bound to introduce some new bugs.
This commit is contained in:
PatR
2020-12-22 13:48:29 -08:00
parent 934808be0e
commit 1b7c372f5d
7 changed files with 83 additions and 45 deletions

View File

@@ -1,4 +1,4 @@
NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.396 $ $NHDT-Date: 1608335163 2020/12/18 23:46:03 $ NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.399 $ $NHDT-Date: 1608673688 2020/12/22 21:48:08 $
General Fixes and Modified Features General Fixes and Modified Features
----------------------------------- -----------------------------------
@@ -344,6 +344,7 @@ when protection from shape changers begins, force mimic out of concealment
best possible armor class reduced from -127 to -99; worst from +127 to +99; best possible armor class reduced from -127 to -99; worst from +127 to +99;
charged or enchanted individual items also capped at +/- 99 (affects charged or enchanted individual items also capped at +/- 99 (affects
wizard mode wishing, negligible effect on normal play) wizard mode wishing, negligible effect on normal play)
fix several inconsistencies for objects at hole locations
Fixes to 3.7.0-x Problems that Were Exposed Via git Repository Fixes to 3.7.0-x Problems that Were Exposed Via git Repository

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 do.c $NHDT-Date: 1601595709 2020/10/01 23:41:49 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.249 $ */ /* NetHack 3.7 do.c $NHDT-Date: 1608673689 2020/12/22 21:48:09 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.256 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Derek S. Ray, 2015. */ /*-Copyright (c) Derek S. Ray, 2015. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -254,6 +254,8 @@ deletedwithboulder:
pline("%s %s into %s %s.", The(xname(obj)), pline("%s %s into %s %s.", The(xname(obj)),
otense(obj, "tumble"), the_your[t->madeby_u], otense(obj, "tumble"), the_your[t->madeby_u],
is_pit(t->ttyp) ? "pit" : "hole"); is_pit(t->ttyp) ? "pit" : "hole");
if (is_hole(t->ttyp) && ship_object(obj, x, y, FALSE))
return TRUE;
} else if (obj->globby) { } else if (obj->globby) {
/* Globby things like puddings might stick together */ /* Globby things like puddings might stick together */
while (obj && (otmp = obj_nexto_xy(obj, x, y, TRUE)) != 0) { while (obj && (otmp = obj_nexto_xy(obj, x, y, TRUE)) != 0) {
@@ -698,8 +700,6 @@ boolean with_impact;
if (obj == uswapwep) if (obj == uswapwep)
setuswapwep((struct obj *) 0); setuswapwep((struct obj *) 0);
if (!u.uswallow && flooreffects(obj, u.ux, u.uy, "drop"))
return;
if (u.uswallow) { if (u.uswallow) {
/* hero has dropped an item while inside an engulfer */ /* hero has dropped an item while inside an engulfer */
if (obj != uball) { /* mon doesn't pick up ball */ if (obj != uball) { /* mon doesn't pick up ball */
@@ -711,6 +711,8 @@ boolean with_impact;
(void) mpickobj(u.ustuck, obj); (void) mpickobj(u.ustuck, obj);
} }
} else { } else {
if (flooreffects(obj, u.ux, u.uy, "drop"))
return;
place_object(obj, u.ux, u.uy); place_object(obj, u.ux, u.uy);
if (with_impact) if (with_impact)
container_impact_dmg(obj, u.ux, u.uy); container_impact_dmg(obj, u.ux, u.uy);

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 dokick.c $NHDT-Date: 1606343576 2020/11/25 22:32:56 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.160 $ */ /* NetHack 3.7 dokick.c $NHDT-Date: 1608673689 2020/12/22 21:48:09 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.162 $ */
/* Copyright (c) Izchak Miller, Mike Stephenson, Steve Linhart, 1989. */ /* Copyright (c) Izchak Miller, Mike Stephenson, Steve Linhart, 1989. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -1814,23 +1814,22 @@ xchar x, y;
g.gate_str = 0; g.gate_str = 0;
/* this matches the player restriction in goto_level() */ /* this matches the player restriction in goto_level() */
if (on_level(&u.uz, &qstart_level) && !ok_to_quest()) if (on_level(&u.uz, &qstart_level) && !ok_to_quest()) {
return MIGR_NOWHERE; return MIGR_NOWHERE;
}
if (stway && !stway->up && !stway->isladder) { if (stway && !stway->up && !stway->isladder) {
g.gate_str = "down the stairs"; g.gate_str = "down the stairs";
return (stway->tolev.dnum == u.uz.dnum) ? MIGR_STAIRS_UP return (stway->tolev.dnum == u.uz.dnum) ? MIGR_STAIRS_UP
: MIGR_SSTAIRS; : MIGR_SSTAIRS;
} }
if (stway && !stway->up && stway->isladder) { if (stway && !stway->up && stway->isladder) {
g.gate_str = "down the ladder"; g.gate_str = "down the ladder";
return MIGR_LADDER_UP; return MIGR_LADDER_UP;
} }
/* hole will always be flagged as seen; trap drop might or might not */
if (((ttmp = t_at(x, y)) != 0 && ttmp->tseen) if ((ttmp = t_at(x, y)) != 0 && ttmp->tseen && is_hole(ttmp->ttyp)) {
&& is_hole(ttmp->ttyp)) {
g.gate_str = (ttmp->ttyp == TRAPDOOR) ? "through the trap door" g.gate_str = (ttmp->ttyp == TRAPDOOR) ? "through the trap door"
: "through the hole"; : "through the hole";
return MIGR_RANDOM; return MIGR_RANDOM;
} }
return MIGR_NOWHERE; return MIGR_NOWHERE;

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 dothrow.c $NHDT-Date: 1607200366 2020/12/05 20:32:46 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.191 $ */ /* NetHack 3.7 dothrow.c $NHDT-Date: 1608673690 2020/12/22 21:48:10 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.192 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2013. */ /*-Copyright (c) Robert Patrick Rankin, 2013. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -451,11 +451,32 @@ boolean verbosely; /* usually True; False if caller has given drop message */
dropy(obj); dropy(obj);
return; return;
} }
if (IS_ALTAR(levl[u.ux][u.uy].typ)) if (IS_ALTAR(levl[u.ux][u.uy].typ)) {
doaltarobj(obj); doaltarobj(obj);
else if (verbosely) } else if (verbosely) {
pline("%s %s the %s.", Doname2(obj), otense(obj, "hit"), const char *surf = surface(u.ux, u.uy);
surface(u.ux, u.uy)); struct trap *t = t_at(u.ux, u.uy);
/* describe something that might keep the object where it is
or precede next message stating that it falls */
if (t && t->tseen) {
switch (t->ttyp) {
case TRAPDOOR:
surf = "trap door";
break;
case HOLE:
surf = "edge of the hole";
break;
case PIT:
case SPIKED_PIT:
surf = "edge of the pit";
break;
default:
break;
}
}
pline("%s %s the %s.", Doname2(obj), otense(obj, "hit"), surf);
}
if (hero_breaks(obj, u.ux, u.uy, TRUE)) if (hero_breaks(obj, u.ux, u.uy, TRUE))
return; return;

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 engrave.c $NHDT-Date: 1596498167 2020/08/03 23:42:47 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.98 $ */ /* NetHack 3.7 engrave.c $NHDT-Date: 1608673691 2020/12/22 21:48:11 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.99 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2012. */ /*-Copyright (c) Robert Patrick Rankin, 2012. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -146,20 +146,23 @@ boolean check_pit;
{ {
struct trap *t; struct trap *t;
if (u.uswallow) if (u.uswallow || (u.ustuck && !sticks(g.youmonst.data))
|| (Levitation && !(Is_airlevel(&u.uz) || Is_waterlevel(&u.uz))))
return FALSE; return FALSE;
/* Restricted/unskilled riders can't reach the floor */ /* Restricted/unskilled riders can't reach the floor */
if (u.usteed && P_SKILL(P_RIDING) < P_BASIC) if (u.usteed && P_SKILL(P_RIDING) < P_BASIC)
return FALSE; return FALSE;
if (check_pit && !Flying if (u.uundetected && ceiling_hider(g.youmonst.data))
&& (t = t_at(u.ux, u.uy)) != 0 return FALSE;
if (Flying || g.youmonst.data->msize >= MZ_HUGE)
return TRUE;
if (check_pit && (t = t_at(u.ux, u.uy)) != 0
&& (uteetering_at_seen_pit(t) || uescaped_shaft(t))) && (uteetering_at_seen_pit(t) || uescaped_shaft(t)))
return FALSE; return FALSE;
return (boolean) ((!Levitation || Is_airlevel(&u.uz) return TRUE;
|| Is_waterlevel(&u.uz))
&& (!u.uundetected || !is_hider(g.youmonst.data)
|| u.umonnum == PM_TRAPPER));
} }
/* give a message after caller has determined that hero can't reach */ /* give a message after caller has determined that hero can't reach */

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 hack.c $NHDT-Date: 1608335164 2020/12/18 23:46:04 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.273 $ */ /* NetHack 3.7 hack.c $NHDT-Date: 1608673692 2020/12/22 21:48:12 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.274 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Derek S. Ray, 2015. */ /*-Copyright (c) Derek S. Ray, 2015. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -2692,6 +2692,8 @@ boolean newlev;
static int static int
pickup_checks() pickup_checks()
{ {
struct trap *traphere;
/* uswallow case added by GAN 01/29/87 */ /* uswallow case added by GAN 01/29/87 */
if (u.uswallow) { if (u.uswallow) {
if (!u.ustuck->minvent) { if (!u.ustuck->minvent) {
@@ -2707,8 +2709,8 @@ pickup_checks()
} }
} }
if (is_pool(u.ux, u.uy)) { if (is_pool(u.ux, u.uy)) {
if (Wwalking || is_floater(g.youmonst.data) || is_clinger(g.youmonst.data) if (Wwalking || is_floater(g.youmonst.data)
|| (Flying && !Breathless)) { || is_clinger(g.youmonst.data) || (Flying && !Breathless)) {
You("cannot dive into the %s to pick things up.", You("cannot dive into the %s to pick things up.",
hliquid("water")); hliquid("water"));
return 0; return 0;
@@ -2718,8 +2720,8 @@ pickup_checks()
} }
} }
if (is_lava(u.ux, u.uy)) { if (is_lava(u.ux, u.uy)) {
if (Wwalking || is_floater(g.youmonst.data) || is_clinger(g.youmonst.data) if (Wwalking || is_floater(g.youmonst.data)
|| (Flying && !Breathless)) { || is_clinger(g.youmonst.data) || (Flying && !Breathless)) {
You_cant("reach the bottom to pick things up."); You_cant("reach the bottom to pick things up.");
return 0; return 0;
} else if (!likes_lava(g.youmonst.data)) { } else if (!likes_lava(g.youmonst.data)) {
@@ -2749,18 +2751,27 @@ pickup_checks()
There("is nothing here to pick up."); There("is nothing here to pick up.");
return 0; return 0;
} }
if (!can_reach_floor(TRUE)) { traphere = t_at(u.ux, u.uy);
struct trap *traphere = t_at(u.ux, u.uy); if (!can_reach_floor(traphere && is_pit(traphere->ttyp))) {
if (traphere /* it here's a hole here, any objects here clearly aren't at
&& (uteetering_at_seen_pit(traphere) || uescaped_shaft(traphere))) the bottom so only check for pits */
You("cannot reach the bottom of the %s.", if (traphere && uteetering_at_seen_pit(traphere)) {
is_pit(traphere->ttyp) ? "pit" : "abyss"); You("cannot reach the bottom of the pit.");
else if (u.usteed && P_SKILL(P_RIDING) < P_BASIC) } else if (u.usteed && P_SKILL(P_RIDING) < P_BASIC) {
rider_cant_reach(); rider_cant_reach();
else if (Blind && !can_reach_floor(TRUE)) } else if (Blind) {
You("cannot reach anything here."); You("cannot reach anything here.");
else } else {
You("cannot reach the %s.", surface(u.ux, u.uy)); const char *surf = surface(u.ux, u.uy);
if (traphere) {
if (traphere->ttyp == HOLE)
surf = "edge of the hole";
else if (traphere->ttyp == TRAPDOOR)
surf = "trap door";
}
You("cannot reach the %s.", surf);
}
return 0; return 0;
} }
return -1; /* can do normal pickup */ return -1; /* can do normal pickup */

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 pickup.c $NHDT-Date: 1601595711 2020/10/01 23:41:51 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.272 $ */ /* NetHack 3.7 pickup.c $NHDT-Date: 1608673693 2020/12/22 21:48:13 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.273 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2012. */ /*-Copyright (c) Robert Patrick Rankin, 2012. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -598,11 +598,11 @@ int what; /* should be a long */
return 0; return 0;
} }
/* no pickup if levitating & not on air or water level */ /* no pickup if levitating & not on air or water level */
if (!can_reach_floor(TRUE)) { t = t_at(u.ux, u.uy);
if (!can_reach_floor(t && is_pit(t->ttyp))) {
(void) describe_decor(); /* even when !flags.mention_decor */ (void) describe_decor(); /* even when !flags.mention_decor */
if ((g.multi && !g.context.run) || (autopickup && !flags.pickup) if ((g.multi && !g.context.run) || (autopickup && !flags.pickup)
|| ((t = t_at(u.ux, u.uy)) != 0 || (t && (uteetering_at_seen_pit(t) || uescaped_shaft(t))))
&& (uteetering_at_seen_pit(t) || uescaped_shaft(t))))
read_engr_at(u.ux, u.uy); read_engr_at(u.ux, u.uy);
return 0; return 0;
} }
@@ -1780,8 +1780,9 @@ int x, y;
boolean looting; /* loot vs tip */ boolean looting; /* loot vs tip */
{ {
const char *verb = looting ? "loot" : "tip"; const char *verb = looting ? "loot" : "tip";
struct trap *t = t_at(x, y);
if (!can_reach_floor(TRUE)) { if (!can_reach_floor(t && is_pit(t->ttyp))) {
if (u.usteed && P_SKILL(P_RIDING) < P_BASIC) if (u.usteed && P_SKILL(P_RIDING) < P_BASIC)
rider_cant_reach(); /* not skilled enough to reach */ rider_cant_reach(); /* not skilled enough to reach */
else else