View Single Post
06/08/21, 05:52 AM   #5
Keldor
 
Keldor's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2015
Posts: 101
I want to share my current solution for this request. Thanks to votan who sent me some code snippets from his AddOn that I could use as base for my solution!
I'm now using the EVENT_EXPERIENCE_GAIN event in combination with the following code.

Lua Code:
  1. POIEventType = {
  2.     NONE = 0,
  3.     DARK_ANCHOR = 1,
  4.     ABYSSAL_GEYSERS = 2,
  5.     HARROWSTORM = 3,
  6. }
  7.  
  8. -- Lookup table for zones that can have the for example dark anchors
  9. POIZoneTypes = {}
  10. POIZoneTypes.DarkAnchors = {
  11.     [3] = 1,
  12.     [19] = 1,
  13.     [20] = 1,
  14.     [41] = 1,
  15.     [57] = 1,
  16.     [58] = 1,
  17.     [92] = 1,
  18.     [101] = 1,
  19.     [103] = 1,
  20.     [104] = 1,
  21.     [108] = 1,
  22.     [117] = 1,
  23.     [181] = 1,
  24.     [381] = 1,
  25.     [382] = 1,
  26.     [383] = 1,
  27. }
  28. POIZoneTypes.AbyssalGeysers = {
  29.     [1011] = 1,
  30. }
  31. POIZoneTypes.Harrowstorms = {
  32.     [1160] = 1,
  33.     [1207] = 1,
  34. }
  35.  
  36. function MyAddon.EventExperienceUpdate(_, reason)
  37.  
  38.     if reason == PROGRESS_REASON_SCRIPTED_EVENT then
  39.  
  40.         local poiType = POIEventType.NONE
  41.         local px, py = GetMapPlayerPosition("player")
  42.         local zoneIndex = GetCurrentMapZoneIndex()
  43.         local x, y, icon
  44.  
  45.         for poiIndex = 1, GetNumPOIs(zoneIndex) do
  46.  
  47.             x, y, _, icon = GetPOIMapInfo(zoneIndex, poiIndex)
  48.  
  49.             if icon == "/esoui/art/icons/poi/poi_portal_complete.dds" or icon == "/esoui/art/icons/poi/poi_portal_incomplete.dds" then
  50.  
  51.                 x, y = x - px, y - py
  52.                 x, y = x * x, y * y
  53.  
  54.                 if (x + y) < 0.0001 then
  55.  
  56.                     local zoneId = tonumber(GetZoneId(zoneIndex))
  57.                     local parentZoneId = tonumber(GetParentZoneId(zoneId))
  58.  
  59.                     if type(POIZoneTypes.DarkAnchors[zoneId]) ~= "nil" or type(POIZoneTypes.DarkAnchors[parentZoneId]) ~= "nil" then
  60.                         poiType = POIEventType.DARK_ANCHOR
  61.                         break
  62.                     elseif type(POIZoneTypes.AbyssalGeysers[zoneId]) ~= "nil" or type(POIZoneTypes.AbyssalGeysers[parentZoneId]) ~= "nil" then
  63.                         poiType = POIEventType.ABYSSAL_GEYSERS
  64.                         break
  65.                     elseif type(POIZoneTypes.Harrowstorms[zoneId]) ~= "nil" or type(POIZoneTypes.Harrowstorms[parentZoneId]) ~= "nil" then
  66.                         poiType = POIEventType.HARROWSTORM
  67.                         break
  68.                     end
  69.                 end
  70.             end
  71.         end
  72.  
  73.         -- Use poiType to check what kind of POI event has finished
  74.         -- Example:
  75.         if poiType == POIEventType.DARK_ANCHOR then
  76.             -- Do something
  77.         end
  78.     end
  79. end
  80.  
  81. EVENT_MANAGER:RegisterForEvent("MyAddon", EVENT_EXPERIENCE_GAIN, MyAddon.EventExperienceUpdate)