Jump to content

Recommended Posts

In vanilla the previous plugin will not work.

You can try :
 

using System.Threading;
using robotManager.Helpful;
using wManager.Wow.Class;
using wManager.Wow.Helpers;
using wManager.Wow.ObjectManager;

public class Main : wManager.Plugin.IPlugin
{
    public void Initialize()
    {
        Logging.Write("CastSpellByName to /cast plugin loaded.");
        robotManager.Events.Events.OnCustomEvent += OnEventsOnOnCustomEvent;
    }

    private void OnEventsOnOnCustomEvent(string name, object[] args, System.ComponentModel.CancelEventArgs cancelable)
    {
        if (name.StartsWith("Spell.Launch") &&
            args.Length >= 1 &&
            args[0] is Spell)
        {
            Spell spellName = args[0] as Spell;

            if (spellName != null){
                
                string luaUnit = null;
                bool stopMove = false;
                bool waitIsCast = false;
                if (args.Length >= 5 &&
                    args[4] is string &&
                    args[2] is bool &&
                    args[1] is bool)
                {
                    stopMove = (bool)args[1];
                    waitIsCast = (bool)args[2];
                    luaUnit = args[4] as string;
                }

                cancelable.Cancel = true;

                if (stopMove)
                {
                    if (ObjectManager.Me.GetMove)
                        MovementManager.StopMoveTo(true, 1000);
                    if (ObjectManager.Me.GetMove)
                        Thread.Sleep(10);
                }
                
                if (!string.IsNullOrWhiteSpace(luaUnit) && luaUnit != "player" && luaUnit != "none")
                {
                    Logging.WriteDebug("Casting " + spellName + " on " + luaUnit + " with macro /cast");
                    wManager.Wow.Helpers.Lua.RunMacroText("/cast [@" + luaUnit + "] " + spellName);
                }
                else
                {
                    Logging.WriteDebug("Casting " + spellName + " with macro /cast");
                    wManager.Wow.Helpers.Lua.RunMacroText("/cast " + spellName);
                }
                
                
                if (waitIsCast)
                    Thread.Sleep((int)(Usefuls.Latency * 0.9));
                else
                    Thread.Sleep(10);

                while (waitIsCast && ObjectManager.Me.IsCast)
                {
                    Thread.Sleep(1);
                }
            }
        }
    }

    public void Dispose()
    {
        robotManager.Events.Events.OnCustomEvent -= OnEventsOnOnCustomEvent;
    }

    public void Settings()
    {
    }
}

 

Main.cs

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...