OSDN Git Service

99048ff4b6290a7b54e8ea3f40ef6f1ac90801e2
[hengbandforosx/hengbandosx.git] / src / mind / mind-priest.c
1 #include "mind/mind-priest.h"
2 #include "core/player-update-types.h"
3 #include "core/window-redrawer.h"
4 #include "flavor/flavor-describer.h"
5 #include "flavor/object-flavor-types.h"
6 #include "floor/floor-object.h"
7 #include "object-enchant/item-feeling.h"
8 #include "object-enchant/special-object-flags.h"
9 #include "object-enchant/trc-types.h"
10 #include "object-enchant/tr-types.h"
11 #include "object-hook/hook-checker.h"
12 #include "object-hook/hook-enchant.h"
13 #include "object-hook/hook-weapon.h"
14 #include "object/item-tester-hooker.h"
15 #include "object/item-use-flags.h"
16 #include "object/object-flags.h"
17 #include "racial/racial-android.h"
18 #include "system/object-type-definition.h"
19 #include "util/bit-flags-calculator.h"
20 #include "view/display-messages.h"
21
22 /*!
23  * @brief 武器の祝福処理 /
24  * Bless a weapon
25  * @return ターン消費を要する処理を行ったならばTRUEを返す
26  */
27 bool bless_weapon(player_type *caster_ptr)
28 {
29     item_tester_hook = object_is_weapon;
30
31     concptr q = _("どのアイテムを祝福しますか?", "Bless which weapon? ");
32     concptr s = _("祝福できる武器がありません。", "You have weapon to bless.");
33
34     OBJECT_IDX item;
35     object_type *o_ptr = choose_object(caster_ptr, &item, q, s, USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT, 0);
36     if (!o_ptr)
37         return FALSE;
38
39     GAME_TEXT o_name[MAX_NLEN];
40     describe_flavor(caster_ptr, o_name, o_ptr, OD_OMIT_PREFIX | OD_NAME_ONLY);
41     BIT_FLAGS flgs[TR_FLAG_SIZE];
42     object_flags(caster_ptr, o_ptr, flgs);
43
44     if (object_is_cursed(o_ptr)) {
45         if (((o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint1(100) < 33)) || has_flag(flgs, TR_ADD_L_CURSE) || has_flag(flgs, TR_ADD_H_CURSE)
46             || (o_ptr->curse_flags & TRC_PERMA_CURSE)) {
47 #ifdef JP
48             msg_format("%sを覆う黒いオーラは祝福を跳ね返した!", o_name);
49 #else
50             msg_format("The black aura on %s %s disrupts the blessing!", ((item >= 0) ? "your" : "the"), o_name);
51 #endif
52
53             return TRUE;
54         }
55
56 #ifdef JP
57         msg_format("%s から邪悪なオーラが消えた。", o_name);
58 #else
59         msg_format("A malignant aura leaves %s %s.", ((item >= 0) ? "your" : "the"), o_name);
60 #endif
61         o_ptr->curse_flags = 0L;
62         o_ptr->ident |= IDENT_SENSE;
63         o_ptr->feeling = FEEL_NONE;
64         caster_ptr->update |= PU_BONUS;
65         caster_ptr->window_flags |= PW_EQUIP;
66     }
67
68     /*
69      * Next, we try to bless it. Artifacts have a 1/3 chance of
70      * being blessed, otherwise, the operation simply disenchants
71      * them, godly power negating the magic. Ok, the explanation
72      * is silly, but otherwise priests would always bless every
73      * artifact weapon they find. Ego weapons and normal weapons
74      * can be blessed automatically.
75      */
76     if (has_flag(flgs, TR_BLESSED)) {
77 #ifdef JP
78         msg_format("%s は既に祝福されている。", o_name);
79 #else
80         msg_format("%s %s %s blessed already.", ((item >= 0) ? "Your" : "The"), o_name, ((o_ptr->number > 1) ? "were" : "was"));
81 #endif
82         return TRUE;
83     }
84
85     if (!(object_is_artifact(o_ptr) || object_is_ego(o_ptr)) || one_in_(3)) {
86 #ifdef JP
87         msg_format("%sは輝いた!", o_name);
88 #else
89         msg_format("%s %s shine%s!", ((item >= 0) ? "Your" : "The"), o_name, ((o_ptr->number > 1) ? "" : "s"));
90 #endif
91         add_flag(o_ptr->art_flags, TR_BLESSED);
92         o_ptr->discount = 99;
93     } else {
94         bool dis_happened = FALSE;
95         msg_print(_("その武器は祝福を嫌っている!", "The weapon resists your blessing!"));
96
97         /* Disenchant tohit */
98         if (o_ptr->to_h > 0) {
99             o_ptr->to_h--;
100             dis_happened = TRUE;
101         }
102
103         if ((o_ptr->to_h > 5) && (randint0(100) < 33))
104             o_ptr->to_h--;
105
106         /* Disenchant todam */
107         if (o_ptr->to_d > 0) {
108             o_ptr->to_d--;
109             dis_happened = TRUE;
110         }
111
112         if ((o_ptr->to_d > 5) && (randint0(100) < 33))
113             o_ptr->to_d--;
114
115         /* Disenchant toac */
116         if (o_ptr->to_a > 0) {
117             o_ptr->to_a--;
118             dis_happened = TRUE;
119         }
120
121         if ((o_ptr->to_a > 5) && (randint0(100) < 33))
122             o_ptr->to_a--;
123
124         if (dis_happened) {
125             msg_print(_("周囲が凡庸な雰囲気で満ちた...", "There is a static feeling in the air..."));
126
127 #ifdef JP
128             msg_format("%s は劣化した!", o_name);
129 #else
130             msg_format("%s %s %s disenchanted!", ((item >= 0) ? "Your" : "The"), o_name, ((o_ptr->number > 1) ? "were" : "was"));
131 #endif
132         }
133     }
134
135     caster_ptr->update |= PU_BONUS;
136     caster_ptr->window_flags |= PW_EQUIP | PW_PLAYER;
137     calc_android_exp(caster_ptr);
138     return TRUE;
139 }