Пример #1
0
    void UpdateAI(const uint32 uiDiff)
    {

        if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
            return;

        // Enrage
        if (m_uiEnrageTimer <= uiDiff)
        {
            if (DoCastSpellIfCan(m_creature, SPELL_BERSERK) == CAST_OK)
            {
                DoScriptText(SAY_BERSERK, m_creature);
                m_uiEnrageTimer = (5 * MINUTE + 30) * IN_MILLISECONDS;
            }
        }
        else
            m_uiEnrageTimer -= uiDiff;

        switch (m_uiPhase)
        {
            case PHASE_GROUND:
            {
                // phase change timer
                if (m_uiPhaseTimer <= uiDiff)
                {
                    m_uiPhase = PHASE_RUNNING;
                    SetCombatMovement(false);
                    m_creature->GetMotionMaster()->MovePoint(POINT_CENTER_GROUND, QueenLocs[0].x, QueenLocs[0].y, QueenLocs[0].z);
                    m_uiPhaseTimer = 13000;
                }
                else
                    m_uiPhaseTimer -= uiDiff;

                // Blood Mirror
                if (m_uiBloodMirrorTimer <= uiDiff)
                {
                    if (Unit *pVictim = SelectClosestFriendlyTarget(m_creature->getVictim()))
                    {
                        pVictim->CastSpell(m_creature->getVictim(), SPELL_BLOOD_MIRROR, true, 0, 0, pVictim->GetObjectGuid());
                        m_uiBloodMirrorTimer = 5000;
                    }
                }
                else
                    m_uiBloodMirrorTimer -= uiDiff;

                // Delirious Slash
                if (m_uiDeliriousSlashTimer <= uiDiff)
                {
                    /**
                     * Spell that handles targeting - we can do this here.
                     * if (DoCastSpellIfCan(m_creature, SPELL_DELIRIOUS_SLASH) == CAST_OK)
                     */
                    if (Unit *pTarget = SelectClosestFriendlyTarget(m_creature->getVictim()))
                    {
                        uint32 spell = SPELL_DELIRIOUS_SLASH_1;

                        // if target is not in 5yd range then cast spell with charge effect
                        if (!m_creature->IsWithinDist(pTarget, 5.0f))
                            spell = SPELL_DELIRIOUS_SLASH_2;

                        if (DoCastSpellIfCan(pTarget, spell) == CAST_OK)
                            m_uiDeliriousSlashTimer = 15000;
                    }
                }
                else
                    m_uiDeliriousSlashTimer -= uiDiff;

                // Vampiric Bite
                if (!m_bHasBitten)
                {
                    if (m_uiVampiricBiteTimer <= uiDiff)
                    {
                        /**
                         * Spell handles targeting, but we can do this here.
                         * if (DoCastSpellIfCan(m_creature, SPELL_VAMPIRIC_BITE) == CAST_OK)
                         */
                        if (Unit *pTarget = SelectVampiricBiteTarget())
                        {
                            if (DoCastSpellIfCan(pTarget, SPELL_VAMPIRIC_BITE_TRIGGERED) == CAST_OK)
                            {
                                m_bHasBitten = true;
                                DoScriptText(SAY_BITE_1 - urand(0, 1), m_creature);
                            }
                        }
                    }
                    else
                        m_uiVampiricBiteTimer -= uiDiff;
                }

                // Twilight Bloodbolt
                if (m_uiBloodboltTimer <= uiDiff)
                {
                    if (DoCastSpellIfCan(m_creature, SPELL_TWILIGHT_BLOODBOLT) == CAST_OK)
                        m_uiBloodboltTimer = urand(15000, 20000);
                }
                else
                    m_uiBloodboltTimer -= uiDiff;

                // Pact of the Darkfallen
                if (m_uiPactTimer <= uiDiff)
                {
                    if (DoCastSpellIfCan(m_creature, SPELL_PACT_OF_THE_DARKFALLEN) == CAST_OK)
                    {
                        m_uiPactTimer = urand(20000, 25000);
                        DoScriptText(SAY_PACT, m_creature);
                    }
                }
                else
                    m_uiPactTimer -= uiDiff;

                // Swarming Shadows
                if (m_uiSwarmingShadowsTimer <= uiDiff)
                {
                    /**
                     * spell which handles picking targets
                     * but we can use SelectAttackingTarget() here
                     * if (DoCastSpellIfCan(m_creature, SPELL_SWARMING_SHADOWS) == CAST_OK)
                     */
                    if (Unit *pTarget = SelectRandomRangedTarget(m_creature))
                    {
                        if (DoCastSpellIfCan(pTarget, SPELL_SWARMING_SHADOWS_TRIGGERED) == CAST_OK)
                        {
                            m_uiSwarmingShadowsTimer = urand(30000, 35000);
                            DoScriptText(SAY_SHADOWS, m_creature);
                        }
                    }
                }
                else
                    m_uiSwarmingShadowsTimer -= uiDiff;

                DoMeleeAttackIfReady();

                break;
            }
            case PHASE_RUNNING:
            case PHASE_FLYING:
            {
                // wait for arriving at the point
                break;
            }
            case PHASE_AIR:
            {
                // phase change timer
                if (m_uiPhaseTimer <= uiDiff)
                {
                    m_uiPhase = PHASE_FLYING;
                    m_uiPhaseTimer = 2 * MINUTE * IN_MILLISECONDS - 13000; // substract the air phase duration
                    m_creature->GetMotionMaster()->Clear();
                    m_creature->GetMotionMaster()->MovePoint(POINT_CENTER_GROUND, QueenLocs[0].x, QueenLocs[0].y, QueenLocs[0].z);
                }
                else
                    m_uiPhaseTimer -= uiDiff;

                break;
            }
        }
    }
    void UpdateAI(const uint32 uiDiff)
    {
        if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
            return;

        if (m_uiBloodMirrorCheckTimer < uiDiff)
        {
            if (Unit *pOff = SelectClosestFriendlyTarget(m_creature->getVictim()))
            {
                if(m_creature->getVictim()->HasAura(SPELL_BLOOD_MIRROR_OFF))
                    m_creature->getVictim()->RemoveAurasDueToSpell(SPELL_BLOOD_MIRROR_OFF);

                if(pOff->HasAura(SPELL_BLOOD_MIRROR_TANK))
                    pOff->RemoveAurasDueToSpell(SPELL_BLOOD_MIRROR_TANK);

                if (!m_creature->getVictim()->HasAura(SPELL_BLOOD_MIRROR_TANK))
                {
                    pOff->CastSpell(m_creature->getVictim(), SPELL_BLOOD_MIRROR_TANK, true);
                    /*if (pOff->HasAura(SPELL_SHADOWS_EDGE) && !pOff->HasAura(SPELL_GUSHING_WOUND) && m_bIs25Man)
                        pOff->CastSpell(pOff, SPELL_GUSHING_WOUND, true);*/
                }
                if (!pOff->HasAura(SPELL_BLOOD_MIRROR_OFF))
                {
                    m_creature->getVictim()->CastSpell(pOff, SPELL_BLOOD_MIRROR_OFF, true);
                    /*if (m_creature->getVictim()->HasAura(SPELL_SHADOWS_EDGE) && !m_creature->getVictim()->HasAura(SPELL_GUSHING_WOUND) && m_bIs25Man)
                        m_creature->getVictim()->CastSpell(m_creature->getVictim(), SPELL_GUSHING_WOUND, true);*/
                }
            }
            m_uiBloodMirrorCheckTimer = 500;
        }
        else m_uiBloodMirrorCheckTimer -= uiDiff;

        if (m_uiEnrageTimer < uiDiff)
        {
            if (DoCastSpellIfCan(m_creature, SPELL_BERSERK, CAST_TRIGGERED) == CAST_OK)
            {
                DoScriptText(SAY_BERSERK,m_creature);
                m_uiEnrageTimer = 5.5 * MINUTE * IN_MILLISECONDS;
            }
        }
        else m_uiEnrageTimer -= uiDiff;

        switch (m_uiPhase)
        {
        case PHASE_GROUND:
            if (m_uiTwilightTimer < uiDiff)
            {
                if (Unit *pTarget = SelectRandomRangedTarget(m_creature))
                {
                    if (DoCastSpellIfCan(pTarget, SPELL_TWILIGHT_BLOODBOLT) == CAST_OK)
                        m_uiTwilightTimer = urand(12000, 17000);
                }
            }
            else m_uiTwilightTimer -= uiDiff;

            // Delirious Slash
            if (m_uiDeliriousSlashTimer <= uiDiff)
            {
                /**
                 * Spell that handles targeting - we can do this here.
                 * if (DoCastSpellIfCan(m_creature, SPELL_DELIRIOUS_SLASH) == CAST_OK)
                 */
                if (Unit *pTarget = SelectClosestFriendlyTarget(m_creature->getVictim()))
                {
                    uint32 spell = SPELL_DELIRIOUS_SLASH_1;

                    // if target is not in 5yd range then cast spell with charge effect
                    if (!m_creature->IsWithinDist(pTarget, 5.0f))
                        spell = SPELL_DELIRIOUS_SLASH_2;

                    if (DoCastSpellIfCan(pTarget, spell) == CAST_OK)
                        m_uiDeliriousSlashTimer = 15000;
                }
            }
            else
                m_uiDeliriousSlashTimer -= uiDiff;

            /*if (m_uiDeliriousSlashTimer < uiDiff)
            {
                if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM,2))
                {
                    if (DoCastSpellIfCan(pTarget, SPELL_DELIRIOUS_SLASH) == CAST_OK)
                        m_uiDeliriousSlashTimer = urand(15000, 20000);
                }
            }
            else m_uiDeliriousSlashTimer -= uiDiff;*/

            if (m_uiPactTimer < uiDiff)
            {
                //if (Unit *pTarget = SelectRandomRangedTarget(m_creature))
                //{
                    if (DoCastSpellIfCan(m_creature, SPELL_PACT_OF_DARKFALLEN) == CAST_OK)
                    {
                        DoScriptText(SAY_PACT, m_creature);
                        m_uiPactTimer = 30000;
                    }
                //}
            }
            else m_uiPactTimer -= uiDiff;

            if (m_uiShadowsTimer < uiDiff)
            {
                if (Unit *pTarget = SelectRandomRangedTarget(m_creature))
                {
                    if (DoCastSpellIfCan(pTarget, SPELL_SWARMING_SHADOWS) == CAST_OK)
                    {
                        DoScriptText(SAY_SHADOWS,m_creature);
                        m_uiShadowsTimer = 30000;
                    }
                }
            }
            else m_uiShadowsTimer -= uiDiff;

            if (m_uiBiteTimer < uiDiff && !m_bBite)
            {
                if (Unit* pTarget = SelectVampiricBiteTarget())
                {
                    if (DoCastSpellIfCan(pTarget, SPELL_VAMPIRIC_BITE) == CAST_OK)
                    {
                        m_bBite = true;
                        DoScriptText(SAY_BITE_1, m_creature);
                    }
                }
            }
            else m_uiBiteTimer -= uiDiff;

            if (m_uiPhaseTimer < uiDiff && m_creature->GetHealthPercent() >= 5)
            {
                m_uiPhase = PHASE_MOVING_CENTER;
                m_creature->GetMotionMaster()->Clear();
                m_creature->GetMotionMaster()->MovePoint(POINT_CENTER_GROUND, QueenLocs[0].x, QueenLocs[0].y, QueenLocs[0].z);
                SetCombatMovement(false);
                m_uiPhaseTimer = 13000;
            }
            else m_uiPhaseTimer -= uiDiff;

            DoMeleeAttackIfReady();
            break;
        case PHASE_MOVING_CENTER:
            break;
        case PHASE_FLYING:
            m_creature->HandleEmote(EMOTE_ONESHOT_LAND);
            break;
        case PHASE_AIR:
            // phase change timer
            if (m_uiPhaseTimer <= uiDiff)
            {
                m_uiPhase = PHASE_FLYING;
                m_uiPhaseTimer = 2 * MINUTE * IN_MILLISECONDS - 13000; // substract the air phase duration
                m_creature->GetMotionMaster()->Clear();
                m_creature->GetMotionMaster()->MovePoint(POINT_CENTER_GROUND, QueenLocs[0].x, QueenLocs[0].y, QueenLocs[0].z);
            }
            else
                m_uiPhaseTimer -= uiDiff;

            break;
        }
    }