OSDN Git Service

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