OSDN Git Service

Merge branch 'master' of git.sourceforge.jp:/gitroot/hengband/hengband
[hengband/hengband.git] / src / cmd6.c
index e07f024..ecd16c9 100644 (file)
@@ -84,7 +84,7 @@ static void do_cmd_eat_food_aux(int item)
        sound(SOUND_EAT);
 
        /* Take a turn */
-       energy_use = 100;
+       p_ptr->energy_use = 100;
 
        /* Identity not known yet */
        ident = FALSE;
@@ -502,7 +502,7 @@ static void do_cmd_eat_food_aux(int item)
                        object_prep(q_ptr, lookup_kind(o_ptr->tval, o_ptr->sval));
 
                        /* Drop the object from heaven */
-                       (void)drop_near(q_ptr, -1, py, px);
+                       (void)drop_near(q_ptr, -1, p_ptr->y, p_ptr->x);
                }
                else
                {
@@ -598,7 +598,7 @@ static bool item_tester_hook_eatable(object_type *o_ptr)
  */
 void do_cmd_eat_food(void)
 {
-       int         item;
+       OBJECT_IDX item;
        cptr        q, s;
 
 
@@ -636,7 +636,7 @@ static void do_cmd_quaff_potion_aux(int item)
 
 
        /* Take a turn */
-       energy_use = 100;
+       p_ptr->energy_use = 100;
 
        if (world_player)
        {
@@ -1026,7 +1026,7 @@ static void do_cmd_quaff_potion_aux(int item)
                                }
                                for (; i < EATER_EXT*3; i++)
                                {
-                                       int k_idx = lookup_kind(TV_ROD, i-EATER_EXT*2);
+                                       KIND_OBJECT_IDX k_idx = lookup_kind(TV_ROD, i-EATER_EXT*2);
                                        p_ptr->magic_num1[i] -= ((p_ptr->magic_num2[i] < 10) ? EATER_ROD_CHARGE*3 : p_ptr->magic_num2[i]*EATER_ROD_CHARGE/3)*k_info[k_idx].pval;
                                        if (p_ptr->magic_num1[i] < 0) p_ptr->magic_num1[i] = 0;
                                }
@@ -1184,15 +1184,7 @@ static void do_cmd_quaff_potion_aux(int item)
                        do_cmd_rerate(FALSE);
                        get_max_stats();
                        p_ptr->update |= PU_BONUS;
-                       if (p_ptr->muta1 || p_ptr->muta2 || p_ptr->muta3)
-                       {
-                               chg_virtue(V_CHANCE, -5);
-                               msg_print(_("全ての突然変異が治った。", "You are cured of all mutations."));
-                               p_ptr->muta1 = p_ptr->muta2 = p_ptr->muta3 = 0;
-                               p_ptr->update |= PU_BONUS;
-                               handle_stuff();
-                               mutant_regenerate_mod = calc_mutant_regenerate_mod();
-                       }
+                       lose_all_mutations();
                        ident = TRUE;
                        break;
 
@@ -1217,11 +1209,7 @@ static void do_cmd_quaff_potion_aux(int item)
                case SV_POTION_POLYMORPH:
                        if ((p_ptr->muta1 || p_ptr->muta2 || p_ptr->muta3) && one_in_(23))
                        {
-                               chg_virtue(V_CHANCE, -5);
-                               msg_print(_("全ての突然変異が治った。", "You are cured of all mutations."));
-                               p_ptr->muta1 = p_ptr->muta2 = p_ptr->muta3 = 0;
-                               p_ptr->update |= PU_BONUS;
-                               handle_stuff();
+                               lose_all_mutations();
                        }
                        else
                        {
@@ -1241,7 +1229,7 @@ static void do_cmd_quaff_potion_aux(int item)
        if (prace_is_(RACE_SKELETON))
        {
                msg_print(_("液体の一部はあなたのアゴを素通りして落ちた!", "Some of the fluid falls through your jaws!"));
-               (void)potion_smash_effect(0, py, px, q_ptr->k_idx);
+               (void)potion_smash_effect(0, p_ptr->y, p_ptr->x, q_ptr->k_idx);
        }
 
        /* Combine / Reorder the pack (later) */
@@ -1345,7 +1333,7 @@ static bool item_tester_hook_quaff(object_type *o_ptr)
  */
 void do_cmd_quaff_potion(void)
 {
-       int  item;
+       OBJECT_IDX item;
        cptr q, s;
 
        if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
@@ -1400,7 +1388,7 @@ static void do_cmd_read_scroll_aux(int item, bool known)
 
 
        /* Take a turn */
-       energy_use = 100;
+       p_ptr->energy_use = 100;
 
        if (world_player)
        {
@@ -1476,7 +1464,7 @@ static void do_cmd_read_scroll_aux(int item, bool known)
                {
                        for (k = 0; k < randint1(3); k++)
                        {
-                               if (summon_specific(0, py, px, dun_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
+                               if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
                                {
                                        ident = TRUE;
                                }
@@ -1488,7 +1476,7 @@ static void do_cmd_read_scroll_aux(int item, bool known)
                {
                        for (k = 0; k < randint1(3); k++)
                        {
-                               if (summon_specific(0, py, px, dun_level, SUMMON_UNDEAD, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
+                               if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, SUMMON_UNDEAD, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
                                {
                                        ident = TRUE;
                                }
@@ -1498,7 +1486,7 @@ static void do_cmd_read_scroll_aux(int item, bool known)
 
                case SV_SCROLL_SUMMON_PET:
                {
-                       if (summon_specific(-1, py, px, dun_level, 0, (PM_ALLOW_GROUP | PM_FORCE_PET)))
+                       if (summon_specific(-1, p_ptr->y, p_ptr->x, dun_level, 0, (PM_ALLOW_GROUP | PM_FORCE_PET)))
                        {
                                ident = TRUE;
                        }
@@ -1507,7 +1495,7 @@ static void do_cmd_read_scroll_aux(int item, bool known)
 
                case SV_SCROLL_SUMMON_KIN:
                {
-                       if (summon_kin_player(p_ptr->lev, py, px, (PM_FORCE_PET | PM_ALLOW_GROUP)))
+                       if (summon_kin_player(p_ptr->lev, p_ptr->y, p_ptr->x, (PM_FORCE_PET | PM_ALLOW_GROUP)))
                        {
                                ident = TRUE;
                        }
@@ -1516,7 +1504,7 @@ static void do_cmd_read_scroll_aux(int item, bool known)
 
                case SV_SCROLL_TRAP_CREATION:
                {
-                       if (trap_creation(py, px)) ident = TRUE;
+                       if (trap_creation(p_ptr->y, p_ptr->x)) ident = TRUE;
                        break;
                }
 
@@ -1734,7 +1722,7 @@ static void do_cmd_read_scroll_aux(int item, bool known)
 
                case SV_SCROLL_STAR_DESTRUCTION:
                {
-                       if (destroy_area(py, px, 13 + randint0(5), FALSE))
+                       if (destroy_area(p_ptr->y, p_ptr->x, 13 + randint0(5), FALSE))
                                ident = TRUE;
                        else
                                msg_print(_("ダンジョンが揺れた...", "The dungeon trembles..."));
@@ -1787,14 +1775,14 @@ static void do_cmd_read_scroll_aux(int item, bool known)
 
                case SV_SCROLL_ACQUIREMENT:
                {
-                       acquirement(py, px, 1, TRUE, FALSE, FALSE);
+                       acquirement(p_ptr->y, p_ptr->x, 1, TRUE, FALSE, FALSE);
                        ident = TRUE;
                        break;
                }
 
                case SV_SCROLL_STAR_ACQUIREMENT:
                {
-                       acquirement(py, px, randint1(2) + 1, TRUE, FALSE, FALSE);
+                       acquirement(p_ptr->y, p_ptr->x, randint1(2) + 1, TRUE, FALSE, FALSE);
                        ident = TRUE;
                        break;
                }
@@ -1861,14 +1849,14 @@ static void do_cmd_read_scroll_aux(int item, bool known)
                case SV_SCROLL_AMUSEMENT:
                {
                        ident = TRUE;
-                       amusement(py, px, 1, FALSE);
+                       amusement(p_ptr->y, p_ptr->x, 1, FALSE);
                        break;
                }
 
                case SV_SCROLL_STAR_AMUSEMENT:
                {
                        ident = TRUE;
-                       amusement(py, px,  randint1(2) + 1, FALSE);
+                       amusement(p_ptr->y, p_ptr->x,  randint1(2) + 1, FALSE);
                        break;
                }
        }
@@ -1988,7 +1976,7 @@ static bool item_tester_hook_readable(object_type *o_ptr)
 void do_cmd_read_scroll(void)
 {
        object_type *o_ptr;
-       int  item;
+       OBJECT_IDX item;
        cptr q, s;
 
        if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
@@ -2048,7 +2036,7 @@ void do_cmd_read_scroll(void)
  * @param known 判明済ならばTRUE
  * @return 発動により効果内容が確定したならばTRUEを返す
  */
-static int staff_effect(int sval, bool *use_charge, bool powerful, bool magic, bool known)
+static int staff_effect(OBJECT_SUBTYPE_VALUE sval, bool *use_charge, bool powerful, bool magic, bool known)
 {
        int k;
        int ident = FALSE;
@@ -2085,7 +2073,7 @@ static int staff_effect(int sval, bool *use_charge, bool powerful, bool magic, b
                        const int times = randint1(powerful ? 8 : 4);
                        for (k = 0; k < times; k++)
                        {
-                               if (summon_specific(0, py, px, dun_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
+                               if (summon_specific(0, p_ptr->y, p_ptr->x, dun_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
                                {
                                        ident = TRUE;
                                }
@@ -2132,8 +2120,8 @@ static int staff_effect(int sval, bool *use_charge, bool powerful, bool magic, b
 
                case SV_STAFF_STARLITE:
                {
-                       int num = damroll(5, 3);
-                       int y = 0, x = 0;
+                       HIT_POINT num = damroll(5, 3);
+                       POSITION y = 0, x = 0;
                        int attempts;
 
                        if (!p_ptr->blind && !magic)
@@ -2146,7 +2134,7 @@ static int staff_effect(int sval, bool *use_charge, bool powerful, bool magic, b
 
                                while (attempts--)
                                {
-                                       scatter(&y, &x, py, px, 4, 0);
+                                       scatter(&y, &x, p_ptr->y, p_ptr->x, 4, 0);
 
                                        if (!cave_have_flag_bold(y, x, FF_PROJECT)) continue;
 
@@ -2321,7 +2309,7 @@ static int staff_effect(int sval, bool *use_charge, bool powerful, bool magic, b
 
                case SV_STAFF_EARTHQUAKES:
                {
-                       if (earthquake(py, px, (powerful ? 15 : 10)))
+                       if (earthquake(p_ptr->y, p_ptr->x, (powerful ? 15 : 10)))
                                ident = TRUE;
                        else
                                msg_print(_("ダンジョンが揺れた。", "The dungeon trembles."));
@@ -2331,7 +2319,7 @@ static int staff_effect(int sval, bool *use_charge, bool powerful, bool magic, b
 
                case SV_STAFF_DESTRUCTION:
                {
-                       if (destroy_area(py, px, (powerful ? 18 : 13) + randint0(5), FALSE))
+                       if (destroy_area(p_ptr->y, p_ptr->x, (powerful ? 18 : 13) + randint0(5), FALSE))
                                ident = TRUE;
 
                        break;
@@ -2339,7 +2327,7 @@ static int staff_effect(int sval, bool *use_charge, bool powerful, bool magic, b
 
                case SV_STAFF_ANIMATE_DEAD:
                {
-                       if (animate_dead(0, py, px))
+                       if (animate_dead(0, p_ptr->y, p_ptr->x))
                                ident = TRUE;
 
                        break;
@@ -2348,7 +2336,7 @@ static int staff_effect(int sval, bool *use_charge, bool powerful, bool magic, b
                case SV_STAFF_MSTORM:
                {
                        msg_print(_("強力な魔力が敵を引き裂いた!", "Mighty magics rend your enemies!"));
-                       project(0, (powerful ? 7 : 5), py, px,
+                       project(0, (powerful ? 7 : 5), p_ptr->y, p_ptr->x,
                                (randint1(200) + (powerful ? 500 : 300)) * 2, GF_MANA, PROJECT_KILL | PROJECT_ITEM | PROJECT_GRID, -1);
                        if ((p_ptr->pclass != CLASS_MAGE) && (p_ptr->pclass != CLASS_HIGH_MAGE) && (p_ptr->pclass != CLASS_SORCERER) && (p_ptr->pclass != CLASS_MAGIC_EATER) && (p_ptr->pclass != CLASS_BLUE_MAGE))
                        {
@@ -2412,7 +2400,7 @@ static void do_cmd_use_staff_aux(int item)
 
 
        /* Take a turn */
-       energy_use = 100;
+       p_ptr->energy_use = 100;
 
        /* Extract the item level */
        lev = k_info[o_ptr->k_idx].level;
@@ -2547,7 +2535,7 @@ static void do_cmd_use_staff_aux(int item)
  */
 void do_cmd_use_staff(void)
 {
-       int  item;
+       OBJECT_IDX item;
        cptr q, s;
 
        if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
@@ -2575,7 +2563,7 @@ void do_cmd_use_staff(void)
  * @param magic 魔道具術上の処理ならばTRUE
  * @return 発動により効果内容が確定したならばTRUEを返す
  */
-static int wand_effect(int sval, int dir, bool powerful, bool magic)
+static int wand_effect(OBJECT_SUBTYPE_VALUE sval, int dir, bool powerful, bool magic)
 {
        int ident = FALSE;
        int lev = powerful ? p_ptr->lev * 2 : p_ptr->lev;
@@ -2585,7 +2573,7 @@ static int wand_effect(int sval, int dir, bool powerful, bool magic)
        if (sval == SV_WAND_WONDER)
        {
                int vir = virtue_number(V_CHANCE);
-               sval = randint0(SV_WAND_WONDER);
+               sval = (OBJECT_SUBTYPE_VALUE)randint0(SV_WAND_WONDER);
 
                if (vir)
                {
@@ -2609,7 +2597,7 @@ static int wand_effect(int sval, int dir, bool powerful, bool magic)
        {
                case SV_WAND_HEAL_MONSTER:
                {
-                       int dam = damroll((powerful ? 20 : 10), 10);
+                       HIT_POINT dam = damroll((powerful ? 20 : 10), 10);
                        if (heal_monster(dir, dam)) ident = TRUE;
                        break;
                }
@@ -2649,14 +2637,14 @@ static int wand_effect(int sval, int dir, bool powerful, bool magic)
 
                case SV_WAND_STONE_TO_MUD:
                {
-                       int dam = powerful ? 40 + randint1(60) : 20 + randint1(30);
+                       HIT_POINT dam = powerful ? 40 + randint1(60) : 20 + randint1(30);
                        if (wall_to_mud(dir, dam)) ident = TRUE;
                        break;
                }
 
                case SV_WAND_LITE:
                {
-                       int dam = damroll((powerful ? 12 : 6), 8);
+                       HIT_POINT dam = damroll((powerful ? 12 : 6), 8);
                        msg_print(_("青く輝く光線が放たれた。", "A line of blue shimmering light appears."));
                        (void)lite_line(dir, dam);
                        ident = TRUE;
@@ -2687,9 +2675,9 @@ static int wand_effect(int sval, int dir, bool powerful, bool magic)
                        break;
                }
 
-               case SV_WAND_DRAIN_LIFE:
+               case SV_WAND_HYPODYNAMIA:
                {
-                       if (drain_life(dir, 80 + lev)) ident = TRUE;
+                       if (hypodynamic_bolt(dir, 80 + lev)) ident = TRUE;
                        break;
                }
 
@@ -2777,21 +2765,21 @@ static int wand_effect(int sval, int dir, bool powerful, bool magic)
 
                case SV_WAND_DRAGON_FIRE:
                {
-                       fire_ball(GF_FIRE, dir, (powerful ? 300 : 200), -3);
+                       fire_breath(GF_FIRE, dir, (powerful ? 300 : 200), 3);
                        ident = TRUE;
                        break;
                }
 
                case SV_WAND_DRAGON_COLD:
                {
-                       fire_ball(GF_COLD, dir, (powerful ? 270 : 180), -3);
+                       fire_breath(GF_COLD, dir, (powerful ? 270 : 180), 3);
                        ident = TRUE;
                        break;
                }
 
                case SV_WAND_DRAGON_BREATH:
                {
-                       int dam;
+                       HIT_POINT dam;
                        int typ;
 
                        switch (randint1(5))
@@ -2917,7 +2905,7 @@ static void do_cmd_aim_wand_aux(int item)
        target_pet = old_target_pet;
 
        /* Take a turn */
-       energy_use = 100;
+       p_ptr->energy_use = 100;
 
        /* Get the level */
        lev = k_info[o_ptr->k_idx].level;
@@ -3020,7 +3008,7 @@ static void do_cmd_aim_wand_aux(int item)
  */
 void do_cmd_aim_wand(void)
 {
-       int     item;
+       OBJECT_IDX item;
        cptr    q, s;
 
        /* Restrict choices to wands */
@@ -3050,7 +3038,7 @@ void do_cmd_aim_wand(void)
  * @param magic 魔道具術上の処理ならばTRUE
  * @return 発動により効果内容が確定したならばTRUEを返す
  */
-static int rod_effect(int sval, int dir, bool *use_charge, bool powerful, bool magic)
+static int rod_effect(OBJECT_SUBTYPE_VALUE sval, int dir, bool *use_charge, bool powerful, bool magic)
 {
        int ident = FALSE;
        int lev = powerful ? p_ptr->lev * 2 : p_ptr->lev;
@@ -3182,7 +3170,7 @@ static int rod_effect(int sval, int dir, bool *use_charge, bool powerful, bool m
 
                case SV_ROD_LITE:
                {
-                       int dam = damroll((powerful ? 12 : 6), 8);
+                       HIT_POINT dam = damroll((powerful ? 12 : 6), 8);
                        msg_print(_("青く輝く光線が放たれた。", "A line of blue shimmering light appears."));
                        (void)lite_line(dir, dam);
                        ident = TRUE;
@@ -3201,9 +3189,9 @@ static int rod_effect(int sval, int dir, bool *use_charge, bool powerful, bool m
                        break;
                }
 
-               case SV_ROD_DRAIN_LIFE:
+               case SV_ROD_HYPODYNAMIA:
                {
-                       if (drain_life(dir, 70 + 3 * lev / 2)) ident = TRUE;
+                       if (hypodynamic_bolt(dir, 70 + 3 * lev / 2)) ident = TRUE;
                        break;
                }
 
@@ -3278,7 +3266,7 @@ static int rod_effect(int sval, int dir, bool *use_charge, bool powerful, bool m
 
                case SV_ROD_STONE_TO_MUD:
                {
-                       int dam = powerful ? 40 + randint1(60) : 20 + randint1(30);
+                       HIT_POINT dam = powerful ? 40 + randint1(60) : 20 + randint1(30);
                        if (wall_to_mud(dir, dam)) ident = TRUE;
                        break;
                }
@@ -3349,7 +3337,7 @@ static void do_cmd_zap_rod_aux(int item)
 
 
        /* Take a turn */
-       energy_use = 100;
+       p_ptr->energy_use = 100;
 
        /* Extract the item level */
        lev = k_info[o_ptr->k_idx].level;
@@ -3450,7 +3438,7 @@ static void do_cmd_zap_rod_aux(int item)
  */
 void do_cmd_zap_rod(void)
 {
-       int item;
+       OBJECT_IDX item;
        cptr q, s;
 
        if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
@@ -3635,7 +3623,7 @@ static void do_cmd_activate_aux(int item)
        }
 
        /* Take a turn */
-       energy_use = 100;
+       p_ptr->energy_use = 100;
 
        /* Extract the item level */
        lev = k_info[o_ptr->k_idx].level;
@@ -3704,7 +3692,7 @@ static void do_cmd_activate_aux(int item)
                ((o_ptr->sval == SV_LITE_TORCH) || (o_ptr->sval == SV_LITE_LANTERN)))
        {
                msg_print(_("燃料がない。", "It has no fuel."));
-               energy_use = 0;
+               p_ptr->energy_use = 0;
                return;
        }
 
@@ -3741,13 +3729,13 @@ static void do_cmd_activate_aux(int item)
                else
 #endif
                {
-                       int pet_ctr, i;
-                       u16b *who;
+                       IDX pet_ctr, i;
+                       IDX *who;
                        int max_pet = 0;
                        u16b dummy_why;
 
                        /* Allocate the "who" array */
-                       C_MAKE(who, max_m_idx, u16b);
+                       C_MAKE(who, max_m_idx, IDX);
 
                        /* Process the monsters (backwards) */
                        for (pet_ctr = m_max - 1; pet_ctr >= 1; pet_ctr--)
@@ -3766,11 +3754,11 @@ static void do_cmd_activate_aux(int item)
                        for (i = 0; i < max_pet; i++)
                        {
                                pet_ctr = who[i];
-                               teleport_monster_to(pet_ctr, py, px, 100, TELEPORT_PASSIVE);
+                               teleport_monster_to(pet_ctr, p_ptr->y, p_ptr->x, 100, TELEPORT_PASSIVE);
                        }
 
                        /* Free the "who" array */
-                       C_KILL(who, max_m_idx, u16b);
+                       C_KILL(who, max_m_idx, IDX);
                }
                o_ptr->timeout = 100+randint1(100);
                return;
@@ -3790,10 +3778,10 @@ static void do_cmd_activate_aux(int item)
 
                        if(fire_ball(GF_CAPTURE, dir, 0, 0))
                        {
-                               o_ptr->pval = cap_mon;
-                               o_ptr->xtra3 = cap_mspeed;
-                               o_ptr->xtra4 = cap_hp;
-                               o_ptr->xtra5 = cap_maxhp;
+                               o_ptr->pval = (PARAMETER_VALUE)cap_mon;
+                               o_ptr->xtra3 = (XTRA8)cap_mspeed;
+                               o_ptr->xtra4 = (XTRA16)cap_hp;
+                               o_ptr->xtra5 = (XTRA16)cap_maxhp;
                                if (cap_nickname)
                                {
                                        cptr t;
@@ -3835,11 +3823,11 @@ static void do_cmd_activate_aux(int item)
                }
                else
                {
-                       bool success = FALSE;
+                       success = FALSE;
                        if (!get_rep_dir2(&dir)) return;
-                       if (monster_can_enter(py + ddy[dir], px + ddx[dir], &r_info[o_ptr->pval], 0))
+                       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, py + ddy[dir], px + ddx[dir], o_ptr->pval, (PM_FORCE_PET | PM_NO_KAGE)))
+                               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 (o_ptr->xtra3) m_list[hack_m_idx_ii].mspeed = o_ptr->xtra3;
                                        if (o_ptr->xtra5) m_list[hack_m_idx_ii].max_maxhp = o_ptr->xtra5;
@@ -3909,6 +3897,7 @@ static void do_cmd_activate_aux(int item)
                        if (!success)
                                msg_print(_("おっと、解放に失敗した。", "Oops.  You failed to release your pet."));
                }
+               calc_android_exp();
                return;
        }
 
@@ -3922,7 +3911,7 @@ static void do_cmd_activate_aux(int item)
  */
 void do_cmd_activate(void)
 {
-       int     item;
+       OBJECT_IDX item;
        cptr    q, s;
 
 
@@ -4010,7 +3999,7 @@ static bool item_tester_hook_use(object_type *o_ptr)
  */
 void do_cmd_use(void)
 {
-       int         item;
+       OBJECT_IDX item;
        object_type *o_ptr;
        cptr        q, s;
 
@@ -4131,19 +4120,20 @@ void do_cmd_use(void)
  * @param only_browse 閲覧するだけならばTRUE
  * @return 選択した魔力のID、キャンセルならば-1を返す
  */
-static int select_magic_eater(bool only_browse)
+static OBJECT_SUBTYPE_VALUE select_magic_eater(bool only_browse)
 {
-       int ext=0;
+       OBJECT_SUBTYPE_VALUE ext = 0;
        char choice;
        bool flag, request_list;
-       int tval = 0;
-       int             ask = TRUE, i = 0;
+       OBJECT_TYPE_VALUE tval = 0;
+       int             ask = TRUE;
+       OBJECT_SUBTYPE_VALUE i = 0;
        char            out_val[160];
 
        int menu_line = (use_menu ? 1 : 0);
 
 #ifdef ALLOW_REPEAT
-       int sn;
+       COMMAND_CODE sn;
        if (repeat_pull(&sn))
        {
                /* Verify the spell */
@@ -4278,10 +4268,12 @@ static int select_magic_eater(bool only_browse)
                if (request_list || use_menu)
                {
                        byte y, x = 0;
-                       int ctr, chance;
-                       int k_idx;
+                       OBJECT_SUBTYPE_VALUE ctr;
+                       PERCENTAGE chance;
+                       IDX k_idx;
                        char dummy[80];
-                       int x1, y1, level;
+                       POSITION x1, y1;
+                       int level;
                        byte col;
 
                        strcpy(dummy, "");
@@ -4477,7 +4469,7 @@ static int select_magic_eater(bool only_browse)
                                ask = (isupper(choice));
 
                                /* Lowercase */
-                               if (ask) choice = tolower(choice);
+                               if (ask) choice = (char)tolower(choice);
 
                                /* Extract request */
                                i = (islower(choice) ? A2I(choice) : -1);
@@ -4579,7 +4571,12 @@ static int select_magic_eater(bool only_browse)
  */
 bool do_cmd_magic_eater(bool only_browse, bool powerful)
 {
-       int item, chance, level, k_idx, tval, sval;
+       OBJECT_SUBTYPE_VALUE item;
+       PERCENTAGE chance;
+       DEPTH level;
+       IDX k_idx;
+       OBJECT_TYPE_VALUE tval;
+       OBJECT_SUBTYPE_VALUE sval;
        bool use_charge = TRUE;
 
        /* Not when confused */
@@ -4592,12 +4589,12 @@ bool do_cmd_magic_eater(bool only_browse, bool powerful)
        item = select_magic_eater(only_browse);
        if (item == -1)
        {
-               energy_use = 0;
+               p_ptr->energy_use = 0;
                return FALSE;
        }
        if (item >= EATER_EXT*2) {tval = TV_ROD;sval = item - EATER_EXT*2;}
        else if (item >= EATER_EXT) {tval = TV_WAND;sval = item - EATER_EXT;}
-       else {tval = TV_STAFF;sval = item;}
+       else {tval = TV_STAFF; sval = item;}
        k_idx = lookup_kind(tval, sval);
 
        level = (tval == TV_ROD ? k_info[k_idx].level * 5 / 6 - 5 : k_info[k_idx].level);
@@ -4626,7 +4623,7 @@ bool do_cmd_magic_eater(bool only_browse, bool powerful)
                sound(SOUND_FAIL);
                if (randint1(100) >= chance)
                        chg_virtue(V_CHANCE,-1);
-               energy_use = 100;
+               p_ptr->energy_use = 100;
 
                return TRUE;
        }
@@ -4654,7 +4651,7 @@ bool do_cmd_magic_eater(bool only_browse, bool powerful)
                if (randint1(100) < chance)
                        chg_virtue(V_CHANCE,1);
        }
-       energy_use = 100;
+       p_ptr->energy_use = 100;
        if (tval == TV_ROD) p_ptr->magic_num1[item] += k_info[k_idx].pval * EATER_ROD_CHARGE;
        else p_ptr->magic_num1[item] -= EATER_CHARGE;