OSDN Git Service

[Refactor] #37353 アリーナのコマンド制限処理を cmd_limit_arena() に統合。 / Integrate command limitatio...
[hengband/hengband.git] / src / cmd-activate.c
index 2a68100..0dc1c83 100644 (file)
@@ -9,6 +9,13 @@
 #include "angband.h"
 #include "cmd-activate.h"
 #include "object-hook.h"
+#include "spells-summon.h"
+#include "sort.h"
+#include "projection.h"
+#include "artifact.h"
+#include "avatar.h"
+#include "spells-status.h"
+#include "realm-hex.h"
 
 /*!
 * @brief ペット入りモンスターボールをソートするための比較関数
@@ -63,9 +70,11 @@ static bool ang_sort_comp_pet(vptr u, vptr v, int a, int b)
  * the user hits "escape" at the "direction" prompt.
  * </pre>
  */
-void do_cmd_activate_aux(int item)
+void do_cmd_activate_aux(INVENTORY_IDX item)
 {
-       int         dir, lev, chance, fail;
+       DIRECTION dir;
+       DEPTH lev;
+       int chance, fail;
        object_type *o_ptr;
        bool success;
 
@@ -82,7 +91,6 @@ void do_cmd_activate_aux(int item)
                o_ptr = &o_list[0 - item];
        }
 
-       /* Take a turn */
        p_ptr->energy_use = 100;
 
        /* Extract the item level */
@@ -159,7 +167,6 @@ void do_cmd_activate_aux(int item)
        /* Activate the artifact */
        msg_print(_("始動させた...", "You activate it..."));
 
-       /* Sound */
        sound(SOUND_ZAP);
 
        /* Activate object */
@@ -167,7 +174,6 @@ void do_cmd_activate_aux(int item)
        {
                (void)activate_artifact(o_ptr);
 
-               /* Window stuff */
                p_ptr->window |= (PW_INVEN | PW_EQUIP);
 
                /* Success */
@@ -180,22 +186,14 @@ void do_cmd_activate_aux(int item)
                if (music_singing_any()) stop_singing();
                if (hex_spelling_any()) stop_hex_spell_all();
 
-#if 0
-               if (object_is_cursed(o_ptr))
-               {
-                       msg_print(_("カン高い音が響き渡った。", "You produce a shrill whistling sound."));
-                       aggravate_monsters(0);
-               }
-               else
-#endif
                {
                        IDX pet_ctr, i;
-                       IDX *who;
+                       MONSTER_IDX *who;
                        int max_pet = 0;
                        u16b dummy_why;
 
                        /* Allocate the "who" array */
-                       C_MAKE(who, max_m_idx, IDX);
+                       C_MAKE(who, max_m_idx, MONSTER_IDX);
 
                        /* Process the monsters (backwards) */
                        for (pet_ctr = m_max - 1; pet_ctr >= 1; pet_ctr--)
@@ -220,7 +218,7 @@ void do_cmd_activate_aux(int item)
                        /* Free the "who" array */
                        C_KILL(who, max_m_idx, IDX);
                }
-               o_ptr->timeout = 100+randint1(100);
+               o_ptr->timeout = 100 + randint1(100);
                return;
        }
        else if (o_ptr->tval == TV_CAPTURE)
@@ -244,7 +242,7 @@ void do_cmd_activate_aux(int item)
                                o_ptr->xtra5 = (XTRA16)cap_maxhp;
                                if (cap_nickname)
                                {
-                                       cptr t;
+                                       concptr t;
                                        char *s;
                                        char buf[80] = "";
 
@@ -284,7 +282,7 @@ void do_cmd_activate_aux(int item)
                else
                {
                        success = FALSE;
-                       if (!get_rep_dir2(&dir)) return;
+                       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 (place_monster_aux(0, p_ptr->y + ddy[dir], p_ptr->x + ddx[dir], o_ptr->pval, (PM_FORCE_PET | PM_NO_KAGE)))
@@ -296,7 +294,7 @@ void do_cmd_activate_aux(int item)
                                        if (o_ptr->inscription)
                                        {
                                                char buf[80];
-                                               cptr t;
+                                               concptr t;
 #ifndef JP
                                                bool quote = FALSE;
 #endif
@@ -372,23 +370,22 @@ void do_cmd_activate_aux(int item)
 void do_cmd_activate(void)
 {
        OBJECT_IDX item;
-       cptr    q, s;
+       concptr q, s;
 
+       if (p_ptr->wild_mode) return;
+       if (cmd_limit_arena(p_ptr)) return;
 
        if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
        {
                set_action(ACTION_NONE);
        }
 
-       item_tester_no_ryoute = TRUE;
-       /* Prepare the hook */
        item_tester_hook = item_tester_hook_activate;
 
-       /* Get an item */
        q = _("どのアイテムを始動させますか? ", "Activate which item? ");
        s = _("始動できるアイテムを装備していない。", "You have nothing to activate.");
 
-       if (!get_item(&item, q, s, (USE_EQUIP))) return;
+       if (!choose_object(&item, q, s, (USE_EQUIP | IGNORE_BOTHHAND_SLOT))) return;
 
        /* Activate the item */
        do_cmd_activate_aux(item);
@@ -402,10 +399,11 @@ void do_cmd_activate(void)
 */
 static bool activate_dragon_breath(object_type *o_ptr)
 {
-       u32b flgs[TR_FLAG_SIZE]; /* for resistance flags */
+       BIT_FLAGS flgs[TR_FLAG_SIZE]; /* for resistance flags */
        int type[20];
-       cptr name[20];
-       int i, dir, t, n = 0;
+       concptr name[20];
+       int i, t, n = 0;
+       DIRECTION dir;
 
        if (!get_aim_dir(&dir)) return FALSE;
 
@@ -445,7 +443,7 @@ bool activate_artifact(object_type *o_ptr)
        PLAYER_LEVEL plev = p_ptr->lev;
        int k, dummy = 0;
        DIRECTION dir;
-       cptr name = k_name + k_info[o_ptr->k_idx].name;
+       concptr name = k_name + k_info[o_ptr->k_idx].name;
        const activation_type* const act_ptr = find_activation_info(o_ptr);
 
        /* Paranoia */
@@ -639,25 +637,7 @@ bool activate_artifact(object_type *o_ptr)
 
        case ACT_WHIRLWIND:
        {
-               {
-                       int y = 0, x = 0;
-                       cave_type       *c_ptr;
-                       monster_type    *m_ptr;
-
-                       for (dir = 0; dir <= 9; dir++)
-                       {
-                               y = p_ptr->y + ddy[dir];
-                               x = p_ptr->x + ddx[dir];
-                               c_ptr = &cave[y][x];
-
-                               /* Get the monster */
-                               m_ptr = &m_list[c_ptr->m_idx];
-
-                               /* Hack -- attack monsters */
-                               if (c_ptr->m_idx && (m_ptr->ml || cave_have_flag_bold(y, x, FF_PROJECT)))
-                                       py_attack(y, x, 0);
-                       }
-               }
+               massacre();
                break;
        }
 
@@ -778,9 +758,7 @@ bool activate_artifact(object_type *o_ptr)
                        while (attempts--)
                        {
                                scatter(&y, &x, p_ptr->y, p_ptr->x, 4, 0);
-
                                if (!cave_have_flag_bold(y, x, FF_PROJECT)) continue;
-
                                if (!player_bold(y, x)) break;
                        }
 
@@ -819,6 +797,7 @@ bool activate_artifact(object_type *o_ptr)
                }
                break;
        }
+
        case ACT_BR_COLD:
        {
                if (!get_aim_dir(&dir)) return FALSE;
@@ -829,6 +808,7 @@ bool activate_artifact(object_type *o_ptr)
                }
                break;
        }
+
        case ACT_BR_DRAGON:
        {
                if (!activate_dragon_breath(o_ptr)) return FALSE;
@@ -836,7 +816,6 @@ bool activate_artifact(object_type *o_ptr)
        }
 
        /* Activate for other offensive action */
-
        case ACT_CONFUSE:
        {
                msg_print(_("様々な色の火花を発している...", "It glows in scintillating colours..."));
@@ -955,14 +934,14 @@ bool activate_artifact(object_type *o_ptr)
 
        case ACT_SUMMON_ANIMAL:
        {
-               (void)summon_specific(-1, p_ptr->y, p_ptr->x, plev, SUMMON_ANIMAL_RANGER, (PM_ALLOW_GROUP | PM_FORCE_PET));
+               (void)summon_specific(-1, p_ptr->y, p_ptr->x, plev, SUMMON_ANIMAL_RANGER, (PM_ALLOW_GROUP | PM_FORCE_PET), '\0');
                break;
        }
 
        case ACT_SUMMON_PHANTOM:
        {
                msg_print(_("幻霊を召喚した。", "You summon a phantasmal servant."));
-               (void)summon_specific(-1, p_ptr->y, p_ptr->x, dun_level, SUMMON_PHANTOM, (PM_ALLOW_GROUP | PM_FORCE_PET));
+               (void)summon_specific(-1, p_ptr->y, p_ptr->x, dun_level, SUMMON_PHANTOM, (PM_ALLOW_GROUP | PM_FORCE_PET), '\0');
                break;
        }
 
@@ -975,7 +954,7 @@ bool activate_artifact(object_type *o_ptr)
                if (pet) mode |= PM_FORCE_PET;
                else mode |= PM_NO_PET;
 
-               if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, ((plev * 3) / 2), SUMMON_ELEMENTAL, mode))
+               if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, ((plev * 3) / 2), SUMMON_ELEMENTAL, mode, '\0'))
                {
                        msg_print(_("エレメンタルが現れた...", "An elemental materializes..."));
                        if (pet)
@@ -989,22 +968,7 @@ bool activate_artifact(object_type *o_ptr)
 
        case ACT_SUMMON_DEMON:
        {
-               bool pet = one_in_(3);
-               BIT_FLAGS mode = 0L;
-
-               if (!(pet && (plev < 50))) mode |= PM_ALLOW_GROUP;
-               if (pet) mode |= PM_FORCE_PET;
-               else mode |= PM_NO_PET;
-
-               if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, ((plev * 3) / 2), SUMMON_DEMON, mode))
-               {
-                       msg_print(_("硫黄の悪臭が充満した。", "The area fills with a stench of sulphur and brimstone."));
-                       if (pet)
-                               msg_print(_("「ご用でございますか、ご主人様」", "'What is thy bidding... Master?'"));
-                       else
-                               msg_print(_("「NON SERVIAM! Wretch! お前の魂を頂くぞ!」", "'NON SERVIAM! Wretch! I shall feast on thy mortal soul!'"));
-               }
-
+               cast_summon_demon((plev * 3) / 2);
                break;
        }
 
@@ -1020,7 +984,7 @@ bool activate_artifact(object_type *o_ptr)
                if (pet) mode |= PM_FORCE_PET;
                else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
 
-               if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, ((plev * 3) / 2), type, mode))
+               if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, ((plev * 3) / 2), type, mode, '\0'))
                {
                        msg_print(_("冷たい風があなたの周りに吹き始めた。それは腐敗臭を運んでいる...",
                                "Cold winds begin to blow around you, carrying with them the stench of decay..."));
@@ -1042,7 +1006,7 @@ bool activate_artifact(object_type *o_ptr)
                if (pet) mode |= PM_FORCE_PET;
                else mode |= PM_NO_PET;
 
-               if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, ((p_ptr->lev * 3) / 2), SUMMON_HOUND, mode))
+               if (summon_specific((pet ? -1 : 0), p_ptr->y, p_ptr->x, ((p_ptr->lev * 3) / 2), SUMMON_HOUND, mode, '\0'))
                {
 
                        if (pet)
@@ -1059,7 +1023,7 @@ bool activate_artifact(object_type *o_ptr)
        case ACT_SUMMON_DAWN:
        {
                msg_print(_("暁の師団を召喚した。", "You summon the Legion of the Dawn."));
-               (void)summon_specific(-1, p_ptr->y, p_ptr->x, dun_level, SUMMON_DAWN, (PM_ALLOW_GROUP | PM_FORCE_PET));
+               (void)summon_specific(-1, p_ptr->y, p_ptr->x, dun_level, SUMMON_DAWN, (PM_ALLOW_GROUP | PM_FORCE_PET), '\0');
                break;
        }
 
@@ -1146,13 +1110,7 @@ bool activate_artifact(object_type *o_ptr)
        case ACT_CURING:
        {
                msg_format(_("%sの優しさに癒される...", "the %s cures you affectionately ..."), name);
-               (void)set_poisoned(0);
-               (void)set_confused(0);
-               (void)set_blind(0);
-               (void)set_stun(0);
-               (void)set_cut(0);
-               (void)set_image(0);
-
+               true_healing(0);
                break;
        }
 
@@ -1173,12 +1131,7 @@ bool activate_artifact(object_type *o_ptr)
 
        case ACT_BERSERK:
        {
-               (void)set_afraid(0);
-               (void)set_shero(randint1(25) + 25, FALSE);
-               /* (void)set_afraid(0);
-               (void)set_hero(randint1(50) + 50, FALSE);
-               (void)set_blessed(randint1(50) + 50, FALSE);
-               o_ptr->timeout = 100 + randint1(100); */
+               (void)berserk(randint1(25) + 25);
                break;
        }
 
@@ -1408,7 +1361,7 @@ bool activate_artifact(object_type *o_ptr)
        case ACT_RECALL:
        {
                msg_print(_("やわらかな白色に輝いている...", "It glows soft white..."));
-               if (!word_of_recall()) return FALSE;
+               if (!recall_player(p_ptr, randint0(21) + 15)) return FALSE;
                break;
        }
 
@@ -1428,7 +1381,7 @@ bool activate_artifact(object_type *o_ptr)
 
                if (get_check(_("帰還の力を使いますか?", "Activate recall? ")))
                {
-                       (void)word_of_recall();
+                       (void)recall_player(p_ptr, randint0(21) + 15);
                }
 
                break;
@@ -1495,10 +1448,7 @@ bool activate_artifact(object_type *o_ptr)
        case ACT_DISP_CURSE_XTRA:
        {
                msg_format(_("%sが真実を照らし出す...", "The %s exhibits the truth..."), name);
-               if (remove_all_curse())
-               {
-                       msg_print(_("誰かに見守られているような気がする。", "You feel as if someone is watching over you."));
-               }
+               (void)remove_all_curse();
                (void)probing();
                break;
        }
@@ -1540,28 +1490,21 @@ bool activate_artifact(object_type *o_ptr)
                                p_ptr->csp = 0;
                                p_ptr->csp_frac = 0;
 
-                               /* Message */
                                msg_print(_("石を制御できない!", "You are too weak to control the stone!"));
                                /* Hack -- Bypass free action */
-                               (void)set_paralyzed(p_ptr->paralyzed +
-                                       randint1(5 * oops + 1));
+                               (void)set_paralyzed(p_ptr->paralyzed + randint1(5 * oops + 1));
 
                                /* Confusing. */
-                               (void)set_confused(p_ptr->confused +
-                                       randint1(5 * oops + 1));
+                               (void)set_confused(p_ptr->confused + randint1(5 * oops + 1));
                        }
-
-                       /* Redraw mana */
                        p_ptr->redraw |= (PR_MANA);
                }
                take_hit(DAMAGE_LOSELIFE, damroll(1, 12), _("危険な秘密", "perilous secrets"), -1);
                /* Confusing. */
-               if (one_in_(5)) (void)set_confused(p_ptr->confused +
-                       randint1(10));
+               if (one_in_(5)) (void)set_confused(p_ptr->confused + randint1(10));
 
                /* Exercise a little care... */
-               if (one_in_(20))
-                       take_hit(DAMAGE_LOSELIFE, damroll(4, 10), _("危険な秘密", "perilous secrets"), -1);
+               if (one_in_(20)) take_hit(DAMAGE_LOSELIFE, damroll(4, 10), _("危険な秘密", "perilous secrets"), -1);
                break;
        }
 
@@ -1607,9 +1550,10 @@ bool activate_artifact(object_type *o_ptr)
        /* Unique activation */
        case ACT_CAST_OFF:
        {
-               int inv, t;
+               INVENTORY_IDX inv;
+               int t;
                OBJECT_IDX o_idx;
-               char o_name[MAX_NLEN];
+               GAME_TEXT o_name[MAX_NLEN];
                object_type forge;
 
                /* Cast off activated item */
@@ -1684,12 +1628,12 @@ bool activate_artifact(object_type *o_ptr)
 
        case ACT_FISHING:
        {
-               int x, y;
+               POSITION x, y;
 
-               if (!get_rep_dir2(&dir)) return FALSE;
+               if (!get_direction(&dir, FALSE, FALSE)) return FALSE;
                y = p_ptr->y + ddy[dir];
                x = p_ptr->x + ddx[dir];
-               tsuri_dir = dir;
+               p_ptr->fishing_dir = dir;
                if (!cave_have_flag_bold(y, x, FF_WATER))
                {
                        msg_print(_("そこは水辺ではない。", "There is no fishing place."));
@@ -1697,7 +1641,7 @@ bool activate_artifact(object_type *o_ptr)
                }
                else if (cave[y][x].m_idx)
                {
-                       char m_name[80];
+                       GAME_TEXT m_name[MAX_NLEN];
                        monster_desc(m_name, &m_list[cave[y][x].m_idx], 0);
                        msg_format(_("%sが邪魔だ!", "%^s is stand in your way."), m_name);
                        p_ptr->energy_use = 0;
@@ -1712,7 +1656,7 @@ bool activate_artifact(object_type *o_ptr)
        {
                int count = 0, i;
                monster_type *m_ptr;
-               cptr kakusan = "";
+               concptr kakusan = "";
 
                if (summon_named_creature(0, p_ptr->y, p_ptr->x, MON_SUKE, PM_FORCE_PET))
                {
@@ -1895,7 +1839,7 @@ void get_bloody_moon_flags(object_type *o_ptr)
        for (i = 0; i < 2; i++)
        {
                int tmp = randint0(11);
-               if (tmp < 6) add_flag(o_ptr->art_flags, TR_STR + tmp);
+               if (tmp < A_MAX) add_flag(o_ptr->art_flags, TR_STR + tmp);
                else add_flag(o_ptr->art_flags, TR_STEALTH + tmp - 6);
        }
 }