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)
|
||||
# default: 1 (enable)
|
||||
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)
|
||||
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.)
|
||||
# Default: 1 (enable)
|
||||
@@ -656,7 +662,7 @@ AiPlayerbot.RandomBotArenaTeamCount = 20
|
||||
AiPlayerbot.DeleteRandomBotArenaTeams = 0
|
||||
|
||||
# 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)
|
||||
AiPlayerbot.PvpProhibitedAreaIds = "976,35,392"
|
||||
|
||||
@@ -283,6 +283,9 @@ bool PlayerbotAIConfig::Initialize()
|
||||
botRepairWhenSummon = sConfigMgr->GetOption<bool>("AiPlayerbot.BotRepairWhenSummon", true);
|
||||
autoInitOnly = sConfigMgr->GetOption<bool>("AiPlayerbot.AutoInitOnly", false);
|
||||
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);
|
||||
maintenanceCommand = sConfigMgr->GetOption<int32>("AiPlayerbot.MaintenanceCommand", 1);
|
||||
autoGearCommand = sConfigMgr->GetOption<int32>("AiPlayerbot.AutoGearCommand", 1);
|
||||
|
||||
@@ -224,6 +224,7 @@ class PlayerbotAIConfig
|
||||
bool botRepairWhenSummon;
|
||||
bool autoInitOnly;
|
||||
float autoInitEquipLevelLimitRatio;
|
||||
int32 maxAddedBots, maxAddedBotsPerClass;
|
||||
int32 addClassCommand;
|
||||
int32 maintenanceCommand;
|
||||
int32 autoGearCommand, autoGearQualityLimit, autoGearScoreLimit;
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
#include "CharacterPackets.h"
|
||||
#include "Common.h"
|
||||
#include "Define.h"
|
||||
#include "Group.h"
|
||||
#include "GroupMgr.h"
|
||||
#include "ObjectAccessor.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "PlayerbotAIConfig.h"
|
||||
@@ -19,6 +21,7 @@
|
||||
#include "ChannelMgr.h"
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <istream>
|
||||
#include <string>
|
||||
|
||||
PlayerbotHolder::PlayerbotHolder() : PlayerbotAIBase(false)
|
||||
@@ -89,25 +92,42 @@ void PlayerbotHolder::HandlePlayerBotLoginCallback(PlayerbotLoginQueryHolder con
|
||||
Player* bot = botSession->GetPlayer();
|
||||
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());
|
||||
return;
|
||||
}
|
||||
|
||||
sRandomPlayerbotMgr->OnPlayerLogin(bot);
|
||||
|
||||
uint32 masterAccount = holder.GetMasterAccountId();
|
||||
WorldSession* masterSession = masterAccount ? sWorld->FindSession(masterAccount) : nullptr;
|
||||
std::ostringstream out;
|
||||
bool allowed = false;
|
||||
if (botAccountId == masterAccount)
|
||||
if (botAccountId == masterAccount) {
|
||||
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;
|
||||
else if (sPlayerbotAIConfig->IsInRandomAccountList(botAccountId))
|
||||
} else if (sPlayerbotAIConfig->IsInRandomAccountList(botAccountId)) {
|
||||
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)
|
||||
{
|
||||
sRandomPlayerbotMgr->OnPlayerLogin(bot);
|
||||
OnBotLogin(bot);
|
||||
}
|
||||
else
|
||||
@@ -115,10 +135,12 @@ void PlayerbotHolder::HandlePlayerBotLoginCallback(PlayerbotLoginQueryHolder con
|
||||
if (masterSession)
|
||||
{
|
||||
ChatHandler ch(masterSession);
|
||||
ch.PSendSysMessage("You are not allowed to control bot %s", bot->GetName());
|
||||
ch.SendSysMessage(out.str());
|
||||
}
|
||||
OnBotLogin(bot);
|
||||
LogoutPlayerBot(bot->GetGUID());
|
||||
botSession->LogoutPlayer(true);
|
||||
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());
|
||||
}
|
||||
@@ -453,7 +475,22 @@ void PlayerbotHolder::OnBotLogin(Player* const bot)
|
||||
botAI->TellMaster("Hello!", PLAYERBOT_SECURITY_TALK);
|
||||
|
||||
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();
|
||||
@@ -1157,6 +1194,19 @@ std::string const PlayerbotHolder::LookupBots(Player* master)
|
||||
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)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -48,7 +48,8 @@ class PlayerbotHolder : public PlayerbotAIBase
|
||||
uint32 GetAccountId(ObjectGuid guid);
|
||||
std::string const ListBots(Player* master);
|
||||
std::string const LookupBots(Player* master);
|
||||
|
||||
uint32 GetPlayerbotsCount() { return playerBots.size(); }
|
||||
uint32 GetPlayerbotsCountByClass(uint32 cls);
|
||||
protected:
|
||||
virtual void OnBotLoginInternal(Player* const bot) = 0;
|
||||
|
||||
|
||||
@@ -137,6 +137,8 @@ std::string const QueryItemUsageAction::QueryItemUsage(ItemTemplate const* item)
|
||||
return "Auctionhouse";
|
||||
case ITEM_USAGE_AMMO:
|
||||
return "Ammunition";
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return "";
|
||||
|
||||
@@ -588,11 +588,12 @@ void ChatReplyAction::ChatReplyDo(Player* bot, uint32 type, uint32 guid1, uint32
|
||||
if (ChannelMgr* cMgr = ChannelMgr::forTeam(bot->GetTeamId()))
|
||||
{
|
||||
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)
|
||||
chn->Say(bot->GetGUID(), c, LANG_COMMON);
|
||||
else
|
||||
chn->Say(bot->GetGUID(), c, LANG_ORCISH);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -151,7 +151,7 @@ void TrainerAction::TellFooter(uint32 totalCost)
|
||||
bool MaintenanceAction::Execute(Event event)
|
||||
{
|
||||
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;
|
||||
}
|
||||
botAI->TellMaster("I'm maintaining");
|
||||
@@ -187,7 +187,7 @@ bool RemoveGlyphAction::Execute(Event event)
|
||||
bool AutoGearAction::Execute(Event event)
|
||||
{
|
||||
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;
|
||||
}
|
||||
botAI->TellMaster("I'm auto gearing");
|
||||
|
||||
@@ -51,5 +51,5 @@ void GenericRogueNonCombatStrategy::InitTriggers(std::vector<TriggerNode*>& trig
|
||||
|
||||
triggers.push_back(new TriggerNode(
|
||||
"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