function to check that target is reachable...
diff --git a/src/game/Unit.h b/src/game/Unit.h
index 1aa2f09..b8ed835 100644
--- a/src/game/Unit.h
+++ b/src/game/Unit.h
@@ -1959,6 +1959,8 @@ class MANGOS_DLL_SPEC Unit : public WorldObject
// Movement info
MovementInfo m_movementInfo;
+ bool IsTargetReachable(Unit const* target) const;
+
protected:
explicit Unit ();
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index 98f0802..09a3d81 100644
--- a/src/game/Unit.cpp
+++ b/src/game/Unit.cpp
@@ -10851,6 +10851,16 @@ SpellAuraHolder* Unit::GetSpellAuraHolder (uint32 spellid, uint64 casterGUID)
return NULL;
}
+bool Unit::IsTargetReachable(Unit const* target) const
+{
+ if (!target)
+ return false;
+
+ PathInfo* i_path = new PathInfo(this, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), true);
+
+ return (i_path) ? (i_path->getPathType() & (PATHFIND_NORMAL | PATHFIND_INCOMPLETE)) : true;
+}
+
template<typename Elem, typename Node>
void Unit::SendMonsterMoveByPath(Path<Elem,Node> const& path, uint32 start, uint32 end, SplineFlags flags, uint32 traveltime)
{
... and integration into aggro system:
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index 98f0802..e012e13 100644
--- a/src/game/Unit.cpp
+++ b/src/game/Unit.cpp
@@ -3744,8 +3744,12 @@ bool Unit::isInAccessablePlaceFor(Creature const* c) const
{
if(IsInWater())
return c->CanSwim();
- else
- return c->CanWalk() || c->CanFly();
+ else if (c->CanFly())
+ return true;
+ else if (c->CanWalk())
+ return c->IsTargetReachable(this);
+ else
+ return false;
}
bool Unit::IsInWater() const