OSDN Git Service

This commit was manufactured by cvs2svn to create tag
[hengband/hengband.git] / src / mspells2.c
index dd795e4..3a86bca 100644 (file)
@@ -20,7 +20,7 @@
  */
 static void monst_breath_monst(int m_idx, int y, int x, int typ, int dam_hp, int rad, bool breath, int monspell, bool learnable)
 {
-       int flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_MONSTER;
+       int flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
 
        monster_type *m_ptr = &m_list[m_idx];
        monster_race *r_ptr = &r_info[m_ptr->r_idx];
@@ -44,14 +44,14 @@ static void monst_breath_monst(int m_idx, int y, int x, int typ, int dam_hp, int
  */
 static void monst_bolt_monst(int m_idx, int y, int x, int typ, int dam_hp, int monspell, bool learnable)
 {
-       int flg = PROJECT_STOP | PROJECT_KILL | PROJECT_MONSTER | PROJECT_REFLECTABLE;
+       int flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
 
        (void)project(m_idx, 0, y, x, dam_hp, typ, flg, (learnable ? monspell : -1));
 }
 
 static void monst_beam_monst(int m_idx, int y, int x, int typ, int dam_hp, int monspell, bool learnable)
 {
-       int flg = PROJECT_BEAM | PROJECT_KILL | PROJECT_THRU | PROJECT_MONSTER;
+       int flg = PROJECT_BEAM | PROJECT_KILL | PROJECT_THRU;
 
        (void)project(m_idx, 0, y, x, dam_hp, typ, flg, (learnable ? monspell : -1));
 }
@@ -89,7 +89,7 @@ static bool direct_beam(int y1, int x1, int y2, int x2, monster_type *m_ptr)
                        return FALSE;
                }
 
-               if (friend && y == py && x == px)
+               if (friend && player_bold(y, x))
                        return FALSE;
        }
        if (!hit2)
@@ -101,7 +101,11 @@ static bool breath_direct(int y1, int x1, int y2, int x2, int rad, bool disint_b
 {
        /* Must be the same as projectable() */
 
-       int i, y, x;
+       int i;
+
+       /* Initial grid */
+       int y = y1;
+       int x = x1;
 
        int grid_n = 0;
        u16b grid_g[512];
@@ -116,53 +120,89 @@ static bool breath_direct(int y1, int x1, int y2, int x2, int rad, bool disint_b
 
        /* Check the projection path */
        grid_n = project_path(grid_g, MAX_RANGE, y1, x1, y2, x2, disint_ball ? PROJECT_DISI : 0);
-       breath_shape(grid_g, grid_n, &grids, gx, gy, gm, &gm_rad, rad, y1, x1, y2, x2, disint_ball, FALSE);
 
-       for (i = 0; i < grids; i++)
+       /* Project along the path */
+       for (i = 0; i < grid_n; ++i)
        {
-               /* Extract the location */
-               y = gy[i];
-               x = gx[i];
+               int ny = GRID_Y(grid_g[i]);
+               int nx = GRID_X(grid_g[i]);
 
-               if (y == y2 && x == x2)
-                       hit2 = TRUE;
-               if (y == py && x == px)
-                       hityou = TRUE;
+               if (disint_ball)
+               {
+                       /* Hack -- Balls explode before reaching walls */
+                       if (cave_stop_disintegration(ny, nx)) break;
+               }
+               else
+               {
+                       /* Hack -- Balls explode before reaching walls */
+                       if (!cave_floor_bold(ny, nx)) break;
+               }
+
+               /* Save the "blast epicenter" */
+               y = ny;
+               x = nx;
        }
-       if (!hit2)
-               return FALSE;
-       if (friend && hityou)
-               return FALSE;
+
+       grid_n = i;
+
+       if (!grid_n)
+       {
+               if (disint_ball)
+               {
+                       if (in_disintegration_range(y1, x1, y2, x2) && (distance(y1, x1, y2, x2) <= rad)) hit2 = TRUE;
+                       if (in_disintegration_range(y1, x1, py, px) && (distance(y1, x1, py, px) <= rad)) hityou = TRUE;
+               }
+               else
+               {
+                       if (los(y1, x1, y2, x2) && (distance(y1, x1, y2, x2) <= rad)) hit2 = TRUE;
+                       if (los(y1, x1, py, px) && (distance(y1, x1, py, px) <= rad)) hityou = TRUE;
+               }
+       }
+       else
+       {
+               breath_shape(grid_g, grid_n, &grids, gx, gy, gm, &gm_rad, rad, y1, x1, y, x, disint_ball, FALSE);
+
+               for (i = 0; i < grids; i++)
+               {
+                       /* Extract the location */
+                       y = gy[i];
+                       x = gx[i];
+
+                       if ((y == y2) && (x == x2)) hit2 = TRUE;
+                       if (player_bold(y, x)) hityou = TRUE;
+               }
+       }
+
+       if (!hit2) return FALSE;
+       if (friend && hityou) return FALSE;
+
        return TRUE;
 }
 
 /*
- * Get the actual center point of ball spells (originally from TOband)
+ * Get the actual center point of ball spells (rad > 1) (originally from TOband)
  */
-static void get_project_point(int sy, int sx, int *ty, int *tx)
+static void get_project_point(int sy, int sx, int *ty, int *tx, int flg)
 {
-       int  nx, ny;
        u16b path_g[128];
        int  path_n, i;
 
-       path_n = project_path(path_g, MAX_RANGE, sy, sx, *ty, *tx, 0L);
+       path_n = project_path(path_g, MAX_RANGE, sy, sx, *ty, *tx, flg);
 
-       /* "Explosion point" starts from start point */
        *ty = sy;
        *tx = sx;
 
        /* Project along the path */
        for (i = 0; i < path_n; i++)
        {
-               ny = GRID_Y(path_g[i]);
-               nx = GRID_X(path_g[i]);
+               sy = GRID_Y(path_g[i]);
+               sx = GRID_X(path_g[i]);
 
                /* Hack -- Balls explode before reaching walls */
-               if (!cave_floor_bold(ny, nx)) break;
+               if (!cave_floor_bold(sy, sx)) break;
 
-               /* Advance */
-               *ty = ny;
-               *tx = nx;
+               *ty = sy;
+               *tx = sx;
        }
 }
 
@@ -189,8 +229,10 @@ bool monst_spell_monst(int m_idx)
 
        char m_name[160];
        char t_name[160];
+
+#ifndef JP
        char m_poss[160];
-       char ddesc[160];
+#endif
 
        monster_type *m_ptr = &m_list[m_idx];
        monster_type *t_ptr = NULL;
@@ -215,6 +257,11 @@ bool monst_spell_monst(int m_idx)
 
        bool pet = is_pet(m_ptr);
 
+       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 resists_tele = FALSE;
+
        /* Prepare flags for summoning */
        if (pet) p_mode |= PM_FORCE_PET;
        if (!pet) u_mode |= PM_ALLOW_UNIQUE;
@@ -317,7 +364,17 @@ bool monst_spell_monst(int m_idx)
        /* Extract the monster level */
        rlev = ((r_ptr->level >= 1) ? r_ptr->level : 1);
 
-       if (dun_level && (!p_ptr->inside_quest || (p_ptr->inside_quest < MIN_RANDOM_QUEST)) && (d_info[dungeon_type].flags1 & DF1_NO_MAGIC))
+       /* Remove unimplemented spells */
+       f4 &= ~(RF4_DISPEL);
+       f6 &= ~(RF6_WORLD | RF6_FORGET);
+
+       /* Remove unimplemented special moves */
+       if (f6 & RF6_SPECIAL)
+       {
+               if (r_ptr->d_char != 'B') f6 &= ~(RF6_SPECIAL);
+       }
+
+       if (in_no_magic_dungeon && !(r_ptr->flags2 & RF2_STUPID))
        {
                f4 &= (RF4_NOMAGIC_MASK);
                f5 &= (RF5_NOMAGIC_MASK);
@@ -328,8 +385,9 @@ bool monst_spell_monst(int m_idx)
        {
                f4 &= ~(RF4_SUMMON_MASK);
                f5 &= ~(RF5_SUMMON_MASK);
-               f6 &= ~(RF6_SUMMON_MASK);
+               f6 &= ~(RF6_SUMMON_MASK | RF6_TELE_LEVEL);
        }
+
        if (p_ptr->inside_battle && !one_in_(3))
        {
                f6 &= ~(RF6_HEAL);
@@ -349,7 +407,7 @@ bool monst_spell_monst(int m_idx)
 
                if (!(p_ptr->pet_extra_flags & PF_TELEPORT))
                {
-                       f6 &= ~(RF6_BLINK | RF6_TPORT | RF6_TELE_AWAY);
+                       f6 &= ~(RF6_BLINK | RF6_TPORT | RF6_TELE_TO | RF6_TELE_AWAY | RF6_TELE_LEVEL);
                }
 
                if (!(p_ptr->pet_extra_flags & PF_ATTACK_SPELL))
@@ -369,22 +427,22 @@ bool monst_spell_monst(int m_idx)
                /* Prevent collateral damage */
                if (!(p_ptr->pet_extra_flags & PF_BALL_SPELL) && (m_idx != p_ptr->riding))
                {
-                       if ((f4 & RF4_BALL_MASK) ||
+                       if ((f4 & (RF4_BALL_MASK & ~(RF4_ROCKET))) ||
                            (f5 & RF5_BALL_MASK) ||
                            (f6 & RF6_BALL_MASK))
                        {
                                int real_y = y;
                                int real_x = x;
-                               int dist;
 
-                               get_project_point(m_ptr->fy, m_ptr->fx, &real_y, &real_x);
-                               dist = distance(real_y, real_x, py, px);
+                               get_project_point(m_ptr->fy, m_ptr->fx, &real_y, &real_x, 0L);
 
                                if (los(real_y, real_x, py, px))
                                {
+                                       int dist = distance(real_y, real_x, py, px);
+
                                        if (dist <= 2)
                                        {
-                                               f4 &= ~(RF4_BALL_MASK);
+                                               f4 &= ~(RF4_BALL_MASK & ~(RF4_ROCKET));
                                                f5 &= ~(RF5_BALL_MASK);
                                                f6 &= ~(RF6_BALL_MASK);
                                        }
@@ -397,6 +455,16 @@ bool monst_spell_monst(int m_idx)
                                }
                        }
 
+                       if (f4 & RF4_ROCKET)
+                       {
+                               int real_y = y;
+                               int real_x = x;
+
+                               get_project_point(m_ptr->fy, m_ptr->fx, &real_y, &real_x, PROJECT_STOP);
+                               if (los(real_y, real_x, py, px) && (distance(real_y, real_x, py, px) <= 2))
+                                       f4 &= ~(RF4_ROCKET);
+                       }
+
                        if (((f4 & RF4_BEAM_MASK) ||
                             (f5 & RF5_BEAM_MASK) ||
                             (f6 & RF6_BEAM_MASK)) &&
@@ -427,45 +495,71 @@ bool monst_spell_monst(int m_idx)
                                }
                        }
                }
+
+               /* Special moves restriction */
+               if (f6 & RF6_SPECIAL)
+               {
+                       if (r_ptr->d_char == 'B')
+                       {
+                               if ((p_ptr->pet_extra_flags & (PF_ATTACK_SPELL | PF_TELEPORT)) != (PF_ATTACK_SPELL | PF_TELEPORT))
+                                       f6 &= ~(RF6_SPECIAL);
+                       }
+                       else f6 &= ~(RF6_SPECIAL);
+               }
        }
 
        /* Remove some spells if necessary */
 
-       /* Check for a clean bolt shot */
-       if (((f4 & RF4_BOLT_MASK) ||
-            (f5 & RF5_BOLT_MASK) ||
-            (f6 & RF6_BOLT_MASK)) &&
-           !(r_ptr->flags2 & RF2_STUPID) &&
-           !clean_shot(m_ptr->fy, m_ptr->fx, t_ptr->fy, t_ptr->fx, pet))
+       if (!(r_ptr->flags2 & RF2_STUPID))
        {
-               f4 &= ~(RF4_BOLT_MASK);
-               f5 &= ~(RF5_BOLT_MASK);
-               f6 &= ~(RF6_BOLT_MASK);
-       }
+               /* Check for a clean bolt shot */
+               if (((f4 & RF4_BOLT_MASK) ||
+                    (f5 & RF5_BOLT_MASK) ||
+                    (f6 & RF6_BOLT_MASK)) &&
+                   !clean_shot(m_ptr->fy, m_ptr->fx, t_ptr->fy, t_ptr->fx, pet))
+               {
+                       f4 &= ~(RF4_BOLT_MASK);
+                       f5 &= ~(RF5_BOLT_MASK);
+                       f6 &= ~(RF6_BOLT_MASK);
+               }
 
-       /* Check for a possible summon */
-       if (((f4 & RF4_SUMMON_MASK) ||
-            (f5 & RF5_SUMMON_MASK) ||
-            (f6 & RF6_SUMMON_MASK)) &&
-           !(r_ptr->flags2 & RF2_STUPID) &&
-           !(summon_possible(t_ptr->fy, t_ptr->fx)))
-       {
-               /* Remove summoning spells */
-               f4 &= ~(RF4_SUMMON_MASK);
-               f5 &= ~(RF5_SUMMON_MASK);
-               f6 &= ~(RF6_SUMMON_MASK);
+               /* Check for a possible summon */
+               if (((f4 & RF4_SUMMON_MASK) ||
+                    (f5 & RF5_SUMMON_MASK) ||
+                    (f6 & RF6_SUMMON_MASK)) &&
+                   !(summon_possible(t_ptr->fy, t_ptr->fx)))
+               {
+                       /* Remove summoning spells */
+                       f4 &= ~(RF4_SUMMON_MASK);
+                       f5 &= ~(RF5_SUMMON_MASK);
+                       f6 &= ~(RF6_SUMMON_MASK);
+               }
+
+               /* Check for a possible raise dead */
+               if ((f6 & RF6_RAISE_DEAD) && !raise_possible(m_ptr))
+               {
+                       /* Remove raise dead spell */
+                       f6 &= ~(RF6_RAISE_DEAD);
+               }
        }
 
-       /* Hack -- allow "desperate" spells */
-       if ((r_ptr->flags2 & RF2_SMART) &&
-           (m_ptr->hp < m_ptr->maxhp / 10) &&
-           (randint0(100) < 50))
+       if (r_ptr->flags2 & RF2_SMART)
        {
-               /* Require intelligent spells */
-               f4 &= (RF4_INT_MASK);
-               f5 &= (RF5_INT_MASK);
-               f6 &= (RF6_INT_MASK);
+               /* Hack -- allow "desperate" spells */
+               if ((m_ptr->hp < m_ptr->maxhp / 10) &&
+                   (randint0(100) < 50))
+               {
+                       /* Require intelligent spells */
+                       f4 &= (RF4_INT_MASK);
+                       f5 &= (RF5_INT_MASK);
+                       f6 &= (RF6_INT_MASK);
+               }
 
+               /* Hack -- decline "teleport level" in some case */
+               if ((f6 & RF6_TELE_LEVEL) && TELE_LEVEL_IS_INEFF((t_idx == p_ptr->riding) ? 0 : t_idx))
+               {
+                       f6 &= ~(RF6_TELE_LEVEL);
+               }
        }
 
        /* No spells left */
@@ -501,15 +595,14 @@ bool monst_spell_monst(int m_idx)
        /* Get the monster name (or "it") */
        monster_desc(m_name, m_ptr, 0x00);
 
+#ifndef JP
        /* Get the monster possessive ("his"/"her"/"its") */
-       monster_desc(m_poss, m_ptr, 0x22);
+       monster_desc(m_poss, m_ptr, MD_PRON_VISIBLE | MD_POSSESSIVE);
+#endif
 
        /* Get the target's name (or "it") */
        monster_desc(t_name, t_ptr, 0x00);
 
-       /* Hack -- Get the "died from" name */
-       monster_desc(ddesc, m_ptr, 0x88);
-
        /* Choose a spell to cast */
        thrown_spell = spell[randint0(num)];
 
@@ -523,18 +616,15 @@ bool monst_spell_monst(int m_idx)
        if (p_ptr->riding && (m_idx == p_ptr->riding)) disturb(1, 0);
 
        /* Check for spell failure (inate attacks never fail) */
-       if ((thrown_spell >= 128) && m_ptr->stunned && one_in_(2))
+       if (!spell_is_inate(thrown_spell) && (in_no_magic_dungeon || (m_ptr->stunned && one_in_(2))))
        {
                disturb(1, 0);
                /* Message */
-               if (thrown_spell != (160+7)) /* Not RF6_SPECIAL */
-               {
 #ifdef JP
-                       msg_format("%^s¤Ï¼öʸ¤ò¾§¤¨¤è¤¦¤È¤·¤¿¤¬¼ºÇÔ¤·¤¿¡£", m_name);
+               msg_format("%^s¤Ï¼öʸ¤ò¾§¤¨¤è¤¦¤È¤·¤¿¤¬¼ºÇÔ¤·¤¿¡£", m_name);
 #else
-                       msg_format("%^s tries to cast a spell, but fails.", m_name);
+               msg_format("%^s tries to cast a spell, but fails.", m_name);
 #endif
-               }
 
                return (TRUE);
        }
@@ -573,7 +663,7 @@ bool monst_spell_monst(int m_idx)
        case 96+2:
                return FALSE;
 
-       /* RF4_XXX4X4 */
+       /* RF4_ROCKET */
        case 96+3:
                if (known)
                {
@@ -1534,7 +1624,7 @@ bool monst_spell_monst(int m_idx)
 
                break;
 
-       /* RF4_RF4_BR_NUKE */
+       /* RF4_BR_NUKE */
        case 96+29:
                if (known)
                {
@@ -2081,7 +2171,7 @@ bool monst_spell_monst(int m_idx)
                if (see_m)
                {
 #ifdef JP
-                       msg_format("%^s¤Ï%s¤ò¤¸¤Ã¤Èâˤó¤À", m_name, t_name);
+                       msg_format("%^s¤Ï%s¤ò¤¸¤Ã¤Èâˤó¤À¡£", m_name, t_name);
 #else
                        msg_format("%^s gazes intently at %s.", m_name, t_name);
 #endif
@@ -2092,20 +2182,17 @@ bool monst_spell_monst(int m_idx)
                /* Attempt a saving throw */
                if ((tr_ptr->flags1 & RF1_UNIQUE) ||
                    (tr_ptr->flags3 & RF3_NO_CONF) ||
-                   (tr_ptr->flags3 & RF3_RES_ALL) ||
+                   (tr_ptr->flagsr & RFR_RES_ALL) ||
                    (tr_ptr->level > randint1((rlev - 10) < 1 ? 1 : (rlev - 10)) + 10))
                {
                        /* No obvious effect */
                        if (see_both)
                        {
-                               /* Memorize a flag */
-                               if (tr_ptr->flags3 & (RF3_RES_ALL))
-                               {
-                                       tr_ptr->r_flags3 |= (RF3_RES_ALL);
-                               }
-                               else if (tr_ptr->flags3 & (RF3_NO_CONF))
+                               if (is_original_ap(t_ptr))
                                {
-                                       tr_ptr->r_flags3 |= (RF3_NO_CONF);
+                                       /* Memorize a flag */
+                                       if (tr_ptr->flagsr & RFR_RES_ALL) tr_ptr->r_flagsr |= (RFR_RES_ALL);
+                                       if (tr_ptr->flags3 & RF3_NO_CONF) tr_ptr->r_flags3 |= (RF3_NO_CONF);
                                }
 
 #ifdef JP
@@ -2131,11 +2218,10 @@ bool monst_spell_monst(int m_idx)
                        t_ptr->confused += randint0(4) + 4;
 
 #ifdef JP
-                       mon_take_hit_mon(t_idx, dam, &fear, "¤ÎÀº¿À¤ÏÊø²õ¤·¡¢ÆùÂΤÏÈ´¤±¶õ¤È¤Ê¤Ã¤¿¡£", m_idx);
+                       mon_take_hit_mon(t_idx, dam, &fear, "¤ÎÀº¿À¤ÏÊø²õ¤·¡¢ÆùÂΤÏÈ´¤±³Ì¤È¤Ê¤Ã¤¿¡£", m_idx);
 #else
                        mon_take_hit_mon(t_idx, dam, &fear, " collapses, a mindless husk.", m_idx);
 #endif
-
                }
 
                wake_up = TRUE;
@@ -2147,7 +2233,7 @@ bool monst_spell_monst(int m_idx)
                if (see_m)
                {
 #ifdef JP
-                       msg_format("%^s¤Ï%s¤ò¤¸¤Ã¤Èâˤó¤À", m_name, t_name);
+                       msg_format("%^s¤Ï%s¤ò¤¸¤Ã¤Èâˤó¤À¡£", m_name, t_name);
 #else
                        msg_format("%^s gazes intently at %s.", m_name, t_name);
 #endif
@@ -2158,20 +2244,17 @@ bool monst_spell_monst(int m_idx)
                /* Attempt a saving throw */
                if ((tr_ptr->flags1 & RF1_UNIQUE) ||
                    (tr_ptr->flags3 & RF3_NO_CONF) ||
-                   (tr_ptr->flags3 & RF3_RES_ALL) ||
+                   (tr_ptr->flagsr & RFR_RES_ALL) ||
                    (tr_ptr->level > randint1((rlev - 10) < 1 ? 1 : (rlev - 10)) + 10))
                {
                        /* No obvious effect */
                        if (see_both)
                        {
-                               /* Memorize a flag */
-                               if (tr_ptr->flags3 & (RF3_RES_ALL))
-                               {
-                                       tr_ptr->r_flags3 |= (RF3_RES_ALL);
-                               }
-                               else if (tr_ptr->flags3 & (RF3_NO_CONF))
+                               if (is_original_ap(t_ptr))
                                {
-                                       tr_ptr->r_flags3 |= (RF3_NO_CONF);
+                                       /* Memorize a flag */
+                                       if (tr_ptr->flagsr & RFR_RES_ALL) tr_ptr->r_flagsr |= (RFR_RES_ALL);
+                                       if (tr_ptr->flags3 & RF3_NO_CONF) tr_ptr->r_flags3 |= (RF3_NO_CONF);
                                }
 
 #ifdef JP
@@ -2199,11 +2282,10 @@ bool monst_spell_monst(int m_idx)
                        t_ptr->stunned += randint0(4) + 4;
 
 #ifdef JP
-                       mon_take_hit_mon(t_idx, dam, &fear, "¤ÎÀº¿À¤ÏÊø²õ¤·¡¢ÆùÂΤÏÈ´¤±¶õ¤È¤Ê¤Ã¤¿¡£", m_idx);
+                       mon_take_hit_mon(t_idx, dam, &fear, "¤ÎÀº¿À¤ÏÊø²õ¤·¡¢ÆùÂΤÏÈ´¤±³Ì¤È¤Ê¤Ã¤¿¡£", m_idx);
 #else
                        mon_take_hit_mon(t_idx, dam, &fear, " collapses, a mindless husk.", m_idx);
 #endif
-
                }
 
                wake_up = TRUE;
@@ -2231,12 +2313,12 @@ bool monst_spell_monst(int m_idx)
 
                dam = damroll(3, 8);
                if ((randint0(100 + rlev/2) < (tr_ptr->level + 35)) ||
-                   (tr_ptr->flags3 & RF3_RES_ALL))
+                   (tr_ptr->flagsr & RFR_RES_ALL))
                {
                        /* Memorize a flag */
-                       if (tr_ptr->flags3 & (RF3_RES_ALL))
+                       if (tr_ptr->flagsr & RFR_RES_ALL)
                        {
-                               tr_ptr->r_flags3 |= (RF3_RES_ALL);
+                               if (is_original_ap(t_ptr)) tr_ptr->r_flagsr |= (RFR_RES_ALL);
                        }
 #ifdef JP
                        if (see_both) msg_format("%^s¤ÏÂÑÀ­¤ò»ý¤Ã¤Æ¤¤¤ë¡ª", t_name);
@@ -2275,12 +2357,12 @@ bool monst_spell_monst(int m_idx)
 
                dam = damroll(8, 8);
                if ((randint0(100 + rlev/2) < (tr_ptr->level + 35)) ||
-                   (tr_ptr->flags3 & RF3_RES_ALL))
+                   (tr_ptr->flagsr & RFR_RES_ALL))
                {
                        /* Memorize a flag */
-                       if (tr_ptr->flags3 & (RF3_RES_ALL))
+                       if (tr_ptr->flagsr & RFR_RES_ALL)
                        {
-                               tr_ptr->r_flags3 |= (RF3_RES_ALL);
+                               if (is_original_ap(t_ptr)) tr_ptr->r_flagsr |= (RFR_RES_ALL);
                        }
 #ifdef JP
                        if (see_both) msg_format("%^s¤ÏÂÑÀ­¤ò»ý¤Ã¤Æ¤¤¤ë¡ª", t_name);
@@ -2292,7 +2374,6 @@ bool monst_spell_monst(int m_idx)
                else
                {
                        mon_take_hit_mon(t_idx, dam, &fear, NULL, m_idx);
-
                }
 
                wake_up = TRUE;
@@ -2320,12 +2401,12 @@ bool monst_spell_monst(int m_idx)
 
                dam = damroll(10, 15);
                if ((randint0(100 + rlev/2) < (tr_ptr->level + 35)) ||
-                   (tr_ptr->flags3 & RF3_RES_ALL))
+                   (tr_ptr->flagsr & RFR_RES_ALL))
                {
                        /* Memorize a flag */
-                       if (tr_ptr->flags3 & (RF3_RES_ALL))
+                       if (tr_ptr->flagsr & RFR_RES_ALL)
                        {
-                               tr_ptr->r_flags3 |= (RF3_RES_ALL);
+                               if (is_original_ap(t_ptr)) tr_ptr->r_flagsr |= (RFR_RES_ALL);
                        }
 #ifdef JP
                        if (see_both) msg_format("%^s¤ÏÂÑÀ­¤ò»ý¤Ã¤Æ¤¤¤ë¡ª", t_name);
@@ -2364,12 +2445,12 @@ bool monst_spell_monst(int m_idx)
 
                dam = damroll(15, 15);
                if (((randint0(100 + rlev/2) < (tr_ptr->level + 35)) && (m_ptr->r_idx != MON_KENSHIROU)) ||
-                   (tr_ptr->flags3 & RF3_RES_ALL))
+                   (tr_ptr->flagsr & RFR_RES_ALL))
                {
                        /* Memorize a flag */
-                       if (tr_ptr->flags3 & (RF3_RES_ALL))
+                       if (tr_ptr->flagsr & RFR_RES_ALL)
                        {
-                               tr_ptr->r_flags3 |= (RF3_RES_ALL);
+                               if (is_original_ap(t_ptr)) tr_ptr->r_flagsr |= (RFR_RES_ALL);
                        }
 #ifdef JP
                        if (see_both) msg_format("%^s¤ÏÂÑÀ­¤ò»ý¤Ã¤Æ¤¤¤ë¡ª", t_name);
@@ -2949,7 +3030,7 @@ bool monst_spell_monst(int m_idx)
                        if (see_m)
                        {
 #ifdef JP
-                               msg_format("%^s¤¬¼«Ê¬¤ÎÂΤËÇ°¤òÁ÷¤Ã¤¿¡£", m_name, m_poss);
+                               msg_format("%^s¤¬¼«Ê¬¤ÎÂΤËÇ°¤òÁ÷¤Ã¤¿¡£", m_name);
 #else
                                msg_format("%^s concentrates on %s body.", m_name, m_poss);
 #endif
@@ -2994,12 +3075,12 @@ bool monst_spell_monst(int m_idx)
                        }
                }
 
-               if ((tr_ptr->flags1 & RF1_UNIQUE) || (tr_ptr->flags3 & RF3_RES_ALL))
+               if ((tr_ptr->flags1 & RF1_UNIQUE) || (tr_ptr->flagsr & RFR_RES_ALL))
                {
                        /* Memorize a flag */
-                       if (tr_ptr->flags3 & (RF3_RES_ALL))
+                       if (tr_ptr->flagsr & RFR_RES_ALL)
                        {
-                               tr_ptr->r_flags3 |= (RF3_RES_ALL);
+                               if (is_original_ap(t_ptr)) tr_ptr->r_flagsr |= (RFR_RES_ALL);
                        }
 #ifdef JP
                        if (see_both) msg_format("¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª", t_name);
@@ -3171,45 +3252,7 @@ bool monst_spell_monst(int m_idx)
 #endif
                }
 
-               teleport_away(m_idx, MAX_SIGHT * 2 + 5, FALSE);
-
-               if (los(py, px, m_ptr->fy, m_ptr->fx) && !world_monster && see_m)
-               {
-                       for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
-                       {
-                               u32b flgs[TR_FLAG_SIZE];
-                               object_type *o_ptr = &inventory[i];
-
-                               if (cursed_p(o_ptr)) continue;
-
-                               object_flags(o_ptr, flgs);
-
-                               if((have_flag(flgs, TR_TELEPORT)) || (p_ptr->muta1 & MUT1_VTELEPORT) || (p_ptr->pclass == CLASS_IMITATOR))
-                               {
-#ifdef JP
-                                       cptr msg = "¤Ä¤¤¤Æ¤¤¤­¤Þ¤¹¤«¡©";
-#else
-                                       cptr msg = "Do you follow it? ";
-#endif
-
-                                       if(get_check_strict(msg, CHECK_OKAY_CANCEL))
-                                       {
-                                               if (one_in_(3))
-                                               {
-                                                       teleport_player(200);
-#ifdef JP
-                                                       msg_print("¼ºÇÔ¡ª");
-#else
-                                                       msg_print("Failed!");
-#endif
-                                               }
-                                               else teleport_player_to(m_ptr->fy, m_ptr->fx, TRUE);
-                                               p_ptr->energy_need = ENERGY_NEED();
-                                       }
-                                       break;
-                               }
-                       }
-               }
+               teleport_away_followable(m_idx);
                break;
 
        /* RF6_WORLD */
@@ -3225,15 +3268,10 @@ bool monst_spell_monst(int m_idx)
 
        /* RF6_SPECIAL */
        case 160+7:
-               if (p_ptr->inside_arena || p_ptr->inside_battle) return FALSE;
-
-               switch(m_ptr->r_idx)
+               switch (m_ptr->r_idx)
                {
                case MON_OHMU:
-                       for (k = 0; k < 6; k++)
-                       {
-                               summon_specific(m_idx, m_ptr->fy, m_ptr->fx, rlev, SUMMON_BIZARRE1, PM_ALLOW_GROUP);
-                       }
+                       /* Moved to process_monster(), like multiplication */
                        return FALSE;
 
                default:
@@ -3250,12 +3288,78 @@ bool monst_spell_monst(int m_idx)
 #endif
                                        }
                                        teleport_away(m_idx, 10, FALSE);
-                                       p_ptr->update |= (PU_MONSTERS | PU_MON_LITE);
+                                       p_ptr->update |= (PU_MONSTERS);
                                }
                                else
                                {
-                                       /* Not implemented */
-                                       return FALSE;
+                                       if (known)
+                                       {
+                                               if (see_either)
+                                               {
+#ifdef JP
+                                                       msg_format("%^s¤¬%s¤òÄϤó¤Ç¶õÃ椫¤éÅꤲÍî¤È¤·¤¿¡£", m_name, t_name);
+#else
+                                                       msg_format("%^s holds %s, and drops from the sky.", m_name, t_name);
+#endif
+
+                                               }
+                                               else
+                                               {
+                                                       mon_fight = TRUE;
+                                               }
+                                       }
+
+                                       dam = damroll(4, 8);
+
+                                       if (t_idx == p_ptr->riding) teleport_player_to(m_ptr->fy, m_ptr->fx, FALSE);
+                                       else teleport_monster_to(t_idx, m_ptr->fy, m_ptr->fx, 100);
+
+                                       sound(SOUND_FALL);
+
+                                       if (tr_ptr->flags7 & RF7_CAN_FLY)
+                                       {
+#ifdef JP
+                                               if (see_t) msg_format("%^s¤ÏÀŤ«¤ËÃåÃϤ·¤¿¡£", t_name);
+#else
+                                               if (see_t) msg_format("%^s floats gently down to the ground.", t_name);
+#endif
+                                       }
+                                       else
+                                       {
+#ifdef JP
+                                               if (see_t) msg_format("%^s¤ÏÃÏÌ̤Ë᤭¤Ä¤±¤é¤ì¤¿¡£", t_name);
+#else
+                                               if (see_t) msg_format("%^s crashed into the ground.", t_name);
+#endif
+                                               dam += damroll(6, 8);
+                                       }
+
+                                       if (p_ptr->riding == t_idx)
+                                       {
+                                               int get_damage = 0;
+
+                                               /* Mega hack -- this special action deals damage to the player. Therefore the code of "eyeeye" is necessary.
+                                                  -- henkma
+                                                */
+                                               get_damage = take_hit(DAMAGE_NOESCAPE, dam, m_name, -1);
+                                               if (p_ptr->tim_eyeeye && get_damage > 0 && !p_ptr->is_dead)
+                                               {
+#ifdef JP
+                                                       msg_format("¹¶·â¤¬%s¼«¿È¤ò½ý¤Ä¤±¤¿¡ª", m_name);
+#else
+                                                       char m_name_self[80];
+
+                                                       /* hisself */
+                                                       monster_desc(m_name_self, m_ptr, MD_PRON_VISIBLE | MD_POSSESSIVE | MD_OBJECTIVE);
+
+                                                       msg_format("The attack of %s has wounded %s!", m_name, m_name_self);
+#endif
+                                                       project(0, 0, m_ptr->fy, m_ptr->fx, get_damage, GF_MISSILE, PROJECT_KILL, -1);
+                                                       set_tim_eyeeye(p_ptr->tim_eyeeye-5, TRUE);
+                                               }
+                                       }
+
+                                       mon_take_hit_mon(t_idx, dam, &fear, extract_note_dies(real_r_ptr(t_ptr)), m_idx);
                                }
                                break;
                        }
@@ -3269,8 +3373,65 @@ bool monst_spell_monst(int m_idx)
 
        /* RF6_TELE_TO */
        case 160+8:
-               /* Not implemented */
-               return FALSE;
+               if (known)
+               {
+                       if (see_either)
+                       {
+#ifdef JP
+                               msg_format("%^s¤¬%s¤ò°ú¤­Ìᤷ¤¿¡£", m_name, t_name);
+#else
+                               msg_format("%^s commands %s to return.", m_name, t_name);
+#endif
+
+                       }
+                       else
+                       {
+                               mon_fight = TRUE;
+                       }
+               }
+
+               if (tr_ptr->flagsr & RFR_RES_TELE)
+               {
+                       if ((tr_ptr->flags1 & RF1_UNIQUE) || (tr_ptr->flagsr & RFR_RES_ALL))
+                       {
+                               if (see_t)
+                               {
+                                       if (is_original_ap(t_ptr)) tr_ptr->r_flagsr |= RFR_RES_TELE;
+#ifdef JP
+                                       msg_format("%^s¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡£", t_name);
+#else
+                                       msg_format("%^s is unaffected!", t_name);
+#endif
+
+                               }
+
+                               resists_tele = TRUE;
+                       }
+                       else if (tr_ptr->level > randint1(100))
+                       {
+                               if (see_t)
+                               {
+                                       if (is_original_ap(t_ptr)) tr_ptr->r_flagsr |= RFR_RES_TELE;
+#ifdef JP
+                                       msg_format("%^s¤ÏÂÑÀ­¤ò»ý¤Ã¤Æ¤¤¤ë¡ª", t_name);
+#else
+                                       msg_format("%^s resists!", t_name);
+#endif
+
+                               }
+
+                               resists_tele = TRUE;
+                       }
+               }
+
+               if (!resists_tele)
+               {
+                       if (t_idx == p_ptr->riding) teleport_player_to(m_ptr->fy, m_ptr->fx, TRUE);
+                       else teleport_monster_to(t_idx, m_ptr->fy, m_ptr->fx, 100);
+               }
+
+               wake_up = TRUE;
+               break;
 
        /* RF6_TELE_AWAY */
        case 160+9:
@@ -3291,55 +3452,88 @@ bool monst_spell_monst(int m_idx)
                        }
                }
 
+               if (tr_ptr->flagsr & RFR_RES_TELE)
                {
-                       bool resists_tele = FALSE;
-
-                       if (tr_ptr->flags3 & RF3_RES_TELE)
+                       if ((tr_ptr->flags1 & RF1_UNIQUE) || (tr_ptr->flagsr & RFR_RES_ALL))
                        {
-                               if ((tr_ptr->flags1 & RF1_UNIQUE) || (tr_ptr->flags3 & (RF3_RES_ALL)))
+                               if (see_t)
                                {
-                                       if (see_t)
-                                       {
-                                               tr_ptr->r_flags3 |= RF3_RES_TELE;
+                                       if (is_original_ap(t_ptr)) tr_ptr->r_flagsr |= RFR_RES_TELE;
 #ifdef JP
-                                               msg_format("%^s¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡£", t_name);
+                                       msg_format("%^s¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡£", t_name);
 #else
-                                               msg_format("%^s is unaffected!", t_name);
+                                       msg_format("%^s is unaffected!", t_name);
 #endif
 
-                                       }
-
-                                       resists_tele = TRUE;
                                }
-                               else if (tr_ptr->level > randint1(100))
+
+                               resists_tele = TRUE;
+                       }
+                       else if (tr_ptr->level > randint1(100))
+                       {
+                               if (see_t)
                                {
-                                       if (see_t)
-                                       {
-                                               tr_ptr->r_flags3 |= RF3_RES_TELE;
+                                       if (is_original_ap(t_ptr)) tr_ptr->r_flagsr |= RFR_RES_TELE;
 #ifdef JP
-                                               msg_format("%^s¤ÏÂÑÀ­¤ò»ý¤Ã¤Æ¤¤¤ë¡ª", t_name);
+                                       msg_format("%^s¤ÏÂÑÀ­¤ò»ý¤Ã¤Æ¤¤¤ë¡ª", t_name);
 #else
-                                               msg_format("%^s resists!", t_name);
+                                       msg_format("%^s resists!", t_name);
 #endif
 
-                                       }
-
-                                       resists_tele = TRUE;
                                }
-                       }
 
-                       if (!resists_tele)
-                       {
-                               if (t_idx == p_ptr->riding) teleport_player(MAX_SIGHT * 2 + 5);
-                               else teleport_away(t_idx, MAX_SIGHT * 2 + 5, FALSE);
+                               resists_tele = TRUE;
                        }
                }
+
+               if (!resists_tele)
+               {
+                       if (t_idx == p_ptr->riding) teleport_player_away(m_idx, MAX_SIGHT * 2 + 5);
+                       else teleport_away(t_idx, MAX_SIGHT * 2 + 5, FALSE);
+               }
+
+               wake_up = TRUE;
                break;
 
        /* RF6_TELE_LEVEL */
        case 160+10:
-               /* Not implemented */
-               return FALSE;
+               if (known)
+               {
+                       if (see_either)
+                       {
+#ifdef JP
+                               msg_format("%^s¤¬%s¤Î­¤ò»Ø¤µ¤·¤¿¡£", m_name, t_name);
+#else
+                               msg_format("%^s gestures at %s's feet.", m_name, t_name);
+#endif
+                       }
+                       else
+                       {
+                               mon_fight = TRUE;
+                       }
+               }
+
+               if (tr_ptr->flagsr & (RFR_EFF_RES_NEXU_MASK | RFR_RES_TELE))
+               {
+#ifdef JP
+                       if (see_t) msg_format("%^s¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡£", t_name);
+#else
+                       if (see_t) msg_format("%^s is unaffected!", t_name);
+#endif
+               }
+               else if ((tr_ptr->flags1 & RF1_QUESTOR) ||
+                           (tr_ptr->level > randint1((rlev - 10) < 1 ? 1 : (rlev - 10)) + 10))
+               {
+#ifdef JP
+                       if (see_t) msg_format("%^s¤Ï¸úÎϤòÄ·¤ÍÊÖ¤·¤¿¡ª", t_name);
+#else
+                       if (see_t) msg_format("%^s resist the effects!", t_name);
+#endif
+               }
+               else teleport_level((t_idx == p_ptr->riding) ? 0 : t_idx);
+
+               wake_up = TRUE;
+               break;
 
        /* RF6_PSY_SPEAR */
        case 160+11:
@@ -3394,7 +3588,7 @@ bool monst_spell_monst(int m_idx)
                        }
                }
 
-               (void)project(m_idx, 3, y, x, 0, GF_DARK_WEAK, PROJECT_GRID | PROJECT_KILL | PROJECT_MONSTER, MS_DARKNESS);
+               (void)project(m_idx, 3, y, x, 0, GF_DARK_WEAK, PROJECT_GRID | PROJECT_KILL, MS_DARKNESS);
 
                unlite_room(y, x);
 
@@ -4079,6 +4273,7 @@ bool monst_spell_monst(int m_idx)
        if (wake_up)
        {
                t_ptr->csleep = 0;
+               if (tr_ptr->flags7 & RF7_HAS_LD_MASK) p_ptr->update |= (PU_MON_LITE);
        }
 
        if (fear && see_t)
@@ -4093,7 +4288,7 @@ bool monst_spell_monst(int m_idx)
 
        if (see_m && maneable && !world_monster && !p_ptr->blind && (p_ptr->pclass == CLASS_IMITATOR))
        {
-               if (thrown_spell != 167)
+               if (thrown_spell != 167) /* Not RF6_SPECIAL */
                {
                        if (p_ptr->mane_num == MAX_MANE)
                        {
@@ -4109,12 +4304,12 @@ bool monst_spell_monst(int m_idx)
                        p_ptr->mane_num++;
                        new_mane = TRUE;
 
-                       p_ptr->redraw |= (PR_MANE);
+                       p_ptr->redraw |= (PR_IMITATION);
                }
        }
 
        /* Remember what the monster did, if we saw it */
-       if (see_m)
+       if (see_m && is_original_ap(m_ptr))
        {
                /* Inate spell */
                if (thrown_spell < 32*4)
@@ -4141,7 +4336,7 @@ bool monst_spell_monst(int m_idx)
        /* Always take note of monsters that kill you */
        if (p_ptr->is_dead && (r_ptr->r_deaths < MAX_SHORT) && !p_ptr->inside_arena)
        {
-               r_ptr->r_deaths++;
+               r_ptr->r_deaths++; /* Ignore appearance difference */
        }
 
        /* A spell was cast */