Beispiel #1
0
        public override bool DoOrderAttack()
        {
            if (m_Creature.IsDeadPet)
            {
                return(true);
            }

            if (m_Creature.Orb == null)
            {
                return(base.DoOrderAttack());
            }

            if (m_Creature.ControlTarget == null || m_Creature.ControlTarget.Deleted || m_Creature.ControlTarget.Map != m_Creature.Map || !m_Creature.ControlTarget.Alive || m_Creature.ControlTarget.IsDeadBondedPet)
            {
                m_Creature.DebugSay("I think he might be dead. He's not anywhere around here at least. That's cool. I'm glad he's dead.");

                if (m_Creature.Orb.Aggression == Aggression.Following)
                {
                    m_Creature.ControlTarget = m_Creature.ControlMaster;
                    m_Creature.ControlOrder  = OrderType.Follow;

                    m_Creature.CurrentSpeed = 0.1;
                }
                else if (m_Creature.Orb.Anchor is Mobile && ((Mobile)m_Creature.Orb.Anchor).Alive)
                {
                    m_Creature.ControlTarget = (Mobile)m_Creature.Orb.Anchor;
                    m_Creature.ControlOrder  = OrderType.Follow;

                    m_Creature.CurrentSpeed = 0.1;
                }
                else
                {
                    m_Creature.ControlTarget = null;
                    m_Creature.ControlOrder  = OrderType.None;

                    m_Creature.CurrentSpeed = m_Creature.Orb.Anchor == null ? m_Creature.PassiveSpeed : m_Creature.ActiveSpeed;
                }

                Think();
            }
            else
            {
                m_Creature.DebugSay("Attacking target...");
                Think();
            }

            return(true);
        }
Beispiel #2
0
        public override bool Obey()
        {
            if (m_Creature.Orb == null || !m_Creature.Controlled)
            {
                return(base.Obey());
            }

            switch (m_Creature.Orb.Aggression)
            {
            default:
            {
                if (m_Creature.ControlOrder != OrderType.Follow)
                {
                    m_Creature.ControlOrder = OrderType.Follow;
                }

                DoOrderFollow();
            }
            break;

            case Aggression.Defensive:
            {
                if (m_Creature.Combatant != null)
                {
                    if (m_Creature.ControlOrder == OrderType.Follow)
                    {
                        m_Creature.ControlOrder = OrderType.Attack;
                        Action = ActionType.Combat;
                    }

                    break;
                }

                if (_NextAggressorCheck <= Core.TickCount)
                {
                    IPoint3D p     = m_Creature.Orb.GetAnchorActual();
                    double   range = m_Creature.RangePerception;

                    IPooledEnumerable eable   = m_Creature.Map.GetMobilesInRange(new Point3D(p), (int)range);
                    Mobile            closest = null;

                    foreach (Mobile m in eable)
                    {
                        if (m.Combatant == m_Creature || m.Combatant == m_Creature.ControlMaster)
                        {
                            double dist = closest == null ? range : closest.GetDistanceToSqrt(m_Creature);
                            if (closest == null || dist < range)
                            {
                                range   = dist;
                                closest = m;
                            }
                        }
                    }

                    eable.Free();

                    if (closest != null)
                    {
                        m_Creature.ControlTarget = closest;
                        m_Creature.ControlOrder  = OrderType.Attack;
                        m_Creature.Combatant     = closest;
                        m_Creature.DebugSay("But -that- is not dead. Here we go again...");

                        Action = ActionType.Combat;
                    }

                    _NextAggressorCheck = Core.TickCount + 1000;
                }
            }
            break;

            case Aggression.Aggressive:
            {
                if (m_Creature.Combatant != null)
                {
                    if (m_Creature.ControlOrder == OrderType.Follow)
                    {
                        m_Creature.ControlOrder = OrderType.Attack;
                        Action = ActionType.Combat;
                    }

                    break;
                }

                if (AcquireFocusMob(m_Creature.RangePerception, m_Creature.FightMode, false, false, true))
                {
                    if (m_Creature.FocusMob == m_Creature.ControlMaster)
                    {
                        break;
                    }

                    if (m_Creature.Debug)
                    {
                        m_Creature.DebugSay("I have detected {0}, attacking", m_Creature.FocusMob.Name);
                    }

                    m_Creature.ControlOrder = OrderType.Attack;
                    m_Creature.Combatant    = m_Creature.FocusMob;

                    Action = ActionType.Combat;
                }
            }
            break;
            }

            if (m_Creature.Combatant == null)
            {
                if (m_Creature.ControlOrder != OrderType.Follow)
                {
                    m_Creature.ControlOrder = OrderType.Follow;
                }

                m_Creature.ControlTarget = m_Creature.ControlMaster;
                Action = ActionType.Guard;
                DoOrderFollow();
            }

            Think();
            return(true);
        }