From 42e7349956520421e3436f389c2403d81f5b8ef4 Mon Sep 17 00:00:00 2001 From: RDW Date: Thu, 30 May 2024 16:45:25 +0200 Subject: [PATCH] Core: Implemented support for Primal Storms via Area POIs This is a more reliable way of tracking the Elemental Storm events, although it isn't quite perfect: Firstly, the persistent elementals will be ignored if the storm that originally spawned them is no longer active. Since it's unknown whether they even drop the pets in this case and they won't respawn once killed anyway, I'd consider this a minor flaw that can probably be ignored (leading to a few missing attempts at worst). Unfortunately, I haven't found a way of detecting whether the current area is affected. So Rarity simply checks whether any Elemental Storm is active in the current zone, which could lead to false positives if someone was to go to another area that can also be imbued (but currently isn't). However... who does that while farming the pets, anyway? For the most part this approach should work well, and if not then I'll have to think of a workaround for this problem later. --- Core.lua | 5 ++++ Core/Interoperability/Blizzard/AreaPOIs.lua | 28 +++++++++++++++++++++ Rarity.toc | 1 + 3 files changed, 34 insertions(+) create mode 100644 Core/Interoperability/Blizzard/AreaPOIs.lua diff --git a/Core.lua b/Core.lua index 1eee08da..2b340618 100644 --- a/Core.lua +++ b/Core.lua @@ -719,6 +719,11 @@ function R:IsAttemptAllowed(item) end end + if not Rarity.AreaPOIs.HasActiveAreaPOIs(item.requiredAreaPOIs) then + Rarity:Debug(format("Attempts for item %s are disallowed (requires active area POIs)", item.name)) + return false + end + -- No valid instance difficulty configuration; allow (this needs to be the second-to-last check) if item.instanceDifficulties == nil diff --git a/Core/Interoperability/Blizzard/AreaPOIs.lua b/Core/Interoperability/Blizzard/AreaPOIs.lua new file mode 100644 index 00000000..4ae8b75c --- /dev/null +++ b/Core/Interoperability/Blizzard/AreaPOIs.lua @@ -0,0 +1,28 @@ +local L = LibStub("AceLocale-3.0"):GetLocale("Rarity") + +local GetAreaPOIInfo = C_AreaPoiInfo.GetAreaPOIInfo +local GetBestMapForUnit = C_Map.GetBestMapForUnit + +local format = string.format +local ipairs = ipairs + +local AreaPOIs = {} + +function AreaPOIs.HasActiveAreaPOIs(areaPOIs) + if not areaPOIs then + return false + end + + local currentMapID = GetBestMapForUnit("player") + for index, areaPointOfInterestID in ipairs(areaPOIs) do + local info = GetAreaPOIInfo(currentMapID, areaPointOfInterestID) + if info ~= nil then + Rarity:Debug(format("Detected active area POI %d", areaPointOfInterestID)) + return true + end + end + + return false +end + +Rarity.AreaPOIs = AreaPOIs diff --git a/Rarity.toc b/Rarity.toc index 90c8dcaf..9450678f 100644 --- a/Rarity.toc +++ b/Rarity.toc @@ -124,6 +124,7 @@ Core\Interoperability\WoWUnit\Testing.lua # Wrappers for the WOW API (to provide a consistent API) Core\Interoperability\Blizzard\AddonCompartment.lua +Core\Interoperability\Blizzard\AreaPOIs.lua Core\Interoperability\Blizzard\MapInfo.lua # Addon Core