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

Developing an unstucker plugin - need some tests run!

You're plugin doesn't even show up on the Plugins panel in the bot, and I copied it to the Plugins folder
 
That plugin didn't even work, they just integrated that into the bot directly
 
Can't compile it because there's a WPF dependency. Cbf to install VS so this project is off.

dll plugins are scary...

Hopefully DB can compile the .cs files on the fly with CodeDOM or something so we don't have to deal with DLLs.

That plugin didn't even work, they just integrated that into the bot directly

I assumed it worked because the author posted it without suggesting otherwise. I know.
 
Last edited:
So, not entirely sure but I think the issue was I didn't know you needed to make a "parent folder"

I think someone took your profile and posted it in another thread and mentioned that point, and it worked, so your plugin probably works fine
 
Assuming that other post was your same plugin, I got it working, but it hearthed and then didn't log off?
 
Oh great. I can finish it. All the plugin should do is output some info to the logs. I need the plugin activated while your in game AFTER you've started a profile/script first though. Download is back up in my original post and here: TryGetQuestInfo.cs - Localhostr

Can you post a link to the thread you're talking about?
 
Ok so it turns out that once you leave the game the script will automatically rejoin, so I don't need to do these tests at all. Here's the completed script. Someone let me know if it works.

Save it as Unstucker.cs

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

namespace Unstucker
{
    public class Unstucker : IPlugin
    {
        #region Iplugin
        public bool Equals(IPlugin other)
        {
            // we should probably be comparing versions too
            return other.Name == Name;
        }

        public string Author
        {
            get { return "eax"; }
        }

        public string Description
        {
            get { return "Automatically teleports player back to down when stuck."; }
        }

        public string Name
        {
            get { return "Unstucker"; }
        }

        public Version Version
        {
            get { return new Version(1, 0); }
        }

        public Window DisplayWindow { get { return null; } }

        /// <summary> Executes the shutdown action. This is called when the bot is shutting down. (Not when Stop() is called) </summary>
        public void OnShutdown()
        {
        }

        /// <summary> Executes the enabled action. This is called when the user has enabled this specific plugin via the GUI. </summary>
        public void OnEnabled()
        {
            Logging.Write("Unstucker enabled.");
        }

        /// <summary> Executes the disabled action. This is called whent he user has disabled this specific plugin via the GUI. </summary>
        public void OnDisabled()
        {
            Logging.Write("Unstucker disabled.");
        }

        #endregion

        private DateTime LastCheckTime { get; set; }
        private DateTime LastLogTime { get; set; }
        private List<Vector3> LoggedPositions { get; set; };

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

        public void OnInitialize()
        {
            LastCheckTime = DateTime.Now;
            LastLogTime = DateTime.Now;
            LoggedPositions = new List<Vector3>();
            LoggedPositions.Add(ZetaDia.Actors.Me.Position);
        }

        public void OnPulse()
        {
            // if we're not in game or if...we're not valid?...then we do nothing
            if (!ZetaDia.IsInGame || !ZetaDia.Me.IsValid)
                return;

            // if it's been 10 seconds since we've logged a position, then we log a new position
            if (DateTime.Now.Subtract(LastLogTime).TotalSeconds > 10)
            {
                LastLogTime = DateTime.Now;
                LoggedPositions.Add(ZetaDia.Actors.Me.Position);
            }

            // if it's been 60 seconds since we've last evaluated the logged positions, evaluate the logged positions
            if (DateTime.Now.Subtract(LastCheckTime).TotalSeconds > 60)
            {
                LastCheckTime = DateTime.Now;

                // if our person has not traveled 10 yards or whatever in the last 60 seconds, we're stuck
                if (GetMaxDistanceTraveled(LoggedPositions) < 10f)
                {
                    if (!ZetaDia.Actors.Me.IsInTown)
                    {
                        ZetaDia.Actors.Me.UseTownPortal();
                        Thread.Sleep(8000);
                    }
                    ZetaDia.Service.Games.LeaveGame();
                }
                
                // ok now we reset everything
                LastLogTime = DateTime.Now;
                LoggedPositions.Clear();
            }
        }

    }
}
 
Last edited:
I'm getting:

Compiler Error: c:\Users\Alan\Desktop\Demonbuddy\Plugins\Unstucker\Unstucker.cs(67,60) : error CS1597: Semicolon after method or accessor block is not valid
 
[00:48:26.861 N] Compiler Error: c:\Users\Michael\Desktop\DLC\Plugins\Unstucker\Unstucker.cs(67,60) : error CS1597: Semicolon after method or accessor block is not valid
 
Fixed, testing now






using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Windows;
using Zeta;
using Zeta.Common;
using Zeta.Common.Plugins;
using Zeta.Internals;
using Zeta.Internals.Actors;
using Zeta.Internals.Service;


namespace Unstucker
{
public class Unstucker : IPlugin
{
#region Iplugin
public bool Equals(IPlugin other)
{
// we should probably be comparing versions too
return other.Name == Name;
}


public string Author
{
get { return "eax"; }
}


public string Description
{
get { return "Automatically teleports player back to down when stuck."; }
}


public string Name
{
get { return "Unstucker"; }
}


public Version Version
{
get { return new Version(1, 0); }
}


public Window DisplayWindow { get { return null; } }


/// <summary> Executes the shutdown action. This is called when the bot is shutting down. (Not when Stop() is called) </summary>
public void OnShutdown()
{
}


/// <summary> Executes the enabled action. This is called when the user has enabled this specific plugin via the GUI. </summary>
public void OnEnabled()
{
Logging.Write("Unstucker enabled.");
}


/// <summary> Executes the disabled action. This is called whent he user has disabled this specific plugin via the GUI. </summary>
public void OnDisabled()
{
Logging.Write("Unstucker disabled.");
}


#endregion


private DateTime LastCheckTime { get; set; }
private DateTime LastLogTime { get; set; }
private List<Vector3> LoggedPositions { get; set; }


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


public void OnInitialize()
{
LastCheckTime = DateTime.Now;
LastLogTime = DateTime.Now;
LoggedPositions = new List<Vector3>();
LoggedPositions.Add(ZetaDia.Actors.Me.Position);
}


public void OnPulse()
{
// if we're not in game or if...we're not valid?...then we do nothing
if (!ZetaDia.IsInGame || !ZetaDia.Me.IsValid)
return;


// if it's been 10 seconds since we've logged a position, then we log a new position
if (DateTime.Now.Subtract(LastLogTime).TotalSeconds > 10)
{
LastLogTime = DateTime.Now;
LoggedPositions.Add(ZetaDia.Actors.Me.Position);
}


// if it's been 60 seconds since we've last evaluated the logged positions, evaluate the logged positions
if (DateTime.Now.Subtract(LastCheckTime).TotalSeconds > 60)
{
LastCheckTime = DateTime.Now;


// if our person has not traveled 10 yards or whatever in the last 60 seconds, we're stuck
if (GetMaxDistanceTraveled(LoggedPositions) < 10f)
{
ZetaDia.Actors.Me.UseTownPortal();
Thread.Sleep(8000);
ZetaDia.Service.Games.LeaveGame();
}

// ok now we reset everytSmog#1823hing
LastLogTime = DateTime.Now;
LoggedPositions.Clear();
}
}


}
}
 
Still fails

[00:52:02.926 D] System.NullReferenceException: Object reference not set to an instance of an object.
at Unstucker.Unstucker.OnInitialize() in c:\Users\Michael\Desktop\DLC\Plugins\Unstucker\Unstucker.cs:line 83
at Zeta.Common.Plugins.PluginManager.ReloadAllPlugins(String pluginsDirectory, Boolean reloadOnFileChange)
 
I took the semi-colon off a few minutes ago and have it running atm, waiting to see if it works
 
Ok so it turns out that once you leave the game the script will automatically rejoin, so I don't need to do these tests at all. Here's the completed script. Someone let me know if it works.

Save it as Unstucker.cs

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

namespace Unstucker
{
    public class Unstucker : IPlugin
    {
        #region Iplugin
        public bool Equals(IPlugin other)
        {
            // we should probably be comparing versions too
            return other.Name == Name;
        }

        public string Author
        {
            get { return "eax"; }
        }

        public string Description
        {
            get { return "Automatically teleports player back to down when stuck."; }
        }

        public string Name
        {
            get { return "Unstucker"; }
        }

        public Version Version
        {
            get { return new Version(1, 0); }
        }

        public Window DisplayWindow { get { return null; } }

        /// <summary> Executes the shutdown action. This is called when the bot is shutting down. (Not when Stop() is called) </summary>
        public void OnShutdown()
        {
        }

        /// <summary> Executes the enabled action. This is called when the user has enabled this specific plugin via the GUI. </summary>
        public void OnEnabled()
        {
            Logging.Write("Unstucker enabled.");
        }

        /// <summary> Executes the disabled action. This is called whent he user has disabled this specific plugin via the GUI. </summary>
        public void OnDisabled()
        {
            Logging.Write("Unstucker disabled.");
        }

        #endregion

        private DateTime LastCheckTime { get; set; }
        private DateTime LastLogTime { get; set; }
        private List<Vector3> LoggedPositions { get; set; };

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

        public void OnInitialize()
        {
            LastCheckTime = DateTime.Now;
            LastLogTime = DateTime.Now;
            LoggedPositions = new List<Vector3>();
            LoggedPositions.Add(ZetaDia.Actors.Me.Position);
        }

        public void OnPulse()
        {
            // if we're not in game or if...we're not valid?...then we do nothing
            if (!ZetaDia.IsInGame || !ZetaDia.Me.IsValid)
                return;

            // if it's been 10 seconds since we've logged a position, then we log a new position
            if (DateTime.Now.Subtract(LastLogTime).TotalSeconds > 10)
            {
                LastLogTime = DateTime.Now;
                LoggedPositions.Add(ZetaDia.Actors.Me.Position);
            }

            // if it's been 60 seconds since we've last evaluated the logged positions, evaluate the logged positions
            if (DateTime.Now.Subtract(LastCheckTime).TotalSeconds > 60)
            {
                LastCheckTime = DateTime.Now;

                // if our person has not traveled 10 yards or whatever in the last 60 seconds, we're stuck
                if (GetMaxDistanceTraveled(LoggedPositions) < 10f)
                {
                    if (!ZetaDia.Actors.Me.IsInTown)
                    {
                        ZetaDia.Actors.Me.UseTownPortal();
                        Thread.Sleep(8000);
                    }
                    ZetaDia.Service.Games.LeaveGame();
                }
                
                // ok now we reset everything
                LastLogTime = DateTime.Now;
                LoggedPositions.Clear();
            }
        }

    }
}

Compile error: Demonbuddy 1.0.442.84\Plugins\Unstucker\Unstucker.cs(67,60) : error CS1597: Semicolon after method or accessor block is not valid
 
Compile error: Demonbuddy 1.0.442.84\Plugins\Unstucker\Unstucker.cs(67,60) : error CS1597: Semicolon after method or accessor block is not valid

private DateTime LastCheckTime { get; set; }
private DateTime LastLogTime { get; set; }
private List<Vector3> LoggedPositions { get; set; };

Take the ; off last line and it compiles, unfortunately it doesn't seem to fix getting stuck.
 
Compile error: Demonbuddy 1.0.442.84\Plugins\Unstucker\Unstucker.cs(67,60) : error CS1597: Semicolon after method or accessor block is not valid
Just open the Unstucker.cs in notepad and fix this line:

private List<Vector3> LoggedPositions { get; set; };

to this

private List<Vector3> LoggedPositions { get; set; }

(remove the ; at the end)

Testing the unstucker now, I think its gonna work.
May I also ask, what library you imported to use the Zeta API?
 
I already posted an update fixing that, but it still won't work.

[01:01:30.543 D] Exception thrown when initializing Unstucker. Plugin is now disabled. Stack trace is as follows.
[01:01:30.545 D] System.NullReferenceException: Object reference not set to an instance of an object.
at Unstucker.Unstucker.OnInitialize() in c:\Users\Michael\Desktop\DLC\Plugins\Unstucker\Unstucker.cs:line 83
at Zeta.Common.Plugins.PluginManager.ReloadAllPlugins(String pluginsDirectory, Boolean reloadOnFileChange)
[01:01:30.547 D] There are 1 plugins.
[01:01:37.413 N] Unstucker enabled.
[01:01:44.034 D] Start/Stop Button Clicked!



Basically it threw an error, I manually turned it back on, and surprise surprise... when I got stuck it failed to do anything at all :'(
 
Back
Top