Playerbot: only assist targets the owner is actually fighting
ResolveOwnerAssistTarget preferred GetSelectedUnit() over the victim, so merely targeting a neutral/yellow mob made every bot attack it. Now the victim (real combat target) is preferred, and the selected-unit fallback only counts when the owner is IN combat and targeting that unit (a cast in flight) — a selected-but-unattacked mob never pulls the squad.
This commit is contained in:
@@ -149,7 +149,12 @@ Unit* ResolveOwnerAssistTarget(Player* owner)
|
|||||||
if (!owner || !owner->IsInWorld())
|
if (!owner || !owner->IsInWorld())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
Unit* t = owner->GetSelectedUnit();
|
// Assist only what the owner is ACTUALLY fighting. Prefer the victim
|
||||||
|
// (the unit the owner is attacking); a merely-selected target (e.g. a
|
||||||
|
// neutral/yellow mob the player is hovering or inspecting) must NOT pull
|
||||||
|
// the squad into combat — bots only join once the player commits to an
|
||||||
|
// attack.
|
||||||
|
Unit* t = owner->GetVictim();
|
||||||
if (t)
|
if (t)
|
||||||
{
|
{
|
||||||
if (!t->IsAlive() || t->GetMap() != owner->GetMap())
|
if (!t->IsAlive() || t->GetMap() != owner->GetMap())
|
||||||
@@ -160,11 +165,20 @@ Unit* ResolveOwnerAssistTarget(Player* owner)
|
|||||||
|
|
||||||
if (!t)
|
if (!t)
|
||||||
{
|
{
|
||||||
t = owner->GetVictim();
|
// Casters/ranged can have a selected target while the victim field
|
||||||
if (t && (!t->IsAlive() || t->GetMap() != owner->GetMap()))
|
// lags a cast — treat the selection as an assist target only when the
|
||||||
t = nullptr;
|
// owner is genuinely ENGAGED with it (in combat and targeting it).
|
||||||
if (t && !owner->IsValidAttackTarget(t))
|
t = owner->GetSelectedUnit();
|
||||||
t = nullptr;
|
if (t)
|
||||||
|
{
|
||||||
|
if (!t->IsAlive() || t->GetMap() != owner->GetMap())
|
||||||
|
t = nullptr;
|
||||||
|
else if (!owner->IsValidAttackTarget(t))
|
||||||
|
t = nullptr;
|
||||||
|
else if (!owner->IsInCombat() ||
|
||||||
|
owner->GetTarget() != t->GetGUID())
|
||||||
|
t = nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return t;
|
return t;
|
||||||
|
|||||||
Reference in New Issue
Block a user