OSDN Git Service

add translation
[jnethack/source.git] / src / dothrow.c
1 /* NetHack 3.6  dothrow.c       $NHDT-Date: 1446975465 2015/11/08 09:37:45 $  $NHDT-Branch: master $:$NHDT-Revision: 1.113 $ */
2 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3 /* NetHack may be freely redistributed.  See license for details. */
4
5 /* Contains code for 't' (throw) */
6
7 /* JNetHack Copyright */
8 /* (c) Issei Numata, Naoki Hamada, Shigehiro Miyashita, 1994-2000  */
9 /* For 3.4-, Copyright (c) SHIRAKATA Kentaro, 2002-2016            */
10 /* JNetHack may be freely redistributed.  See license for details. */
11
12 #include "hack.h"
13
14 STATIC_DCL int FDECL(throw_obj, (struct obj *, int));
15 STATIC_DCL boolean FDECL(ok_to_throw, (int *));
16 STATIC_DCL void NDECL(autoquiver);
17 STATIC_DCL int FDECL(gem_accept, (struct monst *, struct obj *));
18 STATIC_DCL void FDECL(tmiss, (struct obj *, struct monst *, BOOLEAN_P));
19 STATIC_DCL int FDECL(throw_gold, (struct obj *));
20 STATIC_DCL void FDECL(check_shop_obj, (struct obj *, XCHAR_P, XCHAR_P,
21                                        BOOLEAN_P));
22 STATIC_DCL void FDECL(breakmsg, (struct obj *, BOOLEAN_P));
23 STATIC_DCL boolean FDECL(toss_up, (struct obj *, BOOLEAN_P));
24 STATIC_DCL boolean FDECL(throwing_weapon, (struct obj *));
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      * For the last, if player's response is a stack, we put
405      * that stack into quiver slot provided it's not wielded.
406      */
407     if (!ok_to_throw(&shotlimit))
408         return 0;
409
410     if ((obj = uquiver) == 0) {
411         if (!flags.autoquiver) {
412 /*JP
413             You("have no ammunition readied.");
414 */
415             You("\94­\8eË\8f\80\94õ\82ª\90®\82Á\82Ä\82¢\82È\82¢\81I");
416         } else {
417             autoquiver();
418             if ((obj = uquiver) == 0)
419 /*JP
420                 You("have nothing appropriate for your quiver.");
421 */
422                 You("\94­\8eË\82·\82é\82à\82Ì\82ª\82È\82¢\81D");
423         }
424         /* if autoquiver is disabled or has failed, prompt for missile;
425            fill quiver with it if it's not wielded */
426         if (!obj) {
427             obj = getobj(uslinging() ? bullets : toss_objs, "throw");
428             /* Q command doesn't allow gold in quiver */
429             if (obj && !obj->owornmask && obj->oclass != COIN_CLASS)
430                 setuqwep(obj); /* demi-autoquiver */
431         }
432         /* give feedback if quiver has now been filled */
433         if (uquiver) {
434             uquiver->owornmask &= ~W_QUIVER; /* less verbose */
435 /*JP
436             prinv("You ready:", uquiver, 0L);
437 */
438             prinv("\8f\80\94õ\81F", uquiver, 0L);
439             uquiver->owornmask |= W_QUIVER;
440         }
441     }
442
443     return obj ? throw_obj(obj, shotlimit) : 0;
444 }
445
446 /* if in midst of multishot shooting/throwing, stop early */
447 void
448 endmultishot(verbose)
449 boolean verbose;
450 {
451     if (m_shot.i < m_shot.n) {
452         if (verbose && !context.mon_moving) {
453 #if 0 /*JP*/
454             You("stop %s after the %d%s %s.",
455                 m_shot.s ? "firing" : "throwing", m_shot.i, ordin(m_shot.i),
456                 m_shot.s ? "shot" : "toss");
457 #else
458             You("%d\94­\96Ú\82ð%s\82Æ\82±\82ë\82Å\8ec\82è\82ð%s\82Ì\82ð\82â\82ß\82½\81D", m_shot.i,
459                 m_shot.s ? "\8c\82\82Á\82½" : "\93\8a\82°\82½",
460                 m_shot.s ? "\8c\82\82Â" : "\93\8a\82°\82é");
461 #endif
462         }
463         m_shot.n = m_shot.i; /* make current shot be the last */
464     }
465 }
466
467 /*
468  * Object hits floor at hero's feet.  Called from drop() and throwit().
469  */
470 void
471 hitfloor(obj)
472 register struct obj *obj;
473 {
474     if (IS_SOFT(levl[u.ux][u.uy].typ) || u.uinwater) {
475         dropy(obj);
476         return;
477     }
478     if (IS_ALTAR(levl[u.ux][u.uy].typ))
479         doaltarobj(obj);
480     else
481 #if 0 /*JP*/
482         pline("%s hit%s the %s.", Doname2(obj), (obj->quan == 1L) ? "s" : "",
483               surface(u.ux, u.uy));
484 #else
485         pline("%s\82Í%s\82É\96½\92\86\82µ\82½\81D", Doname2(obj),
486               surface(u.ux,u.uy));
487 #endif
488
489     if (hero_breaks(obj, u.ux, u.uy, TRUE))
490         return;
491     if (ship_object(obj, u.ux, u.uy, FALSE))
492         return;
493     dropz(obj, TRUE);
494 }
495
496 /*
497  * Walk a path from src_cc to dest_cc, calling a proc for each location
498  * except the starting one.  If the proc returns FALSE, stop walking
499  * and return FALSE.  If stopped early, dest_cc will be the location
500  * before the failed callback.
501  */
502 boolean
503 walk_path(src_cc, dest_cc, check_proc, arg)
504 coord *src_cc;
505 coord *dest_cc;
506 boolean FDECL((*check_proc), (genericptr_t, int, int));
507 genericptr_t arg;
508 {
509     int x, y, dx, dy, x_change, y_change, err, i, prev_x, prev_y;
510     boolean keep_going = TRUE;
511
512     /* Use Bresenham's Line Algorithm to walk from src to dest */
513     dx = dest_cc->x - src_cc->x;
514     dy = dest_cc->y - src_cc->y;
515     prev_x = x = src_cc->x;
516     prev_y = y = src_cc->y;
517
518     if (dx < 0) {
519         x_change = -1;
520         dx = -dx;
521     } else
522         x_change = 1;
523     if (dy < 0) {
524         y_change = -1;
525         dy = -dy;
526     } else
527         y_change = 1;
528
529     i = err = 0;
530     if (dx < dy) {
531         while (i++ < dy) {
532             prev_x = x;
533             prev_y = y;
534             y += y_change;
535             err += dx << 1;
536             if (err > dy) {
537                 x += x_change;
538                 err -= dy << 1;
539             }
540             /* check for early exit condition */
541             if (!(keep_going = (*check_proc)(arg, x, y)))
542                 break;
543         }
544     } else {
545         while (i++ < dx) {
546             prev_x = x;
547             prev_y = y;
548             x += x_change;
549             err += dy << 1;
550             if (err > dx) {
551                 y += y_change;
552                 err -= dx << 1;
553             }
554             /* check for early exit condition */
555             if (!(keep_going = (*check_proc)(arg, x, y)))
556                 break;
557         }
558     }
559
560     if (keep_going)
561         return TRUE; /* successful */
562
563     dest_cc->x = prev_x;
564     dest_cc->y = prev_y;
565     return FALSE;
566 }
567
568 /*
569  * Single step for the hero flying through the air from jumping, flying,
570  * etc.  Called from hurtle() and jump() via walk_path().  We expect the
571  * argument to be a pointer to an integer -- the range -- which is
572  * used in the calculation of points off if we hit something.
573  *
574  * Bumping into monsters won't cause damage but will wake them and make
575  * them angry.  Auto-pickup isn't done, since you don't have control over
576  * your movements at the time.
577  *
578  * Possible additions/changes:
579  *      o really attack monster if we hit one
580  *      o set stunned if we hit a wall or door
581  *      o reset nomul when we stop
582  *      o creepy feeling if pass through monster (if ever implemented...)
583  *      o bounce off walls
584  *      o let jumps go over boulders
585  */
586 boolean
587 hurtle_step(arg, x, y)
588 genericptr_t arg;
589 int x, y;
590 {
591     int ox, oy, *range = (int *) arg;
592     struct obj *obj;
593     struct monst *mon;
594     boolean may_pass = TRUE;
595     struct trap *ttmp;
596     int dmg = 0;
597
598     if (!isok(x, y)) {
599 /*JP
600         You_feel("the spirits holding you back.");
601 */
602         You_feel("\82 \82È\82½\82ð\95ß\82Ü\82¦\82Ä\82¢\82½\8d°\82ª\96ß\82Á\82½\8bC\82ª\82µ\82½\81D");
603         return FALSE;
604     } else if (!in_out_region(x, y)) {
605         return FALSE;
606     } else if (*range == 0) {
607         return FALSE; /* previous step wants to stop now */
608     }
609
610     if (!Passes_walls || !(may_pass = may_passwall(x, y))) {
611         if (IS_ROCK(levl[x][y].typ) || closed_door(x, y)) {
612             const char *s;
613
614 /*JP
615             pline("Ouch!");
616 */
617             pline("\82¢\82Ä\82Á\81I");
618             if (IS_TREE(levl[x][y].typ))
619 /*JP
620                 s = "bumping into a tree";
621 */
622                 s = "\96Ø\82É\82Ô\82¿\82 \82½\82Á\82Ä";
623             else if (IS_ROCK(levl[x][y].typ))
624 /*JP
625                 s = "bumping into a wall";
626 */
627                 s = "\95Ç\82É\82Ô\82¿\82 \82½\82Á\82Ä";
628             else
629 /*JP
630                 s = "bumping into a door";
631 */
632                 s = "\94à\82É\82Ô\82¿\82 \82½\82Á\82Ä";
633             dmg = rnd(2 + *range);
634             losehp(Maybe_Half_Phys(dmg), s, KILLED_BY);
635             wake_nearto(x,y, 10);
636             return FALSE;
637         }
638         if (levl[x][y].typ == IRONBARS) {
639 /*JP
640             You("crash into some iron bars.  Ouch!");
641 */
642             You("\93S\82Ì\96_\82É\82Ô\82¿\82 \82½\82Á\82½\81D\82¢\82Ä\82Á\81I");
643             dmg = rnd(2 + *range);
644 #if 0 /*JP*/
645             losehp(Maybe_Half_Phys(dmg), "crashing into iron bars",
646                    KILLED_BY);
647 #else
648             losehp(Maybe_Half_Phys(dmg), "\93S\82Ì\96_\82É\82Ô\82¿\82 \82½\82Á\82Ä",
649                    KILLED_BY);
650 #endif
651             wake_nearto(x,y, 20);
652             return FALSE;
653         }
654         if ((obj = sobj_at(BOULDER, x, y)) != 0) {
655 /*JP
656             You("bump into a %s.  Ouch!", xname(obj));
657 */
658             You("%s\82É\82Ô\82¿\82 \82½\82Á\82½\81D\82¢\82Ä\82Á\81I", xname(obj));
659             dmg = rnd(2 + *range);
660 /*JP
661             losehp(Maybe_Half_Phys(dmg), "bumping into a boulder", KILLED_BY);
662 */
663             losehp(Maybe_Half_Phys(dmg), "\8aâ\82É\82Ô\82¿\82 \82½\82Á\82Ä", KILLED_BY);
664             wake_nearto(x,y, 10);
665             return FALSE;
666         }
667         if (!may_pass) {
668             /* did we hit a no-dig non-wall position? */
669 /*JP
670             You("smack into something!");
671 */
672             You("\89½\82©\82É\82Ô\82¿\82 \82½\82Á\82½\81I");
673             dmg = rnd(2 + *range);
674 #if 0 /*JP*/
675             losehp(Maybe_Half_Phys(dmg), "touching the edge of the universe",
676                    KILLED_BY);
677 #else
678             losehp(Maybe_Half_Phys(dmg), "\90¢\8aE\82Ì\89Ê\82Ä\82É\90G\82ê\82Ä",
679                    KILLED_BY);
680 #endif
681             wake_nearto(x,y, 10);
682             return FALSE;
683         }
684         if ((u.ux - x) && (u.uy - y) && bad_rock(youmonst.data, u.ux, y)
685             && bad_rock(youmonst.data, x, u.uy)) {
686             boolean too_much =
687                 (invent && (inv_weight() + weight_cap() > 600));
688             /* Move at a diagonal. */
689             if (bigmonst(youmonst.data) || too_much) {
690 #if 0 /*JP*/
691                 You("%sget forcefully wedged into a crevice.",
692                     too_much ? "and all your belongings " : "");
693 #else
694                 You("%s\82Í\82Þ\82è\82â\82è\82·\82«\8aÔ\82É\89\9f\82µ\8d\9e\82ß\82ç\82ê\82½\81D",
695                     too_much ? "\82Æ\91S\95\94\82Ì\89×\95¨" : "");
696 #endif
697                 dmg = rnd(2 + *range);
698 #if 0 /*JP*/
699                 losehp(Maybe_Half_Phys(dmg), "wedging into a narrow crevice",
700                        KILLED_BY);
701 #else
702                 losehp(Maybe_Half_Phys(dmg), "\8b·\82¢\82·\82«\8aÔ\82É\89\9f\82µ\8d\9e\82ß\82ç\82ê\82Ä",
703                        KILLED_BY);
704 #endif
705                 wake_nearto(x,y, 10);
706                 return FALSE;
707             }
708         }
709     }
710
711     if ((mon = m_at(x, y)) != 0) {
712 /*JP
713         You("bump into %s.", a_monnam(mon));
714 */
715         You("%s\82É\82Ô\82¿\82 \82½\82Á\82½\81D", a_monnam(mon));
716         wakeup(mon);
717         wake_nearto(x,y, 10);
718         return FALSE;
719     }
720     if ((u.ux - x) && (u.uy - y) && bad_rock(youmonst.data, u.ux, y)
721         && bad_rock(youmonst.data, x, u.uy)) {
722         /* Move at a diagonal. */
723         if (Sokoban) {
724 /*JP
725             You("come to an abrupt halt!");
726 */
727             You("\82Æ\82Â\82º\82ñ\92â\8e~\82µ\82½\81I");
728             return FALSE;
729         }
730     }
731
732     ox = u.ux;
733     oy = u.uy;
734     u_on_newpos(x, y); /* set u.<ux,uy>, u.usteed-><mx,my>; cliparound(); */
735     newsym(ox, oy);    /* update old position */
736     vision_recalc(1);  /* update for new position */
737     flush_screen(1);
738     /* FIXME:
739      * Each trap should really trigger on the recoil if
740      * it would trigger during normal movement. However,
741      * not all the possible side-effects of this are
742      * tested [as of 3.4.0] so we trigger those that
743      * we have tested, and offer a message for the
744      * ones that we have not yet tested.
745      */
746     if ((ttmp = t_at(x, y)) != 0) {
747         if (ttmp->ttyp == MAGIC_PORTAL) {
748             dotrap(ttmp, 0);
749             return FALSE;
750         } else if (ttmp->ttyp == VIBRATING_SQUARE) {
751             pline("The ground vibrates as you pass it.");
752             dotrap(ttmp, 0); /* doesn't print messages */
753         } else if (ttmp->ttyp == FIRE_TRAP) {
754             dotrap(ttmp, 0);
755         } else if ((ttmp->ttyp == PIT || ttmp->ttyp == SPIKED_PIT
756                     || ttmp->ttyp == HOLE || ttmp->ttyp == TRAPDOOR)
757                    && Sokoban) {
758             /* Air currents overcome the recoil */
759             dotrap(ttmp, 0);
760             *range = 0;
761             return TRUE;
762         } else {
763             if (ttmp->tseen)
764 #if 0 /*JP*/
765                 You("pass right over %s.",
766                     an(defsyms[trap_to_defsym(ttmp->ttyp)].explanation));
767 #else
768                 You("%s\82Ì\90^\8fã\82ð\92Ê\89ß\82µ\82½\81D",
769                     defsyms[trap_to_defsym(ttmp->ttyp)].explanation);
770 #endif
771         }
772     }
773     if (--*range < 0) /* make sure our range never goes negative */
774         *range = 0;
775     if (*range != 0)
776         delay_output();
777     return TRUE;
778 }
779
780 STATIC_OVL boolean
781 mhurtle_step(arg, x, y)
782 genericptr_t arg;
783 int x, y;
784 {
785     struct monst *mon = (struct monst *) arg;
786
787     /* TODO: Treat walls, doors, iron bars, pools, lava, etc. specially
788      * rather than just stopping before.
789      */
790     if (goodpos(x, y, mon, 0) && m_in_out_region(mon, x, y)) {
791         remove_monster(mon->mx, mon->my);
792         newsym(mon->mx, mon->my);
793         place_monster(mon, x, y);
794         newsym(mon->mx, mon->my);
795         set_apparxy(mon);
796         (void) mintrap(mon);
797         return TRUE;
798     }
799     return FALSE;
800 }
801
802 /*
803  * The player moves through the air for a few squares as a result of
804  * throwing or kicking something.
805  *
806  * dx and dy should be the direction of the hurtle, not of the original
807  * kick or throw and be only.
808  */
809 void
810 hurtle(dx, dy, range, verbose)
811 int dx, dy, range;
812 boolean verbose;
813 {
814     coord uc, cc;
815
816     /* The chain is stretched vertically, so you shouldn't be able to move
817      * very far diagonally.  The premise that you should be able to move one
818      * spot leads to calculations that allow you to only move one spot away
819      * from the ball, if you are levitating over the ball, or one spot
820      * towards the ball, if you are at the end of the chain.  Rather than
821      * bother with all of that, assume that there is no slack in the chain
822      * for diagonal movement, give the player a message and return.
823      */
824     if (Punished && !carried(uball)) {
825 /*JP
826         You_feel("a tug from the iron ball.");
827 */
828         You_feel("\93S\8b\85\82É\82Ð\82Á\82Ï\82ç\82ê\82Ä\82¢\82é\82æ\82¤\82È\8bC\82ª\82µ\82½\81D");
829         nomul(0);
830         return;
831     } else if (u.utrap) {
832 #if 0 /*JP*/
833         You("are anchored by the %s.",
834             u.utraptype == TT_WEB
835                 ? "web"
836                 : u.utraptype == TT_LAVA
837                       ? "lava"
838                       : u.utraptype == TT_INFLOOR
839                             ? surface(u.ux, u.uy)
840                             : u.utraptype == TT_BURIEDBALL ? "buried ball"
841                                                            : "trap");
842 #else
843         You("%s\82É\90\98\82¦\82Â\82¯\82ç\82ê\82Ä\82¢\82é\81D",
844             u.utraptype == TT_WEB
845                 ? "\82­\82à\82Ì\91\83"
846                 : u.utraptype == TT_LAVA
847                       ? "\97n\8aâ"
848                       : u.utraptype == TT_INFLOOR
849                             ? surface(u.ux,u.uy)
850                             : u.utraptype == TT_BURIEDBALL ? "\96\84\82Ü\82Á\82Ä\82¢\82é\8b\85"
851                                                            : "ã©");
852 #endif
853         nomul(0);
854         return;
855     }
856
857     /* make sure dx and dy are [-1,0,1] */
858     dx = sgn(dx);
859     dy = sgn(dy);
860
861     if (!range || (!dx && !dy) || u.ustuck)
862         return; /* paranoia */
863
864     nomul(-range);
865 /*JP
866     multi_reason = "moving through the air";
867 */
868     multi_reason = "\8bó\92\86\82ð\88Ú\93®\82µ\82Ä\82¢\82é\8e\9e\82É";
869     nomovemsg = ""; /* it just happens */
870     if (verbose)
871 /*JP
872         You("%s in the opposite direction.", range > 1 ? "hurtle" : "float");
873 */
874         You("\8bt\95û\8cü\82É\94ò\82Î\82³\82ê\82½\81D");
875     /* if we're in the midst of shooting multiple projectiles, stop */
876     endmultishot(TRUE);
877     sokoban_guilt();
878     uc.x = u.ux;
879     uc.y = u.uy;
880     /* this setting of cc is only correct if dx and dy are [-1,0,1] only */
881     cc.x = u.ux + (dx * range);
882     cc.y = u.uy + (dy * range);
883     (void) walk_path(&uc, &cc, hurtle_step, (genericptr_t) &range);
884 }
885
886 /* Move a monster through the air for a few squares.
887  */
888 void
889 mhurtle(mon, dx, dy, range)
890 struct monst *mon;
891 int dx, dy, range;
892 {
893     coord mc, cc;
894
895     /* At the very least, debilitate the monster */
896     mon->movement = 0;
897     mon->mstun = 1;
898
899     /* Is the monster stuck or too heavy to push?
900      * (very large monsters have too much inertia, even floaters and flyers)
901      */
902     if (mon->data->msize >= MZ_HUGE || mon == u.ustuck || mon->mtrapped)
903         return;
904
905     /* Make sure dx and dy are [-1,0,1] */
906     dx = sgn(dx);
907     dy = sgn(dy);
908     if (!range || (!dx && !dy))
909         return; /* paranoia */
910     /* don't let grid bugs be hurtled diagonally */
911     if (dx && dy && NODIAG(monsndx(mon->data)))
912         return;
913
914     /* Send the monster along the path */
915     mc.x = mon->mx;
916     mc.y = mon->my;
917     cc.x = mon->mx + (dx * range);
918     cc.y = mon->my + (dy * range);
919     (void) walk_path(&mc, &cc, mhurtle_step, (genericptr_t) mon);
920     return;
921 }
922
923 STATIC_OVL void
924 check_shop_obj(obj, x, y, broken)
925 struct obj *obj;
926 xchar x, y;
927 boolean broken;
928 {
929     struct monst *shkp = shop_keeper(*u.ushops);
930
931     if (!shkp)
932         return;
933
934     if (broken || !costly_spot(x, y)
935         || *in_rooms(x, y, SHOPBASE) != *u.ushops) {
936         /* thrown out of a shop or into a different shop */
937         if (is_unpaid(obj))
938             (void) stolen_value(obj, u.ux, u.uy, (boolean) shkp->mpeaceful,
939                                 FALSE);
940         if (broken)
941             obj->no_charge = 1;
942     } else {
943         if (costly_spot(u.ux, u.uy) && costly_spot(x, y)) {
944             if (is_unpaid(obj))
945                 subfrombill(obj, shkp);
946             else if (x != shkp->mx || y != shkp->my)
947                 sellobj(obj, x, y);
948         }
949     }
950 }
951
952 /*
953  * Hero tosses an object upwards with appropriate consequences.
954  *
955  * Returns FALSE if the object is gone.
956  */
957 STATIC_OVL boolean
958 toss_up(obj, hitsroof)
959 struct obj *obj;
960 boolean hitsroof;
961 {
962     const char *action;
963     boolean petrifier = ((obj->otyp == EGG || obj->otyp == CORPSE)
964                          && touch_petrifies(&mons[obj->corpsenm]));
965     /* note: obj->quan == 1 */
966
967     if (!has_ceiling(&u.uz)) {
968 #if 0 /*JP*/
969         action = "flies up into"; /* into "the sky" or "the water above" */
970 #else
971         action = "\82Ì\92\86\82ð\94ò\82ñ\82¾"; /* into "the sky" or "the water above" */
972 #endif
973     } else if (hitsroof) {
974         if (breaktest(obj)) {
975 /*JP
976             pline("%s hits the %s.", Doname2(obj), ceiling(u.ux, u.uy));
977 */
978             pline("%s\82Í%s\82É\96½\92\86\82µ\82½\81D", Doname2(obj), ceiling(u.ux, u.uy));
979             breakmsg(obj, !Blind);
980             breakobj(obj, u.ux, u.uy, TRUE, TRUE);
981             return FALSE;
982         }
983 /*JP
984         action = "hits";
985 */
986         action = "\82É\96½\92\86\82µ\82½";
987     } else {
988 /*JP
989         action = "almost hits";
990 */
991         action = "\82É\82à\82¤\8f­\82µ\82Å\96½\92\86\82·\82é\82Æ\82±\82ë\82¾\82Á\82½";
992     }
993 #if 0 /*JP*/
994     pline("%s %s the %s, then falls back on top of your %s.", Doname2(obj),
995           action, ceiling(u.ux, u.uy), body_part(HEAD));
996 #else
997     pline("%s\82Í%s%s\81C\82»\82µ\82Ä%s\82Ì\8fã\82É\97\8e\82¿\82Ä\82«\82½\81D", Doname2(obj),
998           ceiling(u.ux, u.uy), action, body_part(HEAD));
999 #endif
1000
1001     /* object now hits you */
1002
1003     if (obj->oclass == POTION_CLASS) {
1004         potionhit(&youmonst, obj, TRUE);
1005     } else if (breaktest(obj)) {
1006         int otyp = obj->otyp;
1007         int blindinc;
1008
1009         /* need to check for blindness result prior to destroying obj */
1010         blindinc = ((otyp == CREAM_PIE || otyp == BLINDING_VENOM)
1011                     /* AT_WEAP is ok here even if attack type was AT_SPIT */
1012                     && can_blnd(&youmonst, &youmonst, AT_WEAP, obj))
1013                        ? rnd(25)
1014                        : 0;
1015         breakmsg(obj, !Blind);
1016         breakobj(obj, u.ux, u.uy, TRUE, TRUE);
1017         obj = 0; /* it's now gone */
1018         switch (otyp) {
1019         case EGG:
1020             if (petrifier && !Stone_resistance
1021                 && !(poly_when_stoned(youmonst.data)
1022                      && polymon(PM_STONE_GOLEM))) {
1023                 /* egg ends up "all over your face"; perhaps
1024                    visored helmet should still save you here */
1025                 if (uarmh)
1026 /*JP
1027                     Your("%s fails to protect you.", helm_simple_name(uarmh));
1028 */
1029                     Your("%s\82Í\82 \82È\82½\82ð\8eç\82ê\82È\82©\82Á\82½\81D", helm_simple_name(uarmh));
1030                 goto petrify;
1031             }
1032         case CREAM_PIE:
1033         case BLINDING_VENOM:
1034 /*JP
1035             pline("You've got it all over your %s!", body_part(FACE));
1036 */
1037             pline("\82»\82ê\82Í%s\82ð\82×\82Á\82Æ\82è\82Æ\95¢\82Á\82½\81I", body_part(FACE));
1038             if (blindinc) {
1039                 if (otyp == BLINDING_VENOM && !Blind)
1040 /*JP
1041                     pline("It blinds you!");
1042 */
1043                     pline("\96Ú\82ª\8c©\82¦\82È\82­\82È\82Á\82½\81I");
1044                 u.ucreamed += blindinc;
1045                 make_blinded(Blinded + (long) blindinc, FALSE);
1046                 if (!Blind)
1047                     Your1(vision_clears);
1048             }
1049             break;
1050         default:
1051             break;
1052         }
1053         return FALSE;
1054     } else { /* neither potion nor other breaking object */
1055         boolean less_damage = uarmh && is_metallic(uarmh), artimsg = FALSE;
1056         int dmg = dmgval(obj, &youmonst);
1057
1058         if (obj->oartifact)
1059             /* need a fake die roll here; rn1(18,2) avoids 1 and 20 */
1060             artimsg = artifact_hit((struct monst *) 0, &youmonst, obj, &dmg,
1061                                    rn1(18, 2));
1062
1063         if (!dmg) { /* probably wasn't a weapon; base damage on weight */
1064             dmg = (int) obj->owt / 100;
1065             if (dmg < 1)
1066                 dmg = 1;
1067             else if (dmg > 6)
1068                 dmg = 6;
1069             if (youmonst.data == &mons[PM_SHADE]
1070                 && objects[obj->otyp].oc_material != SILVER)
1071                 dmg = 0;
1072         }
1073         if (dmg > 1 && less_damage)
1074             dmg = 1;
1075         if (dmg > 0)
1076             dmg += u.udaminc;
1077         if (dmg < 0)
1078             dmg = 0; /* beware negative rings of increase damage */
1079         dmg = Maybe_Half_Phys(dmg);
1080
1081         if (uarmh) {
1082             if (less_damage && dmg < (Upolyd ? u.mh : u.uhp)) {
1083                 if (!artimsg)
1084 /*JP
1085                     pline("Fortunately, you are wearing a hard helmet.");
1086 */
1087                     pline("\8dK\89^\82É\82à\81C\82 \82È\82½\82Í\8cÅ\82¢\8a\95\82ð\90g\82É\82Â\82¯\82Ä\82¢\82½\81D");
1088                 /* helmet definitely protects you when it blocks petrification
1089                  */
1090             } else if (!petrifier) {
1091                 if (flags.verbose)
1092 /*JP
1093                     Your("%s does not protect you.", helm_simple_name(uarmh));
1094 */
1095                     Your("%s\82Å\82Í\96h\82¬\82«\82ê\82È\82©\82Á\82½\81D", helm_simple_name(uarmh));
1096             }
1097         } else if (petrifier && !Stone_resistance
1098                    && !(poly_when_stoned(youmonst.data)
1099                         && polymon(PM_STONE_GOLEM))) {
1100         petrify:
1101             killer.format = KILLED_BY;
1102 #if 0 /*JP*/
1103             Strcpy(killer.name, "elementary physics"); /* "what goes up..." */
1104 #else
1105             Strcpy(killer.name, "\8f\89\93\99\95¨\97\9d\82É\82æ\82è"); /* "what goes up..." */
1106 #endif
1107 /*JP
1108             You("turn to stone.");
1109 */
1110             You("\90Î\82É\82È\82Á\82½\81D");
1111             if (obj)
1112                 dropy(obj); /* bypass most of hitfloor() */
1113             thrownobj = 0;  /* now either gone or on floor */
1114             done(STONING);
1115             return obj ? TRUE : FALSE;
1116         }
1117         hitfloor(obj);
1118         thrownobj = 0;
1119 #if 0 /*JP*/
1120         losehp(Maybe_Half_Phys(dmg), "falling object", KILLED_BY_AN);
1121 #else
1122         losehp(Maybe_Half_Phys(dmg), "\97\8e\89º\95¨\82Å", KILLED_BY_AN);
1123 #endif
1124     }
1125     return TRUE;
1126 }
1127
1128 /* return true for weapon meant to be thrown; excludes ammo */
1129 STATIC_OVL boolean
1130 throwing_weapon(obj)
1131 struct obj *obj;
1132 {
1133     return (boolean) (is_missile(obj) || is_spear(obj)
1134                       /* daggers and knife (excludes scalpel) */
1135                       || (is_blade(obj) && !is_sword(obj)
1136                           && (objects[obj->otyp].oc_dir & PIERCE))
1137                       /* special cases [might want to add AXE] */
1138                       || obj->otyp == WAR_HAMMER || obj->otyp == AKLYS);
1139 }
1140
1141 /* the currently thrown object is returning to you (not for boomerangs) */
1142 STATIC_OVL void
1143 sho_obj_return_to_u(obj)
1144 struct obj *obj;
1145 {
1146     /* might already be our location (bounced off a wall) */
1147     if (bhitpos.x != u.ux || bhitpos.y != u.uy) {
1148         int x = bhitpos.x - u.dx, y = bhitpos.y - u.dy;
1149
1150         tmp_at(DISP_FLASH, obj_to_glyph(obj));
1151         while (x != u.ux || y != u.uy) {
1152             tmp_at(x, y);
1153             delay_output();
1154             x -= u.dx;
1155             y -= u.dy;
1156         }
1157         tmp_at(DISP_END, 0);
1158     }
1159 }
1160
1161 /* throw an object, NB: obj may be consumed in the process */
1162 void
1163 throwit(obj, wep_mask, twoweap)
1164 struct obj *obj;
1165 long wep_mask; /* used to re-equip returning boomerang */
1166 boolean
1167     twoweap; /* used to restore twoweapon mode if wielded weapon returns */
1168 {
1169     register struct monst *mon;
1170     register int range, urange;
1171     boolean crossbowing, impaired = (Confusion || Stunned || Blind
1172                                      || Hallucination || Fumbling);
1173
1174     notonhead = FALSE; /* reset potentially stale value */
1175     if ((obj->cursed || obj->greased) && (u.dx || u.dy) && !rn2(7)) {
1176         boolean slipok = TRUE;
1177         if (ammo_and_launcher(obj, uwep))
1178 /*JP
1179             pline("%s!", Tobjnam(obj, "misfire"));
1180 */
1181             pline("%s\82Í\82Í\82¸\82ê\82½\81I", xname(obj));
1182         else {
1183             /* only slip if it's greased or meant to be thrown */
1184             if (obj->greased || throwing_weapon(obj))
1185                 /* BUG: this message is grammatically incorrect if obj has
1186                    a plural name; greased gloves or boots for instance. */
1187 /*JP
1188                 pline("%s as you throw it!", Tobjnam(obj, "slip"));
1189 */
1190                 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));
1191             else
1192                 slipok = FALSE;
1193         }
1194         if (slipok) {
1195             u.dx = rn2(3) - 1;
1196             u.dy = rn2(3) - 1;
1197             if (!u.dx && !u.dy)
1198                 u.dz = 1;
1199             impaired = TRUE;
1200         }
1201     }
1202
1203     if ((u.dx || u.dy || (u.dz < 1))
1204         && calc_capacity((int) obj->owt) > SLT_ENCUMBER
1205         && (Upolyd ? (u.mh < 5 && u.mh != u.mhmax)
1206                    : (u.uhp < 10 && u.uhp != u.uhpmax))
1207         && obj->owt > (unsigned) ((Upolyd ? u.mh : u.uhp) * 2)
1208         && !Is_airlevel(&u.uz)) {
1209 /*JP
1210         You("have so little stamina, %s drops from your grasp.",
1211 */
1212         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",
1213             the(xname(obj)));
1214         exercise(A_CON, FALSE);
1215         u.dx = u.dy = 0;
1216         u.dz = 1;
1217     }
1218
1219     thrownobj = obj;
1220     thrownobj->was_thrown = 1;
1221
1222     if (u.uswallow) {
1223         mon = u.ustuck;
1224         bhitpos.x = mon->mx;
1225         bhitpos.y = mon->my;
1226     } else if (u.dz) {
1227         if (u.dz < 0 && Role_if(PM_VALKYRIE) && obj->oartifact == ART_MJOLLNIR
1228             && !impaired) {
1229 #if 0 /*JP*/
1230             pline("%s the %s and returns to your hand!", Tobjnam(obj, "hit"),
1231                   ceiling(u.ux, u.uy));
1232 #else
1233             pline("%s\82Í%s\82É\96½\92\86\82µ\82 \82È\82½\82Ì\8eè\82É\96ß\82Á\82Ä\82«\82½\81I", xname(obj),
1234                   ceiling(u.ux,u.uy));
1235 #endif
1236             obj = addinv(obj);
1237             (void) encumber_msg();
1238             setuwep(obj);
1239             u.twoweap = twoweap;
1240         } else if (u.dz < 0) {
1241             (void) toss_up(obj, rn2(5) && !Underwater);
1242         } else if (u.dz > 0 && u.usteed && obj->oclass == POTION_CLASS
1243                    && rn2(6)) {
1244             /* alternative to prayer or wand of opening/spell of knock
1245                for dealing with cursed saddle:  throw holy water > */
1246             potionhit(u.usteed, obj, TRUE);
1247         } else {
1248             hitfloor(obj);
1249         }
1250         thrownobj = (struct obj *) 0;
1251         return;
1252
1253     } else if (obj->otyp == BOOMERANG && !Underwater) {
1254         if (Is_airlevel(&u.uz) || Levitation)
1255             hurtle(-u.dx, -u.dy, 1, TRUE);
1256         mon = boomhit(obj, u.dx, u.dy);
1257         if (mon == &youmonst) { /* the thing was caught */
1258             exercise(A_DEX, TRUE);
1259             obj = addinv(obj);
1260             (void) encumber_msg();
1261             if (wep_mask && !(obj->owornmask & wep_mask)) {
1262                 setworn(obj, wep_mask);
1263                 u.twoweap = twoweap;
1264             }
1265             thrownobj = (struct obj *) 0;
1266             return;
1267         }
1268     } else {
1269         /* crossbow range is independent of strength */
1270         crossbowing =
1271             (ammo_and_launcher(obj, uwep) && weapon_type(uwep) == P_CROSSBOW);
1272         urange = (crossbowing ? 18 : (int) ACURRSTR) / 2;
1273         /* balls are easy to throw or at least roll;
1274          * also, this insures the maximum range of a ball is greater
1275          * than 1, so the effects from throwing attached balls are
1276          * actually possible
1277          */
1278         if (obj->otyp == HEAVY_IRON_BALL)
1279             range = urange - (int) (obj->owt / 100);
1280         else
1281             range = urange - (int) (obj->owt / 40);
1282         if (obj == uball) {
1283             if (u.ustuck)
1284                 range = 1;
1285             else if (range >= 5)
1286                 range = 5;
1287         }
1288         if (range < 1)
1289             range = 1;
1290
1291         if (is_ammo(obj)) {
1292             if (ammo_and_launcher(obj, uwep)) {
1293                 if (crossbowing)
1294                     range = BOLT_LIM;
1295                 else
1296                     range++;
1297             } else if (obj->oclass != GEM_CLASS)
1298                 range /= 2;
1299         }
1300
1301         if (Is_airlevel(&u.uz) || Levitation) {
1302             /* action, reaction... */
1303             urange -= range;
1304             if (urange < 1)
1305                 urange = 1;
1306             range -= urange;
1307             if (range < 1)
1308                 range = 1;
1309         }
1310
1311         if (obj->otyp == BOULDER)
1312             range = 20; /* you must be giant */
1313         else if (obj->oartifact == ART_MJOLLNIR)
1314             range = (range + 1) / 2; /* it's heavy */
1315         else if (obj == uball && u.utrap && u.utraptype == TT_INFLOOR)
1316             range = 1;
1317
1318         if (Underwater)
1319             range = 1;
1320
1321         mon = bhit(u.dx, u.dy, range, THROWN_WEAPON,
1322                    (int FDECL((*), (MONST_P, OBJ_P))) 0,
1323                    (int FDECL((*), (OBJ_P, OBJ_P))) 0, &obj);
1324         thrownobj = obj; /* obj may be null now */
1325
1326         /* have to do this after bhit() so u.ux & u.uy are correct */
1327         if (Is_airlevel(&u.uz) || Levitation)
1328             hurtle(-u.dx, -u.dy, urange, TRUE);
1329
1330         if (!obj)
1331             return;
1332     }
1333
1334     if (mon) {
1335         boolean obj_gone;
1336
1337         if (mon->isshk && obj->where == OBJ_MINVENT && obj->ocarry == mon) {
1338             thrownobj = (struct obj *) 0;
1339             return; /* alert shk caught it */
1340         }
1341         (void) snuff_candle(obj);
1342         notonhead = (bhitpos.x != mon->mx || bhitpos.y != mon->my);
1343         obj_gone = thitmonst(mon, obj);
1344         /* Monster may have been tamed; this frees old mon */
1345         mon = m_at(bhitpos.x, bhitpos.y);
1346
1347         /* [perhaps this should be moved into thitmonst or hmon] */
1348         if (mon && mon->isshk
1349             && (!inside_shop(u.ux, u.uy)
1350                 || !index(in_rooms(mon->mx, mon->my, SHOPBASE), *u.ushops)))
1351             hot_pursuit(mon);
1352
1353         if (obj_gone)
1354             thrownobj = 0;
1355     }
1356
1357     if (!thrownobj) {
1358         ; /* missile has already been handled */
1359     } else if (u.uswallow) {
1360         /* ball is not picked up by monster */
1361         if (obj != uball)
1362             (void) mpickobj(u.ustuck, obj);
1363         thrownobj = (struct obj *) 0;
1364     } else {
1365         /* the code following might become part of dropy() */
1366         if (obj->oartifact == ART_MJOLLNIR && Role_if(PM_VALKYRIE)
1367             && rn2(100)) {
1368             /* we must be wearing Gauntlets of Power to get here */
1369             sho_obj_return_to_u(obj); /* display its flight */
1370
1371             if (!impaired && rn2(100)) {
1372 /*JP
1373                 pline("%s to your hand!", Tobjnam(obj, "return"));
1374 */
1375                 pline("%s\82Í\82 \82È\82½\82Ì\8eè\82É\96ß\82Á\82Ä\82«\82½\81I", xname(obj));
1376                 obj = addinv(obj);
1377                 (void) encumber_msg();
1378                 setuwep(obj);
1379                 u.twoweap = twoweap;
1380                 if (cansee(bhitpos.x, bhitpos.y))
1381                     newsym(bhitpos.x, bhitpos.y);
1382             } else {
1383                 int dmg = rn2(2);
1384                 if (!dmg) {
1385 #if 0 /*JP*/
1386                     pline(Blind ? "%s lands %s your %s."
1387                                 : "%s back to you, landing %s your %s.",
1388                           Blind ? Something : Tobjnam(obj, "return"),
1389                           Levitation ? "beneath" : "at",
1390                           makeplural(body_part(FOOT)));
1391 #else
1392                     pline("%s\82Í%s\82 \82È\82½\82Ì%s\82Ì%s\82É\97\8e\82¿\82½\81D",
1393                           xname(obj),
1394                           Blind ? "" : "\96ß\82Á\82Ä\82«\82Ä\81C",
1395                           body_part(FOOT),
1396                           Levitation ? "\89º" : "\82»\82Î");
1397 #endif
1398                 } else {
1399                     dmg += rnd(3);
1400 #if 0 /*JP*/
1401                     pline(Blind ? "%s your %s!"
1402                                 : "%s back toward you, hitting your %s!",
1403                           Tobjnam(obj, Blind ? "hit" : "fly"),
1404                           body_part(ARM));
1405 #else
1406                     pline("%s\82Í%s\82 \82È\82½\82Ì%s\82É\96½\92\86\82µ\82½\81I",
1407                           xname(obj),
1408                           Blind ? "" : "\96ß\82Á\82Ä\82«\82Ä\81C",
1409                           body_part(ARM));
1410 #endif
1411                     (void) artifact_hit((struct monst *) 0, &youmonst, obj,
1412                                         &dmg, 0);
1413 #if 0 /*JP*/
1414                     losehp(Maybe_Half_Phys(dmg), killer_xname(obj),
1415                            KILLED_BY);
1416 #else
1417                     {
1418                         char jbuf[BUFSZ];
1419                         Sprintf(jbuf, "%s\82Å", xname(obj));
1420                         losehp(Maybe_Half_Phys(dmg), jbuf, KILLED_BY);
1421                     }
1422 #endif
1423                 }
1424                 if (ship_object(obj, u.ux, u.uy, FALSE)) {
1425                     thrownobj = (struct obj *) 0;
1426                     return;
1427                 }
1428                 dropy(obj);
1429             }
1430             thrownobj = (struct obj *) 0;
1431             return;
1432         }
1433
1434         if (!IS_SOFT(levl[bhitpos.x][bhitpos.y].typ) && breaktest(obj)) {
1435             tmp_at(DISP_FLASH, obj_to_glyph(obj));
1436             tmp_at(bhitpos.x, bhitpos.y);
1437             delay_output();
1438             tmp_at(DISP_END, 0);
1439             breakmsg(obj, cansee(bhitpos.x, bhitpos.y));
1440             breakobj(obj, bhitpos.x, bhitpos.y, TRUE, TRUE);
1441             thrownobj = (struct obj *) 0;
1442             return;
1443         }
1444 /*JP
1445         if (flooreffects(obj, bhitpos.x, bhitpos.y, "fall")) {
1446 */
1447         if (flooreffects(obj,bhitpos.x, bhitpos.y, "\97\8e\82¿\82é")) {
1448             thrownobj = (struct obj *) 0;
1449             return;
1450         }
1451         obj_no_longer_held(obj);
1452         if (mon && mon->isshk && is_pick(obj)) {
1453             if (cansee(bhitpos.x, bhitpos.y))
1454 /*JP
1455                 pline("%s snatches up %s.", Monnam(mon), the(xname(obj)));
1456 */
1457                 pline("%s\82Í%s\82ð\92D\82¢\82Æ\82Á\82½\81D", Monnam(mon), xname(obj));
1458             if (*u.ushops || obj->unpaid)
1459                 check_shop_obj(obj, bhitpos.x, bhitpos.y, FALSE);
1460             (void) mpickobj(mon, obj); /* may merge and free obj */
1461             thrownobj = (struct obj *) 0;
1462             return;
1463         }
1464         (void) snuff_candle(obj);
1465         if (!mon && ship_object(obj, bhitpos.x, bhitpos.y, FALSE)) {
1466             thrownobj = (struct obj *) 0;
1467             return;
1468         }
1469         thrownobj = (struct obj *) 0;
1470         place_object(obj, bhitpos.x, bhitpos.y);
1471         /* container contents might break;
1472            do so before turning ownership of thrownobj over to shk
1473            (container_impact_dmg handles item already owned by shop) */
1474         if (!IS_SOFT(levl[bhitpos.x][bhitpos.y].typ))
1475             /* <x,y> is spot where you initiated throw, not bhitpos */
1476             container_impact_dmg(obj, u.ux, u.uy);
1477         /* charge for items thrown out of shop;
1478            shk takes possession for items thrown into one */
1479         if ((*u.ushops || obj->unpaid) && obj != uball)
1480             check_shop_obj(obj, bhitpos.x, bhitpos.y, FALSE);
1481
1482         stackobj(obj);
1483         if (obj == uball)
1484             drop_ball(bhitpos.x, bhitpos.y);
1485         if (cansee(bhitpos.x, bhitpos.y))
1486             newsym(bhitpos.x, bhitpos.y);
1487         if (obj_sheds_light(obj))
1488             vision_full_recalc = 1;
1489     }
1490 }
1491
1492 /* an object may hit a monster; various factors adjust the chance of hitting
1493  */
1494 int
1495 omon_adj(mon, obj, mon_notices)
1496 struct monst *mon;
1497 struct obj *obj;
1498 boolean mon_notices;
1499 {
1500     int tmp = 0;
1501
1502     /* size of target affects the chance of hitting */
1503     tmp += (mon->data->msize - MZ_MEDIUM); /* -2..+5 */
1504     /* sleeping target is more likely to be hit */
1505     if (mon->msleeping) {
1506         tmp += 2;
1507         if (mon_notices)
1508             mon->msleeping = 0;
1509     }
1510     /* ditto for immobilized target */
1511     if (!mon->mcanmove || !mon->data->mmove) {
1512         tmp += 4;
1513         if (mon_notices && mon->data->mmove && !rn2(10)) {
1514             mon->mcanmove = 1;
1515             mon->mfrozen = 0;
1516         }
1517     }
1518     /* some objects are more likely to hit than others */
1519     switch (obj->otyp) {
1520     case HEAVY_IRON_BALL:
1521         if (obj != uball)
1522             tmp += 2;
1523         break;
1524     case BOULDER:
1525         tmp += 6;
1526         break;
1527     default:
1528         if (obj->oclass == WEAPON_CLASS || is_weptool(obj)
1529             || obj->oclass == GEM_CLASS)
1530             tmp += hitval(obj, mon);
1531         break;
1532     }
1533     return tmp;
1534 }
1535
1536 /* thrown object misses target monster */
1537 STATIC_OVL void
1538 tmiss(obj, mon, maybe_wakeup)
1539 struct obj *obj;
1540 struct monst *mon;
1541 boolean maybe_wakeup;
1542 {
1543     const char *missile = mshot_xname(obj);
1544
1545     /* If the target can't be seen or doesn't look like a valid target,
1546        avoid "the arrow misses it," or worse, "the arrows misses the mimic."
1547        An attentive player will still notice that this is different from
1548        an arrow just landing short of any target (no message in that case),
1549        so will realize that there is a valid target here anyway. */
1550     if (!canseemon(mon) || (mon->m_ap_type && mon->m_ap_type != M_AP_MONSTER))
1551 /*JP
1552         pline("%s %s.", The(missile), otense(obj, "miss"));
1553 */
1554         pline("%s\82Í\82Í\82¸\82ê\82½\81D", missile);
1555     else
1556         miss(missile, mon);
1557     if (maybe_wakeup && !rn2(3))
1558         wakeup(mon);
1559     return;
1560 }
1561
1562 #define quest_arti_hits_leader(obj, mon)      \
1563     (obj->oartifact && is_quest_artifact(obj) \
1564      && mon->m_id == quest_status.leader_m_id)
1565
1566 /*
1567  * Object thrown by player arrives at monster's location.
1568  * Return 1 if obj has disappeared or otherwise been taken care of,
1569  * 0 if caller must take care of it.
1570  * Also used for kicked objects and for polearms/grapnel applied at range.
1571  */
1572 int
1573 thitmonst(mon, obj)
1574 register struct monst *mon;
1575 register struct obj *obj; /* thrownobj or kickedobj or uwep */
1576 {
1577     register int tmp;     /* Base chance to hit */
1578     register int disttmp; /* distance modifier */
1579     int otyp = obj->otyp, hmode;
1580     boolean guaranteed_hit = (u.uswallow && mon == u.ustuck);
1581
1582     hmode = (obj == uwep) ? HMON_APPLIED : (obj == kickedobj) ? HMON_KICKED
1583                                                               : HMON_THROWN;
1584
1585     /* Differences from melee weapons:
1586      *
1587      * Dex still gives a bonus, but strength does not.
1588      * Polymorphed players lacking attacks may still throw.
1589      * There's a base -1 to hit.
1590      * No bonuses for fleeing or stunned targets (they don't dodge
1591      *    melee blows as readily, but dodging arrows is hard anyway).
1592      * Not affected by traps, etc.
1593      * Certain items which don't in themselves do damage ignore tmp.
1594      * Distance and monster size affect chance to hit.
1595      */
1596     tmp = -1 + Luck + find_mac(mon) + u.uhitinc
1597           + maybe_polyd(youmonst.data->mlevel, u.ulevel);
1598     if (ACURR(A_DEX) < 4)
1599         tmp -= 3;
1600     else if (ACURR(A_DEX) < 6)
1601         tmp -= 2;
1602     else if (ACURR(A_DEX) < 8)
1603         tmp -= 1;
1604     else if (ACURR(A_DEX) >= 14)
1605         tmp += (ACURR(A_DEX) - 14);
1606
1607     /* Modify to-hit depending on distance; but keep it sane.
1608      * Polearms get a distance penalty even when wielded; it's
1609      * hard to hit at a distance.
1610      */
1611     disttmp = 3 - distmin(u.ux, u.uy, mon->mx, mon->my);
1612     if (disttmp < -4)
1613         disttmp = -4;
1614     tmp += disttmp;
1615
1616     /* gloves are a hindrance to proper use of bows */
1617     if (uarmg && uwep && objects[uwep->otyp].oc_skill == P_BOW) {
1618         switch (uarmg->otyp) {
1619         case GAUNTLETS_OF_POWER: /* metal */
1620             tmp -= 2;
1621             break;
1622         case GAUNTLETS_OF_FUMBLING:
1623             tmp -= 3;
1624             break;
1625         case LEATHER_GLOVES:
1626         case GAUNTLETS_OF_DEXTERITY:
1627             break;
1628         default:
1629             impossible("Unknown type of gloves (%d)", uarmg->otyp);
1630             break;
1631         }
1632     }
1633
1634     tmp += omon_adj(mon, obj, TRUE);
1635     if (is_orc(mon->data)
1636         && maybe_polyd(is_elf(youmonst.data), Race_if(PM_ELF)))
1637         tmp++;
1638     if (guaranteed_hit) {
1639         tmp += 1000; /* Guaranteed hit */
1640     }
1641
1642     if (obj->oclass == GEM_CLASS && is_unicorn(mon->data)) {
1643         if (mon->msleeping || !mon->mcanmove) {
1644             tmiss(obj, mon, FALSE);
1645             return 0;
1646         } else if (mon->mtame) {
1647 /*JP
1648             pline("%s catches and drops %s.", Monnam(mon), the(xname(obj)));
1649 */
1650             pline("%s\82Í%s\82ð\82­\82í\82¦\82Ä\92u\82¢\82½\81D", Monnam(mon), xname(obj));
1651             return 0;
1652         } else {
1653 /*JP
1654             pline("%s catches %s.", Monnam(mon), the(xname(obj)));
1655 */
1656             pline("%s\82Í%s\82ð\82­\82í\82¦\82½\81D", Monnam(mon), xname(obj));
1657             return gem_accept(mon, obj);
1658         }
1659     }
1660
1661     /* don't make game unwinnable if naive player throws artifact
1662        at leader... (kicked artifact is ok too; HMON_APPLIED could
1663        occur if quest artifact polearm or grapnel ever gets added) */
1664     if (hmode != HMON_APPLIED && quest_arti_hits_leader(obj, mon)) {
1665         /* not wakeup(), which angers non-tame monsters */
1666         mon->msleeping = 0;
1667         mon->mstrategy &= ~STRAT_WAITMASK;
1668
1669         if (mon->mcanmove) {
1670 /*JP
1671             pline("%s catches %s.", Monnam(mon), the(xname(obj)));
1672 */
1673             pline("%s\82Í%s\82ð\92Í\82ñ\82¾\81D", Monnam(mon), xname(obj));
1674             if (mon->mpeaceful) {
1675                 boolean next2u = monnear(mon, u.ux, u.uy);
1676
1677                 finish_quest(obj); /* acknowledge quest completion */
1678 #if 0 /*JP*/
1679                 pline("%s %s %s back to you.", Monnam(mon),
1680                       (next2u ? "hands" : "tosses"), the(xname(obj)));
1681 #else
1682                 pline("%s\82Í%s\82ð\82 \82È\82½\82É\95Ô\82µ\82½\81D", Monnam(mon),
1683                       xname(obj));
1684 #endif
1685                 if (!next2u)
1686                     sho_obj_return_to_u(obj);
1687                 obj = addinv(obj); /* back into your inventory */
1688                 (void) encumber_msg();
1689             } else {
1690                 /* angry leader caught it and isn't returning it */
1691                 if (*u.ushops || obj->unpaid) /* not very likely... */
1692                     check_shop_obj(obj, mon->mx, mon->my, FALSE);
1693                 (void) mpickobj(mon, obj);
1694             }
1695             return 1; /* caller doesn't need to place it */
1696         }
1697         return 0;
1698     }
1699
1700     if (obj->oclass == WEAPON_CLASS || is_weptool(obj)
1701         || obj->oclass == GEM_CLASS) {
1702         if (hmode == HMON_KICKED) {
1703             /* throwing adjustments and weapon skill bonus don't apply */
1704             tmp -= (is_ammo(obj) ? 5 : 3);
1705         } else if (is_ammo(obj)) {
1706             if (!ammo_and_launcher(obj, uwep)) {
1707                 tmp -= 4;
1708             } else {
1709                 tmp += uwep->spe - greatest_erosion(uwep);
1710                 tmp += weapon_hit_bonus(uwep);
1711                 if (uwep->oartifact)
1712                     tmp += spec_abon(uwep, mon);
1713                 /*
1714                  * Elves and Samurais are highly trained w/bows,
1715                  * especially their own special types of bow.
1716                  * Polymorphing won't make you a bow expert.
1717                  */
1718                 if ((Race_if(PM_ELF) || Role_if(PM_SAMURAI))
1719                     && (!Upolyd || your_race(youmonst.data))
1720                     && objects[uwep->otyp].oc_skill == P_BOW) {
1721                     tmp++;
1722                     if (Race_if(PM_ELF) && uwep->otyp == ELVEN_BOW)
1723                         tmp++;
1724                     else if (Role_if(PM_SAMURAI) && uwep->otyp == YUMI)
1725                         tmp++;
1726                 }
1727             }
1728         } else { /* thrown non-ammo or applied polearm/grapnel */
1729             if (otyp == BOOMERANG) /* arbitrary */
1730                 tmp += 4;
1731             else if (throwing_weapon(obj)) /* meant to be thrown */
1732                 tmp += 2;
1733             else if (obj == thrownobj) /* not meant to be thrown */
1734                 tmp -= 2;
1735             /* we know we're dealing with a weapon or weptool handled
1736                by WEAPON_SKILLS once ammo objects have been excluded */
1737             tmp += weapon_hit_bonus(obj);
1738         }
1739
1740         if (tmp >= rnd(20)) {
1741             if (hmode == HMON_APPLIED)
1742                 u.uconduct.weaphit++;
1743             if (hmon(mon, obj, hmode)) { /* mon still alive */
1744                 cutworm(mon, bhitpos.x, bhitpos.y, obj);
1745             }
1746             exercise(A_DEX, TRUE);
1747             /* if hero is swallowed and projectile kills the engulfer,
1748                obj gets added to engulfer's inventory and then dropped,
1749                so we can't safely use that pointer anymore; it escapes
1750                the chance to be used up here... */
1751             if (!thrownobj)
1752                 return 1;
1753             /* projectiles other than magic stones
1754                sometimes disappear when thrown */
1755             if (objects[otyp].oc_skill < P_NONE
1756                 && objects[otyp].oc_skill > -P_BOOMERANG
1757                 && !objects[otyp].oc_magic) {
1758                 /* we were breaking 2/3 of everything unconditionally.
1759                  * we still don't want anything to survive unconditionally,
1760                  * but we need ammo to stay around longer on average.
1761                  */
1762                 int broken, chance;
1763                 chance = 3 + greatest_erosion(obj) - obj->spe;
1764                 if (chance > 1)
1765                     broken = rn2(chance);
1766                 else
1767                     broken = !rn2(4);
1768                 if (obj->blessed && !rnl(4))
1769                     broken = 0;
1770
1771                 if (broken) {
1772                     if (*u.ushops || obj->unpaid)
1773                         check_shop_obj(obj, bhitpos.x, bhitpos.y, TRUE);
1774                     obfree(obj, (struct obj *) 0);
1775                     return 1;
1776                 }
1777             }
1778             passive_obj(mon, obj, (struct attack *) 0);
1779         } else {
1780             tmiss(obj, mon, TRUE);
1781             if (hmode == HMON_APPLIED)
1782                 wakeup(mon);
1783         }
1784
1785     } else if (otyp == HEAVY_IRON_BALL) {
1786         exercise(A_STR, TRUE);
1787         if (tmp >= rnd(20)) {
1788             int was_swallowed = guaranteed_hit;
1789
1790             exercise(A_DEX, TRUE);
1791             if (!hmon(mon, obj, hmode)) { /* mon killed */
1792                 if (was_swallowed && !u.uswallow && obj == uball)
1793                     return 1; /* already did placebc() */
1794             }
1795         } else {
1796             tmiss(obj, mon, TRUE);
1797         }
1798
1799     } else if (otyp == BOULDER) {
1800         exercise(A_STR, TRUE);
1801         if (tmp >= rnd(20)) {
1802             exercise(A_DEX, TRUE);
1803             (void) hmon(mon, obj, hmode);
1804         } else {
1805             tmiss(obj, mon, TRUE);
1806         }
1807
1808     } else if ((otyp == EGG || otyp == CREAM_PIE || otyp == BLINDING_VENOM
1809                 || otyp == ACID_VENOM)
1810                && (guaranteed_hit || ACURR(A_DEX) > rnd(25))) {
1811         (void) hmon(mon, obj, hmode);
1812         return 1; /* hmon used it up */
1813
1814     } else if (obj->oclass == POTION_CLASS
1815                && (guaranteed_hit || ACURR(A_DEX) > rnd(25))) {
1816         potionhit(mon, obj, TRUE);
1817         return 1;
1818
1819     } else if (befriend_with_obj(mon->data, obj)
1820                || (mon->mtame && dogfood(mon, obj) <= ACCFOOD)) {
1821         if (tamedog(mon, obj)) {
1822             return 1; /* obj is gone */
1823         } else {
1824             tmiss(obj, mon, FALSE);
1825             mon->msleeping = 0;
1826             mon->mstrategy &= ~STRAT_WAITMASK;
1827         }
1828     } else if (guaranteed_hit) {
1829         /* this assumes that guaranteed_hit is due to swallowing */
1830         wakeup(mon);
1831         if (obj->otyp == CORPSE && touch_petrifies(&mons[obj->corpsenm])) {
1832             if (is_animal(u.ustuck->data)) {
1833                 minstapetrify(u.ustuck, TRUE);
1834                 /* Don't leave a cockatrice corpse available in a statue */
1835                 if (!u.uswallow) {
1836                     delobj(obj);
1837                     return 1;
1838                 }
1839             }
1840         }
1841 #if 0 /*JP*/
1842         pline("%s into %s %s.", Tobjnam(obj, "vanish"),
1843               s_suffix(mon_nam(mon)),
1844               is_animal(u.ustuck->data) ? "entrails" : "currents");
1845 #else
1846         pline("%s\82Í%s\82Ì%s\82Ö\8fÁ\82¦\82½\81D", xname(obj),
1847               mon_nam(mon),
1848               is_animal(u.ustuck->data) ? "\93à\91\9f\82Ì\92\86" : "\97¬\82ê");
1849 #endif
1850     } else {
1851         tmiss(obj, mon, TRUE);
1852     }
1853
1854     return 0;
1855 }
1856
1857 STATIC_OVL int
1858 gem_accept(mon, obj)
1859 register struct monst *mon;
1860 register struct obj *obj;
1861 {
1862     char buf[BUFSZ];
1863     boolean is_buddy = sgn(mon->data->maligntyp) == sgn(u.ualign.type);
1864     boolean is_gem = objects[obj->otyp].oc_material == GEMSTONE;
1865     int ret = 0;
1866 /*JP
1867     static NEARDATA const char nogood[] = " is not interested in your junk.";
1868 */
1869     static NEARDATA const char nogood[] = "\82 \82È\82½\82Ì\83K\83\89\83N\83^\82É\8b»\96¡\82ð\8e¦\82³\82È\82¢\81D";
1870 /*JP
1871     static NEARDATA const char acceptgift[] = " accepts your gift.";
1872 */
1873     static NEARDATA const char acceptgift[] = "\82 \82È\82½\82Ì\91¡\82è\95¨\82ð\8eó\82¯\82Æ\82Á\82½\81D";
1874 /*JP
1875     static NEARDATA const char maybeluck[] = " hesitatingly";
1876 */
1877     static NEARDATA const char maybeluck[] = "\82½\82ß\82ç\82¢\82È\82ª\82ç";
1878 /*JP
1879     static NEARDATA const char noluck[] = " graciously";
1880 */
1881     static NEARDATA const char noluck[] = "\92\9a\8fd\82É";
1882 /*JP
1883     static NEARDATA const char addluck[] = " gratefully";
1884 */
1885     static NEARDATA const char addluck[] = "\8aì\82ñ\82Å";
1886
1887     Strcpy(buf, Monnam(mon));
1888 #if 1 /*JP*/
1889     Strcat(buf, "\82Í");
1890 #endif
1891     mon->mpeaceful = 1;
1892     mon->mavenge = 0;
1893
1894     /* object properly identified */
1895     if (obj->dknown && objects[obj->otyp].oc_name_known) {
1896         if (is_gem) {
1897             if (is_buddy) {
1898                 Strcat(buf, addluck);
1899                 change_luck(5);
1900             } else {
1901                 Strcat(buf, maybeluck);
1902                 change_luck(rn2(7) - 3);
1903             }
1904         } else {
1905             Strcat(buf, nogood);
1906             goto nopick;
1907         }
1908         /* making guesses */
1909     } else if (has_oname(obj) || objects[obj->otyp].oc_uname) {
1910         if (is_gem) {
1911             if (is_buddy) {
1912                 Strcat(buf, addluck);
1913                 change_luck(2);
1914             } else {
1915                 Strcat(buf, maybeluck);
1916                 change_luck(rn2(3) - 1);
1917             }
1918         } else {
1919             Strcat(buf, nogood);
1920             goto nopick;
1921         }
1922         /* value completely unknown to @ */
1923     } else {
1924         if (is_gem) {
1925             if (is_buddy) {
1926                 Strcat(buf, addluck);
1927                 change_luck(1);
1928             } else {
1929                 Strcat(buf, maybeluck);
1930                 change_luck(rn2(3) - 1);
1931             }
1932         } else {
1933             Strcat(buf, noluck);
1934         }
1935     }
1936     Strcat(buf, acceptgift);
1937     if (*u.ushops || obj->unpaid)
1938         check_shop_obj(obj, mon->mx, mon->my, TRUE);
1939     (void) mpickobj(mon, obj); /* may merge and free obj */
1940     ret = 1;
1941
1942 nopick:
1943     if (!Blind)
1944         pline1(buf);
1945     if (!tele_restrict(mon))
1946         (void) rloc(mon, TRUE);
1947     return ret;
1948 }
1949
1950 /*
1951  * Comments about the restructuring of the old breaks() routine.
1952  *
1953  * There are now three distinct phases to object breaking:
1954  *     breaktest() - which makes the check/decision about whether the
1955  *                   object is going to break.
1956  *     breakmsg()  - which outputs a message about the breakage,
1957  *                   appropriate for that particular object. Should
1958  *                   only be called after a positive breaktest().
1959  *                   on the object and, if it going to be called,
1960  *                   it must be called before calling breakobj().
1961  *                   Calling breakmsg() is optional.
1962  *     breakobj()  - which actually does the breakage and the side-effects
1963  *                   of breaking that particular object. This should
1964  *                   only be called after a positive breaktest() on the
1965  *                   object.
1966  *
1967  * Each of the above routines is currently static to this source module.
1968  * There are two routines callable from outside this source module which
1969  * perform the routines above in the correct sequence.
1970  *
1971  *   hero_breaks() - called when an object is to be broken as a result
1972  *                   of something that the hero has done. (throwing it,
1973  *                   kicking it, etc.)
1974  *   breaks()      - called when an object is to be broken for some
1975  *                   reason other than the hero doing something to it.
1976  */
1977
1978 /*
1979  * The hero causes breakage of an object (throwing, dropping it, etc.)
1980  * Return 0 if the object didn't break, 1 if the object broke.
1981  */
1982 int
1983 hero_breaks(obj, x, y, from_invent)
1984 struct obj *obj;
1985 xchar x, y;          /* object location (ox, oy may not be right) */
1986 boolean from_invent; /* thrown or dropped by player; maybe on shop bill */
1987 {
1988     boolean in_view = Blind ? FALSE : (from_invent || cansee(x, y));
1989     if (!breaktest(obj))
1990         return 0;
1991     breakmsg(obj, in_view);
1992     breakobj(obj, x, y, TRUE, from_invent);
1993     return 1;
1994 }
1995
1996 /*
1997  * The object is going to break for a reason other than the hero doing
1998  * something to it.
1999  * Return 0 if the object doesn't break, 1 if the object broke.
2000  */
2001 int
2002 breaks(obj, x, y)
2003 struct obj *obj;
2004 xchar x, y; /* object location (ox, oy may not be right) */
2005 {
2006     boolean in_view = Blind ? FALSE : cansee(x, y);
2007
2008     if (!breaktest(obj))
2009         return 0;
2010     breakmsg(obj, in_view);
2011     breakobj(obj, x, y, FALSE, FALSE);
2012     return 1;
2013 }
2014
2015 void
2016 release_camera_demon(obj, x, y)
2017 struct obj *obj;
2018 xchar x, y;
2019 {
2020     struct monst *mtmp;
2021     if (!rn2(3)
2022         && (mtmp = makemon(&mons[rn2(3) ? PM_HOMUNCULUS : PM_IMP], x, y,
2023                            NO_MM_FLAGS)) != 0) {
2024         if (canspotmon(mtmp))
2025 #if 0 /*JP*/
2026             pline("%s is released!", Hallucination
2027                                          ? An(rndmonnam(NULL))
2028                                          : "The picture-painting demon");
2029 #else
2030             pline("%s\82ª\89ð\95ú\82³\82ê\82½\81I", Hallucination
2031                                          ? rndmonnam(NULL)
2032                                          : "\82¨\8aG\95`\82«\82Ì\88«\96\82");
2033 #endif
2034         mtmp->mpeaceful = !obj->cursed;
2035         set_malign(mtmp);
2036     }
2037 }
2038
2039 /*
2040  * Unconditionally break an object. Assumes all resistance checks
2041  * and break messages have been delivered prior to getting here.
2042  */
2043 void
2044 breakobj(obj, x, y, hero_caused, from_invent)
2045 struct obj *obj;
2046 xchar x, y;          /* object location (ox, oy may not be right) */
2047 boolean hero_caused; /* is this the hero's fault? */
2048 boolean from_invent;
2049 {
2050     boolean fracture = FALSE;
2051
2052     switch (obj->oclass == POTION_CLASS ? POT_WATER : obj->otyp) {
2053     case MIRROR:
2054         if (hero_caused)
2055             change_luck(-2);
2056         break;
2057     case POT_WATER:      /* really, all potions */
2058         obj->in_use = 1; /* in case it's fatal */
2059         if (obj->otyp == POT_OIL && obj->lamplit) {
2060             explode_oil(obj, x, y);
2061         } else if (distu(x, y) <= 2) {
2062             if (!breathless(youmonst.data) || haseyes(youmonst.data)) {
2063                 if (obj->otyp != POT_WATER) {
2064                     if (!breathless(youmonst.data)) {
2065                         /* [what about "familiar odor" when known?] */
2066 /*JP
2067                         You("smell a peculiar odor...");
2068 */
2069                         You("\96ò\82Á\82Û\82¢\93õ\82¢\82ª\82µ\82½\81D\81D\81D");
2070                     } else {
2071 #if 0 /*JP*/
2072                         const char *eyes = body_part(EYE);
2073
2074                         if (eyecount(youmonst.data) != 1)
2075                             eyes = makeplural(eyes);
2076                         Your("%s %s.", eyes, vtense(eyes, "water"));
2077 #else
2078                         You("\97Ü%s\82É\82È\82Á\82½\81D", body_part(EYE));
2079 #endif
2080                     }
2081                 }
2082                 potionbreathe(obj);
2083             }
2084         }
2085         /* monster breathing isn't handled... [yet?] */
2086         break;
2087     case EXPENSIVE_CAMERA:
2088         release_camera_demon(obj, x, y);
2089         break;
2090     case EGG:
2091         /* breaking your own eggs is bad luck */
2092         if (hero_caused && obj->spe && obj->corpsenm >= LOW_PM)
2093             change_luck((schar) -min(obj->quan, 5L));
2094         break;
2095     case BOULDER:
2096     case STATUE:
2097         /* caller will handle object disposition;
2098            we're just doing the shop theft handling */
2099         fracture = TRUE;
2100         break;
2101     default:
2102         break;
2103     }
2104
2105     if (hero_caused) {
2106         if (from_invent || obj->unpaid) {
2107             if (*u.ushops || obj->unpaid)
2108                 check_shop_obj(obj, x, y, TRUE);
2109         } else if (!obj->no_charge && costly_spot(x, y)) {
2110             /* it is assumed that the obj is a floor-object */
2111             char *o_shop = in_rooms(x, y, SHOPBASE);
2112             struct monst *shkp = shop_keeper(*o_shop);
2113
2114             if (shkp) { /* (implies *o_shop != '\0') */
2115                 static NEARDATA long lastmovetime = 0L;
2116                 static NEARDATA boolean peaceful_shk = FALSE;
2117                 /*  We want to base shk actions on her peacefulness
2118                     at start of this turn, so that "simultaneous"
2119                     multiple breakage isn't drastically worse than
2120                     single breakage.  (ought to be done via ESHK)  */
2121                 if (moves != lastmovetime)
2122                     peaceful_shk = shkp->mpeaceful;
2123                 if (stolen_value(obj, x, y, peaceful_shk, FALSE) > 0L
2124                     && (*o_shop != u.ushops[0] || !inside_shop(u.ux, u.uy))
2125                     && moves != lastmovetime)
2126                     make_angry_shk(shkp, x, y);
2127                 lastmovetime = moves;
2128             }
2129         }
2130     }
2131     if (!fracture)
2132         delobj(obj);
2133 }
2134
2135 /*
2136  * Check to see if obj is going to break, but don't actually break it.
2137  * Return 0 if the object isn't going to break, 1 if it is.
2138  */
2139 boolean
2140 breaktest(obj)
2141 struct obj *obj;
2142 {
2143     if (obj_resists(obj, 1, 99))
2144         return 0;
2145     if (objects[obj->otyp].oc_material == GLASS && !obj->oartifact
2146         && obj->oclass != GEM_CLASS)
2147         return 1;
2148     switch (obj->oclass == POTION_CLASS ? POT_WATER : obj->otyp) {
2149     case EXPENSIVE_CAMERA:
2150     case POT_WATER: /* really, all potions */
2151     case EGG:
2152     case CREAM_PIE:
2153     case MELON:
2154     case ACID_VENOM:
2155     case BLINDING_VENOM:
2156         return 1;
2157     default:
2158         return 0;
2159     }
2160 }
2161
2162 STATIC_OVL void
2163 breakmsg(obj, in_view)
2164 struct obj *obj;
2165 boolean in_view;
2166 {
2167     const char *to_pieces;
2168
2169 #if 0 /*JP*/
2170     to_pieces = "";
2171 #else
2172     /* "shatter" \81¨ "\82±\82È\82²\82È\82É\82È\82Á\82½"
2173        "shatter into a thousand pieces" \81¨ "\82­\82¾\82¯\82Ä\82Î\82ç\82Î\82ç\82É\82È\82Á\82½" */
2174     to_pieces = "\82±\82È\82²\82È";
2175 #endif
2176     switch (obj->oclass == POTION_CLASS ? POT_WATER : obj->otyp) {
2177     default: /* glass or crystal wand */
2178         if (obj->oclass != WAND_CLASS)
2179             impossible("breaking odd object?");
2180     case CRYSTAL_PLATE_MAIL:
2181     case LENSES:
2182     case MIRROR:
2183     case CRYSTAL_BALL:
2184     case EXPENSIVE_CAMERA:
2185 /*JP
2186         to_pieces = " into a thousand pieces";
2187 */
2188         to_pieces = "\82­\82¾\82¯\82Ä\82Î\82ç\82Î\82ç";
2189     /*FALLTHRU*/
2190     case POT_WATER: /* really, all potions */
2191         if (!in_view)
2192 /*JP
2193             You_hear("%s shatter!", something);
2194 */
2195             You_hear("%s\82ª\89ó\82ê\82é\89¹\82ð\95·\82¢\82½\81I", something);
2196         else
2197 #if 0 /*JP*/
2198             pline("%s shatter%s%s!", Doname2(obj),
2199                   (obj->quan == 1L) ? "s" : "", to_pieces);
2200 #else
2201             pline("%s\82Í%s\82É\82È\82Á\82½\81I", Doname2(obj), to_pieces);
2202 #endif
2203         break;
2204     case EGG:
2205     case MELON:
2206 /*JP
2207         pline("Splat!");
2208 */
2209         pline("\83r\83`\83\83\81I");
2210         break;
2211     case CREAM_PIE:
2212         if (in_view)
2213 /*JP
2214             pline("What a mess!");
2215 */
2216             pline("\82±\82è\82á\82Ð\82Ç\82¢\81I");
2217         break;
2218     case ACID_VENOM:
2219     case BLINDING_VENOM:
2220 /*JP
2221         pline("Splash!");
2222 */
2223         pline("\83r\83`\83\83\81I");
2224         break;
2225     }
2226 }
2227
2228 STATIC_OVL int
2229 throw_gold(obj)
2230 struct obj *obj;
2231 {
2232     int range, odx, ody;
2233     register struct monst *mon;
2234
2235     if (!u.dx && !u.dy && !u.dz) {
2236 /*JP
2237         You("cannot throw gold at yourself.");
2238 */
2239         pline("\8e©\95ª\82É\8bà\89Ý\82ð\93\8a\82°\82é\82±\82Æ\82Í\82Å\82«\82È\82¢\81D");
2240         return 0;
2241     }
2242     freeinv(obj);
2243     if (u.uswallow) {
2244 #if 0 /*JP*/
2245         pline(is_animal(u.ustuck->data) ? "%s in the %s's entrails."
2246                                         : "%s into %s.",
2247               "The money disappears", mon_nam(u.ustuck));
2248 #else
2249         pline(is_animal(u.ustuck->data) ? "\8bà\89Ý\82Í%s\82Ì\95 \82Ì\92\86\82Ö\8fÁ\82¦\82Ä\82¢\82Á\82½\81D"
2250                                         : "\8bà\89Ý\82Í%s\82Ì\92\86\82Ö\8fÁ\82¦\82Ä\82¢\82Á\82½\81D",
2251               mon_nam(u.ustuck));
2252 #endif
2253         add_to_minv(u.ustuck, obj);
2254         return 1;
2255     }
2256
2257     if (u.dz) {
2258         if (u.dz < 0 && !Is_airlevel(&u.uz) && !Underwater
2259             && !Is_waterlevel(&u.uz)) {
2260 #if 0 /*JP*/
2261             pline_The("gold hits the %s, then falls back on top of your %s.",
2262                       ceiling(u.ux, u.uy), body_part(HEAD));
2263 #else
2264             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",
2265                   ceiling(u.ux,u.uy), body_part(HEAD));
2266 #endif
2267             /* some self damage? */
2268             if (uarmh)
2269 /*JP
2270                 pline("Fortunately, you are wearing %s!",
2271 */
2272                 pline("\8dK\89^\82È\82±\82Æ\82É\81C\82 \82È\82½\82Í%s\82ð\90g\82É\82Â\82¯\82Ä\82¢\82é\81I",
2273                       an(helm_simple_name(uarmh)));
2274         }
2275         bhitpos.x = u.ux;
2276         bhitpos.y = u.uy;
2277     } else {
2278         /* consistent with range for normal objects */
2279         range = (int) ((ACURRSTR) / 2 - obj->owt / 40);
2280
2281         /* see if the gold has a place to move into */
2282         odx = u.ux + u.dx;
2283         ody = u.uy + u.dy;
2284         if (!ZAP_POS(levl[odx][ody].typ) || closed_door(odx, ody)) {
2285             bhitpos.x = u.ux;
2286             bhitpos.y = u.uy;
2287         } else {
2288             mon = bhit(u.dx, u.dy, range, THROWN_WEAPON,
2289                        (int FDECL((*), (MONST_P, OBJ_P))) 0,
2290                        (int FDECL((*), (OBJ_P, OBJ_P))) 0, &obj);
2291             if (!obj)
2292                 return 1; /* object is gone */
2293             if (mon) {
2294                 if (ghitm(mon, obj)) /* was it caught? */
2295                     return 1;
2296             } else {
2297                 if (ship_object(obj, bhitpos.x, bhitpos.y, FALSE))
2298                     return 1;
2299             }
2300         }
2301     }
2302
2303 /*JP
2304     if (flooreffects(obj, bhitpos.x, bhitpos.y, "fall"))
2305 */
2306     if (flooreffects(obj, bhitpos.x, bhitpos.y, "\97\8e\82¿\82é"))
2307         return 1;
2308     if (u.dz > 0)
2309 /*JP
2310         pline_The("gold hits the %s.", surface(bhitpos.x, bhitpos.y));
2311 */
2312         pline("\8bà\89Ý\82Í%s\82É\96½\92\86\82µ\82½\81D", surface(bhitpos.x, bhitpos.y));
2313     place_object(obj, bhitpos.x, bhitpos.y);
2314     if (*u.ushops)
2315         sellobj(obj, bhitpos.x, bhitpos.y);
2316     stackobj(obj);
2317     newsym(bhitpos.x, bhitpos.y);
2318     return 1;
2319 }
2320
2321 /*dothrow.c*/