OSDN Git Service

[Refactor] #37353 混乱時のコマンド制限処理を cmd_limit_confused() に統合。 / Integrate command limitat...
[hengband/hengband.git] / src / racial.c
index 12e5f2e..ef6bca7 100644 (file)
@@ -21,6 +21,8 @@
 #include "player-status.h"
 #include "spells-status.h"
 #include "spells-object.h"
+#include "cmd-spell.h"
+#include "realm-hex.h"
 
 /*!
  * @brief 魔法系コマンドを実行できるかの判定を返す
@@ -59,11 +61,7 @@ static bool choose_kamae(void)
        int i;
        char buf[80];
 
-       if (p_ptr->confused)
-       {
-               msg_print(_("混乱していて構えられない!", "Too confused."));
-               return FALSE;
-       }
+       if (cmd_limit_confused(p_ptr)) return FALSE;
        screen_save();
        prt(_(" a) 構えをとく", " a) No form"), 2, 20);
 
@@ -150,11 +148,7 @@ static bool choose_kata(void)
        int i;
        char buf[80];
 
-       if (p_ptr->confused)
-       {
-               msg_print(_("混乱していて構えられない!", "Too confused."));
-               return FALSE;
-       }
+       if (cmd_limit_confused(p_ptr)) return FALSE;
 
        if (p_ptr->stun)
        {
@@ -343,15 +337,13 @@ static int racial_aux(power_desc_type *pd_ptr)
                                         "You need to attain level %d to use this power."), min_level);
 
                p_ptr->energy_use = 0;
-               return 0;
+               return FALSE;
        }
 
-       /* Too confused */
-       else if (p_ptr->confused)
+       if (cmd_limit_confused(p_ptr))
        {
-               msg_print(_("混乱していてその能力は使えない。", "You are too confused to use this power."));
                p_ptr->energy_use = 0;
-               return 0;
+               return FALSE;
        }
 
        /* Risk death? */
@@ -360,7 +352,7 @@ static int racial_aux(power_desc_type *pd_ptr)
                if (!get_check(_("本当に今の衰弱した状態でこの能力を使いますか?", "Really use the power in your weakened state? ")))
                {
                        p_ptr->energy_use = 0;
-                       return 0;
+                       return FALSE;
                }
        }
 
@@ -414,25 +406,7 @@ static bool cmd_racial_power_aux(s32b command)
                {
                case CLASS_WARRIOR:
                {
-                       POSITION y = 0, x = 0;
-                       int i;
-                       cave_type *c_ptr;
-
-                       for (i = 0; i < A_MAX; i++)
-                       {
-                               dir = randint0(8);
-                               y = p_ptr->y + ddy_ddd[dir];
-                               x = p_ptr->x + ddx_ddd[dir];
-                               c_ptr = &cave[y][x];
-
-                               /* Hack -- attack monsters */
-                               if (c_ptr->m_idx)
-                                       py_attack(y, x, 0);
-                               else
-                               {
-                                       msg_print(_("攻撃が空をきった。", "You attack the empty air."));
-                               }
-                       }
+                       return sword_dancing(p_ptr);
                        break;
                }
                case CLASS_HIGH_MAGE:
@@ -486,47 +460,17 @@ 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;
-                               if (gain_sp)
-                               {
-                                       p_ptr->csp += gain_sp;
-                                       if (p_ptr->csp > p_ptr->msp)
-                                       {
-                                               p_ptr->csp = p_ptr->msp;
-                                               p_ptr->csp_frac = 0;
-                                       }
-                               }
-                               else
-                               {
-                                       msg_print(_("変換に失敗した。", "You failed to convert."));
-                               }
+                               return comvert_hp_to_mp(p_ptr);
                        }
                        else if (command == -4)
                        {
-                               if (p_ptr->csp >= p_ptr->lev / 5)
-                               {
-                                       p_ptr->csp -= p_ptr->lev / 5;
-                                       hp_player(p_ptr->lev);
-                               }
-                               else
-                               {
-                                       msg_print(_("変換に失敗した。", "You failed to convert."));
-                               }
+                               return comvert_mp_to_hp(p_ptr);
                        }
-
-                       /* Redraw mana and hp */
-                       p_ptr->redraw |= (PR_HP | PR_MANA);
-
                        break;
                }
                case CLASS_CHAOS_WARRIOR:
                {
-                       msg_print(_("辺りを睨んだ...", "You glare nearby monsters..."));
-                       slow_monsters(p_ptr->lev);
-                       stun_monsters(p_ptr->lev * 4);
-                       confuse_monsters(p_ptr->lev * 4);
-                       turn_monsters(p_ptr->lev * 4);
-                       stasis_monsters(p_ptr->lev * 4);
+                       return confusing_light(p_ptr);
                        break;
                }
                case CLASS_MONK:
@@ -549,54 +493,14 @@ static bool cmd_racial_power_aux(s32b command)
                        }
                        else if (command == -4)
                        {
-                               POSITION x, y;
-
-                               if (!get_rep_dir(&dir, FALSE)) return FALSE;
-                               y = p_ptr->y + ddy[dir];
-                               x = p_ptr->x + ddx[dir];
-                               if (cave[y][x].m_idx)
-                               {
-                                       if (one_in_(2)) 
-                                               msg_print(_("あーたたたたたたたたたたたたたたたたたたたたたた!!!", 
-                                                                       "Ahhhtatatatatatatatatatatatatatataatatatatattaaaaa!!!!"));
-                                       else
-                                               msg_print(_("オラオラオラオラオラオラオラオラオラオラオラオラ!!!",
-                                                                       "Oraoraoraoraoraoraoraoraoraoraoraoraoraoraoraoraora!!!!"));
-
-                                       py_attack(y, x, 0);
-                                       if (cave[y][x].m_idx)
-                                       {
-                                               handle_stuff();
-                                               py_attack(y, x, 0);
-                                       }
-                                       p_ptr->energy_need += ENERGY_NEED();
-                               }
-                               else
-                               {
-                                       msg_print(_("その方向にはモンスターはいません。", "You don't see any monster in this direction"));
-                                       msg_print(NULL);
-                               }
+                               return double_attack(p_ptr);
                        }
                        break;
                }
                case CLASS_MINDCRAFTER:
                case CLASS_FORCETRAINER:
                {
-                       if (total_friends)
-                       {
-                               msg_print(_("今はペットを操ることに集中していないと。", "You need concentration on the pets now."));
-                               return FALSE;
-                       }
-                       msg_print(_("少し頭がハッキリした。", "You feel your head clear a little."));
-
-                       p_ptr->csp += (3 + p_ptr->lev/20);
-                       if (p_ptr->csp >= p_ptr->msp)
-                       {
-                               p_ptr->csp = p_ptr->msp;
-                               p_ptr->csp_frac = 0;
-                       }
-                       p_ptr->redraw |= (PR_MANA);
-                       break;
+                       return clear_mind(p_ptr);
                }
                case CLASS_TOURIST:
                {
@@ -669,27 +573,6 @@ static bool cmd_racial_power_aux(s32b command)
                {
                        if (command == -3)
                        {
-                               int max_csp = MAX(p_ptr->msp*4, p_ptr->lev*5+5);
-
-                               if (total_friends)
-                               {
-                                       msg_print(_("今はペットを操ることに集中していないと。", "You need concentration on the pets now."));
-                                       return FALSE;
-                               }
-                               if (p_ptr->special_defense & KATA_MASK)
-                               {
-                                       msg_print(_("今は構えに集中している。", "You need concentration on your form."));
-                                       return FALSE;
-                               }
-                               msg_print(_("精神を集中して気合いを溜めた。", "You concentrate to charge your power."));
-
-                               p_ptr->csp += p_ptr->msp / 2;
-                               if (p_ptr->csp >= max_csp)
-                               {
-                                       p_ptr->csp = max_csp;
-                                       p_ptr->csp_frac = 0;
-                               }
-                               p_ptr->redraw |= (PR_MANA);
                        }
                        else if (command == -4)
                        {
@@ -718,43 +601,7 @@ static bool cmd_racial_power_aux(s32b command)
                }
                case CLASS_CAVALRY:
                {
-                       GAME_TEXT m_name[MAX_NLEN];
-                       monster_type *m_ptr;
-                       monster_race *r_ptr;
-                       int rlev;
-
-                       if (p_ptr->riding)
-                       {
-                               msg_print(_("今は乗馬中だ。", "You ARE riding."));
-                               return FALSE;
-                       }
-                       if (!do_riding(TRUE)) return TRUE;
-                       m_ptr = &m_list[p_ptr->riding];
-                       r_ptr = &r_info[m_ptr->r_idx];
-                       monster_desc(m_name, m_ptr, 0);
-                       msg_format(_("%sに乗った。", "You ride on %s."),m_name);
-                       if (is_pet(m_ptr)) break;
-                       rlev = r_ptr->level;
-                       if (r_ptr->flags1 & RF1_UNIQUE) rlev = rlev * 3 / 2;
-                       if (rlev > 60) rlev = 60+(rlev-60)/2;
-                       if ((randint1(p_ptr->skill_exp[GINOU_RIDING] / 120 + p_ptr->lev * 2 / 3) > rlev)
-                           && one_in_(2) && !p_ptr->inside_arena && !p_ptr->inside_battle
-                           && !(r_ptr->flags7 & (RF7_GUARDIAN)) && !(r_ptr->flags1 & (RF1_QUESTOR))
-                           && (rlev < p_ptr->lev * 3 / 2 + randint0(p_ptr->lev / 5)))
-                       {
-                               msg_format(_("%sを手なずけた。", "You tame %s."),m_name);
-                               set_pet(m_ptr);
-                       }
-                       else
-                       {
-                               msg_format(_("%sに振り落とされた!", "You have thrown off by %s."),m_name);
-                               rakuba(1,TRUE);
-
-                               /* Paranoia */
-                               /* 落馬処理に失敗してもとにかく乗馬解除 */
-                               p_ptr->riding = 0;
-                       }
-                       break;
+                       return rodeo(p_ptr);
                }
                case CLASS_BERSERKER:
                {
@@ -782,27 +629,7 @@ static bool cmd_racial_power_aux(s32b command)
                        }
                        else if (command == -4)
                        {
-                               if (total_friends)
-                               {
-                                       msg_print(_("今はペットを操ることに集中していないと。", "You need concentration on the pets now."));
-                                       return FALSE;
-                               }
-                               if (is_mirror_grid(&cave[p_ptr->y][p_ptr->x]))
-                               {
-                                       msg_print(_("少し頭がハッキリした。", "You feel your head clear a little."));
-
-                                       p_ptr->csp += (5 + p_ptr->lev * p_ptr->lev / 100);
-                                       if (p_ptr->csp >= p_ptr->msp)
-                                       {
-                                               p_ptr->csp = p_ptr->msp;
-                                               p_ptr->csp_frac = 0;
-                                       }
-                                       p_ptr->redraw |= (PR_MANA);
-                               }
-                               else
-                               {
-                                       msg_print(_("鏡の上でないと集中できない!", "Here are not any mirrors!"));
-                               }
+                               return mirror_concentration(p_ptr);
                        }
                        break;
                }
@@ -818,12 +645,7 @@ static bool cmd_racial_power_aux(s32b command)
                case MIMIC_DEMON:
                case MIMIC_DEMON_LORD:
                {
-                       int type = (one_in_(2) ? GF_NETHER : GF_FIRE);
-                       if (!get_aim_dir(&dir)) return FALSE;
-                       stop_mouth();
-                       msg_format(_("あなたは%sのブレスを吐いた。", "You breathe %s."),((type == GF_NETHER) ? _("地獄", "nether") : _("火炎", "fire")));
-                       fire_breath(type, dir, plev * 3, (plev / 15) + 1);
-                       break;
+                       return demonic_breath(p_ptr);
                }
                case MIMIC_VAMPIRE:
                        vampirism();
@@ -990,13 +812,7 @@ static bool cmd_racial_power_aux(s32b command)
                        break;
 
                case RACE_DEMON:
-                       {
-                               int type = (one_in_(2) ? GF_NETHER : GF_FIRE);
-                               if (!get_aim_dir(&dir)) return FALSE;
-                               stop_mouth();
-                               msg_format(_("あなたは%sのブレスを吐いた。", "You breathe %s."),((type == GF_NETHER) ? _("地獄", "nether") : _("火炎", "fire")));
-                               fire_breath(type, dir, plev * 3, (plev / 15) + 1);
-                       }
+                       return demonic_breath(p_ptr); 
                        break;
 
                case RACE_KUTAR:
@@ -1042,9 +858,8 @@ void do_cmd_racial_power(void)
 
        num = 0;
 
-       if (p_ptr->confused)
+       if (cmd_limit_confused(p_ptr))
        {
-               msg_print(_("混乱していて特殊能力を使えません!", "You are too confused to use any powers!"));
                p_ptr->energy_use = 0;
                return;
        }