OSDN Git Service

一般形のナズグルに与えられるフラグUNIQUE_7をNAZGULと置き換えた. この
[hengband/hengband.git] / src / dungeon.c
index 7aeac28..35bb9cf 100644 (file)
@@ -1017,7 +1017,7 @@ static void regen_monsters(void)
 
 
 /*
- * Regenerate the monsters (once per 100 game turns)
+ * Regenerate the captured monsters (once per 30 game turns)
  *
  * XXX XXX XXX Should probably be done during monster turns.
  */
@@ -1073,6 +1073,354 @@ static void regen_captured_monsters(void)
 }
 
 
+/*
+ * 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);
+                               }
+                       }
+               }
+       }
+}
+
+
 static void notice_lite_change(object_type *o_ptr)
 {
        /* Hack -- notice interesting fuel steps */
@@ -1133,7 +1481,7 @@ msg_print("
 
 void leave_quest_check(void)
 {
-       /* Save quset number for dungeon pref file ($LEAVING_QUEST) */
+       /* Save quest number for dungeon pref file ($LEAVING_QUEST) */
        leaving_quest = p_ptr->inside_quest;
 
        /* Leaving an 'only once' quest marks it as failed */
@@ -1488,8 +1836,14 @@ static void check_music(void)
                        /* Recalculate bonuses */
                        p_ptr->update |= (PU_BONUS | PU_HP);
 
-                       /* Redraw status bar */
-                       p_ptr->redraw |= (PR_STATUS);
+                       /* Redraw map and status bar */
+                       p_ptr->redraw |= (PR_MAP | PR_STATUS | PR_STATE);
+
+                       /* Update monsters */
+                       p_ptr->update |= (PU_MONSTERS);
+
+                       /* Window stuff */
+                       p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
                }
        }
        if (p_ptr->spell_exp[spell] < SPELL_EXP_BEGINNER)
@@ -1551,13 +1905,17 @@ static void process_world(void)
        s32b len = TURNS_PER_TICK * TOWN_DAWN;
        s32b tick = turn % len + len / 4;
 
+       int quest_num = quest_number(dun_level);
+
        extract_day_hour_min(&day, &hour, &min);
        prev_min = (1440 * (tick - TURNS_PER_TICK) / len) % 60;
 
        if ((turn - old_turn == (150 - dun_level) * TURNS_PER_TICK)
-           && (dun_level) &&
-           !(quest_number(dun_level) && ((quest_number(dun_level) < MIN_RANDOM_QUEST) && !(quest_number(dun_level) == QUEST_OBERON || quest_number(dun_level) == QUEST_SERPENT || !(quest[quest_number(dun_level)].flags & QUEST_FLAG_PRESET)))) &&
-           !(p_ptr->inside_battle))
+           && dun_level &&
+           !(quest_num && (is_fixed_quest_idx(quest_num) &&
+           !((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT) ||
+             !(quest[quest_num].flags & QUEST_FLAG_PRESET)))) &&
+           !p_ptr->inside_battle)
                do_cmd_feeling();
 
        if (p_ptr->inside_battle && !p_ptr->leaving)
@@ -1642,7 +2000,7 @@ msg_print("
                }
        }
 
-       /* Every 20 game turns */
+       /* Every 10 game turns */
        if (turn % TURNS_PER_TICK) return;
 
        /*** Check the Time and Load ***/
@@ -1726,12 +2084,11 @@ msg_print("
                        {
                                /* Message */
 #ifdef JP
-msg_print("Ì뤬ÌÀ¤±¤¿¡£");
+                               msg_print("Ì뤬ÌÀ¤±¤¿¡£");
 #else
                                msg_print("The sun has risen.");
 #endif
 
-
                                /* Hack -- Scan the town */
                                for (y = 0; y < cur_hgt; y++)
                                {
@@ -1755,14 +2112,15 @@ msg_print("
                        /* Night falls */
                        else
                        {
+                               byte feat;
+
                                /* Message */
 #ifdef JP
-msg_print("Æü¤¬ÄÀ¤ó¤À¡£");
+                               msg_print("Æü¤¬ÄÀ¤ó¤À¡£");
 #else
                                msg_print("The sun has fallen.");
 #endif
 
-
                                /* Hack -- Scan the town */
                                for (y = 0; y < cur_hgt; y++)
                                {
@@ -1771,24 +2129,27 @@ msg_print("
                                                /* Get the cave grid */
                                                c_ptr = &cave[y][x];
 
-                                               /* Darken "boring" features */
-                                               if ((c_ptr->feat <= FEAT_INVIS) ||
-                                                   ((c_ptr->feat >= FEAT_DEEP_WATER) &&
-                                                       (c_ptr->feat <= FEAT_MOUNTAIN) &&
-                                                    (c_ptr->feat != FEAT_MUSEUM)) ||
-                                                   (x == 0) || (x == cur_wid-1) ||
-                                                   (y == 0) || (y == cur_hgt-1))
+                                               /* Feature code (applying "mimic" field) */
+                                               feat = f_info[c_ptr->mimic ? c_ptr->mimic : c_ptr->feat].mimic;
+
+                                               if (!is_mirror_grid(c_ptr) && (feat != FEAT_QUEST_ENTER) && (feat != FEAT_ENTRANCE))
                                                {
-                                                       /* Forget the grid */
-                                                       if (!is_mirror_grid(c_ptr)) c_ptr->info &= ~(CAVE_GLOW | CAVE_MARK);
+                                                       /* Assume dark */
+                                                       c_ptr->info &= ~(CAVE_GLOW);
+
+                                                       if ((feat <= FEAT_INVIS) || (feat == FEAT_DIRT) || (feat == FEAT_GRASS))
+                                                       {
+                                                               /* Forget the normal floor grid */
+                                                               c_ptr->info &= ~(CAVE_MARK);
 
-                                                       /* Hack -- Notice spot */
-                                                       note_spot(y, x);
+                                                               /* Hack -- Notice spot */
+                                                               note_spot(y, x);
+                                                       }
                                                }
                                        }
 
-                                       /* Glow deep lava */
-                                       glow_deep_lava();
+                                       /* Glow deep lava and building entrances */
+                                       glow_deep_lava_and_bldg();
                                }
                        }
 
@@ -1804,7 +2165,8 @@ msg_print("
        }
 
        /* Set back the rewards once a day */
-       if (!(turn % (TURNS_PER_TICK*10 * STORE_TURNS)))
+       /* Only used for reward in thief's guild for now */
+       if (!(turn % (TURNS_PER_TICK * TOWN_DAWN)))
        {
                int n;
 
@@ -1838,6 +2200,9 @@ if (cheat_xtra) msg_print("
        if (!(turn % (TURNS_PER_TICK*10)) && !p_ptr->inside_battle) regen_monsters();
        if (!(turn % (TURNS_PER_TICK*3))) regen_captured_monsters();
 
+       /* Hack -- Process the counters of all monsters */
+       process_monsters_counters();
+
 
        /*** Damage over Time ***/
 
@@ -1859,7 +2224,7 @@ if (cheat_xtra) msg_print("
        {
                if (!dun_level && !p_ptr->resist_lite && !IS_INVULN() && is_daytime())
                {
-                       if (cave[py][px].info & CAVE_GLOW)
+                       if ((cave[py][px].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW)
                        {
                                /* Take damage */
 #ifdef JP
@@ -2091,39 +2456,10 @@ dam_desc = "
 
        if (!hour && !min)
        {
-               monster_race *r_ptr;
-
                if (min != prev_min)
                {
-                       int max_dl = 3;
-                       bool old_inside_battle = p_ptr->inside_battle;
-
                        do_cmd_write_nikki(NIKKI_HIGAWARI, 0, NULL);
-
-                       p_ptr->inside_battle = TRUE;
-                       get_mon_num_prep(NULL,NULL);
-
-                       for (i = 0; i < max_d_idx; i++)
-                       {
-                               if (max_dlv[i] < d_info[i].mindepth) continue;
-                               if (max_dl < max_dlv[i]) max_dl = max_dlv[i];
-                       }
-                       while (1)
-                       {
-                               today_mon = get_mon_num(max_dl);
-                               r_ptr = &r_info[today_mon];
-
-                               if (r_ptr->flags1 & RF1_UNIQUE) continue;
-                               if (r_ptr->flags7 & (RF7_UNIQUE_7 | RF7_UNIQUE2)) continue;
-                               if (r_ptr->flags2 & (RF2_MULTIPLY)) continue;
-                               if (!(r_ptr->flags9 & RF9_DROP_CORPSE) || !(r_ptr->flags9 & RF9_DROP_SKELETON)) continue;
-                               if (r_ptr->level < MIN(max_dl/2, 40)) continue;
-                               if (r_ptr->rarity > 10) continue;
-                               if (r_ptr->level == 0) continue;
-                               break;
-                       }
-                       p_ptr->today_mon = 0;
-                       p_ptr->inside_battle = old_inside_battle;
+                       determine_today_mon(FALSE);
                }
        }
 
@@ -2259,13 +2595,11 @@ take_hit(DAMAGE_NOESCAPE, i, "
                /* Digest normally */
                if (p_ptr->food < PY_FOOD_MAX)
                {
-                       /* Every 100 game turns */
+                       /* Every 50 game turns */
                        if (!(turn % (TURNS_PER_TICK*5)))
                        {
                                /* Basic digestion rate based on speed */
-                               i = /* extract_energy[p_ptr->pspeed] * 2;*/
-                               ((p_ptr->pspeed > 199) ? 49 : ((p_ptr->pspeed < 0) ?
-                               1 : extract_energy[p_ptr->pspeed]));
+                               i = SPEED_TO_ENERGY(p_ptr->pspeed);
 
                                /* Regeneration takes more food */
                                if (p_ptr->regenerate) i += 20;
@@ -3033,7 +3367,7 @@ msg_print("
                        msg_print(NULL);
 
                        /* Absorb light from the current possition */
-                       if (cave[py][px].info & CAVE_GLOW)
+                       if ((cave[py][px].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW)
                        {
                                hp_player(10);
                        }
@@ -3333,6 +3667,9 @@ msg_print("̵Ũ
 
                                hp_player(healing);
                                p_ptr->csp -= healing;
+
+                               /* Redraw mana */
+                               p_ptr->redraw |= (PR_MANA);
                        }
                }
                if ((p_ptr->muta2 & MUT2_HP_TO_SP) && !p_ptr->anti_magic &&
@@ -3350,6 +3687,9 @@ msg_print("̵Ũ
                                }
 
                                p_ptr->csp += healing;
+
+                               /* Redraw mana */
+                               p_ptr->redraw |= (PR_MANA);
 #ifdef JP
 take_hit(DAMAGE_LOSELIFE, healing, "Ƭ¤Ë¾º¤Ã¤¿·ì", -1);
 #else
@@ -3927,7 +4267,7 @@ static bool enter_wizard_mode(void)
 
                /* Mention effects */
 #ifdef JP
-               msg_print("¥¦¥£¥¶¡¼¥É¥â¡¼¥É¤Ï¥Ç¥Ð¥°¤È¼Â¸³¤Î¤¿¤á¤Î¥â¡¼¥É¤Ç¤¹¡£ ");
+               msg_print("¥¦¥£¥¶¡¼¥É¥â¡¼¥É¤Ï¥Ç¥Ð¥å°¤È¼Â¸³¤Î¤¿¤á¤Î¥â¡¼¥É¤Ç¤¹¡£ ");
                msg_print("°ìÅÙ¥¦¥£¥¶¡¼¥É¥â¡¼¥É¤ËÆþ¤ë¤È¥¹¥³¥¢¤Ïµ­Ï¿¤µ¤ì¤Þ¤»¤ó¡£");
 #else
                msg_print("Wizard mode is for debugging and experimenting.");
@@ -3983,8 +4323,8 @@ static bool enter_debug_mode(void)
 
                /* Mention effects */
 #ifdef JP
-               msg_print("¥Ç¥Ð¥°¡¦¥³¥Þ¥ó¥É¤Ï¥Ç¥Ð¥°¤È¼Â¸³¤Î¤¿¤á¤Î¥³¥Þ¥ó¥É¤Ç¤¹¡£ ");
-               msg_print("¥Ç¥Ð¥°¡¦¥³¥Þ¥ó¥É¤ò»È¤¦¤È¥¹¥³¥¢¤Ïµ­Ï¿¤µ¤ì¤Þ¤»¤ó¡£");
+               msg_print("¥Ç¥Ð¥Ã¥°¡¦¥³¥Þ¥ó¥É¤Ï¥Ç¥Ð¥Ã¥°¤È¼Â¸³¤Î¤¿¤á¤Î¥³¥Þ¥ó¥É¤Ç¤¹¡£ ");
+               msg_print("¥Ç¥Ð¥å°¡¦¥³¥Þ¥ó¥É¤ò»È¤¦¤È¥¹¥³¥¢¤Ïµ­Ï¿¤µ¤ì¤Þ¤»¤ó¡£");
 #else
                msg_print("The debug commands are for debugging and experimenting.");
                msg_print("The game will not be scored if you use debug commands.");
@@ -3994,7 +4334,7 @@ static bool enter_debug_mode(void)
 
                /* Verify request */
 #ifdef JP
-               if (!get_check("ËÜÅö¤Ë¥Ç¥Ð¥°¡¦¥³¥Þ¥ó¥É¤ò»È¤¤¤Þ¤¹¤«? "))
+               if (!get_check("ËÜÅö¤Ë¥Ç¥Ð¥å°¡¦¥³¥Þ¥ó¥É¤ò»È¤¤¤Þ¤¹¤«? "))
 #else
                if (!get_check("Are you sure you want to use debug commands? "))
 #endif
@@ -4035,7 +4375,7 @@ static bool enter_borg_mode(void)
        {
                /* Mention effects */
 #ifdef JP
-               msg_print("¥Ü¡¼¥°¡¦¥³¥Þ¥ó¥É¤Ï¥Ç¥Ð¥°¤È¼Â¸³¤Î¤¿¤á¤Î¥³¥Þ¥ó¥É¤Ç¤¹¡£ ");
+               msg_print("¥Ü¡¼¥°¡¦¥³¥Þ¥ó¥É¤Ï¥Ç¥Ð¥å°¤È¼Â¸³¤Î¤¿¤á¤Î¥³¥Þ¥ó¥É¤Ç¤¹¡£ ");
                msg_print("¥Ü¡¼¥°¡¦¥³¥Þ¥ó¥É¤ò»È¤¦¤È¥¹¥³¥¢¤Ïµ­Ï¿¤µ¤ì¤Þ¤»¤ó¡£");
 #else
                msg_print("The borg commands are for debugging and experimenting.");
@@ -5114,7 +5454,7 @@ msg_print("
        /* Give the player some energy */
        else if (!(load && p_ptr->energy_need <= 0))
        {
-               p_ptr->energy_need -= (p_ptr->pspeed > 199 ? 49 : (p_ptr->pspeed < 0 ? 1 : extract_energy[p_ptr->pspeed]));
+               p_ptr->energy_need -= SPEED_TO_ENERGY(p_ptr->pspeed);
        }
 
        /* No turn yet */
@@ -5235,6 +5575,8 @@ msg_print("
                        /* Recover fully */
                        m_ptr->csleep = 0;
 
+                       if (r_info[m_ptr->r_idx].flags7 & RF7_HAS_LD_MASK) p_ptr->update |= (PU_MON_LITE);
+
                        /* Acquire the monster name */
                        monster_desc(m_name, m_ptr, 0);
 #ifdef JP
@@ -5638,11 +5980,15 @@ msg_format("%s(%c)
                                        /* Skip dead monsters */
                                        if (!m_ptr->r_idx) continue;
 
+                                       /* Skip unseen monsters */
+                                       if (!m_ptr->ml) continue;
+
                                        /* Access the monster race */
-                                       r_ptr = &r_info[m_ptr->r_idx];
+                                       r_ptr = &r_info[m_ptr->ap_r_idx];
 
                                        /* Skip non-multi-hued monsters */
-                                       if (!(r_ptr->flags1 & RF1_ATTR_MULTI)) continue;
+                                       if (!(r_ptr->flags1 & (RF1_ATTR_MULTI | RF1_SHAPECHANGER)))
+                                               continue;
 
                                        /* Reset the flag */
                                        shimmer_monsters = TRUE;
@@ -5894,7 +6240,9 @@ static void dungeon(bool load_game)
        /* Refresh */
        Term_fresh();
 
-       if (quest_number(dun_level) && ((quest_number(dun_level) < MIN_RANDOM_QUEST) && !(quest_number(dun_level) == QUEST_OBERON || quest_number(dun_level) == QUEST_SERPENT || !(quest[quest_number(dun_level)].flags & QUEST_FLAG_PRESET)))) do_cmd_feeling();
+       if (quest_num && (is_fixed_quest_idx(quest_num) &&
+           !((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT) ||
+           !(quest[quest_num].flags & QUEST_FLAG_PRESET)))) do_cmd_feeling();
 
        if (p_ptr->inside_battle)
        {
@@ -5905,7 +6253,6 @@ static void dungeon(bool load_game)
                }
                else
                {
-                       
 #ifdef JP
 msg_print("»î¹ç³«»Ï¡ª");
 #else
@@ -5935,9 +6282,9 @@ msg_print("
                                   d_name+d_info[dungeon_type].name, 
                                   r_name+r_info[d_info[dungeon_type].final_guardian].name);
 #else
-               msg_format("%^s lives in this level as the keeper of %s.",
-                                  r_name+r_info[d_info[dungeon_type].final_guardian].name, 
-                                  d_name+d_info[dungeon_type].name);
+                       msg_format("%^s lives in this level as the keeper of %s.",
+                                          r_name+r_info[d_info[dungeon_type].final_guardian].name, 
+                                          d_name+d_info[dungeon_type].name);
 #endif
        }
 
@@ -6148,6 +6495,128 @@ static void load_all_pref_files(void)
 
 
 /*
+ * Extract option variables from bit sets
+ */
+void extract_option_vars(void)
+{
+       int i;
+
+       for (i = 0; option_info[i].o_desc; i++)
+       {
+               int os = option_info[i].o_set;
+               int ob = option_info[i].o_bit;
+
+               /* Set the "default" options */
+               if (option_info[i].o_var)
+               {
+                       /* Set */
+                       if (option_flag[os] & (1L << ob))
+                       {
+                               /* Set */
+                               (*option_info[i].o_var) = TRUE;
+                       }
+
+                       /* Clear */
+                       else
+                       {
+                               /* Clear */
+                               (*option_info[i].o_var) = FALSE;
+                       }
+               }
+       }
+}
+
+
+/*
+ * Determine bounty uniques
+ */
+void determine_bounty_uniques(void)
+{
+       int          i, j, tmp;
+       monster_race *r_ptr;
+
+       get_mon_num_prep(NULL, NULL);
+       for (i = 0; i < MAX_KUBI; i++)
+       {
+               while (1)
+               {
+                       kubi_r_idx[i] = get_mon_num(MAX_DEPTH - 1);
+                       r_ptr = &r_info[kubi_r_idx[i]];
+
+                       if (!(r_ptr->flags1 & RF1_UNIQUE)) continue;
+
+                       if (!(r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON))) continue;
+
+                       if (r_ptr->rarity > 100) continue;
+
+                       if (no_questor_or_bounty_uniques(kubi_r_idx[i])) continue;
+
+                       for (j = 0; j < i; j++)
+                               if (kubi_r_idx[i] == kubi_r_idx[j]) break;
+
+                       if (j == i) break;
+               }
+       }
+
+       /* Sort them */
+       for (i = 0; i < MAX_KUBI - 1; i++)
+       {
+               for (j = i; j < MAX_KUBI; j++)
+               {
+                       if (r_info[kubi_r_idx[i]].level > r_info[kubi_r_idx[j]].level)
+                       {
+                               tmp = kubi_r_idx[i];
+                               kubi_r_idx[i] = kubi_r_idx[j];
+                               kubi_r_idx[j] = tmp;
+                       }
+               }
+       }
+}
+
+
+/*
+ * Determine today's bounty monster
+ * Note: conv_old is used if loaded 0.0.3 or older save file
+ */
+void determine_today_mon(bool conv_old)
+{
+       int max_dl = 3, i;
+       bool old_inside_battle = p_ptr->inside_battle;
+       monster_race *r_ptr;
+
+       if (!conv_old)
+       {
+               for (i = 0; i < max_d_idx; i++)
+               {
+                       if (max_dlv[i] < d_info[i].mindepth) continue;
+                       if (max_dl < max_dlv[i]) max_dl = max_dlv[i];
+               }
+       }
+       else max_dl = MAX(max_dlv[DUNGEON_ANGBAND], 3);
+
+       p_ptr->inside_battle = TRUE;
+       get_mon_num_prep(NULL, NULL);
+
+       while (1)
+       {
+               today_mon = get_mon_num(max_dl);
+               r_ptr = &r_info[today_mon];
+
+               if (r_ptr->flags1 & RF1_UNIQUE) continue;
+               if (r_ptr->flags7 & (RF7_NAZGUL | RF7_UNIQUE2)) continue;
+               if (r_ptr->flags2 & RF2_MULTIPLY) continue;
+               if ((r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) != (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) continue;
+               if (r_ptr->level < MIN(max_dl / 2, 40)) continue;
+               if (r_ptr->rarity > 10) continue;
+               break;
+       }
+
+       p_ptr->today_mon = 0;
+       p_ptr->inside_battle = old_inside_battle;
+}
+
+
+/*
  * Actually play a game
  *
  * If the "new_game" parameter is true, then, after loading the
@@ -6177,7 +6646,7 @@ void play_game(bool new_game)
 
        /* Initialise the resize hooks */
        angband_term[0]->resize_hook = resize_map;
-       
+
        for (i = 1; i < 8; i++)
        {
                /* Does the term exist? */
@@ -6205,29 +6674,7 @@ quit("
        }
 
        /* Extract the options */
-       for (i = 0; option_info[i].o_desc; i++)
-       {
-               int os = option_info[i].o_set;
-               int ob = option_info[i].o_bit;
-
-               /* Set the "default" options */
-               if (option_info[i].o_var)
-               {
-                       /* Set */
-                       if (option_flag[os] & (1L << ob))
-                       {
-                               /* Set */
-                               (*option_info[i].o_var) = TRUE;
-                       }
-
-                       /* Clear */
-                       else
-                       {
-                               /* Clear */
-                               (*option_info[i].o_var) = FALSE;
-                       }
-               }
-       }
+       extract_option_vars();
 
        /* Report waited score */
        if (p_ptr->wait_report_score)
@@ -6357,8 +6804,6 @@ quit("
        /* Roll new character */
        if (new_game)
        {
-               monster_race *r_ptr;
-
                /* The dungeon is not ready */
                character_dungeon = FALSE;
 
@@ -6389,57 +6834,9 @@ quit("
 #endif
 
                load = FALSE;
-               get_mon_num_prep(NULL, NULL);
-               for (i = 0; i < MAX_KUBI; i++)
-               {
-                       while (1)
-                       {
-                               int j;
-
-                               kubi_r_idx[i] = get_mon_num(MAX_DEPTH - 1);
-                               r_ptr = &r_info[kubi_r_idx[i]];
-
-                               if(!(r_ptr->flags1 & RF1_UNIQUE)) continue;
-
-                               if(!(r_ptr->flags9 & RF9_DROP_CORPSE)) continue;
-                               if (r_ptr->rarity > 100) continue;
-
-                               if(r_ptr->flags6 & RF6_SPECIAL) continue;
-
-                               for (j = 0; j < i; j++)
-                                       if (kubi_r_idx[i] == kubi_r_idx[j])break;
 
-                               if (j == i) break;
-                       }
-               }
-               for (i = 0; i < MAX_KUBI -1; i++)
-               {
-                       int j,tmp;
-                       for (j = i; j < MAX_KUBI; j++)
-                       {
-                               if (r_info[kubi_r_idx[i]].level > r_info[kubi_r_idx[j]].level)
-                               {
-                                       tmp = kubi_r_idx[i];
-                                       kubi_r_idx[i] = kubi_r_idx[j];
-                                       kubi_r_idx[j] = tmp;
-                               }
-                       }
-               }
-
-               p_ptr->inside_battle = TRUE;
-               while (1)
-               {
-                       today_mon = get_mon_num(3);
-                       r_ptr = &r_info[today_mon];
-
-                       if (r_ptr->flags1 & RF1_UNIQUE) continue;
-                       if (r_ptr->flags2 & (RF2_MULTIPLY)) continue;
-                       if (!(r_ptr->flags9 & RF9_DROP_CORPSE) || !(r_ptr->flags9 & RF9_DROP_SKELETON)) continue;
-                       if (r_ptr->rarity > 10) continue;
-                       if (r_ptr->level == 0) continue;
-                       break;
-               }
-               p_ptr->inside_battle = FALSE;
+               determine_bounty_uniques();
+               determine_today_mon(FALSE);
        }
        else
        {
@@ -6458,9 +6855,9 @@ quit("
                if (p_ptr->riding == -1)
                {
                        p_ptr->riding = 0;
-                       for(i = m_max; i > 0; i--)
+                       for (i = m_max; i > 0; i--)
                        {
-                               if ((m_list[i].fy == py) && (m_list[i].fx == px))
+                               if (player_bold(m_list[i].fy, m_list[i].fx))
                                {
                                        p_ptr->riding = i;
                                        break;
@@ -6635,10 +7032,10 @@ prt("
                        if (p_ptr->inside_arena)
                        {
                                p_ptr->inside_arena = FALSE;
-                               if(p_ptr->arena_number > MAX_ARENA_MONS)
+                               if (p_ptr->arena_number > MAX_ARENA_MONS)
                                        p_ptr->arena_number++;
                                else
-                                       p_ptr->arena_number = 99;
+                                       p_ptr->arena_number = -1 - p_ptr->arena_number;
                                p_ptr->is_dead = FALSE;
                                p_ptr->chp = 0;
                                p_ptr->chp_frac = 0;