ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   General Authoring Discussion (https://www.esoui.com/forums/forumdisplay.php?f=174)
-   -   Unknown POI listed as MAP_PIN_TYPE_POI_SEEN (https://www.esoui.com/forums/showthread.php?t=8076)

MasterLenman 09/25/18 08:09 AM

Unknown POI listed as MAP_PIN_TYPE_POI_SEEN
 
I'm currently updating the Destinations addon for Murkmire, and unknown points of interest were broken by this update. The addon used to check for them like this:
Lua Code:
  1. local zoneIndex = GetCurrentMapZoneIndex()
  2.  
  3. for poiIndex = 1, GetNumPOIs(zoneIndex) do
  4.     local normalizedX, normalizedY, poiType = GetPOIMapInfo(zoneIndex, poiIndex)
  5.     local unknown = poiType == MAP_PIN_TYPE_INVALID
  6.     if unkown do ......... end
  7. end

Since 4.2.0 this no longer works, as poiType is now always MAP_PIN_TYPE_POI_SEEN, even if they are not shown to the player. Why was this changed? Does anyone know of a good new way to check for unknown POIs?

ZOS_DanBatson 09/26/18 09:23 AM

The new signature for that function is:

GetPOIMapInfo(zoneIndex, poiIndex) return normalizedX, normalizedZ, poiPinType, icon, isShownInCurrentMap, linkedCollectibleIsLocked, isDiscovered, isNearby

isDiscovered and isNearby were added.

Now instead of obfuscating POIs you haven't seen, we let the API know about it (where it is, which icon, etc) and we provide whether or not it's discovered and whether or not it's nearby to determine whether or not we want to show it on the map. For the purposes of addons, you can make your own determinations about what POIs you show and how (primarily using isShownInCurrentMap, isDiscovered, and isNearby), but you no longer need to cache off your own position and icon information.

If the zoneIndex and poiIndex are good, you should no longer be getting back INVALID for the poiPinType. To mirror the old behavior, in the past if isDiscovered was false and isNearby was false, poiPinType would have been INVALID.

Lua Code:
  1. local normalizedX, normalizedZ, poiPinType, icon, isShownInCurrentMap, linkedCollectibleIsLocked, isDiscovered, isNearby = GetPOIMapInfo(zoneIndex, poiIndex)
  2. local unknown = not (isDiscovered or isNearby)

Hydra9268 10/21/18 02:58 AM

Thanks for the information Dan!

Hydra9268 10/26/18 09:20 PM

For the past few days, I've reviewed this change and remain at a loss.

The Zygor devs coded their Addon to automatically call GetPOIMapInfo whenever the map opens or changes, so the data appears to initialize at call-time. I believe this negates the need to create the map pins like how other Addons do it. (example from ChronicCollector.lua)



Here's their code from Zygor's pointer.lua file with my edits based on Dan's reply:

Lua Code:
  1. _GetPOIMapInfo_ORIG_ZGV = GetPOIMapInfo
  2. function GetPOIMapInfo( map, id, truthful )
  3.  
  4.     if truthful then
  5.         return _GetPOIMapInfo_ORIG_ZGV( map, id )
  6.     end
  7.    
  8.     local normalizedX, normalizedY, poiPinType, icon, isShownInCurrentMap, linkedCollectibleIsLocked, isDiscovered, isNearby = _GetPOIMapInfo_ORIG_ZGV( map, id )
  9.  
  10.     if icon:find("icon_missing") then
  11.         icon = ZGV.DIR.."/Arrows/Stealth/cbni0-o1egp.dds"
  12.     end
  13.  
  14.     if poiPinType == not (isDiscovered or isNearby) then
  15.         poiPinType = MAP_PIN_TYPE_INVALID
  16.     else
  17.         poiPinType = MAP_PIN_TYPE_POI_SEEN
  18.     end
  19.  
  20.     LMP:CreatePin( poiPinType, "pin-"..id, normalizedX, normalizedY )
  21.  
  22.     return normalizedX, normalizedY, poiPinType, icon, isShownInCurrentMap, linkedCollectibleIsLocked, isDiscovered, isNearby
  23. end

I tried a series of method calls with most throwing null or undefined errors.

Lua Code:
  1. ZO_WorldMapPins:CreatePin(poiPinType, id, normalizedX, normalizedY)
Lua Code:
  1. CreateSinglePOIPin( map, id)
Lua Code:
  1. g_mapPinManager:CreatePin(poiPinType, "testing", normalizedX, normalizedY)
Lua Code:
  1. ZO_MapLocations:AddLocation( map )

The last thing I tried was the popular LibMapPins library. The Library does receive the required data.


via
Lua Code:
  1. LMP:CreatePin( poiPinType, "pin-"..id, normalizedX, normalizedY )


However, I do not see undiscovered pins on the map. That's where I get lost. Any ideas on what I'm missing?

Baertram 10/28/18 03:03 AM

Not abke to help here but please do not override the functions of the game! It will break other addons if your addon does not ##OptionallDependsOn: addonName!

Please use Zo_PreHook instead and return false to call the original function, or true to end after your preehook code was run and the original function does not need to be run anymore.

MasterLenman 11/04/18 12:44 AM

Quote:

Originally Posted by ZOS_DanBatson (Post 36159)
The new signature for that function is:

GetPOIMapInfo(zoneIndex, poiIndex) return normalizedX, normalizedZ, poiPinType, icon, isShownInCurrentMap, linkedCollectibleIsLocked, isDiscovered, isNearby

isDiscovered and isNearby were added.

Now instead of obfuscating POIs you haven't seen, we let the API know about it (where it is, which icon, etc) and we provide whether or not it's discovered and whether or not it's nearby to determine whether or not we want to show it on the map. For the purposes of addons, you can make your own determinations about what POIs you show and how (primarily using isShownInCurrentMap, isDiscovered, and isNearby), but you no longer need to cache off your own position and icon information.

If the zoneIndex and poiIndex are good, you should no longer be getting back INVALID for the poiPinType. To mirror the old behavior, in the past if isDiscovered was false and isNearby was false, poiPinType would have been INVALID.

Lua Code:
  1. local normalizedX, normalizedZ, poiPinType, icon, isShownInCurrentMap, linkedCollectibleIsLocked, isDiscovered, isNearby = GetPOIMapInfo(zoneIndex, poiIndex)
  2. local unknown = not (isDiscovered or isNearby)

Thanks for the detailed response and explanation! It's working fine now in Destinations.

Hydra9268 01/05/19 11:00 PM

Quote:

Originally Posted by Baertram (Post 36408)
Not abke to help here but please do not override the functions of the game! It will break other addons if your addon does not ##OptionallDependsOn: addonName!

Please use Zo_PreHook instead and return false to call the original function, or true to end after your preehook code was run and the original function does not need to be run anymore.

Hi, Baertram. Thanks! I didn't understand at the time what you meant, but I do now. I removed that POS code and deprecated out of the Addon. I don't know what the hell the Zygor devs were thinking when they put that in.


All times are GMT -6. The time now is 04:52 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI