From: Hourier Date: Thu, 5 Aug 2021 08:59:12 +0000 (+0900) Subject: [Refactor] #929 Separated change_virtue_wild_thief() from mon_take_hit() X-Git-Tag: vmacos3.0.0-alpha52~139^2~2^2~11 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=911098d9c15c53b22a789ed30ca53cc6f44646b8;p=hengbandforosx%2Fhengbandosx.git [Refactor] #929 Separated change_virtue_wild_thief() from mon_take_hit() --- diff --git a/src/monster/monster-damage.cpp b/src/monster/monster-damage.cpp index 85a412997..2dd7217e5 100644 --- a/src/monster/monster-damage.cpp +++ b/src/monster/monster-damage.cpp @@ -72,9 +72,6 @@ MonsterDamageProcessor::MonsterDamageProcessor(player_type *target_ptr, MONSTER_ bool MonsterDamageProcessor::mon_take_hit(concptr note) { auto *m_ptr = &this->target_ptr->current_floor_ptr->m_list[this->m_idx]; - auto innocent = true; - auto thief = false; - monster_type exp_mon; (void)COPY(&exp_mon, m_ptr, monster_type); @@ -123,30 +120,7 @@ bool MonsterDamageProcessor::mon_take_hit(concptr note) chg_virtue(this->target_ptr, V_VALOUR, -1); } - for (auto i = 0; i < MAX_NUM_BLOWS; i++) { - if (r_ptr->blow[i].d_dice != 0) { - innocent = false; - } - - if ((r_ptr->blow[i].effect == RBE_EAT_ITEM) || (r_ptr->blow[i].effect == RBE_EAT_GOLD)) { - thief = true; - } - } - - if (r_ptr->level > 0) { - innocent = false; - } - - if (thief) { - if (any_bits(r_ptr->flags1, RF1_UNIQUE)) { - chg_virtue(this->target_ptr, V_JUSTICE, 3); - } else if (1 + ((r_ptr->level) / 10 + (2 * this->target_ptr->current_floor_ptr->dun_level)) >= randint1(100)) { - chg_virtue(this->target_ptr, V_JUSTICE, 1); - } - } else if (innocent) { - chg_virtue(this->target_ptr, V_JUSTICE, -1); - } - + this->change_virtue_wild_thief(); auto magic_ability_flags = r_ptr->ability_flags; magic_ability_flags.reset(RF_ABILITY_NOMAGIC_MASK); if (any_bits(r_ptr->flags3, RF3_ANIMAL) && none_bits(r_ptr->flags3, RF3_EVIL) && magic_ability_flags.none()) { @@ -533,6 +507,48 @@ void MonsterDamageProcessor::change_virtue_revenge() } } +/* + * @brief 盗み逃げをするモンスター及び地上のモンスターを攻撃した際に徳を変化させる + */ +void MonsterDamageProcessor::change_virtue_wild_thief() +{ + auto *floor_ptr = this->target_ptr->current_floor_ptr; + auto *m_ptr = &floor_ptr->m_list[this->m_idx]; + auto *r_ptr = &r_info[m_ptr->r_idx]; + auto innocent = true; + auto thief = false; + for (auto i = 0; i < MAX_NUM_BLOWS; i++) { + if (r_ptr->blow[i].d_dice != 0) { + innocent = false; + } + + if ((r_ptr->blow[i].effect == RBE_EAT_ITEM) || (r_ptr->blow[i].effect == RBE_EAT_GOLD)) { + thief = true; + } + } + + if (r_ptr->level > 0) { + innocent = false; + } + + if (thief) { + if (any_bits(r_ptr->flags1, RF1_UNIQUE)) { + chg_virtue(this->target_ptr, V_JUSTICE, 3); + return; + } + + if (1 + ((r_ptr->level) / 10 + (2 * floor_ptr->dun_level)) >= randint1(100)) { + chg_virtue(this->target_ptr, V_JUSTICE, 1); + } + + return; + } + + if (innocent) { + chg_virtue(this->target_ptr, V_JUSTICE, -1); + } +} + /*! * @brief モンスターに与えたダメージを元に経験値を加算する / * Calculate experience point to be get diff --git a/src/monster/monster-damage.h b/src/monster/monster-damage.h index fe6315212..b12bfe897 100644 --- a/src/monster/monster-damage.h +++ b/src/monster/monster-damage.h @@ -33,6 +33,7 @@ private: void change_virtue_unique(); void change_virtue_good_evil(); void change_virtue_revenge(); + void change_virtue_wild_thief(); void set_redraw(); void summon_special_unique(); };