Quantcast
WoWInterface - View Single Post - Detecting World PvP Zones
View Single Post
06-18-15, 09:29 AM   #14
Banknorris
A Chromatic Dragonspawn
 
Banknorris's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2014
Posts: 153
This is working perfectly in all three places (Ashran, Tol Barad and Wintergrasp):
Lua Code:
  1. local f = CreateFrame("Frame")
  2.  
  3. f:SetScript("OnEvent",function(self,event,...)
  4.     if event=="PLAYER_ENTERING_WORLD" then
  5.         local _,_,_,_,_,_,_,instance_id = GetInstanceInfo()
  6.         if instance_id==1191 or IsInActiveWorldPVP() then
  7.             f.in_active_world_combat_zone = true
  8.         else
  9.             f.in_active_world_combat_zone = false
  10.         end
  11.     elseif event=="BATTLEFIELD_MGR_ENTERED" then
  12.         if ...==1 or ...==21 or ...==24 then
  13.             f.in_active_world_combat_zone = true
  14.         end
  15.     elseif event=="BATTLEFIELD_MGR_EJECTED" then
  16.         if ...==1 or ...==21 or ...==24 then
  17.             f.in_active_world_combat_zone = false
  18.         end
  19.     elseif event=="BATTLEFIELD_MGR_STATE_CHANGE" then
  20.         if (...==1 or ...==21) and IsInActiveWorldPVP()==false then
  21.             f.in_active_world_combat_zone = false
  22.         end
  23.     end
  24.     print(f.in_active_world_combat_zone)
  25. end)
  26. f:RegisterEvent("PLAYER_ENTERING_WORLD")
  27. f:RegisterEvent("BATTLEFIELD_MGR_ENTERED")
  28. f:RegisterEvent("BATTLEFIELD_MGR_EJECTED")
  29. f:RegisterEvent("BATTLEFIELD_MGR_STATE_CHANGE")
Side note: I noticed that GetInstanceInfo() does not return the right id after ZONE_CHANGED_NEW_AREA (it returns the area you just left instead), at least when running into and out of Ashran.
__________________
"In this world nothing can be said to be certain, except that fractional reserve banking is a Ponzi scheme and that you won't believe it." - Mandrill

Last edited by Banknorris : 06-18-15 at 01:48 PM.
  Reply With Quote