Skip to content

Commit 75f7932

Browse files
committed
Rewrite PVP Talent Load/Trigger to use SpellIds
Instead of indexes. This breaks all existing pvp talent trigger/load options, though a lot would break anyway with the class changes of TWW. This ensures that in the future patch changes should be less likely break the load/trigger options. And improves cross-spec setups. Fixes; #4557
1 parent 001969d commit 75f7932

File tree

3 files changed

+31
-30
lines changed

3 files changed

+31
-30
lines changed

WeakAuras/Prototypes.lua

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -801,20 +801,22 @@ if WeakAuras.IsRetail() then
801801
end
802802
end
803803

804-
---@param index integer
804+
---@param spellId integer
805805
---@return boolean hasTalent
806-
---@return number? talentId
807-
function WeakAuras.CheckPvpTalentByIndex(index)
806+
---@return number? spellid
807+
function WeakAuras.CheckPvpTalentBySpellId(spellId)
808808
local checkTalentSlotInfo = C_SpecializationInfo.GetPvpTalentSlotInfo(1)
809809
if checkTalentSlotInfo then
810-
local checkTalentId = checkTalentSlotInfo.availableTalentIDs[index]
811810
for i = 1, 3 do
812811
local talentSlotInfo = C_SpecializationInfo.GetPvpTalentSlotInfo(i)
813-
if talentSlotInfo and (talentSlotInfo.selectedTalentID == checkTalentId) then
814-
return true, checkTalentId
812+
if talentSlotInfo and talentSlotInfo.selectedTalentID then
813+
local selectedSpellId = select(6, GetPvpTalentInfoByID(talentSlotInfo.selectedTalentID))
814+
if selectedSpellId == spellId then
815+
return true, spellId
816+
end
815817
end
816818
end
817-
return false, checkTalentId
819+
return false, spellId
818820
end
819821
return false
820822
end
@@ -1663,17 +1665,23 @@ Private.load_prototype = {
16631665
single_spec = GetSpecialization();
16641666
end
16651667

1666-
-- print ("Using talent cache", single_class, single_spec);
16671668
-- If a single specific class was found, load the specific list for it
1669+
if not single_class then
1670+
single_class = select(2, UnitClass("player"))
1671+
end
1672+
if not single_spec then
1673+
single_spec = GetSpecialization()
1674+
end
1675+
16681676
if(single_class and Private.pvp_talent_types_specific[single_class]
16691677
and single_spec and Private.pvp_talent_types_specific[single_class][single_spec]) then
16701678
return Private.pvp_talent_types_specific[single_class][single_spec];
16711679
else
1672-
return Private.pvp_talent_types;
1680+
return {}
16731681
end
16741682
end
16751683
end,
1676-
test = "WeakAuras.CheckPvpTalentByIndex(%d)",
1684+
test = "WeakAuras.CheckPvpTalentBySpellId(%d)",
16771685
enable = WeakAuras.IsRetail(),
16781686
hidden = not WeakAuras.IsRetail(),
16791687
events = {"PLAYER_PVP_TALENT_UPDATE"}
@@ -7135,9 +7143,9 @@ Private.event_prototypes = {
71357143
local index = %s
71367144
local activeName, activeIcon, _
71377145
7138-
local active, talentId = WeakAuras.CheckPvpTalentByIndex(index)
7139-
if talentId then
7140-
_, activeName, activeIcon = GetPvpTalentInfoByID(talentId)
7146+
local active, spellId = WeakAuras.CheckPvpTalentBySpellId(index)
7147+
if spellId then
7148+
activeName, _, activeIcon = Private.ExecEnv.GetSpellInfo(spellId)
71417149
end
71427150
]]):format(index or 0))
71437151
if (inverse) then
@@ -7158,9 +7166,9 @@ Private.event_prototypes = {
71587166
table.insert(ret, ([[
71597167
if (not active) then
71607168
local index = %s
7161-
active, talentId = WeakAuras.CheckPvpTalentByIndex(index)
7162-
if active and talentId then
7163-
_, activeName, activeIcon = GetPvpTalentInfoByID(talentId)
7169+
active, spellId = WeakAuras.CheckPvpTalentBySpellId(index)
7170+
if active and spellId then
7171+
activeName, _, activeIcon = Private.ExecEnv.GetSpellInfo(spellId)
71647172
end
71657173
end
71667174
]]):format(index))
@@ -7185,7 +7193,7 @@ Private.event_prototypes = {
71857193
if(Private.pvp_talent_types_specific[class] and Private.pvp_talent_types_specific[class][spec]) then
71867194
return Private.pvp_talent_types_specific[class][spec];
71877195
else
7188-
return Private.pvp_talent_types;
7196+
return {}
71897197
end
71907198
end,
71917199
test = "active",

WeakAuras/Types.lua

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1832,14 +1832,6 @@ else
18321832
end
18331833
end
18341834

1835-
---@type table<number, string>
1836-
Private.pvp_talent_types = {}
1837-
if WeakAuras.IsRetail() then
1838-
for i = 1,10 do
1839-
tinsert(Private.pvp_talent_types, string.format(L["PvP Talent %i"], i));
1840-
end
1841-
end
1842-
18431835
---@type table<number, string>
18441836
Private.talent_extra_option_types = {
18451837
[0] = L["Talent Known"],

WeakAuras/WeakAuras.lua

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,19 +1003,20 @@ local function CreatePvPTalentCache()
10031003
Private.pvp_talent_types_specific[player_class] = Private.pvp_talent_types_specific[player_class] or {};
10041004
Private.pvp_talent_types_specific[player_class][spec] = Private.pvp_talent_types_specific[player_class][spec] or {};
10051005

1006+
--- @type fun(talentId: number): number, string
10061007
local function formatTalent(talentId)
1007-
local _, name, icon = GetPvpTalentInfoByID(talentId);
1008-
return "|T"..icon..":0|t "..name
1008+
local _, name, icon, _, _, spellId = GetPvpTalentInfoByID(talentId);
1009+
return spellId, "|T"..icon..":0|t "..name
10091010
end
10101011

10111012
local slotInfo = C_SpecializationInfo.GetPvpTalentSlotInfo(1);
10121013
if (slotInfo) then
1013-
10141014
Private.pvp_talent_types_specific[player_class][spec] = {};
10151015

10161016
local pvpSpecTalents = slotInfo.availableTalentIDs;
1017-
for i, talentId in ipairs(pvpSpecTalents) do
1018-
Private.pvp_talent_types_specific[player_class][spec][i] = formatTalent(talentId);
1017+
for _, talentId in ipairs(pvpSpecTalents) do
1018+
local index, displayText = formatTalent(talentId)
1019+
Private.pvp_talent_types_specific[player_class][spec][index] = displayText
10191020
end
10201021
end
10211022
end

0 commit comments

Comments
 (0)