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 auto *floor_ptr = this->player_ptr->current_floor_ptr;
49 switch (this->o_ptr->tval) {
50 case ItemKindType::FLASK:
51 this->o_ptr->fuel = this->o_ptr->pval;
52 this->o_ptr->pval = 0;
54 case ItemKindType::WAND:
55 case ItemKindType::STAFF:
56 this->enchant_wand_staff();
58 case ItemKindType::ROD:
59 this->o_ptr->pval = k_info[this->o_ptr->k_idx].pval;
61 case ItemKindType::CAPTURE:
62 this->o_ptr->pval = 0;
63 object_aware(this->player_ptr, this->o_ptr);
64 object_known(this->o_ptr);
66 case ItemKindType::FIGURINE:
67 this->enchant_figurine();
69 case ItemKindType::CORPSE: {
70 PARAMETER_VALUE i = 1;
74 if (this->o_ptr->sval == SV_SKELETON) {
75 match = RF9_DROP_SKELETON;
76 } else if (this->o_ptr->sval == SV_CORPSE) {
77 match = RF9_DROP_CORPSE;
80 get_mon_num_prep(this->player_ptr, item_monster_okay, nullptr);
82 i = get_mon_num(this->player_ptr, 0, floor_ptr->dun_level, 0);
84 check = (floor_ptr->dun_level < r_ptr->level) ? (r_ptr->level - floor_ptr->dun_level) : 0;
87 if (!(r_ptr->flags9 & match))
95 this->o_ptr->pval = i;
96 object_aware(this->player_ptr, this->o_ptr);
97 object_known(this->o_ptr);
100 case ItemKindType::STATUE: {
101 PARAMETER_VALUE i = 1;
104 i = randint1(r_info.size() - 1);
112 this->o_ptr->pval = i;
114 msg_format(_("%sの像", "Statue of %s"), r_ptr->name.c_str());
117 object_aware(this->player_ptr, this->o_ptr);
118 object_known(this->o_ptr);
121 case ItemKindType::CHEST: {
122 DEPTH obj_level = k_info[this->o_ptr->k_idx].level;
126 this->o_ptr->pval = randint1(obj_level);
127 if (this->o_ptr->sval == SV_CHEST_KANDUME)
128 this->o_ptr->pval = 6;
130 this->o_ptr->chest_level = floor_ptr->dun_level + 5;
131 if (this->o_ptr->pval > 55)
132 this->o_ptr->pval = 55 + (byte)randint0(5);
143 * The wand or staff gets a number of initial charges equal
144 * to between 1/2 (+1) and the full object kind's pval.
146 void OtherItemsEnchanter::enchant_wand_staff()
148 auto *k_ptr = &k_info[this->o_ptr->k_idx];
149 this->o_ptr->pval = k_ptr->pval / 2 + randint1((k_ptr->pval + 1) / 2);
152 void OtherItemsEnchanter::enchant_figurine()
154 auto *floor_ptr = this->player_ptr->current_floor_ptr;
158 r_idx = randint1(r_info.size() - 1);
159 if (!item_monster_okay(this->player_ptr, r_idx) || (r_idx == MON_TSUCHINOKO)) {
163 auto *r_ptr = &r_info[r_idx];
164 auto check = (floor_ptr->dun_level < r_ptr->level) ? (r_ptr->level - floor_ptr->dun_level) : 0;
165 if ((r_ptr->rarity == 0) || (r_ptr->rarity > 100) || (randint0(check) > 0)) {
172 this->o_ptr->pval = r_idx;
174 this->o_ptr->curse_flags.set(CurseTraitType::CURSED);