Exemple #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)))
                {
                    m_Owner.Focus = null;
                    Stop();
                    return;
                }
                else if (m_Owner.Weapon is Fists)
                {
                    m_Owner.Kill();
                    Stop();
                    return;
                }

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

                if (target == null)
                {
                    Stop();
                }
                else if (!(target.Region is Regions.GuardedRegion))
                {
                    m_Owner.Move(m_Owner.GetDirectionTo(target));
                }
                else if (!m_Owner.InRange(target, 1))
                {
                    TeleportTo(target);
                }
            }
Exemple #2
0
 private bool OutOfMaxDistance(Mobile target)
 {
     return(!m_Owner.InRange(target, m_Owner.Weapon.MaxRange));
 }
Exemple #3
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)))
                {
                    m_Owner.Focus = null;
                    Stop();
                    return;
                }
                else if (m_Owner.Weapon is Fists)
                {
                    m_Owner.Kill();
                    Stop();
                    return;
                }

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

                if (target == null)
                {
                    Stop();
                }
                else
                {                // <instakill>
                    /* TeleportTo( target );
                     * target.BoltEffect( 0 );
                     *
                     * if ( target is BaseCreature )
                     *      ((BaseCreature)target).NoKillAwards = true;
                     *
                     * target.Damage( target.HitsMax, m_Owner );
                     * target.Kill(); // just in case, maybe Damage is overriden on some shard
                     *
                     * if ( target.Corpse != null && !target.Player )
                     *      target.Corpse.Delete();
                     *
                     * m_Owner.Focus = null;
                     * Stop();*/
                }                // </instakill>
                                 /*else */ if (!m_Owner.InRange(target, 20))
                {
                    m_Shooting    = false;
                    m_Owner.Focus = null;
                }
                else if (!m_Owner.InLOS(target))
                {
                    m_Shooting = false;
                    TeleportTo(target);
                }
                else if (!m_Owner.CanSee(target))
                {
                    m_Shooting = false;

                    if (!m_Owner.InRange(target, 2))
                    {
                        if (!m_Owner.Move(m_Owner.GetDirectionTo(target) | Direction.Running) && OutOfMaxDistance(target))
                        {
                            TeleportTo(target);
                        }
                    }
                    else
                    {
                        if (!m_Owner.UseSkill(SkillName.DetectHidden) && Utility.Random(50) == 0)
                        {
                            m_Owner.Say("Reveal!");
                        }
                    }
                }
                else
                {
                    if (m_Shooting && (TimeToSpare() || OutOfMaxDistance(target)))
                    {
                        m_Shooting = false;
                    }
                    else if (!m_Shooting && InMinDistance(target))
                    {
                        m_Shooting = true;
                    }

                    if (!m_Shooting)
                    {
                        if (m_Owner.InRange(target, 1))
                        {
                            if (!m_Owner.Move((Direction)(m_Owner.GetDirectionTo(target) - 4) | Direction.Running) && OutOfMaxDistance(target))                                     // Too close, move away
                            {
                                TeleportTo(target);
                            }
                        }
                        else if (!m_Owner.InRange(target, 2))
                        {
                            if (!m_Owner.Move(m_Owner.GetDirectionTo(target) | Direction.Running) && OutOfMaxDistance(target))
                            {
                                TeleportTo(target);
                            }
                        }
                    }
                }
            }