-/*
- * Process the counters of monsters (once per 10 game turns)
- *
- * This function is to process monsters' counters same as player's.
- */
-static void process_monsters_counters(void)
-{
- int m_idx;
- monster_type *m_ptr;
- monster_race *r_ptr;
-
- u32b noise; /* Hack -- local "player stealth" value */
-
- /* Handle "leaving" */
- if (p_ptr->leaving) return;
-
- /* Hack -- calculate the "player noise" */
- noise = (1L << (30 - p_ptr->skill_stl));
-
- /* Process the monsters (backwards) */
- for (m_idx = m_max - 1; m_idx >= 1; m_idx--)
- {
- /* 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;
-
- /* Handle Invulnerability */
- if (m_ptr->invulner)
- {
- /* Reduce by one, note if expires */
- m_ptr->invulner--;
-
- if (!m_ptr->invulner)
- {
- if (m_ptr->ml)
- {
- char m_name[80];
-
- /* Acquire the monster name */
- monster_desc(m_name, m_ptr, 0);
-
- /* Dump a message */
-#ifdef JP
- msg_format("%^s¤Ï¤â¤¦ÌµÅ¨¤Ç¤Ê¤¤¡£", m_name);
-#else
- msg_format("%^s is no longer invulnerable.", m_name);
-#endif
-
- if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
- if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
- }
- if (!p_ptr->wild_mode) m_ptr->energy_need += ENERGY_NEED();
- }
- }
-
- /* Handle fast */
- if (m_ptr->fast)
- {
- /* Reduce by one, note if expires */
- m_ptr->fast--;
-
- if (!m_ptr->fast && m_ptr->ml)
- {
- char m_name[80];
-
- /* Acquire the monster name */
- monster_desc(m_name, m_ptr, 0);
-
- /* Dump a message */
-#ifdef JP
- msg_format("%^s¤Ï¤â¤¦²Ã®¤µ¤ì¤Æ¤¤¤Ê¤¤¡£", m_name);
-#else
- msg_format("%^s is no longer fast.", m_name);
-#endif
-
- if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
- if (p_ptr->riding == m_idx)
- {
- p_ptr->redraw |= (PR_UHEALTH);
- p_ptr->update |= (PU_BONUS);
- }
- }
- }
-
- /* Handle slow */
- if (m_ptr->slow)
- {
- /* Reduce by one, note if expires */
- m_ptr->slow--;
-
- if (!m_ptr->slow && m_ptr->ml)
- {
- char m_name[80];
-
- /* Acquire the monster name */
- monster_desc(m_name, m_ptr, 0);
-
- /* Dump a message */
-#ifdef JP
- msg_format("%^s¤Ï¤â¤¦¸ºÂ®¤µ¤ì¤Æ¤¤¤Ê¤¤¡£", m_name);
-#else
- msg_format("%^s is no longer slow.", m_name);
-#endif
-
- if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
- if (p_ptr->riding == m_idx)
- {
- p_ptr->redraw |= (PR_UHEALTH);
- p_ptr->update |= (PU_BONUS);
- }
- }
- }
-
- /* Handle "sleep" */
- if (m_ptr->csleep)
- {
- /* Assume does not wake up */
- bool test = FALSE;
-
- /* Hack -- Require proximity */
- if (m_ptr->cdis < AAF_LIMIT)
- {
- /* Handle "sensing radius" */
- if (m_ptr->cdis <= (is_pet(m_ptr) ? ((r_ptr->aaf > MAX_SIGHT) ? MAX_SIGHT : r_ptr->aaf) : r_ptr->aaf))
- {
- /* We may wake up */
- test = TRUE;
- }
-
- /* Handle "sight" and "aggravation" */
- else if ((m_ptr->cdis <= MAX_SIGHT) && (player_has_los_bold(m_ptr->fy, m_ptr->fx)))
- {
- /* We may wake up */
- test = TRUE;
- }
- }
-
- if (test)
- {
- u32b notice = randint0(1024);
-
- /* Nightmare monsters are more alert */
- if (ironman_nightmare) notice /= 2;
-
- /* Hack -- See if monster "notices" player */
- if ((notice * notice * notice) <= noise)
- {
- /* Hack -- amount of "waking" */
- /* Wake up faster near the player */
- int d = (m_ptr->cdis < AAF_LIMIT / 2) ? (AAF_LIMIT / m_ptr->cdis) : 1;
-
- /* Hack -- amount of "waking" is affected by speed of player */
- d = (d * SPEED_TO_ENERGY(p_ptr->pspeed)) / 10;
- if (d < 0) d = 1;
-
- /* Still asleep */
- if (m_ptr->csleep > d)
- {
- /* Monster wakes up "a little bit" */
- m_ptr->csleep -= d;
-
- /* Notice the "not waking up" */
- if (m_ptr->ml)
- {
- /* Hack -- Count the ignores */
- if (r_ptr->r_ignore < MAX_UCHAR)
- {
- r_ptr->r_ignore++;
- }
- }
- }
-
- /* Just woke up */
- else
- {
- /* Reset sleep counter */
- m_ptr->csleep = 0;
-
- if (r_ptr->flags7 & RF7_HAS_LD_MASK) p_ptr->update |= (PU_MON_LITE);
-
- /* Notice the "waking up" */
- if (m_ptr->ml)
- {
- char m_name[80];
-
- /* Acquire the monster name */
- monster_desc(m_name, m_ptr, 0);
-
- /* Dump a message */
-#ifdef JP
- msg_format("%^s¤¬Ìܤò³Ð¤Þ¤·¤¿¡£", m_name);
-#else
- msg_format("%^s wakes up.", m_name);
-#endif
-
- /* Redraw the health bar */
- if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
- if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
-
- /* Hack -- Count the wakings */
- if (r_ptr->r_wake < MAX_UCHAR)
- {
- r_ptr->r_wake++;
- }
- }
- }
- }
- }
- }
-
- /* Handle "stun" */
- if (m_ptr->stunned)
- {
- int d = 1;
-
- /* Make a "saving throw" against stun */
- if (randint0(10000) <= r_ptr->level * r_ptr->level)
- {
- /* Recover fully */
- d = m_ptr->stunned;
- }
-
- /* Hack -- Recover from stun */
- if (m_ptr->stunned > d)
- {
- /* Recover somewhat */
- m_ptr->stunned -= d;
- }
-
- /* Fully recover */
- else
- {
- /* Recover fully */
- m_ptr->stunned = 0;
-
- /* Message if visible */
- if (m_ptr->ml)
- {
- char m_name[80];
-
- /* Acquire the monster name */
- monster_desc(m_name, m_ptr, 0);
-
- /* Dump a message */
-#ifdef JP
- msg_format("%^s¤ÏÛ¯Û°¾õÂÖ¤«¤éΩ¤Áľ¤Ã¤¿¡£", m_name);
-#else
- msg_format("%^s is no longer stunned.", m_name);
-#endif
-
- if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
- if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
- }
- }
- }
-
- /* Handle confusion */
- if (m_ptr->confused)
- {
- /* Amount of "boldness" */
- int d = randint1(r_ptr->level / 20 + 1);
-
- /* Still confused */
- if (m_ptr->confused > d)
- {
- /* Reduce the confusion */
- m_ptr->confused -= d;
- }
-
- /* Recovered */
- else
- {
- /* No longer confused */
- m_ptr->confused = 0;
-
- /* Message if visible */
- if (m_ptr->ml)
- {
- char m_name[80];
-
- /* Acquire the monster name */
- monster_desc(m_name, m_ptr, 0);
-
- /* Dump a message */
-#ifdef JP
- msg_format("%^s¤Ïº®Í𤫤éΩ¤Áľ¤Ã¤¿¡£", m_name);
-#else
- msg_format("%^s is no longer confused.", m_name);
-#endif
-
- if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
- if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
- }
- }
- }
-
- /* Handle "fear" */
- if (m_ptr->monfear)
- {
- /* Amount of "boldness" */
- int d = randint1(r_ptr->level / 20 + 1);
-
- /* Still afraid */
- if (m_ptr->monfear > d)
- {
- /* Reduce the fear */
- m_ptr->monfear -= d;
- }
-
- /* Recover from fear, take note if seen */
- else
- {
- /* No longer afraid */
- m_ptr->monfear = 0;
-
- /* Visual note */
- if (m_ptr->ml)
- {
- char m_name[80];
-#ifndef JP
- char m_poss[80];
-
- /* Acquire the monster possessive */
- monster_desc(m_poss, m_ptr, MD_PRON_VISIBLE | MD_POSSESSIVE);
-#endif
-
- /* Acquire the monster name */
- monster_desc(m_name, m_ptr, 0);
-
- /* Dump a message */
-#ifdef JP
- msg_format("%^s¤Ïͦµ¤¤ò¼è¤êÌᤷ¤¿¡£", m_name);
-#else
- msg_format("%^s recovers %s courage.", m_name, m_poss);
-#endif
-
- if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
- if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
- }
- }
- }
- }
-}
-
-