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