Quantcast
WoWInterface - View Single Post - Event for switching talents?
View Single Post
08-07-17, 09:43 AM   #1
Galaxy119
A Flamescale Wyrmkin
 
Galaxy119's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2014
Posts: 111
Event for switching talents?

Sorry if this has been asked before but I couldn't find an answer, is there an event that fires when players select a talent?
The reason for needing this is for the rogue level 45 talents, Deeper stratagem and Anticipation, I have it where it correctly displays the proper amount of combo points for each talent choice in this tier, however you have to /reload upon logging in or changing the talent selection for the combo point bar to be affected by the change.

Lua Code:
  1. local parent, ns = ...
  2. local oUF = ns.oUF or oUF
  3.  
  4. local GetComboPoints = GetComboPoints
  5. if (select(2, GetTalentTierInfo(3,1))) == 1 then
  6.     MAX_COMBO_POINTS = 6
  7. elseif (select(2, GetTalentTierInfo(3,1))) == 2 then
  8.     MAX_COMBO_POINTS = 10
  9. else
  10.     MAX_COMBO_POINTS = 5
  11. end
  12. local class = select(2, UnitClass("player"))
  13.  
  14. local Update = function(self, event, unit, powerType)
  15.   if unit and (unit ~= "player" and unit ~= "vehicle") then return end
  16.   if powerType and powerType ~= "COMBO_POINTS" then return end
  17.   local bar = self.ComboBar
  18.   local cp = 0
  19.   if(UnitExists("vehicle") and UnitPower("vehicle",4) >= 1) then
  20.     cp = UnitPower("vehicle",4)
  21.   else
  22.     cp = UnitPower("player",4)
  23.   end
  24.  
  25.   if cp < 1 and (UnitHasVehicleUI("player") or class ~= "ROGUE") then
  26.     bar:Hide()
  27.     return
  28.   else
  29.     bar:Show()
  30.   end
  31.  
  32.   for i=1, MAX_COMBO_POINTS do
  33.     local orb = self.ComboPoints[i]
  34.     local full = cp/MAX_COMBO_POINTS
  35.     if(i <= cp) then
  36.       if full == 1 then
  37.         orb.fill:SetVertexColor(1,0,0)
  38.         orb.glow:SetVertexColor(1,0,0)
  39.       else
  40.         orb.fill:SetVertexColor(bar.color.r,bar.color.g,bar.color.b)
  41.         orb.glow:SetVertexColor(bar.color.r,bar.color.g,bar.color.b)
  42.       end
  43.       orb.fill:Show()
  44.       orb.glow:Show()
  45.       orb.highlight:Show()
  46.     else
  47.       orb.fill:Hide()
  48.       orb.glow:Hide()
  49.       orb.highlight:Hide()
  50.     end
  51.   end
  52. end
  53.  
  54. local Path = function(self, ...)
  55.   return (self.ComboPoints.Override or Update) (self, ...)
  56. end
  57.  
  58. local ForceUpdate = function(element)
  59.   return Path(element.__owner, "ForceUpdate", element.__owner.unit, nil)
  60. end
  61.  
  62. local Enable = function(self)
  63.   local element = self.ComboPoints
  64.   if(element) then
  65.     element.__owner = self
  66.     element.ForceUpdate = ForceUpdate
  67.     self:RegisterEvent("UNIT_COMBO_POINTS", Path, true) --make this unitless, some vehicles have combo points
  68.     self:RegisterEvent("UNIT_POWER_FREQUENT", Path)
  69.     local helper = CreateFrame("Frame") --this is needed...adding player_login to the visivility events does not do anything
  70.     helper:RegisterEvent("PLAYER_ENTERING_WORLD")
  71.     helper:SetScript("OnEvent", function() Path(self) end)
  72.     return true
  73.   end
  74. end
  75.  
  76. local Disable = function(self)
  77.   local element = self.ComboPoints
  78.   if(element) then
  79.     self:UnregisterEvent("UNIT_COMBO_POINTS", Path)
  80.     self:UnregisterEvent("UNIT_POWER_FREQUENT", Path)
  81.     self:UnregisterEvent("PLAYER_ENTERING_WORLD")
  82.   end
  83. end
  84.  
  85. oUF:AddElement("ComboPoints", Path, Enable, Disable)
__________________
My Addons | "If someone says something is impossible, they either lack imagination, or lack determination."
  Reply With Quote