E char *FDECL(random_engraving, (char *));
E void FDECL(wipeout_text, (char *,int,unsigned));
-E boolean NDECL(can_reach_floor);
+E boolean FDECL(can_reach_floor, (BOOLEAN_P));
+E void FDECL(cant_reach_floor, (int,int,BOOLEAN_P,BOOLEAN_P));
E const char *FDECL(surface, (int,int));
E const char *FDECL(ceiling, (int,int));
E struct engr *FDECL(engr_at, (XCHAR_P,XCHAR_P));
-/* SCCS Id: @(#)apply.c 3.5 2005/04/13 */
+/* SCCS Id: @(#)apply.c 3.5 2005/06/02 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
struct obj *corpse = sobj_at(CORPSE, rx, ry),
*statue = sobj_at(STATUE, rx, ry);
- if (!can_reach_floor()) { /* levitation or unskilled riding */
+ if (!can_reach_floor(TRUE)) { /* levitation or unskilled riding */
corpse = 0; /* can't reach corpse on floor */
/* you can't reach tiny statues (even though you can fight
tiny monsters while levitating--consistency, what's that?) */
} else if (u.dz) {
if (Underwater)
You_hear("faint splashing.");
- else if (u.dz < 0 || !can_reach_floor())
- You_cant("reach the %s.",
- (u.dz > 0) ? surface(u.ux,u.uy) : ceiling(u.ux,u.uy));
+ else if (u.dz < 0 || !can_reach_floor(TRUE))
+ cant_reach_floor(u.ux, u.uy, (u.dz < 0), TRUE);
else if (its_dead(u.ux, u.uy, &res))
; /* message already given */
else if (Is_stronghold(&u.uz))
-/* SCCS Id: @(#)dig.c 3.5 2005/04/13 */
+/* SCCS Id: @(#)dig.c 3.5 2005/06/02 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
{
register int rx, ry;
register struct rm *lev;
+ struct trap *trap;
int dig_target;
boolean ispick = is_pick(obj);
const char *verbing = ispick ? "digging" : "chopping";
dig_target = dig_typ(obj, rx, ry);
if (dig_target == DIGTYP_UNDIGGABLE) {
/* ACCESSIBLE or POOL */
- struct trap *trap = t_at(rx, ry);
-
+ trap = t_at(rx, ry);
if (trap && trap->ttyp == WEB) {
if (!trap->tseen) {
seetrap(trap);
} else if (Is_airlevel(&u.uz) || Is_waterlevel(&u.uz)) {
/* it must be air -- water checked above */
You("swing %s through thin air.", yobjnam(obj, (char *)0));
- } else if (!can_reach_floor()) {
- You_cant("reach the %s.", surface(u.ux,u.uy));
+ } else if (!can_reach_floor(FALSE)) {
+ cant_reach_floor(u.ux, u.uy, FALSE, FALSE);
} else if (is_pool(u.ux, u.uy) || is_lava(u.ux, u.uy)) {
/* Monsters which swim also happen not to be able to dig */
You("cannot stay under%s long enough.",
is_pool(u.ux, u.uy) ? "water" : " the lava");
+ } else if ((trap = t_at(u.ux, u.uy)) != 0 &&
+ uteetering_at_seen_pit(trap)) {
+ dotrap(trap, FORCEBUNGLE);
+ /* might escape trap and still be teetering at brink */
+ if (!u.utrap) cant_reach_floor(u.ux, u.uy, FALSE, TRUE);
} else if (!ispick) {
pline("%s merely scratches the %s.",
Yobjnam2(obj, (char *)0), surface(u.ux,u.uy));
-/* SCCS Id: @(#)do.c 3.5 2005/03/28 */
+/* SCCS Id: @(#)do.c 3.5 2005/06/02 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
return(1);
}
#endif
- if (!can_reach_floor()) {
+ if (!can_reach_floor(TRUE)) {
if(flags.verbose) You("drop %s.", doname(obj));
#ifndef GOLDOBJ
if (obj->oclass != COIN_CLASS || obj == invent) freeinv(obj);
-/* SCCS Id: @(#)eat.c 3.5 2005/04/08 */
+/* SCCS Id: @(#)eat.c 3.5 2005/06/02 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
boolean feeding = (!strcmp(verb, "eat"));
/* if we can't touch floor objects then use invent food only */
- if (!can_reach_floor() ||
+ if (!can_reach_floor(TRUE) ||
#ifdef STEED
(feeding && u.usteed) || /* can't eat off floor while riding */
#endif
-/* SCCS Id: @(#)engrave.c 3.5 2005/04/22 */
+/* SCCS Id: @(#)engrave.c 3.5 2005/06/02 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
while (lth && engr[lth-1] == ' ') engr[--lth] = 0;
}
+/* check whether hero can reach something at ground level */
boolean
-can_reach_floor()
+can_reach_floor(check_pit)
+boolean check_pit;
{
struct trap *t;
/* Restricted/unskilled riders can't reach the floor */
if (u.usteed && P_SKILL(P_RIDING) < P_BASIC) return FALSE;
#endif
- if ((t = t_at(u.ux, u.uy)) != 0 && uteetering_at_seen_pit(t) &&
- !Flying)
+ if (check_pit && (t = t_at(u.ux, u.uy)) != 0 &&
+ uteetering_at_seen_pit(t) && !Flying)
return FALSE;
return (boolean)((!Levitation ||
u.umonnum == PM_TRAPPER));
}
+/* give a message after caller has determined that hero can't reach */
+void
+cant_reach_floor(x, y, up, check_pit)
+int x, y;
+boolean up, check_pit;
+{
+ You("can't reach the %s.",
+ up ? ceiling(x, y) :
+ (check_pit && can_reach_floor(FALSE)) ? "bottom of the pit" :
+ surface(x, y));
+}
+
const char *
surface(x, y)
register int x, y;
u_wipe_engr(cnt)
register int cnt;
{
- if (can_reach_floor())
+ if (can_reach_floor(TRUE))
wipe_engr_at(u.ux, u.uy, cnt);
}
break;
case ENGRAVE:
case HEADSTONE:
- if (!Blind || can_reach_floor()) {
+ if (!Blind || can_reach_floor(TRUE)) {
sensed = 1;
pline("%s is engraved here on the %s.",
Something,
}
break;
case BURN:
- if (!Blind || can_reach_floor()) {
+ if (!Blind || can_reach_floor(TRUE)) {
sensed = 1;
pline("Some text has been %s into the %s here.",
is_ice(x,y) ? "melted" : "burned",
pline("What would you write? \"Jonah was here\"?");
return(0);
} else if (is_whirly(u.ustuck->data)) {
- You_cant("reach the %s.", surface(u.ux,u.uy));
+ cant_reach_floor(u.ux, u.uy, FALSE, FALSE);
return(0);
} else
jello = TRUE;
Your("message dissolves...");
return(0);
}
- if (otmp->oclass != WAND_CLASS && !can_reach_floor()) {
- You_cant("reach the %s!", surface(u.ux,u.uy));
+ if (otmp->oclass != WAND_CLASS && !can_reach_floor(TRUE)) {
+ cant_reach_floor(u.ux, u.uy, FALSE, TRUE);
return(0);
}
if (IS_ALTAR(levl[u.ux][u.uy].typ)) {
/* type = ENGR_BLOOD wands */
}
} else /* end if zappable */
- if (!can_reach_floor()) {
- You_cant("reach the %s!", surface(u.ux,u.uy));
+ if (!can_reach_floor(TRUE)) {
+ cant_reach_floor(u.ux, u.uy, FALSE, TRUE);
return(0);
}
break;
}
if (!ptext) { /* Early exit for some implements. */
- if (otmp->oclass == WAND_CLASS && !can_reach_floor())
- You_cant("reach the %s!", surface(u.ux,u.uy));
+ if (otmp->oclass == WAND_CLASS && !can_reach_floor(TRUE))
+ cant_reach_floor(u.ux, u.uy, FALSE, TRUE);
return(1);
}
return(1);
} else
if ( (type != oep->engr_type) || (c == 'n') ) {
- if (!Blind || can_reach_floor())
+ if (!Blind || can_reach_floor(TRUE))
You("will overwrite the current message.");
eow = TRUE;
}
-/* SCCS Id: @(#)hack.c 3.5 2004/11/11 */
+/* SCCS Id: @(#)hack.c 3.5 2005/06/02 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
There("is nothing here to pick up.");
return 0;
}
- if (!can_reach_floor()) {
+ if (!can_reach_floor(TRUE)) {
if (traphere && uteetering_at_seen_pit(traphere))
You("cannot reach the bottom of the pit.");
#ifdef STEED
-/* SCCS Id: @(#)invent.c 3.5 2005/04/06 */
+/* SCCS Id: @(#)invent.c 3.5 2005/06/02 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
}
if (dfeature && !drift && !strcmp(dfeature, surface(u.ux,u.uy)))
dfeature = 0; /* ice already identifed */
- if (!can_reach_floor()) {
+ if (!can_reach_floor(TRUE)) {
pline("But you can't reach it!");
return(0);
}
-/* SCCS Id: @(#)lock.c 3.5 2000/02/06 */
+/* SCCS Id: @(#)lock.c 3.5 2005/06/02 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
pline(no_longer, "hold the", what);
reset_pick();
return 0;
- } else if (xlock.box && !can_reach_floor()) {
+ } else if (xlock.box && !can_reach_floor(TRUE)) {
pline(no_longer, "reach the", "lock");
reset_pick();
return 0;
for(otmp = level.objects[cc.x][cc.y]; otmp; otmp = otmp->nexthere)
if (Is_box(otmp)) {
++count;
- if (!can_reach_floor()) {
+ if (!can_reach_floor(TRUE)) {
You_cant("reach %s from up here.", the(xname(otmp)));
return 0;
}
-/* SCCS Id: @(#)pickup.c 3.5 2005/04/06 */
+/* SCCS Id: @(#)pickup.c 3.5 2005/06/02 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
}
/* no pickup if levitating & not on air or water level */
- if (!can_reach_floor()) {
+ if (!can_reach_floor(TRUE)) {
if ((multi && !context.run) ||
(autopickup && !flags.pickup) ||
(ttmp && uteetering_at_seen_pit(ttmp)))
{
const char *verb = looting ? "loot" : "tip";
- if (!can_reach_floor()) {
+ if (!can_reach_floor(TRUE)) {
#ifdef STEED
if (u.usteed && P_SKILL(P_RIDING) < P_BASIC)
rider_cant_reach(); /* not skilled enough to reach */
else
#endif
- You("cannot reach the %s.", surface(x, y));
+ cant_reach_floor(x, y, FALSE, TRUE);
return FALSE;
} else if ((is_pool(x, y) && (looting || !Underwater)) ||
is_lava(x, y)) {
if (empty_it) {
struct obj *otmp, *nobj;
boolean verbose = FALSE,
- highdrop = !can_reach_floor(),
+ highdrop = !can_reach_floor(TRUE),
altarizing = IS_ALTAR(levl[u.ux][u.uy].typ),
cursed_mbag = (Is_mbag(box) && box->cursed);
int held = carried(box);
-/* SCCS Id: @(#)potion.c 3.5 2005/04/23 */
+/* SCCS Id: @(#)potion.c 3.5 2005/06/02 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
return 0;
}
/* Is there a fountain to drink from here? */
- if (IS_FOUNTAIN(levl[u.ux][u.uy].typ) && can_reach_floor()) {
+ if (IS_FOUNTAIN(levl[u.ux][u.uy].typ) &&
+ /* not as low as floor level but similar restrictions apply */
+ can_reach_floor(FALSE)) {
if(yn("Drink from the fountain?") == 'y') {
drinkfountain();
return 1;
}
#ifdef SINKS
/* Or a kitchen sink? */
- if (IS_SINK(levl[u.ux][u.uy].typ) && can_reach_floor()) {
+ if (IS_SINK(levl[u.ux][u.uy].typ) &&
+ /* not as low as floor level but similar restrictions apply */
+ can_reach_floor(FALSE)) {
if (yn("Drink from the sink?") == 'y') {
drinksink();
return 1;
-/* SCCS Id: @(#)sit.c 3.5 2004/12/21 */
+/* SCCS Id: @(#)sit.c 3.5 2005/06/02 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
if (u.uundetected && is_hider(youmonst.data) && u.umonnum != PM_TRAPPER)
u.uundetected = 0; /* no longer on the ceiling */
- if (!can_reach_floor()) {
+ if (!can_reach_floor(FALSE)) {
if (Levitation)
You("tumble in place.");
else
if (!(Is_box(obj) || objects[obj->otyp].oc_material == CLOTH))
pline("It's not very comfortable...");
- } else if (trap != 0 ||
- (u.utrap && (u.utraptype >= TT_LAVA))) {
-
+ } else if (trap != 0 || (u.utrap && (u.utraptype >= TT_LAVA))) {
if (u.utrap) {
exercise(A_WIS, FALSE); /* you're getting stuck longer */
- if(u.utraptype == TT_BEARTRAP) {
- You_cant("sit down with your %s in the bear trap.", body_part(FOOT));
+ if (u.utraptype == TT_BEARTRAP) {
+ You_cant("sit down with your %s in the bear trap.",
+ body_part(FOOT));
u.utrap++;
- } else if(u.utraptype == TT_PIT) {
- if(trap && trap->ttyp == SPIKED_PIT) {
+ } else if (u.utraptype == TT_PIT) {
+ if (trap && trap->ttyp == SPIKED_PIT) {
You("sit down on a spike. Ouch!");
losehp(Half_physical_damage ? rn2(2) : 1,
"sitting on an iron spike", KILLED_BY);
} else
You("sit down in the pit.");
u.utrap += rn2(5);
- } else if(u.utraptype == TT_WEB) {
+ } else if (u.utraptype == TT_WEB) {
You("sit in the spider web and get entangled further!");
u.utrap += rn1(10, 5);
- } else if(u.utraptype == TT_LAVA) {
+ } else if (u.utraptype == TT_LAVA) {
/* Must have fire resistance or they'd be dead already */
You("sit in the lava!");
u.utrap += rnd(4);
losehp(d(2,10), "sitting in lava", KILLED_BY); /* lava damage */
- } else if(u.utraptype == TT_INFLOOR || u.utraptype == TT_BURIEDBALL) {
+ } else if (u.utraptype == TT_INFLOOR ||
+ u.utraptype == TT_BURIEDBALL) {
You_cant("maneuver to sit!");
u.utrap++;
}
} else {
- You("sit down.");
+ You("sit down.");
dotrap(trap, 0);
}
} else if(Underwater || Is_waterlevel(&u.uz)) {
-/* SCCS Id: @(#)trap.c 3.5 2005/04/13 */
+/* SCCS Id: @(#)trap.c 3.5 2005/06/02 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
}
}
/* untrappable traps are located on the ground. */
- if (!can_reach_floor()) {
+ if (!can_reach_floor(TRUE)) {
#ifdef STEED
if (u.usteed && P_SKILL(P_RIDING) < P_BASIC)
You("aren't skilled enough to reach from %s.",