mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-28 21:02:14 +01:00
Core/Creature: redo some logical checks in _IsTargetAcceptable
- Check against current creature victim, don't check potential victim attacking list. - Neutral creatures with aggressive reactstate were triggered to attack from MoveInLineOfSight because of this check - Prevents attack from a distance after right clicking an npc Closes #19235
This commit is contained in:
@@ -2262,7 +2262,7 @@ bool Creature::CanAssistTo(const Unit* u, const Unit* enemy, bool checkfaction /
|
|||||||
|
|
||||||
// use this function to avoid having hostile creatures attack
|
// use this function to avoid having hostile creatures attack
|
||||||
// friendlies and other mobs they shouldn't attack
|
// friendlies and other mobs they shouldn't attack
|
||||||
bool Creature::_IsTargetAcceptable(const Unit* target) const
|
bool Creature::_IsTargetAcceptable(Unit const* target) const
|
||||||
{
|
{
|
||||||
ASSERT(target);
|
ASSERT(target);
|
||||||
|
|
||||||
@@ -2281,13 +2281,17 @@ bool Creature::_IsTargetAcceptable(const Unit* target) const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Unit* myVictim = getAttackerForHelper();
|
Unit const* targetVictim = target->getAttackerForHelper();
|
||||||
const Unit* targetVictim = target->getAttackerForHelper();
|
|
||||||
|
|
||||||
// if I'm already fighting target, or I'm hostile towards the target, the target is acceptable
|
// if I'm already fighting target, or I'm hostile towards the target, the target is acceptable
|
||||||
if (myVictim == target || targetVictim == this || IsHostileTo(target))
|
if (GetVictim() == target || IsHostileTo(target))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
// a player is targeting me, but I'm not hostile towards it, and not currently attacking it, the target is not acceptable
|
||||||
|
// (players may set their victim from a distance, and doesn't mean we should attack)
|
||||||
|
if (target->GetTypeId() == TYPEID_PLAYER && targetVictim == this)
|
||||||
|
return false;
|
||||||
|
|
||||||
// if the target's victim is friendly, and the target is neutral, the target is acceptable
|
// if the target's victim is friendly, and the target is neutral, the target is acceptable
|
||||||
if (targetVictim && IsFriendlyTo(targetVictim))
|
if (targetVictim && IsFriendlyTo(targetVictim))
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user