OSDN Git Service

近く行なうキャラクター情報'C'の画面の変更に備えて、表示する各行の
[hengband/hengband.git] / src / cmd1.c
1 /* File: cmd1.c */
2
3 /* Purpose: Movement commands (part 1) */
4
5 /*
6  * Copyright (c) 1989 James E. Wilson, Robert A. Koeneke
7  *
8  * This software may be copied and distributed for educational, research, and
9  * not for profit purposes provided that this copyright and statement are
10  * included in all such copies.
11  */
12
13 #include "angband.h"
14 #define MAX_VAMPIRIC_DRAIN 50
15
16
17 /*
18  * Determine if the player "hits" a monster (normal combat).
19  * Note -- Always miss 5%, always hit 5%, otherwise random.
20  */
21 bool test_hit_fire(int chance, int ac, int vis)
22 {
23         int k;
24
25         /* Percentile dice */
26         k = rand_int(100);
27
28         /* Hack -- Instant miss or hit */
29         if (k < 10) return (k < 5);
30
31         if (p_ptr->pseikaku == SEIKAKU_NAMAKE)
32                 if (one_in_(20)) return (FALSE);
33
34         /* Never hit */
35         if (chance <= 0) return (FALSE);
36
37         /* Invisible monsters are harder to hit */
38         if (!vis) chance = (chance + 1) / 2;
39
40         /* Power competes against armor */
41         if (rand_int(chance) < (ac * 3 / 4)) return (FALSE);
42
43         /* Assume hit */
44         return (TRUE);
45 }
46
47
48
49 /*
50  * Determine if the player "hits" a monster (normal combat).
51  *
52  * Note -- Always miss 5%, always hit 5%, otherwise random.
53  */
54 bool test_hit_norm(int chance, int ac, int vis)
55 {
56         int k;
57
58         /* Percentile dice */
59         k = rand_int(100);
60
61         /* Hack -- Instant miss or hit */
62         if (k < 10) return (k < 5);
63
64         /* Wimpy attack never hits */
65         if (chance <= 0) return (FALSE);
66
67         /* Penalize invisible targets */
68         if (!vis) chance = (chance + 1) / 2;
69
70         /* Power must defeat armor */
71         if (rand_int(chance) < (ac * 3 / 4)) return (FALSE);
72
73         /* Assume hit */
74         return (TRUE);
75 }
76
77
78
79 /*
80  * Critical hits (from objects thrown by player)
81  * Factor in item weight, total plusses, and player level.
82  */
83 s16b critical_shot(int weight, int plus, int dam)
84 {
85         int i, k;
86
87         /* Extract "shot" power */
88         i = (weight + ((p_ptr->to_h_b + plus) * 4) + (p_ptr->lev * 2));
89
90         /* Critical hit */
91         if (randint(5000) <= i)
92         {
93                 k = weight + randint(500);
94
95                 if (k < 500)
96                 {
97 #ifdef JP
98                         msg_print("¼ê¤´¤¿¤¨¤¬¤¢¤Ã¤¿¡ª");
99 #else
100                         msg_print("It was a good hit!");
101 #endif
102
103                         dam = 2 * dam + 5;
104                 }
105                 else if (k < 1000)
106                 {
107 #ifdef JP
108                         msg_print("¤«¤Ê¤ê¤Î¼ê¤´¤¿¤¨¤¬¤¢¤Ã¤¿¡ª");
109 #else
110                         msg_print("It was a great hit!");
111 #endif
112
113                         dam = 2 * dam + 10;
114                 }
115                 else
116                 {
117 #ifdef JP
118                         msg_print("²ñ¿´¤Î°ì·â¤À¡ª");
119 #else
120                         msg_print("It was a superb hit!");
121 #endif
122
123                         dam = 3 * dam + 15;
124                 }
125         }
126
127         return (dam);
128 }
129
130
131
132 /*
133  * Critical hits (by player)
134  *
135  * Factor in weapon weight, total plusses, player level.
136  */
137 s16b critical_norm(int weight, int plus, int dam, s16b meichuu, int mode)
138 {
139         int i, k;
140
141         /* Extract "blow" power */
142         i = (weight + (meichuu * 3 + plus * 5) + (p_ptr->lev * 3));
143
144         /* Chance */
145         if ((randint((p_ptr->pclass == CLASS_NINJA) ? 4444 : 5000) <= i) || (mode == HISSATSU_MAJIN) || (mode == HISSATSU_3DAN))
146         {
147                 k = weight + randint(650);
148                 if ((mode == HISSATSU_MAJIN) || (mode == HISSATSU_3DAN)) k+= randint(650);
149
150                 if (k < 400)
151                 {
152 #ifdef JP
153                         msg_print("¼ê¤´¤¿¤¨¤¬¤¢¤Ã¤¿¡ª");
154 #else
155                         msg_print("It was a good hit!");
156 #endif
157
158                         dam = 2 * dam + 5;
159                 }
160                 else if (k < 700)
161                 {
162 #ifdef JP
163                         msg_print("¤«¤Ê¤ê¤Î¼ê¤´¤¿¤¨¤¬¤¢¤Ã¤¿¡ª");
164 #else
165                         msg_print("It was a great hit!");
166 #endif
167
168                         dam = 2 * dam + 10;
169                 }
170                 else if (k < 900)
171                 {
172 #ifdef JP
173                         msg_print("²ñ¿´¤Î°ì·â¤À¡ª");
174 #else
175                         msg_print("It was a superb hit!");
176 #endif
177
178                         dam = 3 * dam + 15;
179                 }
180                 else if (k < 1300)
181                 {
182 #ifdef JP
183                         msg_print("ºÇ¹â¤Î²ñ¿´¤Î°ì·â¤À¡ª");
184 #else
185                         msg_print("It was a *GREAT* hit!");
186 #endif
187
188                         dam = 3 * dam + 20;
189                 }
190                 else
191                 {
192 #ifdef JP
193                         msg_print("ÈæÎà¤Ê¤­ºÇ¹â¤Î²ñ¿´¤Î°ì·â¤À¡ª");
194 #else
195                         msg_print("It was a *SUPERB* hit!");
196 #endif
197
198                         dam = ((7 * dam) / 2) + 25;
199                 }
200         }
201
202         return (dam);
203 }
204
205
206
207 /*
208  * Extract the "total damage" from a given object hitting a given monster.
209  *
210  * Note that "flasks of oil" do NOT do fire damage, although they
211  * certainly could be made to do so.  XXX XXX
212  *
213  * Note that most brands and slays are x3, except Slay Animal (x2),
214  * Slay Evil (x2), and Kill dragon (x5).
215  */
216 s16b tot_dam_aux(object_type *o_ptr, int tdam, monster_type *m_ptr, int mode)
217 {
218         int mult = 10;
219
220         monster_race *r_ptr = &r_info[m_ptr->r_idx];
221
222         u32b f1, f2, f3;
223
224         /* Extract the flags */
225         object_flags(o_ptr, &f1, &f2, &f3);
226
227         /* Some "weapons" and "ammo" do extra damage */
228         switch (o_ptr->tval)
229         {
230                 case TV_SHOT:
231                 case TV_ARROW:
232                 case TV_BOLT:
233                 case TV_HAFTED:
234                 case TV_POLEARM:
235                 case TV_SWORD:
236                 case TV_DIGGING:
237                 {
238                         /* Slay Animal */
239                         if ((f1 & TR1_SLAY_ANIMAL) &&
240                             (r_ptr->flags3 & RF3_ANIMAL))
241                         {
242                                 if (m_ptr->ml)
243                                 {
244                                         r_ptr->r_flags3 |= RF3_ANIMAL;
245                                 }
246
247                                 if (mult < 20) mult = 20;
248                         }
249
250                         /* Slay Evil */
251                         if ((f1 & TR1_SLAY_EVIL) &&
252                             (r_ptr->flags3 & RF3_EVIL))
253                         {
254                                 if (m_ptr->ml)
255                                 {
256                                         r_ptr->r_flags3 |= RF3_EVIL;
257                                 }
258
259                                 if (mult < 20) mult = 20;
260                         }
261
262                         /* Slay Undead */
263                         if ((f1 & TR1_SLAY_UNDEAD) &&
264                             (r_ptr->flags3 & RF3_UNDEAD))
265                         {
266                                 if (m_ptr->ml)
267                                 {
268                                         r_ptr->r_flags3 |= RF3_UNDEAD;
269                                 }
270
271                                 if (mult < 30) mult = 30;
272                         }
273
274                         /* Slay Demon */
275                         if ((f1 & TR1_SLAY_DEMON) &&
276                             (r_ptr->flags3 & RF3_DEMON))
277                         {
278                                 if (m_ptr->ml)
279                                 {
280                                         r_ptr->r_flags3 |= RF3_DEMON;
281                                 }
282
283                                 if (mult < 30) mult = 30;
284                         }
285
286                         /* Slay Orc */
287                         if ((f1 & TR1_SLAY_ORC) &&
288                             (r_ptr->flags3 & RF3_ORC))
289                         {
290                                 if (m_ptr->ml)
291                                 {
292                                         r_ptr->r_flags3 |= RF3_ORC;
293                                 }
294
295                                 if (mult < 30) mult = 30;
296                         }
297
298                         /* Slay Troll */
299                         if ((f1 & TR1_SLAY_TROLL) &&
300                             (r_ptr->flags3 & RF3_TROLL))
301                         {
302                                 if (m_ptr->ml)
303                                 {
304                                         r_ptr->r_flags3 |= RF3_TROLL;
305                                 }
306
307                                 if (mult < 30) mult = 30;
308                         }
309
310                         /* Slay Giant */
311                         if ((f1 & TR1_SLAY_GIANT) &&
312                             (r_ptr->flags3 & RF3_GIANT))
313                         {
314                                 if (m_ptr->ml)
315                                 {
316                                         r_ptr->r_flags3 |= RF3_GIANT;
317                                 }
318
319                                 if (mult < 30) mult = 30;
320                                 if (o_ptr->name1 == ART_HRUNTING)
321                                         mult *= 3;
322                         }
323
324                         /* Slay Dragon  */
325                         if ((f1 & TR1_SLAY_DRAGON) &&
326                             (r_ptr->flags3 & RF3_DRAGON))
327                         {
328                                 if (m_ptr->ml)
329                                 {
330                                         r_ptr->r_flags3 |= RF3_DRAGON;
331                                 }
332
333                                 if (mult < 30) mult = 30;
334                         }
335
336                         /* Execute Dragon */
337                         if ((f1 & TR1_KILL_DRAGON) &&
338                             (r_ptr->flags3 & RF3_DRAGON))
339                         {
340                                 if (m_ptr->ml)
341                                 {
342                                         r_ptr->r_flags3 |= RF3_DRAGON;
343                                 }
344
345                                 if (mult < 50) mult = 50;
346
347                                 if ((o_ptr->name1 == ART_AEGLIN) && (m_ptr->r_idx == MON_FAFNER))
348                                         mult *= 3;
349                         }
350
351                         /* Brand (Acid) */
352                         if ((f1 & TR1_BRAND_ACID) || (p_ptr->special_attack & (ATTACK_ACID)))
353                         {
354                                 /* Notice immunity */
355                                 if (r_ptr->flags3 & RF3_IM_ACID)
356                                 {
357                                         if (m_ptr->ml)
358                                         {
359                                                 r_ptr->r_flags3 |= RF3_IM_ACID;
360                                         }
361                                 }
362
363                                 /* Otherwise, take the damage */
364                                 else
365                                 {
366                                         if (mult < 25) mult = 25;
367                                 }
368                         }
369
370                         /* Brand (Elec) */
371                         if ((f1 & TR1_BRAND_ELEC) || (p_ptr->special_attack & (ATTACK_ELEC)) || (mode == HISSATSU_ELEC))
372                         {
373                                 /* Notice immunity */
374                                 if (r_ptr->flags3 & RF3_IM_ELEC)
375                                 {
376                                         if (m_ptr->ml)
377                                         {
378                                                 r_ptr->r_flags3 |= RF3_IM_ELEC;
379                                         }
380                                 }
381
382                                 /* Otherwise, take the damage */
383                                 else if (((f1 & TR1_BRAND_ELEC) || (p_ptr->special_attack & (ATTACK_ELEC))) && (mode == HISSATSU_ELEC))
384                                 {
385                                         if (mult < 70) mult = 70;
386                                 }
387                                 else if (mode == HISSATSU_ELEC)
388                                 {
389                                         if (mult < 50) mult = 50;
390                                 }
391
392                                 else
393                                 {
394                                         if (mult < 25) mult = 25;
395                                 }
396                         }
397
398                         /* Brand (Fire) */
399                         if ((f1 & TR1_BRAND_FIRE) || (p_ptr->special_attack & (ATTACK_FIRE)) || (mode == HISSATSU_FIRE))
400                         {
401                                 /* Notice immunity */
402                                 if (r_ptr->flags3 & RF3_IM_FIRE)
403                                 {
404                                         if (m_ptr->ml)
405                                         {
406                                                 r_ptr->r_flags3 |= RF3_IM_FIRE;
407                                         }
408                                 }
409
410                                 /* Otherwise, take the damage */
411                                 else if (((f1 & TR1_BRAND_FIRE) || (p_ptr->special_attack & (ATTACK_FIRE))) && (mode == HISSATSU_FIRE))
412                                 {
413                                         if (r_ptr->flags3 & RF3_HURT_FIRE)
414                                         {
415                                                 if (mult < 70) mult = 70;
416                                                 if (m_ptr->ml)
417                                                 {
418                                                         r_ptr->r_flags3 |= RF3_HURT_FIRE;
419                                                 }
420                                         }
421                                         else if (mult < 35) mult = 35;
422                                 }
423                                 else
424                                 {
425                                         if (r_ptr->flags3 & RF3_HURT_FIRE)
426                                         {
427                                                 if (mult < 50) mult = 50;
428                                                 if (m_ptr->ml)
429                                                 {
430                                                         r_ptr->r_flags3 |= RF3_HURT_FIRE;
431                                                 }
432                                         }
433                                         else if (mult < 25) mult = 25;
434                                 }
435                         }
436
437                         /* Brand (Cold) */
438                         if ((f1 & TR1_BRAND_COLD) || (p_ptr->special_attack & (ATTACK_COLD)) || (mode == HISSATSU_COLD))
439                         {
440                                 /* Notice immunity */
441                                 if (r_ptr->flags3 & RF3_IM_COLD)
442                                 {
443                                         if (m_ptr->ml)
444                                         {
445                                                 r_ptr->r_flags3 |= RF3_IM_COLD;
446                                         }
447                                 }
448                                 /* Otherwise, take the damage */
449                                 else if (((f1 & TR1_BRAND_COLD) || (p_ptr->special_attack & (ATTACK_COLD))) && (mode == HISSATSU_COLD))
450                                 {
451                                         if (r_ptr->flags3 & RF3_HURT_COLD)
452                                         {
453                                                 if (mult < 70) mult = 70;
454                                                 if (m_ptr->ml)
455                                                 {
456                                                         r_ptr->r_flags3 |= RF3_HURT_COLD;
457                                                 }
458                                         }
459                                         else if (mult < 35) mult = 35;
460                                 }
461                                 else
462                                 {
463                                         if (r_ptr->flags3 & RF3_HURT_COLD)
464                                         {
465                                                 if (mult < 50) mult = 50;
466                                                 if (m_ptr->ml)
467                                                 {
468                                                         r_ptr->r_flags3 |= RF3_HURT_COLD;
469                                                 }
470                                         }
471                                         else if (mult < 25) mult = 25;
472                                 }
473                         }
474
475                         /* Brand (Poison) */
476                         if ((f1 & TR1_BRAND_POIS) || (p_ptr->special_attack & (ATTACK_POIS)) || (mode == HISSATSU_POISON))
477                         {
478                                 /* Notice immunity */
479                                 if (r_ptr->flags3 & RF3_IM_POIS)
480                                 {
481                                         if (m_ptr->ml)
482                                         {
483                                                 r_ptr->r_flags3 |= RF3_IM_POIS;
484                                         }
485                                 }
486
487                                 /* Otherwise, take the damage */
488                                 else if (((f1 & TR1_BRAND_POIS) || (p_ptr->special_attack & (ATTACK_POIS))) && (mode == HISSATSU_POISON))
489                                 {
490                                         if (mult < 35) mult = 35;
491                                 }
492                                 else
493                                 {
494                                         if (mult < 25) mult = 25;
495                                 }
496                         }
497                         if ((mode == HISSATSU_ZANMA) && (r_ptr->flags3 & (RF3_DEMON | RF3_UNDEAD | RF3_NONLIVING)) && (r_ptr->flags3 & RF3_EVIL))
498                         {
499                                 if (mult < 15) mult = 25;
500                                 else if (mult < 50) mult = MIN(50, mult+20);
501                         }
502                         if (mode == HISSATSU_UNDEAD)
503                         {
504                                 if (r_ptr->flags3 & RF3_UNDEAD)
505                                 {
506                                         if (m_ptr->ml)
507                                         {
508                                                 r_ptr->r_flags3 |= RF3_UNDEAD;
509                                         }
510                                         if (mult == 10) mult = 70;
511                                         else if (mult < 140) mult = MIN(140, mult+60);
512                                 }
513                                 if (mult == 10) mult = 40;
514                                 else if (mult < 60) mult = MIN(60, mult+30);
515                         }
516                         if ((mode == HISSATSU_SEKIRYUKA) && p_ptr->cut && !(r_ptr->flags3 & (RF3_DEMON | RF3_UNDEAD | RF3_NONLIVING)))
517                         {
518                                 int tmp = MIN(100, MAX(10, p_ptr->cut / 10));
519                                 if (mult < tmp) mult = tmp;
520                         }
521                         if ((mode == HISSATSU_HAGAN) && (r_ptr->flags3 & RF3_HURT_ROCK))
522                         {
523                                 if (m_ptr->ml)
524                                 {
525                                         r_ptr->r_flags3 |= RF3_HURT_ROCK;
526                                 }
527                                 if (mult == 10) mult = 40;
528                                 else if (mult < 60) mult = 60;
529                         }
530                         if ((p_ptr->pclass != CLASS_SAMURAI) && (f1 & TR1_FORCE_WEPON) && (p_ptr->csp > (o_ptr->dd * o_ptr->ds / 5)))
531                         {
532                                 p_ptr->csp -= (1+(o_ptr->dd * o_ptr->ds / 5));
533                                 p_ptr->redraw |= (PR_MANA);
534                                 mult = MIN(60, mult * 7 / 2);
535                         }
536                         break;
537                 }
538         }
539         if (mult > 150) mult = 150;
540
541         /* Return the total damage */
542         return (tdam * mult / 10);
543 }
544
545
546 /*
547  * Search for hidden things
548  */
549 void search(void)
550 {
551         int y, x, chance;
552
553         s16b this_o_idx, next_o_idx = 0;
554
555         cave_type *c_ptr;
556
557
558         /* Start with base search ability */
559         chance = p_ptr->skill_srh;
560
561         /* Penalize various conditions */
562         if (p_ptr->blind || no_lite()) chance = chance / 10;
563         if (p_ptr->confused || p_ptr->image) chance = chance / 10;
564
565         /* Search the nearby grids, which are always in bounds */
566         for (y = (py - 1); y <= (py + 1); y++)
567         {
568                 for (x = (px - 1); x <= (px + 1); x++)
569                 {
570                         /* Sometimes, notice things */
571                         if (rand_int(100) < chance)
572                         {
573                                 /* Access the grid */
574                                 c_ptr = &cave[y][x];
575
576 #ifdef USE_SCRIPT
577                                 if (player_search_grid_callback(y, x))
578                                 {
579                                         /* Disturb */
580                                         disturb(0, 0);
581
582                                         return;
583                                 }
584 #endif /* USE_SCRIPT */
585
586                                 /* Invisible trap */
587                                 if (c_ptr->info & CAVE_TRAP)
588                                 {
589                                         /* Pick a trap */
590                                         pick_trap(y, x);
591
592                                         /* Message */
593 #ifdef JP
594                                         msg_print("¥È¥é¥Ã¥×¤òȯ¸«¤·¤¿¡£");
595 #else
596                                         msg_print("You have found a trap.");
597 #endif
598
599
600                                         /* Disturb */
601                                         disturb(0, 0);
602                                 }
603
604                                 /* Secret door */
605                                 if (c_ptr->feat == FEAT_SECRET)
606                                 {
607                                         /* Message */
608 #ifdef JP
609                                         msg_print("±£¤·¥É¥¢¤òȯ¸«¤·¤¿¡£");
610 #else
611                                         msg_print("You have found a secret door.");
612 #endif
613
614
615                                         /* Pick a door */
616                                         place_closed_door(y, x);
617
618                                         /* Disturb */
619                                         disturb(0, 0);
620                                 }
621
622                                 /* Scan all objects in the grid */
623                                 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
624                                 {
625                                         object_type *o_ptr;
626
627                                         /* Acquire object */
628                                         o_ptr = &o_list[this_o_idx];
629
630                                         /* Acquire next object */
631                                         next_o_idx = o_ptr->next_o_idx;
632
633                                         /* Skip non-chests */
634                                         if (o_ptr->tval != TV_CHEST) continue;
635
636                                         /* Skip non-trapped chests */
637                                         if (!chest_traps[o_ptr->pval]) continue;
638
639                                         /* Identify once */
640                                         if (!object_known_p(o_ptr))
641                                         {
642                                                 /* Message */
643 #ifdef JP
644                                                 msg_print("È¢¤Ë»Å³Ý¤±¤é¤ì¤¿¥È¥é¥Ã¥×¤òȯ¸«¤·¤¿¡ª");
645 #else
646                                                 msg_print("You have discovered a trap on the chest!");
647 #endif
648
649
650                                                 /* Know the trap */
651                                                 object_known(o_ptr);
652
653                                                 /* Notice it */
654                                                 disturb(0, 0);
655                                         }
656                                 }
657                         }
658                 }
659         }
660 }
661
662
663 /*
664  * Helper routine for py_pickup() and py_pickup_floor().
665  *
666  * Add the given dungeon object to the character's inventory.
667  *
668  * Delete the object afterwards.
669  */
670 void py_pickup_aux(int o_idx)
671 {
672         int slot, i;
673
674 #ifdef JP
675 /*
676  * ¥¢¥¤¥Æ¥à¤ò½¦¤Ã¤¿ºÝ¤Ë¡Ö£²¤Ä¤Î¥±¡¼¥­¤ò»ý¤Ã¤Æ¤¤¤ë¡×
677  * "You have two cakes." ¤È¥¢¥¤¥Æ¥à¤ò½¦¤Ã¤¿¸å¤Î¹ç·×¤Î¤ß¤Îɽ¼¨¤¬¥ª¥ê¥¸¥Ê¥ë
678  * ¤À¤¬¡¢°ãÏ´¶¤¬
679  * ¤¢¤ë¤È¤¤¤¦»ØŦ¤ò¤¦¤±¤¿¤Î¤Ç¡¢¡Ö¡Á¤ò½¦¤Ã¤¿¡¢¡Á¤ò»ý¤Ã¤Æ¤¤¤ë¡×¤È¤¤¤¦É½¼¨
680  * ¤Ë¤«¤¨¤Æ¤¢¤ë¡£¤½¤Î¤¿¤á¤ÎÇÛÎó¡£
681  */
682         char o_name[MAX_NLEN];
683         char old_name[MAX_NLEN];
684         char kazu_str[80];
685         int hirottakazu;
686         extern char *object_desc_kosuu(char *t, object_type *o_ptr);
687 #else
688         char o_name[MAX_NLEN];
689 #endif
690
691         object_type *o_ptr;
692
693         o_ptr = &o_list[o_idx];
694
695 #ifdef JP
696         /* Describe the object */
697         object_desc(old_name, o_ptr, TRUE, 0);
698         object_desc_kosuu(kazu_str, o_ptr);
699         hirottakazu = o_ptr->number;
700 #endif
701         /* Carry the object */
702         slot = inven_carry(o_ptr);
703
704         /* Get the object again */
705         o_ptr = &inventory[slot];
706
707         /* Delete the object */
708         delete_object_idx(o_idx);
709
710         if (p_ptr->pseikaku == SEIKAKU_MUNCHKIN) identify_item(o_ptr);
711
712         /* Describe the object */
713         object_desc(o_name, o_ptr, TRUE, 3);
714
715         /* Message */
716 #ifdef JP
717         if ((o_ptr->name1 == ART_CRIMSON) && (p_ptr->pseikaku == SEIKAKU_COMBAT))
718         {
719                 msg_format("¤³¤¦¤·¤Æ¡¢%s¤Ï¡Ø¥¯¥ê¥à¥¾¥ó¡Ù¤ò¼ê¤ËÆþ¤ì¤¿¡£", player_name);
720                 msg_print("¤·¤«¤·º£¡¢¡Øº®Æ٤Υµ¡¼¥Ú¥ó¥È¡Ù¤ÎÊü¤Ã¤¿¥â¥ó¥¹¥¿¡¼¤¬¡¢");
721                 msg_format("%s¤Ë½±¤¤¤«¤«¤ë¡¥¡¥¡¥", player_name);
722         }
723         else
724         {
725                 if (plain_pickup)
726                 {
727                         msg_format("%s(%c)¤ò»ý¤Ã¤Æ¤¤¤ë¡£",o_name, index_to_label(slot));
728                 }
729                 else
730                 {
731                         if (o_ptr->number > hirottakazu) {
732                             msg_format("%s½¦¤Ã¤Æ¡¢%s(%c)¤ò»ý¤Ã¤Æ¤¤¤ë¡£",
733                                kazu_str, o_name, index_to_label(slot));
734                         } else {
735                                 msg_format("%s(%c)¤ò½¦¤Ã¤¿¡£", o_name, index_to_label(slot));
736                         }
737                 }
738         }
739         strcpy(record_o_name, old_name);
740 #else
741         msg_format("You have %s (%c).", o_name, index_to_label(slot));
742         strcpy(record_o_name, o_name);
743 #endif
744         record_turn = turn;
745
746
747         /* Check if completed a quest */
748         for (i = 0; i < max_quests; i++)
749         {
750                 if ((quest[i].type == QUEST_TYPE_FIND_ARTIFACT) &&
751                     (quest[i].status == QUEST_STATUS_TAKEN) &&
752                            (quest[i].k_idx == o_ptr->name1))
753                 {
754                         quest[i].status = QUEST_STATUS_COMPLETED;
755                         quest[i].complev = (byte)p_ptr->lev;
756 #ifdef JP
757                         msg_print("¥¯¥¨¥¹¥È¤òãÀ®¤·¤¿¡ª");
758 #else
759                         msg_print("You completed your quest!");
760 #endif
761
762                         msg_print(NULL);
763                 }
764         }
765 }
766
767
768 bool can_player_destroy_object(object_type *o_ptr)
769 {
770         /* Artifacts cannot be destroyed */
771         if (artifact_p(o_ptr) || o_ptr->art_name)
772         {
773                 byte feel = FEEL_SPECIAL;
774
775                 /* Hack -- Handle icky artifacts */
776                 if (cursed_p(o_ptr) || broken_p(o_ptr)) feel = FEEL_TERRIBLE;
777
778                 /* Hack -- inscribe the artifact */
779                 o_ptr->feeling = feel;
780
781                 /* We have "felt" it (again) */
782                 o_ptr->ident |= (IDENT_SENSE);
783
784                 /* Combine the pack */
785                 p_ptr->notice |= (PN_COMBINE);
786
787                 /* Redraw equippy chars */
788                 p_ptr->redraw |= (PR_EQUIPPY);
789
790                 /* Window stuff */
791                 p_ptr->window |= (PW_INVEN | PW_EQUIP);
792
793                 /* Done */
794                 return FALSE;
795         }
796
797         return TRUE;
798 }
799
800 /** ¼«Æ°½¦¤¤È½Äê **/
801
802 int is_autopick(object_type *o_ptr)
803 {
804         int i;
805         char o_name[MAX_NLEN];
806         cptr str;
807 #ifdef JP
808         static char kanji_colon[] = "¡§";
809 #endif
810
811         if (o_ptr->tval == TV_GOLD) return -1;
812         
813         object_desc(o_name, o_ptr, FALSE, 3);
814         for (i = 0; o_name[i]; i++)
815         {
816 #ifdef JP
817                 if (iskanji(o_name[i]))
818                         i++;
819                 else
820 #endif
821                 if (isupper(o_name[i]))
822                         o_name[i] = tolower(o_name[i]);
823         }
824         
825         for (i=0; i<max_autopick; i++)
826         {
827                 int len = 0;
828                 bool collectable = FALSE;
829                 bool flag = FALSE;
830
831                 str = autopick_name[i];
832
833 #ifdef JP               
834                 /*** ¤¹¤Ù¤Æ¤Î... ***/
835                 if (!strncmp(str, "¤¹¤Ù¤Æ¤Î", 8)) str+= 8;
836
837                 /*** ´û¤Ë»ý¤Ã¤Æ¤¤¤ë¥¢¥¤¥Æ¥à ***/
838                 if (!strncmp(str, "¼ý½¸Ãæ¤Î", 8))
839                 {
840                         collectable = TRUE;
841                         str+= 8;
842                 }
843
844                 /*** Ì¤´ÕÄê¤Î... ***/
845                 if (!strncmp(str, "̤´ÕÄê¤Î",8) &&
846                     !object_known_p(o_ptr) && !( (o_ptr->ident)&IDENT_SENSE)) str+= 8;
847                 
848                 /*** ´ÕÄêºÑ¤ß¤Î... ***/
849                 if (!strncmp(str, "´ÕÄêºÑ¤ß¤Î",10) &&
850                     object_known_p(o_ptr) ) str+= 10;
851
852                 /*** *´ÕÄê*ºÑ¤ß¤Î... ***/
853                 if (!strncmp(str, "*´ÕÄê*ºÑ¤ß¤Î",12) &&
854                     object_known_p(o_ptr) && (o_ptr->ident & IDENT_MENTAL) ) str+= 12;
855                 
856                 /*** ÌµÌäÎ... ***/
857                 if (!strncmp(str, "̵ÌäÎ", 6)
858                     && (object_known_p(o_ptr)) && !o_ptr->inscription
859                     && (!o_ptr->name1 && !o_ptr->name2 && !o_ptr->art_name))
860                 {
861                         switch (o_ptr->tval)
862                         {
863                         case TV_SHOT: case TV_ARROW: case TV_BOLT: case TV_BOW:
864                         case TV_DIGGING: case TV_HAFTED: case TV_POLEARM: case TV_SWORD: 
865                         case TV_BOOTS: case TV_GLOVES: case TV_HELM: case TV_CROWN:
866                         case TV_SHIELD: case TV_CLOAK:
867                         case TV_SOFT_ARMOR: case TV_HARD_ARMOR: case TV_DRAG_ARMOR:
868                         case TV_LITE: case TV_AMULET: case TV_RING: case TV_CARD:
869                                 str += 6;
870                         }
871                 }
872                 
873                 /*** Ì¤È½ÌÀ¤Î...  ***/
874                 if (!strncmp(str, "̤ȽÌÀ¤Î",8) && 
875                     !object_aware_p(o_ptr)) str+= 8;
876                 
877                 /*** Ìµ²ÁÃͤÎ... ***/
878                 if (!strncmp(str, "̵²ÁÃͤÎ", 8)
879                     && object_value(o_ptr) <= 0) str+= 8;
880                 
881                 /*** ¥À¥¤¥¹ÌÜ2 ***/
882                 if (o_ptr->tval != TV_BOW && !strncmp(str, "¥À¥¤¥¹Ìܤΰ㤦", 14))
883                 {
884                         object_kind *k_ptr = &k_info[o_ptr->k_idx];
885                         
886                         if ((o_ptr->dd != k_ptr->dd) || (o_ptr->ds != k_ptr->ds))
887                         {
888                                 str += 14;
889                         }
890                 }
891                 
892                 /*** ¥À¥¤¥¹ÌÜ ***/
893                 if (!strncmp(str, "¥À¥¤¥¹ÌÜ", 8) && isdigit(*(str + 8)) && isdigit(*(str + 9))){
894                         if ( (o_ptr->dd) * (o_ptr->ds) >= (*(str+8)-'0') * 10 + (*(str + 9)-'0')) str+= 10;
895                         if (!strncmp(str, "°Ê¾å¤Î", 6)) str+= 6;
896                 }
897                 
898                 /*** ¾Þ¶â¼ó¤Î»àÂÎ/¹ü ***/
899                 if (!strncmp(str, "¾Þ¶â¼ó¤Î", 8) &&
900                     (o_ptr->tval == TV_CORPSE) &&
901                     object_is_shoukinkubi(o_ptr)) str+= 8;
902                 
903                 /*** ¥æ¥Ë¡¼¥¯¡¦¥â¥ó¥¹¥¿¡¼¤Î»àÂÎ/¹ü ***/
904                 if (!strncmp(str, "¥æ¥Ë¡¼¥¯¡¦¥â¥ó¥¹¥¿¡¼¤Î", 22) &&
905                     ((o_ptr->tval == TV_CORPSE) || (o_ptr->tval == TV_STATUE)) &&
906                     (r_info[o_ptr->pval].flags1 & RF1_UNIQUE)) str+= 22;
907                 
908                 /*** ¿Í´Ö¤Î»àÂÎ/¹ü (for Daemon) ***/
909                 if (!strncmp(str, "¿Í´Ö¤Î", 6) &&
910                     (o_ptr->tval == TV_CORPSE) &&
911                     (strchr("pht", r_info[o_ptr->pval].d_char))) str+= 6;
912                 
913                 /*** º£¤Î¿¦¶È¤Ç»È¤¨¤Ê¤¤ËâË¡½ñ ***/
914                 if (!strncmp(str, "Æɤá¤Ê¤¤", 8) &&
915                     (o_ptr->tval >= TV_LIFE_BOOK) &&
916                     !check_book_realm(o_ptr->tval, o_ptr->sval)) str += 8;
917                 
918                 /*** Âè°ìÎΰè¤ÎËâË¡½ñ ***/
919                 if (!strncmp(str, "Âè°ìÎΰè¤Î", 10) &&
920                     !(p_ptr->pclass == CLASS_SORCERER) &&
921                     !(p_ptr->pclass == CLASS_RED_MAGE) &&
922                     (o_ptr->tval >= TV_LIFE_BOOK) &&
923                     (REALM1_BOOK == o_ptr->tval) ) str += 10;
924                 
925                 /*** ÂèÆóÎΰè¤ÎËâË¡½ñ ***/
926                 if (!strncmp(str, "ÂèÆóÎΰè¤Î", 10) &&
927                     !(p_ptr->pclass == CLASS_SORCERER) &&
928                     !(p_ptr->pclass == CLASS_RED_MAGE) &&
929                     (o_ptr->tval >= TV_LIFE_BOOK) &&
930                     (REALM2_BOOK == o_ptr->tval) ) str += 10;
931                 
932                 /*** nºýÌܤÎËâË¡½ñ ***/
933                 if (!strncmp(str + 1, "ºýÌܤÎ", 6) &&
934                     (o_ptr->tval >= TV_LIFE_BOOK) &&
935                     (*str == '1' + o_ptr->sval) ) str += 6 + 1;
936                 
937                 
938                 /*** ¥¢¥¤¥Æ¥à¤Î¥«¥Æ¥´¥ê»ØÄêͽÌó¸ì ***/
939                 if (!strncmp(str, "¥¢¥¤¥Æ¥à",8)) len = 8;
940                 
941                 else if (!strncmp(str, "¥¢¡¼¥Æ¥£¥Õ¥¡¥¯¥È", 16)){
942                         if (object_known_p(o_ptr)
943                             && (artifact_p(o_ptr) || o_ptr->art_name))
944                                 len = 16;
945                 }
946
947                 else if (!strncmp(str, "Éð´ï", 4)){
948                         switch( o_ptr->tval ){
949                         case TV_BOW:
950                         case TV_HAFTED:
951                         case TV_POLEARM:
952                         case TV_SWORD:
953                         case TV_DIGGING:
954                         {len =  4; break;}
955                         }
956                 }
957                 
958                 else if (!strncmp(str, "Ëɶñ", 4)){
959                         switch( o_ptr->tval ){
960                         case TV_BOOTS:
961                         case TV_GLOVES:
962                         case TV_CLOAK:
963                         case TV_CROWN:
964                         case TV_HELM:
965                         case TV_SHIELD:
966                         case TV_SOFT_ARMOR:
967                         case TV_HARD_ARMOR:
968                         case TV_DRAG_ARMOR:
969                         {len =  4; break;}
970                         }
971                 }
972                 
973                 else if (!strncmp(str, "Ìð", 2)){
974                         switch( o_ptr->tval ){
975                         case TV_SHOT:
976                         case TV_BOLT:
977                         case TV_ARROW:
978                         {len =  2;break;}
979                         }
980                 }
981                 
982                 else if (!strncmp(str, "ËâË¡¥¢¥¤¥Æ¥à", 12)){
983                         switch( o_ptr->tval ){
984                         case TV_SCROLL:
985                         case TV_STAFF:
986                         case TV_WAND:
987                         case TV_ROD:
988                         {len =  12; break;}
989                         }
990                 }
991                 
992                 else if (!strncmp(str, "¸÷¸»", 4)){
993                         switch( o_ptr->tval ){
994                         case TV_LITE:
995                         {len =  4; break;}
996                         }
997                 }
998                 
999                 else if (!strncmp(str, "¤¬¤é¤¯¤¿", 8)){
1000                         switch( o_ptr->tval ){
1001                         case TV_SKELETON:
1002                         case TV_BOTTLE:
1003                         case TV_JUNK:
1004                         case TV_STATUE:
1005                         {len =  8; break;}
1006                         }
1007                 }
1008                 else if (!strncmp(str, "ËâË¡½ñ", 6) &&
1009                          o_ptr->tval >= TV_LIFE_BOOK) len = 6;
1010                 else if (!strncmp(str, "Æß´ï", 4) &&
1011                          o_ptr->tval == TV_HAFTED) len = 4;
1012                 else if (!strncmp(str, "½â", 2) &&
1013                          o_ptr->tval == TV_SHIELD) len = 2;
1014                 else if (!strncmp(str, "µÝ", 2) &&
1015                          o_ptr->tval == TV_BOW) len = 2;
1016                 else if (!strncmp(str, "»ØÎØ", 4) &&
1017                          o_ptr->tval == TV_RING) len = 4;
1018                 else if (!strncmp(str, "¥¢¥ß¥å¥ì¥Ã¥È", 12) &&
1019                          o_ptr->tval == TV_AMULET) len = 12;
1020                 else if (!strncmp(str, "³»", 2) &&
1021                          (o_ptr->tval == TV_DRAG_ARMOR || o_ptr->tval == TV_HARD_ARMOR ||
1022                           o_ptr->tval == TV_SOFT_ARMOR)) len = 2;
1023                 else if (!strncmp(str, "¥¯¥í¡¼¥¯", 8) &&
1024                          o_ptr->tval == TV_CLOAK) len = 8;
1025                 else if (!strncmp(str, "³õ", 2) &&
1026                          (o_ptr->tval == TV_CROWN || o_ptr->tval == TV_HELM)) len = 2;
1027                 else if (!strncmp(str, "äƼê", 4) &&
1028                          o_ptr->tval == TV_GLOVES) len = 4;
1029                 else if (!strncmp(str, "·¤", 2) &&
1030                          o_ptr->tval == TV_BOOTS) len = 2;
1031
1032                 str += len;
1033                 if (*str == 0)
1034                         flag = TRUE;
1035                 else if (*str == ':')
1036                         str += 1;
1037                 else if (*str == kanji_colon[0] && *(str+1) == kanji_colon[1])
1038                         str += 2;
1039                 else if (len)
1040                         continue;
1041 #else
1042 #define NEXT_WORD(len) (void)(str += len, str += (' '==*str)?1:0)
1043
1044                 /*** ¤¹¤Ù¤Æ¤Î... ***/
1045                 if (!strncmp(str, "all", 3)) NEXT_WORD(3);
1046
1047                 /*** ´û¤Ë»ý¤Ã¤Æ¤¤¤ë¥¢¥¤¥Æ¥à ***/
1048                 if (!strncmp(str, "collecting", 10))
1049                 {
1050                         collectable = TRUE;
1051                         NEXT_WORD(10);
1052                 }
1053
1054                 /*** Ì¤´ÕÄê¤Î... ***/
1055                 if (!strncmp(str, "unidentified",12) &&
1056                     !object_known_p(o_ptr) && !( (o_ptr->ident)&IDENT_SENSE)) NEXT_WORD(12);
1057                 
1058                 /*** ´ÕÄêºÑ¤ß¤Î... ***/
1059                 if (!strncmp(str, "identified",10) &&
1060                     object_known_p(o_ptr) ) NEXT_WORD(10);
1061
1062                 /*** *´ÕÄê*ºÑ¤ß¤Î... ***/
1063                 if (!strncmp(str, "*identified*",12) &&
1064                     object_known_p(o_ptr) && (o_ptr->ident & IDENT_MENTAL) ) NEXT_WORD(12);
1065                 
1066                 /*** ÌµÌäÎ... ***/
1067                 if (!strncmp(str, "nameless", 8)
1068                     && (object_known_p(o_ptr)) && !o_ptr->inscription
1069                     && (!o_ptr->name1 && !o_ptr->name2 && !o_ptr->art_name))
1070                 {
1071                         switch (o_ptr->tval)
1072                         {
1073                         case TV_SHOT: case TV_ARROW: case TV_BOLT: case TV_BOW:
1074                         case TV_DIGGING: case TV_HAFTED: case TV_POLEARM: case TV_SWORD: 
1075                         case TV_BOOTS: case TV_GLOVES: case TV_HELM: case TV_CROWN:
1076                         case TV_SHIELD: case TV_CLOAK:
1077                         case TV_SOFT_ARMOR: case TV_HARD_ARMOR: case TV_DRAG_ARMOR:
1078                         case TV_LITE: case TV_AMULET: case TV_RING: case TV_CARD:
1079                                 str += 9;
1080                         }
1081                 }
1082                 
1083                 /*** Ì¤È½ÌÀ¤Î...  ***/
1084                 if (!strncmp(str, "unaware",7) && 
1085                     !object_aware_p(o_ptr)) NEXT_WORD(7);
1086                 
1087                 /*** Ìµ²ÁÃͤÎ... ***/
1088                 if (!strncmp(str, "worthless", 9)
1089                     && object_value(o_ptr) <= 0) NEXT_WORD(9);
1090                 
1091                 /*** ¥À¥¤¥¹ÌÜ2 ***/
1092                 if (o_ptr->tval != TV_BOW && !strncmp(str, "dice boosted", 12))
1093                 {
1094                         object_kind *k_ptr = &k_info[o_ptr->k_idx];                     
1095                         if ((o_ptr->dd != k_ptr->dd) || (o_ptr->ds != k_ptr->ds))
1096                                 str += 13;
1097                 }
1098                 
1099                 /*** ¥À¥¤¥¹ÌÜ ***/
1100                 if (!strncmp(str, "more than ", 10) &&
1101                     !strncmp(str+2+10, " dice ", 6) &&
1102                     isdigit(str[10]) && isdigit(str[11]) &&
1103                     o_ptr->dd * o_ptr->ds >= (str[10]-'0') * 10 + (str[11]-'0'))
1104                         NEXT_WORD(10+2+6);
1105                 
1106                 /*** ¾Þ¶â¼ó¤Î»àÂÎ/¹ü ***/
1107                 if (!strncmp(str, "wanted", 6) &&
1108                     (o_ptr->tval == TV_CORPSE) &&
1109                     object_is_shoukinkubi(o_ptr)) NEXT_WORD(6);
1110                 
1111                 /*** ¥æ¥Ë¡¼¥¯¡¦¥â¥ó¥¹¥¿¡¼¤Î»àÂÎ/¹ü ***/
1112                 if (!strncmp(str, "unique monster's", 16) &&
1113                     ((o_ptr->tval == TV_CORPSE) || (o_ptr->tval == TV_STATUE)) &&
1114                     (r_info[o_ptr->pval].flags1 & RF1_UNIQUE)) NEXT_WORD(16);
1115                 
1116                 /*** ¿Í´Ö¤Î»àÂÎ/¹ü (for Daemon) ***/
1117                 if (!strncmp(str, "human", 5) &&
1118                     (o_ptr->tval == TV_CORPSE) &&
1119                     (strchr("pht", r_info[o_ptr->pval].d_char))) NEXT_WORD(5);
1120                 
1121                 /*** º£¤Î¿¦¶È¤Ç»È¤¨¤Ê¤¤ËâË¡½ñ ***/
1122                 if (!strncmp(str, "unreadable", 10) &&
1123                     (o_ptr->tval >= TV_LIFE_BOOK) &&
1124                     !check_book_realm(o_ptr->tval, o_ptr->sval)) NEXT_WORD(10);
1125                 
1126                 /*** Âè°ìÎΰè¤ÎËâË¡½ñ ***/
1127                 if (!strncmp(str, "first realm's", 13) &&
1128                     !(p_ptr->pclass == CLASS_SORCERER) &&
1129                     !(p_ptr->pclass == CLASS_RED_MAGE) &&
1130                     (o_ptr->tval >= TV_LIFE_BOOK) &&
1131                     (REALM1_BOOK == o_ptr->tval) ) NEXT_WORD(13);
1132                 
1133                 /*** ÂèÆóÎΰè¤ÎËâË¡½ñ ***/
1134                 if (!strncmp(str, "second realm's", 14) &&
1135                     !(p_ptr->pclass == CLASS_SORCERER) &&
1136                     !(p_ptr->pclass == CLASS_RED_MAGE) &&
1137                     (o_ptr->tval >= TV_LIFE_BOOK) &&
1138                     (REALM2_BOOK == o_ptr->tval) ) NEXT_WORD(14);
1139                 
1140                 /*** nºýÌܤÎËâË¡½ñ ***/
1141                 if (!strncmp(str, "first", 5) &&
1142                     (o_ptr->tval >= TV_LIFE_BOOK) &&
1143                     (0 == o_ptr->sval) ) NEXT_WORD(5);
1144                 if (!strncmp(str, "second", 6) &&
1145                     (o_ptr->tval >= TV_LIFE_BOOK) &&
1146                     (1 == o_ptr->sval) ) NEXT_WORD(6);
1147                 if (!strncmp(str, "third", 5) &&
1148                     (o_ptr->tval >= TV_LIFE_BOOK) &&
1149                     (2 == o_ptr->sval) ) NEXT_WORD(5);
1150                 if (!strncmp(str, "fourth", 6) &&
1151                     (o_ptr->tval >= TV_LIFE_BOOK) &&
1152                     (3 == o_ptr->sval) ) NEXT_WORD(6);
1153                 
1154                 /*** ¥¢¥¤¥Æ¥à¤Î¥«¥Æ¥´¥ê»ØÄêͽÌó¸ì ***/
1155                 if (!strncmp(str, "items",5)) len = 5;
1156                 
1157                 else if (!strncmp(str, "artifacts", 9)){
1158                         if (object_known_p(o_ptr)
1159                             && (artifact_p(o_ptr) || o_ptr->art_name))
1160                                 len = 9;
1161                 }
1162
1163                 else if (!strncmp(str, "weapons", 7)){
1164                         switch( o_ptr->tval ){
1165                         case TV_BOW:
1166                         case TV_HAFTED:
1167                         case TV_POLEARM:
1168                         case TV_SWORD:
1169                         case TV_DIGGING:
1170                         {len =  7; break;}
1171                         }
1172                 }
1173                 
1174                 else if (!strncmp(str, "armors", 6)){
1175                         switch( o_ptr->tval ){
1176                         case TV_BOOTS:
1177                         case TV_GLOVES:
1178                         case TV_CLOAK:
1179                         case TV_CROWN:
1180                         case TV_HELM:
1181                         case TV_SHIELD:
1182                         case TV_SOFT_ARMOR:
1183                         case TV_HARD_ARMOR:
1184                         case TV_DRAG_ARMOR:
1185                         {len =  6; break;}
1186                         }
1187                 }
1188                 
1189                 else if (!strncmp(str, "missiles", 8)){
1190                         switch( o_ptr->tval ){
1191                         case TV_SHOT:
1192                         case TV_BOLT:
1193                         case TV_ARROW:
1194                         {len =  8;break;}
1195                         }
1196                 }
1197                 
1198                 else if (!strncmp(str, "magical devices", 15)){
1199                         switch( o_ptr->tval ){
1200                         case TV_SCROLL:
1201                         case TV_STAFF:
1202                         case TV_WAND:
1203                         case TV_ROD:
1204                         {len =  15; break;}
1205                         }
1206                 }
1207                 
1208                 else if (!strncmp(str, "lights", 6)){
1209                         switch( o_ptr->tval ){
1210                         case TV_LITE:
1211                         {len =  6; break;}
1212                         }
1213                 }
1214                 
1215                 else if (!strncmp(str, "junks", 5)){
1216                         switch( o_ptr->tval ){
1217                         case TV_SKELETON:
1218                         case TV_BOTTLE:
1219                         case TV_JUNK:
1220                         case TV_STATUE:
1221                         {len =  5; break;}
1222                         }
1223                 }
1224                 else if (!strncmp(str, "spellbooks", 10) &&
1225                          o_ptr->tval >= TV_LIFE_BOOK) len = 10;
1226                 else if (!strncmp(str, "hafted weapons", 14) &&
1227                          o_ptr->tval == TV_HAFTED) len = 14;
1228                 else if (!strncmp(str, "shields", 7) &&
1229                          o_ptr->tval == TV_SHIELD) len = 7;
1230                 else if (!strncmp(str, "bows", 4) &&
1231                          o_ptr->tval == TV_BOW) len = 4;
1232                 else if (!strncmp(str, "rings", 5) &&
1233                          o_ptr->tval == TV_RING) len = 5;
1234                 else if (!strncmp(str, "amulets", 7) &&
1235                          o_ptr->tval == TV_AMULET) len = 7;
1236                 else if (!strncmp(str, "suits", 5) &&
1237                          (o_ptr->tval == TV_DRAG_ARMOR || o_ptr->tval == TV_HARD_ARMOR ||
1238                           o_ptr->tval == TV_SOFT_ARMOR)) len = 5;
1239                 else if (!strncmp(str, "cloaks", 6) &&
1240                          o_ptr->tval == TV_CLOAK) len = 6;
1241                 else if (!strncmp(str, "helms", 5) &&
1242                          (o_ptr->tval == TV_CROWN || o_ptr->tval == TV_HELM)) len = 5;
1243                 else if (!strncmp(str, "gloves", 6) &&
1244                          o_ptr->tval == TV_GLOVES) len = 6;
1245                 else if (!strncmp(str, "boots", 5) &&
1246                          o_ptr->tval == TV_BOOTS) len = 5;
1247
1248                 str += len;
1249                 if (*str == 0)
1250                         flag = TRUE;
1251                 else if (*str == ':')
1252                         str += 1;
1253                 else if (len)
1254                         continue;
1255 #endif
1256
1257                 if (*str == '^')
1258                 {
1259                         str++;
1260                         if (!strncmp(o_name, str, strlen(str)))
1261                                 flag = TRUE;
1262                 }
1263                 else
1264 #ifdef JP
1265                         if (strstr_j(o_name, str))
1266 #else
1267                         if (strstr(o_name, str))
1268 #endif
1269                 {
1270                         flag = TRUE;
1271                 }
1272
1273                 if (flag)
1274                 {
1275                         int j;
1276                         if (!collectable)
1277                                 return i;
1278                         /* Check if there is a same item */
1279                         for (j = 0; j < INVEN_PACK; j++)
1280                         {
1281                                 if (object_similar(&inventory[j], o_ptr))
1282                                         return i;
1283                         }
1284                 }
1285         }/* for */
1286
1287         return -1;
1288 }
1289
1290
1291 static bool is_autopick2( object_type *o_ptr) {
1292       cptr s;
1293
1294       /* No inscription */
1295       if (!o_ptr->inscription) return (FALSE);
1296
1297       /* Find a '=' */
1298       s = strchr(quark_str(o_ptr->inscription), '=');
1299
1300       /* Process inscription */
1301       while (s)
1302       {
1303               /* Auto-pickup on "=g" */
1304               if (s[1] == 'g') return (TRUE);
1305
1306               /* Find another '=' */
1307               s = strchr(s + 1, '=');
1308       }
1309
1310       /* Don't auto pickup */
1311       return (FALSE);
1312 }
1313
1314 /*
1315  * Automatically destroy items in this grid.
1316  */
1317 static bool is_opt_confirm_destroy(object_type *o_ptr)
1318 {
1319         if (!destroy_items) return FALSE;
1320
1321         /* Known to be worthless? */
1322         if (leave_worth)
1323                 if (object_value(o_ptr) > 0) return FALSE;
1324         
1325         if (leave_equip)
1326                 if ((o_ptr->tval >= TV_SHOT) && (o_ptr->tval <= TV_DRAG_ARMOR)) return FALSE;
1327         
1328         if (leave_chest)
1329                 if ((o_ptr->tval == TV_CHEST) && o_ptr->pval) return FALSE;
1330         
1331         if (leave_wanted)
1332         {
1333                 if (o_ptr->tval == TV_CORPSE
1334                     && object_is_shoukinkubi(o_ptr)) return FALSE;
1335         }
1336         
1337         if (leave_corpse)
1338                 if (o_ptr->tval == TV_CORPSE) return FALSE;
1339         
1340         if (leave_junk)
1341                 if ((o_ptr->tval == TV_SKELETON) || (o_ptr->tval == TV_BOTTLE) || (o_ptr->tval == TV_JUNK) || (o_ptr->tval == TV_STATUE)) return FALSE;
1342         
1343         if (o_ptr->tval == TV_GOLD) return FALSE;
1344         
1345         return TRUE;
1346 }
1347
1348 /*
1349  * Automatically pickup/destroy items in this grid.
1350  */
1351 static void auto_pickup_items(cave_type *c_ptr)
1352 {
1353         s16b this_o_idx, next_o_idx = 0;
1354         s16b inscribe_flags(object_type *o_ptr, cptr out_val);
1355         
1356         char o_name[MAX_NLEN];
1357         int idx;
1358         
1359         /* Scan the pile of objects */
1360         for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
1361         {
1362                 /* Acquire object */
1363                 object_type *o_ptr = &o_list[this_o_idx];
1364                 
1365                 /* Acquire next object */
1366                 next_o_idx = o_ptr->next_o_idx;
1367                 idx = is_autopick(o_ptr);
1368
1369                 if (idx >= 0 && autopick_insc[idx] && !o_ptr->inscription)
1370                         o_ptr->inscription = inscribe_flags(o_ptr, autopick_insc[idx]);
1371
1372                 if (is_autopick2(o_ptr) ||
1373                    (idx >= 0 && (autopick_action[idx] & DO_AUTOPICK)))
1374                 {
1375                         disturb(0,0);
1376
1377                         if (!inven_carry_okay(o_ptr)){
1378                                 /* Describe the object */
1379                                 object_desc(o_name, o_ptr, TRUE, 3);
1380                                 /* Message */
1381 #ifdef JP
1382                                 msg_format("¥¶¥Ã¥¯¤Ë¤Ï%s¤òÆþ¤ì¤ë·ä´Ö¤¬¤Ê¤¤¡£", o_name);
1383 #else
1384                                 msg_format("You have no room for %s.", o_name);
1385 #endif
1386                                 continue;
1387                         }
1388                         py_pickup_aux(this_o_idx);
1389
1390                         continue;
1391                 }
1392                 
1393                 else if ((idx == -1 && is_opt_confirm_destroy(o_ptr)) ||
1394                          (!always_pickup && (idx != -1 && (autopick_action[idx] & DO_AUTODESTROY))))
1395                 {
1396                         disturb(0,0);
1397                         /* Describe the object (with {terrible/special}) */
1398                         object_desc(o_name, o_ptr, TRUE, 3);
1399                         /* Artifact? */
1400                         if (!can_player_destroy_object(o_ptr))
1401                         {
1402                                 /* Message */
1403 #ifdef JP
1404                                 msg_format("%s¤ÏÇ˲õÉÔǽ¤À¡£", o_name);
1405 #else
1406                                 msg_format("You cannot auto-destroy %s.", o_name);
1407 #endif
1408                                 
1409                                 /* Done */
1410                                 continue;
1411                         }
1412                         /* Destroy the item */
1413                         delete_object_idx(this_o_idx);
1414                         
1415                         /* Print a message */
1416 #ifdef JP
1417                         msg_format("%s¤ò¼«Æ°Ç˲õ¤·¤Þ¤¹¡£", o_name);
1418 #else
1419                         msg_format("Auto-destroying %s.", o_name);
1420 #endif
1421                         
1422                         continue;
1423                 }
1424         }
1425 }
1426
1427
1428 /*
1429  * Player "wants" to pick up an object or gold.
1430  * Note that we ONLY handle things that can be picked up.
1431  * See "move_player()" for handling of other things.
1432  */
1433 void carry(int pickup)
1434 {
1435         cave_type *c_ptr = &cave[py][px];
1436
1437         s16b this_o_idx, next_o_idx = 0;
1438
1439         char    o_name[MAX_NLEN];
1440
1441         /* Recenter the map around the player */
1442         verify_panel();
1443
1444         /* Update stuff */
1445         p_ptr->update |= (PU_MONSTERS);
1446
1447         /* Redraw map */
1448         p_ptr->redraw |= (PR_MAP);
1449
1450         /* Window stuff */
1451         p_ptr->window |= (PW_OVERHEAD);
1452
1453         /* Handle stuff */
1454         handle_stuff();
1455
1456         /* Automatically pickup/destroy/inscribe items */
1457         auto_pickup_items(c_ptr);
1458
1459
1460 #ifdef ALLOW_EASY_FLOOR
1461
1462         if (easy_floor)
1463         {
1464                 py_pickup_floor(pickup);
1465                 return;
1466         }
1467
1468 #endif /* ALLOW_EASY_FLOOR */
1469
1470         /* Scan the pile of objects */
1471         for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
1472         {
1473                 object_type *o_ptr;
1474
1475                 /* Acquire object */
1476                 o_ptr = &o_list[this_o_idx];
1477
1478 #ifdef ALLOW_EASY_SENSE /* TNB */
1479
1480                 /* Option: Make item sensing easy */
1481                 if (easy_sense)
1482                 {
1483                         /* Sense the object */
1484                         (void)sense_object(o_ptr);
1485                 }
1486
1487 #endif /* ALLOW_EASY_SENSE -- TNB */
1488
1489                 /* Describe the object */
1490                 object_desc(o_name, o_ptr, TRUE, 3);
1491
1492                 /* Acquire next object */
1493                 next_o_idx = o_ptr->next_o_idx;
1494
1495                 /* Hack -- disturb */
1496                 disturb(0, 0);
1497
1498                 /* Pick up gold */
1499                 if (o_ptr->tval == TV_GOLD)
1500                 {
1501                         int value = (long)o_ptr->pval;
1502
1503                         /* Delete the gold */
1504                         delete_object_idx(this_o_idx);
1505
1506                         /* Message */
1507 #ifdef JP
1508                 msg_format(" $%ld ¤Î²ÁÃͤ¬¤¢¤ë%s¤ò¸«¤Ä¤±¤¿¡£",
1509                            (long)value, o_name);
1510 #else
1511                         msg_format("You collect %ld gold pieces worth of %s.",
1512                                    (long)value, o_name);
1513 #endif
1514
1515
1516                         sound(SOUND_SELL);
1517
1518                         /* Collect the gold */
1519                         p_ptr->au += value;
1520
1521                         /* Redraw gold */
1522                         p_ptr->redraw |= (PR_GOLD);
1523
1524                         /* Window stuff */
1525                         p_ptr->window |= (PW_PLAYER);
1526                 }
1527
1528                 /* Pick up objects */
1529                 else
1530                 {
1531                         /* Describe the object */
1532                         if (!pickup)
1533
1534                         {
1535 #ifdef JP
1536                                 msg_format("%s¤¬¤¢¤ë¡£", o_name);
1537 #else
1538                                 msg_format("You see %s.", o_name);
1539 #endif
1540
1541                         }
1542
1543                         /* Note that the pack is too full */
1544                         else if (!inven_carry_okay(o_ptr))
1545                         {
1546 #ifdef JP
1547                                 msg_format("¥¶¥Ã¥¯¤Ë¤Ï%s¤òÆþ¤ì¤ë·ä´Ö¤¬¤Ê¤¤¡£", o_name);
1548 #else
1549                                 msg_format("You have no room for %s.", o_name);
1550 #endif
1551
1552                         }
1553
1554                         /* Pick up the item (if requested and allowed) */
1555                         else
1556                         {
1557                                 int okay = TRUE;
1558
1559                                 /* Hack -- query every item */
1560                                 if (carry_query_flag)
1561                                 {
1562                                         char out_val[MAX_NLEN+20];
1563 #ifdef JP
1564                                         sprintf(out_val, "%s¤ò½¦¤¤¤Þ¤¹¤«? ", o_name);
1565 #else
1566                                         sprintf(out_val, "Pick up %s? ", o_name);
1567 #endif
1568
1569                                         okay = get_check(out_val);
1570                                 }
1571
1572                                 /* Attempt to pick up an object. */
1573                                 if (okay)
1574                                 {
1575                                         /* Pick up the object */
1576                                         py_pickup_aux(this_o_idx);
1577                                 }
1578                         }
1579                 }
1580         }
1581 }
1582
1583
1584 /*
1585  * Determine if a trap affects the player.
1586  * Always miss 5% of the time, Always hit 5% of the time.
1587  * Otherwise, match trap power against player armor.
1588  */
1589 static int check_hit(int power)
1590 {
1591         int k, ac;
1592
1593         /* Percentile dice */
1594         k = rand_int(100);
1595
1596         /* Hack -- 5% hit, 5% miss */
1597         if (k < 10) return (k < 5);
1598
1599         if (p_ptr->pseikaku == SEIKAKU_NAMAKE)
1600                 if (one_in_(20)) return (FALSE);
1601
1602         /* Paranoia -- No power */
1603         if (power <= 0) return (FALSE);
1604
1605         /* Total armor */
1606         ac = p_ptr->ac + p_ptr->to_a;
1607
1608         /* Power competes against Armor */
1609         if (randint(power) > ((ac * 3) / 4)) return (TRUE);
1610
1611         /* Assume miss */
1612         return (FALSE);
1613 }
1614
1615
1616
1617 /*
1618  * Handle player hitting a real trap
1619  */
1620 static void hit_trap(bool break_trap)
1621 {
1622         int i, num, dam;
1623         int x = px, y = py;
1624
1625         cave_type *c_ptr;
1626
1627 #ifdef JP
1628         cptr            name = "¥È¥é¥Ã¥×";
1629 #else
1630         cptr name = "a trap";
1631 #endif
1632
1633
1634
1635         /* Disturb the player */
1636         disturb(0, 0);
1637
1638         /* Get the cave grid */
1639         c_ptr = &cave[y][x];
1640
1641         /* Analyze XXX XXX XXX */
1642         switch (c_ptr->feat)
1643         {
1644                 case FEAT_TRAP_TRAPDOOR:
1645                 {
1646                         if (p_ptr->ffall)
1647                         {
1648 #ifdef JP
1649                                 msg_print("Í¸Í¤òÈô¤Ó±Û¤¨¤¿¡£");
1650 #else
1651                                 msg_print("You fly over a trap door.");
1652 #endif
1653
1654                         }
1655                         else
1656                         {
1657 #ifdef JP
1658                                 msg_print("Í¸Í¤ËÍî¤Á¤¿¡ª");
1659                                 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
1660                                         msg_print("¤¯¤Ã¤½¡Á¡ª");
1661 #else
1662                                 msg_print("You have fallen through a trap door!");
1663 #endif
1664
1665                                 sound(SOUND_FALL);
1666                                 dam = damroll(2, 8);
1667 #ifdef JP
1668                                 name = "Í¸Í";
1669 #else
1670                                 name = "a trap door";
1671 #endif
1672
1673                                 take_hit(DAMAGE_NOESCAPE, dam, name, -1);
1674
1675                                 /* Still alive and autosave enabled */
1676                                 if (autosave_l && (p_ptr->chp >= 0))
1677                                         do_cmd_save_game(TRUE);
1678
1679 #ifdef JP
1680                                 do_cmd_write_nikki(NIKKI_STAIR, 1, "Í¸Í¤ËÍî¤Á¤¿");
1681 #else
1682                                 do_cmd_write_nikki(NIKKI_STAIR, 1, "You have fallen through a trap door!");
1683 #endif
1684                                 dun_level++;
1685
1686                                 /* Leaving */
1687                                 p_ptr->leaving = TRUE;
1688                         }
1689                         break;
1690                 }
1691
1692                 case FEAT_TRAP_PIT:
1693                 {
1694                         if (p_ptr->ffall)
1695                         {
1696 #ifdef JP
1697                                 msg_print("Í·ê¤òÈô¤Ó±Û¤¨¤¿¡£");
1698 #else
1699                                 msg_print("You fly over a pit trap.");
1700 #endif
1701
1702                         }
1703                         else
1704                         {
1705 #ifdef JP
1706                                 msg_print("Í·ê¤ËÍî¤Á¤Æ¤·¤Þ¤Ã¤¿¡ª");
1707 #else
1708                                 msg_print("You have fallen into a pit!");
1709 #endif
1710
1711                                 dam = damroll(2, 6);
1712 #ifdef JP
1713                                 name = "Í·ê";
1714 #else
1715                                 name = "a pit trap";
1716 #endif
1717
1718                                 take_hit(DAMAGE_NOESCAPE, dam, name, -1);
1719                         }
1720                         break;
1721                 }
1722
1723                 case FEAT_TRAP_SPIKED_PIT:
1724                 {
1725                         if (p_ptr->ffall)
1726                         {
1727 #ifdef JP
1728                                 msg_print("¥È¥²¤Î¤¢¤ëÍ·ê¤òÈô¤Ó±Û¤¨¤¿¡£");
1729 #else
1730                                 msg_print("You fly over a spiked pit.");
1731 #endif
1732
1733                         }
1734                         else
1735                         {
1736 #ifdef JP
1737                         msg_print("¥¹¥Ñ¥¤¥¯¤¬Éߤ«¤ì¤¿Í·ê¤ËÍî¤Á¤Æ¤·¤Þ¤Ã¤¿¡ª");
1738 #else
1739                                 msg_print("You fall into a spiked pit!");
1740 #endif
1741
1742
1743                                 /* Base damage */
1744 #ifdef JP
1745                                 name = "Í·ê";
1746 #else
1747                                 name = "a pit trap";
1748 #endif
1749
1750                                 dam = damroll(2, 6);
1751
1752                                 /* Extra spike damage */
1753                                 if (rand_int(100) < 50)
1754                                 {
1755 #ifdef JP
1756                                         msg_print("¥¹¥Ñ¥¤¥¯¤¬»É¤µ¤Ã¤¿¡ª");
1757 #else
1758                                         msg_print("You are impaled!");
1759 #endif
1760
1761
1762 #ifdef JP
1763                                         name = "¥È¥²¤Î¤¢¤ëÍ·ê";
1764 #else
1765                                         name = "a spiked pit";
1766 #endif
1767
1768                                         dam = dam * 2;
1769                                         (void)set_cut(p_ptr->cut + randint(dam));
1770                                 }
1771
1772                                 /* Take the damage */
1773                                 take_hit(DAMAGE_NOESCAPE, dam, name, -1);
1774                         }
1775                         break;
1776                 }
1777
1778                 case FEAT_TRAP_POISON_PIT:
1779                 {
1780                         if (p_ptr->ffall)
1781                         {
1782 #ifdef JP
1783                                 msg_print("¥È¥²¤Î¤¢¤ëÍ·ê¤òÈô¤Ó±Û¤¨¤¿¡£");
1784 #else
1785                                 msg_print("You fly over a spiked pit.");
1786 #endif
1787
1788                         }
1789                         else
1790                         {
1791 #ifdef JP
1792                         msg_print("¥¹¥Ñ¥¤¥¯¤¬Éߤ«¤ì¤¿Í·ê¤ËÍî¤Á¤Æ¤·¤Þ¤Ã¤¿¡ª");
1793 #else
1794                                 msg_print("You fall into a spiked pit!");
1795 #endif
1796
1797
1798                                 /* Base damage */
1799                                 dam = damroll(2, 6);
1800
1801 #ifdef JP
1802                                 name = "Í·ê";
1803 #else
1804                                 name = "a pit trap";
1805 #endif
1806
1807
1808                                 /* Extra spike damage */
1809                                 if (rand_int(100) < 50)
1810                                 {
1811 #ifdef JP
1812                                         msg_print("ÆǤòÅɤé¤ì¤¿¥¹¥Ñ¥¤¥¯¤¬»É¤µ¤Ã¤¿¡ª");
1813 #else
1814                                         msg_print("You are impaled on poisonous spikes!");
1815 #endif
1816
1817
1818 #ifdef JP
1819                                         name = "¥È¥²¤Î¤¢¤ëÍ·ê";
1820 #else
1821                                         name = "a spiked pit";
1822 #endif
1823
1824
1825                                         dam = dam * 2;
1826                                         (void)set_cut(p_ptr->cut + randint(dam));
1827
1828                                         if (p_ptr->resist_pois || p_ptr->oppose_pois)
1829                                         {
1830 #ifdef JP
1831                                                 msg_print("¤·¤«¤·ÆǤαƶÁ¤Ï¤Ê¤«¤Ã¤¿¡ª");
1832 #else
1833                                                 msg_print("The poison does not affect you!");
1834 #endif
1835
1836                                         }
1837
1838                                         else
1839                                         {
1840                                                 dam = dam * 2;
1841                                                 (void)set_poisoned(p_ptr->poisoned + randint(dam));
1842                                         }
1843                                 }
1844
1845                                 /* Take the damage */
1846                                 take_hit(DAMAGE_NOESCAPE, dam, name, -1);
1847                         }
1848
1849                         break;
1850                 }
1851
1852                 case FEAT_TRAP_TY_CURSE:
1853                 {
1854 #ifdef JP
1855                         msg_print("²¿¤«¤¬¥Ô¥«¥Ã¤È¸÷¤Ã¤¿¡ª");
1856 #else
1857                         msg_print("There is a flash of shimmering light!");
1858 #endif
1859
1860                         c_ptr->info &= ~(CAVE_MARK);
1861                         cave_set_feat(y, x, floor_type[rand_int(100)]);
1862                         num = 2 + randint(3);
1863                         for (i = 0; i < num; i++)
1864                         {
1865                                 (void)summon_specific(0, y, x, dun_level, 0, TRUE, FALSE, FALSE, TRUE, TRUE);
1866                         }
1867
1868                         if (dun_level > randint(100)) /* No nasty effect for low levels */
1869                         {
1870                                 bool stop_ty = FALSE;
1871                                 int count = 0;
1872
1873                                 do
1874                                 {
1875                                         stop_ty = activate_ty_curse(stop_ty, &count);
1876                                 }
1877                                 while (randint(6) == 1);
1878                         }
1879                         break;
1880                 }
1881
1882                 case FEAT_TRAP_TELEPORT:
1883                 {
1884 #ifdef JP
1885                         msg_print("¥Æ¥ì¥Ý¡¼¥È¡¦¥È¥é¥Ã¥×¤Ë¤Ò¤Ã¤«¤«¤Ã¤¿¡ª");
1886 #else
1887                         msg_print("You hit a teleport trap!");
1888 #endif
1889
1890                         teleport_player(100);
1891                         break;
1892                 }
1893
1894                 case FEAT_TRAP_FIRE:
1895                 {
1896 #ifdef JP
1897                         msg_print("±ê¤ËÊñ¤Þ¤ì¤¿¡ª");
1898 #else
1899                         msg_print("You are enveloped in flames!");
1900 #endif
1901
1902                         dam = damroll(4, 6);
1903 #ifdef JP
1904                         fire_dam(dam, "±ê¤Î¥È¥é¥Ã¥×", -1);
1905 #else
1906                         fire_dam(dam, "a fire trap", -1);
1907 #endif
1908
1909                         break;
1910                 }
1911
1912                 case FEAT_TRAP_ACID:
1913                 {
1914 #ifdef JP
1915                         msg_print("»À¤¬¿á¤­¤«¤±¤é¤ì¤¿¡ª");
1916 #else
1917                         msg_print("You are splashed with acid!");
1918 #endif
1919
1920                         dam = damroll(4, 6);
1921 #ifdef JP
1922                         acid_dam(dam, "»À¤Î¥È¥é¥Ã¥×", -1);
1923 #else
1924                         acid_dam(dam, "an acid trap", -1);
1925 #endif
1926
1927                         break;
1928                 }
1929
1930                 case FEAT_TRAP_SLOW:
1931                 {
1932                         if (check_hit(125))
1933                         {
1934 #ifdef JP
1935                                 msg_print("¾®¤µ¤Ê¥À¡¼¥Ä¤¬Èô¤ó¤Ç¤­¤Æ»É¤µ¤Ã¤¿¡ª");
1936 #else
1937                                 msg_print("A small dart hits you!");
1938 #endif
1939
1940                                 dam = damroll(1, 4);
1941                                 take_hit(DAMAGE_ATTACK, dam, name, -1);
1942                                 (void)set_slow(p_ptr->slow + rand_int(20) + 20, FALSE);
1943                         }
1944                         else
1945                         {
1946 #ifdef JP
1947                                 msg_print("¾®¤µ¤Ê¥À¡¼¥Ä¤¬Èô¤ó¤Ç¤­¤¿¡ª¤¬¡¢±¿Îɤ¯Åö¤¿¤é¤Ê¤«¤Ã¤¿¡£");
1948 #else
1949                                 msg_print("A small dart barely misses you.");
1950 #endif
1951
1952                         }
1953                         break;
1954                 }
1955
1956                 case FEAT_TRAP_LOSE_STR:
1957                 {
1958                         if (check_hit(125))
1959                         {
1960 #ifdef JP
1961                                 msg_print("¾®¤µ¤Ê¥À¡¼¥Ä¤¬Èô¤ó¤Ç¤­¤Æ»É¤µ¤Ã¤¿¡ª");
1962 #else
1963                                 msg_print("A small dart hits you!");
1964 #endif
1965
1966                                 dam = damroll(1, 4);
1967 #ifdef JP
1968                                 take_hit(DAMAGE_ATTACK, dam, "¥À¡¼¥Ä¤Îæ«", -1);
1969 #else
1970                                 take_hit(DAMAGE_ATTACK, dam, "a dart trap", -1);
1971 #endif
1972
1973                                 (void)do_dec_stat(A_STR);
1974                         }
1975                         else
1976                         {
1977 #ifdef JP
1978                                 msg_print("¾®¤µ¤Ê¥À¡¼¥Ä¤¬Èô¤ó¤Ç¤­¤¿¡ª¤¬¡¢±¿Îɤ¯Åö¤¿¤é¤Ê¤«¤Ã¤¿¡£");
1979 #else
1980                                 msg_print("A small dart barely misses you.");
1981 #endif
1982
1983                         }
1984                         break;
1985                 }
1986
1987                 case FEAT_TRAP_LOSE_DEX:
1988                 {
1989                         if (check_hit(125))
1990                         {
1991 #ifdef JP
1992                                 msg_print("¾®¤µ¤Ê¥À¡¼¥Ä¤¬Èô¤ó¤Ç¤­¤Æ»É¤µ¤Ã¤¿¡ª");
1993 #else
1994                                 msg_print("A small dart hits you!");
1995 #endif
1996
1997                                 dam = damroll(1, 4);
1998 #ifdef JP
1999                                 take_hit(DAMAGE_ATTACK, dam, "¥À¡¼¥Ä¤Îæ«", -1);
2000 #else
2001                                 take_hit(DAMAGE_ATTACK, dam, "a dart trap", -1);
2002 #endif
2003
2004                                 (void)do_dec_stat(A_DEX);
2005                         }
2006                         else
2007                         {
2008 #ifdef JP
2009                                 msg_print("¾®¤µ¤Ê¥À¡¼¥Ä¤¬Èô¤ó¤Ç¤­¤¿¡ª¤¬¡¢±¿Îɤ¯Åö¤¿¤é¤Ê¤«¤Ã¤¿¡£");
2010 #else
2011                                 msg_print("A small dart barely misses you.");
2012 #endif
2013
2014                         }
2015                         break;
2016                 }
2017
2018                 case FEAT_TRAP_LOSE_CON:
2019                 {
2020                         if (check_hit(125))
2021                         {
2022 #ifdef JP
2023                                 msg_print("¾®¤µ¤Ê¥À¡¼¥Ä¤¬Èô¤ó¤Ç¤­¤Æ»É¤µ¤Ã¤¿¡ª");
2024 #else
2025                                 msg_print("A small dart hits you!");
2026 #endif
2027
2028                                 dam = damroll(1, 4);
2029 #ifdef JP
2030                                 take_hit(DAMAGE_ATTACK, dam, "¥À¡¼¥Ä¤Îæ«", -1);
2031 #else
2032                                 take_hit(DAMAGE_ATTACK, dam, "a dart trap", -1);
2033 #endif
2034
2035                                 (void)do_dec_stat(A_CON);
2036                         }
2037                         else
2038                         {
2039 #ifdef JP
2040                                 msg_print("¾®¤µ¤Ê¥À¡¼¥Ä¤¬Èô¤ó¤Ç¤­¤¿¡ª¤¬¡¢±¿Îɤ¯Åö¤¿¤é¤Ê¤«¤Ã¤¿¡£");
2041 #else
2042                                 msg_print("A small dart barely misses you.");
2043 #endif
2044
2045                         }
2046                         break;
2047                 }
2048
2049                 case FEAT_TRAP_BLIND:
2050                 {
2051 #ifdef JP
2052                         msg_print("¹õ¤¤¥¬¥¹¤ËÊñ¤ß¹þ¤Þ¤ì¤¿¡ª");
2053 #else
2054                         msg_print("A black gas surrounds you!");
2055 #endif
2056
2057                         if (!p_ptr->resist_blind)
2058                         {
2059                                 (void)set_blind(p_ptr->blind + rand_int(50) + 25);
2060                         }
2061                         break;
2062                 }
2063
2064                 case FEAT_TRAP_CONFUSE:
2065                 {
2066 #ifdef JP
2067                         msg_print("¤­¤é¤á¤¯¥¬¥¹¤ËÊñ¤ß¹þ¤Þ¤ì¤¿¡ª");
2068 #else
2069                         msg_print("A gas of scintillating colors surrounds you!");
2070 #endif
2071
2072                         if (!p_ptr->resist_conf)
2073                         {
2074                                 (void)set_confused(p_ptr->confused + rand_int(20) + 10);
2075                         }
2076                         break;
2077                 }
2078
2079                 case FEAT_TRAP_POISON:
2080                 {
2081 #ifdef JP
2082                         msg_print("»É·ãŪ¤ÊÎп§¤Î¥¬¥¹¤ËÊñ¤ß¹þ¤Þ¤ì¤¿¡ª");
2083 #else
2084                         msg_print("A pungent green gas surrounds you!");
2085 #endif
2086
2087                         if (!p_ptr->resist_pois && !p_ptr->oppose_pois)
2088                         {
2089                                 (void)set_poisoned(p_ptr->poisoned + rand_int(20) + 10);
2090                         }
2091                         break;
2092                 }
2093
2094                 case FEAT_TRAP_SLEEP:
2095                 {
2096 #ifdef JP
2097                         msg_print("´ñ̯¤ÊÇò¤¤Ì¸¤ËÊñ¤Þ¤ì¤¿¡ª");
2098 #else
2099                         msg_print("A strange white mist surrounds you!");
2100 #endif
2101
2102                         if (!p_ptr->free_act)
2103                         {
2104 #ifdef JP
2105 msg_print("¤¢¤Ê¤¿¤Ï̲¤ê¤Ë½¢¤¤¤¿¡£");
2106 #else
2107                                 msg_print("You fall asleep.");
2108 #endif
2109
2110
2111                                 if (ironman_nightmare)
2112                                 {
2113 #ifdef JP
2114 msg_print("¿È¤ÎÌÓ¤â¤è¤À¤Ä¸÷·Ê¤¬Æ¬¤ËÉ⤫¤ó¤À¡£");
2115 #else
2116                                         msg_print("A horrible vision enters your mind.");
2117 #endif
2118
2119
2120                                         /* Pick a nightmare */
2121                                         get_mon_num_prep(get_nightmare, NULL);
2122
2123                                         /* Have some nightmares */
2124                                         have_nightmare(get_mon_num(MAX_DEPTH));
2125
2126                                         /* Remove the monster restriction */
2127                                         get_mon_num_prep(NULL, NULL);
2128                                 }
2129                                 (void)set_paralyzed(p_ptr->paralyzed + rand_int(10) + 5);
2130                         }
2131                         break;
2132                 }
2133
2134                 case FEAT_TRAP_TRAPS:
2135                 {
2136 #ifdef JP
2137 msg_print("¤Þ¤Ð¤æ¤¤Á®¸÷¤¬Áö¤Ã¤¿¡ª");
2138 #else
2139                         msg_print("There is a bright flash of light!");
2140 #endif
2141
2142
2143                         /* Destroy this trap */
2144                         cave_set_feat(y, x, floor_type[rand_int(100)]);
2145
2146                         /* Make some new traps */
2147                         project(0, 1, y, x, 0, GF_MAKE_TRAP, PROJECT_HIDE | PROJECT_JUMP | PROJECT_GRID, -1);
2148
2149                         break;
2150                 }
2151         }
2152         if (break_trap && is_trap(c_ptr->feat))
2153         {
2154                 cave_set_feat(y, x, floor_type[rand_int(100)]);
2155 #ifdef JP
2156                 msg_print("¥È¥é¥Ã¥×¤òÊ´ºÕ¤·¤¿¡£");
2157 #else
2158                 msg_print("You destroyed the trap.");
2159 #endif
2160         }
2161 }
2162
2163
2164 void touch_zap_player(monster_type *m_ptr)
2165 {
2166         int aura_damage = 0;
2167         monster_race *r_ptr = &r_info[m_ptr->r_idx];
2168
2169         if (r_ptr->flags2 & RF2_AURA_FIRE)
2170         {
2171                 if (!p_ptr->immune_fire)
2172                 {
2173                         char aura_dam[80];
2174
2175                         aura_damage = damroll(1 + (r_ptr->level / 26), 1 + (r_ptr->level / 17));
2176
2177                         /* Hack -- Get the "died from" name */
2178                         monster_desc(aura_dam, m_ptr, 0x88);
2179
2180 #ifdef JP
2181                         msg_print("ÆÍÁ³¤È¤Æ¤âÇ®¤¯¤Ê¤Ã¤¿¡ª");
2182 #else
2183                         msg_print("You are suddenly very hot!");
2184 #endif
2185
2186
2187                         if (p_ptr->oppose_fire) aura_damage = (aura_damage + 2) / 3;
2188                         if (p_ptr->resist_fire) aura_damage = (aura_damage + 2) / 3;
2189
2190                         take_hit(DAMAGE_NOESCAPE, aura_damage, aura_dam, -1);
2191                         r_ptr->r_flags2 |= RF2_AURA_FIRE;
2192                         handle_stuff();
2193                 }
2194         }
2195
2196         if (r_ptr->flags3 & RF3_AURA_COLD)
2197         {
2198                 if (!p_ptr->immune_cold)
2199                 {
2200                         char aura_dam[80];
2201
2202                         aura_damage = damroll(1 + (r_ptr->level / 26), 1 + (r_ptr->level / 17));
2203
2204                         /* Hack -- Get the "died from" name */
2205                         monster_desc(aura_dam, m_ptr, 0x88);
2206
2207 #ifdef JP
2208                         msg_print("ÆÍÁ³¤È¤Æ¤â´¨¤¯¤Ê¤Ã¤¿¡ª");
2209 #else
2210                         msg_print("You are suddenly very cold!");
2211 #endif
2212
2213
2214                         if (p_ptr->oppose_cold) aura_damage = (aura_damage + 2) / 3;
2215                         if (p_ptr->resist_cold) aura_damage = (aura_damage + 2) / 3;
2216
2217                         take_hit(DAMAGE_NOESCAPE, aura_damage, aura_dam, -1);
2218                         r_ptr->r_flags3 |= RF3_AURA_COLD;
2219                         handle_stuff();
2220                 }
2221         }
2222
2223         if (r_ptr->flags2 & RF2_AURA_ELEC)
2224         {
2225                 if (!p_ptr->immune_elec)
2226                 {
2227                         char aura_dam[80];
2228
2229                         aura_damage = damroll(1 + (r_ptr->level / 26), 1 + (r_ptr->level / 17));
2230
2231                         /* Hack -- Get the "died from" name */
2232                         monster_desc(aura_dam, m_ptr, 0x88);
2233
2234                         if (p_ptr->oppose_elec) aura_damage = (aura_damage + 2) / 3;
2235                         if (p_ptr->resist_elec) aura_damage = (aura_damage + 2) / 3;
2236
2237 #ifdef JP
2238                         msg_print("ÅÅ·â¤ò¤¯¤é¤Ã¤¿¡ª");
2239 #else
2240                         msg_print("You get zapped!");
2241 #endif
2242
2243                         take_hit(DAMAGE_NOESCAPE, aura_damage, aura_dam, -1);
2244                         r_ptr->r_flags2 |= RF2_AURA_ELEC;
2245                         handle_stuff();
2246                 }
2247         }
2248 }
2249
2250
2251 static void natural_attack(s16b m_idx, int attack, bool *fear, bool *mdeath)
2252 {
2253         int             k, bonus, chance;
2254         int             n_weight = 0;
2255         monster_type    *m_ptr = &m_list[m_idx];
2256         monster_race    *r_ptr = &r_info[m_ptr->r_idx];
2257         char            m_name[80];
2258
2259         int             dss, ddd;
2260
2261         char            *atk_desc;
2262
2263         switch (attack)
2264         {
2265                 case MUT2_SCOR_TAIL:
2266                         dss = 3;
2267                         ddd = 7;
2268                         n_weight = 5;
2269 #ifdef JP
2270                         atk_desc = "¿¬Èø";
2271 #else
2272                         atk_desc = "tail";
2273 #endif
2274
2275                         break;
2276                 case MUT2_HORNS:
2277                         dss = 2;
2278                         ddd = 6;
2279                         n_weight = 15;
2280 #ifdef JP
2281                         atk_desc = "³Ñ";
2282 #else
2283                         atk_desc = "horns";
2284 #endif
2285
2286                         break;
2287                 case MUT2_BEAK:
2288                         dss = 2;
2289                         ddd = 4;
2290                         n_weight = 5;
2291 #ifdef JP
2292                         atk_desc = "¥¯¥Á¥Ð¥·";
2293 #else
2294                         atk_desc = "beak";
2295 #endif
2296
2297                         break;
2298                 case MUT2_TRUNK:
2299                         dss = 1;
2300                         ddd = 4;
2301                         n_weight = 35;
2302 #ifdef JP
2303                         atk_desc = "¾Ý¤ÎÉ¡";
2304 #else
2305                         atk_desc = "trunk";
2306 #endif
2307
2308                         break;
2309                 case MUT2_TENTACLES:
2310                         dss = 2;
2311                         ddd = 5;
2312                         n_weight = 5;
2313 #ifdef JP
2314                         atk_desc = "¿¨¼ê";
2315 #else
2316                         atk_desc = "tentacles";
2317 #endif
2318
2319                         break;
2320                 default:
2321                         dss = ddd = n_weight = 1;
2322 #ifdef JP
2323                         atk_desc = "̤ÄêµÁ¤ÎÉô°Ì";
2324 #else
2325                         atk_desc = "undefined body part";
2326 #endif
2327
2328         }
2329
2330         /* Extract monster name (or "it") */
2331         monster_desc(m_name, m_ptr, 0);
2332
2333
2334         /* Calculate the "attack quality" */
2335         bonus = p_ptr->to_h_m;
2336         bonus += (p_ptr->lev * 6 / 5);
2337         chance = (p_ptr->skill_thn + (bonus * BTH_PLUS_ADJ));
2338
2339         /* Test for hit */
2340         if ((!(r_ptr->flags2 & RF2_QUANTUM) || !rand_int(2)) && test_hit_norm(chance, r_ptr->ac, m_ptr->ml))
2341         {
2342                 /* Sound */
2343                 sound(SOUND_HIT);
2344
2345 #ifdef JP
2346                 msg_format("%s¤ò%s¤Ç¹¶·â¤·¤¿¡£", m_name, atk_desc);
2347 #else
2348                 msg_format("You hit %s with your %s.", m_name, atk_desc);
2349 #endif
2350
2351
2352                 k = damroll(ddd, dss);
2353                 k = critical_norm(n_weight, bonus, k, (s16b)bonus, 0);
2354
2355                 /* Apply the player damage bonuses */
2356                 k += p_ptr->to_d_m;
2357
2358                 /* No negative damage */
2359                 if (k < 0) k = 0;
2360
2361                 /* Modify the damage */
2362                 k = mon_damage_mod(m_ptr, k, FALSE);
2363
2364                 /* Complex message */
2365                 if (wizard)
2366                 {
2367 #ifdef JP
2368                                 msg_format("%d/%d ¤Î¥À¥á¡¼¥¸¤òÍ¿¤¨¤¿¡£", k, m_ptr->hp);
2369 #else
2370                         msg_format("You do %d (out of %d) damage.", k, m_ptr->hp);
2371 #endif
2372
2373                 }
2374
2375                 /* Anger the monster */
2376                 if (k > 0) anger_monster(m_ptr);
2377
2378                 /* Damage, check for fear and mdeath */
2379                 switch (attack)
2380                 {
2381                         case MUT2_SCOR_TAIL:
2382                                 project(0, 0, m_ptr->fy, m_ptr->fx, k, GF_POIS, PROJECT_KILL | PROJECT_NO_REF, -1);
2383                                 *mdeath = (m_ptr->r_idx == 0);
2384                                 break;
2385                         case MUT2_HORNS:
2386                                 *mdeath = mon_take_hit(m_idx, k, fear, NULL);
2387                                 break;
2388                         case MUT2_BEAK:
2389                                 *mdeath = mon_take_hit(m_idx, k, fear, NULL);
2390                                 break;
2391                         case MUT2_TRUNK:
2392                                 *mdeath = mon_take_hit(m_idx, k, fear, NULL);
2393                                 break;
2394                         case MUT2_TENTACLES:
2395                                 *mdeath = mon_take_hit(m_idx, k, fear, NULL);
2396                                 break;
2397                         default:
2398                                 *mdeath = mon_take_hit(m_idx, k, fear, NULL);
2399                 }
2400
2401                 touch_zap_player(m_ptr);
2402         }
2403         /* Player misses */
2404         else
2405         {
2406                 /* Sound */
2407                 sound(SOUND_MISS);
2408
2409                 /* Message */
2410 #ifdef JP
2411                         msg_format("¥ß¥¹¡ª %s¤Ë¤«¤ï¤µ¤ì¤¿¡£", m_name);
2412 #else
2413                 msg_format("You miss %s.", m_name);
2414 #endif
2415
2416         }
2417 }
2418
2419
2420
2421 /*
2422  * Player attacks a (poor, defenseless) creature        -RAK-
2423  *
2424  * If no "weapon" is available, then "punch" the monster one time.
2425  */
2426 static void py_attack_aux(int y, int x, bool *fear, bool *mdeath, s16b hand, int mode)
2427 {
2428         int             num = 0, k, bonus, chance, vir;
2429
2430         cave_type       *c_ptr = &cave[y][x];
2431
2432         monster_type    *m_ptr = &m_list[c_ptr->m_idx];
2433         monster_race    *r_ptr = &r_info[m_ptr->r_idx];
2434
2435         object_type     *o_ptr;
2436
2437         char            m_name[80];
2438
2439         bool            success_hit = FALSE;
2440         bool            old_success_hit = FALSE;
2441         bool            backstab = FALSE;
2442         bool            vorpal_cut = FALSE;
2443         int             chaos_effect = 0;
2444         bool            stab_fleeing = FALSE;
2445         bool            fuiuchi = FALSE;
2446         bool            do_quake = FALSE;
2447         bool            drain_msg = TRUE;
2448         int             drain_result = 0, drain_heal = 0;
2449         bool            can_drain = FALSE;
2450         int             num_blow;
2451         int             drain_left = MAX_VAMPIRIC_DRAIN;
2452         u32b            f1, f2, f3; /* A massive hack -- life-draining weapons */
2453         bool            is_human = (r_ptr->d_char == 'p');
2454         bool            is_lowlevel = (r_ptr->level < (p_ptr->lev - 15));
2455         bool            zantetsu_mukou, e_j_mukou;
2456
2457
2458
2459         if (((p_ptr->pclass == CLASS_ROGUE) || (p_ptr->pclass == CLASS_NINJA)) && inventory[INVEN_RARM+hand].tval)
2460         {
2461                 int tmp = p_ptr->lev*8+50;
2462                 if (p_ptr->monlite && (mode != HISSATSU_NYUSIN)) tmp /= 3;
2463                 if (p_ptr->aggravate) tmp /= 2;
2464                 if (r_ptr->level > (p_ptr->lev*p_ptr->lev/20+10)) tmp /= 3;
2465                 if (m_ptr->csleep && m_ptr->ml)
2466                 {
2467                         /* Can't backstab creatures that we can't see, right? */
2468                         backstab = TRUE;
2469                 }
2470                 else if ((p_ptr->special_defense & NINJA_S_STEALTH) && (rand_int(tmp) > (r_ptr->level+20)) && m_ptr->ml)
2471                 {
2472                         fuiuchi = TRUE;
2473                 }
2474                 else if (m_ptr->monfear && m_ptr->ml)
2475                 {
2476                         stab_fleeing = TRUE;
2477                 }
2478         }
2479
2480         if(!buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM))
2481         {
2482                 if ((r_ptr->level + 10) > p_ptr->lev)
2483                 {
2484                         if (skill_exp[GINOU_SUDE] < s_info[p_ptr->pclass].s_max[GINOU_SUDE])
2485                         {
2486                                 if (skill_exp[GINOU_SUDE] < 4000)
2487                                         skill_exp[GINOU_SUDE]+=40;
2488                                 else if((skill_exp[GINOU_SUDE] < 6000))
2489                                         skill_exp[GINOU_SUDE]+=5;
2490                                 else if((skill_exp[GINOU_SUDE] < 7000) && (p_ptr->lev > 19))
2491                                         skill_exp[GINOU_SUDE]+=1;
2492                                 else if((skill_exp[GINOU_SUDE] < 8000) && (p_ptr->lev > 34))
2493                                         if (one_in_(3)) skill_exp[GINOU_SUDE]+=1;
2494                                 p_ptr->update |= (PU_BONUS);
2495                         }
2496                 }
2497         }
2498         else
2499         {
2500                 if ((r_ptr->level + 10) > p_ptr->lev)
2501                 {
2502                         if (weapon_exp[inventory[INVEN_RARM+hand].tval-TV_BOW][inventory[INVEN_RARM+hand].sval] < s_info[p_ptr->pclass].w_max[inventory[INVEN_RARM+hand].tval-TV_BOW][inventory[INVEN_RARM+hand].sval])
2503                         {
2504                                 if (weapon_exp[inventory[INVEN_RARM+hand].tval-TV_BOW][inventory[INVEN_RARM+hand].sval] < 4000)
2505                                         weapon_exp[inventory[INVEN_RARM+hand].tval-TV_BOW][inventory[INVEN_RARM+hand].sval]+=80;
2506                                 else if((weapon_exp[inventory[INVEN_RARM+hand].tval-TV_BOW][inventory[INVEN_RARM+hand].sval] < 6000))
2507                                         weapon_exp[inventory[INVEN_RARM+hand].tval-TV_BOW][inventory[INVEN_RARM+hand].sval]+=10;
2508                                 else if((weapon_exp[inventory[INVEN_RARM+hand].tval-TV_BOW][inventory[INVEN_RARM+hand].sval] < 7000) && (p_ptr->lev > 19))
2509                                         weapon_exp[inventory[INVEN_RARM+hand].tval-TV_BOW][inventory[INVEN_RARM+hand].sval]+=1;
2510                                 else if((weapon_exp[inventory[INVEN_RARM+hand].tval-TV_BOW][inventory[INVEN_RARM+hand].sval] < 8000) && (p_ptr->lev > 34))
2511                                         if (one_in_(2)) weapon_exp[inventory[INVEN_RARM+hand].tval-TV_BOW][inventory[INVEN_RARM+hand].sval]+=1;
2512                                 p_ptr->update |= (PU_BONUS);
2513                         }
2514                 }
2515         }
2516
2517         /* Disturb the monster */
2518         m_ptr->csleep = 0;
2519         if (r_ptr->flags7 & (RF7_HAS_LITE_1 | RF7_HAS_LITE_2))
2520                 p_ptr->update |= (PU_MON_LITE);
2521
2522         /* Extract monster name (or "it") */
2523         monster_desc(m_name, m_ptr, 0);
2524
2525         /* Access the weapon */
2526         o_ptr = &inventory[INVEN_RARM+hand];
2527
2528         /* Calculate the "attack quality" */
2529         bonus = p_ptr->to_h[hand] + o_ptr->to_h;
2530         chance = (p_ptr->skill_thn + (bonus * BTH_PLUS_ADJ));
2531         if (mode == HISSATSU_IAI) chance += 60;
2532         if (p_ptr->special_defense & KATA_KOUKIJIN) chance += 150;
2533
2534         if (p_ptr->sutemi) chance = MAX(chance * 3 / 2, chance + 60);
2535
2536         vir = virtue_number(V_VALOUR);
2537         if (vir)
2538         {
2539                 chance += (p_ptr->virtues[vir - 1]/10);
2540         }
2541
2542         zantetsu_mukou = ((o_ptr->name1 == ART_ZANTETSU) && (r_ptr->d_char == 'j'));
2543         e_j_mukou = ((o_ptr->name1 == ART_EXCALIBUR_J) && (r_ptr->d_char == 'S'));
2544
2545         if ((mode == HISSATSU_KYUSHO) || (mode == HISSATSU_MINEUCHI) || (mode == HISSATSU_3DAN) || (mode == HISSATSU_IAI)) num_blow = 1;
2546         else if (mode == HISSATSU_COLD) num_blow = p_ptr->num_blow[hand]+2;
2547         else num_blow = p_ptr->num_blow[hand];
2548
2549         /* Attack once for each legal blow */
2550         while ((num++ < num_blow) && !death)
2551         {
2552                 if (((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI)) || (mode == HISSATSU_KYUSHO))
2553                 {
2554                         if (p_ptr->migite && p_ptr->hidarite)
2555                         {
2556                                 success_hit = (randint(2) == 1);
2557                         }
2558                         else success_hit = TRUE;
2559                 }
2560                 else if (mode == HISSATSU_MAJIN)
2561                 {
2562                         if (num == 1)
2563                         {
2564                                 if (one_in_(2))
2565                                         success_hit = FALSE;
2566                                 old_success_hit = success_hit;
2567                         }
2568                         else success_hit = old_success_hit;
2569                 }
2570                 else if ((p_ptr->pclass == CLASS_NINJA) && ((backstab || fuiuchi) && !(r_ptr->flags3 & RF3_RES_ALL))) success_hit = TRUE;
2571                 else success_hit = test_hit_norm(chance, r_ptr->ac, m_ptr->ml);
2572
2573                 /* Test for hit */
2574                 if (success_hit)
2575                 {
2576                         /* Sound */
2577                         sound(SOUND_HIT);
2578
2579                         /* Message */
2580                         if (backstab)
2581 #ifdef JP
2582                                 msg_format("¤¢¤Ê¤¿¤ÏÎä¹ó¤Ë¤â̲¤Ã¤Æ¤¤¤ë̵ÎϤÊ%s¤òÆͤ­»É¤·¤¿¡ª",
2583 #else
2584                                 msg_format("You cruelly stab the helpless, sleeping %s!",
2585 #endif
2586
2587                                     m_name);
2588                         else if (fuiuchi)
2589 #ifdef JP
2590                                 msg_format("ÉÔ°Õ¤òÆͤ¤¤Æ%s¤Ë¶¯Îõ¤Ê°ì·â¤ò¶ô¤é¤ï¤»¤¿¡ª",
2591 #else
2592                                 msg_format("You make surprise attack, and hit %s with a powerful blow!",
2593 #endif
2594
2595                                     m_name);
2596                         else if (stab_fleeing)
2597 #ifdef JP
2598                                 msg_format("ƨ¤²¤ë%s¤òÇØÃ椫¤éÆͤ­»É¤·¤¿¡ª",
2599 #else
2600                                 msg_format("You backstab the fleeing %s!",
2601 #endif
2602
2603                                     m_name);
2604                         else
2605                         {
2606                                 if (!(((p_ptr->pclass == CLASS_MONK) || (p_ptr->pclass == CLASS_FORCETRAINER) || (p_ptr->pclass == CLASS_BERSERKER)) && (empty_hands(TRUE) > 1)))
2607 #ifdef JP
2608                         msg_format("%s¤ò¹¶·â¤·¤¿¡£", m_name);
2609 #else
2610                                         msg_format("You hit %s.", m_name);
2611 #endif
2612
2613                         }
2614
2615                         /* Hack -- bare hands do one damage */
2616                         k = 1;
2617
2618                         object_flags(o_ptr, &f1, &f2, &f3);
2619
2620                         /* Select a chaotic effect (50% chance) */
2621                         if ((f1 & TR1_CHAOTIC) && (randint(2) == 1))
2622                         {
2623                                 if (randint(10)==1)
2624                                 chg_virtue(V_CHANCE, 1);
2625
2626                                 if (randint(5) < 3)
2627                                 {
2628                                         /* Vampiric (20%) */
2629                                         chaos_effect = 1;
2630                                 }
2631                                 else if (randint(250) == 1)
2632                                 {
2633                                         /* Quake (0.12%) */
2634                                         chaos_effect = 2;
2635                                 }
2636                                 else if (randint(10) != 1)
2637                                 {
2638                                         /* Confusion (26.892%) */
2639                                         chaos_effect = 3;
2640                                 }
2641                                 else if (randint(2) == 1)
2642                                 {
2643                                         /* Teleport away (1.494%) */
2644                                         chaos_effect = 4;
2645                                 }
2646                                 else
2647                                 {
2648                                         /* Polymorph (1.494%) */
2649                                         chaos_effect = 5;
2650                                 }
2651                         }
2652
2653                         /* Vampiric drain */
2654                         if ((f1 & TR1_VAMPIRIC) || (chaos_effect == 1) || (mode == HISSATSU_DRAIN))
2655                         {
2656                                 /* Only drain "living" monsters */
2657                                 if (monster_living(r_ptr))
2658                                         can_drain = TRUE;
2659                                 else
2660                                         can_drain = FALSE;
2661                         }
2662
2663                         if ((f1 & TR1_VORPAL) && (randint((o_ptr->name1 == ART_VORPAL_BLADE) ? 3 : 6) == 1) && !zantetsu_mukou)
2664                                 vorpal_cut = TRUE;
2665                         else vorpal_cut = FALSE;
2666
2667                         if (((p_ptr->pclass == CLASS_MONK) || (p_ptr->pclass == CLASS_FORCETRAINER) || (p_ptr->pclass == CLASS_BERSERKER)) && (empty_hands(TRUE) > 1))
2668                         {
2669                                 int special_effect = 0, stun_effect = 0, times = 0, max_times;
2670                                 int min_level = 1;
2671                                 martial_arts *ma_ptr = &ma_blows[0], *old_ptr = &ma_blows[0];
2672                                 int resist_stun = 0;
2673
2674                                 if (r_ptr->flags1 & RF1_UNIQUE) resist_stun += 88;
2675                                 if (r_ptr->flags3 & RF3_NO_STUN) resist_stun += 66;
2676                                 if (r_ptr->flags3 & RF3_NO_CONF) resist_stun += 33;
2677                                 if (r_ptr->flags3 & RF3_NO_SLEEP) resist_stun += 33;
2678                                 if ((r_ptr->flags3 & RF3_UNDEAD) || (r_ptr->flags3 & RF3_NONLIVING))
2679                                         resist_stun += 66;
2680
2681                                 if (p_ptr->special_defense & KAMAE_BYAKKO)
2682                                         max_times = (p_ptr->lev < 3 ? 1 : p_ptr->lev / 3);
2683                                 else if (p_ptr->special_defense & KAMAE_SUZAKU)
2684                                         max_times = 1;
2685                                 else if (p_ptr->special_defense & KAMAE_GENBU)
2686                                         max_times = 1;
2687                                 else
2688                                         max_times = (p_ptr->lev < 7 ? 1 : p_ptr->lev / 7);
2689                                 /* Attempt 'times' */
2690                                 for (times = 0; times < max_times; times++)
2691                                 {
2692                                         do
2693                                         {
2694                                                 ma_ptr = &ma_blows[rand_int(MAX_MA)];
2695                                                 if ((p_ptr->pclass == CLASS_FORCETRAINER) && (ma_ptr->min_level > 1)) min_level = ma_ptr->min_level + 3;
2696                                                 else min_level = ma_ptr->min_level;
2697                                         }
2698                                         while ((min_level > p_ptr->lev) ||
2699                                                (randint(p_ptr->lev) < ma_ptr->chance));
2700
2701                                         /* keep the highest level attack available we found */
2702                                         if ((ma_ptr->min_level > old_ptr->min_level) &&
2703                                             !p_ptr->stun && !p_ptr->confused)
2704                                         {
2705                                                 old_ptr = ma_ptr;
2706
2707                                                 if (wizard && cheat_xtra)
2708                                                 {
2709 #ifdef JP
2710                                                         msg_print("¹¶·â¤òºÆÁªÂò¤·¤Þ¤·¤¿¡£");
2711 #else
2712                                                         msg_print("Attack re-selected.");
2713 #endif
2714
2715                                                 }
2716                                         }
2717                                         else
2718                                         {
2719                                                 ma_ptr = old_ptr;
2720                                         }
2721                                 }
2722
2723                                 if (p_ptr->pclass == CLASS_FORCETRAINER) min_level = MAX(1, ma_ptr->min_level - 3);
2724                                 else min_level = ma_ptr->min_level;
2725                                 k = damroll(ma_ptr->dd, ma_ptr->ds);
2726                                 if (p_ptr->special_attack & ATTACK_SUIKEN) k *= 2;
2727
2728                                 if (ma_ptr->effect == MA_KNEE)
2729                                 {
2730                                         if (r_ptr->flags1 & RF1_MALE)
2731                                         {
2732 #ifdef JP
2733                                                 msg_format("%s¤Ë¶âŪɨ½³¤ê¤ò¤¯¤é¤ï¤·¤¿¡ª", m_name);
2734 #else
2735                                                 msg_format("You hit %s in the groin with your knee!", m_name);
2736 #endif
2737
2738                                                 sound(SOUND_PAIN);
2739                                                 special_effect = MA_KNEE;
2740                                         }
2741                                         else
2742                                                 msg_format(ma_ptr->desc, m_name);
2743                                 }
2744
2745                                 else if (ma_ptr->effect == MA_SLOW)
2746                                 {
2747                                         if (!((r_ptr->flags1 & RF1_NEVER_MOVE) ||
2748                                             strchr("~#{}.UjmeEv$,DdsbBFIJQSXclnw!=?", r_ptr->d_char)))
2749                                         {
2750 #ifdef JP
2751                                                 msg_format("%s¤Î­¼ó¤Ë´ØÀá½³¤ê¤ò¤¯¤é¤ï¤·¤¿¡ª", m_name);
2752 #else
2753                                                 msg_format("You kick %s in the ankle.", m_name);
2754 #endif
2755
2756                                                 special_effect = MA_SLOW;
2757                                         }
2758                                         else msg_format(ma_ptr->desc, m_name);
2759                                 }
2760                                 else
2761                                 {
2762                                         if (ma_ptr->effect)
2763                                         {
2764                                                 stun_effect = (ma_ptr->effect / 2) + randint(ma_ptr->effect / 2);
2765                                         }
2766
2767                                         msg_format(ma_ptr->desc, m_name);
2768                                 }
2769
2770                                 k = critical_norm(p_ptr->lev * randint((p_ptr->special_defense & KAMAE_SUZAKU) ? 5 : 10), min_level, k, p_ptr->to_h[0], 0);
2771
2772                                 if ((special_effect == MA_KNEE) && ((k + p_ptr->to_d[hand]) < m_ptr->hp))
2773                                 {
2774 #ifdef JP
2775                                         msg_format("%^s¤Ï¶ìÄˤˤ¦¤á¤¤¤Æ¤¤¤ë¡ª", m_name);
2776 #else
2777                                         msg_format("%^s moans in agony!", m_name);
2778 #endif
2779
2780                                         stun_effect = 7 + randint(13);
2781                                         resist_stun /= 3;
2782                                 }
2783
2784                                 else if ((special_effect == MA_SLOW) && ((k + p_ptr->to_d[hand]) < m_ptr->hp))
2785                                 {
2786                                         if (!(r_ptr->flags1 & RF1_UNIQUE) &&
2787                                             (randint(p_ptr->lev) > r_ptr->level) &&
2788                                             m_ptr->mspeed > 60)
2789                                         {
2790 #ifdef JP
2791                                                 msg_format("%^s¤Ï­¤ò¤Ò¤­¤º¤ê»Ï¤á¤¿¡£", m_name);
2792 #else
2793                                                 msg_format("%^s starts limping slower.", m_name);
2794 #endif
2795
2796                                                 m_ptr->mspeed -= 10;
2797                                         }
2798                                 }
2799
2800                                 if (stun_effect && ((k + p_ptr->to_d[hand]) < m_ptr->hp))
2801                                 {
2802                                         if (p_ptr->lev > randint(r_ptr->level + resist_stun + 10))
2803                                         {
2804                                                 if (m_ptr->stunned)
2805 #ifdef JP
2806                                                         msg_format("%^s¤Ï¤µ¤é¤Ë¥Õ¥é¥Õ¥é¤Ë¤Ê¤Ã¤¿¡£", m_name);
2807 #else
2808                                                         msg_format("%^s is more stunned.", m_name);
2809 #endif
2810
2811                                                 else
2812 #ifdef JP
2813                                                         msg_format("%^s¤Ï¥Õ¥é¥Õ¥é¤Ë¤Ê¤Ã¤¿¡£", m_name);
2814 #else
2815                                                         msg_format("%^s is stunned.", m_name);
2816 #endif
2817
2818
2819                                                 m_ptr->stunned += stun_effect;
2820                                         }
2821                                 }
2822                         }
2823
2824                         /* Handle normal weapon */
2825                         else if (o_ptr->k_idx)
2826                         {
2827                                 k = damroll(o_ptr->dd, o_ptr->ds);
2828                                 if (p_ptr->riding)
2829                                 {
2830                                         if((o_ptr->tval == TV_POLEARM) && ((o_ptr->sval == SV_LANCE) || (o_ptr->sval == SV_HEAVY_LANCE)))
2831                                         {
2832                                                 k += damroll(2, o_ptr->ds);
2833                                         }
2834                                 }
2835
2836                                 k = tot_dam_aux(o_ptr, k, m_ptr, mode);
2837
2838                                 if (backstab)
2839                                 {
2840                                         k *= (3 + (p_ptr->lev / 20));
2841                                 }
2842                                 else if (fuiuchi)
2843                                 {
2844                                         k = k*(5+(p_ptr->lev*2/25))/2;
2845                                 }
2846                                 else if (stab_fleeing)
2847                                 {
2848                                         k = (3 * k) / 2;
2849                                 }
2850
2851                                 if ((p_ptr->impact[hand] && ((k > 50) || randint(7) == 1)) ||
2852                                          (chaos_effect == 2) || (mode == HISSATSU_QUAKE))
2853                                 {
2854                                         do_quake = TRUE;
2855                                 }
2856
2857                                 if ((!(o_ptr->tval == TV_SWORD) || !(o_ptr->sval == SV_DOKUBARI)) && !(mode == HISSATSU_KYUSHO))
2858                                         k = critical_norm(o_ptr->weight, o_ptr->to_h, k, p_ptr->to_h[hand], mode);
2859
2860                                 drain_result = k;
2861
2862                                 if (vorpal_cut)
2863                                 {
2864                                         int mult = 2;
2865
2866                                         int inc_chance = (o_ptr->name1 == ART_VORPAL_BLADE) ? 2 : 4;
2867
2868                                         if ((o_ptr->name1 == ART_CHAINSWORD) && (randint(2) != 1))
2869                                         {
2870                                                 char chainsword_noise[1024];
2871 #ifdef JP
2872        if (!get_rnd_line("chainswd_j.txt", 0, chainsword_noise))
2873 #else
2874                                                 if (!get_rnd_line("chainswd.txt", 0, chainsword_noise))
2875 #endif
2876
2877                                                 {
2878                                                         msg_print(chainsword_noise);
2879                                                 }
2880                                         }
2881
2882                                         if (o_ptr->name1 == ART_VORPAL_BLADE)
2883                                         {
2884 #ifdef JP
2885                                                 msg_print("Ìܤˤâ»ß¤Þ¤é¤Ì¥Ü¡¼¥Ñ¥ë¡¦¥Ö¥ì¡¼¥É¡¢¼êÏ£¤ÎÁá¶È¡ª");
2886 #else
2887                                                 msg_print("Your Vorpal Blade goes snicker-snack!");
2888 #endif
2889
2890                                         }
2891                                         else
2892                                         {
2893 #ifdef JP
2894                                                 msg_format("%s¤ò¥°¥Ã¥µ¥êÀÚ¤êÎö¤¤¤¿¡ª", m_name);
2895 #else
2896                                                 msg_format("Your weapon cuts deep into %s!", m_name);
2897 #endif
2898
2899                                         }
2900
2901                                         /* Try to increase the damage */
2902                                         while (one_in_(inc_chance))
2903                                         {
2904                                                 mult++;
2905                                         }
2906
2907                                         k *= mult;
2908
2909                                         /* Ouch! */
2910                                         if (((r_ptr->flags3 & RF3_RES_ALL) ? k/100 : k) > m_ptr->hp)
2911                                         {
2912 #ifdef JP
2913                                                 msg_format("%s¤ò¿¿¤ÃÆó¤Ä¤Ë¤·¤¿¡ª", m_name);
2914 #else
2915                                                 msg_format("You cut %s in half!", m_name);
2916 #endif
2917
2918                                         }
2919                                         else
2920                                         {
2921                                                 switch(mult)
2922                                                 {
2923 #ifdef JP
2924 case 2: msg_format("%s¤ò»Â¤Ã¤¿¡ª", m_name);             break;
2925 #else
2926                                                         case 2: msg_format("You gouge %s!", m_name);            break;
2927 #endif
2928
2929 #ifdef JP
2930 case 3: msg_format("%s¤ò¤Ö¤Ã¤¿»Â¤Ã¤¿¡ª", m_name);                       break;
2931 #else
2932                                                         case 3: msg_format("You maim %s!", m_name);                     break;
2933 #endif
2934
2935 #ifdef JP
2936 case 4: msg_format("%s¤ò¥á¥Ã¥¿»Â¤ê¤Ë¤·¤¿¡ª", m_name);           break;
2937 #else
2938                                                         case 4: msg_format("You carve %s!", m_name);            break;
2939 #endif
2940
2941 #ifdef JP
2942 case 5: msg_format("%s¤ò¥á¥Ã¥¿¥á¥¿¤Ë»Â¤Ã¤¿¡ª", m_name);         break;
2943 #else
2944                                                         case 5: msg_format("You cleave %s!", m_name);           break;
2945 #endif
2946
2947 #ifdef JP
2948 case 6: msg_format("%s¤ò»É¿È¤Ë¤·¤¿¡ª", m_name);         break;
2949 #else
2950                                                         case 6: msg_format("You smite %s!", m_name);            break;
2951 #endif
2952
2953 #ifdef JP
2954 case 7: msg_format("%s¤ò»Â¤Ã¤Æ»Â¤Ã¤Æ»Â¤ê¤Þ¤¯¤Ã¤¿¡ª", m_name);   break;
2955 #else
2956                                                         case 7: msg_format("You eviscerate %s!", m_name);       break;
2957 #endif
2958
2959 #ifdef JP
2960 default:        msg_format("%s¤òºÙÀÚ¤ì¤Ë¤·¤¿¡ª", m_name);               break;
2961 #else
2962                                                         default:        msg_format("You shred %s!", m_name);            break;
2963 #endif
2964
2965                                                 }
2966                                         }
2967                                         drain_result = drain_result * 3 / 2;
2968                                 }
2969
2970                                 k += o_ptr->to_d;
2971                                 drain_result += o_ptr->to_d;
2972                         }
2973
2974                         /* Apply the player damage bonuses */
2975                         k += p_ptr->to_d[hand];
2976                         drain_result += p_ptr->to_d[hand];
2977
2978                         if ((mode == HISSATSU_SUTEMI) || (mode == HISSATSU_3DAN)) k *= 2;
2979                         if ((mode == HISSATSU_SEKIRYUKA) && (r_ptr->flags3 & (RF3_UNDEAD | RF3_DEMON | RF3_NONLIVING))) k = 0;
2980                         if ((mode == HISSATSU_SEKIRYUKA) && !p_ptr->cut) k /= 2;
2981
2982                         /* No negative damage */
2983                         if (k < 0) k = 0;
2984
2985                         if ((mode == HISSATSU_ZANMA) && !((r_ptr->flags3 & (RF3_DEMON | RF3_UNDEAD | RF3_NONLIVING)) && (r_ptr->flags3 & RF3_EVIL)))
2986                         {
2987                                 k = 0;
2988                         }
2989
2990                         if (zantetsu_mukou)
2991                         {
2992 #ifdef JP
2993                                 msg_print("¤³¤ó¤ÊÆð¤é¤«¤¤¤â¤Î¤ÏÀÚ¤ì¤ó¡ª");
2994 #else
2995                                 msg_print("You cannot cut such a elastic thing!");
2996 #endif
2997                                 k = 0;
2998                         }
2999
3000                         if (e_j_mukou)
3001                         {
3002 #ifdef JP
3003                                 msg_print("ÃØéá¤Ï¶ì¼ê¤À¡ª");
3004 #else
3005                                 msg_print("Spiders are difficult for you to deal with!");
3006 #endif
3007                                 k /= 2;
3008                         }
3009
3010                         if (mode == HISSATSU_MINEUCHI)
3011                         {
3012                                 int tmp = (10 + randint(15) + p_ptr->lev / 5);
3013
3014                                 k = 0;
3015                                 anger_monster(m_ptr);
3016
3017                                 if (!(r_ptr->flags3 & (RF3_NO_STUN)))
3018                                 {
3019                                         /* Get stunned */
3020                                         if (m_ptr->stunned)
3021                                         {
3022 #ifdef JP
3023 msg_format("%s¤Ï¤Ò¤É¤¯¤â¤¦¤í¤¦¤È¤·¤¿¡£", m_name);
3024 #else
3025                                                 msg_format("%s is more dazed.", m_name);
3026 #endif
3027
3028                                                 tmp /= 2;
3029                                         }
3030                                         else
3031                                         {
3032 #ifdef JP
3033 msg_format("%s ¤Ï¤â¤¦¤í¤¦¤È¤·¤¿¡£", m_name);
3034 #else
3035                                                 msg_format("%s is dazed.", m_name);
3036 #endif
3037                                         }
3038
3039                                         /* Apply stun */
3040                                         m_ptr->stunned = (tmp < 200) ? tmp : 200;
3041                                 }
3042                                 else
3043                                 {
3044 #ifdef JP
3045 msg_format("%s ¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡£", m_name);
3046 #else
3047                                                 msg_format("%s is not effected.", m_name);
3048 #endif
3049                                 }
3050                         }
3051
3052                         /* Modify the damage */
3053                         k = mon_damage_mod(m_ptr, k, (bool)(((o_ptr->tval == TV_POLEARM) && (o_ptr->sval == SV_DEATH_SCYTHE)) || ((p_ptr->pclass == CLASS_BERSERKER) && one_in_(2))));
3054                         if (((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI)) || (mode == HISSATSU_KYUSHO))
3055                         {
3056                                 if ((randint(randint(r_ptr->level/7)+5) == 1) && !(r_ptr->flags1 & RF1_UNIQUE) && !(r_ptr->flags7 & RF7_UNIQUE2))
3057                                 {
3058                                         k = m_ptr->hp + 1;
3059 #ifdef JP
3060 msg_format("%s¤ÎµÞ½ê¤òÆͤ­»É¤·¤¿¡ª", m_name);
3061 #else
3062                                         msg_format("You hit %s on a fatal spot!", m_name);
3063 #endif
3064                                 }
3065                                 else k = 1;
3066                         }
3067                         else if ((p_ptr->pclass == CLASS_NINJA) && (!p_ptr->icky_wield[hand]) && ((p_ptr->cur_lite <= 0) || one_in_(7)))
3068                         {
3069                                 int maxhp = maxroll(r_ptr->hdice, r_ptr->hside);
3070                                 if (one_in_(backstab ? 13 : (stab_fleeing || fuiuchi) ? 15 : 27))
3071                                 {
3072                                         k *= 5;
3073                                         drain_result *= 2;
3074 #ifdef JP
3075 msg_format("¿Ï¤¬%s¤Ë¿¼¡¹¤ÈÆͤ­»É¤µ¤Ã¤¿¡ª", m_name);
3076 #else
3077                                         msg_format("You critically injured %s!", m_name);
3078 #endif
3079                                 }
3080                                 else if (((m_ptr->hp < maxhp/2) && one_in_((p_ptr->num_blow[0]+p_ptr->num_blow[1]+1)*10)) || (((one_in_(666)) || ((backstab || fuiuchi) && one_in_(11))) && !(r_ptr->flags1 & RF1_UNIQUE) && !(r_ptr->flags7 & RF7_UNIQUE2)))
3081                                 {
3082                                         if ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_UNIQUE2) || (m_ptr->hp >= maxhp/2))
3083                                         {
3084                                                 k = MAX(k*5, m_ptr->hp/2);
3085                                                 drain_result *= 2;
3086 #ifdef JP
3087 msg_format("%s¤ËÃ×Ì¿½ý¤òÉé¤ï¤»¤¿¡ª", m_name);
3088 #else
3089                                         msg_format("You fatally injured %s!", m_name);
3090 #endif
3091                                         }
3092                                         else
3093                                         {
3094                                                 k = m_ptr->hp + 1;
3095 #ifdef JP
3096 msg_format("¿Ï¤¬%s¤ÎµÞ½ê¤ò´Ó¤¤¤¿¡ª", m_name);
3097 #else
3098                                         msg_format("You hit %s on a fatal spot!", m_name);
3099 #endif
3100                                         }
3101                                 }
3102                         }
3103
3104                         /* Complex message */
3105                         if (wizard || cheat_xtra)
3106                         {
3107 #ifdef JP
3108                                 msg_format("%d/%d ¤Î¥À¥á¡¼¥¸¤òÍ¿¤¨¤¿¡£", k, m_ptr->hp);
3109 #else
3110                                 msg_format("You do %d (out of %d) damage.", k, m_ptr->hp);
3111 #endif
3112
3113                         }
3114
3115                         if (k <= 0) can_drain = FALSE;
3116
3117                         if (drain_result > m_ptr->hp)
3118                                 drain_result = m_ptr->hp;
3119
3120                         /* Damage, check for fear and death */
3121                         if (mon_take_hit(c_ptr->m_idx, k, fear, NULL))
3122                         {
3123                                 *mdeath = TRUE;
3124                                 if ((p_ptr->pclass == CLASS_BERSERKER) && energy_use)
3125                                 {
3126                                         if (p_ptr->migite && p_ptr->hidarite)
3127                                         {
3128                                                 if (hand) energy_use = energy_use*3/5+energy_use*num*2/(p_ptr->num_blow[hand]*5);
3129                                                 else energy_use = energy_use*num*3/(p_ptr->num_blow[hand]*5);
3130                                         }
3131                                         else
3132                                         {
3133                                                 energy_use = energy_use*num/p_ptr->num_blow[hand];
3134                                         }
3135                                 }
3136                                 if ((o_ptr->name1 == ART_ZANTETSU) && is_lowlevel)
3137 #ifdef JP
3138                                         msg_print("¤Þ¤¿¤Ä¤Þ¤é¤Ì¤â¤Î¤ò»Â¤Ã¤Æ¤·¤Þ¤Ã¤¿¡¥¡¥¡¥");
3139 #else
3140                                         msg_print("Sign..Another trifling thing I've cut....");
3141 #endif
3142                                 break;
3143                         }
3144
3145                         /* Anger the monster */
3146                         if (k > 0) anger_monster(m_ptr);
3147
3148                         touch_zap_player(m_ptr);
3149
3150                         /* Are we draining it?  A little note: If the monster is
3151                         dead, the drain does not work... */
3152
3153                         if (can_drain && (drain_result > 0))
3154                         {
3155                                 if (o_ptr->name1 == ART_MURAMASA)
3156                                 {
3157                                         if (is_human)
3158                                         {
3159                                                 int to_h = o_ptr->to_h;
3160                                                 int to_d = o_ptr->to_d;
3161                                                 int i, flag;
3162
3163                                                 flag = 1;
3164                                                 for (i = 0; i < to_h + 3; i++) if (one_in_(4)) flag = 0;
3165                                                 if (flag) to_h++;
3166
3167                                                 flag = 1;
3168                                                 for (i = 0; i < to_d + 3; i++) if (one_in_(4)) flag = 0;
3169                                                 if (flag) to_d++;
3170
3171                                                 if (o_ptr->to_h != to_h || o_ptr->to_d != to_d)
3172                                                 {
3173 #ifdef JP
3174                                                         msg_print("ÍÅÅá¤Ï·ì¤òµÛ¤Ã¤Æ¶¯¤¯¤Ê¤Ã¤¿¡ª");
3175 #else
3176                                                         msg_print("Muramasa sucked blood, and became more powerful!");
3177 #endif
3178                                                         o_ptr->to_h = to_h;
3179                                                         o_ptr->to_d = to_d;
3180                                                 }
3181                                         }
3182                                 }
3183                                 else
3184                                 {
3185                                         if (drain_result > 5) /* Did we really hurt it? */
3186                                         {
3187                                                 drain_heal = damroll(2, drain_result / 6);
3188
3189                                                 if (cheat_xtra)
3190                                                 {
3191 #ifdef JP
3192                                                         msg_format("Draining left: %d", drain_left);
3193 #else
3194                                                         msg_format("Draining left: %d", drain_left);
3195 #endif
3196
3197                                                 }
3198
3199                                                 if (drain_left)
3200                                                 {
3201                                                         if (drain_heal < drain_left)
3202                                                         {
3203                                                                 drain_left -= drain_heal;
3204                                                         }
3205                                                         else
3206                                                         {
3207                                                                 drain_heal = drain_left;
3208                                                                 drain_left = 0;
3209                                                         }
3210
3211                                                         if (drain_msg)
3212                                                         {
3213 #ifdef JP
3214                                                                 msg_format("¿Ï¤¬%s¤«¤éÀ¸Ì¿ÎϤòµÛ¤¤¼è¤Ã¤¿¡ª", m_name);
3215 #else
3216                                                                 msg_format("Your weapon drains life from %s!", m_name);
3217 #endif
3218
3219                                                                 drain_msg = FALSE;
3220                                                         }
3221
3222                                                         drain_heal = (drain_heal * mutant_regenerate_mod) / 100;
3223
3224                                                         hp_player(drain_heal);
3225                                                         /* We get to keep some of it! */
3226                                                 }
3227                                         }
3228                                 }
3229                                 m_ptr->maxhp -= (k+7)/8;
3230                                 if (m_ptr->hp > m_ptr->maxhp) m_ptr->hp = m_ptr->maxhp;
3231 #ifdef JP
3232                                 msg_format("%s¤Ï¼å¤¯¤Ê¤Ã¤¿¤è¤¦¤À¡£", m_name);
3233 #else
3234                                 msg_format("%^s seems weakened.", m_name);
3235 #endif
3236                         }
3237                         can_drain = FALSE;
3238                         drain_result = 0;
3239
3240                         /* Confusion attack */
3241                         if ((p_ptr->special_attack & ATTACK_CONFUSE) || (chaos_effect == 3) || (mode == HISSATSU_CONF))
3242                         {
3243                                 /* Cancel glowing hands */
3244                                 if (p_ptr->special_attack & ATTACK_CONFUSE)
3245                                 {
3246                                         p_ptr->special_attack &= ~(ATTACK_CONFUSE);
3247 #ifdef JP
3248                                         msg_print("¼ê¤Îµ±¤­¤¬¤Ê¤¯¤Ê¤Ã¤¿¡£");
3249 #else
3250                                         msg_print("Your hands stop glowing.");
3251 #endif
3252                                         p_ptr->redraw |= (PR_STATUS);
3253
3254                                 }
3255
3256                                 /* Confuse the monster */
3257                                 if (r_ptr->flags3 & RF3_NO_CONF)
3258                                 {
3259                                         if (m_ptr->ml)
3260                                         {
3261                                                 r_ptr->r_flags3 |= RF3_NO_CONF;
3262                                         }
3263
3264 #ifdef JP
3265                                         msg_format("%^s¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡£", m_name);
3266 #else
3267                                         msg_format("%^s is unaffected.", m_name);
3268 #endif
3269
3270                                 }
3271                                 else if (rand_int(100) < r_ptr->level)
3272                                 {
3273 #ifdef JP
3274                                         msg_format("%^s¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡£", m_name);
3275 #else
3276                                         msg_format("%^s is unaffected.", m_name);
3277 #endif
3278
3279                                 }
3280                                 else
3281                                 {
3282 #ifdef JP
3283                                         msg_format("%^s¤Ïº®Í𤷤¿¤è¤¦¤À¡£", m_name);
3284 #else
3285                                         msg_format("%^s appears confused.", m_name);
3286 #endif
3287
3288                                         m_ptr->confused += 10 + rand_int(p_ptr->lev) / 5;
3289                                 }
3290                         }
3291
3292                         else if (chaos_effect == 4)
3293                         {
3294                                 bool resists_tele = FALSE;
3295
3296                                 if (r_ptr->flags3 & RF3_RES_TELE)
3297                                 {
3298                                         if (r_ptr->flags1 & RF1_UNIQUE)
3299                                         {
3300                                                 if (m_ptr->ml) r_ptr->r_flags3 |= RF3_RES_TELE;
3301 #ifdef JP
3302                                                 msg_format("%^s¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡£", m_name);
3303 #else
3304                                                 msg_format("%^s is unaffected!", m_name);
3305 #endif
3306
3307                                                 resists_tele = TRUE;
3308                                         }
3309                                         else if (r_ptr->level > randint(100))
3310                                         {
3311                                                 if (m_ptr->ml) r_ptr->r_flags3 |= RF3_RES_TELE;
3312 #ifdef JP
3313                                                 msg_format("%^s¤ÏÄñ¹³ÎϤò»ý¤Ã¤Æ¤¤¤ë¡ª", m_name);
3314 #else
3315                                                 msg_format("%^s resists!", m_name);
3316 #endif
3317
3318                                                 resists_tele = TRUE;
3319                                         }
3320                                 }
3321
3322                                 if (!resists_tele)
3323                                 {
3324 #ifdef JP
3325                                         msg_format("%^s¤Ï¾Ã¤¨¤¿¡ª", m_name);
3326 #else
3327                                         msg_format("%^s disappears!", m_name);
3328 #endif
3329
3330                                         teleport_away(c_ptr->m_idx, 50, FALSE);
3331                                         num = p_ptr->num_blow[hand] + 1; /* Can't hit it anymore! */
3332                                         *mdeath = TRUE;
3333                                 }
3334                         }
3335
3336                         else if ((chaos_effect == 5) && cave_floor_bold(y, x) &&
3337                                  (randint(90) > r_ptr->level))
3338                         {
3339                                 if (!(r_ptr->flags1 & RF1_UNIQUE) &&
3340                                     !(r_ptr->flags4 & RF4_BR_CHAO) &&
3341                                     !(r_ptr->flags1 & RF1_QUESTOR))
3342                                 {
3343                                         if (polymorph_monster(y, x))
3344                                         {
3345 #ifdef JP
3346                                                 msg_format("%^s¤ÏÊѲ½¤·¤¿¡ª", m_name);
3347 #else
3348                                                 msg_format("%^s changes!", m_name);
3349 #endif
3350
3351
3352                                                 /* Hack -- Get new monster */
3353                                                 m_ptr = &m_list[c_ptr->m_idx];
3354
3355                                                 /* Oops, we need a different name... */
3356                                                 monster_desc(m_name, m_ptr, 0);
3357
3358                                                 /* Hack -- Get new race */
3359                                                 r_ptr = &r_info[m_ptr->r_idx];
3360
3361                                                 *fear = FALSE;
3362                                         }
3363                                         else
3364                                         {
3365 #ifdef JP
3366                                         msg_format("%^s¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡£", m_name);
3367 #else
3368                                                 msg_format("%^s is unaffected.", m_name);
3369 #endif
3370
3371                                         }
3372                                 }
3373                         }
3374                         else if (o_ptr->name1 == ART_G_HAMMER)
3375                         {
3376                                 monster_type *m_ptr = &m_list[c_ptr->m_idx];
3377
3378                                 if (m_ptr->hold_o_idx)
3379                                 {
3380                                         object_type *q_ptr = &o_list[m_ptr->hold_o_idx];
3381                                         char o_name[MAX_NLEN];
3382
3383                                         object_desc(o_name, q_ptr, TRUE, 0);
3384                                         q_ptr->held_m_idx = 0;
3385                                         q_ptr->marked = FALSE;
3386                                         m_ptr->hold_o_idx = q_ptr->next_o_idx;
3387                                         q_ptr->next_o_idx = 0;
3388 #ifdef JP
3389                                         msg_format("%s¤òÃ¥¤Ã¤¿¡£", o_name);
3390 #else
3391                                         msg_format("You snatched %s.", o_name);
3392 #endif
3393                                         inven_carry(q_ptr);
3394                                 }
3395                         }
3396                 }
3397
3398                 /* Player misses */
3399                 else
3400                 {
3401                         backstab = FALSE; /* Clumsy! */
3402                         fuiuchi = FALSE; /* Clumsy! */
3403
3404                         if ((o_ptr->tval == TV_POLEARM) && (o_ptr->sval == SV_DEATH_SCYTHE) && (randint(3) == 1))
3405                         {
3406                                 u32b f1, f2, f3;
3407
3408                                 /* Sound */
3409                                 sound(SOUND_HIT);
3410
3411                                 /* Message */
3412 #ifdef JP
3413                                 msg_format("¥ß¥¹¡ª %s¤Ë¤«¤ï¤µ¤ì¤¿¡£", m_name);
3414 #else
3415                                 msg_format("You miss %s.", m_name);
3416 #endif
3417                                 /* Message */
3418 #ifdef JP
3419                                 msg_print("¿¶¤ê²ó¤·¤¿Âç³ù¤¬¼«Ê¬¼«¿È¤ËÊ֤äƤ­¤¿¡ª");
3420 #else
3421                                 msg_print("Your scythe returns to you!");
3422 #endif
3423
3424                                 /* Extract the flags */
3425                                 object_flags(o_ptr, &f1, &f2, &f3);
3426
3427                                 k = damroll(o_ptr->dd, o_ptr->ds);
3428                                 {
3429                                         int mult;
3430                                         switch (p_ptr->mimic_form)
3431                                         {
3432                                         case MIMIC_NONE:
3433                                                 switch (p_ptr->prace)
3434                                                 {
3435                                                         case RACE_YEEK:
3436                                                         case RACE_KLACKON:
3437                                                         mult = 2;break;
3438                                                         case RACE_HALF_ORC:
3439                                                         case RACE_HALF_TROLL:
3440                                                         case RACE_HALF_OGRE:
3441                                                         case RACE_HALF_GIANT:
3442                                                         case RACE_HALF_TITAN:
3443                                                         case RACE_CYCLOPS:
3444                                                         case RACE_IMP:
3445                                                         case RACE_GOLEM:
3446                                                         case RACE_SKELETON:
3447                                                         case RACE_ZOMBIE:
3448                                                         case RACE_VAMPIRE:
3449                                                         case RACE_SPECTRE:
3450                                                         case RACE_DEMON:
3451                                                                 mult = 3;break;
3452                                                         case RACE_DRACONIAN:
3453                                                                 mult = 5;break;
3454                                                         default:
3455                                                                 mult = 1;break;
3456                                                 }
3457                                                 break;
3458                                         case MIMIC_DEMON:
3459                                         case MIMIC_DEMON_LORD:
3460                                         case MIMIC_VAMPIRE:
3461                                                 mult = 3;break;
3462                                         default:
3463                                                 mult = 1;break;
3464                                         }
3465
3466                                         if (p_ptr->align < 0 && mult < 2)
3467                                                 mult = 2;
3468                                         if (!(p_ptr->resist_acid || p_ptr->oppose_acid) && (mult < 3))
3469                                                 mult = mult * 5 / 2;
3470                                         if (!(p_ptr->resist_elec || p_ptr->oppose_elec) && (mult < 3))
3471                                                 mult = mult * 5 / 2;
3472                                         if (!(p_ptr->resist_fire || p_ptr->oppose_fire) && (mult < 3))
3473                                                 mult = mult * 5 / 2;
3474                                         if (!(p_ptr->resist_cold || p_ptr->oppose_cold) && (mult < 3))
3475                                                 mult = mult * 5 / 2;
3476                                         if (!(p_ptr->resist_pois || p_ptr->oppose_pois) && (mult < 3))
3477                                                 mult = mult * 5 / 2;
3478
3479                                         if ((p_ptr->pclass != CLASS_SAMURAI) && (f1 & TR1_FORCE_WEPON) && (p_ptr->csp > (p_ptr->msp / 30)))
3480                                         {
3481                                                 p_ptr->csp -= (1+(p_ptr->msp / 30));
3482                                                 p_ptr->redraw |= (PR_MANA);
3483                                                 mult = mult * 7 / 2;
3484                                         }
3485                                         k *= mult;
3486                                 }
3487
3488                                 k = critical_norm(o_ptr->weight, o_ptr->to_h, k, p_ptr->to_h[hand], mode);
3489                                 if (randint(6) == 1)
3490                                 {
3491                                         int mult = 2;
3492 #ifdef JP
3493                                         msg_format("¥°¥Ã¥µ¥êÀÚ¤êÎö¤«¤ì¤¿¡ª");
3494 #else
3495                                         msg_format("Your weapon cuts deep into yourself!");
3496 #endif
3497                                         /* Try to increase the damage */
3498                                         while (one_in_(4))
3499                                         {
3500                                                 mult++;
3501                                         }
3502
3503                                         k *= mult;
3504                                 }
3505                                 k += (p_ptr->to_d[hand] + o_ptr->to_d);
3506
3507 #ifdef JP
3508                                 take_hit(DAMAGE_FORCE, k, "»à¤ÎÂç³ù", -1);
3509 #else
3510                                 take_hit(DAMAGE_FORCE, k, "Death scythe", -1);
3511 #endif
3512
3513                                 redraw_stuff();
3514                         }
3515                         else
3516                         {
3517                                 /* Sound */
3518                                 sound(SOUND_MISS);
3519
3520                                 /* Message */
3521 #ifdef JP
3522                                 msg_format("¥ß¥¹¡ª %s¤Ë¤«¤ï¤µ¤ì¤¿¡£", m_name);
3523 #else
3524                                 msg_format("You miss %s.", m_name);
3525 #endif
3526                         }
3527                 }
3528                 backstab = FALSE;
3529                 fuiuchi = FALSE;
3530         }
3531
3532
3533         if (drain_left != MAX_VAMPIRIC_DRAIN)
3534         {
3535                 if (randint(4)==1)
3536                 {
3537                         chg_virtue(V_UNLIFE, 1);
3538                 }
3539         }
3540         /* Mega-Hack -- apply earthquake brand */
3541         if (do_quake)
3542         {
3543                 earthquake(py, px, 10);
3544                 if (!cave[y][x].m_idx) *mdeath = TRUE;
3545         }
3546 }
3547
3548 bool py_attack(int y, int x, int mode)
3549 {
3550         bool            fear = FALSE;
3551         bool            mdeath = FALSE;
3552         bool            stormbringer = FALSE;
3553
3554         cave_type       *c_ptr = &cave[y][x];
3555         monster_type    *m_ptr = &m_list[c_ptr->m_idx];
3556         char            m_name[80];
3557
3558         /* Disturb the player */
3559         disturb(0, 0);
3560
3561         energy_use = 100;
3562
3563         if (m_ptr->csleep) /* It is not honorable etc to attack helpless victims */
3564         {
3565                 if (!(r_info[m_ptr->r_idx].flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_COMPASSION, -1);
3566                 if (!(r_info[m_ptr->r_idx].flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(V_HONOUR, -1);
3567         }
3568
3569         /* Extract monster name (or "it") */
3570         monster_desc(m_name, m_ptr, 0);
3571
3572         /* Auto-Recall if possible and visible */
3573         if (m_ptr->ml) monster_race_track((bool)(m_ptr->mflag2 & MFLAG_KAGE), m_ptr->r_idx);
3574
3575         /* Track a new monster */
3576         if (m_ptr->ml) health_track(c_ptr->m_idx);
3577
3578         if ((r_info[m_ptr->r_idx].flags1 & RF1_FEMALE) &&
3579             !(p_ptr->stun || p_ptr->confused || p_ptr->image || !m_ptr->ml))
3580         {
3581                 if ((inventory[INVEN_RARM].name1 == ART_ZANTETSU) || (inventory[INVEN_LARM].name1 == ART_ZANTETSU))
3582                 {
3583 #ifdef JP
3584                         msg_print("ÀÛ¼Ô¡¢¤ª¤Ê¤´¤Ï»Â¤ì¤Ì¡ª");
3585 #else
3586                         msg_print("I can not attack women!");
3587 #endif
3588                         return FALSE;
3589                 }
3590         }
3591
3592         if (d_info[dungeon_type].flags1 & DF1_NO_MELEE)
3593         {
3594 #ifdef JP
3595                 msg_print("¤Ê¤¼¤«¹¶·â¤¹¤ë¤³¤È¤¬¤Ç¤­¤Ê¤¤¡£");
3596 #else
3597                 msg_print("Something prevent you from attacking.");
3598 #endif
3599                 return FALSE;
3600         }
3601
3602         /* Stop if friendly */
3603         if (!is_hostile(m_ptr) &&
3604             !(p_ptr->stun || p_ptr->confused || p_ptr->image ||
3605             p_ptr->shero || !m_ptr->ml))
3606         {
3607                 if (inventory[INVEN_RARM].art_name)
3608                 {
3609                         if (inventory[INVEN_RARM].name1 == ART_STORMBRINGER) stormbringer = TRUE;
3610                 }
3611                 if (inventory[INVEN_LARM].art_name)
3612                 {
3613                         if (inventory[INVEN_LARM].name1 == ART_STORMBRINGER) stormbringer = TRUE;
3614                 }
3615                 if (stormbringer)
3616                 {
3617 #ifdef JP
3618                         msg_format("¹õ¤¤¿Ï¤Ï¶¯ÍߤË%s¤ò¹¶·â¤·¤¿¡ª", m_name);
3619 #else
3620                         msg_format("Your black blade greedily attacks %s!", m_name);
3621 #endif
3622                         chg_virtue(V_INDIVIDUALISM, 1);
3623                         chg_virtue(V_HONOUR, -1);
3624                         chg_virtue(V_JUSTICE, -1);
3625                         chg_virtue(V_COMPASSION, -1);
3626                 }
3627                 else if (p_ptr->pclass != CLASS_BERSERKER)
3628                 {
3629 #ifdef JP
3630                         if (get_check("ËÜÅö¤Ë¹¶·â¤·¤Þ¤¹¤«¡©"))
3631 #else
3632                         if (get_check("Really hit it? "))
3633 #endif
3634                         {
3635                                 chg_virtue(V_INDIVIDUALISM, 1);
3636                                 chg_virtue(V_HONOUR, -1);
3637                                 chg_virtue(V_JUSTICE, -1);
3638                                 chg_virtue(V_COMPASSION, -1);
3639                         }
3640                         else
3641                         {
3642 #ifdef JP
3643                                 msg_format("%s¤ò¹¶·â¤¹¤ë¤Î¤ò»ß¤á¤¿¡£", m_name);
3644 #else
3645                                 msg_format("You stop to avoid hitting %s.", m_name);
3646 #endif
3647                         return FALSE;
3648                         }
3649                 }
3650         }
3651
3652
3653         /* Handle player fear */
3654         if (p_ptr->afraid)
3655         {
3656                 /* Message */
3657                 if (m_ptr->ml)
3658 #ifdef JP
3659                 msg_format("¶²¤¯¤Æ%s¤ò¹¶·â¤Ç¤­¤Ê¤¤¡ª", m_name);
3660 #else
3661                         msg_format("You are too afraid to attack %s!", m_name);
3662 #endif
3663
3664                 else
3665 #ifdef JP
3666                         msg_format ("¤½¤Ã¤Á¤Ë¤Ï²¿¤«¶²¤¤¤â¤Î¤¬¤¤¤ë¡ª");
3667 #else
3668                         msg_format ("There is something scary in your way!");
3669 #endif
3670
3671                 /* Disturb the monster */
3672                 m_ptr->csleep = 0;
3673                 p_ptr->update |= (PU_MON_LITE);
3674
3675                 /* Done */
3676                 return FALSE;
3677         }
3678
3679         if (p_ptr->migite && p_ptr->hidarite)
3680         {
3681                 if ((skill_exp[GINOU_NITOURYU] < s_info[p_ptr->pclass].s_max[GINOU_NITOURYU]) && ((skill_exp[GINOU_NITOURYU] - 1000) / 200 < r_info[m_ptr->r_idx].level))
3682                 {
3683                         if (skill_exp[GINOU_NITOURYU] < 4000)
3684                                 skill_exp[GINOU_NITOURYU]+=80;
3685                         else if(skill_exp[GINOU_NITOURYU] < 6000)
3686                                 skill_exp[GINOU_NITOURYU]+=4;
3687                         else if(skill_exp[GINOU_NITOURYU] < 7000)
3688                                 skill_exp[GINOU_NITOURYU]+=1;
3689                         else if(skill_exp[GINOU_NITOURYU] < 8000)
3690                                 if (one_in_(3)) skill_exp[GINOU_NITOURYU]+=1;
3691                         p_ptr->update |= (PU_BONUS);
3692                 }
3693         }
3694
3695         if (p_ptr->riding)
3696         {
3697                 int ridinglevel = r_info[m_list[p_ptr->riding].r_idx].level;
3698                 if ((skill_exp[GINOU_RIDING] < s_info[p_ptr->pclass].s_max[GINOU_RIDING]) && ((skill_exp[GINOU_RIDING] - 1000) / 200 < r_info[m_ptr->r_idx].level) && (skill_exp[GINOU_RIDING]/100 - 2000 < ridinglevel))
3699                         skill_exp[GINOU_RIDING]++;
3700                 if ((skill_exp[GINOU_RIDING] < s_info[p_ptr->pclass].s_max[GINOU_RIDING]) && (skill_exp[GINOU_RIDING]/100 < ridinglevel))
3701                 {
3702                         if (ridinglevel*100 > (skill_exp[GINOU_RIDING] + 1500))
3703                                 skill_exp[GINOU_RIDING] += (1+(ridinglevel - skill_exp[GINOU_RIDING]/100 - 15));
3704                         else skill_exp[GINOU_RIDING]++;
3705                 }
3706                 p_ptr->update |= (PU_BONUS);
3707         }
3708
3709         riding_t_m_idx = c_ptr->m_idx;
3710         if (p_ptr->migite) py_attack_aux(y, x, &fear, &mdeath, 0, mode);
3711         if (p_ptr->hidarite && !mdeath) py_attack_aux(y, x, &fear, &mdeath, 1, mode);
3712
3713         /* Mutations which yield extra 'natural' attacks */
3714         if (!mdeath)
3715         {
3716                 if ((p_ptr->muta2 & MUT2_HORNS) && !mdeath)
3717                         natural_attack(c_ptr->m_idx, MUT2_HORNS, &fear, &mdeath);
3718                 if ((p_ptr->muta2 & MUT2_BEAK) && !mdeath)
3719                         natural_attack(c_ptr->m_idx, MUT2_BEAK, &fear, &mdeath);
3720                 if ((p_ptr->muta2 & MUT2_SCOR_TAIL) && !mdeath)
3721                         natural_attack(c_ptr->m_idx, MUT2_SCOR_TAIL, &fear, &mdeath);
3722                 if ((p_ptr->muta2 & MUT2_TRUNK) && !mdeath)
3723                         natural_attack(c_ptr->m_idx, MUT2_TRUNK, &fear, &mdeath);
3724                 if ((p_ptr->muta2 & MUT2_TENTACLES) && !mdeath)
3725                         natural_attack(c_ptr->m_idx, MUT2_TENTACLES, &fear, &mdeath);
3726         }
3727
3728         /* Hack -- delay fear messages */
3729         if (fear && m_ptr->ml && !mdeath)
3730         {
3731                 /* Sound */
3732                 sound(SOUND_FLEE);
3733
3734                 /* Message */
3735 #ifdef JP
3736                 msg_format("%^s¤Ï¶²Éݤ·¤Æƨ¤²½Ð¤·¤¿¡ª", m_name);
3737 #else
3738                 msg_format("%^s flees in terror!", m_name);
3739 #endif
3740
3741         }
3742
3743         if ((p_ptr->special_defense & KATA_IAI) && ((mode != HISSATSU_IAI) || mdeath))
3744         {
3745                 set_action(ACTION_NONE);
3746         }
3747
3748         return mdeath;
3749 }
3750
3751
3752 static bool pattern_seq(int c_y, int c_x, int n_y, int n_x)
3753 {
3754         if (!pattern_tile(c_y, c_x) && !pattern_tile(n_y, n_x))
3755                 return TRUE;
3756
3757         if (cave[n_y][n_x].feat == FEAT_PATTERN_START)
3758         {
3759                 if (!pattern_tile(c_y, c_x) &&
3760                     !p_ptr->confused && !p_ptr->stun && !p_ptr->image)
3761                 {
3762 #ifdef JP
3763                         if (get_check("¥Ñ¥¿¡¼¥ó¤Î¾å¤òÊ⤭»Ï¤á¤ë¤È¡¢Á´¤Æ¤òÊ⤫¤Ê¤±¤ì¤Ð¤Ê¤ê¤Þ¤»¤ó¡£¤¤¤¤¤Ç¤¹¤«¡©"))
3764 #else
3765                         if (get_check("If you start walking the Pattern, you must walk the whole way. Ok? "))
3766 #endif
3767
3768                                 return TRUE;
3769                         else
3770                                 return FALSE;
3771                 }
3772                 else
3773                         return TRUE;
3774         }
3775         else if ((cave[n_y][n_x].feat == FEAT_PATTERN_OLD) ||
3776                  (cave[n_y][n_x].feat == FEAT_PATTERN_END) ||
3777                  (cave[n_y][n_x].feat == FEAT_PATTERN_XTRA2))
3778         {
3779                 if (pattern_tile(c_y, c_x))
3780                 {
3781                         return TRUE;
3782                 }
3783                 else
3784                 {
3785 #ifdef JP
3786                         msg_print("¥Ñ¥¿¡¼¥ó¤Î¾å¤òÊ⤯¤Ë¤Ï¥¹¥¿¡¼¥ÈÃÏÅÀ¤«¤éÊ⤭»Ï¤á¤Ê¤¯¤Æ¤Ï¤Ê¤ê¤Þ¤»¤ó¡£");
3787 #else
3788                         msg_print("You must start walking the Pattern from the startpoint.");
3789 #endif
3790
3791                         return FALSE;
3792                 }
3793         }
3794         else if ((cave[n_y][n_x].feat == FEAT_PATTERN_XTRA1) ||
3795                  (cave[c_y][c_x].feat == FEAT_PATTERN_XTRA1))
3796         {
3797                 return TRUE;
3798         }
3799         else if (cave[c_y][c_x].feat == FEAT_PATTERN_START)
3800         {
3801                 if (pattern_tile(n_y, n_x))
3802                         return TRUE;
3803                 else
3804                 {
3805 #ifdef JP
3806                         msg_print("¥Ñ¥¿¡¼¥ó¤Î¾å¤ÏÀµ¤·¤¤½ç½ø¤ÇÊ⤫¤Í¤Ð¤Ê¤ê¤Þ¤»¤ó¡£");
3807 #else
3808                         msg_print("You must walk the Pattern in correct order.");
3809 #endif
3810
3811                         return FALSE;
3812                 }
3813         }
3814         else if ((cave[c_y][c_x].feat == FEAT_PATTERN_OLD) ||
3815                  (cave[c_y][c_x].feat == FEAT_PATTERN_END) ||
3816                  (cave[c_y][c_x].feat == FEAT_PATTERN_XTRA2))
3817         {
3818                 if (!pattern_tile(n_y, n_x))
3819                 {
3820 #ifdef JP
3821                         msg_print("¥Ñ¥¿¡¼¥ó¤òƧ¤ß³°¤·¤Æ¤Ï¤¤¤±¤Þ¤»¤ó¡£");
3822 #else
3823                         msg_print("You may not step off from the Pattern.");
3824 #endif
3825
3826                         return FALSE;
3827                 }
3828                 else
3829                 {
3830                         return TRUE;
3831                 }
3832         }
3833         else
3834         {
3835                 if (!pattern_tile(c_y, c_x))
3836                 {
3837 #ifdef JP
3838                         msg_print("¥Ñ¥¿¡¼¥ó¤Î¾å¤òÊ⤯¤Ë¤Ï¥¹¥¿¡¼¥ÈÃÏÅÀ¤«¤éÊ⤭»Ï¤á¤Ê¤¯¤Æ¤Ï¤Ê¤ê¤Þ¤»¤ó¡£");
3839 #else
3840                         msg_print("You must start walking the Pattern from the startpoint.");
3841 #endif
3842
3843                         return FALSE;
3844                 }
3845                 else
3846                 {
3847                         byte ok_move = FEAT_PATTERN_START;
3848                         switch (cave[c_y][c_x].feat)
3849                         {
3850                                 case FEAT_PATTERN_1:
3851                                         ok_move = FEAT_PATTERN_2;
3852                                         break;
3853                                 case FEAT_PATTERN_2:
3854                                         ok_move = FEAT_PATTERN_3;
3855                                         break;
3856                                 case FEAT_PATTERN_3:
3857                                         ok_move = FEAT_PATTERN_4;
3858                                         break;
3859                                 case FEAT_PATTERN_4:
3860                                         ok_move = FEAT_PATTERN_1;
3861                                         break;
3862                                 default:
3863                                         if (wizard)
3864 #ifdef JP
3865                                                 msg_format("¤ª¤«¤·¤Ê¥Ñ¥¿¡¼¥óÊâ¹Ô¡¢%d¡£", cave[c_y][c_x]);
3866 #else
3867                                                 msg_format("Funny Pattern walking, %d.", cave[c_y][c_x]);
3868 #endif
3869
3870                                         return TRUE; /* Goof-up */
3871                         }
3872
3873                         if ((cave[n_y][n_x].feat == ok_move) ||
3874                             (cave[n_y][n_x].feat == cave[c_y][c_x].feat))
3875                                 return TRUE;
3876                         else
3877                         {
3878                                 if (!pattern_tile(n_y, n_x))
3879 #ifdef JP
3880                                         msg_print("¥Ñ¥¿¡¼¥ó¤òƧ¤ß³°¤·¤Æ¤Ï¤¤¤±¤Þ¤»¤ó¡£");
3881 #else
3882                                         msg_print("You may not step off from the Pattern.");
3883 #endif
3884
3885                                 else
3886 #ifdef JP
3887                                         msg_print("¥Ñ¥¿¡¼¥ó¤Î¾å¤ÏÀµ¤·¤¤½ç½ø¤ÇÊ⤫¤Í¤Ð¤Ê¤ê¤Þ¤»¤ó¡£");
3888 #else
3889                                         msg_print("You must walk the Pattern in correct order.");
3890 #endif
3891
3892
3893                                 return FALSE;
3894                         }
3895                 }
3896         }
3897 }
3898
3899
3900
3901 bool player_can_enter(byte feature)
3902 {
3903         bool pass_wall;
3904
3905         /* Player can not walk through "walls" unless in Shadow Form */
3906         if (p_ptr->wraith_form || p_ptr->pass_wall || p_ptr->kabenuke)
3907                 pass_wall = TRUE;
3908         else
3909                 pass_wall = FALSE;
3910
3911         switch (feature)
3912         {
3913                 case FEAT_DEEP_WATER:
3914                 case FEAT_SHAL_LAVA:
3915                 case FEAT_DEEP_LAVA:
3916                         return (TRUE);
3917
3918                 case FEAT_DARK_PIT:
3919                 {
3920                         if (p_ptr->ffall)
3921                                 return (TRUE);
3922                         else
3923                                 return (FALSE);
3924                 }
3925
3926                 case FEAT_TREES:
3927                 {
3928                         return (TRUE);
3929                 }
3930
3931                 case FEAT_RUBBLE:
3932                 case FEAT_MAGMA:
3933                 case FEAT_QUARTZ:
3934                 case FEAT_MAGMA_H:
3935                 case FEAT_QUARTZ_H:
3936                 case FEAT_MAGMA_K:
3937                 case FEAT_QUARTZ_K:
3938                 case FEAT_WALL_EXTRA:
3939                 case FEAT_WALL_INNER:
3940                 case FEAT_WALL_OUTER:
3941                 case FEAT_WALL_SOLID:
3942                 {
3943                         return (pass_wall);
3944                 }
3945
3946                 case FEAT_MOUNTAIN:
3947                 {
3948                         return (!dun_level && p_ptr->ffall);
3949                 }
3950                 case FEAT_PERM_EXTRA:
3951                 case FEAT_PERM_INNER:
3952                 case FEAT_PERM_OUTER:
3953                 case FEAT_PERM_SOLID:
3954                 {
3955                         return (FALSE);
3956                 }
3957         }
3958
3959         return (TRUE);
3960 }
3961
3962
3963 /*
3964  * Move player in the given direction, with the given "pickup" flag.
3965  *
3966  * This routine should (probably) always induce energy expenditure.
3967  *
3968  * Note that moving will *always* take a turn, and will *always* hit
3969  * any monster which might be in the destination grid.  Previously,
3970  * moving into walls was "free" and did NOT hit invisible monsters.
3971  */
3972 void move_player(int dir, int do_pickup, bool break_trap)
3973 {
3974         int y, x;
3975
3976         cave_type *c_ptr;
3977         monster_type *m_ptr;
3978
3979         char m_name[80];
3980
3981         bool p_can_pass_walls = FALSE;
3982         bool stormbringer = FALSE;
3983
3984         bool oktomove = TRUE;
3985         bool do_past = FALSE;
3986
3987         /* Find the result of moving */
3988         y = py + ddy[dir];
3989         x = px + ddx[dir];
3990
3991         /* Examine the destination */
3992         c_ptr = &cave[y][x];
3993
3994
3995         /* Exit the area */
3996         if (!dun_level && !p_ptr->wild_mode &&
3997                 ((x == 0) || (x == MAX_WID - 1) ||
3998                  (y == 0) || (y == MAX_HGT - 1)))
3999         {
4000                 /* Can the player enter the grid? */
4001                 if (c_ptr->mimic && player_can_enter(c_ptr->mimic))
4002                 {
4003                         /* Hack: move to new area */
4004                         if ((y == 0) && (x == 0))
4005                         {
4006                                 p_ptr->wilderness_y--;
4007                                 p_ptr->wilderness_x--;
4008                                 p_ptr->oldpy = cur_hgt - 2;
4009                                 p_ptr->oldpx = cur_wid - 2;
4010                                 ambush_flag = FALSE;
4011                         }
4012
4013                         else if ((y == 0) && (x == MAX_WID - 1))
4014                         {
4015                                 p_ptr->wilderness_y--;
4016                                 p_ptr->wilderness_x++;
4017                                 p_ptr->oldpy = cur_hgt - 2;
4018                                 p_ptr->oldpx = 1;
4019                                 ambush_flag = FALSE;
4020                         }
4021
4022                         else if ((y == MAX_HGT - 1) && (x == 0))
4023                         {
4024                                 p_ptr->wilderness_y++;
4025                                 p_ptr->wilderness_x--;
4026                                 p_ptr->oldpy = 1;
4027                                 p_ptr->oldpx = cur_wid - 2;
4028                                 ambush_flag = FALSE;
4029                         }
4030
4031                         else if ((y == MAX_HGT - 1) && (x == MAX_WID - 1))
4032                         {
4033                                 p_ptr->wilderness_y++;
4034                                 p_ptr->wilderness_x++;
4035                                 p_ptr->oldpy = 1;
4036                                 p_ptr->oldpx = 1;
4037                                 ambush_flag = FALSE;
4038                         }
4039
4040                         else if (y == 0)
4041                         {
4042                                 p_ptr->wilderness_y--;
4043                                 p_ptr->oldpy = cur_hgt - 2;
4044                                 p_ptr->oldpx = x;
4045                                 ambush_flag = FALSE;
4046                         }
4047
4048                         else if (y == MAX_HGT - 1)
4049                         {
4050                                 p_ptr->wilderness_y++;
4051                                 p_ptr->oldpy = 1;
4052                                 p_ptr->oldpx = x;
4053                                 ambush_flag = FALSE;
4054                         }
4055
4056                         else if (x == 0)
4057                         {
4058                                 p_ptr->wilderness_x--;
4059                                 p_ptr->oldpx = cur_wid - 2;
4060                                 p_ptr->oldpy = y;
4061                                 ambush_flag = FALSE;
4062                         }
4063
4064                         else if (x == MAX_WID - 1)
4065                         {
4066                                 p_ptr->wilderness_x++;
4067                                 p_ptr->oldpx = 1;
4068                                 p_ptr->oldpy = y;
4069                                 ambush_flag = FALSE;
4070                         }
4071
4072                         p_ptr->leftbldg = TRUE;
4073                         p_ptr->leaving = TRUE;
4074                         energy_use = 100;
4075
4076                         return;
4077                 }
4078
4079                 oktomove = FALSE;
4080         }
4081
4082         /* Get the monster */
4083         m_ptr = &m_list[c_ptr->m_idx];
4084
4085
4086         if (inventory[INVEN_RARM].art_name)
4087         {
4088                 if (inventory[INVEN_RARM].name1 == ART_STORMBRINGER)
4089                         stormbringer = TRUE;
4090         }
4091         else if (inventory[INVEN_LARM].art_name)
4092         {
4093                 if (inventory[INVEN_LARM].name1 == ART_STORMBRINGER)
4094                         stormbringer = TRUE;
4095         }
4096
4097         /* Player can not walk through "walls"... */
4098         /* unless in Shadow Form */
4099         if (p_ptr->wraith_form || p_ptr->pass_wall || p_ptr->kabenuke)
4100                 p_can_pass_walls = TRUE;
4101         if ((cave[y][x].feat >= FEAT_PERM_EXTRA) &&
4102             (cave[y][x].feat <= FEAT_PERM_SOLID))
4103         {
4104                 p_can_pass_walls = FALSE;
4105         }
4106
4107         if (p_ptr->riding)
4108         {
4109                 cave[py][px].m_idx = 0;
4110         }
4111
4112         /* Hack -- attack monsters */
4113         if (c_ptr->m_idx && (m_ptr->ml || cave_floor_bold(y, x) || p_can_pass_walls))
4114         {
4115
4116                 /* Attack -- only if we can see it OR it is not in a wall */
4117                 if (!is_hostile(m_ptr) &&
4118                     !(p_ptr->confused || p_ptr->image || !m_ptr->ml || p_ptr->stun ||
4119                     ((p_ptr->muta2 & MUT2_BERS_RAGE) && p_ptr->shero)) &&
4120                     (pattern_seq(py, px, y, x)) &&
4121                     ((cave_floor_bold(y, x)) || (c_ptr->feat == FEAT_TREES) || (p_can_pass_walls)))
4122                 {
4123                         m_ptr->csleep = 0;
4124                         p_ptr->update |= (PU_MON_LITE);
4125
4126                         /* Extract monster name (or "it") */
4127                         monster_desc(m_name, m_ptr, 0);
4128
4129                         /* Auto-Recall if possible and visible */
4130                         if (m_ptr->ml) monster_race_track((bool)(m_ptr->mflag2 & MFLAG_KAGE), m_ptr->r_idx);
4131
4132                         /* Track a new monster */
4133                         if (m_ptr->ml) health_track(c_ptr->m_idx);
4134
4135                         /* displace? */
4136                         if ((stormbringer && (randint(1000) > 666)) || (p_ptr->pclass == CLASS_BERSERKER))
4137                         {
4138                                 py_attack(y, x, 0);
4139                                 oktomove = FALSE;
4140                         }
4141                         else if (monster_can_cross_terrain(cave[py][px].feat, &r_info[m_ptr->r_idx]) &&
4142                                  (cave_floor_bold(py, px) || cave[py][px].feat == FEAT_TREES ||
4143                                   (r_info[m_ptr->r_idx].flags2 & RF2_PASS_WALL)))
4144                         {
4145                                 do_past = TRUE;
4146                         }
4147                         else
4148                         {
4149 #ifdef JP
4150                                 msg_format("%^s¤¬¼ÙËâ¤À¡ª", m_name);
4151 #else
4152                                 msg_format("%^s is in your way!", m_name);
4153 #endif
4154
4155                                 energy_use = 0;
4156                                 oktomove = FALSE;
4157                         }
4158
4159                         /* now continue on to 'movement' */
4160                 }
4161                 else
4162                 {
4163                         py_attack(y, x, 0);
4164                         oktomove = FALSE;
4165                 }
4166         }
4167
4168         if (!oktomove)
4169         {
4170         }
4171
4172         else if ((c_ptr->feat == FEAT_DARK_PIT) && !p_ptr->ffall)
4173         {
4174 #ifdef JP
4175                 msg_print("Îö¤±Ìܤò²£Àڤ뤳¤È¤Ï¤Ç¤­¤Þ¤»¤ó¡£");
4176 #else
4177                 msg_print("You can't cross the chasm.");
4178 #endif
4179
4180                 energy_use = 0;
4181                 running = 0;
4182                 oktomove = FALSE;
4183         }
4184
4185         else if (c_ptr->feat == FEAT_MOUNTAIN)
4186         {
4187                 if (dun_level || !p_ptr->ffall)
4188                 {
4189 #ifdef JP
4190                         msg_print("»³¤Ë¤ÏÅФì¤Þ¤»¤ó¡ª");
4191 #else
4192                         msg_print("You can't climb the mountains!");
4193 #endif
4194
4195                         running = 0;
4196                         energy_use = 0;
4197                         oktomove = FALSE;
4198                 }
4199         }
4200         /*
4201          * Player can move through trees and
4202          * has effective -10 speed
4203          * Rangers can move without penality
4204          */
4205         else if (c_ptr->feat == FEAT_TREES)
4206         {
4207                 oktomove = TRUE;
4208                 if ((p_ptr->pclass != CLASS_RANGER) && !p_ptr->ffall) energy_use *= 2;
4209         }
4210
4211         else if ((c_ptr->feat >= FEAT_QUEST_ENTER) &&
4212                 (c_ptr->feat <= FEAT_QUEST_EXIT))
4213         {
4214                 oktomove = TRUE;
4215         }
4216
4217 #ifdef ALLOW_EASY_DISARM /* TNB */
4218
4219         /* Disarm a visible trap */
4220         else if ((do_pickup != easy_disarm) && is_trap(c_ptr->feat))
4221         {
4222                 bool ignore = FALSE;
4223                 switch (c_ptr->feat)
4224                 {
4225                         case FEAT_TRAP_TRAPDOOR:
4226                         case FEAT_TRAP_PIT:
4227                         case FEAT_TRAP_SPIKED_PIT:
4228                         case FEAT_TRAP_POISON_PIT:
4229                                 if (p_ptr->ffall) ignore = TRUE;
4230                                 break;
4231                         case FEAT_TRAP_TELEPORT:
4232                                 if (p_ptr->anti_tele) ignore = TRUE;
4233                                 break;
4234                         case FEAT_TRAP_FIRE:
4235                                 if (p_ptr->immune_fire) ignore = TRUE;
4236                                 break;
4237                         case FEAT_TRAP_ACID:
4238                                 if (p_ptr->immune_acid) ignore = TRUE;
4239                                 break;
4240                         case FEAT_TRAP_BLIND:
4241                                 if (p_ptr->resist_blind) ignore = TRUE;
4242                                 break;
4243                         case FEAT_TRAP_CONFUSE:
4244                                 if (p_ptr->resist_conf) ignore = TRUE;
4245                                 break;
4246                         case FEAT_TRAP_POISON:
4247                                 if (p_ptr->resist_pois) ignore = TRUE;
4248                                 break;
4249                         case FEAT_TRAP_SLEEP:
4250                                 if (p_ptr->free_act) ignore = TRUE;
4251                                 break;
4252                 }
4253
4254                 if (!ignore)
4255                 {
4256                         (void)do_cmd_disarm_aux(y, x, dir);
4257                         return;
4258                 }
4259         }
4260
4261 #endif /* ALLOW_EASY_DISARM -- TNB */
4262         else if (p_ptr->riding && (r_info[m_list[p_ptr->riding].r_idx].flags1 & RF1_NEVER_MOVE))
4263         {
4264 #ifdef JP
4265                 msg_print("Æ°¤±¤Ê¤¤¡ª");
4266 #else
4267                 msg_print("Can't move!");
4268 #endif
4269                 energy_use = 0;
4270                 oktomove = FALSE;
4271                 disturb(0, 0);
4272         }
4273
4274         else if (p_ptr->riding && m_list[p_ptr->riding].monfear)
4275         {
4276                 char m_name[80];
4277
4278                 /* Acquire the monster name */
4279                 monster_desc(m_name, &m_list[p_ptr->riding], 0);
4280
4281                 /* Dump a message */
4282 #ifdef JP
4283 msg_format("%s¤¬¶²Éݤ·¤Æ¤¤¤ÆÀ©¸æ¤Ç¤­¤Ê¤¤¡£", m_name);
4284 #else
4285                 msg_format("%^s is too scared to control.", m_name);
4286 #endif
4287                 oktomove = FALSE;
4288                 disturb(0, 0);
4289         }
4290
4291         else if (p_ptr->riding && p_ptr->riding_ryoute)
4292         {
4293                 oktomove = FALSE;
4294                 disturb(0, 0);
4295         }
4296
4297         else if ((p_ptr->riding && (r_info[m_list[p_ptr->riding].r_idx].flags7 & RF7_AQUATIC)) && (c_ptr->feat != FEAT_SHAL_WATER) && (c_ptr->feat != FEAT_DEEP_WATER))
4298         {
4299 #ifdef JP
4300                 msg_print("Φ¾å¤Ë¾å¤¬¤ì¤Ê¤¤¡£");
4301 #else
4302                 msg_print("Can't land.");
4303 #endif
4304                 energy_use = 0;
4305                 oktomove = FALSE;
4306                 disturb(0, 0);
4307         }
4308
4309         else if ((p_ptr->riding && !(r_info[m_list[p_ptr->riding].r_idx].flags7 & (RF7_AQUATIC | RF7_CAN_SWIM | RF7_CAN_FLY))) && (c_ptr->feat == FEAT_DEEP_WATER))
4310         {
4311 #ifdef JP
4312                 msg_print("¿å¾å¤Ë¹Ô¤±¤Ê¤¤¡£");
4313 #else
4314                 msg_print("Can't swim.");
4315 #endif
4316                 energy_use = 0;
4317                 oktomove = FALSE;
4318                 disturb(0, 0);
4319         }
4320
4321         else if ((p_ptr->riding && (r_info[m_list[p_ptr->riding].r_idx].flags2 & (RF2_AURA_FIRE)) && !(r_info[m_list[p_ptr->riding].r_idx].flags7 & (RF7_CAN_FLY))) && (c_ptr->feat == FEAT_SHAL_WATER))
4322         {
4323 #ifdef JP
4324                 msg_print("¿å¾å¤Ë¹Ô¤±¤Ê¤¤¡£");
4325 #else
4326                 msg_print("Can't swim.");
4327 #endif
4328                 energy_use = 0;
4329                 oktomove = FALSE;
4330                 disturb(0, 0);
4331         }
4332
4333         else if ((p_ptr->riding && !(r_info[m_list[p_ptr->riding].r_idx].flags7 & (RF7_CAN_FLY)) && !(r_info[m_list[p_ptr->riding].r_idx].flags3 & (RF3_IM_FIRE))) && ((c_ptr->feat == FEAT_SHAL_LAVA) || (c_ptr->feat == FEAT_DEEP_LAVA)))
4334         {
4335 #ifdef JP
4336                 msg_print("ÍÏ´ä¤Î¾å¤Ë¹Ô¤±¤Ê¤¤¡£");
4337 #else
4338                 msg_print("Too hot to go through.");
4339 #endif
4340                 energy_use = 0;
4341                 oktomove = FALSE;
4342                 disturb(0, 0);
4343         }
4344
4345         else if (p_ptr->riding && m_list[p_ptr->riding].stunned && one_in_(2))
4346         {
4347                 char m_name[80];
4348                 monster_desc(m_name, &m_list[p_ptr->riding], 0);
4349 #ifdef JP
4350                 msg_format("%s¤¬Û¯Û°¤È¤·¤Æ¤¤¤Æ¤¦¤Þ¤¯Æ°¤±¤Ê¤¤¡ª",m_name);
4351 #else
4352                 msg_format("You cannot control stunned %s!",m_name);
4353 #endif
4354                 oktomove = FALSE;
4355                 disturb(0, 0);
4356         }
4357
4358         /* Player can not walk through "walls" unless in wraith form...*/
4359         else if ((!cave_floor_bold(y, x)) &&
4360                 (!p_can_pass_walls))
4361         {
4362                 oktomove = FALSE;
4363
4364                 /* Disturb the player */
4365                 disturb(0, 0);
4366
4367                 /* Notice things in the dark */
4368                 if ((!(c_ptr->info & (CAVE_MARK))) &&
4369                     (p_ptr->blind || !(c_ptr->info & (CAVE_LITE))))
4370                 {
4371                         /* Rubble */
4372                         if (c_ptr->feat == FEAT_RUBBLE)
4373                         {
4374 #ifdef JP
4375                                 msg_print("´äÀФ¬¹Ô¤¯¼ê¤ò¤Ï¤Ð¤ó¤Ç¤¤¤ë¤è¤¦¤À¡£");
4376 #else
4377                                 msg_print("You feel some rubble blocking your way.");
4378 #endif
4379
4380                                 c_ptr->info |= (CAVE_MARK);
4381                                 lite_spot(y, x);
4382                         }
4383
4384                         /* Closed door */
4385                         else if (c_ptr->feat < FEAT_SECRET)
4386                         {
4387 #ifdef JP
4388                                 msg_print("¥É¥¢¤¬¹Ô¤¯¼ê¤ò¤Ï¤Ð¤ó¤Ç¤¤¤ë¤è¤¦¤À¡£");
4389 #else
4390                                 msg_print("You feel a closed door blocking your way.");
4391 #endif
4392
4393                                 c_ptr->info |= (CAVE_MARK);
4394                                 lite_spot(y, x);
4395                         }
4396
4397                         /* Wall (or secret door) */
4398                         else
4399                         {
4400 #ifdef JP
4401                                 msg_print("Êɤ¬¹Ô¤¯¼ê¤ò¤Ï¤Ð¤ó¤Ç¤¤¤ë¤è¤¦¤À¡£");
4402 #else
4403                                 msg_print("You feel a wall blocking your way.");
4404 #endif
4405
4406                                 c_ptr->info |= (CAVE_MARK);
4407                                 lite_spot(y, x);
4408                         }
4409                 }
4410
4411                 /* Notice things */
4412                 else
4413                 {
4414                         /* Rubble */
4415                         if (c_ptr->feat == FEAT_RUBBLE)
4416                         {
4417 #ifdef JP
4418                                 msg_print("´äÀФ¬¹Ô¤¯¼ê¤ò¤Ï¤Ð¤ó¤Ç¤¤¤ë¡£");
4419 #else
4420                                 msg_print("There is rubble blocking your way.");
4421 #endif
4422
4423
4424                                 if (!(p_ptr->confused || p_ptr->stun || p_ptr->image))
4425                                         energy_use = 0;
4426
4427                                 /*
4428                                  * Well, it makes sense that you lose time bumping into
4429                                  * a wall _if_ you are confused, stunned or blind; but
4430                                  * typing mistakes should not cost you a turn...
4431                                  */
4432                         }
4433                         /* Closed doors */
4434                         else if (c_ptr->feat < FEAT_SECRET)
4435                         {
4436 #ifdef ALLOW_EASY_OPEN
4437
4438                                 if (easy_open && easy_open_door(y, x)) return;
4439
4440 #endif /* ALLOW_EASY_OPEN */
4441
4442 #ifdef JP
4443                                 msg_print("¥É¥¢¤¬¹Ô¤¯¼ê¤ò¤Ï¤Ð¤ó¤Ç¤¤¤ë¡£");
4444 #else
4445                                 msg_print("There is a closed door blocking your way.");
4446 #endif
4447
4448
4449                                 if (!(p_ptr->confused || p_ptr->stun || p_ptr->image))
4450                                         energy_use = 0;
4451                         }
4452
4453                         /* Wall (or secret door) */
4454                         else
4455                         {
4456 #ifdef JP
4457                                 msg_print("Êɤ¬¹Ô¤¯¼ê¤ò¤Ï¤Ð¤ó¤Ç¤¤¤ë¡£");
4458 #else
4459                                 msg_print("There is a wall blocking your way.");
4460 #endif
4461
4462
4463                                 if (!(p_ptr->confused || p_ptr->stun || p_ptr->image))
4464                                         energy_use = 0;
4465                         }
4466                 }
4467
4468                 /* Sound */
4469                 sound(SOUND_HITWALL);
4470         }
4471
4472         /* Normal movement */
4473         if (!pattern_seq(py, px, y, x))
4474         {
4475                 if (!(p_ptr->confused || p_ptr->stun || p_ptr->image))
4476                 {
4477                         energy_use = 0;
4478                 }
4479
4480                 /* To avoid a loop with running */
4481                 disturb(0, 0);
4482
4483                 oktomove = FALSE;
4484         }
4485
4486         /* Normal movement */
4487         if (oktomove)
4488         {
4489                 int oy, ox;
4490
4491 #ifdef USE_SCRIPT
4492                 if (player_enter_grid_callback(y, x)) return;
4493
4494                 /* Player movement callback */
4495                 if (player_move_callback(y, x)) return;
4496 #endif /* USE_SCRIPT */
4497
4498 #ifdef USE_FRAKIR
4499                 if (p_ptr->warning)
4500                   {
4501                     if(!process_frakir(x,y))
4502                       {
4503                         energy_use = 25;return;
4504                       }
4505                   }
4506 #endif
4507
4508                 if (do_past)
4509                 {
4510 #ifdef JP
4511                         msg_format("%s¤ò²¡¤·Âऱ¤¿¡£", m_name);
4512 #else
4513                         msg_format("You push past %s.", m_name);
4514 #endif
4515
4516                         m_ptr->fy = py;
4517                         m_ptr->fx = px;
4518                         cave[py][px].m_idx = c_ptr->m_idx;
4519                         c_ptr->m_idx = 0;
4520                         update_mon(cave[py][px].m_idx, TRUE);
4521                 }
4522
4523                 /* Change oldpx and oldpy to place the player well when going back to big mode */
4524                 if (p_ptr->wild_mode)
4525                 {
4526                         if(ddy[dir] > 0)  p_ptr->oldpy = 1;
4527                         if(ddy[dir] < 0)  p_ptr->oldpy = MAX_HGT - 2;
4528                         if(ddy[dir] == 0) p_ptr->oldpy = MAX_HGT / 2;
4529                         if(ddx[dir] > 0)  p_ptr->oldpx = 1;
4530                         if(ddx[dir] < 0)  p_ptr->oldpx = MAX_WID - 2;
4531                         if(ddx[dir] == 0) p_ptr->oldpx = MAX_WID / 2;
4532                 }
4533
4534                 /* Save old location */
4535                 oy = py;
4536                 ox = px;
4537
4538                 /* Move the player */
4539                 py = y;
4540                 px = x;
4541
4542                 if (p_ptr->riding && (r_info[m_list[p_ptr->riding].r_idx].flags2 & RF2_KILL_WALL))
4543                 {
4544                         if (cave[py][px].feat > FEAT_SECRET && cave[py][px].feat < FEAT_PERM_SOLID)
4545                         {
4546                                 /* Forget the wall */
4547                                 cave[py][px].info &= ~(CAVE_MARK);
4548
4549                                 /* Notice */
4550                                 cave_set_feat(py, px, floor_type[rand_int(100)]);
4551                         }
4552                 }
4553                 if (music_singing(MUSIC_WALL))
4554                 {
4555                         project(0, 0, py, px,
4556                                 (60 + p_ptr->lev), GF_DISINTEGRATE, PROJECT_KILL | PROJECT_ITEM, -1);
4557                 }
4558                 else if (p_ptr->kill_wall)
4559                 {
4560                         if (cave_valid_bold(py, px) &&
4561                                 (cave[py][px].feat < FEAT_PATTERN_START ||
4562                                  cave[py][px].feat > FEAT_PATTERN_XTRA2) &&
4563                                 (cave[py][px].feat < FEAT_DEEP_WATER ||
4564                                  cave[py][px].feat > FEAT_GRASS))
4565                         {
4566                                 if (cave[py][px].feat == FEAT_TREES)
4567                                         cave_set_feat(py, px, FEAT_GRASS);
4568                                 else
4569                                 {
4570                                         cave[py][px].feat = floor_type[rand_int(100)];
4571                                         cave[py][px].info &= ~(CAVE_MASK);
4572                                         cave[py][px].info |= CAVE_FLOOR;
4573                                 }
4574                         }
4575                                 /* Update some things -- similar to GF_KILL_WALL */
4576                         p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MONSTERS | PU_MON_LITE);
4577                 }
4578
4579                 /* Redraw new spot */
4580                 lite_spot(py, px);
4581
4582                 /* Redraw old spot */
4583                 lite_spot(oy, ox);
4584
4585                 /* Sound */
4586                 /* sound(SOUND_WALK); */
4587
4588                 /* Check for new panel (redraw map) */
4589                 verify_panel();
4590
4591                 /* For get everything when requested hehe I'm *NASTY* */
4592                 if (dun_level && (d_info[dungeon_type].flags1 & DF1_FORGET))
4593                 {
4594                         wiz_dark();
4595                 }
4596
4597                 if ((p_ptr->pclass == CLASS_NINJA))
4598                 {
4599                         if (c_ptr->info & (CAVE_GLOW)) set_superstealth(FALSE);
4600                         else if (p_ptr->cur_lite <= 0) set_superstealth(TRUE);
4601                 }
4602                 if ((p_ptr->action == ACTION_HAYAGAKE) && !cave_floor_bold(py, px))
4603                 {
4604 #ifdef JP
4605                         msg_print("¤³¤³¤Ç¤ÏÁÇÁ᤯ư¤±¤Ê¤¤¡£");
4606 #else
4607                         msg_print("You cannot run in wall.");
4608 #endif
4609                         set_action(ACTION_NONE);
4610                 }
4611
4612                 /* Update stuff */
4613                 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
4614
4615                 /* Update the monsters */
4616                 p_ptr->update |= (PU_DISTANCE);
4617
4618                 /* Window stuff */
4619                 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
4620
4621                 /* Spontaneous Searching */
4622                 if ((p_ptr->skill_fos >= 50) ||
4623                     (0 == rand_int(50 - p_ptr->skill_fos)))
4624                 {
4625                         search();
4626                 }
4627
4628                 /* Continuous Searching */
4629                 if (p_ptr->action == ACTION_SEARCH)
4630                 {
4631                         search();
4632                 }
4633
4634                 /* Handle "objects" */
4635
4636 #ifdef ALLOW_EASY_DISARM /* TNB */
4637
4638                 carry(do_pickup != always_pickup);
4639
4640 #else /* ALLOW_EASY_DISARM -- TNB */
4641
4642                 carry(do_pickup);
4643
4644 #endif /* ALLOW_EASY_DISARM -- TNB */
4645
4646                 /* Handle "store doors" */
4647                 if (((c_ptr->feat >= FEAT_SHOP_HEAD) &&
4648                     (c_ptr->feat <= FEAT_SHOP_TAIL)) ||
4649                     (c_ptr->feat == FEAT_MUSEUM))
4650                 {
4651                         /* Disturb */
4652                         disturb(0, 0);
4653
4654                         energy_use = 0;
4655                         /* Hack -- Enter store */
4656                         command_new = 253;
4657                 }
4658
4659                 /* Handle "building doors" -KMW- */
4660                 else if ((c_ptr->feat >= FEAT_BLDG_HEAD) &&
4661                     (c_ptr->feat <= FEAT_BLDG_TAIL))
4662                 {
4663                         /* Disturb */
4664                         disturb(0, 0);
4665
4666                         energy_use = 0;
4667                         /* Hack -- Enter building */
4668                         command_new = 254;
4669                 }
4670
4671                 /* Handle quest areas -KMW- */
4672                 else if (cave[y][x].feat == FEAT_QUEST_ENTER)
4673                 {
4674                         /* Disturb */
4675                         disturb(0, 0);
4676
4677                         energy_use = 0;
4678                         /* Hack -- Enter quest level */
4679                         command_new = 255;
4680                 }
4681
4682                 else if (cave[y][x].feat == FEAT_QUEST_EXIT)
4683                 {
4684                         if (quest[p_ptr->inside_quest].type == QUEST_TYPE_FIND_EXIT)
4685                         {
4686                                 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_C, p_ptr->inside_quest, NULL);
4687                                 quest[p_ptr->inside_quest].status = QUEST_STATUS_COMPLETED;
4688                                 quest[p_ptr->inside_quest].complev = (byte)p_ptr->lev;
4689 #ifdef JP
4690                                 msg_print("¥¯¥¨¥¹¥È¤òãÀ®¤·¤¿¡ª");
4691 #else
4692                                 msg_print("You accomplished your quest!");
4693 #endif
4694
4695                                 msg_print(NULL);
4696                         }
4697
4698                         leaving_quest = p_ptr->inside_quest;
4699
4700                         /* Leaving an 'only once' quest marks it as failed */
4701                         if (leaving_quest &&
4702                                 ((quest[leaving_quest].flags & QUEST_FLAG_ONCE) || (quest[leaving_quest].type == QUEST_TYPE_RANDOM)) &&
4703                                 (quest[leaving_quest].status == QUEST_STATUS_TAKEN))
4704                         {
4705                                 if ((quest[leaving_quest].type == QUEST_TYPE_RANDOM) && record_rand_quest)
4706                                         do_cmd_write_nikki(NIKKI_RAND_QUEST_F, leaving_quest, NULL);
4707                                 else if (record_fix_quest)
4708                                         do_cmd_write_nikki(NIKKI_FIX_QUEST_F, leaving_quest, NULL);
4709                                 quest[leaving_quest].status = QUEST_STATUS_FAILED;
4710                                 quest[leaving_quest].complev = (byte)p_ptr->lev;
4711                                 if (quest[leaving_quest].type == QUEST_TYPE_RANDOM)
4712                                         r_info[quest[leaving_quest].r_idx].flags1 &= ~(RF1_QUESTOR);
4713                         }
4714
4715                         p_ptr->inside_quest = cave[y][x].special;
4716                         dun_level = 0;
4717                         p_ptr->oldpx = 0;
4718                         p_ptr->oldpy = 0;
4719                         p_ptr->leaving = TRUE;
4720                 }
4721
4722                 /* Discover invisible traps */
4723                 else if (c_ptr->info & CAVE_TRAP)
4724                 {
4725                         /* Disturb */
4726                         disturb(0, 0);
4727
4728                         /* Message */
4729 #ifdef JP
4730                         msg_print("¥È¥é¥Ã¥×¤À¡ª");
4731 #else
4732                         msg_print("You found a trap!");
4733 #endif
4734
4735
4736                         /* Pick a trap */
4737                         pick_trap(py, px);
4738
4739                         /* Hit the trap */
4740                         hit_trap(break_trap);
4741                 }
4742
4743                 /* Set off an visible trap */
4744                 else if (is_trap(c_ptr->feat))
4745                 {
4746                         /* Disturb */
4747                         disturb(0, 0);
4748
4749                         /* Hit the trap */
4750                         hit_trap(break_trap);
4751                 }
4752         }
4753         if (p_ptr->riding)
4754         {
4755                 m_list[p_ptr->riding].fy = py;
4756                 m_list[p_ptr->riding].fx = px;
4757                 cave[py][px].m_idx = p_ptr->riding;
4758                 update_mon(cave[py][px].m_idx, TRUE);
4759                 p_ptr->update |= (PU_MON_LITE);
4760         }
4761 }
4762
4763
4764 /*
4765  * Hack -- Check for a "known wall" (see below)
4766  */
4767 static int see_wall(int dir, int y, int x)
4768 {
4769         /* Get the new location */
4770         y += ddy[dir];
4771         x += ddx[dir];
4772
4773         /* Illegal grids are not known walls */
4774         if (!in_bounds2(y, x)) return (FALSE);
4775
4776         /* Non-wall grids are not known walls */
4777         if (cave[y][x].feat < FEAT_SECRET) return (FALSE);
4778
4779         if ((cave[y][x].feat >= FEAT_DEEP_WATER) &&
4780             (cave[y][x].feat <= FEAT_GRASS)) return (FALSE);
4781
4782         if ((cave[y][x].feat >= FEAT_SHOP_HEAD) &&
4783             (cave[y][x].feat <= FEAT_SHOP_TAIL)) return (FALSE);
4784
4785         if (cave[y][x].feat == FEAT_DEEP_GRASS) return (FALSE);
4786         if (cave[y][x].feat == FEAT_FLOWER) return (FALSE);
4787
4788         if (cave[y][x].feat == FEAT_MUSEUM) return (FALSE);
4789
4790         if ((cave[y][x].feat >= FEAT_BLDG_HEAD) &&
4791             (cave[y][x].feat <= FEAT_BLDG_TAIL)) return (FALSE);
4792
4793 /*      if (cave[y][x].feat == FEAT_TREES) return (FALSE); */
4794
4795         /* Must be known to the player */
4796         if (!(cave[y][x].info & (CAVE_MARK))) return (FALSE);
4797
4798         if (cave[y][x].feat >= FEAT_TOWN) return (FALSE);
4799
4800         /* Default */
4801         return (TRUE);
4802 }
4803
4804
4805 /*
4806  * Hack -- Check for an "unknown corner" (see below)
4807  */
4808 static int see_nothing(int dir, int y, int x)
4809 {
4810         /* Get the new location */
4811         y += ddy[dir];
4812         x += ddx[dir];
4813
4814         /* Illegal grids are unknown */
4815         if (!in_bounds2(y, x)) return (TRUE);
4816
4817         /* Memorized grids are always known */
4818         if (cave[y][x].info & (CAVE_MARK)) return (FALSE);
4819
4820         /* Non-floor grids are unknown */
4821         if (!cave_floor_bold(y, x)) return (TRUE);
4822
4823         /* Viewable door/wall grids are known */
4824         if (player_can_see_bold(y, x)) return (FALSE);
4825
4826         /* Default */
4827         return (TRUE);
4828 }
4829
4830
4831
4832
4833
4834 /*
4835  * The running algorithm:                       -CJS-
4836  *
4837  * In the diagrams below, the player has just arrived in the
4838  * grid marked as '@', and he has just come from a grid marked
4839  * as 'o', and he is about to enter the grid marked as 'x'.
4840  *
4841  * Of course, if the "requested" move was impossible, then you
4842  * will of course be blocked, and will stop.
4843  *
4844  * Overview: You keep moving until something interesting happens.
4845  * If you are in an enclosed space, you follow corners. This is
4846  * the usual corridor scheme. If you are in an open space, you go
4847  * straight, but stop before entering enclosed space. This is
4848  * analogous to reaching doorways. If you have enclosed space on
4849  * one side only (that is, running along side a wall) stop if
4850  * your wall opens out, or your open space closes in. Either case
4851  * corresponds to a doorway.
4852  *
4853  * What happens depends on what you can really SEE. (i.e. if you
4854  * have no light, then running along a dark corridor is JUST like
4855  * running in a dark room.) The algorithm works equally well in
4856  * corridors, rooms, mine tailings, earthquake rubble, etc, etc.
4857  *
4858  * These conditions are kept in static memory:
4859  * find_openarea         You are in the open on at least one
4860  * side.
4861  * find_breakleft        You have a wall on the left, and will
4862  * stop if it opens
4863  * find_breakright       You have a wall on the right, and will
4864  * stop if it opens
4865  *
4866  * To initialize these conditions, we examine the grids adjacent
4867  * to the grid marked 'x', two on each side (marked 'L' and 'R').
4868  * If either one of the two grids on a given side is seen to be
4869  * closed, then that side is considered to be closed. If both
4870  * sides are closed, then it is an enclosed (corridor) run.
4871  *
4872  * LL           L
4873  * @x          LxR
4874  * RR          @R
4875  *
4876  * Looking at more than just the immediate squares is
4877  * significant. Consider the following case. A run along the
4878  * corridor will stop just before entering the center point,
4879  * because a choice is clearly established. Running in any of
4880  * three available directions will be defined as a corridor run.
4881  * Note that a minor hack is inserted to make the angled corridor
4882  * entry (with one side blocked near and the other side blocked
4883  * further away from the runner) work correctly. The runner moves
4884  * diagonally, but then saves the previous direction as being
4885  * straight into the gap. Otherwise, the tail end of the other
4886  * entry would be perceived as an alternative on the next move.
4887  *
4888  * #.#
4889  * ##.##
4890  * .@x..
4891  * ##.##
4892  * #.#
4893  *
4894  * Likewise, a run along a wall, and then into a doorway (two
4895  * runs) will work correctly. A single run rightwards from @ will
4896  * stop at 1. Another run right and down will enter the corridor
4897  * and make the corner, stopping at the 2.
4898  *
4899  * #@x    1
4900  * ########### ######
4901  * 2        #
4902  * #############
4903  * #
4904  *
4905  * After any move, the function area_affect is called to
4906  * determine the new surroundings, and the direction of
4907  * subsequent moves. It examines the current player location
4908  * (at which the runner has just arrived) and the previous
4909  * direction (from which the runner is considered to have come).
4910  *
4911  * Moving one square in some direction places you adjacent to
4912  * three or five new squares (for straight and diagonal moves
4913  * respectively) to which you were not previously adjacent,
4914  * marked as '!' in the diagrams below.
4915  *
4916  * ...!   ...
4917  * .o@!   .o.!
4918  * ...!   ..@!
4919  * !!!
4920  *
4921  * You STOP if any of the new squares are interesting in any way:
4922  * for example, if they contain visible monsters or treasure.
4923  *
4924  * You STOP if any of the newly adjacent squares seem to be open,
4925  * and you are also looking for a break on that side. (that is,
4926  * find_openarea AND find_break).
4927  *
4928  * You STOP if any of the newly adjacent squares do NOT seem to be
4929  * open and you are in an open area, and that side was previously
4930  * entirely open.
4931  *
4932  * Corners: If you are not in the open (i.e. you are in a corridor)
4933  * and there is only one way to go in the new squares, then turn in
4934  * that direction. If there are more than two new ways to go, STOP.
4935  * If there are two ways to go, and those ways are separated by a
4936  * square which does not seem to be open, then STOP.
4937  *
4938  * Otherwise, we have a potential corner. There are two new open
4939  * squares, which are also adjacent. One of the new squares is
4940  * diagonally located, the other is straight on (as in the diagram).
4941  * We consider two more squares further out (marked below as ?).
4942  *
4943  * We assign "option" to the straight-on grid, and "option2" to the
4944  * diagonal grid, and "check_dir" to the grid marked 's'.
4945  *
4946  * .s
4947  * @x?
4948  * #?
4949  *
4950  * If they are both seen to be closed, then it is seen that no
4951  * benefit is gained from moving straight. It is a known corner.
4952  * To cut the corner, go diagonally, otherwise go straight, but
4953  * pretend you stepped diagonally into that next location for a
4954  * full view next time. Conversely, if one of the ? squares is
4955  * not seen to be closed, then there is a potential choice. We check
4956  * to see whether it is a potential corner or an intersection/room entrance.
4957  * If the square two spaces straight ahead, and the space marked with 's'
4958  * are both blank, then it is a potential corner and enter if find_examine
4959  * is set, otherwise must stop because it is not a corner.
4960  */
4961
4962
4963
4964
4965 /*
4966  * Hack -- allow quick "cycling" through the legal directions
4967  */
4968 static byte cycle[] =
4969 { 1, 2, 3, 6, 9, 8, 7, 4, 1, 2, 3, 6, 9, 8, 7, 4, 1 };
4970
4971 /*
4972  * Hack -- map each direction into the "middle" of the "cycle[]" array
4973  */
4974 static byte chome[] =
4975 { 0, 8, 9, 10, 7, 0, 11, 6, 5, 4 };
4976
4977 /*
4978  * The direction we are running
4979  */
4980 static byte find_current;
4981
4982 /*
4983  * The direction we came from
4984  */
4985 static byte find_prevdir;
4986
4987 /*
4988  * We are looking for open area
4989  */
4990 static bool find_openarea;
4991
4992 /*
4993  * We are looking for a break
4994  */
4995 static bool find_breakright;
4996 static bool find_breakleft;
4997
4998
4999
5000 /*
5001  * Initialize the running algorithm for a new direction.
5002  *
5003  * Diagonal Corridor -- allow diaginal entry into corridors.
5004  *
5005  * Blunt Corridor -- If there is a wall two spaces ahead and
5006  * we seem to be in a corridor, then force a turn into the side
5007  * corridor, must be moving straight into a corridor here. ???
5008  *
5009  * Diagonal Corridor    Blunt Corridor (?)
5010  *       # #                  #
5011  *       #x#                 @x#
5012  *       @p.                  p
5013  */
5014 static void run_init(int dir)
5015 {
5016         int             row, col, deepleft, deepright;
5017         int             i, shortleft, shortright;
5018
5019
5020         /* Save the direction */
5021         find_current = dir;
5022
5023         /* Assume running straight */
5024         find_prevdir = dir;
5025
5026         /* Assume looking for open area */
5027         find_openarea = TRUE;
5028
5029         /* Assume not looking for breaks */
5030         find_breakright = find_breakleft = FALSE;
5031
5032         /* Assume no nearby walls */
5033         deepleft = deepright = FALSE;
5034         shortright = shortleft = FALSE;
5035
5036         p_ptr->run_py = py;
5037         p_ptr->run_px = px;
5038
5039         /* Find the destination grid */
5040         row = py + ddy[dir];
5041         col = px + ddx[dir];
5042
5043         /* Extract cycle index */
5044         i = chome[dir];
5045
5046         /* Check for walls */
5047         if (see_wall(cycle[i+1], py, px))
5048         {
5049                 find_breakleft = TRUE;
5050                 shortleft = TRUE;
5051         }
5052         else if (see_wall(cycle[i+1], row, col))
5053         {
5054                 find_breakleft = TRUE;
5055                 deepleft = TRUE;
5056         }
5057
5058         /* Check for walls */
5059         if (see_wall(cycle[i-1], py, px))
5060         {
5061                 find_breakright = TRUE;
5062                 shortright = TRUE;
5063         }
5064         else if (see_wall(cycle[i-1], row, col))
5065         {
5066                 find_breakright = TRUE;
5067                 deepright = TRUE;
5068         }
5069
5070         /* Looking for a break */
5071         if (find_breakleft && find_breakright)
5072         {
5073                 /* Not looking for open area */
5074                 find_openarea = FALSE;
5075
5076                 /* Hack -- allow angled corridor entry */
5077                 if (dir & 0x01)
5078                 {
5079                         if (deepleft && !deepright)
5080                         {
5081                                 find_prevdir = cycle[i - 1];
5082                         }
5083                         else if (deepright && !deepleft)
5084                         {
5085                                 find_prevdir = cycle[i + 1];
5086                         }
5087                 }
5088
5089                 /* Hack -- allow blunt corridor entry */
5090                 else if (see_wall(cycle[i], row, col))
5091                 {
5092                         if (shortleft && !shortright)
5093                         {
5094                                 find_prevdir = cycle[i - 2];
5095                         }
5096                         else if (shortright && !shortleft)
5097                         {
5098                                 find_prevdir = cycle[i + 2];
5099                         }
5100                 }
5101         }
5102 }
5103
5104
5105 /*
5106  * Update the current "run" path
5107  *
5108  * Return TRUE if the running should be stopped
5109  */
5110 static bool run_test(void)
5111 {
5112         int         prev_dir, new_dir, check_dir = 0;
5113         int         row, col;
5114         int         i, max, inv;
5115         int         option = 0, option2 = 0;
5116         cave_type   *c_ptr;
5117
5118         /* Where we came from */
5119         prev_dir = find_prevdir;
5120
5121
5122         /* Range of newly adjacent grids */
5123         max = (prev_dir & 0x01) + 1;
5124
5125
5126         /* Look at every newly adjacent square. */
5127         for (i = -max; i <= max; i++)
5128         {
5129                 s16b this_o_idx, next_o_idx = 0;
5130
5131
5132                 /* New direction */
5133                 new_dir = cycle[chome[prev_dir] + i];
5134
5135                 /* New location */
5136                 row = py + ddy[new_dir];
5137                 col = px + ddx[new_dir];
5138
5139                 /* Access grid */
5140                 c_ptr = &cave[row][col];
5141
5142
5143                 /* Visible monsters abort running */
5144                 if (c_ptr->m_idx)
5145                 {
5146                         monster_type *m_ptr = &m_list[c_ptr->m_idx];
5147
5148                         /* Visible monster */
5149                         if (m_ptr->ml) return (TRUE);
5150                 }
5151
5152                 /* Visible objects abort running */
5153                 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
5154                 {
5155                         object_type *o_ptr;
5156
5157                         /* Acquire object */
5158                         o_ptr = &o_list[this_o_idx];
5159
5160                         /* Acquire next object */
5161                         next_o_idx = o_ptr->next_o_idx;
5162
5163                         /* Visible object */
5164                         if (o_ptr->marked) return (TRUE);
5165                 }
5166
5167
5168                 /* Assume unknown */
5169                 inv = TRUE;
5170
5171                 /* Check memorized grids */
5172                 if (c_ptr->info & (CAVE_MARK))
5173                 {
5174                         bool notice = TRUE;
5175
5176                         /* Examine the terrain */
5177                         switch (c_ptr->feat)
5178                         {
5179                                 /* Floors */
5180                                 case FEAT_FLOOR:
5181
5182                                 /* Invis traps */
5183                                 case FEAT_INVIS:
5184
5185                                 /* Secret doors */
5186                                 case FEAT_SECRET:
5187
5188                                 /* Normal veins */
5189                                 case FEAT_MAGMA:
5190                                 case FEAT_QUARTZ:
5191
5192                                 /* Hidden treasure */
5193                                 case FEAT_MAGMA_H:
5194                                 case FEAT_QUARTZ_H:
5195
5196                                 /* Walls */
5197                                 case FEAT_WALL_EXTRA:
5198                                 case FEAT_WALL_INNER:
5199                                 case FEAT_WALL_OUTER:
5200                                 case FEAT_WALL_SOLID:
5201                                 case FEAT_PERM_EXTRA:
5202                                 case FEAT_PERM_INNER:
5203                                 case FEAT_PERM_OUTER:
5204                                 case FEAT_PERM_SOLID:
5205                                 /* dirt, grass, trees, ... */
5206                                 case FEAT_SHAL_WATER:
5207                                 case FEAT_DIRT:
5208                                 case FEAT_GRASS:
5209                                 case FEAT_DEEP_GRASS:
5210                                 case FEAT_FLOWER:
5211                                 case FEAT_DARK_PIT:
5212                                 case FEAT_TREES:
5213                                 case FEAT_MOUNTAIN:
5214                                 {
5215                                         /* Ignore */
5216                                         notice = FALSE;
5217
5218                                         /* Done */
5219                                         break;
5220                                 }
5221
5222                                 /* quest features */
5223                                 case FEAT_QUEST_ENTER:
5224                                 case FEAT_QUEST_EXIT:
5225                                 {
5226                                         /* Notice */
5227                                         notice = TRUE;
5228
5229                                         /* Done */
5230                                         break;
5231                                 }
5232
5233                                 case FEAT_DEEP_LAVA:
5234                                 case FEAT_SHAL_LAVA:
5235                                 {
5236                                         /* Ignore */
5237                                         if (p_ptr->invuln || p_ptr->immune_fire) notice = FALSE;
5238
5239                                         /* Done */
5240                                         break;
5241                                 }
5242
5243                                 case FEAT_DEEP_WATER:
5244                                 {
5245                                         /* Ignore */
5246                                         if (p_ptr->ffall) notice = FALSE;
5247
5248                                         /* Done */
5249                                         break;
5250                                 }
5251
5252                                 /* Open doors */
5253                                 case FEAT_OPEN:
5254                                 case FEAT_BROKEN:
5255                                 {
5256                                         /* Option -- ignore */
5257                                         if (find_ignore_doors) notice = FALSE;
5258
5259                                         /* Done */
5260                                         break;
5261                                 }
5262
5263                                 /* Stairs */
5264                                 case FEAT_LESS:
5265                                 case FEAT_MORE:
5266                                 case FEAT_LESS_LESS:
5267                                 case FEAT_MORE_MORE:
5268                                 case FEAT_ENTRANCE:
5269                                 {
5270                                         /* Option -- ignore */
5271                                         if (find_ignore_stairs) notice = FALSE;
5272
5273                                         /* Done */
5274                                         break;
5275                                 }
5276                         }
5277
5278                         /* Interesting feature */
5279                         if (notice) return (TRUE);
5280
5281                         /* The grid is "visible" */
5282                         inv = FALSE;
5283                 }
5284
5285                 /* Analyze unknown grids and floors */
5286 /*              if (inv || cave_floor_bold(row, col) || */
5287 /*                  (cave[row][col].feat == FEAT_TREES)) */
5288                 if (inv || cave_floor_bold(row, col))
5289                 {
5290                         /* Looking for open area */
5291                         if (find_openarea)
5292                         {
5293                                 /* Nothing */
5294                         }
5295
5296                         /* The first new direction. */
5297                         else if (!option)
5298                         {
5299                                 option = new_dir;
5300                         }
5301
5302                         /* Three new directions. Stop running. */
5303                         else if (option2)
5304                         {
5305                                 return (TRUE);
5306                         }
5307
5308                         /* Two non-adjacent new directions.  Stop running. */
5309                         else if (option != cycle[chome[prev_dir] + i - 1])
5310                         {
5311                                 return (TRUE);
5312                         }
5313
5314                         /* Two new (adjacent) directions (case 1) */
5315                         else if (new_dir & 0x01)
5316                         {
5317                                 check_dir = cycle[chome[prev_dir] + i - 2];
5318                                 option2 = new_dir;
5319                         }
5320
5321                         /* Two new (adjacent) directions (case 2) */
5322                         else
5323                         {
5324                                 check_dir = cycle[chome[prev_dir] + i + 1];
5325                                 option2 = option;
5326                                 option = new_dir;
5327                         }
5328                 }
5329
5330                 /* Obstacle, while looking for open area */
5331                 else
5332                 {
5333                         if (find_openarea)
5334                         {
5335                                 if (i < 0)
5336                                 {
5337                                         /* Break to the right */
5338                                         find_breakright = TRUE;
5339                                 }
5340
5341                                 else if (i > 0)
5342                                 {
5343                                         /* Break to the left */
5344                                         find_breakleft = TRUE;
5345                                 }
5346                         }
5347                 }
5348         }
5349
5350
5351         /* Looking for open area */
5352         if (find_openarea)
5353         {
5354                 /* Hack -- look again */
5355                 for (i = -max; i < 0; i++)
5356                 {
5357                         new_dir = cycle[chome[prev_dir] + i];
5358
5359                         row = py + ddy[new_dir];
5360                         col = px + ddx[new_dir];
5361
5362                         /* Access grid */
5363                         c_ptr = &cave[row][col];
5364
5365                         /* Unknown grid or non-wall XXX XXX XXX cave_floor_grid(c_ptr)) */
5366                         if (!(c_ptr->info & (CAVE_MARK)) ||
5367                             ((c_ptr->feat < FEAT_SECRET) ||
5368                              (c_ptr->feat == FEAT_FLOWER) ||
5369                              (c_ptr->feat == FEAT_DEEP_GRASS) ||
5370                             ((c_ptr->feat >= FEAT_DEEP_WATER) &&
5371                                  (c_ptr->feat <= FEAT_GRASS))))
5372
5373                         {
5374                                 /* Looking to break right */
5375                                 if (find_breakright)
5376                                 {
5377                                         return (TRUE);
5378                                 }
5379                         }
5380
5381                         /* Obstacle */
5382                         else
5383                         {
5384                                 /* Looking to break left */
5385                                 if (find_breakleft)
5386                                 {
5387                                         return (TRUE);
5388                                 }
5389                         }
5390                 }
5391
5392                 /* Hack -- look again */
5393                 for (i = max; i > 0; i--)
5394                 {
5395                         new_dir = cycle[chome[prev_dir] + i];
5396
5397                         row = py + ddy[new_dir];
5398                         col = px + ddx[new_dir];
5399
5400                         /* Access grid */
5401                         c_ptr = &cave[row][col];
5402
5403                         /* Unknown grid or non-wall XXX XXX XXX cave_floor_grid(c_ptr)) */
5404                         if (!(c_ptr->info & (CAVE_MARK)) ||
5405                             ((c_ptr->feat < FEAT_SECRET) ||
5406                              (c_ptr->feat == FEAT_FLOWER) ||
5407                              (c_ptr->feat == FEAT_DEEP_GRASS) ||
5408                             ((c_ptr->feat >= FEAT_DEEP_WATER) &&
5409                                  (c_ptr->feat <= FEAT_GRASS))))
5410
5411                         {
5412                                 /* Looking to break left */
5413                                 if (find_breakleft)
5414                                 {
5415                                         return (TRUE);
5416                                 }
5417                         }
5418
5419                         /* Obstacle */
5420                         else
5421                         {
5422                                 /* Looking to break right */
5423                                 if (find_breakright)
5424                                 {
5425                                         return (TRUE);
5426                                 }
5427                         }
5428                 }
5429         }
5430
5431
5432         /* Not looking for open area */
5433         else
5434         {
5435                 /* No options */
5436                 if (!option)
5437                 {
5438                         return (TRUE);
5439                 }
5440
5441                 /* One option */
5442                 else if (!option2)
5443                 {
5444                         /* Primary option */
5445                         find_current = option;
5446
5447                         /* No other options */
5448                         find_prevdir = option;
5449                 }
5450
5451                 /* Two options, examining corners */
5452                 else if (find_examine && !find_cut)
5453                 {
5454                         /* Primary option */
5455                         find_current = option;
5456
5457                         /* Hack -- allow curving */
5458                         find_prevdir = option2;
5459                 }
5460
5461                 /* Two options, pick one */
5462                 else
5463                 {
5464                         /* Get next location */
5465                         row = py + ddy[option];
5466                         col = px + ddx[option];
5467
5468                         /* Don't see that it is closed off. */
5469                         /* This could be a potential corner or an intersection. */
5470                         if (!see_wall(option, row, col) ||
5471                             !see_wall(check_dir, row, col))
5472                         {
5473                                 /* Can not see anything ahead and in the direction we */
5474                                 /* are turning, assume that it is a potential corner. */
5475                                 if (find_examine &&
5476                                     see_nothing(option, row, col) &&
5477                                     see_nothing(option2, row, col))
5478                                 {
5479                                         find_current = option;
5480                                         find_prevdir = option2;
5481                                 }
5482
5483                                 /* STOP: we are next to an intersection or a room */
5484                                 else
5485                                 {
5486                                         return (TRUE);
5487                                 }
5488                         }
5489
5490                         /* This corner is seen to be enclosed; we cut the corner. */
5491                         else if (find_cut)
5492                         {
5493                                 find_current = option2;
5494                                 find_prevdir = option2;
5495                         }
5496
5497                         /* This corner is seen to be enclosed, and we */
5498                         /* deliberately go the long way. */
5499                         else
5500                         {
5501                                 find_current = option;
5502                                 find_prevdir = option2;
5503                         }
5504                 }
5505         }
5506
5507
5508         /* About to hit a known wall, stop */
5509         if (see_wall(find_current, py, px))
5510         {
5511                 return (TRUE);
5512         }
5513
5514
5515         /* Failure */
5516         return (FALSE);
5517 }
5518
5519
5520
5521 /*
5522  * Take one step along the current "run" path
5523  */
5524 void run_step(int dir)
5525 {
5526         /* Start running */
5527         if (dir)
5528         {
5529                 /* Hack -- do not start silly run */
5530                 if (see_wall(dir, py, px) &&
5531                    (cave[py+ddy[dir]][px+ddx[dir]].feat != FEAT_TREES))
5532                 {
5533                         /* Message */
5534 #ifdef JP
5535                         msg_print("¤½¤ÎÊý¸þ¤Ë¤Ï¹Ô¤±¤Þ¤»¤ó¡£");
5536 #else
5537                         msg_print("You cannot run in that direction.");
5538 #endif
5539
5540
5541                         /* Disturb */
5542                         disturb(0, 0);
5543
5544                         /* Done */
5545                         return;
5546                 }
5547
5548                 /* Calculate torch radius */
5549                 p_ptr->update |= (PU_TORCH);
5550
5551                 /* Initialize */
5552                 run_init(dir);
5553         }
5554
5555         /* Keep running */
5556         else
5557         {
5558                 /* Update run */
5559                 if (run_test())
5560                 {
5561                         /* Disturb */
5562                         disturb(0, 0);
5563
5564                         /* Done */
5565                         return;
5566                 }
5567         }
5568
5569         /* Decrease the run counter */
5570         if (--running <= 0) return;
5571
5572         /* Take time */
5573         energy_use = 100;
5574
5575         /* Move the player, using the "pickup" flag */
5576 #ifdef ALLOW_EASY_DISARM /* TNB */
5577
5578         move_player(find_current, FALSE, FALSE);
5579
5580 #else /* ALLOW_EASY_DISARM -- TNB */
5581
5582         move_player(find_current, always_pickup, FALSE);
5583
5584 #endif /* ALLOW_EASY_DISARM -- TNB */
5585
5586         if ((py == p_ptr->run_py) && (px == p_ptr->run_px))
5587         {
5588                 p_ptr->run_py = 0;
5589                 p_ptr->run_px = 0;
5590                 disturb(0, 0);
5591         }
5592 }