mirror of
https://github.com/mod-playerbots/mod-playerbots
synced 2025-11-29 15:58:20 +08:00
Fix unique equip init and bots login
This commit is contained in:
@@ -370,7 +370,7 @@ void RandomPlayerbotMgr::UpdateAIInternal(uint32 elapsed, bool /*minimal*/)
|
||||
break;
|
||||
}
|
||||
|
||||
if (loginBots)
|
||||
if (loginBots && botLoading.empty())
|
||||
{
|
||||
loginBots += updateBots;
|
||||
loginBots = std::min(loginBots, maxNewBots);
|
||||
@@ -1041,6 +1041,9 @@ bool RandomPlayerbotMgr::ProcessBot(uint32 bot)
|
||||
|
||||
SetEventValue(bot, "login", 0, 0);
|
||||
|
||||
if (!player->IsInWorld())
|
||||
return false;
|
||||
|
||||
if (player->GetGroup() || player->HasUnitState(UNIT_STATE_IN_FLIGHT))
|
||||
return false;
|
||||
|
||||
|
||||
@@ -235,6 +235,7 @@ void PlayerbotFactory::Randomize(bool incremental)
|
||||
pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Spells1");
|
||||
LOG_DEBUG("playerbots", "Initializing spells (step 1)...");
|
||||
// bot->LearnDefaultSkills();
|
||||
bot->LearnDefaultSkills();
|
||||
InitClassSpells();
|
||||
InitAvailableSpells();
|
||||
if (pmo)
|
||||
@@ -425,7 +426,10 @@ void PlayerbotFactory::Refresh()
|
||||
InitFood();
|
||||
InitReagents();
|
||||
// InitPotions();
|
||||
if (!sPlayerbotAIConfig->equipmentPersistence || bot->GetLevel() < sPlayerbotAIConfig->equipmentPersistenceLevel)
|
||||
{
|
||||
InitTalentsTree(true, true, true);
|
||||
}
|
||||
InitPet();
|
||||
InitPetTalents();
|
||||
InitClassSpells();
|
||||
@@ -885,7 +889,7 @@ void PlayerbotFactory::ClearEverything()
|
||||
ClearSpells();
|
||||
ClearInventory();
|
||||
ResetQuests();
|
||||
bot->SaveToDB(false, false);
|
||||
// bot->SaveToDB(false, false);
|
||||
}
|
||||
|
||||
void PlayerbotFactory::ClearSpells()
|
||||
@@ -1616,7 +1620,7 @@ void PlayerbotFactory::InitEquipment(bool incremental, bool second_chance)
|
||||
|
||||
if (proto->Quality != desiredQuality)
|
||||
continue;
|
||||
|
||||
// delay heavy check
|
||||
// if (!CanEquipItem(proto))
|
||||
// continue;
|
||||
|
||||
@@ -1634,7 +1638,7 @@ void PlayerbotFactory::InitEquipment(bool incremental, bool second_chance)
|
||||
if (slot == EQUIPMENT_SLOT_OFFHAND && bot->getClass() == CLASS_ROGUE &&
|
||||
proto->Class != ITEM_CLASS_WEAPON)
|
||||
continue;
|
||||
|
||||
// delay heavy check
|
||||
// uint16 dest = 0;
|
||||
// if (CanEquipUnseenItem(slot, dest, itemId))
|
||||
items[slot].push_back(itemId);
|
||||
@@ -1690,6 +1694,7 @@ void PlayerbotFactory::InitEquipment(bool incremental, bool second_chance)
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (oldItem)
|
||||
{
|
||||
uint8 bagIndex = oldItem->GetBagSlot();
|
||||
@@ -1701,13 +1706,18 @@ void PlayerbotFactory::InitEquipment(bool incremental, bool second_chance)
|
||||
bot->GetSession()->HandleAutoStoreBagItemOpcode(packet);
|
||||
}
|
||||
|
||||
oldItem = bot->GetItemByPos(INVENTORY_SLOT_BAG_0, slot);
|
||||
// fail to store in bag
|
||||
if (oldItem)
|
||||
continue;
|
||||
|
||||
Item* newItem = bot->EquipNewItem(dest, bestItemForSlot, true);
|
||||
bot->AutoUnequipOffhandIfNeed();
|
||||
if (newItem)
|
||||
{
|
||||
newItem->AddToWorld();
|
||||
newItem->AddToUpdateQueueOf(bot);
|
||||
}
|
||||
// if (newItem)
|
||||
// {
|
||||
// newItem->AddToWorld();
|
||||
// newItem->AddToUpdateQueueOf(bot);
|
||||
// }
|
||||
}
|
||||
// Secondary init for better equips
|
||||
/// @todo: clean up duplicate code
|
||||
@@ -1770,11 +1780,11 @@ void PlayerbotFactory::InitEquipment(bool incremental, bool second_chance)
|
||||
}
|
||||
Item* newItem = bot->EquipNewItem(dest, bestItemForSlot, true);
|
||||
bot->AutoUnequipOffhandIfNeed();
|
||||
if (newItem)
|
||||
{
|
||||
newItem->AddToWorld();
|
||||
newItem->AddToUpdateQueueOf(bot);
|
||||
}
|
||||
// if (newItem)
|
||||
// {
|
||||
// newItem->AddToWorld();
|
||||
// newItem->AddToUpdateQueueOf(bot);
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2305,8 +2315,6 @@ void PlayerbotFactory::SetRandomSkill(uint16 id)
|
||||
|
||||
void PlayerbotFactory::InitAvailableSpells()
|
||||
{
|
||||
bot->LearnDefaultSkills();
|
||||
|
||||
if (trainerIdCache.empty())
|
||||
{
|
||||
CreatureTemplateContainer const* creatureTemplateContainer = sObjectMgr->GetCreatureTemplates();
|
||||
@@ -2324,7 +2332,8 @@ void PlayerbotFactory::InitAvailableSpells()
|
||||
trainerIdCache.push_back(trainerId);
|
||||
}
|
||||
}
|
||||
uint32 learnedCounter = 0;
|
||||
// uint32 learnedCounter = 0;
|
||||
// uint32 oktest = 0;
|
||||
for (uint32 trainerId : trainerIdCache)
|
||||
{
|
||||
TrainerSpellData const* trainer_spells = sObjectMgr->GetNpcTrainerSpells(trainerId);
|
||||
@@ -2368,6 +2377,7 @@ void PlayerbotFactory::InitAvailableSpells()
|
||||
{
|
||||
continue;
|
||||
}
|
||||
// oktest++;
|
||||
if (tSpell->learnedSpell[0])
|
||||
{
|
||||
bot->learnSpell(tSpell->learnedSpell[0], false);
|
||||
@@ -2377,8 +2387,9 @@ void PlayerbotFactory::InitAvailableSpells()
|
||||
botAI->CastSpell(tSpell->spell, bot);
|
||||
}
|
||||
}
|
||||
if (++learnedCounter > 20)
|
||||
break;
|
||||
// LOG_INFO("playerbots", "C: {}, ok: {}", ++learnedCounter, oktest);
|
||||
// if (++learnedCounter > 20)
|
||||
// break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,13 +11,13 @@
|
||||
std::map<uint32, SkillLineAbilityEntry const*> ListSpellsAction::skillSpells;
|
||||
std::set<uint32> ListSpellsAction::vendorItems;
|
||||
|
||||
bool CompareSpells(std::pair<uint32, std::string>& s1, std::pair<uint32, std::string>& s2)
|
||||
bool CompareSpells(const std::pair<uint32, std::string>& s1, const std::pair<uint32, std::string>& s2)
|
||||
{
|
||||
SpellInfo const* si1 = sSpellMgr->GetSpellInfo(s1.first);
|
||||
SpellInfo const* si2 = sSpellMgr->GetSpellInfo(s2.first);
|
||||
if (!si1 || !si2)
|
||||
{
|
||||
LOG_ERROR("playerbots", "SpellInfo missing.");
|
||||
LOG_ERROR("playerbots", "SpellInfo missing. {} {}", s1.first, s2.first);
|
||||
return false;
|
||||
}
|
||||
uint32 p1 = si1->SchoolMask * 20000;
|
||||
@@ -54,7 +54,7 @@ bool CompareSpells(std::pair<uint32, std::string>& s1, std::pair<uint32, std::st
|
||||
|
||||
if (p1 == p2)
|
||||
{
|
||||
return strcmp(si1->SpellName[0], si1->SpellName[1]) > 0;
|
||||
return strcmp(si1->SpellName[0], si2->SpellName[0]) > 0;
|
||||
}
|
||||
|
||||
return p1 > p2;
|
||||
@@ -274,6 +274,10 @@ std::vector<std::pair<uint32, std::string>> ListSpellsAction::GetSpellList(std::
|
||||
if (out.str().empty())
|
||||
continue;
|
||||
|
||||
if (itr->first == 0)
|
||||
{
|
||||
LOG_ERROR("playerbots", "?! {}", itr->first);
|
||||
}
|
||||
spells.push_back(std::pair<uint32, std::string>(itr->first, out.str()));
|
||||
alreadySeenList += spellInfo->SpellName[0];
|
||||
alreadySeenList += ",";
|
||||
|
||||
Reference in New Issue
Block a user