diff --git a/zone/bot.cpp b/zone/bot.cpp index f5bb347fd..2caf3abc0 100644 --- a/zone/bot.cpp +++ b/zone/bot.cpp @@ -8426,8 +8426,10 @@ void Bot::Camp(bool databaseSave) { //Mitch Raid* bot_raid = entity_list.GetRaidByBotName(this->GetName()); if (bot_raid) { + uint32 gid = bot_raid->GetGroup(this->GetName()); bot_raid->SendRaidGroupRemove(this->GetName(), bot_raid->GetGroup(this->GetName())); bot_raid->RemoveMember(this->GetName()); + bot_raid->GroupUpdate(gid); } @@ -8655,7 +8657,8 @@ Bot* Bot::GetBotByBotClientOwnerAndBotName(Client* c, std::string botName) { void Bot::ProcessBotGroupInvite(Client* c, std::string botName) { if(c) { - Bot* invitedBot = GetBotByBotClientOwnerAndBotName(entity_list.GetBotByBotName(botName)->GetOwner()->CastToClient(), botName); +// Bot* invitedBot = GetBotByBotClientOwnerAndBotName(entity_list.GetBotByBotName(botName)->GetOwner()->CastToClient(), botName); + Bot* invitedBot = GetBotByBotClientOwnerAndBotName(c, botName); //Mitch changed entity from c if(invitedBot && !invitedBot->HasGroup()) { if(!c->IsGrouped()) { @@ -10292,6 +10295,9 @@ uint8 Bot::spell_casting_chances[SPELL_TYPE_COUNT][PLAYER_CLASS_COUNT][EQ::const void Bot::ProcessRaidInvite(Client* invitee, Client* invitor) { + if (!invitee || !invitor) + return; + Raid* raid = entity_list.GetRaidByClient(invitor); Group* g_invitee = invitee->GetGroup(); Group* g_invitor = invitor->GetGroup(); @@ -10560,6 +10566,9 @@ void Bot::ProcessRaidInvite(Client* invitee, Client* invitor) { void Bot::ProcessRaidInvite(Bot* invitee, Client* invitor) { + if (!invitee || !invitor) + return; + Raid* raid = entity_list.GetRaidByClient(invitor); Group* g_invitee = invitee->GetGroup(); Group* g_invitor = invitor->GetGroup(); @@ -10686,7 +10695,7 @@ void Bot::ProcessRaidInvite(Bot* invitee, Client* invitor) { // raid->GroupUpdate(0, true); // raid->SendBulkRaid(invitee); //Send a raid updates to the invitor g_invitor->JoinRaidXTarget(raid, true); -// g_invitor->DisbandGroup(true); + g_invitor->DisbandGroup(true); //Added Jan 23 to fix group database and entity integrity raid->GroupUpdate(0, true); if (raid->IsLocked()) { raid->SendRaidLockTo(invitor); diff --git a/zone/bot_raid.cpp b/zone/bot_raid.cpp index 3d946b292..c66fa32ff 100644 --- a/zone/bot_raid.cpp +++ b/zone/bot_raid.cpp @@ -74,7 +74,10 @@ void Bot::AI_Process_Raid() // We also need a leash owner and follow mob (subset of primary AI criteria) Client* leash_owner = nullptr; - if (r_group < 12 && !leash_owner) { + if (r_group < 12 && raid->IsGroupLeader(this->GetName())) { + leash_owner = raid->GetLeader(); + } + else if (r_group < 12) { leash_owner = raid->GetGroupLeader(r_group); } else { diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 7e7d3b60e..996071459 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -11756,10 +11756,79 @@ void Client::Handle_OP_RaidCommand(const EQApplicationPacket* app) case RaidCommandDisband: { Raid* raid = entity_list.GetRaidByClient(this); Client* c = entity_list.GetClientByName(raid_command_packet->leader_name); + Bot* b = entity_list.GetBotByBotName(raid_command_packet->leader_name); if (raid) { uint32 group = raid->GetGroup(raid_command_packet->leader_name); +#ifdef BOTS + //Mitch added to remove all bots if the Bot_Owner is removed from the Raid + //Does not camp the Bots, just removes from the raid + std::vector raid_members_bots; + if (c) + { + int owner_id = c->CharacterID(); + for (int i = 0; i < MAX_RAID_MEMBERS; ++i) + { + if (raid->members[i].member && raid->members[i].member->IsBot() && raid->members[i].member->CastToBot()->GetOwner()->CastToClient()->CharacterID() == owner_id) + { + raid_members_bots.emplace_back(raid->members[i].member->CastToBot()); + } + } + // If the bot is a group leader then re-create the botgroup, dropping any clients + for (auto bot_iter : raid_members_bots) { + if (bot_iter && bot_iter->IsBot()) + if (raid->IsGroupLeader(bot_iter->GetName())) + { + uint32 gid = raid->GetGroup(bot_iter->GetName()); + std::vector r_group_members = raid->GetRaidGroupMembers(gid); + Group* group_inst = new Group(bot_iter); + entity_list.AddGroup(group_inst); + database.SetGroupID(bot_iter->GetCleanName(), group_inst->GetID(), bot_iter->GetBotID()); + database.SetGroupLeaderName(group_inst->GetID(), bot_iter->GetCleanName()); + bot_iter->SetFollowID(c->GetID()); + for (auto member_iter : r_group_members) { + if (!member_iter.member->IsClient() && strcmp(member_iter.membername, bot_iter->GetName()) == 0) + bot_iter->SetFollowID(owner_id); + else + Bot::AddBotToGroup(member_iter.member->CastToBot(), group_inst); + } + } + raid->RemoveMember(bot_iter->GetName()); + } + } + else if (b) + { + uint32 gid = raid->GetGroup(raid_command_packet->leader_name); + if (gid < 12 && raid->GetGroupLeader(gid)->IsBot()) + { + Client* c2 = entity_list.GetClientByName(raid_command_packet->player_name); + if (c2 && !raid->IsGroupLeader(raid_command_packet->leader_name)) { + c2->Message(Chat::Red, "%s is in a Bot Group. Please disband %s instead.", + raid_command_packet->leader_name, raid->GetGroupLeader(gid)->CastToBot()->GetName()); + break; + } + else + { + uint32 gid = raid->GetGroup(b->GetName()); + std::vector r_group_members = raid->GetRaidGroupMembers(gid); + Group* group_inst = new Group(b); + entity_list.AddGroup(group_inst); + database.SetGroupID(b->GetCleanName(), group_inst->GetID(), b->GetBotID()); + database.SetGroupLeaderName(group_inst->GetID(), b->GetCleanName()); + for (auto member_iter : r_group_members) { + if (!member_iter.member->IsClient() && strcmp(member_iter.membername, b->GetName()) == 0) + member_iter.member->SetFollowID(b->GetOwner()->CastToClient()->GetID()); + else + Bot::AddBotToGroup(member_iter.member->CastToBot(), group_inst); + raid->RemoveMember(member_iter.membername); + } + + } + + } + } +#endif if (group < 12) { uint32 i = raid->GetPlayerIndex(raid_command_packet->leader_name); if (raid->members[i].IsGroupLeader) { //assign group leader to someone else @@ -11790,24 +11859,6 @@ void Client::Handle_OP_RaidCommand(const EQApplicationPacket* app) raid->RemoveMember(raid_command_packet->leader_name); Client* c = entity_list.GetClientByName(raid_command_packet->leader_name); if (c) { -#ifdef BOTS - - //Mitch added to remove all bots if the Bot_Owner is removed from the Raid - //Does not camp the Bots, just removes from the raid - std::vector raid_members_bots; - int owner_id = entity_list.GetClientByName(raid_command_packet->leader_name)->CharacterID(); - for (int i = 0; i < MAX_RAID_MEMBERS; ++i) - { - if (raid->members[i].member && raid->members[i].member->IsBot() && raid->members[i].member->CastToBot()->GetOwner()->CastToClient()->CharacterID() == owner_id) - { - raid_members_bots.emplace_back(raid->members[i].member->CastToBot()); - } - } - for (auto bot_iter : raid_members_bots) { - if (bot_iter && bot_iter->IsBot()) - raid->RemoveMember(bot_iter->GetName()); - } -#endif raid->SendGroupDisband(c); } diff --git a/zone/raids.cpp b/zone/raids.cpp index 689aff450..ac83812ff 100644 --- a/zone/raids.cpp +++ b/zone/raids.cpp @@ -110,6 +110,14 @@ void Raid::AddMember(Client *c, uint32 group, bool rleader, bool groupleader, bo LearnMembers(); VerifyRaid(); + +#ifdef BOTS + if (rleader) { + database.SetRaidGroupLeaderInfo(group, GetID()); + UpdateRaidAAs(); + } + else +#endif if (rleader) { database.SetRaidGroupLeaderInfo(RAID_GROUPLESS, GetID()); UpdateRaidAAs(); @@ -182,18 +190,22 @@ void Raid::AddBot(Bot* b, uint32 group, bool rleader, bool groupleader, bool loo LearnMembers(); VerifyRaid(); - if (rleader) { - database.SetRaidGroupLeaderInfo(RAID_GROUPLESS, GetID()); - UpdateRaidAAs(); - } - if (group != RAID_GROUPLESS && groupleader) { - database.SetRaidGroupLeaderInfo(group, GetID()); - //UpdateGroupAAs(group); - } -// if (group < 12) -// GroupUpdate(group); -// else // get raid AAs, GroupUpdate will handles it otherwise - //SendGroupLeadershipAA(c, RAID_GROUPLESS); Is this needed for bots? +// Bots are being invited and cannot be the raid leader +// if (rleader) { +// database.SetRaidGroupLeaderInfo(RAID_GROUPLESS, GetID()); +// UpdateRaidAAs(); +// } + +// Bots can be group leaders, though they do not have GroupAA +// if (group != RAID_GROUPLESS && groupleader) { +// database.SetRaidGroupLeaderInfo(group, GetID()); +// UpdateGroupAAs(group); //Mitch Jan 22 +// } + + if (group < 12) //Jan22 + GroupUpdate(group); //Jan22 + else // get raid AAs, GroupUpdate will handles it otherwise Jan 22 + SendGroupLeadershipAA(b->GetOwner()->CastToClient(), RAID_GROUPLESS); //Is this needed for bots? Jan 22 SendRaidAddAll(b->GetName()); b->SetRaidGrouped(true);