OSDN Git Service

抹殺/消滅, ペット爆破, 親モンスター消滅, モンスター圧縮, 不潔な病人の
[hengband/hengband.git] / src / floors.c
index d3494ea..67bb685 100644 (file)
@@ -191,6 +191,9 @@ static void kill_saved_floor(saved_floor_type *sf_ptr)
 {
        char floor_savefile[1024];
 
+       /* Paranoia */
+       if (!sf_ptr) return;
+
        /* Already empty */
        if (!sf_ptr->floor_id) return;
 
@@ -275,7 +278,8 @@ s16b get_new_floor_id(void)
        sf_ptr->lower_floor_id = 0;
        sf_ptr->visit_mark = latest_visit_mark++;
 
-       /* sf_ptr->dun_level is not yet decided */
+       /* sf_ptr->dun_level may be changed later */
+       sf_ptr->dun_level = dun_level;
 
 
        /* Increment number of floor_id */
@@ -330,9 +334,17 @@ static void build_dead_end(void)
 
        /* Give one square */
        place_floor_bold(py, px);
+
+       wipe_generate_cave_flags();
 }
 
 
+/* Maximum number of preservable pets */
+#define MAX_PARTY_MON 21
+
+static monster_type party_mon[MAX_PARTY_MON];
+
+
 /*
  * Preserve_pets
  */
@@ -389,7 +401,7 @@ static void preserve_pet(void)
                                int dis = distance(py, px, m_ptr->fy, m_ptr->fx);
 
                                /* Confused (etc.) monsters don't follow. */
-                               if (m_ptr->confused || m_ptr->stunned || m_ptr->csleep) continue;
+                               if (MON_CONFUSED(m_ptr) || MON_STUNNED(m_ptr) || MON_CSLEEP(m_ptr)) continue;
 
                                /* Pet of other pet don't follow. */
                                if (m_ptr->parent_m_idx) continue;
@@ -432,7 +444,7 @@ static void preserve_pet(void)
                        if (p_ptr->riding == i) continue;
 
                        monster_desc(m_name, m_ptr, MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE);
-                       do_cmd_write_nikki(NIKKI_NAMED_PET, 4, m_name);
+                       do_cmd_write_nikki(NIKKI_NAMED_PET, RECORD_NAMED_PET_MOVED, m_name);
                }
        }
 
@@ -447,10 +459,10 @@ static void preserve_pet(void)
                {
                        /* Its parent have gone, it also goes away. */
 
-                       if (m_ptr->ml)
+                       if (is_seen(m_ptr))
                        {
                                char m_name[80];
-                       
+
                                /* Acquire the monster name */
                                monster_desc(m_name, m_ptr, 0);
 
@@ -547,7 +559,7 @@ static void place_pet(void)
                        m_ptr->fy = cy;
                        m_ptr->fx = cx;
                        m_ptr->ml = TRUE;
-                       m_ptr->csleep = 0;
+                       m_ptr->mtimed[MTIMED_CSLEEP] = 0;
 
                        /* Paranoia */
                        m_ptr->hold_o_idx = 0;
@@ -594,7 +606,7 @@ static void place_pet(void)
                        if (record_named_pet && m_ptr->nickname)
                        {
                                monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
-                               do_cmd_write_nikki(NIKKI_NAMED_PET, 5, m_name);
+                               do_cmd_write_nikki(NIKKI_NAMED_PET, RECORD_NAMED_PET_LOST_SIGHT, m_name);
                        }
 
                        /* Pre-calculated in precalc_cur_num_of_pet(), but need to decrease */
@@ -602,8 +614,8 @@ static void place_pet(void)
                }
        }
 
-       /* For accuracy of precalc_cur_num_of_pet() */               
-       C_WIPE(party_mon, MAX_PARTY_MON, monster_type);                            
+       /* For accuracy of precalc_cur_num_of_pet() */
+       C_WIPE(party_mon, MAX_PARTY_MON, monster_type);
 }
 
 
@@ -647,7 +659,7 @@ static void update_unique_artifact(s16b cur_floor_id)
                if (!o_ptr->k_idx) continue;
 
                /* Memorize location of the artifact */
-               if (artifact_p(o_ptr))
+               if (object_is_fixed_artifact(o_ptr))
                {
                        a_info[o_ptr->name1].floor_id = cur_floor_id;
                }
@@ -707,12 +719,12 @@ static void get_out_monster(void)
 
                m_ptr = &m_list[m_idx];
 
-               /* Update the new location */
-               cave[ny][nx].m_idx = m_idx;
-
                /* Update the old location */
                cave[oy][ox].m_idx = 0;
 
+               /* Update the new location */
+               cave[ny][nx].m_idx = m_idx;
+
                /* Move the monster */
                m_ptr->fy = ny;
                m_ptr->fx = nx; 
@@ -850,6 +862,8 @@ void leave_floor(void)
        /* Remove all mirrors without explosion */
        remove_all_mirrors(FALSE);
 
+       if (p_ptr->special_defense & NINJA_S_STEALTH) set_superstealth(FALSE);
+
        /* New floor is not yet prepared */
        new_floor_id = 0;
 
@@ -860,9 +874,6 @@ void leave_floor(void)
        {
            /* Get temporal floor_id */
            p_ptr->floor_id = get_new_floor_id();
-           
-           /* Record the dungeon level */
-           get_sf_ptr(p_ptr->floor_id)->dun_level = dun_level;
        }
 
 
@@ -912,7 +923,7 @@ void leave_floor(void)
                if (!o_ptr->k_idx) continue;
 
                /* Delete old memorized location of the artifact */
-               if (artifact_p(o_ptr))
+               if (object_is_fixed_artifact(o_ptr))
                {
                        a_info[o_ptr->name1].floor_id = 0;
                }
@@ -1029,9 +1040,6 @@ void leave_floor(void)
                {
                        c_ptr->special = new_floor_id;
                }
-
-               /* Record new dungeon level */
-               get_sf_ptr(new_floor_id)->dun_level = dun_level;
        }
 
        /* Fix connection -- level teleportation or trap door */
@@ -1176,14 +1184,27 @@ void change_floor(void)
                        }
                }
 
+               /* Break connection to killed floor */
+               else
+               {
+                       if (change_floor_mode & CFM_UP)
+                               sf_ptr->lower_floor_id = 0;
+                       else if (change_floor_mode & CFM_DOWN)
+                               sf_ptr->upper_floor_id = 0;
+               }
+
                /* Maintain monsters and artifacts */
                if (loaded)
                {
                        int i;
-                       s32b absence_ticks = (turn - sf_ptr->last_visit) / TURNS_PER_TICK;
+                       s32b tmp_last_visit = sf_ptr->last_visit;
+                       s32b absence_ticks;
                        int alloc_chance = d_info[dungeon_type].max_m_alloc_chance;
                        int alloc_times;
 
+                       while (tmp_last_visit > turn) tmp_last_visit -= TURNS_PER_TICK * TOWN_DAWN;
+                       absence_ticks = (turn - tmp_last_visit) / TURNS_PER_TICK;
+
                        /* Maintain monsters */
                        for (i = 1; i < m_max; i++)
                        {
@@ -1198,23 +1219,13 @@ void change_floor(void)
                                        /* Restore HP */
                                        m_ptr->hp = m_ptr->maxhp = m_ptr->max_maxhp;
 
-                                       /* Remove fear */
-                                       m_ptr->monfear = 0;
-
-                                       /* Remove invulnerability */
-                                       m_ptr->invulner = 0;
-
-                                       /* Remove fast status */
-                                       m_ptr->fast = 0;
-
-                                       /* Remove slow status */
-                                       m_ptr->slow = 0;
-
-                                       /* Remove stun */
-                                       m_ptr->stunned = 0;
-
-                                       /* Remove confusion */
-                                       m_ptr->confused = 0;
+                                       /* Remove timed status (except MTIMED_CSLEEP) */
+                                       (void)set_monster_fast(i, 0);
+                                       (void)set_monster_slow(i, 0);
+                                       (void)set_monster_stunned(i, 0);
+                                       (void)set_monster_confused(i, 0);
+                                       (void)set_monster_monfear(i, 0);
+                                       (void)set_monster_invulner(i, 0, FALSE);
                                }
 
                                /* Extract real monster race */
@@ -1241,7 +1252,7 @@ void change_floor(void)
                                if (!o_ptr->k_idx) continue;
 
                                /* Ignore non-artifact */
-                               if (!artifact_p(o_ptr)) continue;
+                               if (!object_is_fixed_artifact(o_ptr)) continue;
 
                                /* Appear at a different floor? */
                                if (a_info[o_ptr->name1].floor_id != new_floor_id)
@@ -1256,7 +1267,7 @@ void change_floor(void)
                                }
                        }
 
-                       place_quest_monsters();
+                       (void)place_quest_monsters();
 
                        /* Place some random monsters */
                        alloc_times = absence_ticks / alloc_chance;
@@ -1319,19 +1330,13 @@ void change_floor(void)
                                /* No stairs down from Quest */
                                if ((change_floor_mode & CFM_UP) && !quest_number(dun_level))
                                {
-                                       if (change_floor_mode & CFM_SHAFT)
-                                               c_ptr->feat = FEAT_MORE_MORE;
-                                       else
-                                               c_ptr->feat = FEAT_MORE;
+                                       c_ptr->feat = (change_floor_mode & CFM_SHAFT) ? feat_state(feat_down_stair, FF_SHAFT) : feat_down_stair;
                                }
 
                                /* No stairs up when ironman_downward */
                                else if ((change_floor_mode & CFM_DOWN) && !ironman_downward)
                                {
-                                       if (change_floor_mode & CFM_SHAFT)
-                                               c_ptr->feat = FEAT_LESS_LESS;
-                                       else
-                                               c_ptr->feat = FEAT_LESS;
+                                       c_ptr->feat = (change_floor_mode & CFM_SHAFT) ? feat_state(feat_up_stair, FF_SHAFT) : feat_up_stair;
                                }
 
                                /* Paranoia -- Clear mimic */
@@ -1400,6 +1405,10 @@ void change_floor(void)
        /* Remember when this level was "created" */
        old_turn = turn;
 
+       /* No dungeon feeling yet */
+       p_ptr->feeling_turn = old_turn;
+       p_ptr->feeling = 0;
+
        /* Clear all flags */
        change_floor_mode = 0L;
 }
@@ -1458,6 +1467,14 @@ void stair_creation(void)
        /* Extract current floor data */
        sf_ptr = get_sf_ptr(p_ptr->floor_id);
 
+       /* Paranoia */
+       if (!sf_ptr)
+       {
+               /* No floor id? -- Create now! */
+               p_ptr->floor_id = get_new_floor_id();
+               sf_ptr = get_sf_ptr(p_ptr->floor_id);
+       } 
+
        /* Choose randomly */
        if (up && down)
        {
@@ -1517,17 +1534,15 @@ void stair_creation(void)
        /* Create a staircase */
        if (up)
        {
-               if (dest_sf_ptr->last_visit && dest_sf_ptr->dun_level <= dun_level - 2)
-                       cave_set_feat(py, px, FEAT_LESS_LESS);
-               else
-                       cave_set_feat(py, px, FEAT_LESS);
+               cave_set_feat(py, px,
+                       (dest_sf_ptr->last_visit && (dest_sf_ptr->dun_level <= dun_level - 2)) ?
+                       feat_state(feat_up_stair, FF_SHAFT) : feat_up_stair);
        }
        else
        {
-               if (dest_sf_ptr->last_visit && dest_sf_ptr->dun_level >= dun_level + 2)
-                       cave_set_feat(py, px, FEAT_MORE_MORE);
-               else
-                       cave_set_feat(py, px, FEAT_MORE);
+               cave_set_feat(py, px,
+                       (dest_sf_ptr->last_visit && (dest_sf_ptr->dun_level >= dun_level + 2)) ?
+                       feat_state(feat_down_stair, FF_SHAFT) : feat_down_stair);
        }