diff --git a/src/PlayerbotAI.cpp b/src/PlayerbotAI.cpp index 76cac833..daa276f1 100644 --- a/src/PlayerbotAI.cpp +++ b/src/PlayerbotAI.cpp @@ -239,6 +239,9 @@ void PlayerbotAI::UpdateAI(uint32 elapsed, bool minimal) // check activity AllowActivity(); + if (bot->GetCurrentSpell(CURRENT_CHANNELED_SPELL)) { + return; + } Spell* currentSpell = bot->GetCurrentSpell(CURRENT_GENERIC_SPELL); if (currentSpell && currentSpell->getState() == SPELL_STATE_CASTING && currentSpell->GetCastTime()) { @@ -448,7 +451,7 @@ void PlayerbotAI::Reset(bool full) aiObjectContext->GetValue("ignore rpg target")->Get().clear(); bot->GetMotionMaster()->Clear(); - bot->CleanupAfterTaxiFlight(); + // bot->CleanupAfterTaxiFlight(); InterruptSpell(); if (full) @@ -2470,13 +2473,13 @@ void PlayerbotAI::WaitForSpellCast(Spell* spell) SpellInfo const* spellInfo = spell->GetSpellInfo(); float castTime = spell->GetCastTime(); - if (spellInfo->IsChanneled()) - { - int32 duration = spellInfo->GetDuration(); - bot->ApplySpellMod(spellInfo->Id, SPELLMOD_DURATION, duration); - if (duration > 0) - castTime += duration; - } + // if (spellInfo->IsChanneled()) + // { + // int32 duration = spellInfo->GetDuration(); + // bot->ApplySpellMod(spellInfo->Id, SPELLMOD_DURATION, duration); + // if (duration > 0) + // castTime += duration; + // } castTime = ceil(castTime); diff --git a/src/RandomItemMgr.cpp b/src/RandomItemMgr.cpp index 1bb91a76..31f8a3e9 100644 --- a/src/RandomItemMgr.cpp +++ b/src/RandomItemMgr.cpp @@ -2174,7 +2174,7 @@ void RandomItemMgr::BuildAmmoCache() LOG_INFO("server.loading", "Building ammo cache for {} levels", maxLevel); uint32 counter = 0; - for (uint32 level = 1; level <= maxLevel + 1; level += 10) + for (uint32 level = 1; level <= maxLevel; level += 1) { for (uint32 subClass = ITEM_SUBCLASS_ARROW; subClass <= ITEM_SUBCLASS_BULLET; subClass++) { @@ -2185,7 +2185,7 @@ void RandomItemMgr::BuildAmmoCache() Field* fields = results->Fetch(); uint32 entry = fields[0].Get(); - ammoCache[level / 10][subClass] = entry; + ammoCache[level][subClass] = entry; ++counter; } } @@ -2195,7 +2195,7 @@ void RandomItemMgr::BuildAmmoCache() uint32 RandomItemMgr::GetAmmo(uint32 level, uint32 subClass) { - return ammoCache[level / 10][subClass]; + return ammoCache[level][subClass]; } void RandomItemMgr::BuildPotionCache() diff --git a/src/RandomPlayerbotMgr.cpp b/src/RandomPlayerbotMgr.cpp index 4866f7c1..3a9eca28 100644 --- a/src/RandomPlayerbotMgr.cpp +++ b/src/RandomPlayerbotMgr.cpp @@ -24,6 +24,7 @@ #include "ServerFacade.h" #include "ChannelMgr.h" +#include #include #include @@ -991,14 +992,14 @@ void RandomPlayerbotMgr::RandomTeleport(Player* bot, std::vector& std::vector tlocs; for (auto& loc : locs) tlocs.push_back(WorldPosition(loc)); - + LOG_INFO("playerbots", "Locs {} collected.", tlocs.size()); //Do not teleport to maps disabled in config tlocs.erase(std::remove_if(tlocs.begin(), tlocs.end(), [bot](WorldPosition l) { std::vector::iterator i = find(sPlayerbotAIConfig->randomBotMaps.begin(), sPlayerbotAIConfig->randomBotMaps.end(), l.getMapId()); return i == sPlayerbotAIConfig->randomBotMaps.end(); }), tlocs.end()); - + LOG_INFO("playerbots", "Locs {} after disabled in config.", tlocs.size()); // Check locs again in case all possible locations were removed if (tlocs.empty()) { @@ -1007,21 +1008,21 @@ void RandomPlayerbotMgr::RandomTeleport(Player* bot, std::vector& } //Random shuffle based on distance. Closer distances are more likely (but not exclusivly) to be at the begin of the list. - tlocs = sTravelMgr->getNextPoint(WorldPosition(bot), tlocs, 0); - + // tlocs = sTravelMgr->getNextPoint(WorldPosition(bot), tlocs, 0); + // LOG_INFO("playerbots", "Locs {} after shuffled.", tlocs.size()); // 5% + 0.1% per level chance node on different map in selection. - tlocs.erase(std::remove_if(tlocs.begin(), tlocs.end(), [bot](WorldLocation const& l) - { - return l.GetMapId() != bot->GetMapId() && urand(1, 100) > 5 + 0.1 * bot->getLevel(); - }), tlocs.end()); - + // tlocs.erase(std::remove_if(tlocs.begin(), tlocs.end(), [bot](WorldLocation const& l) + // { + // return l.GetMapId() != bot->GetMapId() && urand(1, 100) > 5 + 0.1 * bot->getLevel(); + // }), tlocs.end()); + // LOG_INFO("playerbots", "Locs {} after remove different maps.", tlocs.size()); // Continent is about 20.000 large // Bot will travel 0-5000 units + 75-150 units per level. - tlocs.erase(std::remove_if(tlocs.begin(), tlocs.end(), [bot](WorldLocation const& l) - { - return sServerFacade->GetDistance2d(bot, l.GetPositionX(), l.GetPositionY()) > urand(0, 5000) + bot->getLevel() * 15 * urand(5, 10); - }), tlocs.end()); - + // tlocs.erase(std::remove_if(tlocs.begin(), tlocs.end(), [bot](WorldLocation const& l) + // { + // return sServerFacade->GetDistance2d(bot, l.GetPositionX(), l.GetPositionY()) > urand(0, 5000) + bot->getLevel() * 15 * urand(5, 10); + // }), tlocs.end()); + // LOG_INFO("playerbots", "Locs {} after remove too far away.", tlocs.size()); if (tlocs.empty()) { LOG_DEBUG("playerbots", "Cannot teleport bot {} - no locations available", bot->GetName().c_str()); @@ -1035,7 +1036,7 @@ void RandomPlayerbotMgr::RandomTeleport(Player* bot, std::vector& { for (uint8 attemtps = 0; attemtps < 3; ++attemtps) { - WorldLocation loc = tlocs[i]; + WorldLocation loc = tlocs[urand(0, tlocs.size() - 1)]; float x = loc.GetPositionX() + (attemtps > 0 ? urand(0, sPlayerbotAIConfig->grindDistance) - sPlayerbotAIConfig->grindDistance / 2 : 0); float y = loc.GetPositionY() + (attemtps > 0 ? urand(0, sPlayerbotAIConfig->grindDistance) - sPlayerbotAIConfig->grindDistance / 2 : 0); diff --git a/src/strategy/actions/AttackAction.cpp b/src/strategy/actions/AttackAction.cpp index c425cc2f..1cff464c 100644 --- a/src/strategy/actions/AttackAction.cpp +++ b/src/strategy/actions/AttackAction.cpp @@ -113,6 +113,8 @@ bool AttackAction::Attack(Unit* target, bool with_pet /*true*/) } else { pet->GetCharmInfo()->SetCommandState(COMMAND_FOLLOW); pet->GetCharmInfo()->SetIsCommandFollow(true); + pet->GetCharmInfo()->IsReturning(); + pet->GetMotionMaster()->MoveFollow(bot, PET_FOLLOW_DIST, pet->GetFollowAngle()); } } diff --git a/src/strategy/actions/ChooseTargetActions.cpp b/src/strategy/actions/ChooseTargetActions.cpp index 732fcc23..26395d35 100644 --- a/src/strategy/actions/ChooseTargetActions.cpp +++ b/src/strategy/actions/ChooseTargetActions.cpp @@ -72,6 +72,7 @@ bool DropTargetAction::Execute(Event event) context->GetValue("current target")->Set(nullptr); bot->SetTarget(ObjectGuid::Empty); + bot->SetSelection(ObjectGuid()); botAI->ChangeEngine(BOT_STATE_NON_COMBAT); botAI->InterruptSpell(); bot->AttackStop(); @@ -84,6 +85,8 @@ bool DropTargetAction::Execute(Event event) pet->GetCharmInfo()->SetCommandState(COMMAND_FOLLOW); pet->GetCharmInfo()->SetIsCommandFollow(true); pet->AttackStop(); + pet->GetCharmInfo()->IsReturning(); + pet->GetMotionMaster()->MoveFollow(bot, PET_FOLLOW_DIST, pet->GetFollowAngle()); } } diff --git a/src/strategy/priest/GenericPriestStrategy.cpp b/src/strategy/priest/GenericPriestStrategy.cpp index 3e3632fb..6941b3fe 100644 --- a/src/strategy/priest/GenericPriestStrategy.cpp +++ b/src/strategy/priest/GenericPriestStrategy.cpp @@ -21,7 +21,7 @@ void GenericPriestStrategy::InitTriggers(std::vector& triggers) triggers.push_back(new TriggerNode("critical health", NextAction::array(0, new NextAction("remove shadowform", 72.0f), new NextAction("power word: shield", 71.0f), new NextAction("flash heal", 70.0f), nullptr))); triggers.push_back(new TriggerNode("party member critical health", NextAction::array(0, new NextAction("remove shadowform", 62.0f), new NextAction("power word: shield on party", 61.0f), new NextAction("flash heal on party", 60.0f), nullptr))); triggers.push_back(new TriggerNode("medium threat", NextAction::array(0, new NextAction("fade", 55.0f), nullptr))); - triggers.push_back(new TriggerNode("enemy is close", NextAction::array(0, new NextAction("psychic scream", 50.0f), nullptr))); + // triggers.push_back(new TriggerNode("enemy is close", NextAction::array(0, new NextAction("psychic scream", 50.0f), nullptr))); triggers.push_back(new TriggerNode("low mana", NextAction::array(0, new NextAction("inner focus", 42.0f), nullptr))); triggers.push_back(new TriggerNode("medium mana", NextAction::array(0, new NextAction("symbol of hope", ACTION_EMERGENCY), nullptr))); triggers.push_back(new TriggerNode("low mana", NextAction::array(0, new NextAction("consume magic", 10.0f), nullptr)));