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("QuestorManager.BookmarkDestination: Invalid bookmark destination!"); SolarSystemId = DirectEve.Instance.Session.SolarSystemId ?? -1; BookmarkId = -1; return; } Logging.Log("QuestorManager.BookmarkDestination: Destination set to bookmark [" + bookmark.Title + "]"); var location = GetBookmarkLocation(bookmark); if (location == null) { Logging.Log("QuestorManager.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; }
public override bool PerformFinalDestinationTask() { DirectBookmark bookmark = Cache.Instance.BookmarkById(BookmarkId); bool arrived = PerformFinalDestinationTask(bookmark, 150000); return(arrived); }
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; } }
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); }
public BookmarkDestination(DirectBookmark bookmark) { if (bookmark == null) { Logging.Log("Traveler.BookmarkDestination: Invalid bookmark destination!"); SolarSystemId = Cache.Instance.DirectEve.Session.SolarSystemId ?? -1; BookmarkId = -1; return; } Logging.Log("Traveler.BookmarkDestination: Destination set to bookmark [" + bookmark.Title + "]"); BookmarkId = bookmark.BookmarkId ?? -1; SolarSystemId = bookmark.LocationId ?? -1; }
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 static void TravelHome(string module) { if (_States.CurrentQuestorState == QuestorState.CombatMissionsBehavior || _States.CurrentQuestorState == QuestorState.CloseQuestor) { // // if we got this far it is because we have not setup Settings.Instance.HomeBookmarkName yet or we do not have a // bookmark in game with the configured prefix at the start of the name of the bookmark // we will instead use the AgentID to find the station // if (Settings.Instance.DebugGotobase) { Logging.Log("TravelHome", "TravelToAgentsStation(module);", Logging.Teal); } TravelToAgentsStation(module); return; } //only call bookmark stuff if UseHomebookmark is true if (Settings.Instance.UseHomebookmark) { TravelHomeCounter++; if (myHomeBookmarks == null || TravelHomeCounter > 30) { TravelHomeCounter = 0; myHomeBookmarks = Cache.Instance.BookmarksByLabel(Settings.Instance.HomeBookmarkName).ToList(); } if (myHomeBookmarks.Any()) { DirectBookmark oldestHomeBookmark = myHomeBookmarks.OrderBy(b => b.CreatedOn).FirstOrDefault(); if (oldestHomeBookmark != null && oldestHomeBookmark.LocationId != null) { TravelToHomeBookmark(oldestHomeBookmark, module); return; } return; } Logging.Log("Traveler.TravelHome", "HomeBookmarkName bookmark not found! using AgentsStation info instead: We were Looking for bookmark starting with [" + Settings.Instance.HomeBookmarkName + "] found none.", Logging.Orange); } TravelToAgentsStation(module); return; }
public void ProcessState() { // Invalid settings, quit while we're ahead if (!ValidSettings) { if (DateTime.UtcNow.Subtract(LastAction).TotalSeconds < Time.Instance.ValidateSettings_seconds) //default is a 15 second interval { Logging.Log("CombatHelperBehavior", "Invalid Settings: Running ValidateCombatMissionSettings();", Logging.Orange); ValidateCombatMissionSettings(); LastAction = DateTime.UtcNow; } return; } if (Settings.Instance.FinishWhenNotSafe && (_States.CurrentCombatHelperBehaviorState != CombatHelperBehaviorState.GotoNearestStation /*|| State!=QuestorState.GotoBase*/)) { //need to remove spam if (Cache.Instance.InSpace && !Cache.Instance.LocalSafe(Settings.Instance.LocalBadStandingPilotsToTolerate, Settings.Instance.LocalBadStandingLevelToConsiderBad)) { EntityCache station = null; if (Cache.Instance.Stations != null && Cache.Instance.Stations.Any()) { station = Cache.Instance.Stations.OrderBy(x => x.Distance).FirstOrDefault(); } if (station != null) { Logging.Log("Local not safe", "Station found. Going to nearest station", Logging.White); _States.CurrentCombatHelperBehaviorState = CombatHelperBehaviorState.GotoNearestStation; } else { Logging.Log("Local not safe", "Station not found. Going back to base", Logging.White); _States.CurrentCombatHelperBehaviorState = CombatHelperBehaviorState.GotoBase; } Cache.Instance.StopBot = true; } } if (Cache.Instance.SessionState == "Quitting") { BeginClosingQuestor(); } if (Cache.Instance.GotoBaseNow) { _States.CurrentCombatHelperBehaviorState = CombatHelperBehaviorState.GotoBase; } if ((DateTime.UtcNow.Subtract(Cache.Instance.QuestorStarted_DateTime).TotalSeconds > 10) && (DateTime.UtcNow.Subtract(Cache.Instance.QuestorStarted_DateTime).TotalSeconds < 60)) { if (Cache.Instance.QuestorJustStarted) { Cache.Instance.QuestorJustStarted = false; Cache.Instance.SessionState = "Starting Up"; // write session log Statistics.WriteSessionLogStarting(); } } // // Panic always runs, not just in space // DebugPerformanceClearandStartTimer(); _panic.ProcessState(); DebugPerformanceStopandDisplayTimer("Panic.ProcessState"); if (_States.CurrentPanicState == PanicState.Panic || _States.CurrentPanicState == PanicState.Panicking) { // If Panic is in panic state, questor is in panic States.CurrentCombatHelperBehaviorState :) _States.CurrentCombatHelperBehaviorState = CombatHelperBehaviorState.Panic; DebugCombatHelperBehaviorStates(); if (PanicStateReset) { _States.CurrentPanicState = PanicState.Normal; PanicStateReset = false; } } else if (_States.CurrentPanicState == PanicState.Resume) { // Reset panic state _States.CurrentPanicState = PanicState.Normal; // Sit Idle and wait for orders. _States.CurrentTravelerState = TravelerState.Idle; _States.CurrentCombatHelperBehaviorState = CombatHelperBehaviorState.Idle; DebugCombatHelperBehaviorStates(); } DebugPanicstates(); // // the slave processstate is meant to override any CombatHelper behavior (it is after all meant to help the master kill things) // //_slave.ProcessState(); // // done with slave process state // //Logging.Log("test"); switch (_States.CurrentCombatHelperBehaviorState) { case CombatHelperBehaviorState.Idle: if (Cache.Instance.StopBot) { // // this is used by the 'local is safe' routines - standings checks - at the moment is stops questor for the rest of the session. // if (Settings.Instance.DebugAutoStart || Settings.Instance.DebugIdle) { Logging.Log("CombatHelperBehavior", "DebugIdle: StopBot [" + Cache.Instance.StopBot + "]", Logging.White); } return; } if (Cache.Instance.InSpace) { if (Settings.Instance.DebugAutoStart || Settings.Instance.DebugIdle) { Logging.Log("CombatHelperBehavior", "DebugIdle: InSpace [" + Cache.Instance.InSpace + "]", Logging.White); } // Questor does not handle in space starts very well, head back to base to try again Logging.Log("CombatHelperBehavior", "Started questor while in space, heading back to base in 15 seconds", Logging.White); LastAction = DateTime.UtcNow; _States.CurrentCombatHelperBehaviorState = CombatHelperBehaviorState.DelayedGotoBase; break; } if (DateTime.UtcNow < Cache.Instance.LastInSpace.AddSeconds(10)) { if (Settings.Instance.DebugAutoStart || Settings.Instance.DebugIdle) { Logging.Log("CombatHelperBehavior", "DebugIdle: Cache.Instance.LastInSpace [" + Cache.Instance.LastInSpace.Subtract(DateTime.UtcNow).TotalSeconds + "] sec ago, waiting until we have been docked for 10+ seconds", Logging.White); } return; } _States.CurrentArmState = ArmState.Idle; _States.CurrentDroneState = DroneState.Idle; _States.CurrentSalvageState = SalvageState.Idle; _States.CurrentTravelerState = TravelerState.Idle; _States.CurrentUnloadLootState = UnloadLootState.Idle; _States.CurrentTravelerState = TravelerState.Idle; Logging.Log("CombatHelperBehavior", "Started questor in Combat Helper mode", Logging.White); LastAction = DateTime.UtcNow; _States.CurrentCombatHelperBehaviorState = CombatHelperBehaviorState.CombatHelper; break; case CombatHelperBehaviorState.DelayedGotoBase: if (DateTime.UtcNow.Subtract(LastAction).TotalSeconds < Time.Instance.DelayedGotoBase_seconds) { break; } Logging.Log("CombatHelperBehavior", "Heading back to base", Logging.White); _States.CurrentCombatHelperBehaviorState = CombatHelperBehaviorState.GotoBase; break; case CombatHelperBehaviorState.Arm: // // only used when someone manually selects the arm state. // if (_States.CurrentArmState == ArmState.Idle) { Logging.Log("Arm", "Begin", Logging.White); _States.CurrentArmState = ArmState.Begin; // Load right ammo based on mission Arm.AmmoToLoad.Clear(); Arm.LoadSpecificAmmo(new[] { Cache.Instance.MissionDamageType }); } Arm.ProcessState(); if (Settings.Instance.DebugStates) { Logging.Log("Arm.State", "is" + _States.CurrentArmState, Logging.White); } if (_States.CurrentArmState == ArmState.NotEnoughAmmo) { // we know we are connected if we were able to arm the ship - update the lastknownGoodConnectedTime // we may be out of drones/ammo but disconnecting/reconnecting will not fix that so update the timestamp Cache.Instance.LastKnownGoodConnectedTime = DateTime.UtcNow; Cache.Instance.MyWalletBalance = Cache.Instance.DirectEve.Me.Wealth; Logging.Log("Arm", "Armstate.NotEnoughAmmo", Logging.Orange); _States.CurrentArmState = ArmState.Idle; _States.CurrentCombatHelperBehaviorState = CombatHelperBehaviorState.Error; } if (_States.CurrentArmState == ArmState.NotEnoughDrones) { // we know we are connected if we were able to arm the ship - update the lastknownGoodConnectedTime // we may be out of drones/ammo but disconnecting/reconnecting will not fix that so update the timestamp Cache.Instance.LastKnownGoodConnectedTime = DateTime.UtcNow; Cache.Instance.MyWalletBalance = Cache.Instance.DirectEve.Me.Wealth; Logging.Log("Arm", "Armstate.NotEnoughDrones", Logging.Orange); _States.CurrentArmState = ArmState.Idle; _States.CurrentCombatHelperBehaviorState = CombatHelperBehaviorState.Error; } if (_States.CurrentArmState == ArmState.Done) { //we know we are connected if we were able to arm the ship - update the lastknownGoodConnectedTime Cache.Instance.LastKnownGoodConnectedTime = DateTime.UtcNow; Cache.Instance.MyWalletBalance = Cache.Instance.DirectEve.Me.Wealth; _States.CurrentArmState = ArmState.Idle; _States.CurrentDroneState = DroneState.WaitingForTargets; _States.CurrentCombatHelperBehaviorState = CombatHelperBehaviorState.Idle; } break; case CombatHelperBehaviorState.CombatHelper: if (Cache.Instance.InSpace) { DebugPerformanceClearandStartTimer(); Combat.ProcessState(); DebugPerformanceStopandDisplayTimer("Combat.ProcessState"); if (Settings.Instance.DebugStates) { Logging.Log("Combat.State is", _States.CurrentCombatState.ToString(), Logging.White); } DebugPerformanceClearandStartTimer(); Drones.ProcessState(); DebugPerformanceStopandDisplayTimer("Drones.ProcessState"); if (Settings.Instance.DebugStates) { Logging.Log("Drones.State is", _States.CurrentDroneState.ToString(), Logging.White); } DebugPerformanceClearandStartTimer(); Salvage.ProcessState(); DebugPerformanceStopandDisplayTimer("Salvage.ProcessState"); if (Settings.Instance.DebugStates) { Logging.Log("Salvage.State is", _States.CurrentSalvageState.ToString(), Logging.White); } // If we are out of ammo, return to base (do we want to do this with combat helper?!) if (_States.CurrentCombatState == CombatState.OutOfAmmo) { Logging.Log("Combat", "Out of Ammo!", Logging.Orange); _States.CurrentCombatHelperBehaviorState = CombatHelperBehaviorState.GotoBase; // Clear looted containers Cache.Instance.LootedContainers.Clear(); } } break; case CombatHelperBehaviorState.Salvage: if (!Cache.Instance.InSpace) { return; } if (Cache.Instance.CurrentShipsCargo == null) { return; } Cache.Instance.SalvageAll = true; if (Settings.Instance.SpeedTank || !Settings.Instance.SpeedTank) { Cache.Instance.OpenWrecks = true; } if (Settings.Instance.UnloadLootAtStation && Cache.Instance.CurrentShipsCargo.IsValid && (Cache.Instance.CurrentShipsCargo.Capacity - Cache.Instance.CurrentShipsCargo.UsedCapacity) < 100) { Logging.Log("CombatMissionsBehavior.Salvage", "We are full, go to base to unload", Logging.White); _States.CurrentCombatMissionBehaviorState = CombatMissionsBehaviorState.GotoBase; break; } if (!Cache.Instance.UnlootedContainers.Any()) { return; } //we __cannot ever__ approach in salvage.cs so this section _is_ needed. Salvage.MoveIntoRangeOfWrecks(); try { // Overwrite settings, as the 'normal' settings do not apply Salvage.MaximumWreckTargets = Cache.Instance.MaxLockedTargets; Salvage.ReserveCargoCapacity = 80; Salvage.LootEverything = true; Salvage.ProcessState(); //Logging.Log("number of max cache ship: " + Cache.Instance.ActiveShip.MaxLockedTargets); //Logging.Log("number of max cache me: " + Cache.Instance.DirectEve.Me.MaxLockedTargets); //Logging.Log("number of max math.min: " + _salvage.MaximumWreckTargets); } finally { ApplyCombatHelperSettings(); } break; case CombatHelperBehaviorState.GotoBase: if (Settings.Instance.DebugGotobase) { Logging.Log("CombatHelperBehavior", "GotoBase: AvoidBumpingThings()", Logging.White); } if (Settings.Instance.AvoidBumpingThings) { NavigateOnGrid.AvoidBumpingThings(Cache.Instance.BigObjects.FirstOrDefault(), "CombatHelperBehaviorState.GotoBase"); } if (Settings.Instance.DebugGotobase) { Logging.Log("CombatHelperBehavior", "GotoBase: Traveler.TravelHome()", Logging.White); } Traveler.TravelHome("CombatHelperBehavior.TravelHome"); if (_States.CurrentTravelerState == TravelerState.AtDestination && DateTime.UtcNow > Cache.Instance.LastInSpace.AddSeconds(5)) // || DateTime.UtcNow.Subtract(Cache.Instance.EnteredCloseQuestor_DateTime).TotalMinutes > 10) { if (Settings.Instance.DebugGotobase) { Logging.Log("CombatHelperBehavior", "GotoBase: We are at destination", Logging.White); } Cache.Instance.GotoBaseNow = false; //we are there - turn off the 'forced' gotobase Cache.Instance.Mission = Cache.Instance.GetAgentMission(AgentID, false); _States.CurrentCombatHelperBehaviorState = CombatHelperBehaviorState.UnloadLoot; Traveler.Destination = null; } break; case CombatHelperBehaviorState.UnloadLoot: if (_States.CurrentUnloadLootState == UnloadLootState.Idle) { Logging.Log("CombatHelperBehavior", "UnloadLoot: Begin", Logging.White); _States.CurrentUnloadLootState = UnloadLootState.Begin; } _unloadLoot.ProcessState(); if (Settings.Instance.DebugStates) { Logging.Log("CombatHelperBehavior", "UnloadLoot.State is " + _States.CurrentUnloadLootState, Logging.White); } if (_States.CurrentUnloadLootState == UnloadLootState.Done) { Cache.Instance.LootAlreadyUnloaded = true; _States.CurrentUnloadLootState = UnloadLootState.Idle; Cache.Instance.Mission = Cache.Instance.GetAgentMission(AgentID, false); if (_States.CurrentCombatState == CombatState.OutOfAmmo) // on mission { Logging.Log("CombatHelperBehavior.UnloadLoot", "We are out of ammo", Logging.Orange); _States.CurrentCombatHelperBehaviorState = CombatHelperBehaviorState.Arm; return; } _States.CurrentCombatHelperBehaviorState = CombatHelperBehaviorState.Arm; Logging.Log("CombatHelperBehavior.Unloadloot", "CharacterMode: [" + Settings.Instance.CharacterMode + "], AfterMissionSalvaging: [" + Settings.Instance.AfterMissionSalvaging + "], CombatHelperBehaviorState: [" + _States.CurrentCombatHelperBehaviorState + "]", Logging.White); Statistics.Instance.FinishedMission = DateTime.UtcNow; return; } break; case CombatHelperBehaviorState.WarpOutStation: DirectBookmark warpOutBookmark = Cache.Instance.BookmarksByLabel(Settings.Instance.UndockBookmarkPrefix ?? "").OrderByDescending(b => b.CreatedOn).FirstOrDefault(b => b.LocationId == Cache.Instance.DirectEve.Session.SolarSystemId); //DirectBookmark _bookmark = Cache.Instance.BookmarksByLabel(Settings.Instance.bookmarkWarpOut + "-" + Cache.Instance.CurrentAgent ?? "").OrderBy(b => b.CreatedOn).FirstOrDefault(); long solarid = Cache.Instance.DirectEve.Session.SolarSystemId ?? -1; if (warpOutBookmark == null) { Logging.Log("BackgroundBehavior.WarpOut", "No Bookmark", Logging.White); _States.CurrentCombatHelperBehaviorState = CombatHelperBehaviorState.CombatHelper; } else if (warpOutBookmark.LocationId == solarid) { if (Traveler.Destination == null) { Logging.Log("BackgroundBehavior.WarpOut", "Warp at " + warpOutBookmark.Title, Logging.White); Traveler.Destination = new BookmarkDestination(warpOutBookmark); Cache.Instance.DoNotBreakInvul = true; } Traveler.ProcessState(); if (_States.CurrentTravelerState == TravelerState.AtDestination) { Logging.Log("BackgroundBehavior.WarpOut", "Safe!", Logging.White); Cache.Instance.DoNotBreakInvul = false; _States.CurrentCombatHelperBehaviorState = CombatHelperBehaviorState.CombatHelper; Traveler.Destination = null; } } else { Logging.Log("BackgroundBehavior.WarpOut", "No Bookmark in System", Logging.Orange); _States.CurrentCombatHelperBehaviorState = CombatHelperBehaviorState.CombatHelper; } break; case CombatHelperBehaviorState.Traveler: if (Settings.Instance.SpeedTank) { Cache.Instance.OpenWrecks = false; } List <int> destination = Cache.Instance.DirectEve.Navigation.GetDestinationPath(); if (destination == null || destination.Count == 0) { // happens if autopilot is not set and this QuestorState is chosen manually // this also happens when we get to destination (!?) Logging.Log("CombatHelperBehavior.Traveler", "No destination?", Logging.White); _States.CurrentCombatHelperBehaviorState = CombatHelperBehaviorState.Error; } else if (destination.Count == 1 && destination.FirstOrDefault() == 0) { destination[0] = Cache.Instance.DirectEve.Session.SolarSystemId ?? -1; } if (destination != null && (Traveler.Destination == null || Traveler.Destination.SolarSystemId != destination.Last())) { IEnumerable <DirectBookmark> bookmarks = Cache.Instance.AllBookmarks.Where(b => b.LocationId == destination.Last()).ToList(); if (bookmarks.FirstOrDefault() != null && bookmarks.Any()) { Traveler.Destination = new BookmarkDestination(bookmarks.OrderBy(b => b.CreatedOn).FirstOrDefault()); } else { Logging.Log("CombatHelperBehavior.Traveler", "Destination: [" + Cache.Instance.DirectEve.Navigation.GetLocation(destination.Last()).Name + "]", Logging.White); Traveler.Destination = new SolarSystemDestination(destination.Last()); } } else { 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("CombatHelperBehavior.Traveler", "an error has occurred", Logging.White); _States.CurrentCombatHelperBehaviorState = CombatHelperBehaviorState.Error; } else if (Cache.Instance.InSpace) { Logging.Log("CombatHelperBehavior.Traveler", "Arrived at destination (in space, Questor stopped)", Logging.White); _States.CurrentCombatHelperBehaviorState = CombatHelperBehaviorState.Error; } else { Logging.Log("CombatHelperBehavior.Traveler", "Arrived at destination", Logging.White); _States.CurrentCombatHelperBehaviorState = CombatHelperBehaviorState.Idle; return; } } } break; case CombatHelperBehaviorState.GotoNearestStation: if (!Cache.Instance.InSpace || Cache.Instance.InWarp) { return; } EntityCache station = null; if (Cache.Instance.Stations != null && Cache.Instance.Stations.Any()) { station = Cache.Instance.Stations.OrderBy(x => x.Distance).FirstOrDefault(); } if (station != null) { if (station.Distance > (int)Distances.WarptoDistance) { if (station.WarpTo()) { Logging.Log("CombatHelperBehavior.GotoNearestStation", "[" + station.Name + "] which is [" + Math.Round(station.Distance / 1000, 0) + "k away]", Logging.White); _States.CurrentCombatHelperBehaviorState = CombatHelperBehaviorState.Idle; } } else { if (station.Distance < 1900) { if (station.Dock()) { Logging.Log("CombatHelperBehavior.GotoNearestStation", "[" + station.Name + "] which is [" + Math.Round(station.Distance / 1000, 0) + "k away]", Logging.White); } } else { if (Cache.Instance.NextApproachAction < DateTime.UtcNow && (Cache.Instance.Approaching == null || Cache.Instance.Approaching.Id != station.Id)) { Logging.Log("CombatHelperBehavior.GotoNearestStation", "Approaching [" + station.Name + "] which is [" + Math.Round(station.Distance / 1000, 0) + "k away]", Logging.White); station.Approach(); } } } } else { _States.CurrentCombatHelperBehaviorState = CombatHelperBehaviorState.Error; //should we goto idle here? } break; case CombatHelperBehaviorState.LogCombatTargets: //combat targets //List<EntityCache> combatentitiesInList = Cache.Instance.Entities.Where(t => t.IsNpc && !t.IsBadIdea && t.CategoryId == (int)CategoryID.Entity && !t.IsContainer && t.Distance < Cache.Instance.MaxRange && !Cache.Instance.IgnoreTargets.Contains(t.Name.Trim())).ToList(); List <EntityCache> combatentitiesInList = Cache.Instance.EntitiesOnGrid.Where(t => t.IsNpc && !t.IsBadIdea && t.CategoryId == (int)CategoryID.Entity && !t.IsContainer).ToList(); Statistics.EntityStatistics(combatentitiesInList); Cache.Instance.Paused = true; break; case CombatHelperBehaviorState.LogDroneTargets: //drone targets List <EntityCache> droneentitiesInList = Cache.Instance.EntitiesOnGrid.Where(e => e.IsNpc && !e.IsBadIdea && e.CategoryId == (int)CategoryID.Entity && !e.IsContainer && !e.IsSentry && !e.IsLargeCollidable).ToList(); Statistics.EntityStatistics(droneentitiesInList); Cache.Instance.Paused = true; break; case CombatHelperBehaviorState.LogStationEntities: //stations List <EntityCache> stationsInList = Cache.Instance.Entities.Where(e => !e.IsSentry && e.GroupId == (int)Group.Station).ToList(); Statistics.EntityStatistics(stationsInList); Cache.Instance.Paused = true; break; case CombatHelperBehaviorState.LogStargateEntities: //stargates List <EntityCache> stargatesInList = Cache.Instance.Entities.Where(e => !e.IsSentry && e.GroupId == (int)Group.Stargate).ToList(); Statistics.EntityStatistics(stargatesInList); Cache.Instance.Paused = true; break; case CombatHelperBehaviorState.LogAsteroidBelts: //Asteroid Belts List <EntityCache> asteroidbeltsInList = Cache.Instance.Entities.Where(e => !e.IsSentry && e.GroupId == (int)Group.AsteroidBelt).ToList(); Statistics.EntityStatistics(asteroidbeltsInList); Cache.Instance.Paused = true; break; case CombatHelperBehaviorState.Default: _States.CurrentCombatHelperBehaviorState = CombatHelperBehaviorState.Idle; break; } }
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); }
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("QuestorManager.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("QuestorManager.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("QuestorManager.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("QuestorManager.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("QuestorManager.BookmarkDestination: Arrived at the bookmark [" + bookmark.Title + "]"); return(true); } if (nextAction > DateTime.Now) { return(false); } Logging.Log("QuestorManager.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); }
public void ProcessState() { // Invalid settings, quit while we're ahead if (!ValidSettings) { if (DateTime.UtcNow.Subtract(LastAction).TotalSeconds < Time.Instance.ValidateSettings_seconds) //default is a 15 second interval { ValidateDedicatedSalvageSettings(); LastAction = DateTime.UtcNow; } return; } //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! //this local is safe check is useless as their is no LocalWatch processstate running every tick... //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! //If local unsafe go to base and do not start mission again if (Settings.Instance.FinishWhenNotSafe && (_States.CurrentDedicatedBookmarkSalvagerBehaviorState != DedicatedBookmarkSalvagerBehaviorState.GotoNearestStation /*|| State!=QuestorState.GotoBase*/)) { //need to remove spam if (Cache.Instance.InSpace && !Cache.Instance.LocalSafe(Settings.Instance.LocalBadStandingPilotsToTolerate, Settings.Instance.LocalBadStandingLevelToConsiderBad)) { EntityCache station = null; if (Cache.Instance.Stations != null && Cache.Instance.Stations.Any()) { station = Cache.Instance.Stations.OrderBy(x => x.Distance).FirstOrDefault(); } if (station != null) { Logging.Log("Local not safe", "Station found. Going to nearest station", Logging.White); _States.CurrentDedicatedBookmarkSalvagerBehaviorState = DedicatedBookmarkSalvagerBehaviorState.GotoNearestStation; } else { Logging.Log("Local not safe", "Station not found. Going back to base", Logging.White); _States.CurrentDedicatedBookmarkSalvagerBehaviorState = DedicatedBookmarkSalvagerBehaviorState.GotoBase; } Cache.Instance.StopBot = true; } } if (Cache.Instance.SessionState == "Quitting") { BeginClosingQuestor(); } if (Cache.Instance.GotoBaseNow) { _States.CurrentDedicatedBookmarkSalvagerBehaviorState = DedicatedBookmarkSalvagerBehaviorState.GotoBase; } if ((DateTime.UtcNow.Subtract(Cache.Instance.QuestorStarted_DateTime).TotalSeconds > 10) && (DateTime.UtcNow.Subtract(Cache.Instance.QuestorStarted_DateTime).TotalSeconds < 60)) { if (Cache.Instance.QuestorJustStarted) { Cache.Instance.QuestorJustStarted = false; Cache.Instance.SessionState = "Starting Up"; // write session log Statistics.WriteSessionLogStarting(); } } // // Panic always runs, not just in space // DebugPerformanceClearandStartTimer(); _panic.ProcessState(); DebugPerformanceStopandDisplayTimer("Panic.ProcessState"); if (_States.CurrentPanicState == PanicState.Panic || _States.CurrentPanicState == PanicState.Panicking) { DebugDedicatedBookmarkSalvagerBehaviorStates(); if (PanicStateReset) { _States.CurrentPanicState = PanicState.Normal; PanicStateReset = false; } } else if (_States.CurrentPanicState == PanicState.Resume) { // Reset panic state _States.CurrentPanicState = PanicState.Normal; } DebugPanicstates(); switch (_States.CurrentDedicatedBookmarkSalvagerBehaviorState) { case DedicatedBookmarkSalvagerBehaviorState.Idle: if (Cache.Instance.StopBot) { return; } _States.CurrentAgentInteractionState = AgentInteractionState.Idle; _States.CurrentArmState = ArmState.Idle; _States.CurrentDroneState = DroneState.Idle; _States.CurrentSalvageState = SalvageState.Idle; _States.CurrentStorylineState = StorylineState.Idle; _States.CurrentTravelerState = TravelerState.Idle; _States.CurrentUnloadLootState = UnloadLootState.Idle; _States.CurrentTravelerState = TravelerState.AtDestination; if (Cache.Instance.InSpace) { // Questor does not handle in space starts very well, head back to base to try again Logging.Log("DedicatedBookmarkSalvagerBehavior", "Started questor while in space, heading back to base in 15 seconds", Logging.White); LastAction = DateTime.UtcNow; Cache.Instance.NextSalvageTrip = DateTime.UtcNow; _States.CurrentDedicatedBookmarkSalvagerBehaviorState = DedicatedBookmarkSalvagerBehaviorState.CheckBookmarkAge; break; } // only attempt to write the mission statistics logs if one of the mission stats logs is enabled in settings //if (Settings.Instance.SalvageStats1Log) //{ // if (!Statistics.Instance.SalvageLoggingCompleted) // { // Statistics.WriteSalvagerStatistics(); // break; // } //} if (Settings.Instance.AutoStart) { //we know we are connected here Cache.Instance.LastKnownGoodConnectedTime = DateTime.UtcNow; Cache.Instance.MyWalletBalance = Cache.Instance.DirectEve.Me.Wealth; // Don't start a new action an hour before downtime if (DateTime.UtcNow.Hour == 10) { if (Settings.Instance.DebugAutoStart) { Logging.Log("DedicatedBookmarkSalvagerBehavior", "Autostart: if (DateTime.UtcNow.Hour == 10)", Logging.White); } break; } // Don't start a new action near downtime if (DateTime.UtcNow.Hour == 11 && DateTime.UtcNow.Minute < 15) { if (Settings.Instance.DebugAutoStart) { Logging.Log("DedicatedBookmarkSalvagerBehavior", "if (DateTime.UtcNow.Hour == 11 && DateTime.UtcNow.Minute < 15)", Logging.White); } break; } //Logging.Log("DedicatedBookmarkSalvagerBehavior::: _nextBookmarksrefresh.subtract(DateTime.UtcNow).totalminutes [" + // Math.Round(DateTime.UtcNow.Subtract(_nextBookmarkRefreshCheck).TotalMinutes,0) + "]"); //Logging.Log("DedicatedBookmarkSalvagerBehavior::: Next Salvage Trip Scheduled in [" + // _Cache.Instance.NextSalvageTrip.ToString(CultureInfo.InvariantCulture) + "min]"); if (DateTime.UtcNow > _nextBookmarkRefreshCheck) { _nextBookmarkRefreshCheck = DateTime.UtcNow.AddMinutes(1); if (Cache.Instance.InStation && (DateTime.UtcNow > _nextBookmarksrefresh)) { _nextBookmarksrefresh = DateTime.UtcNow.AddMinutes(Cache.Instance.RandomNumber(18, 24)); Logging.Log("DedicatedBookmarkSalvagerBehavior", "Next Bookmark refresh in [" + Math.Round(_nextBookmarksrefresh.Subtract(DateTime.UtcNow).TotalMinutes, 0) + "min]", Logging.White); Cache.Instance.DirectEve.RefreshBookmarks(); } else { Logging.Log("DedicatedBookmarkSalvagerBehavior", "Next Bookmark refresh in [" + Math.Round(_nextBookmarksrefresh.Subtract(DateTime.UtcNow).TotalMinutes, 0) + "min]", Logging.White); Logging.Log("DedicatedBookmarkSalvagerBehavior", "Next Salvage Trip Scheduled in [" + Math.Round(Cache.Instance.NextSalvageTrip.Subtract(DateTime.UtcNow).TotalMinutes, 0) + "min]", Logging.White); } } if (DateTime.UtcNow > Cache.Instance.NextSalvageTrip) { Logging.Log("DedicatedBookmarkSalvagerBehavior.BeginAftermissionSalvaging", "Starting Another Salvage Trip", Logging.White); LastAction = DateTime.UtcNow; _States.CurrentDedicatedBookmarkSalvagerBehaviorState = DedicatedBookmarkSalvagerBehaviorState.Start; return; } } else { Cache.Instance.LastScheduleCheck = DateTime.UtcNow; Questor.TimeCheck(); //Should we close questor due to stoptime or runtime? } break; case DedicatedBookmarkSalvagerBehaviorState.DelayedGotoBase: if (DateTime.UtcNow.Subtract(LastAction).TotalSeconds < Time.Instance.DelayedGotoBase_seconds) { break; } Logging.Log("DedicatedBookmarkSalvagerBehavior", "Heading back to base", Logging.White); _States.CurrentDedicatedBookmarkSalvagerBehaviorState = DedicatedBookmarkSalvagerBehaviorState.GotoBase; break; case DedicatedBookmarkSalvagerBehaviorState.Start: Cache.Instance.OpenWrecks = true; ValidateDedicatedSalvageSettings(); _States.CurrentDedicatedBookmarkSalvagerBehaviorState = DedicatedBookmarkSalvagerBehaviorState.UnloadLoot; break; case DedicatedBookmarkSalvagerBehaviorState.LocalWatch: if (Settings.Instance.UseLocalWatch) { Cache.Instance.LastLocalWatchAction = DateTime.UtcNow; if (Cache.Instance.LocalSafe(Settings.Instance.LocalBadStandingPilotsToTolerate, Settings.Instance.LocalBadStandingLevelToConsiderBad)) { Logging.Log("DedicatedBookmarkSalvagerBehavior.LocalWatch", "local is clear", Logging.White); _States.CurrentDedicatedBookmarkSalvagerBehaviorState = DedicatedBookmarkSalvagerBehaviorState.BeginAfterMissionSalvaging; } else { Logging.Log("DedicatedBookmarkSalvagerBehavior.LocalWatch", "Bad standings pilots in local: We will stay 5 minutes in the station and then we will check if it is clear again", Logging.White); _States.CurrentDedicatedBookmarkSalvagerBehaviorState = DedicatedBookmarkSalvagerBehaviorState.WaitingforBadGuytoGoAway; Cache.Instance.LastKnownGoodConnectedTime = DateTime.UtcNow; Cache.Instance.MyWalletBalance = Cache.Instance.DirectEve.Me.Wealth; } } else { _States.CurrentDedicatedBookmarkSalvagerBehaviorState = DedicatedBookmarkSalvagerBehaviorState.BeginAfterMissionSalvaging; } break; case DedicatedBookmarkSalvagerBehaviorState.WaitingforBadGuytoGoAway: Cache.Instance.LastKnownGoodConnectedTime = DateTime.UtcNow; Cache.Instance.MyWalletBalance = Cache.Instance.DirectEve.Me.Wealth; if (DateTime.UtcNow.Subtract(Cache.Instance.LastLocalWatchAction).TotalMinutes < Time.Instance.WaitforBadGuytoGoAway_minutes) { //TODO: add debug logging here break; } _States.CurrentDedicatedBookmarkSalvagerBehaviorState = DedicatedBookmarkSalvagerBehaviorState.LocalWatch; break; case DedicatedBookmarkSalvagerBehaviorState.GotoBase: Cache.Instance.CurrentlyShouldBeSalvaging = false; if (Settings.Instance.DebugGotobase) { Logging.Log("DedicatedBookmarkSalvagerBehavior", "GotoBase: AvoidBumpingThings()", Logging.White); } NavigateOnGrid.AvoidBumpingThings(Cache.Instance.BigObjects.FirstOrDefault(), "DedicatedBookmarkSalvagerBehaviorState.GotoBase"); if (Settings.Instance.DebugGotobase) { Logging.Log("DedicatedBookmarkSalvagerBehavior", "GotoBase: Traveler.TravelHome()", Logging.White); } Traveler.TravelHome("DedicatedBookmarkSalvagerBehavior"); if (_States.CurrentTravelerState == TravelerState.AtDestination) // || DateTime.UtcNow.Subtract(Cache.Instance.EnteredCloseQuestor_DateTime).TotalMinutes > 10) { if (Settings.Instance.DebugGotobase) { Logging.Log("DedicatedBookmarkSalvagerBehavior", "GotoBase: We are at destination", Logging.White); } Cache.Instance.GotoBaseNow = false; //we are there - turn off the 'forced' gotobase Cache.Instance.Mission = Cache.Instance.GetAgentMission(AgentID, false); _States.CurrentDedicatedBookmarkSalvagerBehaviorState = DedicatedBookmarkSalvagerBehaviorState.UnloadLoot; Traveler.Destination = null; } break; case DedicatedBookmarkSalvagerBehaviorState.UnloadLoot: if (_States.CurrentUnloadLootState == UnloadLootState.Idle) { Logging.Log("DedicatedBookmarkSalvagerBehavior", "UnloadLoot: Begin", Logging.White); _States.CurrentUnloadLootState = UnloadLootState.Begin; } _unloadLoot.ProcessState(); if (Settings.Instance.DebugStates) { Logging.Log("DedicatedBookmarkSalvagerBehavior", "UnloadLoot.State = " + _States.CurrentUnloadLootState, Logging.White); } if (_States.CurrentUnloadLootState == UnloadLootState.Done) { Cache.Instance.LootAlreadyUnloaded = true; _States.CurrentUnloadLootState = UnloadLootState.Idle; _States.CurrentDedicatedBookmarkSalvagerBehaviorState = DedicatedBookmarkSalvagerBehaviorState.CheckBookmarkAge; } break; case DedicatedBookmarkSalvagerBehaviorState.CheckBookmarkAge: if (DateTime.UtcNow >= Cache.Instance.NextSalvageTrip || Cache.Instance.InSpace) { if (Cache.Instance.GetSalvagingBookmark == null) { BookmarksThatAreNotReadyYet = Cache.Instance.BookmarksByLabel(Settings.Instance.BookmarkPrefix + " "); if (BookmarksThatAreNotReadyYet != null && BookmarksThatAreNotReadyYet.Any()) { Logging.Log("DedicatedBookmarkSalvagerBehavior", "CheckBookmarkAge: There are [" + BookmarksThatAreNotReadyYet.Count() + "] Salvage Bookmarks that have not yet aged [" + Settings.Instance.AgeofBookmarksForSalvageBehavior + "] min.", Logging.White); } Logging.Log("DedicatedBookmarkSalvagerBehavior", "CheckBookmarkAge: Character mode is BookmarkSalvager and no bookmarks are ready to salvage.", Logging.White); //We just need a NextSalvagerSession timestamp to key off of here to add the delay if (Cache.Instance.InSpace) { // Questor does not handle in space starts very well, head back to base to try again LastAction = DateTime.UtcNow; Cache.Instance.NextSalvageTrip = DateTime.UtcNow.AddMinutes(Time.Instance.DelayBetweenSalvagingSessions_minutes); _States.CurrentDedicatedBookmarkSalvagerBehaviorState = DedicatedBookmarkSalvagerBehaviorState.GotoBase; break; } _States.CurrentDedicatedBookmarkSalvagerBehaviorState = DedicatedBookmarkSalvagerBehaviorState.Idle; _States.CurrentQuestorState = QuestorState.Idle; Cache.Instance.NextSalvageTrip = DateTime.UtcNow.AddMinutes(Time.Instance.DelayBetweenSalvagingSessions_minutes); break; } Logging.Log("DedicatedBookmarkSalvagerBehavior", "CheckBookmarkAge: There are [ " + Cache.Instance.AfterMissionSalvageBookmarks.Count() + " ] more salvage bookmarks older then:" + Cache.Instance.AgedDate.ToString(CultureInfo.InvariantCulture) + ", left to process", Logging.White); _States.CurrentDedicatedBookmarkSalvagerBehaviorState = DedicatedBookmarkSalvagerBehaviorState.BeginAfterMissionSalvaging; Statistics.Instance.StartedSalvaging = DateTime.UtcNow; } else { Logging.Log("DedicatedBookmarkSalvagerBehavior", "CheckBookmarkAge: next salvage timer not expired. Waiting...", Logging.White); _States.CurrentDedicatedBookmarkSalvagerBehaviorState = DedicatedBookmarkSalvagerBehaviorState.Idle; _States.CurrentQuestorState = QuestorState.Idle; return; } break; case DedicatedBookmarkSalvagerBehaviorState.BeginAfterMissionSalvaging: if (DateTime.UtcNow > Statistics.Instance.StartedSalvaging.AddMinutes(2)) { Logging.Log("DedicatedBookmarkSalvagebehavior", "Found [" + Cache.Instance.AfterMissionSalvageBookmarks.Count() + "] salvage bookmarks ready to process.", Logging.White); Statistics.Instance.StartedSalvaging = DateTime.UtcNow; //this will be reset for each "run" between the station and the field if using <unloadLootAtStation>true</unloadLootAtStation> Cache.Instance.NextSalvageTrip = DateTime.UtcNow.AddMinutes(Time.Instance.DelayBetweenSalvagingSessions_minutes); } //we know we are connected here Cache.Instance.LastKnownGoodConnectedTime = DateTime.UtcNow; Cache.Instance.MyWalletBalance = Cache.Instance.DirectEve.Me.Wealth; Cache.Instance.OpenWrecks = true; if (Cache.Instance.InStation) { if (_States.CurrentArmState == ArmState.Idle) { _States.CurrentArmState = ArmState.SwitchToSalvageShip; } Arm.ProcessState(); } if (_States.CurrentArmState == ArmState.Done || Cache.Instance.InSpace) { _States.CurrentArmState = ArmState.Idle; if (_afterMissionSalvageBookmarks == null || Cache.Instance.InStation) { _afterMissionSalvageBookmarks = Cache.Instance.AfterMissionSalvageBookmarks.OrderBy(b => b.CreatedOn).ToList(); } _afterMissionSalvageBookmarks = _afterMissionSalvageBookmarks.OrderBy(b => b.CreatedOn).ToList(); if (DateTime.UtcNow < Cache.Instance.LastAccelerationGateDetected.AddSeconds(10)) //long enough that the timer should expire if we have to warp even small distances to the next bm { _States.CurrentDedicatedBookmarkSalvagerBehaviorState = DedicatedBookmarkSalvagerBehaviorState.GotoBase; Cache.Instance.NextSalvageTrip = DateTime.UtcNow.AddMinutes(Time.Instance.DelayBetweenSalvagingSessions_minutes); return; //Logging.Log("DedicatedBookmarkSalvagerBehavior.Salvager", "There is a gate on grid with us: deferring processing any bookmarks within CloseRangeScan because those are likely behind this gate and might have NPCs still there", Logging.White); //_afterMissionSalvageBookmarks = new List<DirectBookmark>(_afterMissionSalvageBookmarks.Where(b => Cache.Instance.DistanceFromMe(b.X ?? 0, b.Y ?? 0, b.Z ?? 0) > (int)Distance.DirectionalScannerCloseRange)).OrderBy(b => b.CreatedOn).ToList(); //int i = 1; //Logging.Log("DedicatedBookmarkSalvagerBehavior.Salvager", "Listing bookmarks in: _afterMissionSalvageBookmarks, they should be all more than CloseRangeScan [" + Distance.DirectionalScannerCloseRange + "] away.", Logging.Red); //foreach (var bm in _afterMissionSalvageBookmarks) //{ // Logging.Log("", "[" + i + "] BM Name: [" + bm.Title + "]" + "] Distance: [" + Cache.Instance.DistanceFromMe(bm.X ?? 0, bm.Y ?? 0, bm.Z ?? 0) + "]", Logging.Red); // i++; //} //if (_afterMissionSalvageBookmarks.Any()) //{ // Logging.Log("DedicatedBookmarkSalvagerBehavior.Salvager", "_afterMissionSalvageBookmarks contains [" + _afterMissionSalvageBookmarks.Count() + "] bookmarks", Logging.White); //} //else //{ // Logging.Log("DedicatedBookmarkSalvagerBehavior.Salvager", "_afterMissionSalvageBookmarks contains [ Zero ] bookmarks", Logging.White); // Logging.Log("DedicatedBookmarkSalvagerBehavior.Salvager", "AfterMissionSalvageBookmarks (including BMs we cant process yet) contains [" + Cache.Instance.AfterMissionSalvageBookmarks + "]", Logging.White); //} } DirectBookmark bookmark = _afterMissionSalvageBookmarks.OrderBy(b => b.CreatedOn).FirstOrDefault(); if (bookmark == null) { _States.CurrentDedicatedBookmarkSalvagerBehaviorState = DedicatedBookmarkSalvagerBehaviorState.GotoBase; Cache.Instance.NextSalvageTrip = DateTime.UtcNow.AddMinutes(Time.Instance.DelayBetweenSalvagingSessions_minutes); return; } Logging.Log("DedicatedBookmarkSalvagerBehavior.Salvager", "Salvaging at first oldest bookmarks created on: " + bookmark.CreatedOn.ToString(), Logging.White); List <DirectBookmark> bookmarksInLocal = new List <DirectBookmark>(_afterMissionSalvageBookmarks.Where(b => b.LocationId == Cache.Instance.DirectEve.Session.SolarSystemId). OrderBy(b => b.CreatedOn)); DirectBookmark localBookmark = bookmarksInLocal.FirstOrDefault(); if (localBookmark != null) { Traveler.Destination = new BookmarkDestination(localBookmark); } else { Traveler.Destination = new BookmarkDestination(bookmark); } _States.CurrentDedicatedBookmarkSalvagerBehaviorState = DedicatedBookmarkSalvagerBehaviorState.GotoSalvageBookmark; //we know we are connected here Cache.Instance.LastKnownGoodConnectedTime = DateTime.UtcNow; Cache.Instance.LastInWarp = DateTime.UtcNow; Cache.Instance.MyWalletBalance = Cache.Instance.DirectEve.Me.Wealth; return; } break; case DedicatedBookmarkSalvagerBehaviorState.GotoSalvageBookmark: Traveler.ProcessState(); if (Cache.Instance.GateInGrid()) { //Logging.Log("DedicatedBookmarkSalvagerBehavior", "GotoSalvageBookmark: We found gate in salvage bookmark. Going back to Base", Logging.White); Logging.Log("DedicatedBookmarkSalvagerBehavior", "GotoSalvageBookmark: We found gate in salvage bookmark. Skipping this bookmark.", Logging.White); Cache.Instance.LastAccelerationGateDetected = DateTime.UtcNow; //we know we are connected here Cache.Instance.LastKnownGoodConnectedTime = DateTime.UtcNow; Cache.Instance.MyWalletBalance = Cache.Instance.DirectEve.Me.Wealth; _States.CurrentDedicatedBookmarkSalvagerBehaviorState = DedicatedBookmarkSalvagerBehaviorState.BeginAfterMissionSalvaging; Traveler.Destination = null; Cache.Instance.NextSalvageTrip = DateTime.UtcNow.AddMinutes(Time.Instance.DelayBetweenSalvagingSessions_minutes); return; } if (_States.CurrentTravelerState == TravelerState.AtDestination) { Logging.Log("DedicatedBookmarkSalvagerBehavior", "GotoSalvageBookmark: Gate not found, we can start salvaging", Logging.White); //we know we are connected here Cache.Instance.LastKnownGoodConnectedTime = DateTime.UtcNow; Cache.Instance.MyWalletBalance = Cache.Instance.DirectEve.Me.Wealth; Cache.Instance.LastInWarp = DateTime.UtcNow; _States.CurrentDedicatedBookmarkSalvagerBehaviorState = DedicatedBookmarkSalvagerBehaviorState.Salvage; Traveler.Destination = null; return; } if (Settings.Instance.DebugStates) { Logging.Log("Traveler.State is ", _States.CurrentTravelerState.ToString(), Logging.White); } break; case DedicatedBookmarkSalvagerBehaviorState.Salvage: if (Settings.Instance.DebugSalvage) { Logging.Log("DedicatedBookmarkSalvagerBehavior", "salvage::: attempting to open cargo hold", Logging.White); } if (Cache.Instance.CurrentShipsCargo == null) { Logging.Log("DedicatedBookmarkSalvagerBehavior", "salvage:: if (Cache.Instance.CurrentShipsCargo == null)", Logging.Teal); return; } if (Settings.Instance.DebugSalvage) { Logging.Log("DedicatedBookmarkSalvagerBehavior", "salvage::: done opening cargo hold", Logging.White); } Cache.Instance.SalvageAll = true; Cache.Instance.OpenWrecks = true; Cache.Instance.CurrentlyShouldBeSalvaging = true; const int distanceToCheck = (int)Distances.OnGridWithMe; // is there any NPCs within distanceToCheck? EntityCache deadlyNPC = Cache.Instance.EntitiesOnGrid.Where(t => t.Distance < distanceToCheck && !t.IsEntityIShouldLeaveAlone && !t.IsContainer && t.IsNpc && t.CategoryId == (int)CategoryID.Entity && !t.IsLargeCollidable).OrderBy(t => t.Distance).FirstOrDefault(); if (deadlyNPC != null) { Logging.Log("DedicatedBookmarkSalvagerBehavior.Salvage", "Npc name:[" + deadlyNPC.Name + "] with groupId:[" + deadlyNPC.GroupId + "].", Logging.White); // found NPCs that will likely kill out fragile salvage boat! DirectBookmark bookmark = Cache.Instance.AfterMissionSalvageBookmarks.OrderBy(b => b.CreatedOn).FirstOrDefault(); if (bookmark != null) { Cache.Instance.DeleteBookmarksOnGrid("DedicatedBookmarkSalvageBehavior"); return; } Statistics.Instance.FinishedSalvaging = DateTime.UtcNow; Cache.Instance.NextSalvageTrip = DateTime.UtcNow; _States.CurrentDedicatedBookmarkSalvagerBehaviorState = DedicatedBookmarkSalvagerBehaviorState.GotoBase; return; } if (Cache.Instance.CurrentShipsCargo.IsValid && (Cache.Instance.CurrentShipsCargo.Capacity - Cache.Instance.CurrentShipsCargo.UsedCapacity) < Settings.Instance.ReserveCargoCapacity + 10) { Logging.Log("DedicatedBookmarkSalvageBehavior.Salvage", "We are full, go to base to unload", Logging.White); _States.CurrentDedicatedBookmarkSalvagerBehaviorState = DedicatedBookmarkSalvagerBehaviorState.GotoBase; break; } else if (Cache.Instance.CurrentShipsCargo.IsValid) { if (Settings.Instance.DebugSalvage) { Logging.Log("DedicatedSalvager", "CurrentCapacity [" + Cache.Instance.CurrentShipsCargo.Capacity + "] UsedCapacity [" + Cache.Instance.CurrentShipsCargo.UsedCapacity + "][" + Settings.Instance.ReserveCargoCapacity + "]", Logging.Debug); } } if (!Cache.Instance.UnlootedContainers.Any()) { if (!Cache.Instance.DeleteBookmarksOnGrid("DedicatedBookmarkSalvageBehavior")) { return; } // this can eventually be moved to somewhere else like unloadloot BUT... // that will mean keeping track of bookmarks we delete and such in this local list. _afterMissionSalvageBookmarks = Cache.Instance.AfterMissionSalvageBookmarks.OrderBy(b => b.CreatedOn).ToList(); _States.CurrentDedicatedBookmarkSalvagerBehaviorState = DedicatedBookmarkSalvagerBehaviorState.CheckBookmarkAge; return; } if (DateTime.UtcNow > Cache.Instance.LastInWarp.AddMinutes(20)) { Logging.Log("DedicatedBookmarkSalvagerBehavior", "It has been over 20 min since we were last in warp. Assuming something went wrong: setting GoToBase", Logging.Orange); _States.CurrentDedicatedBookmarkSalvagerBehaviorState = DedicatedBookmarkSalvagerBehaviorState.GotoBase; return; } if (Settings.Instance.DebugSalvage) { Logging.Log("DedicatedBookmarkSalvagerBehavior", "salvage: we have more wrecks to salvage", Logging.White); } //we __cannot ever__ approach in salvage.cs so this section _is_ needed. Salvage.MoveIntoRangeOfWrecks(); try { // Overwrite settings, as the 'normal' settings do not apply Salvage.MaximumWreckTargets = Cache.Instance.MaxLockedTargets; Salvage.ReserveCargoCapacity = 80; Salvage.LootEverything = true; Salvage.ProcessState(); //Logging.Log("number of max cache ship: " + Cache.Instance.ActiveShip.MaxLockedTargets); //Logging.Log("number of max cache me: " + Cache.Instance.DirectEve.Me.MaxLockedTargets); //Logging.Log("number of max math.min: " + _salvage.MaximumWreckTargets); } finally { ApplySalvageSettings(); } break; case DedicatedBookmarkSalvagerBehaviorState.Default: _States.CurrentDedicatedBookmarkSalvagerBehaviorState = DedicatedBookmarkSalvagerBehaviorState.Idle; break; } }
/// <summary> /// Do a mini-questor here (goto mission, execute mission, goto base) /// </summary> /// <returns></returns> public StorylineState ExecuteMission(Storyline storyline) { switch (_state) { case GenericCombatStorylineState.WarpOutStation: DirectBookmark warpOutBookMark = Cache.Instance.BookmarksByLabel(Settings.Instance.UndockBookmarkPrefix ?? "").OrderByDescending(b => b.CreatedOn).FirstOrDefault(b => b.LocationId == Cache.Instance.DirectEve.Session.SolarSystemId); long solarid = Cache.Instance.DirectEve.Session.SolarSystemId ?? -1; if (warpOutBookMark == null) { Logging.Log("GenericCombatStoryline.WarpOut", "No Bookmark", Logging.Orange); _state = GenericCombatStorylineState.GotoMission; break; } if (warpOutBookMark.LocationId == solarid) { if (Traveler.Destination == null) { Logging.Log("GenericCombatStoryline.WarpOut", "Warp at " + warpOutBookMark.Title, Logging.White); Traveler.Destination = new BookmarkDestination(warpOutBookMark); Cache.Instance.DoNotBreakInvul = true; } Traveler.ProcessState(); if (_States.CurrentTravelerState == TravelerState.AtDestination) { Logging.Log("GenericCombatStoryline.WarpOut", "Safe!", Logging.White); Cache.Instance.DoNotBreakInvul = false; _state = GenericCombatStorylineState.GotoMission; Traveler.Destination = null; break; } break; } Logging.Log("GenericCombatStoryline.WarpOut", "No Bookmark in System", Logging.White); _state = GenericCombatStorylineState.GotoMission; break; case GenericCombatStorylineState.GotoMission: MissionBookmarkDestination missionDestination = Traveler.Destination as MissionBookmarkDestination; // // if we have no destination yet... OR if missionDestination.AgentId != storyline.CurrentStorylineAgentId // //if (missionDestination != null) Logging.Log("GenericCombatStoryline: missionDestination.AgentId [" + missionDestination.AgentId + "] " + "and storyline.CurrentStorylineAgentId [" + storyline.CurrentStorylineAgentId + "]"); //if (missionDestination == null) Logging.Log("GenericCombatStoryline: missionDestination.AgentId [ NULL ] " + "and storyline.CurrentStorylineAgentId [" + storyline.CurrentStorylineAgentId + "]"); if (missionDestination == null || missionDestination.AgentId != Cache.Instance.CurrentStorylineAgentId) // We assume that this will always work "correctly" (tm) { string nameOfBookmark = ""; if (Settings.Instance.EveServerName == "Tranquility") { nameOfBookmark = "Encounter"; } if (Settings.Instance.EveServerName == "Serenity") { nameOfBookmark = "遭遇战"; } if (nameOfBookmark == "") { nameOfBookmark = "Encounter"; } Logging.Log("GenericCombatStoryline", "Setting Destination to 1st bookmark from AgentID: [" + Cache.Instance.CurrentStorylineAgentId + "] with [" + nameOfBookmark + "] in the title", Logging.White); Traveler.Destination = new MissionBookmarkDestination(Cache.Instance.GetMissionBookmark(Cache.Instance.CurrentStorylineAgentId, nameOfBookmark)); } if (Cache.Instance.PotentialCombatTargets.Any()) { Logging.Log("GenericCombatStoryline", "Priority targets found while traveling, engaging!", Logging.White); Combat.ProcessState(); } Traveler.ProcessState(); if (_States.CurrentTravelerState == TravelerState.AtDestination) { _state = GenericCombatStorylineState.ExecuteMission; //_States.CurrentCombatState = CombatState.CheckTargets; Traveler.Destination = null; } break; case GenericCombatStorylineState.ExecuteMission: Combat.ProcessState(); Drones.ProcessState(); Salvage.ProcessState(); _combatMissionCtrl.ProcessState(); // If we are out of ammo, return to base, the mission will fail to complete and the bot will reload the ship // and try the mission again if (_States.CurrentCombatState == CombatState.OutOfAmmo) { // Clear looted containers Cache.Instance.LootedContainers.Clear(); Logging.Log("GenericCombatStoryline", "Out of Ammo!", Logging.Orange); return(StorylineState.ReturnToAgent); } if (_States.CurrentCombatMissionCtrlState == CombatMissionCtrlState.Done) { // Clear looted containers Cache.Instance.LootedContainers.Clear(); return(StorylineState.ReturnToAgent); } // If in error state, just go home and stop the bot if (_States.CurrentCombatMissionCtrlState == CombatMissionCtrlState.Error) { // Clear looted containers Cache.Instance.LootedContainers.Clear(); Logging.Log("MissionController", "Error", Logging.Red); return(StorylineState.ReturnToAgent); } break; } return(StorylineState.ExecuteMission); }
public override bool PerformFinalDestinationTask() { DirectBookmark bookmark = Cache.Instance.BookmarkById(BookmarkId); return(PerformFinalDestinationTask2(bookmark, 150000, ref _nextAction)); }
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.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; } } } if (Settings.Instance.SpeedTank) { 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; }
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.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; } } } if (Settings.Instance.SpeedTank) { 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; }
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); } if (bookmark.WarpTo()) { 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); nextAction = DateTime.UtcNow.AddSeconds(30); return(false); } return(false); }
//public bool InMission { get; set; } public void ProcessState() { // Only pulse state changes every 500ms if (DateTime.UtcNow < _nextPanicProcessState || Settings.Instance.DebugDisablePanic) //default: 500ms { return; } _nextPanicProcessState = DateTime.UtcNow.AddMilliseconds(500); switch (_States.CurrentPanicState) { case PanicState.Idle: // // below is the reasons we will start the panic state(s) - if the below is not met do nothing // if (Cache.Instance.InSpace && Cache.Instance.ActiveShip.Entity != null && !Cache.Instance.ActiveShip.Entity.IsCloaked) { _States.CurrentPanicState = PanicState.Normal; return; } break; case PanicState.Normal: if (Cache.Instance.InStation) { _States.CurrentPanicState = PanicState.Idle; } if (Cache.Instance.ActiveShip.Entity != null) { _lastNormalX = Cache.Instance.ActiveShip.Entity.X; _lastNormalY = Cache.Instance.ActiveShip.Entity.Y; _lastNormalZ = Cache.Instance.ActiveShip.Entity.Z; } if (Cache.Instance.ActiveShip.Entity == null) { return; } if (DateTime.UtcNow < Cache.Instance.LastSessionChange.AddSeconds(10)) { return; } if ((long)Cache.Instance.ActiveShip.StructurePercentage == 0) //if your hull is 0 you are dead or bugged, wait. { return; } if (Settings.Instance.WatchForActiveWars && Cache.Instance.IsCorpInWar) { Logging.Log("Cache", "Your corp is involved in a war [" + Cache.Instance.IsCorpInWar + "] and WatchForActiveWars [" + Settings.Instance.WatchForActiveWars + "], Starting panic!", Logging.Orange); _States.CurrentPanicState = PanicState.StartPanicking; //return; } if (Cache.Instance.InSpace) { if (!Cache.Instance.InMission && Cache.Instance.ActiveShip.GroupId == (int)Group.Capsule) { Logging.Log("Panic", "You are in a Capsule, you must have died :(", Logging.Red); _States.CurrentPanicState = PanicState.BookmarkMyWreck; //_States.CurrentPanicState = PanicState.StartPanicking; return; } if (Cache.Instance.TargetedBy.Any()) { if (Settings.Instance.DebugPanic) { Logging.Log("Panic.Normal", "We have been locked by [" + Cache.Instance.TargetedBy.Count() + "] Entities", Logging.Debug); } List <EntityCache> EntitiesThatAreWarpScramblingMe = Cache.Instance.TargetedBy.Where(t => t.IsWarpScramblingMe).ToList(); if (EntitiesThatAreWarpScramblingMe.Any()) { if (Settings.Instance.DebugPanic) { Logging.Log("Panic.Normal", "We have been warp scrambled by [" + EntitiesThatAreWarpScramblingMe.Count() + "] Entities", Logging.Debug); } if (Cache.Instance.UseDrones) { Cache.Instance.AddDronePriorityTargets(EntitiesThatAreWarpScramblingMe, DronePriority.WarpScrambler, "Panic", Settings.Instance.AddWarpScramblersToDronePriorityTargetList); } Cache.Instance.AddPrimaryWeaponPriorityTargets(EntitiesThatAreWarpScramblingMe, PrimaryWeaponPriority.WarpScrambler, "Panic", Settings.Instance.AddWarpScramblersToDronePriorityTargetList); } if (Settings.Instance.SpeedTank) { List <EntityCache> EntitiesThatAreWebbingMe = Cache.Instance.TargetedBy.Where(t => t.IsWebbingMe).ToList(); if (EntitiesThatAreWebbingMe.Any()) { if (Settings.Instance.DebugPanic) { Logging.Log("Panic.Normal", "We have been webbed by [" + EntitiesThatAreWebbingMe.Count() + "] Entities", Logging.Debug); } if (Cache.Instance.UseDrones) { Cache.Instance.AddDronePriorityTargets(EntitiesThatAreWebbingMe, DronePriority.Webbing, "Panic", Settings.Instance.AddWebifiersToDronePriorityTargetList); } Cache.Instance.AddPrimaryWeaponPriorityTargets(EntitiesThatAreWebbingMe, PrimaryWeaponPriority.Webbing, "Panic", Settings.Instance.AddWebifiersToPrimaryWeaponsPriorityTargetList); } List <EntityCache> EntitiesThatAreTargetPaintingMe = Cache.Instance.TargetedBy.Where(t => t.IsTargetPaintingMe).ToList(); if (EntitiesThatAreTargetPaintingMe.Any()) { if (Settings.Instance.DebugPanic) { Logging.Log("Panic.Normal", "We have been target painted by [" + EntitiesThatAreTargetPaintingMe.Count() + "] Entities", Logging.Debug); } if (Cache.Instance.UseDrones) { Cache.Instance.AddDronePriorityTargets(EntitiesThatAreTargetPaintingMe, DronePriority.PriorityKillTarget, "Panic", Settings.Instance.AddTargetPaintersToDronePriorityTargetList); } Cache.Instance.AddPrimaryWeaponPriorityTargets(EntitiesThatAreTargetPaintingMe, PrimaryWeaponPriority.TargetPainting, "Panic", Settings.Instance.AddTargetPaintersToPrimaryWeaponsPriorityTargetList); } } List <EntityCache> EntitiesThatAreNeutralizingMe = Cache.Instance.TargetedBy.Where(t => t.IsNeutralizingMe).ToList(); if (EntitiesThatAreNeutralizingMe.Any()) { if (Settings.Instance.DebugPanic) { Logging.Log("Panic.Normal", "We have been neuted by [" + EntitiesThatAreNeutralizingMe.Count() + "] Entities", Logging.Debug); } if (Cache.Instance.UseDrones) { Cache.Instance.AddDronePriorityTargets(EntitiesThatAreNeutralizingMe, DronePriority.PriorityKillTarget, "Panic", Settings.Instance.AddNeutralizersToDronePriorityTargetList); } Cache.Instance.AddPrimaryWeaponPriorityTargets(EntitiesThatAreNeutralizingMe, PrimaryWeaponPriority.Neutralizing, "Panic", Settings.Instance.AddNeutralizersToPrimaryWeaponsPriorityTargetList); } List <EntityCache> EntitiesThatAreJammingMe = Cache.Instance.TargetedBy.Where(t => t.IsJammingMe).ToList(); if (EntitiesThatAreJammingMe.Any()) { if (Settings.Instance.DebugPanic) { Logging.Log("Panic.Normal", "We have been ECMd by [" + EntitiesThatAreJammingMe.Count() + "] Entities", Logging.Debug); } if (Cache.Instance.UseDrones) { Cache.Instance.AddDronePriorityTargets(EntitiesThatAreJammingMe, DronePriority.PriorityKillTarget, "Panic", Settings.Instance.AddECMsToDroneTargetList); } Cache.Instance.AddPrimaryWeaponPriorityTargets(EntitiesThatAreJammingMe, PrimaryWeaponPriority.Jamming, "Panic", Settings.Instance.AddECMsToPrimaryWeaponsPriorityTargetList); } List <EntityCache> EntitiesThatAreSensorDampeningMe = Cache.Instance.TargetedBy.Where(t => t.IsSensorDampeningMe).ToList(); if (EntitiesThatAreSensorDampeningMe.Any()) { if (Settings.Instance.DebugPanic) { Logging.Log("Panic.Normal", "We have been Sensor Damped by [" + EntitiesThatAreSensorDampeningMe.Count() + "] Entities", Logging.Debug); } if (Cache.Instance.UseDrones) { Cache.Instance.AddDronePriorityTargets(EntitiesThatAreSensorDampeningMe, DronePriority.PriorityKillTarget, "Panic", Settings.Instance.AddDampenersToDronePriorityTargetList); } Cache.Instance.AddPrimaryWeaponPriorityTargets(EntitiesThatAreSensorDampeningMe, PrimaryWeaponPriority.Dampening, "Panic", Settings.Instance.AddDampenersToPrimaryWeaponsPriorityTargetList); } if (Cache.Instance.Modules.Any(m => m.IsTurret)) { // // tracking disrupting targets // List <EntityCache> EntitiesThatAreTrackingDisruptingMe = Cache.Instance.TargetedBy.Where(t => t.IsTrackingDisruptingMe).ToList(); if (EntitiesThatAreTrackingDisruptingMe.Any()) { if (Settings.Instance.DebugPanic) { Logging.Log("Panic.Normal", "We have been Tracking Disrupted by [" + EntitiesThatAreTrackingDisruptingMe.Count() + "] Entities", Logging.Debug); } if (Cache.Instance.UseDrones) { Cache.Instance.AddDronePriorityTargets(EntitiesThatAreTrackingDisruptingMe, DronePriority.PriorityKillTarget, "Panic", Settings.Instance.AddTrackingDisruptorsToDronePriorityTargetList); } Cache.Instance.AddPrimaryWeaponPriorityTargets(EntitiesThatAreTrackingDisruptingMe, PrimaryWeaponPriority.Dampening, "Panic", Settings.Instance.AddTrackingDisruptorsToPrimaryWeaponsPriorityTargetList); } } } if (Math.Round(DateTime.UtcNow.Subtract(_lastPriorityTargetLogging).TotalSeconds) > Settings.Instance.ListPriorityTargetsEveryXSeconds) { _lastPriorityTargetLogging = DateTime.UtcNow; icount = 1; foreach (EntityCache target in Cache.Instance.DronePriorityEntities) { icount++; Logging.Log("Panic.ListDronePriorityTargets", "[" + icount + "][" + target.Name + "][" + Cache.Instance.MaskedID(target.Id) + "][" + Math.Round(target.Distance / 1000, 0) + "k away] WARP[" + target.IsWarpScramblingMe + "] ECM[" + target.IsJammingMe + "] Damp[" + target.IsSensorDampeningMe + "] TP[" + target.IsTargetPaintingMe + "] NEUT[" + target.IsNeutralizingMe + "]", Logging.Teal); continue; } icount = 1; foreach (EntityCache target in Cache.Instance.PrimaryWeaponPriorityEntities) { icount++; Logging.Log("Panic.ListPrimaryWeaponPriorityTargets", "[" + icount + "][" + target.Name + "][" + Cache.Instance.MaskedID(target.Id) + "][" + Math.Round(target.Distance / 1000, 0) + "k away] WARP[" + target.IsWarpScramblingMe + "] ECM[" + target.IsJammingMe + "] Damp[" + target.IsSensorDampeningMe + "] TP[" + target.IsTargetPaintingMe + "] NEUT[" + target.IsNeutralizingMe + "]", Logging.Teal); continue; } } if (Cache.Instance.ActiveShip.ArmorPercentage < 100) { Cache.Instance.NeedRepair = true; // // do not return here, we are just setting a flag for use by arm to repair or not repair... // } else { Cache.Instance.NeedRepair = false; } if (Cache.Instance.InMission && Cache.Instance.ActiveShip.CapacitorPercentage < Settings.Instance.MinimumCapacitorPct && Cache.Instance.ActiveShip.GroupId != 31) { // Only check for cap-panic while in a mission, not while doing anything else Logging.Log("Panic", "Start panicking, capacitor [" + Math.Round(Cache.Instance.ActiveShip.CapacitorPercentage, 0) + "%] below [" + Settings.Instance.MinimumCapacitorPct + "%] S[" + Math.Round(Cache.Instance.ActiveShip.ShieldPercentage, 0) + "%] A[" + Math.Round(Cache.Instance.ActiveShip.ArmorPercentage, 0) + "%] C[" + Math.Round(Cache.Instance.ActiveShip.CapacitorPercentage, 0) + "%]", Logging.Red); //Questor.panic_attempts_this_mission; Cache.Instance.PanicAttemptsThisMission++; Cache.Instance.PanicAttemptsThisPocket++; _States.CurrentPanicState = PanicState.StartPanicking; return; } if (Cache.Instance.ActiveShip.ShieldPercentage < Settings.Instance.MinimumShieldPct) { Logging.Log("Panic", "Start panicking, shield [" + Math.Round(Cache.Instance.ActiveShip.ShieldPercentage, 0) + "%] below [" + Settings.Instance.MinimumShieldPct + "%] S[" + Math.Round(Cache.Instance.ActiveShip.ShieldPercentage, 0) + "%] A[" + Math.Round(Cache.Instance.ActiveShip.ArmorPercentage, 0) + "%] C[" + Math.Round(Cache.Instance.ActiveShip.CapacitorPercentage, 0) + "%]", Logging.Red); Cache.Instance.PanicAttemptsThisMission++; Cache.Instance.PanicAttemptsThisPocket++; _States.CurrentPanicState = PanicState.StartPanicking; return; } if (Cache.Instance.ActiveShip.ArmorPercentage < Settings.Instance.MinimumArmorPct) { Logging.Log("Panic", "Start panicking, armor [" + Math.Round(Cache.Instance.ActiveShip.ArmorPercentage, 0) + "%] below [" + Settings.Instance.MinimumArmorPct + "%] S[" + Math.Round(Cache.Instance.ActiveShip.ShieldPercentage, 0) + "%] A[" + Math.Round(Cache.Instance.ActiveShip.ArmorPercentage, 0) + "%] C[" + Math.Round(Cache.Instance.ActiveShip.CapacitorPercentage, 0) + "%]", Logging.Red); Cache.Instance.PanicAttemptsThisMission++; Cache.Instance.PanicAttemptsThisPocket++; _States.CurrentPanicState = PanicState.StartPanicking; return; } BookmarkMyWreckAttempts = 1; // reset to 1 when we are known to not be in a pod anymore _delayedResume = false; if (Cache.Instance.InMission) { if (Cache.Instance.ActiveShip.GroupId == (int)Group.Capsule) { Logging.Log("Panic", "You are in a Capsule, you must have died in a mission :(", Logging.Red); _States.CurrentPanicState = PanicState.BookmarkMyWreck; } int frigates = Cache.Instance.EntitiesNotSelf.Count(e => e.IsFrigate && e.IsPlayer); int cruisers = Cache.Instance.EntitiesNotSelf.Count(e => e.IsCruiser && e.IsPlayer); int battlecruisers = Cache.Instance.EntitiesNotSelf.Count(e => e.IsBattlecruiser && e.IsPlayer); int battleships = Cache.Instance.EntitiesNotSelf.Count(e => e.IsBattleship && e.IsPlayer); if (Settings.Instance.FrigateInvasionLimit > 0 && frigates >= Settings.Instance.FrigateInvasionLimit) { _delayedResume = true; Cache.Instance.PanicAttemptsThisMission++; Cache.Instance.PanicAttemptsThisPocket++; _States.CurrentPanicState = PanicState.StartPanicking; Logging.Log("Panic", "Start panicking, mission invaded by [" + frigates + "] Frigates", Logging.Red); } if (Settings.Instance.CruiserInvasionLimit > 0 && cruisers >= Settings.Instance.CruiserInvasionLimit) { _delayedResume = true; Cache.Instance.PanicAttemptsThisMission++; Cache.Instance.PanicAttemptsThisPocket++; _States.CurrentPanicState = PanicState.StartPanicking; Logging.Log("Panic", "Start panicking, mission invaded by [" + cruisers + "] Cruisers", Logging.Red); } if (Settings.Instance.BattlecruiserInvasionLimit > 0 && battlecruisers >= Settings.Instance.BattlecruiserInvasionLimit) { _delayedResume = true; Cache.Instance.PanicAttemptsThisMission++; Cache.Instance.PanicAttemptsThisPocket++; _States.CurrentPanicState = PanicState.StartPanicking; Logging.Log("Panic", "Start panicking, mission invaded by [" + battlecruisers + "] BattleCruisers", Logging.Red); } if (Settings.Instance.BattleshipInvasionLimit > 0 && battleships >= Settings.Instance.BattleshipInvasionLimit) { _delayedResume = true; Cache.Instance.PanicAttemptsThisMission++; Cache.Instance.PanicAttemptsThisPocket++; _States.CurrentPanicState = PanicState.StartPanicking; Logging.Log("Panic", "Start panicking, mission invaded by [" + battleships + "] BattleShips", Logging.Red); } if (_delayedResume) { _randomDelay = (Settings.Instance.InvasionRandomDelay > 0 ? _random.Next(Settings.Instance.InvasionRandomDelay) : 0); _randomDelay += Settings.Instance.InvasionMinimumDelay; foreach (EntityCache enemy in Cache.Instance.EntitiesNotSelf.Where(e => e.IsPlayer)) { Logging.Log("Panic", "Invaded by: PlayerName [" + enemy.Name + "] ShipTypeID [" + enemy.TypeId + "] Distance [" + Math.Round(enemy.Distance, 0) / 1000 + "k] Velocity [" + Math.Round(enemy.Velocity, 0) + "]", Logging.Red); } } } } break; // NOTE: The difference between Panicking and StartPanicking is that the bot will move to "Panic" state once in warp & Panicking // and the bot wont go into Panic mode while still "StartPanicking" case PanicState.StartPanicking: case PanicState.Panicking: // // Add any warp scramblers to the priority list // Use the same rules here as you do before you panic, as we probably want to keep killing DPS if configured to do so // EntityCache EntityIsWarpScramblingMeWhilePanicing = Cache.Instance.TargetedBy.FirstOrDefault(t => t.IsWarpScramblingMe); if (EntityIsWarpScramblingMeWhilePanicing != null) { if (Cache.Instance.UseDrones) { Cache.Instance.AddDronePriorityTargets(Cache.Instance.TargetedBy.Where(t => t.IsWarpScramblingMe), DronePriority.WarpScrambler, "Panic", Settings.Instance.AddWarpScramblersToDronePriorityTargetList); } Cache.Instance.AddPrimaryWeaponPriorityTargets(Cache.Instance.TargetedBy.Where(t => t.IsWarpScramblingMe), PrimaryWeaponPriority.WarpScrambler, "Panic", Settings.Instance.AddWarpScramblersToPrimaryWeaponsPriorityTargetList); } // Failsafe, in theory would/should never happen if (_States.CurrentPanicState == PanicState.Panicking && Cache.Instance.TargetedBy.Any(t => t.IsWarpScramblingMe)) { // Resume is the only state that will make Questor revert to combat mode _States.CurrentPanicState = PanicState.Resume; return; } if (Cache.Instance.InStation) { Logging.Log("Panic", "Entered a station, lower panic mode", Logging.White); Settings.Instance.LoadSettings(); _States.CurrentPanicState = PanicState.Panic; return; } // Once we have warped off 500km, assume we are "safer" if (_States.CurrentPanicState == PanicState.StartPanicking && Cache.Instance.DistanceFromMe(_lastNormalX, _lastNormalY, _lastNormalZ) > (int)Distances.PanicDistanceToConsiderSafelyWarpedOff) { Logging.Log("Panic", "We have warped off: My ShipType: [" + Logging.Yellow + Cache.Instance.ActiveShip.TypeName + Logging.White + "] My ShipName [" + Logging.Yellow + Cache.Instance.ActiveShip.GivenName + Logging.White + "]", Logging.White); _States.CurrentPanicState = PanicState.Panicking; } // We leave the panicking state once we actually start warping off EntityCache station = null; if (Cache.Instance.Stations != null && Cache.Instance.Stations.Any()) { station = Cache.Instance.Stations.FirstOrDefault(); } if (station != null && Cache.Instance.InSpace) { if (Cache.Instance.InWarp) { if (Cache.Instance.PrimaryWeaponPriorityEntities != null && Cache.Instance.PrimaryWeaponPriorityEntities.Any()) { Cache.Instance.RemovePrimaryWeaponPriorityTargets(Cache.Instance.PrimaryWeaponPriorityEntities.ToList()); } if (Cache.Instance.UseDrones && Cache.Instance.DronePriorityEntities != null && Cache.Instance.DronePriorityEntities.Any()) { Cache.Instance.RemoveDronePriorityTargets(Cache.Instance.DronePriorityEntities.ToList()); } break; } if (station.Distance > (int)Distances.WarptoDistance) { NavigateOnGrid.AvoidBumpingThings(Cache.Instance.BigObjectsandGates.FirstOrDefault(), "Panic"); if (Cache.Instance.DronePriorityEntities.Any(pt => pt.IsWarpScramblingMe) || Cache.Instance.PrimaryWeaponPriorityEntities.Any(pt => pt.IsWarpScramblingMe)) { EntityCache WarpScrambledBy = Cache.Instance.DronePriorityEntities.FirstOrDefault(pt => pt.IsWarpScramblingMe) ?? Cache.Instance.PrimaryWeaponPriorityEntities.FirstOrDefault(pt => pt.IsWarpScramblingMe); if (WarpScrambledBy != null && DateTime.UtcNow > _nextWarpScrambledWarning) { _nextWarpScrambledWarning = DateTime.UtcNow.AddSeconds(20); Logging.Log("Panic", "We are scrambled by: [" + Logging.White + WarpScrambledBy.Name + Logging.Orange + "][" + Logging.White + Math.Round(WarpScrambledBy.Distance, 0) + Logging.Orange + "][" + Logging.White + WarpScrambledBy.Id + Logging.Orange + "]", Logging.Orange); _lastWarpScrambled = DateTime.UtcNow; } } if (DateTime.UtcNow > Cache.Instance.NextWarpAction || DateTime.UtcNow.Subtract(_lastWarpScrambled).TotalSeconds < Time.Instance.WarpScrambledNoDelay_seconds) //this will effectively spam warpto as soon as you are free of warp disruption if you were warp disrupted in the past 10 seconds) { if (station.WarpTo()) { Logging.Log("Panic", "Warping to [" + Logging.Yellow + station.Name + Logging.Red + "][" + Logging.Yellow + Math.Round((station.Distance / 1000) / 149598000, 2) + Logging.Red + " AU away]", Logging.Red); Cache.Instance.IsMissionPocketDone = true; } } else { Logging.Log("Panic", "Warping will be attempted again after [" + Math.Round(Cache.Instance.NextWarpAction.Subtract(DateTime.UtcNow).TotalSeconds, 0) + "sec]", Logging.Red); } //if (Cache.Instance.ActiveShip.GroupId == (int)Group.Capsule) //{ // Logging.Log("Panic", "You are in a Capsule, you must have died :(", Logging.Red); //} return; } if (station.Distance < (int)Distances.DockingRange) { if (station.Dock()) { Logging.Log("Panic", "Docking with [" + Logging.Yellow + station.Name + Logging.Red + "][" + Logging.Yellow + Math.Round((station.Distance / 1000) / 149598000, 2) + Logging.Red + " AU away]", Logging.Red); } return; } if (DateTime.UtcNow > Cache.Instance.NextTravelerAction) { if (Cache.Instance.Approaching == null || Cache.Instance.Approaching.Id != station.Id || Cache.Instance.MyShipEntity.Velocity < 50) { Logging.Log("Panic", "Approaching to [" + station.Name + "] which is [" + Math.Round(station.Distance / 1000, 0) + "k away]", Logging.Red); station.Approach(); Cache.Instance.NextTravelerAction = DateTime.UtcNow.AddSeconds(Time.Instance.ApproachDelay_seconds); return; } Logging.Log("Panic", "Already Approaching to: [" + station.Name + "] which is [" + Math.Round(station.Distance / 1000, 0) + "k away]", Logging.Red); return; } Logging.Log("Panic", "Approaching has been delayed for [" + Math.Round(Cache.Instance.NextWarpAction.Subtract(DateTime.UtcNow).TotalSeconds, 0) + "sec]", Logging.Red); return; } if (Cache.Instance.InSpace) { if (DateTime.UtcNow.Subtract(Cache.Instance.LastLoggingAction).TotalSeconds > 15) { Logging.Log("Panic", "No station found in local?", Logging.Red); } if (Cache.Instance.SafeSpotBookmarks.Any() && Cache.Instance.SafeSpotBookmarks.Any(b => b.LocationId == Cache.Instance.DirectEve.Session.SolarSystemId)) { List <DirectBookmark> SafeSpotBookmarksInLocal = new List <DirectBookmark>(Cache.Instance.SafeSpotBookmarks .Where(b => b.LocationId == Cache.Instance.DirectEve.Session.SolarSystemId) .OrderBy(b => b.CreatedOn)); if (SafeSpotBookmarksInLocal.Any()) { DirectBookmark offridSafeSpotBookmark = SafeSpotBookmarksInLocal.OrderBy(i => Cache.Instance.DistanceFromMe(i.X ?? 0, i.Y ?? 0, i.Z ?? 0)).FirstOrDefault(); if (offridSafeSpotBookmark != null) { if (Cache.Instance.InWarp) { _States.CurrentPanicState = PanicState.Panic; return; } if (Cache.Instance.TargetedBy.Any(t => t.IsWarpScramblingMe)) { Logging.Log("Panic", "We are still warp scrambled!", Logging.Red); //This runs every 'tick' so we should see it every 1.5 seconds or so _lastWarpScrambled = DateTime.UtcNow; return; } if (DateTime.UtcNow > Cache.Instance.NextWarpAction || DateTime.UtcNow.Subtract(_lastWarpScrambled).TotalSeconds < 10) //this will effectively spam warpto as soon as you are free of warp disruption if you were warp disrupted in the past 10 seconds { if (offridSafeSpotBookmark.WarpTo()) { double DistanceToBm = Cache.Instance.DistanceFromMe(offridSafeSpotBookmark.X ?? 0, offridSafeSpotBookmark.Y ?? 0, offridSafeSpotBookmark.Z ?? 0); Logging.Log("Panic", "Warping to safespot bookmark [" + offridSafeSpotBookmark.Title + "][" + Math.Round((DistanceToBm / 1000) / 149598000, 2) + " AU away]", Logging.Red); return; } return; } Logging.Log("Panic", "Warping has been delayed for [" + Math.Round(Cache.Instance.NextWarpAction.Subtract(DateTime.UtcNow).TotalSeconds, 0) + "sec]", Logging.Red); return; } } } else { // What is this you say? No star? if (Cache.Instance.Star == null) { return; } if (Cache.Instance.Star.Distance > (int)Distances.WeCanWarpToStarFromHere) { if (Cache.Instance.InWarp) { return; } if (Cache.Instance.TargetedBy.Any(t => t.IsWarpScramblingMe)) { Logging.Log("Panic", "We are still warp scrambled!", Logging.Red); //This runs every 'tick' so we should see it every 1.5 seconds or so _lastWarpScrambled = DateTime.UtcNow; return; } //this will effectively spam warpto as soon as you are free of warp disruption if you were warp disrupted in the past 10 seconds if (DateTime.UtcNow > Cache.Instance.NextWarpAction || DateTime.UtcNow.Subtract(_lastWarpScrambled).TotalSeconds < 10) { if (Cache.Instance.Star.WarpTo()) { Logging.Log("Panic", "Warping to [" + Logging.Yellow + Cache.Instance.Star.Name + Logging.Red + "][" + Logging.Yellow + Math.Round((Cache.Instance.Star.Distance / 1000) / 149598000, 2) + Logging.Red + " AU away]", Logging.Red); return; } return; } Logging.Log("Panic", "Warping has been delayed for [" + Math.Round(Cache.Instance.NextWarpAction.Subtract(DateTime.UtcNow).TotalSeconds, 0) + "sec]", Logging.Red); return; } } } Logging.Log("Panic", "At a safe location, lower panic mode", Logging.Red); Settings.Instance.LoadSettings(); _States.CurrentPanicState = PanicState.Panic; break; case PanicState.BookmarkMyWreck: BookmarkMyWreckAttempts++; if (Cache.Instance.Wrecks.Any(i => i.Name.Contains(Settings.Instance.CombatShipName))) { Cache.Instance.CreateBookmark("Wreck: " + Settings.Instance.CombatShipName); _States.CurrentPanicState = PanicState.StartPanicking; break; } if (BookmarkMyWreckAttempts++ > 3) { _States.CurrentPanicState = PanicState.StartPanicking; break; } break; case PanicState.Panic: // Do not resume until you're no longer in a capsule if (Cache.Instance.ActiveShip.GroupId == (int)Group.Capsule) { break; } if (Cache.Instance.InStation) { if (Cache.Instance.IsCorpInWar && Settings.Instance.WatchForActiveWars) { if (Settings.Instance.DebugWatchForActiveWars) { Logging.Log("Panic", "Cache.Instance.IsCorpInWar [" + Cache.Instance.IsCorpInWar + "] and Settings.Instance.WatchForActiveWars [" + Settings.Instance.WatchForActiveWars + "] staying in panic (effectively paused in station)", Logging.Debug); } Cache.Instance.Paused = true; Settings.Instance.AutoStart = false; return; } if (Cache.Instance.DirectEve.HasSupportInstances() && Settings.Instance.UseStationRepair) { if (!Cache.Instance.RepairItems("Repair Function")) { break; //attempt to use repair facilities if avail in station } } Logging.Log("Panic", "We're in a station, resume mission", Logging.Red); _States.CurrentPanicState = _delayedResume ? PanicState.DelayedResume : PanicState.Resume; } bool isSafe = Cache.Instance.ActiveShip.CapacitorPercentage >= Settings.Instance.SafeCapacitorPct; isSafe &= Cache.Instance.ActiveShip.ShieldPercentage >= Settings.Instance.SafeShieldPct; isSafe &= Cache.Instance.ActiveShip.ArmorPercentage >= Settings.Instance.SafeArmorPct; if (isSafe) { if (Cache.Instance.InSpace) { Cache.Instance.RepairAll = true; } Logging.Log("Panic", "We have recovered, resume mission", Logging.Red); _States.CurrentPanicState = _delayedResume ? PanicState.DelayedResume : PanicState.Resume; } if (_States.CurrentPanicState == PanicState.DelayedResume) { Logging.Log("Panic", "Delaying resume for " + _randomDelay + " seconds", Logging.Red); Cache.Instance.IsMissionPocketDone = false; _resumeTime = DateTime.UtcNow.AddSeconds(_randomDelay); } break; case PanicState.DelayedResume: if (DateTime.UtcNow > _resumeTime) { _States.CurrentPanicState = PanicState.Resume; } break; case PanicState.Resume: // Don't do anything here break; } }
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); }
public void ProcessState() { if (DateTime.UtcNow.Subtract(_lastPulse).TotalMilliseconds < Time.Instance.QuestorPulse_milliseconds) //default: 1500ms { return; } _lastPulse = DateTime.UtcNow; if (Cache.Instance.SessionState == "Quitting") { BeginClosingQuestor(); } if (Cache.Instance.GotoBaseNow) { _States.CurrentMiningState = MiningState.GotoBase; } if ((DateTime.UtcNow.Subtract(Cache.Instance.QuestorStarted_DateTime).TotalSeconds > 10) && (DateTime.UtcNow.Subtract(Cache.Instance.QuestorStarted_DateTime).TotalSeconds < 60)) { if (Cache.Instance.QuestorJustStarted) { Cache.Instance.QuestorJustStarted = false; Cache.Instance.SessionState = "Starting Up"; // write session log Statistics.WriteSessionLogStarting(); } } _panic.ProcessState(); if (_States.CurrentPanicState == PanicState.Panic || _States.CurrentPanicState == PanicState.Panicking) { // If Panic is in panic state, questor is in panic States.CurrentCombatMissionBehaviorState :) _States.CurrentMiningState = MiningState.Panic; if (PanicStateReset) { _States.CurrentPanicState = PanicState.Normal; PanicStateReset = false; } } else if (_States.CurrentPanicState == PanicState.Resume) { // Reset panic state _States.CurrentPanicState = PanicState.Normal; _States.CurrentTravelerState = TravelerState.Idle; _States.CurrentMiningState = MiningState.GotoBelt; } if (Settings.Instance.DebugMiningBehavior) { Logging.Log("MiningBehavior", "Pre-switch", Logging.White); } switch (_States.CurrentMiningState) { case MiningState.Default: case MiningState.Idle: _States.CurrentMiningState = MiningState.Cleanup; break; case MiningState.Cleanup: if (Cache.Instance.LootAlreadyUnloaded == false) { _States.CurrentMiningState = MiningState.GotoBase; break; } Cleanup.CheckEVEStatus(); _States.CurrentMiningState = MiningState.Arm; break; case MiningState.GotoBase: DirectBookmark miningHome = Cache.Instance.BookmarksByLabel("Mining Home").FirstOrDefault(); //Cache.Instance.DirectEve.Navigation.GetDestinationPath Traveler.TravelToMiningHomeBookmark(miningHome, "Mining go to base"); if (_States.CurrentTravelerState == TravelerState.AtDestination) // || DateTime.UtcNow.Subtract(Cache.Instance.EnteredCloseQuestor_DateTime).TotalMinutes > 10) { if (Settings.Instance.DebugGotobase) { Logging.Log("MiningBehavior", "GotoBase: We are at destination", Logging.White); } Cache.Instance.GotoBaseNow = false; //we are there - turn off the 'forced' gotobase _States.CurrentMiningState = MiningState.UnloadLoot; Traveler.Destination = null; } break; case MiningState.UnloadLoot: // // this state should never be reached in space. if we are in space and in this state we should switch to gotobase // if (Cache.Instance.InSpace) { Logging.Log(_States.CurrentCombatMissionBehaviorState.ToString(), "We are in space, how did we get set to this state while in space? Changing state to: GotoBase", Logging.White); _States.CurrentMiningState = MiningState.GotoBase; } if (_States.CurrentUnloadLootState == UnloadLootState.Idle) { Logging.Log("MiningBehavior", "UnloadLoot: Begin", Logging.White); _States.CurrentUnloadLootState = UnloadLootState.Begin; } _unloadLoot.ProcessState(); if (_States.CurrentUnloadLootState == UnloadLootState.Done) { Cache.Instance.LootAlreadyUnloaded = true; _States.CurrentUnloadLootState = UnloadLootState.Idle; if (_States.CurrentCombatState == CombatState.OutOfAmmo) { Logging.Log("MiningBehavior.UnloadLoot", "We are out of ammo", Logging.Orange); _States.CurrentMiningState = MiningState.Idle; return; } _States.CurrentMiningState = MiningState.Idle; _States.CurrentQuestorState = QuestorState.Idle; Logging.Log("MiningBehavior.Unloadloot", "CharacterMode: [" + Settings.Instance.CharacterMode + "], AfterMissionSalvaging: [" + Settings.Instance.AfterMissionSalvaging + "], MiningState: [" + _States.CurrentMiningState + "]", Logging.White); return; } break; case MiningState.Start: Cache.Instance.OpenWrecks = false; _States.CurrentMiningState = MiningState.Arm; DirectBookmark asteroidShortcut = Cache.Instance.BookmarksByLabel("Asteroid Location").FirstOrDefault(); if (asteroidShortcut != null) { asteroidShortcut.Delete(); } break; case MiningState.Arm: // // this state should never be reached in space. if we are in space and in this state we should switch to gotobase // if (Cache.Instance.InSpace) { Logging.Log(_States.CurrentMiningState.ToString(), "We are in space, how did we get set to this state while in space? Changing state to: GotoBase", Logging.White); _States.CurrentMiningState = MiningState.GotoBase; } if (_States.CurrentArmState == ArmState.Idle) { Logging.Log("Arm", "Begin", Logging.White); _States.CurrentArmState = ArmState.Begin; // Load ammo... this "fixes" the problem I experienced with not reloading after second arm phase. The quantity was getting set to 0. Arm.AmmoToLoad.Clear(); Arm.AmmoToLoad.Add(Settings.Instance.Ammo.FirstOrDefault()); //FIXME: bad hack - this should be fixed differently / elsewhere Ammo FirstAmmoToLoad = Arm.AmmoToLoad.FirstOrDefault(); if (FirstAmmoToLoad != null && FirstAmmoToLoad.Quantity == 0) { FirstAmmoToLoad.Quantity = 333; } } Arm.ProcessState(); if (_States.CurrentArmState == ArmState.NotEnoughAmmo) { // we know we are connected if we were able to arm the ship - update the lastknownGoodConnectedTime // we may be out of drones/ammo but disconnecting/reconnecting will not fix that so update the timestamp Cache.Instance.LastKnownGoodConnectedTime = DateTime.UtcNow; Cache.Instance.MyWalletBalance = Cache.Instance.DirectEve.Me.Wealth; Logging.Log("Arm", "Armstate.NotEnoughAmmo", Logging.Orange); _States.CurrentArmState = ArmState.Idle; _States.CurrentMiningState = MiningState.Error; } if (_States.CurrentArmState == ArmState.NotEnoughDrones) { // we know we are connected if we were able to arm the ship - update the lastknownGoodConnectedTime // we may be out of drones/ammo but disconnecting/reconnecting will not fix that so update the timestamp Cache.Instance.LastKnownGoodConnectedTime = DateTime.UtcNow; Cache.Instance.MyWalletBalance = Cache.Instance.DirectEve.Me.Wealth; Logging.Log("Arm", "Armstate.NotEnoughDrones", Logging.Orange); _States.CurrentArmState = ArmState.Idle; _States.CurrentMiningState = MiningState.Error; } if (_States.CurrentArmState == ArmState.Done) { 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 know we are connected if we were able to arm the ship - update the lastknownGoodConnectedTime Cache.Instance.LastKnownGoodConnectedTime = DateTime.UtcNow; Cache.Instance.MyWalletBalance = Cache.Instance.DirectEve.Me.Wealth; _States.CurrentArmState = ArmState.Idle; _States.CurrentDroneState = DroneState.WaitingForTargets; //exit the station Cache.Instance.DirectEve.ExecuteCommand(DirectCmd.CmdExitStation); //set up a wait of 10 seconds so the undock can complete _lastPulse = DateTime.UtcNow.AddSeconds(10); _States.CurrentMiningState = MiningState.GotoBelt; } } break; case MiningState.GotoBelt: if (DateTime.UtcNow.Subtract(_lastPulse).TotalMilliseconds < Time.Instance.QuestorPulse_milliseconds * 2) { return; } if (Cache.Instance.InWarp || (!Cache.Instance.InSpace && !Cache.Instance.InStation)) { return; } // // this should goto a mining system bookmark (one of possibly many) // then goto the 1st belt. This would allow for mining in systems without stations // Logging.Log("MiningBehavior", "Setting Destination to 1st Asteroid belt.", Logging.White); DirectBookmark asteroidShortcutGTB = Cache.Instance.BookmarksByLabel("Asteroid Location").FirstOrDefault(); if (asteroidShortcutGTB != null) { if (Cache.Instance.EntityById(_currentBelt.Id).Distance < 65000) { _States.CurrentMiningState = MiningState.Mine; Traveler.Destination = null; } else { asteroidShortcutGTB.WarpTo(); _lastPulse = DateTime.UtcNow; } break; } IEnumerable <EntityCache> belts = Cache.Instance.Entities.Where(i => i.GroupId == (int)Group.AsteroidBelt && !i.Name.ToLower().Contains("ice") && !EmptyBelts.Contains(i.Id)); EntityCache belt = belts.OrderBy(x => x.Distance).FirstOrDefault(); _currentBelt = belt; //Traveler.Destination = new MissionBookmarkDestination(belt); if (belt != null) { if (belt.Distance < 35000) { _States.CurrentMiningState = MiningState.Mine; Traveler.Destination = null; } else { if (belt.WarpTo()) { _lastPulse = DateTime.UtcNow; } } break; } _States.CurrentMiningState = MiningState.GotoBase; Logging.Log("MiningBehavior", "Could not find a suitable Asteroid belt.", Logging.White); Settings.Instance.AutoStart = false; break; case MiningState.Mine: IEnumerable <EntityCache> _asteroidsOnGrid = Cache.Instance.EntitiesOnGrid.Where(i => i.Distance < (int)Distances.OnGridWithMe && i.CategoryId == (int)CategoryID.Asteroid).OrderBy(i => i.Distance); IEnumerable <EntityCache> _asteroidsInRange = _asteroidsOnGrid.Where(i => i.Distance < 65000).ToList(); EntityCache asteroid = null; if (asteroid == null && _asteroidsInRange.Any(i => i.GroupId == (int)Group.Kernite)) { asteroid = _asteroidsInRange.Where(i => i.GroupId == (int)Group.Kernite).OrderBy(i => i.Distance).FirstOrDefault(); } if (asteroid == null && _asteroidsInRange.Any(i => i.GroupId == (int)Group.Plagioclase)) { asteroid = _asteroidsInRange.Where(i => i.GroupId == (int)Group.Plagioclase).OrderBy(i => i.Distance).FirstOrDefault(); } if (asteroid == null && _asteroidsInRange.Any(i => i.GroupId == (int)Group.Pyroxeres)) { asteroid = _asteroidsInRange.Where(i => i.GroupId == (int)Group.Pyroxeres).OrderBy(i => i.Distance).FirstOrDefault(); } if (asteroid == null && _asteroidsInRange.Any(i => i.GroupId == (int)Group.Scordite)) { asteroid = _asteroidsInRange.Where(i => i.GroupId == (int)Group.Scordite).OrderBy(i => i.Distance).FirstOrDefault(); } if (asteroid == null && _asteroidsInRange.Any(i => i.GroupId == (int)Group.Veldspar)) { asteroid = _asteroidsInRange.Where(i => i.GroupId == (int)Group.Veldspar).OrderBy(i => i.Distance).FirstOrDefault(); } if (asteroid == null) { EmptyBelts.Add(_currentBelt.Id); DirectBookmark asteroidShortcutBM2 = Cache.Instance.BookmarksByLabel("Asteroid Location").FirstOrDefault(); if (asteroidShortcutBM2 != null) { asteroidShortcutBM2.Delete(); } Logging.Log("MiningBehavior", "Could not find a suitable Asteroid to mine in this belt.", Logging.White); _States.CurrentMiningState = MiningState.GotoBelt; break; } Logging.Log("Mining: [", "Target Rock is [" + asteroid.Name + "][" + Math.Round(asteroid.Distance / 1000, 0) + "k] ID [" + asteroid.MaskedId + "] GroupID [" + asteroid.GroupId + "]", Logging.White); _targetAsteroidID = asteroid.Id; _targetAsteroid.Approach(); _States.CurrentMiningState = MiningState.MineAsteroid; break; case MiningState.MineAsteroid: if (Cache.Instance.EntityById(_targetAsteroidID) == null) { Logging.Log("Mining: [", "Target Rock [" + Cache.Instance.MaskedID(_targetAsteroidID) + "] has been depleted. Searching for another target.", Logging.White); _States.CurrentMiningState = MiningState.Mine; return; } _targetAsteroid = Cache.Instance.EntityById(_targetAsteroidID); Combat.ProcessState(); Drones.ProcessState(); // If we are out of ammo, return to base, Arm should then grab the right ammo / crystals / drones if (_States.CurrentCombatState == CombatState.OutOfAmmo) { Logging.Log("Combat", "Out of Ammo!", Logging.Orange); _States.CurrentMiningState = MiningState.GotoBase; } //check if we're full // // we really ought to be checking for and using the OreHold if needed, not directly using the cargohold ffs! // if (Cache.Instance.CurrentShipsCargo == null) { return; } if (Cache.Instance.CurrentShipsCargo.IsValid && (Cache.Instance.CurrentShipsCargo.UsedCapacity >= Cache.Instance.CurrentShipsCargo.Capacity * .9) && Cache.Instance.CurrentShipsCargo.Capacity > 0) { if (_States.CurrentDroneState == DroneState.WaitingForTargets) { Logging.Log("Miner:MineAsteroid", "We are full, go to base to unload. Capacity is: " + Cache.Instance.CurrentShipsCargo.Capacity + ", Used: " + Cache.Instance.CurrentShipsCargo.UsedCapacity, Logging.White); _States.CurrentMiningState = MiningState.GotoBase; break; } if (_States.CurrentDroneState == DroneState.WaitingForTargets) { Logging.Log("Miner:MineAsteroid", "We are full, but drones are busy. Drone state: " + _States.CurrentDroneState.ToString(), Logging.White); } } // // do we need to make sure the rock is in targeting range? rats that damp, frigates with crap skills?, wormhole effects... // if (_targetAsteroid.Distance < 10000) { if (_targetAsteroid.Distance < 9400) { if (_asteroidBookmarkForID != _targetAsteroid.Id) { DirectBookmark asteroidShortcutBM = Cache.Instance.BookmarksByLabel("Asteroid Location").FirstOrDefault(); if (asteroidShortcutBM != null) { asteroidShortcutBM.UpdateBookmark("Asteroid Location", "Mining Shortcut"); } else { Cache.Instance.DirectEve.BookmarkCurrentLocation("Asteroid Location", "Mining Shortcut", null); } _asteroidBookmarkForID = _targetAsteroid.Id; } } if (Cache.Instance.Targeting.Contains(_targetAsteroid)) { if (Settings.Instance.DebugMiningBehavior) { Logging.Log("Miner:MineAsteroid", "Targeting asteroid.", Logging.White); } return; //wait } if (Cache.Instance.Targets.Contains(_targetAsteroid)) { if (Settings.Instance.DebugMiningBehavior) { Logging.Log("Miner:MineAsteroid", "Asteroid Targeted.", Logging.White); } //if(!_targetAsteroid.IsActiveTarget) _targetAsteroid.MakeActiveTarget(); List <ModuleCache> miningTools = Cache.Instance.Modules.Where(m => MiningToolGroupIDs.Contains(m.GroupId)).ToList(); _minerNumber = 0; foreach (ModuleCache miningTool in miningTools) { if (Cache.Instance.LastActivatedTimeStamp != null && Cache.Instance.LastActivatedTimeStamp.ContainsKey(miningTool.ItemId)) { if (Cache.Instance.LastActivatedTimeStamp[miningTool.ItemId].AddSeconds(3) > DateTime.UtcNow) { continue; } } _minerNumber++; // Are we on the right target? if (miningTool.IsActive) { if (miningTool.TargetId != _targetAsteroid.Id) { if (miningTool.Click()) { return; } return; } continue; } // Are we deactivating? if (miningTool.IsDeactivating) { continue; } if (miningTool.Activate(_targetAsteroid)) { //only activate one module per cycle Logging.Log("Mining", "Activating mining tool [" + _minerNumber + "] on [" + _targetAsteroid.Name + "][" + Cache.Instance.MaskedID(_targetAsteroid.Id) + "][" + Math.Round(_targetAsteroid.Distance / 1000, 0) + "k away]", Logging.Teal); return; } continue; } return; } //mine //asteroid is not targeted if (Settings.Instance.DebugMiningBehavior) { Logging.Log("Miner:MineAsteroid", "Asteroid not yet targeted.", Logging.White); } if (DateTime.UtcNow < Cache.Instance.NextTargetAction) //if we just did something wait a fraction of a second { return; } if (Cache.Instance.MaxLockedTargets == 0) { if (!_isJammed) { Logging.Log("Mining", "We are jammed and can't target anything", Logging.Orange); } _isJammed = true; return; } if (_isJammed) { // Clear targeting list as it does not apply Cache.Instance.TargetingIDs.Clear(); Logging.Log("Mining", "We are no longer jammed, ReTargeting", Logging.Teal); } _isJammed = false; _targetAsteroid.LockTarget("Mining.targetAsteroid"); Cache.Instance.NextTargetAction = DateTime.UtcNow.AddMilliseconds(Time.Instance.TargetDelay_milliseconds); return; } //check 10K distance // // not inside 10k // if (Settings.Instance.DebugMiningBehavior) { Logging.Log("Miner:MineAsteroid", "Debug: Distance to Target [" + Math.Round(_targetAsteroid.Distance / 1000, 2) + "] > 10K.] Id [" + _targetAsteroid.Id + "] TargetingMe [" + Combat.TargetingMe.Count() + "]", Logging.White); } //this isn't working because Cache.Instance.Approaching.TargetValue always seems to return null. This will negatively impact combat since it won't orbit. Might want to check CombatState instead. if (Cache.Instance.IsApproaching(_targetAsteroidID) && !Cache.Instance.TargetedBy.Any()) { // // this will only approach every 15 sec // _targetAsteroid.Approach(); } break; } //ends MiningState switch } //ends ProcessState method
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 arived if (bookmark.ItemId.HasValue && bookmark.ItemId == Cache.Instance.DirectEve.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"); 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) { undockBookmark = bookmarks.FirstOrDefault(); if (undockBookmark.X == null || undockBookmark.Y == null || undockBookmark.Z == null) { Logging.Log("Traveler.StationDestination: undock bookmark [" + undockBookmark.Title + "] is unusable: it has no coords"); undockBookmark = null; } else { Logging.Log("Traveler.StationDestination: undock bookmark [" + undockBookmark.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); 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("Traveler.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("Traveler.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("Traveler.BookmarkDestination: Arrived at undock bookmark [" + undockBookmark.Title + "]"); undockBookmark = null; } else { Logging.Log("Traveler.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("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 + "]"); Cache.Instance.DoNotBreakInvul = false; bookmark.WarpTo(); nextAction = DateTime.Now.AddSeconds((int)Time.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 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); }