OSDN Git Service

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