OSDN Git Service

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