OSDN Git Service

[Refactor] #38997 choose_object() に player_type * 引数を追加し宣言を player-inventory.h に移動.
[hengband/hengband.git] / src / cmd-zaprod.c
index 96f9527..f8fc2a3 100644 (file)
@@ -5,6 +5,7 @@
 #include "player-status.h"
 #include "player-effects.h"
 #include "player-class.h"
+#include "player-inventory.h"
 #include "objectkind.h"
 #include "object-hook.h"
 #include "spells.h"
  * @param magic 魔道具術上の処理ならばTRUE
  * @return 発動により効果内容が確定したならばTRUEを返す
  */
-int rod_effect(OBJECT_SUBTYPE_VALUE sval, DIRECTION dir, bool *use_charge, bool powerful, bool magic)
+int rod_effect(player_type *creature_ptr, OBJECT_SUBTYPE_VALUE sval, DIRECTION dir, bool *use_charge, bool powerful, bool magic)
 {
        int ident = FALSE;
-       PLAYER_LEVEL lev = powerful ? p_ptr->lev * 2 : p_ptr->lev;
+       PLAYER_LEVEL lev = powerful ? creature_ptr->lev * 2 : creature_ptr->lev;
        POSITION detect_rad = powerful ? DETECT_RAD_DEFAULT * 3 / 2 : DETECT_RAD_DEFAULT;
        POSITION rad = powerful ? 3 : 2;
 
@@ -64,7 +65,7 @@ int rod_effect(OBJECT_SUBTYPE_VALUE sval, DIRECTION dir, bool *use_charge, bool
 
        case SV_ROD_RECALL:
        {
-               if (!recall_player(p_ptr, randint0(21) + 15)) *use_charge = FALSE;
+               if (!recall_player(creature_ptr, randint0(21) + 15)) *use_charge = FALSE;
                ident = TRUE;
                break;
        }
@@ -99,7 +100,7 @@ int rod_effect(OBJECT_SUBTYPE_VALUE sval, DIRECTION dir, bool *use_charge, bool
        case SV_ROD_CURING:
        {
                if (true_healing(0)) ident = TRUE;
-               if (set_shero(p_ptr, 0, TRUE)) ident = TRUE;
+               if (set_shero(creature_ptr, 0, TRUE)) ident = TRUE;
                break;
        }
 
@@ -111,14 +112,14 @@ int rod_effect(OBJECT_SUBTYPE_VALUE sval, DIRECTION dir, bool *use_charge, bool
 
        case SV_ROD_RESTORATION:
        {
-               if(restore_level(p_ptr)) ident = TRUE;
+               if(restore_level(creature_ptr)) ident = TRUE;
                if(restore_all_status()) ident = TRUE;
                break;
        }
 
        case SV_ROD_SPEED:
        {
-               if (set_fast(p_ptr, randint1(30) + (powerful ? 30 : 15), FALSE)) ident = TRUE;
+               if (set_fast(creature_ptr, randint1(30) + (powerful ? 30 : 15), FALSE)) ident = TRUE;
                break;
        }
 
@@ -268,7 +269,7 @@ int rod_effect(OBJECT_SUBTYPE_VALUE sval, DIRECTION dir, bool *use_charge, bool
 * pvals are defined for each rod in k_info. -LM-
 * </pre>
 */
-void exe_zap_rod(INVENTORY_IDX item)
+void exe_zap_rod(player_type *creature_ptr, INVENTORY_IDX item)
 {
        int ident, chance, lev, fail;
        DIRECTION dir = 0;
@@ -280,7 +281,7 @@ void exe_zap_rod(INVENTORY_IDX item)
 
        object_kind *k_ptr;
 
-       o_ptr = REF_ITEM(p_ptr, current_floor_ptr, item);
+       o_ptr = REF_ITEM(creature_ptr, current_floor_ptr, item);
 
        /* Mega-Hack -- refuse to zap a pile from the ground */
        if ((item < 0) && (o_ptr->number > 1))
@@ -299,15 +300,15 @@ void exe_zap_rod(INVENTORY_IDX item)
        }
 
 
-       take_turn(p_ptr, 100);
+       take_turn(creature_ptr, 100);
 
        lev = k_info[o_ptr->k_idx].level;
 
        /* Base chance of success */
-       chance = p_ptr->skill_dev;
+       chance = creature_ptr->skill_dev;
 
        /* Confusion hurts skill */
-       if (p_ptr->confused) chance = chance / 2;
+       if (creature_ptr->confused) chance = chance / 2;
 
        fail = lev + 5;
        if (chance > fail) fail -= (chance - fail) * 2;
@@ -315,9 +316,9 @@ void exe_zap_rod(INVENTORY_IDX item)
        if (fail < USE_DEVICE) fail = USE_DEVICE;
        if (chance < USE_DEVICE) chance = USE_DEVICE;
 
-       if (cmd_limit_time_walk(p_ptr)) return;
+       if (cmd_limit_time_walk(creature_ptr)) return;
 
-       if (p_ptr->pclass == CLASS_BERSERKER) success = FALSE;
+       if (creature_ptr->pclass == CLASS_BERSERKER) success = FALSE;
        else if (chance > fail)
        {
                if (randint0(chance * 2) < fail) success = FALSE;
@@ -357,17 +358,17 @@ void exe_zap_rod(INVENTORY_IDX item)
 
        sound(SOUND_ZAP);
 
-       ident = rod_effect(o_ptr->sval, dir, &use_charge, FALSE, FALSE);
+       ident = rod_effect(creature_ptr, o_ptr->sval, dir, &use_charge, FALSE, FALSE);
 
        /* Increase the timeout by the rod kind's pval. -LM- */
        if (use_charge) o_ptr->timeout += k_ptr->pval;
-       p_ptr->update |= (PU_COMBINE | PU_REORDER);
+       creature_ptr->update |= (PU_COMBINE | PU_REORDER);
 
        if (!(object_is_aware(o_ptr)))
        {
-               chg_virtue(p_ptr, V_PATIENCE, -1);
-               chg_virtue(p_ptr, V_CHANCE, 1);
-               chg_virtue(p_ptr, V_KNOWLEDGE, -1);
+               chg_virtue(creature_ptr, V_PATIENCE, -1);
+               chg_virtue(creature_ptr, V_CHANCE, 1);
+               chg_virtue(creature_ptr, V_KNOWLEDGE, -1);
        }
 
        /* Tried the object */
@@ -377,38 +378,38 @@ void exe_zap_rod(INVENTORY_IDX item)
        if (ident && !object_is_aware(o_ptr))
        {
                object_aware(o_ptr);
-               gain_exp(p_ptr, (lev + (p_ptr->lev >> 1)) / p_ptr->lev);
+               gain_exp(creature_ptr, (lev + (creature_ptr->lev >> 1)) / creature_ptr->lev);
        }
 
-       p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
+       creature_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
 }
 
 /*!
 * @brief ロッドを使うコマンドのメインルーチン /
 * @return なし
 */
-void do_cmd_zap_rod(void)
+void do_cmd_zap_rod(player_type *creature_ptr)
 {
        OBJECT_IDX item;
        concptr q, s;
 
-       if (p_ptr->wild_mode)
+       if (creature_ptr->wild_mode)
        {
                return;
        }
 
-       if (cmd_limit_arena(p_ptr)) return;
+       if (cmd_limit_arena(creature_ptr)) return;
 
-       if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
+       if (creature_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
        {
-               set_action(p_ptr, ACTION_NONE);
+               set_action(creature_ptr, ACTION_NONE);
        }
 
        q = _("どのロッドを振りますか? ", "Zap which rod? ");
        s = _("使えるロッドがない。", "You have no rod to zap.");
 
-       if (!choose_object(&item, q, s, (USE_INVEN | USE_FLOOR), TV_ROD)) return;
+       if (!choose_object(p_ptr, &item, q, s, (USE_INVEN | USE_FLOOR), TV_ROD)) return;
 
        /* Zap the rod */
-       exe_zap_rod(item);
+       exe_zap_rod(creature_ptr, item);
 }