/// <summary> /// Navigate to a solar system /// </summary> /// <param name = "solarSystemId"></param> private static void NavigateToBookmarkSystem(long solarSystemId) { if (Time.Instance.NextTravelerAction > DateTime.UtcNow) { if (Logging.DebugTraveler) Logging.Log("Traveler", "NavigateToBookmarkSystem: will continue in [ " + Math.Round(Time.Instance.NextTravelerAction.Subtract(DateTime.UtcNow).TotalSeconds, 0) + " ]sec", Logging.Debug); return; } if (DateTime.UtcNow < Time.Instance.LastSessionChange.AddSeconds(10)) { if (Logging.DebugTraveler) Logging.Log("Traveler", "NavigateToBookmarkSystem: We just session changed less than 10 sec go, wait.", Logging.Teal); return; } Time.Instance.NextTravelerAction = DateTime.UtcNow.AddSeconds(1); if (Logging.DebugTraveler) Logging.Log("Traveler", "NavigateToBookmarkSystem - Iterating- next iteration should be in no less than [1] second ", Logging.Teal); _destinationRoute = null; _destinationRoute = EveCom.Route.Path; if (_destinationRoute == null || _destinationRoute.Count == 0 || _destinationRoute.All(d => d != solarSystemId)) { if (Logging.DebugTraveler) if (_destinationRoute != null || (_destinationRoute != null && _destinationRoute.Count == 0)) Logging.Log("Traveler", "NavigateToBookmarkSystem: We have no destination yet", Logging.Teal); if (Logging.DebugTraveler) if (_destinationRoute != null || (_destinationRoute != null && _destinationRoute.Count != 0 && _destinationRoute.All(d => d != solarSystemId))) Logging.Log("Traveler", "NavigateToBookmarkSystem: the destination is not currently set to solarsystemId [" + solarSystemId + "]", Logging.Teal); // We do not have the destination set if (DateTime.UtcNow > _nextGetLocation || Location == null) { if (Logging.DebugTraveler) Logging.Log("Traveler", "NavigateToBookmarkSystem: getting Location of solarSystemId [" + solarSystemId + "]", Logging.Teal); _nextGetLocation = DateTime.UtcNow.AddSeconds(10); Location = EveComFramework.Data.SolarSystem.All.FirstOrDefault(i => i.ID.ToString() == solarSystemId.ToString()); return; } if (Location != null) { _locationErrors = 0; Logging.Log("Traveler", "Setting destination to [" + Logging.Yellow + Location.Name + Logging.Green + "]", Logging.Green); try { EveCom.Route.SetDestination(Location.ID); } catch (Exception) { Logging.Log("Traveler", "NavigateToBookmarkSystem: set destination to [" + Location + "] failed ", Logging.Debug); } Time.Instance.NextTravelerAction = DateTime.UtcNow.AddSeconds(1); return; } Logging.Log("Traveler", "NavigateToBookmarkSystem: Error setting solar system destination [" + Logging.Yellow + solarSystemId + Logging.Green + "]", Logging.Green); _locationErrors++; if (_locationErrors > 20) { _States.CurrentTravelerState = TravelerState.Error; return; } return; } _locationErrors = 0; if (!QuestorCache.Instance.InSpace) { if (QuestorCache.Instance.InStation) { if (DateTime.UtcNow > Time.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) { EveCom.CommandExtenders.Execute(EveCom.Command.CmdExitStation); Time.Instance.NextTravelerAction = DateTime.UtcNow.AddSeconds(Time.Instance.TravelerExitStationAmIInSpaceYet_seconds); } } Time.Instance.NextActivateModules = DateTime.UtcNow.AddSeconds(QuestorCache.Instance.RandomNumber(2, 3)); // We are not yet in space, wait for it return; } // We are apparently not really in space yet... if (QuestorCache.Instance.ActiveShip == null) { return; } //if (Logging.DebugTraveler) Logging.Log("Traveler", "Destination is set: processing...", Logging.Teal); if (!TravelerDestination.UseInstaBookmark()) return; // Find the first waypoint long waypoint = _destinationRoute.FirstOrDefault(); //if (Logging.DebugTraveler) Logging.Log("Traveler", "NavigateToBookmarkSystem: getting next way-points locationName", Logging.Teal); EveComFramework.Data.SolarSystem solarsystem = EveComFramework.Data.SolarSystem.All.FirstOrDefault(i => i.ID.ToString() == waypoint.ToString()); if (solarsystem != null) { _locationName = solarsystem.Name; } if (Logging.DebugTraveler) Logging.Log("Traveler", "NavigateToBookmarkSystem: Next Waypoint is: [" + _locationName + "]", Logging.Teal); if (waypoint > 60000000) // this MUST be a station { //insert code to handle station destinations here } if (waypoint < 60000000) // this is not a station, probably a system { //useful?a } EveComFramework.Data.SolarSystem solarSystemInRoute = EveComFramework.Data.SolarSystem.All.FirstOrDefault(i => i.ID.ToString() == waypoint.ToString()); if (_States.CurrentQuestorState == QuestorState.CombatMissionsBehavior || _States.CurrentQuestorState == QuestorState.DedicatedBookmarkSalvagerBehavior) { if (solarSystemInRoute != null && solarSystemInRoute.Security < 0.45 && ((int)QuestorCache.Instance.ActiveShip.GroupID != (int)Group.Shuttle || (int)QuestorCache.Instance.ActiveShip.GroupID != (int)Group.Frigate || (int)QuestorCache.Instance.ActiveShip.GroupID != (int)Group.Interceptor)) { Logging.Log("Traveler", "NavigateToBookmarkSystem: Next Waypoint is: [" + _locationName + "] which is LOW SEC! This should never happen. Turning off AutoStart and going home.", Logging.Teal); QuestorSettings.Instance.AutoStart = false; if (_States.CurrentQuestorState == QuestorState.CombatMissionsBehavior) { _States.CurrentCombatMissionBehaviorState = CombatMissionsBehaviorState.GotoBase; } if (_States.CurrentQuestorState == QuestorState.DedicatedBookmarkSalvagerBehavior) { _States.CurrentDedicatedBookmarkSalvagerBehaviorState = DedicatedBookmarkSalvagerBehaviorState.GotoBase; } //if (_States.CurrentQuestorState == QuestorState.CombatHelperBehavior) //{ // _States.CurrentCombatHelperBehaviorState = CombatHelperBehaviorState.GotoBase; //} return; } } // Find the stargate associated with it if (!QuestorCache.Instance.Stargates.Any()) { // not found, that cant be true?!?!?!?! Logging.Log("Traveler", "Error [" + Logging.Yellow + _locationName + Logging.Green + "] not found, most likely lag waiting [" + Time.Instance.TravelerNoStargatesFoundRetryDelay_seconds + "] seconds.", Logging.Red); Time.Instance.NextTravelerAction = DateTime.UtcNow.AddSeconds(Time.Instance.TravelerNoStargatesFoundRetryDelay_seconds); return; } // Warp to, approach or jump the stargate EntityCache myNextStargate = QuestorCache.Instance.StargateByName(_locationName); if (myNextStargate != null) { if (QuestorCache.Instance.Modules == null) return; if ((myNextStargate.Distance < (int)Distances.DecloakRange && !QuestorCache.Instance.ActiveShip.Cloaked) || (myNextStargate.Distance < (int)Distances.JumpRange && QuestorCache.Instance.Modules.Any(i => i.GroupId != (int)Group.CloakingDevice))) { if (myNextStargate.Jump()) { Logging.Log("Traveler", "Jumping to [" + Logging.Yellow + _locationName + Logging.Green + "]", Logging.Green); Time.Instance.NextTravelerAction = DateTime.UtcNow.AddSeconds(5); return; } return; } if (myNextStargate.Distance < (int)Distances.WarptoDistance && myNextStargate.Distance != 0) { if (DateTime.UtcNow > Time.Instance.NextApproachAction && !QuestorCache.Instance.IsApproaching(myNextStargate.Id)) { if (Logging.DebugTraveler) Logging.Log("Traveler", "NavigateToBookmarkSystem: approaching the stargate named [" + myNextStargate.Name + "]", Logging.Teal); myNextStargate.Approach(); //you could use a negative approach distance here but ultimately that is a bad idea.. Id like to go toward the entity without approaching it so we would end up inside the docking ring (eventually) return; } if (Logging.DebugTraveler) Logging.Log("Traveler", "NavigateToBookmarkSystem: we are already approaching the stargate named [" + myNextStargate.Name + "]", Logging.Teal); return; } if (QuestorCache.Instance.InSpace && !Combat.TargetedBy.Any(t => t.IsWarpScramblingMe)) { if (myNextStargate.WarpTo()) { Logging.Log("Traveler", "Warping to [" + Logging.Yellow + _locationName + Logging.Green + "][" + Logging.Yellow + Math.Round((myNextStargate.Distance / 1000) / 149598000, 2) + Logging.Green + " AU away]", Logging.Green); return; } return; } } //Time.Instance.NextTravelerAction = DateTime.UtcNow.AddSeconds(Time.Instance.WarptoDelay_seconds); //this should probably use a different Time definition, but this works for now. (5 seconds) if (!Combat.ReloadAll(QuestorCache.Instance.MyShipEntity)) return; return; }
public static void ProcessState() { // Only pulse state changes every 1.5s if (DateTime.UtcNow.Subtract(_lastTravelerPulse).TotalMilliseconds < 1000) //default: 1000ms { if (Logging.DebugTraveler) Logging.Log("Traveler.Processstate", "if (DateTime.UtcNow.Subtract(_lastTravelerPulse).TotalMilliseconds < 1000)", Logging.Debug); return; } if (Logging.DebugTraveler) Logging.Log("Traveler.Traveling", "Traveler.Processstate() - _States.CurrentTravelerState [" + _States.CurrentTravelerState + "]", Logging.Debug); switch (_States.CurrentTravelerState) { case TravelerState.Idle: _States.CurrentTravelerState = TravelerState.Traveling; break; case TravelerState.Traveling: //if we are in warp, do nothing, as nothing can actually be done until we are out of warp anyway. if ((!QuestorCache.Instance.InSpace && !QuestorCache.Instance.InStation) || QuestorCache.Instance.InWarp) { if (Logging.DebugTraveler) Logging.Log("Traveler.Traveling", "if ((!QuestorCache.Instance.InSpace && !QuestorCache.Instance.InStation) || QuestorCache.Instance.InWarp)", Logging.Debug); return; } if (Destination == null) { _States.CurrentTravelerState = TravelerState.Error; break; } if (Destination.SolarSystemId != EveCom.Session.SolarSystemID) { if (Logging.DebugTraveler) Logging.Log("Traveler.Traveling","NavigateToBookmarkSystem(Destination.SolarSystemId)", Logging.Debug); NavigateToBookmarkSystem(Destination.SolarSystemId); } else if (Destination.PerformFinalDestinationTask()) { _destinationRoute = null; Location = null; _locationName = string.Empty; _locationErrors = 0; //Logging.Log("traveler: _States.CurrentTravelerState = TravelerState.AtDestination;"); _States.CurrentTravelerState = TravelerState.AtDestination; } break; case TravelerState.AtDestination: //do nothing when at destination //Traveler sits in AtDestination when it has nothing to do, NOT in idle. break; default: break; } }
/// <summary> /// Set destination to a solar system /// </summary> public static bool SetStationDestination(long stationId, long solarSystemId) { Location = EveComFramework.Data.SolarSystem.All.FirstOrDefault(i => i.ID.ToString() == solarSystemId.ToString()); if (Location != null) { _locationErrors = 0; if (Logging.DebugTraveler) Logging.Log("Traveler", "Setting destination to [" + Logging.Yellow + Location.Name + Logging.Green + "]", Logging.Teal); try { EveCom.Route.SetDestination(stationId); } catch (Exception) { Logging.Log("Traveler", "SetStationDestination: set destination to [" + Location.ToString() + "] failed ", Logging.Debug); } return true; } Logging.Log("Traveler", "Error setting station destination [" + Logging.Yellow + stationId + Logging.Green + "]", Logging.Green); _locationErrors++; if (_locationErrors > 20) { return false; } return false; }