diff options
author | ariel- <ariel-@users.noreply.github.com> | 2017-03-04 04:18:55 -0300 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2019-08-17 20:04:14 +0200 |
commit | 3d52ba93fc59070ef0a8c3411440ad979399c954 (patch) | |
tree | 5eaf3f6ded4178816fced9b336f39c65451242a7 /src | |
parent | fa46e7c40606fcbd14973075d2ed262708049ffb (diff) |
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
(cherrypicked from 15a207fcac15d336b848f9759f75386e12b6a35f)
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/Entities/Creature/Creature.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index d73dfeb1308..5e7df4ab3c1 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -2343,7 +2343,7 @@ bool Creature::CanAssistTo(const Unit* u, const Unit* enemy, bool checkfaction / // use this function to avoid having hostile creatures 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); @@ -2362,13 +2362,17 @@ bool Creature::_IsTargetAcceptable(const Unit* target) const return false; } - const Unit* myVictim = getAttackerForHelper(); - const Unit* targetVictim = target->getAttackerForHelper(); + Unit const* targetVictim = target->getAttackerForHelper(); // 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; + // 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 (targetVictim && IsFriendlyTo(targetVictim)) return true; |