OSDN Git Service

Add Doxygen comment to racial.c.
[hengband/hengband.git] / src / racial.c
index 7e7a478..b5f69a8 100644 (file)
@@ -1,19 +1,22 @@
-/* File: racial.c */
-
-/*
- * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
- *
- * This software may be copied and distributed for educational, research,
- * and not for profit purposes provided that this copyright and statement
- * are included in all such copies.  Other copyrights may also apply.
+/*!
+ * @file racial.c
+ * @brief ¥ì¥¤¥·¥ã¥ë¤ÈÆÍÁ³ÊѰۤε»Ç½½èÍý / Racial powers (and mutations)
+ * @date 2014/01/08
+ * @author
+ * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke\n
+ * This software may be copied and distributed for educational, research,\n
+ * and not for profit purposes provided that this copyright and statement\n
+ * are included in all such copies.  Other copyrights may also apply.\n
+ * 2014 Deskull rearranged comment for Doxygen. \n
  */
 
-/* Purpose: Racial powers (and mutations) */
-
 #include "angband.h"
 
-/*
+/*!
+ * @brief ÂоݤΥ¢¥¤¥Æ¥à¤¬Ìð¤ä¥¯¥í¥¹¥Ü¥¦¤ÎÌð¤ÎºàÎÁ¤Ë¤Ê¤ë¤«¤òÊÖ¤¹¡£/
  * Hook to determine if an object is contertible in an arrow/bolt
+ * @param o_ptr ¥ª¥Ö¥¸¥§¥¯¥È¤Î¹½Â¤ÂΤλ²¾È¥Ý¥¤¥ó¥¿¡£
+ * @return ºàÎÁ¤Ë¤Ç¤­¤ë¤Ê¤éTRUE¤òÊÖ¤¹
  */
 static bool item_tester_hook_convertible(object_type *o_ptr)
 {
@@ -24,10 +27,10 @@ static bool item_tester_hook_convertible(object_type *o_ptr)
        return (FALSE);
 }
 
-
-/*
- * do_cmd_cast calls this function if the player's class
- * is 'archer'.
+/*!
+ * @brief ¥ì¥¤¥·¥ã¥ë¡ÖÃÆ/Ìð¤ÎÀ½Â¤¡×½èÍý / do_cmd_cast calls this function if the player's class is 'archer'.
+ * Hook to determine if an object is contertible in an arrow/bolt
+ * @return À½Â¤¤ò¼ÂºÝ¤Ë¹Ô¤Ã¤¿¤éTRUE¡¢¥­¥ã¥ó¥»¥ë¤·¤¿¤éFALSE¤òÊÖ¤¹
  */
 static bool do_cmd_archer(void)
 {
@@ -114,8 +117,28 @@ static bool do_cmd_archer(void)
                y = py + ddy[dir];
                x = px + ddx[dir];
                c_ptr = &cave[y][x];
-               if (c_ptr->feat == FEAT_RUBBLE)
+
+               if (!have_flag(f_info[get_feat_mimic(c_ptr)].flags, FF_CAN_DIG))
+               {
+#ifdef JP
+                       msg_print("¤½¤³¤Ë¤Ï´äÀФ¬¤Ê¤¤¡£");
+#else
+                       msg_print("You need pile of rubble.");
+#endif
+                       return FALSE;
+               }
+               else if (!cave_have_flag_grid(c_ptr, FF_CAN_DIG) || !cave_have_flag_grid(c_ptr, FF_HURT_ROCK))
+               {
+#ifdef JP
+                       msg_print("¹Å¤¹¤®¤ÆÊø¤»¤Ê¤«¤Ã¤¿¡£");
+#else
+                       msg_print("You failed to make ammo.");
+#endif
+               }
+               else
                {
+                       s16b slot;
+
                        /* Get local object */
                        q_ptr = &forge;
 
@@ -124,37 +147,33 @@ static bool do_cmd_archer(void)
                        q_ptr->number = (byte)rand_range(15,30);
                        object_aware(q_ptr);
                        object_known(q_ptr);
-                       apply_magic(q_ptr, p_ptr->lev, FALSE, FALSE, FALSE, FALSE);
+                       apply_magic(q_ptr, p_ptr->lev, AM_NO_FIXED_ART);
                        q_ptr->discount = 99;
 
-                       (void)inven_carry(q_ptr);
+                       slot = inven_carry(q_ptr);
 
-                       object_desc(o_name, q_ptr, TRUE, 2);
+                       object_desc(o_name, q_ptr, 0);
 #ifdef JP
-                       msg_format("´äÀФòºï¤Ã¤Æ%s¤òºî¤Ã¤¿¡£",o_name);
+                       msg_format("%s¤òºî¤Ã¤¿¡£", o_name);
 #else
                        msg_print("You make some ammo.");
 #endif
 
-                       (void)wall_to_mud(dir);
-                       p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW);
-                       p_ptr->window |= (PW_OVERHEAD);
-               }
-               else
-               {
-#ifdef JP
-                       msg_print("¤½¤³¤Ë¤Ï´äÀФ¬¤Ê¤¤¡£");
-#else
-                       msg_print("You need pile of rubble.");
-#endif
+                       /* Auto-inscription */
+                       if (slot >= 0) autopick_alter_item(slot, FALSE);
+
+                       /* Destroy the wall */
+                       cave_alter_feat(y, x, FF_HURT_ROCK);
+
+                       p_ptr->update |= (PU_FLOW);
                }
        }
        /**********Create arrows*********/
        else if (ext == 2)
        {
                int item;
-
                cptr q, s;
+               s16b slot;
 
                item_tester_hook = item_tester_hook_convertible;
 
@@ -178,21 +197,21 @@ static bool do_cmd_archer(void)
                else
                {
                        q_ptr = &o_list[0 - item];
-               }       
+               }
 
                /* Get local object */
                q_ptr = &forge;
 
                /* Hack -- Give the player some small firestones */
                object_prep(q_ptr, lookup_kind(TV_ARROW, m_bonus(1, p_ptr->lev)+ 1));
-               q_ptr->number = (byte)rand_range(5,10);
+               q_ptr->number = (byte)rand_range(5, 10);
                object_aware(q_ptr);
                object_known(q_ptr);
-               apply_magic(q_ptr, p_ptr->lev, FALSE, FALSE, FALSE, FALSE);
+               apply_magic(q_ptr, p_ptr->lev, AM_NO_FIXED_ART);
 
                q_ptr->discount = 99;
 
-               object_desc(o_name, q_ptr, TRUE, 2);
+               object_desc(o_name, q_ptr, 0);
 #ifdef JP
                msg_format("%s¤òºî¤Ã¤¿¡£", o_name);
 #else
@@ -211,14 +230,18 @@ static bool do_cmd_archer(void)
                        floor_item_describe(0 - item);
                        floor_item_optimize(0 - item);
                }
-               (void)inven_carry(q_ptr);
+
+               slot = inven_carry(q_ptr);
+
+               /* Auto-inscription */
+               if (slot >= 0) autopick_alter_item(slot, FALSE);
        }
        /**********Create bolts*********/
        else if (ext == 3)
        {
                int item;
-
                cptr q, s;
+               s16b slot;
 
                item_tester_hook = item_tester_hook_convertible;
 
@@ -242,21 +265,21 @@ static bool do_cmd_archer(void)
                else
                {
                        q_ptr = &o_list[0 - item];
-               }       
+               }
 
                /* Get local object */
                q_ptr = &forge;
 
                /* Hack -- Give the player some small firestones */
                object_prep(q_ptr, lookup_kind(TV_BOLT, m_bonus(1, p_ptr->lev)+1));
-               q_ptr->number = (byte)rand_range(4,8);
+               q_ptr->number = (byte)rand_range(4, 8);
                object_aware(q_ptr);
                object_known(q_ptr);
-               apply_magic(q_ptr, p_ptr->lev, FALSE, FALSE, FALSE, FALSE);
+               apply_magic(q_ptr, p_ptr->lev, AM_NO_FIXED_ART);
 
                q_ptr->discount = 99;
 
-               object_desc(o_name, q_ptr, TRUE, 2);
+               object_desc(o_name, q_ptr, 0);
 #ifdef JP
                msg_format("%s¤òºî¤Ã¤¿¡£", o_name);
 #else
@@ -276,11 +299,18 @@ static bool do_cmd_archer(void)
                        floor_item_optimize(0 - item);
                }
 
-               (void)inven_carry(q_ptr);
+               slot = inven_carry(q_ptr);
+
+               /* Auto-inscription */
+               if (slot >= 0) autopick_alter_item(slot, FALSE);
        }
        return TRUE;
 }
 
+/*!
+ * @brief ËâÆ»¶ñ½Ñ»Õ¤ÎËâÎϼè¤ê¹þ¤ß½èÍý
+ * @return ¼è¤ê¹þ¤ß¤ò¼Â¹Ô¤·¤¿¤éTRUE¡¢¥­¥ã¥ó¥»¥ë¤·¤¿¤éFALSE¤òÊÖ¤¹
+ */
 bool gain_magic(void)
 {
        int item;
@@ -327,7 +357,7 @@ s = "
        }
 
 
-       if (!object_known_p(o_ptr))
+       if (!object_is_known(o_ptr))
        {
 #ifdef JP
                msg_print("´ÕÄꤵ¤ì¤Æ¤¤¤Ê¤¤¤È¼è¤ê¹þ¤á¤Ê¤¤¡£");
@@ -380,7 +410,7 @@ s = "
                }
        }
 
-       object_desc(o_name, o_ptr, TRUE, 3);
+       object_desc(o_name, o_ptr, 0);
        /* Message */
 #ifdef JP
        msg_format("%s¤ÎËâÎϤò¼è¤ê¹þ¤ó¤À¡£", o_name);
@@ -407,7 +437,48 @@ s = "
        return TRUE;
 }
 
+/*!
+ * @brief ËâË¡·Ï¥³¥Þ¥ó¥É¤ò¼Â¹Ô¤Ç¤­¤ë¤«¤ÎȽÄê¤òÊÖ¤¹
+ * @return ËâË¡·Ï¥³¥Þ¥ó¥É¤ò»ÈÍѲÄǽ¤Ê¤éTRUE¡¢ÉÔ²Äǽ¤Ê¤é¤ÐÍýͳ¤ò¥á¥Ã¥»¡¼¥¸É½¼¨¤·¤ÆFALSE¤òÊÖ¤¹¡£
+ */
+static bool can_do_cmd_cast(void)
+{
+       if (dun_level && (d_info[dungeon_type].flags1 & DF1_NO_MAGIC))
+       {
+#ifdef JP
+               msg_print("¥À¥ó¥¸¥ç¥ó¤¬ËâË¡¤òµÛ¼ý¤·¤¿¡ª");
+#else
+               msg_print("The dungeon absorbs all attempted magic!");
+#endif
+               msg_print(NULL);
+               return FALSE;
+       }
+       else if (p_ptr->anti_magic)
+       {
+#ifdef JP
+               msg_print("È¿ËâË¡¥Ð¥ê¥¢¤¬ËâË¡¤ò¼ÙË⤷¤¿¡ª");
+#else
+               msg_print("An anti-magic shell disrupts your magic!");
+#endif
+               return FALSE;
+       }
+       else if (p_ptr->shero)
+       {
+#ifdef JP
+               msg_format("¶¸Àï»Î²½¤·¤Æ¤¤¤ÆƬ¤¬²ó¤é¤Ê¤¤¡ª");
+#else
+               msg_format("You cannot think directly!");
+#endif
+               return FALSE;
+       }
+       else
+               return TRUE;
+}
 
+/*!
+ * @brief ½¤¹ÔÁΤ齤¨ÀßÄê½èÍý
+ * @return ¹½¤¨¤òÊѲ½¤µ¤»¤¿¤éTRUE¡¢¹½¤¨ÉÔǽ¤«¥­¥ã¥ó¥»¥ë¤·¤¿¤éFALSE¤òÊÖ¤¹¡£
+ */
 static bool choose_kamae(void)
 {
        char choice;
@@ -459,7 +530,7 @@ static bool choose_kamae(void)
                        screen_load();
                        return FALSE;
                }
-               else if ((choice == 'a') || (choice == 'A') || (choice == ESCAPE))
+               else if ((choice == 'a') || (choice == 'A'))
                {
                        if (p_ptr->action == ACTION_KAMAE)
                        {
@@ -522,6 +593,10 @@ static bool choose_kamae(void)
        return TRUE;
 }
 
+/*!
+ * @brief ·õ½Ñ²È¤Î·¿ÀßÄê½èÍý
+ * @return ·¿¤òÊѲ½¤µ¤»¤¿¤éTRUE¡¢·¿¤Î¹½¤¨ÉÔǽ¤«¥­¥ã¥ó¥»¥ë¤·¤¿¤éFALSE¤òÊÖ¤¹¡£
+ */
 static bool choose_kata(void)
 {
        char choice;
@@ -597,7 +672,7 @@ static bool choose_kata(void)
                        screen_load();
                        return FALSE;
                }
-               else if ((choice == 'a') || (choice == 'A') || (choice == ESCAPE))
+               else if ((choice == 'a') || (choice == 'A'))
                {
                        if (p_ptr->action == ACTION_KATA)
                        {
@@ -662,8 +737,14 @@ static bool choose_kata(void)
 }
 
 
+/*!
+ * @brief ¥ì¥¤¥·¥ã¥ë¡¦¥Ñ¥ï¡¼¾ðÊó¤Îtypedef
+ */
 typedef struct power_desc_type power_desc_type;
 
+/*!
+ * @brief ¥ì¥¤¥·¥ã¥ë¡¦¥Ñ¥ï¡¼¾ðÊó¤Î¹½Â¤ÂÎÄêµÁ
+ */
 struct power_desc_type
 {
        char name[40];
@@ -675,8 +756,10 @@ struct power_desc_type
 };
 
 
-/*
- * Returns the chance to activate a racial power/mutation
+/*!
+ * @brief ¥ì¥¤¥·¥ã¥ë¡¦¥Ñ¥ï¡¼¤ÎȯưÀ®¸ùΨ¤ò·×»»¤¹¤ë / Returns the chance to activate a racial power/mutation
+ * @param pd_ptr È¯Æ°¤·¤¿¤¤¥ì¥¤¥·¥ã¥ë¡¦¥Ñ¥ï¡¼¾ðÊó¤Î¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
+ * @return À®¸ùΨ(%)¤òÊÖ¤¹
  */
 static int racial_chance(power_desc_type *pd_ptr)
 {
@@ -728,23 +811,25 @@ static int racial_chance(power_desc_type *pd_ptr)
 
 
 static int  racial_cost;
-static bool racial_use_hp;
 
-/*
- * Note: return value indicates that we have succesfully used the power
- * 1: Succeeded, 0: Cancelled, -1: Failed
+/*!
+ * @brief ¥ì¥¤¥·¥ã¥ë¡¦¥Ñ¥ï¡¼¤Îȯư¤ÎȽÄê½èÍý
+ * @param pd_ptr È¯Æ°¤·¤¿¤¤¥ì¥¤¥·¥ã¥ë¡¦¥Ñ¥ï¡¼¾ðÊó¤Î¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
+ * @return
+ * È¯Æ°À®¸ù¤Ê¤é¤Ð1¡¢È¯Æ°¼ºÇԤʤé¤Ð-1¡¢¥­¥ã¥ó¥»¥ë¤Ê¤é¤Ð0¤òÊÖ¤¹¡£
+ * return value indicates that we have succesfully used the power 1: Succeeded, 0: Cancelled, -1: Failed
  */
 static int racial_aux(power_desc_type *pd_ptr)
 {
        s16b min_level  = pd_ptr->level;
        int  use_stat   = pd_ptr->stat;
        int  difficulty = pd_ptr->fail;
+       int  use_hp = 0;
 
-       racial_cost   = pd_ptr->cost;
-       racial_use_hp = FALSE;
+       racial_cost = pd_ptr->cost;
 
        /* Not enough mana - use hp */
-       if (p_ptr->csp < racial_cost) racial_use_hp = TRUE;
+       if (p_ptr->csp < racial_cost) use_hp = racial_cost - p_ptr->csp;
 
        /* Power is not available yet */
        if (p_ptr->lev < min_level)
@@ -773,7 +858,7 @@ static int racial_aux(power_desc_type *pd_ptr)
        }
 
        /* Risk death? */
-       else if (racial_use_hp && (p_ptr->chp < racial_cost))
+       else if (p_ptr->chp < use_hp)
        {
 #ifdef JP
                if (!get_check("ËÜÅö¤Ëº£¤Î¿ê¼å¤·¤¿¾õÂ֤Ǥ³¤ÎǽÎϤò»È¤¤¤Þ¤¹¤«¡©"))
@@ -814,17 +899,31 @@ static int racial_aux(power_desc_type *pd_ptr)
                return 1;
        }
 
+       if (flush_failure) flush();
 #ifdef JP
        msg_print("½¼Ê¬¤Ë½¸Ãæ¤Ç¤­¤Ê¤«¤Ã¤¿¡£");
 #else
        msg_print("You've failed to concentrate hard enough.");
 #endif
-       if (flush_failure) flush();
 
        return -1;
 }
 
+/*!
+ * @brief ¥ì¥¤¥·¥ã¥ë¡¦¥Ñ¥ï¡¼È¯Æ°»þ¤Ë¸ý¤ò»È¤¦·Ñ³Ū¤Ê±Ó¾§½èÍý¤òÃæÃǤ¹¤ë
+ * @return ¤Ê¤·
+ */
+void ratial_stop_mouth()
+{
+       if (music_singing_any()) stop_singing();
+       if (hex_spelling_any()) stop_hex_spell_all();
+}
 
+/*!
+ * @brief ¥ì¥¤¥·¥ã¥ë¡¦¥Ñ¥ï¡¼È¯Æ°½èÍý
+ * @param command È¯Æ°¤¹¤ë¥ì¥¤¥·¥ã¥ë¤ÎID
+ * @return ½èÍý¤ò¼ÂºÝ¤Ë¼Â¹Ô¤·¤¿¾ì¹ç¤ÏTRUE¡¢¥­¥ã¥ó¥»¥ë¤·¤¿¾ì¹çFALSE¤òÊÖ¤¹¡£
+ */
 static bool cmd_racial_power_aux(s32b command)
 {
        s16b        plev = p_ptr->lev;
@@ -838,7 +937,6 @@ static bool cmd_racial_power_aux(s32b command)
                {
                        int y = 0, x = 0, i;
                        cave_type       *c_ptr;
-                       monster_type    *m_ptr;
 
                        for (i = 0; i < 6; i++)
                        {
@@ -847,9 +945,6 @@ static bool cmd_racial_power_aux(s32b command)
                                x = px + ddx_ddd[dir];
                                c_ptr = &cave[y][x];
 
-                               /* Get the monster */
-                               m_ptr = &m_list[c_ptr->m_idx];
-
                                /* Hack -- attack monsters */
                                if (c_ptr->m_idx)
                                        py_attack(y, x, 0);
@@ -864,8 +959,15 @@ static bool cmd_racial_power_aux(s32b command)
                        }
                        break;
                }
-               case CLASS_MAGE:
                case CLASS_HIGH_MAGE:
+               if (p_ptr->realm1 == REALM_HEX)
+               {
+                       bool retval = stop_hex_spell();
+                       if (retval) energy_use = 10;
+                       return (retval);
+               }
+               case CLASS_MAGE:
+               /* case CLASS_HIGH_MAGE: */
                case CLASS_SORCERER:
                {
                        if (!eat_magic(p_ptr->lev * 2)) return FALSE;
@@ -901,7 +1003,7 @@ static bool cmd_racial_power_aux(s32b command)
 #else
                                        msg_print("You are failed to run away.");
 #endif
-                               else teleport_player(30);
+                               else teleport_player(30, 0L);
                        }
                        else
                        {
@@ -916,6 +1018,7 @@ static bool cmd_racial_power_aux(s32b command)
                        break;
                }
                case CLASS_RANGER:
+               case CLASS_SNIPER:
                {
 #ifdef JP
                        msg_print("Ũ¤òÄ´ºº¤·¤¿...");
@@ -928,30 +1031,23 @@ static bool cmd_racial_power_aux(s32b command)
                }
                case CLASS_PALADIN:
                {
-                       if (is_good_realm(p_ptr->realm1))
-                       {
-                               if (!get_aim_dir(&dir)) return FALSE;
-                               fire_beam(GF_HOLY_FIRE, dir, plev * 3);
-                       }
-                       else
-                       {
-                               if (!get_aim_dir(&dir)) return FALSE;
-                               fire_beam(GF_HELL_FIRE, dir, plev * 3);
-                       }
+                       if (!get_aim_dir(&dir)) return FALSE;
+                       fire_beam(is_good_realm(p_ptr->realm1) ? GF_HOLY_FIRE : GF_HELL_FIRE,
+                                 dir, plev * 3);
                        break;
                }
                case CLASS_WARRIOR_MAGE:
                {
                        if (command == -3)
                        {
-                               int gain_sp;
 #ifdef JP
-                               if ((gain_sp = take_hit(DAMAGE_USELIFE, p_ptr->lev, "£È£Ð¤«¤é£Í£Ð¤Ø¤Î̵ËŤÊÊÑ´¹", -1)))
+                               int gain_sp = take_hit(DAMAGE_USELIFE, p_ptr->lev, "£È£Ð¤«¤é£Í£Ð¤Ø¤Î̵ËŤÊÊÑ´¹", -1) / 5;
 #else
-                               if ((gain_sp = take_hit(DAMAGE_USELIFE, p_ptr->lev, "thoughtless convertion from HP to SP", -1)))
+                               int gain_sp = take_hit(DAMAGE_USELIFE, p_ptr->lev, "thoughtless convertion from HP to SP", -1) / 5;
 #endif
+                               if (gain_sp)
                                {
-                                       p_ptr->csp += gain_sp / 5;
+                                       p_ptr->csp += gain_sp;
                                        if (p_ptr->csp > p_ptr->msp)
                                        {
                                                p_ptr->csp = p_ptr->msp;
@@ -967,7 +1063,7 @@ static bool cmd_racial_power_aux(s32b command)
                        }
                        else if (command == -4)
                        {
-                               if (p_ptr->csp >= p_ptr->lev/5)
+                               if (p_ptr->csp >= p_ptr->lev / 5)
                                {
                                        p_ptr->csp -= p_ptr->lev / 5;
                                        hp_player(p_ptr->lev);
@@ -979,6 +1075,10 @@ static bool cmd_racial_power_aux(s32b command)
                                        msg_print("You failed to convert.");
 #endif
                        }
+
+                       /* Redraw mana and hp */
+                       p_ptr->redraw |= (PR_HP | PR_MANA);
+
                        break;
                }
                case CLASS_CHAOS_WARRIOR:
@@ -988,7 +1088,7 @@ static bool cmd_racial_power_aux(s32b command)
 #else
                        msg_print("You glare nearby monsters...");
 #endif
-                       slow_monsters();
+                       slow_monsters(p_ptr->lev);
                        stun_monsters(p_ptr->lev * 4);
                        confuse_monsters(p_ptr->lev * 4);
                        turn_monsters(p_ptr->lev * 4);
@@ -997,7 +1097,7 @@ static bool cmd_racial_power_aux(s32b command)
                }
                case CLASS_MONK:
                {
-                       if (empty_hands(TRUE) < 2)
+                       if (!(empty_hands(TRUE) & EMPTY_HAND_RARM))
                        {
 #ifdef JP
                                msg_print("ÁǼꤸ¤ã¤Ê¤¤¤È¤Ç¤­¤Þ¤»¤ó¡£");
@@ -1006,13 +1106,20 @@ static bool cmd_racial_power_aux(s32b command)
 #endif
                                return FALSE;
                        }
+                       if (p_ptr->riding)
+                       {
+#ifdef JP
+                               msg_print("¾èÇÏÃæ¤Ï¤Ç¤­¤Þ¤»¤ó¡£");
+#else
+                               msg_print("You need to get off a pet.");
+#endif
+                               return FALSE;
+                       }
 
                        if (command == -3)
                        {
-                               if (choose_kamae()) energy_use = 100;
-                               else energy_use = 0;
+                               if (!choose_kamae()) return FALSE;
                                p_ptr->update |= (PU_BONUS);
-                               p_ptr->redraw |= (PR_ARMOR);
                        }
                        else if (command == -4)
                        {
@@ -1076,6 +1183,9 @@ 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;
                }
                case CLASS_TOURIST:
@@ -1104,13 +1214,12 @@ static bool cmd_racial_power_aux(s32b command)
                        {
                                if (!get_aim_dir(&dir)) return FALSE;
                                (void)fire_ball_hide(GF_CONTROL_LIVING, dir, p_ptr->lev, 0);
-                               break;
                        }
                        else if (command == -4)
                        {
                                project_hack(GF_CONTROL_LIVING, p_ptr->lev);
-                               break;
                        }
+                       break;
                }
                case CLASS_ARCHER:
                {
@@ -1119,21 +1228,30 @@ static bool cmd_racial_power_aux(s32b command)
                }
                case CLASS_MAGIC_EATER:
                {
-                       if (!gain_magic()) return FALSE;
+                       if (command == -3) {
+                               if (!gain_magic()) return FALSE;
+                       } else if (command == -4) {
+                               if (!can_do_cmd_cast()) return FALSE;
+                               if (!do_cmd_magic_eater(FALSE, TRUE)) return FALSE;
+                       }
                        break;
                }
                case CLASS_BARD:
                {
+                       /* Singing is already stopped */
+                       if (!p_ptr->magic_num1[0] && !p_ptr->magic_num1[1]) return FALSE;
+
                        stop_singing();
                        energy_use = 10;
-                       return FALSE;
+                       break;
                }
                case CLASS_RED_MAGE:
                {
+                       if (!can_do_cmd_cast()) return FALSE;
                        handle_stuff();
                        do_cmd_cast();
                        handle_stuff();
-                       if (!p_ptr->paralyzed)
+                       if (!p_ptr->paralyzed && can_do_cmd_cast())
                                do_cmd_cast();
                        break;
                }
@@ -1173,10 +1291,13 @@ 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)
                        {
-                               if (!buki_motteruka(INVEN_RARM))
+                               if (!buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM))
                                {
 #ifdef JP
                                        msg_print("Éð´ï¤ò»ý¤¿¤Ê¤¤¤È¤¤¤±¤Þ¤»¤ó¡£");
@@ -1185,10 +1306,8 @@ static bool cmd_racial_power_aux(s32b command)
 #endif
                                        return FALSE;
                                }
-                               if (choose_kata()) energy_use = 100;
-                               else energy_use = 0;
+                               if (!choose_kata()) return FALSE;
                                p_ptr->update |= (PU_BONUS);
-                               p_ptr->redraw |= (PR_ARMOR);
                        }
                        break;
                }
@@ -1282,19 +1401,8 @@ static bool cmd_racial_power_aux(s32b command)
                {
                        if (command == -3)
                        {
-                               int x, y;
-                               for (x = 0; x < cur_wid; x++)
-                               {
-                                       for (y = 0; y < cur_hgt; y++)
-                                       {
-                                               if (is_mirror_grid(&cave[y][x]))
-                                               {
-                                                       remove_mirror(y, x);
-                                                       project(0, 2, y, x, p_ptr->lev / 2 + 5, GF_SHARDS,
-                                                               (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP | PROJECT_NO_HANGEKI), -1);
-                                               }
-                                       }
-                               }
+                               /* Explode all mirrors */
+                               remove_all_mirrors(TRUE);
                        }
                        else if (command == -4)
                        {
@@ -1321,6 +1429,9 @@ 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
                                {
@@ -1335,11 +1446,35 @@ static bool cmd_racial_power_aux(s32b command)
                }
                case CLASS_NINJA:
                {
-                       if (p_ptr->action == ACTION_HAYAGAKE) set_action(ACTION_NONE);
-                       else set_action(ACTION_HAYAGAKE);
+                       if (p_ptr->action == ACTION_HAYAGAKE)
+                       {
+                               set_action(ACTION_NONE);
+                       }
+                       else
+                       {
+                               cave_type *c_ptr = &cave[py][px];
+                               feature_type *f_ptr = &f_info[c_ptr->feat];
+
+                               if (!have_flag(f_ptr->flags, FF_PROJECT) ||
+                                   (!p_ptr->levitation && have_flag(f_ptr->flags, FF_DEEP)))
+                               {
+#ifdef JP
+                                       msg_print("¤³¤³¤Ç¤ÏÁÇÁ᤯ư¤±¤Ê¤¤¡£");
+#else
+                                       msg_print("You cannot run in here.");
+#endif
+                               }
+                               else
+                               {
+                                       set_action(ACTION_HAYAGAKE);
+                               }
+                       }
+
+
                        energy_use = 0;
                        break;
                }
+
                }
        }
        else if (p_ptr->mimic_form)
@@ -1351,6 +1486,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;
+                       ratial_stop_mouth();
 #ifdef JP
                        msg_format("¤¢¤Ê¤¿¤Ï%s¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£",((type == GF_NETHER) ? "ÃϹö" : "²Ð±ê"));
 #else
@@ -1381,6 +1517,8 @@ static bool cmd_racial_power_aux(s32b command)
                                x = px + ddx[dir];
                                c_ptr = &cave[y][x];
 
+                               ratial_stop_mouth();
+
                                if (!c_ptr->m_idx)
                                {
 #ifdef JP
@@ -1457,7 +1595,7 @@ static bool cmd_racial_power_aux(s32b command)
                                q_ptr = &forge;
 
                                /* Create the food ration */
-                               object_prep(q_ptr, 21);
+                               object_prep(q_ptr, lookup_kind(TV_FOOD, SV_FOOD_RATION));
 
                                /* Drop the object from heaven */
                                (void)drop_near(q_ptr, -1, py, px);
@@ -1477,7 +1615,7 @@ static bool cmd_racial_power_aux(s32b command)
                        msg_print("Blink!");
 #endif
 
-                       teleport_player(10);
+                       teleport_player(10, 0L);
                        break;
 
                case RACE_HALF_ORC:
@@ -1560,13 +1698,7 @@ static bool cmd_racial_power_aux(s32b command)
 
                case RACE_HALF_GIANT:
                        if (!get_aim_dir(&dir)) return FALSE;
-#ifdef JP
-                       msg_print("ÀФÎÊɤò᤭¤Ä¤±¤¿¡£");
-#else
-                       msg_print("You bash at a stone wall.");
-#endif
-
-                       (void)wall_to_mud(dir);
+                       (void)wall_to_mud(dir, 20 + randint1(30));
                        break;
 
                case RACE_HALF_TITAN:
@@ -1592,6 +1724,7 @@ static bool cmd_racial_power_aux(s32b command)
 
                case RACE_YEEK:
                        if (!get_aim_dir(&dir)) return FALSE;
+                       ratial_stop_mouth();
 #ifdef JP
                        msg_print("¿È¤ÎÌÓ¤â¤è¤À¤Ä¶«¤ÓÀ¼¤ò¾å¤²¤¿¡ª");
 #else
@@ -1603,6 +1736,7 @@ static bool cmd_racial_power_aux(s32b command)
 
                case RACE_KLACKON:
                        if (!get_aim_dir(&dir)) return FALSE;
+                       ratial_stop_mouth();
 #ifdef JP
                        msg_print("»À¤òÅǤ¤¤¿¡£");
 #else
@@ -1843,6 +1977,8 @@ static bool cmd_racial_power_aux(s32b command)
                                        }
                                }
 
+                               ratial_stop_mouth();
+
 #ifdef JP
                                msg_format("¤¢¤Ê¤¿¤Ï%s¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£", Type_desc);
 #else
@@ -1925,6 +2061,8 @@ static bool cmd_racial_power_aux(s32b command)
                                x = px + ddx[dir];
                                c_ptr = &cave[y][x];
 
+                               ratial_stop_mouth();
+
                                if (!c_ptr->m_idx)
                                {
 #ifdef JP
@@ -1975,6 +2113,7 @@ static bool cmd_racial_power_aux(s32b command)
 
                case RACE_SPECTRE:
                        if (!get_aim_dir(&dir)) return FALSE;
+                       ratial_stop_mouth();
 #ifdef JP
                        msg_print("¤¢¤Ê¤¿¤Ï¤ª¤É¤í¤ª¤É¤í¤·¤¤¶«¤ÓÀ¼¤ò¤¢¤²¤¿¡ª");
 #else
@@ -1992,13 +2131,14 @@ static bool cmd_racial_power_aux(s32b command)
 #endif
 
                        if (plev < 25) sleep_monsters_touch();
-                       else (void)sleep_monsters();
+                       else (void)sleep_monsters(plev);
                        break;
 
                case RACE_DEMON:
                        {
                                int type = (one_in_(2) ? GF_NETHER : GF_FIRE);
                                if (!get_aim_dir(&dir)) return FALSE;
+                               ratial_stop_mouth();
 #ifdef JP
                                msg_format("¤¢¤Ê¤¿¤Ï%s¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£",((type == GF_NETHER) ? "ÃϹö" : "²Ð±ê"));
 #else
@@ -2009,7 +2149,7 @@ static bool cmd_racial_power_aux(s32b command)
                        }
                        break;
 
-               case RACE_KUTA:
+               case RACE_KUTAR:
                        (void)set_tsubureru(randint1(20) + 30, FALSE);
                        break;
 
@@ -2058,7 +2198,7 @@ static bool cmd_racial_power_aux(s32b command)
 #else
                                msg_print("You fire a rocket.");
 #endif
-                               fire_ball(GF_ROCKET, dir, plev * 5, 2);
+                               fire_rocket(GF_ROCKET, dir, plev * 5, 2);
                        }
                        break;
 
@@ -2075,9 +2215,9 @@ static bool cmd_racial_power_aux(s32b command)
        return TRUE;
 }
 
-
-/*
- * Allow user to choose a power (racial / mutation) to activate
+/*!
+ * @brief ¥ì¥¤¥·¥ã¥ë¡¦¥Ñ¥ï¡¼¥³¥Þ¥ó¥É¤Î¥á¥¤¥ó¥ë¡¼¥Á¥ó / Allow user to choose a power (racial / mutation) to activate
+ * @return ¤Ê¤·
  */
 void do_cmd_racial_power(void)
 {
@@ -2134,8 +2274,23 @@ strcpy(power_desc[num].name, "
                power_desc[num++].number = -3;
                break;
        }
-       case CLASS_MAGE:
        case CLASS_HIGH_MAGE:
+       if (p_ptr->realm1 == REALM_HEX)
+       {
+#ifdef JP
+               strcpy(power_desc[num].name, "±Ó¾§¤ò¤ä¤á¤ë");
+#else
+               strcpy(power_desc[num].name, "Stop spelling");
+#endif
+               power_desc[num].level = 1;
+               power_desc[num].cost = 0;
+               power_desc[num].stat = A_INT;
+               power_desc[num].fail = 0;
+               power_desc[num++].number = -3;
+               break;
+       }
+       case CLASS_MAGE:
+       /* case CLASS_HIGH_MAGE: */
        case CLASS_SORCERER:
        {
 #ifdef JP
@@ -2199,6 +2354,7 @@ strcpy(power_desc[num].name, "
                break;
        }
        case CLASS_RANGER:
+       case CLASS_SNIPER:
        {
 #ifdef JP
 strcpy(power_desc[num].name, "¥â¥ó¥¹¥¿¡¼Ä´ºº");
@@ -2423,6 +2579,13 @@ strcpy(power_desc[num].name, "
                power_desc[num].stat = A_INT;
                power_desc[num].fail = 0;
                power_desc[num++].number = -3;
+
+               strcpy(power_desc[num].name, _("¶¯ÎÏȯư", "Powerful Activation"));
+               power_desc[num].level = 10;
+               power_desc[num].cost = 10 + (lvl - 10) / 2;
+               power_desc[num].stat = A_INT;
+               power_desc[num].fail = 0;
+               power_desc[num++].number = -4;
                break;
        }
        case CLASS_BARD:
@@ -2965,7 +3128,7 @@ sprintf(power_desc[num].name, "
                        power_desc[num].fail = 20;
                        power_desc[num++].number = -1;
                        break;
-               case RACE_KUTA:
+               case RACE_KUTAR:
 #ifdef JP
 strcpy(power_desc[num].name, "²£¤Ë¿­¤Ó¤ë");
 #else
@@ -3781,20 +3944,20 @@ prt("                            Lv   MP 
        {
                if (racial_cost)
                {
-                       if (racial_use_hp)
+                       int actual_racial_cost = racial_cost / 2 + randint1(racial_cost / 2);
+
+                       /* If mana is not enough, player consumes hit point! */
+                       if (p_ptr->csp < actual_racial_cost)
                        {
+                               actual_racial_cost -= p_ptr->csp;
+                               p_ptr->csp = 0;
 #ifdef JP
-                               take_hit(DAMAGE_USELIFE, (racial_cost / 2) + randint1(racial_cost / 2),
-                                        "²áÅ٤ν¸Ãæ", -1);
+                               take_hit(DAMAGE_USELIFE, actual_racial_cost, "²áÅ٤ν¸Ãæ", -1);
 #else
-                               take_hit(DAMAGE_USELIFE, (racial_cost / 2) + randint1(racial_cost / 2),
-                                        "concentrating too hard", -1);
+                               take_hit(DAMAGE_USELIFE, actual_racial_cost, "concentrating too hard", -1);
 #endif
                        }
-                       else
-                       {
-                               p_ptr->csp -= (racial_cost / 2) + randint1(racial_cost / 2);
-                       }
+                       else p_ptr->csp -= actual_racial_cost;
 
                        /* Redraw mana and hp */
                        p_ptr->redraw |= (PR_HP | PR_MANA);