Пример #1
0
		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();
		}
Пример #2
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;
 }
Пример #3
0
		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;
		}