Пример #1
0
        public bool KickBoat(BaseBoat boat)
        {
            if (boat == null || boat.Deleted)
            {
                return(false);
            }

            for (int i = 0; i < 25; i++)
            {
                Rectangle2D rec = m_KickLocs[Utility.Random(m_KickLocs.Length)];

                int x = Utility.RandomMinMax(rec.X, rec.X + rec.Width);
                int y = Utility.RandomMinMax(rec.Y, rec.Y + rec.Height);
                int z = boat.Z;

                Point3D p = new Point3D(x, y, z);

                if (boat.CanFit(p, boat.Map, boat.ItemID))
                {
                    boat.Teleport(x - boat.X, y - boat.Y, z - boat.Z);

                    if (boat.Owner != null && boat.Owner.NetState != null)
                    {
                        boat.SendMessageToAllOnBoard(1149785); //A strong tide comes and carries your boat to deeper water.
                    }
                    return(true);
                }
            }
            return(false);
        }
Пример #2
0
        public void OnPlacement(Mobile from, Point3D p)
        {
            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;
                }

                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, boat.ItemID) && map != Map.Ilshenar && map != Map.Malas)
                {
                    Delete();

                    boat.Owner    = from;
                    boat.Anchored = true;
                    boat.ShipName = m_ShipName;

                    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);
                }
                else
                {
                    boat.Delete();
                    from.SendLocalizedMessage(1043284);                       // A ship can not be created here.
                }
            }
        }
Пример #3
0
        public override void OnSpeech(SpeechEventArgs e)
        {
            Mobile from = e.Mobile;

            if (!e.Handled && from.InRange(this, 10) && e.Speech.ToLower() == this.Word)
            {
                BaseBoat boat = BaseBoat.FindBoatAt(from, from.Map);

                if (boat == null)
                {
                    return;
                }

                if (!this.Active)
                {
                    if (boat.TillerMan != null)
                    {
                        boat.TillerMan.Say(502507);                           // Ar, Legend has it that these pillars are inactive! No man knows how it might be undone!
                    }

                    return;
                }

                Map map = from.Map;

                for (int i = 0; i < 5; i++)                   // Try 5 times
                {
                    int x = Utility.Random(Destination.X, Destination.Width);
                    int y = Utility.Random(Destination.Y, Destination.Height);
                    int z = map.GetAverageZ(x, y);

                    Point3D dest = new Point3D(x, y, z);

                    if (boat.CanFit(dest, map, boat.ItemID))
                    {
                        int xOffset = x - boat.X;
                        int yOffset = y - boat.Y;
                        int zOffset = z - boat.Z;

                        boat.Teleport(xOffset, yOffset, zOffset);

                        return;
                    }
                }

                if (boat.TillerMan != null)
                {
                    boat.TillerMan.Say(502508);                       // Ar, I refuse to take that matey through here!
                }
            }
        }
Пример #4
0
        public void OnSummonBoat(Mobile from, Point3D p)
        {
            Map map = from.Map;

            if (map == null)
            {
                return;
            }

            BaseBoat boat = SummonedBoat;

            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, boat.ItemID))
            {
                Delete();

                boat.Owner    = from;
                boat.Anchored = true;

                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);
            }
            else
            {
                boat.Delete();

                from.SendMessage("A ship cannot be summoned here.");
            }

            from.Frozen = false;
        }
Пример #5
0
        public void OnPlacement(Mobile from, Point3D p, int itemID, Direction d)
        {
            if (Deleted)
            {
                return;
            }
            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;
                }

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

                if (from.Region.IsPartOf(typeof(HouseRegion)) || b != null && (b.GetType() == Boat.GetType() || !b.IsRowBoat && !(this is RowBoatDeed)))
                {
                    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.GetMobilesOnBoard().Any()).OrderByDescending(y => y.Serial).FirstOrDefault();

                        if (lastrowboat != null)
                        {
                            lastrowboat.Delete();
                        }
                    }
                    else
                    {
                        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.
                }
            }
        }
Пример #6
0
        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.
                }
            }
        }
Пример #7
0
        public void OnPlacement(Mobile from, Point3D p, int hue)
        {
            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;
                Region reg = Region.Find(from.Location, from.Map);

                if (map == null)
                {
                    return;
                }

                BaseBoat boat = Boat;
                boat.Hue = hue;

                if (boat == null)
                {
                    return;
                }

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

                bool CanBuild = false;

                if (reg.IsPartOf(typeof(OutDoorBadRegion)) ||
                    reg.IsPartOf(typeof(VillageRegion)) ||
                    reg.IsPartOf(typeof(BargeDeadRegion)) ||
                    reg.IsPartOf(typeof(DeadRegion)) ||
                    reg.IsPartOf(typeof(PirateRegion)) ||
                    reg.IsPartOf(typeof(OutDoorRegion)) ||
                    reg.IsPartOf(typeof(PublicRegion)) ||
                    Server.Misc.Worlds.IsMainRegion(Server.Misc.Worlds.GetRegionName(from.Map, from.Location)))
                {
                    CanBuild = true;
                }

                if (DockSearch.NearDock(from) == false)
                {
                    from.SendMessage("You must be near a dock to launch your ship!");
                }
                else if (BaseBoat.IsValidLocation(p, map) && CanBuild == true && boat.CanFit(p, map, boat.ItemID))
                {
                    Delete();

                    boat.Owner    = from;
                    boat.Anchored = true;
                    boat.ShipName = m_ShipName;

                    if (from.Skills[SkillName.Fishing].Base >= 90)
                    {
                        boat.m_BoatDoor.Visible = true;
                    }

                    uint keyValue = boat.CreateKeys(from);

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

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

                    boat.TillerMan.Hue = hue;
                    boat.Hold.Hue      = hue;
                    boat.BoatDoor.Hue  = hue;
                    boat.PPlank.Hue    = hue;
                    boat.SPlank.Hue    = hue;

                    boat.MoveToWorld(p, map);
                    from.PlaySound(0x026);
                }
                else
                {
                    boat.Delete();
                    from.SendLocalizedMessage(1043284);                       // A ship can not be created here.
                }
            }
        }
Пример #8
0
        public void RemoveBoat(BaseBoat boat)
        {
            if (boat == null)
            {
                return;
            }

            //First, we'll try and put the boat in the cooresponding location where it warped in
            if (boat.Map != null && boat.Map != Map.Internal && m_Altar != null && m_Altar.WarpRegion != null)
            {
                Map         map = boat.Map;
                Rectangle2D rec = m_Altar.WarpRegion.Bounds;

                int x = boat.X - m_Bounds.X;
                int y = boat.Y - m_Bounds.Y;
                int z = map.GetAverageZ(x, y);

                Point3D ePnt = new Point3D(rec.X + x, rec.Y + y, -5);

                int offsetX = ePnt.X - boat.X;
                int offsetY = ePnt.Y - boat.Y;
                int offsetZ = map.GetAverageZ(ePnt.X, ePnt.Y) - boat.Z;

                if (boat.CanFit(ePnt, this.Map, boat.ItemID))
                {
                    boat.Teleport(offsetX, offsetY, offsetZ);

                    //int z = this.Map.GetAverageZ(boat.X, boat.Y);
                    if (boat.Z != -5)
                    {
                        boat.Z = -5;
                    }

                    if (boat.TillerMan != null)
                    {
                        boat.TillerManSay(501425); //Ar, turbulent water!
                    }
                    return;
                }
            }

            //Plan B, lets kick to some random location who-knows-where
            for (int i = 0; i < 25; i++)
            {
                Rectangle2D rec  = CorgulAltar.BoatKickLocation;
                Point3D     ePnt = CorgulAltar.GetRandomPoint(rec, Map);

                int offsetX = ePnt.X - boat.X;
                int offsetY = ePnt.Y - boat.Y;
                int offsetZ = ePnt.Z - boat.Z;

                if (boat.CanFit(ePnt, this.Map, boat.ItemID))
                {
                    boat.Teleport(offsetX, offsetY, -5);
                    boat.SendMessageToAllOnBoard("A rough patch of sea has disoriented the crew!");

                    //int z = this.Map.GetAverageZ(boat.X, boat.Y);
                    if (boat.Z != -5)
                    {
                        boat.Z = -5;
                    }

                    if (boat.TillerMan != null)
                    {
                        boat.TillerManSay(501425); //Ar, turbulent water!
                    }
                    break;
                }
            }
        }
Пример #9
0
        public void OnPlacement(Mobile from, Point3D p, int hue)
        {
            if (Deleted)
            {
                return;
            }
            else if (!IsChildOf(from.Backpack))
            {
                from.SendLocalizedMessage(1042001);                   // That must be in your pack for you to use it.
            }
            else
            {
                string phrase_a = "You must be near a dock to launch your ship!";
                string phrase_b = "A ship can not be launched here.";
                if (BaseBoat.isCarpet(Boat))
                {
                    phrase_b = "The magic of the carpet cannot be used here.";
                }

                Map    map = from.Map;
                Region reg = Region.Find(from.Location, from.Map);

                if (map == null)
                {
                    return;
                }

                if (from.Region.IsPartOf(typeof(HouseRegion)) || BaseBoat.FindBoatAt(from, from.Map) != null)
                {
                    from.SendMessage(phrase_a);
                    return;
                }

                BaseBoat boat = Boat;
                boat.Hue = hue;

                if (boat == null)
                {
                    return;
                }

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

                bool CanBuild = false;

                if (reg.IsPartOf(typeof(OutDoorBadRegion)) ||
                    reg.IsPartOf(typeof(VillageRegion)) ||
                    reg.IsPartOf(typeof(BargeDeadRegion)) ||
                    reg.IsPartOf(typeof(NecromancerRegion)) ||
                    reg.IsPartOf(typeof(DeadRegion)) ||
                    reg.IsPartOf("the Forgotten Lighthouse") ||
                    reg.IsPartOf("Anchor Rock Docks") ||
                    reg.IsPartOf("Kraken Reef Docks") ||
                    reg.IsPartOf("Savage Sea Docks") ||
                    reg.IsPartOf("Serpent Sail Docks") ||
                    reg.IsPartOf(typeof(PirateRegion)) ||
                    reg.IsPartOf(typeof(OutDoorRegion)) ||
                    reg.IsPartOf(typeof(PublicRegion)) ||
                    Server.Misc.Worlds.IsMainRegion(Server.Misc.Worlds.GetRegionName(from.Map, from.Location)))
                {
                    CanBuild = true;
                }

                if (!DockSearch.NearDock(from) && !BaseBoat.isCarpet(boat))
                {
                    from.SendMessage(phrase_a);
                }
                else if (BaseBoat.IsValidLocation(p, map) && CanBuild == true && boat.CanFit(p, map, boat.ItemID))
                {
                    Delete();

                    boat.Owner    = from;
                    boat.Anchored = true;
                    boat.ShipName = m_ShipName;

                    if (from.Skills[SkillName.Fishing].Base >= 90 && boat.m_BoatDoor != null)
                    {
                        boat.m_BoatDoor.Visible = true; boat.BoatDoor.Hue = hue;
                    }

                    uint keyValue = boat.CreateKeys(from);

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

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

                    boat.TillerMan.Hue = hue;
                    boat.Hold.Hue      = hue;
                    boat.PPlank.Hue    = hue;
                    boat.SPlank.Hue    = hue;

                    boat.MoveToWorld(p, map);
                    if (BaseBoat.isCarpet(boat))
                    {
                        from.PlaySound(0x1FD);
                    }
                    else
                    {
                        from.PlaySound(0x026);
                    }
                }
                else
                {
                    boat.Delete();
                    from.SendMessage(phrase_b);
                }
            }
        }
Пример #10
0
        public void OnPlacement(Mobile from, Point3D p)
        {
            if (Deleted)
            {
                return;
            }
            else if (!IsChildOf(from.Backpack))
            {
                from.SendAsciiMessage("That must be in your pack for you to use it.");                   // That must be in your pack for you to use it.
            }
            else
            {
                Map map = from.Map;

                if (map == null)
                {
                    return;
                }

                BaseBoat boat = Boat;

                if (boat == null)
                {
                    return;
                }

                if (from.InRange(this.DockLocation, 20))
                {
                }
                else
                {
                    from.SendAsciiMessage("You are too far away from the location at which the ship was docked.");
                    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, boat.ItemID) && map != Map.Ilshenar && map != Map.Malas)
                {
                    Delete();

                    boat.Owner    = from;
                    boat.Anchored = true;
                    boat.ShipName = m_ShipName;

                    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);
                }
                else
                {
                    boat.Delete();
                    from.SendAsciiMessage("A ship can not be created here.");                       // A ship can not be created here.
                }
            }
        }
Пример #11
0
        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.
                }
            }
        }
Пример #12
0
            protected override void OnTick()
            {
                if (!m_ShipSpawner.Activated)
                {
                    return;
                }

                DateTime nextSpawnTime = m_ShipSpawner.m_LastActivity + m_ShipSpawner.m_NextActivity;

                if (nextSpawnTime < DateTime.UtcNow)
                {
                    if (m_ShipSpawner.m_Boats.Count < m_ShipSpawner.ShipCount)
                    {
                        int shipsNeeded  = m_ShipSpawner.ShipCount - m_ShipSpawner.m_Boats.Count;
                        int shipsSpawned = 0;

                        if (!m_ShipSpawner.SpawnAllAvailable)
                        {
                            shipsNeeded = 1;
                        }

                        m_ShipSpawner.m_LastActivity = DateTime.UtcNow;
                        m_ShipSpawner.m_NextActivity = TimeSpan.FromMinutes(Utility.RandomMinMax(m_ShipSpawner.m_MinSpawnTime, m_ShipSpawner.m_MaxSpawnTime));

                        //Ships Needed
                        for (int a = 0; a < shipsNeeded; a++)
                        {
                            BaseBoat boat = GetRandomBoatType(m_ShipSpawner.m_ShipTypes);

                            if (boat == null)
                            {
                                continue;
                            }

                            bool shipSpawned = false;

                            //Make 50 Attempts to Find Randomized Location for Boat Spawn Point Before Aborting
                            for (int b = 0; b < 50; b++)
                            {
                                if (shipSpawned)
                                {
                                    break;
                                }

                                Point3D newLocation = new Point3D();

                                int x = m_ShipSpawner.X;

                                int xOffset = Utility.RandomMinMax(0, m_ShipSpawner.SpawnRange);
                                if (Utility.RandomDouble() >= .5)
                                {
                                    xOffset *= -1;
                                }

                                x += xOffset;

                                int y = m_ShipSpawner.Y;

                                int yOffset = Utility.RandomMinMax(0, m_ShipSpawner.SpawnRange);
                                if (Utility.RandomDouble() >= .5)
                                {
                                    yOffset *= -1;
                                }

                                y += yOffset;

                                newLocation.X = x;
                                newLocation.Y = y;
                                newLocation.Z = m_ShipSpawner.Z;

                                Direction newDirection     = Direction.North;
                                int       shipFacingItemID = -1;

                                //Try Preferred Direction first
                                switch (m_ShipSpawner.PreferredDirection)
                                {
                                case Direction.North:
                                    newDirection     = Direction.North;
                                    shipFacingItemID = boat.NorthID;
                                    break;

                                case Direction.Up:
                                    newDirection     = Direction.North;
                                    shipFacingItemID = boat.NorthID;
                                    break;

                                case Direction.East:
                                    newDirection     = Direction.East;
                                    shipFacingItemID = boat.EastID;
                                    break;

                                case Direction.Right:
                                    newDirection     = Direction.East;
                                    shipFacingItemID = boat.EastID;
                                    break;

                                case Direction.South:
                                    newDirection     = Direction.South;
                                    shipFacingItemID = boat.SouthID;
                                    break;

                                case Direction.Down:
                                    newDirection     = Direction.South;
                                    shipFacingItemID = boat.SouthID;
                                    break;

                                case Direction.West:
                                    newDirection     = Direction.West;
                                    shipFacingItemID = boat.WestID;
                                    break;

                                case Direction.Left:
                                    newDirection     = Direction.West;
                                    shipFacingItemID = boat.WestID;
                                    break;

                                default:
                                    newDirection     = Direction.North;
                                    shipFacingItemID = boat.NorthID;
                                    break;
                                }

                                if (boat.CanFit(newLocation, m_ShipSpawner.Map, shipFacingItemID))
                                {
                                    m_ShipSpawner.m_LastActivity = DateTime.UtcNow;

                                    boat.MoveToWorld(newLocation, m_ShipSpawner.Map);
                                    m_ShipSpawner.m_Boats.Add(boat);
                                    boat.m_ShipSpawner = m_ShipSpawner;

                                    Timer.DelayCall(TimeSpan.FromSeconds(.200), delegate
                                    {
                                        if (boat != null)
                                        {
                                            if (!boat.Deleted && boat.CanFit(newLocation, m_ShipSpawner.Map, shipFacingItemID))
                                            {
                                                boat.SetFacing(newDirection);
                                            }
                                        }
                                    });

                                    shipSpawned = true;
                                }

                                //Try Random Direction
                                else
                                {
                                    int randomDirection = Utility.RandomList(1, 2, 3, 4);

                                    switch (randomDirection)
                                    {
                                    case 1:
                                        newDirection     = Direction.North;
                                        shipFacingItemID = boat.NorthID;
                                        break;

                                    case 2:
                                        newDirection     = Direction.East;
                                        shipFacingItemID = boat.EastID;
                                        break;

                                    case 3:
                                        newDirection     = Direction.South;
                                        shipFacingItemID = boat.SouthID;
                                        break;

                                    case 4:
                                        newDirection     = Direction.West;
                                        shipFacingItemID = boat.WestID;
                                        break;
                                    }

                                    if (boat.CanFit(newLocation, m_ShipSpawner.Map, shipFacingItemID))
                                    {
                                        m_ShipSpawner.m_LastActivity = DateTime.UtcNow;

                                        boat.MoveToWorld(newLocation, m_ShipSpawner.Map);
                                        m_ShipSpawner.m_Boats.Add(boat);
                                        boat.m_ShipSpawner = m_ShipSpawner;

                                        Timer.DelayCall(TimeSpan.FromSeconds(.200), delegate
                                        {
                                            boat.SetFacing(newDirection);
                                        });

                                        shipSpawned = true;
                                    }
                                }
                            }

                            if (!shipSpawned)
                            {
                                boat.Delete();
                            }
                        }
                    }
                }
            }
Пример #13
0
        public void OnPlacement(Mobile from, Point3D p)
        {
            PlayerMobile player = from as PlayerMobile;

            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.Felucca)
                {
                    from.SendLocalizedMessage(1043284); // A ship can not be created here.
                    return;
                }

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

                if (from.GetDistanceToSqrt(p) > 10)
                {
                    from.SendMessage("You cannot place a ship that far away from land.");
                    return;
                }

                foreach (BaseBoat boatInstance in BaseBoat.m_Instances)
                {
                    if (boatInstance.Owner == from)
                    {
                        from.SendMessage("You already have a boat at sea.");
                        return;
                    }
                }

                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);

                Direction newDirection     = Direction.North;
                int       shipFacingItemID = -1;

                switch (from.Direction)
                {
                case Direction.North:
                    newDirection     = Direction.North;
                    shipFacingItemID = boat.NorthID;
                    break;

                case Direction.Up:
                    newDirection     = Direction.North;
                    shipFacingItemID = boat.NorthID;
                    break;

                case Direction.East:
                    newDirection     = Direction.East;
                    shipFacingItemID = boat.EastID;
                    break;

                case Direction.Right:
                    newDirection     = Direction.East;
                    shipFacingItemID = boat.EastID;
                    break;

                case Direction.South:
                    newDirection     = Direction.South;
                    shipFacingItemID = boat.SouthID;
                    break;

                case Direction.Down:
                    newDirection     = Direction.South;
                    shipFacingItemID = boat.SouthID;
                    break;

                case Direction.West:
                    newDirection     = Direction.West;
                    shipFacingItemID = boat.WestID;
                    break;

                case Direction.Left:
                    newDirection     = Direction.West;
                    shipFacingItemID = boat.WestID;
                    break;

                default:
                    newDirection     = Direction.North;
                    shipFacingItemID = boat.NorthID;
                    break;
                }

                if (BaseBoat.IsValidLocation(p, map) && boat.CanFit(p, map, shipFacingItemID))
                {
                    //Set Boat Properties Stored in Deed
                    boat.CoOwners       = m_CoOwners;
                    boat.Friends        = m_Friends;
                    boat.GuildAsFriends = GuildAsFriends;

                    boat.Owner    = from;
                    boat.ShipName = m_ShipName;

                    boat.TargetingMode      = m_TargetingMode;
                    boat.TimeLastRepaired   = m_TimeLastRepaired;
                    boat.NextTimeRepairable = m_NextTimeRepairable;

                    boat.DecayTime = DateTime.UtcNow + boat.BoatDecayDelay;

                    boat.Anchored = true;

                    ShipUniqueness.GenerateShipUniqueness(boat);

                    boat.HitPoints  = HitPoints;
                    boat.SailPoints = SailPoints;
                    boat.GunPoints  = GunPoints;

                    bool fullSailPoints = (boat.SailPoints == boat.BaseMaxSailPoints);
                    bool fullGunPoints  = (boat.GunPoints == boat.BaseMaxGunPoints);
                    bool fullHitPoints  = (boat.HitPoints == boat.BaseMaxHitPoints);

                    boat.SetFacing(newDirection);

                    boat.MoveToWorld(p, map);

                    Delete();

                    BoatRune boatRune = new BoatRune(boat, from);
                    boat.BoatRune = boatRune;

                    BoatRune boatBankRune = new BoatRune(boat, from);
                    boat.BoatBankRune = boatBankRune;

                    bool addedToPack = false;
                    bool addedToBank = false;

                    if (from.AddToBackpack(boatRune))
                    {
                        addedToPack = true;
                    }

                    BankBox bankBox = from.FindBankNoCreate();

                    if (bankBox != null)
                    {
                        if (bankBox.Items.Count < bankBox.MaxItems)
                        {
                            bankBox.AddItem(boatBankRune);
                            addedToBank = true;
                        }
                    }

                    string message = "You place the ship at sea. A boat rune has been placed both in your bankbox and your backpack.";

                    if (!addedToPack && !addedToBank)
                    {
                        message = "You place the ship at sea. However, there was no room in neither your bankbox nor your backpack to place boat runes.";
                    }

                    else if (!addedToPack)
                    {
                        message = "You place the ship at sea. A boat rune was placed in your bankbox, however, there was no room in your backpack to place a boat rune.";
                    }

                    else if (!addedToBank)
                    {
                        message = "You place the ship at sea. A boat rune was placed in your backpack, however, there was no room in your bankbox to place a boat rune.";
                    }

                    from.SendMessage(message);
                }

                else
                {
                    boat.Delete();
                    from.SendMessage("A boat cannot be placed there. You may change your facing to change the direction of the boat placement.");
                }
            }
        }
Пример #14
0
        public void OnPlacement(Mobile from, Point3D p, int hue)
        {
            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.Region.IsPartOf(typeof(HouseRegion)) || BaseBoat.FindBoatAt(from, from.Map) != null)
                {
                    from.SendLocalizedMessage(1010568, null, 0x25);                       // You may not place a ship while on another ship or inside a house.
                    return;
                }

                BaseBoat boat = Boat;
                boat.Hue = hue;

                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, boat.ItemID))
                {
                    Delete();

                    boat.Owner    = from;
                    boat.Anchored = true;

                    if (from.Skills[SkillName.Fishing].Base >= 90)
                    {
                        boat.m_BoatDoor.Visible = true;
                    }

                    uint keyValue = boat.CreateKeys(from);

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

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

                    boat.TillerMan.Hue = hue;
                    boat.Hold.Hue      = hue;
                    boat.BoatDoor.Hue  = hue;
                    boat.PPlank.Hue    = hue;
                    boat.SPlank.Hue    = hue;

                    boat.MoveToWorld(p, map);
                    from.PlaySound(0x026);
                }
                else
                {
                    boat.Delete();
                    from.SendLocalizedMessage(1043284);                       // A ship can not be created here.
                }
            }
        }
Пример #15
0
        public override void OnSpeech(SpeechEventArgs e)
        {
            Mobile from = e.Mobile;

            if (!e.Handled && from.InRange(this, 10) && e.Speech.ToLower() == this.Word)
            {
                BaseBoat boat = BaseBoat.FindBoatAt(from, from.Map);

                if (boat == null)
                {
                    return;
                }

                if (!this.Active)
                {
                    if (boat.TillerMan != null)
                    {
                        boat.TillerMan.Say(502507);                           // Ar, Legend has it that these pillars are inactive! No man knows how it might be undone!
                    }
                    return;
                }


                if (T2AAccess.IsT2A(m_Destination.Start, from.Map))
                {
                    if (boat.Map != null && boat.Map != Map.Internal)
                    {
                        MultiComponentList mcl = boat.Components;

                        IPooledEnumerable eable = boat.Map.GetClientsInBounds(new Rectangle2D(boat.X + mcl.Min.X, boat.Y + mcl.Min.Y, mcl.Width, mcl.Height));

                        foreach (NetState ns in eable)
                        {
                            if (ns != null && ns.Mobile != null && boat.Contains((Mobile)ns.Mobile) && !T2AAccess.HasAccess(ns.Mobile))
                            {
                                eable.Free();
                                from.SendMessage("One or more players on board does not have access to T2A at this time.");
                                return;
                            }
                        }

                        eable.Free();
                    }
                }

                Map map = from.Map;

                for (int i = 0; i < 5; i++)                   // Try 5 times
                {
                    int x = Utility.Random(Destination.X, Destination.Width);
                    int y = Utility.Random(Destination.Y, Destination.Height);
                    int z = map.GetAverageZ(x, y);

                    Point3D dest = new Point3D(x, y, z);

                    if (boat.CanFit(dest, map, boat.ItemID))
                    {
                        int xOffset = x - boat.X;
                        int yOffset = y - boat.Y;
                        int zOffset = z - boat.Z;

                        boat.Teleport(xOffset, yOffset, zOffset);

                        return;
                    }
                }

                if (boat.TillerMan != null)
                {
                    boat.TillerMan.Say(502508);                       // Ar, I refuse to take that matey through here!
                }
            }
        }
Пример #16
0
        public void CheckEnter(BaseBoat boat)
        {
            if (boat == null || this.Map == null || this.Map == Map.Internal)
            {
                return;
            }

            //Do not enter corgul region if we aren't in this region anymore
            Region r = Region.Find(boat.Location, boat.Map);

            if (r != null && !r.IsPartOf(this))
            {
                return;
            }

            Map map = this.Map;
            List <ISpawnable>   list = boat.GetObjectsOnBoard();
            List <PlayerMobile> pms  = new List <PlayerMobile>();
            bool hasMap = false;

            foreach (ISpawnable i in list)
            {
                if (i is PlayerMobile && ((PlayerMobile)i).NetState != null)
                {
                    pms.Add((PlayerMobile)i);
                    PlayerMobile pm = (PlayerMobile)i;

                    if (pm.Backpack == null)
                    {
                        continue;
                    }

                    Item item = pm.Backpack.FindItemByType(typeof(CorgulIslandMap));
                    if (item != null && item is CorgulIslandMap && this.Contains(((CorgulIslandMap)item).DestinationPoint))
                    {
                        hasMap = true;
                        break;
                    }
                }
            }

            if (hasMap)
            {
                int x = boat.X - m_Bounds.X;
                int y = boat.Y - m_Bounds.Y;
                int z = map.GetAverageZ(x, y);

                Point3D ePnt = new Point3D(CorgulAltar.CorgulBounds.X + x, CorgulAltar.CorgulBounds.Y + y, 0);

                int offsetX = ePnt.X - boat.X;
                int offsetY = ePnt.Y - boat.Y;
                int offsetZ = map.GetAverageZ(ePnt.X, ePnt.Y) - boat.Z;

                if (boat.CanFit(ePnt, this.Map, boat.ItemID))
                {
                    boat.Teleport(offsetX, offsetY, offsetZ);

                    //int z = this.Map.GetAverageZ(boat.X, boat.Y);
                    if (boat.Z != 0)
                    {
                        boat.Z = 0;
                    }

                    if (boat.TillerMan != null)
                    {
                        boat.TillerManSay(501425); //Ar, turbulent water!
                    }
                }
                else
                {
                    boat.StopMove(true);
                    boat.SendMessageToAllOnBoard("The boat has struck a coral reef!");
                }
            }
        }
Пример #17
0
        public void OnPlacement(Mobile from, Point3D p)
        {
            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)) || BaseBoat.FindBoatAt(from, from.Map) != null)
                {
                    from.SendLocalizedMessage(1010568, null, 0x25); // You may not place a ship while on another ship or inside a house.
                    return;
                }

                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, boat.ItemID))
                {
                    Delete();

                    boat.Owner    = from;
                    boat.Anchored = true;

                    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);
                }
                else
                {
                    boat.Delete();
                    from.SendLocalizedMessage(1043284); // A ship can not be created here.
                }
            }
        }
Пример #18
0
        public void OnPlacement(Mobile from, Point3D p)
        {
            if (Deleted)
            {
                return;
            }

            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)) || BaseBoat.FindBoatAt(from, from.Map) != null)
                {
                    // You may not place a ship while on another ship or inside a house.
                    from.SendLocalizedMessage(1010568, null, 0x25);
                    return;
                }

                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, boat.ItemID))
                {
                    Delete();

                    boat.Owner    = from;
                    boat.Anchored = true;

                    uint keyValue = boat.CreateKeys(from);

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

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

                    foreach (BoatComponent component in boat.BoatComponents)
                    {
                        if (component is BoatRope)
                        {
                            ((BoatRope)component).KeyValue = keyValue;
                        }
                    }

                    boat.MoveToWorld(p, map);
                    from.SendGump(
                        new WarningGump(
                            1060637,
                            30720,
                            "!!! WARNING WARNING WARNING WARNING !!!\nBoats are SINKABLE by using cannons. When a boat has sustained significant damage, it will also be BOARDABLE (the planks or ropes will open to anybody). This means anything that you have on the boat is at risk! The owner of a sunken boat can (through a deed that appears in their bank) either pay a ransom to those who destroyed the boat OR risk venturing out to repair the boat themselves, in which case they have a certain time window to do so or else it can be repaired and captured by anybody else (and therefore LOST TO THEM). Boat deeds and dry-docked boats ARE blessed.",
                            0xFFC000,
                            320,
                            240,
                            null,
                            null));
                }
                else
                {
                    boat.Delete();
                    from.SendLocalizedMessage(1043284);                     // A ship can not be created here.
                }
            }
        }