private void InitializeMafiaBots() { this.ClearMafiaBots(); #region Get Bots from Cache List <RoleplayBot> MafiaBots = RoleplayBotManager.CachedRoleplayBots.Values.Where(RoleplayBot => RoleplayBot != null && RoleplayBot.AIType == RoleplayBotAIType.MAFIAWARS).ToList(); RoleplayBot GreenBoss, BlueBoss, GreenThug1, GreenThug2, BlueThug1, BlueThug2; GreenBoss = MafiaBots.Where(MafiaWarsBot => MafiaWarsBot.Motto.ToLower().Contains("green") && MafiaWarsBot.Motto.ToLower().Contains("boss")).FirstOrDefault(); BlueBoss = MafiaBots.Where(MafiaWarsBot => MafiaWarsBot.Motto.ToLower().Contains("blue") && MafiaWarsBot.Motto.ToLower().Contains("boss")).FirstOrDefault(); GreenThug1 = MafiaBots.Where(MafiaWarsBot => MafiaWarsBot.Motto.ToLower().Contains("green") && !MafiaWarsBot.Motto.ToLower().Contains("boss")).First(); GreenThug2 = MafiaBots.Where(MafiaWarsBot => MafiaWarsBot.Motto.ToLower().Contains("green") && !MafiaWarsBot.Motto.ToLower().Contains("boss")).Last(); BlueThug1 = MafiaBots.Where(MafiaWarsBot => MafiaWarsBot.Motto.ToLower().Contains("blue") && !MafiaWarsBot.Motto.ToLower().Contains("boss")).First(); BlueThug2 = MafiaBots.Where(MafiaWarsBot => MafiaWarsBot.Motto.ToLower().Contains("blue") && !MafiaWarsBot.Motto.ToLower().Contains("boss")).Last(); GreenBoss.Dead = false; GreenBoss.Invisible = false; GreenThug1.Dead = false; GreenThug1.Invisible = false; GreenThug2.Dead = false; GreenThug2.Invisible = false; BlueBoss.Dead = false; BlueBoss.Invisible = false; BlueThug1.Dead = false; BlueThug1.Invisible = false; BlueThug2.Dead = false; BlueThug2.Invisible = false; #endregion #region Deploy bots RoleplayBotManager.DeployBotByID(GreenBoss.Id); RoleplayBotManager.DeployBotByID(BlueBoss.Id); RoleplayBotManager.DeployBotByID(GreenThug1.Id); RoleplayBotManager.DeployBotByID(GreenThug2.Id); RoleplayBotManager.DeployBotByID(BlueThug1.Id); RoleplayBotManager.DeployBotByID(BlueThug2.Id); #endregion #region Insert deployed bots into list new Thread(() => { Thread.Sleep(2000); this.MafiaBots.TryAdd("greenboss", RoleplayBotManager.GetDeployedBotById(GreenBoss.Id)); this.MafiaBots.TryAdd("greenthug1", RoleplayBotManager.GetDeployedBotById(GreenBoss.Id)); this.MafiaBots.TryAdd("greenthug2", RoleplayBotManager.GetDeployedBotById(GreenBoss.Id)); this.MafiaBots.TryAdd("blueboss", RoleplayBotManager.GetDeployedBotById(GreenBoss.Id)); this.MafiaBots.TryAdd("bluethug1", RoleplayBotManager.GetDeployedBotById(GreenBoss.Id)); this.MafiaBots.TryAdd("bluethug2", RoleplayBotManager.GetDeployedBotById(GreenBoss.Id)); }).Start(); #endregion }
public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet) { if (!Session.GetHabbo().InRoom) { return; } Room Room = null; if (!PlusEnvironment.GetGame().GetRoomManager().TryGetRoom(Session.GetHabbo().CurrentRoomId, out Room)) { return; } if ((Room.AllowPets == 0 && !Room.CheckRights(Session, true)) || !Room.CheckRights(Session, true)) { Session.SendMessage(new RoomErrorNotifComposer(1)); return; } if (Room.GetRoomUserManager().PetCount > PlusStaticGameSettings.RoomPetPlacementLimit) { Session.SendMessage(new RoomErrorNotifComposer(2));//5 = I have too many. return; } Pet Pet = null; if (!Session.GetHabbo().GetInventoryComponent().TryGetPet(Packet.PopInt(), out Pet)) { return; } if (Pet == null) { return; } if (Pet.PlacedInRoom) { Session.SendNotification("Este animal de estimação já está no quarto"); return; } int X = Packet.PopInt(); int Y = Packet.PopInt(); if (!Room.GetGameMap().CanWalk(X, Y, false)) { Session.SendMessage(new RoomErrorNotifComposer(4)); return; } RoomUser OldPet = null; if (Room.GetRoomUserManager().TryGetPet(Pet.PetId, out OldPet)) { Room.GetRoomUserManager().RemoveBot(OldPet.VirtualId, false); } Pet.X = X; Pet.Y = Y; Pet.PlacedInRoom = true; Pet.RoomId = Room.RoomId; List <RandomSpeech> RndSpeechList = new List <RandomSpeech>(); RoomBot RoomBot = new RoomBot(Pet.PetId, Pet.RoomId, "pet", "freeroam", Pet.Name, "", Pet.Look, X, Y, 0, 0, 0, 0, 0, 0, ref RndSpeechList, "", 0, Pet.OwnerId, false, 0, false, 0); if (RoomBot == null) { return; } //old//Room.GetRoomUserManager().DeployBot(RoomBot, Pet); RoleplayBotManager.DeployBotByID(RoomBot.Id, "owner", Room.Id); Pet.DBState = DatabaseUpdateState.NeedsUpdate; Room.GetRoomUserManager().UpdatePets(); Pet ToRemove = null; if (!Session.GetHabbo().GetInventoryComponent().TryRemovePet(Pet.PetId, out ToRemove)) { log.Error("Erro ao remover o animal de estimação: " + ToRemove.PetId); return; } Session.SendMessage(new PetInventoryComposer(Session.GetHabbo().GetInventoryComponent().GetPets())); }
public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet) { if (!Session.GetHabbo().InRoom) { return; } Room Room; if (!PlusEnvironment.GetGame().GetRoomManager().TryGetRoom(Session.GetHabbo().CurrentRoomId, out Room)) { return; } if (!Room.CheckRights(Session, true)) { return; } int BotId = Packet.PopInt(); int X = Packet.PopInt(); int Y = Packet.PopInt(); if (!Room.GetGameMap().CanWalk(X, Y, false) || !Room.GetGameMap().ValidTile(X, Y)) { Session.SendNotification("Você não pode colocar um bot aqui!"); return; } Bot Bot = null; if (!Session.GetHabbo().GetInventoryComponent().TryGetBot(BotId, out Bot)) { return; } RoleplayBot RoleplayBotInstance; if (RoleplayBotManager.CachedRoleplayBots.TryGetValue(BotId, out RoleplayBotInstance)) { RoleplayBotManager.DeployBotByID(BotId); return; } int BotCount = 0; foreach (RoomUser User in Room.GetRoomUserManager().GetUserList().ToList()) { if (User == null || User.IsPet || !User.IsBot) { continue; } BotCount += 1; } if (BotCount >= 5 && !Session.GetHabbo().GetPermissions().HasRight("bot_place_any_override")) { Session.SendNotification("Desculpa; 5 bots por quarto apenas!"); return; } //TODO: Hmm, maybe not???? using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("UPDATE `bots` SET `room_id` = '" + Room.RoomId + "', `x` = @CoordX, `y` = @CoordY WHERE `id` = @BotId LIMIT 1"); dbClient.AddParameter("BotId", Bot.Id); dbClient.AddParameter("CoordX", X); dbClient.AddParameter("CoordY", Y); dbClient.RunQuery(); } List <RandomSpeech> BotSpeechList = new List <RandomSpeech>(); //TODO: Grab data? DataRow GetData = null; using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("SELECT `ai_type`,`rotation`,`walk_mode`,`automatic_chat`,`speaking_interval`,`mix_sentences`,`chat_bubble` FROM `bots` WHERE `id` = @BotId LIMIT 1"); dbClient.AddParameter("BotId", Bot.Id); GetData = dbClient.getRow(); dbClient.SetQuery("SELECT `text` FROM `bots_speech` WHERE `bot_id` = @BotId"); dbClient.AddParameter("BotId", Bot.Id); DataTable BotSpeech = dbClient.getTable(); foreach (DataRow Speech in BotSpeech.Rows) { BotSpeechList.Add(new RandomSpeech(Convert.ToString(Speech["text"]), Bot.Id)); } } RoomUser BotUser = Room.GetRoomUserManager().DeployBot(new RoomBot(Bot.Id, Session.GetHabbo().CurrentRoomId, Convert.ToString(GetData["ai_type"]), Convert.ToString(GetData["walk_mode"]), Bot.Name, "", Bot.Figure, X, Y, 0, 4, 0, 0, 0, 0, ref BotSpeechList, "", 0, Bot.OwnerId, PlusEnvironment.EnumToBool(GetData["automatic_chat"].ToString()), Convert.ToInt32(GetData["speaking_interval"]), PlusEnvironment.EnumToBool(GetData["mix_sentences"].ToString()), Convert.ToInt32(GetData["chat_bubble"])), null); BotUser.Chat("Hello!", false, 0); Room.GetGameMap().UpdateUserMovement(new System.Drawing.Point(X, Y), new System.Drawing.Point(X, Y), BotUser); Bot ToRemove = null; if (!Session.GetHabbo().GetInventoryComponent().TryRemoveBot(BotId, out ToRemove)) { Console.WriteLine("Erro ao remover Bot: " + ToRemove.Id); return; } Session.SendMessage(new BotInventoryComposer(Session.GetHabbo().GetInventoryComponent().GetBots())); }