Пример #1
0
        public static void HandleChatMessage(Bot bot, ChatClientMultiMessage message)
        {
            if (message.content.StartsWith(".move"))
            {
                message.BlockNetworkSend();// do not send this message to the server

                var splits = message.content.Split(' ');
                if (splits.Length != 2)
                {
                    bot.Character.SendMessage("syntax : .move [Right/Left/Top/Bottom/Any]");
                    return;
                }

                MapNeighbour neighbour;
                try
                {
                    neighbour = (MapNeighbour)Enum.Parse(typeof(MapNeighbour), splits[1]);
                }
                catch (Exception)
                {
                    bot.Character.SendMessage("syntax : .move [Right/Left/Top/Bottom/Any]");
                    return;
                }


                if (bot.Character.ChangeMap(neighbour) == MapNeighbour.None)
                {
                    bot.Character.SendMessage(string.Format("Cannot move to {0} !", neighbour));
                }
            }
        }
Пример #2
0
 public void HandlePartyMemberRemoveMessage(Bot bot, PartyMemberRemoveMessage message)
 {
   if (Party == null) return;
   Party = Party.Where(member => member.id != message.leavingPlayerId).ToList();
   if (message.leavingPlayerId == PartyLeaderId)
     PartyLeaderId = null;
 }
Пример #3
0
        public static void HandleMapMessage(Bot bot, MapComplementaryInformationsDataMessage message)
        {
            if (!AllowSeeker) return;

            GroupMonster[] groups = bot.Character.Map.Actors.OfType<GroupMonster>().ToArray();
            var alreadySignaled = new List<string>();
            foreach (GroupMonster @group in groups)
            {
                string monster = SeekedInGroup(@group, bot);
                if (!String.IsNullOrEmpty(monster))
                {
                    if (!alreadySignaled.Contains(monster))
                    {
                        alreadySignaled.Add(monster);

                        bot.Character.SendMessage(String.Format("Le monstre <b>'{0}'</b> a été trouvé sur cette carte.", monster), System.Drawing.Color.Green);
                    }
                }
                string archi = SeekedArchiMonsterInGroup(@group, bot);
                if (!String.IsNullOrEmpty(archi))
                {
                    bot.Character.SendMessage(String.Format("L'archimonstre <b>'{0}'</b> a été trouvé sur cette carte.", archi), System.Drawing.Color.Red);
                }
            }
        }
        public static void HandleGameMapMovementCancelMessage(Bot bot, GameMapMovementCancelMessage message)
        {
            if (!AllowComparer)
                return;

            bot.SendToClient(new DebugHighlightCellsMessage(Color.Violet.ToArgb(), new short[] { message.cellId }));
        }
Пример #5
0
 internal static void HandleListCommand(string[] parameters, Bot bot)
 {
     if (MonsterSeeker.SeekedMonsters.Count > 0)
         bot.ChatManager.PrintMessageToClient(String.Format("Les monstres suivants sont recherchés :\n{0}", MonsterSeeker.SeekedMonsters.Aggregate((a, b) => a + ", " + b)), System.Drawing.Color.DarkSlateGray);
     else
         bot.ChatManager.PrintMessageToClient("Aucun monstre n'est recherché.", System.Drawing.Color.DarkSlateGray);
 }
Пример #6
0
 public void HandlePartyJoinMessage(Bot bot, PartyJoinMessage message)
 {
   Party = new List<PartyMemberInformations>();
   foreach (PartyMemberInformations member in message.members)
     Party.Add(member);
   PartyId = message.partyId;
   PartyLeaderId = message.partyLeaderId;
 }
Пример #7
0
        private static string SeekedInGroup(GroupMonster group, Bot bot)
        {
            if (group == null) return null;

            string[] monsters = group.Monsters.Where(entry => IsSeeking(entry.Name.ToLowerInvariant())).Select(entry => entry.Name).ToArray();
            if (monsters.Length == 0) return null;
            
            return monsters.FirstOrDefault();
        }
Пример #8
0
        private static string SeekedArchiMonsterInGroup(GroupMonster group, Bot bot)
        {
            if (group == null) return null;
            if (!SeekArchiMonster) return null;

            string[] monsters = group.Monsters.Where(entry => entry.IsArchMonster).Select(entry => entry.Name).ToArray();
            if (monsters.Length == 0) return null;

            return monsters.Aggregate((a,b) => a + ", " + b);
        }
Пример #9
0
        public static void HandleChatMessage(Bot bot, ChatClientMultiMessage message)
        {
            // if the client sends ".hello" in the chat
            if (message.content == ".hello")
            {
                message.BlockNetworkSend();// do not send this message to the server

                bot.Character.SendMessage(string.Format("Hello {0} you are on sub area {1}",
                    bot.Character.Name, bot.Character.Map.SubArea.Name));
            }
        }
        public static void HandleAuthenticationTicketMessage(Bot bot, AuthenticationTicketMessage message)
        {
            if (m_languageFound)
                return;

            Languages lang;
            if (!m_langsShortcuts.TryGetValue(message.lang, out lang))
                return;

            Host.ChangeLanguage(lang);
            m_languageFound = true;
        }
Пример #11
0
        public AutoFight(Bot bot)
        {
            m_bot = bot;
            bot.Character.FightJoined += OnFightJoined;
            bot.Character.FightLeft += OnFightLeft;
            bot.Character.MapJoined += OnMapJoined;

            if (bot.Character.IsFighting())
                OnFightJoined(bot.Character, bot.Character.Fight);
            else if (bot.Character.Map != null)
                OnMapJoined(bot.Character, bot.Character.Map);
        }
Пример #12
0
 internal static void HandleSeekCommand(string[] parameters, Bot bot)
 {
     if (parameters.Length != 1)
     {
         bot.ChatManager.PrintMessageToClient("Invalid use. Use help command for more informations.", System.Drawing.Color.Firebrick);
         return;
     }
     if (MonsterSeeker.AddMonster(parameters[0].ToLowerInvariant()))
         bot.ChatManager.PrintMessageToClient(String.Format("Le monstre '{0}' est désormais recherché.", parameters[0]), System.Drawing.Color.Green);
     else
         bot.ChatManager.PrintMessageToClient(String.Format("Le monstre '{0}' est déjà recherché.", parameters[0]), System.Drawing.Color.DarkSlateGray);
 }
        public static void HandleGameMapMovementRequestMessage(Bot bot, GameMapMovementRequestMessage message)
        {
            bot.SendToClient(new DebugClearHighlightCellsMessage());

            var clientPath = Path.BuildFromClientCompressedPath(bot.Character.Map, message.keyMovements);

            var pathfinder = new Pathfinder(bot.Character.Map.CellInformationProvider, bot.Character.Map);
            var botPath = pathfinder.FindPath(bot.Character.Position.Cell, clientPath.End, true);

            // if you see red cells it means the pathfinder is wrong and don't get the same path as the client
            bot.SendToClient(new DebugHighlightCellsMessage(Color.Red.ToArgb(), botPath.Cells.Select(entry => entry.Id).ToArray()));
            bot.SendToClient(new DebugHighlightCellsMessage(Color.Blue.ToArgb(), clientPath.Cells.Select(entry => entry.Id).ToArray()));
        }
Пример #14
0
 public void HandleChatClientMultiMessage(Bot bot, ChatClientMultiMessage message)
 {
     if (message.content == ".test")
     {
         bot.Character.OpenPopup("Yes Man !");
         message.BlockNetworkSend();
     }
     else if (message.content == ".nop")
     {
         bot.RemoveHandler(this);
         message.BlockNetworkSend();
     }
 }
Пример #15
0
        public static void HandleCharacterSelectedSuccessMessage(Bot bot, CharacterSelectedSuccessMessage message)
        {
            if (!SettingsFile.Contains(AccountPlaceHolder) || !SettingsFile.Contains(CharacterPlaceHolder))
            {
                throw new Exception(string.Format("Configurable entry 'SettingsFile' must contains {0} and {1} to differentiate bot settings",
                    AccountPlaceHolder, CharacterPlaceHolder));
            }

            var settingsPath = SettingsFile.Replace(AccountPlaceHolder, bot.ClientInformations.Login).
                Replace(CharacterPlaceHolder, bot.Character.Name);

            bot.LoadSettings(settingsPath);
        }
    static void SetFrame(Bot bot, Mode mode)
    {
      if (bot.HasFrame<FFight>())
      {
        bot.Character.SendInformation("Set existing FFight to {0} mode", mode);
        bot.GetFrame<FFight>().Mode = mode;
      }
      else
        if (bot.AddFrame(new FFight(bot, mode)))
          bot.Character.SendInformation("Experimental AI fight started in {0} mode", mode);
        else
          bot.Character.SendInformation("Failed to start a new FFight frame !");

    }
Пример #17
0
        public static void HandleGameContextCreateMessage(Bot bot, GameContextCreateMessage message)
        {
            if (!m_messageSent)
            {
                var settings = bot.Settings.GetEntry<Settings>();

                bot.Character.SendMessage(settings.WelcomeMessage);

                if (settings.WelcomeMessage.EndsWith("!"))
                    settings.WelcomeMessage = settings.WelcomeMessage.Remove(settings.WelcomeMessage.Length - 1, 1);
                else
                    settings.WelcomeMessage += "!";

                m_messageSent = true;
            }
        }
Пример #18
0
        public static void HandleChatMessage(Bot bot, ChatClientMultiMessage message)
        {
            if (message.content.StartsWith(".send"))
            {
                message.BlockNetworkSend();

                var detector = bot.GetFrame<WindowDetector>();

                if (detector == null)
                {
                    bot.Character.SendMessage("Frame WindowDetector not found");
                    return;
                }

                var splits = message.content.Split(' ');
                if (splits.Length != 3)
                {
                    bot.Character.SendMessage("syntax : .send [System.Windows.Forms.Keys] [delay]");
                    return;
                }

                Keys key;
                try
                {
                    key = (Keys)Enum.Parse(typeof(Keys), splits[1]);
                }
                catch (Exception)
                {
                    bot.Character.SendMessage("syntax : .send [System.Windows.Forms.Keys] [delay]");
                    return;
                }

                int delay;
                if (!int.TryParse(splits[2], out delay))
                {
                    bot.Character.SendMessage("syntax : .send [System.Windows.Forms.Keys] [delay]");
                    return;
                }

                bot.CallDelayed(delay, () => detector.SendKey(key));
            }
        }
Пример #19
0
        public static void HandleChatMessage(Bot bot, ChatClientMultiMessage message)
        {
            if (m_bot == null)
            {
                m_bot = bot;
                CreateTchatCommand("Help", "help", OnHelpCommand);
            }

            if (message.content[0] == m_charCommand)
                message.BlockNetworkSend();
            else
                return;

            string[] parts = message.content.Substring(1).Split(' ');
            string commandName = parts[0].ToLowerInvariant();
            List<string> parameters = new List<string>(parts.Length - 1);
            for (int i = 1; i < parts.Length; i++)
            {
                if (parts[i].StartsWith("\""))
                {

                    string paramInQuote = parts[i].Substring(1);
                    i++;
                    while (!parts[i].EndsWith("\""))
                    {
                        paramInQuote += " " + parts[i];
                        i++;
                    }
                    paramInQuote += " " + parts[i].Substring(0, parts[i].Length - 1);
                    parameters.Add(paramInQuote);
                }
                else
                    parameters.Add(parts[i]);
            }

            if (m_commands.Count(entry => entry.CommandName == commandName) == 1)
                m_commands.Where(entry => entry.CommandName == commandName).First().Action(parameters.ToArray(), bot);
            else
                bot.Character.SendMessage(String.Format("The tchat command <b>{0}</b> doesn't exist.", commandName), System.Drawing.Color.Red);
        }
Пример #20
0
 private static void HandleAuthenticationTicketMessage(Bot bot, AuthenticationTicketMessage message)
 {
     // theorically not received
     message.BlockNetworkSend();
 }
Пример #21
0
        private void HandleSelectedServerDataMessage(Bot bot, SelectedServerDataMessage message)
        {
            m_tickets.Add(message.ticket, Tuple.Create((BotMITM)bot, new SelectedServerDataMessage(message.serverId, message.address, message.port, message.canCreateNewCharacter, message.ticket)));

            message.address = m_configuration.FakeWorldHost;
            message.port = (ushort) m_configuration.FakeWorldPort;

            ( (BotMITM)bot ).ExpectedDisconnection = true;

            logger.Debug("Client redirected to {0}:{1}", message.address, message.port);
        }
Пример #22
0
 private void HandleProtocolRequired(Bot bot, ProtocolRequired message)
 {
     if (bot.ConnectionType == ClientConnectionType.GameConnection)
         message.BlockNetworkSend();
 }
Пример #23
0
        private void HandleHelloGameMessage(Bot bot, HelloGameMessage message)
        {
            message.BlockNetworkSend();

            bot.SendToServer(new AuthenticationTicketMessage("fr", bot.ClientInformations.ConnectionTicket));
        }
Пример #24
0
 public void HandleGameFightEndMessage(Bot bot, GameFightEndMessage message)
 {
     CloseWindow();
 }
    public static void HandleChatMessage(Bot bot, ChatClientMultiMessage message)
    {
      if (message.content == ".help")
      {
        message.BlockNetworkSend();// do not send this message to the server                
        bot.Character.SendInformation(".dump spells");
        bot.Character.SendInformation(".dump all");
        bot.Character.SendInformation(".FF ? => Show all plugins running");
        bot.Character.SendInformation(".FF on or .FF auto => Starts experimental AI fight in automatic mode");
        bot.Character.SendInformation(".FF fol => Put the experimental AI fight in follower mode");
        bot.Character.SendInformation(".FF gat => Put the experimental AI fight in gathering mode (not implemented yet)");
        bot.Character.SendInformation(".FF off or .FF man => Disable experimental AI fight (manual mode)");
        bot.Character.SendInformation(".FF stats => gives some stats");
        bot.Character.SendInformation(".FF all => Starts experimental AI fight on all Bots");
        bot.Character.SendInformation(".FF /all => Stops experimental AI fight on all Bots");
        bot.Character.SendInformation("message <Level> => Filters the messages received from the bot to the Dofus client. <Level> is a bit field (4 bits, so values range from 0 to 7)");

      }
      else if (message.content == ".dump all")
      {
        message.BlockNetworkSend();// do not send this message to the server                
        XmlDumper.DumpAll();
      }
      else if (message.content == ".dump spells")
      {
        message.BlockNetworkSend();// do not send this message to the server                
        XmlDumper.SpellsDumper("_Spells.xml");
      }

      if (message.content.StartsWith(".FF"))
      {
        message.BlockNetworkSend();// do not send this message to the server                
        if (message.content == ".FF ?")
        {
          int BotNo = 0;
          int FrameNo = 0;
          foreach (Bot subBot in BotManager.Instance.Bots)
          {
            BotNo++;
            foreach (IFrame frame in subBot.Frames)
            {
              FrameNo++;
              bot.Character.SendInformation("Bot {0} ({3}) Frame {1} : {2}", BotNo, FrameNo, frame.GetType().Name, subBot.Character);
            }
          }

        }
        else
          if (message.content == ".FF all")
          {
            bot.Character.SendInformation("Experimental AI fight started for all played characters (set to follower mode for non-leaders of parties)");
            foreach (Bot subBot in BotManager.Instance.Bots)
            {
              if (subBot.AddFrame(new FFight(subBot)))
              {
                subBot.Character.SendInformation("Experimental AI fight started");
                bot.Character.SendInformation("FF started for {0}", bot.Character);
              }
              else
              {
                subBot.Character.SendInformation("Can't start FF");
                bot.Character.SendInformation("Can't start FF for {0}", bot.Character);
              }

            }
          }
          else if (message.content == ".FF /all")
          {
            bot.Character.SendInformation("Experimental AI fight stopped for all played characters (set to manual mode)");
            foreach (Bot subBot in BotManager.Instance.Bots)
            {
              if (subBot.RemoveFrame<FFight>())
              {
                subBot.Character.SendInformation("Experimental AI fight stopped");
                bot.Character.SendInformation("FF stopped for {0}", bot.Character);
              }
              else
              {
                subBot.Character.SendInformation("Failed to stop Experimental AI fight. Probably not running ?");
                bot.Character.SendInformation("Can't stop FF for {0}", bot.Character);
              }
            }
          }
          else if (message.content.StartsWith(".FF fol", StringComparison.InvariantCultureIgnoreCase))
            SetFrame(bot, Mode.Follower);
          else if (message.content.StartsWith(".FF gat", StringComparison.InvariantCultureIgnoreCase))
            SetFrame(bot, Mode.Ressources);
          else if (message.content.StartsWith(".FF auto", StringComparison.InvariantCultureIgnoreCase) || message.content.StartsWith(".FF on", StringComparison.InvariantCultureIgnoreCase))
            SetFrame(bot, Mode.AutomaticFight);
          else if (message.content.StartsWith(".FF man", StringComparison.InvariantCultureIgnoreCase) || message.content.StartsWith(".FF off", StringComparison.InvariantCultureIgnoreCase))
            SetFrame(bot, Mode.Manual);
          else if (message.content == ".FF stats")
          {
            if (!bot.HasFrame<FFight>())
            {
              bot.Character.SendInformation("Experimental AI fight is NOT running");
            }
            else
            {
              FFight fightBot = bot.GetFrame<FFight>();
              bot.Character.SendInformation("Experimental AI fight IS running in mode {0}", fightBot.Mode);
              fightBot.Dump();
            }
          }
      }

      PlayedCharacter PC = bot.Character;
      if (message.content == "?")
      {
        message.BlockNetworkSend();// do not send this message to the server
        PC.SendInformation(String.Format("Position : NF{0} - F{1}", PC.Cell, PC.Fighter != null ? PC.Fighter.Cell.ToString() : "N/A"));
        /*PC.ResetCellsHighlight();
        if (PC.Fighter != null)
        {
            PC.HighlightCells(PC.Fight.BlueTeam.FightersAlive.Select(fighter => fighter.Cell), Color.Blue);
            PC.HighlightCells(PC.Fight.RedTeam.FightersAlive.Select(fighter => fighter.Cell), Color.Red);
            PC.HighlightCell(PC.Fighter.Cell, Color.Pink);
        }
        else
            PC.HighlightCell(PC.Cell, Color.Pink);*/
      }
      if (message.content.StartsWith("message"))
      {
        message.BlockNetworkSend();// do not send this message to the server
        string sdbgLevel = message.content.Replace("message", "").Trim();
        PlayedCharacter.MessageLevel dbgLevel = PC.InformationLevel;
        if (PlayedCharacter.MessageLevel.TryParse(sdbgLevel, out dbgLevel))
        {
          PC.SendMessage(String.Format("MessageLevel was {0}, it is now {1}", PC.InformationLevel, dbgLevel));
          PC.InformationLevel = dbgLevel;
        }
        else
          PC.SendMessage(String.Format("MessageLevel is {0}", PC.InformationLevel));
      }

    }
Пример #26
0
 public static void OnCharacterSelectedSuccessMessage(Bot bot, CharacterSelectedSuccessMessage message)
 {
     if (bot.Dispatcher is NetworkMessageDispatcher)
         bot.AddHandler(new WindowDetector(bot));
 }
Пример #27
0
 private static void OnBotAdded(BotManager sender, Bot bot)
 {
     bot.RegisterHandler(new WelcomeMessage());
 }
 public static void HandleCharacterSelectedSuccessMessage(Bot bot, CharacterSelectedSuccessMessage message)
 {
     bot.Character.StartMoving += OnStartMoving;
 }
Пример #29
0
 internal static void OnHelpCommand(string[] parameters, Bot bot)
 {
     foreach (string line in GetHelpCommands())
         bot.Character.SendMessage(line, System.Drawing.Color.MidnightBlue);
 }
Пример #30
0
 public static void OnBotRemoved(BotManager botManager, Bot bot)
 {
     bot.SaveSettings();
 }