OSDN Git Service

#37287 #37353 (2.2.0.89) 型の置換を継続中。 / Ongoing type replacement.
[hengband/hengband.git] / src / object2.c
index 2ad34a1..ffe8304 100644 (file)
 
 #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
@@ -235,15 +250,12 @@ void delete_object(int y, int x)
  * @param i2 整理したい配列の終点
  * @return なし
  */
-static void compact_objects_aux(int i1, int i2)
+static void compact_objects_aux(IDX i1, IDX i2)
 {
-       int i;
-
+       IDX i;
        cave_type *c_ptr;
-
        object_type *o_ptr;
 
-
        /* Do nothing */
        if (i1 == i2) return;
 
@@ -333,7 +345,8 @@ static void compact_objects_aux(int i1, int i2)
  */
 void compact_objects(int size)
 {
-       int i, y, x, num, cnt;
+       IDX i;
+       int y, x, num, cnt;
        int cur_lev, cur_dis, chance;
        object_type *o_ptr;
 
@@ -397,7 +410,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;
@@ -518,9 +531,9 @@ void wipe_o_list(void)
  * This routine should almost never fail, but in case it does,
  * we must be sure to handle "failure" of this routine.
  */
-s16b o_pop(void)
+IDX o_pop(void)
 {
-       int i;
+       IDX i;
 
 
        /* Initial allocation */
@@ -1842,11 +1855,11 @@ void object_absorb(object_type *o_ptr, object_type *j_ptr)
  * @param sval 検索したいベースアイテムのsval
  * @return なし
  */
-s16b lookup_kind(int tval, int sval)
+IDX lookup_kind(OBJECT_TYPE_VALUE tval, OBJECT_SUBTYPE_VALUE sval)
 {
-       int k;
+       IDX k;
        int num = 0;
-       int bk = 0;
+       IDX bk = 0;
 
        /* Look for it */
        for (k = 1; k < max_k_idx; k++)
@@ -1920,7 +1933,7 @@ void object_copy(object_type *o_ptr, object_type *j_ptr)
  * @param k_idx 新たに作成したいベースアイテム情報のID
  * @return なし
  */
-void object_prep(object_type *o_ptr, int k_idx)
+void object_prep(object_type *o_ptr, IDX k_idx)
 {
        object_kind *k_ptr = &k_info[k_idx];
 
@@ -2064,28 +2077,15 @@ static void object_mention(object_type *o_ptr)
 {
        char o_name[MAX_NLEN];
 
-       /*!
-        * @note アイテム名取得後アイテムの価値に応じたデバッグメッセージを出力する。
-        * Get Describe and view, Artifact, Random Artifact, Ego-item, and Normal item.
-        */
-       object_desc(o_name, o_ptr, (OD_NAME_ONLY | OD_STORE));
+       object_aware(o_ptr);
+       object_known(o_ptr);
 
-       if (object_is_fixed_artifact(o_ptr))
-       {
-               msg_format(_("伝説のアイテム (%s)", "Artifact (%s)"), o_name);
-       }
-       else if (o_ptr->art_name)
-       {
-               msg_print(_("ランダム・アーティファクト", "Random artifact"));
-       }
-       else if (object_is_ego(o_ptr))
-       {
-               msg_format(_("名のあるアイテム (%s)", "Ego-item (%s)"), o_name);
-       }
-       else
-       {
-               msg_format(_("アイテム (%s)", "Object (%s)"), o_name);
-       }
+       /* Mark the item as fully known */
+       o_ptr->ident |= (IDENT_MENTAL);
+
+       /* Description */
+       object_desc(o_name, o_ptr, 0);
+       msg_format_wizard(CHEAT_OBJECT, _("%sを生成しました。", "%s was generated."), o_name);
 }
 
 /*!
@@ -2101,8 +2101,8 @@ static void object_mention(object_type *o_ptr)
  */
 static bool make_artifact_special(object_type *o_ptr)
 {
-       int i;
-       int k_idx = 0;
+       IDX i;
+       IDX k_idx = 0;
 
        /*! @note 地上ではキャンセルする / No artifacts in the town */
        if (!dun_level) return (FALSE);
@@ -2170,7 +2170,7 @@ static bool make_artifact_special(object_type *o_ptr)
  */
 static bool make_artifact(object_type *o_ptr)
 {
-       int i;
+       IDX i;
 
 
        /* No artifacts in the town */
@@ -2283,11 +2283,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))
        {
@@ -2671,9 +2671,8 @@ static void add_esp_weak(object_type *o_ptr, bool extra)
  */
 static void a_m_aux_2(object_type *o_ptr, int level, int power)
 {
-       int toac1 = randint1(5) + m_bonus(5, level);
-
-       int toac2 = m_bonus(10, level);
+       ARMOUR_CLASS toac1 = randint1(5) + m_bonus(5, level);
+       ARMOUR_CLASS toac2 = m_bonus(10, level);
 
        /* Good */
        if (power > 0)
@@ -2714,10 +2713,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;
                }
 
@@ -2761,24 +2756,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)
                                {
@@ -2829,8 +2823,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;
                        }
@@ -2879,8 +2871,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;
                        }
@@ -2907,8 +2897,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;
                        }
@@ -3015,8 +3003,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;
                        }
@@ -3136,6 +3122,7 @@ static void a_m_aux_2(object_type *o_ptr, int level, int power)
                        break;
                }
        }
+
 }
 
 
@@ -3236,9 +3223,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;
                                }
 
@@ -3743,9 +3727,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;
                                }
 
@@ -4094,7 +4075,7 @@ static void a_m_aux_4(object_type *o_ptr, int level, int power)
 
                case TV_FIGURINE:
                {
-                       int i = 1;
+                       PARAMETER_VALUE i = 1;
                        int check;
 
                        monster_race *r_ptr;
@@ -4128,19 +4109,12 @@ 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;
                }
 
                case TV_CORPSE:
                {
-                       int i = 1;
+                       PARAMETER_VALUE i = 1;
                        int check;
 
                        u32b match = 0;
@@ -4182,11 +4156,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);
@@ -4195,7 +4164,7 @@ static void a_m_aux_4(object_type *o_ptr, int level, int power)
 
                case TV_STATUE:
                {
-                       int i = 1;
+                       PARAMETER_VALUE i = 1;
 
                        monster_race *r_ptr;
 
@@ -4424,10 +4393,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;
        }
@@ -4664,9 +4629,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;
@@ -4688,6 +4650,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);
        }
+
+       
 }
 
 
@@ -4804,7 +4768,7 @@ bool make_object(object_type *j_ptr, u32b mode)
        /* Generate a special object, or a normal object */
        if (!one_in_(prob) || !make_artifact_special(j_ptr))
        {
-               int k_idx;
+               IDX k_idx;
 
                /* Good objects */
                if ((mode & AM_GOOD) && !get_obj_num_hook)
@@ -4855,13 +4819,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);
@@ -4880,9 +4838,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];
@@ -5005,7 +4963,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;
 
@@ -5497,8 +5455,8 @@ void acquirement(int y1, int x1, int num, bool great, bool special, bool known)
 
 typedef struct
 {
-       int tval;
-       int sval;
+       OBJECT_TYPE_VALUE tval;
+       OBJECT_SUBTYPE_VALUE sval;
        int prob;
        byte flag;
 } amuse_type;
@@ -5544,7 +5502,8 @@ void amusement(int y1, int x1, int num, bool known)
        /* Acquirement */
        while (num)
        {
-               int i, k_idx, a_idx = 0;
+               int i;
+               IDX k_idx, a_idx = 0;
                int r = randint0(t);
                bool insta_art, fixed_art;
 
@@ -5831,7 +5790,7 @@ void inven_item_increase(int item, int num)
        else if (num < 0) num = 0;
 
        /* Un-apply */
-       num -= o_ptr->number;
+       num -= (ITEM_NUMBER)o_ptr->number;
 
        /* Change the number and weight */
        if (num)
@@ -6027,10 +5986,10 @@ void floor_item_increase(int item, int num)
        else if (num < 0) num = 0;
 
        /* Un-apply */
-       num -= o_ptr->number;
+       num -= (int)o_ptr->number;
 
        /* Change the number */
-       o_ptr->number += num;
+       o_ptr->number += (ITEM_NUMBER)num;
 }
 
 
@@ -6465,7 +6424,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);
@@ -6662,7 +6621,7 @@ void reorder_pack(void)
  * @details
  * Include list of usable spells for readible books
  */
-void display_koff(int k_idx)
+void display_koff(IDX k_idx)
 {
        int y;
 
@@ -7147,8 +7106,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))
                                {
@@ -7174,7 +7133,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);
@@ -7762,11 +7721,14 @@ static void drain_essence(void)
        int i, item;
        int dec = 4;
        bool observe = FALSE;
-       int old_ds, old_dd, old_to_h, old_to_d, old_ac, old_to_a, old_pval, old_name2, old_timeout;
+       int old_ds, old_dd, old_to_h, old_to_d, old_ac, old_to_a, old_pval, old_name2;
+       TIME_EFFECT old_timeout;
        u32b old_flgs[TR_FLAG_SIZE], new_flgs[TR_FLAG_SIZE];
        object_type *o_ptr;
-       cptr            q, s;
-       byte iy, ix, marked, number;
+       cptr q, s;
+       POSITION iy, ix;
+       byte_hack marked;
+       ITEM_NUMBER number;
        s16b next_o_idx, weight;
 
        for (i = 0; i < sizeof(drain_value) / sizeof(int); i++)
@@ -7867,7 +7829,7 @@ static void drain_essence(void)
        for (i = 0; essence_info[i].add_name; i++)
        {
                essence_type *es_ptr = &essence_info[i];
-               int pval = 0;
+               PARAMETER_VALUE pval = 0;
 
                if (es_ptr->add < TR_FLAG_MAX && is_pval_flag(es_ptr->add) && old_pval)
                        pval = (have_flag(new_flgs, es_ptr->add)) ? old_pval - o_ptr->pval : old_pval;
@@ -8461,14 +8423,14 @@ static void add_essence(int mode)
                        {
                                char tmp[80];
                                char tmp_val[160];
-                               int pval;
-                               int limit = MIN(5, p_ptr->magic_num1[es_ptr->essence]/es_ptr->value);
+                               PARAMETER_VALUE pval;
+                               PARAMETER_VALUE limit = MIN(5, p_ptr->magic_num1[es_ptr->essence]/es_ptr->value);
 
                                sprintf(tmp, _("いくつ付加しますか? (1-%d): ", "Enchant how many? (1-%d): "), limit);
                                strcpy(tmp_val, "1");
 
                                if (!get_string(tmp, tmp_val, 1)) return;
-                               pval = atoi(tmp_val);
+                               pval = (PARAMETER_VALUE)atoi(tmp_val);
                                if (pval > limit) pval = limit;
                                else if (pval < 1) pval = 1;
                                o_ptr->pval += pval;
@@ -8486,7 +8448,8 @@ static void add_essence(int mode)
                {
                        char tmp_val[160];
                        int val;
-                       int get_to_h, get_to_d;
+                       HIT_PROB get_to_h;
+                       HIT_POINT get_to_d;
 
                        strcpy(tmp_val, "1");
                        if (!get_string(format(_("いくつ付加しますか? (1-%d):", "Enchant how many? (1-%d):"), p_ptr->lev/7+3), tmp_val, 2)) return;