private async Task <bool> ScanForObjective() { if (PluginTime.ReadyToUse(_lastScanTime, 1000)) { _lastScanTime = PluginTime.CurrentMillisecond; if (_actorId != 0) { //var objectiveActor = BountyHelpers.ScanForActor(_actorId, _objectiveScanRange, _actorSelector); var objectiveActor = ActorFinder.FindActor(_actorId, _markerId, 500, "", _actorSelector); if (objectiveActor != null) { _objectiveLocation = objectiveActor.Position; if (_stopDistance == -1) { _stopDistance = objectiveActor.Radius; } } else { _objectiveLocation = Vector3.Zero; } } if (_objectiveLocation != Vector3.Zero) { Core.Logger.Log($"[MoveToObject] Found the objective at distance {AdvDia.MyPosition.Distance(_objectiveLocation)}"); } } return(true); }
private void ScanForObjective() { if (_previouslyFoundLocation != Vector3.Zero && PluginTime.ReadyToUse(_returnTimeForPreviousLocation, 60000)) { _objectiveLocation = _previouslyFoundLocation; _previouslyFoundLocation = Vector3.Zero; Core.Logger.Debug("[KillUniqueMonster] Returning previous objective location."); return; } if (PluginTime.ReadyToUse(_lastScanTime, 1000)) { _lastScanTime = PluginTime.CurrentMillisecond; if (_marker != 0) { _objectiveLocation = BountyHelpers.ScanForMarkerLocation(_marker, _objectiveScanRange); } if (_objectiveLocation == Vector3.Zero && _actorId != 0) { _objectiveLocation = BountyHelpers.ScanForActorLocation(_actorId, _objectiveScanRange); } if (_objectiveLocation != Vector3.Zero) { using (new PerformanceLogger("[KillUniqueMonster] Path to Objective Check", true)) { Core.Logger.Log("[KillUniqueMonster] Found the objective at distance {0}", AdvDia.MyPosition.Distance(_objectiveLocation)); ExplorationHelpers.SetExplorationPriority(_objectiveLocation); } } } }
private void ScanForObjective() { if (_previouslyFoundLocation != Vector3.Zero && PluginTime.ReadyToUse(_returnTimeForPreviousLocation, 60000)) { _objectiveLocation = _previouslyFoundLocation; _previouslyFoundLocation = Vector3.Zero; _returnTimeForPreviousLocation = PluginTime.CurrentMillisecond; Logger.Debug("[EnterLevelArea] Returning previous objective location."); return; } if (PluginTime.ReadyToUse(_lastScanTime, 250)) { _lastScanTime = PluginTime.CurrentMillisecond; if (_portalMarker != 0) { _objectiveLocation = BountyHelpers.ScanForMarkerLocation(_portalMarker, _objectiveScanRange); } // Belial if (_objectiveLocation == Vector3.Zero && _portalActorId == 159574) { _objectiveLocation = BountyHelpers.ScanForActorLocation(_portalActorId, _objectiveScanRange); } //if (_objectiveLocation == Vector3.Zero && _portalActorId != 0) //{ // _objectiveLocation = BountyHelpers.ScanForActorLocation(_portalActorId, _objectiveScanRange); //} if (_objectiveLocation != Vector3.Zero) { Logger.Info("[EnterLevelArea] Found the objective at distance {0}", AdvDia.MyPosition.Distance2D(_objectiveLocation)); } } }
private void ScanForObjective() { if (PluginTime.ReadyToUse(_lastScanTime, 1000)) { _lastScanTime = PluginTime.CurrentMillisecond; if (_actorId != 0) { _objectiveLocation = BountyHelpers.ScanForActorLocation(_actorId, _objectiveScanRange); } if (_objectiveLocation != Vector3.Zero) { using (new PerformanceLogger("[MoveToObject] Path to Objective Check", true)) { //if ((Navigator.GetNavigationProviderAs<DefaultNavigationProvider>().CanFullyClientPathTo(_objectiveLocation))) //{ Logger.Info("[MoveToObject] Found the objective at distance {0}", AdvDia.MyPosition.Distance2D(_objectiveLocation)); //} //else //{ // Logger.Debug("[MoveToObject] Found the objective at distance {0}, but cannot get a path to it.", // AdvDia.MyPosition.Distance2D(_objectiveLocation)); // _objectiveLocation = Vector3.Zero; //} } } } }
private void ScanForObjective() { if (_previouslyFoundLocation != Vector3.Zero && PluginTime.ReadyToUse(_returnTimeForPreviousLocation, 60000)) { _objectiveLocation = _previouslyFoundLocation; _previouslyFoundLocation = Vector3.Zero; Logger.Debug("[MoveToScenePosition] Returning previous objective location."); return; } if (PluginTime.ReadyToUse(_lastScanTime, 1000)) { _lastScanTime = PluginTime.CurrentMillisecond; if (!string.IsNullOrEmpty(_sceneName)) { var scene = ScenesStorage.CurrentWorldScenes.OrderBy(s => s.Center.DistanceSqr(AdvDia.MyPosition.ToVector2())).FirstOrDefault(s => s.Name.Contains(_sceneName)); if (scene != null) { _worldScene = scene; _objectiveLocation = _worldScene.GetWorldPosition(_position); } } else if (!string.IsNullOrEmpty(_tempSceneName)) { var scene = ScenesStorage.CurrentWorldScenes.OrderBy(s => s.Center.DistanceSqr(AdvDia.MyPosition.ToVector2())).FirstOrDefault(s => s.Name == _tempSceneName); if (scene != null) { _worldScene = scene; _objectiveLocation = _worldScene.GetWorldPosition(_position); } } //if (_objectiveLocation == Vector3.Zero && _actorId != 0) //{ // _objectiveLocation = BountyHelpers.ScanForActorLocation(_actorId, _objectiveScanRange); //} if (_objectiveLocation != Vector3.Zero) { using (new PerformanceLogger("[MoveToScenePosition] Path to Objective Check", true)) { //if ((Navigator.GetNavigationProviderAs<DefaultNavigationProvider>().CanFullyClientPathTo(_objectiveLocation))) //{ Logger.Info("[MoveToScenePosition] Found the objective at distance {0}", AdvDia.MyPosition.Distance2D(_objectiveLocation)); //} //else //{ // Logger.Debug("[MoveToMapMarker] Found the objective at distance {0}, but cannot get a path to it.", // AdvDia.MyPosition.Distance2D(_objectiveLocation)); // _objectiveLocation = Vector3.Zero; //} } } } }
public static void Pulse() { if (PluginTime.ReadyToUse(_lastPulseTime, 2000)) { _lastPulseTime = PluginTime.CurrentMillisecond; var gameId = ZetaDia.Service.CurrentGameId; foreach (var bountyStatistic in Stats.Where(s => !(s.IsCompleted || s.IsFailed) && s.GameId == gameId)) { bountyStatistic.LastSeen = DateTime.UtcNow; } } }
private void ScanForObjective() { if (_previouslyFoundLocation != Vector3.Zero && PluginTime.ReadyToUse(_returnTimeForPreviousLocation, 60000)) { _objectiveLocation = _previouslyFoundLocation; _previouslyFoundLocation = Vector3.Zero; _returnTimeForPreviousLocation = PluginTime.CurrentMillisecond; Logger.Debug("[MoveToMapMarker] Returning previous objective location."); return; } if (PluginTime.ReadyToUse(_lastScanTime, 1000)) { _lastScanTime = PluginTime.CurrentMillisecond; if (_marker != 0) { if (_marker == -1) { _objectiveLocation = BountyHelpers.ScanForMarkerLocation(0, _objectiveScanRange); } else { _objectiveLocation = BountyHelpers.ScanForMarkerLocation(_marker, _objectiveScanRange); } } //if (_objectiveLocation == Vector3.Zero && _actorId != 0) //{ // _objectiveLocation = BountyHelpers.ScanForActorLocation(_actorId, _objectiveScanRange); //} if (_objectiveLocation != Vector3.Zero) { using (new PerformanceLogger("[MoveToMapMarker] Path to Objective Check", true)) { //if ((Navigator.GetNavigationProviderAs<DefaultNavigationProvider>().CanFullyClientPathTo(_objectiveLocation))) //{ Logger.Info("[MoveToMapMarker] Found the objective at distance {0}", AdvDia.MyPosition.Distance2D(_objectiveLocation)); //} //else //{ // Logger.Debug("[MoveToMapMarker] Found the objective at distance {0}, but cannot get a path to it.", // AdvDia.MyPosition.Distance2D(_objectiveLocation)); // _objectiveLocation = Vector3.Zero; //} } } } }
private void ScanForObjective() { if (_previouslyFoundLocation != Vector3.Zero && PluginTime.ReadyToUse(_returnTimeForPreviousLocation, 60000)) { _objectiveLocation = _previouslyFoundLocation; _previouslyFoundLocation = Vector3.Zero; _returnTimeForPreviousLocation = PluginTime.CurrentMillisecond; Core.Logger.Debug("Returning previous objective location."); return; } if (PluginTime.ReadyToUse(_lastScanTime, 1000)) { _lastScanTime = PluginTime.CurrentMillisecond; TrinityMarker marker = null; if (_markerHash != 0) { if (_markerHash == -1) { marker = BountyHelpers.ScanForMarker(0, _objectiveScanRange); } else { marker = BountyHelpers.ScanForMarker(_markerHash, _markerType, _objectiveScanRange); } } else if (!string.IsNullOrEmpty(_markerName)) { marker = BountyHelpers.ScanForMarker(_markerName, _objectiveScanRange); } else if (_markerType != default(WorldMarkerType)) { marker = BountyHelpers.ScanForMarker(_markerType, _objectiveScanRange); } if (marker != null && marker.Position != Vector3.Zero) { _objectiveLocation = marker.Position; Core.Logger.Log($"[MoveToMapMarker] Found the objective {marker}"); ExplorationHelpers.SetExplorationPriority(_objectiveLocation); } _objectiveLocation = marker?.Position ?? Vector3.Zero; } }
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) { _objectiveLocation = BountyHelpers.ScanForActorLocation(_actorId, _objectiveScanRange); } if (_objectiveLocation != Vector3.Zero) { Logger.Info("[InteractWithUnit] Found the objective at distance {0}", AdvDia.MyPosition.Distance2D(_objectiveLocation)); } } }
private void ScanForObjective() { if (_previouslyFoundLocation != Vector3.Zero && PluginTime.ReadyToUse(_returnTimeForPreviousLocation, 60000)) { _objectiveLocation = _previouslyFoundLocation; _previouslyFoundLocation = Vector3.Zero; Core.Logger.Debug("[MoveToScene] Returning previous objective location."); return; } if (PluginTime.ReadyToUse(_lastScanTime, 1000)) { _lastScanTime = PluginTime.CurrentMillisecond; if (!string.IsNullOrEmpty(SceneName)) { _scene = Core.Scenes.CurrentWorldScenes.OrderBy(s => s.Center.DistanceSqr(AdvDia.MyPosition.ToVector2())).FirstOrDefault(s => s.Name.ToLowerInvariant().Contains(SceneName.ToLowerInvariant()) || s.HasChild && s.SubScene.Name.ToLowerInvariant().Contains(SceneName.ToLowerInvariant())); var centerNode = _scene?.Nodes.Where(n => n.HasEnoughNavigableCells) .OrderBy(n => n.Center.DistanceSqr(_scene.Center)) .FirstOrDefault(); if (centerNode != null) { _objectiveLocation = centerNode.NavigableCenter; } } if (_objectiveLocation != Vector3.Zero && PluginTime.ReadyToUse(_lastObjectiveFoundTime, 20000)) { _lastObjectiveFoundTime = PluginTime.CurrentMillisecond; using (new PerformanceLogger("[MoveToScene] Path to Objective Check", true)) { Core.Logger.Log("[MoveToScene] Found the objective at distance {0}", AdvDia.MyPosition.Distance(_objectiveLocation)); ExplorationHelpers.SetExplorationPriority(_objectiveLocation); } } else { _objectiveLocation = Vector3.Zero; } } }
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 void ScanForObjective() { //if (_previouslyFoundLocation != Vector3.Zero && PluginTime.ReadyToUse(_returnTimeForPreviousLocation, 60000)) //{ // _objectiveLocation = _previouslyFoundLocation; // _previouslyFoundLocation = Vector3.Zero; // Core.Logger.Debug("[MoveToScenePosition] Returning previous objective location."); // return; //} if (PluginTime.ReadyToUse(_lastScanTime, 1000)) { _lastScanTime = PluginTime.CurrentMillisecond; if (_sceneSnoId > 0) { var scene = Core.Scenes.CurrentWorldScenes.OrderBy(s => s.Center.DistanceSqr(AdvDia.MyPosition.ToVector2())).FirstOrDefault(s => s.SnoId == _sceneSnoId || s.HasChild && s.SubScene.SnoId == _sceneSnoId); if (scene != null) { _worldScene = scene; _objectiveLocation = _worldScene.GetWorldPosition(_position); ExplorationHelpers.SetExplorationPriority(_objectiveLocation); Core.Logger.Debug($"Scan found target scene by SnoId {_worldScene.Name} ({_worldScene.SnoId}). Pos={_objectiveLocation} Dist={_objectiveLocation.Distance(AdvDia.MyPosition)} Relative={_position}"); } } else if (!string.IsNullOrEmpty(_sceneName)) { var scene = Core.Scenes.CurrentWorldScenes.OrderBy( s => s.Center.DistanceSqr(AdvDia.MyPosition.ToVector2())) .FirstOrDefault( s => s.Name.ToLowerInvariant().Contains(_sceneName.ToLowerInvariant()) || s.SubScene != null && s.SubScene.Name.ToLowerInvariant().Contains(_sceneName.ToLowerInvariant()) ); if (scene != null) { _worldScene = scene; _objectiveLocation = _worldScene.GetWorldPosition(_position); ExplorationHelpers.SetExplorationPriority(_objectiveLocation); Core.Logger.Debug($"Scan found target scene {_worldScene.Name} ({_worldScene.SnoId}). Pos={_objectiveLocation} Dist={_objectiveLocation.Distance(AdvDia.MyPosition)} Relative={_position}"); } } if (!Core.Scenes.CurrentScene.IsConnected(_objectiveLocation)) { Core.Logger.Debug($"Unable to reach the scene, we need to uncover more intermediary scenes first"); _objectiveLocation = Vector3.Zero; } //else if (!string.IsNullOrEmpty(_tempSceneName)) //{ // var scene = Core.Scenes.CurrentWorldScenes.OrderBy(s => s.Center.DistanceSqr(AdvDia.MyPosition.ToVector2())).FirstOrDefault(s => s.Name == _tempSceneName); // if (scene != null) // { // _worldScene = scene; // _objectiveLocation = _worldScene.GetWorldPosition(_position); // } //} //if (_objectiveLocation == Vector3.Zero && _actorId != 0) //{ // _objectiveLocation = BountyHelpers.ScanForActorLocation(_actorId, _objectiveScanRange); //} //if (_objectiveLocation != Vector3.Zero) //{ // using (new PerformanceLogger("[MoveToScenePosition] Path to Objective Check", true)) // { // //if ((Navigator.GetNavigationProviderAs<Navigator>().CanFullyClientPathTo(_objectiveLocation))) // //{ // Core.Logger.Log("[MoveToScenePosition] Found the objective at distance {0}", // AdvDia.MyPosition.Distance(_objectiveLocation)); // //} // //else // //{ // // Core.Logger.Debug("[MoveToMapMarker] Found the objective at distance {0}, but cannot get a path to it.", // // AdvDia.MyPosition.Distance(_objectiveLocation)); // // _objectiveLocation = Vector3.Zero; // //} // } //} } }
private void ScanForObjective() { if (_previouslyFoundLocation != Vector3.Zero && PluginTime.ReadyToUse(_returnTimeForPreviousLocation, 60000)) { _objectiveLocation = _previouslyFoundLocation; _previouslyFoundLocation = Vector3.Zero; _returnTimeForPreviousLocation = PluginTime.CurrentMillisecond; Core.Logger.Debug("[EnterLevelArea] Returning previous objective location."); return; } if (PluginTime.ReadyToUse(_lastScanTime, 250)) { _lastScanTime = PluginTime.CurrentMillisecond; if (_portalMarker != 0) { if (_objectiveLocation == Vector3.Zero) { // Help with weighting exploration nodes even if its unreachable/unpathable. var markerlocation = BountyHelpers.ScanForMarkerLocation(_portalMarker, 5000); ExplorationHelpers.SetExplorationPriority(markerlocation); } _objectiveLocation = BountyHelpers.ScanForMarkerLocation(_portalMarker, _objectiveScanRange); if (ExplorationData.FortressLevelAreaIds.Contains(AdvDia.CurrentLevelAreaId)) { _deathGateLocation = DeathGates.GetBestGatePosition(_objectiveLocation); if (_deathGateLocation != Vector3.Zero) { if (Navigator.StuckHandler.IsStuck && _deathGateLocation.Distance(AdvDia.MyPosition) < 125f) { var nearestGate = ActorFinder.FindNearestDeathGate(); if (nearestGate != null) { Core.Logger.Warn("Found death gate location"); _objectiveLocation = nearestGate.Position; } } } } } if (_objectives != null && _objectives.Any()) { BountyHelpers.ObjectiveActor objective; _objectiveLocation = BountyHelpers.TryFindObjectivePosition(_objectives, _objectiveScanRange, out objective); if (objective != null) { _objective = objective; _portalActorId = objective.ActorId; _destinationWorldId = objective.DestWorldId; } } // Belial if (_objectiveLocation == Vector3.Zero && _portalActorId == 159574) { _objectiveLocation = BountyHelpers.ScanForActorLocation(_portalActorId, _objectiveScanRange); } //if (_objectiveLocation == Vector3.Zero && _portalActorId != 0) //{ // _objectiveLocation = BountyHelpers.ScanForActorLocation(_portalActorId, _objectiveScanRange); //} if (_objectiveLocation != Vector3.Zero) { Core.Logger.Log("[EnterLevelArea] Found the objective at distance {0}", AdvDia.MyPosition.Distance(_objectiveLocation)); ExplorationHelpers.SetExplorationPriority(_objectiveLocation); } } }
private async Task <bool> Moving() { var distanceToDestination = AdvDia.MyPosition.Distance(_destination); if (_destination != Vector3.Zero) { if (_distance != 0 && distanceToDestination <= _distance) { Navigator.PlayerMover.MoveStop(); MoveResult = MoveResult.ReachedDestination; } else { if (_mover == Mover.StraightLine && PluginTime.ReadyToUse(_lastRaywalkCheck, 200)) { if (!NavigationGrid.Instance.CanRayWalk(AdvDia.MyPosition, _destination)) { _mover = Mover.Navigator; } _lastRaywalkCheck = PluginTime.CurrentMillisecond; } switch (_mover) { case Mover.StraightLine: Navigator.PlayerMover.MoveTowards(_destination); MoveResult = MoveResult.Moved; return(false); case Mover.Navigator: MoveResult = await Navigator.MoveTo(_destination); break; } } switch (MoveResult) { case MoveResult.ReachedDestination: if ((_distance != 0 && distanceToDestination <= _distance) || distanceToDestination <= 7f) { Logger.Debug("[Navigation] Completed (Distance to destination: {0})", distanceToDestination); State = States.Completed; } else { _deathGate = ActorFinder.FindNearestDeathGate(_deathGateIgnoreList); if (_deathGate != null) { State = States.MovingToDeathGate; } else { State = States.Failed; MoveResult = MoveResult.Failed; } } return(false); case MoveResult.Failed: break; case MoveResult.PathGenerationFailed: var navProvider = Navigator.NavigationProvider as DefaultNavigationProvider; if (navProvider != null) { Logger.Debug("[Navigation] Path generation failed."); navProvider.Clear(); } if (distanceToDestination < 100 && NavigationGrid.Instance.CanRayWalk(AdvDia.MyPosition, _destination)) { _mover = Mover.StraightLine; return(false); } State = States.Failed; return(false); case MoveResult.UnstuckAttempt: if (_unstuckAttemps > 1) { State = States.Failed; return(false); } _unstuckAttemps++; Logger.Debug("[Navigation] Unstuck attempt #{0}", _unstuckAttemps); break; case MoveResult.PathGenerated: case MoveResult.Moved: break; case MoveResult.PathGenerating: if (_pathGenetionTimer.IsFinished) { Logger.Info("Patiently waiting for the Navigation Server"); _pathGenetionTimer.Reset(); } break; } return(false); } State = States.Completed; return(false); }