Suggestion for usage of `UNIT_SPELLCAST_SUCCEEDED`
tflo opened this issue ยท 4 comments
I've seen the addon is watching the UNIT_SPELLCAST_SUCCEEDED
event and then checks the recipes that are being tracked.
This can be a very frequent event (especially in a crowded area), but the good thing is that it always comes with an argument that tells you who the caster is.
So, in the event conditional, the first thing I would do is check if arg1 is 'player'. (Assuming the addon is not interested in other people's spell casts). If it is not 'player', then just do nothing.
I'm not saying that your code is causing noticeable lag or anything, but if you have 100 addons loaded and 50 of them are running unnecessary routines on very frequently firing events, then it will add up ๐
Disclaimer: I've only had a quick look at the code, so it's possible I'm missing something. If the addon really needs to do something about other players' casting events, then just ignore this post.
Actually, my proposal was not quite accurate. You don't even have to check the argument of the event, you can already filter it when registering:
RegisterUnitEvent("UNIT_SPELLCAST_SUCCEEDED", "player")