1 /* NetHack 3.6 pickup.c $NHDT-Date: 1545785547 2018/12/26 00:52:27 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.222 $ */
2 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3 /*-Copyright (c) Robert Patrick Rankin, 2012. */
4 /* NetHack may be freely redistributed. See license for details. */
6 /* JNetHack Copyright */
7 /* (c) Issei Numata, Naoki Hamada, Shigehiro Miyashita, 1994-2000 */
8 /* For 3.4-, Copyright (c) SHIRAKATA Kentaro, 2002-2019 */
9 /* JNetHack may be freely redistributed. See license for details. */
12 * Contains code for picking objects up, and container use.
17 #define CONTAINED_SYM '>' /* from invent.c */
19 STATIC_DCL void FDECL(simple_look, (struct obj *, BOOLEAN_P));
20 STATIC_DCL boolean FDECL(query_classes, (char *, boolean *, boolean *,
21 const char *, struct obj *,
23 STATIC_DCL boolean FDECL(fatal_corpse_mistake, (struct obj *, BOOLEAN_P));
24 STATIC_DCL void FDECL(check_here, (BOOLEAN_P));
25 STATIC_DCL boolean FDECL(n_or_more, (struct obj *));
26 STATIC_DCL boolean FDECL(all_but_uchain, (struct obj *));
28 STATIC_DCL boolean FDECL(allow_cat_no_uchain, (struct obj *));
30 STATIC_DCL int FDECL(autopick, (struct obj *, int, menu_item **));
31 STATIC_DCL int FDECL(count_categories, (struct obj *, int));
32 STATIC_DCL int FDECL(delta_cwt, (struct obj *, struct obj *));
33 STATIC_DCL long FDECL(carry_count, (struct obj *, struct obj *, long,
34 BOOLEAN_P, int *, int *));
35 STATIC_DCL int FDECL(lift_object, (struct obj *, struct obj *, long *,
37 STATIC_DCL boolean FDECL(mbag_explodes, (struct obj *, int));
38 STATIC_DCL long FDECL(boh_loss, (struct obj *container, int));
39 STATIC_PTR int FDECL(in_container, (struct obj *));
40 STATIC_PTR int FDECL(out_container, (struct obj *));
41 STATIC_DCL void FDECL(removed_from_icebox, (struct obj *));
42 STATIC_DCL long FDECL(mbag_item_gone, (int, struct obj *));
43 STATIC_DCL void FDECL(explain_container_prompt, (BOOLEAN_P));
44 STATIC_DCL int FDECL(traditional_loot, (BOOLEAN_P));
45 STATIC_DCL int FDECL(menu_loot, (int, BOOLEAN_P));
46 STATIC_DCL char FDECL(in_or_out_menu, (const char *, struct obj *, BOOLEAN_P,
47 BOOLEAN_P, BOOLEAN_P, BOOLEAN_P));
48 STATIC_DCL boolean FDECL(able_to_loot, (int, int, BOOLEAN_P));
49 STATIC_DCL boolean NDECL(reverse_loot);
50 STATIC_DCL boolean FDECL(mon_beside, (int, int));
51 STATIC_DCL int FDECL(do_loot_cont, (struct obj **, int, int));
52 STATIC_DCL void FDECL(tipcontainer, (struct obj *));
54 /* define for query_objlist() and autopickup() */
55 #define FOLLOW(curr, flags) \
56 (((flags) & BY_NEXTHERE) ? (curr)->nexthere : (curr)->nobj)
58 #define GOLD_WT(n) (((n) + 50L) / 100L)
59 /* if you can figure this out, give yourself a hearty pat on the back... */
60 #define GOLD_CAPACITY(w, n) (((w) * -100L) - ((n) + 50L) - 1L)
62 /* A variable set in use_container(), to be used by the callback routines
63 in_container() and out_container() from askchain() and use_container().
64 Also used by menu_loot() and container_gone(). */
65 static NEARDATA struct obj *current_container;
66 static NEARDATA boolean abort_looting;
67 #define Icebox (current_container->otyp == ICE_BOX)
71 moderateloadmsg[] = "You have a little trouble lifting",
73 moderateloadmsg[] = "
\82ð
\8e\9d\82Á
\82½
\82ç
\8f
\82µ
\82Ó
\82ç
\82Â
\82¢
\82½",
75 nearloadmsg[] = "You have much trouble lifting",
77 nearloadmsg[] = "
\82Í
\82¸
\82Á
\82µ
\82è
\82Æ
\8c¨
\82É
\82Ì
\82µ
\82©
\82©
\82Á
\82½",
79 overloadmsg[] = "You have extreme difficulty lifting";
81 overloadmsg[] = "
\82ð
\8e\9d\82¿
\82 \82°
\82é
\82Ì
\82Í
\82Æ
\82Ä
\82à
\82Â
\82ç
\82¢";
83 /* BUG: this lets you look at cockatrice corpses while blind without
85 /* much simpler version of the look-here code; used by query_classes() */
87 simple_look(otmp, here)
88 struct obj *otmp; /* list of objects */
89 boolean here; /* flag for type of obj list linkage */
91 /* Neither of the first two cases is expected to happen, since
92 * we're only called after multiple classes of objects have been
93 * detected, hence multiple objects must be present.
96 impossible("simple_look(null)");
97 } else if (!(here ? otmp->nexthere : otmp->nobj)) {
100 winid tmpwin = create_nhwindow(NHW_MENU);
102 putstr(tmpwin, 0, "");
104 putstr(tmpwin, 0, doname(otmp));
105 otmp = here ? otmp->nexthere : otmp->nobj;
107 display_nhwindow(tmpwin, TRUE);
108 destroy_nhwindow(tmpwin);
113 collect_obj_classes(ilets, otmp, here, filter, itemcount)
115 register struct obj *otmp;
117 boolean FDECL((*filter), (OBJ_P));
120 register int iletct = 0;
124 ilets[iletct] = '\0'; /* terminate ilets so that index() will work */
126 c = def_oc_syms[(int) otmp->oclass].sym;
127 if (!index(ilets, c) && (!filter || (*filter)(otmp)))
128 ilets[iletct++] = c, ilets[iletct] = '\0';
130 otmp = here ? otmp->nexthere : otmp->nobj;
137 * Suppose some '?' and '!' objects are present, but '/' objects aren't:
138 * "a" picks all items without further prompting;
139 * "A" steps through all items, asking one by one;
140 * "?" steps through '?' items, asking, and ignores '!' ones;
141 * "/" becomes 'A', since no '/' present;
142 * "?a" or "a?" picks all '?' without further prompting;
143 * "/a" or "a/" becomes 'A' since there aren't any '/'
144 * (bug fix: 3.1.0 thru 3.1.3 treated it as "a");
145 * "?/a" or "a?/" or "/a?",&c picks all '?' even though no '/'
146 * (ie, treated as if it had just been "?a").
148 /*JP CHECK: 3.4.3
\82Å
\82Ì
\8cÄ
\82Ñ
\8fo
\82µ
\8c³
149 pickup.c:572:("
\8fE
\82¤") if (!query_classes(oclasses, &selective, &all_of_a_type,
150 pickup.c:2604:("
\8eæ
\82è
\8fo
\82·") if (query_classes(select, &one_by_one, &allflag,
151 pickup.c:2704:("
\93ü
\82ê
\82é") if (query_classes(select, &one_by_one, &allflag, "
\93ü
\82ê
\82é",
154 query_classes(oclasses, one_at_a_time, everything, action, objs, here,
157 boolean *one_at_a_time, *everything;
163 char ilets[36], inbuf[BUFSZ] = DUMMY; /* FIXME: hardcoded ilets[] length */
164 int iletct, oclassct;
165 boolean not_everything, filtered;
168 int itemcount, bcnt, ucnt, ccnt, xcnt, ocnt;
170 oclasses[oclassct = 0] = '\0';
171 *one_at_a_time = *everything = m_seen = FALSE;
174 iletct = collect_obj_classes(ilets, objs, here,
175 (boolean FDECL((*), (OBJ_P))) 0, &itemcount);
180 oclasses[0] = def_char_to_objclass(ilets[0]);
182 } else { /* more than one choice available */
183 /* additional choices */
184 ilets[iletct++] = ' ';
185 ilets[iletct++] = 'a';
186 ilets[iletct++] = 'A';
187 ilets[iletct++] = (objs == invent ? 'i' : ':');
189 if (itemcount && menu_on_demand)
190 ilets[iletct++] = 'm';
191 if (count_unpaid(objs))
192 ilets[iletct++] = 'u';
194 tally_BUCX(objs, here, &bcnt, &ucnt, &ccnt, &xcnt, &ocnt);
196 ilets[iletct++] = 'B';
198 ilets[iletct++] = 'U';
200 ilets[iletct++] = 'C';
202 ilets[iletct++] = 'X';
203 ilets[iletct] = '\0';
206 const char *where = 0;
207 char sym, oc_of_sym, *p;
210 oclasses[oclassct = 0] = '\0';
211 *one_at_a_time = *everything = FALSE;
212 not_everything = filtered = FALSE;
214 Sprintf(qbuf, "What kinds of thing do you want to %s? [%s]", action,
217 Sprintf(qbuf,"
\82Ç
\82Ì
\8eí
\97Þ
\82Ì
\82à
\82Ì
\82ð%s
\82©
\81H[%s]", jpolite(action),
221 if (*inbuf == '\033')
224 for (p = inbuf; (sym = *p++) != 0; ) {
228 *one_at_a_time = TRUE;
231 else if (sym == ':') {
232 simple_look(objs, here); /* dumb if objs==invent */
233 /* if we just scanned the contents of a container
234 then mark it as having known contents */
235 if (objs->where == OBJ_CONTAINED)
236 objs->ocontainer->cknown = 1;
238 } else if (sym == 'i') {
239 (void) display_inventory((char *) 0, TRUE);
241 } else if (sym == 'm') {
243 } else if (index("uBUCX", sym)) {
244 add_valid_menu_class(sym); /* 'u' or 'B','U','C',or 'X' */
247 oc_of_sym = def_char_to_objclass(sym);
248 if (index(ilets, sym)) {
249 add_valid_menu_class(oc_of_sym);
250 oclasses[oclassct++] = oc_of_sym;
251 oclasses[oclassct] = '\0';
255 where = !strcmp(action, "pick up") ? "here"
257 where = !strcmp(action, "
\8fE
\82¤") ? "
\82±
\82±"
259 : !strcmp(action, "take out") ? "inside" : "";
261 : !strcmp(action, "
\8eæ
\82è
\8fo
\82·") ? "
\82Ì
\92\86" : "";
264 There("are no %c's %s.", sym, where);
266 pline("%c
\82Í%s
\82É
\82È
\82¢
\81D", sym, where);
269 You("have no %c's.", sym);
271 You("%c
\82Í
\8e\9d\82Á
\82Ä
\82¢
\82È
\82¢
\81D", sym);
272 not_everything = TRUE;
275 } /* for p:sym in inbuf */
277 if (m_seen && menu_on_demand) {
278 *menu_on_demand = (((*everything || !oclassct) && !filtered)
282 if (!oclassct && (!*everything || not_everything)) {
283 /* didn't pick anything,
284 or tried to pick something that's not present */
285 *one_at_a_time = TRUE; /* force 'A' */
286 *everything = FALSE; /* inhibit 'a' */
292 /* check whether hero is bare-handedly touching a cockatrice corpse */
294 fatal_corpse_mistake(obj, remotely)
298 if (uarmg || remotely || obj->otyp != CORPSE
299 || !touch_petrifies(&mons[obj->corpsenm]) || Stone_resistance)
302 if (poly_when_stoned(youmonst.data) && polymon(PM_STONE_GOLEM)) {
303 display_nhwindow(WIN_MESSAGE, FALSE); /* --More-- */
308 pline("Touching %s is a fatal mistake.",
310 pline("%s
\82É
\90G
\82ê
\82é
\82Ì
\82Í
\92v
\96½
\93I
\82È
\8aÔ
\88á
\82¢
\82¾
\81D",
311 corpse_xname(obj, (const char *) 0, CXN_SINGULAR | CXN_ARTICLE));
312 instapetrify(killer_xname(obj));
316 /* attempting to manipulate a Rider's corpse triggers its revival */
318 rider_corpse_revival(obj, remotely)
322 if (!obj || obj->otyp != CORPSE || !is_rider(&mons[obj->corpsenm]))
326 pline("At your %s, the corpse suddenly moves...",
328 pline("
\82 \82È
\82½
\82ª%s
\82é
\82Æ
\93Ë
\91R
\8e\80\91Ì
\82ª
\93®
\82«
\8fo
\82µ
\82½
\81D
\81D
\81D",
330 remotely ? "attempted acquisition" : "touch");
332 remotely ? "
\8al
\93¾
\82µ
\82æ
\82¤
\82Æ
\82·" : "
\90G");
333 (void) revive_corpse(obj);
334 exercise(A_WIS, FALSE);
338 /* look at the objects at our location, unless there are too many of them */
340 check_here(picked_some)
343 register struct obj *obj;
346 /* count the objects here */
347 for (obj = level.objects[u.ux][u.uy]; obj; obj = obj->nexthere) {
352 /* If there are objects here, take a look. */
357 (void) look_here(ct, picked_some);
359 read_engr_at(u.ux, u.uy);
363 /* Value set by query_objlist() for n_or_more(). */
364 static long val_for_n_or_more;
366 /* query_objlist callback: return TRUE if obj's count is >= reference value */
373 return (boolean) (obj->quan >= val_for_n_or_more);
376 /* list of valid menu classes for query_objlist() and allow_category callback
377 (with room for all object classes, 'u'npaid, BUCX, and terminator) */
378 static char valid_menu_classes[MAXOCLASSES + 1 + 4 + 1];
379 static boolean class_filter, bucx_filter, shop_filter;
381 /* check valid_menu_classes[] for an entry; also used by askchain() */
383 menu_class_present(c)
386 return (c && index(valid_menu_classes, c)) ? TRUE : FALSE;
390 add_valid_menu_class(c)
393 static int vmc_count = 0;
395 if (c == 0) { /* reset */
397 class_filter = bucx_filter = shop_filter = FALSE;
398 } else if (!menu_class_present(c)) {
399 valid_menu_classes[vmc_count++] = (char) c;
400 /* categorize the new class */
404 case 'C': /*FALLTHRU*/
416 valid_menu_classes[vmc_count] = '\0';
419 /* query_objlist callback: return TRUE if not uchain */
424 return (boolean) (obj != uchain);
427 /* query_objlist callback: return TRUE */
431 struct obj *obj UNUSED;
440 /* For coins, if any class filter is specified, accept if coins
441 * are included regardless of whether either unpaid or BUC-status
442 * is also specified since player has explicitly requested coins.
443 * If no class filtering is specified but bless/curse state is,
444 * coins are either unknown or uncursed based on an option setting.
446 if (obj->oclass == COIN_CLASS)
448 ? (index(valid_menu_classes, COIN_CLASS) ? TRUE : FALSE)
449 : shop_filter /* coins are never unpaid, but check anyway */
450 ? (obj->unpaid ? TRUE : FALSE)
452 ? (index(valid_menu_classes, iflags.goldX ? 'X' : 'U')
454 : TRUE; /* catchall: no filters specified, so accept */
456 if (Role_if(PM_PRIEST))
460 * There are three types of filters possible and the first and
461 * third can have more than one entry:
462 * 1) object class (armor, potion, &c);
463 * 2) unpaid shop item;
464 * 3) bless/curse state (blessed, uncursed, cursed, BUC-unknown).
465 * When only one type is present, the situation is simple:
466 * to be accepted, obj's status must match one of the entries.
467 * When more than one type is present, the obj will now only
468 * be accepted when it matches one entry of each type.
469 * So ?!B will accept blessed scrolls or potions, and [u will
470 * accept unpaid armor. (In 3.4.3, an object was accepted by
471 * this filter if it met any entry of any type, so ?!B resulted
472 * in accepting all scrolls and potions regardless of bless/curse
473 * state plus all blessed non-scroll, non-potion objects.)
476 /* if class is expected but obj's class is not in the list, reject */
477 if (class_filter && !index(valid_menu_classes, obj->oclass))
479 /* if unpaid is expected and obj isn't unpaid, reject (treat a container
480 holding any unpaid object as unpaid even if isn't unpaid itself) */
481 if (shop_filter && !obj->unpaid
482 && !(Has_contents(obj) && count_unpaid(obj->cobj) > 0))
484 /* check for particular bless/curse state */
486 /* first categorize this object's bless/curse state */
487 char bucx = !obj->bknown ? 'X'
488 : obj->blessed ? 'B' : obj->cursed ? 'C' : 'U';
490 /* if its category is not in the list, reject */
491 if (!index(valid_menu_classes, bucx))
494 /* obj didn't fail any of the filter checks, so accept */
499 /* query_objlist callback: return TRUE if valid category (class), no uchain */
501 allow_cat_no_uchain(obj)
505 && ((index(valid_menu_classes, 'u') && obj->unpaid)
506 || index(valid_menu_classes, obj->oclass)))
512 /* query_objlist callback: return TRUE if valid class and worn */
514 is_worn_by_type(otmp)
515 register struct obj *otmp;
517 return (is_worn(otmp) && allow_category(otmp)) ? TRUE : FALSE;
521 * Have the hero pick things from the ground
522 * or a monster's inventory if swallowed.
527 * <0 pickup count of something
529 * Returns 1 if tried to pick something up, whether
530 * or not it succeeded.
534 int what; /* should be a long */
536 int i, n, res, count, n_tried = 0, n_picked = 0;
537 menu_item *pick_list = (menu_item *) 0;
538 boolean autopickup = what > 0;
539 struct obj **objchain_p;
542 /* we might have arrived here while fainted or sleeping, via
543 random teleport or levitation timeout; if so, skip check_here
544 and read_engr_at in addition to bypassing autopickup itself
545 [probably ought to check whether hero is using a cockatrice
546 corpse for a pillow here... (also at initial faint/sleep)] */
547 if (autopickup && multi < 0 && unconscious())
550 if (what < 0) /* pick N of something */
552 else /* pick anything */
558 /* no auto-pick if no-pick move, nothing there, or in a pool */
559 if (autopickup && (context.nopick || !OBJ_AT(u.ux, u.uy)
560 || (is_pool(u.ux, u.uy) && !Underwater)
561 || is_lava(u.ux, u.uy))) {
562 read_engr_at(u.ux, u.uy);
565 /* no pickup if levitating & not on air or water level */
566 if (!can_reach_floor(TRUE)) {
567 if ((multi && !context.run) || (autopickup && !flags.pickup)
568 || ((ttmp = t_at(u.ux, u.uy)) != 0
569 && uteetering_at_seen_pit(ttmp)))
570 read_engr_at(u.ux, u.uy);
573 /* multi && !context.run means they are in the middle of some other
574 * action, or possibly paralyzed, sleeping, etc.... and they just
575 * teleported onto the object. They shouldn't pick it up.
577 if ((multi && !context.run) || (autopickup && !flags.pickup)) {
581 if (notake(youmonst.data)) {
584 You("are physically incapable of picking anything up.");
586 You("
\95¨
\97\9d\93I
\82É
\8fE
\82¢
\82 \82°
\82é
\82±
\82Æ
\82ª
\82Å
\82«
\82È
\82¢
\81D");
592 /* if there's anything here, stop running */
593 if (OBJ_AT(u.ux, u.uy) && context.run && context.run != 8
598 add_valid_menu_class(0); /* reset */
600 objchain_p = &level.objects[u.ux][u.uy];
601 traverse_how = BY_NEXTHERE;
603 objchain_p = &u.ustuck->minvent;
604 traverse_how = 0; /* nobj */
607 * Start the actual pickup process. This is split into two main
608 * sections, the newer menu and the older "traditional" methods.
609 * Automatic pickup has been split into its own menu-style routine
610 * to make things less confusing.
613 n = autopick(*objchain_p, traverse_how, &pick_list);
617 if (flags.menu_style != MENU_TRADITIONAL || iflags.menu_requested) {
618 /* use menus exclusively */
619 traverse_how |= AUTOSELECT_SINGLE
620 | (flags.sortpack ? INVORDER_SORT : 0);
621 if (count) { /* looking for N of something */
625 Sprintf(qbuf, "Pick %d of what?", count);
627 Sprintf(qbuf, "
\89½
\82ð%d
\8cÂ
\8fE
\82¢
\82Ü
\82·
\82©
\81H", count);
628 val_for_n_or_more = count; /* set up callback selector */
629 n = query_objlist(qbuf, objchain_p, traverse_how,
630 &pick_list, PICK_ONE, n_or_more);
631 /* correct counts, if any given */
632 for (i = 0; i < n; i++)
633 pick_list[i].count = count;
636 n = query_objlist("Pick up what?", objchain_p,
637 (traverse_how | FEEL_COCKATRICE),
638 &pick_list, PICK_ANY, all_but_uchain);
640 n = query_objlist("
\89½
\82ð
\8fE
\82¢
\82Ü
\82·
\82©
\81H", objchain_p,
641 (traverse_how | FEEL_COCKATRICE),
642 &pick_list, PICK_ANY, all_but_uchain);
648 for (n_picked = i = 0; i < n; i++) {
649 res = pickup_object(pick_list[i].item.a_obj, pick_list[i].count,
652 break; /* can't continue */
656 free((genericptr_t) pick_list);
659 /* old style interface */
662 boolean all_of_a_type, selective, bycat;
663 char oclasses[MAXOCLASSES + 10]; /* +10: room for B,U,C,X plus slop */
664 struct obj *obj, *obj2;
666 oclasses[0] = '\0'; /* types to consider (empty for all) */
667 all_of_a_type = TRUE; /* take all of considered types */
668 selective = FALSE; /* ask for each item */
670 /* check for more than one object */
671 for (obj = *objchain_p; obj; obj = FOLLOW(obj, traverse_how))
674 if (ct == 1 && count) {
675 /* if only one thing, then pick it */
677 lcount = min(obj->quan, (long) count);
679 if (pickup_object(obj, lcount, FALSE) > 0)
680 n_picked++; /* picked something */
683 } else if (ct >= 2) {
687 There("are %s objects here.", (ct <= 10) ? "several" : "many");
689 pline("
\82±
\82±
\82É
\82Í%s
\82à
\82Ì
\82ª
\82 \82é
\81D", (ct <= 10) ? "
\82¢
\82
\82Â
\82©" : "
\91ò
\8eR
\82Ì");
691 if (!query_classes(oclasses, &selective, &all_of_a_type,
692 "pick up", *objchain_p,
693 (traverse_how & BY_NEXTHERE) ? TRUE : FALSE,
696 if (!query_classes(oclasses, &selective, &all_of_a_type,
697 "
\8fE
\82¤", *objchain_p,
698 (traverse_how & BY_NEXTHERE) ? TRUE : FALSE,
704 traverse_how |= INVORDER_SORT;
706 n = query_objlist("Pick up what?", objchain_p, traverse_how,
707 &pick_list, PICK_ANY,
708 (via_menu == -2) ? allow_all
711 n = query_objlist("
\89½
\82ð
\8fE
\82¢
\82Ü
\82·
\82©
\81H", objchain_p, traverse_how,
712 &pick_list, PICK_ANY,
713 (via_menu == -2) ? allow_all
719 bycat = (menu_class_present('B') || menu_class_present('U')
720 || menu_class_present('C') || menu_class_present('X'));
722 for (obj = *objchain_p; obj; obj = obj2) {
723 obj2 = FOLLOW(obj, traverse_how);
724 if (bycat ? !allow_category(obj)
725 : (!selective && oclasses[0]
726 && !index(oclasses, obj->oclass)))
730 if (!all_of_a_type) {
734 (void) safe_qbuf(qbuf, "Pick up ", "?", obj, doname,
735 ansimpleoname, something);
737 (void) safe_qbuf(qbuf, "", "
\82ð
\8fE
\82¢
\82Ü
\82·
\82©
\81H", obj, doname,
738 ansimpleoname, "
\82±
\82ê");
740 switch ((obj->quan < 2L) ? ynaq(qbuf) : ynNaq(qbuf)) {
742 goto end_query; /* out 2 levels */
746 all_of_a_type = TRUE;
749 oclasses[0] = obj->oclass;
753 case '#': /* count was entered */
755 continue; /* 0 count => No */
756 lcount = (long) yn_number;
757 if (lcount > obj->quan)
768 if ((res = pickup_object(obj, lcount, FALSE)) < 0)
773 ; /* statement required after label */
777 if (hides_under(youmonst.data))
778 (void) hideunder(&youmonst);
780 /* position may need updating (invisible hero) */
782 newsym_force(u.ux, u.uy);
784 /* check if there's anything else here after auto-pickup is done */
786 check_here(n_picked > 0);
789 add_valid_menu_class(0); /* reset */
790 return (n_tried > 0);
794 is_autopickup_exception(obj, grab)
796 boolean grab; /* forced pickup, rather than forced leave behind? */
799 * Does the text description of this match an exception?
801 struct autopickup_exception
802 *ape = (grab) ? iflags.autopickup_exceptions[AP_GRAB]
803 : iflags.autopickup_exceptions[AP_LEAVE];
806 char *objdesc = makesingular(doname(obj));
809 if (regex_match(objdesc, ape->regex))
818 autopick_testobj(otmp, calc_costly)
822 static boolean costly = FALSE;
823 const char *otypes = flags.pickup_types;
826 /* calculate 'costly' just once for a given autopickup operation */
828 costly = (otmp->where == OBJ_FLOOR
829 && costly_spot(otmp->ox, otmp->oy));
831 /* first check: reject if an unpaid item in a shop */
832 if (costly && !otmp->no_charge)
835 /* check for pickup_types */
836 pickit = (!*otypes || index(otypes, otmp->oclass));
837 /* check for "always pick up */
839 pickit = is_autopickup_exception(otmp, TRUE);
840 /* then for "never pick up */
842 pickit = !is_autopickup_exception(otmp, FALSE);
843 /* pickup_thrown overrides pickup_types and exceptions */
845 pickit = (flags.pickup_thrown && otmp->was_thrown);
850 * Pick from the given list using flags.pickup_types. Return the number
851 * of items picked (not counts). Create an array that returns pointers
852 * and counts of the items to be picked up. If the number of items
853 * picked is zero, the pickup list is left alone. The caller of this
854 * function must free the pickup list.
857 autopick(olist, follow, pick_list)
858 struct obj *olist; /* the object list */
859 int follow; /* how to follow the object list */
860 menu_item **pick_list; /* list of objects and counts to pick up */
862 menu_item *pi; /* pick item */
865 boolean check_costly = TRUE;
867 /* first count the number of eligible items */
868 for (n = 0, curr = olist; curr; curr = FOLLOW(curr, follow)) {
869 if (autopick_testobj(curr, check_costly))
871 check_costly = FALSE; /* only need to check once per autopickup */
875 *pick_list = pi = (menu_item *) alloc(sizeof (menu_item) * n);
876 for (n = 0, curr = olist; curr; curr = FOLLOW(curr, follow)) {
877 if (autopick_testobj(curr, FALSE)) {
878 pi[n].item.a_obj = curr;
879 pi[n].count = curr->quan;
888 * Put up a menu using the given object list. Only those objects on the
889 * list that meet the approval of the allow function are displayed. Return
890 * a count of the number of items selected, as well as an allocated array of
891 * menu_items, containing pointers to the objects selected and counts. The
892 * returned counts are guaranteed to be in bounds and non-zero.
895 * BY_NEXTHERE - Follow object list via nexthere instead of nobj.
896 * AUTOSELECT_SINGLE - Don't ask if only 1 object qualifies - just
898 * USE_INVLET - Use object's invlet.
899 * INVORDER_SORT - Use hero's pack order.
900 * INCLUDE_HERO - Showing engulfer's invent; show hero too.
901 * SIGNAL_NOMENU - Return -1 rather than 0 if nothing passes "allow".
902 * SIGNAL_ESCAPE - Return -1 rather than 0 if player uses ESC to
904 * FEEL_COCKATRICE - touch corpse.
907 query_objlist(qstr, olist_p, qflags, pick_list, how, allow)
908 const char *qstr; /* query string */
909 struct obj **olist_p; /* the list to pick from */
910 int qflags; /* options to control the query */
911 menu_item **pick_list; /* return list of items picked */
912 int how; /* type of query */
913 boolean FDECL((*allow), (OBJ_P)); /* allow function */
917 struct obj *curr, *last, fake_hero_object, *olist = *olist_p;
920 boolean printed_type_name, first,
921 sorted = (qflags & INVORDER_SORT) != 0,
922 engulfer = (qflags & INCLUDE_HERO) != 0;
924 Loot *sortedolist, *srtoli;
926 *pick_list = (menu_item *) 0;
927 if (!olist && !engulfer)
930 /* count the number of items allowed */
931 for (n = 0, last = 0, curr = olist; curr; curr = FOLLOW(curr, qflags))
932 if ((*allow)(curr)) {
938 /* don't autoselect swallowed hero if it's the only choice */
939 qflags &= ~AUTOSELECT_SINGLE;
942 if (n == 0) /* nothing to pick here */
943 return (qflags & SIGNAL_NOMENU) ? -1 : 0;
945 if (n == 1 && (qflags & AUTOSELECT_SINGLE)) {
946 *pick_list = (menu_item *) alloc(sizeof (menu_item));
947 (*pick_list)->item.a_obj = last;
948 (*pick_list)->count = last->quan;
952 sortflags = (((flags.sortloot == 'f'
953 || (flags.sortloot == 'l' && !(qflags & USE_INVLET)))
955 : ((qflags & USE_INVLET) ? SORTLOOT_INVLET : 0))
956 | (flags.sortpack ? SORTLOOT_PACK : 0)
957 | ((qflags & FEEL_COCKATRICE) ? SORTLOOT_PETRIFY : 0));
958 sortedolist = sortloot(&olist, sortflags,
959 (qflags & BY_NEXTHERE) ? TRUE : FALSE, allow);
961 win = create_nhwindow(NHW_MENU);
965 * Run through the list and add the objects to the menu. If
966 * INVORDER_SORT is set, we'll run through the list once for
967 * each type so we can group them. The allow function was
968 * called by sortloot() and will be called once per item here.
970 pack = flags.inv_order;
973 printed_type_name = FALSE;
974 for (srtoli = sortedolist; ((curr = srtoli->obj) != 0); ++srtoli) {
975 if (sorted && curr->oclass != *pack)
977 if ((qflags & FEEL_COCKATRICE) && curr->otyp == CORPSE
978 && will_feel_cockatrice(curr, FALSE)) {
979 destroy_nhwindow(win); /* stop the menu and revert */
980 (void) look_here(0, FALSE);
983 if ((*allow)(curr)) {
984 /* if sorting, print type name (once only) */
985 if (sorted && !printed_type_name) {
987 add_menu(win, NO_GLYPH, &any, 0, 0, iflags.menu_headings,
988 let_to_name(*pack, FALSE,
990 && iflags.menu_head_objsym)),
992 printed_type_name = TRUE;
996 add_menu(win, obj_to_glyph(curr, rn2_on_display_rng), &any,
997 (qflags & USE_INVLET) ? curr->invlet
998 : (first && curr->oclass == COIN_CLASS) ? '$' : 0,
999 def_oc_syms[(int) objects[curr->otyp].oc_class].sym,
1000 ATR_NONE, doname_with_price(curr), MENU_UNSELECTED);
1005 } while (sorted && *pack);
1006 unsortloot(&sortedolist);
1012 if (sorted && n > 1) {
1014 Sprintf(buf, "%s Creatures",
1015 is_animal(u.ustuck->data) ? "Swallowed" : "Engulfed");
1017 Sprintf(buf, "%s
\8d\9e\82Ü
\82ê
\82Ä
\82¢
\82é
\89ö
\95¨",
1018 is_animal(u.ustuck->data) ? "
\88ù
\82Ý" : "
\8aª
\82«");
1020 add_menu(win, NO_GLYPH, &any, 0, 0, iflags.menu_headings, buf,
1023 fake_hero_object = zeroobj;
1024 fake_hero_object.quan = 1L; /* not strictly necessary... */
1025 any.a_obj = &fake_hero_object;
1026 add_menu(win, mon_to_glyph(&youmonst, rn2_on_display_rng), &any,
1027 /* fake inventory letter, no group accelerator */
1028 CONTAINED_SYM, 0, ATR_NONE, an(self_lookat(buf)),
1032 end_menu(win, qstr);
1033 n = select_menu(win, how, pick_list);
1034 destroy_nhwindow(win);
1040 /* fix up counts: -1 means no count used => pick all;
1041 if fake_hero_object was picked, discard that choice */
1042 for (i = k = 0, mi = *pick_list; i < n; i++, mi++) {
1043 if (mi->item.a_obj == &fake_hero_object)
1045 if (mi->count == -1L || mi->count > mi->item.a_obj->quan)
1046 mi->count = mi->item.a_obj->quan;
1048 (*pick_list)[k] = *mi;
1052 /* fake_hero was only choice so discard whole list */
1053 free((genericptr_t) *pick_list);
1057 /* other stuff plus fake_hero; last slot is now unused */
1058 (*pick_list)[k].item = zeroany;
1059 (*pick_list)[k].count = 0L;
1063 /* -1 is used for SIGNAL_NOMENU, so callers don't expect it
1064 to indicate that the player declined to make a choice */
1065 n = (qflags & SIGNAL_ESCAPE) ? -2 : 0;
1071 * allow menu-based category (class) selection (for Drop,take off etc.)
1075 query_category(qstr, olist, qflags, pick_list, how)
1076 const char *qstr; /* query string */
1077 struct obj *olist; /* the list to pick from */
1078 int qflags; /* behaviour modification flags */
1079 menu_item **pick_list; /* return list of items picked */
1080 int how; /* type of query */
1087 boolean collected_type_name;
1090 boolean FDECL((*ofilter), (OBJ_P)) = (boolean FDECL((*), (OBJ_P))) 0;
1091 boolean do_unpaid = FALSE;
1092 boolean do_blessed = FALSE, do_cursed = FALSE, do_uncursed = FALSE,
1093 do_buc_unknown = FALSE;
1094 int num_buc_types = 0;
1096 *pick_list = (menu_item *) 0;
1099 if ((qflags & UNPAID_TYPES) && count_unpaid(olist))
1101 if (qflags & WORN_TYPES)
1103 if ((qflags & BUC_BLESSED) && count_buc(olist, BUC_BLESSED, ofilter)) {
1107 if ((qflags & BUC_CURSED) && count_buc(olist, BUC_CURSED, ofilter)) {
1111 if ((qflags & BUC_UNCURSED) && count_buc(olist, BUC_UNCURSED, ofilter)) {
1115 if ((qflags & BUC_UNKNOWN) && count_buc(olist, BUC_UNKNOWN, ofilter)) {
1116 do_buc_unknown = TRUE;
1120 ccount = count_categories(olist, qflags);
1121 /* no point in actually showing a menu for a single category */
1122 if (ccount == 1 && !do_unpaid && num_buc_types <= 1
1123 && !(qflags & BILLED_TYPES)) {
1124 for (curr = olist; curr; curr = FOLLOW(curr, qflags)) {
1125 if (ofilter && !(*ofilter)(curr))
1130 *pick_list = (menu_item *) alloc(sizeof(menu_item));
1131 (*pick_list)->item.a_int = curr->oclass;
1134 debugpline0("query_category: no single object match");
1139 win = create_nhwindow(NHW_MENU);
1141 pack = flags.inv_order;
1143 if (qflags & CHOOSE_ALL) {
1147 add_menu(win, NO_GLYPH, &any, invlet, 0, ATR_NONE,
1149 (qflags & WORN_TYPES) ? "Auto-select every item being worn"
1151 (qflags & WORN_TYPES) ? "
\90g
\82É
\82Â
\82¯
\82ç
\82ê
\82é
\95¨
\91S
\82Ä"
1153 : "Auto-select every item",
1159 add_menu(win, NO_GLYPH, &any, 0, 0, ATR_NONE, "", MENU_UNSELECTED);
1162 if ((qflags & ALL_TYPES) && (ccount > 1)) {
1165 any.a_int = ALL_TYPES_SELECTED;
1166 add_menu(win, NO_GLYPH, &any, invlet, 0, ATR_NONE,
1168 (qflags & WORN_TYPES) ? "All worn types" : "All types",
1170 (qflags & WORN_TYPES) ? "
\90g
\82É
\82Â
\82¯
\82é
\82à
\82Ì
\91S
\82Ä" : "
\91S
\82Ä",
1176 collected_type_name = FALSE;
1177 for (curr = olist; curr; curr = FOLLOW(curr, qflags)) {
1178 if (curr->oclass == *pack) {
1179 if (ofilter && !(*ofilter)(curr))
1181 if (!collected_type_name) {
1183 any.a_int = curr->oclass;
1185 win, NO_GLYPH, &any, invlet++,
1186 def_oc_syms[(int) objects[curr->otyp].oc_class].sym,
1187 ATR_NONE, let_to_name(*pack, FALSE,
1189 && iflags.menu_head_objsym),
1191 collected_type_name = TRUE;
1196 if (invlet >= 'u') {
1197 impossible("query_category: too many categories");
1202 if (do_unpaid || (qflags & BILLED_TYPES) || do_blessed || do_cursed
1203 || do_uncursed || do_buc_unknown) {
1205 add_menu(win, NO_GLYPH, &any, 0, 0, ATR_NONE, "", MENU_UNSELECTED);
1208 /* unpaid items if there are any */
1214 add_menu(win, NO_GLYPH, &any, invlet, 0, ATR_NONE, "Unpaid items",
1216 add_menu(win, NO_GLYPH, &any, invlet, 0, ATR_NONE, "
\96¢
\95¥
\82Ì
\82à
\82Ì",
1219 /* billed items: checked by caller, so always include if BILLED_TYPES */
1220 if (qflags & BILLED_TYPES) {
1224 add_menu(win, NO_GLYPH, &any, invlet, 0, ATR_NONE,
1226 "Unpaid items already used up", MENU_UNSELECTED);
1228 "
\96¢
\95¥
\82Å
\8eg
\82Á
\82Ä
\82µ
\82Ü
\82Á
\82½
\82à
\82Ì", MENU_UNSELECTED);
1231 /* items with b/u/c/unknown if there are any;
1232 this cluster of menu entries is in alphabetical order,
1233 reversing the usual sequence of 'U' and 'C' in BUCX */
1238 add_menu(win, NO_GLYPH, &any, invlet, 0, ATR_NONE,
1240 "Items known to be Blessed", MENU_UNSELECTED);
1242 "
\8fj
\95\9f\82³
\82ê
\82Ä
\82¢
\82é
\82Æ
\82í
\82©
\82Á
\82Ä
\82¢
\82é
\82à
\82Ì", MENU_UNSELECTED);
1248 add_menu(win, NO_GLYPH, &any, invlet, 0, ATR_NONE,
1250 "Items known to be Cursed", MENU_UNSELECTED);
1252 "
\8eô
\82í
\82ê
\82Ä
\82¢
\82é
\82Æ
\82í
\82©
\82Á
\82Ä
\82¢
\82é
\82à
\82Ì", MENU_UNSELECTED);
1258 add_menu(win, NO_GLYPH, &any, invlet, 0, ATR_NONE,
1260 "Items known to be Uncursed", MENU_UNSELECTED);
1262 "
\8eô
\82í
\82ê
\82Ä
\82¢
\82È
\82¢
\82Æ
\82í
\82©
\82Á
\82Ä
\82¢
\82é
\82à
\82Ì", MENU_UNSELECTED);
1264 if (do_buc_unknown) {
1269 add_menu(win, NO_GLYPH, &any, invlet, 0, ATR_NONE,
1270 "Items of unknown Bless/Curse status", MENU_UNSELECTED);
1272 add_menu(win, NO_GLYPH, &any, invlet, 0, ATR_NONE,
1273 "
\8fj
\95\9f\81^
\8eô
\82¢
\82ª
\82í
\82©
\82ç
\82È
\82¢
\82à
\82Ì", MENU_UNSELECTED);
1276 end_menu(win, qstr);
1277 n = select_menu(win, how, pick_list);
1278 destroy_nhwindow(win);
1280 n = 0; /* caller's don't expect -1 */
1285 count_categories(olist, qflags)
1290 boolean counted_category;
1294 pack = flags.inv_order;
1296 counted_category = FALSE;
1297 for (curr = olist; curr; curr = FOLLOW(curr, qflags)) {
1298 if (curr->oclass == *pack) {
1299 if ((qflags & WORN_TYPES)
1300 && !(curr->owornmask & (W_ARMOR | W_ACCESSORY | W_WEAPON)))
1302 if (!counted_category) {
1304 counted_category = TRUE;
1314 * How much the weight of the given container will change when the given
1315 * object is removed from it. Use before and after weight amounts rather
1316 * than trying to match the calculation used by weight() in mkobj.c.
1319 delta_cwt(container, obj)
1320 struct obj *container, *obj;
1325 if (container->otyp != BAG_OF_HOLDING)
1328 owt = nwt = container->owt;
1329 /* find the object so that we can remove it */
1330 for (prev = &container->cobj; *prev; prev = &(*prev)->nobj)
1334 panic("delta_cwt: obj not inside container?");
1336 /* temporarily remove the object and calculate resulting weight */
1338 nwt = weight(container);
1339 *prev = obj; /* put the object back; obj->nobj is still valid */
1344 /* could we carry `obj'? if not, could we carry some of it/them? */
1346 carry_count(obj, container, count, telekinesis, wt_before, wt_after)
1347 struct obj *obj, *container; /* object to pick up, bag it's coming out of */
1349 boolean telekinesis;
1350 int *wt_before, *wt_after;
1352 boolean adjust_wt = container && carried(container),
1353 is_gold = obj->oclass == COIN_CLASS;
1354 int wt, iw, ow, oow;
1355 long qq, savequan, umoney;
1358 const char *verb, *prefx1, *prefx2, *suffx;
1360 const char *verb, *prefx1;
1362 char obj_nambuf[BUFSZ], where[BUFSZ];
1364 savequan = obj->quan;
1366 umoney = money_cnt(invent);
1367 iw = max_capacity();
1369 if (count != savequan) {
1371 obj->owt = (unsigned) weight(obj);
1373 wt = iw + (int) obj->owt;
1375 wt -= delta_cwt(container, obj);
1376 /* This will go with silver+copper & new gold weight */
1377 if (is_gold) /* merged gold might affect cumulative weight */
1378 wt -= (GOLD_WT(umoney) + GOLD_WT(count) - GOLD_WT(umoney + count));
1379 if (count != savequan) {
1380 obj->quan = savequan;
1389 /* see how many we can lift */
1391 iw -= (int) GOLD_WT(umoney);
1393 qq = GOLD_CAPACITY((long) iw, umoney);
1396 qq = 50L - (umoney % 100L) - 1L;
1399 for (; qq <= count; qq += 100L) {
1401 obj->owt = (unsigned) GOLD_WT(qq);
1402 ow = (int) GOLD_WT(umoney + qq);
1403 ow -= delta_cwt(container, obj);
1413 else if (qq > count)
1415 wt = iw + (int) GOLD_WT(umoney + qq);
1416 } else if (count > 1 || count < obj->quan) {
1418 * Ugh. Calc num to lift by changing the quan of of the
1419 * object and calling weight.
1421 * This works for containers only because containers
1422 * don't merge. -dean
1424 for (qq = 1L; qq <= count; qq++) {
1426 obj->owt = (unsigned) (ow = weight(obj));
1428 ow -= delta_cwt(container, obj);
1435 /* there's only one, and we can't lift it */
1438 obj->quan = savequan;
1442 /* some message will be given */
1443 Strcpy(obj_nambuf, doname(obj));
1446 Sprintf(where, "in %s", the(xname(container)));
1448 Sprintf(where, "%s
\82Ì
\92\86\82É
\93ü
\82Á
\82Ä
\82¢
\82é", the(xname(container)));
1452 verb = "
\89^
\82×
\82È
\82¢";
1455 Strcpy(where, "lying here");
1457 Strcpy(where, "
\82±
\82±
\82É
\92u
\82¢
\82Ä
\82 \82é");
1459 verb = telekinesis ? "acquire" : "lift";
1461 verb = telekinesis ? "
\8al
\93¾
\82Å
\82«
\82È
\82¢" : "
\8e\9d\82¿
\82 \82°
\82ç
\82ê
\82È
\82¢";
1464 /* lint suppression */
1465 *obj_nambuf = *where = '\0';
1468 /* we can carry qq of them */
1472 You("can only %s %s of the %s %s.", verb,
1473 (qq == 1L) ? "one" : "some", obj_nambuf, where);
1475 You("%s%s
\82Ì
\82¤
\82¿
\82Ì%s
\82µ
\82©%s
\81D",
1476 where, obj_nambuf, (qq == 1L) ? "
\88ê
\82Â" : "
\82¢
\82
\82Â
\82©", verb);
1484 Strcpy(where, "here"); /* slightly shorter form */
1486 Strcpy(where, "
\82±
\82±
\82É
\82Í"); /* slightly shorter form */
1488 if (invent || umoney) {
1490 prefx1 = "you cannot ";
1492 suffx = " any more";
1494 prefx1 = "
\82±
\82ê
\88È
\8fã";
1498 prefx1 = (obj->quan == 1L) ? "it " : "even one ";
1499 prefx2 = "is too heavy for you to ";
1502 prefx1 = "
\8fd
\82·
\82¬
\82Ä";
1506 There("%s %s %s, but %s%s%s%s.", otense(obj, "are"), obj_nambuf, where,
1507 prefx1, prefx2, verb, suffx);
1509 pline("%s%s
\82ª
\82 \82é
\81C
\82µ
\82©
\82µ%s%s
\81D",
1510 where, obj_nambuf, prefx1, verb);
1513 /* *wt_after = iw; */
1517 /* determine whether character is able and player is willing to carry `obj' */
1520 lift_object(obj, container, cnt_p, telekinesis)
1521 struct obj *obj, *container; /* object to pick up, bag it's coming out of */
1523 boolean telekinesis;
1525 int result, old_wt, new_wt, prev_encumbr, next_encumbr;
1527 if (obj->otyp == BOULDER && Sokoban) {
1529 You("cannot get your %s around this %s.", body_part(HAND),
1532 You("%s
\82ð%s
\82Å
\8e\9d\82¿
\82 \82°
\82é
\82±
\82Æ
\82ª
\82Å
\82«
\82È
\82¢
\81D",
1533 xname(obj), body_part(HAND));
1537 /* override weight consideration for loadstone picked up by anybody
1538 and for boulder picked up by hero poly'd into a giant; override
1539 availability of open inventory slot iff not already carrying one */
1540 if (obj->otyp == LOADSTONE
1541 || (obj->otyp == BOULDER && throws_rocks(youmonst.data))) {
1542 if (inv_cnt(FALSE) < 52 || !carrying(obj->otyp)
1543 || merge_choice(invent, obj))
1544 return 1; /* lift regardless of current situation */
1545 /* if we reach here, we're out of slots and already have at least
1546 one of these, so treat this one more like a normal item */
1548 You("are carrying too much stuff to pick up %s %s.",
1549 (obj->quan == 1L) ? "another" : "more", simpleonames(obj));
1551 You("%s
\82ð%s
\8fE
\82¤
\82É
\82Í
\95¨
\82ð
\8e\9d\82¿
\82·
\82¬
\82Ä
\82¢
\82é
\81D",
1552 simpleonames(obj), (obj->quan == 1L) ? "
\82à
\82¤
\88ê
\82Â" : "
\82à
\82Á
\82Æ");
1557 *cnt_p = carry_count(obj, container, *cnt_p, telekinesis,
1560 result = -1; /* nothing lifted */
1561 } else if (obj->oclass != COIN_CLASS
1562 /* [exception for gold coins will have to change
1563 if silver/copper ones ever get implemented] */
1564 && inv_cnt(FALSE) >= 52 && !merge_choice(invent, obj)) {
1566 Your("knapsack cannot accommodate any more items.");
1568 Your("
\83i
\83b
\83v
\83U
\83b
\83N
\82Í
\82±
\82ê
\88È
\8fã
\83A
\83C
\83e
\83\80\82ð
\8bl
\82ß
\8d\9e\82ß
\82È
\82¢
\81D");
1569 result = -1; /* nothing lifted */
1572 prev_encumbr = near_capacity();
1573 if (prev_encumbr < flags.pickup_burden)
1574 prev_encumbr = flags.pickup_burden;
1575 next_encumbr = calc_capacity(new_wt - old_wt);
1576 if (next_encumbr > prev_encumbr) {
1578 result = 0; /* don't lift */
1584 long savequan = obj->quan;
1588 Strcpy(qbuf, (next_encumbr > HVY_ENCUMBER)
1590 : (next_encumbr > MOD_ENCUMBER)
1594 /*JP:
\83A
\83C
\83e
\83\80\96¼
\82Ì
\8cã
\82ë
\82É
\95t
\82¯
\82½
\82¢
\82ªsafe_qbuf
\82Ìqsuffix
\82Í
1595 qbuf
\82Æ
\8b¤
\97p
\82Å
\82«
\82È
\82¢
\82Ì
\82Å
\95Ê
\82Éqsfx
\82ð
\97p
\88Ó
\82µ
\82Ä
\82»
\82¿
\82ç
\82ð
\8eg
\82¤*/
1596 Strcpy(qsfx, (next_encumbr > HVY_ENCUMBER)
1598 : (next_encumbr > MOD_ENCUMBER)
1601 Strcat(qsfx, "
\81D
\91±
\82¯
\82Ü
\82·
\82©
\81H");
1604 #if 0 /*JP*//*
\93ú
\96{
\8cê
\82Å
\82Í
\82Ç
\82¿
\82ç
\82à
\81u
\8e\9d\82Â
\81v
\82Å
\8dÏ
\82Ü
\82¹
\82é*/
1606 (void) strsubst(qbuf, "lifting", "removing");
1610 (void) safe_qbuf(qbuf, qbuf, ". Continue?", obj, doname,
1611 ansimpleoname, something);
1612 #else /*JP:
\91O
\82É
\82Í
\89½
\82à
\95t
\82¯
\82¸
\8cã
\82ë
\82Éqsfx
\82ð
\95t
\82¯
\82é*/
1613 (void) safe_qbuf(qbuf, "", qsfx, obj, doname,
1614 ansimpleoname, "
\82±
\82ê");
1616 obj->quan = savequan;
1617 switch (ynq(qbuf)) {
1625 break; /* 'y' => result == 1 */
1627 clear_nhwindow(WIN_MESSAGE);
1632 if (obj->otyp == SCR_SCARE_MONSTER && result <= 0 && !container)
1638 * Pick up <count> of obj from the ground and add it to the hero's inventory.
1639 * Returns -1 if caller should break out of its loop, 0 if nothing picked
1640 * up, 1 if otherwise.
1643 pickup_object(obj, count, telekinesis)
1646 boolean telekinesis; /* not picking it up directly by hand */
1650 if (obj->quan < count) {
1651 impossible("pickup_object: count %ld > quan %ld?", count, obj->quan);
1655 /* In case of auto-pickup, where we haven't had a chance
1656 to look at it yet; affects docall(SCR_SCARE_MONSTER). */
1660 if (obj == uchain) { /* do not pick up attached chain */
1662 } else if (obj->oartifact && !touch_artifact(obj, &youmonst)) {
1664 } else if (obj->otyp == CORPSE) {
1665 if (fatal_corpse_mistake(obj, telekinesis)
1666 || rider_corpse_revival(obj, telekinesis))
1668 } else if (obj->otyp == SCR_SCARE_MONSTER) {
1671 else if (!obj->spe && !obj->cursed)
1675 pline_The("scroll%s %s to dust as you %s %s up.", plur(obj->quan),
1676 otense(obj, "turn"), telekinesis ? "raise" : "pick",
1677 (obj->quan == 1L) ? "it" : "them");
1679 pline("
\8aª
\95¨
\82Í
\82 \82È
\82½
\82ª%s
\8fã
\82°
\82é
\82Æ
\90o
\82Æ
\82È
\82Á
\82Ä
\82µ
\82Ü
\82Á
\82½
\81D",
1680 telekinesis ? "
\8e\9d\82¿" : "
\8fE
\82¢");
1682 if (!(objects[SCR_SCARE_MONSTER].oc_name_known)
1683 && !(objects[SCR_SCARE_MONSTER].oc_uname))
1685 useupf(obj, obj->quan);
1686 return 1; /* tried to pick something up and failed, but
1687 don't want to terminate pickup loop yet */
1691 if ((res = lift_object(obj, (struct obj *) 0, &count, telekinesis)) <= 0)
1694 /* Whats left of the special case for gold :-) */
1695 if (obj->oclass == COIN_CLASS)
1697 if (obj->quan != count && obj->otyp != LOADSTONE)
1698 obj = splitobj(obj, count);
1700 obj = pick_obj(obj);
1702 if (uwep && uwep == obj)
1703 mrg_to_wielded = TRUE;
1704 nearload = near_capacity();
1705 prinv(nearload == SLT_ENCUMBER ? moderateloadmsg : (char *) 0, obj,
1707 mrg_to_wielded = FALSE;
1712 * Do the actual work of picking otmp from the floor or monster's interior
1713 * and putting it in the hero's inventory. Take care of billing. Return a
1714 * pointer to the object where otmp ends up. This may be different
1715 * from otmp because of merging.
1722 int ox = otmp->ox, oy = otmp->oy;
1723 boolean robshop = (!u.uswallow && otmp != uball && costly_spot(ox, oy));
1725 obj_extract_self(otmp);
1728 /* for shop items, addinv() needs to be after addtobill() (so that
1729 object merger can take otmp->unpaid into account) but before
1730 remote_robbery() (which calls rob_shop() which calls setpaid()
1731 after moving costs of unpaid items to shop debt; setpaid()
1732 calls clear_unpaid() for lots of object chains, but 'otmp' isn't
1733 on any of those between obj_extract_self() and addinv(); for
1734 3.6.0, 'otmp' remained flagged as an unpaid item in inventory
1735 and triggered impossible() every time inventory was examined) */
1737 char saveushops[5], fakeshop[2];
1739 /* addtobill cares about your location rather than the object's;
1740 usually they'll be the same, but not when using telekinesis
1741 (if ever implemented) or a grappling hook */
1742 Strcpy(saveushops, u.ushops);
1743 fakeshop[0] = *in_rooms(ox, oy, SHOPBASE);
1745 Strcpy(u.ushops, fakeshop);
1746 /* sets obj->unpaid if necessary */
1747 addtobill(otmp, TRUE, FALSE, FALSE);
1748 Strcpy(u.ushops, saveushops);
1749 robshop = otmp->unpaid && !index(u.ushops, *fakeshop);
1752 result = addinv(otmp);
1753 /* if you're taking a shop item from outside the shop, make shk notice */
1755 remote_burglary(ox, oy);
1761 * prints a message if encumbrance changed since the last check and
1762 * returns the new encumbrance value (from near_capacity()).
1767 static int oldcap = UNENCUMBERED;
1768 int newcap = near_capacity();
1770 if (oldcap < newcap) {
1774 Your("movements are slowed slightly because of your load.");
1776 Your("
\93®
\82«
\82Í
\89×
\95¨
\82Ì
\82½
\82ß
\82É
\8f
\82µ
\92x
\82
\82È
\82Á
\82½
\81D");
1780 You("rebalance your load. Movement is difficult.");
1782 You("
\89×
\95¨
\82Ì
\92Þ
\8d\87\82ð
\82Æ
\82è
\92¼
\82µ
\82½
\82ª
\81C
\93®
\82«
\82É
\82
\82¢
\81D");
1786 You("%s under your heavy load. Movement is very hard.",
1787 stagger(youmonst.data, "stagger"));
1789 You("
\89×
\95¨
\82Ì
\8fd
\82Ý
\82Å
\82æ
\82ë
\82æ
\82ë
\82µ
\82½
\81D
\93®
\82
\82Ì
\82ª
\94ñ
\8fí
\82É
\82«
\82Â
\82¢
\81D");
1794 You("%s move a handspan with this load!",
1795 newcap == 4 ? "can barely" : "can't even");
1797 You("
\82±
\82Ì
\8fd
\82³
\82Å
\82Í
\8f
\82µ
\82à
\93®
\82¯
\82È
\82¢
\81I");
1802 } else if (oldcap > newcap) {
1806 Your("movements are now unencumbered.");
1808 Your("
\93®
\82«
\82Í
\8ay
\82É
\82È
\82Á
\82½
\81D");
1812 Your("movements are only slowed slightly by your load.");
1814 You("
\82¿
\82å
\82Á
\82Æ
\93®
\82«
\82â
\82·
\82
\82È
\82Á
\82½
\81D");
1818 You("rebalance your load. Movement is still difficult.");
1820 You("
\89×
\95¨
\82Ì
\92Þ
\8d\87\82ð
\82Æ
\82è
\92¼
\82µ
\82½
\81D
\82¾
\82ª
\82Ü
\82¾
\93®
\82
\82Ì
\82Í
\82«
\82Â
\82¢
\81D");
1824 You("%s under your load. Movement is still very hard.",
1825 stagger(youmonst.data, "stagger"));
1827 You("
\89×
\95¨
\82Ì
\8fd
\82Ý
\82ª
\82¸
\82Á
\82µ
\82è
\82Æ
\82
\82é
\81D
\82Ü
\82¾
\93®
\82
\82Ì
\82ª
\94ñ
\8fí
\82É
\82«
\82Â
\82¢
\81D");
1838 /* Is there a container at x,y. Optional: return count of containers at x,y */
1840 container_at(x, y, countem)
1844 struct obj *cobj, *nobj;
1845 int container_count = 0;
1847 for (cobj = level.objects[x][y]; cobj; cobj = nobj) {
1848 nobj = cobj->nexthere;
1849 if (Is_container(cobj)) {
1855 return container_count;
1859 able_to_loot(x, y, looting)
1861 boolean looting; /* loot vs tip */
1864 const char *verb = looting ? "loot" : "tip";
1866 const char *verb = looting ? "
\8aJ
\82¯
\82é" : "
\82Ð
\82Á
\82
\82è
\95Ô
\82·";
1868 if (!can_reach_floor(TRUE)) {
1869 if (u.usteed && P_SKILL(P_RIDING) < P_BASIC)
1870 rider_cant_reach(); /* not skilled enough to reach */
1872 cant_reach_floor(x, y, FALSE, TRUE);
1874 } else if ((is_pool(x, y) && (looting || !Underwater)) || is_lava(x, y)) {
1875 /* at present, can't loot in water even when Underwater;
1876 can tip underwater, but not when over--or stuck in--lava */
1878 You("cannot %s things that are deep in the %s.", verb,
1879 hliquid(is_lava(x, y) ? "lava" : "water"));
1881 You("%s
\82É
\90[
\82
\82É
\92¾
\82ñ
\82¾
\82à
\82Ì
\82ð%s
\82±
\82Æ
\82Í
\82Å
\82«
\82È
\82¢
\81D",
1882 hliquid(is_lava(u.ux, u.uy) ? "
\97n
\8aâ" : "
\90\85"), verb);
1885 } else if (nolimbs(youmonst.data)) {
1887 pline("Without limbs, you cannot %s anything.", verb);
1889 pline("
\8eè
\91«
\82ª
\82È
\82¢
\82Ì
\82Å
\81C%s
\82±
\82Æ
\82Í
\82Å
\82«
\82È
\82¢
\81D", verb);
1891 } else if (looting && !freehand()) {
1893 pline("Without a free %s, you cannot loot anything.",
1895 pline("
\8e©
\97R
\82É
\82È
\82é%s
\82ª
\82È
\82¢
\82Ì
\82Å
\81C
\8aJ
\82¯
\82é
\82±
\82Æ
\82Í
\82Å
\82«
\82È
\82¢
\81D",
1908 for (i = -1; i <= 1; i++)
1909 for (j = -1; j <= 1; j++) {
1912 if (isok(nx, ny) && MON_AT(nx, ny))
1919 do_loot_cont(cobjp, cindex, ccount)
1921 int cindex, ccount; /* index of this container (1..N), number of them (N) */
1923 struct obj *cobj = *cobjp;
1927 if (cobj->olocked) {
1931 cobj->lknown ? "It is" : "Hmmm, it turns out to be");
1933 pline("%s
\8c®
\82ª
\82©
\82©
\82Á
\82Ä
\82¢
\82é
\81D",
1934 cobj->lknown ? "" : "
\82Þ
\81[
\82ñ
\81C");
1936 else if (cobj->lknown)
1938 pline("%s is locked.", The(xname(cobj)));
1940 pline("%s
\82Í
\8c®
\82ª
\82©
\82©
\82Á
\82Ä
\82¢
\82é
\81D", xname(cobj));
1943 pline("Hmmm, %s turns out to be locked.", the(xname(cobj)));
1945 pline("
\82Þ
\81[
\82ñ
\81C%s
\82Í
\8c®
\82ª
\82©
\82©
\82Á
\82Ä
\82¢
\82é
\81D", xname(cobj));
1951 if (cobj->otyp == BAG_OF_TRICKS) {
1955 You("carefully open %s...", the(xname(cobj)));
1957 You("
\90T
\8fd
\82É%s
\82ð
\8aJ
\82¯
\82½
\81D
\81D
\81D", xname(cobj));
1959 pline("It develops a huge set of teeth and bites you!");
1961 pline("
\8a\93\82©
\82ç
\91å
\82«
\82È
\8e\95\82ª
\90¶
\82¦
\82Ä
\82«
\82Ä
\81C
\82 \82È
\82½
\82ð
\8a\9a\82ñ
\82¾
\81I");
1964 losehp(Maybe_Half_Phys(tmp), "carnivorous bag", KILLED_BY_AN);
1966 losehp(Maybe_Half_Phys(tmp), "
\90H
\93÷
\8a\93\82É
\8a\9a\82Ü
\82ê
\82Ä", KILLED_BY_AN);
1967 makeknown(BAG_OF_TRICKS);
1968 abort_looting = TRUE;
1973 You("%sopen %s...", (!cobj->cknown || !cobj->lknown) ? "carefully " : "",
1975 You("%s%s
\82ð
\8aJ
\82¯
\82½
\81D
\81D
\81D", (!cobj->cknown || !cobj->lknown) ? "
\90T
\8fd
\82É" : "",
1977 return use_container(cobjp, 0, (boolean) (cindex < ccount));
1980 /* loot a container on the floor or loot saddle from mon. */
1984 struct obj *cobj, *nobj;
1985 register int c = -1;
1988 boolean underfoot = TRUE;
1989 #if 0 /*JP*//*not used*/
1990 const char *dont_find_anything = "don't find anything";
1994 int prev_inquiry = 0;
1995 boolean prev_loot = FALSE;
1998 abort_looting = FALSE;
2000 if (check_capacity((char *) 0)) {
2001 /* "Can't do that while carrying so much stuff." */
2004 if (nohands(youmonst.data)) {
2006 You("have no hands!"); /* not `body_part(HAND)' */
2008 pline("
\82 \82È
\82½
\82É
\82Í
\8eè
\82ª
\82È
\82¢
\81I");
2013 if (rn2(6) && reverse_loot())
2017 pline("Being confused, you find nothing to loot.");
2019 pline("
\8d¬
\97\90\82µ
\82Ä
\82¢
\82é
\82Ì
\82Å
\81C
\8aJ
\82¯
\82é
\82à
\82Ì
\82ð
\8c©
\82Â
\82¯
\82ç
\82ê
\82È
\82¢
\81D");
2020 return 1; /* costs a turn */
2021 } /* else fallthrough to normal looting */
2026 if (iflags.menu_requested)
2030 if ((num_conts = container_at(cc.x, cc.y, TRUE)) > 0) {
2031 boolean anyfound = FALSE;
2033 if (!able_to_loot(cc.x, cc.y, TRUE))
2036 if (Blind && !uarmg) {
2037 /* if blind and without gloves, attempting to #loot at the
2038 location of a cockatrice corpse is fatal before asking
2039 whether to manipulate any containers */
2040 for (nobj = sobj_at(CORPSE, cc.x, cc.y); nobj;
2041 nobj = nxtobj(nobj, CORPSE, TRUE))
2042 if (will_feel_cockatrice(nobj, FALSE)) {
2043 feel_cockatrice(nobj, FALSE);
2044 /* if life-saved (or poly'd into stone golem),
2045 terminate attempt to loot */
2050 if (num_conts > 1) {
2051 /* use a menu to loot many containers */
2055 menu_item *pick_list = (menu_item *) 0;
2058 win = create_nhwindow(NHW_MENU);
2061 for (cobj = level.objects[cc.x][cc.y]; cobj;
2062 cobj = cobj->nexthere)
2063 if (Is_container(cobj)) {
2065 add_menu(win, NO_GLYPH, &any, 0, 0, ATR_NONE,
2066 doname(cobj), MENU_UNSELECTED);
2069 end_menu(win, "Loot which containers?");
2071 end_menu(win, "
\82Ç
\82ê
\82ð
\8aJ
\82¯
\82Ü
\82·
\82©
\81H");
2072 n = select_menu(win, PICK_ANY, &pick_list);
2073 destroy_nhwindow(win);
2076 for (i = 1; i <= n; i++) {
2077 cobj = pick_list[i - 1].item.a_obj;
2078 timepassed |= do_loot_cont(&cobj, i, n);
2079 if (abort_looting) {
2080 /* chest trap or magic bag explosion or <esc> */
2081 free((genericptr_t) pick_list);
2085 free((genericptr_t) pick_list);
2090 for (cobj = level.objects[cc.x][cc.y]; cobj; cobj = nobj) {
2091 nobj = cobj->nexthere;
2093 if (Is_container(cobj)) {
2095 c = ynq(safe_qbuf(qbuf, "There is ", " here, loot it?",
2096 cobj, doname, ansimpleoname,
2099 c = ynq(safe_qbuf(qbuf, "
\82±
\82±
\82É
\82Í", "
\82ª
\82 \82é
\81C
\8aJ
\82¯
\82Ü
\82·
\82©
\81H",
2100 cobj, doname, ansimpleoname,
2109 timepassed |= do_loot_cont(&cobj, 1, 1);
2111 /* chest trap or magic bag explosion or <esc> */
2118 } else if (IS_GRAVE(levl[cc.x][cc.y].typ)) {
2120 You("need to dig up the grave to effectively loot it...");
2122 You("
\95æ
\8dr
\82ç
\82µ
\82ð
\82·
\82é
\82É
\82Í
\8c@
\82ç
\82È
\82
\82Ä
\82Í
\81D
\81D
\81D");
2126 * 3.3.1 introduced directional looting for some things.
2129 if (c != 'y' && mon_beside(u.ux, u.uy)) {
2131 if (!get_adjacent_loc("Loot in what direction?",
2133 if (!get_adjacent_loc("
\82Ç
\82Ì
\95û
\8cü
\82ð
\92²
\82×
\82é
\81H",
2135 "Invalid loot location", u.ux, u.uy, &cc))
2137 "
\96³
\8cø
\82È
\95û
\8cü", u.ux, u.uy, &cc))
2139 if (cc.x == u.ux && cc.y == u.uy) {
2141 if (container_at(cc.x, cc.y, FALSE))
2147 You("%s to loot on the %s.", dont_find_anything,
2148 ceiling(cc.x, cc.y));
2150 You("%s
\82ð
\92²
\82×
\82½
\82ª
\89½
\82à
\82Ý
\82Â
\82©
\82ç
\82È
\82©
\82Á
\82½
\81D",
2151 ceiling(cc.x, cc.y));
2156 mtmp = m_at(cc.x, cc.y);
2158 timepassed = loot_mon(mtmp, &prev_inquiry, &prev_loot);
2159 /* always use a turn when choosing a direction is impaired,
2160 even if you've successfully targetted a saddled creature
2161 and then answered "no" to the "remove its saddle?" prompt */
2162 if (Confusion || Stunned)
2165 /* Preserve pre-3.3.1 behaviour for containers.
2166 * Adjust this if-block to allow container looting
2167 * from one square away to change that in the future.
2170 if (container_at(cc.x, cc.y, FALSE)) {
2173 You_cant("loot anything %sthere with %s in the way.",
2174 prev_inquiry ? "else " : "", mon_nam(mtmp));
2176 pline("%s
\82ª
\82¢
\82é
\82Ì
\82Å%s
\94 \82ð
\8aJ
\82¯
\82ç
\82ê
\82È
\82¢
\81D",
2177 mon_nam(mtmp), prev_inquiry ? "
\82Ù
\82©
\82Ì" : "");
2182 You("have to be at a container to loot it.");
2184 You("
\82Í
\94 \82ð
\8aJ
\82¯
\82é
\82½
\82ß
\82É
\82Í
\93¯
\82¶
\88Ê
\92u
\82É
\82¢
\82È
\82¯
\82ê
\82Î
\82È
\82ç
\82È
\82¢
\81D");
2189 You("%s %sthere to loot.", dont_find_anything,
2190 (prev_inquiry || prev_loot) ? "else " : "");
2192 pline("
\82±
\82±
\82É
\82Í%s
\8aJ
\82¯
\82ç
\82ê
\82é
\82à
\82Ì
\82Í
\82È
\82¢
\81D",
2193 (prev_inquiry || prev_loot) ? "
\82Ù
\82©
\82É" : "");
2198 } else if (c != 'y' && c != 'n') {
2200 You("%s %s to loot.", dont_find_anything,
2201 underfoot ? "here" : "there");
2203 pline("%s
\82É
\82Í
\8aJ
\82¯
\82ç
\82ê
\82é
\82à
\82Ì
\82Í
\82È
\82¢
\81D",
2204 underfoot ? "
\82±
\82±" : "
\82»
\82±");
2210 /* called when attempting to #loot while confused */
2214 struct obj *goldob = 0, *coffers, *otmp, boxdummy;
2217 int n, x = u.ux, y = u.uy;
2220 /* n objects: 1/(n+1) chance per object plus 1/(n+1) to fall off end
2222 for (n = inv_cnt(TRUE), otmp = invent; otmp; --n, otmp = otmp->nobj)
2225 prinv("You find old loot:", otmp, 0L);
2227 prinv("
\88È
\91O
\8aJ
\82¯
\82½
\82à
\82Ì:", otmp, 0L);
2233 /* find a money object to mess with */
2234 for (goldob = invent; goldob; goldob = goldob->nobj)
2235 if (goldob->oclass == COIN_CLASS) {
2236 contribution = ((long) rnd(5) * goldob->quan + 4L) / 5L;
2237 if (contribution < goldob->quan)
2238 goldob = splitobj(goldob, contribution);
2244 if (!IS_THRONE(levl[x][y].typ)) {
2246 /* the dropped gold might have fallen to lower level */
2249 pline("Ok, now there is loot here.");
2251 pline("
\83I
\81[
\83P
\81[
\81C
\82±
\82±
\82É
\98d
\98G
\82ð
\92u
\82¢
\82Ä
\82¨
\82±
\82¤
\81D");
2253 /* find original coffers chest if present, otherwise use nearest one
2256 for (coffers = fobj; coffers; coffers = coffers->nobj)
2257 if (coffers->otyp == CHEST) {
2258 if (coffers->spe == 2)
2259 break; /* a throne room chest */
2261 || distu(coffers->ox, coffers->oy)
2262 < distu(otmp->ox, otmp->oy))
2263 otmp = coffers; /* remember closest ordinary chest */
2270 verbalize("Thank you for your contribution to reduce the debt.");
2272 verbalize("
\90Ô
\8e\9a\8d\91\8dÂ
\95Ô
\8dÏ
\82Ì
\82½
\82ß
\82Ì
\8añ
\95t
\82É
\8a´
\8eÓ
\82µ
\82Ü
\82·
\81D");
2274 (void) add_to_container(coffers, goldob);
2275 coffers->owt = weight(coffers);
2276 coffers->cknown = 0;
2277 if (!coffers->olocked) {
2278 boxdummy = zeroobj, boxdummy.otyp = SPE_WIZARD_LOCK;
2279 (void) boxlock(coffers, &boxdummy);
2281 } else if (levl[x][y].looted != T_LOOTED
2282 && (mon = makemon(courtmon(), x, y, NO_MM_FLAGS)) != 0) {
2284 add_to_minv(mon, goldob);
2286 pline("The exchequer accepts your contribution.");
2288 pline("
\8dà
\96±
\8fÈ
\82Í
\82 \82È
\82½
\82Ì
\8añ
\95t
\82ð
\8eó
\82¯
\82Æ
\82Á
\82½
\81D");
2290 levl[x][y].looted = T_LOOTED;
2293 You("drop %s.", doname(goldob));
2295 You("%s
\82ð
\97\8e\82µ
\82½
\81D", doname(goldob));
2302 /* loot_mon() returns amount of time passed.
2305 loot_mon(mtmp, passed_info, prev_loot)
2315 /* 3.3.1 introduced the ability to remove saddle from a steed.
2316 * *passed_info is set to TRUE if a loot query was given.
2317 * *prev_loot is set to TRUE if something was actually acquired in here.
2319 if (mtmp && mtmp != u.usteed && (otmp = which_armor(mtmp, W_SADDLE))) {
2325 Sprintf(qbuf, "Do you want to remove the saddle from %s?",
2326 x_monnam(mtmp, ARTICLE_THE, (char *) 0,
2327 SUPPRESS_SADDLE, FALSE));
2329 Sprintf(qbuf, "%s
\82©
\82ç
\88Æ
\82ð
\82Í
\82¸
\82µ
\82Ü
\82·
\82©
\81H",
2330 x_monnam(mtmp, ARTICLE_THE, (char *) 0,
2331 SUPPRESS_SADDLE, FALSE));
2333 if ((c = yn_function(qbuf, ynqchars, 'n')) == 'y') {
2334 if (nolimbs(youmonst.data)) {
2336 You_cant("do that without limbs."); /* not body_part(HAND) */
2338 You_cant("
\8eè
\82ª
\82È
\82¢
\82Æ
\82Å
\82«
\82È
\82¢
\81D");
2344 You("can't. The saddle seems to be stuck to %s.",
2346 pline("
\88Æ
\82Í%s
\82É
\82
\82Á
\82Â
\82¢
\82Ä
\82¢
\82é
\82æ
\82¤
\82¾
\81D",
2347 x_monnam(mtmp, ARTICLE_THE, (char *) 0,
2348 SUPPRESS_SADDLE, FALSE));
2349 /* the attempt costs you time */
2352 obj_extract_self(otmp);
2353 if ((unwornmask = otmp->owornmask) != 0L) {
2354 mtmp->misc_worn_check &= ~unwornmask;
2355 otmp->owornmask = 0L;
2356 update_mon_intrinsics(mtmp, otmp, FALSE, FALSE);
2359 otmp = hold_another_object(otmp, "You drop %s!", doname(otmp),
2361 otmp = hold_another_object(otmp, "%s
\82ð
\97\8e\82Æ
\82µ
\82½
\81I", doname(otmp),
2364 timepassed = rnd(3);
2367 } else if (c == 'q') {
2371 /* 3.4.0 introduced ability to pick things up from swallower's stomach */
2373 int count = passed_info ? *passed_info : 0;
2375 timepassed = pickup(count);
2381 * Decide whether an object being placed into a magic bag will cause
2382 * it to explode. If the object is a bag itself, check recursively.
2385 mbag_explodes(obj, depthin)
2389 /* these won't cause an explosion when they're empty */
2390 if ((obj->otyp == WAN_CANCELLATION || obj->otyp == BAG_OF_TRICKS)
2394 /* odds: 1/1, 2/2, 3/4, 4/8, 5/16, 6/32, 7/64, 8/128, 9/128, 10/128,... */
2395 if ((Is_mbag(obj) || obj->otyp == WAN_CANCELLATION)
2396 && (rn2(1 << (depthin > 7 ? 7 : depthin)) <= depthin))
2398 else if (Has_contents(obj)) {
2401 for (otmp = obj->cobj; otmp; otmp = otmp->nobj)
2402 if (mbag_explodes(otmp, depthin + 1))
2409 boh_loss(container, held)
2410 struct obj *container;
2413 /* sometimes toss objects if a cursed magic bag */
2414 if (Is_mbag(container) && container->cursed && Has_contents(container)) {
2416 struct obj *curr, *otmp;
2418 for (curr = container->cobj; curr; curr = otmp) {
2421 obj_extract_self(curr);
2422 loss += mbag_item_gone(held, curr);
2430 /* Returns: -1 to stop, 1 item was inserted, 0 item was not inserted. */
2433 register struct obj *obj;
2435 boolean floor_container = !carried(current_container);
2436 boolean was_unpaid = FALSE;
2439 if (!current_container) {
2440 impossible("<in> no current_container?");
2442 } else if (obj == uball || obj == uchain) {
2444 You("must be kidding.");
2446 pline("
\82²
\8fç
\92k
\82ð
\81D");
2448 } else if (obj == current_container) {
2450 pline("That would be an interesting topological exercise.");
2452 pline("
\82»
\82ê
\82Í
\8b»
\96¡
\82ð
\82»
\82»
\82ç
\82ê
\82é
\83g
\83|
\83\8d\83W
\81[
\82Ì
\96â
\91è
\82¾
\81D");
2454 } else if (obj->owornmask & (W_ARMOR | W_ACCESSORY)) {
2456 Norep("You cannot %s %s you are wearing.",
2457 Icebox ? "refrigerate" : "stash", something);
2459 Norep("
\90g
\82É
\82Â
\82¯
\82Ä
\82¢
\82é
\82à
\82Ì
\82ð%s
\82±
\82Æ
\82Í
\82Å
\82«
\82È
\82¢
\81D",
2460 Icebox ? "
\97â
\93\80\82·
\82é" : "
\82µ
\82Ü
\82¤");
2463 } else if ((obj->otyp == LOADSTONE) && obj->cursed) {
2466 pline_The("stone%s won't leave your person.", plur(obj->quan));
2468 pline("
\82Ç
\82¤
\82¢
\82¤
\82í
\82¯
\82©
\82»
\82Ì
\90Î
\82ð
\82µ
\82Ü
\82¤
\82±
\82Æ
\82Í
\82Å
\82«
\82È
\82¢
\81D");
2470 } else if (obj->otyp == AMULET_OF_YENDOR
2471 || obj->otyp == CANDELABRUM_OF_INVOCATION
2472 || obj->otyp == BELL_OF_OPENING
2473 || obj->otyp == SPE_BOOK_OF_THE_DEAD) {
2474 /* Prohibit Amulets in containers; if you allow it, monsters can't
2475 * steal them. It also becomes a pain to check to see if someone
2476 * has the Amulet. Ditto for the Candelabrum, the Bell and the Book.
2479 pline("%s cannot be confined in such trappings.", The(xname(obj)));
2481 pline("%s
\82Í
\8bl
\82ß
\82é
\82±
\82Æ
\82Í
\82Å
\82«
\82È
\82¢
\81D", The(xname(obj)));
2483 } else if (obj->otyp == LEASH && obj->leashmon != 0) {
2485 pline("%s attached to your pet.", Tobjnam(obj, "are"));
2487 pline("%s
\82Í
\83y
\83b
\83g
\82É
\95t
\82¯
\82ç
\82ê
\82Ä
\82¢
\82é
\81D", xname(obj));
2489 } else if (obj == uwep) {
2494 setuwep((struct obj *) 0);
2495 /* This uwep check is obsolete. It dates to 3.0 and earlier when
2496 * unwielding Firebrand would be fatal in hell if hero had no other
2497 * fire resistance. Life-saving would force it to be re-wielded.
2500 return 0; /* unwielded, died, rewielded */
2501 } else if (obj == uswapwep) {
2502 setuswapwep((struct obj *) 0);
2503 } else if (obj == uquiver) {
2504 setuqwep((struct obj *) 0);
2507 if (fatal_corpse_mistake(obj, FALSE))
2510 /* boxes, boulders, and big statues can't fit into any container */
2511 if (obj->otyp == ICE_BOX || Is_box(obj) || obj->otyp == BOULDER
2512 || (obj->otyp == STATUE && bigmonst(&mons[obj->corpsenm]))) {
2514 * xname() uses a static result array. Save obj's name
2515 * before current_container's name is computed. Don't
2516 * use the result of strcpy() within You() --- the order
2517 * of evaluation of the parameters is undefined.
2519 Strcpy(buf, the(xname(obj)));
2521 You("cannot fit %s into %s.", buf, the(xname(current_container)));
2523 pline("%s
\82ð%s
\82É
\8bl
\82ß
\8d\9e\82Þ
\82±
\82Æ
\82Í
\82Å
\82«
\82È
\82¢
\81D", buf, the(xname(current_container)));
2529 if (obj_is_burning(obj)) /* this used to be part of freeinv() */
2530 (void) snuff_lit(obj);
2532 if (floor_container && costly_spot(u.ux, u.uy)) {
2533 /* defer gold until after put-in message */
2534 if (obj->oclass != COIN_CLASS) {
2535 /* sellobj() will take an unpaid item off the shop bill */
2536 was_unpaid = obj->unpaid ? TRUE : FALSE;
2537 /* don't sell when putting the item into your own container,
2538 * but handle billing correctly */
2539 sellobj_state(current_container->no_charge
2540 ? SELL_DONTSELL : SELL_DELIBERATE);
2541 sellobj(obj, u.ux, u.uy);
2542 sellobj_state(SELL_NORMAL);
2545 if (Icebox && !age_is_relative(obj)) {
2546 obj->age = monstermoves - obj->age; /* actual age */
2547 /* stop any corpse timeouts when frozen */
2548 if (obj->otyp == CORPSE && obj->timed) {
2549 long rot_alarm = stop_timer(ROT_CORPSE, obj_to_any(obj));
2551 (void) stop_timer(REVIVE_MON, obj_to_any(obj));
2552 /* mark a non-reviving corpse as such */
2556 } else if (Is_mbag(current_container) && mbag_explodes(obj, 0)) {
2557 /* explicitly mention what item is triggering the explosion */
2559 pline("As you put %s inside, you are blasted by a magical explosion!",
2561 pline("%s
\82ð
\92\86\82É
\93ü
\82ê
\82é
\82Æ
\81C
\82 \82È
\82½
\82Í
\96\82\96@
\82Ì
\94\9a\94
\82ð
\97\81\82Ñ
\82½
\81I",
2563 /* did not actually insert obj yet */
2565 addtobill(obj, FALSE, FALSE, TRUE);
2566 obfree(obj, (struct obj *) 0);
2567 /* if carried, shop goods will be flagged 'unpaid' and obfree() will
2568 handle bill issues, but if on floor, we need to put them on bill
2569 before deleting them (non-shop items will be flagged 'no_charge') */
2571 && costly_spot(current_container->ox, current_container->oy)) {
2572 struct obj save_no_charge;
2574 save_no_charge.no_charge = current_container->no_charge;
2575 addtobill(current_container, FALSE, FALSE, FALSE);
2576 /* addtobill() clears no charge; we need to set it back
2577 so that useupf() doesn't double bill */
2578 current_container->no_charge = save_no_charge.no_charge;
2580 delete_contents(current_container);
2581 if (!floor_container)
2582 useup(current_container);
2583 else if (obj_here(current_container, u.ux, u.uy))
2584 useupf(current_container, current_container->quan);
2586 panic("in_container: bag not found.");
2589 losehp(d(6, 6), "magical explosion", KILLED_BY_AN);
2591 losehp(d(6, 6), "
\96\82\96@
\82Ì
\94\9a\94
\82Å", KILLED_BY_AN);
2592 current_container = 0; /* baggone = TRUE; */
2595 if (current_container) {
2596 Strcpy(buf, the(xname(current_container)));
2598 You("put %s into %s.", doname(obj), buf);
2600 You("%s
\82ð%s
\82Ì
\92\86\82É
\82µ
\82Ü
\82Á
\82½
\81D", doname(obj), buf);
2602 /* gold in container always needs to be added to credit */
2603 if (floor_container && obj->oclass == COIN_CLASS)
2604 sellobj(obj, current_container->ox, current_container->oy);
2605 (void) add_to_container(current_container, obj);
2606 current_container->owt = weight(current_container);
2608 /* gold needs this, and freeinv() many lines above may cause
2609 * the encumbrance to disappear from the status, so just always
2610 * update status immediately.
2613 return (current_container ? 1 : -1);
2616 /* askchain() filter used by in_container();
2617 * returns True if the container is intact and 'obj' isn't it, False if
2618 * container is gone (magic bag explosion) or 'obj' is the container itself;
2619 * also used by getobj() when picking a single item to stash
2625 return (current_container && obj != current_container);
2628 /* Returns: -1 to stop, 1 item was removed, 0 item was not removed. */
2631 register struct obj *obj;
2633 register struct obj *otmp;
2634 boolean is_gold = (obj->oclass == COIN_CLASS);
2638 if (!current_container) {
2639 impossible("<out> no current_container?");
2641 } else if (is_gold) {
2642 obj->owt = weight(obj);
2645 if (obj->oartifact && !touch_artifact(obj, &youmonst))
2648 if (fatal_corpse_mistake(obj, FALSE))
2652 if ((res = lift_object(obj, current_container, &count, FALSE)) <= 0)
2655 if (obj->quan != count && obj->otyp != LOADSTONE)
2656 obj = splitobj(obj, count);
2658 /* Remove the object from the list. */
2659 obj_extract_self(obj);
2660 current_container->owt = weight(current_container);
2663 removed_from_icebox(obj);
2665 if (!obj->unpaid && !carried(current_container)
2666 && costly_spot(current_container->ox, current_container->oy)) {
2667 obj->ox = current_container->ox;
2668 obj->oy = current_container->oy;
2669 addtobill(obj, FALSE, FALSE, FALSE);
2672 pick_pick(obj); /* shopkeeper feedback */
2675 loadlev = near_capacity();
2676 prinv(loadlev ? ((loadlev < MOD_ENCUMBER)
2678 ? "You have a little trouble removing"
2680 ? "
\82ð
\89^
\82Ô
\82Ì
\82Í
\8f
\81X
\8d¢
\93ï
\82¾
\81D"
2682 : "You have much trouble removing")
2684 : "
\82ð
\89^
\82Ô
\82Ì
\82Í
\82©
\82È
\82è
\8d¢
\93ï
\82¾
\81D")
2689 bot(); /* update character's gold piece count immediately */
2694 /* taking a corpse out of an ice box needs a couple of adjustments */
2696 removed_from_icebox(obj)
2699 if (!age_is_relative(obj)) {
2700 obj->age = monstermoves - obj->age; /* actual age */
2701 if (obj->otyp == CORPSE)
2702 start_corpse_timeout(obj);
2706 /* an object inside a cursed bag of holding is being destroyed */
2708 mbag_item_gone(held, item)
2717 pline("%s %s vanished!", Doname2(item), otense(item, "have"));
2719 pline("%s
\82Í
\8fÁ
\82¦
\8b\8e\82Á
\82½
\81I", Doname2(item));
2722 You("%s %s disappear!", Blind ? "notice" : "see", doname(item));
2724 You("%s
\82ª
\8c©
\82¦
\82È
\82
\82È
\82é
\82Ì%s
\81D", doname(item), Blind ? "
\82É
\8bC
\82Ã
\82¢
\82½" : "
\82ð
\8c©
\82½");
2727 if (*u.ushops && (shkp = shop_keeper(*u.ushops)) != 0) {
2728 if (held ? (boolean) item->unpaid : costly_spot(u.ux, u.uy))
2729 loss = stolen_value(item, u.ux, u.uy, (boolean) shkp->mpeaceful,
2732 obfree(item, (struct obj *) 0);
2736 /* used for #loot/apply, #tip, and final disclosure */
2738 observe_quantum_cat(box, makecat, givemsg)
2740 boolean makecat, givemsg;
2743 static NEARDATA const char sc[] = "Schroedinger's Cat";
2745 static NEARDATA const char sc[] = "
\83V
\83\85\83\8c\83f
\83B
\83\93\83K
\81[
\82Ì
\94L";
2746 struct obj *deadcat;
2747 struct monst *livecat = 0;
2749 boolean itsalive = !rn2(2);
2751 if (get_obj_location(box, &ox, &oy, 0))
2752 box->ox = ox, box->oy = oy; /* in case it's being carried */
2754 /* this isn't really right, since any form of observation
2755 (telepathic or monster/object/food detection) ought to
2756 force the determination of alive vs dead state; but basing it
2757 just on opening or disclosing the box is much simpler to cope with */
2759 /* SchroedingersBox already has a cat corpse in it */
2760 deadcat = box->cobj;
2763 livecat = makemon(&mons[PM_HOUSECAT], box->ox, box->oy,
2764 NO_MINVENT | MM_ADJACENTOK);
2766 livecat->mpeaceful = 1;
2767 set_malign(livecat);
2769 if (!canspotmon(livecat))
2771 You("think %s brushed your %s.", something,
2774 You("%s
\82ª
\82 \82È
\82½
\82Ì%s
\82ð
\82
\82·
\82®
\82Á
\82½
\82Æ
\8ev
\82Á
\82½
\81D", something,
2779 pline("%s inside the box is still alive!",
2782 pline("
\94 \82Ì
\82È
\82©
\82Ì%s
\82Í
\82Ü
\82¾
\90¶
\82«
\82Ä
\82¢
\82é
\81I",
2786 (void) christen_monst(livecat, sc);
2788 obj_extract_self(deadcat);
2789 obfree(deadcat, (struct obj *) 0), deadcat = 0;
2791 box->owt = weight(box);
2795 box->spe = 0; /* now an ordinary box (with a cat corpse inside) */
2797 /* set_corpsenm() will start the rot timer that was removed
2798 when makemon() created SchroedingersBox; start it from
2799 now rather than from when this special corpse got created */
2800 deadcat->age = monstermoves;
2801 set_corpsenm(deadcat, PM_HOUSECAT);
2802 deadcat = oname(deadcat, sc);
2806 pline_The("%s inside the box is dead!",
2807 Hallucination ? rndmonnam((char *) 0) : "housecat");
2809 pline_The("
\94 \82Ì
\92\86\82Ì%s
\82Í
\8e\80\82ñ
\82Å
\82¢
\82é
\81I",
2810 Hallucination ? rndmonnam((char *) 0) : "
\94L");
2819 /* used by askchain() to check for magic bag explosion */
2822 int FDECL((*fn), (OBJ_P));
2824 /* result is only meaningful while use_container() is executing */
2825 return ((fn == in_container || fn == out_container)
2826 && !current_container);
2830 explain_container_prompt(more_containers)
2831 boolean more_containers;
2833 static const char *const explaintext[] = {
2835 "Container actions:",
2837 " : -- Look: examine contents",
2838 " o -- Out: take things out",
2839 " i -- In: put things in",
2840 " b -- Both: first take things out, then put things in",
2841 " r -- Reversed: put things in, then take things out",
2842 " s -- Stash: put one item in", "",
2843 " n -- Next: loot next selected container",
2844 " q -- Quit: finished",
2845 " ? -- Help: display this text.",
2848 "
\93ü
\82ê
\95¨
\82Ö
\82Ì
\8ds
\93®
\81F",
2850 " : -- Look:
\92\86\90g
\82ð
\92²
\82×
\82é",
2851 " o -- Out:
\95¨
\82ð
\8fo
\82·",
2852 " i -- In:
\95¨
\82ð
\93ü
\82ê
\82é",
2853 " b -- Both:
\82Ü
\82¸
\95¨
\82ð
\8fo
\82µ
\81A
\82»
\82ê
\82©
\82ç
\95¨
\82ð
\93ü
\82ê
\82é",
2854 " r -- Reversed:
\95¨
\82ð
\93ü
\82ê
\81A
\82»
\82ê
\82©
\82ç
\95¨
\82ð
\8fo
\82·",
2855 " s -- Stash:
\95¨
\82ð
\88ê
\82Â
\93ü
\82ê
\82é",
2856 " n -- Next:
\8e\9f\82É
\91I
\82ñ
\82¾
\93ü
\82ê
\95¨
\82ð
\92²
\82×
\82é",
2857 " q -- Quit:
\89½
\82à
\82µ
\82È
\82¢",
2858 " ? -- Help:
\82±
\82ê
\82ð
\95\
\8e¦
\82·
\82é",
2862 const char *const *txtpp;
2865 /* "Do what with <container>? [:oibrsq or ?] (q)" */
2866 if ((win = create_nhwindow(NHW_TEXT)) != WIN_ERR) {
2867 for (txtpp = explaintext; *txtpp; ++txtpp) {
2868 if (!more_containers && !strncmp(*txtpp, " n ", 3))
2870 putstr(win, 0, *txtpp);
2872 display_nhwindow(win, FALSE);
2873 destroy_nhwindow(win);
2880 if (nohands(youmonst.data)) {
2882 You("have no hands!"); /* not `body_part(HAND)' */
2884 pline("
\82 \82È
\82½
\82É
\82Í
\8eè
\82ª
\82È
\82¢
\81I"); /* not `body_part(HAND)' */
2887 } else if (!freehand()) {
2889 You("have no free %s.", body_part(HAND));
2891 You("%s
\82Ì
\8e©
\97R
\82ª
\8cø
\82©
\82È
\82¢
\81D", body_part(HAND));
2897 static const char stashable[] = { ALLOW_COUNT, COIN_CLASS, ALL_CLASSES, 0 };
2900 use_container(objp, held, more_containers)
2903 boolean more_containers; /* True iff #loot multiple and this isn't last one */
2905 struct obj *otmp, *obj = *objp;
2906 boolean quantum_cat, cursed_mbag, loot_out, loot_in, loot_in_first,
2907 stash_one, inokay, outokay, outmaybe;
2908 char c, emptymsg[BUFSZ], qbuf[QBUFSZ], pbuf[QBUFSZ], xbuf[QBUFSZ];
2912 abort_looting = FALSE;
2920 pline("%s locked.", Tobjnam(obj, "are"));
2922 pline("%s
\82Í
\8c®
\82ª
\82©
\82©
\82Á
\82Ä
\82¢
\82é
\81D", xname(obj));
2925 You("must put it down to unlock.");
2927 if (held) pline("
\89º
\82É
\92u
\82©
\82È
\82¢
\82±
\82Æ
\82É
\82Í
\8c®
\82ð
\82Í
\82¸
\82¹
\82È
\82¢
\81D");
2930 } else if (obj->otrapped) {
2933 You("open %s...", the(xname(obj)));
2935 You("%s
\82ð
\8aJ
\82¯
\82½
\81D
\81D
\81D", the(xname(obj)));
2937 (void) chest_trap(obj, HAND, FALSE);
2938 /* even if the trap fails, you've used up this turn */
2939 if (multi >= 0) { /* in case we didn't become paralyzed */
2942 multi_reason = "opening a container";
2944 multi_reason = "
\94 \82ð
\8aJ
\82¯
\82Ä
\82¢
\82é
\8e\9e\82É";
2947 abort_looting = TRUE;
2952 current_container = obj; /* for use by in/out_container */
2954 * From here on out, all early returns go through 'containerdone:'.
2957 /* check for Schroedinger's Cat */
2958 quantum_cat = SchroedingersBox(current_container);
2960 observe_quantum_cat(current_container, TRUE, TRUE);
2964 cursed_mbag = Is_mbag(current_container)
2965 && current_container->cursed
2966 && Has_contents(current_container);
2968 && (loss = boh_loss(current_container, held)) != 0) {
2971 You("owe %ld %s for lost merchandise.", loss, currency(loss));
2973 You("
\8e¸
\82Á
\82½
\8f¤
\95i
\82Ì
\82½
\82ß
\82É%ld%s
\82Ì
\95\89\8dÂ
\82ð
\95\89\82Á
\82½
\81D", loss, currency(loss));
2974 current_container->owt = weight(current_container);
2976 inokay = (invent != 0
2977 && !(invent == current_container && !current_container->nobj));
2978 outokay = Has_contents(current_container);
2979 if (!outokay) /* preformat the empty-container message */
2981 Sprintf(emptymsg, "%s is %sempty.", Ysimple_name2(current_container),
2982 (quantum_cat || cursed_mbag) ? "now " : "");
2984 Sprintf(emptymsg, "%s
\82Í%s
\8bó
\82Á
\82Û
\82¾
\81D", Ysimple_name2(current_container),
2985 (quantum_cat || cursed_mbag) ? "
\8d¡
\82Í" : "");
2989 * What-to-do prompt's list of possible actions:
2990 * always include the look-inside choice (':');
2991 * include the take-out choice ('o') if container
2992 * has anything in it or if player doesn't yet know
2993 * that it's empty (latter can change on subsequent
2994 * iterations if player picks ':' response);
2995 * include the put-in choices ('i','s') if hero
2996 * carries any inventory (including gold);
2997 * include do-both when 'o' is available, even if
2998 * inventory is empty--taking out could alter that;
2999 * include do-both-reversed when 'i' is available,
3000 * even if container is empty--for similar reason;
3001 * include the next container choice ('n') when
3002 * relevant, and make it the default;
3003 * always include the quit choice ('q'), and make
3004 * it the default if there's no next containter;
3005 * include the help choice (" or ?") if `cmdassist'
3006 * run-time option is set;
3007 * (Player can pick any of (o,i,b,r,n,s,?) even when
3008 * they're not listed among the available actions.)
3010 * Do what with <the/your/Shk's container>? [:oibrs nq or ?] (q)
3012 * <The/Your/Shk's container> is empty. Do what with it? [:irs nq or ?]
3014 for (;;) { /* repeats iff '?' or ":' gets chosen */
3015 outmaybe = (outokay || !current_container->cknown);
3018 (void) safe_qbuf(qbuf, (char *) 0, " is empty. Do what with it?",
3019 current_container, Yname2, Ysimple_name2,
3022 (void) safe_qbuf(qbuf, (char *) 0, "
\82Í
\8bó
\82¾
\81D
\82Ç
\82¤
\82·
\82é
\81H",
3023 current_container, Yname2, Ysimple_name2,
3028 (void) safe_qbuf(qbuf, "Do what with ", "?", current_container,
3029 yname, ysimple_name, "it");
3031 (void) safe_qbuf(qbuf, (char *) 0, "
\82ð
\82Ç
\82¤
\82·
\82é
\81H", current_container,
3032 yname, ysimple_name, "
\82±
\82ê");
3034 /* ask player about what to do with this container */
3035 if (flags.menu_style == MENU_PARTIAL
3036 || flags.menu_style == MENU_FULL) {
3037 if (!inokay && !outmaybe) {
3038 /* nothing to take out, nothing to put in;
3039 trying to do both will yield proper feedback */
3042 c = in_or_out_menu(qbuf, current_container, outmaybe, inokay,
3043 (boolean) (used != 0), more_containers);
3045 } else { /* TRADITIONAL or COMBINATION */
3046 xbuf[0] = '\0'; /* list of extra acceptable responses */
3047 Strcpy(pbuf, ":"); /* look inside */
3048 Strcat(outmaybe ? pbuf : xbuf, "o"); /* take out */
3049 Strcat(inokay ? pbuf : xbuf, "i"); /* put in */
3050 Strcat(outmaybe ? pbuf : xbuf, "b"); /* both */
3051 Strcat(inokay ? pbuf : xbuf, "rs"); /* reversed, stash */
3052 Strcat(pbuf, " "); /* separator */
3053 Strcat(more_containers ? pbuf : xbuf, "n"); /* next container */
3054 Strcat(pbuf, "q"); /* quit */
3055 if (iflags.cmdassist)
3056 /* this unintentionally allows user to answer with 'o' or
3057 'r'; fortunately, those are already valid choices here */
3058 Strcat(pbuf, " or ?"); /* help */
3062 Strcat(strcat(pbuf, "\033"), xbuf);
3063 c = yn_function(qbuf, pbuf, more_containers ? 'n' : 'q');
3064 } /* PARTIAL|FULL vs other modes */
3067 explain_container_prompt(more_containers);
3068 } else if (c == ':') { /* note: will set obj->cknown */
3069 if (!current_container->cknown)
3070 used = 1; /* gaining info */
3071 container_contents(current_container, FALSE, FALSE, TRUE);
3074 } /* loop until something other than '?' or ':' is picked */
3077 abort_looting = TRUE;
3078 if (c == 'n' || c == 'q') /* [not strictly needed; falling thru works] */
3080 loot_out = (c == 'o' || c == 'b' || c == 'r');
3081 loot_in = (c == 'i' || c == 'b' || c == 'r');
3082 loot_in_first = (c == 'r'); /* both, reversed */
3083 stash_one = (c == 's');
3085 /* out-only or out before in */
3086 if (loot_out && !loot_in_first) {
3087 if (!Has_contents(current_container)) {
3088 pline1(emptymsg); /* <whatever> is empty. */
3089 if (!current_container->cknown)
3091 current_container->cknown = 1;
3093 add_valid_menu_class(0); /* reset */
3094 if (flags.menu_style == MENU_TRADITIONAL)
3095 used |= traditional_loot(FALSE);
3097 used |= (menu_loot(0, FALSE) > 0);
3098 add_valid_menu_class(0);
3102 if ((loot_in || stash_one)
3103 && (!invent || (invent == current_container && !invent->nobj))) {
3105 You("don't have anything%s to %s.", invent ? " else" : "",
3106 stash_one ? "stash" : "put in");
3108 You("%s
\93ü
\82ê
\82é
\82à
\82Ì
\82ª
\82È
\82¢
\81D", invent ? "
\91¼
\82É" : "");
3110 loot_in = stash_one = FALSE;
3114 * Gone: being nice about only selecting food if we know we are
3115 * putting things in an ice chest.
3118 add_valid_menu_class(0); /* reset */
3119 if (flags.menu_style == MENU_TRADITIONAL)
3120 used |= traditional_loot(TRUE);
3122 used |= (menu_loot(0, TRUE) > 0);
3123 add_valid_menu_class(0);
3124 } else if (stash_one) {
3125 /* put one item into container */
3126 if ((otmp = getobj(stashable, "stash")) != 0) {
3127 if (in_container(otmp)) {
3130 /* couldn't put selected item into container for some
3131 reason; might need to undo splitobj() */
3132 (void) unsplitobj(otmp);
3136 /* putting something in might have triggered magic bag explosion */
3137 if (!current_container)
3141 if (loot_out && loot_in_first) {
3142 if (!Has_contents(current_container)) {
3143 pline1(emptymsg); /* <whatever> is empty. */
3144 if (!current_container->cknown)
3146 current_container->cknown = 1;
3148 add_valid_menu_class(0); /* reset */
3149 if (flags.menu_style == MENU_TRADITIONAL)
3150 used |= traditional_loot(FALSE);
3152 used |= (menu_loot(0, FALSE) > 0);
3153 add_valid_menu_class(0);
3159 /* Not completely correct; if we put something in without knowing
3160 whatever was already inside, now we suddenly do. That can't
3161 be helped unless we want to track things item by item and then
3162 deal with containers whose contents are "partly known". */
3163 if (current_container)
3164 current_container->cknown = 1;
3168 *objp = current_container; /* might have become null */
3169 if (current_container)
3170 current_container = 0; /* avoid hanging on to stale pointer */
3172 abort_looting = TRUE;
3176 /* loot current_container (take things out or put things in), by prompting */
3178 traditional_loot(put_in)
3181 int FDECL((*actionfunc), (OBJ_P)), FDECL((*checkfunc), (OBJ_P));
3182 struct obj **objlist;
3183 char selection[MAXOCLASSES + 10]; /* +10: room for B,U,C,X plus slop */
3185 boolean one_by_one, allflag;
3186 int used = 0, menu_on_request = 0;
3192 action = "
\93ü
\82ê
\82é";
3194 actionfunc = in_container;
3198 action = "take out";
3200 action = "
\8eæ
\82è
\8fo
\82·";
3201 objlist = &(current_container->cobj);
3202 actionfunc = out_container;
3203 checkfunc = (int FDECL((*), (OBJ_P))) 0;
3206 if (query_classes(selection, &one_by_one, &allflag, action, *objlist,
3207 FALSE, &menu_on_request)) {
3208 if (askchain(objlist, (one_by_one ? (char *) 0 : selection), allflag,
3209 actionfunc, checkfunc, 0, action))
3211 } else if (menu_on_request < 0) {
3212 used = (menu_loot(menu_on_request, put_in) > 0);
3217 /* loot current_container (take things out or put things in), using a menu */
3219 menu_loot(retry, put_in)
3223 int n, i, n_looted = 0;
3224 boolean all_categories = TRUE, loot_everything = FALSE;
3227 const char *action = put_in ? "Put in" : "Take out";
3229 const char *action = put_in ? "
\93ü
\82ê
\82é" : "
\8eæ
\82è
\8fo
\82·";
3230 struct obj *otmp, *otmp2;
3231 menu_item *pick_list;
3236 all_categories = (retry == -2);
3237 } else if (flags.menu_style == MENU_FULL) {
3238 all_categories = FALSE;
3240 Sprintf(buf, "%s what type of objects?", action);
3242 Sprintf(buf, "
\82Ç
\82Ì
\8eí
\97Þ
\82Ì
\82à
\82Ì
\82ð%s
\81H", action);
3243 mflags = (ALL_TYPES | UNPAID_TYPES | BUCX_TYPES | CHOOSE_ALL);
3244 n = query_category(buf, put_in ? invent : current_container->cobj,
3245 mflags, &pick_list, PICK_ANY);
3248 for (i = 0; i < n; i++) {
3249 if (pick_list[i].item.a_int == 'A')
3250 loot_everything = TRUE;
3251 else if (pick_list[i].item.a_int == ALL_TYPES_SELECTED)
3252 all_categories = TRUE;
3254 add_valid_menu_class(pick_list[i].item.a_int);
3256 free((genericptr_t) pick_list);
3259 if (loot_everything) {
3261 current_container->cknown = 1;
3262 for (otmp = current_container->cobj; otmp; otmp = otmp2) {
3264 res = out_container(otmp);
3270 for (otmp = invent; otmp && current_container; otmp = otmp2) {
3272 res = in_container(otmp);
3279 mflags = INVORDER_SORT;
3280 if (put_in && flags.invlet_constant)
3281 mflags |= USE_INVLET;
3283 current_container->cknown = 1;
3285 Sprintf(buf, "%s what?", action);
3287 Sprintf(buf, "
\89½
\82ð%s
\81H", action);
3288 n = query_objlist(buf, put_in ? &invent : &(current_container->cobj),
3289 mflags, &pick_list, PICK_ANY,
3290 all_categories ? allow_all : allow_category);
3293 for (i = 0; i < n; i++) {
3294 otmp = pick_list[i].item.a_obj;
3295 count = pick_list[i].count;
3296 if (count > 0 && count < otmp->quan) {
3297 otmp = splitobj(otmp, count);
3298 /* special split case also handled by askchain() */
3300 res = put_in ? in_container(otmp) : out_container(otmp);
3302 if (!current_container) {
3303 /* otmp caused current_container to explode;
3304 both are now gone */
3305 otmp = 0; /* and break loop */
3306 } else if (otmp && otmp != pick_list[i].item.a_obj) {
3307 /* split occurred, merge again */
3308 (void) merged(&pick_list[i].item.a_obj, &otmp);
3313 free((genericptr_t) pick_list);
3320 in_or_out_menu(prompt, obj, outokay, inokay, alreadyused, more_containers)
3323 boolean outokay, inokay, alreadyused, more_containers;
3325 /* underscore is not a choice; it's used to skip element [0] */
3326 static const char lootchars[] = "_:oibrsnq", abc_chars[] = "_:abcdenq";
3329 menu_item *pick_list;
3332 const char *menuselector = flags.lootabc ? abc_chars : lootchars;
3335 win = create_nhwindow(NHW_MENU);
3338 any.a_int = 1; /* ':' */
3340 Sprintf(buf, "Look inside %s", thesimpleoname(obj));
3342 Sprintf(buf, "%s
\82Ì
\92\86\90g
\82ð
\8c©
\82é", thesimpleoname(obj));
3343 add_menu(win, NO_GLYPH, &any, menuselector[any.a_int], 0, ATR_NONE, buf,
3346 any.a_int = 2; /* 'o' */
3348 Sprintf(buf, "take %s out", something);
3350 Strcpy(buf, "
\89½
\82©
\82ð
\8eæ
\82è
\8fo
\82·");
3351 add_menu(win, NO_GLYPH, &any, menuselector[any.a_int], 0, ATR_NONE,
3352 buf, MENU_UNSELECTED);
3355 any.a_int = 3; /* 'i' */
3357 Sprintf(buf, "put %s in", something);
3359 Strcpy(buf, "
\89½
\82©
\82ð
\93ü
\82ê
\82é");
3360 add_menu(win, NO_GLYPH, &any, menuselector[any.a_int], 0, ATR_NONE,
3361 buf, MENU_UNSELECTED);
3364 any.a_int = 4; /* 'b' */
3366 Sprintf(buf, "%stake out, then put in", inokay ? "both; " : "");
3368 Sprintf(buf, "%s
\82Ü
\82¸
\8eæ
\82è
\8fo
\82·
\81C
\82»
\82ê
\82©
\82ç
\93ü
\82ê
\82é", inokay ? "
\97¼
\95û; " : "");
3369 add_menu(win, NO_GLYPH, &any, menuselector[any.a_int], 0, ATR_NONE,
3370 buf, MENU_UNSELECTED);
3373 any.a_int = 5; /* 'r' */
3375 Sprintf(buf, "%sput in, then take out",
3376 outokay ? "both reversed; " : "");
3378 Sprintf(buf, "%s
\82Ü
\82¸
\93ü
\82ê
\82é
\81C
\82»
\82ê
\82©
\82ç
\8eæ
\82è
\8fo
\82·",
3379 outokay ? "
\97¼
\95û
\82ð
\8bt
\8f\87\82Å; " : "");
3381 add_menu(win, NO_GLYPH, &any, menuselector[any.a_int], 0, ATR_NONE,
3382 buf, MENU_UNSELECTED);
3383 any.a_int = 6; /* 's' */
3385 Sprintf(buf, "stash one item into %s", thesimpleoname(obj));
3387 Sprintf(buf, "
\82à
\82Ì
\82ð
\88ê
\82Â
\82¾
\82¯%s
\82É
\93ü
\82ê
\82é", thesimpleoname(obj));
3388 add_menu(win, NO_GLYPH, &any, menuselector[any.a_int], 0, ATR_NONE,
3389 buf, MENU_UNSELECTED);
3392 add_menu(win, NO_GLYPH, &any, 0, 0, ATR_NONE, "", MENU_UNSELECTED);
3393 if (more_containers) {
3394 any.a_int = 7; /* 'n' */
3396 add_menu(win, NO_GLYPH, &any, menuselector[any.a_int], 0, ATR_NONE,
3397 "loot next container", MENU_SELECTED);
3399 add_menu(win, NO_GLYPH, &any, menuselector[any.a_int], 0, ATR_NONE,
3400 "
\8e\9f\82Ì
\94 \82ð
\8aJ
\82¯
\82é", MENU_SELECTED);
3403 any.a_int = 8; /* 'q' */
3405 Strcpy(buf, alreadyused ? "done" : "do nothing");
3407 Strcpy(buf, alreadyused ? "
\8fI
\82í
\82é" : "
\89½
\82à
\82µ
\82È
\82¢");
3408 add_menu(win, NO_GLYPH, &any, menuselector[any.a_int], 0, ATR_NONE, buf,
3409 more_containers ? MENU_UNSELECTED : MENU_SELECTED);
3411 end_menu(win, prompt);
3412 n = select_menu(win, PICK_ONE, &pick_list);
3413 destroy_nhwindow(win);
3415 int k = pick_list[0].item.a_int;
3417 if (n > 1 && k == (more_containers ? 7 : 8))
3418 k = pick_list[1].item.a_int;
3419 free((genericptr_t) pick_list);
3420 return lootchars[k]; /* :,o,i,b,r,s,n,q */
3422 return (n == 0 && more_containers) ? 'n' : 'q'; /* next or quit */
3425 static const char tippables[] = { ALL_CLASSES, TOOL_CLASS, 0 };
3427 /* #tip command -- empty container contents onto floor */
3431 struct obj *cobj, *nobj;
3434 char c, buf[BUFSZ], qbuf[BUFSZ];
3435 const char *spillage = 0;
3438 * doesn't require free hands;
3439 * limbs are needed to tip floor containers
3442 /* at present, can only tip things at current spot, not adjacent ones */
3443 cc.x = u.ux, cc.y = u.uy;
3445 /* check floor container(s) first; at most one will be accessed */
3446 if ((boxes = container_at(cc.x, cc.y, TRUE)) > 0) {
3448 Sprintf(buf, "You can't tip %s while carrying so much.",
3449 !flags.verbose ? "a container" : (boxes > 1) ? "one" : "it");
3451 Strcpy(buf, "
\82½
\82
\82³
\82ñ
\82à
\82Ì
\82ð
\8e\9d\82¿
\82·
\82¬
\82Ä
\82¢
\82é
\82Ì
\82Å
\82Ð
\82Á
\82
\82è
\82©
\82¦
\82¹
\82È
\82¢
\81D");
3453 if (!check_capacity(buf) && able_to_loot(cc.x, cc.y, FALSE)) {
3454 if (boxes > 1 && (flags.menu_style != MENU_TRADITIONAL
3455 || iflags.menu_requested)) {
3456 /* use menu to pick a container to tip */
3460 menu_item *pick_list = (menu_item *) 0;
3461 struct obj dummyobj, *otmp;
3464 win = create_nhwindow(NHW_MENU);
3467 for (cobj = level.objects[cc.x][cc.y], i = 0; cobj;
3468 cobj = cobj->nexthere)
3469 if (Is_container(cobj)) {
3472 add_menu(win, NO_GLYPH, &any, 0, 0, ATR_NONE,
3473 doname(cobj), MENU_UNSELECTED);
3477 add_menu(win, NO_GLYPH, &any, 0, 0, ATR_NONE,
3478 "", MENU_UNSELECTED);
3479 any.a_obj = &dummyobj;
3480 /* use 'i' for inventory unless there are so many
3481 containers that it's already being used */
3482 i = (i <= 'i' - 'a' && !flags.lootabc) ? 'i' : 0;
3484 add_menu(win, NO_GLYPH, &any, i, 0, ATR_NONE,
3485 "tip something being carried", MENU_SELECTED);
3487 add_menu(win, NO_GLYPH, &any, i, 0, ATR_NONE,
3488 "
\93ü
\82ê
\95¨
\82ð
\82Ð
\82Á
\82
\82è
\82©
\82¦
\82·", MENU_SELECTED);
3491 end_menu(win, "
\82Ç
\82Ì
\93ü
\82ê
\95¨
\82ð
\82Ð
\82Á
\82
\82è
\82©
\82¦
\82·
\81H");
3492 n = select_menu(win, PICK_ONE, &pick_list);
3493 destroy_nhwindow(win);
3495 * Deal with quirk of preselected item in pick-one menu:
3496 * n == 0 => picked preselected entry, toggling it off;
3497 * n == 1 => accepted preselected choice via SPACE or RETURN;
3498 * n == 2 => picked something other than preselected entry;
3499 * n == -1 => cancelled via ESC;
3501 otmp = (n <= 0) ? (struct obj *) 0 : pick_list[0].item.a_obj;
3502 if (n > 1 && otmp == &dummyobj)
3503 otmp = pick_list[1].item.a_obj;
3505 free((genericptr_t) pick_list);
3506 if (otmp && otmp != &dummyobj) {
3512 /* else pick-from-invent below */
3514 for (cobj = level.objects[cc.x][cc.y]; cobj; cobj = nobj) {
3515 nobj = cobj->nexthere;
3516 if (!Is_container(cobj))
3519 c = ynq(safe_qbuf(qbuf, "There is ", " here, tip it?",
3521 doname, ansimpleoname, "container"));
3523 c = ynq(safe_qbuf(qbuf, "
\82±
\82±
\82É
\82Í", "
\82ª
\82 \82é
\81C
\82Ð
\82Á
\82
\82è
\95Ô
\82·?",
3525 doname, ansimpleoname, "
\93ü
\82ê
\95¨"));
3532 /* can only tip one container at a time */
3539 /* either no floor container(s) or couldn't tip one or didn't tip any */
3540 cobj = getobj(tippables, "tip");
3545 if (Is_container(cobj) || cobj->otyp == HORN_OF_PLENTY) {
3549 /* assorted other cases */
3550 if (Is_candle(cobj) && cobj->lamplit) {
3551 /* note "wax" even for tallow candles to avoid giving away info */
3555 spillage = "
\82ë
\82¤";
3556 } else if ((cobj->otyp == POT_OIL && cobj->lamplit)
3557 || (cobj->otyp == OIL_LAMP && cobj->age != 0L)
3558 || (cobj->otyp == MAGIC_LAMP && cobj->spe != 0)) {
3563 /* todo: reduce potion's remaining burn timer or oil lamp's fuel */
3564 } else if (cobj->otyp == CAN_OF_GREASE && cobj->spe > 0) {
3565 /* charged consumed below */
3567 spillage = "grease";
3569 spillage = "
\8e\89";
3570 } else if (cobj->otyp == FOOD_RATION || cobj->otyp == CRAM_RATION
3571 || cobj->otyp == LEMBAS_WAFER) {
3573 spillage = "crumbs";
3575 spillage = "
\83p
\83\93\82
\82¸";
3576 } else if (cobj->oclass == VENOM_CLASS) {
3580 spillage = "
\93Å
\89t";
3584 if (is_pool(u.ux, u.uy))
3586 Sprintf(buf, " and gradually %s", vtense(spillage, "dissipate"));
3588 Strcpy(buf, "
\82»
\82µ
\82Ä
\8f\99\81X
\82É
\8eU
\82Á
\82Ä
\82¢
\82Á
\82½
\81D");
3589 else if (is_lava(u.ux, u.uy))
3591 Sprintf(buf, " and immediately %s away",
3592 vtense(spillage, "burn"));
3594 Strcpy(buf, "
\82»
\82µ
\82Ä
\82·
\82®
\82É
\94R
\82¦
\82Â
\82«
\82½
\81D");
3597 pline("Some %s %s onto the %s%s.", spillage,
3598 vtense(spillage, "spill"), surface(u.ux, u.uy), buf);
3600 pline("%s
\82ª%s
\82Ì
\8fã
\82É
\94ò
\82Ñ
\8eU
\82Á
\82½
\81D%s", spillage,
3601 surface(u.ux, u.uy), buf);
3603 /* shop usage message comes after the spill message */
3604 if (cobj->otyp == CAN_OF_GREASE && cobj->spe > 0) {
3605 consume_obj_charge(cobj, TRUE);
3607 /* something [useless] happened */
3610 /* anything not covered yet */
3611 if (cobj->oclass == POTION_CLASS) /* can't pour potions... */
3613 pline_The("%s %s securely sealed.", xname(cobj), otense(cobj, "are"));
3615 pline_The("%s
\82Í
\82µ
\82Á
\82©
\82è
\82Æ
\90ð
\82ª
\82³
\82ê
\82Ä
\82¢
\82é
\81D", xname(cobj));
3616 else if (cobj->otyp == STATUE)
3618 pline("Nothing interesting happens.");
3620 pline("
\96Ê
\94\92\82¢
\82±
\82Æ
\82Í
\89½
\82à
\8bN
\82«
\82È
\82©
\82Á
\82½
\81D");
3622 pline1(nothing_happens);
3628 struct obj *box; /* or bag */
3630 xchar ox = u.ux, oy = u.uy; /* #tip only works at hero's location */
3631 boolean empty_it = FALSE, maybeshopgoods;
3633 /* box is either held or on floor at hero's spot; no need to check for
3634 nesting; when held, we need to update its location to match hero's;
3635 for floor, the coordinate updating is redundant */
3636 if (get_obj_location(box, &ox, &oy, 0))
3637 box->ox = ox, box->oy = oy;
3639 /* Shop handling: can't rely on the container's own unpaid
3640 or no_charge status because contents might differ with it.
3641 A carried container's contents will be flagged as unpaid
3642 or not, as appropriate, and need no special handling here.
3643 Items owned by the hero get sold to the shop without
3644 confirmation as with other uncontrolled drops. A floor
3645 container's contents will be marked no_charge if owned by
3646 hero, otherwise they're owned by the shop. By passing
3647 the contents through shop billing, they end up getting
3648 treated the same as in the carried case. We do so one
3649 item at a time instead of doing whole container at once
3650 to reduce the chance of exhausting shk's billing capacity. */
3651 maybeshopgoods = !carried(box) && costly_spot(box->ox, box->oy);
3653 /* caveat: this assumes that cknown, lknown, olocked, and otrapped
3654 fields haven't been overloaded to mean something special for the
3655 non-standard "container" horn of plenty */
3659 pline("It's locked.");
3661 pline("
\8c®
\82ª
\8a|
\82©
\82Á
\82Ä
\82¢
\82é
\81D");
3662 } else if (box->otrapped) {
3663 /* we're not reaching inside but we're still handling it... */
3664 (void) chest_trap(box, HAND, FALSE);
3665 /* even if the trap fails, you've used up this turn */
3666 if (multi >= 0) { /* in case we didn't become paralyzed */
3669 multi_reason = "tipping a container";
3671 multi_reason = "
\94 \82ð
\82Ð
\82Á
\82
\82è
\95Ô
\82µ
\82Ä
\82¢
\82é
\8e\9e\82É";
3674 } else if (box->otyp == BAG_OF_TRICKS || box->otyp == HORN_OF_PLENTY) {
3675 boolean bag = box->otyp == BAG_OF_TRICKS;
3676 int old_spe = box->spe, seen = 0;
3678 if (maybeshopgoods && !box->no_charge)
3679 addtobill(box, FALSE, FALSE, TRUE);
3680 /* apply this bag/horn until empty or monster/object creation fails
3681 (if the latter occurs, force the former...) */
3683 if (!(bag ? bagotricks(box, TRUE, &seen)
3684 : hornoplenty(box, TRUE)))
3686 } while (box->spe > 0);
3688 if (box->spe < old_spe) {
3691 pline((seen == 0) ? "Nothing seems to happen."
3692 : (seen == 1) ? "A monster appears."
3693 : "Monsters appear!");
3695 pline((seen == 0) ? "
\89½
\82à
\8bN
\82«
\82È
\82©
\82Á
\82½
\82æ
\82¤
\82¾
\81D"
3696 : (seen == 1) ? "
\89ö
\95¨
\82ª
\8c»
\82ê
\82½
\81D"
3697 : "
\89ö
\95¨
\82ª
\8c»
\82ê
\82½
\81I");
3699 /* check_unpaid wants to see a non-zero charge count */
3701 check_unpaid_usage(box, TRUE);
3702 box->spe = 0; /* empty */
3705 if (maybeshopgoods && !box->no_charge)
3706 subfrombill(box, shop_keeper(*in_rooms(ox, oy, SHOPBASE)));
3707 } else if (SchroedingersBox(box)) {
3708 char yourbuf[BUFSZ];
3710 observe_quantum_cat(box, TRUE, TRUE);
3711 if (!Has_contents(box)) /* evidently a live cat came out */
3712 /* container type of "large box" is inferred */
3714 pline("%sbox is now empty.", Shk_Your(yourbuf, box));
3716 pline("%s
\94 \82Í
\8bó
\82É
\82È
\82Á
\82½
\81D", Shk_Your(yourbuf, box));
3717 else /* holds cat corpse */
3720 } else if (!Has_contents(box)) {
3723 pline("It's empty.");
3725 pline("
\82±
\82ê
\82Í
\8bó
\82¾
\81D");
3731 struct obj *otmp, *nobj;
3732 boolean terse, highdrop = !can_reach_floor(TRUE),
3733 altarizing = IS_ALTAR(levl[ox][oy].typ),
3734 cursed_mbag = (Is_mbag(box) && box->cursed);
3735 int held = carried(box);
3739 highdrop = altarizing = FALSE;
3740 terse = !(highdrop || altarizing || costly_spot(box->ox, box->oy));
3742 /* Terse formatting is
3743 * "Objects spill out: obj1, obj2, obj3, ..., objN."
3744 * If any other messages intervene between objects, we revert to
3745 * "ObjK drops to the floor.", "ObjL drops to the floor.", &c.
3749 box->cobj->nobj ? "Objects spill" : "An object spills",
3752 pline("
\92\86\90g
\82ª
\8fo
\82Ä
\82«
\82½%s",
3753 !(highdrop || altarizing) ? "
\81F" : "
\81D");
3755 for (otmp = box->cobj; otmp; otmp = nobj) {
3757 obj_extract_self(otmp);
3758 otmp->ox = box->ox, otmp->oy = box->oy;
3760 if (box->otyp == ICE_BOX) {
3761 removed_from_icebox(otmp); /* resume rotting for corpse */
3762 } else if (cursed_mbag && !rn2(13)) {
3763 loss += mbag_item_gone(held, otmp);
3764 /* abbreviated drop format is no longer appropriate */
3769 if (maybeshopgoods) {
3770 addtobill(otmp, FALSE, FALSE, TRUE);
3771 iflags.suppress_price++; /* doname formatting */
3775 /* might break or fall down stairs; handles altars itself */
3776 hitfloor(otmp, TRUE);
3780 } else if (!terse) {
3782 pline("%s %s to the %s.", Doname2(otmp),
3783 otense(otmp, "drop"), surface(ox, oy));
3785 pline("%s
\82Í%s
\82Ì
\8fã
\82É
\97\8e\82¿
\82½
\81D", Doname2(otmp),
3790 pline("%s%c", doname(otmp), nobj ? ',' : '.');
3792 pline("%s%s", doname(otmp), nobj ? "
\81C" : "
\81D");
3793 iflags.last_msg = PLNMSG_OBJNAM_ONLY;
3796 if (iflags.last_msg != PLNMSG_OBJNAM_ONLY)
3797 terse = FALSE; /* terse formatting has been interrupted */
3800 iflags.suppress_price--; /* reset */
3802 if (loss) /* magic bag lost some shop goods */
3804 You("owe %ld %s for lost merchandise.", loss, currency(loss));
3806 You("
\8e¸
\82Á
\82½
\82à
\82Ì
\82É
\91Î
\82µ
\82Ä%ld%s
\82Ì
\95\89\8dÂ
\82ð
\95\89\82Á
\82½
\81D", loss, currency(loss));
3807 box->owt = weight(box); /* mbag_item_gone() doesn't update this */
3809 (void) encumber_msg();