From adfeb85c30eed25c1aa6837a4a17d6c03f859655 Mon Sep 17 00:00:00 2001 From: Hourier Date: Tue, 18 Aug 2020 17:50:01 +0900 Subject: [PATCH] [Refactor] #40634 Separated activate_breath_*() from activation-switcher.c to activation-breath.c/h --- src/object-activation/activation-breath.c | 29 +++++++++++++++++++++++++++++ src/object-activation/activation-breath.h | 2 ++ src/object-activation/activation-switcher.c | 23 +++-------------------- 3 files changed, 34 insertions(+), 20 deletions(-) diff --git a/src/object-activation/activation-breath.c b/src/object-activation/activation-breath.c index a60633e95..c42541c8f 100644 --- a/src/object-activation/activation-breath.c +++ b/src/object-activation/activation-breath.c @@ -3,6 +3,9 @@ #include "object/object-flags.h" #include "spell-kind/spells-launcher.h" #include "spell-realm/spells-hex.h" +#include "spell/spell-types.h" +#include "status/element-resistance.h" +#include "sv-definition/sv-ring-types.h" #include "system/object-type-definition.h" #include "target/target-getter.h" #include "util/bit-flags-calculator.h" @@ -49,3 +52,29 @@ bool activate_dragon_breath(player_type *user_ptr, object_type *o_ptr) fire_breath(user_ptr, type[t], dir, 250, 4); return TRUE; } + +bool activate_breath_fire(player_type *user_ptr, object_type *o_ptr) +{ + DIRECTION dir; + if (!get_aim_dir(user_ptr, &dir)) + return FALSE; + + fire_breath(user_ptr, GF_FIRE, dir, 200, 2); + if ((o_ptr->tval == TV_RING) && (o_ptr->sval == SV_RING_FLAMES)) + (void)set_oppose_fire(user_ptr, randint1(20) + 20, FALSE); + + return TRUE; +} + +bool activate_breath_cold(player_type *user_ptr, object_type *o_ptr) +{ + DIRECTION dir; + if (!get_aim_dir(user_ptr, &dir)) + return FALSE; + + fire_breath(user_ptr, GF_COLD, dir, 200, 2); + if ((o_ptr->tval == TV_RING) && (o_ptr->sval == SV_RING_ICE)) + (void)set_oppose_cold(user_ptr, randint1(20) + 20, FALSE); + + return TRUE; +} diff --git a/src/object-activation/activation-breath.h b/src/object-activation/activation-breath.h index 3806a3b23..a304340fb 100644 --- a/src/object-activation/activation-breath.h +++ b/src/object-activation/activation-breath.h @@ -3,3 +3,5 @@ #include "system/angband.h" bool activate_dragon_breath(player_type *user_ptr, object_type *o_ptr); +bool activate_breath_fire(player_type *user_ptr, object_type *o_ptr); +bool activate_breath_cold(player_type *user_ptr, object_type *o_ptr); diff --git a/src/object-activation/activation-switcher.c b/src/object-activation/activation-switcher.c index cc1ff7fbf..d93a27a56 100644 --- a/src/object-activation/activation-switcher.c +++ b/src/object-activation/activation-switcher.c @@ -576,28 +576,11 @@ bool switch_activation(player_type *user_ptr, object_type *o_ptr, const activati case ACT_BLADETURNER: return activate_bladeturner(user_ptr); case ACT_BR_FIRE: - if (!get_aim_dir(user_ptr, &dir)) - return FALSE; - - fire_breath(user_ptr, GF_FIRE, dir, 200, 2); - if ((o_ptr->tval == TV_RING) && (o_ptr->sval == SV_RING_FLAMES)) - (void)set_oppose_fire(user_ptr, randint1(20) + 20, FALSE); - - return TRUE; + return activate_breath_fire(user_ptr, o_ptr); case ACT_BR_COLD: - if (!get_aim_dir(user_ptr, &dir)) - return FALSE; - - fire_breath(user_ptr, GF_COLD, dir, 200, 2); - if ((o_ptr->tval == TV_RING) && (o_ptr->sval == SV_RING_ICE)) - (void)set_oppose_cold(user_ptr, randint1(20) + 20, FALSE); - - return TRUE; + return activate_breath_cold(user_ptr, o_ptr); case ACT_BR_DRAGON: - if (!activate_dragon_breath(user_ptr, o_ptr)) - return FALSE; - - return TRUE; + return activate_dragon_breath(user_ptr, o_ptr); case ACT_CONFUSE: msg_print(_("様々な色の火花を発している...", "It glows in scintillating colours...")); if (!get_aim_dir(user_ptr, &dir)) -- 2.11.0