1 /* NetHack 3.6 shk.c $NHDT-Date: 1446854234 2015/11/06 23:57:14 $ $NHDT-Branch: master $:$NHDT-Revision: 1.116 $ */
2 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3 /* NetHack may be freely redistributed. See license for details. */
5 /* JNetHack Copyright */
6 /* (c) Issei Numata, Naoki Hamada, Shigehiro Miyashita, 1994-2000 */
7 /* For 3.4-, Copyright (c) SHIRAKATA Kentaro, 2002-2016 */
8 /* JNetHack may be freely redistributed. See license for details. */
14 #define PAY_CANT 0 /* too poor */
16 #define PAY_BROKE (-2)
18 STATIC_DCL void FDECL(makekops, (coord *));
19 STATIC_DCL void FDECL(call_kops, (struct monst *, BOOLEAN_P));
20 STATIC_DCL void FDECL(kops_gone, (BOOLEAN_P));
22 #define NOTANGRY(mon) ((mon)->mpeaceful)
23 #define ANGRY(mon) (!NOTANGRY(mon))
24 #define IS_SHOP(x) (rooms[x].rtype >= SHOPBASE)
26 #define muteshk(shkp) \
27 ((shkp)->msleeping || !(shkp)->mcanmove \
28 || (shkp)->data->msound <= MS_ANIMAL)
30 extern const struct shclass shtypes[]; /* defined in shknam.c */
32 STATIC_VAR NEARDATA long int followmsg; /* last time of follow message */
34 STATIC_VAR const char and_its_contents[] = " and its contents";
36 STATIC_VAR const char and_its_contents[] = "
\92\86\90g
\82ð
\8d\87\82í
\82¹
\82Ä";
38 STATIC_VAR const char the_contents_of[] = "the contents of ";
41 STATIC_DCL void FDECL(append_honorific, (char *));
42 STATIC_DCL void FDECL(setpaid, (struct monst *));
43 STATIC_DCL long FDECL(addupbill, (struct monst *));
44 STATIC_DCL void FDECL(pacify_shk, (struct monst *));
45 STATIC_DCL struct bill_x *FDECL(onbill, (struct obj *, struct monst *,
47 STATIC_DCL struct monst *FDECL(next_shkp, (struct monst *, BOOLEAN_P));
48 STATIC_DCL long FDECL(shop_debt, (struct eshk *));
49 STATIC_DCL char *FDECL(shk_owns, (char *, struct obj *));
50 STATIC_DCL char *FDECL(mon_owns, (char *, struct obj *));
51 STATIC_DCL void FDECL(clear_unpaid, (struct obj *));
52 STATIC_DCL long FDECL(check_credit, (long, struct monst *));
53 STATIC_DCL void FDECL(pay, (long, struct monst *));
54 STATIC_DCL long FDECL(get_cost, (struct obj *, struct monst *));
55 STATIC_DCL long FDECL(set_cost, (struct obj *, struct monst *));
56 STATIC_DCL const char *FDECL(shk_embellish, (struct obj *, long));
57 STATIC_DCL long FDECL(cost_per_charge, (struct monst *, struct obj *,
59 STATIC_DCL long FDECL(cheapest_item, (struct monst *));
60 STATIC_DCL int FDECL(dopayobj, (struct monst *, struct bill_x *,
61 struct obj **, int, BOOLEAN_P));
62 STATIC_DCL long FDECL(stolen_container, (struct obj *, struct monst *,
64 STATIC_DCL long FDECL(getprice, (struct obj *, BOOLEAN_P));
65 STATIC_DCL void FDECL(shk_names_obj, (struct monst *, struct obj *,
66 const char *, long, const char *));
67 STATIC_DCL struct obj *FDECL(bp_to_obj, (struct bill_x *));
68 STATIC_DCL boolean FDECL(inherits, (struct monst *, int, int));
69 STATIC_DCL void FDECL(set_repo_loc, (struct monst *));
70 STATIC_DCL boolean NDECL(angry_shk_exists);
71 STATIC_DCL void FDECL(rile_shk, (struct monst *));
72 STATIC_DCL void FDECL(rouse_shk, (struct monst *, BOOLEAN_P));
73 STATIC_DCL void FDECL(remove_damage, (struct monst *, BOOLEAN_P));
74 STATIC_DCL void FDECL(sub_one_frombill, (struct obj *, struct monst *));
75 STATIC_DCL void FDECL(add_one_tobill, (struct obj *, BOOLEAN_P,
77 STATIC_DCL void FDECL(dropped_container, (struct obj *, struct monst *,
79 STATIC_DCL void FDECL(add_to_billobjs, (struct obj *));
80 STATIC_DCL void FDECL(bill_box_content, (struct obj *, BOOLEAN_P, BOOLEAN_P,
82 STATIC_DCL boolean FDECL(rob_shop, (struct monst *));
83 STATIC_DCL void FDECL(deserted_shop, (char *));
84 STATIC_DCL boolean FDECL(special_stock, (struct obj *, struct monst *,
86 #if 0 /*JP*//*
\8eg
\82í
\82È
\82¢*/
87 STATIC_DCL const char *FDECL(cad, (BOOLEAN_P));
91 invariants: obj->unpaid iff onbill(obj) [unless bp->useup]
92 obj->quan <= bp->bquan
96 * Transfer money from inventory to monster when paying
97 * shopkeepers, priests, oracle, succubus, and other demons.
98 * Simple with only gold coins.
99 * This routine will handle money changing when multiple
100 * coin types is implemented, only appropriate
101 * monsters will pay change. (Peaceful shopkeepers, priests
102 * and the oracle try to maintain goodwill while selling
103 * their wares or services. Angry monsters and all demons
104 * will keep anything they get their hands on.
105 * Returns the amount actually paid, so we can know
106 * if the monster kept the change.
109 money2mon(mon, amount)
113 struct obj *ygold = findgold(invent);
116 impossible("%s payment in money2mon!", amount ? "negative" : "zero");
119 if (!ygold || ygold->quan < amount) {
120 impossible("Paying without %s money?", ygold ? "enough" : "");
124 if (ygold->quan > amount)
125 ygold = splitobj(ygold, amount);
126 else if (ygold->owornmask)
127 remove_worn_item(ygold, FALSE); /* quiver */
129 add_to_minv(mon, ygold);
135 * Transfer money from monster to inventory.
136 * Used when the shopkeeper pay for items, and when
137 * the priest gives you money for an ale.
144 struct obj *mongold = findgold(mon->minvent);
147 impossible("%s payment in money2u!", amount ? "negative" : "zero");
150 if (!mongold || mongold->quan < amount) {
151 impossible("%s paying without %s money?", a_monnam(mon),
152 mongold ? "enough" : "");
156 if (mongold->quan > amount)
157 mongold = splitobj(mongold, amount);
158 obj_extract_self(mongold);
160 if (!merge_choice(invent, mongold) && inv_cnt(FALSE) >= 52) {
162 You("have no room for the money!");
164 You("
\82¨
\8bà
\82ð
\8e\9d\82Â
\97]
\97T
\82ª
\82È
\82¢
\81I");
172 STATIC_OVL struct monst *
173 next_shkp(shkp, withbill)
174 register struct monst *shkp;
175 register boolean withbill;
177 for (; shkp; shkp = shkp->nmon) {
178 if (DEADMONSTER(shkp))
180 if (shkp->isshk && (ESHK(shkp)->billct || !withbill))
185 if (NOTANGRY(shkp)) {
186 if (ESHK(shkp)->surcharge)
189 if (!ESHK(shkp)->surcharge)
196 /* called in mon.c */
201 struct eshk *eshk = ESHK(mtmp);
202 struct mkroom *sroom = &rooms[eshk->shoproom - ROOMOFFSET];
207 /* [BUG: some of this should be done on the shop level */
208 /* even when the shk dies on a different level.] */
209 if (on_level(&eshk->shoplevel, &u.uz)) {
210 remove_damage(mtmp, TRUE);
211 sroom->resident = (struct monst *) 0;
212 if (!search_special(ANY_SHOP))
213 level.flags.has_shop = 0;
215 /* items on shop floor revert to ordinary objects */
216 for (sx = sroom->lx; sx <= sroom->hx; sx++)
217 for (sy = sroom->ly; sy <= sroom->hy; sy++)
218 for (otmp = level.objects[sx][sy]; otmp;
219 otmp = otmp->nexthere)
222 /* Make sure bill is set only when the
223 dead shk is the resident shk. */
224 if ((p = index(u.ushops, eshk->shoproom)) != 0) {
226 eshk->bill_p = (struct bill_x *) 0;
227 /* remove eshk->shoproom from u.ushops */
236 set_residency(shkp, zero_out)
237 register struct monst *shkp;
238 register boolean zero_out;
240 if (on_level(&(ESHK(shkp)->shoplevel), &u.uz))
241 rooms[ESHK(shkp)->shoproom - ROOMOFFSET].resident =
242 (zero_out) ? (struct monst *) 0 : shkp;
247 register struct monst *mtmp, *mtmp2;
249 rooms[ESHK(mtmp2)->shoproom - ROOMOFFSET].resident = mtmp2;
250 if (inhishop(mtmp) && *u.ushops == ESHK(mtmp)->shoproom) {
251 ESHK(mtmp2)->bill_p = &(ESHK(mtmp2)->bill[0]);
255 /* do shopkeeper specific structure munging -dlc */
257 restshk(shkp, ghostly)
262 struct eshk *eshkp = ESHK(shkp);
264 if (eshkp->bill_p != (struct bill_x *) -1000)
265 eshkp->bill_p = &eshkp->bill[0];
266 /* shoplevel can change as dungeons move around */
267 /* savebones guarantees that non-homed shk's will be gone */
269 assign_level(&eshkp->shoplevel, &u.uz);
270 if (ANGRY(shkp) && strncmpi(eshkp->customer, plname, PL_NSIZ))
276 /* Clear the unpaid bit on all of the objects in the list. */
279 register struct obj *list;
282 if (Has_contents(list))
283 clear_unpaid(list->cobj);
289 /* either you paid or left the shop or the shopkeeper died */
292 register struct monst *shkp;
294 register struct obj *obj;
295 register struct monst *mtmp;
297 /* FIXME: object handling should be limited to
298 items which are on this particular shk's bill */
300 clear_unpaid(invent);
302 clear_unpaid(level.buriedobjlist);
304 thrownobj->unpaid = 0;
306 kickedobj->unpaid = 0;
307 for (mtmp = fmon; mtmp; mtmp = mtmp->nmon)
308 clear_unpaid(mtmp->minvent);
309 for (mtmp = migrating_mons; mtmp; mtmp = mtmp->nmon)
310 clear_unpaid(mtmp->minvent);
312 while ((obj = billobjs) != 0) {
313 obj_extract_self(obj);
317 ESHK(shkp)->billct = 0;
318 ESHK(shkp)->credit = 0L;
319 ESHK(shkp)->debit = 0L;
320 ESHK(shkp)->loan = 0L;
326 register struct monst *shkp;
328 register int ct = ESHK(shkp)->billct;
329 register struct bill_x *bp = ESHK(shkp)->bill_p;
330 register long total = 0L;
333 total += bp->price * bp->bquan;
340 call_kops(shkp, nearshop)
341 register struct monst *shkp;
342 register boolean nearshop;
344 /* Keystone Kops srt@ucla */
345 register boolean nokops;
352 pline("An alarm sounds!");
354 pline("
\8cx
\95ñ
\82ª
\96Â
\82è
\82Ð
\82Ñ
\82¢
\82½
\81I");
356 nokops = ((mvitals[PM_KEYSTONE_KOP].mvflags & G_GONE)
357 && (mvitals[PM_KOP_SERGEANT].mvflags & G_GONE)
358 && (mvitals[PM_KOP_LIEUTENANT].mvflags & G_GONE)
359 && (mvitals[PM_KOP_KAPTAIN].mvflags & G_GONE));
361 if (!angry_guards(!!Deaf) && nokops) {
362 if (flags.verbose && !Deaf)
364 pline("But no one seems to respond to it.");
366 pline("
\82µ
\82©
\82µ
\92N
\82à
\89\9e\93\9a\82µ
\82È
\82©
\82Á
\82½
\81D");
377 /* Create swarm around you, if you merely "stepped out" */
380 pline_The("Keystone Kops appear!");
382 pline("
\8cx
\94õ
\88õ
\82ª
\8c»
\82í
\82ê
\82½
\81I");
390 pline_The("Keystone Kops are after you!");
392 pline("
\8cx
\94õ
\88õ
\82ª
\82¢
\82é
\81I");
393 /* Create swarm near down staircase (hinders return to level) */
397 /* Create swarm near shopkeeper (hinders return to shop) */
404 /* x,y is strictly inside shop */
411 rno = levl[x][y].roomno;
412 if ((rno < ROOMOFFSET) || levl[x][y].edge || !IS_SHOP(rno - ROOMOFFSET))
419 u_left_shop(leavestring, newlev)
428 * ((didn't leave outright) AND
429 * ((he is now strictly-inside the shop) OR
430 * (he wasn't strictly-inside last turn anyway)))
431 * THEN (there's nothing to do, so just return)
433 if (!*leavestring && (!levl[u.ux][u.uy].edge || levl[u.ux0][u.uy0].edge))
436 shkp = shop_keeper(*u.ushops0);
437 if (!shkp || !inhishop(shkp))
438 return; /* shk died, teleported, changed levels... */
441 if (!eshkp->billct && !eshkp->debit) /* bill is settled */
444 if (!*leavestring && !muteshk(shkp)) {
446 * Player just stepped onto shop-boundary (known from above logic).
447 * Try to intimidate him into paying his bill
450 verbalize(NOTANGRY(shkp) ? "%s! Please pay before leaving."
451 : "%s! Don't you leave without paying!",
454 verbalize(NOTANGRY(shkp) ? "%s
\82³
\82ñ
\81I
\8bA
\82é
\91O
\82É
\81C
\82¨
\8bà
\82ð
\95¥
\82Á
\82Ä
\82¢
\82½
\82¾
\82¯
\82Ü
\82¹
\82ñ
\82©
\81D"
455 : "%s
\81I
\8bA
\82é
\91O
\82É
\81C
\8bà
\82ð
\95¥
\82¦
\81I",
461 if (rob_shop(shkp)) {
462 call_kops(shkp, (!newlev && levl[u.ux0][u.uy0].edge));
466 /* robbery from outside the shop via telekinesis or grappling hook */
468 remote_burglary(x, y)
474 shkp = shop_keeper(*in_rooms(x, y, SHOPBASE));
475 if (!shkp || !inhishop(shkp))
476 return; /* shk died, teleported, changed levels... */
479 if (!eshkp->billct && !eshkp->debit) /* bill is settled */
482 if (rob_shop(shkp)) {
483 /*[might want to set 2nd arg based on distance from shop doorway]*/
484 call_kops(shkp, FALSE);
488 /* shop merchandise has been taken; pay for it with any credit available;
489 return false if the debt is fully covered by credit, true otherwise */
498 rouse_shk(shkp, TRUE);
499 total = (addupbill(shkp) + eshkp->debit);
500 if (eshkp->credit >= total) {
502 Your("credit of %ld %s is used to cover your shopping bill.",
504 Your("
\97a
\82¯
\8bà
\82©
\82ç%ld%s
\82ª
\8a¨
\92è
\82Ì
\8ex
\95¥
\82¢
\82É
\8eg
\82í
\82ê
\82½
\81D",
506 eshkp->credit, currency(eshkp->credit));
507 total = 0L; /* credit gets cleared by setpaid() */
510 You("escaped the shop without paying!");
512 You("
\8bà
\82ð
\95¥
\82í
\82¸
\82É
\93X
\82©
\82ç
\93¦
\82°
\82½
\81I");
513 total -= eshkp->credit;
519 /* by this point, we know an actual robbery has taken place */
520 eshkp->robbed += total;
522 You("stole %ld %s worth of merchandise.", total, currency(total));
524 You("
\8eG
\89Ý
\82ð%ld%s
\95ª
\93\90\82ñ
\82¾
\81D", total, currency(total));
525 if (!Role_if(PM_ROGUE)) /* stealing is unlawful */
526 adjalign(-sgn(u.ualign.type));
532 /* give a message when entering an untended shop (caller has verified that) */
534 deserted_shop(enterstring)
535 /*const*/ char *enterstring;
538 struct mkroom *r = &rooms[(int) *enterstring - ROOMOFFSET];
539 int x, y, m = 0, n = 0;
541 for (x = r->lx; x <= r->hx; ++x)
542 for (y = r->ly; y <= r->hy; ++y) {
543 if (x == u.ux && y == u.uy)
545 if ((mtmp = m_at(x, y)) != 0) {
547 if (sensemon(mtmp) || ((mtmp->m_ap_type == M_AP_NOTHING
548 || mtmp->m_ap_type == M_AP_MONSTER)
554 if (Blind && !(Blind_telepat || Detect_monsters))
555 ++n; /* force feedback to be less specific */
558 pline("This shop %s %s.", (m < n) ? "seems to be" : "is",
559 !n ? "deserted" : "untended");
561 pline("
\93X
\82Í%s%s
\81D",
562 !n ? "
\94p
\9aÐ
\82Æ
\89»
\82µ
\82Ä
\82¢
\82é" : "
\95ú
\8aü
\82³
\82ê
\82Ä
\82¢
\82é",
563 (m < n) ? "
\82æ
\82¤
\82¾" : "is");
568 u_entered_shop(enterstring)
572 register struct monst *shkp;
573 register struct eshk *eshkp;
574 static char empty_shops[5];
579 if (!(shkp = shop_keeper(*enterstring))) {
580 if (!index(empty_shops, *enterstring)
581 && in_rooms(u.ux, u.uy, SHOPBASE)
582 != in_rooms(u.ux0, u.uy0, SHOPBASE))
583 deserted_shop(enterstring);
584 Strcpy(empty_shops, u.ushops);
591 if (!inhishop(shkp)) {
592 /* dump core when referenced */
593 eshkp->bill_p = (struct bill_x *) -1000;
594 if (!index(empty_shops, *enterstring))
595 deserted_shop(enterstring);
596 Strcpy(empty_shops, u.ushops);
601 eshkp->bill_p = &(eshkp->bill[0]);
603 if ((!eshkp->visitct || *eshkp->customer)
604 && strncmpi(eshkp->customer, plname, PL_NSIZ)) {
605 /* You seem to be new here */
607 eshkp->following = 0;
608 (void) strncpy(eshkp->customer, plname, PL_NSIZ);
612 if (muteshk(shkp) || eshkp->following)
613 return; /* no dialog */
617 pline("%s senses your presence.", shkname(shkp));
619 pline("%s
\82Í
\82 \82È
\82½
\82Ì
\91¶
\8dÝ
\82É
\8bC
\82ª
\82Â
\82¢
\82½
\81D", shkname(shkp));
621 verbalize("Invisible customers are not welcome!");
623 verbalize("
\93§
\96¾
\82È
\82¨
\8bq
\82³
\82ñ
\82Æ
\82Í
\8a´
\90S
\82µ
\82È
\82¢
\82È
\81I");
627 rt = rooms[*enterstring - ROOMOFFSET].rtype;
631 verbalize("So, %s, you dare return to %s %s?!", plname,
632 s_suffix(shkname(shkp)), shtypes[rt - SHOPBASE].name);
634 verbalize("%s
\81I
\82í
\82´
\82í
\82´%s
\82Ì%s
\82É
\96ß
\82Á
\82Ä
\82«
\82½
\82Ì
\82©
\81H
\81I", plname,
635 s_suffix(shkname(shkp)), shtypes[rt - SHOPBASE].name);
637 } else if (eshkp->robbed) {
639 pline("%s mutters imprecations against shoplifters.", shkname(shkp));
641 pline("%s
\82Í
\93D
\96_
\82ð
\82Ì
\82Ì
\82µ
\82Á
\82½
\81D", shkname(shkp));
644 verbalize("%s, %s! Welcome%s to %s %s!", Hello(shkp), plname,
645 eshkp->visitct++ ? " again" : "", s_suffix(shkname(shkp)),
646 shtypes[rt - SHOPBASE].name);
648 verbalize("%s
\81I%s
\82Ì%s
\82É%s
\81I", Hello(shkp), shkname(shkp),
649 shtypes[rt - SHOPBASE].name,
650 eshkp->visitct++ ? "
\82Ü
\82½
\97\88\82Ü
\82µ
\82½
\82Ë" : "
\82æ
\82¤
\82±
\82»");
653 /* can't do anything about blocking if teleported in */
654 if (!inside_shop(u.ux, u.uy)) {
655 boolean should_block;
658 struct obj *pick = carrying(PICK_AXE),
659 *mattock = carrying(DWARVISH_MATTOCK);
661 if (pick || mattock) {
662 cnt = 1; /* so far */
663 if (pick && mattock) { /* carrying both types */
665 tool = "digging tool";
667 tool = "
\8c@
\82é
\93¹
\8bï";
668 cnt = 2; /* `more than 1' is all that matters */
673 tool = "
\82Â
\82é
\82Í
\82µ";
674 /* hack: `pick' already points somewhere into inventory */
675 while ((pick = pick->nobj) != 0)
676 if (pick->otyp == PICK_AXE)
678 } else { /* assert(mattock != 0) */
682 tool = "
\82Â
\82é
\82Í
\82µ";
683 while ((mattock = mattock->nobj) != 0)
684 if (mattock->otyp == DWARVISH_MATTOCK)
686 /* [ALI] Shopkeeper identifies mattock(s) */
688 makeknown(DWARVISH_MATTOCK);
691 verbalize(NOTANGRY(shkp)
692 ? "Will you please leave your %s%s outside?"
693 : "Leave the %s%s outside.",
696 verbalize(NOTANGRY(shkp)
697 ? "%s
\82ð
\8aO
\82É
\92u
\82¢
\82Ä
\82«
\82Ä
\82¢
\82½
\82¾
\82¯
\82Ü
\82¹
\82ñ
\82©
\81H"
698 : "%s
\82ð
\8aO
\82Ö
\92u
\82¢
\82Ä
\82±
\82¢
\81I",
702 } else if (u.usteed) {
704 verbalize(NOTANGRY(shkp) ? "Will you please leave %s outside?"
705 : "Leave %s outside.",
708 verbalize(NOTANGRY(shkp) ? "%s
\82ð
\8aO
\82É
\92u
\82¢
\82Ä
\82«
\82Ä
\82¢
\82½
\82¾
\82¯
\82Ü
\82¹
\82ñ
\82©
\81H"
709 : "%s
\82ð
\8aO
\82Ö
\92u
\82¢
\82Ä
\82±
\82¢
\81I",
715 (Fast && (sobj_at(PICK_AXE, u.ux, u.uy)
716 || sobj_at(DWARVISH_MATTOCK, u.ux, u.uy)));
719 (void) dochug(shkp); /* shk gets extra move */
724 /* called when removing a pick-axe or mattock from a container */
731 if (obj->unpaid || !is_pick(obj))
733 shkp = shop_keeper(*u.ushops);
734 if (shkp && inhishop(shkp) && !muteshk(shkp)) {
735 static NEARDATA long pickmovetime = 0L;
737 /* if you bring a sack of N picks into a shop to sell,
738 don't repeat this N times when they're taken out */
739 if (moves != pickmovetime)
741 verbalize("You sneaky %s! Get out of here with that pick!",
744 verbalize("
\82Ð
\82«
\82å
\82¤
\8eÒ
\82ß
\81I
\82Â
\82é
\82Í
\82µ
\82ð
\8e\9d\82Á
\82Ä
\8aO
\82É
\8fo
\82ë
\81I");
746 pickmovetime = moves;
751 Decide whether two unpaid items are mergable; caller is responsible for
752 making sure they're unpaid and the same type of object; we check the price
753 quoted by the shopkeeper and also that they both belong to the same shk.
756 same_price(obj1, obj2)
757 struct obj *obj1, *obj2;
759 register struct monst *shkp1, *shkp2;
760 struct bill_x *bp1 = 0, *bp2 = 0;
761 boolean are_mergable = FALSE;
763 /* look up the first object by finding shk whose bill it's on */
764 for (shkp1 = next_shkp(fmon, TRUE); shkp1;
765 shkp1 = next_shkp(shkp1->nmon, TRUE))
766 if ((bp1 = onbill(obj1, shkp1, TRUE)) != 0)
768 /* second object is probably owned by same shk; if not, look harder */
769 if (shkp1 && (bp2 = onbill(obj2, shkp1, TRUE)) != 0) {
772 for (shkp2 = next_shkp(fmon, TRUE); shkp2;
773 shkp2 = next_shkp(shkp2->nmon, TRUE))
774 if ((bp2 = onbill(obj2, shkp2, TRUE)) != 0)
779 impossible("same_price: object wasn't on any bill!");
781 are_mergable = (shkp1 == shkp2 && bp1->price == bp2->price);
786 * Figure out how much is owed to a given shopkeeper.
787 * At present, we ignore any amount robbed from the shop, to avoid
788 * turning the `$' command into a way to discover that the current
789 * level is bones data which has a shk on the warpath.
797 long debt = eshkp->debit;
799 for (bp = eshkp->bill_p, ct = eshkp->billct; ct > 0; bp++, ct--)
800 debt += bp->price * bp->bquan;
804 /* called in response to the `$' command */
806 shopper_financial_report()
808 struct monst *shkp, *this_shkp = shop_keeper(inside_shop(u.ux, u.uy));
813 eshkp = this_shkp ? ESHK(this_shkp) : 0;
814 if (eshkp && !(eshkp->credit || shop_debt(eshkp))) {
816 You("have no credit or debt in here.");
818 You("
\97a
\82¯
\8bà
\82à
\8eØ
\8bà
\82à
\82È
\82¢
\81D");
819 this_shkp = 0; /* skip first pass */
822 /* pass 0: report for the shop we're currently in, if any;
823 pass 1: report for all other shops on this level. */
824 for (pass = this_shkp ? 0 : 1; pass <= 1; pass++)
825 for (shkp = next_shkp(fmon, FALSE); shkp;
826 shkp = next_shkp(shkp->nmon, FALSE)) {
827 if ((shkp != this_shkp) ^ pass)
830 if ((amt = eshkp->credit) != 0)
832 You("have %ld %s credit at %s %s.", amt, currency(amt),
833 s_suffix(shkname(shkp)),
834 shtypes[eshkp->shoptype - SHOPBASE].name);
836 You("%ld%s
\82Ì
\97a
\82¯
\8bà
\82ª%s
\82Ì%s
\82É
\82 \82é
\81D", amt, currency(amt),
838 shtypes[eshkp->shoptype - SHOPBASE].name);
840 else if (shkp == this_shkp)
842 You("have no credit in here.");
844 You("
\97a
\82¯
\8bà
\82Í
\82È
\82¢
\81D");
845 if ((amt = shop_debt(eshkp)) != 0)
847 You("owe %s %ld %s.", shkname(shkp), amt, currency(amt));
849 You("%s
\82É%ld%s
\82Ì
\8eØ
\82è
\82ª
\82 \82é
\81D", shkname(shkp), amt, currency(amt));
850 else if (shkp == this_shkp)
852 You("don't owe any money here.");
854 pline("
\82±
\82Ì
\93X
\82É
\8eØ
\82è
\82Í
\82È
\82¢
\81D");
860 register struct monst *mtmp;
862 struct eshk *eshkp = ESHK(mtmp);
864 return (index(in_rooms(mtmp->mx, mtmp->my, SHOPBASE), eshkp->shoproom)
865 && on_level(&eshkp->shoplevel, &u.uz));
873 rmno >= ROOMOFFSET ? rooms[rmno - ROOMOFFSET].resident : 0;
876 if (NOTANGRY(shkp)) {
877 if (ESHK(shkp)->surcharge)
880 if (!ESHK(shkp)->surcharge)
889 register struct mkroom *sroom;
891 register struct monst *mtmp = sroom->resident;
896 return (boolean) inhishop(mtmp);
899 STATIC_OVL struct bill_x *
900 onbill(obj, shkp, silent)
901 register struct obj *obj;
902 register struct monst *shkp;
903 register boolean silent;
906 register struct bill_x *bp = ESHK(shkp)->bill_p;
907 register int ct = ESHK(shkp)->billct;
910 if (bp->bo_id == obj->o_id) {
913 pline("onbill: paid obj on bill?");
915 pline("
\8a¨
\92è
\81F
\95¥
\82¤
\81H");
920 if (obj->unpaid & !silent)
922 pline("onbill: unpaid obj not on bill?");
924 pline("
\8a¨
\92è
\81F
\95¥
\82í
\82È
\82¢
\81H");
925 return (struct bill_x *) 0;
928 /* check whether an object or any of its contents belongs to a shop */
933 return (boolean) (obj->unpaid
934 || (Has_contents(obj) && count_unpaid(obj->cobj)));
937 /* Delete the contents of the given object. */
940 register struct obj *obj;
942 register struct obj *curr;
944 while ((curr = obj->cobj) != 0) {
945 obj_extract_self(curr);
946 obfree(curr, (struct obj *) 0);
950 /* called with two args on merge */
953 register struct obj *obj, *merge;
955 register struct bill_x *bp;
956 register struct bill_x *bpm;
957 register struct monst *shkp;
959 if (obj->otyp == LEASH && obj->leashmon)
961 if (obj->oclass == FOOD_CLASS)
962 food_disappears(obj);
963 if (obj->oclass == SPBOOK_CLASS)
964 book_disappears(obj);
965 if (Has_contents(obj))
966 delete_contents(obj);
970 /* look for a shopkeeper who owns this object */
971 for (shkp = next_shkp(fmon, TRUE); shkp;
972 shkp = next_shkp(shkp->nmon, TRUE))
973 if (onbill(obj, shkp, TRUE))
976 /* sanity check, more or less */
978 shkp = shop_keeper(*u.ushops);
980 * Note: `shkp = shop_keeper(*u.ushops)' used to be
981 * unconditional. But obfree() is used all over
982 * the place, so making its behavior be dependent
983 * upon player location doesn't make much sense.
986 if ((bp = onbill(obj, shkp, FALSE)) != 0) {
989 obj->unpaid = 0; /* only for doinvbill */
990 add_to_billobjs(obj);
993 bpm = onbill(merge, shkp, FALSE);
995 /* this used to be a rename */
996 impossible("obfree: not on bill??");
999 /* this was a merger */
1000 bpm->bquan += bp->bquan;
1001 ESHK(shkp)->billct--;
1004 /* DRS/NS 2.2.6 messes up -- Peter Kendell */
1005 int indx = ESHK(shkp)->billct;
1007 *bp = ESHK(shkp)->bill_p[indx];
1010 *bp = ESHK(shkp)->bill_p[ESHK(shkp)->billct];
1014 if (obj->owornmask) {
1015 impossible("obfree: deleting worn obj (%d: %ld)", obj->otyp,
1017 /* unfortunately at this point we don't know whether worn mask
1018 applied to hero or a monster or perhaps something bogus, so
1019 can't call remove_worn_item() to get <X>_off() side-effects */
1026 check_credit(tmp, shkp)
1028 register struct monst *shkp;
1030 long credit = ESHK(shkp)->credit;
1033 ; /* nothing to do; just 'return tmp;' */
1034 } else if (credit >= tmp) {
1036 pline_The("price is deducted from your credit.");
1038 pline("
\91ã
\8bà
\82Í
\97a
\82¯
\8bà
\82©
\82ç
\8d·
\82µ
\88ø
\82©
\82ê
\82½
\81D");
1039 ESHK(shkp)->credit -= tmp;
1043 pline_The("price is partially covered by your credit.");
1045 pline("
\91ã
\8bà
\82Ì
\88ê
\95\94\82Í
\82 \82È
\82½
\82Ì
\97a
\82¯
\8bà
\82Å
\95â
\82í
\82ê
\82½
\81D");
1046 ESHK(shkp)->credit = 0L;
1055 register struct monst *shkp;
1057 long robbed = ESHK(shkp)->robbed;
1058 long balance = ((tmp <= 0L) ? tmp : check_credit(tmp, shkp));
1061 money2mon(shkp, balance);
1062 else if (balance < 0)
1063 money2u(shkp, -balance);
1069 ESHK(shkp)->robbed = robbed;
1073 /* return shkp to home position */
1075 home_shk(shkp, killkops)
1076 register struct monst *shkp;
1077 register boolean killkops;
1079 register xchar x = ESHK(shkp)->shk.x, y = ESHK(shkp)->shk.y;
1081 (void) mnearto(shkp, x, y, TRUE);
1082 level.flags.has_shop = 1;
1087 after_shk_move(shkp);
1093 register struct monst *shkp;
1095 for (shkp = next_shkp(fmon, FALSE); shkp;
1096 shkp = next_shkp(shkp->nmon, FALSE))
1102 /* remove previously applied surcharge from all billed items */
1105 register struct monst *shkp;
1107 NOTANGRY(shkp) = TRUE; /* make peaceful */
1108 if (ESHK(shkp)->surcharge) {
1109 register struct bill_x *bp = ESHK(shkp)->bill_p;
1110 register int ct = ESHK(shkp)->billct;
1112 ESHK(shkp)->surcharge = FALSE;
1114 register long reduction = (bp->price + 3L) / 4L;
1115 bp->price -= reduction; /* undo 33% increase */
1121 /* add aggravation surcharge to all billed items */
1124 register struct monst *shkp;
1126 NOTANGRY(shkp) = FALSE; /* make angry */
1127 if (!ESHK(shkp)->surcharge) {
1128 register struct bill_x *bp = ESHK(shkp)->bill_p;
1129 register int ct = ESHK(shkp)->billct;
1131 ESHK(shkp)->surcharge = TRUE;
1133 register long surcharge = (bp->price + 2L) / 3L;
1134 bp->price += surcharge;
1140 /* wakeup and/or unparalyze shopkeeper */
1142 rouse_shk(shkp, verbosely)
1146 if (!shkp->mcanmove || shkp->msleeping) {
1147 /* greed induced recovery... */
1148 if (verbosely && canspotmon(shkp))
1150 pline("%s %s.", Monnam(shkp),
1151 shkp->msleeping ? "wakes up" : "can move again");
1153 pline("%s
\82Í%s
\81D", Monnam(shkp),
1154 shkp->msleeping ? "
\96Ú
\82ª
\8ao
\82ß
\82½" : "
\82Ó
\82½
\82½
\82Ñ
\93®
\82¯
\82é
\82æ
\82¤
\82É
\82È
\82Á
\82½");
1156 shkp->msleeping = 0;
1163 make_happy_shk(shkp, silentkops)
1164 register struct monst *shkp;
1165 register boolean silentkops;
1167 boolean wasmad = ANGRY(shkp);
1168 struct eshk *eshkp = ESHK(shkp);
1171 eshkp->following = 0;
1173 if (!Role_if(PM_ROGUE))
1174 adjalign(sgn(u.ualign.type));
1175 if (!inhishop(shkp)) {
1176 char shk_nam[BUFSZ];
1177 boolean vanished = canseemon(shkp);
1179 Strcpy(shk_nam, mon_nam(shkp));
1180 if (on_level(&eshkp->shoplevel, &u.uz)) {
1181 home_shk(shkp, FALSE);
1182 /* didn't disappear if shk can still be seen */
1183 if (canseemon(shkp))
1186 /* if sensed, does disappear regardless whether seen */
1189 /* can't act as porter for the Amulet, even if shk
1190 happens to be going farther down rather than up */
1191 mdrop_special_objs(shkp);
1192 /* arrive near shop's door */
1193 migrate_to_level(shkp, ledger_no(&eshkp->shoplevel),
1194 MIGR_APPROX_XY, &eshkp->shd);
1195 /* dismiss kops on that level when shk arrives */
1196 eshkp->dismiss_kops = TRUE;
1200 pline("Satisfied, %s suddenly disappears!", shk_nam);
1202 pline("%s
\82Í
\96\9e\91«
\82·
\82é
\82Æ
\81C
\93Ë
\91R
\8fÁ
\82¦
\82½
\81I", shk_nam);
1205 pline("%s calms down.", Monnam(shkp));
1207 pline("%s
\82Í
\97\8e\92\85\82¢
\82½
\81D", Monnam(shkp));
1209 make_happy_shoppers(silentkops);
1212 /* called by make_happy_shk() and also by losedogs() for migrating shk */
1214 make_happy_shoppers(silentkops)
1217 if (!angry_shk_exists()) {
1218 kops_gone(silentkops);
1225 register struct monst *shkp;
1231 (void) strncpy(ESHK(shkp)->customer, plname, PL_NSIZ);
1232 ESHK(shkp)->following = 1;
1235 /* used when the shkp is teleported or falls (ox == 0) out of his shop,
1236 * or when the player is not on a costly_spot and he
1237 * damages something inside the shop. these conditions
1238 * must be checked by the calling function.
1241 make_angry_shk(shkp, ox, oy)
1242 register struct monst *shkp;
1243 register xchar ox, oy;
1246 struct eshk *eshkp = ESHK(shkp);
1248 /* all pending shop transactions are now "past due" */
1249 if (eshkp->billct || eshkp->debit || eshkp->loan || eshkp->credit) {
1250 eshkp->robbed += (addupbill(shkp) + eshkp->debit + eshkp->loan);
1251 eshkp->robbed -= eshkp->credit;
1252 if (eshkp->robbed < 0L)
1254 /* billct, debit, loan, and credit will be cleared by setpaid */
1258 /* If you just used a wand of teleportation to send the shk away, you
1259 might not be able to see her any more. Monnam would yield "it",
1260 which makes this message look pretty silly, so temporarily restore
1261 her original location during the call to Monnam. */
1262 sx = shkp->mx, sy = shkp->my;
1263 if (isok(ox, oy) && cansee(ox, oy) && !cansee(sx, sy))
1264 shkp->mx = ox, shkp->my = oy;
1266 pline("%s %s!", Monnam(shkp), !ANGRY(shkp) ? "gets angry" : "is furious");
1268 pline("%s
\82Í%s
\81I", Monnam(shkp), !ANGRY(shkp) ? "
\93{
\82Á
\82½" : "
\93{
\82è
\8b¶
\82Á
\82½");
1269 shkp->mx = sx, shkp->my = sy;
1274 STATIC_VAR const char no_money[] = "Moreover, you%s have no money.";
1276 STATIC_VAR const char no_money[] = "
\82µ
\82©
\82à
\81C
\82 \82È
\82½
\82Í
\82¨
\8bà
\82ª
\82È
\82¢%s
\81D";
1277 STATIC_VAR const char not_enough_money[] =
1279 "Besides, you don't have enough to interest %s.";
1281 "
\82µ
\82©
\82à
\81C
\82 \82È
\82½
\82Í%s
\82ª
\8b»
\96¡
\82ð
\8e\9d\82Â
\82Ù
\82Ç
\82¨
\8bà
\82ð
\8e\9d\82Á
\82Ä
\82¢
\82È
\82¢
\81I";
1284 cheapest_item(shkp) /* delivers the cheapest item on the list */
1285 register struct monst *shkp;
1287 register int ct = ESHK(shkp)->billct;
1288 register struct bill_x *bp = ESHK(shkp)->bill_p;
1289 register long gmin = (bp->price * bp->bquan);
1292 if (bp->price * bp->bquan < gmin)
1293 gmin = bp->price * bp->bquan;
1302 register struct eshk *eshkp;
1303 register struct monst *shkp;
1304 struct monst *nxtm, *resident;
1307 int pass, tmp, sk = 0, seensk = 0;
1308 boolean paid = FALSE, stashed_gold = (hidden_gold() > 0L);
1312 /* Find how many shk's there are, how many are in
1313 * sight, and are you in a shop room with one.
1315 nxtm = resident = 0;
1316 for (shkp = next_shkp(fmon, FALSE); shkp;
1317 shkp = next_shkp(shkp->nmon, FALSE)) {
1319 if (ANGRY(shkp) && distu(shkp->mx, shkp->my) <= 2)
1321 if (canspotmon(shkp))
1323 if (inhishop(shkp) && (*u.ushops == ESHK(shkp)->shoproom))
1327 if (nxtm) { /* Player should always appease an */
1328 shkp = nxtm; /* irate shk standing next to them. */
1332 if ((!sk && (!Blind || Blind_telepat)) || (!Blind && !seensk)) {
1334 There("appears to be no shopkeeper here to receive your payment.");
1336 pline("
\8ex
\95¥
\82¢
\82ð
\8eó
\82¯
\82Æ
\82é
\93X
\8eå
\82Í
\82±
\82±
\82É
\82Í
\82¢
\82È
\82¢
\82æ
\82¤
\82¾
\81D");
1344 You("
\8c©
\82é
\82±
\82Æ
\82ª
\82Å
\82«
\82È
\82¢
\81D
\81D
\81D");
1348 /* The usual case. Allow paying at a distance when
1349 * inside a tended shop. Should we change that?
1351 if (sk == 1 && resident) {
1357 for (shkp = next_shkp(fmon, FALSE); shkp;
1358 shkp = next_shkp(shkp->nmon, FALSE))
1359 if (canspotmon(shkp))
1361 if (shkp != resident && distu(shkp->mx, shkp->my) > 2) {
1363 pline("%s is not near enough to receive your payment.",
1365 pline("%s
\82Í
\89\93\82
\82É
\82¢
\82é
\82Ì
\82Å
\8ex
\95¥
\82¦
\82È
\82¢
\81D",
1377 pline("
\92N
\82É
\95¥
\82¤
\81H");
1381 if (getpos(&cc, TRUE, "the creature you want to pay") < 0)
1383 if (getpos(&cc, TRUE, "
\8ex
\95¥
\82¢
\82½
\82¢
\91\8a\8eè") < 0)
1384 return 0; /* player pressed ESC */
1389 pline("Try again...");
1391 pline("
\82à
\82¤
\88ê
\93x
\81D
\81D
\81D");
1394 if (u.ux == cx && u.uy == cy) {
1396 You("are generous to yourself.");
1398 pline("
\8e©
\95ª
\8e©
\90g
\82É
\82È
\82ñ
\82Ä
\8bC
\91O
\82Ì
\82¢
\82¢
\82±
\82Æ
\81I");
1401 mtmp = m_at(cx, cy);
1404 There("is no one there to receive your payment.");
1406 pline("
\8ex
\95¥
\82¢
\82ð
\8eó
\82¯
\82Æ
\82ê
\82é
\91\8a\8eè
\82Í
\82¢
\82È
\82¢
\81D");
1411 pline("%s is not interested in your payment.", Monnam(mtmp));
1413 pline("%s
\82Í
\8ex
\95¥
\82¢
\82É
\8b»
\96¡
\82ð
\8e¦
\82³
\82È
\82¢
\81D", Monnam(mtmp));
1416 if (mtmp != resident && distu(mtmp->mx, mtmp->my) > 2) {
1418 pline("%s is too far to receive your payment.", Monnam(mtmp));
1420 pline("%s
\82Í
\8ex
\95¥
\82¢
\82É
\8b»
\96¡
\82ð
\8e¦
\82³
\82È
\82¢
\81D", Monnam(mtmp));
1427 debugpline0("dopay: null shkp.");
1432 ltmp = eshkp->robbed;
1434 /* wake sleeping shk when someone who owes money offers payment */
1435 if (ltmp || eshkp->billct || eshkp->debit)
1436 rouse_shk(shkp, TRUE);
1438 if (!shkp->mcanmove || shkp->msleeping) { /* still asleep/paralyzed */
1440 pline("%s %s.", Monnam(shkp),
1441 rn2(2) ? "seems to be napping" : "doesn't respond");
1443 pline("%s
\82Í%s
\81D", Monnam(shkp),
1444 rn2(2) ? "
\8b\8f\96°
\82è
\82ð
\82µ
\82Ä
\82¢
\82é
\82æ
\82¤
\82¾" : "
\94½
\89\9e\82ª
\82È
\82¢");
1449 if (shkp != resident && NOTANGRY(shkp)) {
1450 umoney = money_cnt(invent);
1453 You("do not owe %s anything.", mon_nam(shkp));
1455 You("%s
\82É
\8eØ
\82è
\82Í
\82È
\82¢
\81D", mon_nam(shkp));
1458 You("%shave no money.", stashed_gold ? "seem to " : "");
1460 You("
\82¨
\8bà
\82ª
\82È
\82¢%s
\81D", stashed_gold ? "
\82æ
\82¤
\82¾" : "");
1463 pline("But you have some gold stashed away.");
1465 pline("
\82µ
\82©
\82µ
\81C
\82 \82È
\82½
\82É
\82Í
\82¿
\82å
\82Á
\82Á
\82Æ
\82µ
\82½
\83w
\83\
\83N
\83\8a\82ª
\82 \82é
\81D");
1467 if (umoney > ltmp) {
1469 You("give %s the %ld gold piece%s %s asked for.",
1470 shkname(shkp), ltmp, plur(ltmp), mhe(shkp));
1472 You("%s
\82É
\96]
\82Ý
\92Ê
\82è%ld
\96\87\82Ì
\8bà
\89Ý
\82ð
\97^
\82¦
\82½
\81D",
1473 shkname(shkp), ltmp);
1478 You("give %s all your%s gold.", shkname(shkp),
1479 stashed_gold ? " openly kept" : "");
1481 You("%s
\82É%s
\82¨
\8bà
\91S
\95\94\82ð
\97^
\82¦
\82½
\81D", shkname(shkp),
1482 stashed_gold ? "
\8eè
\8e\9d\82¿
\82Ì" : "");
1487 pline("But you have hidden gold!");
1489 pline("
\82µ
\82©
\82µ
\81C
\82 \82È
\82½
\82Í
\83w
\83\
\83N
\83\8a\82ª
\82 \82é
\81I");
1491 if ((umoney < ltmp / 2L) || (umoney < ltmp && stashed_gold))
1493 pline("Unfortunately, %s doesn't look satisfied.", mhe(shkp));
1495 pline("
\8ec
\94O
\82È
\82ª
\82ç
\81C%s
\82Í
\96\9e\91«
\82µ
\82Ä
\82È
\82¢
\82æ
\82¤
\82¾
\81D", mhe(shkp));
1497 make_happy_shk(shkp, FALSE);
1502 /* ltmp is still eshkp->robbed here */
1503 if (!eshkp->billct && !eshkp->debit) {
1504 umoney = money_cnt(invent);
1505 if (!ltmp && NOTANGRY(shkp)) {
1507 You("do not owe %s anything.", shkname(shkp));
1509 You("%s
\82É
\8eØ
\82è
\82Í
\82È
\82¢
\81D", shkname(shkp));
1512 pline(no_money, stashed_gold ? " seem to" : "");
1514 pline(no_money, stashed_gold ? "
\82æ
\82¤
\82¾" : "");
1517 pline("%s is after blood, not money!", shkname(shkp));
1519 pline("%s
\82Í
\8c\8c\82Ü
\82Ý
\82ê
\82¾
\81D
\82¨
\8bà
\82Ç
\82±
\82ë
\82¶
\82á
\82È
\82¢
\81I", Monnam(shkp));
1520 if (umoney < ltmp / 2L || (umoney < ltmp && stashed_gold)) {
1523 pline(no_money, stashed_gold ? " seem to" : "");
1525 pline(no_money, stashed_gold ? "
\82æ
\82¤
\82¾" : "");
1527 pline(not_enough_money, mhim(shkp));
1531 pline("But since %s shop has been robbed recently,", mhis(shkp));
1533 pline("
\82µ
\82©
\82µ
\81C%s
\93X
\82Í
\8dÅ
\8bß
\93\90\82Ý
\82É
\82 \82Á
\82½
\82Ì
\82Å
\81C", mhis(shkp));
1535 pline("you %scompensate %s for %s losses.",
1536 (umoney < ltmp) ? "partially " : "", shkname(shkp),
1539 pline("%s
\82Ì
\91¹
\8e¸%s
\82ð
\95â
\93U
\82µ
\82½
\81D", mhis(shkp),
1540 (umoney < ltmp) ? "
\82Ì
\88ê
\95\94" : "");
1542 pay(umoney < ltmp ? umoney : ltmp, shkp);
1543 make_happy_shk(shkp, FALSE);
1545 /* shopkeeper is angry, but has not been robbed --
1546 * door broken, attacked, etc. */
1548 pline("%s is after your hide, not your money!", Monnam(shkp));
1550 pline("%s
\82Í
\82 \82È
\82½
\82Ì
\96½
\82ð
\91_
\82Á
\82Ä
\82¢
\82é
\81C
\82¨
\8bà
\82Ç
\82±
\82ë
\82¶
\82á
\82È
\82¢
\81I", Monnam(shkp));
1551 if (umoney < 1000L) {
1554 pline(no_money, stashed_gold ? " seem to" : "");
1556 pline(no_money, stashed_gold ? "
\82æ
\82¤
\82¾" : "");
1558 pline(not_enough_money, mhim(shkp));
1562 You("try to appease %s by giving %s 1000 gold pieces.",
1563 x_monnam(shkp, ARTICLE_THE, "angry", 0, FALSE), mhim(shkp));
1565 You("
\8bà
\89Ý1000
\96\87\82ð%s
\82É
\8eè
\93n
\82µ
\82Ä
\82È
\82¾
\82ß
\82æ
\82¤
\82Æ
\82µ
\82½
\81D",
1566 x_monnam(shkp, ARTICLE_THE, "
\93{
\82Á
\82½", 0, FALSE));
1569 if (strncmp(eshkp->customer, plname, PL_NSIZ) || rn2(3))
1570 make_happy_shk(shkp, FALSE);
1573 pline("But %s is as angry as ever.", shkname(shkp));
1575 pline("
\82µ
\82©
\82µ%s
\82Í
\82Ü
\82¾
\93{
\82Á
\82Ä
\82¢
\82é
\81D", shkname(shkp));
1579 if (shkp != resident) {
1580 impossible("dopay: not to shopkeeper?");
1585 /* pay debt, if any, first */
1587 long dtmp = eshkp->debit;
1588 long loan = eshkp->loan;
1590 umoney = money_cnt(invent);
1591 #if 0 /*JP*//*
\96\96\94ö
\82É
\89ñ
\82·*/
1592 Sprintf(sbuf, "You owe %s %ld %s ", shkname(shkp), dtmp,
1598 Strcat(sbuf, "you picked up in the store.");
1600 Strcpy(sbuf, "
\93X
\82Ì
\92\86\82Å
\8fE
\82Á
\82½
\82à
\82Ì
\82É
\91Î
\82µ
\82Ä
\81C");
1604 "for gold picked up and the use of merchandise.");
1606 Strcpy(sbuf,"
\8fE
\82Á
\82½
\82¨
\8bà
\82â
\8eg
\82Á
\82½
\8eG
\89Ý
\82É
\91Î
\82µ
\82Ä
\81C");
1610 Strcat(sbuf, "for the use of merchandise.");
1612 Strcpy(sbuf, "
\8eg
\82Á
\82½
\8eG
\89Ý
\82É
\91Î
\82µ
\82Ä
\81C");
1613 #if 1 /*JP*//*
\8fã
\82©
\82ç
\88Ú
\93®*/
1614 Sprintf(eos(sbuf), "%s
\82É%ld%s
\82Ì
\8eØ
\82è
\82ª
\82 \82é
\81D",
1615 shkname(shkp), dtmp, currency(dtmp));
1618 if (umoney + eshkp->credit < dtmp) {
1620 pline("But you don't%s have enough gold%s.",
1621 stashed_gold ? " seem to" : "",
1622 eshkp->credit ? " or credit" : "");
1624 pline("
\82µ
\82©
\82µ
\81C
\82¨
\8bà%s
\91«
\82è
\82È
\82¢%s
\81D",
1625 eshkp->credit ? "
\82à
\97a
\82¯
\8bà
\82à" : "
\82ª",
1626 stashed_gold ? "
\82æ
\82¤
\82¾" : "");
1630 if (eshkp->credit >= dtmp) {
1631 eshkp->credit -= dtmp;
1635 Your("debt is covered by your credit.");
1637 Your("
\8eØ
\8bà
\82Í
\97a
\82¯
\8bà
\82Å
\95â
\82í
\82ê
\82½
\81D");
1638 } else if (!eshkp->credit) {
1639 money2mon(shkp, dtmp);
1643 You("pay that debt.");
1645 You("
\8eØ
\8bà
\82ð
\95¥
\82Á
\82½
\81D");
1648 dtmp -= eshkp->credit;
1650 money2mon(shkp, dtmp);
1654 pline("That debt is partially offset by your credit.");
1656 pline("
\82»
\82Ì
\8eØ
\8bà
\82Í
\88ê
\95\94\97a
\82¯
\8bà
\82Å
\91\8a\8eE
\82³
\82ê
\82½
\81D");
1658 You("pay the remainder.");
1660 You("
\8ec
\82è
\82ð
\95¥
\82Á
\82½
\81D");
1666 /* now check items on bill */
1667 if (eshkp->billct) {
1668 register boolean itemize;
1670 umoney = money_cnt(invent);
1671 if (!umoney && !eshkp->credit) {
1673 You("%shave no money or credit%s.",
1674 stashed_gold ? "seem to " : "", paid ? " left" : "");
1676 You("%s
\82¨
\8bà
\82à
\97a
\82¯
\8bà
\82à
\8e\9d\82Á
\82Ä
\82È
\82¢%s
\81D",
1677 paid ? "
\82à
\82¤" : "", stashed_gold ? "
\82æ
\82¤
\82¾" : "");
1681 if ((umoney + eshkp->credit) < cheapest_item(shkp)) {
1683 You("don't have enough money to buy%s the item%s you picked.",
1684 eshkp->billct > 1 ? " any of" : "", plur(eshkp->billct));
1686 pline("
\8fE
\82Á
\82½
\95i
\95¨
\82ð
\94\83\82¤
\82É
\82Í
\82¨
\8bà
\82ª
\91«
\82è
\82È
\82¢
\81D");
1690 pline("Maybe you have some gold stashed away?");
1692 You("
\82Ç
\82±
\82©
\82É
\82¨
\8bà
\82ð
\89B
\82µ
\82Ä
\82¢
\82é
\82Ì
\82©
\82à
\81H");
1696 /* this isn't quite right; it itemizes without asking if the
1697 * single item on the bill is partly used up and partly unpaid */
1699 iprompt = (eshkp->billct > 1 ? ynq("Itemized billing?") : 'y');
1701 iprompt = (eshkp->billct > 1 ? ynq("
\8cÂ
\95Ê
\82É
\8a¨
\92è
\82µ
\82Ü
\82·
\82©
\81H") : 'y');
1702 itemize = (iprompt == 'y');
1706 for (pass = 0; pass <= 1; pass++) {
1708 while (tmp < eshkp->billct) {
1710 register struct bill_x *bp = &(eshkp->bill_p[tmp]);
1712 /* find the object on one of the lists */
1713 if ((otmp = bp_to_obj(bp)) != 0) {
1714 /* if completely used up, object quantity is stale;
1715 restoring it to its original value here avoids
1716 making the partly-used-up code more complicated */
1718 otmp->quan = bp->bquan;
1720 impossible("Shopkeeper administration out of order.");
1721 setpaid(shkp); /* be nice to the player */
1724 if (pass == bp->useup && otmp->quan == bp->bquan) {
1725 /* pay for used-up items on first pass and others
1726 * on second, so player will be stuck in the store
1727 * less often; things which are partly used up
1728 * are processed on both passes */
1731 switch (dopayobj(shkp, bp, &otmp, pass, itemize)) {
1736 goto thanks; /*break*/
1751 *bp = eshkp->bill_p[--eshkp->billct];
1757 update_inventory(); /* Done in dopayobj() if itemize. */
1759 if (!ANGRY(shkp) && paid && !muteshk(shkp))
1761 verbalize("Thank you for shopping in %s %s!", s_suffix(shkname(shkp)),
1762 shtypes[eshkp->shoptype - SHOPBASE].name);
1764 verbalize("%s
\82Ì%s
\82Ö
\82Ü
\82½
\82Ç
\82¤
\82¼
\81I", shkname(shkp),
1765 shtypes[eshkp->shoptype - SHOPBASE].name);
1770 /* return 2 if used-up portion paid
1771 * 1 if paid successfully
1772 * 0 if not enough money
1773 * -1 if skip this object
1774 * -2 if no money/credit left
1777 dopayobj(shkp, bp, obj_p, which, itemize)
1778 register struct monst *shkp;
1779 register struct bill_x *bp;
1781 int which; /* 0 => used-up item, 1 => other (unpaid or lost) */
1784 register struct obj *obj = *obj_p;
1785 long ltmp, quan, save_quan;
1786 long umoney = money_cnt(invent);
1788 boolean stashed_gold = (hidden_gold() > 0L), consumed = (which == 0);
1790 if (!obj->unpaid && !bp->useup) {
1791 impossible("Paid object on bill??");
1794 if (itemize && umoney + ESHK(shkp)->credit == 0L) {
1796 You("%shave no money or credit left.",
1797 stashed_gold ? "seem to " : "");
1799 You("
\82à
\82¤
\82¨
\8bà
\82à
\97a
\82¯
\8bà
\82à
\82È
\82¢%s
\81D",
1800 stashed_gold ? "
\82æ
\82¤
\82¾" : "");
1804 /* we may need to temporarily adjust the object, if part of the
1805 original quantity has been used up but part remains unpaid */
1806 save_quan = obj->quan;
1808 /* either completely used up (simple), or split needed */
1810 if (quan > obj->quan) /* difference is amount used up */
1813 /* dealing with ordinary unpaid item */
1816 obj->quan = quan; /* to be used by doname() */
1817 obj->unpaid = 0; /* ditto */
1818 iflags.suppress_price++; /* affects containers */
1819 ltmp = bp->price * quan;
1820 buy = PAY_BUY; /* flag; if changed then return early */
1823 char qbuf[BUFSZ], qsfx[BUFSZ];
1826 Sprintf(qsfx, " for %ld %s. Pay?", ltmp, currency(ltmp));
1828 Sprintf(qsfx, "
\82Í%ld%s
\82Å
\82·.
\94\83\82¢
\82Ü
\82·
\82©
\81H", ltmp, currency(ltmp));
1830 (void) safe_qbuf(qbuf, (char *) 0, qsfx, obj,
1831 (quan == 1L) ? Doname2 : doname, ansimpleoname,
1832 (quan == 1L) ? "that" : "those");
1834 (void) safe_qbuf(qbuf, (char *) 0, qsfx, obj,
1835 (quan == 1L) ? Doname2 : doname, ansimpleoname,
1838 if (yn(qbuf) == 'n') {
1839 buy = PAY_SKIP; /* don't want to buy */
1840 } else if (quan < bp->bquan && !consumed) { /* partly used goods */
1841 obj->quan = bp->bquan - save_quan; /* used up amount */
1843 verbalize("%s for the other %s before buying %s.",
1844 ANGRY(shkp) ? "Pay" : "Please pay",
1845 simpleonames(obj), /* short name suffices */
1846 save_quan > 1L ? "these" : "this one");
1848 verbalize("
\82»
\82ê
\82ð
\94\83\82¤
\82Ü
\82¦
\82É
\91¼
\82Ì%s
\82ð%s",
1850 ANGRY(shkp) ? "
\95¥
\82¦
\81I" : "
\95¥
\82Á
\82Ä
\82
\82¾
\82³
\82¢
\81D");
1852 buy = PAY_SKIP; /* shk won't sell */
1855 if (buy == PAY_BUY && umoney + ESHK(shkp)->credit < ltmp) {
1857 You("don't%s have gold%s enough to pay for %s.",
1858 stashed_gold ? " seem to" : "",
1859 (ESHK(shkp)->credit > 0L) ? " or credit" : "",
1860 thesimpleoname(obj));
1862 You("%s
\82Ì
\91ã
\8bà
\82ð
\8ex
\95¥
\82¤
\82¾
\82¯
\82Ì
\82¨
\8bà%s
\8e\9d\82Á
\82Ä
\82È
\82¢%s
\81D",
1863 thesimpleoname(obj),
1864 (ESHK(shkp)->credit > 0L) ? "
\82à
\97a
\82¯
\8bà
\82à" : "
\82ð",
1865 stashed_gold ? "
\82æ
\82¤
\82¾" : "");
1867 buy = itemize ? PAY_SKIP : PAY_CANT;
1870 if (buy != PAY_BUY) {
1871 /* restore unpaid object to original state */
1872 obj->quan = save_quan;
1874 iflags.suppress_price--;
1880 shk_names_obj(shkp, obj,
1881 consumed ? "paid for %s at a cost of %ld gold piece%s.%s"
1882 : "bought %s for %ld gold piece%s.%s",
1885 shk_names_obj(shkp, obj,
1886 consumed ? "%s
\82É
\8bà
\89Ý%ld
\96\87%s
\82ð
\8ex
\95¥
\82Á
\82½
\81D%s"
1887 : "%s
\82ð
\8bà
\89Ý%ld
\96\87%s
\82Å
\94\83\82Á
\82½
\81D%s",
1890 obj->quan = save_quan; /* restore original count */
1891 /* quan => amount just bought, save_quan => remaining unpaid count */
1893 if (quan != bp->bquan) {
1894 /* eliminate used-up portion; remainder is still unpaid */
1895 bp->bquan = obj->quan;
1899 } else { /* completely used-up, so get rid of it */
1900 obj_extract_self(obj);
1901 /* assert( obj == *obj_p ); */
1903 *obj_p = 0; /* destroy pointer to freed object */
1906 update_inventory(); /* Done just once in dopay() if !itemize. */
1907 iflags.suppress_price--;
1911 static struct repo { /* repossession context */
1912 struct monst *shopkeeper;
1916 /* routine called after dying (or quitting) */
1919 int croaked; /* -1: escaped dungeon; 0: quit; 1: died */
1921 struct monst *mtmp, *mtmp2, *firstshk, *resident, *creditor, *hostile,
1924 boolean taken = FALSE, local;
1927 /* if we escaped from the dungeon, shopkeepers can't reach us;
1928 shops don't occur on level 1, but this could happen if hero
1929 level teleports out of the dungeon and manages not to die */
1932 /* [should probably also return false when dead hero has been
1933 petrified since shk shouldn't be able to grab inventory
1934 which has been shut inside a statue] */
1936 /* this is where inventory will end up if any shk takes it */
1937 repo.location.x = repo.location.y = 0;
1938 repo.shopkeeper = 0;
1941 * Scan all shopkeepers on the level, to prioritize them:
1942 * 1) keeper of shop hero is inside and who is owed money,
1943 * 2) keeper of shop hero is inside who isn't owed any money,
1944 * 3) other shk who is owed money, 4) other shk who is angry,
1945 * 5) any shk local to this level, and if none is found,
1946 * 6) first shk on monster list (last resort; unlikely, since
1947 * any nonlocal shk will probably be in the owed category
1948 * and almost certainly be in the angry category).
1950 resident = creditor = hostile = localshk = (struct monst *) 0;
1951 for (mtmp = next_shkp(fmon, FALSE); mtmp;
1952 mtmp = next_shkp(mtmp2, FALSE)) {
1955 local = on_level(&eshkp->shoplevel, &u.uz);
1956 if (local && index(u.ushops, eshkp->shoproom)) {
1957 /* inside this shk's shop [there might be more than one
1958 resident shk if hero is standing in a breech of a shared
1959 wall, so give priority to one who's also owed money] */
1960 if (!resident || eshkp->billct || eshkp->debit || eshkp->robbed)
1962 } else if (eshkp->billct || eshkp->debit || eshkp->robbed) {
1963 /* owe this shopkeeper money (might also owe others) */
1966 } else if (eshkp->following || ANGRY(mtmp)) {
1967 /* this shopkeeper is antagonistic (others might be too) */
1971 /* this shopkeeper's shop is on current level */
1977 /* give highest priority shopkeeper first crack */
1978 firstshk = resident ? resident
1979 : creditor ? creditor
1984 taken = inherits(firstshk, numsk, croaked);
1987 /* now handle the rest */
1988 for (mtmp = next_shkp(fmon, FALSE); mtmp;
1989 mtmp = next_shkp(mtmp2, FALSE)) {
1992 local = on_level(&eshkp->shoplevel, &u.uz);
1993 if (mtmp != firstshk) {
1995 taken |= inherits(mtmp, numsk, croaked);
1997 /* for bones: we don't want a shopless shk around */
2005 inherits(shkp, numsk, croaked)
2012 struct eshk *eshkp = ESHK(shkp);
2013 boolean take = FALSE, taken = FALSE;
2014 unsigned save_minvis = shkp->minvis;
2015 int roomno = *u.ushops;
2019 /* The simplifying principle is that first-come
2020 already took everything you had. */
2022 if (cansee(shkp->mx, shkp->my) && croaked) {
2024 if (has_head(shkp->data) && !rn2(2))
2026 Sprintf(takes, ", shakes %s %s,", mhis(shkp),
2027 mbodypart(shkp, HEAD));
2029 Strcpy(takes, "
\8eñ
\82ð
\90U
\82è
\81C");
2032 pline("%s %slooks at your corpse%s and %s.", Monnam(shkp),
2033 (!shkp->mcanmove || shkp->msleeping) ? "wakes up, " : "",
2034 takes, !inhishop(shkp) ? "disappears" : "sighs");
2036 pline("%s
\82Í%s
\82 \82È
\82½
\82Ì
\8e\80\91Ì
\82ð
\8c©
\82Ä%s%s
\81D", Monnam(shkp),
2037 (!shkp->mcanmove || shkp->msleeping) ? "
\96Ú
\82ð
\82³
\82Ü
\82·
\82Æ" : "",
2038 takes, !inhishop(shkp) ? "
\8ep
\82ð
\8fÁ
\82µ
\82½" : "
\97
\91§
\82ð
\82Â
\82¢
\82½");
2041 rouse_shk(shkp, FALSE); /* wake shk for bones */
2042 taken = (roomno == eshkp->shoproom);
2046 /* get one case out of the way: you die in the shop, the */
2047 /* shopkeeper is peaceful, nothing stolen, nothing owed. */
2048 if (roomno == eshkp->shoproom && inhishop(shkp) && !eshkp->billct
2049 && !eshkp->robbed && !eshkp->debit && NOTANGRY(shkp)
2050 && !eshkp->following) {
2051 taken = (invent != 0);
2054 pline("%s gratefully inherits all your possessions.",
2056 pline("%s
\82Í
\82 \82È
\82½
\82Ì
\8e\9d\82¿
\95¨
\82ð
\82 \82è
\82ª
\82½
\82
\8eó
\82¯
\82Æ
\82Á
\82½
\81D",
2062 if (eshkp->billct || eshkp->debit || eshkp->robbed) {
2063 if (roomno == eshkp->shoproom && inhishop(shkp))
2064 loss = addupbill(shkp) + eshkp->debit;
2065 if (loss < eshkp->robbed)
2066 loss = eshkp->robbed;
2070 if (eshkp->following || ANGRY(shkp) || take) {
2073 umoney = money_cnt(invent);
2075 if (!shkp->mcanmove || shkp->msleeping)
2077 Strcat(takes, "wakes up and ");
2079 Strcat(takes, "
\96Ú
\82ª
\82³
\82ß
\82é
\82Æ
\81C");
2080 if (distu(shkp->mx, shkp->my) > 2)
2082 Strcat(takes, "comes and ");
2084 Strcat(takes, "
\8bß
\82Ã
\82«
\81C");
2086 Strcat(takes, "takes");
2089 if (loss > umoney || !loss || roomno == eshkp->shoproom) {
2090 eshkp->robbed -= umoney;
2091 if (eshkp->robbed < 0L)
2094 money2mon(shkp, umoney);
2097 pline("%s %s all your possessions.", shkname(shkp), takes);
2099 pline("%s
\82Í%s
\82 \82È
\82½
\82Ì
\8e\9d\82¿
\95¨
\82·
\82×
\82Ä
\82ð
\82à
\82ç
\82Á
\82½
\81D", shkname(shkp), takes);
2101 /* where to put player's invent (after disclosure) */
2104 money2mon(shkp, loss);
2107 pline("%s %s the %ld %s %sowed %s.", Monnam(shkp), takes, loss,
2109 strncmp(eshkp->customer, plname, PL_NSIZ) ? "" : "you ",
2110 shkp->female ? "her" : "him");
2112 pline("%s
\82Í%s%s
\8eØ
\82è
\82Ä
\82¢
\82é%ld%s
\82ð
\8eó
\82¯
\82Æ
\82Á
\82½
\81D", Monnam(shkp), takes,
2113 strncmp(eshkp->customer, plname, PL_NSIZ) ?
2114 "" : "
\82 \82È
\82½
\82ª",
2115 loss, currency(loss));
2117 /* shopkeeper has now been paid in full */
2119 eshkp->following = 0;
2123 /* in case we create bones */
2124 rouse_shk(shkp, FALSE); /* wake up */
2125 if (!inhishop(shkp))
2126 home_shk(shkp, FALSE);
2129 shkp->minvis = save_minvis;
2138 register xchar ox, oy;
2139 struct eshk *eshkp = ESHK(shkp);
2141 /* if you're not in this shk's shop room, or if you're in its doorway
2142 or entry spot, then your gear gets dumped all the way inside */
2143 if (*u.ushops != eshkp->shoproom || IS_DOOR(levl[u.ux][u.uy].typ)
2144 || (u.ux == eshkp->shk.x && u.uy == eshkp->shk.y)) {
2145 /* shk.x,shk.y is the position immediately in
2146 * front of the door -- move in one more space
2150 ox += sgn(ox - eshkp->shd.x);
2151 oy += sgn(oy - eshkp->shd.y);
2152 } else { /* already inside this shk's shop */
2156 /* finish_paybill will deposit invent here */
2157 repo.location.x = ox;
2158 repo.location.y = oy;
2159 repo.shopkeeper = shkp;
2162 /* called at game exit, after inventory disclosure but before making bones */
2166 struct monst *shkp = repo.shopkeeper;
2167 int ox = repo.location.x, oy = repo.location.y;
2169 #if 0 /* don't bother */
2170 if (ox == 0 && oy == 0)
2171 impossible("finish_paybill: no location");
2173 /* normally done by savebones(), but that's too late in this case */
2175 /* if hero has any gold left, take it into shopkeeper's possession */
2177 long umoney = money_cnt(invent);
2180 money2mon(shkp, umoney);
2182 /* transfer rest of the character's inventory to the shop floor */
2183 drop_upon_death((struct monst *) 0, (struct obj *) 0, ox, oy);
2186 /* find obj on one of the lists */
2187 STATIC_OVL struct obj *
2189 register struct bill_x *bp;
2191 register struct obj *obj;
2192 register unsigned int id = bp->bo_id;
2195 obj = o_on(id, billobjs);
2202 * Look for o_id on all lists but billobj. Return obj or NULL if not found.
2203 * Its OK for restore_timers() to call this function, there should not
2204 * be any timeouts on the billobjs chain.
2211 struct monst *mon, *mmtmp[3];
2214 /* first check various obj lists directly */
2215 if ((obj = o_on(id, invent)) != 0)
2217 if ((obj = o_on(id, fobj)) != 0)
2219 if ((obj = o_on(id, level.buriedobjlist)) != 0)
2221 if ((obj = o_on(id, migrating_objs)) != 0)
2224 /* not found yet; check inventory for members of various monst lists */
2226 mmtmp[1] = migrating_mons;
2227 mmtmp[2] = mydogs; /* for use during level changes */
2228 for (i = 0; i < 3; i++)
2229 for (mon = mmtmp[i]; mon; mon = mon->nmon)
2230 if ((obj = o_on(id, mon->minvent)) != 0)
2233 /* not found at all */
2234 return (struct obj *) 0;
2237 /* Returns the price of an arbitrary item in the shop.
2238 Returns 0 if the item doesn't belong to a shopkeeper. */
2240 get_cost_of_shop_item(obj)
2241 register struct obj *obj;
2248 && obj->oclass != COIN_CLASS
2249 && obj != uball && obj != uchain
2250 && get_obj_location(obj, &x, &y, 0)
2252 || (obj->where == OBJ_FLOOR
2253 && !obj->no_charge && costly_spot(x, y)))
2254 && (shkp = shop_keeper(*in_rooms(x, y, SHOPBASE))) != 0
2255 && inhishop(shkp)) {
2256 cost = obj->quan * get_cost(obj, shkp);
2257 if (Has_contents(obj))
2258 cost += contained_cost(obj, shkp, 0L, FALSE, FALSE);
2263 /* calculate the value that the shk will charge for [one of] an object */
2266 register struct obj *obj;
2267 register struct monst *shkp; /* if angry, impose a surcharge */
2269 long tmp = getprice(obj, FALSE),
2270 /* used to perform a single calculation even when multiple
2271 adjustments (unID'd, dunce/tourist, charisma) are made */
2272 multiplier = 1L, divisor = 1L;
2276 /* shopkeeper may notice if the player isn't very knowledgeable -
2277 especially when gem prices are concerned */
2278 if (!obj->dknown || !objects[obj->otyp].oc_name_known) {
2279 if (obj->oclass == GEM_CLASS
2280 && objects[obj->otyp].oc_material == GLASS) {
2282 /* get a value that's 'random' from game to game, but the
2283 same within the same game */
2284 boolean pseudorand =
2285 (((int) ubirthday % obj->otyp) >= obj->otyp / 2);
2287 /* all gems are priced high - real or not */
2288 switch (obj->otyp - LAST_GEM) {
2290 i = pseudorand ? DIAMOND : OPAL;
2293 i = pseudorand ? SAPPHIRE : AQUAMARINE;
2296 i = pseudorand ? RUBY : JASPER;
2298 case 4: /* yellowish brown */
2299 i = pseudorand ? AMBER : TOPAZ;
2301 case 5: /* orange */
2302 i = pseudorand ? JACINTH : AGATE;
2304 case 6: /* yellow */
2305 i = pseudorand ? CITRINE : CHRYSOBERYL;
2308 i = pseudorand ? BLACK_OPAL : JET;
2311 i = pseudorand ? EMERALD : JADE;
2313 case 9: /* violet */
2314 i = pseudorand ? AMETHYST : FLUORITE;
2317 impossible("bad glass gem %d?", obj->otyp);
2321 tmp = (long) objects[i].oc_cost;
2322 } else if (!(obj->o_id % 4)) {
2323 /* unid'd, arbitrarily impose surcharge: tmp *= 4/3 */
2328 if (uarmh && uarmh->otyp == DUNCE_CAP)
2329 multiplier *= 4L, divisor *= 3L;
2330 else if ((Role_if(PM_TOURIST) && u.ulevel < (MAXULEV / 2))
2331 || (uarmu && !uarm && !uarmc)) /* touristy shirt visible */
2332 multiplier *= 4L, divisor *= 3L;
2334 if (ACURR(A_CHA) > 18)
2336 else if (ACURR(A_CHA) == 18)
2337 multiplier *= 2L, divisor *= 3L;
2338 else if (ACURR(A_CHA) >= 16)
2339 multiplier *= 3L, divisor *= 4L;
2340 else if (ACURR(A_CHA) <= 5)
2342 else if (ACURR(A_CHA) <= 7)
2343 multiplier *= 3L, divisor *= 2L;
2344 else if (ACURR(A_CHA) <= 10)
2345 multiplier *= 4L, divisor *= 3L;
2347 /* tmp = (tmp * multiplier) / divisor [with roundoff tweak] */
2350 /* tmp = (((tmp * 10) / divisor) + 5) / 10 */
2359 /* the artifact prices in artilist[] are also used as a score bonus;
2360 inflate their shop price here without affecting score calculation */
2364 /* anger surcharge should match rile_shk's, so we do it separately
2365 from the multiplier/divisor calculation */
2366 if (shkp && ESHK(shkp)->surcharge)
2367 tmp += (tmp + 2L) / 3L;
2371 /* returns the price of a container's content. the price
2372 * of the "top" container is added in the calling functions.
2373 * a different price quoted for selling as vs. buying.
2376 contained_cost(obj, shkp, price, usell, unpaid_only)
2381 boolean unpaid_only;
2383 register struct obj *otmp;
2385 /* price of contained objects; "top" container handled by caller */
2386 for (otmp = obj->cobj; otmp; otmp = otmp->nobj) {
2387 if (otmp->oclass == COIN_CLASS)
2391 if (saleable(shkp, otmp) && !otmp->unpaid
2392 && otmp->oclass != BALL_CLASS
2393 && !(otmp->oclass == FOOD_CLASS && otmp->oeaten)
2394 && !(Is_candle(otmp)
2395 && otmp->age < 20L * (long) objects[otmp->otyp].oc_cost))
2396 price += set_cost(otmp, shkp);
2397 } else if (!otmp->no_charge && (otmp->unpaid || !unpaid_only)) {
2398 price += get_cost(otmp, shkp) * otmp->quan;
2401 if (Has_contents(otmp))
2402 price = contained_cost(otmp, shkp, price, usell, unpaid_only);
2410 register struct obj *obj;
2412 register struct obj *otmp;
2413 register long value = 0L;
2415 /* accumulate contained gold */
2416 for (otmp = obj->cobj; otmp; otmp = otmp->nobj)
2417 if (otmp->oclass == COIN_CLASS)
2418 value += otmp->quan;
2419 else if (Has_contents(otmp))
2420 value += contained_gold(otmp);
2426 dropped_container(obj, shkp, sale)
2427 register struct obj *obj;
2428 register struct monst *shkp;
2429 register boolean sale;
2431 register struct obj *otmp;
2433 /* the "top" container is treated in the calling fn */
2434 for (otmp = obj->cobj; otmp; otmp = otmp->nobj) {
2435 if (otmp->oclass == COIN_CLASS)
2438 if (!otmp->unpaid && !(sale && saleable(shkp, otmp)))
2439 otmp->no_charge = 1;
2441 if (Has_contents(otmp))
2442 dropped_container(otmp, shkp, sale);
2447 picked_container(obj)
2448 register struct obj *obj;
2450 register struct obj *otmp;
2452 /* the "top" container is treated in the calling fn */
2453 for (otmp = obj->cobj; otmp; otmp = otmp->nobj) {
2454 if (otmp->oclass == COIN_CLASS)
2457 if (otmp->no_charge)
2458 otmp->no_charge = 0;
2460 if (Has_contents(otmp))
2461 picked_container(otmp);
2466 special_stock(obj, shkp, quietly)
2471 /* for unique situations */
2472 if (ESHK(shkp)->shoptype == CANDLESHOP
2473 && obj->otyp == CANDELABRUM_OF_INVOCATION) {
2475 if (is_izchak(shkp, TRUE) && !u.uevent.invoked) {
2477 verbalize("No thanks, I'd hang onto that if I were you.");
2479 verbalize("
\82¢
\82â
\81C
\82¢
\82ç
\82È
\82¢
\81D
\8e\84\82È
\82ç
\82»
\82ê
\82ð
\8eè
\95ú
\82³
\82È
\82¢
\82Ë
\81D");
2483 "You'll need %d%s candle%s to go along with it.",
2484 (7 - obj->spe), (obj->spe > 0) ? " more" : "",
2485 plur(7 - obj->spe));
2488 "
\82»
\82ê
\82ð
\8eg
\82¤
\82É
\82Í%s%d
\96{
\82Ì
\82ë
\82¤
\82»
\82
\82ª
\95K
\97v
\82¾
\81D",
2489 (obj->spe > 0) ? "
\82 \82Æ" : "", (7 - obj->spe));
2491 /* [what if hero is already carrying enough candles?
2492 should Izchak explain how to attach them instead] */
2495 verbalize("I won't stock that. Take it out of here!");
2497 verbalize("
\82»
\82ê
\82Í
\8ed
\93ü
\82ê
\82È
\82¢
\82æ
\81D
\8e\9d\82Á
\82Ä
\82¢
\82«
\82È
\82³
\82¢
\81I");
2505 /* calculate how much the shk will pay when buying [all of] an object */
2508 register struct obj *obj;
2509 register struct monst *shkp;
2511 long tmp = getprice(obj, TRUE) * obj->quan, multiplier = 1L, divisor = 1L;
2513 if (uarmh && uarmh->otyp == DUNCE_CAP)
2515 else if ((Role_if(PM_TOURIST) && u.ulevel < (MAXULEV / 2))
2516 || (uarmu && !uarm && !uarmc)) /* touristy shirt visible */
2521 /* shopkeeper may notice if the player isn't very knowledgeable -
2522 especially when gem prices are concerned */
2523 if (!obj->dknown || !objects[obj->otyp].oc_name_known) {
2524 if (obj->oclass == GEM_CLASS) {
2525 /* different shop keepers give different prices */
2526 if (objects[obj->otyp].oc_material == GEMSTONE
2527 || objects[obj->otyp].oc_material == GLASS) {
2528 tmp = (obj->otyp % (6 - shkp->m_id % 3));
2529 tmp = (tmp + 3) * obj->quan;
2531 } else if (tmp > 1L && !rn2(4))
2532 multiplier *= 3L, divisor *= 4L;
2536 /* [see get_cost()] */
2544 /* avoid adjusting nonzero to zero */
2549 /* (no adjustment for angry shk here) */
2553 /* called when an item's value has been enhanced; if it happens to be
2554 on any shop bill, update that bill to reflect the new higher price
2555 [if the new price drops for some reason, keep the old one in place] */
2557 alter_cost(obj, amt)
2559 long amt; /* if 0, use regular shop pricing, otherwise force amount;
2560 if negative, use abs(amt) even if it's less than old cost */
2562 struct bill_x *bp = 0;
2566 for (shkp = next_shkp(fmon, TRUE); shkp; shkp = next_shkp(shkp, TRUE))
2567 if ((bp = onbill(obj, shkp, TRUE)) != 0) {
2568 new_price = !amt ? get_cost(obj, shkp) : (amt < 0L) ? -amt : amt;
2569 if (new_price > bp->price || amt < 0L) {
2570 bp->price = new_price;
2578 /* called from doinv(invent.c) for inventory of unpaid objects */
2580 unpaid_cost(unp_obj, include_contents)
2581 struct obj *unp_obj; /* known to be unpaid or contain unpaid */
2582 boolean include_contents;
2584 struct bill_x *bp = (struct bill_x *) 0;
2589 if (!get_obj_location(unp_obj, &ox, &oy, BURIED_TOO | CONTAINED_TOO))
2590 ox = u.ux, oy = u.uy; /* (shouldn't happen) */
2591 if ((shkp = shop_keeper(*in_rooms(ox, oy, SHOPBASE))) != 0) {
2592 bp = onbill(unp_obj, shkp, TRUE);
2594 /* didn't find shk? try searching bills */
2595 for (shkp = next_shkp(fmon, TRUE); shkp;
2596 shkp = next_shkp(shkp->nmon, TRUE))
2597 if ((bp = onbill(unp_obj, shkp, TRUE)) != 0)
2601 /* onbill() gave no message if unexpected problem occurred */
2602 if (!shkp || (unp_obj->unpaid && !bp)) {
2603 impossible("unpaid_cost: object wasn't on any bill.");
2606 amt = unp_obj->quan * bp->price;
2607 if (include_contents && Has_contents(unp_obj))
2608 amt = contained_cost(unp_obj, shkp, amt, FALSE, TRUE);
2614 add_one_tobill(obj, dummy, shkp)
2623 if (!billable(&shkp, obj, *u.ushops, TRUE))
2627 if (eshkp->billct == BILLSZ) {
2629 You("got that for free!");
2631 You("
\82»
\82ê
\82ð
\82½
\82¾
\82Å
\8eè
\82É
\93ü
\82ê
\82½
\81I");
2635 bct = eshkp->billct;
2636 bp = &(eshkp->bill_p[bct]);
2637 bp->bo_id = obj->o_id;
2638 bp->bquan = obj->quan;
2639 if (dummy) { /* a dummy object must be inserted into */
2640 bp->useup = 1; /* the billobjs chain here. crucial for */
2641 add_to_billobjs(obj); /* eating floorfood in shop. see eat.c */
2644 bp->price = get_cost(obj, shkp);
2650 add_to_billobjs(obj)
2653 if (obj->where != OBJ_FREE)
2654 panic("add_to_billobjs: obj not free");
2656 obj_stop_timers(obj);
2658 obj->nobj = billobjs;
2660 obj->where = OBJ_ONBILL;
2663 /* recursive billing of objects within containers. */
2665 bill_box_content(obj, ininv, dummy, shkp)
2666 register struct obj *obj;
2667 register boolean ininv, dummy;
2668 register struct monst *shkp;
2670 register struct obj *otmp;
2672 for (otmp = obj->cobj; otmp; otmp = otmp->nobj) {
2673 if (otmp->oclass == COIN_CLASS)
2676 /* the "top" box is added in addtobill() */
2677 if (!otmp->no_charge)
2678 add_one_tobill(otmp, dummy, shkp);
2679 if (Has_contents(otmp))
2680 bill_box_content(otmp, ininv, dummy, shkp);
2684 /* shopkeeper tells you what you bought or sold, sometimes partly IDing it */
2686 shk_names_obj(shkp, obj, fmt, amt, arg)
2689 const char *fmt; /* "%s %ld %s %s", doname(obj), amt, plur(amt), arg */
2693 char *obj_name, fmtbuf[BUFSZ];
2694 boolean was_unknown = !obj->dknown;
2697 /* Use real name for ordinary weapons/armor, and spell-less
2698 * scrolls/books (that is, blank and mail), but only if the
2699 * object is within the shk's area of interest/expertise.
2701 if (!objects[obj->otyp].oc_magic && saleable(shkp, obj)
2702 && (obj->oclass == WEAPON_CLASS || obj->oclass == ARMOR_CLASS
2703 || obj->oclass == SCROLL_CLASS || obj->oclass == SPBOOK_CLASS
2704 || obj->otyp == MIRROR)) {
2705 was_unknown |= !objects[obj->otyp].oc_name_known;
2706 makeknown(obj->otyp);
2708 obj_name = doname(obj);
2709 /* Use an alternate message when extra information is being provided */
2710 #if 0 /*JP*//*
\93ú
\96{
\8cê
\82Å
\82Í
\93¯
\82¶
\88µ
\82¢*/
2712 Sprintf(fmtbuf, "%%s; you %s", fmt);
2713 obj_name[0] = highc(obj_name[0]);
2714 pline(fmtbuf, obj_name, (obj->quan > 1L) ? "them" : "it", amt,
2717 You(fmt, obj_name, amt, plur(amt), arg);
2720 You(fmt, obj_name, amt, "", arg);
2724 /* decide whether a shopkeeper thinks an item belongs to her */
2726 billable(shkpp, obj, roomno, reset_nocharge)
2727 struct monst **shkpp; /* in: non-null if shk has been validated; out: shk */
2730 boolean reset_nocharge;
2732 struct monst *shkp = *shkpp;
2734 /* if caller hasn't supplied a shopkeeper, look one up now */
2738 shkp = shop_keeper(roomno);
2739 if (!shkp || !inhishop(shkp))
2743 /* perhaps we threw it away earlier */
2744 if (onbill(obj, shkp, FALSE)
2745 || (obj->oclass == FOOD_CLASS && obj->oeaten))
2747 /* outer container might be marked no_charge but still have contents
2748 which should be charged for; clear no_charge when picking things up */
2749 if (obj->no_charge) {
2750 if (!Has_contents(obj) || (contained_gold(obj) == 0L
2751 && contained_cost(obj, shkp, 0L, FALSE,
2752 !reset_nocharge) == 0L))
2753 shkp = 0; /* not billable */
2754 if (reset_nocharge && !shkp && obj->oclass != COIN_CLASS) {
2756 if (Has_contents(obj))
2757 picked_container(obj); /* clear no_charge */
2760 return shkp ? TRUE : FALSE;
2764 addtobill(obj, ininv, dummy, silent)
2766 boolean ininv, dummy, silent;
2768 struct monst *shkp = 0;
2769 long ltmp, cltmp, gltmp;
2773 if (!billable(&shkp, obj, *u.ushops, TRUE))
2776 if (obj->oclass == COIN_CLASS) {
2777 costly_gold(obj->ox, obj->oy, obj->quan);
2779 } else if (ESHK(shkp)->billct == BILLSZ) {
2782 You("got that for free!");
2784 You("
\82»
\82ê
\82ð
\82½
\82¾
\82Å
\8eè
\82É
\93ü
\82ê
\82½
\81I");
2788 ltmp = cltmp = gltmp = 0L;
2789 container = Has_contents(obj);
2791 if (!obj->no_charge)
2792 ltmp = get_cost(obj, shkp);
2794 if (obj->no_charge && !container) {
2800 cltmp = contained_cost(obj, shkp, cltmp, FALSE, FALSE);
2801 gltmp = contained_gold(obj);
2804 add_one_tobill(obj, dummy, shkp);
2806 bill_box_content(obj, ininv, dummy, shkp);
2807 picked_container(obj); /* reset contained obj->no_charge */
2812 costly_gold(obj->ox, obj->oy, gltmp);
2819 contentscount = count_unpaid(obj->cobj);
2820 } else { /* !container */
2821 add_one_tobill(obj, dummy, shkp);
2825 if (!muteshk(shkp) && !silent) {
2830 pline("%s has no interest in %s.", Monnam(shkp), the(xname(obj)));
2832 pline("%s
\82Í%s
\82É
\8b»
\96¡
\82ð
\8e¦
\82³
\82È
\82¢
\81D", Monnam(shkp), xname(obj));
2837 pline("%s will cost you %ld %s%s.", The(xname(obj)), ltmp,
2838 currency(ltmp), (obj->quan > 1L) ? " each" : "");
2840 pline("%s
\82Í%s
\82½
\82Á
\82½
\82Ì%ld%s
\82¾
\81D", xname(obj),
2841 (obj->quan > 1L) ? "
\88ê
\82Â" : "", ltmp, currency(ltmp));
2844 long save_quan = obj->quan;
2847 Strcpy(buf, "\"For you, ");
2849 Strcat(buf, "scum;");
2851 append_honorific(buf);
2852 Strcat(buf, "; only");
2855 Strcpy(buf, "
\81u");
2857 Strcat(buf, "
\82±
\82Ì
\83N
\83\
\82Á
\82½
\82ê
\81C");
2859 append_honorific(buf);
2860 Strcat(buf, "
\81C");
2863 obj->quan = 1L; /* fool xname() into giving singular */
2865 pline("%s %ld %s %s %s%s.\"", buf, ltmp, currency(ltmp),
2866 (save_quan > 1L) ? "per" : (contentscount && !obj->unpaid)
2867 ? "for the contents of this"
2870 (contentscount && obj->unpaid) ? and_its_contents : "");
2872 pline("%s%s%s
\82½
\82Á
\82½
\82Ì%ld%s
\82¾
\81D
\81v", buf, xname(obj),
2873 (save_quan > 1L) ? "
\82Í
\88ê
\82Â" : (contentscount && !obj->unpaid)
2874 ? "
\82Ì
\92\86\90g
\82Í"
2876 ltmp, currency(ltmp));
2878 obj->quan = save_quan;
2880 } else if (!silent) {
2883 pline_The("list price of %s%s%s is %ld %s%s.",
2884 (contentscount && !obj->unpaid) ? the_contents_of : "",
2886 (contentscount && obj->unpaid) ? and_its_contents : "",
2887 ltmp, currency(ltmp), (obj->quan > 1L) ? " each" : "");
2889 pline_The("%s%s%s%s
\82½
\82Á
\82½
\82Ì%ld%s
\82¾.",
2891 (contentscount && !obj->unpaid) ? "
\82Ì
\92\86\90g
\82Í" : "",
2892 (contentscount && obj->unpaid) ? and_its_contents : "",
2893 (obj->quan > 1L) ? "
\82»
\82ê
\82¼
\82ê" : "", ltmp, currency(ltmp));
2897 pline("%s does not notice.", Monnam(shkp));
2899 pline("%s
\82Í
\8bC
\82ª
\82Â
\82¢
\82Ä
\82¢
\82È
\82¢
\81D", Monnam(shkp));
2904 append_honorific(buf)
2907 /* (chooses among [0]..[3] normally; [1]..[4] after the
2908 Wizard has been killed or invocation ritual performed) */
2910 static const char *const honored[] = { "good", "honored", "most gracious",
2912 "most renowned and sacred" };
2914 static const char *const honored[] = {
2915 "
\82â
\82\9f", "
\82â
\82\9f\81C
\96¼
\97_
\82 \82é", "
\82â
\82\9f\81C
\8fã
\95i
\82È",
2916 "
\82â
\82\9f\81C
\91¸
\8ch
\82·
\82é",
2917 "
\82â
\82\9f\81C
\8d\82\96¼
\82Å
\90_
\90¹
\82È"
2920 Strcat(buf, honored[rn2(SIZE(honored) - 1) + u.uevent.udemigod]);
2921 #if 0 /*JP*//*
\93ú
\96{
\8cê
\82Å
\82Í
\82»
\82±
\82Ü
\82Å
\82µ
\82È
\82¢*/
2922 if (is_vampire(youmonst.data))
2923 Strcat(buf, (flags.female) ? " dark lady" : " dark lord");
2924 else if (is_elf(youmonst.data))
2925 Strcat(buf, (flags.female) ? " hiril" : " hir");
2929 Strcat(buf, !is_human(youmonst.data) ? " creature" : (flags.female)
2933 Strcat(buf, !is_human(youmonst.data) ? "
\90¶
\95¨
\82³
\82ñ" : (flags.female)
2934 ? "
\82¨
\8fì
\82³
\82ñ"
2935 : "
\92U
\93ß
\82³
\82ñ");
2940 splitbill(obj, otmp)
2941 register struct obj *obj, *otmp;
2943 /* otmp has been split off from obj */
2944 register struct bill_x *bp;
2946 register struct monst *shkp = shop_keeper(*u.ushops);
2948 if (!shkp || !inhishop(shkp)) {
2949 impossible("splitbill: no resident shopkeeper??");
2952 bp = onbill(obj, shkp, FALSE);
2954 impossible("splitbill: not on bill?");
2957 if (bp->bquan < otmp->quan) {
2958 impossible("Negative quantity on bill??");
2960 if (bp->bquan == otmp->quan) {
2961 impossible("Zero quantity on bill??");
2963 bp->bquan -= otmp->quan;
2965 if (ESHK(shkp)->billct == BILLSZ)
2969 bp = &(ESHK(shkp)->bill_p[ESHK(shkp)->billct]);
2970 bp->bo_id = otmp->o_id;
2971 bp->bquan = otmp->quan;
2974 ESHK(shkp)->billct++;
2979 sub_one_frombill(obj, shkp)
2980 register struct obj *obj;
2981 register struct monst *shkp;
2983 register struct bill_x *bp;
2985 if ((bp = onbill(obj, shkp, FALSE)) != 0) {
2986 register struct obj *otmp;
2989 if (bp->bquan > obj->quan) {
2992 otmp->oextra = (struct oextra *) 0;
2993 bp->bo_id = otmp->o_id = context.ident++;
2994 otmp->where = OBJ_FREE;
2995 otmp->quan = (bp->bquan -= obj->quan);
2996 otmp->owt = 0; /* superfluous */
2998 add_to_billobjs(otmp);
3001 ESHK(shkp)->billct--;
3004 /* DRS/NS 2.2.6 messes up -- Peter Kendell */
3005 int indx = ESHK(shkp)->billct;
3007 *bp = ESHK(shkp)->bill_p[indx];
3010 *bp = ESHK(shkp)->bill_p[ESHK(shkp)->billct];
3013 } else if (obj->unpaid) {
3014 impossible("sub_one_frombill: unpaid object not on bill");
3019 /* recursive check of unpaid objects within nested containers. */
3021 subfrombill(obj, shkp)
3022 register struct obj *obj;
3023 register struct monst *shkp;
3025 register struct obj *otmp;
3027 sub_one_frombill(obj, shkp);
3029 if (Has_contents(obj))
3030 for (otmp = obj->cobj; otmp; otmp = otmp->nobj) {
3031 if (otmp->oclass == COIN_CLASS)
3034 if (Has_contents(otmp))
3035 subfrombill(otmp, shkp);
3037 sub_one_frombill(otmp, shkp);
3042 stolen_container(obj, shkp, price, ininv)
3052 /* the price of contained objects; caller handles top container */
3053 for (otmp = obj->cobj; otmp; otmp = otmp->nobj) {
3054 if (otmp->oclass == COIN_CLASS)
3057 if (!billable(&shkp, otmp, ESHK(shkp)->shoproom, TRUE)) {
3058 /* billable() returns false for objects already on bill */
3059 if ((bp = onbill(otmp, shkp, FALSE)) == 0)
3061 /* this assumes that we're being called by stolen_value()
3062 (or by a recursive call to self on behalf of it) where
3063 the cost of this object is about to be added to shop
3064 debt in place of having it remain on the current bill */
3065 billamt = bp->bquan * bp->price;
3066 sub_one_frombill(otmp, shkp); /* avoid double billing */
3071 else if (ininv ? otmp->unpaid : !otmp->no_charge)
3072 price += otmp->quan * get_cost(otmp, shkp);
3074 if (Has_contents(otmp))
3075 price = stolen_container(otmp, shkp, price, ininv);
3082 stolen_value(obj, x, y, peaceful, silent)
3085 boolean peaceful, silent;
3087 long value = 0L, gvalue = 0L, billamt = 0L;
3088 char roomno = *in_rooms(x, y, SHOPBASE);
3090 struct monst *shkp = 0;
3092 if (!billable(&shkp, obj, roomno, FALSE)) {
3093 /* things already on the bill yield a not-billable result, so
3094 we need to check bill before deciding that shk doesn't care */
3095 if ((bp = onbill(obj, shkp, FALSE)) == 0)
3097 /* shk does care; take obj off bill to avoid double billing */
3098 billamt = bp->bquan * bp->price;
3099 sub_one_frombill(obj, shkp);
3102 if (obj->oclass == COIN_CLASS) {
3103 gvalue += obj->quan;
3107 else if (!obj->no_charge)
3108 value += obj->quan * get_cost(obj, shkp);
3110 if (Has_contents(obj)) {
3112 (obj->where == OBJ_INVENT || obj->where == OBJ_FREE);
3114 value += stolen_container(obj, shkp, 0L, ininv);
3116 gvalue += contained_gold(obj);
3120 if (gvalue + value == 0L)
3126 boolean credit_use = !!ESHK(shkp)->credit;
3127 value = check_credit(value, shkp);
3128 /* 'peaceful' affects general treatment, but doesn't affect
3129 * the fact that other code expects that all charges after the
3130 * shopkeeper is angry are included in robbed, not debit */
3132 ESHK(shkp)->robbed += value;
3134 ESHK(shkp)->debit += value;
3137 const char *still = "";
3140 if (ESHK(shkp)->credit) {
3142 You("have %ld %s credit remaining.", ESHK(shkp)->credit,
3143 currency(ESHK(shkp)->credit));
3145 You("%ld%s
\82Ì
\97a
\82¯
\8bà
\82ª
\8ec
\82Á
\82Ä
\82¢
\82é
\81D", ESHK(shkp)->credit,
3146 currency(ESHK(shkp)->credit));
3149 } else if (!value) {
3151 You("have no credit remaining.");
3153 pline("
\97a
\82¯
\8bà
\82Í
\82È
\82
\82È
\82Á
\82½
\81D");
3159 still = "
\82³
\82ç
\82É";
3161 if (obj->oclass == COIN_CLASS)
3163 You("%sowe %s %ld %s!", still, mon_nam(shkp), value,
3166 You("%s%s
\82É%ld%s
\82Ì
\8eØ
\82è
\82ð
\82Â
\82
\82Á
\82½
\81I", still, mon_nam(shkp), value,
3171 You("%sowe %s %ld %s for %s!", still, mon_nam(shkp), value,
3172 currency(value), obj->quan > 1L ? "them" : "it");
3174 You("%s%s
\82É%ld%s
\82Ì
\8eØ
\82è
\82ð
\82Â
\82
\82Á
\82½
\81I", still, mon_nam(shkp), value,
3179 ESHK(shkp)->robbed += value;
3182 if (cansee(shkp->mx, shkp->my)) {
3184 Norep("%s booms: \"%s, you are a thief!\"", Monnam(shkp),
3187 Norep("%s
\82Í
\8b©
\82ñ
\82¾
\81F
\81u%s
\81C
\91Ò
\82Ä
\81I
\82±
\82Ì
\82Ç
\82ë
\82Ú
\82¤
\82ß
\81I
\81v", Monnam(shkp),
3192 Norep("You hear a scream, \"Thief!\"");
3194 Norep("
\8bà
\90Ø
\82è
\90º
\82ð
\95·
\82¢
\82½
\81C
\81u
\91Ò
\82Ä
\81I
\82±
\82Ì
\82Ç
\82ë
\82Ú
\82¤
\82ß
\81I
\81v");
3197 (void) angry_guards(FALSE);
3202 /* auto-response flag for/from "sell foo?" 'a' => 'y', 'q' => 'n' */
3203 static char sell_response = 'a';
3204 static int sell_how = SELL_NORMAL;
3205 /* can't just use sell_response='y' for auto_credit because the 'a' response
3206 shouldn't carry over from ordinary selling to credit selling */
3207 static boolean auto_credit = FALSE;
3210 sellobj_state(deliberate)
3213 /* If we're deliberately dropping something, there's no automatic
3214 response to the shopkeeper's "want to sell" query; however, if we
3215 accidentally drop anything, the shk will buy it/them without asking.
3216 This retains the old pre-query risk that slippery fingers while in
3217 shops entailed: you drop it, you've lost it.
3219 sell_response = (deliberate != SELL_NORMAL) ? '\0' : 'a';
3220 sell_how = deliberate;
3221 auto_credit = FALSE;
3226 register struct obj *obj;
3229 register struct monst *shkp;
3230 register struct eshk *eshkp;
3231 long ltmp = 0L, cltmp = 0L, gltmp = 0L, offer, shkmoney;
3232 boolean saleitem, cgold = FALSE, container = Has_contents(obj);
3233 boolean isgold = (obj->oclass == COIN_CLASS);
3234 boolean only_partially_your_contents = FALSE;
3236 if (!(shkp = shop_keeper(*in_rooms(x, y, SHOPBASE))) || !inhishop(shkp))
3238 if (!costly_spot(x, y))
3243 if (obj->unpaid && !container && !isgold) {
3244 sub_one_frombill(obj, shkp);
3248 /* find the price of content before subfrombill */
3249 cltmp = contained_cost(obj, shkp, cltmp, TRUE, FALSE);
3250 /* find the value of contained gold */
3251 gltmp += contained_gold(obj);
3252 cgold = (gltmp > 0L);
3255 saleitem = saleable(shkp, obj);
3256 if (!isgold && !obj->unpaid && saleitem)
3257 ltmp = set_cost(obj, shkp);
3259 offer = ltmp + cltmp;
3261 /* get one case out of the way: nothing to sell, and no gold */
3262 if (!isgold && ((offer + gltmp) == 0L || sell_how == SELL_DONTSELL)) {
3263 boolean unpaid = is_unpaid(obj);
3266 dropped_container(obj, shkp, FALSE);
3267 if (!obj->unpaid && !saleitem)
3270 subfrombill(obj, shkp);
3274 if (!unpaid && (sell_how != SELL_DONTSELL)
3275 && !special_stock(obj, shkp, FALSE))
3277 pline("%s seems uninterested.", Monnam(shkp));
3279 pline("%s
\82Í
\8b»
\96¡
\82ª
\82È
\82¢
\82æ
\82¤
\82¾
\81D", Monnam(shkp));
3283 /* you dropped something of your own - probably want to sell it */
3284 rouse_shk(shkp, TRUE); /* wake up sleeping or paralyzed shk */
3287 if (ANGRY(shkp)) { /* they become shop-objects, no pay */
3290 verbalize("Thank you, scum!");
3292 verbalize("
\82 \82è
\82ª
\82Æ
\82æ
\81C
\82±
\82Ì
\83N
\83\
\82Á
\82½
\82ê
\81I");
3293 subfrombill(obj, shkp);
3297 if (eshkp->robbed) { /* shkp is not angry? */
3302 if ((eshkp->robbed -= offer < 0L))
3304 if (offer && !muteshk(shkp))
3307 "Thank you for your contribution to restock this recently plundered shop.");
3309 "
\8añ
\91¡
\82ð
\82Ç
\82¤
\82à
\82 \82è
\82ª
\82Æ
\82¤
\81D
\8dÅ
\8bß
\93\90\82Ý
\82É
\82 \82Á
\82Ä
\8eQ
\82Á
\82Ä
\82½
\82ñ
\82¾
\81D");
3310 subfrombill(obj, shkp);
3314 if (isgold || cgold) {
3318 if (eshkp->debit >= gltmp) {
3319 if (eshkp->loan) { /* you carry shop's gold */
3320 if (eshkp->loan >= gltmp)
3321 eshkp->loan -= gltmp;
3325 eshkp->debit -= gltmp;
3327 Your("debt is %spaid off.", eshkp->debit ? "partially " : "");
3329 Your("
\8eØ
\8bà
\82Í%s
\8ex
\95¥
\82í
\82ê
\82½
\81D", eshkp->debit ? "
\88ê
\95\94" : "");
3331 long delta = gltmp - eshkp->debit;
3333 eshkp->credit += delta;
3338 Your("debt is paid off.");
3340 Your("
\8eØ
\8bà
\82Í
\8ex
\95¥
\82í
\82ê
\82½
\81D");
3342 if (eshkp->credit == delta)
3344 You("have established %ld %s credit.", delta,
3347 pline("%ld%s
\82ð
\97a
\82¯
\82½
\81D", delta,
3352 pline("%ld %s added to your credit; total is now %ld %s.",
3353 delta, currency(delta), eshkp->credit,
3354 currency(eshkp->credit));
3356 pline("
\97a
\82¯
\8bà
\82É%ld%s
\92Ç
\89Á
\82³
\82ê
\82½;
\8d\87\8cv
\82Í%ld%s
\82É
\82È
\82Á
\82½
\81D.",
3357 delta, currency(delta), eshkp->credit,
3358 currency(eshkp->credit));
3365 dropped_container(obj, shkp, FALSE);
3366 if (!obj->unpaid && !saleitem)
3368 subfrombill(obj, shkp);
3374 if ((!saleitem && !(container && cltmp > 0L)) || eshkp->billct == BILLSZ
3375 || obj->oclass == BALL_CLASS || obj->oclass == CHAIN_CLASS
3376 || offer == 0L || (obj->oclass == FOOD_CLASS && obj->oeaten)
3378 && obj->age < 20L * (long) objects[obj->otyp].oc_cost)) {
3380 pline("%s seems uninterested%s.", Monnam(shkp),
3381 cgold ? " in the rest" : "");
3383 pline("%s
\82Í%s
\8b»
\96¡
\82ª
\82È
\82¢
\82æ
\82¤
\82¾
\81D", Monnam(shkp),
3384 cgold ? "
\8ec
\82è
\95¨
\82É
\82Í" : "");
3387 dropped_container(obj, shkp, FALSE);
3392 shkmoney = money_cnt(shkp->minvent);
3394 char c, qbuf[BUFSZ];
3398 long tmpcr = ((offer * 9L) / 10L) + (offer <= 1L);
3400 if (sell_how == SELL_NORMAL || auto_credit) {
3401 c = sell_response = 'y';
3402 } else if (sell_response != 'n') {
3404 pline("%s cannot pay you at present.", shkname(shkp));
3406 pline("%s
\82Í
\8d¡
\82Ì
\82Æ
\82±
\82ë
\82Í
\8ex
\95¥
\82¦
\82È
\82¢
\81D", Monnam(shkp));
3408 Sprintf(qbuf, "Will you accept %ld %s in credit for ", tmpcr,
3410 c = ynaq(safe_qbuf(qbuf, qbuf, "?", obj, doname, thesimpleoname,
3411 (obj->quan == 1L) ? "that" : "those"));
3413 Sprintf(qsfx, "
\82É
\82Â
\82¢
\82Ä%ld%s
\82Ì
\97a
\82¯
\8bà
\82ð
\8eó
\82¯
\82¢
\82ê
\82Ü
\82·
\82©
\81H", tmpcr,
3415 c = ynaq(safe_qbuf(qbuf, "", qsfx, obj, doname, thesimpleoname,
3422 } else /* previously specified "quit" */
3429 (sell_how != SELL_NORMAL)
3430 ? "traded %s for %ld zorkmid%s in %scredit."
3431 : "relinquish %s and acquire %ld zorkmid%s in %scredit.",
3432 tmpcr, (eshkp->credit > 0L) ? "additional " : "");
3436 (sell_how != SELL_NORMAL)
3437 ? "%s
\82ð
\8bà
\89Ý%ld
\96\87\95ª
\82Ì
\97a
\82¯
\8bà
\82Å
\8eó
\82¯
\82Æ
\82Á
\82½%s
\81D"
3438 : "%s
\82ð
\93n
\82µ
\81C
\8bà
\89Ý%ld
\96\87\95ª
\82Ì
\97a
\82¯
\8bà
\82ð
\93¾
\82½%s
\81D",
3441 eshkp->credit += tmpcr;
3442 subfrombill(obj, shkp);
3445 sell_response = 'n';
3447 dropped_container(obj, shkp, FALSE);
3450 subfrombill(obj, shkp);
3453 char qbuf[BUFSZ], qsfx[BUFSZ];
3454 boolean short_funds = (offer > shkmoney), one;
3458 if (!sell_response) {
3459 long yourc = 0L, shksc;
3462 /* number of items owned by shk */
3463 shksc = count_contents(obj, TRUE, TRUE, FALSE);
3464 /* number of items owned by you (total - shksc) */
3465 yourc = count_contents(obj, TRUE, TRUE, TRUE) - shksc;
3466 only_partially_your_contents = shksc && yourc;
3469 "<shk> offers * for ..." query formatting.
3471 "... your <object>. Sell it?"
3472 "... your <objects>. Sell them?"
3473 A container is either owned by the hero, or already
3474 owned by the shk (!ltmp), or the shk isn't interested
3475 in buying it (also !ltmp). It's either empty (!cltmp)
3476 or it has contents owned by the hero or it has some
3477 contents owned by the hero and others by the shk.
3478 (The case where it has contents already entirely owned
3479 by the shk is treated the same was if it were empty
3480 since the hero isn't selling any of those contents.)
3482 "... your <empty bag>. Sell it?"
3483 "... your <bag> and its contents. Sell them?"
3484 "... your <bag> and item inside. Sell them?"
3485 "... your <bag> and items inside. Sell them?"
3487 "... your item in the <bag>. Sell it?"
3488 "... your items in the <bag>. Sell them?"
3491 Sprintf(qbuf, "%s offers%s %ld gold piece%s for %s%s ",
3492 shkname(shkp), short_funds ? " only" : "", offer,
3495 ? ((yourc == 1L) ? "your item in " : "your items in ")
3497 obj->unpaid ? "the" : "your");
3498 one = obj->unpaid ? (yourc == 1L) : (obj->quan == 1L && !cltmp);
3499 Sprintf(qsfx, "%s. Sell %s?",
3501 ? (only_partially_your_contents
3502 ? ((yourc == 1L) ? " and item inside"
3503 : " and items inside")
3506 one ? "it" : "them");
3507 (void) safe_qbuf(qbuf, qbuf, qsfx, obj, xname, simpleonames,
3508 one ? "that" : "those");
3511 "%s
\82Í
\82 \82È
\82½
\82Ì", Monnam(shkp));
3513 "%s
\82É%ld
\82Ì
\92l%s
\81D
\94\84\82è
\82Ü
\82·
\82©
\81H",
3514 (!ltmp && cltmp) ? "
\82Ì
\92\86\90g" : "",
3516 short_funds ? "
\82µ
\82©
\82Â
\82¯
\82È
\82©
\82Á
\82½" : "
\82ð
\82Â
\82¯
\82½");
3517 (void) safe_qbuf(qbuf, qbuf, qsfx, obj, xname, simpleonames,
3521 qbuf[0] = '\0'; /* just to pacify lint */
3523 switch (sell_response ? sell_response : ynaq(qbuf)) {
3525 sell_response = 'n';
3528 dropped_container(obj, shkp, FALSE);
3531 subfrombill(obj, shkp);
3534 sell_response = 'y';
3537 dropped_container(obj, shkp, TRUE);
3538 if (!obj->unpaid && !saleitem)
3540 subfrombill(obj, shkp);
3543 shk_names_obj(shkp, obj,
3544 (sell_how != SELL_NORMAL)
3545 ? ((!ltmp && cltmp && only_partially_your_contents)
3546 ? "sold some items inside %s for %ld gold piece%s.%s"
3547 : "sold %s for %ld gold piece%s.%s")
3548 : "relinquish %s and receive %ld gold piece%s in compensation.%s",
3551 shk_names_obj(shkp, obj,
3552 (sell_how != SELL_NORMAL)
3553 ? ((!ltmp && cltmp && only_partially_your_contents)
3554 ? "%s
\82Ì
\92\86\90g
\82ð
\8bà
\89Ý%ld
\96\87\82Å
\94\84\82Á
\82½%s
\81D%s"
3555 : "%s
\82ð
\8bà
\89Ý%ld
\96\87\82Å
\94\84\82Á
\82½%s
\81D%s")
3556 : "%s
\82ð
\93n
\82µ
\81C
\8bà
\89Ý%ld
\96\87\82Ì
\91ã
\8f\9e\82ð
\8eó
\82¯
\82Æ
\82Á
\82½%s
\81D%s",
3561 impossible("invalid sell response");
3568 int mode; /* 0: deliver count 1: paged */
3571 void sasc_bug(struct obj *, unsigned);
3575 struct bill_x *bp, *end_bp;
3581 shkp = shop_keeper(*u.ushops);
3582 if (!shkp || !inhishop(shkp)) {
3584 impossible("doinvbill: no shopkeeper?");
3590 /* count expended items, so that the `I' command can decide
3591 whether to include 'x' in its prompt string */
3592 int cnt = !eshkp->debit ? 0 : 1;
3594 for (bp = eshkp->bill_p, end_bp = &eshkp->bill_p[eshkp->billct];
3597 || ((obj = bp_to_obj(bp)) != 0 && obj->quan < bp->bquan))
3602 datawin = create_nhwindow(NHW_MENU);
3604 putstr(datawin, 0, "Unpaid articles already used up:");
3606 putstr(datawin, 0, "
\82·
\82Å
\82É
\8eg
\82Á
\82Ä
\82µ
\82Ü
\82Á
\82½
\96¢
\95¥
\82Ì
\95i
\96Ú
\81F");
3607 putstr(datawin, 0, "");
3610 for (bp = eshkp->bill_p, end_bp = &eshkp->bill_p[eshkp->billct];
3611 bp < end_bp; bp++) {
3612 obj = bp_to_obj(bp);
3614 impossible("Bad shopkeeper administration.");
3617 if (bp->useup || bp->bquan > obj->quan) {
3618 long oquan, uquan, thisused;
3621 uquan = (bp->useup ? bp->bquan : bp->bquan - oquan);
3622 thisused = bp->price * uquan;
3623 totused += thisused;
3624 iflags.suppress_price++; /* suppress "(unpaid)" suffix */
3625 /* Why 'x'? To match `I x', more or less. */
3626 buf_p = xprname(obj, (char *) 0, 'x', FALSE, thisused, uquan);
3627 iflags.suppress_price--;
3628 putstr(datawin, 0, buf_p);
3632 /* additional shop debt which has no itemization available */
3634 putstr(datawin, 0, "");
3635 totused += eshkp->debit;
3637 buf_p = xprname((struct obj *) 0, "usage charges and/or other fees",
3638 GOLD_SYM, FALSE, eshkp->debit, 0L);
3640 buf_p = xprname((struct obj *) 0, "
\8eg
\97p
\97¿
\82Ü
\82½
\82Í
\91¼
\82Ì
\8eè
\90\94\97¿",
3641 GOLD_SYM, FALSE, eshkp->debit, 0L);
3643 putstr(datawin, 0, buf_p);
3646 buf_p = xprname((struct obj *) 0, "Total:", '*', FALSE, totused, 0L);
3648 buf_p = xprname((struct obj *) 0, "
\8d\87\8cv
\81F", '*', FALSE, totused, 0L);
3649 putstr(datawin, 0, "");
3650 putstr(datawin, 0, buf_p);
3651 display_nhwindow(datawin, FALSE);
3653 destroy_nhwindow(datawin);
3660 getprice(obj, shk_buying)
3661 register struct obj *obj;
3664 register long tmp = (long) objects[obj->otyp].oc_cost;
3666 if (obj->oartifact) {
3667 tmp = arti_cost(obj);
3671 switch (obj->oclass) {
3673 /* simpler hunger check, (2-4)*cost */
3674 if (u.uhs >= HUNGRY && !shk_buying)
3675 tmp *= (long) u.uhs;
3684 if (obj->otyp == POT_WATER && !obj->blessed && !obj->cursed)
3690 tmp += 10L * (long) obj->spe;
3694 && obj->age < 20L * (long) objects[obj->otyp].oc_cost)
3701 /* shk catches thrown pick-axe */
3704 register struct obj *obj;
3705 register xchar x, y;
3707 register struct monst *shkp;
3709 if (!(shkp = shop_keeper(inside_shop(x, y))) || !inhishop(shkp))
3712 if (shkp->mcanmove && !shkp->msleeping
3713 && (*u.ushops != ESHK(shkp)->shoproom || !inside_shop(u.ux, u.uy))
3714 && dist2(shkp->mx, shkp->my, x, y) < 3
3715 /* if it is the shk's pos, you hit and anger him */
3716 && (shkp->mx != x || shkp->my != y)) {
3717 if (mnearto(shkp, x, y, TRUE) && !muteshk(shkp))
3719 verbalize("Out of my way, scum!");
3721 verbalize("
\82Ç
\82¯
\81C
\83N
\83\
\82Á
\82½
\82ê
\81I");
3724 pline("%s nimbly%s catches %s.", Monnam(shkp),
3725 (x == shkp->mx && y == shkp->my) ? "" : " reaches over and",
3728 pline("%s
\82Í
\82·
\82Î
\82â
\82%s%s
\82ð
\82Â
\82©
\82Ü
\82¦
\82½
\81D", Monnam(shkp),
3729 (x == shkp->mx && y == shkp->my) ? "" : "
\8bß
\82Ã
\82¢
\82Ä",
3732 if (!canspotmon(shkp))
3733 map_invisible(x, y);
3737 subfrombill(obj, shkp);
3738 (void) mpickobj(shkp, obj);
3741 return (struct monst *) 0;
3745 add_damage(x, y, cost)
3746 register xchar x, y;
3749 struct damage *tmp_dam;
3752 if (IS_DOOR(levl[x][y].typ)) {
3755 /* Don't schedule for repair unless it's a real shop entrance */
3756 for (shops = in_rooms(x, y, SHOPBASE); *shops; shops++)
3757 if ((mtmp = shop_keeper(*shops)) != 0 && x == ESHK(mtmp)->shd.x
3758 && y == ESHK(mtmp)->shd.y)
3763 for (tmp_dam = level.damagelist; tmp_dam; tmp_dam = tmp_dam->next)
3764 if (tmp_dam->place.x == x && tmp_dam->place.y == y) {
3765 tmp_dam->cost += cost;
3768 tmp_dam = (struct damage *) alloc((unsigned) sizeof(struct damage));
3769 tmp_dam->when = monstermoves;
3770 tmp_dam->place.x = x;
3771 tmp_dam->place.y = y;
3772 tmp_dam->cost = cost;
3773 tmp_dam->typ = levl[x][y].typ;
3774 tmp_dam->next = level.damagelist;
3775 level.damagelist = tmp_dam;
3776 /* If player saw damage, display as a wall forever */
3778 levl[x][y].seenv = SVALL;
3782 * Do something about damage. Either (!croaked) try to repair it, or
3783 * (croaked) just discard damage structs for non-shared locations, since
3784 * they'll never get repaired. Assume that shared locations will get
3785 * repaired eventually by the other shopkeeper(s). This might be an erroneous
3786 * assumption (they might all be dead too), but we have no reasonable way of
3791 remove_damage(shkp, croaked)
3795 struct damage *tmp_dam, *tmp2_dam;
3796 boolean did_repair = FALSE, saw_door = FALSE, saw_floor = FALSE,
3797 stop_picking = FALSE, doorway_trap = FALSE;
3798 int saw_walls = 0, saw_untrap = 0;
3799 char trapmsg[BUFSZ];
3801 tmp_dam = level.damagelist;
3804 register xchar x = tmp_dam->place.x, y = tmp_dam->place.y;
3807 unsigned old_doormask = 0;
3810 Strcpy(shops, in_rooms(x, y, SHOPBASE));
3811 if (index(shops, ESHK(shkp)->shoproom)) {
3812 if (IS_DOOR(levl[x][y].typ))
3813 old_doormask = levl[x][y].doormask;
3816 disposition = (shops[1]) ? 0 : 1;
3817 else if (stop_picking)
3818 disposition = repair_damage(shkp, tmp_dam, FALSE);
3820 /* Defer the stop_occupation() until after repair msgs */
3821 if (closed_door(x, y))
3822 stop_picking = picking_at(x, y);
3823 disposition = repair_damage(shkp, tmp_dam, FALSE);
3825 stop_picking = FALSE;
3831 tmp_dam = tmp_dam->next;
3835 if (disposition > 1) {
3838 if (IS_WALL(levl[x][y].typ)) {
3840 } else if (IS_DOOR(levl[x][y].typ)
3841 /* an existing door here implies trap removal */
3842 && !(old_doormask & (D_ISOPEN | D_CLOSED))) {
3844 } else if (disposition == 3) { /* untrapped */
3846 if (IS_DOOR(levl[x][y].typ))
3847 doorway_trap = TRUE;
3854 tmp_dam = tmp_dam->next;
3856 free((genericptr_t) level.damagelist);
3857 level.damagelist = tmp_dam;
3859 free((genericptr_t) tmp2_dam->next);
3860 tmp2_dam->next = tmp_dam;
3868 Sprintf(trapmsg, "%s trap%s",
3869 (saw_untrap > 3) ? "several" : (saw_untrap > 1) ? "some"
3872 Sprintf(eos(trapmsg), " %s", vtense(trapmsg, "are"));
3873 Sprintf(eos(trapmsg), " removed from the %s",
3874 (doorway_trap && saw_untrap == 1) ? "doorway" : "floor");
3876 Sprintf(trapmsg, "%sã©
\82ª%s
\82©
\82ç
\8fÁ
\82¦",
3877 (saw_untrap > 3) ? "
\82 \82¿
\82±
\82¿
\82Ì" : (saw_untrap > 1) ? "
\89½
\83J
\8f\8a\82Ì"
3879 (doorway_trap && saw_untrap == 1) ? "
\94à" : "
\8f°");
3882 trapmsg[0] = '\0'; /* not just lint suppression... */
3886 char wallbuf[BUFSZ];
3888 Sprintf(wallbuf, "section%s", plur(saw_walls));
3889 pline("Suddenly, %s %s of wall %s up!",
3890 (saw_walls == 1) ? "a" : (saw_walls <= 3) ? "some" : "several",
3891 wallbuf, vtense(wallbuf, "close"));
3893 pline("
\93Ë
\91R
\81C
\95Ç
\82ª%s
\95Â
\82Ü
\82Á
\82½
\81I",
3894 (saw_walls == 1) ? "" : (saw_walls <= 3) ? "
\89½
\89Ó
\8f\8a\82©" : "
\82 \82¿
\82±
\82¿
\82Å");
3899 pline_The("shop door reappears!");
3901 pline("
\93X
\82Ì
\94à
\82ª
\82Ü
\82½
\8c»
\82í
\82ê
\82½
\81I");
3904 pline_The("floor is repaired!");
3906 pline("
\8f°
\82Í
\8fC
\95\9c\82³
\82ê
\82½
\81I");
3909 pline("%s!", upstart(trapmsg));
3911 pline("%s
\82½
\81I", trapmsg);
3913 if (saw_door || saw_floor || saw_untrap)
3915 pline("Suddenly, %s%s%s%s%s!",
3916 saw_door ? "the shop door reappears" : "",
3917 (saw_door && saw_floor) ? " and " : "",
3918 saw_floor ? "the floor damage is gone" : "",
3919 ((saw_door || saw_floor) && *trapmsg) ? " and " : "",
3922 pline("
\93Ë
\91R
\81C%s%s%s%s%s
\82½!",
3923 saw_door ? "
\93X
\82Ì
\94à
\82ª
\82Ü
\82½
\8c»
\82í
\82ê" : "",
3924 (saw_door && saw_floor) ? "
\81C" : "",
3925 saw_floor ? "
\8f°
\82Ì
\8f\9d\82ª
\8fC
\95\9c\82³
\82ê" : "",
3926 ((saw_door || saw_floor) && *trapmsg) ? "
\81C" : "",
3929 else if (inside_shop(u.ux, u.uy) == ESHK(shkp)->shoproom)
3931 You_feel("more claustrophobic than before.");
3933 You("
\91O
\82æ
\82è
\95Â
\8f\8a\8b°
\95|
\8fÇ
\8bC
\96¡
\82É
\82È
\82Á
\82½
\81D");
3934 else if (!Deaf && !rn2(10))
3936 Norep("The dungeon acoustics noticeably change.");
3938 Norep("
\96À
\8b{
\82Ì
\89¹
\8b¿
\82Í
\82¢
\82¿
\82¶
\82é
\82µ
\82
\95Ï
\82Á
\82½
\81D");
3945 * 0: repair postponed, 1: silent repair (no messages), 2: normal repair
3949 repair_damage(shkp, tmp_dam, catchup)
3950 register struct monst *shkp;
3951 register struct damage *tmp_dam;
3952 boolean catchup; /* restoring a level */
3954 register xchar x, y, i;
3956 register struct monst *mtmp;
3957 register struct obj *otmp;
3958 register struct trap *ttmp;
3960 if ((monstermoves - tmp_dam->when) < REPAIR_DELAY)
3962 if (shkp->msleeping || !shkp->mcanmove || ESHK(shkp)->following)
3964 x = tmp_dam->place.x;
3965 y = tmp_dam->place.y;
3966 if (!IS_ROOM(tmp_dam->typ)) {
3967 if (x == u.ux && y == u.uy)
3970 if (x == shkp->mx && y == shkp->my)
3972 if ((mtmp = m_at(x, y)) && (!passes_walls(mtmp->data)))
3975 if ((ttmp = t_at(x, y)) != 0) {
3976 if (x == u.ux && y == u.uy)
3979 if (ttmp->ttyp == LANDMINE || ttmp->ttyp == BEAR_TRAP) {
3980 /* convert to an object */
3981 otmp = mksobj((ttmp->ttyp == LANDMINE) ? LAND_MINE : BEARTRAP,
3984 otmp->owt = weight(otmp);
3985 (void) mpickobj(shkp, otmp);
3988 if (IS_DOOR(tmp_dam->typ) && !(levl[x][y].doormask & D_ISOPEN)) {
3989 levl[x][y].doormask = D_CLOSED;
3991 } else if (IS_WALL(tmp_dam->typ)) {
3992 levl[x][y].typ = tmp_dam->typ;
3998 if (IS_ROOM(tmp_dam->typ)) {
3999 /* No messages, because player already filled trap door */
4002 if ((tmp_dam->typ == levl[x][y].typ)
4003 && (!IS_DOOR(tmp_dam->typ) || (levl[x][y].doormask > D_BROKEN)))
4004 /* No messages if player already replaced shop door */
4006 levl[x][y].typ = tmp_dam->typ;
4007 (void) memset((genericptr_t) litter, 0, sizeof(litter));
4008 if ((otmp = level.objects[x][y]) != 0) {
4009 /* Scatter objects haphazardly into the shop */
4010 #define NEED_UPDATE 1
4013 #define horiz(i) ((i % 3) - 1)
4014 #define vert(i) ((i / 3) - 1)
4015 for (i = 0; i < 9; i++) {
4016 if ((i == 4) || (!ZAP_POS(levl[x + horiz(i)][y + vert(i)].typ)))
4019 if (inside_shop(x + horiz(i), y + vert(i))
4020 == ESHK(shkp)->shoproom)
4021 litter[i] |= INSHOP;
4023 if (Punished && !u.uswallow
4024 && ((uchain->ox == x && uchain->oy == y)
4025 || (uball->ox == x && uball->oy == y))) {
4027 * Either the ball or chain is in the repair location.
4029 * Take the easy way out and put ball&chain under hero.
4033 verbalize("Get your junk out of my wall!");
4035 verbalize("
\82»
\82Ì
\83K
\83\89\83N
\83^
\82ð
\8aO
\82É
\8e\9d\82Á
\82Ä
\8ds
\82«
\82È
\81I");
4036 unplacebc(); /* pick 'em up */
4037 placebc(); /* put 'em down */
4039 while ((otmp = level.objects[x][y]) != 0)
4040 /* Don't mess w/ boulders -- just merge into wall */
4041 if ((otmp->otyp == BOULDER) || (otmp->otyp == ROCK)) {
4042 obj_extract_self(otmp);
4043 obfree(otmp, (struct obj *) 0);
4045 while (!(litter[i = rn2(9)] & INSHOP))
4047 remove_object(otmp);
4048 place_object(otmp, x + horiz(i), y + vert(i));
4049 litter[i] |= NEED_UPDATE;
4053 return 1; /* repair occurred while off level */
4056 if (IS_DOOR(tmp_dam->typ)) {
4057 levl[x][y].doormask = D_CLOSED; /* arbitrary */
4060 /* don't set doormask - it is (hopefully) the same as it was
4061 if not, perhaps save it with the damage array... */
4063 if (IS_WALL(tmp_dam->typ) && cansee(x, y)) {
4064 /* Player sees actual repair process, so they KNOW it's a wall */
4065 levl[x][y].seenv = SVALL;
4068 /* Mark this wall as "repaired". There currently is no code
4069 to do anything about repaired walls, so don't do it. */
4071 for (i = 0; i < 9; i++)
4072 if (litter[i] & NEED_UPDATE)
4073 newsym(x + horiz(i), y + vert(i));
4083 * shk_move: return 1: moved 0: didn't -1: let m_move do it -2: died
4087 register struct monst *shkp;
4089 register xchar gx, gy, omx, omy;
4091 register schar appr;
4092 register struct eshk *eshkp = ESHK(shkp);
4094 boolean uondoor = FALSE, satdoor, avoid = FALSE, badinv;
4100 remove_damage(shkp, FALSE);
4102 if ((udist = distu(omx, omy)) < 3 && (shkp->data != &mons[PM_GRID_BUG]
4103 || (omx == u.ux || omy == u.uy))) {
4104 if (ANGRY(shkp) || (Conflict && !resist(shkp, RING_CLASS, 0, 0))) {
4107 Your("displaced image doesn't fool %s!", mon_nam(shkp));
4109 pline("%s
\82Í
\82 \82È
\82½
\82Ì
\8c¶
\89e
\82É
\82¾
\82Ü
\82³
\82ê
\82È
\82©
\82Á
\82½
\81I", mon_nam(shkp));
4110 (void) mattacku(shkp);
4113 if (eshkp->following) {
4114 if (strncmp(eshkp->customer, plname, PL_NSIZ)) {
4117 verbalize("%s, %s! I was looking for %s.", Hello(shkp),
4118 plname, eshkp->customer);
4120 verbalize("%s
\81I
\82í
\82½
\82µ
\82Í%s
\82ð
\92T
\82µ
\82Ä
\82¢
\82Ü
\82·
\81D", Hello(shkp),
4123 eshkp->following = 0;
4126 if (moves > followmsg + 4) {
4129 verbalize("%s, %s! Didn't you forget to pay?",
4130 Hello(shkp), plname);
4132 verbalize("%s
\81I
\8ex
\95¥
\82¢
\82ð
\96Y
\82ê
\82Ä
\82¢
\82Ü
\82¹
\82ñ
\82©
\81H",
4138 pline("%s doesn't like customers who don't pay.",
4141 pline ("%s
\82Í
\8bà
\82ð
\95¥
\82í
\82È
\82¢
\8bq
\82ª
\8c\99\82¢
\82Ý
\82½
\82¢
\82¾
\81D",
4155 satdoor = (gx == omx && gy == omy);
4156 if (eshkp->following || ((z = holetime()) >= 0 && z * z <= udist)) {
4157 /* [This distance check used to apply regardless of
4158 whether the shk was following, but that resulted in
4159 m_move() sometimes taking the shk out of the shop if
4160 the player had fenced him in with boulders or traps.
4161 Such voluntary abandonment left unpaid objects in
4162 invent, triggering billing impossibilities on the
4163 next level once the character fell through the hole.] */
4164 if (udist > 4 && eshkp->following && !eshkp->billct)
4165 return -1; /* leave it to m_move */
4168 } else if (ANGRY(shkp)) {
4169 /* Move towards the hero if the shopkeeper can see him. */
4170 if (shkp->mcansee && m_canseeu(shkp)) {
4176 #define GDIST(x, y) (dist2(x, y, gx, gy))
4177 if (Invis || u.usteed) {
4180 uondoor = (u.ux == eshkp->shd.x && u.uy == eshkp->shd.y);
4183 (carrying(PICK_AXE) || carrying(DWARVISH_MATTOCK)
4184 || (Fast && (sobj_at(PICK_AXE, u.ux, u.uy)
4185 || sobj_at(DWARVISH_MATTOCK, u.ux, u.uy))));
4186 if (satdoor && badinv)
4190 avoid = (*u.ushops && distu(gx, gy) > 8);
4194 if (((!eshkp->robbed && !eshkp->billct && !eshkp->debit) || avoid)
4195 && GDIST(omx, omy) < 3) {
4196 if (!badinv && !onlineu(omx, omy))
4204 z = move_special(shkp, inhishop(shkp), appr, uondoor, avoid, omx, omy, gx,
4207 after_shk_move(shkp);
4212 /* called after shopkeeper moves, in case themove causes re-entry into shop */
4214 after_shk_move(shkp)
4217 struct eshk *eshkp = ESHK(shkp);
4219 if (eshkp->bill_p == (struct bill_x *) -1000 && inhishop(shkp)) {
4220 /* reset bill_p, need to re-calc player's occupancy too */
4221 eshkp->bill_p = &eshkp->bill[0];
4222 check_special_room(FALSE);
4226 /* for use in levl_follower (mondata.c) */
4229 register struct monst *mtmp;
4231 return (boolean) (mtmp->isshk && ESHK(mtmp)->following);
4234 /* You are digging in the shop. */
4239 register struct monst *shkp = shop_keeper(*u.ushops);
4242 const char *grabs = "grabs";
4244 const char *grabs = "
\82Â
\82©
\82ñ
\82¾";
4249 /* 0 == can't speak, 1 == makes animal noises, 2 == speaks */
4251 if (shkp->msleeping || !shkp->mcanmove || is_silent(shkp->data))
4252 ; /* lang stays 0 */
4253 else if (shkp->data->msound <= MS_ANIMAL)
4255 else if (shkp->data->msound >= MS_HUMANOID)
4258 if (!inhishop(shkp)) {
4259 if (Role_if(PM_KNIGHT)) {
4261 You_feel("like a common thief.");
4263 You("
\93D
\96_
\93¯
\91R
\82È
\8bC
\82ª
\82µ
\82½
\81D");
4264 adjalign(-sgn(u.ualign.type));
4271 if (u.utraptype == TT_PIT)
4274 "Be careful, %s, or you might fall through the floor.",
4275 flags.female ? "madam" : "sir");
4277 verbalize("
\92\8d\88Ó
\82µ
\82Ä
\82
\82¾
\82³
\82¢%s
\81C
\8f°
\82©
\82ç
\97\8e\82¿
\82Ü
\82·
\82æ
\81D",
4278 flags.female ? "
\82¨
\8fì
\82³
\82ñ" : "
\82¨
\8bq
\82³
\82ñ");
4282 verbalize("%s, do not damage the floor here!",
4283 flags.female ? "Madam" : "Sir");
4285 verbalize("%s
\81C
\8f°
\82É
\8f\9d\82ð
\82Â
\82¯
\82È
\82¢
\82Å
\82
\82¾
\82³
\82¢
\81I",
4286 flags.female ? "
\82¨
\8fì
\82³
\82ñ" : "
\82¨
\8bq
\82³
\82ñ");
4289 if (Role_if(PM_KNIGHT)) {
4291 You_feel("like a common thief.");
4293 You("
\93D
\96_
\93¯
\91R
\82È
\8bC
\82ª
\82µ
\82½
\81D");
4294 adjalign(-sgn(u.ualign.type));
4296 } else if (!um_dist(shkp->mx, shkp->my, 5)
4297 && !shkp->msleeping && shkp->mcanmove
4298 && (ESHK(shkp)->billct || ESHK(shkp)->debit)) {
4299 register struct obj *obj, *obj2;
4301 if (nolimbs(shkp->data)) {
4303 grabs = "knocks off";
4305 grabs = "
\92@
\82«
\97\8e\82µ
\82½";
4307 /* This is what should happen, but for balance
4308 * reasons, it isn't currently.
4311 pline("%s curses %s inability to grab your backpack!",
4312 shkname(shkp), mhim(shkp));
4317 if (distu(shkp->mx, shkp->my) > 2) {
4319 /* for some reason the shopkeeper can't come next to you */
4320 if (distu(shkp->mx, shkp->my) > 2) {
4324 pline("%s curses you in anger and frustration!",
4326 pline("
\93{
\82è
\82Å
\95s
\96\9e\82Ì
\82½
\82Ü
\82Á
\82Ä
\82¢
\82é%s
\82Í
\82 \82È
\82½
\82ð
\8eô
\82Á
\82½
\81I",
4334 pline("%s %s, and %s your backpack!", shkname(shkp),
4335 makeplural(locomotion(shkp->data, "leap")), grabs);
4337 pline("%s
\82Í
\94ò
\82Ñ
\82Â
\82¢
\82Ä
\81C
\82 \82È
\82½
\82Ì
\94w
\95\89\82¢
\91Ü
\82ð%s
\81I", shkname(shkp),
4342 pline("%s %s your backpack!", shkname(shkp), grabs);
4344 pline("%s
\82Í
\82 \82È
\82½
\82Ì
\94w
\95\89\82¢
\91Ü
\82ð%s
\81I", shkname(shkp), grabs);
4346 for (obj = invent; obj; obj = obj2) {
4348 if ((obj->owornmask & ~(W_SWAPWEP | W_QUIVER)) != 0
4349 || (obj == uswapwep && u.twoweap)
4350 || (obj->otyp == LEASH && obj->leashmon))
4352 if (obj == current_wand)
4356 subfrombill(obj, shkp);
4357 (void) add_to_minv(shkp, obj); /* may free obj */
4366 static const short k_mndx[4] = { PM_KEYSTONE_KOP, PM_KOP_SERGEANT,
4367 PM_KOP_LIEUTENANT, PM_KOP_KAPTAIN };
4368 int k_cnt[4], cnt, mndx, k;
4370 k_cnt[0] = cnt = abs(depth(&u.uz)) + rnd(5);
4371 k_cnt[1] = (cnt / 3) + 1; /* at least one sarge */
4372 k_cnt[2] = (cnt / 6); /* maybe a lieutenant */
4373 k_cnt[3] = (cnt / 9); /* and maybe a kaptain */
4375 for (k = 0; k < 4; k++) {
4376 if ((cnt = k_cnt[k]) == 0)
4379 if (mvitals[mndx].mvflags & G_GONE)
4383 if (enexto(mm, mm->x, mm->y, &mons[mndx]))
4384 (void) makemon(&mons[mndx], mm->x, mm->y, NO_MM_FLAGS);
4389 pay_for_damage(dmgstr, cant_mollify)
4391 boolean cant_mollify;
4393 register struct monst *shkp = (struct monst *) 0;
4394 char shops_affected[5];
4395 register boolean uinshp = (*u.ushops != '\0');
4397 register xchar x, y;
4399 boolean dugwall = (!strcmp(dmgstr, "dig into") /* wand */
4400 || !strcmp(dmgstr, "damage")); /* pick-axe */
4402 boolean ni_wo = !strcmp(dmgstr, "
\8c\8a\82ð
\82 \82¯
\82é"); /* wand */
4403 boolean dugwall = (ni_wo || !strcmp(dmgstr, "
\8f\9d\82Â
\82¯
\82é")); /* pick-axe */
4405 boolean animal, pursue;
4406 struct damage *tmp_dam, *appear_here = 0;
4407 /* any number >= (80*80)+(24*24) would do, actually */
4408 long cost_of_damage = 0L;
4409 unsigned int nearest_shk = 7000, nearest_damage = 7000;
4412 for (tmp_dam = level.damagelist;
4413 (tmp_dam && (tmp_dam->when == monstermoves));
4414 tmp_dam = tmp_dam->next) {
4419 cost_of_damage += tmp_dam->cost;
4420 Strcpy(shops_affected,
4421 in_rooms(tmp_dam->place.x, tmp_dam->place.y, SHOPBASE));
4422 for (shp = shops_affected; *shp; shp++) {
4423 struct monst *tmp_shk;
4424 unsigned int shk_distance;
4426 if (!(tmp_shk = shop_keeper(*shp)))
4428 if (tmp_shk == shkp) {
4429 unsigned int damage_distance =
4430 distu(tmp_dam->place.x, tmp_dam->place.y);
4432 if (damage_distance < nearest_damage) {
4433 nearest_damage = damage_distance;
4434 appear_here = tmp_dam;
4438 if (!inhishop(tmp_shk))
4440 shk_distance = distu(tmp_shk->mx, tmp_shk->my);
4441 if (shk_distance > nearest_shk)
4443 if ((shk_distance == nearest_shk) && picks) {
4449 nearest_shk = shk_distance;
4450 appear_here = tmp_dam;
4451 nearest_damage = distu(tmp_dam->place.x, tmp_dam->place.y);
4455 if (!cost_of_damage || !shkp)
4458 animal = (shkp->data->msound <= MS_ANIMAL);
4460 x = appear_here->place.x;
4461 y = appear_here->place.y;
4463 /* not the best introduction to the shk... */
4464 (void) strncpy(ESHK(shkp)->customer, plname, PL_NSIZ);
4466 /* if the shk is already on the war path, be sure it's all out */
4467 if (ANGRY(shkp) || ESHK(shkp)->following) {
4472 /* if the shk is not in their shop.. */
4473 if (!*in_rooms(shkp->mx, shkp->my, SHOPBASE)) {
4474 if (!cansee(shkp->mx, shkp->my))
4481 if (um_dist(shkp->mx, shkp->my, 1)
4482 && !um_dist(shkp->mx, shkp->my, 3)) {
4484 pline("%s leaps towards you!", shkname(shkp));
4486 pline("%s
\82Í
\82 \82È
\82½
\82É
\94ò
\82Ñ
\82©
\82©
\82Á
\82½
\81I", shkname(shkp));
4489 pursue = um_dist(shkp->mx, shkp->my, 1);
4494 * Make shkp show up at the door. Effect: If there is a monster
4495 * in the doorway, have the hero hear the shopkeeper yell a bit,
4496 * pause, then have the shopkeeper appear at the door, having
4497 * yanked the hapless critter out of the way.
4500 if (!Deaf && !animal) {
4502 You_hear("an angry voice:");
4504 You("
\93{
\82è
\82Ì
\90º
\82ð
\95·
\82¢
\82½
\81F");
4506 verbalize("Out of my way, scum!");
4508 verbalize("
\82Ç
\82¯
\81I
\83N
\83\
\82Á
\82½
\82ê
\81I");
4510 #if defined(UNIX) || defined(VMS)
4511 #if defined(SYSV) || defined(ULTRIX) || defined(VMS)
4520 (void) mnearto(shkp, x, y, TRUE);
4523 if ((um_dist(x, y, 1) && !uinshp) || cant_mollify
4524 || (money_cnt(invent) + ESHK(shkp)->credit) < cost_of_damage
4527 if (muteshk(shkp)) {
4528 if (animal && shkp->mcanmove && !shkp->msleeping)
4530 } else if (pursue || uinshp || !um_dist(x, y, 1)) {
4532 verbalize("How dare you %s my %s?", dmgstr,
4533 dugwall ? "shop" : "door");
4535 verbalize("
\82Ç
\82¤
\82µ
\82Ä%s%s%s
\82è
\82µ
\82½
\82ñ
\82¾
\81H",
4536 dugwall ? "
\93X" : "
\94à",
4537 ni_wo ? "
\82É" : "
\82ð",
4542 pline("%s shouts:", shkname(shkp));
4544 pline("%s
\82Í
\82³
\82¯
\82ñ
\82¾
\81F", shkname(shkp));
4546 verbalize("Who dared %s my %s?", dmgstr,
4547 dugwall ? "shop" : "door");
4549 verbalize("
\92N
\82ª%s%s%s
\82è
\82µ
\82½
\82ñ
\82¾
\82ë
\82¤
\81H",
4550 dugwall ? "
\93X" : "
\94à",
4551 ni_wo ? "
\82É" : "
\82ð",
4561 Your("invisibility does not fool %s!", shkname(shkp));
4563 pline("%s
\82Í
\93§
\96¾
\82È
\82 \82È
\82½
\82É
\82¾
\82Ü
\82³
\82ê
\82È
\82©
\82Á
\82½
\81I", shkname(shkp));
4565 Sprintf(qbuf, "%sYou did %ld %s worth of damage!%s Pay?",
4566 !animal ? cad(TRUE) : "", cost_of_damage,
4567 currency(cost_of_damage), !animal ? "\"" : "");
4569 Sprintf(qbuf,"
\81u
\82¨
\82¢
\81I%ld%s
\82Ì
\91¹
\8aQ
\82¾
\81I
\81v
\95¥
\82¢
\82Ü
\82·
\82©
\81H",
4570 cost_of_damage, currency(cost_of_damage));
4572 if (yn(qbuf) != 'n') {
4573 cost_of_damage = check_credit(cost_of_damage, shkp);
4574 money2mon(shkp, cost_of_damage);
4577 pline("Mollified, %s accepts your restitution.", shkname(shkp));
4579 pline("%s
\82Í
\81C
\8a´
\8fî
\82ð
\82â
\82í
\82ç
\82°
\94\85\8f\9e\8bà
\82ð
\8eó
\82¯
\82Æ
\82Á
\82½
\81D", shkname(shkp));
4580 /* move shk back to his home loc */
4581 home_shk(shkp, FALSE);
4586 verbalize("Oh, yes! You'll pay!");
4588 verbalize("
\82³
\82 \81C
\95¥
\82¤
\82ñ
\82¾
\81I");
4592 adjalign(-sgn(u.ualign.type));
4596 /* called in dokick.c when we kick an object that might be in a store */
4599 register xchar x, y;
4604 if (!level.flags.has_shop)
4606 shkp = shop_keeper(*in_rooms(x, y, SHOPBASE));
4607 if (!shkp || !inhishop(shkp))
4610 return (boolean) (inside_shop(x, y)
4611 && !(x == eshkp->shk.x && y == eshkp->shk.y));
4614 /* called by dotalk(sounds.c) when #chatting; returns obj if location
4615 contains shop goods and shopkeeper is willing & able to speak */
4618 register xchar x, y;
4620 register struct obj *otmp;
4621 register struct monst *shkp;
4623 if (!(shkp = shop_keeper(*in_rooms(x, y, SHOPBASE))) || !inhishop(shkp))
4624 return (struct obj *) 0;
4626 for (otmp = level.objects[x][y]; otmp; otmp = otmp->nexthere)
4627 if (otmp->oclass != COIN_CLASS)
4629 /* note: otmp might have ->no_charge set, but that's ok */
4630 return (otmp && costly_spot(x, y)
4631 && NOTANGRY(shkp) && shkp->mcanmove && !shkp->msleeping)
4636 /* give price quotes for all objects linked to this one (ie, on this spot) */
4638 price_quote(first_obj)
4639 register struct obj *first_obj;
4641 register struct obj *otmp;
4642 char buf[BUFSZ], price[40];
4645 boolean contentsonly = FALSE;
4647 struct monst *shkp = shop_keeper(inside_shop(u.ux, u.uy));
4649 tmpwin = create_nhwindow(NHW_MENU);
4651 putstr(tmpwin, 0, "Fine goods for sale:");
4653 putstr(tmpwin, 0, "
\94\84\82è
\82É
\82Å
\82Ä
\82¢
\82é
\82·
\82Î
\82ç
\82µ
\82¢
\8f¤
\95i
\81F");
4654 putstr(tmpwin, 0, "");
4655 for (otmp = first_obj; otmp; otmp = otmp->nexthere) {
4656 if (otmp->oclass == COIN_CLASS)
4658 cost = (otmp->no_charge || otmp == uball || otmp == uchain)
4660 : get_cost(otmp, (struct monst *) 0);
4661 contentsonly = !cost;
4662 if (Has_contents(otmp))
4663 cost += contained_cost(otmp, shkp, 0L, FALSE, FALSE);
4666 Strcpy(price, "no charge");
4668 Strcpy(price, "
\96³
\97¿");
4669 contentsonly = FALSE;
4672 Sprintf(price, "%ld %s%s", cost, currency(cost),
4673 (otmp->quan) > 1L ? " each" : "");
4675 Sprintf(price, "%s%ld%s",
4676 otmp->quan > 1L ? "
\82»
\82ê
\82¼
\82ê" : "", cost, currency(cost));
4680 Sprintf(buf, "%s%s, %s", contentsonly ? the_contents_of : "",
4681 doname(otmp), price);
4683 Sprintf(buf, "%s%s
\81C%s", doname(otmp),
4684 contentsonly ? "
\82Ì
\92\86\90g" : "", price);
4686 putstr(tmpwin, 0, buf), cnt++;
4689 display_nhwindow(tmpwin, TRUE);
4690 } else if (cnt == 1) {
4692 /* "<doname(obj)>, no charge" */
4694 pline("%s!", upstart(buf)); /* buf still contains the string */
4696 pline("%s
\81I", buf); /* buf still contains the string */
4699 /* print cost in slightly different format, so can't reuse buf;
4700 cost and contentsonly are already set up */
4702 Sprintf(buf, "%s%s", contentsonly ? the_contents_of : "",
4705 Sprintf(buf, "%s%s", doname(first_obj),
4706 contentsonly ? "
\82Ì
\92\86\90g" : "");
4709 pline("%s, price %ld %s%s%s", upstart(buf), cost, currency(cost),
4710 (first_obj->quan > 1L) ? " each" : "",
4711 contentsonly ? "." : shk_embellish(first_obj, cost));
4713 pline("%s%s
\82Í%s%ld%s
\82¾
\81D",
4714 shk_embellish(first_obj, cost), buf,
4715 first_obj->quan > 1L ? "
\82»
\82ê
\82¼
\82ê" : "",
4716 cost, currency(cost));
4720 destroy_nhwindow(tmpwin);
4724 \93X
\8eå
\82Ì
\94\84\82è
\95¶
\8bå
\81B
\89p
\8cê
\82Å
\82Í
\96\96\94ö
\82É
\95t
\82
\82ª
\93ú
\96{
\8cê
\82Å
\82Í
\90æ
\93ª
\82É
\95t
\82
\81B
4725 \92¼
\8cã
\82É
\83A
\83C
\83e
\83\80\96¼
\82ª
\97\88\82é
\82Ì
\82Å
\81A
\83A
\83C
\83e
\83\80\82É
\91Î
\82·
\82é
\8c`
\97e
\82Å
\82à
\93Æ
\97§
\82µ
\82½
\95¶
\82Å
\82à
\97Ç
\82¢
\81B
4727 STATIC_OVL const char *
4728 shk_embellish(itm, cost)
4729 register struct obj *itm;
4733 register int o, choice = rn2(5);
4735 choice = (cost < 100L ? 1 : cost < 500L ? 2 : 3);
4742 if (o == FOOD_CLASS)
4744 return ", gourmets' delight!";
4746 return "
\83O
\83\8b\83\81\82ª
\8b\83\82¢
\82Ä
\8aì
\82Ô";
4747 if (objects[itm->otyp].oc_name_known
4748 ? objects[itm->otyp].oc_magic
4749 : (o == AMULET_CLASS || o == RING_CLASS || o == WAND_CLASS
4750 || o == POTION_CLASS || o == SCROLL_CLASS
4751 || o == SPBOOK_CLASS))
4753 return ", painstakingly developed!";
4755 return "
\88ê
\8b\89\82Ì
\96\82\97Í
\82ð
\94é
\82ß
\82½";
4757 return ", superb craftsmanship!";
4759 return "
\88ê
\97¬
\90E
\90l
\82Ì
\8dì
\82Á
\82½";
4762 return ", finest quality.";
4764 return "
\8dÅ
\8d\82\82Ì
\95i
\8e¿
\82ð
\8cÖ
\82é";
4767 return ", an excellent choice.";
4769 return "
\82³
\82·
\82ª
\82¨
\8bq
\82³
\82ñ
\96Ú
\82ª
\8d\82\82¢
\81I";
4772 return ", a real bargain.";
4774 return "
\96{
\93ú
\82Ì
\96Ú
\8bÊ
\8f¤
\95i
\81I";
4778 } else if (itm->oartifact) {
4780 return ", one of a kind!";
4782 return "
\82±
\82ê
\82Í
\90¢
\8aE
\82É
\82Ü
\82½
\82Æ
\82È
\82¢
\81I";
4790 /* First 4 supplied by Ronen and Tamar, remainder by development team */
4791 const char *Izchak_speaks[] = {
4793 "%s says: 'These shopping malls give me a headache.'",
4795 "%s
\9eH
\82
\81w
\82±
\82ê
\82ç
\83V
\83\87\83b
\83s
\83\93\83O
\8aX
\82Í
\93ª
\92É
\82Ì
\83^
\83l
\82¾
\81D
\81x",
4797 "%s says: 'Slow down. Think clearly.'",
4799 "%s
\9eH
\82
\81w
\97\8e\82¿
\92\85\82¢
\82Ä
\81C
\96¾
\9dð
\82É
\8dl
\82¦
\82æ
\81D
\81x",
4801 "%s says: 'You need to take things one at a time.'",
4803 "%s
\9eH
\82
\81w
\88ê
\93x
\82É
\88ê
\8cÂ
\82¸
\82Â
\8eæ
\82é
\95K
\97v
\82ª
\82 \82é
\81D
\81x",
4805 "%s says: 'I don't like poofy coffee... give me Columbian Supremo.'",
4807 "%s
\9eH
\82
\81w
\83z
\83\82\82Á
\82Û
\82¢
\83R
\81[
\83q
\82Í
\8dD
\82«
\82¶
\82á
\82È
\82¢
\81D
\81D
\81D
\83R
\83\8d\83\93\83r
\83A
\83\93\81E
\83X
\83v
\83\8c\83\82\82ð
\82½
\82Ì
\82Þ
\81D
\81x",
4809 "%s says that getting the devteam's agreement on anything is difficult.",
4811 "
\8aJ
\94
\83`
\81[
\83\80\82É
\89½
\82ç
\82©
\82Ì
\8b¦
\92è
\82ð
\8b\81\82ß
\82é
\82±
\82Æ
\82Í
\8d¢
\93ï
\82¾
\82Æ%s
\82Í
\8fq
\82×
\82½
\81D",
4813 "%s says that he has noticed those who serve their deity will prosper.",
4815 "%s
\82Í
\90_
\82É
\8ed
\82¦
\82Ä
\82¢
\82é
\82â
\82Â
\82Í
\90¬
\8c÷
\82µ
\82Ä
\82¢
\82é
\82Æ
\8fq
\82×
\82½
\81D",
4817 "%s says: 'Don't try to steal from me - I have friends in high places!'",
4819 "%s
\9eH
\82
\81w
\8e\84\82©
\82ç
\93\90\82à
\82¤
\82È
\82ñ
\82Ä
\8ev
\82í
\82È
\82¢
\82±
\82Æ
\82¾
\81D
\8fã
\82Ì
\95û
\82É
\92m
\82è
\8d\87\82¢
\82ª
\82¢
\82é
\82ñ
\82¾
\82©
\82ç
\81D
\81x",
4821 "%s says: 'You may well need something from this shop in the future.'",
4823 "%s
\9eH
\82
\81w
\8f«
\97\88\82±
\82Ì
\93X
\82Ì
\89½
\82©
\82ª
\95K
\97v
\82Æ
\82È
\82é
\82¾
\82ë
\82¤
\81x",
4825 "%s comments about the Valley of the Dead as being a gateway."
4827 "%s
\82Í
\8e\80\82Ì
\92J
\82Í
\83Q
\81[
\83g
\83E
\83F
\83C
\82¾
\82ë
\82¤
\82Æ
\83R
\83\81\83\93\83g
\82ð
\8fq
\82×
\82½
\81D"
4837 /* The monster type is shopkeeper, but this monster is
4838 not actually a shk, which could happen if someone
4839 wishes for a shopkeeper statue and then animates it.
4840 (Note: shkname() would be "" in a case like this.) */
4842 pline("%s asks whether you've seen any untended shops recently.",
4844 pline("%s
\82Í
\8dÅ
\8bß
\82Ç
\82±
\82©
\82É
\93X
\88õ
\82Ì
\82¢
\82È
\82¢
\93X
\82Í
\82È
\82¢
\82©
\82Æ
\82½
\82¸
\82Ë
\82½
\81D",
4847 /* [Perhaps we ought to check whether this conversation
4848 is taking place inside an untended shop, but a shopless
4849 shk can probably be expected to be rather disoriented.] */
4856 pline("%s mentions how much %s dislikes %s customers.",
4857 shkname(shkp), mhe(shkp), eshk->robbed ? "non-paying" : "rude");
4859 pline("%s
\82Í%s
\8bq
\82Í
\91å
\8c\99\82¢
\82¾
\82Æ
\8c¾
\82Á
\82½
\81D",
4860 shkname(shkp), eshk->robbed ? "
\8bà
\82ð
\8ex
\95¥
\82í
\82È
\82¢" : "
\96³
\97ç
\82È");
4862 } else if (eshk->following) {
4863 if (strncmp(eshk->customer, plname, PL_NSIZ)) {
4865 verbalize("%s %s! I was looking for %s.",
4866 Hello(shkp), plname, eshk->customer);
4868 verbalize("%s
\81I
\8e\84\82Í%s
\82ð
\92T
\82µ
\82Ä
\82¢
\82Ü
\82·
\81D",
4869 Hello(shkp), eshk->customer);
4871 eshk->following = 0;
4874 verbalize("%s %s! Didn't you forget to pay?",
4875 Hello(shkp), plname);
4877 verbalize("%s
\81I
\8ex
\95¥
\82¢
\82ð
\96Y
\82ê
\82Ä
\82¢
\82Ü
\82¹
\82ñ
\82©
\81H",
4881 } else if (eshk->billct) {
4882 register long total = addupbill(shkp) + eshk->debit;
4885 pline("%s says that your bill comes to %ld %s.",
4886 shkname(shkp), total, currency(total));
4888 pline("%s
\82Í
\8a¨
\92è
\82ª%ld%s
\82É
\82È
\82é
\82Æ
\8c¾
\82Á
\82½
\81D",
4889 shkname(shkp), total, currency(total));
4891 } else if (eshk->debit) {
4893 pline("%s reminds you that you owe %s %ld %s.",
4894 shkname(shkp), mhim(shkp), eshk->debit, currency(eshk->debit));
4896 pline("
\82 \82È
\82½
\82Í%s
\82É%ld%s
\82Ì
\8eØ
\82è
\82ª
\82 \82é
\82±
\82Æ
\82ð
\8ev
\82¢
\82¾
\82µ
\82½
\81D",
4897 shkname(shkp), eshk->debit, currency(eshk->debit));
4899 } else if (eshk->credit) {
4901 pline("%s encourages you to use your %ld %s of credit.",
4902 shkname(shkp), eshk->credit, currency(eshk->credit));
4904 pline("%s
\82Í%ld%s
\82Ì
\97a
\82¯
\8bà
\82ð
\8eg
\82¤
\82æ
\82¤
\8a©
\82ß
\82½
\81D",
4905 shkname(shkp), eshk->credit, currency(eshk->credit));
4907 } else if (eshk->robbed) {
4909 pline("%s complains about a recent robbery.", shkname(shkp));
4911 pline("%s
\82Í
\8dÅ
\8bß
\82Ì
\8b
\93\90\82É
\82Â
\82¢
\82Ä
\8bð
\92s
\82ð
\82±
\82Ú
\82µ
\82½
\81D", shkname(shkp));
4912 } else if ((shkmoney = money_cnt(shkp->minvent)) < 50) {
4914 pline("%s complains that business is bad.", shkname(shkp));
4916 pline("%s
\82Í
\8f¤
\94\84\82ª
\8e|
\82
\82¢
\82Á
\82Ä
\82È
\82¢
\82Æ
\8bð
\92s
\82ð
\82±
\82Ú
\82µ
\82½
\81D", shkname(shkp));
4917 } else if (shkmoney > 4000) {
4919 pline("%s says that business is good.", shkname(shkp));
4921 pline("%s
\82Í
\8f¤
\94\84\82ª
\8e|
\82
\82¢
\82Á
\82Ä
\82¢
\82é
\82Æ
\8c¾
\82Á
\82½
\81D", shkname(shkp));
4922 } else if (is_izchak(shkp, FALSE)) {
4923 pline(Izchak_speaks[rn2(SIZE(Izchak_speaks))], shkname(shkp));
4926 pline("%s talks about the problem of shoplifters.", shkname(shkp));
4928 pline("%s
\82Í
\96\9c\88ø
\82Ì
\96â
\91è
\82É
\82Â
\82¢
\82Ä
\98b
\82µ
\82½
\81D", shkname(shkp));
4936 register int cnt = 0;
4937 register struct monst *mtmp, *mtmp2;
4939 for (mtmp = fmon; mtmp; mtmp = mtmp2) {
4941 if (mtmp->data->mlet == S_KOP) {
4942 if (canspotmon(mtmp))
4949 pline_The("Kop%s (disappointed) vanish%s into thin air.",
4950 plur(cnt), (cnt == 1) ? "es" : "");
4952 pline("
\8cx
\8a¯
\82Í(
\82ª
\82Á
\82©
\82è
\82µ
\82Ä)
\8ep
\82ð
\8fÁ
\82µ
\82½
\81D");
4957 cost_per_charge(shkp, otmp, altusage)
4960 boolean altusage; /* some items have an "alternate" use with different cost */
4964 if (!shkp || !inhishop(shkp))
4965 return 0L; /* insurance */
4966 tmp = get_cost(otmp, shkp);
4968 /* The idea is to make the exhaustive use of an unpaid item
4969 * more expensive than buying it outright.
4971 if (otmp->otyp == MAGIC_LAMP) { /* 1 */
4972 /* normal use (ie, as light source) of a magic lamp never
4973 degrades its value, but not charging anything would make
4974 identification too easy; charge an amount comparable to
4975 what is charged for an ordinary lamp (don't bother with
4976 angry shk surcharge) */
4978 tmp = (long) objects[OIL_LAMP].oc_cost;
4980 tmp += tmp / 3L; /* djinni is being released */
4981 } else if (otmp->otyp == MAGIC_MARKER) { /* 70 - 100 */
4982 /* No way to determine in advance how many charges will be
4983 * wasted. So, arbitrarily, one half of the price per use.
4986 } else if (otmp->otyp == BAG_OF_TRICKS /* 1 - 20 */
4987 || otmp->otyp == HORN_OF_PLENTY) {
4988 /* altusage: emptying of all the contents at once */
4991 } else if (otmp->otyp == CRYSTAL_BALL /* 1 - 5 */
4992 || otmp->otyp == OIL_LAMP /* 1 - 10 */
4993 || otmp->otyp == BRASS_LANTERN
4994 || (otmp->otyp >= MAGIC_FLUTE
4995 && otmp->otyp <= DRUM_OF_EARTHQUAKE) /* 5 - 9 */
4996 || otmp->oclass == WAND_CLASS) { /* 3 - 11 */
4999 } else if (otmp->oclass == SPBOOK_CLASS) {
5001 } else if (otmp->otyp == CAN_OF_GREASE || otmp->otyp == TINNING_KIT
5002 || otmp->otyp == EXPENSIVE_CAMERA) {
5004 } else if (otmp->otyp == POT_OIL) {
5010 /* Charge the player for partial use of an unpaid object.
5012 * Note that bill_dummy_object() should be used instead
5013 * when an object is completely used.
5016 check_unpaid_usage(otmp, altusage)
5021 const char *fmt, *arg1, *arg2;
5025 if (!otmp->unpaid || !*u.ushops
5026 || (otmp->spe <= 0 && objects[otmp->otyp].oc_charged))
5028 if (!(shkp = shop_keeper(*u.ushops)) || !inhishop(shkp))
5030 if ((tmp = cost_per_charge(shkp, otmp, altusage)) == 0L)
5034 if (otmp->oclass == SPBOOK_CLASS) {
5036 fmt = "%sYou owe%s %ld %s.";
5038 fmt = "%s%s%ld%s
\82Ì
\8eØ
\82è
\82¾
\81D";
5040 Sprintf(buf, "This is no free library, %s! ", cad(FALSE));
5042 Strcpy(buf, "
\82¨
\82¢
\81I
\82±
\82±
\82Í
\90}
\8f\91\8aÙ
\82¶
\82á
\82È
\82¢
\81I");
5043 arg1 = rn2(2) ? buf : "";
5045 arg2 = ESHK(shkp)->debit > 0L ? " an additional" : "";
5047 arg2 = ESHK(shkp)->debit > 0L ? "
\82³
\82ç
\82É
\8c¾
\82¦
\82Î" : "";
5048 } else if (otmp->otyp == POT_OIL) {
5050 fmt = "%s%sThat will cost you %ld %s (Yendorian Fuel Tax).";
5052 fmt = "%s%s
\92l
\92i
\82Í%ld%s(
\83C
\83F
\83\93\83_
\81[
\94R
\97¿
\90Å)
\82¾
\81D";
5053 } else if (altusage && (otmp->otyp == BAG_OF_TRICKS
5054 || otmp->otyp == HORN_OF_PLENTY)) {
5056 fmt = "%s%sEmptying that will cost you %ld %s.";
5058 fmt = "%s%s
\82»
\82ê
\82Ì
\8eg
\97p
\97¿
\82Í%ld%s
\82¾
\81D";
5063 arg1 = "
\82¤
\82í
\81I";
5066 arg1 = "Watch it! ";
5068 arg1 = "
\8bC
\82ð
\82Â
\82¯
\82ë
\81I";
5071 fmt = "%s%sUsage fee, %ld %s.";
5073 fmt = "%s%s
\8eg
\97p
\97¿
\82Í
\81C%ld%s
\82¾
\81D";
5078 arg1 = "
\82¨
\82¢
\81I";
5083 arg2 = "
\83S
\83z
\83\93\81D";
5086 if (!muteshk(shkp)) {
5087 verbalize(fmt, arg1, arg2, tmp, currency(tmp));
5088 exercise(A_WIS, TRUE); /* you just got info */
5090 ESHK(shkp)->debit += tmp;
5093 /* for using charges of unpaid objects "used in the normal manner" */
5098 check_unpaid_usage(otmp, FALSE); /* normal item use */
5102 costly_gold(x, y, amount)
5103 register xchar x, y;
5104 register long amount;
5106 register long delta;
5107 register struct monst *shkp;
5108 register struct eshk *eshkp;
5110 if (!costly_spot(x, y))
5112 /* shkp now guaranteed to exist by costly_spot() */
5113 shkp = shop_keeper(*in_rooms(x, y, SHOPBASE));
5116 if (eshkp->credit >= amount) {
5117 if (eshkp->credit > amount)
5119 Your("credit is reduced by %ld %s.", amount, currency(amount));
5121 Your("
\97a
\82¯
\8bà
\82Í%ld%s
\8c¸
\82Á
\82½
\81D", amount, currency(amount));
5124 Your("credit is erased.");
5126 Your("
\97a
\82¯
\8bà
\82Í
\92 \8fÁ
\82µ
\82É
\82È
\82Á
\82½
\81D");
5127 eshkp->credit -= amount;
5129 delta = amount - eshkp->credit;
5132 Your("credit is erased.");
5134 Your("
\97a
\82¯
\8bà
\82Í
\92 \8fÁ
\82µ
\82É
\82È
\82Á
\82½
\81D");
5137 Your("debt increases by %ld %s.", delta, currency(delta));
5139 Your("
\8eØ
\8bà
\82Í%ld%s
\91\9d\82¦
\82½
\81D", delta, currency(delta));
5142 You("owe %s %ld %s.", shkname(shkp), delta, currency(delta));
5144 You("%s
\82É%ld%s
\82Ì
\8eØ
\82è
\82ð
\82Â
\82
\82Á
\82½
\81D", shkname(shkp), delta, currency(delta));
5145 eshkp->debit += delta;
5146 eshkp->loan += delta;
5151 /* used in domove to block diagonal shop-exit */
5152 /* x,y should always be a door */
5155 register xchar x, y;
5157 register int roomno = *in_rooms(x, y, SHOPBASE);
5158 register struct monst *shkp;
5160 if (roomno < 0 || !IS_SHOP(roomno))
5162 if (!IS_DOOR(levl[x][y].typ))
5164 if (roomno != *u.ushops)
5167 if (!(shkp = shop_keeper((char) roomno)) || !inhishop(shkp))
5170 if (shkp->mx == ESHK(shkp)->shk.x && shkp->my == ESHK(shkp)->shk.y
5171 /* Actually, the shk should be made to block _any_
5172 * door, including a door the player digs, if the
5173 * shk is within a 'jumping' distance.
5175 && ESHK(shkp)->shd.x == x
5176 && ESHK(shkp)->shd.y == y
5177 && shkp->mcanmove && !shkp->msleeping
5178 && (ESHK(shkp)->debit || ESHK(shkp)->billct || ESHK(shkp)->robbed)) {
5180 pline("%s%s blocks your way!", shkname(shkp),
5181 Invis ? " senses your motion and" : "");
5183 pline("%s
\82Í%s
\82 \82È
\82½
\82Ì
\91O
\82É
\97§
\82¿
\82Ó
\82³
\82ª
\82Á
\82½
\81I", shkname(shkp),
5184 Invis ? "
\93®
\82«
\82ð
\8a´
\82¶
\82Æ
\82è
\81C" : "");
5191 /* used in domove to block diagonal shop-entry;
5192 u.ux, u.uy should always be a door */
5195 register xchar x, y;
5197 register xchar sx, sy;
5198 register int roomno;
5199 register struct monst *shkp;
5201 if (!(IS_DOOR(levl[u.ux][u.uy].typ)
5202 && levl[u.ux][u.uy].doormask == D_BROKEN))
5205 roomno = *in_rooms(x, y, SHOPBASE);
5206 if (roomno < 0 || !IS_SHOP(roomno))
5208 if (!(shkp = shop_keeper((char) roomno)) || !inhishop(shkp))
5211 if (ESHK(shkp)->shd.x != u.ux || ESHK(shkp)->shd.y != u.uy)
5214 sx = ESHK(shkp)->shk.x;
5215 sy = ESHK(shkp)->shk.y;
5217 if (shkp->mx == sx && shkp->my == sy && shkp->mcanmove && !shkp->msleeping
5218 && (x == sx - 1 || x == sx + 1 || y == sy - 1 || y == sy + 1)
5219 && (Invis || carrying(PICK_AXE) || carrying(DWARVISH_MATTOCK)
5222 pline("%s%s blocks your way!", shkname(shkp),
5223 Invis ? " senses your motion and" : "");
5225 pline("%s%s
\82 \82È
\82½
\82Ì
\91O
\82É
\97§
\82¿
\82Ó
\82³
\82ª
\82Á
\82½
\81I", shkname(shkp),
5226 Invis ? "
\93®
\82«
\82ð
\8a´
\82¶
\82Æ
\82è
\81C" : "");
5233 /* "your " or "Foobar's " (note the trailing space) */
5234 /*
\81u
\82 \82È
\82½
\82Ì
\81v
\82©
\81uFoobar
\82Ì
\81v(
\96\96\94ö
\82É
\8bó
\94\92\82Í
\95s
\97v) */
5240 if (!shk_owns(buf, obj) && !mon_owns(buf, obj))
5241 Strcpy(buf, the_your[carried(obj) ? 1 : 0]);
5243 return strcat(buf, " ");
5253 (void) shk_your(buf, obj);
5268 if (get_obj_location(obj, &x, &y, 0)
5269 && (obj->unpaid || (obj->where == OBJ_FLOOR && !obj->no_charge
5270 && costly_spot(x, y)))) {
5271 shkp = shop_keeper(inside_shop(x, y));
5273 return strcpy(buf, shkp ? s_suffix(shkname(shkp)) : the_your[0]);
5276 strcpy(buf, shkname(shkp));
5277 strcat(buf, "
\82Ì");
5292 if (obj->where == OBJ_MINVENT)
5294 return strcpy(buf, s_suffix(y_monnam(obj->ocarry)));
5297 strcpy(buf, mon_nam(obj->ocarry));
5298 strcat(buf, "
\82Ì");
5305 #if 0 /*JP*//*
\97\90\96\
\82É
\8cÄ
\82Ñ
\82©
\82¯
\82é
\82Æ
\82«
\82Ì
\93ñ
\90l
\8fÌ
\81B
\93ú
\96{
\8cê
\82Å
\82Í
\81u
\82¨
\82¢
\81v
\82Å
\8dÏ
\82Þ
\82Ì
\82Å
\8eg
\82í
\82È
\82¢*/
5306 STATIC_OVL const char *
5308 boolean altusage; /* used as a verbalized exclamation: \"Cad! ...\" */
5310 const char *res = 0;
5312 switch (is_demon(youmonst.data) ? 3 : poly_gender()) {
5326 impossible("cad: unknown gender");
5331 char *cadbuf = mon_nam(&youmonst); /* snag an output buffer */
5333 /* alternate usage adds a leading double quote and trailing
5334 exclamation point plus sentence separating spaces */
5335 Sprintf(cadbuf, "\"%s! ", res);
5336 cadbuf[1] = highc(cadbuf[1]);
5345 sasc_bug(struct obj *op, unsigned x)