OSDN Git Service

ユニークのクローンを倒した場合はその旨playrecordに明記するように変更.
[hengband/hengband.git] / src / cmd5.c
index d979e12..639f31b 100644 (file)
@@ -149,21 +149,20 @@ static int get_spell(int *sn, cptr prompt, int sval, bool learned, int use_realm
 
        /* 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 = ' '; 
-               else if( !get_com(out_val, &choice, TRUE) )break; 
+               if (choice == ESCAPE) choice = ' '; 
+               else if (!get_com(out_val, &choice, TRUE))break;
 
                if (use_menu && choice != ' ')
                {
-                       switch(choice)
+                       switch (choice)
                        {
                                case '0':
                                {
                                        screen_load();
-                                       return (FALSE);
-                                       break;
+                                       return FALSE;
                                }
 
                                case '8':
@@ -329,7 +328,7 @@ static int get_spell(int *sn, cptr prompt, int sval, bool learned, int use_realm
 
 
        /* Abort if needed */
-       if (!flag) return (FALSE);
+       if (!flag) return FALSE;
 
        /* Save the choice */
        (*sn) = spell;
@@ -341,7 +340,7 @@ static int get_spell(int *sn, cptr prompt, int sval, bool learned, int use_realm
 #endif /* ALLOW_REPEAT -- TNB */
 
        /* Success */
-       return (TRUE);
+       return TRUE;
 }
 
 
@@ -383,13 +382,11 @@ void do_cmd_browse(void)
        int             item, sval, use_realm = 0, j, line;
        int             spell = -1;
        int             num = 0;
-       int             increment = 0;
 
        byte            spells[64];
        char            temp[62*4];
 
        object_type     *o_ptr;
-       magic_type      *s_ptr;
 
        cptr q, s;
 
@@ -455,11 +452,6 @@ s = "
        sval = o_ptr->sval;
 
        use_realm = tval2realm(o_ptr->tval);
-       if ((p_ptr->pclass != CLASS_SORCERER) && (p_ptr->pclass != CLASS_RED_MAGE) && is_magic(use_realm))
-       {
-               if (o_ptr->tval == REALM2_BOOK) increment = 32;
-               else if (o_ptr->tval != REALM1_BOOK) increment = 64;
-       }
 
        /* Track the object kind */
        object_kind_track(o_ptr->k_idx);
@@ -516,13 +508,13 @@ s = "
                                prt("No spells to browse.", 0, 0);
 #endif
                        (void)inkey();
-                       
+
 
                        /* Restore the screen */
                        screen_load();
 
                        return;
-               }                                 
+               }
 
                /* Clear lines, position cursor  (really should use strlen here) */
                Term_erase(14, 14, 255);
@@ -530,18 +522,8 @@ s = "
                Term_erase(14, 12, 255);
                Term_erase(14, 11, 255);
 
-               /* Access the spell */
-               if (!is_magic(use_realm))
-               {
-                       s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
-               }
-               else
-               {
-                       s_ptr = &mp_ptr->info[use_realm - 1][spell];
-               }
-
-               roff_to_buf(spell_tips[technic2magic(use_realm)-1][spell] ,62, temp, sizeof(temp));
-               for(j=0, line = 11;temp[j];j+=(1+strlen(&temp[j])))
+               roff_to_buf(spell_tips[technic2magic(use_realm) - 1][spell], 62, temp, sizeof(temp));
+               for (j = 0, line = 11; temp[j]; j += 1 + strlen(&temp[j]))
                {
                        prt(&temp[j], line, 15);
                        line++;
@@ -555,24 +537,24 @@ s = "
 
 static void change_realm2(int next_realm)
 {
-       int i, j=0;
+       int i, j = 0;
        char tmp[80];
 
        for (i = 0; i < 64; i++)
        {
                p_ptr->spell_order[j] = p_ptr->spell_order[i];
-               if(p_ptr->spell_order[i] < 32) j++;
+               if (p_ptr->spell_order[i] < 32) j++;
        }
        for (; j < 64; j++)
                p_ptr->spell_order[j] = 99;
 
        for (i = 32; i < 64; i++)
        {
-               p_ptr->spell_exp[i] = 0;
+               p_ptr->spell_exp[i] = SPELL_EXP_UNSKILLED;
        }
        p_ptr->spell_learned2 = 0L;
        p_ptr->spell_worked2 = 0L;
-       p_ptr->spell_forgotten2 = 0L;   
+       p_ptr->spell_forgotten2 = 0L;
 
 #ifdef JP
        sprintf(tmp,"ËâË¡¤ÎÎΰè¤ò%s¤«¤é%s¤ËÊѹ¹¤·¤¿¡£", realm_names[p_ptr->realm2], realm_names[next_realm]);
@@ -799,9 +781,9 @@ msg_format("
 
        if (learned)
        {
-               int max_exp = (spell < 32) ? 1600 : 1400;
+               int max_exp = (spell < 32) ? SPELL_EXP_MASTER : SPELL_EXP_EXPERT;
                int old_exp = p_ptr->spell_exp[spell];
-               int new_rank = 0;
+               int new_rank = EXP_LEVEL_UNSKILLED;
                cptr name = spell_names[technic2magic(increment ? p_ptr->realm2 : p_ptr->realm1)-1][spell%32];
 
                if (old_exp >= max_exp)
@@ -821,31 +803,31 @@ msg_format("
                {
                        return;
                }
-               else if (old_exp >= 1400)
+               else if (old_exp >= SPELL_EXP_EXPERT)
                {
-                       p_ptr->spell_exp[spell] = 1600;
-                       new_rank = 4;
+                       p_ptr->spell_exp[spell] = SPELL_EXP_MASTER;
+                       new_rank = EXP_LEVEL_MASTER;
                }
-               else if (old_exp >= 1200)
+               else if (old_exp >= SPELL_EXP_SKILLED)
                {
-                       if (spell >= 32) p_ptr->spell_exp[spell] = 1400;
-                       else p_ptr->spell_exp[spell] += 200;
-                       new_rank = 3;
+                       if (spell >= 32) p_ptr->spell_exp[spell] = SPELL_EXP_EXPERT;
+                       else p_ptr->spell_exp[spell] += SPELL_EXP_EXPERT - SPELL_EXP_SKILLED;
+                       new_rank = EXP_LEVEL_EXPERT;
                }
-               else if (old_exp >= 900)
+               else if (old_exp >= SPELL_EXP_BEGINNER)
                {
-                       p_ptr->spell_exp[spell] = 1200+(old_exp-900)*2/3;
-                       new_rank = 2;
+                       p_ptr->spell_exp[spell] = SPELL_EXP_SKILLED + (old_exp - SPELL_EXP_BEGINNER) * 2 / 3;
+                       new_rank = EXP_LEVEL_SKILLED;
                }
                else
                {
-                       p_ptr->spell_exp[spell] = 900+(old_exp)/3;
-                       new_rank = 1;
+                       p_ptr->spell_exp[spell] = SPELL_EXP_BEGINNER + old_exp / 3;
+                       new_rank = EXP_LEVEL_BEGINNER;
                }
 #ifdef JP
-               msg_format("%s¤Î½ÏÎýÅÙ¤¬%s¤Ë¾å¤¬¤Ã¤¿¡£", name, shougou_moji[new_rank]);
+               msg_format("%s¤Î½ÏÎýÅÙ¤¬%s¤Ë¾å¤¬¤Ã¤¿¡£", name, exp_level_str[new_rank]);
 #else
-               msg_format("Your proficiency of %s is now %s rank.", name, shougou_moji[new_rank]);
+               msg_format("Your proficiency of %s is now %s rank.", name, exp_level_str[new_rank]);
 #endif
        }
        else
@@ -882,14 +864,21 @@ msg_format("
        /* Take a turn */
        energy_use = 100;
 
-       if (mp_ptr->spell_book == TV_LIFE_BOOK)
+       switch (mp_ptr->spell_book)
+       {
+       case TV_LIFE_BOOK:
                chg_virtue(V_FAITH, 1);
-       else if (mp_ptr->spell_book == TV_DEATH_BOOK)
+               break;
+       case TV_DEATH_BOOK:
                chg_virtue(V_UNLIFE, 1);
-       else if (mp_ptr->spell_book == TV_NATURE_BOOK)
+               break;
+       case TV_NATURE_BOOK:
                chg_virtue(V_NATURE, 1);
-       else
+               break;
+       default:
                chg_virtue(V_KNOWLEDGE, 1);
+               break;
+       }
 
        /* Sound */
        sound(SOUND_STUDY);
@@ -902,17 +891,12 @@ msg_format("
        {
                /* Message */
 #ifdef JP
-                       if( p_ptr->new_spells < 10 ){
-                               msg_format("¤¢¤È %d ¤Ä¤Î%s¤ò³Ø¤Ù¤ë¡£", p_ptr->new_spells, p);
-                       }else{
-                               msg_format("¤¢¤È %d ¸Ä¤Î%s¤ò³Ø¤Ù¤ë¡£", p_ptr->new_spells, p);
-                       }
+               if (p_ptr->new_spells < 10) msg_format("¤¢¤È %d ¤Ä¤Î%s¤ò³Ø¤Ù¤ë¡£", p_ptr->new_spells, p);
+               else msg_format("¤¢¤È %d ¸Ä¤Î%s¤ò³Ø¤Ù¤ë¡£", p_ptr->new_spells, p);
 #else
-               msg_format("You can learn %d more %s%s.",
-                       p_ptr->new_spells, p,
-                       (p_ptr->new_spells != 1) ? "s" : "");
+               msg_format("You can learn %d more %s%s.", p_ptr->new_spells, p,
+                          (p_ptr->new_spells != 1) ? "s" : "");
 #endif
-
        }
 #endif
 
@@ -1122,8 +1106,7 @@ static bool cast_life_spell(int spell)
                fire_ball_hide(GF_WOUNDS, dir, damroll(5+((plev - 5) / 3), 15), 0);
                break;
        case 21: /* Word of Recall */
-               if (!word_of_recall()) return FALSE;
-               break;
+               return word_of_recall();
        case 22: /* Alter Reality */
                alter_reality();
                break;
@@ -1263,7 +1246,6 @@ static bool cast_sorcery_spell(int spell)
                break;
        case 19: /* Teleport to town */
                return tele_town();
-               break;
        case 20: /* Self knowledge */
                (void)self_knowledge();
                break;
@@ -1276,8 +1258,7 @@ static bool cast_sorcery_spell(int spell)
                (void)teleport_player_level();
                break;
        case 22: /* Word of Recall */
-               if (!word_of_recall()) return FALSE;
-               break;
+               return word_of_recall();
        case 23: /* Dimension Door */
 #ifdef JP
 msg_print("¼¡¸µ¤ÎÈ⤬³«¤¤¤¿¡£ÌÜŪÃϤòÁª¤ó¤Ç²¼¤µ¤¤¡£");
@@ -1337,7 +1318,6 @@ static bool cast_nature_spell(int spell)
        int         dir;
        int         beam;
        int         plev = p_ptr->lev;
-       bool    no_trump = FALSE;
 
        if (p_ptr->pclass == CLASS_MAGE) beam = plev;
        else if (p_ptr->pclass == CLASS_HIGH_MAGE || p_ptr->pclass == CLASS_SORCERER) beam = plev + 10;
@@ -1448,7 +1428,13 @@ msg_print("
                break;
        case 14: /* Summon Animals */
                if (!(summon_specific(-1, py, px, plev, SUMMON_ANIMAL_RANGER, (PM_ALLOW_GROUP | PM_FORCE_PET))))
-                       no_trump = TRUE;
+               {
+#ifdef JP
+                       msg_print("ưʪ¤Ï¸½¤ì¤Ê¤«¤Ã¤¿¡£");
+#else
+                       msg_print("No animals arrive.");
+#endif
+               }
                break;
        case 15: /* Herbal Healing */
                (void)hp_player(500);
@@ -1559,14 +1545,6 @@ msg_format("
                msg_print(NULL);
        }
 
-       if (no_trump)
-#ifdef JP
-msg_print("ưʪ¤Ï¸½¤ì¤Ê¤«¤Ã¤¿¡£");
-#else
-               msg_print("No animals arrive.");
-#endif
-
-
        return TRUE;
 }
 
@@ -1716,7 +1694,6 @@ msg_print("
                                sleep_monsters();
                                hp_player(300);
                        }
-                       break;
                }
                break;
        case 9: /* Chaos Bolt */
@@ -2277,7 +2254,6 @@ msg_print("
                        return ident_spell(FALSE);
                else
                        return identify_fully(FALSE);
-               break;
        case 27: /* Mimic vampire */
                (void)set_mimic(10+plev/2 + randint1(10+plev/2), MIMIC_VAMPIRE, FALSE);
                break;
@@ -2313,18 +2289,12 @@ take_hit(DAMAGE_USELIFE, 20 + randint1(30), "
 static bool cast_trump_spell(int spell, bool success)
 {
        int     dir;
-       int     beam;
        int     plev = p_ptr->lev;
        int     summon_lev = plev * 2 / 3 + randint1(plev/2);
        int     dummy = 0;
        bool    no_trump = FALSE;
        bool    unique_okay = FALSE;
 
-
-       if (p_ptr->pclass == CLASS_MAGE) beam = plev;
-       else if (p_ptr->pclass == CLASS_HIGH_MAGE || p_ptr->pclass == CLASS_SORCERER) beam = plev + 10;
-       else beam = plev / 2;
-
        if (summon_lev < 1) summon_lev = 1;
        if (!success || (randint1(50+plev) < plev/10)) unique_okay = TRUE;
        switch (spell)
@@ -2848,7 +2818,7 @@ msg_print("
                case 14: /* Word of Recall */
                        if (success)
                        {
-                               if (!word_of_recall()) return FALSE;
+                               return word_of_recall();
                        }
                        break;
                case 15: /* Banish */
@@ -3302,7 +3272,6 @@ static bool cast_arcane_spell(int spell)
        int     beam;
        int     plev = p_ptr->lev;
        int     dummy = 0;
-       bool    no_trump = FALSE;
 
        if (p_ptr->pclass == CLASS_MAGE) beam = plev;
        else if (p_ptr->pclass == CLASS_HIGH_MAGE || p_ptr->pclass == CLASS_SORCERER) beam = plev + 10;
@@ -3408,7 +3377,13 @@ msg_print("
                break;
        case 25: /* Conjure Elemental */
                if (!summon_specific(-1, py, px, plev, SUMMON_ELEMENTAL, (PM_ALLOW_GROUP | PM_FORCE_PET)))
-                       no_trump = TRUE;
+               {
+#ifdef JP
+                       msg_print("¥¨¥ì¥á¥ó¥¿¥ë¤Ï¸½¤ì¤Ê¤«¤Ã¤¿¡£");
+#else
+                       msg_print("No Elementals arrive.");
+#endif
+               }
                break;
        case 26: /* Teleport Level */
 #ifdef JP
@@ -3439,8 +3414,7 @@ msg_print("
                (void)detect_all(DETECT_RAD_DEFAULT);
                break;
        case 30: /* Word of Recall */
-               if (!word_of_recall()) return FALSE;
-               break;
+               return word_of_recall();
        case 31: /* Clairvoyance */
                chg_virtue(V_KNOWLEDGE, 1);
                chg_virtue(V_ENLIGHTEN, 1);
@@ -3455,13 +3429,6 @@ msg_print("
                msg_print(NULL);
        }
 
-       if (no_trump)
-#ifdef JP
-msg_print("¥¨¥ì¥á¥ó¥¿¥ë¤Ï¸½¤ì¤Ê¤«¤Ã¤¿¡£");
-#else
-               msg_print("No Elementals arrive.");
-#endif
-
        return TRUE;
 }
 
@@ -3470,7 +3437,6 @@ static bool cast_enchant_spell(int spell)
 {
        int     plev = p_ptr->lev;
        int     dummy = 0;
-       bool    no_trump = FALSE;
 
        switch (spell)
        {
@@ -3535,7 +3501,6 @@ static bool cast_enchant_spell(int spell)
                break;
        case 15: /* Mana Branding */
                return choose_ele_attack();
-               break;
        case 16: /* Telepathy */
                (void)set_tim_esp(randint1(30) + 25, FALSE);
                break;
@@ -3562,14 +3527,18 @@ static bool cast_enchant_spell(int spell)
                if (summon_specific(-1, py, px, plev, SUMMON_GOLEM, PM_FORCE_PET))
                {
 #ifdef JP
-msg_print("¥´¡¼¥ì¥à¤òºî¤Ã¤¿¡£");
+                       msg_print("¥´¡¼¥ì¥à¤òºî¤Ã¤¿¡£");
 #else
-               msg_print("You make a golem.");
+                       msg_print("You make a golem.");
 #endif
                }
                else
                {
-                       no_trump = TRUE;
+#ifdef JP
+                       msg_print("¤¦¤Þ¤¯¥´¡¼¥ì¥à¤òºî¤ì¤Ê¤«¤Ã¤¿¡£");
+#else
+                       msg_print("No Golems arrive.");
+#endif
                }
                break;
        case 23: /* Magic armor */
@@ -3590,13 +3559,10 @@ msg_print("
                break;
        case 26: /* Total Knowledge */
                return identify_fully(FALSE);
-               break;
        case 27: /* Enchant Weapon */
                return enchant_spell(randint0(4) + 1, randint0(4) + 1, 0);
-               break;
        case 28: /* Enchant Armor */
                return enchant_spell(0, 0, randint0(3) + 2);
-               break;
        case 29: /* Brand Weapon */
                brand_weapon(randint0(18));
                break;
@@ -3616,20 +3582,12 @@ msg_print("
 #endif
                break;
        case 31: /* Immune */
-               return (choose_ele_immune(13 + randint1(13)));
-               break;
+               return choose_ele_immune(13 + randint1(13));
        default:
                msg_format("You cast an unknown Craft spell: %d.", spell);
                msg_print(NULL);
        }
 
-       if (no_trump)
-#ifdef JP
-msg_print("¤¦¤Þ¤¯¥´¡¼¥ì¥à¤òºî¤ì¤Ê¤«¤Ã¤¿¡£");
-#else
-               msg_print("No Golems arrive.");
-#endif
-
        return TRUE;
 }
 
@@ -4262,7 +4220,8 @@ void stop_singing(void)
        }
        if (!p_ptr->magic_num1[0]) return;
 
-       set_action(ACTION_NONE);
+       /* Hack -- if called from set_action(), avoid recursive loop */
+       if (p_ptr->action == ACTION_SING) set_action(ACTION_NONE);
 
        switch(p_ptr->magic_num1[0])
        {
@@ -5112,24 +5071,24 @@ msg_print("An infernal sound echoed.");
                        s16b cur_exp = p_ptr->spell_exp[(increment ? 32 : 0)+spell];
                        s16b exp_gain = 0;
 
-                       if (cur_exp < 900)
-                               exp_gain+=60;
-                       else if(cur_exp < 1200)
+                       if (cur_exp < SPELL_EXP_BEGINNER)
+                               exp_gain += 60;
+                       else if (cur_exp < SPELL_EXP_SKILLED)
                        {
                                if ((dun_level > 4) && ((dun_level + 10) > p_ptr->lev))
                                        exp_gain = 8;
                        }
-                       else if(cur_exp < 1400)
+                       else if (cur_exp < SPELL_EXP_EXPERT)
                        {
                                if (((dun_level + 5) > p_ptr->lev) && ((dun_level + 5) > s_ptr->slevel))
                                        exp_gain = 2;
                        }
-                       else if((cur_exp < 1600) && !increment)
+                       else if ((cur_exp < SPELL_EXP_MASTER) && !increment)
                        {
                                if (((dun_level + 5) > p_ptr->lev) && (dun_level > s_ptr->slevel))
                                        exp_gain = 1;
                        }
-                       p_ptr->spell_exp[(increment ? 32 : 0)+spell] += exp_gain;
+                       p_ptr->spell_exp[(increment ? 32 : 0) + spell] += exp_gain;
                }
        }
 
@@ -5495,25 +5454,37 @@ bool rakuba(int dam, bool force)
        {
                if (!force)
                {
-                       int level = r_ptr->level;
-                       if (p_ptr->riding_ryoute) level += 20;
-                       if ((dam/2 + r_ptr->level) > (p_ptr->skill_exp[GINOU_RIDING]/30+10))
+                       int cur = p_ptr->skill_exp[GINOU_RIDING];
+                       int max = s_info[p_ptr->pclass].s_max[GINOU_RIDING];
+                       int ridinglevel = r_ptr->level;
+
+                       /* ÍîÇϤΤ·¤ä¤¹¤µ */
+                       int rakubalevel = r_ptr->level;
+                       if (p_ptr->riding_ryoute) rakubalevel += 20;
+
+                       if ((cur < max) && (max > 1000) &&
+                           (dam / 2 + ridinglevel) > (cur / 30 + 10))
                        {
-                               if((p_ptr->skill_exp[GINOU_RIDING] < s_info[p_ptr->pclass].s_max[GINOU_RIDING]) && s_info[p_ptr->pclass].s_max[GINOU_RIDING] > 1000)
-                               {
-                                       if (r_ptr->level*100 > (p_ptr->skill_exp[GINOU_RIDING] + 1500))
-                                               p_ptr->skill_exp[GINOU_RIDING] += (1+(r_ptr->level - p_ptr->skill_exp[GINOU_RIDING]/100 - 15));
-                                       else p_ptr->skill_exp[GINOU_RIDING]++;
-                               }
+                               int inc = 0;
+
+                               if (ridinglevel > (cur / 100 + 15))
+                                       inc += 1 + (ridinglevel - cur / 100 - 15);
+                               else
+                                       inc += 1;
+
+                               p_ptr->skill_exp[GINOU_RIDING] = MIN(max, cur + inc);
                        }
-                       if (randint0(dam/2 + level*2) < (p_ptr->skill_exp[GINOU_RIDING]/30+10))
+
+                       /* ¥ì¥Ù¥ë¤ÎÄ㤤¾èÇϤ«¤é¤ÏÍîÇϤ·¤Ë¤¯¤¤ */
+                       if (randint0(dam / 2 + rakubalevel * 2) < cur / 30 + 10)
                        {
-                               if ((((p_ptr->pclass == CLASS_BEASTMASTER) || (p_ptr->pclass == CLASS_CAVALRY)) && !p_ptr->riding_ryoute) || !one_in_(p_ptr->lev*(p_ptr->riding_ryoute ? 2 : 3)+30))
+                               if ((((p_ptr->pclass == CLASS_BEASTMASTER) || (p_ptr->pclass == CLASS_CAVALRY)) && !p_ptr->riding_ryoute) || !one_in_(p_ptr->lev*(p_ptr->riding_ryoute ? 2 : 3) + 30))
                                {
                                        return FALSE;
                                }
                        }
                }
+
                /* Check around the player */
                for (i = 0; i < 8; i++)
                {
@@ -5711,7 +5682,7 @@ msg_print("
 
                        return FALSE;
                }
-               if (r_info[m_ptr->r_idx].level > randint1((p_ptr->skill_exp[GINOU_RIDING]/50 + p_ptr->lev/2 +20)))
+               if (r_info[m_ptr->r_idx].level > randint1((p_ptr->skill_exp[GINOU_RIDING] / 50 + p_ptr->lev / 2 + 20)))
                {
 #ifdef JP
 msg_print("¤¦¤Þ¤¯¾è¤ì¤Ê¤«¤Ã¤¿¡£");