Skip to content

Commit

Permalink
Core: Implemented support for Primal Storms via Area POIs
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rdw-software committed May 30, 2024
1 parent be5ff43 commit 42e7349
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
28 changes: 28 additions & 0 deletions Core/Interoperability/Blizzard/AreaPOIs.lua
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions Rarity.toc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 42e7349

Please sign in to comment.