diff --git a/zone/bot_raid.cpp b/zone/bot_raid.cpp index 13537e0e8..a0ba2c8c6 100644 --- a/zone/bot_raid.cpp +++ b/zone/bot_raid.cpp @@ -116,6 +116,30 @@ void Raid::HandleBotGroupDisband(uint32 owner, uint32 gid) } } +// we need to cleanup any camped/offline bots when the owner leaves the Raid +void Raid::HandleOfflineBots(uint32 owner) { + std::list bots_list; + if (!database.botdb.LoadBotsList(owner, bots_list)) { + return; + } + + for (const auto& b: bots_list) { + if (IsRaidMember(b.Name)) { + for (const auto& m: members) { + if (m.is_bot && strcmp(m.member_name, b.Name) == 0) { + uint32 gid = GetGroup(m.member_name); + SendRaidGroupRemove(m.member_name, gid); + RemoveMember(m.member_name); + GroupUpdate(gid); + if (!RaidCount()) { + DisbandRaid(); + } + } + } + } + } +} + uint8 Bot::GetNumberNeedingHealedInRaidGroup(uint8& need_healed, uint8 hpr, bool includePets, Raid* raid) { if (raid) { @@ -170,8 +194,8 @@ void Bot::CreateBotRaid(Mob* invitee, Client* invitor, bool group_invite, Raid* Group* g_invitee = invitee->GetGroup(); Group* g_invitor = invitor->GetGroup(); - if (g_invitee && invitor->IsClient()) { - if (!g_invitee->IsLeader(invitee)) { + if (g_invitee && invitor->IsClient() && !g_invitee->IsLeader(invitee)) { + if (g_invitee->GetLeader()) { invitor->Message( Chat::Red, fmt::format( @@ -180,6 +204,9 @@ void Bot::CreateBotRaid(Mob* invitee, Client* invitor, bool group_invite, Raid* ).c_str() ); return; + } else { + invitor->Message(Chat::Red, "You can only invite group leaders or ungrouped bots."); + return; } } diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 4e67608f5..1980926c0 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -12180,6 +12180,7 @@ void Client::Handle_OP_RaidCommand(const EQApplicationPacket* app) uint32 i = raid->GetPlayerIndex(raid_command_packet->leader_name); raid->SetNewRaidLeader(i); raid->HandleBotGroupDisband(c_to_disband->CharacterID()); + raid->HandleOfflineBots(c_to_disband->CharacterID()); raid->RemoveMember(raid_command_packet->leader_name); raid->SendGroupDisband(c_to_disband); raid->GroupUpdate(group); diff --git a/zone/raids.cpp b/zone/raids.cpp index bd28bbfe4..54250e680 100644 --- a/zone/raids.cpp +++ b/zone/raids.cpp @@ -1703,11 +1703,10 @@ void Raid::VerifyRaid() //attribute before calling a client function or casting to client. b = entity_list.GetBotByBotName(m.member_name); m.member = b->CastToClient(); - m.is_bot = true; //Used to identify those members who are Bots + m.is_bot = true; } else { m.member = nullptr; - m.is_bot = false; } } diff --git a/zone/raids.h b/zone/raids.h index b8eadbc7b..d3fd1fe3c 100644 --- a/zone/raids.h +++ b/zone/raids.h @@ -256,6 +256,7 @@ public: std::vector GetRaidGroupBotMembers(uint32 gid); std::vector GetRaidBotMembers(uint32 owner = 0); void HandleBotGroupDisband(uint32 owner, uint32 gid = RAID_GROUPLESS); + void HandleOfflineBots(uint32 owner); RaidMember members[MAX_RAID_MEMBERS]; char leadername[64];