示例#1
0
 /// <summary>
 /// This creates the housing consignment merchant attached to a house.
 /// You can override this to create your own consignment merchant derived from the standard merchant
 /// </summary>
 /// <returns></returns>
 public virtual GameConsignmentMerchant CreateHousingConsignmentMerchant(House house)
 {
     var m = new GameConsignmentMerchant();
     m.Name = "Consignment Merchant";
     return m;
 }
示例#2
0
文件: House.cs 项目: boscorillium/dol
		public void RemoveConsignment()
		{
			var npcmob = GameServer.Database.SelectObject<Mob>("HouseNumber = '" + HouseNumber + "'");
			if (npcmob != null)
			{
				GameNPC[] npc = WorldMgr.GetNPCsByNameFromRegion(npcmob.Name, npcmob.Region, (eRealm) npcmob.Realm);

				foreach (GameNPC hnpc in npc)
				{
					if (hnpc.HouseNumber == HouseNumber)
					{
						var itemcon = GameServer.Database.SelectObjects<InventoryItem>("OwnerID = '" + this.OwnerID + "' AND SlotPosition >= 1500 AND SlotPosition <= 1599");
						if (itemcon.Count > 0)
						{
							for (int i = 0; i < itemcon.Count; i++)
							{
								itemcon[i].OwnerLot = 0;
								GameServer.Database.SaveObject(itemcon[i]);
							}
						}
						hnpc.DeleteFromDatabase();
						hnpc.Delete();
					}
				}
			}

			var merchant = GameServer.Database.SelectObject<DBHouseMerchant>("HouseNumber = '" + HouseNumber + "'");
			if (merchant != null)
			{
				GameServer.Database.DeleteObject(merchant);
			}

			_consignment = null;
			DatabaseItem.HasConsignment = false;

			SaveIntoDatabase();
		}
        public void HandlePacket(GameClient client, GSPacketIn packet)
        {
            // player is null, return
            if (client.Player == null)
            {
                return;
            }

            // active consignment merchant is null, return
            GameConsignmentMerchant conMerchant = client.Player.ActiveInventoryObject as GameConsignmentMerchant;

            if (conMerchant == null)
            {
                return;
            }

            // current house is null, return
            House house = HouseMgr.GetHouse(conMerchant.HouseNumber);

            if (house == null)
            {
                return;
            }

            // make sure player has permissions to withdraw from the consignment merchant
            if (!house.CanUseConsignmentMerchant(client.Player, ConsignmentPermissions.Withdraw))
            {
                client.Player.Out.SendMessage("You don't have permission to withdraw money from this merchant!", eChatType.CT_Important, eChatLoc.CL_ChatWindow);
                return;
            }

            lock (conMerchant.LockObject())
            {
                long totalConMoney = conMerchant.TotalMoney;

                if (totalConMoney > 0)
                {
                    if (ServerProperties.Properties.CONSIGNMENT_USE_BP)
                    {
                        client.Player.Out.SendMessage("You withdraw " + totalConMoney.ToString() + " BountyPoints from your Merchant.", eChatType.CT_Important, eChatLoc.CL_ChatWindow);
                        client.Player.BountyPoints += totalConMoney;
                        client.Player.Out.SendUpdatePoints();
                    }
                    else
                    {
                        ChatUtil.SendMerchantMessage(client, "GameMerchant.OnPlayerWithdraw", Money.GetString(totalConMoney));
                        client.Player.AddMoney(totalConMoney);
                        InventoryLogging.LogInventoryAction(conMerchant, client.Player, eInventoryActionType.Merchant, totalConMoney);
                    }

                    conMerchant.TotalMoney -= totalConMoney;

                    if (ServerProperties.Properties.MARKET_ENABLE_LOG)
                    {
                        log.DebugFormat("CM: [{0}:{1}] withdraws {2} from CM on lot {3}.", client.Player.Name, client.Account.Name, totalConMoney, conMerchant.HouseNumber);
                    }

                    client.Out.SendConsignmentMerchantMoney(conMerchant.TotalMoney);
                }
            }
        }
示例#4
0
文件: House.cs 项目: boscorillium/dol
		public bool AddConsignment(int startValue)
		{
			// check to make sure a consignment merchant doesn't already exist for this house.
			var obj = GameServer.Database.SelectObject<Mob>("HouseNumber = '" + HouseNumber + "'");
			if (obj != null)
				return false;

			var merchant = GameServer.Database.SelectObject<DBHouseMerchant>("HouseNumber = '" + HouseNumber + "'");
			if (merchant != null)
				return false;

			// create a new consignment merchant entry, and add it to the DB
			var newM = new DBHouseMerchant {HouseNumber = HouseNumber, Quantity = startValue};
			GameServer.Database.AddObject(newM);

			float[] consignmentCoords = HousingConstants.ConsignmentPositioning[Model];
			double multi = consignmentCoords[0];
			var range = (int) consignmentCoords[1];
			var zaddition = (int) consignmentCoords[2];
			var realm = (int) consignmentCoords[3];

			double angle = Heading*((Math.PI*2)/360); // angle*2pi/360;
			var heading = (ushort) ((Heading < 180 ? Heading + 180 : Heading - 180)/0.08789);
			var tX = (int) ((X + (500*Math.Sin(angle))) - Math.Sin(angle - multi)*range);
			var tY = (int) ((Y - (500*Math.Cos(angle))) + Math.Cos(angle - multi)*range);

			var con = new GameConsignmentMerchant
			{
				CurrentRegionID = RegionID,
				X = tX,
				Y = tY,
				Z = Z + zaddition,
				Level = 50,
				Realm = (eRealm) realm,
				HouseNumber = (ushort)HouseNumber,
				Name = "GameConsignmentMerchant Merchant",
				Heading = heading,
				Model = 144
			};

			con.Flags |= GameNPC.eFlags.PEACE;
			con.LoadedFromScript = false;
			con.RoamingRange = 0;

			if (DatabaseItem.GuildHouse)
				con.GuildName = DatabaseItem.GuildName;

			con.AddToWorld();
			con.SaveIntoDatabase();

			DatabaseItem.HasConsignment = true;
			SaveIntoDatabase();

			return true;
		}