So I am doing something like the following to figure out how long it will take a mob to die...is there a better way or a "smoother" or more accurate way (it is a time to die driven status bar being you vs your target)it does the calculations for you and your target and sets the value of the status bar off of that along with showing both times to die as text under the bar (RemainingTimeToKill is capped also to prevent infinite errors)
the HPs / MaxHPs are actually updated by unit event handlers but this is the current formula I am using
lua Code:
-- CombatStartTime is set on event elsewhere
local FullHP = UnitHealtMax("target")
local CurrentHP = UnitHealth("target")
local LostHP = FullHP - CurrentHP
local TimeSpent = (Time - CombatStartTime > 1) and (Time - CombatStartTime) or 1
local DPS = LostHP / TimeSpent > 0.1 and LostHP / TimeSpent or 0.1
local FullTimeToKill = FullHP / DPS
local RemainingTimeToKill = math.floor((FullTimeToKill - TimeSpent) + 0.5)