View Single Post
03-20-21, 12:49 AM   #5
millanzarreta
A Deviate Faerie Dragon
 
millanzarreta's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2010
Posts: 11
Originally Posted by Ketho View Post
IsSpellKnown() works for me with the spell ID returned by the aforementioned GetPvpTalentInfoByID()
I tested IsSpellKnown() again and it works for new active spells from PvP talents, but don't work for pasive talents and for new spells that replace others (for example Ice Form that replaces Icy Veins); the latter is what I had tested and that is why I assumed it never worked.

Originally Posted by Ketho View Post
IsPlayerSpell() seems to work for both passive/non-passive pvp talents
Ohh yes, IsPlayerSpell() is the key, works like a charm, it has worked for me for all the PvP talents I have tested

Good point about the SPELLS_CHANGED event, seems to fire always when PvP talents go ON or OFF (although obviously it can also be triggered on many other occasions, it's ok for what I needed)

Originally Posted by Ketho View Post
Activating it manually with warmode off and using /pvp did not seem to activate the pvp talents for me. But I assume it does indeed get activated when you enter combat with other players
Yes, warmode off disable the PvP talents and they cannot be activated with /pvp, but they are automatic activated when you enter in PvP combat, and automatic disabled some seconds after you leave the PvP combat.

I used your function with minor modifications:

Lua Code:
  1. local function ArePvpTalentsActive()
  2.     local inInstance, instanceType = IsInInstance()
  3.     if inInstance and (instanceType == "pvp" or instanceType == "arena") then
  4.         return true
  5.     elseif inInstance and (instanceType == "party" or instanceType == "raid" or instanceType == "scenario") then
  6.         return false
  7.     else
  8.         local talents = C_SpecializationInfo.GetAllSelectedPvpTalentIDs()
  9.         for _, pvptalent in pairs(talents) do
  10.             local spellID = select(6, GetPvpTalentInfoByID(pvptalent))
  11.             if IsPlayerSpell(spellID) then
  12.                 return true
  13.             end
  14.         end
  15.     end
  16. end
  17.  
  18. local function OnEvent(self, event, ...)
  19.     local status = ArePvpTalentsActive() and "active" or "not active"
  20.     print("PvP Talents are "..status)
  21. end
  22.      
  23. local f = CreateFrame("Frame")
  24. f:RegisterEvent("SPELLS_CHANGED")
  25. f:SetScript("OnEvent", OnEvent)

I add a previous check of IsInInstance() to fast-check if the player is in PvP instance or PvE instance, where as far as I know the PvP talents are always enabled and disabled respectively. Surely this is not necessary, but it seems better to me this way.

Thank you a lot, greetings
  Reply With Quote