Zer0 148 Posted May 22, 2021 Share Posted May 22, 2021 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? Link to comment https://wrobot.eu/forums/topic/13059-can-wrobot-catch-unit_spellcast_succeeded-with-arguments/ Share on other sites More sharing options...
Matenia 628 Posted May 23, 2021 Share Posted May 23, 2021 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. Zer0 1 Link to comment https://wrobot.eu/forums/topic/13059-can-wrobot-catch-unit_spellcast_succeeded-with-arguments/#findComment-62056 Share on other sites More sharing options...
Zer0 148 Posted May 23, 2021 Author Share Posted May 23, 2021 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). 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. Link to comment https://wrobot.eu/forums/topic/13059-can-wrobot-catch-unit_spellcast_succeeded-with-arguments/#findComment-62057 Share on other sites More sharing options...
Zer0 148 Posted May 23, 2021 Author Share Posted May 23, 2021 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 Link to comment https://wrobot.eu/forums/topic/13059-can-wrobot-catch-unit_spellcast_succeeded-with-arguments/#findComment-62058 Share on other sites More sharing options...
Droidz 2738 Posted May 23, 2021 Share Posted May 23, 2021 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? Zer0 1 Link to comment https://wrobot.eu/forums/topic/13059-can-wrobot-catch-unit_spellcast_succeeded-with-arguments/#findComment-62059 Share on other sites More sharing options...
Zer0 148 Posted May 23, 2021 Author Share Posted May 23, 2021 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. Link to comment https://wrobot.eu/forums/topic/13059-can-wrobot-catch-unit_spellcast_succeeded-with-arguments/#findComment-62061 Share on other sites More sharing options...
Droidz 2738 Posted May 25, 2021 Share Posted May 25, 2021 It is french client but this works for me. WBjxgEyiOk.mp4 Link to comment https://wrobot.eu/forums/topic/13059-can-wrobot-catch-unit_spellcast_succeeded-with-arguments/#findComment-62071 Share on other sites More sharing options...
Zer0 148 Posted May 25, 2021 Author Share Posted May 25, 2021 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? Link to comment https://wrobot.eu/forums/topic/13059-can-wrobot-catch-unit_spellcast_succeeded-with-arguments/#findComment-62073 Share on other sites More sharing options...
Zer0 148 Posted May 25, 2021 Author Share Posted May 25, 2021 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 ? Link to comment https://wrobot.eu/forums/topic/13059-can-wrobot-catch-unit_spellcast_succeeded-with-arguments/#findComment-62076 Share on other sites More sharing options...
Droidz 2738 Posted May 26, 2021 Share Posted May 26, 2021 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. Link to comment https://wrobot.eu/forums/topic/13059-can-wrobot-catch-unit_spellcast_succeeded-with-arguments/#findComment-62085 Share on other sites More sharing options...
Zer0 148 Posted May 26, 2021 Author Share Posted May 26, 2021 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) I hope it helps. Droidz 1 Link to comment https://wrobot.eu/forums/topic/13059-can-wrobot-catch-unit_spellcast_succeeded-with-arguments/#findComment-62093 Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now