2 #include "core/hp-mp-processor.h"
3 #include "realm/realm-song.h"
4 #include "player-damage.h"
5 #include "object/object-flavor.h"
6 #include "object/object-ego.h"
7 #include "world/world.h"
8 #include "player-effects.h"
9 #include "floor/pattern-walk.h"
10 #include "core/hp-mp-regenerator.h"
11 #include "cmd/cmd-pet.h"
14 * @brief 10ゲームターンが進行するごとにプレイヤーのHPとMPの増減処理を行う。
15 * / Handle timed damage and regeneration every 10 game turns
18 void process_player_hp_mp(player_type* creature_ptr)
20 feature_type* f_ptr = &f_info[creature_ptr->current_floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].feat];
21 bool cave_no_regen = FALSE;
22 int upkeep_factor = 0;
23 int regen_amount = PY_REGEN_NORMAL;
24 if (creature_ptr->poisoned && !IS_INVULN(creature_ptr)) {
25 take_hit(creature_ptr, DAMAGE_NOESCAPE, 1, _("毒", "poison"), -1);
28 if (creature_ptr->cut && !IS_INVULN(creature_ptr)) {
30 if (creature_ptr->cut > 1000) {
32 } else if (creature_ptr->cut > 200) {
34 } else if (creature_ptr->cut > 100) {
36 } else if (creature_ptr->cut > 50) {
38 } else if (creature_ptr->cut > 25) {
40 } else if (creature_ptr->cut > 10) {
46 take_hit(creature_ptr, DAMAGE_NOESCAPE, dam, _("致命傷", "a fatal wound"), -1);
49 if (PRACE_IS_(creature_ptr, RACE_VAMPIRE) || (creature_ptr->mimic_form == MIMIC_VAMPIRE)) {
50 if (!creature_ptr->current_floor_ptr->dun_level && !creature_ptr->resist_lite && !IS_INVULN(creature_ptr) && is_daytime()) {
51 if ((creature_ptr->current_floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW) {
52 msg_print(_("日光があなたのアンデッドの肉体を焼き焦がした!", "The sun's rays scorch your undead flesh!"));
53 take_hit(creature_ptr, DAMAGE_NOESCAPE, 1, _("日光", "sunlight"), -1);
58 if (creature_ptr->inventory_list[INVEN_LITE].tval && (creature_ptr->inventory_list[INVEN_LITE].name2 != EGO_LITE_DARKNESS) && !creature_ptr->resist_lite) {
59 object_type* o_ptr = &creature_ptr->inventory_list[INVEN_LITE];
60 GAME_TEXT o_name[MAX_NLEN];
61 char ouch[MAX_NLEN + 40];
62 object_desc(creature_ptr, o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
63 msg_format(_("%sがあなたのアンデッドの肉体を焼き焦がした!", "The %s scorches your undead flesh!"), o_name);
66 object_desc(creature_ptr, o_name, o_ptr, OD_NAME_ONLY);
67 sprintf(ouch, _("%sを装備したダメージ", "wielding %s"), o_name);
69 if (!IS_INVULN(creature_ptr))
70 take_hit(creature_ptr, DAMAGE_NOESCAPE, 1, ouch, -1);
74 if (have_flag(f_ptr->flags, FF_LAVA) && !IS_INVULN(creature_ptr) && !creature_ptr->immune_fire) {
77 if (have_flag(f_ptr->flags, FF_DEEP)) {
78 damage = 6000 + randint0(4000);
79 } else if (!creature_ptr->levitation) {
80 damage = 3000 + randint0(2000);
84 if (PRACE_IS_(creature_ptr, RACE_ENT))
86 if (creature_ptr->resist_fire)
88 if (is_oppose_fire(creature_ptr))
90 if (creature_ptr->levitation)
93 damage = damage / 100 + (randint0(100) < (damage % 100));
95 if (creature_ptr->levitation) {
96 msg_print(_("熱で火傷した!", "The heat burns you!"));
97 take_hit(creature_ptr, DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"), f_name + f_info[get_feat_mimic(&creature_ptr->current_floor_ptr->grid_array[creature_ptr->y][creature_ptr->x])].name), -1);
99 concptr name = f_name + f_info[get_feat_mimic(&creature_ptr->current_floor_ptr->grid_array[creature_ptr->y][creature_ptr->x])].name;
100 msg_format(_("%sで火傷した!", "The %s burns you!"), name);
101 take_hit(creature_ptr, DAMAGE_NOESCAPE, damage, name, -1);
104 cave_no_regen = TRUE;
108 if (have_flag(f_ptr->flags, FF_COLD_PUDDLE) && !IS_INVULN(creature_ptr) && !creature_ptr->immune_cold) {
111 if (have_flag(f_ptr->flags, FF_DEEP)) {
112 damage = 6000 + randint0(4000);
113 } else if (!creature_ptr->levitation) {
114 damage = 3000 + randint0(2000);
118 if (creature_ptr->resist_cold)
120 if (is_oppose_cold(creature_ptr))
122 if (creature_ptr->levitation)
125 damage = damage / 100 + (randint0(100) < (damage % 100));
127 if (creature_ptr->levitation) {
128 msg_print(_("冷気に覆われた!", "The cold engulfs you!"));
129 take_hit(creature_ptr, DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"), f_name + f_info[get_feat_mimic(&creature_ptr->current_floor_ptr->grid_array[creature_ptr->y][creature_ptr->x])].name), -1);
131 concptr name = f_name + f_info[get_feat_mimic(&creature_ptr->current_floor_ptr->grid_array[creature_ptr->y][creature_ptr->x])].name;
132 msg_format(_("%sに凍えた!", "The %s frostbites you!"), name);
133 take_hit(creature_ptr, DAMAGE_NOESCAPE, damage, name, -1);
136 cave_no_regen = TRUE;
140 if (have_flag(f_ptr->flags, FF_ELEC_PUDDLE) && !IS_INVULN(creature_ptr) && !creature_ptr->immune_elec) {
143 if (have_flag(f_ptr->flags, FF_DEEP)) {
144 damage = 6000 + randint0(4000);
145 } else if (!creature_ptr->levitation) {
146 damage = 3000 + randint0(2000);
150 if (creature_ptr->resist_elec)
152 if (is_oppose_elec(creature_ptr))
154 if (creature_ptr->levitation)
157 damage = damage / 100 + (randint0(100) < (damage % 100));
159 if (creature_ptr->levitation) {
160 msg_print(_("電撃を受けた!", "The electricity shocks you!"));
161 take_hit(creature_ptr, DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"), f_name + f_info[get_feat_mimic(&creature_ptr->current_floor_ptr->grid_array[creature_ptr->y][creature_ptr->x])].name), -1);
163 concptr name = f_name + f_info[get_feat_mimic(&creature_ptr->current_floor_ptr->grid_array[creature_ptr->y][creature_ptr->x])].name;
164 msg_format(_("%sに感電した!", "The %s shocks you!"), name);
165 take_hit(creature_ptr, DAMAGE_NOESCAPE, damage, name, -1);
168 cave_no_regen = TRUE;
172 if (have_flag(f_ptr->flags, FF_ACID_PUDDLE) && !IS_INVULN(creature_ptr) && !creature_ptr->immune_acid) {
175 if (have_flag(f_ptr->flags, FF_DEEP)) {
176 damage = 6000 + randint0(4000);
177 } else if (!creature_ptr->levitation) {
178 damage = 3000 + randint0(2000);
182 if (creature_ptr->resist_acid)
184 if (is_oppose_acid(creature_ptr))
186 if (creature_ptr->levitation)
189 damage = damage / 100 + (randint0(100) < (damage % 100));
191 if (creature_ptr->levitation) {
192 msg_print(_("酸が飛び散った!", "The acid melts you!"));
193 take_hit(creature_ptr, DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"), f_name + f_info[get_feat_mimic(&creature_ptr->current_floor_ptr->grid_array[creature_ptr->y][creature_ptr->x])].name), -1);
195 concptr name = f_name + f_info[get_feat_mimic(&creature_ptr->current_floor_ptr->grid_array[creature_ptr->y][creature_ptr->x])].name;
196 msg_format(_("%sに溶かされた!", "The %s melts you!"), name);
197 take_hit(creature_ptr, DAMAGE_NOESCAPE, damage, name, -1);
200 cave_no_regen = TRUE;
204 if (have_flag(f_ptr->flags, FF_POISON_PUDDLE) && !IS_INVULN(creature_ptr)) {
207 if (have_flag(f_ptr->flags, FF_DEEP)) {
208 damage = 6000 + randint0(4000);
209 } else if (!creature_ptr->levitation) {
210 damage = 3000 + randint0(2000);
214 if (creature_ptr->resist_pois)
216 if (is_oppose_pois(creature_ptr))
218 if (creature_ptr->levitation)
221 damage = damage / 100 + (randint0(100) < (damage % 100));
223 if (creature_ptr->levitation) {
224 msg_print(_("毒気を吸い込んだ!", "The gas poisons you!"));
225 take_hit(creature_ptr, DAMAGE_NOESCAPE, damage, format(_("%sの上に浮遊したダメージ", "flying over %s"), f_name + f_info[get_feat_mimic(&creature_ptr->current_floor_ptr->grid_array[creature_ptr->y][creature_ptr->x])].name), -1);
226 if (creature_ptr->resist_pois)
227 (void)set_poisoned(creature_ptr, creature_ptr->poisoned + 1);
229 concptr name = f_name + f_info[get_feat_mimic(&creature_ptr->current_floor_ptr->grid_array[creature_ptr->y][creature_ptr->x])].name;
230 msg_format(_("%sに毒された!", "The %s poisons you!"), name);
231 take_hit(creature_ptr, DAMAGE_NOESCAPE, damage, name, -1);
232 if (creature_ptr->resist_pois)
233 (void)set_poisoned(creature_ptr, creature_ptr->poisoned + 3);
236 cave_no_regen = TRUE;
240 if (have_flag(f_ptr->flags, FF_WATER) && have_flag(f_ptr->flags, FF_DEEP) && !creature_ptr->levitation && !creature_ptr->can_swim && !creature_ptr->resist_water) {
241 if (creature_ptr->total_weight > weight_limit(creature_ptr)) {
242 msg_print(_("溺れている!", "You are drowning!"));
243 take_hit(creature_ptr, DAMAGE_NOESCAPE, randint1(creature_ptr->lev), _("溺れ", "drowning"), -1);
244 cave_no_regen = TRUE;
248 if (creature_ptr->riding) {
250 if ((r_info[creature_ptr->current_floor_ptr->m_list[creature_ptr->riding].r_idx].flags2 & RF2_AURA_FIRE) && !creature_ptr->immune_fire) {
251 damage = r_info[creature_ptr->current_floor_ptr->m_list[creature_ptr->riding].r_idx].level / 2;
252 if (PRACE_IS_(creature_ptr, RACE_ENT))
253 damage += damage / 3;
254 if (creature_ptr->resist_fire)
256 if (is_oppose_fire(creature_ptr))
258 msg_print(_("熱い!", "It's hot!"));
259 take_hit(creature_ptr, DAMAGE_NOESCAPE, damage, _("炎のオーラ", "Fire aura"), -1);
261 if ((r_info[creature_ptr->current_floor_ptr->m_list[creature_ptr->riding].r_idx].flags2 & RF2_AURA_ELEC) && !creature_ptr->immune_elec) {
262 damage = r_info[creature_ptr->current_floor_ptr->m_list[creature_ptr->riding].r_idx].level / 2;
263 if (PRACE_IS_(creature_ptr, RACE_ANDROID))
264 damage += damage / 3;
265 if (creature_ptr->resist_elec)
267 if (is_oppose_elec(creature_ptr))
269 msg_print(_("痛い!", "It hurts!"));
270 take_hit(creature_ptr, DAMAGE_NOESCAPE, damage, _("電気のオーラ", "Elec aura"), -1);
272 if ((r_info[creature_ptr->current_floor_ptr->m_list[creature_ptr->riding].r_idx].flags3 & RF3_AURA_COLD) && !creature_ptr->immune_cold) {
273 damage = r_info[creature_ptr->current_floor_ptr->m_list[creature_ptr->riding].r_idx].level / 2;
274 if (creature_ptr->resist_cold)
276 if (is_oppose_cold(creature_ptr))
278 msg_print(_("冷たい!", "It's cold!"));
279 take_hit(creature_ptr, DAMAGE_NOESCAPE, damage, _("冷気のオーラ", "Cold aura"), -1);
283 /* Spectres -- take damage when moving through walls */
285 * Added: ANYBODY takes damage if inside through walls
286 * without wraith form -- NOTE: Spectres will never be
287 * reduced below 0 hp by being inside a stone wall; others
290 if (!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY)) {
291 if (!IS_INVULN(creature_ptr) && !creature_ptr->wraith_form && !creature_ptr->kabenuke && ((creature_ptr->chp > (creature_ptr->lev / 5)) || !creature_ptr->pass_wall)) {
293 cave_no_regen = TRUE;
295 if (creature_ptr->pass_wall) {
296 msg_print(_("体の分子が分解した気がする!", "Your molecules feel disrupted!"));
297 dam_desc = _("密度", "density");
299 msg_print(_("崩れた岩に押し潰された!", "You are being crushed!"));
300 dam_desc = _("硬い岩", "solid rock");
303 take_hit(creature_ptr, DAMAGE_NOESCAPE, 1 + (creature_ptr->lev / 5), dam_desc, -1);
307 if (creature_ptr->food < PY_FOOD_WEAK) {
308 if (creature_ptr->food < PY_FOOD_STARVE) {
310 } else if (creature_ptr->food < PY_FOOD_FAINT) {
311 regen_amount = PY_REGEN_FAINT;
313 regen_amount = PY_REGEN_WEAK;
317 if (pattern_effect(creature_ptr)) {
318 cave_no_regen = TRUE;
320 if (creature_ptr->regenerate) {
321 regen_amount = regen_amount * 2;
323 if (creature_ptr->special_defense & (KAMAE_MASK | KATA_MASK)) {
326 if (creature_ptr->cursed & TRC_SLOW_REGEN) {
331 if ((creature_ptr->action == ACTION_SEARCH) || (creature_ptr->action == ACTION_REST)) {
332 regen_amount = regen_amount * 2;
335 upkeep_factor = calculate_upkeep(creature_ptr);
336 if ((creature_ptr->action == ACTION_LEARN) || (creature_ptr->action == ACTION_HAYAGAKE) || (creature_ptr->special_defense & KATA_KOUKIJIN)) {
337 upkeep_factor += 100;
340 regenmana(creature_ptr, upkeep_factor, regen_amount);
341 if (creature_ptr->pclass == CLASS_MAGIC_EATER) {
342 regenmagic(creature_ptr, regen_amount);
345 if ((creature_ptr->csp == 0) && (creature_ptr->csp_frac == 0)) {
346 while (upkeep_factor > 100) {
347 msg_print(_("こんなに多くのペットを制御できない!", "Too many pets to control at once!"));
349 do_cmd_pet_dismiss(creature_ptr);
351 upkeep_factor = calculate_upkeep(creature_ptr);
353 msg_format(_("維持MPは %d%%", "Upkeep: %d%% mana."), upkeep_factor);
358 if (creature_ptr->poisoned)
360 if (creature_ptr->cut)
365 regen_amount = (regen_amount * creature_ptr->mutant_regenerate_mod) / 100;
366 if ((creature_ptr->chp < creature_ptr->mhp) && !cave_no_regen) {
367 regenhp(creature_ptr, regen_amount);