Example #1
0
        public override bool WalkMobileRange(IPoint3D p, int iSteps, bool bRun, int iWantDistMin, int iWantDistMax)
        {
            if (m_Creature.Orb == null || m_Creature.ControlMaster == null)
            {
                return(base.WalkMobileRange(p, iSteps, bRun, iWantDistMin, iWantDistMax));
            }

            int range = m_Creature.GetLeashLength();

            if (p is Mobile && (Mobile)p == m_Creature.ControlMaster)
            {
                p = m_Creature.Orb.GetAnchorActual();

                if (m_Creature.InRange(p, range))
                {
                    return(false);
                }
                else
                {
                    return(base.WalkMobileRange(p, iSteps, bRun, range, range));
                }
            }

            return(base.WalkMobileRange(p, iSteps, bRun, iWantDistMin, iWantDistMax));
        }
Example #2
0
 public bool IsFollowing()
 {
     return((int)m_Pet.GetDistanceToSqrt(GetAnchorLocation()) > m_Pet.GetLeashLength() + 1 && m_Pet.ControlOrder == OrderType.Follow);
 }
Example #3
0
        public override bool DoOrderFollow()
        {
            if (m_Creature.Orb == null || !m_Creature.Controlled)
            {
                return(base.DoOrderFollow());
            }

            bool fighting = false;

            switch (m_Creature.Orb.Aggression)
            {
            case Aggression.Following:
                return(base.DoOrderFollow());

            case Aggression.Defensive:
            {
                int      length = m_Creature.GetLeashLength();
                IPoint3D p      = m_Creature.Orb.Anchor as IPoint3D;

                if (p == null)
                {
                    p = m_Creature;
                }

                Mobile combatant = m_Creature.Combatant != null ? m_Creature.Combatant : m_Creature.ControlMaster.Combatant != null ? m_Creature.ControlMaster.Combatant : null;

                if (combatant != null && combatant.GetDistanceToSqrt(p) <= length)
                {
                    if (m_Creature.Debug)
                    {
                        m_Creature.DebugSay("I have detected {0} as an aggressor, attacking", m_Creature.FocusMob.Name);
                    }

                    fighting = true;

                    m_Creature.Combatant     = combatant;
                    m_Creature.ControlTarget = combatant;
                    m_Creature.ControlOrder  = OrderType.Attack;
                    Action = ActionType.Combat;
                }
                else
                {
                    return(base.DoOrderFollow());
                }
            }
            break;

            case Aggression.Aggressive:
            {
                if (AcquireFocusMob(m_Creature.GetLeashLength(), m_Creature.FightMode, false, false, true))
                {
                    if (m_Creature.Debug)
                    {
                        m_Creature.DebugSay("I have detected {0}, attacking", m_Creature.FocusMob.Name);
                    }

                    fighting = true;

                    m_Creature.Combatant     = m_Creature.FocusMob;
                    m_Creature.ControlTarget = m_Creature.FocusMob;
                    m_Creature.ControlOrder  = OrderType.Attack;
                    Action = ActionType.Combat;
                }
                else
                {
                    return(base.DoOrderFollow());
                }
            }
            break;
            }

            if (!fighting)
            {
                return(base.DoOrderFollow());
            }

            return(true);
        }