Beispiel #1
0
            protected override void OnTick()
            {
                if (m_Owner.Deleted)
                {
                    Stop();
                    return;
                }

                m_Owner.Criminal = false;
                m_Owner.Kills    = 0;
                m_Owner.Stam     = m_Owner.StamMax;

                Mobile target = m_Owner.Focus;

                if (target == null || target.Deleted || !target.Alive || !m_Owner.CanBeHarmful(target))
                {
                    if (target != null && (!target.Alive || target.Deleted))
                    {
                        if (!target.Player && target.Corpse != null && !target.Corpse.Deleted)
                        {
                            target.Corpse.Delete();
                        }

                        target.RemoveAggressor(m_Owner);
                        target.RemoveAggressed(m_Owner);
                        m_Owner.RemoveAggressor(target);
                        m_Owner.RemoveAggressed(target);
                    }
                    Stop();
                    m_Owner.Focus           = m_Owner.Combatant = null;
                    m_Owner.AIObject.Action = ActionType.Wander;
                    return;
                }

                if (m_Owner.Combatant != target)
                {
                    m_Owner.Combatant = target;
                }

                if (!m_Owner.InRange(target, 30) || !m_Owner.CanSee(target))
                {
                    m_Owner.Focus           = m_Owner.Combatant = null;
                    m_Owner.AIObject.Action = ActionType.Wander;
                }
                else if (!m_Owner.InRange(target, 5) || !m_Owner.InLOS(target))
                {
                    TeleportTo(target);
                }

                /*else if ( !m_Owner.InRange( target, 1 ) )
                 * {
                 *      if ( !m_Owner.Move( m_Owner.GetDirectionTo( target ) | Direction.Running ) )
                 *              TeleportTo( target );
                 * }*/
            }