• Visit Rebornbuddy
  • ChainIt - Allows you to do chain quest without running back!

    Discussion in 'Plugins' started by heinzskies, Jul 13, 2015.

    1. heinzskies

      heinzskies Member

      Joined:
      Sep 7, 2014
      Messages:
      57
      Likes Received:
      2
      Trophy Points:
      8
      Warning, you have to find a way to blacklist the non fate mob yourself or else it will work or not I don't know.
      The code below is experimental. It works but there might be some bugs.
      Code:
      using System;
      using System.Linq;
      using System.Threading.Tasks;
      using System.Windows.Media;
      using Buddy.Coroutines;
      using Clio.Utilities;
      using ff14bot;
      using ff14bot.AClasses;
      using ff14bot.Behavior;
      using ff14bot.BotBases;
      using ff14bot.Helpers;
      using ff14bot.Managers;
      using ff14bot.Navigation;
      using TreeSharp;
      
      namespace ChainIt
      {
          public class ChainIt : BotPlugin
          {
              public override string Author { get { return "Heinzskies"; } }
              public override Version Version { get { return new Version(0, 0, 1); } }
              public override string Name { get { return "ChainIt"; } }
              public override string Description { get { return "Allow you to do chain quest without going back."; } }
      
              public override bool WantButton
              {
                  get { return false; }
              }
      
              public new bool Equals(BotPlugin other)
              {
                  throw new NotImplementedException();
              }
      
              bool _lastFateChainActive = false;
              FateIdleAction _userAction = FateIdleAction.Nothing;
              private Composite _action;
      
              public override void OnPulse()
              {
      
                  uint[] fatesChain = { 643, 644, 645, 646 };
      
                  foreach (var fateChain in from fateChain in fatesChain let fateSearch = FateManager.ActiveFates.Count(fate => fate.Id == fateChain) where fateSearch != 0 select fateChain)
                  {
                      ActiveChain();
                      if (fatesChain.Last() == fateChain)
                      {
                          _lastFateChainActive = true;
                      }
                          
                      FatebotSettings.Instance.ThisFateOnly = FateManager.GetFateById(fateChain).Name;
                  }
      
      
                  if (FateManager.ActiveFates.Count(fate => fate.Id == fatesChain.Last()) == 0 && _lastFateChainActive)
                  {
                      _lastFateChainActive = false;
                      FatebotSettings.Instance.ThisFateOnly = "";
                      FatebotSettings.Instance.IdleAction = _userAction;
                  }
              }
      
              private void ActiveChain()
              {
                  if (FatebotSettings.Instance.IdleAction != FateIdleAction.Nothing)
                  {
                      _userAction = FatebotSettings.Instance.IdleAction;
                  }
                  FatebotSettings.Instance.IdleAction = FateIdleAction.Nothing;
              }
      
              public override void OnInitialize()
              {
                  _action = new Decorator(r => 
                  Core.Player.Location.Distance(new Vector3("252.831238, 25, 4.66978")) > 15 &&
                  (
                  FatebotSettings.Instance.ThisFateOnly == "Dark Devices - The Plea" ||
                   FatebotSettings.Instance.ThisFateOnly == "Dark Devices - The Bait" ||
                   FatebotSettings.Instance.ThisFateOnly == "Dark Devices - The End" ||
                   FatebotSettings.Instance.ThisFateOnly == "Dark Devices - The Switch"
                  )
                  , new ActionRunCoroutine(p => DoIt()));
              }
      
              public override void OnShutdown()
              {
                  TreeRoot.OnStart -= OnBotStart;
                  TreeRoot.OnStop -= OnBotStop;
                  TreeHooks.Instance.OnHooksCleared -= OnOnHooksCleared;
      
                  RemoveHooks();
              }
      
              private void AddHooks()
              {
                  TreeHooks.Instance.InsertHook("TreeStart", 0, _action);
              }
      
              private void RemoveHooks()
              {
                  TreeHooks.Instance.RemoveHook("TreeStart", _action);
              }
      
              public override void OnEnabled()
              {
                  TreeRoot.OnStart += OnBotStart;
                  TreeRoot.OnStop += OnBotStop;
                  TreeHooks.Instance.OnHooksCleared += OnOnHooksCleared;
      
                  if (TreeRoot.IsRunning)
                  {
                      AddHooks();
                  }
      
                  Logging.Write(Colors.SkyBlue, "[ChainIt] v" + Version + " Enabled");
              }
      
              private static async Task<bool> DoIt()
              {
                  Poi.Clear("Moving to fate hotspot location");
                  
                  Navigator.MoveTo(new Vector3("252.831238, 25, 4.66978"));
                  
                  return true;
              }
      
              public override void OnDisabled()
              {
                  TreeRoot.OnStart -= OnBotStart;
                  TreeRoot.OnStop -= OnBotStop;
                  TreeHooks.Instance.OnHooksCleared -= OnOnHooksCleared;
                  RemoveHooks();
              }
      
              #region Event Handlers
      
              private void OnBotStop(BotBase bot)
              {
                  RemoveHooks();
              }
      
              private void OnBotStart(BotBase bot)
              {
                  AddHooks();
              }
      
              private void OnOnHooksCleared(object sender, EventArgs e)
              {
                  AddHooks();
              }
      
              #endregion
          }
      }
       
    2. Shee

      Shee Member

      Joined:
      Apr 22, 2014
      Messages:
      37
      Likes Received:
      0
      Trophy Points:
      6
      Hello,

      how can i have ID of fates to priorize them ?

      Thanks
       
    3. Master9000

      Master9000 New Member

      Joined:
      Jul 22, 2015
      Messages:
      74
      Likes Received:
      3
      Trophy Points:
      0
      worked beautifully, is there anyway to make this code have both the dark devices and the svara fate chain in piece of code? ^^
       
    4. Cloud30000

      Cloud30000 New Member

      Joined:
      May 9, 2015
      Messages:
      298
      Likes Received:
      7
      Trophy Points:
      0
      You can actually have it wait at as many fates as you would like; just add them all to the line he mentioned separated by a comma:
      uint[] fatesChain = { 643, 644, 645, 646, [id of fate5], [id of fate6], [id of fate7], [id of fate8] };

      If you search at xivdb for fates such as http://xivdb.com/?fate/643/Dark-Devices---The-Plea, you will find the fate id in the url like so:
      [​IMG]
       
    5. Master9000

      Master9000 New Member

      Joined:
      Jul 22, 2015
      Messages:
      74
      Likes Received:
      3
      Trophy Points:
      0
      you rock <3 ^^
       
    6. RequiemOfADream

      RequiemOfADream Member

      Joined:
      Aug 3, 2015
      Messages:
      40
      Likes Received:
      0
      Trophy Points:
      6
      So how do we active this thing. I created the .cs file with the Visual Studio, and put it in the Plugins folder etc etc etc, but it isnt showing up in RB
       
    7. y2krazy

      y2krazy Community Developer

      Joined:
      Jun 21, 2011
      Messages:
      2,803
      Likes Received:
      70
      Trophy Points:
      48
      Did you put it in its own folder? Did you restart RB after you added the file?
       
    8. RequiemOfADream

      RequiemOfADream Member

      Joined:
      Aug 3, 2015
      Messages:
      40
      Likes Received:
      0
      Trophy Points:
      6
      yes and yes, several times
       
    9. kei220

      kei220 Member

      Joined:
      May 22, 2015
      Messages:
      78
      Likes Received:
      0
      Trophy Points:
      6
      what you mean by show up in RB? cause you wont notice UI or anything just it do the requirement
       
    10. y2krazy

      y2krazy Community Developer

      Joined:
      Jun 21, 2011
      Messages:
      2,803
      Likes Received:
      70
      Trophy Points:
      48
      ^ If this is the case, it won't show up in the Plugins list, but should still be functional.
       
    11. ExMatt

      ExMatt Active Member

      Joined:
      Jul 5, 2015
      Messages:
      1,030
      Likes Received:
      14
      Trophy Points:
      38
      First thing we need to do when plugins don't show up in the UI is get a full log. It is likely you are getting a compilation error.
       
    12. RequiemOfADream

      RequiemOfADream Member

      Joined:
      Aug 3, 2015
      Messages:
      40
      Likes Received:
      0
      Trophy Points:
      6
      Finally figured it out, thanks!
       
    13. I dont get it

      I dont get it New Member

      Joined:
      Aug 5, 2015
      Messages:
      9
      Likes Received:
      0
      Trophy Points:
      0
      I copied and pasted that text into a Wordpad document and saved it as ChainIt.cs and placed it into a ChainIt folder within the Plugins folder - it doesn't work for me, I keep running away from the first FATE, then running back, then away, then back, etc.

      What am I doing wrong? Or can someone supply a working document that I can place in the ChainIt folder?

      Much appreciated
       

    Share This Page