OSDN Git Service

[Refactor] #37353 mon_take_hit() のコメントアウト済落馬処理を削除。 / Delete comment outed process...
[hengband/hengband.git] / src / mspells3.c
index cac77a3..d39543a 100644 (file)
@@ -23,7 +23,7 @@
 * @param tmp 返すメッセージを格納する配列
 * @return なし
 */
-void set_bluemage_damage(int SPELL_NUM, int plev, cptr msg, char* tmp)
+void set_bluemage_damage(int SPELL_NUM, PLAYER_LEVEL plev, cptr msg, char* tmp)
 {
     int base_damage = monspell_bluemage_damage(SPELL_NUM, plev, BASE_DAM);
     int dice_num = monspell_bluemage_damage(SPELL_NUM, plev, DICE_NUM);
@@ -43,8 +43,7 @@ void set_bluemage_damage(int SPELL_NUM, int plev, cptr msg, char* tmp)
  */
 static void learned_info(char *p, int power)
 {
-       int plev = pseudo_plev();
-       int hp = p_ptr->chp;
+       PLAYER_LEVEL plev = pseudo_plev();
 
 #ifdef JP
        cptr s_dam = " 損傷:%s";
@@ -200,15 +199,15 @@ static void learned_info(char *p, int power)
  * when you run it. It's probably easy to fix but I haven't tried,\n
  * sorry.\n
  */
-static int get_learned_power(int *sn)
+static int get_learned_power(SPELL_IDX *sn)
 {
        int             i = 0;
        int             num = 0;
        int             y = 1;
        int             x = 18;
-       int             minfail = 0;
-       int             plev = p_ptr->lev;
-       int             chance = 0;
+       PERCENTAGE minfail = 0;
+       PLAYER_LEVEL plev = p_ptr->lev;
+       PERCENTAGE chance = 0;
        int             ask = TRUE, mode = 0;
        int             spellnum[MAX_MONSPELLS];
        char            ch;
@@ -217,7 +216,7 @@ static int get_learned_power(int *sn)
        char            comment[80];
        s32b            f4 = 0, f5 = 0, f6 = 0;
        cptr            p = _("魔法", "magic");
-
+       COMMAND_CODE code;
        monster_power   spell;
        bool            flag, redraw;
        int menu_line = (use_menu ? 1 : 0);
@@ -231,16 +230,14 @@ static int get_learned_power(int *sn)
        /* No redraw yet */
        redraw = FALSE;
 
-#ifdef ALLOW_REPEAT /* TNB */
-
        /* Get the spell, if available */
-       if (repeat_pull(sn))
+       
+       if (repeat_pull(&code))
        {
                /* Success */
                return (TRUE);
        }
-
-#endif /* ALLOW_REPEAT -- TNB */
+       *sn = (SPELL_IDX)code;
 
        if (use_menu)
        {
@@ -539,7 +536,7 @@ static int get_learned_power(int *sn)
                        ask = isupper(choice);
 
                        /* Lowercase */
-                       if (ask) choice = tolower(choice);
+                       if (ask) choice = (char)tolower(choice);
 
                        /* Extract request */
                        i = (islower(choice) ? A2I(choice) : -1);
@@ -577,7 +574,6 @@ static int get_learned_power(int *sn)
        /* Show choices */
        p_ptr->window |= (PW_SPELL);
 
-       /* Window stuff */
        window_stuff();
 
        /* Abort if needed */
@@ -586,11 +582,7 @@ static int get_learned_power(int *sn)
        /* Save the choice */
        (*sn) = spellnum[i];
 
-#ifdef ALLOW_REPEAT /* TNB */
-
-       repeat_push(*sn);
-
-#endif /* ALLOW_REPEAT -- TNB */
+       repeat_push((COMMAND_CODE)spellnum[i]);
 
        /* Success */
        return (TRUE);
@@ -606,14 +598,13 @@ static int get_learned_power(int *sn)
  */
 static bool cast_learned_spell(int spell, bool success)
 {
-       int             dir;
-       int             plev = pseudo_plev();
-       int     summon_lev = p_ptr->lev * 2 / 3 + randint1(p_ptr->lev/2);
-       int             hp = p_ptr->chp;
-       int             damage = 0;
-       bool   pet = success;
-       bool   no_trump = FALSE;
-       u32b p_mode, u_mode = 0L, g_mode;
+       DIRECTION dir;
+       PLAYER_LEVEL plev = pseudo_plev();
+       PLAYER_LEVEL summon_lev = p_ptr->lev * 2 / 3 + randint1(p_ptr->lev/2);
+       HIT_POINT damage = 0;
+       bool pet = success;
+       bool no_trump = FALSE;
+       BIT_FLAGS p_mode, u_mode = 0L, g_mode;
 
        if (pet)
        {
@@ -639,13 +630,13 @@ static bool cast_learned_spell(int spell, bool success)
                break;
        case MS_DISPEL:
        {
-               int m_idx;
+               MONSTER_IDX m_idx;
 
                if (!target_set(TARGET_KILL)) return FALSE;
                m_idx = cave[target_row][target_col].m_idx;
                if (!m_idx) break;
                if (!player_has_los_bold(target_row, target_col)) break;
-               if (!projectable(py, px, target_row, target_col)) break;
+               if (!projectable(p_ptr->y, p_ptr->x, target_row, target_col)) break;
                dispel_monster_status(m_idx);
                break;
        }
@@ -658,8 +649,6 @@ static bool cast_learned_spell(int spell, bool success)
                break;
        case MS_SHOOT:
        {
-               object_type *o_ptr = NULL;
-
                if (!get_aim_dir(&dir)) return FALSE;
                
         msg_print(_("矢を放った。", "You fire an arrow."));
@@ -678,140 +667,140 @@ static bool cast_learned_spell(int spell, bool success)
 
         msg_print(_("酸のブレスを吐いた。", "You breathe acid."));
         damage = monspell_bluemage_damage((MS_BR_ACID), plev, DAM_ROLL);
-               fire_ball(GF_ACID, dir, damage, (plev > 40 ? -3 : -2));
+               fire_breath(GF_ACID, dir, damage, (plev > 40 ? 3 : 2));
                break;
        case MS_BR_ELEC:
                if (!get_aim_dir(&dir)) return FALSE;
 
         msg_print(_("稲妻のブレスを吐いた。", "You breathe lightning."));
         damage = monspell_bluemage_damage((MS_BR_ELEC), plev, DAM_ROLL);
-               fire_ball(GF_ELEC, dir, damage, (plev > 40 ? -3 : -2));
+               fire_breath(GF_ELEC, dir, damage, (plev > 40 ? 3 : 2));
                break;
        case MS_BR_FIRE:
                if (!get_aim_dir(&dir)) return FALSE;
 
         msg_print(_("火炎のブレスを吐いた。", "You breathe fire."));
         damage = monspell_bluemage_damage((MS_BR_FIRE), plev, DAM_ROLL);
-               fire_ball(GF_FIRE, dir, damage, (plev > 40 ? -3 : -2));
+               fire_breath(GF_FIRE, dir, damage, (plev > 40 ? 3 : 2));
                break;
        case MS_BR_COLD:
         if (!get_aim_dir(&dir)) return FALSE;
 
         msg_print(_("冷気のブレスを吐いた。", "You breathe frost."));
         damage = monspell_bluemage_damage((MS_BR_COLD), plev, DAM_ROLL);
-               fire_ball(GF_COLD, dir, damage, (plev > 40 ? -3 : -2));
+               fire_breath(GF_COLD, dir, damage, (plev > 40 ? 3 : 2));
                break;
        case MS_BR_POIS:
         if (!get_aim_dir(&dir)) return FALSE;
 
         msg_print(_("ガスのブレスを吐いた。", "You breathe gas."));
         damage = monspell_bluemage_damage((MS_BR_POIS), plev, DAM_ROLL);
-               fire_ball(GF_POIS, dir, damage, (plev > 40 ? -3 : -2));
+               fire_breath(GF_POIS, dir, damage, (plev > 40 ? 3 : 2));
                break;
        case MS_BR_NETHER:
         if (!get_aim_dir(&dir)) return FALSE;
 
         msg_print(_("地獄のブレスを吐いた。", "You breathe nether."));
         damage = monspell_bluemage_damage((MS_BR_NETHER), plev, DAM_ROLL);
-               fire_ball(GF_NETHER, dir, damage, (plev > 40 ? -3 : -2));
+               fire_breath(GF_NETHER, dir, damage, (plev > 40 ? 3 : 2));
                break;
        case MS_BR_LITE:
                if (!get_aim_dir(&dir)) return FALSE;
 
         msg_print(_("閃光のブレスを吐いた。", "You breathe light."));
         damage = monspell_bluemage_damage((MS_BR_LITE), plev, DAM_ROLL);
-               fire_ball(GF_LITE, dir, damage, (plev > 40 ? -3 : -2));
+               fire_breath(GF_LITE, dir, damage, (plev > 40 ? 3 : 2));
                break;
        case MS_BR_DARK:
                if (!get_aim_dir(&dir)) return FALSE;
 
         msg_print(_("暗黒のブレスを吐いた。", "You breathe darkness."));
         damage = monspell_bluemage_damage((MS_BR_DARK), plev, DAM_ROLL);
-               fire_ball(GF_DARK, dir, damage, (plev > 40 ? -3 : -2));
+               fire_breath(GF_DARK, dir, damage, (plev > 40 ? 3 : 2));
                break;
        case MS_BR_CONF:
                if (!get_aim_dir(&dir)) return FALSE;
 
         msg_print(_("混乱のブレスを吐いた。", "You breathe confusion."));
         damage = monspell_bluemage_damage((MS_BR_CONF), plev, DAM_ROLL);
-               fire_ball(GF_CONFUSION, dir, damage, (plev > 40 ? -3 : -2));
+               fire_breath(GF_CONFUSION, dir, damage, (plev > 40 ? 3 : 2));
                break;
        case MS_BR_SOUND:
                if (!get_aim_dir(&dir)) return FALSE;
 
         msg_print(_("轟音のブレスを吐いた。", "You breathe sound."));
         damage = monspell_bluemage_damage((MS_BR_SOUND), plev, DAM_ROLL);
-               fire_ball(GF_SOUND, dir, damage, (plev > 40 ? -3 : -2));
+               fire_breath(GF_SOUND, dir, damage, (plev > 40 ? 3 : 2));
                break;
        case MS_BR_CHAOS:
                if (!get_aim_dir(&dir)) return FALSE;
 
         msg_print(_("カオスのブレスを吐いた。", "You breathe chaos."));
         damage = monspell_bluemage_damage((MS_BR_CHAOS), plev, DAM_ROLL);
-               fire_ball(GF_CHAOS, dir, damage, (plev > 40 ? -3 : -2));
+               fire_breath(GF_CHAOS, dir, damage, (plev > 40 ? 3 : 2));
                break;
        case MS_BR_DISEN:
                if (!get_aim_dir(&dir)) return FALSE;
 
         msg_print(_("劣化のブレスを吐いた。", "You breathe disenchantment."));
         damage = monspell_bluemage_damage((MS_BR_DISEN), plev, DAM_ROLL);
-               fire_ball(GF_DISENCHANT, dir, damage, (plev > 40 ? -3 : -2));
+               fire_breath(GF_DISENCHANT, dir, damage, (plev > 40 ? 3 : 2));
                break;
        case MS_BR_NEXUS:
                if (!get_aim_dir(&dir)) return FALSE;
 
         msg_print(_("因果混乱のブレスを吐いた。", "You breathe nexus."));
         damage = monspell_bluemage_damage((MS_BR_NEXUS), plev, DAM_ROLL);
-               fire_ball(GF_NEXUS, dir, damage, (plev > 40 ? -3 : -2));
+               fire_breath(GF_NEXUS, dir, damage, (plev > 40 ? 3 : 2));
                break;
        case MS_BR_TIME:
                if (!get_aim_dir(&dir)) return FALSE;
 
         msg_print(_("時間逆転のブレスを吐いた。", "You breathe time."));
         damage = monspell_bluemage_damage((MS_BR_TIME), plev, DAM_ROLL);
-               fire_ball(GF_TIME, dir, damage, (plev > 40 ? -3 : -2));
+               fire_breath(GF_TIME, dir, damage, (plev > 40 ? 3 : 2));
                break;
        case MS_BR_INERTIA:
                if (!get_aim_dir(&dir)) return FALSE;
 
         msg_print(_("遅鈍のブレスを吐いた。", "You breathe inertia."));
         damage = monspell_bluemage_damage((MS_BR_INERTIA), plev, DAM_ROLL);
-               fire_ball(GF_INERTIA, dir, damage, (plev > 40 ? -3 : -2));
+               fire_breath(GF_INERTIAL, dir, damage, (plev > 40 ? 3 : 2));
                break;
        case MS_BR_GRAVITY:
                if (!get_aim_dir(&dir)) return FALSE;
 
         msg_print(_("重力のブレスを吐いた。", "You breathe gravity."));
         damage = monspell_bluemage_damage((MS_BR_GRAVITY), plev, DAM_ROLL);
-               fire_ball(GF_GRAVITY, dir, damage, (plev > 40 ? -3 : -2));
+               fire_breath(GF_GRAVITY, dir, damage, (plev > 40 ? 3 : 2));
                break;
        case MS_BR_SHARDS:
         if (!get_aim_dir(&dir)) return FALSE;
 
         msg_print(_("破片のブレスを吐いた。", "You breathe shards."));
         damage = monspell_bluemage_damage((MS_BR_SHARDS), plev, DAM_ROLL);
-               fire_ball(GF_SHARDS, dir, damage, (plev > 40 ? -3 : -2));
+               fire_breath(GF_SHARDS, dir, damage, (plev > 40 ? 3 : 2));
                break;
        case MS_BR_PLASMA:
         if (!get_aim_dir(&dir)) return FALSE;
 
         msg_print(_("プラズマのブレスを吐いた。", "You breathe plasma."));
         damage = monspell_bluemage_damage((MS_BR_PLASMA), plev, DAM_ROLL);
-               fire_ball(GF_PLASMA, dir, damage, (plev > 40 ? -3 : -2));
+               fire_breath(GF_PLASMA, dir, damage, (plev > 40 ? 3 : 2));
                break;
        case MS_BR_FORCE:
         if (!get_aim_dir(&dir)) return FALSE;
 
         msg_print(_("フォースのブレスを吐いた。", "You breathe force."));
         damage = monspell_bluemage_damage((MS_BR_FORCE), plev, DAM_ROLL);
-               fire_ball(GF_FORCE, dir, damage, (plev > 40 ? -3 : -2));
+               fire_breath(GF_FORCE, dir, damage, (plev > 40 ? 3 : 2));
                break;
        case MS_BR_MANA:
                if (!get_aim_dir(&dir)) return FALSE;
 
         msg_print(_("魔力のブレスを吐いた。", "You breathe mana."));
         damage = monspell_bluemage_damage((MS_BR_MANA), plev, DAM_ROLL);
-               fire_ball(GF_MANA, dir, damage, (plev > 40 ? -3 : -2));
+               fire_breath(GF_MANA, dir, damage, (plev > 40 ? 3 : 2));
                break;
        case MS_BALL_NUKE:
                if (!get_aim_dir(&dir)) return FALSE;
@@ -825,7 +814,7 @@ static bool cast_learned_spell(int spell, bool success)
 
         msg_print(_("放射性廃棄物のブレスを吐いた。", "You breathe toxic waste."));
         damage = monspell_bluemage_damage((MS_BR_NUKE), plev, DAM_ROLL);
-               fire_ball(GF_NUKE, dir, damage, (plev > 40 ? -3 : -2));
+               fire_breath(GF_NUKE, dir, damage, (plev > 40 ? 3 : 2));
                break;
        case MS_BALL_CHAOS:
                if (!get_aim_dir(&dir)) return FALSE;
@@ -839,7 +828,7 @@ static bool cast_learned_spell(int spell, bool success)
 
         msg_print(_("分解のブレスを吐いた。", "You breathe disintegration."));
         damage = monspell_bluemage_damage((MS_BR_DISI), plev, DAM_ROLL);
-               fire_ball(GF_DISINTEGRATE, dir, damage, (plev > 40 ? -3 : -2));
+               fire_breath(GF_DISINTEGRATE, dir, damage, (plev > 40 ? 3 : 2));
                break;
        case MS_BALL_ACID:
                if (!get_aim_dir(&dir)) return FALSE;
@@ -1082,13 +1071,11 @@ static bool cast_learned_spell(int spell, bool success)
                /* Hack */
                p_ptr->energy_need -= 1000 + (100 + randint1(200)+200)*TURNS_PER_TICK/10;
 
-               /* Redraw map */
                p_ptr->redraw |= (PR_MAP);
 
                /* Update monsters */
                p_ptr->update |= (PU_MONSTERS);
 
-               /* Window stuff */
                p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
 
                handle_stuff();
@@ -1104,7 +1091,7 @@ static bool cast_learned_spell(int spell, bool success)
                if (!target_set(TARGET_KILL)) return FALSE;
                if (!cave[target_row][target_col].m_idx) break;
                if (!player_has_los_bold(target_row, target_col)) break;
-               if (!projectable(py, px, target_row, target_col)) break;
+               if (!projectable(p_ptr->y, p_ptr->x, target_row, target_col)) break;
                m_ptr = &m_list[cave[target_row][target_col].m_idx];
                r_ptr = &r_info[m_ptr->r_idx];
                monster_desc(m_name, m_ptr, 0);
@@ -1124,7 +1111,7 @@ static bool cast_learned_spell(int spell, bool success)
                        }
                }
         msg_format(_("%sを引き戻した。", "You command %s to return."), m_name);
-               teleport_monster_to(cave[target_row][target_col].m_idx, py, px, 100, TELEPORT_PASSIVE);
+               teleport_monster_to(cave[target_row][target_col].m_idx, p_ptr->y, p_ptr->x, 100, TELEPORT_PASSIVE);
                break;
        }
        case MS_TELE_AWAY:
@@ -1134,7 +1121,7 @@ static bool cast_learned_spell(int spell, bool success)
                break;
        case MS_TELE_LEVEL:
        {
-               int target_m_idx;
+               MONSTER_IDX target_m_idx;
                monster_type *m_ptr;
                monster_race *r_ptr;
                char m_name[80];
@@ -1143,7 +1130,7 @@ static bool cast_learned_spell(int spell, bool success)
                target_m_idx = cave[target_row][target_col].m_idx;
                if (!target_m_idx) break;
                if (!player_has_los_bold(target_row, target_col)) break;
-               if (!projectable(py, px, target_row, target_col)) break;
+               if (!projectable(p_ptr->y, p_ptr->x, target_row, target_col)) break;
                m_ptr = &m_list[target_m_idx];
                r_ptr = &r_info[m_ptr->r_idx];
                monster_desc(m_name, m_ptr, 0);
@@ -1180,7 +1167,7 @@ static bool cast_learned_spell(int spell, bool success)
                break;
     case MS_RAISE_DEAD:
         msg_print(_("死者復活の呪文を唱えた。", "You cast a animate dead."));
-               (void)animate_dead(0, py, px);
+               (void)animate_dead(0, p_ptr->y, p_ptr->x);
                break;
        case MS_S_KIN:
        {
@@ -1189,7 +1176,7 @@ static bool cast_learned_spell(int spell, bool success)
         msg_print(_("援軍を召喚した。", "You summon minions."));
                for (k = 0;k < 1; k++)
                {
-                       if (summon_kin_player(summon_lev, py, px, (pet ? PM_FORCE_PET : 0L)))
+                       if (summon_kin_player(summon_lev, p_ptr->y, p_ptr->x, (pet ? PM_FORCE_PET : 0L)))
                        {
                                if (!pet) msg_print(_("召喚された仲間は怒っている!", "Summoned fellows are angry!"));
                        }
@@ -1206,7 +1193,7 @@ static bool cast_learned_spell(int spell, bool success)
 
         msg_print(_("サイバーデーモンを召喚した!", "You summon a Cyberdemon!"));
                for (k = 0 ;k < 1 ; k++)
-                       if (summon_specific((pet ? -1 : 0), py, px, summon_lev, SUMMON_CYBER, p_mode))
+                       if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, summon_lev, SUMMON_CYBER, p_mode))
                        {
                 if (!pet)
                     msg_print(_("召喚されたサイバーデーモンは怒っている!", "The summoned Cyberdemon are angry!"));
@@ -1222,7 +1209,7 @@ static bool cast_learned_spell(int spell, bool success)
                int k;
         msg_print(_("仲間を召喚した。", "You summon help."));
                for (k = 0;k < 1; k++)
-                       if (summon_specific((pet ? -1 : 0), py, px, summon_lev, 0, p_mode))
+                       if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, summon_lev, 0, p_mode))
                        {
                 if (!pet)
                     msg_print(_("召喚されたモンスターは怒っている!", "The summoned monster is angry!"));
@@ -1238,7 +1225,7 @@ static bool cast_learned_spell(int spell, bool success)
                int k;
         msg_print(_("モンスターを召喚した!", "You summon monsters!"));
                for (k = 0;k < plev / 15 + 2; k++)
-                       if(summon_specific((pet ? -1 : 0), py, px, summon_lev, 0, (p_mode | u_mode)))
+                       if(summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, summon_lev, 0, (p_mode | u_mode)))
                        {
                 if (!pet)
                     msg_print(_("召喚されたモンスターは怒っている!", "The summoned monsters are angry!"));
@@ -1254,7 +1241,7 @@ static bool cast_learned_spell(int spell, bool success)
                int k;
         msg_print(_("アリを召喚した。", "You summon ants."));
                for (k = 0;k < 1; k++)
-                       if (summon_specific((pet ? -1 : 0), py, px, summon_lev, SUMMON_ANT, (PM_ALLOW_GROUP | p_mode)))
+                       if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, summon_lev, SUMMON_ANT, (PM_ALLOW_GROUP | p_mode)))
                        {
                 if (!pet)
                     msg_print(_("召喚されたアリは怒っている!", "The summoned ants are angry!"));
@@ -1270,7 +1257,7 @@ static bool cast_learned_spell(int spell, bool success)
                int k;
         msg_print(_("蜘蛛を召喚した。", "You summon spiders."));
                for (k = 0;k < 1; k++)
-                       if (summon_specific((pet ? -1 : 0), py, px, summon_lev, SUMMON_SPIDER, (PM_ALLOW_GROUP | p_mode)))
+                       if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, summon_lev, SUMMON_SPIDER, (PM_ALLOW_GROUP | p_mode)))
                        {
                 if (!pet)
                     msg_print(_("召喚された蜘蛛は怒っている!", "Summoned spiders are angry!"));
@@ -1286,7 +1273,7 @@ static bool cast_learned_spell(int spell, bool success)
                int k;
         msg_print(_("ハウンドを召喚した。", "You summon hounds."));
                for (k = 0;k < 1; k++)
-                       if (summon_specific((pet ? -1 : 0), py, px, summon_lev, SUMMON_HOUND, (PM_ALLOW_GROUP | p_mode)))
+                       if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, summon_lev, SUMMON_HOUND, (PM_ALLOW_GROUP | p_mode)))
                        {
                 if (!pet)
                     msg_print(_("召喚されたハウンドは怒っている!", "Summoned hounds are angry!"));
@@ -1302,7 +1289,7 @@ static bool cast_learned_spell(int spell, bool success)
                int k;
         msg_print(_("ヒドラを召喚した。", "You summon a hydras."));
                for (k = 0;k < 1; k++)
-                       if (summon_specific((pet ? -1 : 0), py, px, summon_lev, SUMMON_HYDRA, (g_mode | p_mode)))
+                       if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, summon_lev, SUMMON_HYDRA, (g_mode | p_mode)))
                        {
                 if (!pet)
                     msg_print(_("召喚されたヒドラは怒っている!", "Summoned hydras are angry!"));
@@ -1318,7 +1305,7 @@ static bool cast_learned_spell(int spell, bool success)
                int k;
         msg_print(_("天使を召喚した!", "You summon an angel!"));
                for (k = 0;k < 1; k++)
-                       if (summon_specific((pet ? -1 : 0), py, px, summon_lev, SUMMON_ANGEL, (g_mode | p_mode)))
+                       if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, summon_lev, SUMMON_ANGEL, (g_mode | p_mode)))
                        {
                 if (!pet)
                     msg_print(_("召喚された天使は怒っている!", "Summoned angels are angry!"));
@@ -1334,7 +1321,7 @@ static bool cast_learned_spell(int spell, bool success)
                int k;
         msg_print(_("混沌の宮廷から悪魔を召喚した!", "You summon a demon from the Courts of Chaos!"));
                for (k = 0;k < 1; k++)
-                       if (summon_specific((pet ? -1 : 0), py, px, summon_lev, SUMMON_DEMON, (g_mode | p_mode)))
+                       if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, summon_lev, SUMMON_DEMON, (g_mode | p_mode)))
                        {
                 if (!pet)
                     msg_print(_("召喚されたデーモンは怒っている!", "Summoned demons are angry!"));
@@ -1350,7 +1337,7 @@ static bool cast_learned_spell(int spell, bool success)
                int k;
         msg_print(_("アンデッドの強敵を召喚した!", "You summon an undead adversary!"));
                for (k = 0;k < 1; k++)
-                       if (summon_specific((pet ? -1 : 0), py, px, summon_lev, SUMMON_UNDEAD, (g_mode | p_mode)))
+                       if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, summon_lev, SUMMON_UNDEAD, (g_mode | p_mode)))
                        {
                 if (!pet)
                     msg_print(_("召喚されたアンデッドは怒っている!", "Summoned undeads are angry!"));
@@ -1366,7 +1353,7 @@ static bool cast_learned_spell(int spell, bool success)
                int k;
         msg_print(_("ドラゴンを召喚した!", "You summon a dragon!"));
                for (k = 0;k < 1; k++)
-                       if (summon_specific((pet ? -1 : 0), py, px, summon_lev, SUMMON_DRAGON, (g_mode | p_mode)))
+                       if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, summon_lev, SUMMON_DRAGON, (g_mode | p_mode)))
                        {
                 if (!pet)
                     msg_print(_("召喚されたドラゴンは怒っている!", "Summoned dragons are angry!"));
@@ -1382,7 +1369,7 @@ static bool cast_learned_spell(int spell, bool success)
                int k;
         msg_print(_("強力なアンデッドを召喚した!", "You summon a greater undead!"));
                for (k = 0;k < 1; k++)
-                       if (summon_specific((pet ? -1 : 0), py, px, summon_lev, SUMMON_HI_UNDEAD, (g_mode | p_mode | u_mode)))
+                       if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, summon_lev, SUMMON_HI_UNDEAD, (g_mode | p_mode | u_mode)))
                        {
                 if (!pet)
                     msg_print(_("召喚された上級アンデッドは怒っている!", "Summoned greater undeads are angry!"));
@@ -1398,7 +1385,7 @@ static bool cast_learned_spell(int spell, bool success)
                int k;
         msg_print(_("古代ドラゴンを召喚した!", "You summon an ancient dragon!"));
                for (k = 0;k < 1; k++)
-                       if (summon_specific((pet ? -1 : 0), py, px, summon_lev, SUMMON_HI_DRAGON, (g_mode | p_mode | u_mode)))
+                       if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, summon_lev, SUMMON_HI_DRAGON, (g_mode | p_mode | u_mode)))
                        {
                 if (!pet)
                     msg_print(_("召喚された古代ドラゴンは怒っている!", "Summoned ancient dragons are angry!"));
@@ -1414,7 +1401,7 @@ static bool cast_learned_spell(int spell, bool success)
                int k;
         msg_print(_("アンバーの王族を召喚した!", "You summon a Lord of Amber!"));
                for (k = 0;k < 1; k++)
-                       if (summon_specific((pet ? -1 : 0), py, px, summon_lev, SUMMON_AMBERITES, (g_mode | p_mode | u_mode)))
+                       if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, summon_lev, SUMMON_AMBERITES, (g_mode | p_mode | u_mode)))
                        {
                 if (!pet)
                     msg_print(_("召喚されたアンバーの王族は怒っている!", "Summoned Lords of Amber are angry!"));
@@ -1428,20 +1415,20 @@ static bool cast_learned_spell(int spell, bool success)
        case MS_S_UNIQUE:
        {
                int k, count = 0;
-        msg_print(_("特別な強敵を召喚した!", "You summon a special opponent!"));
+               msg_print(_("特別な強敵を召喚した!", "You summon a special opponent!"));
                for (k = 0;k < 1; k++)
-                       if (summon_specific((pet ? -1 : 0), py, px, summon_lev, SUMMON_UNIQUE, (g_mode | p_mode | PM_ALLOW_UNIQUE)))
+                       if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, summon_lev, SUMMON_UNIQUE, (g_mode | p_mode | PM_ALLOW_UNIQUE)))
                        {
                                count++;
-                if (!pet)
-                    msg_print(_("召喚されたユニーク・モンスターは怒っている!", "Summoned special opponents are angry!"));
+                               if (!pet)
+                                       msg_print(_("召喚されたユニーク・モンスターは怒っている!", "Summoned special opponents are angry!"));
                        }
                for (k = count;k < 1; k++)
-                       if (summon_specific((pet ? -1 : 0), py, px, summon_lev, SUMMON_HI_UNDEAD, (g_mode | p_mode | PM_ALLOW_UNIQUE)))
+                       if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, summon_lev, SUMMON_HI_UNDEAD, (g_mode | p_mode | PM_ALLOW_UNIQUE)))
                        {
                                count++;
-                if (!pet)
-                    msg_print(_("召喚された上級アンデッドは怒っている!", "Summoned greater undeads are angry!"));
+                               if (!pet)
+                                       msg_print(_("召喚された上級アンデッドは怒っている!", "Summoned greater undeads are angry!"));
                        }
                if (!count)
                {
@@ -1467,13 +1454,13 @@ static bool cast_learned_spell(int spell, bool success)
  */
 bool do_cmd_cast_learned(void)
 {
-       int             n = 0;
-       int             chance;
-       int             minfail = 0;
-       int             plev = p_ptr->lev;
-       monster_power   spell;
-       bool            cast;
-       int             need_mana;
+       SPELL_IDX n = 0;
+       PERCENTAGE chance;
+       PERCENTAGE minfail = 0;
+       PLAYER_LEVEL plev = p_ptr->lev;
+       monster_power spell;
+       bool cast;
+       MANA_POINT need_mana;
 
 
        /* not if confused */
@@ -1571,7 +1558,6 @@ bool do_cmd_cast_learned(void)
                p_ptr->csp = 0;
                p_ptr->csp_frac = 0;
 
-               /* Message */
                msg_print(_("精神を集中しすぎて気を失ってしまった!", "You faint from the effort!"));
 
                /* Hack -- Bypass free action */
@@ -1584,7 +1570,6 @@ bool do_cmd_cast_learned(void)
                {
                        bool perm = (randint0(100) < 25);
 
-                       /* Message */
                        msg_print(_("体を悪くしてしまった!", "You have damaged your health!"));
 
                        /* Reduce constitution */
@@ -1592,10 +1577,8 @@ bool do_cmd_cast_learned(void)
                }
        }
 
-       /* Take a turn */
-       energy_use = 100;
+       p_ptr->energy_use = 100;
 
-       /* Window stuff */
        p_ptr->redraw |= (PR_MANA);
        p_ptr->window |= (PW_PLAYER);
        p_ptr->window |= (PW_SPELL);
@@ -1620,7 +1603,6 @@ void learn_spell(int monspell)
                msg_format(_("%sを学習した!", "You have learned %s!"), monster_powers[monspell].name);
                gain_exp(monster_powers[monspell].level * monster_powers[monspell].smana);
 
-               /* Sound */
                sound(SOUND_STUDY);
 
                new_mane = TRUE;
@@ -1640,7 +1622,7 @@ void learn_spell(int monspell)
  */
 /*
  */
-void set_rf_masks(s32b *f4, s32b *f5, s32b *f6, int mode)
+void set_rf_masks(s32b *f4, s32b *f5, s32b *f6, BIT_FLAGS mode)
 {
        switch (mode)
        {