Esempio n. 1
0
 public static void OnHit(Mobile shooter, IPoint3D hit, Map map, AmmoInfo info)
 {
     /*if (info == null || map == null || map == Map.Internal || shooter == null || hit == null)
      *  return;
      *
      * if (info.AmmoType == typeof(LightHotShot) || info.AmmoType == typeof(HeavyHotShot))
      * {
      *  BaseGalleon g = BaseGalleon.FindGalleonAt(hit, map);
      *
      *  if (g != null)
      *  {
      *      int x = hit.X;
      *      int y = hit.Y;
      *      int d = g is BritannianShip ? 3 : 2;
      *
      *      switch (g.Facing)
      *      {
      *          case Direction.North:
      *          case Direction.South:
      *              do
      *              {
      *                  x = g.X + Utility.RandomMinMax(-d, d);
      *                  y = g.Y + Utility.RandomMinMax(-1, 1);
      *              }
      *              while (x == g.X);
      *              break;
      *          case Direction.East:
      *          case Direction.West:
      *              do
      *              {
      *                  x = g.X + Utility.RandomMinMax(-1, 1);
      *                  y = g.Y + Utility.RandomMinMax(-d, d);
      *              }
      *              while (y == g.Y);
      *
      *                  break;
      *      }
      *
      *      Point3D point = new Point3D(x, y, g.ZSurface);
      *      GetSurfaceTop(ref point, map);
      *
      *      new HotShotItem(point, shooter, map, TimeSpan.FromSeconds(45), 15);
      *  }
      * }
      * else if (info.AmmoType == typeof(LightFragShot) || info.AmmoType == typeof(HeavyFragShot))
      * {
      *  Mobile hitMobile = hit as Mobile;
      *  Point3D p = new Point3D(hit);
      *  List<Mobile> list = new List<Mobile>();
      *
      *  IPooledEnumerable eable = map.GetMobilesInRange(p, 2);
      *  foreach (Mobile m in eable)
      *  {
      *      if (m != hitMobile && Server.Spells.SpellHelper.ValidIndirectTarget(shooter, m) && shooter.CanBeHarmful(m, false))
      *          list.Add(m);
      *  }
      *
      *  new FragShotTimer(hitMobile, shooter, p, map, Utility.RandomMinMax(info.MinDamage, info.MaxDamage), list);
      * }*/
 }
Esempio n. 2
0
        public static void Initialize()
        {
            m_Infos = new Dictionary <Type, AmmoInfo>();

            m_Infos[typeof(LightCannonball)] = new AmmoInfo(typeof(LightCannonball), "cannonball", 20, 30, 3);
            m_Infos[typeof(HeavyCannonball)] = new AmmoInfo(typeof(HeavyCannonball), "cannonball", 30, 50, 3);
            m_Infos[typeof(LightGrapeshot)]  = new AmmoInfo(typeof(LightGrapeshot), "grapeshot", 40, 50, 3);
            m_Infos[typeof(HeavyGrapeshot)]  = new AmmoInfo(typeof(HeavyGrapeshot), "grapeshot", 50, 75, 3);

            m_Infos[typeof(HeavyFlameCannonball)] = new AmmoInfo(typeof(HeavyFlameCannonball), "cannonball", 30, 50, 3, true, 50, 50, 0, 0, 0, false);
            m_Infos[typeof(LightFlameCannonball)] = new AmmoInfo(typeof(LightFlameCannonball), "cannonball", 20, 30, 3, true, 50, 50, 0, 0, 0, false);
            m_Infos[typeof(HeavyFrostCannonball)] = new AmmoInfo(typeof(HeavyFrostCannonball), "cannonball", 30, 50, 3, true, 50, 0, 50, 0, 0, false);
            m_Infos[typeof(LightFrostCannonball)] = new AmmoInfo(typeof(LightFrostCannonball), "cannonball", 20, 30, 3, true, 50, 0, 50, 0, 0, false);

            // Custom Ammo Types, you can un-comment out to use!

            /*m_Infos[typeof(LightScatterShot)] = new AmmoInfo(typeof(LightScatterShot), "scatter shot", 20, 30, 1, false);
             * m_Infos[typeof(HeavyScatterShot)] = new AmmoInfo(typeof(HeavyScatterShot), "scatter shot", 30, 40, 1, false);
             *
             * //These require special action with onhit
             * m_Infos[typeof(LightFragShot)] = new AmmoInfo(typeof(LightFragShot), "frag shot", 20, 30, 3, true, 25, 75, 0, 0, 0, false);
             * m_Infos[typeof(HeavyFragShot)] = new AmmoInfo(typeof(HeavyFragShot), "frag shot", 35, 45, 3, true, 25, 75, 0, 0, 0, false);
             *
             * m_Infos[typeof(LightHotShot)] = new AmmoInfo(typeof(LightHotShot), "hot shot", 15, 25, 6, true, 0, 100, 0, 0, 0, true);
             * m_Infos[typeof(HeavyHotShot)] = new AmmoInfo(typeof(HeavyHotShot), "hot shot", 25, 35, 6, true, 0, 100, 0, 0, 0, true);*/
        }
Esempio n. 3
0
        public static void Initialize()
        {
            m_Infos = new Dictionary<Type, AmmoInfo>();

            m_Infos[typeof(LightCannonball)] = new AmmoInfo(typeof(LightCannonball), "cannonball", 20, 30, 3);
            m_Infos[typeof(HeavyCannonball)] = new AmmoInfo(typeof(HeavyCannonball), "cannonball", 30, 50, 3);
            m_Infos[typeof(LightGrapeshot)] = new AmmoInfo(typeof(LightGrapeshot), "grapeshot", 40, 50, 3);
            m_Infos[typeof(HeavyGrapeshot)] = new AmmoInfo(typeof(HeavyGrapeshot), "grapeshot", 50, 75, 3);

            m_Infos[typeof(HeavyFlameCannonball)] = new AmmoInfo(typeof(HeavyFlameCannonball), "cannonball", 30, 50, 3, true, 50, 50, 0, 0, 0, false);
            m_Infos[typeof(LightFlameCannonball)] = new AmmoInfo(typeof(LightFlameCannonball), "cannonball", 20, 30, 3, true, 50, 50, 0, 0, 0, false);
            m_Infos[typeof(HeavyFrostCannonball)] = new AmmoInfo(typeof(HeavyFrostCannonball), "cannonball", 30, 50, 3, true, 50, 0, 50, 0, 0, false);
            m_Infos[typeof(LightFrostCannonball)] = new AmmoInfo(typeof(LightFrostCannonball), "cannonball", 20, 30, 3, true, 50, 0, 50, 0, 0, false);

            // Custom Ammo Types, you can un-comment out to use!
            /*m_Infos[typeof(LightScatterShot)] = new AmmoInfo(typeof(LightScatterShot), "scatter shot", 20, 30, 1, false);
            m_Infos[typeof(HeavyScatterShot)] = new AmmoInfo(typeof(HeavyScatterShot), "scatter shot", 30, 40, 1, false);

            //These require special action with onhit
            m_Infos[typeof(LightFragShot)] = new AmmoInfo(typeof(LightFragShot), "frag shot", 20, 30, 3, true, 25, 75, 0, 0, 0, false);
            m_Infos[typeof(HeavyFragShot)] = new AmmoInfo(typeof(HeavyFragShot), "frag shot", 35, 45, 3, true, 25, 75, 0, 0, 0, false);

            m_Infos[typeof(LightHotShot)] = new AmmoInfo(typeof(LightHotShot), "hot shot", 15, 25, 6, true, 0, 100, 0, 0, 0, true);
            m_Infos[typeof(HeavyHotShot)] = new AmmoInfo(typeof(HeavyHotShot), "hot shot", 25, 35, 6, true, 0, 100, 0, 0, 0, true);*/
        }
Esempio n. 4
0
        public static void Initialize()
        {
            Infos[typeof(Cannonball)] = new AmmoInfo(typeof(HeavyCannonball), AmmunitionType.Cannonball, 1095804, 5000, 5000, 3);
            Infos[typeof(Grapeshot)]  = new AmmoInfo(typeof(HeavyGrapeshot), AmmunitionType.Grapeshot, 1095741, 100, 150, 3);

            Infos[typeof(FlameCannonball)] = new AmmoInfo(typeof(HeavyFlameCannonball), AmmunitionType.FlameCannonball, 1149633, 5000, 5000, 3, true, 50, 50, 0, 0, 0, false);
            Infos[typeof(FrostCannonball)] = new AmmoInfo(typeof(HeavyFrostCannonball), AmmunitionType.FrostCannonball, 1149634, 30, 50, 3, true, 50, 0, 50, 0, 0, false);
        }
Esempio n. 5
0
        public override void GetProperties(ObjectPropertyList list)
        {
            base.GetProperties(list);

            list.Add(1116026, Charged ? "#1116031" : "#1116032");                           // Charged: ~1_VALUE~
            list.Add(1116027, String.Format("{0}", AmmoInfo.GetAmmoName(this).ToString())); // Ammo: ~1_VALUE~
            list.Add(1116028, Primed ? "#1116031" : "#1116032");                            //Primed: ~1_VALUE~
            list.Add(1116580 + (int)DamageState);
            list.Add(1072241, "{0}\t{1}\t{2}\t{3}", TotalItems, MaxItems, TotalWeight, MaxWeight);
        }
Esempio n. 6
0
        public static TextDefinition GetAmmoName(IShipCannon cannon)
        {
            AmmoInfo info = Infos.Values.FirstOrDefault(i => i.AmmoType == cannon.AmmoType);

            if (info == null)
            {
                return(1116033); // None
            }

            return(info.Name);
        }
Esempio n. 7
0
        public static string GetAmmoName(BaseCannon cannon)
        {
            AmmoInfo info = AmmoInfo.GetAmmoInfo(cannon.LoadedAmmo);

            if (info != null)
            {
                return(info.Name);
            }

            return("unloaded");
        }
Esempio n. 8
0
        private BaseGalleon FindValidBoatTarget(Point3D newPoint, Map map, AmmoInfo info)
        {
            BaseGalleon galleon = BaseGalleon.FindGalleonAt(newPoint, map);

            if (galleon != null && info.RequiresSurface)
            {
                int d = galleon is BritannianShip ? 3 : 2;
                switch (galleon.Facing)
                {
                case Direction.North:
                case Direction.South:
                    if (newPoint.X <= galleon.X - d || newPoint.X >= galleon.X + d)
                    {
                        return(null);
                    }

                    break;

                case Direction.East:
                case Direction.West:
                    if (newPoint.Y <= galleon.Y - d || newPoint.Y >= galleon.Y + d)
                    {
                        return(null);
                    }

                    break;
                }

                StaticTile[] tiles = map.Tiles.GetStaticTiles(newPoint.X, newPoint.Y, true);

                foreach (StaticTile tile in tiles)
                {
                    ItemData id      = TileData.ItemTable[tile.ID & TileData.MaxItemValue];
                    bool     isWater = (tile.ID >= 0x1796 && tile.ID <= 0x17B2);

                    if (!isWater && id.Surface && !id.Impassable)
                    {
                        return(galleon);
                    }
                }

                return(null);
            }

            return(galleon);
        }
Esempio n. 9
0
        public static TextDefinition GetAmmoName(IShipCannon cannon)
        {
            AmmoInfo info = null;

            foreach (var i in Infos.Values)
            {
                if (i.AmmoType == cannon.AmmoType)
                {
                    info = i;
                    break;
                }
            }

            if (info == null)
            {
                return(1116033); // None
            }

            return(info.Name);
        }
Esempio n. 10
0
        public virtual void OnMobileHit(object obj)
        {
            object[] objects = (object[])obj;
            Mobile   toHit   = objects[0] as Mobile;
            Point3D  pnt     = (Point3D)objects[1];

            AmmoInfo ammoInfo = AmmoInfo.GetAmmoInfo((AmmunitionType)objects[2]);

            if (ammoInfo != null)
            {
                int damage = Utility.RandomMinMax(ammoInfo.MinDamage, ammoInfo.MaxDamage);

                if (Operator != null)
                {
                    Operator.DoHarmful(toHit);
                }

                AOS.Damage(toHit, Operator, damage, ammoInfo.PhysicalDamage, ammoInfo.FireDamage, ammoInfo.ColdDamage, ammoInfo.PoisonDamage, ammoInfo.EnergyDamage);
                Effects.SendLocationEffect(toHit.Location, toHit.Map, Utility.RandomBool() ? 14000 : 14013, 15, 10);
                Effects.PlaySound(toHit.Location, toHit.Map, 0x207);
            }
        }
Esempio n. 11
0
        public static void Initialize()
        {
            if (Core.EJ)
            {
                Infos[typeof(Cannonball)] = new AmmoInfo(typeof(HeavyCannonball), AmmunitionType.Cannonball, 1095804, 6500, 6500, 3);
                Infos[typeof(Grapeshot)]  = new AmmoInfo(typeof(HeavyGrapeshot), AmmunitionType.Grapeshot, 1095741, 50, 75, 3);

                Infos[typeof(FlameCannonball)] = new AmmoInfo(typeof(HeavyFlameCannonball), AmmunitionType.FlameCannonball, 1149633, 5000, 5000, 3, true, 50, 50, 0, 0, 0, false);
                Infos[typeof(FrostCannonball)] = new AmmoInfo(typeof(HeavyFrostCannonball), AmmunitionType.FrostCannonball, 1149634, 30, 50, 3, true, 50, 0, 50, 0, 0, false);
            }
            else
            {
                Infos[typeof(LightCannonball)] = new AmmoInfo(typeof(LightCannonball), AmmunitionType.Cannonball, 1095804, 5000, 5000, 3);
                Infos[typeof(HeavyCannonball)] = new AmmoInfo(typeof(HeavyCannonball), AmmunitionType.Cannonball, 1095804, 6500, 6500, 3);
                Infos[typeof(LightGrapeshot)]  = new AmmoInfo(typeof(LightGrapeshot), AmmunitionType.Grapeshot, 1095741, 40, 50, 3);
                Infos[typeof(HeavyGrapeshot)]  = new AmmoInfo(typeof(HeavyGrapeshot), AmmunitionType.Grapeshot, 1095741, 50, 75, 3);

                Infos[typeof(HeavyFlameCannonball)] = new AmmoInfo(typeof(HeavyFlameCannonball), AmmunitionType.FlameCannonball, 1149633, 5000, 5000, 3, true, 50, 50, 0, 0, 0, false);
                Infos[typeof(LightFlameCannonball)] = new AmmoInfo(typeof(LightFlameCannonball), AmmunitionType.FlameCannonball, 1149633, 5000, 5000, 3, true, 50, 50, 0, 0, 0, false);
                Infos[typeof(HeavyFrostCannonball)] = new AmmoInfo(typeof(HeavyFrostCannonball), AmmunitionType.FrostCannonball, 1149634, 5000, 5000, 3, true, 50, 0, 50, 0, 0, false);
                Infos[typeof(LightFrostCannonball)] = new AmmoInfo(typeof(LightFrostCannonball), AmmunitionType.FrostCannonball, 1149634, 5000, 5000, 3, true, 50, 0, 50, 0, 0, false);
            }
        }
Esempio n. 12
0
            public override void AddGumpLayout()
            {
                AddBackground(0, 0, 250, 175, 0x6DB);
                AddHtmlLocalized(10, 10, 230, 18, 1149614 + (int)Cannon.Position, 0x3DFF, false, false);
                AddHtmlLocalized(115, 35, 70, 18, 1158934, 0x7FE7, false, false); // STATUS

                if (Cannon.CanLight)
                {
                    AddButton(10, 35, 0xFA5, 0xFA7, 8, GumpButtonType.Reply, 0);
                    AddHtmlLocalized(45, 35, 70, 18, 1149985, 0x7FFF, false, false); // UNLOAD

                    AddButton(10, 89, 0xFA5, 0xFA7, 6, GumpButtonType.Reply, 0);
                    AddHtmlLocalized(45, 89, 70, 18, 1149638, 0x7FFF, false, false); // FIRE
                }
                else
                {
                    AddButton(10, 35, 0xFA5, 0xFA7, 1, GumpButtonType.Reply, 0);
                    AddHtmlLocalized(45, 35, 70, 18, 1158890, 0x7FFF, false, false); // PREP
                }

                AddHtmlLocalized(115, 53, 115, 18, Cannon.Charged ? 1149631 : 1149632, Cannon.Charged ? 0x1FE7 : 0x7CE7, false, false);                                           // Charged / Not Charged
                AddHtmlLocalized(115, 71, 115, 18, 1114057, Cannon.Loaded ? AmmoInfo.GetAmmoName(Cannon).ToString() : "#1149636", Cannon.Loaded ? 0x1FE7 : 0x7CE7, false, false); // Cannonball / Not Loaded
                AddHtmlLocalized(115, 89, 115, 18, Cannon.Primed ? 1149640 : 1149639, Cannon.Primed ? 0x1FE7 : 0x7CE7, false, false);                                             // Primed / No Fuse

                if (Cannon.Actions.ContainsKey(User))
                {
                    var actual = 0;
                    var list   = Cannon.Actions[User];

                    for (int i = list.Count - 1; i >= 0; i--)
                    {
                        AddHtmlLocalized(10, 112 + (actual * 18), 230, 18, Cannon.Actions[User][i], actual == list.Count - 1 ? 0x7FE7 : 0x3DEF, false, false);
                        actual++;
                    }
                }
            }
Esempio n. 13
0
        public static void OnHit(Mobile shooter, IPoint3D hit, Map map, AmmoInfo info)
        {
            /*if (info == null || map == null || map == Map.Internal || shooter == null || hit == null)
                return;

            if (info.AmmoType == typeof(LightHotShot) || info.AmmoType == typeof(HeavyHotShot))
            {
                BaseGalleon g = BaseGalleon.FindGalleonAt(hit, map);

                if (g != null)
                {
                    int x = hit.X;
                    int y = hit.Y;
                    int d = g is BritannianShip ? 3 : 2;

                    switch (g.Facing)
                    {
                        case Direction.North:
                        case Direction.South:
                            do  
                            {  
                                x = g.X + Utility.RandomMinMax(-d, d);
                                y = g.Y + Utility.RandomMinMax(-1, 1);
                            }
                            while (x == g.X);
                            break;
                        case Direction.East:
                        case Direction.West:
                            do 
                            {
                                x = g.X + Utility.RandomMinMax(-1, 1);
                                y = g.Y + Utility.RandomMinMax(-d, d);
                            }
                            while (y == g.Y);
                                
                                break;
                    }

                    Point3D point = new Point3D(x, y, g.ZSurface);
                    GetSurfaceTop(ref point, map);

                    new HotShotItem(point, shooter, map, TimeSpan.FromSeconds(45), 15);
                }
            }
            else if (info.AmmoType == typeof(LightFragShot) || info.AmmoType == typeof(HeavyFragShot))
            {
                Mobile hitMobile = hit as Mobile;
                Point3D p = new Point3D(hit);
                List<Mobile> list = new List<Mobile>();

                IPooledEnumerable eable = map.GetMobilesInRange(p, 2);
                foreach (Mobile m in eable)
                {
                    if (m != hitMobile && Server.Spells.SpellHelper.ValidIndirectTarget(shooter, m) && shooter.CanBeHarmful(m, false))
                        list.Add(m);
                }

                new FragShotTimer(hitMobile, shooter, p, map, Utility.RandomMinMax(info.MinDamage, info.MaxDamage), list);
            }*/
        }
Esempio n. 14
0
        public virtual void OnShipHit(object obj)
        {
            object[] list   = (object[])obj;
            BaseBoat target = list[0] as BaseBoat;
            Point3D  pnt    = (Point3D)list[1];

            var ammoInfo = AmmoInfo.GetAmmoInfo((AmmunitionType)list[2]);

            if (ammoInfo != null && target != null)
            {
                int damage = (Utility.RandomMinMax(ammoInfo.MinDamage, ammoInfo.MaxDamage));
                damage /= 7;
                target.OnTakenDamage(Operator, damage);

                int z = target.ZSurface;

                if (target.TillerMan != null && target.TillerMan is IEntity)
                {
                    z = ((IEntity)target.TillerMan).Z;
                }

                Direction d       = Utility.GetDirection(this, pnt);
                int       xOffset = 0;
                int       yOffset = 0;
                Point3D   hit     = pnt;

                if (!ammoInfo.RequiresSurface)
                {
                    switch (d)
                    {
                    default:
                    case Direction.North:
                        xOffset = Utility.RandomMinMax(-1, 1);
                        yOffset = Utility.RandomMinMax(-2, 0);
                        hit     = new Point3D(pnt.X + xOffset, pnt.Y + yOffset, z);
                        break;

                    case Direction.South:
                        xOffset = Utility.RandomMinMax(-1, 1);
                        yOffset = Utility.RandomMinMax(0, 2);
                        hit     = new Point3D(pnt.X + xOffset, pnt.Y + yOffset, z);
                        break;

                    case Direction.East:
                        xOffset = Utility.RandomMinMax(0, 2);
                        yOffset = Utility.RandomMinMax(-1, 1);
                        hit     = new Point3D(pnt.X + xOffset, pnt.Y + yOffset, z);
                        break;

                    case Direction.West:
                        xOffset = Utility.RandomMinMax(-2, 0);
                        yOffset = Utility.RandomMinMax(-1, 1);
                        hit     = new Point3D(pnt.X + xOffset, pnt.Y + yOffset, z);
                        break;
                    }
                }

                Effects.SendLocationEffect(hit, target.Map, Utility.RandomBool() ? 14000 : 14013, 15, 10);
                Effects.PlaySound(hit, target.Map, 0x207);

                if (Operator != null && (!Operator.Deleted || CanFireUnmanned))
                {
                    Mobile victim = target.Owner;

                    if (victim != null && target.Contains(victim) && Operator.CanBeHarmful(victim, false))
                    {
                        Operator.DoHarmful(victim);
                    }
                    else
                    {
                        List <Mobile> candidates = new List <Mobile>();
                        SecurityLevel highest    = SecurityLevel.Passenger;

                        foreach (var mob in target.GetMobilesOnBoard().OfType <PlayerMobile>().Where(pm => Operator.CanBeHarmful(pm, false)))
                        {
                            if (target is BaseGalleon && ((BaseGalleon)target).GetSecurityLevel(mob) > highest)
                            {
                                candidates.Insert(0, mob);
                            }
                            else
                            {
                                candidates.Add(mob);
                            }
                        }

                        if (candidates.Count > 0)
                        {
                            Operator.DoHarmful(candidates[0]);
                        }
                        else if (victim != null && Operator.IsHarmfulCriminal(victim))
                        {
                            Operator.CriminalAction(false);
                        }

                        ColUtility.Free(candidates);
                    }
                }
            }
        }
Esempio n. 15
0
        public Target[] AcquireTarget()
        {
            AmmoInfo ammo = AmmoInfo.GetAmmoInfo(AmmoType);

            int     xOffset = 0; int yOffset = 0;
            int     currentRange = 0;
            Point3D pnt          = Location;
            Map     map          = Map;

            switch (GetFacing())
            {
            case Direction.North:
                xOffset = 0; yOffset = -1; break;

            case Direction.South:
                xOffset = 0; yOffset = 1; break;

            case Direction.West:
                xOffset = -1; yOffset = 0; break;

            case Direction.East:
                xOffset = 1; yOffset = 0; break;
            }

            int xo            = xOffset;
            int yo            = yOffset;
            int lateralOffset = 1;

            while (currentRange++ <= Range)
            {
                xOffset = xo;
                yOffset = yo;

                if (LateralOffset > 1 && currentRange % LateralOffset == 0)
                {
                    lateralOffset++;
                }

                TimeSpan delay = TimeSpan.FromSeconds(currentRange / 10.0);

                switch (AmmoType)
                {
                case AmmunitionType.Empty: break;

                case AmmunitionType.Cannonball:
                case AmmunitionType.FrostCannonball:
                case AmmunitionType.FlameCannonball:
                {
                    Point3D newPoint = pnt;
                    //List<IEntity> list = new List<IEntity>();

                    for (int i = -lateralOffset; i <= lateralOffset; i++)
                    {
                        if (xOffset == 0)
                        {
                            newPoint = new Point3D(pnt.X + (xOffset + i), pnt.Y + (yOffset * currentRange), pnt.Z);
                        }
                        else
                        {
                            newPoint = new Point3D(pnt.X + (xOffset * currentRange), pnt.Y + (yOffset + i), pnt.Z);
                        }

                        BaseGalleon g = FindValidBoatTarget(newPoint, map, ammo);

                        if (g != null && g.DamageTaken < DamageLevel.Severely && g.Owner is PlayerMobile)
                        {
                            var target = new Target();
                            target.Entity   = g;
                            target.Location = newPoint;
                            target.Range    = currentRange;

                            return(new Target[] { target });
                        }
                    }
                }
                break;

                case AmmunitionType.Grapeshot:
                {
                    Point3D       newPoint = pnt;
                    List <Target> mobiles  = new List <Target>();

                    for (int i = -lateralOffset; i <= lateralOffset; i++)
                    {
                        if (xOffset == 0)
                        {
                            newPoint = new Point3D(pnt.X + (xOffset + i), pnt.Y + (yOffset * currentRange), pnt.Z);
                        }
                        else
                        {
                            newPoint = new Point3D(pnt.X + (xOffset * currentRange), pnt.Y + (yOffset + i), pnt.Z);
                        }

                        foreach (Mobile m in GetTargets(newPoint, map))
                        {
                            var target = new Target();
                            target.Entity   = m;
                            target.Location = newPoint;
                            target.Range    = currentRange;

                            mobiles.Add(target);
                        }

                        if (mobiles.Count > 0 && ammo.SingleTarget)
                        {
                            var toHit = mobiles[Utility.Random(mobiles.Count)];
                            ColUtility.Free(mobiles);
                            return(new Target[] { toHit });
                        }
                    }

                    if (mobiles.Count > 0)
                    {
                        return(mobiles.ToArray());
                    }
                }
                break;
                }
            }

            return(null);
        }
Esempio n. 16
0
        public virtual void OnShipHit(object obj)
        {
            object[]    list     = (object[])obj;
            BaseGalleon target   = list[0] as BaseGalleon;
            Point3D     pnt      = (Point3D)list[1];
            AmmoInfo    ammoInfo = list[2] as AmmoInfo;
            Mobile      shooter  = list[3] as Mobile;

            if (target != null && Galleon != null)
            {
                int damage = (int)(ammoInfo.GetDamage(this) * Galleon.CannonDamageMod);
                target.OnTakenDamage(shooter, damage);

                int z = target.ZSurface;

                if (target.TillerMan != null && target.TillerMan is IEntity)
                {
                    z = ((IEntity)target.TillerMan).Z;
                }

                Direction d       = Utility.GetDirection(this, pnt);
                int       xOffset = 0;
                int       yOffset = 0;
                Point3D   hit     = pnt;

                if (!ammoInfo.RequiresSurface)
                {
                    switch (d)
                    {
                    default:
                    case Direction.North:
                        xOffset = Utility.RandomMinMax(-1, 1);
                        yOffset = Utility.RandomMinMax(-2, 0);
                        hit     = new Point3D(pnt.X + xOffset, pnt.Y + yOffset, z);
                        break;

                    case Direction.South:
                        xOffset = Utility.RandomMinMax(-1, 1);
                        yOffset = Utility.RandomMinMax(0, 2);
                        hit     = new Point3D(pnt.X + xOffset, pnt.Y + yOffset, z);
                        break;

                    case Direction.East:
                        xOffset = Utility.RandomMinMax(0, 2);
                        yOffset = Utility.RandomMinMax(-1, 1);
                        hit     = new Point3D(pnt.X + xOffset, pnt.Y + yOffset, z);
                        break;

                    case Direction.West:
                        xOffset = Utility.RandomMinMax(-2, 0);
                        yOffset = Utility.RandomMinMax(-1, 1);
                        hit     = new Point3D(pnt.X + xOffset, pnt.Y + yOffset, z);
                        break;
                    }
                }

                Effects.SendLocationEffect(hit, target.Map, Utility.RandomBool() ? 14000 : 14013, 15, 10);
                Effects.PlaySound(hit, target.Map, 0x207);

                Mobile victim = target.Owner;

                if (victim != null && target.Contains(victim) && shooter.CanBeHarmful(victim, false))
                {
                    shooter.DoHarmful(victim);
                }
                else
                {
                    List <Mobile> candidates = new List <Mobile>();
                    SecurityLevel highest    = SecurityLevel.Passenger;

                    foreach (var mob in target.GetMobilesOnBoard().OfType <PlayerMobile>().Where(pm => shooter.CanBeHarmful(pm, false)))
                    {
                        if (Galleon.GetSecurityLevel(mob) > highest)
                        {
                            candidates.Insert(0, mob);
                        }
                        else
                        {
                            candidates.Add(mob);
                        }
                    }

                    if (candidates.Count > 0)
                    {
                        shooter.DoHarmful(candidates[0]);
                    }
                    else if (victim != null && shooter.IsHarmfulCriminal(victim))
                    {
                        shooter.CriminalAction(false);
                    }

                    ColUtility.Free(candidates);
                }

                if (Galleon.Map != null)
                {
                    IPooledEnumerable eable = Galleon.Map.GetItemsInRange(hit, 1);

                    foreach (Item item in eable)
                    {
                        if (item is IShipCannon && !Galleon.Contains(item))
                        {
                            ((IShipCannon)item).OnDamage(damage, shooter);
                        }
                    }

                    eable.Free();
                }
            }
        }
Esempio n. 17
0
        public virtual void Shoot(object cannoneer)
        {
            AmmoInfo ammo = AmmoInfo.GetAmmoInfo(AmmoType);

            if (ammo == null)
            {
                return;
            }

            Mobile shooter = null;

            if (cannoneer is Mobile)
            {
                shooter = (Mobile)cannoneer;
            }

            if (shooter != null && shooter.Player)
            {
                m_Hits -= Utility.RandomMinMax(0, 4);
            }

            DoShootEffects();
            AddAction(shooter, 1149691); //Fired successfully.

            int       xOffset = 0; int yOffset = 0;
            int       currentRange = 0;
            Point3D   pnt          = this.Location;
            Map       map          = this.Map;
            Direction d            = GetFacing();

            switch (d)
            {
            case Direction.North:
                xOffset = 0; yOffset = -1; break;

            case Direction.South:
                xOffset = 0; yOffset = 1; break;

            case Direction.West:
                xOffset = -1; yOffset = 0; break;

            case Direction.East:
                xOffset = 1; yOffset = 0; break;
            }

            int xo            = xOffset;
            int yo            = yOffset;
            int lateralOffset = 1;

            int latDist = ammo.LateralOffset;

            int  range = Range;
            bool hit   = false;

            while (currentRange++ <= range)
            {
                xOffset = xo;
                yOffset = yo;

                if (currentRange % latDist == 0)
                {
                    lateralOffset++;
                }

                TimeSpan delay = TimeSpan.FromSeconds((double)currentRange / 10.0);

                switch (AmmoType)
                {
                case AmmunitionType.Empty: break;

                case AmmunitionType.Cannonball:
                case AmmunitionType.FrostCannonball:
                case AmmunitionType.FlameCannonball:
                {
                    Point3D            newPoint    = pnt;
                    List <IEntity>     list        = new List <IEntity>();
                    List <IDamageable> damageables = new List <IDamageable>();

                    for (int i = -lateralOffset; i <= lateralOffset; i++)
                    {
                        if (xOffset == 0)
                        {
                            newPoint = new Point3D(pnt.X + (xOffset + i), pnt.Y + (yOffset * currentRange), pnt.Z);
                        }
                        else
                        {
                            newPoint = new Point3D(pnt.X + (xOffset * currentRange), pnt.Y + (yOffset + i), pnt.Z);
                        }

                        BaseGalleon g = FindValidBoatTarget(newPoint, map, ammo);

                        if (g != null && g != Galleon && g.IsEnemy(Galleon))
                        {
                            list.Add(g);
                        }

                        damageables.AddRange(FindDamageables(shooter, newPoint, map, false, false, false, true, true));
                    }

                    foreach (var m in damageables)
                    {
                        list.Add(m);
                    }

                    if (list.Count > 0)
                    {
                        IEntity toHit = list[Utility.Random(list.Count)];

                        if (toHit is Mobile)
                        {
                            Timer.DelayCall(delay, new TimerStateCallback(OnMobileHit), new object[] { (Mobile)toHit, newPoint, ammo, shooter });
                            hit = true;
                        }
                        else if (toHit is BaseGalleon)
                        {
                            Timer.DelayCall(delay, new TimerStateCallback(OnShipHit), new object[] { (BaseGalleon)toHit, newPoint, ammo, shooter });
                            hit = true;
                        }
                        else if (toHit is DamageableItem)
                        {
                            Timer.DelayCall(delay, new TimerStateCallback(OnDamageableItemHit), new object[] { (DamageableItem)toHit, newPoint, ammo, shooter });
                            hit = true;
                        }
                    }
                }
                break;

                case AmmunitionType.Grapeshot:
                {
                    Point3D       newPoint = pnt;
                    List <Mobile> mobiles  = new List <Mobile>();

                    for (int i = -lateralOffset; i <= lateralOffset; i++)
                    {
                        if (xOffset == 0)
                        {
                            newPoint = new Point3D(pnt.X + (xOffset + i), pnt.Y + (yOffset * currentRange), pnt.Z);
                        }
                        else
                        {
                            newPoint = new Point3D(pnt.X + (xOffset * currentRange), pnt.Y + (yOffset + i), pnt.Z);
                        }

                        mobiles.AddRange(FindDamageables(shooter, newPoint, map, true, true, true, true, false).OfType <Mobile>());
                    }

                    if (mobiles.Count > 0)
                    {
                        Timer.DelayCall(delay, new TimerStateCallback(OnMobileHit), new object[] { mobiles, newPoint, ammo, shooter });
                        hit = true;
                    }
                }
                break;
                }

                if (hit && ammo.SingleTarget)
                {
                    break;
                }
            }

            ClearCannon();
            InvalidateDamageState();

            if (shooter != null)
            {
                ResendGump(shooter);
            }
        }
Esempio n. 18
0
        private BaseGalleon FindValidBoatTarget(Point3D newPoint, Map map, AmmoInfo info)
        {
            BaseGalleon galleon = BaseGalleon.FindGalleonAt(newPoint, map);

            if (galleon != null && info.RequiresSurface)
            {
                int d = galleon is BritannianShip ? 3 : 2; 
                switch (galleon.Facing)
                {
                    case Direction.North:
                    case Direction.South:
                        if (newPoint.X <= galleon.X - d || newPoint.X >= galleon.X + d)
                            return null;
                        break;
                    case Direction.East:
                    case Direction.West:
                        if (newPoint.Y <= galleon.Y - d || newPoint.Y >= galleon.Y + d)
                            return null;
                        break;
                }

                StaticTile[] tiles = map.Tiles.GetStaticTiles(newPoint.X, newPoint.Y, true);

                foreach (StaticTile tile in tiles)
                {
                    ItemData id = TileData.ItemTable[tile.ID & TileData.MaxItemValue];
                    bool isWater = (tile.ID >= 0x1796 && tile.ID <= 0x17B2);

                    if (!isWater && id.Surface && !id.Impassable)
                    {
                        return galleon;
                    }
                }

                return null;
            }

            return galleon;
        }