OSDN Git Service

Merge branch 'master' into For2.2.2-Refactoring
[hengbandforosx/hengbandosx.git] / src / racial.c
index efa4bbe..a9308af 100644 (file)
 #include "player-status.h"
 #include "spells-status.h"
 #include "spells-object.h"
-
-/*!
- * @brief 魔法系コマンドを実行できるかの判定を返す
- * @return 魔法系コマンドを使用可能ならTRUE、不可能ならば理由をメッセージ表示してFALSEを返す。
- */
-static bool can_do_cmd_cast(void)
-{
-       if (dun_level && (d_info[dungeon_type].flags1 & DF1_NO_MAGIC))
-       {
-               msg_print(_("ダンジョンが魔法を吸収した!", "The dungeon absorbs all attempted magic!"));
-               msg_print(NULL);
-               return FALSE;
-       }
-       else if (p_ptr->anti_magic)
-       {
-               msg_print(_("反魔法バリアが魔法を邪魔した!", "An anti-magic shell disrupts your magic!"));
-               return FALSE;
-       }
-       else if (p_ptr->shero)
-       {
-               msg_format(_("狂戦士化していて頭が回らない!", "You cannot think directly!"));
-               return FALSE;
-       }
-       else
-               return TRUE;
-}
+#include "cmd-spell.h"
+#include "realm-hex.h"
 
 /*!
  * @brief 修行僧の構え設定処理
@@ -59,11 +35,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 +122,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)
        {
@@ -256,7 +224,7 @@ struct power_desc_type
        PLAYER_LEVEL level;     //!<体得レベル
        int cost;
        int stat;
-       int fail;
+       PERCENTAGE fail;
        int number;
 };
 
@@ -269,12 +237,12 @@ struct power_desc_type
 static PERCENTAGE racial_chance(power_desc_type *pd_ptr)
 {
        PLAYER_LEVEL min_level  = pd_ptr->level;
-       int difficulty = pd_ptr->fail;
+       PERCENTAGE difficulty = pd_ptr->fail;
 
        int i;
        int val;
        int sum = 0;
-       int stat = p_ptr->stat_cur[pd_ptr->stat];
+       BASE_STATUS stat = p_ptr->stat_cur[pd_ptr->stat];
 
        /* No chance for success */
        if ((p_ptr->lev < min_level) || p_ptr->confused)
@@ -287,11 +255,11 @@ static PERCENTAGE racial_chance(power_desc_type *pd_ptr)
        /* Calculate difficulty */
        if (p_ptr->stun)
        {
-               difficulty += p_ptr->stun;
+               difficulty += (PERCENTAGE)p_ptr->stun;
        }
        else if (p_ptr->lev > min_level)
        {
-               int lev_adj = ((p_ptr->lev - min_level) / 3);
+               PERCENTAGE lev_adj = (PERCENTAGE)((p_ptr->lev - min_level) / 3);
                if (lev_adj > 10) lev_adj = 10;
                difficulty -= lev_adj;
        }
@@ -342,16 +310,14 @@ static int racial_aux(power_desc_type *pd_ptr)
                msg_format(_("この能力を使用するにはレベル %d に達していなければなりません。", 
                                         "You need to attain level %d to use this power."), min_level);
 
-               p_ptr->energy_use = 0;
-               return 0;
+               free_turn(p_ptr);
+               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;
+               free_turn(p_ptr);
+               return FALSE;
        }
 
        /* Risk death? */
@@ -359,8 +325,8 @@ 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;
+                       free_turn(p_ptr);
+                       return FALSE;
                }
        }
 
@@ -383,7 +349,7 @@ static int racial_aux(power_desc_type *pd_ptr)
        }
 
        /* take time and pay the price */
-       p_ptr->energy_use = 100;
+       take_turn(p_ptr, 100);;
 
        /* Success? */
        if (randint1(p_ptr->stat_cur[use_stat]) >= ((difficulty / 2) + randint1(difficulty / 2)))
@@ -508,21 +474,7 @@ static bool cmd_racial_power_aux(s32b command)
                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:
                {
@@ -567,7 +519,7 @@ static bool cmd_racial_power_aux(s32b command)
                        if (command == -3) {
                                if (!import_magic_device()) return FALSE;
                        } else if (command == -4) {
-                               if (!can_do_cmd_cast()) return FALSE;
+                               if (cmd_limit_cast(p_ptr)) return FALSE;
                                if (!do_cmd_magic_eater(FALSE, TRUE)) return FALSE;
                        }
                        break;
@@ -577,17 +529,17 @@ static bool cmd_racial_power_aux(s32b command)
                        /* Singing is already stopped */
                        if (!SINGING_SONG_EFFECT(p_ptr) && !INTERUPTING_SONG_EFFECT(p_ptr)) return FALSE;
 
-                       stop_singing();
+                       stop_singing(p_ptr);
                        p_ptr->energy_use = 10;
                        break;
                }
                case CLASS_RED_MAGE:
                {
-                       if (!can_do_cmd_cast()) return FALSE;
+                       if (cmd_limit_cast(p_ptr)) return FALSE;
                        handle_stuff();
                        do_cmd_cast();
                        handle_stuff();
-                       if (!p_ptr->paralyzed && can_do_cmd_cast())
+                       if (!p_ptr->paralyzed && !cmd_limit_cast(p_ptr))
                                do_cmd_cast();
                        break;
                }
@@ -595,27 +547,7 @@ 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);
+                               concentration(p_ptr);
                        }
                        else if (command == -4)
                        {
@@ -639,7 +571,7 @@ static bool cmd_racial_power_aux(s32b command)
                        {
                                set_action(ACTION_LEARN);
                        }
-                       p_ptr->energy_use = 0;
+                       free_turn(p_ptr);
                        break;
                }
                case CLASS_CAVALRY:
@@ -868,7 +800,7 @@ static bool cmd_racial_power_aux(s32b command)
 
                default:
                        msg_print(_("この種族は特殊な能力を持っていません。", "This race has no bonus power."));
-                       p_ptr->energy_use = 0;
+                       free_turn(p_ptr);
        }
        }
        return TRUE;
@@ -901,10 +833,9 @@ 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;
+               free_turn(p_ptr);
                return;
        }
 
@@ -1888,7 +1819,7 @@ if (!repeat_pull(&i) || i<0 || i>=num) {
                                case '0':
                                {
                                        screen_load();
-                                       p_ptr->energy_use = 0;
+                                       free_turn(p_ptr);
                                        return;
                                }
 
@@ -2052,7 +1983,7 @@ if (!repeat_pull(&i) || i<0 || i>=num) {
        /* Abort if needed */
        if (!flag)
        {
-               p_ptr->energy_use = 0;
+               free_turn(p_ptr);
                return;
        }
        repeat_push(i);
@@ -2088,13 +2019,11 @@ if (!repeat_pull(&i) || i<0 || i>=num) {
                        }
                        else p_ptr->csp -= actual_racial_cost;
 
-                       /* Redraw mana and hp */
                        p_ptr->redraw |= (PR_HP | PR_MANA);
-
                        p_ptr->window |= (PW_PLAYER | PW_SPELL);
                }
        }
-       else p_ptr->energy_use = 0;
+       else free_turn(p_ptr);
 
        /* Success */
        return;