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"
33 * @brief その他雑多のオブジェクトに生成ランクごとの強化を与えるサブルーチン
34 * Apply magic to an item known to be "boring"
35 * @param player_ptr プレイヤーへの参照ポインタ
36 * @param o_ptr 強化を与えたいオブジェクトの構造体参照ポインタ
38 * @details power > 2はデバッグ専用.
40 void apply_magic_others(PlayerType *player_ptr, object_type *o_ptr, int power)
42 object_kind *k_ptr = &k_info[o_ptr->k_idx];
44 floor_type *floor_ptr = player_ptr->current_floor_ptr;
45 switch (o_ptr->tval) {
46 case ItemKindType::WHISTLE: {
49 case ItemKindType::FLASK: {
50 o_ptr->xtra4 = o_ptr->pval;
54 case ItemKindType::LITE: {
55 if (o_ptr->sval == SV_LITE_TORCH) {
57 o_ptr->xtra4 = randint1(o_ptr->pval);
61 if (o_ptr->sval == SV_LITE_LANTERN) {
63 o_ptr->xtra4 = randint1(o_ptr->pval);
68 become_random_artifact(player_ptr, o_ptr, false);
69 } else if ((power == 2) || ((power == 1) && one_in_(3))) {
70 while (!o_ptr->name2) {
72 bool okay_flag = true;
74 o_ptr->name2 = get_random_ego(INVEN_LITE, true);
76 switch (o_ptr->name2) {
78 if (o_ptr->sval == SV_LITE_FEANOR)
86 } else if (power == -2) {
87 o_ptr->name2 = get_random_ego(INVEN_LITE, false);
88 switch (o_ptr->name2) {
89 case EGO_LITE_DARKNESS:
92 if (o_ptr->sval == SV_LITE_TORCH) {
93 o_ptr->art_flags.set(TR_LITE_M1);
94 } else if (o_ptr->sval == SV_LITE_LANTERN) {
95 o_ptr->art_flags.set(TR_LITE_M2);
96 } else if (o_ptr->sval == SV_LITE_FEANOR) {
97 o_ptr->art_flags.set(TR_LITE_M3);
105 case ItemKindType::WAND:
106 case ItemKindType::STAFF: {
107 /* The wand or staff gets a number of initial charges equal
108 * to between 1/2 (+1) and the full object kind's pval. -LM-
110 o_ptr->pval = k_ptr->pval / 2 + randint1((k_ptr->pval + 1) / 2);
113 case ItemKindType::ROD: {
114 o_ptr->pval = k_ptr->pval;
117 case ItemKindType::CAPTURE: {
119 object_aware(player_ptr, o_ptr);
123 case ItemKindType::FIGURINE: {
124 PARAMETER_VALUE i = 1;
128 i = randint1(r_info.size() - 1);
130 if (!item_monster_okay(player_ptr, i))
132 if (i == MON_TSUCHINOKO)
136 check = (floor_ptr->dun_level < r_ptr->level) ? (r_ptr->level - floor_ptr->dun_level) : 0;
139 if (r_ptr->rarity > 100)
149 o_ptr->curse_flags.set(CurseTraitType::CURSED);
153 case ItemKindType::CORPSE: {
154 PARAMETER_VALUE i = 1;
158 if (o_ptr->sval == SV_SKELETON) {
159 match = RF9_DROP_SKELETON;
160 } else if (o_ptr->sval == SV_CORPSE) {
161 match = RF9_DROP_CORPSE;
164 get_mon_num_prep(player_ptr, item_monster_okay, nullptr);
166 i = get_mon_num(player_ptr, 0, floor_ptr->dun_level, 0);
168 check = (floor_ptr->dun_level < r_ptr->level) ? (r_ptr->level - floor_ptr->dun_level) : 0;
171 if (!(r_ptr->flags9 & match))
180 object_aware(player_ptr, o_ptr);
184 case ItemKindType::STATUE: {
185 PARAMETER_VALUE i = 1;
188 i = randint1(r_info.size() - 1);
198 msg_format(_("%sの像", "Statue of %s"), r_ptr->name.c_str());
201 object_aware(player_ptr, o_ptr);
205 case ItemKindType::CHEST: {
206 DEPTH obj_level = k_info[o_ptr->k_idx].level;
210 o_ptr->pval = randint1(obj_level);
211 if (o_ptr->sval == SV_CHEST_KANDUME)
214 o_ptr->xtra3 = floor_ptr->dun_level + 5;
215 if (o_ptr->pval > 55)
216 o_ptr->pval = 55 + (byte)randint0(5);