1 #include "object-enchant/object-curse.h"
2 #include "flavor/flavor-describer.h"
3 #include "flavor/object-flavor-types.h"
4 #include "inventory/inventory-slot-types.h"
5 #include "object-enchant/item-feeling.h"
6 #include "object-enchant/tr-types.h"
7 #include "object-enchant/trc-types.h"
8 #include "object-hook/hook-armor.h"
9 #include "object-hook/hook-weapon.h"
10 #include "object/object-flags.h"
11 #include "system/item-entity.h"
12 #include "system/player-type-definition.h"
13 #include "system/redrawing-flags-updater.h"
14 #include "util/bit-flags-calculator.h"
15 #include "util/enum-converter.h"
16 #include "view/display-messages.h"
19 const EnumClassFlagGroup<CurseTraitType> TRC_SPECIAL_MASK({ CurseTraitType::TY_CURSE, CurseTraitType::AGGRAVATE });
20 const EnumClassFlagGroup<CurseTraitType> TRC_HEAVY_MASK({ CurseTraitType::TY_CURSE, CurseTraitType::AGGRAVATE, CurseTraitType::DRAIN_EXP, CurseTraitType::ADD_H_CURSE, CurseTraitType::CALL_DEMON, CurseTraitType::CALL_DRAGON, CurseTraitType::CALL_UNDEAD, CurseTraitType::TELEPORT });
24 * @brief アイテムに付加される可能性のある呪いを指定する。
26 * @param o_ptr 呪いをかけられる装備オブジェクトの構造体参照ポインタ
29 CurseTraitType get_curse(int power, ItemEntity *o_ptr)
31 CurseTraitType new_curse;
34 new_curse = i2enum<CurseTraitType>(rand_range(enum2i(CurseTraitType::TY_CURSE), enum2i(CurseTraitType::MAX) - 1));
36 if (TRC_HEAVY_MASK.has_not(new_curse)) {
39 } else if (power == 1) {
40 if (TRC_SPECIAL_MASK.has(new_curse)) {
43 } else if (power == 0) {
44 if (TRC_HEAVY_MASK.has(new_curse)) {
49 if (new_curse == CurseTraitType::LOW_MELEE && !o_ptr->is_weapon()) {
52 if (new_curse == CurseTraitType::LOW_AC && !o_ptr->is_protector()) {
62 * @brief 装備への呪い付加判定と付加処理
63 * @param player_ptr プレイヤーへの参照ポインタ
64 * @param chance 呪いの基本確率
65 * @param heavy_chance さらに重い呪いとなる確率
67 void curse_equipment(PlayerType *player_ptr, PERCENTAGE chance, PERCENTAGE heavy_chance)
69 if (randint1(100) > chance) {
73 auto *o_ptr = &player_ptr->inventory_list[INVEN_MAIN_HAND + randint0(12)];
74 if (!o_ptr->is_valid()) {
78 auto oflags = object_flags(o_ptr);
79 const auto item_name = describe_flavor(player_ptr, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
81 /* Extra, biased saving throw for blessed items */
82 if (oflags.has(TR_BLESSED)) {
84 msg_format("祝福された%sは呪いを跳ね返した!", item_name.data());
86 msg_format("Your blessed %s resist%s cursing!", item_name.data(), ((o_ptr->number > 1) ? "" : "s"));
88 /* Hmmm -- can we wear multiple items? If not, this is unnecessary */
94 if ((randint1(100) <= heavy_chance) && (o_ptr->is_fixed_or_random_artifact() || o_ptr->is_ego())) {
95 if (o_ptr->curse_flags.has_not(CurseTraitType::HEAVY_CURSE)) {
98 o_ptr->curse_flags.set(CurseTraitType::HEAVY_CURSE);
99 o_ptr->curse_flags.set(CurseTraitType::CURSED);
102 if (!o_ptr->is_cursed()) {
105 o_ptr->curse_flags.set(CurseTraitType::CURSED);
108 if (heavy_chance >= 50) {
112 auto new_curse = get_curse(curse_power, o_ptr);
113 if (o_ptr->curse_flags.has_not(new_curse)) {
115 o_ptr->curse_flags.set(new_curse);
119 msg_format(_("悪意に満ちた黒いオーラが%sをとりまいた...", "There is a malignant black aura surrounding %s..."), item_name.data());
120 o_ptr->feeling = FEEL_NONE;
123 RedrawingFlagsUpdater::get_instance().set_flag(StatusRecalculatingFlag::BONUS);