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

Farm Vehicle Owner's Mark [PLUGIN]

AUser

New Member
Joined
Oct 17, 2014
Messages
26
Reaction score
0
I had posted this as a response to a request on another thread.

Code:
#region Using Directives

using ArcheBuddy.Bot.Classes;
using System;
using System.Linq;
using System.Threading;
using System.ComponentModel;

#endregion

namespace Experiment
{
    public class OwnersMark
        : Core, INotifyPropertyChanged
    {
        #region Public Static Methods

        public static string GetPluginAuthor()
        {
            return "AUser";
        }

        public static string GetPluginVersion()
        {
            return "1.0.0.3";
        }

        public static string GetPluginDescription()
        {
            return "Keep Owner's Mark on Vehicle";
        }

        #endregion

        #region INotifyPropertyChanged

        public event PropertyChangedEventHandler PropertyChanged;

        protected void OnPropertyChanged(string name)
        {
            if (PropertyChanged != null)
                PropertyChanged.Invoke(this, new PropertyChangedEventArgs(name));
        }

        void HandleStateChange(object sender, PropertyChangedEventArgs e)
        {
            Log("Mount Status: " + (PlayerMounted ? "Sitting" : "Standing"));
            if (PlayerMounted)
                refreshBuff(true);
        }

        #endregion

        #region Properties

        private bool _mounted;
        public bool PlayerMounted
        {
            get { return _mounted; }
            set
            {
                var original = _mounted;
                _mounted = value;

                if (_mounted != original)
                    OnPropertyChanged("PlayerMounted");
            }
        }

        #endregion

        #region Public Methods

        //Call on plugin start
        public void PluginRun()
        {
            ClearLogs();
            Log("Starting ------------------");

            foreach (var mount in getCreatures().Where(a => a.ownerUniqId == me.uniqId && (a.type == BotTypes.Slave || a.type == BotTypes.Mount)))
                Log(string.Format("Name: {0} Type: {1}", mount.name, mount.type.ToString()));

            SetGroupStatus("Guard", true);

            this.PropertyChanged += HandleStateChange;

            DoIt();
        }

        //Call on plugin stop
        public void PluginStop()
        {
            Log("Stopping ------------------");

            DelGroupStatus("Guard");

            this.PropertyChanged -= HandleStateChange;
        }

        public void DoIt()
        {
            while (true)
            {
                PlayerMounted = this.isMounted();

                if (GetGroupStatus("Guard"))
                    if (PlayerMounted)
                        refreshBuff();

                Thread.Sleep(50);
            }
        }

        #endregion

        #region Private Methods

        private void refreshBuff(bool forceRecast = false)
        {
            var mount = this.getSlave();
            BindSlave();

            Thread.Sleep(1000);

            if (forceRecast)
            {
                // Disregard existing buff and reset
                SetTarget(mount);
                UseSkill("Owner's Mark");
            }
            else if (!mount.getBuffs().Any(a => a.name == "Owner's Mark"))
            {
                // Apply only if buff doesn't already exist
                UseSkill("Owner's Mark");
            }
        }

        #endregion
    }
}
 
Last edited:
Would this work on boats? Like Clipper/fishing?
And can you make an on/off button on the widget?
 
Would this work on boats? Like Clipper/fishing?
And can you make an on/off button on the widget?

Added On/Off toggle.

I have a variant I've been playing with for other vehicles. When i'm content with it, I'll share.
 
Thanks! I would love to have this "on" when I am fishing/driving a fishing boat so that whenever I grab the wheel, it does it ASAP. Also, is there a way to change the 'time' to do it, so perhaps it presses this every 10-20 seconds instead of when it expires?
 
Thanks! I would love to have this "on" when I am fishing/driving a fishing boat so that whenever I grab the wheel, it does it ASAP. Also, is there a way to change the 'time' to do it, so perhaps it presses this every 10-20 seconds instead of when it expires?

I revised it to reapply Owner's Mark when you mount the vehicle again; even if the existing buff hasn't expired and it will work with any vehicle now.
 
Back
Top