OSDN Git Service

[Refactor] #38997 project_all_los() に player_type * 引数を追加. / Add player_type * argume...
[hengband/hengband.git] / src / realm-hex.c
index 23afa7d..f63041a 100644 (file)
 #include "player-status.h"
 #include "player-effects.h"
 #include "player-skill.h"
+#include "player-inventory.h"
 #include "realm-hex.h"
 #include "grid.h"
 #include "monsterrace.h"
 #include "targeting.h"
+#include "realm-song.h"
+#include "view-mainwindow.h"
+#include "world.h"
 
 #define MAX_KEEP 4 /*!<呪術の最大詠唱数 */
 
  * @brief プレイヤーが詠唱中の全呪術を停止する
  * @return なし
  */
-bool stop_hex_spell_all(void)
+bool stop_hex_spell_all(player_type *caster_ptr)
 {
        SPELL_IDX i;
 
        for (i = 0; i < 32; i++)
        {
-               if (hex_spelling(i)) do_spell(REALM_HEX, i, SPELL_STOP);
+               if (hex_spelling(i)) exe_spell(caster_ptr, REALM_HEX, i, SPELL_STOP);
        }
 
-       CASTING_HEX_FLAGS(p_ptr) = 0;
-       CASTING_HEX_NUM(p_ptr) = 0;
+       CASTING_HEX_FLAGS(caster_ptr) = 0;
+       CASTING_HEX_NUM(caster_ptr) = 0;
 
-       if (p_ptr->action == ACTION_SPELL) set_action(ACTION_NONE);
+       if (caster_ptr->action == ACTION_SPELL) set_action(caster_ptr, ACTION_NONE);
 
-       p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
-       p_ptr->redraw |= (PR_EXTRA | PR_HP | PR_MANA);
+       caster_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
+       caster_ptr->redraw |= (PR_EXTRA | PR_HP | PR_MANA);
 
        return TRUE;
 }
@@ -64,7 +68,7 @@ bool stop_hex_spell_all(void)
  * @brief プレイヤーが詠唱中の呪術から一つを選んで停止する
  * @return なし
  */
-bool stop_hex_spell(void)
+bool stop_hex_spell(player_type *caster_ptr)
 {
        int spell;
        char choice = 0;
@@ -74,21 +78,21 @@ bool stop_hex_spell(void)
        TERM_LEN x = 20;
        int sp[MAX_KEEP];
 
-       if (!hex_spelling_any())
+       if (!hex_spelling_any(caster_ptr))
        {
                msg_print(_("呪文を詠唱していません。", "You are casting no spell."));
                return FALSE;
        }
 
        /* Stop all spells */
-       else if ((CASTING_HEX_NUM(p_ptr) == 1) || (p_ptr->lev < 35))
+       else if ((CASTING_HEX_NUM(caster_ptr) == 1) || (caster_ptr->lev < 35))
        {
-               return stop_hex_spell_all();
+               return stop_hex_spell_all(caster_ptr);
        }
        else
        {
                strnfmt(out_val, 78, _("どの呪文の詠唱を中断しますか?(呪文 %c-%c, 'l'全て, ESC)", "Which spell do you stop casting? (Spell %c-%c, 'l' to all, ESC)"),
-                       I2A(0), I2A(CASTING_HEX_NUM(p_ptr) - 1));
+                       I2A(0), I2A(CASTING_HEX_NUM(caster_ptr) - 1));
 
                screen_save();
 
@@ -102,7 +106,7 @@ bool stop_hex_spell(void)
                                if (hex_spelling(spell))
                                {
                                        Term_erase(x, y + n + 1, 255);
-                                       put_str(format("%c)  %s", I2A(n), do_spell(REALM_HEX, spell, SPELL_NAME)), y + n + 1, x + 2);
+                                       put_str(format("%c)  %s", I2A(n), exe_spell(caster_ptr, REALM_HEX, spell, SPELL_NAME)), y + n + 1, x + 2);
                                        sp[n++] = spell;
                                }
                        }
@@ -113,9 +117,9 @@ bool stop_hex_spell(void)
                        if (choice == 'l')      /* All */
                        {
                                screen_load();
-                               return stop_hex_spell_all();
+                               return stop_hex_spell_all(caster_ptr);
                        }
-                       if ((choice < I2A(0)) || (choice > I2A(CASTING_HEX_NUM(p_ptr) - 1))) continue;
+                       if ((choice < I2A(0)) || (choice > I2A(CASTING_HEX_NUM(caster_ptr) - 1))) continue;
                        flag = TRUE;
                }
        }
@@ -126,13 +130,13 @@ bool stop_hex_spell(void)
        {
                int n = sp[A2I(choice)];
 
-               do_spell(REALM_HEX, n, SPELL_STOP);
-               CASTING_HEX_FLAGS(p_ptr) &= ~(1L << n);
-               CASTING_HEX_NUM(p_ptr)--;
+               exe_spell(caster_ptr, REALM_HEX, n, SPELL_STOP);
+               CASTING_HEX_FLAGS(caster_ptr) &= ~(1L << n);
+               CASTING_HEX_NUM(caster_ptr)--;
        }
 
-       p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
-       p_ptr->redraw |= (PR_EXTRA | PR_HP | PR_MANA);
+       caster_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
+       caster_ptr->redraw |= (PR_EXTRA | PR_HP | PR_MANA);
 
        return flag;
 }
@@ -143,7 +147,7 @@ bool stop_hex_spell(void)
  * Upkeeping hex spells Called from dungeon.c
  * @return なし
  */
-void check_hex(void)
+void check_hex(player_type *caster_ptr)
 {
        int spell;
        MANA_POINT need_mana;
@@ -151,20 +155,20 @@ void check_hex(void)
        bool res = FALSE;
 
        /* Spells spelled by player */
-       if (p_ptr->realm1 != REALM_HEX) return;
-       if (!CASTING_HEX_FLAGS(p_ptr) && !p_ptr->magic_num1[1]) return;
+       if (caster_ptr->realm1 != REALM_HEX) return;
+       if (!CASTING_HEX_FLAGS(caster_ptr) && !caster_ptr->magic_num1[1]) return;
 
-       if (p_ptr->magic_num1[1])
+       if (caster_ptr->magic_num1[1])
        {
-               p_ptr->magic_num1[0] = p_ptr->magic_num1[1];
-               p_ptr->magic_num1[1] = 0;
+               caster_ptr->magic_num1[0] = caster_ptr->magic_num1[1];
+               caster_ptr->magic_num1[1] = 0;
                res = TRUE;
        }
 
        /* Stop all spells when anti-magic ability is given */
-       if (p_ptr->anti_magic)
+       if (caster_ptr->anti_magic)
        {
-               stop_hex_spell_all();
+               stop_hex_spell_all(caster_ptr);
                return;
        }
 
@@ -182,31 +186,31 @@ void check_hex(void)
        /* Culcurates final mana cost */
        need_mana_frac = 0;
        s64b_div(&need_mana, &need_mana_frac, 0, 3); /* Divide by 3 */
-       need_mana += (CASTING_HEX_NUM(p_ptr) - 1);
+       need_mana += (CASTING_HEX_NUM(caster_ptr) - 1);
 
        /* Not enough mana */
-       if (s64b_cmp(p_ptr->csp, p_ptr->csp_frac, need_mana, need_mana_frac) < 0)
+       if (s64b_cmp(caster_ptr->csp, caster_ptr->csp_frac, need_mana, need_mana_frac) < 0)
        {
-               stop_hex_spell_all();
+               stop_hex_spell_all(caster_ptr);
                return;
        }
 
        /* Enough mana */
        else
        {
-               s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), need_mana, need_mana_frac);
+               s64b_sub(&(caster_ptr->csp), &(caster_ptr->csp_frac), need_mana, need_mana_frac);
 
-               p_ptr->redraw |= PR_MANA;
+               caster_ptr->redraw |= PR_MANA;
                if (res)
                {
                        msg_print(_("詠唱を再開した。", "You restart spelling."));
 
-                       p_ptr->action = ACTION_SPELL;
+                       caster_ptr->action = ACTION_SPELL;
 
-                       p_ptr->update |= (PU_BONUS | PU_HP);
-                       p_ptr->redraw |= (PR_MAP | PR_STATUS | PR_STATE);
-                       p_ptr->update |= (PU_MONSTERS);
-                       p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
+                       caster_ptr->update |= (PU_BONUS | PU_HP);
+                       caster_ptr->redraw |= (PR_MAP | PR_STATUS | PR_STATE);
+                       caster_ptr->update |= (PU_MONSTERS);
+                       caster_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
                }
        }
 
@@ -219,14 +223,14 @@ void check_hex(void)
 
                s_ptr = &technic_info[REALM_HEX - MIN_TECHNIC][spell];
 
-               if (p_ptr->spell_exp[spell] < SPELL_EXP_BEGINNER)
-                       p_ptr->spell_exp[spell] += 5;
-               else if(p_ptr->spell_exp[spell] < SPELL_EXP_SKILLED)
-               { if (one_in_(2) && (current_floor_ptr->dun_level > 4) && ((current_floor_ptr->dun_level + 10) > p_ptr->lev)) p_ptr->spell_exp[spell] += 1; }
-               else if(p_ptr->spell_exp[spell] < SPELL_EXP_EXPERT)
-               { if (one_in_(5) && ((current_floor_ptr->dun_level + 5) > p_ptr->lev) && ((current_floor_ptr->dun_level + 5) > s_ptr->slevel)) p_ptr->spell_exp[spell] += 1; }
-               else if(p_ptr->spell_exp[spell] < SPELL_EXP_MASTER)
-               { if (one_in_(5) && ((current_floor_ptr->dun_level + 5) > p_ptr->lev) && (current_floor_ptr->dun_level > s_ptr->slevel)) p_ptr->spell_exp[spell] += 1; }
+               if (caster_ptr->spell_exp[spell] < SPELL_EXP_BEGINNER)
+                       caster_ptr->spell_exp[spell] += 5;
+               else if(caster_ptr->spell_exp[spell] < SPELL_EXP_SKILLED)
+               { if (one_in_(2) && (caster_ptr->current_floor_ptr->dun_level > 4) && ((caster_ptr->current_floor_ptr->dun_level + 10) > caster_ptr->lev)) caster_ptr->spell_exp[spell] += 1; }
+               else if(caster_ptr->spell_exp[spell] < SPELL_EXP_EXPERT)
+               { if (one_in_(5) && ((caster_ptr->current_floor_ptr->dun_level + 5) > caster_ptr->lev) && ((caster_ptr->current_floor_ptr->dun_level + 5) > s_ptr->slevel)) caster_ptr->spell_exp[spell] += 1; }
+               else if(caster_ptr->spell_exp[spell] < SPELL_EXP_MASTER)
+               { if (one_in_(5) && ((caster_ptr->current_floor_ptr->dun_level + 5) > caster_ptr->lev) && (caster_ptr->current_floor_ptr->dun_level > s_ptr->slevel)) caster_ptr->spell_exp[spell] += 1; }
        }
 
        /* Do any effects of continual spells */
@@ -234,7 +238,7 @@ void check_hex(void)
        {
                if (hex_spelling(spell))
                {
-                       do_spell(REALM_HEX, spell, SPELL_CONT);
+                       exe_spell(caster_ptr, REALM_HEX, spell, SPELL_CONT);
                }
        }
 }
@@ -243,12 +247,12 @@ void check_hex(void)
  * @brief プレイヤーの呪術詠唱枠がすでに最大かどうかを返す
  * @return すでに全枠を利用しているならTRUEを返す
  */
-bool hex_spell_fully(void)
+bool hex_spell_fully(player_type *caster_ptr)
 {
        int k_max = 0;
-       k_max = (p_ptr->lev / 15) + 1;
+       k_max = (caster_ptr->lev / 15) + 1;
        k_max = MIN(k_max, MAX_KEEP);
-       if (CASTING_HEX_NUM(p_ptr) < k_max) return FALSE;
+       if (CASTING_HEX_NUM(caster_ptr) < k_max) return FALSE;
        return TRUE;
 }
 
@@ -256,15 +260,15 @@ bool hex_spell_fully(void)
  * @brief 一定ゲームターン毎に復讐処理の残り期間の判定を行う
  * @return なし
  */
-void revenge_spell(void)
+void revenge_spell(player_type *caster_ptr)
 {
-       if (p_ptr->realm1 != REALM_HEX) return;
-       if (HEX_REVENGE_TURN(p_ptr) <= 0) return;
+       if (caster_ptr->realm1 != REALM_HEX) return;
+       if (HEX_REVENGE_TURN(caster_ptr) <= 0) return;
 
-       switch(HEX_REVENGE_TYPE(p_ptr))
+       switch(HEX_REVENGE_TYPE(caster_ptr))
        {
-               case 1: do_spell(REALM_HEX, HEX_PATIENCE, SPELL_CONT); break;
-               case 2: do_spell(REALM_HEX, HEX_REVENGE, SPELL_CONT); break;
+               case 1: exe_spell(caster_ptr, REALM_HEX, HEX_PATIENCE, SPELL_CONT); break;
+               case 2: exe_spell(caster_ptr, REALM_HEX, HEX_REVENGE, SPELL_CONT); break;
        }
 }
 
@@ -288,7 +292,7 @@ void revenge_store(HIT_POINT dam)
  */
 bool teleport_barrier(MONSTER_IDX m_idx)
 {
-       monster_type *m_ptr = &current_floor_ptr->m_list[m_idx];
+       monster_type *m_ptr = &p_ptr->current_floor_ptr->m_list[m_idx];
        monster_race *r_ptr = &r_info[m_ptr->r_idx];
 
        if (!hex_spelling(HEX_ANTI_TELE)) return FALSE;
@@ -304,7 +308,7 @@ bool teleport_barrier(MONSTER_IDX m_idx)
  */
 bool magic_barrier(MONSTER_IDX m_idx)
 {
-       monster_type *m_ptr = &current_floor_ptr->m_list[m_idx];
+       monster_type *m_ptr = &p_ptr->current_floor_ptr->m_list[m_idx];
        monster_race *r_ptr = &r_info[m_ptr->r_idx];
 
        if (!hex_spelling(HEX_ANTI_MAGIC)) return FALSE;
@@ -320,7 +324,7 @@ bool magic_barrier(MONSTER_IDX m_idx)
  */
 bool multiply_barrier(MONSTER_IDX m_idx)
 {
-       monster_type *m_ptr = &current_floor_ptr->m_list[m_idx];
+       monster_type *m_ptr = &p_ptr->current_floor_ptr->m_list[m_idx];
        monster_race *r_ptr = &r_info[m_ptr->r_idx];
 
        if (!hex_spelling(HEX_ANTI_MULTI)) return FALSE;
@@ -335,7 +339,7 @@ bool multiply_barrier(MONSTER_IDX m_idx)
 * @param mode 処理内容 (SPELL_NAME / SPELL_DESC / SPELL_INFO / SPELL_CAST / SPELL_CONT / SPELL_STOP)
 * @return SPELL_NAME / SPELL_DESC / SPELL_INFO 時には文字列ポインタを返す。SPELL_CAST / SPELL_CONT / SPELL_STOP 時はNULL文字列を返す。
 */
-concptr do_hex_spell(SPELL_IDX spell, BIT_FLAGS mode)
+concptr do_hex_spell(player_type *caster_ptr, SPELL_IDX spell, BIT_FLAGS mode)
 {
        bool name = (mode == SPELL_NAME) ? TRUE : FALSE;
        bool desc = (mode == SPELL_DESC) ? TRUE : FALSE;
@@ -346,7 +350,7 @@ concptr do_hex_spell(SPELL_IDX spell, BIT_FLAGS mode)
 
        bool add = TRUE;
 
-       PLAYER_LEVEL plev = p_ptr->lev;
+       PLAYER_LEVEL plev = caster_ptr->lev;
        HIT_POINT power;
 
        switch (spell)
@@ -357,14 +361,14 @@ concptr do_hex_spell(SPELL_IDX spell, BIT_FLAGS mode)
                if (desc) return _("祝福により攻撃精度と防御力が上がる。", "Attempts to increase +to_hit of a weapon and AC");
                if (cast)
                {
-                       if (!p_ptr->blessed)
+                       if (!caster_ptr->blessed)
                        {
                                msg_print(_("高潔な気分になった!", "You feel righteous!"));
                        }
                }
                if (stop)
                {
-                       if (!p_ptr->blessed)
+                       if (!caster_ptr->blessed)
                        {
                                msg_print(_("高潔な気分が消え失せた。", "The prayer has expired."));
                        }
@@ -379,7 +383,7 @@ concptr do_hex_spell(SPELL_IDX spell, BIT_FLAGS mode)
                {
                        msg_print(_("気分が良くなってくる。", "You feel better and better."));
                }
-               if (cast || cont) (void)cure_light_wounds(1, 10);
+               if (cast || cont) (void)cure_light_wounds(caster_ptr, 1, 10);
                break;
 
        case 2:
@@ -402,7 +406,7 @@ concptr do_hex_spell(SPELL_IDX spell, BIT_FLAGS mode)
                if (info) return info_damage(1, power, 0);
                if (cast || cont)
                {
-                       project_all_los(GF_POIS, randint1(power));
+                       project_all_los(caster_ptr, GF_POIS, randint1(power));
                }
                break;
 
@@ -430,7 +434,7 @@ concptr do_hex_spell(SPELL_IDX spell, BIT_FLAGS mode)
                        q = _("どれを呪いますか?", "Which weapon do you curse?");
                        s = _("武器を装備していない。", "You wield no weapons.");
 
-                       o_ptr = choose_object(&item, q, s, (USE_EQUIP));
+                       o_ptr = choose_object(p_ptr, &item, q, s, (USE_EQUIP), 0);
                        if (!o_ptr) return FALSE;
 
                        object_desc(o_name, o_ptr, OD_NAME_ONLY);
@@ -488,7 +492,7 @@ concptr do_hex_spell(SPELL_IDX spell, BIT_FLAGS mode)
                                o_ptr->curse_flags |= get_curse(curse_rank, o_ptr);
                        }
 
-                       p_ptr->update |= (PU_BONUS);
+                       caster_ptr->update |= (PU_BONUS);
                        add = FALSE;
                }
                break;
@@ -507,22 +511,22 @@ concptr do_hex_spell(SPELL_IDX spell, BIT_FLAGS mode)
                if (name) return _("我慢", "Patience");
                if (desc) return _("数ターン攻撃を耐えた後、受けたダメージを地獄の業火として周囲に放出する。",
                        "Bursts hell fire strongly after patients any damage while few turns.");
-               power = MIN(200, (HEX_REVENGE_POWER(p_ptr) * 2));
+               power = MIN(200, (HEX_REVENGE_POWER(caster_ptr) * 2));
                if (info) return info_damage(0, 0, power);
                if (cast)
                {
-                       int a = 3 - (p_ptr->pspeed - 100) / 10;
+                       int a = 3 - (caster_ptr->pspeed - 100) / 10;
                        MAGIC_NUM2 r = 3 + randint1(3) + MAX(0, MIN(3, a));
 
-                       if (HEX_REVENGE_TURN(p_ptr) > 0)
+                       if (HEX_REVENGE_TURN(caster_ptr) > 0)
                        {
                                msg_print(_("すでに我慢をしている。", "You are already patienting."));
                                return NULL;
                        }
 
-                       HEX_REVENGE_TYPE(p_ptr) = 1;
-                       HEX_REVENGE_TURN(p_ptr) = r;
-                       HEX_REVENGE_POWER(p_ptr) = 0;
+                       HEX_REVENGE_TYPE(caster_ptr) = 1;
+                       HEX_REVENGE_TURN(caster_ptr) = r;
+                       HEX_REVENGE_POWER(caster_ptr) = 0;
                        msg_print(_("じっと耐えることにした。", "You decide to patient all damages."));
                        add = FALSE;
                }
@@ -530,25 +534,25 @@ concptr do_hex_spell(SPELL_IDX spell, BIT_FLAGS mode)
                {
                        POSITION rad = 2 + (power / 50);
 
-                       HEX_REVENGE_TURN(p_ptr)--;
+                       HEX_REVENGE_TURN(caster_ptr)--;
 
-                       if ((HEX_REVENGE_TURN(p_ptr) <= 0) || (power >= 200))
+                       if ((HEX_REVENGE_TURN(caster_ptr) <= 0) || (power >= 200))
                        {
                                msg_print(_("我慢が解かれた!", "Time for end of patioence!"));
                                if (power)
                                {
-                                       project(0, rad, p_ptr->y, p_ptr->x, power, GF_HELL_FIRE,
+                                       project(caster_ptr, 0, rad, caster_ptr->y, caster_ptr->x, power, GF_HELL_FIRE,
                                                (PROJECT_STOP | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL), -1);
                                }
-                               if (p_ptr->wizard)
+                               if (current_world_ptr->wizard)
                                {
                                        msg_format(_("%d点のダメージを返した。", "You return %d damages."), power);
                                }
 
                                /* Reset */
-                               HEX_REVENGE_TYPE(p_ptr) = 0;
-                               HEX_REVENGE_TURN(p_ptr) = 0;
-                               HEX_REVENGE_POWER(p_ptr) = 0;
+                               HEX_REVENGE_TYPE(caster_ptr) = 0;
+                               HEX_REVENGE_TURN(caster_ptr) = 0;
+                               HEX_REVENGE_POWER(caster_ptr) = 0;
                        }
                }
                break;
@@ -575,7 +579,7 @@ concptr do_hex_spell(SPELL_IDX spell, BIT_FLAGS mode)
                {
                        msg_print(_("気分が良くなってくる。", "You feel better and better."));
                }
-               if (cast || cont) (void)cure_serious_wounds(2, 10);
+               if (cast || cont) (void)cure_serious_wounds(caster_ptr, 2, 10);
                break;
 
        case 10:
@@ -583,9 +587,9 @@ concptr do_hex_spell(SPELL_IDX spell, BIT_FLAGS mode)
                if (desc) return _("呪文詠唱を中止することなく、薬の効果を得ることができる。", "Quaffs a potion without canceling of casting a spell.");
                if (cast)
                {
-                       CASTING_HEX_FLAGS(p_ptr) |= (1L << HEX_INHAIL);
-                       do_cmd_quaff_potion();
-                       CASTING_HEX_FLAGS(p_ptr) &= ~(1L << HEX_INHAIL);
+                       CASTING_HEX_FLAGS(caster_ptr) |= (1L << HEX_INHAIL);
+                       do_cmd_quaff_potion(p_ptr);
+                       CASTING_HEX_FLAGS(caster_ptr) &= ~(1L << HEX_INHAIL);
                        add = FALSE;
                }
                break;
@@ -598,7 +602,7 @@ concptr do_hex_spell(SPELL_IDX spell, BIT_FLAGS mode)
                if (info) return info_damage(1, power, 0);
                if (cast || cont)
                {
-                       project_all_los(GF_HYPODYNAMIA, randint1(power));
+                       project_all_los(caster_ptr, GF_HYPODYNAMIA, randint1(power));
                }
                break;
 
@@ -611,7 +615,7 @@ concptr do_hex_spell(SPELL_IDX spell, BIT_FLAGS mode)
 #ifdef JP
                        msg_print("あなたの武器が黒く輝いた。");
 #else
-                       if (!empty_hands(FALSE))
+                       if (!empty_hands(caster_ptr, FALSE))
                                msg_print("Your weapons glow bright black.");
                        else
                                msg_print("Your weapon glows bright black.");
@@ -622,7 +626,7 @@ concptr do_hex_spell(SPELL_IDX spell, BIT_FLAGS mode)
 #ifdef JP
                        msg_print("武器の輝きが消え去った。");
 #else
-                       msg_format("Brightness of weapon%s disappeared.", (empty_hands(FALSE)) ? "" : "s");
+                       msg_format("Brightness of weapon%s disappeared.", (empty_hands(caster_ptr, FALSE)) ? "" : "s");
 #endif
                }
                break;
@@ -683,7 +687,7 @@ concptr do_hex_spell(SPELL_IDX spell, BIT_FLAGS mode)
                {
                        msg_print(_("気分が良くなってくる。", "You feel better and better."));
                }
-               if (cast || cont) (void)cure_critical_wounds(damroll(4, 10));
+               if (cast || cont) (void)cure_critical_wounds(caster_ptr, damroll(4, 10));
                break;
 
        case 18:
@@ -707,7 +711,7 @@ concptr do_hex_spell(SPELL_IDX spell, BIT_FLAGS mode)
                }
                if (cast || cont)
                {
-                       animate_dead(0, p_ptr->y, p_ptr->x);
+                       animate_dead(0, caster_ptr->y, caster_ptr->x);
                }
                break;
 
@@ -726,10 +730,10 @@ concptr do_hex_spell(SPELL_IDX spell, BIT_FLAGS mode)
                        q = _("どれを呪いますか?", "Which piece of armour do you curse?");
                        s = _("防具を装備していない。", "You wield no piece of armours.");
 
-                       o_ptr = choose_object(&item, q, s, (USE_EQUIP));
+                       o_ptr = choose_object(p_ptr, &item, q, s, (USE_EQUIP), 0);
                        if (!o_ptr) return FALSE;
 
-                       o_ptr = &p_ptr->inventory_list[item];
+                       o_ptr = &caster_ptr->inventory_list[item];
                        object_desc(o_name, o_ptr, OD_NAME_ONLY);
                        object_flags(o_ptr, f);
 
@@ -786,7 +790,7 @@ concptr do_hex_spell(SPELL_IDX spell, BIT_FLAGS mode)
                                o_ptr->curse_flags |= get_curse(curse_rank, o_ptr);
                        }
 
-                       p_ptr->update |= (PU_BONUS);
+                       caster_ptr->update |= (PU_BONUS);
                        add = FALSE;
                }
                break;
@@ -796,7 +800,7 @@ concptr do_hex_spell(SPELL_IDX spell, BIT_FLAGS mode)
                if (desc) return _("影のオーラを身にまとい、敵に影のダメージを与える。", "Gives aura of shadow.");
                if (cast)
                {
-                       object_type *o_ptr = &p_ptr->inventory_list[INVEN_OUTER];
+                       object_type *o_ptr = &caster_ptr->inventory_list[INVEN_OUTER];
 
                        if (!o_ptr->k_idx)
                        {
@@ -815,14 +819,14 @@ concptr do_hex_spell(SPELL_IDX spell, BIT_FLAGS mode)
                }
                if (cont)
                {
-                       object_type *o_ptr = &p_ptr->inventory_list[INVEN_OUTER];
+                       object_type *o_ptr = &caster_ptr->inventory_list[INVEN_OUTER];
 
                        if ((!o_ptr->k_idx) || (!object_is_cursed(o_ptr)))
                        {
-                               do_spell(REALM_HEX, spell, SPELL_STOP);
-                               CASTING_HEX_FLAGS(p_ptr) &= ~(1L << spell);
-                               CASTING_HEX_NUM(p_ptr)--;
-                               if (!SINGING_SONG_ID(p_ptr)) set_action(ACTION_NONE);
+                               exe_spell(p_ptr, REALM_HEX, spell, SPELL_STOP);
+                               CASTING_HEX_FLAGS(caster_ptr) &= ~(1L << spell);
+                               CASTING_HEX_NUM(caster_ptr)--;
+                               if (!SINGING_SONG_ID(caster_ptr)) set_action(caster_ptr, ACTION_NONE);
                        }
                }
                if (stop)
@@ -838,7 +842,7 @@ concptr do_hex_spell(SPELL_IDX spell, BIT_FLAGS mode)
                if (info) return info_damage(1, power, 0);
                if (cast || cont)
                {
-                       project_all_los(GF_PSI_DRAIN, randint1(power));
+                       project_all_los(caster_ptr, GF_PSI_DRAIN, randint1(power));
                }
                break;
 
@@ -871,34 +875,34 @@ concptr do_hex_spell(SPELL_IDX spell, BIT_FLAGS mode)
                if (cast || cont)
                {
                        bool flag = FALSE;
-                       int d = (p_ptr->max_exp - p_ptr->exp);
-                       int r = (p_ptr->exp / 20);
+                       int d = (caster_ptr->max_exp - caster_ptr->exp);
+                       int r = (caster_ptr->exp / 20);
                        int i;
 
                        if (d > 0)
                        {
                                if (d < r)
-                                       p_ptr->exp = p_ptr->max_exp;
+                                       caster_ptr->exp = caster_ptr->max_exp;
                                else
-                                       p_ptr->exp += r;
+                                       caster_ptr->exp += r;
 
                                /* Check the experience */
-                               check_experience();
+                               check_experience(caster_ptr);
 
                                flag = TRUE;
                        }
                        for (i = A_STR; i < A_MAX; i++)
                        {
-                               if (p_ptr->stat_cur[i] < p_ptr->stat_max[i])
+                               if (caster_ptr->stat_cur[i] < caster_ptr->stat_max[i])
                                {
-                                       if (p_ptr->stat_cur[i] < 18)
-                                               p_ptr->stat_cur[i]++;
+                                       if (caster_ptr->stat_cur[i] < 18)
+                                               caster_ptr->stat_cur[i]++;
                                        else
-                                               p_ptr->stat_cur[i] += 10;
+                                               caster_ptr->stat_cur[i] += 10;
 
-                                       if (p_ptr->stat_cur[i] > p_ptr->stat_max[i])
-                                               p_ptr->stat_cur[i] = p_ptr->stat_max[i];
-                                       p_ptr->update |= (PU_BONUS);
+                                       if (caster_ptr->stat_cur[i] > caster_ptr->stat_max[i])
+                                               caster_ptr->stat_cur[i] = caster_ptr->stat_max[i];
+                                       caster_ptr->update |= (PU_BONUS);
 
                                        flag = TRUE;
                                }
@@ -906,13 +910,13 @@ concptr do_hex_spell(SPELL_IDX spell, BIT_FLAGS mode)
 
                        if (!flag)
                        {
-                               msg_format(_("%sの呪文の詠唱をやめた。", "Finish casting '%^s'."), do_spell(REALM_HEX, HEX_RESTORE, SPELL_NAME));
-                               CASTING_HEX_FLAGS(p_ptr) &= ~(1L << HEX_RESTORE);
-                               if (cont) CASTING_HEX_NUM(p_ptr)--;
-                               if (CASTING_HEX_NUM(p_ptr)) p_ptr->action = ACTION_NONE;
+                               msg_format(_("%sの呪文の詠唱をやめた。", "Finish casting '%^s'."), exe_spell(p_ptr, REALM_HEX, HEX_RESTORE, SPELL_NAME));
+                               CASTING_HEX_FLAGS(caster_ptr) &= ~(1L << HEX_RESTORE);
+                               if (cont) CASTING_HEX_NUM(caster_ptr)--;
+                               if (CASTING_HEX_NUM(caster_ptr)) caster_ptr->action = ACTION_NONE;
 
-                               p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
-                               p_ptr->redraw |= (PR_EXTRA);
+                               caster_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
+                               caster_ptr->redraw |= (PR_EXTRA);
 
                                return "";
                        }
@@ -933,14 +937,14 @@ concptr do_hex_spell(SPELL_IDX spell, BIT_FLAGS mode)
                        q = _("どの装備品から吸収しますか?", "Which cursed equipment do you drain mana from?");
                        s = _("呪われたアイテムを装備していない。", "You have no cursed equipment.");
 
-                       o_ptr = choose_object(&item, q, s, (USE_EQUIP));
+                       o_ptr = choose_object(p_ptr, &item, q, s, (USE_EQUIP), 0);
                        if (!o_ptr) return FALSE;
 
                        object_flags(o_ptr, f);
 
-                       p_ptr->csp += (p_ptr->lev / 5) + randint1(p_ptr->lev / 5);
-                       if (have_flag(f, TR_TY_CURSE) || (o_ptr->curse_flags & TRC_TY_CURSE)) p_ptr->csp += randint1(5);
-                       if (p_ptr->csp > p_ptr->msp) p_ptr->csp = p_ptr->msp;
+                       caster_ptr->csp += (caster_ptr->lev / 5) + randint1(caster_ptr->lev / 5);
+                       if (have_flag(f, TR_TY_CURSE) || (o_ptr->curse_flags & TRC_TY_CURSE)) caster_ptr->csp += randint1(5);
+                       if (caster_ptr->csp > caster_ptr->msp) caster_ptr->csp = caster_ptr->msp;
 
                        if (o_ptr->curse_flags & TRC_PERMA_CURSE)
                        {
@@ -972,7 +976,7 @@ concptr do_hex_spell(SPELL_IDX spell, BIT_FLAGS mode)
 #ifdef JP
                        msg_print("あなたの武器が血を欲している。");
 #else
-                       if (!empty_hands(FALSE))
+                       if (!empty_hands(caster_ptr, FALSE))
                                msg_print("Your weapons want more blood now.");
                        else
                                msg_print("Your weapon wants more blood now.");
@@ -983,7 +987,7 @@ concptr do_hex_spell(SPELL_IDX spell, BIT_FLAGS mode)
 #ifdef JP
                        msg_print("武器の渇望が消え去った。");
 #else
-                       msg_format("Thirsty of weapon%s disappeared.", (empty_hands(FALSE)) ? "" : "s");
+                       msg_format("Thirsty of weapon%s disappeared.", (empty_hands(caster_ptr, FALSE)) ? "" : "s");
 #endif
                }
                break;
@@ -1019,11 +1023,11 @@ concptr do_hex_spell(SPELL_IDX spell, BIT_FLAGS mode)
                                        int dy = y + ddy_ddd[dir];
                                        int dx = x + ddx_ddd[dir];
                                        if (dir == 5) continue;
-                                       if (current_floor_ptr->grid_array[dy][dx].m_idx) flag = TRUE;
+                                       if (p_ptr->current_floor_ptr->grid_array[dy][dx].m_idx) flag = TRUE;
                                }
 
-                               if (!cave_empty_bold(y, x) || (current_floor_ptr->grid_array[y][x].info & CAVE_ICKY) ||
-                                       (distance(y, x, p_ptr->y, p_ptr->x) > plev + 2))
+                               if (!cave_empty_bold(p_ptr->current_floor_ptr, y, x) || (p_ptr->current_floor_ptr->grid_array[y][x].info & CAVE_ICKY) ||
+                                       (distance(y, x, caster_ptr->y, caster_ptr->x) > plev + 2))
                                {
                                        msg_print(_("そこには移動できない。", "Can not teleport to there."));
                                        continue;
@@ -1033,12 +1037,12 @@ concptr do_hex_spell(SPELL_IDX spell, BIT_FLAGS mode)
 
                        if (flag && randint0(plev * plev / 2))
                        {
-                               teleport_player_to(y, x, 0L);
+                               teleport_player_to(caster_ptr, y, x, 0L);
                        }
                        else
                        {
                                msg_print(_("おっと!", "Oops!"));
-                               teleport_player(30, 0L);
+                               teleport_player(caster_ptr, 30, 0L);
                        }
 
                        add = FALSE;
@@ -1060,30 +1064,30 @@ concptr do_hex_spell(SPELL_IDX spell, BIT_FLAGS mode)
                if (name) return _("復讐の宣告", "Revenge sentence");
                if (desc) return _("数ターン後にそれまで受けたダメージに応じた威力の地獄の劫火の弾を放つ。",
                        "Fires  a ball of hell fire to try revenging after few turns.");
-               power = HEX_REVENGE_POWER(p_ptr);
+               power = HEX_REVENGE_POWER(caster_ptr);
                if (info) return info_damage(0, 0, power);
                if (cast)
                {
                        MAGIC_NUM2 r;
-                       int a = 3 - (p_ptr->pspeed - 100) / 10;
+                       int a = 3 - (caster_ptr->pspeed - 100) / 10;
                        r = 1 + randint1(2) + MAX(0, MIN(3, a));
 
-                       if (HEX_REVENGE_TURN(p_ptr) > 0)
+                       if (HEX_REVENGE_TURN(caster_ptr) > 0)
                        {
                                msg_print(_("すでに復讐は宣告済みだ。", "You already pronounced your revenge."));
                                return NULL;
                        }
 
-                       HEX_REVENGE_TYPE(p_ptr) = 2;
-                       HEX_REVENGE_TURN(p_ptr) = r;
+                       HEX_REVENGE_TYPE(caster_ptr) = 2;
+                       HEX_REVENGE_TURN(caster_ptr) = r;
                        msg_format(_("あなたは復讐を宣告した。あと %d ターン。", "You pronounce your revenge. %d turns left."), r);
                        add = FALSE;
                }
                if (cont)
                {
-                       HEX_REVENGE_TURN(p_ptr)--;
+                       HEX_REVENGE_TURN(caster_ptr)--;
 
-                       if (HEX_REVENGE_TURN(p_ptr) <= 0)
+                       if (HEX_REVENGE_TURN(caster_ptr) <= 0)
                        {
                                DIRECTION dir;
 
@@ -1096,9 +1100,9 @@ concptr do_hex_spell(SPELL_IDX spell, BIT_FLAGS mode)
                                                msg_print(_("復讐の時だ!", "Time to revenge!"));
                                        } while (!get_aim_dir(&dir));
 
-                                       fire_ball(GF_HELL_FIRE, dir, power, 1);
+                                       fire_ball(caster_ptr, GF_HELL_FIRE, dir, power, 1);
 
-                                       if (p_ptr->wizard)
+                                       if (current_world_ptr->wizard)
                                        {
                                                msg_format(_("%d点のダメージを返した。", "You return %d damages."), power);
                                        }
@@ -1107,7 +1111,7 @@ concptr do_hex_spell(SPELL_IDX spell, BIT_FLAGS mode)
                                {
                                        msg_print(_("復讐する気が失せた。", "You are not a mood to revenge."));
                                }
-                               HEX_REVENGE_POWER(p_ptr) = 0;
+                               HEX_REVENGE_POWER(caster_ptr) = 0;
                        }
                }
                break;
@@ -1117,16 +1121,16 @@ concptr do_hex_spell(SPELL_IDX spell, BIT_FLAGS mode)
        if ((cast) && (add))
        {
                /* add spell */
-               CASTING_HEX_FLAGS(p_ptr) |= 1L << (spell);
-               CASTING_HEX_NUM(p_ptr)++;
+               CASTING_HEX_FLAGS(caster_ptr) |= 1L << (spell);
+               CASTING_HEX_NUM(caster_ptr)++;
 
-               if (p_ptr->action != ACTION_SPELL) set_action(ACTION_SPELL);
+               if (caster_ptr->action != ACTION_SPELL) set_action(caster_ptr, ACTION_SPELL);
        }
 
        if (!info)
        {
-               p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
-               p_ptr->redraw |= (PR_EXTRA | PR_HP | PR_MANA);
+               caster_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
+               caster_ptr->redraw |= (PR_EXTRA | PR_HP | PR_MANA);
        }
 
        return "";