Ejemplo n.º 1
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->ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_MOD_TAUNT, true);
                        me->ApplySpellImmune(0, IMMUNITY_EFFECT,SPELL_EFFECT_ATTACK_ME, true);
                        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_instance && pFloor)
                            m_instance->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_instance)
                        m_instance->SetData(DATA_ONYXIA_PHASE, m_uiPhase);
                    DoScriptText(SAY_PHASE_3_TRANS, me);

                    SetCombatMovement(true);
                    me->SetFlying(false);
                    m_bIsMoving = false;
                    me->ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_MOD_TAUNT, false);
                    me->ApplySpellImmune(0, IMMUNITY_EFFECT,SPELL_EFFECT_ATTACK_ME, 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* target = SelectTarget(SELECT_TARGET_RANDOM, 0))
                            DoCast(target, 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;
            }
        }
Ejemplo n.º 2
0
        void UpdateAI(uint32 Diff)
        {
            if (!UpdateVictim())
                return;

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

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

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

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

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

                DoMeleeAttackIfReady();
            }
            else
            {
                if (HealthBelowPct(40))
                {
                    Phase = PHASE_END;
                    if (instance)
                        instance->SetData(DATA_ONYXIA_PHASE, Phase);
                    Talk(SAY_PHASE_3_TRANS);

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

                if (DeepBreathTimer <= Diff)
                {
                    if (!IsMoving)
                    {
                        if (me->IsNonMeleeSpellCasted(false))
                            me->InterruptNonMeleeSpells(false);

                        Talk(EMOTE_BREATH);
                        DoCast(me, PointData->SpellId);
                        DeepBreathTimer = 70000;
                    }
                }
                else
                    DeepBreathTimer -= Diff;

                if (MovementTimer <= Diff)
                {
                    if (!IsMoving)
                    {
                        SetNextRandomPoint();
                        PointData = GetMoveData();

                        if (!PointData)
                            return;

                        me->GetMotionMaster()->MovePoint(PointData->LocId, PointData->fX, PointData->fY, PointData->fZ);
                        IsMoving = true;
                        MovementTimer = 25000;
                    }
                }
                else
                    MovementTimer -= Diff;

                if (FireballTimer <= Diff)
                {
                    if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() != POINT_MOTION_TYPE)
                    {
                        if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0))
                            DoCast(target, SPELL_FIREBALL);

                        FireballTimer = 8000;
                    }
                }
                else
                    FireballTimer -= Diff;

                if (LairGuardTimer <= Diff)
                {
                    me->SummonCreature(NPC_LAIRGUARD, SpawnLocations[2], TEMPSUMMON_CORPSE_DESPAWN);
                    LairGuardTimer = 30000;
                }
                else
                    LairGuardTimer -= Diff;

                if (WhelpTimer <= Diff)
                {
                    me->SummonCreature(NPC_WHELP, SpawnLocations[0], TEMPSUMMON_CORPSE_DESPAWN);
                    me->SummonCreature(NPC_WHELP, SpawnLocations[1], TEMPSUMMON_CORPSE_DESPAWN);
                    if (SummonWhelpCount >= RAID_MODE(20, 40))
                    {
                        SummonWhelpCount = 0;
                        WhelpTimer = 90000;
                    }
                    else
                        WhelpTimer = 500;
                }
                else
                    WhelpTimer -= Diff;
            }
        }
Ejemplo n.º 3
0
        void UpdateAI(uint32 diff) override
        {
            if (!UpdateVictim())
                return;

            //Common to PHASE_START && PHASE_END
            if (Phase == PHASE_START || Phase == PHASE_END)
            {
                //Specific to PHASE_START || PHASE_END
                if (Phase == PHASE_START)
                {
                    if (HealthBelowPct(65))
                    {
                        if (Unit* target = me->GetVictim())
                            tankGUID = target->GetGUID();
                        SetCombatMovement(false);
                        Phase = PHASE_BREATH;
                        me->SetReactState(REACT_PASSIVE);
                        me->AttackStop();
                        me->GetMotionMaster()->MovePoint(10, Phase2Location);
                        return;
                    }
                }

                events.Update(diff);

                while (uint32 eventId = events.ExecuteEvent())
                {
                    switch (eventId)
                    {
                        case EVENT_BELLOWING_ROAR: // Phase PHASE_END
                        {
                            DoCastVictim(SPELL_BELLOWING_ROAR);
                            // Eruption
                            GameObject* Floor = NULL;
                            Trinity::GameObjectInRangeCheck check(me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), 15);
                            Trinity::GameObjectLastSearcher<Trinity::GameObjectInRangeCheck> searcher(me, Floor, check);
                            me->VisitNearbyGridObject(30, searcher);
                            if (Floor)
                                instance->SetData64(DATA_FLOOR_ERUPTION_GUID, Floor->GetGUID());
                            events.ScheduleEvent(EVENT_BELLOWING_ROAR, 30000);
                            break;
                        }
                        case EVENT_FLAME_BREATH:   // Phase PHASE_START and PHASE_END
                            DoCastVictim(SPELL_FLAME_BREATH);
                            events.ScheduleEvent(EVENT_FLAME_BREATH, urand(10000, 20000));
                            break;
                        case EVENT_TAIL_SWEEP:     // Phase PHASE_START and PHASE_END
                            DoCastAOE(SPELL_TAIL_SWEEP);
                            events.ScheduleEvent(EVENT_TAIL_SWEEP, urand(15000, 20000));
                            break;
                        case EVENT_CLEAVE:         // Phase PHASE_START and PHASE_END
                            DoCastVictim(SPELL_CLEAVE);
                            events.ScheduleEvent(EVENT_CLEAVE, urand(2000, 5000));
                            break;
                        case EVENT_WING_BUFFET:    // Phase PHASE_START and PHASE_END
                            DoCastVictim(SPELL_WING_BUFFET);
                            events.ScheduleEvent(EVENT_WING_BUFFET, urand(15000, 30000));
                            break;
                        default:
                            break;
                    }
                }
                DoMeleeAttackIfReady();
            }
            else
            {
                if (HealthBelowPct(40))
                {
                    Phase = PHASE_END;
                    instance->SetData(DATA_ONYXIA_PHASE, PHASE_END);
                    Talk(SAY_PHASE_3_TRANS);
                    SetCombatMovement(true);
                    IsMoving = false;
                    Position const pos = me->GetHomePosition();
                    me->GetMotionMaster()->MovePoint(9, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ() + 12.0f);
                    events.ScheduleEvent(EVENT_BELLOWING_ROAR, 30000);
                    return;
                }

                if (!me->isMoving())
                    if (Creature* trigger = ObjectAccessor::GetCreature(*me, triggerGUID))
                        me->SetFacingToObject(trigger);

                events.Update(diff);

                while (uint32 eventId = events.ExecuteEvent())
                {
                    switch (eventId)
                    {
                        case EVENT_DEEP_BREATH:      // Phase PHASE_BREATH
                            if (!IsMoving)
                            {
                                if (me->IsNonMeleeSpellCast(false))
                                    me->InterruptNonMeleeSpells(false);

                                Talk(EMOTE_BREATH);
                                if (PointData) /// @todo: In what cases is this null? What should we do?
                                    DoCast(me, PointData->SpellId);
                                events.ScheduleEvent(EVENT_DEEP_BREATH, 75000);
                            }
                            else
                                events.ScheduleEvent(EVENT_DEEP_BREATH, 1000);
                            break;
                        case EVENT_MOVEMENT:         // Phase PHASE_BREATH
                            if (!IsMoving && !(me->HasUnitState(UNIT_STATE_CASTING)))
                            {
                                SetNextRandomPoint();
                                PointData = GetMoveData();

                                if (!PointData)
                                    return;

                                me->GetMotionMaster()->MovePoint(PointData->LocId, PointData->fX, PointData->fY, PointData->fZ);
                                IsMoving = true;
                                events.ScheduleEvent(EVENT_MOVEMENT, 25000);
                            }
                            else
                                events.ScheduleEvent(EVENT_MOVEMENT, 500);
                            break;
                        case EVENT_FIREBALL:         // Phase PHASE_BREATH
                            if (!IsMoving)
                            {
                                if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0))
                                    DoCast(target, SPELL_FIREBALL);
                                events.ScheduleEvent(EVENT_FIREBALL, 8000);
                            }
                            else
                                events.ScheduleEvent(EVENT_FIREBALL, 1000);
                            break;
                        case EVENT_LAIR_GUARD:       // Phase PHASE_BREATH
                            me->SummonCreature(NPC_LAIRGUARD, SpawnLocations[2], TEMPSUMMON_CORPSE_DESPAWN);
                            events.ScheduleEvent(EVENT_LAIR_GUARD, 30000);
                            break;
                        case EVENT_WHELP_SPAWN:      // Phase PHASE_BREATH
                            me->SummonCreature(NPC_WHELP, SpawnLocations[0], TEMPSUMMON_CORPSE_DESPAWN);
                            me->SummonCreature(NPC_WHELP, SpawnLocations[1], TEMPSUMMON_CORPSE_DESPAWN);
                            if (SummonWhelpCount >= RAID_MODE(20, 40))
                            {
                                SummonWhelpCount = 0;
                                events.ScheduleEvent(EVENT_WHELP_SPAWN, 90000);
                            }
                            else
                                events.ScheduleEvent(EVENT_WHELP_SPAWN, 500);
                            break;
                        default:
                            break;
                    }
                }
            }
        }
Ejemplo n.º 4
0
    void UpdateAI(const uint32 uiDiff)
    {
        if (!UpdateVictim())
            return;

        if (m_uiPhase == PHASE_START || m_uiPhase == PHASE_END)
        {
            if (m_uiFlameBreathTimer <= uiDiff)
            {
                DoCast(m_creature->getVictim(), SPELL_FLAMEBREATH);
                m_uiFlameBreathTimer = urand(10000, 20000);
            }
            else
                m_uiFlameBreathTimer -= uiDiff;

            if (m_uiTailSweepTimer <= uiDiff)
            {
                DoCast(m_creature, SPELL_TAILSWEEP);
                m_uiTailSweepTimer = urand(15000, 20000);
            }
            else
                m_uiTailSweepTimer -= uiDiff;

            if (m_uiCleaveTimer <= uiDiff)
            {
                DoCast(m_creature->getVictim(), SPELL_CLEAVE);
                m_uiCleaveTimer = urand(2000, 5000);
            }
            else
                m_uiCleaveTimer -= uiDiff;

            if (m_uiWingBuffetTimer <= uiDiff)
            {
                DoCast(m_creature->getVictim(), SPELL_WINGBUFFET);
                m_uiWingBuffetTimer = urand(15000, 30000);
            }
            else
                m_uiWingBuffetTimer -= uiDiff;

            if (m_uiPhase == PHASE_END)
            {
                if (m_uiBellowingRoarTimer <= uiDiff)
                {
                    DoCast(m_creature->getVictim(), SPELL_BELLOWINGROAR);
                    m_uiBellowingRoarTimer = 30000;
                }
                else
                    m_uiBellowingRoarTimer -= uiDiff;
            }
            else
            {
                if (m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 60)
                {
                    m_uiPhase = PHASE_BREATH;

                    SetCombatMovement(false);

                    m_creature->GetMotionMaster()->Clear(false);
                    m_creature->GetMotionMaster()->MoveIdle();

                    DoScriptText(SAY_PHASE_2_TRANS, m_creature);

                    if (m_pPointData)
                        m_creature->GetMotionMaster()->MovePoint(m_pPointData->uiLocId, m_pPointData->fX, m_pPointData->fY, m_pPointData->fZ);

                    SetNextRandomPoint();
                    return;
                }
            }

            DoMeleeAttackIfReady();
        }
        else
        {
            if (m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 40)
            {
                m_uiPhase = PHASE_END;
                DoScriptText(SAY_PHASE_3_TRANS, m_creature);

                SetCombatMovement(true);
                m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim());

                return;
            }

            if (m_uiMovementTimer <= uiDiff)
            {
                m_pPointData = GetMoveData();

                SetNextRandomPoint();

                m_uiMovementTimer = 25000;

                if (!m_pPointData)
                    return;

                if (m_uiMovePoint == m_pPointData->uiLocIdEnd)
                {
                    if (m_creature->IsNonMeleeSpellCasted(false))
                        m_creature->InterruptNonMeleeSpells(false);

                    DoScriptText(EMOTE_BREATH, m_creature);
                    DoCast(m_creature, m_pPointData->uiSpellId);
                }
                else
                {
                    m_creature->GetMotionMaster()->MovePoint(m_pPointData->uiLocId, m_pPointData->fX, m_pPointData->fY, m_pPointData->fZ);
                }
            }
            else
                m_uiMovementTimer -= uiDiff;

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

                    m_uiEngulfingFlamesTimer = 8000;
                }
            }
            else
                m_uiEngulfingFlamesTimer -= uiDiff;           //engulfingflames is supposed to be activated by a fireball but haven't come by

            if (m_bIsSummoningWhelps)
            {
                if (m_uiSummonCount < MAX_WHELP)
                {
                    if (m_uiWhelpTimer <= uiDiff)
                    {
                        m_creature->SummonCreature(NPC_WHELP, afSpawnLocations[0][0], afSpawnLocations[0][1], afSpawnLocations[0][2], 0.0f, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 30000);
                        m_creature->SummonCreature(NPC_WHELP, afSpawnLocations[1][0], afSpawnLocations[1][1], afSpawnLocations[1][2], 0.0f, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 30000);
                        m_uiWhelpTimer = 1000;
                    }
                    else
                        m_uiWhelpTimer -= uiDiff;
                }
                else
                {
                    m_bIsSummoningWhelps = false;
                    m_uiSummonCount = 0;
                    m_uiSummonWhelpsTimer = 30000;
                }
            }
            else
            {
                if (m_uiSummonWhelpsTimer <= uiDiff)
                    m_bIsSummoningWhelps = true;
                else
                    m_uiSummonWhelpsTimer -= uiDiff;
            }
            if (m_bIsSummoningLairGuards)
            {
                if (m_uiLairGuardTimer <= uiDiff)
                {
                    m_creature->SummonCreature(NPC_LAIRGUARD, afSpawnLocations[0][0], afSpawnLocations[0][1], afSpawnLocations[0][2], 0.0f, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 30000);
                    m_creature->SummonCreature(NPC_LAIRGUARD, afSpawnLocations[1][0], afSpawnLocations[1][1], afSpawnLocations[1][2], 0.0f, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 30000);
                    m_uiLairGuardTimer = 30000;
                }
                else
                    m_uiLairGuardTimer -= uiDiff;
            }
            else
            {
                if (m_uiLairGuardTimer <= uiDiff)
                    m_bIsSummoningLairGuards = true;
                else
                    m_uiLairGuardTimer -= uiDiff;
            }
        }
    }
Ejemplo n.º 5
0
    void UpdateAI(const uint32 uiDiff)
    {
        if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
            return;

        if (m_uiEvadeCheckCooldown < uiDiff)
        {
            if (m_creature->GetDistance2d(-22.346f, -214.57f) > 100.0f)
            {
                EnterEvadeMode();
                m_uiPhase = PHASE_START;
            }
            m_uiEvadeCheckCooldown = 2000;
        }
        else
            m_uiEvadeCheckCooldown -= uiDiff;

        if (m_uiPhase == PHASE_START || m_uiPhase == PHASE_END)
        {
            if (m_uiFlameBreathTimer < uiDiff)
            {
                DoCastSpellIfCan(m_creature->getVictim(), Regular ? SPELL_FLAMEBREATH : H_SPELL_FLAMEBREATH);
                m_uiFlameBreathTimer = urand(10000, 20000);
            }
            else
                m_uiFlameBreathTimer -= uiDiff;

            if (m_uiTailSweepTimer < uiDiff)
            {
                DoCastSpellIfCan(m_creature, Regular ? SPELL_TAILSWEEP : H_SPELL_TAILSWEEP);
                m_uiTailSweepTimer = urand(15000, 20000);
            }
            else
                m_uiTailSweepTimer -= uiDiff;

            if (m_uiCleaveTimer < uiDiff)
            {
                DoCastSpellIfCan(m_creature->getVictim(), SPELL_CLEAVE);
                m_uiCleaveTimer = urand(2000, 5000);
            }
            else
                m_uiCleaveTimer -= uiDiff;

            if (m_uiWingBuffetTimer < uiDiff)
            {
                DoCastSpellIfCan(m_creature->getVictim(), Regular ? SPELL_WINGBUFFET : H_SPELL_WINGBUFFET);
                m_uiWingBuffetTimer = urand(15000, 30000);
            }
            else
                m_uiWingBuffetTimer -= uiDiff;

            if (m_uiPhase == PHASE_END)
            {
                if (m_uiBellowingRoarTimer < uiDiff)
                {
                    DoCastSpellIfCan(m_creature->getVictim(), SPELL_BELLOWINGROAR);
                    m_uiBellowingRoarTimer = 30000;
                }
                else
                    m_uiBellowingRoarTimer -= uiDiff;
            }
            else
            {
                if (m_creature->GetHealthPercent() < 65.0f)
                {
                    m_uiPhase = PHASE_BREATH;

                    SetCombatMovement(false);

                    m_creature->GetMotionMaster()->Clear(false);
                    m_creature->GetMotionMaster()->MoveIdle();

                    DoScriptText(SAY_PHASE_2_TRANS, m_creature);

                    if (m_pPointData)
                        m_creature->GetMotionMaster()->MovePoint(m_pPointData->uiLocId, m_pPointData->fX, m_pPointData->fY, m_pPointData->fZ);

                    SetNextRandomPoint();
                    return;
                }
            }

            DoMeleeAttackIfReady();
        }
        else
        {
            if (m_creature->GetHealthPercent() < 40.0f)
            {
                m_uiPhase = PHASE_END;
                DoScriptText(SAY_PHASE_3_TRANS, m_creature);

                SetCombatMovement(true);
                m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim());

                return;
            }

            if (m_uiMovementTimer < uiDiff)
            {
                m_pPointData = GetMoveData();

                SetNextRandomPoint();

                m_uiMovementTimer = 25000;

                if (!m_pPointData)
                    return;

                if (m_uiMovePoint == m_pPointData->uiLocIdEnd)
                {
                    if (m_creature->IsNonMeleeSpellCasted(false))
                        m_creature->InterruptNonMeleeSpells(false);

                    DoScriptText(EMOTE_BREATH, m_creature);
                    DoCastSpellIfCan(m_creature, m_pPointData->uiSpellId);
                }
                else
                {
                    m_creature->GetMotionMaster()->MovePoint(m_pPointData->uiLocId, m_pPointData->fX, m_pPointData->fY, m_pPointData->fZ);
                }
            }
            else
                m_uiMovementTimer -= uiDiff;

            if (m_uiEngulfingFlamesTimer < uiDiff)
            {
                if (m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType() != POINT_MOTION_TYPE)
                {
                    if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0))
                        DoCastSpellIfCan(pTarget, SPELL_FIREBALL);

                    m_uiEngulfingFlamesTimer = 8000;
                }
            }
            else
                m_uiEngulfingFlamesTimer -= uiDiff;           //engulfingflames is supposed to be activated by a fireball but haven't come by

            if (m_bIsSummoningWhelps)
            {
                if (m_uiSummonCount < m_uiMaxWhelps)
                {
                    if (m_uiWhelpTimer < uiDiff)
                    {
                        m_creature->SummonCreature(NPC_WHELP, SpawnLocs[0][0], SpawnLocs[0][1], SpawnLocs[0][2], 0.0f, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 30000);
                        m_creature->SummonCreature(NPC_WHELP, SpawnLocs[1][0], SpawnLocs[1][1], SpawnLocs[1][2], 0.0f, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 30000);
                        m_uiSummonCount += 2;
                        m_uiWhelpTimer = 500;
                    }
                    else
                        m_uiWhelpTimer -= uiDiff;
                }
                else
                {
                    m_bIsSummoningWhelps = false;
                    m_uiSummonCount = 0;
                    m_uiSummonWhelpsTimer = 85000;
                }
            }
            else
            {
                if (m_uiSummonWhelpsTimer < uiDiff)
                    m_bIsSummoningWhelps = true;
                else
                    m_uiSummonWhelpsTimer -= uiDiff;
            }

            if (SummonGuardTimer < uiDiff)
            {
                m_creature->SummonCreature(NPC_GUARD, SpawnLocs[2][0], SpawnLocs[2][1], SpawnLocs[2][2], 0.0f, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 30000);
                SummonGuardTimer = 30000;
            }
            else 
                SummonGuardTimer -= uiDiff;
        }
    }