OSDN Git Service

通常のセーブ/ロード時以外でc_ptr->mimicに0以外の値を代入する際に, 最
[hengband/hengband.git] / src / object2.c
index b22233c..5bec9e4 100644 (file)
@@ -865,16 +865,25 @@ static s32b object_value_base(object_type *o_ptr)
 
 
 /* Return the value of the flags the object has... */
-s32b flag_cost(object_type * o_ptr, int plusses)
+s32b flag_cost(object_type *o_ptr, int plusses)
 {
        s32b total = 0;
        u32b flgs[TR_FLAG_SIZE];
        s32b tmp_cost;
        int count;
        int i;
+       object_kind *k_ptr = &k_info[o_ptr->k_idx];
 
        object_flags(o_ptr, flgs);
 
+       /*
+        * Exclude fixed flags of the base item.
+        * pval bonuses of base item will be treated later.
+        */
+       for (i = 0; i < TR_FLAG_SIZE; i++)
+               flgs[i] &= ~(k_ptr->flags[i]);
+
+       /* Exclude fixed flags of the fixed artifact. */
        if (o_ptr->name1)
        {
                artifact_type *a_ptr = &a_info[o_ptr->name1];
@@ -882,30 +891,20 @@ s32b flag_cost(object_type * o_ptr, int plusses)
                for (i = 0; i < TR_FLAG_SIZE; i++)
                        flgs[i] &= ~(a_ptr->flags[i]);
        }
-       else
-       {
-               if ((o_ptr->tval == TV_RING) || (o_ptr->tval == TV_AMULET))
-               {
-                       object_kind *k_ptr = &k_info[o_ptr->k_idx];
 
-                       for (i = 0; i < TR_FLAG_SIZE; i++)
-                               flgs[i] &= ~(k_ptr->flags[i]);
-               }
-
-               if (o_ptr->name2)
-               {
-                       ego_item_type *e_ptr = &e_info[o_ptr->name2];
-
-                       for (i = 0; i < TR_FLAG_SIZE; i++)
-                               flgs[i] &= ~(e_ptr->flags[i]);
+       /* Exclude fixed flags of the ego-item. */
+       else if (o_ptr->name2)
+       {
+               ego_item_type *e_ptr = &e_info[o_ptr->name2];
 
-               }
-               else if (o_ptr->art_name)
-               {
-                       total = 5000;
-               }
+               for (i = 0; i < TR_FLAG_SIZE; i++)
+                       flgs[i] &= ~(e_ptr->flags[i]);
        }
 
+
+       /*
+        * Calucurate values of remaining flags
+        */
        if (have_flag(flgs, TR_STR)) total += (1500 * plusses);
        if (have_flag(flgs, TR_INT)) total += (1500 * plusses);
        if (have_flag(flgs, TR_WIS)) total += (1500 * plusses);
@@ -921,7 +920,6 @@ s32b flag_cost(object_type * o_ptr, int plusses)
                total += (10000 + (2500 * plusses));
        if ((have_flag(flgs, TR_BLOWS)) && (plusses > 0))
                total += (10000 + (2500 * plusses));
-       if (have_flag(flgs, TR_DEC_MANA)) total += 10000;
 
        tmp_cost = 0;
        count = 0;
@@ -1020,6 +1018,7 @@ s32b flag_cost(object_type * o_ptr, int plusses)
        if (have_flag(flgs, TR_SLOW_DIGEST)) total += 750;
        if (have_flag(flgs, TR_REGEN)) total += 2500;
        if (have_flag(flgs, TR_WARNING)) total += 2000;
+       if (have_flag(flgs, TR_DEC_MANA)) total += 10000;
        if (have_flag(flgs, TR_XTRA_MIGHT)) total += 2250;
        if (have_flag(flgs, TR_XTRA_SHOTS)) total += 10000;
        if (have_flag(flgs, TR_IGNORE_ACID)) total += 100;
@@ -1176,6 +1175,8 @@ s32b object_value_real(object_type *o_ptr)
                /* Hack -- Use the artifact cost instead */
                value = a_ptr->cost;
                value += flag_cost(o_ptr, o_ptr->pval);
+
+               /* Don't add pval bonuses etc. */
                return (value);
        }
 
@@ -1203,62 +1204,59 @@ s32b object_value_real(object_type *o_ptr)
                if (flag) value += flag_cost(o_ptr, o_ptr->pval);
        }
 
-
-       /* Analyze pval bonus */
+       /* Analyze pval bonus for normal object */
        switch (o_ptr->tval)
        {
-               case TV_SHOT:
-               case TV_ARROW:
-               case TV_BOLT:
-               case TV_BOW:
-               case TV_DIGGING:
-               case TV_HAFTED:
-               case TV_POLEARM:
-               case TV_SWORD:
-               case TV_BOOTS:
-               case TV_GLOVES:
-               case TV_HELM:
-               case TV_CROWN:
-               case TV_SHIELD:
-               case TV_CLOAK:
-               case TV_SOFT_ARMOR:
-               case TV_HARD_ARMOR:
-               case TV_DRAG_ARMOR:
-               case TV_LITE:
-               case TV_AMULET:
-               case TV_RING:
-               {
-                       /* Hack -- Negative "pval" is always bad */
-                       if (o_ptr->pval < 0) return (0L);
-
-                       /* No pval */
-                       if (!o_ptr->pval) break;
+       case TV_SHOT:
+       case TV_ARROW:
+       case TV_BOLT:
+       case TV_BOW:
+       case TV_DIGGING:
+       case TV_HAFTED:
+       case TV_POLEARM:
+       case TV_SWORD:
+       case TV_BOOTS:
+       case TV_GLOVES:
+       case TV_HELM:
+       case TV_CROWN:
+       case TV_SHIELD:
+       case TV_CLOAK:
+       case TV_SOFT_ARMOR:
+       case TV_HARD_ARMOR:
+       case TV_DRAG_ARMOR:
+       case TV_LITE:
+       case TV_AMULET:
+       case TV_RING:
+               /* No pval */
+               if (!o_ptr->pval) break;
+
+               /* Hack -- Negative "pval" is always bad */
+               if (o_ptr->pval < 0) return (0L);
+
+               /* Give credit for stat bonuses */
+               if (have_flag(flgs, TR_STR)) value += (o_ptr->pval * 200L);
+               if (have_flag(flgs, TR_INT)) value += (o_ptr->pval * 200L);
+               if (have_flag(flgs, TR_WIS)) value += (o_ptr->pval * 200L);
+               if (have_flag(flgs, TR_DEX)) value += (o_ptr->pval * 200L);
+               if (have_flag(flgs, TR_CON)) value += (o_ptr->pval * 200L);
+               if (have_flag(flgs, TR_CHR)) value += (o_ptr->pval * 200L);
+
+               /* Give credit for stealth and searching */
+               if (have_flag(flgs, TR_MAGIC_MASTERY)) value += (o_ptr->pval * 100);
+               if (have_flag(flgs, TR_STEALTH)) value += (o_ptr->pval * 100L);
+               if (have_flag(flgs, TR_SEARCH)) value += (o_ptr->pval * 100L);
+
+               /* Give credit for infra-vision and tunneling */
+               if (have_flag(flgs, TR_INFRA)) value += (o_ptr->pval * 50L);
+               if (have_flag(flgs, TR_TUNNEL)) value += (o_ptr->pval * 50L);
+
+               /* Give credit for extra attacks */
+               if (have_flag(flgs, TR_BLOWS)) value += (o_ptr->pval * 5000L);
+
+               /* Give credit for speed bonus */
+               if (have_flag(flgs, TR_SPEED)) value += (o_ptr->pval * 10000L);
 
-                       /* Give credit for stat bonuses */
-                       if (have_flag(flgs, TR_STR)) value += (o_ptr->pval * 200L);
-                       if (have_flag(flgs, TR_INT)) value += (o_ptr->pval * 200L);
-                       if (have_flag(flgs, TR_WIS)) value += (o_ptr->pval * 200L);
-                       if (have_flag(flgs, TR_DEX)) value += (o_ptr->pval * 200L);
-                       if (have_flag(flgs, TR_CON)) value += (o_ptr->pval * 200L);
-                       if (have_flag(flgs, TR_CHR)) value += (o_ptr->pval * 200L);
-
-                       /* Give credit for stealth and searching */
-                       if (have_flag(flgs, TR_MAGIC_MASTERY)) value += (o_ptr->pval * 100L);
-                       if (have_flag(flgs, TR_STEALTH)) value += (o_ptr->pval * 100L);
-                       if (have_flag(flgs, TR_SEARCH)) value += (o_ptr->pval * 100L);
-
-                       /* Give credit for infra-vision and tunneling */
-                       if (have_flag(flgs, TR_INFRA)) value += (o_ptr->pval * 50L);
-                       if (have_flag(flgs, TR_TUNNEL)) value += (o_ptr->pval * 50L);
-
-                       /* Give credit for extra attacks */
-                       if (have_flag(flgs, TR_BLOWS)) value += (o_ptr->pval * 5000L);
-
-                       /* Give credit for speed bonus */
-                       if (have_flag(flgs, TR_SPEED)) value += (o_ptr->pval * 10000L);
-
-                       break;
-               }
+               break;
        }
 
 
@@ -1388,6 +1386,9 @@ s32b object_value_real(object_type *o_ptr)
                }
        }
 
+       /* Worthless object */
+       if (value < 0) return 0L;
+
        /* Return the value */
        return (value);
 }
@@ -3829,7 +3830,7 @@ static bool item_monster_okay(int r_idx)
        /* No uniques */
        if (r_ptr->flags1 & RF1_UNIQUE) return (FALSE);
        if (r_ptr->flags7 & RF7_KAGE) return (FALSE);
-       if (r_ptr->flags3 & RF3_RES_ALL) return (FALSE);
+       if (r_ptr->flagsr & RFR_RES_ALL) return (FALSE);
        if (r_ptr->flags7 & RF7_UNIQUE_7) return (FALSE);
        if (r_ptr->flags1 & RF1_FORCE_DEPTH) return (FALSE);
        if (r_ptr->flags7 & RF7_UNIQUE2) return (FALSE);
@@ -5213,7 +5214,7 @@ s16b drop_near(object_type *j_ptr, int chance, int y, int x)
 
        /* Mega-Hack -- no message if "dropped" by player */
        /* Message when an object falls under the player */
-       if (chance && (by == py) && (bx == px))
+       if (chance && player_bold(by, bx))
        {
 #ifdef JP
                msg_print("²¿¤«¤¬Â­²¼¤Ëž¤¬¤Ã¤Æ¤­¤¿¡£");
@@ -5362,7 +5363,7 @@ void place_trap(int y, int x)
        if (!cave_naked_bold(y, x)) return;
 
        /* Place an invisible trap */
-       c_ptr->mimic = c_ptr->feat;
+       c_ptr->mimic = f_info[c_ptr->feat].mimic;
        c_ptr->feat = choose_random_trap();
 }
 
@@ -6389,48 +6390,72 @@ static void spell_damcalc(monster_type *m_ptr, int typ, int dam, int limit, int
        switch (typ)
        {
        case GF_ELEC:
-               if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
-               if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
-               if (prace_is_(RACE_ANDROID)) dam += dam / 3;
-               if (p_ptr->resist_elec) dam = (dam + 2) / 3;
-               if (IS_OPPOSE_ELEC())
-                       dam = (dam + 2) / 3;
-               if (p_ptr->immune_elec) dam = 0;
+               if (p_ptr->immune_elec)
+               {
+                       dam = 0;
+                       ignore_wraith_form = TRUE;
+               }
+               else
+               {
+                       if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
+                       if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
+                       if (prace_is_(RACE_ANDROID)) dam += dam / 3;
+                       if (p_ptr->resist_elec) dam = (dam + 2) / 3;
+                       if (IS_OPPOSE_ELEC())
+                               dam = (dam + 2) / 3;
+               }
                break;
 
        case GF_POIS:
                if (p_ptr->resist_pois) dam = (dam + 2) / 3;
-               if (IS_OPPOSE_POIS())
-                       dam = (dam + 2) / 3;
+               if (IS_OPPOSE_POIS()) dam = (dam + 2) / 3;
                break;
 
        case GF_ACID:
-               if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
-               if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
-               if (p_ptr->resist_acid) dam = (dam + 2) / 3;
-               if (IS_OPPOSE_ACID())
-                       dam = (dam + 2) / 3;
-               if (p_ptr->immune_acid) dam = 0;
+               if (p_ptr->immune_acid)
+               {
+                       dam = 0;
+                       ignore_wraith_form = TRUE;
+               }
+               else
+               {
+                       if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
+                       if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
+                       if (p_ptr->resist_acid) dam = (dam + 2) / 3;
+                       if (IS_OPPOSE_ACID()) dam = (dam + 2) / 3;
+               }
                break;
 
        case GF_COLD:
        case GF_ICE:
-               if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
-               if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
-               if (p_ptr->resist_cold) dam = (dam + 2) / 3;
-               if (IS_OPPOSE_COLD())
-                       dam = (dam + 2) / 3;
-               if (p_ptr->immune_cold) dam = 0;
+               if (p_ptr->immune_cold)
+               {
+                       dam = 0;
+                       ignore_wraith_form = TRUE;
+               }
+               else
+               {
+                       if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
+                       if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
+                       if (p_ptr->resist_cold) dam = (dam + 2) / 3;
+                       if (IS_OPPOSE_COLD()) dam = (dam + 2) / 3;
+               }
                break;
 
        case GF_FIRE:
-               if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
-               if (prace_is_(RACE_ENT)) dam += dam / 3;
-               if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
-               if (p_ptr->resist_fire) dam = (dam + 2) / 3;
-               if (IS_OPPOSE_FIRE())
-                       dam = (dam + 2) / 3;
-               if (p_ptr->immune_fire) dam = 0;
+               if (p_ptr->immune_fire)
+               {
+                       dam = 0;
+                       ignore_wraith_form = TRUE;
+               }
+               else
+               {
+                       if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
+                       if (prace_is_(RACE_ENT)) dam += dam / 3;
+                       if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
+                       if (p_ptr->resist_fire) dam = (dam + 2) / 3;
+                       if (IS_OPPOSE_FIRE()) dam = (dam + 2) / 3;
+               }
                break;
 
        case GF_PSY_SPEAR:
@@ -6441,19 +6466,31 @@ static void spell_damcalc(monster_type *m_ptr, int typ, int dam, int limit, int
                if (!p_ptr->blind &&
                    ((inventory[INVEN_RARM].k_idx && (inventory[INVEN_RARM].name1 == ART_ZANTETSU)) ||
                     (inventory[INVEN_LARM].k_idx && (inventory[INVEN_LARM].name1 == ART_ZANTETSU))))
+               {
                        dam = 0;
+                       ignore_wraith_form = TRUE;
+               }
                break;
 
        case GF_LITE:
                if (p_ptr->resist_lite) dam /= 2; /* Worst case of 4 / (d4 + 7) */
                if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE)) dam *= 2;
                else if (prace_is_(RACE_S_FAIRY)) dam = dam * 4 / 3;
-               ignore_wraith_form = TRUE;
+
+               /*
+                * Cannot use "ignore_wraith_form" strictly (for "random one damage")
+                * "dam *= 2;" for later "dam /= 2"
+                */
+               if (p_ptr->wraith_form) dam *= 2;
                break;
 
        case GF_DARK:
-               if (p_ptr->resist_dark) dam /= 2; /* Worst case of 4 / (d4 + 7) */
-               if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE) || p_ptr->wraith_form) dam = 0;
+               if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE) || p_ptr->wraith_form)
+               {
+                       dam = 0;
+                       ignore_wraith_form = TRUE;
+               }
+               else if (p_ptr->resist_dark) dam /= 2; /* Worst case of 4 / (d4 + 7) */
                break;
 
        case GF_SHARDS:
@@ -6473,8 +6510,12 @@ static void spell_damcalc(monster_type *m_ptr, int typ, int dam, int limit, int
                break;
 
        case GF_NETHER:
-               if (p_ptr->resist_neth) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
-               if (prace_is_(RACE_SPECTRE)) dam = 0;
+               if (prace_is_(RACE_SPECTRE))
+               {
+                       dam = 0;
+                       ignore_wraith_form = TRUE;
+               }
+               else if (p_ptr->resist_neth) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
                break;
 
        case GF_DISENCHANT:
@@ -6499,14 +6540,17 @@ static void spell_damcalc(monster_type *m_ptr, int typ, int dam, int limit, int
 
        case GF_NUKE:
                if (p_ptr->resist_pois) dam = (2 * dam + 2) / 5;
-               if (IS_OPPOSE_POIS())
-                       dam = (2 * dam + 2) / 5;
+               if (IS_OPPOSE_POIS()) dam = (2 * dam + 2) / 5;
                break;
 
        case GF_DEATH_RAY:
                if (p_ptr->mimic_form)
                {
-                       if (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_NONLIVING) dam = 0;
+                       if (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_NONLIVING)
+                       {
+                               dam = 0;
+                               ignore_wraith_form = TRUE;
+                       }
                }
                else
                {
@@ -6519,6 +6563,7 @@ static void spell_damcalc(monster_type *m_ptr, int typ, int dam, int limit, int
                        case RACE_DEMON:
                        case RACE_SPECTRE:
                                dam = 0;
+                               ignore_wraith_form = TRUE;
                                break;
                        }
                }
@@ -6535,18 +6580,30 @@ static void spell_damcalc(monster_type *m_ptr, int typ, int dam, int limit, int
 
        case GF_MIND_BLAST:
        case GF_BRAIN_SMASH:
-               if (100 + rlev / 2 <= MAX(5, p_ptr->skill_sav)) dam = 0;
+               if (100 + rlev / 2 <= MAX(5, p_ptr->skill_sav))
+               {
+                       dam = 0;
+                       ignore_wraith_form = TRUE;
+               }
                break;
 
        case GF_CAUSE_1:
        case GF_CAUSE_2:
        case GF_CAUSE_3:
        case GF_HAND_DOOM:
-               if (100 + rlev / 2 <= p_ptr->skill_sav) dam = 0;
+               if (100 + rlev / 2 <= p_ptr->skill_sav)
+               {
+                       dam = 0;
+                       ignore_wraith_form = TRUE;
+               }
                break;
 
        case GF_CAUSE_4:
-               if ((100 + rlev / 2 <= p_ptr->skill_sav) && (m_ptr->r_idx != MON_KENSHIROU)) dam = 0;
+               if ((100 + rlev / 2 <= p_ptr->skill_sav) && (m_ptr->r_idx != MON_KENSHIROU))
+               {
+                       dam = 0;
+                       ignore_wraith_form = TRUE;
+               }
                break;
        }
 
@@ -6564,6 +6621,7 @@ static int blow_damcalc(monster_type *m_ptr, monster_blow *blow_ptr)
 {
        int  dam = blow_ptr->d_dice * blow_ptr->d_side;
        int  dummy_max = 0;
+       bool check_wraith_form = TRUE;
 
        if (blow_ptr->method != RBM_EXPLODE)
        {
@@ -6586,27 +6644,38 @@ static int blow_damcalc(monster_type *m_ptr, monster_blow *blow_ptr)
                case RBE_ACID:
                        spell_damcalc(m_ptr, GF_ACID, dam, 0, &dummy_max);
                        dam = dummy_max;
+                       check_wraith_form = FALSE;
                        break;
 
                case RBE_ELEC:
                        spell_damcalc(m_ptr, GF_ELEC, dam, 0, &dummy_max);
                        dam = dummy_max;
+                       check_wraith_form = FALSE;
                        break;
 
                case RBE_FIRE:
                        spell_damcalc(m_ptr, GF_FIRE, dam, 0, &dummy_max);
                        dam = dummy_max;
+                       check_wraith_form = FALSE;
                        break;
 
                case RBE_COLD:
                        spell_damcalc(m_ptr, GF_COLD, dam, 0, &dummy_max);
                        dam = dummy_max;
+                       check_wraith_form = FALSE;
                        break;
 
                case RBE_DR_MANA:
                        dam = 0;
+                       check_wraith_form = FALSE;
                        break;
                }
+
+               if (check_wraith_form && p_ptr->wraith_form)
+               {
+                       dam /= 2;
+                       if (!dam) dam = 1;
+               }
        }
        else
        {
@@ -6636,7 +6705,6 @@ bool process_warning(int xx, int yy)
                        int dam_max0 = 0;
                        monster_type *m_ptr;
                        monster_race *r_ptr;
-                       u32b f4, f5, f6;
 
                        if (!in_bounds(my, mx) || (distance(my, mx, yy, xx) > WARNING_AWARE_RANGE)) continue;
 
@@ -6651,26 +6719,27 @@ bool process_warning(int xx, int yy)
 
                        r_ptr = &r_info[m_ptr->r_idx];
 
-                       f4 = r_ptr->flags4;
-                       f5 = r_ptr->flags5;
-                       f6 = r_ptr->flags6;
-
                        /* Monster spells (only powerful ones)*/
                        if (projectable(my, mx, yy, xx))
                        {
                                int breath_dam_div3 = m_ptr->hp / 3;
                                int breath_dam_div6 = m_ptr->hp / 6;
+                               u32b f4 = r_ptr->flags4;
+                               u32b f5 = r_ptr->flags5;
+                               u32b f6 = r_ptr->flags6;
 
                                if (!(d_info[dungeon_type].flags1 & DF1_NO_MAGIC))
                                {
                                        int rlev = ((r_ptr->level >= 1) ? r_ptr->level : 1);
                                        int storm_dam = rlev * 4 + 150;
+                                       bool powerful = (bool)(r_ptr->flags2 & RF2_POWERFUL);
 
+                                       if (f4 & RF4_BA_CHAO) spell_damcalc(m_ptr, GF_CHAOS, rlev * (powerful ? 3 : 2) + 100, 0, &dam_max0);
                                        if (f5 & RF5_BA_MANA) spell_damcalc(m_ptr, GF_MANA, storm_dam, 0, &dam_max0);
                                        if (f5 & RF5_BA_DARK) spell_damcalc(m_ptr, GF_DARK, storm_dam, 0, &dam_max0);
                                        if (f5 & RF5_BA_LITE) spell_damcalc(m_ptr, GF_LITE, storm_dam, 0, &dam_max0);
                                        if (f6 & RF6_HAND_DOOM) spell_damcalc(m_ptr, GF_HAND_DOOM, p_ptr->chp * 6 / 10, 0, &dam_max0);
-                                       if (f6 & RF6_PSY_SPEAR) spell_damcalc(m_ptr, GF_PSY_SPEAR, (r_ptr->flags2 & RF2_POWERFUL) ? (rlev * 2 + 150) : (rlev * 3 / 2 + 100), 0, &dam_max0);
+                                       if (f6 & RF6_PSY_SPEAR) spell_damcalc(m_ptr, GF_PSY_SPEAR, powerful ? (rlev * 2 + 150) : (rlev * 3 / 2 + 100), 0, &dam_max0);
                                }
                                if (f4 & RF4_ROCKET) spell_damcalc(m_ptr, GF_ROCKET, m_ptr->hp / 4, 800, &dam_max0);
                                if (f4 & RF4_BR_ACID) spell_damcalc(m_ptr, GF_ACID, breath_dam_div3, 1600, &dam_max0);
@@ -6743,7 +6812,7 @@ bool process_warning(int xx, int yy)
 #ifdef JP
                        return get_check("ËÜÅö¤Ë¤³¤Î¤Þ¤Þ¿Ê¤à¤«¡©");
 #else
-                       return get_check("Realy want to go ahead? ");
+                       return get_check("Really want to go ahead? ");
 #endif
                }
        }
@@ -7957,11 +8026,11 @@ static void add_essence(int mode)
 #ifdef JP
                msg_print("¤½¤Î¥¢¥¤¥Æ¥à¤Ï¤³¤ì°Ê¾å²þÎɤǤ­¤Ê¤¤¡£");
 #else
-               msg_print("This item is no more able to be improved");
+               msg_print("This item is no more able to be improved.");
 #endif
                return;
        }
-       
+
        object_desc(o_name, o_ptr, FALSE, 0);
 
        use_essence = es_ptr->value;
@@ -7990,7 +8059,16 @@ static void add_essence(int mode)
                }
                if (is_pval_flag(es_ptr->add))
                {
-                       if (es_ptr->add == TR_BLOWS)
+                       if (o_ptr->pval < 0)
+                       {
+#ifdef JP
+                               msg_print("¤³¤Î¥¢¥¤¥Æ¥à¤ÎǽÎϽ¤Àµ¤ò¶¯²½¤¹¤ë¤³¤È¤Ï¤Ç¤­¤Ê¤¤¡£");
+#else
+                               msg_print("You cannot increase magic number of this item.");
+#endif
+                               return;
+                       }
+                       else if (es_ptr->add == TR_BLOWS)
                        {
                                if (o_ptr->pval > 1)
                                {
@@ -8000,15 +8078,21 @@ static void add_essence(int mode)
                                        if (!get_check("The magic number of this weapon will become 1. Are you sure? ")) return;
 #endif
                                }
+
                                o_ptr->pval = 1;
+#ifdef JP
+                               msg_format("¥¨¥Ã¥»¥ó¥¹¤ò%d¸Ä»ÈÍѤ·¤Þ¤¹¡£", use_essence);
+#else
+                               msg_format("It will take %d essences.", use_essence);
+#endif
                        }
-                       else if (o_ptr->pval)
+                       else if (o_ptr->pval > 0)
                        {
                                use_essence *= o_ptr->pval;
 #ifdef JP
-                               msg_format("¥¨¥Ã¥»¥ó¥¹¤ò%d¸Ä»ÈÍѤ·¤Þ¤¹¡£",use_essence);
+                               msg_format("¥¨¥Ã¥»¥ó¥¹¤ò%d¸Ä»ÈÍѤ·¤Þ¤¹¡£", use_essence);
 #else
-                               msg_format("It will take %d essences.",use_essence);
+                               msg_format("It will take %d essences.", use_essence);
 #endif
                        }
                        else
@@ -8018,7 +8102,6 @@ static void add_essence(int mode)
                                int pval;
                                int limit = MIN(5, p_ptr->magic_num1[es_ptr->essence]/es_ptr->value);
 
-
 #ifdef JP
                                sprintf(tmp, "¤¤¤¯¤ÄÉղä·¤Þ¤¹¤«¡© (1-%d): ", limit);
 #else
@@ -8030,14 +8113,15 @@ static void add_essence(int mode)
                                pval = atoi(tmp_val);
                                if (pval > limit) pval = limit;
                                else if (pval < 1) pval = 1;
-                               o_ptr->pval = pval;
+                               o_ptr->pval += pval;
                                use_essence *= pval;
 #ifdef JP
-                               msg_format("¥¨¥Ã¥»¥ó¥¹¤ò%d¸Ä»ÈÍѤ·¤Þ¤¹¡£",use_essence);
+                               msg_format("¥¨¥Ã¥»¥ó¥¹¤ò%d¸Ä»ÈÍѤ·¤Þ¤¹¡£", use_essence);
 #else
-                               msg_format("It will take %d essences.",use_essence);
+                               msg_format("It will take %d essences.", use_essence);
 #endif
                        }
+
                        if (p_ptr->magic_num1[es_ptr->essence] < use_essence)
                        {
 #ifdef JP
@@ -8065,16 +8149,16 @@ static void add_essence(int mode)
                        else if (val < 1) val = 1;
                        use_essence *= val;
 #ifdef JP
-                       msg_format("¥¨¥Ã¥»¥ó¥¹¤ò%d¸Ä»ÈÍѤ·¤Þ¤¹¡£",use_essence);
+                       msg_format("¥¨¥Ã¥»¥ó¥¹¤ò%d¸Ä»ÈÍѤ·¤Þ¤¹¡£", use_essence);
 #else
-                       msg_format("It will take %d essences.",use_essence);
+                       msg_format("It will take %d essences.", use_essence);
 #endif
                        if (p_ptr->magic_num1[es_ptr->essence] < use_essence)
                        {
 #ifdef JP
                                msg_print("¥¨¥Ã¥»¥ó¥¹¤¬Â­¤ê¤Ê¤¤¡£");
 #else
-                               msg_print("You don't have enough essences");
+                               msg_print("You don't have enough essences.");
 #endif
                                return;
                        }
@@ -8176,7 +8260,7 @@ static void add_essence(int mode)
 #ifdef JP
                        msg_print("¥¨¥Ã¥»¥ó¥¹¤¬Â­¤ê¤Ê¤¤¡£");
 #else
-                       msg_print("You don't have enough essences");
+                       msg_print("You don't have enough essences.");
 #endif
                        return;
                }
@@ -8295,7 +8379,7 @@ static void erase_essence(void)
 #ifdef JP
        msg_print("¥¨¥Ã¥»¥ó¥¹¤ò¼è¤êµî¤Ã¤¿¡£");
 #else
-       msg_print("You removed all essence you have added");
+       msg_print("You removed all essence you have added.");
 #endif
 
        /* Combine the pack */