3 * @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"
22 * @brief 防具系オブジェクトに生成ランクごとの強化を与えるサブルーチン
23 * Apply magic to an item known to be "armor"
24 * @param owner_ptr プレーヤーへの参照ポインタ
25 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
30 * Hack -- note special processing for crown/helm\n
31 * Hack -- note special processing for robe of permanence\n
33 void apply_magic_armor(player_type *owner_ptr, object_type *o_ptr, DEPTH level, int power)
35 ARMOUR_CLASS toac1 = (ARMOUR_CLASS)randint1(5) + m_bonus(5, level);
36 ARMOUR_CLASS toac2 = (ARMOUR_CLASS)m_bonus(10, level);
42 } else if (power < 0) {
49 o_ptr->curse_flags |= TRC_CURSED;
52 switch (o_ptr->tval) {
54 /* power > 2 is debug only */
55 if (one_in_(50) || (power > 2))
56 become_random_artifact(owner_ptr, o_ptr, FALSE);
62 if ((o_ptr->tval == TV_SOFT_ARMOR) && (o_ptr->sval == SV_ROBE) && (randint0(100) < 15)) {
64 o_ptr->name2 = EGO_YOIYAMI;
65 o_ptr->k_idx = lookup_kind(TV_SOFT_ARMOR, SV_YOIYAMI_ROBE);
66 o_ptr->sval = SV_YOIYAMI_ROBE;
70 o_ptr->name2 = EGO_PERMANENCE;
76 /* power > 2 is debug only */
77 if (one_in_(20) || (power > 2)) {
78 become_random_artifact(owner_ptr, o_ptr, FALSE);
83 bool okay_flag = TRUE;
84 o_ptr->name2 = get_random_ego(INVEN_BODY, TRUE);
85 switch (o_ptr->name2) {
87 if (o_ptr->tval != TV_HARD_ARMOR) {
93 if (o_ptr->tval != TV_SOFT_ARMOR) {
106 switch (o_ptr->name2) {
109 add_flag(o_ptr->art_flags, TR_RES_POIS);
112 o_ptr->weight = (2 * k_info[o_ptr->k_idx].weight / 3);
113 o_ptr->ac = k_info[o_ptr->k_idx].ac + 5;
118 } else if (power < -1) {
120 bool okay_flag = TRUE;
121 o_ptr->name2 = get_random_ego(INVEN_BODY, FALSE);
123 switch (o_ptr->name2) {
126 o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
127 one_in_(3) ? add_flag(o_ptr->art_flags, TR_DRAIN_EXP)
128 : one_in_(2) ? add_flag(o_ptr->art_flags, TR_DRAIN_HP) : add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
131 add_flag(o_ptr->art_flags, TR_AGGRAVATE);
133 add_flag(o_ptr->art_flags, TR_ADD_L_CURSE);
135 add_flag(o_ptr->art_flags, TR_ADD_H_CURSE);
137 add_flag(o_ptr->art_flags, TR_DRAIN_HP);
139 add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
141 add_flag(o_ptr->art_flags, TR_DRAIN_EXP);
143 add_flag(o_ptr->art_flags, TR_TY_CURSE);
145 add_flag(o_ptr->art_flags, TR_CALL_DEMON);
149 o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
151 add_flag(o_ptr->art_flags, TR_TY_CURSE);
153 add_flag(o_ptr->art_flags, TR_ADD_H_CURSE);
155 add_flag(o_ptr->art_flags, TR_AGGRAVATE);
157 add_flag(o_ptr->art_flags, TR_NO_MAGIC);
159 add_flag(o_ptr->art_flags, TR_NO_TELE);
174 if (o_ptr->sval == SV_DRAGON_SHIELD) {
175 dragon_resist(o_ptr);
181 /* power > 2 is debug only */
182 if (one_in_(20) || (power > 2)) {
183 become_random_artifact(owner_ptr, o_ptr, FALSE);
188 o_ptr->name2 = get_random_ego(INVEN_SUB_HAND, TRUE);
189 if (o_ptr->sval != SV_SMALL_METAL_SHIELD && o_ptr->sval != SV_LARGE_METAL_SHIELD && o_ptr->name2 == EGO_S_DWARVEN) {
196 switch (o_ptr->name2) {
199 one_high_resistance(o_ptr);
201 add_flag(o_ptr->art_flags, TR_RES_POIS);
204 if (o_ptr->sval == SV_MIRROR_SHIELD)
209 o_ptr->weight = (2 * k_info[o_ptr->k_idx].weight / 3);
210 o_ptr->ac = k_info[o_ptr->k_idx].ac + 3;
218 if (o_ptr->sval == SV_SET_OF_DRAGON_GLOVES) {
219 dragon_resist(o_ptr);
225 /* power > 2 is debug only */
226 if (one_in_(20) || (power > 2)) {
227 become_random_artifact(owner_ptr, o_ptr, FALSE);
230 o_ptr->name2 = get_random_ego(INVEN_ARMS, TRUE);
231 } else if (power < -1) {
232 o_ptr->name2 = get_random_ego(INVEN_ARMS, FALSE);
239 if (o_ptr->sval == SV_PAIR_OF_DRAGON_GREAVE) {
240 dragon_resist(o_ptr);
246 /* power > 2 is debug only */
247 if (one_in_(20) || (power > 2)) {
248 become_random_artifact(owner_ptr, o_ptr, FALSE);
252 o_ptr->name2 = get_random_ego(INVEN_FEET, TRUE);
253 switch (o_ptr->name2) {
254 case EGO_SLOW_DESCENT:
256 one_high_resistance(o_ptr);
261 } else if (power < -1) {
262 o_ptr->name2 = get_random_ego(INVEN_FEET, FALSE);
269 /* power > 2 is debug only */
270 if (one_in_(20) || (power > 2)) {
271 become_random_artifact(owner_ptr, o_ptr, FALSE);
277 o_ptr->name2 = get_random_ego(INVEN_HEAD, TRUE);
279 switch (o_ptr->name2) {
281 if (add_esp_strong(o_ptr))
282 add_esp_weak(o_ptr, TRUE);
284 add_esp_weak(o_ptr, FALSE);
288 case EGO_REGENERATION:
295 add_esp_strong(o_ptr);
297 add_esp_weak(o_ptr, FALSE);
301 /* not existing crown (wisdom,lite, etc...) */
310 } else if (power < -1) {
313 o_ptr->name2 = get_random_ego(INVEN_HEAD, FALSE);
315 switch (o_ptr->name2) {
319 case EGO_ANCIENT_CURSE:
321 add_flag(o_ptr->art_flags, TR_NO_MAGIC);
323 add_flag(o_ptr->art_flags, TR_NO_TELE);
325 add_flag(o_ptr->art_flags, TR_TY_CURSE);
327 add_flag(o_ptr->art_flags, TR_DRAIN_EXP);
329 add_flag(o_ptr->art_flags, TR_DRAIN_HP);
331 add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
343 if (o_ptr->sval == SV_DRAGON_HELM) {
344 dragon_resist(o_ptr);
350 /* power > 2 is debug only */
351 if (one_in_(20) || (power > 2)) {
352 become_random_artifact(owner_ptr, o_ptr, FALSE);
358 o_ptr->name2 = get_random_ego(INVEN_HEAD, TRUE);
359 switch (o_ptr->name2) {
362 case EGO_INFRAVISION:
363 case EGO_H_PROTECTION:
368 add_esp_strong(o_ptr);
370 add_esp_weak(o_ptr, FALSE);
376 add_flag(o_ptr->art_flags, TR_LITE_1);
378 add_flag(o_ptr->art_flags, TR_LITE_2);
381 /* not existing helm (Magi, Might, etc...)*/
390 } else if (power < -1) {
393 o_ptr->name2 = get_random_ego(INVEN_HEAD, FALSE);
395 switch (o_ptr->name2) {
398 o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
399 one_in_(3) ? add_flag(o_ptr->art_flags, TR_DRAIN_EXP)
400 : one_in_(2) ? add_flag(o_ptr->art_flags, TR_DRAIN_HP) : add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
403 add_flag(o_ptr->art_flags, TR_AGGRAVATE);
405 add_flag(o_ptr->art_flags, TR_ADD_L_CURSE);
407 add_flag(o_ptr->art_flags, TR_ADD_H_CURSE);
409 add_flag(o_ptr->art_flags, TR_DRAIN_HP);
411 add_flag(o_ptr->art_flags, TR_DRAIN_MANA);
413 add_flag(o_ptr->art_flags, TR_DRAIN_EXP);
415 add_flag(o_ptr->art_flags, TR_TY_CURSE);
417 add_flag(o_ptr->art_flags, TR_CALL_DEMON);
419 case EGO_ANCIENT_CURSE:
433 /* power > 2 is debug only */
434 if (one_in_(20) || (power > 2)) {
435 become_random_artifact(owner_ptr, o_ptr, FALSE);
438 o_ptr->name2 = get_random_ego(INVEN_OUTER, TRUE);
440 switch (o_ptr->name2) {
449 add_flag(o_ptr->art_flags, TR_COWARDICE);
451 add_flag(o_ptr->art_flags, TR_CALL_UNDEAD);
453 add_flag(o_ptr->art_flags, TR_SLOW_REGEN);
455 add_flag(o_ptr->art_flags, TR_DRAIN_EXP);
459 } else if (power < -1) {
460 o_ptr->name2 = get_random_ego(INVEN_OUTER, FALSE);