Skip to content

Commit

Permalink
Added the option to show AP and SP from Argent Dawn items.
Browse files Browse the repository at this point in the history
Some database serialization compatibility fixes.
The base mana regen is no longer floored.
  • Loading branch information
getov committed Dec 26, 2020
1 parent fccdc52 commit 21bf9b9
Show file tree
Hide file tree
Showing 5 changed files with 171 additions and 21 deletions.
2 changes: 1 addition & 1 deletion CharacterStatsClassic.toc
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 4 additions & 1 deletion CharacterStatsClassicCallbacks.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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");
Expand Down
28 changes: 28 additions & 0 deletions CharacterStatsClassicConstants.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 = " ";

72 changes: 55 additions & 17 deletions CharacterStatsClassicUI.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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");
Expand All @@ -220,25 +269,14 @@ 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;
CharacterStatsClassicCharacterDB = UISettingsCharacter;
end
end

dbLoader:SetScript("OnEvent", dbLoader.OnEvent);
dbLoader:SetScript("OnEvent", dbLoader.OnEvent);
-- Serializing the DB
85 changes: 83 additions & 2 deletions CharacterStatsClassicUtils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 --
Expand Down Expand Up @@ -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

Expand All @@ -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);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 21bf9b9

Please sign in to comment.