public static void WalletCheck() { if (_States.CurrentQuestorState == QuestorState.Mining || _States.CurrentQuestorState == QuestorState.CombatHelperBehavior || _States.CurrentQuestorState == QuestorState.DedicatedBookmarkSalvagerBehavior) //_States.CurrentQuestorState == QuestorState.BackgroundBehavior) { if (Settings.Instance.DebugWalletBalance) { Logging.Log("Questor.WalletCheck", "QuestorState is [" + _States.CurrentQuestorState.ToString() + "] which does not use WalletCheck", Logging.White); } return; } Cache.Instance.LastWalletCheck = DateTime.UtcNow; //Logging.Log("[Questor] Wallet Balance Debug Info: LastKnownGoodConnectedTime = " + Settings.Instance.lastKnownGoodConnectedTime); //Logging.Log("[Questor] Wallet Balance Debug Info: DateTime.UtcNow - LastKnownGoodConnectedTime = " + DateTime.UtcNow.Subtract(Settings.Instance.LastKnownGoodConnectedTime).TotalSeconds); if (Math.Round(DateTime.UtcNow.Subtract(Cache.Instance.LastKnownGoodConnectedTime).TotalMinutes) > 1) { Logging.Log("Questor.WalletCheck", String.Format("Wallet Balance Has Not Changed in [ {0} ] minutes.", Math.Round(DateTime.UtcNow.Subtract(Cache.Instance.LastKnownGoodConnectedTime).TotalMinutes, 0)), Logging.White); } if (Settings.Instance.DebugWalletBalance) { Logging.Log("Questor.WalletCheck", String.Format("DEBUG: Wallet Balance [ {0} ] has been checked.", Math.Round(DateTime.UtcNow.Subtract(Cache.Instance.LastKnownGoodConnectedTime).TotalMinutes, 0)), Logging.Yellow); } //Settings.Instance.WalletBalanceChangeLogOffDelay = 2; //used for debugging purposes //Logging.Log("Cache.Instance.lastKnownGoodConnectedTime is currently: " + Cache.Instance.LastKnownGoodConnectedTime); if (Math.Round(DateTime.UtcNow.Subtract(Cache.Instance.LastKnownGoodConnectedTime).TotalMinutes) < Settings.Instance.WalletBalanceChangeLogOffDelay) { try { if ((long)Cache.Instance.MyWalletBalance != (long)Cache.Instance.DirectEve.Me.Wealth) { Cache.Instance.LastKnownGoodConnectedTime = DateTime.UtcNow; Cache.Instance.MyWalletBalance = Cache.Instance.DirectEve.Me.Wealth; } } catch (Exception exception) { Logging.Log("Questor.WalletCheck", "Checking my wallet balance caused an exception [" + exception + "]", Logging.White); } } else if (Settings.Instance.WalletBalanceChangeLogOffDelay != 0) { if ((Cache.Instance.InStation) || (Math.Round(DateTime.UtcNow.Subtract(Cache.Instance.LastKnownGoodConnectedTime).TotalMinutes) > Settings.Instance.WalletBalanceChangeLogOffDelay + 5)) { Logging.Log("Questor", String.Format("Questor: Wallet Balance Has Not Changed in [ {0} ] minutes. Switching to QuestorState.CloseQuestor", Math.Round(DateTime.UtcNow.Subtract(Cache.Instance.LastKnownGoodConnectedTime).TotalMinutes, 0)), Logging.White); Cache.Instance.ReasonToStopQuestor = "Wallet Balance did not change for over " + Settings.Instance.WalletBalanceChangeLogOffDelay + "min"; Cache.Instance.CloseQuestorCMDLogoff = false; Cache.Instance.CloseQuestorCMDExitGame = true; Cache.Instance.SessionState = "Exiting"; Cleanup.BeginClosingQuestor(); return; } // // it is assumed if you got this far that you are in space. If you are 'stuck' in a session change then you'll be stuck another 5 min until the timeout above. // _States.CurrentDedicatedBookmarkSalvagerBehaviorState = DedicatedBookmarkSalvagerBehaviorState.GotoBase; _States.CurrentCombatMissionBehaviorState = CombatMissionsBehaviorState.GotoBase; _States.CurrentCombatHelperBehaviorState = CombatHelperBehaviorState.GotoBase; return; } }
private void EVEOnFrame(object sender, EventArgs e) { if (!OnframeProcessEveryPulse()) { return; } if (Settings.Instance.DebugOnframe) { Logging.Log("Questor", "OnFrame: this is Questor.cs [" + DateTime.UtcNow + "] by default the next pulse will be in [" + Time.Instance.QuestorPulse_milliseconds + "]milliseconds", Logging.Teal); } RunOnceAfterStartup(); RunOnceInStationAfterStartup(); if (!Cache.Instance.Paused) { if (DateTime.UtcNow.Subtract(Cache.Instance.LastWalletCheck).TotalMinutes > Time.Instance.WalletCheck_minutes && !Settings.Instance.DefaultSettingsLoaded) { WalletCheck(); } } // We always check our defense state if we're in space, regardless of questor state // We also always check panic if ((Cache.Instance.LastInSpace.AddSeconds(2) > DateTime.UtcNow) && Cache.Instance.InSpace) { DebugPerformanceClearandStartTimer(); if (!Cache.Instance.DoNotBreakInvul) { _defense.ProcessState(); } DebugPerformanceStopandDisplayTimer("Defense.ProcessState"); } if (Cache.Instance.Paused || DateTime.UtcNow < _nextQuestorAction) { Cache.Instance.LastKnownGoodConnectedTime = DateTime.UtcNow; Cache.Instance.MyWalletBalance = Cache.Instance.DirectEve.Me.Wealth; Cache.Instance.GotoBaseNow = false; Cache.Instance.SessionState = string.Empty; return; } if (Cache.Instance.SessionState == "Quitting") { if (_States.CurrentQuestorState != QuestorState.CloseQuestor) { Cleanup.BeginClosingQuestor(); } } // When in warp there's nothing we can do, so ignore everything if (Cache.Instance.InSpace && Cache.Instance.InWarp) { return; } switch (_States.CurrentQuestorState) { case QuestorState.Idle: if (TimeCheck()) { return; //Should we close questor due to stoptime or runtime? } if (!SkillQueueCheck()) { return; //if we need to train skills we return here, on the next pass we will be _States.CurrentQuestorState = QuestorSate.SkillTrainer } if (Cache.Instance.StopBot) { if (Settings.Instance.DebugIdle) { Logging.Log("Questor", "Cache.Instance.StopBot = true - this is set by the LocalWatch code so that we stay in station when local is unsafe", Logging.Orange); } return; } if (_States.CurrentQuestorState == QuestorState.Idle && Settings.Instance.CharacterMode != "none" && Settings.Instance.CharacterName != null) { _States.CurrentQuestorState = QuestorState.Start; return; } Logging.Log("Questor", "Settings.Instance.CharacterMode = [" + Settings.Instance.CharacterMode + "]", Logging.Orange); _States.CurrentQuestorState = QuestorState.Error; break; case QuestorState.CombatMissionsBehavior: // // QuestorState will stay here until changed externally by the behavior we just kicked into starting // _combatMissionsBehavior.ProcessState(); break; case QuestorState.SkillTrainer: // // QuestorState will stay here until changed externally by the behavior we just kicked into starting // SkillTrainerClass.ProcessState(); break; case QuestorState.CombatHelperBehavior: // // QuestorState will stay here until changed externally by the behavior we just kicked into starting // _combatHelperBehavior.ProcessState(); break; case QuestorState.DedicatedBookmarkSalvagerBehavior: // // QuestorState will stay here until changed externally by the behavior we just kicked into starting // _dedicatedBookmarkSalvagerBehavior.ProcessState(); break; case QuestorState.DirectionalScannerBehavior: // // QuestorState will stay here until changed externally by the behavior we just kicked into starting // _directionalScannerBehavior.ProcessState(); break; case QuestorState.DebugHangarsBehavior: // // QuestorState will stay here until changed externally by the behavior we just kicked into starting // _debugHangarsBehavior.ProcessState(); break; case QuestorState.DebugReloadAll: if (!Combat.ReloadAll(Cache.Instance.EntitiesNotSelf.OrderBy(t => t.Distance).FirstOrDefault(t => t.Distance < (double)Distances.OnGridWithMe))) { return; } _States.CurrentQuestorState = QuestorState.Start; break; case QuestorState.Mining: _miningBehavior.ProcessState(); break; case QuestorState.Start: switch (Settings.Instance.CharacterMode.ToLower()) { case "combat missions": case "combat_missions": case "dps": Logging.Log("Questor", "Start Mission Behavior", Logging.White); _States.CurrentQuestorState = QuestorState.CombatMissionsBehavior; break; case "salvage": Logging.Log("Questor", "Start Salvaging Behavior", Logging.White); _States.CurrentQuestorState = QuestorState.DedicatedBookmarkSalvagerBehavior; break; case "mining": Logging.Log("Questor", "Start Mining Behavior", Logging.White); _States.CurrentQuestorState = QuestorState.Mining; _States.CurrentMiningState = MiningState.Start; break; case "combat helper": case "combat_helper": case "combathelper": Logging.Log("Questor", "Start CombatHelper Behavior", Logging.White); _States.CurrentQuestorState = QuestorState.CombatHelperBehavior; break; case "custom": Logging.Log("Questor", "Start Custom Behavior", Logging.White); //_States.CurrentQuestorState = QuestorState.BackgroundBehavior; break; case "directionalscanner": Logging.Log("Questor", "Start DirectionalScanner Behavior", Logging.White); _States.CurrentQuestorState = QuestorState.DirectionalScannerBehavior; break; } break; case QuestorState.CloseQuestor: if (Cache.Instance.ReasonToStopQuestor == string.Empty) { Cache.Instance.ReasonToStopQuestor = "case QuestorState.CloseQuestor:"; } Cleanup.CloseQuestor(Cache.Instance.ReasonToStopQuestor); return; case QuestorState.DebugCloseQuestor: //Logging.Log("ISBoxerCharacterSet: " + Settings.Instance.Lavish_ISBoxerCharacterSet); //Logging.Log("Profile: " + Settings.Instance.Lavish_InnerspaceProfile); //Logging.Log("Game: " + Settings.Instance.Lavish_Game); Logging.Log("Questor", "CloseQuestorCMDUplinkInnerspaceProfile: " + Settings.Instance.CloseQuestorCMDUplinkInnerspaceProfile, Logging.White); Logging.Log("Questor", "CloseQuestorCMDUplinkISboxerCharacterSet: " + Settings.Instance.CloseQuestorCMDUplinkIsboxerCharacterSet, Logging.White); Logging.Log("Questor", "CloseQuestorArbitraryOSCmd" + Settings.Instance.CloseQuestorArbitraryOSCmd, Logging.White); Logging.Log("Questor", "CloseQuestorOSCmdContents" + Settings.Instance.CloseQuestorOSCmdContents, Logging.White); Logging.Log("Questor", "WalletBalanceChangeLogOffDelay: " + Settings.Instance.WalletBalanceChangeLogOffDelay, Logging.White); Logging.Log("Questor", "WalletBalanceChangeLogOffDelayLogoffOrExit: " + Settings.Instance.WalletBalanceChangeLogOffDelayLogoffOrExit, Logging.White); Logging.Log("Questor", "EVEProcessMemoryCeiling: " + Settings.Instance.EVEProcessMemoryCeiling, Logging.White); Logging.Log("Questor", "EVEProcessMemoryCeilingLogofforExit: " + Settings.Instance.EVEProcessMemoryCeilingLogofforExit, Logging.White); Logging.Log("Questor", "Cache.Instance.CloseQuestorCMDExitGame: " + Cache.Instance.CloseQuestorCMDExitGame, Logging.White); Logging.Log("Questor", "Cache.Instance.CloseQuestorCMDLogoff: " + Cache.Instance.CloseQuestorCMDLogoff, Logging.White); Logging.Log("Questor", "Cache.Instance.CloseQuestorEndProcess: " + Cache.Instance.CloseQuestorEndProcess, Logging.White); Logging.Log("Questor", "Cache.Instance.EnteredCloseQuestor_DateTime: " + Cache.Instance.EnteredCloseQuestor_DateTime.ToShortTimeString(), Logging.White); _States.CurrentQuestorState = QuestorState.Error; return; case QuestorState.DebugWindows: List <DirectWindow> windows = Cache.Instance.Windows; if (windows != null && windows.Any()) { foreach (DirectWindow window in windows) { Logging.Log("Questor", "--------------------------------------------------", Logging.Orange); Logging.Log("Questor", "Debug_Window.Name: [" + window.Name + "]", Logging.White); Logging.Log("Questor", "Debug_Window.Caption: [" + window.Caption + "]", Logging.White); Logging.Log("Questor", "Debug_Window.Type: [" + window.Type + "]", Logging.White); Logging.Log("Questor", "Debug_Window.IsModal: [" + window.IsModal + "]", Logging.White); Logging.Log("Questor", "Debug_Window.IsDialog: [" + window.IsDialog + "]", Logging.White); Logging.Log("Questor", "Debug_Window.Id: [" + window.Id + "]", Logging.White); Logging.Log("Questor", "Debug_Window.IsKillable: [" + window.IsKillable + "]", Logging.White); Logging.Log("Questor", "Debug_Window.Html: [" + window.Html + "]", Logging.White); } //Logging.Log("Questor", "Debug_InventoryWindows", Logging.White); //foreach (DirectWindow window in windows) //{ // if (window.Type.Contains("inventory")) // { // Logging.Log("Questor", "Debug_Window.Name: [" + window.Name + "]", Logging.White); // Logging.Log("Questor", "Debug_Window.Type: [" + window.Type + "]", Logging.White); // Logging.Log("Questor", "Debug_Window.Caption: [" + window.Caption + "]", Logging.White); // //Logging.Log("Questor", "Debug_Window.Type: [" + window. + "]", Logging.White); // } //} } else { Logging.Log("Questor", "DebugWindows: No Windows Found", Logging.White); } _States.CurrentQuestorState = QuestorState.Error; return; case QuestorState.DebugInventoryTree: if (Cache.Instance.PrimaryInventoryWindow.ExpandCorpHangarView()) { Logging.Log("DebugInventoryTree", "ExpandCorpHangar executed", Logging.Teal); } Logging.Log("DebugInventoryTree", "--------------------------------------------------", Logging.Orange); Logging.Log("DebugInventoryTree", "InventoryWindow.Name: [" + Cache.Instance.PrimaryInventoryWindow.Name + "]", Logging.White); Logging.Log("DebugInventoryTree", "InventoryWindow.Caption: [" + Cache.Instance.PrimaryInventoryWindow.Caption + "]", Logging.White); Logging.Log("DebugInventoryTree", "InventoryWindow.Type: [" + Cache.Instance.PrimaryInventoryWindow.Type + "]", Logging.White); Logging.Log("DebugInventoryTree", "InventoryWindow.IsModal: [" + Cache.Instance.PrimaryInventoryWindow.IsModal + "]", Logging.White); Logging.Log("DebugInventoryTree", "InventoryWindow.IsDialog: [" + Cache.Instance.PrimaryInventoryWindow.IsDialog + "]", Logging.White); Logging.Log("DebugInventoryTree", "InventoryWindow.Id: [" + Cache.Instance.PrimaryInventoryWindow.Id + "]", Logging.White); Logging.Log("DebugInventoryTree", "InventoryWindow.IsKillable: [" + Cache.Instance.PrimaryInventoryWindow.IsKillable + "]", Logging.White); Logging.Log("DebugInventoryTree", "InventoryWindow.IsReady: [" + Cache.Instance.PrimaryInventoryWindow.IsReady + "]", Logging.White); Logging.Log("DebugInventoryTree", "InventoryWindow.LocationFlag: [" + Cache.Instance.PrimaryInventoryWindow.LocationFlag + "]", Logging.White); Logging.Log("DebugInventoryTree", "InventoryWindow.currInvIdName: " + Cache.Instance.PrimaryInventoryWindow.currInvIdName, Logging.Red); Logging.Log("DebugInventoryTree", "InventoryWindow.currInvIdName: " + Cache.Instance.PrimaryInventoryWindow.currInvIdItem, Logging.Red); foreach (Int64 itemInTree in Cache.Instance.IDsinInventoryTree) { if (Cache.Instance.PrimaryInventoryWindow.GetIdsFromTree(false).Contains(itemInTree)) { Cache.Instance.PrimaryInventoryWindow.SelectTreeEntryByID(itemInTree); Cache.Instance.IDsinInventoryTree.Remove(itemInTree); break; } } break; //case QuestorState.BackgroundBehavior: // // QuestorState will stay here until changed externally by the behavior we just kicked into starting // //_backgroundbehavior.ProcessState(); //break; } }
public static bool TimeCheck() { if (DateTime.UtcNow < Cache.Instance.NextTimeCheckAction) { return(false); } Cache.Instance.NextTimeCheckAction = DateTime.UtcNow.AddSeconds(90); Logging.Log("Questor", "Checking: Current time [" + DateTime.Now.ToString(CultureInfo.InvariantCulture) + "] StopTimeSpecified [" + Cache.Instance.StopTimeSpecified + "] StopTime [ " + Cache.Instance.StopTime + "] ManualStopTime = " + Cache.Instance.ManualStopTime, Logging.White); if (DateTime.UtcNow.Subtract(Cache.Instance.QuestorStarted_DateTime).TotalMinutes > Cache.Instance.MaxRuntime) { // quit questor Logging.Log("Questor", "Maximum runtime exceeded. Quitting...", Logging.White); Cache.Instance.ReasonToStopQuestor = "Maximum runtime specified and reached."; Settings.Instance.AutoStart = false; Cache.Instance.CloseQuestorCMDLogoff = false; Cache.Instance.CloseQuestorCMDExitGame = true; Cache.Instance.SessionState = "Exiting"; Cleanup.BeginClosingQuestor(); return(true); } if (Cache.Instance.StopTimeSpecified) { if (DateTime.Now >= Cache.Instance.StopTime) { Logging.Log("Questor", "Time to stop. StopTimeSpecified and reached. Quitting game.", Logging.White); Cache.Instance.ReasonToStopQuestor = "StopTimeSpecified and reached."; Settings.Instance.AutoStart = false; Cache.Instance.CloseQuestorCMDLogoff = false; Cache.Instance.CloseQuestorCMDExitGame = true; Cache.Instance.SessionState = "Exiting"; Cleanup.BeginClosingQuestor(); return(true); } } if (DateTime.Now >= Cache.Instance.ManualRestartTime) { Logging.Log("Questor", "Time to stop. ManualRestartTime reached. Quitting game.", Logging.White); Cache.Instance.ReasonToStopQuestor = "ManualRestartTime reached."; Settings.Instance.AutoStart = true; Cache.Instance.CloseQuestorCMDLogoff = false; Cache.Instance.CloseQuestorCMDExitGame = true; Cache.Instance.SessionState = "Exiting"; Cleanup.BeginClosingQuestor(); return(true); } if (DateTime.Now >= Cache.Instance.ManualStopTime) { Logging.Log("Questor", "Time to stop. ManualStopTime reached. Quitting game.", Logging.White); Cache.Instance.ReasonToStopQuestor = "ManualStopTime reached."; Settings.Instance.AutoStart = false; Cache.Instance.CloseQuestorCMDLogoff = false; Cache.Instance.CloseQuestorCMDExitGame = true; Cache.Instance.SessionState = "Exiting"; Cleanup.BeginClosingQuestor(); return(true); } if (Cache.Instance.ExitWhenIdle) { Logging.Log("Questor", "ExitWhenIdle set to true. Quitting game.", Logging.White); Cache.Instance.ReasonToStopQuestor = "ExitWhenIdle set to true"; Settings.Instance.AutoStart = false; Cache.Instance.CloseQuestorCMDLogoff = false; Cache.Instance.CloseQuestorCMDExitGame = true; Cache.Instance.SessionState = "Exiting"; Cleanup.BeginClosingQuestor(); return(true); } if (Cache.Instance.MissionsThisSession > Cache.Instance.StopSessionAfterMissionNumber) { Logging.Log("Questor", "MissionsThisSession [" + Cache.Instance.MissionsThisSession + "] is greater than StopSessionAfterMissionNumber [" + Cache.Instance.StopSessionAfterMissionNumber + "]. Quitting game.", Logging.White); Cache.Instance.ReasonToStopQuestor = "MissionsThisSession > StopSessionAfterMissionNumber"; Settings.Instance.AutoStart = false; Cache.Instance.CloseQuestorCMDLogoff = false; Cache.Instance.CloseQuestorCMDExitGame = true; Cache.Instance.SessionState = "Exiting"; Cleanup.BeginClosingQuestor(); return(true); } return(false); }