public virtual bool WalkMobileRange(Mobile m, int iSteps, bool bRun, int iWantDistMin, int iWantDistMax)
{
if (m_Mobile.Deleted || m_Mobile.DisallowAllMoves)
return false;
if (m != null)
{
for (int i = 0; i < iSteps; i++)
{
// Get the curent distance
int iCurrDist = (int)m_Mobile.GetDistanceToSqrt(m);
if (iCurrDist < iWantDistMin || iCurrDist > iWantDistMax)
{
bool needCloser = (iCurrDist > iWantDistMax);
bool needFurther = !needCloser;
if (needCloser && m_Path != null && m_Path.Goal == m)
{
if (m_Path.Follow(bRun, 1))
m_Path = null;
}
else
{
Direction dirTo;
if (iCurrDist > iWantDistMax)
dirTo = m_Mobile.GetDirectionTo(m);
else
dirTo = m.GetDirectionTo(m_Mobile);
// Add the run flag
if (bRun)
dirTo = dirTo | Direction.Running;
if (!DoMove(dirTo, true) && needCloser)
{
m_Path = new PathFollower(m_Mobile, m);
m_Path.Mover = new MoveMethod(DoMoveImpl);
if (m_Path.Follow(bRun, 1))
m_Path = null;
}
else
{
m_Path = null;
}
}
}
else
{
return true;
}
}
// Get the curent distance
int iNewDist = (int)m_Mobile.GetDistanceToSqrt(m);
if (iNewDist >= iWantDistMin && iNewDist <= iWantDistMax)
return true;
else
return false;
}
return false;
}