• Visit Rebornbuddy
  • Use hearthstone if stuck

    Discussion in 'Honorbuddy Forum' started by dron1k, Mar 14, 2017.

    1. dron1k

      dron1k Member

      Joined:
      Dec 22, 2014
      Messages:
      37
      Likes Received:
      2
      Trophy Points:
      8
      Hi, does anyone know how to code this? I mean something like:
      Code:
      If
      standing_at_one_place_for_5_minutes
      then
      "RunMacro" Macro="/use Hearthstone"
      I think I should use CustomBehavior, but not sure how. I want to implement this in profile, w\o any extra plugins.
       
      Last edited: Mar 21, 2017
    2. Svenstar123

      Svenstar123 Member

      Joined:
      Dec 24, 2012
      Messages:
      584
      Likes Received:
      24
      Trophy Points:
      18
      check out EchoTigers questing profile packs, he has this implemented.
       
    3. dron1k

      dron1k Member

      Joined:
      Dec 22, 2014
      Messages:
      37
      Likes Received:
      2
      Trophy Points:
      8
      Sadly I can't find anything there, searching for 'hearthstone' or '8690' (spell id)
       
    4. Djops

      Djops Member

      Joined:
      Oct 22, 2016
      Messages:
      62
      Likes Received:
      0
      Trophy Points:
      6
    5. dron1k

      dron1k Member

      Joined:
      Dec 22, 2014
      Messages:
      37
      Likes Received:
      2
      Trophy Points:
      8
    6. EchoTiger

      EchoTiger Official Profile and Singular Developer Staff Member Moderator

      Joined:
      Nov 28, 2012
      Messages:
      6,809
      Likes Received:
      631
      Trophy Points:
      113
      Since you said CustomBehavior, I'm assuming this would be for the Questing botbase?
      Here's a very simple method of how custom anti-stuck might look in a questing profile:

      PHP:
      <CustomBehavior File="RunCode" Type="Definition"><![CDATA[
          public static class 
      StuckDetection
          
      {
              public static 
      Vector3 LastPoint = new Vector3(0f,0f,0f);

              public static 
      bool IsStuck()
              {
                  if (!
      StyxWoW.Me.IsValid) return false;
                  if (
      StyxWoW.Me.IsDead) return false;
                  if (
      StyxWoW.Me.IsActuallyInCombat) return false;
                  if (
      StyxWoW.Me.HasAura("Resurrection Sickness")) return false;

                  var 
      currentPoint StyxWoW.Me.Location;
                  var 
      isStuck currentPoint.DistanceSqr(LastPoint) < 10f 10f;
                  
      LastPoint currentPoint;
                  return 
      isStuck;
              }
          }
      ]]>
      </
      CustomBehavior>
      <
      CustomBehavior File="RunCode" Code="StuckDetection.LastPoint = new Vector3(0f,0f,0f);" /> <!-- Clean out stale data in case the user stop/starts the bot. -->
      <
      CustomBehavior File="Hooks\DoWhen" ActivityName="DoWhen_StuckDetector" AllowUseWhileMounted="true" LogExecution="false" UseAtInterval="210000" >
          <If 
      Condition="StuckDetection.IsStuck() &amp;&amp; HasItem(6948)" >
              <
      CustomBehavior File="RunCode"><![CDATA[
                  
      Logging.Write(System.Windows.Media.Colors.DeepSkyBlue"[ProfileBase]: Stuck detection activated!");
                  
      await CommonCoroutines.StopMoving();
                  
      await CommonCoroutines.LandAndDismount();
                  
      WoWItem hearthstoneItem StyxWoW.Me.BagItems.FirstOrDefault(=> x.Entry == 6948);
                  if (
      hearthstoneItem.CooldownTimeLeft != TimeSpan.Zero) {
                      
      Logging.Write(System.Windows.Media.Colors.DeepSkyBlue"[ProfileBase]: Awaiting Hearthstone cooldown before attempting hearth!");
                      
      await Coroutine.Wait(1800000, () => hearthstoneItem.CooldownTimeLeft == TimeSpan.Zero);
                  }
                  
      hearthstoneItem.Interact();
                  
      await Coroutine.Sleep(11500);
                  
      Logging.Write(System.Windows.Media.Colors.DeepSkyBlue"[ProfileBase]: Reloading profile.");
                  
      ProfileManager.LoadNew(ProfileManager.XmlLocation);
              ]]>
              </
      CustomBehavior>
          </If>
      </
      CustomBehavior>
      This approach favors using DoWhen instead of hooking directly in using TreeHook.InsertHook.
      Mainly because with DoWhen we can use UseAtInterval. This way we won't have to code in our own timer.

      Another approach would be to actually use TreeHooks.InsertHook - which from there you'd hook in at Questbot_Profile.
      DoWhen hooks in at Questbot_Main which is why there's so many checks on the IsStuck();

      Questbot_Profile runs at a profile level while Questbot_Main runs above all other hooks such as combat/loot/etc.
       
      dron1k likes this.

    Share This Page