OSDN Git Service

[Refactor] #37353 monster1~monster-hook間整理。 / Refactor between monster1 and monster...
[hengband/hengband.git] / src / mutation.c
index 44845c7..73d46dd 100644 (file)
  */
 bool gain_random_mutation(int choose_mut)
 {
-       int     attempts_left = 20;
-       cptr    muta_desc = "";
-       bool    muta_chosen = FALSE;
-       u32b    muta_which = 0;
-       u32b    *muta_class = NULL;
+       int attempts_left = 20;
+       cptr muta_desc = "";
+       bool muta_chosen = FALSE;
+       BIT_FLAGS muta_which = 0;
+       BIT_FLAGS *muta_class = NULL;
 
        if (choose_mut) attempts_left = 1;
 
@@ -862,8 +862,8 @@ bool lose_mutation(int choose_mut)
        int attempts_left = 20;
        cptr muta_desc = "";
        bool muta_chosen = FALSE;
-       u32b muta_which = 0;
-       u32b *muta_class = NULL;
+       BIT_FLAGS muta_which = 0;
+       BIT_FLAGS *muta_class = NULL;
 
        if (choose_mut) attempts_left = 1;
 
@@ -2019,23 +2019,6 @@ void do_cmd_knowledge_mutations(void)
        fd_kill(file_name);
 }
 
-/*!
- * @brief 符号なし32ビット整数のビット数を返す。
- * @param x ビット数を調べたい変数
- * @return ビット数
- */
-int count_bits(BIT_FLAGS x)
-{
-       int n = 0;
-
-       if (x) do
-       {
-               n++;
-       }
-       while (0 != (x = x&(x-1)));
-
-       return (n);
-}
 
 /*!
  * @brief 現在プレイヤー得ている突然変異の数を返す。
@@ -2083,133 +2066,72 @@ int calc_mutant_regenerate_mod(void)
        return (regen);
 }
 
-/*!
- * @brief 突然変異レイシャル上で口を使うよりを行った際に歌や呪術を停止する /
- * @return なし
- */
-static void mutation_stop_mouth(void)
-{
-       if (music_singing_any()) stop_singing();
-       if (hex_spelling_any()) stop_hex_spell_all();
-}
-
 
 /*!
  * @brief 突然変異のレイシャル効果実装
- * @return 発動させる突然変異レイシャルのID
+ * @param power 発動させる突然変異レイシャルのID
  * @return レイシャルを実行した場合TRUE、キャンセルした場合FALSEを返す
  */
-bool mutation_power_aux(u32b power)
+bool mutation_power_aux(int power)
 {
-       int     dir = 0;
-       int     lvl = p_ptr->lev;
-
+       DIRECTION dir = 0;
+       PLAYER_LEVEL lvl = p_ptr->lev;
 
        switch (power)
        {
                case MUT1_SPIT_ACID:
                        if (!get_aim_dir(&dir)) return FALSE;
-                       mutation_stop_mouth();
+                       stop_mouth();
                        msg_print(_("酸を吐きかけた...", "You spit acid..."));
-
                        fire_ball(GF_ACID, dir, lvl, 1 + (lvl / 30));
                        break;
 
                case MUT1_BR_FIRE:
                        if (!get_aim_dir(&dir)) return FALSE;
-                       mutation_stop_mouth();
+                       stop_mouth();
                        msg_print(_("あなたは火炎のブレスを吐いた...", "You breathe fire..."));
-
                        fire_breath(GF_FIRE, dir, lvl * 2, 1 + (lvl / 20));
                        break;
 
                case MUT1_HYPN_GAZE:
                        if (!get_aim_dir(&dir)) return FALSE;
                        msg_print(_("あなたの目は幻惑的になった...", "Your eyes look mesmerizing..."));
-
                        (void)charm_monster(dir, lvl);
                        break;
 
                case MUT1_TELEKINES:
                        if (!get_aim_dir(&dir)) return FALSE;
                        msg_print(_("集中している...", "You concentrate..."));
-
                        fetch(dir, lvl * 10, TRUE);
                        break;
 
                case MUT1_VTELEPORT:
                        msg_print(_("集中している...", "You concentrate..."));
-
                        teleport_player(10 + 4 * lvl, 0L);
                        break;
 
                case MUT1_MIND_BLST:
                        if (!get_aim_dir(&dir)) return FALSE;
                        msg_print(_("集中している...", "You concentrate..."));
-
                        fire_bolt(GF_PSI, dir, damroll(3 + ((lvl - 1) / 5), 3));
                        break;
 
                case MUT1_RADIATION:
                        msg_print(_("体から放射能が発生した!", "Radiation flows from your body!"));
-
                        fire_ball(GF_NUKE, 0, (lvl * 2), 3 + (lvl / 20));
                        break;
 
                case MUT1_VAMPIRISM:
-                       {
-                               int x, y, dummy;
-                               cave_type *c_ptr;
-
-                               /* Only works on adjacent monsters */
-                               if (!get_rep_dir2(&dir)) return FALSE;
-                               y = p_ptr->y + ddy[dir];
-                               x = p_ptr->x + ddx[dir];
-                               c_ptr = &cave[y][x];
-
-                               mutation_stop_mouth();
-
-                               if (!(c_ptr->m_idx))
-                               {
-                                       msg_print(_("何もない場所に噛みついた!", "You bite into thin air!"));
-
-                                       break;
-                               }
-
-                               msg_print(_("あなたはニヤリとして牙をむいた...", "You grin and bare your fangs..."));
-
-
-                               dummy = lvl * 2;
-
-                               if (hypodynamic_bolt(dir, dummy))
-                               {
-                                       if (p_ptr->food < PY_FOOD_FULL)
-                                               /* No heal if we are "full" */
-                                               (void)hp_player(dummy);
-                                       else
-                                               msg_print(_("あなたは空腹ではありません。", "You were not hungry."));
-
-                                       /* Gain nutritional sustenance: 150/hp drained */
-                                       /* A Food ration gives 5000 food points (by contrast) */
-                                       /* Don't ever get more than "Full" this way */
-                                       /* But if we ARE Gorged,  it won't cure us */
-                                       dummy = p_ptr->food + MIN(5000, 100 * dummy);
-                                       if (p_ptr->food < PY_FOOD_MAX)   /* Not gorged already */
-                                               (void)set_food(dummy >= PY_FOOD_MAX ? PY_FOOD_MAX-1 : dummy);
-                               }
-                               else
-                                       msg_print(_("げぇ!ひどい味だ。", "Yechh. That tastes foul."));
-
-                       }
+                       vampirism();
                        break;
 
                case MUT1_SMELL_MET:
-                       mutation_stop_mouth();
+                       stop_mouth();
                        (void)detect_treasure(DETECT_RAD_DEFAULT);
                        break;
 
                case MUT1_SMELL_MON:
-                       mutation_stop_mouth();
+                       stop_mouth();
                        (void)detect_monsters_normal(DETECT_RAD_DEFAULT);
                        break;
 
@@ -2218,68 +2140,7 @@ bool mutation_power_aux(u32b power)
                        break;
 
                case MUT1_EAT_ROCK:
-                       {
-                               int x, y;
-                               cave_type *c_ptr;
-                               feature_type *f_ptr, *mimic_f_ptr;
-
-                               if (!get_rep_dir2(&dir)) return FALSE;
-                               y = p_ptr->y + ddy[dir];
-                               x = p_ptr->x + ddx[dir];
-                               c_ptr = &cave[y][x];
-                               f_ptr = &f_info[c_ptr->feat];
-                               mimic_f_ptr = &f_info[get_feat_mimic(c_ptr)];
-
-                               mutation_stop_mouth();
-
-                               if (!have_flag(mimic_f_ptr->flags, FF_HURT_ROCK))
-                               {
-                                       msg_print(_("この地形は食べられない。", "You cannot eat this feature."));
-                                       break;
-                               }
-                               else if (have_flag(f_ptr->flags, FF_PERMANENT))
-                               {
-                                       msg_format(_("いてっ!この%sはあなたの歯より硬い!", "Ouch!  This %s is harder than your teeth!"), f_name + mimic_f_ptr->name);
-                                       break;
-                               }
-                               else if (c_ptr->m_idx)
-                               {
-                                       monster_type *m_ptr = &m_list[c_ptr->m_idx];
-                                       msg_print(_("何かが邪魔しています!", "There's something in the way!"));
-
-                                       if (!m_ptr->ml || !is_pet(m_ptr)) py_attack(y, x, 0);
-                                       break;
-                               }
-                               else if (have_flag(f_ptr->flags, FF_TREE))
-                               {
-                                       msg_print(_("木の味は好きじゃない!", "You don't like the woody taste!"));
-                                       break;
-                               }
-                               else if (have_flag(f_ptr->flags, FF_GLASS))
-                               {
-                                       msg_print(_("ガラスの味は好きじゃない!", "You don't like the glassy taste!"));
-                                       break;
-                               }
-                               else if (have_flag(f_ptr->flags, FF_DOOR) || have_flag(f_ptr->flags, FF_CAN_DIG))
-                               {
-                                       (void)set_food(p_ptr->food + 3000);
-                               }
-                               else if (have_flag(f_ptr->flags, FF_MAY_HAVE_GOLD) || have_flag(f_ptr->flags, FF_HAS_GOLD))
-                               {
-                                       (void)set_food(p_ptr->food + 5000);
-                               }
-                               else
-                               {
-                                       msg_format(_("この%sはとてもおいしい!", "This %s is very filling!"), f_name + mimic_f_ptr->name);
-                                       (void)set_food(p_ptr->food + 10000);
-                               }
-
-                               /* Destroy the wall */
-                               cave_alter_feat(y, x, FF_HURT_ROCK);
-
-                               /* Move the player */
-                               (void)move_player_effect(y, x, MPE_DONT_PICKUP);
-                       }
+                       return eat_lock();
                        break;
 
                case MUT1_SWAP_POS:
@@ -2294,7 +2155,7 @@ bool mutation_power_aux(u32b power)
                        break;
 
                case MUT1_SHRIEK:
-                       mutation_stop_mouth();
+                       stop_mouth();
                        (void)fire_ball(GF_SOUND, 0, 2 * lvl, 8);
                        (void)aggravate_monsters(0);
                        break;
@@ -2320,9 +2181,7 @@ bool mutation_power_aux(u32b power)
                        break;
 
                case MUT1_BERSERK:
-                       (void)set_shero(randint1(25) + 25, FALSE);
-                       (void)hp_player(30);
-                       (void)set_afraid(0);
+                       (void)berserk(randint1(25) + 25);
                        break;
 
                case MUT1_POLYMORPH:
@@ -2337,7 +2196,7 @@ bool mutation_power_aux(u32b power)
                /* Summon pet molds around the player */
                case MUT1_GROW_MOLD:
                        {
-                               int i;
+                               DIRECTION i;
                                for (i = 0; i < 8; i++)
                                {
                                        summon_specific(-1, p_ptr->y, p_ptr->x, lvl, SUMMON_MOLD, PM_FORCE_PET);
@@ -2391,39 +2250,13 @@ bool mutation_power_aux(u32b power)
                        break;
 
                case MUT1_STERILITY:
-                       /* Fake a population explosion. */
-#ifdef JP
-                       msg_print("突然頭が痛くなった!");
-                       take_hit(DAMAGE_LOSELIFE, randint1(17) + 17, "禁欲を強いた疲労", -1);
-#else
-                       msg_print("You suddenly have a headache!");
-                       take_hit(DAMAGE_LOSELIFE, randint1(17) + 17, "the strain of forcing abstinence", -1);
-#endif
-
+                       msg_print(_("突然頭が痛くなった!", "You suddenly have a headache!"));
+                       take_hit(DAMAGE_LOSELIFE, randint1(17) + 17, _("禁欲を強いた疲労", "the strain of forcing abstinence"), -1);
                        num_repro += MAX_REPRO;
                        break;
 
                case MUT1_PANIC_HIT:
-                       {
-                               int x, y;
-
-                               if (!get_rep_dir2(&dir)) 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 teleport."));
-                                       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 MUT1_DAZZLE:
@@ -2443,12 +2276,11 @@ bool mutation_power_aux(u32b power)
 
                case MUT1_BANISH:
                        {
-                               int x, y;
+                               POSITION x, y;
                                cave_type *c_ptr;
                                monster_type *m_ptr;
                                monster_race *r_ptr;
-
-                               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];
                                c_ptr = &cave[y][x];
@@ -2473,11 +2305,9 @@ bool mutation_power_aux(u32b power)
                                        if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
                                        {
                                                char m_name[80];
-
                                                monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
                                                do_cmd_write_nikki(NIKKI_NAMED_PET, RECORD_NAMED_PET_GENOCIDE, m_name);
                                        }
-
                                        /* Delete the monster, rather than killing it. */
                                        delete_monster_idx(c_ptr->m_idx);
                                        msg_print(_("その邪悪なモンスターは硫黄臭い煙とともに消え去った!", "The evil creature vanishes in a puff of sulfurous smoke!"));
@@ -2486,7 +2316,6 @@ bool mutation_power_aux(u32b power)
                                else
                                {
                                        msg_print(_("祈りは効果がなかった!", "Your invocation is ineffectual!"));
-
                                        if (one_in_(13)) m_ptr->mflag2 |= MFLAG2_NOGENO;
                                }
                        }
@@ -2494,14 +2323,12 @@ bool mutation_power_aux(u32b power)
 
                case MUT1_COLD_TOUCH:
                        {
-                               int x, y;
+                               POSITION x, y;
                                cave_type *c_ptr;
-
-                               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];
                                c_ptr = &cave[y][x];
-
                                if (!c_ptr->m_idx)
                                {
                                        msg_print(_("あなたは何もない場所で手を振った。", "You wave your hands in the air."));
@@ -2512,7 +2339,7 @@ bool mutation_power_aux(u32b power)
                        }
                        break;
 
-               /* XXX_XXX_XXX Hack!  MUT1_LAUNCHER is negative, see above */
+               /* XXX_XXX_XXX Hack! MUT1_LAUNCHER is negative, see above */
                case 3: /* MUT1_LAUNCHER */
                        /* Gives a multiplier of 2 at first, up to 3 at 40th */
                        if (!do_cmd_throw(2 + lvl / 40, FALSE, -1)) return FALSE;