public override void OnButtonPress() { Logging.Write("IsConnected: {0}", IsConnected); foreach (string name in HBRelogRemoteApi.GetProfileNames()) { Logging.Write("{1}: GetProfileStatus: {0}", HBRelogRemoteApi.GetProfileStatus(name), name); HBRelogRemoteApi.SetProfileStatusText(HbProcId, TreeRoot.StatusText); } }
private async Task <bool> MainCoroutine() { if (!string.IsNullOrEmpty(CurrentProfileName)) { QBCLog.Info("Skipping Current HBRelogTask... Bye Bye Now"); HBRelogRemoteApi.SkipCurrentTask(CurrentProfileName); BehaviorDone(); return(true); } else { QBCLog.Error("Could not connect to HBRelog Server or Invalid Profile. Could not Skip Task"); BehaviorDone(); return(true); } }
public static void MonitorTimerCb(object sender, EventArgs args) { try { if (!IsConnected) { return; } if (!StyxWoW.IsInGame) { return; } if (TreeRoot.StatusText != _lastStatus && !string.IsNullOrEmpty(TreeRoot.StatusText)) { HBRelogRemoteApi.SetProfileStatusText(HbProcId, TreeRoot.StatusText); _lastStatus = TreeRoot.StatusText; } if (HeartbeatTimer.IsFinished) { HBRelogRemoteApi.Heartbeat(HbProcId); HeartbeatTimer.Reset(); } if (GameStats.IsMeasuring) { UpdateTooltip(); } } catch (Exception ex) { if (ex is CommunicationObjectFaultedException) { return; } if (ex is EndpointNotFoundException) { Logging.Write("Unable to connect to HBRelog"); } Logging.WriteException(ex); } }
private static void UpdateTooltip() { try { string tooltip = string.Empty; if (StyxWoW.Me.Level < 110) { tooltip += string.Format("XP/hr: {0}\n", GameStats.XPPerHour); } if (TreeRoot.Current.Name == "BGBuddy") { tooltip += string.Format("BGs: {0} ({1}/hr)\n", GameStats.BGsCompleted, GameStats.BGsPerHour); tooltip += string.Format("BGs won: {0} ({1}/hr)\n", GameStats.BGsWon, GameStats.BGsWonPerHour); tooltip += string.Format("BGs lost: {0} ({1}/hr)\n", GameStats.BGsLost, GameStats.BGsLostPerHour); tooltip += string.Format("Honor/hr: {0}\n", GameStats.HonorPerHour); } else { tooltip += $"Gold: {GameStats.GoldGained} ({GameStats.LootsPerHour}/hr)\n"; tooltip += string.Format("Loots: {0} ({1}/hr)\n", GameStats.Loots, GameStats.LootsPerHour); tooltip += string.Format("Deaths: {0} - ({1}/hr)\n", GameStats.Deaths, GameStats.DeathsPerHour); if (TreeRoot.Current.Name != "Gatherbuddy2") { tooltip += string.Format("Mobs killed: {0} - ({1}/hr)\n", GameStats.MobsKilled, GameStats.MobsPerHour); } } if (tooltip != _lastTooltip) { HBRelogRemoteApi.SetBotInfoToolTip(HbProcId, tooltip); _lastTooltip = tooltip; } } catch (Exception ex) { // Logging.WriteException(ex); } }
public HBRelogHelper() { Instance = this; try { AppDomain.CurrentDomain.ProcessExit += CurrentDomainProcessExit; AppDomain.CurrentDomain.UnhandledException += CurrentDomainUnhandledException; HbProcId = Process.GetCurrentProcess().Id; _pipeFactory = new ChannelFactory <IRemotingApi>(new NetNamedPipeBinding(), new EndpointAddress("net.pipe://localhost/HBRelog/Server")); HBRelogRemoteApi = _pipeFactory.CreateChannel(); //instead of spawning a new thread use the GUI one. Application.Current.Dispatcher.Invoke(new Action( delegate { _monitorTimer = new DispatcherTimer(); _monitorTimer.Tick += MonitorTimerCb; _monitorTimer.Interval = TimeSpan.FromSeconds(10); _monitorTimer.Start(); })); IsConnected = HBRelogRemoteApi.Init(HbProcId); if (IsConnected) { Logging.Write("HBRelogHelper: Connected with HBRelog"); CurrentProfileName = HBRelogRemoteApi.GetCurrentProfileName(HbProcId); } else { Logging.Write("HBRelogHelper: Could not connect to HBRelog"); } } catch (Exception ex) { // fail silently. Logging.Write(Colors.Red, ex.ToString()); } // since theres no point of this plugin showing up in plugin list lets just throw an exception. // new HB doesn't catch exceptions // throw new Exception("Ignore this exception"); }
public HBRelogHelper() { Instance = this; try { AppDomain.CurrentDomain.ProcessExit += CurrentDomainProcessExit; AppDomain.CurrentDomain.UnhandledException += CurrentDomainUnhandledException; HbProcId = Process.GetCurrentProcess().Id; var pipeInfoPath = Path.Combine(Utilities.AssemblyDirectory, "Plugins", "HBRelogHelper", "pipeName.txt"); var pipeName = File.ReadAllText(pipeInfoPath); _pipeFactory = new ChannelFactory <IRemotingApi>(new NetNamedPipeBinding(), new EndpointAddress($"net.pipe://localhost/{pipeName}/Server")); HBRelogRemoteApi = _pipeFactory.CreateChannel(); IsConnected = HBRelogRemoteApi.Init(HbProcId); if (IsConnected) { Log("Connected with HBRelog"); //instead of spawning a new thread use the GUI one. Application.Current.Dispatcher.Invoke(new Action( delegate { _monitorTimer = new DispatcherTimer(); _monitorTimer.Tick += MonitorTimerCb; _monitorTimer.Interval = TimeSpan.FromSeconds(10); _monitorTimer.Start(); })); CurrentProfileName = HBRelogRemoteApi.GetCurrentProfileName(HbProcId); } else { Log("Could not connect to HBRelog"); } } catch (Exception ex) { // fail silently. Logging.Write(Colors.Red, ex.ToString()); } }
public static void MonitorTimerCb(object sender, EventArgs args) { try { if (!IsConnected) { return; } if (!TreeRoot.IsRunning) { int profileStatus = HBRelogRemoteApi.GetProfileStatus(CurrentProfileName); // if HB isn't running after 30 seconds // and the HBRelog profile isn't paused then restart hb if (profileStatus != 1 && DateTime.Now - _runningTimeStamp >= TimeSpan.FromSeconds(50)) { HBRelogRemoteApi.RestartHB(HbProcId); } } else { _runningTimeStamp = DateTime.Now; } if (TreeRoot.StatusText != _lastStatus && !string.IsNullOrEmpty(TreeRoot.StatusText)) { HBRelogRemoteApi.SetProfileStatusText(HbProcId, TreeRoot.StatusText); _lastStatus = TreeRoot.StatusText; } if (InfoPanel.IsMeasuring) { UpdateTooltip(); } } catch (Exception ex) { Logging.WriteException(ex); } }
public override void OnStart() { // Let QuestBehaviorBase do basic initializaion of the behavior, deal with bad or deprecated attributes, // capture configuration state, install BT hooks, etc. This will also update the goal text. var isBehaviorShouldRun = OnStart_QuestBehaviorCore(); // If the quest is complete, this behavior is already done... // So we don't want to falsely inform the user of things that will be skipped. if (isBehaviorShouldRun) { HbProcId = System.Diagnostics.Process.GetCurrentProcess().Id; _pipeFactory = new ChannelFactory <IRemotingApi>(new NetNamedPipeBinding(), new EndpointAddress("net.pipe://localhost/HBRelog/Server")); try { HBRelogRemoteApi = _pipeFactory.CreateChannel(); IsConnected = HBRelogRemoteApi.Init(HbProcId); if (IsConnected) { QBCLog.DeveloperInfo("Connected to HBRelog Server"); CurrentProfileName = HBRelogRemoteApi.GetCurrentProfileName(HbProcId); QBCLog.DeveloperInfo(string.Format("HBRelog Current Profile: {0}", CurrentProfileName)); } else { QBCLog.Error("Could Not Connect to HBRelog Server at net.pipe://localhost/HBRelog/Server"); } } catch (Exception ex) { QBCLog.Error( "Could not make endpoint connection to HBRelog Application. You may not be running under HBRelog. Ignoring"); CurrentProfileName = string.Empty; } } }
public static string[] GetProfileNames() { return(HBRelogRemoteApi.GetProfileNames()); }
public static void SkipCurrentTask(string profileName) { HBRelogRemoteApi.SkipCurrentTask(profileName); }
public static void SetProfileStatusText(string status) { HBRelogRemoteApi.SetProfileStatusText(HbProcID, status); }
public static int GetProfileStatus(string profileName) { return(HBRelogRemoteApi.GetProfileStatus(profileName)); }
public static void Logon(string character, string server, string customClass, string botBase, string profilePath) { HBRelogRemoteApi.Logon(HbProcID, character, server, customClass, botBase, profilePath); }
public static void IdleProfile(string profileName, TimeSpan time) { HBRelogRemoteApi.IdleProfile(profileName, time); }
public static void PauseProfile(string profileName) { HBRelogRemoteApi.PauseProfile(profileName); }
public static void StopProfile(string profileName) { HBRelogRemoteApi.StopProfile(profileName); }
public static void RestartHB() { HBRelogRemoteApi.RestartHB(HbProcID); }