Пример #1
0
 public override bool Interact(GamePlayer player)
 {
     if (player.CharacterClass.Name == "Enchantress")
     {
        TradeItems = new MerchantTradeItems("" + "Enchanter" + "Epic");
     }
     else if (player.CharacterClass.Name == "Sorceress")
     {
        TradeItems = new MerchantTradeItems("" + "Sorcerer" + "Epic");
     }
     else if (player.CharacterClass.Name == "Armswoman")
     {
        TradeItems = new MerchantTradeItems("" + "Armsman" + "Epic");
     }
     else if (player.CharacterClass.Name == "Blademistress")
     {
        TradeItems = new MerchantTradeItems("" + "Blademaster" + "Epic");
     }
     else if (player.CharacterClass.Name == "Heroine")
     {
        TradeItems = new MerchantTradeItems("" + "Hero" + "Epic");
     }
     else if (player.CharacterClass.Name == "Huntress")
     {
        TradeItems = new MerchantTradeItems("" + "Hunter" + "Epic");
     }
     else
     {
         TradeItems = new MerchantTradeItems("" + player.CharacterClass.Name + "Epic");
     }
     player.Out.SendMerchantWindow(TradeItems, eMerchantWindowType.Bp);
     return true;
 }
Пример #2
0
 public override bool Interact(GamePlayer player)
 {
     if (player.CharacterClass.Name == "Enchantress")
     {
         TradeItems = new MerchantTradeItems("" + "Enchanter" + "Epic");
     }
     else if (player.CharacterClass.Name == "Sorceress")
     {
         TradeItems = new MerchantTradeItems("" + "Sorcerer" + "Epic");
     }
     else if (player.CharacterClass.Name == "Armswoman")
     {
         TradeItems = new MerchantTradeItems("" + "Armsman" + "Epic");
     }
     else if (player.CharacterClass.Name == "Blademistress")
     {
         TradeItems = new MerchantTradeItems("" + "Blademaster" + "Epic");
     }
     else if (player.CharacterClass.Name == "Heroine")
     {
         TradeItems = new MerchantTradeItems("" + "Hero" + "Epic");
     }
     else if (player.CharacterClass.Name == "Huntress")
     {
         TradeItems = new MerchantTradeItems("" + "Hunter" + "Epic");
     }
     else
     {
         TradeItems = new MerchantTradeItems("" + player.CharacterClass.Name + "Epic");
     }
     player.Out.SendMerchantWindow(TradeItems, eMerchantWindowType.Bp);
     return(true);
 }
Пример #3
0
        public override void LoadTemplate(INpcTemplate template)
        {
            base.LoadTemplate(template);

            if (template != null && string.IsNullOrEmpty(template.ItemsListTemplateID) == false)
            {
                TradeItems = new MerchantTradeItems(template.ItemsListTemplateID);
            }
        }
Пример #4
0
        /// <summary>
        /// Loads a merchant from the DB
        /// </summary>
        /// <param name="merchantobject">The merchant DB object</param>
        public override void LoadFromDatabase(DataObject merchantobject)
        {
            base.LoadFromDatabase(merchantobject);
            if (!(merchantobject is Mob))
            {
                return;
            }
            Mob merchant = (Mob)merchantobject;

            if (merchant.ItemsListTemplateID != null && merchant.ItemsListTemplateID.Length > 0)
            {
                m_tradeItems = new MerchantTradeItems(merchant.ItemsListTemplateID);
            }
        }
Пример #5
0
		/// <summary>
		/// Loads a merchant from the DB
		/// </summary>
		/// <param name="merchantobject">The merchant DB object</param>
		public override void LoadFromDatabase(DataObject merchantobject)
		{
			base.LoadFromDatabase(merchantobject);
			if (!(merchantobject is Mob)) return;
			Mob merchant = (Mob)merchantobject;
			if (merchant.ItemsListTemplateID != null && merchant.ItemsListTemplateID.Length > 0)
				m_tradeItems = new MerchantTradeItems(merchant.ItemsListTemplateID);
		}
Пример #6
0
		public override void LoadTemplate(INpcTemplate template)
		{
			base.LoadTemplate(template);

			if (string.IsNullOrEmpty(template.ItemsListTemplateID) == false)
			{
				TradeItems = new MerchantTradeItems(template.ItemsListTemplateID);
			}
		}
Пример #7
0
		/// <summary>
		/// Called when a player buys an item
		/// </summary>
		/// <param name="player">The player making the purchase</param>
		/// <param name="item_slot">slot of the item to be bought</param>
		/// <param name="number">Number to be bought</param>
		/// <param name="TradeItems"></param>
		/// <returns>true if buying is allowed, false if buying should be prevented</returns>
		public static void OnPlayerBuy(GamePlayer player, int item_slot, int number, MerchantTradeItems TradeItems)
		{
			//Get the template
			int pagenumber = item_slot / MerchantTradeItems.MAX_ITEM_IN_TRADEWINDOWS;
			int slotnumber = item_slot % MerchantTradeItems.MAX_ITEM_IN_TRADEWINDOWS;

			ItemTemplate template = TradeItems.GetItem(pagenumber, (eMerchantWindowSlot)slotnumber);
			if (template == null) return;

			//Calculate the amout of items
			int amountToBuy = number;
			if (template.PackSize > 0)
				amountToBuy *= template.PackSize;

			if (amountToBuy <= 0) return;

			//Calculate the value of items
			long totalValue = number * template.Price;

			lock (player.Inventory)
			{

				if (player.GetCurrentMoney() < totalValue)
				{
					player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client, "GameMerchant.OnPlayerBuy.YouNeed", Money.GetString(totalValue)), eChatType.CT_System, eChatLoc.CL_SystemWindow);
					return;
				}

				if (!player.Inventory.AddTemplate(GameInventoryItem.Create<ItemTemplate>(template), amountToBuy, eInventorySlot.FirstBackpack, eInventorySlot.LastBackpack))
				{
					player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client, "GameMerchant.OnPlayerBuy.NotInventorySpace"), eChatType.CT_System, eChatLoc.CL_SystemWindow);
					return;
				}
				InventoryLogging.LogInventoryAction("(TRADEITEMS;" + TradeItems.ItemsListID + ")", player, eInventoryActionType.Merchant, template, amountToBuy);
				//Generate the buy message
				string message;
				if (amountToBuy > 1)
					message = LanguageMgr.GetTranslation(player.Client, "GameMerchant.OnPlayerBuy.BoughtPieces", amountToBuy, template.GetName(1, false), Money.GetString(totalValue));
				else
					message = LanguageMgr.GetTranslation(player.Client, "GameMerchant.OnPlayerBuy.Bought", template.GetName(1, false), Money.GetString(totalValue));

				// Check if player has enough money and subtract the money
				if (!player.RemoveMoney(totalValue, message, eChatType.CT_Merchant, eChatLoc.CL_SystemWindow))
				{
					throw new Exception("Money amount changed while adding items.");
				}
				InventoryLogging.LogInventoryAction(player, "(TRADEITEMS;" + TradeItems.ItemsListID + ")", eInventoryActionType.Merchant, totalValue);
			}
		}
Пример #8
0
        /// <summary>
        /// Called when a player buys an item
        /// </summary>
        /// <param name="player">The player making the purchase</param>
        /// <param name="item_slot">slot of the item to be bought</param>
        /// <param name="number">Number to be bought</param>
        /// <param name="TradeItems"></param>
        /// <returns>true if buying is allowed, false if buying should be prevented</returns>
        public static void OnPlayerBuy(GamePlayer player, int item_slot, int number, MerchantTradeItems TradeItems)
        {
            //Get the template
            int pagenumber = item_slot / MerchantTradeItems.MAX_ITEM_IN_TRADEWINDOWS;
            int slotnumber = item_slot % MerchantTradeItems.MAX_ITEM_IN_TRADEWINDOWS;

            ItemTemplate template = TradeItems.GetItem(pagenumber, (eMerchantWindowSlot)slotnumber);

            if (template == null)
            {
                return;
            }

            //Calculate the amout of items
            int amountToBuy = number;

            if (template.PackSize > 0)
            {
                amountToBuy *= template.PackSize;
            }

            if (amountToBuy <= 0)
            {
                return;
            }

            //Calculate the value of items
            long totalValue = number * template.Price;

            lock (player.Inventory)
            {
                if (player.GetCurrentMoney() < totalValue)
                {
                    player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "GameMerchant.OnPlayerBuy.YouNeed", Money.GetString(totalValue)), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                    return;
                }

                if (!player.Inventory.AddTemplate(GameInventoryItem.Create(template), amountToBuy, eInventorySlot.FirstBackpack, eInventorySlot.LastBackpack))
                {
                    player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "GameMerchant.OnPlayerBuy.NotInventorySpace"), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                    return;
                }
                InventoryLogging.LogInventoryAction("(TRADEITEMS;" + TradeItems.ItemsListID + ")", player, eInventoryActionType.Merchant, template, amountToBuy);
                //Generate the buy message
                string message;
                if (amountToBuy > 1)
                {
                    message = LanguageMgr.GetTranslation(player.Client.Account.Language, "GameMerchant.OnPlayerBuy.BoughtPieces", amountToBuy, template.GetName(1, false), Money.GetString(totalValue));
                }
                else
                {
                    message = LanguageMgr.GetTranslation(player.Client.Account.Language, "GameMerchant.OnPlayerBuy.Bought", template.GetName(1, false), Money.GetString(totalValue));
                }

                // Check if player has enough money and subtract the money
                if (!player.RemoveMoney(totalValue, message, eChatType.CT_Merchant, eChatLoc.CL_SystemWindow))
                {
                    throw new Exception("Money amount changed while adding items.");
                }
                InventoryLogging.LogInventoryAction(player, "(TRADEITEMS;" + TradeItems.ItemsListID + ")", eInventoryActionType.Merchant, totalValue);
            }
        }
Пример #9
0
        public override bool WhisperReceive(GameLiving source, string str)
        {
            if (!base.WhisperReceive(source, str))
                return false;
            GamePlayer player = source as GamePlayer;
            if (player == null) return false;

            switch (str)
            {
                case "Gold":
                    {
                        TurnTo(player, 10000);
                        isBounty = false;
                        TradeItems = new MerchantTradeItems("BuffTokens");
                        SendMerchantWindow(player);
                    }
                    break;
                case "Bounty Points":
                    {
                        TurnTo(player, 10000);
                        isBounty = true;
                        TradeItems = new MerchantTradeItems("BPBuffTokens");
                        player.Out.SendMerchantWindow(TradeItems, eMerchantWindowType.Bp);
                    }
                    break;
            }
            return true;
        }
Пример #10
0
 public override bool Interact(GamePlayer player)
 {
     TradeItems = new MerchantTradeItems("BuffTokens");
     if (!base.Interact(player)) return false;
     TurnTo(player, 10000);
     player.Out.SendMessage("Greetings, " + player.Name + ". The King has instructed me to strengthen you so that you may defend the lands with valor. Simply hand me the token for the enhancement you desire, and I will empower you accordingly. Do you wish to purchase tokens with [Gold] or [Bounty Points]?", eChatType.CT_Say, eChatLoc.CL_PopupWindow);
     isBounty = false;
     SendMerchantWindow(player);
     return true;
 }
Пример #11
0
		public void SendMerchantWindow(MerchantTradeItems itemlist, eMerchantWindowType windowType) { }
Пример #12
0
		public void SendMerchantWindow(MerchantTradeItems itemlist, eMerchantWindowType windowType)
		{
			if (SendMerchantWindowMethod != null) SendMerchantWindowMethod(this, itemlist, windowType);
		}