#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"
#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"
#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"
#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"
#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"
#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"
#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"
#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"
#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"
#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
#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"
#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"
#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"
#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"
#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"
#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;
+}
#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);
/*!
- * @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 なし
#pragma once
-#include "monster/monster-util.h"
#include "system/angband.h"
#include "system/monster-type-definition.h"
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);
#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"
/*!
- * @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 グローバル変数の除去と関数引数への代替を行う
/*!
- * @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 生成階
#pragma once
-#include "monster/monster-util.h"
#include "system/angband.h"
#include "system/monster-type-definition.h"
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);
#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"
#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"
#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"
#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"
#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"
#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"
#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"