Exemple #1
0
        public override bool DoActionFlee()
        {
            BaseAnimal ba   = (BaseAnimal)m_Mobile;
            Mobile     from = ba.Predator;

            //Direction togo = Direction.South;
            if (from != null)
            {
                if (ba.Grouping != GroupingType.None)
                {
                    if (ba.PackLeader != null && ba.PackLeader != m_Mobile)
                    {
                        BaseAnimal bapl = (BaseAnimal)ba.PackLeader;
                        ba.DebugSay("checking pack leaders predator");
                        if (bapl.Predator != null)
                        {
                            Run(bapl.Direction);
                        }
                        else
                        {
                            m_Mobile.FocusMob = from;
                            m_Mobile.DebugSay("I am fleeing!");
                            RunFrom(from);
                        }
                    }
                    else if (ba.PackLeader == null && ba.Mate != null)
                    {
                        BaseAnimal mate = (BaseAnimal)ba.Mate;
                        ba.DebugSay("checking mates predator");
                        if (mate.Predator != null)
                        {
                            Run(mate.Direction);
                        }
                        else
                        {
                            m_Mobile.FocusMob = from;
                            m_Mobile.DebugSay("I am fleeing!");
                            RunFrom(from);
                        }
                    }
                }
                else
                {
                    m_Mobile.FocusMob = from;
                    m_Mobile.DebugSay("I am fleeing!");
                    RunFrom(from);
                    //return true;
                }

                if (from == null || from.Deleted || from.Map != m_Mobile.Map)
                {
                    m_Mobile.DebugSay("I have lost him");
                    Action = ActionType.Guard;
                    return(true);
                }
                if (!m_Mobile.InRange(from, 21))
                {
                    m_Mobile.DebugSay("I have fled");
                    ba.Predator = null;
                    Action      = ActionType.Guard;
                    return(true);
                }
                else
                {
                    m_Mobile.DebugSay("I am fleeing!");
                    RunFrom(from);
                }
            }
            return(true);
        }