Skip to content

Commit

Permalink
Fixed artifact module getting randomly disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
Sonaza committed Oct 1, 2019
1 parent bb95381 commit 70efb83
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 24 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 3.1.2
* Fixed artifact module getting randomly disabled when changing zones.

## 3.1.1
* Fixed changed Recruit-A-Friend check function call. Can't find specs on the level ranges so now it just calculates bonuses for anything up to level 120.
* Fixed initial game load spouting total garbage values for everything, causing the addon think some bars were inactive/disabled. Selected bars shouldn't reset on game startup now.
Expand Down
2 changes: 1 addition & 1 deletion Experiencer.toc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
## Title: Experiencer
## Notes: Simple but advanced tracking progress bar addon
## Author: Sonaza
## Version: 3.1.1
## Version: 3.1.2
## OptionalDeps: Ace3
## SavedVariables: ExperiencerDB, ExperiencerDB_module_experience, ExperiencerDB_module_reputation, ExperiencerDB_module_artifact, ExperiencerDB_module_honor, ExperiencerDB_module_conquest

Expand Down
62 changes: 39 additions & 23 deletions modules/artifact.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,30 +21,45 @@ local module = Addon:RegisterModule("artifact", {
module.levelUpRequiresAction = true;
module.hasCustomMouseCallback = false;

module.hasArtifact = true;

function module:Initialize()
self:RegisterEvent("AZERITE_ITEM_EXPERIENCE_CHANGED");
self:RegisterEvent("UNIT_INVENTORY_CHANGED");
module.apInSession = 0;

module:UpdateHasArtifact();
end

local HEART_OF_AZEROTH_ITEM_ID = 158075;
local HEART_OF_AZEROTH_QUEST_ID = 51211;
function module:UNIT_INVENTORY_CHANGED(event, unit)
if (unit ~= "player") then return end
module:UpdateHasArtifact();
module:Refresh();
end

function module:IsDisabled()
return not module.hasArtifact;
end

local HEART_OF_AZEROTH_ITEM_ID = 158075;
local HEART_OF_AZEROTH_QUEST_ID = 51211;

function module:UpdateHasArtifact()
local playerLevel = UnitLevel("player");
if (playerLevel < 110) then
return true;
end

local hasArtifact = C_AzeriteItem.HasActiveAzeriteItem();
if (not hasArtifact) then
-- C_AzeriteItem.HasActiveAzeriteItem may return false
-- during initial game loading, try a fallback to item id
local itemId = GetInventoryItemID("player", 2);
if (itemId == HEART_OF_AZEROTH_ITEM_ID) then
hasArtifact = true;
module.hasArtifact = false;
else
local hasArtifact = C_AzeriteItem.HasActiveAzeriteItem();
if (not hasArtifact) then
-- C_AzeriteItem.HasActiveAzeriteItem may return false
-- during initial game loading, try a fallback to item id
local itemId = GetInventoryItemID("player", 2);
if (itemId == HEART_OF_AZEROTH_ITEM_ID) then
hasArtifact = true;
end
end
module.hasArtifact = hasArtifact;
end
return not hasArtifact;
end

function module:AllowedToBufferUpdate()
Expand All @@ -68,25 +83,26 @@ function module:FormatNumber(value)
end

function module:GetArtifactName()
local azeriteItemLocation = C_AzeriteItem.FindActiveAzeriteItem();
if (not azeriteItemLocation) then
return "Azerite Artifact";
end

-- idk if the azeriteItemLocation.equipmentSlotIndex has changed or whatever
--local itemID = GetInventoryItemID("player", azeriteItemLocation.equipmentSlotIndex);
local itemID = GetInventoryItemID("player", 2); -- can probably hardcode the neck with its slot id
if (itemID == nil) then return "Unknown" end
--local azeriteItemLocation = C_AzeriteItem.FindActiveAzeriteItem();
--if (not azeriteItemLocation) then
-- return "Azerite Artifact";
--end
--local itemID = GetInventoryItemID("player", 2); -- can probably hardcode the neck with its slot id
--if (itemID == nil) then return "Unknown" end

local itemID = HEART_OF_AZEROTH_ITEM_ID;

local name = GetItemInfo(itemID);
if (not name) then
self:RegisterEvent("GET_ITEM_INFO_RECEIVED");
else
self:UnregisterEvent("GET_ITEM_INFO_RECEIVED");
end
return name;
end

function module:GetText()
if(not C_AzeriteItem.HasActiveAzeriteItem()) then
if (module:IsDisabled()) then
return "No artifact";
end

Expand Down

0 comments on commit 70efb83

Please sign in to comment.