Cleanup IsAttackAllowed checks for bots and their pets

This commit is contained in:
nytmyr
2025-02-02 08:45:06 -06:00
parent b57be45b51
commit 91996f15f0
+20 -19
View File
@@ -743,28 +743,29 @@ bool Mob::IsAttackAllowed(Mob *target, bool isSpellAttack)
} }
// can't damage own pet (applies to everthing) // can't damage own pet (applies to everthing)
Mob *target_owner = target->GetOwner(); Mob* target_owner = target->GetOwner();
Mob *our_owner = GetOwner(); Mob* our_owner = GetOwner();
Mob* target_ultimate_owner = (target->IsBot() ? target->CastToBot()->GetBotOwner() : target->GetUltimateOwner());
Mob* our_ultimate_owner = (IsBot() ? CastToBot()->GetBotOwner() : GetUltimateOwner());
if (target_owner && target_owner == this) { // Self-owner check
if (target_owner == this || our_owner == target) {
return false; return false;
} }
else if (
IsBot() && target_ultimate_owner && // Bot-specific logic
( if (IsBot()) {
(target_ultimate_owner == our_ultimate_owner) || Mob* target_ultimate_owner = target->IsBot() ? target->CastToBot()->GetBotOwner() : target->GetUltimateOwner();
(target_ultimate_owner->IsOfClientBot()) Mob* our_ultimate_owner = CastToBot()->GetBotOwner();
)
) { if (target_ultimate_owner) {
return false; if (target_ultimate_owner == our_ultimate_owner || target_ultimate_owner->IsOfClientBot()) {
} return false;
else if (our_owner && our_owner == target) { }
return false; }
}
else if (IsBot() && our_ultimate_owner && our_ultimate_owner == target) { // Bots should not attack their ultimate owner
return false; if (our_ultimate_owner == target) {
return false;
}
} }
// invalidate for swarm pets for later on if their owner is a corpse // invalidate for swarm pets for later on if their owner is a corpse