OSDN Git Service

fix #36370
[jnethack/source.git] / src / steal.c
1 /* NetHack 3.6  steal.c $NHDT-Date: 1446713643 2015/11/05 08:54:03 $  $NHDT-Branch: master $:$NHDT-Revision: 1.65 $ */
2 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3 /* NetHack may be freely redistributed.  See license for details. */
4
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. */
9
10 #include "hack.h"
11
12 STATIC_PTR int NDECL(stealarm);
13
14 STATIC_DCL const char *FDECL(equipname, (struct obj *));
15
16 STATIC_OVL const char *
17 equipname(otmp)
18 register struct obj *otmp;
19 {
20     return ((otmp == uarmu)
21 /*JP
22                 ? "shirt"
23 */
24                 ? "\83V\83\83\83c"
25                 : (otmp == uarmf)
26 /*JP
27                       ? "boots"
28 */
29                       ? "\8cC"
30                       : (otmp == uarms)
31 /*JP
32                             ? "shield"
33 */
34                             ? "\8f\82"
35                             : (otmp == uarmg)
36 /*JP
37                                   ? "gloves"
38 */
39                                   ? "\8f¬\8eè"
40                                   : (otmp == uarmc)
41                                         ? cloak_simple_name(otmp)
42                                         : (otmp == uarmh)
43                                               ? helm_simple_name(otmp)
44                                               : suit_simple_name(otmp));
45 }
46
47 /* proportional subset of gold; return value actually fits in an int */
48 long
49 somegold(lmoney)
50 long lmoney;
51 {
52 #ifdef LINT /* long conv. ok */
53     int igold = 0;
54 #else
55     int igold = (lmoney >= (long) LARGEST_INT) ? LARGEST_INT : (int) lmoney;
56 #endif
57
58     if (igold < 50)
59         ; /* all gold */
60     else if (igold < 100)
61         igold = rn1(igold - 25 + 1, 25);
62     else if (igold < 500)
63         igold = rn1(igold - 50 + 1, 50);
64     else if (igold < 1000)
65         igold = rn1(igold - 100 + 1, 100);
66     else if (igold < 5000)
67         igold = rn1(igold - 500 + 1, 500);
68     else if (igold < 10000)
69         igold = rn1(igold - 1000 + 1, 1000);
70     else
71         igold = rn1(igold - 5000 + 1, 5000);
72
73     return (long) igold;
74 }
75
76 /*
77  * Find the first (and hopefully only) gold object in a chain.
78  * Used when leprechaun (or you as leprechaun) looks for
79  * someone else's gold.  Returns a pointer so the gold may
80  * be seized without further searching.
81  * May search containers too.
82  * Deals in gold only, as leprechauns don't care for lesser coins.
83 */
84 struct obj *
85 findgold(chain)
86 register struct obj *chain;
87 {
88     while (chain && chain->otyp != GOLD_PIECE)
89         chain = chain->nobj;
90     return chain;
91 }
92
93 /*
94  * Steal gold coins only.  Leprechauns don't care for lesser coins.
95 */
96 void
97 stealgold(mtmp)
98 register struct monst *mtmp;
99 {
100     register struct obj *fgold = g_at(u.ux, u.uy);
101     register struct obj *ygold;
102     register long tmp;
103     struct monst *who;
104     const char *whose, *what;
105
106     /* skip lesser coins on the floor */
107     while (fgold && fgold->otyp != GOLD_PIECE)
108         fgold = fgold->nexthere;
109
110     /* Do you have real gold? */
111     ygold = findgold(invent);
112
113     if (fgold && (!ygold || fgold->quan > ygold->quan || !rn2(5))) {
114         obj_extract_self(fgold);
115         add_to_minv(mtmp, fgold);
116         newsym(u.ux, u.uy);
117 #if 0 /*JP*/
118         if (u.usteed) {
119             who = u.usteed;
120             whose = s_suffix(y_monnam(who));
121             what = makeplural(mbodypart(who, FOOT));
122         } else {
123             who = &youmonst;
124             whose = "your";
125             what = makeplural(body_part(FOOT));
126         }
127         /* [ avoid "between your rear regions" :-] */
128         if (slithy(who->data))
129             what = "coils";
130         /* reduce "rear hooves/claws" to "hooves/claws" */
131         if (!strncmp(what, "rear ", 5))
132             what += 5;
133         pline("%s quickly snatches some gold from %s %s %s!", Monnam(mtmp),
134               (Levitation || Flying) ? "beneath" : "between", whose, what);
135 #else /*JP:\91«\82ª\96³\82­\82Ä\82à\81u\91«\8c³\81v\82Å\82æ\82µ\82Æ\82·\82é*/
136         pline("%s\82Í\91f\91\81\82­\82 \82È\82½\82Ì%s\82©\82ç\8bà\82ð\82Ð\82Á\82½\82­\82Á\82½\81I", Monnam(mtmp),
137               (Levitation || Flying) ? "\89º" : "\91«\8c³");
138 #endif
139         if (!ygold || !rn2(5)) {
140             if (!tele_restrict(mtmp))
141                 (void) rloc(mtmp, TRUE);
142             monflee(mtmp, 0, FALSE, FALSE);
143         }
144     } else if (ygold) {
145         const int gold_price = objects[GOLD_PIECE].oc_cost;
146
147         tmp = (somegold(money_cnt(invent)) + gold_price - 1) / gold_price;
148         tmp = min(tmp, ygold->quan);
149         if (tmp < ygold->quan)
150             ygold = splitobj(ygold, tmp);
151         else
152             setnotworn(ygold);
153         freeinv(ygold);
154         add_to_minv(mtmp, ygold);
155 /*JP
156         Your("purse feels lighter.");
157 */
158         Your("\8dà\95z\82Í\8cy\82­\82È\82Á\82½\81D");
159         if (!tele_restrict(mtmp))
160             (void) rloc(mtmp, TRUE);
161         monflee(mtmp, 0, FALSE, FALSE);
162         context.botl = 1;
163     }
164 }
165
166 /* steal armor after you finish taking it off */
167 unsigned int stealoid; /* object to be stolen */
168 unsigned int stealmid; /* monster doing the stealing */
169
170 STATIC_PTR int
171 stealarm(VOID_ARGS)
172 {
173     register struct monst *mtmp;
174     register struct obj *otmp;
175
176     for (otmp = invent; otmp; otmp = otmp->nobj) {
177         if (otmp->o_id == stealoid) {
178             for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
179                 if (mtmp->m_id == stealmid) {
180                     if (DEADMONSTER(mtmp))
181                         impossible("stealarm(): dead monster stealing");
182                     if (!dmgtype(mtmp->data, AD_SITM)) /* polymorphed */
183                         goto botm;
184                     if (otmp->unpaid)
185                         subfrombill(otmp, shop_keeper(*u.ushops));
186                     freeinv(otmp);
187 /*JP
188                     pline("%s steals %s!", Monnam(mtmp), doname(otmp));
189 */
190                     pline("%s\82Í%s\82ð\93\90\82ñ\82¾\81I", Monnam(mtmp), doname(otmp));
191                     (void) mpickobj(mtmp, otmp); /* may free otmp */
192                     /* Implies seduction, "you gladly hand over ..."
193                        so we don't set mavenge bit here. */
194                     monflee(mtmp, 0, FALSE, FALSE);
195                     if (!tele_restrict(mtmp))
196                         (void) rloc(mtmp, TRUE);
197                     break;
198                 }
199             }
200             break;
201         }
202     }
203 botm:
204     stealoid = 0;
205     return 0;
206 }
207
208 /* An object you're wearing has been taken off by a monster (theft or
209    seduction).  Also used if a worn item gets transformed (stone to flesh). */
210 void
211 remove_worn_item(obj, unchain_ball)
212 struct obj *obj;
213 boolean unchain_ball; /* whether to unpunish or just unwield */
214 {
215     if (donning(obj))
216         cancel_don();
217     if (!obj->owornmask)
218         return;
219
220     if (obj->owornmask & W_ARMOR) {
221         if (obj == uskin) {
222             impossible("Removing embedded scales?");
223             skinback(TRUE); /* uarm = uskin; uskin = 0; */
224         }
225         if (obj == uarm)
226             (void) Armor_off();
227         else if (obj == uarmc)
228             (void) Cloak_off();
229         else if (obj == uarmf)
230             (void) Boots_off();
231         else if (obj == uarmg)
232             (void) Gloves_off();
233         else if (obj == uarmh)
234             (void) Helmet_off();
235         else if (obj == uarms)
236             (void) Shield_off();
237         else if (obj == uarmu)
238             (void) Shirt_off();
239         /* catchall -- should never happen */
240         else
241             setworn((struct obj *) 0, obj->owornmask & W_ARMOR);
242     } else if (obj->owornmask & W_AMUL) {
243         Amulet_off();
244     } else if (obj->owornmask & W_RING) {
245         Ring_gone(obj);
246     } else if (obj->owornmask & W_TOOL) {
247         Blindf_off(obj);
248     } else if (obj->owornmask & W_WEAPON) {
249         if (obj == uwep)
250             uwepgone();
251         if (obj == uswapwep)
252             uswapwepgone();
253         if (obj == uquiver)
254             uqwepgone();
255     }
256
257     if (obj->owornmask & (W_BALL | W_CHAIN)) {
258         if (unchain_ball)
259             unpunish();
260     } else if (obj->owornmask) {
261         /* catchall */
262         setnotworn(obj);
263     }
264 }
265
266 /* Returns 1 when something was stolen (or at least, when N should flee now)
267  * Returns -1 if the monster died in the attempt
268  * Avoid stealing the object stealoid
269  * Nymphs and monkeys won't steal coins
270  */
271 int
272 steal(mtmp, objnambuf)
273 struct monst *mtmp;
274 char *objnambuf;
275 {
276     struct obj *otmp;
277     int tmp, could_petrify, armordelay, olddelay, named = 0, retrycnt = 0;
278     boolean monkey_business, /* true iff an animal is doing the thievery */
279         was_doffing;
280
281     if (objnambuf)
282         *objnambuf = '\0';
283     /* the following is true if successful on first of two attacks. */
284     if (!monnear(mtmp, u.ux, u.uy))
285         return 0;
286
287     /* food being eaten might already be used up but will not have
288        been removed from inventory yet; we don't want to steal that,
289        so this will cause it to be removed now */
290     if (occupation)
291         (void) maybe_finished_meal(FALSE);
292
293     if (!invent || (inv_cnt(FALSE) == 1 && uskin)) {
294     nothing_to_steal:
295         /* Not even a thousand men in armor can strip a naked man. */
296         if (Blind)
297 /*JP
298             pline("Somebody tries to rob you, but finds nothing to steal.");
299 */
300             pline("\92N\82©\82ª\82 \82È\82½\82©\82ç\93\90\82à\82¤\82Æ\82µ\82½\82ª\81C\93\90\82Þ\82à\82Ì\82ª\82È\82¢\82±\82Æ\82É\8bC\82ª\82Â\82¢\82½\81D");
301         else
302 /*JP
303             pline("%s tries to rob you, but there is nothing to steal!",
304 */
305             pline("%s\82Í\82 \82È\82½\82©\82ç\93\90\82à\82¤\82Æ\82µ\82½\82ª\81C\93\90\82Þ\82à\82Ì\82ª\82È\82¢\82±\82Æ\82É\8bC\82ª\82Â\82¢\82½\81I",
306                   Monnam(mtmp));
307         return 1; /* let her flee */
308     }
309
310     monkey_business = is_animal(mtmp->data);
311     if (monkey_business || uarmg) {
312         ; /* skip ring special cases */
313     } else if (Adornment & LEFT_RING) {
314         otmp = uleft;
315         goto gotobj;
316     } else if (Adornment & RIGHT_RING) {
317         otmp = uright;
318         goto gotobj;
319     }
320
321 retry:
322     tmp = 0;
323     for (otmp = invent; otmp; otmp = otmp->nobj)
324         if ((!uarm || otmp != uarmc) && otmp != uskin
325             && otmp->oclass != COIN_CLASS)
326             tmp += (otmp->owornmask & (W_ARMOR | W_ACCESSORY)) ? 5 : 1;
327     if (!tmp)
328         goto nothing_to_steal;
329     tmp = rn2(tmp);
330     for (otmp = invent; otmp; otmp = otmp->nobj)
331         if ((!uarm || otmp != uarmc) && otmp != uskin
332             && otmp->oclass != COIN_CLASS) {
333             tmp -= (otmp->owornmask & (W_ARMOR | W_ACCESSORY)) ? 5 : 1;
334             if (tmp < 0)
335                 break;
336         }
337     if (!otmp) {
338         impossible("Steal fails!");
339         return 0;
340     }
341     /* can't steal ring(s) while wearing gloves */
342     if ((otmp == uleft || otmp == uright) && uarmg)
343         otmp = uarmg;
344     /* can't steal gloves while wielding - so steal the wielded item. */
345     if (otmp == uarmg && uwep)
346         otmp = uwep;
347     /* can't steal armor while wearing cloak - so steal the cloak. */
348     else if (otmp == uarm && uarmc)
349         otmp = uarmc;
350     /* can't steal shirt while wearing cloak or suit */
351     else if (otmp == uarmu && uarmc)
352         otmp = uarmc;
353     else if (otmp == uarmu && uarm)
354         otmp = uarm;
355
356 gotobj:
357     if (otmp->o_id == stealoid)
358         return 0;
359
360     if (otmp->otyp == BOULDER && !throws_rocks(mtmp->data)) {
361         if (!retrycnt++)
362             goto retry;
363         goto cant_take;
364     }
365     /* animals can't overcome curse stickiness nor unlock chains */
366     if (monkey_business) {
367         boolean ostuck;
368         /* is the player prevented from voluntarily giving up this item?
369            (ignores loadstones; the !can_carry() check will catch those) */
370         if (otmp == uball)
371             ostuck = TRUE; /* effectively worn; curse is implicit */
372         else if (otmp == uquiver || (otmp == uswapwep && !u.twoweap))
373             ostuck = FALSE; /* not really worn; curse doesn't matter */
374         else
375             ostuck = ((otmp->cursed && otmp->owornmask)
376                       /* nymphs can steal rings from under
377                          cursed weapon but animals can't */
378                       || (otmp == uright && welded(uwep))
379                       || (otmp == uleft && welded(uwep) && bimanual(uwep)));
380
381         if (ostuck || can_carry(mtmp, otmp) == 0) {
382 #if 0 /*JP*/
383             static const char *const how[] = { "steal", "snatch", "grab",
384                                                "take" };
385         cant_take:
386             pline("%s tries to %s %s%s but gives up.", Monnam(mtmp),
387                   how[rn2(SIZE(how))],
388                   (otmp->owornmask & W_ARMOR) ? "your " : "",
389                   (otmp->owornmask & W_ARMOR) ? equipname(otmp)
390                                               : yname(otmp));
391 #else
392         cant_take:
393             pline("%s\82Í%s\82ð\93\90\82à\82¤\82Æ\82µ\82½\82ª\92ú\82ß\82½\81D", Monnam(mtmp),
394                   (otmp->owornmask & W_ARMOR) ? equipname(otmp)
395                                               : yname(otmp));
396 #endif
397             /* the fewer items you have, the less likely the thief
398                is going to stick around to try again (0) instead of
399                running away (1) */
400             return !rn2(inv_cnt(FALSE) / 5 + 2);
401         }
402     }
403
404     if (otmp->otyp == LEASH && otmp->leashmon) {
405         if (monkey_business && otmp->cursed)
406             goto cant_take;
407         o_unleash(otmp);
408     }
409
410     was_doffing = doffing(otmp);
411     /* stop donning/doffing now so that afternmv won't be clobbered
412        below; stop_occupation doesn't handle donning/doffing */
413     olddelay = stop_donning(otmp);
414     /* you're going to notice the theft... */
415     stop_occupation();
416
417     if (otmp->owornmask & (W_ARMOR | W_ACCESSORY)) {
418         switch (otmp->oclass) {
419         case TOOL_CLASS:
420         case AMULET_CLASS:
421         case RING_CLASS:
422         case FOOD_CLASS: /* meat ring */
423             remove_worn_item(otmp, TRUE);
424             break;
425         case ARMOR_CLASS:
426             armordelay = objects[otmp->otyp].oc_delay;
427             if (olddelay > 0 && olddelay < armordelay)
428                 armordelay = olddelay;
429             if (monkey_business) {
430                 /* animals usually don't have enough patience
431                    to take off items which require extra time */
432                 if (armordelay >= 1 && !olddelay && rn2(10))
433                     goto cant_take;
434                 remove_worn_item(otmp, TRUE);
435                 break;
436             } else {
437                 int curssv = otmp->cursed;
438                 int slowly;
439                 boolean seen = canspotmon(mtmp);
440
441                 otmp->cursed = 0;
442                 /* can't charm you without first waking you */
443                 if (Unaware)
444                     unmul((char *) 0);
445                 slowly = (armordelay >= 1 || multi < 0);
446                 if (flags.female)
447 #if 0 /*JP*/
448                     pline("%s charms you.  You gladly %s your %s.",
449                           !seen ? "She" : Monnam(mtmp),
450                           curssv ? "let her take"
451                                  : !slowly ? "hand over"
452                                            : was_doffing ? "continue removing"
453                                                          : "start removing",
454                           equipname(otmp));
455 #else
456                     pline("%s\82Í\82 \82È\82½\82ð\96£\97¹\82µ\82½\81D\82 \82È\82½\82Í\82æ\82ë\82±\82ñ\82Å%s\82ð%s\82½\81D",
457                           !seen ? "\94Þ\8f\97" : Monnam(mtmp),
458                           equipname(otmp),
459                           curssv ? "\82Í\82¸\82µ\82Ä\82à\82ç\82Á"
460                                  : !slowly ? "\82Í\82¸\82µ\82Ä\8eè\93n\82µ"
461                                            : was_doffing ? "\82Í\82¸\82µ\91±\82¯"
462                                                          : "\82Í\82¸\82µ\8en\82ß");
463 #endif
464                 else
465 #if 0 /*JP*/
466                     pline("%s seduces you and %s off your %s.",
467                           !seen ? "She" : Adjmonnam(mtmp, "beautiful"),
468                           curssv
469                               ? "helps you to take"
470                               : !slowly ? "you take"
471                                         : was_doffing ? "you continue taking"
472                                                       : "you start taking",
473                           equipname(otmp));
474 #else
475                     pline("%s\82Í\82 \82È\82½\82ð\97U\98f\82µ\82½\81D\82 \82È\82½\82Í%s\82ð%s\81D",
476                           !seen ? "\94Þ\8f\97" : Adjmonnam(mtmp, "\94ü\82µ\82¢"),
477                           equipname(otmp),
478                           curssv
479                               ? "\82Í\82¸\82µ\82Ä\82à\82ç\82Á"
480                               : !slowly ? "\82Í\82¸\82µ"
481                                         : was_doffing ? "\82Í\82¸\82µ\91±\82¯"
482                                                       : "\82Í\82¸\82µ\8en\82ß");
483 #endif
484                 named++;
485                 /* the following is to set multi for later on */
486                 nomul(-armordelay);
487 /*JP
488                 multi_reason = "taking off clothes";
489 */
490                 multi_reason = "\95\9e\82ð\92E\82¢\82Å\82¢\82é\8e\9e\82É";
491                 nomovemsg = 0;
492                 remove_worn_item(otmp, TRUE);
493                 otmp->cursed = curssv;
494                 if (multi < 0) {
495                     /*
496                     multi = 0;
497                     afternmv = 0;
498                     */
499                     stealoid = otmp->o_id;
500                     stealmid = mtmp->m_id;
501                     afternmv = stealarm;
502                     return 0;
503                 }
504             }
505             break;
506         default:
507             impossible("Tried to steal a strange worn thing. [%d]",
508                        otmp->oclass);
509         }
510     } else if (otmp->owornmask)
511         remove_worn_item(otmp, TRUE);
512
513     /* do this before removing it from inventory */
514     if (objnambuf)
515         Strcpy(objnambuf, yname(otmp));
516     /* set mavenge bit so knights won't suffer an
517      * alignment penalty during retaliation;
518      */
519     mtmp->mavenge = 1;
520
521     if (otmp->unpaid)
522         subfrombill(otmp, shop_keeper(*u.ushops));
523     freeinv(otmp);
524 /*JP
525     pline("%s stole %s.", named ? "She" : Monnam(mtmp), doname(otmp));
526 */
527     pline("%s\82Í%s\82ð\93\90\82ñ\82¾\81D", named ? "\94Þ\8f\97" : Monnam(mtmp), doname(otmp));
528     could_petrify =
529         (otmp->otyp == CORPSE && touch_petrifies(&mons[otmp->corpsenm]));
530     (void) mpickobj(mtmp, otmp); /* may free otmp */
531     if (could_petrify && !(mtmp->misc_worn_check & W_ARMG)) {
532         minstapetrify(mtmp, TRUE);
533         return -1;
534     }
535     return (multi < 0) ? 0 : 1;
536 }
537
538 /* Returns 1 if otmp is free'd, 0 otherwise. */
539 int
540 mpickobj(mtmp, otmp)
541 register struct monst *mtmp;
542 register struct obj *otmp;
543 {
544     int freed_otmp;
545     boolean snuff_otmp = FALSE;
546
547     /* if monster is acquiring a thrown or kicked object, the throwing
548        or kicking code shouldn't continue to track and place it */
549     if (otmp == thrownobj)
550         thrownobj = 0;
551     else if (otmp == kickedobj)
552         kickedobj = 0;
553     /* don't want hidden light source inside the monster; assumes that
554        engulfers won't have external inventories; whirly monsters cause
555        the light to be extinguished rather than letting it shine thru */
556     if (obj_sheds_light(otmp) && attacktype(mtmp->data, AT_ENGL)) {
557         /* this is probably a burning object that you dropped or threw */
558         if (u.uswallow && mtmp == u.ustuck && !Blind)
559 /*JP
560             pline("%s out.", Tobjnam(otmp, "go"));
561 */
562             pline("%s\82Í\94ò\82Ñ\82¾\82µ\82½\81D", xname(otmp));
563         snuff_otmp = TRUE;
564     }
565     /* for hero owned object on shop floor, mtmp is taking possession
566        and if it's eventually dropped in a shop, shk will claim it */
567     if (!mtmp->mtame)
568         otmp->no_charge = 0;
569     /* Must do carrying effects on object prior to add_to_minv() */
570     carry_obj_effects(otmp);
571     /* add_to_minv() might free otmp [if merged with something else],
572        so we have to call it after doing the object checks */
573     freed_otmp = add_to_minv(mtmp, otmp);
574     /* and we had to defer this until object is in mtmp's inventory */
575     if (snuff_otmp)
576         snuff_light_source(mtmp->mx, mtmp->my);
577     return freed_otmp;
578 }
579
580 void
581 stealamulet(mtmp)
582 struct monst *mtmp;
583 {
584     struct obj *otmp = (struct obj *) 0;
585     int real = 0, fake = 0;
586
587     /* select the artifact to steal */
588     if (u.uhave.amulet) {
589         real = AMULET_OF_YENDOR;
590         fake = FAKE_AMULET_OF_YENDOR;
591     } else if (u.uhave.questart) {
592         for (otmp = invent; otmp; otmp = otmp->nobj)
593             if (is_quest_artifact(otmp))
594                 break;
595         if (!otmp)
596             return; /* should we panic instead? */
597     } else if (u.uhave.bell) {
598         real = BELL_OF_OPENING;
599         fake = BELL;
600     } else if (u.uhave.book) {
601         real = SPE_BOOK_OF_THE_DEAD;
602     } else if (u.uhave.menorah) {
603         real = CANDELABRUM_OF_INVOCATION;
604     } else
605         return; /* you have nothing of special interest */
606
607     if (!otmp) {
608         /* If we get here, real and fake have been set up. */
609         for (otmp = invent; otmp; otmp = otmp->nobj)
610             if (otmp->otyp == real || (otmp->otyp == fake && !mtmp->iswiz))
611                 break;
612     }
613
614     if (otmp) { /* we have something to snatch */
615         if (otmp->owornmask)
616             remove_worn_item(otmp, TRUE);
617         if (otmp->unpaid)
618             subfrombill(otmp, shop_keeper(*u.ushops));
619         freeinv(otmp);
620         /* mpickobj wont merge otmp because none of the above things
621            to steal are mergable */
622         (void) mpickobj(mtmp, otmp); /* may merge and free otmp */
623 /*JP
624         pline("%s stole %s!", Monnam(mtmp), doname(otmp));
625 */
626         pline("%s\82Í%s\82ð\93\90\82ñ\82¾\81I", Monnam(mtmp), doname(otmp));
627         if (can_teleport(mtmp->data) && !tele_restrict(mtmp))
628             (void) rloc(mtmp, TRUE);
629     }
630 }
631
632 /* when a mimic gets poked with something, it might take that thing
633    (at present, only implemented for when the hero does the poking) */
634 void
635 maybe_absorb_item(mon, obj, ochance, achance)
636 struct monst *mon;
637 struct obj *obj;
638 int ochance, achance; /* percent chance for ordinary item, artifact */
639 {
640     if (obj == uball || obj == uchain || obj->oclass == ROCK_CLASS
641         || obj_resists(obj, 100 - ochance, 100 - achance)
642         || !touch_artifact(obj, mon))
643         return;
644
645     if (carried(obj)) {
646         if (obj->owornmask)
647             remove_worn_item(obj, TRUE);
648         if (obj->unpaid)
649             subfrombill(obj, shop_keeper(*u.ushops));
650         if (cansee(mon->mx, mon->my)) {
651             const char *MonName = Monnam(mon);
652
653 #if 0 /*JP*//*\93ú\96{\8cê\82Å\82Í\95s\97v*/
654             /* mon might be invisible; avoid "It pulls ... and absorbs it!" */
655             if (!strcmp(MonName, "It"))
656                 MonName = "Something";
657 #endif
658 #if 0 /*JP*/
659             pline("%s pulls %s away from you and absorbs %s!", MonName,
660                   yname(obj), (obj->quan > 1L) ? "them" : "it");
661 #else
662             pline("%s\82Í%s\82ð\88ø\82Á\82Ï\82è\8d\9e\82ñ\82Å\8bz\8eû\82µ\82½\81I", MonName,
663                   yname(obj));
664 #endif
665         } else {
666             const char *hand_s = body_part(HAND);
667
668             if (bimanual(obj))
669                 hand_s = makeplural(hand_s);
670 #if 0 /*JP*/
671             pline("%s %s pulled from your %s!", upstart(yname(obj)),
672                   otense(obj, "are"), hand_s);
673 #else
674             pline("%s\82Í\82 \82È\82½\82Ì%s\82©\82ç\88ø\82Á\82Ï\82è\8d\9e\82Ü\82ê\82½\81I", upstart(yname(obj)),
675                   hand_s);
676 #endif
677         }
678         freeinv(obj);
679     } else {
680         /* not carried; presumably thrown or kicked */
681         if (canspotmon(mon))
682 /*JP
683             pline("%s absorbs %s!", Monnam(mon), yname(obj));
684 */
685             pline("%s\82Í%s\82ð\8bz\8eû\82µ\82½\81I", Monnam(mon), yname(obj));
686     }
687     /* add to mon's inventory */
688     (void) mpickobj(mon, obj);
689 }
690
691 /* drop one object taken from a (possibly dead) monster's inventory */
692 void
693 mdrop_obj(mon, obj, verbosely)
694 struct monst *mon;
695 struct obj *obj;
696 boolean verbosely;
697 {
698     int omx = mon->mx, omy = mon->my;
699     boolean update_mon = FALSE;
700
701     if (obj->owornmask) {
702         /* perform worn item handling if the monster is still alive */
703         if (mon->mhp > 0) {
704             mon->misc_worn_check &= ~obj->owornmask;
705             update_mon = TRUE;
706             /* don't charge for an owned saddle on dead steed (provided
707                that the hero is within the same shop at the time) */
708         } else if (mon->mtame && (obj->owornmask & W_SADDLE) && !obj->unpaid
709                    && costly_spot(omx, omy)
710                    /* being at costly_spot guarantees lev->roomno is not 0 */
711                    && index(in_rooms(u.ux, u.uy, SHOPBASE),
712                             levl[omx][omy].roomno)) {
713             obj->no_charge = 1;
714         }
715         /* this should be done even if the monster has died */
716         if (obj->owornmask & W_WEP)
717             setmnotwielded(mon, obj);
718         obj->owornmask = 0L;
719     }
720     /* obj_no_longer_held(obj); -- done by place_object */
721     if (verbosely && cansee(omx, omy))
722 /*JP
723         pline("%s drops %s.", Monnam(mon), distant_name(obj, doname));
724 */
725         pline("%s\82Í%s\82ð\92u\82¢\82½\81D", Monnam(mon), distant_name(obj, doname));
726 /*JP
727     if (!flooreffects(obj, omx, omy, "fall")) {
728 */
729     if (!flooreffects(obj, omx, omy, "\97\8e\82¿\82é")) {
730         place_object(obj, omx, omy);
731         stackobj(obj);
732     }
733     /* do this last, after placing obj on floor; removing steed's saddle
734        throws rider, possibly inflicting fatal damage and producing bones */
735     if (update_mon)
736         update_mon_intrinsics(mon, obj, FALSE, TRUE);
737 }
738
739 /* some monsters bypass the normal rules for moving between levels or
740    even leaving the game entirely; when that happens, prevent them from
741    taking the Amulet or invocation tools with them */
742 void
743 mdrop_special_objs(mon)
744 struct monst *mon;
745 {
746     struct obj *obj, *otmp;
747
748     for (obj = mon->minvent; obj; obj = otmp) {
749         otmp = obj->nobj;
750         /* the Amulet, invocation tools, and Rider corpses resist even when
751            artifacts and ordinary objects are given 0% resistance chance */
752         if (obj_resists(obj, 0, 0)) {
753             obj_extract_self(obj);
754             mdrop_obj(mon, obj, FALSE);
755         }
756     }
757 }
758
759 /* release the objects the creature is carrying */
760 void
761 relobj(mtmp, show, is_pet)
762 struct monst *mtmp;
763 int show;
764 boolean is_pet; /* If true, pet should keep wielded/worn items */
765 {
766     struct obj *otmp;
767     int omx = mtmp->mx, omy = mtmp->my;
768
769     /* vault guard's gold goes away rather than be dropped... */
770     if (mtmp->isgd && (otmp = findgold(mtmp->minvent)) != 0) {
771         if (canspotmon(mtmp))
772 #if 0 /*JP*/
773             pline("%s gold %s.", s_suffix(Monnam(mtmp)),
774                   canseemon(mtmp) ? "vanishes" : "seems to vanish");
775 #else
776             pline("%s\82Ì\8bà\82Í\8fÁ\82¦\82½%s\81D", Monnam(mtmp),
777                   canseemon(mtmp) ? "" : "\82æ\82¤\82¾");
778 #endif
779         obj_extract_self(otmp);
780         obfree(otmp, (struct obj *) 0);
781     } /* isgd && has gold */
782
783     while ((otmp = (is_pet ? droppables(mtmp) : mtmp->minvent)) != 0) {
784         obj_extract_self(otmp);
785         mdrop_obj(mtmp, otmp, is_pet && flags.verbose);
786     }
787
788     if (show && cansee(omx, omy))
789         newsym(omx, omy);
790 }
791
792 /*steal.c*/