OSDN Git Service

update year to 2019
[jnethack/source.git] / src / dothrow.c
1 /* NetHack 3.6  dothrow.c       $NHDT-Date: 1522967321 2018/04/05 22:28:41 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.135 $ */
2 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3 /*-Copyright (c) Robert Patrick Rankin, 2013. */
4 /* NetHack may be freely redistributed.  See license for details. */
5
6 /* Contains code for 't' (throw) */
7
8 /* JNetHack Copyright */
9 /* (c) Issei Numata, Naoki Hamada, Shigehiro Miyashita, 1994-2000  */
10 /* For 3.4-, Copyright (c) SHIRAKATA Kentaro, 2002-2019            */
11 /* JNetHack may be freely redistributed.  See license for details. */
12
13 #include "hack.h"
14
15 STATIC_DCL int FDECL(throw_obj, (struct obj *, int));
16 STATIC_DCL boolean FDECL(ok_to_throw, (int *));
17 STATIC_DCL void NDECL(autoquiver);
18 STATIC_DCL int FDECL(gem_accept, (struct monst *, struct obj *));
19 STATIC_DCL void FDECL(tmiss, (struct obj *, struct monst *, BOOLEAN_P));
20 STATIC_DCL int FDECL(throw_gold, (struct obj *));
21 STATIC_DCL void FDECL(check_shop_obj, (struct obj *, XCHAR_P, XCHAR_P,
22                                        BOOLEAN_P));
23 STATIC_DCL void FDECL(breakmsg, (struct obj *, BOOLEAN_P));
24 STATIC_DCL boolean FDECL(toss_up, (struct obj *, BOOLEAN_P));
25 STATIC_DCL void FDECL(sho_obj_return_to_u, (struct obj * obj));
26 STATIC_DCL boolean FDECL(mhurtle_step, (genericptr_t, int, int));
27
28 static NEARDATA const char toss_objs[] = { ALLOW_COUNT, COIN_CLASS,
29                                            ALL_CLASSES, WEAPON_CLASS, 0 };
30 /* different default choices when wielding a sling (gold must be included) */
31 static NEARDATA const char bullets[] = { ALLOW_COUNT, COIN_CLASS, ALL_CLASSES,
32                                          GEM_CLASS, 0 };
33
34 /* thrownobj (decl.c) tracks an object until it lands */
35
36 extern boolean notonhead; /* for long worms */
37
38 /* Throw the selected object, asking for direction */
39 STATIC_OVL int
40 throw_obj(obj, shotlimit)
41 struct obj *obj;
42 int shotlimit;
43 {
44     struct obj *otmp;
45     int multishot;
46     schar skill;
47     long wep_mask;
48     boolean twoweap, weakmultishot;
49
50     /* ask "in what direction?" */
51     if (!getdir((char *) 0)) {
52         /* No direction specified, so cancel the throw;
53          * might need to undo an object split.
54          * We used to use freeinv(obj),addinv(obj) here, but that can
55          * merge obj into another stack--usually quiver--even if it hadn't
56          * been split from there (possibly triggering a panic in addinv),
57          * and freeinv+addinv potentially has other side-effects.
58          */
59         if (obj->o_id == context.objsplit.parent_oid
60             || obj->o_id == context.objsplit.child_oid)
61             (void) unsplitobj(obj);
62         return 0; /* no time passes */
63     }
64
65     /*
66      * Throwing money is usually for getting rid of it when
67      * a leprechaun approaches, or for bribing an oncoming
68      * angry monster.  So throw the whole object.
69      *
70      * If the money is in quiver, throw one coin at a time,
71      * possibly using a sling.
72      */
73     if (obj->oclass == COIN_CLASS && obj != uquiver)
74         return throw_gold(obj);
75
76 /*JP
77     if (!canletgo(obj, "throw"))
78 */
79     if (!canletgo(obj, "\93\8a\82°\82é"))
80         return 0;
81     if (obj->oartifact == ART_MJOLLNIR && obj != uwep) {
82 /*JP
83         pline("%s must be wielded before it can be thrown.", The(xname(obj)));
84 */
85         pline("\93\8a\82°\82é\91O\82É%s\82ð\91\95\94õ\82µ\82È\82­\82Ä\82Í\82È\82ç\82È\82¢\81D", xname(obj));
86         return 0;
87     }
88     if ((obj->oartifact == ART_MJOLLNIR && ACURR(A_STR) < STR19(25))
89         || (obj->otyp == BOULDER && !throws_rocks(youmonst.data))) {
90 /*JP
91         pline("It's too heavy.");
92 */
93         pline("\8fd\82·\82¬\82Ä\93\8a\82°\82ç\82ê\82È\82¢\81D");
94         return 1;
95     }
96     if (!u.dx && !u.dy && !u.dz) {
97 /*JP
98         You("cannot throw an object at yourself.");
99 */
100         pline("\8e©\95ª\82É\8cü\82©\82Á\82Ä\82Í\93\8a\82°\82ç\82ê\82È\82¢\81D");
101         return 0;
102     }
103     u_wipe_engr(2);
104     if (!uarmg && obj->otyp == CORPSE && touch_petrifies(&mons[obj->corpsenm])
105         && !Stone_resistance) {
106 #if 0 /*JP*/
107         You("throw %s with your bare %s.",
108             corpse_xname(obj, (const char *) 0, CXN_PFX_THE),
109             /* throwing with one hand, but pluralize since the
110                expression "with your bare hands" sounds better */
111             makeplural(body_part(HAND)));
112 #else
113         You("\91f%s\82Å%s\82Ì\8e\80\91Ì\82ð\93\8a\82°\82½\81D",
114             body_part(HAND),
115             corpse_xname(obj, (const char *) 0, CXN_PFX_THE));
116 #endif
117 /*JP
118         Sprintf(killer.name, "throwing %s bare-handed", killer_xname(obj));
119 */
120         Sprintf(killer.name, "%s\82Ì\8e\80\91Ì\82ð\91f\8eè\82Å\93\8a\82°\82Ä", killer_xname(obj));
121         instapetrify(killer.name);
122     }
123     if (welded(obj)) {
124         weldmsg(obj);
125         return 1;
126     }
127     if (is_wet_towel(obj))
128         dry_a_towel(obj, -1, FALSE);
129
130     /* Multishot calculations
131      * (potential volley of up to N missiles; default for N is 1)
132      */
133     multishot = 1;
134     skill = objects[obj->otyp].oc_skill;
135     if (obj->quan > 1L /* no point checking if there's only 1 */
136         /* ammo requires corresponding launcher be wielded */
137         && (is_ammo(obj) ? matching_launcher(obj, uwep)
138                          /* otherwise any stackable (non-ammo) weapon */
139                          : obj->oclass == WEAPON_CLASS)
140         && !(Confusion || Stunned)) {
141         /* some roles don't get a volley bonus until becoming expert */
142         weakmultishot = (Role_if(PM_WIZARD) || Role_if(PM_PRIEST)
143                          || (Role_if(PM_HEALER) && skill != P_KNIFE)
144                          || (Role_if(PM_TOURIST) && skill != -P_DART)
145                          /* poor dexterity also inhibits multishot */
146                          || Fumbling || ACURR(A_DEX) <= 6);
147
148         /* Bonus if the player is proficient in this weapon... */
149         switch (P_SKILL(weapon_type(obj))) {
150         case P_EXPERT:
151             multishot++;
152         /*FALLTHRU*/
153         case P_SKILLED:
154             if (!weakmultishot)
155                 multishot++;
156             break;
157         default: /* basic or unskilled: no bonus */
158             break;
159         }
160         /* ...or is using a special weapon for their role... */
161         switch (Role_switch) {
162         case PM_CAVEMAN:
163             /* give bonus for low-tech gear */
164             if (skill == -P_SLING || skill == P_SPEAR)
165                 multishot++;
166             break;
167         case PM_MONK:
168             /* allow higher volley count despite skill limitation */
169             if (skill == -P_SHURIKEN)
170                 multishot++;
171             break;
172         case PM_RANGER:
173             /* arbitrary; encourage use of other missiles beside daggers */
174             if (skill != P_DAGGER)
175                 multishot++;
176             break;
177         case PM_ROGUE:
178             /* possibly should add knives... */
179             if (skill == P_DAGGER)
180                 multishot++;
181             break;
182         case PM_SAMURAI:
183             /* role-specific launcher and its ammo */
184             if (obj->otyp == YA && uwep && uwep->otyp == YUMI)
185                 multishot++;
186             break;
187         default:
188             break; /* No bonus */
189         }
190         /* ...or using their race's special bow; no bonus for spears */
191         if (!weakmultishot)
192             switch (Race_switch) {
193             case PM_ELF:
194                 if (obj->otyp == ELVEN_ARROW && uwep
195                     && uwep->otyp == ELVEN_BOW)
196                     multishot++;
197                 break;
198             case PM_ORC:
199                 if (obj->otyp == ORCISH_ARROW && uwep
200                     && uwep->otyp == ORCISH_BOW)
201                     multishot++;
202                 break;
203             case PM_GNOME:
204                 /* arbitrary; there isn't any gnome-specific gear */
205                 if (skill == -P_CROSSBOW)
206                     multishot++;
207                 break;
208             case PM_HUMAN:
209             case PM_DWARF:
210             default:
211                 break; /* No bonus */
212             }
213
214         /* crossbows are slow to load and probably shouldn't allow multiple
215            shots at all, but that would result in players never using them;
216            instead, high strength is necessary to load and shoot quickly */
217         if (multishot > 1 && skill == -P_CROSSBOW
218             && ammo_and_launcher(obj, uwep)
219             && (int) ACURRSTR < (Race_if(PM_GNOME) ? 16 : 18))
220             multishot = rnd(multishot);
221
222         multishot = rnd(multishot);
223         if ((long) multishot > obj->quan)
224             multishot = (int) obj->quan;
225         if (shotlimit > 0 && multishot > shotlimit)
226             multishot = shotlimit;
227     }
228
229     m_shot.s = ammo_and_launcher(obj, uwep) ? TRUE : FALSE;
230     /* give a message if shooting more than one, or if player
231        attempted to specify a count */
232     if (multishot > 1 || shotlimit > 0) {
233         /* "You shoot N arrows." or "You throw N daggers." */
234 #if 0 /*JP*/
235         You("%s %d %s.", m_shot.s ? "shoot" : "throw",
236             multishot, /* (might be 1 if player gave shotlimit) */
237             (multishot == 1) ? singular(obj, xname) : xname(obj));
238 #else
239         You("%d%s\82Ì%s\82ð%s\81D",
240             multishot,
241             numeral(obj), xname(obj),
242             m_shot.s ? "\8c\82\82Á\82½" : "\93\8a\82°\82½");
243 #endif
244     }
245
246     wep_mask = obj->owornmask;
247     m_shot.o = obj->otyp;
248     m_shot.n = multishot;
249     for (m_shot.i = 1; m_shot.i <= m_shot.n; m_shot.i++) {
250         twoweap = u.twoweap;
251         /* split this object off from its slot if necessary */
252         if (obj->quan > 1L) {
253             otmp = splitobj(obj, 1L);
254         } else {
255             otmp = obj;
256             if (otmp->owornmask)
257                 remove_worn_item(otmp, FALSE);
258         }
259         freeinv(otmp);
260         throwit(otmp, wep_mask, twoweap);
261     }
262     m_shot.n = m_shot.i = 0;
263     m_shot.o = STRANGE_OBJECT;
264     m_shot.s = FALSE;
265
266     return 1;
267 }
268
269 /* common to dothrow() and dofire() */
270 STATIC_OVL boolean
271 ok_to_throw(shotlimit_p)
272 int *shotlimit_p; /* (see dothrow()) */
273 {
274     /* kludge to work around parse()'s pre-decrement of `multi' */
275     *shotlimit_p = (multi || save_cm) ? multi + 1 : 0;
276     multi = 0; /* reset; it's been used up */
277
278     if (notake(youmonst.data)) {
279 /*JP
280         You("are physically incapable of throwing or shooting anything.");
281 */
282         You("\89½\82©\82ð\93\8a\82°\82é\82Ì\82Í\95¨\97\9d\93I\82É\96³\97\9d\82¾\81D");
283         return FALSE;
284     } else if (nohands(youmonst.data)) {
285 #if 0 /*JP*/
286         You_cant("throw or shoot without hands."); /* not body_part(HAND) */
287 #else
288         You("\8eè\82ª\82È\82¢\81D"); /* not body_part(HAND) */
289 #endif
290         return FALSE;
291         /*[what about !freehand(), aside from cursed missile launcher?]*/
292     }
293     if (check_capacity((char *) 0))
294         return FALSE;
295     return TRUE;
296 }
297
298 /* t command - throw */
299 int
300 dothrow()
301 {
302     register struct obj *obj;
303     int shotlimit;
304
305     /*
306      * Since some characters shoot multiple missiles at one time,
307      * allow user to specify a count prefix for 'f' or 't' to limit
308      * number of items thrown (to avoid possibly hitting something
309      * behind target after killing it, or perhaps to conserve ammo).
310      *
311      * Prior to 3.3.0, command ``3t'' meant ``t(shoot) t(shoot) t(shoot)''
312      * and took 3 turns.  Now it means ``t(shoot at most 3 missiles)''.
313      *
314      * [3.6.0:  shot count setup has been moved into ok_to_throw().]
315      */
316     if (!ok_to_throw(&shotlimit))
317         return 0;
318
319     obj = getobj(uslinging() ? bullets : toss_objs, "throw");
320     /* it is also possible to throw food */
321     /* (or jewels, or iron balls... ) */
322
323     return obj ? throw_obj(obj, shotlimit) : 0;
324 }
325
326 /* KMH -- Automatically fill quiver */
327 /* Suggested by Jeffrey Bay <jbay@convex.hp.com> */
328 static void
329 autoquiver()
330 {
331     struct obj *otmp, *oammo = 0, *omissile = 0, *omisc = 0, *altammo = 0;
332
333     if (uquiver)
334         return;
335
336     /* Scan through the inventory */
337     for (otmp = invent; otmp; otmp = otmp->nobj) {
338         if (otmp->owornmask || otmp->oartifact || !otmp->dknown) {
339             ; /* Skip it */
340         } else if (otmp->otyp == ROCK
341                    /* seen rocks or known flint or known glass */
342                    || (otmp->otyp == FLINT
343                        && objects[otmp->otyp].oc_name_known)
344                    || (otmp->oclass == GEM_CLASS
345                        && objects[otmp->otyp].oc_material == GLASS
346                        && objects[otmp->otyp].oc_name_known)) {
347             if (uslinging())
348                 oammo = otmp;
349             else if (ammo_and_launcher(otmp, uswapwep))
350                 altammo = otmp;
351             else if (!omisc)
352                 omisc = otmp;
353         } else if (otmp->oclass == GEM_CLASS) {
354             ; /* skip non-rock gems--they're ammo but
355                  player has to select them explicitly */
356         } else if (is_ammo(otmp)) {
357             if (ammo_and_launcher(otmp, uwep))
358                 /* Ammo matched with launcher (bow+arrow, crossbow+bolt) */
359                 oammo = otmp;
360             else if (ammo_and_launcher(otmp, uswapwep))
361                 altammo = otmp;
362             else
363                 /* Mismatched ammo (no better than an ordinary weapon) */
364                 omisc = otmp;
365         } else if (is_missile(otmp)) {
366             /* Missile (dart, shuriken, etc.) */
367             omissile = otmp;
368         } else if (otmp->oclass == WEAPON_CLASS && throwing_weapon(otmp)) {
369             /* Ordinary weapon */
370             if (objects[otmp->otyp].oc_skill == P_DAGGER && !omissile)
371                 omissile = otmp;
372             else
373                 omisc = otmp;
374         }
375     }
376
377     /* Pick the best choice */
378     if (oammo)
379         setuqwep(oammo);
380     else if (omissile)
381         setuqwep(omissile);
382     else if (altammo)
383         setuqwep(altammo);
384     else if (omisc)
385         setuqwep(omisc);
386
387     return;
388 }
389
390 /* f command -- fire: throw from the quiver */
391 int
392 dofire()
393 {
394     int shotlimit;
395     struct obj *obj;
396
397     /*
398      * Same as dothrow(), except we use quivered missile instead
399      * of asking what to throw/shoot.
400      *
401      * If quiver is empty, we use autoquiver to fill it when the
402      * corresponding option is on.  If the option is off or if
403      * autoquiver doesn't select anything, we ask what to throw.
404      * Then we put the chosen item into the quiver slot unless
405      * it is already in another slot.  [Matters most if it is a
406      * stack but also matters for single item if this throw gets
407      * aborted (ESC at the direction prompt).  Already wielded
408      * item is excluded because wielding might be necessary
409      * (Mjollnir) or make the throw behave differently (aklys),
410      * and alt-wielded item is excluded because switching slots
411      * would end two-weapon combat even if throw gets aborted.]
412      */
413     if (!ok_to_throw(&shotlimit))
414         return 0;
415
416     if ((obj = uquiver) == 0) {
417         if (!flags.autoquiver) {
418 /*JP
419             You("have no ammunition readied.");
420 */
421             You("\94­\8eË\8f\80\94õ\82ª\90®\82Á\82Ä\82¢\82È\82¢\81I");
422         } else {
423             autoquiver();
424             if ((obj = uquiver) == 0)
425 /*JP
426                 You("have nothing appropriate for your quiver.");
427 */
428                 You("\94­\8eË\82·\82é\82à\82Ì\82ª\82È\82¢\81D");
429         }
430         /* if autoquiver is disabled or has failed, prompt for missile;
431            fill quiver with it if it's not wielded */
432         if (!obj) {
433             obj = getobj(uslinging() ? bullets : toss_objs, "throw");
434             /* Q command doesn't allow gold in quiver */
435             if (obj && !obj->owornmask && obj->oclass != COIN_CLASS)
436                 setuqwep(obj); /* demi-autoquiver */
437         }
438         /* give feedback if quiver has now been filled */
439         if (uquiver) {
440             uquiver->owornmask &= ~W_QUIVER; /* less verbose */
441 /*JP
442             prinv("You ready:", uquiver, 0L);
443 */
444             prinv("\8f\80\94õ\81F", uquiver, 0L);
445             uquiver->owornmask |= W_QUIVER;
446         }
447     }
448
449     return obj ? throw_obj(obj, shotlimit) : 0;
450 }
451
452 /* if in midst of multishot shooting/throwing, stop early */
453 void
454 endmultishot(verbose)
455 boolean verbose;
456 {
457     if (m_shot.i < m_shot.n) {
458         if (verbose && !context.mon_moving) {
459 #if 0 /*JP*/
460             You("stop %s after the %d%s %s.",
461                 m_shot.s ? "firing" : "throwing", m_shot.i, ordin(m_shot.i),
462                 m_shot.s ? "shot" : "toss");
463 #else
464             You("%d\94­\96Ú\82ð%s\82Æ\82±\82ë\82Å\8ec\82è\82ð%s\82Ì\82ð\82â\82ß\82½\81D", m_shot.i,
465                 m_shot.s ? "\8c\82\82Á\82½" : "\93\8a\82°\82½",
466                 m_shot.s ? "\8c\82\82Â" : "\93\8a\82°\82é");
467 #endif
468         }
469         m_shot.n = m_shot.i; /* make current shot be the last */
470     }
471 }
472
473 /*
474  * Object hits floor at hero's feet.  Called from drop() and throwit().
475  */
476 void
477 hitfloor(obj)
478 register struct obj *obj;
479 {
480     if (IS_SOFT(levl[u.ux][u.uy].typ) || u.uinwater) {
481         dropy(obj);
482         return;
483     }
484     if (IS_ALTAR(levl[u.ux][u.uy].typ))
485         doaltarobj(obj);
486     else
487 #if 0 /*JP*/
488         pline("%s hit%s the %s.", Doname2(obj), (obj->quan == 1L) ? "s" : "",
489               surface(u.ux, u.uy));
490 #else
491         pline("%s\82Í%s\82É\96½\92\86\82µ\82½\81D", Doname2(obj),
492               surface(u.ux,u.uy));
493 #endif
494
495     if (hero_breaks(obj, u.ux, u.uy, TRUE))
496         return;
497     if (ship_object(obj, u.ux, u.uy, FALSE))
498         return;
499     dropz(obj, TRUE);
500 }
501
502 /*
503  * Walk a path from src_cc to dest_cc, calling a proc for each location
504  * except the starting one.  If the proc returns FALSE, stop walking
505  * and return FALSE.  If stopped early, dest_cc will be the location
506  * before the failed callback.
507  */
508 boolean
509 walk_path(src_cc, dest_cc, check_proc, arg)
510 coord *src_cc;
511 coord *dest_cc;
512 boolean FDECL((*check_proc), (genericptr_t, int, int));
513 genericptr_t arg;
514 {
515     int x, y, dx, dy, x_change, y_change, err, i, prev_x, prev_y;
516     boolean keep_going = TRUE;
517
518     /* Use Bresenham's Line Algorithm to walk from src to dest.
519      *
520      * This should be replaced with a more versatile algorithm
521      * since it handles slanted moves in a suboptimal way.
522      * Going from 'x' to 'y' needs to pass through 'z', and will
523      * fail if there's an obstable there, but it could choose to
524      * pass through 'Z' instead if that way imposes no obstacle.
525      *     ..y          .Zy
526      *     xz.    vs    x..
527      * Perhaps we should check both paths and accept whichever
528      * one isn't blocked.  But then multiple zigs and zags could
529      * potentially produce a meandering path rather than the best
530      * attempt at a straight line.  And (*check_proc)() would
531      * need to work more like 'travel', distinguishing between
532      * testing a possible move and actually attempting that move.
533      */
534     dx = dest_cc->x - src_cc->x;
535     dy = dest_cc->y - src_cc->y;
536     prev_x = x = src_cc->x;
537     prev_y = y = src_cc->y;
538
539     if (dx < 0) {
540         x_change = -1;
541         dx = -dx;
542     } else
543         x_change = 1;
544     if (dy < 0) {
545         y_change = -1;
546         dy = -dy;
547     } else
548         y_change = 1;
549
550     i = err = 0;
551     if (dx < dy) {
552         while (i++ < dy) {
553             prev_x = x;
554             prev_y = y;
555             y += y_change;
556             err += dx << 1;
557             if (err > dy) {
558                 x += x_change;
559                 err -= dy << 1;
560             }
561             /* check for early exit condition */
562             if (!(keep_going = (*check_proc)(arg, x, y)))
563                 break;
564         }
565     } else {
566         while (i++ < dx) {
567             prev_x = x;
568             prev_y = y;
569             x += x_change;
570             err += dy << 1;
571             if (err > dx) {
572                 y += y_change;
573                 err -= dx << 1;
574             }
575             /* check for early exit condition */
576             if (!(keep_going = (*check_proc)(arg, x, y)))
577                 break;
578         }
579     }
580
581     if (keep_going)
582         return TRUE; /* successful */
583
584     dest_cc->x = prev_x;
585     dest_cc->y = prev_y;
586     return FALSE;
587 }
588
589 /* hack for hurtle_step() -- it ought to be changed to take an argument
590    indicating lev/fly-to-dest vs lev/fly-to-dest-minus-one-land-on-dest
591    vs drag-to-dest; original callers use first mode, jumping wants second,
592    grappling hook backfire and thrown chained ball need third */
593 boolean
594 hurtle_jump(arg, x, y)
595 genericptr_t arg;
596 int x, y;
597 {
598     boolean res;
599     long save_EWwalking = EWwalking;
600
601     /* prevent jumping over water from being placed in that water */
602     EWwalking |= I_SPECIAL;
603     res = hurtle_step(arg, x, y);
604     EWwalking = save_EWwalking;
605     return res;
606 }
607
608 /*
609  * Single step for the hero flying through the air from jumping, flying,
610  * etc.  Called from hurtle() and jump() via walk_path().  We expect the
611  * argument to be a pointer to an integer -- the range -- which is
612  * used in the calculation of points off if we hit something.
613  *
614  * Bumping into monsters won't cause damage but will wake them and make
615  * them angry.  Auto-pickup isn't done, since you don't have control over
616  * your movements at the time.
617  *
618  * Possible additions/changes:
619  *      o really attack monster if we hit one
620  *      o set stunned if we hit a wall or door
621  *      o reset nomul when we stop
622  *      o creepy feeling if pass through monster (if ever implemented...)
623  *      o bounce off walls
624  *      o let jumps go over boulders
625  */
626 boolean
627 hurtle_step(arg, x, y)
628 genericptr_t arg;
629 int x, y;
630 {
631     int ox, oy, *range = (int *) arg;
632     struct obj *obj;
633     struct monst *mon;
634     boolean may_pass = TRUE;
635     struct trap *ttmp;
636     int dmg = 0;
637
638     if (!isok(x, y)) {
639 /*JP
640         You_feel("the spirits holding you back.");
641 */
642         You_feel("\82 \82È\82½\82ð\95ß\82Ü\82¦\82Ä\82¢\82½\8d°\82ª\96ß\82Á\82½\8bC\82ª\82µ\82½\81D");
643         return FALSE;
644     } else if (!in_out_region(x, y)) {
645         return FALSE;
646     } else if (*range == 0) {
647         return FALSE; /* previous step wants to stop now */
648     }
649
650     if (!Passes_walls || !(may_pass = may_passwall(x, y))) {
651         boolean odoor_diag = (IS_DOOR(levl[x][y].typ)
652                               && (levl[x][y].doormask & D_ISOPEN)
653                               && (u.ux - x) && (u.uy - y));
654
655         if (IS_ROCK(levl[x][y].typ) || closed_door(x, y) || odoor_diag) {
656             const char *s;
657
658             if (odoor_diag)
659 /*JP
660                 You("hit the door edge!");
661 */
662                 You("\94à\82Ì\92[\82É\93\96\82½\82Á\82½\81I");
663 /*JP
664             pline("Ouch!");
665 */
666             pline("\82¢\82Ä\82Á\81I");
667             if (IS_TREE(levl[x][y].typ))
668 /*JP
669                 s = "bumping into a tree";
670 */
671                 s = "\96Ø\82É\82Ô\82¿\82 \82½\82Á\82Ä";
672             else if (IS_ROCK(levl[x][y].typ))
673 /*JP
674                 s = "bumping into a wall";
675 */
676                 s = "\95Ç\82É\82Ô\82¿\82 \82½\82Á\82Ä";
677             else
678 /*JP
679                 s = "bumping into a door";
680 */
681                 s = "\94à\82É\82Ô\82¿\82 \82½\82Á\82Ä";
682             dmg = rnd(2 + *range);
683             losehp(Maybe_Half_Phys(dmg), s, KILLED_BY);
684             wake_nearto(x,y, 10);
685             return FALSE;
686         }
687         if (levl[x][y].typ == IRONBARS) {
688 /*JP
689             You("crash into some iron bars.  Ouch!");
690 */
691             You("\93S\82Ì\96_\82É\82Ô\82¿\82 \82½\82Á\82½\81D\82¢\82Ä\82Á\81I");
692             dmg = rnd(2 + *range);
693 #if 0 /*JP*/
694             losehp(Maybe_Half_Phys(dmg), "crashing into iron bars",
695                    KILLED_BY);
696 #else
697             losehp(Maybe_Half_Phys(dmg), "\93S\82Ì\96_\82É\82Ô\82¿\82 \82½\82Á\82Ä",
698                    KILLED_BY);
699 #endif
700             wake_nearto(x,y, 20);
701             return FALSE;
702         }
703         if ((obj = sobj_at(BOULDER, x, y)) != 0) {
704 /*JP
705             You("bump into a %s.  Ouch!", xname(obj));
706 */
707             You("%s\82É\82Ô\82¿\82 \82½\82Á\82½\81D\82¢\82Ä\82Á\81I", xname(obj));
708             dmg = rnd(2 + *range);
709 /*JP
710             losehp(Maybe_Half_Phys(dmg), "bumping into a boulder", KILLED_BY);
711 */
712             losehp(Maybe_Half_Phys(dmg), "\8aâ\82É\82Ô\82¿\82 \82½\82Á\82Ä", KILLED_BY);
713             wake_nearto(x,y, 10);
714             return FALSE;
715         }
716         if (!may_pass) {
717             /* did we hit a no-dig non-wall position? */
718 /*JP
719             You("smack into something!");
720 */
721             You("\89½\82©\82É\82Ô\82¿\82 \82½\82Á\82½\81I");
722             dmg = rnd(2 + *range);
723 #if 0 /*JP*/
724             losehp(Maybe_Half_Phys(dmg), "touching the edge of the universe",
725                    KILLED_BY);
726 #else
727             losehp(Maybe_Half_Phys(dmg), "\90¢\8aE\82Ì\89Ê\82Ä\82É\90G\82ê\82Ä",
728                    KILLED_BY);
729 #endif
730             wake_nearto(x,y, 10);
731             return FALSE;
732         }
733         if ((u.ux - x) && (u.uy - y) && bad_rock(youmonst.data, u.ux, y)
734             && bad_rock(youmonst.data, x, u.uy)) {
735             boolean too_much = (invent && (inv_weight() + weight_cap() > 600));
736
737             /* Move at a diagonal. */
738             if (bigmonst(youmonst.data) || too_much) {
739 #if 0 /*JP*/
740                 You("%sget forcefully wedged into a crevice.",
741                     too_much ? "and all your belongings " : "");
742 #else
743                 You("%s\82Í\82Þ\82è\82â\82è\82·\82«\8aÔ\82É\89\9f\82µ\8d\9e\82ß\82ç\82ê\82½\81D",
744                     too_much ? "\82Æ\91S\95\94\82Ì\89×\95¨" : "");
745 #endif
746                 dmg = rnd(2 + *range);
747 #if 0 /*JP*/
748                 losehp(Maybe_Half_Phys(dmg), "wedging into a narrow crevice",
749                        KILLED_BY);
750 #else
751                 losehp(Maybe_Half_Phys(dmg), "\8b·\82¢\82·\82«\8aÔ\82É\89\9f\82µ\8d\9e\82ß\82ç\82ê\82Ä",
752                        KILLED_BY);
753 #endif
754                 wake_nearto(x,y, 10);
755                 return FALSE;
756             }
757         }
758     }
759
760     if ((mon = m_at(x, y)) != 0
761 #if 0   /* we can't include these two exceptions unless we know we're
762          * going to end up past the current spot rather than on it;
763          * for that, we need to know that the range is not exhausted
764          * and also that the next spot doesn't contain an obstacle */
765         && !(mon->mundetected && hides_under(mon) && (Flying || Levitation))
766         && !(mon->mundetected && mon->data->mlet == S_EEL
767              && (Flying || Levitation || Wwalking))
768 #endif
769         ) {
770         const char *mnam, *pronoun;
771         int glyph = glyph_at(x, y);
772
773         mon->mundetected = 0; /* wakeup() will handle mimic */
774         mnam = a_monnam(mon); /* after unhiding */
775         pronoun = mhim(mon);
776 #if 0 /*JP*/
777         if (!strcmp(mnam, "it")) {
778 #else
779         if (!strcmp(mnam, "\89½\8eÒ\82©")) {
780 #endif
781             /* mhim() uses pronoun_gender() which forces neuter if monster
782                can't be seen; we want him/her for humanoid sensed by touch */
783 #if 0 /*JP*/
784             if (!strcmp(pronoun, "it") && humanoid(mon->data))
785 #else
786             if (!strcmp(pronoun, "\89½\8eÒ\82©") && humanoid(mon->data))
787 #endif
788                 pronoun = genders[mon->female].him;
789 #if 0 /*JP*/
790             mnam = !strcmp(pronoun, "it") ? "something" : "someone";
791 #else
792             mnam = !strcmp(pronoun, "\89½\8eÒ\82©") ? "\89½\82©" : "\89½\8eÒ\82©";
793 #endif
794         }
795         if (!glyph_is_monster(glyph) && !glyph_is_invisible(glyph))
796 #if 0 /*JP*/
797             You("find %s by bumping into %s.", mnam, pronoun);
798 #else
799             You("\82Ô\82¿\82 \82½\82Á\82½\82±\82Æ\82Å%s\82ð\8c©\82Â\82¯\82½\81D", mnam);
800 #endif
801         else
802 /*JP
803             You("bump into %s.", mnam);
804 */
805             You("%s\82É\82Ô\82¿\82 \82½\82Á\82½\81D", mnam);
806         wakeup(mon, FALSE);
807         if (!canspotmon(mon))
808             map_invisible(mon->mx, mon->my);
809         setmangry(mon, FALSE);
810         wake_nearto(x, y, 10);
811         return FALSE;
812     }
813
814     if ((u.ux - x) && (u.uy - y)
815         && bad_rock(youmonst.data, u.ux, y)
816         && bad_rock(youmonst.data, x, u.uy)) {
817         /* Move at a diagonal. */
818         if (Sokoban) {
819 /*JP
820             You("come to an abrupt halt!");
821 */
822             You("\82Æ\82Â\82º\82ñ\92â\8e~\82µ\82½\81I");
823             return FALSE;
824         }
825     }
826
827     /* Caller has already determined that dragging the ball is allowed */
828     if (Punished && uball->where == OBJ_FLOOR) {
829         int bc_control;
830         xchar ballx, bally, chainx, chainy;
831         boolean cause_delay;
832
833         if (drag_ball(x, y, &bc_control, &ballx, &bally, &chainx,
834                       &chainy, &cause_delay, TRUE))
835             move_bc(0, bc_control, ballx, bally, chainx, chainy);
836     }
837
838     ox = u.ux;
839     oy = u.uy;
840     u_on_newpos(x, y); /* set u.<ux,uy>, u.usteed-><mx,my>; cliparound(); */
841     newsym(ox, oy);    /* update old position */
842     vision_recalc(1);  /* update for new position */
843     flush_screen(1);
844
845     if (is_pool(x, y) && !u.uinwater
846         && ((Is_waterlevel(&u.uz) && levl[x][y].typ == WATER)
847             || !(Levitation || Flying || Wwalking))) {
848         multi = 0; /* can move, so drown() allows crawling out of water */
849         (void) drown();
850         return FALSE;
851     }
852
853     /* FIXME:
854      * Each trap should really trigger on the recoil if
855      * it would trigger during normal movement. However,
856      * not all the possible side-effects of this are
857      * tested [as of 3.4.0] so we trigger those that
858      * we have tested, and offer a message for the
859      * ones that we have not yet tested.
860      */
861     if ((ttmp = t_at(x, y)) != 0) {
862         if (ttmp->ttyp == MAGIC_PORTAL) {
863             dotrap(ttmp, 0);
864             return FALSE;
865         } else if (ttmp->ttyp == VIBRATING_SQUARE) {
866 /*JP
867             pline("The ground vibrates as you pass it.");
868 */
869             pline("\82 \82È\82½\82ª\92Ê\89ß\82·\82é\82Æ\92n\96Ê\82ª\90k\93®\82µ\82½\81D");
870             dotrap(ttmp, 0); /* doesn't print messages */
871         } else if (ttmp->ttyp == FIRE_TRAP) {
872             dotrap(ttmp, 0);
873         } else if ((ttmp->ttyp == PIT || ttmp->ttyp == SPIKED_PIT
874                     || ttmp->ttyp == HOLE || ttmp->ttyp == TRAPDOOR)
875                    && Sokoban) {
876             /* Air currents overcome the recoil */
877             dotrap(ttmp, 0);
878             *range = 0;
879             return TRUE;
880         } else {
881             if (ttmp->tseen)
882 #if 0 /*JP*/
883                 You("pass right over %s.",
884                     an(defsyms[trap_to_defsym(ttmp->ttyp)].explanation));
885 #else
886                 You("%s\82Ì\90^\8fã\82ð\92Ê\89ß\82µ\82½\81D",
887                     defsyms[trap_to_defsym(ttmp->ttyp)].explanation);
888 #endif
889         }
890     }
891     if (--*range < 0) /* make sure our range never goes negative */
892         *range = 0;
893     if (*range != 0)
894         delay_output();
895     return TRUE;
896 }
897
898 STATIC_OVL boolean
899 mhurtle_step(arg, x, y)
900 genericptr_t arg;
901 int x, y;
902 {
903     struct monst *mon = (struct monst *) arg;
904
905     /* TODO: Treat walls, doors, iron bars, pools, lava, etc. specially
906      * rather than just stopping before.
907      */
908     if (goodpos(x, y, mon, 0) && m_in_out_region(mon, x, y)) {
909         remove_monster(mon->mx, mon->my);
910         newsym(mon->mx, mon->my);
911         place_monster(mon, x, y);
912         newsym(mon->mx, mon->my);
913         set_apparxy(mon);
914         (void) mintrap(mon);
915         return TRUE;
916     }
917     return FALSE;
918 }
919
920 /*
921  * The player moves through the air for a few squares as a result of
922  * throwing or kicking something.
923  *
924  * dx and dy should be the direction of the hurtle, not of the original
925  * kick or throw and be only.
926  */
927 void
928 hurtle(dx, dy, range, verbose)
929 int dx, dy, range;
930 boolean verbose;
931 {
932     coord uc, cc;
933
934     /* The chain is stretched vertically, so you shouldn't be able to move
935      * very far diagonally.  The premise that you should be able to move one
936      * spot leads to calculations that allow you to only move one spot away
937      * from the ball, if you are levitating over the ball, or one spot
938      * towards the ball, if you are at the end of the chain.  Rather than
939      * bother with all of that, assume that there is no slack in the chain
940      * for diagonal movement, give the player a message and return.
941      */
942     if (Punished && !carried(uball)) {
943 /*JP
944         You_feel("a tug from the iron ball.");
945 */
946         You_feel("\93S\8b\85\82É\82Ð\82Á\82Ï\82ç\82ê\82Ä\82¢\82é\82æ\82¤\82È\8bC\82ª\82µ\82½\81D");
947         nomul(0);
948         return;
949     } else if (u.utrap) {
950 #if 0 /*JP*/
951         You("are anchored by the %s.",
952             u.utraptype == TT_WEB
953                 ? "web"
954                 : u.utraptype == TT_LAVA
955                       ? hliquid("lava")
956                       : u.utraptype == TT_INFLOOR
957                             ? surface(u.ux, u.uy)
958                             : u.utraptype == TT_BURIEDBALL ? "buried ball"
959                                                            : "trap");
960 #else
961         You("%s\82É\90\98\82¦\82Â\82¯\82ç\82ê\82Ä\82¢\82é\81D",
962             u.utraptype == TT_WEB
963                 ? "\82­\82à\82Ì\91\83"
964                 : u.utraptype == TT_LAVA
965                       ? "\97n\8aâ"
966                       : u.utraptype == TT_INFLOOR
967                             ? surface(u.ux,u.uy)
968                             : u.utraptype == TT_BURIEDBALL ? "\96\84\82Ü\82Á\82Ä\82¢\82é\8b\85"
969                                                            : "ã©");
970 #endif
971         nomul(0);
972         return;
973     }
974
975     /* make sure dx and dy are [-1,0,1] */
976     dx = sgn(dx);
977     dy = sgn(dy);
978
979     if (!range || (!dx && !dy) || u.ustuck)
980         return; /* paranoia */
981
982     nomul(-range);
983 /*JP
984     multi_reason = "moving through the air";
985 */
986     multi_reason = "\8bó\92\86\82ð\88Ú\93®\82µ\82Ä\82¢\82é\8e\9e\82É";
987     nomovemsg = ""; /* it just happens */
988     if (verbose)
989 /*JP
990         You("%s in the opposite direction.", range > 1 ? "hurtle" : "float");
991 */
992         You("\8bt\95û\8cü\82É\94ò\82Î\82³\82ê\82½\81D");
993     /* if we're in the midst of shooting multiple projectiles, stop */
994     endmultishot(TRUE);
995     sokoban_guilt();
996     uc.x = u.ux;
997     uc.y = u.uy;
998     /* this setting of cc is only correct if dx and dy are [-1,0,1] only */
999     cc.x = u.ux + (dx * range);
1000     cc.y = u.uy + (dy * range);
1001     (void) walk_path(&uc, &cc, hurtle_step, (genericptr_t) &range);
1002 }
1003
1004 /* Move a monster through the air for a few squares. */
1005 void
1006 mhurtle(mon, dx, dy, range)
1007 struct monst *mon;
1008 int dx, dy, range;
1009 {
1010     coord mc, cc;
1011
1012     /* At the very least, debilitate the monster */
1013     mon->movement = 0;
1014     mon->mstun = 1;
1015
1016     /* Is the monster stuck or too heavy to push?
1017      * (very large monsters have too much inertia, even floaters and flyers)
1018      */
1019     if (mon->data->msize >= MZ_HUGE || mon == u.ustuck || mon->mtrapped)
1020         return;
1021
1022     /* Make sure dx and dy are [-1,0,1] */
1023     dx = sgn(dx);
1024     dy = sgn(dy);
1025     if (!range || (!dx && !dy))
1026         return; /* paranoia */
1027     /* don't let grid bugs be hurtled diagonally */
1028     if (dx && dy && NODIAG(monsndx(mon->data)))
1029         return;
1030
1031     /* Send the monster along the path */
1032     mc.x = mon->mx;
1033     mc.y = mon->my;
1034     cc.x = mon->mx + (dx * range);
1035     cc.y = mon->my + (dy * range);
1036     (void) walk_path(&mc, &cc, mhurtle_step, (genericptr_t) mon);
1037     return;
1038 }
1039
1040 STATIC_OVL void
1041 check_shop_obj(obj, x, y, broken)
1042 struct obj *obj;
1043 xchar x, y;
1044 boolean broken;
1045 {
1046     struct monst *shkp = shop_keeper(*u.ushops);
1047
1048     if (!shkp)
1049         return;
1050
1051     if (broken || !costly_spot(x, y)
1052         || *in_rooms(x, y, SHOPBASE) != *u.ushops) {
1053         /* thrown out of a shop or into a different shop */
1054         if (is_unpaid(obj))
1055             (void) stolen_value(obj, u.ux, u.uy, (boolean) shkp->mpeaceful,
1056                                 FALSE);
1057         if (broken)
1058             obj->no_charge = 1;
1059     } else {
1060         if (costly_spot(u.ux, u.uy) && costly_spot(x, y)) {
1061             if (is_unpaid(obj))
1062                 subfrombill(obj, shkp);
1063             else if (x != shkp->mx || y != shkp->my)
1064                 sellobj(obj, x, y);
1065         }
1066     }
1067 }
1068
1069 /*
1070  * Hero tosses an object upwards with appropriate consequences.
1071  *
1072  * Returns FALSE if the object is gone.
1073  */
1074 STATIC_OVL boolean
1075 toss_up(obj, hitsroof)
1076 struct obj *obj;
1077 boolean hitsroof;
1078 {
1079     const char *action;
1080     boolean petrifier = ((obj->otyp == EGG || obj->otyp == CORPSE)
1081                          && touch_petrifies(&mons[obj->corpsenm]));
1082     /* note: obj->quan == 1 */
1083
1084     if (!has_ceiling(&u.uz)) {
1085 #if 0 /*JP*/
1086         action = "flies up into"; /* into "the sky" or "the water above" */
1087 #else
1088         action = "\82Ì\92\86\82ð\94ò\82ñ\82¾"; /* into "the sky" or "the water above" */
1089 #endif
1090     } else if (hitsroof) {
1091         if (breaktest(obj)) {
1092 /*JP
1093             pline("%s hits the %s.", Doname2(obj), ceiling(u.ux, u.uy));
1094 */
1095             pline("%s\82Í%s\82É\96½\92\86\82µ\82½\81D", Doname2(obj), ceiling(u.ux, u.uy));
1096             breakmsg(obj, !Blind);
1097             breakobj(obj, u.ux, u.uy, TRUE, TRUE);
1098             return FALSE;
1099         }
1100 /*JP
1101         action = "hits";
1102 */
1103         action = "\82É\96½\92\86\82µ\82½";
1104     } else {
1105 /*JP
1106         action = "almost hits";
1107 */
1108         action = "\82É\82à\82¤\8f­\82µ\82Å\96½\92\86\82·\82é\82Æ\82±\82ë\82¾\82Á\82½";
1109     }
1110 #if 0 /*JP*/
1111     pline("%s %s the %s, then falls back on top of your %s.", Doname2(obj),
1112           action, ceiling(u.ux, u.uy), body_part(HEAD));
1113 #else
1114     pline("%s\82Í%s%s\81C\82»\82µ\82Ä%s\82Ì\8fã\82É\97\8e\82¿\82Ä\82«\82½\81D", Doname2(obj),
1115           ceiling(u.ux, u.uy), action, body_part(HEAD));
1116 #endif
1117
1118     /* object now hits you */
1119
1120     if (obj->oclass == POTION_CLASS) {
1121         potionhit(&youmonst, obj, POTHIT_HERO_THROW);
1122     } else if (breaktest(obj)) {
1123         int otyp = obj->otyp;
1124         int blindinc;
1125
1126         /* need to check for blindness result prior to destroying obj */
1127         blindinc = ((otyp == CREAM_PIE || otyp == BLINDING_VENOM)
1128                     /* AT_WEAP is ok here even if attack type was AT_SPIT */
1129                     && can_blnd(&youmonst, &youmonst, AT_WEAP, obj))
1130                        ? rnd(25)
1131                        : 0;
1132         breakmsg(obj, !Blind);
1133         breakobj(obj, u.ux, u.uy, TRUE, TRUE);
1134         obj = 0; /* it's now gone */
1135         switch (otyp) {
1136         case EGG:
1137             if (petrifier && !Stone_resistance
1138                 && !(poly_when_stoned(youmonst.data)
1139                      && polymon(PM_STONE_GOLEM))) {
1140                 /* egg ends up "all over your face"; perhaps
1141                    visored helmet should still save you here */
1142                 if (uarmh)
1143 /*JP
1144                     Your("%s fails to protect you.", helm_simple_name(uarmh));
1145 */
1146                     Your("%s\82Í\82 \82È\82½\82ð\8eç\82ê\82È\82©\82Á\82½\81D", helm_simple_name(uarmh));
1147                 goto petrify;
1148             }
1149             /*FALLTHRU*/
1150         case CREAM_PIE:
1151         case BLINDING_VENOM:
1152 /*JP
1153             pline("You've got it all over your %s!", body_part(FACE));
1154 */
1155             pline("\82»\82ê\82Í%s\82ð\82×\82Á\82Æ\82è\82Æ\95¢\82Á\82½\81I", body_part(FACE));
1156             if (blindinc) {
1157                 if (otyp == BLINDING_VENOM && !Blind)
1158 /*JP
1159                     pline("It blinds you!");
1160 */
1161                     pline("\96Ú\82ª\8c©\82¦\82È\82­\82È\82Á\82½\81I");
1162                 u.ucreamed += blindinc;
1163                 make_blinded(Blinded + (long) blindinc, FALSE);
1164                 if (!Blind)
1165                     Your1(vision_clears);
1166             }
1167             break;
1168         default:
1169             break;
1170         }
1171         return FALSE;
1172     } else { /* neither potion nor other breaking object */
1173         boolean less_damage = uarmh && is_metallic(uarmh), artimsg = FALSE;
1174         int dmg = dmgval(obj, &youmonst);
1175
1176         if (obj->oartifact)
1177             /* need a fake die roll here; rn1(18,2) avoids 1 and 20 */
1178             artimsg = artifact_hit((struct monst *) 0, &youmonst, obj, &dmg,
1179                                    rn1(18, 2));
1180
1181         if (!dmg) { /* probably wasn't a weapon; base damage on weight */
1182             dmg = (int) obj->owt / 100;
1183             if (dmg < 1)
1184                 dmg = 1;
1185             else if (dmg > 6)
1186                 dmg = 6;
1187             if (youmonst.data == &mons[PM_SHADE]
1188                 && objects[obj->otyp].oc_material != SILVER)
1189                 dmg = 0;
1190         }
1191         if (dmg > 1 && less_damage)
1192             dmg = 1;
1193         if (dmg > 0)
1194             dmg += u.udaminc;
1195         if (dmg < 0)
1196             dmg = 0; /* beware negative rings of increase damage */
1197         dmg = Maybe_Half_Phys(dmg);
1198
1199         if (uarmh) {
1200             if (less_damage && dmg < (Upolyd ? u.mh : u.uhp)) {
1201                 if (!artimsg)
1202 /*JP
1203                     pline("Fortunately, you are wearing a hard helmet.");
1204 */
1205                     pline("\8dK\89^\82É\82à\81C\82 \82È\82½\82Í\8cÅ\82¢\8a\95\82ð\90g\82É\82Â\82¯\82Ä\82¢\82½\81D");
1206                 /* helmet definitely protects you when it blocks petrification
1207                  */
1208             } else if (!petrifier) {
1209                 if (flags.verbose)
1210 /*JP
1211                     Your("%s does not protect you.", helm_simple_name(uarmh));
1212 */
1213                     Your("%s\82Å\82Í\96h\82¬\82«\82ê\82È\82©\82Á\82½\81D", helm_simple_name(uarmh));
1214             }
1215         } else if (petrifier && !Stone_resistance
1216                    && !(poly_when_stoned(youmonst.data)
1217                         && polymon(PM_STONE_GOLEM))) {
1218         petrify:
1219             killer.format = KILLED_BY;
1220 #if 0 /*JP*/
1221             Strcpy(killer.name, "elementary physics"); /* "what goes up..." */
1222 #else
1223             Strcpy(killer.name, "\8f\89\93\99\95¨\97\9d\82É\82æ\82è"); /* "what goes up..." */
1224 #endif
1225 /*JP
1226             You("turn to stone.");
1227 */
1228             You("\90Î\82É\82È\82Á\82½\81D");
1229             if (obj)
1230                 dropy(obj); /* bypass most of hitfloor() */
1231             thrownobj = 0;  /* now either gone or on floor */
1232             done(STONING);
1233             return obj ? TRUE : FALSE;
1234         }
1235         hitfloor(obj);
1236         thrownobj = 0;
1237 #if 0 /*JP*/
1238         losehp(Maybe_Half_Phys(dmg), "falling object", KILLED_BY_AN);
1239 #else
1240         losehp(Maybe_Half_Phys(dmg), "\97\8e\89º\95¨\82Å", KILLED_BY_AN);
1241 #endif
1242     }
1243     return TRUE;
1244 }
1245
1246 /* return true for weapon meant to be thrown; excludes ammo */
1247 boolean
1248 throwing_weapon(obj)
1249 struct obj *obj;
1250 {
1251     return (boolean) (is_missile(obj) || is_spear(obj)
1252                       /* daggers and knife (excludes scalpel) */
1253                       || (is_blade(obj) && !is_sword(obj)
1254                           && (objects[obj->otyp].oc_dir & PIERCE))
1255                       /* special cases [might want to add AXE] */
1256                       || obj->otyp == WAR_HAMMER || obj->otyp == AKLYS);
1257 }
1258
1259 /* the currently thrown object is returning to you (not for boomerangs) */
1260 STATIC_OVL void
1261 sho_obj_return_to_u(obj)
1262 struct obj *obj;
1263 {
1264     /* might already be our location (bounced off a wall) */
1265     if ((u.dx || u.dy) && (bhitpos.x != u.ux || bhitpos.y != u.uy)) {
1266         int x = bhitpos.x - u.dx, y = bhitpos.y - u.dy;
1267
1268         tmp_at(DISP_FLASH, obj_to_glyph(obj));
1269         while (isok(x,y) && (x != u.ux || y != u.uy)) {
1270             tmp_at(x, y);
1271             delay_output();
1272             x -= u.dx;
1273             y -= u.dy;
1274         }
1275         tmp_at(DISP_END, 0);
1276     }
1277 }
1278
1279 /* throw an object, NB: obj may be consumed in the process */
1280 void
1281 throwit(obj, wep_mask, twoweap)
1282 struct obj *obj;
1283 long wep_mask; /* used to re-equip returning boomerang */
1284 boolean twoweap; /* used to restore twoweapon mode if wielded weapon returns */
1285 {
1286     register struct monst *mon;
1287     register int range, urange;
1288     boolean crossbowing, impaired = (Confusion || Stunned || Blind
1289                                      || Hallucination || Fumbling);
1290
1291     notonhead = FALSE; /* reset potentially stale value */
1292     if ((obj->cursed || obj->greased) && (u.dx || u.dy) && !rn2(7)) {
1293         boolean slipok = TRUE;
1294
1295         if (ammo_and_launcher(obj, uwep))
1296 /*JP
1297             pline("%s!", Tobjnam(obj, "misfire"));
1298 */
1299             pline("%s\82Í\82Í\82¸\82ê\82½\81I", xname(obj));
1300         else {
1301             /* only slip if it's greased or meant to be thrown */
1302             if (obj->greased || throwing_weapon(obj))
1303                 /* BUG: this message is grammatically incorrect if obj has
1304                    a plural name; greased gloves or boots for instance. */
1305 /*JP
1306                 pline("%s as you throw it!", Tobjnam(obj, "slip"));
1307 */
1308                 pline("%s\82ð\93\8a\82°\82æ\82¤\82Æ\82µ\82½\82ª\81C\82¸\82è\97\8e\82¿\82Ä\82µ\82Ü\82Á\82½\81I", xname(obj));
1309             else
1310                 slipok = FALSE;
1311         }
1312         if (slipok) {
1313             u.dx = rn2(3) - 1;
1314             u.dy = rn2(3) - 1;
1315             if (!u.dx && !u.dy)
1316                 u.dz = 1;
1317             impaired = TRUE;
1318         }
1319     }
1320
1321     if ((u.dx || u.dy || (u.dz < 1))
1322         && calc_capacity((int) obj->owt) > SLT_ENCUMBER
1323         && (Upolyd ? (u.mh < 5 && u.mh != u.mhmax)
1324                    : (u.uhp < 10 && u.uhp != u.uhpmax))
1325         && obj->owt > (unsigned) ((Upolyd ? u.mh : u.uhp) * 2)
1326         && !Is_airlevel(&u.uz)) {
1327 /*JP
1328         You("have so little stamina, %s drops from your grasp.",
1329 */
1330         You("\88¬\97Í\82ª\82È\82­\82È\82Á\82Ä\82¢\82½\82Ì\82Å\81C%s\82ð\88¬\82è\82»\82±\82Ë\82Ä\97\8e\82Æ\82µ\82½\81D",
1331             the(xname(obj)));
1332         exercise(A_CON, FALSE);
1333         u.dx = u.dy = 0;
1334         u.dz = 1;
1335     }
1336
1337     thrownobj = obj;
1338     thrownobj->was_thrown = 1;
1339
1340     if (u.uswallow) {
1341         mon = u.ustuck;
1342         bhitpos.x = mon->mx;
1343         bhitpos.y = mon->my;
1344     } else if (u.dz) {
1345         if (u.dz < 0
1346             /* Mjollnir must we wielded to be thrown--caller verifies this;
1347                aklys must we wielded as primary to return when thrown */
1348             && ((Role_if(PM_VALKYRIE) && obj->oartifact == ART_MJOLLNIR)
1349                 || (obj->otyp == AKLYS && (wep_mask & W_WEP) != 0))
1350             && !impaired) {
1351 #if 0 /*JP*/
1352             pline("%s the %s and returns to your hand!", Tobjnam(obj, "hit"),
1353                   ceiling(u.ux, u.uy));
1354 #else
1355             pline("%s\82Í%s\82É\96½\92\86\82µ\82 \82È\82½\82Ì\8eè\82É\96ß\82Á\82Ä\82«\82½\81I", xname(obj),
1356                   ceiling(u.ux,u.uy));
1357 #endif
1358             obj = addinv(obj);
1359             (void) encumber_msg();
1360             if (obj->owornmask & W_QUIVER) /* in case addinv() autoquivered */
1361                 setuqwep((struct obj *) 0);
1362             setuwep(obj);
1363             u.twoweap = twoweap;
1364         } else if (u.dz < 0) {
1365             (void) toss_up(obj, rn2(5) && !Underwater);
1366         } else if (u.dz > 0 && u.usteed && obj->oclass == POTION_CLASS
1367                    && rn2(6)) {
1368             /* alternative to prayer or wand of opening/spell of knock
1369                for dealing with cursed saddle:  throw holy water > */
1370             potionhit(u.usteed, obj, POTHIT_HERO_THROW);
1371         } else {
1372             hitfloor(obj);
1373         }
1374         thrownobj = (struct obj *) 0;
1375         return;
1376
1377     } else if (obj->otyp == BOOMERANG && !Underwater) {
1378         if (Is_airlevel(&u.uz) || Levitation)
1379             hurtle(-u.dx, -u.dy, 1, TRUE);
1380         mon = boomhit(obj, u.dx, u.dy);
1381         if (mon == &youmonst) { /* the thing was caught */
1382             exercise(A_DEX, TRUE);
1383             obj = addinv(obj);
1384             (void) encumber_msg();
1385             if (wep_mask && !(obj->owornmask & wep_mask)) {
1386                 setworn(obj, wep_mask);
1387                 u.twoweap = twoweap;
1388             }
1389             thrownobj = (struct obj *) 0;
1390             return;
1391         }
1392     } else {
1393         /* crossbow range is independent of strength */
1394         crossbowing =
1395             (ammo_and_launcher(obj, uwep) && weapon_type(uwep) == P_CROSSBOW);
1396         urange = (crossbowing ? 18 : (int) ACURRSTR) / 2;
1397         /* balls are easy to throw or at least roll;
1398          * also, this insures the maximum range of a ball is greater
1399          * than 1, so the effects from throwing attached balls are
1400          * actually possible
1401          */
1402         if (obj->otyp == HEAVY_IRON_BALL)
1403             range = urange - (int) (obj->owt / 100);
1404         else
1405             range = urange - (int) (obj->owt / 40);
1406         if (obj == uball) {
1407             if (u.ustuck)
1408                 range = 1;
1409             else if (range >= 5)
1410                 range = 5;
1411         }
1412         if (range < 1)
1413             range = 1;
1414
1415         if (is_ammo(obj)) {
1416             if (ammo_and_launcher(obj, uwep)) {
1417                 if (crossbowing)
1418                     range = BOLT_LIM;
1419                 else
1420                     range++;
1421             } else if (obj->oclass != GEM_CLASS)
1422                 range /= 2;
1423         }
1424
1425         if (Is_airlevel(&u.uz) || Levitation) {
1426             /* action, reaction... */
1427             urange -= range;
1428             if (urange < 1)
1429                 urange = 1;
1430             range -= urange;
1431             if (range < 1)
1432                 range = 1;
1433         }
1434
1435         if (obj->otyp == BOULDER)
1436             range = 20; /* you must be giant */
1437         else if (obj->oartifact == ART_MJOLLNIR)
1438             range = (range + 1) / 2; /* it's heavy */
1439         else if (obj->otyp == AKLYS && (wep_mask & W_WEP) != 0)
1440             /* if an aklys is going to return, range is limited by the
1441                length of the attached cord [implicit aspect of item] */
1442             range = min(range, BOLT_LIM / 2);
1443         else if (obj == uball && u.utrap && u.utraptype == TT_INFLOOR)
1444             range = 1;
1445
1446         if (Underwater)
1447             range = 1;
1448
1449         mon = bhit(u.dx, u.dy, range, THROWN_WEAPON,
1450                    (int FDECL((*), (MONST_P, OBJ_P))) 0,
1451                    (int FDECL((*), (OBJ_P, OBJ_P))) 0, &obj);
1452         thrownobj = obj; /* obj may be null now */
1453
1454         /* have to do this after bhit() so u.ux & u.uy are correct */
1455         if (Is_airlevel(&u.uz) || Levitation)
1456             hurtle(-u.dx, -u.dy, urange, TRUE);
1457
1458         if (!obj)
1459             return;
1460     }
1461
1462     if (mon) {
1463         boolean obj_gone;
1464
1465         if (mon->isshk && obj->where == OBJ_MINVENT && obj->ocarry == mon) {
1466             thrownobj = (struct obj *) 0;
1467             return; /* alert shk caught it */
1468         }
1469         (void) snuff_candle(obj);
1470         notonhead = (bhitpos.x != mon->mx || bhitpos.y != mon->my);
1471         obj_gone = thitmonst(mon, obj);
1472         /* Monster may have been tamed; this frees old mon */
1473         mon = m_at(bhitpos.x, bhitpos.y);
1474
1475         /* [perhaps this should be moved into thitmonst or hmon] */
1476         if (mon && mon->isshk
1477             && (!inside_shop(u.ux, u.uy)
1478                 || !index(in_rooms(mon->mx, mon->my, SHOPBASE), *u.ushops)))
1479             hot_pursuit(mon);
1480
1481         if (obj_gone)
1482             thrownobj = 0;
1483     }
1484
1485     if (!thrownobj) {
1486         ; /* missile has already been handled */
1487     } else if (u.uswallow) {
1488         /* ball is not picked up by monster */
1489         if (obj != uball)
1490             (void) mpickobj(u.ustuck, obj);
1491         thrownobj = (struct obj *) 0;
1492     } else {
1493         /* Mjollnir must we wielded to be thrown--caller verifies this;
1494            aklys must we wielded as primary to return when thrown */
1495         if ((obj->oartifact == ART_MJOLLNIR && Role_if(PM_VALKYRIE))
1496             || (obj->otyp == AKLYS && (wep_mask & W_WEP) != 0)) {
1497             if (rn2(100)) {
1498                 sho_obj_return_to_u(obj); /* display its flight */
1499
1500                 if (!impaired && rn2(100)) {
1501 /*JP
1502                 pline("%s to your hand!", Tobjnam(obj, "return"));
1503 */
1504                 pline("%s\82Í\82 \82È\82½\82Ì\8eè\82É\96ß\82Á\82Ä\82«\82½\81I", xname(obj));
1505                     obj = addinv(obj);
1506                     (void) encumber_msg();
1507                     /* addinv autoquivers an aklys if quiver is empty;
1508                        if obj is quivered, remove it before wielding */
1509                     if (obj->owornmask & W_QUIVER)
1510                         setuqwep((struct obj *) 0);
1511                     setuwep(obj);
1512                     u.twoweap = twoweap;
1513                     if (cansee(bhitpos.x, bhitpos.y))
1514                         newsym(bhitpos.x, bhitpos.y);
1515                 } else {
1516                     int dmg = rn2(2);
1517
1518                     if (!dmg) {
1519 #if 0 /*JP:T*/
1520                         pline(Blind ? "%s lands %s your %s."
1521                                     : "%s back to you, landing %s your %s.",
1522                               Blind ? Something : Tobjnam(obj, "return"),
1523                               Levitation ? "beneath" : "at",
1524                               makeplural(body_part(FOOT)));
1525 #else
1526                         pline("%s\82Í%s\82 \82È\82½\82Ì%s\82Ì%s\82É\97\8e\82¿\82½\81D",
1527                               xname(obj),
1528                               Blind ? "" : "\96ß\82Á\82Ä\82«\82Ä\81C",
1529                               body_part(FOOT),
1530                               Levitation ? "\89º" : "\82»\82Î");
1531 #endif
1532                     } else {
1533                         dmg += rnd(3);
1534 #if 0 /*JP:T*/
1535                         pline(Blind ? "%s your %s!"
1536                                     : "%s back toward you, hitting your %s!",
1537                               Tobjnam(obj, Blind ? "hit" : "fly"),
1538                               body_part(ARM));
1539 #else
1540                         pline("%s\82Í%s\82 \82È\82½\82Ì%s\82É\96½\92\86\82µ\82½\81I",
1541                               xname(obj),
1542                               Blind ? "" : "\96ß\82Á\82Ä\82«\82Ä\81C",
1543                               body_part(ARM));
1544 #endif
1545                         if (obj->oartifact)
1546                             (void) artifact_hit((struct monst *) 0, &youmonst,
1547                                                 obj, &dmg, 0);
1548 #if 0 /*JP*/
1549                         losehp(Maybe_Half_Phys(dmg), killer_xname(obj),
1550                                KILLED_BY);
1551 #else
1552                         {
1553                             char jbuf[BUFSZ];
1554                             Sprintf(jbuf, "%s\82Å", xname(obj));
1555                             losehp(Maybe_Half_Phys(dmg), jbuf, KILLED_BY);
1556                         }
1557 #endif
1558                     }
1559                     if (ship_object(obj, u.ux, u.uy, FALSE)) {
1560                         thrownobj = (struct obj *) 0;
1561                         return;
1562                     }
1563                     dropy(obj);
1564                 }
1565                 thrownobj = (struct obj *) 0;
1566                 return;
1567             } else {
1568                 /* when this location is stepped on, the weapon will be
1569                    auto-picked up due to 'obj->was_thrown' of 1;
1570                    addinv() prevents thrown Mjollnir from being placed
1571                    into the quiver slot, but an aklys will end up there if
1572                    that slot is empty at the time; since hero will need to
1573                    explicitly rewield the weapon to get throw-and-return
1574                    capability back anyway, quivered or not shouldn't matter */
1575 /*JP
1576                 pline("%s to return!", Tobjnam(obj, "fail"));
1577 */
1578                 pline("%s\82Í\96ß\82é\82Ì\82É\8e¸\94s\82µ\82½\81I", xname(obj));
1579                 /* continue below with placing 'obj' at target location */
1580             }
1581         }
1582
1583         if (!IS_SOFT(levl[bhitpos.x][bhitpos.y].typ) && breaktest(obj)) {
1584             tmp_at(DISP_FLASH, obj_to_glyph(obj));
1585             tmp_at(bhitpos.x, bhitpos.y);
1586             delay_output();
1587             tmp_at(DISP_END, 0);
1588             breakmsg(obj, cansee(bhitpos.x, bhitpos.y));
1589             breakobj(obj, bhitpos.x, bhitpos.y, TRUE, TRUE);
1590             thrownobj = (struct obj *) 0;
1591             return;
1592         }
1593 /*JP
1594         if (flooreffects(obj, bhitpos.x, bhitpos.y, "fall")) {
1595 */
1596         if (flooreffects(obj,bhitpos.x, bhitpos.y, "\97\8e\82¿\82é")) {
1597             thrownobj = (struct obj *) 0;
1598             return;
1599         }
1600         obj_no_longer_held(obj);
1601         if (mon && mon->isshk && is_pick(obj)) {
1602             if (cansee(bhitpos.x, bhitpos.y))
1603 /*JP
1604                 pline("%s snatches up %s.", Monnam(mon), the(xname(obj)));
1605 */
1606                 pline("%s\82Í%s\82ð\92D\82¢\82Æ\82Á\82½\81D", Monnam(mon), xname(obj));
1607             if (*u.ushops || obj->unpaid)
1608                 check_shop_obj(obj, bhitpos.x, bhitpos.y, FALSE);
1609             (void) mpickobj(mon, obj); /* may merge and free obj */
1610             thrownobj = (struct obj *) 0;
1611             return;
1612         }
1613         (void) snuff_candle(obj);
1614         if (!mon && ship_object(obj, bhitpos.x, bhitpos.y, FALSE)) {
1615             thrownobj = (struct obj *) 0;
1616             return;
1617         }
1618         thrownobj = (struct obj *) 0;
1619         place_object(obj, bhitpos.x, bhitpos.y);
1620         /* container contents might break;
1621            do so before turning ownership of thrownobj over to shk
1622            (container_impact_dmg handles item already owned by shop) */
1623         if (!IS_SOFT(levl[bhitpos.x][bhitpos.y].typ))
1624             /* <x,y> is spot where you initiated throw, not bhitpos */
1625             container_impact_dmg(obj, u.ux, u.uy);
1626         /* charge for items thrown out of shop;
1627            shk takes possession for items thrown into one */
1628         if ((*u.ushops || obj->unpaid) && obj != uball)
1629             check_shop_obj(obj, bhitpos.x, bhitpos.y, FALSE);
1630
1631         stackobj(obj);
1632         if (obj == uball)
1633             drop_ball(bhitpos.x, bhitpos.y);
1634         if (cansee(bhitpos.x, bhitpos.y))
1635             newsym(bhitpos.x, bhitpos.y);
1636         if (obj_sheds_light(obj))
1637             vision_full_recalc = 1;
1638     }
1639 }
1640
1641 /* an object may hit a monster; various factors adjust the chance of hitting
1642  */
1643 int
1644 omon_adj(mon, obj, mon_notices)
1645 struct monst *mon;
1646 struct obj *obj;
1647 boolean mon_notices;
1648 {
1649     int tmp = 0;
1650
1651     /* size of target affects the chance of hitting */
1652     tmp += (mon->data->msize - MZ_MEDIUM); /* -2..+5 */
1653     /* sleeping target is more likely to be hit */
1654     if (mon->msleeping) {
1655         tmp += 2;
1656         if (mon_notices)
1657             mon->msleeping = 0;
1658     }
1659     /* ditto for immobilized target */
1660     if (!mon->mcanmove || !mon->data->mmove) {
1661         tmp += 4;
1662         if (mon_notices && mon->data->mmove && !rn2(10)) {
1663             mon->mcanmove = 1;
1664             mon->mfrozen = 0;
1665         }
1666     }
1667     /* some objects are more likely to hit than others */
1668     switch (obj->otyp) {
1669     case HEAVY_IRON_BALL:
1670         if (obj != uball)
1671             tmp += 2;
1672         break;
1673     case BOULDER:
1674         tmp += 6;
1675         break;
1676     default:
1677         if (obj->oclass == WEAPON_CLASS || is_weptool(obj)
1678             || obj->oclass == GEM_CLASS)
1679             tmp += hitval(obj, mon);
1680         break;
1681     }
1682     return tmp;
1683 }
1684
1685 /* thrown object misses target monster */
1686 STATIC_OVL void
1687 tmiss(obj, mon, maybe_wakeup)
1688 struct obj *obj;
1689 struct monst *mon;
1690 boolean maybe_wakeup;
1691 {
1692     const char *missile = mshot_xname(obj);
1693
1694     /* If the target can't be seen or doesn't look like a valid target,
1695        avoid "the arrow misses it," or worse, "the arrows misses the mimic."
1696        An attentive player will still notice that this is different from
1697        an arrow just landing short of any target (no message in that case),
1698        so will realize that there is a valid target here anyway. */
1699     if (!canseemon(mon) || (mon->m_ap_type && mon->m_ap_type != M_AP_MONSTER))
1700 /*JP
1701         pline("%s %s.", The(missile), otense(obj, "miss"));
1702 */
1703         pline("%s\82Í\82Í\82¸\82ê\82½\81D", missile);
1704     else
1705         miss(missile, mon);
1706     if (maybe_wakeup && !rn2(3))
1707         wakeup(mon, TRUE);
1708     return;
1709 }
1710
1711 #define quest_arti_hits_leader(obj, mon)      \
1712     (obj->oartifact && is_quest_artifact(obj) \
1713      && mon->m_id == quest_status.leader_m_id)
1714
1715 /*
1716  * Object thrown by player arrives at monster's location.
1717  * Return 1 if obj has disappeared or otherwise been taken care of,
1718  * 0 if caller must take care of it.
1719  * Also used for kicked objects and for polearms/grapnel applied at range.
1720  */
1721 int
1722 thitmonst(mon, obj)
1723 register struct monst *mon;
1724 register struct obj *obj; /* thrownobj or kickedobj or uwep */
1725 {
1726     register int tmp;     /* Base chance to hit */
1727     register int disttmp; /* distance modifier */
1728     int otyp = obj->otyp, hmode;
1729     boolean guaranteed_hit = (u.uswallow && mon == u.ustuck);
1730     int dieroll;
1731
1732     hmode = (obj == uwep) ? HMON_APPLIED
1733               : (obj == kickedobj) ? HMON_KICKED
1734                 : HMON_THROWN;
1735
1736     /* Differences from melee weapons:
1737      *
1738      * Dex still gives a bonus, but strength does not.
1739      * Polymorphed players lacking attacks may still throw.
1740      * There's a base -1 to hit.
1741      * No bonuses for fleeing or stunned targets (they don't dodge
1742      *    melee blows as readily, but dodging arrows is hard anyway).
1743      * Not affected by traps, etc.
1744      * Certain items which don't in themselves do damage ignore tmp.
1745      * Distance and monster size affect chance to hit.
1746      */
1747     tmp = -1 + Luck + find_mac(mon) + u.uhitinc
1748           + maybe_polyd(youmonst.data->mlevel, u.ulevel);
1749     if (ACURR(A_DEX) < 4)
1750         tmp -= 3;
1751     else if (ACURR(A_DEX) < 6)
1752         tmp -= 2;
1753     else if (ACURR(A_DEX) < 8)
1754         tmp -= 1;
1755     else if (ACURR(A_DEX) >= 14)
1756         tmp += (ACURR(A_DEX) - 14);
1757
1758     /* Modify to-hit depending on distance; but keep it sane.
1759      * Polearms get a distance penalty even when wielded; it's
1760      * hard to hit at a distance.
1761      */
1762     disttmp = 3 - distmin(u.ux, u.uy, mon->mx, mon->my);
1763     if (disttmp < -4)
1764         disttmp = -4;
1765     tmp += disttmp;
1766
1767     /* gloves are a hindrance to proper use of bows */
1768     if (uarmg && uwep && objects[uwep->otyp].oc_skill == P_BOW) {
1769         switch (uarmg->otyp) {
1770         case GAUNTLETS_OF_POWER: /* metal */
1771             tmp -= 2;
1772             break;
1773         case GAUNTLETS_OF_FUMBLING:
1774             tmp -= 3;
1775             break;
1776         case LEATHER_GLOVES:
1777         case GAUNTLETS_OF_DEXTERITY:
1778             break;
1779         default:
1780             impossible("Unknown type of gloves (%d)", uarmg->otyp);
1781             break;
1782         }
1783     }
1784
1785     tmp += omon_adj(mon, obj, TRUE);
1786     if (is_orc(mon->data)
1787         && maybe_polyd(is_elf(youmonst.data), Race_if(PM_ELF)))
1788         tmp++;
1789     if (guaranteed_hit) {
1790         tmp += 1000; /* Guaranteed hit */
1791     }
1792
1793     if (obj->oclass == GEM_CLASS && is_unicorn(mon->data)) {
1794         if (mon->msleeping || !mon->mcanmove) {
1795             tmiss(obj, mon, FALSE);
1796             return 0;
1797         } else if (mon->mtame) {
1798 /*JP
1799             pline("%s catches and drops %s.", Monnam(mon), the(xname(obj)));
1800 */
1801             pline("%s\82Í%s\82ð\82­\82í\82¦\82Ä\92u\82¢\82½\81D", Monnam(mon), xname(obj));
1802             return 0;
1803         } else {
1804 /*JP
1805             pline("%s catches %s.", Monnam(mon), the(xname(obj)));
1806 */
1807             pline("%s\82Í%s\82ð\82­\82í\82¦\82½\81D", Monnam(mon), xname(obj));
1808             return gem_accept(mon, obj);
1809         }
1810     }
1811
1812     /* don't make game unwinnable if naive player throws artifact
1813        at leader... (kicked artifact is ok too; HMON_APPLIED could
1814        occur if quest artifact polearm or grapnel ever gets added) */
1815     if (hmode != HMON_APPLIED && quest_arti_hits_leader(obj, mon)) {
1816         /* AIS: changes to wakeup() means that it's now less inappropriate here
1817            than it used to be, but the manual version works just as well */
1818         mon->msleeping = 0;
1819         mon->mstrategy &= ~STRAT_WAITMASK;
1820
1821         if (mon->mcanmove) {
1822 /*JP
1823             pline("%s catches %s.", Monnam(mon), the(xname(obj)));
1824 */
1825             pline("%s\82Í%s\82ð\92Í\82ñ\82¾\81D", Monnam(mon), xname(obj));
1826             if (mon->mpeaceful) {
1827                 boolean next2u = monnear(mon, u.ux, u.uy);
1828
1829                 finish_quest(obj); /* acknowledge quest completion */
1830 #if 0 /*JP*/
1831                 pline("%s %s %s back to you.", Monnam(mon),
1832                       (next2u ? "hands" : "tosses"), the(xname(obj)));
1833 #else
1834                 pline("%s\82Í%s\82ð\82 \82È\82½\82É\95Ô\82µ\82½\81D", Monnam(mon),
1835                       xname(obj));
1836 #endif
1837                 if (!next2u)
1838                     sho_obj_return_to_u(obj);
1839                 obj = addinv(obj); /* back into your inventory */
1840                 (void) encumber_msg();
1841             } else {
1842                 /* angry leader caught it and isn't returning it */
1843                 if (*u.ushops || obj->unpaid) /* not very likely... */
1844                     check_shop_obj(obj, mon->mx, mon->my, FALSE);
1845                 (void) mpickobj(mon, obj);
1846             }
1847             return 1; /* caller doesn't need to place it */
1848         }
1849         return 0;
1850     }
1851
1852     dieroll = rnd(20);
1853
1854     if (obj->oclass == WEAPON_CLASS || is_weptool(obj)
1855         || obj->oclass == GEM_CLASS) {
1856         if (hmode == HMON_KICKED) {
1857             /* throwing adjustments and weapon skill bonus don't apply */
1858             tmp -= (is_ammo(obj) ? 5 : 3);
1859         } else if (is_ammo(obj)) {
1860             if (!ammo_and_launcher(obj, uwep)) {
1861                 tmp -= 4;
1862             } else {
1863                 tmp += uwep->spe - greatest_erosion(uwep);
1864                 tmp += weapon_hit_bonus(uwep);
1865                 if (uwep->oartifact)
1866                     tmp += spec_abon(uwep, mon);
1867                 /*
1868                  * Elves and Samurais are highly trained w/bows,
1869                  * especially their own special types of bow.
1870                  * Polymorphing won't make you a bow expert.
1871                  */
1872                 if ((Race_if(PM_ELF) || Role_if(PM_SAMURAI))
1873                     && (!Upolyd || your_race(youmonst.data))
1874                     && objects[uwep->otyp].oc_skill == P_BOW) {
1875                     tmp++;
1876                     if (Race_if(PM_ELF) && uwep->otyp == ELVEN_BOW)
1877                         tmp++;
1878                     else if (Role_if(PM_SAMURAI) && uwep->otyp == YUMI)
1879                         tmp++;
1880                 }
1881             }
1882         } else { /* thrown non-ammo or applied polearm/grapnel */
1883             if (otyp == BOOMERANG) /* arbitrary */
1884                 tmp += 4;
1885             else if (throwing_weapon(obj)) /* meant to be thrown */
1886                 tmp += 2;
1887             else if (obj == thrownobj) /* not meant to be thrown */
1888                 tmp -= 2;
1889             /* we know we're dealing with a weapon or weptool handled
1890                by WEAPON_SKILLS once ammo objects have been excluded */
1891             tmp += weapon_hit_bonus(obj);
1892         }
1893
1894         if (tmp >= dieroll) {
1895             boolean wasthrown = (thrownobj != 0);
1896
1897             /* attack hits mon */
1898             if (hmode == HMON_APPLIED)
1899                 u.uconduct.weaphit++;
1900             if (hmon(mon, obj, hmode, dieroll)) { /* mon still alive */
1901                 cutworm(mon, bhitpos.x, bhitpos.y, obj);
1902             }
1903             exercise(A_DEX, TRUE);
1904             /* if hero was swallowed and projectile killed the engulfer,
1905                'obj' got added to engulfer's inventory and then dropped,
1906                so we can't safely use that pointer anymore; it escapes
1907                the chance to be used up here... */
1908             if (wasthrown && !thrownobj)
1909                 return 1;
1910
1911             /* projectiles other than magic stones
1912                sometimes disappear when thrown */
1913             if (objects[otyp].oc_skill < P_NONE
1914                 && objects[otyp].oc_skill > -P_BOOMERANG
1915                 && !objects[otyp].oc_magic) {
1916                 /* we were breaking 2/3 of everything unconditionally.
1917                  * we still don't want anything to survive unconditionally,
1918                  * but we need ammo to stay around longer on average.
1919                  */
1920                 int broken, chance;
1921
1922                 chance = 3 + greatest_erosion(obj) - obj->spe;
1923                 if (chance > 1)
1924                     broken = rn2(chance);
1925                 else
1926                     broken = !rn2(4);
1927                 if (obj->blessed && !rnl(4))
1928                     broken = 0;
1929
1930                 if (broken) {
1931                     if (*u.ushops || obj->unpaid)
1932                         check_shop_obj(obj, bhitpos.x, bhitpos.y, TRUE);
1933                     obfree(obj, (struct obj *) 0);
1934                     return 1;
1935                 }
1936             }
1937             passive_obj(mon, obj, (struct attack *) 0);
1938         } else {
1939             tmiss(obj, mon, TRUE);
1940             if (hmode == HMON_APPLIED)
1941                 wakeup(mon, TRUE);
1942         }
1943
1944     } else if (otyp == HEAVY_IRON_BALL) {
1945         exercise(A_STR, TRUE);
1946         if (tmp >= dieroll) {
1947             int was_swallowed = guaranteed_hit;
1948
1949             exercise(A_DEX, TRUE);
1950             if (!hmon(mon, obj, hmode, dieroll)) { /* mon killed */
1951                 if (was_swallowed && !u.uswallow && obj == uball)
1952                     return 1; /* already did placebc() */
1953             }
1954         } else {
1955             tmiss(obj, mon, TRUE);
1956         }
1957
1958     } else if (otyp == BOULDER) {
1959         exercise(A_STR, TRUE);
1960         if (tmp >= dieroll) {
1961             exercise(A_DEX, TRUE);
1962             (void) hmon(mon, obj, hmode, dieroll);
1963         } else {
1964             tmiss(obj, mon, TRUE);
1965         }
1966
1967     } else if ((otyp == EGG || otyp == CREAM_PIE || otyp == BLINDING_VENOM
1968                 || otyp == ACID_VENOM)
1969                && (guaranteed_hit || ACURR(A_DEX) > rnd(25))) {
1970         (void) hmon(mon, obj, hmode, dieroll);
1971         return 1; /* hmon used it up */
1972
1973     } else if (obj->oclass == POTION_CLASS
1974                && (guaranteed_hit || ACURR(A_DEX) > rnd(25))) {
1975         potionhit(mon, obj, POTHIT_HERO_THROW);
1976         return 1;
1977
1978     } else if (befriend_with_obj(mon->data, obj)
1979                || (mon->mtame && dogfood(mon, obj) <= ACCFOOD)) {
1980         if (tamedog(mon, obj)) {
1981             return 1; /* obj is gone */
1982         } else {
1983             tmiss(obj, mon, FALSE);
1984             mon->msleeping = 0;
1985             mon->mstrategy &= ~STRAT_WAITMASK;
1986         }
1987     } else if (guaranteed_hit) {
1988         /* this assumes that guaranteed_hit is due to swallowing */
1989         wakeup(mon, TRUE);
1990         if (obj->otyp == CORPSE && touch_petrifies(&mons[obj->corpsenm])) {
1991             if (is_animal(u.ustuck->data)) {
1992                 minstapetrify(u.ustuck, TRUE);
1993                 /* Don't leave a cockatrice corpse available in a statue */
1994                 if (!u.uswallow) {
1995                     delobj(obj);
1996                     return 1;
1997                 }
1998             }
1999         }
2000 #if 0 /*JP*/
2001         pline("%s into %s %s.", Tobjnam(obj, "vanish"),
2002               s_suffix(mon_nam(mon)),
2003               is_animal(u.ustuck->data) ? "entrails" : "currents");
2004 #else
2005         pline("%s\82Í%s\82Ì%s\82Ö\8fÁ\82¦\82½\81D", xname(obj),
2006               mon_nam(mon),
2007               is_animal(u.ustuck->data) ? "\93à\91\9f\82Ì\92\86" : "\97¬\82ê");
2008 #endif
2009     } else {
2010         tmiss(obj, mon, TRUE);
2011     }
2012
2013     return 0;
2014 }
2015
2016 STATIC_OVL int
2017 gem_accept(mon, obj)
2018 register struct monst *mon;
2019 register struct obj *obj;
2020 {
2021     char buf[BUFSZ];
2022     boolean is_buddy = sgn(mon->data->maligntyp) == sgn(u.ualign.type);
2023     boolean is_gem = objects[obj->otyp].oc_material == GEMSTONE;
2024     int ret = 0;
2025 /*JP
2026     static NEARDATA const char nogood[] = " is not interested in your junk.";
2027 */
2028     static NEARDATA const char nogood[] = "\82 \82È\82½\82Ì\83K\83\89\83N\83^\82É\8b»\96¡\82ð\8e¦\82³\82È\82¢\81D";
2029 /*JP
2030     static NEARDATA const char acceptgift[] = " accepts your gift.";
2031 */
2032     static NEARDATA const char acceptgift[] = "\82 \82È\82½\82Ì\91¡\82è\95¨\82ð\8eó\82¯\82Æ\82Á\82½\81D";
2033 /*JP
2034     static NEARDATA const char maybeluck[] = " hesitatingly";
2035 */
2036     static NEARDATA const char maybeluck[] = "\82½\82ß\82ç\82¢\82È\82ª\82ç";
2037 /*JP
2038     static NEARDATA const char noluck[] = " graciously";
2039 */
2040     static NEARDATA const char noluck[] = "\92\9a\8fd\82É";
2041 /*JP
2042     static NEARDATA const char addluck[] = " gratefully";
2043 */
2044     static NEARDATA const char addluck[] = "\8aì\82ñ\82Å";
2045
2046     Strcpy(buf, Monnam(mon));
2047 #if 1 /*JP*/
2048     Strcat(buf, "\82Í");
2049 #endif
2050     mon->mpeaceful = 1;
2051     mon->mavenge = 0;
2052
2053     /* object properly identified */
2054     if (obj->dknown && objects[obj->otyp].oc_name_known) {
2055         if (is_gem) {
2056             if (is_buddy) {
2057                 Strcat(buf, addluck);
2058                 change_luck(5);
2059             } else {
2060                 Strcat(buf, maybeluck);
2061                 change_luck(rn2(7) - 3);
2062             }
2063         } else {
2064             Strcat(buf, nogood);
2065             goto nopick;
2066         }
2067         /* making guesses */
2068     } else if (has_oname(obj) || objects[obj->otyp].oc_uname) {
2069         if (is_gem) {
2070             if (is_buddy) {
2071                 Strcat(buf, addluck);
2072                 change_luck(2);
2073             } else {
2074                 Strcat(buf, maybeluck);
2075                 change_luck(rn2(3) - 1);
2076             }
2077         } else {
2078             Strcat(buf, nogood);
2079             goto nopick;
2080         }
2081         /* value completely unknown to @ */
2082     } else {
2083         if (is_gem) {
2084             if (is_buddy) {
2085                 Strcat(buf, addluck);
2086                 change_luck(1);
2087             } else {
2088                 Strcat(buf, maybeluck);
2089                 change_luck(rn2(3) - 1);
2090             }
2091         } else {
2092             Strcat(buf, noluck);
2093         }
2094     }
2095     Strcat(buf, acceptgift);
2096     if (*u.ushops || obj->unpaid)
2097         check_shop_obj(obj, mon->mx, mon->my, TRUE);
2098     (void) mpickobj(mon, obj); /* may merge and free obj */
2099     ret = 1;
2100
2101 nopick:
2102     if (!Blind)
2103         pline1(buf);
2104     if (!tele_restrict(mon))
2105         (void) rloc(mon, TRUE);
2106     return ret;
2107 }
2108
2109 /*
2110  * Comments about the restructuring of the old breaks() routine.
2111  *
2112  * There are now three distinct phases to object breaking:
2113  *     breaktest() - which makes the check/decision about whether the
2114  *                   object is going to break.
2115  *     breakmsg()  - which outputs a message about the breakage,
2116  *                   appropriate for that particular object. Should
2117  *                   only be called after a positive breaktest().
2118  *                   on the object and, if it going to be called,
2119  *                   it must be called before calling breakobj().
2120  *                   Calling breakmsg() is optional.
2121  *     breakobj()  - which actually does the breakage and the side-effects
2122  *                   of breaking that particular object. This should
2123  *                   only be called after a positive breaktest() on the
2124  *                   object.
2125  *
2126  * Each of the above routines is currently static to this source module.
2127  * There are two routines callable from outside this source module which
2128  * perform the routines above in the correct sequence.
2129  *
2130  *   hero_breaks() - called when an object is to be broken as a result
2131  *                   of something that the hero has done. (throwing it,
2132  *                   kicking it, etc.)
2133  *   breaks()      - called when an object is to be broken for some
2134  *                   reason other than the hero doing something to it.
2135  */
2136
2137 /*
2138  * The hero causes breakage of an object (throwing, dropping it, etc.)
2139  * Return 0 if the object didn't break, 1 if the object broke.
2140  */
2141 int
2142 hero_breaks(obj, x, y, from_invent)
2143 struct obj *obj;
2144 xchar x, y;          /* object location (ox, oy may not be right) */
2145 boolean from_invent; /* thrown or dropped by player; maybe on shop bill */
2146 {
2147     boolean in_view = Blind ? FALSE : (from_invent || cansee(x, y));
2148     if (!breaktest(obj))
2149         return 0;
2150     breakmsg(obj, in_view);
2151     breakobj(obj, x, y, TRUE, from_invent);
2152     return 1;
2153 }
2154
2155 /*
2156  * The object is going to break for a reason other than the hero doing
2157  * something to it.
2158  * Return 0 if the object doesn't break, 1 if the object broke.
2159  */
2160 int
2161 breaks(obj, x, y)
2162 struct obj *obj;
2163 xchar x, y; /* object location (ox, oy may not be right) */
2164 {
2165     boolean in_view = Blind ? FALSE : cansee(x, y);
2166
2167     if (!breaktest(obj))
2168         return 0;
2169     breakmsg(obj, in_view);
2170     breakobj(obj, x, y, FALSE, FALSE);
2171     return 1;
2172 }
2173
2174 void
2175 release_camera_demon(obj, x, y)
2176 struct obj *obj;
2177 xchar x, y;
2178 {
2179     struct monst *mtmp;
2180     if (!rn2(3)
2181         && (mtmp = makemon(&mons[rn2(3) ? PM_HOMUNCULUS : PM_IMP], x, y,
2182                            NO_MM_FLAGS)) != 0) {
2183         if (canspotmon(mtmp))
2184 #if 0 /*JP*/
2185             pline("%s is released!", Hallucination
2186                                          ? An(rndmonnam(NULL))
2187                                          : "The picture-painting demon");
2188 #else
2189             pline("%s\82ª\89ð\95ú\82³\82ê\82½\81I", Hallucination
2190                                          ? rndmonnam(NULL)
2191                                          : "\82¨\8aG\95`\82«\82Ì\88«\96\82");
2192 #endif
2193         mtmp->mpeaceful = !obj->cursed;
2194         set_malign(mtmp);
2195     }
2196 }
2197
2198 /*
2199  * Unconditionally break an object. Assumes all resistance checks
2200  * and break messages have been delivered prior to getting here.
2201  */
2202 void
2203 breakobj(obj, x, y, hero_caused, from_invent)
2204 struct obj *obj;
2205 xchar x, y;          /* object location (ox, oy may not be right) */
2206 boolean hero_caused; /* is this the hero's fault? */
2207 boolean from_invent;
2208 {
2209     boolean fracture = FALSE;
2210
2211     switch (obj->oclass == POTION_CLASS ? POT_WATER : obj->otyp) {
2212     case MIRROR:
2213         if (hero_caused)
2214             change_luck(-2);
2215         break;
2216     case POT_WATER:      /* really, all potions */
2217         obj->in_use = 1; /* in case it's fatal */
2218         if (obj->otyp == POT_OIL && obj->lamplit) {
2219             explode_oil(obj, x, y);
2220         } else if (distu(x, y) <= 2) {
2221             if (!breathless(youmonst.data) || haseyes(youmonst.data)) {
2222                 if (obj->otyp != POT_WATER) {
2223                     if (!breathless(youmonst.data)) {
2224                         /* [what about "familiar odor" when known?] */
2225 /*JP
2226                         You("smell a peculiar odor...");
2227 */
2228                         You("\96ò\82Á\82Û\82¢\93õ\82¢\82ª\82µ\82½\81D\81D\81D");
2229                     } else {
2230 #if 0 /*JP*/
2231                         const char *eyes = body_part(EYE);
2232
2233                         if (eyecount(youmonst.data) != 1)
2234                             eyes = makeplural(eyes);
2235                         Your("%s %s.", eyes, vtense(eyes, "water"));
2236 #else
2237                         You("\97Ü%s\82É\82È\82Á\82½\81D", body_part(EYE));
2238 #endif
2239                     }
2240                 }
2241                 potionbreathe(obj);
2242             }
2243         }
2244         /* monster breathing isn't handled... [yet?] */
2245         break;
2246     case EXPENSIVE_CAMERA:
2247         release_camera_demon(obj, x, y);
2248         break;
2249     case EGG:
2250         /* breaking your own eggs is bad luck */
2251         if (hero_caused && obj->spe && obj->corpsenm >= LOW_PM)
2252             change_luck((schar) -min(obj->quan, 5L));
2253         break;
2254     case BOULDER:
2255     case STATUE:
2256         /* caller will handle object disposition;
2257            we're just doing the shop theft handling */
2258         fracture = TRUE;
2259         break;
2260     default:
2261         break;
2262     }
2263
2264     if (hero_caused) {
2265         if (from_invent || obj->unpaid) {
2266             if (*u.ushops || obj->unpaid)
2267                 check_shop_obj(obj, x, y, TRUE);
2268         } else if (!obj->no_charge && costly_spot(x, y)) {
2269             /* it is assumed that the obj is a floor-object */
2270             char *o_shop = in_rooms(x, y, SHOPBASE);
2271             struct monst *shkp = shop_keeper(*o_shop);
2272
2273             if (shkp) { /* (implies *o_shop != '\0') */
2274                 static NEARDATA long lastmovetime = 0L;
2275                 static NEARDATA boolean peaceful_shk = FALSE;
2276                 /*  We want to base shk actions on her peacefulness
2277                     at start of this turn, so that "simultaneous"
2278                     multiple breakage isn't drastically worse than
2279                     single breakage.  (ought to be done via ESHK)  */
2280                 if (moves != lastmovetime)
2281                     peaceful_shk = shkp->mpeaceful;
2282                 if (stolen_value(obj, x, y, peaceful_shk, FALSE) > 0L
2283                     && (*o_shop != u.ushops[0] || !inside_shop(u.ux, u.uy))
2284                     && moves != lastmovetime)
2285                     make_angry_shk(shkp, x, y);
2286                 lastmovetime = moves;
2287             }
2288         }
2289     }
2290     if (!fracture)
2291         delobj(obj);
2292 }
2293
2294 /*
2295  * Check to see if obj is going to break, but don't actually break it.
2296  * Return 0 if the object isn't going to break, 1 if it is.
2297  */
2298 boolean
2299 breaktest(obj)
2300 struct obj *obj;
2301 {
2302     if (obj_resists(obj, 1, 99))
2303         return 0;
2304     if (objects[obj->otyp].oc_material == GLASS && !obj->oartifact
2305         && obj->oclass != GEM_CLASS)
2306         return 1;
2307     switch (obj->oclass == POTION_CLASS ? POT_WATER : obj->otyp) {
2308     case EXPENSIVE_CAMERA:
2309     case POT_WATER: /* really, all potions */
2310     case EGG:
2311     case CREAM_PIE:
2312     case MELON:
2313     case ACID_VENOM:
2314     case BLINDING_VENOM:
2315         return 1;
2316     default:
2317         return 0;
2318     }
2319 }
2320
2321 STATIC_OVL void
2322 breakmsg(obj, in_view)
2323 struct obj *obj;
2324 boolean in_view;
2325 {
2326     const char *to_pieces;
2327
2328 #if 0 /*JP*/
2329     to_pieces = "";
2330 #else
2331     /* "shatter" \81¨ "\82±\82È\82²\82È\82É\82È\82Á\82½"
2332        "shatter into a thousand pieces" \81¨ "\82­\82¾\82¯\82Ä\82Î\82ç\82Î\82ç\82É\82È\82Á\82½" */
2333     to_pieces = "\82±\82È\82²\82È";
2334 #endif
2335     switch (obj->oclass == POTION_CLASS ? POT_WATER : obj->otyp) {
2336     default: /* glass or crystal wand */
2337         if (obj->oclass != WAND_CLASS)
2338             impossible("breaking odd object?");
2339         /*FALLTHRU*/
2340     case CRYSTAL_PLATE_MAIL:
2341     case LENSES:
2342     case MIRROR:
2343     case CRYSTAL_BALL:
2344     case EXPENSIVE_CAMERA:
2345 /*JP
2346         to_pieces = " into a thousand pieces";
2347 */
2348         to_pieces = "\82­\82¾\82¯\82Ä\82Î\82ç\82Î\82ç";
2349     /*FALLTHRU*/
2350     case POT_WATER: /* really, all potions */
2351         if (!in_view)
2352 /*JP
2353             You_hear("%s shatter!", something);
2354 */
2355             You_hear("%s\82ª\89ó\82ê\82é\89¹\82ð\95·\82¢\82½\81I", something);
2356         else
2357 #if 0 /*JP*/
2358             pline("%s shatter%s%s!", Doname2(obj),
2359                   (obj->quan == 1L) ? "s" : "", to_pieces);
2360 #else
2361             pline("%s\82Í%s\82É\82È\82Á\82½\81I", Doname2(obj), to_pieces);
2362 #endif
2363         break;
2364     case EGG:
2365     case MELON:
2366 /*JP
2367         pline("Splat!");
2368 */
2369         pline("\83r\83`\83\83\81I");
2370         break;
2371     case CREAM_PIE:
2372         if (in_view)
2373 /*JP
2374             pline("What a mess!");
2375 */
2376             pline("\82±\82è\82á\82Ð\82Ç\82¢\81I");
2377         break;
2378     case ACID_VENOM:
2379     case BLINDING_VENOM:
2380 /*JP
2381         pline("Splash!");
2382 */
2383         pline("\83r\83`\83\83\81I");
2384         break;
2385     }
2386 }
2387
2388 STATIC_OVL int
2389 throw_gold(obj)
2390 struct obj *obj;
2391 {
2392     int range, odx, ody;
2393     register struct monst *mon;
2394
2395     if (!u.dx && !u.dy && !u.dz) {
2396 /*JP
2397         You("cannot throw gold at yourself.");
2398 */
2399         pline("\8e©\95ª\82É\8bà\89Ý\82ð\93\8a\82°\82é\82±\82Æ\82Í\82Å\82«\82È\82¢\81D");
2400         return 0;
2401     }
2402     freeinv(obj);
2403     if (u.uswallow) {
2404 #if 0 /*JP*/
2405         pline(is_animal(u.ustuck->data) ? "%s in the %s's entrails."
2406                                         : "%s into %s.",
2407               "The money disappears", mon_nam(u.ustuck));
2408 #else
2409         pline(is_animal(u.ustuck->data) ? "\8bà\89Ý\82Í%s\82Ì\95 \82Ì\92\86\82Ö\8fÁ\82¦\82Ä\82¢\82Á\82½\81D"
2410                                         : "\8bà\89Ý\82Í%s\82Ì\92\86\82Ö\8fÁ\82¦\82Ä\82¢\82Á\82½\81D",
2411               mon_nam(u.ustuck));
2412 #endif
2413         add_to_minv(u.ustuck, obj);
2414         return 1;
2415     }
2416
2417     if (u.dz) {
2418         if (u.dz < 0 && !Is_airlevel(&u.uz) && !Underwater
2419             && !Is_waterlevel(&u.uz)) {
2420 #if 0 /*JP*/
2421             pline_The("gold hits the %s, then falls back on top of your %s.",
2422                       ceiling(u.ux, u.uy), body_part(HEAD));
2423 #else
2424             pline("\8bà\89Ý\82Í%s\82É\96½\92\86\82µ\81C\82 \82È\82½\82Ì%s\82Ì\90^\8fã\82É\97\8e\82¿\82Ä\82«\82½\81D",
2425                   ceiling(u.ux,u.uy), body_part(HEAD));
2426 #endif
2427             /* some self damage? */
2428             if (uarmh)
2429 /*JP
2430                 pline("Fortunately, you are wearing %s!",
2431 */
2432                 pline("\8dK\89^\82È\82±\82Æ\82É\81C\82 \82È\82½\82Í%s\82ð\90g\82É\82Â\82¯\82Ä\82¢\82é\81I",
2433                       an(helm_simple_name(uarmh)));
2434         }
2435         bhitpos.x = u.ux;
2436         bhitpos.y = u.uy;
2437     } else {
2438         /* consistent with range for normal objects */
2439         range = (int) ((ACURRSTR) / 2 - obj->owt / 40);
2440
2441         /* see if the gold has a place to move into */
2442         odx = u.ux + u.dx;
2443         ody = u.uy + u.dy;
2444         if (!ZAP_POS(levl[odx][ody].typ) || closed_door(odx, ody)) {
2445             bhitpos.x = u.ux;
2446             bhitpos.y = u.uy;
2447         } else {
2448             mon = bhit(u.dx, u.dy, range, THROWN_WEAPON,
2449                        (int FDECL((*), (MONST_P, OBJ_P))) 0,
2450                        (int FDECL((*), (OBJ_P, OBJ_P))) 0, &obj);
2451             if (!obj)
2452                 return 1; /* object is gone */
2453             if (mon) {
2454                 if (ghitm(mon, obj)) /* was it caught? */
2455                     return 1;
2456             } else {
2457                 if (ship_object(obj, bhitpos.x, bhitpos.y, FALSE))
2458                     return 1;
2459             }
2460         }
2461     }
2462
2463 /*JP
2464     if (flooreffects(obj, bhitpos.x, bhitpos.y, "fall"))
2465 */
2466     if (flooreffects(obj, bhitpos.x, bhitpos.y, "\97\8e\82¿\82é"))
2467         return 1;
2468     if (u.dz > 0)
2469 /*JP
2470         pline_The("gold hits the %s.", surface(bhitpos.x, bhitpos.y));
2471 */
2472         pline("\8bà\89Ý\82Í%s\82É\96½\92\86\82µ\82½\81D", surface(bhitpos.x, bhitpos.y));
2473     place_object(obj, bhitpos.x, bhitpos.y);
2474     if (*u.ushops)
2475         sellobj(obj, bhitpos.x, bhitpos.y);
2476     stackobj(obj);
2477     newsym(bhitpos.x, bhitpos.y);
2478     return 1;
2479 }
2480
2481 /*dothrow.c*/