/// <summary> /// Bookmark an entity /// </summary> /// <param name="entity"></param> /// <param name="name"></param> /// <param name="comment"></param> /// <param name="folderId"></param> /// <param name="corp"></param> /// <returns></returns> public bool BookmarkEntity(DirectEntity entity, string name, string comment, long?folderId, bool corp = false) { if (!entity.IsValid) { return(false); } if (!corp && Session.CharacterId == null) { return(false); } if (corp && Session.CorporationId == null) { return(false); } if (!corp) { return(DirectBookmark.BookmarkLocation(this, Session.CharacterId.Value, entity.Id, name, comment, entity.TypeId, Session.SolarSystemId, folderId)); } else { return(DirectBookmark.BookmarkLocation(this, Session.CorporationId.Value, entity.Id, name, comment, entity.TypeId, Session.SolarSystemId, folderId)); } }
public BookmarkDestination2(DirectBookmark bookmark) { if (bookmark == null) { Logging.Log("QuestorManager.BookmarkDestination", "Invalid bookmark destination!", Logging.White); SolarSystemId = Cache.Instance.DirectEve.Session.SolarSystemId ?? -1; BookmarkId = -1; return; } Logging.Log("QuestorManager.BookmarkDestination", "Destination set to bookmark [" + bookmark.Title + "]", Logging.White); DirectLocation location = GetBookmarkLocation(bookmark); if (location == null) { Logging.Log("QuestorManager.BookmarkDestination", "Invalid bookmark destination!", Logging.White); SolarSystemId = Cache.Instance.DirectEve.Session.SolarSystemId ?? -1; BookmarkId = -1; return; } BookmarkId = bookmark.BookmarkId ?? -1; SolarSystemId = location.SolarSystemId ?? Cache.Instance.DirectEve.Session.SolarSystemId ?? -1; }
public BookmarkDestination(DirectBookmark bookmark) { if (bookmark == null) { Logging.Log("Traveler.BookmarkDestination: Invalid bookmark destination!"); SolarSystemId = DirectEve.Instance.Session.SolarSystemId ?? -1; BookmarkId = -1; return; } Logging.Log("Traveler.BookmarkDestination: Destination set to bookmark [" + bookmark.Title + "]"); var location = GetBookmarkLocation(bookmark); if (location == null) { Logging.Log("Traveler.BookmarkDestination: Invalid bookmark destination!"); SolarSystemId = DirectEve.Instance.Session.SolarSystemId ?? -1; BookmarkId = -1; return; } BookmarkId = bookmark.BookmarkId ?? -1; SolarSystemId = location.SolarSystemId ?? DirectEve.Instance.Session.SolarSystemId ?? -1; }
internal static bool PerformFinalDestinationTask(DirectBookmark bookmark, int warpDistance, ref DateTime nextAction) { // The bookmark no longer exists, assume we are there if (bookmark == null) return true; var invType = Cache.Instance.InvTypesById[bookmark.TypeId ?? -1]; if (invType.GroupId == (int) Group.Station) // Let StationDestination handle it :) { var arrived = StationDestination.PerformFinalDestinationTask(bookmark.ItemId ?? -1, bookmark.Entity.Name, ref nextAction); if (arrived) Logging.Log("Traveler.BookmarkDestination: Arrived at bookmark [" + bookmark.Title + "]"); return arrived; } // Its not a station bookmark, make sure we are in space if (!Cache.Instance.InSpace && Cache.Instance.InStation) { // We are in a station, but not the correct station! if (nextAction < DateTime.Now) { Logging.Log("Traveler.BookmarkDestination: We're docked but our destination is in space, undocking"); Cache.Instance.DirectEve.ExecuteCommand(DirectCmd.CmdExitStation); nextAction = DateTime.Now.AddSeconds(30); } // We are not there yet return false; } if (!Cache.Instance.InSpace) { // We are not in space and not in a station, wait a bit return false; } // This bookmark has no x / y / z, assume we are there. if (bookmark.X == -1 || bookmark.Y == -1 || bookmark.Z == -1) { Logging.Log("Traveler.BookmarkDestination: Arrived at the bookmark [" + bookmark.Title + "][No XYZ]"); return true; } var distance = Cache.Instance.DistanceFromMe(bookmark.X ?? 0, bookmark.Y ?? 0, bookmark.Z ?? 0); if (distance < warpDistance) { Logging.Log("Traveler.BookmarkDestination: Arrived at the bookmark [" + bookmark.Title + "]"); return true; } if (nextAction > DateTime.Now) return false; Logging.Log("Traveler.BookmarkDestination: Warping to bookmark [" + bookmark.Title + "]"); bookmark.WarpTo(); nextAction = DateTime.Now.AddSeconds(30); return false; }
/// <summary> /// Create a bookmark folder /// </summary> /// <param name="name"></param> /// <returns></returns> public bool CreateCorpBookmarkFolder(string name) { if (Session.CorporationId == null) { return(false); } return(DirectBookmark.CreateBookmarkFolder(this, Session.CorporationId.Value, name)); }
static void OnFrame(object sender, EventArgs e) { if (DateTime.Now.Subtract(_lastPulse).TotalMilliseconds < 1500) return; _lastPulse = DateTime.Now; // New frame, invalidate old cache Cache.Instance.InvalidateCache(); if (Cache.Instance.InWarp) return; if (!_started) { _started = true; if (!Cache.Instance.DirectEve.Session.IsReady) { Logging.Log("GoToBM: Not in game, exiting"); return; } Logging.Log("GoToBM: Attempting to find bookmark [" + _BM + "]"); foreach (var bookmark in Cache.Instance.DirectEve.Bookmarks) { if (bookmark.Title.ToLower().Equals(_BM)) { _bookmark = bookmark; break; } if (_bookmark == null && bookmark.Title.ToLower().Contains(_BM)) { _bookmark = bookmark; } } if (_bookmark == null) { Logging.Log("GoToBM: Bookmark not found"); _done = true; return; } _traveler.Destination = new BookmarkDestination(_bookmark); } _traveler.ProcessState(); if (_traveler.State == TravelerState.AtDestination) { _done = true; Logging.Log("GoToBM: At destination"); } else if (_traveler.State == TravelerState.Error) { Logging.Log("GoToBM: Traveler error"); _done = true; } }
public BookmarkDestination(DirectBookmark bookmark) { if (bookmark == null) { Logging.Log("TravelerDestination.BookmarkDestination", "Invalid bookmark destination!", Logging.Red); SolarSystemId = Cache.Instance.DirectEve.Session.SolarSystemId ?? -1; BookmarkId = -1; return; } Logging.Log("TravelerDestination.BookmarkDestination", "Destination set to bookmark [" + Logging.Yellow + bookmark.Title + Logging.Green + "]", Logging.Green); BookmarkId = bookmark.BookmarkId ?? -1; SolarSystemId = bookmark.LocationId ?? -1; }
public BookmarkDestination(DirectBookmark bookmark) { if (bookmark == null) { Logging.Log("TravelerDestination.BookmarkDestination: Invalid bookmark destination!"); SolarSystemId = Cache.Instance.DirectEve.Session.SolarSystemId ?? -1; BookmarkId = -1; return; } Logging.Log("TravelerDestination.BookmarkDestination: Destination set to bookmark [" + bookmark.Title + "]"); BookmarkId = bookmark.BookmarkId ?? -1; SolarSystemId = bookmark.LocationId ?? -1; }
/// <summary> /// Bookmark the current location /// </summary> /// <param name="ownerId"></param> /// <param name="name"></param> /// <param name="comment"></param> /// <param name="folderId"></param> /// <returns></returns> internal bool BookmarkCurrentLocation(long ownerId, string name, string comment, long?folderId) { if (Session.StationId.HasValue) { var station = GetLocalSvc("station").Attribute("station"); if (!station.IsValid) { return(false); } return(DirectBookmark.BookmarkLocation(this, ownerId, (long)station.Attribute("stationID"), name, comment, (int)station.Attribute("stationTypeID"), (long?)station.Attribute("solarSystemID"), folderId)); } if (ActiveShip.Entity.IsValid && Session.SolarSystemId.HasValue) { return(DirectBookmark.BookmarkLocation(this, ownerId, ActiveShip.Entity.Id, name, comment, ActiveShip.Entity.TypeId, Session.SolarSystemId, folderId)); } return(false); }
internal static bool PerformFinalDestinationTask(long stationId, string stationName, ref DateTime nextAction, ref DirectBookmark localUndockBookmark) { if (Cache.Instance.InStation && Cache.Instance.DirectEve.Session.StationId == stationId) { Logging.Log("TravelerDestination.StationDestination", "Arrived in station", Logging.Green); return true; } if (Cache.Instance.InStation && DateTime.UtcNow > Cache.Instance.LastInSpace.AddSeconds(10)) { // We are in a station, but not the correct station! if (DateTime.UtcNow > Cache.Instance.NextUndockAction) { if (_undockAttempts > 10) { Logging.Log("TravelerDestination.StationDestination", "This is not the destination station, we have tried to undock [" + _undockAttempts + "] times - and it is evidentally not working (lag?) - restarting Questor (and EVE)", Logging.Green); Cache.Instance.SessionState = "Quitting"; //this will perform a graceful restart } Logging.Log("TravelerDestination.StationDestination", "This is not the destination station, undocking from [" + Cache.Instance.DirectEve.GetLocationName(Cache.Instance.DirectEve.Session.StationId ?? 0) + "]", Logging.Green); //if (!string.IsNullOrEmpty(Settings.Instance.UndockPrefix)) //{ // var bookmarks = Cache.Instance.BookmarksByLabel(Settings.Instance.UndockPrefix).OrderByDescending(b => b.CreatedOn).Where(b => b.LocationId == Cache.Instance.DirectEve.Session.SolarSystemId); // //var bookmarks = Cache.Instance.DirectEve.Bookmarks.Where(b => b.LocationId == Cache.Instance.DirectEve.Session.SolarSystemId).Where(b => b.Title.Contains(Settings.Instance.UndockPrefix)); //this does not handle more than one station undock bookmark per system and WILL likely warp to the wrong bm in that case // //var bookmarks = Cache.Instance.DirectEve.Bookmarks.Where(b => b.LocationId == Cache.Instance.DirectEve.Session.SolarSystemId).Where(b => b.Title.Contains(Cache.Instance.DirectEve.GetLocationName(Cache.Instance.DirectEve.Session.StationId ?? 0)) && b.Title.Contains(Settings.Instance.UndockPrefix)); // //var bookmarks = Cache.Instance.DirectEve.Bookmarks.Where(b => b.Title.Contains(Cache.Instance.DirectEve.GetLocationName(Cache.Instance.DirectEve.Session.StationId ?? 0)) && b.Title.Contains(Settings.Instance.UndockPrefix)); // if (bookmarks != null && bookmarks.Count() > 0) // { // localUndockBookmark = bookmarks.FirstOrDefault(); // if (localUndockBookmark.X == null || localUndockBookmark.Y == null || localUndockBookmark.Z == null) // { // Logging.Log("TravelerDestination.StationDestination: undock bookmark [" + localUndockBookmark.Title + "] is unusable: it has no coords"); // localUndockBookmark = null; // } // else Logging.Log("TravelerDestination.StationDestination: undock bookmark [" + localUndockBookmark.Title + "] is usable: it has coords"); // } // else Logging.Log("TravelerDestination.StationDestination: you do not have an undock bookmark that has the prefix: " + Settings.Instance.UndockPrefix + " in local"); //+ Cache.Instance.DirectEve.GetLocationName((long)Cache.Instance.DirectEve.Session.StationId) + " and " + Settings.Instance.UndockPrefix + " did not both exist in a bookmark"); //} //else Logging.Log("TravelerDestination.StationDestination: UndockPrefix is not configured"); Cache.Instance.DirectEve.ExecuteCommand(DirectCmd.CmdExitStation); _undockAttempts++; Cache.Instance.NextUndockAction = DateTime.UtcNow.AddSeconds(Time.Instance.TravelerExitStationAmIInSpaceYet_seconds); return false; } // We are not there yet return false; } if ((DateTime.UtcNow > Cache.Instance.LastInStation.AddSeconds(10)) && !Cache.Instance.InSpace) { // We are not in station and not in space? Wait for a bit return false; } if (nextAction > DateTime.UtcNow) return false; _undockAttempts = 0; if (localUndockBookmark != null) { double distance = Cache.Instance.DistanceFromMe(localUndockBookmark.X ?? 0, localUndockBookmark.Y ?? 0, localUndockBookmark.Z ?? 0); if (distance < (int)Distance.WarptoDistance) { Logging.Log("TravelerDestination.BookmarkDestination", "Arrived at undock bookmark [" + Logging.Yellow + localUndockBookmark.Title + Logging.Green + "]", Logging.White); localUndockBookmark = null; } else { Logging.Log("TravelerDestination.BookmarkDestination", "Warping to undock bookmark [" + Logging.Yellow + localUndockBookmark.Title + Logging.Green + "][" + Math.Round((distance / 1000) / 149598000, 2) + " AU away]", Logging.White); //if (!Combat.ReloadAll(Cache.Instance.EntitiesNotSelf.OrderBy(t => t.Distance).FirstOrDefault(t => t.Distance < (double)Distance.OnGridWithMe))) return false; localUndockBookmark.WarpTo(); nextAction = DateTime.UtcNow.AddSeconds(10); return false; } } //else Logging.Log("TravelerDestination.BookmarkDestination","undock bookmark missing: " + Cache.Instance.DirectEve.GetLocationName((long)Cache.Instance.DirectEve.Session.StationId) + " and " + Settings.Instance.UndockPrefix + " did not both exist in a bookmark"); EntityCache entity = Cache.Instance.EntitiesByName(stationName).FirstOrDefault(); if (entity == null) { // We are there but no station? Wait a bit return false; } if (entity.Distance < (int)Distance.DockingRange) { if (DateTime.UtcNow > Cache.Instance.NextDockAction) { Logging.Log("TravelerDestination.StationDestination", "Dock at [" + Logging.Yellow + entity.Name + Logging.Green + "] which is [" + Math.Round(entity.Distance / 1000, 0) + "k away]", Logging.Green); entity.Dock(); return false; } } else if (entity.Distance < (int)Distance.WarptoDistance) { if (DateTime.UtcNow > Cache.Instance.NextApproachAction) { Logging.Log("TravelerDestination.StationDestination", "Approaching[" + Logging.Yellow + entity.Name + Logging.Green + "] which is [" + Math.Round(entity.Distance / 1000, 0) + "k away]", Logging.Green); entity.Approach(); return false; } } else { if (DateTime.UtcNow > Cache.Instance.NextDockAction) { Logging.Log("TravelerDestination.StationDestination", "Warp to and dock at [" + Logging.Yellow + entity.Name + Logging.Green + "][" + Math.Round((entity.Distance / 1000) / 149598000, 2) + " AU away]", Logging.Green); entity.WarpToAndDock(); return false; } } nextAction = DateTime.UtcNow.AddSeconds(20); return false; }
/// <summary> /// Invalidate the cached items /// </summary> public void InvalidateCache() { try { // // this list of variables is cleared every pulse. // _activeDrones = null; _agent = null; _aggressed = null; _allBookmarks = null; _ammoHangar = null; _approaching = null; _activeDrones = null; _bestDroneTargets = null; _bestPrimaryWeaponTargets = null; _bigObjects = null; _bigObjectsAndGates = null; _combatTargets = null; _currentShipsCargo = null; _containerInSpace = null; _containers = null; _entities = null; _entitiesNotSelf = null; _entitiesOnGrid = null; _entitiesById.Clear(); _fittingManagerWindow = null; _gates = null; _IDsinInventoryTree = null; _itemHangar = null; _jumpBridges = null; _lootContainer = null; _lootHangar = null; _lpStore = null; _maxLockedTargets = null; _maxDroneRange = null; _maxrange = null; _maxTargetRange = null; _modules = null; _modulesAsItemCache = null; _myShipEntity = null; _objects = null; _potentialCombatTargets = null; _primaryWeaponPriorityTargetsPerFrameCaching = null; _safeSpotBookmarks = null; _star = null; _stations = null; _stargate = null; _stargates = null; _targets = null; _targeting = null; _targetedBy = null; _TotalTargetsandTargeting = null; _undockBookmark = null; _unlootedContainers = null; _unlootedWrecksAndSecureCans = null; _windows = null; _primaryWeaponPriorityEntities = null; _dronePriorityEntities = null; _preferredPrimaryWeaponTarget = null; //if (QuestorJustStarted && InvalidateCacheQuestorJustStartedFlag) //{ // InvalidateCacheQuestorJustStartedFlag = false; // if (Settings.Instance.DebugPreferredPrimaryWeaponTarget) Logging.Log("Cache.InvalidateCache", "QuestorJustStarted: initializing", Logging.Debug); if (_primaryWeaponPriorityTargets != null && _primaryWeaponPriorityTargets.Any()) { _primaryWeaponPriorityTargets.ForEach(pt => pt.ClearCache()); } if (_dronePriorityTargets != null && _dronePriorityTargets.Any()) { _dronePriorityTargets.ForEach(pt => pt.ClearCache()); } //} } catch (Exception exception) { Logging.Log("Cache.InvalidateCache", "Exception [" + exception + "]", Logging.Debug); } }
private static void OnFrame(object sender, EventArgs e) { if (DateTime.Now.Subtract(_lastPulse).TotalMilliseconds < 1500) return; _lastPulse = DateTime.Now; // New frame, invalidate old cache Cache.Instance.InvalidateCache(); Cache.Instance.LastFrame = DateTime.Now; // Session is not ready yet, do not continue if (!Cache.Instance.DirectEve.Session.IsReady) return; if (Cache.Instance.DirectEve.Session.IsReady) Cache.Instance.LastSessionIsReady = DateTime.Now; // We are not in space or station, don't do shit yet! if (!Cache.Instance.InSpace && !Cache.Instance.InStation) { Cache.Instance.NextInSpaceorInStation = DateTime.Now.AddSeconds(12); Cache.Instance.LastSessionChange = DateTime.Now; return; } if (DateTime.Now < Cache.Instance.NextInSpaceorInStation) return; // We always check our defense state if we're in space, regardless of questor state // We also always check panic if (Cache.Instance.InSpace) { if (!Cache.Instance.DoNotBreakInvul) { _defense.ProcessState(); } } // Start _cleanup.ProcessState // Description: Closes Windows, and eventually other things considered 'cleanup' useful to more than just Questor(Missions) but also Anomalies, Mining, etc // _cleanup.ProcessState(); // Done // Cleanup State: ProcessState if (Cache.Instance.InWarp) return; if (!_started) { _started = true; if (!Cache.Instance.DirectEve.Session.IsReady) { Logging.Log("GoToBM"," Not in game, exiting",Logging.white); return; } Logging.Log("GoToBM",": Attempting to find bookmark [" + _BM + "]",Logging.white); foreach (var bookmark in Cache.Instance.DirectEve.Bookmarks) { if (bookmark.Title.ToLower().Equals(_BM)) { _bookmark = bookmark; break; } if (_bookmark == null && bookmark.Title.ToLower().Contains(_BM)) { _bookmark = bookmark; } } if (_bookmark == null) { Logging.Log("GoToBM",": Bookmark not found",Logging.white); _done = true; return; } _traveler.Destination = new BookmarkDestination(_bookmark); } _traveler.ProcessState(); if (_States.CurrentTravelerState == TravelerState.AtDestination) { _done = true; Logging.Log("GoToBM"," At destination",Logging.white); } else if (_States.CurrentTravelerState == TravelerState.Error) { Logging.Log("GoToBM"," Traveler error",Logging.white); _done = true; } }
internal static bool PerformFinalDestinationTask2(DirectBookmark bookmark, int warpDistance, ref DateTime nextAction) { // The bookmark no longer exists, assume we are there if (bookmark == null) return true; DirectLocation location = GetBookmarkLocation(bookmark); if (Cache.Instance.DirectEve.Session.IsInStation) { // We have arrived if (location != null && location.ItemId == Cache.Instance.DirectEve.Session.StationId) return true; if (DateTime.UtcNow > Cache.Instance.LastInSpace.AddSeconds(45)) //do not try to leave the station until you have been docked for at least 45seconds! (this gives some overhead to load the station env + session change timer) { // We are apparently in a station that is incorrect Logging.Log("QuestorManager.BookmarkDestination", "We're docked in the wrong station, undocking", Logging.White); Cache.Instance.DirectEve.ExecuteCommand(DirectCmd.CmdExitStation); nextAction = DateTime.UtcNow.AddSeconds(30); return false; } return false; } // Is this a station bookmark? if (bookmark.Entity != null && bookmark.Entity.GroupId == (int)Group.Station) { bool arrived = StationDestination2.PerformFinalDestinationTask(bookmark.Entity.Id, bookmark.Entity.Name, ref nextAction); if (arrived) Logging.Log("QuestorManager.BookmarkDestination", "Arrived at bookmark [" + bookmark.Title + "]", Logging.White); return arrived; } // Its not a station bookmark, make sure we are in space if (Cache.Instance.DirectEve.Session.IsInStation) { // We are in a station, but not the correct station! if (nextAction < DateTime.UtcNow) { if (DateTime.UtcNow > Cache.Instance.LastInSpace.AddSeconds(45)) //do not try to leave the station until you have been docked for at least 45seconds! (this gives some overhead to load the station env + session change timer) { Logging.Log("QuestorManager.BookmarkDestination", "We're docked but our destination is in space, undocking", Logging.White); Cache.Instance.DirectEve.ExecuteCommand(DirectCmd.CmdExitStation); nextAction = DateTime.UtcNow.AddSeconds(30); } } // We are not there yet return false; } if (!Cache.Instance.DirectEve.Session.IsInSpace) { // We are not in space and not in a station, wait a bit return false; } // This bookmark has no x / y / z, assume we are there. if (bookmark.X == -1 || bookmark.Y == -1 || bookmark.Z == -1) { Logging.Log("QuestorManager.BookmarkDestination", "Arrived at the bookmark [" + Logging.Yellow + bookmark.Title + Logging.White + "][No XYZ]", Logging.White); return true; } double distance = Cache.Instance.DistanceFromMe(bookmark.X ?? 0, bookmark.Y ?? 0, bookmark.Z ?? 0); if (distance < warpDistance) { Logging.Log("QuestorManager.BookmarkDestination", "Arrived at the bookmark [" + Logging.Yellow + bookmark.Title + Logging.White + "]", Logging.White); return true; } if (nextAction > DateTime.UtcNow) return false; if (Cache.Instance.GateInGrid() && (distance / 1000) < (int)Distances.MaxPocketsDistanceKm) { Logging.Log("QuestorManager.BookmarkDestination", "Bookmark [" + Logging.Yellow + bookmark.Title + Logging.White + "][" + Logging.Yellow + Math.Round((distance / 1000) / 149598000, 2) + Logging.White + "] AU away. Which is [" + Logging.Yellow + Math.Round((distance / 1000), 2) + Logging.White + "].", Logging.White); } Logging.Log("QuestorManager.BookmarkDestination", "Warping to bookmark [" + Logging.Yellow + bookmark.Title + Logging.White + "][" + Math.Round((distance / 1000) / 149598000, 2) + "] AU away. Which is [" + Math.Round((distance / 1000), 2) + "]", Logging.White); bookmark.WarpTo(); nextAction = DateTime.UtcNow.AddSeconds(30); return false; }
/// <summary> /// Refresh the PnPWindow /// </summary> /// <returns></returns> public bool RefreshPnPWindow() { return(DirectBookmark.RefreshPnPWindow(this)); }
private static DirectLocation GetBookmarkLocation(DirectBookmark bookmark) { DirectLocation location = Cache.Instance.DirectEve.Navigation.GetLocation(bookmark.ItemId ?? -1); if (!location.IsValid) location = Cache.Instance.DirectEve.Navigation.GetLocation(bookmark.LocationId ?? -1); if (!location.IsValid) return null; return location; }
internal static bool PerformFinalDestinationTask(DirectBookmark bookmark, int warpDistance, ref DateTime nextAction, ref DirectBookmark undockBookmark) { // The bookmark no longer exists, assume we are not there if (bookmark == null) return false; if (Cache.Instance.DirectEve.Session.IsInStation) { // We have arrived if (bookmark.ItemId.HasValue && bookmark.ItemId == Cache.Instance.DirectEve.Session.StationId) return true; // We are apparently in a station that is incorrect Logging.Log("TravelerDestination.BookmarkDestination", "This is not the destination station, undocking", Logging.Green); //if (!string.IsNullOrEmpty(Settings.Instance.UndockPrefix)) //{ // var bookmarks = Cache.Instance.BookmarksByLabel(Settings.Instance.UndockPrefix).OrderByDescending(b => b.CreatedOn).Where(b => b.LocationId == Cache.Instance.DirectEve.Session.SolarSystemId); // //var bookmarks = Cache.Instance.DirectEve.Bookmarks.Where(b => b.LocationId == Cache.Instance.DirectEve.Session.SolarSystemId).OrderByDescending(b => b.CreatedOn).Where(b => b.Title.Contains(Settings.Instance.UndockPrefix)); //this does not handle more than one station undock bookmark per system and WILL likely warp to the wrong bm in that case // //var bookmarks = Cache.Instance.DirectEve.Bookmarks.Where(b => b.Title.Contains(Cache.Instance.DirectEve.GetLocationName(Cache.Instance.DirectEve.Session.StationId ?? 0)) && b.Title.Contains(Settings.Instance.UndockPrefix)); // if (bookmarks != null && bookmarks.Count() > 0) // { // undockBookmark = bookmarks.FirstOrDefault(); // if (undockBookmark.X == null || undockBookmark.Y == null || undockBookmark.Z == null) // { // Logging.Log("TravelerDestination.BookmarkDestination","undock bookmark [" + undockBookmark.Title + "] is unusable: it has no coords"); // undockBookmark = null; // } // else Logging.Log("TravelerDestination.BookmarkDestination","undock bookmark [" + undockBookmark.Title + "] is usable: it has coords"); // } // else Logging.Log("TravelerDestination.BookmarkDestination","you do not have an undock bookmark that contains [" + Settings.Instance.UndockPrefix + "] in local"); //} //else Logging.Log("TravelerDestination.BookmarkDestination","UndockPrefix is not configured"); Cache.Instance.DirectEve.ExecuteCommand(DirectCmd.CmdExitStation); nextAction = DateTime.UtcNow.AddSeconds(Time.Instance.TravelerExitStationAmIInSpaceYet_seconds); return false; } // Is this a station bookmark? if (bookmark.Entity != null && bookmark.Entity.GroupId == (int)Group.Station) { bool arrived = StationDestination.PerformFinalDestinationTask(bookmark.Entity.Id, bookmark.Entity.Name, ref nextAction, ref undockBookmark); if (arrived) Logging.Log("TravelerDestination.BookmarkDestination", "Arrived at bookmark [" + Logging.Yellow + bookmark.Title + Logging.Green + "]", Logging.Green); return arrived; } // Its not a station bookmark, make sure we are in space if (Cache.Instance.DirectEve.Session.IsInStation) { // We are in a station, but not the correct station! if (nextAction < DateTime.UtcNow) { Logging.Log("TravelerDestination.BookmarkDestination", "We're docked but our destination is in space, undocking", Logging.Green); Cache.Instance.DirectEve.ExecuteCommand(DirectCmd.CmdExitStation); nextAction = DateTime.UtcNow.AddSeconds(Time.Instance.TravelerExitStationAmIInSpaceYet_seconds); } // We are not there yet return false; } if (!Cache.Instance.InSpace) { // We are not in space and not in a station, wait a bit return false; } if (undockBookmark != null) { double distanceToUndockBookmark = Cache.Instance.DistanceFromMe(bookmark.X ?? 0, bookmark.Y ?? 0, bookmark.Z ?? 0); if (distanceToUndockBookmark < (int)Distance.WarptoDistance) { Logging.Log("TravelerDestination.BookmarkDestination", "Arrived at undock bookmark [" + Logging.Yellow + undockBookmark.Title + Logging.Green + "]", Logging.Green); undockBookmark = null; } else { Logging.Log("TravelerDestination.BookmarkDestination", "Warping to undock bookmark [" + Logging.Yellow + undockBookmark.Title + Logging.Green + "][" + Logging.Yellow + Math.Round((distanceToUndockBookmark / 1000) / 149598000, 2) + Logging.Green + " AU away]", Logging.Green); //if (!Combat.ReloadAll(Cache.Instance.EntitiesNotSelf.OrderBy(t => t.Distance).FirstOrDefault(t => t.Distance < (double)Distance.OnGridWithMe))) return false; undockBookmark.WarpTo(); nextAction = DateTime.UtcNow.AddSeconds(Time.Instance.TravelerInWarpedNextCommandDelay_seconds); return false; } } // This bookmark has no x / y / z, assume we are there. if (bookmark.X == -1 || bookmark.Y == -1 || bookmark.Z == -1) { Logging.Log("TravelerDestination.BookmarkDestination", "Arrived at the bookmark [" + Logging.Yellow + bookmark.Title + Logging.Green + "][No XYZ]", Logging.Green); return true; } double distance = Cache.Instance.DistanceFromMe(bookmark.X ?? 0, bookmark.Y ?? 0, bookmark.Z ?? 0); if (distance < warpDistance) { Logging.Log("TravelerDestination.BookmarkDestination", "Arrived at the bookmark [" + Logging.Yellow + bookmark.Title + Logging.Green + "]", Logging.Green); return true; } if (nextAction > DateTime.UtcNow) return false; if (Math.Round((distance / 1000)) < (int)Distance.MaxPocketsDistanceKm && Cache.Instance.AccelerationGates.Count() != 0) { Logging.Log("QuestorManager.BookmarkDestination", "Warp to bookmark in same pocket requested but acceleration gate found delaying." , Logging.White); return true; } Logging.Log("TravelerDestination.BookmarkDestination", "Warping to bookmark [" + Logging.Yellow + bookmark.Title + Logging.Green + "][" + Logging.Yellow + Math.Round((distance / 1000) / 149598000, 2) + Logging.Green + " AU away]", Logging.Green); Cache.Instance.DoNotBreakInvul = false; //if (!Combat.ReloadAll(Cache.Instance.EntitiesNotSelf.OrderBy(t => t.Distance).FirstOrDefault(t => t.Distance < (double)Distance.OnGridWithMe))) return false; if (Cache.Instance.MissionWarpAtDistanceRange != 0 && bookmark.Title.Contains("Encounter")) { Logging.Log("TravelerDestination.BookmarkDestination", "Warping to bookmark [" + Logging.Yellow + bookmark.Title + Logging.Green + "][" + Logging.Yellow + " At " + Cache.Instance.MissionWarpAtDistanceRange + Logging.Green + " km]", Logging.Green); bookmark.WarpTo(Cache.Instance.MissionWarpAtDistanceRange * 1000); } else { bookmark.WarpTo(); } nextAction = DateTime.UtcNow.AddSeconds(Time.Instance.TravelerInWarpedNextCommandDelay_seconds); return false; }
internal static bool PerformFinalDestinationTask(DirectBookmark bookmark, int warpDistance, ref DateTime nextAction) { // The bookmark no longer exists, assume we are there if (bookmark == null) return true; var location = GetBookmarkLocation(bookmark); if (DirectEve.Instance.Session.IsInStation) { // We have arived if (location != null && location.ItemId == DirectEve.Instance.Session.StationId) return true; // We are apparently in a station that is incorrect Logging.Log("Traveler.BookmarkDestination: We're docked in the wrong station, undocking"); DirectEve.Instance.ExecuteCommand(DirectCmd.CmdExitStation); nextAction = DateTime.Now.AddSeconds(30); return false; } // Is this a station bookmark? if (bookmark.Entity != null && bookmark.Entity.GroupId == (int) Group.Station) { var arrived = StationDestination.PerformFinalDestinationTask(bookmark.Entity.Id, bookmark.Entity.Name, ref nextAction); if (arrived) Logging.Log("Traveler.BookmarkDestination: Arrived at bookmark [" + bookmark.Title + "]"); return arrived; } // Its not a station bookmark, make sure we are in space if (DirectEve.Instance.Session.IsInStation) { // We are in a station, but not the correct station! if (nextAction < DateTime.Now) { Logging.Log("Traveler.BookmarkDestination: We're docked but our destination is in space, undocking"); DirectEve.Instance.ExecuteCommand(DirectCmd.CmdExitStation); nextAction = DateTime.Now.AddSeconds(30); } // We are not there yet return false; } if (!DirectEve.Instance.Session.IsInSpace) { // We are not in space and not in a station, wait a bit return false; } // This bookmark has no x / y / z, assume we are there. if (bookmark.X == -1 || bookmark.Y == -1 || bookmark.Z == -1) { Logging.Log("Traveler.BookmarkDestination: Arrived at the bookmark [" + bookmark.Title + "][No XYZ]"); return true; } var distance = DirectEve.Instance.DistanceFromMe(bookmark.X ?? 0, bookmark.Y ?? 0, bookmark.Z ?? 0); if (distance < warpDistance) { Logging.Log("Traveler.BookmarkDestination: Arrived at the bookmark [" + bookmark.Title + "]"); return true; } if (nextAction > DateTime.Now) return false; Logging.Log("Traveler.BookmarkDestination: Warping to bookmark [" + bookmark.Title + "]"); bookmark.WarpTo(); nextAction = DateTime.Now.AddSeconds(30); return false; }
internal static bool PerformFinalDestinationTask(long stationId, string stationName, ref DateTime nextAction, ref DirectBookmark localundockBookmark) { if (Cache.Instance.InStation && Cache.Instance.DirectEve.Session.StationId == stationId) { Logging.Log("TravelerDestination.StationDestination: Arrived in station"); return true; } if (Cache.Instance.InStation) { // We are in a station, but not the correct station! if (nextAction < DateTime.Now) { Logging.Log("TravelerDestination.StationDestination: We're docked in the wrong station, undocking from [" + Cache.Instance.DirectEve.GetLocationName(Cache.Instance.DirectEve.Session.StationId ?? 0) + "]"); //if (!string.IsNullOrEmpty(Settings.Instance.UndockPrefix)) //{ // var bookmarks = Cache.Instance.BookmarksByLabel(Settings.Instance.UndockPrefix).OrderByDescending(b => b.CreatedOn).Where(b => b.LocationId == Cache.Instance.DirectEve.Session.SolarSystemId); // //var bookmarks = Cache.Instance.DirectEve.Bookmarks.Where(b => b.LocationId == Cache.Instance.DirectEve.Session.SolarSystemId).Where(b => b.Title.Contains(Settings.Instance.UndockPrefix)); //this does not handle more than one station undock bookmark per system and WILL likely warp to the wrong bm in that case // //var bookmarks = Cache.Instance.DirectEve.Bookmarks.Where(b => b.LocationId == Cache.Instance.DirectEve.Session.SolarSystemId).Where(b => b.Title.Contains(Cache.Instance.DirectEve.GetLocationName(Cache.Instance.DirectEve.Session.StationId ?? 0)) && b.Title.Contains(Settings.Instance.UndockPrefix)); // //var bookmarks = Cache.Instance.DirectEve.Bookmarks.Where(b => b.Title.Contains(Cache.Instance.DirectEve.GetLocationName(Cache.Instance.DirectEve.Session.StationId ?? 0)) && b.Title.Contains(Settings.Instance.UndockPrefix)); // if (bookmarks != null && bookmarks.Count() > 0) // { // localundockBookmark = bookmarks.FirstOrDefault(); // if (localundockBookmark.X == null || localundockBookmark.Y == null || localundockBookmark.Z == null) // { // Logging.Log("TravelerDestination.StationDestination: undock bookmark [" + localundockBookmark.Title + "] is unusable: it has no coords"); // localundockBookmark = null; // } // else Logging.Log("TravelerDestination.StationDestination: undock bookmark [" + localundockBookmark.Title + "] is usable: it has coords"); // } // else Logging.Log("TravelerDestination.StationDestination: you do not have an undock bookmark that has the prefix: " + Settings.Instance.UndockPrefix + " in local"); //+ Cache.Instance.DirectEve.GetLocationName((long)Cache.Instance.DirectEve.Session.StationId) + " and " + Settings.Instance.UndockPrefix + " did not both exist in a bookmark"); //} //else Logging.Log("TravelerDestination.StationDestination: UndockPrefix is not configured"); Cache.Instance.DirectEve.ExecuteCommand(DirectCmd.CmdExitStation); nextAction = DateTime.Now.AddSeconds((int)Time.TravelerExitStationAmIInSpaceYet_seconds); } // We are not there yet return false; } if (!Cache.Instance.InSpace) { // We are not in station and not in space? Wait for a bit return false; } if (nextAction > DateTime.Now) return false; if (localundockBookmark != null) { if (Cache.Instance.DistanceFromMe(localundockBookmark.X ?? 0, localundockBookmark.Y ?? 0, localundockBookmark.Z ?? 0) < (int)Distance.WarptoDistance) { Logging.Log("TravelerDestination.BookmarkDestination: Arrived at undock bookmark [" + localundockBookmark.Title + "]"); localundockBookmark = null; } else { Logging.Log("TravelerDestination.BookmarkDestination: Warping to undock bookmark [" + localundockBookmark.Title + "]"); localundockBookmark.WarpTo(); nextAction = DateTime.Now.AddSeconds(10); //nextAction = DateTime.Now.AddSeconds(Settings.Instance.UndockDelay); return false; } } //else Logging.Log("TravelerDestination.BookmarkDestination: undock bookmark missing: " + Cache.Instance.DirectEve.GetLocationName((long)Cache.Instance.DirectEve.Session.StationId) + " and " + Settings.Instance.UndockPrefix + " did not both exist in a bookmark"); var entity = Cache.Instance.EntitiesByName(stationName).FirstOrDefault(); if (entity == null) { // We are there but no station? Wait a bit return false; } if (entity.Distance < (int)Distance.DockingRange) { Logging.Log("TravelerDestination.StationDestination: Dock at [" + entity.Name + "]"); entity.Dock(); } else if (entity.Distance < (int)Distance.WarptoDistance) entity.Approach(); else { Logging.Log("TravelerDestination.StationDestination: Warp to and dock at [" + entity.Name + "]"); entity.WarpTo(); } nextAction = DateTime.Now.AddSeconds(20); return false; }
/// <summary> /// Refresh the bookmark cache (if needed) /// </summary> /// <returns></returns> public bool RefreshBookmarks() { return(DirectBookmark.RefreshBookmarks(this)); }
internal static bool PerformFinalDestinationTask(DirectBookmark bookmark, int warpDistance) { // The bookmark no longer exists, assume we are not there if (bookmark == null) return false; // Is this a station bookmark? if (bookmark.Entity != null && bookmark.Entity.GroupId == (int)Group.Station) { bool arrived = StationDestination.PerformFinalDestinationTask(bookmark.Entity.Id, bookmark.Entity.Name); if (arrived) { Logging.Log("TravelerDestination.BookmarkDestination", "Arrived at bookmark [" + Logging.Yellow + bookmark.Title + Logging.Green + "]", Logging.Green); } return arrived; } if (Cache.Instance.InStation) { // We have arrived if (bookmark.ItemId.HasValue && bookmark.ItemId == Cache.Instance.DirectEve.Session.StationId) return true; // We are in a station, but not the correct station! if (DateTime.UtcNow > Cache.Instance.NextUndockAction) { TravelerDestination.Undock(); return false; } return false; } if (!Cache.Instance.InSpace) { // We are not in space and not in a station, wait a bit return false; } if (_nextTravelerDestinationAction > DateTime.UtcNow) return false; _undockAttempts = 0; if (Cache.Instance.UndockBookmark != null) { double distanceToUndockBookmark = Cache.Instance.DistanceFromMe(bookmark.X ?? 0, bookmark.Y ?? 0, bookmark.Z ?? 0); if (distanceToUndockBookmark < (int)Distances.WarptoDistance) { Logging.Log("TravelerDestination.BookmarkDestination", "Arrived at undock bookmark [" + Logging.Yellow + Cache.Instance.UndockBookmark.Title + Logging.Green + "]", Logging.Green); Cache.Instance.UndockBookmark = null; } else { if (Cache.Instance.UndockBookmark.WarpTo()) { Logging.Log("TravelerDestination.BookmarkDestination", "Warping to undock bookmark [" + Logging.Yellow + Cache.Instance.UndockBookmark.Title + Logging.Green + "][" + Logging.Yellow + Math.Round((distanceToUndockBookmark / 1000) / 149598000, 2) + Logging.Green + " AU away]", Logging.Green); _nextTravelerDestinationAction = DateTime.UtcNow.AddSeconds(Time.Instance.TravelerInWarpedNextCommandDelay_seconds); //if (!Combat.ReloadAll(Cache.Instance.EntitiesNotSelf.OrderBy(t => t.Distance).FirstOrDefault(t => t.Distance < (double)Distance.OnGridWithMe))) return false; return false; } } } // This bookmark has no x / y / z, assume we are there. if (bookmark.X == -1 || bookmark.Y == -1 || bookmark.Z == -1) { Logging.Log("TravelerDestination.BookmarkDestination", "Arrived at the bookmark [" + Logging.Yellow + bookmark.Title + Logging.Green + "][No XYZ]", Logging.Green); return true; } double distance = Cache.Instance.DistanceFromMe(bookmark.X ?? 0, bookmark.Y ?? 0, bookmark.Z ?? 0); if (distance < warpDistance) { Logging.Log("TravelerDestination.BookmarkDestination", "Arrived at the bookmark [" + Logging.Yellow + bookmark.Title + Logging.Green + "]", Logging.Green); return true; } if (_nextTravelerDestinationAction > DateTime.UtcNow) return false; if (Math.Round((distance / 1000)) < (int)Distances.MaxPocketsDistanceKm && Cache.Instance.AccelerationGates.Count() != 0) { Logging.Log("TravelerDestination.BookmarkDestination", "Warp to bookmark in same pocket requested but acceleration gate found delaying.", Logging.White); return true; } Cache.Instance.DoNotBreakInvul = false; string nameOfBookmark = ""; if (Settings.Instance.EveServerName == "Tranquility") nameOfBookmark = "Encounter"; if (Settings.Instance.EveServerName == "Serenity") nameOfBookmark = "遭遇战"; if (nameOfBookmark == "") nameOfBookmark = "Encounter"; //if (!Combat.ReloadAll(Cache.Instance.EntitiesNotSelf.OrderBy(t => t.Distance).FirstOrDefault(t => t.Distance < (double)Distance.OnGridWithMe))) return false; if (Cache.Instance.MissionWarpAtDistanceRange != 0 && bookmark.Title.Contains(nameOfBookmark)) { if (bookmark.WarpTo(Cache.Instance.MissionWarpAtDistanceRange*1000)) { Logging.Log("TravelerDestination.BookmarkDestination", "Warping to bookmark [" + Logging.Yellow + bookmark.Title + Logging.Green + "][" + Logging.Yellow + " At " + Cache.Instance.MissionWarpAtDistanceRange + Logging.Green + " km]", Logging.Green); } } else { if (bookmark.WarpTo()) { Logging.Log("TravelerDestination.BookmarkDestination", "Warping to bookmark [" + Logging.Yellow + bookmark.Title + Logging.Green + "][" + Logging.Yellow + Math.Round((distance / 1000) / 149598000, 2) + Logging.Green + " AU away]", Logging.Green); } } return false; }
public static void TravelToMiningHomeBookmark(DirectBookmark myHomeBookmark, string module) { // // defending yourself is more important that the traveling part... so it comes first. // if (Cache.Instance.InSpace && Settings.Instance.DefendWhileTraveling) { if (!Cache.Instance.DirectEve.ActiveShip.Entity.IsCloaked || (Cache.Instance.LastSessionChange.AddSeconds(60) > DateTime.UtcNow)) { if (Settings.Instance.DebugGotobase) Logging.Log(module, "TravelToMiningHomeBookmark: _combat.ProcessState()", Logging.White); _combat.ProcessState(); if (!Cache.Instance.TargetedBy.Any(t => t.IsWarpScramblingMe)) { if (Settings.Instance.DebugGotobase) Logging.Log(module, "TravelToMiningHomeBookmark: we are not scrambled - pulling drones.", Logging.White); Cache.Instance.IsMissionPocketDone = true; //tells drones.cs that we can pull drones //Logging.Log("CombatmissionBehavior","TravelToAgentStation: not pointed",Logging.White); } else if (Cache.Instance.TargetedBy.Any(t => t.IsWarpScramblingMe)) { Cache.Instance.IsMissionPocketDone = false; if (Settings.Instance.DebugGotobase) Logging.Log(module, "TravelToMiningHomeBookmark: we are scrambled", Logging.Teal); _drones.ProcessState(); return; } } } Cache.Instance.OpenWrecks = false; if (Settings.Instance.DebugGotobase) Logging.Log(module, "TravelToMiningHomeBookmark: Cache.Instance.AgentStationId [" + Cache.Instance.AgentStationID + "]", Logging.White); if (Settings.Instance.DebugGotobase) Logging.Log(module, "TravelToMiningHomeBookmark: Cache.Instance.AgentSolarSystemId [" + Cache.Instance.AgentSolarSystemID + "]", Logging.White); if (_destination == null) { Logging.Log(module, "Destination: [" + myHomeBookmark.Description + "]", Logging.White); //Cache.Instance.DirectEve.Navigation.GetLocation((long)myHomeBookmark.LocationId).SetDestination(); _destination = new BookmarkDestination(myHomeBookmark); //_destination = new StationDestination(Cache.Instance.AgentSolarSystemID, Cache.Instance.AgentStationID, Cache.Instance.AgentStationName); _States.CurrentTravelerState = TravelerState.Idle; return; } else { if (Settings.Instance.DebugGotobase) if (Traveler.Destination != null) Logging.Log("MiningMissionsBehavior", "TravelToMiningHomeBookmark: Traveler.Destination.SolarSystemId [" + Traveler.Destination.SolarSystemId + "]", Logging.White); Traveler.ProcessState(); //we also assume you are connected during a manual set of questor into travel mode (safe assumption considering someone is at the kb) Cache.Instance.LastKnownGoodConnectedTime = DateTime.UtcNow; Cache.Instance.MyWalletBalance = Cache.Instance.DirectEve.Me.Wealth; if (_States.CurrentTravelerState == TravelerState.AtDestination) { if (_States.CurrentCombatMissionCtrlState == CombatMissionCtrlState.Error) { Logging.Log(module, "an error has occurred", Logging.White); if (_States.CurrentCombatMissionBehaviorState == CombatMissionsBehaviorState.Traveler) { _States.CurrentCombatMissionBehaviorState = CombatMissionsBehaviorState.Error; } return; } if (Cache.Instance.InSpace) { Logging.Log(module, "Arrived at destination (in space, Questor stopped)", Logging.White); Cache.Instance.Paused = true; return; } Logging.Log(module, "Arrived at destination", Logging.White); if (_States.CurrentCombatMissionBehaviorState == CombatMissionsBehaviorState.Traveler) { _States.CurrentCombatMissionBehaviorState = CombatMissionsBehaviorState.Idle; } if (_States.CurrentDedicatedBookmarkSalvagerBehaviorState == DedicatedBookmarkSalvagerBehaviorState.Traveler) { _States.CurrentDedicatedBookmarkSalvagerBehaviorState = DedicatedBookmarkSalvagerBehaviorState.Idle; } if (_States.CurrentCombatHelperBehaviorState == CombatHelperBehaviorState.Traveler) { _States.CurrentCombatHelperBehaviorState = CombatHelperBehaviorState.Idle; } return; } } return; }
public static void TravelToHomeBookmark(DirectBookmark myHomeBookmark, string module) { // // defending yourself is more important that the traveling part... so it comes first. // if (Cache.Instance.InSpace && Settings.Instance.DefendWhileTraveling) { if (!Cache.Instance.DirectEve.ActiveShip.Entity.IsCloaked || (Cache.Instance.LastSessionChange.AddSeconds(60) > DateTime.UtcNow)) { if (Settings.Instance.DebugGotobase) Logging.Log(module, "TravelToAgentsStation: _combat.ProcessState()", Logging.White); _combat.ProcessState(); if (!Cache.Instance.TargetedBy.Any(t => t.IsWarpScramblingMe)) { if (Settings.Instance.DebugGotobase) Logging.Log(module, "TravelToAgentsStation: we are not scrambled - pulling drones.", Logging.White); Cache.Instance.IsMissionPocketDone = true; //tells drones.cs that we can pull drones //Logging.Log("CombatmissionBehavior","TravelToAgentStation: not pointed",Logging.White); } else if (Cache.Instance.TargetedBy.Any(t => t.IsWarpScramblingMe)) { Cache.Instance.IsMissionPocketDone = false; if (Settings.Instance.DebugGotobase) Logging.Log(module, "TravelToAgentsStation: we are scrambled", Logging.Teal); _drones.ProcessState(); return; } } } Cache.Instance.OpenWrecks = false; /* if (Settings.Instance.setEveClientDestinationWhenTraveling) //sets destination to Questors destination, so they match... (defaults to false, needs testing again and probably needs to be exposed as a setting) { if (DateTime.UtcNow > _nextGetDestinationPath || EVENavdestination == null) { if (Settings.Instance.DebugGotobase) Logging.Log(module, "TravelToAgentsStation: EVENavdestination = Cache.Instance.DirectEve.Navigation.GetDestinationPath();", Logging.White); _nextGetDestinationPath = DateTime.UtcNow.AddSeconds(20); _nextSetEVENavDestination = DateTime.UtcNow.AddSeconds(4); EVENavdestination = Cache.Instance.DirectEve.Navigation.GetDestinationPath(); if (Settings.Instance.DebugGotobase) if (EVENavdestination != null) Logging.Log(module, "TravelToAgentsStation: Cache.Instance.DirectEve.Navigation.GetLocation(EVENavdestination.Last()).LocationId [" + Cache.Instance.DirectEve.Navigation.GetLocation(EVENavdestination.Last()).LocationId + "]", Logging.White); return; } if (Cache.Instance.DirectEve.Navigation.GetLocation(EVENavdestination.Last()).LocationId != Cache.Instance.AgentSolarSystemID) { //Logging.Log("CombatMissionsBehavior", "TravelToAgentsStation: Cache.Instance.DirectEve.Navigation.GetLocation(EVENavdestination.Last()).LocationId [" + Cache.Instance.DirectEve.Navigation.GetLocation(EVENavdestination.Last()).LocationId + "]", Logging.White); //Logging.Log("CombatMissionsBehavior", "TravelToAgentsStation: EVENavdestination.LastOrDefault() [" + EVENavdestination.LastOrDefault() + "]", Logging.White); //Logging.Log("CombatMissionsBehavior", "TravelToAgentsStation: Cache.Instance.AgentSolarSystemID [" + Cache.Instance.AgentSolarSystemID + "]", Logging.White); if (DateTime.UtcNow > _nextSetEVENavDestination) { if (Settings.Instance.DebugGotobase) Logging.Log(module, "TravelToAgentsStation: Cache.Instance.DirectEve.Navigation.SetDestination(Cache.Instance.AgentStationId);", Logging.White); _nextSetEVENavDestination = DateTime.UtcNow.AddSeconds(7); Cache.Instance.DirectEve.Navigation.SetDestination(Cache.Instance.AgentStationID); Logging.Log(module, "Setting Destination to [" + Cache.Instance.AgentStationName + "'s] Station", Logging.White); return; } } else if (EVENavdestination != null || EVENavdestination.Count != 0) { if (EVENavdestination.Count == 1 && EVENavdestination.FirstOrDefault() == 0) EVENavdestination[0] = Cache.Instance.DirectEve.Session.SolarSystemId ?? -1; } } */ if (Settings.Instance.DebugGotobase) Logging.Log(module, "TravelToAgentsStation: Cache.Instance.AgentStationId [" + Cache.Instance.AgentStationID + "]", Logging.White); if (Settings.Instance.DebugGotobase) Logging.Log(module, "TravelToAgentsStation: Cache.Instance.AgentSolarSystemId [" + Cache.Instance.AgentSolarSystemID + "]", Logging.White); if (_destination == null || _destination.SolarSystemId != Cache.Instance.AgentSolarSystemID) { Logging.Log(module, "Destination: [" + Cache.Instance.AgentStationName + "]", Logging.White); _destination = new StationDestination(Cache.Instance.AgentSolarSystemID, Cache.Instance.AgentStationID, Cache.Instance.AgentStationName); _States.CurrentTravelerState = TravelerState.Idle; return; } else { if (Settings.Instance.DebugGotobase) if (Traveler.Destination != null) Logging.Log("CombatMissionsBehavior", "TravelToAgentsStation: Traveler.Destination.SolarSystemId [" + Traveler.Destination.SolarSystemId + "]", Logging.White); Traveler.ProcessState(); //we also assume you are connected during a manual set of questor into travel mode (safe assumption considering someone is at the kb) Cache.Instance.LastKnownGoodConnectedTime = DateTime.UtcNow; Cache.Instance.MyWalletBalance = Cache.Instance.DirectEve.Me.Wealth; if (_States.CurrentTravelerState == TravelerState.AtDestination) { if (_States.CurrentCombatMissionCtrlState == CombatMissionCtrlState.Error) { Logging.Log(module, "an error has occurred", Logging.White); if (_States.CurrentCombatMissionBehaviorState == CombatMissionsBehaviorState.Traveler) { _States.CurrentCombatMissionBehaviorState = CombatMissionsBehaviorState.Error; } return; } if (Cache.Instance.InSpace) { Logging.Log(module, "Arrived at destination (in space, Questor stopped)", Logging.White); Cache.Instance.Paused = true; return; } Logging.Log(module, "Arrived at destination", Logging.White); if (_States.CurrentCombatMissionBehaviorState == CombatMissionsBehaviorState.Traveler) { _States.CurrentCombatMissionBehaviorState = CombatMissionsBehaviorState.Idle; } if (_States.CurrentDedicatedBookmarkSalvagerBehaviorState == DedicatedBookmarkSalvagerBehaviorState.Traveler) { _States.CurrentDedicatedBookmarkSalvagerBehaviorState = DedicatedBookmarkSalvagerBehaviorState.Idle; } if (_States.CurrentCombatHelperBehaviorState == CombatHelperBehaviorState.Traveler) { _States.CurrentCombatHelperBehaviorState = CombatHelperBehaviorState.Idle; } return; } } return; }
/// <summary> /// Navigate to a solar system /// </summary> /// <param name = "solarSystemId"></param> private void NagivateToBookmarkSystem(long solarSystemId) { if (_nextTravelerAction > DateTime.Now) return; var undockBookmark = UndockBookmark; UndockBookmark = undockBookmark; var destination = Cache.Instance.DirectEve.Navigation.GetDestinationPath(); if (destination.Count == 0 || !destination.Any(d => d == solarSystemId)) { // We do not have the destination set var location = Cache.Instance.DirectEve.Navigation.GetLocation(solarSystemId); if (location.IsValid) { Logging.Log("Traveler: (traveler.cs) Setting destination to [" + location.Name + "]"); location.SetDestination(); } else { Logging.Log("Traveler: (traveler.cs) Error setting solar system destination [" + solarSystemId + "]"); State = TravelerState.Error; } return; } else { if (!Cache.Instance.InSpace) { if (Cache.Instance.InStation) { Cache.Instance.DirectEve.ExecuteCommand(DirectCmd.CmdExitStation); _nextTravelerAction = DateTime.Now.AddSeconds((int)Time.TravelerExitStationAmIInSpaceYet_seconds); } // We are not yet in space, wait for it return; } // Find the first waypoint var waypoint = destination.First(); // Get the name of the next system var locationName = Cache.Instance.DirectEve.Navigation.GetLocationName(waypoint); // Find the stargate associated with it var entities = Cache.Instance.EntitiesByName("Stargate (" + locationName + ")"); if (entities.Count() == 0) { // not found, that cant be true?!?!?!?! Logging.Log("Traveler: (traveler.cs) Error [Stargate (" + locationName + ")] not found, most likely lag waiting 15 seconds."); _nextTravelerAction = DateTime.Now.AddSeconds((int)Time.TravelerNoStargatesFoundRetryDelay_seconds); return; } // Warp to, approach or jump the stargate var entity = entities.First(); if (entity.Distance < (int)Distance.DecloakRange) { Logging.Log("Traveler: (traveler.cs) Jumping to [" + locationName + "]"); entity.Jump(); _nextTravelerAction = DateTime.Now.AddSeconds((int)Time.TravelerJumpedGateNextCommandDelay_seconds); } else if (entity.Distance < (int)Distance.WarptoDistance) entity.Approach(); else { Logging.Log("Traveler: (traveler.cs) Warping to [Stargate (" + locationName + ")]"); entity.WarpTo(); _nextTravelerAction = DateTime.Now.AddSeconds((int)Time.TravelerInWarpedNextCommandDelay_seconds); } } }
internal static bool PerformFinalDestinationTask(DirectBookmark bookmark, int warpDistance, ref DateTime nextAction, ref DirectBookmark undockBookmark) { // The bookmark no longer exists, assume we aren't there if (bookmark == null) return false; if (Cache.Instance.DirectEve.Session.IsInStation) { // We have arrived if (bookmark.ItemId.HasValue && bookmark.ItemId == Cache.Instance.DirectEve.Session.StationId) return true; // We are apparently in a station that is incorrect Logging.Log("TravelerDestination.BookmarkDestination: We're docked in the wrong station, undocking"); //if (!string.IsNullOrEmpty(Settings.Instance.UndockPrefix)) //{ // var bookmarks = Cache.Instance.BookmarksByLabel(Settings.Instance.UndockPrefix).OrderByDescending(b => b.CreatedOn).Where(b => b.LocationId == Cache.Instance.DirectEve.Session.SolarSystemId); // //var bookmarks = Cache.Instance.DirectEve.Bookmarks.Where(b => b.LocationId == Cache.Instance.DirectEve.Session.SolarSystemId).OrderByDescending(b => b.CreatedOn).Where(b => b.Title.Contains(Settings.Instance.UndockPrefix)); //this does not handle more than one station undock bookmark per system and WILL likely warp to the wrong bm in that case // //var bookmarks = Cache.Instance.DirectEve.Bookmarks.Where(b => b.Title.Contains(Cache.Instance.DirectEve.GetLocationName(Cache.Instance.DirectEve.Session.StationId ?? 0)) && b.Title.Contains(Settings.Instance.UndockPrefix)); // if (bookmarks != null && bookmarks.Count() > 0) // { // undockBookmark = bookmarks.FirstOrDefault(); // if (undockBookmark.X == null || undockBookmark.Y == null || undockBookmark.Z == null) // { // Logging.Log("TravelerDestination.BookmarkDestination: undock bookmark [" + undockBookmark.Title + "] is unusable: it has no coords"); // undockBookmark = null; // } // else Logging.Log("TravelerDestination.BookmarkDestination: undock bookmark [" + undockBookmark.Title + "] is usable: it has coords"); // } // else Logging.Log("TravelerDestination.BookmarkDestination: you do not have an undock bookmark that contains [" + Settings.Instance.UndockPrefix + "] in local"); //} //else Logging.Log("TravelerDestination.BookmarkDestination: UndockPrefix is not configured"); Cache.Instance.DirectEve.ExecuteCommand(DirectCmd.CmdExitStation); nextAction = DateTime.Now.AddSeconds((int)Time.TravelerExitStationAmIInSpaceYet_seconds); return false; } // Is this a station bookmark? if (bookmark.Entity != null && bookmark.Entity.GroupId == (int)Group.Station) { var arrived = StationDestination.PerformFinalDestinationTask(bookmark.Entity.Id, bookmark.Entity.Name, ref nextAction, ref undockBookmark); if (arrived) Logging.Log("TravelerDestination.BookmarkDestination: Arrived at bookmark [" + bookmark.Title + "]"); return arrived; } // Its not a station bookmark, make sure we are in space if (Cache.Instance.DirectEve.Session.IsInStation) { // We are in a station, but not the correct station! if (nextAction < DateTime.Now) { Logging.Log("TravelerDestination.BookmarkDestination: We're docked but our destination is in space, undocking"); Cache.Instance.DirectEve.ExecuteCommand(DirectCmd.CmdExitStation); nextAction = DateTime.Now.AddSeconds((int)Time.TravelerExitStationAmIInSpaceYet_seconds); } // We are not there yet return false; } if (!Cache.Instance.InSpace) { // We are not in space and not in a station, wait a bit return false; } if (undockBookmark != null) { if (Cache.Instance.DistanceFromMe(undockBookmark.X ?? 0, undockBookmark.Y ?? 0, undockBookmark.Z ?? 0) < (int)Distance.WarptoDistance) { Logging.Log("TravelerDestination.BookmarkDestination: Arrived at undock bookmark [" + undockBookmark.Title + "]"); undockBookmark = null; } else { Logging.Log("TravelerDestination.BookmarkDestination: Warping to undock bookmark [" + undockBookmark.Title + "]"); undockBookmark.WarpTo(); nextAction = DateTime.Now.AddSeconds((int)Time.TravelerInWarpedNextCommandDelay_seconds); //nextAction = DateTime.Now.AddSeconds(Settings.Instance.UndockDelay); return false; } } // This bookmark has no x / y / z, assume we are there. if (bookmark.X == -1 || bookmark.Y == -1 || bookmark.Z == -1) { Logging.Log("TravelerDestination.BookmarkDestination: Arrived at the bookmark [" + bookmark.Title + "][No XYZ]"); return true; } var distance = Cache.Instance.DistanceFromMe(bookmark.X ?? 0, bookmark.Y ?? 0, bookmark.Z ?? 0); if (distance < warpDistance) { Logging.Log("TravelerDestination.BookmarkDestination: Arrived at the bookmark [" + bookmark.Title + "]"); return true; } if (nextAction > DateTime.Now) return false; Logging.Log("TravelerDestination.BookmarkDestination: Warping to bookmark [" + bookmark.Title + "]"); Cache.Instance.DoNotBreakInvul = false; bookmark.WarpTo(); nextAction = DateTime.Now.AddSeconds((int)Time.TravelerInWarpedNextCommandDelay_seconds); return false; }
internal static bool PerformFinalDestinationTask(long stationId, string stationName, ref DateTime nextAction, ref DirectBookmark localundockBookmark) { if (Cache.Instance.InStation && Cache.Instance.DirectEve.Session.StationId == stationId) { Logging.Log("Traveler.StationDestination: Arrived in station"); return true; } if (Cache.Instance.InStation) { // We are in a station, but not the correct station! if (nextAction < DateTime.Now) { Logging.Log("Traveler.StationDestination: We're docked in the wrong station, undocking from [" + Cache.Instance.DirectEve.GetLocationName(Cache.Instance.DirectEve.Session.StationId ?? 0) + "]"); if (!string.IsNullOrEmpty(Settings.Instance.UndockPrefix)) { var bookmarks = Cache.Instance.DirectEve.Bookmarks.Where(b => b.Title.Contains(Cache.Instance.DirectEve.GetLocationName(Cache.Instance.DirectEve.Session.StationId ?? 0)) && b.Title.Contains(Settings.Instance.UndockPrefix)); if (bookmarks != null && bookmarks.Count() > 0) { localundockBookmark = bookmarks.FirstOrDefault(); if (localundockBookmark.X == null || localundockBookmark.Y == null || localundockBookmark.Z == null) { Logging.Log("Traveler.StationDestination: undock bookmark [" + localundockBookmark.Title + "] is unusable: it has no coords"); localundockBookmark = null; } else Logging.Log("Traveler.StationDestination: undock bookmark [" + localundockBookmark.Title + "] is usable: it has coords"); } else Logging.Log("Traveler.StationDestination: undock bookmark does not exist"); } else Logging.Log("Traveler.StationDestination: UndockPrefix is not configured"); Cache.Instance.DirectEve.ExecuteCommand(DirectCmd.CmdExitStation); nextAction = DateTime.Now.AddSeconds((int)Time.TravelerExitStationAmIInSpaceYet_seconds); //nextAction = DateTime.Now.AddSeconds(Settings.Instance.UndockDelay); } // We are not there yet return false; } if (!Cache.Instance.InSpace) { // We are not in station and not in space? Wait for a bit return false; } if (nextAction > DateTime.Now) return false; if (localundockBookmark != null) { if (Cache.Instance.DistanceFromMe(localundockBookmark.X ?? 0, localundockBookmark.Y ?? 0, localundockBookmark.Z ?? 0) < (int)Distance.WarptoDistance) { Logging.Log("Traveler.BookmarkDestination: Arrived at undock bookmark [" + localundockBookmark.Title + "]"); localundockBookmark = null; } else { Logging.Log("Traveler.BookmarkDestination: Warping to undock bookmark [" + localundockBookmark.Title + "]"); localundockBookmark.WarpTo(); nextAction = DateTime.Now.AddSeconds(10); //nextAction = DateTime.Now.AddSeconds(Settings.Instance.UndockDelay); return false; } } else Logging.Log("Traveler.BookmarkDestination: undock bookmark does not exist and equals null"); var entity = Cache.Instance.EntitiesByName(stationName).FirstOrDefault(); if (entity == null) { // We are there but no station? Wait a bit return false; } if (entity.Distance < (int)Distance.DockingRange) { Logging.Log("Traveler.StationDestination: Dock at [" + entity.Name + "]"); entity.Dock(); } else if (entity.Distance < (int)Distance.WarptoDistance) entity.Approach(); else { Logging.Log("Traveler.StationDestination: Warp to and dock at [" + entity.Name + "]"); entity.WarpTo(); } nextAction = DateTime.Now.AddSeconds(20); return false; }