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

Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Townrun on button press?

Notmyreal

Member
Joined
Apr 22, 2014
Messages
62
Hi im trying myself with writing a plugin now. I read the guides in the guide section installed visual studio express everything is ready.

Im trying to write a plugin, that when i press a button at the exilebuddy settings gui, starts to loot the items and execute the townrun.
I sadly didnt get really far. Thats what i got for now:

6mTQIeM.png

PG6po2G.png


Code:
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Windows.Controls;
using log4net;
using Loki.Bot;
using Loki.Bot.Logic.Bots.OldGrindBot;
using Loki.Common;
using Loki.Game;
using Loki.Game.GameData;

namespace RequestTownRun
{
    internal class RequestTownRun : IPlugin
    {
        private static readonly ILog Log = Logger.GetLoggerInstanceForType();

        private Gui _instance;

        private static uint _seed;
        private static DatWorldAreaWrapper _areaEntry;

        private static bool _isDead;
        private static uint _isDeadSeed;
        private static readonly Dictionary<uint, int> DeathsPerInstance = new Dictionary<uint, int>();

        private static string _name;
        private static int _level;

        #region Implementation of IAuthored

        /// <summary> The name of the plugin. </summary>
        public string Name
        {
            get
            {
                return "RequestTownRun";
            }
        }

        /// <summary>The author of the plugin.</summary>
        public string Author
        {
            get
            {
                return "---";
            }
        }

        /// <summary> The description of the plugin. </summary>
        public string Description
        {
            get
            {
                return "Start to loot and begin a TownRun.";
            }
        }

        /// <summary>The version of the plugin.</summary>
        public string Version
        {
            get
            {
                return "0.0.1.1";
            }
        }

        #endregion

        #region Implementation of IBase

        /// <summary>Initializes this plugin.</summary>
        public void Initialize()
        {
            Log.DebugFormat("[RequestTownRun] Initialize");
        }

        /// <summary>Deinitializes this object. This is called when the object is being unloaded from the bot.</summary>
        public void Deinitialize()
        {
            Log.DebugFormat("[RequestTownRun] Deinitialize");
        }

        #endregion

        #region Implementation of IRunnable

        /// <summary> The plugin start callback. Do any initialization here. </summary>
        public void Start()
        {
            Log.DebugFormat("[RequestTownRun] Start");
        }

        /// <summary> The plugin tick callback. Do any update logic here. </summary>
        public void Tick()
        {
            _taskManager.Tick();
            if (!LokiPoe.IsInGame)
                return;
        }

        /// <summary> The plugin stop callback. Do any pre-dispose cleanup here. </summary>
        public void Stop()
        {
            Log.DebugFormat("[RequestTownRun] Stop");
        }

        #endregion

        #region Implementation of IConfigurable

        /// <summary>The settings object. This will be registered in the current configuration.</summary>
        public JsonSettings Settings
        {
            get
            {
                return RequestTownRunSettings.Instance;
            }
        }

        /// <summary> The plugin's settings control. This will be added to the Exilebuddy Settings tab.</summary>
        public UserControl Control
        {
            get
            {
                return (_instance ?? (_instance = new Gui()));
            }
        }

        #endregion

        #region Implementation of ILogic

        /// <summary>
        /// Coroutine logic to execute.
        /// </summary>
        /// <param name="type">The requested type of logic to execute.</param>
        /// <param name="param">Data sent to the object from the caller.</param>
        /// <returns>true if logic was executed to handle this type and false otherwise.</returns>
        public async Task<bool> Logic(string type, params dynamic[] param)
        {
            if (type == "plugin_coroutine_event")
            {
               

                return true;
            }

            return false;
        }

        /// <summary>
        /// Non-coroutine logic to execute.
        /// </summary>
        /// <param name="name">The name of the logic to invoke.</param>
        /// <param name="param">The data passed to the logic.</param>
        /// <returns>Data from the executed logic.</returns>
        public object Execute(string name, params dynamic[] param)
        {
            return null;
        }

        #endregion

        #region Implementation of IEnableable

        /// <summary> The plugin is being enabled.</summary>
        public void Enable()
        {
            Log.DebugFormat("[RequestTownRun] Enable");
        }

        /// <summary> The plugin is being disabled.</summary>
        public void Disable()
        {
            Log.DebugFormat("[RequestTownRun] Disable");
        }

        #endregion

        #region Override of Object

        /// <summary>Returns a string that represents the current object.</summary>
        /// <returns>A string that represents the current object.</returns>
        public override string ToString()
        {
            return Name + ": " + Description;
        }

        #endregion
    }
}

I would appreciate if someone could give me a push in the right direction.
 
To trigger a town run in the old bot, you need to obtain the Settings instance of the OldGrindBot, cast to the OldGrindBotSettings type, then you can call the TriggerTownRun function.

This is roughly:
Code:
var settings = BotManager.CurrentBot.Settings as Loki.Bot.Logic.Bots.OldGrindBot.OldGrindBotSettings;
// check for null to make sure the current bot is actually as expected.
settings.TriggerTownRun();

The output should be something like: "[TriggerTownRun] NeedsTownRun = 0. Now setting to 1."

The bot will do a town run after that, and then return to the area to continue.
 
To trigger a town run in the old bot, you need to obtain the Settings instance of the OldGrindBot, cast to the OldGrindBotSettings type, then you can call the TriggerTownRun function.

This is roughly:
Code:
var settings = BotManager.CurrentBot.Settings as Loki.Bot.Logic.Bots.OldGrindBot.OldGrindBotSettings;
// check for null to make sure the current bot is actually as expected.
settings.TriggerTownRun();

The output should be something like: "[TriggerTownRun] NeedsTownRun = 0. Now setting to 1."

The bot will do a town run after that, and then return to the area to continue.
Thanks <3
 
Back
Top