OSDN Git Service

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