1 #include "mind/mind-priest.h"
2 #include "core/window-redrawer.h"
3 #include "flavor/flavor-describer.h"
4 #include "flavor/object-flavor-types.h"
5 #include "floor/floor-object.h"
6 #include "object-enchant/item-feeling.h"
7 #include "object-enchant/special-object-flags.h"
8 #include "object-enchant/tr-types.h"
9 #include "object-enchant/trc-types.h"
10 #include "object-hook/hook-weapon.h"
11 #include "object/item-tester-hooker.h"
12 #include "object/item-use-flags.h"
13 #include "object/object-flags.h"
14 #include "racial/racial-android.h"
15 #include "system/item-entity.h"
16 #include "system/player-type-definition.h"
17 #include "system/redrawing-flags-updater.h"
18 #include "util/bit-flags-calculator.h"
19 #include "view/display-messages.h"
24 * @return ターン消費を要する処理を行ったならばTRUEを返す
26 bool bless_weapon(PlayerType *player_ptr)
28 concptr q = _("どのアイテムを祝福しますか?", "Bless which weapon? ");
29 concptr s = _("祝福できる武器がありません。", "You have no weapon to bless.");
32 constexpr BIT_FLAGS options = USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT;
33 auto *o_ptr = choose_object(player_ptr, &item, q, s, options, FuncItemTester(&ItemEntity::is_weapon));
38 const auto item_name = describe_flavor(player_ptr, o_ptr, OD_OMIT_PREFIX | OD_NAME_ONLY);
39 auto flags = object_flags(o_ptr);
40 auto &rfu = RedrawingFlagsUpdater::get_instance();
41 if (o_ptr->is_cursed()) {
42 auto can_disturb_blessing = o_ptr->curse_flags.has(CurseTraitType::HEAVY_CURSE) && (randint1(100) < 33);
43 can_disturb_blessing |= flags.has(TR_ADD_L_CURSE);
44 can_disturb_blessing |= flags.has(TR_ADD_H_CURSE);
45 can_disturb_blessing |= o_ptr->curse_flags.has(CurseTraitType::PERSISTENT_CURSE);
46 can_disturb_blessing |= o_ptr->curse_flags.has(CurseTraitType::PERMA_CURSE);
47 if (can_disturb_blessing) {
49 msg_format("%sを覆う黒いオーラは祝福を跳ね返した!", item_name.data());
51 msg_format("The black aura on %s %s disrupts the blessing!", ((item >= 0) ? "your" : "the"), item_name.data());
58 msg_format("%s から邪悪なオーラが消えた。", item_name.data());
60 msg_format("A malignant aura leaves %s %s.", ((item >= 0) ? "your" : "the"), item_name.data());
62 o_ptr->curse_flags.clear();
63 set_bits(o_ptr->ident, IDENT_SENSE);
64 o_ptr->feeling = FEEL_NONE;
65 rfu.set_flag(StatusRedrawingFlag::BONUS);
66 set_bits(player_ptr->window_flags, PW_EQUIPMENT | PW_FLOOR_ITEMS | PW_FOUND_ITEMS);
70 * Next, we try to bless it. Artifacts have a 1/3 chance of
71 * being blessed, otherwise, the operation simply disenchants
72 * them, godly power negating the magic. Ok, the explanation
73 * is silly, but otherwise priests would always bless every
74 * artifact weapon they find. Ego weapons and normal weapons
75 * can be blessed automatically.
77 if (flags.has(TR_BLESSED)) {
79 msg_format("%s は既に祝福されている。", item_name.data());
81 msg_format("%s %s %s blessed already.", ((item >= 0) ? "Your" : "The"), item_name.data(), ((o_ptr->number > 1) ? "were" : "was"));
86 if (!(o_ptr->is_fixed_or_random_artifact() || o_ptr->is_ego()) || one_in_(3)) {
88 msg_format("%sは輝いた!", item_name.data());
90 msg_format("%s %s shine%s!", ((item >= 0) ? "Your" : "The"), item_name.data(), ((o_ptr->number > 1) ? "" : "s"));
92 o_ptr->art_flags.set(TR_BLESSED);
95 bool dis_happened = false;
96 msg_print(_("その武器は祝福を嫌っている!", "The weapon resists your blessing!"));
98 /* Disenchant tohit */
99 if (o_ptr->to_h > 0) {
104 if ((o_ptr->to_h > 5) && (randint0(100) < 33)) {
108 /* Disenchant todam */
109 if (o_ptr->to_d > 0) {
114 if ((o_ptr->to_d > 5) && (randint0(100) < 33)) {
118 /* Disenchant toac */
119 if (o_ptr->to_a > 0) {
124 if ((o_ptr->to_a > 5) && (randint0(100) < 33)) {
129 msg_print(_("周囲が凡庸な雰囲気で満ちた...", "There is a static feeling in the air..."));
132 msg_format("%s は劣化した!", item_name.data());
134 msg_format("%s %s %s disenchanted!", ((item >= 0) ? "Your" : "The"), item_name.data(), ((o_ptr->number > 1) ? "were" : "was"));
139 rfu.set_flag(StatusRedrawingFlag::BONUS);
140 set_bits(player_ptr->window_flags, PW_EQUIPMENT | PW_PLAYER | PW_FLOOR_ITEMS | PW_FOUND_ITEMS);
141 calc_android_exp(player_ptr);