OSDN Git Service

[Refactor] #40274 Unified angband_music_basic_name[] into main/music-definitions...
[hengband/hengband.git] / src / player-damage.c
index d87d6ac..012412e 100644 (file)
@@ -1,10 +1,14 @@
 #include "angband.h"
 #include "core.h"
 #include "util.h"
-#include "term.h"
+#include "main/music-definitions-table.h"
+#include "gameterm.h"
 
 #include "avatar.h"
-#include "cmd-dump.h"
+#include "market/building.h"
+#include "io/write-diary.h"
+#include "cmd/cmd-dump.h"
+#include "market/arena-info-table.h"
 #include "realm-song.h"
 #include "floor.h"
 #include "artifact.h"
@@ -17,6 +21,7 @@
 #include "player-status.h"
 #include "player-effects.h"
 #include "player-class.h"
+#include "player-race.h"
 #include "monster-spell.h"
 #include "world.h"
 #include "view-mainwindow.h"
@@ -77,7 +82,7 @@ void inventory_damage(player_type *player_ptr, inven_func typ, int perc)
                /* Some casualities */
                if (!amt) continue;
                
-               object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
+               object_desc(player_ptr, o_name, o_ptr, OD_OMIT_PREFIX);
 
                msg_format(_("%s(%c)が%s壊れてしまった!", "%sour %s (%c) %s destroyed!"),
 #ifdef JP
@@ -89,7 +94,7 @@ void inventory_damage(player_type *player_ptr, inven_func typ, int perc)
 #endif
 
 #ifdef JP
-               if ((player_ptr->pseikaku == SEIKAKU_COMBAT) || (player_ptr->inventory_list[INVEN_BOW].name1 == ART_CRIMSON))
+               if (IS_ECHIZEN(player_ptr))
                        msg_print("やりやがったな!");
                else if ((player_ptr->pseikaku == SEIKAKU_CHARGEMAN))
                {
@@ -101,15 +106,15 @@ void inventory_damage(player_type *player_ptr, inven_func typ, int perc)
                /* Potions smash open */
                if (object_is_potion(o_ptr))
                {
-                       (void)potion_smash_effect(0, player_ptr->y, player_ptr->x, o_ptr->k_idx);
+                       (void)potion_smash_effect(player_ptr, 0, player_ptr->y, player_ptr->x, o_ptr->k_idx);
                }
 
                /* Reduce the charges of rods/wands */
                reduce_charges(o_ptr, amt);
 
                /* Destroy "amt" items */
-               inven_item_increase(i, -amt);
-               inven_item_optimize(i);
+               inven_item_increase(player_ptr, i, -amt);
+               inven_item_optimize(player_ptr, i);
        }
 }
 
@@ -141,23 +146,23 @@ static bool acid_minus_ac(player_type *creature_ptr)
        case 7: o_ptr = &creature_ptr->inventory_list[INVEN_FEET]; break;
        }
 
-       if (!o_ptr->k_idx) return (FALSE);
-       if (!object_is_armour(o_ptr)) return (FALSE);
+       if (!o_ptr->k_idx) return FALSE;
+       if (!object_is_armour(o_ptr)) return FALSE;
 
-       object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
+       object_desc(creature_ptr, o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
        object_flags(o_ptr, flgs);
        /* No damage left to be done */
        if (o_ptr->ac + o_ptr->to_a <= 0)
        {
-               msg_format(_("%sは既にボロボロだ!", "Your %s is already crumble!"), o_name);
-               return (FALSE);
+               msg_format(_("%sは既にボロボロだ!", "Your %s is already fully corroded!"), o_name);
+               return FALSE;
        }
 
        /* Object resists */
        if (have_flag(flgs, TR_IGNORE_ACID))
        {
                msg_format(_("しかし%sには効果がなかった!", "Your %s is unaffected!"), o_name);
-               return (TRUE);
+               return TRUE;
        }
 
        msg_format(_("%sが酸で腐食した!", "Your %s is corroded!"), o_name);
@@ -172,7 +177,7 @@ static bool acid_minus_ac(player_type *creature_ptr)
        calc_android_exp(creature_ptr);
 
        /* Item was damaged */
-       return (TRUE);
+       return TRUE;
 }
 
 
@@ -190,12 +195,12 @@ HIT_POINT acid_dam(player_type *creature_ptr, HIT_POINT dam, concptr kb_str, int
 {
        HIT_POINT get_damage;
        int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
-       bool double_resist = IS_OPPOSE_ACID();
+       bool double_resist = is_oppose_acid(creature_ptr);
 
        /* Total Immunity */
        if (creature_ptr->immune_acid || (dam <= 0))
        {
-               learn_spell(monspell);
+               learn_spell(creature_ptr, monspell);
                return 0;
        }
 
@@ -240,12 +245,12 @@ HIT_POINT elec_dam(player_type *creature_ptr, HIT_POINT dam, concptr kb_str, int
 {
        HIT_POINT get_damage;
        int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
-       bool double_resist = IS_OPPOSE_ELEC();
+       bool double_resist = is_oppose_elec(creature_ptr);
 
        /* Total immunity */
        if (creature_ptr->immune_elec || (dam <= 0))
        {
-               learn_spell(monspell);
+               learn_spell(creature_ptr, monspell);
                return 0;
        }
 
@@ -289,12 +294,12 @@ HIT_POINT fire_dam(player_type *creature_ptr, HIT_POINT dam, concptr kb_str, int
 {
        HIT_POINT get_damage;
        int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
-       bool double_resist = IS_OPPOSE_FIRE();
+       bool double_resist = is_oppose_fire(creature_ptr);
 
        /* Totally immune */
        if (creature_ptr->immune_fire || (dam <= 0))
        {
-               learn_spell(monspell);
+               learn_spell(creature_ptr, monspell);
                return 0;
        }
 
@@ -338,12 +343,12 @@ HIT_POINT cold_dam(player_type *creature_ptr, HIT_POINT dam, concptr kb_str, int
 {
        HIT_POINT get_damage;
        int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
-       bool double_resist = IS_OPPOSE_COLD();
+       bool double_resist = is_oppose_cold(creature_ptr);
 
        /* Total immunity */
        if (creature_ptr->immune_cold || (dam <= 0))
        {
-               learn_spell(monspell);
+               learn_spell(creature_ptr, monspell);
                return 0;
        }
 
@@ -406,7 +411,7 @@ int take_hit(player_type *creature_ptr, int damage_type, HIT_POINT damage, concp
                }
        }
 
-       if (monspell >= 0) learn_spell(monspell);
+       if (monspell >= 0) learn_spell(creature_ptr, monspell);
 
        /* Mega-Hack -- Apply "invulnerability" */
        if ((damage_type != DAMAGE_USELIFE) && (damage_type != DAMAGE_LOSELIFE))
@@ -435,7 +440,7 @@ int take_hit(player_type *creature_ptr, int damage_type, HIT_POINT damage, concp
                        }
                        else if (damage_type == DAMAGE_ATTACK)
                        {
-                               msg_print(_("攻撃は幻影に命中し、あなたには届かなかった。", "The attack hits Shadow, you are unharmed!"));
+                               msg_print(_("攻撃は幻影に命中し、あなたには届かなかった。", "The attack hits Shadow, but you are unharmed!"));
                                return 0;
                        }
                }
@@ -484,16 +489,17 @@ int take_hit(player_type *creature_ptr, int damage_type, HIT_POINT damage, concp
        {
                bool android = (creature_ptr->prace == RACE_ANDROID ? TRUE : FALSE);
 
-#ifdef JP       /* 死んだ時に強制終了して死を回避できなくしてみた by Habu */
+#ifdef JP
+               /* 死んだ時に強制終了して死を回避できなくしてみた by Habu */
                if (!cheat_save)
-                       if (!save_player()) msg_print("セーブ失敗!");
+                       if (!save_player(creature_ptr)) msg_print("セーブ失敗!");
 #endif
 
                sound(SOUND_DEATH);
 
                chg_virtue(creature_ptr, V_SACRIFICE, 10);
 
-               handle_stuff();
+               handle_stuff(creature_ptr);
                creature_ptr->leaving = TRUE;
 
                /* Note death */
@@ -504,11 +510,11 @@ int take_hit(player_type *creature_ptr, int damage_type, HIT_POINT damage, concp
                        concptr m_name = r_name + r_info[arena_info[creature_ptr->arena_number].r_idx].name;
                        msg_format(_("あなたは%sの前に敗れ去った。", "You are beaten by %s."), m_name);
                        msg_print(NULL);
-                       if (record_arena) exe_write_diary(creature_ptr, NIKKI_ARENA, -1 - creature_ptr->arena_number, m_name);
+                       if (record_arena) exe_write_diary(creature_ptr, DIARY_ARENA, -1 - creature_ptr->arena_number, m_name);
                }
                else
                {
-                       QUEST_IDX q_idx = quest_number(creature_ptr->current_floor_ptr->dun_level);
+                       QUEST_IDX q_idx = quest_number(creature_ptr, creature_ptr->current_floor_ptr->dun_level);
                        bool seppuku = streq(hit_from, "Seppuku");
                        bool winning_seppuku = current_world_ptr->total_winner && seppuku;
 
@@ -543,7 +549,7 @@ int take_hit(player_type *creature_ptr, int damage_type, HIT_POINT damage, concp
 
                        if (winning_seppuku)
                        {
-                               exe_write_diary(creature_ptr, NIKKI_BUNSHOU, 0, _("勝利の後切腹した。", "did Seppuku after the winning."));
+                               exe_write_diary(creature_ptr, DIARY_DESCRIPTION, 0, _("勝利の後切腹した。", "committed seppuku after the winning."));
                        }
                        else
                        {
@@ -560,11 +566,11 @@ int take_hit(player_type *creature_ptr, int damage_type, HIT_POINT damage, concp
                                        sprintf(buf, _("%d階", "level %d"), (int)creature_ptr->current_floor_ptr->dun_level);
 
                                sprintf(tmp, _("%sで%sに殺された。", "killed by %s %s."), buf, creature_ptr->died_from);
-                               exe_write_diary(creature_ptr, NIKKI_BUNSHOU, 0, tmp);
+                               exe_write_diary(creature_ptr, DIARY_DESCRIPTION, 0, tmp);
                        }
 
-                       exe_write_diary(creature_ptr, NIKKI_GAMESTART, 1, _("-------- ゲームオーバー --------", "--------   Game  Over   --------"));
-                       exe_write_diary(creature_ptr, NIKKI_BUNSHOU, 1, "\n\n\n\n");
+                       exe_write_diary(creature_ptr, DIARY_GAMESTART, 1, _("-------- ゲームオーバー --------", "--------   Game  Over   --------"));
+                       exe_write_diary(creature_ptr, DIARY_DESCRIPTION, 1, "\n\n\n\n");
 
                        flush();
 
@@ -683,7 +689,7 @@ int take_hit(player_type *creature_ptr, int damage_type, HIT_POINT damage, concp
                return damage;
        }
 
-       handle_stuff();
+       handle_stuff(creature_ptr);
 
        /* Hitpoint warning */
        if (creature_ptr->chp < warning)
@@ -698,8 +704,8 @@ int take_hit(player_type *creature_ptr, int damage_type, HIT_POINT damage, concp
                        if (creature_ptr->image && damage_type == DAMAGE_ATTACK)
                                hit_from = _("何か", "something");
 
-                       sprintf(tmp, _("%sによってピンチに陥った。", "A critical situation because of %s."), hit_from);
-                       exe_write_diary(creature_ptr, NIKKI_BUNSHOU, 0, tmp);
+                       sprintf(tmp, _("%sによってピンチに陥った。", "was in a critical situation because of %s."), hit_from);
+                       exe_write_diary(creature_ptr, DIARY_DESCRIPTION, 0, tmp);
                }
 
                if (auto_more)