OSDN Git Service

[Refactor] #40466 Moved bad-status-setter.c/h and buff-setter.c/h from player/ to...
[hengbandforosx/hengbandosx.git] / src / player / digestion-processor.c
1 #include "player/digestion-processor.h"
2 #include "core/speed-table.h"
3 #include "object-enchant/trc-types.h"
4 #include "player/player-damage.h"
5 #include "status/bad-status-setter.h"
6 #include "player/player-effects.h"
7 #include "player/player-move.h"
8 #include "player/special-defense-types.h"
9 #include "view/display-messages.h"
10 #include "world/world.h"
11
12 /*!
13  * @brief 10ゲームターンが進行するごとにプレイヤーの腹を減らす
14  * @param creature_ptr プレーヤーへの参照ポインタ
15  * @return なし
16  */
17 void starve_player(player_type *creature_ptr)
18 {
19     if (creature_ptr->phase_out)
20         return;
21
22     if (creature_ptr->food >= PY_FOOD_MAX) {
23         (void)set_food(creature_ptr, creature_ptr->food - 100);
24     } else if (!(current_world_ptr->game_turn % (TURNS_PER_TICK * 5))) {
25         int digestion = SPEED_TO_ENERGY(creature_ptr->pspeed);
26         if (creature_ptr->regenerate)
27             digestion += 20;
28         if (creature_ptr->special_defense & (KAMAE_MASK | KATA_MASK))
29             digestion += 20;
30         if (creature_ptr->cursed & TRC_FAST_DIGEST)
31             digestion += 30;
32
33         if (creature_ptr->slow_digest)
34             digestion -= 5;
35
36         if (digestion < 1)
37             digestion = 1;
38         if (digestion > 100)
39             digestion = 100;
40
41         (void)set_food(creature_ptr, creature_ptr->food - digestion);
42     }
43
44     if ((creature_ptr->food >= PY_FOOD_FAINT))
45         return;
46
47     if (!creature_ptr->paralyzed && (randint0(100) < 10)) {
48         msg_print(_("あまりにも空腹で気絶してしまった。", "You faint from the lack of food."));
49         disturb(creature_ptr, TRUE, TRUE);
50         (void)set_paralyzed(creature_ptr, creature_ptr->paralyzed + 1 + randint0(5));
51     }
52
53     if (creature_ptr->food < PY_FOOD_STARVE) {
54         HIT_POINT dam = (PY_FOOD_STARVE - creature_ptr->food) / 10;
55         if (!is_invuln(creature_ptr))
56             take_hit(creature_ptr, DAMAGE_LOSELIFE, dam, _("空腹", "starvation"), -1);
57     }
58 }