Thread: Time to die
View Single Post
08-21-21, 11:24 AM   #1
Billtopia
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Apr 2009
Posts: 110
Time to die

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:
  1. -- CombatStartTime is set on event elsewhere
  2. local FullHP = UnitHealtMax("target")
  3. local CurrentHP = UnitHealth("target")
  4. local LostHP = FullHP - CurrentHP
  5. local TimeSpent = (Time - CombatStartTime > 1) and (Time - CombatStartTime) or 1
  6. local DPS = LostHP / TimeSpent > 0.1 and LostHP / TimeSpent or 0.1
  7. local FullTimeToKill = FullHP / DPS
  8. local RemainingTimeToKill = math.floor((FullTimeToKill - TimeSpent) + 0.5)
  Reply With Quote