OSDN Git Service

[Refactor] #38997 set_oppose_elec() に player_type * 引数を追加.
[hengband/hengband.git] / src / cmd-quaff.c
index 8f2a1b8..6724e2d 100644 (file)
@@ -7,12 +7,28 @@
  */
 
 #include "angband.h"
+#include "util.h"
+
+#include "birth.h"
 #include "selfinfo.h"
 #include "object-hook.h"
 #include "mutation.h"
 #include "avatar.h"
+#include "spells.h"
 #include "spells-status.h"
+#include "player-effects.h"
+#include "player-status.h"
+#include "player-damage.h"
+#include "player-race.h"
 #include "realm-hex.h"
+#include "realm-song.h"
+#include "spells-floor.h"
+#include "object-broken.h"
+#include "cmd-basic.h"
+#include "floor.h"
+#include "objectkind.h"
+#include "view-mainwindow.h"
+#include "player-class.h"
 
 /*!
  * @brief 薬を飲むコマンドのサブルーチン /
@@ -20,7 +36,7 @@
  * @param item 飲む薬オブジェクトの所持品ID
  * @return なし
  */
-void do_cmd_quaff_potion_aux(INVENTORY_IDX item)
+void exe_quaff_potion(INVENTORY_IDX item)
 {
        bool ident;
        DEPTH lev;
@@ -28,6 +44,7 @@ void do_cmd_quaff_potion_aux(INVENTORY_IDX item)
        object_type forge;
        object_type *q_ptr;
 
+       take_turn(p_ptr, 100);
 
        if (p_ptr->timewalk)
        {
@@ -38,7 +55,7 @@ void do_cmd_quaff_potion_aux(INVENTORY_IDX item)
                return;
        }
 
-       if (music_singing_any()) stop_singing();
+       if (music_singing_any()) stop_singing(p_ptr);
        if (hex_spelling_any())
        {
                if (!hex_spelling(HEX_INHAIL)) stop_hex_spell_all();
@@ -47,23 +64,21 @@ void do_cmd_quaff_potion_aux(INVENTORY_IDX item)
        /* Get the item (in the pack) */
        if (item >= 0)
        {
-               o_ptr = &inventory[item];
+               o_ptr = &p_ptr->inventory_list[item];
        }
 
        /* Get the item (on the floor) */
        else
        {
-               o_ptr = &o_list[0 - item];
+               o_ptr = &current_floor_ptr->o_list[0 - item];
        }
        q_ptr = &forge;
-
-       /* Obtain a local object */
        object_copy(q_ptr, o_ptr);
 
        /* Single object */
        q_ptr->number = 1;
 
-       /* Reduce and describe inventory */
+       /* Reduce and describe p_ptr->inventory_list */
        if (item >= 0)
        {
                inven_item_increase(item, -1);
@@ -113,32 +128,32 @@ void do_cmd_quaff_potion_aux(INVENTORY_IDX item)
                        break;
 
                case SV_POTION_SLOWNESS:
-                       if (set_slow(randint1(25) + 15, FALSE)) ident = TRUE;
+                       if (set_slow(p_ptr, randint1(25) + 15, FALSE)) ident = TRUE;
                        break;
 
                case SV_POTION_SALT_WATER:
                        msg_print(_("うぇ!思わず吐いてしまった。", "The potion makes you vomit!"));
 
-                       if (!(prace_is_(RACE_GOLEM) ||
-                             prace_is_(RACE_ZOMBIE) ||
-                             prace_is_(RACE_DEMON) ||
-                             prace_is_(RACE_ANDROID) ||
-                             prace_is_(RACE_SPECTRE) ||
+                       if (!(PRACE_IS_(p_ptr, RACE_GOLEM) ||
+                             PRACE_IS_(p_ptr, RACE_ZOMBIE) ||
+                             PRACE_IS_(p_ptr, RACE_DEMON) ||
+                             PRACE_IS_(p_ptr, RACE_ANDROID) ||
+                             PRACE_IS_(p_ptr, RACE_SPECTRE) ||
                              (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_NONLIVING)))
                        {
                                /* Only living creatures get thirsty */
                                (void)set_food(PY_FOOD_STARVE - 1);
                        }
 
-                       (void)set_poisoned(0);
-                       (void)set_paralyzed(p_ptr->paralyzed + 4);
+                       (void)set_poisoned(p_ptr, 0);
+                       (void)set_paralyzed(p_ptr, p_ptr->paralyzed + 4);
                        ident = TRUE;
                        break;
 
                case SV_POTION_POISON:
                        if (!(p_ptr->resist_pois || IS_OPPOSE_POIS()))
                        {
-                               if (set_poisoned(p_ptr->poisoned + randint0(15) + 10))
+                               if (set_poisoned(p_ptr, p_ptr->poisoned + randint0(15) + 10))
                                {
                                        ident = TRUE;
                                }
@@ -148,7 +163,7 @@ void do_cmd_quaff_potion_aux(INVENTORY_IDX item)
                case SV_POTION_BLINDNESS:
                        if (!p_ptr->resist_blind)
                        {
-                               if (set_blind(p_ptr->blind + randint0(100) + 100))
+                               if (set_blind(p_ptr, p_ptr->blind + randint0(100) + 100))
                                {
                                        ident = TRUE;
                                }
@@ -171,7 +186,7 @@ void do_cmd_quaff_potion_aux(INVENTORY_IDX item)
                                        /* Have some nightmares */
                                        sanity_blast(NULL, FALSE);
                                }
-                               if (set_paralyzed(p_ptr->paralyzed + randint0(4) + 4))
+                               if (set_paralyzed(p_ptr, p_ptr->paralyzed + randint0(4) + 4))
                                {
                                        ident = TRUE;
                                }
@@ -193,37 +208,37 @@ void do_cmd_quaff_potion_aux(INVENTORY_IDX item)
                        msg_print(_("身も心も弱ってきて、精気が抜けていくようだ。", "Your nerves and muscles feel weak and lifeless!"));
                        take_hit(DAMAGE_LOSELIFE, damroll(10, 10), _("破滅の薬", "a potion of Ruination"), -1);
 
-                       (void)dec_stat(A_DEX, 25, TRUE);
-                       (void)dec_stat(A_WIS, 25, TRUE);
-                       (void)dec_stat(A_CON, 25, TRUE);
-                       (void)dec_stat(A_STR, 25, TRUE);
-                       (void)dec_stat(A_CHR, 25, TRUE);
-                       (void)dec_stat(A_INT, 25, TRUE);
+                       (void)dec_stat(p_ptr, A_DEX, 25, TRUE);
+                       (void)dec_stat(p_ptr, A_WIS, 25, TRUE);
+                       (void)dec_stat(p_ptr, A_CON, 25, TRUE);
+                       (void)dec_stat(p_ptr, A_STR, 25, TRUE);
+                       (void)dec_stat(p_ptr, A_CHR, 25, TRUE);
+                       (void)dec_stat(p_ptr, A_INT, 25, TRUE);
                        ident = TRUE;
                        break;
 
                case SV_POTION_DEC_STR:
-                       if (do_dec_stat(A_STR)) ident = TRUE;
+                       if (do_dec_stat(p_ptr, A_STR)) ident = TRUE;
                        break;
 
                case SV_POTION_DEC_INT:
-                       if (do_dec_stat(A_INT)) ident = TRUE;
+                       if (do_dec_stat(p_ptr, A_INT)) ident = TRUE;
                        break;
 
                case SV_POTION_DEC_WIS:
-                       if (do_dec_stat(A_WIS)) ident = TRUE;
+                       if (do_dec_stat(p_ptr, A_WIS)) ident = TRUE;
                        break;
 
                case SV_POTION_DEC_DEX:
-                       if (do_dec_stat(A_DEX)) ident = TRUE;
+                       if (do_dec_stat(p_ptr, A_DEX)) ident = TRUE;
                        break;
 
                case SV_POTION_DEC_CON:
-                       if (do_dec_stat(A_CON)) ident = TRUE;
+                       if (do_dec_stat(p_ptr, A_CON)) ident = TRUE;
                        break;
 
                case SV_POTION_DEC_CHR:
-                       if (do_dec_stat(A_CHR)) ident = TRUE;
+                       if (do_dec_stat(p_ptr, A_CHR)) ident = TRUE;
                        break;
 
                case SV_POTION_DETONATIONS:
@@ -239,39 +254,39 @@ void do_cmd_quaff_potion_aux(INVENTORY_IDX item)
                        break;
 
                case SV_POTION_INFRAVISION:
-                       if (set_tim_infra(p_ptr->tim_infra + 100 + randint1(100), FALSE))
+                       if (set_tim_infra(p_ptr, p_ptr->tim_infra + 100 + randint1(100), FALSE))
                        {
                                ident = TRUE;
                        }
                        break;
 
                case SV_POTION_DETECT_INVIS:
-                       if (set_tim_invis(p_ptr->tim_invis + 12 + randint1(12), FALSE))
+                       if (set_tim_invis(p_ptr, p_ptr->tim_invis + 12 + randint1(12), FALSE))
                        {
                                ident = TRUE;
                        }
                        break;
 
                case SV_POTION_SLOW_POISON:
-                       if (set_poisoned(p_ptr->poisoned / 2)) ident = TRUE;
+                       if (set_poisoned(p_ptr, p_ptr->poisoned / 2)) ident = TRUE;
                        break;
 
                case SV_POTION_CURE_POISON:
-                       if (set_poisoned(0)) ident = TRUE;
+                       if (set_poisoned(p_ptr, 0)) ident = TRUE;
                        break;
 
                case SV_POTION_BOLDNESS:
-                       if (set_afraid(0)) ident = TRUE;
+                       if (set_afraid(p_ptr, 0)) ident = TRUE;
                        break;
 
                case SV_POTION_SPEED:
                        if (!p_ptr->fast)
                        {
-                               if (set_fast(randint1(25) + 15, FALSE)) ident = TRUE;
+                               if (set_fast(p_ptr, randint1(25) + 15, FALSE)) ident = TRUE;
                        }
                        else
                        {
-                               (void)set_fast(p_ptr->fast + 5, FALSE);
+                               (void)set_fast(p_ptr, p_ptr->fast + 5, FALSE);
                        }
                        break;
 
@@ -330,27 +345,27 @@ void do_cmd_quaff_potion_aux(INVENTORY_IDX item)
                        break;
 
                case SV_POTION_RES_STR:
-                       if (do_res_stat(A_STR)) ident = TRUE;
+                       if (do_res_stat(p_ptr, A_STR)) ident = TRUE;
                        break;
 
                case SV_POTION_RES_INT:
-                       if (do_res_stat(A_INT)) ident = TRUE;
+                       if (do_res_stat(p_ptr, A_INT)) ident = TRUE;
                        break;
 
                case SV_POTION_RES_WIS:
-                       if (do_res_stat(A_WIS)) ident = TRUE;
+                       if (do_res_stat(p_ptr, A_WIS)) ident = TRUE;
                        break;
 
                case SV_POTION_RES_DEX:
-                       if (do_res_stat(A_DEX)) ident = TRUE;
+                       if (do_res_stat(p_ptr, A_DEX)) ident = TRUE;
                        break;
 
                case SV_POTION_RES_CON:
-                       if (do_res_stat(A_CON)) ident = TRUE;
+                       if (do_res_stat(p_ptr, A_CON)) ident = TRUE;
                        break;
 
                case SV_POTION_RES_CHR:
-                       if (do_res_stat(A_CHR)) ident = TRUE;
+                       if (do_res_stat(p_ptr, A_CHR)) ident = TRUE;
                        break;
 
                case SV_POTION_INC_STR:
@@ -425,7 +440,7 @@ void do_cmd_quaff_potion_aux(INVENTORY_IDX item)
                        chg_virtue(V_ENLIGHTEN, 1);
                        if (p_ptr->exp < PY_MAX_EXP)
                        {
-                               s32b ee = (p_ptr->exp / 2) + 10;
+                               EXP ee = (p_ptr->exp / 2) + 10;
                                if (ee > 100000L) ee = 100000L;
                                msg_print(_("更に経験を積んだような気がする。", "You feel more experienced."));
                                gain_exp(ee);
@@ -434,8 +449,8 @@ void do_cmd_quaff_potion_aux(INVENTORY_IDX item)
                        break;
 
                case SV_POTION_RESISTANCE:
-                       (void)set_oppose_acid(p_ptr->oppose_acid + randint1(20) + 20, FALSE);
-                       (void)set_oppose_elec(p_ptr->oppose_elec + randint1(20) + 20, FALSE);
+                       (void)set_oppose_acid(p_ptr, p_ptr->oppose_acid + randint1(20) + 20, FALSE);
+                       (void)set_oppose_elec(p_ptr, p_ptr->oppose_elec + randint1(20) + 20, FALSE);
                        (void)set_oppose_fire(p_ptr->oppose_fire + randint1(20) + 20, FALSE);
                        (void)set_oppose_cold(p_ptr->oppose_cold + randint1(20) + 20, FALSE);
                        (void)set_oppose_pois(p_ptr->oppose_pois + randint1(20) + 20, FALSE);
@@ -447,7 +462,7 @@ void do_cmd_quaff_potion_aux(INVENTORY_IDX item)
                        break;
 
                case SV_POTION_INVULNERABILITY:
-                       (void)set_invuln(p_ptr->invuln + randint1(4) + 4, FALSE);
+                       (void)set_invuln(p_ptr, p_ptr->invuln + randint1(4) + 4, FALSE);
                        ident = TRUE;
                        break;
 
@@ -460,8 +475,8 @@ void do_cmd_quaff_potion_aux(INVENTORY_IDX item)
                        break;
 
                case SV_POTION_NEO_TSUYOSHI:
-                       (void)set_image(0);
-                       (void)set_tsuyoshi(p_ptr->tsuyoshi + randint1(100) + 100, FALSE);
+                       (void)set_image(p_ptr, 0);
+                       (void)set_tsuyoshi(p_ptr, p_ptr->tsuyoshi + randint1(100) + 100, FALSE);
                        ident = TRUE;
                        break;
 
@@ -469,10 +484,10 @@ void do_cmd_quaff_potion_aux(INVENTORY_IDX item)
                        msg_print(_("「オクレ兄さん!」", "Brother OKURE!"));
                        msg_print(NULL);
                        p_ptr->tsuyoshi = 1;
-                       (void)set_tsuyoshi(0, TRUE);
+                       (void)set_tsuyoshi(p_ptr, 0, TRUE);
                        if (!p_ptr->resist_chaos)
                        {
-                               (void)set_image(50 + randint1(50));
+                               (void)set_image(p_ptr, 50 + randint1(50));
                        }
                        ident = TRUE;
                        break;
@@ -488,7 +503,7 @@ void do_cmd_quaff_potion_aux(INVENTORY_IDX item)
                                {
                                        if (one_in_(2))
                                        {
-                                               if(gain_random_mutation(0)) ident = TRUE;
+                                               if(gain_mutation(p_ptr, 0)) ident = TRUE;
                                        }
                                        else if (lose_mutation(0)) ident = TRUE;
                                } while(!ident || one_in_(2));
@@ -497,7 +512,7 @@ void do_cmd_quaff_potion_aux(INVENTORY_IDX item)
                }
        }
 
-       if (prace_is_(RACE_SKELETON))
+       if (PRACE_IS_(p_ptr, RACE_SKELETON))
        {
                msg_print(_("液体の一部はあなたのアゴを素通りして落ちた!", "Some of the fluid falls through your jaws!"));
                (void)potion_smash_effect(0, p_ptr->y, p_ptr->x, q_ptr->k_idx);
@@ -604,8 +619,8 @@ void do_cmd_quaff_potion(void)
        q = _("どの薬を飲みますか? ", "Quaff which potion? ");
        s = _("飲める薬がない。", "You have no potions to quaff.");
 
-       if (!choose_object(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
+       if (!choose_object(&item, q, s, (USE_INVEN | USE_FLOOR), 0)) return;
 
        /* Quaff the potion */
-       do_cmd_quaff_potion_aux(item);
+       exe_quaff_potion(item);
 }