예제 #1
0
        private void ScanBurst(FastBitmapHSV bitmap, ScreenData screenData)
        {
            float monoAcc = 0.0f;

            for (int idxY = 0; idxY < rectBurstActive.Height; idxY++)
            {
                for (int idxX = 0; idxX < rectBurstActive.Width; idxX++)
                {
                    FastPixelHSV testPx = bitmap.GetPixel(rectBurstActive.X + idxX, rectBurstActive.Y + idxY);
                    monoAcc += testPx.GetMonochrome();
                }
            }

            float monoAvg       = monoAcc / (rectBurstActive.Width * rectBurstActive.Height);
            float centerFillPct = 0;

            if (monoAvg < 15)
            {
                screenData.BurstState = EBurstState.Active;
            }
            else
            {
                centerFillPct = ScreenshotUtilities.CountFillPct(bitmap, rectBurstCenter, matchBurstCenter);
                if (centerFillPct > 0.75f)
                {
                    screenData.BurstState      = EBurstState.ReadyAndCenter;
                    screenData.BurstMarkerPctX = 0.5f;
                    screenData.BurstMarkerPctY = 0.5f;

                    if (DebugLevel >= EDebugLevel.Verbose)
                    {
                        Rectangle box = GetSpecialActionBox((int)ESpecialBox.BurstCenter);
                        DrawRectangle(bitmap, box.X, box.Y, box.Width, box.Height, 255);
                    }
                }
                else
                {
                    ScanBurstPosition(bitmap, screenData);

                    if (DebugLevel >= EDebugLevel.Verbose && screenData.BurstState == EBurstState.Ready)
                    {
                        Rectangle box = GetSpecialActionBox((int)ESpecialBox.BurstReady);
                        DrawRectangle(bitmap, box.X, box.Y, box.Width, box.Height, 255);
                    }
                }
            }

            if (DebugLevel >= EDebugLevel.Simple)
            {
                Console.WriteLine("{0} ScanBurst: {1}", ScannerName, screenData.BurstState);
            }
            if (DebugLevel >= EDebugLevel.Verbose)
            {
                Console.WriteLine(">> monoAvg: {0}, centerFillPct: {1}", monoAvg, centerFillPct);
            }
        }
예제 #2
0
        public void SetHSV(int hue, int saturation, int value)
        {
            HuePack        = (byte)(hue & 0xff);
            SaturationPack = (byte)((saturation & 0x7f) | ((hue & 0x100) >> 1));
            Value          = (byte)value;

            ScreenshotUtilities.HsvToRgb(hue, saturation, value, out int colorR, out int colorG, out int colorB);
            Monochrome = (byte)Math.Round((0.2125 * colorR) + (0.7154 * colorG) + (0.0721 * colorB));
            RawR       = (byte)colorR;
            RawG       = (byte)colorG;
            RawB       = (byte)colorB;
            HasHSL     = 1;
        }
예제 #3
0
        protected bool HasOpenedChatLine(FastBitmapHSV bitmap, out int mode)
        {
            mode = 0;
            for (int posX = 0; posX < bitmap.Width; posX++)
            {
                var  testPx     = bitmap.GetPixel(posX, posChatBackY);
                bool isMatching = matchChatLineBack.IsMatching(testPx);
                if (!isMatching)
                {
                    if (DebugLevel >= EDebugLevel.Verbose)
                    {
                        Console.WriteLine("{0} HasOpenedChatLine: failed match! ({1},{2})=({3}) vs filter({4})",
                                          ScannerName, posX, posChatBackY, testPx, matchChatLineBack);
                    }
                    return(false);
                }

                testPx     = bitmap.GetPixel(posX, posNoChatBackY);
                isMatching = matchChatLineBack.IsMatching(testPx);
                if (isMatching)
                {
                    if (DebugLevel >= EDebugLevel.Verbose)
                    {
                        Console.WriteLine("{0} HasOpenedChatLine: failed no match! ({1},{2})=({3}) vs filter({4})",
                                          ScannerName, posX, posNoChatBackY, testPx, matchChatLineBack);
                    }
                    return(false);
                }
            }

            for (int testMode = 1; testMode < posChatLineModeY.Length; testMode++)
            {
                var  avgPx      = ScreenshotUtilities.GetAverageColor(bitmap, new Rectangle(rectChatLine.X, posChatLineModeY[testMode], rectChatLine.Width, rectChatLine.Height));
                bool isMatching = matchChatLine.IsMatching(avgPx) && !matchChatLineBack.IsMatching(avgPx);
                if (!isMatching)
                {
                    if (DebugLevel >= EDebugLevel.Verbose)
                    {
                        Console.WriteLine("{0} HasOpenedChatLine: failed mode:{1}... ({2}) vs filter({3})",
                                          ScannerName, testMode, avgPx, matchChatLine);
                    }
                }
                else
                {
                    mode = testMode;
                    return(true);
                }
            }

            return(false);
        }
예제 #4
0
        protected void ScanBurst(FastBitmapHSV bitmap, ScreenData screenData)
        {
            var centerFillPct = ScreenshotUtilities.CountFillPct(bitmap, rectBurstCenter, matchBurstCenter);

            screenData.hasBurstInCenter = centerFillPct > 0.75f;

            if (DebugLevel >= EDebugLevel.Simple)
            {
                Console.WriteLine("{0} ScanBurst: {1}", ScannerName, screenData.hasBurstInCenter);
            }
            if (DebugLevel >= EDebugLevel.Verbose)
            {
                Console.WriteLine(">> centerFillPct: {0}", centerFillPct);
            }
        }
예제 #5
0
        protected void ScanSummonSelector(FastBitmapHSV bitmap, ScreenDataBase screenData)
        {
            var avgPx          = ScreenshotUtilities.GetAverageColor(bitmap, rectSummonSelectorA);
            var iconFillPct    = ScreenshotUtilities.CountFillPct(bitmap, rectSummonSelectorB, matchSummonIcon);
            var isAvgMatching  = matchSummonBack.IsMatching(avgPx);
            var isIconMatching = (iconFillPct > 0.10f) && (iconFillPct < 0.35f);

            screenData.hasSummonSelection = isAvgMatching && isIconMatching;

            if (DebugLevel >= EDebugLevel.Simple)
            {
                Console.WriteLine("{0} ScanSummonSelector: {1}", ScannerName, screenData.hasSummonSelection);
            }
            if (DebugLevel >= EDebugLevel.Verbose)
            {
                Console.WriteLine("  avgPx: ({0}) vs ({1}) => {2}, fillIcon: {3} => {4}",
                                  avgPx, matchSummonBack, isAvgMatching,
                                  iconFillPct, isIconMatching);
            }
        }
예제 #6
0
        protected bool HasOkButtonArea(FastBitmapHSV bitmap, ScreenData screenData)
        {
            FastPixelHSV[] avgPx = new FastPixelHSV[rectButtonPos.Length];
            for (int idx = 1; idx < avgPx.Length; idx++)
            {
                avgPx[idx] = ScreenshotUtilities.GetAverageColor(bitmap, rectButtonPos[idx]);

                var scanOb = new ActionData();
                scanOb.buttonColor =
                    matchAvgRed.IsMatching(avgPx[idx]) ? EButtonColor.Red :
                    matchAvgWhite.IsMatching(avgPx[idx]) ? EButtonColor.White :
                    matchAvgSpec.IsMatching(avgPx[idx]) ? EButtonColor.Spec :
                    EButtonColor.Unknown;

                if (scanOb.buttonColor != EButtonColor.Unknown)
                {
                    float[] values = ExtractButtonData(bitmap, idx);
                    scanOb.buttonType = (EButtonType)classifierButtons.Calculate(values, out float DummyPct);

                    switch (scanOb.buttonColor)
                    {
                    case EButtonColor.Red: scanOb.isDisabled = avgPx[idx].GetValue() < 40; break;

                    case EButtonColor.White: scanOb.isDisabled = avgPx[idx].GetValue() < 70; break;

                    default: break;
                    }
                }

                screenData.actions[idx] = scanOb;
            }

            if (screenData.actions[(int)EButtonPos.CombatReportOk].buttonColor == EButtonColor.Red &&
                screenData.actions[(int)EButtonPos.CombatReportOk].buttonType == EButtonType.Ok &&
                screenData.actions[(int)EButtonPos.CombatReportRetry].buttonColor == EButtonColor.White &&
                (screenData.actions[(int)EButtonPos.CombatReportRetry].buttonType == EButtonType.Retry || screenData.actions[(int)EButtonPos.CombatReportRetry].buttonType == EButtonType.Next))
            {
                screenData.mode = EMessageType.CombatReport;
            }
            else if (screenData.actions[(int)EButtonPos.CombatStart].buttonColor == EButtonColor.Red &&
                     screenData.actions[(int)EButtonPos.CombatStart].buttonType == EButtonType.Start &&
                     screenData.actions[(int)EButtonPos.CombatDetails].buttonColor == EButtonColor.Spec &&
                     (screenData.actions[(int)EButtonPos.CombatDetails].buttonType == EButtonType.Details))
            {
                screenData.mode = EMessageType.CombatStart;
            }
            else if (screenData.actions[(int)EButtonPos.Center].buttonColor == EButtonColor.Red &&
                     screenData.actions[(int)EButtonPos.Center].buttonType == EButtonType.Ok)
            {
                screenData.mode = EMessageType.Ok;
            }
            else if (screenData.actions[(int)EButtonPos.CenterTwoLeft].buttonColor == EButtonColor.White &&
                     screenData.actions[(int)EButtonPos.CenterTwoLeft].buttonType == EButtonType.Cancel &&
                     screenData.actions[(int)EButtonPos.CenterTwoRight].buttonColor == EButtonColor.Red &&
                     screenData.actions[(int)EButtonPos.CenterTwoRight].buttonType == EButtonType.Ok)
            {
                screenData.mode = EMessageType.OkCancel;
            }
            else if (screenData.actions[(int)EButtonPos.Center].buttonColor == EButtonColor.White &&
                     screenData.actions[(int)EButtonPos.Center].buttonType == EButtonType.Close)
            {
                screenData.mode = EMessageType.Close;
            }

            if (DebugLevel >= EDebugLevel.Simple)
            {
                Console.WriteLine("{0} Mode: {1}", ScannerName, screenData.mode);
            }
            if (DebugLevel >= EDebugLevel.Verbose)
            {
                Console.WriteLine("  filterRed:({0}), filterWhite:({1}), filterSpec({2})", matchAvgRed, matchAvgWhite, matchAvgSpec);
                for (int idx = 1; idx < avgPx.Length; idx++)
                {
                    Console.WriteLine("  [{0}]:({1}), color:{2}, class:{3}",
                                      (EButtonPos)idx, avgPx[idx],
                                      screenData.actions[idx].buttonColor,
                                      screenData.actions[idx].buttonType);
                }
            }

            return(screenData.mode != EMessageType.Unknown);
        }