OSDN Git Service

[Refactor] 性別で出現モンスターを絞れるようにした
authorSlimebreath6078 <slimebreath6078@yahoo.co.jp>
Thu, 28 Dec 2023 13:18:59 +0000 (22:18 +0900)
committerSlimebreath6078 <slimebreath6078@yahoo.co.jp>
Sun, 7 Jan 2024 08:47:05 +0000 (17:47 +0900)
現状対応するダンジョンはないが、Refactorの体のために追加。不要であれば消す

src/info-reader/dungeon-reader.cpp
src/monster/monster-util.cpp
src/system/dungeon-info.h

index 00fc33a..5830924 100644 (file)
@@ -298,6 +298,17 @@ errr parse_dungeons_info(std::string_view buf, angband_header *)
         }
     } else if (tokens[0] == "M") {
         // M:monsterflags
+        if (tokens[1] == "X") {
+            if (tokens.size() < 3) {
+                return PARSE_ERROR_TOO_FEW_ARGUMENTS;
+            }
+            uint32_t sex;
+            if (!info_grab_one_const(sex, r_info_sex, tokens[2])) {
+                return PARSE_ERROR_INVALID_FLAG;
+            }
+            d_ptr->mon_sex = static_cast<MonsterSex>(sex);
+            return 0;
+        }
         if (tokens.size() < 2) {
             return PARSE_ERROR_TOO_FEW_ARGUMENTS;
         }
index edc7532..6a8c9f9 100644 (file)
@@ -138,6 +138,8 @@ static bool restrict_monster_to_dungeon(const FloorType *floor_ptr, MonsterRaceI
             is_possible_monster_and(r_ptr->population_flags, d_ptr->mon_population_flags),
             is_possible_monster_and(r_ptr->speak_flags, d_ptr->mon_speak_flags),
             is_possible_monster_and(r_ptr->brightness_flags, d_ptr->mon_brightness_flags),
+            is_male(d_ptr->mon_sex) ? is_male(r_ptr->sex) : true,
+            is_female(d_ptr->mon_sex) ? is_female(r_ptr->sex) : true,
         };
 
         auto result = std::all_of(is_possible.begin(), is_possible.end(), [](const auto &v) { return v; });
@@ -163,6 +165,8 @@ static bool restrict_monster_to_dungeon(const FloorType *floor_ptr, MonsterRaceI
             is_possible_monster_or(r_ptr->population_flags, d_ptr->mon_population_flags),
             is_possible_monster_or(r_ptr->speak_flags, d_ptr->mon_speak_flags),
             is_possible_monster_or(r_ptr->brightness_flags, d_ptr->mon_brightness_flags),
+            is_male(d_ptr->mon_sex) ? is_male(r_ptr->sex) : true,
+            is_female(d_ptr->mon_sex) ? is_female(r_ptr->sex) : true,
         };
 
         auto result = std::any_of(is_possible.begin(), is_possible.end(), [](const auto &v) { return v; });
index c7ad4d1..22c9ff6 100644 (file)
@@ -45,6 +45,7 @@ constexpr auto DUNGEON_FEAT_PROB_NUM = 3;
 
 enum class FixedArtifactId : short;
 enum class MonsterRaceId : int16_t;
+enum class MonsterSex;
 
 struct feat_prob {
     FEAT_IDX feat{}; /* Feature tile */
@@ -97,6 +98,7 @@ struct dungeon_type {
     EnumClassFlagGroup<MonsterPopulationType> mon_population_flags;
     EnumClassFlagGroup<MonsterSpeakType> mon_speak_flags;
     EnumClassFlagGroup<MonsterBrightnessType> mon_brightness_flags;
+    MonsterSex mon_sex{};
 
     std::vector<char> r_chars; /* Monster symbols allowed */
     short final_object{}; /* The object you'll find at the bottom */