Пример #1
0
		internal void AddBot(RoomBot Bot)
		{
			this.isUpdated = false;
			if (Bot == null)
			{
				Logging.WriteLine("Bot was null", ConsoleColor.Gray);
				return;
			}
			if (this.InventoryBots.ContainsKey(Bot.BotId))
			{
				Logging.WriteLine("Contains Bot", ConsoleColor.Gray);
			}
			Bot.RoomId = 0u;
			this.InventoryBots.Add(Bot.BotId, Bot);
		}
		internal void PlaceBot()
		{
			Room room = CyberEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId);
			if (room == null || !room.CheckRights(this.Session, true, false))
			{
				return;
			}
			uint num = this.Request.PopWiredUInt();
			RoomBot bot = this.Session.GetHabbo().GetInventoryComponent().GetBot(num);
			if (bot == null)
			{
				Logging.WriteLine("Null bot found" + num, ConsoleColor.Gray);
				return;
			}
			int num2 = this.Request.PopWiredInt32();
			int num3 = this.Request.PopWiredInt32();
			if (!room.GetGameMap().CanWalk(num2, num3, false, 0u) || !room.GetGameMap().validTile(num2, num3))
			{
				this.Session.SendNotif("You can't place your bot here.");
				return;
			}
			using (IQueryAdapter queryreactor = CyberEnvironment.GetDatabaseManager().getQueryReactor())
			{
				queryreactor.runFastQuery(string.Concat(new object[]
				{
					"UPDATE bots SET room_id = '",
					room.RoomId,
					"', x = '",
					num2,
					"', y = '",
					num3,
					"' WHERE id = '",
					num,
					"'"
				}));
			}
			bot.RoomId = room.RoomId;
			List<RandomSpeech> list = new List<RandomSpeech>();
			List<BotResponse> list2 = new List<BotResponse>();
            RoomBot botData = new RoomBot(num, bot.OwnerId, bot.RoomId, AIType.Generic, "freeroam", bot.Name, bot.Motto, bot.Look, num2, num3, 0.0, 4, 0, 0, 0, 0, ref list, ref list2, bot.Gender, bot.DanceId, bot.IsBartender);
			room.GetRoomUserManager().DeployBot(botData, null);
            botData.WasPicked = false;
			this.Session.GetHabbo().GetInventoryComponent().MoveBotToRoom(num);
			this.Session.SendMessage(this.Session.GetHabbo().GetInventoryComponent().SerializeBotInventory());
		}
Пример #3
0
 internal RoomUser DeployBot(RoomBot Bot, Pet PetData)
 {
     int virtualId = this.primaryPrivateUserID++;
     RoomUser roomUser = new RoomUser(0u, this.room.RoomId, virtualId, this.room, false);
     int num = this.secondaryPrivateUserID++;
     roomUser.InternalRoomID = num;
     this.userlist.Add(num, roomUser);
     DynamicRoomModel model = this.room.GetGameMap().Model;
     Point coord = new Point(Bot.X, Bot.Y);
     if (Bot.X > 0 && Bot.Y > 0 && Bot.X < model.MapSizeX && Bot.Y < model.MapSizeY)
     {
         this.room.GetGameMap().AddUserToMap(roomUser, coord);
         roomUser.SetPos(Bot.X, Bot.Y, Bot.Z);
         roomUser.SetRot(Bot.Rot, false);
     }
     else
     {
         Bot.X = model.DoorX;
         Bot.Y = model.DoorY;
         roomUser.SetPos(model.DoorX, model.DoorY, model.DoorZ);
         roomUser.SetRot(model.DoorOrientation, false);
     }
     roomUser.BotData = Bot;
     checked
     {
         roomUser.BotAI = Bot.GenerateBotAI(roomUser.VirtualId, (int)Bot.BotId);
         if (roomUser.IsPet)
         {
             roomUser.BotAI.Init(Bot.BotId, roomUser.VirtualId, this.room.RoomId, roomUser, this.room);
             roomUser.PetData = PetData;
             roomUser.PetData.VirtualId = roomUser.VirtualId;
         }
         else
         {
             roomUser.BotAI.Init(Bot.BotId, roomUser.VirtualId, this.room.RoomId, roomUser, this.room);
         }
         this.UpdateUserStatus(roomUser, false);
         roomUser.UpdateNeeded = true;
         ServerMessage serverMessage = new ServerMessage(Outgoing.SetRoomUserMessageComposer);
         serverMessage.AppendInt32(1);
         roomUser.Serialize(serverMessage, this.room.GetGameMap().gotPublicPool);
         this.room.SendMessage(serverMessage);
         roomUser.BotAI.OnSelfEnterRoom();
         if (roomUser.IsPet)
         {
             if (this.pets.Contains(roomUser.PetData.PetId))
             {
                 this.pets[roomUser.PetData.PetId] = roomUser;
             }
             else
             {
                 this.pets.Add(roomUser.PetData.PetId, roomUser);
             }
             this.petCount++;
         }
         if (roomUser.BotData.AiType == AIType.Generic)
         {
             if (this.bots.Contains(roomUser.BotData.BotId))
             {
                 this.bots[roomUser.BotData.BotId] = roomUser;
             }
             else
             {
                 this.bots.Add(roomUser.BotData.BotId, roomUser);
             }
             serverMessage.Init(Outgoing.DanceStatusMessageComposer);
             serverMessage.AppendInt32(roomUser.VirtualId);
             serverMessage.AppendInt32(roomUser.BotData.DanceId);
             this.room.SendMessage(serverMessage);
             this.petCount++;
         }
         return roomUser;
     }
 }
		internal void PlantMonsterplant(RoomItem Mopla, Room Room)
		{
			if (Room == null)
			{
				return;
			}
			if (Mopla == null)
			{
				return;
			}
			if (Mopla.GetBaseItem().InteractionType != InteractionType.moplaseed)
			{
				return;
			}
			int rarity = int.Parse(Mopla.ExtraData);
			int getX = Mopla.GetX;
			int getY = Mopla.GetY;
			Room.GetRoomItemHandler().RemoveFurniture(this.Session, Mopla.Id, false);
			Pet pet = Catalog.CreatePet(this.Session.GetHabbo().Id, "Monsterplant", 16, "0", "0", rarity);
			this.Response.Init(Outgoing.SendMonsterplantIdMessageComposer);
			this.Response.AppendUInt(pet.PetId);
			this.SendResponse();
			using (IQueryAdapter queryreactor = CyberEnvironment.GetDatabaseManager().getQueryReactor())
			{
				queryreactor.runFastQuery(string.Concat(new object[]
				{
					"UPDATE bots SET room_id = '",
					Room.RoomId,
					"', x = '",
					getX,
					"', y = '",
					getY,
					"' WHERE id = '",
					pet.PetId,
					"'"
				}));
			}
			pet.PlacedInRoom = true;
			pet.RoomId = Room.RoomId;
			List<RandomSpeech> list = new List<RandomSpeech>();
			List<BotResponse> list2 = new List<BotResponse>();
			RoomBot bot = new RoomBot(pet.PetId, pet.OwnerId, pet.RoomId, AIType.Pet, "freeroam", pet.Name, "", pet.Look, getX, getY, 0.0, 4, 0, 0, 0, 0, ref list, ref list2, "", 0, false);
			Room.GetRoomUserManager().DeployBot(bot, pet);

			if (pet.DBState != DatabaseUpdateState.NeedsInsert)
			{
				pet.DBState = DatabaseUpdateState.NeedsUpdate;
			}

			using (IQueryAdapter queryreactor2 = CyberEnvironment.GetDatabaseManager().getQueryReactor())
			{
                queryreactor2.runFastQuery("DELETE FROM items WHERE id = " + Mopla.Id);
				Room.GetRoomUserManager().SavePets(queryreactor2);
			}
		}
Пример #5
0
		internal RoomUser DeployBot(RoomBot Bot)
		{
			return this.roomUserManager.DeployBot(Bot, null);
		}