OSDN Git Service

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