mirror of
https://github.com/liyunfan1223/mod-playerbots.git
synced 2026-02-20 18:10:02 +01:00
Config option ApplyInstanceStrategies
This commit is contained in:
parent
e983f9be00
commit
5a576cd9a5
@ -369,8 +369,8 @@ AiPlayerbot.SyncQuestForPlayer = 0
|
|||||||
#
|
#
|
||||||
#
|
#
|
||||||
|
|
||||||
# Bot can flee for enemy
|
# Auto add dungeon/raid strategies when entering the instance if implemented
|
||||||
AiPlayerbot.FleeingEnabled = 1
|
AiPlayerbot.ApplyInstanceStrategies = 1
|
||||||
|
|
||||||
# Enable auto avoid aoe (experimental)
|
# Enable auto avoid aoe (experimental)
|
||||||
# Default: 1 (enable)
|
# Default: 1 (enable)
|
||||||
@ -388,6 +388,9 @@ AiPlayerbot.AutoSaveMana = 1
|
|||||||
# Default: 60 (60%)
|
# Default: 60 (60%)
|
||||||
AiPlayerbot.SaveManaThreshold = 60
|
AiPlayerbot.SaveManaThreshold = 60
|
||||||
|
|
||||||
|
# Bot can flee for enemy
|
||||||
|
AiPlayerbot.FleeingEnabled = 1
|
||||||
|
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
|
|||||||
@ -136,6 +136,8 @@ PlayerbotAI::PlayerbotAI(Player* bot)
|
|||||||
engines[BOT_STATE_COMBAT] = AiFactory::createCombatEngine(bot, this, aiObjectContext);
|
engines[BOT_STATE_COMBAT] = AiFactory::createCombatEngine(bot, this, aiObjectContext);
|
||||||
engines[BOT_STATE_NON_COMBAT] = AiFactory::createNonCombatEngine(bot, this, aiObjectContext);
|
engines[BOT_STATE_NON_COMBAT] = AiFactory::createNonCombatEngine(bot, this, aiObjectContext);
|
||||||
engines[BOT_STATE_DEAD] = AiFactory::createDeadEngine(bot, this, aiObjectContext);
|
engines[BOT_STATE_DEAD] = AiFactory::createDeadEngine(bot, this, aiObjectContext);
|
||||||
|
if (sPlayerbotAIConfig->applyInstanceStrategies)
|
||||||
|
ApplyInstanceStrategies(bot->GetMapId());
|
||||||
currentEngine = engines[BOT_STATE_NON_COMBAT];
|
currentEngine = engines[BOT_STATE_NON_COMBAT];
|
||||||
currentState = BOT_STATE_NON_COMBAT;
|
currentState = BOT_STATE_NON_COMBAT;
|
||||||
|
|
||||||
@ -650,10 +652,11 @@ void PlayerbotAI::HandleTeleportAck()
|
|||||||
bot->GetSession()->HandleMoveWorldportAck();
|
bot->GetSession()->HandleMoveWorldportAck();
|
||||||
}
|
}
|
||||||
SetNextCheckDelay(urand(2000, 5000));
|
SetNextCheckDelay(urand(2000, 5000));
|
||||||
|
if (sPlayerbotAIConfig->applyInstanceStrategies)
|
||||||
|
ApplyInstanceStrategies(bot->GetMapId(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
SetNextCheckDelay(sPlayerbotAIConfig->globalCoolDown);
|
SetNextCheckDelay(sPlayerbotAIConfig->globalCoolDown);
|
||||||
|
|
||||||
Reset();
|
Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1487,6 +1490,34 @@ std::vector<std::string> PlayerbotAI::GetStrategies(BotState type)
|
|||||||
return e->GetStrategies();
|
return e->GetStrategies();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PlayerbotAI::ApplyInstanceStrategies(uint32 mapId, bool tellMaster)
|
||||||
|
{
|
||||||
|
std::string strategyName;
|
||||||
|
switch (mapId)
|
||||||
|
{
|
||||||
|
case 533:
|
||||||
|
strategyName = "naxx";
|
||||||
|
break;
|
||||||
|
case 603:
|
||||||
|
strategyName = "uld";
|
||||||
|
break;
|
||||||
|
case 469:
|
||||||
|
strategyName = "bwl";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
engines[BOT_STATE_COMBAT]->addStrategy(strategyName);
|
||||||
|
engines[BOT_STATE_NON_COMBAT]->addStrategy(strategyName);
|
||||||
|
if (tellMaster && !strategyName.empty())
|
||||||
|
{
|
||||||
|
std::ostringstream out;
|
||||||
|
out << "Add " << strategyName << " instance strategy";
|
||||||
|
TellMaster(out.str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool PlayerbotAI::DoSpecificAction(std::string const name, Event event, bool silent, std::string const qualifier)
|
bool PlayerbotAI::DoSpecificAction(std::string const name, Event event, bool silent, std::string const qualifier)
|
||||||
{
|
{
|
||||||
std::ostringstream out;
|
std::ostringstream out;
|
||||||
@ -1584,6 +1615,8 @@ void PlayerbotAI::ResetStrategies(bool load)
|
|||||||
AiFactory::AddDefaultCombatStrategies(bot, this, engines[BOT_STATE_COMBAT]);
|
AiFactory::AddDefaultCombatStrategies(bot, this, engines[BOT_STATE_COMBAT]);
|
||||||
AiFactory::AddDefaultNonCombatStrategies(bot, this, engines[BOT_STATE_NON_COMBAT]);
|
AiFactory::AddDefaultNonCombatStrategies(bot, this, engines[BOT_STATE_NON_COMBAT]);
|
||||||
AiFactory::AddDefaultDeadStrategies(bot, this, engines[BOT_STATE_DEAD]);
|
AiFactory::AddDefaultDeadStrategies(bot, this, engines[BOT_STATE_DEAD]);
|
||||||
|
if (sPlayerbotAIConfig->applyInstanceStrategies)
|
||||||
|
ApplyInstanceStrategies(bot->GetMapId());
|
||||||
|
|
||||||
for (uint8 i = 0; i < BOT_STATE_MAX; i++)
|
for (uint8 i = 0; i < BOT_STATE_MAX; i++)
|
||||||
engines[i]->Init();
|
engines[i]->Init();
|
||||||
@ -5736,7 +5769,7 @@ uint32 PlayerbotAI::GetReactDelay()
|
|||||||
bool isResting = bot->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING);
|
bool isResting = bot->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING);
|
||||||
if (!isResting)
|
if (!isResting)
|
||||||
{
|
{
|
||||||
multiplier = urand(5, 20);
|
multiplier = urand(10, 30);
|
||||||
return base * multiplier;
|
return base * multiplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -129,26 +129,25 @@ enum ChatChannelSource
|
|||||||
SRC_UNDEFINED
|
SRC_UNDEFINED
|
||||||
};
|
};
|
||||||
static std::map<ChatChannelSource, std::string> ChatChannelSourceStr = {
|
static std::map<ChatChannelSource, std::string> ChatChannelSourceStr = {
|
||||||
{ SRC_GUILD, "SRC_GUILD"},
|
{SRC_GUILD, "SRC_GUILD"},
|
||||||
{ SRC_WORLD, "SRC_WORLD"},
|
{SRC_WORLD, "SRC_WORLD"},
|
||||||
{ SRC_GENERAL, "SRC_GENERAL"},
|
{SRC_GENERAL, "SRC_GENERAL"},
|
||||||
{ SRC_TRADE, "SRC_TRADE"},
|
{SRC_TRADE, "SRC_TRADE"},
|
||||||
{ SRC_LOOKING_FOR_GROUP, "SRC_LOOKING_FOR_GROUP"},
|
{SRC_LOOKING_FOR_GROUP, "SRC_LOOKING_FOR_GROUP"},
|
||||||
{ SRC_LOCAL_DEFENSE, "SRC_LOCAL_DEFENSE"},
|
{SRC_LOCAL_DEFENSE, "SRC_LOCAL_DEFENSE"},
|
||||||
{ SRC_WORLD_DEFENSE, "SRC_WORLD_DEFENSE"},
|
{SRC_WORLD_DEFENSE, "SRC_WORLD_DEFENSE"},
|
||||||
{ SRC_GUILD_RECRUITMENT, "SRC_GUILD_RECRUITMENT"},
|
{SRC_GUILD_RECRUITMENT, "SRC_GUILD_RECRUITMENT"},
|
||||||
|
|
||||||
{ SRC_SAY, "SRC_SAY"},
|
{SRC_SAY, "SRC_SAY"},
|
||||||
{ SRC_WHISPER, "SRC_WHISPER"},
|
{SRC_WHISPER, "SRC_WHISPER"},
|
||||||
{ SRC_EMOTE, "SRC_EMOTE"},
|
{SRC_EMOTE, "SRC_EMOTE"},
|
||||||
{ SRC_TEXT_EMOTE, "SRC_TEXT_EMOTE"},
|
{SRC_TEXT_EMOTE, "SRC_TEXT_EMOTE"},
|
||||||
{ SRC_YELL, "SRC_YELL"},
|
{SRC_YELL, "SRC_YELL"},
|
||||||
|
|
||||||
{ SRC_PARTY, "SRC_PARTY"},
|
{SRC_PARTY, "SRC_PARTY"},
|
||||||
{ SRC_RAID, "SRC_RAID"},
|
{SRC_RAID, "SRC_RAID"},
|
||||||
|
|
||||||
{ SRC_UNDEFINED, "SRC_UNDEFINED"}
|
{SRC_UNDEFINED, "SRC_UNDEFINED"}};
|
||||||
};
|
|
||||||
enum ChatChannelId
|
enum ChatChannelId
|
||||||
{
|
{
|
||||||
GENERAL = 1,
|
GENERAL = 1,
|
||||||
@ -390,10 +389,12 @@ public:
|
|||||||
void HandleTeleportAck();
|
void HandleTeleportAck();
|
||||||
void ChangeEngine(BotState type);
|
void ChangeEngine(BotState type);
|
||||||
void DoNextAction(bool minimal = false);
|
void DoNextAction(bool minimal = false);
|
||||||
virtual bool DoSpecificAction(std::string const name, Event event = Event(), bool silent = false, std::string const qualifier = "");
|
virtual bool DoSpecificAction(std::string const name, Event event = Event(), bool silent = false,
|
||||||
|
std::string const qualifier = "");
|
||||||
void ChangeStrategy(std::string const name, BotState type);
|
void ChangeStrategy(std::string const name, BotState type);
|
||||||
void ClearStrategies(BotState type);
|
void ClearStrategies(BotState type);
|
||||||
std::vector<std::string> GetStrategies(BotState type);
|
std::vector<std::string> GetStrategies(BotState type);
|
||||||
|
void ApplyInstanceStrategies(uint32 mapId, bool tellMaster = false);
|
||||||
bool ContainsStrategy(StrategyType type);
|
bool ContainsStrategy(StrategyType type);
|
||||||
bool HasStrategy(std::string const name, BotState type);
|
bool HasStrategy(std::string const name, BotState type);
|
||||||
BotState GetState() { return currentState; };
|
BotState GetState() { return currentState; };
|
||||||
@ -434,8 +435,10 @@ public:
|
|||||||
|
|
||||||
bool TellMaster(std::ostringstream& stream, PlayerbotSecurityLevel securityLevel = PLAYERBOT_SECURITY_ALLOW_ALL);
|
bool TellMaster(std::ostringstream& stream, PlayerbotSecurityLevel securityLevel = PLAYERBOT_SECURITY_ALLOW_ALL);
|
||||||
bool TellMaster(std::string const text, PlayerbotSecurityLevel securityLevel = PLAYERBOT_SECURITY_ALLOW_ALL);
|
bool TellMaster(std::string const text, PlayerbotSecurityLevel securityLevel = PLAYERBOT_SECURITY_ALLOW_ALL);
|
||||||
bool TellMasterNoFacing(std::ostringstream& stream, PlayerbotSecurityLevel securityLevel = PLAYERBOT_SECURITY_ALLOW_ALL);
|
bool TellMasterNoFacing(std::ostringstream& stream,
|
||||||
bool TellMasterNoFacing(std::string const text, PlayerbotSecurityLevel securityLevel = PLAYERBOT_SECURITY_ALLOW_ALL);
|
PlayerbotSecurityLevel securityLevel = PLAYERBOT_SECURITY_ALLOW_ALL);
|
||||||
|
bool TellMasterNoFacing(std::string const text,
|
||||||
|
PlayerbotSecurityLevel securityLevel = PLAYERBOT_SECURITY_ALLOW_ALL);
|
||||||
bool TellError(std::string const text, PlayerbotSecurityLevel securityLevel = PLAYERBOT_SECURITY_ALLOW_ALL);
|
bool TellError(std::string const text, PlayerbotSecurityLevel securityLevel = PLAYERBOT_SECURITY_ALLOW_ALL);
|
||||||
bool SayToGuild(const std::string& msg);
|
bool SayToGuild(const std::string& msg);
|
||||||
bool SayToWorld(const std::string& msg);
|
bool SayToWorld(const std::string& msg);
|
||||||
@ -523,12 +526,16 @@ public:
|
|||||||
bool AllowActive(ActivityType activityType);
|
bool AllowActive(ActivityType activityType);
|
||||||
bool AllowActivity(ActivityType activityType = ALL_ACTIVITY, bool checkNow = false);
|
bool AllowActivity(ActivityType activityType = ALL_ACTIVITY, bool checkNow = false);
|
||||||
|
|
||||||
//Check if player is safe to use.
|
// Check if player is safe to use.
|
||||||
bool IsSafe(Player* player);
|
bool IsSafe(Player* player);
|
||||||
bool IsSafe(WorldObject* obj);
|
bool IsSafe(WorldObject* obj);
|
||||||
ChatChannelSource GetChatChannelSource(Player* bot, uint32 type, std::string channelName);
|
ChatChannelSource GetChatChannelSource(Player* bot, uint32 type, std::string channelName);
|
||||||
|
|
||||||
bool HasCheat(BotCheatMask mask) { return ((uint32)mask & (uint32)cheatMask) != 0 || ((uint32)mask & (uint32)sPlayerbotAIConfig->botCheatMask) != 0; }
|
bool HasCheat(BotCheatMask mask)
|
||||||
|
{
|
||||||
|
return ((uint32)mask & (uint32)cheatMask) != 0 ||
|
||||||
|
((uint32)mask & (uint32)sPlayerbotAIConfig->botCheatMask) != 0;
|
||||||
|
}
|
||||||
BotCheatMask GetCheat() { return cheatMask; }
|
BotCheatMask GetCheat() { return cheatMask; }
|
||||||
void SetCheat(BotCheatMask mask) { cheatMask = mask; }
|
void SetCheat(BotCheatMask mask) { cheatMask = mask; }
|
||||||
|
|
||||||
@ -563,7 +570,8 @@ public:
|
|||||||
void PetFollow();
|
void PetFollow();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void _fillGearScoreData(Player* player, Item* item, std::vector<uint32>* gearScore, uint32& twoHandScore, bool mixed = false);
|
static void _fillGearScoreData(Player* player, Item* item, std::vector<uint32>* gearScore, uint32& twoHandScore,
|
||||||
|
bool mixed = false);
|
||||||
bool IsTellAllowed(PlayerbotSecurityLevel securityLevel = PLAYERBOT_SECURITY_ALLOW_ALL);
|
bool IsTellAllowed(PlayerbotSecurityLevel securityLevel = PLAYERBOT_SECURITY_ALLOW_ALL);
|
||||||
|
|
||||||
void HandleCommands();
|
void HandleCommands();
|
||||||
|
|||||||
@ -286,6 +286,7 @@ bool PlayerbotAIConfig::Initialize()
|
|||||||
randomBotNonCombatStrategies = sConfigMgr->GetOption<std::string>("AiPlayerbot.RandomBotNonCombatStrategies", "");
|
randomBotNonCombatStrategies = sConfigMgr->GetOption<std::string>("AiPlayerbot.RandomBotNonCombatStrategies", "");
|
||||||
combatStrategies = sConfigMgr->GetOption<std::string>("AiPlayerbot.CombatStrategies", "+custom::say");
|
combatStrategies = sConfigMgr->GetOption<std::string>("AiPlayerbot.CombatStrategies", "+custom::say");
|
||||||
nonCombatStrategies = sConfigMgr->GetOption<std::string>("AiPlayerbot.NonCombatStrategies", "+custom::say,+return");
|
nonCombatStrategies = sConfigMgr->GetOption<std::string>("AiPlayerbot.NonCombatStrategies", "+custom::say,+return");
|
||||||
|
applyInstanceStrategies = sConfigMgr->GetOption<bool>("AiPlayerbot.ApplyInstanceStrategies", true);
|
||||||
|
|
||||||
commandPrefix = sConfigMgr->GetOption<std::string>("AiPlayerbot.CommandPrefix", "");
|
commandPrefix = sConfigMgr->GetOption<std::string>("AiPlayerbot.CommandPrefix", "");
|
||||||
commandSeparator = sConfigMgr->GetOption<std::string>("AiPlayerbot.CommandSeparator", "\\\\");
|
commandSeparator = sConfigMgr->GetOption<std::string>("AiPlayerbot.CommandSeparator", "\\\\");
|
||||||
@ -477,11 +478,11 @@ bool PlayerbotAIConfig::Initialize()
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
PlayerbotFactory::Init();
|
|
||||||
sRandomItemMgr->Init();
|
sRandomItemMgr->Init();
|
||||||
sRandomItemMgr->InitAfterAhBot();
|
sRandomItemMgr->InitAfterAhBot();
|
||||||
sPlayerbotTextMgr->LoadBotTexts();
|
sPlayerbotTextMgr->LoadBotTexts();
|
||||||
sPlayerbotTextMgr->LoadBotTextChance();
|
sPlayerbotTextMgr->LoadBotTextChance();
|
||||||
|
PlayerbotFactory::Init();
|
||||||
|
|
||||||
if (!sPlayerbotAIConfig->autoDoQuests)
|
if (!sPlayerbotAIConfig->autoDoQuests)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -184,6 +184,7 @@ public:
|
|||||||
bool summonAtInnkeepersEnabled;
|
bool summonAtInnkeepersEnabled;
|
||||||
std::string combatStrategies, nonCombatStrategies;
|
std::string combatStrategies, nonCombatStrategies;
|
||||||
std::string randomBotCombatStrategies, randomBotNonCombatStrategies;
|
std::string randomBotCombatStrategies, randomBotNonCombatStrategies;
|
||||||
|
bool applyInstanceStrategies;
|
||||||
uint32 randomBotMinLevel, randomBotMaxLevel;
|
uint32 randomBotMinLevel, randomBotMaxLevel;
|
||||||
float randomChangeMultiplier;
|
float randomChangeMultiplier;
|
||||||
|
|
||||||
|
|||||||
@ -949,7 +949,6 @@ void RandomItemMgr::BuildItemInfoCache()
|
|||||||
|
|
||||||
PlayerbotsDatabaseTransaction trans = PlayerbotsDatabase.BeginTransaction();
|
PlayerbotsDatabaseTransaction trans = PlayerbotsDatabase.BeginTransaction();
|
||||||
|
|
||||||
// generate stat weights for classes/specs
|
|
||||||
for (auto const& itr : *itemTemplate)
|
for (auto const& itr : *itemTemplate)
|
||||||
{
|
{
|
||||||
ItemTemplate const* proto = &itr.second;
|
ItemTemplate const* proto = &itr.second;
|
||||||
@ -958,11 +957,12 @@ void RandomItemMgr::BuildItemInfoCache()
|
|||||||
|
|
||||||
// skip non armor/weapon
|
// skip non armor/weapon
|
||||||
if (proto->Class != ITEM_CLASS_WEAPON && proto->Class != ITEM_CLASS_ARMOR &&
|
if (proto->Class != ITEM_CLASS_WEAPON && proto->Class != ITEM_CLASS_ARMOR &&
|
||||||
proto->Class != ITEM_CLASS_CONTAINER && proto->Class != ITEM_CLASS_PROJECTILE)
|
proto->Class != ITEM_CLASS_CONTAINER && proto->Class != ITEM_CLASS_PROJECTILE &&
|
||||||
|
proto->Class != ITEM_CLASS_GEM)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!CanEquipItemNew(proto))
|
// if (!CanEquipItemNew(proto))
|
||||||
continue;
|
// continue;
|
||||||
|
|
||||||
// skip test items
|
// skip test items
|
||||||
if (strstr(proto->Name1.c_str(), "(Test)") || strstr(proto->Name1.c_str(), "(TEST)") ||
|
if (strstr(proto->Name1.c_str(), "(Test)") || strstr(proto->Name1.c_str(), "(TEST)") ||
|
||||||
@ -990,29 +990,29 @@ void RandomItemMgr::BuildItemInfoCache()
|
|||||||
proto->RequiredReputationRank > 0)
|
proto->RequiredReputationRank > 0)
|
||||||
continue;*/
|
continue;*/
|
||||||
|
|
||||||
if (proto->RequiredHonorRank > 0 || proto->RequiredSkillRank > 0 || proto->RequiredCityRank > 0)
|
// if (proto->RequiredHonorRank > 0 || proto->RequiredSkillRank > 0 || proto->RequiredCityRank > 0)
|
||||||
continue;
|
// continue;
|
||||||
|
|
||||||
// skip random enchant items
|
// // skip random enchant items
|
||||||
if (proto->RandomProperty)
|
// if (proto->RandomProperty)
|
||||||
continue;
|
// continue;
|
||||||
|
|
||||||
// skip heirloom items
|
// // skip heirloom items
|
||||||
if (proto->Quality == ITEM_QUALITY_HEIRLOOM)
|
// if (proto->Quality == ITEM_QUALITY_HEIRLOOM)
|
||||||
continue;
|
// continue;
|
||||||
|
|
||||||
// check possible equip slots
|
// // check possible equip slots
|
||||||
EquipmentSlots slot = EQUIPMENT_SLOT_START;
|
// EquipmentSlots slot = EQUIPMENT_SLOT_START;
|
||||||
for (std::map<EquipmentSlots, std::set<InventoryType> >::iterator i = viableSlots.begin();
|
// for (std::map<EquipmentSlots, std::set<InventoryType> >::iterator i = viableSlots.begin();
|
||||||
i != viableSlots.end(); ++i)
|
// i != viableSlots.end(); ++i)
|
||||||
{
|
// {
|
||||||
std::set<InventoryType> slots = viableSlots[(EquipmentSlots)i->first];
|
// std::set<InventoryType> slots = viableSlots[(EquipmentSlots)i->first];
|
||||||
if (slots.find((InventoryType)proto->InventoryType) != slots.end())
|
// if (slots.find((InventoryType)proto->InventoryType) != slots.end())
|
||||||
slot = i->first;
|
// slot = i->first;
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (slot == EQUIPMENT_SLOT_START)
|
// if (slot == EQUIPMENT_SLOT_START)
|
||||||
continue;
|
// continue;
|
||||||
|
|
||||||
// Init Item cache
|
// Init Item cache
|
||||||
// ItemInfoEntry cacheInfo;
|
// ItemInfoEntry cacheInfo;
|
||||||
|
|||||||
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
#include <unordered_set>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "AiFactory.h"
|
#include "AiFactory.h"
|
||||||
@ -203,7 +204,7 @@ private:
|
|||||||
std::map<std::string, uint32> weightStatLink;
|
std::map<std::string, uint32> weightStatLink;
|
||||||
std::map<std::string, uint32> weightRatingLink;
|
std::map<std::string, uint32> weightRatingLink;
|
||||||
std::map<uint32, ItemInfoEntry> itemInfoCache;
|
std::map<uint32, ItemInfoEntry> itemInfoCache;
|
||||||
std::set<uint32> itemForTest;
|
std::unordered_set<uint32> itemForTest;
|
||||||
static std::set<uint32> itemCache;
|
static std::set<uint32> itemCache;
|
||||||
// equipCacheNew[RequiredLevel][InventoryType]
|
// equipCacheNew[RequiredLevel][InventoryType]
|
||||||
std::map<uint32, std::map<uint32, std::vector<uint32>>> equipCacheNew;
|
std::map<uint32, std::map<uint32, std::vector<uint32>>> equipCacheNew;
|
||||||
|
|||||||
@ -135,15 +135,17 @@ void PlayerbotFactory::Init()
|
|||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (gemId == 49110)
|
|
||||||
{ // unique gem
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
ItemTemplate const* proto = sObjectMgr->GetItemTemplate(gemId);
|
ItemTemplate const* proto = sObjectMgr->GetItemTemplate(gemId);
|
||||||
|
|
||||||
|
if (proto->ItemLevel < 60)
|
||||||
|
continue;
|
||||||
|
|
||||||
if (proto->Flags & ITEM_FLAG_UNIQUE_EQUIPPABLE)
|
if (proto->Flags & ITEM_FLAG_UNIQUE_EQUIPPABLE)
|
||||||
{ // unique gem
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (sRandomItemMgr->IsTestItem(gemId))
|
||||||
|
continue;
|
||||||
if (!proto || !sGemPropertiesStore.LookupEntry(proto->GemProperties))
|
if (!proto || !sGemPropertiesStore.LookupEntry(proto->GemProperties))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@ -403,7 +405,7 @@ void PlayerbotFactory::Randomize(bool incremental)
|
|||||||
bot->SetMoney(urand(level * 100000, level * 5 * 100000));
|
bot->SetMoney(urand(level * 100000, level * 5 * 100000));
|
||||||
bot->SetHealth(bot->GetMaxHealth());
|
bot->SetHealth(bot->GetMaxHealth());
|
||||||
bot->SetPower(POWER_MANA, bot->GetMaxPower(POWER_MANA));
|
bot->SetPower(POWER_MANA, bot->GetMaxPower(POWER_MANA));
|
||||||
bot->SaveToDB(false, false);
|
// bot->SaveToDB(false, false);
|
||||||
LOG_INFO("playerbots", "Initialization Done.");
|
LOG_INFO("playerbots", "Initialization Done.");
|
||||||
if (pmo)
|
if (pmo)
|
||||||
pmo->finish();
|
pmo->finish();
|
||||||
@ -438,7 +440,7 @@ void PlayerbotFactory::Refresh()
|
|||||||
uint32 money = urand(level * 1000, level * 5 * 1000);
|
uint32 money = urand(level * 1000, level * 5 * 1000);
|
||||||
if (bot->GetMoney() < money)
|
if (bot->GetMoney() < money)
|
||||||
bot->SetMoney(money);
|
bot->SetMoney(money);
|
||||||
bot->SaveToDB(false, false);
|
// bot->SaveToDB(false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerbotFactory::AddConsumables()
|
void PlayerbotFactory::AddConsumables()
|
||||||
@ -805,17 +807,13 @@ void PlayerbotFactory::ClearSkills()
|
|||||||
|
|
||||||
void PlayerbotFactory::ClearEverything()
|
void PlayerbotFactory::ClearEverything()
|
||||||
{
|
{
|
||||||
bot->SaveToDB(false, false);
|
|
||||||
bot->GiveLevel(bot->getClass() == CLASS_DEATH_KNIGHT ? sWorld->getIntConfig(CONFIG_START_HEROIC_PLAYER_LEVEL)
|
bot->GiveLevel(bot->getClass() == CLASS_DEATH_KNIGHT ? sWorld->getIntConfig(CONFIG_START_HEROIC_PLAYER_LEVEL)
|
||||||
: sWorld->getIntConfig(CONFIG_START_PLAYER_LEVEL));
|
: sWorld->getIntConfig(CONFIG_START_PLAYER_LEVEL));
|
||||||
bot->SetUInt32Value(PLAYER_XP, 0);
|
bot->SetUInt32Value(PLAYER_XP, 0);
|
||||||
LOG_INFO("playerbots", "Resetting player...");
|
LOG_INFO("playerbots", "Resetting player...");
|
||||||
bot->resetTalents(true);
|
bot->resetTalents(true);
|
||||||
bot->SaveToDB(false, false);
|
|
||||||
ClearSkills();
|
ClearSkills();
|
||||||
// bot->SaveToDB(false, false);
|
|
||||||
ClearSpells();
|
ClearSpells();
|
||||||
bot->SaveToDB(false, false);
|
|
||||||
ClearInventory();
|
ClearInventory();
|
||||||
ResetQuests();
|
ResetQuests();
|
||||||
bot->SaveToDB(false, false);
|
bot->SaveToDB(false, false);
|
||||||
@ -2027,6 +2025,7 @@ void PlayerbotFactory::InitSkills()
|
|||||||
SetRandomSkill(SKILL_THROWN);
|
SetRandomSkill(SKILL_THROWN);
|
||||||
bot->SetSkill(SKILL_DUAL_WIELD, 0, dualWieldLevel, dualWieldLevel);
|
bot->SetSkill(SKILL_DUAL_WIELD, 0, dualWieldLevel, dualWieldLevel);
|
||||||
bot->SetSkill(SKILL_PLATE_MAIL, 0, skillLevel, skillLevel);
|
bot->SetSkill(SKILL_PLATE_MAIL, 0, skillLevel, skillLevel);
|
||||||
|
bot->SetCanDualWield(dualWieldLevel);
|
||||||
break;
|
break;
|
||||||
case CLASS_PALADIN:
|
case CLASS_PALADIN:
|
||||||
SetRandomSkill(SKILL_SWORDS);
|
SetRandomSkill(SKILL_SWORDS);
|
||||||
@ -2079,8 +2078,9 @@ void PlayerbotFactory::InitSkills()
|
|||||||
SetRandomSkill(SKILL_POLEARMS);
|
SetRandomSkill(SKILL_POLEARMS);
|
||||||
SetRandomSkill(SKILL_FIST_WEAPONS);
|
SetRandomSkill(SKILL_FIST_WEAPONS);
|
||||||
SetRandomSkill(SKILL_THROWN);
|
SetRandomSkill(SKILL_THROWN);
|
||||||
bot->SetSkill(SKILL_MAIL, 0, skillLevel, skillLevel);
|
|
||||||
bot->SetSkill(SKILL_DUAL_WIELD, 0, dualWieldLevel, dualWieldLevel);
|
bot->SetSkill(SKILL_DUAL_WIELD, 0, dualWieldLevel, dualWieldLevel);
|
||||||
|
bot->SetSkill(SKILL_MAIL, 0, skillLevel, skillLevel);
|
||||||
|
bot->SetCanDualWield(dualWieldLevel);
|
||||||
break;
|
break;
|
||||||
case CLASS_ROGUE:
|
case CLASS_ROGUE:
|
||||||
SetRandomSkill(SKILL_SWORDS);
|
SetRandomSkill(SKILL_SWORDS);
|
||||||
@ -2093,6 +2093,7 @@ void PlayerbotFactory::InitSkills()
|
|||||||
SetRandomSkill(SKILL_FIST_WEAPONS);
|
SetRandomSkill(SKILL_FIST_WEAPONS);
|
||||||
SetRandomSkill(SKILL_THROWN);
|
SetRandomSkill(SKILL_THROWN);
|
||||||
bot->SetSkill(SKILL_DUAL_WIELD, 0, 1, 1);
|
bot->SetSkill(SKILL_DUAL_WIELD, 0, 1, 1);
|
||||||
|
bot->SetCanDualWield(true);
|
||||||
break;
|
break;
|
||||||
case CLASS_DEATH_KNIGHT:
|
case CLASS_DEATH_KNIGHT:
|
||||||
SetRandomSkill(SKILL_SWORDS);
|
SetRandomSkill(SKILL_SWORDS);
|
||||||
@ -2103,6 +2104,7 @@ void PlayerbotFactory::InitSkills()
|
|||||||
SetRandomSkill(SKILL_2H_AXES);
|
SetRandomSkill(SKILL_2H_AXES);
|
||||||
SetRandomSkill(SKILL_POLEARMS);
|
SetRandomSkill(SKILL_POLEARMS);
|
||||||
bot->SetSkill(SKILL_DUAL_WIELD, 0, dualWieldLevel, dualWieldLevel);
|
bot->SetSkill(SKILL_DUAL_WIELD, 0, dualWieldLevel, dualWieldLevel);
|
||||||
|
bot->SetCanDualWield(dualWieldLevel);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -2572,7 +2574,6 @@ void PlayerbotFactory::InitInstanceQuests()
|
|||||||
|
|
||||||
ClearInventory();
|
ClearInventory();
|
||||||
bot->SetUInt32Value(PLAYER_XP, currentXP);
|
bot->SetUInt32Value(PLAYER_XP, currentXP);
|
||||||
bot->SaveToDB(false, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerbotFactory::ClearInventory()
|
void PlayerbotFactory::ClearInventory()
|
||||||
@ -3329,7 +3330,7 @@ void PlayerbotFactory::InitGuild()
|
|||||||
if (bot->GetGuildId())
|
if (bot->GetGuildId())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bot->SaveToDB(false, false);
|
// bot->SaveToDB(false, false);
|
||||||
|
|
||||||
// add guild tabard
|
// add guild tabard
|
||||||
if (bot->GetGuildId() && !bot->HasItemCount(5976, 1))
|
if (bot->GetGuildId() && !bot->HasItemCount(5976, 1))
|
||||||
@ -3365,7 +3366,7 @@ void PlayerbotFactory::InitGuild()
|
|||||||
if (bot->GetGuildId() && bot->GetLevel() > 9 && urand(0, 4) && !bot->HasItemCount(5976, 1))
|
if (bot->GetGuildId() && bot->GetLevel() > 9 && urand(0, 4) && !bot->HasItemCount(5976, 1))
|
||||||
StoreItem(5976, 1);
|
StoreItem(5976, 1);
|
||||||
|
|
||||||
bot->SaveToDB(false, false);
|
// bot->SaveToDB(false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerbotFactory::InitImmersive()
|
void PlayerbotFactory::InitImmersive()
|
||||||
@ -3554,7 +3555,7 @@ void PlayerbotFactory::InitArenaTeam()
|
|||||||
arenateams.erase(arenateams.begin() + index);
|
arenateams.erase(arenateams.begin() + index);
|
||||||
}
|
}
|
||||||
|
|
||||||
bot->SaveToDB(false, false);
|
// bot->SaveToDB(false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerbotFactory::ApplyEnchantTemplate()
|
void PlayerbotFactory::ApplyEnchantTemplate()
|
||||||
@ -3670,6 +3671,9 @@ void PlayerbotFactory::ApplyEnchantAndGemsNew(bool destoryOld)
|
|||||||
if (!gemProperties)
|
if (!gemProperties)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if (sPlayerbotAIConfig->limitEnchantExpansion && bot->GetLevel() <= 70 && enchantGem >= 39900)
|
||||||
|
continue;
|
||||||
|
|
||||||
uint32 requiredLevel = gemTemplate->ItemLevel;
|
uint32 requiredLevel = gemTemplate->ItemLevel;
|
||||||
|
|
||||||
if (requiredLevel > bot->GetLevel())
|
if (requiredLevel > bot->GetLevel())
|
||||||
|
|||||||
@ -431,7 +431,8 @@ void StatsWeightCalculator::CalculateItemTypePenalty(ItemTemplate const* proto)
|
|||||||
// spec with double hand
|
// spec with double hand
|
||||||
// fury without duel wield, arms, bear, retribution, blood dk
|
// fury without duel wield, arms, bear, retribution, blood dk
|
||||||
if (isDoubleHand &&
|
if (isDoubleHand &&
|
||||||
((cls == CLASS_WARRIOR && tab == WARRIOR_TAB_FURY && !player_->CanDualWield()) ||
|
((cls == CLASS_HUNTER && !player_->CanDualWield()) ||
|
||||||
|
(cls == CLASS_WARRIOR && tab == WARRIOR_TAB_FURY && !player_->CanDualWield()) ||
|
||||||
(cls == CLASS_WARRIOR && tab == WARRIOR_TAB_ARMS) || (cls == CLASS_DRUID && tab == DRUID_TAB_FERAL) ||
|
(cls == CLASS_WARRIOR && tab == WARRIOR_TAB_ARMS) || (cls == CLASS_DRUID && tab == DRUID_TAB_FERAL) ||
|
||||||
(cls == CLASS_PALADIN && tab == PALADIN_TAB_RETRIBUTION) ||
|
(cls == CLASS_PALADIN && tab == PALADIN_TAB_RETRIBUTION) ||
|
||||||
(cls == CLASS_DEATH_KNIGHT && tab == DEATHKNIGHT_TAB_BLOOD) ||
|
(cls == CLASS_DEATH_KNIGHT && tab == DEATHKNIGHT_TAB_BLOOD) ||
|
||||||
|
|||||||
@ -197,6 +197,7 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle,
|
|||||||
{
|
{
|
||||||
VehicleSeatEntry const* seat = vehicle->GetSeatForPassenger(bot);
|
VehicleSeatEntry const* seat = vehicle->GetSeatForPassenger(bot);
|
||||||
Unit* vehicleBase = vehicle->GetBase();
|
Unit* vehicleBase = vehicle->GetBase();
|
||||||
|
generatePath = vehicleBase->CanFly();
|
||||||
if (!vehicleBase || !seat || !seat->CanControl()) // is passenger and cant move anyway
|
if (!vehicleBase || !seat || !seat->CanControl()) // is passenger and cant move anyway
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -815,7 +816,6 @@ bool MovementAction::ReachCombatTo(Unit* target, float distance)
|
|||||||
|
|
||||||
if (target->HasUnitMovementFlag(MOVEMENTFLAG_FORWARD)) // target is moving forward, predict the position
|
if (target->HasUnitMovementFlag(MOVEMENTFLAG_FORWARD)) // target is moving forward, predict the position
|
||||||
{
|
{
|
||||||
|
|
||||||
float needToGo = bot->GetExactDist(target) - distance;
|
float needToGo = bot->GetExactDist(target) - distance;
|
||||||
float timeToGo = MoveDelay(abs(needToGo)) + sPlayerbotAIConfig->reactDelay / 1000.0f;
|
float timeToGo = MoveDelay(abs(needToGo)) + sPlayerbotAIConfig->reactDelay / 1000.0f;
|
||||||
float targetMoveDist = timeToGo * target->GetSpeed(MOVE_RUN);
|
float targetMoveDist = timeToGo * target->GetSpeed(MOVE_RUN);
|
||||||
@ -848,7 +848,8 @@ bool MovementAction::ReachCombatTo(Unit* target, float distance)
|
|||||||
return false;
|
return false;
|
||||||
path.ShortenPathUntilDist(G3D::Vector3(tx, ty, tz), distance);
|
path.ShortenPathUntilDist(G3D::Vector3(tx, ty, tz), distance);
|
||||||
G3D::Vector3 endPos = path.GetPath().back();
|
G3D::Vector3 endPos = path.GetPath().back();
|
||||||
return MoveTo(target->GetMapId(), endPos.x, endPos.y, endPos.z, false, false, false, false, MovementPriority::MOVEMENT_COMBAT);
|
return MoveTo(target->GetMapId(), endPos.x, endPos.y, endPos.z, false, false, false, false,
|
||||||
|
MovementPriority::MOVEMENT_COMBAT);
|
||||||
}
|
}
|
||||||
|
|
||||||
float MovementAction::GetFollowAngle()
|
float MovementAction::GetFollowAngle()
|
||||||
@ -924,7 +925,6 @@ bool MovementAction::IsWaitingForLastMove(MovementPriority priority)
|
|||||||
if (lastMove.lastdelayTime + lastMove.msTime > getMSTime())
|
if (lastMove.lastdelayTime + lastMove.msTime > getMSTime())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2403,7 +2403,8 @@ bool MoveInsideAction::Execute(Event event) { return MoveInside(bot->GetMapId(),
|
|||||||
bool RotateAroundTheCenterPointAction::Execute(Event event)
|
bool RotateAroundTheCenterPointAction::Execute(Event event)
|
||||||
{
|
{
|
||||||
uint32 next_point = GetCurrWaypoint();
|
uint32 next_point = GetCurrWaypoint();
|
||||||
if (MoveTo(bot->GetMapId(), waypoints[next_point].first, waypoints[next_point].second, bot->GetPositionZ(), false, false, false, false, MovementPriority::MOVEMENT_COMBAT))
|
if (MoveTo(bot->GetMapId(), waypoints[next_point].first, waypoints[next_point].second, bot->GetPositionZ(), false,
|
||||||
|
false, false, false, MovementPriority::MOVEMENT_COMBAT))
|
||||||
{
|
{
|
||||||
call_counters += 1;
|
call_counters += 1;
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@ -319,7 +319,6 @@ bool SpiritHealerAction::Execute(Event event)
|
|||||||
PlayerbotChatHandler ch(bot);
|
PlayerbotChatHandler ch(bot);
|
||||||
bot->ResurrectPlayer(0.5f);
|
bot->ResurrectPlayer(0.5f);
|
||||||
bot->SpawnCorpseBones();
|
bot->SpawnCorpseBones();
|
||||||
bot->SaveToDB(false, false);
|
|
||||||
context->GetValue<Unit*>("current target")->Set(nullptr);
|
context->GetValue<Unit*>("current target")->Set(nullptr);
|
||||||
bot->SetTarget();
|
bot->SetTarget();
|
||||||
botAI->TellMaster("Hello");
|
botAI->TellMaster("Hello");
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user