OSDN Git Service

[Refactor] #37353 未使用構造体 dun_type 削除。 / Delete dun_type, unused structure.
[hengband/hengband.git] / src / mspells1.c
index d862b00..9c9f565 100644 (file)
@@ -1,6 +1,6 @@
-/*!
+/*!
  * @file mspells1.c
- * @brief ¥â¥ó¥¹¥¿¡¼ËâË¡¤Î¼ÂÁõ / Monster spells (attack player)
+ * @brief モンスター魔法の実装 / Monster spells (attack player)
  * @date 2014/01/17
  * @author
  * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke\n
  */
 
 #include "angband.h"
+#include "object-curse.h"
+#include "projection.h"
+#include "quest.h"
+#include "realm-hex.h"
 
 
 /*!
- * @brief ¥â¥ó¥¹¥¿¡¼¤¬¥×¥ì¥¤¥ä¡¼¤Î¼åÅÀ¤ò¤Ä¤¤¤¿ÁªÂò¤ò¼è¤ë¤«¤É¤¦¤«¤ÎȽÄê /
+ * @brief モンスターがプレイヤーの弱点をついた選択を取るかどうかの判定 /
  * Internal probability routine
- * @param r_ptr ¥â¥ó¥¹¥¿¡¼¼ï²¤Î¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
- * @param prob ´ðËܳÎΨ(%)
- * @return Å¬¤·¤¿ÁªÂò¤ò¼è¤ë¤Ê¤é¤ÐTRUE¤òÊÖ¤¹¡£
+ * @param r_ptr ã\83¢ã\83³ã\82¹ã\82¿ã\83¼ç¨®æ\97\8fã\81®æ§\8bé\80 ä½\93å\8f\82ç\85§ã\83\9dã\82¤ã\83³ã\82¿
+ * @param prob 基本確率(%)
+ * @return 適した選択を取るならばTRUEを返す。
  */
-static bool int_outof(monster_race *r_ptr, int prob)
+static bool int_outof(monster_race *r_ptr, PERCENTAGE prob)
 {
        /* Non-Smart monsters are half as "smart" */
        if (!(r_ptr->flags2 & RF2_SMART)) prob = prob / 2;
@@ -59,15 +63,15 @@ static bool int_outof(monster_race *r_ptr, int prob)
 
 
 /*!
- * @brief ¥â¥ó¥¹¥¿¡¼¤ÎËâË¡°ìÍ÷¤«¤éÀï½ÑŪ¤ËŬ¤µ¤Ê¤¤ËâË¡¤ò½ü³°¤¹¤ë /
+ * @brief モンスターの魔法一覧から戦術的に適さない魔法を除外する /
  * Remove the "bad" spells from a spell list
- * @param m_idx ¥â¥ó¥¹¥¿¡¼¤Î¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
- * @param f4p ¥â¥ó¥¹¥¿¡¼ËâË¡¤Î¥Õ¥é¥°¥ê¥¹¥È1
- * @param f5p ¥â¥ó¥¹¥¿¡¼ËâË¡¤Î¥Õ¥é¥°¥ê¥¹¥È2
- * @param f6p ¥â¥ó¥¹¥¿¡¼ËâË¡¤Î¥Õ¥é¥°¥ê¥¹¥È3
- * @return ¤Ê¤·
+ * @param m_idx ã\83¢ã\83³ã\82¹ã\82¿ã\83¼ã\81®æ§\8bé\80 ä½\93å\8f\82ç\85§ã\83\9dã\82¤ã\83³ã\82¿
+ * @param f4p モンスター魔法のフラグリスト1
+ * @param f5p モンスター魔法のフラグリスト2
+ * @param f6p モンスター魔法のフラグリスト3
+ * @return なし
  */
-static void remove_bad_spells(int m_idx, u32b *f4p, u32b *f5p, u32b *f6p)
+static void remove_bad_spells(MONSTER_IDX m_idx, u32b *f4p, u32b *f5p, u32b *f6p)
 {
        monster_type *m_ptr = &m_list[m_idx];
        monster_race *r_ptr = &r_info[m_ptr->r_idx];
@@ -332,7 +336,6 @@ static void remove_bad_spells(int m_idx, u32b *f4p, u32b *f5p, u32b *f6p)
                if (int_outof(r_ptr, 150)) f5 &= ~(RF5_BO_PLAS);
                if (int_outof(r_ptr, 150)) f5 &= ~(RF5_BO_ICEE);
                if (int_outof(r_ptr, 150)) f5 &= ~(RF5_MISSILE);
-               if (int_outof(r_ptr, 150)) f4 &= ~(RF4_SHOOT);
        }
 
        if (smart & (SM_IMM_FREE))
@@ -346,7 +349,7 @@ static void remove_bad_spells(int m_idx, u32b *f4p, u32b *f5p, u32b *f6p)
                f5 &= ~(RF5_DRAIN_MANA);
        }
 
-       /* XXX XXX XXX No spells left? */
+       /* No spells left? */
        /* if (!f4 && !f5 && !f6) ... */
 
        (*f4p) = f4;
@@ -356,15 +359,15 @@ static void remove_bad_spells(int m_idx, u32b *f4p, u32b *f5p, u32b *f6p)
 
 
 /*!
- * @brief ¥â¥ó¥¹¥¿¡¼¤Ë¤È¤Ã¤Æ½êÄê¤ÎÃÏÅÀ¤¬¾¤´Ô¤ËÁê±þ¤·¤¤ÃÏÅÀ¤«¤É¤¦¤«¤òÊÖ¤¹¡£ /
+ * @brief モンスターにとって所定の地点が召還に相応しい地点かどうかを返す。 /
  * Determine if there is a space near the player in which a summoned creature can appear
- * @param y1 È½Äê¤ò¹Ô¤¤¤¿¤¤¥Þ¥¹¤ÎYºÂɸ
- * @param x1 È½Äê¤ò¹Ô¤¤¤¿¤¤¥Þ¥¹¤ÎXºÂɸ
- * @return ¾¤´Ô¤ËÁê±þ¤·¤¤¤Ê¤é¤ÐTRUE¤òÊÖ¤¹
+ * @param y1 判定を行いたいマスのY座標
+ * @param x1 判定を行いたいマスのX座標
+ * @return 召還に相応しいならばTRUEを返す
  */
-bool summon_possible(int y1, int x1)
+bool summon_possible(POSITION y1, POSITION x1)
 {
-       int y, x;
+       POSITION y, x;
 
        /* Start at the player's location, and check 2 grids in each dir */
        for (y = y1 - 2; y <= y1 + 2; y++)
@@ -390,17 +393,17 @@ bool summon_possible(int y1, int x1)
 
 
 /*!
- * @brief ¥â¥ó¥¹¥¿¡¼¤Ë¤È¤Ã¤Æ»à¼ÔÉü³è¤ò¹Ô¤¦¤Ù¤­¾õÂÖ¤«¤É¤¦¤«¤òÊÖ¤¹ /
+ * @brief モンスターにとって死者復活を行うべき状態かどうかを返す /
  * Determine if there is a space near the player in which a summoned creature can appear
- * @param m_ptr È½Äê¤ò¹Ô¤¤¤¿¤¤¥â¥ó¥¹¥¿¡¼¤Î¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
- * @return »à¼ÔÉü³è¤¬Í­¸ú¤Ê¾õÂ֤ʤé¤ÐTRUE¤òÊÖ¤¹¡£
+ * @param m_ptr å\88¤å®\9aã\82\92è¡\8cã\81\84ã\81\9fã\81\84ã\83¢ã\83³ã\82¹ã\82¿ã\83¼ã\81®æ§\8bé\80 ä½\93å\8f\82ç\85§ã\83\9dã\82¤ã\83³ã\82¿
+ * @return 死者復活が有効な状態ならばTRUEを返す。
  */
 bool raise_possible(monster_type *m_ptr)
 {
-       int xx, yy;
-       int y = m_ptr->fy;
-       int x = m_ptr->fx;
-       s16b this_o_idx, next_o_idx = 0;
+       POSITION xx, yy;
+       POSITION y = m_ptr->fy;
+       POSITION x = m_ptr->fx;
+       OBJECT_IDX this_o_idx, next_o_idx = 0;
        cave_type *c_ptr;
 
        for (xx = x - 5; xx <= x + 5; xx++)
@@ -415,7 +418,6 @@ bool raise_possible(monster_type *m_ptr)
                        /* Scan the pile of objects */
                        for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
                        {
-                               /* Acquire object */
                                object_type *o_ptr = &o_list[this_o_idx];
 
                                /* Acquire next object */
@@ -435,14 +437,14 @@ bool raise_possible(monster_type *m_ptr)
 
 
 /*!
- * @brief ¥â¥ó¥¹¥¿¡¼¤Ë¤È¤Ã¤Æ¥Ü¥ë¥È·¿ËâË¡¤¬Í­¸ú¤Ê¾õÂÖ¤«¤òÊÖ¤¹ /
+ * @brief モンスターにとってボルト型魔法が有効な状態かを返す /
  * Determine if a bolt spell will hit the player.
- * @param y1 ¥Ü¥ë¥ÈËâˡȯ¼ÍÃÏÅÀ¤ÎYºÂɸ
- * @param x1 ¥Ü¥ë¥ÈËâˡȯ¼ÍÃÏÅÀ¤ÎXºÂɸ
- * @param y2 ¥Ü¥ë¥ÈËâË¡ÌÜɸÃÏÅÀ¤ÎYºÂɸ
- * @param x2 ¥Ü¥ë¥ÈËâË¡ÌÜɸÃÏÅÀ¤ÎXºÂɸ
- * @param is_friend ¥â¥ó¥¹¥¿¡¼¤¬¥×¥ì¥¤¥ä¡¼¤Ë³²°Õ¤ò»ý¤¿¤Ê¤¤(¥Ú¥Ã¥È¤«Í§¹¥Åª)¤Ê¤é¤ÐTRUE¤ò¤Ä¤±¤ë
- * @return ¥Ü¥ë¥È·¿ËâË¡¤¬Í­¸ú¤Ê¤é¤ÐTRUE¤òÊÖ¤¹¡£
+ * @param y1 ボルト魔法発射地点のY座標
+ * @param x1 ボルト魔法発射地点のX座標
+ * @param y2 ボルト魔法目標地点のY座標
+ * @param x2 ボルト魔法目標地点のX座標
+ * @param is_friend モンスターがプレイヤーに害意を持たない(ペットか友好的)ならばTRUEをつける
+ * @return ボルト型魔法が有効ならばTRUEを返す。
  * @details
  * Originally, it was possible for a friendly to shoot another friendly.\n
  * Change it so a "clean shot" means no equally friendly monster is\n
@@ -453,11 +455,12 @@ bool raise_possible(monster_type *m_ptr)
  * no equally friendly monster is\n
  * between the attacker and target.\n
  */
-bool clean_shot(int y1, int x1, int y2, int x2, bool is_friend)
+bool clean_shot(POSITION y1, POSITION x1, POSITION y2, POSITION x2, bool is_friend)
 {
        /* Must be the same as projectable() */
 
-       int i, y, x;
+       int i;
+       POSITION y, x;
 
        int grid_n = 0;
        u16b grid_g[512];
@@ -499,20 +502,20 @@ bool clean_shot(int y1, int x1, int y2, int x2, bool is_friend)
 }
 
 /*!
- * @brief ¥â¥ó¥¹¥¿¡¼¤Î¥Ü¥ë¥È·¿ËâË¡½èÍý /
+ * @brief モンスターのボルト型魔法処理 /
  * Cast a bolt at the player Stop if we hit a monster Affect monsters and the player
- * @param m_idx ¥â¥ó¥¹¥¿¡¼¤ÎID
- * @param y ÌÜɸ¤ÎYºÂɸ
- * @param x ÌÜɸ¤ÎXºÂɸ
- * @param typ ¸ú²Ì°À­ID
- * @param dam_hp °ÒÎÏ
- * @param monspell ¥â¥ó¥¹¥¿¡¼ËâË¡¤ÎID
- * @param target_type ¥â¥ó¥¹¥¿¡¼¤«¤é¥â¥ó¥¹¥¿¡¼¤Ø·â¤Ä¤Ê¤éMONSTER_TO_MONSTER¡¢¥â¥ó¥¹¥¿¡¼¤«¤é¥×¥ì¥¤¥ä¡¼¤Ê¤éMONSTER_TO_PLAYER
- * @return ¤Ê¤·
+ * @param m_idx モンスターのID
+ * @param y 目標のY座標
+ * @param x 目標のX座標
+ * @param typ 効果属性ID
+ * @param dam_hp 威力
+ * @param monspell モンスター魔法のID
+ * @param target_type モンスターからモンスターへ撃つならMONSTER_TO_MONSTER、モンスターからプレイヤーならMONSTER_TO_PLAYER
+ * @return なし
  */
-void bolt(int m_idx, int y, int x, int typ, int dam_hp, int monspell, int target_type)
+void bolt(MONSTER_IDX m_idx, POSITION y, POSITION x, EFFECT_ID typ, int dam_hp, int monspell, int target_type)
   {
-    int flg;
+    BIT_FLAGS flg = 0;
     bool learnable = spell_learnable(m_idx);
 
     switch (target_type)
@@ -531,19 +534,19 @@ void bolt(int m_idx, int y, int x, int typ, int dam_hp, int monspell, int target
 }
 
 /*!
- * @brief ¥â¥ó¥¹¥¿¡¼¤Î¥Ó¡¼¥à·¿ËâË¡½èÍý /
- * @param m_idx ¥â¥ó¥¹¥¿¡¼¤ÎID
- * @param y ÌÜɸ¤ÎYºÂɸ
- * @param x ÌÜɸ¤ÎXºÂɸ
- * @param typ ¸ú²Ì°À­ID
- * @param dam_hp °ÒÎÏ
- * @param monspell ¥â¥ó¥¹¥¿¡¼ËâË¡¤ÎID
- * @param target_type ¥â¥ó¥¹¥¿¡¼¤«¤é¥â¥ó¥¹¥¿¡¼¤Ø·â¤Ä¤Ê¤éMONSTER_TO_MONSTER¡¢¥â¥ó¥¹¥¿¡¼¤«¤é¥×¥ì¥¤¥ä¡¼¤Ê¤éMONSTER_TO_PLAYER
- * @return ¤Ê¤·
+ * @brief モンスターのビーム型魔法処理 /
+ * @param m_idx モンスターのID
+ * @param y 目標のY座標
+ * @param x 目標のX座標
+ * @param typ 効果属性ID
+ * @param dam_hp 威力
+ * @param monspell モンスター魔法のID
+ * @param target_type モンスターからモンスターへ撃つならMONSTER_TO_MONSTER、モンスターからプレイヤーならMONSTER_TO_PLAYER
+ * @return なし
  */
-void beam(int m_idx, int y, int x, int typ, int dam_hp, int monspell, int target_type)
+void beam(MONSTER_IDX m_idx, POSITION y, POSITION x, EFFECT_ID typ, int dam_hp, int monspell, int target_type)
 {
-    int flg;
+    BIT_FLAGS flg = 0;
     bool learnable = spell_learnable(m_idx);
 
     switch (target_type)
@@ -562,25 +565,25 @@ void beam(int m_idx, int y, int x, int typ, int dam_hp, int monspell, int target
 
 
 /*!
- * @brief ¥â¥ó¥¹¥¿¡¼¤Î¥Ü¡¼¥ë·¿¡õ¥Ö¥ì¥¹·¿ËâË¡½èÍý /
+ * @brief モンスターのボール型&ブレス型魔法処理 /
  * Cast a breath (or ball) attack at the player Pass over any monsters that may be in the way Affect grids, objects, monsters, and the player
- * @param y ÌÜɸÃÏÅÀ¤ÎYºÂɸ
- * @param x ÌÜɸÃÏÅÀ¤ÎXºÂɸ
- * @param m_idx ¥â¥ó¥¹¥¿¡¼¤ÎID
- * @param typ ¸ú²Ì°À­ID
- * @param dam_hp °ÒÎÏ
- * @param rad È¾·Â
- * @param breath TRUE¤Ê¤é¤Ð¥Ö¡¦E¹½èÍ¡¦¡¥ALSE¤Ê¤é¤Ð¥Ü¡¼¡¦EèÍ
- * @param monspell ¥â¥ó¥¹¥¿¡¼ËâË¡¤ÎID
- * @param target_type ¥â¥ó¥¹¥¿¡¼¤«¤é¥â¥ó¥¹¥¿¡¼¤Ø·â¤Ä¤Ê¤éMONSTER_TO_MONSTER¡¢¥â¥ó¥¹¥¿¡¼¤«¤é¥×¥ì¥¤¥ä¡¼¤Ê¤éMONSTER_TO_PLAYER
- * @return ¤Ê¤·
+ * @param y 目標地点のY座標
+ * @param x 目標地点のX座標
+ * @param m_idx モンスターのID
+ * @param typ 効果属性ID
+ * @param dam_hp 威力
+ * @param rad 半径
+ * @param breath 
+ * @param monspell モンスター魔法のID
+ * @param target_type モンスターからモンスターへ撃つならMONSTER_TO_MONSTER、モンスターからプレイヤーならMONSTER_TO_PLAYER
+ * @return なし
  */
-void breath(int y, int x, int m_idx, int typ, int dam_hp, int rad, bool breath, int monspell, int target_type)
+void breath(POSITION y, POSITION x, MONSTER_IDX m_idx, EFFECT_ID typ, int dam_hp, POSITION rad, bool breath, int monspell, int target_type)
 {
     monster_type *m_ptr = &m_list[m_idx];
     monster_race *r_ptr = &r_info[m_ptr->r_idx];
     bool learnable = spell_learnable(m_idx);
-       int flg;
+       BIT_FLAGS flg = 0x00;
 
     switch (target_type)
     {
@@ -619,118 +622,14 @@ void breath(int y, int x, int m_idx, int typ, int dam_hp, int rad, bool breath,
        (void)project(m_idx, rad, y, x, dam_hp, typ, flg, (learnable ? monspell : -1));
 }
 
-/*!
- * @brief ¥â¥ó¥¹¥¿¡¼¤Î¥Ü¡¼¥ë·¿¡õ¥Ö¥ì¥¹·¿ËâË¡½èÍý /
- * @param power ¼ö¤¤¤ÎÃʳ¬
- * @param o_ptr ¼ö¤¤¤ò¤«¤±¤é¤ì¤ëÁõÈ÷¥ª¥Ö¥¸¥§¥¯¥È¤Î¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
- * @return Í¿¤¨¤ë¼ö¤¤¤ÎID
- */
-u32b get_curse(int power, object_type *o_ptr)
-{
-       u32b new_curse;
-
-       while(1)
-       {
-               new_curse = (1 << (randint0(MAX_CURSE)+4));
-               if (power == 2)
-               {
-                       if (!(new_curse & TRC_HEAVY_MASK)) continue;
-               }
-               else if (power == 1)
-               {
-                       if (new_curse & TRC_SPECIAL_MASK) continue;
-               }
-               else if (power == 0)
-               {
-                       if (new_curse & TRC_HEAVY_MASK) continue;
-               }
-               if (new_curse == TRC_LOW_MELEE && !object_is_weapon(o_ptr)) continue;
-               if (new_curse == TRC_LOW_AC && !object_is_armour(o_ptr)) continue;
-               break;
-       }
-       return new_curse;
-}
-
-/*!
- * @brief ÁõÈ÷¤Ø¤Î¼ö¤¤ÉÕ²ÃȽÄê¤ÈÉղýèÍý /
- * @param chance ¼ö¤¤¤Î´ðËܳÎΨ
- * @param heavy_chance ½Å¤¤¼ö¤¤¤òÁªÂò»è¤ËÆþ¤ì¤ë¤«Èݤ«¡£
- * @return ¤Ê¤·
- */
-void curse_equipment(int chance, int heavy_chance)
-{
-       bool        changed = FALSE;
-       int         curse_power = 0;
-       u32b        new_curse;
-       u32b oflgs[TR_FLAG_SIZE];
-       object_type *o_ptr = &inventory[INVEN_RARM + randint0(12)];
-       char o_name[MAX_NLEN];
-
-       if (randint1(100) > chance) return;
-
-       if (!o_ptr->k_idx) return;
-
-       object_flags(o_ptr, oflgs);
 
-       object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
-
-       /* Extra, biased saving throw for blessed items */
-       if (have_flag(oflgs, TR_BLESSED) && (randint1(888) > chance))
-       {
-#ifdef JP
-msg_format("%s¤Ï¼ö¤¤¤òÄ·¤ÍÊÖ¤·¤¿¡ª", o_name,
-#else
-               msg_format("Your %s resist%s cursing!", o_name,
-#endif
-
-                       ((o_ptr->number > 1) ? "" : "s"));
-               /* Hmmm -- can we wear multiple items? If not, this is unnecessary */
-               return;
-       }
-
-       if ((randint1(100) <= heavy_chance) &&
-           (object_is_artifact(o_ptr) || object_is_ego(o_ptr)))
-       {
-               if (!(o_ptr->curse_flags & TRC_HEAVY_CURSE))
-                       changed = TRUE;
-               o_ptr->curse_flags |= TRC_HEAVY_CURSE;
-               o_ptr->curse_flags |= TRC_CURSED;
-               curse_power++;
-       }
-       else
-       {
-               if (!object_is_cursed(o_ptr))
-                       changed = TRUE;
-               o_ptr->curse_flags |= TRC_CURSED;
-       }
-       if (heavy_chance >= 50) curse_power++;
-
-       new_curse = get_curse(curse_power, o_ptr);
-       if (!(o_ptr->curse_flags & new_curse))
-       {
-               changed = TRUE;
-               o_ptr->curse_flags |= new_curse;
-       }
-
-       if (changed)
-       {
-#ifdef JP
-msg_format("°­°Õ¤ËËþ¤Á¤¿¹õ¤¤¥ª¡¼¥é¤¬%s¤ò¤È¤ê¤Þ¤¤¤¿...", o_name);
-#else
-               msg_format("There is a malignant black aura surrounding %s...", o_name);
-#endif
-
-               o_ptr->feeling = FEEL_NONE;
-       }
-       p_ptr->update |= (PU_BONUS);
-}
 
 
 /*!
- * @brief IDÃͤ¬Àµ¤·¤¤¥â¥ó¥¹¥¿¡¼ËâË¡ID¤«¤É¤¦¤«¤òÊÖ¤¹ /
+ * @brief ID値が正しいモンスター魔法IDかどうかを返す /
  * Return TRUE if a spell is good for hurting the player (directly).
- * @param spell È½ÄêÂоݤÎID
- * @return Àµ¤·¤¤ID¤Ê¤é¤ÐTRUE¤òÊÖ¤¹¡£
+ * @param spell 判定対象のID
+ * @return 正しいIDならばTRUEを返す。
  */
 static bool spell_attack(byte spell)
 {
@@ -755,10 +654,10 @@ static bool spell_attack(byte spell)
 
 
 /*!
- * @brief IDÃͤ¬ÂàÈòÌÜŪ¤ËŬ¤·¤¿¥â¥ó¥¹¥¿¡¼ËâË¡ID¤«¤É¤¦¤«¤òÊÖ¤¹ /
+ * @brief ID値が退避目的に適したモンスター魔法IDかどうかを返す /
  * Return TRUE if a spell is good for escaping.
- * @param spell È½ÄêÂоݤÎID
- * @return Å¬¤·¤¿ËâË¡¤ÎID¤Ê¤é¤ÐTRUE¤òÊÖ¤¹¡£
+ * @param spell 判定対象のID
+ * @return 適した魔法のIDならばTRUEを返す。
  */
 static bool spell_escape(byte spell)
 {
@@ -773,10 +672,10 @@ static bool spell_escape(byte spell)
 }
 
 /*!
- * @brief IDÃͤ¬Ë¸³²ÌÜŪ¤ËŬ¤·¤¿¥â¥ó¥¹¥¿¡¼ËâË¡ID¤«¤É¤¦¤«¤òÊÖ¤¹ /
+ * @brief ID値が妨害目的に適したモンスター魔法IDかどうかを返す /
  * Return TRUE if a spell is good for annoying the player.
- * @param spell È½ÄêÂоݤÎID
- * @return Å¬¤·¤¿ËâË¡¤ÎID¤Ê¤é¤ÐTRUE¤òÊÖ¤¹¡£
+ * @param spell 判定対象のID
+ * @return 適した魔法のIDならばTRUEを返す。
  */
 static bool spell_annoy(byte spell)
 {
@@ -803,10 +702,10 @@ static bool spell_annoy(byte spell)
 }
 
 /*!
- * @brief IDÃͤ¬¾¤´­·¿¤Î¥â¥ó¥¹¥¿¡¼ËâË¡ID¤«¤É¤¦¤«¤òÊÖ¤¹ /
+ * @brief ID値が召喚型のモンスター魔法IDかどうかを返す /
  * Return TRUE if a spell is good for annoying the player.
- * @param spell È½ÄêÂоݤÎID
- * @return ¾¤´­·¿ËâË¡¤ÎID¤Ê¤é¤ÐTRUE¤òÊÖ¤¹¡£
+ * @param spell 判定対象のID
+ * @return 召喚型魔法のIDならばTRUEを返す。
  */
 static bool spell_summon(byte spell)
 {
@@ -819,10 +718,10 @@ static bool spell_summon(byte spell)
 
 
 /*!
- * @brief IDÃͤ¬»à¼ÔÉü³è½èÍý¤«¤É¤¦¤«¤òÊÖ¤¹ /
+ * @brief ID値が死者復活処理かどうかを返す /
  * Return TRUE if a spell is good for annoying the player.
- * @param spell È½ÄêÂоݤÎID
- * @return »à¼ÔÉü³è¤Î½èÍý¤Ê¤é¤ÐTRUE¤òÊÖ¤¹¡£
+ * @param spell 判定対象のID
+ * @return 死者復活の処理ならばTRUEを返す。
  */
 static bool spell_raise(byte spell)
 {
@@ -834,10 +733,10 @@ static bool spell_raise(byte spell)
 }
 
 /*!
- * @brief IDÃͤ¬Àï½ÑŪ¤Ê¥â¥ó¥¹¥¿¡¼ËâË¡ID¤«¤É¤¦¤«¤òÊÖ¤¹ /
+ * @brief ID値が戦術的なモンスター魔法IDかどうかを返す /
  * Return TRUE if a spell is good in a tactical situation.
- * @param spell È½ÄêÂоݤÎID
- * @return Àï½ÑŪ¤ÊËâË¡¤ÎID¤Ê¤é¤ÐTRUE¤òÊÖ¤¹¡£
+ * @param spell 判定対象のID
+ * @return 戦術的な魔法のIDならばTRUEを返す。
  */
 static bool spell_tactic(byte spell)
 {
@@ -849,10 +748,10 @@ static bool spell_tactic(byte spell)
 }
 
 /*!
- * @brief IDÃͤ¬ÌµÅ¨²½¤¹¤ë¥â¥ó¥¹¥¿¡¼ËâË¡ID¤«¤É¤¦¤«¤òÊÖ¤¹ /
+ * @brief ID値が無敵化するモンスター魔法IDかどうかを返す /
  * Return TRUE if a spell makes invulnerable.
- * @param spell È½ÄêÂоݤÎID
- * @return ¾¤´­·¿ËâË¡¤ÎID¤Ê¤é¤ÐTRUE¤òÊÖ¤¹¡£
+ * @param spell 判定対象のID
+ * @return 召喚型魔法のIDならばTRUEを返す。
  */
 static bool spell_invulner(byte spell)
 {
@@ -864,10 +763,10 @@ static bool spell_invulner(byte spell)
 }
 
 /*!
- * @brief IDÃͤ¬²Ã®¤¹¤ë¥â¥ó¥¹¥¿¡¼ËâË¡ID¤«¤É¤¦¤«¤òÊÖ¤¹ /
+ * @brief ID値が加速するモンスター魔法IDかどうかを返す /
  * Return TRUE if a spell hastes.
- * @param spell È½ÄêÂоݤÎID
- * @return ¾¤´­·¿ËâË¡¤ÎID¤Ê¤é¤ÐTRUE¤òÊÖ¤¹¡£
+ * @param spell 判定対象のID
+ * @return 召喚型魔法のIDならばTRUEを返す。
  */
 static bool spell_haste(byte spell)
 {
@@ -880,10 +779,10 @@ static bool spell_haste(byte spell)
 
 
 /*!
- * @brief IDÃͤ¬»þ´ÖÄä»ß¤ò¹Ô¤¦¥â¥ó¥¹¥¿¡¼ËâË¡ID¤«¤É¤¦¤«¤òÊÖ¤¹ /
+ * @brief ID値が時間停止を行うモンスター魔法IDかどうかを返す /
  * Return TRUE if a spell world.
- * @param spell È½ÄêÂоݤÎID
- * @return »þ´ÖÄä»ßËâË¡¤ÎID¤Ê¤é¤ÐTRUE¤òÊÖ¤¹¡£
+ * @param spell 判定対象のID
+ * @return 時間停止魔法のIDならばTRUEを返す。
  */
 static bool spell_world(byte spell)
 {
@@ -893,10 +792,10 @@ static bool spell_world(byte spell)
 
 
 /*!
- * @brief IDÃͤ¬ÆÃÊ̸ú²Ì¤Î¥â¥ó¥¹¥¿¡¼ËâË¡ID¤«¤É¤¦¤«¤òÊÖ¤¹ /
+ * @brief ID値が特別効果のモンスター魔法IDかどうかを返す /
  * Return TRUE if a spell special.
- * @param spell È½ÄêÂоݤÎID
- * @return ÆÃÊ̸ú²ÌËâË¡¤ÎID¤Ê¤é¤ÐTRUE¤òÊÖ¤¹¡£
+ * @param spell 判定対象のID
+ * @return 特別効果魔法のIDならばTRUEを返す。
  */
 static bool spell_special(byte spell)
 {
@@ -907,10 +806,10 @@ static bool spell_special(byte spell)
 
 
 /*!
- * @brief IDÃͤ¬¸÷¤Î·õ¤Î¥â¥ó¥¹¥¿¡¼ËâË¡ID¤«¤É¤¦¤«¤òÊÖ¤¹ /
+ * @brief ID値が光の剣のモンスター魔法IDかどうかを返す /
  * Return TRUE if a spell psycho-spear.
- * @param spell È½ÄêÂоݤÎID
- * @return ¸÷¤Î·õ¤ÎID¤Ê¤é¤ÐTRUE¤òÊÖ¤¹¡£
+ * @param spell 判定対象のID
+ * @return 光の剣のIDならばTRUEを返す。
  */
 static bool spell_psy_spe(byte spell)
 {
@@ -923,10 +822,10 @@ static bool spell_psy_spe(byte spell)
 
 
 /*!
- * @brief IDÃͤ¬¼£ÌþËâË¡¤«¤É¤¦¤«¤òÊÖ¤¹ /
+ * @brief ID値が治癒魔法かどうかを返す /
  * Return TRUE if a spell is good for healing.
- * @param spell È½ÄêÂоݤÎID
- * @return ¼£ÌþËâË¡¤ÎID¤Ê¤é¤ÐTRUE¤òÊÖ¤¹¡£
+ * @param spell 判定対象のID
+ * @return 治癒魔法のIDならばTRUEを返す。
  */
 static bool spell_heal(byte spell)
 {
@@ -939,10 +838,10 @@ static bool spell_heal(byte spell)
 
 
 /*!
- * @brief IDÃͤ¬ËâÎϾõ¤É¤¦¤«¤òÊÖ¤¹ /
+ * @brief ID値が魔力消去かどうかを返す /
  * Return TRUE if a spell is good for dispel.
- * @param spell È½ÄêÂоݤÎID
- * @return ËâÎϾõî¤ÎID¤Ê¤é¤ÐTRUE¤òÊÖ¤¹¡£
+ * @param spell 判定対象のID
+ * @return 魔力消去のIDならばTRUEを返す。
  */
 static bool spell_dispel(byte spell)
 {
@@ -955,12 +854,12 @@ static bool spell_dispel(byte spell)
 
 
 /*!
- * @brief ¥â¥ó¥¹¥¿¡¼¤¬¥×¥ì¥¤¥ä¡¼¤ËËâÎϾõî¤òÍ¿¤¨¤ë¤Ù¤­¤«¤òȽÄꤹ¤ë¥ë¡¼¥Á¥ó
+ * @brief モンスターがプレイヤーに魔力消去を与えるべきかを判定するルーチン
  * Check should monster cast dispel spell.
- * @param m_idx ¥â¥ó¥¹¥¿¡¼¤Î¹½Â¤ÂÎÇÛÎóID
- * @return ËâÎϾõî¤ò¤«¤±¤ë¤Ù¤­¤Ê¤éTRUE¤òÊÖ¤¹¡£
+ * @param m_idx モンスターの構造体配列ID
+ * @return 魔力消去をかけるべきならTRUEを返す。
  */
-bool dispel_check(int m_idx)
+bool dispel_check(MONSTER_IDX m_idx)
 {
        monster_type *m_ptr = &m_list[m_idx];
        monster_race *r_ptr = &r_info[m_ptr->r_idx];
@@ -1059,12 +958,12 @@ bool dispel_check(int m_idx)
 
 
 /*!
- * @brief ¥â¥ó¥¹¥¿¡¼¤ÎËâË¡ÁªÂò¥ë¡¼¥Á¥ó
+ * @brief モンスターの魔法選択ルーチン
  * Have a monster choose a spell from a list of "useful" spells.
- * @param m_idx ¥â¥ó¥¹¥¿¡¼¤Î¹½Â¤ÂÎÇÛÎóID
- * @param spells ¸õÊäËâË¡ID¤ò¤Þ¤È¤á¤¿ÇÛÎó
- * @param num spells¤ÎŤµ
- * @return ÁªÂò¤·¤¿¥â¥ó¥¹¥¿¡¼ËâË¡¤ÎID
+ * @param m_idx モンスターの構造体配列ID
+ * @param spells 候補魔法IDをまとめた配列
+ * @param num spellsの長さ
+ * @return 選択したモンスター魔法のID
  * @details
  * Note that this list does NOT include spells that will just hit\n
  * other monsters, and the list is restricted when the monster is\n
@@ -1077,7 +976,7 @@ bool dispel_check(int m_idx)
  *\n
  * This function may well be an efficiency bottleneck.\n
  */
-static int choose_attack_spell(int m_idx, byte spells[], byte num)
+static int choose_attack_spell(MONSTER_IDX m_idx, byte spells[], byte num)
 {
        monster_type *m_ptr = &m_list[m_idx];
        monster_race *r_ptr = &r_info[m_ptr->r_idx];
@@ -1210,7 +1109,7 @@ static int choose_attack_spell(int m_idx, byte spells[], byte num)
        }
 
        /* Player is close and we have attack spells, blink away */
-       if ((distance(py, px, m_ptr->fy, m_ptr->fx) < 4) && (attack_num || (r_ptr->flags6 & RF6_TRAPS)) && (randint0(100) < 75) && !world_monster)
+       if ((distance(p_ptr->y, p_ptr->x, m_ptr->fy, m_ptr->fx) < 4) && (attack_num || (r_ptr->a_ability_flags2 & RF6_TRAPS)) && (randint0(100) < 75) && !world_monster)
        {
                /* Choose tactical spell */
                if (tactic_num) return (tactic[randint0(tactic_num)]);
@@ -1301,12 +1200,12 @@ static int choose_attack_spell(int m_idx, byte spells[], byte num)
 
 
 /*!
- * @brief IDÃͤ¬ÈóËâ½ÑŪ¤ÊÆü쵻ǽ¤«¤É¤¦¤«¤òÊÖ¤¹ /
+ * @brief ID値が非魔術的な特殊技能かどうかを返す /
  * Return TRUE if a spell is inate spell.
- * @param spell È½ÄêÂоݤÎID
- * @return ÈóËâ½ÑŪ¤ÊÆü쵻ǽ¤Ê¤é¤ÐTRUE¤òÊÖ¤¹¡£
+ * @param spell 判定対象のID
+ * @return 非魔術的な特殊技能ならばTRUEを返す。
  */
-bool spell_is_inate(u16b spell)
+bool spell_is_inate(SPELL_IDX spell)
 {
        if (spell < 32 * 4) /* Set RF4 */
        {
@@ -1327,16 +1226,16 @@ bool spell_is_inate(u16b spell)
 
 
 /*!
- * @brief ¥â¥ó¥¹¥¿¡¼¤¬¥×¥ì¥¤¥ä¡¼¤Ë¥À¥á¡¼¥¸¤òÍ¿¤¨¤ë¤¿¤á¤ÎºÇŬ¤ÊºÂɸ¤ò»»½Ð¤¹¤ë /
- * @param m_ptr µ»Ç½¤ò»ÈÍѤ¹¤ë¥â¥ó¥¹¥¿¡¼¹½Â¤ÂΤλ²¾È¥Ý¥¤¥ó¥¿
- * @param yp ºÇŬ¤ÊÌÜɸÃÏÅÀ¤ÎYºÂɸ¤òÊÖ¤¹»²¾È¥Ý¥¤¥ó¥¿
- * @param xp ºÇŬ¤ÊÌÜɸÃÏÅÀ¤ÎXºÂɸ¤òÊÖ¤¹»²¾È¥Ý¥¤¥ó¥¿
- * @param f_flag ¼ÍÀþ¤ËÆþ¤ì¤ë¤Î¤òÈò¤±¤ëÃÏ·Á¤Î½ê»ý¥Õ¥é¥°
- * @param path_check ¼ÍÀþ¤òȽÄꤹ¤ë¤¿¤á¤Î´Ø¿ô¥Ý¥¤¥ó¥¿
- * @return Í­¸ú¤ÊºÂɸ¤¬¤¢¤Ã¤¿¾ì¹çTRUE¤òÊÖ¤¹
+ * @brief モンスターがプレイヤーにダメージを与えるための最適な座標を算出する /
+ * @param m_ptr æ\8a\80è\83½ã\82\92使ç\94¨ã\81\99ã\82\8bã\83¢ã\83³ã\82¹ã\82¿ã\83¼æ§\8bé\80 ä½\93ã\81®å\8f\82ç\85§ã\83\9dã\82¤ã\83³ã\82¿
+ * @param yp æ\9c\80é\81©ã\81ªç\9b®æ¨\99å\9c°ç\82¹ã\81®Y座æ¨\99ã\82\92è¿\94ã\81\99å\8f\82ç\85§ã\83\9dã\82¤ã\83³ã\82¿
+ * @param xp æ\9c\80é\81©ã\81ªç\9b®æ¨\99å\9c°ç\82¹ã\81®X座æ¨\99ã\82\92è¿\94ã\81\99å\8f\82ç\85§ã\83\9dã\82¤ã\83³ã\82¿
+ * @param f_flag å°\84ç·\9aã\81«å\85¥ã\82\8cã\82\8bã\81®ã\82\92é\81¿ã\81\91ã\82\8bå\9c°å½¢ã\81®æ\89\80æ\8c\81ã\83\95ã\83©ã\82°
+ * @param path_check å°\84ç·\9aã\82\92å\88¤å®\9aã\81\99ã\82\8bã\81\9fã\82\81ã\81®é\96¢æ\95°ã\83\9dã\82¤ã\83³ã\82¿
+ * @return 有効な座標があった場合TRUEを返す
  */
-static bool adjacent_grid_check(monster_type *m_ptr, int *yp, int *xp,
-       int f_flag, bool (*path_check)(int, int, int, int))
+static bool adjacent_grid_check(monster_type *m_ptr, POSITION *yp, POSITION *xp,
+       int f_flag, bool (*path_check)(POSITION, POSITION, POSITION, POSITION))
 {
        int i;
        int tonari;
@@ -1349,9 +1248,9 @@ static bool adjacent_grid_check(monster_type *m_ptr, int *yp, int *xp,
                                             {-1,  0,  1, -1,  1, -1,  0,  1},
                                             { 1,  0, -1,  1, -1,  1,  0, -1}};
 
-       if (m_ptr->fy < py && m_ptr->fx < px) tonari = 0;
-       else if (m_ptr->fy < py) tonari = 1;
-       else if (m_ptr->fx < px) tonari = 2;
+       if (m_ptr->fy < p_ptr->y && m_ptr->fx < p_ptr->x) tonari = 0;
+       else if (m_ptr->fy < p_ptr->y) tonari = 1;
+       else if (m_ptr->fx < p_ptr->x) tonari = 2;
        else tonari = 3;
 
        for (i = 0; i < 8; i++)
@@ -1383,19 +1282,19 @@ static bool adjacent_grid_check(monster_type *m_ptr, int *yp, int *xp,
 #define DO_SPELL_BA_LITE 3
 
 /*!
- * @brief ¥â¥ó¥¹¥¿¡¼¤ÎÆü쵻ǽ¥á¥¤¥ó¥ë¡¼¥Á¥ó /
+ * @brief モンスターの特殊技能メインルーチン /
  * Creatures can cast spells, shoot missiles, and breathe.
- * @param m_idx ¥â¥ó¥¹¥¿¡¼¹½Â¤ÂÎÇÛÎó¤ÎID
- * @return ¼ÂºÝ¤ËÆü쵻ǽ¤òÍøÍѤ·¤¿¤éTRUE¤òÊÖ¤¹
+ * @param m_idx モンスター構造体配列のID
+ * @return 実際に特殊技能を利用したらTRUEを返す
  * @details
  * Returns "TRUE" if a spell (or whatever) was (successfully) cast.\n
  *\n
- * XXX XXX XXX This function could use some work, but remember to\n
+ * This function could use some work, but remember to\n
  * keep it as optimized as possible, while retaining generic code.\n
  *\n
  * Verify the various "blind-ness" checks in the code.\n
  *\n
- * XXX XXX XXX Note that several effects should really not be "seen"\n
+ * Note that several effects should really not be "seen"\n
  * if the player is blind.  See also "effects.c" for other "mistakes".\n
  *\n
  * Perhaps monsters should breathe at locations *near* the player,\n
@@ -1440,32 +1339,30 @@ static bool adjacent_grid_check(monster_type *m_ptr, int *yp, int *xp,
  * Note the special "MFLAG_NICE" flag, which prevents a monster from using\n
  * any spell attacks until the player has had a single chance to move.\n
  */
-bool make_attack_spell(int m_idx)
+bool make_attack_spell(MONSTER_IDX m_idx)
 {
-       int             k, thrown_spell = 0, rlev, failrate;
-       byte            spell[96], num = 0;
-       u32b            f4, f5, f6;
-       monster_type    *m_ptr = &m_list[m_idx];
-       monster_race    *r_ptr = &r_info[m_ptr->r_idx];
-       char            m_name[80];
+       int k;
+       SPELL_IDX thrown_spell = 0;
+       DEPTH rlev;
+       PERCENTAGE failrate;
+       byte spell[96], num = 0;
+       BIT_FLAGS f4, f5, f6;
+       monster_type *m_ptr = &m_list[m_idx];
+       monster_race *r_ptr = &r_info[m_ptr->r_idx];
+       GAME_TEXT m_name[MAX_NLEN];
 #ifndef JP
-       char            m_poss[80];
+       char m_poss[80];
 #endif
        bool            no_inate = FALSE;
        bool            do_spell = DO_SPELL_NONE;
        int             dam = 0;
-       int rad = 0; //For elemental spells
 
-       /* Target location */
-       int x = px;
-       int y = py;
+       POSITION x = p_ptr->x;
+       POSITION y = p_ptr->y;
 
        /* Target location for lite breath */
-       int x_br_lite = 0;
-       int y_br_lite = 0;
-
-       /* Summon count */
-       int count = 0;
+       POSITION x_br_lite = 0;
+       POSITION y_br_lite = 0;
 
        /* Extract the "see-able-ness" */
     bool seen = (!p_ptr->blind && m_ptr->ml);
@@ -1474,7 +1371,7 @@ bool make_attack_spell(int m_idx)
        /* Check "projectable" */
        bool direct;
 
-       bool in_no_magic_dungeon = (d_info[dungeon_type].flags1 & DF1_NO_MAGIC) && dun_level
+       bool in_no_magic_dungeon = (d_info[p_ptr->dungeon_idx].flags1 & DF1_NO_MAGIC) && dun_level
                && (!p_ptr->inside_quest || is_fixed_quest_idx(p_ptr->inside_quest));
 
        bool can_use_lite_area = FALSE;
@@ -1496,13 +1393,13 @@ bool make_attack_spell(int m_idx)
        /* Sometimes forbid inate attacks (breaths) */
        if (randint0(100) >= (r_ptr->freq_spell * 2)) no_inate = TRUE;
 
-       /* XXX XXX XXX Handle "track_target" option (?) */
+       /* Handle "track_target" option (?) */
 
 
        /* Extract the racial spell flags */
        f4 = r_ptr->flags4;
-       f5 = r_ptr->flags5;
-       f6 = r_ptr->flags6;
+       f5 = r_ptr->a_ability_flags1;
+       f6 = r_ptr->a_ability_flags2;
 
        /*** require projectable player ***/
 
@@ -1571,7 +1468,7 @@ bool make_attack_spell(int m_idx)
                }
                else if ((f5 & RF5_BA_LITE) && (m_ptr->cdis <= MAX_RANGE))
                {
-                       int by = y, bx = x;
+                       POSITION by = y, bx = x;
                        get_project_point(m_ptr->fy, m_ptr->fx, &by, &bx, 0L);
                        if ((distance(by, bx, y, x) <= 3) && los(by, bx, y, x) && one_in_(5))
                        {
@@ -1613,7 +1510,6 @@ bool make_attack_spell(int m_idx)
 
        reset_target(m_ptr);
 
-       /* Extract the monster level */
        rlev = ((r_ptr->level >= 1) ? r_ptr->level : 1);
 
        /* Forbid inate attacks sometimes */
@@ -1633,7 +1529,7 @@ bool make_attack_spell(int m_idx)
 
                if (!(r_ptr->flags2 & RF2_STUPID))
                {
-                       if (d_info[dungeon_type].flags1 & DF1_DARKNESS) f6 &= ~(RF6_DARKNESS);
+                       if (d_info[p_ptr->dungeon_idx].flags1 & DF1_DARKNESS) f6 &= ~(RF6_DARKNESS);
                        else if ((p_ptr->pclass == CLASS_NINJA) && !can_use_lite_area) f6 &= ~(RF6_DARKNESS);
                }
        }
@@ -1690,7 +1586,7 @@ bool make_attack_spell(int m_idx)
                if (((f4 & RF4_BOLT_MASK) ||
                     (f5 & RF5_BOLT_MASK) ||
                     (f6 & RF6_BOLT_MASK)) &&
-                   !clean_shot(m_ptr->fy, m_ptr->fx, py, px, FALSE))
+                   !clean_shot(m_ptr->fy, m_ptr->fx, p_ptr->y, p_ptr->x, FALSE))
                {
                        /* Remove spells that will only hurt friends */
                        f4 &= ~(RF4_BOLT_MASK);
@@ -1807,9 +1703,8 @@ bool make_attack_spell(int m_idx)
        if (!spell_is_inate(thrown_spell)
            && (in_no_magic_dungeon || (MON_STUNNED(m_ptr) && one_in_(2)) || (randint0(100) < failrate)))
        {
-               disturb(1, 1);
-               /* Message */
-               msg_format(_("%^s¤Ï¼öʸ¤ò¾§¤¨¤è¤¦¤È¤·¤¿¤¬¼ºÇÔ¤·¤¿¡£", "%^s tries to cast a spell, but fails."), m_name);
+               disturb(TRUE, TRUE);
+               msg_format(_("%^sは呪文を唱えようとしたが失敗した。", "%^s tries to cast a spell, but fails."), m_name);
 
                return (TRUE);
        }
@@ -1817,7 +1712,7 @@ bool make_attack_spell(int m_idx)
        /* Hex: Anti Magic Barrier */
        if (!spell_is_inate(thrown_spell) && magic_barrier(m_idx))
        {
-               msg_format(_("È¿ËâË¡¥Ð¥ê¥¢¤¬%^s¤Î¼öʸ¤ò¤«¤­¾Ã¤·¤¿¡£", "Anti magic barrier cancels the spell which %^s casts."), m_name);
+               msg_format(_("反魔法バリアが%^sの呪文をかき消した。", "Anti magic barrier cancels the spell which %^s casts."), m_name);
                return (TRUE);
        }