OSDN Git Service

add type casting for fprintf
[hengband/hengband.git] / src / spells2.c
index 170f59c..2359722 100644 (file)
@@ -109,9 +109,9 @@ sprintf(Dummy, "
        info[i++] = "";
 
 #ifdef JP
-       sprintf(Dummy, "¸½ºß¤Î°À­ : %s(%ld)", your_alignment(), p_ptr->align);
+       sprintf(Dummy, "¸½ºß¤Î°À­ : %s(%ld)", your_alignment(), (long int)p_ptr->align);
 #else
-       sprintf(Dummy, "Your alighnment : %s(%ld)", your_alignment(), p_ptr->align);
+       sprintf(Dummy, "Your alighnment : %s(%ld)", your_alignment(), (long int)p_ptr->align);
 #endif
        strcpy(buf[1], Dummy);
        info[i++] = buf[1];
@@ -528,7 +528,7 @@ sprintf(Dummy, "
 
                        info[i++] = Dummy;
                        break;
-               case RACE_KUTA:
+               case RACE_KUTAR:
                        if (plev > 19)
 #ifdef JP
 info[i++] = "¤¢¤Ê¤¿¤Ï d20+30 ¥¿¡¼¥ó¤Î´Ö²£¤Ë¿­¤Ó¤ë¤³¤È¤¬¤Ç¤­¤ë¡£(15 MP)";
@@ -588,8 +588,9 @@ info[i++] = "
 #endif
                        }
                        break;
-               case CLASS_MAGE:
                case CLASS_HIGH_MAGE:
+                       if (p_ptr->realm1 == REALM_HEX) break;
+               case CLASS_MAGE:
                case CLASS_SORCERER:
                        if (plev > 24)
                        {
@@ -749,7 +750,7 @@ info[i++] = "
                        break;
                case CLASS_BEASTMASTER:
 #ifdef JP
-info[i++] = "¤¢¤Ê¤¿¤Ï1ɤ¤ÎÀ¸Ì¿¤Î¤¢¤ë¥â¥ó¥¹¥¿¡¼¤ò»ÙÇÛ¤¹¤ë¤³¤È¤¬¤Ç¤­¤ë¡£(¥ì¥Ù¥ë/4 MP)";
+info[i++] = "¤¢¤Ê¤¿¤Ï1ÂΤÎÀ¸Ì¿¤Î¤¢¤ë¥â¥ó¥¹¥¿¡¼¤ò»ÙÇÛ¤¹¤ë¤³¤È¤¬¤Ç¤­¤ë¡£(¥ì¥Ù¥ë/4 MP)";
 #else
                        info[i++] = "You can dominate a monster (cost level/4).";
 #endif
@@ -773,9 +774,9 @@ info[i++] = "
                        if (plev > 47)
                        {
 #ifdef JP
-info[i++] = "¤¢¤Ê¤¿¤Ï1¥¿¡¼¥ó¤Ë2²óËâË¡¤ò¾§¤¨¤ë¤³¤È¤¬¤Ç¤­¤ë¡£(77 MP)";
+info[i++] = "¤¢¤Ê¤¿¤Ï1¥¿¡¼¥ó¤Ë2²óËâË¡¤ò¾§¤¨¤ë¤³¤È¤¬¤Ç¤­¤ë¡£(20 MP)";
 #else
-                               info[i++] = "You can cast two spells in one time (cost 77).";
+                               info[i++] = "You can cast two spells in one time (cost 20).";
 #endif
                        }
                        break;
@@ -3845,11 +3846,12 @@ bool detect_objects_magic(int range)
                    (tv == TV_DEATH_BOOK) ||
                    (tv == TV_TRUMP_BOOK) ||
                        (tv == TV_ARCANE_BOOK) ||
-                       (tv == TV_ENCHANT_BOOK) ||
+                       (tv == TV_CRAFT_BOOK) ||
                        (tv == TV_DAEMON_BOOK) ||
                        (tv == TV_CRUSADE_BOOK) ||
                        (tv == TV_MUSIC_BOOK) ||
                        (tv == TV_HISSATSU_BOOK) ||
+                       (tv == TV_HEX_BOOK) ||
                    ((o_ptr->to_a > 0) || (o_ptr->to_h + o_ptr->to_d > 0)))
                {
                        /* Memorize the item */
@@ -4605,17 +4607,9 @@ void aggravate_monsters(int who)
                if (m_ptr->cdis < MAX_SIGHT * 2)
                {
                        /* Wake up */
-                       if (m_ptr->csleep)
+                       if (MON_CSLEEP(m_ptr))
                        {
-                               /* Wake up */
-                               m_ptr->csleep = 0;
-                               if (r_info[m_ptr->r_idx].flags7 & RF7_HAS_LD_MASK) p_ptr->update |= (PU_MON_LITE);
-                               if (m_ptr->ml)
-                               {
-                                       /* Redraw (later) if needed */
-                                       if (p_ptr->health_who == i) p_ptr->redraw |= (PR_HEALTH);
-                                       if (p_ptr->riding == i) p_ptr->redraw |= (PR_UHEALTH);
-                               }
+                               (void)set_monster_csleep(i, 0);
                                sleep = TRUE;
                        }
                        if (!is_pet(m_ptr)) m_ptr->mflag2 |= MFLAG2_NOPET;
@@ -4626,7 +4620,7 @@ void aggravate_monsters(int who)
                {
                        if (!is_pet(m_ptr))
                        {
-                               m_ptr->fast = MIN(200, m_ptr->fast + 100);
+                               (void)set_monster_fast(i, MON_FAST(m_ptr) + 100);
                                speed = TRUE;
                        }
                }
@@ -4663,12 +4657,25 @@ bool genocide_aux(int m_idx, int power, bool player_cast, int dam_side, cptr spe
 
        else if (m_idx == p_ptr->riding) resist = TRUE;
 
+       else if ((p_ptr->inside_quest && !random_quest_number(dun_level)) || p_ptr->inside_arena || p_ptr->inside_battle) resist = TRUE;
+
        else if (player_cast && (r_ptr->level > randint0(power))) resist = TRUE;
 
        else if (player_cast && (m_ptr->mflag2 & MFLAG2_NOGENO)) resist = TRUE;
 
        /* Delete the monster */
-       else delete_monster_idx(m_idx);
+       else
+       {
+               if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
+               {
+                       char m_name[80];
+
+                       monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
+                       do_cmd_write_nikki(NIKKI_NAMED_PET, RECORD_NAMED_PET_GENOCIDE, m_name);
+               }
+
+               delete_monster_idx(m_idx);
+       }
 
        if (resist && player_cast)
        {
@@ -4684,18 +4691,11 @@ bool genocide_aux(int m_idx, int power, bool player_cast, int dam_side, cptr spe
                        msg_format("%^s is unaffected.", m_name);
 #endif
                }
-               if (m_ptr->csleep)
+               if (MON_CSLEEP(m_ptr))
                {
-                       m_ptr->csleep = 0;
-                       if (r_ptr->flags7 & RF7_HAS_LD_MASK) p_ptr->update |= (PU_MON_LITE);
+                       (void)set_monster_csleep(m_idx, 0);
                        if (m_ptr->ml)
                        {
-                               /* Redraw (later) if needed */
-                               if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
-                               if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
-                       }
-                       if (see_m)
-                       {
 #ifdef JP
                                msg_format("%^s¤¬Ìܤò³Ð¤Þ¤·¤¿¡£", m_name);
 #else
@@ -4760,7 +4760,7 @@ bool symbol_genocide(int power, bool player_cast)
        bool result = FALSE;
 
        /* Prevent genocide in quest levels */
-       if (p_ptr->inside_quest && !random_quest_number(dun_level))
+       if ((p_ptr->inside_quest && !random_quest_number(dun_level)) || p_ptr->inside_arena || p_ptr->inside_battle)
        {
                return (FALSE);
        }
@@ -4811,7 +4811,7 @@ bool mass_genocide(int power, bool player_cast)
        bool result = FALSE;
 
        /* Prevent mass genocide in quest levels */
-       if (p_ptr->inside_quest && !random_quest_number(dun_level))
+       if ((p_ptr->inside_quest && !random_quest_number(dun_level)) || p_ptr->inside_arena || p_ptr->inside_battle)
        {
                return (FALSE);
        }
@@ -4855,7 +4855,7 @@ bool mass_genocide_undead(int power, bool player_cast)
        bool result = FALSE;
 
        /* Prevent mass genocide in quest levels */
-       if (p_ptr->inside_quest && !random_quest_number(dun_level))
+       if ((p_ptr->inside_quest && !random_quest_number(dun_level)) || p_ptr->inside_arena || p_ptr->inside_battle)
        {
                return (FALSE);
        }
@@ -4938,7 +4938,7 @@ bool probing(void)
 
                        msg_print(NULL);
 
-                       if (m_ptr->ap_r_idx != m_ptr->r_idx)
+                       if (!is_original_ap(m_ptr))
                        {
                                if (m_ptr->mflag2 & MFLAG2_KAGE)
                                        m_ptr->mflag2 &= ~(MFLAG2_KAGE);
@@ -4950,8 +4950,8 @@ bool probing(void)
                        monster_desc(m_name, m_ptr, MD_IGNORE_HALLU | MD_INDEF_HIDDEN);
 
                        speed = m_ptr->mspeed - 110;
-                       if(m_ptr->fast) speed += 10;
-                       if(m_ptr->slow) speed -= 10;
+                       if (MON_FAST(m_ptr)) speed += 10;
+                       if (MON_SLOW(m_ptr)) speed -= 10;
 
                        /* Get the monster's alignment */
 #ifdef JP
@@ -4988,17 +4988,17 @@ sprintf(buf, "%s ... align:%s HP:%d/%d AC:%d speed:%s%d exp:", m_name, align, m_
                        }
 
 #ifdef JP
-                       if (m_ptr->csleep) strcat(buf,"¿ç̲ ");
-                       if (m_ptr->stunned) strcat(buf,"ۯ۰ ");
-                       if (m_ptr->monfear) strcat(buf,"¶²ÉÝ ");
-                       if (m_ptr->confused) strcat(buf,"º®Íð ");
-                       if (m_ptr->invulner) strcat(buf,"̵Ũ ");
+                       if (MON_CSLEEP(m_ptr)) strcat(buf,"¿ç̲ ");
+                       if (MON_STUNNED(m_ptr)) strcat(buf,"ۯ۰ ");
+                       if (MON_MONFEAR(m_ptr)) strcat(buf,"¶²ÉÝ ");
+                       if (MON_CONFUSED(m_ptr)) strcat(buf,"º®Íð ");
+                       if (MON_INVULNER(m_ptr)) strcat(buf,"̵Ũ ");
 #else
-                       if (m_ptr->csleep) strcat(buf,"sleeping ");
-                       if (m_ptr->stunned) strcat(buf,"stunned ");
-                       if (m_ptr->monfear) strcat(buf,"scared ");
-                       if (m_ptr->confused) strcat(buf,"confused ");
-                       if (m_ptr->invulner) strcat(buf,"invulnerable ");
+                       if (MON_CSLEEP(m_ptr)) strcat(buf,"sleeping ");
+                       if (MON_STUNNED(m_ptr)) strcat(buf,"stunned ");
+                       if (MON_MONFEAR(m_ptr)) strcat(buf,"scared ");
+                       if (MON_CONFUSED(m_ptr)) strcat(buf,"confused ");
+                       if (MON_INVULNER(m_ptr)) strcat(buf,"invulnerable ");
 #endif
                        buf[strlen(buf)-1] = '\0';
                        prt(buf,0,0);
@@ -5144,7 +5144,7 @@ bool destroy_area(int y1, int x1, int r, bool in_generate)
                                        m_ptr->hp = m_ptr->maxhp;
 
                                        /* Try to teleport away quest monsters */
-                                       if (!teleport_away(c_ptr->m_idx, (r * 2) + 1, TRUE, FALSE)) continue;
+                                       if (!teleport_away(c_ptr->m_idx, (r * 2) + 1, TELEPORT_DEC_VALOUR)) continue;
                                }
                                else
                                {
@@ -5153,7 +5153,7 @@ bool destroy_area(int y1, int x1, int r, bool in_generate)
                                                char m_name[80];
 
                                                monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
-                                               do_cmd_write_nikki(NIKKI_NAMED_PET, 6, m_name);
+                                               do_cmd_write_nikki(NIKKI_NAMED_PET, RECORD_NAMED_PET_DESTROY, m_name);
                                        }
 
                                        /* Delete the monster (if any) */
@@ -5219,17 +5219,17 @@ bool destroy_area(int y1, int x1, int r, bool in_generate)
                                        if (t < 20)
                                        {
                                                /* Create granite wall */
-                                               cave_set_feat(y, x, FEAT_WALL);
+                                               cave_set_feat(y, x, feat_granite);
                                        }
                                        else if (t < 70)
                                        {
                                                /* Create quartz vein */
-                                               cave_set_feat(y, x, FEAT_QUARTZ);
+                                               cave_set_feat(y, x, feat_quartz_vein);
                                        }
                                        else if (t < 100)
                                        {
                                                /* Create magma vein */
-                                               cave_set_feat(y, x, FEAT_MAGMA);
+                                               cave_set_feat(y, x, feat_magma_vein);
                                        }
                                        else
                                        {
@@ -5247,12 +5247,12 @@ bool destroy_area(int y1, int x1, int r, bool in_generate)
                                        else if (t < 70)
                                        {
                                                /* Create quartz vein */
-                                               c_ptr->feat = FEAT_QUARTZ;
+                                               c_ptr->feat = feat_quartz_vein;
                                        }
                                        else if (t < 100)
                                        {
                                                /* Create magma vein */
-                                               c_ptr->feat = FEAT_MAGMA;
+                                               c_ptr->feat = feat_magma_vein;
                                        }
                                        else
                                        {
@@ -5369,7 +5369,7 @@ bool destroy_area(int y1, int x1, int r, bool in_generate)
  * for a single turn, unless that monster can pass_walls or kill_walls.
  * This has allowed massive simplification of the "monster" code.
  */
-bool earthquake(int cy, int cx, int r)
+bool earthquake_aux(int cy, int cx, int r, int m_idx)
 {
        int             i, t, y, x, yy, xx, dy, dx;
        int             damage = 0;
@@ -5469,31 +5469,28 @@ bool earthquake(int cy, int cx, int r)
                        case 1:
                        {
 #ifdef JP
-msg_print("¥À¥ó¥¸¥ç¥ó¤ÎÊɤ¬Êø¤ì¤¿¡ª");
+                               msg_print("¥À¥ó¥¸¥ç¥ó¤ÎÊɤ¬Êø¤ì¤¿¡ª");
 #else
                                msg_print("The cave ceiling collapses!");
 #endif
-
                                break;
                        }
                        case 2:
                        {
 #ifdef JP
-msg_print("¥À¥ó¥¸¥ç¥ó¤Î¾²¤¬ÉÔ¼«Á³¤Ë¤Í¤¸¶Ê¤¬¤Ã¤¿¡ª");
+                               msg_print("¥À¥ó¥¸¥ç¥ó¤Î¾²¤¬ÉÔ¼«Á³¤Ë¤Í¤¸¶Ê¤¬¤Ã¤¿¡ª");
 #else
                                msg_print("The cave floor twists in an unnatural way!");
 #endif
-
                                break;
                        }
                        default:
                        {
 #ifdef JP
-msg_print("¥À¥ó¥¸¥ç¥ó¤¬Íɤ줿¡ªÊø¤ì¤¿´ä¤¬Æ¬¤Ë¹ß¤Ã¤Æ¤­¤¿¡ª");
+                               msg_print("¥À¥ó¥¸¥ç¥ó¤¬Íɤ줿¡ªÊø¤ì¤¿´ä¤¬Æ¬¤Ë¹ß¤Ã¤Æ¤­¤¿¡ª");
 #else
                                msg_print("The cave quakes!  You are pummeled with debris!");
 #endif
-
                                break;
                        }
                }
@@ -5503,11 +5500,10 @@ msg_print("
                {
                        /* Message and damage */
 #ifdef JP
-msg_print("¤¢¤Ê¤¿¤Ï¤Ò¤É¤¤²ø²æ¤òÉé¤Ã¤¿¡ª");
+                       msg_print("¤¢¤Ê¤¿¤Ï¤Ò¤É¤¤²ø²æ¤òÉé¤Ã¤¿¡ª");
 #else
                        msg_print("You are severely crushed!");
 #endif
-
                        damage = 200;
                }
 
@@ -5520,22 +5516,20 @@ msg_print("
                                case 1:
                                {
 #ifdef JP
-msg_print("¹ß¤êÃí¤°´ä¤ò¤¦¤Þ¤¯Èò¤±¤¿¡ª");
+                                       msg_print("¹ß¤êÃí¤°´ä¤ò¤¦¤Þ¤¯Èò¤±¤¿¡ª");
 #else
                                        msg_print("You nimbly dodge the blast!");
 #endif
-
                                        damage = 0;
                                        break;
                                }
                                case 2:
                                {
 #ifdef JP
-msg_print("´äÀФ¬¤¢¤Ê¤¿¤Ëľ·â¤·¤¿!");
+                                       msg_print("´äÀФ¬¤¢¤Ê¤¿¤Ëľ·â¤·¤¿!");
 #else
                                        msg_print("You are bashed by rubble!");
 #endif
-
                                        damage = damroll(10, 4);
                                        (void)set_stun(p_ptr->stun + randint1(50));
                                        break;
@@ -5543,11 +5537,10 @@ msg_print("
                                case 3:
                                {
 #ifdef JP
-msg_print("¤¢¤Ê¤¿¤Ï¾²¤ÈÊɤȤδ֤˶´¤Þ¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª");
+                                       msg_print("¤¢¤Ê¤¿¤Ï¾²¤ÈÊɤȤδ֤˶´¤Þ¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª");
 #else
                                        msg_print("You are crushed between the floor and ceiling!");
 #endif
-
                                        damage = damroll(10, 4);
                                        (void)set_stun(p_ptr->stun + randint1(50));
                                        break;
@@ -5562,12 +5555,35 @@ msg_print("
                map[16+py-cy][16+px-cx] = FALSE;
 
                /* Take some damage */
+               if (damage)
+               {
+                       char *killer;
+
+                       if (m_idx)
+                       {
+                               char m_name[80];
+                               monster_type *m_ptr = &m_list[m_idx];
+
+                               /* Get the monster's real name */
+                               monster_desc(m_name, m_ptr, MD_IGNORE_HALLU | MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE);
+
 #ifdef JP
-if (damage) take_hit(DAMAGE_ATTACK, damage, "ÃÏ¿Ì", -1);
+                               killer = format("%s¤Îµ¯¤³¤·¤¿ÃÏ¿Ì", m_name);
 #else
-               if (damage) take_hit(DAMAGE_ATTACK, damage, "an earthquake", -1);
+                               killer = format("an earthquake caused by %s", m_name);
 #endif
+                       }
+                       else
+                       {
+#ifdef JP
+                               killer = "ÃÏ¿Ì";
+#else
+                               killer = "an earthquake";
+#endif
+                       }
 
+                       take_hit(DAMAGE_ATTACK, damage, killer, -1);
+               }
        }
 
        /* Examine the quaked region */
@@ -5653,17 +5669,16 @@ if (damage) take_hit(DAMAGE_ATTACK, damage, "
 
                                        /* Scream in pain */
 #ifdef JP
-msg_format("%^s¤Ï¶ìÄˤǵ㤭¤ï¤á¤¤¤¿¡ª", m_name);
+                                       if (!ignore_unview || is_seen(m_ptr)) msg_format("%^s¤Ï¶ìÄˤǵ㤭¤ï¤á¤¤¤¿¡ª", m_name);
 #else
-                                       msg_format("%^s wails out in pain!", m_name);
+                                       if (!ignore_unview || is_seen(m_ptr)) msg_format("%^s wails out in pain!", m_name);
 #endif
 
-
                                        /* Take damage from the quake */
                                        damage = (sn ? damroll(4, 8) : (m_ptr->hp + 1));
 
                                        /* Monster is certainly awake */
-                                       m_ptr->csleep = 0;
+                                       (void)set_monster_csleep(c_ptr->m_idx, 0);
 
                                        /* Apply damage directly */
                                        m_ptr->hp -= damage;
@@ -5673,9 +5688,9 @@ msg_format("%^s
                                        {
                                                /* Message */
 #ifdef JP
-msg_format("%^s¤Ï´äÀФËËä¤â¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª", m_name);
+                                               if (!ignore_unview || is_seen(m_ptr)) msg_format("%^s¤Ï´äÀФËËä¤â¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª", m_name);
 #else
-                                               msg_format("%^s is embedded in the rock!", m_name);
+                                               if (!ignore_unview || is_seen(m_ptr)) msg_format("%^s is embedded in the rock!", m_name);
 #endif
 
                                                if (c_ptr->m_idx)
@@ -5685,7 +5700,7 @@ msg_format("%^s
                                                                char m2_name[80];
 
                                                                monster_desc(m2_name, m_ptr, MD_INDEF_VISIBLE);
-                                                               do_cmd_write_nikki(NIKKI_NAMED_PET, 7, m2_name);
+                                                               do_cmd_write_nikki(NIKKI_NAMED_PET, RECORD_NAMED_PET_EARTHQUAKE, m2_name);
                                                        }
                                                }
 
@@ -5701,12 +5716,12 @@ msg_format("%^s
                                        {
                                                int m_idx = cave[yy][xx].m_idx;
 
-                                               /* Update the new location */
-                                               cave[sy][sx].m_idx = m_idx;
-
                                                /* Update the old location */
                                                cave[yy][xx].m_idx = 0;
 
+                                               /* Update the new location */
+                                               cave[sy][sx].m_idx = m_idx;
+
                                                /* Move the monster */
                                                m_ptr->fy = sy;
                                                m_ptr->fx = sx;
@@ -5759,21 +5774,21 @@ msg_format("%^s
                                if (t < 20)
                                {
                                        /* Create granite wall */
-                                       cave_set_feat(yy, xx, FEAT_WALL);
+                                       cave_set_feat(yy, xx, feat_granite);
                                }
 
                                /* Quartz */
                                else if (t < 70)
                                {
                                        /* Create quartz vein */
-                                       cave_set_feat(yy, xx, FEAT_QUARTZ);
+                                       cave_set_feat(yy, xx, feat_quartz_vein);
                                }
 
                                /* Magma */
                                else if (t < 100)
                                {
                                        /* Create magma vein */
-                                       cave_set_feat(yy, xx, FEAT_MAGMA);
+                                       cave_set_feat(yy, xx, feat_magma_vein);
                                }
 
                                /* Floor */
@@ -5852,6 +5867,11 @@ msg_format("%^s
        return (TRUE);
 }
 
+bool earthquake(int cy, int cx, int r)
+{
+       return earthquake_aux(cy, cx, r, 0);
+}
+
 
 void discharge_minion(void)
 {
@@ -5902,6 +5922,15 @@ void discharge_minion(void)
                project(i, 2+(r_ptr->level/20), m_ptr->fy,
                        m_ptr->fx, dam, GF_PLASMA, 
                        PROJECT_STOP | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL, -1);
+
+               if (record_named_pet && m_ptr->nickname)
+               {
+                       char m_name[80];
+
+                       monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
+                       do_cmd_write_nikki(NIKKI_NAMED_PET, RECORD_NAMED_PET_BLAST, m_name);
+               }
+
                delete_monster_idx(i);
        }
 }
@@ -5962,15 +5991,13 @@ static void cave_temp_room_lite(void)
                        if (r_ptr->flags2 & (RF2_SMART)) chance = 100;
 
                        /* Sometimes monsters wake up */
-                       if (m_ptr->csleep && (randint0(100) < chance))
+                       if (MON_CSLEEP(m_ptr) && (randint0(100) < chance))
                        {
                                /* Wake up! */
-                               m_ptr->csleep = 0;
-
-                               if (r_ptr->flags7 & RF7_HAS_LD_MASK) p_ptr->update |= (PU_MON_LITE);
+                               (void)set_monster_csleep(c_ptr->m_idx, 0);
 
                                /* Notice the "waking up" */
-                               if (is_seen(m_ptr))
+                               if (m_ptr->ml)
                                {
                                        char m_name[80];
 
@@ -5979,18 +6006,11 @@ static void cave_temp_room_lite(void)
 
                                        /* Dump a message */
 #ifdef JP
-msg_format("%^s¤¬Ìܤò³Ð¤Þ¤·¤¿¡£", m_name);
+                                       msg_format("%^s¤¬Ìܤò³Ð¤Þ¤·¤¿¡£", m_name);
 #else
                                        msg_format("%^s wakes up.", m_name);
 #endif
                                }
-
-                               if (m_ptr->ml)
-                               {
-                                       /* Redraw the health bar */
-                                       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);
-                               }
                        }
                }
 
@@ -6040,24 +6060,27 @@ static void cave_temp_room_unlite(void)
                /* Darken the grid */
                if (do_dark)
                {
-                       for (j = 0; j < 9; j++)
+                       if (dun_level || !is_daytime())
                        {
-                               int by = y + ddy_ddd[j];
-                               int bx = x + ddx_ddd[j];
-
-                               if (in_bounds2(by, bx))
+                               for (j = 0; j < 9; j++)
                                {
-                                       cave_type *cc_ptr = &cave[by][bx];
+                                       int by = y + ddy_ddd[j];
+                                       int bx = x + ddx_ddd[j];
 
-                                       if (have_flag(f_info[get_feat_mimic(cc_ptr)].flags, FF_GLOW))
+                                       if (in_bounds2(by, bx))
                                        {
-                                               do_dark = FALSE;
-                                               break;
+                                               cave_type *cc_ptr = &cave[by][bx];
+
+                                               if (have_flag(f_info[get_feat_mimic(cc_ptr)].flags, FF_GLOW))
+                                               {
+                                                       do_dark = FALSE;
+                                                       break;
+                                               }
                                        }
                                }
-                       }
 
-                       if (!do_dark) continue;
+                               if (!do_dark) continue;
+                       }
 
                        c_ptr->info &= ~(CAVE_GLOW);
 
@@ -6504,7 +6527,7 @@ bool fire_blast(int typ, int dir, int dd, int ds, int num, int dev)
        }
 
        /* Use an actual "target" */
-       else if (dir == 5)
+       else /* if (dir == 5) */
        {
                tx = target_col;
                ty = target_row;
@@ -6600,8 +6623,7 @@ msg_print("
        m_ptr = &m_list[c_ptr->m_idx];
        r_ptr = &r_info[m_ptr->r_idx];
 
-       /* Redraw the health bar */
-       if (p_ptr->health_who == c_ptr->m_idx) p_ptr->redraw |= (PR_HEALTH);
+       (void)set_monster_csleep(c_ptr->m_idx, 0);
 
        if (r_ptr->flagsr & RFR_RES_TELE)
        {
@@ -6613,9 +6635,6 @@ 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);
-
                /* Failure */
                return FALSE;
        }
@@ -6623,7 +6642,7 @@ msg_print("
        sound(SOUND_TELEPORT);
 
        /* Swap the player and monster */
-       (void)move_player_effect(ty, tx, MPE_HANDLE_STUFF | MPE_DONT_PICKUP);
+       (void)move_player_effect(ty, tx, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP);
 
        /* Success */
        return TRUE;
@@ -7003,7 +7022,7 @@ msg_print("
                                msg_print("Space warps about you!");
 #endif
 
-                               teleport_player(damroll(10, 10), TRUE);
+                               teleport_player(damroll(10, 10), TELEPORT_PASSIVE);
                                if (randint0(13)) (*count) += activate_hi_summon(py, px, FALSE);
                                if (!one_in_(6)) break;
                        }
@@ -7382,14 +7401,15 @@ bool charm_living(int dir, int plev)
 }
 
 
-void kawarimi(bool success)
+bool kawarimi(bool success)
 {
        object_type forge;
        object_type *q_ptr = &forge;
        int y, x;
 
-       if (p_ptr->confused || p_ptr->blind || p_ptr->paralyzed || p_ptr->image) return;
-       if (randint0(200) < p_ptr->stun) return;
+       if (p_ptr->is_dead) return FALSE;
+       if (p_ptr->confused || p_ptr->blind || p_ptr->paralyzed || p_ptr->image) return FALSE;
+       if (randint0(200) < p_ptr->stun) return FALSE;
 
        if (!success && one_in_(3))
        {
@@ -7400,13 +7420,13 @@ void kawarimi(bool success)
 #endif
                p_ptr->special_defense &= ~(NINJA_KAWARIMI);
                p_ptr->redraw |= (PR_STATUS);
-               return;
+               return FALSE;
        }
 
        y = py;
        x = px;
 
-       teleport_player(10 + randint1(90), FALSE);
+       teleport_player(10 + randint1(90), 0L);
 
        object_wipe(q_ptr);
 
@@ -7427,6 +7447,9 @@ void kawarimi(bool success)
 
        p_ptr->special_defense &= ~(NINJA_KAWARIMI);
        p_ptr->redraw |= (PR_STATUS);
+
+       /* Teleported */
+       return TRUE;
 }
 
 
@@ -7442,6 +7465,7 @@ bool rush_attack(bool *mdeath)
        u16b path_g[32];
        int path_n, i;
        bool tmp_mdeath = FALSE;
+       bool moved = FALSE;
 
        if (mdeath) *mdeath = FALSE;
 
@@ -7512,7 +7536,7 @@ bool rush_attack(bool *mdeath)
                }
 
                /* Move player before updating the monster */
-               if (!player_bold(ty, tx)) teleport_player_to(ty, tx, FALSE, FALSE);
+               if (!player_bold(ty, tx)) teleport_player_to(ty, tx, TELEPORT_NONMAGICAL);
 
                /* Update the monster */
                update_mon(cave[ny][nx].m_idx, TRUE);
@@ -7543,12 +7567,14 @@ bool rush_attack(bool *mdeath)
 #endif
                }
 
+               if (!player_bold(ty, tx)) teleport_player_to(ty, tx, TELEPORT_NONMAGICAL);
+               moved = TRUE;
                tmp_mdeath = py_attack(ny, nx, HISSATSU_NYUSIN);
 
                break;
        }
 
-       if (!player_bold(ty, tx)) teleport_player_to(ty, tx, FALSE, FALSE);
+       if (!moved && !player_bold(ty, tx)) teleport_player_to(ty, tx, TELEPORT_NONMAGICAL);
 
        if (mdeath) *mdeath = tmp_mdeath;
        return TRUE;