Exemplo n.º 1
0
    void JustDidDialogueStep(int32 iEntry) override
    {
        switch (iEntry)
        {
        case PHASE_DISCS:
            // ToDo: start some movement over the platform
            m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
            m_uiPhase = PHASE_DISCS;
            DoSpawnAdds();
            break;
        case SPELL_DESTROY_PLATFORM_BOOM:
            if (m_pInstance)
            {
                if (Creature* pTrigger = m_pInstance->GetSingleCreatureFromStorage(NPC_LARGE_TRIGGER))
                    pTrigger->CastSpell(pTrigger, SPELL_DESTROY_PLATFORM_BOOM, false);
            }
            break;
        case SPELL_SUMMON_RED_DRAGON:
            if (m_pInstance)
            {
                // Destroy the platform
                if (GameObject* pPlatform = m_pInstance->GetSingleGameObjectFromStorage(GO_PLATFORM))
                    pPlatform->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_UNK_11);
            }

            DoCastSpellIfCan(m_creature, SPELL_SUMMON_RED_DRAGON);
            break;
        case SAY_INTRO_PHASE_3:
            m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
            m_uiPhase = PHASE_DRAGONS;
            break;
        }
    }
    void UpdateAI(const uint32 uiDiff) override
    {
        if (m_uiBeamInitTimer)
        {
            if (m_uiBeamInitTimer <= uiDiff)
            {
                DoHandleBeamHelpers(false);
                m_uiBeamInitTimer = 0;
            }
            else
                m_uiBeamInitTimer -= uiDiff;
        }

        if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
        {
            // handle elementals on OOC timer
            if (m_uiElementalTimer < uiDiff)
            {
                if (DoCastSpellIfCan(m_creature, SPELL_SUMMON_WATER_ELEMENT) == CAST_OK)
                    m_uiElementalTimer = 20000;
            }
            else
                m_uiElementalTimer -= uiDiff;

            return;
        }

        // corrupted form
        if (m_bCorruptedForm)
        {
            if (m_uiVileSludgeTimer < uiDiff)
            {
                if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0, nullptr, SELECT_FLAG_PLAYER))
                {
                    if (DoCastSpellIfCan(pTarget, SPELL_VILE_SLUDGE) == CAST_OK)
                        m_uiVileSludgeTimer = 15000;
                }
            }
            else
                m_uiVileSludgeTimer -= uiDiff;

            // Change to clean
            if (m_uiPosCheckTimer < uiDiff)
            {
                if (CheckTransition())
                {
                    DoScriptText(SAY_SWITCH_TO_CLEAN, m_creature);
                    m_creature->RemoveAurasDueToSpell(SPELL_CORRUPTION);
                    m_uiMarkCount = 0;

                    DoHandleBeamHelpers(false);
                    DoResetThreat();
                    DoSpawnAdds();

                    m_creature->SetMeleeDamageSchool(SPELL_SCHOOL_FROST);
                    m_creature->ApplySpellImmune(nullptr, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_FROST, true);
                    m_creature->ApplySpellImmune(nullptr, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_NATURE, false);

                    m_bCorruptedForm = false;
                    m_uiMarkTimer    = 15000;
                }

                m_uiPosCheckTimer = 1000;
            }
            else
                m_uiPosCheckTimer -= uiDiff;
        }
        // clean form
        else
        {
            if (m_uiWaterTombTimer < uiDiff)
            {
                if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 1, nullptr, SELECT_FLAG_PLAYER))
                {
                    if (DoCastSpellIfCan(pTarget, SPELL_WATER_TOMB) == CAST_OK)
                        m_uiWaterTombTimer = 7000;
                }
            }
            else
                m_uiWaterTombTimer -= uiDiff;

            // Change to corrupt
            if (m_uiPosCheckTimer < uiDiff)
            {
                if (!CheckTransition())
                {
                    if (DoCastSpellIfCan(m_creature, SPELL_CORRUPTION) == CAST_OK)
                    {
                        DoScriptText(SAY_SWITCH_TO_CORRUPT, m_creature);
                        m_uiMarkCount = 0;

                        DoHandleBeamHelpers(true);
                        DoResetThreat();
                        DoSpawnAdds();

                        m_creature->SetMeleeDamageSchool(SPELL_SCHOOL_NATURE);
                        m_creature->ApplySpellImmune(nullptr, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_NATURE, true);
                        m_creature->ApplySpellImmune(nullptr, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_FROST, false);

                        m_bCorruptedForm = true;
                        m_uiMarkTimer    = 15000;
                    }
                }

                m_uiPosCheckTimer = 500;
            }
            else
                m_uiPosCheckTimer -= uiDiff;
        }

        // Apply mark debuff
        if (m_uiMarkTimer < uiDiff)
        {
            if (DoCastSpellIfCan(m_creature, m_bCorruptedForm ? aMarkCorruption[m_uiMarkCount] : aMarkHydross[m_uiMarkCount]) == CAST_OK)
            {
                ++m_uiMarkCount;
                m_uiMarkTimer = 15000;

                // limit the mark counter to 6
                if (m_uiMarkCount == MAX_HYDROSS_MARKS)
                    m_uiMarkCount = MAX_HYDROSS_MARKS - 1;
            }
        }
        else
            m_uiMarkTimer -= uiDiff;

        if (m_uiEnrageTimer)
        {
            if (m_uiEnrageTimer <= uiDiff)
            {
                if (DoCastSpellIfCan(m_creature, SPELL_ENRAGE) == CAST_OK)
                    m_uiEnrageTimer = 0;
            }
            else
                m_uiEnrageTimer -= uiDiff;
        }

        DoMeleeAttackIfReady();
    }