Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 8.68 KB | None | 0 0
  1. ------------------------------------------------------
  2. -- Spell Reminder
  3. ------------------------------------------------------
  4.  
  5. local E, C, L = unpack(select(2, ...)) -- Import Functions/Constants, Config, Locales
  6.  
  7. if C["buffreminder"].enable ~= true then return end
  8. --[[
  9.     Arguments
  10.    
  11.     spells - List of spells in a group, if you have anyone of these spells the icon will hide.
  12.     negate_spells - List of spells in a group, if you have anyone of these spells the icon will immediately hide and stop running the spell check (these should be other peoples spells)
  13.     combat - you must be in combat for it to display
  14.     role - you must be a certain role for it to display (Tank, Melee, Caster)
  15.     tree - you must be active in a specific talent tree for it to display (1, 2, 3) note: tree order can be viewed from left to right when you open your talent pane
  16.     instance - you must be in an instance for it to display, note: if you have combat checked and this option checked then the combat check will only run when your inside a party/raid instance
  17.     pvp - you must be in a pvp area for it to display (bg/arena), note: if you have combat checked and this option checked then the combat check will only run when your inside a bg/arena instance
  18.     reversecheck - only works if you provide a role or a tree, instead of hiding the frame when you have the buff, it shows the frame when you have the buff.
  19.     negate_reversecheck - if reversecheck is set you can set a talent tree to not follow the reverse check
  20.    
  21.     for every group created a new frame is created, it's a lot easier this way
  22. ]]
  23.  
  24. E.ReminderBuffs = {
  25.     PRIEST = {
  26.         [1] = { --inner fire/will group
  27.             ["spells"] = {
  28.                 588, -- inner fire
  29.                 73413, -- inner will           
  30.             },
  31.             ["combat"] = true,
  32.         },
  33.     },
  34.     HUNTER = {
  35.         [1] = { --aspects group
  36.             ["spells"] = {
  37.                 13165, -- hawk
  38.                 5118, -- cheetah
  39.                 13159, -- pack
  40.                 20043, -- wild
  41.                 82661, -- fox  
  42.             },
  43.             ["combat"] = true,
  44.         },             
  45.     },
  46.     MAGE = {
  47.         [1] = { --armors group
  48.             ["spells"] = {
  49.                 7302, -- frost armor
  50.                 6117, -- mage armor
  51.                 30482, -- molten armor     
  52.             },
  53.             ["combat"] = true,
  54.         },     
  55.     },
  56.     WARLOCK = {
  57.         [1] = { --armors group
  58.             ["spells"] = {
  59.                 28176, -- fel armor
  60.                 687, -- demon armor        
  61.             },
  62.             ["combat"] = true,
  63.         },
  64.     },
  65.     PALADIN = {
  66.         [1] = { --Seals group
  67.             ["spells"] = {
  68.                 20154, -- seal of righteousness
  69.                 20164, -- seal of justice
  70.                 20165, -- seal of insight
  71.                 31801, -- seal of truth            
  72.             },
  73.             ["combat"] = true,
  74.         },
  75.         [2] = { -- righteous fury group
  76.             ["spells"] = {
  77.                 25780,
  78.             },
  79.             ["role"] = "Tank",
  80.             ["instance"] = true,
  81.             ["reversecheck"] = true,
  82.             ["negate_reversecheck"] = 1, --Holy paladins use RF sometimes
  83.         },
  84.     },
  85.     SHAMAN = {
  86.         [1] = { --shields group
  87.             ["spells"] = {
  88.                 52127, -- water shield
  89.                 324, -- lightning shield           
  90.             },
  91.             ["combat"] = true,
  92.             ["instance"] = true,
  93.         },
  94.     },
  95.     WARRIOR = {
  96.         [1] = { -- commanding Shout group
  97.             ["spells"] = {
  98.                 469,
  99.             },
  100.             ["negate_spells"] = {
  101.                 6307, -- Blood Pact
  102.                 90364, -- Qiraji Fortitude
  103.                 72590, -- Drums of fortitude
  104.                 21562, -- Fortitude            
  105.             },
  106.             ["combat"] = true,
  107.             ["role"] = "Tank",
  108.         },
  109.         [2] = { -- battle Shout group
  110.             ["spells"] = {
  111.                 6673,
  112.             },
  113.             ["negate_spells"] = {
  114.                 8076, -- strength of earth
  115.                 57330, -- horn of Winter
  116.                 93435, -- roar of courage (hunter pet)                     
  117.             },
  118.             ["combat"] = true,
  119.             ["role"] = "Melee",
  120.         },
  121.     },
  122.     DEATHKNIGHT = {
  123.         [1] = { -- horn of Winter group
  124.             ["spells"] = {
  125.                 57330,
  126.             },
  127.             ["negate_spells"] = {
  128.                 8076, -- strength of earth totem
  129.                 6673, -- battle Shout
  130.                 93435, -- roar of courage (hunter pet)         
  131.             },
  132.             ["combat"] = true,
  133.             ["instance"] = true,
  134.         },
  135.         [2] = { -- blood presence group
  136.             ["spells"] = {
  137.                 48263,
  138.             },
  139.             ["role"] = "Tank",
  140.             ["instance"] = true,   
  141.             ["reversecheck"] = true,
  142.         },
  143.     }, 
  144. }
  145.  
  146. local tab = E.ReminderBuffs[E.myclass]
  147. if not tab then return end
  148.  
  149. local sound
  150. local function OnEvent(self, event, arg1)
  151.     local group = tab[self.id]
  152.     if not group.spells then return end
  153.     if not GetActiveTalentGroup() then return end
  154.     if event == "UNIT_AURA" and arg1 ~= "player" then return end
  155.    
  156.     self:Hide()
  157.    
  158.     if group.negate_spells then
  159.         for _, buff in pairs(group.negate_spells) do
  160.             local name = GetSpellInfo(buff)
  161.             if (name and UnitBuff("player", name)) then
  162.                 sound = true
  163.                 return
  164.             end
  165.         end
  166.     end
  167.    
  168.     for _, buff in pairs(group.spells) do
  169.         local name = GetSpellInfo(buff)
  170.         local usable, nomana = IsUsableSpell(name)
  171.         if (usable or nomana) then
  172.             self.icon:SetTexture(select(3, GetSpellInfo(buff)))
  173.             break
  174.         end        
  175.     end
  176.    
  177.     if (not self.icon:GetTexture() and event == "PLAYER_LOGIN") then
  178.         self:UnregisterAllEvents()
  179.         self:RegisterEvent("LEARNED_SPELL_IN_TAB")
  180.         return
  181.     elseif (self.icon:GetTexture() and event == "LEARNED_SPELL_IN_TAB") then
  182.         self:UnregisterAllEvents()
  183.         self:RegisterEvent("UNIT_AURA")
  184.         self:RegisterEvent("PLAYER_LOGIN")
  185.         self:RegisterEvent("PLAYER_REGEN_ENABLED")
  186.         self:RegisterEvent("PLAYER_REGEN_DISABLED")
  187.         self:RegisterEvent("ZONE_CHANGED_NEW_AREA")
  188.         self:RegisterEvent("UNIT_INVENTORY_CHANGED")
  189.     end    
  190.    
  191.     local role = group.role
  192.     local tree = group.tree
  193.     local combat = group.combat
  194.     local instance = group.instance
  195.     local pvp = group.pvp  
  196.     local reversecheck = group.reversecheck
  197.     local negate_reversecheck = group.negate_reversecheck
  198.     local canplaysound = false
  199.     local rolepass = false
  200.     local treepass = false
  201.     local combatpass = false
  202.     local inInstance, instanceType = IsInInstance()
  203.    
  204.     if role ~= nil then
  205.         if role == E.Role then
  206.             rolepass = true
  207.         else
  208.             rolepass = false
  209.         end
  210.     else
  211.         rolepass = true
  212.     end
  213.    
  214.     if tree ~= nil then
  215.         if tree == GetPrimaryTalentTree() then
  216.             treepass = true
  217.         else
  218.             treepass = false   
  219.         end
  220.     else
  221.         treepass = true
  222.     end
  223.    
  224.     if (instance ~= nil or pvp ~= nil) and combat then
  225.         if instance then
  226.             if instanceType == "party" or instanceType == "raid" then
  227.                 combatpass = true
  228.             else
  229.                 combatpass = false
  230.             end
  231.         elseif pvp then
  232.             if instanceType == "arena" or instanceType == "pvp" then
  233.                 combatpass = true
  234.             else
  235.                 combatpass = false
  236.             end    
  237.         end
  238.     else
  239.         combatpass = true
  240.     end
  241.    
  242.     if reversecheck ~= nil and (role == nil and tree == nil) then reversecheck = nil end
  243.    
  244.     if event == "ZONE_CHANGED_NEW_AREA" or (instance == nil and combat == true) then
  245.         canplaysound = true
  246.     end
  247.    
  248.     if ((combat and UnitAffectingCombat("player")) or (instance and (instanceType == "party" or instanceType == "raid")) or (pvp and (instanceType == "arena" or instanceType == "pvp"))) and
  249.     combatpass == true and treepass == true and rolepass == true and not (UnitInVehicle("player") and self.icon:GetTexture()) then
  250.         for _, buff in pairs(group.spells) do
  251.             local name = GetSpellInfo(buff)
  252.             if (name and UnitBuff("player", name)) then
  253.                 self:Hide()
  254.                 sound = true
  255.                 return
  256.             end
  257.         end
  258.         self:Show()
  259.         if C["buffreminder"].sound == true and sound == true and canplaysound == true then
  260.             PlaySoundFile(C["media"].warning)
  261.             sound = false
  262.         end    
  263.     elseif ((combat and UnitAffectingCombat("player")) or (instance and (instanceType == "party" or instanceType == "raid")) or (pvp and (instanceType == "arena" or instanceType == "pvp"))) and
  264.     combatpass == true and reversecheck == true and not (UnitInVehicle("player") and self.icon:GetTexture()) then
  265.         if negate_reversecheck and negate_reversecheck == GetPrimaryTalentTree() then self:Hide() sound = true return end
  266.         for _, buff in pairs(group.spells) do
  267.             local name = GetSpellInfo(buff)
  268.             if (name and UnitBuff("player", name)) then
  269.                 self:Show()
  270.                 if C["buffreminder"].sound == true and canplaysound == true then PlaySoundFile(C["media"].warning) end
  271.                 return
  272.             end        
  273.         end        
  274.     else
  275.         self:Hide()
  276.         sound = true
  277.     end
  278. end
  279.  
  280. for i=1, #tab do
  281.     local frame = CreateFrame("Frame", "ReminderFrame"..i, UIParent)
  282.     frame:CreatePanel("Default", E.Scale(40), E.Scale(40), "CENTER", UIParent, "CENTER", 0, E.Scale(200))
  283.     frame:SetFrameLevel(1)
  284.     frame.id = i
  285.     frame.icon = frame:CreateTexture(nil, "OVERLAY")
  286.     frame.icon:SetTexCoord(0.1, 0.9, 0.1, 0.9)
  287.     frame.icon:SetPoint("CENTER")
  288.     frame.icon:SetWidth(E.Scale(36))
  289.     frame.icon:SetHeight(E.Scale(36))
  290.     frame:Hide()
  291.  
  292.     frame:RegisterEvent("UNIT_AURA")
  293.     frame:RegisterEvent("PLAYER_LOGIN")
  294.     frame:RegisterEvent("PLAYER_REGEN_ENABLED")
  295.     frame:RegisterEvent("PLAYER_REGEN_DISABLED")
  296.     frame:RegisterEvent("ZONE_CHANGED_NEW_AREA")
  297.     frame:RegisterEvent("UNIT_ENTERING_VEHICLE")
  298.     frame:RegisterEvent("UNIT_ENTERED_VEHICLE")
  299.     frame:RegisterEvent("UNIT_EXITING_VEHICLE")
  300.     frame:RegisterEvent("UNIT_EXITED_VEHICLE")
  301.     frame:SetScript("OnEvent", OnEvent)
  302. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement