This commit is contained in:
neckkola
2022-01-11 17:40:10 -04:00
parent bd831d2b4a
commit 4098d9db51
5 changed files with 73 additions and 12 deletions
+23 -7
View File
@@ -2540,15 +2540,12 @@ void Bot::AI_Process()
Client* bot_owner = (GetBotOwner() && GetBotOwner()->IsClient() ? GetBotOwner()->CastToClient() : nullptr);
Group* bot_group = GetGroup();
Raid* bot_raid = entity_list.GetRaidByClient(bot_owner);
int bot_raid_group = 0;
if (bot_raid)
bot_raid_group = bot_raid->GetGroup(GetName()) + 1;
Raid* bot_raid = entity_list.GetRaidByBot(this);
//#pragma region PRIMARY AI SKIP CHECKS
// Primary reasons for not processing AI
if (!bot_owner || (!bot_group && !bot_raid_group) || !IsAIControlled()) {
if (!bot_owner || (!bot_group && !bot_raid) || !IsAIControlled()) {
return;
}
@@ -2561,7 +2558,21 @@ void Bot::AI_Process()
}
// We also need a leash owner and follow mob (subset of primary AI criteria)
Client* leash_owner = (bot_group->GetLeader() && bot_group->GetLeader()->IsClient() ? bot_group->GetLeader()->CastToClient() : bot_owner);
Client* leash_owner = nullptr;
if (bot_group) {
leash_owner = (bot_group->GetLeader() && bot_group->GetLeader()->IsClient() ? bot_group->GetLeader()->CastToClient() : bot_owner);
}
else if (bot_raid) {
int bot_raid_group = bot_raid->GetGroup(GetName());
if (bot_raid_group > 0) {
leash_owner = bot_raid->GetGroupLeader(bot_raid_group)->CastToClient();
}
else {
leash_owner = bot_raid->GetLeader();
}
}
if (!leash_owner) {
return;
}
@@ -8382,6 +8393,11 @@ void Bot::Camp(bool databaseSave) {
//auto group = GetGroup();
if(GetGroup())
RemoveBotFromGroup(this, GetGroup());
//Mitch
Raid* bot_raid = entity_list.GetRaidByBot(this);
if (bot_raid)
bot_raid->RemoveMember(this->GetName());
// RemoveBotFromGroup() code is too complicated for this to work as-is (still needs to be addressed to prevent memory leaks)
//if (group->GroupCount() < 2)
+12 -1
View File
@@ -11723,6 +11723,8 @@ 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);
if (raid) {
uint32 group = raid->GetGroup(raid_command_packet->leader_name);
@@ -11753,7 +11755,16 @@ void Client::Handle_OP_RaidCommand(const EQApplicationPacket *app)
}
}
}
#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)
{
if (raid->members[i] && raid->members[i].member->IsBot() && raid->members[i].member->GetOwnerID() == entity_list.GetClientByName(raid_command_packet->leader_name)->CharacterID())
raid->RemoveMember(raid->members[i].membername);
}
#endif
raid->RemoveMember(raid_command_packet->leader_name);
Client *c = entity_list.GetClientByName(raid_command_packet->leader_name);
if (c)
+24 -3
View File
@@ -2023,17 +2023,17 @@ Raid *EntityList::GetRaidByID(uint32 id)
return nullptr;
}
Raid *EntityList::GetRaidByClient(Client* client)
Raid* EntityList::GetRaidByClient(Client* client)
{
if (client->p_raid_instance) {
return client->p_raid_instance;
}
std::list<Raid *>::iterator iterator;
std::list<Raid*>::iterator iterator;
iterator = raid_list.begin();
while (iterator != raid_list.end()) {
for (auto &member : (*iterator)->members) {
for (auto& member : (*iterator)->members) {
if (member.member) {
if (member.member == client) {
client->p_raid_instance = *iterator;
@@ -2048,6 +2048,27 @@ Raid *EntityList::GetRaidByClient(Client* client)
return nullptr;
}
Raid* EntityList::GetRaidByBot(Bot* bot)
{
std::list<Raid*>::iterator iterator;
iterator = raid_list.begin();
while (iterator != raid_list.end()) {
for (auto& member : (*iterator)->members) {
if (member.member) {
if (member.member == bot->CastToClient()) {
//client->p_raid_instance = *iterator;
return *iterator;
}
}
}
++iterator;
}
return nullptr;
}
Raid *EntityList::GetRaidByMob(Mob *mob)
{
std::list<Raid *>::iterator iterator;
+3
View File
@@ -197,6 +197,9 @@ public:
Raid *GetRaidByClient(Client* client);
Raid *GetRaidByID(uint32 id);
Raid *GetRaidByLeaderName(const char *leader);
#ifdef BOTS
Raid* GetRaidByBot(Bot* bot);
#endif
Corpse *GetCorpseByOwner(Client* client);
Corpse *GetCorpseByOwnerWithinRange(Client* client, Mob* center, int range);
+11 -1
View File
@@ -246,6 +246,16 @@ void Raid::RemoveMember(const char *characterName)
auto results = database.QueryDatabase(query);
Client *client = entity_list.GetClientByName(characterName);
#ifdef BOTS
Bot* bot = entity_list.GetBotByBotName(characterName);
if (bot) {
bot->SetFollowID(bot->GetOwner()->GetID());
bot->SetGrouped(0);
bot->SetTarget(nullptr);
}
#endif
disbandCheck = true;
SendRaidRemoveAll(characterName);
SendRaidDisband(client);
@@ -1731,7 +1741,7 @@ void Raid::SendHPManaEndPacketsFrom(Mob *mob)
if(members[x].member) {
if(!mob->IsClient() || ((members[x].member != mob->CastToClient()) && (members[x].GroupNumber == group_id))) {
members[x].member->QueuePacket(&hpapp, false);
if (members[x].member->ClientVersion() >= EQ::versions::ClientVersion::SoD) {
if (members[x].member->IsClient() && members[x].member->ClientVersion() >= EQ::versions::ClientVersion::SoD) { //Mitch
outapp.SetOpcode(OP_MobManaUpdate);
MobManaUpdate_Struct *mana_update = (MobManaUpdate_Struct *)outapp.pBuffer;
mana_update->spawn_id = mob->GetID();