Пример #1
0
        private static async Task Click()
        {
            StuckDetection.Reset();
            await Wait.LatencySleep();

            var target = LokiPoe.InGameState.CurrentTarget;

            if (target != null)
            {
                GlobalLog.Info($"[HandleBlockingChestsTask] \"{target.Name}\" ({target.Id}) is under the cursor. Now clicking on it.");
                LokiPoe.Input.PressLMB();
                await Coroutines.FinishCurrentAction(false);
            }
        }
Пример #2
0
        /// <summary>
        /// Runs a task.
        /// </summary>
        /// <returns>true if the task ran and false otherwise.</returns>
        public async Task <bool> Run()
        {
            StuckDetection.Reset();             // We don't want StuckDetection logic running really.

            var leader = Leader;
            var me     = LokiPoe.Me;

            // If we don't have the leader in view, let's try to guess what they did.
            if (leader == null)
            {
                // If we've at least seen the leader once, first try moving to where they were last seen.
                if (_leaderData.LastKnownPosition != Vector2i.Zero)
                {
                    // Move closer to their last known position if we're out of range.
                    if (me.Position.Distance(_leaderData.LastKnownPosition) > 20)
                    {
                        // First, make sure we can actually get to the player's last known position before trying to move there.
                        if (ExilePather.PathExistsBetween(me.Position, _leaderData.LastKnownPosition, true))
                        {
                            // Just move to the location.
                            if (!PlayerMoverManager.MoveTowards(_leaderData.LastKnownPosition))
                            {
                                Log.Error($"[FollowerTask] PlayerMoverManager.MoveTowards failed for {_leaderData.LastKnownPosition}.");
                            }
                        }
                    }

                    // Clear the data so we don't run again.
                    _leaderData.LastKnownPosition = Vector2i.Zero;
                }

                // We have to decide which we want to use based on distance.
                if (_leaderData.LabyrinthReturnPortal != null && _leaderData.LastAreaTransition != null)
                {
                    if (_leaderData.LabyrinthReturnPortal.Distance < _leaderData.LastAreaTransition.Distance)
                    {
                        // Check to see if we saw the player near an area transition or the exit portal
                        if (await HandleLabyrinthReturnPortal())
                        {
                            return(true);
                        }
                    }
                    else
                    {
                        // Check to see if we saw the player near an area transition or the exit portal
                        if (await HandleLastAreaTransition())
                        {
                            return(true);
                        }
                    }
                }
                else                 // Order doesn't matter
                {
                    // Check to see if we saw the player near an area transition or the exit portal
                    if (await HandleLastAreaTransition())
                    {
                        return(true);
                    }

                    // Check to see if we saw the player near an area transition or the exit portal
                    if (await HandleLabyrinthReturnPortal())
                    {
                        return(true);
                    }
                }

                Log.Warn("[TODO 1]");

                return(true);
            }

            // Check to see if were within range. If so, return, as we have nothing else to do here.
            if (leader.Distance <= FollowerSettings.Instance.FollowDistance)
            {
                return(true);
            }

            // Otherwise, first check to see if a path exists between us and the leader, this is mostly to handle transitions
            if (ExilePather.PathExistsBetween(me.Position, leader.Position, true))
            {
                var leaderDistance = leader.Distance;

                // If there's an area transition closer to us than the leader, it's a special boss one,
                // but we don't need to stop the bot really, we can just sit and wait until it opens. Unless
                // we want the character to take it, in which case we can add that logic s well.
                if (LokiPoe.ObjectManager.Objects.OfType <AreaTransition>().Any(at => StringHelper.IsArenaTransition(at) && at.Distance < leaderDistance && at.IsTargetable))
                {
                    return(true);
                }

                // Just move to towards the player.
                if (!PlayerMoverManager.MoveTowards(leader.Position))
                {
                    // We can't do much other than log the error and let the user fix the issue.
                    Log.Error($"[FollowerTask] PlayerMoverManager.MoveTowards failed for {leader.Position}.");
                }

                // Nothing else to do.
                return(true);
            }

            // Check to see if we saw the player near an area transition.
            if (await HandleLastAreaTransition())
            {
                return(true);
            }

            Log.Warn("[TODO 2]");

            // This task takes control over QB/MB, so it should always return true;
            return(true);
        }
Пример #3
0
 public static async Task StuckDetectionSleep(int ms)
 {
     StuckDetection.Reset();
     await Coroutine.Sleep(ms);
 }