• Visit Rebornbuddy
  • Visit Panda Profiles
  • Visit LLamamMagic
  • [Plugin] StuckHelper - Improved stuck handling

    Discussion in 'Archives' started by Zacharybinx34, Jun 7, 2011.

    1. hbaioni

      hbaioni New Member

      Joined:
      Oct 17, 2011
      Messages:
      299
      Likes Received:
      1
      Trophy Points:
      0
      Does it work for trees? I have the same problem than krizkor... Every morning, when I wake up, the bot is "making love" to a tree... Please post your experience.
       
    2. Kopped

      Kopped New Member

      Joined:
      Feb 24, 2010
      Messages:
      178
      Likes Received:
      1
      Trophy Points:
      0
      This just jumps randomly even if not stuck. Is there a update which fixes this?
       
    3. tumbum

      tumbum Active Member

      Joined:
      Mar 17, 2011
      Messages:
      3,341
      Likes Received:
      13
      Trophy Points:
      38
      maybe a dev gets some hands on this nice plugin. if toon casts a spell X time restart HB, or trys to turn in a quest X times restart hb. Mostly the profile/scripts starts to do the quest or the needed thing, after a restart.
       
    4. azidtrip

      azidtrip Member

      Joined:
      Mar 3, 2012
      Messages:
      215
      Likes Received:
      0
      Trophy Points:
      16
      I attempted to modify this as I didnt want the stuckhandling while in water as I suspect it confilct with Anti Drown. Asking if someone could verify the code as I'm not sure if done right. Thankful for answers. :)

      Code:
      //*
       * --------------------------------------------------------------------------------------------------------------
       * ***Removed Swim routines. Modified by azidtrip. Author credits to lofi. :)
       * --------------------------------------------------------------------------------------------------------------
       *
       *
       * This plugin includes following features:
       * - Detects when stuck and performs unstuck routine
       * - Restarts bot when stuck or at intervals (stability fix)
       * - Fixes stuck in air being attacked for ArchaeologyBuddy
       *
       * Author: lofi
       */
      
      using Styx.Combat.CombatRoutine;
      using Styx.Helpers;
      using Styx.Logic.BehaviorTree;
      using Styx.Logic.Combat;
      using Styx.Logic.Inventory.Frames.Gossip;
      using Styx.Logic.Inventory.Frames.LootFrame;
      using Styx.Logic.POI;
      using Styx.Logic.Pathing;
      using Styx.Logic.Profiles;
      using Styx.Logic;
      using Styx.Plugins.PluginClass;
      using Styx.WoWInternals.WoWObjects;
      using Styx.WoWInternals;
      using Styx;
      using System.Collections.Generic;
      using System.Diagnostics;
      using System.Drawing;
      using System.IO;
      using System.Linq;
      using System.Net;
      using System.Reflection;
      using System.Runtime.InteropServices;
      using System.Threading;
      using System.Windows.Forms;
      using System.Xml.Linq;
      using System;
      
      namespace lofi
      {
          public class StuckHelper : HBPlugin, IDisposable
          {
              // User configurations
              private static double RestartInterval = 0; // Restart bot ever x mins, 0 to disable
              private static int StopStartTime = 10; // Seconds to wait between stop and start during re-start
              private static double StuckDistance = 10; // Reset standing still timer after moving this distance
              private static double RestartStuckMinutes = 3.5; // Restart bot after standing still this long, 0 to disable
              private static double UnstuckRoutineMinutes = 2.0; // Perform unstuck after standing still this long, 0 to disable
              private static double ArchBuddyFixMinutes = 0.3; // Dismounts after flying still and being attacked, 0 to disable
              private static double MountFixMinutes = 1.0; // Perform dismount after mounted still this long, 0 to disable
      
              public override string Name { get { return "StuckHelper"; } }
              public override string Author { get { return "lofi"; } }
              public override Version Version { get { return new Version(1, 0, 2); } }
              public override bool WantButton { get { return false; } }
              public override string ButtonText { get { return Version.ToString(); } }
              private static LocalPlayer Me { get { return ObjectManager.Me; } }
              private static Stopwatch spamDelay = new Stopwatch();
              private static Stopwatch restartStandingStillTimer = new Stopwatch();
              private static Stopwatch unstuckStandingStillTimer = new Stopwatch();
              private static Stopwatch archBuddyFixTimer = new Stopwatch();
              private static Stopwatch mountFixTimer = new Stopwatch();
              private static Thread restartIntervalThread = null;
              private static Thread restartWhenStuckThread = null;
              private static WoWPoint lastPoint = new WoWPoint();
              private static Random random = new Random();
      
              public override void OnButtonPress()
              {
              }
      
              public override void Pulse()
              {
                  try
                  {
                      //sanity check and filter-only check
                      if (Me == null || !ObjectManager.IsInGame || BotPoi.Current == null ||
                          !TreeRoot.IsRunning || RoutineManager.Current == null)
                      {
                          return;
                      }
      
                      if (spamDelay.Elapsed.TotalSeconds < 3.0)
                          return; // spam protection
                      spamDelay.Reset();
                      spamDelay.Start();
      
                      // update game objects
                      ObjectManager.Update();
      
                      DetectStuck();
                  }
                  catch (Exception e)
                  {
                      Log("ERROR: " + e.Message + ". See debug log.");
                      Logging.WriteDebug("StuckHelper exception:");
                      Logging.WriteException(e);
                  }
              }
      
              public override void Initialize()
              {
                  if (restartIntervalThread != null && restartIntervalThread.IsAlive)
                  {
                      restartIntervalThread.Abort();
                  }
      
                  if (RestartInterval > 0)
                  {
                      restartIntervalThread = new Thread(new ThreadStart(RestartIntervalThread));
                      restartIntervalThread.Start();
                  }
      
                  spamDelay.Start();
      
                  Log("Loaded version " + Version);
              }
      
              public override void Dispose()
              {
                  if (restartIntervalThread != null && restartIntervalThread.IsAlive)
                  {
                      restartIntervalThread.Abort();
                  }
              }
      
              public static void RestartIntervalThread()
              {
                  while (true) // wait for Abort()
                  {
                      Log("Re-starting HB in " + RestartInterval + " minutes...");
                      Thread.Sleep((int)(RestartInterval * 60 * 1000));
                      RestartBot();
                  }
              }
      
              public static void RestartWhenStuckThread()
              {
                  Log("Detected stuck!! Re-starting bot.");
      
                  if (restartIntervalThread != null && restartIntervalThread.IsAlive)
                  {
                      restartIntervalThread.Abort();
                  }
      
                  RestartBot();
      
                  if (RestartInterval > 0)
                  {
                      restartIntervalThread = new Thread(new ThreadStart(RestartIntervalThread));
                      restartIntervalThread.Start();
                  }
              }
      
              private static void UnstuckRoutine()
              {
                  Log("Performing unstuck routine!");
      
                  Mount.Dismount();
      
                  // long jumps
                  numJumps = random.Next(1, 3);
                  for (int i = 0; i < numJumps; i++)
                  {
                      Styx.Helpers.KeyboardManager.PressKey((char)Keys.Up);
                      Thread.Sleep(random.Next(30, 50));
                      Styx.Helpers.KeyboardManager.PressKey((char)Keys.Space);
                      Thread.Sleep(random.Next(500, 750));
                      Styx.Helpers.KeyboardManager.ReleaseKey((char)Keys.Up);
                      Styx.Helpers.KeyboardManager.ReleaseKey((char)Keys.Space);
                      Thread.Sleep(random.Next(250, 750));
                  }
      
                  // short jumps
                  numJumps = random.Next(1, 3);
                  for (int i = 0; i < numJumps; i++)
                  {
                      Styx.Helpers.KeyboardManager.PressKey((char)Keys.Space);
                      Thread.Sleep(random.Next(30, 50));
                      Styx.Helpers.KeyboardManager.PressKey((char)Keys.Up);
                      Thread.Sleep(random.Next(500, 750));
                      Styx.Helpers.KeyboardManager.ReleaseKey((char)Keys.Up);
                      Styx.Helpers.KeyboardManager.ReleaseKey((char)Keys.Space);
                      Thread.Sleep(random.Next(250, 750));
                  }
      
                  lastPoint = new WoWPoint(Me.X, Me.Y, Me.Z);
              }
      
              private static void RestartBot()
              {
                  if (Me.IsInInstance || Battlegrounds.IsInsideBattleground)
                  {
                      Log("Inside an instance or a BG! Skipped HB re-start.");
                  }
                  else
                  {
                      spamDelay.Reset();
                      restartStandingStillTimer.Reset();
                      unstuckStandingStillTimer.Reset();
                      archBuddyFixTimer.Reset();
                      mountFixTimer.Reset();
      
                      Log("Re-starting HB...");
                      Styx.Logic.BehaviorTree.TreeRoot.Stop();
      
                      Log("Waiting " + StopStartTime + " seconds...");
                      Thread.Sleep(StopStartTime * 1000);
      
                      Log("Starting HB...");
                      Styx.Logic.BehaviorTree.TreeRoot.Start();
                  }
              }
      
              private static bool DetectStuck()
              {
                  WoWPoint myPoint = new WoWPoint(Me.X, Me.Y, Me.Z);
      
                  if (myPoint.Distance(lastPoint) > StuckDistance)
                  {
                      lastPoint = myPoint;
                      restartStandingStillTimer.Reset();
                      unstuckStandingStillTimer.Reset();
                      return false;
                  }
      
                  if (!restartStandingStillTimer.IsRunning)
                      restartStandingStillTimer.Start();
      
                  if (!unstuckStandingStillTimer.IsRunning)
                      unstuckStandingStillTimer.Start();
      
                  if (!archBuddyFixTimer.IsRunning && Me.IsFlying && Me.Combat)
                      archBuddyFixTimer.Start();
                  else if (archBuddyFixTimer.IsRunning && (!Me.IsFlying || !Me.Combat))
                      archBuddyFixTimer.Reset();
      
                  if (!mountFixTimer.IsRunning && Me.Mounted && !Me.IsFlying && !Me.HasAura("Preparation"))
                      mountFixTimer.Start();
                  else if (mountFixTimer.IsRunning && (!Me.Mounted || Me.IsFlying || Me.HasAura("Preparation")))
                      mountFixTimer.Reset();
      
                  if (RestartStuckMinutes != 0 && restartStandingStillTimer.Elapsed.TotalMinutes > RestartStuckMinutes)
                  {
                      restartStandingStillTimer.Reset();
      
                      if (restartIntervalThread != null && restartIntervalThread.IsAlive)
                      {
                          restartIntervalThread.Abort();
                      }
                      if (restartWhenStuckThread != null && restartWhenStuckThread.IsAlive)
                      {
                          restartWhenStuckThread.Abort();
                      }
      
                      restartWhenStuckThread = new Thread(new ThreadStart(RestartWhenStuckThread));
                      restartWhenStuckThread.Start();
                      return true;
                  }
      
                  if (UnstuckRoutineMinutes > 0 && unstuckStandingStillTimer.Elapsed.TotalMinutes > UnstuckRoutineMinutes)
                  {
                      swimFixTimer.Reset();
                      unstuckStandingStillTimer.Reset();
                      UnstuckRoutine();
                      return true;
                  }
      
                  
                  if (ArchBuddyFixMinutes != 0 && archBuddyFixTimer.Elapsed.TotalMinutes > ArchBuddyFixMinutes)
                  {
                      Log("Dismounting while flying");
                      archBuddyFixTimer.Reset();
                      Mount.Dismount();
                      return true;
                  }
      
                  
      	    if (MountFixMinutes != 0 && mountFixTimer.Elapsed.TotalMinutes > MountFixMinutes)
                  {
                      Log("Dismounting to unstuck");
                      mountFixTimer.Reset();
                      Mount.Dismount();
                      return true;
                  }
      
                  return false;
              }
      
              private static void Log(string format, params object[] args)
              {
                  Logging.Write(Color.DarkRed, "[StuckHelper] " + format, args);
              }
          }
      }
      
      
       
      Last edited: Mar 28, 2012
    5. Wire21

      Wire21 New Member

      Joined:
      Mar 28, 2012
      Messages:
      16
      Likes Received:
      0
      Trophy Points:
      0
      Even without anti-drown this addon still goes crazy when underwater.
       
    6. nlr

      nlr New Member

      Joined:
      Feb 24, 2010
      Messages:
      252
      Likes Received:
      0
      Trophy Points:
      0
      Raphus is recoding a new stuck handler soon (its on his development list)
       
    7. palapalapaladuck

      palapalapaladuck New Member

      Joined:
      Apr 14, 2012
      Messages:
      20
      Likes Received:
      0
      Trophy Points:
      0
      Been experiencing a few problems whilst in Vash, the plugin kicks in far too much..Sometimes (most times) I wont even be stuck and it'll perform the unstuck routine. Left HB to farm for a few hours and it significantly reduced the node farm count per hour due to it unsticking me when there was no need.

      Anyone else having a problem like this?
      Any known fixes?...Cant afford to not run it as sometimes i do experience getting stuck, and when I do the bot makes no attempt to move.
       
    8. Ulbjorn

      Ulbjorn New Member

      Joined:
      Feb 15, 2012
      Messages:
      130
      Likes Received:
      0
      Trophy Points:
      0
      This looks like a great plugin.
       
    9. qztr

      qztr Active Member

      Joined:
      Mar 31, 2012
      Messages:
      1,932
      Likes Received:
      17
      Trophy Points:
      38
      I'll test this plugin now, thanks for the release :)
       
    10. joker8656

      joker8656 New Member

      Joined:
      Feb 20, 2012
      Messages:
      26
      Likes Received:
      0
      Trophy Points:
      0
      this is absolute crap.. it jumps when on zeps. and disrupts all of the bots when in travel.
       
    11. Dagradt

      Dagradt Community Developer

      Joined:
      Jul 26, 2010
      Messages:
      1,423
      Likes Received:
      44
      Trophy Points:
      48
      @Everyone who is posting before reading the thread,

      This is broken and has been for a long time, wait for the new release...
       
    12. tumbum

      tumbum Active Member

      Joined:
      Mar 17, 2011
      Messages:
      3,341
      Likes Received:
      13
      Trophy Points:
      38
      anyone maybe take a hand on, and please put in something if the brilliant flightor unstuck takes XXX times just drop mount.
       
    13. Jacan

      Jacan New Member

      Joined:
      Sep 30, 2011
      Messages:
      489
      Likes Received:
      0
      Trophy Points:
      0
      a plugin like this is badly needed and apparently it doesnt require alot of code.. it doesn't make sense why something like this isnt intergrated in hb.. i mean do the developers even bot or do they just make bots :/
       
    14. onedayy

      onedayy New Member

      Joined:
      Jul 9, 2012
      Messages:
      5
      Likes Received:
      0
      Trophy Points:
      0
      I really need a plugin like this because my HB is getting stuck alot in trees when iam running archaelogybuddy. When will a new version come out or is it any other plugin that helps so the bot doesnt stuck in trees?
      Thanks for answer.
       
    15. onedayy

      onedayy New Member

      Joined:
      Jul 9, 2012
      Messages:
      5
      Likes Received:
      0
      Trophy Points:
      0
      I really need a plugin like this because my HB is getting stuck alot in trees when iam running archaelogybuddy. When will a new version come out or is it any other plugin that helps so the bot doesnt stuck in trees?
      Thanks for answer.
       
    16. zeldrak

      zeldrak Well-Known Member

      Joined:
      Oct 25, 2010
      Messages:
      3,516
      Likes Received:
      25
      Trophy Points:
      48
      I haven't tried ArchBuddy with the newest HB yet (ver 5951 of HB), but according to Hawker/Apoc/other devs it shouldn't be getting stuck anymore. The nav system is supposed to be fixed and working.
       
    17. onedayy

      onedayy New Member

      Joined:
      Jul 9, 2012
      Messages:
      5
      Likes Received:
      0
      Trophy Points:
      0
      Thanks for the answer, but unfortunatly the bot keeps stucking in 2 same place and that is Twilight Grove and Seradane. Can someone please help me fix this
       
    18. mudplayerx

      mudplayerx New Member

      Joined:
      Jan 29, 2012
      Messages:
      149
      Likes Received:
      1
      Trophy Points:
      0
      I can confirm that the newest version of HB is still getting stuck in trees when using archbuddy.
       
    19. xittalon

      xittalon New Member

      Joined:
      Jan 9, 2012
      Messages:
      81
      Likes Received:
      0
      Trophy Points:
      0
      i can confirm the same
       

    Share This Page