2 * @file artifact-info.cpp
3 * @brief アーティファクトの発動効果取得関数定義
6 #include "artifact/artifact-info.h"
7 #include "artifact/random-art-effects.h"
8 #include "object-enchant/activation-info-table.h"
9 #include "object-enchant/object-ego.h"
10 #include "object-enchant/object-smith.h"
11 #include "object-enchant/tr-types.h"
12 #include "object/object-kind.h"
13 #include "system/artifact-type-definition.h"
14 #include "system/object-type-definition.h"
15 #include "util/bit-flags-calculator.h"
18 * @brief オブジェクトから能力発動IDを取得する。
19 * @details いくつかのケースで定義されている発動効果から、
20 * 鍛冶師による付与>固定アーティファクト>エゴ>ランダムアーティファクト>ベースアイテムの優先順位で走査していく。
21 * @param o_ptr 対象のオブジェクト構造体ポインタ
24 int activation_index(const object_type *o_ptr)
26 if (auto act_idx = Smith::object_activation(o_ptr); act_idx.has_value()) {
27 return act_idx.value();
30 if (o_ptr->is_fixed_artifact() && a_info[o_ptr->name1].flags.has(TR_ACTIVATE))
31 return a_info[o_ptr->name1].act_idx;
33 if (o_ptr->is_ego() && e_info[o_ptr->name2].flags.has(TR_ACTIVATE))
34 return e_info[o_ptr->name2].act_idx;
36 if (!o_ptr->is_random_artifact() && k_info[o_ptr->k_idx].flags.has(TR_ACTIVATE))
37 return k_info[o_ptr->k_idx].act_idx;
43 * @brief オブジェクトから発動効果構造体のポインタを取得する。
44 * @details activation_index() 関数の結果から参照する。
45 * @param o_ptr 対象のオブジェクト構造体ポインタ
46 * @return 発動効果構造体のポインタを返す
48 const activation_type *find_activation_info(const object_type *o_ptr)
50 const auto index = activation_index(o_ptr);
51 for (auto &p : activation_info) {
52 if (p.index == index) {