From 6f8a8d92535d606afae58b1e5549bda712dc3f9d Mon Sep 17 00:00:00 2001 From: Yunfan Li Date: Fri, 4 Aug 2023 23:14:21 +0800 Subject: [PATCH] temporary disable rndbot group strategy --- src/AiFactory.cpp | 4 +- src/PlayerbotMgr.cpp | 112 +++++++++++------------ src/RandomPlayerbotMgr.cpp | 6 +- src/strategy/actions/MovementActions.cpp | 3 +- src/strategy/values/LootStrategyValue.h | 2 +- 5 files changed, 64 insertions(+), 63 deletions(-) diff --git a/src/AiFactory.cpp b/src/AiFactory.cpp index 733da71d..5f9ec3ac 100644 --- a/src/AiFactory.cpp +++ b/src/AiFactory.cpp @@ -547,7 +547,7 @@ void AiFactory::AddDefaultNonCombatStrategies(Player* player, PlayerbotAI* const nonCombatEngine->addStrategy("pvp"); // nonCombatEngine->addStrategy("collision"); nonCombatEngine->addStrategy("grind"); - nonCombatEngine->addStrategy("group"); + // nonCombatEngine->addStrategy("group"); // nonCombatEngine->addStrategy("guild"); if (sPlayerbotAIConfig->autoDoQuests) @@ -578,7 +578,7 @@ void AiFactory::AddDefaultNonCombatStrategies(Player* player, PlayerbotAI* const nonCombatEngine->addStrategy("pvp"); // nonCombatEngine->addStrategy("collision"); nonCombatEngine->addStrategy("grind"); - nonCombatEngine->addStrategy("group"); + // nonCombatEngine->addStrategy("group"); // nonCombatEngine->addStrategy("guild"); if (sPlayerbotAIConfig->autoDoQuests) diff --git a/src/PlayerbotMgr.cpp b/src/PlayerbotMgr.cpp index 3776c518..2d54c099 100644 --- a/src/PlayerbotMgr.cpp +++ b/src/PlayerbotMgr.cpp @@ -523,72 +523,72 @@ std::string const PlayerbotHolder::ProcessBotCommand(std::string const cmd, Obje return "ok"; } - if (admin) + // if (admin) + // { + Player* bot = GetPlayerBot(guid); + if (!bot) + bot = sRandomPlayerbotMgr->GetPlayerBot(guid); + + if (!bot) + return "bot not found"; + + if (!isRandomAccount || isRandomBot) { + return "ERROR: You can not use this command on summoned random bot."; + } + + if (Player* master = GET_PLAYERBOT_AI(bot)->GetMaster()) { - Player* bot = GetPlayerBot(guid); - if (!bot) - bot = sRandomPlayerbotMgr->GetPlayerBot(guid); - - if (!bot) - return "bot not found"; - - if (!isRandomAccount || !isRandomBot) { - return "ERROR: You can not use this command on non-ramdom bot."; - } - - if (Player* master = GET_PLAYERBOT_AI(bot)->GetMaster()) + if (cmd == "init=white" || cmd == "init=common") { - if (cmd == "init=white" || cmd == "init=common") - { - PlayerbotFactory factory(bot, master->getLevel(), ITEM_QUALITY_NORMAL); - factory.Randomize(false); - return "ok"; - } - else if (cmd == "init=green" || cmd == "init=uncommon") - { - PlayerbotFactory factory(bot, master->getLevel(), ITEM_QUALITY_UNCOMMON); - factory.Randomize(false); - return "ok"; - } - else if (cmd == "init=blue" || cmd == "init=rare") - { - PlayerbotFactory factory(bot, master->getLevel(), ITEM_QUALITY_RARE); - factory.Randomize(false); - return "ok"; - } - else if (cmd == "init=epic" || cmd == "init=purple") - { - PlayerbotFactory factory(bot, master->getLevel(), ITEM_QUALITY_EPIC); - factory.Randomize(false); - return "ok"; - } - else if (cmd == "init=legendary" || cmd == "init=yellow") - { - PlayerbotFactory factory(bot, master->getLevel(), ITEM_QUALITY_LEGENDARY); - factory.Randomize(false); - return "ok"; - } - } - - if (cmd == "levelup" || cmd == "level") - { - PlayerbotFactory factory(bot, bot->getLevel()); - factory.Randomize(true); + PlayerbotFactory factory(bot, master->getLevel(), ITEM_QUALITY_NORMAL); + factory.Randomize(false); return "ok"; } - else if (cmd == "refresh") + else if (cmd == "init=green" || cmd == "init=uncommon") { - PlayerbotFactory factory(bot, bot->getLevel()); - factory.Refresh(); + PlayerbotFactory factory(bot, master->getLevel(), ITEM_QUALITY_UNCOMMON); + factory.Randomize(false); return "ok"; } - else if (cmd == "random") + else if (cmd == "init=blue" || cmd == "init=rare") { - sRandomPlayerbotMgr->Randomize(bot); + PlayerbotFactory factory(bot, master->getLevel(), ITEM_QUALITY_RARE); + factory.Randomize(false); + return "ok"; + } + else if (cmd == "init=epic" || cmd == "init=purple") + { + PlayerbotFactory factory(bot, master->getLevel(), ITEM_QUALITY_EPIC); + factory.Randomize(false); + return "ok"; + } + else if (cmd == "init=legendary" || cmd == "init=yellow") + { + PlayerbotFactory factory(bot, master->getLevel(), ITEM_QUALITY_LEGENDARY); + factory.Randomize(false); return "ok"; } } + if (cmd == "levelup" || cmd == "level") + { + PlayerbotFactory factory(bot, bot->getLevel()); + factory.Randomize(true); + return "ok"; + } + else if (cmd == "refresh") + { + PlayerbotFactory factory(bot, bot->getLevel()); + factory.Refresh(); + return "ok"; + } + else if (cmd == "random") + { + sRandomPlayerbotMgr->Randomize(bot); + return "ok"; + } + // } + return "unknown command"; } @@ -810,7 +810,7 @@ std::vector PlayerbotHolder::HandlePlayerbotCommand(char const* arg std::string const cmdStr = cmd; std::string const charnameStr = charname; - + std::set bots; if (charnameStr == "*" && master) { @@ -883,7 +883,7 @@ std::vector PlayerbotHolder::HandlePlayerbotCommand(char const* arg } else if (master && member != master->GetGUID()) { - out << ProcessBotCommand(cmdStr, member, master->GetGUID(), true, master->GetSession()->GetAccountId(), master->GetGuildId()); + out << ProcessBotCommand(cmdStr, member, master->GetGUID(), master->GetSession()->GetSecurity() >= SEC_GAMEMASTER, master->GetSession()->GetAccountId(), master->GetGuildId()); } else if (!master) { diff --git a/src/RandomPlayerbotMgr.cpp b/src/RandomPlayerbotMgr.cpp index 31c195ba..bdf312db 100644 --- a/src/RandomPlayerbotMgr.cpp +++ b/src/RandomPlayerbotMgr.cpp @@ -941,7 +941,7 @@ bool RandomPlayerbotMgr::ProcessBot(Player* player) uint32 teleport = GetEventValue(bot, "teleport"); if (!teleport) { - LOG_INFO("players", "Bot #{} <{}>: teleport for level and refresh", bot, player->GetName()); + LOG_INFO("playerbots", "Bot #{} <{}>: teleport for level and refresh", bot, player->GetName()); Refresh(player); RandomTeleportForLevel(player); uint32 time = urand(sPlayerbotAIConfig->minRandomBotTeleportInterval, sPlayerbotAIConfig->maxRandomBotTeleportInterval); @@ -1490,8 +1490,8 @@ bool RandomPlayerbotMgr::IsRandomBot(Player* bot) bool RandomPlayerbotMgr::IsRandomBot(ObjectGuid::LowType bot) { ObjectGuid guid = ObjectGuid::Create(bot); - if (sPlayerbotAIConfig->IsInRandomAccountList(sCharacterCache->GetCharacterAccountIdByGuid(guid))) - return true; + if (!sPlayerbotAIConfig->IsInRandomAccountList(sCharacterCache->GetCharacterAccountIdByGuid(guid))) + return false; return GetEventValue(bot, "add"); } diff --git a/src/strategy/actions/MovementActions.cpp b/src/strategy/actions/MovementActions.cpp index 1a6eabaa..b1743802 100644 --- a/src/strategy/actions/MovementActions.cpp +++ b/src/strategy/actions/MovementActions.cpp @@ -135,6 +135,7 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle, if (!IsMovingAllowed(mapId, x, y, z)) { return false; } + UpdateMovementState(); // if (bot->m_movementInfo.HasMovementFlag(MOVEMENTFLAG_FALLING | MOVEMENTFLAG_FALLING_SLOW | MOVEMENTFLAG_FALLING_FAR)) { // bot->Say("I'm falling!, flag:" + std::to_string(bot->m_movementInfo.GetMovementFlags()), LANG_UNIVERSAL); // return false; @@ -166,7 +167,7 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle, } return false; - // UpdateMovementState(); + // // // LOG_DEBUG("playerbots", "IsMovingAllowed {}", IsMovingAllowed()); // bot->AddUnitMovementFlag() diff --git a/src/strategy/values/LootStrategyValue.h b/src/strategy/values/LootStrategyValue.h index 0788eab5..93ae94b1 100644 --- a/src/strategy/values/LootStrategyValue.h +++ b/src/strategy/values/LootStrategyValue.h @@ -13,7 +13,7 @@ class PlayerbotAI; class LootStrategyValue : public ManualSetValue { public: - LootStrategyValue(PlayerbotAI* botAI, std::string const name = "loot strategy") : ManualSetValue(botAI, all, name) { } + LootStrategyValue(PlayerbotAI* botAI, std::string const name = "loot strategy") : ManualSetValue(botAI, normal, name) { } virtual ~LootStrategyValue(); std::string const Save() override;