OSDN Git Service

[Refactor] #38997 teleport_player() に player_type * 引数を追加. / Add player_type * argume...
[hengband/hengband.git] / src / spells3.c
index 92df8b4..cab7594 100644 (file)
@@ -74,7 +74,7 @@
  * Attempt to move the monster at least "dis/2" grids away.
  * But allow variation to prevent infinite loops.
  */
-bool teleport_away(MONSTER_IDX m_idx, POSITION dis, BIT_FLAGS mode)
+bool teleport_away(player_type *caster_ptr, MONSTER_IDX m_idx, POSITION dis, BIT_FLAGS mode)
 {
        POSITION oy, ox, d, i, min;
        int tries = 0;
@@ -82,7 +82,7 @@ bool teleport_away(MONSTER_IDX m_idx, POSITION dis, BIT_FLAGS mode)
 
        bool look = TRUE;
 
-       monster_type *m_ptr = &p_ptr->current_floor_ptr->m_list[m_idx];
+       monster_type *m_ptr = &caster_ptr->current_floor_ptr->m_list[m_idx];
        if (!monster_is_valid(m_ptr)) return (FALSE);
 
        oy = m_ptr->fy;
@@ -92,10 +92,10 @@ bool teleport_away(MONSTER_IDX m_idx, POSITION dis, BIT_FLAGS mode)
        min = dis / 2;
 
        if ((mode & TELEPORT_DEC_VALOUR) &&
-           (((p_ptr->chp * 10) / p_ptr->mhp) > 5) &&
-               (4+randint1(5) < ((p_ptr->chp * 10) / p_ptr->mhp)))
+           (((caster_ptr->chp * 10) / caster_ptr->mhp) > 5) &&
+               (4+randint1(5) < ((caster_ptr->chp * 10) / caster_ptr->mhp)))
        {
-               chg_virtue(p_ptr, V_VALOUR, -1);
+               chg_virtue(caster_ptr, V_VALOUR, -1);
        }
 
        /* Look until done */
@@ -119,13 +119,13 @@ bool teleport_away(MONSTER_IDX m_idx, POSITION dis, BIT_FLAGS mode)
                        }
 
                        /* Ignore illegal locations */
-                       if (!in_bounds(p_ptr->current_floor_ptr, ny, nx)) continue;
+                       if (!in_bounds(caster_ptr->current_floor_ptr, ny, nx)) continue;
 
                        if (!cave_monster_teleportable_bold(m_idx, ny, nx, mode)) continue;
 
                        /* No teleporting into vaults and such */
-                       if (!(p_ptr->inside_quest || p_ptr->inside_arena))
-                               if (p_ptr->current_floor_ptr->grid_array[ny][nx].info & CAVE_ICKY) continue;
+                       if (!(caster_ptr->current_floor_ptr->inside_quest || caster_ptr->current_floor_ptr->inside_arena))
+                               if (caster_ptr->current_floor_ptr->grid_array[ny][nx].info & CAVE_ICKY) continue;
 
                        /* This grid looks good */
                        look = FALSE;
@@ -147,10 +147,10 @@ bool teleport_away(MONSTER_IDX m_idx, POSITION dis, BIT_FLAGS mode)
        sound(SOUND_TPOTHER);
 
        /* Update the old location */
-       p_ptr->current_floor_ptr->grid_array[oy][ox].m_idx = 0;
+       caster_ptr->current_floor_ptr->grid_array[oy][ox].m_idx = 0;
 
        /* Update the new location */
-       p_ptr->current_floor_ptr->grid_array[ny][nx].m_idx = m_idx;
+       caster_ptr->current_floor_ptr->grid_array[ny][nx].m_idx = m_idx;
 
        /* Move the monster */
        m_ptr->fy = ny;
@@ -159,12 +159,12 @@ bool teleport_away(MONSTER_IDX m_idx, POSITION dis, BIT_FLAGS mode)
        /* Forget the counter target */
        reset_target(m_ptr);
 
-       update_monster(m_idx, TRUE);
+       update_monster(caster_ptr, m_idx, TRUE);
        lite_spot(oy, ox);
        lite_spot(ny, nx);
 
        if (r_info[m_ptr->r_idx].flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
-               p_ptr->update |= (PU_MON_LITE);
+               caster_ptr->update |= (PU_MON_LITE);
 
        return (TRUE);
 }
@@ -255,7 +255,7 @@ void teleport_monster_to(MONSTER_IDX m_idx, POSITION ty, POSITION tx, int power,
        m_ptr->fy = ny;
        m_ptr->fx = nx;
 
-       update_monster(m_idx, TRUE);
+       update_monster(p_ptr, m_idx, TRUE);
        lite_spot(oy, ox);
        lite_spot(ny, nx);
 
@@ -400,25 +400,25 @@ bool teleport_player_aux(player_type *creature_ptr, POSITION dis, BIT_FLAGS mode
  * @param mode オプション
  * @return なし
  */
-void teleport_player(POSITION dis, BIT_FLAGS mode)
+void teleport_player(player_type *creature_ptr, POSITION dis, BIT_FLAGS mode)
 {
        POSITION yy, xx;
-       POSITION oy = p_ptr->y;
-       POSITION ox = p_ptr->x;
+       POSITION oy = creature_ptr->y;
+       POSITION ox = creature_ptr->x;
 
-       if (!teleport_player_aux(p_ptr, dis, mode)) return;
+       if (!teleport_player_aux(creature_ptr, dis, mode)) return;
 
        /* Monsters with teleport ability may follow the player */
        for (xx = -1; xx < 2; xx++)
        {
                for (yy = -1; yy < 2; yy++)
                {
-                       MONSTER_IDX tmp_m_idx = p_ptr->current_floor_ptr->grid_array[oy+yy][ox+xx].m_idx;
+                       MONSTER_IDX tmp_m_idx = creature_ptr->current_floor_ptr->grid_array[oy+yy][ox+xx].m_idx;
 
                        /* A monster except your mount may follow */
-                       if (tmp_m_idx && (p_ptr->riding != tmp_m_idx))
+                       if (tmp_m_idx && (creature_ptr->riding != tmp_m_idx))
                        {
-                               monster_type *m_ptr = &p_ptr->current_floor_ptr->m_list[tmp_m_idx];
+                               monster_type *m_ptr = &creature_ptr->current_floor_ptr->m_list[tmp_m_idx];
                                monster_race *r_ptr = &r_info[m_ptr->r_idx];
 
                                /*
@@ -428,7 +428,7 @@ void teleport_player(POSITION dis, BIT_FLAGS mode)
                                if ((r_ptr->a_ability_flags2 & RF6_TPORT) &&
                                    !(r_ptr->flagsr & RFR_RES_TELE))
                                {
-                                       if (!MON_CSLEEP(m_ptr)) teleport_monster_to(tmp_m_idx, p_ptr->y, p_ptr->x, r_ptr->level, 0L);
+                                       if (!MON_CSLEEP(m_ptr)) teleport_monster_to(tmp_m_idx, creature_ptr->y, creature_ptr->x, r_ptr->level, 0L);
                                }
                        }
                }
@@ -540,9 +540,9 @@ void teleport_away_followable(MONSTER_IDX m_idx)
        bool old_ml = m_ptr->ml;
        POSITION old_cdis = m_ptr->cdis;
 
-       teleport_away(m_idx, MAX_SIGHT * 2 + 5, 0L);
+       teleport_away(p_ptr, m_idx, MAX_SIGHT * 2 + 5, 0L);
 
-       if (old_ml && (old_cdis <= MAX_SIGHT) && !current_world_ptr->timewalk_m_idx && !p_ptr->phase_out && los(p_ptr->y, p_ptr->x, oldfy, oldfx))
+       if (old_ml && (old_cdis <= MAX_SIGHT) && !current_world_ptr->timewalk_m_idx && !p_ptr->phase_out && los(p_ptr->current_floor_ptr, p_ptr->y, p_ptr->x, oldfy, oldfx))
        {
                bool follow = FALSE;
 
@@ -574,7 +574,7 @@ void teleport_away_followable(MONSTER_IDX m_idx)
                        {
                                if (one_in_(3))
                                {
-                                       teleport_player(200, TELEPORT_PASSIVE);
+                                       teleport_player(p_ptr, 200, TELEPORT_PASSIVE);
                                        msg_print(_("失敗!", "Failed!"));
                                }
                                else teleport_player_to(p_ptr, m_ptr->fy, m_ptr->fx, 0L);
@@ -595,8 +595,8 @@ bool teleport_level_other(player_type *creature_ptr)
        if (!target_set(TARGET_KILL)) return FALSE;
        target_m_idx = p_ptr->current_floor_ptr->grid_array[target_row][target_col].m_idx;
        if (!target_m_idx) return TRUE;
-       if (!player_has_los_bold(target_row, target_col)) return TRUE;
-       if (!projectable(creature_ptr->y, creature_ptr->x, target_row, target_col)) return TRUE;
+       if (!player_has_los_bold(p_ptr, target_row, target_col)) return TRUE;
+       if (!projectable(creature_ptr->current_floor_ptr, creature_ptr->y, creature_ptr->x, target_row, target_col)) return TRUE;
        m_ptr = &p_ptr->current_floor_ptr->m_list[target_m_idx];
        r_ptr = &r_info[m_ptr->r_idx];
        monster_desc(m_name, m_ptr, 0);
@@ -713,7 +713,7 @@ void teleport_level(player_type *creature_ptr, MONSTER_IDX m_idx)
                        prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
 
                        leave_quest_check();
-                       creature_ptr->inside_quest = 0;
+                       creature_ptr->current_floor_ptr->inside_quest = 0;
                        creature_ptr->leaving = TRUE;
                }
        }
@@ -791,13 +791,13 @@ bool recall_player(player_type *creature_ptr, TIME_EFFECT turns)
         */
 
        /* Ironman option */
-       if (creature_ptr->inside_arena || ironman_downward)
+       if (creature_ptr->current_floor_ptr->inside_arena || ironman_downward)
        {
                msg_print(_("何も起こらなかった。", "Nothing happens."));
                return TRUE;
        }
 
-       if (p_ptr->current_floor_ptr->dun_level && (max_dlv[p_ptr->dungeon_idx] > p_ptr->current_floor_ptr->dun_level) && !creature_ptr->inside_quest && !creature_ptr->word_recall)
+       if (p_ptr->current_floor_ptr->dun_level && (max_dlv[p_ptr->dungeon_idx] > p_ptr->current_floor_ptr->dun_level) && !creature_ptr->current_floor_ptr->inside_quest && !creature_ptr->word_recall)
        {
                if (get_check(_("ここは最深到達階より浅い階です。この階に戻って来ますか? ", "Reset recall depth? ")))
                {
@@ -1028,9 +1028,11 @@ bool apply_disenchant(player_type *target_ptr, BIT_FLAGS mode)
 /*!
  * @brief 虚無招来によるフロア中の全壁除去処理 /
  * Vanish all walls in this floor
+ * @params floor_ptr 対象となるフロアの対象ポインタ
+ * @params subject_ptr 現象を主観するクリーチャーの参照ポインタ
  * @return 実際に処理が反映された場合TRUE
  */
-static bool vanish_dungeon(floor_type *floor_ptr)
+static bool vanish_dungeon(floor_type *floor_ptr, player_type *subject_ptr)
 {
        POSITION y, x;
        grid_type *g_ptr;
@@ -1039,7 +1041,7 @@ static bool vanish_dungeon(floor_type *floor_ptr)
        GAME_TEXT m_name[MAX_NLEN];
 
        /* Prevent vasishing of quest levels and town */
-       if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !floor_ptr->dun_level)
+       if ((subject_ptr->current_floor_ptr->inside_quest && is_fixed_quest_idx(subject_ptr->current_floor_ptr->inside_quest)) || !floor_ptr->dun_level)
        {
                return FALSE;
        }
@@ -1146,9 +1148,9 @@ static bool vanish_dungeon(floor_type *floor_ptr)
        }
 
        /* Mega-Hack -- Forget the view and lite */
-       p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE | PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE | PU_MONSTERS);
-       p_ptr->redraw |= (PR_MAP);
-       p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
+       subject_ptr->update |= (PU_UN_VIEW | PU_UN_LITE | PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE | PU_MONSTERS);
+       subject_ptr->redraw |= (PR_MAP);
+       subject_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
 
        return TRUE;
 }
@@ -1156,8 +1158,10 @@ static bool vanish_dungeon(floor_type *floor_ptr)
 /*!
  * @brief 虚無招来処理 /
  * @return なし
+ * @details
+ * Sorry, it becomes not (void)...
  */
-void call_the_(void)
+void call_the_void(player_type *caster_ptr)
 {
        int i;
        grid_type *g_ptr;
@@ -1165,7 +1169,7 @@ void call_the_(void)
 
        for (i = 0; i < 9; i++)
        {
-               g_ptr = &p_ptr->current_floor_ptr->grid_array[p_ptr->y + ddy_ddd[i]][p_ptr->x + ddx_ddd[i]];
+               g_ptr = &caster_ptr->current_floor_ptr->grid_array[caster_ptr->y + ddy_ddd[i]][caster_ptr->x + ddx_ddd[i]];
 
                if (!cave_have_flag_grid(g_ptr, FF_PROJECT))
                {
@@ -1197,7 +1201,7 @@ void call_the_(void)
        }
 
        /* Prevent destruction of quest levels and town */
-       else if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !p_ptr->current_floor_ptr->dun_level)
+       else if ((caster_ptr->current_floor_ptr->inside_quest && is_fixed_quest_idx(caster_ptr->current_floor_ptr->inside_quest)) || !caster_ptr->current_floor_ptr->dun_level)
        {
                msg_print(_("地面が揺れた。", "The ground trembles."));
        }
@@ -1216,17 +1220,17 @@ void call_the_(void)
 
                if (one_in_(666))
                {
-                       if (!vanish_dungeon(p_ptr->current_floor_ptr)) msg_print(_("ダンジョンは一瞬静まり返った。", "The dungeon silences a moment."));
+                       if (!vanish_dungeon(caster_ptr->current_floor_ptr, caster_ptr)) msg_print(_("ダンジョンは一瞬静まり返った。", "The dungeon silences a moment."));
                }
                else
                {
-                       if (destroy_area(p_ptr->current_floor_ptr, p_ptr->y, p_ptr->x, 15 + p_ptr->lev + randint0(11), FALSE))
+                       if (destroy_area(caster_ptr->current_floor_ptr, caster_ptr->y, caster_ptr->x, 15 + caster_ptr->lev + randint0(11), FALSE))
                                msg_print(_("ダンジョンが崩壊した...", "The dungeon collapses..."));
                        else
                                msg_print(_("ダンジョンは大きく揺れた。", "The dungeon trembles."));
                }
 
-               take_hit(p_ptr, DAMAGE_NOESCAPE, 100 + randint1(150), _("自殺的な虚無招来", "a suicidal Call the Void"), -1);
+               take_hit(caster_ptr, DAMAGE_NOESCAPE, 100 + randint1(150), _("自殺的な虚無招来", "a suicidal Call the Void"), -1);
        }
 }
 
@@ -1285,12 +1289,12 @@ void fetch(player_type *caster_ptr, DIRECTION dir, WEIGHT wgt, bool require_los)
                /* We need to see the item */
                if (require_los)
                {
-                       if (!player_has_los_bold(ty, tx))
+                       if (!player_has_los_bold(p_ptr, ty, tx))
                        {
                                msg_print(_("そこはあなたの視界に入っていません。", "You have no direct line of sight to that location."));
                                return;
                        }
-                       else if (!projectable(caster_ptr->y, caster_ptr->x, ty, tx))
+                       else if (!projectable(caster_ptr->current_floor_ptr, caster_ptr->y, caster_ptr->x, ty, tx))
                        {
                                msg_print(_("そこは壁の向こうです。", "You have no direct line of sight to that location."));
                                return;
@@ -1344,7 +1348,7 @@ void fetch(player_type *caster_ptr, DIRECTION dir, WEIGHT wgt, bool require_los)
 void alter_reality(void)
 {
        /* Ironman option */
-       if (p_ptr->inside_arena || ironman_downward)
+       if (p_ptr->current_floor_ptr->inside_arena || ironman_downward)
        {
                msg_print(_("何も起こらなかった。", "Nothing happens."));
                return;
@@ -2424,12 +2428,12 @@ void display_spell_list(player_type *caster_ptr)
  * @param use_realm 魔法領域
  * @return 経験値
  */
-EXP experience_of_spell(SPELL_IDX spell, REALM_IDX use_realm)
+EXP experience_of_spell(player_type *caster_ptr, SPELL_IDX spell, REALM_IDX use_realm)
 {
-       if (p_ptr->pclass == CLASS_SORCERER) return SPELL_EXP_MASTER;
-       else if (p_ptr->pclass == CLASS_RED_MAGE) return SPELL_EXP_SKILLED;
-       else if (use_realm == p_ptr->realm1) return p_ptr->spell_exp[spell];
-       else if (use_realm == p_ptr->realm2) return p_ptr->spell_exp[spell + 32];
+       if (caster_ptr->pclass == CLASS_SORCERER) return SPELL_EXP_MASTER;
+       else if (caster_ptr->pclass == CLASS_RED_MAGE) return SPELL_EXP_SKILLED;
+       else if (use_realm == caster_ptr->realm1) return caster_ptr->spell_exp[spell];
+       else if (use_realm == caster_ptr->realm2) return caster_ptr->spell_exp[spell + 32];
        else return 0;
 }
 
@@ -2455,7 +2459,7 @@ MANA_POINT mod_need_mana(MANA_POINT need_mana, SPELL_IDX spell, REALM_IDX realm)
                 * need_mana defaults if spell exp equals SPELL_EXP_EXPERT and !p_ptr->dec_mana.
                 * MANA_CONST is used to calculate need_mana effected from spell proficiency.
                 */
-               need_mana = need_mana * (MANA_CONST + SPELL_EXP_EXPERT - experience_of_spell(spell, realm)) + (MANA_CONST - 1);
+               need_mana = need_mana * (MANA_CONST + SPELL_EXP_EXPERT - experience_of_spell(p_ptr, spell, realm)) + (MANA_CONST - 1);
                need_mana *= p_ptr->dec_mana ? DEC_MANA_DIV : MANA_DIV;
                need_mana /= MANA_CONST * MANA_DIV;
                if (need_mana < 1) need_mana = 1;
@@ -2483,15 +2487,15 @@ MANA_POINT mod_need_mana(MANA_POINT need_mana, SPELL_IDX spell, REALM_IDX realm)
  * @return 失敗率(%)
  * @todo 統合を検討
  */
-PERCENTAGE mod_spell_chance_1(PERCENTAGE chance)
+PERCENTAGE mod_spell_chance_1(player_type *caster_ptr, PERCENTAGE chance)
 {
-       chance += p_ptr->to_m_chance;
+       chance += caster_ptr->to_m_chance;
 
-       if (p_ptr->heavy_spell) chance += 20;
+       if (caster_ptr->heavy_spell) chance += 20;
 
-       if (p_ptr->dec_mana && p_ptr->easy_spell) chance -= 4;
-       else if (p_ptr->easy_spell) chance -= 3;
-       else if (p_ptr->dec_mana) chance -= 2;
+       if (caster_ptr->dec_mana && caster_ptr->easy_spell) chance -= 4;
+       else if (caster_ptr->easy_spell) chance -= 3;
+       else if (caster_ptr->dec_mana) chance -= 2;
 
        return chance;
 }
@@ -2508,12 +2512,10 @@ PERCENTAGE mod_spell_chance_1(PERCENTAGE chance)
  * Note: variable "chance" cannot be negative.
  * @todo 統合を検討
  */
-PERCENTAGE mod_spell_chance_2(PERCENTAGE chance)
+PERCENTAGE mod_spell_chance_2(player_type *caster_ptr, PERCENTAGE chance)
 {
-       if (p_ptr->dec_mana) chance--;
-
-       if (p_ptr->heavy_spell) chance += 5;
-
+       if (caster_ptr->dec_mana) chance--;
+       if (caster_ptr->heavy_spell) chance += 5;
        return MAX(chance, 0);
 }
 
@@ -2587,7 +2589,7 @@ PERCENTAGE spell_chance(player_type *caster_ptr, SPELL_IDX spell, REALM_IDX use_
        if (((caster_ptr->pclass == CLASS_PRIEST) || (caster_ptr->pclass == CLASS_SORCERER)) && caster_ptr->icky_wield[0]) chance += 25;
        if (((caster_ptr->pclass == CLASS_PRIEST) || (caster_ptr->pclass == CLASS_SORCERER)) && caster_ptr->icky_wield[1]) chance += 25;
 
-       chance = mod_spell_chance_1(chance);
+       chance = mod_spell_chance_1(caster_ptr, chance);
 
        /* Goodness or evilness gives a penalty to failure rate */
        switch (use_realm)
@@ -2616,13 +2618,13 @@ PERCENTAGE spell_chance(player_type *caster_ptr, SPELL_IDX spell, REALM_IDX use_
        if ((use_realm == caster_ptr->realm1) || (use_realm == caster_ptr->realm2)
            || (caster_ptr->pclass == CLASS_SORCERER) || (caster_ptr->pclass == CLASS_RED_MAGE))
        {
-               EXP exp = experience_of_spell(spell, use_realm);
+               EXP exp = experience_of_spell(caster_ptr, spell, use_realm);
                if (exp >= SPELL_EXP_EXPERT) chance--;
                if (exp >= SPELL_EXP_MASTER) chance--;
        }
 
        /* Return the chance */
-       return mod_spell_chance_2(chance);
+       return mod_spell_chance_2(caster_ptr, chance);
 }
 
 
@@ -2689,7 +2691,7 @@ void print_spells(player_type* caster_ptr, SPELL_IDX target_spell, SPELL_IDX *sp
                        need_mana = s_ptr->smana;
                else
                {
-                       EXP exp = experience_of_spell(spell, use_realm);
+                       EXP exp = experience_of_spell(caster_ptr, spell, use_realm);
 
                        /* Extract mana consumption rate */
                        need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
@@ -2864,7 +2866,7 @@ bool polymorph_monster(player_type *caster_ptr, POSITION y, POSITION x)
        bool health_tracked = (caster_ptr->health_who == g_ptr->m_idx) ? TRUE : FALSE;
        monster_type back_m;
 
-       if (caster_ptr->inside_arena || caster_ptr->phase_out) return (FALSE);
+       if (caster_ptr->current_floor_ptr->inside_arena || caster_ptr->phase_out) return (FALSE);
 
        if ((caster_ptr->riding == g_ptr->m_idx) || (m_ptr->mflag2 & MFLAG2_KAGE)) return (FALSE);
 
@@ -2961,7 +2963,7 @@ static bool dimension_door_aux(DEPTH x, DEPTH y)
            (!randint0(plev / 10 + 10)))
        {
                p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
-               teleport_player((plev + 2) * 2, TELEPORT_PASSIVE);
+               teleport_player(p_ptr, (plev + 2) * 2, TELEPORT_PASSIVE);
 
                /* Failed */
                return FALSE;
@@ -3283,7 +3285,7 @@ bool eat_magic(player_type *caster_ptr, int power)
  * @param px プレイヤーX座標
  * @return なし
  */
-void massacre(void)
+void massacre(player_type *caster_ptr)
 {
        POSITION x, y;
        grid_type *g_ptr;
@@ -3292,18 +3294,18 @@ void massacre(void)
 
        for (dir = 0; dir < 8; dir++)
        {
-               y = p_ptr->y + ddy_ddd[dir];
-               x = p_ptr->x + ddx_ddd[dir];
-               g_ptr = &p_ptr->current_floor_ptr->grid_array[y][x];
-               m_ptr = &p_ptr->current_floor_ptr->m_list[g_ptr->m_idx];
+               y = caster_ptr->y + ddy_ddd[dir];
+               x = caster_ptr->x + ddx_ddd[dir];
+               g_ptr = &caster_ptr->current_floor_ptr->grid_array[y][x];
+               m_ptr = &caster_ptr->current_floor_ptr->m_list[g_ptr->m_idx];
 
                /* Hack -- attack monsters */
                if (g_ptr->m_idx && (m_ptr->ml || cave_have_flag_bold(y, x, FF_PROJECT)))
-                       py_attack(p_ptr, y, x, 0);
+                       py_attack(caster_ptr, y, x, 0);
        }
 }
 
-bool eat_lock(void)
+bool eat_lock(player_type *caster_ptr)
 {
        POSITION x, y;
        grid_type *g_ptr;
@@ -3311,9 +3313,9 @@ bool eat_lock(void)
        DIRECTION dir;
 
        if (!get_direction(&dir, FALSE, FALSE)) return FALSE;
-       y = p_ptr->y + ddy[dir];
-       x = p_ptr->x + ddx[dir];
-       g_ptr = &p_ptr->current_floor_ptr->grid_array[y][x];
+       y = caster_ptr->y + ddy[dir];
+       x = caster_ptr->x + ddx[dir];
+       g_ptr = &caster_ptr->current_floor_ptr->grid_array[y][x];
        f_ptr = &f_info[g_ptr->feat];
        mimic_f_ptr = &f_info[get_feat_mimic(g_ptr)];
 
@@ -3329,10 +3331,10 @@ bool eat_lock(void)
        }
        else if (g_ptr->m_idx)
        {
-               monster_type *m_ptr = &p_ptr->current_floor_ptr->m_list[g_ptr->m_idx];
+               monster_type *m_ptr = &caster_ptr->current_floor_ptr->m_list[g_ptr->m_idx];
                msg_print(_("何かが邪魔しています!", "There's something in the way!"));
 
-               if (!m_ptr->ml || !is_pet(m_ptr)) py_attack(p_ptr, y, x, 0);
+               if (!m_ptr->ml || !is_pet(m_ptr)) py_attack(caster_ptr, y, x, 0);
        }
        else if (have_flag(f_ptr->flags, FF_TREE))
        {
@@ -3344,49 +3346,49 @@ bool eat_lock(void)
        }
        else if (have_flag(f_ptr->flags, FF_DOOR) || have_flag(f_ptr->flags, FF_CAN_DIG))
        {
-               (void)set_food(p_ptr, p_ptr->food + 3000);
+               (void)set_food(caster_ptr, caster_ptr->food + 3000);
        }
        else if (have_flag(f_ptr->flags, FF_MAY_HAVE_GOLD) || have_flag(f_ptr->flags, FF_HAS_GOLD))
        {
-               (void)set_food(p_ptr, p_ptr->food + 5000);
+               (void)set_food(caster_ptr, caster_ptr->food + 5000);
        }
        else
        {
                msg_format(_("この%sはとてもおいしい!", "This %s is very filling!"), f_name + mimic_f_ptr->name);
-               (void)set_food(p_ptr, p_ptr->food + 10000);
+               (void)set_food(caster_ptr, caster_ptr->food + 10000);
        }
 
        /* Destroy the wall */
        cave_alter_feat(y, x, FF_HURT_ROCK);
 
-       (void)move_player_effect(p_ptr, y, x, MPE_DONT_PICKUP);
+       (void)move_player_effect(caster_ptr, y, x, MPE_DONT_PICKUP);
        return TRUE;
 }
 
 
-bool shock_power(void)
+bool shock_power(player_type *caster_ptr)
 {
        DIRECTION dir;
        POSITION y, x;
        HIT_POINT dam;
-       PLAYER_LEVEL plev = p_ptr->lev;
+       PLAYER_LEVEL plev = caster_ptr->lev;
        int boost = P_PTR_KI;
-       if (heavy_armor(p_ptr)) boost /= 2;
+       if (heavy_armor(caster_ptr)) boost /= 2;
 
        project_length = 1;
        if (!get_aim_dir(&dir)) return FALSE;
 
-       y = p_ptr->y + ddy[dir];
-       x = p_ptr->x + ddx[dir];
+       y = caster_ptr->y + ddy[dir];
+       x = caster_ptr->x + ddx[dir];
        dam = damroll(8 + ((plev - 5) / 4) + boost / 12, 8);
        fire_beam(GF_MISSILE, dir, dam);
-       if (p_ptr->current_floor_ptr->grid_array[y][x].m_idx)
+       if (caster_ptr->current_floor_ptr->grid_array[y][x].m_idx)
        {
                int i;
                POSITION ty = y, tx = x;
                POSITION oy = y, ox = x;
-               MONSTER_IDX m_idx = p_ptr->current_floor_ptr->grid_array[y][x].m_idx;
-               monster_type *m_ptr = &p_ptr->current_floor_ptr->m_list[m_idx];
+               MONSTER_IDX m_idx = caster_ptr->current_floor_ptr->grid_array[y][x].m_idx;
+               monster_type *m_ptr = &caster_ptr->current_floor_ptr->m_list[m_idx];
                monster_race *r_ptr = &r_info[m_ptr->r_idx];
                GAME_TEXT m_name[MAX_NLEN];
 
@@ -3402,7 +3404,7 @@ bool shock_power(void)
                        {
                                y += ddy[dir];
                                x += ddx[dir];
-                               if (cave_empty_bold(p_ptr->current_floor_ptr, y, x))
+                               if (cave_empty_bold(caster_ptr->current_floor_ptr, y, x))
                                {
                                        ty = y;
                                        tx = x;
@@ -3412,17 +3414,17 @@ bool shock_power(void)
                        if ((ty != oy) || (tx != ox))
                        {
                                msg_format(_("%sを吹き飛ばした!", "You blow %s away!"), m_name);
-                               p_ptr->current_floor_ptr->grid_array[oy][ox].m_idx = 0;
-                               p_ptr->current_floor_ptr->grid_array[ty][tx].m_idx = m_idx;
+                               caster_ptr->current_floor_ptr->grid_array[oy][ox].m_idx = 0;
+                               caster_ptr->current_floor_ptr->grid_array[ty][tx].m_idx = m_idx;
                                m_ptr->fy = ty;
                                m_ptr->fx = tx;
 
-                               update_monster(m_idx, TRUE);
+                               update_monster(caster_ptr, m_idx, TRUE);
                                lite_spot(oy, ox);
                                lite_spot(ty, tx);
 
                                if (r_ptr->flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
-                                       p_ptr->update |= (PU_MON_LITE);
+                                       caster_ptr->update |= (PU_MON_LITE);
                        }
                }
        }
@@ -3474,10 +3476,10 @@ bool detonation(player_type *creature_ptr)
        return TRUE;
 }
 
-void blood_curse_to_enemy(MONSTER_IDX m_idx)
+void blood_curse_to_enemy(player_type *caster_ptr, MONSTER_IDX m_idx)
 {
-       monster_type *m_ptr = &p_ptr->current_floor_ptr->m_list[m_idx];
-       grid_type *g_ptr = &p_ptr->current_floor_ptr->grid_array[m_ptr->fy][m_ptr->fx];
+       monster_type *m_ptr = &caster_ptr->current_floor_ptr->m_list[m_idx];
+       grid_type *g_ptr = &caster_ptr->current_floor_ptr->grid_array[m_ptr->fy][m_ptr->fx];
        BIT_FLAGS curse_flg = (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP);
        int count = 0;
        do
@@ -3488,7 +3490,7 @@ void blood_curse_to_enemy(MONSTER_IDX m_idx)
                        if (!count)
                        {
                                msg_print(_("地面が揺れた...", "The ground trembles..."));
-                               earthquake(p_ptr, m_ptr->fy, m_ptr->fx, 4 + randint0(4), 0);
+                               earthquake(caster_ptr, m_ptr->fy, m_ptr->fx, 4 + randint0(4), 0);
                                if (!one_in_(6)) break;
                        }
                case 3: case 4: case 5: case 6:
@@ -3505,7 +3507,7 @@ void blood_curse_to_enemy(MONSTER_IDX m_idx)
                        {
                                msg_print(_("空間が歪んだ!", "Space warps about you!"));
 
-                               if (m_ptr->r_idx) teleport_away(g_ptr->m_idx, damroll(10, 10), TELEPORT_PASSIVE);
+                               if (m_ptr->r_idx) teleport_away(caster_ptr, g_ptr->m_idx, damroll(10, 10), TELEPORT_PASSIVE);
                                if (one_in_(13)) count += activate_hi_summon(m_ptr->fy, m_ptr->fx, TRUE);
                                if (!one_in_(6)) break;
                        }
@@ -3527,15 +3529,15 @@ void blood_curse_to_enemy(MONSTER_IDX m_idx)
                        if (pet) mode |= PM_FORCE_PET;
                        else mode |= (PM_NO_PET | PM_FORCE_FRIENDLY);
 
-                       count += summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, (pet ? p_ptr->lev * 2 / 3 + randint1(p_ptr->lev / 2) : p_ptr->current_floor_ptr->dun_level), 0, mode);
+                       count += summon_specific((pet ? -1 : 0), caster_ptr->y, caster_ptr->x, (pet ? caster_ptr->lev * 2 / 3 + randint1(caster_ptr->lev / 2) : caster_ptr->current_floor_ptr->dun_level), 0, mode);
                        if (!one_in_(6)) break;
                }
                case 23: case 24: case 25:
-                       if (p_ptr->hold_exp && (randint0(100) < 75)) break;
+                       if (caster_ptr->hold_exp && (randint0(100) < 75)) break;
                        msg_print(_("経験値が体から吸い取られた気がする!", "You feel your experience draining away..."));
 
-                       if (p_ptr->hold_exp) lose_exp(p_ptr, p_ptr->exp / 160);
-                       else lose_exp(p_ptr, p_ptr->exp / 16);
+                       if (caster_ptr->hold_exp) lose_exp(caster_ptr, caster_ptr->exp / 160);
+                       else lose_exp(caster_ptr, caster_ptr->exp / 16);
                        if (!one_in_(6)) break;
                case 26: case 27: case 28:
                {
@@ -3546,7 +3548,7 @@ void blood_curse_to_enemy(MONSTER_IDX m_idx)
                                {
                                        do
                                        {
-                                               (void)do_dec_stat(p_ptr, i);
+                                               (void)do_dec_stat(caster_ptr, i);
                                        } while (one_in_(2));
 
                                        i++;
@@ -3554,7 +3556,7 @@ void blood_curse_to_enemy(MONSTER_IDX m_idx)
                        }
                        else
                        {
-                               (void)do_dec_stat(p_ptr, randint0(6));
+                               (void)do_dec_stat(caster_ptr, randint0(6));
                        }
                        break;
                }
@@ -3614,19 +3616,19 @@ bool fire_crimson(player_type *shooter_ptr)
  * @brief 町間のテレポートを行うメインルーチン。
  * @return テレポート処理を決定したか否か
  */
-bool tele_town(void)
+bool tele_town(player_type *caster_ptr)
 {
        int i;
        POSITION x, y;
        int num = 0;
 
-       if (p_ptr->current_floor_ptr->dun_level)
+       if (caster_ptr->current_floor_ptr->dun_level)
        {
                msg_print(_("この魔法は地上でしか使えない!", "This spell can only be used on the surface!"));
                return FALSE;
        }
 
-       if (p_ptr->inside_arena || p_ptr->phase_out)
+       if (caster_ptr->current_floor_ptr->inside_arena || caster_ptr->phase_out)
        {
                msg_print(_("この魔法は外でしか使えない!", "This spell can only be used outside!"));
                return FALSE;
@@ -3639,7 +3641,7 @@ bool tele_town(void)
        {
                char buf[80];
 
-               if ((i == NO_TOWN) || (i == SECRET_TOWN) || (i == p_ptr->town_num) || !(p_ptr->visit & (1L << (i - 1)))) continue;
+               if ((i == NO_TOWN) || (i == SECRET_TOWN) || (i == caster_ptr->town_num) || !(caster_ptr->visit & (1L << (i - 1)))) continue;
 
                sprintf(buf, "%c) %-20s", I2A(i - 1), town_info[i].name);
                prt(buf, 5 + i, 5);
@@ -3665,7 +3667,7 @@ bool tele_town(void)
                        return FALSE;
                }
                else if ((i < 'a') || (i > ('a' + max_towns - 2))) continue;
-               else if (((i - 'a' + 1) == p_ptr->town_num) || ((i - 'a' + 1) == NO_TOWN) || ((i - 'a' + 1) == SECRET_TOWN) || !(p_ptr->visit & (1L << (i - 'a')))) continue;
+               else if (((i - 'a' + 1) == caster_ptr->town_num) || ((i - 'a' + 1) == NO_TOWN) || ((i - 'a' + 1) == SECRET_TOWN) || !(caster_ptr->visit & (1L << (i - 'a')))) continue;
                break;
        }
 
@@ -3675,15 +3677,15 @@ bool tele_town(void)
                {
                        if (wilderness[y][x].town == (i - 'a' + 1))
                        {
-                               p_ptr->wilderness_y = y;
-                               p_ptr->wilderness_x = x;
+                               caster_ptr->wilderness_y = y;
+                               caster_ptr->wilderness_x = x;
                        }
                }
        }
 
-       p_ptr->leaving = TRUE;
-       p_ptr->leave_bldg = TRUE;
-       p_ptr->teleport_town = TRUE;
+       caster_ptr->leaving = TRUE;
+       caster_ptr->leave_bldg = TRUE;
+       caster_ptr->teleport_town = TRUE;
        screen_load();
        return TRUE;
 }