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 "util/bit-flags-calculator.h"
20 #include "view/display-messages.h"
23 * @brief 防具系オブジェクトに生成ランクごとの強化を与えるサブルーチン
24 * Apply magic to an item known to be "armor"
25 * @param owner_ptr プレーヤーへの参照ポインタ
26 * @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 |= 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) {
107 switch (o_ptr->name2) {
109 o_ptr->weight = (2 * k_info[o_ptr->k_idx].weight / 3);
110 o_ptr->ac = k_info[o_ptr->k_idx].ac + 5;
115 } else if (power < -1) {
117 bool okay_flag = TRUE;
118 o_ptr->name2 = get_random_ego(INVEN_BODY, FALSE);
120 switch (o_ptr->name2) {
125 msg_print(_("エラー:適した呪い鎧エゴがみつかりませんでした.", "Error:Suitable cursed armor ego not found."));
138 if (o_ptr->sval == SV_DRAGON_SHIELD) {
139 dragon_resist(o_ptr);
145 /* power > 2 is debug only */
146 if (one_in_(20) || (power > 2)) {
147 become_random_artifact(owner_ptr, o_ptr, FALSE);
152 o_ptr->name2 = get_random_ego(INVEN_SUB_HAND, TRUE);
153 if (o_ptr->sval != SV_SMALL_METAL_SHIELD && o_ptr->sval != SV_LARGE_METAL_SHIELD && o_ptr->name2 == EGO_S_DWARVEN) {
160 switch (o_ptr->name2) {
162 if (o_ptr->sval == SV_MIRROR_SHIELD)
166 o_ptr->weight = (2 * k_info[o_ptr->k_idx].weight / 3);
167 o_ptr->ac = k_info[o_ptr->k_idx].ac + 3;
177 if (o_ptr->sval == SV_SET_OF_DRAGON_GLOVES) {
178 dragon_resist(o_ptr);
184 /* power > 2 is debug only */
185 if (one_in_(20) || (power > 2)) {
186 become_random_artifact(owner_ptr, o_ptr, FALSE);
189 o_ptr->name2 = get_random_ego(INVEN_ARMS, TRUE);
190 } else if (power < -1) {
191 o_ptr->name2 = get_random_ego(INVEN_ARMS, FALSE);
198 if (o_ptr->sval == SV_PAIR_OF_DRAGON_GREAVE) {
199 dragon_resist(o_ptr);
205 /* power > 2 is debug only */
206 if (one_in_(20) || (power > 2)) {
207 become_random_artifact(owner_ptr, o_ptr, FALSE);
211 o_ptr->name2 = get_random_ego(INVEN_FEET, TRUE);
212 } else if (power < -1) {
213 o_ptr->name2 = get_random_ego(INVEN_FEET, FALSE);
220 /* power > 2 is debug only */
221 if (one_in_(20) || (power > 2)) {
222 become_random_artifact(owner_ptr, o_ptr, FALSE);
228 o_ptr->name2 = get_random_ego(INVEN_HEAD, TRUE);
230 switch (o_ptr->name2) {
232 if (add_esp_strong(o_ptr))
233 add_esp_weak(o_ptr, TRUE);
235 add_esp_weak(o_ptr, FALSE);
239 case EGO_REGENERATION:
246 add_esp_strong(o_ptr);
248 add_esp_weak(o_ptr, FALSE);
252 /* not existing crown (wisdom,lite, etc...) */
261 } else if (power < -1) {
264 o_ptr->name2 = get_random_ego(INVEN_HEAD, FALSE);
266 switch (o_ptr->name2) {
282 if (o_ptr->sval == SV_DRAGON_HELM) {
283 dragon_resist(o_ptr);
289 /* power > 2 is debug only */
290 if (one_in_(20) || (power > 2)) {
291 become_random_artifact(owner_ptr, o_ptr, FALSE);
297 o_ptr->name2 = get_random_ego(INVEN_HEAD, TRUE);
298 switch (o_ptr->name2) {
301 case EGO_INFRAVISION:
302 case EGO_H_PROTECTION:
308 add_esp_strong(o_ptr);
310 add_esp_weak(o_ptr, FALSE);
314 /* not existing helm (Magi, Might, etc...)*/
323 } else if (power < -1) {
326 o_ptr->name2 = get_random_ego(INVEN_HEAD, FALSE);
328 switch (o_ptr->name2) {
329 case EGO_ANCIENT_CURSE:
345 /* power > 2 is debug only */
346 if (one_in_(20) || (power > 2)) {
347 become_random_artifact(owner_ptr, o_ptr, FALSE);
350 o_ptr->name2 = get_random_ego(INVEN_OUTER, TRUE);
352 switch (o_ptr->name2) {
363 } else if (power < -1) {
364 o_ptr->name2 = get_random_ego(INVEN_OUTER, FALSE);