From: Hourier Date: Thu, 19 Aug 2021 16:10:34 +0000 (+0900) Subject: [Refactor] #1370 Moved display_potion_throw() from cmd-throw.cpp to throw-util.cpp/h X-Git-Tag: vmacos3.0.0-alpha52~124^2^2~10 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=de7a67f46c33f33f1c33c3c5c52172da60f2d804;p=hengbandforosx%2Fhengbandosx.git [Refactor] #1370 Moved display_potion_throw() from cmd-throw.cpp to throw-util.cpp/h --- diff --git a/src/action/throw-util.cpp b/src/action/throw-util.cpp index 6f9a523fd..9853621c4 100644 --- a/src/action/throw-util.cpp +++ b/src/action/throw-util.cpp @@ -40,6 +40,7 @@ #include "object-hook/hook-weapon.h" #include "object/item-tester-hooker.h" #include "object/item-use-flags.h" +#include "object/object-broken.h" #include "object/object-flags.h" #include "object/object-info.h" #include "object/object-kind.h" @@ -217,6 +218,35 @@ void it_type::display_figurine_throw() msg_print(_("これはあまり良くない気がする。", "You have a bad feeling about this.")); } +void it_type::display_potion_throw() +{ + if (!object_is_potion(this->q_ptr)) + return; + + if (!this->hit_body && !this->hit_wall && (randint1(100) >= this->corruption_possibility)) { + this->corruption_possibility = 0; + return; + } + + msg_format(_("%sは砕け散った!", "The %s shatters!"), this->o_name); + if (!potion_smash_effect(this->creature_ptr, 0, this->y, this->x, this->q_ptr->k_idx)) { + this->do_drop = false; + return; + } + + monster_type *angry_m_ptr = &this->creature_ptr->current_floor_ptr->m_list[this->creature_ptr->current_floor_ptr->grid_array[this->y][this->x].m_idx]; + if ((this->creature_ptr->current_floor_ptr->grid_array[this->y][this->x].m_idx == 0) || !is_friendly(angry_m_ptr) || monster_invulner_remaining(angry_m_ptr)) { + this->do_drop = false; + return; + } + + GAME_TEXT angry_m_name[MAX_NLEN]; + monster_desc(this->creature_ptr, angry_m_name, angry_m_ptr, 0); + msg_format(_("%sは怒った!", "%^s gets angry!"), angry_m_name); + set_hostile(this->creature_ptr, &this->creature_ptr->current_floor_ptr->m_list[this->creature_ptr->current_floor_ptr->grid_array[this->y][this->x].m_idx]); + this->do_drop = false; +} + bool it_type::check_what_throw() { if (this->shuriken >= 0) { diff --git a/src/action/throw-util.h b/src/action/throw-util.h index f4d029724..7fbb802a4 100644 --- a/src/action/throw-util.h +++ b/src/action/throw-util.h @@ -61,6 +61,7 @@ public: void set_racial_chance(); void exe_throw(); void display_figurine_throw(); + void display_potion_throw(); private: player_type *creature_ptr; diff --git a/src/cmd-item/cmd-throw.cpp b/src/cmd-item/cmd-throw.cpp index e81308dde..a9ce8984c 100644 --- a/src/cmd-item/cmd-throw.cpp +++ b/src/cmd-item/cmd-throw.cpp @@ -70,35 +70,6 @@ ThrowCommand::ThrowCommand(player_type* creature_ptr) { } -void display_potion_throw(player_type *creature_ptr, it_type *it_ptr) -{ - if (!object_is_potion(it_ptr->q_ptr)) - return; - - if (!it_ptr->hit_body && !it_ptr->hit_wall && (randint1(100) >= it_ptr->corruption_possibility)) { - it_ptr->corruption_possibility = 0; - return; - } - - msg_format(_("%sは砕け散った!", "The %s shatters!"), it_ptr->o_name); - if (!potion_smash_effect(creature_ptr, 0, it_ptr->y, it_ptr->x, it_ptr->q_ptr->k_idx)) { - it_ptr->do_drop = false; - return; - } - - monster_type *m_ptr = &creature_ptr->current_floor_ptr->m_list[creature_ptr->current_floor_ptr->grid_array[it_ptr->y][it_ptr->x].m_idx]; - if ((creature_ptr->current_floor_ptr->grid_array[it_ptr->y][it_ptr->x].m_idx == 0) || !is_friendly(m_ptr) || monster_invulner_remaining(m_ptr)) { - it_ptr->do_drop = false; - return; - } - - GAME_TEXT m_name[MAX_NLEN]; - monster_desc(creature_ptr, m_name, m_ptr, 0); - msg_format(_("%sは怒った!", "%^s gets angry!"), m_name); - set_hostile(creature_ptr, &creature_ptr->current_floor_ptr->m_list[creature_ptr->current_floor_ptr->grid_array[it_ptr->y][it_ptr->x].m_idx]); - it_ptr->do_drop = false; -} - static void display_boomerang_throw(player_type *creature_ptr, it_type *it_ptr) { if ((it_ptr->back_chance > 37) && !creature_ptr->blind && (it_ptr->item >= 0)) { @@ -249,7 +220,7 @@ bool ThrowCommand::do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken) it_ptr->corruption_possibility = (it_ptr->hit_body ? breakage_chance(this->creature_ptr, it_ptr->q_ptr, this->creature_ptr->pclass == CLASS_ARCHER, 0) : 0); it_ptr->display_figurine_throw(); - display_potion_throw(this->creature_ptr, it_ptr); + it_ptr->display_potion_throw(); check_boomerang_throw(this->creature_ptr, it_ptr); process_boomerang_back(this->creature_ptr, it_ptr); drop_thrown_item(this->creature_ptr, it_ptr);