diff --git a/src/AiFactory.cpp b/src/AiFactory.cpp index 1781a272..0860c59b 100644 --- a/src/AiFactory.cpp +++ b/src/AiFactory.cpp @@ -600,7 +600,7 @@ void AiFactory::AddDefaultNonCombatStrategies(Player* player, PlayerbotAI* const nonCombatEngine->ChangeStrategy(sPlayerbotAIConfig->randomBotNonCombatStrategies); } else { - // nonCombatEngine->addStrategy("pvp"); + nonCombatEngine->addStrategy("pvp"); nonCombatEngine->ChangeStrategy(sPlayerbotAIConfig->nonCombatStrategies); } } diff --git a/src/PlayerbotFactory.cpp b/src/PlayerbotFactory.cpp index bea21609..0e907336 100644 --- a/src/PlayerbotFactory.cpp +++ b/src/PlayerbotFactory.cpp @@ -97,9 +97,11 @@ void PlayerbotFactory::Prepare() bot->ResurrectPlayer(1.0f, false); bot->CombatStop(true); - + uint32 currentLevel = bot->GetLevel(); bot->GiveLevel(level); - bot->SetUInt32Value(PLAYER_XP, 0); + if (level != currentLevel) { + bot->SetUInt32Value(PLAYER_XP, 0); + } if (!sPlayerbotAIConfig->randomBotShowHelmet || !urand(0, 4)) { bot->SetFlag(PLAYER_FLAGS, PLAYER_FLAGS_HIDE_HELM); @@ -158,6 +160,7 @@ void PlayerbotFactory::Randomize(bool incremental) if (sPlayerbotAIConfig->randomBotPreQuests) { + uint32 currentXP = bot->GetUInt32Value(PLAYER_XP); LOG_INFO("playerbots", "Initializing quests..."); pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Quests"); InitQuests(classQuestIds); @@ -169,7 +172,7 @@ void PlayerbotFactory::Randomize(bool incremental) ClearInventory(); - bot->SetUInt32Value(PLAYER_XP, 0); + bot->SetUInt32Value(PLAYER_XP, currentXP); CancelAuras(); bot->SaveToDB(false, false); if (pmo) diff --git a/src/RandomPlayerbotMgr.cpp b/src/RandomPlayerbotMgr.cpp index 28cd3fc2..55a884ce 100644 --- a/src/RandomPlayerbotMgr.cpp +++ b/src/RandomPlayerbotMgr.cpp @@ -1329,7 +1329,10 @@ void RandomPlayerbotMgr::Randomize(Player* bot) RandomizeFirst(bot); } else if (bot->getLevel() < sPlayerbotAIConfig->randomBotMaxLevel || !sPlayerbotAIConfig->downgradeMaxLevelBot) { - IncreaseLevel(bot); + uint8 level = bot->getLevel(); + PlayerbotFactory factory(bot, level); + factory.Randomize(true); + // IncreaseLevel(bot); } else { RandomizeFirst(bot); diff --git a/src/strategy/actions/FollowActions.cpp b/src/strategy/actions/FollowActions.cpp index a5018fd2..28fee92a 100644 --- a/src/strategy/actions/FollowActions.cpp +++ b/src/strategy/actions/FollowActions.cpp @@ -56,6 +56,9 @@ bool FollowAction::isUseful() return false; } Formation* formation = AI_VALUE(Formation*, "formation"); + if (!formation) { + return false; + } std::string const target = formation->GetTargetName(); Unit* fTarget = nullptr; diff --git a/src/strategy/actions/UseItemAction.cpp b/src/strategy/actions/UseItemAction.cpp index 906cfa8b..1c50c7c0 100644 --- a/src/strategy/actions/UseItemAction.cpp +++ b/src/strategy/actions/UseItemAction.cpp @@ -86,7 +86,9 @@ bool UseItemAction::UseItem(Item* item, ObjectGuid goGuid, Item* itemTarget, Uni if (item->GetTemplate()->Spells[i].SpellId > 0) { spellId = item->GetTemplate()->Spells[i].SpellId; - break; + if (!botAI->CanCastSpell(spellId, bot, false, item)) { + return false; + } } } @@ -195,7 +197,7 @@ bool UseItemAction::UseItem(Item* item, ObjectGuid goGuid, Item* itemTarget, Uni for (uint8 i = 0; i < MAX_ITEM_PROTO_SPELLS; i++) { - spellId = item->GetTemplate()->Spells[i].SpellId; + uint32 spellId = item->GetTemplate()->Spells[i].SpellId; if (!spellId) continue; diff --git a/src/strategy/druid/GenericDruidNonCombatStrategy.cpp b/src/strategy/druid/GenericDruidNonCombatStrategy.cpp index ef24811a..172776f7 100644 --- a/src/strategy/druid/GenericDruidNonCombatStrategy.cpp +++ b/src/strategy/druid/GenericDruidNonCombatStrategy.cpp @@ -19,6 +19,7 @@ class GenericDruidNonCombatStrategyActionNodeFactory : public NamedObjectFactory creators["rejuvenation on party"] = &rejuvenation_on_party; creators["remove curse on party"] = &remove_curse_on_party; creators["abolish poison on party"] = &abolish_poison_on_party; + creators["revive"] = &revive; } private: @@ -81,6 +82,13 @@ class GenericDruidNonCombatStrategyActionNodeFactory : public NamedObjectFactory /*A*/ NULL, /*C*/ NULL); } + static ActionNode* revive(PlayerbotAI* ai) + { + return new ActionNode ("revive", + /*P*/ NextAction::array(0, new NextAction("caster form"), nullptr), + /*A*/ NULL, + /*C*/ NULL); + } // static ActionNode* innervate([[maybe_unused]] PlayerbotAI* botAI) // { // return new ActionNode ("innervate",