OSDN Git Service

[Refactor] #37353 make_artifact() と make_artifact_special() を artifact.c/h に移動。 ...
authorDeskull <deskull@users.sourceforge.jp>
Thu, 14 Feb 2019 09:37:25 +0000 (18:37 +0900)
committerDeskull <deskull@users.sourceforge.jp>
Thu, 14 Feb 2019 09:37:25 +0000 (18:37 +0900)
src/artifact.c
src/artifact.h
src/object2.c
src/spells1.c

index 5d2fc4f..97dea0b 100644 (file)
@@ -2465,4 +2465,139 @@ static bool weakening_artifact(object_type *o_ptr)
                return TRUE;
        }
        return FALSE;
-}
\ No newline at end of file
+}
+
+/*!
+ * @brief 非INSTA_ART型の固定アーティファクトの生成を確率に応じて試行する。
+ * Mega-Hack -- Attempt to create one of the "Special Objects"
+ * @param o_ptr 生成に割り当てたいオブジェクトの構造体参照ポインタ
+ * @return 生成に成功したらTRUEを返す。
+ * @details
+ * Attempt to change an object into an artifact\n
+ * This routine should only be called by "apply_magic()"\n
+ * Note -- see "make_artifact_special()" and "apply_magic()"\n
+ */
+bool make_artifact(object_type *o_ptr)
+{
+       ARTIFACT_IDX i;
+
+       /* No artifacts in the town */
+       if (!dun_level) return (FALSE);
+
+       /* Paranoia -- no "plural" artifacts */
+       if (o_ptr->number != 1) return (FALSE);
+
+       /* Check the artifact list (skip the "specials") */
+       for (i = 0; i < max_a_idx; i++)
+       {
+               artifact_type *a_ptr = &a_info[i];
+
+               /* Skip "empty" items */
+               if (!a_ptr->name) continue;
+
+               /* 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;
+
+               /* Must have the correct fields */
+               if (a_ptr->tval != o_ptr->tval) continue;
+               if (a_ptr->sval != o_ptr->sval) continue;
+
+               /* XXX XXX Enforce minimum "depth" (loosely) */
+               if (a_ptr->level > dun_level)
+               {
+                       /* Acquire the "out-of-depth factor" */
+                       int d = (a_ptr->level - dun_level) * 2;
+
+                       /* Roll for out-of-depth creation */
+                       if (!one_in_(d)) continue;
+               }
+
+               /* We must make the "rarity roll" */
+               if (!one_in_(a_ptr->rarity)) continue;
+
+               /* 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 */
+       return (FALSE);
+}
+
+/*!
+ * @brief INSTA_ART型の固定アーティファクトの生成を確率に応じて試行する。
+ * Mega-Hack -- Attempt to create one of the "Special Objects"
+ * @param o_ptr 生成に割り当てたいオブジェクトの構造体参照ポインタ
+ * @return 生成に成功したらTRUEを返す。
+ * @details
+ * We are only called from "make_object()", and we assume that\n
+ * "apply_magic()" is called immediately after we return.\n
+ *\n
+ * Note -- see "make_artifact()" and "apply_magic()"\n
+ */
+bool make_artifact_special(object_type *o_ptr)
+{
+       IDX i;
+       KIND_OBJECT_IDX k_idx = 0;
+
+       /*! @note 地上ではキャンセルする / No artifacts in the town */
+       if (!dun_level) return (FALSE);
+
+       /*! @note get_obj_num_hookによる指定がある場合は生成をキャンセルする / Themed object */
+       if (get_obj_num_hook) return (FALSE);
+
+       /*! @note 全固定アーティファクト中からIDの若い順に生成対象とその確率を走査する / Check the artifact list (just the "specials") */
+       for (i = 0; i < max_a_idx; i++)
+       {
+               artifact_type *a_ptr = &a_info[i];
+
+               /*! @note アーティファクト名が空の不正なデータは除外する / Skip "empty" artifacts */
+               if (!a_ptr->name) continue;
+
+               /*! @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;
+
+               /*! @note アーティファクト生成階が現在に対して足りない場合は高確率で1/(不足階層*2)を満たさないと生成リストに加えられない /
+                *  XXX XXX Enforce minimum "depth" (loosely) */
+               if (a_ptr->level > object_level)
+               {
+                       /* @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;
+               }
+
+               /*! @note 1/(レア度)の確率を満たさないと除外される / Artifact "rarity roll" */
+               if (!one_in_(a_ptr->rarity)) continue;
+
+               /*! @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);
+               if (k_info[k_idx].level > object_level)
+               {
+                       int d = (k_info[k_idx].level - object_level) * 5;
+                       if (!one_in_(d)) continue;
+               }
+
+               /*! @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);
+
+               o_ptr->name1 = i;
+               random_artifact_resistance(o_ptr, a_ptr);
+               return (TRUE);
+       }
+
+       /*! @note 全INSTA_ART固定アーティファクトを試行しても決まらなかった場合 FALSEを返す / Failure */
+       return (FALSE);
+}
index 123546d..40beffc 100644 (file)
@@ -12,6 +12,8 @@ extern int activation_index(object_type *o_ptr);
 extern const activation_type* find_activation_info(object_type *o_ptr);
 extern void random_artifact_resistance(object_type * o_ptr, artifact_type *a_ptr);
 extern bool create_named_art(ARTIFACT_IDX a_idx, POSITION y, POSITION x);
+extern bool make_artifact(object_type *o_ptr);
+extern bool make_artifact_special(object_type *o_ptr);
 
 /*** Artifact indexes (see "lib/edit/a_info.txt") ***/
 
index aa32d8a..eb29ce0 100644 (file)
@@ -2124,142 +2124,6 @@ static void object_mention(object_type *o_ptr)
        msg_format_wizard(CHEAT_OBJECT, _("%sを生成しました。", "%s was generated."), o_name);
 }
 
-/*!
- * @brief INSTA_ART型の固定アーティファクトの生成を確率に応じて試行する。
- * Mega-Hack -- Attempt to create one of the "Special Objects"
- * @param o_ptr 生成に割り当てたいオブジェクトの構造体参照ポインタ
- * @return 生成に成功したらTRUEを返す。
- * @details
- * We are only called from "make_object()", and we assume that\n
- * "apply_magic()" is called immediately after we return.\n
- *\n
- * Note -- see "make_artifact()" and "apply_magic()"\n
- */
-static bool make_artifact_special(object_type *o_ptr)
-{
-       IDX i;
-       KIND_OBJECT_IDX k_idx = 0;
-
-       /*! @note 地上ではキャンセルする / No artifacts in the town */
-       if (!dun_level) return (FALSE);
-
-       /*! @note get_obj_num_hookによる指定がある場合は生成をキャンセルする / Themed object */
-       if (get_obj_num_hook) return (FALSE);
-
-       /*! @note 全固定アーティファクト中からIDの若い順に生成対象とその確率を走査する / Check the artifact list (just the "specials") */
-       for (i = 0; i < max_a_idx; i++)
-       {
-               artifact_type *a_ptr = &a_info[i];
-
-               /*! @note アーティファクト名が空の不正なデータは除外する / Skip "empty" artifacts */
-               if (!a_ptr->name) continue;
-
-               /*! @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;
-
-               /*! @note アーティファクト生成階が現在に対して足りない場合は高確率で1/(不足階層*2)を満たさないと生成リストに加えられない /
-                *  XXX XXX Enforce minimum "depth" (loosely) */
-               if (a_ptr->level > object_level)
-               {
-                       /* @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;
-               }
-
-               /*! @note 1/(レア度)の確率を満たさないと除外される / Artifact "rarity roll" */
-               if (!one_in_(a_ptr->rarity)) continue;
-
-               /*! @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);
-               if (k_info[k_idx].level > object_level)
-               {
-                       int d = (k_info[k_idx].level - object_level) * 5;
-                       if (!one_in_(d)) continue;
-               }
-
-               /*! @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);
-
-               o_ptr->name1 = i;
-               random_artifact_resistance(o_ptr, a_ptr);
-               return (TRUE);
-       }
-
-       /*! @note 全INSTA_ART固定アーティファクトを試行しても決まらなかった場合 FALSEを返す / Failure */
-       return (FALSE);
-}
-
-
-/*!
- * @brief 非INSTA_ART型の固定アーティファクトの生成を確率に応じて試行する。
- * Mega-Hack -- Attempt to create one of the "Special Objects"
- * @param o_ptr 生成に割り当てたいオブジェクトの構造体参照ポインタ
- * @return 生成に成功したらTRUEを返す。
- * @details
- * Attempt to change an object into an artifact\n
- * This routine should only be called by "apply_magic()"\n
- * Note -- see "make_artifact_special()" and "apply_magic()"\n
- */
-static bool make_artifact(object_type *o_ptr)
-{
-       ARTIFACT_IDX i;
-
-       /* No artifacts in the town */
-       if (!dun_level) return (FALSE);
-
-       /* Paranoia -- no "plural" artifacts */
-       if (o_ptr->number != 1) return (FALSE);
-
-       /* Check the artifact list (skip the "specials") */
-       for (i = 0; i < max_a_idx; i++)
-       {
-               artifact_type *a_ptr = &a_info[i];
-
-               /* Skip "empty" items */
-               if (!a_ptr->name) continue;
-
-               /* 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;
-
-               /* Must have the correct fields */
-               if (a_ptr->tval != o_ptr->tval) continue;
-               if (a_ptr->sval != o_ptr->sval) continue;
-
-               /* XXX XXX Enforce minimum "depth" (loosely) */
-               if (a_ptr->level > dun_level)
-               {
-                       /* Acquire the "out-of-depth factor" */
-                       int d = (a_ptr->level - dun_level) * 2;
-
-                       /* Roll for out-of-depth creation */
-                       if (!one_in_(d)) continue;
-               }
-
-               /* We must make the "rarity roll" */
-               if (!one_in_(a_ptr->rarity)) continue;
-
-               /* 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 */
-       return (FALSE);
-}
-
 
 /*!
  * @brief アイテムのエゴをレア度の重みに合わせてランダムに選択する
index f87bdb0..b5530f0 100644 (file)
@@ -79,7 +79,7 @@ static void next_mirror(POSITION* next_y, POSITION* next_x, POSITION cury, POSIT
        *next_x = curx + randint0(5) - 2;
        return;
 }
-               
+
 /*!
  * @brief 万色表現用にランダムな色を選択する関数 /
  * Get a legal "multi-hued" color for drawing "spells"