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));
                }
            }
        }
Example #2
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 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();
     }
 }
        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));
            }
        }
Example #5
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);
        }
    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));
      }

    }
Example #7
0
        public static void HandleChatMessage(Bot bot, ChatClientMultiMessage message)
        {
            // if the client sends ".hello" in the chat
            if (message.content == ".fight on")
            {
                message.BlockNetworkSend();// do not send this message to the server

                bot.AddHandler(new AutoFight(bot));
                bot.Character.SendMessage("Auto fight started");
            }
            else if (message.content == ".fight off")
            {
                message.BlockNetworkSend();// do not send this message to the server

                bot.RemoveHandler<AutoFight>();
                bot.Character.SendMessage("Auto fight stopped");

            }
        }
 public ChatMessageClient(ChatClientMultiMessage message)
 {
     if (message == null) throw new ArgumentNullException("message");
     Content = message.content;
     Channel = (ChatActivableChannelsEnum) message.channel;
 }
Example #9
0
 public static void HandleChatClientMultiMessage(Bot bot, ChatClientMultiMessage message)
 {
     bot.SendLocal(new BotChatMessageClient(message));
 }
Example #10
0
        public static void HandleChatMessage(Bot bot, ChatClientMultiMessage message)
        {
            if (message.content.StartsWith(".algo submap"))
            {
                bot.Character.ResetCellsHighlight();

                var sw = Stopwatch.StartNew();
                var submaps = SubMapsManager.Instance.GetMapSubMapsBinder(bot.Character.Map.Id);
                sw.Stop();
                bot.Character.SendMessage(string.Format("{0}ms", sw.ElapsedMilliseconds));

                foreach (var subMap in submaps)
                {
                    var random = new Random();
                    int hue = random.Next(0, 361);
                    bot.Character.SendMessage(string.Format("[{0} mapid:{1} submap:{2}]", subMap.GlobalId, subMap.MapId, subMap.SubMapId));

                    double step = 1d / subMap.Neighbours.Count;
                    for (int i = 0; i < subMap.Neighbours.Count; i++)
                    {
                        var neighbour = subMap.Neighbours[i];
                        var color = HSVColorConverter.ColorFromHSV(hue, step * (i + 1), 1);

                        bot.Character.SendMessage(string.Format("[{0}] to [{1}] ({2})",
                                                                subMap.GlobalId, neighbour.GlobalId,
                                                                neighbour.Transition is MovementTransition ? (neighbour.Transition as MovementTransition).MapNeighbour : MapNeighbour.None));
                        if (neighbour.Transition is MovementTransition)
                            bot.Character.HighlightCells((neighbour.Transition as MovementTransition).Cells, color);
                    }
                }

                message.BlockNetworkSend();
            }
            if (message.content.StartsWith(".algo los"))
            {
                var canBeSee = new List<Cell>();
                var cannotBeSee = new List<Cell>();

                Cell currentCell;
                if (bot.Character.IsFighting())
                    currentCell = bot.Character.Fighter.Cell;
                else
                    currentCell = bot.Character.Cell;

                foreach (var cell in bot.Character.Map.Cells.Where(x => x.Walkable))
                {
                    if (bot.Character.Context.CanBeSeen(currentCell, cell, !bot.Character.IsFighting()))
                    {
                        canBeSee.Add(cell);
                    }
                    else
                    {
                        cannotBeSee.Add(cell);
                    }
                }

                bot.Character.ResetCellsHighlight();

                bot.Character.HighlightCells(canBeSee, Color.Green);
                bot.Character.HighlightCells(cannotBeSee, Color.Red);


                message.BlockNetworkSend();
            }
        }