/// <summary> /// Determines if the last screenshot was of the welcome screen /// </summary> /// <returns>true if we are on the welcome screen, false otherwise</returns> public bool IsWelcomeScreen(out Point?clickLocation) { int centerX = Center.X; const int centerY = 337; const int width = 220; const int height = 80; int left = centerX - (width / 2); int right = centerX + (width / 2); int top = centerY - (height / 2); int bottom = centerY + (height / 2); int totalSize = width * height; int redBlobSize; RGBHSBRange red = RGBHSBRangeFactory.WelcomeScreenClickHere(); bool[,] clickHere = ImageProcessing.ColorFilterPiece(Value, red, left, right, top, bottom); Blob enterGame = ImageProcessing.BiggestBlob(clickHere); redBlobSize = enterGame.Size; if (redBlobSize > (totalSize / 2)) { clickLocation = enterGame.RandomBlobPixel(); clickLocation = new Point(clickLocation.Value.X + left, clickLocation.Value.Y + top); return(true); } else { clickLocation = null; return(false); } }
/// <summary> /// Loads default color ranges /// </summary> private void GetReferenceColors() { FurnaceIconOrange = RGBHSBRangeFactory.FurnaceIconOrange(); BankIconDollar = RGBHSBRangeFactory.BankIconDollar(); BuildingFloor = RGBHSBRangeFactory.PhasmatysBuildingFloorLight(); Furnace = RGBHSBRangeFactory.Furnace(); BankBooth = RGBHSBRangeFactory.BankBoothPhasmatys(); }
/// <summary> /// Sets the reference colors for the lesser demon's parts if they haven't been set already /// </summary> private void GetReferenceColors() { LesserDemonSkin = RGBHSBRangeFactory.LesserDemonSkin(); LesserDemonHorn = RGBHSBRangeFactory.LesserDemonHorn(); RuneMedHelm = RGBHSBRangeFactory.RuneMedHelm(); MithrilArmor = RGBHSBRangeFactory.MithrilArmor(); ChaosRune = RGBHSBRangeFactory.ChaosRuneOrange(); DeathRune = RGBHSBRangeFactory.DeathRuneWhite(); MouseoverTextNPC = RGBHSBRangeFactory.MouseoverTextNPC(); }
/// <summary> /// Sets the filter colors for the obstacles /// </summary> private void GetReferenceColors() { LogBalance = RGBHSBRangeFactory.LogBalance(); CargoNet = RGBHSBRangeFactory.CargoNetFrameTop(); TreeBranch = RGBHSBRangeFactory.GnomeTreeBranch(); TreeTrunk = RGBHSBRangeFactory.GnomeTreeTrunk(); Tightrope = RGBHSBRangeFactory.Tightrope(); DrainPipe = RGBHSBRangeFactory.DrainPipe(); Black = RGBHSBRangeFactory.Black(); }
private void SetColors() { BankChest = RGBHSBRangeFactory.BankChest(); HousePortalPurple = RGBHSBRangeFactory.HousePortalPurple(); BlueMouseOverText = RGBHSBRangeFactory.MouseoverTextStationaryObject(); DemonHead = RGBHSBRangeFactory.LesserDemonSkin(); DialogTitle = RGBHSBRangeFactory.DialogBoxTitle(); DialogBody = RGBHSBRangeFactory.Black(); ContinueBarBlue = RGBHSBRangeFactory.GenericColor(Color.Blue); BackpackBrown = RGBHSBRangeFactory.BackpackBrown(); }
public ButlerSawmill(RunParams startParams) : base(startParams) { InventoryCashSlot = new Point(2, 0); InventoryLawRuneSlot = new Point(1, 0); InventoryLogSlot = new Point(0, 0); FirstLogSlot = new Point(3, 0); BankCashSlot = new Point(7, 0); BankLawRuneSlot = new Point(6, 0); BankLogSlot = new Point(5, 0); BankPlankSlot = new Point(4, 0); YellowMouseOverText = RGBHSBRangeFactory.MouseoverTextNPC(); }
/// <summary> /// Verifies that the pop-up is roughly the expected size /// </summary> /// <returns></returns> protected virtual void GetPopupHeight(Bitmap screen) { int yOffset; for (int row = 0; row < MAX_ROWS; row++) { yOffset = RowOffset(row); Color background = screen.GetPixel(XClick, YClick + yOffset); RGBHSBRange rightClickColor = RGBHSBRangeFactory.RightClickPopup(); if (rightClickColor.ColorInRange(background)) { Height = TITLE_HEIGHT + ((row + 1) * ROW_HEIGHT); } } }
/// <summary> /// Determines if the character is currently running. /// Assumes the character is running if a stamina potion is active because we cannot differentiate. /// </summary> /// <returns>true for running, false for walking</returns> public bool CharacterIsRunning(bool readWindow = false) { if (readWindow && !ReadWindow()) { return(false); } Point runOrb = RunOrbSamplePoint(); Color runColor = Screen[runOrb.X, runOrb.Y]; RGBHSBRange normalRunEnergyFoot = RGBHSBRangeFactory.RunEnergyFoot(); RGBHSBRange staminaRunEnergyFoot = RGBHSBRangeFactory.RunEnergyFootStamina(); bool normalRun = normalRunEnergyFoot.ColorInRange(runColor); bool staminaRun = staminaRunEnergyFoot.ColorInRange(runColor); return(normalRun || staminaRun); }
/// <summary> /// Estimates the target's fraction of its maximum hitpoints using OSBuddy's target hitpoints indicator /// </summary> /// <returns></returns> protected double TargetHitpointFraction() { if (!InCombat()) { return(double.MaxValue); } Screen.UpdateScreenshot(); Color[,] targetHitpoints = Vision.ScreenPiece(TARGET_HP_LEFT, TARGET_HP_RIGHT, TARGET_HP_TOP, TARGET_HP_BOTTOM); RGBHSBRange greenHPBar = RGBHSBRangeFactory.OSBuddyEnemyHitpointsGreen(); bool[,] greenHP = Vision.ColorFilter(targetHitpoints, greenHPBar); double greenWidth = ImageProcessing.BiggestBlob(greenHP).Width; RGBHSBRange redHPBar = RGBHSBRangeFactory.OSBuddyEnemyHitpointsRed(); bool[,] redHP = Vision.ColorFilter(targetHitpoints, redHPBar); double redWidth = ImageProcessing.BiggestBlob(redHP).Width; return(greenWidth / Numerical.NonZero(greenWidth + redWidth)); }
/// <summary> /// Determines an appropriate value to use for building floor color range /// </summary> protected bool ScanForBuildingFloor() { List <RGBHSBRange> colorRanges = new List <RGBHSBRange>() { RGBHSBRangeFactory.PhasmatysBuildingFloorDark(), RGBHSBRangeFactory.PhasmatysBuildingFloorLight() }; Blob bankIcon, bankFloor, furnaceIcon, furnaceFloor; Point offset; foreach (RGBHSBRange colorRange in colorRanges) { if (BankLocation(out bankIcon, out bankFloor, out offset, colorRange) && (bankFloor != null) && BankFloorSizeCheck(bankFloor.Size) && FurnaceLocation(out furnaceIcon, out furnaceFloor, out offset, colorRange) && (furnaceFloor != null) && FurnaceFloorSizeCheck(furnaceFloor.Size)) { BuildingFloor = colorRange; return(true); } } return(false); }
/// <summary> /// Determines whether the player is in combat using OSBuddy's target hitpoints indicator /// </summary> /// <returns></returns> protected bool InCombat() { const double minBackground = 0.1; RGBHSBRange background = RGBHSBRangeFactory.OSBuddyEnemyHitpointsBackground(); Screen.UpdateScreenshot(); bool[,] targetBackground = Vision.ColorFilterPiece(background, TARGET_HP_LEFT, TARGET_HP_RIGHT, TARGET_HP_TOP, TARGET_HP_BOTTOM); double backgroundMatch = ImageProcessing.FractionalMatch(targetBackground); if (backgroundMatch >= minBackground) { return(true); } else { oldHitpoints = new KeyValuePair <DateTime, double>(DateTime.Now, double.MaxValue); return(false); } }
private void GetReferenceColors() { TeaStallRoof = RGBHSBRangeFactory.TeaStallRoof(); MouseOverText = RGBHSBRangeFactory.MouseoverTextStationaryObject(); }
/// <summary> /// Locates the bank icon and bank floor on the minimap. /// Uses the most recent screenshot. /// </summary> /// <param name="bankIcon"></param> /// <param name="bankFloor"></param> /// <param name="offset"></param> /// <returns>true if at least the bank icon is found</returns> protected bool BankLocation(out Blob bankIcon, out Blob bankFloor, out Point offset, RGBHSBRange floorColor) { floorColor = floorColor ?? BuildingFloor; bool[,] minimapBankIcon = Minimap.MinimapFilter(BankIconDollar, out offset); bankIcon = ImageProcessing.BiggestBlob(minimapBankIcon); if (bankIcon == null || bankIcon.Size < BankIconMinSize) { bankFloor = null; return(false); } bool[,] minimapBankFloor = Minimap.MinimapFilter(floorColor); bankFloor = ImageProcessing.ClosestBlob(minimapBankFloor, bankIcon.Center, 100); return(true); }