7 #include "mind/mind-mage.h"
8 #include "core/stuff-handler.h"
9 #include "flavor/flavor-describer.h"
10 #include "flavor/object-flavor-types.h"
11 #include "floor/floor-object.h"
12 #include "inventory/inventory-object.h"
13 #include "object-enchant/special-object-flags.h"
14 #include "object-hook/hook-enchant.h"
15 #include "object-hook/hook-magic.h"
16 #include "object/item-tester-hooker.h"
17 #include "object/item-use-flags.h"
18 #include "object/object-generator.h"
19 #include "object/object-kind.h"
20 #include "player/player-realm.h"
21 #include "system/object-type-definition.h"
22 #include "view/display-messages.h"
26 * @param caster_ptr プレーヤーへの参照ポインタ
28 * @return ターンを消費した場合TRUEを返す
30 bool eat_magic(player_type *caster_ptr, int power)
33 GAME_TEXT o_name[MAX_NLEN];
35 item_tester_hook = item_tester_hook_recharge;
37 concptr q = _("どのアイテムから魔力を吸収しますか?", "Drain which item? ");
38 concptr s = _("魔力を吸収できるアイテムがありません。", "You have nothing to drain.");
42 o_ptr = choose_object(caster_ptr, &item, q, s, (USE_INVEN | USE_FLOOR), 0);
47 k_ptr = &k_info[o_ptr->k_idx];
48 DEPTH lev = k_info[o_ptr->k_idx].level;
50 int recharge_strength = 0;
51 bool is_eating_successful = TRUE;
52 if (o_ptr->tval == TV_ROD) {
53 recharge_strength = ((power > lev / 2) ? (power - lev / 2) : 0) / 5;
54 if (one_in_(recharge_strength)) {
55 is_eating_successful = FALSE;
57 if (o_ptr->timeout > (o_ptr->number - 1) * k_ptr->pval) {
58 msg_print(_("充填中のロッドから魔力を吸収することはできません。", "You can't absorb energy from a discharged rod."));
60 caster_ptr->csp += lev;
61 o_ptr->timeout += k_ptr->pval;
65 recharge_strength = (100 + power - lev) / 15;
66 if (recharge_strength < 0)
67 recharge_strength = 0;
69 if (one_in_(recharge_strength)) {
70 is_eating_successful = FALSE;
72 if (o_ptr->pval > 0) {
73 caster_ptr->csp += lev / 2;
76 if ((o_ptr->tval == TV_STAFF) && (item >= 0) && (o_ptr->number > 1)) {
80 object_copy(q_ptr, o_ptr);
85 item = store_item_to_inventory(caster_ptr, q_ptr);
87 msg_print(_("杖をまとめなおした。", "You unstack your staff."));
90 msg_print(_("吸収できる魔力がありません!", "There's no energy there to absorb!"));
94 o_ptr->ident |= IDENT_EMPTY;
98 if (is_eating_successful) {
99 return redraw_player(caster_ptr);
102 if (object_is_fixed_artifact(o_ptr)) {
103 describe_flavor(caster_ptr, o_name, o_ptr, OD_NAME_ONLY);
104 msg_format(_("魔力が逆流した!%sは完全に魔力を失った。", "The recharging backfires - %s is completely drained!"), o_name);
105 if (o_ptr->tval == TV_ROD)
106 o_ptr->timeout = k_ptr->pval * o_ptr->number;
107 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
110 return redraw_player(caster_ptr);
113 describe_flavor(caster_ptr, o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
115 /* Mages recharge objects more safely. */
116 if (is_wizard_class(caster_ptr)) {
117 /* 10% chance to blow up one rod, otherwise draining. */
118 if (o_ptr->tval == TV_ROD) {
124 /* 75% chance to blow up one wand, otherwise draining. */
125 else if (o_ptr->tval == TV_WAND) {
131 /* 50% chance to blow up one staff, otherwise no effect. */
132 else if (o_ptr->tval == TV_STAFF) {
140 /* All other classes get no special favors. */
142 /* 33% chance to blow up one rod, otherwise draining. */
143 if (o_ptr->tval == TV_ROD) {
149 /* 20% chance of the entire stack, else destroy one wand. */
150 else if (o_ptr->tval == TV_WAND) {
156 /* Blow up one staff. */
157 else if (o_ptr->tval == TV_STAFF) {
162 if (fail_type == 1) {
163 if (o_ptr->tval == TV_ROD) {
164 msg_format(_("ロッドは破損を免れたが、魔力は全て失なわれた。", "You save your rod from destruction, but all charges are lost."), o_name);
165 o_ptr->timeout = k_ptr->pval * o_ptr->number;
166 } else if (o_ptr->tval == TV_WAND) {
167 msg_format(_("%sは破損を免れたが、魔力が全て失われた。", "You save your %s from destruction, but all charges are lost."), o_name);
172 if (fail_type == 2) {
173 if (o_ptr->number > 1) {
174 msg_format(_("乱暴な魔法のために%sが一本壊れた!", "Wild magic consumes one of your %s!"), o_name);
175 /* Reduce rod stack maximum timeout, drain wands. */
176 if (o_ptr->tval == TV_ROD)
177 o_ptr->timeout = MIN(o_ptr->timeout, k_ptr->pval * (o_ptr->number - 1));
178 else if (o_ptr->tval == TV_WAND)
179 o_ptr->pval = o_ptr->pval * (o_ptr->number - 1) / o_ptr->number;
181 msg_format(_("乱暴な魔法のために%sが何本か壊れた!", "Wild magic consumes your %s!"), o_name);
184 vary_item(caster_ptr, item, -1);
187 if (fail_type == 3) {
188 if (o_ptr->number > 1)
189 msg_format(_("乱暴な魔法のために%sが全て壊れた!", "Wild magic consumes all your %s!"), o_name);
191 msg_format(_("乱暴な魔法のために%sが壊れた!", "Wild magic consumes your %s!"), o_name);
193 vary_item(caster_ptr, item, -999);
196 return redraw_player(caster_ptr);