From 87fae136451d7e86afd83afeeb52e4b1daae0812 Mon Sep 17 00:00:00 2001 From: Hourier Date: Mon, 29 Jun 2020 22:04:04 +0900 Subject: [PATCH] [Refactor] #40466 Separated element-resistance.c/h from player-effects.c/h --- Hengband/Hengband/Hengband.vcxproj | 2 + Hengband/Hengband/Hengband.vcxproj.filters | 6 + src/Makefile.am | 1 + src/cmd-item/cmd-activate.c | 5 +- src/cmd-item/cmd-eat.c | 4 +- src/cmd-item/cmd-quaff.c | 2 +- src/cmd-item/cmd-read.c | 2 +- src/core/hp-mp-processor.c | 3 +- src/core/magic-effects-timeout-reducer.c | 1 + src/effect/effect-player-resist-hurt.c | 1 + src/effect/effect-player-switcher.c | 3 +- src/grid/trap.c | 1 + src/mind/mind.c | 2 +- src/monster-attack/monster-attack-switcher.c | 3 +- src/monster/monster-update.c | 1 + src/mspell/mspells1.c | 2 +- src/mutation/mutation.c | 2 +- src/object/warning.c | 2 +- src/player/player-damage.c | 2 +- src/player/player-effects.c | 206 +---------------------- src/player/player-effects.h | 5 - src/player/player-status.c | 30 ---- src/player/player-status.h | 5 - src/player/selfinfo.c | 2 +- src/player/temporary-resistances.c | 1 + src/realm/realm-arcane.c | 3 +- src/realm/realm-craft.c | 2 +- src/realm/realm-death.c | 2 +- src/realm/realm-demon.c | 5 +- src/realm/realm-life.c | 2 +- src/realm/realm-nature.c | 5 +- src/specific-object/chest.c | 4 +- src/specific-object/death-scythe.c | 1 + src/status/element-resistance.c | 237 +++++++++++++++++++++++++++ src/status/element-resistance.h | 14 ++ src/view/main-window-stat-poster.c | 1 + 36 files changed, 299 insertions(+), 271 deletions(-) create mode 100644 src/status/element-resistance.c create mode 100644 src/status/element-resistance.h diff --git a/Hengband/Hengband/Hengband.vcxproj b/Hengband/Hengband/Hengband.vcxproj index 0f9a33aa1..c8143ce6a 100644 --- a/Hengband/Hengband/Hengband.vcxproj +++ b/Hengband/Hengband/Hengband.vcxproj @@ -235,6 +235,7 @@ + @@ -664,6 +665,7 @@ + diff --git a/Hengband/Hengband/Hengband.vcxproj.filters b/Hengband/Hengband/Hengband.vcxproj.filters index c924e3b3e..6f1630d94 100644 --- a/Hengband/Hengband/Hengband.vcxproj.filters +++ b/Hengband/Hengband/Hengband.vcxproj.filters @@ -1517,6 +1517,9 @@ spell-realm + + status + @@ -3325,6 +3328,9 @@ spell-realm + + status + diff --git a/src/Makefile.am b/src/Makefile.am index ff4266669..2968d00b8 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -556,6 +556,7 @@ hengband_SOURCES = \ \ status/bad-status-setter.c status/bad-status-setter.h \ status/buff-setter.c status/buff-setter.h \ + status/element-resistance.c status/element-resistance.h \ status/sight-setter.c status/sight-setter.h \ \ store/store.c store/store.h \ diff --git a/src/cmd-item/cmd-activate.c b/src/cmd-item/cmd-activate.c index 44a3f5815..2fecd38e0 100644 --- a/src/cmd-item/cmd-activate.c +++ b/src/cmd-item/cmd-activate.c @@ -46,8 +46,6 @@ #include "monster-floor/place-monster-types.h" #include "monster/smart-learn-types.h" #include "player/avatar.h" -#include "status/bad-status-setter.h" -#include "status/buff-setter.h" #include "player/digestion-processor.h" #include "player/player-damage.h" #include "player/player-effects.h" @@ -78,6 +76,9 @@ #include "spell/spells-summon.h" #include "spell/spell-types.h" #include "spell/spells3.h" +#include "status/bad-status-setter.h" +#include "status/buff-setter.h" +#include "status/element-resistance.h" #include "status/sight-setter.h" #include "sv-definition/sv-lite-types.h" #include "sv-definition/sv-ring-types.h" diff --git a/src/cmd-item/cmd-eat.c b/src/cmd-item/cmd-eat.c index 348809ebe..a21f94869 100644 --- a/src/cmd-item/cmd-eat.c +++ b/src/cmd-item/cmd-eat.c @@ -24,16 +24,16 @@ #include "perception/object-perception.h" #include "player/avatar.h" #include "status/bad-status-setter.h" -#include "player/mimic-info-table.h" #include "player/digestion-processor.h" #include "player/player-class.h" #include "player/player-damage.h" #include "player/player-effects.h" #include "player/player-race-types.h" -#include "player/player-status.h" #include "player/special-defense-types.h" #include "spell-realm/spells-hex.h" #include "spell/spells-status.h" +#include "status/element-resistance.h" +#include "player/mimic-info-table.h" #include "sv-definition/sv-food-types.h" #include "sv-definition/sv-other-types.h" #include "util/string-processor.h" diff --git a/src/cmd-item/cmd-quaff.c b/src/cmd-item/cmd-quaff.c index f346bd4b4..494e9dbcc 100644 --- a/src/cmd-item/cmd-quaff.c +++ b/src/cmd-item/cmd-quaff.c @@ -31,7 +31,6 @@ #include "player/player-damage.h" #include "player/player-effects.h" #include "player/player-race-types.h" -#include "player/player-status.h" #include "player/selfinfo.h" #include "player/special-defense-types.h" #include "realm/realm-hex-numbers.h" @@ -43,6 +42,7 @@ #include "spell/spells3.h" #include "status/bad-status-setter.h" #include "status/buff-setter.h" +#include "status/element-resistance.h" #include "status/sight-setter.h" #include "sv-definition/sv-potion-types.h" #include "term/screen-processor.h" diff --git a/src/cmd-item/cmd-read.c b/src/cmd-item/cmd-read.c index 650020cfc..c7c13304a 100644 --- a/src/cmd-item/cmd-read.c +++ b/src/cmd-item/cmd-read.c @@ -29,7 +29,6 @@ #include "player/player-class.h" #include "player/player-damage.h" #include "player/player-effects.h" -#include "player/player-status.h" #include "player/special-defense-types.h" #include "spell-kind/spells-curse-removal.h" #include "spell-kind/spells-detection.h" @@ -51,6 +50,7 @@ #include "spell/spells3.h" #include "status/bad-status-setter.h" #include "status/buff-setter.h" +#include "status/element-resistance.h" #include "store/rumor.h" #include "sv-definition/sv-scroll-types.h" #include "term/screen-processor.h" diff --git a/src/core/hp-mp-processor.c b/src/core/hp-mp-processor.c index 9e782dfb6..3d6d868a3 100644 --- a/src/core/hp-mp-processor.c +++ b/src/core/hp-mp-processor.c @@ -11,11 +11,12 @@ #include "object-enchant/object-ego.h" #include "object-enchant/trc-types.h" #include "object/object-flavor.h" -#include "status/bad-status-setter.h" #include "player/player-damage.h" #include "player/player-race-types.h" #include "player/player-race.h" #include "player/special-defense-types.h" +#include "status/bad-status-setter.h" +#include "status/element-resistance.h" #include "util/bit-flags-calculator.h" #include "view/display-messages.h" #include "world/world.h" diff --git a/src/core/magic-effects-timeout-reducer.c b/src/core/magic-effects-timeout-reducer.c index 4a199edf0..0118dc5a3 100644 --- a/src/core/magic-effects-timeout-reducer.c +++ b/src/core/magic-effects-timeout-reducer.c @@ -6,6 +6,7 @@ #include "spell-realm/spells-craft.h" #include "status/bad-status-setter.h" #include "status/buff-setter.h" +#include "status/element-resistance.h" #include "status/sight-setter.h" /*! diff --git a/src/effect/effect-player-resist-hurt.c b/src/effect/effect-player-resist-hurt.c index faead78f3..511a1064f 100644 --- a/src/effect/effect-player-resist-hurt.c +++ b/src/effect/effect-player-resist-hurt.c @@ -14,6 +14,7 @@ #include "spell-kind/spells-teleport.h" #include "spell/spells-status.h" #include "spell/spells3.h" +#include "status/element-resistance.h" #include "system/object-type-definition.h" #include "view/display-messages.h" #include "world/world.h" diff --git a/src/effect/effect-player-switcher.c b/src/effect/effect-player-switcher.c index a1b7d172b..d66a56a1c 100644 --- a/src/effect/effect-player-switcher.c +++ b/src/effect/effect-player-switcher.c @@ -9,11 +9,12 @@ #include "mspell/mspells3.h" #include "object-enchant/object-curse.h" #include "object/object-broken.h" -#include "status/bad-status-setter.h" #include "player/mimic-info-table.h" #include "player/player-damage.h" #include "player/player-race-types.h" #include "spell/spell-types.h" +#include "status/bad-status-setter.h" +#include "status/element-resistance.h" #include "view/display-messages.h" #include "world/world.h" diff --git a/src/grid/trap.c b/src/grid/trap.c index df4b113c2..0910b6551 100644 --- a/src/grid/trap.c +++ b/src/grid/trap.c @@ -33,6 +33,7 @@ #include "spell/process-effect.h" #include "spell/spells-summon.h" #include "spell/spell-types.h" +#include "status/element-resistance.h" #include "util/bit-flags-calculator.h" #include "view/display-messages.h" #include "world/world.h" diff --git a/src/mind/mind.c b/src/mind/mind.c index 7552695a6..a1fdc625a 100644 --- a/src/mind/mind.c +++ b/src/mind/mind.c @@ -46,7 +46,6 @@ #include "player/player-damage.h" #include "player/player-effects.h" #include "player/player-move.h" -#include "player/player-status.h" #include "player/special-defense-types.h" #include "spell/process-effect.h" #include "spell-kind/earthquake.h" @@ -65,6 +64,7 @@ #include "spell/spells3.h" #include "status/bad-status-setter.h" #include "status/buff-setter.h" +#include "status/element-resistance.h" #include "status/sight-setter.h" #include "term/screen-processor.h" #include "util/buffer-shaper.h" diff --git a/src/monster-attack/monster-attack-switcher.c b/src/monster-attack/monster-attack-switcher.c index 1b15929ed..f37928e05 100644 --- a/src/monster-attack/monster-attack-switcher.c +++ b/src/monster-attack/monster-attack-switcher.c @@ -12,11 +12,12 @@ #include "mind/mind-mirror-master.h" #include "monster/monster-status.h" #include "monster/monster-update.h" -#include "status/bad-status-setter.h" #include "player/player-damage.h" #include "player/player-effects.h" #include "spell-kind/earthquake.h" #include "spell/spells3.h" +#include "status/bad-status-setter.h" +#include "status/element-resistance.h" #include "system/object-type-definition.h" #include "view/display-messages.h" diff --git a/src/monster/monster-update.c b/src/monster/monster-update.c index 1caededa5..cf8e109dd 100644 --- a/src/monster/monster-update.c +++ b/src/monster/monster-update.c @@ -23,6 +23,7 @@ #include "player/eldritch-horror.h" #include "player/player-move.h" #include "player/special-defense-types.h" +#include "status/element-resistance.h" /*! * @brief 騎乗中のモンスター情報を更新する diff --git a/src/mspell/mspells1.c b/src/mspell/mspells1.c index a2c813270..7c940c389 100644 --- a/src/mspell/mspells1.c +++ b/src/mspell/mspells1.c @@ -44,7 +44,6 @@ #include "player/player-move.h" #include "player/player-race-types.h" #include "player/player-race.h" -#include "player/player-status.h" #include "player/special-defense-types.h" #include "realm/realm-song-numbers.h" #include "spell-kind/spells-teleport.h" @@ -52,6 +51,7 @@ #include "spell/process-effect.h" #include "spell/range-calc.h" #include "spell/spell-types.h" +#include "status/element-resistance.h" #include "util/bit-flags-calculator.h" #include "view/display-messages.h" #include "world/world.h" diff --git a/src/mutation/mutation.c b/src/mutation/mutation.c index 8d236c867..b468ca0a2 100644 --- a/src/mutation/mutation.c +++ b/src/mutation/mutation.c @@ -45,7 +45,6 @@ #include "player/player-effects.h" #include "player/player-personalities-types.h" #include "player/player-race-types.h" -#include "player/player-status.h" #include "player/selfinfo.h" #include "spell-kind/earthquake.h" #include "spell-kind/spells-charm.h" @@ -59,6 +58,7 @@ #include "spell/spells-summon.h" #include "spell/spell-types.h" #include "spell/spells3.h" +#include "status/element-resistance.h" #include "system/object-type-definition.h" #include "view/display-messages.h" diff --git a/src/object/warning.c b/src/object/warning.c index 4210e6e07..d7ff37af2 100644 --- a/src/object/warning.c +++ b/src/object/warning.c @@ -25,9 +25,9 @@ #include "player/player-class.h" #include "player/player-move.h" #include "player/player-race-types.h" -#include "player/player-status.h" #include "player/special-defense-types.h" #include "spell/spell-types.h" +#include "status/element-resistance.h" #include "util/bit-flags-calculator.h" #include "view/display-messages.h" diff --git a/src/player/player-damage.c b/src/player/player-damage.c index ed04eab29..f5795ad72 100644 --- a/src/player/player-damage.c +++ b/src/player/player-damage.c @@ -42,9 +42,9 @@ #include "player/player-move.h" #include "player/player-personalities-types.h" #include "player/player-race-types.h" -#include "player/player-status.h" #include "player/race-info-table.h" #include "player/special-defense-types.h" +#include "status/element-resistance.h" #include "term/screen-processor.h" #include "term/term-color-types.h" #include "util/bit-flags-calculator.h" diff --git a/src/player/player-effects.c b/src/player/player-effects.c index 44e37c3a2..7c692e986 100644 --- a/src/player/player-effects.c +++ b/src/player/player-effects.c @@ -58,7 +58,6 @@ #include "player/player-personality.h" #include "player/player-race-types.h" #include "player/player-sex.h" -#include "player/player-status.h" #include "player/race-info-table.h" #include "realm/realm-song-numbers.h" #include "spell-kind/spells-floor.h" @@ -67,6 +66,7 @@ #include "spell/spells-status.h" #include "status/bad-status-setter.h" #include "status/buff-setter.h" +#include "status/element-resistance.h" #include "status/sight-setter.h" #include "sv-definition/sv-armor-types.h" #include "sv-definition/sv-protector-types.h" @@ -953,210 +953,6 @@ bool set_tsuyoshi(player_type *creature_ptr, TIME_EFFECT v, bool do_dec) } /*! - * @brief 一時的酸耐性の継続時間をセットする / Set "oppose_acid", notice observable changes - * @param v 継続時間 - * @param do_dec 現在の継続時間より長い値のみ上書きする - * @return ステータスに影響を及ぼす変化があった場合TRUEを返す。 - */ -bool set_oppose_acid(player_type *creature_ptr, TIME_EFFECT v, bool do_dec) -{ - bool notice = FALSE; - v = (v > 10000) ? 10000 : (v < 0) ? 0 : v; - if (creature_ptr->is_dead) - return FALSE; - - if (v) { - if (creature_ptr->oppose_acid && !do_dec) { - if (creature_ptr->oppose_acid > v) - return FALSE; - } else if (!is_oppose_acid(creature_ptr)) { - msg_print(_("酸への耐性がついた気がする!", "You feel resistant to acid!")); - notice = TRUE; - } - } else { - if (creature_ptr->oppose_acid && !music_singing(creature_ptr, MUSIC_RESIST) && !(creature_ptr->special_defense & KATA_MUSOU)) { - msg_print(_("酸への耐性が薄れた気がする。", "You feel less resistant to acid.")); - notice = TRUE; - } - } - - creature_ptr->oppose_acid = v; - - if (!notice) - return FALSE; - creature_ptr->redraw |= (PR_STATUS); - - if (disturb_state) - disturb(creature_ptr, FALSE, FALSE); - handle_stuff(creature_ptr); - return TRUE; -} - -/*! - * @brief 一時的電撃耐性の継続時間をセットする / Set "oppose_elec", notice observable changes - * @param v 継続時間 - * @param do_dec 現在の継続時間より長い値のみ上書きする - * @return ステータスに影響を及ぼす変化があった場合TRUEを返す。 - */ -bool set_oppose_elec(player_type *creature_ptr, TIME_EFFECT v, bool do_dec) -{ - bool notice = FALSE; - v = (v > 10000) ? 10000 : (v < 0) ? 0 : v; - - if (creature_ptr->is_dead) - return FALSE; - - if (v) { - if (creature_ptr->oppose_elec && !do_dec) { - if (creature_ptr->oppose_elec > v) - return FALSE; - } else if (!is_oppose_elec(creature_ptr)) { - msg_print(_("電撃への耐性がついた気がする!", "You feel resistant to electricity!")); - notice = TRUE; - } - } else { - if (creature_ptr->oppose_elec && !music_singing(creature_ptr, MUSIC_RESIST) && !(creature_ptr->special_defense & KATA_MUSOU)) { - msg_print(_("電撃への耐性が薄れた気がする。", "You feel less resistant to electricity.")); - notice = TRUE; - } - } - - creature_ptr->oppose_elec = v; - - if (!notice) - return FALSE; - creature_ptr->redraw |= (PR_STATUS); - - if (disturb_state) - disturb(creature_ptr, FALSE, FALSE); - handle_stuff(creature_ptr); - return TRUE; -} - -/*! - * @brief 一時的火炎耐性の継続時間をセットする / Set "oppose_fire", notice observable changes - * @param v 継続時間 - * @param do_dec 現在の継続時間より長い値のみ上書きする - * @return ステータスに影響を及ぼす変化があった場合TRUEを返す。 - */ -bool set_oppose_fire(player_type *creature_ptr, TIME_EFFECT v, bool do_dec) -{ - bool notice = FALSE; - v = (v > 10000) ? 10000 : (v < 0) ? 0 : v; - if (creature_ptr->is_dead) - return FALSE; - - if ((is_specific_player_race(creature_ptr, RACE_BALROG) && (creature_ptr->lev > 44)) || (creature_ptr->mimic_form == MIMIC_DEMON)) - v = 1; - if (v) { - if (creature_ptr->oppose_fire && !do_dec) { - if (creature_ptr->oppose_fire > v) - return FALSE; - } else if (!is_oppose_fire(creature_ptr)) { - msg_print(_("火への耐性がついた気がする!", "You feel resistant to fire!")); - notice = TRUE; - } - } else { - if (creature_ptr->oppose_fire && !music_singing(creature_ptr, MUSIC_RESIST) && !(creature_ptr->special_defense & KATA_MUSOU)) { - msg_print(_("火への耐性が薄れた気がする。", "You feel less resistant to fire.")); - notice = TRUE; - } - } - - creature_ptr->oppose_fire = v; - - if (!notice) - return FALSE; - creature_ptr->redraw |= (PR_STATUS); - - if (disturb_state) - disturb(creature_ptr, FALSE, FALSE); - handle_stuff(creature_ptr); - return TRUE; -} - -/*! - * @brief 一時的冷気耐性の継続時間をセットする / Set "oppose_cold", notice observable changes - * @param v 継続時間 - * @param do_dec 現在の継続時間より長い値のみ上書きする - * @return ステータスに影響を及ぼす変化があった場合TRUEを返す。 - */ -bool set_oppose_cold(player_type *creature_ptr, TIME_EFFECT v, bool do_dec) -{ - bool notice = FALSE; - v = (v > 10000) ? 10000 : (v < 0) ? 0 : v; - if (creature_ptr->is_dead) - return FALSE; - - if (v) { - if (creature_ptr->oppose_cold && !do_dec) { - if (creature_ptr->oppose_cold > v) - return FALSE; - } else if (!is_oppose_cold(creature_ptr)) { - msg_print(_("冷気への耐性がついた気がする!", "You feel resistant to cold!")); - notice = TRUE; - } - } else { - if (creature_ptr->oppose_cold && !music_singing(creature_ptr, MUSIC_RESIST) && !(creature_ptr->special_defense & KATA_MUSOU)) { - msg_print(_("冷気への耐性が薄れた気がする。", "You feel less resistant to cold.")); - notice = TRUE; - } - } - - creature_ptr->oppose_cold = v; - - if (!notice) - return FALSE; - creature_ptr->redraw |= (PR_STATUS); - - if (disturb_state) - disturb(creature_ptr, FALSE, FALSE); - handle_stuff(creature_ptr); - return TRUE; -} - -/*! - * @brief 一時的毒耐性の継続時間をセットする / Set "oppose_pois", notice observable changes - * @param v 継続時間 - * @param do_dec 現在の継続時間より長い値のみ上書きする - * @return ステータスに影響を及ぼす変化があった場合TRUEを返す。 - */ -bool set_oppose_pois(player_type *creature_ptr, TIME_EFFECT v, bool do_dec) -{ - bool notice = FALSE; - v = (v > 10000) ? 10000 : (v < 0) ? 0 : v; - if ((creature_ptr->pclass == CLASS_NINJA) && (creature_ptr->lev > 44)) - v = 1; - if (creature_ptr->is_dead) - return FALSE; - - if (v) { - if (creature_ptr->oppose_pois && !do_dec) { - if (creature_ptr->oppose_pois > v) - return FALSE; - } else if (!is_oppose_pois(creature_ptr)) { - msg_print(_("毒への耐性がついた気がする!", "You feel resistant to poison!")); - notice = TRUE; - } - } else { - if (creature_ptr->oppose_pois && !music_singing(creature_ptr, MUSIC_RESIST) && !(creature_ptr->special_defense & KATA_MUSOU)) { - msg_print(_("毒への耐性が薄れた気がする。", "You feel less resistant to poison.")); - notice = TRUE; - } - } - - creature_ptr->oppose_pois = v; - if (!notice) - return FALSE; - creature_ptr->redraw |= (PR_STATUS); - - if (disturb_state) - disturb(creature_ptr, FALSE, FALSE); - handle_stuff(creature_ptr); - return TRUE; -} - -/*! * @brief プレイヤーの基本能力値を増加させる / Increases a stat by one randomized level -RAK- * @param stat 上昇させるステータスID * @return 実際に上昇した場合TRUEを返す。 diff --git a/src/player/player-effects.h b/src/player/player-effects.h index e40aee127..455f82b15 100644 --- a/src/player/player-effects.h +++ b/src/player/player-effects.h @@ -19,11 +19,6 @@ bool set_resist_magic(player_type *creature_ptr, TIME_EFFECT v, bool do_dec); bool set_tim_reflect(player_type *creature_ptr, TIME_EFFECT v, bool do_dec); bool set_kabenuke(player_type *creature_ptr, TIME_EFFECT v, bool do_dec); bool set_tsuyoshi(player_type *creature_ptr, TIME_EFFECT v, bool do_dec); -bool set_oppose_acid(player_type *creature_ptr, TIME_EFFECT v, bool do_dec); -bool set_oppose_elec(player_type *creature_ptr, TIME_EFFECT v, bool do_dec); -bool set_oppose_fire(player_type *creature_ptr, TIME_EFFECT v, bool do_dec); -bool set_oppose_cold(player_type *creature_ptr, TIME_EFFECT v, bool do_dec); -bool set_oppose_pois(player_type *creature_ptr, TIME_EFFECT v, bool do_dec); bool inc_stat(player_type *creature_ptr, int stat); bool dec_stat(player_type *creature_ptr, int stat, int amount, int permanent); bool res_stat(player_type *creature_ptr, int stat); diff --git a/src/player/player-status.c b/src/player/player-status.c index 0f540436c..5d92495d6 100644 --- a/src/player/player-status.c +++ b/src/player/player-status.c @@ -4620,36 +4620,6 @@ bool is_blessed(player_type *creature_ptr) } -bool is_oppose_acid(player_type *creature_ptr) -{ - return creature_ptr->oppose_acid || music_singing(creature_ptr, MUSIC_RESIST) || (creature_ptr->special_defense & KATA_MUSOU); -} - - -bool is_oppose_elec(player_type *creature_ptr) -{ - return creature_ptr->oppose_elec || music_singing(creature_ptr, MUSIC_RESIST) || (creature_ptr->special_defense & KATA_MUSOU); -} - - -bool is_oppose_fire(player_type *creature_ptr) -{ - return creature_ptr->oppose_fire || music_singing(creature_ptr, MUSIC_RESIST) || (creature_ptr->special_defense & KATA_MUSOU); -} - - -bool is_oppose_cold(player_type *creature_ptr) -{ - return creature_ptr->oppose_cold || music_singing(creature_ptr, MUSIC_RESIST) || (creature_ptr->special_defense & KATA_MUSOU); -} - - -bool is_oppose_pois(player_type *creature_ptr) -{ - return creature_ptr->oppose_pois || music_singing(creature_ptr, MUSIC_RESIST) || (creature_ptr->special_defense & KATA_MUSOU); -} - - bool is_tim_esp(player_type *creature_ptr) { return creature_ptr->tim_esp || music_singing(creature_ptr, MUSIC_MIND) || (creature_ptr->concent >= CONCENT_TELE_THRESHOLD); diff --git a/src/player/player-status.h b/src/player/player-status.h index c1383d45b..2b16abf93 100644 --- a/src/player/player-status.h +++ b/src/player/player-status.h @@ -766,11 +766,6 @@ extern const s32b player_exp[PY_MAX_LEVEL]; extern const s32b player_exp_a[PY_MAX_LEVEL]; extern bool is_blessed(player_type *creature_ptr); -extern bool is_oppose_acid(player_type *creature_ptr); -extern bool is_oppose_elec(player_type *creature_ptr); -extern bool is_oppose_fire(player_type *creature_ptr); -extern bool is_oppose_cold(player_type *creature_ptr); -extern bool is_oppose_pois(player_type *creature_ptr); extern bool is_time_limit_esp(player_type *creature_ptr); extern bool is_time_limit_stealth(player_type *creature_ptr); extern bool can_two_hands_wielding(player_type *creature_ptr); diff --git a/src/player/selfinfo.c b/src/player/selfinfo.c index 1091d90ca..6d5b48ee6 100644 --- a/src/player/selfinfo.c +++ b/src/player/selfinfo.c @@ -23,9 +23,9 @@ #include "player/player-class.h" #include "player/player-race-types.h" #include "player/player-race.h" -#include "player/player-status.h" #include "realm/realm-names-table.h" #include "realm/realm-song-numbers.h" +#include "status/element-resistance.h" #include "term/screen-processor.h" #include "util/bit-flags-calculator.h" diff --git a/src/player/temporary-resistances.c b/src/player/temporary-resistances.c index ccd06e293..69d7e3b4c 100644 --- a/src/player/temporary-resistances.c +++ b/src/player/temporary-resistances.c @@ -7,6 +7,7 @@ #include "realm/realm-song-numbers.h" #include "realm/realm-types.h" #include "spell-realm/spells-hex.h" +#include "status/element-resistance.h" #include "system/object-type-definition.h" #include "util/bit-flags-calculator.h" diff --git a/src/realm/realm-arcane.c b/src/realm/realm-arcane.c index 805b41bf5..190642911 100644 --- a/src/realm/realm-arcane.c +++ b/src/realm/realm-arcane.c @@ -6,8 +6,6 @@ #include "monster-floor/place-monster-types.h" #include "player/avatar.h" #include "player/digestion-processor.h" -#include "player/player-effects.h" -#include "player/player-status.h" #include "spell-kind/spells-beam.h" #include "spell-kind/spells-detection.h" #include "spell-kind/spells-floor.h" @@ -22,6 +20,7 @@ #include "spell/spells-status.h" #include "spell/spells-summon.h" #include "status/bad-status-setter.h" +#include "status/element-resistance.h" #include "status/sight-setter.h" #include "view/display-messages.h" diff --git a/src/realm/realm-craft.c b/src/realm/realm-craft.c index 2ff6b51c4..1cac0ce2b 100644 --- a/src/realm/realm-craft.c +++ b/src/realm/realm-craft.c @@ -5,7 +5,6 @@ #include "mutation/mutation.h" #include "player/digestion-processor.h" #include "player/player-effects.h" -#include "player/player-status.h" #include "player/selfinfo.h" #include "spell-kind/spells-curse-removal.h" #include "spell-kind/spells-perception.h" @@ -16,6 +15,7 @@ #include "spell/spells-summon.h" #include "spell/spells3.h" #include "status/buff-setter.h" +#include "status/element-resistance.h" #include "status/sight-setter.h" #include "view/display-messages.h" diff --git a/src/realm/realm-death.c b/src/realm/realm-death.c index c5e5740d4..2a73aa7dd 100644 --- a/src/realm/realm-death.c +++ b/src/realm/realm-death.c @@ -8,7 +8,6 @@ #include "player/player-damage.h" #include "player/player-effects.h" #include "player/player-race.h" -#include "player/player-status.h" #include "spell-kind/spells-charm.h" #include "spell-kind/spells-detection.h" #include "spell-kind/spells-genocide.h" @@ -24,6 +23,7 @@ #include "spell/spells-status.h" #include "spell/spells-summon.h" #include "status/buff-setter.h" +#include "status/element-resistance.h" /*! * @brief 暗黒領域魔法の各処理を行う diff --git a/src/realm/realm-demon.c b/src/realm/realm-demon.c index c156ca744..9322444e3 100644 --- a/src/realm/realm-demon.c +++ b/src/realm/realm-demon.c @@ -3,8 +3,6 @@ #include "io/targeting.h" #include "monster-floor/monster-summon.h" #include "monster-floor/place-monster-types.h" -#include "status/bad-status-setter.h" -#include "status/buff-setter.h" #include "player/player-class.h" #include "player/player-damage.h" #include "player/player-effects.h" @@ -20,6 +18,9 @@ #include "spell/spells-status.h" #include "spell/spells-summon.h" #include "spell/spell-types.h" +#include "status/bad-status-setter.h" +#include "status/buff-setter.h" +#include "status/element-resistance.h" #include "status/sight-setter.h" #include "view/display-messages.h" diff --git a/src/realm/realm-life.c b/src/realm/realm-life.c index 82a0146a8..f8f1ddce8 100644 --- a/src/realm/realm-life.c +++ b/src/realm/realm-life.c @@ -4,7 +4,6 @@ #include "io/targeting.h" #include "player/digestion-processor.h" #include "player/player-effects.h" -#include "player/player-status.h" #include "spell-kind/spells-curse-removal.h" #include "spell-kind/spells-detection.h" #include "spell-kind/spells-floor.h" @@ -21,6 +20,7 @@ #include "spell/spells3.h" #include "status/bad-status-setter.h" #include "status/buff-setter.h" +#include "status/element-resistance.h" /*! * @brief 生命領域魔法の各処理を行う diff --git a/src/realm/realm-nature.c b/src/realm/realm-nature.c index 1e8ef1ffe..1eecd7eed 100644 --- a/src/realm/realm-nature.c +++ b/src/realm/realm-nature.c @@ -9,8 +9,6 @@ #include "object/object-generator.h" #include "object/object-kind-hook.h" #include "player/avatar.h" -#include "status/bad-status-setter.h" -#include "status/buff-setter.h" #include "player/player-damage.h" #include "player/player-effects.h" #include "player/player-race-types.h" @@ -33,6 +31,9 @@ #include "spell/spells-summon.h" #include "spell/spell-types.h" #include "spell/spells3.h" +#include "status/bad-status-setter.h" +#include "status/buff-setter.h" +#include "status/element-resistance.h" #include "sv-definition/sv-food-types.h" #include "view/display-messages.h" diff --git a/src/specific-object/chest.c b/src/specific-object/chest.c index e53161cf0..4f6c1be52 100644 --- a/src/specific-object/chest.c +++ b/src/specific-object/chest.c @@ -10,16 +10,16 @@ #include "object-enchant/item-apply-magic.h" #include "object/object-generator.h" #include "perception/object-perception.h" -#include "status/bad-status-setter.h" #include "player/player-class.h" #include "player/player-damage.h" #include "player/player-effects.h" -#include "player/player-status.h" #include "spell-kind/spells-launcher.h" #include "spell-kind/spells-sight.h" #include "spell/spells-summon.h" #include "spell/spell-types.h" #include "spell/spells3.h" +#include "status/bad-status-setter.h" +#include "status/element-resistance.h" #include "sv-definition/sv-other-types.h" #include "system/object-type-definition.h" #include "view/display-messages.h" diff --git a/src/specific-object/death-scythe.c b/src/specific-object/death-scythe.c index 79ea6b4a4..39758e788 100644 --- a/src/specific-object/death-scythe.c +++ b/src/specific-object/death-scythe.c @@ -14,6 +14,7 @@ #include "object/object-flags.h" #include "player/player-damage.h" #include "player/player-race.h" +#include "status/element-resistance.h" #include "util/bit-flags-calculator.h" #include "view/display-messages.h" diff --git a/src/status/element-resistance.c b/src/status/element-resistance.c new file mode 100644 index 000000000..c2f546f96 --- /dev/null +++ b/src/status/element-resistance.c @@ -0,0 +1,237 @@ +#include "status/element-resistance.h" +#include "core/stuff-handler.h" +#include "game-option/disturbance-options.h" +#include "player/player-move.h" +#include "player/player-race.h" +#include "player/special-defense-types.h" +#include "realm/realm-song-numbers.h" +#include "view/display-messages.h" + +/*! + * @brief 一時的酸耐性の継続時間をセットする / Set "oppose_acid", notice observable changes + * @param v 継続時間 + * @param do_dec 現在の継続時間より長い値のみ上書きする + * @return ステータスに影響を及ぼす変化があった場合TRUEを返す。 + */ +bool set_oppose_acid(player_type *creature_ptr, TIME_EFFECT v, bool do_dec) +{ + bool notice = FALSE; + v = (v > 10000) ? 10000 : (v < 0) ? 0 : v; + if (creature_ptr->is_dead) + return FALSE; + + if (v) { + if (creature_ptr->oppose_acid && !do_dec) { + if (creature_ptr->oppose_acid > v) + return FALSE; + } else if (!is_oppose_acid(creature_ptr)) { + msg_print(_("酸への耐性がついた気がする!", "You feel resistant to acid!")); + notice = TRUE; + } + } else { + if (creature_ptr->oppose_acid && !music_singing(creature_ptr, MUSIC_RESIST) && !(creature_ptr->special_defense & KATA_MUSOU)) { + msg_print(_("酸への耐性が薄れた気がする。", "You feel less resistant to acid.")); + notice = TRUE; + } + } + + creature_ptr->oppose_acid = v; + + if (!notice) + return FALSE; + creature_ptr->redraw |= (PR_STATUS); + + if (disturb_state) + disturb(creature_ptr, FALSE, FALSE); + handle_stuff(creature_ptr); + return TRUE; +} + +/*! + * @brief 一時的電撃耐性の継続時間をセットする / Set "oppose_elec", notice observable changes + * @param v 継続時間 + * @param do_dec 現在の継続時間より長い値のみ上書きする + * @return ステータスに影響を及ぼす変化があった場合TRUEを返す。 + */ +bool set_oppose_elec(player_type *creature_ptr, TIME_EFFECT v, bool do_dec) +{ + bool notice = FALSE; + v = (v > 10000) ? 10000 : (v < 0) ? 0 : v; + + if (creature_ptr->is_dead) + return FALSE; + + if (v) { + if (creature_ptr->oppose_elec && !do_dec) { + if (creature_ptr->oppose_elec > v) + return FALSE; + } else if (!is_oppose_elec(creature_ptr)) { + msg_print(_("電撃への耐性がついた気がする!", "You feel resistant to electricity!")); + notice = TRUE; + } + } else { + if (creature_ptr->oppose_elec && !music_singing(creature_ptr, MUSIC_RESIST) && !(creature_ptr->special_defense & KATA_MUSOU)) { + msg_print(_("電撃への耐性が薄れた気がする。", "You feel less resistant to electricity.")); + notice = TRUE; + } + } + + creature_ptr->oppose_elec = v; + + if (!notice) + return FALSE; + creature_ptr->redraw |= (PR_STATUS); + + if (disturb_state) + disturb(creature_ptr, FALSE, FALSE); + handle_stuff(creature_ptr); + return TRUE; +} + +/*! + * @brief 一時的火炎耐性の継続時間をセットする / Set "oppose_fire", notice observable changes + * @param v 継続時間 + * @param do_dec 現在の継続時間より長い値のみ上書きする + * @return ステータスに影響を及ぼす変化があった場合TRUEを返す。 + */ +bool set_oppose_fire(player_type *creature_ptr, TIME_EFFECT v, bool do_dec) +{ + bool notice = FALSE; + v = (v > 10000) ? 10000 : (v < 0) ? 0 : v; + if (creature_ptr->is_dead) + return FALSE; + + if ((is_specific_player_race(creature_ptr, RACE_BALROG) && (creature_ptr->lev > 44)) || (creature_ptr->mimic_form == MIMIC_DEMON)) + v = 1; + if (v) { + if (creature_ptr->oppose_fire && !do_dec) { + if (creature_ptr->oppose_fire > v) + return FALSE; + } else if (!is_oppose_fire(creature_ptr)) { + msg_print(_("火への耐性がついた気がする!", "You feel resistant to fire!")); + notice = TRUE; + } + } else { + if (creature_ptr->oppose_fire && !music_singing(creature_ptr, MUSIC_RESIST) && !(creature_ptr->special_defense & KATA_MUSOU)) { + msg_print(_("火への耐性が薄れた気がする。", "You feel less resistant to fire.")); + notice = TRUE; + } + } + + creature_ptr->oppose_fire = v; + + if (!notice) + return FALSE; + creature_ptr->redraw |= (PR_STATUS); + + if (disturb_state) + disturb(creature_ptr, FALSE, FALSE); + handle_stuff(creature_ptr); + return TRUE; +} + +/*! + * @brief 一時的冷気耐性の継続時間をセットする / Set "oppose_cold", notice observable changes + * @param v 継続時間 + * @param do_dec 現在の継続時間より長い値のみ上書きする + * @return ステータスに影響を及ぼす変化があった場合TRUEを返す。 + */ +bool set_oppose_cold(player_type *creature_ptr, TIME_EFFECT v, bool do_dec) +{ + bool notice = FALSE; + v = (v > 10000) ? 10000 : (v < 0) ? 0 : v; + if (creature_ptr->is_dead) + return FALSE; + + if (v) { + if (creature_ptr->oppose_cold && !do_dec) { + if (creature_ptr->oppose_cold > v) + return FALSE; + } else if (!is_oppose_cold(creature_ptr)) { + msg_print(_("冷気への耐性がついた気がする!", "You feel resistant to cold!")); + notice = TRUE; + } + } else { + if (creature_ptr->oppose_cold && !music_singing(creature_ptr, MUSIC_RESIST) && !(creature_ptr->special_defense & KATA_MUSOU)) { + msg_print(_("冷気への耐性が薄れた気がする。", "You feel less resistant to cold.")); + notice = TRUE; + } + } + + creature_ptr->oppose_cold = v; + + if (!notice) + return FALSE; + creature_ptr->redraw |= (PR_STATUS); + + if (disturb_state) + disturb(creature_ptr, FALSE, FALSE); + handle_stuff(creature_ptr); + return TRUE; +} + +/*! + * @brief 一時的毒耐性の継続時間をセットする / Set "oppose_pois", notice observable changes + * @param v 継続時間 + * @param do_dec 現在の継続時間より長い値のみ上書きする + * @return ステータスに影響を及ぼす変化があった場合TRUEを返す。 + */ +bool set_oppose_pois(player_type *creature_ptr, TIME_EFFECT v, bool do_dec) +{ + bool notice = FALSE; + v = (v > 10000) ? 10000 : (v < 0) ? 0 : v; + if ((creature_ptr->pclass == CLASS_NINJA) && (creature_ptr->lev > 44)) + v = 1; + if (creature_ptr->is_dead) + return FALSE; + + if (v) { + if (creature_ptr->oppose_pois && !do_dec) { + if (creature_ptr->oppose_pois > v) + return FALSE; + } else if (!is_oppose_pois(creature_ptr)) { + msg_print(_("毒への耐性がついた気がする!", "You feel resistant to poison!")); + notice = TRUE; + } + } else { + if (creature_ptr->oppose_pois && !music_singing(creature_ptr, MUSIC_RESIST) && !(creature_ptr->special_defense & KATA_MUSOU)) { + msg_print(_("毒への耐性が薄れた気がする。", "You feel less resistant to poison.")); + notice = TRUE; + } + } + + creature_ptr->oppose_pois = v; + if (!notice) + return FALSE; + creature_ptr->redraw |= (PR_STATUS); + + if (disturb_state) + disturb(creature_ptr, FALSE, FALSE); + handle_stuff(creature_ptr); + return TRUE; +} + +bool is_oppose_acid(player_type *creature_ptr) +{ + return creature_ptr->oppose_acid || music_singing(creature_ptr, MUSIC_RESIST) || (creature_ptr->special_defense & KATA_MUSOU); +} + +bool is_oppose_elec(player_type *creature_ptr) +{ + return creature_ptr->oppose_elec || music_singing(creature_ptr, MUSIC_RESIST) || (creature_ptr->special_defense & KATA_MUSOU); +} + +bool is_oppose_fire(player_type *creature_ptr) +{ + return creature_ptr->oppose_fire || music_singing(creature_ptr, MUSIC_RESIST) || (creature_ptr->special_defense & KATA_MUSOU); +} + +bool is_oppose_cold(player_type *creature_ptr) +{ + return creature_ptr->oppose_cold || music_singing(creature_ptr, MUSIC_RESIST) || (creature_ptr->special_defense & KATA_MUSOU); +} + +bool is_oppose_pois(player_type *creature_ptr) +{ + return creature_ptr->oppose_pois || music_singing(creature_ptr, MUSIC_RESIST) || (creature_ptr->special_defense & KATA_MUSOU); +} diff --git a/src/status/element-resistance.h b/src/status/element-resistance.h new file mode 100644 index 000000000..f291215a5 --- /dev/null +++ b/src/status/element-resistance.h @@ -0,0 +1,14 @@ +#pragma once + +#include "system/angband.h" + +bool set_oppose_acid(player_type *creature_ptr, TIME_EFFECT v, bool do_dec); +bool set_oppose_elec(player_type *creature_ptr, TIME_EFFECT v, bool do_dec); +bool set_oppose_fire(player_type *creature_ptr, TIME_EFFECT v, bool do_dec); +bool set_oppose_cold(player_type *creature_ptr, TIME_EFFECT v, bool do_dec); +bool set_oppose_pois(player_type *creature_ptr, TIME_EFFECT v, bool do_dec); +bool is_oppose_acid(player_type *creature_ptr); +bool is_oppose_elec(player_type *creature_ptr); +bool is_oppose_fire(player_type *creature_ptr); +bool is_oppose_cold(player_type *creature_ptr); +bool is_oppose_pois(player_type *creature_ptr); diff --git a/src/view/main-window-stat-poster.c b/src/view/main-window-stat-poster.c index 3da00bdce..ff55668c1 100644 --- a/src/view/main-window-stat-poster.c +++ b/src/view/main-window-stat-poster.c @@ -6,6 +6,7 @@ #include "realm/realm-hex-numbers.h" #include "realm/realm-types.h" #include "spell-realm/spells-hex.h" +#include "status/element-resistance.h" #include "term/screen-processor.h" #include "term/term-color-types.h" #include "view/main-window-row-column.h" -- 2.11.0