Example #1
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.");
                }
            }
        }
Example #2
0
            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 BoatRune)
                {
                    BoatRune rune = (BoatRune)o;
                    BaseBoat m_Boat;

                    if (rune.m_Boat != null)
                    {
                        m_Boat = rune.m_Boat;

                        if (m_Boat.Deleted)
                        {
                            from.SendMessage("The boat bound to this rune no longer exists.");
                            return;
                        }

                        if (m_Boat.Owner == from)
                        {
                            m_Boat.TransferEmbarkedMobile(from);
                            m_Owner.Effect(m_Boat.GetRandomEmbarkLocation(true), m_Boat.Map, false);
                        }
                        else
                        {
                            from.SendMessage("You must be the owner of that ship to use this rune.");
                        }
                    }

                    else
                    {
                        from.SendMessage("The boat 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.
                }
            }