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 強化を与えたいオブジェクトの構造体参照ポインタ
39 * Hack -- note the special code for various items
41 void apply_magic_others(PlayerType *player_ptr, object_type *o_ptr, int power)
43 object_kind *k_ptr = &k_info[o_ptr->k_idx];
45 floor_type *floor_ptr = player_ptr->current_floor_ptr;
46 switch (o_ptr->tval) {
47 case ItemKindType::WHISTLE: {
50 case ItemKindType::FLASK: {
51 o_ptr->xtra4 = o_ptr->pval;
55 case ItemKindType::LITE: {
56 if (o_ptr->sval == SV_LITE_TORCH) {
58 o_ptr->xtra4 = randint1(o_ptr->pval);
62 if (o_ptr->sval == SV_LITE_LANTERN) {
64 o_ptr->xtra4 = randint1(o_ptr->pval);
68 /* power > 2はデバッグ専用. */
70 become_random_artifact(player_ptr, o_ptr, false);
71 } else if ((power == 2) || ((power == 1) && one_in_(3))) {
72 while (!o_ptr->name2) {
74 bool okay_flag = true;
76 o_ptr->name2 = get_random_ego(INVEN_LITE, true);
78 switch (o_ptr->name2) {
80 if (o_ptr->sval == SV_LITE_FEANOR)
88 } else if (power == -2) {
89 o_ptr->name2 = get_random_ego(INVEN_LITE, false);
90 switch (o_ptr->name2) {
91 case EGO_LITE_DARKNESS:
94 if (o_ptr->sval == SV_LITE_TORCH) {
95 o_ptr->art_flags.set(TR_LITE_M1);
96 } else if (o_ptr->sval == SV_LITE_LANTERN) {
97 o_ptr->art_flags.set(TR_LITE_M2);
98 } else if (o_ptr->sval == SV_LITE_FEANOR) {
99 o_ptr->art_flags.set(TR_LITE_M3);
107 case ItemKindType::WAND:
108 case ItemKindType::STAFF: {
109 /* The wand or staff gets a number of initial charges equal
110 * to between 1/2 (+1) and the full object kind's pval. -LM-
112 o_ptr->pval = k_ptr->pval / 2 + randint1((k_ptr->pval + 1) / 2);
115 case ItemKindType::ROD: {
116 o_ptr->pval = k_ptr->pval;
119 case ItemKindType::CAPTURE: {
121 object_aware(player_ptr, o_ptr);
125 case ItemKindType::FIGURINE: {
126 PARAMETER_VALUE i = 1;
130 i = randint1(r_info.size() - 1);
132 if (!item_monster_okay(player_ptr, i))
134 if (i == MON_TSUCHINOKO)
138 check = (floor_ptr->dun_level < r_ptr->level) ? (r_ptr->level - floor_ptr->dun_level) : 0;
141 if (r_ptr->rarity > 100)
151 o_ptr->curse_flags.set(CurseTraitType::CURSED);
155 case ItemKindType::CORPSE: {
156 PARAMETER_VALUE i = 1;
160 if (o_ptr->sval == SV_SKELETON) {
161 match = RF9_DROP_SKELETON;
162 } else if (o_ptr->sval == SV_CORPSE) {
163 match = RF9_DROP_CORPSE;
166 get_mon_num_prep(player_ptr, item_monster_okay, nullptr);
168 i = get_mon_num(player_ptr, 0, floor_ptr->dun_level, 0);
170 check = (floor_ptr->dun_level < r_ptr->level) ? (r_ptr->level - floor_ptr->dun_level) : 0;
173 if (!(r_ptr->flags9 & match))
182 object_aware(player_ptr, o_ptr);
186 case ItemKindType::STATUE: {
187 PARAMETER_VALUE i = 1;
190 i = randint1(r_info.size() - 1);
200 msg_format(_("%sの像", "Statue of %s"), r_ptr->name.c_str());
203 object_aware(player_ptr, o_ptr);
207 case ItemKindType::CHEST: {
208 DEPTH obj_level = k_info[o_ptr->k_idx].level;
212 o_ptr->pval = randint1(obj_level);
213 if (o_ptr->sval == SV_CHEST_KANDUME)
216 o_ptr->xtra3 = floor_ptr->dun_level + 5;
217 if (o_ptr->pval > 55)
218 o_ptr->pval = 55 + (byte)randint0(5);