OSDN Git Service

#37287 #37353 (2.2.0.89) idx型とhit_prob型を定義し、型の置換を継続中。 / Define typedef idx and hit_pr...
[hengband/hengband.git] / src / object2.c
index dc9c22a..b51a646 100644 (file)
@@ -1,4 +1,4 @@
-/*!
+/*!
  * @file object2.c
  * @brief オブジェクトの実装 / Object code, part 2
  * @date 2014/01/11
 
 #include "angband.h"
 
-#include "kajitips.h"
+static cptr const kaji_tips[5] =
+{
+#ifdef JP
+       "現在持っているエッセンスの一覧を表示する。",
+       "アイテムからエッセンスを取り出す。エッセンスを取られたアイテムは全く魔法がかかっていない初期状態に戻る。",
+       "既にエッセンスが付加されたアイテムからエッセンスのみ消し去る。エッセンスは手に入らない。",
+       "アイテムにエッセンスを付加する。既にエッセンスが付加されたアイテムやアーティファクトには付加できない。",
+       "武器や防具を強化したり、攻撃で傷つかないようにしたりする。エッセンスが付加されたアイテムやアーティファクトに対しても使用できる。",
+#else
+       "Display essences you have.",
+       "Extract essences from an item. The item become non magical.",
+       "Remove added essences from an equipment which was improved before. The removed essence will be ruined.",
+       "Add essences to an item. The improved items or artifacts cannot be reimprove.",
+       "Enchant an equipment or make an equiment element-proofed. The improved items and artifacts can be enchanted too.",
+#endif
+};
 
 /*!
  * @brief 床上、モンスター所持でスタックされたアイテムを削除しスタックを補完する / Excise a dungeon object from any stacks
@@ -397,7 +412,7 @@ void compact_objects(int size)
                        }
 
                        /* Nearby objects start out "immune" */
-                       if ((cur_dis > 0) && (distance(py, px, y, x) < cur_dis)) continue;
+                       if ((cur_dis > 0) && (distance(p_ptr->y, p_ptr->x, y, x) < cur_dis)) continue;
 
                        /* Saving throw */
                        chance = 90;
@@ -2064,35 +2079,15 @@ static void object_mention(object_type *o_ptr)
 {
        char o_name[MAX_NLEN];
 
-       /* Describe */
-       object_desc(o_name, o_ptr, (OD_NAME_ONLY | OD_STORE));
-
-       /* Artifact */
-       if (object_is_fixed_artifact(o_ptr))
-       {
-               /* Silly message */
-               msg_format(_("伝説のアイテム (%s)", "Artifact (%s)"), o_name);
-       }
-
-       /* Random Artifact */
-       else if (o_ptr->art_name)
-       {
-               msg_print(_("ランダム・アーティファクト", "Random artifact"));
-       }
+       object_aware(o_ptr);
+       object_known(o_ptr);
 
-       /* Ego-item */
-       else if (object_is_ego(o_ptr))
-       {
-               /* Silly message */
-               msg_format(_("名のあるアイテム (%s)", "Ego-item (%s)"), o_name);
-       }
+       /* Mark the item as fully known */
+       o_ptr->ident |= (IDENT_MENTAL);
 
-       /* Normal item */
-       else
-       {
-               /* Silly message */
-               msg_format(_("アイテム (%s)", "Object (%s)"), o_name);
-       }
+       /* Description */
+       object_desc(o_name, o_ptr, 0);
+       msg_format_wizard(CHEAT_OBJECT, _("%sを生成しました。", "%s was generated."), o_name);
 }
 
 /*!
@@ -2111,67 +2106,56 @@ static bool make_artifact_special(object_type *o_ptr)
        int i;
        int k_idx = 0;
 
-
-       /* No artifacts in the town */
+       /*! @note 地上ではキャンセルする / No artifacts in the town */
        if (!dun_level) return (FALSE);
 
-       /* Themed object */
+       /*! @note get_obj_num_hookによる指定がある場合は生成をキャンセルする / Themed object */
        if (get_obj_num_hook) return (FALSE);
 
-       /* Check the artifact list (just the "specials") */
+       /*! @note 全固定アーティファクト中からIDの若い順に生成対象とその確率を走査する / Check the artifact list (just the "specials") */
        for (i = 0; i < max_a_idx; i++)
        {
                artifact_type *a_ptr = &a_info[i];
 
-               /* Skip "empty" artifacts */
+               /*! @note アーティファクト名が空の不正なデータは除外する / Skip "empty" artifacts */
                if (!a_ptr->name) continue;
 
-               /* Cannot make an artifact twice */
+               /*! @note 既に生成回数がカウントされたアーティファクト、QUESTITEMと非INSTA_ARTは除外 / Cannot make an artifact twice */
                if (a_ptr->cur_num) continue;
-
                if (a_ptr->gen_flags & TRG_QUESTITEM) continue;
                if (!(a_ptr->gen_flags & TRG_INSTA_ART)) continue;
 
-               /* XXX XXX Enforce minimum "depth" (loosely) */
-               if (a_ptr->level > dun_level)
+               /*! @note アーティファクト生成階が現在に対して足りない場合は高確率で1/(不足階層*2)を満たさないと生成リストに加えられない /
+                *  XXX XXX Enforce minimum "depth" (loosely) */
+               if (a_ptr->level > object_level)
                {
-                       /* Acquire the "out-of-depth factor" */
-                       int d = (a_ptr->level - dun_level) * 2;
-
-                       /* Roll for out-of-depth creation */
+                       /* @note  / Acquire the "out-of-depth factor". Roll for out-of-depth creation. */
+                       int d = (a_ptr->level - object_level) * 2;
                        if (!one_in_(d)) continue;
                }
 
-               /* Artifact "rarity roll" */
+               /*! @note 1/(レア度)の確率を満たさないと除外される / Artifact "rarity roll" */
                if (!one_in_(a_ptr->rarity)) continue;
 
-               /* Find the base object */
+               /*! @note INSTA_ART型固定アーティファクトのベースアイテムもチェック対象とする。ベースアイテムの生成階層が足りない場合1/(不足階層*5) を満たさないと除外される。 /
+                *  Find the base object. XXX XXX Enforce minimum "object" level (loosely). Acquire the "out-of-depth factor". Roll for out-of-depth creation. */
                k_idx = lookup_kind(a_ptr->tval, a_ptr->sval);
-
-               /* XXX XXX Enforce minimum "object" level (loosely) */
                if (k_info[k_idx].level > object_level)
                {
-                       /* Acquire the "out-of-depth factor" */
                        int d = (k_info[k_idx].level - object_level) * 5;
-
-                       /* Roll for out-of-depth creation */
                        if (!one_in_(d)) continue;
                }
 
-               /* Assign the template */
+               /*! @note 前述の条件を満たしたら、後のIDのアーティファクトはチェックせずすぐ確定し生成処理に移す /
+                * Assign the template. Mega-Hack -- mark the item as an artifact. Hack: Some artifacts get random extra powers. Success. */
                object_prep(o_ptr, k_idx);
 
-               /* Mega-Hack -- mark the item as an artifact */
                o_ptr->name1 = i;
-
-               /* Hack: Some artifacts get random extra powers */
                random_artifact_resistance(o_ptr, a_ptr);
-
-               /* Success */
                return (TRUE);
        }
 
-       /* Failure */
+       /*! @note 全INSTA_ART固定アーティファクトを試行しても決まらなかった場合 FALSEを返す / Failure */
        return (FALSE);
 }
 
@@ -2301,11 +2285,11 @@ static byte get_random_ego(byte slot, bool good)
  */
 static void a_m_aux_1(object_type *o_ptr, int level, int power)
 {
-       int tohit1 = randint1(5) + m_bonus(5, level);
-       int todam1 = randint1(5) + m_bonus(5, level);
+       hit_prob tohit1 = randint1(5) + m_bonus(5, level);
+       hit_point todam1 = randint1(5) + m_bonus(5, level);
 
-       int tohit2 = m_bonus(10, level);
-       int todam2 = m_bonus(10, level);
+       hit_prob tohit2 = m_bonus(10, level);
+       hit_point todam2 = m_bonus(10, level);
 
        if ((o_ptr->tval == TV_BOLT) || (o_ptr->tval == TV_ARROW) || (o_ptr->tval == TV_SHOT))
        {
@@ -2732,10 +2716,6 @@ static void a_m_aux_2(object_type *o_ptr, int level, int power)
                {
                        if (one_in_(50) || (power > 2)) /* power > 2 is debug only */
                                create_artifact(o_ptr, FALSE);
-
-                       /* Mention the item */
-                       if (cheat_peek) object_mention(o_ptr);
-
                        break;
                }
 
@@ -2779,24 +2759,23 @@ static void a_m_aux_2(object_type *o_ptr, int level, int power)
 
                                        switch (o_ptr->name2)
                                        {
-                                         case EGO_DWARVEN:
-                                               if (o_ptr->tval != TV_HARD_ARMOR)
-                                               {
-                                                       okay_flag = FALSE;
-                                                       break;
-                                               }
-                                         case EGO_DRUID:
-                                               if (o_ptr->tval != TV_SOFT_ARMOR)
-                                               {
-                                                       okay_flag = FALSE;
-                                                       break;
-                                               }
-                                         default:
+                                               case EGO_DWARVEN:
+                                                       if (o_ptr->tval != TV_HARD_ARMOR)
+                                                       {
+                                                               okay_flag = FALSE;
+                                                       }
+                                               break;
+                                               case EGO_DRUID:
+                                                       if (o_ptr->tval != TV_SOFT_ARMOR)
+                                                       {
+                                                               okay_flag = FALSE;
+                                                       }
+                                               break;
+                                               default:
                                                break;
                                        }
 
-                                       if (okay_flag)
-                                               break;
+                                       if (okay_flag) break;
                                }
                                switch (o_ptr->name2)
                                {
@@ -2847,8 +2826,6 @@ static void a_m_aux_2(object_type *o_ptr, int level, int power)
 
                        if (o_ptr->sval == SV_DRAGON_SHIELD)
                        {
-                               /* Mention the item */
-                               if (cheat_peek) object_mention(o_ptr);
                                dragon_resist(o_ptr);
                                if (!one_in_(3)) break;
                        }
@@ -2897,8 +2874,6 @@ static void a_m_aux_2(object_type *o_ptr, int level, int power)
                {
                        if (o_ptr->sval == SV_SET_OF_DRAGON_GLOVES)
                        {
-                               /* Mention the item */
-                               if (cheat_peek) object_mention(o_ptr);
                                dragon_resist(o_ptr);
                                if (!one_in_(3)) break;
                        }
@@ -2925,8 +2900,6 @@ static void a_m_aux_2(object_type *o_ptr, int level, int power)
                {
                        if (o_ptr->sval == SV_PAIR_OF_DRAGON_GREAVE)
                        {
-                               /* Mention the item */
-                               if (cheat_peek) object_mention(o_ptr);
                                dragon_resist(o_ptr);
                                if (!one_in_(3)) break;
                        }
@@ -3033,8 +3006,6 @@ static void a_m_aux_2(object_type *o_ptr, int level, int power)
                {
                        if (o_ptr->sval == SV_DRAGON_HELM)
                        {
-                               /* Mention the item */
-                               if (cheat_peek) object_mention(o_ptr);
                                dragon_resist(o_ptr);
                                if (!one_in_(3)) break;
                        }
@@ -3154,6 +3125,7 @@ static void a_m_aux_2(object_type *o_ptr, int level, int power)
                        break;
                }
        }
+
 }
 
 
@@ -3254,9 +3226,6 @@ static void a_m_aux_3(object_type *o_ptr, int level, int power)
                                                break;
                                        }
 
-                                       /* Mention the item */
-                                       if (cheat_peek) object_mention(o_ptr);
-
                                        break;
                                }
 
@@ -3761,9 +3730,6 @@ static void a_m_aux_3(object_type *o_ptr, int level, int power)
                                        /* gain one low ESP */
                                        add_esp_weak(o_ptr, FALSE);
 
-                                       /* Mention the item */
-                                       if (cheat_peek) object_mention(o_ptr);
-
                                        break;
                                }
 
@@ -4146,13 +4112,6 @@ static void a_m_aux_4(object_type *o_ptr, int level, int power)
                        /* Some figurines are cursed */
                        if (one_in_(6)) o_ptr->curse_flags |= TRC_CURSED;
 
-                       if (cheat_peek)
-                       {
-                               msg_format(_("%sの人形, 深さ +%d%s", "Figurine of %s, depth +%d%s"),
-                                                         r_name + r_ptr->name, check - 1,
-                                                         !object_is_cursed(o_ptr) ? "" : " {cursed}");
-                       }
-
                        break;
                }
 
@@ -4200,11 +4159,6 @@ static void a_m_aux_4(object_type *o_ptr, int level, int power)
 
                        o_ptr->pval = i;
 
-                       if (cheat_peek)
-                       {
-                               msg_format(_("%sの死体, 深さ +%d", "Corpse of %s, depth +%d"),
-                                                         r_name + r_ptr->name, check - 1);
-                       }
 
                        object_aware(o_ptr);
                        object_known(o_ptr);
@@ -4442,10 +4396,6 @@ void apply_magic(object_type *o_ptr, int lev, u32b mode)
                if (a_ptr->gen_flags & (TRG_RANDOM_CURSE1)) o_ptr->curse_flags |= get_curse(1, o_ptr);
                if (a_ptr->gen_flags & (TRG_RANDOM_CURSE2)) o_ptr->curse_flags |= get_curse(2, o_ptr);
 
-
-               /* Cheat -- peek at the item */
-               if (cheat_peek) object_mention(o_ptr);
-
                /* Done */
                return;
        }
@@ -4682,9 +4632,6 @@ void apply_magic(object_type *o_ptr, int lev, u32b mode)
                        if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_HAYABUSA) && (o_ptr->pval > 2) && (o_ptr->name2 != EGO_ATTACKS))
                                o_ptr->pval = 2;
                }
-
-               /* Cheat -- describe the item */
-               if (cheat_peek) object_mention(o_ptr);
                
                /* Done */
                return;
@@ -4706,6 +4653,8 @@ void apply_magic(object_type *o_ptr, int lev, u32b mode)
                if (k_ptr->gen_flags & (TRG_RANDOM_CURSE1)) o_ptr->curse_flags |= get_curse(1, o_ptr);
                if (k_ptr->gen_flags & (TRG_RANDOM_CURSE2)) o_ptr->curse_flags |= get_curse(2, o_ptr);
        }
+
+       
 }
 
 
@@ -4873,13 +4822,7 @@ bool make_object(object_type *j_ptr, u32b mode)
        obj_level = k_info[j_ptr->k_idx].level;
        if (object_is_fixed_artifact(j_ptr)) obj_level = a_info[j_ptr->name1].level;
 
-       /* Notice "okay" out-of-depth objects */
-       if (!object_is_cursed(j_ptr) && !object_is_broken(j_ptr) &&
-           (obj_level > dun_level))
-       {
-               /* Cheat -- peek at items */
-               if (cheat_peek) object_mention(j_ptr);
-       }
+       if (cheat_peek) object_mention(j_ptr);
 
        /* Success */
        return (TRUE);
@@ -4898,9 +4841,9 @@ bool make_object(object_type *j_ptr, u32b mode)
  * This routine uses "object_level" for the "generation level".\n
  * This routine requires a clean floor grid destination.\n
  */
-void place_object(int y, int x, u32b mode)
+void place_object(position y, position x, u32b mode)
 {
-       s16b o_idx;
+       idx o_idx;
 
        /* Acquire grid */
        cave_type *c_ptr = &cave[y][x];
@@ -5023,7 +4966,7 @@ bool make_gold(object_type *j_ptr)
  * @details
  * The location must be a legal, clean, floor grid.
  */
-void place_gold(int y, int x)
+void place_gold(position y, position x)
 {
        s16b o_idx;
 
@@ -6483,7 +6426,7 @@ void inven_drop(int item, int amt)
        msg_format(_("%s(%c)を落とした。", "You drop %s (%c)."), o_name, index_to_label(item));
 
        /* Drop it near the player */
-       (void)drop_near(q_ptr, 0, py, px);
+       (void)drop_near(q_ptr, 0, p_ptr->y, p_ptr->x);
 
        /* Modify, Describe, Optimize */
        inven_item_increase(item, -amt);
@@ -7034,7 +6977,6 @@ static void spell_damcalc(monster_type *m_ptr, int typ, int dam, int *max)
 * @brief 警告基準を定めるために魔法の効果属性に基づいて最大魔法ダメージを計算する。 /
 * Calculate spell damages
 * @param spell_num RF4ならRF4_SPELL_STARTのように32区切りのベースとなる数値
-* @param spell_flag RF4_SHRIEKなどのスペルフラグ
 * @param typ 効果属性のID
 * @param m_idx 魔法を行使するモンスターのID
 * @param max 算出した最大ダメージを返すポインタ
@@ -7166,8 +7108,8 @@ bool process_warning(int xx, int yy)
                        if (projectable(my, mx, yy, xx))
             {
                                u32b f4 = r_ptr->flags4;
-                               u32b f5 = r_ptr->flags5;
-                               u32b f6 = r_ptr->flags6;
+                               u32b f5 = r_ptr->a_ability_flags1;
+                               u32b f6 = r_ptr->a_ability_flags2;
 
                                if (!(d_info[dungeon_type].flags1 & DF1_NO_MAGIC))
                                {
@@ -7193,7 +7135,7 @@ bool process_warning(int xx, int yy)
                 if (f4 & RF4_BR_DISE) spell_damcalc_by_spellnum(MS_BR_DISEN, GF_DISENCHANT, c_ptr->m_idx, &dam_max0);
                 if (f4 & RF4_BR_NEXU) spell_damcalc_by_spellnum(MS_BR_NEXUS, GF_NEXUS, c_ptr->m_idx, &dam_max0);
                 if (f4 & RF4_BR_TIME) spell_damcalc_by_spellnum(MS_BR_TIME, GF_TIME, c_ptr->m_idx, &dam_max0);
-                if (f4 & RF4_BR_INER) spell_damcalc_by_spellnum(MS_BR_INERTIA, GF_INERTIA, c_ptr->m_idx, &dam_max0);
+                if (f4 & RF4_BR_INER) spell_damcalc_by_spellnum(MS_BR_INERTIA, GF_INERTIAL, c_ptr->m_idx, &dam_max0);
                 if (f4 & RF4_BR_GRAV) spell_damcalc_by_spellnum(MS_BR_GRAVITY, GF_GRAVITY, c_ptr->m_idx, &dam_max0);
                 if (f4 & RF4_BR_SHAR) spell_damcalc_by_spellnum(MS_BR_SHARDS, GF_SHARDS, c_ptr->m_idx, &dam_max0);
                 if (f4 & RF4_BR_PLAS) spell_damcalc_by_spellnum(MS_BR_PLASMA, GF_PLASMA, c_ptr->m_idx, &dam_max0);
@@ -7819,7 +7761,7 @@ static void drain_essence(void)
                if (!get_check(format(_("本当に%sから抽出してよろしいですか?", "Really extract from %s? "), o_name))) return;
        }
 
-       energy_use = 100;
+       p_ptr->energy_use = 100;
 
        object_flags(o_ptr, old_flgs);
        if (have_flag(old_flgs, TR_KILL_DRAGON)) add_flag(old_flgs, TR_SLAY_DRAGON);
@@ -8531,7 +8473,7 @@ static void add_essence(int mode)
                        if ((o_ptr->to_h >= p_ptr->lev/5+5) && (o_ptr->to_d >= p_ptr->lev/5+5))
                        {
                                msg_print(_("改良に失敗した。", "You failed to enchant."));
-                               energy_use = 100;
+                               p_ptr->energy_use = 100;
                                return;
                        }
                        else
@@ -8545,7 +8487,7 @@ static void add_essence(int mode)
                        if (o_ptr->to_a >= p_ptr->lev/5+5)
                        {
                                msg_print(_("改良に失敗した。", "You failed to enchant."));
-                               energy_use = 100;
+                               p_ptr->energy_use = 100;
                                return;
                        }
                        else
@@ -8622,7 +8564,7 @@ static void add_essence(int mode)
                }
        }
 
-       energy_use = 100;
+       p_ptr->energy_use = 100;
 
 #ifdef JP
        msg_format("%sに%sの能力を付加しました。", o_name, es_ptr->add_name);
@@ -8672,7 +8614,7 @@ static void erase_essence(void)
        object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
        if (!get_check(format(_("よろしいですか? [%s]", "Are you sure? [%s]"), o_name))) return;
 
-       energy_use = 100;
+       p_ptr->energy_use = 100;
 
        if (o_ptr->xtra3 == 1+ESSENCE_SLAY_GLOVE)
        {