OSDN Git Service

[Refactor] #37353 コメント整理 / Refactor comments.
[hengband/hengband.git] / src / mind.c
index 5191584..4eef34b 100644 (file)
@@ -402,7 +402,7 @@ static cptr const mind_tips[5][MAX_MIND_POWERS] =
        "1体のモンスターと位置を交換する。",
        "自分のいる床の上に、モンスターが通ると爆発してダメージを与えるルーンを描く。",
        "一定時間、半物質化し壁を通り抜けられるようになる。さらに、一定時間酸への耐性を得る。装備による耐性に累積する。",
-       "自分を中心とした超巨大な毒、生命力吸収、混乱の球を発生させ、テレポートする。",
+       "自分を中心とした超巨大な毒、衰弱、混乱の球を発生させ、テレポートする。",
        "ランダムな方向に何回か炎か地獄かプラズマのビームを放つ。",
        "全ての攻撃が、1/2の確率で無効になる。",
        "",
@@ -420,7 +420,7 @@ static cptr const mind_tips[5][MAX_MIND_POWERS] =
        "Generate a ball centered on you which inflict monster with PSI damage. Or inflict all monsters with PSI damage at level 25.",
        "Removes fear and stun. Gives heroism and speed. Heals HP a little unless you already have heroism and temporal speed boost.",
        "Pulls a distant item close to you.",
-       "Fires a ball which damages monsters and absorbs monsters' mind power. Absorbing is takes more turns which from 0 to 1.5.",
+       "Fires a ball which damages, co. Absorbing is takes more turns which from 0 to 1.5.",
        "Fires a beam of pure energy which penetrate the invulnerability barrier.",
        "Stops time. Consumes all of your SP. The more consumes SP, the longer duration of spell.",
        "",
@@ -545,7 +545,7 @@ void mindcraft_info(char *p, int use_mind, int power)
        cptr s_dur = "dur ";
        cptr s_range = "range ";
 #endif
-       int plev = p_ptr->lev;
+       PLAYER_LEVEL plev = p_ptr->lev;
 
        strcpy(p, "");
 
@@ -576,7 +576,7 @@ void mindcraft_info(char *p, int use_mind, int power)
                break;
        case MIND_KI:
        {
-               int boost = p_ptr->magic_num1[0];
+               int boost = P_PTR_KI;
 
                if (heavy_armor()) boost /= 2;
 
@@ -675,78 +675,79 @@ void mindcraft_info(char *p, int use_mind, int power)
  * when you run it. It's probably easy to fix but I haven't tried,\n
  * sorry.\n
  */
-  static int get_mind_power(int *sn, bool only_browse)
-    {
-      int             i;
-      int             num = 0;
-      int             y = 1;
-      int             x = 10;
-      int             minfail = 0;
-      int             plev = p_ptr->lev;
-      int             chance = 0;
-      int             ask = TRUE;
-      char            choice;
-      char            out_val[160];
-      char            comment[80];
-      cptr            p;
-
-      mind_type       spell;
-      const mind_power      *mind_ptr;
-      bool            flag, redraw;
-      int             use_mind;
-      int menu_line = (use_menu ? 1 : 0);
-
-      switch(p_ptr->pclass)
+static bool_hack get_mind_power(SPELL_IDX *sn, bool only_browse)
+{
+       SPELL_IDX i;
+       int             num = 0;
+       TERM_LEN y = 1;
+       TERM_LEN x = 10;
+       int             minfail = 0;
+       PLAYER_LEVEL plev = p_ptr->lev;
+       int             chance = 0;
+       int             ask = TRUE;
+       char            choice;
+       char            out_val[160];
+       char            comment[80];
+       cptr            p;
+       COMMAND_CODE code;
+       mind_type       spell;
+       const mind_power      *mind_ptr;
+       bool            flag, redraw;
+       int             use_mind;
+       int menu_line = (use_menu ? 1 : 0);
+
+       switch (p_ptr->pclass)
        {
        case CLASS_MINDCRAFTER:
-         {
-           use_mind = MIND_MINDCRAFTER;
-           p = _("超能力", "mindcraft");
-           break;
-         }
+       {
+               use_mind = MIND_MINDCRAFTER;
+               p = _("超能力", "mindcraft");
+               break;
+       }
        case CLASS_FORCETRAINER:
-         {
-           use_mind = MIND_KI;
-           p = _("練気術", "Force");
-           break;
-         }
+       {
+               use_mind = MIND_KI;
+               p = _("練気術", "Force");
+               break;
+       }
        case CLASS_BERSERKER:
-         {
-           use_mind = MIND_BERSERKER;
-           p = _("技", "brutal power");
-           break;
-         }
+       {
+               use_mind = MIND_BERSERKER;
+               p = _("技", "brutal power");
+               break;
+       }
        case CLASS_MIRROR_MASTER:
-         {
-           use_mind = MIND_MIRROR_MASTER;
-           p = _("鏡魔法", "magic");
-           break;
-         }
+       {
+               use_mind = MIND_MIRROR_MASTER;
+               p = _("鏡魔法", "magic");
+               break;
+       }
        case CLASS_NINJA:
-         {
-           use_mind = MIND_NINJUTSU;
-           p = _("忍術", "ninjutsu");
-           break;
-         }
+       {
+               use_mind = MIND_NINJUTSU;
+               p = _("忍術", "ninjutsu");
+               break;
+       }
        default:
-         {
-           use_mind = 0;
-           p = _("超能力", "mindcraft");
-           break;
-         }
+       {
+               use_mind = 0;
+               p = _("超能力", "mindcraft");
+               break;
+       }
        }
-      mind_ptr = &mind_powers[use_mind];
+       mind_ptr = &mind_powers[use_mind];
 
        /* Assume cancelled */
-      *sn = (-1);
-
-#ifdef ALLOW_REPEAT /* TNB */
+       *sn = (-1);
 
        /* Get the spell, if available */
-       if (repeat_pull(sn))
+
+       if (repeat_pull(&code))
        {
+               *sn = (SPELL_IDX)code;
                /* Hack -- If requested INVEN_FORCE(1111), pull again */
-               if (*sn == INVEN_FORCE) repeat_pull(sn);
+               if (*sn == INVEN_FORCE) repeat_pull(&code);
+               *sn = (SPELL_IDX)code;
 
                /* Verify the spell */
                if (mind_ptr->info[*sn].min_lev <= plev)
@@ -756,8 +757,6 @@ void mindcraft_info(char *p, int use_mind, int power)
                }
        }
 
-#endif /* ALLOW_REPEAT -- TNB */
-
     /* Nothing chosen yet */
     flag = FALSE;
 
@@ -852,11 +851,9 @@ void mindcraft_info(char *p, int use_mind, int power)
                                prt("", y, x);
                                put_str(_("名前", "Name"), y, x + 5);
 
-#ifdef JP
-put_str(format("Lv   %s   失率 効果", ((use_mind == MIND_BERSERKER) || (use_mind == MIND_NINJUTSU)) ? "HP" : "MP"), y, x + 35);
-#else
-put_str(format("Lv   %s   Fail Info", ((use_mind == MIND_BERSERKER) || (use_mind == MIND_NINJUTSU)) ? "HP" : "MP"), y, x + 35);
-#endif
+                               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);
 
@@ -892,7 +889,7 @@ put_str(format("Lv   %s   Fail Info", ((use_mind == MIND_BERSERKER) || (use_mind
                                                        if (i == 5)
                                                        {
                                                                int j;
-                                                               for (j = 0; j < p_ptr->magic_num1[0] / 50; j++)
+                                                               for (j = 0; j < P_PTR_KI / 50; j++)
                                                                        mana_cost += (j+1) * 3 / 2;
                                                        }
                                                }
@@ -934,16 +931,12 @@ put_str(format("Lv   %s   Fail Info", ((use_mind == MIND_BERSERKER) || (use_mind
                                                else strcpy(psi_desc, "     ");
                                        }
                                        else
-                                               sprintf(psi_desc, "  %c) ",I2A(i));
+                                               sprintf(psi_desc, "  %c) ", I2A(i));
                                        /* Dump the spell --(-- */
                                        strcat(psi_desc,
                                               format("%-30s%2d %4d%s %3d%%%s",
                                                      spell.name, spell.min_lev, mana_cost,
-#ifdef JP
-                                                     (((use_mind == MIND_MINDCRAFTER) && (i == 13)) ? "~" : "  "), 
-#else
-                                                     (((use_mind == MIND_MINDCRAFTER) && (i == 13)) ? "~ " : "  "), 
-#endif
+                                                     (((use_mind == MIND_MINDCRAFTER) && (i == 13)) ? _("~", "~ ") : "  "),
                                                      chance, comment));
                                        prt(psi_desc, y + i + 1, x);
                                }
@@ -972,7 +965,7 @@ put_str(format("Lv   %s   Fail Info", ((use_mind == MIND_BERSERKER) || (use_mind
                        ask = isupper(choice);
 
                        /* Lowercase */
-                       if (ask) choice = tolower(choice);
+                       if (ask) choice = (char)tolower(choice);
 
                        /* Extract request */
                        i = (islower(choice) ? A2I(choice) : -1);
@@ -1010,7 +1003,6 @@ put_str(format("Lv   %s   Fail Info", ((use_mind == MIND_BERSERKER) || (use_mind
        /* Show choices */
        p_ptr->window |= (PW_SPELL);
 
-       /* Window stuff */
        window_stuff();
 
        /* Abort if needed */
@@ -1019,11 +1011,7 @@ put_str(format("Lv   %s   Fail Info", ((use_mind == MIND_BERSERKER) || (use_mind
        /* Save the choice */
        (*sn) = i;
 
-#ifdef ALLOW_REPEAT /* TNB */
-
-       repeat_push(*sn);
-
-#endif /* ALLOW_REPEAT -- TNB */
+       repeat_push((COMMAND_CODE)i);
 
        /* Success */
        return (TRUE);
@@ -1039,7 +1027,8 @@ static bool cast_mindcrafter_spell(int spell)
 {
        int             b = 0;
        int             dir;
-       int             plev = p_ptr->lev;
+       TIME_EFFECT t;
+       PLAYER_LEVEL plev = p_ptr->lev;
 
        /* spell code */
        switch (spell)
@@ -1069,7 +1058,7 @@ static bool cast_mindcrafter_spell(int spell)
                }
 
                if ((plev > 24) && (plev < 40))
-                       set_tim_esp(plev, FALSE);
+                       set_tim_esp((TIME_EFFECT)plev, FALSE);
 
                if (!b) msg_print(_("安全な気がする。", "You feel safe."));
 
@@ -1113,12 +1102,12 @@ static bool cast_mindcrafter_spell(int spell)
                break;
        case 6:
                /* Character Armour */
-               set_shield(plev, FALSE);
-               if (plev > 14) set_oppose_acid(plev, FALSE);
-               if (plev > 19) set_oppose_fire(plev, FALSE);
-               if (plev > 24) set_oppose_cold(plev, FALSE);
-               if (plev > 29) set_oppose_elec(plev, FALSE);
-               if (plev > 34) set_oppose_pois(plev, FALSE);
+               set_shield((TIME_EFFECT)plev, FALSE);
+               if (plev > 14) set_oppose_acid((TIME_EFFECT)plev, FALSE);
+               if (plev > 19) set_oppose_fire((TIME_EFFECT)plev, FALSE);
+               if (plev > 24) set_oppose_cold((TIME_EFFECT)plev, FALSE);
+               if (plev > 29) set_oppose_elec((TIME_EFFECT)plev, FALSE);
+               if (plev > 34) set_oppose_pois((TIME_EFFECT)plev, FALSE);
                break;
        case 7:
                /* Psychometry */
@@ -1150,10 +1139,10 @@ static bool cast_mindcrafter_spell(int spell)
                        hp_player(plev);
                }
 
-               b = 10 + randint1((plev * 3) / 2);
-               set_hero(b, FALSE);
+               t = 10 + randint1((plev * 3) / 2);
+               set_hero(t, FALSE);
                /* Haste */
-               (void)set_fast(b, FALSE);
+               (void)set_fast(t, FALSE);
                break;
        case 10:
                /* Telekinesis */
@@ -1192,13 +1181,11 @@ static bool cast_mindcrafter_spell(int spell)
                /* 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();
@@ -1219,9 +1206,9 @@ static bool cast_mindcrafter_spell(int spell)
  */
 static bool cast_force_spell(int spell)
 {
-       int             dir;
-       int             plev = p_ptr->lev;
-       int             boost = p_ptr->magic_num1[0];
+       DIRECTION dir;
+       PLAYER_LEVEL plev = p_ptr->lev;
+       int boost = P_PTR_KI;
 
        if (heavy_armor()) boost /= 2;
 
@@ -1249,12 +1236,12 @@ static bool cast_force_spell(int spell)
                break;
        case 5:
                msg_print(_("気を練った。", "You improved the Force."));
-               p_ptr->magic_num1[0] += (70 + plev);
+               P_PTR_KI += (70 + plev);
                p_ptr->update |= (PU_BONUS);
-               if (randint1(p_ptr->magic_num1[0]) > (plev * 4 + 120))
+               if (randint1(P_PTR_KI) > (plev * 4 + 120))
                {
                        msg_print(_("気が暴走した!", "The Force exploded!"));
-                       fire_ball(GF_MANA, 0, p_ptr->magic_num1[0] / 2, 10);
+                       fire_ball(GF_MANA, 0, P_PTR_KI / 2, 10);
                        take_hit(DAMAGE_LOSELIFE, p_ptr->magic_num1[0] / 2, _("気の暴走", "Explosion of the Force"), -1);
                }
                else return TRUE;
@@ -1263,70 +1250,15 @@ 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;
-                       int 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 = m_idx;
-                                       m_ptr->fy = ty;
-                                       m_ptr->fx = 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);
                break;
        case 9:
        {
-               int m_idx;
+               MONSTER_IDX m_idx;
 
                if (!target_set(TARGET_KILL)) return FALSE;
                m_idx = cave[target_row][target_col].m_idx;
@@ -1368,7 +1300,7 @@ static bool cast_force_spell(int spell)
        default:
                msg_print(_("なに?", "Zap?"));
        }
-       p_ptr->magic_num1[0] = 0;
+       P_PTR_KI = 0;
        p_ptr->update |= (PU_BONUS);
 
        return TRUE;
@@ -1379,16 +1311,16 @@ static bool cast_force_spell(int spell)
  * @brief 現在フロアに存在している鏡の数を数える / calculate mirrors
  * @return 鏡の枚数
  */
-static int number_of_mirrors( void )
+static int number_of_mirrors(void)
 {
-  int 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++;
-    }
-  }
-  return val;
+       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++;
+               }
+       }
+       return val;
 }
 
 /*!
@@ -1400,138 +1332,139 @@ static int number_of_mirrors( void )
 static bool cast_mirror_spell(int spell)
 {
        int             dir;
-       int             plev = p_ptr->lev;
+       PLAYER_LEVEL plev = p_ptr->lev;
        int             tmp;
-       int             x,y;
+       TIME_EFFECT t;
+       int             x, y;
 
        /* spell code */
        switch (spell)
        {
-       /* mirror of seeing */
+               /* mirror of seeing */
        case 0:
-         tmp = is_mirror_grid(&cave[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(plev,FALSE);
-         if( plev + tmp > 38 )map_area(DETECT_RAD_MAP);
-         if( tmp == 0 && plev < 5 ){
-           msg_print(_("鏡がなくて集中できなかった!", "You need a mirror to concentrate!"));
-         }
-         break;
-       /* drip of light */
+               tmp = is_mirror_grid(&cave[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);
+               if (plev + tmp > 38)map_area(DETECT_RAD_MAP);
+               if (tmp == 0 && plev < 5) {
+                       msg_print(_("鏡がなくて集中できなかった!", "You need a mirror to concentrate!"));
+               }
+               break;
+               /* drip of light */
        case 1:
-         if( number_of_mirrors() < 4 + plev/10 ){
-           place_mirror();
-         }
-         else {
+               if (number_of_mirrors() < 4 + plev / 10) {
+                       place_mirror();
+               }
+               else {
                        msg_format(_("これ以上鏡は制御できない!", "There are too many mirrors to control!"));
-         }
-         break;
+               }
+               break;
        case 2:
-         if (!get_aim_dir(&dir)) return FALSE;
-         if ( plev > 9 && is_mirror_grid(&cave[p_ptr->y][p_ptr->x]) ) {
-           fire_beam(GF_LITE, dir,damroll(3+((plev-1)/5),4));
-         }
-         else {
-           fire_bolt(GF_LITE, dir,damroll(3+((plev-1)/5),4));
-         }
-         break;
-       /* warped mirror */
+               if (!get_aim_dir(&dir)) return FALSE;
+               if (plev > 9 && is_mirror_grid(&cave[p_ptr->y][p_ptr->x])) {
+                       fire_beam(GF_LITE, dir, damroll(3 + ((plev - 1) / 5), 4));
+               }
+               else {
+                       fire_bolt(GF_LITE, dir, damroll(3 + ((plev - 1) / 5), 4));
+               }
+               break;
+               /* warped mirror */
        case 3:
-         teleport_player(10, 0L);
-         break;
-       /* mirror of light */
+               teleport_player(10, 0L);
+               break;
+               /* mirror of light */
        case 4:
-         (void)lite_area(damroll(2, (plev / 2)), (plev / 10) + 1);
-         break;
-       /* mirror of wandering */
+               (void)lite_area(damroll(2, (plev / 2)), (plev / 10) + 1);
+               break;
+               /* mirror of wandering */
        case 5:
-         teleport_player(plev * 5, 0L);
-         break;
-       /* robe of dust */
+               teleport_player(plev * 5, 0L);
+               break;
+               /* robe of dust */
        case 6:
-         set_dustrobe(20+randint1(20),FALSE);
-         break;
-       /* banishing mirror */
+               set_dustrobe(20 + randint1(20), FALSE);
+               break;
+               /* banishing mirror */
        case 7:
-         if (!get_aim_dir(&dir)) return FALSE;
-         (void)fire_beam(GF_AWAY_ALL, dir , plev);
-         break;
-       /* mirror clashing */
+               if (!get_aim_dir(&dir)) return FALSE;
+               (void)fire_beam(GF_AWAY_ALL, dir, plev);
+               break;
+               /* mirror clashing */
        case 8:
-         if (!get_aim_dir(&dir)) return FALSE;
-         fire_ball(GF_SHARDS, dir, damroll(8 + ((plev - 5) / 4), 8),
-                   (plev > 20 ? (plev - 20) / 8 + 1 : 0));
-         break;
-       /* mirror sleeping */
+               if (!get_aim_dir(&dir)) return FALSE;
+               fire_ball(GF_SHARDS, dir, damroll(8 + ((plev - 5) / 4), 8),
+                       (plev > 20 ? (plev - 20) / 8 + 1 : 0));
+               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])) {
-               project(0,2,y,x,plev,GF_OLD_SLEEP,(PROJECT_GRID|PROJECT_ITEM|PROJECT_KILL|PROJECT_JUMP|PROJECT_NO_HANGEKI),-1);
-             }
-           }
-         }
-         break;
-       /* seeker ray */
+               for (x = 0; x < cur_wid; x++) {
+                       for (y = 0; y < cur_hgt; y++) {
+                               if (is_mirror_grid(&cave[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);
+                               }
+                       }
+               }
+               break;
+               /* seeker ray */
        case 10:
-         if (!get_aim_dir(&dir)) return FALSE;
-         fire_beam(GF_SEEKER,dir, damroll(11+(plev-5)/4,8));
-         break;
-       /* seal of mirror */
+               if (!get_aim_dir(&dir)) return FALSE;
+               fire_beam(GF_SEEKER, dir, damroll(11 + (plev - 5) / 4, 8));
+               break;
+               /* seal of mirror */
        case 11:
-         seal_of_mirror(plev*4+100);
-         break;
-       /* shield of water */
+               seal_of_mirror(plev * 4 + 100);
+               break;
+               /* shield of water */
        case 12:
-         tmp = 20+randint1(20);
-         set_shield(tmp, FALSE);
-         if( plev > 31 )set_tim_reflect(tmp, FALSE);
-         if( plev > 39 )set_resist_magic(tmp,FALSE);
-         break;
-       /* super ray */
+               t = 20 + randint1(20);
+               set_shield(t, FALSE);
+               if (plev > 31)set_tim_reflect(t, FALSE);
+               if (plev > 39)set_resist_magic(t, FALSE);
+               break;
+               /* super ray */
        case 13:
-         if (!get_aim_dir(&dir)) return FALSE;
-         fire_beam(GF_SUPER_RAY,dir, 150+randint1(2*plev));
-         break;
-       /* illusion light */
+               if (!get_aim_dir(&dir)) return FALSE;
+               fire_beam(GF_SUPER_RAY, dir, 150 + randint1(2 * plev));
+               break;
+               /* illusion light */
        case 14:
-         tmp = is_mirror_grid(&cave[p_ptr->y][p_ptr->x]) ? 4 : 3;
-         slow_monsters(plev);
-         stun_monsters(plev*tmp);
-         confuse_monsters(plev*tmp);
-         turn_monsters(plev*tmp);
-         stun_monsters(plev*tmp);
-         stasis_monsters(plev*tmp);
-         break;
-       /* mirror shift */
+               tmp = is_mirror_grid(&cave[p_ptr->y][p_ptr->x]) ? 4 : 3;
+               slow_monsters(plev);
+               stun_monsters(plev*tmp);
+               confuse_monsters(plev*tmp);
+               turn_monsters(plev*tmp);
+               stun_monsters(plev*tmp);
+               stasis_monsters(plev*tmp);
+               break;
+               /* mirror shift */
        case 15:
-         if( !is_mirror_grid(&cave[p_ptr->y][p_ptr->x]) ){
-               msg_print(_("鏡の国の場所がわからない!", "You cannot find out where is the world of mirror!"));
+               if (!is_mirror_grid(&cave[p_ptr->y][p_ptr->x])) {
+                       msg_print(_("鏡の国の場所がわからない!", "You cannot find out where is the world of mirror!"));
+                       break;
+               }
+               alter_reality();
                break;
-         }
-         alter_reality();
-         break;
-       /* mirror tunnel */
+               /* mirror tunnel */
        case 16:
-         msg_print(_("鏡の世界を通り抜け…  ", "Go through the world of mirror..."));
-         return mirror_tunnel();
+               msg_print(_("鏡の世界を通り抜け…  ", "Go through the world of mirror..."));
+               return mirror_tunnel();
 
-       /* mirror of recall */
+               /* mirror of recall */
        case 17:
                return word_of_recall();
-       /* multi-shadow */
+               /* multi-shadow */
        case 18:
-         set_multishadow(6+randint1(6),FALSE);
-         break;
-       /* binding field */
+               set_multishadow(6 + randint1(6), FALSE);
+               break;
+               /* binding field */
        case 19:
-         if( !binding_field(plev*11+5) )msg_print(_("適当な鏡を選べなかった!", "You were not able to choose suitable mirrors!"));
-         break;
-       /* mirror of Ruffnor */
+               if (!binding_field(plev * 11 + 5))msg_print(_("適当な鏡を選べなかった!", "You were not able to choose suitable mirrors!"));
+               break;
+               /* mirror of Ruffnor */
        case 20:
-         (void)set_invuln(randint1(4)+4,FALSE);
-         break;
+               (void)set_invuln(randint1(4) + 4, FALSE);
+               break;
        default:
                msg_print(_("なに?", "Zap?"));
 
@@ -1549,8 +1482,8 @@ static bool cast_mirror_spell(int spell)
  */
 static bool cast_berserk_spell(int spell)
 {
-       int y, x;
-       int dir;
+       POSITION y, x;
+       DIRECTION dir;
 
        /* spell code */
        switch (spell)
@@ -1566,7 +1499,7 @@ 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];
@@ -1597,7 +1530,7 @@ static bool cast_berserk_spell(int spell)
        }
        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);
@@ -1624,9 +1557,9 @@ static bool cast_berserk_spell(int spell)
  */
 static bool cast_ninja_spell(int spell)
 {
-       int x, y;
-       int dir;
-       int plev = p_ptr->lev;
+       POSITION x, y;
+       DIRECTION dir;
+       PLAYER_LEVEL plev = p_ptr->lev;
 
        /* spell code */
        switch (spell)
@@ -1673,22 +1606,7 @@ static bool cast_ninja_spell(int spell)
        }
        case 5:
        {
-               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)
-               {
-                       py_attack(y, x, 0);
-                       if (randint0(p_ptr->skill_dis) < 7)
-                               msg_print(_("うまく逃げられなかった。", "You failed to run away."));
-                       else
-                               teleport_player(30, 0L);
-               }
-               else
-               {
-                       msg_print(_("その方向にはモンスターはいません。", "You don't see any monster in this direction"));
-                       msg_print(NULL);
-               }
+               if(!panic_hit()) return FALSE;
                break;
        }
        case 6:
@@ -1705,7 +1623,7 @@ static bool cast_ninja_spell(int spell)
        case 9:
                fire_ball(GF_FIRE, 0, 50+plev, plev/10+2);
                teleport_player(30, 0L);
-               set_oppose_fire(plev, FALSE);
+               set_oppose_fire((TIME_EFFECT)plev, FALSE);
                break;
        case 10:
                return rush_attack(NULL);
@@ -1714,7 +1632,7 @@ static bool cast_ninja_spell(int spell)
                int i;
                for (i = 0; i < 8; i++)
                {
-                       int slot;
+                       OBJECT_IDX slot;
 
                        for (slot = 0; slot < INVEN_PACK; slot++)
                        {
@@ -1733,7 +1651,7 @@ static bool cast_ninja_spell(int spell)
                        }
 
                        /* Gives a multiplier of 2 at first, up to 3 at 40th */
-                       do_cmd_throw_aux(1, FALSE, slot);
+                       do_cmd_throw(1, FALSE, slot);
 
                        p_ptr->energy_use = 100;
                }
@@ -1742,12 +1660,12 @@ static bool cast_ninja_spell(int spell)
        case 12:
        {
                monster_type *m_ptr;
-               int m_idx;
+               MONSTER_IDX m_idx;
                char m_name[80];
                int i;
                int path_n;
                u16b path_g[512];
-               int ty,tx;
+               POSITION ty, tx;
 
                if (!target_set(TARGET_KILL)) return FALSE;
                m_idx = cave[target_row][target_col].m_idx;
@@ -1778,17 +1696,17 @@ static bool cast_ninja_spell(int spell)
                cave[target_row][target_col].m_idx = 0;
 
                /* Update the new location */
-               cave[ty][tx].m_idx = m_idx;
+               cave[ty][tx].m_idx = (s16b)m_idx;
 
                /* Move the monster */
-               m_ptr->fy = ty;
-               m_ptr->fx = tx;
+               m_ptr->fy = (byte_hack)ty;
+               m_ptr->fx = (byte_hack)tx;
 
                /* Wake the monster up */
                (void)set_monster_csleep(m_idx, 0);
 
                /* Update the monster (new location) */
-               update_mon(m_idx, TRUE);
+               update_monster(m_idx, TRUE);
 
                /* Redraw the old grid */
                lite_spot(target_row, target_col);
@@ -1830,11 +1748,11 @@ static bool cast_ninja_spell(int spell)
                break;
        case 16:
                (void)set_kabenuke(randint1(plev/2) + plev/2, FALSE);
-               set_oppose_acid(plev, FALSE);
+               set_oppose_acid((TIME_EFFECT)plev, FALSE);
                break;
        case 17:
                fire_ball(GF_POIS, 0, 75+plev*2/3, plev/5+2);
-               fire_ball(GF_OLD_DRAIN, 0, 75+plev*2/3, plev/5+2);
+               fire_ball(GF_HYPODYNAMIA, 0, 75+plev*2/3, plev/5+2);
                fire_ball(GF_CONFUSION, 0, 75+plev*2/3, plev/5+2);
                teleport_player(30, 0L);
                break;
@@ -1845,7 +1763,7 @@ static bool cast_ninja_spell(int spell)
 
                for (k = 0; k < num; k++)
                {
-                       int typ = one_in_(2) ? GF_FIRE : one_in_(3) ? GF_NETHER : GF_PLASMA;
+                       EFFECT_ID typ = one_in_(2) ? GF_FIRE : one_in_(3) ? GF_NETHER : GF_PLASMA;
                        int attempts = 1000;
 
                        while (attempts--)
@@ -1875,10 +1793,11 @@ static bool cast_ninja_spell(int spell)
  */
 void do_cmd_mind(void)
 {
-       int             n = 0,  b = 0;
+       SPELL_IDX n = 0;
+       int b = 0;
        int             chance;
        int             minfail = 0;
-       int             plev = p_ptr->lev;
+       PLAYER_LEVEL plev = p_ptr->lev;
        int             old_csp = p_ptr->csp;
        mind_type       spell;
        bool            cast;
@@ -1933,7 +1852,7 @@ void do_cmd_mind(void)
                if (n == 5)
                {
                        int j;
-                       for (j = 0; j < p_ptr->magic_num1[0] / 50; j++)
+                       for (j = 0; j < P_PTR_KI / 50; j++)
                                mana_cost += (j+1) * 3 / 2;
                }
        }
@@ -2006,10 +1925,10 @@ void do_cmd_mind(void)
 
                if ((use_mind != MIND_BERSERKER) && (use_mind != MIND_NINJUTSU))
                {
-                       if ((use_mind == MIND_KI) && (n != 5) && p_ptr->magic_num1[0])
+                       if ((use_mind == MIND_KI) && (n != 5) && P_PTR_KI)
                        {
                                msg_print(_("気が散ってしまった...", "Your improved Force has gone away..."));
-                               p_ptr->magic_num1[0] = 0;
+                               P_PTR_KI = 0;
                        }
 
                        if (randint1(100) < (chance / 2))
@@ -2111,7 +2030,6 @@ void do_cmd_mind(void)
        }
 
 
-       /* Take a turn */
        p_ptr->energy_use = 100;
        /* teleport from mirror costs small energy */
        if( on_mirror && p_ptr->pclass == CLASS_MIRROR_MASTER )
@@ -2152,7 +2070,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 */
@@ -2163,7 +2080,6 @@ void do_cmd_mind(void)
                {
                        bool perm = (randint0(100) < 25);
 
-                       /* Message */
                        msg_print(_("自分の精神を攻撃してしまった!", "You have damaged your mind!"));
 
                        /* Reduce constitution */
@@ -2174,7 +2090,6 @@ void do_cmd_mind(void)
        /* Redraw mana */
        p_ptr->redraw |= (PR_MANA);
 
-       /* Window stuff */
        p_ptr->window |= (PW_PLAYER);
        p_ptr->window |= (PW_SPELL);
 }
@@ -2186,7 +2101,7 @@ void do_cmd_mind(void)
  */
 void do_cmd_mind_browse(void)
 {
-       int n = 0;
+       SPELL_IDX n = 0;
        int j, line;
        char temp[62*5];
        int use_mind = 0;