OSDN Git Service

モンスターの状態変化処理を標準ターンで行う際に, 処理の必要のある状態
authornothere <nothere@0568b783-4c39-0410-ac80-bf13821ea2a2>
Fri, 16 Jan 2004 19:51:08 +0000 (19:51 +0000)
committernothere <nothere@0568b783-4c39-0410-ac80-bf13821ea2a2>
Fri, 16 Jan 2004 19:51:08 +0000 (19:51 +0000)
変化を持つモンスターの分だけ行うように変更. これで処理が極端に重いこ
とは少なくなると考えられるが, 詳細な検証が必要. 有効であれば1.6.xに
マージする. なお, 以下の変更と修正を含む.
* GF_CRUSADEで乗馬が加速してもPU_BONUSがないので追加した.
* party_mon[]をfloors.cに移転しstaticとした. また, MAX_PARTY_MONも併
  せてfloors.cに移転.
* カオス属性などで変身失敗した場合にもc_ptr->m_idxは変わる可能性があ
  るため, 関連するポインタを再計算するように修正.
* GF_CAPTUREの処理の微修正.

23 files changed:
src/cmd1.c
src/cmd5.c
src/defines.h
src/dungeon.c
src/effects.c
src/externs.h
src/floors.c
src/generate.c
src/init2.c
src/load.c
src/mane.c
src/melee2.c
src/mind.c
src/monster2.c
src/mspells1.c
src/mspells2.c
src/mspells3.c
src/spells1.c
src/spells2.c
src/spells3.c
src/types.h
src/variable.c
src/xtra2.c

index f0bdacd..c71f17b 100644 (file)
@@ -2071,9 +2071,13 @@ static void py_attack_aux(int y, int x, bool *fear, bool *mdeath, s16b hand, int
                }
        }
 
-       /* Disturb the monster */
-       m_ptr->csleep = 0;
-       if (r_ptr->flags7 & RF7_HAS_LD_MASK) p_ptr->update |= (PU_MON_LITE);
+       if (m_ptr->csleep)
+       {
+               /* Disturb the monster */
+               m_ptr->csleep = 0;
+               if (!need_mproc(m_ptr)) mproc_remove(m_ptr->mproc_idx);
+               if (r_ptr->flags7 & RF7_HAS_LD_MASK) p_ptr->update |= (PU_MON_LITE);
+       }
 
        /* Extract monster name (or "it") */
        monster_desc(m_name, m_ptr, 0);
@@ -2340,13 +2344,23 @@ static void py_attack_aux(int y, int x, bool *fear, bool *mdeath, s16b hand, int
                                {
                                        if (p_ptr->lev > randint1(r_ptr->level + resist_stun + 10))
                                        {
+                                               if (m_ptr->stunned)
+                                               {
+#ifdef JP
+                                                       msg_format("%^s¤Ï¤µ¤é¤Ë¥Õ¥é¥Õ¥é¤Ë¤Ê¤Ã¤¿¡£", m_name);
+#else
+                                                       msg_format("%^s is more stunned.", m_name);
+#endif
+                                               }
+                                               else
+                                               {
 #ifdef JP
-                                               if (m_ptr->stunned) msg_format("%^s¤Ï¤µ¤é¤Ë¥Õ¥é¥Õ¥é¤Ë¤Ê¤Ã¤¿¡£", m_name);
-                                               else msg_format("%^s¤Ï¥Õ¥é¥Õ¥é¤Ë¤Ê¤Ã¤¿¡£", m_name);
+                                                       msg_format("%^s¤Ï¥Õ¥é¥Õ¥é¤Ë¤Ê¤Ã¤¿¡£", m_name);
 #else
-                                               if (m_ptr->stunned) msg_format("%^s is more stunned.", m_name);
-                                               else msg_format("%^s is stunned.", m_name);
+                                                       msg_format("%^s is stunned.", m_name);
 #endif
+                                                       if (!m_ptr->mproc_idx) mproc_add(c_ptr->m_idx);
+                                               }
 
                                                m_ptr->stunned += stun_effect;
                                        }
@@ -2527,6 +2541,7 @@ static void py_attack_aux(int y, int x, bool *fear, bool *mdeath, s16b hand, int
 #else
                                                msg_format("%s is dazed.", m_name);
 #endif
+                                               if (!m_ptr->mproc_idx) mproc_add(c_ptr->m_idx);
                                        }
 
                                        /* Apply stun */
@@ -2770,6 +2785,7 @@ static void py_attack_aux(int y, int x, bool *fear, bool *mdeath, s16b hand, int
                                        msg_format("%^s appears confused.", m_name);
 #endif
 
+                                       if (!m_ptr->mproc_idx) mproc_add(c_ptr->m_idx);
                                        m_ptr->confused += 10 + randint0(p_ptr->lev) / 5;
                                }
                        }
@@ -2831,16 +2847,6 @@ static void py_attack_aux(int y, int x, bool *fear, bool *mdeath, s16b hand, int
                                                msg_format("%^s changes!", m_name);
 #endif
 
-
-                                               /* Hack -- Get new monster */
-                                               m_ptr = &m_list[c_ptr->m_idx];
-
-                                               /* Oops, we need a different name... */
-                                               monster_desc(m_name, m_ptr, 0);
-
-                                               /* Hack -- Get new race */
-                                               r_ptr = &r_info[m_ptr->r_idx];
-
                                                *fear = FALSE;
                                                weak = FALSE;
                                        }
@@ -2851,8 +2857,16 @@ static void py_attack_aux(int y, int x, bool *fear, bool *mdeath, s16b hand, int
 #else
                                                msg_format("%^s is unaffected.", m_name);
 #endif
-
                                        }
+
+                                       /* Hack -- Get new monster */
+                                       m_ptr = &m_list[c_ptr->m_idx];
+
+                                       /* Oops, we need a different name... */
+                                       monster_desc(m_name, m_ptr, 0);
+
+                                       /* Hack -- Get new race */
+                                       r_ptr = &r_info[m_ptr->r_idx];
                                }
                        }
                        else if (o_ptr->name1 == ART_G_HAMMER)
@@ -3155,7 +3169,7 @@ bool py_attack(int y, int x, int mode)
                /* Message */
                if (m_ptr->ml)
 #ifdef JP
-               msg_format("¶²¤¯¤Æ%s¤ò¹¶·â¤Ç¤­¤Ê¤¤¡ª", m_name);
+                       msg_format("¶²¤¯¤Æ%s¤ò¹¶·â¤Ç¤­¤Ê¤¤¡ª", m_name);
 #else
                        msg_format("You are too afraid to attack %s!", m_name);
 #endif
@@ -3167,9 +3181,13 @@ bool py_attack(int y, int x, int mode)
                        msg_format ("There is something scary in your way!");
 #endif
 
-               /* Disturb the monster */
-               m_ptr->csleep = 0;
-               if (r_ptr->flags7 & RF7_HAS_LD_MASK) p_ptr->update |= (PU_MON_LITE);
+               if (m_ptr->csleep)
+               {
+                       /* Disturb the monster */
+                       m_ptr->csleep = 0;
+                       if (!need_mproc(m_ptr)) mproc_remove(m_ptr->mproc_idx);
+                       if (r_ptr->flags7 & RF7_HAS_LD_MASK) p_ptr->update |= (PU_MON_LITE);
+               }
 
                /* Done */
                return FALSE;
@@ -3876,8 +3894,13 @@ void move_player(int dir, bool do_pickup, bool break_trap)
                    ((p_ptr->muta2 & MUT2_BERS_RAGE) && p_ptr->shero)) &&
                    pattern_seq(py, px, y, x) && (p_can_enter || p_can_kill_walls))
                {
-                       m_ptr->csleep = 0;
-                       if (r_ptr->flags7 & RF7_HAS_LD_MASK) p_ptr->update |= (PU_MON_LITE);
+                       if (m_ptr->csleep)
+                       {
+                               /* Disturb the monster */
+                               m_ptr->csleep = 0;
+                               if (!need_mproc(m_ptr)) mproc_remove(m_ptr->mproc_idx);
+                               if (r_ptr->flags7 & RF7_HAS_LD_MASK) p_ptr->update |= (PU_MON_LITE);
+                       }
 
                        /* Extract monster name (or "it") */
                        monster_desc(m_name, m_ptr, 0);
index 48d062a..386f32d 100644 (file)
@@ -2152,6 +2152,7 @@ bool do_riding(bool force)
                        char m_name[80];
                        monster_desc(m_name, m_ptr, 0);
                        m_ptr->csleep = 0;
+                       if (!need_mproc(m_ptr)) mproc_remove(m_ptr->mproc_idx);
 #ifdef JP
                        msg_format("%s¤òµ¯¤³¤·¤¿¡£", m_name);
 #else
index 9d02086..b834129 100644 (file)
 #define PF_RYOUTE       0x0040
 
 
-/* Maximum number of preservable pets */
-#define MAX_PARTY_MON 21
-
-
 /*
  * There is a 1/20 (5%) chance of inflating the requested object_level
  * during the creation of an object (see "get_obj_num()" in "object.c").
@@ -5488,3 +5484,8 @@ extern int PlayerUID;
 #define MPE_DO_PICKUP     0x00000020
 #define MPE_BREAK_TRAP    0x00000040
 #define MPE_DONT_SWAP_MON 0x00000080
+
+
+#define need_mproc(M) \
+       ((M)->invulner || (M)->fast || (M)->slow || (M)->csleep || \
+        (M)->stunned || (M)->confused || (M)->monfear)
index a841fc7..708877f 100644 (file)
@@ -1104,10 +1104,10 @@ static void regen_captured_monsters(void)
  */
 static void process_monsters_counters(void)
 {
-       int          m_idx;
+       int          m_idx, i;
        monster_type *m_ptr;
        monster_race *r_ptr;
-       bool         see_m;
+       bool         see_m, need_mproc_remove;
 
        u32b noise; /* Hack -- local "player stealth" value */
 
@@ -1118,15 +1118,15 @@ static void process_monsters_counters(void)
        noise = (1L << (30 - p_ptr->skill_stl));
 
        /* Process the monsters (backwards) */
-       for (m_idx = m_max - 1; m_idx >= 1; m_idx--)
+       for (i = mproc_max - 1; i >= 1; i--)
        {
+               m_idx = mproc_list[i];
+               need_mproc_remove = TRUE;
+
                /* Access the monster */
                m_ptr = &m_list[m_idx];
                r_ptr = &r_info[m_ptr->r_idx];
 
-               /* Ignore "dead" monsters */
-               if (!m_ptr->r_idx) continue;
-
                see_m = is_seen(m_ptr);
 
                /* Handle Invulnerability */
@@ -1158,6 +1158,7 @@ static void process_monsters_counters(void)
                                }
                                if (!p_ptr->wild_mode) m_ptr->energy_need += ENERGY_NEED();
                        }
+                       else need_mproc_remove = FALSE;
                }
 
                /* Handle fast */
@@ -1184,6 +1185,7 @@ static void process_monsters_counters(void)
                                }
                                if (p_ptr->riding == m_idx) p_ptr->update |= (PU_BONUS);
                        }
+                       else need_mproc_remove = FALSE;
                }
 
                /* Handle slow */
@@ -1210,6 +1212,7 @@ static void process_monsters_counters(void)
                                }
                                if (p_ptr->riding == m_idx) p_ptr->update |= (PU_BONUS);
                        }
+                       else need_mproc_remove = FALSE;
                }
 
                /* Handle "sleep" */
@@ -1259,6 +1262,7 @@ static void process_monsters_counters(void)
                                        {
                                                /* Monster wakes up "a little bit" */
                                                m_ptr->csleep -= d;
+                                               need_mproc_remove = FALSE;
 
                                                /* Notice the "not waking up" */
                                                if (is_original_ap_and_seen(m_ptr))
@@ -1326,6 +1330,7 @@ static void process_monsters_counters(void)
                        {
                                /* Recover somewhat */
                                m_ptr->stunned -= d;
+                               need_mproc_remove = FALSE;
                        }
 
                        /* Fully recover */
@@ -1363,6 +1368,7 @@ static void process_monsters_counters(void)
                        {
                                /* Reduce the confusion */
                                m_ptr->confused -= d;
+                               need_mproc_remove = FALSE;
                        }
 
                        /* Recovered */
@@ -1400,6 +1406,7 @@ static void process_monsters_counters(void)
                        {
                                /* Reduce the fear */
                                m_ptr->monfear -= d;
+                               need_mproc_remove = FALSE;
                        }
 
                        /* Recover from fear, take note if seen */
@@ -1436,6 +1443,8 @@ static void process_monsters_counters(void)
                                }
                        }
                }
+
+               if (need_mproc_remove) mproc_remove(i);
        }
 }
 
@@ -4325,7 +4334,7 @@ msg_print("
        if (!(turn % (TURNS_PER_TICK*3))) regen_captured_monsters();
 
        /* Hack -- Process the counters of all monsters */
-       process_monsters_counters();
+       if (mproc_max > 1) process_monsters_counters();
 
 
        /* Date changes */
@@ -5824,6 +5833,7 @@ msg_print("
        {
                monster_type *m_ptr = &m_list[p_ptr->riding];
                monster_race *r_ptr = &r_info[m_ptr->r_idx];
+               bool need_mproc_remove = FALSE;
 
                if (m_ptr->csleep)
                {
@@ -5831,6 +5841,7 @@ msg_print("
 
                        /* Recover fully */
                        m_ptr->csleep = 0;
+                       need_mproc_remove = TRUE;
 
                        if (r_ptr->flags7 & RF7_HAS_LD_MASK) p_ptr->update |= (PU_MON_LITE);
 
@@ -5869,6 +5880,7 @@ msg_print("
 
                                /* Recover fully */
                                m_ptr->stunned = 0;
+                               need_mproc_remove = TRUE;
 
                                /* Acquire the monster name */
                                monster_desc(m_name, m_ptr, 0);
@@ -5907,6 +5919,7 @@ msg_print("
 
                                /* Recover fully */
                                m_ptr->confused = 0;
+                               need_mproc_remove = TRUE;
 
                                /* Acquire the monster name */
                                monster_desc(m_name, m_ptr, 0);
@@ -5945,6 +5958,7 @@ msg_print("
 
                                /* Recover fully */
                                m_ptr->monfear = 0;
+                               need_mproc_remove = TRUE;
 
                                /* Acquire the monster name */
                                monster_desc(m_name, m_ptr, 0);
@@ -5959,6 +5973,8 @@ msg_print("
                        }
                }
 
+               if (need_mproc_remove && !need_mproc(m_ptr)) mproc_remove(m_ptr->mproc_idx);
+
                /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
                handle_stuff();
        }
index 306ea4c..f3f7ecb 100644 (file)
@@ -219,9 +219,26 @@ void reset_tim_flags(void)
 
        if (p_ptr->riding)
        {
-               m_list[p_ptr->riding].fast = 0;
-               m_list[p_ptr->riding].slow = 0;
-               m_list[p_ptr->riding].invulner = 0;
+               monster_type *m_ptr = &m_list[p_ptr->riding];
+               bool need_mproc_remove = FALSE;
+
+               if (m_ptr->fast)
+               {
+                       m_ptr->fast = 0;
+                       need_mproc_remove = TRUE;
+               }
+               if (m_ptr->slow)
+               {
+                       m_ptr->slow = 0;
+                       need_mproc_remove = TRUE;
+               }
+               if (m_ptr->invulner)
+               {
+                       m_ptr->invulner = 0;
+                       need_mproc_remove = TRUE;
+               }
+
+               if (need_mproc_remove && !need_mproc(m_ptr)) mproc_remove(m_ptr->mproc_idx);
        }
 
        if (p_ptr->pclass == CLASS_BARD)
index 41367a0..431138f 100644 (file)
@@ -444,6 +444,8 @@ extern s16b max_floor_id;
 extern u32b saved_floor_file_sign;
 extern object_type *o_list;
 extern monster_type *m_list;
+extern s16b *mproc_list;
+extern s16b mproc_max;
 extern u16b max_towns;
 extern town_type *town;
 extern object_type *inventory;
@@ -551,7 +553,6 @@ extern int pet_t_m_idx;
 extern int riding_t_m_idx;
 extern s16b kubi_r_idx[MAX_KUBI];
 extern s16b today_mon;
-extern monster_type party_mon[MAX_PARTY_MON];
 extern bool write_level;
 extern u32b playtime;
 extern u32b start_time;
@@ -894,6 +895,8 @@ extern cptr funny_comments[MAX_SAN_COMMENT];
 extern void set_target(monster_type *m_ptr, int y, int x);
 extern void reset_target(monster_type *m_ptr);
 extern monster_race *real_r_ptr(monster_type *m_ptr);
+extern void mproc_add(int m_idx);
+extern void mproc_remove(int mproc_idx);
 extern void delete_monster_idx(int i);
 extern void delete_monster(int y, int x);
 extern void compact_monsters(int size);
index 1514660..9cf93be 100644 (file)
@@ -333,6 +333,12 @@ static void build_dead_end(void)
 }
 
 
+/* Maximum number of preservable pets */
+#define MAX_PARTY_MON 21
+
+static monster_type party_mon[MAX_PARTY_MON];
+
+
 /*
  * Preserve_pets
  */
@@ -572,6 +578,9 @@ static void place_pet(void)
                        /* Hack -- Count the number of "reproducers" */
                        if (r_ptr->flags2 & RF2_MULTIPLY) num_repro++;
 
+                       if (need_mproc(m_ptr)) mproc_add(m_idx);
+                       else m_ptr->mproc_idx = 0;
+
                        /* Hack -- Notice new multi-hued monsters */
                        {
                                monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
@@ -602,8 +611,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);
 }
 
 
@@ -1217,6 +1226,8 @@ void change_floor(void)
 
                                        /* Remove confusion */
                                        m_ptr->confused = 0;
+
+                                       if (!m_ptr->csleep) mproc_remove(m_ptr->mproc_idx);
                                }
 
                                /* Extract real monster race */
index 514bd52..978f690 100644 (file)
@@ -1445,6 +1445,7 @@ void clear_cave(void)
        C_WIPE(m_list, m_max, monster_type);
        m_max = 1;
        m_cnt = 0;
+       mproc_max = 1;
 
        /* Pre-calc cur_num of pets in party_mon[] */
        precalc_cur_num_of_pet();
index b9ddc85..3b0751e 100644 (file)
@@ -1605,6 +1605,9 @@ static errr init_other(void)
        /* Allocate and Wipe the monster list */
        C_MAKE(m_list, max_m_idx, monster_type);
 
+       /* Allocate and Wipe the monster process list */
+       C_MAKE(mproc_list, max_m_idx, s16b);
+
        /* Allocate and Wipe the max dungeon level */
        C_MAKE(max_dlv, max_d_idx, s16b);
 
index 58b8b97..fc6421a 100644 (file)
@@ -2632,6 +2632,8 @@ note(format("
 
                /* Read the monster */
                rd_monster(m_ptr);
+               if (need_mproc(m_ptr)) mproc_add(m_idx);
+               else m_ptr->mproc_idx = 0;
 
 
                /* Access grid */
@@ -2903,6 +2905,8 @@ static errr rd_saved_floor(saved_floor_type *sf_ptr)
 
                /* Read the monster */
                rd_monster(m_ptr);
+               if (need_mproc(m_ptr)) mproc_add(m_idx);
+               else m_ptr->mproc_idx = 0;
 
 
                /* Access grid */
index 9e22dfe..13a4725 100644 (file)
@@ -311,6 +311,7 @@ msg_print("
        case MS_DISPEL:
        {
                monster_type *m_ptr;
+               bool need_mproc_remove = FALSE;
                char m_name[80];
 
                if (!target_set(TARGET_KILL)) return FALSE;
@@ -322,6 +323,7 @@ msg_print("
                if (m_ptr->invulner)
                {
                        m_ptr->invulner = 0;
+                       need_mproc_remove = TRUE;
                        if (m_ptr->ml)
                        {
 #ifdef JP
@@ -337,6 +339,7 @@ msg_print("
                if (m_ptr->fast)
                {
                        m_ptr->fast = 0;
+                       need_mproc_remove = TRUE;
 #ifdef JP
                        if (m_ptr->ml) msg_format("%s¤Ï¤â¤¦²Ã®¤µ¤ì¤Æ¤¤¤Ê¤¤¡£", m_name);
 #else
@@ -346,6 +349,7 @@ msg_print("
                if (m_ptr->slow)
                {
                        m_ptr->slow = 0;
+                       need_mproc_remove = TRUE;
 #ifdef JP
                        if (m_ptr->ml) msg_format("%s¤Ï¤â¤¦¸ºÂ®¤µ¤ì¤Æ¤¤¤Ê¤¤¡£", m_name);
 #else
@@ -353,6 +357,7 @@ msg_print("
 #endif
                }
 
+               if (need_mproc_remove && !need_mproc(m_ptr)) mproc_remove(m_ptr->mproc_idx);
                break;
        }
        case MS_ROCKET:
index 14fe9b7..a825d03 100644 (file)
@@ -209,10 +209,13 @@ void mon_take_hit_mon(int m_idx, int dam, bool *fear, cptr note, int who)
                if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
        }
 
-       /* Wake it up */
-       m_ptr->csleep = 0;
-
-       if (r_ptr->flags7 & RF7_HAS_LD_MASK) p_ptr->update |= (PU_MON_LITE);
+       if (m_ptr->csleep)
+       {
+               /* Wake it up */
+               m_ptr->csleep = 0;
+               if (!need_mproc(m_ptr)) mproc_remove(m_ptr->mproc_idx);
+               if (r_ptr->flags7 & RF7_HAS_LD_MASK) p_ptr->update |= (PU_MON_LITE);
+       }
 
        if (p_ptr->riding && (m_idx == p_ptr->riding)) disturb(1, 0);
 
@@ -352,6 +355,7 @@ msg_format("%^s
                {
                        /* Cure fear */
                        m_ptr->monfear = 0;
+                       if (!need_mproc(m_ptr)) mproc_remove(m_ptr->mproc_idx);
 
                        /* No more fear */
                        (*fear) = FALSE;
@@ -376,6 +380,8 @@ msg_format("%^s
                        /* Hack -- note fear */
                        (*fear) = TRUE;
 
+                       if (!m_ptr->mproc_idx) mproc_add(m_idx);
+
                        /* XXX XXX XXX Hack -- Add some timed fear */
                        m_ptr->monfear += (randint1(10) +
                                (((dam >= m_ptr->hp) && (percentage > 7)) ?
@@ -1521,10 +1527,14 @@ static bool monst_attack_monst(int m_idx, int t_idx)
                /* Monster hits */
                if (!effect || check_hit2(power, rlev, ac, m_ptr->stunned))
                {
-                       /* Wake it up */
-                       t_ptr->csleep = 0;
+                       if (t_ptr->csleep)
+                       {
+                               /* Wake it up */
+                               t_ptr->csleep = 0;
+                               if (!need_mproc(t_ptr)) mproc_remove(t_ptr->mproc_idx);
+                               if (tr_ptr->flags7 & RF7_HAS_LD_MASK) p_ptr->update |= (PU_MON_LITE);
+                       }
 
-                       if (tr_ptr->flags7 & RF7_HAS_LD_MASK) p_ptr->update |= (PU_MON_LITE);
                        if (t_ptr->ml)
                        {
                                /* Redraw the health bar */
@@ -2138,15 +2148,19 @@ msg_format("%s
                        case RBM_ENGULF:
                        case RBM_CHARGE:
                                {
-                                       /* Wake it up */
-                                       t_ptr->csleep = 0;
-
-                                       if (tr_ptr->flags7 & RF7_HAS_LD_MASK) p_ptr->update |= (PU_MON_LITE);
-                                       if (t_ptr->ml)
+                                       if (t_ptr->csleep)
                                        {
-                                               /* Redraw the health bar */
-                                               if (p_ptr->health_who == t_idx) p_ptr->redraw |= (PR_HEALTH);
-                                               if (p_ptr->riding == t_idx) p_ptr->redraw |= (PR_UHEALTH);
+                                               /* Wake it up */
+                                               t_ptr->csleep = 0;
+                                               if (!need_mproc(t_ptr)) mproc_remove(t_ptr->mproc_idx);
+                                               if (tr_ptr->flags7 & RF7_HAS_LD_MASK) p_ptr->update |= (PU_MON_LITE);
+
+                                               if (t_ptr->ml)
+                                               {
+                                                       /* Redraw the health bar */
+                                                       if (p_ptr->health_who == t_idx) p_ptr->redraw |= (PR_HEALTH);
+                                                       if (p_ptr->riding == t_idx) p_ptr->redraw |= (PR_UHEALTH);
+                                               }
                                        }
 
                                        /* Visible monsters */
@@ -2187,7 +2201,11 @@ msg_format("%s
                sound(SOUND_EXPLODE);
 
                /* Cancel Invulnerability */
-               if (m_ptr->invulner) m_ptr->invulner = 0;
+               if (m_ptr->invulner)
+               {
+                       m_ptr->invulner = 0;
+                       if (!need_mproc(m_ptr)) mproc_remove(m_ptr->mproc_idx);
+               }
 
 #ifdef JP
                mon_take_hit_mon(m_idx, m_ptr->hp + 1, &fear, "¤ÏÇúȯ¤·¤ÆÊ´¡¹¤Ë¤Ê¤Ã¤¿¡£", m_idx);
@@ -2486,7 +2504,7 @@ static void process_monster(int m_idx)
 
                /* Reset sleep counter */
                m_ptr->csleep = 0;
-
+               if (!need_mproc(m_ptr)) mproc_remove(m_ptr->mproc_idx);
                if (r_ptr->flags7 & RF7_HAS_LD_MASK) p_ptr->update |= (PU_MON_LITE);
 
                /* Notice the "waking up" */
@@ -3216,16 +3234,18 @@ msg_format("%^s%s", m_name, monmessage);
                                /* Monster pushed past another monster */
                                did_move_body = TRUE;
 
-                               /* Wake up the moved monster */
-                               y_ptr->csleep = 0;
-
-                               if (r_info[y_ptr->r_idx].flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
-                                       p_ptr->update |= (PU_MON_LITE);
-
-                               if (y_ptr->ml)
+                               if (y_ptr->csleep)
                                {
-                                       /* Redraw the health bar */
-                                       if (p_ptr->health_who == c_ptr->m_idx) p_ptr->redraw |= (PR_HEALTH);
+                                       /* Wake up the moved monster */
+                                       y_ptr->csleep = 0;
+                                       if (!need_mproc(y_ptr)) mproc_remove(y_ptr->mproc_idx);
+                                       if (z_ptr->flags7 & (RF7_LITE_MASK | RF7_DARK_MASK)) p_ptr->update |= (PU_MON_LITE);
+
+                                       if (y_ptr->ml)
+                                       {
+                                               /* Redraw the health bar */
+                                               if (p_ptr->health_who == c_ptr->m_idx) p_ptr->redraw |= (PR_HEALTH);
+                                       }
                                }
 
                                /* XXX XXX XXX Message */
@@ -3559,6 +3579,7 @@ msg_format("%^s%s", m_name, monmessage);
        {
                /* No longer afraid */
                m_ptr->monfear = 0;
+               if (!need_mproc(m_ptr)) mproc_remove(m_ptr->mproc_idx);
 
                /* Message if seen */
                if (see_m)
index 546516d..413530c 100644 (file)
@@ -1167,6 +1167,7 @@ static bool cast_force_spell(int spell)
        case 9:
        {
                monster_type *m_ptr;
+               bool need_mproc_remove = FALSE;
                char m_name[80];
 
                if (!target_set(TARGET_KILL)) return FALSE;
@@ -1178,6 +1179,7 @@ static bool cast_force_spell(int spell)
                if (m_ptr->invulner)
                {
                        m_ptr->invulner = 0;
+                       need_mproc_remove = TRUE;
                        if (m_ptr->ml)
                        {
 #ifdef JP
@@ -1193,6 +1195,7 @@ static bool cast_force_spell(int spell)
                if (m_ptr->fast)
                {
                        m_ptr->fast = 0;
+                       need_mproc_remove = TRUE;
 #ifdef JP
                        if (m_ptr->ml) msg_format("%s¤Ï¤â¤¦²Ã®¤µ¤ì¤Æ¤¤¤Ê¤¤¡£", m_name);
 #else
@@ -1202,6 +1205,7 @@ static bool cast_force_spell(int spell)
                if (m_ptr->slow)
                {
                        m_ptr->slow = 0;
+                       need_mproc_remove = TRUE;
 #ifdef JP
                        if (m_ptr->ml) msg_format("%s¤Ï¤â¤¦¸ºÂ®¤µ¤ì¤Æ¤¤¤Ê¤¤¡£", m_name);
 #else
@@ -1209,6 +1213,7 @@ static bool cast_force_spell(int spell)
 #endif
                }
 
+               if (need_mproc_remove && !need_mproc(m_ptr)) mproc_remove(m_ptr->mproc_idx);
                break;
        }
        case 10:
@@ -1736,8 +1741,12 @@ msg_print("
                m_ptr->fy = ty;
                m_ptr->fx = tx;
 
-               /* Wake the monster up */
-               m_ptr->csleep = 0;
+               if (m_ptr->csleep)
+               {
+                       /* Wake the monster up */
+                       m_ptr->csleep = 0;
+                       if (!need_mproc(m_ptr)) mproc_remove(m_ptr->mproc_idx);
+               }
 
                /* Update the monster (new location) */
                update_mon(m_idx, TRUE);
index 1542f1a..8ebf0be 100644 (file)
@@ -190,6 +190,20 @@ monster_race *real_r_ptr(monster_type *m_ptr)
 }
 
 
+void mproc_add(int m_idx)
+{
+       m_list[m_idx].mproc_idx = mproc_max;
+       mproc_list[mproc_max++] = m_idx;
+}
+
+
+void mproc_remove(int mproc_idx)
+{
+       m_list[mproc_list[mproc_idx]].mproc_idx = 0;
+       mproc_list[mproc_idx] = mproc_list[--mproc_max];
+}
+
+
 /*
  * Delete a monster by index.
  *
@@ -217,6 +231,8 @@ void delete_monster_idx(int i)
        /* Hack -- count the number of "reproducers" */
        if (r_ptr->flags2 & (RF2_MULTIPLY)) num_repro--;
 
+       if (m_ptr->mproc_idx) mproc_remove(m_ptr->mproc_idx);
+
 
        /* Hack -- remove target monster */
        if (i == target_who) target_who = 0;
@@ -363,6 +379,7 @@ static void compact_monsters_aux(int i1, int i2)
        /* Wipe the hole */
        (void)WIPE(&m_list[i1], monster_type);
 
+       if (m_list[i2].mproc_idx) mproc_list[m_list[i2].mproc_idx] = i2;
 }
 
 
@@ -502,7 +519,7 @@ void wipe_m_list(void)
 
        /*
         * Wiping racial counters of all monsters and incrementing of racial
-        * counters of monsters in party_mon[] is required to prevent multiple
+        * counters of monsters in party_mon[] are required to prevent multiple
         * generation of unique monster who is the minion of player.
         */
 
@@ -515,6 +532,9 @@ void wipe_m_list(void)
        /* Reset "m_cnt" */
        m_cnt = 0;
 
+       /* Reset "mproc_max" */
+       mproc_max = 1;
+
        /* Hack -- reset "reproducer" count */
        num_repro = 0;
 
@@ -3270,6 +3290,8 @@ msg_print("
        /* Hack -- Count the number of "reproducers" */
        if (r_ptr->flags2 & RF2_MULTIPLY) num_repro++;
 
+       if (need_mproc(m_ptr)) mproc_add(c_ptr->m_idx);
+       else m_ptr->mproc_idx = 0;
 
        /* Hack -- Notice new multi-hued monsters */
        {
index 545571e..e6baea0 100644 (file)
@@ -1753,16 +1753,28 @@ msg_format("%^s
                        if (p_ptr->riding)
                        {
                                monster_type *riding_ptr = &m_list[p_ptr->riding];
+                               bool need_mproc_remove = FALSE;
+
                                if (riding_ptr->invulner)
                                {
                                        riding_ptr->invulner = 0;
+                                       need_mproc_remove = TRUE;
                                        riding_ptr->energy_need += ENERGY_NEED();
                                }
-                               riding_ptr->fast = 0;
-                               riding_ptr->slow = 0;
+                               if (riding_ptr->fast)
+                               {
+                                       riding_ptr->fast = 0;
+                                       need_mproc_remove = TRUE;
+                               }
+                               if (riding_ptr->slow)
+                               {
+                                       riding_ptr->slow = 0;
+                                       need_mproc_remove = TRUE;
+                               }
                                p_ptr->update |= PU_BONUS;
                                if (p_ptr->health_who == p_ptr->riding) p_ptr->redraw |= PR_HEALTH;
                                p_ptr->redraw |= (PR_UHEALTH);
+                               if (need_mproc_remove && !need_mproc(riding_ptr)) mproc_remove(riding_ptr->mproc_idx);
                        }
 
 #ifdef JP
@@ -3256,6 +3268,7 @@ msg_format("%^s
 #else
                                msg_format("%^s starts moving faster.", m_name);
 #endif
+                               if (!m_ptr->mproc_idx) mproc_add(m_idx);
                        }
                        m_ptr->fast = MIN(200, m_ptr->fast + 100);
                        if (p_ptr->riding == m_idx) p_ptr->update |= PU_BONUS;
@@ -3365,6 +3378,7 @@ msg_format("%^s
                        {
                                /* Cancel fear */
                                m_ptr->monfear = 0;
+                               if (!need_mproc(m_ptr)) mproc_remove(m_ptr->mproc_idx);
 
                                /* Message */
 #ifdef JP
@@ -3402,8 +3416,11 @@ msg_format("%s
 
                        }
 
-                       if (!(m_ptr->invulner))
+                       if (!m_ptr->invulner)
+                       {
+                               if (!m_ptr->mproc_idx) mproc_add(m_idx);
                                m_ptr->invulner = randint1(4) + 4;
+                       }
 
                        if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
                        if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
index 002ac22..3dfbb24 100644 (file)
@@ -2670,7 +2670,11 @@ bool monst_spell_monst(int m_idx)
                }
                else
                {
-                       if (!t_ptr->monfear) fear = TRUE;
+                       if (!t_ptr->monfear)
+                       {
+                               if (!t_ptr->mproc_idx) mproc_add(t_idx);
+                               fear = TRUE;
+                       }
 
                        t_ptr->monfear += randint0(4) + 4;
                }
@@ -2727,6 +2731,7 @@ bool monst_spell_monst(int m_idx)
 #endif
 
 
+                       if (!t_ptr->mproc_idx) mproc_add(t_idx);
                        t_ptr->confused += 12 + (byte)randint0(4);
                }
 
@@ -2780,6 +2785,7 @@ bool monst_spell_monst(int m_idx)
 #endif
 
 
+                       if (!t_ptr->mproc_idx) mproc_add(t_idx);
                        t_ptr->confused += 12 + (byte)randint0(4);
                }
 
@@ -2834,6 +2840,7 @@ bool monst_spell_monst(int m_idx)
 #else
                                if (see_t) msg_format("%^s starts moving slower.", t_name);
 #endif
+                               if (!t_ptr->mproc_idx) mproc_add(t_idx);
                        }
 
                        t_ptr->slow = MIN(200, t_ptr->slow + 50);
@@ -2891,6 +2898,7 @@ bool monst_spell_monst(int m_idx)
 #endif
 
 
+                       if (!t_ptr->mproc_idx) mproc_add(t_idx);
                        t_ptr->stunned += randint1(4) + 4;
                }
 
@@ -2926,7 +2934,7 @@ bool monst_spell_monst(int m_idx)
 #else
                        if (see_m) msg_format("%^s starts moving faster.", m_name);
 #endif
-
+                       if (!m_ptr->mproc_idx) mproc_add(m_idx);
                }
                m_ptr->fast = MIN(200, m_ptr->fast + 100);
                if (p_ptr->riding == m_idx) p_ptr->update |= PU_BONUS;
@@ -3029,6 +3037,7 @@ bool monst_spell_monst(int m_idx)
                {
                        /* Cancel fear */
                        m_ptr->monfear = 0;
+                       if (!need_mproc(m_ptr)) mproc_remove(m_ptr->mproc_idx);
 
                        /* Message */
 #ifdef JP
@@ -3061,7 +3070,11 @@ bool monst_spell_monst(int m_idx)
                        }
                }
 
-               if (!m_ptr->invulner) m_ptr->invulner = randint1(4) + 4;
+               if (!m_ptr->invulner)
+               {
+                       if (!m_ptr->mproc_idx) mproc_add(m_idx);
+                       m_ptr->invulner = randint1(4) + 4;
+               }
 
                if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
                if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
@@ -4200,9 +4213,10 @@ bool monst_spell_monst(int m_idx)
                break;
        }
 
-       if (wake_up)
+       if (wake_up && t_ptr->csleep)
        {
                t_ptr->csleep = 0;
+               if (!need_mproc(t_ptr)) mproc_remove(t_ptr->mproc_idx);
                if (tr_ptr->flags7 & RF7_HAS_LD_MASK) p_ptr->update |= (PU_MON_LITE);
                if (t_ptr->ml)
                {
index a5b4b76..d70d506 100644 (file)
@@ -725,6 +725,7 @@ msg_print("
        case MS_DISPEL:
        {
                monster_type *m_ptr;
+               bool need_mproc_remove = FALSE;
                char m_name[80];
 
                if (!target_set(TARGET_KILL)) return FALSE;
@@ -736,6 +737,7 @@ msg_print("
                if (m_ptr->invulner)
                {
                        m_ptr->invulner = 0;
+                       need_mproc_remove = TRUE;
                        if (m_ptr->ml)
                        {
 #ifdef JP
@@ -751,6 +753,7 @@ msg_print("
                if (m_ptr->fast)
                {
                        m_ptr->fast = 0;
+                       need_mproc_remove = TRUE;
 #ifdef JP
                        if (m_ptr->ml) msg_format("%s¤Ï¤â¤¦²Ã®¤µ¤ì¤Æ¤¤¤Ê¤¤¡£", m_name);
 #else
@@ -760,6 +763,7 @@ msg_print("
                if (m_ptr->slow)
                {
                        m_ptr->slow = 0;
+                       need_mproc_remove = TRUE;
 #ifdef JP
                        if (m_ptr->ml) msg_format("%s¤Ï¤â¤¦¸ºÂ®¤µ¤ì¤Æ¤¤¤Ê¤¤¡£", m_name);
 #else
@@ -767,6 +771,7 @@ msg_print("
 #endif
                }
 
+               if (need_mproc_remove && !need_mproc(m_ptr)) mproc_remove(m_ptr->mproc_idx);
                break;
        }
        case MS_ROCKET:
index b436cd3..4a94b2f 100644 (file)
@@ -1695,6 +1695,7 @@ static bool project_m(int who, int r, int y, int x, int dam, int typ , int flg)
        int do_time = 0;
 
        bool heal_leper = FALSE;
+       bool need_mproc_remove = FALSE;
 
        /* Hold the monster name */
        char m_name[80];
@@ -2501,6 +2502,7 @@ note = "
 #else
                                                note = " starts moving slower.";
 #endif
+                                               if (!m_ptr->mproc_idx) mproc_add(c_ptr->m_idx);
                                        }
                                        m_ptr->slow = MIN(200, m_ptr->slow + 50);
                                        if (c_ptr->m_idx == p_ptr->riding)
@@ -2620,6 +2622,7 @@ note = "
 #else
                                                note = " starts moving slower.";
 #endif
+                                               if (!m_ptr->mproc_idx) mproc_add(c_ptr->m_idx);
                                        }
                                        m_ptr->slow = MIN(200, m_ptr->slow + 50);
                                        if (c_ptr->m_idx == p_ptr->riding)
@@ -3379,10 +3382,14 @@ note = "
                {
                        if (seen) obvious = TRUE;
 
-                       /* Wake up */
-                       m_ptr->csleep = 0;
+                       if (m_ptr->csleep)
+                       {
+                               /* Wake up */
+                               m_ptr->csleep = 0;
+                               need_mproc_remove = TRUE;
 
-                       if (r_ptr->flags7 & RF7_HAS_LD_MASK) p_ptr->update |= (PU_MON_LITE);
+                               if (r_ptr->flags7 & RF7_HAS_LD_MASK) p_ptr->update |= (PU_MON_LITE);
+                       }
 
                        if (m_ptr->maxhp < m_ptr->max_maxhp)
                        {
@@ -3396,6 +3403,8 @@ note = "
 
                        if (!dam)
                        {
+                               if (need_mproc_remove && !need_mproc(m_ptr)) mproc_remove(m_ptr->mproc_idx);
+
                                /* Redraw (later) if needed */
                                if (p_ptr->health_who == c_ptr->m_idx) p_ptr->redraw |= (PR_HEALTH);
                                if (p_ptr->riding == c_ptr->m_idx) p_ptr->redraw |= (PR_UHEALTH);
@@ -3408,11 +3417,14 @@ note = "
                {
                        if (seen) obvious = TRUE;
 
-                       /* Wake up */
-                       m_ptr->csleep = 0;
-
-                       if (r_ptr->flags7 & RF7_HAS_LD_MASK) p_ptr->update |= (PU_MON_LITE);
+                       if (m_ptr->csleep)
+                       {
+                               /* Wake up */
+                               m_ptr->csleep = 0;
+                               need_mproc_remove = TRUE;
 
+                               if (r_ptr->flags7 & RF7_HAS_LD_MASK) p_ptr->update |= (PU_MON_LITE);
+                       }
                        if (m_ptr->stunned)
                        {
 #ifdef JP
@@ -3421,6 +3433,7 @@ note = "
                                if (seen_msg) msg_format("%^s is no longer stunned.", m_name);
 #endif
                                m_ptr->stunned = 0;
+                               need_mproc_remove = TRUE;
                        }
                        if (m_ptr->confused)
                        {
@@ -3430,6 +3443,7 @@ note = "
                                if (seen_msg) msg_format("%^s is no longer confused.", m_name);
 #endif
                                m_ptr->confused = 0;
+                               need_mproc_remove = TRUE;
                        }
                        if (m_ptr->monfear)
                        {
@@ -3439,6 +3453,7 @@ note = "
                                if (seen_msg) msg_format("%^s recovers %s courage.", m_name, m_poss);
 #endif
                                m_ptr->monfear = 0;
+                               need_mproc_remove = TRUE;
                        }
 
                        /* Heal */
@@ -3474,6 +3489,8 @@ note = "
                                if (!who) chg_virtue(V_COMPASSION, 5);
                        }
 
+                       if (need_mproc_remove && !need_mproc(m_ptr)) mproc_remove(m_ptr->mproc_idx);
+
                        /* Redraw (later) if needed */
                        if (p_ptr->health_who == c_ptr->m_idx) p_ptr->redraw |= (PR_HEALTH);
                        if (p_ptr->riding == c_ptr->m_idx) p_ptr->redraw |= (PR_UHEALTH);
@@ -3504,6 +3521,7 @@ note = "
 #else
                                note = " starts moving faster.";
 #endif
+                               if (!m_ptr->mproc_idx) mproc_add(c_ptr->m_idx);
                        }
                        m_ptr->fast = MIN(200, m_ptr->fast + 100);
 
@@ -3563,6 +3581,7 @@ note = "
 #else
                                        note = " starts moving slower.";
 #endif
+                                       if (!m_ptr->mproc_idx) mproc_add(c_ptr->m_idx);
                                }
                                m_ptr->slow = MIN(200, m_ptr->slow + 50);
 
@@ -5125,6 +5144,7 @@ note_dies = "
                                        do_conf = randint0(8) + 8;
                                        do_stun = randint0(8) + 8;
                                }
+                               if (!m_ptr->mproc_idx) mproc_add(c_ptr->m_idx);
                                m_ptr->slow = MIN(200, m_ptr->slow + 10);
                                if (c_ptr->m_idx == p_ptr->riding)
                                        p_ptr->update |= (PU_BONUS);
@@ -5332,7 +5352,7 @@ note_dies = "
                            (r_ptr->flags1 & (RF1_UNIQUE)) || (r_ptr->flags7 & (RF7_NAZGUL)) || (r_ptr->flags7 & (RF7_UNIQUE2)) || (r_ptr->flags1 & RF1_QUESTOR) || m_ptr->parent_m_idx)
                        {
 #ifdef JP
-msg_format("%s¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡£",m_name);
+                               msg_format("%s¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡£",m_name);
 #else
                                msg_format("%^s is unaffected.", m_name);
 #endif
@@ -5340,7 +5360,7 @@ msg_format("%s
                                break;
                        }
 
-                       if (is_pet(m_ptr)) nokori_hp = m_ptr->maxhp*4L;
+                       if (is_pet(m_ptr)) nokori_hp = m_ptr->maxhp * 4L;
                        else if ((p_ptr->pclass == CLASS_BEASTMASTER) && monster_living(r_ptr))
                                nokori_hp = m_ptr->maxhp * 3 / 10;
                        else
@@ -5349,7 +5369,7 @@ msg_format("%s
                        if (m_ptr->hp >= nokori_hp)
                        {
 #ifdef JP
-msg_format("¤â¤Ã¤È¼å¤é¤»¤Ê¤¤¤È¡£");
+                               msg_format("¤â¤Ã¤È¼å¤é¤»¤Ê¤¤¤È¡£");
 #else
                                msg_format("You need to weaken %s more.", m_name);
 #endif
@@ -5359,24 +5379,21 @@ msg_format("
                        {
                                if (m_ptr->mflag2 & MFLAG2_CHAMELEON) choose_new_monster(c_ptr->m_idx, FALSE, MON_CHAMELEON);
 #ifdef JP
-msg_format("%s¤òÊᤨ¤¿¡ª",m_name);
+                               msg_format("%s¤òÊᤨ¤¿¡ª",m_name);
 #else
                                msg_format("You capture %^s!", m_name);
 #endif
-                               cap_mon = m_list[c_ptr->m_idx].r_idx;
-                               cap_mspeed = m_list[c_ptr->m_idx].mspeed;
-                               cap_hp = m_list[c_ptr->m_idx].hp;
-                               cap_maxhp = m_list[c_ptr->m_idx].max_maxhp;
-                               if (m_list[c_ptr->m_idx].nickname)
-                                       cap_nickname = quark_add(quark_str(m_list[c_ptr->m_idx].nickname));
-                               else
-                                       cap_nickname = 0;
+                               cap_mon = m_ptr->r_idx;
+                               cap_mspeed = m_ptr->mspeed;
+                               cap_hp = m_ptr->hp;
+                               cap_maxhp = m_ptr->max_maxhp;
+                               cap_nickname = m_ptr->nickname; /* Quark transfer */
                                if (c_ptr->m_idx == p_ptr->riding)
                                {
                                        if (rakuba(-1, FALSE))
                                        {
 #ifdef JP
-msg_print("ÃÏÌ̤ËÍî¤È¤µ¤ì¤¿¡£");
+                                               msg_print("ÃÏÌ̤ËÍî¤È¤µ¤ì¤¿¡£");
 #else
                                                msg_format("You have fallen from %s.", m_name);
 #endif
@@ -5479,6 +5496,7 @@ note = "
 #else
                                                note = " starts moving slower.";
 #endif
+                                               if (!m_ptr->mproc_idx) mproc_add(c_ptr->m_idx);
                                        }
                                        m_ptr->slow = MIN(200, m_ptr->slow + 50);
 
@@ -5671,7 +5689,10 @@ note = "
                                        note = " starts moving faster.";
 #endif
 
+                                       if (!m_ptr->mproc_idx) mproc_add(c_ptr->m_idx);
                                        m_ptr->fast = MIN(200, m_ptr->fast + 100);
+
+                                       if (c_ptr->m_idx == p_ptr->riding) p_ptr->update |= (PU_BONUS);
                                        success = TRUE;
                                }
 
@@ -5694,6 +5715,7 @@ note = "
 #endif
 
                                        set_pet(m_ptr);
+                                       if (!m_ptr->mproc_idx) mproc_add(c_ptr->m_idx);
                                        m_ptr->fast = MIN(200, m_ptr->fast + 100);
 
                                        /* Learn about type */
@@ -5800,6 +5822,8 @@ note = "
        }
        else
        {
+               bool need_mproc_add = FALSE;
+
                /* Sound and Impact resisters never stun */
                if (do_stun &&
                    !(r_ptr->flagsr & (RFR_RES_SOUN | RFR_RES_WALL)) &&
@@ -5828,6 +5852,7 @@ note = "
 #endif
 
                                tmp = do_stun;
+                               need_mproc_add = TRUE;
                        }
 
                        /* Apply stun */
@@ -5867,6 +5892,7 @@ note = "
 #endif
 
                                tmp = do_conf;
+                               need_mproc_add = TRUE;
                        }
 
                        /* Apply confusion */
@@ -5899,6 +5925,12 @@ note = "
                /* Mega-Hack -- Handle "polymorph" -- monsters get a saving throw */
                if (do_poly && (randint1(90) > r_ptr->level))
                {
+                       if (need_mproc_add)
+                       {
+                               if (!m_ptr->mproc_idx) mproc_add(c_ptr->m_idx);
+                               need_mproc_add = FALSE;
+                       }
+
                        if (polymorph_monster(y, x))
                        {
                                /* Obvious */
@@ -5913,12 +5945,6 @@ note = "
 
                                /* Turn off the damage */
                                dam = 0;
-
-                               /* Hack -- Get new monster */
-                               m_ptr = &m_list[c_ptr->m_idx];
-
-                               /* Hack -- Get new race */
-                               r_ptr = &r_info[m_ptr->r_idx];
                        }
                        else
                        {
@@ -5929,6 +5955,12 @@ note = "
                                note = " is unaffected!";
 #endif
                        }
+
+                       /* Hack -- Get new monster */
+                       m_ptr = &m_list[c_ptr->m_idx];
+
+                       /* Hack -- Get new race */
+                       r_ptr = &r_info[m_ptr->r_idx];
                }
 
                /* Handle "teleport" */
@@ -5963,12 +5995,16 @@ note = "
                        /* Increase fear */
                        tmp = m_ptr->monfear + do_fear;
 
+                       if (!m_ptr->monfear) need_mproc_add = TRUE;
+
                        /* Set fear */
                        m_ptr->monfear = (tmp < 200) ? tmp : 200;
 
                        /* Get angry */
                        get_angry = TRUE;
                }
+
+               if (need_mproc_add && !m_ptr->mproc_idx) mproc_add(c_ptr->m_idx);
        }
 
        if (typ == GF_DRAIN_MANA)
@@ -5983,10 +6019,13 @@ note = "
                if (p_ptr->health_who == c_ptr->m_idx) p_ptr->redraw |= (PR_HEALTH);
                if (p_ptr->riding == c_ptr->m_idx) p_ptr->redraw |= (PR_UHEALTH);
 
-               /* Wake the monster up */
-               m_ptr->csleep = 0;
-
-               if (r_ptr->flags7 & RF7_HAS_LD_MASK) p_ptr->update |= (PU_MON_LITE);
+               if (m_ptr->csleep)
+               {
+                       /* Wake the monster up */
+                       m_ptr->csleep = 0;
+                       if (!need_mproc(m_ptr)) mproc_remove(m_ptr->mproc_idx);
+                       if (r_ptr->flags7 & RF7_HAS_LD_MASK) p_ptr->update |= (PU_MON_LITE);
+               }
 
                /* Hurt the monster */
                m_ptr->hp -= dam;
@@ -6049,7 +6088,11 @@ msg_print("
                        }
 
                        /* Hack -- handle sleep */
-                       if (do_sleep) m_ptr->csleep = do_sleep;
+                       if (do_sleep)
+                       {
+                               if (!m_ptr->mproc_idx) mproc_add(c_ptr->m_idx);
+                               m_ptr->csleep = do_sleep;
+                       }
                }
        }
 
@@ -6115,7 +6158,11 @@ msg_print("
                        }
 
                        /* Hack -- handle sleep */
-                       if (do_sleep) m_ptr->csleep = do_sleep;
+                       if (do_sleep)
+                       {
+                               if (!m_ptr->mproc_idx) mproc_add(c_ptr->m_idx);
+                               m_ptr->csleep = do_sleep;
+                       }
                }
        }
 
index 884abbf..215a7e9 100644 (file)
@@ -4609,6 +4609,7 @@ void aggravate_monsters(int who)
                        {
                                /* Wake up */
                                m_ptr->csleep = 0;
+                               if (!need_mproc(m_ptr)) mproc_remove(m_ptr->mproc_idx);
                                if (r_info[m_ptr->r_idx].flags7 & RF7_HAS_LD_MASK) p_ptr->update |= (PU_MON_LITE);
                                if (m_ptr->ml)
                                {
@@ -4626,6 +4627,7 @@ void aggravate_monsters(int who)
                {
                        if (!is_pet(m_ptr))
                        {
+                               if (!m_ptr->mproc_idx) mproc_add(i);
                                m_ptr->fast = MIN(200, m_ptr->fast + 100);
                                speed = TRUE;
                        }
@@ -4687,6 +4689,7 @@ bool genocide_aux(int m_idx, int power, bool player_cast, int dam_side, cptr spe
                if (m_ptr->csleep)
                {
                        m_ptr->csleep = 0;
+                       if (!need_mproc(m_ptr)) mproc_remove(m_ptr->mproc_idx);
                        if (r_ptr->flags7 & RF7_HAS_LD_MASK) p_ptr->update |= (PU_MON_LITE);
                        if (m_ptr->ml)
                        {
@@ -5663,7 +5666,11 @@ msg_format("%^s
                                        damage = (sn ? damroll(4, 8) : (m_ptr->hp + 1));
 
                                        /* Monster is certainly awake */
-                                       m_ptr->csleep = 0;
+                                       if (m_ptr->csleep)
+                                       {
+                                               m_ptr->csleep = 0;
+                                               if (!need_mproc(m_ptr)) mproc_remove(m_ptr->mproc_idx);
+                                       }
 
                                        /* Apply damage directly */
                                        m_ptr->hp -= damage;
@@ -5966,7 +5973,7 @@ static void cave_temp_room_lite(void)
                        {
                                /* Wake up! */
                                m_ptr->csleep = 0;
-
+                               if (!need_mproc(m_ptr)) mproc_remove(m_ptr->mproc_idx);
                                if (r_ptr->flags7 & RF7_HAS_LD_MASK) p_ptr->update |= (PU_MON_LITE);
 
                                /* Notice the "waking up" */
@@ -6616,8 +6623,12 @@ msg_print("
 
                if (is_original_ap_and_seen(m_ptr)) r_ptr->r_flagsr |= RFR_RES_TELE;
 
-               m_ptr->csleep = 0;
-               if (r_ptr->flags7 & RF7_HAS_LD_MASK) p_ptr->update |= (PU_MON_LITE);
+               if (m_ptr->csleep)
+               {
+                       m_ptr->csleep = 0;
+                       if (!need_mproc(m_ptr)) mproc_remove(m_ptr->mproc_idx);
+                       if (r_ptr->flags7 & RF7_HAS_LD_MASK) p_ptr->update |= (PU_MON_LITE);
+               }
 
                /* Failure */
                return FALSE;
index 142361d..f53ffa8 100644 (file)
@@ -1508,6 +1508,7 @@ static bool vanish_dungeon(void)
                        {
                                /* Reset sleep counter */
                                m_ptr->csleep = 0;
+                               if (!need_mproc(m_ptr)) mproc_remove(m_ptr->mproc_idx);
 
                                /* Notice the "waking up" */
                                if (is_seen(m_ptr))
@@ -5364,7 +5365,11 @@ bool polymorph_monster(int y, int x)
                {
                        /* Placing the new monster failed */
                        if (place_monster_aux(0, y, x, old_r_idx, (mode | PM_NO_KAGE | PM_IGNORE_TERRAIN)))
+                       {
                                m_list[hack_m_idx_ii] = back_m;
+                               if (need_mproc(&back_m)) mproc_add(hack_m_idx_ii);
+                               else m_list[hack_m_idx_ii].mproc_idx = 0;
+                       }
                }
 
                if (targeted) target_who = hack_m_idx_ii;
index 84272a8..4085ae0 100644 (file)
@@ -615,6 +615,8 @@ struct monster_type
        u32b smart;                     /* Field for "smart_learn" */
 
        s16b parent_m_idx;
+
+       s16b mproc_idx;
 };
 
 
index d04bc72..c31db65 100644 (file)
@@ -686,6 +686,12 @@ object_type *o_list;
  */
 monster_type *m_list;
 
+/*
+ * The array to process dungeon monsters [max_m_idx]
+ */
+s16b *mproc_list;
+s16b mproc_max = 1; /* Number of monsters to be processed */
+
 
 /*
  * Maximum number of towns
@@ -1164,8 +1170,6 @@ int riding_t_m_idx;
 s16b kubi_r_idx[MAX_KUBI];
 s16b today_mon;
 
-monster_type party_mon[MAX_PARTY_MON];
-
 bool write_level;
 
 u32b playtime;
index fd19f3c..2dcce4f 100644 (file)
@@ -1714,10 +1714,13 @@ bool mon_take_hit(int m_idx, int dam, bool *fear, cptr note)
        if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
        if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
 
-       /* Wake it up */
-       m_ptr->csleep = 0;
-
-       if (r_ptr->flags7 & RF7_HAS_LD_MASK) p_ptr->update |= (PU_MON_LITE);
+       if (m_ptr->csleep)
+       {
+               /* Wake it up */
+               m_ptr->csleep = 0;
+               if (!need_mproc(m_ptr)) mproc_remove(m_ptr->mproc_idx);
+               if (r_ptr->flags7 & RF7_HAS_LD_MASK) p_ptr->update |= (PU_MON_LITE);
+       }
 
        /* Hack - Cancel any special player stealth magics. -LM- */
        if (p_ptr->special_defense & NINJA_S_STEALTH)
@@ -2106,6 +2109,7 @@ msg_format("%s
                {
                        /* Cure fear */
                        m_ptr->monfear = 0;
+                       if (!need_mproc(m_ptr)) mproc_remove(m_ptr->mproc_idx);
 
                        /* No more fear */
                        (*fear) = FALSE;
@@ -2130,6 +2134,8 @@ msg_format("%s
                        /* Hack -- note fear */
                        (*fear) = TRUE;
 
+                       if (!m_ptr->mproc_idx) mproc_add(m_idx);
+
                        /* XXX XXX XXX Hack -- Add some timed fear */
                        m_ptr->monfear = (randint1(10) +
                                          (((dam >= m_ptr->hp) && (percentage > 7)) ?