}
}
- /* 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);
{
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;
}
#else
msg_format("%s is dazed.", m_name);
#endif
+ if (!m_ptr->mproc_idx) mproc_add(c_ptr->m_idx);
}
/* Apply stun */
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;
}
}
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;
}
#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)
/* 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
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;
((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);
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
#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").
#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)
*/
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 */
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 */
}
if (!p_ptr->wild_mode) m_ptr->energy_need += ENERGY_NEED();
}
+ else need_mproc_remove = FALSE;
}
/* Handle fast */
}
if (p_ptr->riding == m_idx) p_ptr->update |= (PU_BONUS);
}
+ else need_mproc_remove = FALSE;
}
/* Handle slow */
}
if (p_ptr->riding == m_idx) p_ptr->update |= (PU_BONUS);
}
+ else need_mproc_remove = FALSE;
}
/* Handle "sleep" */
{
/* 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))
{
/* Recover somewhat */
m_ptr->stunned -= d;
+ need_mproc_remove = FALSE;
}
/* Fully recover */
{
/* Reduce the confusion */
m_ptr->confused -= d;
+ need_mproc_remove = FALSE;
}
/* Recovered */
{
/* Reduce the fear */
m_ptr->monfear -= d;
+ need_mproc_remove = FALSE;
}
/* Recover from fear, take note if seen */
}
}
}
+
+ if (need_mproc_remove) mproc_remove(i);
}
}
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 */
{
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)
{
/* Recover fully */
m_ptr->csleep = 0;
+ need_mproc_remove = TRUE;
if (r_ptr->flags7 & RF7_HAS_LD_MASK) p_ptr->update |= (PU_MON_LITE);
/* Recover fully */
m_ptr->stunned = 0;
+ need_mproc_remove = TRUE;
/* Acquire the monster name */
monster_desc(m_name, m_ptr, 0);
/* Recover fully */
m_ptr->confused = 0;
+ need_mproc_remove = TRUE;
/* Acquire the monster name */
monster_desc(m_name, m_ptr, 0);
/* Recover fully */
m_ptr->monfear = 0;
+ need_mproc_remove = TRUE;
/* Acquire the monster name */
monster_desc(m_name, m_ptr, 0);
}
}
+ 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();
}
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)
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;
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;
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);
}
+/* Maximum number of preservable pets */
+#define MAX_PARTY_MON 21
+
+static monster_type party_mon[MAX_PARTY_MON];
+
+
/*
* Preserve_pets
*/
/* 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];
}
}
- /* 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);
}
/* Remove confusion */
m_ptr->confused = 0;
+
+ if (!m_ptr->csleep) mproc_remove(m_ptr->mproc_idx);
}
/* Extract real monster race */
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();
/* 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);
/* Read the monster */
rd_monster(m_ptr);
+ if (need_mproc(m_ptr)) mproc_add(m_idx);
+ else m_ptr->mproc_idx = 0;
/* Access grid */
/* Read the monster */
rd_monster(m_ptr);
+ if (need_mproc(m_ptr)) mproc_add(m_idx);
+ else m_ptr->mproc_idx = 0;
/* Access grid */
case MS_DISPEL:
{
monster_type *m_ptr;
+ bool need_mproc_remove = FALSE;
char m_name[80];
if (!target_set(TARGET_KILL)) return FALSE;
if (m_ptr->invulner)
{
m_ptr->invulner = 0;
+ need_mproc_remove = TRUE;
if (m_ptr->ml)
{
#ifdef JP
if (m_ptr->fast)
{
m_ptr->fast = 0;
+ need_mproc_remove = TRUE;
#ifdef JP
if (m_ptr->ml) msg_format("%s¤Ï¤â¤¦²Ã®¤µ¤ì¤Æ¤¤¤Ê¤¤¡£", m_name);
#else
if (m_ptr->slow)
{
m_ptr->slow = 0;
+ need_mproc_remove = TRUE;
#ifdef JP
if (m_ptr->ml) msg_format("%s¤Ï¤â¤¦¸ºÂ®¤µ¤ì¤Æ¤¤¤Ê¤¤¡£", m_name);
#else
#endif
}
+ if (need_mproc_remove && !need_mproc(m_ptr)) mproc_remove(m_ptr->mproc_idx);
break;
}
case MS_ROCKET:
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);
{
/* Cure fear */
m_ptr->monfear = 0;
+ if (!need_mproc(m_ptr)) mproc_remove(m_ptr->mproc_idx);
/* No more fear */
(*fear) = FALSE;
/* 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)) ?
/* 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 */
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 */
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);
/* 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" */
/* 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 */
{
/* No longer afraid */
m_ptr->monfear = 0;
+ if (!need_mproc(m_ptr)) mproc_remove(m_ptr->mproc_idx);
/* Message if seen */
if (see_m)
case 9:
{
monster_type *m_ptr;
+ bool need_mproc_remove = FALSE;
char m_name[80];
if (!target_set(TARGET_KILL)) return FALSE;
if (m_ptr->invulner)
{
m_ptr->invulner = 0;
+ need_mproc_remove = TRUE;
if (m_ptr->ml)
{
#ifdef JP
if (m_ptr->fast)
{
m_ptr->fast = 0;
+ need_mproc_remove = TRUE;
#ifdef JP
if (m_ptr->ml) msg_format("%s¤Ï¤â¤¦²Ã®¤µ¤ì¤Æ¤¤¤Ê¤¤¡£", m_name);
#else
if (m_ptr->slow)
{
m_ptr->slow = 0;
+ need_mproc_remove = TRUE;
#ifdef JP
if (m_ptr->ml) msg_format("%s¤Ï¤â¤¦¸ºÂ®¤µ¤ì¤Æ¤¤¤Ê¤¤¡£", m_name);
#else
#endif
}
+ if (need_mproc_remove && !need_mproc(m_ptr)) mproc_remove(m_ptr->mproc_idx);
break;
}
case 10:
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);
}
+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.
*
/* 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;
/* Wipe the hole */
(void)WIPE(&m_list[i1], monster_type);
+ if (m_list[i2].mproc_idx) mproc_list[m_list[i2].mproc_idx] = i2;
}
/*
* 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.
*/
/* Reset "m_cnt" */
m_cnt = 0;
+ /* Reset "mproc_max" */
+ mproc_max = 1;
+
/* Hack -- reset "reproducer" count */
num_repro = 0;
/* 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 */
{
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
#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;
{
/* Cancel fear */
m_ptr->monfear = 0;
+ if (!need_mproc(m_ptr)) mproc_remove(m_ptr->mproc_idx);
/* Message */
#ifdef JP
}
- 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);
}
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;
}
#endif
+ if (!t_ptr->mproc_idx) mproc_add(t_idx);
t_ptr->confused += 12 + (byte)randint0(4);
}
#endif
+ if (!t_ptr->mproc_idx) mproc_add(t_idx);
t_ptr->confused += 12 + (byte)randint0(4);
}
#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);
#endif
+ if (!t_ptr->mproc_idx) mproc_add(t_idx);
t_ptr->stunned += randint1(4) + 4;
}
#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;
{
/* Cancel fear */
m_ptr->monfear = 0;
+ if (!need_mproc(m_ptr)) mproc_remove(m_ptr->mproc_idx);
/* Message */
#ifdef JP
}
}
- 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);
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)
{
case MS_DISPEL:
{
monster_type *m_ptr;
+ bool need_mproc_remove = FALSE;
char m_name[80];
if (!target_set(TARGET_KILL)) return FALSE;
if (m_ptr->invulner)
{
m_ptr->invulner = 0;
+ need_mproc_remove = TRUE;
if (m_ptr->ml)
{
#ifdef JP
if (m_ptr->fast)
{
m_ptr->fast = 0;
+ need_mproc_remove = TRUE;
#ifdef JP
if (m_ptr->ml) msg_format("%s¤Ï¤â¤¦²Ã®¤µ¤ì¤Æ¤¤¤Ê¤¤¡£", m_name);
#else
if (m_ptr->slow)
{
m_ptr->slow = 0;
+ need_mproc_remove = TRUE;
#ifdef JP
if (m_ptr->ml) msg_format("%s¤Ï¤â¤¦¸ºÂ®¤µ¤ì¤Æ¤¤¤Ê¤¤¡£", m_name);
#else
#endif
}
+ if (need_mproc_remove && !need_mproc(m_ptr)) mproc_remove(m_ptr->mproc_idx);
break;
}
case MS_ROCKET:
int do_time = 0;
bool heal_leper = FALSE;
+ bool need_mproc_remove = FALSE;
/* Hold the monster name */
char m_name[80];
#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)
#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)
{
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)
{
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);
{
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
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)
{
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)
{
if (seen_msg) msg_format("%^s recovers %s courage.", m_name, m_poss);
#endif
m_ptr->monfear = 0;
+ need_mproc_remove = TRUE;
}
/* Heal */
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);
#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);
#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);
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);
(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
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
if (m_ptr->hp >= nokori_hp)
{
#ifdef JP
-msg_format("¤â¤Ã¤È¼å¤é¤»¤Ê¤¤¤È¡£");
+ msg_format("¤â¤Ã¤È¼å¤é¤»¤Ê¤¤¤È¡£");
#else
msg_format("You need to weaken %s more.", m_name);
#endif
{
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
#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);
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;
}
#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 */
}
else
{
+ bool need_mproc_add = FALSE;
+
/* Sound and Impact resisters never stun */
if (do_stun &&
!(r_ptr->flagsr & (RFR_RES_SOUN | RFR_RES_WALL)) &&
#endif
tmp = do_stun;
+ need_mproc_add = TRUE;
}
/* Apply stun */
#endif
tmp = do_conf;
+ need_mproc_add = TRUE;
}
/* Apply confusion */
/* 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 */
/* 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
{
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" */
/* 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)
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;
}
/* 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;
+ }
}
}
}
/* 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;
+ }
}
}
{
/* 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)
{
{
if (!is_pet(m_ptr))
{
+ if (!m_ptr->mproc_idx) mproc_add(i);
m_ptr->fast = MIN(200, m_ptr->fast + 100);
speed = TRUE;
}
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)
{
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;
{
/* 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" */
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;
{
/* 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))
{
/* 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;
u32b smart; /* Field for "smart_learn" */
s16b parent_m_idx;
+
+ s16b mproc_idx;
};
*/
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
s16b kubi_r_idx[MAX_KUBI];
s16b today_mon;
-monster_type party_mon[MAX_PARTY_MON];
-
bool write_level;
u32b playtime;
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)
{
/* Cure fear */
m_ptr->monfear = 0;
+ if (!need_mproc(m_ptr)) mproc_remove(m_ptr->mproc_idx);
/* No more fear */
(*fear) = FALSE;
/* 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)) ?