OSDN Git Service

[Refactor] #38824 get_item() を choose_object() に置換完了。 / Replaced get_item() to choose...
[hengband/hengband.git] / src / racial.c
index c209743..ae869d2 100644 (file)
@@ -14,7 +14,7 @@
 #include "cmd-magiceat.h"
 #include "cmd-zapwand.h"
 #include "cmd-pet.h"
-
+#include "melee.h"
 #include "object-hook.h"
 
 /*!
@@ -31,7 +31,7 @@ static bool do_cmd_archer(void)
        object_type     *q_ptr;
 
        char com[80];
-       char o_name[MAX_NLEN];
+       GAME_TEXT o_name[MAX_NLEN];
 
        q_ptr = &forge;
 
@@ -101,8 +101,6 @@ static bool do_cmd_archer(void)
                else
                {
                        s16b slot;
-
-                       /* Get local object */
                        q_ptr = &forge;
 
                        /* Hack -- Give the player some small firestones */
@@ -136,24 +134,11 @@ static bool do_cmd_archer(void)
 
                item_tester_hook = item_tester_hook_convertible;
 
-               /* Get an item */
                q = _("どのアイテムから作りますか? ", "Convert which item? ");
                s = _("材料を持っていない。", "You have no item to convert.");
-               if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return FALSE;
-
-               /* Get the item (in the pack) */
-               if (item >= 0)
-               {
-                       q_ptr = &inventory[item];
-               }
-
-               /* Get the item (on the floor) */
-               else
-               {
-                       q_ptr = &o_list[0 - item];
-               }
+               q_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
+               if (!q_ptr) return FALSE;
 
-               /* Get local object */
                q_ptr = &forge;
 
                /* Hack -- Give the player some small firestones */
@@ -195,24 +180,12 @@ static bool do_cmd_archer(void)
 
                item_tester_hook = item_tester_hook_convertible;
 
-               /* Get an item */
                q = _("どのアイテムから作りますか? ", "Convert which item? ");
                s = _("材料を持っていない。", "You have no item to convert.");
-               if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return FALSE;
 
-               /* Get the item (in the pack) */
-               if (item >= 0)
-               {
-                       q_ptr = &inventory[item];
-               }
-
-               /* Get the item (on the floor) */
-               else
-               {
-                       q_ptr = &o_list[0 - item];
-               }
+               q_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
+               if (!q_ptr) return FALSE;
 
-               /* Get local object */
                q_ptr = &forge;
 
                /* Hack -- Give the player some small firestones */
@@ -259,28 +232,16 @@ bool gain_magic(void)
        int ext = 0;
        cptr q, s;
        object_type *o_ptr;
-       char o_name[MAX_NLEN];
+       GAME_TEXT o_name[MAX_NLEN];
 
        /* Only accept legal items */
        item_tester_hook = item_tester_hook_recharge;
 
-       /* Get an item */
        q = _("どのアイテムの魔力を取り込みますか? ", "Gain power of which item? ");
        s = _("魔力を取り込めるアイテムがない。", "You have nothing to gain power.");
 
-       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);
 
        if (o_ptr->tval == TV_STAFF && o_ptr->sval == SV_STAFF_NOTHING)
        {
@@ -288,7 +249,6 @@ bool gain_magic(void)
                return FALSE;
        }
 
-
        if (!object_is_known(o_ptr))
        {
                msg_print(_("鑑定されていないと取り込めない。", "You need to identify before absorbing."));
@@ -335,7 +295,6 @@ bool gain_magic(void)
        }
 
        object_desc(o_name, o_ptr, 0);
-       /* Message */
        msg_format(_("%sの魔力を取り込んだ。", "You absorb magic of %s."), o_name);
 
        /* Eliminate the item (from the pack) */
@@ -399,8 +358,6 @@ static bool choose_kamae(void)
                msg_print(_("混乱していて構えられない!", "Too confused."));
                return FALSE;
        }
-
-       /* Save screen */
        screen_save();
        prt(_(" a) 構えをとく", " a) No form"), 2, 20);
 
@@ -504,8 +461,6 @@ static bool choose_kata(void)
                msg_print(_("体が震えて構えられない!", "You are trembling with fear!"));
                return FALSE;
        }
-
-       /* Save screen */
        screen_save();
        prt(_(" a) 型を崩す", " a) No Form"), 2, 20);
 
@@ -593,12 +548,12 @@ typedef struct power_desc_type power_desc_type;
  */
 struct power_desc_type
 {
-       char name[80];
-       PLAYER_LEVEL level;
-       int  cost;
-       int  stat;
-       int  fail;
-       int  number;
+       GAME_TEXT name[MAX_NLEN];      //!<レイシャル名
+       PLAYER_LEVEL level;     //!<体得レベル
+       int cost;
+       int stat;
+       int fail;
+       int number;
 };
 
 
@@ -607,10 +562,10 @@ struct power_desc_type
  * @param pd_ptr 発動したいレイシャル・パワー情報の構造体参照ポインタ
  * @return 成功率(%)を返す
  */
-static int racial_chance(power_desc_type *pd_ptr)
+static PERCENTAGE racial_chance(power_desc_type *pd_ptr)
 {
        PLAYER_LEVEL min_level  = pd_ptr->level;
-       int  difficulty = pd_ptr->fail;
+       int difficulty = pd_ptr->fail;
 
        int i;
        int val;
@@ -667,7 +622,7 @@ static int  racial_cost;
  */
 static int racial_aux(power_desc_type *pd_ptr)
 {
-       s16b min_level  = pd_ptr->level;
+       PLAYER_LEVEL min_level  = pd_ptr->level;
        int  use_stat   = pd_ptr->stat;
        int  difficulty = pd_ptr->fail;
        int  use_hp = 0;
@@ -727,8 +682,7 @@ static int racial_aux(power_desc_type *pd_ptr)
        p_ptr->energy_use = 100;
 
        /* Success? */
-       if (randint1(p_ptr->stat_cur[use_stat]) >=
-           ((difficulty / 2) + randint1(difficulty / 2)))
+       if (randint1(p_ptr->stat_cur[use_stat]) >= ((difficulty / 2) + randint1(difficulty / 2)))
        {
                return 1;
        }
@@ -747,8 +701,8 @@ static int racial_aux(power_desc_type *pd_ptr)
  */
 static bool cmd_racial_power_aux(s32b command)
 {
-       s16b        plev = p_ptr->lev;
-       int         dir = 0;
+       PLAYER_LEVEL plev = p_ptr->lev;
+       DIRECTION dir = 0;
 
        if (command <= -3)
        {
@@ -756,10 +710,11 @@ static bool cmd_racial_power_aux(s32b command)
                {
                case CLASS_WARRIOR:
                {
-                       int y = 0, x = 0, i;
-                       cave_type       *c_ptr;
+                       POSITION y = 0, x = 0;
+                       int i;
+                       cave_type *c_ptr;
 
-                       for (i = 0; i < 6; i++)
+                       for (i = 0; i < A_MAX; i++)
                        {
                                dir = randint0(8);
                                y = p_ptr->y + ddy_ddd[dir];
@@ -827,8 +782,7 @@ static bool cmd_racial_power_aux(s32b command)
                {
                        if (command == -3)
                        {
-                               int gain_sp = take_hit(DAMAGE_USELIFE, p_ptr->lev, 
-                                                               _("HPからMPへの無謀な変換", "thoughtless convertion from HP to SP"), -1) / 5;
+                               int gain_sp = take_hit(DAMAGE_USELIFE, p_ptr->lev, _("HPからMPへの無謀な変換", "thoughtless convertion from HP to SP"), -1) / 5;
                                if (gain_sp)
                                {
                                        p_ptr->csp += gain_sp;
@@ -937,8 +891,6 @@ static bool cmd_racial_power_aux(s32b command)
                                p_ptr->csp = p_ptr->msp;
                                p_ptr->csp_frac = 0;
                        }
-
-                       /* Redraw mana */
                        p_ptr->redraw |= (PR_MANA);
                        break;
                }
@@ -971,7 +923,7 @@ static bool cmd_racial_power_aux(s32b command)
                        }
                        else if (command == -4)
                        {
-                               project_hack(GF_CHARM_LIVING, p_ptr->lev);
+                               project_all_los(GF_CHARM_LIVING, p_ptr->lev);
                        }
                        break;
                }
@@ -1033,8 +985,6 @@ static bool cmd_racial_power_aux(s32b command)
                                        p_ptr->csp = max_csp;
                                        p_ptr->csp_frac = 0;
                                }
-
-                               /* Redraw mana */
                                p_ptr->redraw |= (PR_MANA);
                        }
                        else if (command == -4)
@@ -1064,7 +1014,7 @@ static bool cmd_racial_power_aux(s32b command)
                }
                case CLASS_CAVALRY:
                {
-                       char m_name[80];
+                       GAME_TEXT m_name[MAX_NLEN];
                        monster_type *m_ptr;
                        monster_race *r_ptr;
                        int rlev;
@@ -1143,8 +1093,6 @@ static bool cmd_racial_power_aux(s32b command)
                                                p_ptr->csp = p_ptr->msp;
                                                p_ptr->csp_frac = 0;
                                        }
-
-                                       /* Redraw mana */
                                        p_ptr->redraw |= (PR_MANA);
                                }
                                else
@@ -1193,12 +1141,7 @@ static bool cmd_racial_power_aux(s32b command)
                        int type = (one_in_(2) ? GF_NETHER : GF_FIRE);
                        if (!get_aim_dir(&dir)) return FALSE;
                        stop_mouth();
-#ifdef JP
-                       msg_format("あなたは%sのブレスを吐いた。",((type == GF_NETHER) ? "地獄" : "火炎"));
-#else
-                       msg_format("You breathe %s.",((type == GF_NETHER) ? "nether" : "fire"));
-#endif
-
+                       msg_format(_("あなたは%sのブレスを吐いた。", "You breathe %s."),((type == GF_NETHER) ? _("地獄", "nether") : _("火炎", "fire")));
                        fire_breath(type, dir, plev * 3, (plev / 15) + 1);
                        break;
                }
@@ -1224,8 +1167,6 @@ static bool cmd_racial_power_aux(s32b command)
                        {
                                object_type *q_ptr;
                                object_type forge;
-
-                               /* Get local object */
                                q_ptr = &forge;
 
                                /* Create the food ration */
@@ -1331,12 +1272,8 @@ static bool cmd_racial_power_aux(s32b command)
 
                case RACE_DRACONIAN:
                        {
-                               int  Type = (one_in_(3) ? GF_COLD : GF_FIRE);
-#ifdef JP
-                               cptr Type_desc = ((Type == GF_COLD) ? "冷気" : "炎");
-#else
-                               cptr Type_desc = ((Type == GF_COLD) ? "cold" : "fire");
-#endif
+                               int Type = (one_in_(3) ? GF_COLD : GF_FIRE);
+                               cptr Type_desc = ((Type == GF_COLD) ? _("冷気", "cold") : _("炎", "fire"));
 
                                if (!get_aim_dir(&dir)) return FALSE;
 
@@ -1519,12 +1456,7 @@ static bool cmd_racial_power_aux(s32b command)
                                int type = (one_in_(2) ? GF_NETHER : GF_FIRE);
                                if (!get_aim_dir(&dir)) return FALSE;
                                stop_mouth();
-#ifdef JP
-                               msg_format("あなたは%sのブレスを吐いた。",((type == GF_NETHER) ? "地獄" : "火炎"));
-#else
-                               msg_format("You breathe %s.",((type == GF_NETHER) ? "nether" : "fire"));
-#endif
-
+                               msg_format(_("あなたは%sのブレスを吐いた。", "You breathe %s."),((type == GF_NETHER) ? _("地獄", "nether") : _("火炎", "fire")));
                                fire_breath(type, dir, plev * 3, (plev / 15) + 1);
                        }
                        break;
@@ -1587,6 +1519,7 @@ void do_cmd_racial_power(void)
        char            out_val[160];
        int menu_line = (use_menu ? 1 : 0);
 
+       if (p_ptr->wild_mode) return;
 
        for (num = 0; num < 36; num++)
        {
@@ -2566,9 +2499,7 @@ void do_cmd_racial_power(void)
                                _("(特殊能力 %c-%c, *'で一覧, ESCで中断) どの特殊能力を使いますか?", "(Powers %c-%c, *=List, ESC=exit) Use which power? "),
                                I2A(0), (num <= 26) ? I2A(num - 1) : '0' + num - 27);
 
-#ifdef ALLOW_REPEAT
 if (!repeat_pull(&i) || i<0 || i>=num) {
-#endif /* ALLOW_REPEAT */
        if (use_menu) screen_save();
         /* Get a spell from the user */
 
@@ -2640,14 +2571,12 @@ if (!repeat_pull(&i) || i<0 || i>=num) {
                                int ctr = 0;
                                char dummy[80];
                                char letter;
-                               int x1, y1;
+                               TERM_LEN x1, y1;
 
                                strcpy(dummy, "");
 
                                /* Show list */
                                redraw = TRUE;
-
-                               /* Save the screen */
                                if (!use_menu) screen_save();
 
                                /* Print header(s) */
@@ -2691,8 +2620,6 @@ if (!repeat_pull(&i) || i<0 || i>=num) {
                        {
                                /* Hide list */
                                redraw = FALSE;
-
-                               /* Restore the screen */
                                screen_load();
                        }
 
@@ -2748,8 +2675,6 @@ if (!repeat_pull(&i) || i<0 || i>=num) {
                /* Stop the loop */
                flag = TRUE;
        }
-
-       /* Restore the screen */
        if (redraw) screen_load();
 
        /* Abort if needed */
@@ -2758,10 +2683,8 @@ if (!repeat_pull(&i) || i<0 || i>=num) {
                p_ptr->energy_use = 0;
                return;
        }
-#ifdef ALLOW_REPEAT
        repeat_push(i);
        } /*if (!repeat_pull(&i) || ...)*/
-#endif /* ALLOW_REPEAT */
        switch (racial_aux(&power_desc[i]))
        {
        case 1:
@@ -2796,7 +2719,6 @@ if (!repeat_pull(&i) || i<0 || i>=num) {
                        /* Redraw mana and hp */
                        p_ptr->redraw |= (PR_HP | PR_MANA);
 
-                       /* Window stuff */
                        p_ptr->window |= (PW_PLAYER | PW_SPELL);
                }
        }