OSDN Git Service

カメレオンは最初に決まった属性のモンスターにしか化けないので, 生成時にsub_alignも一致させるようにした. また, ダンジョンの主召喚ではなく自然生成されたカメレ...
author_nothere <_nothere@0568b783-4c39-0410-ac80-bf13821ea2a2>
Thu, 16 May 2002 11:30:05 +0000 (11:30 +0000)
committer_nothere <_nothere@0568b783-4c39-0410-ac80-bf13821ea2a2>
Thu, 16 May 2002 11:30:05 +0000 (11:30 +0000)
src/monster2.c

index ffc7a8f..11166f0 100644 (file)
@@ -2485,6 +2485,11 @@ void update_monsters(bool full)
 }
 
 
+/*
+ * Hack -- the index of the summoning monster
+ */
+static int summon_specific_who_for_chameleons = 0;
+
 static bool monster_hook_chameleon_lord(int r_idx)
 {
        monster_race *r_ptr = &r_info[r_idx];
@@ -2556,11 +2561,26 @@ void choose_new_monster(int m_idx, bool born, int r_idx)
                        r_ptr = &r_info[r_idx];
 
                        if (!monster_can_cross_terrain(cave[m_ptr->fy][m_ptr->fx].feat, r_ptr)) continue;
-                       if (!born && !old_unique)
+                       if (!born)
+                       {
+                               if (!old_unique)
+                               {
+                                       if ((r_info[old_r_idx].flags3 & RF3_GOOD) && !(r_ptr->flags3 & RF3_GOOD)) continue;
+                                       if ((r_info[old_r_idx].flags3 & RF3_EVIL) && !(r_ptr->flags3 & RF3_EVIL)) continue;
+                                       if (!(r_info[old_r_idx].flags3 & (RF3_GOOD | RF3_EVIL)) && (r_ptr->flags3 & (RF3_GOOD | RF3_EVIL))) continue;
+                               }
+                               else
+                               {
+                                       if ((m_ptr->sub_align & SUB_ALIGN_EVIL) && (r_ptr->flags3 & RF3_GOOD)) continue;
+                                       if ((m_ptr->sub_align & SUB_ALIGN_GOOD) && (r_ptr->flags3 & RF3_EVIL)) continue;
+                               }
+                       }
+                       else if (summon_specific_who_for_chameleons > 0)
                        {
-                               if ((r_info[old_r_idx].flags3 & RF3_GOOD) && !(r_ptr->flags3 & RF3_GOOD)) continue;
-                               if ((r_info[old_r_idx].flags3 & RF3_EVIL) && !(r_ptr->flags3 & RF3_EVIL)) continue;
-                               if (!(r_info[old_r_idx].flags3 & (RF3_GOOD | RF3_EVIL)) && (r_ptr->flags3 & (RF3_GOOD | RF3_EVIL))) continue;
+                               monster_type *sm_ptr = &m_list[summon_specific_who_for_chameleons];
+
+                               if ((sm_ptr->sub_align & SUB_ALIGN_EVIL) && (r_ptr->flags3 & RF3_GOOD)) continue;
+                               if ((sm_ptr->sub_align & SUB_ALIGN_GOOD) && (r_ptr->flags3 & RF3_EVIL)) continue;
                        }
                        break;
                }
@@ -2572,7 +2592,17 @@ void choose_new_monster(int m_idx, bool born, int r_idx)
        m_ptr->ap_r_idx = r_idx;
        update_mon(m_idx, FALSE);
        lite_spot(m_ptr->fy, m_ptr->fx);
-       if (born) return;
+       if (born)
+       {
+               /* Sub-alignment of a chameleon */
+               if (r_ptr->flags3 & (RF3_EVIL | RF3_GOOD))
+               {
+                       m_ptr->sub_align = SUB_ALIGN_NEUTRAL;
+                       if (r_ptr->flags3 & RF3_EVIL) m_ptr->sub_align |= SUB_ALIGN_EVIL;
+                       if (r_ptr->flags3 & RF3_GOOD) m_ptr->sub_align |= SUB_ALIGN_GOOD;
+               }
+               return;
+       }
 
        if (m_idx == p_ptr->riding)
        {
@@ -2857,6 +2887,16 @@ msg_print("
        m_ptr->r_idx = r_idx;
        m_ptr->ap_r_idx = initial_r_appearance(r_idx);
 
+       /* Sub-alignment of a monster */
+       if ((who > 0) && !(r_ptr->flags3 & (RF3_EVIL | RF3_GOOD)))
+               m_ptr->sub_align = m_list[who].sub_align;
+       else
+       {
+               m_ptr->sub_align = SUB_ALIGN_NEUTRAL;
+               if (r_ptr->flags3 & RF3_EVIL) m_ptr->sub_align |= SUB_ALIGN_EVIL;
+               if (r_ptr->flags3 & RF3_GOOD) m_ptr->sub_align |= SUB_ALIGN_GOOD;
+       }
+
        /* Place the monster at the location */
        m_ptr->fy = y;
        m_ptr->fx = x;
@@ -2882,10 +2922,19 @@ msg_print("
 
        if (r_ptr->flags7 & RF7_CHAMELEON)
        {
+               if (who > 0) summon_specific_who_for_chameleons = who;
+               else summon_specific_who_for_chameleons = 0;
+
                choose_new_monster(c_ptr->m_idx, TRUE, 0);
                r_ptr = &r_info[m_ptr->r_idx];
                m_ptr->mflag2 |= MFLAG_CHAMELEON;
                rating++;
+
+               /* Hack - Set sub_align to neutral when the Chameleon Lord is generated as "GUARDIAN" */
+               if ((r_ptr->flags1 & RF1_UNIQUE) && (who <= 0))
+                       m_ptr->sub_align = SUB_ALIGN_NEUTRAL;
+
+               summon_specific_who_for_chameleons = 0;
        }
        else if (is_kage)
        {
@@ -2893,16 +2942,6 @@ msg_print("
                m_ptr->mflag2 |= MFLAG_KAGE;
        }
 
-       /* Sub-alignment of a monster */
-       if ((who > 0) && !(r_ptr->flags3 & (RF3_EVIL | RF3_GOOD)))
-               m_ptr->sub_align = m_list[who].sub_align;
-       else
-       {
-               m_ptr->sub_align = SUB_ALIGN_NEUTRAL;
-               if (r_ptr->flags3 & RF3_EVIL) m_ptr->sub_align |= SUB_ALIGN_EVIL;
-               if (r_ptr->flags3 & RF3_GOOD) m_ptr->sub_align |= SUB_ALIGN_GOOD;
-       }
-
        if (no_pet) m_ptr->mflag2 |= MFLAG_NOPET;
 
        /* Not visible */