internal static RoomBot CreateBot(uint UserId, string Name, string Look, string Motto, string Gender, int TemplateId) { List<RandomSpeech> RandomSpeech = new List<RandomSpeech>(); List<BotResponse> BotResponse = new List<BotResponse>(); uint id; using (IQueryAdapter dbClient = SilverwaveEnvironment.GetDatabaseManager().getQueryreactor()) { dbClient.setQuery("INSERT INTO bots (user_id,name,motto,look,gender,walk_mode) VALUES (@h_user,@b_name,@b_motto,@b_look,@b_gender,@b_walk)"); dbClient.addParameter("h_user", UserId); dbClient.addParameter("b_name", Name); dbClient.addParameter("b_motto", Motto); dbClient.addParameter("b_look", Look); dbClient.addParameter("b_gender", Gender); dbClient.addParameter("b_walk", "freeroam"); id = Convert.ToUInt32(dbClient.insertQuery()); } RoomBot bot = new RoomBot(id, UserId, 0, AIType.Generic, "freeroam", Name, Motto, Look, 0, 0, 0, 0, 0, 0, 0, 0, ref RandomSpeech, ref BotResponse, Gender, 0); return bot; }
internal RoomUser DeployBot(RoomBot Bot) { return roomUserManager.DeployBot(Bot, null); }
internal void AddBot(RoomBot Bot) { isUpdated = false; if (Bot == null) { Logging.WriteLine("Bot was null"); return; } if (InventoryBots.ContainsKey(Bot.BotId)) { Logging.WriteLine("Contains Bot"); } //Bot.PlacedInRoom = false; Bot.RoomId = 0; InventoryBots.Add(Bot.BotId, Bot); }
internal RoomUser DeployBot(RoomBot Bot, Pet PetData) { int num2; this.primaryPrivateUserID = (num2 = this.primaryPrivateUserID) + 1; RoomUser BotUser = new RoomUser(0, this.room.RoomId, num2, this.room, false); this.secondaryPrivateUserID = (num2 = this.secondaryPrivateUserID) + 1; int key = num2; BotUser.InternalRoomID = key; this.userlist.Add(key, BotUser); DynamicRoomModel Model = this.room.GetGameMap().Model; Point myPoint = new Point(Bot.X,Bot.Y); if ((Bot.X > 0 && Bot.Y > 0) && Bot.X < Model.MapSizeX && Bot.Y < Model.MapSizeY) { room.GetGameMap().AddUserToMap(BotUser, myPoint); BotUser.SetPos(Bot.X, Bot.Y, Bot.Z); BotUser.SetRot(Bot.Rot, false); } else { Bot.X = Model.DoorX; Bot.Y = Model.DoorY; BotUser.SetPos(Model.DoorX, Model.DoorY, Model.DoorZ); BotUser.SetRot(Model.DoorOrientation, false); } BotUser.BotData = Bot; BotUser.BotAI = Bot.GenerateBotAI(BotUser.VirtualId,(int)Bot.BotId); if (BotUser.IsPet) { BotUser.BotAI.Init(Bot.BotId, BotUser.VirtualId, room.RoomId, BotUser, room); BotUser.PetData = PetData; BotUser.PetData.VirtualId = BotUser.VirtualId; } else { BotUser.BotAI.Init(Bot.BotId, BotUser.VirtualId, room.RoomId, BotUser, room); } this.UpdateUserStatus(BotUser, false); BotUser.UpdateNeeded = true; ServerMessage EnterMessage = new ServerMessage(Outgoing.PlaceBot); EnterMessage.AppendInt32(1); BotUser.Serialize(EnterMessage, room.GetGameMap().gotPublicPool); room.SendMessage(EnterMessage); BotUser.BotAI.OnSelfEnterRoom(); if (BotUser.IsPet) { if (pets.ContainsKey(BotUser.PetData.PetId)) //Pet allready placed pets[BotUser.PetData.PetId] = BotUser; else pets.Add(BotUser.PetData.PetId, BotUser); petCount++; } if (BotUser.BotData.AiType == AIType.Generic) { if (bots.ContainsKey(BotUser.BotData.BotId)) bots[BotUser.BotData.BotId] = BotUser; else { bots.Add(BotUser.BotData.BotId, BotUser); } EnterMessage.Init(Outgoing.Dance); EnterMessage.AppendInt32(BotUser.VirtualId); EnterMessage.AppendInt32(BotUser.BotData.DanceId); room.SendMessage(EnterMessage); petCount++; } return BotUser; }