LibProcessable

14.8k Downloads

Check for enchanting building when visiting another Garrison

Blazeflack opened this issue ยท 4 comments

commented

I'd like to know if you think it might be possible to update the enchantBuilding flag when visiting the Garrison of someone else.

Currently LibStub("LibProcessable"):IsDisenchantable() will always return false if you don't have the building in your own Garrison and if you are not an enchanter.

I'm not sure if it is even possible without using horrible hacks. I'd like to hear if you have any ideas.

commented

Garrisons and their benefits are way out of date, and I highly doubt anyone still needs this.
In case anyone does, I want to focus my effort on providing info on player-available methods of processing, and not those of the world around them.

commented

I have considered this, but the only way I know how (right now atleast) is by reading changes to the world map and its landmarks, which indeed would be considered "hacky".

commented

I've been working on an addon that lets me disenchant items more efficiently while at an enchanting building, and one of the ways I ended up updating the list of items to be disenchanted was through the events "SPELL_CONFIRMATION_PROMPT" and "UNIT_SPELLCAST_SENT".

The following is an example of how it could work:

local enchantBuilding = false
local f = CreateFrame("Frame")
f:RegisterEvent("PLAYER_ENTERING_WORLD")
f:SetScript("OnEvent", function(self, event, arg1, arg2)
    if event == "PLAYER_ENTERING_WORLD" then
        self:RegisterEvent("SPELL_CONFIRMATION_PROMPT")
        self:UnregisterEvent(event)
    elseif event == "SPELL_CONFIRMATION_PROMPT" and arg1 == 161736 then --Disenchant prompt from clicking the Essence Font
        self:RegisterEvent("UNIT_SPELLCAST_SENT")
    elseif event == "UNIT_SPELLCAST_SENT" and arg2 == GetSpellInfo(161710) then --"Disenchant Helper (DO NOT DISPLAY)"
        --We have just accepted the disenchant prompt, clearly we're at an enchant building
        enchantBuilding = true
    end
end)

This would of course require the user to click the Essence Font at the enchant building at least once before it would update, but that is better than nothing.
The event handling could probably be prettier, and it would probably also need to refresh the checks when you swap between your own Garrison and others.

The above example should give you a rough idea of what I had in mind though.

commented

Another idea is to let the API accept an override parameter, which can be passed from the addon calling :IsDisenchantable. That way other addon authors can do their own "hacky" checks and simply tell LibProcessable that we are in fact near an enchanting building.

The upside is it would be more clean.
The downside is it would require more work by the people using this library if they need this enchant building check.