OSDN Git Service

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