diff --git a/zone/bot.cpp b/zone/bot.cpp index a1ee0f691..ceeefb898 100644 --- a/zone/bot.cpp +++ b/zone/bot.cpp @@ -2119,6 +2119,7 @@ void Bot::AI_Process() //ALT COMBAT (ACQUIRE HATE) glm::vec3 Goal(0, 0, 0); + // We have aggro to choose from if (IsEngaged()) { if (rest_timer.Enabled()) { @@ -2135,16 +2136,18 @@ void Bot::AI_Process() // RETURNING FLAG - else if (GetReturningFlag()) { - if (!ReturningFlagChecks(bot_owner, fm_distance)) { - return; - } + if (GetReturningFlag()) { + LogTestDebugDetail("#{}: {} has ReturningFlag", __LINE__, GetCleanName()); //deleteme + ReturningFlagChecks(bot_owner, leash_owner, fm_distance); + + return; } // DEFAULT (ACQUIRE TARGET) // VERIFY TARGET AND STANCE auto tar = GetBotTarget(bot_owner); + if (!tar) { return; } @@ -2204,6 +2207,9 @@ void Bot::AI_Process() if (GetPullingFlag()) { if (!TargetValidation(tar)) { return; } + if (!DoLosChecks(this, tar)) { + return; + } if (atCombatRange) { if (RuleB(Bots, AllowRangedPulling) && IsBotRanged() && ranged_timer.Check(false)) { StopMoving(CalculateHeadingToTarget(tar->GetX(), tar->GetY())); @@ -2239,7 +2245,9 @@ void Bot::AI_Process() } } + TryPursueTarget(leash_distance, Goal); return; + //TODO bot rewrite - need pulling checks below to prevent assist } // ENGAGED AT COMBAT RANGE @@ -2334,7 +2342,6 @@ void Bot::AI_Process() SetAttackingFlag(false); if (!bot_owner->GetBotPulling()) { - SetPullingFlag(false); SetReturningFlag(false); } @@ -3013,24 +3020,41 @@ Mob* Bot::GetBotTarget(Client* bot_owner) return t; } -bool Bot::ReturningFlagChecks(Client* bot_owner, float fm_distance) {// Need to make it back to group before clearing return flag - if (fm_distance <= GetFollowDistance()) { - - // Once we're back, clear blocking flags so everyone else can join in +bool Bot::ReturningFlagChecks(Client* bot_owner, Mob* leash_owner, float fm_distance) { + if ( + (NOT_GUARDING && fm_distance <= GetFollowDistance()) || + (GUARDING && DistanceSquared(GetPosition(), GetGuardPoint()) <= GetFollowDistance()) + ) { // Once we're back, clear blocking flags so everyone else can join in SetReturningFlag(false); bot_owner->SetBotPulling(false); if (GetPet()) { GetPet()->SetPetOrder(m_previous_pet_order); } + + return false; } // Need to keep puller out of combat until they reach their 'return to' destination - if (HasTargetReflection()) { + WipeHateList(); - SetTarget(nullptr); - WipeHateList(); - return false; + if (!IsMoving()) { + glm::vec3 Goal(0, 0, 0); + + if (GUARDING) { + Goal = GetGuardPoint(); + } + else { + Mob* follow_mob = entity_list.GetMob(GetFollowID()); + + if (!follow_mob) { + follow_mob = leash_owner; + SetFollowID(leash_owner->GetID()); + } + + Goal = follow_mob->GetPosition(); + } + RunTo(Goal.x, Goal.y, Goal.z); } return true; diff --git a/zone/bot.h b/zone/bot.h index 5a9cbf7fb..9e187d216 100644 --- a/zone/bot.h +++ b/zone/bot.h @@ -932,7 +932,7 @@ public: ); bool PullingFlagChecks(Client* bot_owner); - bool ReturningFlagChecks(Client* bot_owner, float fm_distance); + bool ReturningFlagChecks(Client* bot_owner, Mob* leash_owner, float fm_distance); void BotPullerProcess(Client* bot_owner, Raid* raid);