Jump to content

I need help with my fightclass thought lua code


Recommended Posts

Hi, folks. I have a problem with my fightclass, maybe someone can help me? 

Anyway, this description of my problem. I'm playing on custom wow server, which using russian language. So I have to do my fightclass use lua code (/runMacroText ""). It's works great, when I using it for myself, but doesn't work, when I need healing class for teammate. For exaple: I'm trying go to dungeon my character with heal, but chart just staying afk. He's trying healing enemy, but not teammate. He just choice teammate at targen on 1-2 second and switches to someone else. Then they're just die. 


So, how can I do to my healing teammate, don't enemy? 

Link to comment
Share on other sites

Hello,

No tested, but you can try this plugin :  CastSpellByName to Cast Macro.cs

using robotManager.Helpful;

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("SpellManager.CastSpellByName") &&
            args.Length >= 1 &&
            args[0] is string)
        {
            var spellName = (string)args[0];

            if (!string.IsNullOrWhiteSpace(spellName)){
                
                string luaUnit = null;
                if (args.Length >= 2 &&
                    args[1] is string)
                    luaUnit = (string)args[1];

                cancelable.Cancel = true;

                if (!string.IsNullOrWhiteSpace(luaUnit) && luaUnit != "player")
                {
                    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);
                }
            }
        }
    }

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

    public void Settings()
    {
    }
}

I haven't tested, but this plugin should enable fight classes that use the bot method "CastSpellByNameOn" (which is the case for most fight classes) to force the bot to use "/cast ..." instead. Therefore, use this plugin with your fight class configured normally (without using "/cast").

Link to comment
Share on other sites

I tried fix it, but errors become many. I used Visual Studio, trying fixed errors with syntax, but VS says "everything is okay", but then I put it at folder Wrobot, I got too many errors

I don't know why... Can you give me an idea, why it can happen? @Droidz

Link to comment
Share on other sites

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...