Something went wrong. Try again.
A World of Warcraft Experience Bar addon
worldofwarcraft wow addon midnight
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200local _, F = ...
F.State = { level = 0, isMaxLevel = false,
-- XP Values currentXP = 0, maxXP = 0, restedXP = 0, questXP = 0, completeXP = 0, incompleteXP = 0,
-- Session Data session = { gainedXP = 0, lastXP = 0, startTime = 0, realTotalTime = 0, realLevelTime = 0, lastTimePlayedRequest = 0 }}
local function GetQuestRewardXP(index, questID) local rewardXP = 0
if questID and C_QuestLog.GetQuestLogRewardXP then rewardXP = C_QuestLog.GetQuestLogRewardXP(questID) or 0 end
if questID and C_QuestLog.SetSelectedQuest and C_QuestLog.GetSelectedQuest and GetQuestLogRewardXP then local previous = C_QuestLog.GetSelectedQuest() if previous ~= questID then C_QuestLog.SetSelectedQuest(questID) end
local selectedXP = GetQuestLogRewardXP() or 0
if previous and previous ~= questID then C_QuestLog.SetSelectedQuest(previous) end
if selectedXP > 0 then rewardXP = selectedXP end elseif rewardXP == 0 and GetQuestLogRewardXP then rewardXP = GetQuestLogRewardXP(index) or 0 end
return rewardXPend
function F.State:UpdatePlayerXP() self.level = UnitLevel("player") self.currentXP = UnitXP("player") self.maxXP = UnitXPMax("player") self.restedXP = GetXPExhaustion() or 0
-- Max Level Logic local expansionLevel = GetExpansionLevel() local maxLevel = math.min(GetMaxPlayerLevel(), GetMaxLevelForExpansionLevel(expansionLevel)) self.isMaxLevel = self.level >= maxLevelend
function F.State:UpdateQuestXP() if F.DB and F.DB.questTrackingEnabled == false then self.questXP = 0 self.completeXP = 0 self.incompleteXP = 0 return end
local numEntries = C_QuestLog.GetNumQuestLogEntries() local qXP, cXP, iXP = 0, 0, 0
for i = 1, numEntries do local info = C_QuestLog.GetInfo(i) -- this skips the XP header for a category / campaign as they should not be respected if info and not info.isHeader and not info.isHidden and info.questID > 0 then local isTracked = true if F.DB and F.DB.trackedOnly and C_QuestLog.GetQuestWatchType then local watchType = C_QuestLog.GetQuestWatchType(info.questID) isTracked = (watchType == 1) end
if isTracked then -- Use the quest log index when querying the reward XP local rewardXP = GetQuestRewardXP(i, info.questID) if rewardXP > 0 then qXP = qXP + rewardXP
local completeState = info.isComplete if completeState == nil then completeState = C_QuestLog.IsComplete(info.questID) end
local isComplete = completeState == 1 or completeState == true if not isComplete then isComplete = C_QuestLog.ReadyForTurnIn(info.questID) end
if isComplete then cXP = cXP + rewardXP else iXP = iXP + rewardXP end end end end end
self.questXP = qXP self.completeXP = cXP self.incompleteXP = iXPend
function F.State:DebugDumpQuests() local numEntries = C_QuestLog.GetNumQuestLogEntries() print("NixxnuxXPBar: DebugDumpQuests - numEntries =", numEntries)
local qXP, cXP, iXP = 0, 0, 0
for i = 1, numEntries do local info = C_QuestLog.GetInfo(i) if info then local reward = GetQuestRewardXP(i, info.questID)
local status = "UNKNOWN" if info.isHeader then status = "HEADER" elseif info.isHidden then status = "HIDDEN" else local completeState = info.isComplete if completeState == nil and info.questID then completeState = C_QuestLog.IsComplete(info.questID) end
local isComplete = completeState == 1 or completeState == true if not isComplete and info.questID then isComplete = C_QuestLog.ReadyForTurnIn(info.questID) end
status = isComplete and "COMPLETE" or "INCOMPLETE" end
print(string.format(" [%d] id=%s title=\"%s\" reward=%d status=%s isHeader=%s isHidden=%s", i, tostring(info.questID), tostring(info.title), reward, status, tostring(info.isHeader), tostring(info.isHidden) ))
if reward > 0 then qXP = qXP + reward if status == "COMPLETE" then cXP = cXP + reward else iXP = iXP + reward end end end end
print(string.format("Computed totals -> questXP=%d, completeXP=%d, incompleteXP=%d", qXP, cXP, iXP)) print(string.format("State totals -> questXP=%d, completeXP=%d, incompleteXP=%d", self.questXP or 0, self.completeXP or 0, self.incompleteXP or 0))end
-- Convenience slash command to quickly invoke the debug dumpSLASH_NIXXNUXXPBARDEBUG1 = SLASH_NIXXNUXXPBARDEBUG1 or "/nxpdebug"SlashCmdList = SlashCmdList or {}SlashCmdList["NIXXNUXXPBARDEBUG"] = function() F.State:DebugDumpQuests()end
function F.State:GetSessionStats() local currentTime = GetTime() local now = time()
local sessionTime = now - self.session.startTime local hourlyXP, timeToLevel = 0, 0
local coeff = sessionTime / 3600 local remainingXP = self.maxXP - self.currentXP
if coeff > 0 and self.session.gainedXP > 0 then hourlyXP = math.ceil(self.session.gainedXP / coeff) if hourlyXP > 0 then timeToLevel = math.ceil(remainingXP / hourlyXP * 3600) end end
return hourlyXP, timeToLevel, sessionTimeend