OSDN Git Service

ウィザードモードに職業を変える機能を追加(ただし、魔法領域の再設定などは行われず不完全であるので注意)
[hengband/hengband.git] / src / mspells1.c
index e4a1176..0048b65 100644 (file)
@@ -834,7 +834,7 @@ static bool spell_dispel(byte spell)
 /*
  * Check should monster cast dispel spell.
  */
-static bool dispel_check(int m_idx)
+bool dispel_check(int m_idx)
 {
        monster_type *m_ptr = &m_list[m_idx];
        monster_race *r_ptr = &r_info[m_ptr->r_idx];
@@ -924,7 +924,7 @@ static bool dispel_check(int m_idx)
 
        if (p_ptr->riding && (m_list[p_ptr->riding].mspeed < 135))
        {
-               if (m_list[p_ptr->riding].fast) return (TRUE);
+               if (MON_FAST(&m_list[p_ptr->riding])) return (TRUE);
        }
 
        /* No need to cast dispel spell */
@@ -1049,7 +1049,7 @@ static int choose_attack_spell(int m_idx, byte spells[], byte num)
        }
 
        /* Hurt badly or afraid, attempt to flee */
-       if (((m_ptr->hp < m_ptr->maxhp / 3) || m_ptr->monfear) && one_in_(2))
+       if (((m_ptr->hp < m_ptr->maxhp / 3) || MON_MONFEAR(m_ptr)) && one_in_(2))
        {
                /* Choose escape spell if possible */
                if (escape_num) return (escape[randint0(escape_num)]);
@@ -1137,7 +1137,7 @@ static int choose_attack_spell(int m_idx, byte spells[], byte num)
        }
 
        /* Cast globe of invulnerability if not already in effect */
-       if (invul_num && !(m_ptr->invulner) && (randint0(100) < 50))
+       if (invul_num && !m_ptr->mtimed[MTIMED_INVULNER] && (randint0(100) < 50))
        {
                /* Choose Globe of Invulnerability */
                return (invul[randint0(invul_num)]);
@@ -1151,7 +1151,7 @@ static int choose_attack_spell(int m_idx, byte spells[], byte num)
        }
 
        /* Haste self if we aren't already somewhat hasted (rarely) */
-       if (haste_num && (randint0(100) < 20) && !(m_ptr->fast))
+       if (haste_num && (randint0(100) < 20) && !MON_FAST(m_ptr))
        {
                /* Choose haste spell */
                return (haste[randint0(haste_num)]);
@@ -1192,6 +1192,48 @@ bool spell_is_inate(u16b spell)
 }
 
 
+static bool adjacent_grid_check(monster_type *m_ptr, int *yp, int *xp,
+       int f_flag, bool (*path_check)(int, int, int, int))
+{
+       int i;
+       int tonari;
+       static int tonari_y[4][8] = {{-1, -1, -1,  0,  0,  1,  1,  1},
+                                            {-1, -1, -1,  0,  0,  1,  1,  1},
+                                            { 1,  1,  1,  0,  0, -1, -1, -1},
+                                            { 1,  1,  1,  0,  0, -1, -1, -1}};
+       static int tonari_x[4][8] = {{-1,  0,  1, -1,  1, -1,  0,  1},
+                                            { 1,  0, -1,  1, -1,  1,  0, -1},
+                                            {-1,  0,  1, -1,  1, -1,  0,  1},
+                                            { 1,  0, -1,  1, -1,  1,  0, -1}};
+
+       if (m_ptr->fy < py && m_ptr->fx < px) tonari = 0;
+       else if (m_ptr->fy < py) tonari = 1;
+       else if (m_ptr->fx < px) tonari = 2;
+       else tonari = 3;
+
+       for (i = 0; i < 8; i++)
+       {
+               int next_x = *xp + tonari_x[tonari][i];
+               int next_y = *yp + tonari_y[tonari][i];
+               cave_type *c_ptr;
+
+               /* Access the next grid */
+               c_ptr = &cave[next_y][next_x];
+
+               /* Skip this feature */
+               if (!cave_have_flag_grid(c_ptr, f_flag)) continue;
+
+               if (path_check(m_ptr->fy, m_ptr->fx, next_y, next_x))
+               {
+                       *yp = next_y;
+                       *xp = next_x;
+                       return TRUE;
+               }
+       }
+
+       return FALSE;
+}
+
 #define DO_SPELL_NONE    0
 #define DO_SPELL_BR_LITE 1
 #define DO_SPELL_BR_DISI 2
@@ -1273,6 +1315,10 @@ bool make_attack_spell(int m_idx)
        int x = px;
        int y = py;
 
+       /* Target location for lite breath */
+       int x_br_lite = 0;
+       int y_br_lite = 0;
+
        /* Summon count */
        int count = 0;
 
@@ -1291,8 +1337,12 @@ bool make_attack_spell(int m_idx)
        bool in_no_magic_dungeon = (d_info[dungeon_type].flags1 & DF1_NO_MAGIC) && dun_level
                && (!p_ptr->inside_quest || is_fixed_quest_idx(p_ptr->inside_quest));
 
+       bool can_use_lite_area = FALSE;
+
+       bool can_remember;
+
        /* Cannot cast spells when confused */
-       if (m_ptr->confused)
+       if (MON_CONFUSED(m_ptr))
        {
                reset_target(m_ptr);
                return (FALSE);
@@ -1319,6 +1369,33 @@ bool make_attack_spell(int m_idx)
        /* Check range */
        if ((m_ptr->cdis > MAX_RANGE) && !m_ptr->target_y) return (FALSE);
 
+       /* Check path for lite breath */
+       if (f4 & RF4_BR_LITE)
+       {
+               y_br_lite = y;
+               x_br_lite = x;
+
+               if (los(m_ptr->fy, m_ptr->fx, y_br_lite, x_br_lite))
+               {
+                       feature_type *f_ptr = &f_info[cave[y_br_lite][x_br_lite].feat];
+
+                       if (!have_flag(f_ptr->flags, FF_LOS))
+                       {
+                               if (have_flag(f_ptr->flags, FF_PROJECT) && one_in_(2)) f4 &= ~(RF4_BR_LITE);
+                       }
+               }
+
+               /* Check path to next grid */
+               else if (!adjacent_grid_check(m_ptr, &y_br_lite, &x_br_lite, FF_LOS, los)) f4 &= ~(RF4_BR_LITE);
+
+               /* Don't breath lite to the wall if impossible */
+               if (!(f4 & RF4_BR_LITE))
+               {
+                       y_br_lite = 0;
+                       x_br_lite = 0;
+               }
+       }
+
        /* Check path */
        if (projectable(m_ptr->fy, m_ptr->fx, y, x))
        {
@@ -1347,8 +1424,7 @@ bool make_attack_spell(int m_idx)
                        success = TRUE;
                }
                else if ((f4 & RF4_BR_LITE) && (m_ptr->cdis < MAX_RANGE/2) &&
-                   los(m_ptr->fy, m_ptr->fx, y, x) &&
-                   (one_in_(10) || (projectable(y, x, m_ptr->fy, m_ptr->fx) && one_in_(2))))
+                   los(m_ptr->fy, m_ptr->fx, y, x) && one_in_(5))
                {
                        do_spell = DO_SPELL_BR_LITE;
                        success = TRUE;
@@ -1357,53 +1433,14 @@ bool make_attack_spell(int m_idx)
                {
                        int by = y, bx = x;
                        get_project_point(m_ptr->fy, m_ptr->fx, &by, &bx, 0L);
-                       if ((distance(by, bx, y, x) <= 3) && los(by, bx, y, x) &&
-                           (one_in_(10) || (projectable(y, x, m_ptr->fy, m_ptr->fx) && one_in_(2))))
+                       if ((distance(by, bx, y, x) <= 3) && los(by, bx, y, x) && one_in_(5))
                        {
                                do_spell = DO_SPELL_BA_LITE;
                                success = TRUE;
                        }
                }
 
-               if (!success)
-               {
-                       int i;
-                       int tonari;
-                       int tonari_y[4][8] = {{-1,-1,-1,0,0,1,1,1},
-                                             {-1,-1,-1,0,0,1,1,1},
-                                             {1,1,1,0,0,-1,-1,-1},
-                                             {1,1,1,0,0,-1,-1,-1}};
-                       int tonari_x[4][8] = {{-1,0,1,-1,1,-1,0,1},
-                                             {1,0,-1,1,-1,1,0,-1},
-                                             {-1,0,1,-1,1,-1,0,1},
-                                             {1,0,-1,1,-1,1,0,-1}};
-
-                       if (m_ptr->fy < py && m_ptr->fx < px) tonari = 0;
-                       else if (m_ptr->fy < py) tonari = 1;
-                       else if (m_ptr->fx < px) tonari = 2;
-                       else tonari = 3;
-
-                       for (i = 0; i < 8; i++)
-                       {
-                               int next_x = x + tonari_x[tonari][i];
-                               int next_y = y + tonari_y[tonari][i];
-                               cave_type *c_ptr;
-
-                               /* Access the next grid */
-                               c_ptr = &cave[next_y][next_x];
-
-                               /* Skip door, rubble, wall, tree, mountain, etc. */
-                               if (!have_flag(f_flags_grid(c_ptr), FF_PROJECT)) continue;
-
-                               if (projectable(m_ptr->fy, m_ptr->fx, next_y, next_x))
-                               {
-                                       y = next_y;
-                                       x = next_x;
-                                       success = TRUE;
-                                       break;
-                               }
-                       }
-               }
+               if (!success) success = adjacent_grid_check(m_ptr, &y, &x, FF_PROJECT, projectable);
 
                if (!success)
                {
@@ -1416,6 +1453,18 @@ bool make_attack_spell(int m_idx)
                                f6 &= (RF6_INDIRECT_MASK);
                                success = TRUE;
                        }
+
+                       if (y_br_lite && x_br_lite && (m_ptr->cdis < MAX_RANGE/2) && one_in_(5))
+                       {
+                               if (!success)
+                               {
+                                       y = y_br_lite;
+                                       x = x_br_lite;
+                                       do_spell = DO_SPELL_BR_LITE;
+                                       success = TRUE;
+                               }
+                               else f4 |= (RF4_BR_LITE);
+                       }
                }
 
                /* No spells */
@@ -1435,16 +1484,18 @@ bool make_attack_spell(int m_idx)
                f6 &= ~(RF6_NOMAGIC_MASK);
        }
 
-       if (!p_ptr->csp)
+       if (f6 & RF6_DARKNESS)
        {
-               f5 &= ~(RF5_DRAIN_MANA);
-       }
+               if ((p_ptr->pclass == CLASS_NINJA) &&
+                   !(r_ptr->flags3 & (RF3_UNDEAD | RF3_HURT_LITE)) &&
+                   !(r_ptr->flags7 & RF7_DARK_MASK))
+                       can_use_lite_area = TRUE;
 
-       if ((p_ptr->pclass == CLASS_NINJA) &&
-           ((r_ptr->flags3 & (RF3_UNDEAD | RF3_HURT_LITE)) ||
-            (r_ptr->flags7 & RF7_DARK_MASK)))
-       {
-               f6 &= ~(RF6_DARKNESS);
+               if (!(r_ptr->flags2 & RF2_STUPID))
+               {
+                       if (d_info[dungeon_type].flags1 & DF1_DARKNESS) f6 &= ~(RF6_DARKNESS);
+                       else if ((p_ptr->pclass == CLASS_NINJA) && !can_use_lite_area) f6 &= ~(RF6_DARKNESS);
+               }
        }
 
        if (in_no_magic_dungeon && !(r_ptr->flags2 & RF2_STUPID))
@@ -1493,6 +1544,8 @@ bool make_attack_spell(int m_idx)
 
        if (!(r_ptr->flags2 & RF2_STUPID))
        {
+               if (!p_ptr->csp) f5 &= ~(RF5_DRAIN_MANA);
+
                /* Check for a clean bolt shot */
                if (((f4 & RF4_BOLT_MASK) ||
                     (f5 & RF5_BOLT_MASK) ||
@@ -1612,7 +1665,7 @@ bool make_attack_spell(int m_idx)
 
        /* Check for spell failure (inate attacks never fail) */
        if (!spell_is_inate(thrown_spell)
-           && (in_no_magic_dungeon || (m_ptr->stunned && one_in_(2)) || (randint0(100) < failrate)))
+           && (in_no_magic_dungeon || (MON_STUNNED(m_ptr) && one_in_(2)) || (randint0(100) < failrate)))
        {
                disturb(1, 0);
                /* Message */
@@ -1625,9 +1678,22 @@ bool make_attack_spell(int m_idx)
                return (TRUE);
        }
 
+       /* Hex: Anti Magic Barrier */
+       if (!spell_is_inate(thrown_spell) && magic_barrier(m_idx))
+       {
+#ifdef JP
+               msg_format("È¿ËâË¡¥Ð¥ê¥¢¤¬%^s¤Î¼öʸ¤ò¤«¤­¾Ã¤·¤¿¡£", m_name);
+#else
+               msg_format("Anti magic barrier cancels the spell which %^s casts.");
+#endif
+               return (TRUE);
+       }
+
        /* Projectable? */
        direct = player_bold(y, x);
 
+       can_remember = is_original_ap_and_seen(m_ptr);
+
        /* Cast the spell. */
        switch (thrown_spell)
        {
@@ -1664,96 +1730,8 @@ msg_format("%^s
                        if (blind) msg_format("%^s mumbles powerfully.", m_name);
                        else msg_format("%^s invokes a dispel magic.", m_name);
 #endif
-                       set_fast(0, TRUE);
-                       set_lightspeed(0, TRUE);
-                       set_slow(0, TRUE);
-                       set_shield(0, TRUE);
-                       set_blessed(0, TRUE);
-                       set_tsuyoshi(0, TRUE);
-                       set_hero(0, TRUE);
-                       set_shero(0, TRUE);
-                       set_protevil(0, TRUE);
-                       set_invuln(0, TRUE);
-                       set_wraith_form(0, TRUE);
-                       set_kabenuke(0, TRUE);
-                       set_tim_res_nether(0, TRUE);
-                       set_tim_res_time(0, TRUE);
-                       /* by henkma */
-                       set_tim_reflect(0,TRUE);
-                       set_multishadow(0,TRUE);
-                       set_dustrobe(0,TRUE);
-
-                       set_tim_invis(0, TRUE);
-                       set_tim_infra(0, TRUE);
-                       set_tim_esp(0, TRUE);
-                       set_tim_regen(0, TRUE);
-                       set_tim_stealth(0, TRUE);
-                       set_tim_levitation(0, TRUE);
-                       set_tim_sh_touki(0, TRUE);
-                       set_tim_sh_fire(0, TRUE);
-                       set_tim_sh_holy(0, TRUE);
-                       set_tim_eyeeye(0, TRUE);
-                       set_magicdef(0, TRUE);
-                       set_resist_magic(0, TRUE);
-                       set_oppose_acid(0, TRUE);
-                       set_oppose_elec(0, TRUE);
-                       set_oppose_fire(0, TRUE);
-                       set_oppose_cold(0, TRUE);
-                       set_oppose_pois(0, TRUE);
-                       set_ultimate_res(0, TRUE);
-                       set_mimic(0, 0, TRUE);
-                       set_ele_attack(0, 0);
-                       set_ele_immune(0, 0);
-                       /* Cancel glowing hands */
-                       if (p_ptr->special_attack & ATTACK_CONFUSE)
-                       {
-                               p_ptr->special_attack &= ~(ATTACK_CONFUSE);
-#ifdef JP
-                               msg_print("¼ê¤Îµ±¤­¤¬¤Ê¤¯¤Ê¤Ã¤¿¡£");
-#else
-                               msg_print("Your hands stop glowing.");
-#endif
-
-                       }
-                       if ((p_ptr->pclass == CLASS_BARD) && (p_ptr->magic_num1[0]))
-                       {
-                               p_ptr->magic_num1[1] = p_ptr->magic_num1[0];
-                               p_ptr->magic_num1[0] = 0;
-#ifdef JP
-                               msg_print("²Î¤¬ÅÓÀڤ줿¡£");
-#else
-                               msg_print("Your singing is interrupted.");
-#endif
-                               p_ptr->action = ACTION_NONE;
-
-                               /* Recalculate bonuses */
-                               p_ptr->update |= (PU_BONUS | PU_HP);
-
-                               /* Redraw map */
-                               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);
-
-                               p_ptr->energy_need += ENERGY_NEED();
-                       }
-                       if (p_ptr->riding)
-                       {
-                               monster_type *riding_ptr = &m_list[p_ptr->riding];
-                               if (riding_ptr->invulner)
-                               {
-                                       riding_ptr->invulner = 0;
-                                       riding_ptr->energy_need += ENERGY_NEED();
-                               }
-                               riding_ptr->fast = 0;
-                               riding_ptr->slow = 0;
-                               p_ptr->update |= PU_BONUS;
-                               if (p_ptr->health_who == p_ptr->riding) p_ptr->redraw |= PR_HEALTH;
-                               p_ptr->redraw |= (PR_UHEALTH);
-                       }
+                       dispel_player();
+                       if (p_ptr->riding) dispel_monster_status(p_ptr->riding);
 
 #ifdef JP
                        if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
@@ -1980,7 +1958,7 @@ else msg_format("%^s
 #endif
 
                        dam = ((m_ptr->hp / 6) > 400 ? 400 : (m_ptr->hp / 6));
-                       breath(y, x, m_idx, GF_LITE, dam,0, TRUE, MS_BR_LITE, learnable);
+                       breath(y_br_lite, x_br_lite, m_idx, GF_LITE, dam,0, TRUE, MS_BR_LITE, learnable);
                        update_smart_learn(m_idx, DRS_LITE);
                        break;
                }
@@ -3239,16 +3217,14 @@ msg_format("%^s
                        }
 
                        /* Allow quick speed increases to base+10 */
-                       if (!m_ptr->fast)
+                       if (set_monster_fast(m_idx, MON_FAST(m_ptr) + 100))
                        {
 #ifdef JP
-msg_format("%^s¤ÎÆ°¤­¤¬Â®¤¯¤Ê¤Ã¤¿¡£", m_name);
+                               msg_format("%^s¤ÎÆ°¤­¤¬Â®¤¯¤Ê¤Ã¤¿¡£", m_name);
 #else
                                msg_format("%^s starts moving faster.", m_name);
 #endif
                        }
-                       m_ptr->fast = MIN(200, m_ptr->fast + 100);
-                       if (p_ptr->riding == m_idx) p_ptr->update |= PU_BONUS;
                        break;
                }
 
@@ -3351,18 +3327,17 @@ msg_format("%^s
                        if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
 
                        /* Cancel fear */
-                       if (m_ptr->monfear)
+                       if (MON_MONFEAR(m_ptr))
                        {
                                /* Cancel fear */
-                               m_ptr->monfear = 0;
+                               (void)set_monster_monfear(m_idx, 0);
 
                                /* Message */
 #ifdef JP
-msg_format("%^s¤Ïͦµ¤¤ò¼è¤êÌᤷ¤¿¡£", m_name);
+                               msg_format("%^s¤Ïͦµ¤¤ò¼è¤êÌᤷ¤¿¡£", m_name);
 #else
                                msg_format("%^s recovers %s courage.", m_name, m_poss);
 #endif
-
                        }
                        break;
                }
@@ -3392,11 +3367,7 @@ msg_format("%s
 
                        }
 
-                       if (!(m_ptr->invulner))
-                               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);
+                       if (!MON_INVULNER(m_ptr)) (void)set_monster_invulner(m_idx, randint1(4) + 4, FALSE);
                        break;
                }
 
@@ -3404,69 +3375,47 @@ msg_format("%s
                case 160+4:
                {
                        disturb(1, 0);
+                       if (teleport_barrier(m_idx))
+                       {
 #ifdef JP
-msg_format("%^s¤¬½Ö»þ¤Ë¾Ã¤¨¤¿¡£", m_name);
+                               msg_format("ËâË¡¤Î¥Ð¥ê¥¢¤¬%^s¤Î¥Æ¥ì¥Ý¡¼¥È¤ò¼ÙË⤷¤¿¡£", m_name);
 #else
-                       msg_format("%^s blinks away.", m_name);
+                               msg_format("Magic barrier obstructs teleporting of %^s.", m_name);
 #endif
-
-                       teleport_away(m_idx, 10, FALSE);
-                       p_ptr->update |= (PU_MONSTERS);
+                       }
+                       else
+                       {
+#ifdef JP
+                               msg_format("%^s¤¬½Ö»þ¤Ë¾Ã¤¨¤¿¡£", m_name);
+#else
+                               msg_format("%^s blinks away.", m_name);
+#endif
+                               teleport_away(m_idx, 10, 0L);
+                               p_ptr->update |= (PU_MONSTERS);
+                       }
                        break;
                }
 
                /* RF6_TPORT */
                case 160+5:
                {
-                       int i, oldfy, oldfx;
-                       u32b flgs[TR_FLAG_SIZE];
-                       object_type *o_ptr;
-
-                       oldfy = m_ptr->fy;
-                       oldfx = m_ptr->fx;
-
                        disturb(1, 0);
-#ifdef JP
-msg_format("%^s¤¬¥Æ¥ì¥Ý¡¼¥È¤·¤¿¡£", m_name);
-#else
-                       msg_format("%^s teleports away.", m_name);
-#endif
-
-                       teleport_away(m_idx, MAX_SIGHT * 2 + 5, FALSE);
-
-                       if (los(py, px, oldfy, oldfx) && !world_monster)
+                       if (teleport_barrier(m_idx))
                        {
-                               for (i=INVEN_RARM;i<INVEN_TOTAL;i++)
-                               {
-                                       o_ptr = &inventory[i];
-                                       if (!object_is_cursed(o_ptr))
-                                       {
-                                               object_flags(o_ptr, flgs);
-
-                                               if ((have_flag(flgs, TR_TELEPORT)) || (p_ptr->muta1 & MUT1_VTELEPORT) || (p_ptr->pclass == CLASS_IMITATOR))
-                                               {
 #ifdef JP
-                                                       if (get_check_strict("¤Ä¤¤¤Æ¤¤¤­¤Þ¤¹¤«¡©", CHECK_OKAY_CANCEL))
+                               msg_format("ËâË¡¤Î¥Ð¥ê¥¢¤¬%^s¤Î¥Æ¥ì¥Ý¡¼¥È¤ò¼ÙË⤷¤¿¡£", m_name);
 #else
-                                                       if (get_check_strict("Do you follow it? ", CHECK_OKAY_CANCEL))
+                               msg_format("Magic barrier obstructs teleporting of %^s.", m_name);
 #endif
-                                                       {
-                                                               if (one_in_(3))
-                                                               {
-                                                                       teleport_player(200, TRUE);
+                       }
+                       else
+                       {
 #ifdef JP
-                                                                       msg_print("¼ºÇÔ¡ª");
+                               msg_format("%^s¤¬¥Æ¥ì¥Ý¡¼¥È¤·¤¿¡£", m_name);
 #else
-                                                                       msg_print("Failed!");
+                               msg_format("%^s teleports away.", m_name);
 #endif
-                                                               }
-                                                               else teleport_player_to(m_ptr->fy, m_ptr->fx, TRUE, FALSE);
-                                                               p_ptr->energy_need += ENERGY_NEED();
-                                                       }
-                                                       break;
-                                               }
-                                       }
-                               }
+                               teleport_away_followable(m_idx);
                        }
                        break;
                }
@@ -3591,7 +3540,7 @@ msg_format("%^s
 #else
                                                msg_format("%^s suddenly go out of your sight!", m_name);
 #endif
-                                               teleport_away(m_idx, 10, FALSE);
+                                               teleport_away(m_idx, 10, TELEPORT_NONMAGICAL);
                                                p_ptr->update |= (PU_MONSTERS);
                                        }
                                        else
@@ -3600,12 +3549,12 @@ msg_format("%^s
                                                bool fear; /* dummy */
 
 #ifdef JP
-                                               msg_format("%^s¤¬¤¢¤Ê¤¿¤òÄϤó¤Ç¶õÃ椫¤éÅꤲÍ¤¿¡£", m_name);
+                                               msg_format("%^s¤¬¤¢¤Ê¤¿¤òÄϤó¤Ç¶õÃ椫¤éÅꤲÍî¤Ȥ·¤¿¡£", m_name);
 #else
                                                msg_format("%^s holds you, and drops from the sky.", m_name);
 #endif
                                                dam = damroll(4, 8);
-                                               teleport_player_to(m_ptr->fy, m_ptr->fx, FALSE, TRUE);
+                                               teleport_player_to(m_ptr->fy, m_ptr->fx, TELEPORT_NONMAGICAL | TELEPORT_PASSIVE);
 
                                                sound(SOUND_FALL);
 
@@ -3669,7 +3618,7 @@ msg_format("%^s
                        msg_format("%^s commands you to return.", m_name);
 #endif
 
-                       teleport_player_to(m_ptr->fy, m_ptr->fx, TRUE, TRUE);
+                       teleport_player_to(m_ptr->fy, m_ptr->fx, TELEPORT_PASSIVE);
                        learn_spell(MS_TELE_TO);
                        break;
                }
@@ -3688,7 +3637,7 @@ msg_format("%^s
 #endif
 
                        learn_spell(MS_TELE_AWAY);
-                       teleport_player(100, TRUE);
+                       teleport_player_away(m_idx, 100);
                        break;
                }
 
@@ -3764,25 +3713,25 @@ else msg_format("%^s
                        if (!direct) return (FALSE);
                        disturb(1, 0);
 #ifdef JP
-if (blind) msg_format("%^s¤¬²¿¤«¤ò¤Ä¤Ö¤ä¤¤¤¿¡£", m_name);
+                       if (blind) msg_format("%^s¤¬²¿¤«¤ò¤Ä¤Ö¤ä¤¤¤¿¡£", m_name);
 #else
                        if (blind) msg_format("%^s mumbles.", m_name);
 #endif
 
 #ifdef JP
-else if (p_ptr->pclass == CLASS_NINJA) msg_format("%^s¤¬ÊÕ¤ê¤òÌÀ¤ë¤¯¾È¤é¤·¤¿¡£", m_name);
-else msg_format("%^s¤¬°Å°Ç¤ÎÃæ¤Ç¼ê¤ò¿¶¤Ã¤¿¡£", m_name);
+                       else if (can_use_lite_area) msg_format("%^s¤¬ÊÕ¤ê¤òÌÀ¤ë¤¯¾È¤é¤·¤¿¡£", m_name);
+                       else msg_format("%^s¤¬°Å°Ç¤ÎÃæ¤Ç¼ê¤ò¿¶¤Ã¤¿¡£", m_name);
 #else
-                       else if (p_ptr->pclass == CLASS_NINJA)
-                               msg_format("%^s cast a spell to light up.", m_name);
+                       else if (can_use_lite_area) msg_format("%^s cast a spell to light up.", m_name);
                        else msg_format("%^s gestures in shadow.", m_name);
 #endif
 
-                       learn_spell(MS_DARKNESS);
-                       if (p_ptr->pclass == CLASS_NINJA)
-                               (void)lite_area(0, 3);
+                       if (can_use_lite_area) (void)lite_area(0, 3);
                        else
+                       {
+                               learn_spell(MS_DARKNESS);
                                (void)unlite_area(0, 3);
+                       }
                        break;
                }
 
@@ -4482,6 +4431,9 @@ msg_print("
                /* RF6_S_UNIQUE */
                case 160+31:
                {
+                       bool uniques_are_summoned = FALSE;
+                       int non_unique_type = SUMMON_HI_UNDEAD;
+
                        disturb(1, 0);
 #ifdef JP
 if (blind) msg_format("%^s¤¬²¿¤«¤ò¤Ä¤Ö¤ä¤¤¤¿¡£", m_name);
@@ -4499,28 +4451,26 @@ else msg_format("%^s
                        {
                                count += summon_specific(m_idx, y, x, rlev, SUMMON_UNIQUE, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE));
                        }
-                       if (r_ptr->flags3 & RF3_GOOD)
-                       {
-                               for (k = count; k < s_num_4; k++)
-                               {
-                                       count += summon_specific(m_idx, y, x, rlev, SUMMON_ANGEL, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE));
-                               }
-                       }
-                       else
+
+                       if (count) uniques_are_summoned = TRUE;
+
+                       if ((m_ptr->sub_align & (SUB_ALIGN_GOOD | SUB_ALIGN_EVIL)) == (SUB_ALIGN_GOOD | SUB_ALIGN_EVIL))
+                               non_unique_type = 0;
+                       else if (m_ptr->sub_align & SUB_ALIGN_GOOD)
+                               non_unique_type = SUMMON_ANGEL;
+
+                       for (k = count; k < s_num_4; k++)
                        {
-                               for (k = count; k < s_num_4; k++)
-                               {
-                                       count += summon_specific(m_idx, y, x, rlev, SUMMON_HI_UNDEAD, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE));
-                               }
+                               count += summon_specific(m_idx, y, x, rlev, non_unique_type, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE));
                        }
+
                        if (blind && count)
                        {
 #ifdef JP
-msg_print("¿¤¯¤ÎÎ϶¯¤¤¤â¤Î¤¬´Ö¶á¤Ë¸½¤ì¤¿²»¤¬Ê¹¤³¤¨¤ë¡£");
+                               msg_format("¿¤¯¤Î%s¤¬´Ö¶á¤Ë¸½¤ì¤¿²»¤¬Ê¹¤³¤¨¤ë¡£", uniques_are_summoned ? "Î϶¯¤¤¤â¤Î" : "¤â¤Î");
 #else
-                               msg_print("You hear many powerful things appear nearby.");
+                               msg_format("You hear many %s appear nearby.", uniques_are_summoned ? "powerful things" : "things");
 #endif
-
                        }
                        break;
                }
@@ -4550,12 +4500,12 @@ msg_print("¿
                        p_ptr->mane_num++;
                        new_mane = TRUE;
 
-                       p_ptr->redraw |= (PR_MANE);
+                       p_ptr->redraw |= (PR_IMITATION);
                }
        }
 
        /* Remember what the monster did to us */
-       if (seen && is_original_ap(m_ptr))
+       if (can_remember)
        {
                /* Inate spell */
                if (thrown_spell < 32 * 4)