X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=src%2Fmonster-floor%2Fmonster-summon.cpp;h=ec17bf22cf1fd82b6815005e6cc7c3ffdff14fcf;hb=ca06a783f4715e692abeaecf5565101aa95624e6;hp=08c1aea2048b1196a206d885e69036f1e0b1d65d;hpb=cfc19a9ec715315a99cceab25446d6d012afc6a6;p=hengbandforosx%2Fhengbandosx.git diff --git a/src/monster-floor/monster-summon.cpp b/src/monster-floor/monster-summon.cpp index 08c1aea20..ec17bf22c 100644 --- a/src/monster-floor/monster-summon.cpp +++ b/src/monster-floor/monster-summon.cpp @@ -1,6 +1,5 @@ -#include "monster-floor/monster-summon.h" +#include "monster-floor/monster-summon.h" #include "dungeon/dungeon-flag-types.h" -#include "dungeon/dungeon.h" #include "floor/geometry.h" #include "floor/wild.h" #include "main/sound-definitions-table.h" @@ -11,14 +10,16 @@ #include "monster-race/monster-race.h" #include "monster-race/race-flags1.h" #include "monster-race/race-flags7.h" +#include "monster-race/race-indice-types.h" #include "monster/monster-info.h" #include "monster/monster-list.h" #include "monster/monster-util.h" #include "mspell/summon-checker.h" #include "spell/summon-types.h" +#include "system/dungeon-info.h" #include "system/floor-type-definition.h" -#include "system/monster-race-definition.h" -#include "system/monster-type-definition.h" +#include "system/monster-entity.h" +#include "system/monster-race-info.h" #include "system/player-type-definition.h" /*! @@ -40,39 +41,47 @@ bool summon_unique_okay = false; * @param r_idx チェックするモンスター種族ID * @return 召喚対象にできるならばTRUE */ -static bool summon_specific_okay(player_type *player_ptr, MONRACE_IDX r_idx) +static bool summon_specific_okay(PlayerType *player_ptr, MonsterRaceId r_idx) { - monster_race *r_ptr = &r_info[r_idx]; - if (!mon_hook_dungeon(player_ptr, r_idx)) + auto *r_ptr = &monraces_info[r_idx]; + if (!mon_hook_dungeon(player_ptr, r_idx)) { return false; + } + auto &floor = *player_ptr->current_floor_ptr; if (summon_specific_who > 0) { - monster_type *m_ptr = &player_ptr->current_floor_ptr->m_list[summon_specific_who]; - if (monster_has_hostile_align(player_ptr, m_ptr, 0, 0, r_ptr)) + auto *m_ptr = &floor.m_list[summon_specific_who]; + if (monster_has_hostile_align(player_ptr, m_ptr, 0, 0, r_ptr)) { return false; + } } else if (summon_specific_who < 0) { - if (monster_has_hostile_align(player_ptr, nullptr, 10, -10, r_ptr) && !one_in_(std::abs(player_ptr->alignment) / 2 + 1)) + if (monster_has_hostile_align(player_ptr, nullptr, 10, -10, r_ptr) && !one_in_(std::abs(player_ptr->alignment) / 2 + 1)) { return false; + } } - if (!summon_unique_okay && ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL))) + if (!summon_unique_okay && (r_ptr->kind_flags.has(MonsterKindType::UNIQUE) || (r_ptr->population_flags.has(MonsterPopulationType::NAZGUL)))) { return false; + } - if (!summon_specific_type) + if (!summon_specific_type) { return true; + } - if ((summon_specific_who < 0) && ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL)) - && monster_has_hostile_align(player_ptr, nullptr, 10, -10, r_ptr)) + const auto is_like_unique = r_ptr->kind_flags.has(MonsterKindType::UNIQUE) || (r_ptr->population_flags.has(MonsterPopulationType::NAZGUL)); + if ((summon_specific_who < 0) && is_like_unique && monster_has_hostile_align(player_ptr, nullptr, 10, -10, r_ptr)) { return false; + } - if ((r_ptr->flags7 & RF7_CHAMELEON) && d_info[player_ptr->dungeon_idx].flags.has(DF::CHAMELEON)) + if (r_ptr->misc_flags.has(MonsterMiscType::CHAMELEON) && floor.get_dungeon_definition().flags.has(DungeonFeatureType::CHAMELEON)) { return true; + } if (summon_specific_who > 0) { - monster_type *m_ptr = &player_ptr->current_floor_ptr->m_list[summon_specific_who]; + auto *m_ptr = &floor.m_list[summon_specific_who]; return check_summon_specific(player_ptr, m_ptr->r_idx, r_idx); } else { - return check_summon_specific(player_ptr, 0, r_idx); + return check_summon_specific(player_ptr, MonsterRaceId::PLAYER, r_idx); } } @@ -97,11 +106,12 @@ static bool is_dead_summoning(summon_type type) * ダンジョン及びクエストはdun_level>0となる。 * 荒野はdun_level==0なので、その場合荒野レベルを返す。 */ -DEPTH get_dungeon_or_wilderness_level(player_type *player_ptr) +DEPTH get_dungeon_or_wilderness_level(PlayerType *player_ptr) { - floor_type *floor_ptr = player_ptr->current_floor_ptr; - if (floor_ptr->dun_level > 0) + auto *floor_ptr = player_ptr->current_floor_ptr; + if (floor_ptr->dun_level > 0) { return floor_ptr->dun_level; + } return wilderness[player_ptr->wilderness_y][player_ptr->wilderness_x].level; } @@ -117,15 +127,17 @@ DEPTH get_dungeon_or_wilderness_level(player_type *player_ptr) * @param mode 生成オプション * @return 召喚できたらtrueを返す */ -bool summon_specific(player_type *player_ptr, MONSTER_IDX who, POSITION y1, POSITION x1, DEPTH lev, summon_type type, BIT_FLAGS mode) +bool summon_specific(PlayerType *player_ptr, MONSTER_IDX who, POSITION y1, POSITION x1, DEPTH lev, summon_type type, BIT_FLAGS mode) { - floor_type *floor_ptr = player_ptr->current_floor_ptr; - if (floor_ptr->inside_arena) + auto *floor_ptr = player_ptr->current_floor_ptr; + if (floor_ptr->inside_arena) { return false; + } POSITION x, y; - if (!mon_scatter(player_ptr, 0, &y, &x, y1, x1, 2)) + if (!mon_scatter(player_ptr, MonsterRace::empty_id(), &y, &x, y1, x1, 2)) { return false; + } summon_specific_who = who; summon_specific_type = type; @@ -133,16 +145,17 @@ bool summon_specific(player_type *player_ptr, MONSTER_IDX who, POSITION y1, POSI get_mon_num_prep(player_ptr, summon_specific_okay, get_monster_hook2(player_ptr, y, x)); DEPTH dlev = get_dungeon_or_wilderness_level(player_ptr); - MONRACE_IDX r_idx = get_mon_num(player_ptr, 0, (dlev + lev) / 2 + 5, 0); - if (!r_idx) { + MonsterRaceId r_idx = get_mon_num(player_ptr, 0, (dlev + lev) / 2 + 5, mode); + if (!MonsterRace(r_idx).is_valid()) { summon_specific_type = SUMMON_NONE; return false; } - if (is_dead_summoning(type)) + if (is_dead_summoning(type)) { mode |= PM_NO_KAGE; + } - if (!place_monster_aux(player_ptr, who, y, x, r_idx, mode)) { + if (!place_specific_monster(player_ptr, who, y, x, r_idx, mode)) { summon_specific_type = SUMMON_NONE; return false; } @@ -153,8 +166,8 @@ bool summon_specific(player_type *player_ptr, MONSTER_IDX who, POSITION y1, POSI if (who <= 0) { notice = true; } else { - monster_type *m_ptr = &player_ptr->current_floor_ptr->m_list[who]; - if (is_pet(m_ptr)) { + auto *m_ptr = &player_ptr->current_floor_ptr->m_list[who]; + if (m_ptr->is_pet()) { notice = true; } else if (is_seen(player_ptr, m_ptr)) { notice = true; @@ -180,16 +193,16 @@ bool summon_specific(player_type *player_ptr, MONSTER_IDX who, POSITION y1, POSI * @param mode 生成オプション * @return 召喚できたらtrueを返す */ -bool summon_named_creature(player_type *player_ptr, MONSTER_IDX who, POSITION oy, POSITION ox, MONRACE_IDX r_idx, BIT_FLAGS mode) +bool summon_named_creature(PlayerType *player_ptr, MONSTER_IDX who, POSITION oy, POSITION ox, MonsterRaceId r_idx, BIT_FLAGS mode) { - if ((r_idx <= 0) || (r_idx >= static_cast(r_info.size()))) { + if (!MonsterRace(r_idx).is_valid() || (r_idx >= static_cast(monraces_info.size()))) { return false; } - + POSITION x, y; if (player_ptr->current_floor_ptr->inside_arena || !mon_scatter(player_ptr, r_idx, &y, &x, oy, ox, 2)) { return false; } - - return place_monster_aux(player_ptr, who, y, x, r_idx, (mode | PM_NO_KAGE)); + + return place_specific_monster(player_ptr, who, y, x, r_idx, (mode | PM_NO_KAGE)); }