public virtual void DamageTarget_Callback(object state) { object[] args = (object[])state; Mobile from = (Mobile)args[0]; BaseShipWeapon weapon = (BaseShipWeapon)args[1]; IEntity target = (IEntity)args[2]; Point3D targetloc = (Point3D)args[3]; Item pitem = (Item)args[4]; IShipProjectile projectile = pitem as IShipProjectile; if (projectile != null) { projectile.OnHit(from, weapon, target, targetloc); } }
public virtual void LaunchProjectile(Mobile from, Item projectile, IEntity target, Point3D targetloc, TimeSpan delay) { IShipProjectile pitem = projectile as IShipProjectile; if (pitem == null) { return; } int animationid = pitem.AnimationID; int animationhue = pitem.AnimationHue; Effects.PlaySound(target, from.Map, Utility.RandomList(0x11B, 0x11C, 0x11D)); // show the projectile moving to the target XmlBoatFight.SendMovingProjectileEffect(this, target, animationid, ProjectileLaunchPoint, targetloc, 7, 0, false, true, animationhue); // delayed damage at the target to account for travel distance of the projectile Timer.DelayCall(delay, new TimerStateCallback(DamageTarget_Callback), new object[] { from, this, target, targetloc, projectile }); return; }
public virtual bool AttackTarget(Mobile from, IEntity target, Point3D targetloc, bool checkLOS) { IShipProjectile projectile = _projectile as IShipProjectile; 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)XmlBoatFight.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; 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 = WeaponLoadingDelay - dexbonus - firingspeedbonus; _nextFiringTime = DateTime.Now + 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 _projectile.Consume(1); // update the properties display Projectile = _projectile; return(true); } LaunchProjectile(from, _projectile, target, targetloc, TimeSpan.FromSeconds((double)distance * 0.08)); return(true); }