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

        if (m_uiHolyground_Timer < uiDiff)
        {
            DoCast(m_creature, SPELL_HOLYGROUND, true);     //Triggered so it doesn't interrupt her at all
            m_uiHolyground_Timer = 3000;
        }
        else
            m_uiHolyground_Timer -= uiDiff;

        if (m_uiRepentance_Timer < uiDiff)
        {
            DoCast(m_creature->getVictim(),SPELL_REPENTANCE);
            DoScriptText(urand(0, 1) ? SAY_REPENTANCE1 : SAY_REPENTANCE2, m_creature);

            m_uiRepentance_Timer = urand(25000, 35000);     //A little randomness on that spell
        }
        else
            m_uiRepentance_Timer -= uiDiff;

        if (m_uiHolyfire_Timer < uiDiff)
        {
            //Time for an omgwtfpwn code to make maiden cast holy fire only on units outside the holy ground's 18 yard range
            Unit* pTarget = NULL;
            std::list<HostilReference *> t_list = m_creature->getThreatManager().getThreatList();
            std::vector<Unit *> target_list;
            for(std::list<HostilReference *>::iterator itr = t_list.begin(); itr!= t_list.end(); ++itr)
            {
                pTarget = Unit::GetUnit(*m_creature, (*itr)->getUnitGuid());
                if (pTarget && !pTarget->IsWithinDist(m_creature, 12.0f, false))
                    target_list.push_back(pTarget);
                pTarget = NULL;
            }
            if (target_list.size())
                pTarget = *(target_list.begin()+rand()%target_list.size());

            DoCast(pTarget,SPELL_HOLYFIRE);

            m_uiHolyfire_Timer = urand(8000, 23000);        //Anywhere from 8 to 23 seconds, good luck having several of those in a row!
        }
        else
            m_uiHolyfire_Timer -= uiDiff;

        if (m_uiHolywrath_Timer < uiDiff)
        {
            if (Unit* pTarget = SelectUnit(SELECT_TARGET_RANDOM,0))
                DoCast(pTarget, SPELL_HOLYWRATH);

            m_uiHolywrath_Timer = urand(20000, 25000);      //20-25 secs sounds nice
        }
        else
            m_uiHolywrath_Timer -= uiDiff;

        DoMeleeAttackIfReady();
    }
Example #2
0
        void IsSummonedBy(Unit* summoner) override
        {
            if (summoner->GetEntry() == NPC_MIDNIGHT)
                _phase = PHASE_ATTUMEN_ENGAGES;

            if (summoner->GetEntry() == NPC_ATTUMEN_UNMOUNTED)
            {
                _phase = PHASE_MOUNTED;
                DoCastSelf(SPELL_SPAWN_SMOKE);

                scheduler.Schedule(Seconds(10), Seconds(25), [this](TaskContext task)
                {
                    Unit* target = nullptr;
                    ThreatContainer::StorageType const &t_list = me->getThreatManager().getThreatList();
                    std::vector<Unit*> target_list;

                    for (ThreatContainer::StorageType::const_iterator itr = t_list.begin(); itr != t_list.end(); ++itr)
                    {
                        target = ObjectAccessor::GetUnit(*me, (*itr)->getUnitGuid());
                        if (target && !target->IsWithinDist(me, 8.00f, false) && target->IsWithinDist(me, 25.0f, false))
                            target_list.push_back(target);

                        target = nullptr;
                    }

                    if (!target_list.empty())
                        target = Trinity::Containers::SelectRandomContainerElement(target_list);

                    DoCast(target, SPELL_CHARGE);
                    task.Repeat(Seconds(10), Seconds(25));
                });

                scheduler.Schedule(Seconds(25), Seconds(35), [this](TaskContext task)
                {
                    DoCastVictim(SPELL_KNOCKDOWN);
                    task.Repeat(Seconds(25), Seconds(35));
                });
            }
        }
	void TryHealBrother(uint32 diff) {
		if (IAmVeklor()) // this spell heals caster and the other brother so let VN cast it
			return;

		if (Heal_Timer <= diff) {
			Unit *pOtherBoss = GetOtherBoss();
			if (pOtherBoss && pOtherBoss->IsWithinDist(me, 60)) {
				DoCast(pOtherBoss, SPELL_HEAL_BROTHER);
				Heal_Timer = 1000;
			}
		} else
			Heal_Timer -= diff;
	}
        void IsSummonedBy(WorldObject* summoner) override
        {
            if (summoner->GetEntry() == NPC_MIDNIGHT)
                _phase = PHASE_ATTUMEN_ENGAGES;

            if (summoner->GetEntry() == NPC_ATTUMEN_UNMOUNTED)
            {
                _phase = PHASE_MOUNTED;
                DoCastSelf(SPELL_SPAWN_SMOKE);

                scheduler.Schedule(Seconds(10), Seconds(25), [this](TaskContext task)
                {
                    Unit* target = nullptr;
                    std::vector<Unit*> target_list;

                    for (auto* ref : me->GetThreatManager().GetUnsortedThreatList())
                    {
                        target = ref->GetVictim();
                        if (target && !target->IsWithinDist(me, 8.00f, false) && target->IsWithinDist(me, 25.0f, false))
                            target_list.push_back(target);

                        target = nullptr;
                    }

                    if (!target_list.empty())
                        target = Trinity::Containers::SelectRandomContainerElement(target_list);

                    DoCast(target, SPELL_CHARGE);
                    task.Repeat(Seconds(10), Seconds(25));
                });

                scheduler.Schedule(Seconds(25), Seconds(35), [this](TaskContext task)
                {
                    DoCastVictim(SPELL_KNOCKDOWN);
                    task.Repeat(Seconds(25), Seconds(35));
                });
            }
        }
Example #5
0
            void FilterTargets(std::list<Unit*>& unitList)
            {
                totalTargets = NULL;
                for (std::list<Unit*>::iterator itr = unitList.begin() ; itr != unitList.end(); ++itr)
                {
                    Unit *target = (*itr);
                    if (!target)
                        continue;

                    if (!target->IsWithinDist(GetTargetUnit(), 10.0f))
                    {
                        unitList.remove(target);
                        continue;
                    }

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

            //GreaterFireball_Timer
            if (GreaterFireball_Timer < diff || me->IsWithinDist(me->GetVictim(), 30))
            {
                DoCastVictim(SPELL_GREATER_FIREBALL);
                GreaterFireball_Timer = 2000;
            } else GreaterFireball_Timer -= diff;

            //SpellShield_Timer
            if (SpellShield_Timer <= diff)
            {
                me->InterruptNonMeleeSpells(false);
                DoCastVictim(SPELL_SPELLSHIELD);
                SpellShield_Timer = 30000;
            } else SpellShield_Timer -= diff;

            //BlastWave_Timer
            if (BlastWave_Timer <= diff)
            {
                Unit* target = NULL;
                std::list<HostileReference*> t_list = me->getThreatManager().getThreatList();
                std::vector<Unit*> target_list;
                for (std::list<HostileReference*>::const_iterator itr = t_list.begin(); itr!= t_list.end(); ++itr)
                {
                    target = ObjectAccessor::GetUnit(*me, (*itr)->getUnitGuid());
                                                                //15 yard radius minimum
                    if (target && target->IsWithinDist(me, 15, false))
                        target_list.push_back(target);
                    target = NULL;
                }
                if (!target_list.empty())
                    target = *(target_list.begin() + rand32() % target_list.size());

                me->InterruptNonMeleeSpells(false);
                DoCast(target, SPELL_BLAST_WAVE);
                BlastWave_Timer = 60000;
            } else BlastWave_Timer -= diff;
        }
        void UpdateAI(uint32 diff) override
        {
            if (!UpdateVictim())
                return;

            //GreaterFireball_Timer
            if (GreaterFireball_Timer < diff || me->IsWithinDist(me->GetVictim(), 30))
            {
                DoCastVictim(SPELL_GREATER_FIREBALL);
                GreaterFireball_Timer = 2000;
            } else GreaterFireball_Timer -= diff;

            //SpellShield_Timer
            if (SpellShield_Timer <= diff)
            {
                me->InterruptNonMeleeSpells(false);
                DoCastVictim(SPELL_SPELLSHIELD);
                SpellShield_Timer = 30000;
            } else SpellShield_Timer -= diff;

            //BlastWave_Timer
            if (BlastWave_Timer <= diff)
            {
                std::vector<Unit*> target_list;
                for (auto* ref : me->GetThreatManager().GetUnsortedThreatList())
                {
                    Unit* target = ref->GetVictim();
                    if (target && target->IsWithinDist(me, 15, false)) // 15 yard radius minimum
                        target_list.push_back(target);
                }
                Unit* target = nullptr;
                if (!target_list.empty())
                    target = *(target_list.begin() + rand32() % target_list.size());

                me->InterruptNonMeleeSpells(false);
                DoCast(target, SPELL_BLAST_WAVE);
                BlastWave_Timer = 60000;
            } else BlastWave_Timer -= diff;
        }
Example #8
0
            void UpdateAI(const uint32 diff)
            {
                if(!UpdateVictim())
                    return;
                // Pounding
                if(Pounding_Timer <= diff)
                {
                    DoCast(me->getVictim(), SPELL_POUNDING);
                    DoScriptText(RAND(SAY_POUNDING1, SAY_POUNDING2), me);
                    Pounding_Timer = 15000; //cast time(3000) + cooldown time(12000)
                }
                else
                    Pounding_Timer -= diff;
                // Arcane Orb
                if(ArcaneOrb_Timer <= diff)
                {
                    Unit* target = NULL;
                    std::list<HostileReference *> t_list = me->getThreatManager().getThreatList();
                    std::vector<Unit* > target_list;
                    for(std::list<HostileReference *>::const_iterator itr = t_list.begin(); itr!= t_list.end(); ++itr)
                    {
                        target = Unit::GetUnit(*me, (*itr)->getUnitGuid());
                        if(!target)
                            continue;
                        // exclude pets & totems, 18 yard radius minimum
                        if(target->GetTypeId() == TYPEID_PLAYER && target->isAlive() && !target->IsWithinDist(me, 18, false))
                            target_list.push_back(target);
                        target = NULL;
                    }

                    if(target_list.size())
                        target = *(target_list.begin()+rand()%target_list.size());
                    else
                        target = me->getVictim();

                    if(target)
                        me->CastSpell(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), SPELL_ARCANE_ORB, false, NULL, NULL, 0, target);
                    ArcaneOrb_Timer = 3000;
                }
                else
                    ArcaneOrb_Timer -= diff;
                // Single Target knock back, reduces aggro
                if(KnockAway_Timer <= diff)
                {
                    DoCast(me->getVictim(), SPELL_KNOCK_AWAY);
                    //Drop 25% aggro
                    if(DoGetThreat(me->getVictim()))
                        DoModifyThreatPercent(me->getVictim(), -25);
                    KnockAway_Timer = 30000;
                }
                else
                    KnockAway_Timer -= diff;
                //Berserk
                if(Berserk_Timer < diff && !Enraged)
                {
                    DoCast(me, SPELL_BERSERK);
                    Enraged = true;
                }
                else
                    Berserk_Timer -= diff;

                DoMeleeAttackIfReady();

                EnterEvadeIfOutOfCombatArea(diff);
            }
Example #9
0
void boss_attumen::boss_attumenAI::UpdateAI(const uint32 diff)
{
    if (ResetTimer)
    {
        if (ResetTimer <= diff)
        {
            ResetTimer = 0;
            Unit *pMidnight = Unit::GetUnit(*me, Midnight);
            if (pMidnight)
            {
                pMidnight->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                pMidnight->SetVisible(true);
            }
            Midnight = 0;
            me->SetVisible(false);
            me->Kill(me);
        }
    } else ResetTimer -= diff;

    //Return since we have no target
    if (!UpdateVictim())
        return;

    if (me->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE))
        return;

    if (CleaveTimer <= diff)
    {
        DoCast(me->getVictim(), SPELL_SHADOWCLEAVE);
        CleaveTimer = urand(10000, 15000);
    } else CleaveTimer -= diff;

    if (CurseTimer <= diff)
    {
        DoCast(me->getVictim(), SPELL_INTANGIBLE_PRESENCE);
        CurseTimer = 30000;
    } else CurseTimer -= diff;

    if (RandomYellTimer <= diff)
    {
        DoScriptText(RAND(SAY_RANDOM1, SAY_RANDOM2), me);
        RandomYellTimer = urand(30000, 60000);
    } else RandomYellTimer -= diff;

    if (me->GetUInt32Value(UNIT_FIELD_DISPLAYID) == MOUNTED_DISPLAYID)
    {
        if (ChargeTimer <= diff)
        {
            Unit *pTarget = NULL;
            std::list<HostileReference *> t_list = me->getThreatManager().getThreatList();
            std::vector<Unit *> target_list;
            for (std::list<HostileReference *>::const_iterator itr = t_list.begin(); itr!= t_list.end(); ++itr)
            {
                pTarget = Unit::GetUnit(*me, (*itr)->getUnitGuid());
                if (pTarget && !pTarget->IsWithinDist(me, ATTACK_DISTANCE, false))
                    target_list.push_back(pTarget);
                pTarget = NULL;
            }
            if (target_list.size())
                pTarget = *(target_list.begin()+rand()%target_list.size());

            DoCast(pTarget, SPELL_BERSERKER_CHARGE);
            ChargeTimer = 20000;
        } else ChargeTimer -= diff;
    }
    else
    {
        if (HealthBelowPct(25))
        {
            Creature *pMidnight = Unit::GetCreature(*me, Midnight);
            if (pMidnight && pMidnight->GetTypeId() == TYPEID_UNIT)
            {
                CAST_AI(boss_midnight::boss_midnightAI, (pMidnight->AI()))->Mount(me);
                me->SetHealth(pMidnight->GetHealth());
                DoResetThreat();
            }
        }
    }

    DoMeleeAttackIfReady();
}
Example #10
0
        void UpdateAI(const uint32 diff)
        {
            //Only if not incombat check if the event is started
            if(!me->isInCombat() && pInstance && pInstance->GetData(DATA_MAULGAREVENT))
            {
                Unit* target = Unit::GetUnit((*me), pInstance->GetData64(DATA_MAULGAREVENT_TANK));

                if(target)
                {
                    AttackStart(target);
                }
            }

            //Return since we have no target
            if(!UpdateVictim())
                return;

            //someone evaded!
            if(pInstance && !pInstance->GetData(DATA_MAULGAREVENT))
            {
                EnterEvadeMode();
                return;
            }

            //GreaterFireball_Timer
            if(GreaterFireball_Timer < diff || me->IsWithinDist(me->getVictim(), 30))
            {
                DoCast(me->getVictim(), SPELL_GREATER_FIREBALL);
                GreaterFireball_Timer = 2000;
            } else GreaterFireball_Timer -= diff;

            //SpellShield_Timer
            if(SpellShield_Timer <= diff)
            {
                me->InterruptNonMeleeSpells(false);
                DoCast(me->getVictim(), SPELL_SPELLSHIELD);
                SpellShield_Timer = 30000;
            } else SpellShield_Timer -= diff;

            //BlastWave_Timer
            if(BlastWave_Timer <= diff)
            {
                Unit* target = NULL;
                std::list<HostileReference *> t_list = me->getThreatManager().getThreatList();
                std::vector<Unit* > target_list;
                for(std::list<HostileReference *>::const_iterator itr = t_list.begin(); itr!= t_list.end(); ++itr)
                {
                    target = Unit::GetUnit(*me, (*itr)->getUnitGuid());
                                                                //15 yard radius minimum
                    if(target && target->IsWithinDist(me, 15, false))
                        target_list.push_back(target);
                    target = NULL;
                }
                if(!target_list.empty())
                    target = *(target_list.begin()+rand()%target_list.size());

                me->InterruptNonMeleeSpells(false);
                DoCast(target, SPELL_BLAST_WAVE);
                BlastWave_Timer = 60000;
            } else BlastWave_Timer -= diff;
        }
    void UpdateAI(const uint32 diff)
    {
        if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
            return;

        // Pounding
        if (Pounding_Timer < diff)
        {
            DoCastSpellIfCan(m_creature->getVictim(),SPELL_POUNDING);
            DoScriptText(urand(0, 1) ? SAY_POUNDING1 : SAY_POUNDING2, m_creature);

            Pounding_Timer = 15000;                         //cast time(3000) + cooldown time(12000)
        }else Pounding_Timer -= diff;

        // Arcane Orb
        if (ArcaneOrb_Timer < diff)
        {
            Unit *target = NULL;
            std::vector<Unit *> target_list;

            ThreatList const& tList = m_creature->getThreatManager().getThreatList();
            for (ThreatList::const_iterator itr = tList.begin();itr != tList.end(); ++itr)
            {
                target = m_creature->GetMap()->GetUnit((*itr)->getUnitGuid());

                // exclude pets & totems
                if (!target || target->GetTypeId() != TYPEID_PLAYER)
                    continue;

                //18 yard radius minimum
                if (target->IsWithinDist(m_creature, 18.0f, false))
                    continue;

                target_list.push_back(target);
            }

            if (target_list.size())
                target = *(target_list.begin()+rand()%target_list.size());
            else
                target = m_creature->getVictim();

            if (target)
                DoCastSpellIfCan(target, SPELL_ARCANE_ORB_MISSILE);

            ArcaneOrb_Timer = 3000;
        }else ArcaneOrb_Timer -= diff;

        // Single Target knock back, reduces aggro
        if (KnockAway_Timer < diff)
        {
            DoCastSpellIfCan(m_creature->getVictim(),SPELL_KNOCK_AWAY);

            KnockAway_Timer = 30000;
        }else KnockAway_Timer -= diff;

        //Berserk
        if (Berserk_Timer < diff)
        {
            if (m_creature->IsNonMeleeSpellCasted(false))
                m_creature->InterruptNonMeleeSpells(false);

            DoCastSpellIfCan(m_creature,SPELL_BERSERK);
            Berserk_Timer = 600000;
        }else Berserk_Timer -= diff;

        DoMeleeAttackIfReady();

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

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

                while (uint32 eventId = events.ExecuteEvent())
                {
                    switch (eventId)
                    {
                        case EVENT_POUNDING:
                            DoCastVictim(SPELL_POUNDING);
                            Talk(SAY_POUNDING);
                            events.ScheduleEvent(EVENT_POUNDING, 15000);
                            break;
                        case EVENT_ARCANE_ORB:
                        {
                            Unit* target = NULL;
                            std::list<HostileReference*> t_list = me->getThreatManager().getThreatList();
                            std::vector<Unit*> target_list;
                            for (std::list<HostileReference*>::const_iterator itr = t_list.begin(); itr != t_list.end(); ++itr)
                            {
                                target = ObjectAccessor::GetUnit(*me, (*itr)->getUnitGuid());
                                if (!target)
                                    continue;
                                // exclude pets & totems, 18 yard radius minimum
                                if (target->GetTypeId() == TYPEID_PLAYER && target->IsAlive() && !target->IsWithinDist(me, 18, false))
                                    target_list.push_back(target);
                                target = NULL;
                            }

                            if (!target_list.empty())
                                target = *(target_list.begin() + rand32() % target_list.size());
                            else
                                target = me->GetVictim();

                            if (target)
                                me->CastSpell(target, SPELL_ARCANE_ORB, false, NULL, NULL);

                            events.ScheduleEvent(EVENT_ARCANE_ORB, 3000);
                            break;
                        }
                        case EVENT_KNOCK_AWAY:
                            DoCastVictim(SPELL_KNOCK_AWAY);
                            // Drop 25% aggro
                            if (DoGetThreat(me->GetVictim()))
                                DoModifyThreatPercent(me->GetVictim(), -25);

                            events.ScheduleEvent(EVENT_KNOCK_AWAY, 30000);
                            break;
                        case EVENT_BERSERK:
                            if (!Enraged)
                            {
                                DoCast(me, SPELL_BERSERK);
                                Enraged = true;
                            }
                            break;
                        default:
                            break;
                    }
                }

                DoMeleeAttackIfReady();

                EnterEvadeIfOutOfCombatArea(diff);
            }
Example #13
0
    void UpdateAI(const uint32 uiDiff)
    {
        if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
            return;

        if (m_pInstance && !m_pInstance->GetData(TYPE_MOROES))
            EnterEvadeMode();

        if (!m_bEnrage && m_creature->GetHealthPercent() < 30.0f)
        {
            DoCastSpellIfCan(m_creature, SPELL_FRENZY);
            m_bEnrage = true;
        }

        if (m_uiCheckAdds_Timer < uiDiff)
        {
            for (uint8 i = 0; i < 4; ++i)
            {
                if (m_auiAddGUID[i])
                {
                    Creature* pTemp = m_creature->GetMap()->GetCreature(m_auiAddGUID[i]);
                    if (pTemp && pTemp->isAlive() && (!pTemp->SelectHostileTarget() || !pTemp->getVictim()))
                        pTemp->AI()->AttackStart(m_creature->getVictim());
                }
            }
            m_uiCheckAdds_Timer = 5000;
        }
        else
            m_uiCheckAdds_Timer -= uiDiff;

        if (!m_bEnrage)
        {
            // Cast Vanish, then Garrote random victim
            if (m_uiVanish_Timer < uiDiff)
            {
                m_creature->setFaction(35);
                m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                DoCastSpellIfCan(m_creature, SPELL_VANISH);
                m_bInVanish      = true;
                m_uiVanish_Timer = 30000;
                m_uiWait_Timer   = 5000;
            }
            else
                m_uiVanish_Timer -= uiDiff;

            if (m_bInVanish)
            {
                if (m_uiWait_Timer < uiDiff)
                {
                    DoScriptText(urand(0, 1) ? SAY_SPECIAL_1 : SAY_SPECIAL_2, m_creature);

                    if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0))
                        pTarget->CastSpell(pTarget, SPELL_GARROTE, true);

                    m_creature->setFaction(16);
                    m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                    m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                    m_creature->AI()->AttackStart(m_creature->getVictim());
                    m_bInVanish = false;
                }
                else
                    m_uiWait_Timer -= uiDiff;
            }

            //Gouge highest aggro, and attack second highest
            if (m_uiGouge_Timer < uiDiff)
            {
                DoCastSpellIfCan(m_creature->getVictim(), SPELL_GOUGE);
                m_uiGouge_Timer = 40000;
            }
            else
                m_uiGouge_Timer -= uiDiff;

            if (m_uiBlind_Timer < uiDiff)
            {
                Unit* pTarget = NULL;

                ThreatList const& vThreatList = m_creature->getThreatManager().getThreatList();
                if (vThreatList.empty())
                    return;

                std::vector<Unit*> vTargetList;

                for (ThreatList::const_iterator itr = vThreatList.begin();itr != vThreatList.end(); ++itr)
                {
                    pTarget = m_creature->GetMap()->GetUnit((*itr)->getUnitGuid());

                    if (pTarget && pTarget->IsWithinDist(m_creature, ATTACK_DISTANCE, false))
                        vTargetList.push_back(pTarget);
                }

                if (!vTargetList.empty())
                    pTarget = *(vTargetList.begin()+rand()%vTargetList.size());

                if (pTarget)
                    DoCastSpellIfCan(pTarget, SPELL_BLIND);

                m_uiBlind_Timer = 40000;
            }
            else
                m_uiBlind_Timer -= uiDiff;
        }

        if (!m_bInVanish)
            DoMeleeAttackIfReady();
    }
Example #14
0
    void UpdateAI(const uint32 uiDiff)
    {
        //Return since we have no target
        if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
            return;

        // Growth
        // Gruul can cast this spell up to 30 times
        if (m_uiGrowth_Timer < uiDiff)
        {
            DoScriptText(EMOTE_GROW, m_creature);
            DoCast(m_creature,SPELL_GROWTH);
            m_uiGrowth_Timer = 30000;
        }
        else
            m_uiGrowth_Timer -= uiDiff;

        if (m_bPerformingGroundSlam)
        {
            if (m_uiGroundSlamTimer < uiDiff)
            {
                m_uiGroundSlamTimer     = 120000;
                m_uiHurtfulStrike_Timer = 8000;

                //Give a little time to the players to undo the damage from shatter
                if (m_uiReverberation_Timer < 10000)
                    m_uiReverberation_Timer += 10000;

                DoCast(m_creature, SPELL_SHATTER);
            }
            else
                m_uiGroundSlamTimer -= uiDiff;
        }
        else
        {
            // Hurtful Strike
            if (m_uiHurtfulStrike_Timer < uiDiff)
            {
                // Find 2nd-aggro target within melee range.
                Unit *pTarget = NULL;
                ThreatList const& tList = m_creature->getThreatManager().getThreatList();
                ThreatList::const_iterator itr = tList.begin();
                std::advance(itr, 1);
                for (;itr != tList.end(); ++itr)
                {
                    pTarget = Unit::GetUnit(*m_creature, (*itr)->getUnitGuid());
                    // exclude pets, totems & player out of melee range
                    if (pTarget->GetTypeId() != TYPEID_PLAYER || !pTarget->IsWithinDist(m_creature, ATTACK_DISTANCE, false))
                    {
                        pTarget = NULL;
                        continue;
                    }
                    //we've found someone
                    break;
                }

                if (pTarget)
                    DoCast(pTarget,SPELL_HURTFUL_STRIKE);
                else
                    DoCast(m_creature->getVictim(),SPELL_HURTFUL_STRIKE);

                m_uiHurtfulStrike_Timer = 8000;
            }
            else
                m_uiHurtfulStrike_Timer -= uiDiff;

            // Reverberation
            if (m_uiReverberation_Timer < uiDiff)
            {
                DoCast(m_creature->getVictim(), SPELL_REVERBERATION, true);
                m_uiReverberation_Timer = urand(15000, 25000);
            }
            else
                m_uiReverberation_Timer -= uiDiff;

            // Cave In
            if (m_uiCaveIn_Timer < uiDiff)
            {
                if (Unit* pTarget = SelectUnit(SELECT_TARGET_RANDOM,0))
                    DoCast(pTarget,SPELL_CAVE_IN);

                if (m_uiCaveIn_StaticTimer >= 4000)
                    m_uiCaveIn_StaticTimer -= 2000;

                    m_uiCaveIn_Timer = m_uiCaveIn_StaticTimer;

            }
            else
                m_uiCaveIn_Timer -= uiDiff;

            // Ground Slam, Gronn Lord's Grasp, Stoned, Shatter
            if (m_uiGroundSlamTimer < uiDiff)
            {
                m_creature->GetMotionMaster()->Clear();
                m_creature->GetMotionMaster()->MoveIdle();

                m_bPerformingGroundSlam = true;
                m_uiGroundSlamTimer     = 10000;

                DoCast(m_creature, SPELL_GROUND_SLAM);
            }
            else
                m_uiGroundSlamTimer -= uiDiff;

            DoMeleeAttackIfReady();
        }
    }
Example #15
0
    void UpdateAI(const uint32 diff)
    {
        if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
            return;

        if (m_pInstance && !m_pInstance->GetData(TYPE_MOROES))
            EnterEvadeMode();

        if (!Enrage && m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 30)
        {
            DoCast(m_creature, SPELL_FRENZY);
            Enrage = true;
        }

        if (CheckAdds_Timer < diff)
        {
            for (uint8 i = 0; i < 4; ++i)
            {
                Unit* Temp = NULL;
                if (AddGUID[i])
                {
                    Temp = Unit::GetUnit((*m_creature),AddGUID[i]);
                    if (Temp && Temp->isAlive())
                        if (!Temp->SelectHostileTarget() || !Temp->getVictim())
                            ((Creature*)Temp)->AI()->AttackStart(m_creature->getVictim());
                }
            }
            CheckAdds_Timer = 5000;
        }else CheckAdds_Timer -= diff;

        if (!Enrage)
        {
            //Cast Vanish, then Garrote random victim
            if (Vanish_Timer < diff)
            {
                m_creature->setFaction(35);
                m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                DoCast(m_creature, SPELL_VANISH);
                InVanish = true;
                Vanish_Timer = 30000;
                Wait_Timer = 5000;
            }else Vanish_Timer -= diff;

            if (InVanish)
            {
                if (Wait_Timer < diff)
                {
                    DoScriptText(urand(0, 1) ? SAY_SPECIAL_1 : SAY_SPECIAL_2, m_creature);

                    if (Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0))
                        target->CastSpell(target, SPELL_GARROTE, true);

                    m_creature->setFaction(16);
                    m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                    m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                    m_creature->AI()->AttackStart(m_creature->getVictim());
                    InVanish = false;
                }else Wait_Timer -= diff;
            }

            //Gouge highest aggro, and attack second highest
            if (Gouge_Timer < diff)
            {
                DoCast(m_creature->getVictim(), SPELL_GOUGE);
                Gouge_Timer = 40000;
            }else Gouge_Timer -= diff;

            if (Blind_Timer < diff)
            {
                Unit* target = NULL;
                std::list<HostileReference*> t_list = m_creature->getThreatManager().getThreatList();

                if (t_list.empty())
                    return;

                std::vector<Unit*> target_list;
                for (std::list<HostileReference*>::iterator itr = t_list.begin(); itr!= t_list.end(); ++itr)
                {
                    target = Unit::GetUnit(*m_creature, (*itr)->getUnitGuid());
                    if (target && target->IsWithinDist(m_creature, ATTACK_DISTANCE, false))
                        target_list.push_back(target);
                }
                if (target_list.size())
                    target = *(target_list.begin()+rand()%target_list.size());

                if (target)
                    DoCast(target, SPELL_BLIND);

                Blind_Timer = 40000;
            }else Blind_Timer -= diff;
        }

        if (!InVanish)
            DoMeleeAttackIfReady();
    }
Example #16
0
    void UpdateAI(const uint32 diff)
    {
        if (!m_creature->SelectHostilTarget() || !m_creature->getVictim())
            return;

        // Pounding
        if (Pounding_Timer < diff)
        {
            DoCast(m_creature->getVictim(),SPELL_POUNDING);

            switch(rand()%2)
            {
                case 0: DoScriptText(SAY_POUNDING1, m_creature); break;
                case 1: DoScriptText(SAY_POUNDING2, m_creature); break;
            }

            Pounding_Timer = 15000;                         //cast time(3000) + cooldown time(12000)
        }else Pounding_Timer -= diff;

        // Arcane Orb
        if (ArcaneOrb_Timer < diff)
        {
            Unit *target = NULL;
            std::list<HostilReference *> t_list = m_creature->getThreatManager().getThreatList();
            std::vector<Unit *> target_list;
            for(std::list<HostilReference *>::iterator itr = t_list.begin(); itr!= t_list.end(); ++itr)
            {
                target = Unit::GetUnit(*m_creature, (*itr)->getUnitGuid());
                // exclude pets & totems
                if (target->GetTypeId() != TYPEID_PLAYER)
                    continue;

                //18 yard radius minimum
                if (target && !target->IsWithinDist(m_creature, 18.0f, false))
                    target_list.push_back(target);

                target = NULL;
            }

            if (target_list.size())
                target = *(target_list.begin()+rand()%target_list.size());
            else
                target = m_creature->getVictim();

            if (target)
                DoCast(target, SPELL_ARCANE_ORB_MISSILE);

            ArcaneOrb_Timer = 3000;
        }else ArcaneOrb_Timer -= diff;

        // Single Target knock back, reduces aggro
        if (KnockAway_Timer < diff)
        {
            DoCast(m_creature->getVictim(),SPELL_KNOCK_AWAY);

            //Drop 25% aggro
            if (m_creature->getThreatManager().getThreat(m_creature->getVictim()))
                m_creature->getThreatManager().modifyThreatPercent(m_creature->getVictim(),-25);

            KnockAway_Timer = 30000;
        }else KnockAway_Timer -= diff;

        //Berserk
        if (Berserk_Timer < diff)
        {
            if (m_creature->IsNonMeleeSpellCasted(false))
                m_creature->InterruptNonMeleeSpells(false);

            DoCast(m_creature,SPELL_BERSERK);
            Berserk_Timer = 600000;
        }else Berserk_Timer -= diff;

        DoMeleeAttackIfReady();

        EnterEvadeIfOutOfCombatArea(diff);
    }