public async Task FindAndClickNpc(int threshold, bool leftClick)
        {
            var npc = GetClosestNpc();

            if (npc != null)
            {
                if (npc.Height >= threshold)
                {
                    foreach (var location in locFindAndClickNpc)
                    {
                        var clickPostion = bitmapProvider.DirectBitmap.ToScreenCoordinates(npc.ClickPoint.X + location.X, npc.ClickPoint.Y + location.Y);
                        mouseInput.SetCursorPosition(clickPostion);
                        await Task.Delay(100);

                        CursorClassifier.Classify(out var cls).Dispose();
                        if (cls == CursorClassification.Kill)
                        {
                            await AquireTargetAtCursor(clickPostion, npc, leftClick);

                            return;
                        }
                        else if (cls == CursorClassification.Vendor)
                        {
                            await AquireTargetAtCursor(clickPostion, npc, leftClick);

                            return;
                        }
                    }
                }
                else
                {
                    logger.LogInformation($"{ this.GetType().Name}.FindAndClickNpc: NPC found but below threshold {threshold}! Height={npc.Height}, width={npc.Width}");
                }
            }
            else
            {
                //logger.LogInformation($"{ this.GetType().Name}.FindAndClickNpc: No NPC found!");
            }
        }
Beispiel #2
0
        public async Task TargetingAndClickNpc(bool leftClick, CancellationToken cancellationToken)
        {
            if (npcNameFinder.NpcCount == 0)
            {
                return;
            }

            var npc = npcNameFinder.Npcs.First();

            logger.LogInformation($"> NPCs found: ({npc.Min.X},{npc.Min.Y})[{npc.Width},{npc.Height}]");

            foreach (var location in locTargetingAndClickNpc)
            {
                if (cancellationToken.IsCancellationRequested)
                {
                    return;
                }

                var clickPostion = npcNameFinder.ToScreenCoordinates(npc.ClickPoint.X + location.X, npc.ClickPoint.Y + location.Y);
                input.SetCursorPosition(clickPostion);
                await Task.Delay(MOUSE_DELAY);

                if (cancellationToken.IsCancellationRequested)
                {
                    return;
                }

                CursorClassifier.Classify(out var cls);
                if (cls == CursorType.Kill || cls == CursorType.Vendor)
                {
                    await AquireTargetAtCursor(clickPostion, npc, leftClick);

                    return;
                }
            }
        }