1 #include "object-enchant/object-curse.h"
2 #include "core/player-update-types.h"
3 #include "flavor/flavor-describer.h"
4 #include "flavor/object-flavor-types.h"
5 #include "inventory/inventory-slot-types.h"
6 #include "object-enchant/item-feeling.h"
7 #include "object-enchant/tr-types.h"
8 #include "object-enchant/trc-types.h"
9 #include "object-hook/hook-armor.h"
10 #include "object-hook/hook-checker.h"
11 #include "object-hook/hook-enchant.h"
12 #include "object-hook/hook-weapon.h"
13 #include "object/object-flags.h"
14 #include "util/bit-flags-calculator.h"
15 #include "view/display-messages.h"
18 #define TRC_SPECIAL_MASK (TRC_TY_CURSE | TRC_AGGRAVATE)
19 #define TRC_HEAVY_MASK (TRC_TY_CURSE | TRC_AGGRAVATE | TRC_DRAIN_EXP | TRC_ADD_H_CURSE | TRC_CALL_DEMON | TRC_CALL_DRAGON | TRC_CALL_UNDEAD | TRC_TELEPORT)
22 * @brief アイテムに付加される可能性のある呪いを指定する。
24 * @param o_ptr 呪いをかけられる装備オブジェクトの構造体参照ポインタ
27 BIT_FLAGS get_curse(player_type *owner_ptr, int power, object_type *o_ptr)
32 new_curse = (1 << (randint0(MAX_CURSE) + 4));
34 if (!(new_curse & TRC_HEAVY_MASK))
36 } else if (power == 1) {
37 if (new_curse & TRC_SPECIAL_MASK)
39 } else if (power == 0) {
40 if (new_curse & TRC_HEAVY_MASK)
44 if (new_curse == TRC_LOW_MELEE && !object_is_weapon(owner_ptr, o_ptr))
46 if (new_curse == TRC_LOW_AC && !object_is_armour(owner_ptr, o_ptr))
55 * @brief 装備への呪い付加判定と付加処理
56 * @param owner_ptr プレーヤーへの参照ポインタ
57 * @param chance 呪いの基本確率
58 * @param heavy_chance さらに重い呪いとなる確率
61 void curse_equipment(player_type *owner_ptr, PERCENTAGE chance, PERCENTAGE heavy_chance)
63 if (randint1(100) > chance)
66 object_type *o_ptr = &owner_ptr->inventory_list[INVEN_RARM + randint0(12)];
69 BIT_FLAGS oflgs[TR_FLAG_SIZE];
70 object_flags(owner_ptr, o_ptr, oflgs);
71 GAME_TEXT o_name[MAX_NLEN];
72 describe_flavor(owner_ptr, o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
74 /* Extra, biased saving throw for blessed items */
75 if (has_flag(oflgs, TR_BLESSED)) {
77 msg_format("祝福された%sは呪いを跳ね返した!", o_name);
79 msg_format("Your blessed %s resist%s cursing!", o_name, ((o_ptr->number > 1) ? "" : "s"));
81 /* Hmmm -- can we wear multiple items? If not, this is unnecessary */
87 if ((randint1(100) <= heavy_chance) && (object_is_artifact(o_ptr) || object_is_ego(o_ptr))) {
88 if (!(o_ptr->curse_flags & TRC_HEAVY_CURSE))
90 o_ptr->curse_flags |= TRC_HEAVY_CURSE;
91 o_ptr->curse_flags |= TRC_CURSED;
94 if (!object_is_cursed(o_ptr))
96 o_ptr->curse_flags |= TRC_CURSED;
99 if (heavy_chance >= 50)
102 BIT_FLAGS new_curse = get_curse(owner_ptr, curse_power, o_ptr);
103 if (!(o_ptr->curse_flags & new_curse)) {
105 o_ptr->curse_flags |= new_curse;
109 msg_format(_("悪意に満ちた黒いオーラが%sをとりまいた...", "There is a malignant black aura surrounding %s..."), o_name);
110 o_ptr->feeling = FEEL_NONE;
113 owner_ptr->update |= PU_BONUS;