OSDN Git Service

[Add] @return を不要に書き込んだことによる警告をひとまず置換で修正.
[hengbandforosx/hengbandosx.git] / src / mind / mind-priest.cpp
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 "system/player-type-definition.h"
20 #include "util/bit-flags-calculator.h"
21 #include "view/display-messages.h"
22
23 /*!
24  * @brief 武器の祝福処理 /
25  * Bless a weapon
26  * @return ターン消費を要する処理を行ったならばTRUEを返す
27  */
28 bool bless_weapon(player_type *caster_ptr)
29 {
30     item_tester_hook = object_is_weapon;
31
32     concptr q = _("どのアイテムを祝福しますか?", "Bless which weapon? ");
33     concptr s = _("祝福できる武器がありません。", "You have weapon to bless.");
34
35     OBJECT_IDX item;
36     object_type *o_ptr = choose_object(caster_ptr, &item, q, s, USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT, TV_NONE);
37     if (!o_ptr)
38         return FALSE;
39
40     GAME_TEXT o_name[MAX_NLEN];
41     describe_flavor(caster_ptr, o_name, o_ptr, OD_OMIT_PREFIX | OD_NAME_ONLY);
42     BIT_FLAGS flgs[TR_FLAG_SIZE];
43     object_flags(caster_ptr, o_ptr, flgs);
44
45     if (object_is_cursed(o_ptr)) {
46         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)
47             || (o_ptr->curse_flags & TRC_PERMA_CURSE)) {
48 #ifdef JP
49             msg_format("%sを覆う黒いオーラは祝福を跳ね返した!", o_name);
50 #else
51             msg_format("The black aura on %s %s disrupts the blessing!", ((item >= 0) ? "your" : "the"), o_name);
52 #endif
53
54             return TRUE;
55         }
56
57 #ifdef JP
58         msg_format("%s から邪悪なオーラが消えた。", o_name);
59 #else
60         msg_format("A malignant aura leaves %s %s.", ((item >= 0) ? "your" : "the"), o_name);
61 #endif
62         o_ptr->curse_flags = 0L;
63         set_bits(o_ptr->ident, IDENT_SENSE);
64         set_bits(o_ptr->feeling, FEEL_NONE);
65         set_bits(caster_ptr->update, PU_BONUS);
66         set_bits(caster_ptr->window_flags, PW_EQUIP | PW_FLOOR_ITEM_LIST);
67     }
68
69     /*
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.
76      */
77     if (has_flag(flgs, TR_BLESSED)) {
78 #ifdef JP
79         msg_format("%s は既に祝福されている。", o_name);
80 #else
81         msg_format("%s %s %s blessed already.", ((item >= 0) ? "Your" : "The"), o_name, ((o_ptr->number > 1) ? "were" : "was"));
82 #endif
83         return TRUE;
84     }
85
86     if (!(object_is_artifact(o_ptr) || object_is_ego(o_ptr)) || one_in_(3)) {
87 #ifdef JP
88         msg_format("%sは輝いた!", o_name);
89 #else
90         msg_format("%s %s shine%s!", ((item >= 0) ? "Your" : "The"), o_name, ((o_ptr->number > 1) ? "" : "s"));
91 #endif
92         add_flag(o_ptr->art_flags, TR_BLESSED);
93         o_ptr->discount = 99;
94     } else {
95         bool dis_happened = FALSE;
96         msg_print(_("その武器は祝福を嫌っている!", "The weapon resists your blessing!"));
97
98         /* Disenchant tohit */
99         if (o_ptr->to_h > 0) {
100             o_ptr->to_h--;
101             dis_happened = TRUE;
102         }
103
104         if ((o_ptr->to_h > 5) && (randint0(100) < 33))
105             o_ptr->to_h--;
106
107         /* Disenchant todam */
108         if (o_ptr->to_d > 0) {
109             o_ptr->to_d--;
110             dis_happened = TRUE;
111         }
112
113         if ((o_ptr->to_d > 5) && (randint0(100) < 33))
114             o_ptr->to_d--;
115
116         /* Disenchant toac */
117         if (o_ptr->to_a > 0) {
118             o_ptr->to_a--;
119             dis_happened = TRUE;
120         }
121
122         if ((o_ptr->to_a > 5) && (randint0(100) < 33))
123             o_ptr->to_a--;
124
125         if (dis_happened) {
126             msg_print(_("周囲が凡庸な雰囲気で満ちた...", "There is a static feeling in the air..."));
127
128 #ifdef JP
129             msg_format("%s は劣化した!", o_name);
130 #else
131             msg_format("%s %s %s disenchanted!", ((item >= 0) ? "Your" : "The"), o_name, ((o_ptr->number > 1) ? "were" : "was"));
132 #endif
133         }
134     }
135
136     set_bits(caster_ptr->update, PU_BONUS);
137     set_bits(caster_ptr->window_flags, PW_EQUIP | PW_PLAYER | PW_FLOOR_ITEM_LIST);
138     calc_android_exp(caster_ptr);
139     return TRUE;
140 }