View Single Post
05-29-20, 06:42 AM   #2
Ketho
A Pyroguard Emberseer
 
Ketho's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,026
You can register for ZONE_CHANGED_NEW_AREA and check the zone mapID by looking if the child mapIDs match any of your dungeon mapIDs
Otherwise you could hardcode a list of zones and their respective dungeons
Lua Code:
  1. local dungeons = {
  2.     [225] = true, -- The Stockade
  3.     [291] = true, -- The Deadmines
  4. }
  5.  
  6. local function OnEvent(self, event)
  7.     -- entered new zone
  8.     local uiMapId = C_Map.GetBestMapForUnit("player")
  9.     local children = C_Map.GetMapChildrenInfo(uiMapId)
  10.     for _, childMap in pairs(children) do
  11.         if dungeons[childMap.mapID] then
  12.             -- there is a raid/dungeon in this zone
  13.             local zoneName = C_Map.GetMapInfo(uiMapId).name
  14.             print(format("You entered %s (%d) which has %s (%d)", zoneName, uiMapId, childMap.name, childMap.mapID))
  15.         end
  16.     end
  17. end
  18.  
  19. local f = CreateFrame("Frame")
  20. f:RegisterEvent("ZONE_CHANGED_NEW_AREA")
  21. f:SetScript("OnEvent", OnEvent)
Code:
> You entered Westfall (52) which has The Deadmines (291)
Other API you might want to look into: You can also reference AllTheThings source code for their approach

Last edited by Ketho : 05-29-20 at 06:34 PM.
  Reply With Quote