From c0bcc8d292dd9f7319e95cb1b0816f83f3bcbbb7 Mon Sep 17 00:00:00 2001 From: "nethack.allison" Date: Wed, 10 Jul 2002 12:32:03 +0000 Subject: [PATCH] modify #untrap prompting further > The intention is, I believe, to cater for the situation where you, a > chest, and a dungeon-trap are all on the same square; previously > (C340-71), you wouldn't have been able to check the chest for traps > because an #untrap in direction '.' would always have tried to disarm > the dungeon trap. However, since you can't trap-check containers on > adjacent squares, it'd wouldn't hurt if the question was dispensed > with when you specify a direction that isn't your square. > > (Note that "you cannot deal with traps while trapped!", so there's > still several situations when you can't trap-check a chest on a > trap-square, even though you can loot it, until you've untrapped > yourself; is this really consistent? Should the if(u.utrap) check > be moved to the "case y:" branch of the switch?) --- src/trap.c | 40 +++++++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/src/trap.c b/src/trap.c index 36e13349b..bfd5ed57a 100644 --- a/src/trap.c +++ b/src/trap.c @@ -3127,22 +3127,44 @@ boolean force; struct trap *ttmp; struct monst *mtmp; boolean trap_skipped = FALSE; + boolean box_here = FALSE; + boolean deal_with_floor_trap = FALSE; + char the_trap[BUFSZ], qbuf[QBUFSZ]; + int containercnt = 0; if(!getdir((char *)0)) return(0); x = u.ux + u.dx; y = u.uy + u.dy; - if ((ttmp = t_at(x,y)) && ttmp->tseen) { - if (u.utrap) { - You("cannot deal with traps while trapped!"); - return 1; + for(otmp = level.objects[x][y]; otmp; otmp = otmp->nexthere) { + if(Is_box(otmp) && !u.dx && !u.dy) { + box_here = TRUE; + containercnt++; + if (containercnt > 1) break; } - There("is %s here.", an(defsyms[trap_to_defsym(ttmp->ttyp)].explanation)); + } - switch (ynq(ttmp->ttyp == WEB ? "Remove it?" : "Disarm it?")) { - case 'q': return(0); - case 'n': trap_skipped = TRUE; break; - case 'y': + if ((ttmp = t_at(x,y)) && ttmp->tseen) { + deal_with_floor_trap = TRUE; + Strcpy(the_trap, the(defsyms[trap_to_defsym(ttmp->ttyp)].explanation)); + if (box_here) { + Sprintf(qbuf, "There %s and %s here. %s %s?", + (containercnt == 1) ? "is a container" : "are containers", + an(defsyms[trap_to_defsym(ttmp->ttyp)].explanation), + ttmp->ttyp == WEB ? "Remove" : "Disarm", the_trap); + switch (ynq(qbuf)) { + case 'q': return(0); + case 'n': trap_skipped = TRUE; + deal_with_floor_trap = FALSE; + break; + } + } + if (deal_with_floor_trap) { + if (u.utrap) { + You("cannot deal with %s while trapped%s!", the_trap, + (x == u.ux && y == u.uy) ? " in it" : ""); + return 1; + } switch(ttmp->ttyp) { case BEAR_TRAP: case WEB: