1 #include "artifact/artifact-info.h"
2 #include "artifact/random-art-effects.h"
3 #include "cmd-item/cmd-smith.h"
4 #include "mind/mind-weaponsmith.h"
5 #include "object-enchant/object-ego.h"
6 #include "object-enchant/tr-types.h"
7 #include "object-hook/hook-enchant.h"
8 #include "object/object-kind.h"
9 #include "system/artifact-type-definition.h"
10 #include "system/object-type-definition.h"
11 #include "util/bit-flags-calculator.h"
14 * @brief オブジェクトから能力発動IDを取得する。
15 * @details いくつかのケースで定義されている発動効果から、
16 * 鍛冶師による付与>固定アーティファクト>エゴ>ランダムアーティファクト>ベースアイテムの優先順位で走査していく。
17 * @param o_ptr 対象のオブジェクト構造体ポインタ
20 int activation_index(player_type *player_ptr, object_type *o_ptr)
22 if (object_is_smith(player_ptr, o_ptr)) {
23 switch (o_ptr->xtra3 - 1) {
24 case ESSENCE_TMP_RES_ACID:
25 return ACT_RESIST_ACID;
26 case ESSENCE_TMP_RES_ELEC:
27 return ACT_RESIST_ELEC;
28 case ESSENCE_TMP_RES_FIRE:
29 return ACT_RESIST_FIRE;
30 case ESSENCE_TMP_RES_COLD:
31 return ACT_RESIST_COLD;
37 if (object_is_fixed_artifact(o_ptr) && has_flag(a_info[o_ptr->name1].flags, TR_ACTIVATE))
38 return a_info[o_ptr->name1].act_idx;
40 if (object_is_ego(o_ptr) && has_flag(e_info[o_ptr->name2].flags, TR_ACTIVATE))
41 return e_info[o_ptr->name2].act_idx;
43 if (!object_is_random_artifact(o_ptr) && has_flag(k_info[o_ptr->k_idx].flags, TR_ACTIVATE))
44 return k_info[o_ptr->k_idx].act_idx;
50 * @brief オブジェクトから発動効果構造体のポインタを取得する。
51 * @details activation_index() 関数の結果から参照する。
52 * @param o_ptr 対象のオブジェクト構造体ポインタ
53 * @return 発動効果構造体のポインタを返す
55 const activation_type *find_activation_info(player_type *player_ptr, object_type *o_ptr)
57 const int index = activation_index(player_ptr, o_ptr);
58 const activation_type *p;
59 for (p = activation_info; p->flag != NULL; ++p)
60 if (p->index == index)