mirror of
https://github.com/mod-playerbots/mod-playerbots
synced 2025-11-29 15:58:20 +08:00
ammo, pet return
This commit is contained in:
@@ -239,6 +239,9 @@ void PlayerbotAI::UpdateAI(uint32 elapsed, bool minimal)
|
|||||||
// check activity
|
// check activity
|
||||||
AllowActivity();
|
AllowActivity();
|
||||||
|
|
||||||
|
if (bot->GetCurrentSpell(CURRENT_CHANNELED_SPELL)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
Spell* currentSpell = bot->GetCurrentSpell(CURRENT_GENERIC_SPELL);
|
Spell* currentSpell = bot->GetCurrentSpell(CURRENT_GENERIC_SPELL);
|
||||||
if (currentSpell && currentSpell->getState() == SPELL_STATE_CASTING && currentSpell->GetCastTime())
|
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();
|
aiObjectContext->GetValue<GuidSet&>("ignore rpg target")->Get().clear();
|
||||||
|
|
||||||
bot->GetMotionMaster()->Clear();
|
bot->GetMotionMaster()->Clear();
|
||||||
bot->CleanupAfterTaxiFlight();
|
// bot->CleanupAfterTaxiFlight();
|
||||||
InterruptSpell();
|
InterruptSpell();
|
||||||
|
|
||||||
if (full)
|
if (full)
|
||||||
@@ -2470,13 +2473,13 @@ void PlayerbotAI::WaitForSpellCast(Spell* spell)
|
|||||||
SpellInfo const* spellInfo = spell->GetSpellInfo();
|
SpellInfo const* spellInfo = spell->GetSpellInfo();
|
||||||
|
|
||||||
float castTime = spell->GetCastTime();
|
float castTime = spell->GetCastTime();
|
||||||
if (spellInfo->IsChanneled())
|
// if (spellInfo->IsChanneled())
|
||||||
{
|
// {
|
||||||
int32 duration = spellInfo->GetDuration();
|
// int32 duration = spellInfo->GetDuration();
|
||||||
bot->ApplySpellMod(spellInfo->Id, SPELLMOD_DURATION, duration);
|
// bot->ApplySpellMod(spellInfo->Id, SPELLMOD_DURATION, duration);
|
||||||
if (duration > 0)
|
// if (duration > 0)
|
||||||
castTime += duration;
|
// castTime += duration;
|
||||||
}
|
// }
|
||||||
|
|
||||||
castTime = ceil(castTime);
|
castTime = ceil(castTime);
|
||||||
|
|
||||||
|
|||||||
@@ -2174,7 +2174,7 @@ void RandomItemMgr::BuildAmmoCache()
|
|||||||
LOG_INFO("server.loading", "Building ammo cache for {} levels", maxLevel);
|
LOG_INFO("server.loading", "Building ammo cache for {} levels", maxLevel);
|
||||||
|
|
||||||
uint32 counter = 0;
|
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++)
|
for (uint32 subClass = ITEM_SUBCLASS_ARROW; subClass <= ITEM_SUBCLASS_BULLET; subClass++)
|
||||||
{
|
{
|
||||||
@@ -2185,7 +2185,7 @@ void RandomItemMgr::BuildAmmoCache()
|
|||||||
|
|
||||||
Field* fields = results->Fetch();
|
Field* fields = results->Fetch();
|
||||||
uint32 entry = fields[0].Get<uint32>();
|
uint32 entry = fields[0].Get<uint32>();
|
||||||
ammoCache[level / 10][subClass] = entry;
|
ammoCache[level][subClass] = entry;
|
||||||
++counter;
|
++counter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2195,7 +2195,7 @@ void RandomItemMgr::BuildAmmoCache()
|
|||||||
|
|
||||||
uint32 RandomItemMgr::GetAmmo(uint32 level, uint32 subClass)
|
uint32 RandomItemMgr::GetAmmo(uint32 level, uint32 subClass)
|
||||||
{
|
{
|
||||||
return ammoCache[level / 10][subClass];
|
return ammoCache[level][subClass];
|
||||||
}
|
}
|
||||||
|
|
||||||
void RandomItemMgr::BuildPotionCache()
|
void RandomItemMgr::BuildPotionCache()
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
#include "ServerFacade.h"
|
#include "ServerFacade.h"
|
||||||
#include "ChannelMgr.h"
|
#include "ChannelMgr.h"
|
||||||
|
|
||||||
|
#include <cstdlib>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <boost/thread/thread.hpp>
|
#include <boost/thread/thread.hpp>
|
||||||
|
|
||||||
@@ -991,14 +992,14 @@ void RandomPlayerbotMgr::RandomTeleport(Player* bot, std::vector<WorldLocation>&
|
|||||||
std::vector<WorldPosition> tlocs;
|
std::vector<WorldPosition> tlocs;
|
||||||
for (auto& loc : locs)
|
for (auto& loc : locs)
|
||||||
tlocs.push_back(WorldPosition(loc));
|
tlocs.push_back(WorldPosition(loc));
|
||||||
|
LOG_INFO("playerbots", "Locs {} collected.", tlocs.size());
|
||||||
//Do not teleport to maps disabled in config
|
//Do not teleport to maps disabled in config
|
||||||
tlocs.erase(std::remove_if(tlocs.begin(), tlocs.end(), [bot](WorldPosition l)
|
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());
|
std::vector<uint32>::iterator i = find(sPlayerbotAIConfig->randomBotMaps.begin(), sPlayerbotAIConfig->randomBotMaps.end(), l.getMapId());
|
||||||
return i == sPlayerbotAIConfig->randomBotMaps.end();
|
return i == sPlayerbotAIConfig->randomBotMaps.end();
|
||||||
}), tlocs.end());
|
}), tlocs.end());
|
||||||
|
LOG_INFO("playerbots", "Locs {} after disabled in config.", tlocs.size());
|
||||||
// Check locs again in case all possible locations were removed
|
// Check locs again in case all possible locations were removed
|
||||||
if (tlocs.empty())
|
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.
|
//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.
|
// 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)
|
// 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();
|
// return l.GetMapId() != bot->GetMapId() && urand(1, 100) > 5 + 0.1 * bot->getLevel();
|
||||||
}), tlocs.end());
|
// }), tlocs.end());
|
||||||
|
// LOG_INFO("playerbots", "Locs {} after remove different maps.", tlocs.size());
|
||||||
// Continent is about 20.000 large
|
// Continent is about 20.000 large
|
||||||
// Bot will travel 0-5000 units + 75-150 units per level.
|
// Bot will travel 0-5000 units + 75-150 units per level.
|
||||||
tlocs.erase(std::remove_if(tlocs.begin(), tlocs.end(), [bot](WorldLocation const& l)
|
// 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);
|
// return sServerFacade->GetDistance2d(bot, l.GetPositionX(), l.GetPositionY()) > urand(0, 5000) + bot->getLevel() * 15 * urand(5, 10);
|
||||||
}), tlocs.end());
|
// }), tlocs.end());
|
||||||
|
// LOG_INFO("playerbots", "Locs {} after remove too far away.", tlocs.size());
|
||||||
if (tlocs.empty())
|
if (tlocs.empty())
|
||||||
{
|
{
|
||||||
LOG_DEBUG("playerbots", "Cannot teleport bot {} - no locations available", bot->GetName().c_str());
|
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)
|
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 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);
|
float y = loc.GetPositionY() + (attemtps > 0 ? urand(0, sPlayerbotAIConfig->grindDistance) - sPlayerbotAIConfig->grindDistance / 2 : 0);
|
||||||
|
|||||||
@@ -113,6 +113,8 @@ bool AttackAction::Attack(Unit* target, bool with_pet /*true*/)
|
|||||||
} else {
|
} else {
|
||||||
pet->GetCharmInfo()->SetCommandState(COMMAND_FOLLOW);
|
pet->GetCharmInfo()->SetCommandState(COMMAND_FOLLOW);
|
||||||
pet->GetCharmInfo()->SetIsCommandFollow(true);
|
pet->GetCharmInfo()->SetIsCommandFollow(true);
|
||||||
|
pet->GetCharmInfo()->IsReturning();
|
||||||
|
pet->GetMotionMaster()->MoveFollow(bot, PET_FOLLOW_DIST, pet->GetFollowAngle());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -72,6 +72,7 @@ bool DropTargetAction::Execute(Event event)
|
|||||||
context->GetValue<Unit*>("current target")->Set(nullptr);
|
context->GetValue<Unit*>("current target")->Set(nullptr);
|
||||||
|
|
||||||
bot->SetTarget(ObjectGuid::Empty);
|
bot->SetTarget(ObjectGuid::Empty);
|
||||||
|
bot->SetSelection(ObjectGuid());
|
||||||
botAI->ChangeEngine(BOT_STATE_NON_COMBAT);
|
botAI->ChangeEngine(BOT_STATE_NON_COMBAT);
|
||||||
botAI->InterruptSpell();
|
botAI->InterruptSpell();
|
||||||
bot->AttackStop();
|
bot->AttackStop();
|
||||||
@@ -84,6 +85,8 @@ bool DropTargetAction::Execute(Event event)
|
|||||||
pet->GetCharmInfo()->SetCommandState(COMMAND_FOLLOW);
|
pet->GetCharmInfo()->SetCommandState(COMMAND_FOLLOW);
|
||||||
pet->GetCharmInfo()->SetIsCommandFollow(true);
|
pet->GetCharmInfo()->SetIsCommandFollow(true);
|
||||||
pet->AttackStop();
|
pet->AttackStop();
|
||||||
|
pet->GetCharmInfo()->IsReturning();
|
||||||
|
pet->GetMotionMaster()->MoveFollow(bot, PET_FOLLOW_DIST, pet->GetFollowAngle());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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("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("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("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("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("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)));
|
triggers.push_back(new TriggerNode("low mana", NextAction::array(0, new NextAction("consume magic", 10.0f), nullptr)));
|
||||||
|
|||||||
Reference in New Issue
Block a user