Quantcast Event for switching talents? - WoWInterface
Thread Tools Display Modes
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
08-07-17, 10:23 AM   #2
syncrow
A Flamescale Wyrmkin
 
syncrow's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 149
"PLAYER_TALENT_UPDATE"
might be the event you are searching for!
__________________
  Reply With Quote
08-07-17, 10:49 AM   #3
sezz
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 100
Unit_maxpower
  Reply With Quote
08-07-17, 11:23 AM   #4
Galaxy119
A Flamescale Wyrmkin
 
Galaxy119's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2014
Posts: 111
Originally Posted by syncrow View Post
might be the event you are searching for!
Nope, that event fires when you change specs afaik
__________________
My Addons | "If someone says something is impossible, they either lack imagination, or lack determination."
  Reply With Quote
08-07-17, 11:34 AM   #5
pas06
A Wyrmkin Dreamwalker
Join Date: Apr 2009
Posts: 54
i am not sure if there is an event but /eventtrace
Code:
https://wow.gamepedia.com/Eventtrace
tells you whenever a event fires
i just tested it and PLAYER_TALENT_UPDATE, PLAYER_PVP_TALENT_UPDATE and ACTIVE_TALENT_GROUP_CHANGED fired.
PLAYER_PVP_TALENT_UPDATE fired even tho i changed a normal (non pvp) talent

Last edited by pas06 : 08-07-17 at 11:39 AM.
  Reply With Quote
08-07-17, 11:57 AM   #6
Galaxy119
A Flamescale Wyrmkin
 
Galaxy119's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2014
Posts: 111
Hm, in that case, can you look over the code I'm using and see how you would go about using PLAYER_TALENT_UPDATE to update the MAX_COMBO_POINTS variable cuz it's not working the way i've tried it
__________________
My Addons | "If someone says something is impossible, they either lack imagination, or lack determination."
  Reply With Quote
08-07-17, 12:20 PM   #7
Kakjens
A Cliff Giant
Join Date: Apr 2017
Posts: 75
Why you are not using UnitPowerMax in line 32?

Last edited by Kakjens : 08-07-17 at 12:24 PM.
  Reply With Quote
08-07-17, 01:32 PM   #8
p3lim
A Pyroguard Emberseer
 
p3lim's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,691
Why are you not using the ClassPower element that works out of the box in oUF?
If you need to do customizations to its behavior you can easily use callbacks or overrides.
  Reply With Quote
08-08-17, 12:51 AM   #9
syncrow
A Flamescale Wyrmkin
 
syncrow's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 149
try to use

Lua Code:
  1. local cp = UnitPower("Player", SPELL_POWER_COMBO_POINTS)
  2. local cpMax = UnitPowerMax("player", SPELL_POWER_COMBO_POINTS);
  3.  
  4. for i = 1, cpMax do...
__________________

Last edited by syncrow : 08-08-17 at 12:58 AM.
  Reply With Quote
08-09-17, 09:32 AM   #10
Galaxy119
A Flamescale Wyrmkin
 
Galaxy119's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2014
Posts: 111
Originally Posted by p3lim View Post
Why are you not using the ClassPower element that works out of the box in oUF?
If you need to do customization to its behavior you can easily use callbacks or overrides.
Because I'm working with an older version oUF and when I tried to implement ClassPower I failed epically because I have no idea what i'm doing with oUF itself. Most of my coding involves me reverse engineering things that work to figure out how they work so I can implement them myself.
__________________
My Addons | "If someone says something is impossible, they either lack imagination, or lack determination."
  Reply With Quote
08-09-17, 06:29 PM   #11
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,598
You should update your copy of oUF.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
08-09-17, 09:52 PM   #12
Galaxy119
A Flamescale Wyrmkin
 
Galaxy119's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2014
Posts: 111
So I thought I had already, and upon updating I realize why I thought I did and why I hadn't.

I did previously attempt to update the oUF version being used, but upon doing so I am hit with this error that pretty much completely breaks my entire oUF layout, and I could never figure out how to fix it;
Code:
Message: Interface\AddOns\Roth_UI\units\player.lua:305: attempt to compare number with nil
Time: 08/09/17 20:50:05
Count: 1
Stack: Interface\AddOns\Roth_UI\units\player.lua:305: attempt to compare number with nilInterface\SharedXML\SharedBasicControls.lua:204: in function <Interface\SharedXML\SharedBasicControls.lua:203>
[C]: ?
Interface\AddOns\Roth_UI\units\player.lua:305: in function <Interface\AddOns\Roth_UI\units\player.lua:303>
(tail call): ?
(tail call): ?
Interface\AddOns\Roth_UI\embeds\oUF\ouf.lua:198: in function <Interface\AddOns\Roth_UI\embeds\oUF\ouf.lua:187>
(tail call): ?

Locals: errorMessage = "Interface\AddOns\Roth_UI\units\player.lua:305: attempt to compare number with nil"
DisplayMessageInternal = <function> defined @Interface\SharedXML\SharedBasicControls.lua:187
MESSAGE_TYPE_ERROR = 0

The offending function (4th line down is the one that causes the error):
Lua Code:
  1. --post update orb func (used to display lowHp on percentage)
  2.   local updateValue = function(bar, unit, cur, max)
  3.     local per = 0
  4.     if max > 0 then per = floor(cur/max*100) end
  5.     local orb = bar:GetParent()
  6.     local self = orb:GetParent()
  7.     --if orb.type == "HEALTH" and  (per <= 25 and not UnitIsDeadOrGhost(unit)) then
  8.     if orb.type == "HEALTH" and  (per <= 25 or UnitIsDeadOrGhost(unit)) then
  9.       orb.lowHP:Show()
  10.     elseif orb.type == "HEALTH" then
  11.       orb.lowHP:Hide()
  12.     end
  13.     if orb.type == "HEALTH" and UnitIsDeadOrGhost(unit) then
  14.       orb.skull:Show()
  15.     elseif orb.type == "HEALTH" then
  16.       orb.skull:Hide()
  17.     end
  18.     if db.char[orb.type].value.hideOnEmpty and (UnitIsDeadOrGhost(unit) or cur < 1) then
  19.       orb.values:Hide()
  20.     elseif db.char[orb.type].value.hideOnFull and (cur == max) then
  21.       orb.values:Hide()
  22.     elseif not orb.values:IsShown() then
  23.       orb.values:Show()
  24.     end
  25.     if orb.type == "HEALTH" then
  26.       orb.values.top:SetText(oUF.Tags.Methods["diablo:HealthOrbTop"](self.unit or "player"))
  27.       orb.values.bottom:SetText(oUF.Tags.Methods["diablo:HealthOrbBottom"](self.unit or "player"))
  28.     elseif orb.type == "POWER" then
  29.       orb.values.top:SetText(oUF.Tags.Methods["diablo:PowerOrbTop"](self.unit or "player"))
  30.       orb.values.bottom:SetText(oUF.Tags.Methods["diablo:PowerOrbBottom"](self.unit or "player"))
  31.     end
  32.     if UnitIsDeadOrGhost(unit) then
  33.       bar:SetValue(0)
  34.     end
  35.     if ns.panel:IsShown() then
  36.       ns.panel.eventHelper:SetOrbsToMax()
  37.     end
  38.   end --post update orb func (used to display lowHp on percentage)
  39.   local updateValue = function(bar, unit, cur, max)
  40.     local per = 0
  41.     if max > 0 then per = floor(cur/max*100) end
  42.     local orb = bar:GetParent()
  43.     local self = orb:GetParent()
  44.     --if orb.type == "HEALTH" and  (per <= 25 and not UnitIsDeadOrGhost(unit)) then
  45.     if orb.type == "HEALTH" and  (per <= 25 or UnitIsDeadOrGhost(unit)) then
  46.       orb.lowHP:Show()
  47.     elseif orb.type == "HEALTH" then
  48.       orb.lowHP:Hide()
  49.     end
  50.     if orb.type == "HEALTH" and UnitIsDeadOrGhost(unit) then
  51.       orb.skull:Show()
  52.     elseif orb.type == "HEALTH" then
  53.       orb.skull:Hide()
  54.     end
  55.     if db.char[orb.type].value.hideOnEmpty and (UnitIsDeadOrGhost(unit) or cur < 1) then
  56.       orb.values:Hide()
  57.     elseif db.char[orb.type].value.hideOnFull and (cur == max) then
  58.       orb.values:Hide()
  59.     elseif not orb.values:IsShown() then
  60.       orb.values:Show()
  61.     end
  62.     if orb.type == "HEALTH" then
  63.       orb.values.top:SetText(oUF.Tags.Methods["diablo:HealthOrbTop"](self.unit or "player"))
  64.       orb.values.bottom:SetText(oUF.Tags.Methods["diablo:HealthOrbBottom"](self.unit or "player"))
  65.     elseif orb.type == "POWER" then
  66.       orb.values.top:SetText(oUF.Tags.Methods["diablo:PowerOrbTop"](self.unit or "player"))
  67.       orb.values.bottom:SetText(oUF.Tags.Methods["diablo:PowerOrbBottom"](self.unit or "player"))
  68.     end
  69.     if UnitIsDeadOrGhost(unit) then
  70.       bar:SetValue(0)
  71.     end
  72.     if ns.panel:IsShown() then
  73.       ns.panel.eventHelper:SetOrbsToMax()
  74.     end
  75.   end
__________________
My Addons | "If someone says something is impossible, they either lack imagination, or lack determination."
  Reply With Quote
08-09-17, 09:58 PM   #13
Galaxy119
A Flamescale Wyrmkin
 
Galaxy119's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2014
Posts: 111
It also apparently somehow breaks a vast majority of the rest of my interface if I comment the offending line out, all of my unit frames seem to break, so I need to fix that line but I'm not sure what the actual problem is, since it works fine with the older version of oUF.
(statusbars and raid icons are super misplaced and some textures aren't even loaded, but no lua errors are displayed, see image, ignore actionbars, those are from bartender cuz i was testing another bug)
__________________
My Addons | "If someone says something is impossible, they either lack imagination, or lack determination."

Last edited by Galaxy119 : 08-09-17 at 10:23 PM.
  Reply With Quote
08-09-17, 11:32 PM   #14
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 1,791
What happens add this at the top of the function?
Code:
max = max or 0
This will force max to be zero if nil is passed.
__________________
ESOUI AddOns | WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote
08-09-17, 11:59 PM   #15
Galaxy119
A Flamescale Wyrmkin
 
Galaxy119's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2014
Posts: 111
Originally Posted by SDPhantom View Post
What happens add this at the top of the function?
Code:
max = max or 0
This will force max to be zero if nil is passed.
This does solve the lua error, however the visual artifacts remain (the green statusbars on the target and target's target, aswell as no unitframe textures for the target, all unit frames have all raid icons above their head simultaneously, etc. (the stuff pictured in the screenshot)
Now I'm not entierly convinced the visual issue with the statusbars is related to this error, disabling the player's frame entierly doesn't seem to affect the issue, and removing thatline while using the older version of oUF doesn't either, so now I'm super confused.

Yay for things breaking without errors!
__________________
My Addons | "If someone says something is impossible, they either lack imagination, or lack determination."

Last edited by Galaxy119 : 08-10-17 at 12:02 AM.
  Reply With Quote
08-11-17, 04:06 PM   #16
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,286
Originally Posted by Galaxy119 View Post
It also apparently somehow breaks a vast majority of the rest of my interface if I comment the offending line out, all of my unit frames seem to break, so I need to fix that line but I'm not sure what the actual problem is, since it works fine with the older version of oUF.
(statusbars and raid icons are super misplaced and some textures aren't even loaded, but no lua errors are displayed, see image, ignore actionbars, those are from bartender cuz i was testing another bug)
Whats the name of this font?
  Reply With Quote
08-12-17, 01:09 AM   #17
Galaxy119
A Flamescale Wyrmkin
 
Galaxy119's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2014
Posts: 111
Originally Posted by Resike View Post
Whats the name of this font?
"Cracked" it's included in my UI.
Thanks for offering something useful to my problem tho.
__________________
My Addons | "If someone says something is impossible, they either lack imagination, or lack determination."
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Event for switching talents?

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off