can_cast &= m_ptr->ml;
can_cast &= !is_stunned;
can_cast &= player_ptr->muta.has_not(PlayerMutationType::BERS_RAGE) || !is_shero(player_ptr);
- if (!is_hostile(m_ptr) && can_cast && pattern_seq(player_ptr, player_ptr->y, player_ptr->x, y, x) && (p_can_enter || p_can_kill_walls)) {
+ if (!m_ptr->is_hostile() && can_cast && pattern_seq(player_ptr, player_ptr->y, player_ptr->x, y, x) && (p_can_enter || p_can_kill_walls)) {
(void)set_monster_csleep(player_ptr, g_ptr->m_idx, 0);
monster_desc(player_ptr, m_name, m_ptr, 0);
if (m_ptr->ml) {
return false;
}
- if (!is_hostile(m_ptr) && !(is_stunned || is_confused || is_hallucinated || is_shero(player_ptr) || !m_ptr->ml)) {
+ if (!m_ptr->is_hostile() && !(is_stunned || is_confused || is_hallucinated || is_shero(player_ptr) || !m_ptr->ml)) {
constexpr auto stormbringer = FixedArtifactId::STORMBRINGER;
auto is_stormbringer = false;
if (player_ptr->inventory_list[INVEN_MAIN_HAND].fixed_artifact_idx == stormbringer) {
void QuestCompletionChecker::complete_kill_all()
{
- if (!is_hostile(this->m_ptr) || (this->count_all_hostile_monsters() != 1)) {
+ if (!this->m_ptr->is_hostile() || (this->count_all_hostile_monsters() != 1)) {
return;
}
void QuestCompletionChecker::complete_tower()
{
const auto &quest_list = QuestList::get_instance();
- if (!is_hostile(this->m_ptr)) {
+ if (!this->m_ptr->is_hostile()) {
return;
}
for (auto x = 0; x < floor_ptr->width; ++x) {
for (auto y = 0; y < floor_ptr->height; ++y) {
auto m_idx = floor_ptr->grid_array[y][x].m_idx;
- if ((m_idx > 0) && is_hostile(&floor_ptr->m_list[m_idx])) {
+ if ((m_idx > 0) && floor_ptr->m_list[m_idx].is_hostile()) {
++number_mon;
}
}
ProcessResult effect_monster_domination(PlayerType *player_ptr, effect_monster_type *em_ptr)
{
- if (!is_hostile(em_ptr->m_ptr)) {
+ if (!em_ptr->m_ptr->is_hostile()) {
return ProcessResult::PROCESS_CONTINUE;
}
em_ptr->obvious = true;
}
- if (em_ptr->r_ptr->kind_flags.has(MonsterKindType::UNIQUE) || any_bits(em_ptr->r_ptr->flags1, RF1_QUESTOR) || (em_ptr->r_ptr->flags3 & RF3_NO_CONF) || (em_ptr->r_ptr->level > randint1((em_ptr->dam - 10) < 1 ? 1 : (em_ptr->dam - 10)) + 10)) {
+ const auto is_unique = em_ptr->r_ptr->kind_flags.has(MonsterKindType::UNIQUE);
+ const auto is_questor = any_bits(em_ptr->r_ptr->flags1, RF1_QUESTOR);
+ const auto is_no_confusion = any_bits(em_ptr->r_ptr->flags3, RF3_NO_CONF);
+ if (is_unique || is_questor || is_no_confusion || (em_ptr->r_ptr->level > randint1((em_ptr->dam - 10) < 1 ? 1 : (em_ptr->dam - 10)) + 10)) {
if (((em_ptr->r_ptr->flags3 & RF3_NO_CONF) != 0) && is_original_ap_and_seen(player_ptr, em_ptr->m_ptr)) {
em_ptr->r_ptr->r_flags3 |= (RF3_NO_CONF);
}
has_pet = true;
}
- if (monster_csleep_remaining(m_ptr) || (m_ptr->cdis > MAX_SIGHT) || !is_hostile(m_ptr)) {
+ if (monster_csleep_remaining(m_ptr) || (m_ptr->cdis > MAX_SIGHT) || !m_ptr->is_hostile()) {
continue;
}
return;
}
- bool vs_ninja = PlayerClass(player_ptr).equals(PlayerClassType::NINJA) && !is_hostile(ms_ptr->t_ptr);
+ bool vs_ninja = PlayerClass(player_ptr).equals(PlayerClassType::NINJA) && !ms_ptr->t_ptr->is_hostile();
bool can_use_lite_area = vs_ninja && ms_ptr->r_ptr->kind_flags.has_not(MonsterKindType::UNDEAD) && ms_ptr->r_ptr->resistance_flags.has_not(MonsterResistanceType::HURT_LITE) && !(ms_ptr->r_ptr->flags7 & RF7_DARK_MASK);
if (ms_ptr->r_ptr->behavior_flags.has(MonsterBehaviorType::STUPID)) {
return;
return false;
}
- return is_hostile(this->m_ptr);
+ return this->m_ptr->is_hostile();
}
/*!
return true;
}
- if (!is_hostile(m_ptr)) {
+ if (!m_ptr->is_hostile()) {
mm[0] = mm[1] = mm[2] = mm[3] = 5;
get_enemy_dir(player_ptr, m_idx, mm);
return true;
monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
if (m_ptr->ml && (disturb_move || (disturb_near && m_ptr->mflag.has(MonsterTemporaryFlagType::VIEW) && projectable(player_ptr, player_ptr->y, player_ptr->x, m_ptr->fy, m_ptr->fx)) || (disturb_high && ap_r_ptr->r_tkills && ap_r_ptr->level >= player_ptr->lev))) {
- if (is_hostile(m_ptr)) {
+ if (m_ptr->is_hostile()) {
disturb(player_ptr, false, true);
}
}
auto *floor_ptr = this->player_ptr->current_floor_ptr;
auto *m_ptr = &floor_ptr->m_list[this->m_idx];
auto *r_ptr = &r_info[m_ptr->r_idx];
- if (this->done || this->will_run || !is_hostile(m_ptr) || none_bits(r_ptr->flags1, RF1_FRIENDS)) {
+ if (this->done || this->will_run || !m_ptr->is_hostile() || none_bits(r_ptr->flags1, RF1_FRIENDS)) {
return;
}
}
}
- if (is_hostile(m_ptr) != is_hostile(n_ptr)) {
+ if (m_ptr->is_hostile() != n_ptr->is_hostile()) {
return true;
}
return m_ptr->ap_r_idx == m_ptr->r_idx;
}
-bool is_hostile(const monster_type *m_ptr)
-{
- return !m_ptr->is_friendly() && !m_ptr->is_pet();
-}
-
/*!
* @brief モンスターがアイテム類に擬態しているかどうかを返す
*
bool monster_has_hostile_align(PlayerType *player_ptr, monster_type *m_ptr, int pa_good, int pa_evil, monster_race *r_ptr);
bool is_original_ap_and_seen(PlayerType *player_ptr, monster_type *m_ptr);
-bool is_hostile(const monster_type *m_ptr);
bool is_original_ap(const monster_type *m_ptr);
bool is_mimicry(monster_type *m_ptr);
um_ptr->m_ptr->mflag.set(MonsterTemporaryFlagType::SANITY_BLAST);
}
- if (disturb_near && (projectable(player_ptr, um_ptr->m_ptr->fy, um_ptr->m_ptr->fx, player_ptr->y, player_ptr->x) && projectable(player_ptr, player_ptr->y, player_ptr->x, um_ptr->m_ptr->fy, um_ptr->m_ptr->fx))) {
- if (disturb_pets || is_hostile(um_ptr->m_ptr)) {
+ const auto &m_ref = *um_ptr->m_ptr;
+ const auto projectable_from_monster = projectable(player_ptr, m_ref.fy, m_ref.fx, player_ptr->y, player_ptr->x);
+ const auto projectable_from_player = projectable(player_ptr, player_ptr->y, player_ptr->x, m_ref.fy, m_ref.fx);
+ if (disturb_near && projectable_from_monster && projectable_from_player) {
+ if (disturb_pets || m_ref.is_hostile()) {
disturb(player_ptr, true, true);
}
}
player_ptr->redraw |= PR_UHEALTH;
}
- if (um_ptr->do_disturb && (disturb_pets || is_hostile(um_ptr->m_ptr))) {
+ if (um_ptr->do_disturb && (disturb_pets || um_ptr->m_ptr->is_hostile())) {
disturb(player_ptr, true, true);
}
}
if (um_ptr->m_ptr->mflag.has_not(MonsterTemporaryFlagType::VIEW)) {
um_ptr->m_ptr->mflag.set(MonsterTemporaryFlagType::VIEW);
- if (um_ptr->do_disturb && (disturb_pets || is_hostile(um_ptr->m_ptr))) {
+ if (um_ptr->do_disturb && (disturb_pets || um_ptr->m_ptr->is_hostile())) {
disturb(player_ptr, true, true);
}
}
}
um_ptr->m_ptr->mflag.reset(MonsterTemporaryFlagType::VIEW);
- if (um_ptr->do_disturb && (disturb_pets || is_hostile(um_ptr->m_ptr))) {
+ if (um_ptr->do_disturb && (disturb_pets || um_ptr->m_ptr->is_hostile())) {
disturb(player_ptr, true, true);
}
}
return false;
}
- if (msa_ptr->m_ptr->mflag.has(MonsterTemporaryFlagType::PREVENT_MAGIC) || !is_hostile(msa_ptr->m_ptr) || ((msa_ptr->m_ptr->cdis > get_max_range(player_ptr)) && !msa_ptr->m_ptr->target_y)) {
+ const auto &m_ref = *msa_ptr->m_ptr;
+ if (m_ref.mflag.has(MonsterTemporaryFlagType::PREVENT_MAGIC) || !m_ref.is_hostile() || ((m_ref.cdis > get_max_range(player_ptr)) && !m_ref.target_y)) {
return false;
}
concptr msg_done;
auto *floor_ptr = player_ptr->current_floor_ptr;
auto *m_ptr = &floor_ptr->m_list[m_idx];
- monster_type *t_ptr = &floor_ptr->m_list[t_idx];
auto *r_ptr = &r_info[m_ptr->r_idx];
bool can_use_lite_area = false;
bool monster_to_monster = target_type == MONSTER_TO_MONSTER;
GAME_TEXT t_name[MAX_NLEN];
monster_name(player_ptr, t_idx, t_name);
- if (PlayerClass(player_ptr).equals(PlayerClassType::NINJA) && r_ptr->kind_flags.has_not(MonsterKindType::UNDEAD) && r_ptr->resistance_flags.has_not(MonsterResistanceType::HURT_LITE) && !(r_ptr->flags7 & RF7_DARK_MASK)) {
+ const auto is_ninja = PlayerClass(player_ptr).equals(PlayerClassType::NINJA);
+ const auto is_living_monster = r_ptr->kind_flags.has_not(MonsterKindType::UNDEAD);
+ const auto is_not_weak_lite = r_ptr->resistance_flags.has_not(MonsterResistanceType::HURT_LITE);
+ if (is_ninja && is_living_monster && is_not_weak_lite && none_bits(r_ptr->flags7, RF7_DARK_MASK)) {
can_use_lite_area = true;
}
- if (monster_to_monster && !is_hostile(t_ptr)) {
+ const auto &t_ref = floor_ptr->m_list[t_idx];
+ if (monster_to_monster && !t_ref.is_hostile()) {
can_use_lite_area = false;
}
if (monster_csleep_remaining(m_ptr)) {
continue;
}
- if (!is_hostile(m_ptr)) {
+ if (!m_ptr->is_hostile()) {
continue;
}
{
return this->mflag2.has(MonsterConstantFlagType::PET);
}
+
+bool monster_type::is_hostile() const
+{
+ return !this->is_friendly() && !this->is_pet();
+}
bool is_friendly() const;
bool is_pet() const;
+ bool is_hostile() const;
};