diff --git a/src/PlayerbotFactory.cpp b/src/PlayerbotFactory.cpp index aebf53ee..5699f0ca 100644 --- a/src/PlayerbotFactory.cpp +++ b/src/PlayerbotFactory.cpp @@ -98,7 +98,7 @@ void PlayerbotFactory::Prepare() if (!sPlayerbotAIConfig->disableRandomLevels) { - bot->SetLevel(level); + bot->GiveLevel(level); } else if (bot->getLevel() < sPlayerbotAIConfig->randombotStartingLevel) { @@ -125,7 +125,7 @@ void PlayerbotFactory::Randomize(bool incremental) LOG_INFO("playerbots", "Preparing to {} randomize...", (incremental ? "incremental" : "full")); Prepare(); - + bot->SaveToDB(false, false); LOG_INFO("playerbots", "Resetting player..."); PerformanceMonitorOperation* pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Reset"); bot->resetTalents(true); @@ -143,6 +143,8 @@ void PlayerbotFactory::Randomize(bool incremental) if (pmo) pmo->finish(); + bot->resetTalents(true); + bot->SaveToDB(false, false); /* pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Immersive"); LOG_INFO("playerbots", "Initializing immersive..."); @@ -178,7 +180,7 @@ void PlayerbotFactory::Randomize(bool incremental) pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Spells1"); LOG_INFO("playerbots", "Initializing spells (step 1)..."); - // InitClassSpells(); + InitClassSpells(); InitAvailableSpells(); if (pmo) pmo->finish(); @@ -1344,44 +1346,19 @@ void PlayerbotFactory::InitSecondEquipmentSet() void PlayerbotFactory::InitBags() { - std::vector ids; - - ItemTemplateContainer const* itemTemplates = sObjectMgr->GetItemTemplateStore(); - for (auto const& itr : *itemTemplates) - { - ItemTemplate const* proto = &itr.second; - if (!proto || proto->Class != ITEM_CLASS_CONTAINER) - continue; - - if (!CanEquipItem(proto, ITEM_QUALITY_NORMAL)) - continue; - - ids.push_back(itr.first); - } - - if (ids.empty()) - { - LOG_ERROR("playerbots", "{}: no bags found", bot->GetName().c_str()); - return; - } - for (uint8 slot = INVENTORY_SLOT_BAG_START; slot < INVENTORY_SLOT_BAG_END; ++slot) { - for (uint32 attempts = 0; attempts < 15; attempts++) + uint32 newItemId = 23162; + + uint16 dest; + if (!CanEquipUnseenItem(slot, dest, newItemId)) + continue; + + Item* newItem = bot->EquipNewItem(dest, newItemId, true); + if (newItem) { - uint32 index = urand(0, ids.size() - 1); - uint32 newItemId = ids[index]; - - uint16 dest; - if (!CanEquipUnseenItem(slot, dest, newItemId)) - continue; - - if (Item* newItem = bot->EquipNewItem(dest, newItemId, true)) - { - newItem->AddToWorld(); - newItem->AddToUpdateQueueOf(bot); - break; - } + newItem->AddToWorld(); + newItem->AddToUpdateQueueOf(bot); } } } @@ -1791,8 +1768,8 @@ void PlayerbotFactory::InitAvailableSpells() bot->learnSpell(tSpell->spell); } } - if (bot->IsSpellFitByClassAndRace(20271) && !bot->HasSpell(20271)) // judgement missing - bot->learnSpell(20271, false); + // if (bot->IsSpellFitByClassAndRace(20271) && !bot->HasSpell(20271)) // judgement missing + // bot->learnSpell(20271, false); } void PlayerbotFactory::InitClassSpells() diff --git a/src/RandomPlayerbotMgr.cpp b/src/RandomPlayerbotMgr.cpp index d1cda297..070a9471 100644 --- a/src/RandomPlayerbotMgr.cpp +++ b/src/RandomPlayerbotMgr.cpp @@ -1525,7 +1525,7 @@ std::string const RandomPlayerbotMgr::GetEventData(uint32 bot, std::string const data = e.data; } - return std::move(data); + return data; } uint32 RandomPlayerbotMgr::SetEventValue(uint32 bot, std::string const event, uint32 value, uint32 validIn, std::string const data) diff --git a/src/Talentspec.h b/src/Talentspec.h index 1e160716..421a8e48 100644 --- a/src/Talentspec.h +++ b/src/Talentspec.h @@ -32,6 +32,7 @@ class TalentSpec }; TalentSpec() { }; + virtual ~TalentSpec() { } TalentSpec(uint32 classMask); TalentSpec(TalentSpec* base, std::string const link); TalentSpec(Player* bot); diff --git a/src/strategy/ItemVisitors.cpp b/src/strategy/ItemVisitors.cpp index 4aabbd88..a989bdac 100644 --- a/src/strategy/ItemVisitors.cpp +++ b/src/strategy/ItemVisitors.cpp @@ -85,3 +85,8 @@ bool FindItemUsageVisitor::Accept(ItemTemplate const* proto) return false; } + +bool FindUsableNamedItemVisitor::Accept(ItemTemplate const* proto) +{ + return true; +} \ No newline at end of file diff --git a/src/strategy/ItemVisitors.h b/src/strategy/ItemVisitors.h index 6a981aac..9026d19c 100644 --- a/src/strategy/ItemVisitors.h +++ b/src/strategy/ItemVisitors.h @@ -411,4 +411,12 @@ class FindItemUsageVisitor : public FindUsableItemVisitor ItemUsage usage; }; +class FindUsableNamedItemVisitor : public FindUsableItemVisitor +{ + public: + FindUsableNamedItemVisitor(Player* bot): FindUsableItemVisitor(bot) {} + + bool Accept(ItemTemplate const* proto) override; + +}; #endif diff --git a/src/strategy/Value.h b/src/strategy/Value.h index 0fc1c3c9..bff21d09 100644 --- a/src/strategy/Value.h +++ b/src/strategy/Value.h @@ -20,6 +20,7 @@ class UntypedValue : public AiNamedObject { public: UntypedValue(PlayerbotAI* botAI, std::string const name) : AiNamedObject(botAI, name) { } + virtual ~UntypedValue() { } virtual void Update() { } virtual void Reset() { } virtual std::string const Format() { return "?"; } diff --git a/src/strategy/actions/BattleGroundJoinAction.h b/src/strategy/actions/BattleGroundJoinAction.h index a34ff162..33285857 100644 --- a/src/strategy/actions/BattleGroundJoinAction.h +++ b/src/strategy/actions/BattleGroundJoinAction.h @@ -43,7 +43,7 @@ class FreeBGJoinAction : public BGJoinAction class BGLeaveAction : public Action { public: - BGLeaveAction(PlayerbotAI* botAI, std::string const name = "bg leave") : Action(botAI) { } + BGLeaveAction(PlayerbotAI* botAI, std::string const name = "bg leave") : Action(botAI, name) { } bool Execute(Event event) override; }; diff --git a/src/strategy/actions/InventoryAction.cpp b/src/strategy/actions/InventoryAction.cpp index 6c70871e..cf974216 100644 --- a/src/strategy/actions/InventoryAction.cpp +++ b/src/strategy/actions/InventoryAction.cpp @@ -282,6 +282,10 @@ std::vector InventoryAction::parseItems(std::string const text, IterateIt IterateItems(&visitor, ITERATE_ITEMS_IN_BAGS); found.insert(visitor.GetResult().begin(), visitor.GetResult().end()); } + + FindUsableNamedItemVisitor visitor(bot); + IterateItems(&visitor, ITERATE_ITEMS_IN_BAGS); + found.insert(visitor.GetResult().begin(), visitor.GetResult().end()); uint32 quality = chat->parseItemQuality(text); if (quality != MAX_ITEM_QUALITY) diff --git a/src/strategy/generic/GrindingStrategy.h b/src/strategy/generic/GrindingStrategy.h index c4a06158..ba5228d8 100644 --- a/src/strategy/generic/GrindingStrategy.h +++ b/src/strategy/generic/GrindingStrategy.h @@ -16,7 +16,7 @@ class GrindingStrategy : public NonCombatStrategy std::string const getName() override { return "grind"; } uint32 GetType() const override { return STRATEGY_TYPE_DPS; } - NextAction** getDefaultActions(); + NextAction** getDefaultActions() override; void InitTriggers(std::vector& triggers) override; }; diff --git a/src/strategy/generic/GuardStrategy.h b/src/strategy/generic/GuardStrategy.h index 5d43f0f4..923dc4ea 100644 --- a/src/strategy/generic/GuardStrategy.h +++ b/src/strategy/generic/GuardStrategy.h @@ -15,7 +15,7 @@ class GuardStrategy : public NonCombatStrategy GuardStrategy(PlayerbotAI* botAI) : NonCombatStrategy(botAI) { } std::string const getName() override { return "guard"; } - NextAction** getDefaultActions(); + NextAction** getDefaultActions() override; void InitTriggers(std::vector& triggers) override; };