Ejemplo n.º 1
0
        /// <summary>
        /// Click down and release a mouse button
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="clickTypeDown"></param>
        /// <param name="clickTypeUp"></param>
        private static Point Click(int x, int y, int clickTypeDown, int clickTypeUp, int hoverDelay, int randomize)
        {
            Random rng        = new Random();
            Point  clickPoint = Probability.GaussianCircle(new Point(x, y), 0.35 * randomize, 0, 360, randomize);

            x = clickPoint.X;
            y = clickPoint.Y;

            ScreenScraper.BringToForeGround();
            ScreenScraper.GameScreenToWindow(ref x, ref y);
            if (BotProgram.StopFlag)
            {
                return(new Point(0, 0));
            }
            NaturalMove(x, y);

            BotProgram.SafeWaitPlus(hoverDelay, 0.25 * hoverDelay);  //wait for RS client to recognize the cursor hover
            if (!BotProgram.StopFlag)
            {
                mouse_event(clickTypeDown, x, y, 0, 0);
                mouse_event(clickTypeUp, x, y, 0, 0);
            }

            return(clickPoint);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Starts the chosen bot program
 /// </summary>
 /// <param name="botProgram">bot program to start</param>
 private void RunBotProgram(Button startButton)
 {
     CollectStartParams();
     RunningBot = BotRegistry.GetSelectedBot(RunParams, RunParams.BotManager);
     SetActiveState(startButton);
     RunningBot.Start();
     UpdateTimer.Enabled = true;
 }
        public MainWindow()
        {
            InitializeComponent();
            BotProgram.UploadCommands(BasicCommands.GetBasicCommands());
            Menu menuWindow = new Menu();

            Close();
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Teleports the player to the configured location.
 /// </summary>
 public void Teleport(bool waitForTeleport)
 {
     Mouse.LeftClick(TeleportButton.X, TeleportButton.Y, 8);
     if (waitForTeleport)
     {
         BotProgram.SafeWait(2000);
     }
 }
Ejemplo n.º 5
0
        public BotProgram Optimize(Model3D modelToBuild)
        {
            _scene         = Scene.New(modelToBuild.Resolution);
            _program       = new BotProgram();
            _voxelsToFill  = modelToBuild.NumberOfFullVoxels();
            _currentYLevel = 0;
            _model         = modelToBuild;

            OptimizeInternal();

            return(_program);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Use the Make-X option in a Make-X pop-up
        /// </summary>
        public void MakeXItems(int itemsToMake)
        {
            const int yOffset = 70;

            SelectOption(yOffset);

            //Wait for the "Enter amount:" prompt to appear
            if (WaitForEnterAmount(5000))
            {
                BotProgram.SafeWaitPlus(200, 50);
                BotUtilities.EnterAmount(Keyboard, itemsToMake);
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Logs in to for the selected bot on a rotation tab
        /// </summary>
        /// <param name="rotationList">rotation tab to use</param>
        /// <param name="botSelection">selected bot on the rotation tab</param>
        /// <param name="startButton">reference to the start button used for this tab</param>
        private void RotationLogIn(RunParamsList rotationList, int botSelection, Button startButton)
        {
            CollectStartParams();
            if (rotationList == null || !Numerical.WithinBounds(botSelection, 0, RunParams.PhasmatysParams.Count - 1))
            {
                return;
            }

            rotationList[botSelection].TaskComplete = new BotResponse(BotDone);
            RunningBot = new LogInToGame(rotationList[botSelection]);
            RunningBot.Start();
            SetActiveState(startButton);
            UpdateTimer.Enabled = true;
        }
Ejemplo n.º 8
0
        public BotProgram Optimize(Model3D modelToBuild)
        {
            _modelToBuild      = modelToBuild;
            _treeToConstruct   = _modelToBuild.ToOctoTree();
            _scene             = Scene.New(_modelToBuild.Resolution);
            _program           = new BotProgram();
            _resolution        = _modelToBuild.Resolution;
            _resolutionSquared = _resolution * _resolution;
            _dsu          = new DSU(_resolutionSquared * _resolution + 1);
            _voxelsFilled = 0;

            // Console.WriteLine("Starting to optimize...");

            OptimizeInternal();

            return(_program);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Sets up the Start form for the idle state
        /// </summary>
        private void SetIdleState()
        {
            RunningBot           = null;
            BotIsRunning         = false;
            Text                 = FORM_NAME;
            RunParams.BotManager = BotRegistry.BotManager.None;
            StatusMessage.Text   = "";
            PhasmatysStatus.Text = "";

            foreach (Button button in StartButtons)
            {
                button.Text      = "Start";
                button.BackColor = ColorTranslator.FromHtml("#527E3F");
                button.Enabled   = true;
            }

            BringToFront();
            WindowState = FormWindowState.Normal;
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Waits for the right-click popup to appear
        /// </summary>
        /// <param name="timeout"></param>
        /// <returns></returns>
        public virtual bool WaitForPopup(int timeout = 3000, CheckHeight checkHeight = CheckHeight.None)
        {
            Color[,] screen = null;
            Stopwatch watch = new Stopwatch();

            watch.Start();
            while (watch.ElapsedMilliseconds < timeout)
            {
                if (BotProgram.SafeWait(200))
                {
                    return(false);
                }
                screen = ScreenScraper.GetRGB(ScreenScraper.CaptureWindow());
                if (PopupExists(screen) && PopupIsCorrectHeight(screen, checkHeight))
                {
                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Opens the Withdraw-X menu for a specified bank slot and clicks on the specified withdraw option
        /// </summary>
        /// <param name="column"></param>
        /// <param name="row"></param>
        /// <param name="yOffset"></param>
        public void WithdrawMenuClick(int column, int row, int yOffset)
        {
            Point?itemSlot = ItemSlotLocation(column, row);

            if (itemSlot == null)
            {
                return;
            }

            //open the withdraw right-click menu
            Point click = Probability.GaussianCircle(new Point(itemSlot.Value.X, itemSlot.Value.Y), 4, 0, 360, 11);

            Mouse.RightClick(click.X, click.Y);
            BotProgram.SafeWaitPlus(200, 100);
            RightClick menu = new RightClick(click.X, click.Y, RSClient, 9);

            menu.WaitForPopup();

            //click on Withdraw-All
            click = Probability.GaussianRectangle(click.X - 90, click.X + 90, click.Y + yOffset - 2, click.Y + yOffset + 2);
            Mouse.LeftClick(click.X, click.Y);
            BotProgram.SafeWaitPlus(200, 100);
        }
Ejemplo n.º 12
0
 /// <summary>
 /// Holds a key down for a set time.
 /// </summary>
 /// <param name="key">System.Windows.Forms.Keys to specify a key to hold down.</param>
 /// <param name="milliseconds">Number of milliseconds to hold down the key.</param>
 public void HoldKey(Keys key, int milliseconds)
 {
     keybd_event((byte)key, 0, KEY_DOWN_EVENT, 0);
     BotProgram.SafeWait(milliseconds);
     keybd_event((byte)key, 0, KEY_UP_EVENT, 0);
 }
Ejemplo n.º 13
0
 /// <summary>
 /// Goes through the dialog with the dark mage to repair runecrafting pouches
 /// </summary>
 /// <returns>true if successful</returns>
 public bool RepairPouches(TextBoxTool textBox)
 {
     Mouse.LeftClick(Left + 240, Top + 102, 10);
     BotProgram.SafeWait(NPC_CONTACT_CAST_TIME);
     return(textBox.ClickThroughTextScreens(4, 5000));
 }
Ejemplo n.º 14
0
        /// <summary>
        /// Waits for a dial to spin the specified number of quarter turns
        /// </summary>
        protected void WaitForDialSpin(int numberOfTurns)
        {
            const int quarterTurnTime = 1000;

            BotProgram.SafeWaitPlus(numberOfTurns * quarterTurnTime, 100);
        }
Ejemplo n.º 15
0
 /// <summary>
 /// Sets the bank to withdraw items as notes
 /// </summary>
 public void WithdrawAsNotes()
 {
     Mouse.LeftClick(Left + 279, Bottom - 15, 5);
     BotProgram.SafeWaitPlus(200, 20);
 }
Ejemplo n.º 16
0
 /// <summary>
 /// Clicks on the "Deposit Inventory" button in the bank pop-up
 /// </summary>
 /// <param name="screenWidth">width of the game screen in pixels</param>
 /// <param name="screenHeight">height of the game screen in pixels</param>
 public void DepositInventory()
 {
     Mouse.LeftClick(Left + 427, Bottom - 22, 10);
     BotProgram.SafeWaitPlus(200, 20);
 }