OSDN Git Service

[Refactor] #2243 ボールをbreath関数から切り離す
authorSlimebreath6078 <slimebreath6078@yahoo.co.jp>
Sun, 20 Feb 2022 16:19:18 +0000 (01:19 +0900)
committerSlimebreath6078 <slimebreath6078@yahoo.co.jp>
Mon, 21 Feb 2022 14:54:27 +0000 (23:54 +0900)
src/mspell/mspell-ball.cpp
src/mspell/mspell-checker.cpp
src/mspell/mspell-checker.h

index 89c9ccb..de6979b 100644 (file)
@@ -36,7 +36,7 @@ MonsterSpellResult spell_RF4_BA_NUKE(PlayerType *player_ptr, POSITION y, POSITIO
     monspell_message(player_ptr, m_idx, t_idx, msg, target_type);
 
     const auto dam = monspell_damage(player_ptr, MonsterAbilityType::BA_NUKE, m_idx, DAM_ROLL);
-    const auto proj_res = breath(player_ptr, y, x, m_idx, AttributeType::NUKE, dam, 2, false, target_type);
+    const auto proj_res = ball(player_ptr, y, x, m_idx, AttributeType::NUKE, dam, 2, target_type);
     if (target_type == MONSTER_TO_PLAYER) {
         update_smart_learn(player_ptr, m_idx, DRS_POIS);
     }
@@ -66,7 +66,7 @@ MonsterSpellResult spell_RF4_BA_CHAO(PlayerType *player_ptr, POSITION y, POSITIO
     monspell_message(player_ptr, m_idx, t_idx, msg, target_type);
 
     const auto dam = monspell_damage(player_ptr, MonsterAbilityType::BA_CHAO, m_idx, DAM_ROLL);
-    const auto proj_res = breath(player_ptr, y, x, m_idx, AttributeType::CHAOS, dam, 4, false, target_type);
+    const auto proj_res = ball(player_ptr, y, x, m_idx, AttributeType::CHAOS, dam, 4, target_type);
     if (target_type == MONSTER_TO_PLAYER) {
         update_smart_learn(player_ptr, m_idx, DRS_CHAOS);
     }
@@ -98,7 +98,7 @@ MonsterSpellResult spell_RF5_BA_ACID(PlayerType *player_ptr, POSITION y, POSITIO
 
     const auto rad = monster_is_powerful(player_ptr->current_floor_ptr, m_idx) ? 4 : 2;
     const auto dam = monspell_damage(player_ptr, MonsterAbilityType::BA_ACID, m_idx, DAM_ROLL);
-    const auto proj_res = breath(player_ptr, y, x, m_idx, AttributeType::ACID, dam, rad, false, target_type);
+    const auto proj_res = ball(player_ptr, y, x, m_idx, AttributeType::ACID, dam, rad, target_type);
     if (target_type == MONSTER_TO_PLAYER) {
         update_smart_learn(player_ptr, m_idx, DRS_ACID);
     }
@@ -130,7 +130,7 @@ MonsterSpellResult spell_RF5_BA_ELEC(PlayerType *player_ptr, POSITION y, POSITIO
 
     const auto rad = monster_is_powerful(player_ptr->current_floor_ptr, m_idx) ? 4 : 2;
     const auto dam = monspell_damage(player_ptr, MonsterAbilityType::BA_ELEC, m_idx, DAM_ROLL);
-    const auto proj_res = breath(player_ptr, y, x, m_idx, AttributeType::ELEC, dam, rad, false, target_type);
+    const auto proj_res = ball(player_ptr, y, x, m_idx, AttributeType::ELEC, dam, rad, target_type);
     if (target_type == MONSTER_TO_PLAYER) {
         update_smart_learn(player_ptr, m_idx, DRS_ELEC);
     }
@@ -171,7 +171,7 @@ MonsterSpellResult spell_RF5_BA_FIRE(PlayerType *player_ptr, POSITION y, POSITIO
 
     const auto rad = monster_is_powerful(player_ptr->current_floor_ptr, m_idx) ? 4 : 2;
     const auto dam = monspell_damage(player_ptr, MonsterAbilityType::BA_FIRE, m_idx, DAM_ROLL);
-    const auto proj_res = breath(player_ptr, y, x, m_idx, AttributeType::FIRE, dam, rad, false, target_type);
+    const auto proj_res = ball(player_ptr, y, x, m_idx, AttributeType::FIRE, dam, rad, target_type);
     if (target_type == MONSTER_TO_PLAYER) {
         update_smart_learn(player_ptr, m_idx, DRS_FIRE);
     }
@@ -203,7 +203,7 @@ MonsterSpellResult spell_RF5_BA_COLD(PlayerType *player_ptr, POSITION y, POSITIO
 
     const auto rad = monster_is_powerful(player_ptr->current_floor_ptr, m_idx) ? 4 : 2;
     const auto dam = monspell_damage(player_ptr, MonsterAbilityType::BA_COLD, m_idx, DAM_ROLL);
-    const auto proj_res = breath(player_ptr, y, x, m_idx, AttributeType::COLD, dam, rad, false, target_type);
+    const auto proj_res = ball(player_ptr, y, x, m_idx, AttributeType::COLD, dam, rad, target_type);
     if (target_type == MONSTER_TO_PLAYER) {
         update_smart_learn(player_ptr, m_idx, DRS_COLD);
     }
@@ -233,7 +233,7 @@ MonsterSpellResult spell_RF5_BA_POIS(PlayerType *player_ptr, POSITION y, POSITIO
     monspell_message(player_ptr, m_idx, t_idx, msg, target_type);
 
     const auto dam = monspell_damage(player_ptr, MonsterAbilityType::BA_POIS, m_idx, DAM_ROLL);
-    const auto proj_res = breath(player_ptr, y, x, m_idx, AttributeType::POIS, dam, 2, false, target_type);
+    const auto proj_res = ball(player_ptr, y, x, m_idx, AttributeType::POIS, dam, 2, target_type);
     if (target_type == MONSTER_TO_PLAYER) {
         update_smart_learn(player_ptr, m_idx, DRS_POIS);
     }
@@ -263,7 +263,7 @@ MonsterSpellResult spell_RF5_BA_NETH(PlayerType *player_ptr, POSITION y, POSITIO
     monspell_message(player_ptr, m_idx, t_idx, msg, target_type);
 
     const auto dam = monspell_damage(player_ptr, MonsterAbilityType::BA_NETH, m_idx, DAM_ROLL);
-    const auto proj_res = breath(player_ptr, y, x, m_idx, AttributeType::NETHER, dam, 2, false, target_type);
+    const auto proj_res = ball(player_ptr, y, x, m_idx, AttributeType::NETHER, dam, 2, target_type);
     if (target_type == MONSTER_TO_PLAYER) {
         update_smart_learn(player_ptr, m_idx, DRS_NETH);
     }
@@ -306,7 +306,7 @@ MonsterSpellResult spell_RF5_BA_WATE(PlayerType *player_ptr, POSITION y, POSITIO
     }
 
     const auto dam = monspell_damage(player_ptr, MonsterAbilityType::BA_WATE, m_idx, DAM_ROLL);
-    const auto proj_res = breath(player_ptr, y, x, m_idx, AttributeType::WATER, dam, 4, false, target_type);
+    const auto proj_res = ball(player_ptr, y, x, m_idx, AttributeType::WATER, dam, 4, target_type);
 
     auto res = MonsterSpellResult::make_valid(dam);
     res.learnable = proj_res.affected_player;
@@ -333,7 +333,7 @@ MonsterSpellResult spell_RF5_BA_MANA(PlayerType *player_ptr, POSITION y, POSITIO
     monspell_message(player_ptr, m_idx, t_idx, msg, target_type);
 
     const auto dam = monspell_damage(player_ptr, MonsterAbilityType::BA_MANA, m_idx, DAM_ROLL);
-    const auto proj_res = breath(player_ptr, y, x, m_idx, AttributeType::MANA, dam, 4, false, target_type);
+    const auto proj_res = ball(player_ptr, y, x, m_idx, AttributeType::MANA, dam, 4, target_type);
 
     auto res = MonsterSpellResult::make_valid(dam);
     res.learnable = proj_res.affected_player;
@@ -361,7 +361,7 @@ MonsterSpellResult spell_RF5_BA_DARK(PlayerType *player_ptr, POSITION y, POSITIO
     monspell_message(player_ptr, m_idx, t_idx, msg, target_type);
 
     const auto dam = monspell_damage(player_ptr, MonsterAbilityType::BA_DARK, m_idx, DAM_ROLL);
-    const auto proj_res = breath(player_ptr, y, x, m_idx, AttributeType::DARK, dam, 4, false, target_type);
+    const auto proj_res = ball(player_ptr, y, x, m_idx, AttributeType::DARK, dam, 4, target_type);
     if (target_type == MONSTER_TO_PLAYER) {
         update_smart_learn(player_ptr, m_idx, DRS_DARK);
     }
@@ -392,7 +392,7 @@ MonsterSpellResult spell_RF5_BA_LITE(PlayerType *player_ptr, POSITION y, POSITIO
     monspell_message(player_ptr, m_idx, t_idx, msg, target_type);
 
     const auto dam = monspell_damage(player_ptr, MonsterAbilityType::BA_LITE, m_idx, DAM_ROLL);
-    const auto proj_res = breath(player_ptr, y, x, m_idx, AttributeType::LITE, dam, 4, false, target_type);
+    const auto proj_res = ball(player_ptr, y, x, m_idx, AttributeType::LITE, dam, 4, target_type);
     if (target_type == MONSTER_TO_PLAYER) {
         update_smart_learn(player_ptr, m_idx, DRS_LITE);
     }
@@ -423,7 +423,7 @@ MonsterSpellResult spell_RF5_BA_VOID(PlayerType *player_ptr, POSITION y, POSITIO
     monspell_message(player_ptr, m_idx, t_idx, msg, target_type);
 
     const auto dam = monspell_damage(player_ptr, MonsterAbilityType::BA_VOID, m_idx, DAM_ROLL);
-    const auto proj_res = breath(player_ptr, y, x, m_idx, AttributeType::VOID_MAGIC, dam, 4, false, target_type);
+    const auto proj_res = ball(player_ptr, y, x, m_idx, AttributeType::VOID_MAGIC, dam, 4, target_type);
 
     auto res = MonsterSpellResult::make_valid(dam);
     res.learnable = proj_res.affected_player;
@@ -451,7 +451,7 @@ MonsterSpellResult spell_RF5_BA_ABYSS(PlayerType *player_ptr, POSITION y, POSITI
     monspell_message(player_ptr, m_idx, t_idx, msg, target_type);
 
     const auto dam = monspell_damage(player_ptr, MonsterAbilityType::BA_ABYSS, m_idx, DAM_ROLL);
-    const auto proj_res = breath(player_ptr, y, x, m_idx, AttributeType::ABYSS, dam, 4, false, target_type);
+    const auto proj_res = ball(player_ptr, y, x, m_idx, AttributeType::ABYSS, dam, 4, target_type);
     if (target_type == MONSTER_TO_PLAYER) {
         update_smart_learn(player_ptr, m_idx, DRS_DARK);
     }
index 8363d01..f2c0566 100644 (file)
@@ -231,6 +231,16 @@ ProjectResult beam(PlayerType *player_ptr, MONSTER_IDX m_idx, POSITION y, POSITI
     return project(player_ptr, m_idx, 0, y, x, dam_hp, typ, flg);
 }
 
+ProjectResult ball(PlayerType *player_ptr, POSITION y, POSITION x, MONSTER_IDX m_idx, AttributeType typ, int dam_hp, POSITION rad, int target_type)
+{
+    BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
+    if (target_type == MONSTER_TO_PLAYER) {
+        flg |= PROJECT_PLAYER;
+    }
+
+    return project(player_ptr, m_idx, rad, y, x, dam_hp, typ, flg);
+}
+
 /*!
  * @brief モンスターのボール型&ブレス型魔法処理 /
  * Cast a breath (or ball) attack at the player Pass over any monsters that may be in the way Affect grids, objects, monsters, and the player
index 744e563..28916ad 100644 (file)
@@ -15,6 +15,7 @@ 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 ball(PlayerType *player_ptr, POSITION y, POSITION x, MONSTER_IDX m_idx, AttributeType typ, int dam_hp, POSITION rad, 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);