OSDN Git Service

branch-hexの変更をコミット。
[hengband/hengband.git] / src / mspells2.c
index a3e90ad..3e7ec22 100644 (file)
@@ -248,6 +248,32 @@ void get_project_point(int sy, int sx, int *ty, int *tx, int flg)
 }
 
 /*
+ * Check should monster cast dispel spell at other monster.
+ */
+static bool dispel_check_monster(int m_idx, int t_idx)
+{
+       monster_type *t_ptr = &m_list[t_idx];
+
+       /* Invulnabilty */
+       if (MON_INVULNER(t_ptr)) return TRUE;
+
+       /* Speed */
+       if (t_ptr->mspeed < 135)
+       {
+               if (MON_FAST(t_ptr)) return TRUE;
+       }
+
+       /* Riding monster */
+       if (t_idx == p_ptr->riding)
+       {
+               if (dispel_check(m_idx)) return TRUE;
+       }
+
+       /* No need to cast dispel spell */
+       return FALSE;
+}
+
+/*
  * Monster tries to 'cast a spell' (or breath, etc)
  * at another monster.
  *
@@ -324,7 +350,7 @@ bool monst_spell_monst(int m_idx)
                t_ptr = &m_list[t_idx];
 
                /* Cancel if not projectable (for now) */
-               if (!projectable(m_ptr->fy, m_ptr->fx, t_ptr->fy, t_ptr->fx))
+               if ((m_idx == t_idx) || !projectable(m_ptr->fy, m_ptr->fx, t_ptr->fy, t_ptr->fx))
                {
                        t_idx = 0;
                }
@@ -340,8 +366,8 @@ bool monst_spell_monst(int m_idx)
                        t_ptr = &m_list[t_idx];
 
                        /* Cancel if neither enemy nor a given target */
-                       if (t_idx != pet_t_m_idx &&
-                           !are_enemies(m_ptr, t_ptr))
+                       if ((m_idx == t_idx) ||
+                           ((t_idx != pet_t_m_idx) && !are_enemies(m_ptr, t_ptr)))
                        {
                                t_idx = 0;
                        }
@@ -381,7 +407,7 @@ bool monst_spell_monst(int m_idx)
                        if (!t_ptr->r_idx) continue;
 
                        /* Monster must be 'an enemy' */
-                       if (!are_enemies(m_ptr, t_ptr)) continue;
+                       if ((m_idx == t_idx) || !are_enemies(m_ptr, t_ptr)) continue;
 
                        /* Monster must be projectable */
                        if (!projectable(m_ptr->fy, m_ptr->fx, t_ptr->fy, t_ptr->fx)) continue;
@@ -408,9 +434,14 @@ bool monst_spell_monst(int m_idx)
        rlev = ((r_ptr->level >= 1) ? r_ptr->level : 1);
 
        /* Remove unimplemented spells */
-       f4 &= ~(RF4_DISPEL);
        f6 &= ~(RF6_WORLD | RF6_TRAPS | RF6_FORGET);
 
+       if (f4 & RF4_BR_LITE)
+       {
+               if (!los(m_ptr->fy, m_ptr->fx, t_ptr->fy, t_ptr->fx))
+                       f4 &= ~(RF4_BR_LITE);
+       }
+
        /* Remove unimplemented special moves */
        if (f6 & RF6_SPECIAL)
        {
@@ -612,6 +643,13 @@ bool monst_spell_monst(int m_idx)
                        f6 &= ~(RF6_SUMMON_MASK);
                }
 
+               /* Dispel magic */
+               if ((f4 & RF4_DISPEL) && !dispel_check_monster(m_idx, t_idx))
+               {
+                       /* Remove dispel spell */
+                       f4 &= ~(RF4_DISPEL);
+               }
+
                /* Check for a possible raise dead */
                if ((f6 & RF6_RAISE_DEAD) && !raise_possible(m_ptr))
                {
@@ -714,6 +752,17 @@ bool monst_spell_monst(int m_idx)
                return (TRUE);
        }
 
+       /* Hex: Anti Magic Barrier */
+       if (!spell_is_inate(thrown_spell) && magic_barrier(m_idx))
+       {
+#ifdef JP
+               if (see_m) msg_format("È¿ËâË¡¥Ð¥ê¥¢¤¬%^s¤Î¼öʸ¤ò¤«¤­¾Ã¤·¤¿¡£", m_name);
+#else
+               if (see_m) msg_format("Anti magic barrier cancels the spell which %^s casts.");
+#endif
+               return (TRUE);
+       }
+
        can_remember = is_original_ap_and_seen(m_ptr);
 
        switch (thrown_spell)
@@ -748,7 +797,26 @@ bool monst_spell_monst(int m_idx)
 
        /* RF4_DISPEL */
        case 96+2:
-               return FALSE;
+               if (known)
+               {
+                       if (see_m)
+                       {
+#ifdef JP
+                               msg_format("%^s¤¬%s¤ËÂФ·¤ÆËâÎϾõî¤Î¼öʸ¤òÇ°¤¸¤¿¡£", m_name, t_name);
+#else
+                               msg_format("%^s invokes a dispel magic at %s.", m_name, t_name);
+#endif
+                       }
+                       else
+                       {
+                               mon_fight = TRUE;
+                       }
+               }
+
+               if (t_idx == p_ptr->riding) dispel_player();
+               dispel_monster_status(t_idx);
+
+               break;
 
        /* RF4_ROCKET */
        case 96+3:
@@ -3052,32 +3120,56 @@ bool monst_spell_monst(int m_idx)
 
        /* RF6_BLINK */
        case 160+4:
-               if (see_m)
+               if (teleport_barrier(m_idx))
                {
+                       if (see_m)
+                       {
 #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
-
+                       }
+               }
+               else
+               {
+                       if (see_m)
+                       {
+#ifdef JP
+                               msg_format("%^s¤¬½Ö»þ¤Ë¾Ã¤¨¤¿¡£", m_name);
+#else
+                               msg_format("%^s blinks away.", m_name);
+#endif
+                       }
+                       teleport_away(m_idx, 10, 0L);
                }
-
-               teleport_away(m_idx, 10, 0L);
-
                break;
 
        /* RF6_TPORT */
        case 160+5:
-               if (see_m)
+               if (teleport_barrier(m_idx))
                {
+                       if (see_m)
+                       {
 #ifdef JP
-                       msg_format("%^s¤¬¥Æ¥ì¥Ý¡¼¥È¤·¤¿¡£", m_name);
+                               msg_format("ËâË¡¤Î¥Ð¥ê¥¢¤¬%^s¤Î¥Æ¥ì¥Ý¡¼¥È¤ò¼ÙË⤷¤¿¡£", m_name);
 #else
-                       msg_format("%^s teleports away.", m_name);
+                               msg_format("Magic barrier obstructs teleporting of %^s.", m_name);
 #endif
+                       }
+               }
+               else
+               {
+                       if (see_m)
+                       {
+#ifdef JP
+                               msg_format("%^s¤¬¥Æ¥ì¥Ý¡¼¥È¤·¤¿¡£", m_name);
+#else
+                               msg_format("%^s teleports away.", m_name);
+#endif
+                       }
+                       teleport_away_followable(m_idx);
                }
-
-               teleport_away_followable(m_idx);
                break;
 
        /* RF6_WORLD */
@@ -3155,7 +3247,7 @@ bool monst_spell_monst(int m_idx)
                                                if (see_either)
                                                {
 #ifdef JP
-                                                       msg_format("%^s¤¬%s¤òÄϤó¤Ç¶õÃ椫¤éÅꤲÍ¤¿¡£", m_name, t_name);
+                                                       msg_format("%^s¤¬%s¤òÄϤó¤Ç¶õÃ椫¤éÅꤲÍî¤Ȥ·¤¿¡£", m_name, t_name);
 #else
                                                        msg_format("%^s holds %s, and drops from the sky.", m_name, t_name);
 #endif
@@ -4137,6 +4229,20 @@ bool monst_spell_monst(int m_idx)
                        count += summon_specific(m_idx, y, x, rlev, SUMMON_UNIQUE, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE));
                }
 
+               {
+                       int non_unique_type = SUMMON_HI_UNDEAD;
+
+                       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++)
+                       {
+                               count += summon_specific(m_idx, y, x, rlev, non_unique_type, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE));
+                       }
+               }
+
                if (known && !see_t && count)
                {
                        mon_fight = TRUE;
@@ -4174,7 +4280,7 @@ bool monst_spell_monst(int m_idx)
                        p_ptr->mane_num++;
                        new_mane = TRUE;
 
-                       p_ptr->redraw |= (PR_MANE);
+                       p_ptr->redraw |= (PR_IMITATION);
                }
        }