[Bots] Fix ^oo autodefend from sending bots/pets to invalid haters (#3772)

Bots and especially their pets could get in a loop where they try to attack an invalid target. This would result in their pets spamming "That is not a legal target" messages.
This commit is contained in:
nytmyr authored and GitHub committed 2023-12-16 16:08:16 -05:00
1 parent fcb40daaf1
commit 4d118ab978
1 file changed
+1 -1
+1 -1
View File
@@ -2357,7 +2357,7 @@ bool Bot::TryAutoDefend(Client* bot_owner, float leash_distance) {
}
auto hater = entity_list.GetMob(hater_iter.spawn_id);
if (hater && !hater->IsMezzed() && DistanceSquared(hater->GetPosition(), bot_owner->GetPosition()) <= leash_distance) {
if (hater && hater->CastToNPC()->IsOnHatelist(bot_owner) && !hater->IsMezzed() && DistanceSquared(hater->GetPosition(), bot_owner->GetPosition()) <= leash_distance) {
// This is roughly equivilent to npc attacking a client pet owner
AddToHateList(hater, 1);
SetTarget(hater);