public virtual bool DoOrderFollow()
{
if (CheckHerding())
{
m_Mobile.DebugSay("Praise the shepherd!");
}
else if (m_Mobile.ControlTarget != null && !m_Mobile.ControlTarget.Deleted && m_Mobile.ControlTarget != m_Mobile)
{
int iCurrDist = (int)m_Mobile.GetDistanceToSqrt(m_Mobile.ControlTarget);
if (iCurrDist > m_Mobile.RangePerception)
{
m_Mobile.DebugSay("I have lost the one to follow. I stay here");
if (m_Mobile.Combatant != null && !m_Mobile.Combatant.Deleted && m_Mobile.Combatant.Alive && !m_Mobile.Combatant.IsDeadBondedPet)
{
m_Mobile.Warmode = true;
m_Mobile.Direction = m_Mobile.GetDirectionTo(m_Mobile.Combatant);
}
else
{
m_Mobile.Warmode = false;
}
}
else
{
m_Mobile.DebugSay("My master told me to follow: {0}", m_Mobile.ControlTarget.Name);
// Not exactly OSI style, but better than nothing.
bool bRun = (iCurrDist > 5);
if (WalkMobileRange(m_Mobile.ControlTarget, 1, bRun, 0, 1))
{
if (m_Mobile.Combatant != null && !m_Mobile.Combatant.Deleted && m_Mobile.Combatant.Alive && !m_Mobile.Combatant.IsDeadBondedPet)
{
m_Mobile.Warmode = true;
m_Mobile.Direction = m_Mobile.GetDirectionTo(m_Mobile.Combatant);
}
else
{
m_Mobile.Warmode = false;
}
}
}
}
else
{
m_Mobile.DebugSay("I have nobody to follow");
m_Mobile.ControlTarget = null;
m_Mobile.ControlOrder = OrderType.None;
}
return true;
}