OSDN Git Service

6544914c10d90ee3bad60fc0e5eb62e7ccb7abb5
[hengband/hengband.git] / src / cmd2.c
1 /* File: cmd2.c */
2
3 /*
4  * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
5  *
6  * This software may be copied and distributed for educational, research,
7  * and not for profit purposes provided that this copyright and statement
8  * are included in all such copies.  Other copyrights may also apply.
9  */
10
11 /* Purpose: Movement commands (part 2) */
12
13 #include "angband.h"
14
15
16 /*
17  * Go up one level
18  */
19 void do_cmd_go_up(void)
20 {
21         bool go_up = FALSE;
22
23         /* Player grid */
24         cave_type *c_ptr = &cave[py][px];
25         feature_type *f_ptr = &f_info[c_ptr->feat];
26
27         int up_num = 0;
28
29         if (p_ptr->special_defense & KATA_MUSOU)
30         {
31                 set_action(ACTION_NONE);
32         }
33
34         /* Verify stairs */
35         if (!have_flag(f_ptr->flags, FF_LESS))
36         {
37 #ifdef JP
38                 msg_print("¤³¤³¤Ë¤Ï¾å¤ê³¬Ãʤ¬¸«Åö¤¿¤é¤Ê¤¤¡£");
39 #else
40                 msg_print("I see no up staircase here.");
41 #endif
42
43                 return;
44         }
45
46         /* Quest up stairs */
47         if (have_flag(f_ptr->flags, FF_QUEST))
48         {
49                 /* Success */
50 #ifdef JP
51                 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
52                         msg_print("¤Ê¤ó¤À¤³¤Î³¬Ãʤϡª");
53                 else
54                         msg_print("¾å¤Î³¬¤ËÅФä¿¡£");
55 #else
56                 msg_print("You enter the up staircase.");
57 #endif
58
59                 leave_quest_check();
60
61                 p_ptr->inside_quest = c_ptr->special;
62
63                 /* Activate the quest */
64                 if (!quest[p_ptr->inside_quest].status)
65                 {
66                         quest[p_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
67                 }
68
69                 /* Leaving a quest */
70                 if (!p_ptr->inside_quest)
71                 {
72                         dun_level = 0;
73                 }
74
75                 /* Leaving */
76                 p_ptr->leaving = TRUE;
77
78                 p_ptr->oldpx = 0;
79                 p_ptr->oldpy = 0;
80
81                 /* End the command */
82                 return;
83         }
84
85         if (!dun_level)
86         {
87                 go_up = TRUE;
88         }
89         else
90         {
91                 quest_type *q_ptr = &quest[p_ptr->inside_quest];
92
93                 /* Confirm leaving from once only quest */
94                 if (confirm_quest && p_ptr->inside_quest &&
95                     (q_ptr->type == QUEST_TYPE_RANDOM ||
96                      (q_ptr->flags & QUEST_FLAG_ONCE &&
97                       q_ptr->status != QUEST_STATUS_COMPLETED)))
98                 {
99 #ifdef JP
100                         msg_print("¤³¤Î³¬¤ò°ìÅÙµî¤ë¤ÈÆóÅÙ¤ÈÌá¤Ã¤ÆÍè¤é¤ì¤Þ¤»¤ó¡£");
101                         if (get_check("ËÜÅö¤Ë¤³¤Î³¬¤òµî¤ê¤Þ¤¹¤«¡©")) go_up = TRUE;
102 #else
103                         msg_print("You can't come back here once you leave this floor.");
104                         if (get_check("Really leave this floor? ")) go_up = TRUE;
105 #endif
106                 }
107                 else
108                 {
109                         go_up = TRUE;
110                 }
111         }
112
113         /* Cancel the command */
114         if (!go_up) return;
115
116         /* Hack -- take a turn */
117         energy_use = 100;
118
119         if (autosave_l) do_cmd_save_game(TRUE);
120
121         /* For a random quest */
122         if (p_ptr->inside_quest &&
123             quest[p_ptr->inside_quest].type == QUEST_TYPE_RANDOM)
124         {
125                 leave_quest_check();
126
127                 p_ptr->inside_quest = 0;
128         }
129
130         /* For a fixed quest */
131         if (p_ptr->inside_quest &&
132             quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM)
133         {
134                 leave_quest_check();
135
136                 p_ptr->inside_quest = c_ptr->special;
137                 dun_level = 0;
138                 up_num = 0;
139         }
140
141         /* For normal dungeon and random quest */
142         else
143         {
144                 /* New depth */
145                 if (have_flag(f_ptr->flags, FF_SHAFT))
146                 {
147                         /* Create a way back */
148                         prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_SHAFT);
149
150                         up_num = 2;
151                 }
152                 else
153                 {
154                         /* Create a way back */
155                         prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP);
156
157                         up_num = 1;
158                 }
159
160                 /* Get out from current dungeon */
161                 if (dun_level - up_num < d_info[dungeon_type].mindepth)
162                         up_num = dun_level;
163         }
164
165 #ifdef JP
166         if (record_stair) do_cmd_write_nikki(NIKKI_STAIR, 0-up_num, "³¬Ãʤò¾å¤Ã¤¿");
167 #else
168         if (record_stair) do_cmd_write_nikki(NIKKI_STAIR, 0-up_num, "climbed up the stairs to");
169 #endif
170
171         /* Success */
172 #ifdef JP
173         if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
174                 msg_print("¤Ê¤ó¤À¤³¤Î³¬Ãʤϡª");
175         else if (up_num == dun_level)
176                 msg_print("ÃϾå¤ËÌá¤Ã¤¿¡£");
177         else
178                 msg_print("³¬Ãʤò¾å¤Ã¤Æ¿·¤¿¤Ê¤ë̵ܤؤÈ­¤òƧ¤ßÆþ¤ì¤¿¡£");
179 #else
180         if (up_num == dun_level)
181                 msg_print("You go back to the surface.");
182         else
183                 msg_print("You enter a maze of up staircases.");
184 #endif
185
186         /* Leaving */
187         p_ptr->leaving = TRUE;
188 }
189
190
191 /*
192  * Go down one level
193  */
194 void do_cmd_go_down(void)
195 {
196         /* Player grid */
197         cave_type *c_ptr = &cave[py][px];
198         feature_type *f_ptr = &f_info[c_ptr->feat];
199
200         bool fall_trap = FALSE;
201         int down_num = 0;
202
203         if (p_ptr->special_defense & KATA_MUSOU)
204         {
205                 set_action(ACTION_NONE);
206         }
207
208         /* Verify stairs */
209         if (!have_flag(f_ptr->flags, FF_MORE))
210         {
211 #ifdef JP
212                 msg_print("¤³¤³¤Ë¤Ï²¼¤ê³¬Ãʤ¬¸«Åö¤¿¤é¤Ê¤¤¡£");
213 #else
214                 msg_print("I see no down staircase here.");
215 #endif
216
217                 return;
218         }
219
220         if (have_flag(f_ptr->flags, FF_TRAP)) fall_trap = TRUE;
221
222         /* Quest entrance */
223         if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
224         {
225                 do_cmd_quest();
226         }
227
228         /* Quest down stairs */
229         else if (have_flag(f_ptr->flags, FF_QUEST))
230         {
231 #ifdef JP
232                 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
233                         msg_print("¤Ê¤ó¤À¤³¤Î³¬Ãʤϡª");
234                 else
235                         msg_print("²¼¤Î³¬¤Ë¹ß¤ê¤¿¡£");
236 #else
237                         msg_print("You enter the down staircase.");
238 #endif
239
240
241                 leave_quest_check();
242
243                 p_ptr->inside_quest = c_ptr->special;
244
245                 /* Activate the quest */
246                 if (!quest[p_ptr->inside_quest].status)
247                 {
248                         quest[p_ptr->inside_quest].status = QUEST_STATUS_TAKEN;
249                 }
250
251                 /* Leaving a quest */
252                 if (!p_ptr->inside_quest)
253                 {
254                         dun_level = 0;
255                 }
256
257                 /* Leaving */
258                 p_ptr->leaving = TRUE;
259
260                 p_ptr->oldpx = 0;
261                 p_ptr->oldpy = 0;
262         }
263
264         else
265         {
266                 int target_dungeon = 0;
267
268                 if (!dun_level)
269                 {
270                         target_dungeon = have_flag(f_ptr->flags, FF_ENTRANCE) ? c_ptr->special : DUNGEON_ANGBAND;
271
272                         if (ironman_downward && (target_dungeon != DUNGEON_ANGBAND))
273                         {
274 #ifdef JP
275                                 msg_print("¥À¥ó¥¸¥ç¥ó¤ÎÆþ¸ý¤ÏºÉ¤¬¤ì¤Æ¤¤¤ë¡ª");
276 #else
277                                 msg_print("The entrance of this dungeon is closed!");
278 #endif
279                                 return;
280                         }
281                         if (!max_dlv[target_dungeon])
282                         {
283 #ifdef JP
284                                 msg_format("¤³¤³¤Ë¤Ï%s¤ÎÆþ¤ê¸ý(%d³¬ÁêÅö)¤¬¤¢¤ê¤Þ¤¹", d_name+d_info[target_dungeon].name, d_info[target_dungeon].mindepth);
285                                 if (!get_check("ËÜÅö¤Ë¤³¤Î¥À¥ó¥¸¥ç¥ó¤ËÆþ¤ê¤Þ¤¹¤«¡©")) return;
286 #else
287                                 msg_format("There is the entrance of %s (Danger level: %d)", d_name+d_info[target_dungeon].name, d_info[target_dungeon].mindepth);
288                                 if (!get_check("Do you really get in this dungeon? ")) return;
289 #endif
290                         }
291
292                         /* Save old player position */
293                         p_ptr->oldpx = px;
294                         p_ptr->oldpy = py;
295                         dungeon_type = (byte)target_dungeon;
296
297                         /*
298                          * Clear all saved floors
299                          * and create a first saved floor
300                          */
301                         prepare_change_floor_mode(CFM_FIRST_FLOOR);
302                 }
303
304                 /* Hack -- take a turn */
305                 energy_use = 100;
306
307                 if (autosave_l) do_cmd_save_game(TRUE);
308
309                 /* Go down */
310                 if (have_flag(f_ptr->flags, FF_SHAFT)) down_num += 2;
311                 else down_num += 1;
312
313                 if (!dun_level)
314                 {
315                         /* Enter the dungeon just now */
316                         p_ptr->enter_dungeon = TRUE;
317                         down_num = d_info[dungeon_type].mindepth;
318                 }
319
320                 if (record_stair)
321                 {
322 #ifdef JP
323                         if (fall_trap) do_cmd_write_nikki(NIKKI_STAIR, down_num, "Í¸Í¤ËÍî¤Á¤¿");
324                         else do_cmd_write_nikki(NIKKI_STAIR, down_num, "³¬Ãʤò²¼¤ê¤¿");
325 #else
326                         if (fall_trap) do_cmd_write_nikki(NIKKI_STAIR, down_num, "fell through a trap door");
327                         else do_cmd_write_nikki(NIKKI_STAIR, down_num, "climbed down the stairs to");
328 #endif
329                 }
330
331                 if (fall_trap)
332                 {
333 #ifdef JP
334                         msg_print("¤ï¤¶¤ÈÍ¸Í¤ËÍî¤Á¤¿¡£");
335 #else
336                         msg_print("You deliberately jump through the trap door.");
337 #endif
338                 }
339                 else
340                 {
341                         /* Success */
342                         if (target_dungeon)
343                         {
344 #ifdef JP
345                                 msg_format("%s¤ØÆþ¤Ã¤¿¡£", d_text + d_info[dungeon_type].text);
346 #else
347                                 msg_format("You entered %s.", d_text + d_info[dungeon_type].text);
348 #endif
349                         }
350                         else
351                         {
352 #ifdef JP
353                                 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
354                                         msg_print("¤Ê¤ó¤À¤³¤Î³¬Ãʤϡª");
355                                 else
356                                         msg_print("³¬Ãʤò²¼¤ê¤Æ¿·¤¿¤Ê¤ë̵ܤؤÈ­¤òƧ¤ßÆþ¤ì¤¿¡£");
357 #else
358                                 msg_print("You enter a maze of down staircases.");
359 #endif
360                         }
361                 }
362
363
364                 /* Leaving */
365                 p_ptr->leaving = TRUE;
366
367                 if (fall_trap)
368                 {
369                         prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
370                 }
371                 else
372                 {
373                         if (have_flag(f_ptr->flags, FF_SHAFT))
374                         {
375                                 /* Create a way back */
376                                 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_SHAFT);
377                         }
378                         else
379                         {
380                                 /* Create a way back */
381                                 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN);
382                         }
383                 }
384         }
385 }
386
387
388
389 /*
390  * Simple command to "search" for one turn
391  */
392 void do_cmd_search(void)
393 {
394         /* Allow repeated command */
395         if (command_arg)
396         {
397                 /* Set repeat count */
398                 command_rep = command_arg - 1;
399
400                 /* Redraw the state */
401                 p_ptr->redraw |= (PR_STATE);
402
403                 /* Cancel the arg */
404                 command_arg = 0;
405         }
406
407         /* Take a turn */
408         energy_use = 100;
409
410         /* Search */
411         search();
412 }
413
414
415 /*
416  * Determine if a grid contains a chest
417  */
418 static s16b chest_check(int y, int x)
419 {
420         cave_type *c_ptr = &cave[y][x];
421
422         s16b this_o_idx, next_o_idx = 0;
423
424
425         /* Scan all objects in the grid */
426         for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
427         {
428                 object_type *o_ptr;
429
430                 /* Acquire object */
431                 o_ptr = &o_list[this_o_idx];
432
433                 /* Acquire next object */
434                 next_o_idx = o_ptr->next_o_idx;
435
436                 /* Skip unknown chests XXX XXX */
437                 /* if (!o_ptr->marked) continue; */
438
439                 /* Check for chest */
440                 if (o_ptr->tval == TV_CHEST) return (this_o_idx);
441         }
442
443         /* No chest */
444         return (0);
445 }
446
447
448 /*
449  * Allocates objects upon opening a chest    -BEN-
450  *
451  * Disperse treasures from the given chest, centered at (x,y).
452  *
453  * Small chests often contain "gold", while Large chests always contain
454  * items.  Wooden chests contain 2 items, Iron chests contain 4 items,
455  * and Steel chests contain 6 items.  The "value" of the items in a
456  * chest is based on the "power" of the chest, which is in turn based
457  * on the level on which the chest is generated.
458  */
459 static void chest_death(bool scatter, int y, int x, s16b o_idx)
460 {
461         int number;
462
463         bool small;
464         u32b mode = AM_GOOD;
465
466         object_type forge;
467         object_type *q_ptr;
468
469         object_type *o_ptr = &o_list[o_idx];
470
471
472         /* Small chests often hold "gold" */
473         small = (o_ptr->sval < SV_CHEST_MIN_LARGE);
474
475         /* Determine how much to drop (see above) */
476         number = (o_ptr->sval % SV_CHEST_MIN_LARGE) * 2;
477
478         if (o_ptr->sval == SV_CHEST_KANDUME)
479         {
480                 number = 5;
481                 small = FALSE;
482                 mode |= AM_GREAT;
483                 object_level = o_ptr->xtra3;
484         }
485         else
486         {
487                 /* Determine the "value" of the items */
488                 object_level = ABS(o_ptr->pval) + 10;
489         }
490
491         /* Zero pval means empty chest */
492         if (!o_ptr->pval) number = 0;
493
494         /* Opening a chest */
495         opening_chest = TRUE;
496
497         /* Drop some objects (non-chests) */
498         for (; number > 0; --number)
499         {
500                 /* Get local object */
501                 q_ptr = &forge;
502
503                 /* Wipe the object */
504                 object_wipe(q_ptr);
505
506                 /* Small chests often drop gold */
507                 if (small && (randint0(100) < 25))
508                 {
509                         /* Make some gold */
510                         if (!make_gold(q_ptr)) continue;
511                 }
512
513                 /* Otherwise drop an item */
514                 else
515                 {
516                         /* Make a good object */
517                         if (!make_object(q_ptr, mode)) continue;
518                 }
519
520                 /* If chest scatters its contents, pick any floor square. */
521                 if (scatter)
522                 {
523                         int i;
524                         for (i = 0; i < 200; i++)
525                         {
526                                 /* Pick a totally random spot. */
527                                 y = randint0(MAX_HGT);
528                                 x = randint0(MAX_WID);
529
530                                 /* Must be an empty floor. */
531                                 if (!cave_empty_bold(y, x)) continue;
532
533                                 /* Place the object there. */
534                                 drop_near(q_ptr, -1, y, x);
535
536                                 /* Done. */
537                                 break;
538                         }
539                 }
540                 /* Normally, drop object near the chest. */
541                 else drop_near(q_ptr, -1, y, x);
542         }
543
544         /* Reset the object level */
545         object_level = base_level;
546
547         /* No longer opening a chest */
548         opening_chest = FALSE;
549
550         /* Empty */
551         o_ptr->pval = 0;
552
553         /* Known */
554         object_known(o_ptr);
555 }
556
557
558 /*
559  * Chests have traps too.
560  *
561  * Exploding chest destroys contents (and traps).
562  * Note that the chest itself is never destroyed.
563  */
564 static void chest_trap(int y, int x, s16b o_idx)
565 {
566         int  i, trap;
567
568         object_type *o_ptr = &o_list[o_idx];
569
570         int mon_level = o_ptr->xtra3;
571
572         /* Ignore disarmed chests */
573         if (o_ptr->pval <= 0) return;
574
575         /* Obtain the traps */
576         trap = chest_traps[o_ptr->pval];
577
578         /* Lose strength */
579         if (trap & (CHEST_LOSE_STR))
580         {
581 #ifdef JP
582                 msg_print("»Å³Ý¤±¤é¤ì¤Æ¤¤¤¿¾®¤µ¤Ê¿Ë¤Ë»É¤µ¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª");
583                 take_hit(DAMAGE_NOESCAPE, damroll(1, 4), "ÆÇ¿Ë", -1);
584 #else
585                 msg_print("A small needle has pricked you!");
586                 take_hit(DAMAGE_NOESCAPE, damroll(1, 4), "a poison needle", -1);
587 #endif
588
589                 (void)do_dec_stat(A_STR);
590         }
591
592         /* Lose constitution */
593         if (trap & (CHEST_LOSE_CON))
594         {
595 #ifdef JP
596                 msg_print("»Å³Ý¤±¤é¤ì¤Æ¤¤¤¿¾®¤µ¤Ê¿Ë¤Ë»É¤µ¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª");
597                 take_hit(DAMAGE_NOESCAPE, damroll(1, 4), "ÆÇ¿Ë", -1);
598 #else
599                 msg_print("A small needle has pricked you!");
600                 take_hit(DAMAGE_NOESCAPE, damroll(1, 4), "a poison needle", -1);
601 #endif
602
603                 (void)do_dec_stat(A_CON);
604         }
605
606         /* Poison */
607         if (trap & (CHEST_POISON))
608         {
609 #ifdef JP
610                 msg_print("ÆÍÇ¡¿á¤­½Ð¤·¤¿Îп§¤Î¥¬¥¹¤ËÊñ¤ß¹þ¤Þ¤ì¤¿¡ª");
611 #else
612                 msg_print("A puff of green gas surrounds you!");
613 #endif
614
615                 if (!(p_ptr->resist_pois || IS_OPPOSE_POIS()))
616                 {
617                         (void)set_poisoned(p_ptr->poisoned + 10 + randint1(20));
618                 }
619         }
620
621         /* Paralyze */
622         if (trap & (CHEST_PARALYZE))
623         {
624 #ifdef JP
625                 msg_print("ÆÍÇ¡¿á¤­½Ð¤·¤¿²«¿§¤¤¥¬¥¹¤ËÊñ¤ß¹þ¤Þ¤ì¤¿¡ª");
626 #else
627                 msg_print("A puff of yellow gas surrounds you!");
628 #endif
629
630
631                 if (!p_ptr->free_act)
632                 {
633                         (void)set_paralyzed(p_ptr->paralyzed + 10 + randint1(20));
634                 }
635         }
636
637         /* Summon monsters */
638         if (trap & (CHEST_SUMMON))
639         {
640                 int num = 2 + randint1(3);
641 #ifdef JP
642                 msg_print("ÆÍÇ¡¿á¤­½Ð¤·¤¿±ì¤ËÊñ¤ß¹þ¤Þ¤ì¤¿¡ª");
643 #else
644                 msg_print("You are enveloped in a cloud of smoke!");
645 #endif
646
647
648                 for (i = 0; i < num; i++)
649                 {
650                         if (randint1(100)<dun_level)
651                                 activate_hi_summon(py, px, FALSE);
652                         else
653                                 (void)summon_specific(0, y, x, mon_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
654                 }
655         }
656
657         /* Elemental summon. */
658         if (trap & (CHEST_E_SUMMON))
659         {
660 #ifdef JP
661                 msg_print("Êõ¤ò¼é¤ë¤¿¤á¤Ë¥¨¥ì¥á¥ó¥¿¥ë¤¬¸½¤ì¤¿¡ª");
662 #else
663                 msg_print("Elemental beings appear to protect their treasures!");
664 #endif
665                 for (i = 0; i < randint1(3) + 5; i++)
666                 {
667                         (void)summon_specific(0, y, x, mon_level, SUMMON_ELEMENTAL, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
668                 }
669         }
670
671         /* Force clouds, then summon birds. */
672         if (trap & (CHEST_BIRD_STORM))
673         {
674 #ifdef JP
675                 msg_print("Ä»¤Î·²¤ì¤¬¤¢¤Ê¤¿¤ò¼è¤ê´¬¤¤¤¿¡ª");
676 #else
677                 msg_print("A storm of birds swirls around you!");
678 #endif
679
680                 for (i = 0; i < randint1(3) + 3; i++)
681                         (void)fire_meteor(-1, GF_FORCE, y, x, o_ptr->pval / 5, 7);
682
683                 for (i = 0; i < randint1(5) + o_ptr->pval / 5; i++)
684                 {
685                         (void)summon_specific(0, y, x, mon_level, SUMMON_BIRD, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
686                 }
687         }
688
689         /* Various colorful summonings. */
690         if (trap & (CHEST_H_SUMMON))
691         {
692                 /* Summon demons. */
693                 if (one_in_(4))
694                 {
695 #ifdef JP
696                         msg_print("±ê¤Èⲫ¤Î±À¤ÎÃæ¤Ë°­Ë⤬»Ñ¤ò¸½¤·¤¿¡ª");
697 #else
698                         msg_print("Demons materialize in clouds of fire and brimstone!");
699 #endif
700
701                         for (i = 0; i < randint1(3) + 2; i++)
702                         {
703                                 (void)fire_meteor(-1, GF_FIRE, y, x, 10, 5);
704                                 (void)summon_specific(0, y, x, mon_level, SUMMON_DEMON, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
705                         }
706                 }
707
708                 /* Summon dragons. */
709                 else if (one_in_(3))
710                 {
711 #ifdef JP
712                         msg_print("°Å°Ç¤Ë¥É¥é¥´¥ó¤Î±Æ¤¬¤Ü¤ó¤ä¤ê¤È¸½¤ì¤¿¡ª");
713 #else
714                         msg_print("Draconic forms loom out of the darkness!");
715 #endif
716
717                         for (i = 0; i < randint1(3) + 2; i++)
718                         {
719                                 (void)summon_specific(0, y, x, mon_level, SUMMON_DRAGON, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
720                         }
721                 }
722
723                 /* Summon hybrids. */
724                 else if (one_in_(2))
725                 {
726 #ifdef JP
727                         msg_print("´ñ̯¤Ê»Ñ¤Î²øʪ¤¬½±¤Ã¤ÆÍ褿¡ª");
728 #else
729                         msg_print("Creatures strange and twisted assault you!");
730 #endif
731
732                         for (i = 0; i < randint1(5) + 3; i++)
733                         {
734                                 (void)summon_specific(0, y, x, mon_level, SUMMON_HYBRID, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
735                         }
736                 }
737
738                 /* Summon vortices (scattered) */
739                 else
740                 {
741 #ifdef JP
742                         msg_print("±²´¬¤«¹çÂΤ·¡¢ÇËÎö¤·¤¿¡ª");
743 #else
744                         msg_print("Vortices coalesce and wreak destruction!");
745 #endif
746
747                         for (i = 0; i < randint1(3) + 2; i++)
748                         {
749                                 (void)summon_specific(0, y, x, mon_level, SUMMON_VORTEX, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
750                         }
751                 }
752         }
753
754         /* Dispel player. */
755         if ((trap & (CHEST_RUNES_OF_EVIL)) && o_ptr->k_idx)
756         {
757                 /* Determine how many nasty tricks can be played. */
758                 int nasty_tricks_count = 4 + randint0(3);
759
760                 /* Message. */
761 #ifdef JP
762                 msg_print("¶²¤·¤¤À¼¤¬¶Á¤¤¤¿:  ¡Ö°Å°Ç¤¬Æò¤ò¤Ä¤Ä¤Þ¤ó¡ª¡×");
763 #else
764                 msg_print("Hideous voices bid:  'Let the darkness have thee!'");
765 #endif
766
767                 /* This is gonna hurt... */
768                 for (; nasty_tricks_count > 0; nasty_tricks_count--)
769                 {
770                         /* ...but a high saving throw does help a little. */
771                         if (randint1(100+o_ptr->pval*2) > p_ptr->skill_sav)
772                         {
773 #ifdef JP
774                                 if (one_in_(6)) take_hit(DAMAGE_NOESCAPE, damroll(5, 20), "ÇËÌǤΥȥé¥Ã¥×¤ÎÊõÈ¢", -1);
775 #else
776                                 if (one_in_(6)) take_hit(DAMAGE_NOESCAPE, damroll(5, 20), "a chest dispel-player trap", -1);
777 #endif
778                                 else if (one_in_(5)) (void)set_cut(p_ptr->cut + 200);
779                                 else if (one_in_(4))
780                                 {
781                                         if (!p_ptr->free_act) 
782                                                 (void)set_paralyzed(p_ptr->paralyzed + 2 + 
783                                                 randint0(6));
784                                         else 
785                                                 (void)set_stun(p_ptr->stun + 10 + 
786                                                 randint0(100));
787                                 }
788                                 else if (one_in_(3)) apply_disenchant(0);
789                                 else if (one_in_(2))
790                                 {
791                                         (void)do_dec_stat(A_STR);
792                                         (void)do_dec_stat(A_DEX);
793                                         (void)do_dec_stat(A_CON);
794                                         (void)do_dec_stat(A_INT);
795                                         (void)do_dec_stat(A_WIS);
796                                         (void)do_dec_stat(A_CHR);
797                                 }
798                                 else (void)fire_meteor(-1, GF_NETHER, y, x, 150, 1);
799                         }
800                 }
801         }
802
803         /* Aggravate monsters. */
804         if (trap & (CHEST_ALARM))
805         {
806 #ifdef JP
807                 msg_print("¤±¤¿¤¿¤Þ¤·¤¤²»¤¬ÌĤê¶Á¤¤¤¿¡ª");
808 #else
809                 msg_print("An alarm sounds!");
810 #endif
811                 aggravate_monsters(0);
812         }
813
814         /* Explode */
815         if ((trap & (CHEST_EXPLODE)) && o_ptr->k_idx)
816         {
817 #ifdef JP
818                 msg_print("ÆÍÁ³¡¢È¢¤¬Çúȯ¤·¤¿¡ª");
819                 msg_print("È¢¤ÎÃæ¤Îʪ¤Ï¤¹¤Ù¤ÆÊ´¡¹¤ËºÕ¤±»¶¤Ã¤¿¡ª");
820 #else
821                 msg_print("There is a sudden explosion!");
822                 msg_print("Everything inside the chest is destroyed!");
823 #endif
824
825                 o_ptr->pval = 0;
826                 sound(SOUND_EXPLODE);
827 #ifdef JP
828                 take_hit(DAMAGE_ATTACK, damroll(5, 8), "Çúȯ¤¹¤ëÈ¢", -1);
829 #else
830                 take_hit(DAMAGE_ATTACK, damroll(5, 8), "an exploding chest", -1);
831 #endif
832
833         }
834         /* Scatter contents. */
835         if ((trap & (CHEST_SCATTER)) && o_ptr->k_idx)
836         {
837 #ifdef JP
838                 msg_print("ÊõÈ¢¤ÎÃæ¿È¤Ï¥À¥ó¥¸¥ç¥ó¤¸¤å¤¦¤Ë»¶Í𤷤¿¡ª");
839 #else
840                 msg_print("The contents of the chest scatter all over the dungeon!");
841 #endif
842                 chest_death(TRUE, y, x, o_idx);
843                 o_ptr->pval = 0;
844         }
845 }
846
847
848 /*
849  * Attempt to open the given chest at the given location
850  *
851  * Assume there is no monster blocking the destination
852  *
853  * Returns TRUE if repeated commands may continue
854  */
855 static bool do_cmd_open_chest(int y, int x, s16b o_idx)
856 {
857         int i, j;
858
859         bool flag = TRUE;
860
861         bool more = FALSE;
862
863         object_type *o_ptr = &o_list[o_idx];
864
865
866         /* Take a turn */
867         energy_use = 100;
868
869         /* Attempt to unlock it */
870         if (o_ptr->pval > 0)
871         {
872                 /* Assume locked, and thus not open */
873                 flag = FALSE;
874
875                 /* Get the "disarm" factor */
876                 i = p_ptr->skill_dis;
877
878                 /* Penalize some conditions */
879                 if (p_ptr->blind || no_lite()) i = i / 10;
880                 if (p_ptr->confused || p_ptr->image) i = i / 10;
881
882                 /* Extract the difficulty */
883                 j = i - o_ptr->pval;
884
885                 /* Always have a small chance of success */
886                 if (j < 2) j = 2;
887
888                 /* Success -- May still have traps */
889                 if (randint0(100) < j)
890                 {
891 #ifdef JP
892                         msg_print("¸°¤ò¤Ï¤º¤·¤¿¡£");
893 #else
894                         msg_print("You have picked the lock.");
895 #endif
896
897                         gain_exp(1);
898                         flag = TRUE;
899                 }
900
901                 /* Failure -- Keep trying */
902                 else
903                 {
904                         /* We may continue repeating */
905                         more = TRUE;
906                         if (flush_failure) flush();
907 #ifdef JP
908                         msg_print("¸°¤ò¤Ï¤º¤»¤Ê¤«¤Ã¤¿¡£");
909 #else
910                         msg_print("You failed to pick the lock.");
911 #endif
912
913                 }
914         }
915
916         /* Allowed to open */
917         if (flag)
918         {
919                 /* Apply chest traps, if any */
920                 chest_trap(y, x, o_idx);
921
922                 /* Let the Chest drop items */
923                 chest_death(FALSE, y, x, o_idx);
924         }
925
926         /* Result */
927         return (more);
928 }
929
930
931 #if defined(ALLOW_EASY_OPEN) || defined(ALLOW_EASY_DISARM) /* TNB */
932
933 /*
934  * Return TRUE if the given feature is an open door
935  */
936 static bool is_open(int feat)
937 {
938         return have_flag(f_info[feat].flags, FF_CLOSE) && (feat != feat_state(feat, FF_CLOSE));
939 }
940
941
942 /*
943  * Return the number of features around (or under) the character.
944  * Usually look for doors and floor traps.
945  */
946 static int count_dt(int *y, int *x, bool (*test)(int feat), bool under)
947 {
948         int d, count, xx, yy;
949
950         /* Count how many matches */
951         count = 0;
952
953         /* Check around (and under) the character */
954         for (d = 0; d < 9; d++)
955         {
956                 cave_type *c_ptr;
957                 s16b feat;
958
959                 /* if not searching under player continue */
960                 if ((d == 8) && !under) continue;
961
962                 /* Extract adjacent (legal) location */
963                 yy = py + ddy_ddd[d];
964                 xx = px + ddx_ddd[d];
965
966                 /* Get the cave */
967                 c_ptr = &cave[yy][xx];
968
969                 /* Must have knowledge */
970                 if (!(c_ptr->info & (CAVE_MARK))) continue;
971
972                 /* Feature code (applying "mimic" field) */
973                 feat = get_feat_mimic(c_ptr);
974
975                 /* Not looking for this feature */
976                 if (!((*test)(feat))) continue;
977
978                 /* OK */
979                 ++count;
980
981                 /* Remember the location. Only useful if only one match */
982                 *y = yy;
983                 *x = xx;
984         }
985
986         /* All done */
987         return count;
988 }
989
990
991 /*
992  * Return the number of chests around (or under) the character.
993  * If requested, count only trapped chests.
994  */
995 static int count_chests(int *y, int *x, bool trapped)
996 {
997         int d, count, o_idx;
998
999         object_type *o_ptr;
1000
1001         /* Count how many matches */
1002         count = 0;
1003
1004         /* Check around (and under) the character */
1005         for (d = 0; d < 9; d++)
1006         {
1007                 /* Extract adjacent (legal) location */
1008                 int yy = py + ddy_ddd[d];
1009                 int xx = px + ddx_ddd[d];
1010
1011                 /* No (visible) chest is there */
1012                 if ((o_idx = chest_check(yy, xx)) == 0) continue;
1013
1014                 /* Grab the object */
1015                 o_ptr = &o_list[o_idx];
1016
1017                 /* Already open */
1018                 if (o_ptr->pval == 0) continue;
1019
1020                 /* No (known) traps here */
1021                 if (trapped && (!object_is_known(o_ptr) ||
1022                         !chest_traps[o_ptr->pval])) continue;
1023
1024                 /* OK */
1025                 ++count;
1026
1027                 /* Remember the location. Only useful if only one match */
1028                 *y = yy;
1029                 *x = xx;
1030         }
1031
1032         /* All done */
1033         return count;
1034 }
1035
1036
1037 /*
1038  * Convert an adjacent location to a direction.
1039  */
1040 static int coords_to_dir(int y, int x)
1041 {
1042         int d[3][3] = { {7, 4, 1}, {8, 5, 2}, {9, 6, 3} };
1043         int dy, dx;
1044
1045         dy = y - py;
1046         dx = x - px;
1047
1048         /* Paranoia */
1049         if (ABS(dx) > 1 || ABS(dy) > 1) return (0);
1050
1051         return d[dx + 1][dy + 1];
1052 }
1053
1054 #endif /* defined(ALLOW_EASY_OPEN) || defined(ALLOW_EASY_DISARM) -- TNB */
1055
1056
1057 /*
1058  * Perform the basic "open" command on doors
1059  *
1060  * Assume destination is a closed/locked/jammed door
1061  *
1062  * Assume there is no monster blocking the destination
1063  *
1064  * Returns TRUE if repeated commands may continue
1065  */
1066 static bool do_cmd_open_aux(int y, int x)
1067 {
1068         int i, j;
1069
1070         /* Get requested grid */
1071         cave_type *c_ptr = &cave[y][x];
1072
1073         feature_type *f_ptr = &f_info[c_ptr->feat];
1074
1075         bool more = FALSE;
1076
1077
1078         /* Take a turn */
1079         energy_use = 100;
1080
1081         /* Seeing true feature code (ignore mimic) */
1082
1083         /* Jammed door */
1084         if (!have_flag(f_ptr->flags, FF_OPEN))
1085         {
1086                 /* Stuck */
1087 #ifdef JP
1088                 msg_format("%s¤Ï¤¬¤Ã¤Á¤ê¤ÈÊĤ¸¤é¤ì¤Æ¤¤¤ë¤è¤¦¤À¡£", f_name + f_info[get_feat_mimic(c_ptr)].name);
1089 #else
1090                 msg_format("The %s appears to be stuck.", f_name + f_info[get_feat_mimic(c_ptr)].name);
1091 #endif
1092
1093         }
1094
1095         /* Locked door */
1096         else if (f_ptr->power)
1097         {
1098                 /* Disarm factor */
1099                 i = p_ptr->skill_dis;
1100
1101                 /* Penalize some conditions */
1102                 if (p_ptr->blind || no_lite()) i = i / 10;
1103                 if (p_ptr->confused || p_ptr->image) i = i / 10;
1104
1105                 /* Extract the lock power */
1106                 j = f_ptr->power;
1107
1108                 /* Extract the difficulty XXX XXX XXX */
1109                 j = i - (j * 4);
1110
1111                 /* Always have a small chance of success */
1112                 if (j < 2) j = 2;
1113
1114                 /* Success */
1115                 if (randint0(100) < j)
1116                 {
1117                         /* Message */
1118 #ifdef JP
1119                         msg_print("¸°¤ò¤Ï¤º¤·¤¿¡£");
1120 #else
1121                         msg_print("You have picked the lock.");
1122 #endif
1123
1124                         /* Open the door */
1125                         cave_alter_feat(y, x, FF_OPEN);
1126
1127                         /* Update some things */
1128                         p_ptr->update |= (PU_VIEW | PU_LITE | PU_MONSTERS | PU_MON_LITE);
1129
1130                         /* Sound */
1131                         sound(SOUND_OPENDOOR);
1132
1133                         /* Experience */
1134                         gain_exp(1);
1135                 }
1136
1137                 /* Failure */
1138                 else
1139                 {
1140                         /* Failure */
1141                         if (flush_failure) flush();
1142
1143                         /* Message */
1144 #ifdef JP
1145                         msg_print("¸°¤ò¤Ï¤º¤»¤Ê¤«¤Ã¤¿¡£");
1146 #else
1147                         msg_print("You failed to pick the lock.");
1148 #endif
1149
1150
1151                         /* We may keep trying */
1152                         more = TRUE;
1153                 }
1154         }
1155
1156         /* Closed door */
1157         else
1158         {
1159                 /* Open the door */
1160                 cave_alter_feat(y, x, FF_OPEN);
1161
1162                 /* Update some things */
1163                 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MONSTERS | PU_MON_LITE);
1164
1165                 /* Sound */
1166                 sound(SOUND_OPENDOOR);
1167         }
1168
1169         /* Result */
1170         return (more);
1171 }
1172
1173
1174
1175 /*
1176  * Open a closed/locked/jammed door or a closed/locked chest.
1177  *
1178  * Unlocking a locked door/chest is worth one experience point.
1179  */
1180 void do_cmd_open(void)
1181 {
1182         int y, x, dir;
1183
1184         s16b o_idx;
1185
1186         bool more = FALSE;
1187
1188         if (p_ptr->special_defense & KATA_MUSOU)
1189         {
1190                 set_action(ACTION_NONE);
1191         }
1192
1193 #ifdef ALLOW_EASY_OPEN /* TNB */
1194
1195         /* Option: Pick a direction */
1196         if (easy_open)
1197         {
1198                 int num_doors, num_chests;
1199
1200                 /* Count closed doors (locked or jammed) */
1201                 num_doors = count_dt(&y, &x, is_closed_door, FALSE);
1202
1203                 /* Count chests (locked) */
1204                 num_chests = count_chests(&y, &x, FALSE);
1205
1206                 /* See if only one target */
1207                 if (num_doors || num_chests)
1208                 {
1209                         bool too_many = (num_doors && num_chests) || (num_doors > 1) ||
1210                             (num_chests > 1);
1211                         if (!too_many) command_dir = coords_to_dir(y, x);
1212                 }
1213         }
1214
1215 #endif /* ALLOW_EASY_OPEN -- TNB */
1216
1217         /* Allow repeated command */
1218         if (command_arg)
1219         {
1220                 /* Set repeat count */
1221                 command_rep = command_arg - 1;
1222
1223                 /* Redraw the state */
1224                 p_ptr->redraw |= (PR_STATE);
1225
1226                 /* Cancel the arg */
1227                 command_arg = 0;
1228         }
1229
1230         /* Get a "repeated" direction */
1231         if (get_rep_dir(&dir, TRUE))
1232         {
1233                 s16b feat;
1234                 cave_type *c_ptr;
1235
1236                 /* Get requested location */
1237                 y = py + ddy[dir];
1238                 x = px + ddx[dir];
1239
1240                 /* Get requested grid */
1241                 c_ptr = &cave[y][x];
1242
1243                 /* Feature code (applying "mimic" field) */
1244                 feat = get_feat_mimic(c_ptr);
1245
1246                 /* Check for chest */
1247                 o_idx = chest_check(y, x);
1248
1249                 /* Nothing useful */
1250                 if (!have_flag(f_info[feat].flags, FF_OPEN) && !o_idx)
1251                 {
1252                         /* Message */
1253 #ifdef JP
1254                 msg_print("¤½¤³¤Ë¤Ï³«¤±¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
1255 #else
1256                         msg_print("You see nothing there to open.");
1257 #endif
1258
1259                 }
1260
1261                 /* Monster in the way */
1262                 else if (c_ptr->m_idx && p_ptr->riding != c_ptr->m_idx)
1263                 {
1264                         /* Take a turn */
1265                         energy_use = 100;
1266
1267                         /* Message */
1268 #ifdef JP
1269                 msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
1270 #else
1271                         msg_print("There is a monster in the way!");
1272 #endif
1273
1274
1275                         /* Attack */
1276                         py_attack(y, x, 0);
1277                 }
1278
1279                 /* Handle chests */
1280                 else if (o_idx)
1281                 {
1282                         /* Open the chest */
1283                         more = do_cmd_open_chest(y, x, o_idx);
1284                 }
1285
1286                 /* Handle doors */
1287                 else
1288                 {
1289                         /* Open the door */
1290                         more = do_cmd_open_aux(y, x);
1291                 }
1292         }
1293
1294         /* Cancel repeat unless we may continue */
1295         if (!more) disturb(0, 0);
1296 }
1297
1298
1299
1300 /*
1301  * Perform the basic "close" command
1302  *
1303  * Assume destination is an open/broken door
1304  *
1305  * Assume there is no monster blocking the destination
1306  *
1307  * Returns TRUE if repeated commands may continue
1308  */
1309 static bool do_cmd_close_aux(int y, int x)
1310 {
1311         /* Get grid and contents */
1312         cave_type *c_ptr = &cave[y][x];
1313         s16b      old_feat = c_ptr->feat;
1314         bool      more = FALSE;
1315
1316         /* Take a turn */
1317         energy_use = 100;
1318
1319         /* Seeing true feature code (ignore mimic) */
1320
1321         /* Open door */
1322         if (have_flag(f_info[old_feat].flags, FF_CLOSE))
1323         {
1324                 /* Hack -- object in the way */
1325                 if ((c_ptr->o_idx || (c_ptr->info & CAVE_OBJECT)) && (feat_state(old_feat, FF_CLOSE) != old_feat))
1326                 {
1327                         /* Message */
1328 #ifdef JP
1329                         msg_print("²¿¤«¤¬¤Ä¤Ã¤«¤¨¤ÆÊĤޤé¤Ê¤¤¡£");
1330 #else
1331                         msg_print("There seems stuck.");
1332 #endif
1333                 }
1334                 else
1335                 {
1336                         /* Close the door */
1337                         cave_alter_feat(y, x, FF_CLOSE);
1338
1339                         /* Broken door */
1340                         if (old_feat == c_ptr->feat)
1341                         {
1342                                 /* Message */
1343 #ifdef JP
1344                                 msg_print("¥É¥¢¤Ï²õ¤ì¤Æ¤·¤Þ¤Ã¤Æ¤¤¤ë¡£");
1345 #else
1346                                 msg_print("The door appears to be broken.");
1347 #endif
1348                         }
1349                         else
1350                         {
1351                                 /* Update some things */
1352                                 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MONSTERS | PU_MON_LITE);
1353
1354                                 /* Sound */
1355                                 sound(SOUND_SHUTDOOR);
1356                         }
1357                 }
1358         }
1359
1360         /* Result */
1361         return (more);
1362 }
1363
1364
1365 /*
1366  * Close an open door.
1367  */
1368 void do_cmd_close(void)
1369 {
1370         int y, x, dir;
1371
1372         bool more = FALSE;
1373
1374         if (p_ptr->special_defense & KATA_MUSOU)
1375         {
1376                 set_action(ACTION_NONE);
1377         }
1378
1379 #ifdef ALLOW_EASY_OPEN /* TNB */
1380
1381         /* Option: Pick a direction */
1382         if (easy_open)
1383         {
1384                 /* Count open doors */
1385                 if (count_dt(&y, &x, is_open, FALSE) == 1)
1386                 {
1387                         command_dir = coords_to_dir(y, x);
1388                 }
1389         }
1390
1391 #endif /* ALLOW_EASY_OPEN -- TNB */
1392
1393         /* Allow repeated command */
1394         if (command_arg)
1395         {
1396                 /* Set repeat count */
1397                 command_rep = command_arg - 1;
1398
1399                 /* Redraw the state */
1400                 p_ptr->redraw |= (PR_STATE);
1401
1402                 /* Cancel the arg */
1403                 command_arg = 0;
1404         }
1405
1406         /* Get a "repeated" direction */
1407         if (get_rep_dir(&dir,FALSE))
1408         {
1409                 cave_type *c_ptr;
1410                 s16b feat;
1411
1412                 /* Get requested location */
1413                 y = py + ddy[dir];
1414                 x = px + ddx[dir];
1415
1416                 /* Get grid and contents */
1417                 c_ptr = &cave[y][x];
1418
1419                 /* Feature code (applying "mimic" field) */
1420                 feat = get_feat_mimic(c_ptr);
1421
1422                 /* Require open/broken door */
1423                 if (!have_flag(f_info[feat].flags, FF_CLOSE))
1424                 {
1425                         /* Message */
1426 #ifdef JP
1427                         msg_print("¤½¤³¤Ë¤ÏÊĤ¸¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
1428 #else
1429                         msg_print("You see nothing there to close.");
1430 #endif
1431                 }
1432
1433                 /* Monster in the way */
1434                 else if (c_ptr->m_idx)
1435                 {
1436                         /* Take a turn */
1437                         energy_use = 100;
1438
1439                         /* Message */
1440 #ifdef JP
1441                         msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
1442 #else
1443                         msg_print("There is a monster in the way!");
1444 #endif
1445
1446                         /* Attack */
1447                         py_attack(y, x, 0);
1448                 }
1449
1450                 /* Close the door */
1451                 else
1452                 {
1453                         /* Close the door */
1454                         more = do_cmd_close_aux(y, x);
1455                 }
1456         }
1457
1458         /* Cancel repeat unless we may continue */
1459         if (!more) disturb(0, 0);
1460 }
1461
1462
1463 /*
1464  * Determine if a given grid may be "tunneled"
1465  */
1466 static bool do_cmd_tunnel_test(int y, int x)
1467 {
1468         cave_type *c_ptr = &cave[y][x];
1469
1470         /* Must have knowledge */
1471         if (!(c_ptr->info & CAVE_MARK))
1472         {
1473                 /* Message */
1474 #ifdef JP
1475                 msg_print("¤½¤³¤Ë¤Ï²¿¤â¸«Åö¤¿¤é¤Ê¤¤¡£");
1476 #else
1477                 msg_print("You see nothing there.");
1478 #endif
1479
1480                 /* Nope */
1481                 return (FALSE);
1482         }
1483
1484         /* Must be a wall/door/etc */
1485         if (!have_flag(f_flags_grid(c_ptr), FF_TUNNEL))
1486         {
1487                 /* Message */
1488 #ifdef JP
1489                 msg_print("¤½¤³¤Ë¤Ï·¡¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
1490 #else
1491                 msg_print("You see nothing there to tunnel.");
1492 #endif
1493
1494                 /* Nope */
1495                 return (FALSE);
1496         }
1497
1498         /* Okay */
1499         return (TRUE);
1500 }
1501
1502
1503 /*
1504  * Perform the basic "tunnel" command
1505  *
1506  * Assumes that no monster is blocking the destination
1507  *
1508  * Do not use twall anymore
1509  *
1510  * Returns TRUE if repeated commands may continue
1511  */
1512 static bool do_cmd_tunnel_aux(int y, int x)
1513 {
1514         cave_type *c_ptr;
1515         feature_type *f_ptr, *mimic_f_ptr;
1516         int power;
1517         cptr name;
1518         bool more = FALSE;
1519
1520         /* Verify legality */
1521         if (!do_cmd_tunnel_test(y, x)) return (FALSE);
1522
1523         /* Take a turn */
1524         energy_use = 100;
1525
1526         /* Get grid */
1527         c_ptr = &cave[y][x];
1528         f_ptr = &f_info[c_ptr->feat];
1529         power = f_ptr->power;
1530
1531         /* Feature code (applying "mimic" field) */
1532         mimic_f_ptr = &f_info[get_feat_mimic(c_ptr)];
1533
1534         name = f_name + mimic_f_ptr->name;
1535
1536         /* Sound */
1537         sound(SOUND_DIG);
1538
1539         if (have_flag(f_ptr->flags, FF_PERMANENT))
1540         {
1541                 /* Titanium */
1542                 if (have_flag(mimic_f_ptr->flags, FF_PERMANENT))
1543                 {
1544 #ifdef JP
1545                         msg_print("¤³¤Î´ä¤Ï¹Å¤¹¤®¤Æ·¡¤ì¤Ê¤¤¤è¤¦¤À¡£");
1546 #else
1547                         msg_print("This seems to be permanent rock.");
1548 #endif
1549                 }
1550
1551                 /* Map border (mimiccing Permanent wall) */
1552                 else
1553                 {
1554 #ifdef JP
1555                         msg_print("¤½¤³¤Ï·¡¤ì¤Ê¤¤!");
1556 #else
1557                         msg_print("You can't tunnel through that!");
1558 #endif
1559                 }
1560         }
1561
1562         /* Dig or tunnel */
1563         else if (have_flag(f_ptr->flags, FF_CAN_DIG))
1564         {
1565                 /* Dig */
1566                 if (p_ptr->skill_dig > randint0(20 * power))
1567                 {
1568                         /* Message */
1569 #ifdef JP
1570                         msg_format("%s¤ò¤¯¤º¤·¤¿¡£", name);
1571 #else
1572                         msg_format("You have removed the %s.", name);
1573 #endif
1574
1575                         /* Remove the feature */
1576                         cave_alter_feat(y, x, FF_TUNNEL);
1577
1578                         /* Update some things */
1579                         p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MONSTERS | PU_MON_LITE);
1580                 }
1581                 else
1582                 {
1583                         /* Message, keep digging */
1584 #ifdef JP
1585                         msg_format("%s¤ò¤¯¤º¤·¤Æ¤¤¤ë¡£", name);
1586 #else
1587                         msg_format("You dig into the %s.", name);
1588 #endif
1589
1590                         more = TRUE;
1591                 }
1592         }
1593
1594         else
1595         {
1596                 bool tree = have_flag(mimic_f_ptr->flags, FF_TREE);
1597
1598                 /* Tunnel */
1599                 if (p_ptr->skill_dig > power + randint0(40 * power))
1600                 {
1601 #ifdef JP
1602                         if (tree) msg_format("%s¤òÀÚ¤êʧ¤Ã¤¿¡£", name);
1603                         else msg_print("·ê¤ò·¡¤ê½ª¤¨¤¿¡£");
1604 #else
1605                         if (tree) msg_format("You have cleared away the %s.", name);
1606                         else msg_print("You have finished the tunnel.");
1607 #endif
1608
1609                         /* Remove the feature */
1610                         cave_alter_feat(y, x, FF_TUNNEL);
1611
1612                         /* Update some things */
1613                         p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MONSTERS | PU_MON_LITE);
1614
1615                         chg_virtue(V_DILIGENCE, 1);
1616                         chg_virtue(V_NATURE, -1);
1617                 }
1618
1619                 /* Keep trying */
1620                 else
1621                 {
1622                         if (tree)
1623                         {
1624                                 /* We may continue chopping */
1625 #ifdef JP
1626                                 msg_format("%s¤òÀڤäƤ¤¤ë¡£", name);
1627 #else
1628                                 msg_format("You chop away at the %s.", name);
1629 #endif
1630                                 /* Occasional Search XXX XXX */
1631                                 if (randint0(100) < 25) search();
1632                         }
1633                         else
1634                         {
1635                                 /* We may continue tunelling */
1636 #ifdef JP
1637                                 msg_format("%s¤Ë·ê¤ò·¡¤Ã¤Æ¤¤¤ë¡£", name);
1638 #else
1639                                 msg_format("You tunnel into the %s.", name);
1640 #endif
1641                         }
1642
1643                         more = TRUE;
1644                 }
1645         }
1646
1647         if (is_hidden_door(c_ptr))
1648         {
1649                 /* Occasional Search XXX XXX */
1650                 if (randint0(100) < 25) search();
1651         }
1652
1653         /* Result */
1654         return more;
1655 }
1656
1657
1658 /*
1659  * Tunnels through "walls" (including rubble and closed doors)
1660  *
1661  * Note that you must tunnel in order to hit invisible monsters
1662  * in walls, though moving into walls still takes a turn anyway.
1663  *
1664  * Digging is very difficult without a "digger" weapon, but can be
1665  * accomplished by strong players using heavy weapons.
1666  */
1667 void do_cmd_tunnel(void)
1668 {
1669         int                     y, x, dir;
1670
1671         cave_type       *c_ptr;
1672         s16b feat;
1673
1674         bool            more = FALSE;
1675
1676
1677         if (p_ptr->special_defense & KATA_MUSOU)
1678         {
1679                 set_action(ACTION_NONE);
1680         }
1681
1682         /* Allow repeated command */
1683         if (command_arg)
1684         {
1685                 /* Set repeat count */
1686                 command_rep = command_arg - 1;
1687
1688                 /* Redraw the state */
1689                 p_ptr->redraw |= (PR_STATE);
1690
1691                 /* Cancel the arg */
1692                 command_arg = 0;
1693         }
1694
1695         /* Get a direction to tunnel, or Abort */
1696         if (get_rep_dir(&dir,FALSE))
1697         {
1698                 /* Get location */
1699                 y = py + ddy[dir];
1700                 x = px + ddx[dir];
1701
1702                 /* Get grid */
1703                 c_ptr = &cave[y][x];
1704
1705                 /* Feature code (applying "mimic" field) */
1706                 feat = get_feat_mimic(c_ptr);
1707
1708                 /* No tunnelling through doors */
1709                 if (have_flag(f_info[feat].flags, FF_DOOR))
1710                 {
1711                         /* Message */
1712 #ifdef JP
1713                         msg_print("¥É¥¢¤Ï·¡¤ì¤Ê¤¤¡£");
1714 #else
1715                         msg_print("You cannot tunnel through doors.");
1716 #endif
1717                 }
1718
1719                 /* No tunnelling through most features */
1720                 else if (!have_flag(f_info[feat].flags, FF_TUNNEL))
1721                 {
1722 #ifdef JP
1723                         msg_print("¤½¤³¤Ï·¡¤ì¤Ê¤¤¡£");
1724 #else
1725                         msg_print("You can't tunnel through that.");
1726 #endif
1727                 }
1728
1729                 /* A monster is in the way */
1730                 else if (c_ptr->m_idx)
1731                 {
1732                         /* Take a turn */
1733                         energy_use = 100;
1734
1735                         /* Message */
1736 #ifdef JP
1737                         msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
1738 #else
1739                         msg_print("There is a monster in the way!");
1740 #endif
1741
1742                         /* Attack */
1743                         py_attack(y, x, 0);
1744                 }
1745
1746                 /* Try digging */
1747                 else
1748                 {
1749                         /* Tunnel through walls */
1750                         more = do_cmd_tunnel_aux(y, x);
1751                 }
1752         }
1753
1754         /* Cancel repetition unless we can continue */
1755         if (!more) disturb(0, 0);
1756 }
1757
1758
1759 #ifdef ALLOW_EASY_OPEN /* TNB */
1760
1761 /*
1762  * easy_open_door --
1763  *
1764  *      If there is a jammed/closed/locked door at the given location,
1765  *      then attempt to unlock/open it. Return TRUE if an attempt was
1766  *      made (successful or not), otherwise return FALSE.
1767  *
1768  *      The code here should be nearly identical to that in
1769  *      do_cmd_open_test() and do_cmd_open_aux().
1770  */
1771 bool easy_open_door(int y, int x)
1772 {
1773         int i, j;
1774
1775         cave_type *c_ptr = &cave[y][x];
1776         feature_type *f_ptr = &f_info[c_ptr->feat];
1777
1778         /* Must be a closed door */
1779         if (!is_closed_door(c_ptr->feat))
1780         {
1781                 /* Nope */
1782                 return (FALSE);
1783         }
1784
1785         /* Jammed door */
1786         if (!have_flag(f_ptr->flags, FF_OPEN))
1787         {
1788                 /* Stuck */
1789 #ifdef JP
1790                 msg_format("%s¤Ï¤¬¤Ã¤Á¤ê¤ÈÊĤ¸¤é¤ì¤Æ¤¤¤ë¤è¤¦¤À¡£", f_name + f_info[get_feat_mimic(c_ptr)].name);
1791 #else
1792                 msg_format("The %s appears to be stuck.", f_name + f_info[get_feat_mimic(c_ptr)].name);
1793 #endif
1794
1795         }
1796
1797         /* Locked door */
1798         else if (f_ptr->power)
1799         {
1800                 /* Disarm factor */
1801                 i = p_ptr->skill_dis;
1802
1803                 /* Penalize some conditions */
1804                 if (p_ptr->blind || no_lite()) i = i / 10;
1805                 if (p_ptr->confused || p_ptr->image) i = i / 10;
1806
1807                 /* Extract the lock power */
1808                 j = f_ptr->power;
1809
1810                 /* Extract the difficulty XXX XXX XXX */
1811                 j = i - (j * 4);
1812
1813                 /* Always have a small chance of success */
1814                 if (j < 2) j = 2;
1815
1816                 /* Success */
1817                 if (randint0(100) < j)
1818                 {
1819                         /* Message */
1820 #ifdef JP
1821                         msg_print("¸°¤ò¤Ï¤º¤·¤¿¡£");
1822 #else
1823                         msg_print("You have picked the lock.");
1824 #endif
1825
1826
1827                         /* Open the door */
1828                         cave_alter_feat(y, x, FF_OPEN);
1829
1830                         /* Update some things */
1831                         p_ptr->update |= (PU_VIEW | PU_LITE | PU_MONSTERS | PU_MON_LITE);
1832
1833                         /* Sound */
1834                         sound(SOUND_OPENDOOR);
1835
1836                         /* Experience */
1837                         gain_exp(1);
1838                 }
1839
1840                 /* Failure */
1841                 else
1842                 {
1843                         /* Failure */
1844                         if (flush_failure) flush();
1845
1846                         /* Message */
1847 #ifdef JP
1848                         msg_print("¸°¤ò¤Ï¤º¤»¤Ê¤«¤Ã¤¿¡£");
1849 #else
1850                         msg_print("You failed to pick the lock.");
1851 #endif
1852
1853                 }
1854         }
1855
1856         /* Closed door */
1857         else
1858         {
1859                 /* Open the door */
1860                 cave_alter_feat(y, x, FF_OPEN);
1861
1862                 /* Update some things */
1863                 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MONSTERS | PU_MON_LITE);
1864
1865                 /* Sound */
1866                 sound(SOUND_OPENDOOR);
1867         }
1868
1869         /* Result */
1870         return (TRUE);
1871 }
1872
1873 #endif /* ALLOW_EASY_OPEN -- TNB */
1874
1875
1876 /*
1877  * Perform the basic "disarm" command
1878  *
1879  * Assume destination is a visible trap
1880  *
1881  * Assume there is no monster blocking the destination
1882  *
1883  * Returns TRUE if repeated commands may continue
1884  */
1885 static bool do_cmd_disarm_chest(int y, int x, s16b o_idx)
1886 {
1887         int i, j;
1888
1889         bool more = FALSE;
1890
1891         object_type *o_ptr = &o_list[o_idx];
1892
1893
1894         /* Take a turn */
1895         energy_use = 100;
1896
1897         /* Get the "disarm" factor */
1898         i = p_ptr->skill_dis;
1899
1900         /* Penalize some conditions */
1901         if (p_ptr->blind || no_lite()) i = i / 10;
1902         if (p_ptr->confused || p_ptr->image) i = i / 10;
1903
1904         /* Extract the difficulty */
1905         j = i - o_ptr->pval;
1906
1907         /* Always have a small chance of success */
1908         if (j < 2) j = 2;
1909
1910         /* Must find the trap first. */
1911         if (!object_is_known(o_ptr))
1912         {
1913 #ifdef JP
1914                 msg_print("¥È¥é¥Ã¥×¤¬¸«¤¢¤¿¤é¤Ê¤¤¡£");
1915 #else
1916                 msg_print("I don't see any traps.");
1917 #endif
1918
1919         }
1920
1921         /* Already disarmed/unlocked */
1922         else if (o_ptr->pval <= 0)
1923         {
1924 #ifdef JP
1925                 msg_print("È¢¤Ë¤Ï¥È¥é¥Ã¥×¤¬»Å³Ý¤±¤é¤ì¤Æ¤¤¤Ê¤¤¡£");
1926 #else
1927                 msg_print("The chest is not trapped.");
1928 #endif
1929
1930         }
1931
1932         /* No traps to find. */
1933         else if (!chest_traps[o_ptr->pval])
1934         {
1935 #ifdef JP
1936                 msg_print("È¢¤Ë¤Ï¥È¥é¥Ã¥×¤¬»Å³Ý¤±¤é¤ì¤Æ¤¤¤Ê¤¤¡£");
1937 #else
1938                 msg_print("The chest is not trapped.");
1939 #endif
1940
1941         }
1942
1943         /* Success (get a lot of experience) */
1944         else if (randint0(100) < j)
1945         {
1946 #ifdef JP
1947                 msg_print("È¢¤Ë»Å³Ý¤±¤é¤ì¤Æ¤¤¤¿¥È¥é¥Ã¥×¤ò²ò½ü¤·¤¿¡£");
1948 #else
1949                 msg_print("You have disarmed the chest.");
1950 #endif
1951
1952                 gain_exp(o_ptr->pval);
1953                 o_ptr->pval = (0 - o_ptr->pval);
1954         }
1955
1956         /* Failure -- Keep trying */
1957         else if ((i > 5) && (randint1(i) > 5))
1958         {
1959                 /* We may keep trying */
1960                 more = TRUE;
1961                 if (flush_failure) flush();
1962 #ifdef JP
1963                 msg_print("È¢¤Î¥È¥é¥Ã¥×²ò½ü¤Ë¼ºÇÔ¤·¤¿¡£");
1964 #else
1965                 msg_print("You failed to disarm the chest.");
1966 #endif
1967
1968         }
1969
1970         /* Failure -- Set off the trap */
1971         else
1972         {
1973 #ifdef JP
1974                 msg_print("¥È¥é¥Ã¥×¤òºîÆ°¤µ¤»¤Æ¤·¤Þ¤Ã¤¿¡ª");
1975 #else
1976                 msg_print("You set off a trap!");
1977 #endif
1978
1979                 sound(SOUND_FAIL);
1980                 chest_trap(y, x, o_idx);
1981         }
1982
1983         /* Result */
1984         return (more);
1985 }
1986
1987
1988 /*
1989  * Perform the basic "disarm" command
1990  *
1991  * Assume destination is a visible trap
1992  *
1993  * Assume there is no monster blocking the destination
1994  *
1995  * Returns TRUE if repeated commands may continue
1996  */
1997 #ifdef ALLOW_EASY_DISARM /* TNB */
1998
1999 bool do_cmd_disarm_aux(int y, int x, int dir)
2000
2001 #else /* ALLOW_EASY_DISARM -- TNB */
2002
2003 static bool do_cmd_disarm_aux(int y, int x, int dir)
2004
2005 #endif /* ALLOW_EASY_DISARM -- TNB */
2006 {
2007         /* Get grid and contents */
2008         cave_type *c_ptr = &cave[y][x];
2009
2010         /* Get feature */
2011         feature_type *f_ptr = &f_info[c_ptr->feat];
2012
2013         /* Access trap name */
2014         cptr name = (f_name + f_ptr->name);
2015
2016         /* Extract trap "power" */
2017         int power = f_ptr->power;
2018
2019         bool more = FALSE;
2020
2021         /* Get the "disarm" factor */
2022         int i = p_ptr->skill_dis;
2023
2024         int j;
2025
2026         /* Take a turn */
2027         energy_use = 100;
2028
2029         /* Penalize some conditions */
2030         if (p_ptr->blind || no_lite()) i = i / 10;
2031         if (p_ptr->confused || p_ptr->image) i = i / 10;
2032
2033         /* Extract the difficulty */
2034         j = i - power;
2035
2036         /* Always have a small chance of success */
2037         if (j < 2) j = 2;
2038
2039         /* Success */
2040         if (randint0(100) < j)
2041         {
2042                 /* Message */
2043 #ifdef JP
2044                 msg_format("%s¤ò²ò½ü¤·¤¿¡£", name);
2045 #else
2046                 msg_format("You have disarmed the %s.", name);
2047 #endif
2048
2049                 /* Reward */
2050                 gain_exp(power);
2051
2052                 /* Remove the trap */
2053                 cave_alter_feat(y, x, FF_DISARM);
2054
2055 #ifdef ALLOW_EASY_DISARM /* TNB */
2056
2057                 /* Move the player onto the trap */
2058                 move_player(dir, easy_disarm, FALSE);
2059
2060 #else /* ALLOW_EASY_DISARM -- TNB */
2061
2062                 /* move the player onto the trap grid */
2063                 move_player(dir, FALSE, FALSE);
2064
2065 #endif /* ALLOW_EASY_DISARM -- TNB */
2066         }
2067
2068         /* Failure -- Keep trying */
2069         else if ((i > 5) && (randint1(i) > 5))
2070         {
2071                 /* Failure */
2072                 if (flush_failure) flush();
2073
2074                 /* Message */
2075 #ifdef JP
2076                 msg_format("%s¤Î²ò½ü¤Ë¼ºÇÔ¤·¤¿¡£", name);
2077 #else
2078                 msg_format("You failed to disarm the %s.", name);
2079 #endif
2080
2081                 /* We may keep trying */
2082                 more = TRUE;
2083         }
2084
2085         /* Failure -- Set off the trap */
2086         else
2087         {
2088                 /* Message */
2089 #ifdef JP
2090                 msg_format("%s¤òºîÆ°¤µ¤»¤Æ¤·¤Þ¤Ã¤¿¡ª", name);
2091 #else
2092                 msg_format("You set off the %s!", name);
2093 #endif
2094
2095 #ifdef ALLOW_EASY_DISARM /* TNB */
2096
2097                 /* Move the player onto the trap */
2098                 move_player(dir, easy_disarm, FALSE);
2099
2100 #else /* ALLOW_EASY_DISARM -- TNB */
2101
2102                 /* Move the player onto the trap */
2103                 move_player(dir, FALSE, FALSE);
2104
2105 #endif /* ALLOW_EASY_DISARM -- TNB */
2106         }
2107
2108         /* Result */
2109         return (more);
2110 }
2111
2112
2113 /*
2114  * Disarms a trap, or chest
2115  */
2116 void do_cmd_disarm(void)
2117 {
2118         int y, x, dir;
2119
2120         s16b o_idx;
2121
2122         bool more = FALSE;
2123
2124         if (p_ptr->special_defense & KATA_MUSOU)
2125         {
2126                 set_action(ACTION_NONE);
2127         }
2128
2129 #ifdef ALLOW_EASY_DISARM /* TNB */
2130
2131         /* Option: Pick a direction */
2132         if (easy_disarm)
2133         {
2134                 int num_traps, num_chests;
2135
2136                 /* Count visible traps */
2137                 num_traps = count_dt(&y, &x, is_trap, TRUE);
2138
2139                 /* Count chests (trapped) */
2140                 num_chests = count_chests(&y, &x, TRUE);
2141
2142                 /* See if only one target */
2143                 if (num_traps || num_chests)
2144                 {
2145                         bool too_many = (num_traps && num_chests) || (num_traps > 1) ||
2146                             (num_chests > 1);
2147                         if (!too_many) command_dir = coords_to_dir(y, x);
2148                 }
2149         }
2150
2151 #endif /* ALLOW_EASY_DISARM -- TNB */
2152
2153         /* Allow repeated command */
2154         if (command_arg)
2155         {
2156                 /* Set repeat count */
2157                 command_rep = command_arg - 1;
2158
2159                 /* Redraw the state */
2160                 p_ptr->redraw |= (PR_STATE);
2161
2162                 /* Cancel the arg */
2163                 command_arg = 0;
2164         }
2165
2166         /* Get a direction (or abort) */
2167         if (get_rep_dir(&dir,TRUE))
2168         {
2169                 cave_type *c_ptr;
2170                 s16b feat;
2171
2172                 /* Get location */
2173                 y = py + ddy[dir];
2174                 x = px + ddx[dir];
2175
2176                 /* Get grid and contents */
2177                 c_ptr = &cave[y][x];
2178
2179                 /* Feature code (applying "mimic" field) */
2180                 feat = get_feat_mimic(c_ptr);
2181
2182                 /* Check for chests */
2183                 o_idx = chest_check(y, x);
2184
2185                 /* Disarm a trap */
2186                 if (!is_trap(feat) && !o_idx)
2187                 {
2188                         /* Message */
2189 #ifdef JP
2190                         msg_print("¤½¤³¤Ë¤Ï²ò½ü¤¹¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
2191 #else
2192                         msg_print("You see nothing there to disarm.");
2193 #endif
2194
2195                 }
2196
2197                 /* Monster in the way */
2198                 else if (c_ptr->m_idx && p_ptr->riding != c_ptr->m_idx)
2199                 {
2200                         /* Message */
2201 #ifdef JP
2202                         msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
2203 #else
2204                         msg_print("There is a monster in the way!");
2205 #endif
2206
2207
2208                         /* Attack */
2209                         py_attack(y, x, 0);
2210                 }
2211
2212                 /* Disarm chest */
2213                 else if (o_idx)
2214                 {
2215                         /* Disarm the chest */
2216                         more = do_cmd_disarm_chest(y, x, o_idx);
2217                 }
2218
2219                 /* Disarm trap */
2220                 else
2221                 {
2222                         /* Disarm the trap */
2223                         more = do_cmd_disarm_aux(y, x, dir);
2224                 }
2225         }
2226
2227         /* Cancel repeat unless told not to */
2228         if (!more) disturb(0, 0);
2229 }
2230
2231
2232 /*
2233  * Perform the basic "bash" command
2234  *
2235  * Assume destination is a closed/locked/jammed door
2236  *
2237  * Assume there is no monster blocking the destination
2238  *
2239  * Returns TRUE if repeated commands may continue
2240  */
2241 static bool do_cmd_bash_aux(int y, int x, int dir)
2242 {
2243         /* Get grid */
2244         cave_type       *c_ptr = &cave[y][x];
2245
2246         /* Hack -- Bash power based on strength */
2247         /* (Ranges from 3 to 20 to 100 to 200) */
2248         int bash = adj_str_blow[p_ptr->stat_ind[A_STR]];
2249
2250         /* Extract door power */
2251         int temp = f_info[c_ptr->feat].power;
2252
2253         bool            more = FALSE;
2254
2255         cptr name = f_name + f_info[get_feat_mimic(c_ptr)].name;
2256
2257         /* Take a turn */
2258         energy_use = 100;
2259
2260         /* Message */
2261 #ifdef JP
2262         msg_format("%s¤ËÂÎÅö¤¿¤ê¤ò¤·¤¿¡ª", name);
2263 #else
2264         msg_format("You smash into the %s!", name);
2265 #endif
2266
2267         /* Compare bash power to door power XXX XXX XXX */
2268         temp = (bash - (temp * 10));
2269
2270         if (p_ptr->pclass == CLASS_BERSERKER) temp *= 2;
2271
2272         /* Hack -- always have a chance */
2273         if (temp < 1) temp = 1;
2274
2275         /* Hack -- attempt to bash down the door */
2276         if (randint0(100) < temp)
2277         {
2278                 /* Message */
2279 #ifdef JP
2280                 msg_format("%s¤ò²õ¤·¤¿¡ª", name);
2281 #else
2282                 msg_format("The %s crashes open!", name);
2283 #endif
2284
2285
2286                 /* Break down the door */
2287                 if ((randint0(100) < 50) || (feat_state(c_ptr->feat, FF_OPEN) == c_ptr->feat))
2288                 {
2289                         cave_alter_feat(y, x, FF_BASH);
2290                 }
2291
2292                 /* Open the door */
2293                 else
2294                 {
2295                         cave_alter_feat(y, x, FF_OPEN);
2296                 }
2297
2298                 /* Sound */
2299                 sound(SOUND_OPENDOOR);
2300
2301                 /* Hack -- Fall through the door */
2302                 move_player(dir, FALSE, FALSE);
2303
2304                 /* Update some things */
2305                 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE);
2306                 p_ptr->update |= (PU_DISTANCE);
2307         }
2308
2309         /* Saving throw against stun */
2310         else if (randint0(100) < adj_dex_safe[p_ptr->stat_ind[A_DEX]] +
2311                  p_ptr->lev)
2312         {
2313                 /* Message */
2314 #ifdef JP
2315                 msg_format("¤³¤Î%s¤Ï´è¾æ¤À¡£", name);
2316 #else
2317                 msg_format("The %s holds firm.", name);
2318 #endif
2319
2320
2321                 /* Allow repeated bashing */
2322                 more = TRUE;
2323         }
2324
2325         /* High dexterity yields coolness */
2326         else
2327         {
2328                 /* Message */
2329 #ifdef JP
2330                 msg_print("ÂΤΥХé¥ó¥¹¤ò¤¯¤º¤·¤Æ¤·¤Þ¤Ã¤¿¡£");
2331 #else
2332                 msg_print("You are off-balance.");
2333 #endif
2334
2335
2336                 /* Hack -- Lose balance ala paralysis */
2337                 (void)set_paralyzed(p_ptr->paralyzed + 2 + randint0(2));
2338         }
2339
2340         /* Result */
2341         return (more);
2342 }
2343
2344
2345 /*
2346  * Bash open a door, success based on character strength
2347  *
2348  * For a closed door, pval is positive if locked; negative if stuck.
2349  *
2350  * For an open door, pval is positive for a broken door.
2351  *
2352  * A closed door can be opened - harder if locked. Any door might be
2353  * bashed open (and thereby broken). Bashing a door is (potentially)
2354  * faster! You move into the door way. To open a stuck door, it must
2355  * be bashed. A closed door can be jammed (see do_cmd_spike()).
2356  *
2357  * Creatures can also open or bash doors, see elsewhere.
2358  */
2359 void do_cmd_bash(void)
2360 {
2361         int                     y, x, dir;
2362
2363         cave_type       *c_ptr;
2364
2365         bool            more = FALSE;
2366
2367
2368         if (p_ptr->special_defense & KATA_MUSOU)
2369         {
2370                 set_action(ACTION_NONE);
2371         }
2372
2373         /* Allow repeated command */
2374         if (command_arg)
2375         {
2376                 /* Set repeat count */
2377                 command_rep = command_arg - 1;
2378
2379                 /* Redraw the state */
2380                 p_ptr->redraw |= (PR_STATE);
2381
2382                 /* Cancel the arg */
2383                 command_arg = 0;
2384         }
2385
2386         /* Get a "repeated" direction */
2387         if (get_rep_dir(&dir,FALSE))
2388         {
2389                 s16b feat;
2390
2391                 /* Bash location */
2392                 y = py + ddy[dir];
2393                 x = px + ddx[dir];
2394
2395                 /* Get grid */
2396                 c_ptr = &cave[y][x];
2397
2398                 /* Feature code (applying "mimic" field) */
2399                 feat = get_feat_mimic(c_ptr);
2400
2401                 /* Nothing useful */
2402                 if (!have_flag(f_info[feat].flags, FF_BASH))
2403                 {
2404                         /* Message */
2405 #ifdef JP
2406                         msg_print("¤½¤³¤Ë¤ÏÂÎÅö¤¿¤ê¤¹¤ë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
2407 #else
2408                         msg_print("You see nothing there to bash.");
2409 #endif
2410
2411                 }
2412
2413                 /* Monster in the way */
2414                 else if (c_ptr->m_idx)
2415                 {
2416                         /* Take a turn */
2417                         energy_use = 100;
2418
2419                         /* Message */
2420 #ifdef JP
2421                         msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
2422 #else
2423                         msg_print("There is a monster in the way!");
2424 #endif
2425
2426
2427                         /* Attack */
2428                         py_attack(y, x, 0);
2429                 }
2430
2431                 /* Bash a closed door */
2432                 else
2433                 {
2434                         /* Bash the door */
2435                         more = do_cmd_bash_aux(y, x, dir);
2436                 }
2437         }
2438
2439         /* Unless valid action taken, cancel bash */
2440         if (!more) disturb(0, 0);
2441 }
2442
2443
2444 /*
2445  * Manipulate an adjacent grid in some way
2446  *
2447  * Attack monsters, tunnel through walls, disarm traps, open doors.
2448  *
2449  * Consider confusion XXX XXX XXX
2450  *
2451  * This command must always take a turn, to prevent free detection
2452  * of invisible monsters.
2453  */
2454 void do_cmd_alter(void)
2455 {
2456         int                     y, x, dir;
2457
2458         cave_type       *c_ptr;
2459
2460         bool            more = FALSE;
2461
2462
2463         if (p_ptr->special_defense & KATA_MUSOU)
2464         {
2465                 set_action(ACTION_NONE);
2466         }
2467
2468         /* Allow repeated command */
2469         if (command_arg)
2470         {
2471                 /* Set repeat count */
2472                 command_rep = command_arg - 1;
2473
2474                 /* Redraw the state */
2475                 p_ptr->redraw |= (PR_STATE);
2476
2477                 /* Cancel the arg */
2478                 command_arg = 0;
2479         }
2480
2481         /* Get a direction */
2482         if (get_rep_dir(&dir,TRUE))
2483         {
2484                 s16b feat;
2485                 feature_type *f_ptr;
2486
2487                 /* Get location */
2488                 y = py + ddy[dir];
2489                 x = px + ddx[dir];
2490
2491                 /* Get grid */
2492                 c_ptr = &cave[y][x];
2493
2494                 /* Feature code (applying "mimic" field) */
2495                 feat = get_feat_mimic(c_ptr);
2496                 f_ptr = &f_info[feat];
2497
2498                 /* Take a turn */
2499                 energy_use = 100;
2500
2501                 /* Attack monsters */
2502                 if (c_ptr->m_idx)
2503                 {
2504                         /* Attack */
2505                         py_attack(y, x, 0);
2506                 }
2507
2508                 /* Locked doors */
2509                 else if (have_flag(f_ptr->flags, FF_OPEN))
2510                 {
2511                         more = do_cmd_open_aux(y, x);
2512                 }
2513
2514                 /* Bash jammed doors */
2515                 else if (have_flag(f_ptr->flags, FF_BASH))
2516                 {
2517                         more = do_cmd_bash_aux(y, x, dir);
2518                 }
2519
2520                 /* Tunnel through walls */
2521                 else if (have_flag(f_ptr->flags, FF_TUNNEL))
2522                 {
2523                         more = do_cmd_tunnel_aux(y, x);
2524                 }
2525
2526                 /* Close open doors */
2527                 else if (have_flag(f_ptr->flags, FF_CLOSE))
2528                 {
2529                         more = do_cmd_close_aux(y, x);
2530                 }
2531
2532                 /* Disarm traps */
2533                 else if (have_flag(f_ptr->flags, FF_DISARM))
2534                 {
2535                         more = do_cmd_disarm_aux(y, x, dir);
2536                 }
2537
2538                 /* Oops */
2539                 else
2540                 {
2541                         /* Oops */
2542 #ifdef JP
2543                         msg_print("²¿¤â¤Ê¤¤¶õÃæ¤ò¹¶·â¤·¤¿¡£");
2544 #else
2545                         msg_print("You attack the empty air.");
2546 #endif
2547
2548                 }
2549         }
2550
2551         /* Cancel repetition unless we can continue */
2552         if (!more) disturb(0, 0);
2553 }
2554
2555
2556 /*
2557  * Find the index of some "spikes", if possible.
2558  *
2559  * XXX XXX XXX Let user choose a pile of spikes, perhaps?
2560  */
2561 static bool get_spike(int *ip)
2562 {
2563         int i;
2564
2565         /* Check every item in the pack */
2566         for (i = 0; i < INVEN_PACK; i++)
2567         {
2568                 object_type *o_ptr = &inventory[i];
2569
2570                 /* Skip non-objects */
2571                 if (!o_ptr->k_idx) continue;
2572
2573                 /* Check the "tval" code */
2574                 if (o_ptr->tval == TV_SPIKE)
2575                 {
2576                         /* Save the spike index */
2577                         (*ip) = i;
2578
2579                         /* Success */
2580                         return (TRUE);
2581                 }
2582         }
2583
2584         /* Oops */
2585         return (FALSE);
2586 }
2587
2588
2589 /*
2590  * Jam a closed door with a spike
2591  *
2592  * This command may NOT be repeated
2593  */
2594 void do_cmd_spike(void)
2595 {
2596         int dir;
2597
2598         if (p_ptr->special_defense & KATA_MUSOU)
2599         {
2600                 set_action(ACTION_NONE);
2601         }
2602
2603         /* Get a "repeated" direction */
2604         if (get_rep_dir(&dir,FALSE))
2605         {
2606                 int y, x, item;
2607                 cave_type *c_ptr;
2608                 s16b feat;
2609
2610                 /* Get location */
2611                 y = py + ddy[dir];
2612                 x = px + ddx[dir];
2613
2614                 /* Get grid and contents */
2615                 c_ptr = &cave[y][x];
2616
2617                 /* Feature code (applying "mimic" field) */
2618                 feat = get_feat_mimic(c_ptr);
2619
2620                 /* Require closed door */
2621                 if (!have_flag(f_info[feat].flags, FF_SPIKE))
2622                 {
2623                         /* Message */
2624 #ifdef JP
2625                         msg_print("¤½¤³¤Ë¤Ï¤¯¤µ¤Ó¤òÂǤƤë¤â¤Î¤¬¸«Åö¤¿¤é¤Ê¤¤¡£");
2626 #else
2627                         msg_print("You see nothing there to spike.");
2628 #endif
2629
2630                 }
2631
2632                 /* Get a spike */
2633                 else if (!get_spike(&item))
2634                 {
2635                         /* Message */
2636 #ifdef JP
2637                         msg_print("¤¯¤µ¤Ó¤ò»ý¤Ã¤Æ¤¤¤Ê¤¤¡ª");
2638 #else
2639                         msg_print("You have no spikes!");
2640 #endif
2641                 }
2642
2643                 /* Is a monster in the way? */
2644                 else if (c_ptr->m_idx)
2645                 {
2646                         /* Take a turn */
2647                         energy_use = 100;
2648
2649                         /* Message */
2650 #ifdef JP
2651                         msg_print("¥â¥ó¥¹¥¿¡¼¤¬Î©¤Á¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ë¡ª");
2652 #else
2653                         msg_print("There is a monster in the way!");
2654 #endif
2655
2656                         /* Attack */
2657                         py_attack(y, x, 0);
2658                 }
2659
2660                 /* Go for it */
2661                 else
2662                 {
2663                         /* Take a turn */
2664                         energy_use = 100;
2665
2666                         /* Successful jamming */
2667 #ifdef JP
2668                         msg_format("%s¤Ë¤¯¤µ¤Ó¤òÂǤÁ¹þ¤ó¤À¡£", f_name + f_info[feat].name);
2669 #else
2670                         msg_format("You jam the %s with a spike.", f_name + f_info[feat].name);
2671 #endif
2672
2673                         cave_alter_feat(y, x, FF_SPIKE);
2674
2675                         /* Use up, and describe, a single spike, from the bottom */
2676                         inven_item_increase(item, -1);
2677                         inven_item_describe(item);
2678                         inven_item_optimize(item);
2679                 }
2680         }
2681 }
2682
2683
2684
2685 /*
2686  * Support code for the "Walk" and "Jump" commands
2687  */
2688 void do_cmd_walk(bool pickup)
2689 {
2690         int dir;
2691
2692         bool more = FALSE;
2693
2694
2695         /* Allow repeated command */
2696         if (command_arg)
2697         {
2698                 /* Set repeat count */
2699                 command_rep = command_arg - 1;
2700
2701                 /* Redraw the state */
2702                 p_ptr->redraw |= (PR_STATE);
2703
2704                 /* Cancel the arg */
2705                 command_arg = 0;
2706         }
2707
2708         /* Get a "repeated" direction */
2709         if (get_rep_dir(&dir,FALSE))
2710         {
2711                 /* Take a turn */
2712                 energy_use = 100;
2713
2714                 if ((dir != 5) && (p_ptr->special_defense & KATA_MUSOU))
2715                 {
2716                         set_action(ACTION_NONE);
2717                 }
2718
2719                 /* Hack -- In small scale wilderness it takes MUCH more time to move */
2720                 if (p_ptr->wild_mode) energy_use *= ((MAX_HGT + MAX_WID) / 2);
2721                 if (p_ptr->action == ACTION_HAYAGAKE) energy_use = energy_use * (45-(p_ptr->lev/2)) / 100;
2722
2723                 /* Actually move the character */
2724                 move_player(dir, pickup, FALSE);
2725
2726                 /* Allow more walking */
2727                 more = TRUE;
2728         }
2729
2730         /* Hack again -- Is there a special encounter ??? */
2731         if (p_ptr->wild_mode && !have_flag(f_flags_bold(py, px), FF_TOWN))
2732         {
2733                 int tmp = 120 + p_ptr->lev*10 - wilderness[py][px].level + 5;
2734                 if (tmp < 1) 
2735                         tmp = 1;
2736                 if (((wilderness[py][px].level + 5) > (p_ptr->lev / 2)) && randint0(tmp) < (21-p_ptr->skill_stl))
2737                 {
2738                         /* Inform the player of his horrible fate :=) */
2739 #ifdef JP
2740                         msg_print("½±·â¤À¡ª");
2741 #else
2742                         msg_print("You are ambushed !");
2743 #endif
2744
2745                         /* Go into large wilderness view */
2746                         p_ptr->oldpy = randint1(MAX_HGT-2);
2747                         p_ptr->oldpx = randint1(MAX_WID-2);
2748                         change_wild_mode();
2749
2750                         /* Give first move to monsters */
2751                         energy_use = 100;
2752
2753                         /* HACk -- set the encouter flag for the wilderness generation */
2754                         generate_encounter = TRUE;
2755                 }
2756         }
2757
2758         /* Cancel repeat unless we may continue */
2759         if (!more) disturb(0, 0);
2760 }
2761
2762
2763
2764 /*
2765  * Start running.
2766  */
2767 void do_cmd_run(void)
2768 {
2769         int dir;
2770
2771         /* Hack -- no running when confused */
2772         if (p_ptr->confused)
2773         {
2774 #ifdef JP
2775                 msg_print("º®Í𤷤Ƥ¤¤ÆÁö¤ì¤Ê¤¤¡ª");
2776 #else
2777                 msg_print("You are too confused!");
2778 #endif
2779
2780                 return;
2781         }
2782
2783         if (p_ptr->special_defense & KATA_MUSOU)
2784         {
2785                 set_action(ACTION_NONE);
2786         }
2787
2788         /* Get a "repeated" direction */
2789         if (get_rep_dir(&dir,FALSE))
2790         {
2791                 /* Hack -- Set the run counter */
2792                 running = (command_arg ? command_arg : 1000);
2793
2794                 /* First step */
2795                 run_step(dir);
2796         }
2797 }
2798
2799
2800
2801 /*
2802  * Stay still.  Search.  Enter stores.
2803  * Pick up treasure if "pickup" is true.
2804  */
2805 void do_cmd_stay(bool pickup)
2806 {
2807         u32b mpe_mode = MPE_STAYING | MPE_ENERGY_USE;
2808
2809         /* Allow repeated command */
2810         if (command_arg)
2811         {
2812                 /* Set repeat count */
2813                 command_rep = command_arg - 1;
2814
2815                 /* Redraw the state */
2816                 p_ptr->redraw |= (PR_STATE);
2817
2818                 /* Cancel the arg */
2819                 command_arg = 0;
2820         }
2821
2822         /* Take a turn */
2823         energy_use = 100;
2824
2825         if (pickup) mpe_mode |= MPE_DO_PICKUP;
2826         (void)move_player_effect(py, px, py, px, mpe_mode);
2827 }
2828
2829
2830
2831 /*
2832  * Resting allows a player to safely restore his hp     -RAK-
2833  */
2834 void do_cmd_rest(void)
2835 {
2836
2837         set_action(ACTION_NONE);
2838
2839         if ((p_ptr->pclass == CLASS_BARD) && (p_ptr->magic_num1[0] || p_ptr->magic_num1[1]))
2840         {
2841                 stop_singing();
2842         }
2843
2844         /* Prompt for time if needed */
2845         if (command_arg <= 0)
2846         {
2847 #ifdef JP
2848                 cptr p = "µÙ·Æ (0-9999, '*' ¤Ç HP/MPÁ´²÷, '&' ¤ÇɬÍפʤÀ¤±): ";
2849 #else
2850                 cptr p = "Rest (0-9999, '*' for HP/SP, '&' as needed): ";
2851 #endif
2852
2853
2854                 char out_val[80];
2855
2856                 /* Default */
2857                 strcpy(out_val, "&");
2858
2859                 /* Ask for duration */
2860                 if (!get_string(p, out_val, 4)) return;
2861
2862                 /* Rest until done */
2863                 if (out_val[0] == '&')
2864                 {
2865                         command_arg = (-2);
2866                 }
2867
2868                 /* Rest a lot */
2869                 else if (out_val[0] == '*')
2870                 {
2871                         command_arg = (-1);
2872                 }
2873
2874                 /* Rest some */
2875                 else
2876                 {
2877                         command_arg = atoi(out_val);
2878                         if (command_arg <= 0) return;
2879                 }
2880         }
2881
2882
2883         /* Paranoia */
2884         if (command_arg > 9999) command_arg = 9999;
2885
2886         if (p_ptr->special_defense & NINJA_S_STEALTH) set_superstealth(FALSE);
2887
2888         /* Take a turn XXX XXX XXX (?) */
2889         energy_use = 100;
2890
2891         /* The sin of sloth */
2892         if (command_arg > 100)
2893                 chg_virtue(V_DILIGENCE, -1);
2894         
2895         /* Why are you sleeping when there's no need?  WAKE UP!*/
2896         if ((p_ptr->chp == p_ptr->mhp) &&
2897             (p_ptr->csp == p_ptr->msp) &&
2898             !p_ptr->blind && !p_ptr->confused &&
2899             !p_ptr->poisoned && !p_ptr->afraid &&
2900             !p_ptr->stun && !p_ptr->cut &&
2901             !p_ptr->slow && !p_ptr->paralyzed &&
2902             !p_ptr->image && !p_ptr->word_recall &&
2903             !p_ptr->alter_reality)
2904                         chg_virtue(V_DILIGENCE, -1);
2905
2906         /* Save the rest code */
2907         resting = command_arg;
2908         p_ptr->action = ACTION_REST;
2909
2910         /* Recalculate bonuses */
2911         p_ptr->update |= (PU_BONUS);
2912
2913         /* Redraw the state */
2914         p_ptr->redraw |= (PR_STATE);
2915
2916         /* Handle stuff */
2917         handle_stuff();
2918
2919         /* Refresh */
2920         Term_fresh();
2921 }
2922
2923
2924 /*
2925  * Determines the odds of an object breaking when thrown at a monster
2926  *
2927  * Note that artifacts never break, see the "drop_near()" function.
2928  */
2929 static int breakage_chance(object_type *o_ptr)
2930 {
2931         int archer_bonus = (p_ptr->pclass == CLASS_ARCHER ? (p_ptr->lev-1)/7 + 4: 0);
2932
2933         /* Examine the item type */
2934         switch (o_ptr->tval)
2935         {
2936                 /* Always break */
2937                 case TV_FLASK:
2938                 case TV_POTION:
2939                 case TV_BOTTLE:
2940                 case TV_FOOD:
2941                 case TV_JUNK:
2942                         return (100);
2943
2944                 /* Often break */
2945                 case TV_LITE:
2946                 case TV_SCROLL:
2947                 case TV_SKELETON:
2948                         return (50);
2949
2950                 /* Sometimes break */
2951                 case TV_WAND:
2952                 case TV_SPIKE:
2953                         return (25);
2954                 case TV_ARROW:
2955                         return (20 - archer_bonus * 2);
2956
2957                 /* Rarely break */
2958                 case TV_SHOT:
2959                 case TV_BOLT:
2960                         return (10 - archer_bonus);
2961                 default:
2962                         return (10);
2963         }
2964 }
2965
2966
2967 static s16b tot_dam_aux_shot(object_type *o_ptr, int tdam, monster_type *m_ptr)
2968 {
2969         int mult = 10;
2970
2971         monster_race *r_ptr = &r_info[m_ptr->r_idx];
2972
2973         u32b flgs[TR_FLAG_SIZE];
2974
2975         /* Extract the flags */
2976         object_flags(o_ptr, flgs);
2977
2978         /* Some "weapons" and "ammo" do extra damage */
2979         switch (o_ptr->tval)
2980         {
2981                 case TV_SHOT:
2982                 case TV_ARROW:
2983                 case TV_BOLT:
2984                 {
2985                         /* Slay Animal */
2986                         if ((have_flag(flgs, TR_SLAY_ANIMAL)) &&
2987                             (r_ptr->flags3 & RF3_ANIMAL))
2988                         {
2989                                 if (m_ptr->ml && is_original_ap(m_ptr))
2990                                 {
2991                                         r_ptr->r_flags3 |= RF3_ANIMAL;
2992                                 }
2993
2994                                 if (mult < 17) mult = 17;
2995                         }
2996
2997                         /* Kill Animal */
2998                         if ((have_flag(flgs, TR_KILL_ANIMAL)) &&
2999                             (r_ptr->flags3 & RF3_ANIMAL))
3000                         {
3001                                 if (m_ptr->ml && is_original_ap(m_ptr))
3002                                 {
3003                                         r_ptr->r_flags3 |= RF3_ANIMAL;
3004                                 }
3005
3006                                 if (mult < 27) mult = 27;
3007                         }
3008
3009                         /* Slay Evil */
3010                         if ((have_flag(flgs, TR_SLAY_EVIL)) &&
3011                             (r_ptr->flags3 & RF3_EVIL))
3012                         {
3013                                 if (m_ptr->ml && is_original_ap(m_ptr))
3014                                 {
3015                                         r_ptr->r_flags3 |= RF3_EVIL;
3016                                 }
3017
3018                                 if (mult < 15) mult = 15;
3019                         }
3020
3021                         /* Kill Evil */
3022                         if ((have_flag(flgs, TR_KILL_EVIL)) &&
3023                             (r_ptr->flags3 & RF3_EVIL))
3024                         {
3025                                 if (m_ptr->ml && is_original_ap(m_ptr))
3026                                 {
3027                                         r_ptr->r_flags3 |= RF3_EVIL;
3028                                 }
3029
3030                                 if (mult < 25) mult = 25;
3031                         }
3032
3033                         /* Slay Human */
3034                         if ((have_flag(flgs, TR_SLAY_HUMAN)) &&
3035                             (r_ptr->flags2 & RF2_HUMAN))
3036                         {
3037                                 if (m_ptr->ml && is_original_ap(m_ptr))
3038                                 {
3039                                         r_ptr->r_flags2 |= RF2_HUMAN;
3040                                 }
3041
3042                                 if (mult < 17) mult = 17;
3043                         }
3044
3045                         /* Kill Human */
3046                         if ((have_flag(flgs, TR_KILL_HUMAN)) &&
3047                             (r_ptr->flags2 & RF2_HUMAN))
3048                         {
3049                                 if (m_ptr->ml && is_original_ap(m_ptr))
3050                                 {
3051                                         r_ptr->r_flags2 |= RF2_HUMAN;
3052                                 }
3053
3054                                 if (mult < 27) mult = 27;
3055                         }
3056
3057                         /* Slay Undead */
3058                         if ((have_flag(flgs, TR_SLAY_UNDEAD)) &&
3059                             (r_ptr->flags3 & RF3_UNDEAD))
3060                         {
3061                                 if (m_ptr->ml && is_original_ap(m_ptr))
3062                                 {
3063                                         r_ptr->r_flags3 |= RF3_UNDEAD;
3064                                 }
3065
3066                                 if (mult < 20) mult = 20;
3067                         }
3068
3069                         /* Kill Undead */
3070                         if ((have_flag(flgs, TR_KILL_UNDEAD)) &&
3071                             (r_ptr->flags3 & RF3_UNDEAD))
3072                         {
3073                                 if (m_ptr->ml && is_original_ap(m_ptr))
3074                                 {
3075                                         r_ptr->r_flags3 |= RF3_UNDEAD;
3076                                 }
3077
3078                                 if (mult < 30) mult = 30;
3079                         }
3080
3081                         /* Slay Demon */
3082                         if ((have_flag(flgs, TR_SLAY_DEMON)) &&
3083                             (r_ptr->flags3 & RF3_DEMON))
3084                         {
3085                                 if (m_ptr->ml && is_original_ap(m_ptr))
3086                                 {
3087                                         r_ptr->r_flags3 |= RF3_DEMON;
3088                                 }
3089
3090                                 if (mult < 20) mult = 20;
3091                         }
3092
3093                         /* Kill Demon */
3094                         if ((have_flag(flgs, TR_KILL_DEMON)) &&
3095                             (r_ptr->flags3 & RF3_DEMON))
3096                         {
3097                                 if (m_ptr->ml && is_original_ap(m_ptr))
3098                                 {
3099                                         r_ptr->r_flags3 |= RF3_DEMON;
3100                                 }
3101
3102                                 if (mult < 30) mult = 30;
3103                         }
3104
3105                         /* Slay Orc */
3106                         if ((have_flag(flgs, TR_SLAY_ORC)) &&
3107                             (r_ptr->flags3 & RF3_ORC))
3108                         {
3109                                 if (m_ptr->ml && is_original_ap(m_ptr))
3110                                 {
3111                                         r_ptr->r_flags3 |= RF3_ORC;
3112                                 }
3113
3114                                 if (mult < 20) mult = 20;
3115                         }
3116
3117                         /* Kill Orc */
3118                         if ((have_flag(flgs, TR_KILL_ORC)) &&
3119                             (r_ptr->flags3 & RF3_ORC))
3120                         {
3121                                 if (m_ptr->ml && is_original_ap(m_ptr))
3122                                 {
3123                                         r_ptr->r_flags3 |= RF3_ORC;
3124                                 }
3125
3126                                 if (mult < 30) mult = 30;
3127                         }
3128
3129                         /* Slay Troll */
3130                         if ((have_flag(flgs, TR_SLAY_TROLL)) &&
3131                             (r_ptr->flags3 & RF3_TROLL))
3132                         {
3133                                 if (m_ptr->ml && is_original_ap(m_ptr))
3134                                 {
3135                                         r_ptr->r_flags3 |= RF3_TROLL;
3136                                 }
3137
3138                                 if (mult < 20) mult = 20;
3139                         }
3140
3141                         /* Kill Troll */
3142                         if ((have_flag(flgs, TR_KILL_TROLL)) &&
3143                             (r_ptr->flags3 & RF3_TROLL))
3144                         {
3145                                 if (m_ptr->ml && is_original_ap(m_ptr))
3146                                 {
3147                                         r_ptr->r_flags3 |= RF3_TROLL;
3148                                 }
3149
3150                                 if (mult < 30) mult = 30;
3151                         }
3152
3153                         /* Slay Giant */
3154                         if ((have_flag(flgs, TR_SLAY_GIANT)) &&
3155                             (r_ptr->flags3 & RF3_GIANT))
3156                         {
3157                                 if (m_ptr->ml && is_original_ap(m_ptr))
3158                                 {
3159                                         r_ptr->r_flags3 |= RF3_GIANT;
3160                                 }
3161
3162                                 if (mult < 20) mult = 20;
3163                         }
3164
3165                         /* Kill Giant */
3166                         if ((have_flag(flgs, TR_KILL_GIANT)) &&
3167                             (r_ptr->flags3 & RF3_GIANT))
3168                         {
3169                                 if (m_ptr->ml && is_original_ap(m_ptr))
3170                                 {
3171                                         r_ptr->r_flags3 |= RF3_GIANT;
3172                                 }
3173
3174                                 if (mult < 30) mult = 30;
3175                         }
3176
3177                         /* Slay Dragon  */
3178                         if ((have_flag(flgs, TR_SLAY_DRAGON)) &&
3179                             (r_ptr->flags3 & RF3_DRAGON))
3180                         {
3181                                 if (m_ptr->ml && is_original_ap(m_ptr))
3182                                 {
3183                                         r_ptr->r_flags3 |= RF3_DRAGON;
3184                                 }
3185
3186                                 if (mult < 20) mult = 20;
3187                         }
3188
3189                         /* Execute Dragon */
3190                         if ((have_flag(flgs, TR_KILL_DRAGON)) &&
3191                             (r_ptr->flags3 & RF3_DRAGON))
3192                         {
3193                                 if (m_ptr->ml && is_original_ap(m_ptr))
3194                                 {
3195                                         r_ptr->r_flags3 |= RF3_DRAGON;
3196                                 }
3197
3198                                 if (mult < 30) mult = 30;
3199
3200                                 if ((o_ptr->name1 == ART_BARD_ARROW) &&
3201                                     (m_ptr->r_idx == MON_SMAUG) &&
3202                                     (inventory[INVEN_BOW].name1 == ART_BARD))
3203                                         mult *= 5;
3204                         }
3205
3206                         /* Brand (Acid) */
3207                         if (have_flag(flgs, TR_BRAND_ACID))
3208                         {
3209                                 /* Notice immunity */
3210                                 if (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK)
3211                                 {
3212                                         if (m_ptr->ml && is_original_ap(m_ptr))
3213                                         {
3214                                                 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK);
3215                                         }
3216                                 }
3217
3218                                 /* Otherwise, take the damage */
3219                                 else
3220                                 {
3221                                         if (mult < 17) mult = 17;
3222                                 }
3223                         }
3224
3225                         /* Brand (Elec) */
3226                         if (have_flag(flgs, TR_BRAND_ELEC))
3227                         {
3228                                 /* Notice immunity */
3229                                 if (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK)
3230                                 {
3231                                         if (m_ptr->ml && is_original_ap(m_ptr))
3232                                         {
3233                                                 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK);
3234                                         }
3235                                 }
3236
3237                                 /* Otherwise, take the damage */
3238                                 else
3239                                 {
3240                                         if (mult < 17) mult = 17;
3241                                 }
3242                         }
3243
3244                         /* Brand (Fire) */
3245                         if (have_flag(flgs, TR_BRAND_FIRE))
3246                         {
3247                                 /* Notice immunity */
3248                                 if (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK)
3249                                 {
3250                                         if (m_ptr->ml && is_original_ap(m_ptr))
3251                                         {
3252                                                 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK);
3253                                         }
3254                                 }
3255
3256                                 /* Otherwise, take the damage */
3257                                 else
3258                                 {
3259                                         if (r_ptr->flags3 & RF3_HURT_FIRE)
3260                                         {
3261                                                 if (mult < 25) mult = 25;
3262                                                 if (m_ptr->ml && is_original_ap(m_ptr))
3263                                                 {
3264                                                         r_ptr->r_flags3 |= RF3_HURT_FIRE;
3265                                                 }
3266                                         }
3267                                         else if (mult < 17) mult = 17;
3268                                 }
3269                         }
3270
3271                         /* Brand (Cold) */
3272                         if (have_flag(flgs, TR_BRAND_COLD))
3273                         {
3274                                 /* Notice immunity */
3275                                 if (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK)
3276                                 {
3277                                         if (m_ptr->ml && is_original_ap(m_ptr))
3278                                         {
3279                                                 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK);
3280                                         }
3281                                 }
3282                                 /* Otherwise, take the damage */
3283                                 else
3284                                 {
3285                                         if (r_ptr->flags3 & RF3_HURT_COLD)
3286                                         {
3287                                                 if (mult < 25) mult = 25;
3288                                                 if (m_ptr->ml && is_original_ap(m_ptr))
3289                                                 {
3290                                                         r_ptr->r_flags3 |= RF3_HURT_COLD;
3291                                                 }
3292                                         }
3293                                         else if (mult < 17) mult = 17;
3294                                 }
3295                         }
3296
3297                         /* Brand (Poison) */
3298                         if (have_flag(flgs, TR_BRAND_POIS))
3299                         {
3300                                 /* Notice immunity */
3301                                 if (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK)
3302                                 {
3303                                         if (m_ptr->ml && is_original_ap(m_ptr))
3304                                         {
3305                                                 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK);
3306                                         }
3307                                 }
3308
3309                                 /* Otherwise, take the damage */
3310                                 else
3311                                 {
3312                                         if (mult < 17) mult = 17;
3313                                 }
3314                         }
3315
3316                         if ((have_flag(flgs, TR_FORCE_WEAPON)) && (p_ptr->csp > (p_ptr->msp / 30)))
3317                         {
3318                                 p_ptr->csp -= (1+(p_ptr->msp / 30));
3319                                 p_ptr->redraw |= (PR_MANA);
3320                                 mult = mult * 5 / 2;
3321                         }
3322                         break;
3323                 }
3324         }
3325
3326         /* Return the total damage */
3327         return (tdam * mult / 10);
3328 }
3329
3330
3331 /*
3332  * Fire an object from the pack or floor.
3333  *
3334  * You may only fire items that "match" your missile launcher.
3335  *
3336  * You must use slings + pebbles/shots, bows + arrows, xbows + bolts.
3337  *
3338  * See "calc_bonuses()" for more calculations and such.
3339  *
3340  * Note that "firing" a missile is MUCH better than "throwing" it.
3341  *
3342  * Note: "unseen" monsters are very hard to hit.
3343  *
3344  * Objects are more likely to break if they "attempt" to hit a monster.
3345  *
3346  * Rangers (with Bows) and Anyone (with "Extra Shots") get extra shots.
3347  *
3348  * The "extra shot" code works by decreasing the amount of energy
3349  * required to make each shot, spreading the shots out over time.
3350  *
3351  * Note that when firing missiles, the launcher multiplier is applied
3352  * after all the bonuses are added in, making multipliers very useful.
3353  *
3354  * Note that Bows of "Extra Might" get extra range and an extra bonus
3355  * for the damage multiplier.
3356  *
3357  * Note that Bows of "Extra Shots" give an extra shot.
3358  */
3359 void do_cmd_fire_aux(int item, object_type *j_ptr)
3360 {
3361         int dir;
3362         int j, y, x, ny, nx, ty, tx;
3363         int tdam, tdis, thits, tmul;
3364         int bonus, chance;
3365         int cur_dis, visible;
3366
3367         object_type forge;
3368         object_type *q_ptr;
3369
3370         object_type *o_ptr;
3371
3372         bool hit_body = FALSE;
3373
3374         char o_name[MAX_NLEN];
3375
3376         int msec = delay_factor * delay_factor * delay_factor;
3377
3378         /* STICK TO */
3379         bool stick_to = FALSE;
3380
3381         /* Access the item (if in the pack) */
3382         if (item >= 0)
3383         {
3384                 o_ptr = &inventory[item];
3385         }
3386         else
3387         {
3388                 o_ptr = &o_list[0 - item];
3389         }
3390
3391         /* Describe the object */
3392         object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
3393
3394
3395         /* Use the proper number of shots */
3396         thits = p_ptr->num_fire;
3397
3398         /* Use a base distance */
3399         tdis = 10;
3400
3401         /* Base damage from thrown object plus launcher bonus */
3402         tdam = damroll(o_ptr->dd, o_ptr->ds) + o_ptr->to_d + j_ptr->to_d;
3403
3404         /* Actually "fire" the object */
3405         bonus = (p_ptr->to_h_b + o_ptr->to_h + j_ptr->to_h);
3406         if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
3407                 chance = (p_ptr->skill_thb + (p_ptr->weapon_exp[0][j_ptr->sval] / 400 + bonus) * BTH_PLUS_ADJ);
3408         else
3409                 chance = (p_ptr->skill_thb + ((p_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + bonus) * BTH_PLUS_ADJ);
3410
3411         energy_use = bow_energy(j_ptr->sval);
3412         tmul = bow_tmul(j_ptr->sval);
3413
3414         /* Get extra "power" from "extra might" */
3415         if (p_ptr->xtra_might) tmul++;
3416
3417         tmul = tmul * (100 + (int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
3418
3419         /* Boost the damage */
3420         tdam *= tmul;
3421         tdam /= 100;
3422
3423         /* Base range */
3424         tdis = 10 + tmul/40;
3425         if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
3426                 tdis -= 5;
3427
3428         project_length = tdis + 1;
3429
3430         /* Get a direction (or cancel) */
3431         if (!get_aim_dir(&dir))
3432         {
3433                 energy_use = 0;
3434
3435                 /* need not to reset project_length (already did)*/
3436
3437                 return;
3438         }
3439
3440         /* Start at the player */
3441         y = py;
3442         x = px;
3443
3444         /* Predict the "target" location */
3445         tx = px + 99 * ddx[dir];
3446         ty = py + 99 * ddy[dir];
3447
3448         /* Check for "target request" */
3449         if ((dir == 5) && target_okay())
3450         {
3451                 tx = target_col;
3452                 ty = target_row;
3453         }
3454
3455         project_length = 0; /* reset to default */
3456
3457         /* Don't shoot at my feet */
3458         if (tx == px && ty == py)
3459         {
3460                 energy_use = 0;
3461
3462                 /* project_length is already reset to 0 */
3463
3464                 return;
3465         }
3466
3467
3468         /* Get local object */
3469         q_ptr = &forge;
3470
3471         /* Obtain a local object */
3472         object_copy(q_ptr, o_ptr);
3473
3474         /* Single object */
3475         q_ptr->number = 1;
3476
3477         /* Reduce and describe inventory */
3478         if (item >= 0)
3479         {
3480                 inven_item_increase(item, -1);
3481                 inven_item_describe(item);
3482                 inven_item_optimize(item);
3483         }
3484
3485         /* Reduce and describe floor item */
3486         else
3487         {
3488                 floor_item_increase(0 - item, -1);
3489                 floor_item_optimize(0 - item);
3490         }
3491
3492
3493         /* Sound */
3494         sound(SOUND_SHOOT);
3495
3496
3497         /* Take a (partial) turn */
3498         energy_use = (energy_use / thits);
3499
3500
3501         /* Hack -- Handle stuff */
3502         handle_stuff();
3503
3504
3505         /* Travel until stopped */
3506         for (cur_dis = 0; cur_dis <= tdis; )
3507         {
3508                 /* Hack -- Stop at the target */
3509                 if ((y == ty) && (x == tx)) break;
3510
3511                 /* Calculate the new location (see "project()") */
3512                 ny = y;
3513                 nx = x;
3514                 mmove2(&ny, &nx, py, px, ty, tx);
3515
3516                 /* Stopped by walls/doors */
3517                 if (!have_flag(f_flags_bold(ny, nx), FF_PROJECT) && !cave[ny][nx].m_idx) break;
3518
3519                 /* Advance the distance */
3520                 cur_dis++;
3521
3522
3523                 /* The player can see the (on screen) missile */
3524                 if (panel_contains(ny, nx) && player_can_see_bold(ny, nx))
3525                 {
3526                         char c = object_char(q_ptr);
3527                         byte a = object_attr(q_ptr);
3528
3529                         /* Draw, Hilite, Fresh, Pause, Erase */
3530                         print_rel(c, a, ny, nx);
3531                         move_cursor_relative(ny, nx);
3532                         Term_fresh();
3533                         Term_xtra(TERM_XTRA_DELAY, msec);
3534                         lite_spot(ny, nx);
3535                         Term_fresh();
3536                 }
3537
3538                 /* The player cannot see the missile */
3539                 else
3540                 {
3541                         /* Pause anyway, for consistancy */
3542                         Term_xtra(TERM_XTRA_DELAY, msec);
3543                 }
3544
3545                 /* Save the new location */
3546                 x = nx;
3547                 y = ny;
3548
3549
3550                 /* Monster here, Try to hit it */
3551                 if (cave[y][x].m_idx)
3552                 {
3553                         cave_type *c_ptr = &cave[y][x];
3554
3555                         monster_type *m_ptr = &m_list[c_ptr->m_idx];
3556                         monster_race *r_ptr = &r_info[m_ptr->r_idx];
3557
3558                         /* Check the visibility */
3559                         visible = m_ptr->ml;
3560
3561                         /* Note the collision */
3562                         hit_body = TRUE;
3563
3564                         if (m_ptr->csleep)
3565                         {
3566                                 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_COMPASSION, -1);
3567                                 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_HONOUR, -1);
3568                         }
3569
3570                         if ((r_ptr->level + 10) > p_ptr->lev)
3571                         {
3572                                 int now_exp = p_ptr->weapon_exp[0][j_ptr->sval];
3573                                 if (now_exp < s_info[p_ptr->pclass].w_max[0][j_ptr->sval])
3574                                 {
3575                                         int amount = 0;
3576                                         if (now_exp < WEAPON_EXP_BEGINNER) amount = 80;
3577                                         else if (now_exp < WEAPON_EXP_SKILLED) amount = 25;
3578                                         else if ((now_exp < WEAPON_EXP_EXPERT) && (p_ptr->lev > 19)) amount = 10;
3579                                         else if (p_ptr->lev > 34) amount = 2;
3580                                         p_ptr->weapon_exp[0][j_ptr->sval] += amount;
3581                                         p_ptr->update |= (PU_BONUS);
3582                                 }
3583                         }
3584
3585                         if (p_ptr->riding)
3586                         {
3587                                 if ((p_ptr->skill_exp[GINOU_RIDING] < s_info[p_ptr->pclass].s_max[GINOU_RIDING])
3588                                         && ((p_ptr->skill_exp[GINOU_RIDING] - (RIDING_EXP_BEGINNER * 2)) / 200 < r_info[m_list[p_ptr->riding].r_idx].level)
3589                                         && one_in_(2))
3590                                 {
3591                                         p_ptr->skill_exp[GINOU_RIDING] += 1;
3592                                         p_ptr->update |= (PU_BONUS);
3593                                 }
3594                         }
3595
3596                         /* Did we hit it (penalize range) */
3597                         if (test_hit_fire(chance - cur_dis, r_ptr->ac, m_ptr->ml))
3598                         {
3599                                 bool fear = FALSE;
3600
3601                                 /* Handle unseen monster */
3602                                 if (!visible)
3603                                 {
3604                                         /* Invisible monster */
3605 #ifdef JP
3606                                         msg_format("%s¤¬Å¨¤òÊ᪤·¤¿¡£", o_name);
3607 #else
3608                                         msg_format("The %s finds a mark.", o_name);
3609 #endif
3610
3611                                 }
3612
3613                                 /* Handle visible monster */
3614                                 else
3615                                 {
3616                                         char m_name[80];
3617
3618                                         /* Get "the monster" or "it" */
3619                                         monster_desc(m_name, m_ptr, 0);
3620
3621                                         /* Message */
3622 #ifdef JP
3623                                         msg_format("%s¤¬%s¤ËÌ¿Ã椷¤¿¡£", o_name, m_name);
3624 #else
3625                                         msg_format("The %s hits %s.", o_name, m_name);
3626 #endif
3627
3628
3629                                         /* Hack -- Track this monster race */
3630                                         if (m_ptr->ml) monster_race_track(m_ptr->ap_r_idx);
3631
3632                                         /* Hack -- Track this monster */
3633                                         if (m_ptr->ml) health_track(c_ptr->m_idx);
3634                                 }
3635
3636                                 /* Apply special damage XXX XXX XXX */
3637                                 tdam = tot_dam_aux_shot(q_ptr, tdam, m_ptr);
3638                                 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, tdam);
3639
3640                                 /* No negative damage */
3641                                 if (tdam < 0) tdam = 0;
3642
3643                                 /* Modify the damage */
3644                                 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
3645
3646                                 /* Complex message */
3647                                 if (p_ptr->wizard || cheat_xtra)
3648                                 {
3649 #ifdef JP
3650                                         msg_format("%d/%d ¤Î¥À¥á¡¼¥¸¤òÍ¿¤¨¤¿¡£",
3651                                                    tdam, m_ptr->hp);
3652 #else
3653                                         msg_format("You do %d (out of %d) damage.",
3654                                                    tdam, m_ptr->hp);
3655 #endif
3656
3657                                 }
3658
3659                                 /* Hit the monster, check for death */
3660                                 if (mon_take_hit(c_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_ptr(m_ptr))))
3661                                 {
3662                                         /* Dead monster */
3663                                 }
3664
3665                                 /* No death */
3666                                 else
3667                                 {
3668                                         /* STICK TO */
3669                                         if (object_is_fixed_artifact(q_ptr))
3670                                         {
3671                                                 char m_name[80];
3672
3673                                                 monster_desc(m_name, m_ptr, 0);
3674
3675                                                 stick_to = TRUE;
3676 #ifdef JP
3677                                                 msg_format("%s¤Ï%s¤ËÆͤ­»É¤µ¤Ã¤¿¡ª",o_name, m_name);
3678 #else
3679                                                 msg_format("%^s have stuck into %s!",o_name, m_name);
3680 #endif
3681                                         }
3682
3683                                         /* Message */
3684                                         message_pain(c_ptr->m_idx, tdam);
3685
3686                                         /* Anger the monster */
3687                                         if (tdam > 0) anger_monster(m_ptr);
3688
3689                                         /* Take note */
3690                                         if (fear && m_ptr->ml)
3691                                         {
3692                                                 char m_name[80];
3693
3694                                                 /* Sound */
3695                                                 sound(SOUND_FLEE);
3696
3697                                                 /* Get the monster name (or "it") */
3698                                                 monster_desc(m_name, m_ptr, 0);
3699
3700                                                 /* Message */
3701 #ifdef JP
3702                                                 msg_format("%^s¤Ï¶²Éݤ·¤Æƨ¤²½Ð¤·¤¿¡ª", m_name);
3703 #else
3704                                                 msg_format("%^s flees in terror!", m_name);
3705 #endif
3706
3707                                         }
3708                                         if (!projectable(m_ptr->fy, m_ptr->fx, py, px))
3709                                         {
3710                                                 set_target(m_ptr, py, px);
3711                                         }
3712                                 }
3713                         }
3714
3715                         /* Stop looking */
3716                         break;
3717                 }
3718         }
3719
3720         /* Chance of breakage (during attacks) */
3721         j = (hit_body ? breakage_chance(q_ptr) : 0);
3722
3723         if(stick_to)
3724         {
3725                 int m_idx = cave[y][x].m_idx;
3726                 monster_type *m_ptr = &m_list[m_idx];
3727                 int o_idx = o_pop();
3728
3729                 if (!o_idx)
3730                   {
3731 #ifdef JP
3732                     msg_format("%s¤Ï¤É¤³¤«¤Ø¹Ô¤Ã¤¿¡£", o_name);
3733 #else
3734                     msg_format("The %s have gone to somewhere.", o_name);
3735 #endif
3736                     if (object_is_fixed_artifact(q_ptr))
3737                       {
3738                         a_info[j_ptr->name1].cur_num = 0;
3739                       }
3740                     return;
3741                   }
3742
3743                 o_ptr = &o_list[ o_idx ];
3744                 object_copy(o_ptr, q_ptr);
3745
3746                 /* Forget mark */
3747                 o_ptr->marked = 0;
3748
3749                 /* Forget location */
3750                 o_ptr->iy = o_ptr->ix = 0;
3751
3752                 /* Memorize monster */
3753                 o_ptr->held_m_idx = m_idx;
3754
3755                 /* Build a stack */
3756                 o_ptr->next_o_idx = m_ptr->hold_o_idx;
3757
3758                 /* Carry object */
3759                 m_ptr->hold_o_idx = o_idx;
3760
3761         }
3762         else
3763                 /* Drop (or break) near that location */
3764                 (void)drop_near(q_ptr, j, y, x);
3765 }
3766
3767
3768 void do_cmd_fire(void)
3769 {
3770         int item;
3771         object_type *j_ptr;
3772         cptr q, s;
3773
3774         /* Get the "bow" (if any) */
3775         j_ptr = &inventory[INVEN_BOW];
3776
3777         /* Require a launcher */
3778         if (!j_ptr->tval)
3779         {
3780 #ifdef JP
3781                 msg_print("¼Í·âÍѤÎÉð´ï¤ò»ý¤Ã¤Æ¤¤¤Ê¤¤¡£");
3782 #else
3783                 msg_print("You have nothing to fire with.");
3784 #endif
3785                 flush();
3786                 return;
3787         }
3788
3789         if (j_ptr->sval == SV_CRIMSON)
3790         {
3791 #ifdef JP
3792                 msg_print("¤³¤ÎÉð´ï¤Ïȯư¤·¤Æ»È¤¦¤â¤Î¤Î¤è¤¦¤À¡£");
3793 #else
3794                 msg_print("Do activate.");
3795 #endif
3796                 flush();
3797                 return;
3798         }
3799
3800
3801         if (p_ptr->special_defense & KATA_MUSOU)
3802         {
3803                 set_action(ACTION_NONE);
3804         }
3805
3806         /* Require proper missile */
3807         item_tester_tval = p_ptr->tval_ammo;
3808
3809         /* Get an item */
3810 #ifdef JP
3811         q = "¤É¤ì¤ò·â¤Á¤Þ¤¹¤«? ";
3812         s = "ȯ¼Í¤µ¤ì¤ë¥¢¥¤¥Æ¥à¤¬¤¢¤ê¤Þ¤»¤ó¡£";
3813 #else
3814         q = "Fire which item? ";
3815         s = "You have nothing to fire.";
3816 #endif
3817
3818         if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR)))
3819         {
3820                 flush();
3821                 return;
3822         }
3823
3824         /* Fire the item */
3825         do_cmd_fire_aux(item, j_ptr);
3826 }
3827
3828
3829 static bool item_tester_hook_boomerang(object_type *o_ptr)
3830 {
3831         if ((o_ptr->tval==TV_DIGGING) || (o_ptr->tval == TV_SWORD) || (o_ptr->tval == TV_POLEARM) || (o_ptr->tval == TV_HAFTED)) return (TRUE);
3832
3833         /* Assume not */
3834         return (FALSE);
3835 }
3836
3837
3838 /*
3839  * Throw an object from the pack or floor.
3840  *
3841  * Note: "unseen" monsters are very hard to hit.
3842  *
3843  * Should throwing a weapon do full damage?  Should it allow the magic
3844  * to hit bonus of the weapon to have an effect?  Should it ever cause
3845  * the item to be destroyed?  Should it do any damage at all?
3846  */
3847 bool do_cmd_throw_aux(int mult, bool boomerang, int shuriken)
3848 {
3849         int dir, item;
3850         int i, j, y, x, ty, tx;
3851         int ny[19], nx[19];
3852         int chance, tdam, tdis;
3853         int mul, div;
3854         int cur_dis, visible;
3855
3856         object_type forge;
3857         object_type *q_ptr;
3858
3859         object_type *o_ptr;
3860
3861         bool hit_body = FALSE;
3862         bool hit_wall = FALSE;
3863         bool equiped_item = FALSE;
3864         bool return_when_thrown = FALSE;
3865
3866         char o_name[MAX_NLEN];
3867
3868         int msec = delay_factor * delay_factor * delay_factor;
3869
3870         u32b flgs[TR_FLAG_SIZE];
3871         cptr q, s;
3872         bool come_back = FALSE;
3873         bool do_drop = TRUE;
3874
3875
3876         if (p_ptr->special_defense & KATA_MUSOU)
3877         {
3878                 set_action(ACTION_NONE);
3879         }
3880
3881         if (shuriken)
3882         {
3883                 item = shuriken;
3884         }
3885         else if (boomerang)
3886         {
3887                 if (buki_motteruka(INVEN_LARM))
3888                 {
3889                         item_tester_hook = item_tester_hook_boomerang;
3890 #ifdef JP
3891                         q = "¤É¤ÎÉð´ï¤òÅꤲ¤Þ¤¹¤«? ";
3892                         s = "Åꤲ¤ëÉð´ï¤¬¤Ê¤¤¡£";
3893 #else
3894                         q = "Throw which item? ";
3895                         s = "You have nothing to throw.";
3896 #endif
3897
3898                         if (!get_item(&item, q, s, (USE_EQUIP)))
3899                         {
3900                                 flush();
3901                                 return FALSE;
3902                         }
3903                 }
3904                 else
3905                 {
3906                         item = INVEN_RARM;
3907                 }
3908         }
3909         else
3910         {
3911                 /* Get an item */
3912 #ifdef JP
3913                 q = "¤É¤Î¥¢¥¤¥Æ¥à¤òÅꤲ¤Þ¤¹¤«? ";
3914                 s = "Åꤲ¤ë¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
3915 #else
3916                 q = "Throw which item? ";
3917                 s = "You have nothing to throw.";
3918 #endif
3919
3920                 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR | USE_EQUIP)))
3921                 {
3922                         flush();
3923                         return FALSE;
3924                 }
3925         }
3926
3927         /* Access the item (if in the pack) */
3928         if (item >= 0)
3929         {
3930                 o_ptr = &inventory[item];
3931         }
3932         else
3933         {
3934                 o_ptr = &o_list[0 - item];
3935         }
3936
3937
3938         /* Item is cursed */
3939         if (object_is_cursed(o_ptr) && (item >= INVEN_RARM))
3940         {
3941                 /* Oops */
3942 #ifdef JP
3943                 msg_print("¤Õ¡¼¤à¡¢¤É¤¦¤ä¤é¼ö¤ï¤ì¤Æ¤¤¤ë¤è¤¦¤À¡£");
3944 #else
3945                 msg_print("Hmmm, it seems to be cursed.");
3946 #endif
3947
3948                 /* Nope */
3949                 return FALSE;
3950         }
3951
3952         if (p_ptr->inside_arena && !boomerang)
3953         {
3954                 if (o_ptr->tval != TV_SPIKE)
3955                 {
3956 #ifdef JP
3957                         msg_print("¥¢¥ê¡¼¥Ê¤Ç¤Ï¥¢¥¤¥Æ¥à¤ò»È¤¨¤Ê¤¤¡ª");
3958 #else
3959                         msg_print("You're in the arena now. This is hand-to-hand!");
3960 #endif
3961                         msg_print(NULL);
3962
3963                         /* Nope */
3964                         return FALSE;
3965                 }
3966         }
3967
3968         /* Get local object */
3969         q_ptr = &forge;
3970
3971         /* Obtain a local object */
3972         object_copy(q_ptr, o_ptr);
3973
3974         /* Extract the thrown object's flags. */
3975         object_flags(q_ptr, flgs);
3976
3977         /* Distribute the charges of rods/wands between the stacks */
3978         distribute_charges(o_ptr, q_ptr, 1);
3979
3980         /* Single object */
3981         q_ptr->number = 1;
3982
3983         /* Description */
3984         object_desc(o_name, q_ptr, OD_OMIT_PREFIX);
3985
3986         if (p_ptr->mighty_throw) mult += 3;
3987
3988         /* Extract a "distance multiplier" */
3989         /* Changed for 'launcher' mutation */
3990         mul = 10 + 2 * (mult - 1);
3991
3992         /* Enforce a minimum "weight" of one pound */
3993         div = ((q_ptr->weight > 10) ? q_ptr->weight : 10);
3994         if ((have_flag(flgs, TR_THROW)) || boomerang) div /= 2;
3995
3996         /* Hack -- Distance -- Reward strength, penalize weight */
3997         tdis = (adj_str_blow[p_ptr->stat_ind[A_STR]] + 20) * mul / div;
3998
3999         /* Max distance of 10-18 */
4000         if (tdis > mul) tdis = mul;
4001
4002         if (shuriken)
4003         {
4004                 ty = randint0(101)-50+py;
4005                 tx = randint0(101)-50+px;
4006         }
4007         else
4008         {
4009                 project_length = tdis + 1;
4010
4011                 /* Get a direction (or cancel) */
4012                 if (!get_aim_dir(&dir)) return FALSE;
4013
4014                 /* Predict the "target" location */
4015                 tx = px + 99 * ddx[dir];
4016                 ty = py + 99 * ddy[dir];
4017
4018                 /* Check for "target request" */
4019                 if ((dir == 5) && target_okay())
4020                 {
4021                         tx = target_col;
4022                         ty = target_row;
4023                 }
4024
4025                 project_length = 0;  /* reset to default */
4026         }
4027
4028         if ((q_ptr->name1 == ART_MJOLLNIR) ||
4029             (q_ptr->name1 == ART_AEGISFANG) || boomerang)
4030                 return_when_thrown = TRUE;
4031
4032         /* Reduce and describe inventory */
4033         if (item >= 0)
4034         {
4035                 inven_item_increase(item, -1);
4036                 if (!return_when_thrown)
4037                         inven_item_describe(item);
4038                 inven_item_optimize(item);
4039         }
4040
4041         /* Reduce and describe floor item */
4042         else
4043         {
4044                 floor_item_increase(0 - item, -1);
4045                 floor_item_optimize(0 - item);
4046         }
4047         if (item >= INVEN_RARM)
4048         {
4049                 equiped_item = TRUE;
4050                 p_ptr->redraw |= (PR_EQUIPPY);
4051         }
4052
4053         /* Take a turn */
4054         energy_use = 100;
4055
4056         /* Rogue and Ninja gets bonus */
4057         if ((p_ptr->pclass == CLASS_ROGUE) || (p_ptr->pclass == CLASS_NINJA))
4058                 energy_use -= p_ptr->lev;
4059
4060         /* Start at the player */
4061         y = py;
4062         x = px;
4063
4064
4065         /* Hack -- Handle stuff */
4066         handle_stuff();
4067
4068         if ((p_ptr->pclass == CLASS_NINJA) && ((q_ptr->tval == TV_SPIKE) || ((have_flag(flgs, TR_THROW)) && (q_ptr->tval == TV_SWORD)))) shuriken = TRUE;
4069         else shuriken = FALSE;
4070
4071         /* Chance of hitting */
4072         if (have_flag(flgs, TR_THROW)) chance = ((p_ptr->skill_tht) +
4073                 ((p_ptr->to_h_b + q_ptr->to_h) * BTH_PLUS_ADJ));
4074         else chance = (p_ptr->skill_tht + (p_ptr->to_h_b * BTH_PLUS_ADJ));
4075
4076         if (shuriken) chance *= 2;
4077
4078         /* Travel until stopped */
4079         for (cur_dis = 0; cur_dis <= tdis; )
4080         {
4081                 /* Hack -- Stop at the target */
4082                 if ((y == ty) && (x == tx)) break;
4083
4084                 /* Calculate the new location (see "project()") */
4085                 ny[cur_dis] = y;
4086                 nx[cur_dis] = x;
4087                 mmove2(&ny[cur_dis], &nx[cur_dis], py, px, ty, tx);
4088
4089                 /* Stopped by walls/doors */
4090                 if (!have_flag(f_flags_bold(ny[cur_dis], nx[cur_dis]), FF_PROJECT))
4091                 {
4092                         hit_wall = TRUE;
4093                         break;
4094                 }
4095
4096                 /* Advance the distance */
4097                 cur_dis++;
4098
4099                 /* The player can see the (on screen) missile */
4100                 if (panel_contains(ny[cur_dis-1], nx[cur_dis-1]) && player_can_see_bold(ny[cur_dis-1], nx[cur_dis-1]))
4101                 {
4102                         char c = object_char(q_ptr);
4103                         byte a = object_attr(q_ptr);
4104
4105                         /* Draw, Hilite, Fresh, Pause, Erase */
4106                         print_rel(c, a, ny[cur_dis-1], nx[cur_dis-1]);
4107                         move_cursor_relative(ny[cur_dis-1], nx[cur_dis-1]);
4108                         Term_fresh();
4109                         Term_xtra(TERM_XTRA_DELAY, msec);
4110                         lite_spot(ny[cur_dis-1], nx[cur_dis-1]);
4111                         Term_fresh();
4112                 }
4113
4114                 /* The player cannot see the missile */
4115                 else
4116                 {
4117                         /* Pause anyway, for consistancy */
4118                         Term_xtra(TERM_XTRA_DELAY, msec);
4119                 }
4120
4121                 /* Save the new location */
4122                 x = nx[cur_dis-1];
4123                 y = ny[cur_dis-1];
4124
4125
4126                 /* Monster here, Try to hit it */
4127                 if (cave[y][x].m_idx)
4128                 {
4129                         cave_type *c_ptr = &cave[y][x];
4130
4131                         monster_type *m_ptr = &m_list[c_ptr->m_idx];
4132                         monster_race *r_ptr = &r_info[m_ptr->r_idx];
4133
4134                         /* Check the visibility */
4135                         visible = m_ptr->ml;
4136
4137                         /* Note the collision */
4138                         hit_body = TRUE;
4139
4140                         /* Did we hit it (penalize range) */
4141                         if (test_hit_fire(chance - cur_dis, r_ptr->ac, m_ptr->ml))
4142                         {
4143                                 bool fear = FALSE;
4144
4145                                 /* Handle unseen monster */
4146                                 if (!visible)
4147                                 {
4148                                         /* Invisible monster */
4149 #ifdef JP
4150                                         msg_format("%s¤¬Å¨¤òÊ᪤·¤¿¡£", o_name);
4151 #else
4152                                         msg_format("The %s finds a mark.", o_name);
4153 #endif
4154
4155                                 }
4156
4157                                 /* Handle visible monster */
4158                                 else
4159                                 {
4160                                         char m_name[80];
4161
4162                                         /* Get "the monster" or "it" */
4163                                         monster_desc(m_name, m_ptr, 0);
4164
4165                                         /* Message */
4166 #ifdef JP
4167                                         msg_format("%s¤¬%s¤ËÌ¿Ã椷¤¿¡£", o_name, m_name);
4168 #else
4169                                         msg_format("The %s hits %s.", o_name, m_name);
4170 #endif
4171
4172
4173                                         /* Hack -- Track this monster race */
4174                                         if (m_ptr->ml) monster_race_track(m_ptr->ap_r_idx);
4175
4176                                         /* Hack -- Track this monster */
4177                                         if (m_ptr->ml) health_track(c_ptr->m_idx);
4178                                 }
4179
4180                                 /* Hack -- Base damage from thrown object */
4181                                 tdam = damroll(q_ptr->dd, q_ptr->ds);
4182                                 /* Apply special damage XXX XXX XXX */
4183                                 tdam = tot_dam_aux(q_ptr, tdam, m_ptr, 0, TRUE);
4184                                 tdam = critical_shot(q_ptr->weight, q_ptr->to_h, tdam);
4185                                 if (q_ptr->to_d > 0)
4186                                         tdam += q_ptr->to_d;
4187                                 else
4188                                         tdam += -q_ptr->to_d;
4189
4190                                 if (boomerang)
4191                                 {
4192                                         tdam *= (mult+p_ptr->num_blow[item - INVEN_RARM]);
4193                                         tdam += p_ptr->to_d_m;
4194                                 }
4195                                 else if (have_flag(flgs, TR_THROW))
4196                                 {
4197                                         tdam *= (3+mult);
4198                                         tdam += p_ptr->to_d_m;
4199                                 }
4200                                 else
4201                                 {
4202                                         tdam *= mult;
4203                                 }
4204                                 if (shuriken)
4205                                 {
4206                                         tdam += ((p_ptr->lev+30)*(p_ptr->lev+30)-900)/55;
4207                                 }
4208
4209                                 /* No negative damage */
4210                                 if (tdam < 0) tdam = 0;
4211
4212                                 /* Modify the damage */
4213                                 tdam = mon_damage_mod(m_ptr, tdam, FALSE);
4214
4215                                 /* Complex message */
4216                                 if (p_ptr->wizard)
4217                                 {
4218 #ifdef JP
4219                                         msg_format("%d/%d¤Î¥À¥á¡¼¥¸¤òÍ¿¤¨¤¿¡£",
4220                                                    tdam, m_ptr->hp);
4221 #else
4222                                         msg_format("You do %d (out of %d) damage.",
4223                                                    tdam, m_ptr->hp);
4224 #endif
4225
4226                                 }
4227
4228                                 /* Hit the monster, check for death */
4229                                 if (mon_take_hit(c_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_ptr(m_ptr))))
4230                                 {
4231                                         /* Dead monster */
4232                                 }
4233
4234                                 /* No death */
4235                                 else
4236                                 {
4237                                         /* Message */
4238                                         message_pain(c_ptr->m_idx, tdam);
4239
4240                                         /* Anger the monster */
4241                                         if ((tdam > 0) && !object_is_potion(q_ptr))
4242                                                 anger_monster(m_ptr);
4243
4244                                         /* Take note */
4245                                         if (fear && m_ptr->ml)
4246                                         {
4247                                                 char m_name[80];
4248
4249                                                 /* Sound */
4250                                                 sound(SOUND_FLEE);
4251
4252                                                 /* Get the monster name (or "it") */
4253                                                 monster_desc(m_name, m_ptr, 0);
4254
4255                                                 /* Message */
4256 #ifdef JP
4257                                                 msg_format("%^s¤Ï¶²Éݤ·¤Æƨ¤²½Ð¤·¤¿¡ª", m_name);
4258 #else
4259                                                 msg_format("%^s flees in terror!", m_name);
4260 #endif
4261
4262                                         }
4263                                 }
4264                         }
4265
4266                         /* Stop looking */
4267                         break;
4268                 }
4269         }
4270
4271         /* Chance of breakage (during attacks) */
4272         j = (hit_body ? breakage_chance(q_ptr) : 0);
4273
4274         /* Figurines transform */
4275         if ((q_ptr->tval == TV_FIGURINE) && !(p_ptr->inside_arena))
4276         {
4277                 j = 100;
4278
4279                 if (!(summon_named_creature(0, y, x, q_ptr->pval,
4280                                             !(object_is_cursed(q_ptr)) ? PM_FORCE_PET : 0L)))
4281 #ifdef JP
4282 msg_print("¿Í·Á¤ÏDZ¤¸¶Ê¤¬¤êºÕ¤±»¶¤Ã¤Æ¤·¤Þ¤Ã¤¿¡ª");
4283 #else
4284                         msg_print("The Figurine writhes and then shatters.");
4285 #endif
4286
4287                 else if (object_is_cursed(q_ptr))
4288 #ifdef JP
4289 msg_print("¤³¤ì¤Ï¤¢¤Þ¤êÎɤ¯¤Ê¤¤µ¤¤¬¤¹¤ë¡£");
4290 #else
4291                         msg_print("You have a bad feeling about this.");
4292 #endif
4293
4294         }
4295
4296
4297         /* Potions smash open */
4298         if (object_is_potion(q_ptr))
4299         {
4300                 if (hit_body || hit_wall || (randint1(100) < j))
4301                 {
4302                         /* Message */
4303 #ifdef JP
4304                         msg_format("%s¤ÏºÕ¤±»¶¤Ã¤¿¡ª", o_name);
4305 #else
4306                         msg_format("The %s shatters!", o_name);
4307 #endif
4308
4309
4310                         if (potion_smash_effect(0, y, x, q_ptr->k_idx))
4311                         {
4312                                 monster_type *m_ptr = &m_list[cave[y][x].m_idx];
4313
4314                                 /* ToDo (Robert): fix the invulnerability */
4315                                 if (cave[y][x].m_idx &&
4316                                     is_friendly(&m_list[cave[y][x].m_idx]) &&
4317                                     !(m_ptr->invulner))
4318                                 {
4319                                         char m_name[80];
4320                                         monster_desc(m_name, &m_list[cave[y][x].m_idx], 0);
4321 #ifdef JP
4322                                         msg_format("%s¤ÏÅܤä¿¡ª", m_name);
4323 #else
4324                                         msg_format("%^s gets angry!", m_name);
4325 #endif
4326
4327                                         set_hostile(&m_list[cave[y][x].m_idx]);
4328                                 }
4329                         }
4330                         do_drop = FALSE;
4331                 }
4332                 else
4333                 {
4334                         j = 0;
4335                 }
4336         }
4337
4338         if (return_when_thrown)
4339         {
4340                 int back_chance = randint1(30)+20+((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
4341                 char o2_name[MAX_NLEN];
4342                 bool super_boomerang = (((q_ptr->name1 == ART_MJOLLNIR) || (q_ptr->name1 == ART_AEGISFANG)) && boomerang);
4343
4344                 j = -1;
4345                 if (boomerang) back_chance += 4+randint1(5);
4346                 if (super_boomerang) back_chance += 100;
4347                 object_desc(o2_name, q_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
4348
4349                 if((back_chance > 30) && (!one_in_(100) || super_boomerang))
4350                 {
4351                         for (i = cur_dis-1;i>0;i--)
4352                         {
4353                                 if (panel_contains(ny[i], nx[i]) && player_can_see_bold(ny[i], nx[i]))
4354                                 {
4355                                         char c = object_char(q_ptr);
4356                                         byte a = object_attr(q_ptr);
4357
4358                                         /* Draw, Hilite, Fresh, Pause, Erase */
4359                                         print_rel(c, a, ny[i], nx[i]);
4360                                         move_cursor_relative(ny[i], nx[i]);
4361                                         Term_fresh();
4362                                         Term_xtra(TERM_XTRA_DELAY, msec);
4363                                         lite_spot(ny[i], nx[i]);
4364                                         Term_fresh();
4365                                 }
4366                                 else
4367                                 {
4368                                         /* Pause anyway, for consistancy */
4369                                         Term_xtra(TERM_XTRA_DELAY, msec);
4370                                 }
4371                         }
4372                         if((back_chance > 37) && !p_ptr->blind && (item >= 0))
4373                         {
4374 #ifdef JP
4375                                 msg_format("%s¤¬¼ê¸µ¤ËÊ֤äƤ­¤¿¡£", o2_name);
4376 #else
4377                                 msg_format("%s comes back to you.", o2_name);
4378 #endif
4379                                 come_back = TRUE;
4380                         }
4381                         else
4382                         {
4383                                 if (item >= 0)
4384                                 {
4385 #ifdef JP
4386                                         msg_format("%s¤ò¼õ¤±Â»¤Í¤¿¡ª", o2_name);
4387 #else
4388                                         msg_format("%s backs, but you can't catch!", o2_name);
4389 #endif
4390                                 }
4391                                 else
4392                                 {
4393 #ifdef JP
4394                                         msg_format("%s¤¬Ê֤äƤ­¤¿¡£", o2_name);
4395 #else
4396                                         msg_format("%s comes back.", o2_name);
4397 #endif
4398                                 }
4399                                 y = py;
4400                                 x = px;
4401                         }
4402                 }
4403                 else
4404                 {
4405 #ifdef JP
4406                         msg_format("%s¤¬Ê֤äƤ³¤Ê¤«¤Ã¤¿¡ª", o2_name);
4407 #else
4408                         msg_format("%s doesn't back!", o2_name);
4409 #endif
4410                 }
4411         }
4412
4413         if (come_back)
4414         {
4415                 if (item == INVEN_RARM || item == INVEN_LARM)
4416                 {
4417                         /* Access the wield slot */
4418                         o_ptr = &inventory[item];
4419
4420                         /* Wear the new stuff */
4421                         object_copy(o_ptr, q_ptr);
4422
4423                         /* Increase the weight */
4424                         p_ptr->total_weight += q_ptr->weight;
4425
4426                         /* Increment the equip counter by hand */
4427                         equip_cnt++;
4428
4429                         /* Recalculate bonuses */
4430                         p_ptr->update |= (PU_BONUS);
4431
4432                         /* Recalculate torch */
4433                         p_ptr->update |= (PU_TORCH);
4434
4435                         /* Recalculate mana XXX */
4436                         p_ptr->update |= (PU_MANA);
4437
4438                         /* Window stuff */
4439                         p_ptr->window |= (PW_EQUIP);
4440                 }
4441                 else
4442                 {
4443                         inven_carry(q_ptr);
4444                 }
4445                 do_drop = FALSE;
4446         }
4447         else if (equiped_item)
4448         {
4449                 kamaenaoshi(item);
4450                 calc_android_exp();
4451         }
4452
4453         /* Drop (or break) near that location */
4454         if (do_drop) (void)drop_near(q_ptr, j, y, x);
4455
4456         return TRUE;
4457 }
4458
4459
4460 /*
4461  * Throw an object from the pack or floor.
4462  */
4463 void do_cmd_throw(void)
4464 {
4465         do_cmd_throw_aux(1, FALSE, 0);
4466 }