示例#1
0
        public int rightClickToAllFullPositions(String module_name, bool random_sleep = true, int lowest_sleep = 100, int highest_sleep = 200)
        {
            if (!GameStateChecker.getInstance().current_game_state.ingame_flags.isinventoryOpen)
            {
                main.getInstance().writeToLog(module_name, "Can't right click on inventory. Inventory not open!");
                return(-1);
            }

            LockedFastImage l      = new LockedFastImage(Tools.D3ScreenShot());
            int             clicks = 0;

            for (int x = 0; x < 10; x++)
            {
                for (int y = 0; y < 6; y++)
                {
                    Point slot = new Point(x, y);
                    if (isFull(slot, l))
                    {
                        clicks++;
                        rightClickOnSlot(slot, random_sleep, lowest_sleep, highest_sleep);
                    }
                }
            }

            return(clicks);
        }
示例#2
0
        static public GameStateChecker getInstance()
        {
            if (instance == null)
                instance = new GameStateChecker();

            return instance;
        }
示例#3
0
        public GameState openInventory()
        {
            GameState game_state;

            if ((game_state = GameStateChecker.getInstance().current_game_state).ingame_flags.isinventoryOpen)
            {
                return(game_state);
            }

            if (GameStateChecker.getInstance().current_game_state.game_state != GameState.GameStates.InGame)
            {
                game_state.game_state = GameState.GameStates.Unknown;
                return(game_state);
            }

            Tools.clickInventory();

            DateTime start = DateTime.Now;

            for (; !((game_state = new GameState()).ingame_flags.isinventoryOpen);)
            {
                System.Threading.Thread.Sleep(50);

                if ((DateTime.Now - start).TotalMilliseconds >= 2000)
                {
                    game_state.game_state = GameState.GameStates.Unknown;
                    return(game_state);
                }
            }

            return(game_state);
        }
示例#4
0
        public int getNumberOfFreeInventorySlots(String module_name, bool random_sleep = true, int lowest_sleep = 100, int highest_sleep = 200)
        {
            if (!GameStateChecker.getInstance().current_game_state.ingame_flags.isinventoryOpen)
            {
                main.getInstance().writeToLog(module_name, "Can't right click on inventory. Inventory not open!");
                return(-1);
            }

            LockedFastImage l     = new LockedFastImage(Tools.D3ScreenShot());
            int             count = 0;

            for (int x = 0; x < 10; x++)
            {
                for (int y = 0; y < 6; y++)
                {
                    Point slot = new Point(x, y);
                    if (isFull(slot, l))
                    {
                        count++;
                    }
                }
            }

            return(slot_number - count);
        }
示例#5
0
        public int getGold(String module_name)
        {
            GameState game_state = GameStateChecker.getInstance().current_game_state;

            if (game_state.game_state != GameState.GameStates.InGame || game_state.ingame_flags.isDead)
            {
                return(-1);
            }

            if (game_state.ingame_flags.isinventoryOpen)
            {
                return(readGoldFromInventory(module_name, game_state));
            }

            if ((game_state = openInventory()).game_state != GameState.GameStates.Unknown)
            {
                int ret = readGoldFromInventory(module_name, game_state);
                closeInventory();
                return(ret);
            }
            else
            {
                return(-1);
            }
        }
        static public GameStateChecker getInstance()
        {
            if (instance == null)
            {
                instance = new GameStateChecker();
            }

            return(instance);
        }
示例#7
0
 private void c_stateChecker_CheckedChanged(object sender, EventArgs e)
 {
     if (c_stateChecker.Checked)
     {
         GameStateChecker.getInstance().start();
     }
     else
     {
         l_gamestate.Text = "";
         GameStateChecker.getInstance().stop();
     }
 }
示例#8
0
        static public bool sendString(String txt, bool secure_writing)
        {
            System.Threading.Thread.Sleep(50);

            foreach (char key_char in txt)
            {
                if (secure_writing && !(GameStateChecker.getInstance().current_game_state.game_state == GameState.GameStates.LoginScreen && GetActiveWindowTitle() == "Diablo III"))
                {
                    return(false);
                }
                PressKey(ConvertCharToVirtualKey(key_char), false);
            }
            return(true);
        }
示例#9
0
        protected override void storeRoute(ref Random rnd, int run_number)
        {
            if (!GameStateChecker.getInstance().current_game_state.ingame_flags.inTown)
            {
                return;
            }

            run_was = possibleRuns.invalid;
            Tools.LeftClick(rnd.Next(452, 480), rnd.Next(150, 185), true, 100, 200, true);

            //3 sec max waiting for stash open
            TimeSpan max   = new TimeSpan(0, 0, 3);
            DateTime start = DateTime.Now;

            for (int i = 0; !GameStateChecker.getInstance().current_game_state.ingame_flags.isStashOpen; i++)
            {
                if (DateTime.Now - start >= max)
                {
                    return;
                }

                System.Threading.Thread.Sleep(500);
            }
            int free_slots = 0;

            if ((free_slots = D3InventoryStuff.getInstance().getNumberOfFreeInventorySlots(module_name, false)) <= 20)
            {
                int clicks = D3InventoryStuff.getInstance().rightClickToAllFullPositions(module_name);
                writeToMainLog(free_slots + " free slots were left. Stored items to stash with " + clicks + " clicks at inventory.");
                finished_store_runs++;
                this.free_slots = D3InventoryStuff.getInstance().getNumberOfFreeInventorySlots(module_name, true);
            }
            else
            {
                this.free_slots = free_slots;
            }

            return;
        }
示例#10
0
        static public bool launchDiablo3(String module_name)
        {
            if (!main.getInstance().validD3Path())
            {
                main.getInstance().writeToLog(module_name, "Can't start Diablo 3! (No valid exe path)");
                return(false);
            }

            System.Diagnostics.Process.Start(main.getInstance().getD3Exepath(), "-launch");

            int max_seconds = main.getInstance().getMaxLaunchWaittime();

            for (int i = 0; i < max_seconds; i++)
            {
                System.Threading.Thread.Sleep(1000);

                try
                {
                    D3Stuff.getInstance().init(true);
                }
                catch { continue; }

                if (D3Stuff.getInstance().getD3WinHandle() != new IntPtr(0))
                {
                    SetWindowPos(D3Stuff.getInstance().getD3WinHandle(), 0, 0, 0, 0, 0, SWP_NOSIZE);
                }

                if (GameStateChecker.getInstance().current_game_state.game_state == GameState.GameStates.LoginScreen)
                {
                    main.getInstance().writeToLog(module_name, "Diablo 3 started!");
                    return(true);
                }
            }

            main.getInstance().writeToLog(module_name, "Can't start Diablo 3! (Was waiting " + max_seconds + " seconds)");
            return(false);
        }
示例#11
0
        protected override bool route(ref Random rnd, int run_time, int run_number)
        {
            DateTime start = DateTime.Now;

            farmRoute(ref rnd, run_time, run_number);

            TimeSpan run_lasted = DateTime.Now - start;

            switch (run_was)
            {
            case possibleRuns.closed:
                time_closed_runs += run_lasted;
                break;

            case possibleRuns.open:
                time_open_runs += run_lasted;
                break;

            case possibleRuns.rep:
                time_rep_runs += run_lasted;
                break;
            }

            if (GameStateChecker.getInstance().current_game_state.ingame_flags.inTown)
            {
                if (main.getInstance().getAutoRep() && GameStateChecker.getInstance().current_game_state.ingame_flags.needRep)
                {
                    writeToMainLog("Going to repair at run " + run_number + "!");
                    repRoute(ref rnd, run_time);
                }
            }

            updateAtmain(run_number);

            return(true);
        }
示例#12
0
        static public bool portToTown(ref Random rnd, string module_name)
        {
            Tools.clickPortal();

            TimeSpan max   = new TimeSpan(0, 0, 10);
            DateTime start = DateTime.Now;

            for (; GameStateChecker.getInstance().current_game_state.ingame_flags.inTown == false;)
            {
                System.Threading.Thread.Sleep(500);

                if (DateTime.Now - start >= max)
                {
                    main.getInstance().writeToLog(module_name, "Port to town failed!");
                    return(false);
                }
                if (GameStateChecker.getInstance().current_game_state.ingame_flags.isDead)
                {
                    main.getInstance().writeToLog(module_name, "Dead!");
                    return(false);
                }
            }
            return(true);
        }
示例#13
0
        private void closeGame(ref Random rnd)
        {
            if (GameStateChecker.getInstance().current_game_state.game_state != GameState.GameStates.DisconnectDienst)
            {
                if (!(GameStateChecker.getInstance().current_game_state.game_state == GameState.GameStates.InGame))
                {
                    return;
                }

                //ESC click
                Tools.LeftClick(rnd.Next(567, 576), rnd.Next(589, 610), true, 500, 800);
                Tools.LeftClick(rnd.Next(340, 471), rnd.Next(344, 351), true, 300, 400);

                TimeSpan max   = new TimeSpan(0, 0, 13);
                DateTime start = DateTime.Now;
                while (true)
                {
                    System.Threading.Thread.Sleep(300);
                    if (GameStateChecker.getInstance().current_game_state.game_state == GameState.GameStates.CharScreen_RedEnterGameButton)
                    {
                        return;
                    }

                    if (DateTime.Now - start >= max)
                    {
                        break;
                    }
                }
            }

            //got a disconnect press 2 times enter to come to login screen
            writeToMainLog("Got a disconnect!");
            Tools.PressKey(Keys.Enter);
            Tools.PressKey(Keys.Enter, true, 5000, 5500);
            return;
        }
示例#14
0
        private bool openGame(ref Random rnd, int run_counter)
        {
            int max_d3_restarts = main.getInstance().getMaxRestarts();
            int restarts        = 0;

            int  invalid_state         = 50;
            int  invalid_state_counter = 0;
            bool game_is_open          = false;

            while (!game_is_open)
            {
                System.Threading.Thread.Sleep(300);

                if (!running)
                {
                    emergencyStop("Stopped at run " + run_counter + "/" + maximum_runs + "!", run_counter);
                    return(false);
                }

                switch (GameStateChecker.getInstance().current_game_state.game_state)
                {
                case GameState.GameStates.D3NotLoaded:
                    writeToMainLog("Starting Diablo3");
                    Tools.restartDiablo3(module_name);
                    break;

                case GameState.GameStates.InGame:
                    game_is_open = true;
                    break;

                case GameState.GameStates.LoginScreen:
                    if (!Tools.login(module_name, main.getInstance().getLoginTrys()))
                    {
                        if (main.getInstance().getPW() == "")
                        {
                            emergencyStop("Stopped at run " + run_counter + "/" + maximum_runs + "! (No password for reconnect!)", run_counter);
                            return(false);
                        }

                        writeToMainLog("Failed to reconnect.");

                        //this is not nessesary if we dont jump to default
                        invalid_state_counter = invalid_state;     // this will force a restart
                        //goto default;
                    }
                    else
                    {
                        invalid_state_counter = 0;
                        restarts = 0;
                        continue;
                    }
                    break;

                case GameState.GameStates.CharScreen_RedEnterGameButton:
                    //spiel fortführen click
                    Tools.LeftClick(rnd.Next(68, 203), rnd.Next(253, 272));
                    invalid_state_counter = 0;
                    break;

                case GameState.GameStates.CharScreen_GrayEnterGameButton:
                    invalid_state_counter = 0;
                    break;

                case GameState.GameStates.DisconnectDienst:
                    //ok klick
                    Tools.LeftClick(rnd.Next(371, 440), rnd.Next(375, 389));
                    invalid_state_counter = 0;
                    break;

                case GameState.GameStates.LoadingScreen:
                    invalid_state_counter = 0;
                    break;

                default:
                    if (invalid_state_counter >= invalid_state)
                    {
                        if (!main.getInstance().validD3Path())
                        {
                            emergencyStop("Stopped at run " + run_counter + "/" + maximum_runs + "! (Too much invalid states)", run_counter);
                            return(false);
                        }

                        if (restarts >= max_d3_restarts)
                        {
                            emergencyStop("Stopped at run " + run_counter + "/" + maximum_runs + "! (Did " + restarts + "/" + max_d3_restarts + " restarts)", run_counter);
                            return(false);
                        }

                        writeToMainLog("Restarting D3 at run " + run_counter + "/" + maximum_runs + "! (" + (restarts + 1) + "/" + max_d3_restarts + " restarts)");
                        Tools.restartDiablo3(module_name);

                        invalid_state_counter = 0;
                        restarts++;
                    }
                    invalid_state_counter++;
                    if (invalid_state_counter % 10 == 0)
                    {
                        writeToMainLog(invalid_state_counter + "/" + invalid_state + " invalid states at open game!");
                    }
                    break;
                }
            }

            return(true);
        }
示例#15
0
        private void main_Load(object sender, EventArgs e)
        {
            PixelColors.getinstance();
            GameStateChecker.getInstance().start();

            writeToLog(module_name, D3Stuff.getInstance().getModuleName() + " loaded!");

            //load bot options
            MyXML xml = new MyXML(config_path);

            try
            {
                n_restart_delay.Value = Convert.ToDecimal(xml.read(restart_delay));
            }
            catch { }

            try
            {
                n_max_waittime.Value = Convert.ToDecimal(xml.read(max_waittime));
            }
            catch { }
            try
            {
                n_max_d3_restarts.Value = Convert.ToDecimal(xml.read(max_restarts));
            }
            catch { }

            try
            {
                n_start_delay.Value = Convert.ToDecimal(xml.read(start_delay));
            }
            catch { }
            try
            {
                n_login_trys.Value = Convert.ToDecimal(xml.read(login_trys));
            }
            catch { }
            try
            {
                c_demonHunter.Checked = Convert.ToBoolean(xml.read(demon_hunter));
            }
            catch { }
            try
            {
                c_remember_pass.Checked = Convert.ToBoolean(xml.read(remember_pass));
                if (c_remember_pass.Checked)
                {
                    String dec_pass = xml.read(encrypted_pass);

                    for (int i = 0; i < enc_times; i++)
                    {
                        dec_pass = Cypher.Decrypt(dec_pass);
                    }

                    t_pw.Text = dec_pass;
                }
            }
            catch { }
            try
            {
                Tools.adjust_bot_point.X = Convert.ToInt32(xml.read(adjust_point_x));
                Tools.adjust_bot_point.Y = Convert.ToInt32(xml.read(adjust_point_y));
            }
            catch { }

            //inithealthBot();
            try
            {
                D3InventoryStuff.getInstance();
            }
            catch (Exception ex) { MessageBox.Show(ex.Message); }

            initHailiesBot();
            initNxtBot();
            initLoginBot();

            lvlBot = new B_levelBot();

            r_log.Text += "------------------------------" + Environment.NewLine;

            r_log.SelectionStart = r_log.Text.Length;
            r_log.ScrollToCaret();

            finished_init = true;

            try
            {
                if (xml.read("first_start") == "")
                {
                    MessageBox.Show("You are using this tool for the first time. Please adjust the bots with the \"" + b_adjust_bot.Text + "\" button.");
                    xml.write("first_start", "!");
                }
            }
            catch { }
        }
示例#16
0
        static public bool login(String module_name, int max_trys, bool loginBot = false)
        {
            String pw = main.getInstance().getPW();

            if (pw == "")
            {
                main.getInstance().writeToLog(module_name, "No login password.");
                return(false);
            }

            int trys_counter          = 0;
            int max_invalid_states    = 10; //10 sek invalid
            int invalid_state_counter = 0;

            while ((!loginBot && trys_counter < max_trys) || (loginBot && main.getInstance().isLoginBotChecked()))
            {
                if (GameStateChecker.getInstance().current_game_state.game_state == GameState.GameStates.CharScreen_RedEnterGameButton)
                {
                    return(true);
                }

                if (GameStateChecker.getInstance().current_game_state.game_state != GameState.GameStates.LoginScreen)
                {
                    invalid_state_counter++;
                    if (invalid_state_counter >= max_invalid_states)
                    {
                        break;
                    }

                    System.Threading.Thread.Sleep(1000);
                    continue;
                }

                invalid_state_counter = 0;

                trys_counter++;
                if (loginBot)
                {
                    main.getInstance().writeToLog(module_name, "Login " + trys_counter + ".");
                }
                else
                {
                    main.getInstance().writeToLog(module_name, "Login " + trys_counter + "/" + max_trys + ".");
                }
                //click on pw field
                LeftClick(409, 423);
                if (sendString(pw, true) == false)
                {
                    return(false);
                }

                PressKey(Keys.Enter);

                do
                {
                    System.Threading.Thread.Sleep(1000);
                } while (GameStateChecker.getInstance().current_game_state.game_state == GameState.GameStates.LoginLoading);

                System.Threading.Thread.Sleep(1000);
                if (GameStateChecker.getInstance().current_game_state.game_state == GameState.GameStates.CharScreen_RedEnterGameButton)
                {
                    return(true);
                }

                PressKey(Keys.Enter);
            }

            return(false);
        }
示例#17
0
 private void B_BaseBot_stateChangedEvent(GameStateChecker game_state_checker, GameStateChangedEventArgs e)
 {
     writeToMainLog("Saw a change from <" + e.OldState.ToStringOneLine() + "> to <" + e.NewState.ToStringOneLine() + ">");
 }
示例#18
0
 private void B_BaseBot_stateChangedEvent(GameStateChecker game_state_checker, GameStateChangedEventArgs e)
 {
     writeToMainLog("Saw a change from <" + e.OldState.ToStringOneLine() + "> to <" + e.NewState.ToStringOneLine() + ">");
 }
        protected override bool route(ref Random rnd, int run_time, int run_number)
        {
            int speed      = 600;
            int run_mult   = 5;
            int run_mult_2 = 4;

            Tools.clickSkill2();
            Tools.clickSkill3();

            Tools.middleClick(rnd.Next(58, 62), rnd.Next(108, 112), false);
            for (int i = 0; i < 2; i++)
            {
                Tools.middleClick(rnd.Next(58, 62), rnd.Next(108, 112), true, speed * run_mult, speed * run_mult);
            }

            //enter mennor
            Tools.LeftClick(rnd.Next(408, 412), rnd.Next(258, 262), true, speed * run_mult, speed * run_mult, true);


            System.Threading.Thread.Sleep(1000);

            Tools.middleClick(rnd.Next(146, 150), rnd.Next(111, 115), false);
            Tools.middleClick(rnd.Next(146, 150), rnd.Next(111, 115), true, speed * run_mult_2, speed * run_mult_2);

            Point cursor = Tools.rightClickHold(rnd.Next(176, 180), rnd.Next(141, 145), true, speed * run_mult_2, speed * run_mult_2);

            //we will attack 4 seconds... without checks
            System.Threading.Thread.Sleep(4000);

            TimeSpan max   = new TimeSpan(0, 0, 60);
            DateTime start = DateTime.Now;

            for (int no_enemy_counter = 0; no_enemy_counter < 5;)
            {
                System.Threading.Thread.Sleep(100);
                if (!isEnemy())
                {
                    no_enemy_counter++;
                }
                else
                {
                    no_enemy_counter = 0;
                }

                if (DateTime.Now - start >= max)
                {
                    break;
                }
            }
            Tools.rightClickHoldOff(cursor.X, cursor.Y, false);

            Tools.clickSkill2();
            System.Threading.Thread.Sleep(1000);
            Tools.portToTown(ref rnd, module_name);

            if (GameStateChecker.getInstance().current_game_state.ingame_flags.inTown)
            {
                if (main.getInstance().getAutoRep() && GameStateChecker.getInstance().current_game_state.ingame_flags.needRep)
                {
                    writeToMainLog("Going to repair at run " + run_number + "!");
                    repRoute(ref rnd, run_time);
                }
            }

            return(true);
        }