2 * @brief 防具系のアイテムを強化して(恐らく床に)生成する処理
8 #include "object-enchant/others/apply-magic-others.h"
9 #include "artifact/random-art-generator.h"
10 #include "game-option/cheat-options.h"
11 #include "inventory/inventory-slot-types.h"
12 #include "monster-race/monster-race-hook.h"
13 #include "monster-race/monster-race.h"
14 #include "monster-race/race-flags9.h"
15 #include "monster-race/race-indice-types.h"
16 #include "monster/monster-list.h"
17 #include "monster/monster-util.h"
18 #include "object-enchant/object-ego.h"
19 #include "object-enchant/tr-types.h"
20 #include "object-enchant/trc-types.h"
21 #include "object/object-kind.h"
22 #include "perception/object-perception.h"
23 #include "sv-definition/sv-lite-types.h"
24 #include "sv-definition/sv-other-types.h"
25 #include "system/floor-type-definition.h"
26 #include "system/monster-race-definition.h"
27 #include "system/object-type-definition.h"
28 #include "system/player-type-definition.h"
29 #include "util/bit-flags-calculator.h"
30 #include "view/display-messages.h"
32 OtherItemsEnchanter::OtherItemsEnchanter(PlayerType *player_ptr, ObjectType *o_ptr)
33 : player_ptr(player_ptr)
39 * @brief その他雑多のオブジェクトに生成ランクごとの強化を与えるサブルーチン
40 * Apply magic to an item known to be "boring"
41 * @param player_ptr プレイヤーへの参照ポインタ
42 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
44 * @details power > 2はデバッグ専用.
46 void OtherItemsEnchanter::apply_magic()
48 switch (this->o_ptr->tval) {
49 case ItemKindType::FLASK:
50 this->o_ptr->fuel = this->o_ptr->pval;
51 this->o_ptr->pval = 0;
53 case ItemKindType::WAND:
54 case ItemKindType::STAFF:
55 this->enchant_wand_staff();
57 case ItemKindType::ROD:
58 this->o_ptr->pval = k_info[this->o_ptr->k_idx].pval;
60 case ItemKindType::CAPTURE:
61 this->o_ptr->pval = 0;
62 object_aware(this->player_ptr, this->o_ptr);
63 object_known(this->o_ptr);
65 case ItemKindType::FIGURINE:
66 this->enchant_figurine();
68 case ItemKindType::CORPSE:
69 this->enchant_corpse();
71 case ItemKindType::STATUE:
72 this->enchant_statue();
74 case ItemKindType::CHEST:
75 this->enchant_chest();
84 * The wand or staff gets a number of initial charges equal
85 * to between 1/2 (+1) and the full object kind's pval.
87 void OtherItemsEnchanter::enchant_wand_staff()
89 auto *k_ptr = &k_info[this->o_ptr->k_idx];
90 this->o_ptr->pval = k_ptr->pval / 2 + randint1((k_ptr->pval + 1) / 2);
93 void OtherItemsEnchanter::enchant_figurine()
95 auto *floor_ptr = this->player_ptr->current_floor_ptr;
99 r_idx = randint1(r_info.size() - 1);
100 if (!item_monster_okay(this->player_ptr, r_idx) || (r_idx == MON_TSUCHINOKO)) {
104 auto *r_ptr = &r_info[r_idx];
105 auto check = (floor_ptr->dun_level < r_ptr->level) ? (r_ptr->level - floor_ptr->dun_level) : 0;
106 if ((r_ptr->rarity == 0) || (r_ptr->rarity > 100) || (randint0(check) > 0)) {
113 this->o_ptr->pval = r_idx;
115 this->o_ptr->curse_flags.set(CurseTraitType::CURSED);
119 void OtherItemsEnchanter::enchant_corpse()
122 if (this->o_ptr->sval == SV_SKELETON) {
123 match = RF9_DROP_SKELETON;
124 } else if (this->o_ptr->sval == SV_CORPSE) {
125 match = RF9_DROP_CORPSE;
128 get_mon_num_prep(this->player_ptr, item_monster_okay, nullptr);
129 auto *floor_ptr = this->player_ptr->current_floor_ptr;
132 r_idx = get_mon_num(this->player_ptr, 0, floor_ptr->dun_level, 0);
133 auto *r_ptr = &r_info[r_idx];
134 auto check = (floor_ptr->dun_level < r_ptr->level) ? (r_ptr->level - floor_ptr->dun_level) : 0;
135 if ((r_ptr->rarity == 0) || none_bits(r_ptr->flags9, match) || (randint0(check) > 0)) {
142 this->o_ptr->pval = r_idx;
143 object_aware(this->player_ptr, this->o_ptr);
144 object_known(this->o_ptr);
147 void OtherItemsEnchanter::enchant_statue()
150 auto &r_ref = r_info[0];
152 r_idx = randint1(r_info.size() - 1);
153 r_ref = r_info[r_idx];
154 if (r_ref.rarity == 0) {
161 this->o_ptr->pval = r_idx;
163 msg_format(_("%sの像", "Statue of %s"), r_ref.name.c_str());
166 object_aware(this->player_ptr, this->o_ptr);
167 object_known(this->o_ptr);
170 void OtherItemsEnchanter::enchant_chest()
172 auto obj_level = k_info[this->o_ptr->k_idx].level;
173 if (obj_level <= 0) {
177 this->o_ptr->pval = randint1(obj_level);
178 if (this->o_ptr->sval == SV_CHEST_KANDUME) {
179 this->o_ptr->pval = 6;
182 this->o_ptr->chest_level = this->player_ptr->current_floor_ptr->dun_level + 5;
183 if (this->o_ptr->pval > 55) {
184 this->o_ptr->pval = 55 + randint0(5);