private static void btnResetGrid_Click(object sender, RoutedEventArgs e) { try { if (BotMain.IsRunning) { BotMain.Stop(); } if (!ZetaDia.IsInGame || !ZetaDia.Me.IsValid) { return; } Thread.Sleep(500); GridSegmentation.Reset(); GridSegmentation.Update(); BrainBehavior.DungeonExplorer.Reset(); BrainBehavior.DungeonExplorer.GetBestRoute(); } catch (Exception ex) { Logger.Log("Could not reset grid: {0}", ex); } }
public override async Task <bool> MainTask() { ResetOnGameChange(); if (ZetaDia.IsInGame && ZetaDia.Me.IsValid && QuestStepReloadLoops >= MaxReloads) { if (StopAtMax) { Core.Logger.Log("*** Max Profile Reloads Threshold Breached *** "); Core.Logger.Log("*** Profile restarts DISABLED *** "); Core.Logger.Log("*** STOPPING BOT *** "); BotMain.Stop(); return(true); } await ReloadProfile(true); return(true); } if (DateTime.UtcNow.Subtract(LastProfileReload).TotalSeconds < 2) { Core.Logger.Log("Profile loading loop detected, counted {0} reloads", QuestStepReloadLoops); return(true); } if (ZetaDia.IsInGame && ZetaDia.Me.IsValid) { await ReloadProfile(ShouldRestartGame); return(false); } return(false); }
private static async Task DisconnectBot() { Console.WriteLine("Disconnecting bot..."); await _lipheBot.Stop(); Console.WriteLine("Disconnected"); }
/// <summary> /// Initializes this <see cref="CombatRoutine" />. /// </summary> /// <remarks>Created 2012-04-03</remarks> public override void Initialize() { if (!_eventsAttached) { Log.Debug("Events Attached"); GameEvents.OnLevelUp += Monk.MonkOnLevelUp; GameEvents.OnLevelUp += Wizard.WizardOnLevelUp; GameEvents.OnLevelUp += WitchDoctor.WitchDoctorOnLevelUp; GameEvents.OnLevelUp += DemonHunter.DemonHunterOnLevelUp; GameEvents.OnLevelUp += Barbarian.BarbarianOnLevelUp; GameEvents.OnLevelUp += Crusader.CrusaderOnLevelUp; GameEvents.OnWorldTransferStart += HandleWorldTransfer; GameEvents.OnWorldChanged += OnWorldChanged; _eventsAttached = true; } if (!CreateBehaviors()) { BotMain.Stop(); return; } _lastClass = Class; Pulsator.OnPulse += SetBehaviorPulse; Navigator.PlayerMover = new BelphegorPlayerMover(); CombatTargeting.Instance.Provider = BelphegorCombatTargetingProvider.Instance; ObstacleTargeting.Instance.Provider = BelphegorObstacleTargetingProvider.Instance; Log.Info("Behaviors created"); }
private static void btnWaitTimerTag_Click(object sender, RoutedEventArgs e) { if (BotMain.IsRunning) { BotMain.Stop(); } Thread.Sleep(500); try { using (new ZetaCacheHelper()) { if (!ZetaDia.IsInGame) { return; } if (ZetaDia.Me == null) { return; } if (!ZetaDia.Me.IsValid) { return; } ZetaDia.Actors.Update(); string tagText = string.Format("\n<WaitTimer questId=\"{0}\" stepId=\"{1}\" waitTime=\"500\" />\n", ZetaDia.CurrentQuest.QuestSNO, ZetaDia.CurrentQuest.StepId); Clipboard.SetText(tagText); Logger.Log(tagText); } } catch (Exception ex) { Logger.Log(ex.ToString()); } }
static void _btnDumpCPlayer_Click(object sender, RoutedEventArgs e) { try { using (ZetaDia.Memory.SaveCacheState()) { ZetaDia.Memory.DisableCache(); if (BotMain.IsRunning) { BotMain.Stop(); Thread.Sleep(1500); } DumpCPlayer(); foreach (var slot in Enum.GetValues(typeof(HotbarSlot)).Cast <HotbarSlot>()) { DiaActiveSkill skill = ZetaDia.CPlayer.GetActiveSkillBySlot(slot); Logger.Log("{0} Active Skill: {1} RuneIndex: {2}", slot, skill.Power, skill.RuneIndex); } foreach (var power in ZetaDia.CPlayer.PassiveSkills) { Logger.Log("Passive Skill: {0}", power); } } } catch (Exception ex) { Logger.Log(ex.ToString()); } }
private static void btnIfTag_Click(object sender, RoutedEventArgs e) { if (BotMain.IsRunning) { BotMain.Stop(); } Thread.Sleep(500); try { using (new ZetaCacheHelper()) { if (!ZetaDia.IsInGame) { return; } if (ZetaDia.Me == null) { return; } if (!ZetaDia.Me.IsValid) { return; } ZetaDia.Actors.Update(); string levelAreaName = ZetaDia.SNO.LookupSNOName(SNOGroup.LevelArea, Player.LevelAreaId); string worldName = ZetaDia.WorldInfo.Name; string tagText = ""; string questInfo; string questHeader; GetQuestInfoText(out questInfo, out questHeader); if (ZetaDia.CurrentAct == Act.OpenWorld && ZetaDia.ActInfo.ActiveBounty != null) { tagText = string.Format(questHeader + "\n<If condition=\"HasQuest({5}) and CurrentWorldId=={6} and CurrentLevelAreaId=={7}\">\n\n</If>", ZetaDia.ActInfo.ActiveBounty.Info.Quest, worldName, ZetaDia.CurrentWorldId, levelAreaName, ZetaDia.CurrentLevelAreaId, ZetaDia.ActInfo.ActiveBounty.Info.QuestSNO, ZetaDia.CurrentWorldId, Player.LevelAreaId); } else if (ZetaDia.CurrentAct == Act.OpenWorld && ZetaDia.IsInTown) { if (ZetaDia.ActInfo.ActiveBounty != null) { tagText = string.Format(questHeader + "\n<If condition=\"HasQuest(0) and CurrentWorldId=={6} and CurrentLevelAreaId=={7}\">\n\n</If>", ZetaDia.ActInfo.ActiveBounty.Info.Quest, worldName, ZetaDia.CurrentWorldId, levelAreaName, ZetaDia.CurrentLevelAreaId, ZetaDia.ActInfo.ActiveBounty.Info.QuestSNO, ZetaDia.CurrentWorldId, Player.LevelAreaId); } } else { tagText = string.Format(questHeader + "\n<If condition=\"IsActiveQuest({3}) and IsActiveQuestStep({4}) and CurrentWorldId=={5} and CurrentLevelAreaId=={6}\">\n\n</If>", ZetaDia.CurrentQuest.Name, worldName, levelAreaName, ZetaDia.CurrentQuest.QuestSNO, ZetaDia.CurrentQuest.StepId, ZetaDia.CurrentWorldId, Player.LevelAreaId); } Logger.Log(tagText); } } catch (Exception ex) { Logger.Log(ex.ToString()); } }
private static RunStatus CharacterSwitch() { BotMain.StatusText = "[Funky] Hero Switch *Switching Heros*"; if (FunkyBaseExtension.Settings.General.AltHeroIndex < 0) { Logger.DBLog.InfoFormat("Hero Index Info not setup!"); BotMain.Stop(); return(RunStatus.Success); } if (HeroIndexInfo.Characters.Count == 0) { Logger.DBLog.InfoFormat("Hero Index Info not setup!"); BotMain.Stop(); return(RunStatus.Success); } if (MainHeroInfo == null) { ZetaDia.Memory.ClearCache(); MainHeroInfo = new HeroInfo(ZetaDia.Service.Hero); } _lastProfilePath = ProfileManager.CurrentProfile.Path; Logger.DBLog.InfoFormat("Switching to Hero Index {0}", FunkyBaseExtension.Settings.General.AltHeroIndex); ZetaDia.Service.GameAccount.SwitchHero(FunkyBaseExtension.Settings.General.AltHeroIndex); return(RunStatus.Running); }
private static void Stop(ILifetimeScope scope, BotMain botMain) { Console.WriteLine("Bot stopping...."); botMain?.Stop(); scope?.Dispose(); Console.WriteLine("Bot stopped"); Console.WriteLine("=============================="); }
private static void RecompilePlugins() { if (BotMain.IsRunning) { BotMain.Stop(false, "Recompiling Plugin!"); while (BotMain.BotThread.IsAlive) { Thread.Sleep(0); } } var EnabledPlugins = PluginManager.GetEnabledPlugins().ToArray(); foreach (var p in PluginManager.Plugins) { p.Enabled = false; } PluginManager.ShutdownAllPlugins(); Logger.DBLog.DebugFormat("Disposing All Routines"); foreach (var r in RoutineManager.Routines) { r.Dispose(); } string sDemonBuddyPath = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); string sTrinityPluginPath = FolderPaths.PluginPath; CodeCompiler FunkyCode = new CodeCompiler(sTrinityPluginPath); //FunkyCode.ParseFilesForCompilerOptions(); Logger.DBLog.DebugFormat("Recompiling Funky Bot"); FunkyCode.Compile(); Logger.DBLog.DebugFormat(FunkyCode.CompiledToLocation); Logger.DBLog.DebugFormat("Clearing all treehooks"); TreeHooks.Instance.ClearAll(); Logger.DBLog.DebugFormat("Disposing of current bot"); BotMain.CurrentBot.Dispose(); Logger.DBLog.DebugFormat("Removing old Assemblies"); CodeCompiler.DeleteOldAssemblies(); BrainBehavior.CreateBrain(); Logger.DBLog.DebugFormat("Reloading Plugins"); PluginManager.ReloadAllPlugins(sDemonBuddyPath + @"\Plugins\"); Logger.DBLog.DebugFormat("Enabling Plugins"); PluginManager.SetEnabledPlugins(EnabledPlugins); Logger.DBLog.DebugFormat("Reloading Routines"); RoutineManager.Reload(); }
void HandleResponse(string data) { string cmd = data.Split(' ')[0]; if (data.Split(' ').Count() > 1) { data = data.Substring(cmd.Length + 1); } switch (cmd) { case "Restart": Log("Restarting bot"); BotMain.Stop(); Thread.Sleep(1000); BotMain.Start(); Reset(); break; case "LoadProfile": LoadProfile(data); break; case "MonsterPower": var powerlevel = Convert.ToInt32(data.Trim()); Log("Recieved MonsterPowerLevel: {0}", powerlevel); if (powerlevel >= 0) { CharacterSettings.Instance.MonsterPowerLevel = powerlevel; } break; case "ForceEnableAll": ForceEnableAllPlugins(); break; case "ForceEnableYar": ForceEnableYar(); break; case "FixPulse": FixPulse(); break; case "Shutdown": Log("Received Shutdown command"); SafeCloseProcess(); break; case "Roger!": case "Unknown command!": break; default: Log("Unknown response! \"{0} {1}\"", cmd, data); break; } _recieved = true; }
private static void btnExploreAreaTag_Click(object sender, RoutedEventArgs e) { if (BotMain.IsRunning) { BotMain.Stop(); } try { using (new ZetaCacheHelper()) { if (!ZetaDia.IsInGame) { return; } if (ZetaDia.Me == null) { return; } if (!ZetaDia.Me.IsValid) { return; } ZetaDia.Actors.Update(); string questInfo; string questHeader; GetQuestInfoText(out questInfo, out questHeader); string tagText = "\n" + questHeader + "\n<ExploreDungeon " + questInfo + " until=\"ExitFound\" exitNameHash=\"0\" actorId=\"0\" pathPrecision=\"45\" boxSize=\"60\" boxTolerance=\"0.01\" objectDistance=\"45\">" + "\n <AlternateActors>" + "\n <AlternateActor actorId=\"0\" objectDistance=\"45\" />" + "\n </AlternateActors>" + "\n <AlternateMarkers>" + "\n <AlternateMarker markerNameHash=\"0\" markerDistance=\"45\" />" + "\n </AlternateMarkers>" + "\n <PriorityScenes>" + "\n <PriorityScene sceneName=\"Exit\" />" + "\n </PriorityScenes>" + "\n <IgnoreScenes>" + "\n <IgnoreScene sceneName=\"_N_\" />" + "\n <IgnoreScene sceneName=\"_S_\" />" + "\n <IgnoreScene sceneName=\"_E_\" />" + "\n <IgnoreScene sceneName=\"_W_\" />" + "\n </IgnoreScenes>" + "\n</ExploreDungeon>"; Clipboard.SetText(tagText); Logger.Log(tagText); } } catch (Exception ex) { Logger.Log(ex.ToString()); } }
public static bool OutOfGameOverlord(object ret) { if (MuleBehavior) { Logger.DBLog.Warn("Cannot Stash anymore Items and Mule behavior is disabled!"); //if (!Bot.Settings.Plugin.CreateMuleOnStashFull) //{ BotMain.Stop(true, "Cannot stash anymore items!"); return(false); //} //Skip this until we create our new A1 game.. if (RanProfile && !TransferedGear) { return(false); } //Now we finish up.. if (RanProfile && TransferedGear && !Finished) { return(true); } Logger.Write(LogLevel.OutOfGame, "Starting Mule Behavior"); CreatedCharacter = false; RanProfile = false; TransferedGear = false; if (ZetaDia.Service.GameAccount.NumEmptyHeroSlots == 0) { Logger.Write(LogLevel.OutOfGame, "No Empty Hero Slots Remain, and our stash if full.. stopping the bot!"); BotMain.Stop(true, "Cannot stash anymore items!"); } else { return(true); } } if (CharacterControl.GamblingCharacterSwitch) { return(true); } if (ExitGameBehavior.BehaviorEngaged) { return(true); } if (!CharacterControl.GameDifficultyChanged && FunkyBaseExtension.Settings.General.CustomDifficulty != String.Empty) { return(true); } return(false); }
public static bool OutOfGameOverlord(object ret) { if (MuleBehavior) { if (!Bot.Settings.Plugin.CreateMuleOnStashFull) { BotMain.Stop(true, "Cannot stash anymore items!"); return(false); } //Skip this until we create our new A1 game.. if (RanProfile && !TransferedGear) { return(false); } //Now we finish up.. if (RanProfile && TransferedGear && !Finished) { return(true); } Logger.Write(LogLevel.OutOfGame, "Starting Mule Behavior"); CreatedCharacter = false; RanProfile = false; TransferedGear = false; if (ZetaDia.Service.GameAccount.NumEmptyHeroSlots == 0) { Logger.Write(LogLevel.OutOfGame, "No Empty Hero Slots Remain, and our stash if full.. stopping the bot!"); BotMain.Stop(true, "Cannot stash anymore items!"); } else { return(true); } } //Change the Monster Power! if (Bot.Settings.Demonbuddy.EnableDemonBuddyCharacterSettings) { int overridePowerLevel = Bot.Settings.Demonbuddy.MonsterPower; Logger.DBLog.InfoFormat("[Funky] Overriding Monster Power Level to {0}", overridePowerLevel.ToString(CultureInfo.InvariantCulture)); CharacterSettings.Instance.MonsterPowerLevel = overridePowerLevel; } ////Disconnect -- Starting Profile Setup. //if (FunkyErrorClicker.FunkyErrorClicker.HadDisconnectError) //{ // Logger.DBLog.InfoFormat("[Funky] Disconnected Last Game.. Reloading Current Profile."); // //ReloadStartingProfile(); // ProfileManager.Load(Zeta.CommonBot.ProfileManager.CurrentProfile.Path); // FunkyErrorClicker.FunkyErrorClicker.HadDisconnectError=false; //} return(false); }
static void btnUseWaypointTag_Click(object sender, RoutedEventArgs e) { if (BotMain.IsRunning) { BotMain.Stop(); } Thread.Sleep(500); try { using (new ZetaCacheHelper()) { if (!ZetaDia.IsInGame) { return; } if (ZetaDia.Me == null) { return; } if (!ZetaDia.Me.IsValid) { return; } ZetaDia.Actors.Update(); List <GizmoWaypoint> objList = (from o in ZetaDia.Actors.GetActorsOfType <GizmoWaypoint>(true) where o.IsValid orderby o.Position.Distance(ZetaDia.Me.Position) select o).ToList(); string tagText = ""; if (objList.Any()) { GizmoWaypoint obj = objList.FirstOrDefault(); if (obj != null) { tagText = string.Format("\n<UseWaypoint questId=\"{0}\" stepId=\"{1}\" waypointNumber=\"{2}\" name=\"{3}\" statusText=\"\" /> \n", ZetaDia.CurrentQuest.QuestSNO, ZetaDia.CurrentQuest.StepId, obj.WaypointNumber, obj.Name); } } else { tagText = string.Format("\n<UseWaypoint questId=\"{0}\" stepId=\"{1}\" waypointNumber=\"\" name=\"\" statusText=\"\" /> \n", ZetaDia.CurrentQuest.QuestSNO, ZetaDia.CurrentQuest.StepId); } Clipboard.SetText(tagText); Logger.Log(tagText); } } catch (Exception ex) { Logger.Log(ex.ToString()); } }
private bool NotStarted() { if (!_experienceTracker.IsStarted) { _experienceTracker.Start(); } SafeZerg.Instance.DisableZerg(); if (_RiftType == RiftType.Greater) { _level = RiftData.GetGreaterRiftLevel(); } if (_runningNephalemInsteadOfGreaterRift && AdvDia.StashAndBackpackItems.Any(i => i.IsValid && i.ActorSNO == RiftData.GreaterRiftKeySNO)) { _level = RiftData.GetGreaterRiftLevel(); _RiftType = RiftType.Greater; _runningNephalemInsteadOfGreaterRift = false; return(false); } if (AdvDia.RiftQuest.State == QuestState.NotStarted && _RiftType == RiftType.Greater && !AdvDia.StashAndBackpackItems.Any(i => i.IsValid && i.ActorSNO == RiftData.GreaterRiftKeySNO)) { if (PluginSettings.Current.GreaterRiftRunNephalem) { _level = -1; _RiftType = RiftType.Nephalem; _runningNephalemInsteadOfGreaterRift = true; return(false); } else { Logger.Error("You have no Greater Rift Keys. Stopping the bot."); BotMain.Stop(); return(true); } } _currentWorldDynamicId = AdvDia.CurrentWorldDynamicId; if (AdvDia.RiftQuest.State == QuestState.InProgress && RiftData.RiftWorldIds.Contains(AdvDia.CurrentWorldId)) { State = States.SearchingForExitPortal; return(false); } State = AdvDia.CurrentWorldId == ExplorationData.ActHubWorldIds[Act.A1] ? States.InTown : States.GoingToAct1Hub; if (AdvDia.RiftQuest.State == QuestState.NotStarted) { ScenesStorage.Reset(); RiftData.EntryPortals.Clear(); _currentWorldDynamicId = 0; _previusWorldDynamicId = 0; _bossLocation = Vector3.Zero; _nextLevelPortalLocation = Vector3.Zero; _holyCowLocation = Vector3.Zero; _holyCowEventCompleted = false; _possiblyCowLevel = false; } return(false); }
private static void HandleFullStash() { Core.Logger.Error($"[StashItems] There is no space in the stash. Woops!"); if (GlobalSettings.Instance.FullInventoryHandling == FullInventoryOption.Logout) { Core.Logger.Error($"[StashItems] Shutting down DB and D3 and requesting no restarts (DemonbuddyExitCode.DoNotRestart: 12) because of DB Setting 'FullInventoryOption.Logout'!"); ZetaDia.Service.Party.LeaveGame(false); Thread.Sleep(15000); BotMain.Stop(false, ""); BotMain.Shutdown(DemonbuddyExitCode.DoNotRestart, true); } }
private static void RecompilePlugins() { if (BotMain.IsRunning) { BotMain.Stop(false, "Recompiling Plugin!"); while (BotMain.BotThread.IsAlive) { Thread.Sleep(0); } } var EnabledPlugins = PluginManager.GetEnabledPlugins().ToArray(); PluginManager.ShutdownAllPlugins(); DBLog.DebugFormat("Removing Funky from plugins"); while (PluginManager.Plugins.Any(p => p.Plugin.Name == "Funky")) { PluginManager.Plugins.Remove(PluginManager.Plugins.First(p => p.Plugin.Name == "Funky")); } DBLog.DebugFormat("Clearing all treehooks"); TreeHooks.Instance.ClearAll(); DBLog.DebugFormat("Disposing of current bot"); BotMain.CurrentBot.Dispose(); DBLog.DebugFormat("Removing old Assemblies"); CodeCompiler.DeleteOldAssemblies(); string sDemonBuddyPath = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); string sTrinityPluginPath = sDemonBuddyPath + @"\Plugins\FunkyBot\"; CodeCompiler FunkyCode = new CodeCompiler(sTrinityPluginPath); FunkyCode.ParseFilesForCompilerOptions(); DBLog.DebugFormat("Recompiling Funky Plugin"); FunkyCode.Compile(); DBLog.DebugFormat(FunkyCode.CompiledToLocation); TreeHooks.Instance.ClearAll(); BrainBehavior.CreateBrain(); DBLog.DebugFormat("Reloading Plugins"); PluginManager.ReloadAllPlugins(sDemonBuddyPath + @"\Plugins\"); DBLog.DebugFormat("Enabling Plugins"); PluginManager.SetEnabledPlugins(EnabledPlugins); }
private static void CheckGamesPerHourStop() { ulong currentGameId = ZetaDia.Service.CurrentGameId.FactoryId; bool gameIdMatch = currentGameId == LastGameId; if (!gameIdMatch) { LastGameId = currentGameId; } if (BotEvents.GameCount > 90 && DateTime.UtcNow.Subtract(BotEvents.LastBotStart).TotalSeconds > 60 && GameStats.Instance.GamesPerHour > 90 && !gameIdMatch) { BotMain.Stop(false, string.Format("[QuestTools] Forcing bot stop - high rate of games/hour detected: {0} Games/hour", GameStats.Instance.GamesPerHour)); } }
public override async Task <bool> MainTask() { var bountiesNoCoroutines = ZetaDia.Storage.Quests.Bounties.Where( b => { BountyData bd = BountyDataFactory.GetBountyData((int)b.Quest); if (bd != null && bd.Coroutines.Count == 0) { return(true); } return(false); }).ToList(); var bounties = ZetaDia.Storage.Quests.Bounties.Where( b => BountyDataFactory.GetBountyData((int)b.Quest) == null && b.State != QuestState.Completed) .ToList(); if (bountiesNoCoroutines.Count != 0) { Core.Logger.Debug("No coroutines:"); foreach (var bounty in bountiesNoCoroutines) { DumpBountyInfo(bounty); } } if (bounties.Count != 0) { Core.Logger.Debug("Not supported:"); foreach (var bounty in bounties) { DumpBountyInfo(bounty); } } if (bounties.Count != 0 || bountiesNoCoroutines.Count != 0) { BotMain.Stop(reason: "Unsupported bounty found!"); } Done(); await Coroutine.Sleep(1000); return(true); }
public static void DumpPlayerSkills() { if (BotMain.IsRunning) { BotMain.Stop(); } using (var helper = new Helpers.ZetaCacheHelper()) { HotbarSkills.Update(TrinityLogLevel.Info, LogCategory.UserInformation); foreach (var skill in HotbarSkills.PassiveSkills.ToList()) { Logger.Log("Passive: {0}", skill); } } }
/// <summary> /// The main Coroutine /// </summary> /// <returns></returns> private async Task <bool> MainCoroutine() { if (!QuestToolsSettings.Instance.AllowProfileReloading && !Force) { Logger.Log("Profile reloading disabled, skipping tag. questId=\"{0}\" stepId=\"{1}\"", ZetaDia.CurrentQuest.QuestSNO, ZetaDia.CurrentQuest.StepId); _isDone = true; return(false); } if (ZetaDia.IsInGame && ZetaDia.Me.IsValid && QuestStepReloadLoops > 15) { if (QuestToolsSettings.Instance.AllowProfileRestarts) { QuestStepReloadLoops = 0; ForceRestartAct(); return(true); } Logger.Log("*** Max Profile Reloads Threshold Breached *** "); Logger.Log("*** Profile restarts DISABLED *** "); Logger.Log("*** QuestTools STOPPING BOT *** "); BotMain.Stop(); return(true); } if (DateTime.UtcNow.Subtract(BotEvents.LastProfileReload).TotalSeconds < 2) { Logger.Log("Profile loading loop detected, counted {0} reloads", QuestStepReloadLoops); _isDone = true; return(true); } if (ZetaDia.IsInGame && ZetaDia.Me.IsValid) { _currProfile = ProfileManager.CurrentProfile.Path; Logger.Log("Reloading profile {0} {1}", _currProfile, QuestInfo()); CountReloads(); BotEvents.LastProfileReload = DateTime.UtcNow; ProfileManager.Load(_currProfile); Navigator.Clear(); return(true); } return(true); }
private void LoadProfile(string profile) { BotMain.Stop(false, "YetAnotherRelogger -> Load new profile"); if (ZetaDia.IsInGame) { ZetaDia.Service.Party.LeaveGame(); while (ZetaDia.IsInGame) { Thread.Sleep(1000); } } Thread.Sleep(2000); Log("Loading profile: {0}", profile); ProfileManager.Load(profile.Trim()); Thread.Sleep(5000); BotMain.Start(); }
public static void AssignBehaviorByName(string name) { if (!string.IsNullOrEmpty(name)) { IBehavior behavior; if (Behaviors.Items.TryGetValue(name, out behavior) && CurrentBehavior != behavior) { Log.Info("Loading behavior: {0}", name); CurrentBehavior = behavior; } } else { Log.Info("Requested behavior '{0}' was not found", name); CurrentBehavior = DefaultBehavior; BotMain.Stop(); } }
void btnResetGrid_Click(object sender, RoutedEventArgs e) { if (BotMain.IsRunning) { BotMain.Stop(); } if (!ZetaDia.IsInGame || !ZetaDia.Me.IsValid) { return; } System.Threading.Thread.Sleep(500); GridSegmentation.Reset(); GridSegmentation.Update(); BrainBehavior.DungeonExplorer.Reset(); BrainBehavior.DungeonExplorer.GetBestRoute(); }
private void ForceEnableAllPlugins() { PluginContainer test; DateTime limit; var disabledPlugins = PluginManager.Plugins.Where(p => !p.Enabled); if (!disabledPlugins.Any()) { return; } Log("Disabled plugins found. User requested all plugins be enabled through YAR. Stopping bot to enable plugins..."); BotMain.Stop(); Thread.Sleep(1000); foreach (var plugin in disabledPlugins) { try { Log("Force enable: \"{0}\"", plugin.Plugin.Name); plugin.Enabled = true; limit = DateTime.Now; while ((test = PluginManager.Plugins.FirstOrDefault(x => x.Plugin.Name.Equals(plugin.Plugin.Name))) != null && !test.Enabled) { if (DateTime.Now.Subtract(limit).TotalSeconds > 5) { Log("Failed to enable: Timeout ({0} seconds) \"{1}\"", DateTime.Now.Subtract(limit).TotalSeconds, plugin.Plugin.Name); break; } Thread.Sleep(100); } } catch (Exception ex) { Log("Failed to enable: \"{0}\"", plugin.Plugin.Name); LogException(ex); } } Log("Finished enabling plugins. Starting the bot..."); BotMain.Start(); }
void HandleResponse(string data) { string cmd = data.Split(' ')[0]; if (data.Split(' ').Count() > 1) { data = data.Substring(cmd.Length + 1); } switch (cmd) { case "Restart": Log("Restarting bot"); BotMain.Stop(); Thread.Sleep(1000); BotMain.Start(); Reset(); break; case "LoadProfile": LoadProfile(data); break; case "ForceEnableAll": ForceEnableAllPlugins(); break; case "ForceEnableYar": ForceEnableYar(); break; case "FixPulse": FixPulse(); break; case "Roger!": case "Unknown command!": break; default: Log("Unknown response! \"{0} {1}\"", cmd, data); break; } _recieved = true; }
public static void CheckForConfig() { string Filename = Variables.Me.Name + ".cfg"; string Folder = Loki.Bot.GlobalSettings.SettingsPath + "\\Allrounder\\"; if (File.Exists(Folder + Filename)) { Variables.Log.Debug("File " + Folder + Filename + " Exists"); ReadConfig(Folder + Filename); } else { Variables.Log.Debug("File " + Folder + Filename + " dosnt exists"); CreateConfig(Folder + Filename); Variables.Log.Debug("Please Check your Character-Settingsfile in " + Folder); Variables.Log.Debug("And add your spells like in the example"); BotMain.Stop("First time use"); } }
public bool GetConditionExec() { bool flag; try { if (Conditional == null) { Conditional = ScriptManager.GetCondition(Condition); } flag = Conditional(); } catch (Exception exception) { Logger.DBLog.DebugFormat(ScriptManager.FormatSyntaxErrorException(exception)); BotMain.Stop(); throw; } return(flag); }
/// <summary> /// Selects the Trinity routine in the RoutineManager /// </summary> private static void SelectTrinityRoutine() { if (!IsLatestRoutineInstalled) { return; } Application.Current.Dispatcher.BeginInvoke((Action)(() => { Logger.LogNormal("Stopping bot to select latest routine"); BotMain.Stop(); CombatRoutine trinityRoutine = (CombatRoutine)RoutineManager.Routines.FirstOrDefault(r => r.Name == "Trinity"); RoutineManager.Current = trinityRoutine; Logger.LogNormal("Routine selected, starting bot"); BotMain.Start(); })); }