-- Will not cast HoT on unit if the buff still has X seconds left ONEHITWONDER_HOT_TIME_PREVENTION = 2; ONEHITWONDER_HOT_SPELLS = { [ONEHITWONDER_SPELL_RENEW_NAME] = 15, [ONEHITWONDER_SPELL_REJUVENATION_NAME] = 12, -- ADD MORE! }; OneHitWonder_HoTList = { }; function OneHitWonder_ShouldHoTUnit(unit, spellName, hotDuration) local name = UnitName(unit); if ( not OneHitWonder_HoTList[name] ) then return true; elseif ( not OneHitWonder_HoTList[name][spellName] ) then return true; else if ( OneHitWonder_HasUnitEffect(unit, nil, spellName) ) then local curTime = GetTime(); if ( ( curTime - OneHitWonder_HoTList[name][spellName] ) > (hotDuration-ONEHITWONDER_HOT_TIME_PREVENTION) ) then return true; else return false; end else return true; end end end -- returns true if a spell was cast, otherwise false function OneHitWonder_HoTUnit(unit) if ( UnitCanAttack(unit, "player") ) then unit = "player"; --return false; end if ( UnitIsUnit(unit, "player") ) then unit = "player"; end local chosenSpell = nil; local chosenDuration = 0; for k, v in ONEHITWONDER_HOT_SPELLS do if ( OneHitWonder_GetSpellId(k) > -1 ) and ( OneHitWonder_ShouldHoTUnit(unit, k, v) ) then chosenSpell = k; chosenDuration = v; break; end end if ( chosenSpell ) then local spellId = OneHitWonder_GetAppropriateSpell(UnitLevel(unit), chosenSpell); if ( not UnitCanAttack("target", "player") ) then if ( unit == "player" ) then local actionId = OneHitWonder_GetActionIdFromSpellId(spellId); if ( actionId ) and ( actionId > -1 ) then UseAction(actionId, 0, 1); return true; end end return false; end if ( OneHitWonder_CastSpell(spellId) ) then SpellTargetUnit(unit); local name = UnitName(unit); if ( not OneHitWonder_HoTList[unit] ) then OneHitWonder_HoTList[unit] = {}; end OneHitWonder_HoTList[unit][chosenSpell] = GetTime(); end end return false; end OneHitWonder_HoTTimeList = { "player", "party1", "party2", "party3", "party4" }; OneHitWonder_PreEmptiveCandidates = { ONEHITWONDER_CLASS_WARRIOR, ONEHITWONDER_CLASS_PALADIN }; function OneHitWonder_PreEmptiveHoTCandidate(unit) if ( unit == "target" ) or (OneHitWonder_IsStringInList(UnitClass(unit), OneHitWonder_PreEmptiveCandidates)) then return true; else return false; end end function OneHitWonder_HoTTime() local loops = 0; local currentEntry = nil; local hasCast = OneHitWonder_HoTUnit("target"); while ( not hasCast ) and ( loops < table.getn(OneHitWonder_HoTTimeList) ) do currentEntry = table.remove(OneHitWonder_HoTTimeList); table.insert(OneHitWonder_HoTTimeList, currentEntry); if ( UnitHealth(unit) < UnitHealthMax(unit) ) or ( OneHitWonder_PreEmptiveHoTCandidate(unit) ) then hasCast = OneHitWonder_HoTUnit(currentEntry); end loops = loops + 1; end return hasCast; end