From: nethack.allison Date: Sun, 1 Jun 2003 15:54:41 +0000 (+0000) Subject: look vs pickup X-Git-Tag: MOVE2GIT~1943 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f65a13cfbe790fac8d347e83ce4ff9002d98a37b;p=nethack look vs pickup I encountered a look vs pickup cockatrice corpse bug today. If you looked at a location with ':', you would instantly get "Touching the cockatrice corpse is a fatal mistake..." but if you used "m," you got the full list of things at the location to choose from. This patch makes the behaviour consistent and more informative to the player. You now get the partial list of things felt up until the cockatrice corpse is encountered, and then you get the "Touching the cockatrice corpse is a fatal mistake..." Before, the code was never displaying the partially built list because the feel_cockatrice() call was happening before the window display call. --- diff --git a/include/extern.h b/include/extern.h index 995f99b93..23a5d4ffe 100644 --- a/include/extern.h +++ b/include/extern.h @@ -797,6 +797,7 @@ E int NDECL(dotypeinv); E const char *FDECL(dfeature_at, (int,int,char *)); E int FDECL(look_here, (int,BOOLEAN_P)); E int NDECL(dolook); +E boolean FDECL(will_feel_cockatrice, (struct obj *,BOOLEAN_P)); E void FDECL(feel_cockatrice, (struct obj *,BOOLEAN_P)); E void FDECL(stackobj, (struct obj *)); E int NDECL(doprgold); diff --git a/include/hack.h b/include/hack.h index a9e0dc67a..f5277babd 100644 --- a/include/hack.h +++ b/include/hack.h @@ -150,6 +150,7 @@ NEARDATA extern coord bhitpos; /* place where throw or zap hits or stops */ #define USE_INVLET 0x4 /* use object's invlet */ #define INVORDER_SORT 0x8 /* sort objects by packorder */ #define SIGNAL_NOMENU 0x10 /* return -1 rather than 0 if none allowed */ +#define FEEL_COCKATRICE 0x20 /* engage cockatrice checks and react */ /* Flags to control query_category() */ /* BY_NEXTHERE used by query_category() too, so skip 0x01 */ diff --git a/src/invent.c b/src/invent.c index f79494725..2614d68ba 100644 --- a/src/invent.c +++ b/src/invent.c @@ -2158,7 +2158,7 @@ boolean picked_some; const char *dfeature = (char *)0; char fbuf[BUFSZ], fbuf2[BUFSZ]; winid tmpwin; - boolean skip_objects = (obj_cnt >= 5); + boolean skip_objects = (obj_cnt >= 5), felt_cockatrice = FALSE; if (u.uswallow && u.ustuck) { struct monst *mtmp = u.ustuck; @@ -2242,13 +2242,22 @@ boolean picked_some; putstr(tmpwin, 0, fbuf); putstr(tmpwin, 0, ""); } - putstr(tmpwin, 0, "Things that are here:"); + putstr(tmpwin, 0, Blind ? "Things that you feel here:" : + "Things that are here:"); for ( ; otmp; otmp = otmp->nexthere) { + if (otmp->otyp == CORPSE && will_feel_cockatrice(otmp, FALSE)) { + char buf[BUFSZ]; + felt_cockatrice = TRUE; + Strcpy(buf, doname(otmp)); + Strcat(buf, "..."); + putstr(tmpwin, 0, buf); + break; + } putstr(tmpwin, 0, doname(otmp)); - if (otmp->otyp == CORPSE) feel_cockatrice(otmp, FALSE); } display_nhwindow(tmpwin, TRUE); destroy_nhwindow(tmpwin); + if (felt_cockatrice) feel_cockatrice(otmp, FALSE); read_engr_at(u.ux, u.uy); /* Eric Backus */ } return(!!Blind); @@ -2261,6 +2270,17 @@ dolook() return look_here(0, FALSE); } +boolean +will_feel_cockatrice(otmp, force_touch) +struct obj *otmp; +boolean force_touch; +{ + if ((Blind || force_touch) && !uarmg && !Stone_resistance && + (otmp->otyp == CORPSE && touch_petrifies(&mons[otmp->corpsenm]))) + return TRUE; + return FALSE; +} + void feel_cockatrice(otmp, force_touch) struct obj *otmp; @@ -2268,8 +2288,7 @@ boolean force_touch; { char kbuf[BUFSZ]; - if ((Blind || force_touch) && !uarmg && !Stone_resistance && - (otmp->otyp == CORPSE && touch_petrifies(&mons[otmp->corpsenm]))) { + if (will_feel_cockatrice(otmp, force_touch)) { if(poly_when_stoned(youmonst.data)) You("touched the %s corpse with your bare %s.", mons[otmp->corpsenm].mname, makeplural(body_part(HAND))); diff --git a/src/pickup.c b/src/pickup.c index 5664cb11b..407b61ac7 100644 --- a/src/pickup.c +++ b/src/pickup.c @@ -465,8 +465,8 @@ int what; /* should be a long */ pick_list[i].count = count; } else { n = query_objlist("Pick up what?", objchain, - traverse_how|AUTOSELECT_SINGLE|INVORDER_SORT, - &pick_list, PICK_ANY, all_but_uchain); + traverse_how|AUTOSELECT_SINGLE|INVORDER_SORT|FEEL_COCKATRICE, + &pick_list, PICK_ANY, all_but_uchain); } menu_pickup: n_tried = n; @@ -683,7 +683,13 @@ boolean FDECL((*allow), (OBJ_P));/* allow function */ pack = flags.inv_order; do { printed_type_name = FALSE; - for (curr = olist; curr; curr = FOLLOW(curr, qflags)) + for (curr = olist; curr; curr = FOLLOW(curr, qflags)) { + if ((qflags & FEEL_COCKATRICE) && curr->otyp == CORPSE && + will_feel_cockatrice(curr, FALSE)) { + destroy_nhwindow(win); /* stop the menu and revert */ + look_here(0, FALSE); + return 0; + } if ((!(qflags & INVORDER_SORT) || curr->oclass == *pack) && (*allow)(curr)) { @@ -701,6 +707,7 @@ boolean FDECL((*allow), (OBJ_P));/* allow function */ def_oc_syms[(int)objects[curr->otyp].oc_class], ATR_NONE, doname(curr), MENU_UNSELECTED); } + } pack++; } while (qflags & INVORDER_SORT && *pack);