Beispiel #1
0
        public bool DoRangedAttack()
        {
            Mobile c = m_Mobile.Combatant;

            if (c == null || Utility.RandomDouble() > rangedattackChance)
            {
                return(false);
            }

            double distance = m_Mobile.GetDistanceToSqrt(c);

            if (distance < 2 || distance > 6)
            {
                return(false);
            }

            int skill   = (int)m_Mobile.Skills[SkillName.Ninjitsu].Value;
            int seconds = 400 / skill;

            List <INinjaWeapon> list = new List <INinjaWeapon>();
            int d = (int)m_Mobile.GetDistanceToSqrt(c.Location);

            foreach (Item item in m_Mobile.Items)
            {
                if (item is INinjaWeapon && ((INinjaWeapon)item).UsesRemaining > 0 && d >= ((INinjaWeapon)item).WeaponMinRange && d <= ((INinjaWeapon)item).WeaponMaxRange)
                {
                    list.Add(item as INinjaWeapon);
                }
            }

            if (m_Mobile.Backpack != null)
            {
                foreach (Item item in m_Mobile.Backpack.Items)
                {
                    if (item is INinjaWeapon && ((INinjaWeapon)item).UsesRemaining > 0 && d >= ((INinjaWeapon)item).WeaponMinRange && d <= ((INinjaWeapon)item).WeaponMaxRange)
                    {
                        list.Add(item as INinjaWeapon);
                    }
                }
            }

            if (list.Count > 0)
            {
                INinjaWeapon toUse = list[Utility.Random(list.Count)];

                if (toUse != null)
                {
                    NinjaWeapon.Shoot(m_Mobile, c, toUse);
                    m_NextRanged = DateTime.UtcNow + TimeSpan.FromSeconds(seconds + Utility.RandomMinMax(-1, +1));
                    return(true);
                }
            }
            return(false);
        }
Beispiel #2
0
        public void DoRangedAttack()
        {
            Mobile c = m_Mobile.Combatant as Mobile;

            if (c == null)
            {
                return;
            }

            List <INinjaWeapon> list = new List <INinjaWeapon>();
            int d = (int)m_Mobile.GetDistanceToSqrt(c.Location);

            for (var index = 0; index < m_Mobile.Items.Count; index++)
            {
                Item item = m_Mobile.Items[index];

                if (item is INinjaWeapon weapon && weapon.UsesRemaining > 0 && d >= weapon.WeaponMinRange && d <= weapon.WeaponMaxRange)
                {
                    list.Add(weapon);
                }
            }

            if (m_Mobile.Backpack != null)
            {
                for (var index = 0; index < m_Mobile.Backpack.Items.Count; index++)
                {
                    Item item = m_Mobile.Backpack.Items[index];

                    if (item is INinjaWeapon weapon && weapon.UsesRemaining > 0 && d >= weapon.WeaponMinRange && d <= weapon.WeaponMaxRange)
                    {
                        list.Add(weapon);
                    }
                }
            }

            if (list.Count > 0)
            {
                INinjaWeapon toUse = list[Utility.Random(list.Count)];

                if (toUse != null)
                {
                    NinjaWeapon.Shoot(m_Mobile, c, toUse);
                }
            }

            ColUtility.Free(list);

            m_NextRanged = DateTime.UtcNow + TimeSpan.FromSeconds(Utility.RandomMinMax(30, 120));
        }
Beispiel #3
0
        public void DoRangedAttack()
        {
            var c = m_Mobile.Combatant as Mobile;

            if (c == null)
            {
                return;
            }

            var list = new List <INinjaWeapon>();
            var d    = (int)m_Mobile.GetDistanceToSqrt(c.Location);

            foreach (var item in m_Mobile.Items)
            {
                if (item is INinjaWeapon && ((INinjaWeapon)item).UsesRemaining > 0 && d >= ((INinjaWeapon)item).WeaponMinRange &&
                    d <= ((INinjaWeapon)item).WeaponMaxRange)
                {
                    list.Add(item as INinjaWeapon);
                }
            }

            if (m_Mobile.Backpack != null)
            {
                foreach (var item in m_Mobile.Backpack.Items)
                {
                    if (item is INinjaWeapon && ((INinjaWeapon)item).UsesRemaining > 0 && d >= ((INinjaWeapon)item).WeaponMinRange &&
                        d <= ((INinjaWeapon)item).WeaponMaxRange)
                    {
                        list.Add(item as INinjaWeapon);
                    }
                }
            }

            if (list.Count > 0)
            {
                var toUse = list[Utility.Random(list.Count)];

                if (toUse != null)
                {
                    NinjaWeapon.Shoot(m_Mobile, c, toUse);
                }
            }

            ColUtility.Free(list);

            m_NextRanged = DateTime.UtcNow + TimeSpan.FromSeconds(Utility.RandomMinMax(30, 120));
        }