Ejemplo n.º 1
0
        public virtual async Task <bool> HandleBeforeCombat()
        {
            /* If standing on/nearby a portal, then assume it is intended to get in there. */
            if (!Core.Player.IsInRift &&
                BountyHelpers.GetPortalNearPosition(ZetaDia.Me.Position) != null)
            {
                Core.Logger.Debug("MainCombatTask Waiting for portal interaction");
                return(false);
            }

            // Wait after elite death until progression globe appears as a valid target or x time has passed.
            if (Core.Rift.IsInRift &&
                await Behaviors.WaitAfterUnitDeath.While(u => u.IsElite &&
                                                         u.Distance < 150 &&
                                                         Core.Targets.Entries.Any(a => a.IsElite &&
                                                                                  a.EliteType != EliteTypes.Minion &&
                                                                                  a.RadiusDistance < 60) &&
                                                         !Core.Targets.Any(p => p.Type == TrinityObjectType.ProgressionGlobe &&
                                                                           p.Distance < 150),
                                                         "Wait for Progression Globe", 1000))
            {
                return(true);
            }

            // Priority movement for progression globes. ** Temporary solution!
            if (TrinityCombat.Targeting.CurrentTarget != null)
            {
                if (await Behaviors.MoveToActor.While(a => a.Type == TrinityObjectType.ProgressionGlobe &&
                                                      !TrinityCombat.Weighting.ShouldIgnore(a) && !a.IsAvoidanceOnPath))
                {
                    return(true);
                }
            }

            // Priority interaction for doors. increases door opening reliability for some edge cases ** Temporary solution!
            if (ZetaDia.Storage.RiftStarted &&
                await Behaviors.MoveToInteract.While(a => a.Type == TrinityObjectType.Door &&
                                                     !a.IsUsed && a.Distance < a.CollisionRadius))
            {
                return(true);
            }

            return(false);
        }
Ejemplo n.º 2
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);
        }