Esempio n. 1
0
        private async Task <bool> Searching()
        {
            if (_objectiveLocation == Vector3.Zero)
            {
                ScanForObjective();
            }

            if (_objectiveLocation != Vector3.Zero)
            {
                _nearestScene = Core.Scenes.CurrentWorldScenes.OrderBy(s => s.Center.Distance(_objectiveLocation.ToVector2())).FirstOrDefault();
                if (_nearestScene != null && DateTime.UtcNow > _nearestSceneCooldown && ExplorationData.FortressWorldIds.Contains(AdvDia.CurrentWorldId))
                {
                    State = States.MovingToNearestScene;
                }

                NavigationCoroutine.Reset();
                State = States.Moving;
                return(false);
            }

            //if (_prioritizeExitScene && !_exitSceneUnreachable && Core.Scenes.CurrentWorldSceneIds.Any(s => s.Contains("Exit")))
            //{
            //    var exitScene = Core.Scenes.CurrentWorldScenes.FirstOrDefault(s => s.Name.Contains("Exit"));
            //    if (exitScene != null)
            //    {
            //        var centerNode =
            //            exitScene.Nodes.Where(n=>n.HasEnoughNavigableCells).OrderBy(n => n.Center.DistanceSqr(exitScene.Center)).FirstOrDefault();
            //        if (centerNode != null)
            //        {
            //            _exitSceneLocation = centerNode.NavigableCenter;
            //            Core.Logger.Debug("[EnterLevelArea] Moving to exit scene");
            //            State=States.MovingToExitScene;
            //            return false;
            //        }
            //    }
            //}

            if (!await ExplorationCoroutine.Explore(BountyData.LevelAreaIds))
            {
                return(false);
            }

            Core.Logger.Debug("[EnterLevelAreaCoroutine] Finished Searching.");

            Core.Scenes.Reset();
            return(false);
        }
Esempio n. 2
0
 private bool NotStarted()
 {
     NavigationCoroutine.Reset();
     State = States.Moving;
     return(false);
 }
Esempio n. 3
0
        private async Task <bool> Moving()
        {
            if (_deathGateLocation != Vector3.Zero)
            {
                if (!await NavigationCoroutine.MoveTo(_deathGateLocation, 5))
                {
                    return(false);
                }

                _deathGateLocation = Vector3.Zero;
            }

            if (!await NavigationCoroutine.MoveTo(_objectiveLocation, 5))
            {
                return(false);
            }

            if (NavigationCoroutine.LastMoveResult == MoveResult.UnstuckAttempt)
            {
                Core.Logger.Debug("Navigation ended with unstuck attempts last result.");
                Navigator.Clear();
            }

            if (AdvDia.MyPosition.Distance(_objectiveLocation) > 50 && NavigationCoroutine.LastResult == CoroutineResult.Failure)
            {
                Core.Logger.Debug("[EnterLevelAreaCoroutine] Navigation ended, extending scan radius to continue searching.");
                NavigationCoroutine.Reset();
                _previouslyFoundLocation       = _objectiveLocation;
                _returnTimeForPreviousLocation = PluginTime.CurrentMillisecond;
                _objectiveLocation             = Vector3.Zero;
                _objectiveScanRange            = ActorFinder.LowerSearchRadius(_objectiveScanRange);
                if (_objectiveScanRange <= 0)
                {
                    _objectiveScanRange = 50;
                }
                State = States.Searching;
                return(false);
            }

            DiaGizmo portal = null;

            if (_portalActorIds != null)
            {
                foreach (var portalid in _portalActorIds)
                {
                    portal = ActorFinder.FindGizmo(portalid);
                    if (portal != null)
                    {
                        _portalActorId = portal.ActorSnoId;
                        break;
                    }
                }
            }
            else
            {
                portal = ActorFinder.FindGizmo(_portalActorId);
            }

            if (portal == null)
            {
                portal = BountyHelpers.GetPortalNearPosition(_objectiveLocation);
                if (portal != null)
                {
                    _discoveredPortalActorId = portal.ActorSnoId;
                }
                else if (_portalActorId == 0)
                {
                    portal = ZetaDia.Actors.GetActorsOfType <GizmoPortal>().OrderBy(d => d.Distance).FirstOrDefault();
                    if (portal != null)
                    {
                        _discoveredPortalActorId = portal.ActorSnoId;
                        Core.Logger.Log($"[EnterLevelArea] Unable to find the portal we needed, using this one instead {portal.Name} ({portal.ActorSnoId})");
                    }
                }
            }

            if (portal == null)
            {
                State = States.Searching;
                return(false);
            }

            _interactRange = portal.CollisionSphere.Radius;
            // Add some tolerance, sometimes the radius is pretty low and it will keep stuck trying to move to it even when it's right besides it.
            _interactRange += ZetaDia.Me.CollisionSphere.Radius;

            Core.Logger.Debug($"[EnterLevelArea] Using interact range from portal: {_interactRange}");

            if (portal.Position.Distance(_objectiveLocation) > _interactRange)
            {
                Core.Logger.Debug($"[EnterLevelArea] Portal is still too far away, something went wrong with NavigationCoroutine");
                await CommonCoroutines.MoveTo(portal.Position);

                State = States.Searching;
                return(false);
            }

            _objectiveLocation = portal.Position;
            State = States.Entering;
            _prePortalWorldDynamicId = AdvDia.CurrentWorldDynamicId;

            Core.PlayerMover.MoveTowards(portal.Position);
            await Coroutine.Sleep(1000);

            return(false);
        }