Fix bots attacking others despite being in a prohibited zone - Issue 227 (#793)

* Fix bots attacking despite being in a prohibited zone

* Protect pets as well and move logic to not skip IsFriendlyTo

* Fix prohibited typo

* Update AttackAction.cpp
This commit is contained in:
SaW
2024-12-17 23:31:38 +01:00
committed by GitHub
parent 2e4db37c4d
commit 3dd92b7fd8

View File

@@ -74,6 +74,7 @@ bool AttackAction::Attack(Unit* target, bool with_pet /*true*/)
{ {
return false; return false;
} }
std::ostringstream msg; std::ostringstream msg;
msg << target->GetName(); msg << target->GetName();
@@ -88,9 +89,11 @@ bool AttackAction::Attack(Unit* target, bool with_pet /*true*/)
if (!bot->IsWithinLOSInMap(target)) if (!bot->IsWithinLOSInMap(target))
{ {
msg << " is not on my sight"; msg << " is not in my sight";
if (verbose) if (verbose)
botAI->TellError(msg.str()); botAI->TellError(msg.str());
return false;
} }
if (target->isDead()) if (target->isDead())
@@ -102,6 +105,14 @@ bool AttackAction::Attack(Unit* target, bool with_pet /*true*/)
return false; return false;
} }
if (!bot->IsValidAttackTarget(target) && sPlayerbotAIConfig->IsInPvpProhibitedZone(bot->GetZoneId()))
{
if (verbose)
botAI->TellError("I cannot attack others in PvP prohibited zones");
return false;
}
// if (bot->IsMounted() && bot->IsWithinLOSInMap(target)) // if (bot->IsMounted() && bot->IsWithinLOSInMap(target))
// { // {
// WorldPacket emptyPacket; // WorldPacket emptyPacket;