Example #1
0
            void UpdateAI(const uint32 diff)
            {
                DoMeleeAttackIfReady();

                if (IAmDead())
                    return;

                ReduceCD(diff);

                opponent = me->getVictim();

                if (!opponent )
                {
                    ResetOrGetNextTarget();
                    DoNonCombatActions();
                    return;
                }

                me->ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_MOD_TAUNT, true);
                me->ApplySpellImmune(0, IMMUNITY_EFFECT, SPELL_EFFECT_ATTACK_ME, true);

                if (me->GetHealth() < me->GetMaxHealth()*0.5 && isTimerReady(uiPotion_Timer))
                {
                    doCast(me, SPELL_HEALING_POTION);
                    uiPotion_Timer = 60000;
                }

                oom_spam = false;

                //buff and heal master's group
                if (master->GetGroup())
                {
                    BuffAndHealGroup(master);
                    CureGroup(master);
                }

                // Heal myself
                HealTarget (me, me->GetHealth() * 100 / me->GetMaxHealth());
                DoNormalAttack(diff);
                Counter(diff);

                ScriptedAI::UpdateAI(diff);
            }
Example #2
0
            void UpdateAI(const uint32 diff)
            {
                DoMeleeAttackIfReady();

                decrementTimers();

                if (IAmDead())
                    return;

                if (me->GetPower(POWER_MANA) < 400 && isTimerReady(uiPotion_Timer))
                {
                    doCast(me, SPELL_MANA_POTION);
                    uiPotion_Timer = 150;
                }

                if (me->GetPower(POWER_MANA)/me->GetMaxPower(POWER_MANA) < 10)
                {
                    if (uiOom_Timer == 0)
                        uiOom_Timer = 1;
                }

                BuffAndHealGroup(master);

                // Heal myself
                HealTarget (me, me->GetHealth() * 100 / me->GetMaxHealth());

                //the rest are combat so return if not fighting
                opponent = SelectTarget(SELECT_TARGET_TOPAGGRO, 0);

                if (!opponent && !me->getVictim())
                {
                    DoNonCombatActions();
                    ResetOrGetNextTarget();
                    return;
                }

                //Cast totems.
                if (me->isInCombat() && isTimerReady(uiEarthTotem_Timer) && !master->HasAura(SPELL_STONE_SKIN_AURA, 0))
                {
                    doCast(me, SPELL_STONE_SKIN_TOTEM);
                    GiveManaBack();
                    uiEarthTotem_Timer = 90;
                    return;
                }

                if (me->isInCombat() && isTimerReady(uiFireTotem_Timer))
                {
                    doCast(me, SPELL_SEARING_TOTEM);
                    GiveManaBack();
                    uiFireTotem_Timer = 180;
                    return;
                }

                if (me->isInCombat() && isTimerReady(uiWindTotem_Timer))
                {
                    doCast(me, SPELL_WINDFURY_TOTEM);
                    GiveManaBack();
                    uiWindTotem_Timer = 180;
                    return;
                }

                if (me->isInCombat())
                {
                    switch(master->getClass())
                    {
                        case CLASS_WARRIOR:
                        case CLASS_DEATH_KNIGHT:
                        case CLASS_ROGUE:
                            if (isTimerReady(uiWaterTotem_Timer) && !master->HasAura(SPELL_HEALING_STREAM_AURA))
                            {
                                doCast(me, SPELL_HEALING_STREAM_TOTEM);
                                uiWaterTotem_Timer = 90;
                                GiveManaBack();
                                return;
                            }
                            break;
                        default: //everyone else gets a mana totem
                            if (isTimerReady (uiWaterTotem_Timer) && !master->HasAura(SPELL_MANA_SPRING_AURA, 0))
                            {
                                doCast(me, SPELL_MANA_SPRING_TOTEM);
                                uiWaterTotem_Timer = 90;
                                GiveManaBack();
                                return;
                            }
                    }
                }

                if (isTimerReady(uiFlameShock_Timer))
                {
                    doCast(opponent, SPELL_FLAME_SHOCK);
                    uiFlameShock_Timer = 120;
                    return;
                }

                if (isTimerReady(uiLightningBolt_Timer))
                {
                    doCast(opponent, SPELL_LIGHTNING_BOLT);
                    uiLightningBolt_Timer = 180;
                    return;
                }

                if (isTimerReady(uiEarthShock_Timer))
                {
                    doCast(opponent, SPELL_EARTH_SHOCK);
                    uiEarthShock_Timer = 250;
                    return;
                }

                //now try to heal bots and pets.  DoSelectLowestHpFriendly will get
                //everyone in group including bots and pets.  Unfortunately it can
                //not be triggered for % of lost HP, so we just set it to -1000.
                //This means low level players wont be healed because they wont have
                //enough HP.
                Unit* target = DoSelectLowestHpFriendly(40, 1000);

                if (target)
                {
                    if (CanCast(target, GetSpellStore()->LookupEntry (SPELL_CHAIN_HEAL)))
                    {
                        doCast(target, SPELL_CHAIN_HEAL, false);
                        uiOthersHeal_Timer = 50;
                    }
                }
                else
                {
                    target = DoSelectLowestHpFriendly(40, 500); //now try someone with less HP lost

                    if (target)
                    {
                        if (CanCast(target, GetSpellStore()->LookupEntry (SPELL_CHAIN_HEAL)))
                        {
                            doCast(target, SPELL_CHAIN_HEAL, false);
                            uiOthersHeal_Timer = 100;
                        }
                    }
                }

                ScriptedAI::UpdateAI(diff);
            }
		void UpdateAI(const uint32 diff)
		{

			ReduceCD(diff);

			if(IAmDead()) return;

			if(!m_creature->isInCombat())
			{
				DoNonCombatActions();
			}

			if(pet && pet != NULL && pet->isDead())
			{
				master->SetBotsPetDied();
				pet = NULL;
			}

			//if we think we have a pet, but master doesn't, it means we teleported
			if(pet && master->m_botHasPet == false)
			{
				master->SetBotsPetDied();
				pet = NULL;
			}

			DoNormalAttack(diff);
			ScriptedAI::UpdateAI(diff);

			//if low on health, drink a potion
			if(m_creature->GetHealth() < m_creature->GetMaxHealth()*0.6 && isTimerReady(Potion_cd))
			{
				doCast(m_creature, HEALINGPOTION);
				Potion_cd = 1500;
			}

			//if low on mana, drink a potion
			 if(m_creature->GetPower(POWER_MANA) < m_creature->GetMaxPower(POWER_MANA)*0.2)
			{
				if(isTimerReady(Potion_cd))
				{
					doCast(m_creature, MANAPOTION);
					//MonsterSay("MANA POTION", LANG_UNIVERSAL, NULL);
					Potion_cd = 1500;
				}
			 }

			opponent = SelectUnit(SELECT_TARGET_TOPAGGRO, 0);
			if(!opponent && !m_creature->getVictim())
			{
				ResetOrGetNextTarget();

				//to reduce the number of crashes, remove pet whenever we are not in combat
				if(pet != NULL && pet->isAlive())
				{
					master->SetBotsPetDied();
					pet = NULL;
				}
				return;
			}


			if(pet == NULL)
				CreatePet();

			if (pet && pet->isAlive() &&
				!pet->isInCombat() &&
				m_creature->getVictim()) {
				pet->Attack (m_creature->getVictim(), true);
				pet->GetMotionMaster()->MoveChase(m_creature->getVictim(), 1, 0);

			}
		}
Example #4
0
    void UpdateAI(const uint32 diff)
    {

        ReduceCD();

        if(IAmDead()) return;

        if(pet && pet != NULL && pet->isDead())
        {
            master->SetBotsPetDied();
            pet = NULL;
        }

        //if we think we have a pet, but master doesn't, it means we teleported
        if(pet && master->m_botHasPet == false)
        {
            master->SetBotsPetDied();
            pet = NULL;
        }

        m_creature->ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_MOD_TAUNT, true);
        m_creature->ApplySpellImmune(0, IMMUNITY_EFFECT, SPELL_EFFECT_ATTACK_ME, true);

        if(m_creature->GetHealth() < m_creature->GetMaxHealth()*0.3 && isTimerReady(Potion_cd))
        {
            doCast(m_creature, HEALINGPOTION);
            Potion_cd = Potion_cd;
        }
        if(m_creature->GetPower(POWER_MANA) < m_creature->GetMaxPower(POWER_MANA)*0.2)
        {
            if(isTimerReady(Potion_cd))
            {
                doCast(m_creature, MANAPOTION);
                //MonsterSay("MANA POTION", LANG_UNIVERSAL, NULL);
                Potion_cd = Potion_cd;
            } else {
                if(oom_spam == false)
                {
                    //MonsterSay("OOM", LANG_UNIVERSAL, NULL);
                    oom_spam = true;
                }
                ScriptedAI::UpdateAI(diff);
                //return; //can't do anything without mana
           }
        }
        oom_spam = false;

        ScriptedAI::UpdateAI(diff);

        opponent = SelectUnit(SELECT_TARGET_TOPAGGRO, 0);
        if(!opponent && !m_creature->getVictim())
        {
            ResetOrGetNextTarget();

            //to reduce the number of crashes, remove pet whenever we are not in combat
            if(pet != NULL && pet->isAlive())
            {
                master->SetBotsPetDied();
                pet = NULL;
            }

            return;
        }

        if(pet == NULL)
            CreatePet();

        if (pet && pet->isAlive() && 
            !pet->isInCombat() &&
            m_creature->getVictim()) {
            pet->Attack (m_creature->getVictim(), true);
            pet->GetMotionMaster()->MoveChase(m_creature->getVictim(), 1, 0);
        }

        if(m_creature->hasUnitState(UNIT_STAT_CASTING))
            return;
 
        DoNormalAttack(diff);
    }