From 0ac772177fbbc9d0df1e9ca3b0d878c93781ac3b Mon Sep 17 00:00:00 2001 From: Slimebreath6078 Date: Mon, 21 Feb 2022 01:03:31 +0900 Subject: [PATCH] =?utf8?q?[Refactor]=20#2243=20=E4=B8=80=E7=82=B9=E3=82=92?= =?utf8?q?=E7=8B=99=E3=81=86=E9=AD=94=E6=B3=95=E3=82=92breath=E9=96=A2?= =?utf8?q?=E6=95=B0=E3=81=8B=E3=82=89=E5=88=87=E3=82=8A=E9=9B=A2=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/mspell/mspell-checker.cpp | 23 +++++++++-------------- src/mspell/mspell-checker.h | 1 + src/mspell/mspell-curse.cpp | 4 ++-- src/mspell/mspell-particularity.cpp | 4 ++-- src/mspell/mspell-status.cpp | 6 +++--- 5 files changed, 17 insertions(+), 21 deletions(-) diff --git a/src/mspell/mspell-checker.cpp b/src/mspell/mspell-checker.cpp index a6e598a9e..8363d0168 100644 --- a/src/mspell/mspell-checker.cpp +++ b/src/mspell/mspell-checker.cpp @@ -265,22 +265,17 @@ ProjectResult breath(PlayerType *player_ptr, POSITION y, POSITION x, MONSTER_IDX if (breath) rad = 0 - rad; - switch (typ) { - case AttributeType::DRAIN_MANA: - case AttributeType::MIND_BLAST: - case AttributeType::BRAIN_SMASH: - case AttributeType::CAUSE_1: - case AttributeType::CAUSE_2: - case AttributeType::CAUSE_3: - case AttributeType::CAUSE_4: - case AttributeType::HAND_DOOM: - flg |= (PROJECT_HIDE | PROJECT_AIMED); - break; - default: - break; + return project(player_ptr, m_idx, rad, y, x, dam_hp, typ, flg); +} + +ProjectResult pointed(PlayerType *player_ptr, POSITION y, POSITION x, MONSTER_IDX m_idx, AttributeType typ, int dam_hp, int target_type) +{ + BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_HIDE | PROJECT_AIMED; + if (target_type == MONSTER_TO_PLAYER) { + flg |= PROJECT_PLAYER; } - return project(player_ptr, m_idx, rad, y, x, dam_hp, typ, flg); + return project(player_ptr, m_idx, 0, y, x, dam_hp, typ, flg); } ProjectResult rocket(PlayerType *player_ptr, POSITION y, POSITION x, MONSTER_IDX m_idx, AttributeType typ, int dam_hp, POSITION rad, int target_type) diff --git a/src/mspell/mspell-checker.h b/src/mspell/mspell-checker.h index 7b1443225..744e56381 100644 --- a/src/mspell/mspell-checker.h +++ b/src/mspell/mspell-checker.h @@ -14,6 +14,7 @@ bool raise_possible(PlayerType *player_ptr, monster_type *m_ptr); bool spell_is_inate(MonsterAbilityType spell); ProjectResult beam(PlayerType *player_ptr, MONSTER_IDX m_idx, POSITION y, POSITION x, AttributeType typ, int dam_hp, int target_type); ProjectResult bolt(PlayerType *player_ptr, MONSTER_IDX m_idx, POSITION y, POSITION x, AttributeType typ, int dam_hp, int target_type); +ProjectResult pointed(PlayerType *player_ptr, POSITION y, POSITION x, MONSTER_IDX m_idx, AttributeType typ, int dam_hp, int target_type); ProjectResult breath( PlayerType *player_ptr, POSITION y, POSITION x, MONSTER_IDX m_idx, AttributeType typ, int dam_hp, POSITION rad, bool breath, int target_type); ProjectResult rocket(PlayerType *player_ptr, POSITION y, POSITION x, MONSTER_IDX m_idx, AttributeType typ, int dam_hp, POSITION rad, int target_type); diff --git a/src/mspell/mspell-curse.cpp b/src/mspell/mspell-curse.cpp index f059bb0f1..35d69874a 100644 --- a/src/mspell/mspell-curse.cpp +++ b/src/mspell/mspell-curse.cpp @@ -45,7 +45,7 @@ static MonsterSpellResult spell_RF5_CAUSE(PlayerType *player_ptr, AttributeType msg_format(msg1, m_name); else msg_format(msg2, m_name); - breath(player_ptr, y, x, m_idx, GF_TYPE, dam, 0, false, target_type); + pointed(player_ptr, y, x, m_idx, GF_TYPE, dam, target_type); return res; } @@ -57,7 +57,7 @@ static MonsterSpellResult spell_RF5_CAUSE(PlayerType *player_ptr, AttributeType } } - breath(player_ptr, y, x, m_idx, GF_TYPE, dam, 0, false, target_type); + pointed(player_ptr, y, x, m_idx, GF_TYPE, dam, target_type); return res; } diff --git a/src/mspell/mspell-particularity.cpp b/src/mspell/mspell-particularity.cpp index c8ec4ebe7..c7c1f5efe 100644 --- a/src/mspell/mspell-particularity.cpp +++ b/src/mspell/mspell-particularity.cpp @@ -70,10 +70,10 @@ MonsterSpellResult spell_RF6_HAND_DOOM(PlayerType *player_ptr, POSITION y, POSIT ProjectResult proj_res; if (target_type == MONSTER_TO_PLAYER) { const auto dam = monspell_damage(player_ptr, MonsterAbilityType::HAND_DOOM, m_idx, DAM_ROLL); - proj_res = breath(player_ptr, y, x, m_idx, AttributeType::HAND_DOOM, dam, 0, false, MONSTER_TO_PLAYER); + proj_res = pointed(player_ptr, y, x, m_idx, AttributeType::HAND_DOOM, dam, MONSTER_TO_PLAYER); } else if (target_type == MONSTER_TO_MONSTER) { const auto dam = 20; /* Dummy power */ - proj_res = breath(player_ptr, y, x, m_idx, AttributeType::HAND_DOOM, dam, 0, false, MONSTER_TO_MONSTER); + proj_res = pointed(player_ptr, y, x, m_idx, AttributeType::HAND_DOOM, dam, MONSTER_TO_MONSTER); } auto res = MonsterSpellResult::make_valid(); diff --git a/src/mspell/mspell-status.cpp b/src/mspell/mspell-status.cpp index 8f9c869d9..973231291 100644 --- a/src/mspell/mspell-status.cpp +++ b/src/mspell/mspell-status.cpp @@ -149,7 +149,7 @@ MonsterSpellResult spell_RF5_DRAIN_MANA(PlayerType *player_ptr, POSITION y, POSI } const auto dam = monspell_damage(player_ptr, MonsterAbilityType::DRAIN_MANA, m_idx, DAM_ROLL); - const auto proj_res = breath(player_ptr, y, x, m_idx, AttributeType::DRAIN_MANA, dam, 0, false, target_type); + const auto proj_res = pointed(player_ptr, y, x, m_idx, AttributeType::DRAIN_MANA, dam, target_type); if (target_type == MONSTER_TO_PLAYER) update_smart_learn(player_ptr, m_idx, DRS_MANA); @@ -189,7 +189,7 @@ MonsterSpellResult spell_RF5_MIND_BLAST(PlayerType *player_ptr, POSITION y, POSI } const auto dam = monspell_damage(player_ptr, MonsterAbilityType::MIND_BLAST, m_idx, DAM_ROLL); - const auto proj_res = breath(player_ptr, y, x, m_idx, AttributeType::MIND_BLAST, dam, 0, false, target_type); + const auto proj_res = pointed(player_ptr, y, x, m_idx, AttributeType::MIND_BLAST, dam, target_type); auto res = MonsterSpellResult::make_valid(dam); res.learnable = proj_res.affected_player; @@ -227,7 +227,7 @@ MonsterSpellResult spell_RF5_BRAIN_SMASH(PlayerType *player_ptr, POSITION y, POS } const auto dam = monspell_damage(player_ptr, MonsterAbilityType::BRAIN_SMASH, m_idx, DAM_ROLL); - const auto proj_res = breath(player_ptr, y, x, m_idx, AttributeType::BRAIN_SMASH, dam, 0, false, target_type); + const auto proj_res = pointed(player_ptr, y, x, m_idx, AttributeType::BRAIN_SMASH, dam, target_type); auto res = MonsterSpellResult::make_valid(dam); res.learnable = proj_res.affected_player; -- 2.11.0