• Visit Rebornbuddy
  • Visit Panda Profiles
  • Visit LLamamMagic
  • Pause Botbase while a condition holds true.

    Discussion in 'Community Developer Forum' started by newb23, Mar 28, 2015.

    1. newb23

      newb23 Community Developer

      Joined:
      Nov 26, 2014
      Messages:
      397
      Likes Received:
      15
      Trophy Points:
      18
      I am almost ready for the re-release of my retainer plugin (attached below) but I am missing one last crucial part; stopping it's basebot (FATEbot, Orderbot, etc).

      I know that it would be easier if it was a botbase itself, but as I want it to be used as a plugin, in conjunction with Agil, RePear, etc, I will be leaving it as such.

      Now, I searched through the forums and found this: https://www.thebuddyforum.com/rebor...lugin.html?highlight=stop+botbase#post1785268

      which I found would likely be useful, as it's what I need, but I have no idea how or where to implement the ideas posted in that thread. Is there any way I could have someone spell it out a little bit more for me?

      I tried attaching ActionAlwaysSucceed in various location, but, I wasn't able to get that to work. I also tried putting my _coroutine OnPulse() into PrioritySelector(), but that didn't work either.

      I know it's probably something simple, some function call I need to make, but for the life of me, I cannot figure it out... :p

      Thank you for your help and patience!

      Edit: I attempted to make the edits suggested by removing the co-routine that initially started the bot and calling to start it using a new tree root. Some portions of it work, some don't, and I am completely lost where I need to edit it now. >_< With the original version, I was to the point where all I needed to do was suspend the botbase, now, I'm not really sure. if I set my start bool to true, it fails at the use of the summoning bell. If I set it to false, it tries to destroy the summoning bell and it tries to take off to do fates.


       

      Attached Files:

      Last edited: Mar 29, 2015
    2. Neverdyne

      Neverdyne Community Developer

      Joined:
      Sep 12, 2014
      Messages:
      649
      Likes Received:
      18
      Trophy Points:
      18
      I never liked stopping the bot base entirely like FateAutoLeveler does. It has caused problems with other plugins before. What I would suggest is that you insert your Composite into the beginning of the tree like what Agil does. You make your composite always succeed when you're doing your thing, and when you're done you let it always fail.
       
    3. newb23

      newb23 Community Developer

      Joined:
      Nov 26, 2014
      Messages:
      397
      Likes Received:
      15
      Trophy Points:
      18
      I remember reading about that, and I dove into Agil for a little bit trying to see how you go it accomplished. Is Composite() GetRoot simply to put commands in your plugin in higher priority than those of the bot base?
       
    4. Neverdyne

      Neverdyne Community Developer

      Joined:
      Sep 12, 2014
      Messages:
      649
      Likes Received:
      18
      Trophy Points:
      18
      I'm on my phone right now so can't show you the code, but what you're looking for is in the plugin .cs file on its Hook method, you'll see an insert instruction there that puts agil's logic at the start of the tree. This is called whenever the bot starts. Agil's entire logic is in that root composite that gets hooked.
       
      Last edited: Mar 28, 2015
    5. newb23

      newb23 Community Developer

      Joined:
      Nov 26, 2014
      Messages:
      397
      Likes Received:
      15
      Trophy Points:
      18
      I attempted to make the edits suggested by removing the co-routine that initially started the bot and calling to start it using a new tree root. Some portions of it work, some don't, and I am completely lost where I need to edit it now. >_< With the original version, I was to the point where all I needed to do was suspend the botbase, now, I'm not really sure. if I set my start bool to true, it fails at the use of the summoning bell. If I set it to false, it tries to destroy the summoning bell and it tries to take off to do fates.
       

      Attached Files:

    6. mastahg

      mastahg Administrator Staff Member

      Joined:
      Feb 27, 2011
      Messages:
      5,345
      Likes Received:
      383
      Trophy Points:
      83
      Clear out onpulse.

      Add anywhere
      Code:
      private Composite _root;
      

      Add to onenabled
      Code:
      onenabled()
      ....
      
      TreeHooks.Instance.OnHooksCleared += OnHooksCleared;
      _root = new ActionRunCoroutine(r=>blahblahblah);
      
      Add to ondisabled
      Code:
      ondisabled()
      ....
      
      TreeHooks.Instance.OnHooksCleared -= OnHooksCleared;
      RemoveHook();
      
      again anywhere
      Code:
              private void OnHooksCleared(object sender, EventArgs args)
              {
                  AddHook();
              }
      
              public void AddHook()
              {
                  TreeHooks.Instance.AddHook("TreeStart", _root);
              }
      
              public void RemoveHook()
              {
      	    TreeHooks.Instance.RemoveHook("TreeStart", _root); 
              }
      
      Plugins by themselves have no direct effect on the botbase, running a coroutine that will yank control is untested and probably isnt reliable. You need to insert your logic into the main logic system of the bot and then you can control it from there.
       
    7. newb23

      newb23 Community Developer

      Joined:
      Nov 26, 2014
      Messages:
      397
      Likes Received:
      15
      Trophy Points:
      18
      Haha, well, it looks like this was a very good step in the right direction. Plugin is looping like it is supposed to, running to and fro and such. However... I cannot get it to release control again. :p

      It appears that it has taken control from FATE/Order bot, as I am not getting messages or having it try to pull me away to a FATE, but, the plugin gets stuck in a loop after it completes, and immediately starts over, not letting FATE/Order bot take control again.

      My OnEnabled is set up like so:
      Code:
              public void OnEnabled()        {            
                      Logging.Write("[RetBot] Enabled");
                      GamelogManager.MessageRecevied += MessageReceived;
                      TreeHooks.Instance.OnHooksCleared += OnHooksCleared;
                      Logging.Write("[RetBot] Beginning Initial Run");
                      _root = new ActionRunCoroutine(r => MovementActions.RetainerMove());
                      Logging.Write("[RetBot] Removing Hook.");
                      RemoveHook();
              }
      
      
      But despite having the logging and remove hook in there, they do not execute. I'm not sure why.
      
      The second portion I will need to have Hook and DeHook is here:
      Code:
              private void MessageReceived(object sender, ChatEventArgs e)        {
                  if (e.ChatLogEntry.Contents.Contains(settings.Lan_V_Complete))
                  {
                      _root = new ActionRunCoroutine(r => MovementActions.RetainerMove());
                      Logging.Write("[RetBot] Removing Hook.");
                      RemoveHook();
                  }
              }
      But, as I cannot get it to stop looping, I cannot test that particular portion.

      Also, I removed the 62 minute long sleep at the end of movement actions so as to try to get it to complete also. No good.

      Is there a way I can tell it (movementactions) to return a value to remove the hook? I thought it would with RemoveHook(), but, I thought wrong.

      Thank you for getting me this much closer! Home Stretch!
       
    8. mastahg

      mastahg Administrator Staff Member

      Joined:
      Feb 27, 2011
      Messages:
      5,345
      Likes Received:
      383
      Trophy Points:
      83
      I don't understand...use one hook, inside the coroutine

      if (shouldidostuff)
      {

      //do stuff
      //don't let the logic further down do anything
      return false;
      }
      else
      {
      //im not doing anything right now
      return true;
      }

      Why are you removing the hook in onenabled...
      Also your changing the compsoite _root which is bad, you need to create it one time and add and remove as necessary, but you shouldn't need to remove it other then in ondisabled. Change your coroutines logic check the status of a variable and use that to decide if it should do anything instead of hooking and unhooking.
       
    9. newb23

      newb23 Community Developer

      Joined:
      Nov 26, 2014
      Messages:
      397
      Likes Received:
      15
      Trophy Points:
      18
      That appears to have been my issue! I'm changing around a couple of my variable names, and getting ready for the re-release now. Thank you all for your support!
       

    Share This Page