OSDN Git Service

[Refactor] #37353 コメント整理。 / Refactor comments.
[hengband/hengband.git] / src / spells3.c
index b82624d..b4664c3 100644 (file)
  */
 
 #include "angband.h"
+#include "floor.h"
 #include "object-hook.h"
 #include "melee.h"
 #include "player-status.h"
+#include "projection.h"
+#include "spells-summon.h"
+#include "quest.h"
+#include "artifact.h"
+#include "avatar.h"
+
 
 /*! テレポート先探索の試行数 / Maximum number of tries for teleporting */
 #define MAX_TRIES 100
@@ -44,7 +51,6 @@ bool teleport_away(MONSTER_IDX m_idx, POSITION dis, BIT_FLAGS mode)
        /* Paranoia */
        if (!m_ptr->r_idx) return (FALSE);
 
-       /* Save the old location */
        oy = m_ptr->fy;
        ox = m_ptr->fx;
 
@@ -157,8 +163,6 @@ void teleport_monster_to(MONSTER_IDX m_idx, POSITION ty, POSITION tx, int power,
 
        ny = m_ptr->fy;
        nx = m_ptr->fx;
-
-       /* Save the old location */
        oy = m_ptr->fy;
        ox = m_ptr->fx;
 
@@ -354,9 +358,7 @@ bool teleport_player_aux(POSITION dis, BIT_FLAGS mode)
                msg_format("『こっちだぁ、%s』", p_ptr->name);
 #endif
 
-       /* Move the player */
        (void)move_player_effect(y, x, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP);
-
        return TRUE;
 }
 
@@ -369,8 +371,6 @@ bool teleport_player_aux(POSITION dis, BIT_FLAGS mode)
 void teleport_player(POSITION dis, BIT_FLAGS mode)
 {
        POSITION yy, xx;
-
-       /* Save the old location */
        POSITION oy = p_ptr->y;
        POSITION ox = p_ptr->x;
 
@@ -413,8 +413,6 @@ void teleport_player(POSITION dis, BIT_FLAGS mode)
 void teleport_player_away(MONSTER_IDX m_idx, POSITION dis)
 {
        POSITION yy, xx;
-
-       /* Save the old location */
        POSITION oy = p_ptr->y;
        POSITION ox = p_ptr->x;
 
@@ -425,7 +423,7 @@ void teleport_player_away(MONSTER_IDX m_idx, POSITION dis)
        {
                for (yy = -1; yy < 2; yy++)
                {
-                       IDX tmp_m_idx = cave[oy+yy][ox+xx].m_idx;
+                       MONSTER_IDX tmp_m_idx = cave[oy+yy][ox+xx].m_idx;
 
                        /* A monster except your mount or caster may follow */
                        if (tmp_m_idx && (p_ptr->riding != tmp_m_idx) && (m_idx != tmp_m_idx))
@@ -498,8 +496,6 @@ void teleport_player_to(POSITION ny, POSITION nx, BIT_FLAGS mode)
        }
 
        sound(SOUND_TELEPORT);
-
-       /* Move the player */
        (void)move_player_effect(y, x, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP);
 }
 
@@ -557,6 +553,32 @@ void teleport_away_followable(MONSTER_IDX m_idx)
 }
 
 
+bool teleport_level_other(player_type *creature_ptr)
+{
+       MONSTER_IDX target_m_idx;
+       monster_type *m_ptr;
+       monster_race *r_ptr;
+       GAME_TEXT m_name[MAX_NLEN];
+
+       if (!target_set(TARGET_KILL)) return FALSE;
+       target_m_idx = cave[target_row][target_col].m_idx;
+       if (!target_m_idx) return TRUE;
+       if (!player_has_los_bold(target_row, target_col)) return TRUE;
+       if (!projectable(creature_ptr->y, creature_ptr->x, target_row, target_col)) return TRUE;
+       m_ptr = &m_list[target_m_idx];
+       r_ptr = &r_info[m_ptr->r_idx];
+       monster_desc(m_name, m_ptr, 0);
+       msg_format(_("%^sの足を指さした。", "You gesture at %^s's feet."), m_name);
+
+       if ((r_ptr->flagsr & (RFR_EFF_RES_NEXU_MASK | RFR_RES_TELE)) ||
+               (r_ptr->flags1 & RF1_QUESTOR) || (r_ptr->level + randint1(50) > creature_ptr->lev + randint1(60)))
+       {
+               msg_format(_("しかし効果がなかった!", "%^s is unaffected!"), m_name);
+       }
+       else teleport_level(target_m_idx);
+       return TRUE;
+}
+
 /*!
  * @brief プレイヤー及びモンスターをレベルテレポートさせる /
  * Teleport the player one level up or down (random when legal)
@@ -742,7 +764,7 @@ void teleport_level(MONSTER_IDX m_idx)
  * @param x コンソールX座標
  * @return 選択されたダンジョンID
  */
-DUNGEON_IDX choose_dungeon(cptr note, POSITION y, POSITION x)
+DUNGEON_IDX choose_dungeon(concptr note, POSITION y, POSITION x)
 {
        DUNGEON_IDX select_dungeon;
        DUNGEON_IDX i;
@@ -762,7 +784,7 @@ DUNGEON_IDX choose_dungeon(cptr note, POSITION y, POSITION x)
        }
 
        /* Allocate the "dun" array */
-       C_MAKE(dun, max_d_idx, s16b);
+       C_MAKE(dun, max_d_idx, DUNGEON_IDX);
 
        screen_save();
        for(i = 1; i < max_d_idx; i++)
@@ -796,7 +818,7 @@ DUNGEON_IDX choose_dungeon(cptr note, POSITION y, POSITION x)
                if ((i == ESCAPE) || !num)
                {
                        /* Free the "dun" array */
-                       C_KILL(dun, max_d_idx, s16b);
+                       C_KILL(dun, max_d_idx, DUNGEON_IDX);
 
                        screen_load();
                        return 0;
@@ -811,7 +833,7 @@ DUNGEON_IDX choose_dungeon(cptr note, POSITION y, POSITION x)
        screen_load();
 
        /* Free the "dun" array */
-       C_KILL(dun, max_d_idx, s16b);
+       C_KILL(dun, max_d_idx, DUNGEON_IDX);
 
        return select_dungeon;
 }
@@ -823,7 +845,7 @@ DUNGEON_IDX choose_dungeon(cptr note, POSITION y, POSITION x)
  * @param turns 発動までのターン数
  * @return 常にTRUEを返す
  */
-bool recall_player(TIME_EFFECT turns)
+bool recall_player(player_type *creature_ptr, TIME_EFFECT turns)
 {
        /*
         * TODO: Recall the player to the last
@@ -831,13 +853,13 @@ bool recall_player(TIME_EFFECT turns)
         */
 
        /* Ironman option */
-       if (p_ptr->inside_arena || ironman_downward)
+       if (creature_ptr->inside_arena || ironman_downward)
        {
                msg_print(_("何も起こらなかった。", "Nothing happens."));
                return TRUE;
        }
 
-       if (dun_level && (max_dlv[dungeon_type] > dun_level) && !p_ptr->inside_quest && !p_ptr->word_recall)
+       if (dun_level && (max_dlv[dungeon_type] > dun_level) && !creature_ptr->inside_quest && !creature_ptr->word_recall)
        {
                if (get_check(_("ここは最深到達階より浅い階です。この階に戻って来ますか? ", "Reset recall depth? ")))
                {
@@ -847,37 +869,66 @@ bool recall_player(TIME_EFFECT turns)
                }
 
        }
-       if (!p_ptr->word_recall)
+       if (!creature_ptr->word_recall)
        {
                if (!dun_level)
                {
                        DUNGEON_IDX select_dungeon;
                        select_dungeon = choose_dungeon(_("に帰還", "recall"), 2, 14);
                        if (!select_dungeon) return FALSE;
-                       p_ptr->recall_dungeon = select_dungeon;
+                       creature_ptr->recall_dungeon = select_dungeon;
                }
-               p_ptr->word_recall = turns;
+               creature_ptr->word_recall = turns;
                msg_print(_("回りの大気が張りつめてきた...", "The air about you becomes charged..."));
-               p_ptr->redraw |= (PR_STATUS);
+               creature_ptr->redraw |= (PR_STATUS);
        }
        else
        {
-               p_ptr->word_recall = 0;
+               creature_ptr->word_recall = 0;
                msg_print(_("張りつめた大気が流れ去った...", "A tension leaves the air around you..."));
-               p_ptr->redraw |= (PR_STATUS);
+               creature_ptr->redraw |= (PR_STATUS);
        }
        return TRUE;
 }
 
-/*!
- * @brief 帰還用メインルーチン
- * @return 常にTRUEを返す
- */
-bool word_of_recall(void)
+bool free_level_recall(player_type *creature_ptr)
 {
-       return(recall_player(randint0(21) + 15));
+       DUNGEON_IDX select_dungeon;
+       DEPTH max_depth;
+       QUANTITY amt;
+
+       select_dungeon = choose_dungeon(_("にテレポート", "teleport"), 4, 0);
+
+       if (!select_dungeon) return FALSE;
+
+       max_depth = d_info[select_dungeon].maxdepth;
+
+       /* Limit depth in Angband */
+       if (select_dungeon == DUNGEON_ANGBAND)
+       {
+               if (quest[QUEST_OBERON].status != QUEST_STATUS_FINISHED) max_depth = 98;
+               else if (quest[QUEST_SERPENT].status != QUEST_STATUS_FINISHED) max_depth = 99;
+       }
+       amt = get_quantity(format(_("%sの何階にテレポートしますか?", "Teleport to which level of %s? "),
+               d_name + d_info[select_dungeon].name), (QUANTITY)max_depth);
+
+       if (amt > 0)
+       {
+               creature_ptr->word_recall = 1;
+               creature_ptr->recall_dungeon = select_dungeon;
+               max_dlv[creature_ptr->recall_dungeon] = ((amt > d_info[select_dungeon].maxdepth) ? d_info[select_dungeon].maxdepth : ((amt < d_info[select_dungeon].mindepth) ? d_info[select_dungeon].mindepth : amt));
+               if (record_maxdepth)
+                       do_cmd_write_nikki(NIKKI_TRUMP, select_dungeon, _("トランプタワーで", "at Trump Tower"));
+
+               msg_print(_("回りの大気が張りつめてきた...", "The air about you becomes charged..."));
+
+               creature_ptr->redraw |= (PR_STATUS);
+               return TRUE;
+       }
+       return FALSE;
 }
 
+
 /*!
  * @brief フロア・リセット処理
  * @return リセット処理が実際に行われたらTRUEを返す
@@ -924,7 +975,7 @@ bool reset_recall(void)
                        do_cmd_write_nikki(NIKKI_TRUMP, select_dungeon, _("フロア・リセットで", "using a scroll of reset recall"));
                                        /* Accept request */
 #ifdef JP
-msg_format("%sの帰還レベルを %d 階にセット。", d_name+d_info[select_dungeon].name, dummy, dummy * 50);
+               msg_format("%sの帰還レベルを %d 階にセット。", d_name+d_info[select_dungeon].name, dummy, dummy * 50);
 #else
                msg_format("Recall depth set to level %d (%d').", dummy, dummy * 50);
 #endif
@@ -948,7 +999,7 @@ msg_format("%sの帰還レベルを %d 階にセット。", d_name+d_info[select
 bool apply_disenchant(BIT_FLAGS mode)
 {
        int             t = 0;
-       object_type     *o_ptr;
+       object_type *o_ptr;
        GAME_TEXT o_name[MAX_NLEN];
        int to_h, to_d, to_a, pval;
 
@@ -981,22 +1032,17 @@ bool apply_disenchant(BIT_FLAGS mode)
                return (FALSE);
        }
 
-
        object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
 
-
        /* Artifacts have 71% chance to resist */
        if (object_is_artifact(o_ptr) && (randint0(100) < 71))
        {
 #ifdef JP
-msg_format("%s(%c)は劣化を跳ね返した!",o_name, index_to_label(t) );
+               msg_format("%s(%c)は劣化を跳ね返した!",o_name, index_to_label(t) );
 #else
-               msg_format("Your %s (%c) resist%s disenchantment!",
-                          o_name, index_to_label(t),
-                          ((o_ptr->number != 1) ? "" : "s"));
+               msg_format("Your %s (%c) resist%s disenchantment!", o_name, index_to_label(t),
+                       ((o_ptr->number != 1) ? "" : "s"));
 #endif
-
-
                return (TRUE);
        }
 
@@ -1027,18 +1073,15 @@ msg_format("%s(%c)は劣化を跳ね返した!",o_name, index_to_label(t) );
            (to_a != o_ptr->to_a) || (pval != o_ptr->pval))
        {
 #ifdef JP
-               msg_format("%s(%c)は劣化してしまった!",
-                          o_name, index_to_label(t) );
+               msg_format("%s(%c)は劣化してしまった!", o_name, index_to_label(t) );
 #else
-               msg_format("Your %s (%c) %s disenchanted!",
-                          o_name, index_to_label(t),
-                          ((o_ptr->number != 1) ? "were" : "was"));
+               msg_format("Your %s (%c) %s disenchanted!", o_name, index_to_label(t),
+                       ((o_ptr->number != 1) ? "were" : "was"));
 #endif
 
                chg_virtue(V_HARMONY, 1);
                chg_virtue(V_ENCHANT, -2);
                p_ptr->update |= (PU_BONUS);
-
                p_ptr->window |= (PW_EQUIP | PW_PLAYER);
 
                calc_android_exp();
@@ -1057,8 +1100,8 @@ void mutate_player(void)
        int ii, jj, i;
 
        /* Pick a pair of stats */
-       ii = randint0(6);
-       for (jj = ii; jj == ii; jj = randint0(6)) /* loop */;
+       ii = randint0(A_MAX);
+       for (jj = ii; jj == ii; jj = randint0(A_MAX)) /* loop */;
 
        max1 = p_ptr->stat_max[ii];
        cur1 = p_ptr->stat_cur[ii];
@@ -1070,7 +1113,7 @@ void mutate_player(void)
        p_ptr->stat_max[jj] = max1;
        p_ptr->stat_cur[jj] = cur1;
 
-       for (i=0;i<6;i++)
+       for (i = 0; i < A_MAX; i++)
        {
                if(p_ptr->stat_max[i] > p_ptr->stat_max_max[i]) p_ptr->stat_max[i] = p_ptr->stat_max_max[i];
                if(p_ptr->stat_cur[i] > p_ptr->stat_max_max[i]) p_ptr->stat_cur[i] = p_ptr->stat_max_max[i];
@@ -1191,7 +1234,7 @@ void brand_weapon(int brand_type)
 {
        OBJECT_IDX item;
        object_type *o_ptr;
-       cptr        q, s;
+       concptr        q, s;
 
 
        /* Assume enchant weapon */
@@ -1200,20 +1243,8 @@ void brand_weapon(int brand_type)
        q = _("どの武器を強化しますか? ", "Enchant which weapon? ");
        s = _("強化できる武器がない。", "You have nothing to enchant.");
 
-       if (!get_item(&item, q, s, (USE_EQUIP | IGNORE_BOTHHAND_SLOT))) return;
-
-       /* Get the item (in the pack) */
-       if (item >= 0)
-       {
-               o_ptr = &inventory[item];
-       }
-
-       /* Get the item (on the floor) */
-       else
-       {
-               o_ptr = &o_list[0 - item];
-       }
-
+       o_ptr = choose_object(&item, q, s, (USE_EQUIP | IGNORE_BOTHHAND_SLOT));
+       if (!o_ptr) return;
 
        /* you can never modify artifacts / ego-items */
        /* you can never modify cursed items */
@@ -1224,7 +1255,7 @@ void brand_weapon(int brand_type)
            !((o_ptr->tval == TV_POLEARM) && (o_ptr->sval == SV_DEATH_SCYTHE)) &&
            !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DIAMOND_EDGE)))
        {
-               cptr act = NULL;
+               concptr act = NULL;
 
                /* Let's get the name before it is changed... */
                GAME_TEXT o_name[MAX_NLEN];
@@ -1641,8 +1672,8 @@ void fetch(DIRECTION dir, WEIGHT wgt, bool require_los)
        cave[p_ptr->y][p_ptr->x].o_idx = i; /* 'move' it */
 
        o_ptr->next_o_idx = 0;
-       o_ptr->iy = (byte)p_ptr->y;
-       o_ptr->ix = (byte)p_ptr->x;
+       o_ptr->iy = p_ptr->y;
+       o_ptr->ix = p_ptr->x;
 
        object_desc(o_name, o_ptr, OD_NAME_ONLY);
        msg_format(_("%^sがあなたの足元に飛んできた。", "%^s flies through the air to your feet."), o_name);
@@ -1834,17 +1865,12 @@ static int remove_curse_aux(int all)
                /* Perma-Cursed Items can NEVER be uncursed */
                if (o_ptr->curse_flags & TRC_PERMA_CURSE)
                {
-                       /* Uncurse it */
                        o_ptr->curse_flags &= (TRC_CURSED | TRC_HEAVY_CURSE | TRC_PERMA_CURSE);
                        continue;
                }
 
-               /* Uncurse it */
                o_ptr->curse_flags = 0L;
-
-               /* Hack -- Assume felt */
                o_ptr->ident |= (IDENT_SENSE);
-
                o_ptr->feeling = FEEL_NONE;
 
                p_ptr->update |= (PU_BONUS);
@@ -1900,7 +1926,7 @@ bool alchemy(void)
        GAME_TEXT o_name[MAX_NLEN];
        char out_val[MAX_NLEN+40];
 
-       cptr q, s;
+       concptr q, s;
 
        /* Hack -- force destruction */
        if (command_arg > 0) force = TRUE;
@@ -1908,20 +1934,8 @@ bool alchemy(void)
        q = _("どのアイテムを金に変えますか?", "Turn which item to gold? ");
        s = _("金に変えられる物がありません。", "You have nothing to turn to gold.");
 
-       if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return (FALSE);
-
-       /* Get the item (in the pack) */
-       if (item >= 0)
-       {
-               o_ptr = &inventory[item];
-       }
-
-       /* Get the item (on the floor) */
-       else
-       {
-               o_ptr = &o_list[0 - item];
-       }
-
+       o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
+       if (!o_ptr) return (FALSE);
 
        /* See how many items */
        if (o_ptr->number > 1)
@@ -1933,7 +1947,6 @@ bool alchemy(void)
                if (amt <= 0) return FALSE;
        }
 
-
        old_number = o_ptr->number;
        o_ptr->number = amt;
        object_desc(o_name, o_ptr, 0);
@@ -1974,12 +1987,8 @@ bool alchemy(void)
                msg_format(_("%sを$%d の金に変えた。", "You turn %s to %ld coins worth of gold."), o_name, price);
 
                p_ptr->au += price;
-
-               /* Redraw gold */
                p_ptr->redraw |= (PR_GOLD);
-
                p_ptr->window |= (PW_PLAYER);
-
        }
 
        /* Eliminate the item (from the pack) */
@@ -2050,7 +2059,6 @@ bool enchant(object_type *o_ptr, int n, int eflag)
        bool    a = object_is_artifact(o_ptr);
        bool    force = (eflag & ENCH_FORCE);
 
-
        /* Large piles resist enchantment */
        prob = o_ptr->number * 100;
 
@@ -2125,11 +2133,7 @@ bool enchant(object_type *o_ptr, int n, int eflag)
 
        /* Failure */
        if (!res) return (FALSE);
-       p_ptr->update |= (PU_BONUS);
-
-       /* Combine / Reorder the pack (later) */
-       p_ptr->update |= (PU_COMBINE | PU_REORDER);
-
+       p_ptr->update |= (PU_BONUS | PU_COMBINE | PU_REORDER);
        p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
 
        calc_android_exp();
@@ -2156,7 +2160,7 @@ bool enchant_spell(HIT_PROB num_hit, HIT_POINT num_dam, ARMOUR_CLASS num_ac)
        bool        okay = FALSE;
        object_type *o_ptr;
        GAME_TEXT o_name[MAX_NLEN];
-       cptr        q, s;
+       concptr        q, s;
 
        /* Assume enchant weapon */
        item_tester_hook = object_allow_enchant_weapon;
@@ -2167,19 +2171,8 @@ bool enchant_spell(HIT_PROB num_hit, HIT_POINT num_dam, ARMOUR_CLASS num_ac)
        q = _("どのアイテムを強化しますか? ", "Enchant which item? ");
        s = _("強化できるアイテムがない。", "You have nothing to enchant.");
 
-       if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT))) return (FALSE);
-
-       /* Get the item (in the pack) */
-       if (item >= 0)
-       {
-               o_ptr = &inventory[item];
-       }
-
-       /* Get the item (on the floor) */
-       else
-       {
-               o_ptr = &o_list[0 - item];
-       }
+       o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
+       if (!o_ptr) return (FALSE);
 
        object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
 #ifdef JP
@@ -2220,7 +2213,7 @@ bool artifact_scroll(void)
        bool okay = FALSE;
        object_type *o_ptr;
        GAME_TEXT o_name[MAX_NLEN];
-       cptr q, s;
+       concptr q, s;
 
        /* Enchant weapon/armour */
        item_tester_hook = item_tester_hook_nameless_weapon_armour;
@@ -2228,18 +2221,8 @@ bool artifact_scroll(void)
        q = _("どのアイテムを強化しますか? ", "Enchant which item? ");
        s = _("強化できるアイテムがない。", "You have nothing to enchant.");
 
-       if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT))) return (FALSE);
-
-       /* Get the item (in the pack) */
-       if (item >= 0)
-       {
-               o_ptr = &inventory[item];
-       }
-       /* Get the item (on the floor) */
-       else
-       {
-               o_ptr = &o_list[0 - item];
-       }
+       o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
+       if (!o_ptr) return (FALSE);
 
        object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
 #ifdef JP
@@ -2351,17 +2334,11 @@ bool identify_item(object_type *o_ptr)
                        chg_virtue(V_KNOWLEDGE, 1);
        }
 
-       /* Identify it fully */
        object_aware(o_ptr);
        object_known(o_ptr);
-
-       /* Player touches it */
        o_ptr->marked |= OM_TOUCHED;
-       p_ptr->update |= (PU_BONUS);
-
-       /* Combine / Reorder the pack (later) */
-       p_ptr->update |= (PU_COMBINE | PU_REORDER);
 
+       p_ptr->update |= (PU_BONUS | PU_COMBINE | PU_REORDER);
        p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
 
        strcpy(record_o_name, o_name);
@@ -2389,9 +2366,9 @@ bool identify_item(object_type *o_ptr)
 bool ident_spell(bool only_equip)
 {
        OBJECT_IDX item;
-       object_type     *o_ptr;
+       object_type *o_ptr;
        GAME_TEXT o_name[MAX_NLEN];
-       cptr            q, s;
+       concptr            q, s;
        bool old_known;
 
        if (only_equip)
@@ -2415,19 +2392,8 @@ bool ident_spell(bool only_equip)
 
        s = _("鑑定するべきアイテムがない。", "You have nothing to identify.");
 
-       if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT))) return (FALSE);
-
-       /* Get the item (in the pack) */
-       if (item >= 0)
-       {
-               o_ptr = &inventory[item];
-       }
-
-       /* Get the item (on the floor) */
-       else
-       {
-               o_ptr = &o_list[0 - item];
-       }
+       o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
+       if (!o_ptr) return (FALSE);
 
        old_known = identify_item(o_ptr);
 
@@ -2468,35 +2434,24 @@ bool ident_spell(bool only_equip)
 bool mundane_spell(bool only_equip)
 {
        OBJECT_IDX item;
-       object_type     *o_ptr;
-       cptr            q, s;
+       object_type *o_ptr;
+       concptr q, s;
 
        if (only_equip) item_tester_hook = object_is_weapon_armour_ammo;
 
        q = _("どれを使いますか?", "Use which item? ");
        s = _("使えるものがありません。", "You have nothing you can use.");
 
-       if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT))) return (FALSE);
-
-       /* Get the item (in the pack) */
-       if (item >= 0)
-       {
-               o_ptr = &inventory[item];
-       }
-
-       /* Get the item (on the floor) */
-       else
-       {
-               o_ptr = &o_list[0 - item];
-       }
+       o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
+       if (!o_ptr) return (FALSE);
 
        msg_print(_("まばゆい閃光が走った!", "There is a bright flash of light!"));
        {
                POSITION iy = o_ptr->iy;                 /* Y-position on map, or zero */
                POSITION ix = o_ptr->ix;                 /* X-position on map, or zero */
-               s16b next_o_idx = o_ptr->next_o_idx; /* Next object in stack (if any) */
+               OBJECT_IDX next_o_idx = o_ptr->next_o_idx; /* Next object in stack (if any) */
                byte marked = o_ptr->marked;         /* Object is marked */
-               s16b weight = o_ptr->number * o_ptr->weight;
+               WEIGHT weight = o_ptr->number * o_ptr->weight;
                u16b inscription = o_ptr->inscription;
 
                /* Wipe it clean */
@@ -2529,7 +2484,7 @@ bool identify_fully(bool only_equip)
        OBJECT_IDX item;
        object_type *o_ptr;
        GAME_TEXT o_name[MAX_NLEN];
-       cptr q, s;
+       concptr q, s;
        bool old_known;
 
        if (only_equip)
@@ -2553,19 +2508,8 @@ bool identify_fully(bool only_equip)
 
        s = _("*鑑定*するべきアイテムがない。", "You have nothing to *identify*.");
 
-       if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT))) return (FALSE);
-
-       /* Get the item (in the pack) */
-       if (item >= 0)
-       {
-               o_ptr = &inventory[item];
-       }
-
-       /* Get the item (on the floor) */
-       else
-       {
-               o_ptr = &o_list[0 - item];
-       }
+       o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
+       if (!o_ptr) return (FALSE);
 
        old_known = identify_item(o_ptr);
 
@@ -2632,7 +2576,7 @@ bool recharge(int power)
        bool fail = FALSE;
        byte fail_type = 1;
 
-       cptr q, s;
+       concptr q, s;
        GAME_TEXT o_name[MAX_NLEN];
 
        /* Only accept legal items */
@@ -2641,19 +2585,8 @@ bool recharge(int power)
        q = _("どのアイテムに魔力を充填しますか? ", "Recharge which item? ");
        s = _("魔力を充填すべきアイテムがない。", "You have nothing to recharge.");
 
-       if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return (FALSE);
-
-       /* Get the item (in the pack) */
-       if (item >= 0)
-       {
-               o_ptr = &inventory[item];
-       }
-
-       /* Get the item (on the floor) */
-       else
-       {
-               o_ptr = &o_list[0 - item];
-       }
+       o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
+       if (!o_ptr) return (FALSE);
 
        /* Get the object kind. */
        k_ptr = &k_info[o_ptr->k_idx];
@@ -2894,10 +2827,7 @@ bool recharge(int power)
                        }
                }
        }
-
-       /* Combine / Reorder the pack (later) */
        p_ptr->update |= (PU_COMBINE | PU_REORDER);
-
        p_ptr->window |= (PW_INVEN);
 
        /* Something was done */
@@ -2916,7 +2846,7 @@ bool bless_weapon(void)
        object_type *o_ptr;
        BIT_FLAGS flgs[TR_FLAG_SIZE];
        GAME_TEXT o_name[MAX_NLEN];
-       cptr q, s;
+       concptr q, s;
 
        /* Bless only weapons */
        item_tester_hook = object_is_weapon;
@@ -2924,24 +2854,10 @@ bool bless_weapon(void)
        q = _("どのアイテムを祝福しますか?", "Bless which weapon? ");
        s = _("祝福できる武器がありません。", "You have weapon to bless.");
 
-       if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT)))
-               return FALSE;
-
-       /* Get the item (in the pack) */
-       if (item >= 0)
-       {
-               o_ptr = &inventory[item];
-       }
-
-       /* Get the item (on the floor) */
-       else
-       {
-               o_ptr = &o_list[0 - item];
-       }
+       o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
+       if (!o_ptr) return FALSE;
 
        object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
-
-       /* Extract the flags */
        object_flags(o_ptr, flgs);
 
        if (object_is_cursed(o_ptr))
@@ -2967,12 +2883,9 @@ bool bless_weapon(void)
 #endif
 
 
-               /* Uncurse it */
                o_ptr->curse_flags = 0L;
 
-               /* Hack -- Assume felt */
                o_ptr->ident |= (IDENT_SENSE);
-
                o_ptr->feeling = FEEL_NONE;
 
                /* Recalculate the bonuses */
@@ -2991,8 +2904,7 @@ bool bless_weapon(void)
        if (have_flag(flgs, TR_BLESSED))
        {
 #ifdef JP
-msg_format("%s は既に祝福されている。",
-    o_name    );
+               msg_format("%s は既に祝福されている。", o_name);
 #else
                msg_format("%s %s %s blessed already.",
                    ((item >= 0) ? "Your" : "The"), o_name,
@@ -3052,20 +2964,17 @@ msg_format("%s は既に祝福されている。",
                        msg_print(_("周囲が凡庸な雰囲気で満ちた...", "There is a static feeling in the air..."));
 
 #ifdef JP
-msg_format("%s は劣化した!",
-     o_name    );
+                       msg_format("%s は劣化した!", o_name);
 #else
-                       msg_format("%s %s %s disenchanted!",
-                           ((item >= 0) ? "Your" : "The"), o_name,
-                           ((o_ptr->number > 1) ? "were" : "was"));
+                       msg_format("%s %s %s disenchanted!", ((item >= 0) ? "Your" : "The"), o_name,
+                               ((o_ptr->number > 1) ? "were" : "was"));
 #endif
 
                }
        }
-       p_ptr->update |= (PU_BONUS);
 
+       p_ptr->update |= (PU_BONUS);
        p_ptr->window |= (PW_EQUIP | PW_PLAYER);
-
        calc_android_exp();
 
        return TRUE;
@@ -3080,10 +2989,10 @@ msg_format("%s は劣化した!",
 bool pulish_shield(void)
 {
        OBJECT_IDX item;
-       object_type     *o_ptr;
+       object_type *o_ptr;
        BIT_FLAGS flgs[TR_FLAG_SIZE];
        GAME_TEXT o_name[MAX_NLEN];
-       cptr            q, s;
+       concptr            q, s;
 
        /* Assume enchant weapon */
        item_tester_tval = TV_SHIELD;
@@ -3091,24 +3000,10 @@ bool pulish_shield(void)
        q = _("どの盾を磨きますか?", "Pulish which weapon? ");
        s = _("磨く盾がありません。", "You have weapon to pulish.");
 
-       if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT)))
-               return FALSE;
-
-       /* Get the item (in the pack) */
-       if (item >= 0)
-       {
-               o_ptr = &inventory[item];
-       }
-
-       /* Get the item (on the floor) */
-       else
-       {
-               o_ptr = &o_list[0 - item];
-       }
+       o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
+       if (!o_ptr) return FALSE;
 
        object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
-
-       /* Extract the flags */
        object_flags(o_ptr, flgs);
 
        if (o_ptr->k_idx && !object_is_artifact(o_ptr) && !object_is_ego(o_ptr) &&
@@ -3236,7 +3131,7 @@ bool potion_smash_effect(MONSTER_IDX who, POSITION y, POSITION x, KIND_OBJECT_ID
                        dt = GF_DARK;
                        angry = TRUE;
                        break;
-               case SV_POTION_CONFUSION: /* Booze */
+               case SV_POTION_BOOZE: /* Booze */
                        dt = GF_OLD_CONF;
                        angry = TRUE;
                        break;
@@ -3300,8 +3195,7 @@ bool potion_smash_effect(MONSTER_IDX who, POSITION y, POSITION x, KIND_OBJECT_ID
                        /* Do nothing */  ;
        }
 
-       (void)project(who, radius, y, x, dam, dt,
-           (PROJECT_JUMP | PROJECT_ITEM | PROJECT_KILL), -1);
+       (void)project(who, radius, y, x, dam, dt, (PROJECT_JUMP | PROJECT_ITEM | PROJECT_KILL), -1);
 
        /* XXX  those potions that explode need to become "known" */
        return angry;
@@ -3325,8 +3219,6 @@ void display_spell_list(void)
        GAME_TEXT name[MAX_NLEN];
        char out_val[160];
 
-
-       /* Erase window */
        clear_from(0);
 
        /* They have too many spells to list */
@@ -3807,7 +3699,7 @@ void print_spells(SPELL_IDX target_spell, SPELL_IDX *spells, int num, TERM_LEN y
        SPELL_IDX spell;
        int  exp_level, increment = 64;
        const magic_type *s_ptr;
-       cptr comment;
+       concptr comment;
        char info[80];
        char out_val[160];
        byte line_attr;
@@ -3970,7 +3862,7 @@ bool rustproof(void)
        OBJECT_IDX item;
        object_type *o_ptr;
        GAME_TEXT o_name[MAX_NLEN];
-       cptr        q, s;
+       concptr q, s;
 
        /* Select a piece of armour */
        item_tester_hook = object_is_armour;
@@ -3978,19 +3870,8 @@ bool rustproof(void)
        q = _("どの防具に錆止めをしますか?", "Rustproof which piece of armour? ");
        s = _("錆止めできるものがありません。", "You have nothing to rustproof.");
 
-       if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT))) return FALSE;
-
-       /* Get the item (in the pack) */
-       if (item >= 0)
-       {
-               o_ptr = &inventory[item];
-       }
-
-       /* Get the item (on the floor) */
-       else
-       {
-               o_ptr = &o_list[0 - item];
-       }
+       o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
+       if (!o_ptr) return FALSE;
 
        object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
 
@@ -4030,7 +3911,6 @@ bool curse_armor(void)
 
        GAME_TEXT o_name[MAX_NLEN];
 
-
        /* Curse the body armor */
        o_ptr = &inventory[INVEN_BODY];
 
@@ -4044,11 +3924,11 @@ bool curse_armor(void)
        {
                /* Cool */
 #ifdef JP
-msg_format("%sが%sを包み込もうとしたが、%sはそれを跳ね返した!",
-"恐怖の暗黒オーラ", "防具", o_name);
+               msg_format("%sが%sを包み込もうとしたが、%sはそれを跳ね返した!",
+                       "恐怖の暗黒オーラ", "防具", o_name);
 #else
                msg_format("A %s tries to %s, but your %s resists the effects!",
-                          "terrible black aura", "surround your armor", o_name);
+                       "terrible black aura", "surround your armor", o_name);
 #endif
 
        }
@@ -4077,11 +3957,7 @@ msg_format("%sが%sを包み込もうとしたが、%sはそれを跳ね返し
 
                /* Break it */
                o_ptr->ident |= (IDENT_BROKEN);
-               p_ptr->update |= (PU_BONUS);
-
-               /* Recalculate mana */
-               p_ptr->update |= (PU_MANA);
-
+               p_ptr->update |= (PU_BONUS | PU_MANA);
                p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
        }
 
@@ -4141,11 +4017,7 @@ bool curse_weapon_object(bool force, object_type *o_ptr)
 
                /* Break it */
                o_ptr->ident |= (IDENT_BROKEN);
-               p_ptr->update |= (PU_BONUS);
-
-               /* Recalculate mana */
-               p_ptr->update |= (PU_MANA);
-
+               p_ptr->update |= (PU_BONUS | PU_MANA);
                p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
        }
 
@@ -4227,8 +4099,7 @@ static MONRACE_IDX poly_r_idx(MONRACE_IDX r_idx)
        DEPTH lev1, lev2;
 
        /* Hack -- Uniques/Questors never polymorph */
-       if ((r_ptr->flags1 & RF1_UNIQUE) ||
-           (r_ptr->flags1 & RF1_QUESTOR))
+       if ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags1 & RF1_QUESTOR))
                return (r_idx);
 
        /* Allowable range of "levels" for resulting monster */
@@ -4346,12 +4217,10 @@ bool polymorph_monster(POSITION y, POSITION x)
                }
                else if (back_m.hold_o_idx) /* Failed (paranoia) */
                {
-                       /* Delete objects */
                        for (this_o_idx = back_m.hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
                        {
                                /* Acquire next object */
                                next_o_idx = o_list[this_o_idx].next_o_idx;
-
                                delete_object_idx(this_o_idx);
                        }
                }
@@ -4451,7 +4320,7 @@ bool eat_magic(int power)
        bool fail = FALSE;
        byte fail_type = 1;
 
-       cptr q, s;
+       concptr q, s;
        GAME_TEXT o_name[MAX_NLEN];
 
        item_tester_hook = item_tester_hook_recharge;
@@ -4459,16 +4328,8 @@ bool eat_magic(int power)
        q = _("どのアイテムから魔力を吸収しますか?", "Drain which item? ");
        s = _("魔力を吸収できるアイテムがありません。", "You have nothing to drain.");
 
-       if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return FALSE;
-
-       if (item >= 0)
-       {
-               o_ptr = &inventory[item];
-       }
-       else
-       {
-               o_ptr = &o_list[0 - item];
-       }
+       o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
+       if (!o_ptr) return FALSE;
 
        k_ptr = &k_info[o_ptr->k_idx];
        lev = k_info[o_ptr->k_idx].level;
@@ -4701,9 +4562,7 @@ bool eat_magic(int power)
                p_ptr->csp = p_ptr->msp;
        }
 
-       /* Redraw mana and hp */
        p_ptr->redraw |= (PR_MANA);
-
        p_ptr->update |= (PU_COMBINE | PU_REORDER);
        p_ptr->window |= (PW_INVEN);
 
@@ -4720,8 +4579,8 @@ bool eat_magic(int power)
 void massacre(void)
 {
        POSITION x, y;
-       cave_type       *c_ptr;
-       monster_type    *m_ptr;
+       cave_type *c_ptr;
+       monster_type *m_ptr;
        DIRECTION dir;
 
        for (dir = 0; dir < 8; dir++)
@@ -4729,8 +4588,6 @@ void massacre(void)
                y = p_ptr->y + ddy_ddd[dir];
                x = p_ptr->x + ddx_ddd[dir];
                c_ptr = &cave[y][x];
-
-               /* Get the monster */
                m_ptr = &m_list[c_ptr->m_idx];
 
                /* Hack -- attack monsters */
@@ -4795,7 +4652,6 @@ bool eat_lock(void)
        /* Destroy the wall */
        cave_alter_feat(y, x, FF_HURT_ROCK);
 
-       /* Move the player */
        (void)move_player_effect(y, x, MPE_DONT_PICKUP);
        return TRUE;
 }
@@ -4820,8 +4676,8 @@ bool shock_power(void)
        if (cave[y][x].m_idx)
        {
                int i;
-               int ty = y, tx = x;
-               int oy = y, ox = x;
+               POSITION ty = y, tx = x;
+               POSITION oy = y, ox = x;
                MONSTER_IDX m_idx = cave[y][x].m_idx;
                monster_type *m_ptr = &m_list[m_idx];
                monster_race *r_ptr = &r_info[m_ptr->r_idx];
@@ -4850,9 +4706,9 @@ bool shock_power(void)
                        {
                                msg_format(_("%sを吹き飛ばした!", "You blow %s away!"), m_name);
                                cave[oy][ox].m_idx = 0;
-                               cave[ty][tx].m_idx = (s16b)m_idx;
-                               m_ptr->fy = (byte_hack)ty;
-                               m_ptr->fx = (byte_hack)tx;
+                               cave[ty][tx].m_idx = m_idx;
+                               m_ptr->fy = ty;
+                               m_ptr->fx = tx;
 
                                update_monster(m_idx, TRUE);
                                lite_spot(oy, ox);
@@ -4864,4 +4720,49 @@ bool shock_power(void)
                }
        }
        return TRUE;
+}
+
+bool booze(player_type *creature_ptr)
+{
+       bool ident = FALSE;
+       if (creature_ptr->pclass != CLASS_MONK) chg_virtue(V_HARMONY, -1);
+       else if (!creature_ptr->resist_conf) creature_ptr->special_attack |= ATTACK_SUIKEN;
+       if (!creature_ptr->resist_conf)
+       {
+               if (set_confused(randint0(20) + 15))
+               {
+                       ident = TRUE;
+               }
+       }
+
+       if (!creature_ptr->resist_chaos)
+       {
+               if (one_in_(2))
+               {
+                       if (set_image(creature_ptr->image + randint0(150) + 150))
+                       {
+                               ident = TRUE;
+                       }
+               }
+               if (one_in_(13) && (creature_ptr->pclass != CLASS_MONK))
+               {
+                       ident = TRUE;
+                       if (one_in_(3)) lose_all_info();
+                       else wiz_dark();
+                       (void)teleport_player_aux(100, TELEPORT_NONMAGICAL | TELEPORT_PASSIVE);
+                       wiz_dark();
+                       msg_print(_("知らない場所で目が醒めた。頭痛がする。", "You wake up somewhere with a sore head..."));
+                       msg_print(_("何も思い出せない。どうやってここへ来たのかも分からない!", "You can't remember a thing, or how you got here!"));
+               }
+       }
+       return ident;
+}
+
+bool detonation(player_type *creature_ptr)
+{
+       msg_print(_("体の中で激しい爆発が起きた!", "Massive explosions rupture your body!"));
+       take_hit(DAMAGE_NOESCAPE, damroll(50, 20), _("爆発の薬", "a potion of Detonation"), -1);
+       (void)set_stun(creature_ptr->stun + 75);
+       (void)set_cut(creature_ptr->cut + 5000);
+       return TRUE;
 }
\ No newline at end of file