OSDN Git Service

[Refactor] #38997 set_oppose_cold() に player_type * 引数を追加.
[hengband/hengband.git] / src / cmd-activate.c
index 4cdf912..e84a003 100644 (file)
@@ -345,7 +345,7 @@ const activation_type activation_info[] =
  * the user hits "escape" at the "direction" prompt.
  * </pre>
  */
-void do_cmd_activate_aux(INVENTORY_IDX item)
+void exe_activate(player_type *user_ptr, INVENTORY_IDX item)
 {
        DIRECTION dir;
        DEPTH lev;
@@ -353,11 +353,10 @@ void do_cmd_activate_aux(INVENTORY_IDX item)
        object_type *o_ptr;
        bool success;
 
-
        /* Get the item (in the pack) */
        if (item >= 0)
        {
-               o_ptr = &p_ptr->inventory_list[item];
+               o_ptr = &user_ptr->inventory_list[item];
        }
 
        /* Get the item (on the floor) */
@@ -366,9 +365,8 @@ void do_cmd_activate_aux(INVENTORY_IDX item)
                o_ptr = &current_floor_ptr->o_list[0 - item];
        }
 
-       take_turn(p_ptr, 100);
+       take_turn(user_ptr, 100);
 
-       /* Extract the item level */
        lev = k_info[o_ptr->k_idx].level;
 
        /* Hack -- use artifact level instead */
@@ -383,10 +381,10 @@ void do_cmd_activate_aux(INVENTORY_IDX item)
        else if (((o_ptr->tval == TV_RING) || (o_ptr->tval == TV_AMULET)) && o_ptr->name2) lev = e_info[o_ptr->name2].level;
 
        /* Base chance of success */
-       chance = p_ptr->skill_dev;
+       chance = user_ptr->skill_dev;
 
        /* Confusion hurts skill */
-       if (p_ptr->confused) chance = chance / 2;
+       if (user_ptr->confused) chance = chance / 2;
 
        fail = lev+5;
        if (chance > fail) fail -= (chance - fail)*2;
@@ -394,9 +392,9 @@ void do_cmd_activate_aux(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(user_ptr)) return;
 
-       if (p_ptr->pclass == CLASS_BERSERKER) success = FALSE;
+       if (user_ptr->pclass == CLASS_BERSERKER) success = FALSE;
        else if (chance > fail)
        {
                if (randint0(chance*2) < fail) success = FALSE;
@@ -429,7 +427,7 @@ void do_cmd_activate_aux(INVENTORY_IDX item)
                ((o_ptr->sval == SV_LITE_TORCH) || (o_ptr->sval == SV_LITE_LANTERN)))
        {
                msg_print(_("燃料がない。", "It has no fuel."));
-               free_turn(p_ptr);
+               free_turn(user_ptr);
                return;
        }
 
@@ -443,7 +441,7 @@ void do_cmd_activate_aux(INVENTORY_IDX item)
        {
                (void)activate_artifact(o_ptr);
 
-               p_ptr->window |= (PW_INVEN | PW_EQUIP);
+               user_ptr->window |= (PW_INVEN | PW_EQUIP);
 
                /* Success */
                return;
@@ -452,7 +450,7 @@ void do_cmd_activate_aux(INVENTORY_IDX item)
        /* Special items */
        else if (o_ptr->tval == TV_WHISTLE)
        {
-               if (music_singing_any()) stop_singing(p_ptr);
+               if (music_singing_any()) stop_singing(user_ptr);
                if (hex_spelling_any()) stop_hex_spell_all();
 
                {
@@ -467,7 +465,7 @@ void do_cmd_activate_aux(INVENTORY_IDX item)
                        /* Process the monsters (backwards) */
                        for (pet_ctr = current_floor_ptr->m_max - 1; pet_ctr >= 1; pet_ctr--)
                        {
-                               if (is_pet(&current_floor_ptr->m_list[pet_ctr]) && (p_ptr->riding != pet_ctr))
+                               if (is_pet(&current_floor_ptr->m_list[pet_ctr]) && (user_ptr->riding != pet_ctr))
                                  who[max_pet++] = pet_ctr;
                        }
 
@@ -477,11 +475,11 @@ void do_cmd_activate_aux(INVENTORY_IDX item)
                        for (i = 0; i < max_pet; i++)
                        {
                                pet_ctr = who[i];
-                               teleport_monster_to(pet_ctr, p_ptr->y, p_ptr->x, 100, TELEPORT_PASSIVE);
+                               teleport_monster_to(pet_ctr, user_ptr->y, user_ptr->x, 100, TELEPORT_PASSIVE);
                        }
 
                        /* Free the "who" array */
-                       C_KILL(who, current_floor_ptr->max_m_idx, IDX);
+                       C_KILL(who, current_floor_ptr->max_m_idx, MONSTER_IDX);
                }
                o_ptr->timeout = 100 + randint1(100);
                return;
@@ -548,9 +546,9 @@ void do_cmd_activate_aux(INVENTORY_IDX item)
                {
                        success = FALSE;
                        if (!get_direction(&dir, FALSE, FALSE)) return;
-                       if (monster_can_enter(p_ptr->y + ddy[dir], p_ptr->x + ddx[dir], &r_info[o_ptr->pval], 0))
+                       if (monster_can_enter(user_ptr->y + ddy[dir], user_ptr->x + ddx[dir], &r_info[o_ptr->pval], 0))
                        {
-                               if (place_monster_aux(0, p_ptr->y + ddy[dir], p_ptr->x + ddx[dir], o_ptr->pval, (PM_FORCE_PET | PM_NO_KAGE)))
+                               if (place_monster_aux(0, user_ptr->y + ddy[dir], user_ptr->x + ddx[dir], o_ptr->pval, (PM_FORCE_PET | PM_NO_KAGE)))
                                {
                                        if (o_ptr->xtra3) current_floor_ptr->m_list[hack_m_idx_ii].mspeed = o_ptr->xtra3;
                                        if (o_ptr->xtra5) current_floor_ptr->m_list[hack_m_idx_ii].max_maxhp = o_ptr->xtra5;
@@ -632,15 +630,15 @@ void do_cmd_activate_aux(INVENTORY_IDX item)
  * @brief 装備を発動するコマンドのメインルーチン /
  * @return なし
  */
-void do_cmd_activate(void)
+void do_cmd_activate(player_type *user_ptr)
 {
        OBJECT_IDX item;
        concptr q, s;
 
-       if (p_ptr->wild_mode) return;
-       if (cmd_limit_arena(p_ptr)) return;
+       if (user_ptr->wild_mode) return;
+       if (cmd_limit_arena(user_ptr)) return;
 
-       if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
+       if (user_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
        {
                set_action(ACTION_NONE);
        }
@@ -653,7 +651,7 @@ void do_cmd_activate(void)
        if (!choose_object(&item, q, s, (USE_EQUIP | IGNORE_BOTHHAND_SLOT), 0)) return;
 
        /* Activate the item */
-       do_cmd_activate_aux(item);
+       exe_activate(user_ptr, item);
 }
 
 /*!
@@ -883,7 +881,7 @@ bool activate_artifact(object_type *o_ptr)
                for (dummy = 0; dummy < 3; dummy++)
                {
                        if (hypodynamic_bolt(dir, 50))
-                               hp_player(50);
+                               hp_player(p_ptr, 50);
                }
                break;
        }
@@ -908,7 +906,7 @@ bool activate_artifact(object_type *o_ptr)
                for (dummy = 0; dummy < 3; dummy++)
                {
                        if (hypodynamic_bolt(dir, 100))
-                               hp_player(100);
+                               hp_player(p_ptr, 100);
                }
                break;
        }
@@ -1036,14 +1034,14 @@ bool activate_artifact(object_type *o_ptr)
                msg_print(_("あなたはエレメントのブレスを吐いた。", "You breathe the elements."));
                fire_breath(GF_MISSILE, dir, 300, 4);
                msg_print(_("鎧が様々な色に輝いた...", "Your armor glows many colours..."));
-               (void)set_afraid(0);
-               (void)set_hero(randint1(50) + 50, FALSE);
-               (void)hp_player(10);
-               (void)set_blessed(randint1(50) + 50, FALSE);
-               (void)set_oppose_acid(randint1(50) + 50, FALSE);
-               (void)set_oppose_elec(randint1(50) + 50, FALSE);
-               (void)set_oppose_fire(randint1(50) + 50, FALSE);
-               (void)set_oppose_cold(randint1(50) + 50, FALSE);
+               (void)set_afraid(p_ptr, 0);
+               (void)set_hero(p_ptr, randint1(50) + 50, FALSE);
+               (void)hp_player(p_ptr, 10);
+               (void)set_blessed(p_ptr, randint1(50) + 50, FALSE);
+               (void)set_oppose_acid(p_ptr, randint1(50) + 50, FALSE);
+               (void)set_oppose_elec(p_ptr, randint1(50) + 50, FALSE);
+               (void)set_oppose_fire(p_ptr, randint1(50) + 50, FALSE);
+               (void)set_oppose_cold(p_ptr, randint1(50) + 50, FALSE);
                (void)set_oppose_pois(randint1(50) + 50, FALSE);
                break;
        }
@@ -1054,7 +1052,7 @@ bool activate_artifact(object_type *o_ptr)
                fire_breath(GF_FIRE, dir, 200, 2);
                if ((o_ptr->tval == TV_RING) && (o_ptr->sval == SV_RING_FLAMES))
                {
-                       (void)set_oppose_fire(randint1(20) + 20, FALSE);
+                       (void)set_oppose_fire(p_ptr, randint1(20) + 20, FALSE);
                }
                break;
        }
@@ -1065,7 +1063,7 @@ bool activate_artifact(object_type *o_ptr)
                fire_breath(GF_COLD, dir, 200, 2);
                if ((o_ptr->tval == TV_RING) && (o_ptr->sval == SV_RING_ICE))
                {
-                       (void)set_oppose_cold(randint1(20) + 20, FALSE);
+                       (void)set_oppose_cold(p_ptr, randint1(20) + 20, FALSE);
                }
                break;
        }
@@ -1241,14 +1239,14 @@ bool activate_artifact(object_type *o_ptr)
        {
                msg_print(_("天国の歌が聞こえる...", "A heavenly choir sings..."));
                (void)cure_critical_wounds(777);
-               (void)set_hero(randint1(25) + 25, FALSE);
+               (void)set_hero(p_ptr, randint1(25) + 25, FALSE);
                break;
        }
 
        case ACT_CURE_LW:
        {
-               (void)set_afraid(0);
-               (void)hp_player(30);
+               (void)set_afraid(p_ptr, 0);
+               (void)hp_player(p_ptr, 30);
                break;
        }
 
@@ -1262,8 +1260,8 @@ bool activate_artifact(object_type *o_ptr)
        case ACT_CURE_POISON:
        {
                msg_print(_("深青色に輝いている...", "It glows deep blue..."));
-               (void)set_afraid(0);
-               (void)set_poisoned(0);
+               (void)set_afraid(p_ptr, 0);
+               (void)set_poisoned(p_ptr, 0);
                break;
        }
 
@@ -1330,17 +1328,17 @@ bool activate_artifact(object_type *o_ptr)
        {
                msg_format(_("%sから鋭い音が流れ出た...", "The %s lets out a shrill wail..."), name);
                k = 3 * p_ptr->lev;
-               (void)set_protevil(randint1(25) + k, FALSE);
+               (void)set_protevil(p_ptr, randint1(25) + k, FALSE);
                break;
        }
 
        case ACT_RESIST_ALL:
        {
                msg_print(_("様々な色に輝いている...", "It glows many colours..."));
-               (void)set_oppose_acid(randint1(40) + 40, FALSE);
-               (void)set_oppose_elec(randint1(40) + 40, FALSE);
-               (void)set_oppose_fire(randint1(40) + 40, FALSE);
-               (void)set_oppose_cold(randint1(40) + 40, FALSE);
+               (void)set_oppose_acid(p_ptr, randint1(40) + 40, FALSE);
+               (void)set_oppose_elec(p_ptr, randint1(40) + 40, FALSE);
+               (void)set_oppose_fire(p_ptr, randint1(40) + 40, FALSE);
+               (void)set_oppose_cold(p_ptr, randint1(40) + 40, FALSE);
                (void)set_oppose_pois(randint1(40) + 40, FALSE);
                break;
        }
@@ -1348,14 +1346,14 @@ bool activate_artifact(object_type *o_ptr)
        case ACT_SPEED:
        {
                msg_print(_("明るく緑色に輝いている...", "It glows bright green..."));
-               (void)set_fast(randint1(20) + 20, FALSE);
+               (void)set_fast(p_ptr, randint1(20) + 20, FALSE);
                break;
        }
 
        case ACT_XTRA_SPEED:
        {
                msg_print(_("明るく輝いている...", "It glows brightly..."));
-               (void)set_fast(randint1(75) + 75, FALSE);
+               (void)set_fast(p_ptr, randint1(75) + 75, FALSE);
                break;
        }
 
@@ -1367,7 +1365,7 @@ bool activate_artifact(object_type *o_ptr)
 
        case ACT_INVULN:
        {
-               (void)set_invuln(randint1(8) + 8, FALSE);
+               (void)set_invuln(p_ptr, randint1(8) + 8, FALSE);
                break;
        }
 
@@ -1379,7 +1377,7 @@ bool activate_artifact(object_type *o_ptr)
 
        case ACT_HERO_SPEED:
        {
-               (void)set_fast(randint1(50) + 50, FALSE);
+               (void)set_fast(p_ptr, randint1(50) + 50, FALSE);
                (void)heroism(50);
                break;
        }
@@ -1392,7 +1390,7 @@ bool activate_artifact(object_type *o_ptr)
                        if (!get_aim_dir(&dir)) return FALSE;
                        fire_ball(GF_ACID, dir, 100, 2);
                }
-               (void)set_oppose_acid(randint1(20) + 20, FALSE);
+               (void)set_oppose_acid(p_ptr, randint1(20) + 20, FALSE);
                break;
        }
 
@@ -1404,7 +1402,7 @@ bool activate_artifact(object_type *o_ptr)
                        if (!get_aim_dir(&dir)) return FALSE;
                        fire_ball(GF_FIRE, dir, 100, 2);
                }
-               (void)set_oppose_fire(randint1(20) + 20, FALSE);
+               (void)set_oppose_fire(p_ptr, randint1(20) + 20, FALSE);
                break;
        }
 
@@ -1416,7 +1414,7 @@ bool activate_artifact(object_type *o_ptr)
                        if (!get_aim_dir(&dir)) return FALSE;
                        fire_ball(GF_COLD, dir, 100, 2);
                }
-               (void)set_oppose_cold(randint1(20) + 20, FALSE);
+               (void)set_oppose_cold(p_ptr, randint1(20) + 20, FALSE);
                break;
        }
 
@@ -1428,7 +1426,7 @@ bool activate_artifact(object_type *o_ptr)
                        if (!get_aim_dir(&dir)) return FALSE;
                        fire_ball(GF_ELEC, dir, 100, 2);
                }
-               (void)set_oppose_elec(randint1(20) + 20, FALSE);
+               (void)set_oppose_elec(p_ptr, randint1(20) + 20, FALSE);
                break;
        }
 
@@ -1664,8 +1662,8 @@ bool activate_artifact(object_type *o_ptr)
        case ACT_SHIKOFUMI:
        {
                msg_print(_("力強く四股を踏んだ。", "You stamp. (as if you are in a ring.)"));
-               (void)set_afraid(0);
-               (void)set_hero(randint1(20) + 20, FALSE);
+               (void)set_afraid(p_ptr, 0);
+               (void)set_hero(p_ptr, randint1(20) + 20, FALSE);
                dispel_evil(p_ptr->lev * 3);
                break;
        }
@@ -1686,14 +1684,14 @@ bool activate_artifact(object_type *o_ptr)
        case ACT_ULTIMATE_RESIST:
        {
                TIME_EFFECT v = randint1(25) + 25;
-               (void)set_afraid(0);
-               (void)set_hero(v, FALSE);
-               (void)hp_player(10);
-               (void)set_blessed(v, FALSE);
-               (void)set_oppose_acid(v, FALSE);
-               (void)set_oppose_elec(v, FALSE);
-               (void)set_oppose_fire(v, FALSE);
-               (void)set_oppose_cold(v, FALSE);
+               (void)set_afraid(p_ptr, 0);
+               (void)set_hero(p_ptr, v, FALSE);
+               (void)hp_player(p_ptr, 10);
+               (void)set_blessed(p_ptr, v, FALSE);
+               (void)set_oppose_acid(p_ptr, v, FALSE);
+               (void)set_oppose_elec(p_ptr, v, FALSE);
+               (void)set_oppose_fire(p_ptr, v, FALSE);
+               (void)set_oppose_cold(p_ptr, v, FALSE);
                (void)set_oppose_pois(v, FALSE);
                (void)set_ultimate_res(v, FALSE);
                break;
@@ -1731,7 +1729,7 @@ bool activate_artifact(object_type *o_ptr)
                msg_format(_("%sはあなたの体力を奪った...", "The %s drains your vitality..."), name);
                take_hit(DAMAGE_LOSELIFE, damroll(3, 8), _("加速した疲労", "the strain of haste"), -1);
                t = 25 + randint1(25);
-               (void)set_fast(p_ptr->fast + t, FALSE);
+               (void)set_fast(p_ptr, p_ptr->fast + t, FALSE);
                break;
        }