Bot Invite/Accept cleanup

This commit is contained in:
neckkola
2022-01-12 18:47:56 -04:00
parent d62171f34d
commit 6411c2335e
3 changed files with 553 additions and 556 deletions
+1 -1
View File
@@ -10115,7 +10115,7 @@ void Bot::StopMoving(float new_heading)
uint8 Bot::spell_casting_chances[SPELL_TYPE_COUNT][PLAYER_CLASS_COUNT][EQ::constants::STANCE_TYPE_COUNT][cntHSND] = { 0 }; uint8 Bot::spell_casting_chances[SPELL_TYPE_COUNT][PLAYER_CLASS_COUNT][EQ::constants::STANCE_TYPE_COUNT][cntHSND] = { 0 };
void Bot::ProcessRaidInvite2(Client* invitee, Client* invitor) { void Bot::ProcessRaidInvite(Client* invitee, Client* invitor) {
Raid* raid = entity_list.GetRaidByClient(invitor); Raid* raid = entity_list.GetRaidByClient(invitor);
Group* g_invitee = invitee->GetGroup(); Group* g_invitee = invitee->GetGroup();
+2 -2
View File
@@ -362,8 +362,8 @@ public:
static std::string RaceIdToString(uint16 raceId); static std::string RaceIdToString(uint16 raceId);
static bool IsBotAttackAllowed(Mob* attacker, Mob* target, bool& hasRuleDefined); static bool IsBotAttackAllowed(Mob* attacker, Mob* target, bool& hasRuleDefined);
static Bot* GetBotByBotClientOwnerAndBotName(Client* c, std::string botName); static Bot* GetBotByBotClientOwnerAndBotName(Client* c, std::string botName);
static void ProcessRaidInvite(Bot* player_accepting_invite, Client* b_owner); //Mitch static void ProcessRaidInvite(Bot* invitee, Client* invitor); //Mitch
static void ProcessRaidInvite2(Client* invitee, Client* invitor); //Mitch static void ProcessRaidInvite(Client* invitee, Client* invitor); //Mitch
static void ProcessBotGroupInvite(Client* c, std::string botName); static void ProcessBotGroupInvite(Client* c, std::string botName);
static void ProcessBotGroupDisband(Client* c, std::string botName); static void ProcessBotGroupDisband(Client* c, std::string botName);
static void BotOrderCampAll(Client* c); static void BotOrderCampAll(Client* c);
+28 -31
View File
@@ -11322,38 +11322,37 @@ void Client::Handle_OP_RaidCommand(const EQApplicationPacket *app)
{ {
case RaidCommandInviteIntoExisting: case RaidCommandInviteIntoExisting:
case RaidCommandInvite: { case RaidCommandInvite: {
//Mitch
#ifdef BOTS #ifdef BOTS //Mitch
Bot* player_to_invite = nullptr; Bot* player_to_invite = nullptr;
Client* player_to_invite_owner = nullptr; Client* player_to_invite_owner = nullptr;
if (entity_list.GetBotByBotName(raid_command_packet->player_name)) { if (entity_list.GetBotByBotName(raid_command_packet->player_name)) {
Bot* player_to_invite = entity_list.GetBotByBotName(raid_command_packet->player_name); Bot* player_to_invite = entity_list.GetBotByBotName(raid_command_packet->player_name);
Client* player_to_invite_owner = player_to_invite->GetOwner()->CastToClient(); Client* player_to_invite_owner = player_to_invite->GetOwner()->CastToClient();
Group* player_to_invite_group = player_to_invite->GetGroup();
if (!player_to_invite) { if (!player_to_invite) {
break; break;
} }
Group* player_to_invite_group = player_to_invite->GetGroup(); //Not allowed: Invite a bot that is already within a raid.
// Not allowed: Invite a bot that is not owned by the inviter and is not in a group. They could be in a group with their owner! if (player_to_invite->IsRaidGrouped()) {
if (player_to_invite->GetOwnerID() != player_to_invite_owner->CharacterID() && !player_to_invite_group) { MessageString(Chat::White, ALREADY_IN_RAID, GetName()); //must invite members not in raid...
Message(Chat::Red, "%s is not grouped and not your Bot. You can only invite your Bots, or Bots grouped with others.", player_to_invite->GetName()); return;
} }
//Not allowed: Invite a bot that is already within a raid. // Not allowed: Invite a bot that is not owned by the invitor
if (player_to_invite->HasRaid()) { if (player_to_invite->IsBot() &&
Message(Chat::Red, "%s is already in a raid.", player_to_invite->GetName()); player_to_invite->CastToBot()->GetOwner()->CastToClient()->CharacterID() !=
break; player_to_invite_owner->CharacterID()) {
Message(Chat::Red, "%s is not your Bot. You can only invite your Bots, or players grouped with bots.", player_to_invite->GetName());
} }
// Not allowed: Invite a bot that is in a group that is already a member
if (player_to_invite_group && player_to_invite_group->IsGroupMember(this)) { // Not allowed: Invite a bot that is in a group but the bot is not the group leader
MessageString(Chat::Red, ALREADY_IN_PARTY); if (player_to_invite_group && !player_to_invite_group->IsLeader(player_to_invite->CastToMob())) {
break; Message(Chat::Red, "You can only invite group leaders or ungrouped bots. Try %s instead.", player_to_invite_group->GetLeader()->GetName());
}
// Not allowed: Invite a bot that is in a group but not the groupleader
if (player_to_invite_group && !player_to_invite_group->IsLeader(player_to_invite)) {
Message(Chat::Red, "You can only invite an ungrouped player or group leader to join your raid.");
break; break;
} }
@@ -11403,12 +11402,11 @@ void Client::Handle_OP_RaidCommand(const EQApplicationPacket *app)
} }
} }
case RaidCommandAcceptInvite: { case RaidCommandAcceptInvite: {
Client* player_accepting_invite = entity_list.GetClientByName(raid_command_packet->player_name); Client* player_accepting_invite = entity_list.GetClientByName(raid_command_packet->player_name);
#ifdef BOTS #ifdef BOTS
// If the accepting client is in a group with a Bot, send the invite to Bot:ProcessRaidInvite // If the accepting client is in a group with a Bot or the invitor is in a group with a Bot, send the invite to Bot:ProcessRaidInvite
// instead of remaining here. // instead of remaining here.
Bot* b = nullptr; Bot* b = nullptr;
Client* invitee = entity_list.GetClientByName(raid_command_packet->leader_name); Client* invitee = entity_list.GetClientByName(raid_command_packet->leader_name);
@@ -11416,6 +11414,11 @@ void Client::Handle_OP_RaidCommand(const EQApplicationPacket *app)
Group* g_invitee = invitee->GetGroup(); Group* g_invitee = invitee->GetGroup();
Group* g_invitor = invitor->GetGroup(); Group* g_invitor = invitor->GetGroup();
if (invitee && invitee->IsRaidGrouped()) {
invitor->MessageString(Chat::White, ALREADY_IN_RAID, GetName()); //group failed, must invite members not in raid...
return;
}
bool invitor_has_bot = false; bool invitor_has_bot = false;
bool invitee_has_bot = false; bool invitee_has_bot = false;
@@ -11443,13 +11446,12 @@ void Client::Handle_OP_RaidCommand(const EQApplicationPacket *app)
} }
} }
if (invitor_has_bot || invitee_has_bot) { if (invitor_has_bot || invitee_has_bot) {
Bot::ProcessRaidInvite2(invitee, invitor); Bot::ProcessRaidInvite(invitee, invitor); //two clients with one or both having groups with bots
break; break;
} }
else else if (invitee->IsBot())
if (invitee->IsBot())
{ {
Bot::ProcessRaidInvite(b, player_accepting_invite); Bot::ProcessRaidInvite(b, player_accepting_invite); //client inviting a bot
break; break;
} }
@@ -11759,14 +11761,9 @@ void Client::Handle_OP_RaidCommand(const EQApplicationPacket *app)
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 #ifdef BOTS
//check to see if the leader_name has any bots in the raid
//if so, remove them as well
// for (int i = 0; i < MAX_RAID_MEMBERS; ++i) //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
// if (raid->members[i].member && raid->members[i].member->IsBot() && raid->members[i].member->CastToBot()->GetOwner()->CastToClient()->CharacterID() == entity_list.GetClientByName(raid_command_packet->leader_name)->CharacterID())
// raid->RemoveMember(raid->members[i].membername);
// }
std::vector<Bot*> raid_members_bots; std::vector<Bot*> raid_members_bots;
int owner_id = entity_list.GetClientByName(raid_command_packet->leader_name)->CharacterID(); int owner_id = entity_list.GetClientByName(raid_command_packet->leader_name)->CharacterID();
for (int i = 0; i < MAX_RAID_MEMBERS; ++i) for (int i = 0; i < MAX_RAID_MEMBERS; ++i)