Jump to content

Recommended Posts

I'm trying to catch the UNIT_SPELLCAST_SUCCEEDED event for Auto Shots.

I've tried 

EventsLua.AttachEventLua("UNIT_SPELLCAST_SUCCEEDED", c => HandleAutoAttackEvent(c));

It does work, but for all spells, and I'm only interested in my own auto attacks (so at least, I know this event is the correct one).

 

EventsLuaWithArgs.OnEventsLuaStringWithArgs += AutoShotEventHandler;

This one is the one I would need, but it doesn't catch any UNIT_SPELLCAST_SUCCEEDED.  It only catches COMBAT_LOG_EVENT_UNFILTERED and COMBAT_LOG_EVENT events. I'm on TBC, I've been told that in WotLK, EventsLuaWithArgs.OnEventsLuaStringWithArgs does catch UNIT_SPELLCAST_SUCCEEDED.

Does anyone know how I can do that?

I use EventsLuaWithArgs.OnEventsLuaStringWithArgs for pretty much everything. It definitely logs all events. However, if you're using something based on my framework, where I copied this functionality, I specifically only registered it with COMBAT_LOG_EVENT_UNFILTERED, whereas Droidz' functionality uses RegisterAllEvents().

Also, have you made sure you're actually getting the event for auto shot in the client? Afaik, at least in TBC, it was never fired.

Thanks for the answer.

I do get the event in the client. I have tried this:

            Lua.LuaDoString($@"
                AIOAutoHunt = CreateFrame('Frame')
                AIOAutoHunt:RegisterEvent(""UNIT_SPELLCAST_SUCCEEDED"")
                AIOAutoHunt:SetScript('OnEvent',
                    function(self, event, unit, spell)
                        if unit == 'player' and spell == 'Auto Shot' then
                            DEFAULT_CHAT_FRAME:AddMessage(spell);
                        end
                    end
                )");

and it catches my auto attacks successfully (I get the message in the chat every time an auto shot is fired).

898226963_CanWRobotcatchUNIT_SPELLCAST_SUCCEEDEDwitharguments-Developersassistance-WRobot-GoogleChrome.jpg.a2781556b9bd0474f876925b5f35f3a1.jpg

I'm not using your framework, I'm using WRobot's EventsLuaWithArgs.OnEventsLuaStringWithArgs (wManager.Wow.Helpers). So I guess something else is wrong, but I'm not sure what.

Also fore reference, I've tried logging all the events

        private void AutoShotEventHandler(string id, List<string> args)
        {
            Logger.Log($"******************** {id} ********************");
            for (int i = 0; i < args.Count; i++)
            {
                Logger.Log($"{i} -> {args[i]}");
            }
            Logger.Log($"******************** END ********************");
        }

You can have a look at the log joined to this post and see what happens (the character is only auto attacking).

23 mai 2021 11H40.log.html

Hey, I tested this code he works for me:

     wManager.Wow.Helpers.EventsLuaWithArgs.OnEventsLuaStringWithArgs += (eventid, args) =>
            {
            if (eventid == "UNIT_SPELLCAST_SUCCEEDED")
                            Logging.WriteDebug("[EVENT] " + args[0] + " > " + args[1]);
            };

It is not the case for you?

7 hours ago, Droidz said:

Hey, I tested this code he works for me:


     wManager.Wow.Helpers.EventsLuaWithArgs.OnEventsLuaStringWithArgs += (eventid, args) =>
            {
            if (eventid == "UNIT_SPELLCAST_SUCCEEDED")
                            Logging.WriteDebug("[EVENT] " + args[0] + " > " + args[1]);
            };

It is not the case for you?

It doesn't work for me. I've ran more tests. I thought it was an issue with my WRobot so I've downloaded a fresh install. No plugin, no addons. Same problem. I have also tried with 2 different TBC clients (Excalibur/Netherwing), same result on both clients. I only get COMBAT_LOG_EVENT_UNFILTERED and COMBAT_LOG_EVENT out of EventsLuaWithArgs.OnEventsLuaStringWithArgs.

On both clients I'm still able to catch the event directly with LUA.

1299932074_PrtScrcapture.jpg.0d295be464dac631e5861378dfebf65b.jpg

I don't doubt your words. If it works for you, then it works, but I feel like I've tried everything, and I'm still having this issue.

So, to recap what I've tried:

Catching the event with no args works:

EventsLua.AttachEventLua("UNIT_SPELLCAST_SUCCEEDED ", c => HandleAutoAttackEvent(c));
...
private void HandleAutoAttackEvent(object context)
{
  Logger.Log("AUTO");
}

Catching the event directly in the client works:

            Lua.LuaDoString($@"
                AIOAutoHunt = CreateFrame('Frame')
                AIOAutoHunt:RegisterEvent(""UNIT_SPELLCAST_SUCCEEDED"")
                AIOAutoHunt:SetScript('OnEvent',
                    function(self, event, unit, spell)
                        if unit == 'player' and spell == 'Auto Shot' then
                            DEFAULT_CHAT_FRAME:AddMessage(spell);
                        end
                    end
                )");

Catching events with args only returns COMBAT_LOG_EVENT and COMBAT_LOG_EVENT_UNFILTERED

EventsLuaWithArgs.OnEventsLuaStringWithArgs += (eventid, args) =>
{
  if (eventid == "UNIT_SPELLCAST_SUCCEEDED")
    Logging.WriteDebug("[EVENT] " + args[0] + " > " + args[1]);
};

------ OR ------

EventsLuaWithArgs.OnEventsLuaStringWithArgs += AutoShotEventHandler;
...
private void AutoShotEventHandler(string id, List<string> args)
{
  Logger.Log($"******************** {id} ********************");
  for (int i = 0; i < args.Count; i++)
  {
    Logger.Log($"{i} -> {args[i]}");
  }
  Logger.Log($"******************** END ********************");
}

I'm using a freshly installed WRobot (no plugin) and I've ran those tests on 2 different WoW clients (no addon). I've made sure I compiled my FightClass with the fresh WRobot dlls as references. Do you have any idea what could possibly be different between your setup and mine? Could it be caused by the client? Something in my code?

I have found what the issue is.

So my AIO first selects a rotation class in Main.Initialize(), and then launches the Initialize() method of the selected class (which also derives from the IClassRotation interface), for example Hunter.Initialize().

For some reason, subscribing to OnEventsLuaStringWithArgs inside Hunter.Initialize() only gets me COMBAT_LOG EVENT and COMBAT_LOG_EVENT_UNFILTERED. I've moved the code to Main.Initialize() and it works perfectly now. I have no idea why it happens like that, but I'm glad it's fixed.

Thanks everyone for your help ?

It is strange, I don't understand what can happen.

I will add logs in case of error in one of the calls

        wManager.Wow.Helpers.EventsLuaWithArgs.OnEventsLuaStringWithArgs += (eventid, args) =>
        {
            Logging.WriteDebug("[EVENT] 1");
        };
        
        wManager.Wow.Helpers.EventsLuaWithArgs.OnEventsLuaStringWithArgs += (eventid, args) =>
        {
            throw new Exception("eeee");
        };
        
        
        wManager.Wow.Helpers.EventsLuaWithArgs.OnEventsLuaStringWithArgs += (eventid, args) =>
        {
            Logging.WriteDebug("[EVENT] 3");
        };

3 is never invoked at home. I hope that the logs will help to resolve problems like this.

For your information, I used to subscribe to OnEventsLuaStringWithArgs in 2 places. 

First in Hunter.Initialize() and then in the constructor of another class called Cast.Cast()

in both places I could only get COMBAT_LOG_EVENT and COMBAT_LOG_EVENT_UNFILTERED. now that I've moved the hunter autoshot event catcher to the Main.Initialize() method, I can get all events from there.

For the sake of testing I've logged the Cast.Cast() event catcher and I still only catch COMBAT_LOG_EVENT and COMBAT_LOG_EVENT_UNFILTERED (Which in this case doesn't matter because I don't need anything else)

image.png.6a378c6822bfa0ea30af92460bd4bf97.png

I hope it helps.

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