2 * @brief ベースアイテムを強化する処理
8 #include "object-enchant/apply-magic.h"
9 #include "artifact/fixed-art-generator.h"
10 #include "artifact/fixed-art-types.h"
11 #include "dungeon/dungeon.h"
12 #include "mutation/mutation-flag-types.h"
13 #include "object-enchant/item-apply-magic.h"
14 #include "object-enchant/object-curse.h"
15 #include "object-enchant/object-ego.h"
16 #include "object-enchant/others/apply-magic-amulet.h"
17 #include "object-enchant/others/apply-magic-others.h"
18 #include "object-enchant/others/apply-magic-ring.h"
19 #include "object-enchant/protector/apply-magic-armor.h"
20 #include "object-enchant/protector/apply-magic-boots.h"
21 #include "object-enchant/protector/apply-magic-cloak.h"
22 #include "object-enchant/protector/apply-magic-crown.h"
23 #include "object-enchant/protector/apply-magic-gloves.h"
24 #include "object-enchant/protector/apply-magic-helm.h"
25 #include "object-enchant/protector/apply-magic-shield.h"
26 #include "object-enchant/special-object-flags.h"
27 #include "object-enchant/tr-types.h"
28 #include "object-enchant/trc-types.h"
29 #include "object-enchant/trg-types.h"
30 #include "object-enchant/weapon/apply-magic-weapon.h"
31 #include "object/object-kind.h"
32 #include "player/player-status-flags.h"
33 #include "sv-definition/sv-armor-types.h"
34 #include "sv-definition/sv-protector-types.h"
35 #include "sv-definition/sv-weapon-types.h"
36 #include "system/artifact-type-definition.h"
37 #include "system/floor-type-definition.h"
38 #include "system/player-type-definition.h"
39 #include "util/bit-flags-calculator.h"
40 #include "world/world.h"
43 * @brief 生成されたベースアイテムに魔法的な強化を与えるメインルーチン
44 * Complete the "creation" of an object by applying "magic" to the item
45 * @param player_ptr プレイヤーへの参照ポインタ
46 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
50 * エゴ&アーティファクトの生成、呪い、pval強化
52 void apply_magic_to_object(PlayerType *player_ptr, object_type *o_ptr, DEPTH lev, BIT_FLAGS mode)
54 if (player_ptr->ppersonality == PERSONALITY_MUNCHKIN)
55 lev += randint0(player_ptr->lev / 2 + 10);
56 if (lev > MAX_DEPTH - 1)
60 if (f1 > d_info[player_ptr->dungeon_idx].obj_good)
61 f1 = d_info[player_ptr->dungeon_idx].obj_good;
64 if ((player_ptr->ppersonality != PERSONALITY_MUNCHKIN) && (f2 > d_info[player_ptr->dungeon_idx].obj_great))
65 f2 = d_info[player_ptr->dungeon_idx].obj_great;
67 if (has_good_luck(player_ptr)) {
70 } else if (player_ptr->muta.has(PlayerMutationType::BAD_LUCK)) {
76 if ((mode & AM_GOOD) || magik(f1)) {
78 if ((mode & AM_GREAT) || magik(f2)) {
80 if (mode & AM_SPECIAL)
83 } else if (magik(f1)) {
88 if (mode & AM_CURSED) {
100 if (mode & (AM_GREAT | AM_SPECIAL))
102 if ((mode & AM_NO_FIXED_ART) || o_ptr->name1)
105 for (int i = 0; i < rolls; i++) {
106 if (make_artifact(player_ptr, o_ptr))
108 if (has_good_luck(player_ptr) && one_in_(77)) {
109 if (make_artifact(player_ptr, o_ptr))
114 if (o_ptr->is_fixed_artifact()) {
115 artifact_type *a_ptr = apply_artifact(player_ptr, o_ptr);
117 if (w_ptr->character_dungeon)
118 a_ptr->floor_id = player_ptr->floor_id;
122 // @todo ファクトリパターンで抽象化する.
123 switch (o_ptr->tval) {
124 case ItemKindType::DIGGING:
125 case ItemKindType::HAFTED:
126 case ItemKindType::BOW:
127 case ItemKindType::SHOT:
128 case ItemKindType::ARROW:
129 case ItemKindType::BOLT:
131 WeaponEnchanter(player_ptr, o_ptr, lev, power).apply_magic();
135 case ItemKindType::POLEARM:
136 if ((power != 0) && (o_ptr->sval != SV_DEATH_SCYTHE)) {
137 WeaponEnchanter(player_ptr, o_ptr, lev, power).apply_magic();
141 case ItemKindType::SWORD:
142 if ((power != 0) && (o_ptr->sval != SV_POISON_NEEDLE)) {
143 WeaponEnchanter(player_ptr, o_ptr, lev, power).apply_magic();
147 case ItemKindType::SHIELD:
148 ShieldEnchanter(player_ptr, o_ptr, lev, power).apply_magic();
150 case ItemKindType::CLOAK:
151 CloakEnchanter(player_ptr, o_ptr, lev, power).apply_magic();
153 case ItemKindType::HELM:
154 HelmEnchanter(player_ptr, o_ptr, lev, power).apply_magic();
156 case ItemKindType::CROWN:
157 CrownEnchanter(player_ptr, o_ptr, lev, power).apply_magic();
159 case ItemKindType::BOOTS:
160 BootsEnchanter(player_ptr, o_ptr, lev, power).apply_magic();
162 case ItemKindType::DRAG_ARMOR:
163 case ItemKindType::HARD_ARMOR:
164 case ItemKindType::SOFT_ARMOR:
165 ArmorEnchanter(player_ptr, o_ptr, lev, power).apply_magic();
167 case ItemKindType::GLOVES:
168 GlovesEnchanter(player_ptr, o_ptr, lev, power).apply_magic();
170 case ItemKindType::RING:
171 RingEnchanter(player_ptr, o_ptr, lev, power).apply_magic();
173 case ItemKindType::AMULET:
174 AmuletEnchanter(player_ptr, o_ptr, lev, power).apply_magic();
177 apply_magic_others(player_ptr, o_ptr, power);
181 if ((o_ptr->tval == ItemKindType::SOFT_ARMOR) && (o_ptr->sval == SV_ABUNAI_MIZUGI) && (player_ptr->ppersonality == PERSONALITY_SEXY)) {
183 o_ptr->art_flags.set(TR_STR);
184 o_ptr->art_flags.set(TR_INT);
185 o_ptr->art_flags.set(TR_WIS);
186 o_ptr->art_flags.set(TR_DEX);
187 o_ptr->art_flags.set(TR_CON);
188 o_ptr->art_flags.set(TR_CHR);
191 if (o_ptr->is_ego()) {
192 apply_ego(o_ptr, lev);
197 object_kind *k_ptr = &k_info[o_ptr->k_idx];
198 if (!k_info[o_ptr->k_idx].cost)
199 o_ptr->ident |= (IDENT_BROKEN);
201 if (k_ptr->gen_flags.has(ItemGenerationTraitType::CURSED))
202 o_ptr->curse_flags.set(CurseTraitType::CURSED);
203 if (k_ptr->gen_flags.has(ItemGenerationTraitType::HEAVY_CURSE))
204 o_ptr->curse_flags.set(CurseTraitType::HEAVY_CURSE);
205 if (k_ptr->gen_flags.has(ItemGenerationTraitType::PERMA_CURSE))
206 o_ptr->curse_flags.set(CurseTraitType::PERMA_CURSE);
207 if (k_ptr->gen_flags.has(ItemGenerationTraitType::RANDOM_CURSE0))
208 o_ptr->curse_flags.set(get_curse(0, o_ptr));
209 if (k_ptr->gen_flags.has(ItemGenerationTraitType::RANDOM_CURSE1))
210 o_ptr->curse_flags.set(get_curse(1, o_ptr));
211 if (k_ptr->gen_flags.has(ItemGenerationTraitType::RANDOM_CURSE2))
212 o_ptr->curse_flags.set(get_curse(2, o_ptr));