Exemple #1
0
        public void OnPlacement(Mobile from, Point3D p, int itemID, Direction d)
        {
            if (Deleted)
            {
                return;
            }

            Map map = from.Map;

            if (map == null)
            {
                return;
            }

            if (from.AccessLevel < AccessLevel.GameMaster && (map == Map.Ilshenar || map == Map.Malas))
            {
                from.SendLocalizedMessage(1043284); // A ship can not be created here.
                return;
            }

            BaseBoat b = BaseBoat.FindBoatAt(from, from.Map);

            if (from.Region.IsPartOf(typeof(HouseRegion)) || b != null && (b.GetType() == Boat.GetType() || !b.IsRowBoat && !IsRowBoatDeed))
            {
                from.SendLocalizedMessage(1010568, null, 0x25); // You may not place a ship while on another ship or inside a house.
                return;
            }

            BoatDirection = d;
            BaseBoat boat = Boat;

            if (boat == null)
            {
                return;
            }

            p = new Point3D(p.X - Offset.X, p.Y - Offset.Y, p.Z - Offset.Z);

            if (BaseBoat.IsValidLocation(p, map) && boat.CanFit(p, map, itemID))
            {
                if (boat.IsRowBoat)
                {
                    BaseBoat lastrowboat = World.Items.Values.OfType <BaseBoat>().Where(x => x.Owner == from && x.IsRowBoat && x.Map != Map.Internal && !x.MobilesOnBoard.Any()).OrderByDescending(y => y.Serial).FirstOrDefault();

                    if (lastrowboat != null)
                    {
                        lastrowboat.Delete();
                    }
                }
                else
                {
                    Delete();
                }

                boat.Owner  = from;
                boat.ItemID = itemID;

                if (boat is BaseGalleon galleon)
                {
                    galleon.SecurityEntry = new SecurityEntry(galleon);
                    galleon.BaseBoatHue   = RandomBasePaintHue();
                }

                if (boat.IsClassicBoat)
                {
                    uint keyValue = boat.CreateKeys(from);

                    if (boat.PPlank != null)
                    {
                        boat.PPlank.KeyValue = keyValue;
                    }

                    if (boat.SPlank != null)
                    {
                        boat.SPlank.KeyValue = keyValue;
                    }
                }

                boat.MoveToWorld(p, map);
                boat.OnAfterPlacement(true);

                LighthouseAddon addon = LighthouseAddon.GetLighthouse(from);

                if (addon != null)
                {
                    if (boat.CanLinkToLighthouse)
                    {
                        from.SendLocalizedMessage(1154592); // You have linked your boat lighthouse.
                    }
                    else
                    {
                        from.SendLocalizedMessage(1154597); // Failed to link to lighthouse.
                    }
                }
            }
            else
            {
                boat.Delete();
                from.SendLocalizedMessage(1043284); // A ship can not be created here.
            }
        }
        public void OnPlacement(Mobile from, Point3D p, int itemID, Direction d)
        {
            if (Deleted)
            {
                return;
            }
            else if (!IsChildOf(from.Backpack))
            {
                from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it.
            }
            else
            {
                Map map = from.Map;

                if (map == null)
                {
                    return;
                }

                BoatDirection = d;
                BaseBoat boat = BoatItem;

                if (boat == null || boat.Deleted)
                {
                    boat = Boat;
                }

                if (boat == null)
                {
                    return;
                }

                Mobile oldOwner = boat.Owner;

                boat.BoatItem = this;
                boat.Owner    = from;

                if (oldOwner != from && boat is BaseGalleon)
                {
                    ((BaseGalleon)boat).SecurityEntry = new SecurityEntry((BaseGalleon)boat);
                }

                p = new Point3D(p.X - Offset.X, p.Y - Offset.Y, p.Z - Offset.Z);

                if (BaseBoat.IsValidLocation(p, map) && boat.CanFit(p, map, itemID) && map != Map.Ilshenar && map != Map.Malas)
                {
                    boat.SetFacing(d);
                    boat.MoveToWorld(p, map);
                    boat.OnPlacement(from);
                    boat.Refresh();

                    boat.OnAfterPlacement(false);

                    var addon = LighthouseAddon.GetLighthouse(from);

                    if (addon != null)
                    {
                        if (boat.CanLinkToLighthouse)
                        {
                            from.SendLocalizedMessage(1154592); // You have linked your boat lighthouse.
                        }
                        else
                        {
                            from.SendLocalizedMessage(1154597); // Failed to link to lighthouse.
                        }
                    }

                    if (boat.IsClassicBoat)
                    {
                        uint keyValue = boat.CreateKeys(from);

                        if (boat.PPlank != null)
                        {
                            boat.PPlank.KeyValue = keyValue;
                        }

                        if (boat.SPlank != null)
                        {
                            boat.SPlank.KeyValue = keyValue;
                        }
                    }

                    Internalize();
                }
                else
                {
                    from.SendLocalizedMessage(1043284); // A ship can not be created here.
                }
            }
        }
        public void OnPlacement(Mobile from, Point3D p, int itemID, Direction d)
        {
            if (Deleted)
            {
                return;
            }
            else if (!IsChildOf(from.Backpack))
            {
                from.SendLocalizedMessage(1042001);                   // That must be in your pack for you to use it.
            }
            else
            {
                Map map = from.Map;

                if (map == null)
                {
                    return;
                }

                if (from.AccessLevel < AccessLevel.GameMaster && (map == Map.Ilshenar || map == Map.Malas))
                {
                    from.SendLocalizedMessage(1043284);                       // A ship can not be created here.
                    return;
                }

                if (from.Region.IsPartOf(typeof(HouseRegion)) || (Server.Multis.BaseBoat.FindBoatAt(from, from.Map) != null && !(this is RowBoatDeed)))
                {
                    from.SendLocalizedMessage(1010568, null, 0x25);                       // You may not place a ship while on another ship or inside a house.
                    return;
                }

                m_Direction = d;
                BaseBoat boat = Boat;

                if (boat == null)
                {
                    return;
                }

                p = new Point3D(p.X - m_Offset.X, p.Y - m_Offset.Y, p.Z - m_Offset.Z);

                if (BaseBoat.IsValidLocation(p, map) && boat.CanFit(p, map, itemID))
                {
                    Delete();

                    boat.Owner  = from;
                    boat.ItemID = itemID;

                    if (boat is BaseGalleon)
                    {
                        ((BaseGalleon)boat).SecurityEntry = new SecurityEntry((BaseGalleon)boat);
                        ((BaseGalleon)boat).BaseBoatHue   = RandomBasePaintHue();
                    }

                    if (boat.IsClassicBoat)
                    {
                        uint keyValue = boat.CreateKeys(from);

                        if (boat.PPlank != null)
                        {
                            boat.PPlank.KeyValue = keyValue;
                        }

                        if (boat.SPlank != null)
                        {
                            boat.SPlank.KeyValue = keyValue;
                        }
                    }

                    boat.MoveToWorld(p, map);
                    boat.OnAfterPlacement(true);

                    var addon = LighthouseAddon.GetLighthouse(from);

                    if (addon != null)
                    {
                        if (boat.CanLinkToLighthouse)
                        {
                            from.SendLocalizedMessage(1154592); // You have linked your boat lighthouse.
                        }
                        else
                        {
                            from.SendLocalizedMessage(1154597); // Failed to link to lighthouse.
                        }
                    }
                }
                else
                {
                    boat.Delete();
                    from.SendLocalizedMessage(1043284);                       // A ship can not be created here.
                }
            }
        }