Ejemplo n.º 1
0
        /// <summary>
        /// Determines if the player is next to a house portal
        /// </summary>
        /// <returns></returns>
        protected bool IsAtHouse()
        {
            Screen.ReadWindow();
            bool[,] portal = Vision.ColorFilterPiece(HousePortalPurple, Screen.Center, 200);
            double match = ImageProcessing.FractionalMatch(portal);

            return(match > 0.001);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Determines if "Click here to continue is showing"
        /// </summary>
        /// <returns>true if the player can push space to continue a dialog</returns>
        protected bool ContinueBar()
        {
            int left   = 233;
            int right  = left + 144;
            int top    = Screen.Height - 59;
            int bottom = top + 10;

            bool[,] continueBar = Vision.ColorFilterPiece(ContinueBarBlue, left, right, top, bottom);
            int textSize = ImageProcessing.MatchCount(continueBar);

            return(Numerical.CloseEnough(285, textSize, 0.01));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Determines if there are enough cloves close enough to the demon
        /// </summary>
        /// <param name="demonCenter"></param>
        /// <param name="cloveRange"></param>
        /// <returns></returns>
        private bool ClovesWithinRange(Point demonCenter, double cloveRange)
        {
            int requiredCloves = 1;
            int minCloveSize   = MinDemonSize / 400;

            bool[,] cloves = Vision.ColorFilterPiece(LesserDemonHorn, demonCenter, (int)cloveRange);
            List <Blob> demonCloves = ImageProcessing.FindBlobs(cloves, true);

            if (demonCloves.Count >= requiredCloves)
            {
                return(demonCloves[requiredCloves - 1].Size > minCloveSize);
            }
            return(false);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Determines if an overload potion is active by looking for the timer above the chat box
        /// </summary>
        /// <returns>true if the timer is found in the expected location above the right side of the chatbox</returns>
        protected bool OverloadTimerExists()
        {
            //bool[,] potionTimerSlot = potionTimerSlot = ColorFilterPiece(OverloadTimer, new Point(503, ScreenHeight - 185), 5);
            //double overloadTimerMatch = overloadTimerMatch = ImageProcessing.FractionalMatch(potionTimerSlot);
            //return overloadTimerMatch > 0.5;

            int left   = 478;
            int right  = left + 37;
            int top    = Screen.Height - 198;
            int bottom = top + 29;

            bool[,] potionTimerSlot = potionTimerSlot = Vision.ColorFilterPiece(PotionTimerBackground, left, right, top, bottom);
            double overloadTimerMatch = overloadTimerMatch = ImageProcessing.FractionalMatch(potionTimerSlot);

            return(overloadTimerMatch > 0.5);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Finds the closest bank booth in the Port Phasmatys bank
        /// </summary>
        /// <returns>True if the bank booths are found</returns>
        internal bool LocateBankBoothPhasmatys(out Blob bankBooth)
        {
            bankBooth = null;
            const int    numberOfBankBooths         = 6;
            const double minBoothWidthToHeightRatio = 2.3667;   //ex 2.6667
            const double maxBoothWidthToHeightRatio = 3.1333;   //ex 2.8333
            int          left   = Screen.Center.X - Screen.ArtifactLength(0.5);
            int          right  = Screen.Center.X + Screen.ArtifactLength(0.3);
            int          top    = Screen.Center.Y - Screen.ArtifactLength(0.15);
            int          bottom = Screen.Center.Y + Screen.ArtifactLength(0.2);

            Screen.ReadWindow();
            Point offset;

            bool[,] bankBooths = Vision.ColorFilterPiece(RGBHSBRangeFactory.BankBoothPhasmatys(), left, right, top, bottom, out offset);
            List <Blob> boothBlobs         = new List <Blob>();
            List <Blob> possibleBoothBlobs = ImageProcessing.FindBlobs(bankBooths, false, MinBankBoothSize, MaxBankBoothSize);  //list of blobs from biggest to smallest

            possibleBoothBlobs.Sort(new BlobProximityComparer(Screen.Center));
            double widthToHeightRatio, rectangularity;

            //Remove blobs that aren't bank booths
            foreach (Blob possibleBooth in possibleBoothBlobs)
            {
                widthToHeightRatio = (possibleBooth.Width / (double)possibleBooth.Height);
                rectangularity     = Geometry.Rectangularity(possibleBooth);
                if (Numerical.WithinBounds(widthToHeightRatio, minBoothWidthToHeightRatio, maxBoothWidthToHeightRatio) && rectangularity > 0.75)
                {
                    boothBlobs.Add(possibleBooth);
                }
            }

            if (boothBlobs.Count != numberOfBankBooths)
            {
                return(false);   //We either failed to locate all of the booths or identified something that was not actually a booth.
            }

            //Reduce the blob list to the bank booths
            boothBlobs.Sort(new BlobHorizontalComparer()); //sort from left to right
            boothBlobs.RemoveAt(3);                        //remove the unusable booths without tellers
            boothBlobs.RemoveAt(0);
            bankBooth = Blob.ClosestBlob(new Point(Screen.Center.X - left, Screen.Center.Y - top), boothBlobs);
            bankBooth.ShiftPixels(offset.X, offset.Y);
            return(true);
        }
Ejemplo n.º 6
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);
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Waits until the fairy rings teleport completes
        /// </summary>
        protected void WaitForFairyRingTeleport()
        {
            bool      teleportStarted = false;
            Stopwatch watch           = new Stopwatch();

            watch.Start();
            double match;

            while (watch.ElapsedMilliseconds < 4000 && !StopFlag)
            {
                Screen.ReadWindow();
                bool[,] portal = Vision.ColorFilterPiece(FairyRingTeleport, Screen.Center, 50);
                match          = ImageProcessing.FractionalMatch(portal);

                if (match > 0.001)
                {
                    teleportStarted = true;
                }
                if (match < 0.001 && teleportStarted)
                {
                    return;
                }
            }
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Calculates the number of text pixels in the dialog body
 /// </summary>
 /// <returns>the number of pixels of text in the dialog body</returns>
 protected int DialogBodyText()
 {
     Screen.ReadWindow();
     bool[,] dialogBody = Vision.ColorFilterPiece(DialogBody, DialogTextLeft, DialogTextRight, DialogTextTop, DialogTextBottom);
     return(ImageProcessing.MatchCount(dialogBody));
 }