/// <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)); }