Skip to content

Commit c87826d

Browse files
committed
Initial code structure for CharacterStatsTBC
0 parents  commit c87826d

19 files changed

+2567
-0
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.vscode/
2+
._ExcludeFileList.txt
3+
*.bat

CharacterStatsTbc.toc

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
## Interface: 11306
2+
## Author: Peter Getov
3+
## Version: 1.0.0b
4+
## Title: |cff00aeffCharacterStatsTBC|r
5+
## Notes: Advanced Character Stats
6+
## DefaultState: enabled
7+
## SavedVariables: CharacterStatsTbcDB
8+
## SavedVariablesPerCharacter: CharacterStatsTbcCharacterDB
9+
10+
Localization\Localization_en.lua
11+
Localization\Localization_de.lua
12+
Localization\Localization_cn.lua
13+
Localization\Localization_ru.lua
14+
Localization\Localization_fr.lua
15+
Localization\Localization_it.lua
16+
Localization\Localization_tw.lua
17+
Localization\Localization_kr.lua
18+
Localization\Localization_es.lua
19+
Localization\Localization_br.lua
20+
21+
CharacterStatsTbcConstants.lua
22+
CharacterStatsTbcUI.lua
23+
CharacterStatsTbcCore.lua
24+
CharacterStatsTbcUtils.lua
25+
CharacterStatsTbcClassUtils.lua
26+
CharacterStatsTbcCallbacks.lua

CharacterStatsTbcCallbacks.lua

+201
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
-- OnEnter Tooltip functions
2+
function CSC_CharacterDamageFrame_OnEnter(self)
3+
-- Main hand weapon
4+
GameTooltip:SetOwner(self, "ANCHOR_RIGHT");
5+
GameTooltip:SetText(self.TooltipMainTxt, HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b);
6+
GameTooltip:AddDoubleLine(ATTACK_SPEED_COLON, format("%.2F", self.attackSpeed), NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b, HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b);
7+
GameTooltip:AddDoubleLine(DAMAGE_COLON, self.damage, NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b, HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b);
8+
GameTooltip:AddDoubleLine(DAMAGE_PER_SECOND, format("%.1F", self.dps), NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b, HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b);
9+
GameTooltip:AddDoubleLine(ATTACK_TOOLTIP..":", self.attackRating, NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b, HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b);
10+
-- Check for offhand weapon
11+
if ( self.offhandAttackSpeed ) then
12+
GameTooltip:AddLine(CSC_SYMBOL_SPACE); -- Blank line.
13+
GameTooltip:AddLine(INVTYPE_WEAPONOFFHAND, HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b);
14+
GameTooltip:AddDoubleLine(ATTACK_SPEED_COLON, format("%.2F", self.offhandAttackSpeed), NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b, HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b);
15+
GameTooltip:AddDoubleLine(DAMAGE_COLON, self.offhandDamage, NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b, HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b);
16+
GameTooltip:AddDoubleLine(DAMAGE_PER_SECOND, format("%.1F", self.offhandDps), NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b, HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b);
17+
end
18+
GameTooltip:Show();
19+
end
20+
21+
function CSC_CharacterSpellDamageFrame_OnEnter(self)
22+
GameTooltip:SetOwner(self, "ANCHOR_RIGHT");
23+
GameTooltip:SetText(STAT_SPELLPOWER, HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b);
24+
GameTooltip:AddDoubleLine(STAT_SPELLPOWER_TOOLTIP);
25+
GameTooltip:AddLine(CSC_SYMBOL_SPACE); -- Blank line.
26+
for i=2, MAX_SPELL_SCHOOLS do
27+
GameTooltip:AddDoubleLine(getglobal("DAMAGE_SCHOOL"..i), format("%.2F", GetSpellBonusDamage(i)), NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b, HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b);
28+
GameTooltip:AddTexture("Interface\\PaperDollInfoFrame\\SpellSchoolIcon"..i);
29+
end
30+
31+
if (self.spVsUndead ~= nil and UISettingsCharacter.showStatsFromArgentDawnItems) then
32+
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);
33+
end
34+
GameTooltip:Show();
35+
end
36+
37+
function CSC_CharacterSpellCritFrame_OnEnter(self)
38+
GameTooltip:SetOwner(self, "ANCHOR_RIGHT");
39+
GameTooltip:SetText(STAT_CRITICAL_STRIKE, HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b);
40+
GameTooltip:AddLine(CSC_SYMBOL_SPACE); -- Blank line.
41+
GameTooltip:AddDoubleLine(SPELL_SCHOOL1_CAP.." "..CRIT_ABBR..": ", format("%.2F", self.holyCrit).."%", NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b, HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b);
42+
GameTooltip:AddDoubleLine(SPELL_SCHOOL2_CAP.." "..CRIT_ABBR..": ", format("%.2F", self.fireCrit).."%", NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b, HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b);
43+
GameTooltip:AddDoubleLine(SPELL_SCHOOL4_CAP.." "..CRIT_ABBR..": ", format("%.2F", self.frostCrit).."%", NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b, HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b);
44+
GameTooltip:AddDoubleLine(SPELL_SCHOOL6_CAP.." "..CRIT_ABBR..": ", format("%.2F", self.arcaneCrit).."%", NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b, HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b);
45+
GameTooltip:AddDoubleLine(SPELL_SCHOOL5_CAP.." "..CRIT_ABBR..": ", format("%.2F", self.shadowCrit).."%", NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b, HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b);
46+
GameTooltip:AddDoubleLine(SPELL_SCHOOL3_CAP.." "..CRIT_ABBR..": ", format("%.2F", self.natureCrit).."%", NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b, HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b);
47+
48+
if self.unitClassId == CSC_SHAMAN_CLASS_ID then
49+
GameTooltip:AddDoubleLine(CSC_LIGHTNING_TXT.." "..CRIT_ABBR..": ", format("%.2F", self.lightningCrit).."%", NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b, HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b);
50+
end
51+
52+
GameTooltip:Show();
53+
end
54+
55+
function CSC_CharacterManaRegenFrame_OnEnter(self)
56+
GameTooltip:SetOwner(self, "ANCHOR_RIGHT");
57+
GameTooltip:SetText(format(MANA_REGEN_TOOLTIP, self.mp5NotCasting, self.mp5Casting), HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b);
58+
GameTooltip:AddDoubleLine(MANA_REGEN.." (From Gear):", self.mp5FromGear);
59+
GameTooltip:AddDoubleLine(MANA_REGEN.." (While Casting):", self.mp5Casting);
60+
GameTooltip:AddDoubleLine(MANA_REGEN.." (While Not Casting):", self.mp5NotCasting);
61+
GameTooltip:Show();
62+
end
63+
64+
function CSC_CharacterBlock_OnEnter(self)
65+
66+
if UISettingsGlobal.useBlizzardBlockValue then
67+
self.blockValue = GetShieldBlock();
68+
else
69+
self.blockValue = CSC_GetBlockValue("player");
70+
71+
local unitClassId = select(3, UnitClass("player"));
72+
if (unitClassId == CSC_WARRIOR_CLASS_ID) then
73+
local blockFromZGEnchants = CSC_GetBlockValueFromWarriorZGEnchants("player");
74+
if (blockFromZGEnchants > 0) then
75+
self.blockValue = self.blockValue + blockFromZGEnchants;
76+
end
77+
end
78+
end
79+
80+
GameTooltip:SetOwner(self, "ANCHOR_RIGHT");
81+
GameTooltip:SetText(" ", HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b);
82+
GameTooltip:AddDoubleLine(BLOCK_CHANCE..": ", self.blockChance);
83+
GameTooltip:AddDoubleLine(ITEM_MOD_BLOCK_VALUE_SHORT..": ", self.blockValue);
84+
GameTooltip:Show();
85+
end
86+
87+
function CSC_CharacterHitChanceFrame_OnEnter(self)
88+
local hitChance = self.hitChance;
89+
90+
local totalWeaponSkill = CSC_GetPlayerWeaponSkill("player", INVSLOT_MAINHAND);
91+
local missChanceVsNPC, missChanceVsBoss, missChanceVsPlayer, dwMissChanceVsNpc, dwMissChanceVsBoss, dwMissChanceVsPlayer = CSC_GetPlayerMissChances("player", hitChance, totalWeaponSkill);
92+
93+
GameTooltip:SetOwner(self, "ANCHOR_RIGHT");
94+
GameTooltip:SetText(STAT_HIT_CHANCE, HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b);
95+
GameTooltip:AddLine("Reduces your chance to miss.");
96+
97+
GameTooltip:AddLine(CSC_SYMBOL_SPACE); -- Blank line.
98+
GameTooltip:AddLine("Miss Chance vs.");
99+
GameTooltip:AddDoubleLine(format(CSC_SYMBOL_TAB.."Level 60 NPC: %.2F%%", missChanceVsNPC), format("(Dual wield: %.2F%%)", dwMissChanceVsNpc));
100+
GameTooltip:AddDoubleLine(format(CSC_SYMBOL_TAB.."Level 60 Player: %.2F%%", missChanceVsPlayer), format("(Dual wield: %.2F%%)", dwMissChanceVsPlayer));
101+
GameTooltip:AddDoubleLine(format(CSC_SYMBOL_TAB.."Level 63 NPC/Boss: %.2F%%", missChanceVsBoss), format("(Dual wield: %.2F%%)", dwMissChanceVsBoss));
102+
GameTooltip:Show();
103+
end
104+
105+
function CSC_CharacterRangedHitChanceFrame_OnEnter(self)
106+
local hitChance = self.hitChance;
107+
108+
local totalWeaponSkill = CSC_GetPlayerWeaponSkill("player", INVSLOT_RANGED);
109+
local missChanceVsNPC, missChanceVsBoss, missChanceVsPlayer, _, _, _ = CSC_GetPlayerMissChances("player", hitChance, totalWeaponSkill);
110+
111+
GameTooltip:SetOwner(self, "ANCHOR_RIGHT");
112+
GameTooltip:SetText(STAT_HIT_CHANCE, HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b);
113+
GameTooltip:AddLine("Reduces your chance to miss.");
114+
115+
GameTooltip:AddLine(CSC_SYMBOL_SPACE); -- Blank line.
116+
GameTooltip:AddLine("Miss Chance vs.");
117+
GameTooltip:AddLine(format(CSC_SYMBOL_TAB.."Level 60 NPC: %.2F%%", missChanceVsNPC));
118+
GameTooltip:AddLine(format(CSC_SYMBOL_TAB.."Level 60 Player: %.2F%%", missChanceVsPlayer));
119+
GameTooltip:AddLine(format(CSC_SYMBOL_TAB.."Level 63 NPC/Boss: %.2F%%", missChanceVsBoss));
120+
GameTooltip:Show();
121+
end
122+
123+
function CSC_CharacterSpellHitChanceFrame_OnEnter(self)
124+
GameTooltip:SetOwner(self, "ANCHOR_RIGHT");
125+
GameTooltip:SetText(format(CSC_SPELL_HIT_TOOLTIP_TXT, self.hitChance), HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b);
126+
127+
if self.unitClassId == CSC_MAGE_CLASS_ID then
128+
GameTooltip:AddLine(CSC_SYMBOL_SPACE); -- Blank line.
129+
GameTooltip:AddLine(CSC_SPELL_HIT_SUBTOOLTIP_TXT);
130+
GameTooltip:AddDoubleLine(CSC_SYMBOL_TAB..CSC_ARCANE_SPELL_HIT_TXT, (self.arcaneHit + self.hitChance).."%");
131+
GameTooltip:AddDoubleLine(CSC_SYMBOL_TAB..CSC_FIRE_SPELL_HIT_TXT, (self.fireHit + self.hitChance).."%");
132+
GameTooltip:AddDoubleLine(CSC_SYMBOL_TAB..CSC_FROST_SPELL_HIT_TXT, (self.frostHit + self.hitChance).."%");
133+
elseif self.unitClassId == CSC_WARLOCK_CLASS_ID then
134+
GameTooltip:AddLine(CSC_SYMBOL_SPACE); -- Blank line.
135+
GameTooltip:AddLine(CSC_SPELL_HIT_SUBTOOLTIP_TXT);
136+
GameTooltip:AddDoubleLine(CSC_SYMBOL_TAB..CSC_DESTRUCTION_SPELL_HIT_TXT, self.hitChance.."%");
137+
GameTooltip:AddDoubleLine(CSC_SYMBOL_TAB..CSC_AFFLICTION_SPELL_HIT_TXT, (self.afflictionHit + self.hitChance).."%");
138+
elseif self.unitClassId == CSC_SHAMAN_CLASS_ID then
139+
GameTooltip:SetText(format(CSC_SPELL_HIT_TOOLTIP_2_TXT, self.hitChance), HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b);
140+
end
141+
GameTooltip:Show();
142+
end
143+
144+
function CSC_CharacterMeleeCritFrame_OnEnter(self)
145+
local hitChance = GetHitModifier();
146+
local totalWeaponSkill = CSC_GetPlayerWeaponSkill("player", INVSLOT_MAINHAND);
147+
local missChanceVsNPC, missChanceVsBoss, missChanceVsPlayer, dwMissChanceVsNpc, dwMissChanceVsBoss, dwMissChanceVsPlayer = CSC_GetPlayerMissChances("player", hitChance, totalWeaponSkill);
148+
149+
-- no weapon equipped, not supported localization or something else went wrong
150+
if not totalWeaponSkill then totalWeaponSkill = 300 end
151+
152+
local critSuppression = 4.8;
153+
local glancingChance = 40;
154+
155+
local extraWeaponSkill = totalWeaponSkill - 300;
156+
local bossDefense = 315; -- level 63
157+
local skillBossDelta = bossDefense - totalWeaponSkill;
158+
local dodgeChance = 5 + (skillBossDelta * 0.1);
159+
local critCap = 100 - missChanceVsBoss - dodgeChance - glancingChance + critSuppression + (extraWeaponSkill * 0.04);
160+
161+
GameTooltip:SetOwner(self, "ANCHOR_RIGHT");
162+
GameTooltip:SetText(self.criticalStrikeTxt, HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b);
163+
GameTooltip:AddLine(CSC_SYMBOL_SPACE); -- Blank line.
164+
GameTooltip:AddLine("Crit cap vs.");
165+
166+
local critChance = GetCritChance();
167+
local CRITCAP_COLOR_CODE = GREEN_FONT_COLOR_CODE;
168+
if critChance > critCap then CRITCAP_COLOR_CODE = ORANGE_FONT_COLOR_CODE end
169+
local critCapTxt = CRITCAP_COLOR_CODE..format("%.2F%%", critCap)..FONT_COLOR_CODE_CLOSE;
170+
171+
local offhandItemId = GetInventoryItemID("player", INVSLOT_OFFHAND);
172+
if offhandItemId then
173+
local critCapDw = 100 - dwMissChanceVsBoss - dodgeChance - glancingChance + critSuppression + (extraWeaponSkill * 0.04);
174+
175+
local DWCRITCAP_COLOR_CODE = GREEN_FONT_COLOR_CODE;
176+
if critChance > critCapDw then DWCRITCAP_COLOR_CODE = ORANGE_FONT_COLOR_CODE end
177+
178+
local critCapDwTxt = DWCRITCAP_COLOR_CODE..format("%.2F%%", critCapDw)..FONT_COLOR_CODE_CLOSE;
179+
GameTooltip:AddDoubleLine(CSC_SYMBOL_TAB.."Level 63 NPC/Boss: "..critCapTxt, "(Dual wield: "..critCapDwTxt..")");
180+
else
181+
GameTooltip:AddDoubleLine(CSC_SYMBOL_TAB.."Level 63 NPC/Boss: "..critCapTxt);
182+
end
183+
184+
GameTooltip:Show();
185+
end
186+
187+
function CSC_CharacterDefenseFrame_OnEnter(self)
188+
local defenseValue, defenseModifier, playerLevel = CSC_GetDefense("player");
189+
local npcWeaponskill = playerLevel*5; -- same level as player
190+
local bossWeaponskill = 315; -- level 63
191+
192+
GameTooltip:SetOwner(self, "ANCHOR_RIGHT");
193+
GameTooltip:SetText(CSC_DEFENSE, HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b);
194+
GameTooltip:AddLine("Increases chance to Dodge, Block and Parry.\nDecreases chance to be hit and critically hit.");
195+
GameTooltip:AddLine(CSC_SYMBOL_SPACE); -- Blank line.
196+
GameTooltip:AddLine("Effect vs.");
197+
GameTooltip:AddLine(format(CSC_SYMBOL_TAB.."Level "..playerLevel.." NPC: %.2F%%", math.max(0, defenseValue+defenseModifier-npcWeaponskill)*0.04));
198+
GameTooltip:AddLine(format(CSC_SYMBOL_TAB.."Level 63 NPC/Boss: %.2F%%", math.max(0, defenseValue+defenseModifier-bossWeaponskill)*0.04));
199+
GameTooltip:Show();
200+
end
201+
-- OnEnter Tooltip functions END

0 commit comments

Comments
 (0)