예제 #1
0
        private void sendPlayerText(string text)
        {
            PlayerTextPacket playerTextPacket = (PlayerTextPacket)Packet.Create(PacketType.PLAYERTEXT);

            playerTextPacket.Text = text.Trim();
            _client.SendToServer(playerTextPacket);
        }
예제 #2
0
        public static void SendChatMessage(this Client client, string message)
        {
            PlayerTextPacket tpacket = Packet.Create <PlayerTextPacket>(PacketType.PLAYERTEXT);

            tpacket.Text = message;
            client.SendToServer(tpacket);
        }
예제 #3
0
파일: AntiLag.cs 프로젝트: abrn/exalt-root
 // Token: 0x06000480 RID: 1152 RVA: 0x000181A0 File Offset: 0x000163A0
 public void PlayerText(PlayerTextPacket playerText)
 {
     if (string.IsNullOrEmpty(playerText.Text))
     {
         return;
     }
     if (playerText.Text.StartsWith("/lock ") || playerText.Text.StartsWith("/unlock "))
     {
         string[] array = playerText.Text.Split(new string[]
         {
             "/lock ",
             "/unlock "
         }, StringSplitOptions.RemoveEmptyEntries);
         if (array.Length < 2)
         {
             return;
         }
         string b = array[1].ToLower();
         foreach (GameObject gameObject in this.client.Players.Values)
         {
             if (gameObject.Name.ToLower() == b)
             {
                 bool add = playerText.Text.StartsWith("/lock ");
                 this.ChangeLog(gameObject.ObjectId, add);
                 break;
             }
         }
     }
 }
예제 #4
0
파일: Realmeye.cs 프로젝트: toddw123/KRelay
        private void OnCommand(Client client, string command, string[] args)
        {
            PlayerTextPacket ptp = (PlayerTextPacket)Packet.Create(PacketType.PLAYERTEXT);

            ptp.Text = "/tell mreyeball " + (command == "hide" ? "hide me" : command);
            client.SendToServer(ptp);
        }
예제 #5
0
        public void ClientPacketSent(Client client, Packet packet)
        {
            if (packet.Type == PacketType.PLAYERTEXT)
            {
                PlayerTextPacket playerText = (PlayerTextPacket)packet;
                string           text       = playerText.Text.Replace("/", "").ToLower();
                string           command    = text.Contains(' ')
                    ? text.Split(' ')[0].ToLower()
                    : text;
                string[] args = text.Contains(' ')
                    ? text.Split(' ').Skip(1).ToArray()
                    : new string[0];

                foreach (var pair in _commandHooks)
                {
                    if (pair.Value.Contains(command))
                    {
                        packet.Send = false;
                        pair.Key(client, command, args);
                    }
                }
            }

            foreach (var pair in _genericPacketHooks.Where(pair => pair.Value == packet.GetType()))
            {
                (pair.Key as Delegate)?.Method.Invoke((pair.Key as Delegate)?.Target,
                                                      new object[2] {
                    client, Convert.ChangeType(packet, pair.Value)
                });
            }
        }
예제 #6
0
        public void PlayerText(RealmTime time, PlayerTextPacket pkt)
        {
            if (pkt.Text[0] == '/')
            {
                var x = pkt.Text.Trim().Split(' ');
                ProcessCmd(x[0].Trim('/'), x.Skip(1).ToArray());
                //CommandManager.Execute(this, time, pkt.Text); // Beta Processor
            }
            else
            {
                /*string txt = Encoding.ASCII.GetString(
                 *  Encoding.Convert(
                 *      Encoding.UTF8,
                 *      Encoding.GetEncoding(
                 *          Encoding.ASCII.EncodingName,
                 *          new EncoderReplacementFallback(string.Empty),
                 *          new DecoderExceptionFallback()
                 *          ),
                 *      Encoding.UTF8.GetBytes(pkt.Text)
                 *  )
                 * );*/
                var txt = pkt.Text.ToSafeText();
                if (txt != "")
                {
                    //Removing unwanted crashing characters from strings
                    var chatColor = "";
                    if (Client.Account.Rank > 3)
                    {
                        chatColor = "@";
                    }
                    else if (Client.Account.Rank == 3)
                    {
                        chatColor = "#";
                    }

                    Owner.BroadcastPacket(new TextPacket
                    {
                        Name       = chatColor + Name,
                        ObjectId   = Id,
                        Stars      = Stars,
                        BubbleTime = 5,
                        Recipient  = "",
                        Text       = txt,
                        CleanText  = txt
                    }, null);
                    foreach (var e in Owner.Enemies)
                    {
                        foreach (var b in e.Value.CondBehaviors)
                        {
                            if (b.Condition == BehaviorCondition.OnChat)
                            {
                                b.Behave(BehaviorCondition.OnChat, e.Value, time, null, pkt.Text);
                                b.Behave(BehaviorCondition.OnChat, e.Value, time, null, pkt.Text, this);
                            }
                        }
                    }
                }
            }
        }
예제 #7
0
 private void OnResendCommand(Client client, string command, string[] args)
 {
     if (lastMessage != "")
     {
         PlayerTextPacket playerTextPacket = (PlayerTextPacket)Packet.Create(PacketType.PLAYERTEXT);
         playerTextPacket.Text = lastMessage;
         client.SendToServer(playerTextPacket);
     }
 }
예제 #8
0
 public void PlayerText(RealmTime time, PlayerTextPacket pkt)
 {
     if (pkt.Text[0] == '/')
     {
         string[] x = pkt.Text.Trim().Split(' ');
         ProcessCmd(x[0].Trim('/'), x.Skip(1).ToArray());
         //CommandManager.Execute(this, time, pkt.Text); // Beta Processor
     }
     else
     {
         string txt = Encoding.ASCII.GetString(
             Encoding.Convert(
                 Encoding.UTF8,
                 Encoding.GetEncoding(
                     Encoding.ASCII.EncodingName,
                     new EncoderReplacementFallback(string.Empty),
                     new DecoderExceptionFallback()
                     ),
                 Encoding.UTF8.GetBytes(pkt.Text)
                 )
             );
         if (txt != "")
         {
             //Removing unwanted crashing characters from strings
             string chatColor = "";
             if (Client.Account.Rank > 1)
             {
                 chatColor = ""; //was @; turns all of your text yellow including your name; looks fugly
             }
             else if (Client.Account.Rank == 1)
             {
                 chatColor = ""; //was #; turns your name a dark orange but your text stays white; looks like you're a npc
             }
             Owner.BroadcastPacket(new TextPacket()
             {
                 Name       = chatColor + Name,
                 ObjectId   = Id,
                 Stars      = Stars,
                 BubbleTime = 5,
                 Recipient  = "",
                 Text       = txt,
                 CleanText  = txt
             }, null);
             foreach (var e in Owner.Enemies)
             {
                 foreach (var b in e.Value.CondBehaviors)
                 {
                     if (b.Condition == BehaviorCondition.OnChat)
                     {
                         b.Behave(BehaviorCondition.OnChat, e.Value, time, null, pkt.Text);
                         b.Behave(BehaviorCondition.OnChat, e.Value, time, null, pkt.Text, this);
                     }
                 }
             }
         }
     }
 }
예제 #9
0
        public static void SendChatMessage(this Client client, string text)
        {
            // Create the packet
            PlayerTextPacket ptp = Packet.Create <PlayerTextPacket>(PacketType.PLAYERTEXT);

            // Set the text of the message
            ptp.Text = text;
            // Send the packet to the server
            client.SendToServer(ptp);
        }
예제 #10
0
 // Token: 0x060004E3 RID: 1251 RVA: 0x0001C5E0 File Offset: 0x0001A7E0
 public void text(PlayerTextPacket playerText)
 {
     if (!Settings.Default.EnableFameTools)
     {
         return;
     }
     if ((Settings.Default.FameBlockTeleports && playerText.Text.StartsWith("/tp ")) || playerText.Text.StartsWith("/teleport "))
     {
         playerText.Send = false;
     }
 }
예제 #11
0
파일: Proxy.cs 프로젝트: Jazz23/KRelay
        /// <summary>
        /// Fires any registered callbacks for the specified packet type.
        /// </summary>
        /// <param name="client">Client that recieved the packet</param>
        /// <param name="packet">Packet that was recieved</param>
        public void FireClientPacket(Client client, Packet packet)
        {
            PluginUtils.ProtectedInvoke(() =>
            {
                // Fire command callbacks
                if (packet.Type == PacketType.PLAYERTEXT)
                {
                    PlayerTextPacket playerText = (PlayerTextPacket)packet;
                    string text    = playerText.Text.Replace("/", "").ToLower();
                    string command = text.Contains(' ')
                                     ? text.Split(' ')[0].ToLower()
                                     : text;
                    string[] args = text.Contains(' ')
                                     ? text.Split(' ').Skip(1).ToArray()
                                     : new string[0];

                    foreach (var pair in _commandHooks)
                    {
                        if (pair.Value.Contains(command))
                        {
                            packet.Send = false;
                            pair.Key(client, command, args);
                        }
                    }
                }

                // Fire general client packet callbacks
                if (ClientPacketRecieved != null)
                {
                    ClientPacketRecieved(client, packet);
                }

                // Fire specific hook callbacks if applicable
                foreach (var pair in _packetHooks)
                {
                    if (pair.Value.Contains(packet.Type))
                    {
                        pair.Key(client, packet);
                    }
                }
                try {
                    foreach (var pair in _genericPacketHooks)
                    {
                        if (pair.Value == packet.GetType())
                        {
                            (pair.Key as Delegate).Method.Invoke((pair.Key as Delegate).Target, new object[2] {
                                client, Convert.ChangeType(packet, pair.Value)
                            });
                        }
                    }
                } catch { }
            }, "ClientPacket");
        }
예제 #12
0
 public void PlayerText(RealmTime time, PlayerTextPacket pkt)
 {
     if (pkt.Text[0] == '/')
     {
         string[] x = pkt.Text.Trim().Split(' ');
         try
         {
             AnnounceText = pkt.Text.Substring(10);
             NewsText     = pkt.Text.Substring(6).Split(';');
         }
         catch
         {
             Console.WriteLine("Error at line 24 of Player.Chat.cs");
         }
         ChatMessage = pkt.Text;
         string[] z = pkt.Text.Trim().Split('|');
         y = z.Skip(1).ToArray();
         ProcessCmd(x[0].Trim('/'), x.Skip(1).ToArray());
     }
     else
     {
         if (psr.Account.Admin == true)
         {
             foreach (var i in RealmManager.Clients.Values)
             {
                 i.SendPacket(new TextPacket()
                 {
                     Name       = psr.Account.Name,
                     Stars      = psr.Player.Stars,
                     BubbleTime = 5,
                     Text       = pkt.Text,
                     Recipient  = i.Account.Name
                 });
             }
         }
         else
         {
             Owner.BroadcastPacket(new TextPacket()
             {
                 Name       = Name,
                 ObjectId   = Id,
                 Stars      = Stars,
                 BubbleTime = 5,
                 Recipient  = "",
                 Text       = pkt.Text,
                 CleanText  = pkt.Text
             }, null);
         }
     }
 }
예제 #13
0
 // Token: 0x060004F6 RID: 1270 RVA: 0x0001D2CC File Offset: 0x0001B4CC
 public void text(PlayerTextPacket playerText)
 {
     if (Settings.Default.EnableMapHack && playerText.Text == "/world" && this.client.MapName == "Realm of the Mad God")
     {
         playerText.Send = false;
         this.client._RUDdpffUqrc18m4ldj2l3yrb1t9(MapHack._fpMap.ContainsKey(this._fp) ? ("World: " + MapHack._fpMap[this._fp].ToString()) : "Unknown world");
         return;
     }
     if (playerText.Text == "/savemap")
     {
         playerText.Send = false;
         using (MemoryStream memoryStream = new MemoryStream())
         {
             BinaryWriter binaryWriter = new BinaryWriter(memoryStream);
             Dictionary <ushort, List <byte[]> > dictionary = new Dictionary <ushort, List <byte[]> >();
             foreach (Square tiles in this.client.Tiles)
             {
                 if (tiles != null)
                 {
                     if (!dictionary.ContainsKey(tiles.Type))
                     {
                         dictionary.Add(tiles.Type, new List <byte[]>());
                     }
                     dictionary[tiles.Type].Add(MapHack.ShortPos.Compress(tiles.X, tiles.Y));
                 }
             }
             foreach (KeyValuePair <ushort, List <byte[]> > keyValuePair in dictionary)
             {
                 binaryWriter.Write(keyValuePair.Key);
                 binaryWriter.Write(keyValuePair.Value.Count);
                 foreach (byte[] buffer in keyValuePair.Value)
                 {
                     binaryWriter.Write(buffer);
                 }
             }
             byte[] bytes = MapHack.Zip(memoryStream.ToArray());
             File.WriteAllBytes(string.Concat(new string[]
             {
                 "map_",
                 this.client.MapName,
                 " ",
                 Environment.TickCount.ToString(),
                 ".gz"
             }), bytes);
         }
     }
 }
예제 #14
0
        private void OnPlayerText(Client client, Packet packet)
        {
            PlayerTextPacket playerTextPacket = (PlayerTextPacket)packet;

            if (!playerTextPacket.Text.StartsWith("/") || playerTextPacket.Text.StartsWith("/t ") || playerTextPacket.Text.StartsWith("/tell ") || playerTextPacket.Text.StartsWith("/w ") || playerTextPacket.Text.StartsWith("/whisper ") || playerTextPacket.Text.StartsWith("/yell "))
            {
                lastMessage = playerTextPacket.Text;
            }

            if (ChatAssistConfig.Default.LogChat)
            {
                using (System.IO.StreamWriter file = new System.IO.StreamWriter("ChatAssist.log", true))
                {
                    file.WriteLine("<" + DateTime.Now.ToString() + ">: You: '" + playerTextPacket.Text + "'");
                }
            }
        }
예제 #15
0
 public void Msg()
 {
     if (enabled && spamenabled)
     {
         if (msgindex % 3 == 0)
         {
             PlayerTextPacket pt = (PlayerTextPacket)Packet.Create(PacketType.PLAYERTEXT);
             pt.Text = this.curTrade.GetMessage();
             if (msgindex % 6 == 0)
             {
                 pt.Text += " ";
             }
             client.SendToServer(pt);
         }
     }
     msgindex++;
 }
예제 #16
0
파일: IpJoin.cs 프로젝트: abrn/exalt-root
    // Token: 0x060004EC RID: 1260 RVA: 0x0001C82C File Offset: 0x0001AA2C
    public void text(PlayerTextPacket text)
    {
        if (!Settings.Default.EnableGotoCommand)
        {
            return;
        }
        if (!text.Text.StartsWith("/"))
        {
            return;
        }
        string[] array = text.Text.Split(new char[]
        {
            ' '
        });
        string a = array[0].ToLower();

        if (a == "/ip")
        {
            text.Send = false;
            this.SendTextToClient("Server IP: " + this._ip);
            return;
        }
        if (a == "/iunderstandthiswarning")
        {
            text.Send = false;
            this.SendTextToClient("Warning acknowledged and disabled, you are free to use /goto now.");
            Settings.Default.EnableGotoCommandWarningAcknowledged = true;
            Settings.Default.Save();
            return;
        }
        if (!(a == "/goto"))
        {
            return;
        }
        text.Send = false;
        if (!Settings.Default.EnableGotoCommandWarningAcknowledged)
        {
            this.SendTextToClient("WARNING! People can effectively steal your login credentials with /goto and gain access to your account. If someone told you to paste this in, you probably don't want to do it. They can host a malicious server that saves your encrypted email and password when you connect, which lets them login to your account in game. YOU HAVE BEEN WARNED! Type /iUnderstandThisWarning to disable this warning.");
            return;
        }
        if (array.Length >= 2 && !string.IsNullOrEmpty(array[1]))
        {
            this.SendClientToIp(array[1]);
        }
    }
예제 #17
0
        private void OnText(Client client, Packet packet)
        {
            if (!ChatAssistConfig.Default.Enabled)
            {
                return;
            }
            //TextPacket text = (TextPacket)packet;
            TextPacket text = packet.To <TextPacket>();

            if (ChatAssistConfig.Default.DisableMessages && text.Recipient == "")
            {
                text.Send = false;
                return;
            }

            foreach (string filter in ChatAssistConfig.Default.Blacklist)
            {
                if (text.Text.ToLower().Contains(filter.ToLower()))
                {
                    // Is spam
                    if (ChatAssistConfig.Default.CensorSpamMessages)
                    {
                        text.Text      = "...";
                        text.CleanText = "...";
                        return;
                    }

                    text.Send = false;

                    if (ChatAssistConfig.Default.AutoIgnoreSpamMessage ||
                        (ChatAssistConfig.Default.AutoIgnoreSpamPM && text.Recipient != ""))
                    {
                        // Ignore
                        PlayerTextPacket playerText = new PlayerTextPacket();
                        playerText.Text = "/ignore " + text.Name;
                        client.SendToServer(playerText);
                        return;
                    }
                }
            }
        }
예제 #18
0
        //public void OnGotoAck(Client client, Packet packet)
        //{
        //	GotoAckPacket gap = (GotoAckPacket)packet;
        //	if (blockGotoAck[client])
        //	{
        //		gap.Send = false;
        //		blockGotoAck[client] = false;
        //		return;
        //	}
        //}

        public void SendMessage(Client client)
        {
            // Check if we have all the items we are selling
            List <ItemStruct> tmpMList = Selling[client].Select(itemb => new ItemStruct(itemb.Name, itemb.Qty)).ToList();

            for (int j = 4; j < 12; j++)
            {
                for (int i = 0; i < tmpMList.Count; i++)
                {
                    if (client.PlayerData.Slot[j] > 0)
                    {
                        if (tmpMList[i].Name == GameData.Items.ByID((ushort)client.PlayerData.Slot[j]).Name)
                        {
                            if (tmpMList[i].Qty > 0)
                            {
                                tmpMList[i].Qty--;
                            }
                            break;
                        }
                    }
                }
            }
            bool send = true;

            for (int i = 0; i < tmpMList.Count; i++)
            {
                if (tmpMList[i].Qty > 0)
                {
                    send = false;
                }
            }
            if (send)
            {
                if (SpamMsg[client] != "")
                {
                    PlayerTextPacket ptp = (PlayerTextPacket)Packet.Create(PacketType.PLAYERTEXT);
                    ptp.Text = SpamMsg[client].Replace(":name:", "@" + client.PlayerData.Name);
                    client.SendToServer(ptp);
                }
            }
        }
예제 #19
0
        public void TC(Client client, Packet packet)
        {
            TradeChangedPacket p  = (TradeChangedPacket)packet;
            PZClient           cl = clientlist[IndexOfClient(client)];

            cl.customer.UpdateItems(p.Offers);
            if (cl.enabled)
            {
                Console.WriteLine("--------------------------");
                int    totlefts = 0;
                string msg      = "";
                foreach (var item in cl.CheckCustomer(true))
                {
                    Console.WriteLine(item.ToString() + " - " + item.amount);
                    totlefts += item.amount;
                    if (item.amount > 0)
                    {
                        msg += item.amount + " " + item.ToString() + ";";
                    }
                }
                Console.WriteLine("Verdict: " + (totlefts <= 0));
                if (totlefts <= 0)
                {
                    cl.SelectSelling();
                    AcceptTradePacket ac = (AcceptTradePacket)Packet.Create(PacketType.ACCEPTTRADE);
                    ac.YourOffers = p.Offers;
                    ac.MyOffers   = cl.GetToSel();
                    cl.client.SendToServer(ac);
                }
                else
                {
                    PlayerTextPacket ptpkt = (PlayerTextPacket)Packet.Create(PacketType.PLAYERTEXT);
                    ptpkt.Text = "/t " + cl.customer.name + " An extra: " + msg + " plz!";
                    cl.client.SendToServer(ptpkt);
                }
            }
        }
예제 #20
0
        public void TS(Client client, Packet packet)
        {
            TradeStartPacket ts = (TradeStartPacket)packet;

            PZClient cl = clientlist[IndexOfClient(client)];

            cl.InTrade = true;
            if (cl.enabled)
            {
                cl.customer = new PZCustomer(ts);
                cl.last     = client.PlayerData.Slot;
                cl.CancelTimerStart();
                if (!cl.curTrade.CheckBuying(cl, ts.YourItems))
                {
                    PlayerTextPacket pt = (PlayerTextPacket)Packet.Create(PacketType.PLAYERTEXT);
                    try
                    {
                        pt.Text = @"/tell " + ts.YourName + " You don't have " + cl.curTrade.BuyingToString();
                        client.SendToServer(pt);
                    }
                    catch
                    {
                        Console.WriteLine("Please define trades for \"" + client.PlayerData.Name + "\" to do");
                    }

                    CancelTradePacket ct = (CancelTradePacket)Packet.Create(PacketType.CANCELTRADE);
                    client.SendToServer(ct);
                    cl.InTrade = false;
                }
                else
                {
                    Console.WriteLine("Found correct stuff!");
                    cl.InTrade = true;
                    cl.SelectSelling();
                }
            }
        }
예제 #21
0
 // Token: 0x060004CE RID: 1230 RVA: 0x0001BCA4 File Offset: 0x00019EA4
 public void _QrK9KtR4xguWgEYrBE9xnEwwcqd(PlayerTextPacket playerText)
 {
     if (this._W6Ov6AArxzTTDnCyBtZPqkqNaKf._50Ms1zsqax9Ua48PaWMPQfIENYb != null && playerText.Text == "/reset")
     {
         this._wIV6RuTHp6K14hjsabfqulJm6RB = this._W6Ov6AArxzTTDnCyBtZPqkqNaKf._50Ms1zsqax9Ua48PaWMPQfIENYb._sNZat68b2TvW6o582Hg9CFuEJCV;
         return;
     }
     if (playerText.Text.StartsWith("/an "))
     {
         string text = playerText.Text.Substring(4);
         if (string.IsNullOrEmpty(text))
         {
             return;
         }
         int num;
         if (!int.TryParse(text, out num))
         {
             return;
         }
         Settings.Default.AutoNexusPercentageThreshold = num;
         this._L9Sq7ilWPAc2XkNbriRGfXQBoeh();
         this._W6Ov6AArxzTTDnCyBtZPqkqNaKf._RUDdpffUqrc18m4ldj2l3yrb1t9(string.Format("Set autonexus health threshold to {0}% (at {1} health)", num, this._jWMYX8VJLB8QB7nBQBQJn0c1btJ));
     }
 }
예제 #22
0
        private void OnText(Client client, Packet packet)
        {
            if (!ChatAssistConfig.Default.Enabled)
            {
                return;
            }

            TextPacket text = packet.To <TextPacket>();

            if (ChatAssistConfig.Default.EnableNPCFilter && text.NumStars == -1) // Not a message from a user
            {
                foreach (string name in NPCIgnoreList)
                {
                    if (text.Name.Contains(name))
                    {
                        text.Send = false;
                        return;
                    }
                }

                //if (text.Name != "" && text.Name != "#Oryx the Mad God")
                //{
                //    PluginUtils.Log("ChatAssist", "Server Message '" + text.Text + "' from: " + text.Name);
                //}
            }

            if ((ChatAssistConfig.Default.DisableMessages && text.Recipient == "") ||
                (text.Recipient == "" && text.NumStars < ChatAssistConfig.Default.StarFilter && text.NumStars != -1) ||
                (text.Recipient != "" && text.NumStars < ChatAssistConfig.Default.StarFilterPM) && text.NumStars != -1)
            {
                text.Send = false;
                return;
            }

            // SpamFilter
            if (ChatAssistConfig.Default.EnableSpamFilter)
            {
                foreach (string filter in ChatAssistConfig.Default.Blacklist)
                {
                    if (text.Text.ToLower().Contains(filter.ToLower()))
                    {
                        // Is spam
                        if (ChatAssistConfig.Default.CensorSpamMessages)
                        {
                            text.Text      = "...";
                            text.CleanText = "...";
                        }
                        else
                        {
                            text.Send = false;
                        }

                        if (ChatAssistConfig.Default.AutoIgnoreSpamMessage ||
                            (ChatAssistConfig.Default.AutoIgnoreSpamPM && text.Recipient != ""))
                        {
                            // Ignore
                            PlayerTextPacket playerText = (PlayerTextPacket)Packet.Create(PacketType.PLAYERTEXT);
                            playerText.Text = "/ignore " + text.Name;
                            client.SendToServer(playerText);
                        }

                        return;
                    }
                }
            }

            // ChatLog
            if (ChatAssistConfig.Default.LogChat && text.NumStars != -1)
            {
                using (System.IO.StreamWriter file = new System.IO.StreamWriter("ChatAssist.log", true))
                {
                    file.WriteLine("<" + DateTime.Now.ToString() + ">: " + text.Name + "[" + text.NumStars + "]: '" + text.Text + "'");
                }
            }
        }
예제 #23
0
파일: Plugin.cs 프로젝트: Astyric/famebot
        public void Initialize(Proxy proxy)
        {
            // Initialize lists so they are empty instead of null.
            targets         = new List <Target>();
            playerPositions = new Dictionary <int, Target>();
            portals         = new List <Portal>();
            enemies         = new List <Enemy>();
            obstacles       = new List <Obstacle>();

            // get obstacles
            obstacleIds = new List <ushort>();
            GameData.Objects.Map.ForEach((kvp) =>
            {
                if (kvp.Value.FullOccupy || kvp.Value.OccupySquare)
                {
                    obstacleIds.Add(kvp.Key);
                }
            });
            PluginUtils.Log("FameBot", "Found {0} obstacles.", obstacleIds.Count);

            // Initialize and display gui.
            gui = new FameBotGUI();
            PluginUtils.ShowGUI(gui);

            // Initialize and display gui if K-Relay is not in stealth mode.
            if (!StealthConfig.Default.StealthEnabled)
            {
                ShowGUI();
            }

            // Hide / show gui based on the stealth mode status.
            proxy.StealthStateChanged += enabled => { if (enabled)
                                                      {
                                                          HideGUI();
                                                      }
                                                      else
                                                      {
                                                          ShowGUI();
                                                      } };

            // Get the config.
            config = ConfigManager.GetConfiguration();

            // Look for all processes with the configured flash player name.
            Process[] processes = Process.GetProcessesByName(config.FlashPlayerName);
            if (processes.Length == 1)
            {
                // If there is one client open, bind to it.
                Log("Automatically bound to client.");
                flashPtr = processes[0].MainWindowHandle;
                gui?.SetHandle(flashPtr);
                if (config.AutoConnect)
                {
                    Start();
                }
            }
            // If there are multiple or no clients running, log a message.
            else if (processes.Length > 1)
            {
                Log("Multiple flash players running. Use the /bind command on the client you want to use.");
            }
            else
            {
                Log("Couldn't find flash player. Use the /bind command in game, then start the bot.");
            }

            #region Proxy Hooks
            proxy.HookCommand("bind", ReceiveCommand);
            proxy.HookCommand("start", ReceiveCommand);
            proxy.HookCommand("gui", ReceiveCommand);
            proxy.HookCommand("famebot", ReceiveCommand);

            proxy.HookPacket(PacketType.UPDATE, OnUpdate);
            proxy.HookPacket(PacketType.NEWTICK, OnNewTick);
            proxy.HookPacket(PacketType.PLAYERHIT, OnHit);
            proxy.HookPacket(PacketType.MAPINFO, OnMapInfo);
            proxy.HookPacket(PacketType.TEXT, OnText);
            proxy.HookPacket(PacketType.GOTOACK, (client, packet) =>
            {
                if (blockNextAck)
                {
                    packet.Send  = false;
                    blockNextAck = false;
                }
            });
            #endregion

            // Runs every time a client connects.
            proxy.ClientConnected += (client) =>
            {
                // Clear all lists and reset keys.
                connectedClient = client;
                targets.Clear();
                playerPositions.Clear();
                enemies.Clear();
                obstacles.Clear();
                followTarget = false;
                isInNexus    = false;
                ResetAllKeys();
            };

            // Runs every time a client disconnects.
            proxy.ClientDisconnected += (client) =>
            {
                Log("Client disconnected. Waiting a few seconds before trying to press play...");
                PressPlay();
            };

            guiEvent += (evt) =>
            {
                switch (evt)
                {
                case GuiEvent.StartBot:
                    Start();
                    break;

                case GuiEvent.StopBot:
                    Stop();
                    break;

                case GuiEvent.SettingsChanged:
                    Log("Updated config");
                    config = ConfigManager.GetConfiguration();
                    break;
                }
            };

            // Send an in game message when the gui fires the event.
            sendMessage += (message) =>
            {
                if (!(connectedClient?.Connected ?? false))
                {
                    return;
                }
                PlayerTextPacket packet = (PlayerTextPacket)Packet.Create(PacketType.PLAYERTEXT);
                packet.Text = message;
                connectedClient.SendToServer(packet);
            };
        }
    public void HandlePlayerCommand(PlayerTextPacket playerText)
    {
        if (!Settings.Default.EnableGotoCommand)
        {
            goto IL_000f;
        }
        goto IL_01d2;
IL_01d2:
        int num;
        int num2;

        if (playerText._Message.StartsWith("/"))
        {
            num  = -184337631;
            num2 = num;
        }
        else
        {
            num  = -1517235003;
            num2 = num;
        }
        goto IL_0014;
IL_0014:
        string[] array = default(string[]);
        while (true)
        {
            uint num3;
            switch ((num3 = (uint)num ^ 0xE1B2BB24u) % 15u)
            {
            case 13u:
                break;

            default:
                return;

            case 10u:
            {
                int num6;
                int num7;
                if (array[0] == "/ip")
                {
                    num6 = 1792502034;
                    num7 = num6;
                }
                else
                {
                    num6 = 698822585;
                    num7 = num6;
                }
                num = num6 ^ ((int)num3 * -985111412);
                continue;
            }

            case 4u:
                goto IL_008d;

            case 3u:
                return;

            case 6u:
                return;

            case 2u:
            {
                _50w8wVuv8bL5nhKaR2EHxjrTamB.SendInfoMessage("Server IP: " + _ServerHostname);
                Thread thread = new Thread((ThreadStart) delegate
                    {
                        Clipboard.SetText(_ServerHostname);
                    });
                thread.SetApartmentState(ApartmentState.STA);
                thread.Start();
                num = (int)(num3 * 1103150964) ^ -1716114833;
                continue;
            }

            case 8u:
                playerText._Send = false;
                num = ((int)num3 * -685168380) ^ -671761443;
                continue;

            case 0u:
                array = playerText._Message.Split(' ');
                num   = -500983293;
                continue;

            case 7u:
                return;

            case 12u:
            {
                int num8;
                int num9;
                if (array.Length >= 2)
                {
                    num8 = -1632455468;
                    num9 = num8;
                }
                else
                {
                    num8 = -2097540126;
                    num9 = num8;
                }
                num = num8 ^ ((int)num3 * -265559845);
                continue;
            }

            case 5u:
            {
                string ip = new string(array[1].Where(delegate(char c)
                    {
                        if (!char.IsLetterOrDigit(c))
                        {
                            while (true)
                            {
                                int num11 = 212579801;
                                while (true)
                                {
                                    uint num12;
                                    switch ((num12 = (uint)num11 ^ 0xDE26FE2u) % 4u)
                                    {
                                    case 2u:
                                        break;

                                    case 3u:
                                        {
                                            int num13;
                                            int num14;
                                            if (c == '.')
                                            {
                                                num13 = -158807755;
                                                num14 = num13;
                                            }
                                            else
                                            {
                                                num13 = -694170600;
                                                num14 = num13;
                                            }
                                            num11 = num13 ^ (int)(num12 * 1129387666);
                                            continue;
                                        }

                                    case 0u:
                                        return(c == '-');

                                    default:
                                        goto IL_0061;
                                    }
                                    break;
                                }
                            }
                        }
                        goto IL_0061;
                        IL_0061:
                        return(true);
                    }).ToArray());
                ConnectToHostname(ip);
                num = -828669762;
                continue;
            }

            case 14u:
                goto IL_01d2;

            case 9u:
                playerText._Send = false;
                num = (int)(num3 * 4425787) ^ -440414735;
                continue;

            case 11u:
            {
                int num4;
                int num5;
                if (string.IsNullOrEmpty(array[1]))
                {
                    num4 = 2079224214;
                    num5 = num4;
                }
                else
                {
                    num4 = 1662400866;
                    num5 = num4;
                }
                num = num4 ^ ((int)num3 * -1900441634);
                continue;
            }

            case 1u:
                return;
            }
            break;
IL_008d:
            int num10;
            if (!(array[0] == "/goto"))
            {
                num   = -828669762;
                num10 = num;
            }
            else
            {
                num   = -181681680;
                num10 = num;
            }
        }
        goto IL_000f;
IL_000f:
        num = -513758749;
        goto IL_0014;
    }
예제 #25
0
    public void _CgwO1K8tgdyKPdKvCtJupNhapLD(PlayerTextPacket playerText)
    {
        if (string.IsNullOrEmpty(playerText._Message))
        {
            return;
        }
        string[]   array = default(string[]);
        PlayerData jI4Bueou7dItYp5S7QML5vyC6Rc       = default(PlayerData);
        IEnumerable <PlayerData> source              = default(IEnumerable <PlayerData>);
        PlayerData      jI4Bueou7dItYp5S7QML5vyC6Rc2 = default(PlayerData);
        double          num14    = default(double);
        PlayerData      current2 = default(PlayerData);
        TeleportPacket  gXkgDctfNPN0Xyz8qvjQDIS73of2 = default(TeleportPacket);
        ReconnectPacket reconnectPacket = default(ReconnectPacket);
        string          value           = default(string);
        string          text            = default(string);
        PlayerData      current         = default(PlayerData);

        while (true)
        {
            int num = -1750270187;
            while (true)
            {
                uint num2;
                switch ((num2 = (uint)num ^ 0xA67D4B79u) % 17u)
                {
                case 7u:
                    break;

                case 2u:
                {
                    int num9;
                    int num10;
                    if (playerText._Message[0] != '/')
                    {
                        num9  = 806781121;
                        num10 = num9;
                    }
                    else
                    {
                        num9  = 532765268;
                        num10 = num9;
                    }
                    num = num9 ^ (int)(num2 * 1164389951);
                    continue;
                }

                case 15u:
                {
                    int num41;
                    int num42;
                    if (Settings.Default.EnableTeleportToSelf)
                    {
                        num41 = -264259780;
                        num42 = num41;
                    }
                    else
                    {
                        num41 = -2010866462;
                        num42 = num41;
                    }
                    num = num41 ^ (int)(num2 * 1334473406);
                    continue;
                }

                case 14u:
                    return;

                case 1u:
                    if (array[0] == "/tp")
                    {
                        num = ((int)num2 * -919367479) ^ -648364078;
                        continue;
                    }
                    while (true)
                    {
                        if (array[0] == "/tpq")
                        {
                            int num11 = -788484004;
                            while (true)
                            {
                                switch ((num2 = (uint)num11 ^ 0xA67D4B79u) % 11u)
                                {
                                case 10u:
                                    num11 = -1591089261;
                                    continue;

                                case 1u:
                                    break;

                                case 8u:
                                    jI4Bueou7dItYp5S7QML5vyC6Rc = source.First();
                                    num11 = ((int)num2 * -185312111) ^ 0x5721D1B0;
                                    continue;

                                case 3u:
                                    return;

                                case 6u:
                                    playerText._Send = false;
                                    num11            = -773015358;
                                    continue;

                                case 4u:
                                {
                                    int num15;
                                    int num16;
                                    if (!source.Any())
                                    {
                                        num15 = 1964101611;
                                        num16 = num15;
                                    }
                                    else
                                    {
                                        num15 = 351924091;
                                        num16 = num15;
                                    }
                                    num11 = num15 ^ ((int)num2 * -907251790);
                                    continue;
                                }

                                case 5u:
                                    jI4Bueou7dItYp5S7QML5vyC6Rc2 = null;
                                    num14 = 0.0;
                                    num11 = -896664423;
                                    continue;

                                case 2u:
                                {
                                    int num12;
                                    int num13;
                                    if (Settings.Default.EnableTeleportToPlayerClosestToQuestCommand)
                                    {
                                        num12 = -1733244460;
                                        num13 = num12;
                                    }
                                    else
                                    {
                                        num12 = -1906903748;
                                        num13 = num12;
                                    }
                                    num11 = num12 ^ (int)(num2 * 1657868672);
                                    continue;
                                }

                                case 9u:
                                    _50w8wVuv8bL5nhKaR2EHxjrTamB.SendInfoMessage("Quest not found!");
                                    return;

                                case 0u:
                                    source = _50w8wVuv8bL5nhKaR2EHxjrTamB._Aq9hW2NyDqEkITmxzYm6OCQLaDB.Values.Where((PlayerData enemy) => enemy._fn2CRnBpjyTWHR9K8SU4iOwhDtK == _EeeRzHBDOL9AqYJ8CIuFvkR3Qlz);
                                    num11  = (int)(num2 * 23163576) ^ -1930811091;
                                    continue;

                                default:
                                    goto IL_052b;
                                }
                                break;
                            }
                            continue;
                        }
                        goto IL_0a15;
IL_0a6b:
                        _50w8wVuv8bL5nhKaR2EHxjrTamB.SendInfoMessage("Teleporting to " + jI4Bueou7dItYp5S7QML5vyC6Rc2._WL2DOBxBuX9DARzf2KPoaJbgZiCb + "!");
                        int num17 = -770781531;
                        goto IL_0695;
IL_0690:
                        num17 = -1589234120;
                        goto IL_0695;
IL_052b:
                        using (Dictionary <int, PlayerData> .ValueCollection.Enumerator enumerator = _50w8wVuv8bL5nhKaR2EHxjrTamB._naDcMlPfaanTh6qrJ3cOuO4HNwz.Values.GetEnumerator())
                        {
                            while (true)
                            {
                                int num18;
                                int num19;
                                if (!enumerator.MoveNext())
                                {
                                    num18 = -193042290;
                                    num19 = num18;
                                }
                                else
                                {
                                    num18 = -1985374203;
                                    num19 = num18;
                                }
                                while (true)
                                {
                                    switch ((num2 = (uint)num18 ^ 0xA67D4B79u) % 9u)
                                    {
                                    case 3u:
                                        num18 = -1985374203;
                                        continue;

                                    default:
                                        goto end_IL_0541;

                                    case 6u:
                                        current2 = enumerator.Current;
                                        num18    = -125787301;
                                        continue;

                                    case 5u:
                                        jI4Bueou7dItYp5S7QML5vyC6Rc2 = current2;
                                        num14 = current2._Position.GetDistance(jI4Bueou7dItYp5S7QML5vyC6Rc._Position);
                                        num18 = -2029029138;
                                        continue;

                                    case 8u:
                                    {
                                        int num26;
                                        int num27;
                                        if (!current2._NNgacHsIcOUlk6tnbwwxK7FDsff())
                                        {
                                            num26 = 1621638204;
                                            num27 = num26;
                                        }
                                        else
                                        {
                                            num26 = 1013029468;
                                            num27 = num26;
                                        }
                                        num18 = num26 ^ ((int)num2 * -99043881);
                                        continue;
                                    }

                                    case 2u:
                                    {
                                        int num22;
                                        int num23;
                                        if (current2._Position.GetDistance(jI4Bueou7dItYp5S7QML5vyC6Rc._Position) >= num14)
                                        {
                                            num22 = -2076566562;
                                            num23 = num22;
                                        }
                                        else
                                        {
                                            num22 = -799362313;
                                            num23 = num22;
                                        }
                                        num18 = num22 ^ ((int)num2 * -1129373452);
                                        continue;
                                    }

                                    case 7u:
                                        break;

                                    case 0u:
                                    {
                                        int num24;
                                        int num25;
                                        if (jI4Bueou7dItYp5S7QML5vyC6Rc2 != null)
                                        {
                                            num24 = -1864538543;
                                            num25 = num24;
                                        }
                                        else
                                        {
                                            num24 = -1042825133;
                                            num25 = num24;
                                        }
                                        num18 = num24 ^ ((int)num2 * -342833652);
                                        continue;
                                    }

                                    case 1u:
                                    {
                                        int num20;
                                        int num21;
                                        if (current2 == _50w8wVuv8bL5nhKaR2EHxjrTamB._PlayerData)
                                        {
                                            num20 = -1385695744;
                                            num21 = num20;
                                        }
                                        else
                                        {
                                            num20 = -457941751;
                                            num21 = num20;
                                        }
                                        num18 = num20 ^ ((int)num2 * -1011815673);
                                        continue;
                                    }

                                    case 4u:
                                        goto end_IL_0541;
                                    }
                                    break;
                                }
                            }
                            end_IL_0541 :;
                        }
                        if (jI4Bueou7dItYp5S7QML5vyC6Rc2 == null)
                        {
                            goto IL_0690;
                        }
                        goto IL_0a6b;
IL_0695:
                        while (true)
                        {
                            switch ((num2 = (uint)num17 ^ 0xA67D4B79u) % 34u)
                            {
                            case 21u:
                                break;

                            default:
                                return;

                            case 28u:
                                goto IL_0733;

                            case 26u:
                                goto IL_0753;

                            case 10u:
                                _50w8wVuv8bL5nhKaR2EHxjrTamB.SendToServer(gXkgDctfNPN0Xyz8qvjQDIS73of2);
                                num17 = (int)(num2 * 1686821117) ^ -2054065793;
                                continue;

                            case 32u:
                                reconnectPacket = (ReconnectPacket)Packet.CreatePacketFromType(PacketType.RECONNECT);
                                num17           = ((int)num2 * -1436860093) ^ -1342146281;
                                continue;

                            case 22u:
                                playerText._Send = false;
                                num17            = -13505546;
                                continue;

                            case 8u:
                                return;

                            case 7u:
                                Settings.Default.CurrentServer = value;
                                num17 = (int)((num2 * 1561157505) ^ 0x25CB793E);
                                continue;

                            case 2u:
                                return;

                            case 1u:
                                _50w8wVuv8bL5nhKaR2EHxjrTamB.SendInfoMessage("No players found to teleport to!");
                                num17 = (int)(num2 * 2096922046) ^ -125483602;
                                continue;

                            case 30u:
                            {
                                int num32;
                                int num33;
                                if (array[0] == "/loc")
                                {
                                    num32 = -712487546;
                                    num33 = num32;
                                }
                                else
                                {
                                    num32 = -1310431336;
                                    num33 = num32;
                                }
                                num17 = num32 ^ ((int)num2 * -292526049);
                                continue;
                            }

                            case 24u:
                                _50w8wVuv8bL5nhKaR2EHxjrTamB.SendInfoMessage("Usage: /connect [server name]");
                                num17 = -2142874341;
                                continue;

                            case 6u:
                                gXkgDctfNPN0Xyz8qvjQDIS73of2           = (TeleportPacket)Packet.CreatePacketFromType(PacketType.TELEPORT);
                                gXkgDctfNPN0Xyz8qvjQDIS73of2._ObjectId = jI4Bueou7dItYp5S7QML5vyC6Rc2._fn2CRnBpjyTWHR9K8SU4iOwhDtK;
                                num17 = (int)(num2 * 931766000) ^ -1673800875;
                                continue;

                            case 27u:
                                reconnectPacket._IsFromArena = false;
                                reconnectPacket._Key         = new byte[0];
                                num17 = ((int)num2 * -96955804) ^ -1988870985;
                                continue;

                            case 31u:
                            {
                                int num34;
                                int num35;
                                if (!(array[0] == "/connect"))
                                {
                                    num34 = 684173617;
                                    num35 = num34;
                                }
                                else
                                {
                                    num34 = 719580645;
                                    num35 = num34;
                                }
                                num17 = num34 ^ (int)(num2 * 696526382);
                                continue;
                            }

                            case 12u:
                                reconnectPacket._KeyTime = -1;
                                num17 = (int)((num2 * 62081320) ^ 0x76031676);
                                continue;

                            case 4u:
                                return;

                            case 33u:
                                reconnectPacket._MapName = value + " Nexus";
                                num17 = (int)((num2 * 2115272512) ^ 0x344C60BE);
                                continue;

                            case 16u:
                                reconnectPacket._GameId = -2;
                                num17 = (int)(num2 * 948123561) ^ -2127748574;
                                continue;

                            case 9u:
                            {
                                int num30;
                                int num31;
                                if (array.Length != 2)
                                {
                                    num30 = 534559486;
                                    num31 = num30;
                                }
                                else
                                {
                                    num30 = 516844265;
                                    num31 = num30;
                                }
                                num17 = num30 ^ ((int)num2 * -157206137);
                                continue;
                            }

                            case 19u:
                                goto IL_098f;

                            case 5u:
                                playerText._Send = false;
                                _50w8wVuv8bL5nhKaR2EHxjrTamB.SendInfoMessage($"Current location: {Math.Round(_50w8wVuv8bL5nhKaR2EHxjrTamB._PlayerData._Position._PositionX, 1)}, {Math.Round(_50w8wVuv8bL5nhKaR2EHxjrTamB._PlayerData._Position._PositionY, 1)}");
                                num17 = -1483513078;
                                continue;

                            case 23u:
                                goto IL_0a15;

                            case 15u:
                            {
                                int num28;
                                int num29;
                                if (ServerList._aCrqUtEobC4JELAJ9SKdNpyMHvF.TryGetValue(array[1].ToLower(), out value))
                                {
                                    num28 = -229036871;
                                    num29 = num28;
                                }
                                else
                                {
                                    num28 = -182536418;
                                    num29 = num28;
                                }
                                num17 = num28 ^ (int)(num2 * 1156014646);
                                continue;
                            }

                            case 25u:
                                goto IL_0a6b;

                            case 20u:
                                Settings.Default.Change();
                                num17 = ((int)num2 * -1527675920) ^ 0x3050A16A;
                                continue;

                            case 14u:
                                _50w8wVuv8bL5nhKaR2EHxjrTamB.SendToClient(reconnectPacket);
                                return;

                            case 0u:
                                reconnectPacket._Port = 2050;
                                num17 = (int)(num2 * 916855739) ^ -357830690;
                                continue;

                            case 13u:
                                reconnectPacket._Hostname = "127.0.0.1";
                                num17 = (int)(num2 * 611952939) ^ -184346516;
                                continue;

                            case 17u:
                                _50w8wVuv8bL5nhKaR2EHxjrTamB.SendInfoMessage("Unknown server!");
                                return;

                            case 29u:
                                return;

                            case 18u:
                                return;

                            case 11u:
                                _50w8wVuv8bL5nhKaR2EHxjrTamB.SendInfoMessage("Connecting to: " + value);
                                num17 = (int)(num2 * 1732984103) ^ -347248346;
                                continue;

                            case 3u:
                                return;
                            }
                            break;
IL_098f:
                            int num36;
                            if (Settings.Default.EnableLocCommand)
                            {
                                num17 = -1503005708;
                                num36 = num17;
                            }
                            else
                            {
                                num17 = -154957677;
                                num36 = num17;
                            }
                            continue;
IL_0753:
                            int num37;
                            if (!(array[0] == "/l"))
                            {
                                num17 = -564094377;
                                num37 = num17;
                            }
                            else
                            {
                                num17 = -1006679788;
                                num37 = num17;
                            }
                            continue;
IL_0733:
                            int num38;
                            if (!Settings.Default.EnableConnectCommand)
                            {
                                num17 = -1712388317;
                                num38 = num17;
                            }
                            else
                            {
                                num17 = -351010149;
                                num38 = num17;
                            }
                        }
                        goto IL_0690;
IL_0a15:
                        int num39;
                        if (!(array[0] == "/con"))
                        {
                            num17 = -1361958442;
                            num39 = num17;
                        }
                        else
                        {
                            num17 = -1417258857;
                            num39 = num17;
                        }
                        goto IL_0695;
                    }

                case 0u:
                    return;

                case 5u:
                {
                    int num43;
                    int num44;
                    if (array.Length == 1)
                    {
                        num43 = -636101856;
                        num44 = num43;
                    }
                    else
                    {
                        num43 = -1018051115;
                        num44 = num43;
                    }
                    num = num43 ^ (int)(num2 * 1919184901);
                    continue;
                }

                case 9u:
                    return;

                case 4u:
                {
                    int num45;
                    int num46;
                    if (Settings.Default.EnableTeleportToPlayerCommand)
                    {
                        num45 = 808092347;
                        num46 = num45;
                    }
                    else
                    {
                        num45 = 767592542;
                        num46 = num45;
                    }
                    num = num45 ^ (int)(num2 * 998309261);
                    continue;
                }

                case 12u:
                {
                    int num40;
                    if (array.Length != 2)
                    {
                        num   = -1265570669;
                        num40 = num;
                    }
                    else
                    {
                        num   = -672276365;
                        num40 = num;
                    }
                    continue;
                }

                case 11u:
                    return;

                case 13u:
                    text = array[1].ToLower();
                    num  = -1164419516;
                    continue;

                case 8u:
                {
                    _50w8wVuv8bL5nhKaR2EHxjrTamB.SendInfoMessage("Teleporting to self!");
                    TeleportPacket gXkgDctfNPN0Xyz8qvjQDIS73of3 = (TeleportPacket)Packet.CreatePacketFromType(PacketType.TELEPORT);
                    gXkgDctfNPN0Xyz8qvjQDIS73of3._ObjectId = _50w8wVuv8bL5nhKaR2EHxjrTamB._PlayerData._fn2CRnBpjyTWHR9K8SU4iOwhDtK;
                    _50w8wVuv8bL5nhKaR2EHxjrTamB.SendToServer(gXkgDctfNPN0Xyz8qvjQDIS73of3);
                    num = ((int)num2 * -247600723) ^ -171822290;
                    continue;
                }

                case 3u:
                    playerText._Send = false;
                    num = -852138602;
                    continue;

                case 6u:
                    array = playerText._Message.Split(' ');
                    if (array.Length != 0)
                    {
                        num = -225100984;
                        continue;
                    }
                    return;

                case 10u:
                    _50w8wVuv8bL5nhKaR2EHxjrTamB.SendInfoMessage("Usage: /tp [partial or full player name]");
                    num = (int)(num2 * 215014787) ^ -718363310;
                    continue;

                default:
                {
                    using (Dictionary <int, PlayerData> .ValueCollection.Enumerator enumerator = _50w8wVuv8bL5nhKaR2EHxjrTamB._naDcMlPfaanTh6qrJ3cOuO4HNwz.Values.GetEnumerator())
                    {
                        while (true)
                        {
                            int num3;
                            int num4;
                            if (enumerator.MoveNext())
                            {
                                num3 = -383970670;
                                num4 = num3;
                            }
                            else
                            {
                                num3 = -74179290;
                                num4 = num3;
                            }
                            while (true)
                            {
                                switch ((num2 = (uint)num3 ^ 0xA67D4B79u) % 8u)
                                {
                                case 6u:
                                    num3 = -383970670;
                                    continue;

                                default:
                                    goto end_IL_026e;

                                case 3u:
                                    current = enumerator.Current;
                                    num3    = -222315011;
                                    continue;

                                case 0u:
                                    break;

                                case 5u:
                                {
                                    int num7;
                                    int num8;
                                    if (!current._WL2DOBxBuX9DARzf2KPoaJbgZiCb.ToLower().Contains(text))
                                    {
                                        num7 = -1300799904;
                                        num8 = num7;
                                    }
                                    else
                                    {
                                        num7 = -1187543807;
                                        num8 = num7;
                                    }
                                    num3 = num7 ^ ((int)num2 * -127224387);
                                    continue;
                                }

                                case 4u:
                                {
                                    int num5;
                                    int num6;
                                    if (current._NNgacHsIcOUlk6tnbwwxK7FDsff())
                                    {
                                        num5 = -2025665199;
                                        num6 = num5;
                                    }
                                    else
                                    {
                                        num5 = -1298686500;
                                        num6 = num5;
                                    }
                                    num3 = num5 ^ (int)(num2 * 1212507724);
                                    continue;
                                }

                                case 1u:
                                {
                                    _50w8wVuv8bL5nhKaR2EHxjrTamB.SendInfoMessage("Teleporting to " + current._WL2DOBxBuX9DARzf2KPoaJbgZiCb + "!");
                                    TeleportPacket teleportPacket = (TeleportPacket)Packet.CreatePacketFromType(PacketType.TELEPORT);
                                    teleportPacket._ObjectId = current._fn2CRnBpjyTWHR9K8SU4iOwhDtK;
                                    _50w8wVuv8bL5nhKaR2EHxjrTamB.SendToServer(teleportPacket);
                                    num3 = (int)((num2 * 2016917650) ^ 0x3A7C32A1);
                                    continue;
                                }

                                case 2u:
                                    return;

                                case 7u:
                                    goto end_IL_026e;
                                }
                                break;
                            }
                        }
                        end_IL_026e :;
                    }
                    _50w8wVuv8bL5nhKaR2EHxjrTamB.SendInfoMessage("Player with the name similar to " + text + " not found!");
                    return;
                }
                }
                break;
            }
        }
    }
예제 #26
0
        public void Initialize(Proxy proxy)
        {
            targets         = new List <Target> ();
            playerPositions = new Dictionary <int, Target> ();
            portals         = new List <Portal> ();
            enemies         = new List <Enemy> ();
            obstacles       = new List <Obstacle> ();

            obstacleIds = new List <ushort> ();
            GameData.Objects.Map.ForEach((kvp) => {
                if (kvp.Value.FullOccupy || kvp.Value.OccupySquare)
                {
                    obstacleIds.Add(kvp.Key);
                }
            });
            PluginUtils.Log("FameBot", "Found {0} obstacles.", obstacleIds.Count);

            gui = new FameBotGUI();
            PluginUtils.ShowGUI(gui);

            config = ConfigManager.GetConfiguration();

            Process[] processes = Process.GetProcessesByName(config.FlashPlayerName);
            if (processes.Length == 1)
            {
                Log("Automatically bound to client.");
                flashPtr = processes[0].MainWindowHandle;
                gui?.SetHandle(flashPtr);
                if (config.AutoConnect)
                {
                    Start();
                }
            }
            else if (processes.Length > 1)
            {
                Log("Multiple flash players running. Use the /bind command on the client you want to use.");
            }
            else
            {
                Log("Couldn't find flash player. Use the /bind command in game, then start the bot.");
            }

            #region Proxy Hooks
            proxy.HookCommand("bind", ReceiveCommand);
            proxy.HookCommand("start", ReceiveCommand);
            proxy.HookCommand("gui", ReceiveCommand);
            proxy.HookCommand("famebot", ReceiveCommand);
            proxy.HookCommand("stop1", ReceiveCommand);
            proxy.HookCommand("options", ReceiveCommand);
            proxy.HookPacket(PacketType.RECONNECT, OnReconnect);
            proxy.HookPacket(PacketType.UPDATE, OnUpdate);
            proxy.HookPacket(PacketType.NEWTICK, OnNewTick);
            proxy.HookPacket(PacketType.PLAYERHIT, OnHit);
            proxy.HookPacket(PacketType.MAPINFO, OnMapInfo);
            proxy.HookPacket(PacketType.TEXT, OnText);
            proxy.HookPacket(PacketType.GOTOACK, (client, packet) => {
                if (blockNextAck)
                {
                    packet.Send  = false;
                    blockNextAck = false;
                }
            });
            #endregion

            proxy.ClientConnected += (client) => {
                connectedClient = client;
                targets.Clear();
                playerPositions.Clear();
                enemies.Clear();
                obstacles.Clear();
                followTarget = false;
                isInNexus    = false;
                ResetAllKeys();
            };

            proxy.ClientDisconnected += (client) => {
                Log("Client disconnected. Waiting a few seconds before trying to press play...");
                PressPlay();
            };

            guiEvent += (evt) => {
                switch (evt)
                {
                case GuiEvent.StartBot:
                    Start();
                    break;

                case GuiEvent.StopBot:
                    Stop();
                    break;

                case GuiEvent.SettingsChanged:
                    Log("Updated config");
                    config = ConfigManager.GetConfiguration();
                    break;
                }
            };

            sendMessage += (message) => {
                if (!(connectedClient?.Connected ?? false))
                {
                    return;
                }
                PlayerTextPacket packet = (PlayerTextPacket)Packet.Create(PacketType.PLAYERTEXT);
                packet.Text = message;
                connectedClient.SendToServer(packet);
            };

            proxy.HookPacket(PacketType.FAILURE, (client, packet) => {
                FailurePacket p = packet as FailurePacket;

                if (p.ErrorId != 9)
                {
                    Console.WriteLine("<FAILURE> ID: " + p.ErrorId + " Message: " + p.ErrorMessage);
                }

                if (p.ErrorMessage == "{\"key\":\"server.realm_full\"}")
                {
                    Attempts++;
                    if (Attempts >= 2 && bestName != "")
                    {
                        _bestName = bestName;
                        ReconnectPacket reconnect = (ReconnectPacket)Packet.Create(PacketType.RECONNECT);
                        reconnect.Name            = "{\"text\":\"server.realm_of_the_mad_god\"}";
                        reconnect.Host            = "";
                        reconnect.Stats           = "";
                        reconnect.Port            = -1;
                        reconnect.GameId          = -3;
                        reconnect.KeyTime         = -1;
                        reconnect.IsFromArena     = false;
                        reconnect.Key             = new byte[0];

                        connectedClient.SendToClient(reconnect);
                        Attempts        = 0;
                        loopingforrealm = true;
                    }
                }
            });

            proxy.HookPacket(PacketType.CREATESUCCESS, (client, packet) => {
                target_ = null;
                if (enabled)
                {
                    PluginUtils.Delay(200, () => Stop());
                    PluginUtils.Delay(500, () => Stop());
                    PluginUtils.Delay(1300, () => Stop());
                    PluginUtils.Delay(2200, () => Start());
                }
            });
        }
예제 #27
0
파일: Client.cs 프로젝트: abrn/exalt-root
    // Token: 0x06000232 RID: 562 RVA: 0x0000FDC0 File Offset: 0x0000DFC0
    private void HandlePacket(Packet packet)
    {
        UpdatePacket updatePacket = packet as UpdatePacket;

        if (updatePacket != null)
        {
            this._objectTracker.Update(updatePacket);
            this.SafeWalk.Update(updatePacket);
            this._autoNexus.Update(updatePacket);
            this._fameHelper.Update(updatePacket);
            this._accuracyFarm.Update(updatePacket);
            this._antiLag.Update(updatePacket);
            this._autoLoot.Update(updatePacket);
            this._mapHack.Update(updatePacket);
            this._o3Helper.Update(updatePacket);
            this._showLHPot.Update(updatePacket);
            return;
        }
        NewTickPacket newTickPacket = packet as NewTickPacket;

        if (newTickPacket != null)
        {
            this._objectTracker.NewTick(newTickPacket);
            this._antiDebuffs.NewTick(newTickPacket);
            this._autoNexus.NewTick(newTickPacket);
            this._antiDdos.NewTick();
            this._fameHelper.NewTick(newTickPacket);
            this._accuracyFarm.NewTick(newTickPacket);
            this._antiLag.NewTick(newTickPacket);
            this._o3Helper.NewTick(newTickPacket);
            this._autoNexus2.NewTick(newTickPacket);
            return;
        }
        MovePacket movePacket = packet as MovePacket;

        if (movePacket != null)
        {
            this.PreviousTime = movePacket._Nx46RcGIU0H1BCGWaJXjN1ieopt;
            this._objectTracker.move(movePacket);
            this._antiDebuffs.Move(movePacket);
            this._autoLoot.Move(movePacket);
            this.AntiAfk.move(movePacket);
            this._autoNexus.move(movePacket);
            this._autoNexus2.move(movePacket);
            return;
        }
        MapInfoPacket mapInfoPacket = packet as MapInfoPacket;

        if (mapInfoPacket != null)
        {
            Console.WriteLine("Client: Map is " + mapInfoPacket.Name);
            this._objectTracker.MapInfo(mapInfoPacket);
            this._autoNexus2.MapInfo(mapInfoPacket);
            this.SafeWalk.MapInfo(mapInfoPacket);
            this._autoNexus.MapInfo(mapInfoPacket);
            this._autoLoot.MapInfo(mapInfoPacket);
            this._fameHelper.MapInfo();
            _accuracyFarm.MapInfo();
            this._antiLag.MapInfo(mapInfoPacket);
            this._mapHack.MapInfo(mapInfoPacket);
            this._o3Helper.MapInfo(mapInfoPacket);
            this._showLHPot.MapInfo(mapInfoPacket);
            return;
        }
        PlayerTextPacket playerTextPacket = packet as PlayerTextPacket;

        if (playerTextPacket != null)
        {
            this._teleportTools.text(playerTextPacket);
            this._ipJoin.text(playerTextPacket);
            this._fameHelper._QrK9KtR4xguWgEYrBE9xnEwwcqd(playerTextPacket);
            this._antiLag.PlayerText(playerTextPacket);
            this._mapHack.text(playerTextPacket);
            this._autoNexus._QrK9KtR4xguWgEYrBE9xnEwwcqd(playerTextPacket);
            return;
        }
        _5Qyhf9ImNgkDzh4BmaDRKP646iH createSuccessPacket = packet as _5Qyhf9ImNgkDzh4BmaDRKP646iH;

        if (createSuccessPacket != null)
        {
            this.PlayerId = createSuccessPacket.ObjectId;
            this._objectTracker._1lYB9SyYVs1zUAIHgLGbUs7pmeb();
            this._bazaarTimer.CreateSuccess();
            this._autoNexus2._1lYB9SyYVs1zUAIHgLGbUs7pmeb();
            return;
        }
        FailurePacket failurePacket = packet as FailurePacket;

        if (failurePacket != null)
        {
            Console.WriteLine(string.Format("Client: Got failure {0}, {1} ({2})", failurePacket.ErrorId, failurePacket.ErrorMessage, failurePacket.ErrorPlace));
            return;
        }
        ReconnectPacket reconnectPacket = packet as ReconnectPacket;

        if (reconnectPacket != null)
        {
            this.Reconnect(reconnectPacket);
            return;
        }
        HelloPacket helloPacket = packet as HelloPacket;

        if (helloPacket != null)
        {
            this.Hello(helloPacket);
            return;
        }
        PlayerHitPacket playerHitPacket = packet as PlayerHitPacket;

        if (playerHitPacket != null)
        {
            this._autoNexus.PlayerHit(playerHitPacket);
            this._antiDebuffs.PlayerHit(playerHitPacket);
            return;
        }
        AoEPacket pqhqze9k9pObME2LmlIcbfEeSYS = packet as AoEPacket;

        if (pqhqze9k9pObME2LmlIcbfEeSYS != null)
        {
            this._autoNexus._M1PxW31jx87SGG4gvOYAwe86vjg(pqhqze9k9pObME2LmlIcbfEeSYS);
            this._antiDebuffs.AoE(pqhqze9k9pObME2LmlIcbfEeSYS);
            return;
        }
        AoEAckPacket x7UwVkbcYG7VnZWu4HCA8hCeQtS = packet as AoEAckPacket;

        if (x7UwVkbcYG7VnZWu4HCA8hCeQtS != null)
        {
            this._autoNexus._iKqf12lpU2ifSlxUxUegqEC5CVe(x7UwVkbcYG7VnZWu4HCA8hCeQtS);
            return;
        }
        GroundDamagePacket hllcDvAIxPBOvJZP4BFTFQUoryN = packet as GroundDamagePacket;

        if (hllcDvAIxPBOvJZP4BFTFQUoryN != null)
        {
            this._autoNexus._524YRDmz9HCOj575eu5oeD5ruJb(hllcDvAIxPBOvJZP4BFTFQUoryN);
            return;
        }
        _6lHFncsY9352Wg3pNnnFZ49g5xA 6lHFncsY9352Wg3pNnnFZ49g5xA = packet as QuestObjIdPacket;
        if (6lHFncsY9352Wg3pNnnFZ49g5xA != null)
        {
            this._teleportTools._FMTVFcTfzNRteqoB3XiUkaNps7l(6lHFncsY9352Wg3pNnnFZ49g5xA);
            return;
        }
        ShowEffectPacket showEffectPacket = packet as ShowEffectPacket;

        if (showEffectPacket != null)
        {
            this._antiLag.ShowEffect(showEffectPacket);
            this._autoNexus._1nwhQXngJ6rNjd7Ufx1bWeF0vhM(showEffectPacket);
            this._o3Helper._1nwhQXngJ6rNjd7Ufx1bWeF0vhM(showEffectPacket);
            return;
        }
        _4wU9AwmH67XtmNygsXuDz9DUXYm 4wU9AwmH67XtmNygsXuDz9DUXYm = packet as _4wU9AwmH67XtmNygsXuDz9DUXYm;
        if (4wU9AwmH67XtmNygsXuDz9DUXYm != null)
        {
            this._antiLag._Q1PiJQ99KBCJeLcZ0HOk3AUAjIP(4wU9AwmH67XtmNygsXuDz9DUXYm);
            return;
        }
        PlayerShootPacket fbqBESNaaIBpK5dNK9X5lWOOll = packet as PlayerShootPacket;

        if (fbqBESNaaIBpK5dNK9X5lWOOll != null)
        {
            this._autoNexus2.PlayerShoot(fbqBESNaaIBpK5dNK9X5lWOOll);
            return;
        }
        TextPacket cbwOjnzusZzuPkHfx7wuwePHqrf = packet as TextPacket;

        if (cbwOjnzusZzuPkHfx7wuwePHqrf != null)
        {
            this._antiSpam._IDtpCgDjmC1AQOcZCJSFNAYjlbH(cbwOjnzusZzuPkHfx7wuwePHqrf);
            this._antiLag.Text(cbwOjnzusZzuPkHfx7wuwePHqrf);
            this._o3Helper._IDtpCgDjmC1AQOcZCJSFNAYjlbH(cbwOjnzusZzuPkHfx7wuwePHqrf);
            return;
        }
        UseItemPacket lylWoxWrca2h31SiYiDb8gyQP0o = packet as UseItemPacket;

        if (lylWoxWrca2h31SiYiDb8gyQP0o != null)
        {
            this._autoNexus2.UseItem(lylWoxWrca2h31SiYiDb8gyQP0o);
            this._fameHelper.UseItem(lylWoxWrca2h31SiYiDb8gyQP0o);
            return;
        }
        EnemyShootPacket cbwrHXLbrCktla3qkqXNmNymbvH = packet as EnemyShootPacket;

        if (cbwrHXLbrCktla3qkqXNmNymbvH != null)
        {
            this._objectTracker._Qz49aY7UXgmnBNNMA6Q6IEQtadk(cbwrHXLbrCktla3qkqXNmNymbvH);
            return;
        }
        InvSwapPacket maJp2qic3r54gk5Eg1eeMowxvXh = packet as InvSwapPacket;

        if (maJp2qic3r54gk5Eg1eeMowxvXh != null)
        {
            this._autoLoot.InvSwap(maJp2qic3r54gk5Eg1eeMowxvXh);
            this._autoNexus._ZHfjECn2B9JJHnVF67eBaO57JUp(maJp2qic3r54gk5Eg1eeMowxvXh);
            return;
        }
        EscapePacket m74ADSrj0VfuNwRBO916gAw0Nu = packet as EscapePacket;

        if (m74ADSrj0VfuNwRBO916gAw0Nu != null)
        {
            this.Escape(m74ADSrj0VfuNwRBO916gAw0Nu);
            return;
        }
        InvitedToGuildPacket tJHGMoVf7DhHyQm8a6SCuL1cSWl = packet as InvitedToGuildPacket;

        if (tJHGMoVf7DhHyQm8a6SCuL1cSWl != null)
        {
            this._antiDdos.Invite(tJHGMoVf7DhHyQm8a6SCuL1cSWl);
            return;
        }
        TeleportPacket rvckmor8bw91EVaRfdwc25aHYbc = packet as TeleportPacket;

        if (rvckmor8bw91EVaRfdwc25aHYbc != null)
        {
            this._fameHelper.Teleport(rvckmor8bw91EVaRfdwc25aHYbc);
            this._accuracyFarm.Teleport(rvckmor8bw91EVaRfdwc25aHYbc);
            return;
        }
        _6UIiGxMChbVinHsvx5uqg8WrMRc 6UIiGxMChbVinHsvx5uqg8WrMRc = packet as InvResultPacket;
        if (6UIiGxMChbVinHsvx5uqg8WrMRc != null)
        {
            this._autoLoot._yOjSn1WKSXsXVziJpL1eH5gSoWg(6UIiGxMChbVinHsvx5uqg8WrMRc);
            return;
        }
        NotificationPacket zIBPB6zZVww7yGWtjJqRMmACh1q = packet as NotificationPacket;

        if (zIBPB6zZVww7yGWtjJqRMmACh1q != null)
        {
            this._autoNexus._4GSfC8bADOwIwOXLYze8EOUBQxJ(zIBPB6zZVww7yGWtjJqRMmACh1q);
            return;
        }
        AccountListPacket k4pBHmoGRyaE6dWf1FIvL0dcuzKA = packet as AccountListPacket;

        if (k4pBHmoGRyaE6dWf1FIvL0dcuzKA != null)
        {
            this._antiLag.AccountList(k4pBHmoGRyaE6dWf1FIvL0dcuzKA);
            return;
        }
        EditAccountListPacket co7ACSeK1WWaCGAPAqLaov37Wqdb = packet as EditAccountListPacket;

        if (co7ACSeK1WWaCGAPAqLaov37Wqdb != null)
        {
            this._antiLag.EditAccountList(co7ACSeK1WWaCGAPAqLaov37Wqdb);
            return;
        }
        _7k8aOfI7MhNrVnHioUXbsPAxkbm 7k8aOfI7MhNrVnHioUXbsPAxkbm = packet as EnemyHitPacket;
        if (7k8aOfI7MhNrVnHioUXbsPAxkbm != null)
        {
            this._o3Helper._9BgsXisaUbFFlj5HLRd76sERUUX(7k8aOfI7MhNrVnHioUXbsPAxkbm);
            return;
        }
        DeathPacket wOmvsGmaE1PheZ2fPjD9V16UEseb = packet as DeathPacket;

        if (wOmvsGmaE1PheZ2fPjD9V16UEseb != null)
        {
            this._autoNexus._qQsqaOxgCR9yg9ky7erATaKrgCC(wOmvsGmaE1PheZ2fPjD9V16UEseb);
            return;
        }
    }
예제 #28
0
 // Token: 0x06000520 RID: 1312 RVA: 0x0001E84C File Offset: 0x0001CA4C
 public void text(PlayerTextPacket playerText)
 {
     if (!string.IsNullOrEmpty(playerText.Text))
     {
         if (playerText.Text[0] == '/')
         {
             string[] array = playerText.Text.Split(new char[]
             {
                 ' '
             });
             if (array.Length != 0)
             {
                 if (array[0] == "/tp")
                 {
                     if (!Settings.Default.EnableTeleportToPlayerCommand || Settings.Default.FameBlockTeleports)
                     {
                         return;
                     }
                     playerText.Send = false;
                     if (array.Length == 1)
                     {
                         if (Settings.Default.EnableTeleportToSelf)
                         {
                             this.client.SendToClient("Teleporting to self!");
                             TeleportPacket teleportPacket = (TeleportPacket)Packet.Create(PacketType.TELEPORT);
                             teleportPacket.ObjectId = this.client.Player.ObjectId;
                             this.client.SendToServer(teleportPacket);
                             return;
                         }
                     }
                     if (array.Length == 2)
                     {
                         string text = array[1].ToLower();
                         foreach (GameObject gameObject in this.client.Players.Values)
                         {
                             if (!gameObject.isInvisible() && gameObject.Name.ToLower().Contains(text))
                             {
                                 this.client.SendToClient("Teleporting to " + gameObject.Name + "!");
                                 TeleportPacket teleportPacket = (TeleportPacket)Packet.Create(PacketType.TELEPORT);
                                 teleportPacket.ObjectId = gameObject.ObjectId;
                                 this.client.SendToServer(teleportPacket);
                                 return;
                             }
                         }
                         this.client.SendToClient("Player with the name similar to " + text + " not found!");
                         return;
                     }
                     this.client.SendToClient("Usage: /tp [partial or full player name]");
                     return;
                 }
                 else if (array[0] == "/tpq")
                 {
                     if (!Settings.Default.EnableTeleportToPlayerClosestToQuestCommand || Settings.Default.FameBlockTeleports)
                     {
                         return;
                     }
                     playerText.Send = false;
                     IEnumerable <GameObject> source = from enemy in this.client.Enemies.Values
                                                       where enemy.ObjectId == this._lastQuest
                                                       select enemy;
                     if (!source.Any <GameObject>())
                     {
                         this.client.SendToClient("Quest not found!");
                         return;
                     }
                     GameObject gameObject2 = null;
                     double     num         = 0.0;
                     GameObject gameObject3 = source.First <GameObject>();
                     foreach (GameObject gameObject4 in this.client.Players.Values)
                     {
                         if (gameObject4 != this.client.Player && !gameObject4.isInvisible() && (gameObject2 == null || gameObject4.ClientPosition.DistanceSquaredTo(gameObject3.ClientPosition) < num))
                         {
                             gameObject2 = gameObject4;
                             num         = gameObject4.ClientPosition.DistanceSquaredTo(gameObject3.ClientPosition);
                         }
                     }
                     if (gameObject2 == null)
                     {
                         this.client.SendToClient("No players found to teleport to!");
                         return;
                     }
                     this.client.SendToClient("Teleporting to " + gameObject2.Name + "!");
                     TeleportPacket teleportPacket2 = (TeleportPacket)Packet.Create(PacketType.TELEPORT);
                     teleportPacket2.ObjectId = gameObject2.ObjectId;
                     this.client.SendToServer(teleportPacket2);
                     return;
                 }
                 else if (array[0] == "/c" || array[0] == "/con" || array[0] == "/connect")
                 {
                     if (!Settings.Default.EnableConnectCommand)
                     {
                         return;
                     }
                     playerText.Send = false;
                     if (array.Length != 2)
                     {
                         this.client.SendToClient("Usage: /connect [server name]");
                     }
                     else
                     {
                         string text2;
                         if (!ServerParser.ServerAbbreviations.TryGetValue(array[1].ToLower(), out text2))
                         {
                             this.client.SendToClient("Unknown server!");
                             return;
                         }
                         ReconnectPacket reconnectPacket = (ReconnectPacket)Packet.Create(PacketType.RECONNECT);
                         reconnectPacket.GameId         = -2;
                         reconnectPacket.Host           = "127.0.0.1";
                         reconnectPacket.Port           = 2050;
                         reconnectPacket.isFromArena    = false;
                         reconnectPacket.Key            = new byte[0];
                         reconnectPacket.KeyTime        = -1;
                         reconnectPacket.Name           = text2 + " Nexus";
                         reconnectPacket.State          = string.Empty;
                         Settings.Default.CurrentServer = text2;
                         this.client.SendToClient("Connecting to: " + text2);
                         this.client.SendToClient(reconnectPacket);
                         return;
                     }
                 }
             }
             return;
         }
     }
 }
예제 #29
0
        public void Initialize(Proxy proxy)
        {
            // Initialize lists so they are empty instead of null.
            targets = new List <Target>();

            playerPositions = new Dictionary <int, Target>();
            portals         = new List <Portal>();
            enemies         = new List <Enemy>();
            rocks           = new List <Rock>();

            // Initialize and display gui.
            gui = new FameBotGUI();
            PluginUtils.ShowGUI(gui);

            // Get the config.
            config = ConfigManager.GetConfiguration();

            // Look for all processes with the name "flash.exe".
            Process[] processes = Process.GetProcessesByName("flash");
            if (processes.Length == 1)
            {
                // If there is one client open, bind to it.
                Log("Automatically bound to client.");
                flashPtr = processes[0].MainWindowHandle;
                gui?.SetHandle(flashPtr);
                if (config.AutoConnect)
                {
                    Start();
                }
            }
            // If there are multiple or no clients running, log a message.
            else if (processes.Length > 1)
            {
                Log("Multiple flash players running. Use the /bind command on the client you want to use.");
            }
            else
            {
                Log("Couldn't find flash player. Use the /bind command in game, then start the bot.");
            }

            #region Proxy Hooks
            proxy.HookCommand("bind", ReceiveCommand);
            proxy.HookCommand("start", ReceiveCommand);
            proxy.HookCommand("gui", ReceiveCommand);

            proxy.HookPacket(PacketType.UPDATE, OnUpdate);
            proxy.HookPacket(PacketType.NEWTICK, OnNewTick);
            proxy.HookPacket(PacketType.PLAYERHIT, OnHit);
            proxy.HookPacket(PacketType.MAPINFO, OnMapInfo);
            proxy.HookPacket(PacketType.TEXT, OnText);
            #endregion

            // Runs every time a client connects.
            proxy.ClientConnected += (client) =>
            {
                // Clear all lists and reset keys.
                connectedClient = client;
                targets.Clear();
                playerPositions.Clear();
                enemies.Clear();
                rocks.Clear();
                followTarget = false;
                isInNexus    = false;
                A_PRESSED    = false;
                D_PRESSED    = false;
                W_PRESSED    = false;
                S_PRESSED    = false;
            };

            // Runs every time a client disconnects.
            proxy.ClientDisconnected += (client) =>
            {
                Log("Client disconnected. Waiting a few seconds before trying to press play...");
                PressPlay();
            };

            guiEvent += (evt) =>
            {
                switch (evt)
                {
                case GuiEvent.StartBot:
                    Start();
                    break;

                case GuiEvent.StopBot:
                    Stop();
                    break;

                case GuiEvent.SettingsChanged:
                    config = ConfigManager.GetConfiguration();
                    break;
                }
            };

            // Send an in game message when the gui fires the event.
            sendMessage += (message) =>
            {
                if (!(connectedClient?.Connected ?? false))
                {
                    return;
                }
                PlayerTextPacket packet = (PlayerTextPacket)Packet.Create(PacketType.PLAYERTEXT);
                packet.Text = message;
                connectedClient.SendToServer(packet);
            };
        }
예제 #30
0
 public void PlayerText(RealmTime time, PlayerTextPacket pkt)
 {
     if (pkt.Text[0] == '/')
     {
         string[] x = pkt.Text.Trim().Split(' ');
         try
         {
             AnnounceText = pkt.Text.Substring(10);
             NewsText     = pkt.Text.Substring(6).Split(';');
         }
         catch
         {
             Console.WriteLine("Error at line 24 of Player.Chat.cs");
         }
         ChatMessage = pkt.Text;
         string[] z = pkt.Text.Trim().Split('|');
         y = z.Skip(1).ToArray();
         ProcessCmd(x[0].Trim('/'), x.Skip(1).ToArray());
     }
     else
     {
         if (psr.Account.Admin == true)
         {
             Owner.BroadcastPacket(new TextPacket()
             {
                 Name       = "@" + psr.Account.Name,
                 Stars      = psr.Player.Stars,
                 BubbleTime = 5,
                 Text       = pkt.Text
             }, null);
         }
         else
         {
             int role;
             using (Database db1 = new Database())
             {
                 role = db1.getRole(psr.Account);
             }
             if (role >= (int)Database.Roles.Donator)
             {
                 Owner.BroadcastPacket(new TextPacket()
                 {
                     Name       = "#" + psr.Account.Name,
                     Stars      = psr.Player.Stars,
                     BubbleTime = 5,
                     Text       = pkt.Text
                 }, null);
             }
             else
             {
                 Owner.BroadcastPacket(new TextPacket()
                 {
                     Name       = Name,
                     ObjectId   = Id,
                     Stars      = Stars,
                     BubbleTime = 5,
                     Recipient  = "",
                     Text       = pkt.Text,
                     CleanText  = pkt.Text
                 }, null);
             }
         }
     }
 }