From d4168ca8a045bff90c6f76e5c402f56bddbf5df1 Mon Sep 17 00:00:00 2001 From: Pawel Date: Sat, 8 Oct 2016 05:31:34 +0200 Subject: [PATCH] v1.14 - 7.0 patch update, unit auta --- TDDps.lua | 13 +++++++++++++ TDDps.toc | 2 +- TDHelper.lua | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 66 insertions(+), 1 deletion(-) diff --git a/TDDps.lua b/TDDps.lua index 3888bd0..c2d3097 100644 --- a/TDDps.lua +++ b/TDDps.lua @@ -15,6 +15,10 @@ _tdError = '|cFFF0563D'; _tdSuccess = '|cFFBCCF02'; local _DPS_time = 0; +-- Globals for time to die +TDDps_TargetGuid = nil; +TD_Hp0, TD_T0, TD_Hpm, TD_Tm = nil, nil, nil, nil; + local Classes = { [1] = 'Warrior', [2] = 'Paladin', @@ -126,6 +130,15 @@ function TDDps_OnEvent(self, event) elseif event == 'PLAYER_ENTERING_WORLD' then TDButton_UpdateButtonGlow(); end + if event == 'PLAYER_TARGET_CHANGED' then + TD_Hp0, TD_T0, TD_Hpm, TD_Tm = nil, nil, nil, nil; + + if UnitExists('target') and not UnitIsFriend('player', 'target') then + TDDps_TargetGuid = UnitGUID('target'); + else + TDDps_TargetGuid = nil; + end + end if TDDps_Frame.rotationEnabled then if event == 'PLAYER_TARGET_CHANGED' then if (UnitIsFriend('player', 'target')) then diff --git a/TDDps.toc b/TDDps.toc index bd6d696..692d31c 100644 --- a/TDDps.toc +++ b/TDDps.toc @@ -1,6 +1,6 @@ ## Title: TDDps ## Notes: Rotation helper framework. -## Version: 1.13 +## Version: 1.14 ## Author: Kaminaris ## Interface: 70000 ## SavedVariables: TDDps_Options diff --git a/TDHelper.lua b/TDHelper.lua index 71cd708..cad6210 100644 --- a/TDHelper.lua +++ b/TDHelper.lua @@ -11,6 +11,8 @@ _Netherwinds = 160452; _DrumsOfFury = 178207; _Exhaustion = 57723; +local INF = 2147483647; + local _Bloodlusts = {_Bloodlust, _TimeWrap, _Heroism, _AncientHysteria, _Netherwinds, _DrumsOfFury}; ---------------------------------------------- @@ -51,6 +53,18 @@ function TD_Aura(name, timeShift) return false, 0; end +---------------------------------------------- +-- Is aura on specific unit +---------------------------------------------- +function TD_UnitAura(name, timeShift, unit) + timeShift = timeShift or 0.2; + local spellName = GetSpellInfo(name); + local _, _, _, count, _, _, expirationTime = UnitAura(unit, spellName); + if expirationTime ~= nil and (expirationTime - GetTime()) > timeShift then + return true, count; + end + return false, 0; +end ---------------------------------------------- -- Is aura on target @@ -185,6 +199,44 @@ function TD_Cooldown(spell, timeShift) end ---------------------------------------------- +-- Time to die - NOT YET WORKING +---------------------------------------------- +--TD_Hp0, TD_T0, TD_Hpm, TD_Tm +function TD_TimeToDie(health) + local unit = UnitGUID('target'); + if unit ~= TDDps_TargetGuid then + --print('phial'); + return INF; + end + + health = health or UnitHealth('target'); + + if health == UnitHealthMax('target') then + TD_Hp0, TD_T0, TD_Hpm, TD_Tm = nil, nil, nil, nil; + --print('phial2'); + return INF; + end + + local time = GetTime(); + + if not TD_Hp0 then + TD_Hp0, TD_T0 = health, time; + TD_Hpm, TD_Tm = health, time; + --print('phial3'); + return INF; + end + + TD_Hpm = (TD_Hpm + health) * .5; + TD_Tm = (TD_Tm + time) * .5; + + if TD_Hpm >= TD_Hp0 then + TD_Hp0, TD_T0, TD_Hpm, TD_Tm = nil, nil, nil, nil; + else + return health * (TD_T0 - TD_Tm) / (TD_Hpm - TD_Hp0); + end +end + +---------------------------------------------- -- Current or Future Mana Percent ---------------------------------------------- function TD_Mana(minus, timeShift) -- 1.7.9.5