Example #1
0
            void UpdateAI(uint32 diff) override
            {
                if (!UpdateVictim() || !CheckInRoom())
                    return;

                events.Update(diff);

                if (me->HasUnitState(UNIT_STATE_CASTING))
                    return;

                while (uint32 eventId = events.ExecuteEvent())
                {
                    switch (eventId)
                    {
                        case EVENT_BONE_SPIKE_GRAVEYARD:
                            if (IsHeroic() || !me->HasAura(SPELL_BONE_STORM))
                                DoCast(me, SPELL_BONE_SPIKE_GRAVEYARD);
                            events.ScheduleEvent(EVENT_BONE_SPIKE_GRAVEYARD, urand(15000, 20000), EVENT_GROUP_SPECIAL);
                            break;
                        case EVENT_COLDFLAME:
                            _coldflameLastPos.Relocate(me);
                            _coldflameTarget.Clear();
                            if (!me->HasAura(SPELL_BONE_STORM))
                                DoCastAOE(SPELL_COLDFLAME_NORMAL);
                            else
                                DoCast(me, SPELL_COLDFLAME_BONE_STORM);
                            events.ScheduleEvent(EVENT_COLDFLAME, 5000, EVENT_GROUP_SPECIAL);
                            break;
                        case EVENT_WARN_BONE_STORM:
                            _boneSlice = false;
                            Talk(EMOTE_BONE_STORM);
                            me->FinishSpell(CURRENT_MELEE_SPELL, false);
                            DoCast(me, SPELL_BONE_STORM);
                            events.DelayEvents(3000, EVENT_GROUP_SPECIAL);
                            events.ScheduleEvent(EVENT_BONE_STORM_BEGIN, 3050);
                            events.ScheduleEvent(EVENT_WARN_BONE_STORM, urand(90000, 95000));
                            break;
                        case EVENT_BONE_STORM_BEGIN:
                            me->SetReactState(REACT_PASSIVE);
                            if (Aura* pStorm = me->GetAura(SPELL_BONE_STORM))
                                pStorm->SetDuration(int32(_boneStormDuration));
                            me->SetSpeed(MOVE_RUN, _baseSpeed*3.0f, true);
                            Talk(SAY_BONE_STORM);
                            events.ScheduleEvent(EVENT_BONE_STORM_END, _boneStormDuration+1);
                            // no break here
                        case EVENT_BONE_STORM_MOVE:
                        {
                            events.ScheduleEvent(EVENT_BONE_STORM_MOVE, _boneStormDuration/3);
                            Unit* unit = SelectTarget(SELECT_TARGET_RANDOM, 0, NonTankTargetSelector(me));
                            if (!unit)
                                unit = SelectTarget(SELECT_TARGET_RANDOM, 0, 0.0f, true);
                            if (unit)
                                me->GetMotionMaster()->MovePoint(POINT_TARGET_BONESTORM_PLAYER, *unit);
                            break;
                        }
                        case EVENT_BONE_STORM_END:
                            me->SetReactState(REACT_AGGRESSIVE);
                            if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() == POINT_MOTION_TYPE)
                                me->GetMotionMaster()->MovementExpired();
                            me->GetMotionMaster()->MoveChase(me->GetVictim());
                            me->SetSpeed(MOVE_RUN, _baseSpeed, true);
                            events.CancelEvent(EVENT_BONE_STORM_MOVE);
                            events.ScheduleEvent(EVENT_ENABLE_BONE_SLICE, 10000);
                            if (!IsHeroic())
                                events.RescheduleEvent(EVENT_BONE_SPIKE_GRAVEYARD, 15000, EVENT_GROUP_SPECIAL);
                            break;
                        case EVENT_ENABLE_BONE_SLICE:
                            _boneSlice = true;
                            break;
                        case EVENT_ENRAGE:
                            DoCast(me, SPELL_BERSERK, true);
                            Talk(SAY_BERSERK);
                            break;
                    }
                }

                // We should not melee attack when storming
                if (me->HasAura(SPELL_BONE_STORM))
                    return;

                // 10 seconds since encounter start Bone Slice replaces melee attacks
                if (_boneSlice && !me->GetCurrentSpell(CURRENT_MELEE_SPELL))
                    DoCastVictim(SPELL_BONE_SLICE);

                DoMeleeAttackIfReady();
            }
Example #2
0
    void UpdateAI(const uint32 diff)
    {
        if (!UpdateVictim())
            return;

        if (Phase == 3)
        {
            if (Timer[TIMER_PHASE] <= diff)
            {
                if (!pInstance)
                    return;
                switch(pInstance->GetData(DATA_MURU_EVENT))
                {
                    case NOT_STARTED:
                        Reset();
                        break;
                    case DONE:
                        Phase = 4;
                        me->DisappearAndDie();
                        break;
                }
                Timer[TIMER_PHASE] = 3000;
            } else Timer[TIMER_PHASE] -= diff;
            return;
        }

        if (EnrageTimer < diff && !me->HasAura(SPELL_ENRAGE, 0))
        {
            DoCast(me, SPELL_ENRAGE, false);
        } else EnrageTimer -= diff;

        for (uint8 i = 0; i < 4; ++i)
        {
            if (Timer[i] <= diff)
            {
                switch(i)
                {
                    case TIMER_DARKNESS:
                        if (!DarkFiend)
                        {
                            DoCastAOE(SPELL_DARKNESS, false);
                            Timer[TIMER_DARKNESS] = 3000;
                            DarkFiend = true;
                        }
                        else
                        {
                            DarkFiend = false;
                            for (uint8 i = 0; i < 8; ++i)
                                me->SummonCreature(CREATURE_DARK_FIENDS,DarkFiends[i][0],DarkFiends[i][1],DarkFiends[i][2], DarkFiends[i][3], TEMPSUMMON_CORPSE_DESPAWN, 0);
                            Timer[TIMER_DARKNESS] = 42000;
                        }
                        break;
                    case TIMER_HUMANOIDES:
                        for (uint8 i = 0; i < 6; ++i)
                            me->SummonCreature(Humanoides[i][0],Humanoides[i][1],Humanoides[i][2],Humanoides[i][3], Humanoides[i][4], TEMPSUMMON_CORPSE_DESPAWN, 0);
                        Timer[TIMER_HUMANOIDES] = 60000;
                        break;
                    case TIMER_PHASE:
                        me->RemoveAllAuras();
                        DoCast(me, SPELL_SUMMON_ENTROPIUS, false);
                        Timer[TIMER_PHASE] = 3000;
                        Phase = 3;
                        return;
                    case TIMER_SENTINEL:
                        DoCastAOE(SPELL_OPEN_PORTAL_2, false);
                        Timer[TIMER_SENTINEL] = 30000;
                        break;
                }
                break;
            }
        }

        //Timer
        for (uint8 i = 0; i < 4; ++i)
        {
            if (i != TIMER_PHASE)Timer[i] -= diff;
            else if (Phase == 2) Timer[i] -= diff;
        }
    }
Example #3
0
    void UpdateAI(const uint32 diff)
    {
        if (!UpdateCombatState() || !CheckInRoom())
            return;

        events.Update(diff);

        while(uint32 eventId = events.ExecuteEvent())
        {
            switch(eventId)
            {
                case EVENT_CURSE:
                    DoCastAOE(SPELL_CURSE_PLAGUEBRINGER);
                    events.ScheduleEvent(EVENT_CURSE, 20000+rand()%10000);
                    return;
                case EVENT_WARRIOR:
                    DoScriptText(SAY_SUMMON, me);
                    SummonUndead(MOB_WARRIOR, HEROIC(2,3));
                    events.ScheduleEvent(EVENT_WARRIOR, 30000);
                    return;
                case EVENT_BLINK:
                    DoCastAOE(SPELL_CRIPPLE, true);
                    DoCastAOE(SPELL_BLINK);
                    DoResetThreat();
                    events.ScheduleEvent(EVENT_BLINK, 20000+rand()%10000);
                    return;
                case EVENT_BALCONY:
                    me->SetReactState(REACT_PASSIVE);
                    me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                    me->AttackStop();
                    me->RemoveAllAuras();
                    me->NearTeleportTo(TELE_X, TELE_Y, TELE_Z, TELE_O);
                    events.Reset();
                    events.ScheduleEvent(EVENT_WAVE, 2000);
                    waveCount = 0;
                    return;
                case EVENT_WAVE:
                    DoScriptText(SAY_SUMMON, me);
                    switch(balconyCount)
                    {
                        case 0: SummonUndead(MOB_CHAMPION, HEROIC(2,4)); break;
                        case 1: SummonUndead(MOB_CHAMPION, HEROIC(1,2));
                                SummonUndead(MOB_GUARDIAN, HEROIC(1,2)); break;
                        case 2: SummonUndead(MOB_GUARDIAN, HEROIC(2,4)); break;
                        default:SummonUndead(MOB_CHAMPION, HEROIC(5,10));
                                SummonUndead(MOB_GUARDIAN, HEROIC(5,10));break;
                    }
                    ++waveCount;
                    events.ScheduleEvent(waveCount < 2 ? EVENT_WAVE : EVENT_GROUND, 34000);
                    return;
                case EVENT_GROUND:
                {
                    ++balconyCount;
                    float x, y, z, o;
                    me->GetHomePosition(x, y, z, o);
                    me->NearTeleportTo(x, y, z, o);
                    EnterPhaseGround();
                    return;
                }
            }
        }

        if (me->HasReactState(REACT_AGGRESSIVE))
            DoMeleeAttackIfReady();
    }
            void UpdateAI(uint32 diff) override
            {
                events.Update(diff);

                if (!events.IsInPhase(PHASE_BIRTH) && !UpdateVictim())
                    return;

                if (events.IsInPhase(PHASE_GROUND))
                {
                    while (uint32 eventId = events.ExecuteEvent())
                    {
                        switch (eventId)
                        {
                            case EVENT_CHECK_RESISTS:
                                DoCast(me, SPELL_CHECK_RESISTS);
                                events.Repeat(Seconds(30));
                                return;
                            case EVENT_GROUND:
                                EnterPhaseGround(false);
                                return;
                            case EVENT_BERSERK:
                                Talk(EMOTE_ENRAGE);
                                DoCast(me, SPELL_BERSERK);
                                return;
                            case EVENT_CLEAVE:
                                DoCastVictim(SPELL_CLEAVE);
                                events.ScheduleEvent(EVENT_CLEAVE, randtime(Seconds(5), Seconds(15)), 0, PHASE_GROUND);
                                return;
                            case EVENT_TAIL:
                                DoCastAOE(SPELL_TAIL_SWEEP);
                                events.ScheduleEvent(EVENT_TAIL, randtime(Seconds(7), Seconds(10)), 0, PHASE_GROUND);
                                return;
                            case EVENT_DRAIN:
                                if (events.IsInPhase(PHASE_FLIGHT))
                                    _delayedDrain = true;
                                else
                                    CastDrain();
                                return;
                            case EVENT_BLIZZARD:
                                DoCastAOE(SPELL_SUMMON_BLIZZARD);
                                events.ScheduleEvent(EVENT_BLIZZARD, RAID_MODE(Seconds(20), Seconds(7)), 0, PHASE_GROUND);
                                break;
                            case EVENT_FLIGHT:
                                if (HealthAbovePct(10))
                                {
                                    _delayedDrain = false;
                                    events.SetPhase(PHASE_FLIGHT);
                                    me->SetReactState(REACT_PASSIVE);
                                    me->AttackStop();
                                    float x, y, z, o;
                                    me->GetHomePosition(x, y, z, o);
                                    me->GetMotionMaster()->MovePoint(1, x, y, z);
                                    return;
                                }
                                break;
                        }
                    }

                    DoMeleeAttackIfReady();
                }
                else
                {
                    if (uint32 eventId = events.ExecuteEvent())
                    {
                        switch (eventId)
                        {
                            case EVENT_CHECK_RESISTS:
                                DoCast(me, SPELL_CHECK_RESISTS);
                                events.Repeat(Seconds(30));
                                return;
                            case EVENT_LIFTOFF:
                            {
                                Talk(EMOTE_AIR_PHASE);
                                if (Creature* buffet = DoSummon(NPC_WING_BUFFET, me, 0.0f, 0, TEMPSUMMON_MANUAL_DESPAWN))
                                    _buffet = buffet->GetGUID();
                                me->HandleEmoteCommand(EMOTE_ONESHOT_LIFTOFF);
                                me->SetHover(true);
                                events.ScheduleEvent(EVENT_ICEBOLT, Seconds(7), 0, PHASE_FLIGHT);

                                _iceboltTargets.clear();
                                std::list<Unit*> targets;
                                SelectTargetList(targets, RAID_MODE(2, 3), SELECT_TARGET_RANDOM, 200.0f, true);
                                for (Unit* target : targets)
                                    if (target)
                                        _iceboltTargets.push_back(target->GetGUID());
                                return;
                            }
                            case EVENT_ICEBOLT:
                            {
                                if (_iceboltTargets.empty())
                                {
                                    events.ScheduleEvent(EVENT_BREATH, Seconds(2), 0, PHASE_FLIGHT);
                                    return;
                                }
                                ObjectGuid target = _iceboltTargets.back();
                                if (Player* pTarget = ObjectAccessor::GetPlayer(*me, target))
                                    if (pTarget->IsAlive())
                                        DoCast(pTarget, SPELL_ICEBOLT);
                                _iceboltTargets.pop_back();

                                if (_iceboltTargets.empty())
                                    events.ScheduleEvent(EVENT_BREATH, Seconds(2), 0, PHASE_FLIGHT);
                                else
                                    events.Repeat(Seconds(3));
                                return;
                            }
                            case EVENT_BREATH:
                            {
                                Talk(EMOTE_BREATH);
                                DoCastAOE(SPELL_FROST_MISSILE);
                                events.ScheduleEvent(EVENT_EXPLOSION, Seconds(8), 0, PHASE_FLIGHT);
                                return;
                            }
                            case EVENT_EXPLOSION:
                                DoCastAOE(SPELL_FROST_BREATH);
                                DoCastAOE(SPELL_FROST_BREATH_ANTICHEAT);
                                events.ScheduleEvent(EVENT_LAND, Seconds(3) + Milliseconds(500), 0, PHASE_FLIGHT);
                                return;
                            case EVENT_LAND:
                                if (_delayedDrain)
                                    CastDrain();
                                if (Creature* cBuffet = ObjectAccessor::GetCreature(*me, _buffet))
                                {
                                    cBuffet->DespawnOrUnsummon(1 * IN_MILLISECONDS);
                                    _buffet.Clear();
                                }
                                me->HandleEmoteCommand(EMOTE_ONESHOT_LAND);
                                Talk(EMOTE_GROUND_PHASE);
                                me->SetHover(false);
                                events.SetPhase(PHASE_GROUND);
                                events.ScheduleEvent(EVENT_GROUND, Seconds(3) + Milliseconds(500), 0, PHASE_GROUND);
                                return;
                            case EVENT_BIRTH:
                                me->SetVisible(true);
                                me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                                me->SetReactState(REACT_AGGRESSIVE);
                                return;
                        }
                    }
                }
            }
            void UpdateAI(uint32 const diff)
            {
                if (!UpdateVictim() || !CheckInRoom())
                    return;

                events.Update(diff);

                if (me->HasUnitState(UNIT_STAT_CASTING))
                    return;

                while (uint32 eventId = events.ExecuteEvent())
                {
                    switch (eventId)
                    {
                        case EVENT_CHECK_PLAYERS:
                            instance->DoRemoveAurasDueToSpellOnPlayers(SPELL_TANK_MARKER);
                            events.ScheduleEvent(EVENT_CHECK_PLAYERS,2000);
                            break;
                        case EVENT_BONE_SPIKE_GRAVEYARD:
                            events.CancelEvent(EVENT_CHECK_PLAYERS);
                            if (IsHeroic() || !me->HasAura(SPELL_BONE_STORM))
                                DoCast(me, SPELL_BONE_SPIKE_GRAVEYARD);
                            events.ScheduleEvent(EVENT_BONE_SPIKE_GRAVEYARD, urand(15000, 20000), EVENT_GROUP_SPECIAL);
                            events.ScheduleEvent(EVENT_CHECK_PLAYERS,2000);
                            break;
                        case EVENT_COLDFLAME:
                            _coldflameLastPos.Relocate(me);
                            _coldflameTarget = 0LL;
                            if (!me->HasAura(SPELL_BONE_STORM))
                                DoCastAOE(SPELL_COLDFLAME_NORMAL);
                            else
                                DoCast(me, SPELL_COLDFLAME_BONE_STORM);
                            events.ScheduleEvent(EVENT_COLDFLAME, 5000, EVENT_GROUP_SPECIAL);
                            break;
                        case EVENT_WARN_BONE_STORM:
                            _boneSlice = false;
                            Talk(EMOTE_BONE_STORM);
                            me->FinishSpell(CURRENT_MELEE_SPELL, false);
                            DoCast(me, SPELL_BONE_STORM);
                            events.DelayEvents(3000, EVENT_GROUP_SPECIAL);
                            me->ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_MOD_TAUNT, true);
                            me->ApplySpellImmune(0, IMMUNITY_EFFECT, SPELL_EFFECT_ATTACK_ME, true);
                            events.ScheduleEvent(EVENT_BONE_STORM_BEGIN, 3050);
                            events.ScheduleEvent(EVENT_WARN_BONE_STORM, urand(90000, 95000));
                            break;
                        case EVENT_BONE_STORM_BEGIN:
                            if (Aura* pStorm = me->GetAura(SPELL_BONE_STORM))
                                pStorm->SetDuration(int32(_boneStormDuration));
                            me->SetSpeed(MOVE_RUN, _baseSpeed*3.0f, true);
                            Talk(SAY_BONE_STORM);
                            events.ScheduleEvent(EVENT_BONE_STORM_END, _boneStormDuration+1);
                            // no break here
                        case EVENT_BONE_STORM_MOVE:
                        {
                            if(me->GetMap()->IsHeroic())
                                events.ScheduleEvent(EVENT_BONE_STORM_MOVE, _boneStormDuration/5);
                            else events.ScheduleEvent(EVENT_BONE_STORM_MOVE, _boneStormDuration/4);
                            Unit* unit = SelectTarget(SELECT_TARGET_RANDOM, 1);
                            if (!unit || unit->isPet() || unit->isTotem())
                                unit = SelectTarget(SELECT_TARGET_RANDOM, 0, 0.0f, true);
                            if (unit)
                                if (unit->isPet() || unit->isTotem())
                                    unit = SelectTarget(SELECT_TARGET_RANDOM, 1);
								else me->GetMotionMaster()->MovePoint(POINT_TARGET_BONESTORM_PLAYER, unit->GetPositionX(), unit->GetPositionY(), unit->GetPositionZ());
                            break;
                        }
                        case EVENT_BONE_STORM_END:
                            if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() == POINT_MOTION_TYPE)
                                me->GetMotionMaster()->MovementExpired();
                            me->ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_MOD_TAUNT, false);
                            me->ApplySpellImmune(0, IMMUNITY_EFFECT, SPELL_EFFECT_ATTACK_ME, false);
                            DoStartMovement(me->getVictim());
                            me->SetSpeed(MOVE_RUN, _baseSpeed, true);
                            events.CancelEvent(EVENT_BONE_STORM_MOVE);
                            events.ScheduleEvent(EVENT_ENABLE_BONE_SLICE, 10000);
                            if (!IsHeroic())
                                events.RescheduleEvent(EVENT_BONE_SPIKE_GRAVEYARD, urand(15000, 20000), EVENT_GROUP_SPECIAL);
                            break;
                        case EVENT_ENABLE_BONE_SLICE:
                            _boneSlice = true;
                            break;
                        case EVENT_ENRAGE:
                            DoCast(me, SPELL_BERSERK, true);
                            Talk(SAY_BERSERK);
                            break;
                    }
                }

                // We should not melee attack when storming
                if (me->HasAura(SPELL_BONE_STORM))
                    return;

                // 10 seconds since encounter start Bone Slice replaces melee attacks
                if (_boneSlice && !me->GetCurrentSpell(CURRENT_MELEE_SPELL))
                    DoCastVictim(SPELL_BONE_SLICE);

                DoMeleeAttackIfReady();
            }
            void UpdateAI(const uint32 diff)
            {
                if (!UpdateVictim())
                    return;

                events.Update(diff);

                if ((me->HealthBelowPct(67) && phase == 0) ||
                    (me->HealthBelowPct(34) && phase == 2))
                {
                    phase++;
                    events.Reset();
                    me->AttackStop();
                    me->SetReactState(REACT_PASSIVE);
                    if (CelestialCall)
                         DoCast(me, SPELL_MIRROR_IMAGE_CC);
                    if (AstralRain)    
                        DoCast(me, SPELL_MIRROR_IMAGE_AR);
                    if (VeilOfSky)
                        DoCast(me, SPELL_MIRROR_IMAGE_VS);
                    me->SetVisible(false);
                    return;
                }

                if (me->HasUnitState(UNIT_STATE_CASTING))
				    return;

			    while (uint32 eventId = events.ExecuteEvent())
                {
                    switch (eventId)
                    {
                        case EVENT_SUPERNOVA:
                            Talk(SAY_SUPERNOVA);
                            DoCastAOE(SPELL_SUPERNOVA);
                            events.ScheduleEvent(EVENT_SUPERNOVA, urand(20000, 25000));
                            break;
                        case EVENT_ASTRAL_RAIN:
                            if (AstralRain)
                            {
                                if (phase == 0) DoCastAOE(SPELL_ASTRAL_RAIN1);
                                else if (phase == 2) DoCastAOE(SPELL_ASTRAL_RAIN2);
                                else if (phase == 4) DoCastAOE(SPELL_ASTRAL_RAIN3);
                                events.ScheduleEvent(EVENT_ASTRAL_RAIN, urand(15000, 22000));
                            }
                            break;
                        case EVENT_CELESTIAL_CALL:
                            if (CelestialCall)
                            {
                                if (phase == 0) DoCast(me, SPELL_CELESTIAL_CALL1);
                                else if (phase == 2) DoCast(me, SPELL_CELESTIAL_CALL2);
                                else if (phase == 4) DoCast(me, SPELL_CELESTIAL_CALL3);
                                events.ScheduleEvent(EVENT_CELESTIAL_CALL, urand(19000, 24000));
                            }
                            break;
                        case EVENT_VEIL_OF_SKY:
                            if (VeilOfSky)
                            {
                                if (phase == 0) DoCast(me, SPELL_VEIL_OF_SKY1);
                                else if (phase == 2) DoCast(me, SPELL_VEIL_OF_SKY2);
                                else if (phase == 4) DoCast(me, SPELL_VEIL_OF_SKY3);
                                events.ScheduleEvent(EVENT_VEIL_OF_SKY, urand(25000, 27000));
                            }
                            break;
                    }
                }

                DoMeleeAttackIfReady();
            }
Example #7
0
 void EnergizeSun()
 {
     //DoScriptText(SAY_ENERGIZE, me);
     me->GetMotionMaster()->MovePoint(0, X, Y, Z);
     DoCastAOE(SPELL_BLESSING_OF_THE_SUN);
 }
Example #8
0
        void UpdateAI(const uint32 uiDiff)
        {
            if (!UpdateVictim())
                return;

            //Common to PHASE_START && PHASE_END
            if (m_uiPhase == PHASE_START || m_uiPhase == PHASE_END)
            {
                //Specific to PHASE_START || PHASE_END
                if (m_uiPhase == PHASE_START)
                {
                    if (HealthBelowPct(60))
                    {
                        SetCombatMovement(false);
                        m_uiPhase = PHASE_BREATH;
                        me->GetMotionMaster()->MovePoint(10, Phase2Location);
                        return;
                    }
                }
                else
                {
                    if (m_uiBellowingRoarTimer <= uiDiff)
                    {
                        DoCastVictim(SPELL_BELLOWING_ROAR);
                        // Eruption
                        GameObject* pFloor = NULL;
                        Trinity::GameObjectInRangeCheck check(me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), 15);
                        Trinity::GameObjectLastSearcher<Trinity::GameObjectInRangeCheck> searcher(me, pFloor, check);
                        me->VisitNearbyGridObject(30, searcher);
                        if (m_pInstance && pFloor)
                            m_pInstance->SetData64(DATA_FLOOR_ERUPTION_GUID, pFloor->GetGUID());
                        m_uiBellowingRoarTimer = 30000;
                    }
                    else
                        m_uiBellowingRoarTimer -= uiDiff;
                }

                if (m_uiFlameBreathTimer <= uiDiff)
                {
                    DoCastVictim(SPELL_FLAME_BREATH);
                    m_uiFlameBreathTimer = urand(10000, 20000);
                }
                else
                    m_uiFlameBreathTimer -= uiDiff;

                if (m_uiTailSweepTimer <= uiDiff)
                {
                    DoCastAOE(SPELL_TAIL_SWEEP);
                    m_uiTailSweepTimer = urand(15000, 20000);
                }
                else
                    m_uiTailSweepTimer -= uiDiff;

                if (m_uiCleaveTimer <= uiDiff)
                {
                    DoCastVictim(SPELL_CLEAVE);
                    m_uiCleaveTimer = urand(2000, 5000);
                }
                else
                    m_uiCleaveTimer -= uiDiff;

                if (m_uiWingBuffetTimer <= uiDiff)
                {
                    DoCastVictim(SPELL_WING_BUFFET);
                    m_uiWingBuffetTimer = urand(15000, 30000);
                }
                else
                    m_uiWingBuffetTimer -= uiDiff;

                DoMeleeAttackIfReady();
            }
            else
            {
                if (HealthBelowPct(40))
                {
                    m_uiPhase = PHASE_END;
                    if (m_pInstance)
                        m_pInstance->SetData(DATA_ONYXIA_PHASE, m_uiPhase);
                    DoScriptText(SAY_PHASE_3_TRANS, me);

                    SetCombatMovement(true);
                    me->SetFlying(false);
                    m_bIsMoving = false;
                    me->GetMotionMaster()->MovePoint(9,me->GetHomePosition());
                    return;
                }

                if (m_uiDeepBreathTimer <= uiDiff)
                {
                    if (!m_bIsMoving)
                    {
                        if (me->IsNonMeleeSpellCasted(false))
                            me->InterruptNonMeleeSpells(false);

                        DoScriptText(EMOTE_BREATH, me);
                        DoCast(me, m_pPointData->uiSpellId);
                        m_uiDeepBreathTimer = 70000;
                    }
                }
                else
                    m_uiDeepBreathTimer -= uiDiff;

                if (m_uiMovementTimer <= uiDiff)
                {
                    if (!m_bIsMoving)
                    {
                        SetNextRandomPoint();
                        m_pPointData = GetMoveData();

                        if (!m_pPointData)
                            return;

                        me->GetMotionMaster()->MovePoint(m_pPointData->uiLocId, m_pPointData->fX, m_pPointData->fY, m_pPointData->fZ);
                        m_bIsMoving = true;
                        m_uiMovementTimer = 25000;
                    }
                }
                else
                    m_uiMovementTimer -= uiDiff;

                if (m_uiFireballTimer <= uiDiff)
                {
                    if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() != POINT_MOTION_TYPE)
                    {
                        if (Unit* pTarget = SelectUnit(SELECT_TARGET_RANDOM, 0))
                            DoCast(pTarget, SPELL_FIREBALL);

                        m_uiFireballTimer = 8000;
                    }
                }
                else
                    m_uiFireballTimer -= uiDiff;

                if (m_uiLairGuardTimer <= uiDiff)
                {
                    me->SummonCreature(NPC_LAIRGUARD, aSpawnLocations[2].GetPositionX(), aSpawnLocations[2].GetPositionY(), aSpawnLocations[2].GetPositionZ(), 0.0f, TEMPSUMMON_CORPSE_DESPAWN);
                    m_uiLairGuardTimer = 30000;
                }
                else
                    m_uiLairGuardTimer -= uiDiff;

                if (m_uiWhelpTimer <= uiDiff)
                {
                    me->SummonCreature(NPC_WHELP, aSpawnLocations[0].GetPositionX(), aSpawnLocations[0].GetPositionY(), aSpawnLocations[0].GetPositionZ(), 0.0f, TEMPSUMMON_CORPSE_DESPAWN);
                    me->SummonCreature(NPC_WHELP, aSpawnLocations[1].GetPositionX(), aSpawnLocations[1].GetPositionY(), aSpawnLocations[1].GetPositionZ(), 0.0f, TEMPSUMMON_CORPSE_DESPAWN);
                    if (m_uiSummonWhelpCount >= RAID_MODE(20,40))
                    {
                        m_uiSummonWhelpCount = 0;
                        m_uiWhelpTimer = 90000;
                    }
                    else
                        m_uiWhelpTimer = 500;
                }
                else
                    m_uiWhelpTimer -= uiDiff;
            }
        }
Example #9
0
            void UpdateAI(uint32 const diff)
            {
                if (!UpdateVictim())
                    return;

                events.Update(diff);

                if (me->HasUnitState(UNIT_STATE_CASTING))
                    return;

                while (uint32 eventId = events.ExecuteEvent())
                {
                    switch (eventId)
                    {
                        case EVENT_SONIC_SCREECH:
                            DoCast(SPELL_SONIC_SCREECH);
                            events.ScheduleEvent(EVENT_SONIC_SCREECH, urand(40*IN_MILLISECONDS, 60*IN_MILLISECONDS));
                            return;
                        case EVENT_TERRIFYING_SCREECH:
                            Talk(EMOTE_FEAR);
                            DoCast(SPELL_TERRIFYING_SCREECH);
                            events.ScheduleEvent(EVENT_TERRIFYING_SCREECH, urand(30*IN_MILLISECONDS, 50*IN_MILLISECONDS));
                            events.ScheduleEvent(EVENT_SENTINEL_BLAST, 1*IN_MILLISECONDS);
                            return;
                        case EVENT_SENTINEL_BLAST:
                            DoCastAOE(SPELL_SENTINEL_BLAST);
                            return;
                        case EVENT_ACTIVATE_DEFENDER:
                            Talk(EMOTE_DEFENDER);
                            DoCast(SPELL_DEFENDER_TRIGGER);
                            if (Creature* trigger = me->FindNearestCreature(NPC_FERAL_DEFENDER_TRIGGER, 50.0f))
                            {
                                trigger->SetDisplayId(MODEL_INVISIBLE);
                                DoCast(trigger, SPELL_ACTIVATE_DEFENDER, true);
                            }
                            return;
                        case EVENT_RESPAWN_DEFENDER:
                            if (defenderLives > 0)
                            {
                                if (Creature* defender = me->FindNearestCreature(NPC_FERAL_DEFENDER, 100.0f, false))
                                {
                                    defender->Respawn();
                                    defender->SetAuraStack(SPELL_FERAL_ESSENCE, defender, defenderLives);
                                }
                            }
                            return;
                        case EVENT_SUMMON_SWARMING_GUARDIAN:
                            if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 0.0f, true))
                                DoCast(target, SPELL_SUMMON_SWARMING_GUARDIAN);
                            events.ScheduleEvent(EVENT_SUMMON_SWARMING_GUARDIAN, urand(30*IN_MILLISECONDS, 45*IN_MILLISECONDS));
                            return;
                        case EVENT_BERSERK:
                            DoCast(me, SPELL_BERSERK, true);
                            Talk(SAY_BERSERK);
                            return;
                        default:
                            return;
                    }
                }

                DoMeleeAttackIfReady();
            }
        void UpdateAI(const uint32 diff)
        {
            switch(Phase)
            {
                case FLYING:
                    if (!UpdateVictim())
                        return;

                    if (me->GetPositionX() >= 475)
                    {
                        me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_NON_ATTACKABLE);
                        if (!m_bSaidEmote)
                        {
                            DoScriptText(EMOTE_RANGE, me);
                            m_bSaidEmote = true;
                        }
                    }
                    else
                    {
                        me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_NON_ATTACKABLE);
                        m_bSaidEmote = false;
                    }

                    if (m_uiMountTimer && m_uiMountTimer <= diff)
                    {
                        me->Mount(DATA_MOUNT);
                        me->SetFlying(true);
                        m_uiMountTimer = 0;
                    } else m_uiMountTimer -= diff;

                    if (m_uiSummonTimer <= diff)
                    {
                        SpawnMobs();
                        m_uiSummonTimer = 25000;
                    } else m_uiSummonTimer -= diff;

                    if (m_uiMovementTimer <= diff)
                    {
                        switch(m_uiWaypointId)
                        {
                            case 0:
                                me->GetMotionMaster()->MovePoint(0, Location[1].GetPositionX(), Location[1].GetPositionY(), Location[1].GetPositionZ());
                                m_uiMovementTimer = 5000;
                                break;
                            case 1:
                                me->GetMotionMaster()->MovePoint(0, Location[2].GetPositionX(), Location[2].GetPositionY(), Location[2].GetPositionZ());
                                m_uiMovementTimer = 2000;
                                break;
                            case 2:
                                me->GetMotionMaster()->MovePoint(0, Location[3].GetPositionX(), Location[3].GetPositionY(), Location[3].GetPositionZ());
                                m_uiMovementTimer = 15000;
                                break;
                            case 3:
                                me->GetMotionMaster()->MovePoint(0, Location[69].GetPositionX(), Location[69].GetPositionY(), Location[69].GetPositionZ());
                                DoScriptText(RAND(SAY_DRAKE_BREATH_1,SAY_DRAKE_BREATH_2), me);
                                DoScriptText(EMOTE_BREATH, me);
                                m_uiMovementTimer = 2500;
                                break;
                            case 4:
                                me->GetMotionMaster()->MovePoint(0, Location[70].GetPositionX(), Location[70].GetPositionY(), Location[70].GetPositionZ());
                                m_uiMovementTimer = 2000;
                                SpawnTrigger();
                                break;
                            case 5:
                                me->GetMotionMaster()->MovePoint(0, Location[71].GetPositionX(), Location[71].GetPositionY(), Location[71].GetPositionZ());
                                m_uiMovementTimer = 3000;
                                break;
                            case 6:
                                me->GetMotionMaster()->MovePoint(0, Location[3].GetPositionX(), Location[3].GetPositionY(), Location[3].GetPositionZ());
                                m_uiWaypointId = 2;
                                m_uiMovementTimer = 15000;
                                break;
                        }
                        m_uiWaypointId++;
                    } else m_uiMovementTimer -= diff;
                    break;
                case SKADI:
                    //Return since we have no target
                    if (!UpdateVictim())
                        return;

                    if (m_uiCrushTimer <= diff)
                    {
                        DoCastVictim(SPELL_CRUSH);
                        m_uiCrushTimer = 8000;
                    } else m_uiCrushTimer -= diff;

                    if (m_uiPoisonedSpearTimer <= diff)
                    {
                        if (Unit* pTarget = SelectTarget(SELECT_TARGET_RANDOM))
                            DoCast(pTarget, SPELL_POISONED_SPEAR);
                        m_uiPoisonedSpearTimer = 10000;
                    } else m_uiPoisonedSpearTimer -= diff;

                    if (m_uiWhirlwindTimer <= diff)
                    {
                        DoCastAOE(SPELL_WHIRLWIND);
                        m_uiWhirlwindTimer = 20000;
                    } else m_uiWhirlwindTimer -= diff;

                    DoMeleeAttackIfReady();
                    break;
            }
        }
Example #11
0
        void UpdateAI(const uint32 diff)
        {
            if (nextWP && movementStarted && !movementCompleted && !nextMovementStarted)
            {
                nextMovementStarted = true;
                me->GetMotionMaster()->MovePoint(nextWP, WaypointPositions[nextWP]);
            }

            if (!UpdateVictim() || !CheckInRoom() || !movementCompleted)
                return;

            events.Update(diff);

            if (me->HasUnitState(UNIT_STAT_CASTING))
                return;

            while (uint32 eventId = events.ExecuteEvent())
            {
                switch(eventId)
                {
                    case EVENT_MARK:
                        if (!(rand()%5))
                            DoScriptText(SAY_SPECIAL[id], me);
                        DoCastAOE(SPELL_MARK[id]);
                        events.ScheduleEvent(EVENT_MARK, 15000);
                        break;
                    case EVENT_CAST:
                        if (!(rand()%5))
                            DoScriptText(SAY_TAUNT[rand()%3][id], me);

                        if (caster)
                        {
                            if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 45.0f))
                                DoCast(target, SPELL_PRIMARY(id));
                        }
                        else
                            DoCast(me->getVictim(), SPELL_PRIMARY(id));

                        events.ScheduleEvent(EVENT_CAST, 15000);
                        break;
                    case EVENT_BERSERK:
                        DoScriptText(SAY_SPECIAL[id], me);
                        DoCast(me, EVENT_BERSERK);
                        break;
                }
            }

            if (punishTimer <= diff)
            {
                if (doDelayPunish)
                {
                    DoCastAOE(SPELL_PUNISH[id], true);
                    doDelayPunish = false;
                }
                punishTimer = 2000;
            } else punishTimer -= diff;

            if (!caster)
                DoMeleeAttackIfReady();
            else if ((!DoSpellAttackIfReady(SPELL_SECONDARY(id)) || !me->IsWithinLOSInMap(me->getVictim())) && movementCompleted && !doDelayPunish)
                doDelayPunish = true;
        }
Example #12
0
        void UpdateAI(const uint32 uiDiff)
        {
            if (!UpdateVictim())
                return;

            events.Update(uiDiff);

            if (me->HasUnitState(UNIT_STAT_CASTING))
                return;

            while (uint32 uiEventId = events.ExecuteEvent())
            {
                switch (uiEventId)
                {
                case EVENT_SHADOW_CRASH:
                    if (Unit * pTarget = GetPlayerAtMinimumRange(15.0f))
                        DoCast(pTarget, SPELL_SHADOW_CRASH);
                    events.ScheduleEvent(EVENT_SHADOW_CRASH, urand(8000, 12000));
                    break;
                case EVENT_SEARING_FLAMES:
                    DoCastAOE(SPELL_SEARING_FLAMES);
                    events.ScheduleEvent(EVENT_SEARING_FLAMES, urand(14000, 17500));
                    break;
                case EVENT_MARK_OF_THE_FACELESS:
                    Unit* pTarget;
                    /*  He will not cast this on players within 15 yards of him.
                        However, if there are not at least 9 people outside of 15 yards
                        he will start casting it on players inside 15 yards melee and tank included.
                    */
                    if (!(pTarget = CheckPlayersInRange(RAID_MODE(4, 9), 15.0f, 50.f)))
                        pTarget = SelectTarget(SELECT_TARGET_RANDOM);
                    DoCast(pTarget, SPELL_MARK_OF_THE_FACELESS);
                    events.ScheduleEvent(EVENT_MARK_OF_THE_FACELESS, urand(35000, 45000));
                    break;
                case EVENT_SURGE_OF_DARKNESS:
                    DoScriptText(EMOTE_SURGE_OF_DARKNESS, me);
                    DoScriptText(SAY_SURGE_OF_DARKNESS, me);
                    DoCast(me, SPELL_SURGE_OF_DARKNESS);
                    events.ScheduleEvent(EVENT_SURGE_OF_DARKNESS, urand(50000, 70000));
                    break;
                case EVENT_SARONITE_VAPORS:
                    DoCast(SPELL_SUMMON_SARONITE_VAPORS);
                    events.ScheduleEvent(EVENT_SARONITE_VAPORS, urand(30000, 35000));

                    if (++uiVaporCount == 6 && bSmellSaronite)
                    {
                        DoScriptText(SAY_HARDMODE, me);
                        DoScriptText(EMOTE_BARRIER, me);
                        summons.DespawnAll();
                        DoCast(me, SPELL_SARONITE_BARRIER);
                        DoCast(SPELL_SUMMON_SARONITE_ANIMUS);
                        me->AddLootMode(LOOT_MODE_HARD_MODE_1);
                        events.CancelEvent(EVENT_SARONITE_VAPORS);
                        events.CancelEvent(EVENT_SEARING_FLAMES);
                    }
                    break;
                case EVENT_BERSERK:
                    DoScriptText(SAY_BERSERK, me);
                    DoCast(me, SPELL_BERSERK);
                    break;
                }
            }

            DoMeleeAttackIfReady();
        }
        void UpdateAI(const uint32 uiDiff)
        {
            if (!UpdateVictim())
                return;

            switch (m_uiStage)
            {
                case 0:
                    if (m_uiFerociousButtTimer <= uiDiff)
                    {
                        DoCastVictim(SPELL_FEROCIOUS_BUTT);
                        m_uiFerociousButtTimer = urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS);
                    } else m_uiFerociousButtTimer -= uiDiff;

                    if (m_uiArticBreathTimer <= uiDiff)
                    {
                        if (Unit *pTarget = SelectUnit(SELECT_TARGET_RANDOM, 0))
                            DoCast(pTarget, SPELL_ARCTIC_BREATH);
                        m_uiArticBreathTimer = urand(25*IN_MILLISECONDS, 40*IN_MILLISECONDS);
                    } else m_uiArticBreathTimer -= uiDiff;

                    if (m_uiWhirlTimer <= uiDiff)
                    {
                        DoCastAOE(SPELL_WHIRL);
                        m_uiWhirlTimer = urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS);
                    } else m_uiWhirlTimer -= uiDiff;

                    if (m_uiMassiveCrashTimer <= uiDiff)
                    {
                        me->GetMotionMaster()->MoveJump(ToCCommonLoc[1].GetPositionX(), ToCCommonLoc[1].GetPositionY(), ToCCommonLoc[1].GetPositionZ(), 10.0f, 20.0f); // 1: Middle of the room
                        m_uiStage = 7; //Invalid (Do nothing more than move)
                        m_uiMassiveCrashTimer = 30*IN_MILLISECONDS;
                    } else m_uiMassiveCrashTimer -= uiDiff;

                    DoMeleeAttackIfReady();
                    break;
                case 1:
                    DoCastAOE(SPELL_MASSIVE_CRASH);
                    m_uiStage = 2;
                    break;
                case 2:
                    if (Unit *pTarget = SelectUnit(SELECT_TARGET_RANDOM, 0))
                    {
                        m_uiTrampleTargetGUID = pTarget->GetGUID();
                        me->SetUInt64Value(UNIT_FIELD_TARGET, m_uiTrampleTargetGUID);
                        DoScriptText(SAY_TRAMPLE_STARE, me, pTarget);
                        m_bTrampleCasted = false;
                        SetCombatMovement(false);
                        me->GetMotionMaster()->MoveIdle();
                        me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                        m_uiTrampleTimer = 4*IN_MILLISECONDS;
                        m_uiStage = 3;
                    } else m_uiStage = 6;
                    break;
                case 3:
                    if (m_uiTrampleTimer <= uiDiff)
                    {
                        if (Unit* pTarget = Unit::GetPlayer(*me, m_uiTrampleTargetGUID))
                        {
                            m_bTrampleCasted = false;
                            m_bMovementStarted = true;
                            m_fTrampleTargetX = pTarget->GetPositionX();
                            m_fTrampleTargetY = pTarget->GetPositionY();
                            m_fTrampleTargetZ = pTarget->GetPositionZ();
                            me->GetMotionMaster()->MoveJump(2*me->GetPositionX()-m_fTrampleTargetX,
                                2*me->GetPositionY()-m_fTrampleTargetY,
                                me->GetPositionZ(),
                                10.0f, 20.0f); // 2: Hop Backwards
                            m_uiStage = 7; //Invalid (Do nothing more than move)
                        } else m_uiStage = 6;
                    } else m_uiTrampleTimer -= uiDiff;
                    break;
                case 4:
                    DoScriptText(SAY_TRAMPLE_START, me);
                    me->GetMotionMaster()->MoveCharge(m_fTrampleTargetX, m_fTrampleTargetY, m_fTrampleTargetZ+2, 42, 1);
                    me->SetUInt64Value(UNIT_FIELD_TARGET, 0);
                    m_uiStage = 5;
                    break;
                case 5:
                    if (m_bMovementFinish)
                    {
                        if (m_uiTrampleTimer <= uiDiff) DoCastAOE(SPELL_TRAMPLE);
                        m_bMovementFinish = false;
                        m_uiStage = 6;
                        return;
                    }
                    if (m_uiTrampleTimer <= uiDiff)
                    {
                        Map::PlayerList const &lPlayers = me->GetMap()->GetPlayers();
                        for (Map::PlayerList::const_iterator itr = lPlayers.begin(); itr != lPlayers.end(); ++itr)
                        {
                            if (Unit* pPlayer = itr->getSource())
                                if (pPlayer->isAlive() && pPlayer->IsWithinDistInMap(me, 6.0f))
                                {
                                    DoCastAOE(SPELL_TRAMPLE);
                                    m_uiTrampleTimer = IN_MILLISECONDS;
                                    break;
                                }
                        }
                    } else m_uiTrampleTimer -= uiDiff;
                    break;
                case 6:
                    if (!m_bTrampleCasted)
                    {
                        DoCast(me, SPELL_STAGGERED_DAZE);
                        DoScriptText(SAY_TRAMPLE_FAIL, me);
                    }
                    m_bMovementStarted = false;
                    me->GetMotionMaster()->MovementExpired();
                    me->GetMotionMaster()->MoveChase(me->getVictim());
                    SetCombatMovement(true);
                    me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                    m_uiStage = 0;
                    break;
            }
        }
    void UpdateAI(const uint32 uiDiff)
    {
        if (!UpdateVictim()) return;

        if (m_pInstance && m_pInstance->GetData(TYPE_NORTHREND_BEASTS) == SNAKES_SPECIAL && !m_bEnraged)
        {
            DoScriptText(SAY_EMERGE, me);
            me->RemoveAurasDueToSpell(SPELL_SUBMERGE_0);
            me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE|UNIT_FLAG_OOC_NOT_ATTACKABLE|UNIT_FLAG_NOT_SELECTABLE);
            DoCast(SPELL_ENRAGE);
            m_bEnraged = true;
            DoScriptText(SAY_BERSERK, me);
            switch (m_uiStage)
            {
                case 0: break;
                case 4:
                    m_uiStage = 5;
                    m_uiSubmergeTimer = 5*IN_MILLISECONDS;
                    break;
                default:
                    m_uiStage = 7;
            }
        }

        switch (m_uiStage)
        {
            case 0: // Mobile
                if (m_uiBiteTimer <= uiDiff)
                {
                    DoCastVictim(m_uiBiteSpell);
                    m_uiBiteTimer = urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS);
                } else m_uiBiteTimer -= uiDiff;

                if (m_uiSpewTimer <= uiDiff)
                {
                    DoCastAOE(m_uiSpewSpell);
                    m_uiSpewTimer = urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS);
                } else m_uiSpewTimer -= uiDiff;

                if (m_uiSlimePoolTimer <= uiDiff)
                {
                    /* Spell summon has only 30s duration */
                    DoCast(me, SUMMON_SLIME_POOL);
                    m_uiSlimePoolTimer = 30*IN_MILLISECONDS;
                } else m_uiSlimePoolTimer -= uiDiff;

                if (m_uiSubmergeTimer <= uiDiff && !m_bEnraged)
                {
                    m_uiStage = 1;
                    m_uiSubmergeTimer = 5*IN_MILLISECONDS;
                } else m_uiSubmergeTimer -= uiDiff;

                DoMeleeAttackIfReady();
                break;
            case 1: // Submerge
                me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE|UNIT_FLAG_OOC_NOT_ATTACKABLE|UNIT_FLAG_NOT_SELECTABLE);
                DoCast(me, SPELL_SUBMERGE_0);
                DoScriptText(SAY_SUBMERGE, me);
                me->GetMotionMaster()->MovePoint(0, ToCCommonLoc[1].GetPositionX()+urand(0, 80)-40, ToCCommonLoc[1].GetPositionY()+urand(0, 80)-40, ToCCommonLoc[1].GetPositionZ());
                m_uiStage = 2;
            case 2: // Wait til emerge
                if (m_uiSubmergeTimer <= uiDiff)
                {
                    m_uiStage = 3;
                    m_uiSubmergeTimer = 50*IN_MILLISECONDS;
                } else m_uiSubmergeTimer -= uiDiff;
                break;
            case 3: // Emerge
                me->SetDisplayId(m_uiModelStationary);
                DoScriptText(SAY_EMERGE, me);
                me->RemoveAurasDueToSpell(SPELL_SUBMERGE_0);
                DoCast(me, SPELL_EMERGE_0);
                me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE|UNIT_FLAG_OOC_NOT_ATTACKABLE|UNIT_FLAG_NOT_SELECTABLE);
                me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE);
                SetCombatMovement(false);
                me->GetMotionMaster()->MoveIdle();
                m_uiStage = 4;
                break;
            case 4: // Stationary
                if (m_uiSprayTimer <= uiDiff)
                {
                    if (Unit *pTarget = SelectUnit(SELECT_TARGET_RANDOM, 0))
                        DoCast(pTarget, m_uiSpraySpell);
                    m_uiSprayTimer = urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS);
                } else m_uiSprayTimer -= uiDiff;

                if (m_uiSweepTimer <= uiDiff)
                {
                    DoCastAOE(SPELL_SWEEP_0);
                    m_uiSweepTimer = urand(15*IN_MILLISECONDS, 30*IN_MILLISECONDS);
                } else m_uiSweepTimer -= uiDiff;

                if (m_uiSubmergeTimer <= uiDiff)
                {
                    m_uiStage = 5;
                    m_uiSubmergeTimer = 10*IN_MILLISECONDS;
                } else m_uiSubmergeTimer -= uiDiff;

                DoSpellAttackIfReady(m_uiSpitSpell);
                break;
            case 5: // Submerge
                me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE|UNIT_FLAG_OOC_NOT_ATTACKABLE|UNIT_FLAG_NOT_SELECTABLE);
                DoCast(me, SPELL_SUBMERGE_0);
                DoScriptText(SAY_SUBMERGE, me);
                me->GetMotionMaster()->MovePoint(0, ToCCommonLoc[1].GetPositionX()+urand(0, 80)-40, ToCCommonLoc[1].GetPositionY()+urand(0, 80)-40, ToCCommonLoc[1].GetPositionZ());
                m_uiStage = 6;
            case 6: // Wait til emerge
                if (m_uiSubmergeTimer <= uiDiff)
                {
                    m_uiStage = 7;
                    m_uiSubmergeTimer = 45*IN_MILLISECONDS;
                } else m_uiSubmergeTimer -= uiDiff;
                break;
            case 7: // Emerge
                me->SetDisplayId(m_uiModelMobile);
                DoScriptText(SAY_EMERGE, me);
                me->RemoveAurasDueToSpell(SPELL_SUBMERGE_0);
                DoCast(me, SPELL_EMERGE_0);
                me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE|UNIT_FLAG_OOC_NOT_ATTACKABLE|UNIT_FLAG_NOT_SELECTABLE);
                me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE);
                SetCombatMovement(true);
                me->GetMotionMaster()->MoveChase(me->getVictim());
                m_uiStage = 0;
                break;
        }
    }
    void UpdateAI(const uint32 diff)
    {
        if (!instance || !UpdateVictim())
            return;

        if (me->HasUnitState(UNIT_STATE_CASTING))
            return;

        switch (Stage)
        {
            case 0:
                break;
            case 1: // Vortex
                if (SpecialAbilityTimer <= diff)
                {
                    if (Creature* pSister = GetSister())
                        pSister->AI()->DoAction(ACTION_VORTEX);
                    Talk(VortexEmote);
                    DoCastAOE(VortexSpellId);
                    Stage = 0;
                    SpecialAbilityTimer = 1*MINUTE*IN_MILLISECONDS;
                }
                else
                    SpecialAbilityTimer -= diff;
                break;
            case 2: // Shield + Pact
                if (SpecialAbilityTimer <= diff)
                {
                    Talk(EMOTE_TWINK_PACT);
                    Talk(SAY_TWINK_PACT);
                    if (Creature* pSister = GetSister())
                    {
                        pSister->AI()->DoAction(ACTION_PACT);
                        pSister->CastSpell(pSister, SPELL_POWER_TWINS, false);
                    }
                    DoCast(me, ShieldSpellId);
                    DoCast(me, TwinPactSpellId);
                    Stage = 0;
                    SpecialAbilityTimer = 1*MINUTE*IN_MILLISECONDS;
                }
                else
                    SpecialAbilityTimer -= diff;
                break;
            default:
                break;
        }

        if (SpikeTimer <= diff)
        {
            DoCastVictim(SpikeSpellId);
            SpikeTimer = 20*IN_MILLISECONDS;
        }
        else
            SpikeTimer -= diff;

        if (IsHeroic() && TouchTimer <= diff)
        {
            if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 200.0f, true, OtherEssenceSpellId))
                me->CastCustomSpell(TouchSpellId, SPELLVALUE_MAX_TARGETS, 1, target, false);
            TouchTimer = urand(10*IN_MILLISECONDS, 15*IN_MILLISECONDS);
        }
        else
            TouchTimer -= diff;

        if (!IsBerserk && BerserkTimer <= diff)
        {
            DoCast(me, SPELL_BERSERK);
            Talk(SAY_BERSERK);
            IsBerserk = true;
        }
        else
            BerserkTimer -= diff;

        DoMeleeAttackIfReady();
    }
        void UpdateAI(uint32 diff) override
        {
            if (!UpdateVictim())
                return;

            events.Update(diff);

            while (uint32 eventId = events.ExecuteEvent())
            {
                switch (eventId)
                {
                    case EVENT_HATEFUL:
                    {
                        // Hateful Strike targets the highest non-MT threat in melee range on 10man
                        // and the higher HP target out of the two highest non-MT threats in melee range on 25man
                        float MostThreat = 0.0f;
                        Unit* secondThreatTarget = NULL;
                        Unit* thirdThreatTarget = NULL;

                        std::list<HostileReference*>::const_iterator i = me->getThreatManager().getThreatList().begin();
                        for (; i != me->getThreatManager().getThreatList().end(); ++i)
                        { // find second highest
                            Unit* target = (*i)->getTarget();
                            if (target->IsAlive() && target != me->GetVictim() && (*i)->getThreat() >= MostThreat && me->IsWithinMeleeRange(target))
                            {
                                MostThreat = (*i)->getThreat();
                                secondThreatTarget = target;
                            }
                        }

                        if (secondThreatTarget && Is25ManRaid())
                        { // find third highest
                            MostThreat = 0.0f;
                            i = me->getThreatManager().getThreatList().begin();
                            for (; i != me->getThreatManager().getThreatList().end(); ++i)
                            {
                                Unit* target = (*i)->getTarget();
                                if (target->IsAlive() && target != me->GetVictim() && target != secondThreatTarget && (*i)->getThreat() >= MostThreat && me->IsWithinMeleeRange(target))
                                {
                                    MostThreat = (*i)->getThreat();
                                    thirdThreatTarget = target;
                                }
                            }
                        }

                        Unit* pHatefulTarget = NULL;
                        if (!thirdThreatTarget)
                            pHatefulTarget = secondThreatTarget;
                        else if (secondThreatTarget)
                            pHatefulTarget = (secondThreatTarget->GetHealth() < thirdThreatTarget->GetHealth()) ? thirdThreatTarget : secondThreatTarget;

                        if (!pHatefulTarget)
                            pHatefulTarget = me->GetVictim();

                        DoCast(pHatefulTarget, SPELL_HATEFUL_STRIKE, true);

                        // add threat to highest threat targets
                        if (me->GetVictim() && me->IsWithinMeleeRange(me->GetVictim()))
                            me->getThreatManager().addThreat(me->GetVictim(), HATEFUL_THREAT_AMT);
                        if (secondThreatTarget)
                            me->getThreatManager().addThreat(secondThreatTarget, HATEFUL_THREAT_AMT);
                        if (thirdThreatTarget)
                            me->getThreatManager().addThreat(thirdThreatTarget, HATEFUL_THREAT_AMT); // this will only ever be used in 25m

                        events.Repeat(Seconds(1));
                        break;
                    }
                    case EVENT_BERSERK:
                        DoCast(me, SPELL_BERSERK, true);
                        Talk(EMOTE_BERSERK);
                        events.ScheduleEvent(EVENT_SLIME, Seconds(2));
                        break;
                    case EVENT_SLIME:
                        DoCastAOE(SPELL_SLIME_BOLT, true);
                        events.Repeat(Seconds(2));
                        break;
                }
            }

            if (!Enraged && HealthBelowPct(5))
            {
                DoCast(me, SPELL_FRENZY, true);
                Talk(EMOTE_FRENZY);
                Enraged = true;
            }

            DoMeleeAttackIfReady();
        }
 void Reset()
 {
     DoCastAOE(SPELL_CONTROLLER_PERIODIC);
 }
Example #18
0
            void UpdateAI(uint32 diff) override
            {
                if (!UpdateVictim())
                    return;

                events.Update(diff);

                if (_frostboltCooldown < diff)
                    _frostboltCooldown = 0;
                else
                    _frostboltCooldown -= diff;

                if (!events.IsInPhase(PHASE_ONE) && me->HasUnitState(UNIT_STATE_CASTING))
                    return;

                if (!_phaseThree && HealthBelowPct(45))
                {
                    _phaseThree = true;
                    _guardianCount = 0;
                    Talk(SAY_REQUEST_AID);
                    events.ScheduleEvent(EVENT_TRANSITION_REPLY, Seconds(4), 0, PHASE_TWO);
                    events.ScheduleEvent(EVENT_TRANSITION_SUMMON, randtime(Seconds(7), Seconds(9)), 0, PHASE_TWO);
                    events.ScheduleEvent(EVENT_TRANSITION_SUMMON, randtime(Seconds(13), Seconds(15)), 0, PHASE_TWO);
                    if (Is25ManRaid())
                    {
                        events.ScheduleEvent(EVENT_TRANSITION_SUMMON, randtime(Seconds(19), Seconds(21)), 0, PHASE_TWO);
                        events.ScheduleEvent(EVENT_TRANSITION_SUMMON, randtime(Seconds(25), Seconds(27)), 0, PHASE_TWO);
                    }
                }

                while (uint32 eventId = events.ExecuteEvent())
                {
                    if (_frostboltCooldown <= 4 * IN_MILLISECONDS) // stop casting bolts for 4 seconds after doing another action
                        _frostboltCooldown = 4 * IN_MILLISECONDS;
                    switch (eventId)
                    {
                        case EVENT_SKELETON:
                        {
                            ++_skeletonCount;
                            if (_skeletonCount == 1) // the first skeleton is actually one of the pre-existing ones - I'm not sure why, but that's what the sniffs say
                            {
                                std::list<Creature*> skeletons;
                                me->GetCreatureListWithEntryInGrid(skeletons, NPC_SKELETON2, 200.0f);
                                if (skeletons.empty())
                                { // prevent UB
                                    EnterEvadeMode(EVADE_REASON_OTHER);
                                    return;
                                }
                                std::list<Creature*>::iterator it = skeletons.begin();
                                std::advance(it, urand(0, skeletons.size() - 1));
                                (*it)->SetReactState(REACT_AGGRESSIVE);
                                (*it)->AI()->DoZoneInCombat(); // will select a player on our threat list as we are the summoner
                            }
                            else
                            {
                                // retail uses server-side spell 28421 for this
                                Creature* summon = me->SummonCreature(NPC_SKELETON1, GetRandomMinionSpawnPoint(), TEMPSUMMON_CORPSE_TIMED_DESPAWN, 2 * IN_MILLISECONDS);
                                summon->AI()->DoZoneInCombat();
                            }

                            uint8 nextTime = 0;
                            if (_skeletonCount < 10)
                                nextTime = 5;
                            else if (_skeletonCount < 19)
                                nextTime = 4;
                            else if (_skeletonCount < 31)
                                nextTime = 3;
                            else if (_skeletonCount == 31)
                                nextTime = 4;
                            else if (_skeletonCount < 72)
                                nextTime = 2;

                            if (nextTime)
                                events.ScheduleEvent(EVENT_SKELETON, Seconds(nextTime), 0, PHASE_ONE);
                            break;
                        }

                        case EVENT_BANSHEE:
                        {
                            ++_bansheeCount;
                            // retail uses server-side spell 28423 for this
                            Creature* summon = me->SummonCreature(NPC_BANSHEE1, GetRandomMinionSpawnPoint(), TEMPSUMMON_CORPSE_TIMED_DESPAWN, 2 * IN_MILLISECONDS);
                            summon->AI()->DoZoneInCombat();

                            uint8 nextTime = 0;
                            if (_bansheeCount < 3)
                                nextTime = 30;
                            else if (_bansheeCount < 7)
                                nextTime = 20;
                            else if (_bansheeCount < 9)
                                nextTime = 15;

                            if (nextTime)
                                events.ScheduleEvent(EVENT_BANSHEE, Seconds(nextTime), 0, PHASE_ONE);
                            break;
                        }

                        case EVENT_ABOMINATION:
                        {
                            ++_abominationCount;
                            // retail uses server-side spell 28422 for this
                            Creature* summon = me->SummonCreature(NPC_ABOMINATION1, GetRandomMinionSpawnPoint(), TEMPSUMMON_CORPSE_TIMED_DESPAWN, 2 * IN_MILLISECONDS);
                            summon->AI()->DoZoneInCombat();

                            uint8 nextTime = 0;
                            if (_abominationCount < 3)
                                nextTime = 30;
                            else if (_abominationCount < 7)
                                nextTime = 20;
                            else if (_abominationCount < 9)
                                nextTime = 15;

                            if (nextTime)
                                events.ScheduleEvent(EVENT_ABOMINATION, Seconds(nextTime), 0, PHASE_ONE);
                            break;
                        }

                        case EVENT_DESPAWN_MINIONS:
                        {
                            // we need a temp vector, as we can't modify summons while iterating (this would cause UB)
                            std::vector<Creature*> toDespawn;
                            toDespawn.reserve(summons.size());
                            for (ObjectGuid sGuid : summons)
                                if (Creature* summon = ObjectAccessor::GetCreature(*me, sGuid))
                                    if (!summon->IsInCombat())
                                        toDespawn.push_back(summon);
                            for (Creature* summon : toDespawn)
                                summon->DespawnOrUnsummon();
                            Talk(SAY_AGGRO);
                            break;
                        }

                        case EVENT_PHASE_TWO:
                            me->CastStop();
                            events.SetPhase(PHASE_TWO);
                            me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_IMMUNE_TO_PC);
                            me->getThreatManager().resetAllAggro();
                            me->SetReactState(REACT_AGGRESSIVE);
                            Talk(EMOTE_PHASE_TWO);

                            _frostboltCooldown = 2 * IN_MILLISECONDS;
                            events.ScheduleEvent(EVENT_FROSTBOLT_VOLLEY, randtime(Seconds(24), Seconds(28)), 0, PHASE_TWO);
                            events.ScheduleEvent(EVENT_SHADOW_FISSURE, randtime(Seconds(6), Seconds(10)), 0, PHASE_TWO);
                            events.ScheduleEvent(EVENT_DETONATE_MANA, randtime(Seconds(27), Seconds(33)), 0, PHASE_TWO);
                            events.ScheduleEvent(EVENT_FROST_BLAST, randtime(Seconds(25), Seconds(45)), 0, PHASE_TWO);
                            if (Is25ManRaid())
                                events.ScheduleEvent(EVENT_CHAINS, randtime(Seconds(60), Seconds(80)), 0, PHASE_TWO);
                            break;

                        case EVENT_FROSTBOLT_VOLLEY:
                            DoCastAOE(SPELL_FROSTBOLT_VOLLEY);
                            events.Repeat(randtime(Seconds(16), Seconds(18)));
                            break;

                        case EVENT_SHADOW_FISSURE:
                            if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 0.0f, true))
                                DoCast(target, SPELL_SHADOW_FISSURE);
                            events.Repeat(randtime(Seconds(14), Seconds(17)));
                            break;

                        case EVENT_DETONATE_MANA:
                        {
                            ManaUserTargetSelector pred;
                            if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, pred))
                                DoCast(target, SPELL_DETONATE_MANA);
                            events.Repeat(randtime(Seconds(30), Seconds(40)));
                            break;
                        }

                        case EVENT_FROST_BLAST:
                            if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1, 0.0f, true))
                                DoCast(target, SPELL_FROST_BLAST);
                            events.Repeat(randtime(Seconds(25), Seconds(45)));
                            break;

                        case EVENT_CHAINS:
                        {
                            DoCastAOE(SPELL_CHAINS_DUMMY);
                            events.Repeat(Minutes(1) + randtime(Seconds(0), Seconds(20)));
                            break;
                        }

                        case EVENT_TRANSITION_REPLY:
                            if (Creature* lichKing = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_LICH_KING)))
                                lichKing->AI()->Talk(SAY_ANSWER_REQUEST);
                            for (NAXData64 portalData : portalList)
                                if (GameObject* portal = ObjectAccessor::GetGameObject(*me, instance->GetGuidData(portalData)))
                                    portal->SetGoState(GO_STATE_ACTIVE);
                            break;

                        case EVENT_TRANSITION_SUMMON:
                        {
                            uint8 selected = urand(_guardianCount, nGuardianSpawns - 1);
                            if (selected != _guardianCount)
                                std::swap(_guardianGroups[selected], _guardianGroups[_guardianCount]);

                            std::list<TempSummon*> summoned;
                            // server-side spell 28454 is used on retail - no point replicating this in spell_dbc
                            me->SummonCreatureGroup(_guardianGroups[_guardianCount++], &summoned);
                            for (TempSummon* guardian : summoned)
                                guardian->AI()->DoAction(ACTION_JUST_SUMMONED);
                            break;
                        }
                    }

                    if (!events.IsInPhase(PHASE_ONE) && me->HasUnitState(UNIT_STATE_CASTING))
                        return;
                }

                if (!_frostboltCooldown)
                {
                    DoCastVictim(SPELL_FROSTBOLT_SINGLE);
                    _frostboltCooldown = 3 * IN_MILLISECONDS;
                }
                else
                    DoMeleeAttackIfReady();
            }
Example #19
0
            void UpdateAI(uint32 diff) override
            {
                if (!UpdateVictim())
                    return;

                events.Update(diff);

                while (uint32 eventId = events.ExecuteEvent())
                {
                    switch (eventId)
                    {
                        case EVENT_RANDOM_CAST:
                            switch (urand(0, 1))
                            {
                                case 0:
                                    if (!_skewer)
                                    {
                                        if (Unit* target = SelectTarget(SELECT_TARGET_TOPAGGRO, 0))
                                        {
                                            DoCast(target, SPELL_SKEWER, true);
                                            Talk(SAY_SKEWER);
                                            Talk(SAY_SKEWER_ANNOUNCE, target);
                                        }
                                        _skewer = true;
                                        events.ScheduleEvent(EVENT_RANDOM_CAST, urand(7000, 10000));
                                    }
                                    else if (!_hate)
                                    {
                                        if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, NonTankTargetSelector(me)))
                                        {
                                            DoCast(target, SPELL_SEETHING_HATE, true);
                                            Talk(SAY_HATE);
                                        }
                                        _hate = true;
                                        events.ScheduleEvent(EVENT_RANDOM_CAST, urand(7000, 10000));
                                    }
                                    else if (_hate && _skewer)
                                    {
                                        Talk(SAY_BLADE_STORM);
                                        DoCastAOE(SPELL_BLADE_DANCE_DUMMY);
                                        DoCastAOE(SPELL_BLADE_DANCE);
                                        events.ScheduleEvent(EVENT_RANDOM_CAST, 21000);
                                        events.ScheduleEvent(EVENT_MOVE_STORM, 4050);
                                        events.ScheduleEvent(EVENT_STOP_STORM, 13000);
                                    }
                                    break;
                                case 1:
                                    if (!_hate)
                                    {
                                        if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, NonTankTargetSelector(me)))
                                        {
                                            DoCast(target, SPELL_SEETHING_HATE, true);
                                            Talk(SAY_HATE);
                                        }
                                        _hate = true;
                                        events.ScheduleEvent(EVENT_RANDOM_CAST, urand(7000, 10000));
                                    }
                                    else if (!_skewer)
                                    {
                                        if (Unit* target = SelectTarget(SELECT_TARGET_TOPAGGRO, 0))
                                        {
                                            DoCast(target, SPELL_SKEWER, true);
                                            Talk(SAY_SKEWER);
                                            Talk(SAY_SKEWER_ANNOUNCE, target);
                                        }
                                        _skewer = true;
                                        events.ScheduleEvent(EVENT_RANDOM_CAST, urand(7000, 10000));
                                    }
                                    else if (_hate && _skewer)
                                    {
                                        Talk(SAY_BLADE_STORM);
                                        DoCastAOE(SPELL_BLADE_DANCE_DUMMY);
                                        DoCastAOE(SPELL_BLADE_DANCE);
                                        events.ScheduleEvent(EVENT_RANDOM_CAST, 21000);
                                        events.ScheduleEvent(EVENT_MOVE_STORM, 4050);
                                        events.ScheduleEvent(EVENT_STOP_STORM, 13000);
                                    }
                                    break;
                            }
                            break;
                        case EVENT_MOVE_STORM:
                            me->SetSpeed(MOVE_RUN, 4.0f);
                            me->SetSpeed(MOVE_WALK, 4.0f);
                            if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, NonTankTargetSelector(me)))
                                me->GetMotionMaster()->MovePoint(POINT_STORM, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ());
                            events.ScheduleEvent(EVENT_MOVE_STORM, 4050);
                            break;
                        case EVENT_STOP_STORM:
                            me->RemoveAura(SPELL_BLADE_DANCE);
                            me->RemoveAura(SPELL_BLADE_DANCE_DUMMY);
                            me->SetSpeed(MOVE_WALK, 1.0f);
                            me->SetSpeed(MOVE_RUN, 1.14f);
                            me->GetMotionMaster()->MoveChase(me->GetVictim());
                            _hate = false;
                            _skewer = false;
                            break;
                        case EVENT_CAST_STORM:
                            DoCastAOE(SPELL_BLADE_DANCE);
                            break;
                    }
                }

                DoMeleeAttackIfReady();
            }
Example #20
0
        void UpdateAI(uint32 const Diff)
        {
            if (!UpdateVictim())
                return;

            events.Update(Diff);

            if (HealthBelowPct(50) && !PermaGround)
                EnterPermaGround();

            if (EnrageTimer <= Diff && !Enraged)
            {
                DoCast(me, SPELL_BERSERK);
                Enraged = true;
            }
            else
                EnrageTimer -= Diff;

            if (HarpoonCounter == RAID_MODE(2, 4))
            {
                HarpoonCounter = 0;
                me->GetMotionMaster()->MovePoint(1, RazorGround);
            }

            if (phase == PHASE_GROUND)
            {
                while (uint32 eventId = events.ExecuteEvent())
                {
                    switch (eventId)
                    {
                    case EVENT_FLIGHT:
                        phase = PHASE_FLIGHT;
                        events.SetPhase(PHASE_FLIGHT);
                        me->SetFlying(true);
                        me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                        me->SetReactState(REACT_PASSIVE);
                        me->AttackStop();
                        me->GetMotionMaster()->MovePoint(0, RazorFlight);
                        events.ScheduleEvent(EVENT_FIREBALL, 7000, 0, PHASE_FLIGHT);
                        events.ScheduleEvent(EVENT_DEVOURING, 10000, 0, PHASE_FLIGHT);
                        events.ScheduleEvent(EVENT_SUMMON, 5000, 0, PHASE_FLIGHT);
                        ++FlyCount;
                        return;
                    case EVENT_LAND:
                        me->SetFlying(false);
                        me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                        me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED | UNIT_FLAG_PACIFIED);
                        if (Creature* commander = ObjectAccessor::GetCreature(*me, instance ? instance->GetData64(DATA_EXPEDITION_COMMANDER) : 0))
                            commander->AI()->DoAction(ACTION_GROUND_PHASE);
                        events.ScheduleEvent(EVENT_BREATH, 30000, 0, PHASE_GROUND);
                        events.ScheduleEvent(EVENT_BUFFET, 33000, 0, PHASE_GROUND);
                        events.ScheduleEvent(EVENT_FLIGHT, 35000, 0, PHASE_GROUND);
                        return;
                    case EVENT_BREATH:
                        me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED | UNIT_FLAG_PACIFIED);
                        me->RemoveAllAuras();
                        me->SetReactState(REACT_AGGRESSIVE);
                        DoScriptText(EMOTE_BREATH, me, 0);
                        DoCastAOE(SPELL_FLAMEBREATH);
                        events.CancelEvent(EVENT_BREATH);
                        return;
                    case EVENT_BUFFET:
                        DoCastAOE(SPELL_WINGBUFFET);
                        if (Creature* controller = ObjectAccessor::GetCreature(*me, instance ? instance->GetData64(DATA_RAZORSCALE_CONTROL) : 0))
                            controller->CastSpell(controller, SPELL_FLAMED, true);
                        events.CancelEvent(EVENT_BUFFET);
                        return;
                    }
                }
            }
            if (phase == PHASE_PERMAGROUND)
            {
                while (uint32 eventId = events.ExecuteEvent())
                {
                    switch (eventId)
                    {
                    case EVENT_FLAME:
                        DoCastAOE(SPELL_FLAMEBUFFET);
                        events.ScheduleEvent(EVENT_FLAME, 10000, 0, PHASE_PERMAGROUND);
                        return;
                    case EVENT_BREATH:
                        me->MonsterTextEmote(EMOTE_BREATH, 0, true);
                        DoCastVictim(SPELL_FLAMEBREATH);
                        events.ScheduleEvent(EVENT_BREATH, 20000, 0, PHASE_PERMAGROUND);
                        return;
                    case EVENT_FIREBALL:
                        if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 200.0f, true))
                            DoCast(target, SPELL_FIREBALL);
                        events.ScheduleEvent(EVENT_FIREBALL, 3000, 0, PHASE_PERMAGROUND);
                        return;
                    case EVENT_DEVOURING:
                        if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 200.0f, true))
                            DoCast(target, SPELL_DEVOURING_FLAME);
                        events.ScheduleEvent(EVENT_DEVOURING, 10000, 0, PHASE_PERMAGROUND);
                        return;
                    case EVENT_BUFFET:
                        DoCastAOE(SPELL_WINGBUFFET);
                        events.CancelEvent(EVENT_BUFFET);
                        return;
                    case EVENT_FUSE:
                        DoCast(me->getVictim(), SPELL_FUSEARMOR);
                        events.ScheduleEvent(EVENT_FUSE, 10000, 0, PHASE_PERMAGROUND);
                        return;
                    }
                }

                DoMeleeAttackIfReady();
            }
            else
            {
                if (uint32 eventId = events.ExecuteEvent())
                {
                    switch (eventId)
                    {
                    case EVENT_FIREBALL:
                        if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 200.0f, true))
                            DoCast(target, SPELL_FIREBALL);
                        events.ScheduleEvent(EVENT_FIREBALL, 3000, 0, PHASE_FLIGHT);
                        return;
                    case EVENT_DEVOURING:
                        if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 200.0f, true))
                            me->CastSpell(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), SPELL_DEVOURING_FLAME, true);
                        events.ScheduleEvent(EVENT_DEVOURING, 10000, 0, PHASE_FLIGHT);
                        return;
                    case EVENT_SUMMON:
                        SummonMoleMachines();
                        events.ScheduleEvent(EVENT_SUMMON, 45000, 0, PHASE_FLIGHT);
                        return;
                    }
                }
            }
        }
 inline void CastDrain()
 {
     DoCastAOE(SPELL_LIFE_DRAIN);
     events.ScheduleEvent(EVENT_DRAIN, randtime(Seconds(22), Seconds(28)));
 }
Example #22
0
        void UpdateAI(uint32 diff) override
        {
            if (HealthBelowPct(75))
            {
                if (PotTimer <= diff)
                {
                    DoCast(me, SPELL_HEALING_POTION, true);
                    PotTimer = 10000;
                } else PotTimer -= diff;
            }

            if (GetAttack() && UpdateVictim())
                DoMeleeAttackIfReady();

            npc_escortAI::UpdateAI(diff);

            if (me->IsInCombat())
                return;

            events.Update(diff);

            while (uint32 eventId = events.ExecuteEvent())
            {
                switch (eventId)
                {
                    case EVENT_EMOTE_BEG:
                        me->HandleEmoteCommand(EMOTE_ONESHOT_BEG);
                        events.ScheduleEvent(EVENT_EMOTE_BEG, Seconds(25));
                        break;
                    case EVENT_BEGIN:
                        if (Player* player = ObjectAccessor::GetPlayer(*me, _player))
                            Talk(TALK_0, player);
                        break;
                    case EVENT_START_ESCORT:
                        events.Reset();
                        me->setFaction(FACTION_ESCORTEE_H);
                        me->SetReactState(REACT_AGGRESSIVE);
                        ENSURE_AI(npc_escortAI, (me->AI()))->Start(true, true, _player);
                        break;
                    case EVENT_TALK_1:
                        if (Player* player = ObjectAccessor::GetPlayer(*me, _player))
                            Talk(TALK_1, player);
                        break;
                    case EVENT_KNEEL:
                        me->HandleEmoteCommand(EMOTE_ONESHOT_KNEEL);
                        break;
                    case EVENT_TALK_2:
                        if (Player* player = ObjectAccessor::GetPlayer(*me, _player))
                            Talk(TALK_2, player);
                        me->LoadEquipment(EQUIP_TORCH);
                        me->SetSheath(SHEATH_STATE_MELEE);
                        break;
                    case EVENT_BURN_CRATES:
                        DoCastAOE(SPELL_BURN, true);
                        break;
                    case EVENT_TALK_3:
                        if (Player* player = ObjectAccessor::GetPlayer(*me, _player))
                            Talk(TALK_3, player);
                        break;
                    case EVENT_TALK_4:
                        if (Player* player = ObjectAccessor::GetPlayer(*me, _player))
                            Talk(TALK_4, player);
                        break;
                    case EVENT_LAUGH:
                        me->HandleEmoteCommand(EMOTE_ONESHOT_LAUGH);
                        break;
                    case EVENT_TALK_5:
                        if (Player* player = ObjectAccessor::GetPlayer(*me, _player))
                            Talk(TALK_5, player);
                        me->HandleEmoteCommand(EMOTE_ONESHOT_RUDE);
                        break;
                    case EVENT_TALK_6:
                        if (Player* player = ObjectAccessor::GetPlayer(*me, _player))
                            Talk(TALK_6, player);
                        break;
                    case EVENT_TALK_8:
                        if (Player* player = ObjectAccessor::GetPlayer(*me, _player))
                            Talk(TALK_8, player);
                        break;
                }
            }
        }
Example #23
0
            void UpdateAI(uint32 const diff)
            {
                if (!UpdateVictim())
                    return;

                events.Update(diff);

                if (me->GetPower(POWER_MANA) == me->GetMaxPower(POWER_MANA))
                {
                    if (_isStonePhase)
                        DoAction(ACTION_STONE_PHASE_END);
                    DoCastAOE(SPELL_ARCANE_ERUPTION);
                    me->SetPower(POWER_MANA, 0);
                }

                if (_isStonePhase)
                {
                    if (events.ExecuteEvent() == EVENT_STONE_PHASE_END)
                        DoAction(ACTION_STONE_PHASE_END);
                    return;
                }

                // Messing up mana-drain channel
                //if (me->HasUnitState(UNIT_STATE_CASTING))
                //    return;

                while (uint32 eventId = events.ExecuteEvent())
                {
                    switch (eventId)
                    {
                        case EVENT_STONE_PHASE:
                            DoAction(ACTION_STONE_PHASE_START);
                            break;
                        case EVENT_DRAIN_MANA:
                        {
                            std::list<Unit*> targetList;
                            {
                                const std::list<HostileReference*>& threatlist = me->getThreatManager().getThreatList();
                                for (std::list<HostileReference*>::const_iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr)
                                    if ((*itr)->getTarget()->GetTypeId() == TYPEID_PLAYER && (*itr)->getTarget()->getPowerType() == POWER_MANA)
                                        targetList.push_back((*itr)->getTarget());
                            }

                            Trinity::Containers::RandomResizeList(targetList, 5);

                            for (std::list<Unit*>::iterator itr = targetList.begin(); itr != targetList.end(); ++itr)
                                DoCast(*itr, SPELL_DRAIN_MANA);

                            events.ScheduleEvent(EVENT_DRAIN_MANA, urand(5000, 15000));
                            break;
                        }/*
                        case EVENT_WIDE_SLASH:
                            DoCast(me, SPELL_WIDE_SLASH);
                            events.ScheduleEvent(EVENT_WIDE_SLASH, 11000);
                            break;
                        case EVENT_TRASH:
                            DoCast(me, SPELL_TRASH);
                            events.ScheduleEvent(EVENT_WIDE_SLASH, 16000);
                            break;*/
                        default:
                            break;
                    }
                }

                DoMeleeAttackIfReady();
            }
Example #24
0
 void JustDied(Unit* /*killer*/)
 {
     DoCastAOE(SPELL_SPIRIT_VENGEANCE_CANCEL);
     _JustDied();
     Talk(SAY_DEATH);
 }
Example #25
0
        void UpdateAI(const uint32 diff)
        {
            if (!UpdateVictim())
                return;

            events.Update(diff);
            
            if (me->hasUnitState(UNIT_STAT_CASTING) || me->HasAura(SPELL_SYSTEMS_SHUTDOWN))
                return;

            while(uint32 eventId = events.ExecuteEvent())
            {
                switch(eventId)
                {
                case 0: break;
                case EVENT_PURSUE:
                    DoScriptText(RAND(SAY_TARGET_1, SAY_TARGET_2, SAY_TARGET_3), me);
                    {
                        DoZoneInCombat();
                        Unit* pTarget;
                        std::vector<Unit *> target_list;
                        std::list<HostileReference*> ThreatList = me->getThreatManager().getThreatList();
                        for (std::list<HostileReference*>::const_iterator itr = ThreatList.begin(); itr != ThreatList.end(); ++itr)
                        {
                            pTarget = Unit::GetUnit(*me, (*itr)->getUnitGuid());
                            
                            if (!pTarget)
                                continue;
                                
                            if (pTarget->GetEntry() == VEHICLE_SIEGE || pTarget->GetEntry() == VEHICLE_DEMOLISHER)
                                target_list.push_back(pTarget);
                                
                            pTarget = NULL;
                        }
                        
                        if (!target_list.empty())
                            pTarget = *(target_list.begin()+rand()%target_list.size());
                        else
                            pTarget = me->getVictim();
                            
                        if (pTarget && pTarget->isAlive())
                        {
                            DoResetThreat();
                            me->AddThreat(pTarget, 5000000.0f);
                            me->AddAura(SPELL_PURSUED, pTarget);
                            me->MonsterTextEmote(EMOTE_PURSUE, pTarget->GetGUID(), true);
                        }
                    }
                    events.RescheduleEvent(EVENT_PURSUE, 35000);
                    break;
                case EVENT_MISSILE:
                    DoCastAOE(SPELL_MISSILE_BARRAGE);
                    events.RescheduleEvent(EVENT_MISSILE, 1500);
                    break;
                case EVENT_VENT:
                    DoCastAOE(SPELL_FLAME_VENTS);
                    events.RescheduleEvent(EVENT_VENT, urand(15000, 20000));
                    break;
                case EVENT_SPEED:
                    DoCastAOE(SPELL_GATHERING_SPEED);
                    events.RescheduleEvent(EVENT_SPEED, 10000);
                break;
                case EVENT_SUMMON:
                    if(summons.size() < 15) // 4seat+1turret+10lift
                        if(Creature *lift = DoSummonFlyer(MOB_MECHANOLIFT, me, float(rand()%20 + 20), 50, 0))
                            lift->GetMotionMaster()->MoveRandom(100);
                    events.RescheduleEvent(EVENT_SUMMON, 2000);
                    break;
                case EVENT_SHUTDOWN:
                    DoScriptText(RAND(SAY_OVERLOAD_1, SAY_OVERLOAD_2, SAY_OVERLOAD_3), me);
                    me->MonsterTextEmote(EMOTE_OVERLOAD, 0, true);
                    DoCast(SPELL_SYSTEMS_SHUTDOWN);
                    me->RemoveAurasDueToSpell(SPELL_GATHERING_SPEED);
                    me->MonsterTextEmote(EMOTE_REPAIR, 0, true);
                    events.RescheduleEvent(EVENT_SHUTDOWN, 90000);
                    break;
                default:
                    events.PopEvent();
                    break;
                }
            }
            
            if (me->IsWithinMeleeRange(me->getVictim()))
                DoSpellAttackIfReady(SPELL_BATTERING_RAM);
        }
Example #26
0
 void EnterCombat(Unit* /*who*/)
 {
     DoCastAOE(SPELL_OHGAN_ORDERS, true);
 }
Example #27
0
        void UpdateAI(uint32 diff) override
        {
            if (!UpdateVictim())
                return;

            if (HealthBelowPct(30) && !me->HasAura(SPELL_FRENZY_HELPER))
            {
                DoCast(SPELL_FRENZY);
            }

            events.Update(diff);

            while (uint32 eventId = events.ExecuteEvent())
            {
                switch (eventId)
                {
                    case EVENT_WRAP:
                    {
                        std::list<Unit*> targets;
                        SelectTargetList(targets, WebTargetSelector(me), RAID_MODE(1, 2), SELECT_TARGET_RANDOM);
                        if (!targets.empty())
                        {
                            Talk(EMOTE_WEB_WRAP);
                            int8 wrapPos = -1;
                            for (Unit* target : targets)
                            {
                                if (wrapPos == -1) // allow all positions on the first target
                                    wrapPos = urand(0, MAX_WRAP_POSITION - 1);
                                else // on subsequent iterations, only allow positions that are not equal to the previous one (this is sufficient since we should only have two targets at most, ever)
                                    wrapPos = (wrapPos + urand(1, MAX_WRAP_POSITION - 1)) % MAX_WRAP_POSITION;

                                target->RemoveAura(RAID_MODE(SPELL_WEB_SPRAY_10, SPELL_WEB_SPRAY_25));
                                if (Creature* wrap = DoSummon(NPC_WEB_WRAP, WrapPositions[wrapPos], 70 * IN_MILLISECONDS, TEMPSUMMON_TIMED_DESPAWN))
                                {
                                    wrap->AI()->SetGUID(target->GetGUID()); // handles application of debuff
                                    target->GetMotionMaster()->MoveJump(WrapPositions[wrapPos], WEB_WRAP_MOVE_SPEED, WEB_WRAP_MOVE_SPEED); // move after stun to avoid stun cancelling move
                                }
                            }
                        }
                        events.Repeat(Seconds(40));
                        break;
                    }
                    case EVENT_SPRAY:
                        Talk(EMOTE_WEB_SPRAY);
                        DoCastAOE(RAID_MODE(SPELL_WEB_SPRAY_10, SPELL_WEB_SPRAY_25));
                        events.Repeat(Seconds(40));
                        break;
                    case EVENT_SHOCK:
                        DoCastAOE(SPELL_POISON_SHOCK);
                        events.Repeat(randtime(Seconds(10), Seconds(20)));
                        break;
                    case EVENT_POISON:
                        DoCastVictim(SPELL_NECROTIC_POISON);
                        events.Repeat(randtime(Seconds(10), Seconds(20)));
                        break;
                    case EVENT_SUMMON:
                        Talk(EMOTE_SPIDERS);
                        uint8 amount = urand(8, 10);
                        for (uint8 i = 0; i < amount; ++i)
                            DoSummon(NPC_SPIDERLING, me, 4.0f, 5 * IN_MILLISECONDS, TEMPSUMMON_CORPSE_TIMED_DESPAWN);
                        events.Repeat(Seconds(40));
                        break;
                }
            }

            DoMeleeAttackIfReady();
        }
Example #28
0
        void UpdateAI(const uint32 diff)
        {
            if (!phase)
                return;

            events.Update(diff);

            if ((phase != PHASE_BIRTH && !UpdateVictim()) || !CheckInRoom())
                return;

            if (CanTheHundredClub)
            {
                if (CheckFrostResistTimer <= diff)
                {
                    CheckPlayersFrostResist();
                    CheckFrostResistTimer = (rand() % 5 + 5) * 1000;
                } else CheckFrostResistTimer -= diff;
            }

            if (phase == PHASE_GROUND)
            {
                while (uint32 eventId = events.ExecuteEvent())
                {
                    switch (eventId)
                    {
                        case EVENT_BERSERK:
                            DoScriptText(EMOTE_ENRAGE, me);
                            DoCast(me, SPELL_BERSERK);
                            return;
                        case EVENT_CLEAVE:
                            DoCast(me->getVictim(), SPELL_CLEAVE);
                            events.ScheduleEvent(EVENT_CLEAVE, 5000+rand()%10000, 0, PHASE_GROUND);
                            return;
                        case EVENT_TAIL:
                            DoCastAOE(SPELL_TAIL_SWEEP);
                            events.ScheduleEvent(EVENT_TAIL, 5000+rand()%10000, 0, PHASE_GROUND);
                            return;
                        case EVENT_DRAIN:
                            DoCastAOE(SPELL_LIFE_DRAIN);
                            events.ScheduleEvent(EVENT_DRAIN, 24000, 0, PHASE_GROUND);
                            return;
                        case EVENT_BLIZZARD:
                        {
                            //DoCastAOE(SPELL_SUMMON_BLIZZARD);
                            if (Creature* summon = DoSummon(MOB_BLIZZARD, me, 0.0f, urand(25000, 30000), TEMPSUMMON_TIMED_DESPAWN))
                                summon->GetMotionMaster()->MoveRandom(40);
                            events.ScheduleEvent(EVENT_BLIZZARD, RAID_MODE(20000, 7000), 0, PHASE_GROUND);
                            break;
                        }
                        case EVENT_FLIGHT:
                            if (HealthAbovePct(10))
                            {
                                phase = PHASE_FLIGHT;
                                events.SetPhase(PHASE_FLIGHT);
                                me->SetReactState(REACT_PASSIVE);
                                me->AttackStop();
                                float x, y, z, o;
                                me->GetHomePosition(x, y, z, o);
                                me->GetMotionMaster()->MovePoint(1, x, y, z);
                                return;
                            }
                            break;
                    }
                }

                DoMeleeAttackIfReady();
            }
            else
            {
                if (uint32 eventId = events.ExecuteEvent())
                {
                    switch (eventId)
                    {
                        case EVENT_LIFTOFF:
                            me->HandleEmoteCommand(EMOTE_ONESHOT_LIFTOFF);
                            me->SetLevitate(true);
                            me->SendMovementFlagUpdate();
                            events.ScheduleEvent(EVENT_ICEBOLT, 1500);
                            iceboltCount = RAID_MODE(2, 3);
                            return;
                        case EVENT_ICEBOLT:
                        {
                            std::vector<Unit*> targets;
                            std::list<HostileReference*>::const_iterator i = me->getThreatManager().getThreatList().begin();
                            for (; i != me->getThreatManager().getThreatList().end(); ++i)
                                if ((*i)->getTarget()->GetTypeId() == TYPEID_PLAYER && !(*i)->getTarget()->HasAura(SPELL_ICEBOLT))
                                    targets.push_back((*i)->getTarget());

                            if (targets.empty())
                                iceboltCount = 0;
                            else
                            {
                                std::vector<Unit*>::const_iterator itr = targets.begin();
                                advance(itr, rand()%targets.size());
                                iceblocks.insert(std::make_pair((*itr)->GetGUID(), 0));
                                DoCast(*itr, SPELL_ICEBOLT);
                                --iceboltCount;
                            }

                            if (iceboltCount)
                                events.ScheduleEvent(EVENT_ICEBOLT, 1000);
                            else
                                events.ScheduleEvent(EVENT_BREATH, 1000);
                            return;
                        }
                        case EVENT_BREATH:
                        {
                            DoScriptText(EMOTE_BREATH, me);
                            DoCastAOE(SPELL_FROST_MISSILE);
                            events.ScheduleEvent(EVENT_EXPLOSION, 8000);
                            return;
                        }
                        case EVENT_EXPLOSION:
                            CastExplosion();
                            ClearIceBlock();
                            events.ScheduleEvent(EVENT_LAND, 3000);
                            return;
                        case EVENT_LAND:
                            me->HandleEmoteCommand(EMOTE_ONESHOT_LAND);
                            me->SetLevitate(false);
                            me->SendMovementFlagUpdate();
                            events.ScheduleEvent(EVENT_GROUND, 1500);
                            return;
                        case EVENT_GROUND:
                            EnterPhaseGround();
                            return;
                        case EVENT_BIRTH:
                            me->SetVisible(true);
                            me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                            me->SetReactState(REACT_AGGRESSIVE);
                            return;
                    }
                }//if (uint32 eventId = events.ExecuteEvent())
            }//if (phase == PHASE_GROUND)
        }
Example #29
0
        void UpdateAI(const uint32 uiDiff)
        {
            if (bDone && uiResetTimer <= uiDiff)
            {
                me->GetMotionMaster()->MovePoint(0, 746.843f, 695.68f, 412.339f);
                bDone = false;
			    if (GameObject* pGO = GameObject::GetGameObject(*me, pInstance->GetData64(DATA_MAIN_GATE)))
                        pInstance->HandleGameObject(pGO->GetGUID(),false);	
            } else uiResetTimer -= uiDiff;

            if (!UpdateVictim())
                return;

            if (uiHolyFireTimer <= uiDiff)
            {
                if (Unit* pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0, 250, true))
                {
                    if (pTarget && pTarget->isAlive())
                        DoCast(pTarget,DUNGEON_MODE(SPELL_HOLY_FIRE,SPELL_HOLY_FIRE_H));
                }
                 if (me->HasAura(SPELL_SHIELD))
                    uiHolyFireTimer = 13000;
                else
                    uiHolyFireTimer = urand(9000,12000);
            } else uiHolyFireTimer -= uiDiff;

            if (uiHolySmiteTimer <= uiDiff)
            {
                if (Unit* pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0, 250, true))
                {
                    if (pTarget && pTarget->isAlive())
                        DoCast(pTarget,DUNGEON_MODE(SPELL_SMITE,SPELL_SMITE_H));
                }
                if (me->HasAura(SPELL_SHIELD))
                    uiHolySmiteTimer = 9000;
                else
                    uiHolySmiteTimer = urand(5000,7000);
            } else uiHolySmiteTimer -= uiDiff;

            if (me->HasAura(SPELL_SHIELD))
            {
                if (uiRenewTimer <= uiDiff)
                {
                    me->InterruptNonMeleeSpells(true);
                    uint8 uiTarget = urand(0,1);
                    switch(uiTarget)
                    {
                        case 0:
                            DoCast(me,DUNGEON_MODE(SPELL_RENEW,SPELL_RENEW_H));
                            break;
                        case 1:
                            if (Creature* pMemory = Unit::GetCreature(*me, MemoryGUID))
                                if (pMemory->isAlive())
                                    DoCast(pMemory, DUNGEON_MODE(SPELL_RENEW,SPELL_RENEW_H));
                            break;
                    }
                    uiRenewTimer = urand(15000,17000);
                } else uiRenewTimer -= uiDiff;
            }

            if (!bHealth && me->GetHealth()*100 / me->GetMaxHealth() <= 35)
            {
		        DoScriptText(SAY_START_6, me);
                me->InterruptNonMeleeSpells(true);
                DoCastAOE(SPELL_HOLY_NOVA,false);
                DoCast(me, SPELL_SHIELD);
                DoCastAOE(SPELL_CONFESS,false);

                bHealth = true;
			    switch(urand(0, 24))
                {
                    case 0: me->SummonCreature(MEMORY_ALGALON, 0.0f, 0.0f, 0.0f, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
                    break;
                    case 1: me->SummonCreature(MEMORY_CHROMAGGUS, 0.0f, 0.0f, 0.0f, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
                    break;
                    case 2: me->SummonCreature(MEMORY_CYANIGOSA, 0.0f, 0.0f, 0.0f, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
                    break;
                    case 3: me->SummonCreature(MEMORY_DELRISSA, 0.0f, 0.0f, 0.0f, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
                    break;
                    case 4: me->SummonCreature(MEMORY_ECK, 0.0f, 0.0f, 0.0f, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
                    break;
                    case 5: me->SummonCreature(MEMORY_ENTROPIUS, 0.0f, 0.0f, 0.0f, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
                    break;
                    case 6: me->SummonCreature(MEMORY_GRUUL, 0.0f, 0.0f, 0.0f, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
                    break;
                    case 7: me->SummonCreature(MEMORY_HAKKAR, 0.0f, 0.0f, 0.0f, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
                    break;
                    case 8: me->SummonCreature(MEMORY_HEIGAN, 0.0f, 0.0f, 0.0f, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
                    break;
                    case 9: me->SummonCreature(MEMORY_HEROD, 0.0f, 0.0f, 0.0f, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
                    break;
                    case 10: me->SummonCreature(MEMORY_HOGGER, 0.0f, 0.0f, 0.0f, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
                    break;
                    case 11: me->SummonCreature(MEMORY_IGNIS, 0.0f, 0.0f, 0.0f, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
                    break;
                    case 12: me->SummonCreature(MEMORY_ILLIDAN, 0.0f, 0.0f, 0.0f, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
                    break;
                    case 13: me->SummonCreature(MEMORY_INGVAR, 0.0f, 0.0f, 0.0f, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
                    break;
                    case 14: me->SummonCreature(MEMORY_KALITHRESH, 0.0f, 0.0f, 0.0f, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
                    break;
                    case 15: me->SummonCreature(MEMORY_LUCIFRON, 0.0f, 0.0f, 0.0f, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
                    break;
                    case 16: me->SummonCreature(MEMORY_MALCHEZAAR, 0.0f, 0.0f, 0.0f, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
                    break;
                    case 17: me->SummonCreature(MEMORY_MUTANUS, 0.0f, 0.0f, 0.0f, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
                    break;
                    case 18: me->SummonCreature(MEMORY_ONYXIA, 0.0f, 0.0f, 0.0f, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
                    break;
                    case 19: me->SummonCreature(MEMORY_THUNDERAAN, 0.0f, 0.0f, 0.0f, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
                    break;
                    case 20: me->SummonCreature(MEMORY_VANCLEEF, 0.0f, 0.0f, 0.0f, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
                    break;
                    case 21: me->SummonCreature(MEMORY_VASHJ, 0.0f, 0.0f, 0.0f, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
                    break;
                    case 22: me->SummonCreature(MEMORY_VEKNILASH, 0.0f, 0.0f, 0.0f, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
                    break;
                    case 23: me->SummonCreature(MEMORY_VEZAX, 0.0f, 0.0f, 0.0f, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
                    break;
                    case 24: me->SummonCreature(MEMORY_ARCHIMONDE, 0.0f, 0.0f, 0.0f, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
                    break; 
	            }
            }

            DoMeleeAttackIfReady();
        }
        void UpdateAI(const uint32 uiDiff)
        {
            if (!bDone && GrandChampionsOutVehicle(me))
            {
                bDone = true;

                if (pInstance && me->GetGUID() == pInstance->GetData64(DATA_GRAND_CHAMPION_1))
                    me->SetHomePosition(739.678f,662.541f,412.393f,4.49f);
                else if (pInstance && me->GetGUID() == pInstance->GetData64(DATA_GRAND_CHAMPION_2))
                    me->SetHomePosition(746.71f,661.02f,411.69f,4.6f);
                else if (pInstance && me->GetGUID() == pInstance->GetData64(DATA_GRAND_CHAMPION_3))
                    me->SetHomePosition(754.34f,660.70f,412.39f,4.79f);

                if (pInstance)
                    pInstance->SetData(BOSS_GRAND_CHAMPIONS, IN_PROGRESS);

                EnterEvadeMode();
                bHome = true;
            }

            if (uiPhaseTimer <= uiDiff)
            {
                if (uiPhase == 1)
                {
                    AggroAllPlayers(me);
                    uiPhase = 0;
                }
            }else uiPhaseTimer -= uiDiff;

            if (!UpdateVictim() || me->HasUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT))
                return;

            if (uiLightningArrowsTimer <= uiDiff)
            {
                DoCastAOE(SPELL_LIGHTNING_ARROWS,false);
                uiLightningArrowsTimer = 7000;
            } else uiLightningArrowsTimer -= uiDiff;

            if (uiShootTimer <= uiDiff)
            {
                if (Unit* pTarget = SelectTarget(SELECT_TARGET_FARTHEST,0,30.0f))
                {
                    uiTargetGUID = pTarget->GetGUID();
                    DoCast(pTarget, SPELL_SHOOT);
                }
                uiShootTimer = 12000;
                uiMultiShotTimer = 3000;
                bShoot = true;
            } else uiShootTimer -= uiDiff;

            if (bShoot && uiMultiShotTimer <= uiDiff)
            {
                me->InterruptNonMeleeSpells(true);
                Unit* pTarget = Unit::GetUnit(*me, uiTargetGUID);

                if (pTarget && me->IsInRange(pTarget,5.0f,30.0f,false))
                {
                    DoCast(pTarget,SPELL_MULTI_SHOT);
                } else
                {
                    Map::PlayerList const& players = me->GetMap()->GetPlayers();
                    if (me->GetMap()->IsDungeon() && !players.isEmpty())
                    {
                        for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
                        {
                            Player* pPlayer = itr->getSource();
                            if (pPlayer && !pPlayer->isGameMaster() && me->IsInRange(pPlayer,5.0f,30.0f,false))
                            {
                                DoCast(pTarget,SPELL_MULTI_SHOT);
                                break;
                            }
                        }
                    }
                }
                bShoot = false;
            } else uiMultiShotTimer -= uiDiff;

            DoMeleeAttackIfReady();
        }