/// <summary> /// After calling the demon, makes sure that conversation with the demon has started /// </summary> /// <returns>true if successful</returns> protected bool InitiateDemonDialog() { int demonTries = 0; while (!StopFlag && !WaitFor(AnyDialog, 1500)) { Blob demon; if (Vision.LocateStationaryObject(DemonHead, out demon, Screen.ArtifactLength(0.015), 3000, Screen.ArtifactArea(0.00005), Screen.ArtifactArea(0.0005))) { Mouse.Move(demon.Center.X, demon.Center.Y); if (Vision.WaitForMouseOverText(YellowMouseOverText)) { LeftClick(demon.Center.X, demon.Center.Y); if (SafeWait(500)) { return(false); } } } else { if (++demonTries > 2) { return(AnyDialog(true)); } } } return(WaitFor(AnyDialog)); }
/// <summary> /// Passes a climbable tree obstacle using the topmost branch (the northern branch if the screen is at compass default /// </summary> /// <returns>true if successful</returns> private bool PassTreeBranch() { Blob treeTrunk; if (!Vision.LocateStationaryObject(TreeTrunk, out treeTrunk, STATIONARY_OBJECT_TOLERANCE, WAIT_FOR_NEXT_OBSTACLE, 0, int.MaxValue, FindTreeTrunk)) { return(false); //unable to locate a tree trunk } Blob treeBranches; if (!FindTreeBranches(out treeBranches, treeTrunk.Center)) { return(false); } //didn't find tree to climb Point branchEnd = treeBranches.GetTop(); Line topBranch = new Line(treeTrunk.Center, branchEnd); Point click = topBranch.OffsetFromEnd(0.0447 * Screen.Height); //~45 pixels in from the end of the branch on a full HD screen LeftClick(click.X, click.Y); SafeWait(1000); //wait for the player to climb the tree return(true); }
/// <summary> /// Find all of the unmined iron ores on the screen and sorts them by proximity to the player /// </summary> /// <returns>true if any ores are located</returns> protected Blob StationaryLocateUnminedOre() { Blob rockLocation; Vision.LocateStationaryObject(IronFilter, out rockLocation, 15, 5000, minIronBlobPxSize, 5 * minIronBlobPxSize, LocateUnminedOre); return(rockLocation); }
/// <summary> /// Passes through a drain pipe obstacle /// </summary> /// <returns>true if successful</returns> private bool PassDrainPipe() { Blob drainPipe; if (!Vision.LocateStationaryObject(DrainPipe, out drainPipe, STATIONARY_OBJECT_TOLERANCE, WAIT_FOR_NEXT_OBSTACLE, MinDrainPipeSize, int.MaxValue, LocateDrainPipe, 2)) { return(false); } LeftClick(drainPipe.Center.X, drainPipe.Center.Y, 5); SafeWait(7000); return(true); }
/// <summary> /// Clicks on a stationary object /// </summary> /// <param name="stationaryObject">color filter for the stationary object</param> /// <param name="tolerance">maximum allowable distance between two subsequent checks to consider both objects the same object</param> /// <param name="afterClickWait">time to wait after clicking on the stationary object</param> /// <param name="maxWaitTime">maximum time to wait before giving up</param> /// <returns></returns> internal bool ClickStationaryObject(ColorFilter stationaryObject, double tolerance, int afterClickWait, int maxWaitTime, int minimumSize) { Blob foundObject; if (Vision.LocateStationaryObject(stationaryObject, out foundObject, tolerance, maxWaitTime, minimumSize)) { Mouse.LeftClick(foundObject.Center.X, foundObject.Center.Y); BotProgram.SafeWaitPlus(afterClickWait, 0.2 * afterClickWait); return(true); } return(false); }
/// <summary> /// Finds the location of the bank chest to click on /// </summary> /// <param name="clickLocation"></param> /// <returns></returns> protected bool BankChestClickLocation(out Point clickLocation) { Blob bankChest; if (Vision.LocateStationaryObject(BankChest, out bankChest, 0, 5000, 1, int.MaxValue, FindBankChest)) { Point clickOffset = new Point(-Screen.ArtifactLength(0.012), -Screen.ArtifactLength(0.006)); clickLocation = Geometry.AddPoints(bankChest.Center, clickOffset); clickLocation = Probability.GaussianCircle(clickLocation, 1, 0, 360, 3); return(true); } clickLocation = new Point(0, 0); return(false); }
/// <summary> /// Passes a cargo net agility obstacle /// </summary> /// <returns>true if successful</returns> private bool PassCargoNet() { Blob cargoNet; if (!Vision.LocateStationaryObject(CargoNet, out cargoNet, STATIONARY_OBJECT_TOLERANCE, WAIT_FOR_NEXT_OBSTACLE, MinCargoNetSize, int.MaxValue, LocateMiddleCargoNet)) { return(false); //unable to locate a set of cargo net frames } Point click = Geometry.RandomMidpoint(cargoNet.GetLeft(), cargoNet.GetRight()); LeftClick(click.X, click.Y + 10, 4); SafeWait(2000); //wait for the play to climb up the net return(true); }
/// <summary> /// Passes a climbable tree obstacle using the topmost branch (the northern branch if the screen is at compass default /// </summary> /// <returns>true if successful</returns> private bool PassTreeTrunk() { Blob treeTrunk; if (!Vision.LocateStationaryObject(TreeTrunk, out treeTrunk, STATIONARY_OBJECT_TOLERANCE, WAIT_FOR_NEXT_OBSTACLE, 0, int.MaxValue, FindTreeTrunk)) { return(false); //unable to locate a tree trunk } Point branchOffset = new Point(-Screen.ArtifactLength(0.0914), Screen.ArtifactLength(0.0177)); Point click = Geometry.AddPoints(treeTrunk.Center, branchOffset); //~45 pixels in from the end of the branch on a full HD screen LeftClick(click.X, click.Y, 6); SafeWait(1500); //wait for the player to climb the tree return(true); }
/// <summary> /// Passes a tight rope obstacle from left to right /// </summary> /// <returns>true if successful</returns> private bool PassTightRope() { Blob tightrope; if (!Vision.LocateStationaryObject(Tightrope, out tightrope, STATIONARY_OBJECT_TOLERANCE, WAIT_FOR_NEXT_OBSTACLE, MinTightropeSize)) { return(false); } Line tightropeAxis = new Line(tightrope.GetLeft(), tightrope.GetRight()); Point click = tightropeAxis.OffsetFromStart(25); LeftClick(click.X, click.Y, 10); SafeWait(500); Mouse.RadialOffset(150, 500, 0, 360); SafeWait(4700); return(true); }
/// <summary> /// Finds the Port Phasmatys bank booths and clicks on them to open the bank. /// Assumes that the player has a ghostspeak amulet equipped. /// Fails if the Port Phasmatys bank booths are not visible on the screen. /// </summary> /// <returns>True if the bank is opened</returns> protected bool ClickBankBooth() { Blob bankBooth; const int maxWaitTime = 12000; if (!Vision.LocateStationaryObject(BankBooth, out bankBooth, 15, maxWaitTime, Banking.MinBankBoothSize, int.MaxValue, Banking.LocateBankBoothPhasmatys)) { return(false); } LeftClick(bankBooth.Center.X, bankBooth.Center.Y, 10); SafeWait(200, 120); Bank bankPopup = new Bank(RSClient, Inventory, Keyboard); bool bankOpened = bankPopup.WaitForPopup(); return(bankOpened); }
/// <summary> /// Jumps from the bank roof to the roof at the start of the tightrope and waits for the player to come to a stop. /// </summary> /// <returns>true if successful</returns> private bool JumpToTightrope() { Blob whiteFlag; if (Vision.LocateStationaryObject(WhiteFlag, out whiteFlag, 20, 7000, Screen.ArtifactArea(0.000065), Screen.ArtifactArea(0.000260))) //ex 0.000130 { ScanForMarkOfGrace(); Point expectedLocation = new Point(whiteFlag.Center.X - Screen.ArtifactLength(0.337), whiteFlag.Center.Y + Screen.ArtifactLength(0.0688)); if (HandEye.MouseOverStationaryObject(new Blob(expectedLocation), true, 25, 3000)) { SafeWait(5500); MoveMouse(Screen.Center.X - Screen.ArtifactLength(0.207), Screen.Center.Y + Screen.ArtifactLength(0.34)); Vision.WaitDuringPlayerAnimation(4000); return(true); } } return(false); }
/// <summary> /// Clicks on a knight 10 times in short succession /// </summary> /// <param name="clickInterval">target time between clicks in milliseconds</param> /// <param name="clicks">number of pickpocket clicks to perform</param> /// <returns>true if a knight is clicked on</returns> protected bool ClickKnight(int clicks) { Stopwatch watch = new Stopwatch(); Blob purpleCloak; for (int i = 0; i < clicks; i++) { watch.Restart(); if (StopFlag) { return(false); } if (Vision.LocateStationaryObject(KnightPurple, out purpleCloak, Screen.ArtifactLength(0.015), 10000, MinPurpleCloakSize, int.MaxValue, Vision.LocateClosestObject, 1)) { if (CheckPosition(purpleCloak.Center)) { if (StopFlag) { return(false); } if (HandEye.MouseOver(purpleCloak.Center, NPCMouseover, true, 0)) { FailedCloakSearches = 0; } else { FailedCloakSearches++; } if (SafeWait(Math.Max(0, PICKPOCKET_TIME - watch.ElapsedMilliseconds), 200)) { return(false); } } } else { BlindSearch(); } } return(FailedCloakSearches < 300); }
/// <summary> /// Locates and walks over the log balance obstacle /// </summary> /// <returns>true if successful</returns> private bool PassLogBalance() { Blob log; if (!Vision.LocateStationaryObject(LogBalance, out log, STATIONARY_OBJECT_TOLERANCE, WAIT_FOR_NEXT_OBSTACLE, MinLogSize, int.MaxValue, null, 2)) { return(false); //unable to locate the log balance } Point logStart = log.GetTop(); Point logEnd = log.GetBottom(); Line logAxis = new Line(logStart, logEnd); Point click = logAxis.OffsetFromStart(30); LeftClick(click.X, click.Y, 2); //wait for the player to cross the log SafeWait(7500); //approximate milliseconds needed to go from the end of the pipe obstacle to the end of the log balance return(true); }