OSDN Git Service

[Refactor] #40014 Moved get_monster_hook(), get_monster_hook2() and get_mon_num_prep...
authorHourier <hourier@users.sourceforge.jp>
Tue, 9 Jun 2020 09:49:36 +0000 (18:49 +0900)
committerHourier <hourier@users.sourceforge.jp>
Tue, 9 Jun 2020 09:49:36 +0000 (18:49 +0900)
28 files changed:
src/birth/inventory-initializer.c
src/cmd-item/cmd-activate.c
src/core/game-play.c
src/core/player-processor.c
src/dungeon/dungeon-processor.c
src/dungeon/quest.c
src/floor/fixed-map-generator.c
src/floor/floor-generate.c
src/floor/wild.c
src/grid/trap.c
src/market/arena.c
src/market/bounty.c
src/monster-race/monster-race-hook.c
src/monster/monster-processor.c
src/monster/monster-status.c
src/monster/monster-util.c
src/monster/monster-util.h
src/monster/monster1.c
src/monster/monster1.h
src/monster/monster2.c
src/monster/monster2.h
src/mspell/mspell-floor.c
src/mspell/mspell-special.c
src/object-enchant/apply-magic-others.c
src/player/eldritch-horror.c
src/room/rooms-pit-nest.c
src/room/rooms-special.c
src/spell/spells3.c

index 4a49883..3ac7b57 100644 (file)
@@ -4,6 +4,7 @@
 #include "floor/floor-object.h"
 #include "inventory/inventory-object.h"
 #include "monster-race/monster-race-hook.h"
+#include "monster/monster-util.h"
 #include "monster/monster2.h"
 #include "object-enchant/apply-magic.h"
 #include "object-enchant/item-apply-magic.h"
index 2a8f2a7..721e98d 100644 (file)
@@ -20,6 +20,7 @@
 #include "io/targeting.h"
 #include "main/sound-definitions-table.h"
 #include "monster/monster-status.h"
+#include "monster/monster-util.h"
 #include "monster/monster1.h"
 #include "monster/monster2.h"
 #include "object-enchant/activation-info-table.h"
index 0b9e6ed..bd87086 100644 (file)
@@ -40,6 +40,7 @@
 #include "market/bounty.h"
 #include "monster-race/race-indice-types.h"
 #include "core/speed-table.h"
+#include "monster/monster-util.h"
 #include "monster/monster2.h"
 #include "monster/place-monster-types.h"
 #include "object/object-flavor.h"
index 71b0ada..61559d7 100644 (file)
@@ -10,6 +10,7 @@
 #include "monster-race/monster-race-hook.h"
 #include "monster/monster-flag-types.h"
 #include "monster/monster-status.h"
+#include "monster/monster-util.h"
 #include "monster/monster2.h"
 #include "monster/place-monster-types.h"
 #include "mutation/mutation.h"
index b15b87a..991b936 100644 (file)
@@ -11,6 +11,7 @@
 #include "market/arena.h"
 #include "monster/monster-processor.h"
 #include "monster/monster-status.h"
+#include "monster/monster-util.h"
 #include "monster/monster2.h"
 #include "player/player-effects.h"
 #include "player/player-move.h"
index 4ea70f8..384c494 100644 (file)
@@ -12,6 +12,7 @@
 #include "locale/english.h"
 #include "main/music-definitions-table.h"
 #include "monster-race/monster-race-hook.h"
+#include "monster/monster-util.h"
 #include "monster/monster2.h"
 #include "monster/smart-learn-types.h"
 #include "object-enchant/artifact.h"
index d725054..a7736f1 100644 (file)
@@ -8,6 +8,7 @@
 #include "info-reader/general-parser.h"
 #include "info-reader/random-grid-effect-types.h"
 #include "io/tokenizer.h"
+#include "monster/monster-util.h"
 #include "monster/place-monster-types.h"
 #include "monster/smart-learn-types.h"
 #include "monster/monster2.h"
index 7e9c471..88551ee 100644 (file)
@@ -30,6 +30,7 @@
 #include "market/arena-info-table.h"
 #include "monster/monster-flag-types.h"
 #include "monster/monster-status.h"
+#include "monster/monster-util.h"
 #include "monster/monster1.h"
 #include "monster/monster2.h"
 #include "monster/place-monster-types.h"
index f7fa3db..7db5851 100644 (file)
@@ -22,6 +22,7 @@
 #include "io/tokenizer.h"
 #include "main/init.h"
 #include "monster/monster-status.h"
+#include "monster/monster-util.h"
 #include "monster/monster1.h"
 #include "monster/monster2.h"
 #include "monster/place-monster-types.h"
index b152da0..55ad6fc 100644 (file)
@@ -13,6 +13,7 @@
 #include "io/write-diary.h"
 #include "main/sound-definitions-table.h"
 #include "mind/mind-mirror-master.h"
+#include "monster/monster-util.h"
 #include "monster/monster2.h"
 #include "monster/place-monster-types.h"
 #include "player/eldritch-horror.h"
 #include "player/player-move.h"
 #include "player/player-personalities-table.h"
 #include "player/player-status.h"
-#include "spell/process-effect.h"
-#include "spell-kind/spells-random.h"
 #include "spell-kind/spells-launcher.h"
+#include "spell-kind/spells-random.h"
 #include "spell-kind/spells-sight.h"
-#include "spell/spells-summon.h"
 #include "spell-kind/spells-teleport.h"
+#include "spell/process-effect.h"
+#include "spell/spells-summon.h"
 #include "spell/spells-type.h"
 #include "util/util.h"
 #include "world/world.h"
 
 static s16b normal_traps[MAX_NORMAL_TRAPS];
 
-
 /*!
  * @brief 箱のトラップテーブル
  * @details
index 2e16855..6b7e6ad 100644 (file)
@@ -7,6 +7,7 @@
 #include "market/building-actions-table.h"
 #include "market/building-util.h"
 #include "monster-race/monster-race-hook.h"
+#include "monster/monster-util.h"
 #include "monster/monster2.h"
 #include "player/player-effects.h"
 #include "world/world.h"
index 774b8b1..24fd6d0 100644 (file)
@@ -8,6 +8,7 @@
 #include "market/building-util.h"
 #include "monster-race/race-indice-types.h"
 #include "monster-race/monster-race-hook.h"
+#include "monster/monster-util.h"
 #include "monster/monster2.h"
 #include "object-enchant/apply-magic.h"
 #include "object-enchant/item-apply-magic.h"
index a076b74..5a05859 100644 (file)
@@ -5,6 +5,7 @@
 #include "monster-attack/monster-attack-types.h"
 #include "monster-race/monster-race.h"
 #include "monster-race/race-indice-types.h"
+#include "monster/monster-util.h"
 #include "monster/monster2.h"
 #include "mspell/monster-spell.h"
 #include "util/util.h"
index 2d0fc4a..90e0cb5 100644 (file)
@@ -29,6 +29,7 @@
 #include "monster/monster-status.h"
 #include "monster/monster-update.h"
 #include "monster/monster-processor-util.h"
+#include "monster/monster-util.h"
 #include "monster/monster1.h"
 #include "monster/monster2.h"
 #include "monster/place-monster-types.h"
index 9987066..acba6cb 100644 (file)
@@ -19,6 +19,7 @@
 #include "monster/monster-description-types.h"
 #include "monster/monster-flag-types.h"
 #include "monster/monster-processor.h"
+#include "monster/monster-util.h"
 #include "monster/monster1.h"
 #include "monster/monster2.h"
 #include "monster/place-monster-types.h"
index ef33821..ac4731b 100644 (file)
@@ -1,4 +1,354 @@
 #include "monster/monster-util.h"
+#include "dungeon/dungeon.h"
+#include "dungeon/quest.h"
+#include "floor/floor.h"
+#include "grid/grid.h"
+#include "floor/wild.h"
+#include "monster-race/monster-race-hook.h"
+#include "monster-race/race-indice-types.h"
+#include "mspell/monster-spell.h"
+#include "spell/spells-summon.h"
 
 MONSTER_IDX hack_m_idx = 0; /* Hack -- see "process_monsters()" */
 MONSTER_IDX hack_m_idx_ii = 0;
+
+/*!
+ * @var chameleon_change_m_idx
+ * @brief カメレオンの変身先モンスターIDを受け渡すためのグローバル変数
+ * @todo 変数渡しの問題などもあるができればchameleon_change_m_idxのグローバル変数を除去し、関数引き渡しに移行すること
+ */
+int chameleon_change_m_idx = 0;
+
+/*!
+ * @var summon_specific_type
+ * @brief 召喚条件を指定するグローバル変数 / Hack -- the "type" of the current "summon specific"
+ * @todo summon_specific_typeグローバル変数の除去と関数引数への代替を行う
+ */
+int summon_specific_type = 0;
+
+static monsterrace_hook_type get_mon_num_hook;
+static monsterrace_hook_type get_mon_num2_hook;
+
+/*!
+ * todo ここには本来floor_type*を追加したいが、monster.hにfloor.hの参照を追加するとコンパイルエラーが出るので保留
+ * @brief 指定されたモンスター種族がダンジョンの制限にかかるかどうかをチェックする / Some dungeon types restrict the possible monsters.
+ * @param player_ptr プレーヤーへの参照ポインタ
+ * @param r_idx チェックするモンスター種族ID
+ * @return 召喚条件が一致するならtrue / Return TRUE is the monster is OK and FALSE otherwise
+ */
+static bool restrict_monster_to_dungeon(player_type *player_ptr, MONRACE_IDX r_idx)
+{
+    DUNGEON_IDX d_idx = player_ptr->dungeon_idx;
+    dungeon_type *d_ptr = &d_info[d_idx];
+    monster_race *r_ptr = &r_info[r_idx];
+
+    if (d_ptr->flags1 & DF1_CHAMELEON) {
+        if (chameleon_change_m_idx)
+            return TRUE;
+    }
+
+    if (d_ptr->flags1 & DF1_NO_MAGIC) {
+        if (r_idx != MON_CHAMELEON && r_ptr->freq_spell && !(r_ptr->flags4 & RF4_NOMAGIC_MASK) && !(r_ptr->a_ability_flags1 & RF5_NOMAGIC_MASK)
+            && !(r_ptr->a_ability_flags2 & RF6_NOMAGIC_MASK))
+            return FALSE;
+    }
+
+    if (d_ptr->flags1 & DF1_NO_MELEE) {
+        if (r_idx == MON_CHAMELEON)
+            return TRUE;
+        if (!(r_ptr->flags4 & (RF4_BOLT_MASK | RF4_BEAM_MASK | RF4_BALL_MASK))
+            && !(r_ptr->a_ability_flags1
+                & (RF5_BOLT_MASK | RF5_BEAM_MASK | RF5_BALL_MASK | RF5_CAUSE_1 | RF5_CAUSE_2 | RF5_CAUSE_3 | RF5_CAUSE_4 | RF5_MIND_BLAST | RF5_BRAIN_SMASH))
+            && !(r_ptr->a_ability_flags2 & (RF6_BOLT_MASK | RF6_BEAM_MASK | RF6_BALL_MASK)))
+            return FALSE;
+    }
+
+    floor_type *floor_ptr = player_ptr->current_floor_ptr;
+    if (d_ptr->flags1 & DF1_BEGINNER) {
+        if (r_ptr->level > floor_ptr->dun_level)
+            return FALSE;
+    }
+
+    if (d_ptr->special_div >= 64)
+        return TRUE;
+    if (summon_specific_type && !(d_ptr->flags1 & DF1_CHAMELEON))
+        return TRUE;
+
+    byte a;
+    switch (d_ptr->mode) {
+    case DUNGEON_MODE_AND: {
+        if (d_ptr->mflags1) {
+            if ((d_ptr->mflags1 & r_ptr->flags1) != d_ptr->mflags1)
+                return FALSE;
+        }
+
+        if (d_ptr->mflags2) {
+            if ((d_ptr->mflags2 & r_ptr->flags2) != d_ptr->mflags2)
+                return FALSE;
+        }
+
+        if (d_ptr->mflags3) {
+            if ((d_ptr->mflags3 & r_ptr->flags3) != d_ptr->mflags3)
+                return FALSE;
+        }
+
+        if (d_ptr->mflags4) {
+            if ((d_ptr->mflags4 & r_ptr->flags4) != d_ptr->mflags4)
+                return FALSE;
+        }
+
+        if (d_ptr->m_a_ability_flags1) {
+            if ((d_ptr->m_a_ability_flags1 & r_ptr->a_ability_flags1) != d_ptr->m_a_ability_flags1)
+                return FALSE;
+        }
+
+        if (d_ptr->m_a_ability_flags2) {
+            if ((d_ptr->m_a_ability_flags2 & r_ptr->a_ability_flags2) != d_ptr->m_a_ability_flags2)
+                return FALSE;
+        }
+
+        if (d_ptr->mflags7) {
+            if ((d_ptr->mflags7 & r_ptr->flags7) != d_ptr->mflags7)
+                return FALSE;
+        }
+
+        if (d_ptr->mflags8) {
+            if ((d_ptr->mflags8 & r_ptr->flags8) != d_ptr->mflags8)
+                return FALSE;
+        }
+
+        if (d_ptr->mflags9) {
+            if ((d_ptr->mflags9 & r_ptr->flags9) != d_ptr->mflags9)
+                return FALSE;
+        }
+
+        if (d_ptr->mflagsr) {
+            if ((d_ptr->mflagsr & r_ptr->flagsr) != d_ptr->mflagsr)
+                return FALSE;
+        }
+
+        for (a = 0; a < 5; a++)
+            if (d_ptr->r_char[a] && (d_ptr->r_char[a] != r_ptr->d_char))
+                return FALSE;
+
+        return TRUE;
+    }
+    case DUNGEON_MODE_NAND: {
+        if (d_ptr->mflags1) {
+            if ((d_ptr->mflags1 & r_ptr->flags1) != d_ptr->mflags1)
+                return TRUE;
+        }
+
+        if (d_ptr->mflags2) {
+            if ((d_ptr->mflags2 & r_ptr->flags2) != d_ptr->mflags2)
+                return TRUE;
+        }
+
+        if (d_ptr->mflags3) {
+            if ((d_ptr->mflags3 & r_ptr->flags3) != d_ptr->mflags3)
+                return TRUE;
+        }
+
+        if (d_ptr->mflags4) {
+            if ((d_ptr->mflags4 & r_ptr->flags4) != d_ptr->mflags4)
+                return TRUE;
+        }
+
+        if (d_ptr->m_a_ability_flags1) {
+            if ((d_ptr->m_a_ability_flags1 & r_ptr->a_ability_flags1) != d_ptr->m_a_ability_flags1)
+                return TRUE;
+        }
+
+        if (d_ptr->m_a_ability_flags2) {
+            if ((d_ptr->m_a_ability_flags2 & r_ptr->a_ability_flags2) != d_ptr->m_a_ability_flags2)
+                return TRUE;
+        }
+
+        if (d_ptr->mflags7) {
+            if ((d_ptr->mflags7 & r_ptr->flags7) != d_ptr->mflags7)
+                return TRUE;
+        }
+
+        if (d_ptr->mflags8) {
+            if ((d_ptr->mflags8 & r_ptr->flags8) != d_ptr->mflags8)
+                return TRUE;
+        }
+
+        if (d_ptr->mflags9) {
+            if ((d_ptr->mflags9 & r_ptr->flags9) != d_ptr->mflags9)
+                return TRUE;
+        }
+
+        if (d_ptr->mflagsr) {
+            if ((d_ptr->mflagsr & r_ptr->flagsr) != d_ptr->mflagsr)
+                return TRUE;
+        }
+
+        for (a = 0; a < 5; a++)
+            if (d_ptr->r_char[a] && (d_ptr->r_char[a] != r_ptr->d_char))
+                return TRUE;
+
+        return FALSE;
+    }
+    case DUNGEON_MODE_OR: {
+        if (r_ptr->flags1 & d_ptr->mflags1)
+            return TRUE;
+        if (r_ptr->flags2 & d_ptr->mflags2)
+            return TRUE;
+        if (r_ptr->flags3 & d_ptr->mflags3)
+            return TRUE;
+        if (r_ptr->flags4 & d_ptr->mflags4)
+            return TRUE;
+        if (r_ptr->a_ability_flags1 & d_ptr->m_a_ability_flags1)
+            return TRUE;
+        if (r_ptr->a_ability_flags2 & d_ptr->m_a_ability_flags2)
+            return TRUE;
+        if (r_ptr->flags7 & d_ptr->mflags7)
+            return TRUE;
+        if (r_ptr->flags8 & d_ptr->mflags8)
+            return TRUE;
+        if (r_ptr->flags9 & d_ptr->mflags9)
+            return TRUE;
+        if (r_ptr->flagsr & d_ptr->mflagsr)
+            return TRUE;
+        for (a = 0; a < 5; a++)
+            if (d_ptr->r_char[a] == r_ptr->d_char)
+                return TRUE;
+
+        return FALSE;
+    }
+    case DUNGEON_MODE_NOR: {
+        if (r_ptr->flags1 & d_ptr->mflags1)
+            return FALSE;
+        if (r_ptr->flags2 & d_ptr->mflags2)
+            return FALSE;
+        if (r_ptr->flags3 & d_ptr->mflags3)
+            return FALSE;
+        if (r_ptr->flags4 & d_ptr->mflags4)
+            return FALSE;
+        if (r_ptr->a_ability_flags1 & d_ptr->m_a_ability_flags1)
+            return FALSE;
+        if (r_ptr->a_ability_flags2 & d_ptr->m_a_ability_flags2)
+            return FALSE;
+        if (r_ptr->flags7 & d_ptr->mflags7)
+            return FALSE;
+        if (r_ptr->flags8 & d_ptr->mflags8)
+            return FALSE;
+        if (r_ptr->flags9 & d_ptr->mflags9)
+            return FALSE;
+        if (r_ptr->flagsr & d_ptr->mflagsr)
+            return FALSE;
+        for (a = 0; a < 5; a++)
+            if (d_ptr->r_char[a] == r_ptr->d_char)
+                return FALSE;
+
+        return TRUE;
+    }
+    }
+
+    return TRUE;
+}
+
+/*!
+ * @brief プレイヤーの現在の広域マップ座標から得た地勢を元にモンスターの生成条件関数を返す
+ * @param player_ptr プレーヤーへの参照ポインタ
+ * @return 地勢にあったモンスターの生成条件関数
+ */
+monsterrace_hook_type get_monster_hook(player_type *player_ptr)
+{
+    if ((player_ptr->current_floor_ptr->dun_level > 0) || (player_ptr->current_floor_ptr->inside_quest > 0))
+        return (monsterrace_hook_type)mon_hook_dungeon;
+
+    switch (wilderness[player_ptr->wilderness_y][player_ptr->wilderness_x].terrain) {
+    case TERRAIN_TOWN:
+        return (monsterrace_hook_type)mon_hook_town;
+    case TERRAIN_DEEP_WATER:
+        return (monsterrace_hook_type)mon_hook_ocean;
+    case TERRAIN_SHALLOW_WATER:
+    case TERRAIN_SWAMP:
+        return (monsterrace_hook_type)mon_hook_shore;
+    case TERRAIN_DIRT:
+    case TERRAIN_DESERT:
+        return (monsterrace_hook_type)mon_hook_waste;
+    case TERRAIN_GRASS:
+        return (monsterrace_hook_type)mon_hook_grass;
+    case TERRAIN_TREES:
+        return (monsterrace_hook_type)mon_hook_wood;
+    case TERRAIN_SHALLOW_LAVA:
+    case TERRAIN_DEEP_LAVA:
+        return (monsterrace_hook_type)mon_hook_volcano;
+    case TERRAIN_MOUNTAIN:
+        return (monsterrace_hook_type)mon_hook_mountain;
+    default:
+        return (monsterrace_hook_type)mon_hook_dungeon;
+    }
+}
+
+/*!
+ * @brief 指定された広域マップ座標の地勢を元にモンスターの生成条件関数を返す
+ * @return 地勢にあったモンスターの生成条件関数
+ */
+monsterrace_hook_type get_monster_hook2(player_type *player_ptr, POSITION y, POSITION x)
+{
+    feature_type *f_ptr = &f_info[player_ptr->current_floor_ptr->grid_array[y][x].feat];
+    if (have_flag(f_ptr->flags, FF_WATER)) {
+        if (have_flag(f_ptr->flags, FF_DEEP)) {
+            return (monsterrace_hook_type)mon_hook_deep_water;
+        } else {
+            return (monsterrace_hook_type)mon_hook_shallow_water;
+        }
+    }
+
+    if (have_flag(f_ptr->flags, FF_LAVA)) {
+        return (monsterrace_hook_type)mon_hook_lava;
+    }
+
+    return (monsterrace_hook_type)mon_hook_floor;
+}
+
+/*!
+ * @brief モンスター生成制限関数最大2つから / Apply a "monster restriction function" to the "monster allocation table"
+ * @param player_ptr プレーヤーへの参照ポインタ
+ * @param monster_hook 制限関数1
+ * @param monster_hook2 制限関数2
+ * @return エラーコード
+ */
+errr get_mon_num_prep(player_type *player_ptr, monsterrace_hook_type monster_hook, monsterrace_hook_type monster_hook2)
+{
+    /* Todo: Check the hooks for non-changes */
+    get_mon_num_hook = monster_hook;
+    get_mon_num2_hook = monster_hook2;
+
+    floor_type *floor_ptr = player_ptr->current_floor_ptr;
+    for (int i = 0; i < alloc_race_size; i++) {
+        monster_race *r_ptr;
+        alloc_entry *entry = &alloc_race_table[i];
+        entry->prob2 = 0;
+        r_ptr = &r_info[entry->index];
+
+        if ((get_mon_num_hook && !((*get_mon_num_hook)(entry->index))) || (get_mon_num2_hook && !((*get_mon_num2_hook)(entry->index))))
+            continue;
+
+        if (!player_ptr->phase_out && !chameleon_change_m_idx && summon_specific_type != SUMMON_GUARDIANS) {
+            if (r_ptr->flags1 & RF1_QUESTOR)
+                continue;
+
+            if (r_ptr->flags7 & RF7_GUARDIAN)
+                continue;
+
+            if ((r_ptr->flags1 & (RF1_FORCE_DEPTH)) && (r_ptr->level > floor_ptr->dun_level))
+                continue;
+        }
+
+        entry->prob2 = entry->prob1;
+        if (floor_ptr->dun_level && (!floor_ptr->inside_quest || is_fixed_quest_idx(floor_ptr->inside_quest))
+            && !restrict_monster_to_dungeon(player_ptr, entry->index) && !player_ptr->phase_out) {
+            int hoge = entry->prob2 * d_info[player_ptr->dungeon_idx].special_div;
+            entry->prob2 = hoge / 64;
+            if (randint0(64) < (hoge & 0x3f))
+                entry->prob2++;
+        }
+    }
+
+    return 0;
+}
index 85646d8..2dc6c55 100644 (file)
@@ -3,5 +3,12 @@
 #include "system/angband.h"
 
 typedef bool (*monsterrace_hook_type)(MONRACE_IDX r_idx);
+
 extern MONSTER_IDX hack_m_idx;
 extern MONSTER_IDX hack_m_idx_ii;
+extern int chameleon_change_m_idx;
+extern int summon_specific_type;
+
+monsterrace_hook_type get_monster_hook(player_type *player_ptr);
+monsterrace_hook_type get_monster_hook2(player_type *player_ptr, POSITION y, POSITION x);
+errr get_mon_num_prep(player_type *player_ptr, monsterrace_hook_type monster_hook, monsterrace_hook_type monster_hook2);
index bc44d2f..37d4601 100644 (file)
@@ -1901,71 +1901,6 @@ void output_monster_spoiler(player_type *player_ptr, MONRACE_IDX r_idx, void(*ro
 
 
 /*!
- * @brief プレイヤーの現在の広域マップ座標から得た地勢を元にモンスターの生成条件関数を返す
- * @param player_ptr プレーヤーへの参照ポインタ
- * @return 地勢にあったモンスターの生成条件関数
- */
-monsterrace_hook_type get_monster_hook(player_type *player_ptr)
-{
-       if ((player_ptr->current_floor_ptr->dun_level > 0) || (player_ptr->current_floor_ptr->inside_quest > 0))
-               return (monsterrace_hook_type)mon_hook_dungeon;
-
-       switch (wilderness[player_ptr->wilderness_y][player_ptr->wilderness_x].terrain)
-       {
-       case TERRAIN_TOWN:
-               return (monsterrace_hook_type)mon_hook_town;
-       case TERRAIN_DEEP_WATER:
-               return (monsterrace_hook_type)mon_hook_ocean;
-       case TERRAIN_SHALLOW_WATER:
-       case TERRAIN_SWAMP:
-               return (monsterrace_hook_type)mon_hook_shore;
-       case TERRAIN_DIRT:
-       case TERRAIN_DESERT:
-               return (monsterrace_hook_type)mon_hook_waste;
-       case TERRAIN_GRASS:
-               return (monsterrace_hook_type)mon_hook_grass;
-       case TERRAIN_TREES:
-               return (monsterrace_hook_type)mon_hook_wood;
-       case TERRAIN_SHALLOW_LAVA:
-       case TERRAIN_DEEP_LAVA:
-               return (monsterrace_hook_type)mon_hook_volcano;
-       case TERRAIN_MOUNTAIN:
-               return (monsterrace_hook_type)mon_hook_mountain;
-       default:
-               return (monsterrace_hook_type)mon_hook_dungeon;
-       }
-}
-
-
-/*!
- * @brief 指定された広域マップ座標の地勢を元にモンスターの生成条件関数を返す
- * @return 地勢にあったモンスターの生成条件関数
- */
-monsterrace_hook_type get_monster_hook2(player_type *player_ptr, POSITION y, POSITION x)
-{
-       feature_type *f_ptr = &f_info[player_ptr->current_floor_ptr->grid_array[y][x].feat];
-       if (have_flag(f_ptr->flags, FF_WATER))
-       {
-               if (have_flag(f_ptr->flags, FF_DEEP))
-               {
-                       return (monsterrace_hook_type)mon_hook_deep_water;
-               }
-               else
-               {
-                       return (monsterrace_hook_type)mon_hook_shallow_water;
-               }
-       }
-
-       if (have_flag(f_ptr->flags, FF_LAVA))
-       {
-               return (monsterrace_hook_type)mon_hook_lava;
-       }
-
-       return (monsterrace_hook_type)mon_hook_floor;
-}
-
-
-/*!
  * @brief モンスターを友好的にする
  * @param m_ptr モンスター情報構造体の参照ポインタ
  * @return なし
index 84aa65c..5b6aa29 100644 (file)
@@ -1,6 +1,5 @@
 #pragma once
 
-#include "monster/monster-util.h"
 #include "system/angband.h"
 #include "system/monster-type-definition.h"
 
@@ -10,8 +9,6 @@ void display_roff(player_type *player_ptr);
 void output_monster_spoiler(player_type *player_ptr, MONRACE_IDX r_idx, void (*roff_func)(TERM_COLOR attr, concptr str));
 concptr extract_note_dies(MONRACE_IDX r_idx);
 void monster_death(player_type *player_ptr, MONSTER_IDX m_idx, bool drop_item);
-monsterrace_hook_type get_monster_hook(player_type *player_ptr);
-monsterrace_hook_type get_monster_hook2(player_type *player_ptr, POSITION y, POSITION x);
 void set_friendly(monster_type *m_ptr);
 void set_pet(player_type *player_ptr, monster_type *m_ptr);
 void set_hostile(player_type *player_ptr, monster_type *m_ptr);
index a8d00ff..2ed595e 100644 (file)
@@ -32,6 +32,7 @@
 #include "monster/monster-description-types.h"
 #include "monster/monster-flag-types.h"
 #include "monster/monster-status.h"
+#include "monster/monster-util.h"
 #include "monster/monster1.h"
 #include "monster/place-monster-types.h"
 #include "monster/smart-learn-types.h"
@@ -388,14 +389,6 @@ MONSTER_IDX m_pop(player_type *player_ptr)
 
 
 /*!
- * @var summon_specific_type
- * @brief 召喚条件を指定するグローバル変数 / Hack -- the "type" of the current "summon specific"
- * @todo summon_specific_typeグローバル変数の除去と関数引数への代替を行う
- */
-static int summon_specific_type = 0;
-
-
-/*!
  * @var summon_specific_who
  * @brief 召喚を行ったプレイヤーあるいはモンスターのIDを示すグローバル変数 / Hack -- the index of the summoning monster
  * @todo summon_specific_who グローバル変数の除去と関数引数への代替を行う
@@ -682,295 +675,6 @@ static bool summon_specific_aux(player_type *player_ptr, MONRACE_IDX summoner_id
 
 
 /*!
- * @var chameleon_change_m_idx
- * @brief カメレオンの変身先モンスターIDを受け渡すためのグローバル変数
- * @todo 変数渡しの問題などもあるができればchameleon_change_m_idxのグローバル変数を除去し、関数引き渡しに移行すること
- */
-static int chameleon_change_m_idx = 0;
-
-/*!
- * todo ここには本来floor_type*を追加したいが、monster.hにfloor.hの参照を追加するとコンパイルエラーが出るので保留
- * @brief 指定されたモンスター種族がダンジョンの制限にかかるかどうかをチェックする / Some dungeon types restrict the possible monsters.
- * @param player_ptr プレーヤーへの参照ポインタ
- * @param r_idx チェックするモンスター種族ID
- * @return 召喚条件が一致するならtrue / Return TRUE is the monster is OK and FALSE otherwise
- */
-static bool restrict_monster_to_dungeon(player_type *player_ptr, MONRACE_IDX r_idx)
-{
-       DUNGEON_IDX d_idx = player_ptr->dungeon_idx;
-       dungeon_type *d_ptr = &d_info[d_idx];
-       monster_race *r_ptr = &r_info[r_idx];
-
-       if (d_ptr->flags1 & DF1_CHAMELEON)
-       {
-               if (chameleon_change_m_idx) return TRUE;
-       }
-
-       if (d_ptr->flags1 & DF1_NO_MAGIC)
-       {
-               if (r_idx != MON_CHAMELEON &&
-                       r_ptr->freq_spell &&
-                       !(r_ptr->flags4 & RF4_NOMAGIC_MASK) &&
-                       !(r_ptr->a_ability_flags1 & RF5_NOMAGIC_MASK) &&
-                       !(r_ptr->a_ability_flags2 & RF6_NOMAGIC_MASK))
-                       return FALSE;
-       }
-
-       if (d_ptr->flags1 & DF1_NO_MELEE)
-       {
-               if (r_idx == MON_CHAMELEON) return TRUE;
-               if (!(r_ptr->flags4 & (RF4_BOLT_MASK | RF4_BEAM_MASK | RF4_BALL_MASK)) &&
-                       !(r_ptr->a_ability_flags1 & (RF5_BOLT_MASK | RF5_BEAM_MASK | RF5_BALL_MASK | RF5_CAUSE_1 | RF5_CAUSE_2 | RF5_CAUSE_3 | RF5_CAUSE_4 | RF5_MIND_BLAST | RF5_BRAIN_SMASH)) &&
-                       !(r_ptr->a_ability_flags2 & (RF6_BOLT_MASK | RF6_BEAM_MASK | RF6_BALL_MASK)))
-                       return FALSE;
-       }
-
-       floor_type *floor_ptr = player_ptr->current_floor_ptr;
-       if (d_ptr->flags1 & DF1_BEGINNER)
-       {
-               if (r_ptr->level > floor_ptr->dun_level)
-                       return FALSE;
-       }
-
-       if (d_ptr->special_div >= 64) return TRUE;
-       if (summon_specific_type && !(d_ptr->flags1 & DF1_CHAMELEON)) return TRUE;
-
-       byte a;
-       switch (d_ptr->mode)
-       {
-       case DUNGEON_MODE_AND:
-       {
-               if (d_ptr->mflags1)
-               {
-                       if ((d_ptr->mflags1 & r_ptr->flags1) != d_ptr->mflags1)
-                               return FALSE;
-               }
-
-               if (d_ptr->mflags2)
-               {
-                       if ((d_ptr->mflags2 & r_ptr->flags2) != d_ptr->mflags2)
-                               return FALSE;
-               }
-
-               if (d_ptr->mflags3)
-               {
-                       if ((d_ptr->mflags3 & r_ptr->flags3) != d_ptr->mflags3)
-                               return FALSE;
-               }
-
-               if (d_ptr->mflags4)
-               {
-                       if ((d_ptr->mflags4 & r_ptr->flags4) != d_ptr->mflags4)
-                               return FALSE;
-               }
-
-               if (d_ptr->m_a_ability_flags1)
-               {
-                       if ((d_ptr->m_a_ability_flags1 & r_ptr->a_ability_flags1) != d_ptr->m_a_ability_flags1)
-                               return FALSE;
-               }
-
-               if (d_ptr->m_a_ability_flags2)
-               {
-                       if ((d_ptr->m_a_ability_flags2 & r_ptr->a_ability_flags2) != d_ptr->m_a_ability_flags2)
-                               return FALSE;
-               }
-
-               if (d_ptr->mflags7)
-               {
-                       if ((d_ptr->mflags7 & r_ptr->flags7) != d_ptr->mflags7)
-                               return FALSE;
-               }
-
-               if (d_ptr->mflags8)
-               {
-                       if ((d_ptr->mflags8 & r_ptr->flags8) != d_ptr->mflags8)
-                               return FALSE;
-               }
-
-               if (d_ptr->mflags9)
-               {
-                       if ((d_ptr->mflags9 & r_ptr->flags9) != d_ptr->mflags9)
-                               return FALSE;
-               }
-
-               if (d_ptr->mflagsr)
-               {
-                       if ((d_ptr->mflagsr & r_ptr->flagsr) != d_ptr->mflagsr)
-                               return FALSE;
-               }
-
-               for (a = 0; a < 5; a++)
-                       if (d_ptr->r_char[a] && (d_ptr->r_char[a] != r_ptr->d_char)) return FALSE;
-
-               return TRUE;
-       }
-       case DUNGEON_MODE_NAND:
-       {
-               if (d_ptr->mflags1)
-               {
-                       if ((d_ptr->mflags1 & r_ptr->flags1) != d_ptr->mflags1)
-                               return TRUE;
-               }
-
-               if (d_ptr->mflags2)
-               {
-                       if ((d_ptr->mflags2 & r_ptr->flags2) != d_ptr->mflags2)
-                               return TRUE;
-               }
-
-               if (d_ptr->mflags3)
-               {
-                       if ((d_ptr->mflags3 & r_ptr->flags3) != d_ptr->mflags3)
-                               return TRUE;
-               }
-
-               if (d_ptr->mflags4)
-               {
-                       if ((d_ptr->mflags4 & r_ptr->flags4) != d_ptr->mflags4)
-                               return TRUE;
-               }
-
-               if (d_ptr->m_a_ability_flags1)
-               {
-                       if ((d_ptr->m_a_ability_flags1 & r_ptr->a_ability_flags1) != d_ptr->m_a_ability_flags1)
-                               return TRUE;
-               }
-
-               if (d_ptr->m_a_ability_flags2)
-               {
-                       if ((d_ptr->m_a_ability_flags2 & r_ptr->a_ability_flags2) != d_ptr->m_a_ability_flags2)
-                               return TRUE;
-               }
-
-               if (d_ptr->mflags7)
-               {
-                       if ((d_ptr->mflags7 & r_ptr->flags7) != d_ptr->mflags7)
-                               return TRUE;
-               }
-
-               if (d_ptr->mflags8)
-               {
-                       if ((d_ptr->mflags8 & r_ptr->flags8) != d_ptr->mflags8)
-                               return TRUE;
-               }
-
-               if (d_ptr->mflags9)
-               {
-                       if ((d_ptr->mflags9 & r_ptr->flags9) != d_ptr->mflags9)
-                               return TRUE;
-               }
-
-               if (d_ptr->mflagsr)
-               {
-                       if ((d_ptr->mflagsr & r_ptr->flagsr) != d_ptr->mflagsr)
-                               return TRUE;
-               }
-
-               for (a = 0; a < 5; a++)
-                       if (d_ptr->r_char[a] && (d_ptr->r_char[a] != r_ptr->d_char)) return TRUE;
-
-               return FALSE;
-       }
-       case DUNGEON_MODE_OR:
-       {
-               if (r_ptr->flags1 & d_ptr->mflags1) return TRUE;
-               if (r_ptr->flags2 & d_ptr->mflags2) return TRUE;
-               if (r_ptr->flags3 & d_ptr->mflags3) return TRUE;
-               if (r_ptr->flags4 & d_ptr->mflags4) return TRUE;
-               if (r_ptr->a_ability_flags1 & d_ptr->m_a_ability_flags1) return TRUE;
-               if (r_ptr->a_ability_flags2 & d_ptr->m_a_ability_flags2) return TRUE;
-               if (r_ptr->flags7 & d_ptr->mflags7) return TRUE;
-               if (r_ptr->flags8 & d_ptr->mflags8) return TRUE;
-               if (r_ptr->flags9 & d_ptr->mflags9) return TRUE;
-               if (r_ptr->flagsr & d_ptr->mflagsr) return TRUE;
-               for (a = 0; a < 5; a++)
-                       if (d_ptr->r_char[a] == r_ptr->d_char) return TRUE;
-
-               return FALSE;
-       }
-       case DUNGEON_MODE_NOR:
-       {
-               if (r_ptr->flags1 & d_ptr->mflags1) return FALSE;
-               if (r_ptr->flags2 & d_ptr->mflags2) return FALSE;
-               if (r_ptr->flags3 & d_ptr->mflags3) return FALSE;
-               if (r_ptr->flags4 & d_ptr->mflags4) return FALSE;
-               if (r_ptr->a_ability_flags1 & d_ptr->m_a_ability_flags1) return FALSE;
-               if (r_ptr->a_ability_flags2 & d_ptr->m_a_ability_flags2) return FALSE;
-               if (r_ptr->flags7 & d_ptr->mflags7) return FALSE;
-               if (r_ptr->flags8 & d_ptr->mflags8) return FALSE;
-               if (r_ptr->flags9 & d_ptr->mflags9) return FALSE;
-               if (r_ptr->flagsr & d_ptr->mflagsr) return FALSE;
-               for (a = 0; a < 5; a++)
-                       if (d_ptr->r_char[a] == r_ptr->d_char) return FALSE;
-
-               return TRUE;
-       }
-       }
-
-       return TRUE;
-}
-
-/*
- * Hack -- function hooks to restrict "get_mon_num_prep()" function
- */
-monsterrace_hook_type get_mon_num_hook;
-monsterrace_hook_type get_mon_num2_hook;
-
-/*!
- * @brief モンスター生成制限関数最大2つから / Apply a "monster restriction function" to the "monster allocation table"
- * @param player_ptr プレーヤーへの参照ポインタ
- * @param monster_hook 制限関数1
- * @param monster_hook2 制限関数2
- * @return エラーコード
- */
-errr get_mon_num_prep(player_type *player_ptr, monsterrace_hook_type monster_hook, monsterrace_hook_type monster_hook2)
-{
-       /* Todo: Check the hooks for non-changes */
-       get_mon_num_hook = monster_hook;
-       get_mon_num2_hook = monster_hook2;
-
-       floor_type *floor_ptr = player_ptr->current_floor_ptr;
-       for (int i = 0; i < alloc_race_size; i++)
-       {
-               monster_race *r_ptr;
-               alloc_entry *entry = &alloc_race_table[i];
-               entry->prob2 = 0;
-               r_ptr = &r_info[entry->index];
-
-               if ((get_mon_num_hook && !((*get_mon_num_hook)(entry->index))) ||
-                       (get_mon_num2_hook && !((*get_mon_num2_hook)(entry->index))))
-                       continue;
-
-               if (!player_ptr->phase_out && !chameleon_change_m_idx &&
-                       summon_specific_type != SUMMON_GUARDIANS)
-               {
-                       if (r_ptr->flags1 & RF1_QUESTOR)
-                               continue;
-
-                       if (r_ptr->flags7 & RF7_GUARDIAN)
-                               continue;
-
-                       if ((r_ptr->flags1 & (RF1_FORCE_DEPTH)) &&
-                               (r_ptr->level > floor_ptr->dun_level))
-                               continue;
-               }
-
-               entry->prob2 = entry->prob1;
-               if (floor_ptr->dun_level && (!floor_ptr->inside_quest || is_fixed_quest_idx(floor_ptr->inside_quest)) &&
-                       !restrict_monster_to_dungeon(player_ptr, entry->index) && !player_ptr->phase_out)
-               {
-                       int hoge = entry->prob2 * d_info[player_ptr->dungeon_idx].special_div;
-                       entry->prob2 = hoge / 64;
-                       if (randint0(64) < (hoge & 0x3f)) entry->prob2++;
-               }
-       }
-
-       return 0;
-}
-
-
-/*!
  * @brief 生成モンスター種族を1種生成テーブルから選択する
  * @param player_ptr プレーヤーへの参照ポインタ
  * @param level 生成階
index aea8e77..97c3b3d 100644 (file)
@@ -1,6 +1,5 @@
 #pragma once
 
-#include "monster/monster-util.h"
 #include "system/angband.h"
 #include "system/monster-type-definition.h"
 
@@ -12,7 +11,6 @@ void delete_monster_idx(player_type *player_ptr, MONSTER_IDX i);
 void compact_monsters(player_type *player_ptr, int size);
 void wipe_monsters_list(player_type *player_ptr);
 MONSTER_IDX m_pop(player_type *player_ptr);
-errr get_mon_num_prep(player_type *player_ptr, monsterrace_hook_type monster_hook, monsterrace_hook_type monster_hook2);
 
 #define GMN_ARENA 0x00000001 //!< 賭け闘技場向け生成
 MONRACE_IDX get_mon_num(player_type *player_ptr, DEPTH level, BIT_FLAGS option);
index 62270ff..64ee77b 100644 (file)
@@ -11,6 +11,7 @@
 #include "monster-race/race-indice-types.h"
 #include "monster/monster-status.h"
 #include "monster/smart-learn-types.h"
+#include "monster/monster1.h"
 #include "monster/monster2.h"
 #include "mspell/monster-spell.h"
 #include "mspell/mspell-status.h"
index 147e30f..db3b394 100644 (file)
@@ -10,6 +10,7 @@
 #include "main/sound-definitions-table.h"
 #include "monster-race/race-indice-types.h"
 #include "monster/monster-description-types.h"
+#include "monster/monster-util.h"
 #include "monster/monster1.h"
 #include "monster/monster2.h"
 #include "mspell/monster-spell.h"
index 0848ed8..a39e75e 100644 (file)
@@ -9,6 +9,7 @@
 #include "floor/floor.h"
 #include "monster-race/race-indice-types.h"
 #include "monster-race/monster-race-hook.h"
+#include "monster/monster-util.h"
 #include "monster/monster2.h"
 #include "object-enchant/artifact.h"
 #include "object-enchant/object-ego.h"
index 404187f..743ece9 100644 (file)
@@ -10,6 +10,7 @@
 #include "monster-race/monster-race-hook.h"
 #include "monster/horror-descriptions.h"
 #include "monster/smart-learn-types.h"
+#include "monster/monster-util.h"
 #include "monster/monster2.h"
 #include "player/player-effects.h"
 #include "player/player-status.h"
index 05ba42d..8abcb8e 100644 (file)
@@ -6,6 +6,7 @@
 #include "grid/feature.h"
 #include "grid/grid.h"
 #include "monster-race/monster-race-hook.h"
+#include "monster/monster-util.h"
 #include "monster/monster1.h"
 #include "monster/monster2.h"
 #include "monster/place-monster-types.h"
index 4c4dac4..ba52eac 100644 (file)
@@ -5,6 +5,7 @@
 #include "grid/feature.h"
 #include "grid/grid.h"
 #include "monster-race/monster-race-hook.h"
+#include "monster/monster-util.h"
 #include "monster/monster2.h"
 #include "monster/place-monster-types.h"
 #include "object-enchant/item-apply-magic.h"
index 4f060b1..3afbaa9 100644 (file)
@@ -39,6 +39,7 @@
 #include "monster/monster-flag-types.h"
 #include "monster/monster-processor.h"
 #include "monster/monster-status.h"
+#include "monster/monster-util.h"
 #include "monster/monster2.h"
 #include "monster/place-monster-types.h"
 #include "monster/smart-learn-types.h"