OSDN Git Service

[Refactor] #37353 mind_type と mind_power 構造体を mind.h へ移動。
[hengband/hengband.git] / src / mind.c
index 75322d0..4b3a6ac 100644 (file)
  * 特殊技能を揃えて実装している。
  */
 
-
-
 #include "angband.h"
+#include "util.h"
+
+#include "mind.h"
+
+#include "floor.h"
+#include "melee.h"
+#include "spells.h"
+#include "spells-summon.h"
+#include "avatar.h"
+#include "player-move.h"
+#include "player-status.h"
+#include "spells-status.h"
+#include "cmd-spell.h"
+#include "spells-floor.h"
+#include "feature.h"
+#include "grid.h"
+#include "cmd-basic.h"
+#include "monster-status.h"
+#include "player-effects.h"
+#include "view-mainwindow.h"
 
 /*! 特殊技能の一覧テーブル */
 mind_power const mind_powers[5] =
@@ -289,7 +307,7 @@ mind_power const mind_powers[5] =
 };
 
 /*! 特殊能力の解説文字列 */
-static cptr const mind_tips[5][MAX_MIND_POWERS] =
+static concptr const mind_tips[5][MAX_MIND_POWERS] =
 {
 #ifdef JP
 {
@@ -536,15 +554,6 @@ static cptr const mind_tips[5][MAX_MIND_POWERS] =
  */
 void mindcraft_info(char *p, int use_mind, int power)
 {
-#ifdef JP
-       cptr s_dam = "損傷:";
-       cptr s_dur = "期間:";
-       cptr s_range = "範囲:";
-#else
-       cptr s_dam = "dam ";
-       cptr s_dur = "dur ";
-       cptr s_range = "range ";
-#endif
        PLAYER_LEVEL plev = p_ptr->lev;
 
        strcpy(p, "");
@@ -555,22 +564,22 @@ void mindcraft_info(char *p, int use_mind, int power)
                switch (power)
                {
                case 0:  break;
-               case 1:  sprintf(p, " %s%dd%d", s_dam, 3 + ((plev - 1) / 4), 3 + plev/15); break;
-               case 2:  sprintf(p, " %s10", s_range); break;
-               case 3:  sprintf(p, " %s%d", s_range, plev * 5);  break;
+               case 1:  sprintf(p, " %s%dd%d", KWD_DAM, 3 + ((plev - 1) / 4), 3 + plev/15); break;
+               case 2:  sprintf(p, " %s10", KWD_SPHERE); break;
+               case 3:  sprintf(p, " %s%d", KWD_SPHERE, plev * 5);  break;
                case 4:  break;
-               case 5: sprintf(p, " %s%dd8", s_dam, 8 + ((plev - 5) / 4));  break;
-               case 6:  sprintf(p, " %s%d", s_dur, plev);  break;
+               case 5: sprintf(p, " %s%dd8", KWD_DAM, 8 + ((plev - 5) / 4));  break;
+               case 6:  sprintf(p, " %s%d", KWD_DURATION, plev);  break;
                case 7:  break;
-               case 8:  sprintf(p, (plev < 25 ? " %s%d" : " %sd%d"), s_dam, (plev < 25 ? plev * 3 / 2 : plev * ((plev - 5) / 10 + 1))); break;
-               case 9:  sprintf(p, " %s10+d%d", s_dur, plev * 3 / 2);  break;
+               case 8:  sprintf(p, (plev < 25 ? " %s%d" : " %sd%d"), KWD_DAM, (plev < 25 ? plev * 3 / 2 : plev * ((plev - 5) / 10 + 1))); break;
+               case 9:  sprintf(p, " %s10+d%d", KWD_DURATION, plev * 3 / 2);  break;
 #ifdef JP
                case 10: sprintf(p, " 最大重量:%d.%dkg", lbtokg1(plev * 15),lbtokg2(plev * 15));  break;
 #else
                case 10: sprintf(p, " max wgt %d", plev * 15);  break;
 #endif
-               case 11: sprintf(p, " %s%dd6", s_dam, plev / 2);  break;
-               case 12: sprintf(p, " %sd%d+%d", s_dam, plev * 3, plev * 3); break;
+               case 11: sprintf(p, " %s%dd6", KWD_DAM, plev / 2);  break;
+               case 12: sprintf(p, " %sd%d+%d", KWD_DAM, plev * 3, plev * 3); break;
                case 13: sprintf(p, _(" 行動:%ld回", " %ld acts."), (long int)(p_ptr->csp + 100-p_ptr->energy_need - 50)/100); break;
                }
                break;
@@ -582,19 +591,19 @@ void mindcraft_info(char *p, int use_mind, int power)
 
                switch (power)
                {
-               case 0:  sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5) + boost / 12); break;
+               case 0:  sprintf(p, " %s%dd4", KWD_DAM, 3 + ((plev - 1) / 5) + boost / 12); break;
                case 1:  break;
-               case 2:  sprintf(p, " %s%d+d30", s_dur, 30 + boost / 5); break;
-               case 3:  sprintf(p, " %s%dd5", s_dam, 5 + ((plev - 1) / 5) + boost / 10); break;
-               case 4:  sprintf(p, " %s%d+d20", s_dur, 20 + boost / 5); break;
+               case 2:  sprintf(p, " %s%d+d30", KWD_DURATION, 30 + boost / 5); break;
+               case 3:  sprintf(p, " %s%dd5", KWD_DAM, 5 + ((plev - 1) / 5) + boost / 10); break;
+               case 4:  sprintf(p, " %s%d+d20", KWD_DURATION, 20 + boost / 5); break;
                case 5:  break;
-               case 6:  sprintf(p, " %s%d+d%d", s_dur, 15 + boost / 7, plev / 2); break;
-               case 7:  sprintf(p, " %s%dd8", s_dam, 8 + ((plev - 5) / 4) + boost / 12); break;
-               case 8:  sprintf(p, " %s10d6+%d", s_dam, plev * 3 / 2 + boost * 3 / 5); break;
+               case 6:  sprintf(p, " %s%d+d%d", KWD_DURATION, 15 + boost / 7, plev / 2); break;
+               case 7:  sprintf(p, " %s%dd8", KWD_DAM, 8 + ((plev - 5) / 4) + boost / 12); break;
+               case 8:  sprintf(p, " %s10d6+%d", KWD_DAM, plev * 3 / 2 + boost * 3 / 5); break;
                case 9:  break;
                case 10: sprintf(p, _(" 最大%d体", " max %d"), 1+boost/100); break;
-               case 11: sprintf(p, " %s%d", s_dam, 100 + plev + boost); break;
-               case 12: sprintf(p, " %s%dd15", s_dam, 10 + plev / 2 + boost * 3 / 10); break;
+               case 11: sprintf(p, " %s%d", KWD_DAM, 100 + plev + boost); break;
+               case 12: sprintf(p, " %s%dd15", KWD_DAM, 10 + plev / 2 + boost * 3 / 10); break;
                case 13: sprintf(p, _(" 行動:%d+d16回", " %d+d16 acts"), 16+boost/20); break;
                }
                break;
@@ -605,25 +614,25 @@ void mindcraft_info(char *p, int use_mind, int power)
                {
                case 0:  break;
                case 1:  break;
-               case 2:  sprintf(p, " %s%dd4", s_dam,  3 + ((plev - 1) / 5) ); break;
-               case 3:  sprintf(p, " %s10", s_range); break;
+               case 2:  sprintf(p, " %s%dd4", KWD_DAM,  3 + ((plev - 1) / 5) ); break;
+               case 3:  sprintf(p, " %s10", KWD_SPHERE); break;
                case 4:  break;
-               case 5:  sprintf(p, " %s%d", s_range, plev *5); break;
-               case 6:  sprintf(p, " %s20+d20", s_dur);  break;
+               case 5:  sprintf(p, " %s%d", KWD_SPHERE, plev *5); break;
+               case 6:  sprintf(p, " %s20+d20", KWD_DURATION);  break;
                case 7:  break;
-               case 8:  sprintf(p, " %s%dd8", s_dam, 8+((plev -5)/4) ); break;
+               case 8:  sprintf(p, " %s%dd8", KWD_DAM, 8+((plev -5)/4) ); break;
                case 9:  break;
-               case 10: sprintf(p, " %s%dd8", s_dam, 11+(plev-5)/4 ); break;
+               case 10: sprintf(p, " %s%dd8", KWD_DAM, 11+(plev-5)/4 ); break;
                case 11: break;
-               case 12: sprintf(p, " %s20+d20", s_dur);  break;
-               case 13: sprintf(p, " %s150+d%d", s_dam, plev*2 ); break;
+               case 12: sprintf(p, " %s20+d20", KWD_DURATION);  break;
+               case 13: sprintf(p, " %s150+d%d", KWD_DAM, plev*2 ); break;
                case 14: break;
                case 15: break;
-               case 16: sprintf(p, " %s%d", s_range, plev/2 +10); break;
+               case 16: sprintf(p, " %s%d", KWD_SPHERE, plev/2 +10); break;
                case 17: break;
-               case 18: sprintf(p, " %s6+d6", s_dur);  break;
-               case 19: sprintf(p, " %s%d", s_dam, plev*11+5 ); break;
-               case 20: sprintf(p, " %s4+d4", s_dur);  break;
+               case 18: sprintf(p, " %s6+d6", KWD_DURATION);  break;
+               case 19: sprintf(p, " %s%d", KWD_DAM, plev*11+5 ); break;
+               case 20: sprintf(p, " %s4+d4", KWD_DURATION);  break;
                }
                break;
        }
@@ -633,24 +642,24 @@ void mindcraft_info(char *p, int use_mind, int power)
                {
                case 0:  break;
                case 1:  break;
-               case 2:  sprintf(p, " %s10", s_range); break;
+               case 2:  sprintf(p, " %s10", KWD_SPHERE); break;
                case 3:  break;
-               case 4:  sprintf(p, " %s%d", s_range , plev *5); break;
-               case 5:  sprintf(p, " %s30", s_range); break;
+               case 4:  sprintf(p, " %s%d", KWD_SPHERE , plev *5); break;
+               case 5:  sprintf(p, " %s30", KWD_SPHERE); break;
                case 6:  break;
                case 7:  break;
-               case 8:  sprintf(p, " %s20+d20", s_dur);  break;
-               case 9:  sprintf(p, " %s%d", s_dam, (50+plev)/2 ); break;
+               case 8:  sprintf(p, " %s20+d20", KWD_DURATION);  break;
+               case 9:  sprintf(p, " %s%d", KWD_DAM, (50+plev)/2 ); break;
                case 10: break;
                case 11: break;
                case 12: break;
                case 13: break;
                case 14: break;
                case 15: break;
-               case 16: sprintf(p, " %s%d+d%d", s_dur, plev/2, plev/2);  break;
-               case 17: sprintf(p, " %s%d*3", s_dam, (75+plev*2/3)/2 ); break;
-               case 18: sprintf(p, " %s%dd10", s_dam, 6+plev/8 ); break;
-               case 19: sprintf(p, " %s6+d6", s_dur);  break;
+               case 16: sprintf(p, " %s%d+d%d", KWD_DURATION, plev/2, plev/2);  break;
+               case 17: sprintf(p, " %s%d*3", KWD_DAM, (75+plev*2/3)/2 ); break;
+               case 18: sprintf(p, " %s%dd10", KWD_DAM, 6+plev/8 ); break;
+               case 19: sprintf(p, " %s6+d6", KWD_DURATION);  break;
                }
                break;
        }
@@ -679,16 +688,16 @@ static bool_hack get_mind_power(SPELL_IDX *sn, bool only_browse)
 {
        SPELL_IDX i;
        int             num = 0;
-       int             y = 1;
-       int             x = 10;
-       int             minfail = 0;
-       int             plev = p_ptr->lev;
-       int             chance = 0;
+       TERM_LEN y = 1;
+       TERM_LEN x = 10;
+       PERCENTAGE minfail = 0;
+       PLAYER_LEVEL plev = p_ptr->lev;
+       PERCENTAGE chance = 0;
        int             ask = TRUE;
        char            choice;
        char            out_val[160];
        char            comment[80];
-       cptr            p;
+       concptr            p;
        COMMAND_CODE code;
        mind_type       spell;
        const mind_power      *mind_ptr;
@@ -740,8 +749,6 @@ static bool_hack get_mind_power(SPELL_IDX *sn, bool only_browse)
        /* Assume cancelled */
        *sn = (-1);
 
-#ifdef ALLOW_REPEAT /* TNB */
-
        /* Get the spell, if available */
 
        if (repeat_pull(&code))
@@ -759,40 +766,38 @@ static bool_hack get_mind_power(SPELL_IDX *sn, bool only_browse)
                }
        }
 
-#endif /* ALLOW_REPEAT -- TNB */
-
     /* Nothing chosen yet */
     flag = FALSE;
 
     /* No redraw yet */
     redraw = FALSE;
 
-    for (i = 0; i < MAX_MIND_POWERS; i++)
+       for (i = 0; i < MAX_MIND_POWERS; i++)
        {
-         if (mind_ptr->info[i].min_lev <= plev)
-           {
-             num++;
-           }
+               if (mind_ptr->info[i].min_lev <= plev)
+               {
+                       num++;
+               }
        }
 
-    /* Build a prompt (accept all spells) */
-    if (only_browse)
+       /* Build a prompt (accept all spells) */
+       if (only_browse)
        {
-               (void) strnfmt(out_val, 78, 
-                                       _("(%^s %c-%c, '*'で一覧, ESC) どの%sについて知りますか?", "(%^ss %c-%c, *=List, ESC=exit) Use which %s? "),
-                                      p, I2A(0), I2A(num - 1), p);
+               (void)strnfmt(out_val, 78,
+                       _("(%^s %c-%c, '*'で一覧, ESC) どの%sについて知りますか?", "(%^ss %c-%c, *=List, ESC=exit) Use which %s? "),
+                       p, I2A(0), I2A(num - 1), p);
        }
        else
        {
-               (void) strnfmt(out_val, 78, 
-                                       _("(%^s %c-%c, '*'で一覧, ESC) どの%sを使いますか?", "(%^ss %c-%c, *=List, ESC=exit) Use which %s? "),
-                                               p, I2A(0), I2A(num - 1), p);
+               (void)strnfmt(out_val, 78,
+                       _("(%^s %c-%c, '*'で一覧, ESC) どの%sを使いますか?", "(%^ss %c-%c, *=List, ESC=exit) Use which %s? "),
+                       p, I2A(0), I2A(num - 1), p);
        }
 
        if (use_menu && !only_browse) screen_save();
-       /* Get a spell from the user */
 
-       choice= (always_show_list || use_menu) ? ESCAPE:1 ;
+       choice = (always_show_list || use_menu) ? ESCAPE : 1;
+
        while (!flag)
        {
                if(choice==ESCAPE) choice = ' '; 
@@ -844,11 +849,7 @@ static bool_hack get_mind_power(SPELL_IDX *sn, bool only_browse)
                        {
                                char psi_desc[80];
                                bool has_weapon[2];
-
-                               /* Show list */
                                redraw = TRUE;
-
-                               /* Save the screen */
                                if (!only_browse && !use_menu) screen_save();
 
                                /* Display a list of spells */
@@ -858,8 +859,8 @@ static bool_hack get_mind_power(SPELL_IDX *sn, bool only_browse)
                                put_str(format(_("Lv   %s   失率 効果", "Lv   %s   Fail Info"),
                                        ((use_mind == MIND_BERSERKER) || (use_mind == MIND_NINJUTSU)) ? "HP" : "MP"), y, x + 35);
 
-                               has_weapon[0] = buki_motteruka(INVEN_RARM);
-                               has_weapon[1] = buki_motteruka(INVEN_LARM);
+                               has_weapon[0] = has_melee_weapon(INVEN_RARM);
+                               has_weapon[1] = has_melee_weapon(INVEN_LARM);
 
                                /* Dump the spells */
                                for (i = 0; i < MAX_MIND_POWERS; i++)
@@ -954,8 +955,6 @@ static bool_hack get_mind_power(SPELL_IDX *sn, bool only_browse)
                        {
                                /* Hide list */
                                redraw = FALSE;
-
-                               /* Restore the screen */
                                screen_load();
                        }
 
@@ -1000,15 +999,10 @@ static bool_hack get_mind_power(SPELL_IDX *sn, bool only_browse)
                /* Stop the loop */
                flag = TRUE;
        }
-
-       /* Restore the screen */
        if (redraw && !only_browse) screen_load();
 
-       /* Show choices */
        p_ptr->window |= (PW_SPELL);
-
-       /* Window stuff */
-       window_stuff();
+       handle_stuff();
 
        /* Abort if needed */
        if (!flag) return (FALSE);
@@ -1016,12 +1010,8 @@ static bool_hack get_mind_power(SPELL_IDX *sn, bool only_browse)
        /* Save the choice */
        (*sn) = i;
 
-#ifdef ALLOW_REPEAT /* TNB */
-
        repeat_push((COMMAND_CODE)i);
 
-#endif /* ALLOW_REPEAT -- TNB */
-
        /* Success */
        return (TRUE);
 }
@@ -1035,7 +1025,7 @@ static bool_hack get_mind_power(SPELL_IDX *sn, bool only_browse)
 static bool cast_mindcrafter_spell(int spell)
 {
        int             b = 0;
-       int             dir;
+       DIRECTION dir;
        TIME_EFFECT t;
        PLAYER_LEVEL plev = p_ptr->lev;
 
@@ -1178,28 +1168,7 @@ static bool cast_mindcrafter_spell(int spell)
                break;
        case 13:
        {
-               if (world_player)
-               {
-                       msg_print(_("既に時は止まっている。", "Time is already stopped."));
-                       return (FALSE);
-               }
-               world_player = TRUE;
-               msg_print(_("「時よ!」", "You yell 'Time!'"));
-               msg_print(NULL);
-
-               /* Hack */
-               p_ptr->energy_need -= 1000 + (100 + p_ptr->csp - 50)*TURNS_PER_TICK/10;
-
-               /* Redraw map */
-               p_ptr->redraw |= (PR_MAP);
-
-               /* Update monsters */
-               p_ptr->update |= (PU_MONSTERS);
-
-               /* Window stuff */
-               p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
-
-               handle_stuff();
+               time_walk(p_ptr);
                break;
        }
        default:
@@ -1261,63 +1230,8 @@ static bool cast_force_spell(int spell)
                set_tim_sh_touki(randint1(plev / 2) + 15 + boost / 7, FALSE);
                break;
        case 7:
-       {
-               int y, x, dam;
-               project_length = 1;
-               if (!get_aim_dir(&dir)) return FALSE;
-
-               y = p_ptr->y + ddy[dir];
-               x = p_ptr->x + ddx[dir];
-               dam = damroll(8 + ((plev - 5) / 4) + boost / 12, 8);
-               fire_beam(GF_MISSILE, dir, dam);
-               if (cave[y][x].m_idx)
-               {
-                       int i;
-                       int ty = y, tx = x;
-                       int oy = y, ox = x;
-                       MONSTER_IDX m_idx = cave[y][x].m_idx;
-                       monster_type *m_ptr = &m_list[m_idx];
-                       monster_race *r_ptr = &r_info[m_ptr->r_idx];
-                       char m_name[80];
-
-                       monster_desc(m_name, m_ptr, 0);
-
-                       if (randint1(r_ptr->level * 3 / 2) > randint0(dam / 2) + dam/2)
-                       {
-                               msg_format(_("%sは飛ばされなかった。", "%^s was not blown away."), m_name);
-                       }
-                       else
-                       {
-                               for (i = 0; i < 5; i++)
-                               {
-                                       y += ddy[dir];
-                                       x += ddx[dir];
-                                       if (cave_empty_bold(y, x))
-                                       {
-                                               ty = y;
-                                               tx = x;
-                                       }
-                                       else break;
-                               }
-                               if ((ty != oy) || (tx != ox))
-                               {
-                                       msg_format(_("%sを吹き飛ばした!", "You blow %s away!"), m_name);
-                                       cave[oy][ox].m_idx = 0;
-                                       cave[ty][tx].m_idx = (s16b)m_idx;
-                                       m_ptr->fy = (byte_hack)ty;
-                                       m_ptr->fx = (byte_hack)tx;
-
-                                       update_mon(m_idx, TRUE);
-                                       lite_spot(oy, ox);
-                                       lite_spot(ty, tx);
-
-                                       if (r_ptr->flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
-                                               p_ptr->update |= (PU_MON_LITE);
-                               }
-                       }
-               }
+               return shock_power();
                break;
-       }
        case 8:
                if (!get_aim_dir(&dir)) return FALSE;
                fire_ball(GF_MISSILE, dir, damroll(10, 6) + plev * 3 / 2 + boost * 3 / 5, (plev < 30) ? 2 : 3);
@@ -1327,7 +1241,7 @@ static bool cast_force_spell(int spell)
                MONSTER_IDX m_idx;
 
                if (!target_set(TARGET_KILL)) return FALSE;
-               m_idx = cave[target_row][target_col].m_idx;
+               m_idx = current_floor_ptr->grid_array[target_row][target_col].m_idx;
                if (!m_idx) break;
                if (!player_has_los_bold(target_row, target_col)) break;
                if (!projectable(p_ptr->y, p_ptr->x, target_row, target_col)) break;
@@ -1340,7 +1254,7 @@ static bool cast_force_spell(int spell)
                bool success = FALSE;
 
                for (i = 0; i < 1 + boost/100; i++)
-                       if (summon_specific(-1, p_ptr->y, p_ptr->x, plev, SUMMON_PHANTOM, PM_FORCE_PET))
+                       if (summon_specific(-1, p_ptr->y, p_ptr->x, plev, SUMMON_PHANTOM, PM_FORCE_PET, '\0'))
                                success = TRUE;
                if (success)
                {
@@ -1381,9 +1295,9 @@ static int number_of_mirrors(void)
 {
        POSITION x, y;
        int val = 0;
-       for (x = 0; x < cur_wid; x++) {
-               for (y = 0; y < cur_hgt; y++) {
-                       if (is_mirror_grid(&cave[y][x])) val++;
+       for (x = 0; x < current_floor_ptr->width; x++) {
+               for (y = 0; y < current_floor_ptr->height; y++) {
+                       if (is_mirror_grid(&current_floor_ptr->grid_array[y][x])) val++;
                }
        }
        return val;
@@ -1397,7 +1311,7 @@ static int number_of_mirrors(void)
  */
 static bool cast_mirror_spell(int spell)
 {
-       int             dir;
+       DIRECTION dir;
        PLAYER_LEVEL plev = p_ptr->lev;
        int             tmp;
        TIME_EFFECT t;
@@ -1408,7 +1322,7 @@ static bool cast_mirror_spell(int spell)
        {
                /* mirror of seeing */
        case 0:
-               tmp = is_mirror_grid(&cave[p_ptr->y][p_ptr->x]) ? 4 : 0;
+               tmp = is_mirror_grid(&current_floor_ptr->grid_array[p_ptr->y][p_ptr->x]) ? 4 : 0;
                if (plev + tmp > 4)detect_monsters_normal(DETECT_RAD_DEFAULT);
                if (plev + tmp > 18)detect_monsters_invis(DETECT_RAD_DEFAULT);
                if (plev + tmp > 28)set_tim_esp((TIME_EFFECT)plev, FALSE);
@@ -1428,7 +1342,7 @@ static bool cast_mirror_spell(int spell)
                break;
        case 2:
                if (!get_aim_dir(&dir)) return FALSE;
-               if (plev > 9 && is_mirror_grid(&cave[p_ptr->y][p_ptr->x])) {
+               if (plev > 9 && is_mirror_grid(&current_floor_ptr->grid_array[p_ptr->y][p_ptr->x])) {
                        fire_beam(GF_LITE, dir, damroll(3 + ((plev - 1) / 5), 4));
                }
                else {
@@ -1464,9 +1378,9 @@ static bool cast_mirror_spell(int spell)
                break;
                /* mirror sleeping */
        case 9:
-               for (x = 0; x < cur_wid; x++) {
-                       for (y = 0; y < cur_hgt; y++) {
-                               if (is_mirror_grid(&cave[y][x])) {
+               for (x = 0; x < current_floor_ptr->width; x++) {
+                       for (y = 0; y < current_floor_ptr->height; y++) {
+                               if (is_mirror_grid(&current_floor_ptr->grid_array[y][x])) {
                                        project(0, 2, y, x, (HIT_POINT)plev, GF_OLD_SLEEP, (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP | PROJECT_NO_HANGEKI), -1);
                                }
                        }
@@ -1495,7 +1409,7 @@ static bool cast_mirror_spell(int spell)
                break;
                /* illusion light */
        case 14:
-               tmp = is_mirror_grid(&cave[p_ptr->y][p_ptr->x]) ? 4 : 3;
+               tmp = is_mirror_grid(&current_floor_ptr->grid_array[p_ptr->y][p_ptr->x]) ? 4 : 3;
                slow_monsters(plev);
                stun_monsters(plev*tmp);
                confuse_monsters(plev*tmp);
@@ -1505,7 +1419,7 @@ static bool cast_mirror_spell(int spell)
                break;
                /* mirror shift */
        case 15:
-               if (!is_mirror_grid(&cave[p_ptr->y][p_ptr->x])) {
+               if (!is_mirror_grid(&current_floor_ptr->grid_array[p_ptr->y][p_ptr->x])) {
                        msg_print(_("鏡の国の場所がわからない!", "You cannot find out where is the world of mirror!"));
                        break;
                }
@@ -1518,7 +1432,7 @@ static bool cast_mirror_spell(int spell)
 
                /* mirror of recall */
        case 17:
-               return word_of_recall();
+               return recall_player(p_ptr, randint0(21) + 15);
                /* multi-shadow */
        case 18:
                set_multishadow(6 + randint1(6), FALSE);
@@ -1565,13 +1479,13 @@ static bool cast_berserk_spell(int spell)
                        return FALSE;
                }
 
-               if (!get_rep_dir2(&dir)) return FALSE;
+               if (!get_direction(&dir, FALSE, FALSE)) return FALSE;
 
                if (dir == 5) return FALSE;
                y = p_ptr->y + ddy[dir];
                x = p_ptr->x + ddx[dir];
 
-               if (!cave[y][x].m_idx)
+               if (!current_floor_ptr->grid_array[y][x].m_idx)
                {
                        msg_print(_("その方向にはモンスターはいません。", "There is no monster."));
                        return FALSE;
@@ -1579,24 +1493,22 @@ static bool cast_berserk_spell(int spell)
 
                py_attack(y, x, 0);
 
-               if (!player_can_enter(cave[y][x].feat, 0) || is_trap(cave[y][x].feat))
+               if (!player_can_enter(current_floor_ptr->grid_array[y][x].feat, 0) || is_trap(current_floor_ptr->grid_array[y][x].feat))
                        break;
 
                y += ddy[dir];
                x += ddx[dir];
 
-               if (player_can_enter(cave[y][x].feat, 0) && !is_trap(cave[y][x].feat) && !cave[y][x].m_idx)
+               if (player_can_enter(current_floor_ptr->grid_array[y][x].feat, 0) && !is_trap(current_floor_ptr->grid_array[y][x].feat) && !current_floor_ptr->grid_array[y][x].m_idx)
                {
                        msg_print(NULL);
-
-                       /* Move the player */
                        (void)move_player_effect(y, x, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP);
                }
                break;
        }
        case 2:
        {
-               if (!get_rep_dir2(&dir)) return FALSE;
+               if (!get_direction(&dir, FALSE, FALSE)) return FALSE;
                y = p_ptr->y + ddy[dir];
                x = p_ptr->x + ddx[dir];
                move_player(dir, easy_disarm, TRUE);
@@ -1623,7 +1535,7 @@ static bool cast_berserk_spell(int spell)
  */
 static bool cast_ninja_spell(int spell)
 {
-       POSITION x, y;
+       POSITION x = 0, y = 0;
        DIRECTION dir;
        PLAYER_LEVEL plev = p_ptr->lev;
 
@@ -1706,20 +1618,15 @@ static bool cast_ninja_spell(int spell)
                        }
                        if (slot == INVEN_PACK)
                        {
-#ifdef JP
-                               if (!i) msg_print("くさびを持っていない。");
-                               else msg_print("くさびがなくなった。");
-#else
-                               if (!i) msg_print("You have no Iron Spikes.");
-                               else msg_print("You have no more Iron Spikes.");
-#endif
+                               if (!i) msg_print(_("くさびを持っていない。", "You have no Iron Spikes."));
+                               else msg_print(_("くさびがなくなった。", "You have no more Iron Spikes."));
                                return FALSE;
                        }
 
                        /* Gives a multiplier of 2 at first, up to 3 at 40th */
                        do_cmd_throw(1, FALSE, slot);
 
-                       p_ptr->energy_use = 100;
+                       take_turn(p_ptr, 100);
                }
                break;
        }
@@ -1727,31 +1634,31 @@ static bool cast_ninja_spell(int spell)
        {
                monster_type *m_ptr;
                MONSTER_IDX m_idx;
-               char m_name[80];
+               GAME_TEXT m_name[MAX_NLEN];
                int i;
                int path_n;
                u16b path_g[512];
                POSITION ty, tx;
 
                if (!target_set(TARGET_KILL)) return FALSE;
-               m_idx = cave[target_row][target_col].m_idx;
+               m_idx = current_floor_ptr->grid_array[target_row][target_col].m_idx;
                if (!m_idx) break;
                if (m_idx == p_ptr->riding) break;
                if (!player_has_los_bold(target_row, target_col)) break;
                if (!projectable(p_ptr->y, p_ptr->x, target_row, target_col)) break;
-               m_ptr = &m_list[m_idx];
+               m_ptr = &current_floor_ptr->m_list[m_idx];
                monster_desc(m_name, m_ptr, 0);
                msg_format(_("%sを引き戻した。", "You pull back %s."), m_name);
                path_n = project_path(path_g, MAX_RANGE, target_row, target_col, p_ptr->y, p_ptr->x, 0);
                ty = target_row, tx = target_col;
                for (i = 1; i < path_n; i++)
                {
-                       int ny = GRID_Y(path_g[i]);
-                       int nx = GRID_X(path_g[i]);
-                       cave_type *c_ptr = &cave[ny][nx];
+                       POSITION ny = GRID_Y(path_g[i]);
+                       POSITION nx = GRID_X(path_g[i]);
+                       grid_type *g_ptr = &current_floor_ptr->grid_array[ny][nx];
 
                        if (in_bounds(ny, nx) && cave_empty_bold(ny, nx) &&
-                           !(c_ptr->info & CAVE_OBJECT) &&
+                           !(g_ptr->info & CAVE_OBJECT) &&
                                !pattern_tile(ny, nx))
                        {
                                ty = ny;
@@ -1759,25 +1666,20 @@ static bool cast_ninja_spell(int spell)
                        }
                }
                /* Update the old location */
-               cave[target_row][target_col].m_idx = 0;
+               current_floor_ptr->grid_array[target_row][target_col].m_idx = 0;
 
                /* Update the new location */
-               cave[ty][tx].m_idx = (s16b)m_idx;
+               current_floor_ptr->grid_array[ty][tx].m_idx = m_idx;
 
                /* Move the monster */
-               m_ptr->fy = (byte_hack)ty;
-               m_ptr->fx = (byte_hack)tx;
+               m_ptr->fy = ty;
+               m_ptr->fx = tx;
 
                /* Wake the monster up */
                (void)set_monster_csleep(m_idx, 0);
 
-               /* Update the monster (new location) */
-               update_mon(m_idx, TRUE);
-
-               /* Redraw the old grid */
+               update_monster(m_idx, TRUE);
                lite_spot(target_row, target_col);
-
-               /* Redraw the new grid */
                lite_spot(ty, tx);
 
                if (r_info[m_ptr->r_idx].flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
@@ -1861,45 +1763,39 @@ void do_cmd_mind(void)
 {
        SPELL_IDX n = 0;
        int b = 0;
-       int             chance;
-       int             minfail = 0;
-       int             plev = p_ptr->lev;
+       PERCENTAGE chance;
+       PERCENTAGE minfail = 0;
+       PLAYER_LEVEL plev = p_ptr->lev;
        int             old_csp = p_ptr->csp;
        mind_type       spell;
        bool            cast;
        int             use_mind, mana_cost;
-       cptr            p;
+       concptr            p;
        bool            on_mirror = FALSE;
 
-       /* not if confused */
-       if (p_ptr->confused)
-       {
-               msg_print(_("混乱していて集中できない!", "You are too confused!"));
-               return;
-       }
+       if (cmd_limit_confused(p_ptr)) return;
 
-       /* get power */
        if (!get_mind_power(&n, FALSE)) return;
 
 #ifdef JP
        switch(p_ptr->pclass)
        {
-               case CLASS_MINDCRAFTER: use_mind = MIND_MINDCRAFTER;p = "精神";break;
-               case CLASS_FORCETRAINER:          use_mind = MIND_KI;p = "気";break;
-               case CLASS_BERSERKER:   use_mind = MIND_BERSERKER;p = "怒り";break;
-               case CLASS_MIRROR_MASTER:   use_mind = MIND_MIRROR_MASTER;p = "鏡魔法";break;
-               case CLASS_NINJA:       use_mind = MIND_NINJUTSU;p = "精神";break;
-               default:                use_mind = 0;p = "超能力";break;
+               case CLASS_MINDCRAFTER: use_mind = MIND_MINDCRAFTER; p = "精神";break;
+               case CLASS_FORCETRAINER:          use_mind = MIND_KI; p = "気";break;
+               case CLASS_BERSERKER:   use_mind = MIND_BERSERKER; p = "怒り";break;
+               case CLASS_MIRROR_MASTER:   use_mind = MIND_MIRROR_MASTER; p = "鏡魔法";break;
+               case CLASS_NINJA:       use_mind = MIND_NINJUTSU; p = "精神";break;
+               default:                use_mind = 0 ;p = "超能力"; break;
        }
 #else
        switch(p_ptr->pclass)
        {
-               case CLASS_MINDCRAFTER: use_mind = MIND_MINDCRAFTER;break;
-               case CLASS_FORCETRAINER:          use_mind = MIND_KI;break;
-               case CLASS_BERSERKER:   use_mind = MIND_BERSERKER;break;
-               case CLASS_MIRROR_MASTER:   use_mind = MIND_MIRROR_MASTER;break;
-               case CLASS_NINJA:       use_mind = MIND_NINJUTSU;break;
-               default:                use_mind = 0;break;
+               case CLASS_MINDCRAFTER: use_mind = MIND_MINDCRAFTER; break;
+               case CLASS_FORCETRAINER:          use_mind = MIND_KI; break;
+               case CLASS_BERSERKER:   use_mind = MIND_BERSERKER; break;
+               case CLASS_MIRROR_MASTER:   use_mind = MIND_MIRROR_MASTER; break;
+               case CLASS_NINJA:       use_mind = MIND_NINJUTSU; break;
+               default:                use_mind = 0; break;
        }
 #endif
        spell = mind_powers[use_mind].info[n];
@@ -1912,9 +1808,9 @@ void do_cmd_mind(void)
        {
                if (heavy_armor()) chance += 20;
                if (p_ptr->icky_wield[0]) chance += 20;
-               else if (buki_motteruka(INVEN_RARM)) chance += 10;
+               else if (has_melee_weapon(INVEN_RARM)) chance += 10;
                if (p_ptr->icky_wield[1]) chance += 20;
-               else if (buki_motteruka(INVEN_LARM)) chance += 10;
+               else if (has_melee_weapon(INVEN_LARM)) chance += 10;
                if (n == 5)
                {
                        int j;
@@ -2067,24 +1963,24 @@ void do_cmd_mind(void)
                switch(use_mind)
                {
                case MIND_MINDCRAFTER:
-                       /* Cast the spell */
+                       
                        cast = cast_mindcrafter_spell(n);
                        break;
                case MIND_KI:
-                       /* Cast the spell */
+                       
                        cast = cast_force_spell(n);
                        break;
                case MIND_BERSERKER:
-                       /* Cast the spell */
+                       
                        cast = cast_berserk_spell(n);
                        break;
                case MIND_MIRROR_MASTER:
-                       /* Cast the spell */
-                       if( is_mirror_grid(&cave[p_ptr->y][p_ptr->x]) )on_mirror = TRUE;
+                       
+                       if( is_mirror_grid(&current_floor_ptr->grid_array[p_ptr->y][p_ptr->x]) )on_mirror = TRUE;
                        cast = cast_mirror_spell(n);
                        break;
                case MIND_NINJUTSU:
-                       /* Cast the spell */
+                       
                        cast = cast_ninja_spell(n);
                        break;
                default:
@@ -2096,11 +1992,14 @@ void do_cmd_mind(void)
        }
 
 
-       p_ptr->energy_use = 100;
        /* teleport from mirror costs small energy */
-       if( on_mirror && p_ptr->pclass == CLASS_MIRROR_MASTER )
+       if(on_mirror && p_ptr->pclass == CLASS_MIRROR_MASTER)
        {
-         if( n==3 || n==5 || n==7 || n==16 ) p_ptr->energy_use = 50;
+         if( n==3 || n==5 || n==7 || n==16 ) take_turn(p_ptr, 50);
+       }
+       else
+       {
+               take_turn(p_ptr, 100);
        }
 
        if ((use_mind == MIND_BERSERKER) || (use_mind == MIND_NINJUTSU))
@@ -2136,7 +2035,6 @@ void do_cmd_mind(void)
                if ((p_ptr->csp - mana_cost) < 0) p_ptr->csp_frac = 0;
                p_ptr->csp = MAX(0, p_ptr->csp - mana_cost);
 
-               /* Message */
                msg_format(_("%sを集中しすぎて気を失ってしまった!", "You faint from the effort!"),p);
 
                /* Hack -- Bypass free action */
@@ -2147,18 +2045,13 @@ void do_cmd_mind(void)
                {
                        bool perm = (randint0(100) < 25);
 
-                       /* Message */
                        msg_print(_("自分の精神を攻撃してしまった!", "You have damaged your mind!"));
 
                        /* Reduce constitution */
                        (void)dec_stat(A_WIS, 15 + randint1(10), perm);
                }
        }
-
-       /* Redraw mana */
        p_ptr->redraw |= (PR_MANA);
-
-       /* Window stuff */
        p_ptr->window |= (PW_PLAYER);
        p_ptr->window |= (PW_SPELL);
 }
@@ -2186,7 +2079,6 @@ void do_cmd_mind_browse(void)
 
        while(1)
        {
-               /* get power */
                if (!get_mind_power(&n, TRUE))
                {
                        screen_load();