ArtifactList::get_instance().reset_generated_flags();
BaseitemList::get_instance().reset_identification_flags();
- for (auto &[r_idx, r_ref] : monraces_info) {
- if (!MonsterRace(r_ref.idx).is_valid()) {
+ for (auto &[_, monrace] : monraces_info) {
+ if (!monrace.is_valid()) {
continue;
}
- r_ref.cur_num = 0;
- r_ref.max_num = MAX_MONSTER_NUM;
- if (r_ref.kind_flags.has(MonsterKindType::UNIQUE)) {
- r_ref.max_num = MAX_UNIQUE_NUM;
- } else if (r_ref.population_flags.has(MonsterPopulationType::NAZGUL)) {
- r_ref.max_num = MAX_NAZGUL_NUM;
+ monrace.cur_num = 0;
+ monrace.max_num = MAX_MONSTER_NUM;
+ if (monrace.kind_flags.has(MonsterKindType::UNIQUE)) {
+ monrace.max_num = MAX_UNIQUE_NUM;
+ } else if (monrace.population_flags.has(MonsterPopulationType::NAZGUL)) {
+ monrace.max_num = MAX_NAZGUL_NUM;
}
- r_ref.r_pkills = 0;
- r_ref.r_akills = 0;
+ monrace.r_pkills = 0;
+ monrace.r_akills = 0;
}
player_ptr->food = PY_FOOD_FULL - 1;
switch (attack) {
case PlayerMutationType::SCOR_TAIL:
project(player_ptr, 0, 0, m_ptr->fy, m_ptr->fx, k, AttributeType::POIS, PROJECT_KILL);
- *mdeath = !MonsterRace(m_ptr->r_idx).is_valid();
+ *mdeath = !m_ptr->is_valid();
break;
case PlayerMutationType::HORNS:
case PlayerMutationType::BEAK:
exe_affect_monster_by_damage(player_ptr, em_ptr);
update_phase_out_stat(player_ptr, em_ptr);
- const auto monster_is_valid = MonsterRace(em_ptr->m_ptr->r_idx).is_valid();
+ const auto monster_is_valid = em_ptr->m_ptr->is_valid();
if (monster_is_valid) {
update_monster(player_ptr, target_m_idx, false);
}
return { basename, "" };
}
- if (!MonsterRace(monrace_id).is_valid()) {
+ if (!monrace.is_valid()) {
return { basename, _(" (空)", " (empty)") };
}
auto norm_total = 0;
for (const auto &[monrace_id, monrace] : monraces) {
/* Ignore unused index */
- if (!MonsterRace(monrace_id).is_valid()) {
+ if (!monrace.is_valid()) {
continue;
}
return;
}
- for (auto &[r_idx, r_ref] : monraces_info) {
- if (!MonsterRace(r_ref.idx).is_valid()) {
+ for (auto &[monrace_id, monrace] : monraces_info) {
+ if (!monrace.is_valid()) {
continue;
}
- if (!sweep_uniques(&r_ref, unique_list_ptr->is_alive)) {
+ if (!sweep_uniques(&monrace, unique_list_ptr->is_alive)) {
continue;
}
- if (r_ref.level) {
- int lev = (r_ref.level - 1) / 10;
+ if (monrace.level) {
+ int lev = (monrace.level - 1) / 10;
if (lev < 10) {
unique_list_ptr->num_uniques[lev]++;
if (unique_list_ptr->max_lev < lev) {
unique_list_ptr->num_uniques_surface++;
}
- unique_list_ptr->monrace_ids.push_back(r_ref.idx);
+ unique_list_ptr->monrace_ids.push_back(monrace_id);
}
const auto &monraces = MonraceList::get_instance();
void init_monsters_alloc()
{
std::vector<const MonsterRaceInfo *> elements;
- for (const auto &[r_idx, r_ref] : monraces_info) {
- if (MonsterRace(r_ref.idx).is_valid()) {
- elements.push_back(&r_ref);
+ for (const auto &[monrace_id, monrace] : monraces_info) {
+ if (monrace.is_valid()) {
+ elements.push_back(&monrace);
}
}
std::vector<MonsterRaceId> monrace_ids;
const auto &monraces = MonraceList::get_instance();
for (const auto &[monrace_id, monrace] : monraces) {
- if (!MonsterRace(monrace_id).is_valid()) {
+ if (!monrace.is_valid()) {
continue;
}
static void aura_fire_by_melee(PlayerType *player_ptr, mam_type *mam_ptr)
{
- auto *r_ptr = &mam_ptr->m_ptr->get_monrace();
- auto *tr_ptr = &mam_ptr->t_ptr->get_monrace();
- if (tr_ptr->aura_flags.has_not(MonsterAuraType::FIRE) || !MonsterRace(mam_ptr->m_ptr->r_idx).is_valid()) {
+ auto &monrace = mam_ptr->m_ptr->get_monrace();
+ auto &monrace_target = mam_ptr->t_ptr->get_monrace();
+ if (monrace_target.aura_flags.has_not(MonsterAuraType::FIRE) || !mam_ptr->m_ptr->is_valid()) {
return;
}
- if (r_ptr->resistance_flags.has_any_of(RFR_EFF_IM_FIRE_MASK) && is_original_ap_and_seen(player_ptr, mam_ptr->m_ptr)) {
- r_ptr->r_resistance_flags.set(r_ptr->resistance_flags & RFR_EFF_IM_FIRE_MASK);
+ if (monrace.resistance_flags.has_any_of(RFR_EFF_IM_FIRE_MASK) && is_original_ap_and_seen(player_ptr, mam_ptr->m_ptr)) {
+ monrace.r_resistance_flags.set(monrace.resistance_flags & RFR_EFF_IM_FIRE_MASK);
return;
}
}
if (mam_ptr->m_ptr->ml && is_original_ap_and_seen(player_ptr, mam_ptr->t_ptr)) {
- tr_ptr->aura_flags.set(MonsterAuraType::FIRE);
+ monrace_target.aura_flags.set(MonsterAuraType::FIRE);
}
- const auto dam = damroll(1 + ((tr_ptr->level) / 26), 1 + ((tr_ptr->level) / 17));
+ const auto dam = damroll(1 + ((monrace_target.level) / 26), 1 + ((monrace_target.level) / 17));
constexpr auto flags = PROJECT_KILL | PROJECT_STOP | PROJECT_AIMED;
project(player_ptr, mam_ptr->t_idx, 0, mam_ptr->m_ptr->fy, mam_ptr->m_ptr->fx, dam, AttributeType::FIRE, flags);
}
static void aura_cold_by_melee(PlayerType *player_ptr, mam_type *mam_ptr)
{
- const auto *m_ptr = mam_ptr->m_ptr;
- auto *r_ptr = &m_ptr->get_monrace();
- auto *tr_ptr = &mam_ptr->t_ptr->get_monrace();
- if (tr_ptr->aura_flags.has_not(MonsterAuraType::COLD) || !MonsterRace(m_ptr->r_idx).is_valid()) {
+ const auto &monster = *mam_ptr->m_ptr;
+ auto &monrace = monster.get_monrace();
+ auto &monrace_target = mam_ptr->t_ptr->get_monrace();
+ if (monrace_target.aura_flags.has_not(MonsterAuraType::COLD) || !monster.is_valid()) {
return;
}
- if (r_ptr->resistance_flags.has_any_of(RFR_EFF_IM_COLD_MASK) && is_original_ap_and_seen(player_ptr, m_ptr)) {
- r_ptr->r_resistance_flags.set(r_ptr->resistance_flags & RFR_EFF_IM_COLD_MASK);
+ if (monrace.resistance_flags.has_any_of(RFR_EFF_IM_COLD_MASK) && is_original_ap_and_seen(player_ptr, &monster)) {
+ monrace.r_resistance_flags.set(monrace.resistance_flags & RFR_EFF_IM_COLD_MASK);
return;
}
msg_format(_("%s^は突然寒くなった!", "%s^ is suddenly very cold!"), mam_ptr->m_name);
}
- if (m_ptr->ml && is_original_ap_and_seen(player_ptr, mam_ptr->t_ptr)) {
- tr_ptr->aura_flags.set(MonsterAuraType::COLD);
+ if (monster.ml && is_original_ap_and_seen(player_ptr, mam_ptr->t_ptr)) {
+ monrace_target.aura_flags.set(MonsterAuraType::COLD);
}
- const auto dam = damroll(1 + ((tr_ptr->level) / 26), 1 + ((tr_ptr->level) / 17));
+ const auto dam = damroll(1 + ((monrace_target.level) / 26), 1 + ((monrace_target.level) / 17));
constexpr auto flags = PROJECT_KILL | PROJECT_STOP | PROJECT_AIMED;
- project(player_ptr, mam_ptr->t_idx, 0, m_ptr->fy, m_ptr->fx, dam, AttributeType::COLD, flags);
+ project(player_ptr, mam_ptr->t_idx, 0, monster.fy, monster.fx, dam, AttributeType::COLD, flags);
}
static void aura_elec_by_melee(PlayerType *player_ptr, mam_type *mam_ptr)
{
- const auto *m_ptr = mam_ptr->m_ptr;
- auto *r_ptr = &m_ptr->get_monrace();
- auto *tr_ptr = &mam_ptr->t_ptr->get_monrace();
- if (tr_ptr->aura_flags.has_not(MonsterAuraType::ELEC) || !MonsterRace(m_ptr->r_idx).is_valid()) {
+ const auto &monster = *mam_ptr->m_ptr;
+ auto &monrace = monster.get_monrace();
+ auto &monrace_target = mam_ptr->t_ptr->get_monrace();
+ if (monrace_target.aura_flags.has_not(MonsterAuraType::ELEC) || !monster.is_valid()) {
return;
}
- if (r_ptr->resistance_flags.has_any_of(RFR_EFF_IM_ELEC_MASK) && is_original_ap_and_seen(player_ptr, m_ptr)) {
- r_ptr->r_resistance_flags.set(r_ptr->resistance_flags & RFR_EFF_IM_ELEC_MASK);
+ if (monrace.resistance_flags.has_any_of(RFR_EFF_IM_ELEC_MASK) && is_original_ap_and_seen(player_ptr, &monster)) {
+ monrace.r_resistance_flags.set(monrace.resistance_flags & RFR_EFF_IM_ELEC_MASK);
return;
}
msg_format(_("%s^は電撃を食らった!", "%s^ gets zapped!"), mam_ptr->m_name);
}
- if (m_ptr->ml && is_original_ap_and_seen(player_ptr, mam_ptr->t_ptr)) {
- tr_ptr->aura_flags.set(MonsterAuraType::ELEC);
+ if (monster.ml && is_original_ap_and_seen(player_ptr, mam_ptr->t_ptr)) {
+ monrace_target.aura_flags.set(MonsterAuraType::ELEC);
}
- const auto dam = damroll(1 + ((tr_ptr->level) / 26), 1 + ((tr_ptr->level) / 17));
+ const auto dam = damroll(1 + ((monrace_target.level) / 26), 1 + ((monrace_target.level) / 17));
constexpr auto flags = PROJECT_KILL | PROJECT_STOP | PROJECT_AIMED;
- project(player_ptr, mam_ptr->t_idx, 0, m_ptr->fy, m_ptr->fx, dam, AttributeType::ELEC, flags);
+ project(player_ptr, mam_ptr->t_idx, 0, monster.fy, monster.fx, dam, AttributeType::ELEC, flags);
}
static bool check_same_monster(PlayerType *player_ptr, mam_type *mam_ptr)
repeat_melee(player_ptr, mam_ptr);
explode_monster_by_melee(player_ptr, mam_ptr);
- if (!mam_ptr->blinked || !MonsterRace(mam_ptr->m_ptr->r_idx).is_valid()) {
+ if (!mam_ptr->blinked || !mam_ptr->m_ptr->is_valid()) {
return true;
}
*/
static bool exe_monster_attack_to_monster(PlayerType *player_ptr, MONSTER_IDX m_idx, Grid *g_ptr)
{
- auto &floor = *player_ptr->current_floor_ptr;
- auto *m_ptr = &floor.m_list[m_idx];
- auto *r_ptr = &m_ptr->get_monrace();
- MonsterEntity *y_ptr;
- y_ptr = &player_ptr->current_floor_ptr->m_list[g_ptr->m_idx];
- if (r_ptr->behavior_flags.has(MonsterBehaviorType::NEVER_BLOW)) {
+ const auto &floor = *player_ptr->current_floor_ptr;
+ const auto &monster = floor.m_list[m_idx];
+ auto &monrace = monster.get_monrace();
+ const auto &monster_target = player_ptr->current_floor_ptr->m_list[g_ptr->m_idx];
+ if (monrace.behavior_flags.has(MonsterBehaviorType::NEVER_BLOW)) {
return false;
}
- if ((r_ptr->behavior_flags.has_not(MonsterBehaviorType::KILL_BODY)) && is_original_ap_and_seen(player_ptr, m_ptr)) {
- r_ptr->r_behavior_flags.set(MonsterBehaviorType::KILL_BODY);
+ if ((monrace.behavior_flags.has_not(MonsterBehaviorType::KILL_BODY)) && is_original_ap_and_seen(player_ptr, &monster)) {
+ monrace.r_behavior_flags.set(MonsterBehaviorType::KILL_BODY);
}
- if (!MonsterRace(y_ptr->r_idx).is_valid() || (y_ptr->hp < 0)) {
+ if (!monster_target.is_valid() || (monster_target.hp < 0)) {
return false;
}
if (monst_attack_monst(player_ptr, m_idx, g_ptr->m_idx)) {
if (floor.get_dungeon_definition().flags.has_not(DungeonFeatureType::NO_MELEE)) {
return false;
}
- if (m_ptr->is_confused()) {
+ if (monster.is_confused()) {
return true;
}
- if (r_ptr->behavior_flags.has_not(MonsterBehaviorType::STUPID)) {
+ if (monrace.behavior_flags.has_not(MonsterBehaviorType::STUPID)) {
return false;
}
- if (is_original_ap_and_seen(player_ptr, m_ptr)) {
- r_ptr->r_behavior_flags.set(MonsterBehaviorType::STUPID);
+ if (is_original_ap_and_seen(player_ptr, &monster)) {
+ monrace.r_behavior_flags.set(MonsterBehaviorType::STUPID);
}
return true;
// 召喚元のモンスターが消滅した時は、召喚されたモンスターのparent_m_idxが
// 召喚されたモンスター自身のm_idxを指すようにする
for (MONSTER_IDX child_m_idx = 1; child_m_idx < floor_ptr->m_max; child_m_idx++) {
- MonsterEntity *child_m_ptr = &floor_ptr->m_list[child_m_idx];
- if (MonsterRace(child_m_ptr->r_idx).is_valid() && child_m_ptr->parent_m_idx == i) {
- child_m_ptr->parent_m_idx = child_m_idx;
+ auto &child_monster = floor_ptr->m_list[child_m_idx];
+ if (child_monster.is_valid() && child_monster.parent_m_idx == i) {
+ child_monster.parent_m_idx = child_m_idx;
}
}
static ProbabilityTable<MonsterRaceId> table;
if (table.empty()) {
- for (const auto &[r_idx, r_ref] : monraces_info) {
- if (MonsterRace(r_idx).is_valid()) {
- table.entry_item(r_idx, 1);
+ for (const auto &[monrace_id, monrace] : monraces_info) {
+ if (monrace.is_valid()) {
+ table.entry_item(monrace_id, 1);
}
}
}
/* Excise dead monsters (backwards!) */
for (MONSTER_IDX i = floor_ptr->m_max - 1; i >= 1; i--) {
- auto *m_ptr = &floor_ptr->m_list[i];
- if (MonsterRace(m_ptr->r_idx).is_valid()) {
+ const auto &monster = floor_ptr->m_list[i];
+ if (monster.is_valid()) {
continue;
}
compact_monsters_aux(player_ptr, floor_ptr->m_max - 1, i);
/* Recycle dead monsters */
for (short i = 1; i < floor_ptr->m_max; i++) {
const auto &monster = floor_ptr->m_list[i];
- if (MonsterRace(monster.r_idx).is_valid()) {
+ if (monster.is_valid()) {
continue;
}
}
// parent_m_idxが自分自身を指している場合は召喚主は消滅している
- if (m_ptr->parent_m_idx != m_idx && MonsterRace(player_ptr->current_floor_ptr->m_list[m_ptr->parent_m_idx].r_idx).is_valid()) {
+ if (m_ptr->parent_m_idx != m_idx && player_ptr->current_floor_ptr->m_list[m_ptr->parent_m_idx].is_valid()) {
return false;
}
case 8:
if (!count) {
msg_print(_("空間が歪んだ!", "Space warps about you!"));
- if (MonsterRace(m_ptr->r_idx).is_valid()) {
+ if (m_ptr->is_valid()) {
teleport_away(player_ptr, g_ptr->m_idx, damroll(10, 10), TELEPORT_PASSIVE);
}
if (one_in_(13)) {
bool okay = true;
for (MONSTER_IDX i = 1; i < player_ptr->current_floor_ptr->m_max; i++) {
auto *m_ptr = &player_ptr->current_floor_ptr->m_list[i];
- if (!MonsterRace(m_ptr->r_idx).is_valid() || !m_ptr->is_pet()) {
+ if (!m_ptr->is_valid() || !m_ptr->is_pet()) {
continue;
}
if (m_ptr->is_named()) {
for (MONSTER_IDX i = 1; i < player_ptr->current_floor_ptr->m_max; i++) {
auto *m_ptr = &player_ptr->current_floor_ptr->m_list[i];
- if (!MonsterRace(m_ptr->r_idx).is_valid() || !m_ptr->is_pet()) {
+ if (!m_ptr->is_valid() || !m_ptr->is_pet()) {
continue;
}
void teleport_monster_to(PlayerType *player_ptr, MONSTER_IDX m_idx, POSITION ty, POSITION tx, int power, teleport_flags mode)
{
auto *m_ptr = &player_ptr->current_floor_ptr->m_list[m_idx];
- if (!MonsterRace(m_ptr->r_idx).is_valid()) {
+ if (!m_ptr->is_valid()) {
return;
}
if (randint1(100) > power) {
bool MonsterEntity::is_valid() const
{
- return MonsterRace(this->r_idx).is_valid();
+ return MonraceList::is_valid(this->r_idx);
}
MonsterRaceId MonsterEntity::get_real_monrace_id() const
}
/*!
+ * @todo 将来的に定義側のIDが廃止されたら有効フラグのフィールド変数を代わりに作る.
+ */
+bool MonsterRaceInfo::is_valid() const
+{
+ return this->idx != MonsterRaceId::PLAYER;
+}
+
+/*!
* @brief エルドリッチホラーの形容詞種別を決める
* @return エルドリッチホラーの形容詞
*/
REAL_TIME defeat_time{}; //!< 倒した時間(ユニーク用) / time at which defeated this race
PERCENTAGE cur_hp_per{}; //!< 生成時現在HP率(%)
+ bool is_valid() const;
const std::string &decide_horror_message() const;
bool has_living_flag() const;
bool is_explodable() const;
if (m_ptr->is_pet()) {
continue;
} // pet
- if (!MonsterRace(m_ptr->r_idx).is_valid()) {
+ if (!m_ptr->is_valid()) {
continue;
} // dead?
term_putstr(col - 2, row + row_offset, 12, TERM_WHITE, " / ");
auto &monster = player_ptr->current_floor_ptr->m_list[monster_list_index];
- if (MonsterRace(monster.r_idx).is_valid()) {
+ if (monster.is_valid()) {
const auto &monrace = monster.get_monrace();
const auto &symbol_config = monrace.symbol_config;
term_putstr(col - 2, row + row_offset, 2, symbol_config.color, format("%c", symbol_config.character));
{
std::set<MonsterRaceId> evol_parents;
std::set<MonsterRaceId> evol_children;
- for (const auto &[r_idx, r_ref] : monraces_info) {
- if (MonsterRace(r_ref.next_r_idx).is_valid()) {
- evol_parents.emplace(r_ref.idx);
- evol_children.emplace(r_ref.next_r_idx);
+ for (const auto &[monrace_id, monrace] : monraces_info) {
+ if (MonsterRace(monrace.next_r_idx).is_valid()) {
+ evol_parents.emplace(monrace_id);
+ evol_children.emplace(monrace.next_r_idx);
}
}