[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 2023-12-16 15:08:16 -06:00 committed by GitHub
parent fcb40daaf1
commit 4d118ab978
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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);