Example #1
0
        /// <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);
            }
        }