Working on botgroup removal

This commit is contained in:
neckkola
2022-01-23 23:49:00 -04:00
parent 5a9c8c18c1
commit 19004730ad
4 changed files with 108 additions and 33 deletions
+11 -2
View File
@@ -8426,8 +8426,10 @@ void Bot::Camp(bool databaseSave) {
//Mitch //Mitch
Raid* bot_raid = entity_list.GetRaidByBotName(this->GetName()); Raid* bot_raid = entity_list.GetRaidByBotName(this->GetName());
if (bot_raid) { if (bot_raid) {
uint32 gid = bot_raid->GetGroup(this->GetName());
bot_raid->SendRaidGroupRemove(this->GetName(), bot_raid->GetGroup(this->GetName())); bot_raid->SendRaidGroupRemove(this->GetName(), bot_raid->GetGroup(this->GetName()));
bot_raid->RemoveMember(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) { void Bot::ProcessBotGroupInvite(Client* c, std::string botName) {
if(c) { 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 //Mitch changed entity from c
if(invitedBot && !invitedBot->HasGroup()) { if(invitedBot && !invitedBot->HasGroup()) {
if(!c->IsGrouped()) { 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) { void Bot::ProcessRaidInvite(Client* invitee, Client* invitor) {
if (!invitee || !invitor)
return;
Raid* raid = entity_list.GetRaidByClient(invitor); Raid* raid = entity_list.GetRaidByClient(invitor);
Group* g_invitee = invitee->GetGroup(); Group* g_invitee = invitee->GetGroup();
Group* g_invitor = invitor->GetGroup(); Group* g_invitor = invitor->GetGroup();
@@ -10560,6 +10566,9 @@ void Bot::ProcessRaidInvite(Client* invitee, Client* invitor) {
void Bot::ProcessRaidInvite(Bot* invitee, Client* invitor) { void Bot::ProcessRaidInvite(Bot* invitee, Client* invitor) {
if (!invitee || !invitor)
return;
Raid* raid = entity_list.GetRaidByClient(invitor); Raid* raid = entity_list.GetRaidByClient(invitor);
Group* g_invitee = invitee->GetGroup(); Group* g_invitee = invitee->GetGroup();
Group* g_invitor = invitor->GetGroup(); Group* g_invitor = invitor->GetGroup();
@@ -10686,7 +10695,7 @@ void Bot::ProcessRaidInvite(Bot* invitee, Client* invitor) {
// raid->GroupUpdate(0, true); // raid->GroupUpdate(0, true);
// raid->SendBulkRaid(invitee); //Send a raid updates to the invitor // raid->SendBulkRaid(invitee); //Send a raid updates to the invitor
g_invitor->JoinRaidXTarget(raid, true); 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); raid->GroupUpdate(0, true);
if (raid->IsLocked()) { if (raid->IsLocked()) {
raid->SendRaidLockTo(invitor); raid->SendRaidLockTo(invitor);
+4 -1
View File
@@ -74,7 +74,10 @@ void Bot::AI_Process_Raid()
// We also need a leash owner and follow mob (subset of primary AI criteria) // We also need a leash owner and follow mob (subset of primary AI criteria)
Client* leash_owner = nullptr; 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); leash_owner = raid->GetGroupLeader(r_group);
} }
else { else {
+69 -18
View File
@@ -11756,10 +11756,79 @@ void Client::Handle_OP_RaidCommand(const EQApplicationPacket* app)
case RaidCommandDisband: { case RaidCommandDisband: {
Raid* raid = entity_list.GetRaidByClient(this); Raid* raid = entity_list.GetRaidByClient(this);
Client* c = entity_list.GetClientByName(raid_command_packet->leader_name); Client* c = entity_list.GetClientByName(raid_command_packet->leader_name);
Bot* b = entity_list.GetBotByBotName(raid_command_packet->leader_name);
if (raid) { if (raid) {
uint32 group = raid->GetGroup(raid_command_packet->leader_name); 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<Bot*> 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<RaidMember> 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<RaidMember> 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) { if (group < 12) {
uint32 i = raid->GetPlayerIndex(raid_command_packet->leader_name); uint32 i = raid->GetPlayerIndex(raid_command_packet->leader_name);
if (raid->members[i].IsGroupLeader) { //assign group leader to someone else 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); raid->RemoveMember(raid_command_packet->leader_name);
Client* c = entity_list.GetClientByName(raid_command_packet->leader_name); Client* c = entity_list.GetClientByName(raid_command_packet->leader_name);
if (c) { 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<Bot*> 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); raid->SendGroupDisband(c);
} }
+24 -12
View File
@@ -110,6 +110,14 @@ void Raid::AddMember(Client *c, uint32 group, bool rleader, bool groupleader, bo
LearnMembers(); LearnMembers();
VerifyRaid(); VerifyRaid();
#ifdef BOTS
if (rleader) {
database.SetRaidGroupLeaderInfo(group, GetID());
UpdateRaidAAs();
}
else
#endif
if (rleader) { if (rleader) {
database.SetRaidGroupLeaderInfo(RAID_GROUPLESS, GetID()); database.SetRaidGroupLeaderInfo(RAID_GROUPLESS, GetID());
UpdateRaidAAs(); UpdateRaidAAs();
@@ -182,18 +190,22 @@ void Raid::AddBot(Bot* b, uint32 group, bool rleader, bool groupleader, bool loo
LearnMembers(); LearnMembers();
VerifyRaid(); VerifyRaid();
if (rleader) { // Bots are being invited and cannot be the raid leader
database.SetRaidGroupLeaderInfo(RAID_GROUPLESS, GetID()); // if (rleader) {
UpdateRaidAAs(); // database.SetRaidGroupLeaderInfo(RAID_GROUPLESS, GetID());
} // UpdateRaidAAs();
if (group != RAID_GROUPLESS && groupleader) { // }
database.SetRaidGroupLeaderInfo(group, GetID());
//UpdateGroupAAs(group); // Bots can be group leaders, though they do not have GroupAA
} // if (group != RAID_GROUPLESS && groupleader) {
// if (group < 12) // database.SetRaidGroupLeaderInfo(group, GetID());
// GroupUpdate(group); // UpdateGroupAAs(group); //Mitch Jan 22
// else // get raid AAs, GroupUpdate will handles it otherwise // }
//SendGroupLeadershipAA(c, RAID_GROUPLESS); Is this needed for bots?
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()); SendRaidAddAll(b->GetName());
b->SetRaidGrouped(true); b->SetRaidGrouped(true);