OSDN Git Service

[Refactor] #37353 構造体 dungeon_info_type を他の慣例に従い dungeon_type に改名。 / Rename dungeon_i...
[hengband/hengband.git] / src / monster2.c
index 87c49ff..6f4e2dd 100644 (file)
 #include "cmd-pet.h"
 #include "monsterrace-hook.h"
 #include "monster-status.h"
+#include "projection.h"
+#include "monster.h"
+#include "spells-summon.h"
+#include "quest.h"
 
 #define HORDE_NOGOOD 0x01 /*!< (未実装フラグ)HORDE生成でGOODなモンスターの生成を禁止する? */
 #define HORDE_NOEVIL 0x02 /*!< (未実装フラグ)HORDE生成でEVILなモンスターの生成を禁止する? */
@@ -264,8 +268,6 @@ void delete_monster_idx(MONSTER_IDX i)
        /* Monster is gone */
        cave[y][x].m_idx = 0;
 
-
-       /* Delete objects */
        for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
        {
                object_type *o_ptr;
@@ -965,7 +967,7 @@ static int chameleon_change_m_idx = 0;
  */
 static bool restrict_monster_to_dungeon(MONRACE_IDX r_idx)
 {
-       dungeon_info_type *d_ptr = &d_info[dungeon_type];
+       dungeon_type *d_ptr = &d_info[p_ptr->dungeon_idx];
        monster_race *r_ptr = &r_info[r_idx];
        byte a;
 
@@ -1203,7 +1205,7 @@ errr get_mon_num_prep(monsterrace_hook_type monster_hook,
 
                if (dun_level && (!p_ptr->inside_quest || is_fixed_quest_idx(p_ptr->inside_quest)) && !restrict_monster_to_dungeon(entry->index) && !p_ptr->inside_battle)
                {
-                       int hoge = entry->prob2 * d_info[dungeon_type].special_div;
+                       int hoge = entry->prob2 * d_info[p_ptr->dungeon_idx].special_div;
                        entry->prob2 = hoge / 64;
                        if (randint0(64) < (hoge & 0x3f)) entry->prob2++;
                }
@@ -1254,7 +1256,7 @@ MONRACE_IDX get_mon_num(DEPTH level)
        pls_kakuritu = MAX(NASTY_MON_MAX, NASTY_MON_BASE - ((dungeon_turn / (TURNS_PER_TICK * 5000L) - delay / 10)));
        pls_level    = MIN(NASTY_MON_PLUS_MAX, 3 + dungeon_turn / (TURNS_PER_TICK * 40000L) - delay / 40 + MIN(5, level / 10)) ;
 
-       if (d_info[dungeon_type].flags1 & DF1_MAZE)
+       if (d_info[p_ptr->dungeon_idx].flags1 & DF1_MAZE)
        {
                pls_kakuritu = MIN(pls_kakuritu / 2, pls_kakuritu - 10);
                if (pls_kakuritu < 2) pls_kakuritu = 2;
@@ -1263,7 +1265,7 @@ MONRACE_IDX get_mon_num(DEPTH level)
        }
 
        /* Boost the level */
-       if (!p_ptr->inside_battle && !(d_info[dungeon_type].flags1 & DF1_BEGINNER))
+       if (!p_ptr->inside_battle && !(d_info[p_ptr->dungeon_idx].flags1 & DF1_BEGINNER))
        {
                /* Nightmare mode allows more out-of depth monsters */
                if (ironman_nightmare && !randint0(pls_kakuritu))
@@ -2260,7 +2262,7 @@ void update_monster(MONSTER_IDX m_idx, bool full)
        bool easy = FALSE;
 
        /* Non-Ninja player in the darkness */
-       bool in_darkness = (d_info[dungeon_type].flags1 & DF1_DARKNESS) && !p_ptr->see_nocto;
+       bool in_darkness = (d_info[p_ptr->dungeon_idx].flags1 & DF1_DARKNESS) && !p_ptr->see_nocto;
 
        /* Do disturb? */
        if (disturb_high)
@@ -2759,7 +2761,7 @@ void choose_new_monster(MONSTER_IDX m_idx, bool born, MONRACE_IDX r_idx)
                else
                        level = dun_level;
 
-               if (d_info[dungeon_type].flags1 & DF1_CHAMELEON) level+= 2+randint1(3);
+               if (d_info[p_ptr->dungeon_idx].flags1 & DF1_CHAMELEON) level+= 2+randint1(3);
 
                r_idx = get_mon_num(level);
                r_ptr = &r_info[r_idx];
@@ -3319,7 +3321,7 @@ static bool place_monster_one(MONSTER_IDX who, POSITION y, POSITION x, MONRACE_I
 #define MON_SCAT_MAXD 10 /*!< mon_scatter()関数によるモンスター配置で許される中心からの最大距離 */
 
 /*!
- * @brief モンスター1体を目標地点に可能なり近い位置に生成する / improved version of scatter() for place monster
+ * @brief モンスター1体を目標地点に可能なり近い位置に生成する / improved version of scatter() for place monster
  * @param r_idx 生成モンスター種族
  * @param yp 結果生成位置y座標
  * @param xp 結果生成位置x座標
@@ -3331,11 +3333,11 @@ static bool place_monster_one(MONSTER_IDX who, POSITION y, POSITION x, MONRACE_I
  */
 static bool mon_scatter(MONRACE_IDX r_idx, POSITION *yp, POSITION *xp, POSITION y, POSITION x, POSITION max_dist)
 {
-       int place_x[MON_SCAT_MAXD];
-       int place_y[MON_SCAT_MAXD];
+       POSITION place_x[MON_SCAT_MAXD];
+       POSITION place_y[MON_SCAT_MAXD];
        int num[MON_SCAT_MAXD];
        int i;
-       int nx, ny;
+       POSITION nx, ny;
 
        if (max_dist >= MON_SCAT_MAXD)
                return FALSE;
@@ -3621,8 +3623,6 @@ bool place_monster_aux(MONSTER_IDX who, POSITION y, POSITION x, MONRACE_IDX r_id
 
                        /* Require empty grids */
                        if (!cave_empty_bold2(ny, nx)) continue;
-
-                       /* Prepare allocation table */
                        get_mon_num_prep(place_monster_can_escort, get_monster_hook2(ny, nx));
 
                        /* Pick a random race */
@@ -3658,8 +3658,6 @@ bool place_monster_aux(MONSTER_IDX who, POSITION y, POSITION x, MONRACE_IDX r_id
 bool place_monster(POSITION y, POSITION x, BIT_FLAGS mode)
 {
        MONRACE_IDX r_idx;
-
-       /* Prepare allocation table */
        get_mon_num_prep(get_monster_hook(), get_monster_hook2(y, x));
 
        /* Pick a monster */
@@ -3688,8 +3686,6 @@ bool alloc_horde(POSITION y, POSITION x)
        int attempts = 1000;
        POSITION cy = y;
        POSITION cx = x;
-
-       /* Prepare allocation table */
        get_mon_num_prep(get_monster_hook(), get_monster_hook2(y, x));
 
        while (--attempts)
@@ -3744,9 +3740,9 @@ bool alloc_horde(POSITION y, POSITION x)
  */
 bool alloc_guardian(bool def_val)
 {
-       MONRACE_IDX guardian = d_info[dungeon_type].final_guardian;
+       MONRACE_IDX guardian = d_info[p_ptr->dungeon_idx].final_guardian;
 
-       if (guardian && (d_info[dungeon_type].maxdepth == dun_level) && (r_info[guardian].cur_num < r_info[guardian].max_num))
+       if (guardian && (d_info[p_ptr->dungeon_idx].maxdepth == dun_level) && (r_info[guardian].cur_num < r_info[guardian].max_num))
        {
                int oy;
                int ox;
@@ -3886,7 +3882,7 @@ static bool summon_specific_okay(MONRACE_IDX r_idx)
            monster_has_hostile_align(NULL, 10, -10, r_ptr))
                return FALSE;
 
-       if ((r_ptr->flags7 & RF7_CHAMELEON) && (d_info[dungeon_type].flags1 & DF1_CHAMELEON)) return TRUE;
+       if ((r_ptr->flags7 & RF7_CHAMELEON) && (d_info[p_ptr->dungeon_idx].flags1 & DF1_CHAMELEON)) return TRUE;
 
        return (summon_specific_aux(r_idx));
 }
@@ -3941,8 +3937,6 @@ bool summon_specific(MONSTER_IDX who, POSITION y1, POSITION x1, DEPTH lev, int t
        summon_kin_type = symbol;
 
        summon_unique_okay = (mode & PM_ALLOW_UNIQUE) ? TRUE : FALSE;
-
-       /* Prepare allocation table */
        get_mon_num_prep(summon_specific_okay, get_monster_hook2(y, x));
 
        /* Pick a monster, using the level calculation */