mirror of
https://github.com/mod-playerbots/mod-playerbots
synced 2025-11-29 15:58:20 +08:00
Merge pull request #358 from liyunfan1223/dev0718
Max added bot configuration
This commit is contained in:
@@ -104,6 +104,12 @@ AiPlayerbot.DeleteRandomBotAccounts = 0
|
|||||||
#
|
#
|
||||||
#
|
#
|
||||||
|
|
||||||
|
# Maximum number of bots added by one account
|
||||||
|
AiPlayerbot.MaxAddedBots = 40
|
||||||
|
|
||||||
|
# Maximum number of bots per class added by one account
|
||||||
|
AiPlayerbot.MaxAddedBotsPerClass = 10
|
||||||
|
|
||||||
# Enable/Disable create bot by addclass command (0 = GM only, 1 = enable)
|
# Enable/Disable create bot by addclass command (0 = GM only, 1 = enable)
|
||||||
# default: 1 (enable)
|
# default: 1 (enable)
|
||||||
AiPlayerbot.AddClassCommand = 1
|
AiPlayerbot.AddClassCommand = 1
|
||||||
@@ -331,7 +337,7 @@ AiPlayerbot.MediumMana = 40
|
|||||||
#
|
#
|
||||||
|
|
||||||
# Bots pick their quest reward (yes = picks first useful item, no = list all rewards, ask = pick useful item and lists if multiple)
|
# Bots pick their quest reward (yes = picks first useful item, no = list all rewards, ask = pick useful item and lists if multiple)
|
||||||
AiPlayerbot.AutoPickReward = no
|
AiPlayerbot.AutoPickReward = yes
|
||||||
|
|
||||||
# Sync quests with player (Bots will complete quests the moment you hand them in. Bots will ignore looting quest items.)
|
# Sync quests with player (Bots will complete quests the moment you hand them in. Bots will ignore looting quest items.)
|
||||||
# Default: 1 (enable)
|
# Default: 1 (enable)
|
||||||
@@ -656,7 +662,7 @@ AiPlayerbot.RandomBotArenaTeamCount = 20
|
|||||||
AiPlayerbot.DeleteRandomBotArenaTeams = 0
|
AiPlayerbot.DeleteRandomBotArenaTeams = 0
|
||||||
|
|
||||||
# PvP Restricted Zones (bots don't pvp)
|
# PvP Restricted Zones (bots don't pvp)
|
||||||
AiPlayerbot.PvpProhibitedZoneIds = "2255,656,2361,2362,2363,976,35,2268,3425,392,541,1446,3828,3712,3738,3565,3539,3623,4152,3988,4658,4284,4418,4436,4275,4323,4395,3703,4298" # 33(stranglethorn vale),440(tanaris)
|
AiPlayerbot.PvpProhibitedZoneIds = "2255,656,2361,2362,2363,976,35,2268,3425,392,541,1446,3828,3712,3738,3565,3539,3623,4152,3988,4658,4284,4418,4436,4275,4323,4395,3703,4298"
|
||||||
|
|
||||||
# PvP Restricted Areas (bots don't pvp)
|
# PvP Restricted Areas (bots don't pvp)
|
||||||
AiPlayerbot.PvpProhibitedAreaIds = "976,35,392"
|
AiPlayerbot.PvpProhibitedAreaIds = "976,35,392"
|
||||||
|
|||||||
@@ -283,6 +283,9 @@ bool PlayerbotAIConfig::Initialize()
|
|||||||
botRepairWhenSummon = sConfigMgr->GetOption<bool>("AiPlayerbot.BotRepairWhenSummon", true);
|
botRepairWhenSummon = sConfigMgr->GetOption<bool>("AiPlayerbot.BotRepairWhenSummon", true);
|
||||||
autoInitOnly = sConfigMgr->GetOption<bool>("AiPlayerbot.AutoInitOnly", false);
|
autoInitOnly = sConfigMgr->GetOption<bool>("AiPlayerbot.AutoInitOnly", false);
|
||||||
autoInitEquipLevelLimitRatio = sConfigMgr->GetOption<float>("AiPlayerbot.AutoInitEquipLevelLimitRatio", 1.0);
|
autoInitEquipLevelLimitRatio = sConfigMgr->GetOption<float>("AiPlayerbot.AutoInitEquipLevelLimitRatio", 1.0);
|
||||||
|
|
||||||
|
maxAddedBots = sConfigMgr->GetOption<int32>("AiPlayerbot.MaxAddedBots", 40);
|
||||||
|
maxAddedBotsPerClass = sConfigMgr->GetOption<int32>("AiPlayerbot.MaxAddedBotsPerClass", 10);
|
||||||
addClassCommand = sConfigMgr->GetOption<int32>("AiPlayerbot.AddClassCommand", 1);
|
addClassCommand = sConfigMgr->GetOption<int32>("AiPlayerbot.AddClassCommand", 1);
|
||||||
maintenanceCommand = sConfigMgr->GetOption<int32>("AiPlayerbot.MaintenanceCommand", 1);
|
maintenanceCommand = sConfigMgr->GetOption<int32>("AiPlayerbot.MaintenanceCommand", 1);
|
||||||
autoGearCommand = sConfigMgr->GetOption<int32>("AiPlayerbot.AutoGearCommand", 1);
|
autoGearCommand = sConfigMgr->GetOption<int32>("AiPlayerbot.AutoGearCommand", 1);
|
||||||
|
|||||||
@@ -224,6 +224,7 @@ class PlayerbotAIConfig
|
|||||||
bool botRepairWhenSummon;
|
bool botRepairWhenSummon;
|
||||||
bool autoInitOnly;
|
bool autoInitOnly;
|
||||||
float autoInitEquipLevelLimitRatio;
|
float autoInitEquipLevelLimitRatio;
|
||||||
|
int32 maxAddedBots, maxAddedBotsPerClass;
|
||||||
int32 addClassCommand;
|
int32 addClassCommand;
|
||||||
int32 maintenanceCommand;
|
int32 maintenanceCommand;
|
||||||
int32 autoGearCommand, autoGearQualityLimit, autoGearScoreLimit;
|
int32 autoGearCommand, autoGearQualityLimit, autoGearScoreLimit;
|
||||||
|
|||||||
@@ -6,6 +6,8 @@
|
|||||||
#include "CharacterPackets.h"
|
#include "CharacterPackets.h"
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
#include "Define.h"
|
#include "Define.h"
|
||||||
|
#include "Group.h"
|
||||||
|
#include "GroupMgr.h"
|
||||||
#include "ObjectAccessor.h"
|
#include "ObjectAccessor.h"
|
||||||
#include "ObjectMgr.h"
|
#include "ObjectMgr.h"
|
||||||
#include "PlayerbotAIConfig.h"
|
#include "PlayerbotAIConfig.h"
|
||||||
@@ -19,6 +21,7 @@
|
|||||||
#include "ChannelMgr.h"
|
#include "ChannelMgr.h"
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <istream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
PlayerbotHolder::PlayerbotHolder() : PlayerbotAIBase(false)
|
PlayerbotHolder::PlayerbotHolder() : PlayerbotAIBase(false)
|
||||||
@@ -89,25 +92,42 @@ void PlayerbotHolder::HandlePlayerBotLoginCallback(PlayerbotLoginQueryHolder con
|
|||||||
Player* bot = botSession->GetPlayer();
|
Player* bot = botSession->GetPlayer();
|
||||||
if (!bot)
|
if (!bot)
|
||||||
{
|
{
|
||||||
LogoutPlayerBot(holder.GetGuid());
|
botSession->LogoutPlayer(true);
|
||||||
|
delete botSession;
|
||||||
// LOG_ERROR("playerbots", "Error logging in bot {}, please try to reset all random bots", holder.GetGuid().ToString().c_str());
|
// LOG_ERROR("playerbots", "Error logging in bot {}, please try to reset all random bots", holder.GetGuid().ToString().c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
sRandomPlayerbotMgr->OnPlayerLogin(bot);
|
|
||||||
|
|
||||||
uint32 masterAccount = holder.GetMasterAccountId();
|
uint32 masterAccount = holder.GetMasterAccountId();
|
||||||
WorldSession* masterSession = masterAccount ? sWorld->FindSession(masterAccount) : nullptr;
|
WorldSession* masterSession = masterAccount ? sWorld->FindSession(masterAccount) : nullptr;
|
||||||
|
std::ostringstream out;
|
||||||
bool allowed = false;
|
bool allowed = false;
|
||||||
if (botAccountId == masterAccount)
|
if (botAccountId == masterAccount) {
|
||||||
allowed = true;
|
allowed = true;
|
||||||
else if (masterSession && sPlayerbotAIConfig->allowGuildBots && bot->GetGuildId() != 0 && bot->GetGuildId() == masterSession->GetPlayer()->GetGuildId())
|
} else if (masterSession && sPlayerbotAIConfig->allowGuildBots && bot->GetGuildId() != 0 && bot->GetGuildId() == masterSession->GetPlayer()->GetGuildId()) {
|
||||||
allowed = true;
|
allowed = true;
|
||||||
else if (sPlayerbotAIConfig->IsInRandomAccountList(botAccountId))
|
} else if (sPlayerbotAIConfig->IsInRandomAccountList(botAccountId)) {
|
||||||
allowed = true;
|
allowed = true;
|
||||||
|
} else {
|
||||||
|
allowed = false;
|
||||||
|
out << "Failure: You are not allowed to control bot " << bot->GetName().c_str();
|
||||||
|
}
|
||||||
|
if (allowed && masterSession) {
|
||||||
|
Player* player = masterSession->GetPlayer();
|
||||||
|
PlayerbotMgr *mgr = GET_PLAYERBOT_MGR(player);
|
||||||
|
uint32 count = mgr->GetPlayerbotsCount();
|
||||||
|
uint32 cls_count = mgr->GetPlayerbotsCountByClass(bot->getClass());
|
||||||
|
if (count >= sPlayerbotAIConfig->maxAddedBots) {
|
||||||
|
allowed = false;
|
||||||
|
out << "Failure: You have added too many bots";
|
||||||
|
} else if (cls_count >= sPlayerbotAIConfig->maxAddedBotsPerClass) {
|
||||||
|
allowed = false;
|
||||||
|
out << "Failure: You have added too many bots for this class";
|
||||||
|
}
|
||||||
|
}
|
||||||
if (allowed)
|
if (allowed)
|
||||||
{
|
{
|
||||||
|
sRandomPlayerbotMgr->OnPlayerLogin(bot);
|
||||||
OnBotLogin(bot);
|
OnBotLogin(bot);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -115,10 +135,12 @@ void PlayerbotHolder::HandlePlayerBotLoginCallback(PlayerbotLoginQueryHolder con
|
|||||||
if (masterSession)
|
if (masterSession)
|
||||||
{
|
{
|
||||||
ChatHandler ch(masterSession);
|
ChatHandler ch(masterSession);
|
||||||
ch.PSendSysMessage("You are not allowed to control bot %s", bot->GetName());
|
ch.SendSysMessage(out.str());
|
||||||
}
|
}
|
||||||
OnBotLogin(bot);
|
botSession->LogoutPlayer(true);
|
||||||
LogoutPlayerBot(bot->GetGUID());
|
delete botSession;
|
||||||
|
// OnBotLogin(bot);
|
||||||
|
// LogoutPlayerBot(bot->GetGUID());
|
||||||
|
|
||||||
// LOG_ERROR("playerbots", "Attempt to add not allowed bot {}, please try to reset all random bots", bot->GetName());
|
// LOG_ERROR("playerbots", "Attempt to add not allowed bot {}, please try to reset all random bots", bot->GetName());
|
||||||
}
|
}
|
||||||
@@ -453,7 +475,22 @@ void PlayerbotHolder::OnBotLogin(Player* const bot)
|
|||||||
botAI->TellMaster("Hello!", PLAYERBOT_SECURITY_TALK);
|
botAI->TellMaster("Hello!", PLAYERBOT_SECURITY_TALK);
|
||||||
|
|
||||||
if (master && master->GetGroup() && !group) {
|
if (master && master->GetGroup() && !group) {
|
||||||
master->GetGroup()->AddMember(bot);
|
Group* mgroup = master->GetGroup();
|
||||||
|
if (mgroup->GetMembersCount() >= 5) {
|
||||||
|
if (!mgroup->isRaidGroup() && !mgroup->isLFGGroup() && !mgroup->isBGGroup() && !mgroup->isBFGroup()) {
|
||||||
|
mgroup->ConvertToRaid();
|
||||||
|
}
|
||||||
|
if (mgroup->isRaidGroup()) {
|
||||||
|
mgroup->AddMember(bot);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
mgroup->AddMember(bot);
|
||||||
|
}
|
||||||
|
} else if (master && !group) {
|
||||||
|
Group* newGroup = new Group();
|
||||||
|
newGroup->Create(master);
|
||||||
|
sGroupMgr->AddGroup(newGroup);
|
||||||
|
newGroup->AddMember(bot);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 accountId = bot->GetSession()->GetAccountId();
|
uint32 accountId = bot->GetSession()->GetAccountId();
|
||||||
@@ -1157,6 +1194,19 @@ std::string const PlayerbotHolder::LookupBots(Player* master)
|
|||||||
return ret_msg;
|
return ret_msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32 PlayerbotHolder::GetPlayerbotsCountByClass(uint32 cls)
|
||||||
|
{
|
||||||
|
uint32 count = 0;
|
||||||
|
for (PlayerBotMap::const_iterator it = GetPlayerBotsBegin(); it != GetPlayerBotsEnd(); ++it)
|
||||||
|
{
|
||||||
|
Player* const bot = it->second;
|
||||||
|
if (bot->getClass() == cls) {
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
PlayerbotMgr::PlayerbotMgr(Player* const master) : PlayerbotHolder(), master(master), lastErrorTell(0)
|
PlayerbotMgr::PlayerbotMgr(Player* const master) : PlayerbotHolder(), master(master), lastErrorTell(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,7 +48,8 @@ class PlayerbotHolder : public PlayerbotAIBase
|
|||||||
uint32 GetAccountId(ObjectGuid guid);
|
uint32 GetAccountId(ObjectGuid guid);
|
||||||
std::string const ListBots(Player* master);
|
std::string const ListBots(Player* master);
|
||||||
std::string const LookupBots(Player* master);
|
std::string const LookupBots(Player* master);
|
||||||
|
uint32 GetPlayerbotsCount() { return playerBots.size(); }
|
||||||
|
uint32 GetPlayerbotsCountByClass(uint32 cls);
|
||||||
protected:
|
protected:
|
||||||
virtual void OnBotLoginInternal(Player* const bot) = 0;
|
virtual void OnBotLoginInternal(Player* const bot) = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -137,6 +137,8 @@ std::string const QueryItemUsageAction::QueryItemUsage(ItemTemplate const* item)
|
|||||||
return "Auctionhouse";
|
return "Auctionhouse";
|
||||||
case ITEM_USAGE_AMMO:
|
case ITEM_USAGE_AMMO:
|
||||||
return "Ammunition";
|
return "Ammunition";
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
|
|||||||
@@ -588,11 +588,12 @@ void ChatReplyAction::ChatReplyDo(Player* bot, uint32 type, uint32 guid1, uint32
|
|||||||
if (ChannelMgr* cMgr = ChannelMgr::forTeam(bot->GetTeamId()))
|
if (ChannelMgr* cMgr = ChannelMgr::forTeam(bot->GetTeamId()))
|
||||||
{
|
{
|
||||||
std::string worldChan = "World";
|
std::string worldChan = "World";
|
||||||
if (Channel* chn = cMgr->GetJoinChannel(worldChan.c_str(), 0))
|
if (Channel* chn = cMgr->GetJoinChannel(worldChan.c_str(), 0)) {
|
||||||
if (bot->GetTeamId() == TEAM_ALLIANCE)
|
if (bot->GetTeamId() == TEAM_ALLIANCE)
|
||||||
chn->Say(bot->GetGUID(), c, LANG_COMMON);
|
chn->Say(bot->GetGUID(), c, LANG_COMMON);
|
||||||
else
|
else
|
||||||
chn->Say(bot->GetGUID(), c, LANG_ORCISH);
|
chn->Say(bot->GetGUID(), c, LANG_ORCISH);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ void TrainerAction::TellFooter(uint32 totalCost)
|
|||||||
bool MaintenanceAction::Execute(Event event)
|
bool MaintenanceAction::Execute(Event event)
|
||||||
{
|
{
|
||||||
if (!sPlayerbotAIConfig->maintenanceCommand) {
|
if (!sPlayerbotAIConfig->maintenanceCommand) {
|
||||||
botAI->TellMaster("maintenance command is not allowed, please check the configuration.");
|
botAI->TellError("maintenance command is not allowed, please check the configuration.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
botAI->TellMaster("I'm maintaining");
|
botAI->TellMaster("I'm maintaining");
|
||||||
@@ -187,7 +187,7 @@ bool RemoveGlyphAction::Execute(Event event)
|
|||||||
bool AutoGearAction::Execute(Event event)
|
bool AutoGearAction::Execute(Event event)
|
||||||
{
|
{
|
||||||
if (!sPlayerbotAIConfig->autoGearCommand) {
|
if (!sPlayerbotAIConfig->autoGearCommand) {
|
||||||
botAI->TellMaster("autogear command is not allowed, please check the configuration.");
|
botAI->TellError("autogear command is not allowed, please check the configuration.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
botAI->TellMaster("I'm auto gearing");
|
botAI->TellMaster("I'm auto gearing");
|
||||||
|
|||||||
@@ -51,5 +51,5 @@ void GenericRogueNonCombatStrategy::InitTriggers(std::vector<TriggerNode*>& trig
|
|||||||
|
|
||||||
triggers.push_back(new TriggerNode(
|
triggers.push_back(new TriggerNode(
|
||||||
"often",
|
"often",
|
||||||
NextAction::array(0, new NextAction("unstealth", 10.0f), NULL)));
|
NextAction::array(0, new NextAction("unstealth", 30.0f), NULL)));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user