OSDN Git Service

[Refactor] #38997 monster_gain_exp() にplayer_type * 引数を追加 / Added player_type * argum...
[hengband/hengband.git] / src / spells1.c
index b669b01..a9a553f 100644 (file)
@@ -245,6 +245,7 @@ static POSITION monster_target_y; /*!< モンスターの攻撃目標Y座標 */
 
 /*!
  * @brief 汎用的なビーム/ボルト/ボール系による地形効果処理 / We are called from "project()" to "damage" terrain features
+ * @param caster_ptr プレーヤーへの参照ポインタ
  * @param who 魔法を発動したモンスター(0ならばプレイヤー) / Index of "source" monster (zero for "player")
  * @param r 効果半径(ビーム/ボルト = 0 / ボール = 1以上) / Radius of explosion (0 = beam/bolt, 1 to 9 = ball)
  * @param y 目標Y座標 / Target y location (or location to travel "towards")
@@ -268,21 +269,21 @@ static POSITION monster_target_y; /*!< モンスターの攻撃目標Y座標 */
  * Perhaps we should affect doors?
  * </pre>
  */
-static bool project_f(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITION y, POSITION x, HIT_POINT dam, EFFECT_ID typ)
+static bool project_f(player_type *caster_ptr, MONSTER_IDX who, POSITION r, POSITION y, POSITION x, HIT_POINT dam, EFFECT_ID typ)
 {
+       floor_type *floor_ptr = caster_ptr->current_floor_ptr;
        grid_type *g_ptr = &floor_ptr->grid_array[y][x];
        feature_type *f_ptr = &f_info[g_ptr->feat];
 
        bool obvious = FALSE;
-       bool known = player_has_los_bold(p_ptr, y, x);
+       bool known = player_has_los_bold(caster_ptr, y, x);
 
        who = who ? who : 0;
 
        /* Reduce damage by distance */
        dam = (dam + r) / (r + 1);
 
-
-       if (have_flag(f_ptr->flags, FF_TREE))
+if (have_flag(f_ptr->flags, FF_TREE))
        {
                concptr message;
                switch (typ)
@@ -320,7 +321,7 @@ static bool project_f(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
                if (message)
                {
                        msg_format(_("木は%s。", "A tree %s"), message);
-                       cave_set_feat(floor_ptr, y, x, one_in_(3) ? feat_brake : feat_grass);
+                       cave_set_feat(caster_ptr, y, x, one_in_(3) ? feat_brake : feat_grass);
 
                        /* Observe */
                        if (g_ptr->info & (CAVE_MARK)) obvious = TRUE;
@@ -372,7 +373,7 @@ static bool project_f(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
                        if (is_hidden_door(g_ptr))
                        {
                                /* Pick a door */
-                               disclose_grid(y, x);
+                               disclose_grid(caster_ptr, y, x);
 
                                /* Check line of sight */
                                if (known)
@@ -392,7 +393,7 @@ static bool project_f(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
                                }
 
                                /* Destroy the trap */
-                               cave_alter_feat(y, x, FF_DISARM);
+                               cave_alter_feat(caster_ptr, y, x, FF_DISARM);
                        }
 
                        /* Locked doors are unlocked */
@@ -401,7 +402,7 @@ static bool project_f(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
                                FEAT_IDX old_feat = g_ptr->feat;
 
                                /* Unlock the door */
-                               cave_alter_feat(y, x, FF_DISARM);
+                               cave_alter_feat(caster_ptr, y, x, FF_DISARM);
 
                                /* Check line of sound */
                                if (known && (old_feat != g_ptr->feat))
@@ -412,7 +413,7 @@ static bool project_f(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
                        }
 
                        /* Remove "unsafe" flag if player is not blind */
-                       if (!p_ptr->blind && player_has_los_bold(p_ptr, y, x))
+                       if (!caster_ptr->blind && player_has_los_bold(caster_ptr, y, x))
                        {
                                g_ptr->info &= ~(CAVE_UNSAFE);
                                lite_spot(y, x);
@@ -436,11 +437,11 @@ static bool project_f(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
                                }
 
                                /* Destroy the feature */
-                               cave_alter_feat(y, x, FF_TUNNEL);
+                               cave_alter_feat(caster_ptr, y, x, FF_TUNNEL);
                        }
 
                        /* Remove "unsafe" flag if player is not blind */
-                       if (!p_ptr->blind && player_has_los_bold(p_ptr, y, x))
+                       if (!caster_ptr->blind && player_has_los_bold(caster_ptr, y, x))
                        {
                                g_ptr->info &= ~(CAVE_UNSAFE);
                                lite_spot(y, x);
@@ -457,7 +458,7 @@ static bool project_f(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
                                s16b old_mimic = g_ptr->mimic;
                                feature_type *mimic_f_ptr = &f_info[get_feat_mimic(g_ptr)];
 
-                               cave_alter_feat(y, x, FF_SPIKE);
+                               cave_alter_feat(caster_ptr, y, x, FF_SPIKE);
                                g_ptr->mimic = old_mimic;
 
                                note_spot(y, x);
@@ -470,6 +471,7 @@ static bool project_f(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
                                        obvious = TRUE;
                                }
                        }
+
                        break;
                }
 
@@ -485,8 +487,8 @@ static bool project_f(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
                                }
 
                                /* Destroy the wall */
-                               cave_alter_feat(y, x, FF_HURT_ROCK);
-                               p_ptr->update |= (PU_FLOW);
+                               cave_alter_feat(caster_ptr, y, x, FF_HURT_ROCK);
+                               caster_ptr->update |= (PU_FLOW);
                        }
 
                        break;
@@ -494,31 +496,31 @@ static bool project_f(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
 
                case GF_MAKE_DOOR:
                {
-                       if (!cave_naked_bold(p_ptr, floor_ptr, y, x)) break;
-                       if (player_bold(p_ptr, y, x)) break;
-                       cave_set_feat(floor_ptr, y, x, feat_door[DOOR_DOOR].closed);
+                       if (!cave_naked_bold(caster_ptr, floor_ptr, y, x)) break;
+                       if (player_bold(caster_ptr, y, x)) break;
+                       cave_set_feat(caster_ptr, y, x, feat_door[DOOR_DOOR].closed);
                        if (g_ptr->info & (CAVE_MARK)) obvious = TRUE;
                        break;
                }
 
                case GF_MAKE_TRAP:
                {
-                       place_trap(floor_ptr, y, x);
+                       place_trap(caster_ptr, y, x);
                        break;
                }
 
                case GF_MAKE_TREE:
                {
-                       if (!cave_naked_bold(p_ptr, floor_ptr, y, x)) break;
-                       if (player_bold(p_ptr, y, x)) break;
-                       cave_set_feat(floor_ptr, y, x, feat_tree);
+                       if (!cave_naked_bold(caster_ptr, floor_ptr, y, x)) break;
+                       if (player_bold(caster_ptr, y, x)) break;
+                       cave_set_feat(caster_ptr, y, x, feat_tree);
                        if (g_ptr->info & (CAVE_MARK)) obvious = TRUE;
                        break;
                }
 
                case GF_MAKE_GLYPH:
                {
-                       if (!cave_naked_bold(p_ptr, floor_ptr, y, x)) break;
+                       if (!cave_naked_bold(caster_ptr, floor_ptr, y, x)) break;
                        g_ptr->info |= CAVE_OBJECT;
                        g_ptr->mimic = feat_glyph;
                        note_spot(y, x);
@@ -528,9 +530,9 @@ static bool project_f(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
 
                case GF_STONE_WALL:
                {
-                       if (!cave_naked_bold(p_ptr, floor_ptr, y, x)) break;
-                       if (player_bold(p_ptr, y, x)) break;
-                       cave_set_feat(floor_ptr, y, x, feat_granite);
+                       if (!cave_naked_bold(caster_ptr, floor_ptr, y, x)) break;
+                       if (player_bold(caster_ptr, y, x)) break;
+                       cave_set_feat(caster_ptr, y, x, feat_granite);
                        break;
                }
 
@@ -540,12 +542,13 @@ static bool project_f(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
                        if (dam == 1)
                        {
                                if (!have_flag(f_ptr->flags, FF_FLOOR)) break;
-                               cave_set_feat(floor_ptr, y, x, feat_shallow_lava);
+                               cave_set_feat(caster_ptr, y, x, feat_shallow_lava);
                        }
                        else if (dam)
                        {
-                               cave_set_feat(floor_ptr, y, x, feat_deep_lava);
+                               cave_set_feat(caster_ptr, y, x, feat_deep_lava);
                        }
+
                        break;
                }
 
@@ -555,12 +558,13 @@ static bool project_f(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
                        if (dam == 1)
                        {
                                if (!have_flag(f_ptr->flags, FF_FLOOR)) break;
-                               cave_set_feat(floor_ptr, y, x, feat_shallow_water);
+                               cave_set_feat(caster_ptr, y, x, feat_shallow_water);
                        }
                        else if (dam)
                        {
-                               cave_set_feat(floor_ptr, y, x, feat_deep_water);
+                               cave_set_feat(caster_ptr, y, x, feat_deep_water);
                        }
+
                        break;
                }
 
@@ -569,23 +573,23 @@ static bool project_f(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
                case GF_LITE:
                {
                        /* Turn on the light */
-                       if (!(d_info[p_ptr->dungeon_idx].flags1 & DF1_DARKNESS))
+                       if (!(d_info[caster_ptr->dungeon_idx].flags1 & DF1_DARKNESS))
                        {
                                g_ptr->info |= (CAVE_GLOW);
                                note_spot(y, x);
                                lite_spot(y, x);
-                               update_local_illumination(p_ptr, y, x);
+                               update_local_illumination(caster_ptr, y, x);
 
                                /* Observe */
-                               if (player_can_see_bold(y, x)) obvious = TRUE;
+                               if (player_can_see_bold(caster_ptr, y, x)) obvious = TRUE;
 
                                /* Mega-Hack -- Update the monster in the affected grid */
                                /* This allows "spear of light" (etc) to work "correctly" */
-                               if (g_ptr->m_idx) update_monster(p_ptr, g_ptr->m_idx, FALSE);
+                               if (g_ptr->m_idx) update_monster(caster_ptr, g_ptr->m_idx, FALSE);
 
-                               if (p_ptr->special_defense & NINJA_S_STEALTH)
+                               if (caster_ptr->special_defense & NINJA_S_STEALTH)
                                {
-                                       if (player_bold(p_ptr, y, x)) set_superstealth(p_ptr, FALSE);
+                                       if (player_bold(caster_ptr, y, x)) set_superstealth(caster_ptr, FALSE);
                                }
                        }
 
@@ -596,7 +600,7 @@ static bool project_f(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
                case GF_DARK_WEAK:
                case GF_DARK:
                {
-                       bool do_dark = !p_ptr->phase_out && !is_mirror_grid(g_ptr);
+                       bool do_dark = !caster_ptr->phase_out && !is_mirror_grid(g_ptr);
                        int j;
 
                        /* Turn off the light. */
@@ -637,13 +641,13 @@ static bool project_f(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
 
                                lite_spot(y, x);
 
-                               update_local_illumination(p_ptr, y, x);
+                               update_local_illumination(caster_ptr, y, x);
 
-                               if (player_can_see_bold(y, x)) obvious = TRUE;
+                               if (player_can_see_bold(caster_ptr, y, x)) obvious = TRUE;
 
                                /* Mega-Hack -- Update the monster in the affected grid */
                                /* This allows "spear of light" (etc) to work "correctly" */
-                               if (g_ptr->m_idx) update_monster(p_ptr, g_ptr->m_idx, FALSE);
+                               if (g_ptr->m_idx) update_monster(caster_ptr, g_ptr->m_idx, FALSE);
                        }
 
                        /* All done */
@@ -655,49 +659,51 @@ static bool project_f(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
                {
                        if (is_mirror_grid(g_ptr))
                        {
-                               msg_print(_("鏡が割れた!", "The mirror was crashed!"));
+                               msg_print(_("鏡が割れた!", "The mirror was shattered!"));
                                sound(SOUND_GLASS);
-                               remove_mirror(y, x);
-                               project(0, 2, y, x, p_ptr->lev / 2 + 5, GF_SHARDS, (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP | PROJECT_NO_HANGEKI), -1);
+                               remove_mirror(caster_ptr, y, x);
+                               project(caster_ptr, 0, 2, y, x, caster_ptr->lev / 2 + 5, GF_SHARDS, (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP | PROJECT_NO_HANGEKI), -1);
                        }
 
                        if (have_flag(f_ptr->flags, FF_GLASS) && !have_flag(f_ptr->flags, FF_PERMANENT) && (dam >= 50))
                        {
                                if (known && (g_ptr->info & CAVE_MARK))
                                {
-                                       msg_format(_("%sが割れた!", "The %s was crashed!"), f_name + f_info[get_feat_mimic(g_ptr)].name);
+                                       msg_format(_("%sが割れた!", "The %s crumbled!"), f_name + f_info[get_feat_mimic(g_ptr)].name);
                                        sound(SOUND_GLASS);
                                }
 
                                /* Destroy the wall */
-                               cave_alter_feat(y, x, FF_HURT_ROCK);
-                               p_ptr->update |= (PU_FLOW);
+                               cave_alter_feat(caster_ptr, y, x, FF_HURT_ROCK);
+                               caster_ptr->update |= (PU_FLOW);
                        }
+
                        break;
                }
 
                case GF_SOUND:
                {
-                       if (is_mirror_grid(g_ptr) && p_ptr->lev < 40)
+                       if (is_mirror_grid(g_ptr) && caster_ptr->lev < 40)
                        {
-                               msg_print(_("鏡が割れた!", "The mirror was crashed!"));
+                               msg_print(_("鏡が割れた!", "The mirror was shattered!"));
                                sound(SOUND_GLASS);
-                               remove_mirror(y, x);
-                               project(0, 2, y, x, p_ptr->lev / 2 + 5, GF_SHARDS, (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP | PROJECT_NO_HANGEKI), -1);
+                               remove_mirror(caster_ptr, y, x);
+                               project(caster_ptr, 0, 2, y, x, caster_ptr->lev / 2 + 5, GF_SHARDS, (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP | PROJECT_NO_HANGEKI), -1);
                        }
 
                        if (have_flag(f_ptr->flags, FF_GLASS) && !have_flag(f_ptr->flags, FF_PERMANENT) && (dam >= 200))
                        {
                                if (known && (g_ptr->info & CAVE_MARK))
                                {
-                                       msg_format(_("%sが割れた!", "The %s was crashed!"), f_name + f_info[get_feat_mimic(g_ptr)].name);
+                                       msg_format(_("%sが割れた!", "The %s crumbled!"), f_name + f_info[get_feat_mimic(g_ptr)].name);
                                        sound(SOUND_GLASS);
                                }
 
                                /* Destroy the wall */
-                               cave_alter_feat(y, x, FF_HURT_ROCK);
-                               p_ptr->update |= (PU_FLOW);
+                               cave_alter_feat(caster_ptr, y, x, FF_HURT_ROCK);
+                               caster_ptr->update |= (PU_FLOW);
                        }
+
                        break;
                }
 
@@ -705,17 +711,18 @@ static bool project_f(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
                {
                        /* Destroy mirror/glyph */
                        if (is_mirror_grid(g_ptr) || is_glyph_grid(g_ptr) || is_explosive_rune_grid(g_ptr))
-                               remove_mirror(y, x);
+                               remove_mirror(caster_ptr, y, x);
 
                        /* Permanent features don't get effect */
                        /* But not protect monsters and other objects */
                        if (have_flag(f_ptr->flags, FF_HURT_DISI) && !have_flag(f_ptr->flags, FF_PERMANENT))
                        {
-                               cave_alter_feat(y, x, FF_HURT_DISI);
+                               cave_alter_feat(caster_ptr, y, x, FF_HURT_DISI);
 
                                /* Update some things -- similar to GF_KILL_WALL */
-                               p_ptr->update |= (PU_FLOW);
+                               caster_ptr->update |= (PU_FLOW);
                        }
+
                        break;
                }
        }
@@ -729,6 +736,7 @@ static bool project_f(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
 
 /*!
  * @brief 汎用的なビーム/ボルト/ボール系によるアイテムオブジェクトへの効果処理 / Handle a beam/bolt/ball causing damage to a monster.
+ * @param caster_ptr プレーヤーへの参照ポインタ
  * @param who 魔法を発動したモンスター(0ならばプレイヤー) / Index of "source" monster (zero for "player")
  * @param r 効果半径(ビーム/ボルト = 0 / ボール = 1以上) / Radius of explosion (0 = beam/bolt, 1 to 9 = ball)
  * @param y 目標Y座標 / Target y location (or location to travel "towards")
@@ -754,14 +762,14 @@ static bool project_f(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
  * We return "TRUE" if the effect of the projection is "obvious".
  * </pre>
  */
-static bool project_o(MONSTER_IDX who, POSITION r, POSITION y, POSITION x, HIT_POINT dam, EFFECT_ID typ)
+static bool project_o(player_type *caster_ptr, MONSTER_IDX who, POSITION r, POSITION y, POSITION x, HIT_POINT dam, EFFECT_ID typ)
 {
-       grid_type *g_ptr = &p_ptr->current_floor_ptr->grid_array[y][x];
+       grid_type *g_ptr = &caster_ptr->current_floor_ptr->grid_array[y][x];
 
        OBJECT_IDX this_o_idx, next_o_idx = 0;
 
        bool obvious = FALSE;
-       bool known = player_has_los_bold(p_ptr, y, x);
+       bool known = player_has_los_bold(caster_ptr, y, x);
 
        BIT_FLAGS flgs[TR_FLAG_SIZE];
 
@@ -780,7 +788,7 @@ static bool project_o(MONSTER_IDX who, POSITION r, POSITION y, POSITION x, HIT_P
        /* Scan all objects in the grid */
        for (this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
        {
-               object_type *o_ptr = &p_ptr->current_floor_ptr->o_list[this_o_idx];
+               object_type *o_ptr = &caster_ptr->current_floor_ptr->o_list[this_o_idx];
 
                bool is_art = FALSE;
                bool ignore = FALSE;
@@ -941,10 +949,10 @@ static bool project_o(MONSTER_IDX who, POSITION r, POSITION y, POSITION x, HIT_P
 
                        case GF_IDENTIFY:
                        {
-                               identify_item(o_ptr);
+                               identify_item(caster_ptr, o_ptr);
 
                                /* Auto-inscription */
-                               autopick_alter_item((-this_o_idx), FALSE);
+                               autopick_alter_item(caster_ptr, (-this_o_idx), FALSE);
                                break;
                        }
 
@@ -981,7 +989,7 @@ static bool project_o(MONSTER_IDX who, POSITION r, POSITION y, POSITION x, HIT_P
                                        int i;
                                        BIT_FLAGS mode = 0L;
 
-                                       if (!who || is_pet(&p_ptr->current_floor_ptr->m_list[who]))
+                                       if (!who || is_pet(&caster_ptr->current_floor_ptr->m_list[who]))
                                                mode |= PM_FORCE_PET;
 
                                        for (i = 0; i < o_ptr->number ; i++)
@@ -1044,7 +1052,7 @@ static bool project_o(MONSTER_IDX who, POSITION r, POSITION y, POSITION x, HIT_P
 
                                k_idx = o_ptr->k_idx;
                                is_potion = object_is_potion(o_ptr);
-                               delete_object_idx(this_o_idx);
+                               delete_object_idx(caster_ptr->current_floor_ptr, this_o_idx);
 
                                /* Potions produce effects when 'shattered' */
                                if (is_potion)
@@ -1058,12 +1066,13 @@ static bool project_o(MONSTER_IDX who, POSITION r, POSITION y, POSITION x, HIT_P
        }
 
        /* Return "Anything seen?" */
-       return (obvious);
+       return obvious;
 }
 
 
 /*!
  * @brief 汎用的なビーム/ボルト/ボール系によるモンスターへの効果処理 / Handle a beam/bolt/ball causing damage to a monster.
+ * @param caster_ptr プレーヤーへの参照ポインタ
  * @param who 魔法を発動したモンスター(0ならばプレイヤー) / Index of "source" monster (zero for "player")
  * @param r 効果半径(ビーム/ボルト = 0 / ボール = 1以上) / Radius of explosion (0 = beam/bolt, 1 to 9 = ball)
  * @param y 目標Y座標 / Target y location (or location to travel "towards")
@@ -1130,14 +1139,15 @@ static bool project_o(MONSTER_IDX who, POSITION r, POSITION y, POSITION x, HIT_P
  * "flg" was added.
  * </pre>
  */
-static bool project_m(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITION y, POSITION x, HIT_POINT dam, EFFECT_ID typ, BIT_FLAGS flg, bool see_s_msg)
+static bool project_m(player_type *caster_ptr, MONSTER_IDX who, POSITION r, POSITION y, POSITION x, HIT_POINT dam, EFFECT_ID typ, BIT_FLAGS flg, bool see_s_msg)
 {
        int tmp;
 
+       floor_type *floor_ptr = caster_ptr->current_floor_ptr;
        grid_type *g_ptr = &floor_ptr->grid_array[y][x];
 
        monster_type *m_ptr = &floor_ptr->m_list[g_ptr->m_idx];
-       monster_type *caster_ptr = (who > 0) ? &floor_ptr->m_list[who] : NULL;
+       monster_type *m_caster_ptr = (who > 0) ? &floor_ptr->m_list[who] : NULL;
 
        monster_race *r_ptr = &r_info[m_ptr->r_idx];
 
@@ -1153,7 +1163,7 @@ static bool project_m(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
        bool obvious = FALSE;
 
        /* Can the player know about this effect? */
-       bool known = ((m_ptr->cdis <= MAX_SIGHT) || p_ptr->phase_out);
+       bool known = ((m_ptr->cdis <= MAX_SIGHT) || caster_ptr->phase_out);
 
        /* Were the effects "irrelevant"? */
        bool skipped = FALSE;
@@ -1196,19 +1206,19 @@ static bool project_m(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
        /* Assume a default death */
        concptr note_dies = extract_note_dies(real_r_idx(m_ptr));
 
-       DEPTH caster_lev = (who > 0) ? r_info[caster_ptr->r_idx].level : (p_ptr->lev * 2);
+       DEPTH caster_lev = (who > 0) ? r_info[m_caster_ptr->r_idx].level : (caster_ptr->lev * 2);
 
        /* Nobody here */
-       if (!g_ptr->m_idx) return (FALSE);
+       if (!g_ptr->m_idx) return FALSE;
 
        /* Never affect projector */
-       if (who && (g_ptr->m_idx == who)) return (FALSE);
-       if ((g_ptr->m_idx == p_ptr->riding) && !who && !(typ == GF_OLD_HEAL) && !(typ == GF_OLD_SPEED) && !(typ == GF_STAR_HEAL)) return (FALSE);
+       if (who && (g_ptr->m_idx == who)) return FALSE;
+       if ((g_ptr->m_idx == caster_ptr->riding) && !who && !(typ == GF_OLD_HEAL) && !(typ == GF_OLD_SPEED) && !(typ == GF_STAR_HEAL)) return FALSE;
        if (sukekaku && ((m_ptr->r_idx == MON_SUKE) || (m_ptr->r_idx == MON_KAKU))) return FALSE;
 
        /* Don't affect already death monsters */
        /* Prevents problems with chain reactions of exploding monsters */
-       if (m_ptr->hp < 0) return (FALSE);
+       if (m_ptr->hp < 0) return FALSE;
 
        /* Reduce damage by distance */
        dam = (dam + r) / (r + 1);
@@ -1220,7 +1230,7 @@ static bool project_m(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
        /* Get the monster possessive ("his"/"her"/"its") */
        monster_desc(m_poss, m_ptr, MD_PRON_VISIBLE | MD_POSSESSIVE);
 
-       if (p_ptr->riding && (g_ptr->m_idx == p_ptr->riding)) disturb(p_ptr, TRUE, TRUE);
+       if (caster_ptr->riding && (g_ptr->m_idx == caster_ptr->riding)) disturb(caster_ptr, TRUE, TRUE);
 
        if (r_ptr->flagsr & RFR_RES_ALL &&
                typ != GF_OLD_CLONE && typ != GF_STAR_HEAL && typ != GF_OLD_HEAL
@@ -1574,7 +1584,7 @@ static bool project_m(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
                                /* Normal monsters slow down */
                                else
                                {
-                                       if (set_monster_slow(g_ptr->m_idx, MON_SLOW(m_ptr) + 50))
+                                       if (set_monster_slow(caster_ptr, g_ptr->m_idx, MON_SLOW(m_ptr) + 50))
                                        {
                                                note = _("の動きが遅くなった。", " starts moving slower.");
                                        }
@@ -1621,7 +1631,7 @@ static bool project_m(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
 
                        if (!resist_tele) do_dist = 10;
                        else do_dist = 0;
-                       if (p_ptr->riding && (g_ptr->m_idx == p_ptr->riding)) do_dist = 0;
+                       if (caster_ptr->riding && (g_ptr->m_idx == caster_ptr->riding)) do_dist = 0;
 
                        if (r_ptr->flagsr & RFR_RES_GRAV)
                        {
@@ -1642,7 +1652,7 @@ static bool project_m(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
                                /* Normal monsters slow down */
                                else
                                {
-                                       if (set_monster_slow(g_ptr->m_idx, MON_SLOW(m_ptr) + 50))
+                                       if (set_monster_slow(caster_ptr, g_ptr->m_idx, MON_SLOW(m_ptr) + 50))
                                        {
                                                note = _("の動きが遅くなった。", " starts moving slower.");
                                        }
@@ -1694,7 +1704,7 @@ static bool project_m(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
                        if (seen) obvious = TRUE;
 
                        /* PSI only works if the monster can see you! -- RG */
-                       if (!(los(floor_ptr, m_ptr->fy, m_ptr->fx, p_ptr->y, p_ptr->x)))
+                       if (!(los(caster_ptr, m_ptr->fy, m_ptr->fx, caster_ptr->y, caster_ptr->x)))
                        {
                                if (seen_msg)
                                        msg_format(_("%sはあなたが見えないので影響されない!", "%^s can't see you, and isn't affected!"), m_name);
@@ -1720,7 +1730,7 @@ static bool project_m(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
                                 * attacks back on them
                                 */
                                if ((r_ptr->flags3 & (RF3_UNDEAD | RF3_DEMON)) &&
-                                       (r_ptr->level > p_ptr->lev / 2) &&
+                                       (r_ptr->level > caster_ptr->lev / 2) &&
                                        one_in_(2))
                                {
                                        note = NULL;
@@ -1729,7 +1739,7 @@ static bool project_m(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
                                                        "%^ss corrupted mind backlashes your attack!")), m_name);
 
                                        /* Saving throw */
-                                       if ((randint0(100 + r_ptr->level / 2) < p_ptr->skill_sav) && !CHECK_MULTISHADOW(p_ptr))
+                                       if ((randint0(100 + r_ptr->level / 2) < caster_ptr->skill_sav) && !CHECK_MULTISHADOW(caster_ptr))
                                        {
                                                msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
                                        }
@@ -1737,28 +1747,28 @@ static bool project_m(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
                                        {
                                                /* Injure +/- confusion */
                                                monster_desc(killer, m_ptr, MD_WRONGDOER_NAME);
-                                               take_hit(p_ptr, DAMAGE_ATTACK, dam, killer, -1);  /* has already been /3 */
-                                               if (one_in_(4) && !CHECK_MULTISHADOW(p_ptr))
+                                               take_hit(caster_ptr, DAMAGE_ATTACK, dam, killer, -1);  /* has already been /3 */
+                                               if (one_in_(4) && !CHECK_MULTISHADOW(caster_ptr))
                                                {
                                                        switch (randint1(4))
                                                        {
                                                        case 1:
-                                                               set_confused(p_ptr, p_ptr->confused + 3 + randint1(dam));
+                                                               set_confused(caster_ptr, caster_ptr->confused + 3 + randint1(dam));
                                                                break;
                                                        case 2:
-                                                               set_stun(p_ptr, p_ptr->stun + randint1(dam));
+                                                               set_stun(caster_ptr, caster_ptr->stun + randint1(dam));
                                                                break;
                                                        case 3:
                                                        {
                                                                if (r_ptr->flags3 & RF3_NO_FEAR)
                                                                        note = _("には効果がなかった。", " is unaffected.");
                                                                else
-                                                                       set_afraid(p_ptr, p_ptr->afraid + 3 + randint1(dam));
+                                                                       set_afraid(caster_ptr, caster_ptr->afraid + 3 + randint1(dam));
                                                                break;
                                                        }
                                                        default:
-                                                               if (!p_ptr->free_act)
-                                                                       (void)set_paralyzed(p_ptr, p_ptr->paralyzed + randint1(dam));
+                                                               if (!caster_ptr->free_act)
+                                                                       (void)set_paralyzed(caster_ptr, caster_ptr->paralyzed + randint1(dam));
                                                                break;
                                                        }
                                                }
@@ -1811,7 +1821,7 @@ static bool project_m(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
                                 * attacks back on them
                                 */
                                if ((r_ptr->flags3 & (RF3_UNDEAD | RF3_DEMON)) &&
-                                       (r_ptr->level > p_ptr->lev / 2) &&
+                                       (r_ptr->level > caster_ptr->lev / 2) &&
                                        (one_in_(2)))
                                {
                                        note = NULL;
@@ -1819,7 +1829,7 @@ static bool project_m(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
                                                (seen ? "%^s's corrupted mind backlashes your attack!" :
                                                        "%^ss corrupted mind backlashes your attack!")), m_name);
                                        /* Saving throw */
-                                       if ((randint0(100 + r_ptr->level / 2) < p_ptr->skill_sav) && !CHECK_MULTISHADOW(p_ptr))
+                                       if ((randint0(100 + r_ptr->level / 2) < caster_ptr->skill_sav) && !CHECK_MULTISHADOW(caster_ptr))
                                        {
                                                msg_print(_("あなたは効力を跳ね返した!", "You resist the effects!"));
                                        }
@@ -1827,15 +1837,15 @@ static bool project_m(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
                                        {
                                                /* Injure + mana drain */
                                                monster_desc(killer, m_ptr, MD_WRONGDOER_NAME);
-                                               if (!CHECK_MULTISHADOW(p_ptr))
+                                               if (!CHECK_MULTISHADOW(caster_ptr))
                                                {
                                                        msg_print(_("超能力パワーを吸いとられた!", "Your psychic energy is drained!"));
-                                                       p_ptr->csp -= damroll(5, dam) / 2;
-                                                       if (p_ptr->csp < 0) p_ptr->csp = 0;
-                                                       p_ptr->redraw |= PR_MANA;
-                                                       p_ptr->window |= (PW_SPELL);
+                                                       caster_ptr->csp -= damroll(5, dam) / 2;
+                                                       if (caster_ptr->csp < 0) caster_ptr->csp = 0;
+                                                       caster_ptr->redraw |= PR_MANA;
+                                                       caster_ptr->window |= (PW_SPELL);
                                                }
-                                               take_hit(p_ptr, DAMAGE_ATTACK, dam, killer, -1);  /* has already been /3 */
+                                               take_hit(caster_ptr, DAMAGE_ATTACK, dam, killer, -1);  /* has already been /3 */
                                        }
                                        dam = 0;
                                }
@@ -1843,16 +1853,16 @@ static bool project_m(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
                        else if (dam > 0)
                        {
                                int b = damroll(5, dam) / 4;
-                               concptr str = (p_ptr->pclass == CLASS_MINDCRAFTER) ? _("超能力パワー", "psychic energy") : _("魔力", "mana");
+                               concptr str = (caster_ptr->pclass == CLASS_MINDCRAFTER) ? _("超能力パワー", "psychic energy") : _("魔力", "mana");
                                concptr msg = _("あなたは%sの苦痛を%sに変換した!",
                                        (seen ? "You convert %s's pain into %s!" :
                                                "You convert %ss pain into %s!"));
                                msg_format(msg, m_name, str);
 
-                               b = MIN(p_ptr->msp, p_ptr->csp + b);
-                               p_ptr->csp = b;
-                               p_ptr->redraw |= PR_MANA;
-                               p_ptr->window |= (PW_SPELL);
+                               b = MIN(caster_ptr->msp, caster_ptr->csp + b);
+                               caster_ptr->csp = b;
+                               caster_ptr->redraw |= PR_MANA;
+                               caster_ptr->window |= (PW_SPELL);
                        }
                        note_dies = _("の精神は崩壊し、肉体は抜け殻となった。", " collapses, a mindless husk.");
                        break;
@@ -1863,7 +1873,7 @@ static bool project_m(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
                        if (seen) obvious = TRUE;
                        if (one_in_(4))
                        {
-                               if (p_ptr->riding && (g_ptr->m_idx == p_ptr->riding)) do_dist = 0;
+                               if (caster_ptr->riding && (g_ptr->m_idx == caster_ptr->riding)) do_dist = 0;
                                else do_dist = 7;
                        }
 
@@ -1919,7 +1929,7 @@ static bool project_m(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
                                 * attacks back on them
                                 */
                                if ((r_ptr->flags3 & (RF3_UNDEAD | RF3_DEMON)) &&
-                                       (r_ptr->level > p_ptr->lev / 2) &&
+                                       (r_ptr->level > caster_ptr->lev / 2) &&
                                        (one_in_(2)))
                                {
                                        note = NULL;
@@ -1928,7 +1938,7 @@ static bool project_m(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
                                                        "%^ss corrupted mind backlashes your attack!")), m_name);
 
                                        /* Saving throw */
-                                       if (randint0(100 + r_ptr->level / 2) < p_ptr->skill_sav)
+                                       if (randint0(100 + r_ptr->level / 2) < caster_ptr->skill_sav)
                                        {
                                                msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
                                        }
@@ -1938,17 +1948,17 @@ static bool project_m(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
                                                switch (randint1(4))
                                                {
                                                case 1:
-                                                       set_stun(p_ptr, p_ptr->stun + dam / 2);
+                                                       set_stun(caster_ptr, caster_ptr->stun + dam / 2);
                                                        break;
                                                case 2:
-                                                       set_confused(p_ptr, p_ptr->confused + dam / 2);
+                                                       set_confused(caster_ptr, caster_ptr->confused + dam / 2);
                                                        break;
                                                default:
                                                {
                                                        if (r_ptr->flags3 & RF3_NO_FEAR)
                                                                note = _("には効果がなかった。", " is unaffected.");
                                                        else
-                                                               set_afraid(p_ptr, p_ptr->afraid + dam);
+                                                               set_afraid(caster_ptr, caster_ptr->afraid + dam);
                                                }
                                                }
                                        }
@@ -1962,7 +1972,7 @@ static bool project_m(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
                        }
                        else
                        {
-                               if (!common_saving_throw_charm(p_ptr, dam, m_ptr))
+                               if (!common_saving_throw_charm(caster_ptr, dam, m_ptr))
                                {
                                        note = _("があなたに隷属した。", " is in your thrall!");
                                        set_pet(m_ptr);
@@ -2117,7 +2127,7 @@ static bool project_m(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
                        if (seen) obvious = TRUE;
 
                        /* Wake up */
-                       (void)set_monster_csleep(g_ptr->m_idx, 0);
+                       (void)set_monster_csleep(caster_ptr, g_ptr->m_idx, 0);
 
                        if (m_ptr->maxhp < m_ptr->max_maxhp)
                        {
@@ -2128,8 +2138,8 @@ static bool project_m(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
                        if (!dam)
                        {
                                /* Redraw (later) if needed */
-                               if (p_ptr->health_who == g_ptr->m_idx) p_ptr->redraw |= (PR_HEALTH);
-                               if (p_ptr->riding == g_ptr->m_idx) p_ptr->redraw |= (PR_UHEALTH);
+                               if (caster_ptr->health_who == g_ptr->m_idx) caster_ptr->redraw |= (PR_HEALTH);
+                               if (caster_ptr->riding == g_ptr->m_idx) caster_ptr->redraw |= (PR_UHEALTH);
                                break;
                        }
 
@@ -2140,21 +2150,21 @@ static bool project_m(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
                        if (seen) obvious = TRUE;
 
                        /* Wake up */
-                       (void)set_monster_csleep(g_ptr->m_idx, 0);
+                       (void)set_monster_csleep(caster_ptr, g_ptr->m_idx, 0);
                        if (MON_STUNNED(m_ptr))
                        {
                                if (seen_msg) msg_format(_("%^sは朦朧状態から立ち直った。", "%^s is no longer stunned."), m_name);
-                               (void)set_monster_stunned(g_ptr->m_idx, 0);
+                               (void)set_monster_stunned(caster_ptr, g_ptr->m_idx, 0);
                        }
                        if (MON_CONFUSED(m_ptr))
                        {
                                if (seen_msg) msg_format(_("%^sは混乱から立ち直った。", "%^s is no longer confused."), m_name);
-                               (void)set_monster_confused(g_ptr->m_idx, 0);
+                               (void)set_monster_confused(caster_ptr, g_ptr->m_idx, 0);
                        }
                        if (MON_MONFEAR(m_ptr))
                        {
                                if (seen_msg) msg_format(_("%^sは勇気を取り戻した。", "%^s recovers %s courage."), m_name);
-                               (void)set_monster_monfear(g_ptr->m_idx, 0);
+                               (void)set_monster_monfear(caster_ptr, g_ptr->m_idx, 0);
                        }
 
                        /* Heal */
@@ -2165,34 +2175,34 @@ static bool project_m(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
 
                        if (!who)
                        {
-                               chg_virtue(p_ptr, V_VITALITY, 1);
+                               chg_virtue(caster_ptr, V_VITALITY, 1);
 
                                if (r_ptr->flags1 & RF1_UNIQUE)
-                                       chg_virtue(p_ptr, V_INDIVIDUALISM, 1);
+                                       chg_virtue(caster_ptr, V_INDIVIDUALISM, 1);
 
                                if (is_friendly(m_ptr))
-                                       chg_virtue(p_ptr, V_HONOUR, 1);
+                                       chg_virtue(caster_ptr, V_HONOUR, 1);
                                else if (!(r_ptr->flags3 & RF3_EVIL))
                                {
                                        if (r_ptr->flags3 & RF3_GOOD)
-                                               chg_virtue(p_ptr, V_COMPASSION, 2);
+                                               chg_virtue(caster_ptr, V_COMPASSION, 2);
                                        else
-                                               chg_virtue(p_ptr, V_COMPASSION, 1);
+                                               chg_virtue(caster_ptr, V_COMPASSION, 1);
                                }
 
                                if (r_ptr->flags3 & RF3_ANIMAL)
-                                       chg_virtue(p_ptr, V_NATURE, 1);
+                                       chg_virtue(caster_ptr, V_NATURE, 1);
                        }
 
                        if (m_ptr->r_idx == MON_LEPER)
                        {
                                heal_leper = TRUE;
-                               if (!who) chg_virtue(p_ptr, V_COMPASSION, 5);
+                               if (!who) chg_virtue(caster_ptr, V_COMPASSION, 5);
                        }
 
                        /* Redraw (later) if needed */
-                       if (p_ptr->health_who == g_ptr->m_idx) p_ptr->redraw |= (PR_HEALTH);
-                       if (p_ptr->riding == g_ptr->m_idx) p_ptr->redraw |= (PR_UHEALTH);
+                       if (caster_ptr->health_who == g_ptr->m_idx) caster_ptr->redraw |= (PR_HEALTH);
+                       if (caster_ptr->riding == g_ptr->m_idx) caster_ptr->redraw |= (PR_UHEALTH);
 
                        note = _("は体力を回復したようだ。", " looks healthier.");
 
@@ -2208,7 +2218,7 @@ static bool project_m(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
                        if (seen) obvious = TRUE;
 
                        /* Speed up */
-                       if (set_monster_fast(g_ptr->m_idx, MON_FAST(m_ptr) + 100))
+                       if (set_monster_fast(caster_ptr, g_ptr->m_idx, MON_FAST(m_ptr) + 100))
                        {
                                note = _("の動きが速くなった。", " starts moving faster.");
                        }
@@ -2216,9 +2226,9 @@ static bool project_m(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
                        if (!who)
                        {
                                if (r_ptr->flags1 & RF1_UNIQUE)
-                                       chg_virtue(p_ptr, V_INDIVIDUALISM, 1);
+                                       chg_virtue(caster_ptr, V_INDIVIDUALISM, 1);
                                if (is_friendly(m_ptr))
-                                       chg_virtue(p_ptr, V_HONOUR, 1);
+                                       chg_virtue(caster_ptr, V_HONOUR, 1);
                        }
 
                        /* No "real" damage */
@@ -2243,7 +2253,7 @@ static bool project_m(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
                        /* Normal monsters slow down */
                        else
                        {
-                               if (set_monster_slow(g_ptr->m_idx, MON_SLOW(m_ptr) + 50))
+                               if (set_monster_slow(caster_ptr, g_ptr->m_idx, MON_SLOW(m_ptr) + 50))
                                {
                                        note = _("の動きが遅くなった。", " starts moving slower.");
                                }
@@ -2340,22 +2350,22 @@ static bool project_m(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
                case GF_CHARM:
                {
                        int vir;
-                       vir = virtue_number(p_ptr, V_HARMONY);
+                       vir = virtue_number(caster_ptr, V_HARMONY);
                        if (vir)
                        {
-                               dam += p_ptr->virtues[vir - 1] / 10;
+                               dam += caster_ptr->virtues[vir - 1] / 10;
                        }
 
-                       vir = virtue_number(p_ptr, V_INDIVIDUALISM);
+                       vir = virtue_number(caster_ptr, V_INDIVIDUALISM);
                        if (vir)
                        {
-                               dam -= p_ptr->virtues[vir - 1] / 20;
+                               dam -= caster_ptr->virtues[vir - 1] / 20;
                        }
 
                        if (seen) obvious = TRUE;
 
                        /* Attempt a saving throw */
-                       if (common_saving_throw_charm(p_ptr, dam, m_ptr))
+                       if (common_saving_throw_charm(caster_ptr, dam, m_ptr))
                        {
 
                                /* Resist */
@@ -2365,7 +2375,7 @@ static bool project_m(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
 
                                if (one_in_(4)) m_ptr->mflag2 |= MFLAG2_NOPET;
                        }
-                       else if (p_ptr->cursed & TRC_AGGRAVATE)
+                       else if (caster_ptr->cursed & TRC_AGGRAVATE)
                        {
                                note = _("はあなたに敵意を抱いている!", " hates you too much!");
                                if (one_in_(4)) m_ptr->mflag2 |= MFLAG2_NOPET;
@@ -2375,9 +2385,9 @@ static bool project_m(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
                                note = _("は突然友好的になったようだ!", " suddenly seems friendly!");
                                set_pet(m_ptr);
 
-                               chg_virtue(p_ptr, V_INDIVIDUALISM, -1);
+                               chg_virtue(caster_ptr, V_INDIVIDUALISM, -1);
                                if (r_ptr->flags3 & RF3_ANIMAL)
-                                       chg_virtue(p_ptr, V_NATURE, 1);
+                                       chg_virtue(caster_ptr, V_NATURE, 1);
                        }
 
                        /* No "real" damage */
@@ -2391,20 +2401,20 @@ static bool project_m(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
                        int vir;
                        if (seen) obvious = TRUE;
 
-                       vir = virtue_number(p_ptr, V_UNLIFE);
+                       vir = virtue_number(caster_ptr, V_UNLIFE);
                        if (vir)
                        {
-                               dam += p_ptr->virtues[vir - 1] / 10;
+                               dam += caster_ptr->virtues[vir - 1] / 10;
                        }
 
-                       vir = virtue_number(p_ptr, V_INDIVIDUALISM);
+                       vir = virtue_number(caster_ptr, V_INDIVIDUALISM);
                        if (vir)
                        {
-                               dam -= p_ptr->virtues[vir - 1] / 20;
+                               dam -= caster_ptr->virtues[vir - 1] / 20;
                        }
 
                        /* Attempt a saving throw */
-                       if (common_saving_throw_control(p_ptr, dam, m_ptr) ||
+                       if (common_saving_throw_control(caster_ptr, dam, m_ptr) ||
                                !(r_ptr->flags3 & RF3_UNDEAD))
                        {
                                /* No obvious effect */
@@ -2412,7 +2422,7 @@ static bool project_m(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
                                obvious = FALSE;
                                if (one_in_(4)) m_ptr->mflag2 |= MFLAG2_NOPET;
                        }
-                       else if (p_ptr->cursed & TRC_AGGRAVATE)
+                       else if (caster_ptr->cursed & TRC_AGGRAVATE)
                        {
                                note = _("はあなたに敵意を抱いている!", " hates you too much!");
                                if (one_in_(4)) m_ptr->mflag2 |= MFLAG2_NOPET;
@@ -2434,20 +2444,20 @@ static bool project_m(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
                        int vir;
                        if (seen) obvious = TRUE;
 
-                       vir = virtue_number(p_ptr, V_UNLIFE);
+                       vir = virtue_number(caster_ptr, V_UNLIFE);
                        if (vir)
                        {
-                               dam += p_ptr->virtues[vir - 1] / 10;
+                               dam += caster_ptr->virtues[vir - 1] / 10;
                        }
 
-                       vir = virtue_number(p_ptr, V_INDIVIDUALISM);
+                       vir = virtue_number(caster_ptr, V_INDIVIDUALISM);
                        if (vir)
                        {
-                               dam -= p_ptr->virtues[vir - 1] / 20;
+                               dam -= caster_ptr->virtues[vir - 1] / 20;
                        }
 
                        /* Attempt a saving throw */
-                       if (common_saving_throw_control(p_ptr, dam, m_ptr) ||
+                       if (common_saving_throw_control(caster_ptr, dam, m_ptr) ||
                                !(r_ptr->flags3 & RF3_DEMON))
                        {
                                /* No obvious effect */
@@ -2455,7 +2465,7 @@ static bool project_m(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
                                obvious = FALSE;
                                if (one_in_(4)) m_ptr->mflag2 |= MFLAG2_NOPET;
                        }
-                       else if (p_ptr->cursed & TRC_AGGRAVATE)
+                       else if (caster_ptr->cursed & TRC_AGGRAVATE)
                        {
                                note = _("はあなたに敵意を抱いている!", " hates you too much!");
                                if (one_in_(4)) m_ptr->mflag2 |= MFLAG2_NOPET;
@@ -2477,20 +2487,20 @@ static bool project_m(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
                        int vir;
                        if (seen) obvious = TRUE;
 
-                       vir = virtue_number(p_ptr, V_NATURE);
+                       vir = virtue_number(caster_ptr, V_NATURE);
                        if (vir)
                        {
-                               dam += p_ptr->virtues[vir - 1] / 10;
+                               dam += caster_ptr->virtues[vir - 1] / 10;
                        }
 
-                       vir = virtue_number(p_ptr, V_INDIVIDUALISM);
+                       vir = virtue_number(caster_ptr, V_INDIVIDUALISM);
                        if (vir)
                        {
-                               dam -= p_ptr->virtues[vir - 1] / 20;
+                               dam -= caster_ptr->virtues[vir - 1] / 20;
                        }
 
                        /* Attempt a saving throw */
-                       if (common_saving_throw_control(p_ptr, dam, m_ptr) ||
+                       if (common_saving_throw_control(caster_ptr, dam, m_ptr) ||
                                !(r_ptr->flags3 & RF3_ANIMAL))
                        {
                                /* Resist */
@@ -2499,7 +2509,7 @@ static bool project_m(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
                                obvious = FALSE;
                                if (one_in_(4)) m_ptr->mflag2 |= MFLAG2_NOPET;
                        }
-                       else if (p_ptr->cursed & TRC_AGGRAVATE)
+                       else if (caster_ptr->cursed & TRC_AGGRAVATE)
                        {
                                note = _("はあなたに敵意を抱いている!", " hates you too much!");
                                if (one_in_(4)) m_ptr->mflag2 |= MFLAG2_NOPET;
@@ -2509,7 +2519,7 @@ static bool project_m(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
                                note = _("はなついた。", " is tamed!");
                                set_pet(m_ptr);
                                if (r_ptr->flags3 & RF3_ANIMAL)
-                                       chg_virtue(p_ptr, V_NATURE, 1);
+                                       chg_virtue(caster_ptr, V_NATURE, 1);
                        }
 
                        /* No "real" damage */
@@ -2522,25 +2532,25 @@ static bool project_m(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
                {
                        int vir;
 
-                       vir = virtue_number(p_ptr, V_UNLIFE);
+                       vir = virtue_number(caster_ptr, V_UNLIFE);
                        if (seen) obvious = TRUE;
 
-                       vir = virtue_number(p_ptr, V_UNLIFE);
+                       vir = virtue_number(caster_ptr, V_UNLIFE);
                        if (vir)
                        {
-                               dam -= p_ptr->virtues[vir - 1] / 10;
+                               dam -= caster_ptr->virtues[vir - 1] / 10;
                        }
 
-                       vir = virtue_number(p_ptr, V_INDIVIDUALISM);
+                       vir = virtue_number(caster_ptr, V_INDIVIDUALISM);
                        if (vir)
                        {
-                               dam -= p_ptr->virtues[vir - 1] / 20;
+                               dam -= caster_ptr->virtues[vir - 1] / 20;
                        }
 
                        msg_format(_("%sを見つめた。", "You stare into %s."), m_name);
 
                        /* Attempt a saving throw */
-                       if (common_saving_throw_charm(p_ptr, dam, m_ptr) ||
+                       if (common_saving_throw_charm(caster_ptr, dam, m_ptr) ||
                                !monster_living(m_ptr->r_idx))
                        {
                                /* Resist */
@@ -2549,7 +2559,7 @@ static bool project_m(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
                                obvious = FALSE;
                                if (one_in_(4)) m_ptr->mflag2 |= MFLAG2_NOPET;
                        }
-                       else if (p_ptr->cursed & TRC_AGGRAVATE)
+                       else if (caster_ptr->cursed & TRC_AGGRAVATE)
                        {
                                note = _("はあなたに敵意を抱いている!", " hates you too much!");
                                if (one_in_(4)) m_ptr->mflag2 |= MFLAG2_NOPET;
@@ -2559,7 +2569,7 @@ static bool project_m(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
                                note = _("を支配した。", " is tamed!");
                                set_pet(m_ptr);
                                if (r_ptr->flags3 & RF3_ANIMAL)
-                                       chg_virtue(p_ptr, V_NATURE, 1);
+                                       chg_virtue(caster_ptr, V_NATURE, 1);
                        }
 
                        /* No "real" damage */
@@ -3100,20 +3110,20 @@ static bool project_m(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
                                if (who > 0)
                                {
                                        /* Heal the monster */
-                                       if (caster_ptr->hp < caster_ptr->maxhp)
+                                       if (m_caster_ptr->hp < m_caster_ptr->maxhp)
                                        {
                                                /* Heal */
-                                               caster_ptr->hp += dam;
-                                               if (caster_ptr->hp > caster_ptr->maxhp) caster_ptr->hp = caster_ptr->maxhp;
+                                               m_caster_ptr->hp += dam;
+                                               if (m_caster_ptr->hp > m_caster_ptr->maxhp) m_caster_ptr->hp = m_caster_ptr->maxhp;
 
                                                /* Redraw (later) if needed */
-                                               if (p_ptr->health_who == who) p_ptr->redraw |= (PR_HEALTH);
-                                               if (p_ptr->riding == who) p_ptr->redraw |= (PR_UHEALTH);
+                                               if (caster_ptr->health_who == who) caster_ptr->redraw |= (PR_HEALTH);
+                                               if (caster_ptr->riding == who) caster_ptr->redraw |= (PR_UHEALTH);
 
                                                /* Special message */
                                                if (see_s_msg)
                                                {
-                                                       monster_desc(killer, caster_ptr, 0);
+                                                       monster_desc(killer, m_caster_ptr, 0);
                                                        msg_format(_("%^sは気分が良さそうだ。", "%^s appears healthier."), killer);
                                                }
                                        }
@@ -3121,7 +3131,7 @@ static bool project_m(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
                                else
                                {
                                        msg_format(_("%sから精神エネルギーを吸いとった。", "You draw psychic energy from %s."), m_name);
-                                       (void)hp_player(p_ptr, dam);
+                                       (void)hp_player(caster_ptr, dam);
                                }
                        }
                        else
@@ -3219,7 +3229,7 @@ static bool project_m(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
                                        do_conf = randint0(8) + 8;
                                        do_stun = randint0(8) + 8;
                                }
-                               (void)set_monster_slow(g_ptr->m_idx, MON_SLOW(m_ptr) + 10);
+                               (void)set_monster_slow(caster_ptr, g_ptr->m_idx, MON_SLOW(m_ptr) + 10);
                        }
                        break;
                }
@@ -3274,7 +3284,7 @@ static bool project_m(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
                                msg_format(_("%sの秘孔を突いて、「お前は既に死んでいる」と叫んだ。",
                                        "You point at %s, screaming the word, 'DIE!'."), m_name);
                        /* Attempt a saving throw */
-                       if ((randint0(100 + (caster_lev / 2)) < (r_ptr->level + 35)) && ((who <= 0) || (caster_ptr->r_idx != MON_KENSHIROU)))
+                       if ((randint0(100 + (caster_lev / 2)) < (r_ptr->level + 35)) && ((who <= 0) || (m_caster_ptr->r_idx != MON_KENSHIROU)))
                        {
                                note = _("には効果がなかった。", " is unaffected.");
                                dam = 0;
@@ -3322,7 +3332,7 @@ static bool project_m(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
                        }
 
                        if (is_pet(m_ptr)) nokori_hp = m_ptr->maxhp * 4L;
-                       else if ((p_ptr->pclass == CLASS_BEASTMASTER) && monster_living(m_ptr->r_idx))
+                       else if ((caster_ptr->pclass == CLASS_BEASTMASTER) && monster_living(m_ptr->r_idx))
                                nokori_hp = m_ptr->maxhp * 3 / 10;
                        else
                                nokori_hp = m_ptr->maxhp * 3 / 20;
@@ -3341,9 +3351,9 @@ static bool project_m(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
                                cap_hp = m_ptr->hp;
                                cap_maxhp = m_ptr->max_maxhp;
                                cap_nickname = m_ptr->nickname; /* Quark transfer */
-                               if (g_ptr->m_idx == p_ptr->riding)
+                               if (g_ptr->m_idx == caster_ptr->riding)
                                {
-                                       if (rakuba(p_ptr, -1, FALSE))
+                                       if (rakuba(caster_ptr, -1, FALSE))
                                        {
                                                msg_format(_("地面に落とされた。", "You have fallen from %s."), m_name);
                                        }
@@ -3351,7 +3361,7 @@ static bool project_m(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
 
                                delete_monster_idx(g_ptr->m_idx);
 
-                               return (TRUE);
+                               return TRUE;
                        }
                        else
                        {
@@ -3365,7 +3375,7 @@ static bool project_m(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
                case GF_ATTACK:
                {
                        /* Return this monster's death */
-                       return py_attack(p_ptr, y, x, dam);
+                       return py_attack(caster_ptr, y, x, dam);
                }
 
                /* Sleep (Use "dam" as "power") */
@@ -3409,7 +3419,7 @@ static bool project_m(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
                                /* Normal monsters slow down */
                                else
                                {
-                                       if (set_monster_slow(g_ptr->m_idx, MON_SLOW(m_ptr) + 50))
+                                       if (set_monster_slow(caster_ptr, g_ptr->m_idx, MON_SLOW(m_ptr) + 50))
                                        {
                                                note = _("の動きが遅くなった。", " starts moving slower.");
                                        }
@@ -3418,7 +3428,7 @@ static bool project_m(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
 
                        else if (effect == 2)
                        {
-                               do_stun = damroll((p_ptr->lev / 10) + 3, (dam)) + 1;
+                               do_stun = damroll((caster_ptr->lev / 10) + 3, (dam)) + 1;
 
                                /* Attempt a saving throw */
                                if ((r_ptr->flags1 & (RF1_UNIQUE)) ||
@@ -3472,10 +3482,10 @@ static bool project_m(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
                case GF_GENOCIDE:
                {
                        if (seen) obvious = TRUE;
-                       if (genocide_aux(g_ptr->m_idx, dam, !who, (r_ptr->level + 1) / 2, _("モンスター消滅", "Genocide One")))
+                       if (genocide_aux(caster_ptr, g_ptr->m_idx, dam, !who, (r_ptr->level + 1) / 2, _("モンスター消滅", "Genocide One")))
                        {
-                               if (seen_msg) msg_format(_("%sは消滅した!", "%^s disappered!"), m_name);
-                               chg_virtue(p_ptr, V_VITALITY, -1);
+                               if (seen_msg) msg_format(_("%sは消滅した!", "%^s disappeared!"), m_name);
+                               chg_virtue(caster_ptr, V_VITALITY, -1);
                                return TRUE;
                        }
 
@@ -3534,7 +3544,7 @@ static bool project_m(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
                                if (is_pet(m_ptr))
                                {
                                        note = _("の動きが速くなった。", " starts moving faster.");
-                                       (void)set_monster_fast(g_ptr->m_idx, MON_FAST(m_ptr) + 100);
+                                       (void)set_monster_fast(caster_ptr, g_ptr->m_idx, MON_FAST(m_ptr) + 100);
                                        success = TRUE;
                                }
 
@@ -3542,7 +3552,7 @@ static bool project_m(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
                                else if ((r_ptr->flags1 & (RF1_QUESTOR)) ||
                                        (r_ptr->flags1 & (RF1_UNIQUE)) ||
                                        (m_ptr->mflag2 & MFLAG2_NOPET) ||
-                                       (p_ptr->cursed & TRC_AGGRAVATE) ||
+                                       (caster_ptr->cursed & TRC_AGGRAVATE) ||
                                        ((r_ptr->level + 10) > randint1(dam)))
                                {
                                        /* Resist */
@@ -3552,7 +3562,7 @@ static bool project_m(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
                                {
                                        note = _("を支配した。", " is tamed!");
                                        set_pet(m_ptr);
-                                       (void)set_monster_fast(g_ptr->m_idx, MON_FAST(m_ptr) + 100);
+                                       (void)set_monster_fast(caster_ptr, g_ptr->m_idx, MON_FAST(m_ptr) + 100);
 
                                        /* Learn about type */
                                        if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flags3 |= (RF3_GOOD);
@@ -3601,7 +3611,7 @@ static bool project_m(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
        }
 
        /* Absolutely no effect */
-       if (skipped) return (FALSE);
+       if (skipped) return FALSE;
 
        /* "Unique" monsters cannot be polymorphed */
        if (r_ptr->flags1 & (RF1_UNIQUE)) do_poly = FALSE;
@@ -3609,23 +3619,23 @@ static bool project_m(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
        /* Quest monsters cannot be polymorphed */
        if (r_ptr->flags1 & RF1_QUESTOR) do_poly = FALSE;
 
-       if (p_ptr->riding && (g_ptr->m_idx == p_ptr->riding)) do_poly = FALSE;
+       if (caster_ptr->riding && (g_ptr->m_idx == caster_ptr->riding)) do_poly = FALSE;
 
        /* "Unique" and "quest" monsters can only be "killed" by the player. */
-       if (((r_ptr->flags1 & (RF1_UNIQUE | RF1_QUESTOR)) || (r_ptr->flags7 & RF7_NAZGUL)) && !p_ptr->phase_out)
+       if (((r_ptr->flags1 & (RF1_UNIQUE | RF1_QUESTOR)) || (r_ptr->flags7 & RF7_NAZGUL)) && !caster_ptr->phase_out)
        {
                if (who && (dam > m_ptr->hp)) dam = m_ptr->hp;
        }
 
        if (!who && slept)
        {
-               if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(p_ptr, V_COMPASSION, -1);
-               if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(p_ptr, V_HONOUR, -1);
+               if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(caster_ptr, V_COMPASSION, -1);
+               if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(caster_ptr, V_HONOUR, -1);
        }
 
        /* Modify the damage */
        tmp = dam;
-       dam = mon_damage_mod(m_ptr, dam, (bool)(typ == GF_PSY_SPEAR));
+       dam = mon_damage_mod(caster_ptr, m_ptr, dam, (bool)(typ == GF_PSY_SPEAR));
        if ((tmp > 0) && (dam == 0)) note = _("はダメージを受けていない。", " is unharmed.");
 
        /* Check for death */
@@ -3656,7 +3666,7 @@ static bool project_m(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
                        }
 
                        /* Apply stun */
-                       (void)set_monster_stunned(g_ptr->m_idx, tmp);
+                       (void)set_monster_stunned(caster_ptr, g_ptr->m_idx, tmp);
 
                        /* Get angry */
                        get_angry = TRUE;
@@ -3684,7 +3694,7 @@ static bool project_m(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
                        }
 
                        /* Apply confusion */
-                       (void)set_monster_confused(g_ptr->m_idx, tmp);
+                       (void)set_monster_confused(caster_ptr, g_ptr->m_idx, tmp);
 
                        /* Get angry */
                        get_angry = TRUE;
@@ -3708,7 +3718,7 @@ static bool project_m(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
                /* Mega-Hack -- Handle "polymorph" -- monsters get a saving throw */
                if (do_poly && (randint1(90) > r_ptr->level))
                {
-                       if (polymorph_monster(p_ptr, y, x))
+                       if (polymorph_monster(caster_ptr, y, x))
                        {
                                if (seen) obvious = TRUE;
 
@@ -3718,11 +3728,6 @@ static bool project_m(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
                                /* Turn off the damage */
                                dam = 0;
                        }
-                       else
-                       {
-                               /* No polymorph */
-                               note = _("には効果がなかった。", " is unaffected.");
-                       }
 
                        /* Hack -- Get new monster */
                        m_ptr = &floor_ptr->m_list[g_ptr->m_idx];
@@ -3738,10 +3743,10 @@ static bool project_m(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
 
                        note = _("が消え去った!", " disappears!");
 
-                       if (!who) chg_virtue(p_ptr, V_VALOUR, -1);
+                       if (!who) chg_virtue(caster_ptr, V_VALOUR, -1);
 
                        /* Teleport */
-                       teleport_away(p_ptr, g_ptr->m_idx, do_dist,
+                       teleport_away(caster_ptr, g_ptr->m_idx, do_dist,
                                (!who ? TELEPORT_DEC_VALOUR : 0L) | TELEPORT_PASSIVE);
 
                        /* Hack -- get new location */
@@ -3756,7 +3761,7 @@ static bool project_m(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
                if (do_fear)
                {
                        /* Set fear */
-                       (void)set_monster_monfear(g_ptr->m_idx, MON_MONFEAR(m_ptr) + do_fear);
+                       (void)set_monster_monfear(caster_ptr, g_ptr->m_idx, MON_MONFEAR(m_ptr) + do_fear);
 
                        /* Get angry */
                        get_angry = TRUE;
@@ -3772,11 +3777,11 @@ static bool project_m(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
        else if (who)
        {
                /* Redraw (later) if needed */
-               if (p_ptr->health_who == g_ptr->m_idx) p_ptr->redraw |= (PR_HEALTH);
-               if (p_ptr->riding == g_ptr->m_idx) p_ptr->redraw |= (PR_UHEALTH);
+               if (caster_ptr->health_who == g_ptr->m_idx) caster_ptr->redraw |= (PR_HEALTH);
+               if (caster_ptr->riding == g_ptr->m_idx) caster_ptr->redraw |= (PR_UHEALTH);
 
                /* Wake the monster up */
-               (void)set_monster_csleep(g_ptr->m_idx, 0);
+               (void)set_monster_csleep(caster_ptr, g_ptr->m_idx, 0);
 
                /* Hurt the monster */
                m_ptr->hp -= dam;
@@ -3803,7 +3808,7 @@ static bool project_m(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
                                }
                        }
 
-                       if (who > 0) monster_gain_exp(who, m_ptr->r_idx);
+                       if (who > 0) monster_gain_exp(caster_ptr, who, m_ptr->r_idx);
 
                        /* Generate treasure, etc */
                        monster_death(g_ptr->m_idx, FALSE);
@@ -3834,7 +3839,7 @@ static bool project_m(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
                        }
 
                        /* Hack -- handle sleep */
-                       if (do_sleep) (void)set_monster_csleep(g_ptr->m_idx, do_sleep);
+                       if (do_sleep) (void)set_monster_csleep(caster_ptr, g_ptr->m_idx, do_sleep);
                }
        }
 
@@ -3847,7 +3852,7 @@ static bool project_m(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
                        char m2_name[MAX_NLEN];
 
                        monster_desc(m2_name, m_ptr, MD_INDEF_VISIBLE);
-                       exe_write_diary(p_ptr, NIKKI_NAMED_PET, RECORD_NAMED_PET_HEAL_LEPER, m2_name);
+                       exe_write_diary(caster_ptr, NIKKI_NAMED_PET, RECORD_NAMED_PET_HEAL_LEPER, m2_name);
                }
 
                delete_monster_idx(g_ptr->m_idx);
@@ -3859,7 +3864,7 @@ static bool project_m(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
                bool fear = FALSE;
 
                /* Hurt the monster, check for fear and death */
-               if (mon_take_hit(g_ptr->m_idx, dam, &fear, note_dies))
+               if (mon_take_hit(caster_ptr, g_ptr->m_idx, dam, &fear, note_dies))
                {
                        /* Dead monster */
                }
@@ -3891,32 +3896,32 @@ static bool project_m(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
                        }
 
                        /* Hack -- handle sleep */
-                       if (do_sleep) (void)set_monster_csleep(g_ptr->m_idx, do_sleep);
+                       if (do_sleep) (void)set_monster_csleep(caster_ptr, g_ptr->m_idx, do_sleep);
                }
        }
 
        if ((typ == GF_BLOOD_CURSE) && one_in_(4))
        {
-               blood_curse_to_enemy(p_ptr, who);
+               blood_curse_to_enemy(caster_ptr, who);
        }
 
-       if (p_ptr->phase_out)
+       if (caster_ptr->phase_out)
        {
-               p_ptr->health_who = g_ptr->m_idx;
-               p_ptr->redraw |= (PR_HEALTH);
-               handle_stuff();
+               caster_ptr->health_who = g_ptr->m_idx;
+               caster_ptr->redraw |= (PR_HEALTH);
+               handle_stuff(caster_ptr);
        }
 
        /* Verify this code */
-       if (m_ptr->r_idx) update_monster(p_ptr, g_ptr->m_idx, FALSE);
+       if (m_ptr->r_idx) update_monster(caster_ptr, g_ptr->m_idx, FALSE);
 
        /* Redraw the monster grid */
        lite_spot(y, x);
 
        /* Update monster recall window */
-       if ((p_ptr->monster_race_idx == m_ptr->r_idx) && (seen || !m_ptr->r_idx))
+       if ((caster_ptr->monster_race_idx == m_ptr->r_idx) && (seen || !m_ptr->r_idx))
        {
-               p_ptr->window |= (PW_MONSTER);
+               caster_ptr->window |= (PW_MONSTER);
        }
 
        if ((dam > 0) && !is_pet(m_ptr) && !is_friendly(m_ptr))
@@ -3928,13 +3933,13 @@ static bool project_m(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
                                set_target(m_ptr, monster_target_y, monster_target_x);
                        }
                }
-               else if ((who > 0) && is_pet(caster_ptr) && !player_bold(p_ptr, m_ptr->target_y, m_ptr->target_x))
+               else if ((who > 0) && is_pet(m_caster_ptr) && !player_bold(caster_ptr, m_ptr->target_y, m_ptr->target_x))
                {
-                       set_target(m_ptr, caster_ptr->fy, caster_ptr->fx);
+                       set_target(m_ptr, m_caster_ptr->fy, m_caster_ptr->fx);
                }
        }
 
-       if (p_ptr->riding && (p_ptr->riding == g_ptr->m_idx) && (dam > 0))
+       if (caster_ptr->riding && (caster_ptr->riding == g_ptr->m_idx) && (dam > 0))
        {
                if (m_ptr->hp > m_ptr->maxhp / 3) dam = (dam + 1) / 2;
                rakubadam_m = (dam > 200) ? 200 : dam;
@@ -3954,7 +3959,7 @@ static bool project_m(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
 
                /* Mark the item as fully known */
                q_ptr->ident |= (IDENT_MENTAL);
-               (void)drop_near(q_ptr, -1, p_ptr->y, p_ptr->x);
+               (void)drop_near(caster_ptr, q_ptr, -1, caster_ptr->y, caster_ptr->x);
        }
 
        /* Track it */
@@ -3966,6 +3971,7 @@ static bool project_m(floor_type *floor_ptr, MONSTER_IDX who, POSITION r, POSITI
        return (obvious);
 }
 
+
 /*!
  * @brief 汎用的なビーム/ボルト/ボール系によるプレイヤーへの効果処理 / Helper function for "project()" below.
  * @param who 魔法を発動したモンスター(0ならばプレイヤー) / Index of "source" monster (zero for "player")
@@ -4020,16 +4026,16 @@ static bool project_p(MONSTER_IDX who, player_type *target_ptr, concptr who_name
 
 
        /* Player is not here */
-       if (!player_bold(p_ptr, y, x)) return (FALSE);
+       if (!player_bold(target_ptr, y, x)) return FALSE;
 
        if ((target_ptr->special_defense & NINJA_KAWARIMI) && dam && (randint0(55) < (target_ptr->lev * 3 / 5 + 20)) && who && (who != target_ptr->riding))
        {
-               if (kawarimi(TRUE)) return FALSE;
+               if (kawarimi(target_ptr, TRUE)) return FALSE;
        }
 
        /* Player cannot hurt himself */
-       if (!who) return (FALSE);
-       if (who == target_ptr->riding) return (FALSE);
+       if (!who) return FALSE;
+       if (who == target_ptr->riding) return FALSE;
 
        if ((target_ptr->reflect || ((target_ptr->special_defense & KATA_FUUJIN) && !target_ptr->blind)) && (flg & PROJECT_REFLECTABLE) && !one_in_(10))
        {
@@ -4044,7 +4050,6 @@ static bool project_p(MONSTER_IDX who, player_type *target_ptr, concptr who_name
                else
                        msg_print(_("攻撃が跳ね返った!", "The attack bounces!"));
 
-
                /* Choose 'new' target */
                if (who > 0)
                {
@@ -4053,7 +4058,7 @@ static bool project_p(MONSTER_IDX who, player_type *target_ptr, concptr who_name
                                t_y = target_ptr->current_floor_ptr->m_list[who].fy - 1 + randint1(3);
                                t_x = target_ptr->current_floor_ptr->m_list[who].fx - 1 + randint1(3);
                                max_attempts--;
-                       } while (max_attempts && in_bounds2u(target_ptr->current_floor_ptr, t_y, t_x) && !projectable(target_ptr->current_floor_ptr, target_ptr->y, target_ptr->x, t_y, t_x));
+                       } while (max_attempts && in_bounds2u(target_ptr->current_floor_ptr, t_y, t_x) && !projectable(target_ptr, target_ptr->y, target_ptr->x, t_y, t_x));
 
                        if (max_attempts < 1)
                        {
@@ -4067,7 +4072,7 @@ static bool project_p(MONSTER_IDX who, player_type *target_ptr, concptr who_name
                        t_x = target_ptr->x - 1 + randint1(3);
                }
 
-               project(0, 0, t_y, t_x, dam, typ, (PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE), monspell);
+               project(target_ptr, 0, 0, t_y, t_x, dam, typ, (PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE), monspell);
 
                disturb(target_ptr, TRUE, TRUE);
                return TRUE;
@@ -4119,7 +4124,7 @@ static bool project_p(MONSTER_IDX who, player_type *target_ptr, concptr who_name
        case GF_ACID:
        {
                if (fuzzy) msg_print(_("酸で攻撃された!", "You are hit by acid!"));
-               get_damage = acid_dam(dam, killer, monspell, FALSE);
+               get_damage = acid_dam(target_ptr, dam, killer, monspell, FALSE);
                break;
        }
 
@@ -4127,7 +4132,7 @@ static bool project_p(MONSTER_IDX who, player_type *target_ptr, concptr who_name
        case GF_FIRE:
        {
                if (fuzzy) msg_print(_("火炎で攻撃された!", "You are hit by fire!"));
-               get_damage = fire_dam(dam, killer, monspell, FALSE);
+               get_damage = fire_dam(target_ptr, dam, killer, monspell, FALSE);
                break;
        }
 
@@ -4135,7 +4140,7 @@ static bool project_p(MONSTER_IDX who, player_type *target_ptr, concptr who_name
        case GF_COLD:
        {
                if (fuzzy) msg_print(_("冷気で攻撃された!", "You are hit by cold!"));
-               get_damage = cold_dam(dam, killer, monspell, FALSE);
+               get_damage = cold_dam(target_ptr, dam, killer, monspell, FALSE);
                break;
        }
 
@@ -4143,14 +4148,14 @@ static bool project_p(MONSTER_IDX who, player_type *target_ptr, concptr who_name
        case GF_ELEC:
        {
                if (fuzzy) msg_print(_("電撃で攻撃された!", "You are hit by lightning!"));
-               get_damage = elec_dam(dam, killer, monspell, FALSE);
+               get_damage = elec_dam(target_ptr, dam, killer, monspell, FALSE);
                break;
        }
 
        /* Standard damage -- also poisons player */
        case GF_POIS:
        {
-               bool double_resist = IS_OPPOSE_POIS();
+               bool double_resist = is_oppose_pois(target_ptr);
                if (fuzzy) msg_print(_("毒で攻撃された!", "You are hit by poison!"));
 
                if (target_ptr->resist_pois) dam = (dam + 2) / 3;
@@ -4173,7 +4178,7 @@ static bool project_p(MONSTER_IDX who, player_type *target_ptr, concptr who_name
        /* Standard damage -- also poisons / mutates player */
        case GF_NUKE:
        {
-               bool double_resist = IS_OPPOSE_POIS();
+               bool double_resist = is_oppose_pois(target_ptr);
                if (fuzzy) msg_print(_("放射能で攻撃された!", "You are hit by radiation!"));
 
                if (target_ptr->resist_pois) dam = (2 * dam + 2) / 5;
@@ -4194,7 +4199,7 @@ static bool project_p(MONSTER_IDX who, player_type *target_ptr, concptr who_name
 
                        if (one_in_(6))
                        {
-                               inven_damage(set_acid_destroy, 2);
+                               inventory_damage(target_ptr, set_acid_destroy, 2);
                        }
                }
                break;
@@ -4257,9 +4262,9 @@ static bool project_p(MONSTER_IDX who, player_type *target_ptr, concptr who_name
                        (void)set_stun(target_ptr, target_ptr->stun + plus_stun);
                }
 
-               if (!(target_ptr->resist_fire || IS_OPPOSE_FIRE() || target_ptr->immune_fire))
+               if (!(target_ptr->resist_fire || is_oppose_fire(target_ptr) || target_ptr->immune_fire))
                {
-                       inven_damage(set_acid_destroy, 3);
+                       inventory_damage(target_ptr, set_acid_destroy, 3);
                }
 
                break;
@@ -4282,7 +4287,7 @@ static bool project_p(MONSTER_IDX who, player_type *target_ptr, concptr who_name
                {
                        msg_print(_("気分がよくなった。", "You feel invigorated!"));
                        hp_player(target_ptr, dam / 4);
-                       learn_spell(monspell);
+                       learn_spell(target_ptr, monspell);
                }
                else
                {
@@ -4309,7 +4314,7 @@ static bool project_p(MONSTER_IDX who, player_type *target_ptr, concptr who_name
 
                        if (one_in_(5) && !target_ptr->resist_water)
                        {
-                               inven_damage(set_cold_destroy, 3);
+                               inventory_damage(target_ptr, set_cold_destroy, 3);
                        }
 
                        if (target_ptr->resist_water) get_damage /= 4;
@@ -4350,8 +4355,8 @@ static bool project_p(MONSTER_IDX who, player_type *target_ptr, concptr who_name
 
                        if (!target_ptr->resist_chaos || one_in_(9))
                        {
-                               inven_damage(set_elec_destroy, 2);
-                               inven_damage(set_fire_destroy, 2);
+                               inventory_damage(target_ptr, set_elec_destroy, 2);
+                               inventory_damage(target_ptr, set_fire_destroy, 2);
                        }
                }
 
@@ -4374,7 +4379,7 @@ static bool project_p(MONSTER_IDX who, player_type *target_ptr, concptr who_name
 
                if (!target_ptr->resist_shard || one_in_(13))
                {
-                       inven_damage(set_cold_destroy, 2);
+                       inventory_damage(target_ptr, set_cold_destroy, 2);
                }
 
                get_damage = take_hit(target_ptr, DAMAGE_ATTACK, dam, killer, monspell);
@@ -4397,7 +4402,7 @@ static bool project_p(MONSTER_IDX who, player_type *target_ptr, concptr who_name
 
                if (!target_ptr->resist_sound || one_in_(13))
                {
-                       inven_damage(set_cold_destroy, 2);
+                       inventory_damage(target_ptr, set_cold_destroy, 2);
                }
 
                get_damage = take_hit(target_ptr, DAMAGE_ATTACK, dam, killer, monspell);
@@ -4485,7 +4490,7 @@ static bool project_p(MONSTER_IDX who, player_type *target_ptr, concptr who_name
 
                if (!target_ptr->resist_shard || one_in_(12))
                {
-                       inven_damage(set_cold_destroy, 3);
+                       inventory_damage(target_ptr, set_cold_destroy, 3);
                }
 
                get_damage = take_hit(target_ptr, DAMAGE_ATTACK, dam, killer, monspell);
@@ -4646,7 +4651,7 @@ static bool project_p(MONSTER_IDX who, player_type *target_ptr, concptr who_name
 
                if (!target_ptr->levitation || one_in_(13))
                {
-                       inven_damage(set_cold_destroy, 2);
+                       inventory_damage(target_ptr, set_cold_destroy, 2);
                }
 
                get_damage = take_hit(target_ptr, DAMAGE_ATTACK, dam, killer, monspell);
@@ -4729,8 +4734,8 @@ static bool project_p(MONSTER_IDX who, player_type *target_ptr, concptr who_name
                get_damage = take_hit(target_ptr, DAMAGE_ATTACK, dam, killer, monspell);
                if (!target_ptr->resist_shard || one_in_(13))
                {
-                       if (!target_ptr->immune_fire) inven_damage(set_fire_destroy, 2);
-                       inven_damage(set_cold_destroy, 2);
+                       if (!target_ptr->immune_fire) inventory_damage(target_ptr, set_fire_destroy, 2);
+                       inventory_damage(target_ptr, set_cold_destroy, 2);
                }
 
                break;
@@ -4740,7 +4745,7 @@ static bool project_p(MONSTER_IDX who, player_type *target_ptr, concptr who_name
        case GF_ICE:
        {
                if (fuzzy) msg_print(_("何か鋭く冷たいもので攻撃された!", "You are hit by something sharp and cold!"));
-               get_damage = cold_dam(dam, killer, monspell, FALSE);
+               get_damage = cold_dam(target_ptr, dam, killer, monspell, FALSE);
                if (!CHECK_MULTISHADOW(target_ptr))
                {
                        if (!target_ptr->resist_shard)
@@ -4752,9 +4757,9 @@ static bool project_p(MONSTER_IDX who, player_type *target_ptr, concptr who_name
                                (void)set_stun(target_ptr, target_ptr->stun + randint1(15));
                        }
 
-                       if ((!(target_ptr->resist_cold || IS_OPPOSE_COLD())) || one_in_(12))
+                       if ((!(target_ptr->resist_cold || is_oppose_cold(target_ptr))) || one_in_(12))
                        {
-                               if (!target_ptr->immune_cold) inven_damage(set_cold_destroy, 3);
+                               if (!target_ptr->immune_cold) inventory_damage(target_ptr, set_cold_destroy, 3);
                        }
                }
 
@@ -4828,7 +4833,7 @@ static bool project_p(MONSTER_IDX who, player_type *target_ptr, concptr who_name
                                target_ptr->csp -= dam;
                        }
 
-                       learn_spell(monspell);
+                       learn_spell(target_ptr, monspell);
                        target_ptr->redraw |= (PR_MANA);
                        target_ptr->window |= (PW_PLAYER | PW_SPELL);
 
@@ -4864,7 +4869,7 @@ static bool project_p(MONSTER_IDX who, player_type *target_ptr, concptr who_name
                if ((randint0(100 + rlev / 2) < MAX(5, target_ptr->skill_sav)) && !CHECK_MULTISHADOW(target_ptr))
                {
                        msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
-                       learn_spell(monspell);
+                       learn_spell(target_ptr, monspell);
                }
                else
                {
@@ -4902,7 +4907,7 @@ static bool project_p(MONSTER_IDX who, player_type *target_ptr, concptr who_name
                if ((randint0(100 + rlev / 2) < MAX(5, target_ptr->skill_sav)) && !CHECK_MULTISHADOW(target_ptr))
                {
                        msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
-                       learn_spell(monspell);
+                       learn_spell(target_ptr, monspell);
                }
                else
                {
@@ -4956,7 +4961,7 @@ static bool project_p(MONSTER_IDX who, player_type *target_ptr, concptr who_name
                if ((randint0(100 + rlev / 2) < target_ptr->skill_sav) && !CHECK_MULTISHADOW(target_ptr))
                {
                        msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
-                       learn_spell(monspell);
+                       learn_spell(target_ptr, monspell);
                }
                else
                {
@@ -4972,7 +4977,7 @@ static bool project_p(MONSTER_IDX who, player_type *target_ptr, concptr who_name
                if ((randint0(100 + rlev / 2) < target_ptr->skill_sav) && !CHECK_MULTISHADOW(target_ptr))
                {
                        msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
-                       learn_spell(monspell);
+                       learn_spell(target_ptr, monspell);
                }
                else
                {
@@ -4988,7 +4993,7 @@ static bool project_p(MONSTER_IDX who, player_type *target_ptr, concptr who_name
                if ((randint0(100 + rlev / 2) < target_ptr->skill_sav) && !CHECK_MULTISHADOW(target_ptr))
                {
                        msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
-                       learn_spell(monspell);
+                       learn_spell(target_ptr, monspell);
                }
                else
                {
@@ -5004,7 +5009,7 @@ static bool project_p(MONSTER_IDX who, player_type *target_ptr, concptr who_name
                if ((randint0(100 + rlev / 2) < target_ptr->skill_sav) && !(m_ptr->r_idx == MON_KENSHIROU) && !CHECK_MULTISHADOW(target_ptr))
                {
                        msg_print(_("しかし秘孔を跳ね返した!", "You resist the effects!"));
-                       learn_spell(monspell);
+                       learn_spell(target_ptr, monspell);
                }
                else
                {
@@ -5020,7 +5025,7 @@ static bool project_p(MONSTER_IDX who, player_type *target_ptr, concptr who_name
                if ((randint0(100 + rlev / 2) < target_ptr->skill_sav) && !CHECK_MULTISHADOW(target_ptr))
                {
                        msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
-                       learn_spell(monspell);
+                       learn_spell(target_ptr, monspell);
                }
                else
                {
@@ -5048,7 +5053,7 @@ static bool project_p(MONSTER_IDX who, player_type *target_ptr, concptr who_name
        }
 
        /* Hex - revenge damage stored */
-       revenge_store(get_damage);
+       revenge_store(target_ptr, get_damage);
 
        if ((target_ptr->tim_eyeeye || hex_spelling(HEX_EYE_FOR_EYE))
                && (get_damage > 0) && !target_ptr->is_dead && (who > 0))
@@ -5059,7 +5064,7 @@ static bool project_p(MONSTER_IDX who, player_type *target_ptr, concptr who_name
                monster_desc(m_name_self, m_ptr, MD_PRON_VISIBLE | MD_POSSESSIVE | MD_OBJECTIVE);
 
                msg_format(_("攻撃が%s自身を傷つけた!", "The attack of %s has wounded %s!"), m_name, m_name_self);
-               project(0, 0, m_ptr->fy, m_ptr->fx, get_damage, GF_MISSILE, PROJECT_KILL, -1);
+               project(target_ptr, 0, 0, m_ptr->fy, m_ptr->fx, get_damage, GF_MISSILE, PROJECT_KILL, -1);
                if (target_ptr->tim_eyeeye) set_tim_eyeeye(target_ptr, target_ptr->tim_eyeeye - 5, TRUE);
        }
 
@@ -5074,7 +5079,7 @@ static bool project_p(MONSTER_IDX who, player_type *target_ptr, concptr who_name
 
        if ((target_ptr->special_defense & NINJA_KAWARIMI) && dam && who && (who != target_ptr->riding))
        {
-               (void)kawarimi(FALSE);
+               (void)kawarimi(target_ptr, FALSE);
        }
 
        /* Return "Anything seen?" */
@@ -5109,13 +5114,12 @@ POSITION dist_to_line(POSITION y, POSITION x, POSITION y1, POSITION x1, POSITION
 }
 
 
-
 /*
  * 
  * Modified version of los() for calculation of disintegration balls.
  * Disintegration effects are stopped by permanent walls.
  */
-bool in_disintegration_range(POSITION y1, POSITION x1, POSITION y2, POSITION x2)
+bool in_disintegration_range(floor_type *floor_ptr, POSITION y1, POSITION x1, POSITION y2, POSITION x2)
 {
        POSITION dx, dy; /* Delta */
        POSITION ax, ay; /* Absolute */
@@ -5134,10 +5138,10 @@ bool in_disintegration_range(POSITION y1, POSITION x1, POSITION y2, POSITION x2)
        ax = ABS(dx);
 
        /* Handle adjacent (or identical) grids */
-       if ((ax < 2) && (ay < 2)) return (TRUE);
+       if ((ax < 2) && (ay < 2)) return TRUE;
 
        /* Paranoia -- require "safe" origin */
-       /* if (!in_bounds(p_ptr->current_floor_ptr, y1, x1)) return (FALSE); */
+       /* if (!in_bounds(floor_ptr, y1, x1)) return FALSE; */
 
        /* Directly South/North */
        if (!dx)
@@ -5147,7 +5151,7 @@ bool in_disintegration_range(POSITION y1, POSITION x1, POSITION y2, POSITION x2)
                {
                        for (ty = y1 + 1; ty < y2; ty++)
                        {
-                               if (cave_stop_disintegration(ty, x1)) return (FALSE);
+                               if (cave_stop_disintegration(floor_ptr, ty, x1)) return FALSE;
                        }
                }
 
@@ -5156,12 +5160,12 @@ bool in_disintegration_range(POSITION y1, POSITION x1, POSITION y2, POSITION x2)
                {
                        for (ty = y1 - 1; ty > y2; ty--)
                        {
-                               if (cave_stop_disintegration(ty, x1)) return (FALSE);
+                               if (cave_stop_disintegration(floor_ptr, ty, x1)) return FALSE;
                        }
                }
 
                /* Assume los */
-               return (TRUE);
+               return TRUE;
        }
 
        /* Directly East/West */
@@ -5172,7 +5176,7 @@ bool in_disintegration_range(POSITION y1, POSITION x1, POSITION y2, POSITION x2)
                {
                        for (tx = x1 + 1; tx < x2; tx++)
                        {
-                               if (cave_stop_disintegration(y1, tx)) return (FALSE);
+                               if (cave_stop_disintegration(floor_ptr, y1, tx)) return FALSE;
                        }
                }
 
@@ -5181,12 +5185,12 @@ bool in_disintegration_range(POSITION y1, POSITION x1, POSITION y2, POSITION x2)
                {
                        for (tx = x1 - 1; tx > x2; tx--)
                        {
-                               if (cave_stop_disintegration(y1, tx)) return (FALSE);
+                               if (cave_stop_disintegration(floor_ptr, y1, tx)) return FALSE;
                        }
                }
 
                /* Assume los */
-               return (TRUE);
+               return TRUE;
        }
 
        /* Extract some signs */
@@ -5198,7 +5202,7 @@ bool in_disintegration_range(POSITION y1, POSITION x1, POSITION y2, POSITION x2)
        {
                if (ay == 2)
                {
-                       if (!cave_stop_disintegration(y1 + sy, x1)) return (TRUE);
+                       if (!cave_stop_disintegration(floor_ptr, y1 + sy, x1)) return TRUE;
                }
        }
 
@@ -5207,7 +5211,7 @@ bool in_disintegration_range(POSITION y1, POSITION x1, POSITION y2, POSITION x2)
        {
                if (ax == 2)
                {
-                       if (!cave_stop_disintegration(y1, x1 + sx)) return (TRUE);
+                       if (!cave_stop_disintegration(floor_ptr, y1, x1 + sx)) return TRUE;
                }
        }
 
@@ -5242,7 +5246,7 @@ bool in_disintegration_range(POSITION y1, POSITION x1, POSITION y2, POSITION x2)
                /* the LOS exactly meets the corner of a tile. */
                while (x2 - tx)
                {
-                       if (cave_stop_disintegration(ty, tx)) return (FALSE);
+                       if (cave_stop_disintegration(floor_ptr, ty, tx)) return FALSE;
 
                        qy += m;
 
@@ -5253,7 +5257,7 @@ bool in_disintegration_range(POSITION y1, POSITION x1, POSITION y2, POSITION x2)
                        else if (qy > f2)
                        {
                                ty += sy;
-                               if (cave_stop_disintegration(ty, tx)) return (FALSE);
+                               if (cave_stop_disintegration(floor_ptr, ty, tx)) return FALSE;
                                qy -= f1;
                                tx += sx;
                        }
@@ -5264,64 +5268,61 @@ bool in_disintegration_range(POSITION y1, POSITION x1, POSITION y2, POSITION x2)
                                tx += sx;
                        }
                }
+
+               return TRUE;
        }
 
-       /* Travel vertically */
+       /* Let m = dx / dy * 2 * (dx * dy) = 2 * dx * dx */
+       qx = ax * ax;
+       m = qx << 1;
+
+       ty = y1 + sy;
+
+       if (qx == f2)
+       {
+               tx = x1 + sx;
+               qx -= f1;
+       }
        else
        {
-               /* Let m = dx / dy * 2 * (dx * dy) = 2 * dx * dx */
-               qx = ax * ax;
-               m = qx << 1;
+               tx = x1;
+       }
+
+       /* Note (below) the case (qx == f2), where */
+       /* the LOS exactly meets the corner of a tile. */
+       while (y2 - ty)
+       {
+               if (cave_stop_disintegration(floor_ptr, ty, tx)) return FALSE;
 
-               ty = y1 + sy;
+               qx += m;
 
-               if (qx == f2)
+               if (qx < f2)
                {
-                       tx = x1 + sx;
-                       qx -= f1;
+                       ty += sy;
                }
-               else
+               else if (qx > f2)
                {
-                       tx = x1;
+                       tx += sx;
+                       if (cave_stop_disintegration(floor_ptr, ty, tx)) return FALSE;
+                       qx -= f1;
+                       ty += sy;
                }
-
-               /* Note (below) the case (qx == f2), where */
-               /* the LOS exactly meets the corner of a tile. */
-               while (y2 - ty)
+               else
                {
-                       if (cave_stop_disintegration(ty, tx)) return (FALSE);
-
-                       qx += m;
-
-                       if (qx < f2)
-                       {
-                               ty += sy;
-                       }
-                       else if (qx > f2)
-                       {
-                               tx += sx;
-                               if (cave_stop_disintegration(ty, tx)) return (FALSE);
-                               qx -= f1;
-                               ty += sy;
-                       }
-                       else
-                       {
-                               tx += sx;
-                               qx -= f1;
-                               ty += sy;
-                       }
+                       tx += sx;
+                       qx -= f1;
+                       ty += sy;
                }
        }
 
-       /* Assume los */
-       return (TRUE);
+       return TRUE;
 }
 
 
 /*
  * breath shape
  */
-void breath_shape(u16b *path_g, int dist, int *pgrids, POSITION *gx, POSITION *gy, POSITION *gm, POSITION *pgm_rad, POSITION rad, POSITION y1, POSITION x1, POSITION y2, POSITION x2, EFFECT_ID typ)
+void breath_shape(player_type *caster_ptr, u16b *path_g, int dist, int *pgrids, POSITION *gx, POSITION *gy, POSITION *gm, POSITION *pgm_rad, POSITION rad, POSITION y1, POSITION x1, POSITION y2, POSITION x2, EFFECT_ID typ)
 {
        POSITION by = y1;
        POSITION bx = x1;
@@ -5332,6 +5333,7 @@ void breath_shape(u16b *path_g, int dist, int *pgrids, POSITION *gx, POSITION *g
        int path_n = 0;
        int mdis = distance(y1, x1, y2, x2) + rad;
 
+       floor_type *floor_ptr = caster_ptr->current_floor_ptr;
        while (bdis <= mdis)
        {
                POSITION x, y;
@@ -5360,7 +5362,7 @@ void breath_shape(u16b *path_g, int dist, int *pgrids, POSITION *gx, POSITION *g
                                for (x = bx - cdis; x <= bx + cdis; x++)
                                {
                                        /* Ignore "illegal" locations */
-                                       if (!in_bounds(p_ptr->current_floor_ptr, y, x)) continue;
+                                       if (!in_bounds(floor_ptr, y, x)) continue;
 
                                        /* Enforce a circular "ripple" */
                                        if (distance(y1, x1, y, x) != bdis) continue;
@@ -5373,15 +5375,15 @@ void breath_shape(u16b *path_g, int dist, int *pgrids, POSITION *gx, POSITION *g
                                        case GF_LITE:
                                        case GF_LITE_WEAK:
                                                /* Lights are stopped by opaque terrains */
-                                               if (!los(p_ptr->current_floor_ptr, by, bx, y, x)) continue;
+                                               if (!los(caster_ptr, by, bx, y, x)) continue;
                                                break;
                                        case GF_DISINTEGRATE:
                                                /* Disintegration are stopped only by perma-walls */
-                                               if (!in_disintegration_range(by, bx, y, x)) continue;
+                                               if (!in_disintegration_range(floor_ptr, by, bx, y, x)) continue;
                                                break;
                                        default:
                                                /* Ball explosions are stopped by walls */
-                                               if (!projectable(p_ptr->current_floor_ptr, by, bx, y, x)) continue;
+                                               if (!projectable(caster_ptr, by, bx, y, x)) continue;
                                                break;
                                        }
 
@@ -5550,7 +5552,7 @@ void breath_shape(u16b *path_g, int dist, int *pgrids, POSITION *gx, POSITION *g
  * and "update_view()" and "update_monsters()" need to be called.
  * </pre>
  */
-bool project(MONSTER_IDX who, POSITION rad, POSITION y, POSITION x, HIT_POINT dam, EFFECT_ID typ, BIT_FLAGS flg, int monspell)
+bool project(player_type *caster_ptr, MONSTER_IDX who, POSITION rad, POSITION y, POSITION x, HIT_POINT dam, EFFECT_ID typ, BIT_FLAGS flg, int monspell)
 {
        int i, t, dist;
 
@@ -5577,7 +5579,7 @@ bool project(MONSTER_IDX who, POSITION rad, POSITION y, POSITION x, HIT_POINT da
        bool breath = FALSE;
 
        /* Is the player blind? */
-       bool blind = (p_ptr->blind ? TRUE : FALSE);
+       bool blind = (caster_ptr->blind ? TRUE : FALSE);
 
        bool old_hide = FALSE;
 
@@ -5614,8 +5616,8 @@ bool project(MONSTER_IDX who, POSITION rad, POSITION y, POSITION x, HIT_POINT da
        rakubadam_m = 0;
 
        /* Default target of monsterspell is player */
-       monster_target_y = p_ptr->y;
-       monster_target_x = p_ptr->x;
+       monster_target_y = caster_ptr->y;
+       monster_target_x = caster_ptr->x;
 
        /* Hack -- Jump to target */
        if (flg & (PROJECT_JUMP))
@@ -5632,16 +5634,16 @@ bool project(MONSTER_IDX who, POSITION rad, POSITION y, POSITION x, HIT_POINT da
        /* Start at player */
        else if (who <= 0)
        {
-               x1 = p_ptr->x;
-               y1 = p_ptr->y;
+               x1 = caster_ptr->x;
+               y1 = caster_ptr->y;
        }
 
        /* Start at monster */
        else if (who > 0)
        {
-               x1 = p_ptr->current_floor_ptr->m_list[who].fx;
-               y1 = p_ptr->current_floor_ptr->m_list[who].fy;
-               monster_desc(who_name, &p_ptr->current_floor_ptr->m_list[who], MD_WRONGDOER_NAME);
+               x1 = caster_ptr->current_floor_ptr->m_list[who].fx;
+               y1 = caster_ptr->current_floor_ptr->m_list[who].fy;
+               monster_desc(who_name, &caster_ptr->current_floor_ptr->m_list[who], MD_WRONGDOER_NAME);
        }
 
        else
@@ -5676,7 +5678,6 @@ bool project(MONSTER_IDX who, POSITION rad, POSITION y, POSITION x, HIT_POINT da
                flg |= PROJECT_HIDE;
        }
 
-
        /* Hack -- Assume there will be no blast (max radius 32) */
        for (dist = 0; dist < 32; dist++) gm[dist] = 0;
 
@@ -5708,15 +5709,15 @@ bool project(MONSTER_IDX who, POSITION rad, POSITION y, POSITION x, HIT_POINT da
 
        /* Calculate the projection path */
 
-       path_n = project_path(path_g, (project_length ? project_length : MAX_RANGE), y1, x1, y2, x2, flg);
-       handle_stuff();
+       path_n = project_path(caster_ptr, path_g, (project_length ? project_length : MAX_RANGE), y1, x1, y2, x2, flg);
+       handle_stuff(caster_ptr);
 
        /* Giga-Hack SEEKER & SUPER_RAY */
 
-       if( typ == GF_SEEKER )
+       if (typ == GF_SEEKER)
        {
                int j;
-               int last_i=0;
+               int last_i = 0;
 
                /* Mega-Hack */
                project_m_n = 0;
@@ -5739,32 +5740,29 @@ bool project(MONSTER_IDX who, POSITION rad, POSITION y, POSITION x, HIT_POINT da
                        gx[grids] = x;
                        grids++;
 
-
                        /* Only do visuals if requested */
                        if (!blind && !(flg & (PROJECT_HIDE)))
                        {
                                /* Only do visuals if the player can "see" the bolt */
-                               if (panel_contains(y, x) && player_has_los_bold(p_ptr, y, x))
+                               if (panel_contains(y, x) && player_has_los_bold(caster_ptr, y, x))
                                {
-                                       u16b p;
-
                                        TERM_COLOR a;
                                        SYMBOL_CODE c;
 
                                        /* Obtain the bolt pict */
-                                       p = bolt_pict(oy, ox, y, x, typ);
+                                       u16b p = bolt_pict(oy, ox, y, x, typ);
 
                                        /* Extract attr/char */
                                        a = PICT_A(p);
                                        c = PICT_C(p);
 
                                        /* Visual effects */
-                                       print_rel(c, a, y, x);
+                                       print_rel(caster_ptr, c, a, y, x);
                                        move_cursor_relative(y, x);
-                                       /*if (fresh_before)*/ Term_fresh();
+                                       Term_fresh();
                                        Term_xtra(TERM_XTRA_DELAY, msec);
                                        lite_spot(y, x);
-                                       /*if (fresh_before)*/ Term_fresh();
+                                       Term_fresh();
 
                                        /* Display "beam" grids */
                                        if (flg & (PROJECT_BEAM))
@@ -5777,7 +5775,7 @@ bool project(MONSTER_IDX who, POSITION rad, POSITION y, POSITION x, HIT_POINT da
                                                c = PICT_C(p);
 
                                                /* Visual effects */
-                                               print_rel(c, a, y, x);
+                                               print_rel(caster_ptr, c, a, y, x);
                                        }
 
                                        /* Hack -- Activate delay */
@@ -5791,62 +5789,70 @@ bool project(MONSTER_IDX who, POSITION rad, POSITION y, POSITION x, HIT_POINT da
                                        Term_xtra(TERM_XTRA_DELAY, msec);
                                }
                        }
-                       if (project_o(0, 0, y, x, dam, GF_SEEKER))notice = TRUE;
-                       if (is_mirror_grid(&p_ptr->current_floor_ptr->grid_array[y][x]))
+
+                       if (project_o(caster_ptr, 0, 0, y, x, dam, GF_SEEKER))notice = TRUE;
+                       if (is_mirror_grid(&caster_ptr->current_floor_ptr->grid_array[y][x]))
                        {
                                /* The target of monsterspell becomes tha mirror(broken) */
                                monster_target_y = y;
                                monster_target_x = x;
 
-                               remove_mirror(y, x);
-                               next_mirror(p_ptr, &oy, &ox, y, x);
+                               remove_mirror(caster_ptr, y, x);
+                               next_mirror(caster_ptr, &oy, &ox, y, x);
 
-                               path_n = i + project_path(&(path_g[i + 1]), (project_length ? project_length : MAX_RANGE), y, x, oy, ox, flg);
+                               path_n = i + project_path(caster_ptr, &(path_g[i + 1]), (project_length ? project_length : MAX_RANGE), y, x, oy, ox, flg);
                                for (j = last_i; j <= i; j++)
                                {
                                        y = GRID_Y(path_g[j]);
                                        x = GRID_X(path_g[j]);
-                                       if (project_m(p_ptr->current_floor_ptr, 0, 0, y, x, dam, GF_SEEKER, flg, TRUE)) notice = TRUE;
+                                       if (project_m(caster_ptr, 0, 0, y, x, dam, GF_SEEKER, flg, TRUE)) notice = TRUE;
                                        if (!who && (project_m_n == 1) && !jump) {
-                                               if (p_ptr->current_floor_ptr->grid_array[project_m_y][project_m_x].m_idx > 0) {
-                                                       monster_type *m_ptr = &p_ptr->current_floor_ptr->m_list[p_ptr->current_floor_ptr->grid_array[project_m_y][project_m_x].m_idx];
+                                               if (caster_ptr->current_floor_ptr->grid_array[project_m_y][project_m_x].m_idx > 0)
+                                               {
+                                                       monster_type *m_ptr = &caster_ptr->current_floor_ptr->m_list[caster_ptr->current_floor_ptr->grid_array[project_m_y][project_m_x].m_idx];
 
                                                        if (m_ptr->ml)
                                                        {
-                                                               if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
-                                                               health_track(p_ptr->current_floor_ptr->grid_array[project_m_y][project_m_x].m_idx);
+                                                               if (!caster_ptr->image) monster_race_track(caster_ptr, m_ptr->ap_r_idx);
+                                                               health_track(caster_ptr, caster_ptr->current_floor_ptr->grid_array[project_m_y][project_m_x].m_idx);
                                                        }
                                                }
                                        }
-                                       (void)project_f(p_ptr->current_floor_ptr, 0, 0, y, x, dam, GF_SEEKER);
+
+                                       (void)project_f(caster_ptr, 0, 0, y, x, dam, GF_SEEKER);
                                }
+
                                last_i = i;
                        }
                }
-               for(i = last_i ; i < path_n ; i++)
+
+               for (i = last_i; i < path_n; i++)
                {
                        POSITION py, px;
                        py = GRID_Y(path_g[i]);
                        px = GRID_X(path_g[i]);
-                       if (project_m(p_ptr->current_floor_ptr, 0, 0, py, px, dam, GF_SEEKER, flg, TRUE))
+                       if (project_m(caster_ptr, 0, 0, py, px, dam, GF_SEEKER, flg, TRUE))
                                notice = TRUE;
                        if (!who && (project_m_n == 1) && !jump) {
-                               if (p_ptr->current_floor_ptr->grid_array[project_m_y][project_m_x].m_idx > 0)
+                               if (caster_ptr->current_floor_ptr->grid_array[project_m_y][project_m_x].m_idx > 0)
                                {
-                                       monster_type *m_ptr = &p_ptr->current_floor_ptr->m_list[p_ptr->current_floor_ptr->grid_array[project_m_y][project_m_x].m_idx];
+                                       monster_type *m_ptr = &caster_ptr->current_floor_ptr->m_list[caster_ptr->current_floor_ptr->grid_array[project_m_y][project_m_x].m_idx];
 
                                        if (m_ptr->ml)
                                        {
-                                               if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
-                                               health_track(p_ptr->current_floor_ptr->grid_array[project_m_y][project_m_x].m_idx);
+                                               if (!caster_ptr->image) monster_race_track(caster_ptr, m_ptr->ap_r_idx);
+                                               health_track(caster_ptr, caster_ptr->current_floor_ptr->grid_array[project_m_y][project_m_x].m_idx);
                                        }
                                }
                        }
-                       (void)project_f(p_ptr->current_floor_ptr, 0, 0, py, px, dam, GF_SEEKER);
+
+                       (void)project_f(caster_ptr, 0, 0, py, px, dam, GF_SEEKER);
                }
+
                return notice;
        }
-       else if(typ == GF_SUPER_RAY){
+       else if (typ == GF_SUPER_RAY)
+       {
                int j;
                int second_step = 0;
 
@@ -5870,13 +5876,12 @@ bool project(MONSTER_IDX who, POSITION rad, POSITION y, POSITION x, HIT_POINT da
                        gy[grids] = y;
                        gx[grids] = x;
                        grids++;
-
-
+                       
                        /* Only do visuals if requested */
                        if (!blind && !(flg & (PROJECT_HIDE)))
                        {
                                /* Only do visuals if the player can "see" the bolt */
-                               if (panel_contains(y, x) && player_has_los_bold(p_ptr, y, x))
+                               if (panel_contains(y, x) && player_has_los_bold(caster_ptr, y, x))
                                {
                                        u16b p;
 
@@ -5891,7 +5896,7 @@ bool project(MONSTER_IDX who, POSITION rad, POSITION y, POSITION x, HIT_POINT da
                                        c = PICT_C(p);
 
                                        /* Visual effects */
-                                       print_rel(c, a, y, x);
+                                       print_rel(caster_ptr, c, a, y, x);
                                        move_cursor_relative(y, x);
                                        /*if (fresh_before)*/ Term_fresh();
                                        Term_xtra(TERM_XTRA_DELAY, msec);
@@ -5909,7 +5914,7 @@ bool project(MONSTER_IDX who, POSITION rad, POSITION y, POSITION x, HIT_POINT da
                                                c = PICT_C(p);
 
                                                /* Visual effects */
-                                               print_rel(c, a, y, x);
+                                               print_rel(caster_ptr, c, a, y, x);
                                        }
 
                                        /* Hack -- Activate delay */
@@ -5923,56 +5928,61 @@ bool project(MONSTER_IDX who, POSITION rad, POSITION y, POSITION x, HIT_POINT da
                                        Term_xtra(TERM_XTRA_DELAY, msec);
                                }
                        }
-                       if(project_o(0,0,y,x,dam,GF_SUPER_RAY) )notice=TRUE;
-                       if (!cave_have_flag_bold(y, x, FF_PROJECT))
+
+                       if (project_o(caster_ptr, 0, 0, y, x, dam, GF_SUPER_RAY))notice = TRUE;
+                       if (!cave_have_flag_bold(caster_ptr->current_floor_ptr, y, x, FF_PROJECT))
                        {
-                               if( second_step )continue;
+                               if (second_step)continue;
                                break;
                        }
-                       if( is_mirror_grid(&p_ptr->current_floor_ptr->grid_array[y][x]) && !second_step )
+
+                       if (is_mirror_grid(&caster_ptr->current_floor_ptr->grid_array[y][x]) && !second_step)
                        {
-                         /* The target of monsterspell becomes tha mirror(broken) */
+                               /* The target of monsterspell becomes tha mirror(broken) */
                                monster_target_y = y;
                                monster_target_x = x;
 
-                               remove_mirror(y,x);
-                               for( j = 0; j <=i ; j++ )
+                               remove_mirror(caster_ptr, y, x);
+                               for (j = 0; j <= i; j++)
                                {
                                        y = GRID_Y(path_g[j]);
                                        x = GRID_X(path_g[j]);
-                                       (void)project_f(p_ptr->current_floor_ptr, 0,0,y,x,dam,GF_SUPER_RAY);
+                                       (void)project_f(caster_ptr, 0, 0, y, x, dam, GF_SUPER_RAY);
                                }
+
                                path_n = i;
-                               second_step =i+1;
-                               path_n += project_path(&(path_g[path_n+1]), (project_length ? project_length : MAX_RANGE), y, x, y-1, x-1, flg);
-                               path_n += project_path(&(path_g[path_n+1]), (project_length ? project_length : MAX_RANGE), y, x, y-1, x  , flg);
-                               path_n += project_path(&(path_g[path_n+1]), (project_length ? project_length : MAX_RANGE), y, x, y-1, x+1, flg);
-                               path_n += project_path(&(path_g[path_n+1]), (project_length ? project_length : MAX_RANGE), y, x, y  , x-1, flg);
-                               path_n += project_path(&(path_g[path_n+1]), (project_length ? project_length : MAX_RANGE), y, x, y  , x+1, flg);
-                               path_n += project_path(&(path_g[path_n+1]), (project_length ? project_length : MAX_RANGE), y, x, y+1, x-1, flg);
-                               path_n += project_path(&(path_g[path_n+1]), (project_length ? project_length : MAX_RANGE), y, x, y+1, x  , flg);
-                               path_n += project_path(&(path_g[path_n+1]), (project_length ? project_length : MAX_RANGE), y, x, y+1, x+1, flg);
+                               second_step = i + 1;
+                               path_n += project_path(caster_ptr, &(path_g[path_n + 1]), (project_length ? project_length : MAX_RANGE), y, x, y - 1, x - 1, flg);
+                               path_n += project_path(caster_ptr, &(path_g[path_n + 1]), (project_length ? project_length : MAX_RANGE), y, x, y - 1, x, flg);
+                               path_n += project_path(caster_ptr, &(path_g[path_n + 1]), (project_length ? project_length : MAX_RANGE), y, x, y - 1, x + 1, flg);
+                               path_n += project_path(caster_ptr, &(path_g[path_n + 1]), (project_length ? project_length : MAX_RANGE), y, x, y, x - 1, flg);
+                               path_n += project_path(caster_ptr, &(path_g[path_n + 1]), (project_length ? project_length : MAX_RANGE), y, x, y, x + 1, flg);
+                               path_n += project_path(caster_ptr, &(path_g[path_n + 1]), (project_length ? project_length : MAX_RANGE), y, x, y + 1, x - 1, flg);
+                               path_n += project_path(caster_ptr, &(path_g[path_n + 1]), (project_length ? project_length : MAX_RANGE), y, x, y + 1, x, flg);
+                               path_n += project_path(caster_ptr, &(path_g[path_n + 1]), (project_length ? project_length : MAX_RANGE), y, x, y + 1, x + 1, flg);
                        }
                }
-               for( i = 0; i < path_n ; i++ )
+
+               for (i = 0; i < path_n; i++)
                {
-                       POSITION py, px;
-                       py = GRID_Y(path_g[i]);
-                       px = GRID_X(path_g[i]);
-                       (void)project_m(p_ptr->current_floor_ptr, 0, 0, py, px, dam, GF_SUPER_RAY, flg, TRUE);
-                       if(!who && (project_m_n == 1) && !jump){
-                               if(p_ptr->current_floor_ptr->grid_array[project_m_y][project_m_x].m_idx >0 ){
-                                       monster_type *m_ptr = &p_ptr->current_floor_ptr->m_list[p_ptr->current_floor_ptr->grid_array[project_m_y][project_m_x].m_idx];
+                       POSITION py = GRID_Y(path_g[i]);
+                       POSITION px = GRID_X(path_g[i]);
+                       (void)project_m(caster_ptr, 0, 0, py, px, dam, GF_SUPER_RAY, flg, TRUE);
+                       if (!who && (project_m_n == 1) && !jump) {
+                               if (caster_ptr->current_floor_ptr->grid_array[project_m_y][project_m_x].m_idx > 0) {
+                                       monster_type *m_ptr = &caster_ptr->current_floor_ptr->m_list[caster_ptr->current_floor_ptr->grid_array[project_m_y][project_m_x].m_idx];
 
                                        if (m_ptr->ml)
                                        {
-                                               if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
-                                               health_track(p_ptr->current_floor_ptr->grid_array[project_m_y][project_m_x].m_idx);
+                                               if (!caster_ptr->image) monster_race_track(caster_ptr, m_ptr->ap_r_idx);
+                                               health_track(caster_ptr, caster_ptr->current_floor_ptr->grid_array[project_m_y][project_m_x].m_idx);
                                        }
                                }
                        }
-                       (void)project_f(p_ptr->current_floor_ptr, 0, 0, py, px, dam, GF_SUPER_RAY);
+
+                       (void)project_f(caster_ptr, 0, 0, py, px, dam, GF_SUPER_RAY);
                }
+
                return notice;
        }
 
@@ -5988,17 +5998,17 @@ bool project(MONSTER_IDX who, POSITION rad, POSITION y, POSITION x, HIT_POINT da
                if (flg & PROJECT_DISI)
                {
                        /* Hack -- Balls explode before reaching walls */
-                       if (cave_stop_disintegration(ny, nx) && (rad > 0)) break;
+                       if (cave_stop_disintegration(caster_ptr->current_floor_ptr, ny, nx) && (rad > 0)) break;
                }
                else if (flg & PROJECT_LOS)
                {
                        /* Hack -- Balls explode before reaching walls */
-                       if (!cave_los_bold(p_ptr->current_floor_ptr, ny, nx) && (rad > 0)) break;
+                       if (!cave_los_bold(caster_ptr->current_floor_ptr, ny, nx) && (rad > 0)) break;
                }
                else
                {
                        /* Hack -- Balls explode before reaching walls */
-                       if (!cave_have_flag_bold(ny, nx, FF_PROJECT) && (rad > 0)) break;
+                       if (!cave_have_flag_bold(caster_ptr->current_floor_ptr, ny, nx, FF_PROJECT) && (rad > 0)) break;
                }
 
                /* Advance */
@@ -6017,7 +6027,7 @@ bool project(MONSTER_IDX who, POSITION rad, POSITION y, POSITION x, HIT_POINT da
                if (!blind && !(flg & (PROJECT_HIDE | PROJECT_FAST)))
                {
                        /* Only do visuals if the player can "see" the bolt */
-                       if (panel_contains(y, x) && player_has_los_bold(p_ptr, y, x))
+                       if (panel_contains(y, x) && player_has_los_bold(caster_ptr, y, x))
                        {
                                u16b p;
 
@@ -6032,7 +6042,7 @@ bool project(MONSTER_IDX who, POSITION rad, POSITION y, POSITION x, HIT_POINT da
                                c = PICT_C(p);
 
                                /* Visual effects */
-                               print_rel(c, a, y, x);
+                               print_rel(caster_ptr, c, a, y, x);
                                move_cursor_relative(y, x);
                                /*if (fresh_before)*/ Term_fresh();
                                Term_xtra(TERM_XTRA_DELAY, msec);
@@ -6050,7 +6060,7 @@ bool project(MONSTER_IDX who, POSITION rad, POSITION y, POSITION x, HIT_POINT da
                                        c = PICT_C(p);
 
                                        /* Visual effects */
-                                       print_rel(c, a, y, x);
+                                       print_rel(caster_ptr, c, a, y, x);
                                }
 
                                /* Hack -- Activate delay */
@@ -6113,7 +6123,7 @@ bool project(MONSTER_IDX who, POSITION rad, POSITION y, POSITION x, HIT_POINT da
                {
                        flg &= ~(PROJECT_HIDE);
 
-                       breath_shape(path_g, dist, &grids, gx, gy, gm, &gm_rad, rad, y1, x1, by, bx, typ);
+                       breath_shape(caster_ptr, path_g, dist, &grids, gx, gy, gm, &gm_rad, rad, y1, x1, by, bx, typ);
                }
                else
                {
@@ -6126,7 +6136,7 @@ bool project(MONSTER_IDX who, POSITION rad, POSITION y, POSITION x, HIT_POINT da
                                        for (x = bx - dist; x <= bx + dist; x++)
                                        {
                                                /* Ignore "illegal" locations */
-                                               if (!in_bounds2(p_ptr->current_floor_ptr, y, x)) continue;
+                                               if (!in_bounds2(caster_ptr->current_floor_ptr, y, x)) continue;
 
                                                /* Enforce a "circular" explosion */
                                                if (distance(by, bx, y, x) != dist) continue;
@@ -6136,15 +6146,15 @@ bool project(MONSTER_IDX who, POSITION rad, POSITION y, POSITION x, HIT_POINT da
                                                case GF_LITE:
                                                case GF_LITE_WEAK:
                                                        /* Lights are stopped by opaque terrains */
-                                                       if (!los(p_ptr->current_floor_ptr, by, bx, y, x)) continue;
+                                                       if (!los(caster_ptr, by, bx, y, x)) continue;
                                                        break;
                                                case GF_DISINTEGRATE:
                                                        /* Disintegration are stopped only by perma-walls */
-                                                       if (!in_disintegration_range(by, bx, y, x)) continue;
+                                                       if (!in_disintegration_range(caster_ptr->current_floor_ptr, by, bx, y, x)) continue;
                                                        break;
                                                default:
                                                        /* Ball explosions are stopped by walls */
-                                                       if (!projectable(p_ptr->current_floor_ptr, by, bx, y, x)) continue;
+                                                       if (!projectable(caster_ptr, by, bx, y, x)) continue;
                                                        break;
                                                }
 
@@ -6156,13 +6166,13 @@ bool project(MONSTER_IDX who, POSITION rad, POSITION y, POSITION x, HIT_POINT da
                                }
 
                                /* Encode some more "radius" info */
-                               gm[dist+1] = grids;
+                               gm[dist + 1] = grids;
                        }
                }
        }
 
        /* Speed -- ignore "non-explosions" */
-       if (!grids) return (FALSE);
+       if (!grids) return FALSE;
 
 
        /* Display the "blast area" if requested */
@@ -6172,13 +6182,13 @@ bool project(MONSTER_IDX who, POSITION rad, POSITION y, POSITION x, HIT_POINT da
                for (t = 0; t <= gm_rad; t++)
                {
                        /* Dump everything with this radius */
-                       for (i = gm[t]; i < gm[t+1]; i++)
+                       for (i = gm[t]; i < gm[t + 1]; i++)
                        {
                                y = gy[i];
                                x = gx[i];
 
                                /* Only do visuals if the player can "see" the blast */
-                               if (panel_contains(y, x) && player_has_los_bold(p_ptr, y, x))
+                               if (panel_contains(y, x) && player_has_los_bold(caster_ptr, y, x))
                                {
                                        u16b p;
 
@@ -6195,7 +6205,7 @@ bool project(MONSTER_IDX who, POSITION rad, POSITION y, POSITION x, HIT_POINT da
                                        c = PICT_C(p);
 
                                        /* Visual effects -- Display */
-                                       print_rel(c, a, y, x);
+                                       print_rel(caster_ptr, c, a, y, x);
                                }
                        }
 
@@ -6222,7 +6232,7 @@ bool project(MONSTER_IDX who, POSITION rad, POSITION y, POSITION x, HIT_POINT da
                                x = gx[i];
 
                                /* Hack -- Erase if needed */
-                               if (panel_contains(y, x) && player_has_los_bold(p_ptr, y, x))
+                               if (panel_contains(y, x) && player_has_los_bold(caster_ptr, y, x))
                                {
                                        lite_spot(y, x);
                                }
@@ -6236,15 +6246,14 @@ bool project(MONSTER_IDX who, POSITION rad, POSITION y, POSITION x, HIT_POINT da
                }
        }
 
-       update_creature(p_ptr);
+       update_creature(caster_ptr);
 
        if (flg & PROJECT_KILL)
        {
-               see_s_msg = (who > 0) ? is_seen(&p_ptr->current_floor_ptr->m_list[who]) :
-                       (!who ? TRUE : (player_can_see_bold(y1, x1) && projectable(p_ptr->current_floor_ptr, p_ptr->y, p_ptr->x, y1, x1)));
+               see_s_msg = (who > 0) ? is_seen(&caster_ptr->current_floor_ptr->m_list[who]) :
+                       (!who ? TRUE : (player_can_see_bold(caster_ptr, y1, x1) && projectable(caster_ptr, caster_ptr->y, caster_ptr->x, y1, x1)));
        }
 
-
        /* Check features */
        if (flg & (PROJECT_GRID))
        {
@@ -6255,7 +6264,7 @@ bool project(MONSTER_IDX who, POSITION rad, POSITION y, POSITION x, HIT_POINT da
                for (i = 0; i < grids; i++)
                {
                        /* Hack -- Notice new "dist" values */
-                       if (gm[dist+1] == i) dist++;
+                       if (gm[dist + 1] == i) dist++;
 
                        /* Get the grid location */
                        y = gy[i];
@@ -6267,17 +6276,18 @@ bool project(MONSTER_IDX who, POSITION rad, POSITION y, POSITION x, HIT_POINT da
                                int d = dist_to_line(y, x, y1, x1, by, bx);
 
                                /* Affect the grid */
-                               if (project_f(p_ptr->current_floor_ptr, who, d, y, x, dam, typ)) notice = TRUE;
+                               if (project_f(caster_ptr, who, d, y, x, dam, typ)) notice = TRUE;
                        }
+
                        else
                        {
                                /* Affect the grid */
-                               if (project_f(p_ptr->current_floor_ptr, who, dist, y, x, dam, typ)) notice = TRUE;
+                               if (project_f(caster_ptr, who, dist, y, x, dam, typ)) notice = TRUE;
                        }
                }
        }
 
-       update_creature(p_ptr);
+       update_creature(caster_ptr);
 
        /* Check objects */
        if (flg & (PROJECT_ITEM))
@@ -6289,7 +6299,7 @@ bool project(MONSTER_IDX who, POSITION rad, POSITION y, POSITION x, HIT_POINT da
                for (i = 0; i < grids; i++)
                {
                        /* Hack -- Notice new "dist" values */
-                       if (gm[dist+1] == i) dist++;
+                       if (gm[dist + 1] == i) dist++;
 
                        /* Get the grid location */
                        y = gy[i];
@@ -6301,17 +6311,16 @@ bool project(MONSTER_IDX who, POSITION rad, POSITION y, POSITION x, HIT_POINT da
                                int d = dist_to_line(y, x, y1, x1, by, bx);
 
                                /* Affect the object in the grid */
-                               if (project_o(who, d, y, x, dam, typ)) notice = TRUE;
+                               if (project_o(caster_ptr, who, d, y, x, dam, typ)) notice = TRUE;
                        }
                        else
                        {
                                /* Affect the object in the grid */
-                               if (project_o(who, dist, y, x, dam, typ)) notice = TRUE;
+                               if (project_o(caster_ptr, who, dist, y, x, dam, typ)) notice = TRUE;
                        }
                }
        }
 
-
        /* Check monsters */
        if (flg & (PROJECT_KILL))
        {
@@ -6338,11 +6347,11 @@ bool project(MONSTER_IDX who, POSITION rad, POSITION y, POSITION x, HIT_POINT da
                        /* A single bolt may be reflected */
                        if (grids <= 1)
                        {
-                               monster_type *m_ptr = &p_ptr->current_floor_ptr->m_list[p_ptr->current_floor_ptr->grid_array[y][x].m_idx];
+                               monster_type *m_ptr = &caster_ptr->current_floor_ptr->m_list[caster_ptr->current_floor_ptr->grid_array[y][x].m_idx];
                                monster_race *ref_ptr = &r_info[m_ptr->r_idx];
 
-                               if ((flg & PROJECT_REFLECTABLE) && p_ptr->current_floor_ptr->grid_array[y][x].m_idx && (ref_ptr->flags2 & RF2_REFLECTING) &&
-                                       ((p_ptr->current_floor_ptr->grid_array[y][x].m_idx != p_ptr->riding) || !(flg & PROJECT_PLAYER)) &&
+                               if ((flg & PROJECT_REFLECTABLE) && caster_ptr->current_floor_ptr->grid_array[y][x].m_idx && (ref_ptr->flags2 & RF2_REFLECTING) &&
+                                       ((caster_ptr->current_floor_ptr->grid_array[y][x].m_idx != caster_ptr->riding) || !(flg & PROJECT_PLAYER)) &&
                                        (!who || dist_hack > 1) && !one_in_(10))
                                {
                                        POSITION t_y, t_x;
@@ -6354,8 +6363,7 @@ bool project(MONSTER_IDX who, POSITION rad, POSITION y, POSITION x, HIT_POINT da
                                                t_y = y_saver - 1 + randint1(3);
                                                t_x = x_saver - 1 + randint1(3);
                                                max_attempts--;
-                                       }
-                                       while (max_attempts && in_bounds2u(p_ptr->current_floor_ptr, t_y, t_x) && !projectable(p_ptr->current_floor_ptr, y, x, t_y, t_x));
+                                       } while (max_attempts && in_bounds2u(caster_ptr->current_floor_ptr, t_y, t_x) && !projectable(caster_ptr, y, x, t_y, t_x));
 
                                        if (max_attempts < 1)
                                        {
@@ -6368,26 +6376,25 @@ bool project(MONSTER_IDX who, POSITION rad, POSITION y, POSITION x, HIT_POINT da
                                        {
                                                if ((m_ptr->r_idx == MON_KENSHIROU) || (m_ptr->r_idx == MON_RAOU))
                                                        msg_print(_("「北斗神拳奥義・二指真空把!」", "The attack bounces!"));
-                                               else if (m_ptr->r_idx == MON_DIO) 
+                                               else if (m_ptr->r_idx == MON_DIO)
                                                        msg_print(_("ディオ・ブランドーは指一本で攻撃を弾き返した!", "The attack bounces!"));
-                                               else 
+                                               else
                                                        msg_print(_("攻撃は跳ね返った!", "The attack bounces!"));
                                        }
                                        if (is_original_ap_and_seen(m_ptr)) ref_ptr->r_flags2 |= RF2_REFLECTING;
 
                                        /* Reflected bolts randomly target either one */
-                                       if (player_bold(p_ptr, y, x) || one_in_(2)) flg &= ~(PROJECT_PLAYER);
+                                       if (player_bold(caster_ptr, y, x) || one_in_(2)) flg &= ~(PROJECT_PLAYER);
                                        else flg |= PROJECT_PLAYER;
 
                                        /* The bolt is reflected */
-                                       project(p_ptr->current_floor_ptr->grid_array[y][x].m_idx, 0, t_y, t_x, dam, typ, flg, monspell);
+                                       project(caster_ptr, caster_ptr->current_floor_ptr->grid_array[y][x].m_idx, 0, t_y, t_x, dam, typ, flg, monspell);
 
                                        /* Don't affect the monster any longer */
                                        continue;
                                }
                        }
 
-
                        /* Find the closest point in the blast */
                        if (breath)
                        {
@@ -6398,9 +6405,8 @@ bool project(MONSTER_IDX who, POSITION rad, POSITION y, POSITION x, HIT_POINT da
                                effective_dist = dist;
                        }
 
-
                        /* There is the riding player on this monster */
-                       if (p_ptr->riding && player_bold(p_ptr, y, x))
+                       if (caster_ptr->riding && player_bold(caster_ptr, y, x))
                        {
                                /* Aimed on the player */
                                if (flg & PROJECT_PLAYER)
@@ -6417,7 +6423,7 @@ bool project(MONSTER_IDX who, POSITION rad, POSITION y, POSITION x, HIT_POINT da
                                        else
                                        {
                                                /*
-                                                * The spell is not well aimed, 
+                                                * The spell is not well aimed,
                                                 * So partly affect the mount too.
                                                 */
                                                effective_dist++;
@@ -6439,10 +6445,10 @@ bool project(MONSTER_IDX who, POSITION rad, POSITION y, POSITION x, HIT_POINT da
                                 * of fire is obstructed by this
                                 * monster.
                                 */
-                               /*
-                                * A beam or bolt will hit either
-                                * player or mount.  Choose randomly.
-                                */
+                                /*
+                                 * A beam or bolt will hit either
+                                 * player or mount.  Choose randomly.
+                                 */
                                else if (flg & (PROJECT_BEAM | PROJECT_REFLECTABLE))
                                {
                                        if (one_in_(2))
@@ -6471,7 +6477,7 @@ bool project(MONSTER_IDX who, POSITION rad, POSITION y, POSITION x, HIT_POINT da
                        }
 
                        /* Affect the monster in the grid */
-                       if (project_m(p_ptr->current_floor_ptr, who, effective_dist, y, x, dam, typ, flg, see_s_msg)) notice = TRUE;
+                       if (project_m(caster_ptr, who, effective_dist, y, x, dam, typ, flg, see_s_msg)) notice = TRUE;
                }
 
 
@@ -6482,20 +6488,19 @@ bool project(MONSTER_IDX who, POSITION rad, POSITION y, POSITION x, HIT_POINT da
                        y = project_m_y;
 
                        /* Track if possible */
-                       if (p_ptr->current_floor_ptr->grid_array[y][x].m_idx > 0)
+                       if (caster_ptr->current_floor_ptr->grid_array[y][x].m_idx > 0)
                        {
-                               monster_type *m_ptr = &p_ptr->current_floor_ptr->m_list[p_ptr->current_floor_ptr->grid_array[y][x].m_idx];
+                               monster_type *m_ptr = &caster_ptr->current_floor_ptr->m_list[caster_ptr->current_floor_ptr->grid_array[y][x].m_idx];
 
                                if (m_ptr->ml)
                                {
-                                       if (!p_ptr->image) monster_race_track(m_ptr->ap_r_idx);
-                                       health_track(p_ptr->current_floor_ptr->grid_array[y][x].m_idx);
+                                       if (!caster_ptr->image) monster_race_track(caster_ptr, m_ptr->ap_r_idx);
+                                       health_track(caster_ptr, caster_ptr->current_floor_ptr->grid_array[y][x].m_idx);
                                }
                        }
                }
        }
 
-
        /* Check player */
        if (flg & (PROJECT_KILL))
        {
@@ -6508,14 +6513,14 @@ bool project(MONSTER_IDX who, POSITION rad, POSITION y, POSITION x, HIT_POINT da
                        int effective_dist;
 
                        /* Hack -- Notice new "dist" values */
-                       if (gm[dist+1] == i) dist++;
+                       if (gm[dist + 1] == i) dist++;
 
                        /* Get the grid location */
                        y = gy[i];
                        x = gx[i];
 
                        /* Affect the player? */
-                       if (!player_bold(p_ptr, y, x)) continue;
+                       if (!player_bold(caster_ptr, y, x)) continue;
 
                        /* Find the closest point in the blast */
                        if (breath)
@@ -6528,7 +6533,7 @@ bool project(MONSTER_IDX who, POSITION rad, POSITION y, POSITION x, HIT_POINT da
                        }
 
                        /* Target may be your horse */
-                       if (p_ptr->riding)
+                       if (caster_ptr->riding)
                        {
                                /* Aimed on the player */
                                if (flg & PROJECT_PLAYER)
@@ -6559,7 +6564,7 @@ bool project(MONSTER_IDX who, POSITION rad, POSITION y, POSITION x, HIT_POINT da
                                else
                                {
                                        /*
-                                        * The spell is not well aimed, 
+                                        * The spell is not well aimed,
                                         * So partly affect the player too.
                                         */
                                        effective_dist++;
@@ -6567,26 +6572,26 @@ bool project(MONSTER_IDX who, POSITION rad, POSITION y, POSITION x, HIT_POINT da
                        }
 
                        /* Affect the player */
-                       if (project_p(who, p_ptr, who_name, effective_dist, y, x, dam, typ, flg, monspell)) notice = TRUE;
+                       if (project_p(who, caster_ptr, who_name, effective_dist, y, x, dam, typ, flg, monspell)) notice = TRUE;
                }
        }
 
-       if (p_ptr->riding)
+       if (caster_ptr->riding)
        {
                GAME_TEXT m_name[MAX_NLEN];
 
-               monster_desc(m_name, &p_ptr->current_floor_ptr->m_list[p_ptr->riding], 0);
+               monster_desc(m_name, &caster_ptr->current_floor_ptr->m_list[caster_ptr->riding], 0);
 
                if (rakubadam_m > 0)
                {
-                       if (rakuba(p_ptr, rakubadam_m, FALSE))
+                       if (rakuba(caster_ptr, rakubadam_m, FALSE))
                        {
                                msg_format(_("%^sに振り落とされた!", "%^s has thrown you off!"), m_name);
                        }
                }
-               if (p_ptr->riding && rakubadam_p > 0)
+               if (caster_ptr->riding && rakubadam_p > 0)
                {
-                       if(rakuba(p_ptr, rakubadam_p, FALSE))
+                       if (rakuba(caster_ptr, rakubadam_p, FALSE))
                        {
                                msg_format(_("%^sから落ちてしまった!", "You have fallen from %s."), m_name);
                        }
@@ -6628,8 +6633,8 @@ bool binding_field(player_type *caster_ptr, HIT_POINT dam)
                                distance(caster_ptr->y, caster_ptr->x, y, x) <= MAX_RANGE &&
                                distance(caster_ptr->y, caster_ptr->x, y, x) != 0 &&
                                player_has_los_bold(caster_ptr, y, x) &&
-                               projectable(caster_ptr->current_floor_ptr, caster_ptr->y, caster_ptr->x, y, x)
-                               ) {
+                               projectable(caster_ptr, caster_ptr->y, caster_ptr->x, y, x))
+                       {
                                mirror_y[mirror_num] = y;
                                mirror_x[mirror_num] = x;
                                mirror_num++;
@@ -6668,8 +6673,10 @@ bool binding_field(player_type *caster_ptr, HIT_POINT dam)
        y2 = point_y[0] > point_y[1] ? point_y[0] : point_y[1];
        y2 = y2 > point_y[2] ? y2 : point_y[2];
 
-       for (y = y1; y <= y2; y++) {
-               for (x = x1; x <= x2; x++) {
+       for (y = y1; y <= y2; y++)
+       {
+               for (x = x1; x <= x2; x++)
+               {
                        if (centersign*((point_x[0] - x)*(point_y[1] - y)
                                - (point_y[0] - y)*(point_x[1] - x)) >= 0 &&
                                centersign*((point_x[1] - x)*(point_y[2] - y)
@@ -6677,12 +6684,14 @@ bool binding_field(player_type *caster_ptr, HIT_POINT dam)
                                centersign*((point_x[2] - x)*(point_y[0] - y)
                                        - (point_y[2] - y)*(point_x[0] - x)) >= 0)
                        {
-                               if (player_has_los_bold(caster_ptr, y, x) && projectable(caster_ptr->current_floor_ptr, caster_ptr->y, caster_ptr->x, y, x)) {
+                               if (player_has_los_bold(caster_ptr, y, x) && projectable(caster_ptr, caster_ptr->y, caster_ptr->x, y, x))
+                               {
                                        /* Visual effects */
                                        if (!(caster_ptr->blind)
-                                               && panel_contains(y, x)) {
+                                               && panel_contains(y, x))
+                                       {
                                                p = bolt_pict(y, x, y, x, GF_MANA);
-                                               print_rel(PICT_C(p), PICT_A(p), y, x);
+                                               print_rel(caster_ptr, PICT_C(p), PICT_A(p), y, x);
                                                move_cursor_relative(y, x);
                                                /*if (fresh_before)*/ Term_fresh();
                                                Term_xtra(TERM_XTRA_DELAY, msec);
@@ -6691,8 +6700,11 @@ bool binding_field(player_type *caster_ptr, HIT_POINT dam)
                        }
                }
        }
-       for (y = y1; y <= y2; y++) {
-               for (x = x1; x <= x2; x++) {
+
+       for (y = y1; y <= y2; y++)
+       {
+               for (x = x1; x <= x2; x++)
+               {
                        if (centersign*((point_x[0] - x)*(point_y[1] - y)
                                - (point_y[0] - y)*(point_x[1] - x)) >= 0 &&
                                centersign*((point_x[1] - x)*(point_y[2] - y)
@@ -6700,14 +6712,18 @@ bool binding_field(player_type *caster_ptr, HIT_POINT dam)
                                centersign*((point_x[2] - x)*(point_y[0] - y)
                                        - (point_y[2] - y)*(point_x[0] - x)) >= 0)
                        {
-                               if (player_has_los_bold(caster_ptr, y, x) && projectable(caster_ptr->current_floor_ptr, caster_ptr->y, caster_ptr->x, y, x)) {
-                                       (void)project_f(caster_ptr->current_floor_ptr, 0, 0, y, x, dam, GF_MANA);
+                               if (player_has_los_bold(caster_ptr, y, x) && projectable(caster_ptr, caster_ptr->y, caster_ptr->x, y, x))
+                               {
+                                       (void)project_f(caster_ptr, 0, 0, y, x, dam, GF_MANA);
                                }
                        }
                }
        }
-       for (y = y1; y <= y2; y++) {
-               for (x = x1; x <= x2; x++) {
+
+       for (y = y1; y <= y2; y++)
+       {
+               for (x = x1; x <= x2; x++)
+               {
                        if (centersign*((point_x[0] - x)*(point_y[1] - y)
                                - (point_y[0] - y)*(point_x[1] - x)) >= 0 &&
                                centersign*((point_x[1] - x)*(point_y[2] - y)
@@ -6715,14 +6731,18 @@ bool binding_field(player_type *caster_ptr, HIT_POINT dam)
                                centersign*((point_x[2] - x)*(point_y[0] - y)
                                        - (point_y[2] - y)*(point_x[0] - x)) >= 0)
                        {
-                               if (player_has_los_bold(caster_ptr, y, x) && projectable(caster_ptr->current_floor_ptr, caster_ptr->y, caster_ptr->x, y, x)) {
-                                       (void)project_o(0, 0, y, x, dam, GF_MANA);
+                               if (player_has_los_bold(caster_ptr, y, x) && projectable(caster_ptr, caster_ptr->y, caster_ptr->x, y, x))
+                               {
+                                       (void)project_o(caster_ptr, 0, 0, y, x, dam, GF_MANA);
                                }
                        }
                }
        }
-       for (y = y1; y <= y2; y++) {
-               for (x = x1; x <= x2; x++) {
+
+       for (y = y1; y <= y2; y++)
+       {
+               for (x = x1; x <= x2; x++)
+               {
                        if (centersign*((point_x[0] - x)*(point_y[1] - y)
                                - (point_y[0] - y)*(point_x[1] - x)) >= 0 &&
                                centersign*((point_x[1] - x)*(point_y[2] - y)
@@ -6730,16 +6750,19 @@ bool binding_field(player_type *caster_ptr, HIT_POINT dam)
                                centersign*((point_x[2] - x)*(point_y[0] - y)
                                        - (point_y[2] - y)*(point_x[0] - x)) >= 0)
                        {
-                               if (player_has_los_bold(caster_ptr, y, x) && projectable(caster_ptr->current_floor_ptr, caster_ptr->y, caster_ptr->x, y, x)) {
-                                       (void)project_m(p_ptr->current_floor_ptr, 0, 0, y, x, dam, GF_MANA,
+                               if (player_has_los_bold(caster_ptr, y, x) && projectable(caster_ptr, caster_ptr->y, caster_ptr->x, y, x))
+                               {
+                                       (void)project_m(caster_ptr, 0, 0, y, x, dam, GF_MANA,
                                                (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP), TRUE);
                                }
                        }
                }
        }
-       if (one_in_(7)) {
+
+       if (one_in_(7))
+       {
                msg_print(_("鏡が結界に耐えきれず、壊れてしまった。", "The field broke a mirror"));
-               remove_mirror(point_y[0], point_x[0]);
+               remove_mirror(caster_ptr, point_y[0], point_x[0]);
        }
 
        return TRUE;
@@ -6752,30 +6775,26 @@ bool binding_field(player_type *caster_ptr, HIT_POINT dam)
  */
 void seal_of_mirror(player_type *caster_ptr, HIT_POINT dam)
 {
-       POSITION x, y;
-
-       for (x = 0; x < caster_ptr->current_floor_ptr->width; x++)
+       for (POSITION x = 0; x < caster_ptr->current_floor_ptr->width; x++)
        {
-               for (y = 0; y < caster_ptr->current_floor_ptr->height; y++)
+               for (POSITION y = 0; y < caster_ptr->current_floor_ptr->height; y++)
                {
-                       if (is_mirror_grid(&caster_ptr->current_floor_ptr->grid_array[y][x]))
+                       if (!is_mirror_grid(&caster_ptr->current_floor_ptr->grid_array[y][x]))
+                               continue;
+                       
+                       if (!project_m(caster_ptr, 0, 0, y, x, dam, GF_GENOCIDE,
+                               (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP), TRUE))
+                               continue;
+                       
+                       if (!caster_ptr->current_floor_ptr->grid_array[y][x].m_idx)
                        {
-                               if (project_m(caster_ptr->current_floor_ptr, 0, 0, y, x, dam, GF_GENOCIDE,
-                                       (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP), TRUE))
-                               {
-                                       if (!caster_ptr->current_floor_ptr->grid_array[y][x].m_idx)
-                                       {
-                                               remove_mirror(y, x);
-                                       }
-                               }
+                               remove_mirror(caster_ptr, y, x);
                        }
                }
        }
-       return;
 }
 
 
-
 /*!
  * @brief 領域魔法に応じて技能の名称を返す。
  * @param tval 魔法書のtval
@@ -6795,4 +6814,3 @@ concptr spell_category_name(OBJECT_TYPE_VALUE tval)
                return _("呪文", "spell");
        }
 }
-