ascott18 / TellMeWhen

TellMeWhen is a combat tracking AddOn for World of Warcraft Retail and Classic
https://wow.curseforge.com/projects/tellmewhen
GNU General Public License v3.0
86 stars 11 forks source link

added empowered stage #2009

Closed arieh closed 1 year ago

arieh commented 1 year ago

I assume this is far from meeting the project standard, but I thought it can be a good start.

Things to note

The code itself is borrowed from how blizz handles the core empowered castbar.

arieh commented 1 year ago

seems like there are some whitespace issues on this pr as well - guess there's no prettier for lua... will see if I can figure out how to clean it up

ascott18 commented 1 year ago

Thanks. I'll probably take this as a start and build on it a bit. I think it can be done without timers.

arieh commented 1 year ago

Thanks. I'll probably take this as a start and build on it a bit. I think it can be done without timers.

Would really love to see how you solve this :) Are you just going to check on updates on every cycle to see if timer has passed?

ascott18 commented 1 year ago

Finished in b30b8cb.

Ultimately the API is simple and fast enough around this that there's no benefit to doing any caching (and in fact caching is probably worse because it'll be running and collecting that data for every member of your raid, even though 99.99% of users will only use this condition for themselves).

arieh commented 1 year ago

cool. need to better understand how anticipate works I guess :) Looking at your code it does look like a much cleaner solution

ascott18 commented 1 year ago

The idea is to come up with the value of GetTime()/TMW.time (same things) at which the condition needs to be next checked.

The anticipate function (assuming the condition is event-driven - it doesn't exist for OnUpdate conditions) runs whenever an event for that condition is fired, and is also ran after that condition has been checked. So its essentially a built-in timer mechanism for triggering the next update to the condition. By having the anticipate time just be the time at which the next empower stage is reached, it'll just keep chaining updates until the desired stage is reached.

If I wanted to be extra clever I could make it calculate for the specific stage that the condition is checking, but I think that's more work than its worth and having to do that calculation wouldn't save many more CPU cycles than it would consume.