1 #include "player/digestion-processor.h"
2 #include "avatar/avatar.h"
3 #include "core/disturbance.h"
4 #include "core/speed-table.h"
5 #include "core/stuff-handler.h"
6 #include "floor/wild.h"
7 #include "game-option/disturbance-options.h"
8 #include "main/sound-definitions-table.h"
9 #include "main/sound-of-music.h"
10 #include "object-enchant/trc-types.h"
11 #include "player-base/player-class.h"
12 #include "player-info/monk-data-type.h"
13 #include "player-info/samurai-data-type.h"
14 #include "player/player-damage.h"
15 #include "player/player-status.h"
16 #include "player/special-defense-types.h"
17 #include "status/bad-status-setter.h"
18 #include "system/player-type-definition.h"
19 #include "system/redrawing-flags-updater.h"
20 #include "timed-effect/player-paralysis.h"
21 #include "timed-effect/timed-effects.h"
22 #include "view/display-messages.h"
23 #include "world/world.h"
26 * @brief 10ゲームターンが進行するごとにプレイヤーの腹を減らす
27 * @param player_ptr プレイヤーへの参照ポインタ
29 void starve_player(PlayerType *player_ptr)
31 if (player_ptr->phase_out) {
35 if (player_ptr->food >= PY_FOOD_MAX) {
36 (void)set_food(player_ptr, player_ptr->food - 100);
37 } else if (!(w_ptr->game_turn % (TURNS_PER_TICK * 5))) {
38 int digestion = speed_to_energy(player_ptr->pspeed);
39 if (player_ptr->regenerate) {
42 PlayerClass pc(player_ptr);
43 if (!pc.monk_stance_is(MonkStanceType::NONE) || !pc.samurai_stance_is(SamuraiStanceType::NONE)) {
46 if (player_ptr->cursed.has(CurseTraitType::FAST_DIGEST)) {
50 if (player_ptr->slow_digest) {
57 if (digestion > 100) {
61 (void)set_food(player_ptr, player_ptr->food - digestion);
64 if ((player_ptr->food >= PY_FOOD_FAINT)) {
68 if (!player_ptr->effects()->paralysis()->is_paralyzed() && (randint0(100) < 10)) {
69 msg_print(_("あまりにも空腹で気絶してしまった。", "You faint from the lack of food."));
70 disturb(player_ptr, true, true);
71 (void)BadStatusSetter(player_ptr).mod_paralysis(1 + randint0(5));
74 if (player_ptr->food < PY_FOOD_STARVE) {
75 int dam = (PY_FOOD_STARVE - player_ptr->food) / 10;
76 if (!is_invuln(player_ptr)) {
77 take_hit(player_ptr, DAMAGE_LOSELIFE, dam, _("空腹", "starvation"));
83 * @brief 空腹状態をセットする / Set "food", notice observable changes
85 * @return ステータスに影響を及ぼす変化があった場合TRUEを返す
87 * Set "", notice observable changes\n
89 * The "food" variable can get as large as 20000, allowing the
90 * addition of the most "filling" item, Elvish Waybread, which adds
91 * 7500 food units, without overflowing the 32767 maximum limit.\n
93 * Perhaps we should disturb the player with various messages,
94 * especially messages about hunger status changes. \n
96 * Digestion of food is handled in "dungeon.c", in which, normally,
97 * the player digests about 20 food units per 100 game turns, more
98 * when "fast", more when "regenerating", less with "slow digestion",
99 * but when the player is "gorged", he digests 100 food units per 10
100 * game turns, or a full 1000 food units per 100 game turns.\n
102 * Note that the player's speed is reduced by 10 units while gorged,
103 * so if the player eats a single food ration (5000 food units) when
104 * full (15000 food units), he will be gorged for (5000/100)*10 = 500
105 * game turns, or 500/(100/5) = 25 player turns (if nothing else is
106 * affecting the player speed).\n
108 bool set_food(PlayerType *player_ptr, TIME_EFFECT v)
110 int old_aux, new_aux;
113 v = (v > 20000) ? 20000 : (v < 0) ? 0
115 if (player_ptr->food < PY_FOOD_FAINT) {
117 } else if (player_ptr->food < PY_FOOD_WEAK) {
119 } else if (player_ptr->food < PY_FOOD_ALERT) {
121 } else if (player_ptr->food < PY_FOOD_FULL) {
123 } else if (player_ptr->food < PY_FOOD_MAX) {
129 if (v < PY_FOOD_FAINT) {
131 } else if (v < PY_FOOD_WEAK) {
133 } else if (v < PY_FOOD_ALERT) {
135 } else if (v < PY_FOOD_FULL) {
137 } else if (v < PY_FOOD_MAX) {
143 if (old_aux < 1 && new_aux > 0) {
144 chg_virtue(player_ptr, Virtue::PATIENCE, 2);
145 } else if (old_aux < 3 && (old_aux != new_aux)) {
146 chg_virtue(player_ptr, Virtue::PATIENCE, 1);
149 chg_virtue(player_ptr, Virtue::TEMPERANCE, 1);
152 chg_virtue(player_ptr, Virtue::TEMPERANCE, -1);
155 if (new_aux > old_aux) {
158 msg_print(_("まだ空腹で倒れそうだ。", "You are still weak."));
161 msg_print(_("まだ空腹だ。", "You are still hungry."));
164 msg_print(_("空腹感がおさまった。", "You are no longer hungry."));
167 msg_print(_("満腹だ!", "You are full!"));
171 msg_print(_("食べ過ぎだ!", "You have gorged yourself!"));
172 chg_virtue(player_ptr, Virtue::HARMONY, -1);
173 chg_virtue(player_ptr, Virtue::PATIENCE, -1);
174 chg_virtue(player_ptr, Virtue::TEMPERANCE, -2);
179 } else if (new_aux < old_aux) {
183 msg_print(_("あまりにも空腹で気を失ってしまった!", "You are getting faint from hunger!"));
187 msg_print(_("お腹が空いて倒れそうだ。", "You are getting weak from hunger!"));
191 msg_print(_("お腹が空いてきた。", "You are getting hungry."));
194 msg_print(_("満腹感がなくなった。", "You are no longer full."));
197 msg_print(_("やっとお腹がきつくなくなった。", "You are no longer gorged."));
201 if (player_ptr->wild_mode && (new_aux < 2)) {
202 change_wild_mode(player_ptr, false);
208 player_ptr->food = v;
214 disturb(player_ptr, false, false);
217 auto &rfu = RedrawingFlagsUpdater::get_instance();
218 rfu.set_flag(StatusRecalculatingFlag::BONUS);
219 rfu.set_flag(MainWindowRedrawingFlag::HUNGER);
220 handle_stuff(player_ptr);