diff --git a/src/game/ThreatManager.cpp b/src/game/ThreatManager.cpp index 7f7820fe1..3593bd3a9 100644 --- a/src/game/ThreatManager.cpp +++ b/src/game/ThreatManager.cpp @@ -252,7 +252,15 @@ HostileReference* ThreatContainer::addThreat(Unit* pVictim, float pThreat) void ThreatContainer::modifyThreatPercent(Unit *pVictim, int32 pPercent) { if(HostileReference* ref = getReferenceByTarget(pVictim)) - ref->addThreatPercent(pPercent); + { + if(pPercent < -100) + { + ref->removeReference(); + delete ref; + } + else + ref->addThreatPercent(pPercent); + } } //============================================================ diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 621c25713..bd35c474b 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -8666,6 +8666,32 @@ bool Unit::SelectHostileTarget() SetInFront(target); if (oldTarget != target) ((Creature*)this)->AI()->AttackStart(target); + + // check if currently selected target is reachable + // NOTE: path alrteady generated from AttackStart() + if(!GetMotionMaster()->operator->()->IsReachable()) + { + // remove all taunts + RemoveSpellsCausingAura(SPELL_AURA_MOD_TAUNT); + + if(m_ThreatManager.getThreatList().size() < 2) + { + // only one target in list, we have to evade after timer + // TODO: make timer - inside Creature class + ((Creature*)this)->AI()->EnterEvadeMode(); + } + else + { + // remove unreachable target from our threat list + // next iteration we will select next possible target + m_HostileRefManager.deleteReference(target); + m_ThreatManager.modifyThreatPercent(target, -101); + + _removeAttacker(target); + } + + return false; + } } return true; } diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 56768fa2a..8038fd532 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "11917" + #define REVISION_NR "11918" #endif // __REVISION_NR_H__