diff --git a/CharacterStatsClassic.toc b/CharacterStatsClassic.toc index 286daf9..d515f60 100644 --- a/CharacterStatsClassic.toc +++ b/CharacterStatsClassic.toc @@ -1,6 +1,6 @@ ## Interface: 11306 ## Author: Peter Getov -## Version: 3.6.8 +## Version: 3.7 ## Title: |cff00aeffCharacterStatsClassic|r ## Notes: Advanced Character Stats ## DefaultState: enabled diff --git a/CharacterStatsClassicCallbacks.lua b/CharacterStatsClassicCallbacks.lua index 7f2c034..2f0db39 100644 --- a/CharacterStatsClassicCallbacks.lua +++ b/CharacterStatsClassicCallbacks.lua @@ -37,6 +37,9 @@ function CSC_CharacterSpellDamageFrame_OnEnter(self) GameTooltip:AddDoubleLine(SPELL_SCHOOL6_CAP.." "..DAMAGE..": ", format("%.2F", self.arcaneDmg), NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b, HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b); GameTooltip:AddDoubleLine(SPELL_SCHOOL5_CAP.." "..DAMAGE..": ", format("%.2F", self.shadowDmg), NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b, HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b); GameTooltip:AddDoubleLine(SPELL_SCHOOL3_CAP.." "..DAMAGE..": ", format("%.2F", self.natureDmg), NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b, HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b); + if (self.spVsUndead ~= nil and UISettingsCharacter.showStatsFromArgentDawnItems) then + GameTooltip:AddDoubleLine(DAMAGE.." vs Undead: ", format("%.2F", self.spVsUndead), NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b, HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b); + end GameTooltip:Show(); end @@ -69,7 +72,7 @@ end function CSC_CharacterBlock_OnEnter(self) - if CharacterStatsClassicDB.useBlizzardBlockValue then + if UISettingsGlobal.useBlizzardBlockValue then self.blockValue = GetShieldBlock(); else self.blockValue = CSC_GetBlockValue("player"); diff --git a/CharacterStatsClassicConstants.lua b/CharacterStatsClassicConstants.lua index 6ca876a..c3fafdf 100644 --- a/CharacterStatsClassicConstants.lua +++ b/CharacterStatsClassicConstants.lua @@ -102,6 +102,34 @@ g_CombatManaRegenSpellIdToModifier = { [22783] = 0.3 }; +g_ArgentDawnAPItems = { + -- Chests + [23087] = 81, -- Plate + [23088] = 81, -- Mail + [23089] = 81, -- Leather + -- Gloves + [23078] = 60, -- Plate + [23082] = 60, -- Mail + [23081] = 60, -- Leather + -- Bracers + [23090] = 45, -- Plate + [23092] = 45, -- Mail + [23093] = 45, -- Leather + -- Trinkets + [13209] = 81, -- Seal of the Dawn + [23206] = 150 -- Mark of the Champion AP +} + +g_ArgentDawnSPItems = { + -- SP cloth set + [23085] = 48, -- Chest + [23091] = 26, -- Bracers + [23084] = 35, -- Gloves + -- Trinkets + [19812] = 48, -- Rune of the Dawn + [23207] = 85 -- Mark of the Champion SP +} + CSC_SYMBOL_TAB = " "; -- for some reason "\t" doesn't work CSC_SYMBOL_SPACE = " "; \ No newline at end of file diff --git a/CharacterStatsClassicUI.lua b/CharacterStatsClassicUI.lua index 47f1e9c..0264478 100644 --- a/CharacterStatsClassicUI.lua +++ b/CharacterStatsClassicUI.lua @@ -4,13 +4,14 @@ local addonName, core = ...; core.UIConfig = {}; -- Defaults -local UISettingsGlobal = { +UISettingsGlobal = { useBlizzardBlockValue = false; } -local UISettingsCharacter = { +UISettingsCharacter = { selectedLeftStatsCategory = 1; selectedRightStatsCategory = 2; + showStatsFromArgentDawnItems = true; } -- for easier referencing the core config @@ -198,6 +199,15 @@ function UIConfig:SetupConfigInterface() function() UISettingsGlobal.useBlizzardBlockValue = not UISettingsGlobal.useBlizzardBlockValue; end); + + CSC_ConfigFrame.chkBtnShowADStats = CreateFrame("CheckButton", "default", CSC_ConfigFrame, "UICheckButtonTemplate"); + CSC_ConfigFrame.chkBtnShowADStats:SetPoint("TOPLEFT", 20, -55); + CSC_ConfigFrame.chkBtnShowADStats.text:SetText("Show AP and SP stats from Argent Dawn items."); + CSC_ConfigFrame.chkBtnShowADStats:SetChecked(UISettingsCharacter.showStatsFromArgentDawnItems); + CSC_ConfigFrame.chkBtnShowADStats:SetScript("OnClick", + function() + UISettingsCharacter.showStatsFromArgentDawnItems = not UISettingsCharacter.showStatsFromArgentDawnItems; + end); end -- Hook a custom function in order to extend the functionality of the default ToggleCharacter function @@ -212,6 +222,45 @@ end hooksecurefunc("ToggleCharacter", CSC_ToggleCharacterPostHook); -- Serializing the DB +local function SerializeGlobalDatabase() + if (CharacterStatsClassicDB == nil) then + CharacterStatsClassicDB = UISettingsGlobal; + end + + if (CharacterStatsClassicDB.useBlizzardBlockValue == nil) then + CharacterStatsClassicDB.useBlizzardBlockValue = UISettingsGlobal.useBlizzardBlockValue; + else + UISettingsGlobal.useBlizzardBlockValue = CharacterStatsClassicDB.useBlizzardBlockValue; + end +end + +local function SerializeCharacterDatabase() + if (CharacterStatsClassicCharacterDB == nil) then + CharacterStatsClassicCharacterDB = UISettingsCharacter; + end + + -- Left dropdown category + if (CharacterStatsClassicCharacterDB.selectedLeftStatsCategory == nil) then + CharacterStatsClassicCharacterDB.selectedLeftStatsCategory = UISettingsCharacter.selectedLeftStatsCategory; + else + UISettingsCharacter.selectedLeftStatsCategory = CharacterStatsClassicCharacterDB.selectedLeftStatsCategory; + end + + -- Right dropdown category + if (CharacterStatsClassicCharacterDB.selectedRightStatsCategory == nil) then + CharacterStatsClassicCharacterDB.selectedRightStatsCategory = UISettingsCharacter.selectedRightStatsCategory; + else + UISettingsCharacter.selectedRightStatsCategory = CharacterStatsClassicCharacterDB.selectedRightStatsCategory; + end + + -- Stats from AD items checkbox + if (CharacterStatsClassicCharacterDB.showStatsFromArgentDawnItems == nil) then + CharacterStatsClassicCharacterDB.showStatsFromArgentDawnItems = UISettingsCharacter.showStatsFromArgentDawnItems; + else + UISettingsCharacter.showStatsFromArgentDawnItems = CharacterStatsClassicCharacterDB.showStatsFromArgentDawnItems; + end +end + local dbLoader = CreateFrame("Frame"); dbLoader:RegisterEvent("ADDON_LOADED"); dbLoader:RegisterEvent("PLAYER_LOGOUT"); @@ -220,20 +269,8 @@ dbLoader:RegisterEvent("PLAYER_LOGOUT"); -- Therefore I have to call any setup-functions dependent on the DB after the event (UIConfig:SetupDropdown()) function dbLoader:OnEvent(event, arg1) if (event == "ADDON_LOADED" and arg1 == "CharacterStatsClassic") then - -- Global DB - if (CharacterStatsClassicDB == nil) then - CharacterStatsClassicDB = UISettingsGlobal; - else - UISettingsGlobal = CharacterStatsClassicDB; - end - - -- Character DB - if (CharacterStatsClassicCharacterDB == nil) then - CharacterStatsClassicCharacterDB = UISettingsCharacter; - else - UISettingsCharacter = CharacterStatsClassicCharacterDB; - end - + SerializeGlobalDatabase(); + SerializeCharacterDatabase(); UIConfig:CreateMenu(); elseif (event == "PLAYER_LOGOUT") then CharacterStatsClassicDB = UISettingsGlobal; @@ -241,4 +278,5 @@ function dbLoader:OnEvent(event, arg1) end end -dbLoader:SetScript("OnEvent", dbLoader.OnEvent); \ No newline at end of file +dbLoader:SetScript("OnEvent", dbLoader.OnEvent); +-- Serializing the DB \ No newline at end of file diff --git a/CharacterStatsClassicUtils.lua b/CharacterStatsClassicUtils.lua index 2878045..85c81cf 100644 --- a/CharacterStatsClassicUtils.lua +++ b/CharacterStatsClassicUtils.lua @@ -223,6 +223,70 @@ function CSC_HasEnchant(unit, slotId, enchantId) return false; end + +function CSC_GetAttackPowerFromArgentDawnItems(unit) + local chestId = GetInventoryItemID(unit, INVSLOT_CHEST); + local glovesId = GetInventoryItemID(unit, INVSLOT_HAND); + local bracerId = GetInventoryItemID(unit, INVSLOT_WRIST); + local trinketFirst = GetInventoryItemID(unit, INVSLOT_TRINKET1); + local trinketSecond = GetInventoryItemID(unit, INVSLOT_TRINKET2); + + local apVsUndead = 0; + + if (g_ArgentDawnAPItems[chestId] ~= nil) then + apVsUndead = apVsUndead + g_ArgentDawnAPItems[chestId]; + end + + if (g_ArgentDawnAPItems[glovesId] ~= nil) then + apVsUndead = apVsUndead + g_ArgentDawnAPItems[glovesId]; + end + + if (g_ArgentDawnAPItems[bracerId] ~= nil) then + apVsUndead = apVsUndead + g_ArgentDawnAPItems[bracerId]; + end + + if (g_ArgentDawnAPItems[trinketFirst] ~= nil) then + apVsUndead = apVsUndead + g_ArgentDawnAPItems[trinketFirst]; + end + + if (g_ArgentDawnAPItems[trinketSecond] ~= nil) then + apVsUndead = apVsUndead + g_ArgentDawnAPItems[trinketSecond]; + end + + return apVsUndead; +end + +function CSC_GetSpellkPowerFromArgentDawnItems(unit) + local chestId = GetInventoryItemID(unit, INVSLOT_CHEST); + local glovesId = GetInventoryItemID(unit, INVSLOT_HAND); + local bracerId = GetInventoryItemID(unit, INVSLOT_WRIST); + local trinketFirst = GetInventoryItemID(unit, INVSLOT_TRINKET1); + local trinketSecond = GetInventoryItemID(unit, INVSLOT_TRINKET2); + + local spVsUndead = 0; + + if (g_ArgentDawnSPItems[chestId] ~= nil) then + spVsUndead = spVsUndead + g_ArgentDawnSPItems[chestId]; + end + + if (g_ArgentDawnSPItems[glovesId] ~= nil) then + spVsUndead = spVsUndead + g_ArgentDawnSPItems[glovesId]; + end + + if (g_ArgentDawnSPItems[bracerId] ~= nil) then + spVsUndead = spVsUndead + g_ArgentDawnSPItems[bracerId]; + end + + if (g_ArgentDawnSPItems[trinketFirst] ~= nil) then + spVsUndead = spVsUndead + g_ArgentDawnSPItems[trinketFirst]; + end + + if (g_ArgentDawnSPItems[trinketSecond] ~= nil) then + spVsUndead = spVsUndead + g_ArgentDawnSPItems[trinketSecond]; + end + + return spVsUndead; +end -- GENERAL UTIL FUNCTIONS END -- -- PRIMARY STATS -- @@ -446,12 +510,17 @@ end function CSC_PaperDollFrame_SetMeleeAttackPower(statFrame, unit) local base, posBuff, negBuff = UnitAttackPower(unit); + + if (UISettingsCharacter.showStatsFromArgentDawnItems) then + local apFromAD = CSC_GetAttackPowerFromArgentDawnItems(unit); + posBuff = posBuff + apFromAD; + end local valueText, tooltipText = CSC_PaperDollFormatStat(MELEE_ATTACK_POWER, base, posBuff, negBuff); local valueNum = max(0, base + posBuff + negBuff); CSC_PaperDollFrame_SetLabelAndText(statFrame, STAT_ATTACK_POWER, valueText, false, valueNum); statFrame.tooltip = tooltipText; - statFrame.tooltip2 = format(MELEE_ATTACK_POWER_TOOLTIP, max((base+posBuff+negBuff), 0)/ATTACK_POWER_MAGIC_NUMBER); + statFrame.tooltip2 = format(MELEE_ATTACK_POWER_TOOLTIP, max((base+posBuff+negBuff), 0)/ATTACK_POWER_MAGIC_NUMBER); statFrame:Show(); end @@ -471,6 +540,12 @@ function CSC_PaperDollFrame_SetRangedAttackPower(statFrame, unit) end local base, posBuff, negBuff = UnitRangedAttackPower(unit); + + if (UISettingsCharacter.showStatsFromArgentDawnItems) then + local apFromAD = CSC_GetAttackPowerFromArgentDawnItems(unit); + posBuff = posBuff + apFromAD; + end + local valueText, tooltipText = CSC_PaperDollFormatStat(RANGED_ATTACK_POWER, base, posBuff, negBuff); local valueNum = max(0, base + posBuff + negBuff); CSC_PaperDollFrame_SetLabelAndText(statFrame, STAT_ATTACK_POWER, valueText, false, valueNum); @@ -904,6 +979,12 @@ function CSC_PaperDollFrame_SetSpellPower(statFrame, unit) maxSpellDmg = max(maxSpellDmg, bonusDamage); end + if (UISettingsCharacter.showStatsFromArgentDawnItems) then + local spFromAD = CSC_GetSpellkPowerFromArgentDawnItems(unit); + maxSpellDmg = maxSpellDmg + spFromAD; + statFrame.spVsUndead = maxSpellDmg; + end + CSC_PaperDollFrame_SetLabelAndText(statFrame, STAT_SPELLPOWER, BreakUpLargeNumbers(maxSpellDmg), false, maxSpellDmg); statFrame:Show(); end @@ -973,7 +1054,7 @@ function CSC_PaperDollFrame_SetManaRegen(statFrame, unit) end -- All mana regen stats are displayed as mana/5 sec. - local regenWhenNotCasting = floor(base * 5.0) + mp5FromGear + mp5FromAuras; + local regenWhenNotCasting = (base * 5.0) + mp5FromGear + mp5FromAuras; casting = mp5FromGear + mp5FromAuras; -- if GetManaRegen() gets fixed ever, this should be changed if mp5ModifierCasting > 0 then