using System; using System.Collections.Generic; using System.Data; using System.Text; using Uber.Collections; using Uber.Storage; namespace Uber.HabboHotel.RoomBots { class RoomBot { public uint BotId; public uint RoomId; public string AiType; public string WalkingMode; public string Name; public string Motto; public string Look; public int X; public int Y; public int Z; public int Rot; public int minX; public int maxX; public int minY; public int maxY; public List RandomSpeech; public SafeList Responses; public bool IsPet { get { return (AiType.ToLower() == "pet"); } } public RoomBot(uint mBotId, uint mRoomId, string mAiType, string mWalkingMode, string mName, string mMotto, string mLook, int mX, int mY, int mZ, int mRot, int mminX, int mminY, int mmaxX, int mmaxY) { this.BotId = mBotId; this.RoomId = mRoomId; this.AiType = mAiType; this.WalkingMode = mWalkingMode; this.Name = mName; this.Motto = mMotto; this.Look = mLook; this.X = mX; this.Y = mY; this.Z = mZ; this.Rot = mRot; this.minX = mminX; this.minY = mminY; this.maxX = mmaxX; this.maxY = mmaxY; LoadRandomSpeech(); LoadResponses(); } public void LoadRandomSpeech() { this.RandomSpeech = null; this.RandomSpeech = new List(); DataTable Data = null; using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient()) { Data = dbClient.ReadDataTable("SELECT * FROM bots_speech WHERE bot_id = '" + BotId + "'"); } if (Data == null) { return; } foreach (DataRow Row in Data.Rows) { this.RandomSpeech.Add(new RandomSpeech((string)Row["text"], UberEnvironment.EnumToBool(Row["shout"].ToString()))); } } public void LoadResponses() { this.Responses = null; this.Responses = new SafeList(); DataTable Data = null; using (DatabaseClient dbClient = UberEnvironment.GetDatabase().GetClient()) { Data = dbClient.ReadDataTable("SELECT * FROM bots_responses WHERE bot_id = '" + BotId + "'"); } if (Data == null) { return; } foreach (DataRow Row in Data.Rows) { this.Responses.Add(new BotResponse((uint)Row["id"], (uint)Row["bot_id"], (string)Row["keywords"], (string)Row["response_text"], Row["mode"].ToString(), (int)Row["serve_id"])); } } public BotResponse GetResponse(string Message) { foreach (BotResponse Response in Responses) { if (Response.KeywordMatched(Message)) { return Response; } } return null; } public RandomSpeech GetRandomSpeech() { return RandomSpeech[UberEnvironment.GetRandomNumber(0, (RandomSpeech.Count - 1))]; } public BotAI GenerateBotAI(int VirtualId) { switch (AiType.ToLower()) { default: case "generic": return new GenericBot(VirtualId); case "guide": return new GuideBot(); case "pet": return new PetBot(VirtualId); } } } }