4 #include "main/music-definitions-table.h"
5 #include "main/sound-definitions-table.h"
9 #include "market/building.h"
10 #include "io/write-diary.h"
11 #include "autopick/autopick-pref-processor.h"
12 #include "cmd/cmd-process-screen.h"
13 #include "market/arena-info-table.h"
14 #include "realm-song.h"
17 #include "object-flavor.h"
18 #include "object-hook.h"
19 #include "object-broken.h"
20 #include "player-move.h"
21 #include "player-damage.h"
22 #include "player-personality.h"
23 #include "player-status.h"
24 #include "player-effects.h"
25 #include "player-class.h"
26 #include "player-race.h"
27 #include "monster-spell.h"
29 #include "view/display-main-window.h"
37 * @brief アイテムを指定確率で破損させる /
38 * Destroys a type of item on a given percent chance
39 * @param player_ptr プレーヤーへの参照ポインタ
40 * @param typ 破損判定関数ポインタ
44 * Note that missiles are no longer necessarily all destroyed
45 * Destruction taken from "melee.c" code for "stealing".
46 * New-style wands and rods handled correctly. -LM-
48 void inventory_damage(player_type *player_ptr, inven_func typ, int perc)
53 GAME_TEXT o_name[MAX_NLEN];
55 if (CHECK_MULTISHADOW(player_ptr) || player_ptr->current_floor_ptr->inside_arena) return;
57 /* Scan through the slots backwards */
58 for (i = 0; i < INVEN_PACK; i++)
60 o_ptr = &player_ptr->inventory_list[i];
61 if (!o_ptr->k_idx) continue;
63 /* Hack -- for now, skip artifacts */
64 if (object_is_artifact(o_ptr)) continue;
66 /* Give this item slot a shot at death */
67 if (!(*typ)(o_ptr)) continue;
69 /* Count the casualties */
70 for (amt = j = 0; j < o_ptr->number; ++j)
72 if (randint0(100) < perc) amt++;
75 /* Some casualities */
78 object_desc(player_ptr, o_name, o_ptr, OD_OMIT_PREFIX);
80 msg_format(_("%s(%c)が%s壊れてしまった!", "%sour %s (%c) %s destroyed!"),
82 o_name, index_to_label(i), ((o_ptr->number > 1) ?
83 ((amt == o_ptr->number) ? "全部" : (amt > 1 ? "何個か" : "一個")) : ""));
85 ((o_ptr->number > 1) ? ((amt == o_ptr->number) ? "All of y" :
86 (amt > 1 ? "Some of y" : "One of y")) : "Y"), o_name, index_to_label(i), ((amt > 1) ? "were" : "was"));
90 if (IS_ECHIZEN(player_ptr))
91 msg_print("やりやがったな!");
92 else if ((player_ptr->pseikaku == SEIKAKU_CHARGEMAN))
94 if (randint0(2) == 0) msg_print(_("ジュラル星人め!", ""));
95 else msg_print(_("弱い者いじめは止めるんだ!", ""));
99 /* Potions smash open */
100 if (object_is_potion(o_ptr))
102 (void)potion_smash_effect(player_ptr, 0, player_ptr->y, player_ptr->x, o_ptr->k_idx);
105 /* Reduce the charges of rods/wands */
106 reduce_charges(o_ptr, amt);
108 /* Destroy "amt" items */
109 inven_item_increase(player_ptr, i, -amt);
110 inven_item_optimize(player_ptr, i);
116 * @brief 酸攻撃による装備のAC劣化処理 /
117 * Acid has hit the player, attempt to affect some armor.
118 * @param 酸を浴びたキャラクタへの参照ポインタ
119 * @return 装備による軽減があったならTRUEを返す
121 * Note that the "base armor" of an object never changes.
122 * If any armor is damaged (or resists), the player takes less damage.
124 static bool acid_minus_ac(player_type *creature_ptr)
126 object_type *o_ptr = NULL;
127 BIT_FLAGS flgs[TR_FLAG_SIZE];
128 GAME_TEXT o_name[MAX_NLEN];
130 /* Pick a (possibly empty) creature_ptr->inventory_list slot */
133 case 1: o_ptr = &creature_ptr->inventory_list[INVEN_RARM]; break;
134 case 2: o_ptr = &creature_ptr->inventory_list[INVEN_LARM]; break;
135 case 3: o_ptr = &creature_ptr->inventory_list[INVEN_BODY]; break;
136 case 4: o_ptr = &creature_ptr->inventory_list[INVEN_OUTER]; break;
137 case 5: o_ptr = &creature_ptr->inventory_list[INVEN_HANDS]; break;
138 case 6: o_ptr = &creature_ptr->inventory_list[INVEN_HEAD]; break;
139 case 7: o_ptr = &creature_ptr->inventory_list[INVEN_FEET]; break;
142 if (!o_ptr->k_idx) return FALSE;
143 if (!object_is_armour(o_ptr)) return FALSE;
145 object_desc(creature_ptr, o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
146 object_flags(o_ptr, flgs);
147 /* No damage left to be done */
148 if (o_ptr->ac + o_ptr->to_a <= 0)
150 msg_format(_("%sは既にボロボロだ!", "Your %s is already fully corroded!"), o_name);
155 if (have_flag(flgs, TR_IGNORE_ACID))
157 msg_format(_("しかし%sには効果がなかった!", "Your %s is unaffected!"), o_name);
161 msg_format(_("%sが酸で腐食した!", "Your %s is corroded!"), o_name);
163 /* Damage the item */
166 /* Calculate bonuses */
167 creature_ptr->update |= (PU_BONUS);
168 creature_ptr->window |= (PW_EQUIP | PW_PLAYER);
170 calc_android_exp(creature_ptr);
172 /* Item was damaged */
178 * @brief 酸属性によるプレイヤー損害処理 /
179 * Hurt the player with Acid
180 * @param creature_ptr 酸を浴びたキャラクタへの参照ポインタ
182 * @param kb_str ダメージ原因記述
183 * @param monspell 原因となったモンスター特殊攻撃ID
184 * @param aura オーラよるダメージが原因ならばTRUE
187 HIT_POINT acid_dam(player_type *creature_ptr, HIT_POINT dam, concptr kb_str, int monspell, bool aura)
189 HIT_POINT get_damage;
190 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
191 bool double_resist = is_oppose_acid(creature_ptr);
194 if (creature_ptr->immune_acid || (dam <= 0))
196 learn_spell(creature_ptr, monspell);
200 /* Vulnerability (Ouch!) */
201 if (creature_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
202 if (creature_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
204 /* Resist the damage */
205 if (creature_ptr->resist_acid) dam = (dam + 2) / 3;
206 if (double_resist) dam = (dam + 2) / 3;
208 if (aura || !CHECK_MULTISHADOW(creature_ptr))
210 if ((!(double_resist || creature_ptr->resist_acid)) &&
211 one_in_(HURT_CHANCE))
212 (void)do_dec_stat(creature_ptr, A_CHR);
214 /* If any armor gets hit, defend the player */
215 if (acid_minus_ac(creature_ptr)) dam = (dam + 1) / 2;
218 get_damage = take_hit(creature_ptr, aura ? DAMAGE_NOESCAPE : DAMAGE_ATTACK, dam, kb_str, monspell);
220 /* Inventory damage */
221 if (!aura && !(double_resist && creature_ptr->resist_acid))
222 inventory_damage(creature_ptr, set_acid_destroy, inv);
228 * @brief 電撃属性によるプレイヤー損害処理 /
229 * Hurt the player with electricity
230 * @param creature_ptr 電撃を浴びたキャラクタへの参照ポインタ
232 * @param kb_str ダメージ原因記述
233 * @param monspell 原因となったモンスター特殊攻撃ID
234 * @param aura オーラよるダメージが原因ならばTRUE
237 HIT_POINT elec_dam(player_type *creature_ptr, HIT_POINT dam, concptr kb_str, int monspell, bool aura)
239 HIT_POINT get_damage;
240 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
241 bool double_resist = is_oppose_elec(creature_ptr);
244 if (creature_ptr->immune_elec || (dam <= 0))
246 learn_spell(creature_ptr, monspell);
250 /* Vulnerability (Ouch!) */
251 if (creature_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
252 if (creature_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
253 if (PRACE_IS_(creature_ptr, RACE_ANDROID)) dam += dam / 3;
255 /* Resist the damage */
256 if (creature_ptr->resist_elec) dam = (dam + 2) / 3;
257 if (double_resist) dam = (dam + 2) / 3;
259 if (aura || !CHECK_MULTISHADOW(creature_ptr))
261 if ((!(double_resist || creature_ptr->resist_elec)) &&
262 one_in_(HURT_CHANCE))
263 (void)do_dec_stat(creature_ptr, A_DEX);
266 get_damage = take_hit(creature_ptr, aura ? DAMAGE_NOESCAPE : DAMAGE_ATTACK, dam, kb_str, monspell);
268 /* Inventory damage */
269 if (!aura && !(double_resist && creature_ptr->resist_elec))
270 inventory_damage(creature_ptr, set_elec_destroy, inv);
277 * @brief 火炎属性によるプレイヤー損害処理 /
278 * Hurt the player with Fire
279 * @param creature_ptr 火炎を浴びたキャラクタへの参照ポインタ
281 * @param kb_str ダメージ原因記述
282 * @param monspell 原因となったモンスター特殊攻撃ID
283 * @param aura オーラよるダメージが原因ならばTRUE
286 HIT_POINT fire_dam(player_type *creature_ptr, HIT_POINT dam, concptr kb_str, int monspell, bool aura)
288 HIT_POINT get_damage;
289 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
290 bool double_resist = is_oppose_fire(creature_ptr);
293 if (creature_ptr->immune_fire || (dam <= 0))
295 learn_spell(creature_ptr, monspell);
299 /* Vulnerability (Ouch!) */
300 if (creature_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
301 if (PRACE_IS_(creature_ptr, RACE_ENT)) dam += dam / 3;
302 if (creature_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
304 /* Resist the damage */
305 if (creature_ptr->resist_fire) dam = (dam + 2) / 3;
306 if (double_resist) dam = (dam + 2) / 3;
308 if (aura || !CHECK_MULTISHADOW(creature_ptr))
310 if ((!(double_resist || creature_ptr->resist_fire)) &&
311 one_in_(HURT_CHANCE))
312 (void)do_dec_stat(creature_ptr, A_STR);
315 get_damage = take_hit(creature_ptr, aura ? DAMAGE_NOESCAPE : DAMAGE_ATTACK, dam, kb_str, monspell);
317 /* Inventory damage */
318 if (!aura && !(double_resist && creature_ptr->resist_fire))
319 inventory_damage(creature_ptr, set_fire_destroy, inv);
326 * @brief 冷気属性によるプレイヤー損害処理 /
327 * Hurt the player with Cold
328 * @param creature_ptr 冷気を浴びたキャラクタへの参照ポインタ
330 * @param kb_str ダメージ原因記述
331 * @param monspell 原因となったモンスター特殊攻撃ID
332 * @param aura オーラよるダメージが原因ならばTRUE
335 HIT_POINT cold_dam(player_type *creature_ptr, HIT_POINT dam, concptr kb_str, int monspell, bool aura)
337 HIT_POINT get_damage;
338 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
339 bool double_resist = is_oppose_cold(creature_ptr);
342 if (creature_ptr->immune_cold || (dam <= 0))
344 learn_spell(creature_ptr, monspell);
348 /* Vulnerability (Ouch!) */
349 if (creature_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
350 if (creature_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
352 /* Resist the damage */
353 if (creature_ptr->resist_cold) dam = (dam + 2) / 3;
354 if (double_resist) dam = (dam + 2) / 3;
356 if (aura || !CHECK_MULTISHADOW(creature_ptr))
358 if ((!(double_resist || creature_ptr->resist_cold)) &&
359 one_in_(HURT_CHANCE))
360 (void)do_dec_stat(creature_ptr, A_STR);
363 get_damage = take_hit(creature_ptr, aura ? DAMAGE_NOESCAPE : DAMAGE_ATTACK, dam, kb_str, monspell);
365 /* Inventory damage */
366 if (!aura && !(double_resist && creature_ptr->resist_cold))
367 inventory_damage(creature_ptr, set_cold_destroy, inv);
374 * Decreases players hit points and sets death flag if necessary
376 * Invulnerability needs to be changed into a "shield"
378 * Hack -- this function allows the user to save (or quit)
379 * the game when he dies, since the "You die." message is shown before
380 * setting the player to "dead".
382 int take_hit(player_type *creature_ptr, int damage_type, HIT_POINT damage, concptr hit_from, int monspell)
384 int old_chp = creature_ptr->chp;
386 char death_message[1024];
389 int warning = (creature_ptr->mhp * hitpoint_warn / 10);
390 if (creature_ptr->is_dead) return 0;
392 if (creature_ptr->sutemi) damage *= 2;
393 if (creature_ptr->special_defense & KATA_IAI) damage += (damage + 4) / 5;
395 if (easy_band) damage = (damage + 1) / 2;
397 if (damage_type != DAMAGE_USELIFE)
399 disturb(creature_ptr, TRUE, TRUE);
402 creature_ptr->now_damaged = TRUE;
406 if (monspell >= 0) learn_spell(creature_ptr, monspell);
408 /* Mega-Hack -- Apply "invulnerability" */
409 if ((damage_type != DAMAGE_USELIFE) && (damage_type != DAMAGE_LOSELIFE))
411 if (IS_INVULN(creature_ptr) && (damage < 9000))
413 if (damage_type == DAMAGE_FORCE)
415 msg_print(_("バリアが切り裂かれた!", "The attack cuts your shield of invulnerability open!"));
417 else if (one_in_(PENETRATE_INVULNERABILITY))
419 msg_print(_("無敵のバリアを破って攻撃された!", "The attack penetrates your shield of invulnerability!"));
427 if (CHECK_MULTISHADOW(creature_ptr))
429 if (damage_type == DAMAGE_FORCE)
431 msg_print(_("幻影もろとも体が切り裂かれた!", "The attack hits Shadow together with you!"));
433 else if (damage_type == DAMAGE_ATTACK)
435 msg_print(_("攻撃は幻影に命中し、あなたには届かなかった。", "The attack hits Shadow, but you are unharmed!"));
440 if (creature_ptr->wraith_form)
442 if (damage_type == DAMAGE_FORCE)
444 msg_print(_("半物質の体が切り裂かれた!", "The attack cuts through your ethereal body!"));
449 if ((damage == 0) && one_in_(2)) damage = 1;
453 if (creature_ptr->special_defense & KATA_MUSOU)
456 if ((damage == 0) && one_in_(2)) damage = 1;
458 } /* not if LOSELIFE USELIFE */
460 /* Hurt the player */
461 creature_ptr->chp -= damage;
462 if (damage_type == DAMAGE_GENO && creature_ptr->chp < 0)
464 damage += creature_ptr->chp;
465 creature_ptr->chp = 0;
468 /* Display the hitpoints */
469 creature_ptr->redraw |= (PR_HP);
471 creature_ptr->window |= (PW_PLAYER);
473 if (damage_type != DAMAGE_GENO && creature_ptr->chp == 0)
475 chg_virtue(creature_ptr, V_SACRIFICE, 1);
476 chg_virtue(creature_ptr, V_CHANCE, 2);
480 if (creature_ptr->chp < 0)
482 bool android = (creature_ptr->prace == RACE_ANDROID ? TRUE : FALSE);
485 /* 死んだ時に強制終了して死を回避できなくしてみた by Habu */
487 if (!save_player(creature_ptr)) msg_print("セーブ失敗!");
492 chg_virtue(creature_ptr, V_SACRIFICE, 10);
494 handle_stuff(creature_ptr);
495 creature_ptr->leaving = TRUE;
498 creature_ptr->is_dead = TRUE;
500 if (creature_ptr->current_floor_ptr->inside_arena)
502 concptr m_name = r_name + r_info[arena_info[creature_ptr->arena_number].r_idx].name;
503 msg_format(_("あなたは%sの前に敗れ去った。", "You are beaten by %s."), m_name);
505 if (record_arena) exe_write_diary(creature_ptr, DIARY_ARENA, -1 - creature_ptr->arena_number, m_name);
509 QUEST_IDX q_idx = quest_number(creature_ptr, creature_ptr->current_floor_ptr->dun_level);
510 bool seppuku = streq(hit_from, "Seppuku");
511 bool winning_seppuku = current_world_ptr->total_winner && seppuku;
513 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_GAMEOVER);
516 /* Make screen dump */
517 screen_dump = make_screen_dump(creature_ptr, process_autopick_file_command);
520 /* Note cause of death */
523 strcpy(creature_ptr->died_from, hit_from);
525 if (!winning_seppuku) strcpy(creature_ptr->died_from, "切腹");
532 sprintf(dummy, "%s%s%s", !creature_ptr->paralyzed ? "" : creature_ptr->free_act ? "彫像状態で" : "麻痺状態で", creature_ptr->image ? "幻覚に歪んだ" : "", hit_from);
534 sprintf(dummy, "%s%s", hit_from, !creature_ptr->paralyzed ? "" : " while helpless");
536 my_strcpy(creature_ptr->died_from, dummy, sizeof creature_ptr->died_from);
539 /* No longer a winner */
540 current_world_ptr->total_winner = FALSE;
544 exe_write_diary(creature_ptr, DIARY_DESCRIPTION, 0, _("勝利の後切腹した。", "committed seppuku after the winning."));
550 if (creature_ptr->current_floor_ptr->inside_arena)
551 strcpy(buf, _("アリーナ", "in the Arena"));
552 else if (!creature_ptr->current_floor_ptr->dun_level)
553 strcpy(buf, _("地上", "on the surface"));
554 else if (q_idx && (is_fixed_quest_idx(q_idx) &&
555 !((q_idx == QUEST_OBERON) || (q_idx == QUEST_SERPENT))))
556 strcpy(buf, _("クエスト", "in a quest"));
558 sprintf(buf, _("%d階", "level %d"), (int)creature_ptr->current_floor_ptr->dun_level);
560 sprintf(tmp, _("%sで%sに殺された。", "killed by %s %s."), buf, creature_ptr->died_from);
561 exe_write_diary(creature_ptr, DIARY_DESCRIPTION, 0, tmp);
564 exe_write_diary(creature_ptr, DIARY_GAMESTART, 1, _("-------- ゲームオーバー --------", "-------- Game Over --------"));
565 exe_write_diary(creature_ptr, DIARY_DESCRIPTION, 1, "\n\n\n\n");
569 if (get_check_strict(_("画面を保存しますか?", "Dump the screen? "), CHECK_NO_HISTORY))
571 do_cmd_save_screen(creature_ptr, handle_stuff, process_autopick_file_command);
576 /* Initialize "last message" buffer */
577 if (creature_ptr->last_message) string_free(creature_ptr->last_message);
578 creature_ptr->last_message = NULL;
580 /* Hack -- Note death */
584 msg_format("あなたは%sました。", android ? "壊れ" : "死に");
586 msg_print(android ? "You are broken." : "You die.");
595 get_rnd_line(_("seppuku_j.txt", "seppuku.txt"), 0, death_message);
599 get_rnd_line(_("death_j.txt", "death.txt"), 0, death_message);
605 while (!get_string(winning_seppuku ? "辞世の句: " : "断末魔の叫び: ", death_message, 1024));
607 while (!get_string("Last word: ", death_message, 1024));
609 } while (winning_seppuku && !get_check_strict(_("よろしいですか?", "Are you sure? "), CHECK_NO_HISTORY));
611 if (death_message[0] == '\0')
614 strcpy(death_message, format("あなたは%sました。", android ? "壊れ" : "死に"));
616 strcpy(death_message, android ? "You are broken." : "You die.");
619 else creature_ptr->last_message = string_make(death_message);
627 int msg_pos_x[9] = { 5, 7, 9, 12, 14, 17, 19, 21, 23 };
628 int msg_pos_y[9] = { 3, 4, 5, 4, 5, 4, 5, 6, 4 };
635 for (i = 0; i < 40; i++)
636 Term_putstr(randint0(w / 2) * 2, randint0(h), 2, TERM_VIOLET, "υ");
639 if (strncmp(str, "「", 2) == 0) str += 2;
641 str2 = my_strstr(str, "」");
642 if (str2 != NULL) *str2 = '\0';
647 str2 = my_strstr(str, " ");
648 if (str2 == NULL) len = strlen(str);
649 else len = str2 - str;
653 Term_putstr_v(w * 3 / 4 - 2 - msg_pos_x[i] * 2, msg_pos_y[i], len,
655 if (str2 == NULL) break;
659 if (*str == 0) break;
663 Term_putstr(w - 1, h - 1, 1, TERM_WHITE, " ");
667 /* Make screen dump */
668 screen_dump = make_screen_dump(creature_ptr, process_autopick_file_command);
671 /* Wait a key press */
676 msg_print(death_message);
684 handle_stuff(creature_ptr);
686 /* Hitpoint warning */
687 if (creature_ptr->chp < warning)
689 /* Hack -- bell on first notice */
690 if (old_chp > warning) bell();
694 if (record_danger && (old_chp > warning))
696 if (creature_ptr->image && damage_type == DAMAGE_ATTACK)
697 hit_from = _("何か", "something");
699 sprintf(tmp, _("%sによってピンチに陥った。", "was in a critical situation because of %s."), hit_from);
700 exe_write_diary(creature_ptr, DIARY_DESCRIPTION, 0, tmp);
705 /* stop auto_more even if DAMAGE_USELIFE */
706 creature_ptr->now_damaged = TRUE;
709 msg_print(_("*** 警告:低ヒット・ポイント! ***", "*** LOW HITPOINT WARNING! ***"));
713 if (creature_ptr->wild_mode && !creature_ptr->leaving && (creature_ptr->chp < MAX(warning, creature_ptr->mhp / 5)))
715 change_wild_mode(creature_ptr, FALSE);