OSDN Git Service

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