OSDN Git Service

858eabdc8179771c978dfa3843e9e979b5d9a26f
[hengband/hengband.git] / src / object / lite-processor.c
1 #include "angband.h"
2 #include "object/lite-processor.h"
3 #include "object-ego.h"
4 #include "object-hook.h"
5 #include "player-move.h"
6 #include "world/world.h"
7
8 /*!
9  * @brief 10ゲームターンが進行する毎に光源の寿命を減らす処理
10  * / Handle burning fuel every 10 game turns
11  * @return なし
12  */
13 void reduce_lite_life(player_type* creature_ptr)
14 {
15     object_type* o_ptr = &creature_ptr->inventory_list[INVEN_LITE];
16     if (o_ptr->tval != TV_LITE)
17         return;
18
19     if (object_is_fixed_artifact(o_ptr) || (o_ptr->sval == SV_LITE_FEANOR) || (o_ptr->xtra4 <= 0))
20         return;
21
22     if (o_ptr->name2 == EGO_LITE_LONG) {
23         if (current_world_ptr->game_turn % (TURNS_PER_TICK * 2))
24             o_ptr->xtra4--;
25     } else
26         o_ptr->xtra4--;
27
28     notice_lite_change(creature_ptr, o_ptr);
29 }
30
31 /*!
32  * @brief 寿命つき光源の警告メッセージ処理
33  * @param creature_ptr プレーヤーへの参照ポインタ
34  * @param o_ptr 現在光源として使っているオブジェクトの構造体参照ポインタ
35  * @return なし
36  */
37 void notice_lite_change(player_type* creature_ptr, object_type* o_ptr)
38 {
39     if ((o_ptr->xtra4 < 100) || (!(o_ptr->xtra4 % 100))) {
40         creature_ptr->window |= (PW_EQUIP);
41     }
42
43     if (creature_ptr->blind) {
44         if (o_ptr->xtra4 == 0)
45             o_ptr->xtra4++;
46     } else if (o_ptr->xtra4 == 0) {
47         disturb(creature_ptr, FALSE, TRUE);
48         msg_print(_("明かりが消えてしまった!", "Your light has gone out!"));
49         creature_ptr->update |= (PU_TORCH);
50         creature_ptr->update |= (PU_BONUS);
51     } else if (o_ptr->name2 == EGO_LITE_LONG) {
52         if ((o_ptr->xtra4 < 50) && (!(o_ptr->xtra4 % 5))
53             && (current_world_ptr->game_turn % (TURNS_PER_TICK * 2))) {
54             if (disturb_minor)
55                 disturb(creature_ptr, FALSE, TRUE);
56             msg_print(_("明かりが微かになってきている。", "Your light is growing faint."));
57         }
58     } else if ((o_ptr->xtra4 < 100) && (!(o_ptr->xtra4 % 10))) {
59         if (disturb_minor)
60             disturb(creature_ptr, FALSE, TRUE);
61         msg_print(_("明かりが微かになってきている。", "Your light is growing faint."));
62     }
63 }