What's new
  • Visit Rebornbuddy
  • Visit Panda Profiles
  • Visit LLamamMagic
  • Visit Resources
  • Visit Downloads
  • Visit Portal

[Plugin] Unstucker - restarts if your character gets stuck

Is this Unstucker hidden from Warden scan? I am asking because this plugin is NOT created by the BOT guys and it uses different memory address?
 
Is this Unstucker hidden from Warden scan? I am asking because this plugin is NOT created by the BOT guys and it uses different memory address?

Unstucker uses DB functions directly; it doesn't do anything on it's own that could get it flagged by Warden.
 
So just checking/tweaking 1.8.1

Wanted to reduced wait time to 10 seconds so:
public static int StuckWaitTime = 10;

To make that possible I left the 5 point update to edited 3 to 2 in:
public static int PositionLoggingInterval =2;

is that all is needed?
 
So just checking/tweaking 1.8.1

Wanted to reduced wait time to 10 seconds so:
public static int StuckWaitTime = 10;

To make that possible I left the 5 point update to edited 3 to 2 in:
public static int PositionLoggingInterval =2;

is that all is needed?

Yep.
 
Good deal. I might test having it shorter at some point. Really going to come down to how long I stand still and whack crap with my axe, but i doubt that's any longer that 3-4 seconds.

Anyways, good plugin. keep up the work.

Edit: Here is something new for you to think about for future releases. I noticed that the total number of stucks I have (5) carry over between each time I get stuck and not resenting to give me a maximum number of tries each time. Or at least that's what I've seen. I will monitor more and see if this keeps happening.
 
Last edited:
Good deal. I might test having it shorter at some point. Really going to come down to how long I stand still and whack crap with my axe, but i doubt that's any longer that 3-4 seconds.

Anyways, good plugin. keep up the work.

Edit: Here is something new for you to think about for future releases. I noticed that the total number of stucks I have (5) carry over between each time I get stuck and not resenting to give me a maximum number of tries each time. Or at least that's what I've seen. I will monitor more and see if this keeps happening.

Can you share the one with less wait time, 40 seconds is too long... :/
 
Hey I actually combined your 1.7 and 1.8 version and added some small changes to your code
While I was busy I saw there was a post about 1.8.1 checked that out aswel and used some code from it too

seem to get inf loop at some situation where the do while loop for random move just keeps filling my logs
and also decreased the timings a bit but thats all up for personal use..

I tried some stuff with Profilemanager.currentprofile.path which results in null :(
so could not try and use that Load function for loading last used profile

Attachment is not working for me somehow so sorry for ugly post ..

Code:
using System;
using System.Collections.Generic;
using System.Threading;
using System.Windows;
using Zeta;
using Zeta.Common;
using Zeta.CommonBot;
using Zeta.Common.Plugins;
using Zeta.Internals;
using Zeta.Internals.Actors;
using Zeta.Internals.Service;

namespace Eax.Plugins
{
    public class Unstucker2 : IPlugin
    {
        // Settings 

        private static int CheckTime =  12; // Maximum time between checks in seconds (default: 40)
        private static int Distance = 30; // Distance in yards that should be traveld within CheckTime (default:10)
        private static int MaxStuckCount = 3; // Maximum allowed time for the but to try a unstucking routine

        // advanced Settings

        private static bool bDecreaseCount = true; // Decrease our stuck counter by 1 after each successful CheckTime period (false will reset it to 0)

        private static int NeededLoggedPositions = 5; // how many logged positions are needed before checking stuck again (default: 5)
        private static int PositionLoggingInterval = 2; // in seconds (default: 3)
        private static int MaxRandomMoves = 4; // Maximum tries for doing the random move loop (preventing inf loop problem)

        // Dont add below here
        private bool IsRestarting { get; set; }
        private bool IsChecking { get; set; }
        private DateTime LastCheckTime { get; set; }
        private DateTime LastLogTime { get; set; }
        private DateTime ThisFightTime { get; set; }
        private string LastUnitID { get; set; }
        private List<Vector3> LoggedPositions { get; set; }
        private int StuckCount { get; set; }
        private DateTime LastStuckTime { get; set; }

        public string Author { get { return "eax"; } }
        public string Description { get { return "This is a modified version on Unstucker v1.8 from eax"; } }
        public string Name { get { return "Unstucker2 v" + Version.ToString(); } }
        public Version Version { get { return new Version(2, 0); } }
        public Window DisplayWindow { get { return null; } }

        private void Log(string message)
        {
            Logging.Write(string.Format("[{0}] {1}", Name, message));
        }

        private static float GetMaxDistanceTraveled(List<Vector3> positions)
        {
            float max = 0F;
            for (int i = 0; i < positions.Count - 1; ++i)
                for (int j = 1; j < positions.Count; ++j)
                    max = Math.Max(max, Math.Abs(positions[i].Distance(positions[j])));
            return max;
        }

        public void OnInitialize()
        {
            StuckCount = 0;
            IsRestarting = false;
            IsChecking = false;
            LastCheckTime = DateTime.Now;
            LastLogTime = DateTime.Now;
            LoggedPositions = new List<Vector3>();
        }

        public void OnPulse()
        {
            // if we're not in game and not in the process of restarting, do nothing
            if (!ZetaDia.IsInGame || !ZetaDia.Me.IsValid || IsRestarting)
            {
                LastCheckTime = DateTime.Now;
                LastLogTime = DateTime.Now;
                LoggedPositions.Clear();
                StuckCount = 0;
                return;
            }

            
            // if it's been 3 seconds since we've logged a position, then we log a new position
            if (DateTime.Now.Subtract(LastLogTime).TotalSeconds > PositionLoggingInterval)
            {
                LastLogTime = DateTime.Now;
                LoggedPositions.Add(ZetaDia.Actors.Me.Position);
            }
			
            // if it's been 40 seconds since we've last evaluated the logged positions, evaluate the logged positions
            if (!IsChecking && (LoggedPositions.Count > NeededLoggedPositions) && (DateTime.Now.Subtract(LastCheckTime).TotalSeconds > CheckTime))
            {
                // we want to prevent this section from being executed twice
                IsChecking = true;

                var rnd = new Random();
                var algorithm = rnd.Next(0, 10);
                // if our person has not traveled 10 yards or whatever in the last 40 seconds, we're stuck
                if (GetMaxDistanceTraveled(LoggedPositions) < Distance)
                {

                    /*if (CombatTargeting.Instance.FirstNpc.IsValid && (CombatTargeting.Instance.FirstNpc.Distance < 15f))
                    {
                        Log("Looks like we are fighting at this position");
                        IsChecking = false;
                        LastCheckTime = DateTime.Now;
                        LastLogTime = DateTime.Now;
                        LoggedPositions.Clear();
                        return;
                    }*/
                    IsRestarting = true;


                    StuckCount++;

                    Log("Your character has not moved "+Distance+" yards for "+CheckTime+" seconds - Trying unstuck routine. (" + StuckCount + "/"+ MaxStuckCount +")");
                    if (StuckCount > MaxStuckCount)
                    { // Restart bot
                        Log("Looks like we cant unstuck ourselfs by moving randomly");
                        
                        Log("Leaving Game");

                        while (ZetaDia.IsInGame)
                        {
                            ZetaDia.Service.Games.LeaveGame();
                            IsRestarting = false;
                            StuckCount = 0;
                            LastCheckTime = DateTime.Now;
                            LastLogTime = DateTime.Now;
                            LoggedPositions.Clear();
                            Thread.Sleep(10000);
                        }
                    }
                    else
                    {
                        // Thanks Nuls
                        var v = ZetaDia.Me.Position;
                        var oldPosition = v;
                        int i = 0;
                        do
                        {
                            i++;
                            if (i > MaxRandomMoves)
                                break;
                            v.X = (DateTime.Now.Millisecond % 2 == 0) ? v.X + rnd.Next(500, 6500) : v.X - rnd.Next(500, 6500);
                            v.Y = (DateTime.Now.Millisecond % 2 == 0) ? v.Y + rnd.Next(500, 6500) : v.Y - rnd.Next(500, 6500);
                            v.Z = (DateTime.Now.Millisecond % 2 == 0) ? v.Z + rnd.Next(500, 6500) : v.Z - rnd.Next(500, 6500);

                            Log("Moving Char randomly to: " + v.ToString() + " (" + i + "/" + MaxRandomMoves + ")");
                            ZetaDia.Me.UsePower(SNOPower.Walk, v, ZetaDia.Me.WorldDynamicId, 2, -1);
                            Thread.Sleep(rnd.Next(2000, 3000)); // HI DB Devs! 
                        } while (ZetaDia.Me.Position == oldPosition);
                    }
                    IsRestarting = false;

                } // if (GetMaxDistanceTraveled(LoggedPositions) < 10f)
                else
                {

                    // decrease stuck count by 1 on successful run
                    if (bDecreaseCount && StuckCount > 0)
                    {
                        StuckCount--;
                        Log("Decreasing StuckCount (" + StuckCount + "/" + MaxStuckCount + ") Looks like we are moving again");
                    }
                    else // reset our stuck counter
                        StuckCount = 0;

                }
                
                IsChecking = false;
                LastCheckTime = DateTime.Now;
                LastLogTime = DateTime.Now;
                LoggedPositions.Clear();
            }
        }

        public void OnShutdown()
        {
        }

        public void OnEnabled()
        {
            Log("Enabled.");
        }

        public void OnDisabled()
        {
            Log("Disabled.");
        }

        public bool Equals(IPlugin other)
        {
            return (other.Name == Name) && (other.Version == Version);
        }
    }
}
 
Yeah. After I get unstuck 5 times through moving every future stuck seems to just end the game for me. Hopefully they fix the issue with not looting vessels soon so I don't teleport from being greedy.
 
why doesnt Unstacker quit/make new game anymore?

my char got stuck today behind a chest and the plugin just tried to move him (unsuccessfully)
 
why doesnt Unstacker quit/make new game anymore?

my char got stuck today behind a chest and the plugin just tried to move him (unsuccessfully)

It will, but first it'll try to move in a random direction to see if it can wrestle itself free.. if that doesn't work it will create a new game.

Way faster when it works (especially with 1.8.1, Nuc shortened the time it takes for unstucker to kick in), and the few times it doesn't, bite the bullet.
 
Last edited:
It will, but first it'll try to move in a random direction to see if it can wrestle itself free.. if that doesn't work it will create a new game.

Way faster when it works (especially with 1.8.1, Nuc shortened the time it takes for unstucker to kick in), and the few times it doesn't, bite the bullet.

1.8.1 is an unofficial one I hacked together haha, but I tried to move some of the timer settings to the top so people can tweak it easier
 
using 1.7 with the "new beta demonbuddy" and working rly rly good but only thing I would like to get changed is the waiting time. The 40 sec is just too long in my opinion
 
yeah I take absolutely no credit for 1.8.1 other than I changed some settings to kick me out of the game faster.

edit: Just a heads up I don't remember which timing I gave to you guys. I tried going down to 5 seconds but that is too short because with standing and attacking and a freeze it'll kick you out of the game. So don't go that low. I'm trying 7 seconds now.
 
Last edited:
Do the 5 seconds only count in CoA?
Because when in town, the character is not moving for more than 5 seconds in order to identify the items
 
Do the 5 seconds only count in CoA?
Because when in town, the character is not moving for more than 5 seconds in order to identify the items

CoA is?
And yeah, one of the bugs is that Unstucker will try to unstuck you when you're identifying items. Not sure how I would prevent this.
 
Core of the Arreat - Sorry, was only thinking about my farming runs.
 
Back
Top