Beispiel #1
0
        private async Task <bool> LookForTarget()
        {
            if (this.playerReader.HasTarget && !this.playerReader.PlayerBitValues.TargetIsDead && !blacklist.IsTargetBlacklisted())
            {
                return(true);
            }
            else
            {
                await input.TapNearestTarget();

                if (!playerReader.HasTarget)
                {
                    npcNameFinder.ChangeNpcType(NpcNameFinder.NPCType.Enemy);
                    if (npcNameFinder.NpcCount > 0)
                    {
                        await this.npcNameFinder.FindAndClickNpc(0, true);
                    }
                }
            }

            if (this.playerReader.HasTarget && !blacklist.IsTargetBlacklisted())
            {
                if (playerReader.PlayerBitValues.IsMounted)
                {
                    //await wowProcess.Dismount();
                }
                await input.TapInteractKey("FollowRouteAction 4");

                return(true);
            }
            return(false);
        }
        public MainWindow()
        {
            InitializeComponent();
            timer           = new Timer(1000);
            timer.Elapsed  += OnTimedEvent;
            timer.AutoReset = true;
            timer.Enabled   = true;

            var logConfig = new LoggerConfiguration()
                            //.WriteTo.File("names.log")
                            .WriteTo.Debug()
                            .CreateLogger();

            Log.Logger = logConfig;
            logger     = new SerilogLoggerProvider(Log.Logger).CreateLogger(nameof(MainWindow));

            var rect = new Rectangle(0, 0, 1920, 1080);

            capturer = new DirectBitmapCapturer(rect);

            npcNameFinder = new NpcNameFinder(logger, capturer);
            npcNameFinder.ChangeNpcType(NpcNames.Neutral | NpcNames.Friendly);

            InitSliders();
        }
        public void Execute()
        {
            npcNameFinder.ChangeNpcType(NpcNames.Enemy | NpcNames.Neutral);

            capturer.Capture();

            System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch();
            stopwatch.Start();
            this.npcNameFinder.Update();
            stopwatch.Stop();
            logger.LogInformation($"Update: {stopwatch.ElapsedMilliseconds}ms");

            var bitmap = capturer.GetBitmap(capturer.Rect.Width, capturer.Rect.Height);

            using (var gr = Graphics.FromImage(bitmap))
            {
                Font       drawFont  = new Font("Arial", 10);
                SolidBrush drawBrush = new SolidBrush(Color.White);

                if (npcNameFinder.Npcs.Count > 0)
                {
                    using (var whitePen = new Pen(Color.White, 1))
                    {
                        gr.DrawRectangle(whitePen, npcNameFinder.Area);

                        npcNameFinder.Npcs.ForEach(n =>
                        {
                            npcNameTargeting.locTargetingAndClickNpc.ForEach(l =>
                            {
                                gr.DrawEllipse(whitePen, l.X + n.ClickPoint.X, l.Y + n.ClickPoint.Y, 5, 5);
                            });
                        });


                        npcNameFinder.Npcs.ForEach(n => gr.DrawRectangle(whitePen, new Rectangle(n.Min, new Size(n.Width, n.Height))));
                        npcNameFinder.Npcs.ForEach(n => gr.DrawString(npcNameFinder.Npcs.IndexOf(n).ToString(), drawFont, drawBrush, new PointF(n.Min.X - 20f, n.Min.Y)));
                    }
                }
            }

            npcNameFinder.Npcs.ForEach(n =>
            {
                logger.LogInformation($"{npcNameFinder.Npcs.IndexOf(n),2} -> rect={new Rectangle(n.Min.X, n.Min.Y, n.Width, n.Height)} ClickPoint={{{n.ClickPoint.X,4},{n.ClickPoint.Y,4}}}");
            });

            logger.LogInformation("\n");

            bitmap.Save("target_names.png");
        }
Beispiel #4
0
        public override async Task PerformAction()
        {
            WowPoint lastPosition = playerReader.PlayerLocation;

            Log("Search for corpse");
            npcNameFinder.ChangeNpcType(NpcNameFinder.NPCType.Corpse);

            await stopMoving.Stop();

            await npcNameFinder.WaitForNUpdate(1);

            bool lootSuccess = await npcNameFinder.FindByCursorType(Cursor.CursorClassification.Loot);

            if (lootSuccess)
            {
                Log("Found corpse - interact with it");
                await playerReader.WaitForNUpdate(1);

                if (classConfiguration.Skin)
                {
                    var targetSkinnable = !playerReader.Unskinnable;
                    AddEffect(GoapKey.shouldskin, targetSkinnable);
                    Log($"Should skin ? {targetSkinnable}");
                    SendActionEvent(new ActionEventArgs(GoapKey.shouldskin, targetSkinnable));
                }

                bool hadToMove = false;
                if (IsPlayerMoving(lastPosition))
                {
                    hadToMove = true;
                    Log("Goto corpse - Wait till player become stil!");
                }

                while (IsPlayerMoving(lastPosition))
                {
                    lastPosition = playerReader.PlayerLocation;
                    if (!await Wait(100, DiDEnteredCombat()))
                    {
                        await AquireTarget();

                        return;
                    }
                }

                // TODO: damn spell batching
                // arriving to the corpse min distance to interact location
                // and says you are too far away
                // so have to wait and retry the action
                // at this point the player have a target
                // might be a good idea to check the last error message :shrug:
                if (hadToMove)
                {
                    if (!await Wait(200, DiDEnteredCombat()))
                    {
                        await AquireTarget();

                        return;
                    }
                }


                await input.TapInteractKey("Approach corpse");

                // TODO: find a better way to get notified about the successful loot
                // challlange:
                // - the mob might have no loot at all so cant check inventory change
                // - loot window could be checked

                /*
                 * if (!await Wait(400, DiDEnteredCombat()))
                 * {
                 *  await AquireTarget();
                 *  return;
                 * }
                 */
                Log("Loot Successfull");

                await GoalExit();
            }
            else
            {
                Log($"No corpse found - Npc Count: {npcNameFinder.NpcCount}");

                if (!await Wait(100, DiDEnteredCombat()))
                {
                    await AquireTarget();
                }
                else
                {
                    await GoalExit();
                }
            }
        }
Beispiel #5
0
 public void ChangeNpcType(NpcNames npcNames)
 {
     npcNameFinder.ChangeNpcType(npcNames);
 }
        public override async Task PerformAction()
        {
            Log("Try to find Corpse");
            npcNameFinder.ChangeNpcType(NpcNameFinder.NPCType.Corpse);

            await stopMoving.Stop();

            // TODO: have to wait for the cursor to switch from loot -> skinning
            // sometimes takes a lot of time
            await npcNameFinder.WaitForNUpdate(1);

            if (await DiDEnteredCombat())
            {
                await AquireTarget();

                return;
            }

            Log("Found corpses: " + npcNameFinder.NpcCount);
            WowPoint lastPosition = playerReader.PlayerLocation;
            bool     skinSuccess  = await npcNameFinder.FindByCursorType(Cursor.CursorClassification.Skin);

            if (skinSuccess)
            {
                await Wait(100, () => false);

                if (IsPlayerMoving(lastPosition))
                {
                    Log("Goto corpse - Wait till the player become stil!");
                }

                while (IsPlayerMoving(lastPosition))
                {
                    lastPosition = playerReader.PlayerLocation;
                    if (!await Wait(100, DiDEnteredCombat()))
                    {
                        await AquireTarget();

                        return;
                    }
                }

                await input.TapInteractKey("Skinning Attempt...");

                do
                {
                    await playerReader.WaitForNUpdate(1);

                    if (await DiDEnteredCombat())
                    {
                        await AquireTarget();

                        return;
                    }
                } while (playerReader.IsCasting);

                // Wait for to update the LastUIErrorMessage
                await playerReader.WaitForNUpdate(1);

                var lastError = this.playerReader.LastUIErrorMessage;
                if (lastError != UI_ERROR.ERR_SPELL_FAILED_S)
                {
                    this.playerReader.LastUIErrorMessage = UI_ERROR.NONE;
                    logger.LogDebug("Skinning Successful!");
                    await GoalExit();
                }
                else
                {
                    logger.LogDebug("Skinning Failed! Retry...");
                }
            }
            else
            {
                logger.LogDebug($"Target is not skinnable - NPC Count: {npcNameFinder.NpcCount}");
                await GoalExit();
            }
        }