Issues regarding UNIT_SPELLCAST_SUCCEEDED
Hey,
Basically this is my first attempt at an addon, it's pretty basic and is supposed to show the amount of Chain Heal bounces for each cast, with multistrikes separated. I've got some previous programming experience, but this is the first time dabbling with Lua. I'll start with explaining the issue and then pasting in the code below. The basic idea is two event listeners, one on UNIT_SPELLCAST_SUCCEEDED and then one on 'COMBAT_LOG_EVENT'. I think I've managed these ones pretty well, but the succeeded event fires before all the combat log collecting has been done. So I figured that the data gathering is taking too long and with no connection between the two events, they'll work asynchronously. Solution seems to be either to speed up the combat log events or make them fire off one another (somehow). Here's the code: Lua Code:
With the successful cast function.. Lua Code:
And the combat log filtering. Lua Code:
Here's some sample output: And full code can be viewed here (pastebin) Thanks for your time! |
What's happening is all the events are firing at the same time, but as the UI engine only runs on one thread, it can only process one at a time in completely random order. One thing I'm seeing though is all the bounces are using the same timestamp, perhaps you can use that to differentiate the separate casts.
|
One thing you may want to do, completely unrelated to the problem you're trying to tackle, is switching to:
local _, _, _, _, _, etc = ... the code may not look as tidy with all of the empty _ variables, but the cpu impact compared to using select(#, ...) should be pretty noticeable, especially if you're poling for chain heal hits in the combat log |
Quote:
1. Addon detects a successful Chain Heal. 2. Store each of the chain heal hits inside a table (since I'll otherwise have to react on each hit individually) 3. Display the total amount of hits, within the timeline this would be preferable to happen as soon as possible after the UNIT_SPELLCAST_SUCCEEDED event. I could do a check for a timestamp from each combat log event, but I wouldn't get the data regarding the previous cast until I've finished the next one (as that particular function only fires once a combat log event has fired). I attempted to gather a timestamp from the UNIT_SPELLCAST_SUCCEEDED, but I couldn't find a way of getting one without generating one myself, through the time() api, which seems highly unreliable. I'm also not quite sure what I would do with the results. Please let me know if I've misunderstood you, or perhaps aiming for an impossible solution. Quote:
On a separate note, whilst still on the general topic. I stumbled upon the OnUpdate functionality, and perhaps a separate solution. I'm not quite familiar with resources and how heavy certain functionality will be on the target system, but my briefly planned solution could perhaps be the following. Remove the UNIT_SPELLCAST_SUCEEDED event-listener, instead provide a OnUpdate function, perhaps tie it in to half of the approximated cast-time of Chain Heal or whatever seems appropriate. Save the chain heals by their timestamp and keep updating the actual frame (the UI component) with the latest set of hits/data. I'd probably need to decide around garbage collection and more, unless that's taken care of by the engine. Could this approach perhaps work? Whilst considering it, the only potential issue would be jerkyness of the data displayed on the screen, since it wouldn't be updated after a cast, but from 0 seconds to whatever interval it ends up being. |
I think SDPhantom's idea of clumping them by timestamp is best. It would require an OnUpdate function briefly to clear the table, but essentially, you'd listen for the event, record the timestamps, and then add them to a table, set the k to the instance, and the v to the timestamp, then compare all of the v's using a for k, v in pairs or something. Once you "clump" all of your events together by looking at their timestamp, you can add them or do w/e. Then wipe the table, turn off the onupdate, and turn back on your combat log parser.
e. if you're worried about the "latency" of the data, you could set the onupdate interval to run once 0.1s after the combat log event. This would essentially be unnoticable, and if it is, just lower the 0.1 to like .06 or w/e your ping is |
sirann has a good idea but instead of an OnUpdate you could try a C_Timer.NewTicker. Use a counter checking its size on each tick, if the counter matches the previous value just do what you need there.
|
From what I see of your code, it's much more complicated than it needs to be for what you describe. Essentially, too much class-style programming is going to end up bogging down the addon with tons of indexing operations. The example I'm going to show is written from scratch.
Lua Code:
This will end up populating the HistoryData table with instances of every single cast of Chain Heal. Every entry will contain a list of every hop the spell did between targets, including who those targets were, how much they were healed, crits, and multistrikes. I also added a little code to reliably run after the events all fire. Quote:
|
you're over complicating it, just use the combat log event for the cast detection, count hits as they come in, announce and reset the counter on the frame following the cast success.
Code:
local f=CreateFrame("Frame") |
Thanks a lot for the answers, unfortunately I don't have enough time as I wished I had to spend on this, so I'll have to get back whenever I've poked and prodded the solutions you guys provided, so again, thanks a lot!
I'll make sure to post again with either a finished product or another cry for help! |
Quote:
Quote:
|
All times are GMT -6. The time now is 04:41 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI