Advertisement
Guest User

Untitled

a guest
Dec 12th, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 10.68 KB | None | 0 0
  1. local A, C, L = select(2, ...):unpack()
  2. local TotemPlugin = CreateFrame("Frame")
  3. local DataBars = A["DataBars"]
  4. local Panels = A["Panels"]
  5.  
  6. -- Lib Globals
  7. local select = select
  8. local unpack = unpack
  9. local format = format
  10.  
  11. -- WoW Globals
  12. local GetSpellInfo = GetSpellInfo
  13.  
  14. -- Locals
  15. local Class = select(2, UnitClass("player"))
  16.  
  17. function TotemPlugin:GetWaterTotems(Name)
  18.     if (Name == "Mana Spring Totem") then
  19.         local _, _, Icon = GetSpellInfo(10497) -- Mana Spring Totem
  20.        
  21.         if (Icon) then
  22.             self.WaterTotems.Icon:SetTexture(Icon)
  23.             self.WaterTotems:Show()
  24.         else
  25.             self.WaterTotems:Hide()
  26.         end
  27.     end
  28.    
  29.     if (Name == "Healing Stream Totem") then
  30.         local _, _, Icon = GetSpellInfo(10463) -- Healing Stream Totem
  31.        
  32.         if (Icon) then
  33.             self.WaterTotems.Icon:SetTexture(WaterIcon)
  34.             self.WaterTotems:Show()
  35.         else
  36.             self.WaterTotems:Hide()
  37.         end
  38.     end
  39.    
  40.     if (Name == "Mana Tide Totem") then
  41.         local _, _, Icon = GetSpellInfo(16190) -- Mana Tide Totem
  42.        
  43.         if (Icon) then
  44.             self.WaterTotems.Icon:SetTexture(Icon)
  45.             self.WaterTotems:Show()
  46.         else
  47.             self.WaterTotems:Hide()
  48.         end
  49.     end
  50.    
  51.     if (Name == "Poison Cleansing Totem") then
  52.         local _, _, Icon = GetSpellInfo(8166) -- Poison Cleansing Totem
  53.        
  54.         if (Icon) then
  55.             self.WaterTotems.Icon:SetTexture(Icon)
  56.             self.WaterTotems:Show()
  57.         else
  58.             self.WaterTotems:Hide()
  59.         end
  60.     end
  61.    
  62.     if (Name == "Disease Cleansing Totem") then
  63.         local _, _, Icon = GetSpellInfo(8170) -- Disease Cleansing Totem
  64.  
  65.         if (Icon) then
  66.             self.WaterTotems.Icon:SetTexture(Icon)
  67.             self.WaterTotems:Show()
  68.         else
  69.             self.WaterTotems:Hide()
  70.         end
  71.     end
  72.    
  73.     if (Name == "Fire Resistance Totem") then
  74.         local _, _, Icon = GetSpellInfo(10538) -- Fire Resistance Totem
  75.        
  76.         if (Icon) then
  77.             self.WaterTotems.Icon:SetTexture(Icon)
  78.             self.WaterTotems:Show()
  79.         else
  80.             self.WaterTotems:Hide()
  81.         end
  82.     end
  83. end
  84.  
  85. function TotemPlugin:GetAirTotems(Name)
  86.     if (Name == "Windfury Totem") then
  87.         local _, _, Icon = GetSpellInfo(10614) -- Windfury Totem
  88.        
  89.         if (Icon) then
  90.             self.AirTotems.Icon:SetTexture(Icon)
  91.             self.AirTotems:Show()
  92.         else
  93.             self.AirTotems:Hide()
  94.         end
  95.     end
  96.    
  97.     if (Name == "Grounding Totem") then
  98.         local _, _, Icon = GetSpellInfo(8177) -- Grounding Totem
  99.        
  100.         if (Icon) then
  101.             self.AirTotems.Icon:SetTexture(Icon)
  102.             self.AirTotems:Show()
  103.         else
  104.             self.AirTotems:Hide()
  105.         end
  106.     end
  107.    
  108.     if (Name == "Grace of Air Totem") then
  109.         local _, _, Icon = GetSpellInfo(10627) -- Grace of Air Totem
  110.        
  111.         if (Icon) then
  112.             self.AirTotems.Icon:SetTexture(Icon)
  113.             self.AirTotems:Show()
  114.         else
  115.             self.AirTotems:Hide()
  116.         end
  117.     end
  118.    
  119.     if (Name == "Tranquil Air Totem") then
  120.         local _, _, Icon = GetSpellInfo(25908) -- Tranquil Air Totem
  121.        
  122.         if (Icon) then
  123.             self.AirTotems.Icon:SetTexture(Icon)
  124.             self.AirTotems:Show()
  125.         else
  126.             self.AirTotems:Hide()
  127.         end
  128.     end
  129.    
  130.     if (Name == "Nature Resistance Totem") then
  131.         local _, _, Icon = GetSpellInfo(10601) -- Nature Resistance Totem
  132.        
  133.         if (Icon) then
  134.             self.AirTotems.Icon:SetTexture(Icon)
  135.             self.AirTotems:Show()
  136.         else
  137.             self.AirTotems:Hide()
  138.         end
  139.     end
  140. end
  141.  
  142. function TotemPlugin:GetEarthTotems(Name)
  143.     if (Name == "Tremor Totem") then
  144.         local _, _, Icon = GetSpellInfo(8143) -- Tremor Totem
  145.        
  146.         if (Icon) then
  147.             self.EarthTotems.Icon:SetTexture(Icon)
  148.             self.EarthTotems:Show()
  149.         else
  150.             self.EarthTotems:Hide()
  151.         end
  152.     end
  153.    
  154.     if (Name == "Strength of Earth Totem") then
  155.         local _, _, Icon = GetSpellInfo(10442) -- Strength of Earth Totem
  156.        
  157.         if (Icon) then
  158.             self.EarthTotems.Icon:SetTexture(Icon)
  159.             self.EarthTotems:Show()
  160.         else
  161.             self.EarthTotems:Hide()
  162.         end
  163.     end
  164.    
  165.     if (Name == "Stoneskin Totem") then
  166.         local _, _, Icon = GetSpellInfo(10408) -- Stoneskin Totem
  167.        
  168.         if (Icon) then
  169.             self.EarthTotems.Icon:SetTexture(Icon)
  170.             self.EarthTotems:Show()
  171.         else
  172.             self.EarthTotems:Hide()
  173.         end
  174.     end
  175.    
  176.     if (Name == "Earthbind Totems") then
  177.         local _, _, Icon = GetSpellInfo(2484) -- Earthbind Totems
  178.        
  179.         if (Icon) then
  180.             self.EarthTotems.Icon:SetTexture(Icon)
  181.             self.EarthTotems:Show()
  182.         else
  183.             self.EarthTotems:Hide()
  184.         end
  185.     end
  186.    
  187.     if (Name == "Stoneclaw Totem") then
  188.         local _, _, Icon = GetSpellInfo(10428) -- Stoneclaw Totem
  189.        
  190.         if (Icon) then
  191.             self.EarthTotems.Icon:SetTexture(Icon)
  192.             self.EarthTotems:Show()
  193.         else
  194.             self.EarthTotems:Hide()
  195.         end
  196.     end
  197. end
  198.  
  199. function TotemPlugin:GetFireTotems(Name)
  200.     if (Name == "Searing Totem") then
  201.         local _, _, Icon = GetSpellInfo(10438) -- Searing Totem
  202.        
  203.         if (Icon) then
  204.             self.FireTotems.Icon:SetTexture(Icon)
  205.             self.FireTotems:Show()
  206.         else
  207.             self.FireTotems:Hide()
  208.         end
  209.     end
  210.    
  211.     if (Name == "Magma Totem") then
  212.         local _, _, Icon = GetSpellInfo(10587) -- Magma Totem
  213.        
  214.         if (Icon) then
  215.             self.FireTotems.Icon:SetTexture(Icon)
  216.             self.FireTotems:Show()
  217.         else
  218.             self.FireTotems:Hide()
  219.         end
  220.     end
  221.    
  222.     if (Name == "Fire Nova Totem") then
  223.         local _, _, Icon = GetSpellInfo(11315) -- Fire Nova Totem
  224.        
  225.         if (Icon) then
  226.             self.FireTotems.Icon:SetTexture(Icon)
  227.             self.FireTotems:Show()
  228.         else
  229.             self.FireTotems:Hide()
  230.         end
  231.     end
  232.    
  233.     if (Name == "Flametongue Totem") then
  234.         local _, _, Icon = GetSpellInfo(16387) -- Earthbind Totems
  235.        
  236.         if (Icon) then
  237.             self.FireTotems.Icon:SetTexture(Icon)
  238.             self.FireTotems:Show()
  239.         else
  240.             self.FireTotems:Hide()
  241.         end
  242.     end
  243.    
  244.     if (Name == "Frost Resistance Totem") then
  245.         local _, _, Icon = GetSpellInfo(10479) -- Frost Resistance Totem
  246.        
  247.         if (Icon) then
  248.             self.FireTotems.Icon:SetTexture(Icon)
  249.             self.FireTotems:Show()
  250.         else
  251.             self.FireTotems:Hide()
  252.         end
  253.     end
  254. end
  255.  
  256. function TotemPlugin:OnEvent(event, unit, _, SpellID)
  257.     local Name, Rank, Icon, _, _, _, ID = GetSpellInfo(SpellID)
  258.  
  259.     if (unit == "player") then
  260.         self:GetWaterTotems(Name)
  261.         self:GetAirTotems(Name)
  262.         self:GetEarthTotems(Name)
  263.         self:GetFireTotems(Name)
  264.     end
  265. end
  266.  
  267. function TotemPlugin:Create()
  268.     local Bar = CreateFrame("Frame", "Aftermathh_TotemFrame", UIParent)
  269.     Bar:Size(220, 12)
  270.     Bar:Point("TOP", Panels.ActionBarPanelMiddle, 0, 48)
  271.    
  272.     -- WATER TOTEMS
  273.     local WaterTotems = CreateFrame("Frame", "Aftermathh_WaterTotemsFrame", UIParent)
  274.     WaterTotems:Size(38, 38)
  275.     WaterTotems:Point("CENTER", Bar, -22, 0)
  276.     WaterTotems:Hide()
  277.    
  278.     WaterTotems.Icon = WaterTotems:CreateTexture(nil, "OVERLAY")
  279.     WaterTotems.Icon:SetInside()
  280.     WaterTotems.Icon:SetTexCoord(unpack(A.TexCoords))
  281.     WaterTotems.Icon:SetSnapToPixelGrid(false)
  282.     WaterTotems.Icon:SetTexelSnappingBias(0)
  283.    
  284.     WaterTotems.OverlayFrameIcon = CreateFrame("Frame", nil, WaterTotems)
  285.     WaterTotems.OverlayFrameIcon:SetFrameLevel(WaterTotems:GetFrameLevel() + 5)
  286.     WaterTotems.OverlayFrameIcon:SetInside(WaterTotems.Icon)
  287.     WaterTotems.OverlayFrameIcon:SetTemplate()
  288.     WaterTotems.OverlayFrameIcon:CreateShadow()
  289.     WaterTotems.OverlayFrameIcon:SetShadowOverlay()
  290.    
  291.     WaterTotems.Cooldown = CreateFrame("Cooldown", nil, WaterTotems, "CooldownFrameTemplate")
  292.     WaterTotems.Cooldown:SetInside()
  293.     WaterTotems.Cooldown:SetReverse(true)
  294.     WaterTotems.Cooldown:SetDrawBling(false)
  295.    
  296.     if (WaterTotems.Cooldown) then
  297.         A:RegisterCooldowns(WaterTotems.Cooldown)
  298.     end
  299.    
  300.     -- AIR TOTEMS  
  301.     local AirTotems = CreateFrame("Frame", "Aftermathh_AirTotemsFrame", UIParent)
  302.     AirTotems:Size(38, 38)
  303.     AirTotems:Point("CENTER", Bar, 22*3, 0)
  304.     AirTotems:Hide()
  305.    
  306.     AirTotems.Icon = AirTotems:CreateTexture(nil, "OVERLAY")
  307.     AirTotems.Icon:SetInside()
  308.     AirTotems.Icon:SetTexCoord(unpack(A.TexCoords))
  309.     AirTotems.Icon:SetSnapToPixelGrid(false)
  310.     AirTotems.Icon:SetTexelSnappingBias(0)
  311.  
  312.     AirTotems.OverlayFrameIcon = CreateFrame("Frame", nil, AirTotems)
  313.     AirTotems.OverlayFrameIcon:SetFrameLevel(AirTotems:GetFrameLevel() + 5)
  314.     AirTotems.OverlayFrameIcon:SetInside(AirTotems.Icon)
  315.     AirTotems.OverlayFrameIcon:SetTemplate()
  316.     AirTotems.OverlayFrameIcon:CreateShadow()
  317.     AirTotems.OverlayFrameIcon:SetShadowOverlay()
  318.    
  319.     AirTotems.Cooldown = CreateFrame("Cooldown", nil, AirTotems, "CooldownFrameTemplate")
  320.     AirTotems.Cooldown:SetInside()
  321.     AirTotems.Cooldown:SetReverse(true)
  322.     AirTotems.Cooldown:SetDrawBling(false)
  323.    
  324.     if (AirTotems.Cooldown) then
  325.         A:RegisterCooldowns(AirTotems.Cooldown)
  326.     end
  327.    
  328.     -- EARTH TOTEMS
  329.     local EarthTotems = CreateFrame("Frame", "Aftermathh_EarthTotemsFrame", UIParent)
  330.     EarthTotems:Size(38, 38)
  331.     EarthTotems:Point("CENTER", Bar, 22, 0)
  332.     EarthTotems:Hide()
  333.    
  334.     EarthTotems.Icon = EarthTotems:CreateTexture(nil, "OVERLAY")
  335.     EarthTotems.Icon:SetInside()
  336.     EarthTotems.Icon:SetTexCoord(unpack(A.TexCoords))
  337.     EarthTotems.Icon:SetSnapToPixelGrid(false)
  338.     EarthTotems.Icon:SetTexelSnappingBias(0)
  339.    
  340.     EarthTotems.OverlayFrameIcon = CreateFrame("Frame", nil, EarthTotems)
  341.     EarthTotems.OverlayFrameIcon:SetFrameLevel(EarthTotems:GetFrameLevel() + 5)
  342.     EarthTotems.OverlayFrameIcon:SetInside(EarthTotems.Icon)
  343.     EarthTotems.OverlayFrameIcon:SetTemplate()
  344.     EarthTotems.OverlayFrameIcon:CreateShadow()
  345.     EarthTotems.OverlayFrameIcon:SetShadowOverlay()
  346.    
  347.     EarthTotems.Cooldown = CreateFrame("Cooldown", nil, EarthTotems, "CooldownFrameTemplate")
  348.     EarthTotems.Cooldown:SetInside()
  349.     EarthTotems.Cooldown:SetReverse(true)
  350.     EarthTotems.Cooldown:SetDrawBling(false)
  351.    
  352.     if (EarthTotems.Cooldown) then
  353.         A:RegisterCooldowns(EarthTotems.Cooldown)
  354.     end
  355.    
  356.     -- FIRE TOTEMS
  357.    
  358.     local FireTotems = CreateFrame("Frame", "Aftermathh_FireTotemsFrame", UIParent)
  359.     FireTotems:Size(38, 38)
  360.     FireTotems:Point("CENTER", Bar, -22*3, 0)
  361.     FireTotems:Hide()
  362.    
  363.     FireTotems.Icon = FireTotems:CreateTexture(nil, "OVERLAY")
  364.     FireTotems.Icon:SetInside()
  365.     FireTotems.Icon:SetTexCoord(unpack(A.TexCoords))
  366.     FireTotems.Icon:SetSnapToPixelGrid(false)
  367.     FireTotems.Icon:SetTexelSnappingBias(0)
  368.    
  369.     FireTotems.OverlayFrameIcon = CreateFrame("Frame", nil, FireTotems)
  370.     FireTotems.OverlayFrameIcon:SetFrameLevel(FireTotems:GetFrameLevel() + 5)
  371.     FireTotems.OverlayFrameIcon:SetInside(FireTotems.Icon)
  372.     FireTotems.OverlayFrameIcon:SetTemplate()
  373.     FireTotems.OverlayFrameIcon:CreateShadow()
  374.     FireTotems.OverlayFrameIcon:SetShadowOverlay()
  375.    
  376.     FireTotems.Cooldown = CreateFrame("Cooldown", nil, FireTotems, "CooldownFrameTemplate")
  377.     FireTotems.Cooldown:SetInside()
  378.     FireTotems.Cooldown:SetReverse(true)
  379.     FireTotems.Cooldown:SetDrawBling(false)
  380.    
  381.     if (FireTotems.Cooldown) then
  382.         A:RegisterCooldowns(FireTotems.Cooldown)
  383.     end
  384.    
  385.     -- ON EVENT
  386.    
  387.     self:RegisterEvent("PLAYER_ENTERING_WORLD")
  388.     self:RegisterEvent("PLAYER_TOTEM_UPDATE")
  389.     self:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED")
  390.     self:RegisterEvent("UNIT_AURA")
  391.     self:SetScript("OnEvent", self.OnEvent)
  392.    
  393.     self.WaterTotems = WaterTotems
  394.     self.AirTotems = AirTotems
  395.     self.EarthTotems = EarthTotems
  396.     self.FireTotems = FireTotems
  397. end
  398.  
  399. function TotemPlugin:Enable()
  400.     if (Class ~= "SHAMAN") then
  401.         return
  402.     end
  403.  
  404.     TotemPlugin:Create()
  405. end
  406.  
  407. DataBars.TotemPlugin = TotemPlugin
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement