OSDN Git Service

通常のセーブ/ロード時以外でc_ptr->mimicに0以外の値を代入する際に, 最
[hengband/hengband.git] / src / object2.c
index 4f521cd..5bec9e4 100644 (file)
@@ -872,16 +872,18 @@ s32b flag_cost(object_type *o_ptr, int plusses)
        s32b tmp_cost;
        int count;
        int i;
-       object_kind *k_ptr;
+       object_kind *k_ptr = &k_info[o_ptr->k_idx];
 
        object_flags(o_ptr, flgs);
 
-       /* Base item's value will be added later. */
-       k_ptr = &k_info[o_ptr->k_idx];
+       /*
+        * 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]);
 
-       /* Fixed artifact's value will be added later. */
+       /* Exclude fixed flags of the fixed artifact. */
        if (o_ptr->name1)
        {
                artifact_type *a_ptr = &a_info[o_ptr->name1];
@@ -890,36 +892,34 @@ s32b flag_cost(object_type *o_ptr, int plusses)
                        flgs[i] &= ~(a_ptr->flags[i]);
        }
 
-       /* Fixed ego item's value will be added later. */
+       /* Exclude fixed flags of the ego-item. */
        else 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]);
-
        }
 
 
        /*
         * Calucurate values of remaining flags
         */
-       if (have_flag(flgs, TR_STR)) total += (1700 * plusses);
-       if (have_flag(flgs, TR_INT)) total += (1700 * plusses);
-       if (have_flag(flgs, TR_WIS)) total += (1700 * plusses);
-       if (have_flag(flgs, TR_DEX)) total += (1700 * plusses);
-       if (have_flag(flgs, TR_CON)) total += (1700 * plusses);
-       if (have_flag(flgs, TR_CHR)) total += (950 * plusses);
-       if (have_flag(flgs, TR_MAGIC_MASTERY)) total += (700 * plusses);
-       if (have_flag(flgs, TR_STEALTH)) total += (350 * plusses);
-       if (have_flag(flgs, TR_SEARCH)) total += (200 * plusses);
-       if (have_flag(flgs, TR_INFRA)) total += (200 * plusses);
-       if (have_flag(flgs, TR_TUNNEL)) total += (225 * plusses);
+       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);
+       if (have_flag(flgs, TR_DEX)) total += (1500 * plusses);
+       if (have_flag(flgs, TR_CON)) total += (1500 * plusses);
+       if (have_flag(flgs, TR_CHR)) total += (750 * plusses);
+       if (have_flag(flgs, TR_MAGIC_MASTERY)) total += (600 * plusses);
+       if (have_flag(flgs, TR_STEALTH)) total += (250 * plusses);
+       if (have_flag(flgs, TR_SEARCH)) total += (100 * plusses);
+       if (have_flag(flgs, TR_INFRA)) total += (150 * plusses);
+       if (have_flag(flgs, TR_TUNNEL)) total += (175 * plusses);
        if ((have_flag(flgs, TR_SPEED)) && (plusses > 0))
-               total += (10000 + (12500 * plusses));
+               total += (10000 + (2500 * plusses));
        if ((have_flag(flgs, TR_BLOWS)) && (plusses > 0))
-               total += (10000 + (7500 * plusses));
-       if (have_flag(flgs, TR_DEC_MANA)) total += 10000;
+               total += (10000 + (2500 * plusses));
 
        tmp_cost = 0;
        count = 0;
@@ -1018,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;
@@ -1174,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);
        }
 
@@ -1201,6 +1204,61 @@ s32b object_value_real(object_type *o_ptr)
                if (flag) value += flag_cost(o_ptr, o_ptr->pval);
        }
 
+       /* 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:
+               /* 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);
+
+               break;
+       }
+
 
        /* Analyze the item */
        switch (o_ptr->tval)
@@ -5305,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();
 }
 
@@ -6325,7 +6383,6 @@ static void spell_damcalc(monster_type *m_ptr, int typ, int dam, int limit, int
        monster_race *r_ptr = &r_info[m_ptr->r_idx];
        int          rlev = r_ptr->level;
        bool         ignore_wraith_form = FALSE;
-       bool         complete_immune = FALSE;
 
        if (limit) dam = (dam > limit) ? limit : dam;
 
@@ -6336,7 +6393,7 @@ static void spell_damcalc(monster_type *m_ptr, int typ, int dam, int limit, int
                if (p_ptr->immune_elec)
                {
                        dam = 0;
-                       complete_immune = TRUE;
+                       ignore_wraith_form = TRUE;
                }
                else
                {
@@ -6358,7 +6415,7 @@ static void spell_damcalc(monster_type *m_ptr, int typ, int dam, int limit, int
                if (p_ptr->immune_acid)
                {
                        dam = 0;
-                       complete_immune = TRUE;
+                       ignore_wraith_form = TRUE;
                }
                else
                {
@@ -6374,7 +6431,7 @@ static void spell_damcalc(monster_type *m_ptr, int typ, int dam, int limit, int
                if (p_ptr->immune_cold)
                {
                        dam = 0;
-                       complete_immune = TRUE;
+                       ignore_wraith_form = TRUE;
                }
                else
                {
@@ -6389,7 +6446,7 @@ static void spell_damcalc(monster_type *m_ptr, int typ, int dam, int limit, int
                if (p_ptr->immune_fire)
                {
                        dam = 0;
-                       complete_immune = TRUE;
+                       ignore_wraith_form = TRUE;
                }
                else
                {
@@ -6411,7 +6468,7 @@ static void spell_damcalc(monster_type *m_ptr, int typ, int dam, int limit, int
                     (inventory[INVEN_LARM].k_idx && (inventory[INVEN_LARM].name1 == ART_ZANTETSU))))
                {
                        dam = 0;
-                       complete_immune = TRUE;
+                       ignore_wraith_form = TRUE;
                }
                break;
 
@@ -6419,14 +6476,19 @@ static void spell_damcalc(monster_type *m_ptr, int typ, int dam, int limit, int
                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 (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE) || p_ptr->wraith_form)
                {
                        dam = 0;
-                       complete_immune = TRUE;
+                       ignore_wraith_form = TRUE;
                }
                else if (p_ptr->resist_dark) dam /= 2; /* Worst case of 4 / (d4 + 7) */
                break;
@@ -6451,7 +6513,7 @@ static void spell_damcalc(monster_type *m_ptr, int typ, int dam, int limit, int
                if (prace_is_(RACE_SPECTRE))
                {
                        dam = 0;
-                       complete_immune = TRUE;
+                       ignore_wraith_form = TRUE;
                }
                else if (p_ptr->resist_neth) dam = dam * 3 / 4; /* Worst case of 6 / (d4 + 7) */
                break;
@@ -6487,7 +6549,7 @@ static void spell_damcalc(monster_type *m_ptr, int typ, int dam, int limit, int
                        if (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_NONLIVING)
                        {
                                dam = 0;
-                               complete_immune = TRUE;
+                               ignore_wraith_form = TRUE;
                        }
                }
                else
@@ -6501,7 +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;
-                               complete_immune = TRUE;
+                               ignore_wraith_form = TRUE;
                                break;
                        }
                }
@@ -6521,7 +6583,7 @@ static void spell_damcalc(monster_type *m_ptr, int typ, int dam, int limit, int
                if (100 + rlev / 2 <= MAX(5, p_ptr->skill_sav))
                {
                        dam = 0;
-                       complete_immune = TRUE;
+                       ignore_wraith_form = TRUE;
                }
                break;
 
@@ -6532,7 +6594,7 @@ static void spell_damcalc(monster_type *m_ptr, int typ, int dam, int limit, int
                if (100 + rlev / 2 <= p_ptr->skill_sav)
                {
                        dam = 0;
-                       complete_immune = TRUE;
+                       ignore_wraith_form = TRUE;
                }
                break;
 
@@ -6540,7 +6602,7 @@ static void spell_damcalc(monster_type *m_ptr, int typ, int dam, int limit, int
                if ((100 + rlev / 2 <= p_ptr->skill_sav) && (m_ptr->r_idx != MON_KENSHIROU))
                {
                        dam = 0;
-                       complete_immune = TRUE;
+                       ignore_wraith_form = TRUE;
                }
                break;
        }
@@ -6548,7 +6610,7 @@ static void spell_damcalc(monster_type *m_ptr, int typ, int dam, int limit, int
        if (p_ptr->wraith_form && !ignore_wraith_form)
        {
                dam /= 2;
-               if (!dam && !complete_immune) dam = 1;
+               if (!dam) dam = 1;
        }
 
        if (dam > *max) *max = dam;
@@ -6559,7 +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 complete_immune = FALSE;
+       bool check_wraith_form = TRUE;
 
        if (blow_ptr->method != RBM_EXPLODE)
        {
@@ -6582,37 +6644,37 @@ 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;
-                       complete_immune = p_ptr->immune_acid;
+                       check_wraith_form = FALSE;
                        break;
 
                case RBE_ELEC:
                        spell_damcalc(m_ptr, GF_ELEC, dam, 0, &dummy_max);
                        dam = dummy_max;
-                       complete_immune = p_ptr->immune_elec;
+                       check_wraith_form = FALSE;
                        break;
 
                case RBE_FIRE:
                        spell_damcalc(m_ptr, GF_FIRE, dam, 0, &dummy_max);
                        dam = dummy_max;
-                       complete_immune = p_ptr->immune_fire;
+                       check_wraith_form = FALSE;
                        break;
 
                case RBE_COLD:
                        spell_damcalc(m_ptr, GF_COLD, dam, 0, &dummy_max);
                        dam = dummy_max;
-                       complete_immune = p_ptr->immune_cold;
+                       check_wraith_form = FALSE;
                        break;
 
                case RBE_DR_MANA:
                        dam = 0;
-                       complete_immune = TRUE;
+                       check_wraith_form = FALSE;
                        break;
                }
 
-               if (p_ptr->wraith_form)
+               if (check_wraith_form && p_ptr->wraith_form)
                {
                        dam /= 2;
-                       if (!dam && !complete_immune) dam = 1;
+                       if (!dam) dam = 1;
                }
        }
        else