Just a quick example. Code: using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using System.Windows.Forms; using Buddy.Coroutines; using ff14bot.AClasses; using ff14bot.Behavior; using ff14bot.Enums; using ff14bot.Helpers; using ff14bot.Managers; using TreeSharp; namespace BetterCoroutineExample { public class BetterCoroutineExample : BotPlugin { internal async Task<bool> DoSomething() { foreach (var bagslot in InventoryManager.EquippedItems) { if (bagslot.BagId == InventoryBagId.Armory_MainHand) continue; if (bagslot.SpiritBond >= 100) { await CommonTasks.ConvertToMateria(bagslot); } } //Don't block the logic below us in the tree. return false; } public override void Dispose() { } public override void Pulse() { } public override string Author { get { return "Mastahg"; } } public override Version Version { get { return new Version(0, 0, 1); } } public override string Name { get { return "Better Coroutine example"; } } private Composite _coroutine; public void OnInitialize() { //OnInitialize only gets called once, so create the object here so that it can be properly removed later. _coroutine = new ActionRunCoroutine(r => DoSomething()); } public override void OnShutdown() { } public override void OnDisabled() { //Remove our event handler and remove our coroutine from the logic tree TreeHooks.Instance.OnHooksCleared -= OnHooksCleared; TreeHooks.Instance.RemoveHook("TreeStart", _coroutine); } public override void OnEnabled() { //Add our hook to the logic tree here and setup event handler for when the treehooks are cleared //We want to add our hook here incase the user enables the plugin once the bot is already running. TreeHooks.Instance.AddHook("TreeStart", _coroutine); TreeHooks.Instance.OnHooksCleared += OnHooksCleared; } private void OnHooksCleared(object sender, EventArgs args) { TreeHooks.Instance.AddHook("TreeStart", _coroutine); } } }
If we can do that, does it mean the API is thread safe? For example, what happens if two threads call Navigator at the same time?
No. Nothing is thread-safe. Doing anything in another thread will likely break things in terrible ways along with burning your house down.
So I've been messing with this for a little bit and got it working in a plugin that I did, but my question is.. Is there a way to stop orderbot completely to allow it to convert, Ive tried a few ways from using botmanager.current.stop to using treeroot.stop (treeroot would stop the pulse all together, wouldnt it?).. or which would be the best way to tell orderbot to pause while converting/equiping a new piece of gear?
As for this, what you'll want todo is hook "TreeStart" and do something like Code: new Decerator(r=>IsDisenchanting, new actionalwaysuccededdededed()) and then when you start doing stuff set that to true and the rest of the tree wont execute then once your done, set it false and itll resume normal operation
Mastahg, I've tried to follow on how you suggested to stop the bot in order to do converts, but no matter which way I try to do it, it appears that the behavior I'm trying to call never gets called. Here is what I currently have: Code: (in OnEnabled) _cache = Behavior(); TreeHooks.Instance.AddHook("TreeStart", _cache); and as for the composite behavior, I have: Code: private Composite Behavior() { return new Decorator(r => timeToConvert, new Action(r => Logging.Write("Behavior Called") ) ); } (i removed the actionalwayssuccedded to put a logging action in there to see if it gets fired or not).. I have tried to add the hook as well as inserthook.. and no matter which way I try.. it appears that the behavior never gets called. Forgive me for such stupid questions, as I'm not too familiar with all this.. I went over to the HB section and read about treehooks and hooking into trees.. but anything I seem to do.. just doesnt work.. do you have any advice?
You need to add a event handler to Code: TreeHooks.Instance.OnHooksCleared Right now your adding a treehook but then somewhere else its being cleared so you need to readd it when that event fires.
Thank you very much for the fast reply! I had no idea that it was being cleared some how, as I didnt see that in any RB logging being done.. but that fixed the issue.. I appreciate your help with it all, thank you!
I've gone and updated the original post with a better example. The original example wasn't the proper way things should be done.
Might just be on my end, but this example doesn't seem to be working anymore. Pulse() should be OnPulse() and it's missing override on OnInitialize(). However, it still isn't firing off the coroutine. Possible that something has changed in a patch along the way? Edit: The hooks are working, i'm just derpy.
Is there a "how to" about plugin dev ? I don't know where to start and how RB really works and i want to dive in to dev a PotD 1-10 loop plugin. Thx, regards,
take a look at the Honorbuddy forums, much of the topic there about building a plugin or botbase are similar here. you can also look at some of the existing plugins & botbases in the forum to get an idea of how to start. You wouldn't be building a DeepDungeon as a plugin it would be a botbase. Potd is also reallly challenging to do well (especially because there isn't very much support for the deep dungeon interfaces and data in reborn buddy right now. the navigation server doesn't support the deep dungeon maps because they don't have a proper zoneid. (zoneid = 0, but they have a rawid and the navserver just uses zoneid) hope that helps you get started some.
I'm a total noob with RB dev, and even VS. With that in mind, I fish a bunch using the Fishing botbase and tried my hand at creating a small plugin that will simply click a Collectable window yes/no depending on preset fish collectability, etc. since the Fishing bot doesn't do it automatically. I followed the example here and I encountered a problem a few others here have had - my coroutine doesn't seem to fire at all. My logic (mostly) works when I put it in the OnPulse method, so it's clear I'm ignorant of something here. Can someone point me in the right direction? My goal is ultimately to try my hand at a fairly robust gathering botbase, so I'm taking steps in that direction. Anyway, here's the code attached. Thanks!
Try adding some logging to the the top of PressCollectableButton and see if its getting run. That looks like it should work. I think the sidestep plugin uses a coroutine hook internally so you could look at that for an example.