private async Task <bool> Moving() { if (!await NavigationCoroutine.MoveTo(_objectiveLocation, 7)) { return(false); } if (NavigationCoroutine.LastResult == CoroutineResult.Failure) { _objectiveLocation = Vector3.Zero; _objectiveScanRange = ActorFinder.LowerSearchRadius(_objectiveScanRange); if (_objectiveScanRange <= 0) { _objectiveScanRange = 50; } State = States.Searching; return(false); } var actor = ActorFinder.FindGizmo(_actorId); if (actor == null) { Core.Logger.Debug("No Gizmo Found."); State = States.Searching; return(false); } State = States.Interacting; _interactionCoroutine = new InteractionCoroutine(actor.ActorSnoId, new TimeSpan(0, 0, _secondsToTimeout), new TimeSpan(0, 0, _secondsToSleepAfterInteraction), _interactAttemps); if (!actor.IsInteractableQuestObject()) { Core.Logger.Error($"Unable to Interact with: {actor.Name} | Distance: {actor.Distance}. Whitelisting."); ActorFinder.InteractWhitelist.Add(actor.ActorSnoId); } return(false); }
private async Task <bool> Moving() { if (!await NavigationCoroutine.MoveTo(_objectiveLocation, 10)) { return(false); } if (NavigationCoroutine.LastResult == CoroutineResult.Failure) { _objectiveLocation = Vector3.Zero; _objectiveScanRange = ActorFinder.LowerSearchRadius(_objectiveScanRange); if (_objectiveScanRange <= 0) { _objectiveScanRange = 50; } State = States.Searching; return(false); } var actor = ActorFinder.FindGizmo(_actorId); if (actor == null) { State = States.Searching; return(false); } State = States.Interacting; _interactionCoroutine = new InteractionCoroutine(actor.ActorSNO, new TimeSpan(0, 0, _secondsToTimeout), new TimeSpan(0, 0, _secondsToSleepAfterInteraction), _interactAttemps); if (!actor.IsInteractableQuestObject()) { ActorFinder.InteractWhitelist.Add(actor.ActorSNO); } return(false); }
private async Task <bool> Interacting() { //if (_interactionCoroutine.State == InteractionCoroutine.States.NotStarted) //{ // var portalGizmo = BountyHelpers.GetPortalNearMarkerPosition(_markerPosition); // if (portalGizmo == null) // { // Core.Logger.Debug("[Bounty] No portal nearby, keep exploring ."); // State = States.SearchingForDestinationWorld; // return false; // } // _interactionCoroutine.DiaObject = portalGizmo; //} Core.Logger.Debug("[InteractWithGizmo] Starting interaction subroutine."); if (await _interactionCoroutine.GetCoroutine()) { ActorFinder.InteractWhitelist.Remove(_actorId); if (_interactionCoroutine.State == InteractionCoroutine.States.TimedOut) { Core.Logger.Error("[InteractWithGizmo] Interaction timed out."); State = States.Failed; return(false); } if (_useAll) { var nextGizmo = ActorFinder.FindGizmo(_actorId, gizmo => gizmo.IsInteractableQuestObject()); if (nextGizmo != null) { Core.Logger.Warn("Found another actor that needs some interaction. Dist={0}", nextGizmo.Distance); State = States.Searching; return(false); } } var actor = ActorFinder.FindGizmo(_actorId); if (actor == null) { Core.Logger.Log($"No Gizmo Found."); State = States.Failed; return(false); } if (await(MoveToAndInteract.Execute(actor))) { State = States.Completed; _interactionCoroutine = null; return(false); } } return(false); }
private async Task <bool> Moving() { if (!await NavigationCoroutine.MoveTo(_objectiveLocation, 12)) { return(false); } if (AdvDia.MyPosition.Distance(_objectiveLocation) > 30 && NavigationCoroutine.LastResult == CoroutineResult.Failure) { _previouslyFoundLocation = _objectiveLocation; _returnTimeForPreviousLocation = PluginTime.CurrentMillisecond; _objectiveLocation = Vector3.Zero; _objectiveScanRange = ActorFinder.LowerSearchRadius(_objectiveScanRange); if (_objectiveScanRange <= 0) { _objectiveScanRange = 50; } State = States.Searching; return(false); } var portal = ActorFinder.FindGizmo(_portalActorId); if (portal == null) { portal = BountyHelpers.GetPortalNearMarkerPosition(_objectiveLocation); if (_portalActorId == 0) { _discoveredPortalActorId = portal.ActorSNO; } //if (_portalActorId != portal.ActorSNO && BountyData.Act == Act.A5) //{ // Logger.Info("[EnterLevelArea] Was expecting to use portal SNO {0}, using {1} instead.", _portalActorId, portal.ActorSNO); // _portalActorId = portal.ActorSNO; //} } else { if (portal.Position.Distance(_objectiveLocation) > 15) { portal = null; } } if (portal == null) { State = States.Searching; return(false); } _objectiveLocation = portal.Position; State = States.Entering; _prePortalWorldDynamicId = AdvDia.CurrentWorldDynamicId; return(false); }
private void ScanForObjective() { if (PluginTime.ReadyToUse(_lastScanTime, 1000)) { _lastScanTime = PluginTime.CurrentMillisecond; if (_marker != 0) { _objectiveLocation = BountyHelpers.ScanForMarkerLocation(_marker, _objectiveScanRange); } if (_objectiveLocation == Vector3.Zero && _actorId != 0) { var actor = ActorFinder.FindGizmo(_actorId); if (actor != null && !actor.HasBeenOperated) { _objectiveLocation = BountyHelpers.ScanForActorLocation(_actorId, _objectiveScanRange); } } if (_objectiveLocation != Vector3.Zero) { Core.Logger.Log("[InteractWithGizmo] Found the objective at distance {0}", AdvDia.MyPosition.Distance(_objectiveLocation)); } } }
private async Task <bool> Searching() { if (_objectiveLocation == Vector3.Zero) { ScanForObjective(); } if (_objectiveLocation != Vector3.Zero) { // Special case for cursed chest events. if (_objectiveLocation.Distance(AdvDia.MyPosition) < 16f && _actorId == 365097 && ActorFinder.FindGizmo(364559) != null) { Core.Logger.Log("Target gizmo has transformed into invulnerable event gizmo. Ending."); State = States.Failed; return(false); } State = States.Moving; return(false); } if (!await ExplorationCoroutine.Explore(BountyData.LevelAreaIds)) { return(false); } Core.Scenes.Reset(); return(false); }
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); }