OSDN Git Service

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