public Tree Clone() { return(new Tree(vc, TreeRoot.Clone(null)) { raiting = raiting }); }
private void UserDialogExitProcessing(PopdownReason popdownReason) { // Log to Honorbuddy why we're exiting behavior... if (popdownReason.IsReasonKnown()) { string directiveRequester = (IsStopOnContinue ? "Profile Writer request" : popdownReason.IsPopdown() ? "Notification criteria no longer valid" : popdownReason.IsTimerExpiry() ? "Profile Writer request" : popdownReason.IsUserResponse() ? "User request" : "Profile Writer request"); string messageType = (popdownReason.IsTimerExpiry() ? "timer expired" : popdownReason.IsUserResponse() ? "user response" : popdownReason.IsPopdown() ? "completion criteria" : "info"); string terminationMessage = string.Format("{0} {1}", (popdownReason.IsBotStop() ? "Honorbuddy stopped due to " : "Continuing profile due to"), directiveRequester); TreeRoot.StatusText = terminationMessage; DialogText = DialogText.Replace(@"\n", System.Environment.NewLine).Replace(@"\t", "\t"); QBCLog.DeveloperInfo("[{0}, {1}] {2}\nDisposition: {3}", DialogTitle, messageType, DialogText, terminationMessage); } if (popdownReason.IsBotStop()) { TreeRoot.Stop(); } }
private void BuildTree() { TreeRoot.Clear(); var root = new TreeViewItemViewModel(this) { Text = FileName, Icon = "/icons/data.ico", IsExpanded = true }; TreeRoot.Add(root); var generalTab = Container.GetExportedValue <GeneralTabViewModel>(); root.Items.Add(new TreeViewItemViewModel(this) { Text = "(General)", Icon = "/icons/general.ico", Tab = generalTab }); Tabs.Add(generalTab); if (PEHeader.ExportDirectory.VirtualAddress > 0) { var exportTab = Container.GetExportedValue <ExportsTabViewModel>(); root.Items.Add(new TreeViewItemViewModel(this) { Text = "Exports (.edata)", Icon = "/icons/export1.ico", Tab = exportTab }); } if (PEHeader.ImportDirectory.VirtualAddress > 0) { var importsTab = Container.GetExportedValue <ImportsTabViewModel>(); root.Items.Add(new TreeViewItemViewModel(this) { Text = "Imports (.idata)", Icon = "/icons/import2.ico", Tab = importsTab }); } //if(PEHeader.ImportAddressTableDirectory.VirtualAddress > 0) { // var iatTab = Container.GetExportedValue<ImportAddressTableTabViewModel>(); // root.Items.Add(new TreeViewItemViewModel(this) { Text = "Import Address Table", Icon = "/icons/iat.ico", Tab = iatTab }); //} if (PEHeader.ResourceDirectory.VirtualAddress > 0) { root.Items.Add(new TreeViewItemViewModel(this) { Text = "Resources (.rsrc)", Icon = "/icons/resources.ico", Tab = Container.GetExportedValue <ResourcesTabViewModel>() }); } //if(PEHeader.ComDescriptorDirectory.VirtualAddress > 0) { // root.Items.Add(new TreeViewItemViewModel(this) { // Text = "CLR", // Icon = "/icons/cpu.ico", // Tab = Container.GetExportedValue<CLRTabViewModel>() // }); //} SelectedTab = generalTab; }
public override void OnStart() { // This reports problems, and stops BT processing if there was a problem with attributes... // We had to defer this action, as the 'profile line number' is not available during the element's // constructor call. OnStart_HandleAttributeProblem(); // 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 (!IsDone) { QBCLog.DeveloperInfo("\n\n " + Message + "\n"); this.UpdateGoalText(QuestId, Message); if (CloseWoW) { QBCLog.Info("Bot shutdown requested by Halt quest behavior."); TreeRoot.Shutdown(HonorbuddyExitCode.DoNotRestart, true); } else { TreeRoot.Stop("Bot stop requested by Halt quest behavior."); } } }
public async Task <bool> Run() { //we are inside POTD if (Constants.InDeepDungeon || Constants.InExitLevel) { return(false); } if (WorldManager.ZoneId != Constants.SouthShroudZoneId || GameObjectManager.GetObjectByNPCId(Constants.CaptainNpcId) == null || GameObjectManager.GetObjectByNPCId(Constants.CaptainNpcId).Distance2D(Core.Me.Location) > 35) { if (Core.Me.IsCasting) { await Coroutine.Sleep(500); return(true); } if (!WorldManager.TeleportById(5)) { Logger.Error("We can't get to Quarrymill. something is very wrong..."); TreeRoot.Stop(); return(false); } await Coroutine.Sleep(1000); return(true); } if (GameObjectManager.GetObjectByNPCId(Constants.CaptainNpcId) == null || GameObjectManager.GetObjectByNPCId(Constants.CaptainNpcId).Distance2D(Core.Me.Location) > 4f) { return(await CommonTasks.MoveAndStop(new MoveToParameters(Constants.CaptainNpcPosition, "Moving toward NPC"), 4f, true)); } return(false); }
private async Task <bool> Run() { if (!IsBusy) { await Reduction(); await Desynth(); if (ReduceSettings.Instance.OpenCoffers) { await CofferTask(); } if (Translator.Language != Language.Chn) { await Extract(); } if (InventoryManager.EquippedItems.Any(i => i.Condition < 30)) { await LlamaLibrary.Helpers.Lisbeth.SelfRepair(); } //ReduceSettings.Instance.Save(); } if (!ReduceSettings.Instance.StayRunning) { TreeRoot.Stop("Stop Requested"); } await Coroutine.Sleep(1000); return(true); }
// remove any occurance of IdentityComposite in the current BotBase, used on dispose or botbase change void BotBaseCleanUp(PrioritySelector bot) { PrioritySelector botbase = null; if (bot != null) { botbase = bot; } else if (TreeRoot.Current.Root is PrioritySelector) { botbase = TreeRoot.Current.Root as PrioritySelector; } // check if we already injected into the BotBase if (botbase != null) { bool isRunning = botbase.IsRunning; if (isRunning) { TreeRoot.Stop(); } for (int i = botbase.Children.Count - 1; i >= 0; i--) { //if (botbase.Children[i] is IdentityComposite ) // this will not work after a recompile because the types are now in different assemblies if (botbase.Children[i].GetType().Name.Contains("PBIdentityComposite")) { botbase.Children.RemoveAt(i); } } } }
void ToggleStart() { try { if (PB.IsRunning) { PB.MySettings.IsRunning = PB.IsRunning = false; PB.MySettings.Save(); } else { // reset all actions foreach (IPBComposite comp in PB.CurrentProfile.Branch.Children) { comp.Reset(); } if (PB.CodeWasModified) { PB.GenorateDynamicCode(); } PB.ProfileSettings.LoadDefaultValues(); PB.MySettings.IsRunning = PB.IsRunning = true; PB.MySettings.Save(); Professionbuddy.PreLoadHbProfile(); Professionbuddy.PreChangeBot(); if (!TreeRoot.IsRunning) TreeRoot.Start(); } UpdateControls(); } catch (Exception ex) { Professionbuddy.Err(ex.ToString()); } }
private async Task <bool> Run() { await Handin(); TreeRoot.Stop("Stop Requested"); return(true); }
public bool ChangeBot() { BotBase bot = BotManager.Instance.Bots.FirstOrDefault(b => b.Key.Contains(BotName)).Value; if (bot == null) { Professionbuddy.Err("ChangeBotAction was unable to find the following bot {0}", BotName); return(false); } Professionbuddy.Log("ChangeBotAction: Switching to {0}", BotName); new Thread(() => { try { TreeRoot.Stop(); } catch (Exception ex) { Logging.Write("ChangeBot: " + ex.ToString()); } finally { BotManager.Instance.SetCurrent(bot); Thread.Sleep(3000); TreeRoot.Start(); } }).Start(); return(true); }
private async Task <bool> Run() { Navigator.PlayerMover = new SlideMover(); Navigator.NavigationProvider = new ServiceNavigationProvider(); _playerItems = InventoryManager.GetBagsByInventoryBagId(PlayerInventoryBagIds).Select(i => i.FilledSlots).SelectMany(x => x).AsParallel().ToList(); var hadOld = await GetHuntBills(); await CompleteHunts(); if (hadOld) { await GetHuntBills(); await CompleteHunts(); } if (WorldManager.CanTeleport()) { WorldManager.TeleportById(Core.Me.HomePoint.Id); await Coroutine.Sleep(5000); if (CommonBehaviors.IsLoading) { await Coroutine.Wait(-1, () => !CommonBehaviors.IsLoading); } } TreeRoot.Stop($"Stop Requested"); return(true); }
private bool EquipPole() { WoWItem pole = _me.BagItems.FirstOrDefault(i => i.ItemInfo.WeaponClass == WoWItemWeaponClass.FishingPole); if (pole != null) { AutoAngler.Instance.Log("Equipping " + pole.Name); // fix for cases where pole is in a fish bag //using (new FrameLock()) //{ // if (_me.Inventory.Equipped.MainHand != null) // { // _me.Inventory.Equipped.MainHand.PickUp(); // if (_me.Inventory.Backpack.FreeSlots > 0) // Lua.DoString("PutItemInBackpack()"); // else // Lua.DoString("for i=1,4 do if GetContainerNumFreeSlots(i) > 0 then PutItemInBag(i) end end"); // } // if (_me.Inventory.Equipped.OffHand != null) // { // _me.Inventory.Equipped.OffHand.PickUp(); // if (_me.Inventory.Backpack.FreeSlots > 1) // Lua.DoString("PutItemInBackpack()"); // else // Lua.DoString("for i=1,4 do if GetContainerNumFreeSlots(i) > 1 then PutItemInBag(i) end end"); // } Utils.EquipItemByID(pole.Entry); //} return(true); } AutoAngler.Instance.Err("No fishing pole found"); TreeRoot.Stop(); return(false); }
public static async Task <bool> ReadRetainers(Func <RetainerInfo, Task> retainerTask) { if (!await OpenRetainerList()) { //Move this to botbase based on return value TreeRoot.Stop("Failed: Find a bell or some retainers"); return(false); } foreach (var retainer in RetainerList.Instance.OrderedRetainerList.Where(i => i.Active)) { Log($"Selecting {retainer.Name}"); await SelectRetainer(retainer.Unique); await retainerTask(retainer); await DeSelectRetainer(); Log($"Done with {retainer.Name}"); } if (!await CloseRetainerList()) { LogCritical("Could not close retainer list"); return(false); } return(true); }
private async Task <bool> Run() { await CustomDeliveries(); TreeRoot.Stop("Stop Requested"); return(true); }
public void NoLoopsTest() { const string bf = "+>+<"; var expected = new TreeRoot { Tree = new TreeObject[] { new Instruction { Operation = Operations.Increment }, new Instruction { Operation = Operations.PointerForward }, new Instruction { Operation = Operations.Increment }, new Instruction { Operation = Operations.PointerBackward } } }; var actual = bf.Parse(); Assert.AreEqual(expected, actual); }
protected override RunStatus Run(object context) { if (StyxWoW.Me.Mounted) { Mount.Dismount(); } Utils.UseItemByID(6948); var hearthSW = new Stopwatch(); hearthSW.Start(); // since I'm logging out lets just abuse sleep anyways :D while (hearthSW.ElapsedMilliseconds < 20000) { // damn.. we got something beating on us... if (StyxWoW.Me.Combat) { return(RunStatus.Success); } Thread.Sleep(100); // I feel so teribad... not! } AutoAngler.Instance.Log("Logging out"); Lua.DoString("Logout()"); TreeRoot.Stop(); return(RunStatus.Success); }
private async Task <bool> Run() { if (!IsBusy) { await Reduction(); await Desynth(); if (ReduceSettings.Instance.OpenCoffers) { await CofferTask(); } if (Translator.Language != Language.Chn) { await Extract(); } //ReduceSettings.Instance.Save(); } if (!ReduceSettings.Instance.StayRunning) { TreeRoot.Stop("Stop Requested"); } await Coroutine.Sleep(1000); return(true); }
/// <summary> /// Executes the action asynchronously while bot is stopped. /// If Bot was running then it is started up again after executing action. /// Also Profesionbuddy's behavior tree is not reseted unlike when bot is restarted manaully /// </summary> /// <param name="action">The action.</param> /// <param name="reason">The reason.</param> public static void ExecuteActionWhileBotIsStopped(Action action, string reason = null) { if (TreeRoot.IsRunning) { BotEvents.OnBotStopDelegate handler = null; handler = args => { try { // We perform the action in a new thread since action can be take a few seconds // and we don't want to hang the main thread. Task.Run(() => { action(); TreeRoot.Start(); }); } finally { BotEvents.OnBotStopped -= handler; } }; // we need to wait for bot to actually stop after calling TreeRoot.Stop, // it doesn't stop synchronously BotEvents.OnBotStopped += handler; ProfessionbuddyBot.IsExecutingActionWhileHonorbuddyIsStopped = true; TreeRoot.Stop(reason); } else { Task.Run(action); } }
private void UserDialogExitProcessing(PopdownReason popdownReason) { // Log to Honorbuddy why we're exiting behavior... if (popdownReason.IsReasonKnown()) { string directiveRequester = (IsStopOnContinue ? "Profile Writer request" : popdownReason.IsPopdown() ? "Notification criteria no longer valid" : popdownReason.IsTimerExpiry() ? "Profile Writer request" : popdownReason.IsUserResponse() ? "User request" : "Profile Writer request"); string messageType = (popdownReason.IsTimerExpiry() ? "timer expired" : popdownReason.IsUserResponse() ? "user response" : popdownReason.IsPopdown() ? "completion criteria" : "info"); string terminationMessage = string.Format("{0} {1}", (popdownReason.IsBotStop() ? "Honorbuddy stopped due to " : "Continuing profile due to"), directiveRequester); TreeRoot.StatusText = terminationMessage; LogMessage(messageType, terminationMessage); } if (popdownReason.IsBotStop()) { TreeRoot.Stop(); } }
private async Task <bool> Run() { if (!GCExpertSettings.Instance.AcceptedRisk) { LogBold("**************************Attention*********************************"); LogBold("Please go to settings"); LogBold("This botbase will turn in any gear that's in your inventory to the GC expert delivery npc"); LogBold("You need to set Accepted to true to show you understand the risk"); TreeRoot.Stop("Stop Requested"); return(true); } await GeneralFunctions.StopBusy(); Log("Turning in current items:"); await HandInExpert(); if (GCExpertSettings.Instance.Craft) { Log("Crafting set to true"); Log($"{Core.Me.MaxGCSeals()} - {GCExpertSettings.Instance.SealReward} < {Core.Me.GCSeals()}"); while (Core.Me.GCSeals() < Core.Me.MaxGCSeals() - GCExpertSettings.Instance.SealReward) { Log("Generating Lisbeth order"); var currentSeals = Core.Me.GCSeals(); var neededSeals = (Core.Me.MaxGCSeals() - currentSeals) - (GCExpertSettings.Instance.SealReward * ConditionParser.ItemCount((uint)GCExpertSettings.Instance.ItemId)); var qty = (int)((neededSeals) / GCExpertSettings.Instance.SealReward); Log($"Need {qty}"); var freeSlots = InventoryManager.FreeSlots; var couldCraft = Math.Min((freeSlots - 10), qty); Log($"Order Would be for {couldCraft}"); var outList = new List <LisbethOrder> { new LisbethOrder(0, 1, (int)GCExpertSettings.Instance.ItemId, (int)couldCraft, ((ClassJobType)DataManager.GetItem((uint)GCExpertSettings.Instance.ItemId).RepairClass).ToString(), true) }; var order = JsonConvert.SerializeObject(outList, Formatting.None); await GeneralFunctions.StopBusy(); Log($"Calling Lisbeth with {order}"); try { await Lisbeth.ExecuteOrders(order); } catch (Exception e) { Log($"{e}"); } await GeneralFunctions.StopBusy(); await HandInExpert(); } } TreeRoot.Stop("Stop Requested"); return(true); }
public GreaterOfTwoEvils(Dictionary <string, string> args) : base(args) { CheckForUnrecognizedAttributes(recognizedAttributes); bool error = false; uint questId; if (!uint.TryParse(Args["QuestId"], out questId)) { Logging.Write("Parsing attribute 'QuestId' in GreaterOfTwoEvils behavior failed! please check your profile!"); error = true; } uint mobId; string argName = Args.ContainsKey("MobId") ? "MobId" : "NpcId"; if (!uint.TryParse(Args[argName], out mobId)) { Logging.Write("Parsing attribute '{0}' in GreaterOfTwoEvils behavior failed! please check your profile!", argName); error = true; } if (error) { TreeRoot.Stop(); } QuestId = questId; MobId = mobId; }
// Empty, for now #endregion #region Overrides of CustomForcedBehavior public override void OnStart() { // Hunting ground processing... // NB: We had to defer this processing from the constructor, because XElement isn't available // to parse child XML nodes until OnStart() is called. HuntingGrounds = HuntingGroundsType.GetOrCreate(Element, "HuntingGrounds", HuntingGroundCenter); IsAttributeProblem |= HuntingGrounds.IsAttributeProblem; // 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. OnStart_QuestBehaviorCore( string.Format("Using {0} on {1}", GetItemNameFromId(ItemId), string.Join(", ", MobIds.Select(m => GetMobNameFromId(m)).Distinct()))); // 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 (!IsDone) { ItemToUse = Me.CarriedItems.FirstOrDefault(i => (i.Entry == ItemId)); if (ItemToUse == null) { LogError("[PROFILE ERROR] Unable to locate in our bags", GetItemNameFromId(ItemId)); TreeRoot.Stop(); BehaviorDone(); } CurrentHuntingGroundWaypoint = HuntingGrounds.FindFirstWaypoint(Me.Location); } }
internal static async Task <bool> ReadRetainers(Func <int, Task> retainerTask) { if (!await OpenRetainerList()) { TreeRoot.Stop("Failed: Find a bell or some retainers"); return(false); } var ordered = RetainerList.Instance.OrderedRetainerList.ToArray(); var numRetainers = await GetNumberOfRetainers(); for (var retainerIndex = 0; retainerIndex < numRetainers; retainerIndex++) { if (!ordered[retainerIndex].Active) { continue; } Log($"Selecting {ordered[retainerIndex].Name}"); await SelectRetainer(retainerIndex); await retainerTask(retainerIndex); await DeSelectRetainer(); Log($"Done with {ordered[retainerIndex].Name}"); } if (!await CloseRetainerList()) { LogCritical("Could not close retainer list"); return(false); } return(true); }
private async Task <bool> Run() { await PrintMasterPieceList(); TreeRoot.Stop("Stop Requested"); return(true); }
private async Task <bool> Run() { await CheckHousing(); // await Coroutine.Sleep(new TimeSpan(0, 1, 0)); TreeRoot.Stop("Stop Requested"); return(true); }
private async Task <bool> Run() { //await PrintMasterPieceList(); await DoGCDailyTurnins(); TreeRoot.Stop("Stop Requested"); return(true); }
//Show a variable private void PopulateVariableRoot(TreeRoot Root, string nName, TreeNodeCollection nParent) { var nd = nParent.Add(string.Format("{0}: {1}", "" /*Root.Type.ToString()*/, nName)); PVNode(nd, Root.RootNode, true); //nd.ExpandAll(); nd.Expand(); }
public List <ITreeNode <T> > ToList(TreeTraverseOrder order = TreeTraverseOrder.DepthFirst) { var lst = TreeRoot.ToList(order); lst.Remove(TreeRoot); return(lst); }
protected override async Task <bool> Main() { while (TreeRoot.IsRunning) { TreeRoot.Stop(); await Coroutine.Wait(1000, () => !TreeRoot.IsRunning); } return(isDone = true); }
public TreeRoot CreateTree() { Profiler.BeginSample("SerializedBehaviorTree.CreateTree()"); TreeRoot treeRoot = CreateTree(new Blackboard()); Profiler.EndSample(); return(treeRoot); }
//Show a variable private void PopulateVariableRoot(TreeRoot Root, string nName, TreeNodeCollection nParent) { var nd = nParent.Add(string.Format("{0}: {1}", ""/*Root.Type.ToString()*/, nName)); PVNode(nd, Root.RootNode, true); //nd.ExpandAll(); nd.Expand(); }