Пример #1
0
        public override void OnDoubleClick(Mobile from)
        {
            PlayerMobile player = from as PlayerMobile;

            if (player == null)
            {
                return;
            }

            if (!m_Registered)
            {
                player.SendSound(0x055);

                player.CloseGump(typeof(ShipRegistrationGump));
                player.SendGump(new ShipRegistrationGump(player, this));
            }

            else
            {
                ShipGumpObject shipGumpObject = new ShipGumpObject(player, null, this);

                player.SendSound(0x055);

                player.CloseGump(typeof(ShipGump));
                player.SendGump(new ShipGump(player, shipGumpObject));
            }
        }
Пример #2
0
        public void LaunchGump(PlayerMobile player)
        {
            if (player == null)
            {
                return;
            }

            ShipGumpObject shipGumpObject = new ShipGumpObject(player, null, this);

            player.CloseGump(typeof(ShipGump));
            player.SendGump(new ShipGump(player, shipGumpObject));
        }
Пример #3
0
        public override void OnDoubleClick(Mobile from)
        {
            PlayerMobile player = from as PlayerMobile;

            if (player == null)
            {
                return;
            }

            if (m_Ship != null)
            {
                if (!m_Ship.Deleted)
                {
                    ShipGumpObject shipGumpObject = new ShipGumpObject(player, m_Ship, null);

                    player.CloseGump(typeof(ShipGump));
                    player.SendGump(new ShipGump(player, shipGumpObject));
                }
            }
        }
Пример #4
0
        public override void OnDoubleClick(Mobile from)
        {
            if (m_Ship == null)
            {
                return;
            }

            PlayerMobile player = from as PlayerMobile;

            if (player == null)
            {
                return;
            }

            ShipGumpObject shipGumpObject = new ShipGumpObject(player, m_Ship, null);

            shipGumpObject.m_Ship = m_Ship;

            player.SendSound(0x055);

            player.CloseGump(typeof(ShipGump));
            player.SendGump(new ShipGump(player, shipGumpObject));
        }
Пример #5
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            if (m_Player == null)
            {
                return;
            }
            if (m_Player.Deleted)
            {
                return;
            }
            if (m_Player.Backpack == null)
            {
                return;
            }
            if (m_ShipUpgradeGumpObject == null)
            {
                return;
            }

            bool closeGump = true;

            BaseShip        ship            = m_ShipUpgradeGumpObject.m_Ship;
            BaseShipDeed    shipDeed        = m_ShipUpgradeGumpObject.m_ShipDeed;
            ShipUpgradeDeed shipUpgradeDeed = m_ShipUpgradeGumpObject.m_ShipUpgradeDeed;

            ShipStatsProfile shipStatsProfile = ShipUniqueness.GetShipStatsProfile(shipDeed, ship, true, true);

            ShipUpgradeDetail upgradeDetail = null;

            bool replaceExistingUpgrade = false;

            #region Upgrade Type

            switch (m_ShipUpgradeGumpObject.m_UpgradeType)
            {
            case ShipUpgrades.UpgradeType.Theme:
                if (ship != null)
                {
                    if (ship.m_ThemeUpgrade != ShipUpgrades.ThemeType.None)
                    {
                        replaceExistingUpgrade = true;
                    }
                }

                if (shipDeed != null)
                {
                    if (shipDeed.m_ThemeUpgrade != ShipUpgrades.ThemeType.None)
                    {
                        replaceExistingUpgrade = true;
                    }
                }

                upgradeDetail = ShipUpgrades.GetThemeDetail(m_ShipUpgradeGumpObject.m_Theme);
                break;

            case ShipUpgrades.UpgradeType.Paint:
                if (ship != null)
                {
                    if (ship.m_PaintUpgrade != ShipUpgrades.PaintType.None)
                    {
                        replaceExistingUpgrade = true;
                    }
                }

                if (shipDeed != null)
                {
                    if (shipDeed.m_PaintUpgrade != ShipUpgrades.PaintType.None)
                    {
                        replaceExistingUpgrade = true;
                    }
                }

                upgradeDetail = ShipUpgrades.GetPaintDetail(m_ShipUpgradeGumpObject.m_Paint);
                break;

            case ShipUpgrades.UpgradeType.CannonMetal:
                if (ship != null)
                {
                    if (ship.m_CannonMetalUpgrade != ShipUpgrades.CannonMetalType.None)
                    {
                        replaceExistingUpgrade = true;
                    }
                }

                if (shipDeed != null)
                {
                    if (shipDeed.m_CannonMetalUpgrade != ShipUpgrades.CannonMetalType.None)
                    {
                        replaceExistingUpgrade = true;
                    }
                }

                upgradeDetail = ShipUpgrades.GetCannonMetalDetail(m_ShipUpgradeGumpObject.m_CannonMetal);
                break;

            case ShipUpgrades.UpgradeType.Outfitting:
                if (ship != null)
                {
                    if (ship.m_OutfittingUpgrade != ShipUpgrades.OutfittingType.None)
                    {
                        replaceExistingUpgrade = true;
                    }
                }

                if (shipDeed != null)
                {
                    if (shipDeed.m_OutfittingUpgrade != ShipUpgrades.OutfittingType.None)
                    {
                        replaceExistingUpgrade = true;
                    }
                }

                upgradeDetail = ShipUpgrades.GetOutfittingDetail(m_ShipUpgradeGumpObject.m_Outfitting);
                break;

            case ShipUpgrades.UpgradeType.Banner:
                if (ship != null)
                {
                    if (ship.m_BannerUpgrade != ShipUpgrades.BannerType.None)
                    {
                        replaceExistingUpgrade = true;
                    }
                }

                if (shipDeed != null)
                {
                    if (shipDeed.m_BannerUpgrade != ShipUpgrades.BannerType.None)
                    {
                        replaceExistingUpgrade = true;
                    }
                }

                upgradeDetail = ShipUpgrades.GetBannerDetail(m_ShipUpgradeGumpObject.m_Banner);
                break;

            case ShipUpgrades.UpgradeType.Charm:
                if (ship != null)
                {
                    if (ship.m_CharmUpgrade != ShipUpgrades.CharmType.None)
                    {
                        replaceExistingUpgrade = true;
                    }
                }

                if (shipDeed != null)
                {
                    if (shipDeed.m_CharmUpgrade != ShipUpgrades.CharmType.None)
                    {
                        replaceExistingUpgrade = true;
                    }
                }

                upgradeDetail = ShipUpgrades.GetCharmDetail(m_ShipUpgradeGumpObject.m_Charm);
                break;

            case ShipUpgrades.UpgradeType.MinorAbility:
                if (ship != null)
                {
                    if (ship.m_MinorAbilityUpgrade != ShipUpgrades.MinorAbilityType.None)
                    {
                        replaceExistingUpgrade = true;
                    }
                }

                if (shipDeed != null)
                {
                    if (shipDeed.m_MinorAbilityUpgrade != ShipUpgrades.MinorAbilityType.None)
                    {
                        replaceExistingUpgrade = true;
                    }
                }

                upgradeDetail = ShipUpgrades.GetMinorAbilityDetail(m_ShipUpgradeGumpObject.m_MinorAbility);
                break;

            case ShipUpgrades.UpgradeType.MajorAbility:
                if (ship != null)
                {
                    if (ship.m_MajorAbilityUpgrade != ShipUpgrades.MajorAbilityType.None)
                    {
                        replaceExistingUpgrade = true;
                    }
                }

                if (shipDeed != null)
                {
                    if (shipDeed.m_MajorAbilityUpgrade != ShipUpgrades.MajorAbilityType.None)
                    {
                        replaceExistingUpgrade = true;
                    }
                }

                upgradeDetail = ShipUpgrades.GetMajorAbilityDetail(m_ShipUpgradeGumpObject.m_MajorAbility);
                break;

            case ShipUpgrades.UpgradeType.EpicAbility:
                if (ship != null)
                {
                    if (ship.m_EpicAbilityUpgrade != ShipUpgrades.EpicAbilityType.None)
                    {
                        replaceExistingUpgrade = true;
                    }
                }

                if (shipDeed != null)
                {
                    if (shipDeed.m_EpicAbilityUpgrade != ShipUpgrades.EpicAbilityType.None)
                    {
                        replaceExistingUpgrade = true;
                    }
                }

                upgradeDetail = ShipUpgrades.GetEpicAbilityDetail(m_ShipUpgradeGumpObject.m_EpicAbility);
                break;
            }

            #endregion

            if (upgradeDetail == null)
            {
                return;
            }

            switch (info.ButtonID)
            {
            //Guide
            case 1:
                closeGump = false;
                break;

            //Install
            case 2:
                switch (m_ShipUpgradeGumpObject.m_UpgradeDisplayMode)
                {
                case UpgradeDisplayMode.DeedUse:
                    if (shipUpgradeDeed == null)
                    {
                        m_Player.SendMessage("That deed is no longer accessible.");
                    }

                    else if (shipUpgradeDeed.Deleted)
                    {
                        m_Player.SendMessage("That deed is no longer accessible.");
                    }

                    else if (!shipUpgradeDeed.IsChildOf(m_Player.Backpack))
                    {
                        m_Player.SendMessage("That deed is no longer accessible.");
                    }

                    else
                    {
                        m_Player.SendMessage("Which ship do you wish to install this upgrade into?");
                        m_Player.Target = new ShipUpgradeTarget(m_Player, m_ShipUpgradeGumpObject);

                        return;
                    }
                    break;

                case UpgradeDisplayMode.DeedAttemptInstall:
                    if (shipUpgradeDeed == null)
                    {
                        m_Player.SendMessage("That upgrade deed is no longer accessible.");
                    }

                    else if (shipUpgradeDeed.Deleted)
                    {
                        m_Player.SendMessage("That upgrade deed is no longer accessible.");
                    }

                    else if (!shipUpgradeDeed.IsChildOf(m_Player.Backpack))
                    {
                        m_Player.SendMessage("That upgrade deed is no longer accessible.");
                    }

                    else if (shipDeed == null)
                    {
                        m_Player.SendMessage("That ship token is no longer accessible.");
                    }

                    else if (shipDeed.Deleted)
                    {
                        m_Player.SendMessage("That ship token is no longer accessible.");
                    }

                    else if (!shipDeed.IsChildOf(m_Player.Backpack))
                    {
                        m_Player.SendMessage("That ship token is no longer accessible.");
                    }

                    else
                    {
                        int doubloonBaseCost = ShipUniqueness.GetShipUpgradeBaseDoubloonCost(upgradeDetail.m_UpgradeType);

                        double doubloonMultiplier   = shipStatsProfile.UpgradeDoubloonMultiplier;
                        int    doubloonAdjustedCost = (int)(Math.Round((double)doubloonBaseCost * (double)doubloonMultiplier));

                        if (replaceExistingUpgrade)
                        {
                            doubloonAdjustedCost = 0;
                        }

                        int doubloonBalance = Banker.GetUniqueCurrencyBalance(m_Player, typeof(Doubloon));

                        if (doubloonBalance >= doubloonAdjustedCost)
                        {
                            if (doubloonAdjustedCost > 0)
                            {
                                Banker.WithdrawUniqueCurrency(m_Player, typeof(Doubloon), doubloonAdjustedCost, true);
                            }

                            switch (upgradeDetail.m_UpgradeType)
                            {
                            case ShipUpgrades.UpgradeType.Theme: shipDeed.m_ThemeUpgrade = shipUpgradeDeed.m_ThemeUpgrade; break;

                            case ShipUpgrades.UpgradeType.Paint: shipDeed.m_PaintUpgrade = shipUpgradeDeed.m_PaintUpgrade; break;

                            case ShipUpgrades.UpgradeType.CannonMetal: shipDeed.m_CannonMetalUpgrade = shipUpgradeDeed.m_CannonMetalUpgrade; break;

                            case ShipUpgrades.UpgradeType.Outfitting: shipDeed.m_OutfittingUpgrade = shipUpgradeDeed.m_OutfittingUpgrade; break;

                            case ShipUpgrades.UpgradeType.Banner: shipDeed.m_BannerUpgrade = shipUpgradeDeed.m_BannerUpgrade; break;

                            case ShipUpgrades.UpgradeType.Charm: shipDeed.m_CharmUpgrade = shipUpgradeDeed.m_CharmUpgrade; break;

                            case ShipUpgrades.UpgradeType.MinorAbility: shipDeed.m_MinorAbilityUpgrade = shipUpgradeDeed.m_MinorAbilityUpgrade; break;

                            case ShipUpgrades.UpgradeType.MajorAbility: shipDeed.m_MajorAbilityUpgrade = shipUpgradeDeed.m_MajorAbilityUpgrade; break;

                            case ShipUpgrades.UpgradeType.EpicAbility: shipDeed.m_EpicAbilityUpgrade = shipUpgradeDeed.m_EpicAbilityUpgrade; break;
                            }

                            if (m_Player.HasGump(typeof(ShipGump)))
                            {
                                m_Player.CloseGump(typeof(ShipGump));
                            }

                            ShipGumpObject shipGumpObject = new ShipGumpObject(m_Player, null, shipDeed);

                            shipGumpObject.m_ShipPage = ShipGump.ShipPageType.Upgrades;

                            m_Player.SendGump(new ShipGump(m_Player, shipGumpObject));

                            if (replaceExistingUpgrade)
                            {
                                m_Player.SendMessage("You place an upgrade onto your ship, overriding the existing one.");
                            }
                            else
                            {
                                m_Player.SendMessage("You place an upgrade onto your ship.");
                            }

                            m_Player.SendSound(0x23D);

                            m_ShipUpgradeGumpObject.m_ShipUpgradeDeed.Delete();

                            return;
                        }

                        else
                        {
                            m_Player.SendMessage("You do not have the neccessary " + doubloonAdjustedCost.ToString() + " doubloons in your bank box to install this upgrade.");
                        }
                    }
                    break;

                case UpgradeDisplayMode.InstalledOnShip:
                    break;
                }

                closeGump = false;
                break;
            }

            if (!closeGump)
            {
                m_Player.CloseGump(typeof(ShipUpgradeGump));
                m_Player.SendGump(new ShipUpgradeGump(m_Player, m_ShipUpgradeGumpObject));
            }
            else
            {
                m_Player.SendSound(CloseGumpSound);
            }
        }
Пример #6
0
        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);
                }
            }
        }