void PlayerbotHunterAI::Pull()
{
    if (!AUTO_SHOT) return;

    // check ammo
    uint32 ammo_id = GetPlayerBot()->GetUInt32Value(PLAYER_AMMO_ID);
    if (!ammo_id) {
        GetPlayerBot()->Say("I'm out of ammo.", LANG_UNIVERSAL);
        return;
    }

    Unit* pTarget = ObjectAccessor::GetUnit(*GetMaster(), GetMaster()->GetSelection());
    if (pTarget==NULL || pTarget->IsFriendlyTo(GetMaster()))
    {
        GetPlayerBot()->Say("Invalid target", LANG_UNIVERSAL);
        GetAI()->Follow(*GetMaster());
        return;
    }

    m_role = BOT_ROLE_DPS_RANGED;
    m_pulling = true;
    GetAI()->SetIgnoreUpdateTime(0);

    if(GetPlayerBot()->GetPet())
        GetPlayerBot()->GetPet()->SetReactState(REACT_PASSIVE);
}
uint8 PlayerbotClassAI::GetHealthPercentRaid(Player *gPlayer, uint8 &countNeedHealing)
{
    uint8 validMemberCount=0;
    uint16 totalHPPercent=0;
    std::list<Unit*> unitList;
    gPlayer->GetRaidMember(unitList,30);
    if(!unitList.empty()){
      for (std::list<Unit*>::iterator itr = unitList.begin() ; itr!=unitList.end();++itr) {
        //Player *tPlayer = GetPlayerBot()->GetObjPlayer((*itr)->GetGUID());
        Unit *tPlayer = sObjectMgr->GetPlayer((*itr)->GetGUID());
        if(tPlayer == NULL) continue;
        if(tPlayer->isDead()) continue;
        if(GetPlayerBot()->GetAreaId() != tPlayer->GetAreaId()) continue;
        //if(tPlayer->GetGUID() == GetPlayerBot()->GetGUID()) continue;
        if(GetPlayerBot()->GetDistance(tPlayer) > 30) continue;
        uint8 fndHPPercent =  tPlayer->GetHealth()*100 / tPlayer->GetMaxHealth();
        totalHPPercent+=fndHPPercent;
        validMemberCount++;
        if (fndHPPercent < 100) countNeedHealing++;

        //const std::string myname = GetPlayerBot()->GetName();
        //const std::string hisname = tPlayer->GetName();
        //sLog->outDebug("me = %s, checked= %s %u [%u / %u]", myname.c_str(), hisname.c_str(), fndHPPercent, tPlayer->GetHealth(), tPlayer->GetMaxHealth());

      }
    }
    if (validMemberCount == 0) return 100;
    return totalHPPercent / validMemberCount;
}
bool PlayerbotDruidAI::RezTarget (Unit *target)
{
    if(!target || target->isAlive()) return false;
    Player *m_bot = GetPlayerBot();
    if (target->IsNonMeleeSpellCasted(true)) { return false; } //Already resurrected

    if (m_bot->isInCombat())
    {
        if (!CanCast(REBIRTH,target)) return false;
        Unit *m_tank = FindMainTankInRaid(m_bot);
        if (!m_tank) m_tank = m_bot;
        if (target->GetGUID() != m_tank->GetGUID() &&
            (target->getClass() != (uint8) CLASS_PRIEST || target->getClass() != (uint8) CLASS_DRUID || target->getClass() != (uint8) CLASS_PALADIN) ) return false;
        std::string msg = "Rezzing ";
        msg += target->GetName();
       // msg += " with ";
       // msg += *REZZSpell->SpellName;
        GetPlayerBot()->Say(msg, LANG_UNIVERSAL);
        return CastSpell(REBIRTH, target);
    }
    else
    {
        if (!CanCast(REVIVE,target)) return false;
        std::string msg = "Rezzing ";
        msg += target->GetName();
       // msg += " with ";
       // msg += *REZZSpell->SpellName;
        GetPlayerBot()->Say(msg, LANG_UNIVERSAL);
        return CastSpell(REVIVE, target);
    }
    return false;
}
Unit *PlayerbotClassAI::DoSelectLowestHpFriendly(float range, uint32 MinHPDiff)
{
    Unit *pUnit = NULL;
    Trinity::MostHPMissingInRange u_check(GetPlayerBot(), range, MinHPDiff);
    Trinity::UnitLastSearcher<Trinity::MostHPMissingInRange> searcher(GetPlayerBot(), pUnit, u_check);

    GetPlayerBot()->VisitNearbyObject(range, searcher);

    return pUnit;
}
bool PlayerbotPaladinAI::RezTarget (Unit *target)
{
    if(!target || target->isAlive()) return false;
    Player *m_bot = GetPlayerBot();
    if (target->IsNonMeleeSpellCasted(true)) { return false; } //Already resurrected
    if (m_bot->isInCombat()) { return false; }

    if (!CanCast(REDEMPTION,target)) return false;
    std::string msg = "Rezzing ";
    msg += target->GetName();
    GetPlayerBot()->Say(msg, LANGUAGE_UNIVERSAL);
    return CastSpell(REDEMPTION, target, false);
}
示例#6
0
bool PlayerbotRogueAI::ChangeWeaponEnchants()
{
    PlayerbotAI *ai = GetAI();
    Player *m_bot = GetPlayerBot();
    if (!m_bot || !ai || m_bot->isDead()) { return false; }

    Item *weap;
    Item *poison;
        
    weap = m_bot->GetWeaponForAttack(BASE_ATTACK);
    if (weap && !weap->GetEnchantmentId(TEMP_ENCHANTMENT_SLOT))
    {
        poison = GetAI()->FindPoisonForward();
        if(poison == NULL) return false;
        GetAI()->PoisonWeapon(*poison, poison->GetProto()->Spells[0].SpellId, TARGET_FLAG_ITEM, EQUIPMENT_SLOT_MAINHAND);
        return true;
    }
    weap = m_bot->GetWeaponForAttack(OFF_ATTACK);
    if (weap && !weap->GetEnchantmentId(TEMP_ENCHANTMENT_SLOT))
    {
        poison = GetAI()->FindPoisonBackward();
        if(poison == NULL) return false;
        GetAI()->PoisonWeapon(*poison, poison->GetProto()->Spells[0].SpellId, TARGET_FLAG_ITEM, EQUIPMENT_SLOT_OFFHAND);
        return true;
    }
    return false;
}
void PlayerbotDeathKnightAI::DoNonCombatActions()
{
	PlayerbotAI* ai = GetAI();
	Player *m_bot = GetPlayerBot();
    if (!m_bot)
        return;

    SpellSequence = SPELL_DK_UNHOLY;

    // buff master with HORN_OF_WINTER
    if (HORN_OF_WINTER> 0)
        (!GetMaster()->HasAura(HORN_OF_WINTER,0) && ai->CastSpell (HORN_OF_WINTER, *GetMaster()));

    // hp check
    if (m_bot->getStandState() != UNIT_STAND_STATE_STAND)
        m_bot->SetStandState(UNIT_STAND_STATE_STAND);

    Item* pItem = ai->FindFood();
    Item* fItem = ai->FindBandage();

    if (pItem != NULL && ai->GetHealthPercent() < 30)
    {
        ai->TellMaster("I could use some food.");
        ai->UseItem(*pItem);
        ai->SetIgnoreUpdateTime(30);
        return;
    }
    else if (pItem == NULL && fItem != NULL && !m_bot->HasAura(RECENTLY_BANDAGED, 0) && ai->GetHealthPercent() < 70)
    {
        ai->TellMaster("I could use first aid.");
        ai->UseItem(*fItem);
        ai->SetIgnoreUpdateTime(8);
        return;
    }
} // end DoNonCombatActions
示例#8
0
void PlayerbotDruidAI::HealTarget(Unit &target, uint8 hp)
{
    PlayerbotAI* ai = GetAI();
    Player *m_bot = GetPlayerBot();

    if (hp < 70 && REJUVENATION > 0 && !target.HasAura(REJUVENATION, EFFECT_INDEX_0) && !target.HasAura(REGROWTH, EFFECT_INDEX_0) && ai->GetManaPercent() >=21)
        ai->CastSpell(REJUVENATION, target);

	if (hp < 60 && LIFEBLOOM > 0 && !target.HasAura(LIFEBLOOM, EFFECT_INDEX_0) && ai->GetManaPercent() >= 28)
        ai->CastSpell(LIFEBLOOM, target);

    if (hp < 55 && REGROWTH > 0 && !target.HasAura(REGROWTH, EFFECT_INDEX_0) && !target.HasAura(REJUVENATION, EFFECT_INDEX_0) && ai->GetManaPercent() >= 33)
        ai->CastSpell(REGROWTH, target);

	if (hp < 50 && SWIFTMEND > 0 && target.HasAura(REJUVENATION, EFFECT_INDEX_0) || target.HasAura(REGROWTH, EFFECT_INDEX_0) && ai->GetManaPercent() >= 16)
        ai->CastSpell(SWIFTMEND, target);

    if (hp < 45 && WILD_GROWTH > 0 && !target.HasAura(WILD_GROWTH, EFFECT_INDEX_0) && ai->GetManaPercent() >= 26)
        ai->CastSpell(WILD_GROWTH, target);

	if (hp < 30 && NOURISH > 0 && ai->GetManaPercent() >= 18)
        ai->CastSpell(NOURISH, target);

	if (hp < 25 && HEALING_TOUCH > 0 && ai->GetManaPercent() >= 38)
        ai->CastSpell(HEALING_TOUCH, target);
} // end HealTarget
bool PlayerbotShamanAI::HealTarget(Unit *target, uint8 hp)
{
    if(!target || target->isDead()) return false;
    Player *m_bot = GetPlayerBot();

    if(hp < 30 && m_bot->isInCombat() && CastSpell(NATURES_SWIFTNESS, m_bot)) {} // NO gcd
    if(hp < 60 && CanCast(HEAL,target,true) && m_bot->HasAura(NATURES_SWIFTNESS) && CastSpell(HEAL, target, false)) {
        return true;
    }
    if(hp < 30 && CastSpell(LESSER_HEAL,target,true,true)) {
        return true;
    }
    if(hp < 40 && m_bot->getRace() == (uint8) RACE_DRAENEI && CastSpell(R_GIFT_OF_NAARU,target)) {} // no GCD
    if(hp < 65 && CanCast(EARTH_SHIELD,target) && !m_bot->HasAura(EARTH_SHIELD,m_bot->GetGUID()) && CastSpell(EARTH_SHIELD,target,false)) {
        return true;
    }
    if(hp < 65 && CastSpell(HEAL,target,true,true)) {
        return true;
    }
    if(hp < 85 && CastSpell(LESSER_HEAL,target,true,true)) {
        return true;
    }

    return false;
} //end HealTarget
示例#10
0
void PlayerbotDruidAI::DoNonCombatActions()
{
    PlayerbotAI *ai = GetAI();
    Player *m_bot = GetPlayerBot();
    if (!m_bot || !ai || m_bot->isDead()) { return; }

    //If Casting or Eating/Drinking return
    if (m_bot->HasUnitState(UNIT_STAT_CASTING)) { return; }
    if (m_bot->getStandState() == UNIT_STAND_STATE_SIT) { return; }

    //buff and heal raid
    if (DoSupportRaid(GetMaster())) { return; }
    if (m_bot->GetGroup() && GetMaster()->GetGroup() != m_bot->GetGroup() && DoSupportRaid(m_bot)) { return; }

    //heal pets and bots
    Unit *target = DoSelectLowestHpFriendly(30, 1000);
    if (target && target->isAlive() && HealTarget(target, target->GetHealth()*100 / target->GetMaxHealth())) { return; }

    //mana/hp check
    //Don't bother with eating, if low on hp, just let it heal themself
    if (m_bot->getRace() == (uint8) RACE_UNDEAD_PLAYER && ai->GetHealthPercent() < 75 && CastSpell(R_CANNIBALIZE,m_bot)) { return; }
    if (ai->GetManaPercent() < 10 && CastSpell (INNERVATE, m_bot)) { return; } //Need mana fast
    if (m_bot->GetHealth() < m_bot->GetMaxHealth() &&
        (ai->GetForm() != FORM_CAT && ai->GetForm() != FORM_MOONKIN && ai->GetForm() != FORM_DIREBEAR && ai->GetForm() != FORM_BEAR)
        && CastSpell(REGROWTH,m_bot)) { return; }
    if (ai->GetManaPercent() < 50) { ai->Feast(); }

} //end DoNonCombatActions
示例#11
0
Player * PlayerbotClassAI::FindMage(Player *gPlayer)
{
    Group::MemberSlotList const &groupSlot = gPlayer->GetGroup()->GetMemberSlots();
    for(Group::member_citerator itr = groupSlot.begin(); itr != groupSlot.end(); itr++)
    {
        Player *tPlayer = sObjectMgr->GetPlayer(itr->guid);

        if(tPlayer == NULL) continue;
        if(tPlayer->GetGUID() == GetPlayerBot()->GetGUID()) continue;
        if(GetPlayerBot()->GetAreaId() != gPlayer->GetAreaId()) continue;
        if(GetPlayerBot()->GetDistance(tPlayer) > 30) continue;

        if (tPlayer->getClass() == CLASS_MAGE) return tPlayer;
    }
    return NULL;
}
//Playerbot mod: logs out a Playerbot.
void WorldSession::LogoutPlayerBot(uint64 guid, bool Save)
{
    Player *pPlayerBot = GetPlayerBot(guid);

    if(pPlayerBot) //log out any playbots I have
    {
        //if (pPlayerBot->IsMounted()) pPlayerBot->GetPlayerbotAI()->GetClassAI()->Unmount();

        pPlayerBot->CombatStop();
        if(pPlayerBot->HaveBot())
            pPlayerBot->SetBotMustDie();

        // remove from group
        Group* m_group = pPlayerBot->GetGroup();
        if (m_group) {
            if (m_group->RemoveMember(pPlayerBot->GetGUID(),GROUP_REMOVEMETHOD_DEFAULT) <= 1) {
                delete m_group;
            }
        }

        WorldSession *pPlayerBotWorldSession = pPlayerBot->m_session;
        m_playerBots.erase(guid); //deletes bot player ptr inside this WorldSession PlayerBotMap
        pPlayerBotWorldSession->LogoutPlayer(Save); //this will delete the bot Player object and PlayerbotAI object
        delete pPlayerBotWorldSession; //finally delete the bot's WorldSession
    }
}
示例#13
0
bool PlayerbotDruidAI::ChangeForm(uint32 form)
{
    PlayerbotAI *ai = GetAI();
    Player *m_bot = GetPlayerBot();
    if (!m_bot || !ai || m_bot->isDead()) { return false; }
    if (!form) return false;

    if (form == 1 && ai->GetForm() == FORM_NONE) return false;

    if (form != 1)
    {
        if (!CanCast(form,m_bot,0,0,1)) return false;
        if (m_bot->HasAura(form)) { return false; }
    }

    if (ai->GetForm() == FORM_TREE) m_bot->RemoveAurasDueToSpell(TREE_OF_LIFE_FORM);
    else if (ai->GetForm() == FORM_CAT) m_bot->RemoveAurasDueToSpell(CAT_FORM);
    else if (ai->GetForm() == FORM_MOONKIN) m_bot->RemoveAurasDueToSpell(MOONKIN_FORM);
    else if (ai->GetForm() == FORM_DIREBEAR || ai->GetForm() == FORM_BEAR) m_bot->RemoveAurasDueToSpell(BEAR_FORM);
    else if (ai->GetForm() == FORM_TRAVEL) m_bot->RemoveAurasDueToSpell(TRAVEL_FORM);
    else if (ai->GetForm() == FORM_FLIGHT || ai->GetForm() == FORM_FLIGHT_EPIC)    m_bot->RemoveAurasDueToSpell(FLIGHT_FORM);
    else if (ai->GetForm() == FORM_AQUA) m_bot->RemoveAurasDueToSpell(AQUATIC_FORM);

    if (form == 1) { return true; }

    return CastSpell(form,m_bot,false);
}
void PlayerbotDeathKnightAI::DoNonCombatActions()
{
    PlayerbotAI *ai = GetAI();
    Player *m_bot = GetPlayerBot();
    if (!m_bot || !ai || m_bot->isDead()) { return; }

    //If Casting or Eating/Drinking return
    if (m_bot->HasUnitState(UNIT_STATE_CASTING)) { return; }
    if (m_bot->getStandState() == UNIT_STAND_STATE_SIT) { return; }

    //Buff UP
    if (CastSpell(HORN_OF_WINTER,m_bot)) { return; }
    if (CastSpell(BONE_SHIELD,m_bot)) { return; }

    //mana/hp check
    if (m_bot->getRace() == (uint8) RACE_UNDEAD_PLAYER && ai->GetHealthPercent() < 75 && CastSpell(R_CANNIBALIZE,m_bot)) { return; }
    if (m_bot->GetHealth() < m_bot->GetMaxHealth() && CastSpell(RUNE_TAP,m_bot)) { return; } //no gcd but lets give the others a time to heal
    if (ai->GetHealthPercent() < 30) { ai->Feast(); }
    //Item* fItem = ai->FindBandage();
    /* if (pItem == NULL && fItem != NULL && !m_bot->HasAura(RECENTLY_BANDAGED, 0) && ai->GetHealthPercent() < 70)
    {
        ai->TellMaster("I could use first aid.");
        ai->UseItem(*fItem);
        ai->SetIgnoreUpdateTime(8);
        return;
    }  */
} // end DoNonCombatActions
示例#15
0
void PlayerbotMgr::LogoutPlayerBot(ObjectGuid guid)
{
    Player* bot = GetPlayerBot(guid);
    if (bot)
    {
        for (uint8 i = 0; i < MAX_ARENA_SLOT; ++i)
        {
            uint32 a_id = bot->GetArenaTeamId(i);
            if (a_id==0)
                continue;

            ArenaTeam *at = sObjectMgr.GetArenaTeamById(a_id);
            if (!at)
                continue;

            if (at->DisbandNoSave(bot))
                delete at;
        }

        if (bot->GetGroup())
            bot->RemoveFromGroup();

        WorldSession * botWorldSessionPtr = bot->GetSession();
        botWorldSessionPtr->LogoutPlayer(true); // this will delete the bot Player object and PlayerbotAI object
        delete botWorldSessionPtr;  // finally delete the bot's WorldSession
    }
}
示例#16
0
void PlayerbotShamanAI::DoNonCombatActions()
{
    PlayerbotAI *ai = GetAI();
    Player *m_bot = GetPlayerBot();
    if (!m_bot || !ai || m_bot->isDead()) { return; }

    //If Casting or Eating/Drinking return
    if (m_bot->HasUnitState(UNIT_STAT_CASTING)) { return; }
    if (m_bot->getStandState() == UNIT_STAND_STATE_SIT) { return; }

    //buff and heal raid
    if (DoSupportRaid(m_bot)) { return; }

    //heal pets and bots
    Unit *target = DoSelectLowestHpFriendly(40, 1000);
    if (target && target->isAlive() && HealTarget(target, target->GetHealth()*100 / target->GetMaxHealth())) { return; }

    //Buffs
    if (ChangeWeaponEnchants()) { return; }
    if (CastSpell(WATER_SHIELD,m_bot)) { return; }
    if (CastSpell(EARTH_SHIELD,m_bot)) { return; }

    //mana/hp check
    //Don't bother with eating, if low on hp, just let it heal themself
    if (m_bot->getRace() == (uint8) RACE_UNDEAD_PLAYER && ai->GetHealthPercent() < 75 && CastSpell(R_CANNIBALIZE,m_bot)) { return; }
    if (m_bot->GetHealth() < m_bot->GetMaxHealth() && CastSpell(LESSER_HEAL,m_bot)) { return; }
	if (ai->GetManaPercent() < 50) { ai->Feast(); }

} //end DoNonCombatActions
示例#17
0
bool PlayerbotDruidAI::HealGroup(Unit *target, uint8 hp, uint8 &countNeedHeal)
{
    PlayerbotAI *ai = GetAI();
    Player *m_bot = GetPlayerBot();
    if (!m_bot || !ai || m_bot->isDead()) { return false; }
    if (!target || target->isDead()) { return false; }

    if (countNeedHeal < 2) { return false; }

    // Decide if it is worth to change form
    if (ai->GetForm() == FORM_MOONKIN || ai->GetForm() == FORM_CAT || ai->GetForm() == FORM_DIREBEAR || ai->GetForm() == FORM_BEAR)
    {
        if (hp > 70) { return false; }
        if (!CanCast(TRANQUILITY,target,0,0,1) && !WILD_GROWTH) { return false; }
        if (!WILD_GROWTH && hp > 35) { return false; }
        if (hp < 65 && GetAI()->GetManaPercent() >= 70 ) { ChangeForm(1); }
        else if (hp < 40 && GetAI()->GetManaPercent() >= 50) { ChangeForm(1); }
        else if (hp < 25 && GetAI()->GetManaPercent() >= 30) { ChangeForm(1); }
        else return false;
    }

    if (hp < 36 && m_bot->isInCombat() && CanCast(TRANQUILITY,target))
    {
            bool sc = CastSpell(TRANQUILITY, target, false);
            if (sc) GetAI()->SetIgnoreUpdateTime(10);
            return sc;
    }
    if (hp < 75 && CastSpell(WILD_GROWTH,target)) { return true; }
    return false;
}
bool PlayerbotDruidAI::HealTarget(Unit *target)
{
    PlayerbotAI* ai = GetAI();
    uint8 hp = target->GetHealth() * 100 / target->GetMaxHealth();

    if (hp >= 70)
        return false;

    // Reset form if needed
    GoBuffForm(GetPlayerBot());

    if (hp < 70 && REJUVENATION > 0 && !target->HasAura(REJUVENATION) && ai->CastSpell(REJUVENATION, *target))
        return true;

    if (hp < 60 && LIFEBLOOM > 0 && !target->HasAura(LIFEBLOOM) && ai->CastSpell(LIFEBLOOM, *target))
        return true;

    if (hp < 55 && REGROWTH > 0 && !target->HasAura(REGROWTH) && ai->CastSpell(REGROWTH, *target))
        return true;

    if (hp < 50 && SWIFTMEND > 0 && (target->HasAura(REJUVENATION) || target->HasAura(REGROWTH)) && ai->CastSpell(SWIFTMEND, *target))
        return true;

    if (hp < 45 && WILD_GROWTH > 0 && !target->HasAura(WILD_GROWTH) && ai->CastSpell(WILD_GROWTH, *target))
        return true;

    if (hp < 30 && NOURISH > 0 && ai->CastSpell(NOURISH, *target))
        return true;

    if (hp < 25 && HEALING_TOUCH > 0 && ai->CastSpell(HEALING_TOUCH, *target))
        return true;

    return false;
} // end HealTarget
示例#19
0
bool PlayerbotDruidAI::HealTarget(Unit *target, uint8 hp)
{
    PlayerbotAI *ai = GetAI();
    Player *m_bot = GetPlayerBot();
    if (!m_bot || !ai || m_bot->isDead()) { return false; }
    if (!target || target->isDead()) { return false; }

    // Decide if it is worth to change form
    if (ai->GetForm() == FORM_MOONKIN || ai->GetForm() == FORM_CAT || ai->GetForm() == FORM_DIREBEAR || ai->GetForm() == FORM_BEAR)
    {
        if (hp < 75 && GetAI()->GetManaPercent() >= 70 ) { ChangeForm(1); }
        else if (hp < 40 && GetAI()->GetManaPercent() >= 50) { ChangeForm(1); }
        else if (hp < 25 && GetAI()->GetManaPercent() >= 30) { ChangeForm(1); }
        else return false;
    }

    // if(m_bot->HasAura(TRAVEL_FORM)) ChangeForm(1);

    if(hp < 60 && m_bot->HasAura(NATURES_SWIFTNESS) && CastSpell(HEALING_TOUCH, target)) { return true; }
    if(hp < 90 && CastSpell(LIFEBLOOM, target)) { return true; }
    if(hp < 80 && CastSpell(REJUVENATION, target)) { return true; }
    if(hp < 60 && CastSpell(REGROWTH, target)) { return true; }
    if(hp < 70 && CanCast(NOURISH,target) &&
        (HasAuraName(target,REJUVENATION,m_bot->GetGUID()) || HasAuraName(target,LIFEBLOOM,m_bot->GetGUID()) || HasAuraName(target,REGROWTH,m_bot->GetGUID()))
        ) { return CastSpell(NOURISH, target, false); }
    if(hp < 50 && CanCast(SWIFTMEND,target) &&
        (HasAuraName(target,REJUVENATION,m_bot->GetGUID()) || HasAuraName(target,REGROWTH,m_bot->GetGUID()))
        ) { return CastSpell(SWIFTMEND, target, false); }
    if(hp < 40 && m_bot->isInCombat() && CastSpell(NATURES_SWIFTNESS, m_bot)) { } // NO gcd
    if(hp < 40 && CastSpell(HEALING_TOUCH, target)) { return true; }
    return false;
} //end HealTarget
示例#20
0
bool PlayerbotDruidAI::BuffPlayer(Unit *target)
{
    PlayerbotAI *ai = GetAI();
    Player *m_bot = GetPlayerBot();
    if (!m_bot || !ai || m_bot->isDead()) { return false; }

    if(!target || target->isDead()) { return false; }

    if (CanCast(THORNS,target,0,0,1) && !HasAuraName(target, THORNS)) {
        // Decide if it is worth to change form
        if( /*m_bot->HasAura(MOONKIN_FORM) ||*/ m_bot->HasAura(CAT_FORM) || m_bot->HasAura(BEAR_FORM))
        {
            if(GetAI()->GetManaPercent() >= 80 ) { ChangeForm(1); }
            else { return false; }
        }
        return CastSpell(THORNS, target, false);
    }
    if (CanCast(MARK_OF_THE_WILD,target,0,0,1) && !HasAuraName(target, GIFT_OF_THE_WILD) && !HasAuraName(target, MARK_OF_THE_WILD)) {
        // Decide if it is worth to change form
        if(/*m_bot->HasAura(MOONKIN_FORM) ||*/ m_bot->HasAura(CAT_FORM) || m_bot->HasAura(BEAR_FORM))
        {
            if(GetAI()->GetManaPercent() >= 70 ) { ChangeForm(1); }
            else return false;
        }
        return CastSpell(MARK_OF_THE_WILD, target, false);
    }
    return false;
}
示例#21
0
bool PlayerbotClassAI::DoSupportRaid(Player *gPlayer, float radius, bool dResurrect, bool dGroupHeal, bool dHeal, bool dCure, bool dBuff)
{
    bool needHeal = false;
    if (dGroupHeal || dHeal)
    {
        uint8 cntNeedHeal = 0;
        uint8 raidHPPercent = GetHealthPercentRaid(gPlayer, cntNeedHeal);
        if (dGroupHeal && raidHPPercent <=90 && cntNeedHeal > 1)
        {
            if (HealGroup(gPlayer, raidHPPercent, cntNeedHeal)) return true;
        }
        if (raidHPPercent < 60 ) needHeal = true;
    }
    //std::list<Unit*> unitList;
    //gPlayer->GetRaidMember(unitList,30);
    Group *pGroup = gPlayer->GetGroup();
    if (!pGroup) return false;
    for (GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next())
    {
        Unit* tPlayer = itr->getSource();
        if(!tPlayer || gPlayer->IsHostileTo(tPlayer)) continue;
        if(GetPlayerBot()->GetAreaId() != tPlayer->GetAreaId()) continue;
        if(!m_bot->IsWithinDistInMap(tPlayer, radius)) {
            continue;
        }
        if(tPlayer->isDead()) // May be we can rez
        {
            if(!dResurrect) continue;
            if(needHeal) continue; //First heal others needing heal
            if(tPlayer->GetGUID() == GetPlayerBot()->GetGUID()) continue;
            if(tPlayer->IsNonMeleeSpellCasted(true)) continue; //Already rez
            if(RezTarget(tPlayer)) {
                return true;
            }
            else continue;
        }
        if (dHeal)
        {
            uint8 tarHPPercent = tPlayer->GetHealth()*100 / tPlayer->GetMaxHealth();
            if (tarHPPercent < 100 && HealTarget(tPlayer, tarHPPercent)) return true;
        }
        if (needHeal && dHeal) continue; //First heal others needing heal
        if (dCure && CureTarget(tPlayer)) return true;
        if (dBuff && BuffPlayer(tPlayer)) return true;
    }
    return false;
}
示例#22
0
bool PlayerbotWarriorAI::DoCombatManeuver(Unit *pTarget, bool cac)
{
    PlayerbotAI* ai = GetAI();
    Player* m_bot = GetPlayerBot();
    Player* m_master = ai->GetLeader();

    switch (m_bot->getRole())
    {
        case WarriorArms:
        {
            static const uint32 SpellArms[] = {BLOODTHIRST, WHIRLWIND, BLOODTHIRST, BLOODTHIRST, CLEAVE,
                WHIRLWIND, BLOODTHIRST, BLOODTHIRST, WHIRLWIND, BLOODTHIRST, HEROIC_STRIKE};
            static uint32 elt = sizeof(SpellArms)/sizeof(uint32);

            for (uint32 i = 1; i <= elt; ++i)
            {
                if (ai->CastSpell(SpellArms[(i+LastSpellArms)%elt], pTarget))
                {
                    LastSpellArms = (i+LastSpellArms)%elt;
                    return true;
                }
            }
            break;
        }
        case WarriorProtection:
        {
            static const uint32 SpellProtection[] = {CHARGE, REND, THUNDER_CLAP, CLEAVE, SHOCKWAVE,
                SUNDER_ARMOR, HEROIC_STRIKE, DEVASTATE, SHIELD_SLAM, REVENGE};
            static uint32 elt = sizeof(SpellProtection)/sizeof(uint32);

            for (uint32 i = 1; i <= elt; ++i)
            {
                if (ai->CastSpell(SpellProtection[(i+LastSpellProtection)%elt], pTarget))
                {
                    LastSpellProtection = (i+LastSpellProtection)%elt;
                    return true;
                }
            }
            break;
        }
        case WarriorFury:
        {
            static const uint32 SpellFury[] = {BLOODTHIRST, WHIRLWIND, BLOODTHIRST, BLOODTHIRST, CLEAVE,
                WHIRLWIND, BLOODTHIRST, BLOODTHIRST, WHIRLWIND, BLOODTHIRST, HEROIC_STRIKE};
            static uint32 elt = sizeof(SpellFury)/sizeof(uint32);

            for (uint32 i = 1; i <= elt; ++i)
            {
                if (ai->CastSpell(SpellFury[(i+LastSpellFury)%elt], pTarget))
                {
                    LastSpellFury = (i+LastSpellFury)%elt;
                    return true;
                }
            }
            break;
        }
    }
    return false;
}
void PlayerbotDeathKnightAI::Pull()
{
    Unit* pTarget = ObjectAccessor::GetUnit(*GetMaster(), GetMaster()->GetSelection());
    if (pTarget==NULL || pTarget->IsFriendlyTo(GetMaster()))
    {
        GetPlayerBot()->Say("Invalid target", LANGUAGE_UNIVERSAL);
        m_pulling = false;
        GetAI()->Follow(*GetMaster());
        return;
    }

    m_role = BOT_ROLE_DPS_RANGED;
    m_pulling = true;
    GetAI()->SetIgnoreUpdateTime(0);

    if (GetPlayerBot()->GetPet()) GetPlayerBot()->GetPet()->SetReactState (REACT_PASSIVE);
}
bool PlayerbotMageAI::CureTarget(Unit *target)
{
	//Cures the target
    Player *m_bot = GetPlayerBot();

    if(!target || target->isDead()) { return false; }
    if (castDispel(DISPEL_CURSE, target)) return true;
    return false;
}
示例#25
0
bool PlayerbotHunterAI::DoProtectSelfAction()
{
    PlayerbotAI *ai = GetAI();
    Player *m_bot = GetPlayerBot();

    if (ai->CastAura(DETERRENCE, m_bot))
        return true;

    return false;
}
示例#26
0
bool PlayerbotShamanAI::CureTarget(Unit *target)
//Cures the target
{
    Player *m_bot = GetPlayerBot();

    if(!target || target->isDead()) { return false; }
    if (castDispel(CLEANSE_SPIRIT, target)) return true;

    return false;
}
示例#27
0
void PlayerbotMgr::LogoutPlayerBot(uint64 guid)
{
    Player* bot = GetPlayerBot(guid);
    if (bot)
    {
        WorldSession * botWorldSessionPtr = bot->GetSession();
        botWorldSessionPtr->LogoutPlayer(true);
        delete botWorldSessionPtr;
    }
}
示例#28
0
bool PlayerbotHunterAI::DoEvadeAction()
{
    PlayerbotAI *ai = GetAI();
    Player *m_bot = GetPlayerBot();

    if (ai->CastAura(FEIGN_DEATH, m_bot))
        return true;

    return false;
}
void PlayerbotWarriorAI::DoNonCombatActions()
{
    PlayerbotAI *ai = GetAI();
    Player * m_bot = GetPlayerBot();
    if (!m_bot)
        return;

    // TODO (by Runsttren): check if shout aura bot has is casted by this bot,
    // otherwise cast other useful shout
    // If the bot is protect talented, she/he needs stamina not attack power.
    // With stance change can the shout change to.
    // Inserted line to battle shout m_bot->HasAura( COMMANDING_SHOUT, EFFECT_INDEX_0)
    // Natsukawa
    if (((COMMANDING_SHOUT > 0 && !m_bot->HasAura(COMMANDING_SHOUT, EFFECT_INDEX_0)) ||
         (BATTLE_SHOUT > 0 && !m_bot->HasAura(BATTLE_SHOUT, EFFECT_INDEX_0))) &&
        ai->GetRageAmount() < 10 && BLOODRAGE > 0 && !m_bot->HasAura(BLOODRAGE, EFFECT_INDEX_0))
        // we do have a useful shout, no rage coming but can cast bloodrage... do it
        ai->CastSpell(BLOODRAGE, *m_bot);
    else if (COMMANDING_SHOUT > 0 && !m_bot->HasAura(COMMANDING_SHOUT, EFFECT_INDEX_0))
        // use commanding shout now
        ai->CastSpell(COMMANDING_SHOUT, *m_bot);
    else if (BATTLE_SHOUT > 0 && !m_bot->HasAura(BATTLE_SHOUT, EFFECT_INDEX_0) && !m_bot->HasAura(COMMANDING_SHOUT, EFFECT_INDEX_0))
        // use battle shout
        ai->CastSpell(BATTLE_SHOUT, *m_bot);

    // buff master with VIGILANCE
    if (VIGILANCE > 0)
        (!GetMaster()->HasAura(VIGILANCE, EFFECT_INDEX_0) && ai->CastSpell(VIGILANCE, *GetMaster()));

    // hp check
    if (m_bot->getStandState() != UNIT_STAND_STATE_STAND)
        m_bot->SetStandState(UNIT_STAND_STATE_STAND);

    Item* pItem = ai->FindFood();
    Item* fItem = ai->FindBandage();

    if (pItem != NULL && ai->GetHealthPercent() < 30)
    {
        ai->TellMaster("I could use some food.");
        ai->UseItem(pItem);
        return;
    }
    else if (pItem == NULL && fItem != NULL && !m_bot->HasAura(RECENTLY_BANDAGED, EFFECT_INDEX_0) && ai->GetHealthPercent() < 70)
    {
        ai->TellMaster("I could use first aid.");
        ai->UseItem(fItem);
        return;
    }
    else if (pItem == NULL && fItem == NULL && m_bot->getRace() == RACE_DRAENEI && !m_bot->HasAura(GIFT_OF_THE_NAARU, EFFECT_INDEX_0) && ai->GetHealthPercent() < 70)
    {
        ai->TellMaster("I'm casting gift of the naaru.");
        ai->CastSpell(GIFT_OF_THE_NAARU, *m_bot);
        return;
    }
} // end DoNonCombatActions
示例#30
0
void PlayerbotDruidAI::_DoNextPVECombatManeuverHeal(Unit* pTarget)
{
    PlayerbotAI* ai = GetAI();
    if (!ai)
        return;

    uint32 masterHP = GetMaster()->GetHealth() * 100 / GetMaster()->GetMaxHealth();

    Player *m_bot = GetPlayerBot();
    Unit* pVictim = pTarget->getVictim();

    if (TREE_OF_LIFE > 0 && !m_bot->HasAura(TREE_OF_LIFE, EFFECT_INDEX_0))
        ai->CastSpell(TREE_OF_LIFE, *m_bot);

    if (m_bot->HasAura(CAT_FORM, EFFECT_INDEX_0))
    {
        m_bot->RemoveAurasDueToSpell(CAT_FORM_1);
        //ai->TellMaster("FormClearCat");
        return;
    }
    if (m_bot->HasAura(BEAR_FORM, EFFECT_INDEX_0))
    {
        m_bot->RemoveAurasDueToSpell(BEAR_FORM_1);
        //ai->TellMaster("FormClearBear");
        return;
    }
    if (m_bot->HasAura(DIRE_BEAR_FORM, EFFECT_INDEX_0))
    {
        m_bot->RemoveAurasDueToSpell(DIRE_BEAR_FORM_1);
        //ai->TellMaster("FormClearDireBear");
        return;
    }
    // spellcasting form, but disables healing spells so it's got to go
    if (m_bot->HasAura(MOONKIN_FORM, EFFECT_INDEX_0))
    {
        m_bot->RemoveAurasDueToSpell(MOONKIN_FORM_1);
        //ai->TellMaster("FormClearMoonkin");
        return;
    }

    if (ai->GetHealthPercent() <= 60)
    {
        HealTarget(m_bot);
        return;
    }
    if (masterHP <= 50)
    {
        HealTarget(GetMaster());
        return;
    }
    // TODO: err... what about the other teammates?

    DruidSpellCombat = 0;
}