コード例 #1
0
    void UpdateAI(const uint32 uiDiff)
    {
        if (!m_bCombatStarted)
            return;

        // Outro
        if (m_bIsHealed)
        {
            if (m_uiOutroTimer <= uiDiff)
            {
                if (m_pInstance)
                {
                    m_pInstance->SetData(TYPE_VALITHRIA, DONE);

                    if (Creature *pDummy = m_pInstance->GetSingleCreatureFromStorage(NPC_GREEN_DRAGON_COMBAT_TRIGGER))
                    {
                        // Set Valithria credit
                        pDummy->CastSpell(pDummy, SPELL_ACHIEVEMENT_CREDIT, true);
                        pDummy->ForcedDespawn(1000);
                    }
                }

                DoRemoveAdds(); // just to be sure
                m_uiOutroTimer = 30000;
                m_creature->ForcedDespawn(1000);
            }
            else
                m_uiOutroTimer -= uiDiff;

            return;
        }

        // Health Check
        if (m_uiHealthCheckTimer <= uiDiff)
        {
            float fHP = m_creature->GetHealthPercent();

            // when reached 75% health
            if (!m_bSaidOver75)
            {
                if (fHP > 75.0f)
                {
                    DoScriptText(SAY_75_HEALTH, m_creature);
                    m_bSaidOver75 = true;
                }
            }

            // when reached 25% health
            if (!m_bSaidOver25)
            {
                if (fHP < 25.0f)
                {
                    DoScriptText(SAY_25_HEALTH, m_creature);
                    m_bSaidOver25 = true;
                }
            }

            // check if encounter is completed
            if (fHP > 95.0f)
            {
                if (DoCastSpellIfCan(m_creature, SPELL_DREAMWALKER_RAGE) == CAST_OK)
                {
                    DoScriptText(SAY_VICTORY, m_creature);
                    m_creature->RemoveAllAuras();
                    m_bIsHealed = true;
                    return;
                }
            }

            m_uiHealthCheckTimer = 1000;
        }
        else
            m_uiHealthCheckTimer -= uiDiff;

        // Enrage
        // After 7 minutes summoning of Suppressers is much faster
        if (!m_bIsEnrage)
        {
            if (m_uiEnrageTimer <= uiDiff)
            {
                m_bIsEnrage = true;
            }
            else
                m_uiEnrageTimer -= uiDiff;
        }

        // Summon Portals
        if (m_uiSummonPortalsTimer <= uiDiff)
        {
            uint32 max = m_bIs25Man ? 12 : 6;

            // this way makes sure that spell is cast
            // this should be done via ScriptEffect spell, but we don't need it in SD2
            for (uint32 i = 0; i < max; ++i)
                m_creature->CastSpell(m_creature, m_bIsHeroic ? SPELL_NIGHTMARE_PORTAL_PRE : SPELL_DREAM_PORTAL_PRE, true);

            if (!m_bIsHeroic)
                DoScriptText(SAY_PORTAL, m_creature);

            m_uiSummonPortalsTimer = 45000;
        }
        else
            m_uiSummonPortalsTimer -= uiDiff;

        // Summon adds

        // Summon Suppresser
        if (m_uiSummonSuppresserTimer <= uiDiff)
        {
            uint32 uiReduction;

            for (uint32 i = 0; i < urand(1, m_bIs25Man ? 3 : 2) + m_uiSummonSuppresserCounter; ++i)
                DoSummonAdd(NPC_SUPPRESSER);

            // 5s faster each summoning
            uiReduction = m_uiSummonSuppresserCounter >= 10 ? 50000 : (m_uiSummonSuppresserCounter * 5000);
            m_uiSummonSuppresserTimer = 60000 - uiReduction; 
            ++m_uiSummonSuppresserCounter;
        }
        else
            m_uiSummonSuppresserTimer -= uiDiff;

        // Summon Blazing Skeleton
        if (m_uiSummonSkeletonTimer <= uiDiff)
        {
            uint32 uiReduction;

            DoSummonAdd(NPC_BLAZING_SKELETON);
            // 5s faster each summoning
            uiReduction = m_uiSummonSkeletonCounter >= 10 ? 50000 : (m_uiSummonSkeletonCounter * 5000);
            m_uiSummonSkeletonTimer = 60000 - uiReduction;
            ++m_uiSummonSkeletonCounter;
        }
        else
            m_uiSummonSkeletonTimer -= uiDiff;

        // Summon Abomination
        if (m_uiSummonAbominationTimer <= uiDiff)
        {
            DoSummonAdd(NPC_GLUTTONOUS_ABOMINATION);
            m_uiSummonAbominationTimer = urand(30000, 60000);
        }
        else
            m_uiSummonAbominationTimer -= uiDiff;

        // Summon Zombie
        if (m_uiSummonZombieTimer <= uiDiff)
        {
            DoSummonAdd(NPC_BLISTERING_ZOMBIE);
            m_uiSummonZombieTimer = urand(25000, 50000);
        }
        else
            m_uiSummonZombieTimer -= uiDiff;

        // Summon Archmage
        if (m_uiSummonArchmageTimer <= uiDiff)
        {
            DoSummonAdd(NPC_RISEN_ARCHMAGE);
            m_uiSummonArchmageTimer = urand(20000, 50000);
        }
        else
            m_uiSummonArchmageTimer -= uiDiff;
    }
コード例 #2
0
    void UpdateAI(const uint32 uiDiff)
    {
        if (!m_bCombatStarted)
            return;

        // Outro
        if (m_bIsHealed)
        {
            if (m_uiOutroTimer <= uiDiff)
            {
                if (m_pInstance)
                {
                    m_pInstance->SetData(TYPE_VALITHRIA, DONE);
                    if (m_pInstance->GetData(TYPE_DIFFICULTY) == RAID_DIFFICULTY_10MAN_NORMAL) 
                        m_pInstance->DoCompleteAchievement(4579);
                    if (m_pInstance->GetData(TYPE_DIFFICULTY) == RAID_DIFFICULTY_25MAN_NORMAL) 
                        m_pInstance->DoCompleteAchievement(4619);

                    if (Creature *pDummy = m_pInstance->GetSingleCreatureFromStorage(NPC_COMBAT_TRIGGER))
                        m_creature->DealDamage(pDummy, pDummy->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NONE, NULL, false);
                }

                m_uiOutroTimer = 30000;
                m_creature->ForcedDespawn(1000);
            }
            else
                m_uiOutroTimer -= uiDiff;

            return;
        }

        // Health Check
        if (m_uiHealthCheckTimer <= uiDiff)
        {
            float fHP = m_creature->GetHealthPercent();

            // when reached 75% health
            if (!m_bSaidOver75)
            {
                if (fHP > 75.0f)
                {
                    DoScriptText(SAY_75_HEALTH, m_creature);
                    m_bSaidOver75 = true;
                }
            }

            // when reached 25% health
            if (!m_bSaidOver25)
            {
                if (fHP < 25.0f)
                {
                    DoScriptText(SAY_25_HEALTH, m_creature);
                    m_bSaidOver25 = true;
                }
            }

            // check if encounter is completed
            if (fHP > 95.0f)
            {
                if (DoCastSpellIfCan(m_creature, SPELL_DREAMWALKER_RAGE) == CAST_OK)
                {
                    DoScriptText(SAY_VICTORY, m_creature);
                    m_creature->RemoveAllAuras();
                    m_bIsHealed = true;
                    return;
                }
            }

            m_uiHealthCheckTimer = 1000;
        }
        else
            m_uiHealthCheckTimer -= uiDiff;

        // Enrage
        // After 7 minutes summoning of Suppressers is much faster
        if (!m_bIsEnrage)
        {
            if (m_uiEnrageTimer <= uiDiff)
            {
                m_bIsEnrage = true;
            }
            else
                m_uiEnrageTimer -= uiDiff;
        }

        // Summon Portals
        if (m_uiSummonPortalsTimer <= uiDiff)
        {
            uint32 max = m_bIs25Man ? 12 : 6;

            // this way makes sure that spell is cast
            // this should be done via ScriptEffect spell, but we don't need it in SD2
            for (uint32 i = 0; i < max; ++i)
                m_creature->CastSpell(m_creature, m_bIsHeroic ? SPELL_NIGHTMARE_PORTAL_PRE : SPELL_DREAM_PORTAL_PRE, true);

            if (!m_bIsHeroic)
                DoScriptText(SAY_PORTAL, m_creature);

            m_uiSummonPortalsTimer = 45000;
        }
        else
            m_uiSummonPortalsTimer -= uiDiff;

        // Summon Adds
        if (m_uiSummonAddTimer <= uiDiff)
        {
            DoSummonAdd();
            m_uiSummonAddTimer = GetNextSummonTimer();
        }
        else
            m_uiSummonAddTimer -= uiDiff;

        // Summon Suppresser
        if (m_uiSummonSuppresserTimer <= uiDiff)
        {
            uint32 max = 1;
            if (roll_chance_i(30))
                ++max;
            if (m_bIsEnrage)
                ++max;

            for (uint32 i = 0; i < max; ++i)
            {
                uint32 loc = urand(1, 2 + (m_bIs25Man ? 2 : 0));
                m_creature->SummonCreature(NPC_SUPPRESSER, SpawnLoc[loc].x, SpawnLoc[loc].y, SpawnLoc[loc].z, 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 1000);

                if (m_bIsEnrage)
                {
                    loc = urand(1, 2 + (m_bIs25Man ? 2 : 0));
                    m_creature->SummonCreature(NPC_BLAZING_SKELETON, SpawnLoc[loc].x, SpawnLoc[loc].y, SpawnLoc[loc].z, 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 1000);
                }
            }

            m_uiSummonSuppresserTimer = m_bIsEnrage ? urand(10000, 15000) : urand(15000, 30000);
        }
        else
            m_uiSummonSuppresserTimer -= uiDiff;
    }