diff --git a/zone/bot_raid.cpp b/zone/bot_raid.cpp index a0ba2c8c6..57bdbc16b 100644 --- a/zone/bot_raid.cpp +++ b/zone/bot_raid.cpp @@ -17,6 +17,8 @@ */ #include "bot.h" +#include "bot_command.h" +#include "client.h" #include "object.h" #include "raids.h" #include "doors.h" @@ -296,4 +298,30 @@ void Bot::ProcessBotGroupAdd(Group* group, Raid* raid, Client* client, bool new_ raid->GroupUpdate(raid_free_group_id); } +void Client::SpawnRaidBotsOnConnect(Raid* raid) { + std::list bots_list; + if (!database.botdb.LoadBotsList(CharacterID(), bots_list) || bots_list.empty()) { + return; + } + + std::vector r_members = raid->GetMembers(); + for (const auto& m: r_members) { + if (strlen(m.member_name) != 0) { + + for (const auto& b: bots_list) { + if (strcmp(m.member_name, b.Name) == 0) { + std::string buffer = "^spawn "; + buffer.append(m.member_name); + bot_command_real_dispatch(this, buffer.c_str()); + auto bot = entity_list.GetBotByBotName(m.member_name); + + if (bot) { + bot->SetRaidGrouped(true); + bot->p_raid_instance = raid; + } + } + } + } + } +} diff --git a/zone/client.h b/zone/client.h index a5b124639..2f5d80383 100644 --- a/zone/client.h +++ b/zone/client.h @@ -2033,6 +2033,7 @@ public: void SetBotSpawnLimit(int new_spawn_limit, uint8 class_id = NO_CLASS); void CampAllBots(uint8 class_id = NO_CLASS); + void SpawnRaidBotsOnConnect(Raid* raid); private: bool bot_owner_options[_booCount]; @@ -2042,7 +2043,6 @@ private: bool CanTradeFVNoDropItem(); void SendMobPositions(); void PlayerTradeEventLog(Trade *t, Trade *t2); - }; #endif diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 22989ce8d..6bf2f5c1a 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -607,28 +607,8 @@ void Client::CompleteConnect() if (raid) { SetRaidGrouped(true); raid->LearnMembers(); - std::list bots_list; - database.botdb.LoadBotsList(this->CharacterID(), bots_list); - std::vector r_members = raid->GetMembers(); - for (const RaidMember& iter : r_members) { - if (iter.member_name) { - for (const BotsAvailableList& b_iter : bots_list) - { - if (strcmp(iter.member_name, b_iter.Name) == 0) - { - char buffer[71] = "^spawn "; - strcat(buffer, iter.member_name); - bot_command_real_dispatch(this, buffer); - Bot* b = entity_list.GetBotByBotName(iter.member_name); - if (b) - { - b->SetRaidGrouped(true); - b->p_raid_instance = raid; - //b->SetFollowID(this->GetID()); - } - } - } - } + if (RuleB(Bots, Enabled)) { + SpawnRaidBotsOnConnect(raid); } raid->VerifyRaid(); raid->GetRaidDetails();