OSDN Git Service

[Refactor] #38995 world_type 構造体に dungeon_turn を取り込む。 / Move dungeon_turn to world_t...
[hengband/hengband.git] / src / monster2.c
index 11ec6de..20262bc 100644 (file)
@@ -235,7 +235,7 @@ MONRACE_IDX real_r_idx(monster_type *m_ptr)
 void delete_monster_idx(MONSTER_IDX i)
 {
        POSITION x, y;
-       monster_type *m_ptr = &m_list[i];
+       monster_type *m_ptr = &current_floor_ptr->m_list[i];
        monster_race *r_ptr = &r_info[m_ptr->r_idx];
        OBJECT_IDX this_o_idx, next_o_idx = 0;
 
@@ -246,7 +246,7 @@ void delete_monster_idx(MONSTER_IDX i)
        real_r_ptr(m_ptr)->cur_num--;
 
        /* Hack -- count the number of "reproducers" */
-       if (r_ptr->flags2 & (RF2_MULTIPLY)) num_repro--;
+       if (r_ptr->flags2 & (RF2_MULTIPLY)) current_floor_ptr->num_repro--;
 
        if (MON_CSLEEP(m_ptr)) (void)set_monster_csleep(i, 0);
        if (MON_FAST(m_ptr)) (void)set_monster_fast(i, 0);
@@ -272,7 +272,7 @@ void delete_monster_idx(MONSTER_IDX i)
        for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
        {
                object_type *o_ptr;
-               o_ptr = &o_list[this_o_idx];
+               o_ptr = &current_floor_ptr->o_list[this_o_idx];
 
                /* Acquire next object */
                next_o_idx = o_ptr->next_o_idx;
@@ -343,7 +343,7 @@ static void compact_monsters_aux(IDX i1, IDX i2)
        if (i1 == i2) return;
 
        /* Old monster */
-       m_ptr = &m_list[i1];
+       m_ptr = &current_floor_ptr->m_list[i1];
 
        y = m_ptr->fy;
        x = m_ptr->fx;
@@ -358,7 +358,7 @@ static void compact_monsters_aux(IDX i1, IDX i2)
        for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
        {
                object_type *o_ptr;
-               o_ptr = &o_list[this_o_idx];
+               o_ptr = &current_floor_ptr->o_list[this_o_idx];
 
                /* Acquire next object */
                next_o_idx = o_ptr->next_o_idx;
@@ -385,7 +385,7 @@ static void compact_monsters_aux(IDX i1, IDX i2)
        {
                for (i = 1; i < m_max; i++)
                {
-                       monster_type *m2_ptr = &m_list[i];
+                       monster_type *m2_ptr = &current_floor_ptr->m_list[i];
 
                        if (m2_ptr->parent_m_idx == i1)
                                m2_ptr->parent_m_idx = i2;
@@ -393,15 +393,15 @@ static void compact_monsters_aux(IDX i1, IDX i2)
        }
 
        /* Structure copy */
-       (void)COPY(&m_list[i2], &m_list[i1], monster_type);
+       (void)COPY(&current_floor_ptr->m_list[i2], &current_floor_ptr->m_list[i1], monster_type);
 
        /* Wipe the hole */
-       (void)WIPE(&m_list[i1], monster_type);
+       (void)WIPE(&current_floor_ptr->m_list[i1], monster_type);
 
        for (i = 0; i < MAX_MTIMED; i++)
        {
                int mproc_idx = get_mproc_idx(i1, i);
-               if (mproc_idx >= 0) mproc_list[i][mproc_idx] = i2;
+               if (mproc_idx >= 0) current_floor_ptr->mproc_list[i][mproc_idx] = i2;
        }
 }
 
@@ -442,7 +442,7 @@ void compact_monsters(int size)
                /* Check all the monsters */
                for (i = 1; i < m_max; i++)
                {
-                       monster_type *m_ptr = &m_list[i];
+                       monster_type *m_ptr = &current_floor_ptr->m_list[i];
 
                        monster_race *r_ptr = &r_info[m_ptr->r_idx];
 
@@ -488,7 +488,7 @@ void compact_monsters(int size)
        for (i = m_max - 1; i >= 1; i--)
        {
                /* Get the i'th monster */
-               monster_type *m_ptr = &m_list[i];
+               monster_type *m_ptr = &current_floor_ptr->m_list[i];
 
                /* Skip real monsters */
                if (m_ptr->r_idx) continue;
@@ -535,7 +535,7 @@ void wipe_m_list(void)
        /* Delete all the monsters */
        for (i = m_max - 1; i >= 1; i--)
        {
-               monster_type *m_ptr = &m_list[i];
+               monster_type *m_ptr = &current_floor_ptr->m_list[i];
 
                /* Skip dead monsters */
                if (!m_ptr->r_idx) continue;
@@ -563,11 +563,11 @@ void wipe_m_list(void)
        /* Reset "m_cnt" */
        m_cnt = 0;
 
-       /* Reset "mproc_max[]" */
-       for (i = 0; i < MAX_MTIMED; i++) mproc_max[i] = 0;
+       /* Reset "current_floor_ptr->mproc_max[]" */
+       for (i = 0; i < MAX_MTIMED; i++) current_floor_ptr->mproc_max[i] = 0;
 
        /* Hack -- reset "reproducer" count */
-       num_repro = 0;
+       current_floor_ptr->num_repro = 0;
 
        /* Hack -- no more target */
        target_who = 0;
@@ -590,7 +590,7 @@ MONSTER_IDX m_pop(void)
        MONSTER_IDX i;
 
        /* Normal allocation */
-       if (m_max < max_m_idx)
+       if (m_max < current_floor_ptr->max_m_idx)
        {
                /* Access the next hole */
                i = m_max;
@@ -611,7 +611,7 @@ MONSTER_IDX m_pop(void)
                monster_type *m_ptr;
 
                /* Acquire monster */
-               m_ptr = &m_list[i];
+               m_ptr = &current_floor_ptr->m_list[i];
 
                /* Skip live monsters */
                if (m_ptr->r_idx) continue;
@@ -1254,8 +1254,8 @@ MONRACE_IDX get_mon_num(DEPTH level)
        int pls_kakuritu, pls_level;
        int delay = mysqrt(level * 10000L) + 400L;
 
-       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)) ;
+       pls_kakuritu = MAX(NASTY_MON_MAX, NASTY_MON_BASE - ((current_world_ptr->dungeon_turn / (TURNS_PER_TICK * 5000L) - delay / 10)));
+       pls_level    = MIN(NASTY_MON_PLUS_MAX, 3 + current_world_ptr->dungeon_turn / (TURNS_PER_TICK * 40000L) - delay / 40 + MIN(5, level / 10)) ;
 
        if (d_info[p_ptr->dungeon_idx].flags1 & DF1_MAZE)
        {
@@ -1663,7 +1663,7 @@ void monster_desc(char *desc, monster_type *m_ptr, BIT_FLAGS mode)
 
                        /* Inside monster arena, and it is not your mount */
                        else if (p_ptr->inside_battle &&
-                                !(p_ptr->riding && (&m_list[p_ptr->riding] == m_ptr)))
+                                !(p_ptr->riding && (&current_floor_ptr->m_list[p_ptr->riding] == m_ptr)))
                        {
                                /* It is a fake unique monster */
                                (void)sprintf(desc, _("%sもどき", "fake %s"), name);
@@ -1708,7 +1708,7 @@ void monster_desc(char *desc, monster_type *m_ptr, BIT_FLAGS mode)
                        strcat(desc,buf);
                }
 
-               if (p_ptr->riding && (&m_list[p_ptr->riding] == m_ptr))
+               if (p_ptr->riding && (&current_floor_ptr->m_list[p_ptr->riding] == m_ptr))
                {
                        strcat(desc,_("(乗馬中)", "(riding)"));
                }
@@ -1869,7 +1869,7 @@ int lore_do_probe(MONRACE_IDX r_idx)
  */
 void lore_treasure(MONSTER_IDX m_idx, ITEM_NUMBER num_item, ITEM_NUMBER num_gold)
 {
-       monster_type *m_ptr = &m_list[m_idx];
+       monster_type *m_ptr = &current_floor_ptr->m_list[m_idx];
 
        monster_race *r_ptr = &r_info[m_ptr->r_idx];
 
@@ -2085,11 +2085,11 @@ void sanity_blast(monster_type *m_ptr, bool necro)
                {
                        if ((p_ptr->stat_use[A_INT] < 4) && (p_ptr->stat_use[A_WIS] < 4))
                        {
-                               msg_print(_("あなたは完璧な馬鹿になったような気がした。しかしそれは元々だった。", "You turn into an utter moron!"));
+                               msg_print(_("あなたは完璧な馬鹿になったような気がした。しかしそれは元々だった。", "You current_world_ptr->game_turn into an utter moron!"));
                        }
                        else
                        {
-                               msg_print(_("あなたは完璧な馬鹿になった!", "You turn into an utter moron!"));
+                               msg_print(_("あなたは完璧な馬鹿になった!", "You current_world_ptr->game_turn into an utter moron!"));
                        }
 
                        if (p_ptr->muta3 & MUT3_HYPER_INT)
@@ -2234,7 +2234,7 @@ void sanity_blast(monster_type *m_ptr, bool necro)
  */
 void update_monster(MONSTER_IDX m_idx, bool full)
 {
-       monster_type *m_ptr = &m_list[m_idx];
+       monster_type *m_ptr = &current_floor_ptr->m_list[m_idx];
 
        monster_race *r_ptr = &r_info[m_ptr->r_idx];
 
@@ -2630,7 +2630,7 @@ void update_monsters(bool full)
        /* Update each (live) monster */
        for (i = 1; i < m_max; i++)
        {
-               monster_type *m_ptr = &m_list[i];
+               monster_type *m_ptr = &current_floor_ptr->m_list[i];
 
                /* Skip dead monsters */
                if (!m_ptr->r_idx) continue;
@@ -2647,7 +2647,7 @@ void update_monsters(bool full)
 static bool monster_hook_chameleon_lord(MONRACE_IDX r_idx)
 {
        monster_race *r_ptr = &r_info[r_idx];
-       monster_type *m_ptr = &m_list[chameleon_change_m_idx];
+       monster_type *m_ptr = &current_floor_ptr->m_list[chameleon_change_m_idx];
        monster_race *old_r_ptr = &r_info[m_ptr->r_idx];
 
        if (!(r_ptr->flags1 & (RF1_UNIQUE))) return FALSE;
@@ -2669,7 +2669,7 @@ static bool monster_hook_chameleon_lord(MONRACE_IDX r_idx)
        /* Born now */
        else if (summon_specific_who > 0)
        {
-               if (monster_has_hostile_align(&m_list[summon_specific_who], 0, 0, r_ptr)) return FALSE;
+               if (monster_has_hostile_align(&current_floor_ptr->m_list[summon_specific_who], 0, 0, r_ptr)) return FALSE;
        }
 
        return TRUE;
@@ -2683,7 +2683,7 @@ static bool monster_hook_chameleon_lord(MONRACE_IDX r_idx)
 static bool monster_hook_chameleon(MONRACE_IDX r_idx)
 {
        monster_race *r_ptr = &r_info[r_idx];
-       monster_type *m_ptr = &m_list[chameleon_change_m_idx];
+       monster_type *m_ptr = &current_floor_ptr->m_list[chameleon_change_m_idx];
        monster_race *old_r_ptr = &r_info[m_ptr->r_idx];
 
        if (r_ptr->flags1 & (RF1_UNIQUE)) return FALSE;
@@ -2706,7 +2706,7 @@ static bool monster_hook_chameleon(MONRACE_IDX r_idx)
        /* Born now */
        else if (summon_specific_who > 0)
        {
-               if (monster_has_hostile_align(&m_list[summon_specific_who], 0, 0, r_ptr)) return FALSE;
+               if (monster_has_hostile_align(&current_floor_ptr->m_list[summon_specific_who], 0, 0, r_ptr)) return FALSE;
        }
 
        return (*(get_monster_hook()))(r_idx);
@@ -2722,7 +2722,7 @@ static bool monster_hook_chameleon(MONRACE_IDX r_idx)
 void choose_new_monster(MONSTER_IDX m_idx, bool born, MONRACE_IDX r_idx)
 {
        int oldmaxhp;
-       monster_type *m_ptr = &m_list[m_idx];
+       monster_type *m_ptr = &current_floor_ptr->m_list[m_idx];
        monster_race *r_ptr;
        char old_m_name[MAX_NLEN];
        bool old_unique = FALSE;
@@ -3002,10 +3002,10 @@ static bool place_monster_one(MONSTER_IDX who, POSITION y, POSITION x, MONRACE_I
                                number_mon = 0;
 
                                /* Count all quest monsters */
-                               for (i2 = 0; i2 < cur_wid; ++i2)
-                                       for (j2 = 0; j2 < cur_hgt; j2++)
+                               for (i2 = 0; i2 < current_floor_ptr->width; ++i2)
+                                       for (j2 = 0; j2 < current_floor_ptr->height; j2++)
                                                if (current_floor_ptr->grid_array[j2][i2].m_idx > 0)
-                                                       if (m_list[current_floor_ptr->grid_array[j2][i2].m_idx].r_idx == quest[hoge].r_idx)
+                                                       if (current_floor_ptr->m_list[current_floor_ptr->grid_array[j2][i2].m_idx].r_idx == quest[hoge].r_idx)
                                                                number_mon++;
                                if(number_mon + quest[hoge].cur_num >= quest[hoge].max_num)
                                        return FALSE;
@@ -3048,7 +3048,7 @@ static bool place_monster_one(MONSTER_IDX who, POSITION y, POSITION x, MONRACE_I
 
 
        /* Get a new monster record */
-       m_ptr = &m_list[g_ptr->m_idx];
+       m_ptr = &current_floor_ptr->m_list[g_ptr->m_idx];
 
        /* Save the race */
        m_ptr->r_idx = r_idx;
@@ -3059,17 +3059,17 @@ static bool place_monster_one(MONSTER_IDX who, POSITION y, POSITION x, MONRACE_I
        m_ptr->mflag2 = 0;
 
        /* Hack -- Appearance transfer */
-       if ((mode & PM_MULTIPLY) && (who > 0) && !is_original_ap(&m_list[who]))
+       if ((mode & PM_MULTIPLY) && (who > 0) && !is_original_ap(&current_floor_ptr->m_list[who]))
        {
-               m_ptr->ap_r_idx = m_list[who].ap_r_idx;
+               m_ptr->ap_r_idx = current_floor_ptr->m_list[who].ap_r_idx;
 
                /* Hack -- Shadower spawns Shadower */
-               if (m_list[who].mflag2 & MFLAG2_KAGE) m_ptr->mflag2 |= MFLAG2_KAGE;
+               if (current_floor_ptr->m_list[who].mflag2 & MFLAG2_KAGE) m_ptr->mflag2 |= MFLAG2_KAGE;
        }
 
        /* Sub-alignment of a monster */
        if ((who > 0) && !(r_ptr->flags3 & (RF3_EVIL | RF3_GOOD)))
-               m_ptr->sub_align = m_list[who].sub_align;
+               m_ptr->sub_align = current_floor_ptr->m_list[who].sub_align;
        else
        {
                m_ptr->sub_align = SUB_ALIGN_NEUTRAL;
@@ -3096,7 +3096,7 @@ static bool place_monster_one(MONSTER_IDX who, POSITION y, POSITION x, MONRACE_I
 
 
        /* Your pet summons its pet. */
-       if (who > 0 && is_pet(&m_list[who]))
+       if (who > 0 && is_pet(&current_floor_ptr->m_list[who]))
        {
                mode |= PM_FORCE_PET;
                m_ptr->parent_m_idx = who;
@@ -3232,7 +3232,7 @@ static bool place_monster_one(MONSTER_IDX who, POSITION y, POSITION x, MONRACE_I
                real_r_ptr(m_ptr)->floor_id = p_ptr->floor_id;
 
        /* Hack -- Count the number of "reproducers" */
-       if (r_ptr->flags2 & RF2_MULTIPLY) num_repro++;
+       if (r_ptr->flags2 & RF2_MULTIPLY) current_floor_ptr->num_repro++;
 
        /* Hack -- Notice new multi-hued monsters */
        {
@@ -3503,7 +3503,7 @@ static MONSTER_IDX place_monster_m_idx = 0;
 static bool place_monster_can_escort(MONRACE_IDX r_idx)
 {
        monster_race *r_ptr = &r_info[place_monster_idx];
-       monster_type *m_ptr = &m_list[place_monster_m_idx];
+       monster_type *m_ptr = &current_floor_ptr->m_list[place_monster_m_idx];
 
        monster_race *z_ptr = &r_info[r_idx];
 
@@ -3652,7 +3652,7 @@ bool place_monster(POSITION y, POSITION x, BIT_FLAGS mode)
        get_mon_num_prep(get_monster_hook(), get_monster_hook2(y, x));
 
        /* Pick a monster */
-       r_idx = get_mon_num(monster_level);
+       r_idx = get_mon_num(current_floor_ptr->monster_level);
 
        /* Handle failure */
        if (!r_idx) return (FALSE);
@@ -3682,7 +3682,7 @@ bool alloc_horde(POSITION y, POSITION x)
        while (--attempts)
        {
                /* Pick a monster */
-               r_idx = get_mon_num(monster_level);
+               r_idx = get_mon_num(current_floor_ptr->monster_level);
 
                /* Handle failure */
                if (!r_idx) return (FALSE);
@@ -3708,7 +3708,7 @@ bool alloc_horde(POSITION y, POSITION x)
 
        m_idx = current_floor_ptr->grid_array[y][x].m_idx;
 
-       if (m_list[m_idx].mflag2 & MFLAG2_CHAMELEON) r_ptr = &r_info[m_list[m_idx].r_idx];
+       if (current_floor_ptr->m_list[m_idx].mflag2 & MFLAG2_CHAMELEON) r_ptr = &r_info[current_floor_ptr->m_list[m_idx].r_idx];
 
        for (attempts = randint1(10) + 5; attempts; attempts--)
        {
@@ -3743,8 +3743,8 @@ bool alloc_guardian(bool def_val)
                while (try_count)
                {
                        /* Get a random spot */
-                       oy = randint1(cur_hgt - 4) + 2;
-                       ox = randint1(cur_wid - 4) + 2;
+                       oy = randint1(current_floor_ptr->height - 4) + 2;
+                       ox = randint1(current_floor_ptr->width - 4) + 2;
 
                        /* Is it a good spot ? */
                        if (cave_empty_bold2(oy, ox) && monster_can_cross_terrain(current_floor_ptr->grid_array[oy][ox].feat, &r_info[guardian], 0))
@@ -3772,7 +3772,7 @@ bool alloc_guardian(bool def_val)
  * @details
  * Place the monster at least "dis" distance from the player.
  * Use "slp" to choose the initial "sleep" status
- * Use "monster_level" for the monster level
+ * Use "current_floor_ptr->monster_level" for the monster level
  */
 bool alloc_monster(POSITION dis, BIT_FLAGS mode)
 {
@@ -3786,8 +3786,8 @@ bool alloc_monster(POSITION dis, BIT_FLAGS mode)
        while (attempts_left--)
        {
                /* Pick a location */
-               y = randint0(cur_hgt);
-               x = randint0(cur_wid);
+               y = randint0(current_floor_ptr->height);
+               x = randint0(current_floor_ptr->width);
 
                /* Require empty floor grid (was "naked") */
                if (current_floor_ptr->dun_level)
@@ -3846,7 +3846,7 @@ static bool summon_specific_okay(MONRACE_IDX r_idx)
        /* Hack -- identify the summoning monster */
        if (summon_specific_who > 0)
        {
-               monster_type *m_ptr = &m_list[summon_specific_who];
+               monster_type *m_ptr = &current_floor_ptr->m_list[summon_specific_who];
 
                /* Do not summon enemies */
 
@@ -3995,7 +3995,7 @@ bool summon_named_creature(MONSTER_IDX who, POSITION oy, POSITION ox, MONRACE_ID
  */
 bool multiply_monster(MONSTER_IDX m_idx, bool clone, BIT_FLAGS mode)
 {
-       monster_type *m_ptr = &m_list[m_idx];
+       monster_type *m_ptr = &current_floor_ptr->m_list[m_idx];
        POSITION y, x;
 
        if (!mon_scatter(m_ptr->r_idx, &y, &x, m_ptr->fy, m_ptr->fx, 1))
@@ -4010,8 +4010,8 @@ bool multiply_monster(MONSTER_IDX m_idx, bool clone, BIT_FLAGS mode)
        /* Hack -- Transfer "clone" flag */
        if (clone || (m_ptr->smart & SM_CLONED))
        {
-               m_list[hack_m_idx_ii].smart |= SM_CLONED;
-               m_list[hack_m_idx_ii].mflag2 |= MFLAG2_NOPET;
+               current_floor_ptr->m_list[hack_m_idx_ii].smart |= SM_CLONED;
+               current_floor_ptr->m_list[hack_m_idx_ii].mflag2 |= MFLAG2_NOPET;
        }
 
        return TRUE;
@@ -4033,7 +4033,7 @@ void message_pain(MONSTER_IDX m_idx, HIT_POINT dam)
        HIT_POINT tmp;
        PERCENTAGE percentage;
 
-       monster_type *m_ptr = &m_list[m_idx];
+       monster_type *m_ptr = &current_floor_ptr->m_list[m_idx];
        monster_race *r_ptr = &r_info[m_ptr->r_idx];
 
        GAME_TEXT m_name[MAX_NLEN];
@@ -4357,7 +4357,7 @@ void message_pain(MONSTER_IDX m_idx, HIT_POINT dam)
  */
 void update_smart_learn(MONSTER_IDX m_idx, int what)
 {
-       monster_type *m_ptr = &m_list[m_idx];
+       monster_type *m_ptr = &current_floor_ptr->m_list[m_idx];
        monster_race *r_ptr = &r_info[m_ptr->r_idx];
 
        /* Not allowed to learn */
@@ -4477,7 +4477,7 @@ void monster_drop_carried_objects(monster_type *m_ptr)
        /* Drop objects being carried */
        for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
        {
-               o_ptr = &o_list[this_o_idx];
+               o_ptr = &current_floor_ptr->o_list[this_o_idx];
 
                /* Acquire next object */
                next_o_idx = o_ptr->next_o_idx;