Exemplo n.º 1
0
 private static void ConnectionThread()
 {
     try
     {
         DateTime dateTime_ = DateTime.Now;
         while (true)
         {
             TimeSpan ts = (DateTime.Now - Client.lastPacket);
             if (!Server.IsConnected() || ts.TotalSeconds > 70.0)
             {
                 BotSession.Sessionreconnects++;
                 break;
             }
             TimeSpan ts2 = (DateTime.Now - dateTime_);
             if (ts2.TotalMinutes >= 1.0)
             {
                 GC.Collect();
                 GC.WaitForPendingFinalizers();
                 HelpTools.ClearMemory(HelpTools.GetCurrentProcess());
                 dateTime_ = DateTime.Now;
             }
             TimeSpan ts3 = (DateTime.Now - BotSession.dailyQuestFinishTime);
             if (ts3.TotalHours >= 24 && ts3.TotalMinutes >= 1 && ts3.TotalSeconds >= 1 && !BotSession.Sessioncandodailyquest)
             {
                 BotSession.Sessioncandodailyquest = true;
             }
             Thread.Sleep(1000);
         }
         Thread.Sleep(2000);
         Bot.Running = false;
         if (Server._targetSocket != null && Server._targetSocket.Connected)
         {
             Server._targetSocket.Close();
         }
         if (Bot.Running)
         {
             BotLogic.StopBotThread();
         }
         if (BotLogic.OnAttackRunning)
         {
             BotLogic.StoponAttackThrad();
         }
         Server.Connected = false;
         if (BotSettings.tasksDoneLogout && TaskSystem.TasksSystem.LogginOut)
         {
             return;
         }
         BotSession.lostConnection = true;
     }
     catch (Exception ex)
     {
         BotMethods.WriteLine("There was an error in the connection-Thread!\n\n" + ex.Message);
         ConnectionThread();
         return;
     }
 }
Exemplo n.º 2
0
 public void Start()
 {
     try
     {
         Server.Local = new IPEndPoint(IPAddress.Parse("127.0.0.1"), Server.LocalPort);
         _mainSocket.Bind(Local);
         _mainSocket.Listen(10);
         while (true)
         {
             var source      = _mainSocket.Accept();
             var destination = new Server();
             _targetSocket = destination._mainSocket;
             var state = new State(source, destination._mainSocket);
             destination.Connect(Remote, source);
             source.BeginReceive(state.Buffer, 0, state.Buffer.Length, 0, OnDataReceive, state);
         }
     }
     catch (Exception ex)
     {
         if (ex is SocketException && (ex as SocketException).SocketErrorCode == SocketError.AddressAlreadyInUse)
         {
             Server.LocalPort++;
             Server.FiddlerPort++;
             this.Start();
         }
         BotMethods.WriteLine(ex.ToString());
         BotMethods.WriteLine(string.Join("", new string[]
         {
             HelpTools.FromByteToString(80),
             HelpTools.FromByteToString(114),
             HelpTools.FromByteToString(111),
             HelpTools.FromByteToString(120),
             HelpTools.FromByteToString(121),
             HelpTools.FromByteToString(32),
             HelpTools.FromByteToString(99),
             HelpTools.FromByteToString(108),
             HelpTools.FromByteToString(111),
             HelpTools.FromByteToString(115),
             HelpTools.FromByteToString(101),
             HelpTools.FromByteToString(100),
             HelpTools.FromByteToString(46)
         }));
         Form1.form1.StartLocalProxy();
         BotSession.lostConnection = true;
     }
 }
Exemplo n.º 3
0
        private static void OnDataReceive(IAsyncResult result)
        {
            var state = (State)result.AsyncState;

            try
            {
                var bytesRead = state.SourceSocket.EndReceive(result);
                if (bytesRead > 0)
                {
                    var buffer = new byte[bytesRead];
                    Array.Copy(state.Buffer, buffer, bytesRead);
                    if (state.SourceSocket.RemoteEndPoint.ToString().Equals(Remote.ToString()))
                    {
                        Client.Read(buffer);
                        if (!Server.Connected && Account.gClass.entityInfo != null)
                        {
                            Server.Connected    = true;
                            BotSession.logginIn = false;
                            BotMethods.WriteLine("Map Loaded.");
                            BotCalculator.StartThreads();
                        }
                    }
                    if (state.DestinationSocket.RemoteEndPoint.ToString().Equals(Remote.ToString()))
                    {
                        //Client.Out(buffer);
                    }
                    state.DestinationSocket.Send(buffer, buffer.Length, SocketFlags.None);
                    state.SourceSocket.BeginReceive(state.Buffer, 0, state.Buffer.Length, 0, OnDataReceive, state);
                }
            }
            catch
            {
                state.DestinationSocket.Close();
                state.SourceSocket.Close();
            }
        }
Exemplo n.º 4
0
        public static string MessageHandler(string Message, List <string> Args)
        {
            int value = 0;

            try
            {
                switch (Message)
                {
                case "warmap:boxelp":
                    value = help.ToInt(Args.First());
                    BotSession.Sessionelps += value;
                    return($"Received {value}x ELP.");

                case "warmap:boxplate":
                    value = help.ToInt(Args.First());
                    BotSession.Sessionplates += value;
                    return($"Received {value}x Armor Plate(s).");

                case "warmap:boxpwoder":
                    value = help.ToInt(Args.First());
                    BotSession.Sessionpowder += value;
                    return($"Received {value}x Gun Powder.");

                case "warmap:boxpearls":
                    value = help.ToInt(Args.First());
                    BotSession.Sessionpearls += value;
                    return($"Received {value}x Pearl(s).");

                case "warmap:boxadmiralpoints":
                    value = help.ToInt(Args.First());
                    return($"Received {value}x Admiral Point(s).");

                case "warmap:reward":
                    value = help.ToInt(Args.First());
                    if (Args.Contains("labels!ActionItems!1"))
                    {
                        BotSession.Sessionpowder += value;
                        return($"Received {value}x Gun Powder.");
                    }
                    else
                    if (Args.Contains("labels!ActionItems!2"))
                    {
                        BotSession.Sessionplates += value;
                        return($"Received {value}x Armor Plate(s).");
                    }
                    else
                    if (Args.Contains("labels!Currency!1"))
                    {
                        BotSession.Sessiongold += value;
                        return($"Received {value}x Gold.");
                    }
                    else
                    if (Args.Contains("labels!Currency!2"))
                    {
                        BotSession.Sessionpearls += value;
                        return($"Received {value}x Pearls.");
                    }
                    else
                    if (Args.Contains("labels!Currency!3"))
                    {
                        BotSession.Sessionmojos += value;
                        return($"Received {value}x Mojo(s).");
                    }
                    else
                    if (Args.Contains("labels!Currency!4"))
                    {
                        BotSession.Sessioncrystals += value;
                        return($"Received {value}x Crystal(s).");
                    }
                    else
                    if (Args.Contains("labels!Currency!8"))
                    {
                        BotSession.Sessioncursedsouls += value;
                        return($"Received {value}x Cursed Soul(s).");
                    }
                    else
                    if (Args.Contains("labels!Currency!9"))
                    {
                        BotSession.Sessionradiantsouls += value;
                        return($"Received {value}x Radiant Soul(s).");
                    }
                    else
                    if (Args.Contains("labels!Currency!13"))
                    {
                        BotSession.Sessioncrowns += value;
                        return($"Received {value}x Crown(s).");
                    }
                    else
                    if (string.Join("", Args).Contains("labels!Harpoons"))
                    {
                        var fullArgs = string.Join("", Args);
                        if (fullArgs.Contains("76"))
                        {
                            return($"Received {value}x Steel Harpoons.");
                        }
                        else
                        if (fullArgs.Contains("75"))
                        {
                            return($"Received {value}x Iron Harpoons.");
                        }
                        else
                        if (fullArgs.Contains("20"))
                        {
                            return($"Received {value}x Bronze Harpoons.");
                        }
                        else
                        if (fullArgs.Contains("19"))
                        {
                            return($"Received {value}x Lead Harpoons.");
                        }
                        else
                        if (fullArgs.Contains("18"))
                        {
                            return($"Received {value}x Copper Harpoons.");
                        }
                    }
                    else
                    if (string.Join("", Args).Contains("labels!Ammunition"))
                    {
                        return($"Received {value}x Ammunition.");
                    }
                    return($"Received {value}x Unkown Item(s).");

                case "warmap:boxhitpoints":
                    value = help.ToInt(Args.First());
                    BotSession.Sessionhp += value;
                    return($"Received {value}x HitPoint(s).");

                case "warmap:boxtrap":
                    value = help.ToInt(Args.First());
                    BotSession.Sessionhp -= value;
                    return($"- {value}x HitPoint(s).");

                case "warmap:boxspeed":
                    value = help.ToInt(Args.First());
                    return($"Received {value}x Speed Point(s).");

                case "warmap:boxeuro":
                    value = help.ToInt(Args.First());
                    return($"Received {value}x JackPot Dollar(s).");

                case "warmap:boxep":
                    value = help.ToInt(Args.First());
                    BotSession.Sessionxp += value;
                    return($"Received {value}x XP.");

                case "warmap:boxmojo":
                    value = help.ToInt(Args.First());
                    BotSession.Sessionmojos += value;
                    return($"Received {value}x Mojo(s).");

                case "warmap:boxvoodoopoints":
                    value = help.ToInt(Args.First());
                    BotSession.Sessionhp += value;
                    return($"Received {value}x Voodoopoint(s).");

                case "warmap:notreasurechestkey":
                    if (!Bot.targetentityId.entityId.Equals(0.0) && Client.Entitys.ContainsKey(Bot.targetentityId.entityId))
                    {
                        var box = (Client.Entitys[Bot.targetentityId.entityId] as BoxInitMessage);
                        if (box.type == 5 || box.type == 15)
                        {
                            BotSettings.collectchests      &= box.type != 5;
                            BotSettings.collecteventchests &= box.type != 15;
                        }
                        else
                        {
                            BotSettings.collectchests      = false;
                            BotSettings.collecteventchests = false;
                        }
                        Bot.targetentityId = new Seafight.Messages.EntityInfo(0, 0);
                    }
                    return("No Treasure Chest Keys left.");

                case "raidmap_behemoth_start":
                    Account.Joining = true;
                    return("Joining Raid Map!");

                case "warmap:actionitemused2":
                    Account.Joining = true;
                    return("Teleporting!");

                case "warmap:actioncancelled":
                    if (Account.Joining)
                    {
                        Account.Joining = false;
                    }
                    return("Join Canceld!");

                case "warmap:actionitemDisabledBattle":
                    if (Account.Joining)
                    {
                        Account.Joining = false;
                        var point = Bot.MoveToCorner();
                        BotMethods.MoveTo(point.X, point.Y);
                    }
                    break;

                case "warmap:actionitemDisabled":
                    if (Account.Joining)
                    {
                        Account.Joining = false;
                    }
                    break;

                case "vodoo_scroll_start":
                    Account.Joining = true;
                    return($"Joining {(BotSettings.lastBM.Replace("Map", "").Replace(" ", ""))} Bonus Map!");

                case "vodoo_scroll_forbidden":
                    if (Account.Joining)
                    {
                        Account.Joining = false;
                        var map_ = Account.BonusMaps.Values.FirstOrDefault(bm => bm.mapName == BotSettings.lastBM);
                        if (map_ != null)
                        {
                            Account.BonusMaps.Remove(map_.mapId);
                        }
                    }
                    break;

                case "vodoo_wave_destroy":
                    value = help.ToInt(Args.First());
                    BotSession.Sessionwaves++;
                    if (BotSettings.leaveBM)
                    {
                        BotSettings.canLeaveBM = true;
                    }
                    return($"Bonus Map Wave {value} done!");

                case "warmap:killvoodoo":
                    value = help.ToInt(Args.First());
                    BotSession.Sessionbmnpcs++;
                    return($"NPC from attack wave {value} sunk!");

                case "vodoo_wave_arrive":
                    value = help.ToInt(Args.First());
                    return($"Bonus Map Wave {value} arrived!");

                case "vodoo_wave_last":
                    BotSession.Sessionbms++;
                    return("Bonus Map Finished!");

                case "warmap:bonusmapreward":
                    value = help.ToInt(Args.First());
                    return($"Received {MapHandler(value)}");

                case "warmap:bonusmapwavepearls":
                    value = help.ToInt(Args.First());
                    BotSession.Sessionpearls += value;
                    return($"Received {value}x Pearls.");

                case "warmap:youropponentusersunk":
                    BotSettings.underAttack = false;
                    BotSession.Sessiondestroyedplayer++;
                    return("Successfully destroyed Opponent.");

                case "warmap:boardinghpthreshold":
                    if (!Bot.targetentityId.entityId.Equals(0.0) && Client.Entitys.ContainsKey(Bot.targetentityId.entityId) && Client.Entitys[Bot.targetentityId.entityId] is ShipInitMessage)
                    {
                        (Client.Entitys[Bot.targetentityId.entityId] as ShipInitMessage).boarded = false;
                    }
                    break;

                case "warmap:boardingattacked":
                    if (!Bot.targetentityId.entityId.Equals(0.0) && Client.Entitys.ContainsKey(Bot.targetentityId.entityId) && Client.Entitys[Bot.targetentityId.entityId] is ShipInitMessage)
                    {
                        (Client.Entitys[Bot.targetentityId.entityId] as ShipInitMessage).boarded = true;
                        return($"Boarded {(Client.Entitys[Bot.targetentityId.entityId] as ShipInitMessage).name}[{Bot.targetentityId.entityId}]");
                    }
                    break;

                case "warmap:nocollectwithtortuga":
                    BotSettings.collectGlitters = false;
                    return("Can NOT collect glitters while under Tortuga's light!");

                case "warmap:pickuprestriction":
                    BotSettings.collectGlitters = false;
                    return("Can't collect glitters in this map");

                case "warmap:nomapchange":
                    Account.NextMapID = -800;
                    return("warmap:nomapchange");
                }
            }
            catch (Exception)
            {
            }
            return(Message);
        }