Skip to content

Commit

Permalink
Xp and rep fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Sonaza committed Sep 29, 2018
1 parent 62cd13a commit c9803d9
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 42 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 3.0.5
* Fixed reputation module menu not properly changing reputations.
* Fixed xp visualizer calculating experience rewards for hidden quests.
* Added option to include the XP from account wide quests (pet battles). Disabled by default considering most players probably aren't doing these quests to level up.
* Fixed heirloom and Recruit-a-Friend XP multipliers.

## 3.0.4
* Added counter that shows amount of Artifact Power gained in current session.
* Fixed bug where Experiencer bars would still show when map was maximized.
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.0.4
## Version: 3.0.5
## OptionalDeps: Ace3
## SavedVariables: ExperiencerDB, ExperiencerDB_module_experience, ExperiencerDB_module_reputation, ExperiencerDB_module_artifact, ExperiencerDB_module_honor, ExperiencerDB_module_conquest

Expand Down
83 changes: 49 additions & 34 deletions modules/experience.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ local module = Addon:RegisterModule("experience", {
QuestXP = {
ShowText = true,
AddIncomplete = false,
IncludeAccountWide = false,
ShowVisualizer = true,
},
},
Expand Down Expand Up @@ -335,6 +336,12 @@ function module:GetOptionsMenu()
checked = function() return self.db.global.QuestXP.AddIncomplete; end,
isNotRadio = true,
},
{
text = "Include XP from account wide quests (pet battles)",
func = function() self.db.global.QuestXP.IncludeAccountWide = not self.db.global.QuestXP.IncludeAccountWide; module:Refresh(); end,
checked = function() return self.db.global.QuestXP.IncludeAccountWide; end,
isNotRadio = true,
},
{
text = "Display visualizer bar",
func = function() self.db.global.QuestXP.ShowVisualizer = not self.db.global.QuestXP.ShowVisualizer; module:Refresh(); end,
Expand Down Expand Up @@ -460,23 +467,24 @@ end
function module:CalculateXPMultiplier()
local multiplier = 1.0;

if(module:HasRecruitingBonus()) then
multiplier = multiplier * 3.0;
end

for _, slotID in ipairs(HEIRLOOM_SLOTS) do
local link = GetInventoryItemLink("player", slotID);
-- Heirloom xp bonus is now factored in quest log
--for _, slotID in ipairs(HEIRLOOM_SLOTS) do
-- local link = GetInventoryItemLink("player", slotID);

if(link) then
local _, _, itemRarity, _, _, _, _, _, itemEquipLoc = GetItemInfo(link);
-- if(link) then
-- local _, _, itemRarity, _, _, _, _, _, itemEquipLoc = GetItemInfo(link);

if(itemRarity == 7) then
local itemID = tonumber(strmatch(link, "item:(%d*)")) or 0;
local itemMultiplier = HEIRLOOM_ITEMXP[itemID] or HEIRLOOM_ITEMXP[itemEquipLoc];
-- if(itemRarity == 7) then
-- local itemID = tonumber(strmatch(link, "item:(%d*)")) or 0;
-- local itemMultiplier = HEIRLOOM_ITEMXP[itemID] or HEIRLOOM_ITEMXP[itemEquipLoc];

multiplier = multiplier + itemMultiplier;
end
end
-- multiplier = multiplier + itemMultiplier;
-- end
-- end
--end

if (module:HasRecruitingBonus()) then
multiplier = math.max(1.5, multiplier);
end

local playerLevel = UnitLevel("player");
Expand All @@ -486,47 +494,54 @@ function module:CalculateXPMultiplier()
if(not buffMultiplier.maxlevel or (buffMultiplier.maxlevel and playerLevel <= buffMultiplier.maxlevel)) then
multiplier = multiplier + buffMultiplier.multiplier;
end
end
end
end

return multiplier;
end

function module:CalculateQuestLogXP()
local completeXP, incompleteXP = 0, 0;
if (GetNumQuestLogEntries() == 0) then return 0, 0, 0; end
local _, numQuests = GetNumQuestLogEntries();
if (numQuests == 0) then return 0, 0, 0; end

local index = 0;
local index = 1;
local lastSelected = GetQuestLogSelection();

repeat
index = index + 1;
local questTitle, _, _, isHeader, _, isComplete, _, questID = GetQuestLogTitle(index);

if(not isHeader) then
local title, _, _, isHeader, _, isComplete, _, questID, _, displayQuestID, isOnMap, hasLocalPOI, isTask, isBounty, isStory, isHidden, isScaling = GetQuestLogTitle(index);
if(title and not isHeader and not isHidden) then
SelectQuestLogEntry(index);

local requiredMoney = GetQuestLogRequiredMoney(index);
local numObjectives = GetNumQuestLeaderBoards(index);
local validEntry = true;

if(isComplete and isComplete < 0) then
isComplete = false;
elseif(numObjectives == 0 and GetMoney() >= requiredMoney) then
isComplete = true;
local questTagID, tagName = GetQuestTagInfo(questID);
if (questTagID == 102 and not self.db.global.QuestXP.IncludeAccountWide) then
validEntry = false;
end

if(isComplete) then
completeXP = completeXP + GetQuestLogRewardXP();
else
incompleteXP = incompleteXP + GetQuestLogRewardXP();
if (validEntry) then
local requiredMoney = GetQuestLogRequiredMoney(index);
local numObjectives = GetNumQuestLeaderBoards(index);

if(isComplete and isComplete < 0) then
isComplete = false;
elseif(numObjectives == 0 and GetMoney() >= requiredMoney) then
isComplete = true;
end

if(isComplete) then
completeXP = completeXP + GetQuestLogRewardXP();
else
incompleteXP = incompleteXP + GetQuestLogRewardXP();
end
end
end
until(questTitle == nil);
index = index + 1;
until (title == nil);

SelectQuestLogEntry(lastSelected);

local multiplier = module:CalculateXPMultiplier();

return completeXP * multiplier, incompleteXP * multiplier, (completeXP + incompleteXP) * multiplier;
end

Expand Down
31 changes: 24 additions & 7 deletions modules/reputation.lua
Original file line number Diff line number Diff line change
Expand Up @@ -401,14 +401,21 @@ function module:GetReputationID(faction_name)
numFactions = GetNumFactions();
end

if(name == faction_name) then return index, factionID end
if(name == faction_name) then
return index, factionID;
end

index = index + 1;
end

return nil
end

function module:MenuSetWatchedFactionIndex(factionIndex)
SetWatchedFactionIndex(factionIndex);
CloseMenus();
end

function module:GetRecentReputationsMenu()
local factions = {
{
Expand All @@ -424,8 +431,8 @@ function module:GetRecentReputationsMenu()
local name = rep.name;
local data = rep.data;

local faction_index = module:GetReputationID(name);
local _, _, standing, _, _, _, _, _, isHeader, isCollapsed, hasRep, isWatched, isChild, factionID = GetFactionInfo(faction_index);
local factionIndex = module:GetReputationID(name);
local _, _, standing, _, _, _, _, _, isHeader, isCollapsed, hasRep, isWatched, isChild, factionID = GetFactionInfo(factionIndex);
local friend_level = select(7, GetFriendshipReputation(factionID));
local standing_text = "";

Expand All @@ -439,7 +446,9 @@ function module:GetRecentReputationsMenu()

tinsert(factions, {
text = string.format("%s (%s) +%s rep this session", name, standing_text, BreakUpLargeNumbers(data.amount)),
func = function() SetWatchedFactionIndex(faction_index); CloseMenus(); end,
func = function()
module:MenuSetWatchedFactionIndex(factionIndex);
end,
checked = function() return isWatched end,
})
end
Expand Down Expand Up @@ -492,7 +501,8 @@ function module:GetReputationsMenu()
local depth = 0;

local factionIndex = 1;
while factionIndex <= GetNumFactions() do
local numFactions = GetNumFactions();
while factionIndex <= numFactions do
local name, _, standing, _, _, _, _, _, isHeader, isCollapsed, hasRep, isWatched, isChild, factionID = GetFactionInfo(factionIndex);
if(name) then
local progressText = "";
Expand Down Expand Up @@ -520,6 +530,7 @@ function module:GetReputationsMenu()

if(isHeader and isCollapsed) then
ExpandFactionHeader(factionIndex);
numFactions = GetNumFactions();
end

if(isHeader and isChild and current) then -- Second tier header
Expand All @@ -536,10 +547,13 @@ function module:GetReputationsMenu()
menuList = {},
})
else
local index = factionIndex;
tinsert(current, {
text = string.format("%s (%s)%s", name, standingText, progressText),
hasArrow = true,
func = function() SetWatchedFactionIndex(factionIndex); CloseMenus(); end,
func = function()
module:MenuSetWatchedFactionIndex(index);
end,
checked = function() return isWatched; end,
menuList = {},
})
Expand Down Expand Up @@ -572,9 +586,12 @@ function module:GetReputationsMenu()

depth = 1
elseif(not isHeader) then -- First and second tier faction
local index = factionIndex;
tinsert(current, {
text = string.format("%s (%s)%s", name, standingText, progressText),
func = function() SetWatchedFactionIndex(factionIndex); CloseMenus(); end,
func = function()
module:MenuSetWatchedFactionIndex(factionIndex);
end,
checked = function() return isWatched end,
})
end
Expand Down

0 comments on commit c9803d9

Please sign in to comment.