1 #include "core/hp-mp-processor.h"
2 #include "cmd-action/cmd-pet.h"
3 #include "core/hp-mp-regenerator.h"
4 #include "floor/floor.h"
5 #include "floor/pattern-walk.h"
6 #include "grid/feature.h"
7 #include "monster-race/race-flags2.h"
8 #include "monster-race/race-flags3.h"
9 #include "object-enchant/object-ego.h"
10 #include "object-enchant/trc-types.h"
11 #include "object/object-flavor.h"
12 #include "player/player-damage.h"
13 #include "player/player-effects.h"
14 #include "player/player-races-table.h"
15 #include "realm/realm-song-numbers.h"
16 #include "world/world.h"
19 * @brief 10ゲームターンが進行するごとにプレイヤーのHPとMPの増減処理を行う。
20 * / Handle timed damage and regeneration every 10 game turns
23 void process_player_hp_mp(player_type *creature_ptr)
25 feature_type *f_ptr = &f_info[creature_ptr->current_floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].feat];
26 bool cave_no_regen = FALSE;
27 int upkeep_factor = 0;
28 int regen_amount = PY_REGEN_NORMAL;
29 if (creature_ptr->poisoned && !IS_INVULN(creature_ptr)) {
30 take_hit(creature_ptr, DAMAGE_NOESCAPE, 1, _("毒", "poison"), -1);
33 if (creature_ptr->cut && !IS_INVULN(creature_ptr)) {
35 if (creature_ptr->cut > 1000) {
37 } else if (creature_ptr->cut > 200) {
39 } else if (creature_ptr->cut > 100) {
41 } else if (creature_ptr->cut > 50) {
43 } else if (creature_ptr->cut > 25) {
45 } else if (creature_ptr->cut > 10) {
51 take_hit(creature_ptr, DAMAGE_NOESCAPE, dam, _("致命傷", "a fatal wound"), -1);
54 if (PRACE_IS_(creature_ptr, RACE_VAMPIRE) || (creature_ptr->mimic_form == MIMIC_VAMPIRE)) {
55 if (!creature_ptr->current_floor_ptr->dun_level && !creature_ptr->resist_lite && !IS_INVULN(creature_ptr) && is_daytime()) {
56 if ((creature_ptr->current_floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW) {
57 msg_print(_("日光があなたのアンデッドの肉体を焼き焦がした!", "The sun's rays scorch your undead flesh!"));
58 take_hit(creature_ptr, DAMAGE_NOESCAPE, 1, _("日光", "sunlight"), -1);
63 if (creature_ptr->inventory_list[INVEN_LITE].tval && (creature_ptr->inventory_list[INVEN_LITE].name2 != EGO_LITE_DARKNESS)
64 && !creature_ptr->resist_lite) {
65 object_type *o_ptr = &creature_ptr->inventory_list[INVEN_LITE];
66 GAME_TEXT o_name[MAX_NLEN];
67 char ouch[MAX_NLEN + 40];
68 object_desc(creature_ptr, o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
69 msg_format(_("%sがあなたのアンデッドの肉体を焼き焦がした!", "The %s scorches your undead flesh!"), o_name);
72 object_desc(creature_ptr, o_name, o_ptr, OD_NAME_ONLY);
73 sprintf(ouch, _("%sを装備したダメージ", "wielding %s"), o_name);
75 if (!IS_INVULN(creature_ptr))
76 take_hit(creature_ptr, DAMAGE_NOESCAPE, 1, ouch, -1);
80 if (have_flag(f_ptr->flags, FF_LAVA) && !IS_INVULN(creature_ptr) && !creature_ptr->immune_fire) {
83 if (have_flag(f_ptr->flags, FF_DEEP)) {
84 damage = 6000 + randint0(4000);
85 } else if (!creature_ptr->levitation) {
86 damage = 3000 + randint0(2000);
90 if (PRACE_IS_(creature_ptr, RACE_ENT))
92 if (creature_ptr->resist_fire)
94 if (is_oppose_fire(creature_ptr))
96 if (creature_ptr->levitation)
99 damage = damage / 100 + (randint0(100) < (damage % 100));
101 if (creature_ptr->levitation) {
102 msg_print(_("熱で火傷した!", "The heat burns you!"));
103 take_hit(creature_ptr, DAMAGE_NOESCAPE, damage,
104 format(_("%sの上に浮遊したダメージ", "flying over %s"),
105 f_name + f_info[get_feat_mimic(&creature_ptr->current_floor_ptr->grid_array[creature_ptr->y][creature_ptr->x])].name),
108 concptr name = f_name + f_info[get_feat_mimic(&creature_ptr->current_floor_ptr->grid_array[creature_ptr->y][creature_ptr->x])].name;
109 msg_format(_("%sで火傷した!", "The %s burns you!"), name);
110 take_hit(creature_ptr, DAMAGE_NOESCAPE, damage, name, -1);
113 cave_no_regen = TRUE;
117 if (have_flag(f_ptr->flags, FF_COLD_PUDDLE) && !IS_INVULN(creature_ptr) && !creature_ptr->immune_cold) {
120 if (have_flag(f_ptr->flags, FF_DEEP)) {
121 damage = 6000 + randint0(4000);
122 } else if (!creature_ptr->levitation) {
123 damage = 3000 + randint0(2000);
127 if (creature_ptr->resist_cold)
129 if (is_oppose_cold(creature_ptr))
131 if (creature_ptr->levitation)
134 damage = damage / 100 + (randint0(100) < (damage % 100));
136 if (creature_ptr->levitation) {
137 msg_print(_("冷気に覆われた!", "The cold engulfs you!"));
138 take_hit(creature_ptr, DAMAGE_NOESCAPE, damage,
139 format(_("%sの上に浮遊したダメージ", "flying over %s"),
140 f_name + f_info[get_feat_mimic(&creature_ptr->current_floor_ptr->grid_array[creature_ptr->y][creature_ptr->x])].name),
143 concptr name = f_name + f_info[get_feat_mimic(&creature_ptr->current_floor_ptr->grid_array[creature_ptr->y][creature_ptr->x])].name;
144 msg_format(_("%sに凍えた!", "The %s frostbites you!"), name);
145 take_hit(creature_ptr, DAMAGE_NOESCAPE, damage, name, -1);
148 cave_no_regen = TRUE;
152 if (have_flag(f_ptr->flags, FF_ELEC_PUDDLE) && !IS_INVULN(creature_ptr) && !creature_ptr->immune_elec) {
155 if (have_flag(f_ptr->flags, FF_DEEP)) {
156 damage = 6000 + randint0(4000);
157 } else if (!creature_ptr->levitation) {
158 damage = 3000 + randint0(2000);
162 if (creature_ptr->resist_elec)
164 if (is_oppose_elec(creature_ptr))
166 if (creature_ptr->levitation)
169 damage = damage / 100 + (randint0(100) < (damage % 100));
171 if (creature_ptr->levitation) {
172 msg_print(_("電撃を受けた!", "The electricity shocks you!"));
173 take_hit(creature_ptr, DAMAGE_NOESCAPE, damage,
174 format(_("%sの上に浮遊したダメージ", "flying over %s"),
175 f_name + f_info[get_feat_mimic(&creature_ptr->current_floor_ptr->grid_array[creature_ptr->y][creature_ptr->x])].name),
178 concptr name = f_name + f_info[get_feat_mimic(&creature_ptr->current_floor_ptr->grid_array[creature_ptr->y][creature_ptr->x])].name;
179 msg_format(_("%sに感電した!", "The %s shocks you!"), name);
180 take_hit(creature_ptr, DAMAGE_NOESCAPE, damage, name, -1);
183 cave_no_regen = TRUE;
187 if (have_flag(f_ptr->flags, FF_ACID_PUDDLE) && !IS_INVULN(creature_ptr) && !creature_ptr->immune_acid) {
190 if (have_flag(f_ptr->flags, FF_DEEP)) {
191 damage = 6000 + randint0(4000);
192 } else if (!creature_ptr->levitation) {
193 damage = 3000 + randint0(2000);
197 if (creature_ptr->resist_acid)
199 if (is_oppose_acid(creature_ptr))
201 if (creature_ptr->levitation)
204 damage = damage / 100 + (randint0(100) < (damage % 100));
206 if (creature_ptr->levitation) {
207 msg_print(_("酸が飛び散った!", "The acid melts you!"));
208 take_hit(creature_ptr, DAMAGE_NOESCAPE, damage,
209 format(_("%sの上に浮遊したダメージ", "flying over %s"),
210 f_name + f_info[get_feat_mimic(&creature_ptr->current_floor_ptr->grid_array[creature_ptr->y][creature_ptr->x])].name),
213 concptr name = f_name + f_info[get_feat_mimic(&creature_ptr->current_floor_ptr->grid_array[creature_ptr->y][creature_ptr->x])].name;
214 msg_format(_("%sに溶かされた!", "The %s melts you!"), name);
215 take_hit(creature_ptr, DAMAGE_NOESCAPE, damage, name, -1);
218 cave_no_regen = TRUE;
222 if (have_flag(f_ptr->flags, FF_POISON_PUDDLE) && !IS_INVULN(creature_ptr)) {
225 if (have_flag(f_ptr->flags, FF_DEEP)) {
226 damage = 6000 + randint0(4000);
227 } else if (!creature_ptr->levitation) {
228 damage = 3000 + randint0(2000);
232 if (creature_ptr->resist_pois)
234 if (is_oppose_pois(creature_ptr))
236 if (creature_ptr->levitation)
239 damage = damage / 100 + (randint0(100) < (damage % 100));
241 if (creature_ptr->levitation) {
242 msg_print(_("毒気を吸い込んだ!", "The gas poisons you!"));
243 take_hit(creature_ptr, DAMAGE_NOESCAPE, damage,
244 format(_("%sの上に浮遊したダメージ", "flying over %s"),
245 f_name + f_info[get_feat_mimic(&creature_ptr->current_floor_ptr->grid_array[creature_ptr->y][creature_ptr->x])].name),
247 if (creature_ptr->resist_pois)
248 (void)set_poisoned(creature_ptr, creature_ptr->poisoned + 1);
250 concptr name = f_name + f_info[get_feat_mimic(&creature_ptr->current_floor_ptr->grid_array[creature_ptr->y][creature_ptr->x])].name;
251 msg_format(_("%sに毒された!", "The %s poisons you!"), name);
252 take_hit(creature_ptr, DAMAGE_NOESCAPE, damage, name, -1);
253 if (creature_ptr->resist_pois)
254 (void)set_poisoned(creature_ptr, creature_ptr->poisoned + 3);
257 cave_no_regen = TRUE;
261 if (have_flag(f_ptr->flags, FF_WATER) && have_flag(f_ptr->flags, FF_DEEP) && !creature_ptr->levitation && !creature_ptr->can_swim
262 && !creature_ptr->resist_water) {
263 if (creature_ptr->total_weight > weight_limit(creature_ptr)) {
264 msg_print(_("溺れている!", "You are drowning!"));
265 take_hit(creature_ptr, DAMAGE_NOESCAPE, randint1(creature_ptr->lev), _("溺れ", "drowning"), -1);
266 cave_no_regen = TRUE;
270 if (creature_ptr->riding) {
272 if ((r_info[creature_ptr->current_floor_ptr->m_list[creature_ptr->riding].r_idx].flags2 & RF2_AURA_FIRE) && !creature_ptr->immune_fire) {
273 damage = r_info[creature_ptr->current_floor_ptr->m_list[creature_ptr->riding].r_idx].level / 2;
274 if (PRACE_IS_(creature_ptr, RACE_ENT))
275 damage += damage / 3;
276 if (creature_ptr->resist_fire)
278 if (is_oppose_fire(creature_ptr))
280 msg_print(_("熱い!", "It's hot!"));
281 take_hit(creature_ptr, DAMAGE_NOESCAPE, damage, _("炎のオーラ", "Fire aura"), -1);
283 if ((r_info[creature_ptr->current_floor_ptr->m_list[creature_ptr->riding].r_idx].flags2 & RF2_AURA_ELEC) && !creature_ptr->immune_elec) {
284 damage = r_info[creature_ptr->current_floor_ptr->m_list[creature_ptr->riding].r_idx].level / 2;
285 if (PRACE_IS_(creature_ptr, RACE_ANDROID))
286 damage += damage / 3;
287 if (creature_ptr->resist_elec)
289 if (is_oppose_elec(creature_ptr))
291 msg_print(_("痛い!", "It hurts!"));
292 take_hit(creature_ptr, DAMAGE_NOESCAPE, damage, _("電気のオーラ", "Elec aura"), -1);
294 if ((r_info[creature_ptr->current_floor_ptr->m_list[creature_ptr->riding].r_idx].flags3 & RF3_AURA_COLD) && !creature_ptr->immune_cold) {
295 damage = r_info[creature_ptr->current_floor_ptr->m_list[creature_ptr->riding].r_idx].level / 2;
296 if (creature_ptr->resist_cold)
298 if (is_oppose_cold(creature_ptr))
300 msg_print(_("冷たい!", "It's cold!"));
301 take_hit(creature_ptr, DAMAGE_NOESCAPE, damage, _("冷気のオーラ", "Cold aura"), -1);
305 /* Spectres -- take damage when moving through walls */
307 * Added: ANYBODY takes damage if inside through walls
308 * without wraith form -- NOTE: Spectres will never be
309 * reduced below 0 hp by being inside a stone wall; others
312 if (!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY)) {
313 if (!IS_INVULN(creature_ptr) && !creature_ptr->wraith_form && !creature_ptr->kabenuke
314 && ((creature_ptr->chp > (creature_ptr->lev / 5)) || !creature_ptr->pass_wall)) {
316 cave_no_regen = TRUE;
318 if (creature_ptr->pass_wall) {
319 msg_print(_("体の分子が分解した気がする!", "Your molecules feel disrupted!"));
320 dam_desc = _("密度", "density");
322 msg_print(_("崩れた岩に押し潰された!", "You are being crushed!"));
323 dam_desc = _("硬い岩", "solid rock");
326 take_hit(creature_ptr, DAMAGE_NOESCAPE, 1 + (creature_ptr->lev / 5), dam_desc, -1);
330 if (creature_ptr->food < PY_FOOD_WEAK) {
331 if (creature_ptr->food < PY_FOOD_STARVE) {
333 } else if (creature_ptr->food < PY_FOOD_FAINT) {
334 regen_amount = PY_REGEN_FAINT;
336 regen_amount = PY_REGEN_WEAK;
340 if (pattern_effect(creature_ptr)) {
341 cave_no_regen = TRUE;
343 if (creature_ptr->regenerate) {
344 regen_amount = regen_amount * 2;
346 if (creature_ptr->special_defense & (KAMAE_MASK | KATA_MASK)) {
349 if (creature_ptr->cursed & TRC_SLOW_REGEN) {
354 if ((creature_ptr->action == ACTION_SEARCH) || (creature_ptr->action == ACTION_REST)) {
355 regen_amount = regen_amount * 2;
358 upkeep_factor = calculate_upkeep(creature_ptr);
359 if ((creature_ptr->action == ACTION_LEARN) || (creature_ptr->action == ACTION_HAYAGAKE) || (creature_ptr->special_defense & KATA_KOUKIJIN)) {
360 upkeep_factor += 100;
363 regenmana(creature_ptr, upkeep_factor, regen_amount);
364 if (creature_ptr->pclass == CLASS_MAGIC_EATER) {
365 regenmagic(creature_ptr, regen_amount);
368 if ((creature_ptr->csp == 0) && (creature_ptr->csp_frac == 0)) {
369 while (upkeep_factor > 100) {
370 msg_print(_("こんなに多くのペットを制御できない!", "Too many pets to control at once!"));
372 do_cmd_pet_dismiss(creature_ptr);
374 upkeep_factor = calculate_upkeep(creature_ptr);
376 msg_format(_("維持MPは %d%%", "Upkeep: %d%% mana."), upkeep_factor);
381 if (creature_ptr->poisoned)
383 if (creature_ptr->cut)
388 regen_amount = (regen_amount * creature_ptr->mutant_regenerate_mod) / 100;
389 if ((creature_ptr->chp < creature_ptr->mhp) && !cave_no_regen) {
390 regenhp(creature_ptr, regen_amount);