コード例 #1
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            if (info.ButtonID == 1 && info.IsSwitched(1))
            {
                PlayerMobile player = sender.Mobile as PlayerMobile;

                if (player != null)
                {
                    QuestSystem qs = player.Quest;

                    if (qs is CollectorQuest)
                    {
                        FindSheetMusicObjective obj = qs.FindObjective(typeof(FindSheetMusicObjective)) as FindSheetMusicObjective;

                        if (obj != null && !obj.Completed)
                        {
                            BankBox bank = player.FindBankNoCreate();

                            if (bank != null && bank.ConsumeTotal(typeof(Gold), 10))
                            {
                                obj.Complete();
                            }
                            else
                            {
                                player.SendLocalizedMessage(1055108);                                   // You don't have enough gold to buy the sheet music.
                            }
                        }
                    }
                }
            }
        }
コード例 #2
0
        public static void ClaimAllDonationItems_OnCommand(CommandEventArgs e)
        {
            PlayerMobile pm       = (PlayerMobile)e.Mobile;
            BankBox      box      = pm.FindBankNoCreate();
            ArrayList    itemList = GetDonationGiftList(pm.Account.Username);

            for (int i = 0; i < itemList.Count; i++)
            {
                DonationGift giftInfo = (DonationGift)itemList[i];
                Item         gift     = RedeemGift(giftInfo.Id, pm.Account.Username) as Item;
                if (!box.TryDropItem(pm, gift, false))
                {
                    pm.AddToBackpack(gift);
                }
            }

            pm.SendMessage("{0} items has been placed in your bank box. Thank you for your donation!", itemList.Count);
        }
コード例 #3
0
ファイル: ReferralRewardsGump.cs プロジェクト: LordEnigma/UO
        public override void OnResponse(NetState state, RelayInfo info)
        {
            if (info == null || state == null || state.Mobile == null || Rewards == null)
            {
                return;
            }

            Mobile from = state.Mobile;

            switch (info.ButtonID)
            {
            case 12:
                // page up
                int nitems = 0;
                if (Rewards != null)
                {
                    nitems = Rewards.Count;
                }

                int page = viewpage + 1;
                if (page > nitems / maxItemsPerPage)
                {
                    page = nitems / maxItemsPerPage;
                }
                state.Mobile.SendGump(new ReferralRewardsGump(state.Mobile, page));
                break;

            case 13:
                // page down
                page = viewpage - 1;
                if (page < 0)
                {
                    page = 0;
                }
                state.Mobile.SendGump(new ReferralRewardsGump(state.Mobile, page));
                break;

            default:
            {
                if (info.ButtonID >= 1000 && info.ButtonID < 2000)
                {
                    int selection = info.ButtonID - 1000;
                    if (selection < Rewards.Count)
                    {
                        ReferralRewardItems r = Rewards[selection] as ReferralRewardItems;

                        XmlReferralRewards re = (XmlReferralRewards)XmlAttach.FindAttachment(from, typeof(XmlReferralRewards));

                        if (((re.LastRewardChosen + TimeSpan.FromDays(1.0)) > DateTime.Now) && from.AccessLevel < AccessLevel.GameMaster)
                        {
                            from.SendMessage(39, "You can only purchase one referral reward per day.");
                            return;
                        }

                        if (re != null && re.PointsAvailable >= r.Cost)
                        {
                            re.PointsAvailable = re.PointsAvailable - r.Cost;
                            re.PointsSpent     = re.PointsSpent + r.Cost;
                            re.RewardsChosen++;
                            re.LastRewardChosen = DateTime.Now;

                            // create an instance of the reward type
                            object o = null;

                            try
                            {
                                o = Activator.CreateInstance(r.RewardType, r.RewardArgs);
                            }
                            catch
                            {
                            }

                            bool received = true;

                            if (o is Item)
                            {
                                if (o is BasePotion)
                                {
                                    BasePotion bp = o as BasePotion;
                                    bp.Amount = 500;
                                }
                                // and give them the item
                                PlayerMobile pm  = from as PlayerMobile;
                                BankBox      box = null;

                                if (pm != null)
                                {
                                    box = pm.FindBankNoCreate();
                                }

                                if (box != null)
                                {
                                    box.AddItem((Item)o);
                                    from.SendMessage("{0} has been placed in your bank box.", ((Item)o).Name);
                                }
                                else if (pm.Backpack != null && !pm.Backpack.Deleted)
                                {
                                    pm.Backpack.AddItem((Item)o);
                                    from.SendMessage("{0} has been placed in your backpack.", ((Item)o).Name);
                                }
                                else
                                {
                                    received = false;
                                    from.SendMessage("An error has occured, please page staff about this issue immediately!");
                                }
                            }
                            else if (o is Mobile)
                            {
                                // if it is controllable then set the buyer as master.  Note this does not check for control slot limits.
                                if (o is BaseCreature)
                                {
                                    BaseCreature b = o as BaseCreature;
                                    b.Controlled    = true;
                                    b.ControlMaster = from;
                                }

                                ((Mobile)o).MoveToWorld(from.Location, from.Map);
                            }
                            else if (o is XmlAttachment)
                            {
                                XmlAttachment a = o as XmlAttachment;


                                XmlAttach.AttachTo(from, a);
                            }
                            else
                            {
                                from.SendMessage(33, "Unable to create {0}. Please page a staff member.", r.RewardType.Name);
                                received = false;
                            }

                            from.SendMessage("You have purchased {0} for {1} Referral Points.", r.Name, r.Cost);

                            LogPurchase(r, from, state, received);
                            // creates a log of the purchased items to Donations.log in the main server folder. This is for Owners to verify donation claims, tracking what sells best, etc.
                        }
                        else
                        {
                            from.SendMessage("Insufficient Referral Points for {0}.", r.Name);
                        }
                        from.SendGump(new ReferralRewardsGump(from, viewpage));
                    }
                }
                else if (info.ButtonID >= 2000)
                {
                    int selection = info.ButtonID - 2000;
                    if (selection < Rewards.Count)
                    {
                        ReferralRewardItems r = Rewards[selection] as ReferralRewardItems;

                        from.SendGump(new ReferralRewardsGump(from, viewpage));

                        if (r != null)
                        {
                            from.CloseGump(typeof(ReferralRewardDescriptionGump));
                            from.SendGump(new ReferralRewardDescriptionGump(r));
                        }
                    }
                }
                break;
            }
            }
        }
コード例 #4
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);
                }
            }
        }