public virtual bool AttackTarget(Mobile from, IEntity target, Point3D targetloc, bool checkLOS)
        {
            ISiegeProjectile projectile = this.m_Projectile as ISiegeProjectile;

            if (from == null || from.Map == null || projectile == null)
            {
                return(false);
            }

            if (!this.HasFiringAngle(targetloc))
            {
                from.SendMessage("No firing angle");
                return(false);
            }

            // check the target range
            int distance = (int)XmlSiege.GetDistance(targetloc, this.Location);

            int projectilerange = (int)(projectile.Range * this.WeaponRangeFactor);

            if (projectilerange < distance)
            {
                from.SendMessage("Out of range");
                return(false);
            }

            if (distance <= this.MinTargetRange)
            {
                from.SendMessage("Target is too close");
                return(false);
            }

            // check the target line of sight
            int height = 1;

            if (target is Item)
            {
                height = ((Item)target).ItemData.Height;
            }
            else if (target is Mobile)
            {
                height = 14;
            }

            Point3D adjustedloc = new Point3D(targetloc.X, targetloc.Y, targetloc.Z + height);

            if (checkLOS && !this.Map.LineOfSight(this, adjustedloc))
            {
                from.SendMessage("Cannot see target");
                return(false);
            }

            // ok, the projectile is being fired
            // calculate attack parameters
            double firingspeedbonus = projectile.FiringSpeed / 10.0;
            double dexbonus         = (double)from.Dex / 30.0;
            int    weaponskill      = (int)from.Skills[SkillName.ArmsLore].Value;

            int accuracybonus = projectile.AccuracyBonus;

            // calculate the cooldown time with dexterity bonus and firing speed bonus on top of the base delay
            double loadingdelay = this.WeaponLoadingDelay - dexbonus - firingspeedbonus;

            this.m_NextFiringTime = DateTime.UtcNow + TimeSpan.FromSeconds(loadingdelay);

            // calculate the accuracy based on distance and weapon skill
            int accuracy = distance * 10 - weaponskill + accuracybonus;

            if (Utility.Random(100) < accuracy)
            {
                from.SendMessage("Target missed");
                // consume the ammunition
                this.m_Projectile.Consume(1);
                // update the properties display
                this.Projectile = this.m_Projectile;
                return(true);
            }

            this.LaunchProjectile(from, this.m_Projectile, target, targetloc, TimeSpan.FromSeconds((double)distance * 0.08));

            return(true);
        }
Beispiel #2
0
        public virtual bool AttackTarget(Mobile from, IEntity target, Point3D targetloc, bool checkLOS)
        {
            ISiegeProjectile projectile = m_Projectile as ISiegeProjectile;

            if (from == null || from.Map == null || projectile == null)
            {
                return(false);
            }

            if (!HasFiringAngle(targetloc))
            {
                from.SendMessage("No firing angle");
                return(false);
            }

            // check the target range
            int distance = (int)XmlSiege.GetDistance(targetloc, Location);

            int projectilerange = (int)(projectile.Range * WeaponRangeFactor);

            if (projectilerange < distance)
            {
                from.SendMessage("Out of range");
                return(false);
            }

            if (distance <= MinTargetRange)
            {
                from.SendMessage("Target is too close");
                return(false);
            }

            // check the target line of sight
            int height = 1;

            if (target is Item)
            {
                height = ((Item)target).ItemData.Height;
            }
            else if (target is Mobile)
            {
                height = 14;
            }

            Point3D adjustedloc = new Point3D(targetloc.X, targetloc.Y, targetloc.Z + height);

            if (checkLOS && !Map.LineOfSight(this, adjustedloc))
            {
                from.SendMessage("Cannot see target");
                return(false);
            }

            // ok, the projectile is being fired
            // calculate attack parameters
            double firingspeedbonus = projectile.FiringSpeed / 10.0;
            double dexbonus         = (double)from.Dex / 30.0;

            // calculate the cooldown time with dexterity bonus and firing speed bonus on top of the base delay
            double loadingdelay = WeaponLoadingDelay - dexbonus - firingspeedbonus;

            m_NextFiringTime = DateTime.UtcNow + TimeSpan.FromSeconds(loadingdelay);

            LaunchProjectile(from, m_Projectile, target, targetloc, TimeSpan.FromSeconds((double)distance * 0.05));

            return(true);
        }