コード例 #1
0
ファイル: UserBotInt.cs プロジェクト: RootkitR/Essential-5.1
        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
            {
            }
        }
コード例 #2
0
ファイル: Room.cs プロジェクト: RootkitR/Essential-5.1
        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;
        }
コード例 #3
0
        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 { }
        }