diff --git a/src/PlayerbotFactory.cpp b/src/PlayerbotFactory.cpp index c961e8d6..9f6658f4 100644 --- a/src/PlayerbotFactory.cpp +++ b/src/PlayerbotFactory.cpp @@ -332,6 +332,7 @@ void PlayerbotFactory::Randomize(bool incremental) pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Pet"); LOG_INFO("playerbots", "Initializing pet..."); InitPet(); + InitPetTalents(); if (pmo) pmo->finish(); } @@ -516,6 +517,67 @@ void PlayerbotFactory::AddConsumables() } } +void PlayerbotFactory::InitPetTalents() +{ + Pet* pet = bot->GetPet(); + if (!pet) { + return; + } + CreatureTemplate const* ci = pet->GetCreatureTemplate(); + if (!ci) { + return; + } + CreatureFamilyEntry const* pet_family = sCreatureFamilyStore.LookupEntry(ci->family); + if (pet_family->petTalentType < 0) { + return; + } + std::map > spells; + for (uint32 i = 0; i < sTalentStore.GetNumRows(); ++i) + { + TalentEntry const *talentInfo = sTalentStore.LookupEntry(i); + if(!talentInfo) + continue; + + TalentTabEntry const *talentTabInfo = sTalentTabStore.LookupEntry( talentInfo->TalentTab ); + + // prevent learn talent for different family (cheating) + if (!((1 << pet_family->petTalentType) & talentTabInfo->petTalentMask)) + return; + + spells[talentInfo->Row].push_back(talentInfo); + } + + uint32 curTalentPoints = pet->GetFreeTalentPoints(); + uint32 maxTalentPoints = pet->GetMaxTalentPointsForLevel(pet->GetLevel()); + int row = -1; + for (std::map >::iterator i = spells.begin(); i != spells.end(); ++i, ++row) + { + std::vector &spells_row = i->second; + if (spells_row.empty()) + { + sLog->outMessage("playerbot", LOG_LEVEL_ERROR, "%s: No spells for talent row %d", bot->GetName().c_str(), i->first); + continue; + } + int attemptCount = 0; + while (!spells_row.empty() && ((int)maxTalentPoints - (int)pet->GetFreeTalentPoints()) < 3 * row && attemptCount++ < 3 && pet->GetFreeTalentPoints()) + { + int index = urand(0, spells_row.size() - 1); + TalentEntry const *talentInfo = spells_row[index]; + int maxRank = 0; + for (int rank = 0; rank < std::min((uint32)MAX_TALENT_RANK, (uint32)pet->GetFreeTalentPoints()); ++rank) + { + uint32 spellId = talentInfo->RankID[rank]; + if (!spellId) + continue; + + maxRank = rank; + } + bot->LearnPetTalent(pet->GetGUID(), talentInfo->TalentID, maxRank); + spells_row.erase(spells_row.begin() + index); + } + } +} + void PlayerbotFactory::InitPet() { Pet* pet = bot->GetPet(); @@ -538,7 +600,7 @@ void PlayerbotFactory::InitPet() if (itr->second.minlevel > bot->getLevel()) continue; - + ids.push_back(itr->first); } diff --git a/src/PlayerbotFactory.h b/src/PlayerbotFactory.h index e699c3ab..f8bf8360 100644 --- a/src/PlayerbotFactory.h +++ b/src/PlayerbotFactory.h @@ -122,6 +122,7 @@ class PlayerbotFactory : public InventoryAction void InitPet(); void InitAmmo(); static uint32 CalcMixedGearScore(uint32 gs, uint32 quality); + void InitPetTalents(); private: void Prepare(); // void InitSecondEquipmentSet(); diff --git a/src/strategy/mage/GenericMageStrategy.cpp b/src/strategy/mage/GenericMageStrategy.cpp index e238e703..f05b7a81 100644 --- a/src/strategy/mage/GenericMageStrategy.cpp +++ b/src/strategy/mage/GenericMageStrategy.cpp @@ -152,8 +152,8 @@ void MageBoostStrategy::InitTriggers(std::vector& triggers) { triggers.push_back(new TriggerNode("icy veins", NextAction::array(0, new NextAction("icy veins", 50.0f), nullptr))); triggers.push_back(new TriggerNode("presence of mind", NextAction::array(0, new NextAction("presence of mind", 42.0f), nullptr))); - triggers.push_back(new TriggerNode("arcane power", NextAction::array(0, new NextAction("arcane power", 41.0f), nullptr))); - triggers.push_back(new TriggerNode("mirror image", NextAction::array(0, new NextAction("mirror image", 41.0f), nullptr))); + // triggers.push_back(new TriggerNode("arcane power", NextAction::array(0, new NextAction("arcane power", 41.0f), nullptr))); + // triggers.push_back(new TriggerNode("mirror image", NextAction::array(0, new NextAction("mirror image", 41.0f), nullptr))); } void MageCcStrategy::InitTriggers(std::vector& triggers)