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