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 { ValidateCombatMissionSettings(); 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.CurrentDirectionalScannerBehaviorState != DirectionalScannerBehaviorState.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.CurrentDirectionalScannerBehaviorState = DirectionalScannerBehaviorState.GotoNearestStation; } else { Logging.Log("Local not safe", "Station not found. Going back to base", Logging.White); _States.CurrentDirectionalScannerBehaviorState = DirectionalScannerBehaviorState.GotoBase; } Cache.Instance.StopBot = true; } } if (Cache.Instance.SessionState == "Quitting") { BeginClosingQuestor(); } if (Cache.Instance.GotoBaseNow) { _States.CurrentDirectionalScannerBehaviorState = DirectionalScannerBehaviorState.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.CurrentDirectionalScannerBehaviorState :) _States.CurrentDirectionalScannerBehaviorState = DirectionalScannerBehaviorState.Panic; DebugDirectionalScannerBehaviorStates(); 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.CurrentDirectionalScannerBehaviorState = DirectionalScannerBehaviorState.Idle; DebugDirectionalScannerBehaviorStates(); } DebugPanicstates(); //Logging.Log("test"); switch (_States.CurrentDirectionalScannerBehaviorState) { case DirectionalScannerBehaviorState.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("DirectionalScannerBehavior", "DebugIdle: StopBot [" + Cache.Instance.StopBot + "]", Logging.White); } return; } if (Cache.Instance.InSpace) { if (Settings.Instance.DebugAutoStart || Settings.Instance.DebugIdle) { Logging.Log("DirectionalScannerBehavior", "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("DirectionalScannerBehavior", "Started questor while in space, heading back to base in 15 seconds", Logging.White); LastAction = DateTime.UtcNow; _States.CurrentDirectionalScannerBehaviorState = DirectionalScannerBehaviorState.DelayedGotoBase; break; } if (DateTime.UtcNow < Cache.Instance.LastInSpace.AddSeconds(10)) { if (Settings.Instance.DebugAutoStart || Settings.Instance.DebugIdle) { Logging.Log("DirectionalScannerBehavior", "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("DirectionalScannerBehavior", "Started questor in Directional Scanner (test) mode", Logging.White); LastAction = DateTime.UtcNow; break; case DirectionalScannerBehaviorState.DelayedGotoBase: if (DateTime.UtcNow.Subtract(LastAction).TotalSeconds < Time.Instance.DelayedGotoBase_seconds) { break; } Logging.Log("DirectionalScannerBehavior", "Heading back to base", Logging.White); _States.CurrentDirectionalScannerBehaviorState = DirectionalScannerBehaviorState.GotoBase; break; case DirectionalScannerBehaviorState.GotoBase: if (Settings.Instance.DebugGotobase) { Logging.Log("DirectionalScannerBehavior", "GotoBase: AvoidBumpingThings()", Logging.White); } NavigateOnGrid.AvoidBumpingThings(Cache.Instance.BigObjects.FirstOrDefault(), "DirectionalScannerBehaviorState.GotoBase"); if (Settings.Instance.DebugGotobase) { Logging.Log("DirectionalScannerBehavior", "GotoBase: Traveler.TravelHome()", Logging.White); } Traveler.TravelHome("DirectionalScannerBehavior"); if (_States.CurrentTravelerState == TravelerState.AtDestination) // || DateTime.UtcNow.Subtract(Cache.Instance.EnteredCloseQuestor_DateTime).TotalMinutes > 10) { if (Settings.Instance.DebugGotobase) { Logging.Log("DirectionalScannerBehavior", "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.CurrentDirectionalScannerBehaviorState = DirectionalScannerBehaviorState.Idle; Traveler.Destination = null; } break; case DirectionalScannerBehaviorState.Traveler: 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("DirectionalScannerBehavior.Traveler", "No destination?", Logging.White); _States.CurrentDirectionalScannerBehaviorState = DirectionalScannerBehaviorState.Error; return; } if (destination.Count == 1 && destination.FirstOrDefault() == 0) { destination[0] = Cache.Instance.DirectEve.Session.SolarSystemId ?? -1; } if (Traveler.Destination == null || Traveler.Destination.SolarSystemId != destination.LastOrDefault()) { IEnumerable <DirectBookmark> bookmarks = Cache.Instance.AllBookmarks.Where(b => b.LocationId == destination.LastOrDefault()).ToList(); if (bookmarks.FirstOrDefault() != null && bookmarks.Any()) { Traveler.Destination = new BookmarkDestination(bookmarks.OrderBy(b => b.CreatedOn).FirstOrDefault()); } else { Logging.Log("DirectionalScannerBehavior.Traveler", "Destination: [" + Cache.Instance.DirectEve.Navigation.GetLocation(destination.Last()).Name + "]", Logging.White); Traveler.Destination = new SolarSystemDestination(destination.LastOrDefault()); } } 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("DirectionalScannerBehavior.Traveler", "an error has occurred", Logging.White); _States.CurrentDirectionalScannerBehaviorState = DirectionalScannerBehaviorState.Error; return; } if (Cache.Instance.InSpace) { Logging.Log("DirectionalScannerBehavior.Traveler", "Arrived at destination (in space, Questor stopped)", Logging.White); _States.CurrentDirectionalScannerBehaviorState = DirectionalScannerBehaviorState.Error; return; } Logging.Log("DirectionalScannerBehavior.Traveler", "Arrived at destination", Logging.White); _States.CurrentDirectionalScannerBehaviorState = DirectionalScannerBehaviorState.Idle; return; } } break; case DirectionalScannerBehaviorState.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("DirectionalScannerBehavior.GotoNearestStation", "[" + station.Name + "] which is [" + Math.Round(station.Distance / 1000, 0) + "k away]", Logging.White); _States.CurrentDirectionalScannerBehaviorState = DirectionalScannerBehaviorState.Idle; break; } break; } if (station.Distance < 1900) { if (station.Dock()) { Logging.Log("DebugBehavior.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("DirectionalScannerBehavior.GotoNearestStation", "Approaching [" + station.Name + "] which is [" + Math.Round(station.Distance / 1000, 0) + "k away]", Logging.White); station.Approach(); } } } else { _States.CurrentDirectionalScannerBehaviorState = DirectionalScannerBehaviorState.Error; //should we goto idle here? } break; case DirectionalScannerBehaviorState.PVPDirectionalScanHalfanAU: Logging.Log("DirectionalScannerBehavior", "PVPDirectionalScanhalfanAU - Starting", Logging.White); List <EntityCache> pvpDirectionalScanHalfanAUentitiesInList = Cache.Instance.Entities.Where(t => t.IsPlayer && t.Distance < (double)Distances.DirectionalScannerCloseRange).OrderBy(t => t.Distance).ToList(); Statistics.EntityStatistics(pvpDirectionalScanHalfanAUentitiesInList); Cache.Instance.Paused = true; break; case DirectionalScannerBehaviorState.PVPDirectionalScan1AU: Logging.Log("DirectionalScannerBehavior", "PVPDirectionalScan1AU - Starting", Logging.White); List <EntityCache> pvpDirectionalScan1AUentitiesInList = Cache.Instance.Entities.Where(t => t.IsPlayer && t.Distance < (double)Distances.DirectionalScannerCloseRange * 1).OrderBy(t => t.Distance).ToList(); Statistics.EntityStatistics(pvpDirectionalScan1AUentitiesInList); Cache.Instance.Paused = true; break; case DirectionalScannerBehaviorState.PVPDirectionalScan5AU: Logging.Log("DirectionalScannerBehavior", "PVPDirectionalScan5AU - Starting", Logging.White); List <EntityCache> pvpDirectionalScan5AUentitiesInList = Cache.Instance.Entities.Where(t => t.IsPlayer && t.Distance < (double)Distances.DirectionalScannerCloseRange * 5).OrderBy(t => t.Distance).ToList(); Statistics.EntityStatistics(pvpDirectionalScan5AUentitiesInList); Cache.Instance.Paused = true; break; case DirectionalScannerBehaviorState.PVPDirectionalScan10AU: Logging.Log("DirectionalScannerBehavior", "PVPDirectionalScan10AU - Starting", Logging.White); List <EntityCache> pvpDirectionalScan10AUentitiesInList = Cache.Instance.Entities.Where(t => t.IsPlayer && t.Distance < (double)Distances.DirectionalScannerCloseRange * 10).OrderBy(t => t.Distance).ToList(); Statistics.EntityStatistics(pvpDirectionalScan10AUentitiesInList); Cache.Instance.Paused = true; break; case DirectionalScannerBehaviorState.PVPDirectionalScan15AU: Logging.Log("DirectionalScannerBehavior", "PVPDirectionalScan15AU - Starting", Logging.White); List <EntityCache> pvpDirectionalScan15AUentitiesInList = Cache.Instance.Entities.Where(t => t.IsPlayer && t.Distance < (double)Distances.DirectionalScannerCloseRange * 15).OrderBy(t => t.Distance).ToList(); Statistics.EntityStatistics(pvpDirectionalScan15AUentitiesInList); Cache.Instance.Paused = true; break; case DirectionalScannerBehaviorState.PVPDirectionalScan20AU: Logging.Log("DirectionalScannerBehavior", "PVPDirectionalScan20AU - Starting", Logging.White); List <EntityCache> pvpDirectionalScan20AUentitiesInList = Cache.Instance.Entities.Where(t => t.IsPlayer && t.Distance < (double)Distances.DirectionalScannerCloseRange * 20).OrderBy(t => t.Distance).ToList(); Statistics.EntityStatistics(pvpDirectionalScan20AUentitiesInList); Cache.Instance.Paused = true; break; case DirectionalScannerBehaviorState.PVPDirectionalScan50AU: Logging.Log("DirectionalScannerBehavior", "PVPDirectionalScan50AU - Starting", Logging.White); List <EntityCache> pvpDirectionalScan50AUentitiesInList = Cache.Instance.Entities.Where(t => t.IsPlayer && t.Distance < (double)Distances.DirectionalScannerCloseRange * 50).OrderBy(t => t.Distance).ToList(); Statistics.EntityStatistics(pvpDirectionalScan50AUentitiesInList); Cache.Instance.Paused = true; break; case DirectionalScannerBehaviorState.PVEDirectionalScanHalfanAU: Logging.Log("DirectionalScannerBehavior", "PVEDirectionalScanhalfanAU - Starting", Logging.White); List <EntityCache> pveDirectionalScanHalfanAUentitiesInList = Cache.Instance.Entities.Where(t => !t.IsPlayer && t.Distance < (double)Distances.DirectionalScannerCloseRange).OrderBy(t => t.Distance).ToList(); Statistics.EntityStatistics(pveDirectionalScanHalfanAUentitiesInList); Cache.Instance.Paused = true; break; case DirectionalScannerBehaviorState.PVEDirectionalScan1AU: Logging.Log("DirectionalScannerBehavior", "PVEDirectionalScan1AU - Starting", Logging.White); List <EntityCache> pveDirectionalScan1AUentitiesInList = Cache.Instance.Entities.Where(t => !t.IsPlayer && t.Distance < (double)Distances.DirectionalScannerCloseRange * 1).OrderBy(t => t.Distance).ToList(); Statistics.EntityStatistics(pveDirectionalScan1AUentitiesInList); Cache.Instance.Paused = true; break; case DirectionalScannerBehaviorState.PVEDirectionalScan5AU: Logging.Log("DirectionalScannerBehavior", "PVEDirectionalScan5AU - Starting", Logging.White); List <EntityCache> pveDirectionalScan5AUentitiesInList = Cache.Instance.Entities.Where(t => !t.IsPlayer && t.Distance < (double)Distances.DirectionalScannerCloseRange * 5).OrderBy(t => t.Distance).ToList(); Statistics.EntityStatistics(pveDirectionalScan5AUentitiesInList); Cache.Instance.Paused = true; break; case DirectionalScannerBehaviorState.PVEDirectionalScan10AU: Logging.Log("DirectionalScannerBehavior", "PVEDirectionalScan10AU - Starting", Logging.White); List <EntityCache> pveDirectionalScan10AUentitiesInList = Cache.Instance.Entities.Where(t => !t.IsPlayer && t.Distance < (double)Distances.DirectionalScannerCloseRange * 10).OrderBy(t => t.Distance).ToList(); Statistics.EntityStatistics(pveDirectionalScan10AUentitiesInList); Cache.Instance.Paused = true; break; case DirectionalScannerBehaviorState.PVEDirectionalScan15AU: Logging.Log("DirectionalScannerBehavior", "PVEDirectionalScan15AU - Starting", Logging.White); List <EntityCache> pveDirectionalScan15AUentitiesInList = Cache.Instance.Entities.Where(t => !t.IsPlayer && t.Distance < (double)Distances.DirectionalScannerCloseRange * 15).OrderBy(t => t.Distance).ToList(); Statistics.EntityStatistics(pveDirectionalScan15AUentitiesInList); Cache.Instance.Paused = true; break; case DirectionalScannerBehaviorState.PVEDirectionalScan20AU: Logging.Log("DirectionalScannerBehavior", "PVEDirectionalScan20AU - Starting", Logging.White); List <EntityCache> pveDirectionalScan20AUentitiesInList = Cache.Instance.Entities.Where(t => !t.IsPlayer && t.Distance < (double)Distances.DirectionalScannerCloseRange * 20).OrderBy(t => t.Distance).ToList(); Statistics.EntityStatistics(pveDirectionalScan20AUentitiesInList); Cache.Instance.Paused = true; break; case DirectionalScannerBehaviorState.PVEDirectionalScan50AU: Logging.Log("DirectionalScannerBehavior", "PVEDirectionalScan50AU - Starting", Logging.White); List <EntityCache> pveDirectionalScan50AUentitiesInList = Cache.Instance.Entities.Where(t => !t.IsPlayer && t.Distance < (double)Distances.DirectionalScannerCloseRange * 50).OrderBy(t => t.Distance).ToList(); Statistics.EntityStatistics(pveDirectionalScan50AUentitiesInList); Cache.Instance.Paused = true; break; case DirectionalScannerBehaviorState.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.Entities.Where(t => t.IsNpc && !t.IsBadIdea && t.CategoryId == (int)CategoryID.Entity && !t.IsContainer).ToList(); Statistics.EntityStatistics(combatentitiesInList); Cache.Instance.Paused = true; break; case DirectionalScannerBehaviorState.LogDroneTargets: //drone targets List <EntityCache> droneentitiesInList = Cache.Instance.Entities.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 DirectionalScannerBehaviorState.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 DirectionalScannerBehaviorState.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 DirectionalScannerBehaviorState.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 DirectionalScannerBehaviorState.Default: if (_States.CurrentDirectionalScannerBehaviorState == DirectionalScannerBehaviorState.Default) { _States.CurrentDirectionalScannerBehaviorState = DirectionalScannerBehaviorState.Idle; } break; } }
public void ProcessState() { //Logging.Log("DebugHangarsBehavior","ProcessState - every tick",Logging.Teal); if (Cache.Instance.SessionState == "Quitting") { BeginClosingQuestor(); } if (Cache.Instance.GotoBaseNow) { _States.CurrentDebugHangarBehaviorState = DebugHangarsBehaviorState.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.CurrentDebugHangarBehaviorState :) _States.CurrentDebugHangarBehaviorState = DebugHangarsBehaviorState.Panic; DebugHangarsBehaviorStates(); 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.CurrentDebugHangarBehaviorState = DebugHangarsBehaviorState.Idle; DebugHangarsBehaviorStates(); } DebugPanicstates(); //Logging.Log("test"); switch (_States.CurrentDebugHangarBehaviorState) { case DebugHangarsBehaviorState.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("DebugHangarsBehavior", "DebugIdle: StopBot [" + Cache.Instance.StopBot + "]", Logging.White); } return; } if (Cache.Instance.InSpace) { if (Settings.Instance.DebugAutoStart || Settings.Instance.DebugIdle) { Logging.Log("DebugHangarsBehavior", "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("DebugHangarsBehavior", "Started questor while in space, heading back to base in 15 seconds", Logging.White); LastAction = DateTime.UtcNow; _States.CurrentDebugHangarBehaviorState = DebugHangarsBehaviorState.DelayedGotoBase; break; } if (DateTime.UtcNow < Cache.Instance.LastInSpace.AddSeconds(10)) { if (Settings.Instance.DebugAutoStart || Settings.Instance.DebugIdle) { Logging.Log("DebugHangarsBehavior", "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; LastAction = DateTime.UtcNow; break; case DebugHangarsBehaviorState.DelayedGotoBase: if (DateTime.UtcNow.Subtract(LastAction).TotalSeconds < Time.Instance.DelayedGotoBase_seconds) { break; } Logging.Log("DebugHangarsBehavior", "Heading back to base", Logging.White); _States.CurrentDebugHangarBehaviorState = DebugHangarsBehaviorState.GotoBase; break; case DebugHangarsBehaviorState.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.CurrentDebugHangarBehaviorState = DebugHangarsBehaviorState.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.CurrentDebugHangarBehaviorState = DebugHangarsBehaviorState.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.CurrentDebugHangarBehaviorState = DebugHangarsBehaviorState.Idle; } break; case DebugHangarsBehaviorState.Salvage: if (!Cache.Instance.InSpace) { return; } Cache.Instance.SalvageAll = true; Cache.Instance.OpenWrecks = true; if (Cache.Instance.CurrentShipsCargo == null) { return; } if (Settings.Instance.UnloadLootAtStation && Cache.Instance.CurrentShipsCargo.Window.IsReady && (Cache.Instance.CurrentShipsCargo.Capacity - Cache.Instance.CurrentShipsCargo.UsedCapacity) < 100) { Logging.Log("CombatMissionsBehavior.Salvage", "We are full, go to base to unload", Logging.White); _States.CurrentDebugHangarBehaviorState = DebugHangarsBehaviorState.GotoBase; break; } if (!Cache.Instance.UnlootedContainers.Any()) { break; } //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 { ApplyDebugSettings(); } break; case DebugHangarsBehaviorState.GotoBase: if (Settings.Instance.DebugGotobase) { Logging.Log("DebugHangarsBehavior", "GotoBase: AvoidBumpingThings()", Logging.White); } AvoidBumpingThings(); if (Settings.Instance.DebugGotobase) { Logging.Log("DebugHangarsBehavior", "GotoBase: TravelToAgentsStation()", Logging.White); } TravelToAgentsStation(); if (_States.CurrentTravelerState == TravelerState.AtDestination) // || DateTime.UtcNow.Subtract(Cache.Instance.EnteredCloseQuestor_DateTime).TotalMinutes > 10) { if (Settings.Instance.DebugGotobase) { Logging.Log("DebugHangarsBehavior", "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.CurrentDebugHangarBehaviorState = DebugHangarsBehaviorState.UnloadLoot; Traveler.Destination = null; } break; case DebugHangarsBehaviorState.UnloadLoot: if (_States.CurrentUnloadLootState == UnloadLootState.Idle) { Logging.Log("DebugHangarsBehavior", "UnloadLoot: Begin", Logging.White); _States.CurrentUnloadLootState = UnloadLootState.Begin; } _unloadLoot.ProcessState(); if (Settings.Instance.DebugStates) { Logging.Log("DebugHangarsBehavior", "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("DebugHangarsBehavior.UnloadLoot", "We are out of ammo", Logging.Orange); _States.CurrentDebugHangarBehaviorState = DebugHangarsBehaviorState.Idle; return; } _States.CurrentDebugHangarBehaviorState = DebugHangarsBehaviorState.Idle; Logging.Log("DebugHangarsBehavior.Unloadloot", "CharacterMode: [" + Settings.Instance.CharacterMode + "], AfterMissionSalvaging: [" + Settings.Instance.AfterMissionSalvaging + "], DebugHangarsBehaviorState: [" + _States.CurrentDebugHangarBehaviorState + "]", Logging.White); Statistics.Instance.FinishedMission = DateTime.UtcNow; return; } break; case DebugHangarsBehaviorState.Traveler: 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("DebugHangarsBehavior.Traveler", "No destination?", Logging.White); _States.CurrentDebugHangarBehaviorState = DebugHangarsBehaviorState.Error; return; } else if (destination.Count == 1 && destination.FirstOrDefault() == 0) { destination[0] = Cache.Instance.DirectEve.Session.SolarSystemId ?? -1; } if (Traveler.Destination == null || Traveler.Destination.SolarSystemId != destination.Last()) { IEnumerable <DirectBookmark> bookmarks = Cache.Instance.AllBookmarks.Where(b => b.LocationId == destination.Last()).ToList(); if (bookmarks != null && bookmarks.Any()) { Traveler.Destination = new BookmarkDestination(bookmarks.OrderBy(b => b.CreatedOn).FirstOrDefault()); } else { Logging.Log("DebugHangarsBehavior.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("DebugHangarsBehavior.Traveler", "an error has occurred", Logging.White); _States.CurrentDebugHangarBehaviorState = DebugHangarsBehaviorState.Error; return; } if (Cache.Instance.InSpace) { Logging.Log("DebugHangarsBehavior.Traveler", "Arrived at destination (in space, Questor stopped)", Logging.White); _States.CurrentDebugHangarBehaviorState = DebugHangarsBehaviorState.Error; return; } Logging.Log("DebugHangarsBehavior.Traveler", "Arrived at destination", Logging.White); _States.CurrentDebugHangarBehaviorState = DebugHangarsBehaviorState.Idle; return; } } break; case DebugHangarsBehaviorState.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("DebugHangarsBehavior.GotoNearestStation", "[" + station.Name + "] which is [" + Math.Round(station.Distance / 1000, 0) + "k away]", Logging.White); _States.CurrentDebugHangarBehaviorState = DebugHangarsBehaviorState.Idle; break; } break; } if (station.Distance < 1900) { if (station.Dock()) { Logging.Log("DebugBehavior.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)) { Cache.Instance.NextApproachAction = DateTime.UtcNow.AddSeconds(Time.Instance.ApproachDelay_seconds); Logging.Log("DebugHangarsBehavior.GotoNearestStation", "Approaching [" + station.Name + "] which is [" + Math.Round(station.Distance / 1000, 0) + "k away]", Logging.White); station.Approach(); } } } else { _States.CurrentDebugHangarBehaviorState = DebugHangarsBehaviorState.Error; //should we goto idle here? } break; case DebugHangarsBehaviorState.ReadyItemsHangar: Logging.Log("DebugHangars", "DebugHangarsState.ReadyItemsHangar:", Logging.White); if (Cache.Instance.ItemHangar == null) { return; } Cache.Instance.DebugInventoryWindows("DebugHangars"); _States.CurrentDebugHangarBehaviorState = DebugHangarsBehaviorState.Error; Cache.Instance.Paused = true; break; case DebugHangarsBehaviorState.StackItemsHangar: Logging.Log("DebugHangars", "DebugHangarsState.StackItemsHangar:", Logging.White); if (!Cache.Instance.StackItemsHangarAsAmmoHangar("DebugHangars")) { return; } Cache.Instance.DebugInventoryWindows("DebugHangars"); _States.CurrentDebugHangarBehaviorState = DebugHangarsBehaviorState.Error; Cache.Instance.Paused = true; break; case DebugHangarsBehaviorState.CloseItemsHangar: Logging.Log("DebugHangars", "DebugHangarsState.CloseItemsHangar:", Logging.White); if (!Cache.Instance.CloseItemsHangar("DebugHangars")) { return; } Cache.Instance.DebugInventoryWindows("DebugHangars"); _States.CurrentDebugHangarBehaviorState = DebugHangarsBehaviorState.Error; Cache.Instance.Paused = true; break; case DebugHangarsBehaviorState.OpenShipsHangar: Logging.Log("DebugHangars", "DebugHangarsState.OpenShipsHangar:", Logging.White); if (!Cache.Instance.OpenShipsHangar("DebugHangars")) { return; } Cache.Instance.DebugInventoryWindows("DebugHangars"); _States.CurrentDebugHangarBehaviorState = DebugHangarsBehaviorState.Error; Cache.Instance.Paused = true; break; case DebugHangarsBehaviorState.StackShipsHangar: Logging.Log("DebugHangars", "DebugHangarsState.StackShipsHangar:", Logging.White); if (!Cache.Instance.StackShipsHangar("DebugHangars")) { return; } Cache.Instance.DebugInventoryWindows("DebugHangars"); _States.CurrentDebugHangarBehaviorState = DebugHangarsBehaviorState.Error; Cache.Instance.Paused = true; break; case DebugHangarsBehaviorState.CloseShipsHangar: Logging.Log("DebugHangars", "DebugHangarsState.CloseShipsHangar:", Logging.White); if (!Cache.Instance.CloseShipsHangar("DebugHangars")) { return; } Cache.Instance.DebugInventoryWindows("DebugHangars"); _States.CurrentDebugHangarBehaviorState = DebugHangarsBehaviorState.Error; Cache.Instance.Paused = true; break; case DebugHangarsBehaviorState.OpenLootContainer: Logging.Log("DebugHangars", "DebugHangarsState.OpenLootContainer:", Logging.White); Cache.Instance.DebugInventoryWindows("DebugHangars"); _States.CurrentDebugHangarBehaviorState = DebugHangarsBehaviorState.Error; Cache.Instance.Paused = true; break; case DebugHangarsBehaviorState.StackLootContainer: Logging.Log("DebugHangars", "DebugHangarsState.StackLootContainer:", Logging.White); if (!Cache.Instance.StackLootContainer("DebugHangars")) { return; } Cache.Instance.DebugInventoryWindows("DebugHangars"); _States.CurrentDebugHangarBehaviorState = DebugHangarsBehaviorState.Error; Cache.Instance.Paused = true; break; case DebugHangarsBehaviorState.CloseLootContainer: Logging.Log("DebugHangars", "DebugHangarsState.CloseLootContainer:", Logging.White); if (!Cache.Instance.CloseLootContainer("DebugHangars")) { return; } Cache.Instance.DebugInventoryWindows("DebugHangars"); _States.CurrentDebugHangarBehaviorState = DebugHangarsBehaviorState.Error; //Cache.Instance.Paused = true; break; case DebugHangarsBehaviorState.OpenCorpAmmoHangar: Logging.Log("DebugHangars", "DebugHangarsState.OpenCorpAmmoHangar:", Logging.White); Cache.Instance.DebugInventoryWindows("DebugHangars"); Logging.Log("OpenCorpAmmoHangar", "AmmoHangar Contains [" + Cache.Instance.AmmoHangar.Items.Count() + "] Items", Logging.Debug); try { int icount = 0; foreach (DirectItem itemfound in Cache.Instance.AmmoHangar.Items) { icount++; Logging.Log("Arm.MoveItems", "Found: Name [" + itemfound.TypeName + "] Quantity [" + itemfound.Quantity + "] in the AmmoHangar", Logging.Red); if (icount > 20) { Logging.Log("Arm.MoveItems", "max items to log reached (over 20). there are probably more items but we only log 20 of em.", Logging.Red); break; } continue; } } catch (Exception exception) { Logging.Log("OpenCorpLootHangar", "Exception was: [" + exception + "]", Logging.Debug); } _States.CurrentDebugHangarBehaviorState = DebugHangarsBehaviorState.Error; Cache.Instance.Paused = true; break; case DebugHangarsBehaviorState.StackCorpAmmoHangar: Logging.Log("DebugHangars", "DebugHangarsState.StackCorpAmmoHangar:", Logging.White); if (!Cache.Instance.StackCorpAmmoHangar("DebugHangars")) { return; } Cache.Instance.DebugInventoryWindows("DebugHangars"); _States.CurrentDebugHangarBehaviorState = DebugHangarsBehaviorState.Error; Cache.Instance.Paused = true; break; case DebugHangarsBehaviorState.CloseCorpAmmoHangar: Logging.Log("DebugHangars", "DebugHangarsState.CloseCorpAmmoHangar:", Logging.White); if (!Cache.Instance.CloseCorpHangar("DebugHangars", "AMMO")) { return; } Cache.Instance.DebugInventoryWindows("DebugHangars"); _States.CurrentDebugHangarBehaviorState = DebugHangarsBehaviorState.Error; Cache.Instance.Paused = true; break; case DebugHangarsBehaviorState.OpenCorpLootHangar: Logging.Log("DebugHangars", "DebugHangarsState.OpenCorpLootHangar:", Logging.White); Cache.Instance.DebugInventoryWindows("DebugHangars"); Logging.Log("OpenCorpLootHangar", "LootHangar Contains [" + Cache.Instance.LootHangar.Items.Count() + "] Items", Logging.Debug); try { int icount2 = 0; foreach (DirectItem itemfound in Cache.Instance.LootHangar.Items) { icount2++; Logging.Log("Arm.MoveItems", "Found: Name [" + itemfound.TypeName + "] Quantity [" + itemfound.Quantity + "] in the LootHangar", Logging.Red); if (icount2 > 20) { Logging.Log("Arm.MoveItems", "max items to log reached (over 20). there are probably more items but we only log 20 of em.", Logging.Red); break; } continue; } } catch (Exception exception) { Logging.Log("OpenCorpLootHangar", "Exception was: [" + exception + "]", Logging.Debug); } _States.CurrentDebugHangarBehaviorState = DebugHangarsBehaviorState.Error; Cache.Instance.Paused = true; break; case DebugHangarsBehaviorState.StackCorpLootHangar: Logging.Log("DebugHangars", "DebugHangarsState.StackCorpLootHangar:", Logging.White); if (!Cache.Instance.StackCorpLootHangar("DebugHangars")) { return; } Cache.Instance.DebugInventoryWindows("DebugHangars"); _States.CurrentDebugHangarBehaviorState = DebugHangarsBehaviorState.Error; Cache.Instance.Paused = true; break; case DebugHangarsBehaviorState.CloseCorpLootHangar: Logging.Log("DebugHangars", "DebugHangarsState.CloseCorpLootHangar:", Logging.White); if (!Cache.Instance.CloseCorpHangar("DebugHangars", "LOOT")) { return; } Cache.Instance.DebugInventoryWindows("DebugHangars"); _States.CurrentDebugHangarBehaviorState = DebugHangarsBehaviorState.Error; Cache.Instance.Paused = true; break; case DebugHangarsBehaviorState.OpenAmmoHangar: Logging.Log("DebugHangars", "DebugHangarsState.OpenAmmoHangar:", Logging.White); Cache.Instance.DebugInventoryWindows("DebugHangars"); _States.CurrentDebugHangarBehaviorState = DebugHangarsBehaviorState.Error; Cache.Instance.Paused = true; break; case DebugHangarsBehaviorState.StackAmmoHangar: Logging.Log("DebugHangars", "DebugHangarsState.StackAmmoHangar:", Logging.White); if (!Cache.Instance.StackAmmoHangar("DebugHangars")) { return; } Cache.Instance.DebugInventoryWindows("DebugHangars"); _States.CurrentDebugHangarBehaviorState = DebugHangarsBehaviorState.Error; Cache.Instance.Paused = true; break; case DebugHangarsBehaviorState.CloseAmmoHangar: Logging.Log("DebugHangars", "DebugHangarsState.CloseAmmoHangar:", Logging.White); if (!Cache.Instance.CloseAmmoHangar("DebugHangars")) { return; } Cache.Instance.DebugInventoryWindows("DebugHangars"); _States.CurrentDebugHangarBehaviorState = DebugHangarsBehaviorState.Error; Cache.Instance.Paused = true; break; case DebugHangarsBehaviorState.OpenLootHangar: Logging.Log("DebugHangars", "DebugHangarsState.OpenLootHangar:", Logging.White); Cache.Instance.DebugInventoryWindows("DebugHangars"); _States.CurrentDebugHangarBehaviorState = DebugHangarsBehaviorState.Error; Cache.Instance.Paused = true; break; case DebugHangarsBehaviorState.StackLootHangar: Logging.Log("DebugHangars", "DebugHangarsState.StackLootHangar:", Logging.White); if (!Cache.Instance.StackLootHangar("DebugHangars")) { return; } Cache.Instance.DebugInventoryWindows("DebugHangars"); _States.CurrentDebugHangarBehaviorState = DebugHangarsBehaviorState.Error; Cache.Instance.Paused = true; break; case DebugHangarsBehaviorState.CloseLootHangar: Logging.Log("DebugHangars", "DebugHangarsState.CloseLootHangar:", Logging.White); if (!Cache.Instance.CloseLootHangar("DebugHangars")) { return; } Cache.Instance.DebugInventoryWindows("DebugHangars"); _States.CurrentDebugHangarBehaviorState = DebugHangarsBehaviorState.Error; Cache.Instance.Paused = true; break; case DebugHangarsBehaviorState.CloseAllInventoryWindows: Logging.Log("DebugHangars", "DebugHangarsState.CloseAllInventoryWindows:", Logging.White); if (!Cleanup.CloseInventoryWindows()) { return; } Cache.Instance.DebugInventoryWindows("DebugHangars"); _States.CurrentDebugHangarBehaviorState = DebugHangarsBehaviorState.Error; Cache.Instance.Paused = true; break; case DebugHangarsBehaviorState.OpenCargoHold: Logging.Log("DebugHangars", "DebugHangarsState.StackLootHangar:", Logging.White); if (Cache.Instance.CurrentShipsCargo == null) { return; } Cache.Instance.DebugInventoryWindows("DebugHangars"); _States.CurrentDebugHangarBehaviorState = DebugHangarsBehaviorState.Error; Cache.Instance.Paused = true; break; case DebugHangarsBehaviorState.StackCargoHold: Logging.Log("DebugHangars", "DebugHangarsState.CloseLootHangar:", Logging.White); if (!Cache.Instance.StackCargoHold("DebugHangars")) { return; } Cache.Instance.DebugInventoryWindows("DebugHangars"); _States.CurrentDebugHangarBehaviorState = DebugHangarsBehaviorState.Error; Cache.Instance.Paused = true; break; case DebugHangarsBehaviorState.CloseCargoHold: Logging.Log("DebugHangars", "DebugHangarsState.CloseAllInventoryWindows:", Logging.White); if (!Cache.Instance.CloseCargoHold("DebugHangars")) { return; } Cache.Instance.DebugInventoryWindows("DebugHangars"); _States.CurrentDebugHangarBehaviorState = DebugHangarsBehaviorState.Error; Cache.Instance.Paused = true; break; case DebugHangarsBehaviorState.GetAmmoHangarID: Logging.Log("DebugHangars", "DebugHangarsState.GetAmmoHangarID:", Logging.White); if (!Cache.Instance.GetCorpAmmoHangarID()) { return; } Logging.Log("DebugHangars", "AmmoHangarId [" + Cache.Instance.AmmoHangarID + "]", Logging.White); Cache.Instance.DebugInventoryWindows("DebugHangars"); _States.CurrentDebugHangarBehaviorState = DebugHangarsBehaviorState.Error; Cache.Instance.Paused = true; break; case DebugHangarsBehaviorState.GetLootHangarID: Logging.Log("DebugHangars", "DebugHangarsState.GetLootHangarID:", Logging.White); if (!Cache.Instance.GetCorpLootHangarID()) { return; } Logging.Log("DebugHangars", "LootHangarId [" + Cache.Instance.LootHangarID + "]", Logging.White); Cache.Instance.DebugInventoryWindows("DebugHangars"); _States.CurrentDebugHangarBehaviorState = DebugHangarsBehaviorState.Error; Cache.Instance.Paused = true; break; case DebugHangarsBehaviorState.OpenInventory: Logging.Log("DebugHangars", "DebugHangarsState.OpenInventory:", Logging.White); if (!Cache.Instance.OpenInventoryWindow("DebugHangarsState.OpenInventoryWindow")) { return; } _States.CurrentDebugHangarBehaviorState = DebugHangarsBehaviorState.Error; Cache.Instance.Paused = true; break; case DebugHangarsBehaviorState.ListInvTree: Logging.Log("DebugHangars", "DebugHangarsState.ListInvTree:", Logging.White); if (!Cache.Instance.ListInvTree("DebugHangarsState.ListInvTree")) { return; } _States.CurrentDebugHangarBehaviorState = DebugHangarsBehaviorState.Error; Cache.Instance.Paused = true; break; case DebugHangarsBehaviorState.OpenOreHold: Logging.Log("DebugHangars", "DebugHangarsState.OpenOreHold:", Logging.White); if (!Cache.Instance.OpenOreHold("DebugHangarsState.OpenOreHold")) { return; } _States.CurrentDebugHangarBehaviorState = DebugHangarsBehaviorState.Error; Cache.Instance.Paused = true; break; case DebugHangarsBehaviorState.Default: break; } }
//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) { if (Cache.Instance.InStation && Cache.Instance.DirectEve.Session.StationId == stationId) { Logging.Log("QuestorManager.StationDestination", "Arrived in station", Logging.White); return(true); } if (Cache.Instance.InStation) { // We are in a station, but not the correct station! if (Cache.Instance.NextUndockAction < 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.StationDestination", "We're docked in the wrong station, undocking", Logging.White); Cache.Instance.DirectEve.ExecuteCommand(DirectCmd.CmdExitStation); Cache.Instance.NextUndockAction = DateTime.UtcNow.AddSeconds(Time.Instance.TravelerExitStationAmIInSpaceYet_seconds); return(false); } } // 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.UtcNow) { return(false); } EntityCache station = Cache.Instance.EntityByName(stationName); if (station == null) { // We are there but no station? Wait a bit return(false); } if (station.Distance < (int)Distances.DockingRange) { if (station.Dock()) { Logging.Log("StationDestination.StationDestination", "Dock at [" + station.Name + "] which is [" + Math.Round(station.Distance / 1000, 0) + "k away]", Logging.White); nextAction = DateTime.UtcNow.AddSeconds(30); } return(false); } if (station.Distance < (int)Distances.WarptoDistance) { if (DateTime.UtcNow > Cache.Instance.NextApproachAction) { Logging.Log("TravelerDestination.StationDestination", "Approaching [" + station.Name + "] which is [" + Math.Round(station.Distance / 1000, 0) + "k away]", Logging.White); station.Approach(); nextAction = DateTime.UtcNow.AddSeconds(30); return(false); } return(false); } if (station.WarpTo()) { Logging.Log("QuestorManager.StationDestination", "Warp to and dock at [" + station.Name + "]", Logging.White); nextAction = DateTime.UtcNow.AddSeconds(30); return(false); } 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 { ValidateCombatMissionSettings(); 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.CurrentDebugBehaviorState != DebugBehaviorState.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.CurrentDebugBehaviorState = DebugBehaviorState.GotoNearestStation; } else { Logging.Log("Local not safe", "Station not found. Going back to base", Logging.White); _States.CurrentDebugBehaviorState = DebugBehaviorState.GotoBase; } Cache.Instance.StopBot = true; } } if (Cache.Instance.SessionState == "Quitting") { BeginClosingQuestor(); } if (Cache.Instance.GotoBaseNow) { _States.CurrentDebugBehaviorState = DebugBehaviorState.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.CurrentDebugBehaviorState :) _States.CurrentDebugBehaviorState = DebugBehaviorState.Panic; DebugDebugBehaviorStates(); 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.CurrentDebugBehaviorState = DebugBehaviorState.Idle; DebugDebugBehaviorStates(); } DebugPanicstates(); //Logging.Log("test"); switch (_States.CurrentDebugBehaviorState) { case DebugBehaviorState.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("DebugBehavior", "DebugIdle: StopBot [" + Cache.Instance.StopBot + "]", Logging.White); } return; } if (Cache.Instance.InSpace) { if (Settings.Instance.DebugAutoStart || Settings.Instance.DebugIdle) { Logging.Log("DebugBehavior", "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("DebugBehavior", "Started questor while in space, heading back to base in 15 seconds", Logging.White); LastAction = DateTime.UtcNow; _States.CurrentDebugBehaviorState = DebugBehaviorState.DelayedGotoBase; break; } if (DateTime.UtcNow < Cache.Instance.LastInSpace.AddSeconds(10)) { if (Settings.Instance.DebugAutoStart || Settings.Instance.DebugIdle) { Logging.Log("DebugBehavior", "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("DebugBehavior", "Started questor in Debug mode", Logging.White); LastAction = DateTime.UtcNow; break; case DebugBehaviorState.DelayedGotoBase: if (DateTime.UtcNow.Subtract(LastAction).TotalSeconds < Time.Instance.DelayedGotoBase_seconds) { break; } Logging.Log("DebugBehavior", "Heading back to base", Logging.White); _States.CurrentDebugBehaviorState = DebugBehaviorState.GotoBase; break; case DebugBehaviorState.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.CurrentDebugBehaviorState = DebugBehaviorState.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.CurrentDebugBehaviorState = DebugBehaviorState.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.CurrentDebugBehaviorState = DebugBehaviorState.Idle; } break; case DebugBehaviorState.Salvage: if (!Cache.Instance.InSpace) { return; } Cache.Instance.SalvageAll = true; Cache.Instance.OpenWrecks = true; if (Cache.Instance.CurrentShipsCargo == null) { return; } if (Settings.Instance.UnloadLootAtStation && Cache.Instance.CurrentShipsCargo.Window.IsReady && (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()) { break; } //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 { ApplyDebugSettings(); } break; case DebugBehaviorState.GotoBase: if (Settings.Instance.DebugGotobase) { Logging.Log("DebugBehavior", "GotoBase: AvoidBumpingThings()", Logging.White); } AvoidBumpingThings(); if (Settings.Instance.DebugGotobase) { Logging.Log("DebugBehavior", "GotoBase: TravelToAgentsStation()", Logging.White); } Traveler.TravelHome("DebugBehavior.TravelHome"); if (_States.CurrentTravelerState == TravelerState.AtDestination) // || DateTime.UtcNow.Subtract(Cache.Instance.EnteredCloseQuestor_DateTime).TotalMinutes > 10) { if (Settings.Instance.DebugGotobase) { Logging.Log("DebugBehavior", "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.CurrentDebugBehaviorState = DebugBehaviorState.UnloadLoot; Traveler.Destination = null; } break; case DebugBehaviorState.UnloadLoot: if (_States.CurrentUnloadLootState == UnloadLootState.Idle) { Logging.Log("DebugBehavior", "UnloadLoot: Begin", Logging.White); _States.CurrentUnloadLootState = UnloadLootState.Begin; } _unloadLoot.ProcessState(); if (Settings.Instance.DebugStates) { Logging.Log("DebugBehavior", "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("DebugBehavior.UnloadLoot", "We are out of ammo", Logging.Orange); _States.CurrentDebugBehaviorState = DebugBehaviorState.Idle; return; } _States.CurrentDebugBehaviorState = DebugBehaviorState.Idle; Logging.Log("DebugBehavior.Unloadloot", "CharacterMode: [" + Settings.Instance.CharacterMode + "], AfterMissionSalvaging: [" + Settings.Instance.AfterMissionSalvaging + "], DebugBehaviorState: [" + _States.CurrentDebugBehaviorState + "]", Logging.White); Statistics.Instance.FinishedMission = DateTime.UtcNow; return; } break; case DebugBehaviorState.Traveler: 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("DebugBehavior.Traveler", "No destination?", Logging.White); _States.CurrentDebugBehaviorState = DebugBehaviorState.Error; return; } if (destination.Count == 1 && destination.FirstOrDefault() == 0) { destination[0] = Cache.Instance.DirectEve.Session.SolarSystemId ?? -1; } if (Traveler.Destination == null || Traveler.Destination.SolarSystemId != destination.Last()) { IEnumerable <DirectBookmark> bookmarks = Cache.Instance.AllBookmarks.Where(b => b.LocationId == destination.Last()).ToList(); if (bookmarks != null && bookmarks.Any()) { Traveler.Destination = new BookmarkDestination(bookmarks.OrderBy(b => b.CreatedOn).FirstOrDefault()); } else { Logging.Log("DebugBehavior.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("DebugBehavior.Traveler", "an error has occurred", Logging.White); _States.CurrentDebugBehaviorState = DebugBehaviorState.Error; return; } else if (Cache.Instance.InSpace) { Logging.Log("DebugBehavior.Traveler", "Arrived at destination (in space, Questor stopped)", Logging.White); _States.CurrentDebugBehaviorState = DebugBehaviorState.Error; return; } else { Logging.Log("DebugBehavior.Traveler", "Arrived at destination", Logging.White); _States.CurrentDebugBehaviorState = DebugBehaviorState.Idle; return; } } } break; case DebugBehaviorState.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("DebugBehavior.GotoNearestStation", "[" + station.Name + "] which is [" + Math.Round(station.Distance / 1000, 0) + "k away]", Logging.White); _States.CurrentDebugBehaviorState = DebugBehaviorState.Idle; break; } break; } else { if (station.Distance < 1900) { if (station.Dock()) { Logging.Log("DebugBehavior.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)) { Cache.Instance.NextApproachAction = DateTime.UtcNow.AddSeconds(Time.Instance.ApproachDelay_seconds); Logging.Log("DebugBehavior.GotoNearestStation", "Approaching [" + station.Name + "] which is [" + Math.Round(station.Distance / 1000, 0) + "k away]", Logging.White); station.Approach(); } } } } else { _States.CurrentDebugBehaviorState = DebugBehaviorState.Error; //should we goto idle here? } break; case DebugBehaviorState.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 DebugBehaviorState.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 DebugBehaviorState.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 DebugBehaviorState.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 DebugBehaviorState.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 DebugBehaviorState.LogCansAndWrecks: //Asteroid Belts List <EntityCache> cansandWrecksInList = Cache.Instance.EntitiesOnGrid.Where(e => !e.IsSentry && e.GroupId == (int)Group.CargoContainer && e.GroupId == (int)Group.Wreck).ToList(); Statistics.EntityStatistics(cansandWrecksInList); Cache.Instance.Paused = true; break; case DebugBehaviorState.Default: _States.CurrentDebugBehaviorState = DebugBehaviorState.Idle; break; } }
internal static bool PerformFinalDestinationTask(long stationId, string stationName) { if (Cache.Instance.InStation && Cache.Instance.DirectEve.Session.StationId == stationId) { Logging.Log("TravelerDestination.StationDestination", "Arrived in station", Logging.Green); return(true); } if (Cache.Instance.InStation && DateTime.UtcNow > Cache.Instance.LastInSpace.AddSeconds(10)) { // We are in a station, but not the correct station! if (DateTime.UtcNow > Cache.Instance.NextUndockAction) { TravelerDestination.Undock(); return(false); } // We are not there yet return(false); } if ((DateTime.UtcNow > Cache.Instance.LastInStation.AddSeconds(10)) && !Cache.Instance.InSpace) { // We are not in station and not in space? Wait for a bit return(false); } if (_nextTravelerDestinationAction > DateTime.UtcNow) { return(false); } _undockAttempts = 0; if (!useInstaBookmark()) { 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"); if (Cache.Instance.Stations == null) { // We are there but no stations? Wait a bit return(false); } EntityCache station = Cache.Instance.EntitiesByName(stationName, Cache.Instance.Stations).FirstOrDefault(); if (station == null) { // We are there but no station? Wait a bit return(false); } if (station.Distance < (int)Distances.DockingRange) { if (station.Dock()) { Logging.Log("TravelerDestination.StationDestination", "Dock at [" + Logging.Yellow + station.Name + Logging.Green + "] which is [" + Math.Round(station.Distance / 1000, 0) + "k away]", Logging.Green); return(false); //we do not return true until we actually appear in the destination (station in this case) } return(false); } if (station.Distance < (int)Distances.WarptoDistance) { if (DateTime.UtcNow > Cache.Instance.NextApproachAction) { Logging.Log("TravelerDestination.StationDestination", "Approaching[" + Logging.Yellow + station.Name + Logging.Green + "] which is [" + Math.Round(station.Distance / 1000, 0) + "k away]", Logging.Green); station.Approach(); return(false); } return(false); } if (station.WarpTo()) { Logging.Log("TravelerDestination.StationDestination", "Warp to and dock at [" + Logging.Yellow + station.Name + Logging.Green + "][" + Math.Round((station.Distance / 1000) / 149598000, 2) + " AU away]", Logging.Green); return(false); } return(false); }