Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.42 KB | None | 0 0
  1. local dsTarget, engClass;
  2.  
  3. local function getMacroID(spellName)
  4.     for i = 1, MAX_ACCOUNT_MACROS + MAX_CHARACTER_MACROS do
  5.         if GetMacroSpell(i) == spellName then
  6.             return i;
  7.         end
  8.     end
  9. end
  10.  
  11. local function eventHandler(self, event, ...)
  12.     if event == "COMBAT_LOG_EVENT_UNFILTERED" then
  13.         if engClass == "DEATHKNIGHT" then
  14.             local _, logEvent, _, _, srcName, _, _, _, destName, _, _, spellID, spellName = select(1, ...);
  15.             if logEvent == "SPELL_AURA_APPLIED" and srcName == UnitName("player") and spellName == "Dark Simulacrum" then
  16.                 dsTarget = destName;
  17.             elseif srcName and srcName == dsTarget and (logEvent == "SPELL_CAST_SUCCESS" or logEvent == "SPELL_MISSED" or logEvent == "SPELL_AURA_APPLIED") then
  18.                 if GetSpellPowerCost(spellID)[1].type == 0 then  -- Mana cost
  19.                     SetMacroSpell(getMacroID("Dark Simulacrum"), spellName);
  20.                     dsTarget = nil;
  21.                 end
  22.             elseif logEvent == "SPELL_AURA_REMOVED" and srcName == UnitName("player") and destName == UnitName("player") and spellName == "Dark Simulacrum" then
  23.                 SetMacroSpell(getMacroID("Dark Simulacrum"), spellName);
  24.                 dsTarget = nil;
  25.             end
  26.         end
  27.     elseif event == "ADDON_LOADED" and select(1, ...) == "DarkSimulacrumMacroTooltip" then
  28.         _, engClass = UnitClass("player");
  29.     end
  30. end
  31.  
  32. local frame = CreateFrame("Frame");
  33. frame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED");
  34. frame:RegisterEvent("ADDON_LOADED");
  35. frame:SetScript("OnEvent", eventHandler);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement