コード例 #1
0
        public static void FetchCachedSpeeches()
        {
            foreach (RoleplayBot RoleplayBot in RoleplayBotManager.CachedRoleplayBots.Values)
            {
                using (var dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.SetQuery("SELECT * from `rp_bots_responses` WHERE `bot_id` = '" + RoleplayBot.Id + "'");
                    DataTable BotResponseTable = dbClient.getTable();

                    if (BotResponseTable != null)
                    {
                        RoleplayBot.Responses.Clear();

                        foreach (DataRow Row in BotResponseTable.Rows)
                        {
                            string Message  = Row["message"].ToString();
                            string Response = Row["response"].ToString();
                            int    Bubble   = Convert.ToInt32(Row["bubble"]);
                            string Type     = Row["type"].ToString();

                            if (!RoleplayBot.Responses.ContainsKey(Message.ToLower()))
                            {
                                RoleplayBot.Responses.TryAdd(Message.ToLower(), new RoleplayBotResponse(Message.ToLower(), Response, Bubble, Type));
                            }
                        }

                        if (RoleplayBotManager.DeployedRoleplayBots.ContainsKey(RoleplayBot.Id))
                        {
                            RoleplayBotManager.DeployedRoleplayBots[RoleplayBot.Id].GetBotRoleplay().Responses = RoleplayBot.Responses;
                        }
                    }

                    dbClient.SetQuery("SELECT * from `rp_bots_speech` WHERE `bot_id` = '" + RoleplayBot.Id + "'");
                    DataTable BotSpeechTable = dbClient.getTable();

                    if (BotSpeechTable != null)
                    {
                        RoleplayBot.RandomSpeech.Clear();

                        foreach (DataRow Speech in BotSpeechTable.Rows)
                        {
                            string Text = Speech["text"].ToString();
                            int    Id   = RoleplayBot.Id;

                            var RandomSpeech = new RandomSpeech(Text, Id);

                            if (!RoleplayBot.RandomSpeech.Contains(RandomSpeech))
                            {
                                RoleplayBot.RandomSpeech.Add(RandomSpeech);
                            }
                        }

                        if (RoleplayBotManager.DeployedRoleplayBots.ContainsKey(RoleplayBot.Id))
                        {
                            RoleplayBotManager.DeployedRoleplayBots[RoleplayBot.Id].GetBotRoleplay().RandomSpeech = RoleplayBot.RandomSpeech;
                        }
                    }
                }
            }
        }
コード例 #2
0
ファイル: BartenderBot.cs プロジェクト: SpreedBlood/PlusEMU
        public override void OnTimerTick()
        {
            if (GetBotData() == null)
            {
                return;
            }

            if (SpeechTimer <= 0)
            {
                if (GetBotData().RandomSpeech.Count > 0)
                {
                    if (GetBotData().AutomaticChat == false)
                    {
                        return;
                    }

                    RandomSpeech Speech = GetBotData().GetRandomSpeech();

                    string String = PlusEnvironment.GetGame().GetChatManager().GetFilter().CheckMessage(Speech.Message);
                    if (String.Contains("<img src") || String.Contains("<font ") || String.Contains("</font>") || String.Contains("</a>") || String.Contains("<i>"))
                    {
                        String = "I really shouldn't be using HTML within bot speeches.";
                    }
                    GetRoomUser().Chat(String, GetBotData().ChatBubble);
                }
                SpeechTimer = GetBotData().SpeakingInterval;
            }
            else
            {
                SpeechTimer--;
            }

            if (ActionTimer <= 0)
            {
                Point nextCoord;
                switch (GetBotData().WalkingMode.ToLower())
                {
                default:
                case "stand":
                    // (8) Why is my life so boring?
                    break;

                case "freeroam":
                    if (GetBotData().ForcedMovement)
                    {
                        if (GetRoomUser().Coordinate == GetBotData().TargetCoordinate)
                        {
                            GetBotData().ForcedMovement   = false;
                            GetBotData().TargetCoordinate = new Point();

                            GetRoomUser().MoveTo(GetBotData().TargetCoordinate.X, GetBotData().TargetCoordinate.Y);
                        }
                    }
                    else if (GetBotData().ForcedUserTargetMovement > 0)
                    {
                        RoomUser Target = GetRoom().GetRoomUserManager().GetRoomUserByHabbo(GetBotData().ForcedUserTargetMovement);
                        if (Target == null)
                        {
                            GetBotData().ForcedUserTargetMovement = 0;
                            GetRoomUser().ClearMovement(true);
                        }
                        else
                        {
                            var Sq = new Point(Target.X, Target.Y);

                            if (Target.RotBody == 0)
                            {
                                Sq.Y--;
                            }
                            else if (Target.RotBody == 2)
                            {
                                Sq.X++;
                            }
                            else if (Target.RotBody == 4)
                            {
                                Sq.Y++;
                            }
                            else if (Target.RotBody == 6)
                            {
                                Sq.X--;
                            }


                            GetRoomUser().MoveTo(Sq);
                        }
                    }
                    else if (GetBotData().TargetUser == 0)
                    {
                        nextCoord = GetRoom().GetGameMap().GetRandomWalkableSquare();
                        GetRoomUser().MoveTo(nextCoord.X, nextCoord.Y);
                    }
                    break;

                case "specified_range":

                    break;
                }

                ActionTimer = new Random(DateTime.Now.Millisecond + VirtualId ^ 2).Next(5, 15);
            }
            else
            {
                ActionTimer--;
            }
        }
コード例 #3
0
ファイル: GenericBot.cs プロジェクト: pedruhb/RavenServer
        public override void OnTimerTick()
        {
            if (GetBotData() == null)
            {
                return;
            }

            if (SpeechTimer <= 0)
            {
                if (GetBotData().RandomSpeech.Count > 0)
                {
                    if (GetBotData().AutomaticChat == false)
                    {
                        return;
                    }

                    RandomSpeech Speech = GetBotData().GetRandomSpeech();

                    string word;
                    string String = RavenEnvironment.GetGame().GetChatManager().GetFilter().IsUnnaceptableWord(Speech.Message, out word) ? "Spam" : Speech.Message;
                    if (String.Contains("<") || String.Contains(">"))
                    {
                        String = "I really shouldn't be using HTML within bot speeches.";
                    }
                    GetRoomUser().Chat(String, false, GetBotData().ChatBubble);
                }
                SpeechTimer = GetBotData().SpeakingInterval;
            }
            else
            {
                SpeechTimer--;
            }

            if (ActionTimer <= 0)
            {
                Point nextCoord;
                switch (GetBotData().WalkingMode.ToLower())
                {
                default:
                case "stand":
                    break;

                case "freeroam":
                    if (GetBotData().ForcedMovement)
                    {
                        if (GetRoomUser().Coordinate == GetBotData().TargetCoordinate)
                        {
                            GetBotData().ForcedMovement   = false;
                            GetBotData().TargetCoordinate = new Point();

                            GetRoomUser().MoveTo(GetBotData().TargetCoordinate.X, GetBotData().TargetCoordinate.Y);
                        }
                    }
                    else if (GetBotData().ForcedUserTargetMovement > 0)
                    {
                        RoomUser Target = GetRoom().GetRoomUserManager().GetRoomUserByHabbo(GetBotData().ForcedUserTargetMovement);
                        if (Target == null)
                        {
                            GetBotData().ForcedUserTargetMovement = 0;
                            GetRoomUser().ClearMovement(true);
                        }
                        else
                        {
                            var Sq = new Point(Target.X, Target.Y);

                            if (Target.RotBody == 0)
                            {
                                Sq.Y--;
                            }
                            else if (Target.RotBody == 2)
                            {
                                Sq.X++;
                            }
                            else if (Target.RotBody == 4)
                            {
                                Sq.Y++;
                            }
                            else if (Target.RotBody == 6)
                            {
                                Sq.X--;
                            }

                            //if (Gamemap.TileDistance(Sq.X, Sq.Y, Target.X, Target.Y) <= 1)
                            //{
                            //    Room Room = GetRoom();
                            //    Room.GetWired().TriggerEvent(WiredBoxType.TriggerBotReachedAvatar, true);
                            //}

                            GetRoomUser().MoveTo(Sq);
                        }
                    }
                    else if (GetBotData().TargetUser == 0)
                    {
                        nextCoord = GetRoom().GetGameMap().getRandomWalkableSquare();
                        GetRoomUser().MoveTo(nextCoord.X, nextCoord.Y);
                    }
                    break;

                case "specified_range":

                    break;
                }

                ActionTimer = new Random(DateTime.Now.Millisecond + this.VirtualId ^ 2).Next(5, 15);
            }
            else
            {
                ActionTimer--;
            }
        }
コード例 #4
0
        public override void OnTimerTick()
        {
            if (GetBotData() == null)
            {
                return;
            }

            if (SpeechTimer <= 0)
            {
                if (GetBotData().RandomSpeech.Count > 0)
                {
                    if (GetBotData().AutomaticChat == false)
                    {
                        return;
                    }

                    RandomSpeech Speech = GetBotData().GetRandomSpeech();

                    string String = BiosEmuThiago.GetGame().GetChatManager().GetFilter().IsUnnaceptableWord(Speech.Message, out string word) ? "Spam" : Speech.Message;
                    if (String.Contains("<img src") || String.Contains("<font ") || String.Contains("</font>") || String.Contains("</a>") || String.Contains("<i>"))
                    {
                        String = "Eu realmente não deveria usar o HTML dentro de discursos de bot.";
                    }
                    GetRoomUser().Chat(String, false, GetBotData().ChatBubble);
                }
                SpeechTimer = GetBotData().SpeakingInterval;
            }
            else
            {
                SpeechTimer--;
            }

            if (ActionTimer <= 0)
            {
                Point nextCoord;
                switch (GetBotData().WalkingMode.ToLower())
                {
                default:
                case "stand":
                    break;

                case "freeroam":
                    if (GetBotData().ForcedMovement)
                    {
                        if (GetRoomUser().Coordinate == GetBotData().TargetCoordinate)
                        {
                            GetBotData().ForcedMovement   = false;
                            GetBotData().TargetCoordinate = new Point();

                            GetRoomUser().MoveTo(GetBotData().TargetCoordinate.X, GetBotData().TargetCoordinate.Y);
                        }
                    }
                    else if (GetBotData().ForcedUserTargetMovement > 0)
                    {
                        RoomUser Target = GetRoom().GetRoomUserManager().GetRoomUserByHabbo(GetBotData().ForcedUserTargetMovement);
                        if (Target == null)
                        {
                            GetBotData().ForcedUserTargetMovement = 0;
                            GetRoomUser().ClearMovement(true);
                        }
                        else
                        {
                            var Sq = new Point(Target.X, Target.Y);

                            if (Target.RotBody == 0)
                            {
                                Sq.Y--;
                            }
                            else if (Target.RotBody == 2)
                            {
                                Sq.X++;
                            }
                            else if (Target.RotBody == 4)
                            {
                                Sq.Y++;
                            }
                            else if (Target.RotBody == 6)
                            {
                                Sq.X--;
                            }


                            GetRoomUser().MoveTo(Sq);
                        }
                    }
                    else if (GetBotData().TargetUser == 0)
                    {
                        nextCoord = GetRoom().GetGameMap().GetRandomWalkableSquare();
                        GetRoomUser().MoveTo(nextCoord.X, nextCoord.Y);
                    }
                    break;

                case "specified_range":

                    break;
                }

                ActionTimer = new Random(DateTime.Now.Millisecond + this.VirtualId ^ 2).Next(5, 15);
            }
            else
            {
                ActionTimer--;
            }
        }