2 * @brief 防具系のアイテムを強化して(恐らく床に)生成する処理
8 #include "object-enchant/apply-magic-armor.h"
9 #include "artifact/random-art-generator.h"
10 #include "inventory/inventory-slot-types.h"
11 #include "object-enchant/object-boost.h"
12 #include "object-enchant/object-ego.h"
13 #include "object/object-kind-hook.h"
14 #include "object/object-kind.h"
15 #include "object-enchant/tr-types.h"
16 #include "object-enchant/trc-types.h"
17 #include "sv-definition/sv-armor-types.h"
18 #include "sv-definition/sv-protector-types.h"
19 #include "system/object-type-definition.h"
20 #include "util/bit-flags-calculator.h"
21 #include "view/display-messages.h"
24 * @brief 防具系オブジェクトに生成ランクごとの強化を与えるサブルーチン
25 * Apply magic to an item known to be "armor"
26 * @param owner_ptr プレーヤーへの参照ポインタ
27 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
31 * Hack -- note special processing for crown/helm\n
32 * Hack -- note special processing for robe of permanence\n
34 void apply_magic_armor(player_type *owner_ptr, object_type *o_ptr, DEPTH level, int power)
36 ARMOUR_CLASS toac1 = (ARMOUR_CLASS)randint1(5) + m_bonus(5, level);
37 ARMOUR_CLASS toac2 = (ARMOUR_CLASS)m_bonus(10, level);
43 } else if (power < 0) {
50 o_ptr->curse_flags.set(TRC::CURSED);
53 switch (o_ptr->tval) {
55 /* power > 2 is debug only */
56 if (one_in_(50) || (power > 2))
57 become_random_artifact(owner_ptr, o_ptr, false);
63 if ((o_ptr->tval == TV_SOFT_ARMOR) && (o_ptr->sval == SV_ROBE) && (randint0(100) < 15)) {
65 o_ptr->name2 = EGO_YOIYAMI;
66 o_ptr->k_idx = lookup_kind(TV_SOFT_ARMOR, SV_YOIYAMI_ROBE);
67 o_ptr->sval = SV_YOIYAMI_ROBE;
71 o_ptr->name2 = EGO_PERMANENCE;
77 /* power > 2 is debug only */
78 if (one_in_(20) || (power > 2)) {
79 become_random_artifact(owner_ptr, o_ptr, false);
84 bool okay_flag = true;
85 o_ptr->name2 = get_random_ego(INVEN_BODY, true);
86 switch (o_ptr->name2) {
88 if (o_ptr->tval != TV_HARD_ARMOR) {
94 if (o_ptr->tval != TV_SOFT_ARMOR) {
106 } else if (power < -1) {
108 bool okay_flag = true;
109 o_ptr->name2 = get_random_ego(INVEN_BODY, false);
111 switch (o_ptr->name2) {
116 msg_print(_("エラー:適した呪い鎧エゴがみつかりませんでした.", "Error:Suitable cursed armor ego not found."));
129 if (o_ptr->sval == SV_DRAGON_SHIELD) {
130 dragon_resist(o_ptr);
136 /* power > 2 is debug only */
137 if (one_in_(20) || (power > 2)) {
138 become_random_artifact(owner_ptr, o_ptr, false);
143 o_ptr->name2 = get_random_ego(INVEN_SUB_HAND, true);
144 if (o_ptr->sval != SV_SMALL_METAL_SHIELD && o_ptr->sval != SV_LARGE_METAL_SHIELD && o_ptr->name2 == EGO_S_DWARVEN) {
151 switch (o_ptr->name2) {
153 if (o_ptr->sval == SV_MIRROR_SHIELD)
164 if (o_ptr->sval == SV_SET_OF_DRAGON_GLOVES) {
165 dragon_resist(o_ptr);
171 /* power > 2 is debug only */
172 if (one_in_(20) || (power > 2)) {
173 become_random_artifact(owner_ptr, o_ptr, false);
176 o_ptr->name2 = get_random_ego(INVEN_ARMS, true);
177 } else if (power < -1) {
178 o_ptr->name2 = get_random_ego(INVEN_ARMS, false);
185 if (o_ptr->sval == SV_PAIR_OF_DRAGON_GREAVE) {
186 dragon_resist(o_ptr);
192 /* power > 2 is debug only */
193 if (one_in_(20) || (power > 2)) {
194 become_random_artifact(owner_ptr, o_ptr, false);
198 o_ptr->name2 = get_random_ego(INVEN_FEET, true);
199 } else if (power < -1) {
200 o_ptr->name2 = get_random_ego(INVEN_FEET, false);
207 /* power > 2 is debug only */
208 if (one_in_(20) || (power > 2)) {
209 become_random_artifact(owner_ptr, o_ptr, false);
215 o_ptr->name2 = get_random_ego(INVEN_HEAD, true);
217 switch (o_ptr->name2) {
221 case EGO_REGENERATION:
227 add_low_telepathy(o_ptr);
230 /* not existing crown (wisdom,lite, etc...) */
239 } else if (power < -1) {
242 o_ptr->name2 = get_random_ego(INVEN_HEAD, false);
244 switch (o_ptr->name2) {
260 if (o_ptr->sval == SV_DRAGON_HELM) {
261 dragon_resist(o_ptr);
267 /* power > 2 is debug only */
268 if (one_in_(20) || (power > 2)) {
269 become_random_artifact(owner_ptr, o_ptr, false);
275 o_ptr->name2 = get_random_ego(INVEN_HEAD, true);
276 switch (o_ptr->name2) {
279 case EGO_INFRAVISION:
280 case EGO_H_PROTECTION:
285 add_low_telepathy(o_ptr);
288 /* not existing helm (Magi, Might, etc...)*/
297 } else if (power < -1) {
300 o_ptr->name2 = get_random_ego(INVEN_HEAD, false);
302 switch (o_ptr->name2) {
303 case EGO_ANCIENT_CURSE:
319 /* power > 2 is debug only */
320 if (one_in_(20) || (power > 2)) {
321 become_random_artifact(owner_ptr, o_ptr, false);
324 o_ptr->name2 = get_random_ego(INVEN_OUTER, true);
325 } else if (power < -1) {
326 o_ptr->name2 = get_random_ego(INVEN_OUTER, false);