OSDN Git Service

[Refactor] #37353 MP回復系の効果をrestore_mana()にまとめる。
[hengband/hengband.git] / src / cmd-activate.c
index fd3da35..655ca14 100644 (file)
@@ -8,6 +8,7 @@
 
 #include "angband.h"
 #include "cmd-activate.h"
+#include "object-hook.h"
 
 /*!
 * @brief ペット入りモンスターボールをソートするための比較関数
@@ -47,28 +48,6 @@ static bool ang_sort_comp_pet(vptr u, vptr v, int a, int b)
        return w1 <= w2;
 }
 
-/*!
-* @brief オブジェクトをプレイヤーが魔道具として発動できるかを判定する /
-* Hook to determine if an object is activatable
-* @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
-* @return 魔道具として発動可能ならばTRUEを返す
-*/
-static bool item_tester_hook_activate(object_type *o_ptr)
-{
-       u32b flgs[TR_FLAG_SIZE];
-
-       /* Not known */
-       if (!object_is_known(o_ptr)) return (FALSE);
-
-       /* Extract the flags */
-       object_flags(o_ptr, flgs);
-
-       /* Check activation flag */
-       if (have_flag(flgs, TR_ACTIVATE)) return (TRUE);
-
-       /* Assume not */
-       return (FALSE);
-}
 
 /*!
  * @brief 装備を発動するコマンドのサブルーチン /
@@ -1106,14 +1085,8 @@ bool activate_artifact(object_type *o_ptr)
        case ACT_CHOIR_SINGS:
        {
                msg_print(_("天国の歌が聞こえる...", "A heavenly choir sings..."));
-               (void)set_poisoned(0);
-               (void)set_cut(0);
-               (void)set_stun(0);
-               (void)set_confused(0);
-               (void)set_blind(0);
-               (void)set_afraid(0);
+               (void)cure_critical_wounds(777);
                (void)set_hero(randint1(25) + 25, FALSE);
-               (void)hp_player(777);
                break;
        }
 
@@ -1127,8 +1100,7 @@ bool activate_artifact(object_type *o_ptr)
        case ACT_CURE_MW:
        {
                msg_print(_("深紫色の光を発している...", "It radiates deep purple..."));
-               hp_player(damroll(4, 8));
-               (void)set_cut((p_ptr->cut / 2) - 50);
+               (void)cure_serious_wounds(4, 8);
                break;
        }
 
@@ -1164,8 +1136,7 @@ bool activate_artifact(object_type *o_ptr)
        {
                msg_print(_("深青色に輝いている...", "It glows deep blue..."));
                msg_print(_("体内に暖かい鼓動が感じられる...", "You feel a warm tingling inside..."));
-               (void)hp_player(700);
-               (void)set_cut(0);
+               (void)cure_critical_wounds(700);
                break;
        }
 
@@ -1173,8 +1144,7 @@ bool activate_artifact(object_type *o_ptr)
        {
                msg_print(_("白く明るく輝いている...", "It glows a bright white..."));
                msg_print(_("ひじょうに気分がよい...", "You feel much better..."));
-               (void)hp_player(1000);
-               (void)set_cut(0);
+               (void)cure_critical_wounds(1000);
                break;
        }
 
@@ -1194,32 +1164,7 @@ bool activate_artifact(object_type *o_ptr)
        case ACT_CURE_MANA_FULL:
        {
                msg_format(_("%sが青白く光った...", "The %s glows pale..."), name);
-               if (p_ptr->pclass == CLASS_MAGIC_EATER)
-               {
-                       int i;
-                       for (i = 0; i < EATER_EXT * 2; i++)
-                       {
-                               p_ptr->magic_num1[i] += (p_ptr->magic_num2[i] < 10) ? EATER_CHARGE * 3 : p_ptr->magic_num2[i] * EATER_CHARGE / 3;
-                               if (p_ptr->magic_num1[i] > p_ptr->magic_num2[i] * EATER_CHARGE) p_ptr->magic_num1[i] = p_ptr->magic_num2[i] * EATER_CHARGE;
-                       }
-                       for (; i < EATER_EXT * 3; i++)
-                       {
-                               KIND_OBJECT_IDX k_idx = lookup_kind(TV_ROD, i - EATER_EXT * 2);
-                               p_ptr->magic_num1[i] -= ((p_ptr->magic_num2[i] < 10) ? EATER_ROD_CHARGE * 3 : p_ptr->magic_num2[i] * EATER_ROD_CHARGE / 3)*k_info[k_idx].pval;
-                               if (p_ptr->magic_num1[i] < 0) p_ptr->magic_num1[i] = 0;
-                       }
-                       msg_print(_("頭がハッキリとした。", "You feel your head clear."));
-                       p_ptr->window |= (PW_PLAYER);
-               }
-               else if (p_ptr->csp < p_ptr->msp)
-               {
-                       p_ptr->csp = p_ptr->msp;
-                       p_ptr->csp_frac = 0;
-                       msg_print(_("頭がハッキリとした。", "You feel your head clear."));
-                       p_ptr->redraw |= (PR_MANA);
-                       p_ptr->window |= (PW_PLAYER);
-                       p_ptr->window |= (PW_SPELL);
-               }
+               restore_mana(TRUE);
                break;
        }
 
@@ -1287,20 +1232,16 @@ bool activate_artifact(object_type *o_ptr)
                break;
        }
 
-       case ACT_HELO:
+       case ACT_HERO:
        {
-               (void)set_afraid(0);
-               set_hero(randint1(25) + 25, FALSE);
-               hp_player(10);
+               (void)heroism(25);
                break;
        }
 
-       case ACT_HELO_SPEED:
+       case ACT_HERO_SPEED:
        {
                (void)set_fast(randint1(50) + 50, FALSE);
-               hp_player(10);
-               set_afraid(0);
-               set_hero(randint1(50) + 50, FALSE);
+               (void)heroism(50);
                break;
        }