public override void OnClick() { if (m_Vendor == null || m_Vendor.Deleted) { return; } if (BaseBoat.HasBoat(m_From)) { if (Banker.Withdraw(m_From, 100, true)) { BaseBoat boat = World.Items.Values.OfType <BaseBoat>().Where(x => x.Owner == m_From).FirstOrDefault(); if (IsSpecialShip(boat)) { ShipRune newRune = new ShipRune((BaseGalleon)boat); m_From.AddToBackpack(newRune); m_Vendor.Say(1149580); // A recall rune to your ship has been placed in your backpack. } else { KeyType[] Types = Enum.GetValues(typeof(KeyType)).Cast <KeyType>().ToArray(); Key packKey = new Key(Types[Utility.Random(Types.Length)], boat.PPlank.KeyValue, boat); packKey.MaxRange = 10; packKey.Name = "a ship key"; m_From.AddToBackpack(packKey); } } else { m_Vendor.Say(500192); // Begging thy pardon, but thou canst not afford that. } } else { m_Vendor.Say(1116767); // The ship could not be located. } }
protected override void OnTarget(Mobile from, object o) { if (o is RecallRune) { RecallRune rune = (RecallRune)o; if (rune.Marked) { m_Owner.Effect(rune.Target, rune.TargetMap, true); } else { from.SendLocalizedMessage(501805); // That rune is not yet marked. } } else if (o is Runebook) { RunebookEntry e = ((Runebook)o).Default; if (e != null) { m_Owner.Effect(e.Location, e.Map, true); } else { from.SendLocalizedMessage(502354); // Target is not marked. } } else if (o is RuneTome) { RuneTome runeTome = o as RuneTome; RuneTomeRuneEntry defaultRuneEntry = null; foreach (RuneTomeRuneEntry entry in runeTome.m_RecallRuneEntries) { if (entry == null) { continue; } if (entry.m_IsDefaultRune) { defaultRuneEntry = entry; break; } } if (defaultRuneEntry == null) { if (runeTome.m_RecallRuneEntries.Count > 0) { defaultRuneEntry = runeTome.m_RecallRuneEntries[0]; } else { from.SendMessage("There are no recall runes stored within this rune tome."); return; } } if (defaultRuneEntry != null) { m_Owner.Effect(defaultRuneEntry.m_Target, defaultRuneEntry.m_TargetMap, true); } } else if (o is ShipRune) { ShipRune rune = (ShipRune)o; BaseShip m_Ship; if (rune.m_Ship != null) { m_Ship = rune.m_Ship; if (m_Ship.Deleted) { from.SendMessage("The ship bound to this rune no longer exists."); return; } if (m_Ship.Owner == from) { m_Ship.TransferEmbarkedMobile(from); m_Owner.Effect(m_Ship.GetRandomEmbarkLocation(true), m_Ship.Map, false); } else { from.SendMessage("You must be the owner of that ship to use this rune."); } } else { from.SendMessage("The ship bound to this rune no longer exists."); } } else if (o is HouseRaffleDeed && ((HouseRaffleDeed)o).ValidLocation()) { HouseRaffleDeed deed = (HouseRaffleDeed)o; m_Owner.Effect(deed.PlotLocation, deed.PlotFacet, true); } else { from.Send(new MessageLocalized(from.Serial, from.Body, MessageType.Regular, 0x3B2, 3, 502357, from.Name, "")); // I can not recall from that object. } }
public void OnPlacement(PlayerMobile player, Point3D location) { if (player == null) { return; } if (!player.Alive) { return; } if (Deleted) { return; } else if (!IsChildOf(player.Backpack)) { player.SendLocalizedMessage(1042001); // That must be in your pack for you to use it. LaunchGump(player); } else { Map map = player.Map; if (map == null) { return; } if (player.AccessLevel < AccessLevel.GameMaster && map != Map.Felucca) { player.SendLocalizedMessage(1043284); // A ship can not be created here. LaunchGump(player); return; } if (player.Region.IsPartOf(typeof(HouseRegion)) || BaseShip.FindShipAt(player, player.Map) != null) { player.SendLocalizedMessage(1010568, null, 0x25); // You may not place a ship while on another ship or inside a house. LaunchGump(player); return; } Region region = Region.Find(location, map); if (region.IsPartOf(typeof(DungeonRegion))) { player.SendLocalizedMessage(502488); // You can not place a ship inside a dungeon. LaunchGump(player); return; } if (region.IsPartOf(typeof(HouseRegion))) { player.SendLocalizedMessage(1042549); // A ship may not be placed in this area. LaunchGump(player); return; } if (player.GetDistanceToSqrt(location) > 10) { player.SendMessage("You cannot place a ship that far away from land."); LaunchGump(player); return; } foreach (BaseShip shipInstance in BaseShip.m_Instances) { if (shipInstance.Owner == player) { player.SendMessage("You already have a ship at sea."); LaunchGump(player); return; } } BaseShip ship = (BaseShip)Activator.CreateInstance(ShipType); if (ship == null) { LaunchGump(player); return; } location = new Point3D(location.X - m_Offset.X, location.Y - m_Offset.Y, location.Z - m_Offset.Z); Direction newDirection = Direction.North; int shipFacingItemID = -1; switch (player.Direction) { case Direction.North: newDirection = Direction.North; shipFacingItemID = ship.NorthID; break; case Direction.Up: newDirection = Direction.North; shipFacingItemID = ship.NorthID; break; case Direction.East: newDirection = Direction.East; shipFacingItemID = ship.EastID; break; case Direction.Right: newDirection = Direction.East; shipFacingItemID = ship.EastID; break; case Direction.South: newDirection = Direction.South; shipFacingItemID = ship.SouthID; break; case Direction.Down: newDirection = Direction.South; shipFacingItemID = ship.SouthID; break; case Direction.West: newDirection = Direction.West; shipFacingItemID = ship.WestID; break; case Direction.Left: newDirection = Direction.West; shipFacingItemID = ship.WestID; break; default: newDirection = Direction.North; shipFacingItemID = ship.NorthID; break; } if (BaseShip.IsValidLocation(location, map) && ship.CanFit(location, map, shipFacingItemID)) { ship.Owner = player; BaseShip.PushDeedStoredPropertiesToShip(this, ship); ship.DecayTime = DateTime.UtcNow + ship.ShipDecayDelay; ship.Anchored = true; ship.SetFacing(newDirection); ship.MoveToWorld(location, map); Delete(); ShipRune shipRune = new ShipRune(ship, player); ship.m_ShipRune = shipRune; ShipRune shipBankRune = new ShipRune(ship, player); ship.m_ShipBankRune = shipBankRune; bool addedToPack = false; bool addedToBank = false; if (player.AddToBackpack(shipRune)) { addedToPack = true; } BankBox bankBox = player.FindBankNoCreate(); if (bankBox != null) { if (bankBox.Items.Count < bankBox.MaxItems) { bankBox.AddItem(shipBankRune); addedToBank = true; } } string message = "You place the ship at sea. A ship 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 ship runes."; } else if (!addedToPack) { message = "You place the ship at sea. A ship rune was placed in your bankbox, however, there was no room in your backpack to place a ship rune."; } else if (!addedToBank) { message = "You place the ship at sea. A ship rune was placed in your backpack, however, there was no room in your bankbox to place a ship rune."; } player.SendMessage(message); ShipGumpObject shipGumpObject = new ShipGumpObject(player, ship, null); player.CloseGump(typeof(ShipGump)); player.SendGump(new ShipGump(player, shipGumpObject)); } else { ship.Delete(); player.SendMessage("A ship cannot be placed there. You may change your facing to change the direction of the ship placement."); LaunchGump(player); } } }