OSDN Git Service

[Refactor] #38997 コード整形&player_type * 引数を追加 / Reshaped codes and added player_type...
authorHourier <hourier@users.sourceforge.jp>
Sat, 4 Jan 2020 14:24:38 +0000 (23:24 +0900)
committerHourier <hourier@users.sourceforge.jp>
Sat, 4 Jan 2020 14:24:38 +0000 (23:24 +0900)
src/combat/melee1.c
src/player-damage.c
src/player-damage.h
src/spells1.c
src/trap.c

index 834b20f..cb3796d 100644 (file)
@@ -1099,27 +1099,26 @@ static concptr desc_moan[] =
 * @param message オーラダメージを受けた際のメッセージ
 * @return なし
 */
-static void touch_zap_player_aux(monster_type *m_ptr, bool immune, int flags_offset, int r_flags_offset, u32b aura_flag,
-       HIT_POINT(*dam_func)(HIT_POINT dam, concptr kb_str, int monspell, bool aura), concptr message)
+static void touch_zap_player_aux(monster_type *m_ptr, player_type *touched_ptr, bool immune, int flags_offset, int r_flags_offset, u32b aura_flag,
+       HIT_POINT(*dam_func)(player_type *creature_type, HIT_POINT dam, concptr kb_str, int monspell, bool aura), concptr message)
 {
        monster_race *r_ptr = &r_info[m_ptr->r_idx];
 
-       if ((atoffset(BIT_FLAGS, r_ptr, flags_offset) & aura_flag) && !immune)
-       {
-               GAME_TEXT mon_name[MAX_NLEN];
-               int aura_damage = damroll(1 + (r_ptr->level / 26), 1 + (r_ptr->level / 17));
-
-               monster_desc(mon_name, m_ptr, MD_WRONGDOER_NAME);
-               msg_print(message);
-               dam_func(aura_damage, mon_name, -1, TRUE);
+       if (!(atoffset(BIT_FLAGS, r_ptr, flags_offset) & aura_flag) || immune) return;
+       
+       GAME_TEXT mon_name[MAX_NLEN];
+       int aura_damage = damroll(1 + (r_ptr->level / 26), 1 + (r_ptr->level / 17));
 
-               if (is_original_ap_and_seen(m_ptr))
-               {
-                       atoffset(BIT_FLAGS, r_ptr, r_flags_offset) |= aura_flag;
-               }
+       monster_desc(mon_name, m_ptr, MD_WRONGDOER_NAME);
+       msg_print(message);
+       dam_func(touched_ptr, aura_damage, mon_name, -1, TRUE);
 
-               handle_stuff();
+       if (is_original_ap_and_seen(m_ptr))
+       {
+               atoffset(BIT_FLAGS, r_ptr, r_flags_offset) |= aura_flag;
        }
+
+       handle_stuff();
 }
 
 /*!
@@ -1130,11 +1129,11 @@ static void touch_zap_player_aux(monster_type *m_ptr, bool immune, int flags_off
 */
 static void touch_zap_player(monster_type *m_ptr, player_type *touched_ptr)
 {
-       touch_zap_player_aux(m_ptr, touched_ptr->immune_fire, offsetof(monster_race, flags2), offsetof(monster_race, r_flags2), RF2_AURA_FIRE,
+       touch_zap_player_aux(m_ptr, touched_ptr, touched_ptr->immune_fire, offsetof(monster_race, flags2), offsetof(monster_race, r_flags2), RF2_AURA_FIRE,
                fire_dam, _("突然とても熱くなった!", "You are suddenly very hot!"));
-       touch_zap_player_aux(m_ptr, touched_ptr->immune_cold, offsetof(monster_race, flags3), offsetof(monster_race, r_flags3), RF3_AURA_COLD,
+       touch_zap_player_aux(m_ptr, touched_ptr, touched_ptr->immune_cold, offsetof(monster_race, flags3), offsetof(monster_race, r_flags3), RF3_AURA_COLD,
                cold_dam, _("突然とても寒くなった!", "You are suddenly very cold!"));
-       touch_zap_player_aux(m_ptr, touched_ptr->immune_elec, offsetof(monster_race, flags2), offsetof(monster_race, r_flags2), RF2_AURA_ELEC,
+       touch_zap_player_aux(m_ptr, touched_ptr, touched_ptr->immune_elec, offsetof(monster_race, flags2), offsetof(monster_race, r_flags2), RF2_AURA_ELEC,
                elec_dam, _("電撃をくらった!", "You get zapped!"));
 }
 
@@ -3134,7 +3133,7 @@ bool make_attack_normal(player_type *target_ptr, MONSTER_IDX m_idx)
                                        if (explode) break;
                                        obvious = TRUE;
                                        msg_print(_("酸を浴びせられた!", "You are covered in acid!"));
-                                       get_damage += acid_dam(damage, ddesc, -1, FALSE);
+                                       get_damage += acid_dam(target_ptr, damage, ddesc, -1, FALSE);
                                        update_creature(target_ptr);
                                        update_smart_learn(m_idx, DRS_ACID);
                                        break;
@@ -3145,7 +3144,7 @@ bool make_attack_normal(player_type *target_ptr, MONSTER_IDX m_idx)
                                        if (explode) break;
                                        obvious = TRUE;
                                        msg_print(_("電撃を浴びせられた!", "You are struck by electricity!"));
-                                       get_damage += elec_dam(damage, ddesc, -1, FALSE);
+                                       get_damage += elec_dam(target_ptr, damage, ddesc, -1, FALSE);
                                        update_smart_learn(m_idx, DRS_ELEC);
                                        break;
                                }
@@ -3155,7 +3154,7 @@ bool make_attack_normal(player_type *target_ptr, MONSTER_IDX m_idx)
                                        if (explode) break;
                                        obvious = TRUE;
                                        msg_print(_("全身が炎に包まれた!", "You are enveloped in flames!"));
-                                       get_damage += fire_dam(damage, ddesc, -1, FALSE);
+                                       get_damage += fire_dam(target_ptr, damage, ddesc, -1, FALSE);
                                        update_smart_learn(m_idx, DRS_FIRE);
                                        break;
                                }
@@ -3165,7 +3164,7 @@ bool make_attack_normal(player_type *target_ptr, MONSTER_IDX m_idx)
                                        if (explode) break;
                                        obvious = TRUE;
                                        msg_print(_("全身が冷気で覆われた!", "You are covered with frost!"));
-                                       get_damage += cold_dam(damage, ddesc, -1, FALSE);
+                                       get_damage += cold_dam(target_ptr, damage, ddesc, -1, FALSE);
                                        update_smart_learn(m_idx, DRS_COLD);
                                        break;
                                }
index 01e3f72..1f1a331 100644 (file)
 #include "files.h"
 
 
-
 /*!
-* @brief アイテムが指定確率で破損するかどうかを判定する /
+* todo 元々「破損したアイテムの数」をreturnしていました
+* しかし調査の結果、どの関数も戻り値を使用していませんでした
+* よって戻りをvoidとし、破損したアイテム数を計上しているローカル変数を削除しました
+* 確認後、問題がなければ本コメントを削除の上コミット願います by Hourier
+* そして英語のコメントにある「stealing」とは一体…
+* ***
+* @brief アイテムを指定確率で破損させる /
 * Destroys a type of item on a given percent chance
 * @param typ 破損判定関数ポインタ
 * @param perc 基本確率
-* @return 破損したアイテムの数
+* @return なし
 * @details
 * Note that missiles are no longer necessarily all destroyed
 * Destruction taken from "melee.c" code for "stealing".
 * New-style wands and rods handled correctly. -LM-
-* Returns number of items destroyed.
 */
-int inven_damage(inven_func typ, int perc)
+void inventory_damage(player_type *player_ptr, inven_func typ, int perc)
 {
        INVENTORY_IDX i;
-       int j, k, amt;
+       int j, amt;
        object_type *o_ptr;
        GAME_TEXT o_name[MAX_NLEN];
 
-       if (CHECK_MULTISHADOW(p_ptr)) return 0;
-
-       if (p_ptr->current_floor_ptr->inside_arena) return 0;
-
-       /* Count the casualties */
-       k = 0;
+       if (CHECK_MULTISHADOW(player_ptr) || player_ptr->current_floor_ptr->inside_arena) return;
 
        /* Scan through the slots backwards */
        for (i = 0; i < INVEN_PACK; i++)
        {
-               o_ptr = &p_ptr->inventory_list[i];
+               o_ptr = &player_ptr->inventory_list[i];
                if (!o_ptr->k_idx) continue;
 
                /* Hack -- for now, skip artifacts */
                if (object_is_artifact(o_ptr)) continue;
 
                /* Give this item slot a shot at death */
-               if ((*typ)(o_ptr))
+               if (!(*typ)(o_ptr)) continue;
+               
+               /* Count the casualties */
+               for (amt = j = 0; j < o_ptr->number; ++j)
                {
-                       /* Count the casualties */
-                       for (amt = j = 0; j < o_ptr->number; ++j)
-                       {
-                               if (randint0(100) < perc) amt++;
-                       }
+                       if (randint0(100) < perc) amt++;
+               }
 
-                       /* Some casualities */
-                       if (amt)
-                       {
-                               object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
+               /* Some casualities */
+               if (!amt) continue;
+               
+               object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
 
-                               msg_format(_("%s(%c)が%s壊れてしまった!", "%sour %s (%c) %s destroyed!"),
+               msg_format(_("%s(%c)が%s壊れてしまった!", "%sour %s (%c) %s destroyed!"),
 #ifdef JP
-                                       o_name, index_to_label(i), ((o_ptr->number > 1) ?
-                                               ((amt == o_ptr->number) ? "全部" : (amt > 1 ? "何個か" : "一個")) : ""));
+                       o_name, index_to_label(i), ((o_ptr->number > 1) ?
+                       ((amt == o_ptr->number) ? "全部" : (amt > 1 ? "何個か" : "一個")) : ""));
 #else
-                                       ((o_ptr->number > 1) ? ((amt == o_ptr->number) ? "All of y" :
-                                               (amt > 1 ? "Some of y" : "One of y")) : "Y"), o_name, index_to_label(i), ((amt > 1) ? "were" : "was"));
+                       ((o_ptr->number > 1) ? ((amt == o_ptr->number) ? "All of y" :
+                       (amt > 1 ? "Some of y" : "One of y")) : "Y"), o_name, index_to_label(i), ((amt > 1) ? "were" : "was"));
 #endif
 
 #ifdef JP
-                               if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (p_ptr->inventory_list[INVEN_BOW].name1 == ART_CRIMSON))
-                                       msg_print("やりやがったな!");
-                               else if ((p_ptr->pseikaku == SEIKAKU_CHARGEMAN))
-                               {
-                                       if (randint0(2) == 0) msg_print(_("ジュラル星人め!", ""));
-                                       else msg_print(_("弱い者いじめは止めるんだ!", ""));
-                               }
+               if ((player_ptr->pseikaku == SEIKAKU_COMBAT) || (player_ptr->inventory_list[INVEN_BOW].name1 == ART_CRIMSON))
+                       msg_print("やりやがったな!");
+               else if ((player_ptr->pseikaku == SEIKAKU_CHARGEMAN))
+               {
+                       if (randint0(2) == 0) msg_print(_("ジュラル星人め!", ""));
+                       else msg_print(_("弱い者いじめは止めるんだ!", ""));
+               }
 #endif
 
-                               /* Potions smash open */
-                               if (object_is_potion(o_ptr))
-                               {
-                                       (void)potion_smash_effect(0, p_ptr->y, p_ptr->x, o_ptr->k_idx);
-                               }
-
-                               /* Reduce the charges of rods/wands */
-                               reduce_charges(o_ptr, amt);
+               /* Potions smash open */
+               if (object_is_potion(o_ptr))
+               {
+                       (void)potion_smash_effect(0, player_ptr->y, player_ptr->x, o_ptr->k_idx);
+               }
 
-                               /* Destroy "amt" items */
-                               inven_item_increase(i, -amt);
-                               inven_item_optimize(i);
+               /* Reduce the charges of rods/wands */
+               reduce_charges(o_ptr, amt);
 
-                               /* Count the casualties */
-                               k += amt;
-                       }
-               }
+               /* Destroy "amt" items */
+               inven_item_increase(i, -amt);
+               inven_item_optimize(i);
        }
-
-       /* Return the casualty count */
-       return (k);
 }
 
 
@@ -190,42 +181,42 @@ static bool acid_minus_ac(player_type *creature_ptr)
 * @param aura オーラよるダメージが原因ならばTRUE
 * @return 修正HPダメージ量
 */
-HIT_POINT acid_dam(HIT_POINT dam, concptr kb_str, int monspell, bool aura)
+HIT_POINT acid_dam(player_type *creature_ptr, HIT_POINT dam, concptr kb_str, int monspell, bool aura)
 {
        HIT_POINT get_damage;
        int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
        bool double_resist = IS_OPPOSE_ACID();
 
        /* Total Immunity */
-       if (p_ptr->immune_acid || (dam <= 0))
+       if (creature_ptr->immune_acid || (dam <= 0))
        {
                learn_spell(monspell);
                return 0;
        }
 
        /* Vulnerability (Ouch!) */
-       if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
-       if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
+       if (creature_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
+       if (creature_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
 
        /* Resist the damage */
-       if (p_ptr->resist_acid) dam = (dam + 2) / 3;
+       if (creature_ptr->resist_acid) dam = (dam + 2) / 3;
        if (double_resist) dam = (dam + 2) / 3;
 
-       if (aura || !CHECK_MULTISHADOW(p_ptr))
+       if (aura || !CHECK_MULTISHADOW(creature_ptr))
        {
-               if ((!(double_resist || p_ptr->resist_acid)) &&
+               if ((!(double_resist || creature_ptr->resist_acid)) &&
                        one_in_(HURT_CHANCE))
-                       (void)do_dec_stat(p_ptr, A_CHR);
+                       (void)do_dec_stat(creature_ptr, A_CHR);
 
                /* If any armor gets hit, defend the player */
-               if (acid_minus_ac(p_ptr)) dam = (dam + 1) / 2;
+               if (acid_minus_ac(creature_ptr)) dam = (dam + 1) / 2;
        }
 
-       get_damage = take_hit(p_ptr, aura ? DAMAGE_NOESCAPE : DAMAGE_ATTACK, dam, kb_str, monspell);
+       get_damage = take_hit(creature_ptr, aura ? DAMAGE_NOESCAPE : DAMAGE_ATTACK, dam, kb_str, monspell);
 
        /* Inventory damage */
-       if (!aura && !(double_resist && p_ptr->resist_acid))
-               inven_damage(set_acid_destroy, inv);
+       if (!aura && !(double_resist && creature_ptr->resist_acid))
+               inventory_damage(creature_ptr, set_acid_destroy, inv);
        return get_damage;
 }
 
@@ -239,40 +230,40 @@ HIT_POINT acid_dam(HIT_POINT dam, concptr kb_str, int monspell, bool aura)
 * @param aura オーラよるダメージが原因ならばTRUE
 * @return 修正HPダメージ量
 */
-HIT_POINT elec_dam(HIT_POINT dam, concptr kb_str, int monspell, bool aura)
+HIT_POINT elec_dam(player_type *creature_ptr, HIT_POINT dam, concptr kb_str, int monspell, bool aura)
 {
        HIT_POINT get_damage;
        int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
        bool double_resist = IS_OPPOSE_ELEC();
 
        /* Total immunity */
-       if (p_ptr->immune_elec || (dam <= 0))
+       if (creature_ptr->immune_elec || (dam <= 0))
        {
                learn_spell(monspell);
                return 0;
        }
 
        /* Vulnerability (Ouch!) */
-       if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
-       if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
-       if (PRACE_IS_(p_ptr, RACE_ANDROID)) dam += dam / 3;
+       if (creature_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
+       if (creature_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
+       if (PRACE_IS_(creature_ptr, RACE_ANDROID)) dam += dam / 3;
 
        /* Resist the damage */
-       if (p_ptr->resist_elec) dam = (dam + 2) / 3;
+       if (creature_ptr->resist_elec) dam = (dam + 2) / 3;
        if (double_resist) dam = (dam + 2) / 3;
 
-       if (aura || !CHECK_MULTISHADOW(p_ptr))
+       if (aura || !CHECK_MULTISHADOW(creature_ptr))
        {
-               if ((!(double_resist || p_ptr->resist_elec)) &&
+               if ((!(double_resist || creature_ptr->resist_elec)) &&
                        one_in_(HURT_CHANCE))
-                       (void)do_dec_stat(p_ptr, A_DEX);
+                       (void)do_dec_stat(creature_ptr, A_DEX);
        }
 
-       get_damage = take_hit(p_ptr, aura ? DAMAGE_NOESCAPE : DAMAGE_ATTACK, dam, kb_str, monspell);
+       get_damage = take_hit(creature_ptr, aura ? DAMAGE_NOESCAPE : DAMAGE_ATTACK, dam, kb_str, monspell);
 
        /* Inventory damage */
-       if (!aura && !(double_resist && p_ptr->resist_elec))
-               inven_damage(set_elec_destroy, inv);
+       if (!aura && !(double_resist && creature_ptr->resist_elec))
+               inventory_damage(creature_ptr, set_elec_destroy, inv);
 
        return get_damage;
 }
@@ -287,40 +278,40 @@ HIT_POINT elec_dam(HIT_POINT dam, concptr kb_str, int monspell, bool aura)
 * @param aura オーラよるダメージが原因ならばTRUE
 * @return 修正HPダメージ量
 */
-HIT_POINT fire_dam(HIT_POINT dam, concptr kb_str, int monspell, bool aura)
+HIT_POINT fire_dam(player_type *creature_ptr, HIT_POINT dam, concptr kb_str, int monspell, bool aura)
 {
        HIT_POINT get_damage;
        int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
        bool double_resist = IS_OPPOSE_FIRE();
 
        /* Totally immune */
-       if (p_ptr->immune_fire || (dam <= 0))
+       if (creature_ptr->immune_fire || (dam <= 0))
        {
                learn_spell(monspell);
                return 0;
        }
 
        /* Vulnerability (Ouch!) */
-       if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
-       if (PRACE_IS_(p_ptr, RACE_ENT)) dam += dam / 3;
-       if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
+       if (creature_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
+       if (PRACE_IS_(creature_ptr, RACE_ENT)) dam += dam / 3;
+       if (creature_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
 
        /* Resist the damage */
-       if (p_ptr->resist_fire) dam = (dam + 2) / 3;
+       if (creature_ptr->resist_fire) dam = (dam + 2) / 3;
        if (double_resist) dam = (dam + 2) / 3;
 
-       if (aura || !CHECK_MULTISHADOW(p_ptr))
+       if (aura || !CHECK_MULTISHADOW(creature_ptr))
        {
-               if ((!(double_resist || p_ptr->resist_fire)) &&
+               if ((!(double_resist || creature_ptr->resist_fire)) &&
                        one_in_(HURT_CHANCE))
-                       (void)do_dec_stat(p_ptr, A_STR);
+                       (void)do_dec_stat(creature_ptr, A_STR);
        }
 
-       get_damage = take_hit(p_ptr, aura ? DAMAGE_NOESCAPE : DAMAGE_ATTACK, dam, kb_str, monspell);
+       get_damage = take_hit(creature_ptr, aura ? DAMAGE_NOESCAPE : DAMAGE_ATTACK, dam, kb_str, monspell);
 
        /* Inventory damage */
-       if (!aura && !(double_resist && p_ptr->resist_fire))
-               inven_damage(set_fire_destroy, inv);
+       if (!aura && !(double_resist && creature_ptr->resist_fire))
+               inventory_damage(creature_ptr, set_fire_destroy, inv);
 
        return get_damage;
 }
@@ -335,39 +326,39 @@ HIT_POINT fire_dam(HIT_POINT dam, concptr kb_str, int monspell, bool aura)
 * @param aura オーラよるダメージが原因ならばTRUE
 * @return 修正HPダメージ量
 */
-HIT_POINT cold_dam(HIT_POINT dam, concptr kb_str, int monspell, bool aura)
+HIT_POINT cold_dam(player_type *creature_ptr, HIT_POINT dam, concptr kb_str, int monspell, bool aura)
 {
        HIT_POINT get_damage;
        int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
        bool double_resist = IS_OPPOSE_COLD();
 
        /* Total immunity */
-       if (p_ptr->immune_cold || (dam <= 0))
+       if (creature_ptr->immune_cold || (dam <= 0))
        {
                learn_spell(monspell);
                return 0;
        }
 
        /* Vulnerability (Ouch!) */
-       if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
-       if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
+       if (creature_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
+       if (creature_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
 
        /* Resist the damage */
-       if (p_ptr->resist_cold) dam = (dam + 2) / 3;
+       if (creature_ptr->resist_cold) dam = (dam + 2) / 3;
        if (double_resist) dam = (dam + 2) / 3;
 
-       if (aura || !CHECK_MULTISHADOW(p_ptr))
+       if (aura || !CHECK_MULTISHADOW(creature_ptr))
        {
-               if ((!(double_resist || p_ptr->resist_cold)) &&
+               if ((!(double_resist || creature_ptr->resist_cold)) &&
                        one_in_(HURT_CHANCE))
-                       (void)do_dec_stat(p_ptr, A_STR);
+                       (void)do_dec_stat(creature_ptr, A_STR);
        }
 
-       get_damage = take_hit(p_ptr, aura ? DAMAGE_NOESCAPE : DAMAGE_ATTACK, dam, kb_str, monspell);
+       get_damage = take_hit(creature_ptr, aura ? DAMAGE_NOESCAPE : DAMAGE_ATTACK, dam, kb_str, monspell);
 
        /* Inventory damage */
-       if (!aura && !(double_resist && p_ptr->resist_cold))
-               inven_damage(set_cold_destroy, inv);
+       if (!aura && !(double_resist && creature_ptr->resist_cold))
+               inventory_damage(creature_ptr, set_cold_destroy, inv);
 
        return get_damage;
 }
@@ -400,7 +391,7 @@ int take_hit(player_type *creature_ptr, int damage_type, HIT_POINT damage, concp
 
        if (damage_type != DAMAGE_USELIFE)
        {
-               disturb(p_ptr, TRUE, TRUE);
+               disturb(creature_ptr, TRUE, TRUE);
                if (auto_more)
                {
                        creature_ptr->now_damaged = TRUE;
@@ -428,7 +419,7 @@ int take_hit(player_type *creature_ptr, int damage_type, HIT_POINT damage, concp
                        }
                }
 
-               if (CHECK_MULTISHADOW(p_ptr))
+               if (CHECK_MULTISHADOW(creature_ptr))
                {
                        if (damage_type == DAMAGE_FORCE)
                        {
@@ -505,11 +496,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(p_ptr, NIKKI_ARENA, -1 - creature_ptr->arena_number, m_name);
+                       if (record_arena) exe_write_diary(creature_ptr, NIKKI_ARENA, -1 - creature_ptr->arena_number, m_name);
                }
                else
                {
-                       QUEST_IDX q_idx = quest_number(p_ptr->current_floor_ptr->dun_level);
+                       QUEST_IDX q_idx = quest_number(creature_ptr->current_floor_ptr->dun_level);
                        bool seppuku = streq(hit_from, "Seppuku");
                        bool winning_seppuku = current_world_ptr->total_winner && seppuku;
 
@@ -544,7 +535,7 @@ int take_hit(player_type *creature_ptr, int damage_type, HIT_POINT damage, concp
 
                        if (winning_seppuku)
                        {
-                               exe_write_diary(p_ptr, NIKKI_BUNSHOU, 0, _("勝利の後切腹した。", "did Seppuku after the winning."));
+                               exe_write_diary(creature_ptr, NIKKI_BUNSHOU, 0, _("勝利の後切腹した。", "did Seppuku after the winning."));
                        }
                        else
                        {
@@ -552,20 +543,20 @@ int take_hit(player_type *creature_ptr, int damage_type, HIT_POINT damage, concp
 
                                if (creature_ptr->current_floor_ptr->inside_arena)
                                        strcpy(buf, _("アリーナ", "in the Arena"));
-                               else if (!p_ptr->current_floor_ptr->dun_level)
+                               else if (!creature_ptr->current_floor_ptr->dun_level)
                                        strcpy(buf, _("地上", "on the surface"));
                                else if (q_idx && (is_fixed_quest_idx(q_idx) &&
                                        !((q_idx == QUEST_OBERON) || (q_idx == QUEST_SERPENT))))
                                        strcpy(buf, _("クエスト", "in a quest"));
                                else
-                                       sprintf(buf, _("%d階", "level %d"), (int)p_ptr->current_floor_ptr->dun_level);
+                                       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(p_ptr, NIKKI_BUNSHOU, 0, tmp);
+                               exe_write_diary(creature_ptr, NIKKI_BUNSHOU, 0, tmp);
                        }
 
-                       exe_write_diary(p_ptr, NIKKI_GAMESTART, 1, _("-------- ゲームオーバー --------", "--------   Game  Over   --------"));
-                       exe_write_diary(p_ptr, NIKKI_BUNSHOU, 1, "\n\n\n\n");
+                       exe_write_diary(creature_ptr, NIKKI_GAMESTART, 1, _("-------- ゲームオーバー --------", "--------   Game  Over   --------"));
+                       exe_write_diary(creature_ptr, NIKKI_BUNSHOU, 1, "\n\n\n\n");
 
                        flush();
 
@@ -700,7 +691,7 @@ int take_hit(player_type *creature_ptr, int damage_type, HIT_POINT damage, concp
                                hit_from = _("何か", "something");
 
                        sprintf(tmp, _("%sによってピンチに陥った。", "A critical situation because of %s."), hit_from);
-                       exe_write_diary(p_ptr, NIKKI_BUNSHOU, 0, tmp);
+                       exe_write_diary(creature_ptr, NIKKI_BUNSHOU, 0, tmp);
                }
 
                if (auto_more)
index 5fba707..5990fc2 100644 (file)
@@ -16,8 +16,8 @@ extern int take_hit(player_type *creature_ptr, int damage_type, HIT_POINT damage
  */
 typedef int(*inven_func)(object_type *);
 
-extern int inven_damage(inven_func typ, int perc);
-extern HIT_POINT acid_dam(HIT_POINT dam, concptr kb_str, int monspell, bool aura);
-extern HIT_POINT elec_dam(HIT_POINT dam, concptr kb_str, int monspell, bool aura);
-extern HIT_POINT fire_dam(HIT_POINT dam, concptr kb_str, int monspell, bool aura);
-extern HIT_POINT cold_dam(HIT_POINT dam, concptr kb_str, int monspell, bool aura);
+extern void inventory_damage(player_type *creature_ptr, inven_func typ, int perc);
+extern HIT_POINT acid_dam(player_type *creature_ptr, HIT_POINT dam, concptr kb_str, int monspell, bool aura);
+extern HIT_POINT elec_dam(player_type *creature_ptr, HIT_POINT dam, concptr kb_str, int monspell, bool aura);
+extern HIT_POINT fire_dam(player_type *creature_ptr, HIT_POINT dam, concptr kb_str, int monspell, bool aura);
+extern HIT_POINT cold_dam(player_type *creature_ptr, HIT_POINT dam, concptr kb_str, int monspell, bool aura);
index 264a308..aa08286 100644 (file)
@@ -4123,7 +4123,7 @@ static bool project_p(MONSTER_IDX who, player_type *target_ptr, concptr who_name
        case GF_ACID:
        {
                if (fuzzy) msg_print(_("酸で攻撃された!", "You are hit by acid!"));
-               get_damage = acid_dam(dam, killer, monspell, FALSE);
+               get_damage = acid_dam(target_ptr, dam, killer, monspell, FALSE);
                break;
        }
 
@@ -4131,7 +4131,7 @@ static bool project_p(MONSTER_IDX who, player_type *target_ptr, concptr who_name
        case GF_FIRE:
        {
                if (fuzzy) msg_print(_("火炎で攻撃された!", "You are hit by fire!"));
-               get_damage = fire_dam(dam, killer, monspell, FALSE);
+               get_damage = fire_dam(target_ptr, dam, killer, monspell, FALSE);
                break;
        }
 
@@ -4139,7 +4139,7 @@ static bool project_p(MONSTER_IDX who, player_type *target_ptr, concptr who_name
        case GF_COLD:
        {
                if (fuzzy) msg_print(_("冷気で攻撃された!", "You are hit by cold!"));
-               get_damage = cold_dam(dam, killer, monspell, FALSE);
+               get_damage = cold_dam(target_ptr, dam, killer, monspell, FALSE);
                break;
        }
 
@@ -4147,7 +4147,7 @@ static bool project_p(MONSTER_IDX who, player_type *target_ptr, concptr who_name
        case GF_ELEC:
        {
                if (fuzzy) msg_print(_("電撃で攻撃された!", "You are hit by lightning!"));
-               get_damage = elec_dam(dam, killer, monspell, FALSE);
+               get_damage = elec_dam(target_ptr, dam, killer, monspell, FALSE);
                break;
        }
 
@@ -4198,7 +4198,7 @@ static bool project_p(MONSTER_IDX who, player_type *target_ptr, concptr who_name
 
                        if (one_in_(6))
                        {
-                               inven_damage(set_acid_destroy, 2);
+                               inventory_damage(target_ptr, set_acid_destroy, 2);
                        }
                }
                break;
@@ -4263,7 +4263,7 @@ static bool project_p(MONSTER_IDX who, player_type *target_ptr, concptr who_name
 
                if (!(target_ptr->resist_fire || IS_OPPOSE_FIRE() || target_ptr->immune_fire))
                {
-                       inven_damage(set_acid_destroy, 3);
+                       inventory_damage(target_ptr, set_acid_destroy, 3);
                }
 
                break;
@@ -4313,7 +4313,7 @@ static bool project_p(MONSTER_IDX who, player_type *target_ptr, concptr who_name
 
                        if (one_in_(5) && !target_ptr->resist_water)
                        {
-                               inven_damage(set_cold_destroy, 3);
+                               inventory_damage(target_ptr, set_cold_destroy, 3);
                        }
 
                        if (target_ptr->resist_water) get_damage /= 4;
@@ -4354,8 +4354,8 @@ static bool project_p(MONSTER_IDX who, player_type *target_ptr, concptr who_name
 
                        if (!target_ptr->resist_chaos || one_in_(9))
                        {
-                               inven_damage(set_elec_destroy, 2);
-                               inven_damage(set_fire_destroy, 2);
+                               inventory_damage(target_ptr, set_elec_destroy, 2);
+                               inventory_damage(target_ptr, set_fire_destroy, 2);
                        }
                }
 
@@ -4378,7 +4378,7 @@ static bool project_p(MONSTER_IDX who, player_type *target_ptr, concptr who_name
 
                if (!target_ptr->resist_shard || one_in_(13))
                {
-                       inven_damage(set_cold_destroy, 2);
+                       inventory_damage(target_ptr, set_cold_destroy, 2);
                }
 
                get_damage = take_hit(target_ptr, DAMAGE_ATTACK, dam, killer, monspell);
@@ -4401,7 +4401,7 @@ static bool project_p(MONSTER_IDX who, player_type *target_ptr, concptr who_name
 
                if (!target_ptr->resist_sound || one_in_(13))
                {
-                       inven_damage(set_cold_destroy, 2);
+                       inventory_damage(target_ptr, set_cold_destroy, 2);
                }
 
                get_damage = take_hit(target_ptr, DAMAGE_ATTACK, dam, killer, monspell);
@@ -4489,7 +4489,7 @@ static bool project_p(MONSTER_IDX who, player_type *target_ptr, concptr who_name
 
                if (!target_ptr->resist_shard || one_in_(12))
                {
-                       inven_damage(set_cold_destroy, 3);
+                       inventory_damage(target_ptr, set_cold_destroy, 3);
                }
 
                get_damage = take_hit(target_ptr, DAMAGE_ATTACK, dam, killer, monspell);
@@ -4650,7 +4650,7 @@ static bool project_p(MONSTER_IDX who, player_type *target_ptr, concptr who_name
 
                if (!target_ptr->levitation || one_in_(13))
                {
-                       inven_damage(set_cold_destroy, 2);
+                       inventory_damage(target_ptr, set_cold_destroy, 2);
                }
 
                get_damage = take_hit(target_ptr, DAMAGE_ATTACK, dam, killer, monspell);
@@ -4733,8 +4733,8 @@ static bool project_p(MONSTER_IDX who, player_type *target_ptr, concptr who_name
                get_damage = take_hit(target_ptr, DAMAGE_ATTACK, dam, killer, monspell);
                if (!target_ptr->resist_shard || one_in_(13))
                {
-                       if (!target_ptr->immune_fire) inven_damage(set_fire_destroy, 2);
-                       inven_damage(set_cold_destroy, 2);
+                       if (!target_ptr->immune_fire) inventory_damage(target_ptr, set_fire_destroy, 2);
+                       inventory_damage(target_ptr, set_cold_destroy, 2);
                }
 
                break;
@@ -4744,7 +4744,7 @@ static bool project_p(MONSTER_IDX who, player_type *target_ptr, concptr who_name
        case GF_ICE:
        {
                if (fuzzy) msg_print(_("何か鋭く冷たいもので攻撃された!", "You are hit by something sharp and cold!"));
-               get_damage = cold_dam(dam, killer, monspell, FALSE);
+               get_damage = cold_dam(target_ptr, dam, killer, monspell, FALSE);
                if (!CHECK_MULTISHADOW(target_ptr))
                {
                        if (!target_ptr->resist_shard)
@@ -4758,7 +4758,7 @@ static bool project_p(MONSTER_IDX who, player_type *target_ptr, concptr who_name
 
                        if ((!(target_ptr->resist_cold || IS_OPPOSE_COLD())) || one_in_(12))
                        {
-                               if (!target_ptr->immune_cold) inven_damage(set_cold_destroy, 3);
+                               if (!target_ptr->immune_cold) inventory_damage(target_ptr, set_cold_destroy, 3);
                        }
                }
 
index 817c859..db3a00a 100644 (file)
@@ -491,7 +491,7 @@ void hit_trap(player_type *trapped_ptr, bool break_trap)
        {
                msg_print(_("炎に包まれた!", "You are enveloped in flames!"));
                dam = damroll(4, 6);
-               (void)fire_dam(dam, _("炎のトラップ", "a fire trap"), -1, FALSE);
+               (void)fire_dam(trapped_ptr, dam, _("炎のトラップ", "a fire trap"), -1, FALSE);
                break;
        }
 
@@ -499,7 +499,7 @@ void hit_trap(player_type *trapped_ptr, bool break_trap)
        {
                msg_print(_("酸が吹きかけられた!", "You are splashed with acid!"));
                dam = damroll(4, 6);
-               (void)acid_dam(dam, _("酸のトラップ", "an acid trap"), -1, FALSE);
+               (void)acid_dam(trapped_ptr, dam, _("酸のトラップ", "an acid trap"), -1, FALSE);
                break;
        }