From cfd411443a8607e42b81c09da3b945490909a9e1 Mon Sep 17 00:00:00 2001 From: Hourier Date: Fri, 5 Jun 2020 18:49:24 +0900 Subject: [PATCH 1/1] [Refactor] #40414 Separated spells-pet.c/h from spells2.c/h --- Hengband/Hengband/Hengband.vcxproj | 2 + Hengband/Hengband/Hengband.vcxproj.filters | 6 +++ src/Makefile.am | 1 + src/realm/realm-daemon.c | 1 + src/spell/spells-pet.c | 61 ++++++++++++++++++++++++++++++ src/spell/spells-pet.h | 5 +++ src/spell/spells2.c | 56 --------------------------- src/spell/spells2.h | 1 - 8 files changed, 76 insertions(+), 57 deletions(-) create mode 100644 src/spell/spells-pet.c create mode 100644 src/spell/spells-pet.h diff --git a/Hengband/Hengband/Hengband.vcxproj b/Hengband/Hengband/Hengband.vcxproj index e58f289e5..cf8df281c 100644 --- a/Hengband/Hengband/Hengband.vcxproj +++ b/Hengband/Hengband/Hengband.vcxproj @@ -361,6 +361,7 @@ + @@ -579,6 +580,7 @@ + diff --git a/Hengband/Hengband/Hengband.vcxproj.filters b/Hengband/Hengband/Hengband.vcxproj.filters index 885c6d090..e13e4076c 100644 --- a/Hengband/Hengband/Hengband.vcxproj.filters +++ b/Hengband/Hengband/Hengband.vcxproj.filters @@ -1151,6 +1151,9 @@ spell + + spell + @@ -2458,6 +2461,9 @@ spell + + spell + diff --git a/src/Makefile.am b/src/Makefile.am index 1355f4a38..9c5a6c49d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -400,6 +400,7 @@ hengband_SOURCES = \ spell/spells-launcher.c spell/spells-launcher.h \ spell/spells-lite.c spell/spells-lite.h \ spell/spells-object.c spell/spells-object.h \ + spell/spells-pet.c spell/spells-pet.h \ spell/spells-sight.c spell/spells-sight.h \ spell/spells-summon.c spell/spells-summon.h \ spell/spells-staff-only.c spell/spells-staff-only.h \ diff --git a/src/realm/realm-daemon.c b/src/realm/realm-daemon.c index d177f6ae5..07f2c7cc7 100644 --- a/src/realm/realm-daemon.c +++ b/src/realm/realm-daemon.c @@ -10,6 +10,7 @@ #include "spell/spells-floor.h" #include "spell/spells-launcher.h" #include "spell/spells-object.h" +#include "spell/spells-pet.h" #include "spell/spells-sight.h" #include "spell/spells-status.h" #include "spell/spells-summon.h" diff --git a/src/spell/spells-pet.c b/src/spell/spells-pet.c new file mode 100644 index 000000000..1143eb951 --- /dev/null +++ b/src/spell/spells-pet.c @@ -0,0 +1,61 @@ +#include "spell/spells-pet.h" +#include "effect/effect-characteristics.h" +#include "floor/floor.h" +#include "io/write-diary.h" +#include "spell/process-effect.h" +#include "spell/spells-type.h" + +/*! + * @brief ペット爆破処理 / + * @return なし + */ +void discharge_minion(player_type *caster_ptr) +{ + bool okay = TRUE; + for (MONSTER_IDX i = 1; i < caster_ptr->current_floor_ptr->m_max; i++) { + monster_type *m_ptr = &caster_ptr->current_floor_ptr->m_list[i]; + if (!m_ptr->r_idx || !is_pet(m_ptr)) + continue; + if (m_ptr->nickname) + okay = FALSE; + } + + if (!okay || caster_ptr->riding) { + if (!get_check(_("本当に全ペットを爆破しますか?", "You will blast all pets. Are you sure? "))) + return; + } + + for (MONSTER_IDX i = 1; i < caster_ptr->current_floor_ptr->m_max; i++) { + monster_type *m_ptr = &caster_ptr->current_floor_ptr->m_list[i]; + if (!m_ptr->r_idx || !is_pet(m_ptr)) + continue; + + monster_race *r_ptr; + r_ptr = &r_info[m_ptr->r_idx]; + if (r_ptr->flags1 & RF1_UNIQUE) { + GAME_TEXT m_name[MAX_NLEN]; + monster_desc(caster_ptr, m_name, m_ptr, 0x00); + msg_format(_("%sは爆破されるのを嫌がり、勝手に自分の世界へと帰った。", "%^s resists being blasted and runs away."), m_name); + delete_monster_idx(caster_ptr, i); + continue; + } + + HIT_POINT dam = m_ptr->maxhp / 2; + if (dam > 100) + dam = (dam - 100) / 2 + 100; + if (dam > 400) + dam = (dam - 400) / 2 + 400; + if (dam > 800) + dam = 800; + project(caster_ptr, i, 2 + (r_ptr->level / 20), m_ptr->fy, m_ptr->fx, dam, GF_PLASMA, PROJECT_STOP | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL, -1); + + if (record_named_pet && m_ptr->nickname) { + GAME_TEXT m_name[MAX_NLEN]; + + monster_desc(caster_ptr, m_name, m_ptr, MD_INDEF_VISIBLE); + exe_write_diary(caster_ptr, DIARY_NAMED_PET, RECORD_NAMED_PET_BLAST, m_name); + } + + delete_monster_idx(caster_ptr, i); + } +} diff --git a/src/spell/spells-pet.h b/src/spell/spells-pet.h new file mode 100644 index 000000000..524a12365 --- /dev/null +++ b/src/spell/spells-pet.h @@ -0,0 +1,5 @@ +#pragma once + +#include "system/angband.h" + +void discharge_minion(player_type *caster_ptr); diff --git a/src/spell/spells2.c b/src/spell/spells2.c index 4b5348eba..af74d433c 100644 --- a/src/spell/spells2.c +++ b/src/spell/spells2.c @@ -70,62 +70,6 @@ #include "world/world.h" /*! - * @brief ペット爆破処理 / - * @return なし - */ -void discharge_minion(player_type *caster_ptr) -{ - bool okay = TRUE; - for (MONSTER_IDX i = 1; i < caster_ptr->current_floor_ptr->m_max; i++) - { - monster_type *m_ptr = &caster_ptr->current_floor_ptr->m_list[i]; - if (!m_ptr->r_idx || !is_pet(m_ptr)) continue; - if (m_ptr->nickname) okay = FALSE; - } - - if (!okay || caster_ptr->riding) - { - if (!get_check(_("本当に全ペットを爆破しますか?", "You will blast all pets. Are you sure? "))) - return; - } - - for (MONSTER_IDX i = 1; i < caster_ptr->current_floor_ptr->m_max; i++) - { - monster_type *m_ptr = &caster_ptr->current_floor_ptr->m_list[i]; - if (!m_ptr->r_idx || !is_pet(m_ptr)) continue; - - monster_race *r_ptr; - r_ptr = &r_info[m_ptr->r_idx]; - if (r_ptr->flags1 & RF1_UNIQUE) - { - GAME_TEXT m_name[MAX_NLEN]; - monster_desc(caster_ptr, m_name, m_ptr, 0x00); - msg_format(_("%sは爆破されるのを嫌がり、勝手に自分の世界へと帰った。", "%^s resists being blasted and runs away."), m_name); - delete_monster_idx(caster_ptr, i); - continue; - } - - HIT_POINT dam = m_ptr->maxhp / 2; - if (dam > 100) dam = (dam - 100) / 2 + 100; - if (dam > 400) dam = (dam - 400) / 2 + 400; - if (dam > 800) dam = 800; - project(caster_ptr, i, 2 + (r_ptr->level / 20), m_ptr->fy, m_ptr->fx, dam, GF_PLASMA, - PROJECT_STOP | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL, -1); - - if (record_named_pet && m_ptr->nickname) - { - GAME_TEXT m_name[MAX_NLEN]; - - monster_desc(caster_ptr, m_name, m_ptr, MD_INDEF_VISIBLE); - exe_write_diary(caster_ptr, DIARY_NAMED_PET, RECORD_NAMED_PET_BLAST, m_name); - } - - delete_monster_idx(caster_ptr, i); - } -} - - -/*! * @brief 衰弱ボルト処理 * @param caster_ptr プレーヤーへの参照ポインタ * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする) diff --git a/src/spell/spells2.h b/src/spell/spells2.h index deded05a0..e673e9db6 100644 --- a/src/spell/spells2.h +++ b/src/spell/spells2.h @@ -26,7 +26,6 @@ bool control_one_undead(player_type* caster_ptr, DIRECTION dir, PLAYER_LEVEL ple bool control_one_demon(player_type* caster_ptr, DIRECTION dir, PLAYER_LEVEL plev); bool charm_animal(player_type* caster_ptr, DIRECTION dir, PLAYER_LEVEL plev); bool eat_magic(player_type* caster_ptr, int power); -void discharge_minion(player_type* caster_ptr); void ring_of_power(player_type* caster_ptr, DIRECTION dir); void wild_magic(player_type* caster_ptr, int spell); void cast_meteor(player_type* caster_ptr, HIT_POINT dam, POSITION rad); -- 2.11.0