public InventoryComponent(uint userId, GameClient client, UserDataFactory userdata) { this.Session = client; this.UserId = userId; this.Items = new List <UserItem>(); this.Pets = new Hashtable(); this.Bots = new Hashtable(); this.hashtable_1 = new Hashtable(); this.Discs = new Hashtable(); this.list_1 = new List <uint>(); foreach (DataRow row in userdata.GetItems().Rows) { string str; uint id = Convert.ToUInt32(row["Id"]); uint baseItem = Convert.ToUInt32(row["base_item"]); int ltdi = Convert.ToInt32(row["ltd_id"]); int ltdc = Convert.ToInt32(row["ltd_cnt"]); string glddata = (string)row["guild_data"]; if (!DBNull.Value.Equals(row["extra_data"])) { str = (string)row["extra_data"]; } else { str = string.Empty; } UserItem item = new UserItem(id, baseItem, str, ltdi, ltdc, glddata); Items.Add(item); if (item.GetBaseItem().InteractionType == "musicdisc") { this.Discs.Add(item.uint_0, item); } } foreach (DataRow row in userdata.GetPets().Rows) { Pet pet = Essential.GetGame().GetCatalog().GetPet(row); this.Pets.Add(pet.PetId, pet); } foreach (DataRow row in userdata.GetBots().Rows) { UserBot bot = Essential.GetGame().GetCatalog().RetrBot(row); this.Bots.Add(bot.BotId, bot); } }
public void AddBot(UserBot bot) { try { if (bot != null) { bot.PlacedInRoom = false; if (!Bots.ContainsKey(bot.BotId)) { Bots.Add(bot.BotId, bot); } this.GetClient().SendMessage(ComposeBotInventoryListMessage()); } } catch { } }
public override void OnSelfEnterRoom() { try { this.botResponse = new List<BotResponse>(); this.randomSpeeches = new List<RandomSpeech>(); using (DatabaseClient dbClient = Essential.GetDatabase().GetClient()) { this.uBot = Essential.GetGame().GetCatalog().RetrBot(dbClient.ReadDataRow("SELECT * FROM user_bots WHERE id=" + (base.GetRoomUser().UId - 1000))); if (this.uBot.BotType != "default") { foreach (DataRow drow in dbClient.ReadDataTable("SELECT * FROM bots_responses WHERE bot_type='" + this.uBot.BotType + "'").Rows) { botResponse.Add(new BotResponse((uint)drow["id"], 0, drow["keywords"].ToString(), drow["response_text"].ToString(), drow["mode"].ToString(), (int)drow["serve_id"])); } } else { foreach (DataRow drow in dbClient.ReadDataTable("SELECT * FROM bots_responses WHERE bot_id='" + this.uBot.BotId + "'").Rows) { botResponse.Add(new BotResponse((uint)drow["id"], 0, drow["keywords"].ToString(), drow["response_text"].ToString(), drow["mode"].ToString(), (int)drow["serve_id"])); } } DataTable dtable = dbClient.ReadDataTable("SELECT * FROM bots_speech WHERE bot_id='" + this.uBot.BotId + "'"); foreach (DataRow drow in dtable.Rows) { randomSpeeches.Add(new RandomSpeech((string)drow["text"], Essential.StringToBoolean(drow["shout"].ToString()), Convert.ToUInt32(drow["bot_id"]))); } speechInterval = dbClient.ReadInt32("SELECT speaking_interval from user_bots WHERE id = " + this.uBot.BotId); canSpeak = Convert.ToBoolean(dbClient.ReadString("SELECT automatic_chat from user_bots WHERE id = " + this.uBot.BotId)); } this.SpeechTimer = speechInterval * 2; this.speechDelta = speechInterval * 2; this.ActionTimer = new Random(((int)this.virtualId ^ 2) + DateTime.Now.Millisecond).Next(10, 30); }catch { } }
public RoomUser AddBotToRoom(RoomBot Bot, UserBot UBot) { int num = (int)UBot.BotId; if(num > 500) { int i = 500; while(i > 0) { i--; RoomUser ru = RoomUsers[i]; if (ru == null) { num = i; break; } } } RoomUser user = new RoomUser(Convert.ToUInt32(UBot.BotId + 1000), this.Id, this.int_7++, true); user.int_20 = num; this.RoomUsers[num] = user; if (Bot.x > 0 && Bot.y > 0 && Bot.x < this.RoomModel.int_4 && Bot.y < this.RoomModel.int_5) { user.method_7(Bot.x, Bot.y, Bot.z); user.method_9(Bot.Rotation); } else { Bot.x = this.RoomModel.DoorX; Bot.y = this.RoomModel.DoorY; user.method_7(this.RoomModel.DoorX, this.RoomModel.DoorY, this.RoomModel.double_0); user.method_9(this.RoomModel.int_2); } user.RoomBot = Bot; user.BotAI = Bot.GetBotAI(user.VirtualId); user.BotAI.Init((int)Bot.Id, user.VirtualId, this.Id); this.method_87(user, true, true); user.UpdateNeeded = true; ServerMessage Message = new ServerMessage(Outgoing.PlaceBot); // P Message.AppendInt32(1); user.method_14(Message); this.SendMessage(Message, null); user.BotAI.OnSelfEnterRoom(); return user; }
public void AddBot(UserBot bot) { try { if (bot != null) { bot.PlacedInRoom = false; if (!Bots.ContainsKey(bot.BotId)) Bots.Add(bot.BotId, bot); this.GetClient().SendMessage(ComposeBotInventoryListMessage()); } } catch { } }