Пример #1
0
        public override void OnDoubleClick(Mobile from)
        {
            if (Galleon != null && !Galleon.Contains(from))
            {
                if (!(from.InRange(Location, 12)))
                {
                    return;
                }

                Galleon.Refresh();

                if (from == Galleon.Owner)
                {
                    base.OnDoubleClick(from);
                    from.MoveToWorld(Location, Map);
                    Galleon.Embark(from);
                }
                else if (Galleon.PlayerAccess != null)
                {
                    if (Galleon.PlayerAccess.ContainsKey((PlayerMobile)from))
                    {
                        if (1 <= Galleon.PlayerAccess[(PlayerMobile)from] && Galleon.PlayerAccess[(PlayerMobile)from] <= 4)
                        {
                            base.OnDoubleClick(from);
                            from.MoveToWorld(Location, Map);
                            Galleon.Embark(from);
                        }
                        else
                        {
                            from.SendLocalizedMessage(1116617); //You do not have permission to board this ship. -Dian
                            base.OnDoubleClick(from);
                        }
                    }
                    else if ((Galleon.Owner != null) && (from.Guild == Galleon.Owner.Guild) && (from.Guild != null))
                    {
                        if (1 <= Galleon.Guild && Galleon.Guild <= 4)
                        {
                            base.OnDoubleClick(from);
                            from.MoveToWorld(Location, Map);
                            Galleon.Embark(from);
                        }
                        else
                        {
                            from.SendLocalizedMessage(1116617); //You do not have permission to board this ship. -Dian
                            base.OnDoubleClick(from);
                        }
                    }
                    else if ((Galleon.Owner != null) && (from.Party == Galleon.Owner.Party) && (from.Party != null))
                    {
                        if (1 <= Galleon.Party && Galleon.Party <= 4)
                        {
                            base.OnDoubleClick(from);
                            from.MoveToWorld(Location, Map);
                            Galleon.Embark(from);
                        }
                        else
                        {
                            from.SendLocalizedMessage(1116617); //You do not have permission to board this ship. -Dian
                            base.OnDoubleClick(from);
                        }
                    }
                    else if (1 <= Galleon.Public && Galleon.Public <= 4)
                    {
                        base.OnDoubleClick(from);
                        from.MoveToWorld(Location, Map);
                        Galleon.Embark(from);
                    }
                    else
                    {
                        from.SendLocalizedMessage(1116617); //You do not have permission to board this ship. -Dian
                        base.OnDoubleClick(from);
                    }
                }
                else if ((Galleon.Owner != null) && (from.Guild == Galleon.Owner.Guild) && (from.Guild != null))
                {
                    if (1 <= Galleon.Guild && Galleon.Guild <= 4)
                    {
                        base.OnDoubleClick(from);
                        from.MoveToWorld(Location, Map);
                        Galleon.Embark(from);
                    }
                    else
                    {
                        from.SendLocalizedMessage(1116617); //You do not have permission to board this ship. -Dian
                        base.OnDoubleClick(from);
                    }
                }
                else if ((Galleon.Owner != null) && (from.Party == Galleon.Owner.Party) && (from.Party != null))
                {
                    if (1 <= Galleon.Party && Galleon.Party <= 4)
                    {
                        base.OnDoubleClick(from);
                        from.MoveToWorld(Location, Map);
                        Galleon.Embark(from);
                    }
                    else
                    {
                        from.SendLocalizedMessage(1116617); //You do not have permission to board this ship. -Dian
                        base.OnDoubleClick(from);
                    }
                }
                else if (1 <= Galleon.Public && Galleon.Public <= 4)
                {
                    base.OnDoubleClick(from);
                    from.MoveToWorld(Location, Map);
                    Galleon.Embark(from);
                }
                else
                {
                    from.SendLocalizedMessage(1116617); //You do not have permission to board this ship. -Dian
                    base.OnDoubleClick(from);
                }
            }
            else if (Galleon != null && Galleon.Contains(from))
            {
                Galleon.Refresh();

                if (Galleon.IsDriven)
                {
                    from.SendLocalizedMessage(1116610);                     //You can't do that while piloting a ship! -Dian
                    return;
                }

                Map map = Map;

                if (map == null)
                {
                    return;
                }

                int rx = 0, ry = 0;

                if (Side == BoatRopeSide.Port)
                {
                    if (Galleon.Facing == Direction.North)
                    {
                        rx = 1;
                    }
                    else if (Galleon.Facing == Direction.South)
                    {
                        rx = -1;
                    }
                    else if (Galleon.Facing == Direction.East)
                    {
                        ry = 1;
                    }
                    else if (Galleon.Facing == Direction.West)
                    {
                        ry = -1;
                    }
                }
                else if (Side == BoatRopeSide.Starboard)
                {
                    if (Galleon.Facing == Direction.North)
                    {
                        rx = -1;
                    }
                    else if (Galleon.Facing == Direction.South)
                    {
                        rx = 1;
                    }
                    else if (Galleon.Facing == Direction.East)
                    {
                        ry = -1;
                    }
                    else if (Galleon.Facing == Direction.West)
                    {
                        ry = 1;
                    }
                }

                for (int i = 1; i <= 12; ++i)
                {
                    int x = X + (i * rx);
                    int y = Y + (i * ry);
                    int z;

                    for (int j = -16; j <= 16; ++j)
                    {
                        z = from.Z + j;

                        if (map.CanFit(x, y, z, 16, false, false) && !Server.Spells.SpellHelper.CheckMulti(new Point3D(x, y, z), map) && !Region.Find(new Point3D(x, y, z), map).IsPartOf(typeof(Factions.StrongholdRegion)))
                        {
                            if (i == 1 && j >= -2 && j <= 2)
                            {
                                return;
                            }

                            from.Location = new Point3D(x, y, z);
                            Galleon.Disembark(from);
                            return;
                        }
                    }

                    z = map.GetAverageZ(x, y);

                    if (map.CanFit(x, y, z, 16, false, false) && !Server.Spells.SpellHelper.CheckMulti(new Point3D(x, y, z), map) && !Region.Find(new Point3D(x, y, z), map).IsPartOf(typeof(Factions.StrongholdRegion)))
                    {
                        if (i == 1)
                        {
                            return;
                        }

                        from.Location = new Point3D(x, y, z);
                        Galleon.Disembark(from);
                        return;
                    }
                }
            }
        }