1 #include "inventory/recharge-processor.h"
2 #include "core/disturbance.h"
3 #include "core/window-redrawer.h"
4 #include "flavor/flavor-describer.h"
5 #include "flavor/object-flavor-types.h"
6 #include "hpmp/hp-mp-regenerator.h"
7 #include "inventory/inventory-slot-types.h"
8 #include "object-hook/hook-checker.h"
9 #include "object/object-kind.h"
10 #include "system/floor-type-definition.h"
11 #include "system/object-type-definition.h"
12 #include "system/player-type-definition.h"
13 #include "util/quarks.h"
14 #include "util/string-processor.h"
15 #include "view/display-messages.h"
19 * !!を刻んだ魔道具の時間経過による再充填を知らせる処理 /
20 * If player has inscribed the object with "!!", let him know when it's recharged. -LM-
21 * @param o_ptr 対象オブジェクトの構造体参照ポインタ
23 static void recharged_notice(player_type *owner_ptr, object_type *o_ptr)
25 if (!o_ptr->inscription)
28 concptr s = angband_strchr(quark_str(o_ptr->inscription), '!');
31 GAME_TEXT o_name[MAX_NLEN];
32 describe_flavor(owner_ptr, o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
34 msg_format("%sは再充填された。", o_name);
36 if (o_ptr->number > 1)
37 msg_format("Your %s are recharged.", o_name);
39 msg_format("Your %s is recharged.", o_name);
41 disturb(owner_ptr, FALSE, FALSE);
45 s = angband_strchr(s + 1, '!');
50 * @brief 10ゲームターンが進行するごとに魔道具の自然充填を行う処理
51 * / Handle recharging objects once every 10 game turns
53 void recharge_magic_items(player_type *creature_ptr)
58 for (changed = FALSE, i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
59 object_type *o_ptr = &creature_ptr->inventory_list[i];
63 if (o_ptr->timeout > 0) {
65 if (!o_ptr->timeout) {
66 recharged_notice(creature_ptr, o_ptr);
73 creature_ptr->window_flags |= (PW_EQUIP);
78 * Recharge rods. Rods now use timeout to control charging status,
79 * and each charging rod in a stack decreases the stack's timeout by
82 for (changed = FALSE, i = 0; i < INVEN_PACK; i++) {
83 object_type *o_ptr = &creature_ptr->inventory_list[i];
84 object_kind *k_ptr = &k_info[o_ptr->k_idx];
88 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout)) {
89 TIME_EFFECT temp = (o_ptr->timeout + (k_ptr->pval - 1)) / k_ptr->pval;
90 if (temp > o_ptr->number)
91 temp = (TIME_EFFECT)o_ptr->number;
93 o_ptr->timeout -= temp;
94 if (o_ptr->timeout < 0)
97 if (!(o_ptr->timeout)) {
98 recharged_notice(creature_ptr, o_ptr);
100 } else if (o_ptr->timeout % k_ptr->pval) {
107 creature_ptr->window_flags |= (PW_INVEN);
111 for (i = 1; i < creature_ptr->current_floor_ptr->o_max; i++) {
112 object_type *o_ptr = &creature_ptr->current_floor_ptr->o_list[i];
113 if (!object_is_valid(o_ptr))
116 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout)) {
117 o_ptr->timeout -= (TIME_EFFECT)o_ptr->number;
118 if (o_ptr->timeout < 0)