ammo, pet return

This commit is contained in:
Yunfan Li
2023-05-30 17:10:51 +08:00
parent ffb0b260d3
commit 7f0b5c2f03
6 changed files with 36 additions and 27 deletions

View File

@@ -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<GuidSet&>("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);

View File

@@ -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<uint32>();
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()

View File

@@ -24,6 +24,7 @@
#include "ServerFacade.h"
#include "ChannelMgr.h"
#include <cstdlib>
#include <iomanip>
#include <boost/thread/thread.hpp>
@@ -991,14 +992,14 @@ void RandomPlayerbotMgr::RandomTeleport(Player* bot, std::vector<WorldLocation>&
std::vector<WorldPosition> 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<uint32>::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<WorldLocation>&
}
//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<WorldLocation>&
{
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);

View File

@@ -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());
}
}

View File

@@ -72,6 +72,7 @@ bool DropTargetAction::Execute(Event event)
context->GetValue<Unit*>("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());
}
}

View File

@@ -21,7 +21,7 @@ void GenericPriestStrategy::InitTriggers(std::vector<TriggerNode*>& 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)));