/// <summary> /// Tries to find a knight to click on without being able to see a purple cloak. /// Adjust position if the knight is found on the same grid square row as the player. /// </summary> /// <returns></returns> protected bool BlindSearch() { Point guess = new Point(Screen.Center.X + (BlindSpot.X * GridSquareHeight), Screen.Center.Y + (BlindSpot.Y * GridSquareHeight)); if (HandEye.MouseOver(guess, NPCMouseover, true, NPCClickRandomization)) { return(true); } for (int x = -1; x <= 1; x++) { for (int y = -1; y <= 1; y++) { if (StopFlag) { return(false); } guess = new Point(Screen.Center.X + (x * GridSquareHeight), Screen.Center.Y + (y * GridSquareHeight)); if (HandEye.MouseOver(guess, NPCMouseover, true, NPCClickRandomization)) { BlindSpot = new Point(x, y); return(true); } } } FailedCloakSearches++; return(false); }
/// <summary> /// Crosses the tightrope /// </summary> /// <returns>true if successful</returns> private bool CrossTightrope() { Blob tightrope; ScanForMarkOfGrace(false); for (int i = 0; i < 3; i++) //finding the tightrope and failing the mouseover probably means that another player was blocking view of the tightrope during the screen capture { if (Vision.LocateObject(Tightrope, out tightrope, Screen.ArtifactArea(0.00009), Screen.ArtifactArea(0.714))) //ex 0.000357 { Point tightropeStart = tightrope.GetTop(); Point hitboxCenter = new Point(tightropeStart.X, tightropeStart.Y - Screen.ArtifactLength(0.0269)); if (HandEye.MouseOverStationaryObject(new Blob(hitboxCenter), true, 10, 3000)) { SafeWait(8000); return(true); } } else { return(false); } } return(false); }
/// <summary> /// Fills the small, medium, and large pouches. /// Refreshes stamina if it is almost out. /// Replaces any depleted jewelry. /// </summary> /// <param name="refreshStamina">set to true to drink a dose of stamina potion</param> /// <returns>true if successful</returns> protected bool FillSmallMediumLargePouches() { Point cursorLocation = new Point(Mouse.X, Mouse.Y); Bank bank; if (HandEye.MouseOverStationaryObject(new Blob(cursorLocation), true, 0, 0)) //try mousing over the default guess location first { bank = new Bank(RSClient, Inventory, Keyboard); if (!bank.WaitForPopup(6000)) { return(false); } } else if (!Banking.OpenBank(out bank, 3)) //Look for the bank if guessing fails { return(false); } bank.DepositAll(InventorySlotCraftedRunes); BankWithdrawForServicing(bank); bank.WithdrawAll(BankSlotPureEssence.X, BankSlotPureEssence.Y); bank.Close(); return(Servicing()); }
/// <summary> /// Attempts to retrieve a falcon after launching it at a kebbit. /// </summary> /// <param name="target">The expected location of the falcon catching the kebbit.</param> /// <returns>True if the falcon catches the kebbit and is successfully retrieved.</returns> protected bool RetrieveFalcon(Point target) { //Find the second inventory slot that should fill when we retrieve the falcon so as not to confuse with accidentally picking up an item from the ground. Point?nextEmptyInventorySlot = Inventory.FirstEmptySlot(false, 2); if (nextEmptyInventorySlot == null) { return(false); } if (!WaitForCatch(ref target) || !WaitForFalconToStop(ref target, (Point)nextEmptyInventorySlot)) { return(false); } Stopwatch retrieveWatch = new Stopwatch(); retrieveWatch.Start(); while (retrieveWatch.ElapsedMilliseconds < 60000 && !StopFlag) { if (HandEye.MouseOverNPC(new Blob(target), true, 0)) { SafeWait((int)(RunTime(target) / 2)); if (Inventory.WaitForSlotToFill((Point)nextEmptyInventorySlot, 5000)) { return(true); } } else if (HandEye.MouseOverStationaryObject(new Blob(target), false, 0, 0)) { //LeftClick(target.X, target.Y, 12); //WaitDuringPlayerAnimation((int) (RunTime(target) * 1.5)); RightClick(target.X, target.Y, 0); RightClick falconMenu = new RightClick(target.X, target.Y, RSClient, Keyboard); falconMenu.WaitForPopup(); falconMenu.CustomOption(1); if (SafeWait(1000)) { return(false); } //TODO Search for the first row in the popup with NPC yellow text instead of picking the second row. } //We accidentally collected the falcon at some point. if (!Inventory.SlotIsEmpty(nextEmptyInventorySlot.Value, true)) { return(true); } //The falcon ran away. else if (!LocateFlashingArrow(ref target)) { FalconRanAway = true; return(false); } } return(false); }
protected override bool Execute() { //Drop kebbit pickups to make room for more. if (!Inventory.SlotIsEmpty(18, true)) { Inventory.DropInventory(false); } List <Kebbit> kebbits = LocateKebbits(); kebbits = SortAndFilterKebbits(kebbits); kebbits = kebbits.GetRange(0, Math.Min(kebbits.Count, 2)); //Only try the first 2 kebbits. foreach (Kebbit kebbit in kebbits) { if (StopFlag) { return(false); } if (HandEye.MouseOverNPC(new Blob(kebbit.Location.Center), true, 1, 500)) { if (RetrieveFalcon(kebbit.Location.Center)) { FailedRuns = 0; RunParams.Iterations--; return(true); } break; //Don't keep trying after a failed catch attempt. } } FailedRuns++; if (FailedRuns >= 5) { if (FailedRuns % 10 == 0) { Minimap.MoveToPosition(225, 0.95, true, 3, 2500, null, 10000); Vision.WaitDuringPlayerAnimation(6000); } else if (FailedRuns % 5 == 0) { Minimap.MoveToPosition(315, 0.95, true, 3, 2500, null, 10000); Vision.WaitDuringPlayerAnimation(6000); } } return(FailedRuns < 60 && !FalconRanAway); }
/// <summary> /// Jumps from the ladder roof to the church roof /// </summary> /// <returns>true if successful</returns> private bool JumpToChurchRoof() { Point hitboxCenter = new Point(Screen.Center.X - Screen.ArtifactLength(0.498), Screen.Center.Y + Screen.ArtifactLength(0.200)); Blob hitboxBlob = new Blob(hitboxCenter); if (HandEye.MouseOverStationaryObject(hitboxBlob, false, 10, 2500)) { ScanForMarkOfGrace(); if (HandEye.MouseOverStationaryObject(new Blob(hitboxCenter), true, 10, 3000)) { SafeWait(5000); return(true); } } return(false); }
} //ex 0.001045 #endregion #region constructors internal Banking(GameScreen screen, Vision vision, HandEye handEye, RSClient client, Keyboard keyboard, Inventory inventory, MinimapGauge minimap) { Screen = screen; Vision = vision; HandEye = handEye; RSClient = client; Keyboard = keyboard; Inventory = inventory; Minimap = minimap; PossibleBankTypes = new List <BankLocator>(); PossibleBankTypes.Add(LocateBankBoothVarrock); PossibleBankTypes.Add(LocateBankBoothSeersVillage); PossibleBankTypes.Add(LocateBankBoothPhasmatys); PossibleBankTypes.Add(LocateBankBoothEdgeville); Bank.ResetNAmount(); }
/// <summary> /// Jumps off of the church roof /// </summary> /// <returns>true if successful</returns> private bool JumpOffTreeRoof() { Point hitboxCenter = new Point(Screen.Center.X + Screen.ArtifactLength(0.069), Screen.Center.Y + Screen.ArtifactLength(0.069)); Blob hitboxBlob = new Blob(hitboxCenter); if (HandEye.MouseOverStationaryObject(hitboxBlob, false, 10, 3500)) { ScanForMarkOfGrace(); if (HandEye.MouseOverStationaryObject(new Blob(hitboxCenter), true, 10, 3000)) { SafeWait(3000); Inventory.HoverStandardTeleport(Inventory.StandardTeleports.Camelot, false, false); Vision.WaitDuringPlayerAnimation(3000); return(true); } } return(false); }
/// <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> /// Clicks the interior nature altar /// </summary> /// <returns>true if successful</returns> protected bool CraftInventory(Point altarLocation, Point?restMouse) { //click on the interior nature altar to craft inventory by guessing the location altarLocation = Probability.GaussianCircle(altarLocation, 5, 0, 360, 15); Blob interiorAltar = new Blob(altarLocation); //guess the location before searching if (!HandEye.MouseOverStationaryObject(interiorAltar, true, 20, 5000)) { if (!LocateAltar(out interiorAltar) || !HandEye.MouseOverStationaryObject(interiorAltar, true, 20, 3000)) { return(false); } } if (restMouse != null) { MoveMouse(restMouse.Value.X, restMouse.Value.Y); //leave the mouse close to where it will be needed next } return(true); }
/// <summary> /// Looks for a mark of grace to pick up and picks it up if found. /// Returns the player to his starting location after picking it up. /// </summary> /// <returns>true if a mark of grace is found</returns> private bool ScanForMarkOfGrace(bool returnToOriginalPosition = true) { Blob markOfGraceBackground, markOfGraceFigure; if (Vision.LocateObject(MarkOfGraceBackground, out markOfGraceBackground, Screen.ArtifactArea(0.000355), Screen.ArtifactArea(0.00142)) && //ex 0.000710 Vision.LocateObject(MarkOfGraceFigure, out markOfGraceFigure, markOfGraceBackground.LeftBound, markOfGraceBackground.RightBound, markOfGraceBackground.TopBound, markOfGraceBackground.BottomBound, Screen.ArtifactArea(0.0000402))) { markOfGraceBackground.AddBlob(markOfGraceFigure); if (HandEye.MouseOverDroppedItem(markOfGraceBackground, true, 5, 3000)) { SafeWait(2000); Vision.WaitDuringPlayerAnimation(8000); if (returnToOriginalPosition) { LeftClick(2 * Screen.Center.X - markOfGraceBackground.Center.X, 2 * Screen.Center.Y - markOfGraceBackground.Center.Y); SafeWait(2000); Vision.WaitDuringPlayerAnimation(8000); } } } return(false); }
/// <summary> /// Clicks the exterior nature altar to enter it and clicks the nature altar to craft the first inventory of essence /// </summary> /// <returns>true if successful</returns> protected bool EnterAltar() { int minimumSize = Screen.ArtifactArea(0.01); //ex 0.0236 Blob exteriorAltar; Point searchCenter = new Point(Screen.Center.X + Screen.ArtifactLength(0.25), Screen.Center.Y - Screen.ArtifactLength(0.24)); if (!HandEye.MouseOverStationaryObject(new Blob(searchCenter), true, 10, 1000)) //click on the exterior nature altar to enter { if (!LocateAltar(out exteriorAltar, searchCenter, Screen.ArtifactLength(0.3))) { return(false); } Vision.WaitDuringPlayerAnimation(3000); if (!HandEye.MouseOverStationaryObject(exteriorAltar, true, 10, 2000)) { return(false); } } SafeWaitPlus((int)(2.5 * BotRegistry.GAME_TICK), 150); //click on the interior nature altar to craft inventory by guessing the location Point altarLocation = new Point(Screen.Center.X, Screen.Center.Y - Screen.ArtifactLength(0.311)); int x = InventorySlotSmallPouch.X, y = InventorySlotSmallPouch.Y; Inventory.InventoryToScreen(ref x, ref y); for (int i = 0; i < 5; i++) { CraftInventory(altarLocation, new Point(x, y)); if (WaitForRunesToCraft(false, 3 * BotRegistry.GAME_TICK)) { break; } SafeWait(BotRegistry.GAME_TICK); } return(true); }
/// <summary> /// Clicks on the window that starts the Seers' Village agility course /// </summary> /// <returns>true if successful</returns> private bool ClimbBank() { int left = Screen.Center.X; int right = Screen.Width - 1; int top = 0; int bottom = Screen.Center.Y; List <Blob> possibleBankWalls = Vision.LocateObjects(BankWall, left, right, top, bottom, true, Screen.ArtifactArea(0.00004), Screen.ArtifactArea(0.0004)); //ex 0.0000803, 0.0004 Point? expectedWallLocation = ExpectedBankWallLocation(); if (expectedWallLocation == null) { return(false); } possibleBankWalls.Sort(new BlobProximityComparer((Point)expectedWallLocation)); if (HandEye.MouseOver(possibleBankWalls, StationaryObjectText, true, 6, 1600)) { SafeWait(4500); MoveMouse(Screen.Center.X - Screen.ArtifactLength(0.511), Screen.Center.Y - Screen.ArtifactLength(0.065)); return(true); } return(false); }
protected override bool Execute() { Screen.ReadWindow(); if (Minimap.Hitpoints() > 0.9) { Logout(); return(false); //Assume that we died in the Nightmare Zone if hitpoints suddenly become full } if (Overload() || Hitpoints() || Absorption()) { if (StopFlag) { return(false); } Point inventoryCorner = new Point(Screen.Width - Inventory.INVENTORY_OFFSET_LEFT - Inventory.INVENTORY_GAP_X, Screen.Height - Inventory.INVENTORY_OFFSET_TOP - Inventory.INVENTORY_GAP_Y); int acceptableAreaRadius = (int)Geometry.DistanceBetweenPoints(Screen.Center, inventoryCorner); HandEye.MouseOverNPC(new Blob(new Point(Screen.Center.X, Screen.Center.Y)), true, acceptableAreaRadius, 1000); } return(true); }
/// <summary> /// Initializes a bot program with a client matching startParams /// </summary> /// <param name="startParams">specifies how to run the bot</param> protected BotProgram(RunParams startParams) { RunParams = startParams; RunParams.ClientType = ScreenScraper.Client.Jagex; RunParams.DefaultCameraPosition = RunParams.CameraPosition.NorthAerial; RunParams.LoginWorld = 0; RSClient = new RSClient(RunParams); Screen = new GameScreen(RSClient, RunParams); RSClient.AddScreen(Screen); Vision = new Vision(Screen, RunParams); Keyboard = new Keyboard(RSClient); Mouse.RSClient = RSClient; HandEye = new HandEye(Vision, Screen); Inventory = new Inventory(RSClient, Keyboard, Screen); Minimap = new MinimapGauge(RSClient, Keyboard, Screen); Textbox = new TextBoxTool(RSClient, Keyboard, Screen); Banking = new Banking(Screen, Vision, HandEye, RSClient, Keyboard, Inventory, Minimap); Conversation = new Conversation(Textbox, Screen, RunParams.Conversation); RNG = new Random(); }
protected override bool Execute() { if (failedRuns > CONSECUTIVE_FAILURES_ALLOWED) { return(false); } //Move to the bank and open it if (!MoveToBankPhasmatys() || !ClickBankBooth()) { failedRuns++; return(true); } //Refresh inventory to a bracelet mould and 27 gold bars if (StopFlag) { return(false); } BankPopup = new Bank(RSClient, Inventory, Keyboard); if (!BankPopup.WaitForPopup(BotUtilities.WAIT_FOR_BANK_WINDOW_TIMEOUT)) { failedRuns++; return(true); } if (StopFlag) { return(false); } BankPopup.DepositInventory(); SafeWaitPlus(500, 200); BankPopup.WithdrawOne(7, 0); SafeWaitPlus(500, 150); BankPopup.WithdrawAll(6, 0); //Move to the furnace and use a gold bar on it if (StopFlag) { return(false); } if (!MoveToFurnace(6000)) { failedRuns++; return(true); } Inventory.ClickInventory(1, 0, false); HandEye.ClickStationaryObject(Furnace, STATIONARY_OBJECT_TOLERANCE, 100, 12000, 1000); //Do the bot-specific actions at the furnace if (StopFlag) { return(false); } if (!FurnaceActions()) { failedRuns++; return(true); } failedRuns = 0; return(true); }