OSDN Git Service

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