1 #include "spell-kind/spells-equipment.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 "inventory/inventory-slot-types.h"
7 #include "object-hook/hook-enchant.h"
8 #include "object-hook/hook-weapon.h"
9 #include "object/object-info.h"
10 #include "player-info/avatar.h"
11 #include "racial/racial-android.h"
12 #include "system/object-type-definition.h"
13 #include "view/display-messages.h"
16 * @brief プレイヤーの装備劣化処理 /
17 * Apply disenchantment to the player's stuff
18 * @param target_ptr プレーヤーへの参照ポインタ
19 * @param mode 最下位ビットが1ならば劣化処理が若干低減される
20 * @return 劣化処理に関するメッセージが発せられた場合はTRUEを返す /
21 * Return "TRUE" if the player notices anything
23 bool apply_disenchant(player_type *target_ptr, BIT_FLAGS mode)
26 switch (randint1(8)) {
54 o_ptr = &target_ptr->inventory_list[t];
58 if (!object_is_weapon_armour_ammo(target_ptr, o_ptr))
61 if ((o_ptr->to_h <= 0) && (o_ptr->to_d <= 0) && (o_ptr->to_a <= 0) && (o_ptr->pval <= 1)) {
65 GAME_TEXT o_name[MAX_NLEN];
66 describe_flavor(target_ptr, o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
67 if (object_is_artifact(o_ptr) && (randint0(100) < 71)) {
69 msg_format("%s(%c)は劣化を跳ね返した!", o_name, index_to_label(t));
71 msg_format("Your %s (%c) resist%s disenchantment!", o_name, index_to_label(t), ((o_ptr->number != 1) ? "" : "s"));
76 int to_h = o_ptr->to_h;
77 int to_d = o_ptr->to_d;
78 int to_a = o_ptr->to_a;
79 int pval = o_ptr->pval;
83 if ((o_ptr->to_h > 5) && (randint0(100) < 20))
88 if ((o_ptr->to_d > 5) && (randint0(100) < 20))
93 if ((o_ptr->to_a > 5) && (randint0(100) < 20))
96 if ((o_ptr->pval > 1) && one_in_(13) && !(mode & 0x01))
99 bool is_actually_disenchanted = to_h != o_ptr->to_h;
100 is_actually_disenchanted |= to_d != o_ptr->to_d;
101 is_actually_disenchanted |= to_a != o_ptr->to_a;
102 is_actually_disenchanted |= pval != o_ptr->pval;
103 if (!is_actually_disenchanted)
107 msg_format("%s(%c)は劣化してしまった!", o_name, index_to_label(t));
109 msg_format("Your %s (%c) %s disenchanted!", o_name, index_to_label(t), ((o_ptr->number != 1) ? "were" : "was"));
111 chg_virtue(target_ptr, V_HARMONY, 1);
112 chg_virtue(target_ptr, V_ENCHANT, -2);
113 target_ptr->update |= (PU_BONUS);
114 target_ptr->window |= (PW_EQUIP | PW_PLAYER);
116 calc_android_exp(target_ptr);