Files

1156 lines
39 KiB
Lua

-- Generated by ops/port_octo_character_stats.py from Octo BetterCharacterStats.lua (sha256 4c6ecd6373b1043e1ddb57fc6cbd4d1e9d051c870958d57d2fd8b0c893f6b42e).
-- The stat functions run unchanged against recorder rows (OctoStatsPane.lua); tooltips go to a line recorder.
local OctoStatsThis
BCS.TipRecorder = BCS.TipRecorder or {} -- methods are filled in by OctoStatsPane.lua
local GameTooltip = BCS.TipRecorder
function BCS:RunWithThis(frame, fn) OctoStatsThis = frame; local ok, err = pcall(fn); OctoStatsThis = nil; return ok, err end
-- 1.12 calls with no 70334 global, served from their 70334 equivalents (file locals only, no global writes).
local function GetItemInfo(item) -- 1.12 tuple = 70334 tuple without itemLevel (4th)
if not (C_Item and C_Item.GetItemInfo) or not item then return end
local name, link, quality, _, minLevel, itemType, subType, stack, equipLoc, texture = C_Item.GetItemInfo(item)
return name, link, quality, minLevel, itemType, subType, stack, equipLoc, texture
end
local function GetSpellName(slot) return C_SpellBook.GetSpellBookItemName(slot, Enum.SpellBookSpellBank.Player) end
local function OffhandHasWeapon() return C_PaperDollInfo.OffhandHasWeapon() and 1 or nil end
-- Weapon item subclass -> skill line; fist weapons and empty hands = Unarmed, as BCS GetWeaponSkillForWeaponType.
local WEAPON_SKILL = {[0]=44,[1]=172,[2]=45,[3]=46,[4]=54,[5]=160,[6]=229,[7]=43,[8]=55,[10]=136,[13]=162,[15]=173,[16]=176,[18]=226,[19]=228}
local function SkillOf(id)
local skill = id and C_SkillInfo.GetSkillLineInfoByID(id)
if not skill or not skill.rank then return 0, 0 end
return skill.rank, skill.modifier or 0
end
local function SlotSkill(slot, unarmed)
local link = GetInventoryItemLink("player", slot)
if not link then return unarmed and SkillOf(162) or 0, 0 end
local _, _, _, _, _, classID, subclassID = C_Item.GetItemInfoInstant(link)
if classID ~= 2 then return 0, 0 end
return SkillOf(WEAPON_SKILL[subclassID])
end
local function UnitAttackBothHands()
local mb, mm = SlotSkill(16, true)
local ob, om = SlotSkill(17, false)
return mb, mm, ob, om
end
local function UnitRangedAttack() return SlotSkill(18, false) end
local function UnitDefense() return SkillOf(95) end
-- 1.12 global strings this file reads; the client's own value wins wherever 70334 still has it.
local ARMOR, ARMOR_COLON = ARMOR or "Armor", ARMOR_COLON or "Armor:"
local ARMOR_TOOLTIP = ARMOR_TOOLTIP or "Damage reduction against level %d: %.2f%%"
local ATTACK_POWER_COLON, MELEE_ATTACK_POWER = ATTACK_POWER_COLON or "Attack Power:", MELEE_ATTACK_POWER or "Melee Attack Power"
local MELEE_ATTACK_POWER_TOOLTIP = MELEE_ATTACK_POWER_TOOLTIP or "Increases damage with melee weapons by %.1f damage per second."
local ATTACK_POWER_MAGIC_NUMBER = ATTACK_POWER_MAGIC_NUMBER or 14
local ATTACK_SPEED_COLON, DAMAGE_COLON, DEFENSE_COLON = ATTACK_SPEED_COLON or "Speed:", DAMAGE_COLON or "Damage:", DEFENSE_COLON or "Defense:"
-- 1.12 PaperDollFormatStat (FrameXML/PaperDollFrame.lua): the 70334 one has another signature and writes other fields.
local function PaperDollFormatStat(name, base, posBuff, negBuff, frame, textString)
posBuff, negBuff = posBuff or 0, negBuff or 0
local effective = max(0, base + posBuff + negBuff)
local text = HIGHLIGHT_FONT_COLOR_CODE .. name .. " " .. effective
if posBuff == 0 and negBuff == 0 then
text = text .. FONT_COLOR_CODE_CLOSE
textString:SetText(effective)
else
if posBuff > 0 or negBuff < 0 then text = text .. " (" .. base .. FONT_COLOR_CODE_CLOSE end
if posBuff > 0 then text = text .. FONT_COLOR_CODE_CLOSE .. GREEN_FONT_COLOR_CODE .. "+" .. posBuff .. FONT_COLOR_CODE_CLOSE end
if negBuff < 0 then text = text .. RED_FONT_COLOR_CODE .. " " .. negBuff .. FONT_COLOR_CODE_CLOSE end
if posBuff > 0 or negBuff < 0 then text = text .. HIGHLIGHT_FONT_COLOR_CODE .. ")" .. FONT_COLOR_CODE_CLOSE end
textString:SetText((negBuff < 0 and RED_FONT_COLOR_CODE or GREEN_FONT_COLOR_CODE) .. effective .. FONT_COLOR_CODE_CLOSE)
end
frame.tooltip = text
end
local _G = _G or getfenv(0)
BCS = BCS or {}
local L, IndexLeft, IndexRight
L = BCS.L
-- Inventory debounce: coalesces rapid equipment changes into a single scan
local inventoryDebounceTimer = 0
local inventoryDebouncePending = false
-- Tree of Life aura bonus from other players, your own is calculated in GetHealingPower()
local aura = .0
local playerName = UnitName("player")
local _, playerClass = UnitClass("player")
BCS.PLAYERSTAT_DROPDOWN_OPTIONS = {
"PLAYERSTAT_BASE_STATS",
"PLAYERSTAT_MELEE_COMBAT",
"PLAYERSTAT_MELEE_BOSS",
"PLAYERSTAT_RANGED_COMBAT",
"PLAYERSTAT_SPELL_COMBAT",
"PLAYERSTAT_SPELL_SCHOOLS",
"PLAYERSTAT_DEFENSES",
"PLAYERSTAT_DEFENSES_BOSS",
}
local function StatFrame_OnUpdate()
OctoStatsThis.time = (OctoStatsThis.time or 0.2) - 0.2
if OctoStatsThis.time <= 0 then
OctoStatsThis.time = 0.2
local OnEnter = OctoStatsThis:GetScript("OnEnter")
if OnEnter then
if GameTooltip:IsOwned(OctoStatsThis) then
OnEnter()
end
end
end
end
local function StatFrame_OnEnter()
GameTooltip:SetOwner(OctoStatsThis, "ANCHOR_RIGHT")
GameTooltip:SetText(OctoStatsThis.tooltip, HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b, false)
GameTooltip:AddLine(OctoStatsThis.tooltipSubtext, NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b, 1)
if OctoStatsThis.tooltipExtra then
GameTooltip:AddLine(OctoStatsThis.tooltipExtra)
end
GameTooltip:Show()
end
local function AddTooltip(statFrame)
if statFrame.tooltip then
statFrame:SetScript("OnEnter", StatFrame_OnEnter)
statFrame:SetScript("OnUpdate", StatFrame_OnUpdate)
else
statFrame:SetScript("OnUpdate", nil)
statFrame:SetScript("OnEnter", nil)
end
end
local function StatFrameMeleeDamage_OnEnter()
-- Main hand weapon
GameTooltip:SetOwner(OctoStatsThis, "ANCHOR_RIGHT")
GameTooltip:SetText(INVTYPE_WEAPONMAINHAND, HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b)
GameTooltip:AddDoubleLine(ATTACK_SPEED_COLON, format("%.2f", OctoStatsThis.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)
GameTooltip:AddDoubleLine(DAMAGE_COLON, OctoStatsThis.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)
GameTooltip:AddDoubleLine(DAMAGE_PER_SECOND, format("%.1f", OctoStatsThis.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)
-- Check for offhand weapon
if OctoStatsThis.offhandAttackSpeed then
GameTooltip:AddLine("\n")
GameTooltip:AddLine(INVTYPE_WEAPONOFFHAND, HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b)
GameTooltip:AddDoubleLine(ATTACK_SPEED_COLON, format("%.2f", OctoStatsThis.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)
GameTooltip:AddDoubleLine(DAMAGE_COLON, OctoStatsThis.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)
GameTooltip:AddDoubleLine(DAMAGE_PER_SECOND, format("%.1f", OctoStatsThis.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)
end
if OctoStatsThis.haste and OctoStatsThis.haste > 0 then
GameTooltip:AddLine("\n")
GameTooltip:AddDoubleLine(L.HASTE_COLON, format("%d%%", OctoStatsThis.haste), 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 OctoStatsThis.armorPen and OctoStatsThis.armorPen > 0 then
GameTooltip:AddDoubleLine(L.ARMOR_PEN_COLON, format("%d", OctoStatsThis.armorPen), 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
elseif OctoStatsThis.armorPen and OctoStatsThis.armorPen > 0 then
GameTooltip:AddLine("\n")
GameTooltip:AddDoubleLine(L.ARMOR_PEN_COLON, format("%d", OctoStatsThis.armorPen), 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
local function StatFrameRangedDamage_OnEnter()
if not OctoStatsThis.damage then
return
end
GameTooltip:SetOwner(OctoStatsThis, "ANCHOR_RIGHT")
GameTooltip:SetText(INVTYPE_RANGED, HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b)
GameTooltip:AddDoubleLine(ATTACK_SPEED_COLON, format("%.2f", OctoStatsThis.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)
GameTooltip:AddDoubleLine(DAMAGE_COLON, OctoStatsThis.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)
GameTooltip:AddDoubleLine(DAMAGE_PER_SECOND, format("%.1f", OctoStatsThis.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)
if OctoStatsThis.haste and OctoStatsThis.haste > 0 then
GameTooltip:AddLine("\n")
GameTooltip:AddDoubleLine(L.HASTE_COLON, format("%d%%", OctoStatsThis.haste), 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 OctoStatsThis.armorPen and OctoStatsThis.armorPen > 0 then
GameTooltip:AddDoubleLine(L.ARMOR_PEN_COLON, format("%d", OctoStatsThis.armorPen), 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
elseif OctoStatsThis.armorPen and OctoStatsThis.armorPen > 0 then
GameTooltip:AddLine("\n")
GameTooltip:AddDoubleLine(L.ARMOR_PEN_COLON, format("%d", OctoStatsThis.armorPen), 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
local function AddDamageTooltip(damageText, statFrame, speed, offhandSpeed, ranged)
local rangedAttackSpeed, minDamage, maxDamage, physicalBonusPos, physicalBonusNeg, percent
local minOffHandDamage, maxOffHandDamage
if ranged then
rangedAttackSpeed, minDamage, maxDamage, physicalBonusPos, physicalBonusNeg, percent = UnitRangedDamage("player")
speed = rangedAttackSpeed
else
minDamage, maxDamage, minOffHandDamage, maxOffHandDamage, physicalBonusPos, physicalBonusNeg, percent = UnitDamage("player")
end
local displayMin = max(floor(minDamage), 1)
local displayMax = max(ceil(maxDamage), 1)
minDamage = (minDamage / percent) - physicalBonusPos - physicalBonusNeg
maxDamage = (maxDamage / percent) - physicalBonusPos - physicalBonusNeg
local baseDamage = (minDamage + maxDamage) * 0.5
local fullDamage = (baseDamage + physicalBonusPos + physicalBonusNeg) * percent
local totalBonus = (fullDamage - baseDamage)
local damagePerSecond = (max(fullDamage, 1) / speed)
local damageTooltip = max(floor(minDamage), 1) .. " - " .. max(ceil(maxDamage), 1)
if totalBonus < 0.1 and totalBonus > -0.1 then
totalBonus = 0
end
if (totalBonus == 0) then
if ((displayMin < 100) and (displayMax < 100)) then
damageText:SetText(displayMin .. " - " .. displayMax)
else
damageText:SetText(displayMin .. "-" .. displayMax)
end
else
local color
if (totalBonus > 0) then
color = GREEN_FONT_COLOR_CODE
else
color = RED_FONT_COLOR_CODE
end
if ((displayMin < 100) and (displayMax < 100)) then
damageText:SetText(color .. displayMin .. " - " .. displayMax .. FONT_COLOR_CODE_CLOSE)
else
damageText:SetText(color .. displayMin .. "-" .. displayMax .. FONT_COLOR_CODE_CLOSE)
end
if (physicalBonusPos > 0) then
damageTooltip = damageTooltip .. GREEN_FONT_COLOR_CODE .. " +" .. physicalBonusPos .. FONT_COLOR_CODE_CLOSE
end
if (physicalBonusNeg < 0) then
damageTooltip = damageTooltip .. RED_FONT_COLOR_CODE .. " " .. physicalBonusNeg .. FONT_COLOR_CODE_CLOSE
end
if (percent > 1) then
damageTooltip = damageTooltip .. GREEN_FONT_COLOR_CODE .. " x" .. floor(percent * 100 + 0.5) .. "%|r"
elseif (percent < 1) then
damageTooltip = damageTooltip .. RED_FONT_COLOR_CODE .. " x" .. floor(percent * 100 + 0.5) .. "%|r"
end
end
statFrame.damage = damageTooltip
statFrame.attackSpeed = speed
statFrame.dps = damagePerSecond
-- If there's an offhand speed then add the offhand info to the tooltip
if (offhandSpeed) then
minOffHandDamage = (minOffHandDamage / percent) - physicalBonusPos - physicalBonusNeg
maxOffHandDamage = (maxOffHandDamage / percent) - physicalBonusPos - physicalBonusNeg
local offhandBaseDamage = (minOffHandDamage + maxOffHandDamage) * 0.5
local offhandFullDamage = (offhandBaseDamage + physicalBonusPos + physicalBonusNeg) * percent
local offhandDamagePerSecond = (max(offhandFullDamage, 1) / offhandSpeed)
local offhandDamageTooltip = max(floor(minOffHandDamage), 1) .. " - " .. max(ceil(maxOffHandDamage), 1)
if (physicalBonusPos > 0) then
offhandDamageTooltip = offhandDamageTooltip .. GREEN_FONT_COLOR_CODE .. " +" .. physicalBonusPos .. FONT_COLOR_CODE_CLOSE
end
if (physicalBonusNeg < 0) then
offhandDamageTooltip = offhandDamageTooltip .. RED_FONT_COLOR_CODE .. " " .. physicalBonusNeg .. FONT_COLOR_CODE_CLOSE
end
if (percent > 1) then
offhandDamageTooltip = offhandDamageTooltip .. GREEN_FONT_COLOR_CODE .. " x" .. floor(percent * 100 + 0.5) .. "%|r"
elseif (percent < 1) then
offhandDamageTooltip = offhandDamageTooltip .. RED_FONT_COLOR_CODE .. " x" .. floor(percent * 100 + 0.5) .. "%|r"
end
statFrame.offhandDamage = offhandDamageTooltip
statFrame.offhandAttackSpeed = offhandSpeed
statFrame.offhandDps = offhandDamagePerSecond
else
statFrame.offhandAttackSpeed = nil
end
statFrame.haste = BCS:GetHaste()
statFrame.armorPen, statFrame.armorPenFromTalent = BCS:GetArmorPen()
if ranged then
statFrame.armorPen = statFrame.armorPen - statFrame.armorPenFromTalent
statFrame:SetScript("OnEnter", StatFrameRangedDamage_OnEnter)
else
statFrame:SetScript("OnEnter", StatFrameMeleeDamage_OnEnter)
end
if statFrame.damage then
statFrame:SetScript("OnUpdate", StatFrame_OnUpdate)
else
statFrame:SetScript("OnUpdate", nil)
end
end
local statIndexTable = {
"STRENGTH",
"AGILITY",
"STAMINA",
"INTELLECT",
"SPIRIT",
}
function BCS:SetStat(statFrame, statIndex)
local label = statFrame.Label
local text = statFrame.StatText
label:SetText(_G["SPELL_STAT" .. (statIndex - 1) .. "_NAME"] .. ":")
local stat, effectiveStat, posBuff, negBuff = UnitStat("player", statIndex)
-- Set the tooltip text
local tooltipText = HIGHLIGHT_FONT_COLOR_CODE .. _G["SPELL_STAT" .. (statIndex - 1) .. "_NAME"] .. " "
if ((posBuff == 0) and (negBuff == 0)) then
text:SetText(effectiveStat)
statFrame.tooltip = tooltipText .. effectiveStat .. FONT_COLOR_CODE_CLOSE
else
tooltipText = tooltipText .. effectiveStat
if (posBuff > 0 or negBuff < 0) then
tooltipText = tooltipText .. " (" .. (stat - posBuff - negBuff) .. FONT_COLOR_CODE_CLOSE
end
if (posBuff > 0) then
tooltipText = tooltipText .. FONT_COLOR_CODE_CLOSE .. GREEN_FONT_COLOR_CODE .. "+" .. posBuff .. FONT_COLOR_CODE_CLOSE
end
if (negBuff < 0) then
tooltipText = tooltipText .. RED_FONT_COLOR_CODE .. " " .. negBuff .. FONT_COLOR_CODE_CLOSE
end
if (posBuff > 0 or negBuff < 0) then
tooltipText = tooltipText .. HIGHLIGHT_FONT_COLOR_CODE .. ")" .. FONT_COLOR_CODE_CLOSE
end
statFrame.tooltip = tooltipText
-- If there are any negative buffs then show the main number in red even if there are
-- positive buffs. Otherwise show in green.
if (negBuff < 0) then
text:SetText(RED_FONT_COLOR_CODE .. effectiveStat .. FONT_COLOR_CODE_CLOSE)
else
text:SetText(GREEN_FONT_COLOR_CODE .. effectiveStat .. FONT_COLOR_CODE_CLOSE)
end
end
statFrame:SetScript("OnEnter", function()
PaperDollStatTooltip("player", statIndexTable[statIndex])
end)
end
function BCS:SetArmor(statFrame)
local label = statFrame.Label
local text = statFrame.StatText
local base, effectiveArmor, armor, posBuff, negBuff = UnitArmor("player")
label:SetText(ARMOR_COLON)
PaperDollFormatStat(ARMOR, base, posBuff, negBuff, statFrame, text)
local playerLevel = UnitLevel("player")
local armorReduction = effectiveArmor / ((85 * playerLevel) + 400)
armorReduction = 100 * (armorReduction / (armorReduction + 1))
statFrame.tooltipSubtext = format(ARMOR_TOOLTIP, playerLevel, armorReduction)
AddTooltip(statFrame)
end
function BCS:GetMissChanceRaw(wepSkill)
local diff = wepSkill - 315
local miss = 5
if TURTLE_WOW_VERSION ~= nil then
miss = miss - (diff * 0.2) - BCS:GetHitRating()
else
if diff < -10 then
miss = miss - diff * 0.2;
else
miss = miss - diff * 0.1;
end
local hitChance = BCS:GetHitRating()
-- if skill diff < -10 then subtract one from +hit, if there is any +hit
if (diff < -10) and (hitChance > 0) then
hitChance = hitChance - 1
end
miss = miss - hitChance
end
return miss
end
function BCS:GetMissChance(wepSkill)
return max(0, min(BCS:GetMissChanceRaw(wepSkill), 60))
end
function BCS:GetDualWieldMissChance(wepSkill)
return max(0, min(BCS:GetMissChanceRaw(wepSkill) + 19, 60))
end
function BCS:GetGlanceChance(wepSkill)
return 10 + 15 * 2;
end
function BCS:GetGlanceReduction(wepSkill)
if TURTLE_WOW_VERSION ~= nil then
return 65 + (wepSkill - 300) * 2
else
local diff = 315 - wepSkill;
local low = math.max(math.min(1.3 - 0.05 * diff, 0.91), 0.01);
local high = math.max(math.min(1.2 - 0.03 * diff, 0.99), 0.2);
return 100 * ((high - low) / 2 + low);
end
end
function BCS:GetDodgeChance(wepSkill)
return math.max(5 + (315 - wepSkill) * 0.1, 0);
end
function BCS:GetDualWieldCritCap(wepSkill)
local cap = 100 - self:GetDualWieldMissChance(wepSkill) - self:GetGlanceChance(wepSkill) - self:GetDodgeChance(wepSkill);
if (cap > 100) then
cap = 100;
end
if (cap < 0) then
cap = 0;
end
return cap;
end
function BCS:GetCritCap(wepSkill)
local cap = 100 - self:GetMissChance(wepSkill) - self:GetGlanceChance(wepSkill) - self:GetDodgeChance(wepSkill);
if (cap > 100) then
cap = 100;
end
if (cap < 0) then
cap = 0;
end
return cap;
end
function BCS:GetEffectiveBlockChance(leveldiff)
local block = GetBlockChance() - ((5 * leveldiff) * 0.04)
if block < 0 then
block = 0
end
return block
end
function BCS:GetEffectiveParryChance(leveldiff)
local parry = GetParryChance() - ((5 * leveldiff) * 0.04)
if parry < 0 then
parry = 0
end
return parry
end
function BCS:GetEffectiveDodgeChance(leveldiff)
local dodge = GetDodgeChance() - ((5 * leveldiff) * 0.04)
if dodge < 0 then
dodge = 0
end
return dodge
end
function BCS:SetDamage(statFrame)
local damageText = statFrame.StatText
local label = statFrame.Label
local speed, offhandSpeed = UnitAttackSpeed("player")
label:SetText(DAMAGE_COLON)
AddDamageTooltip(damageText, statFrame, speed, offhandSpeed)
end
function BCS:SetAttackSpeed(statFrame)
local damageText = statFrame.StatText
local label = statFrame.Label
local speed, offhandSpeed = UnitAttackSpeed("player")
speed = format("%.2f", speed)
if (offhandSpeed) then
offhandSpeed = format("%.2f", offhandSpeed)
end
local text
if (offhandSpeed) then
text = speed .. " | " .. offhandSpeed
else
text = speed
end
AddDamageTooltip(damageText, statFrame, speed, offhandSpeed)
label:SetText(SPEED .. ":")
damageText:SetText(text)
end
function BCS:SetAttackPower(statFrame)
local text = statFrame.StatText
local label = statFrame.Label
local base, posBuff, negBuff = UnitAttackPower("player")
label:SetText(ATTACK_POWER_COLON)
PaperDollFormatStat(MELEE_ATTACK_POWER, base, posBuff, negBuff, statFrame, text)
statFrame.tooltipSubtext = format(MELEE_ATTACK_POWER_TOOLTIP, max((base + posBuff + negBuff), 0) / ATTACK_POWER_MAGIC_NUMBER)
AddTooltip(statFrame)
end
function BCS:SetSpellPower(statFrame, school)
local text = statFrame.StatText
local label = statFrame.Label
if school then
local base, _, _, dmgOnly = BCS:GetSpellPower()
local fromSchool = BCS:GetSpellPower(school)
local total = base + dmgOnly + fromSchool
if fromSchool > 0 then
text:SetText(GREEN_FONT_COLOR_CODE .. total .. FONT_COLOR_CODE_CLOSE)
else
text:SetText(total)
end
label:SetText(L["SPELL_SCHOOL_" .. strupper(school)])
if fromSchool > 0 then
statFrame.tooltip = format(L.SPELL_SCHOOL_SECONDARY_TOOLTIP, school, total, base + dmgOnly, fromSchool)
else
statFrame.tooltip = format(L.SPELL_SCHOOL_TOOLTIP, school, total)
end
statFrame.tooltipSubtext = format(L.SPELL_SCHOOL_TOOLTIP_SUB, strlower(school))
else
local damageAndHealing, secondaryPower, secondaryName, damageOnly = BCS:GetSpellPower()
local total = damageAndHealing + damageOnly
label:SetText(L.SPELL_POWER_COLON)
if secondaryPower > 0 then
text:SetText(GREEN_FONT_COLOR_CODE..total + secondaryPower)
else
text:SetText(total + secondaryPower)
end
if secondaryPower ~= 0 then
statFrame.tooltip = format(L.SPELL_POWER_SECONDARY_TOOLTIP, total + secondaryPower, total, secondaryPower, secondaryName)
statFrame.tooltipSubtext = L.SPELL_POWER_SECONDARY_TOOLTIP_SUB
else
statFrame.tooltip = format(L.SPELL_POWER_TOOLTIP, total)
statFrame.tooltipSubtext = L.SPELL_POWER_TOOLTIP_SUB
end
end
AddTooltip(statFrame)
end
function BCS:SetHitRating(statFrame, ratingType)
local text = statFrame.StatText
local label = statFrame.Label
label:SetText(L.MELEE_HIT_RATING_COLON)
if ratingType == "MELEE" then
text:SetText(BCS:GetHitRating().."%")
statFrame.tooltip = L.MELEE_HIT_TOOLTIP
statFrame.tooltipSubtext = L.MELEE_HIT_TOOLTIP_SUB
AddTooltip(statFrame)
elseif ratingType == "RANGED" then
-- If no ranged attack then set to n/a
if UnitHasRelicSlot("player") or not GetInventoryItemLink("player", 18) then
text:SetText(NOT_APPLICABLE)
return
end
text:SetText(BCS:GetRangedHitRating().."%")
statFrame.tooltip = L.RANGED_HIT_TOOLTIP
statFrame.tooltipSubtext = L.RANGED_HIT_TOOLTIP_SUB
AddTooltip(statFrame)
elseif ratingType == "SPELL" then
local spell_hit, spell_hit_fire, spell_hit_frost, spell_hit_arcane, spell_hit_shadow, spell_hit_holy = BCS:GetSpellHitRating()
local spellPen = BCS:GetSpellPen()
text:SetText(spell_hit.."%")
statFrame.tooltip = L.SPELL_HIT_TOOLTIP
statFrame.tooltipSubtext = L.SPELL_HIT_TOOLTIP_SUB
statFrame:SetScript("OnEnter", function()
GameTooltip:SetOwner(OctoStatsThis, "ANCHOR_RIGHT")
GameTooltip:SetText(OctoStatsThis.tooltip)
GameTooltip:AddLine(OctoStatsThis.tooltipSubtext, NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b, 1)
if spell_hit_fire > 0 then
GameTooltip:AddLine(format(L.HIT_FIRE, spell_hit + spell_hit_fire))
end
if spell_hit_frost > 0 then
GameTooltip:AddLine(format(L.HIT_FROST, spell_hit + spell_hit_frost))
end
if spell_hit_arcane > 0 then
GameTooltip:AddLine(format(L.HIT_ARCANE, spell_hit + spell_hit_arcane))
end
if spell_hit_shadow > 0 then
if playerClass == "WARLOCK" then
GameTooltip:AddLine(format(L.HIT_AFFLICTION, spell_hit + spell_hit_shadow))
else
GameTooltip:AddLine(format(L.HIT_SHADOW, spell_hit + spell_hit_shadow))
end
end
if spell_hit_holy > 0 then
GameTooltip:AddLine(format(L.HIT_HOLY_DISC, spell_hit + spell_hit_holy))
end
if spellPen > 0 then
GameTooltip:AddLine(format(L.SPELL_PEN, spellPen))
end
GameTooltip:Show()
end)
end
end
function BCS:SetMeleeCritChance(statFrame)
local text = statFrame.StatText
local label = statFrame.Label
label:SetText(L.MELEE_CRIT_COLON)
text:SetText(format("%.2f%%", BCS:GetCritChance()))
statFrame.tooltip = L.MELEE_CRIT_TOOLTIP
statFrame.tooltipSubtext = L.MELEE_CRIT_TOOLTIP_SUB
AddTooltip(statFrame)
end
function BCS:SetWeaponSkill(statFrame)
local text = statFrame.StatText
local label = statFrame.Label
label:SetText(L.WEAPON_SKILL_COLON)
local mainHandSkillBase, mainHandSkillMod, offHandSkillBase, offHandSkillMod = UnitAttackBothHands("player")
local mainHandTotal = mainHandSkillBase + mainHandSkillMod
local offHandTotal = offHandSkillBase + offHandSkillMod
if OffhandHasWeapon() then
text:SetText(format("%d | %d", mainHandTotal, offHandTotal))
else
text:SetText(format("%d", mainHandTotal))
end
statFrame.tooltip = L.MELEE_WEAPON_SKILL_TOOLTIP
statFrame.tooltipSubtext = L.MELEE_WEAPON_SKILL_TOOLTIP_SUB
AddTooltip(statFrame)
end
function BCS:SetRangedWeaponSkill(statFrame)
local text = statFrame.StatText
local label = statFrame.Label
label:SetText(L.WEAPON_SKILL_COLON)
-- If no ranged attack then set to n/a
if UnitHasRelicSlot("player") or not GetInventoryItemLink("player", 18) then
text:SetText(NOT_APPLICABLE)
return
end
local rangedSkillBase, rangedSkillMod = UnitRangedAttack("player")
text:SetText(format("%d", rangedSkillBase + rangedSkillMod))
statFrame.tooltip = L.RANGED_WEAPON_SKILL_TOOLTIP
statFrame.tooltipSubtext = L.RANGED_WEAPON_SKILL_TOOLTIP_SUB
AddTooltip(statFrame)
end
function BCS:SetBossMissChance(statFrame)
local frame = statFrame
local text = statFrame.StatText
local label = statFrame.Label
label:SetText(L.MISS_CHANCE_COLON)
local mh_miss = BCS:GetMissChance(BCS:GetMHWeaponSkill())
if OffhandHasWeapon() == 1 then
text:SetText(format("%.1f%% | %.1f%%",
BCS:GetDualWieldMissChance(BCS:GetMHWeaponSkill()),
BCS:GetDualWieldMissChance(BCS:GetOHWeaponSkill())))
else
text:SetText(format("%.1f%%", mh_miss))
end
statFrame.tooltip = format(L.MELEE_MISS_VS_BOSS_TOOLTIP)
statFrame.tooltipSubtext = format(L.MELEE_MISS_VS_BOSS_TOOLTIP_SUB)
AddTooltip(statFrame)
end
function BCS:SetBossGlanceReduction(statFrame)
local text = statFrame.StatText
local label = statFrame.Label
label:SetText(L.GLANCE_REDUCTION_COLON)
if OffhandHasWeapon() == 1 then
text:SetText(format("%d%% | %d%%",
BCS:GetGlanceReduction(BCS:GetMHWeaponSkill()),
BCS:GetGlanceReduction(BCS:GetOHWeaponSkill())))
else
text:SetText(format("%d%%", BCS:GetGlanceReduction(BCS:GetMHWeaponSkill())))
end
statFrame.tooltip = format(L.MELEE_GLANCE_VS_BOSS_TOOLTIP)
statFrame.tooltipSubtext = format(L.MELEE_GLANCE_VS_BOSS_TOOLTIP_SUB)
AddTooltip(statFrame)
end
function BCS:SetBossDodgeChance(statFrame)
local text = statFrame.StatText
local label = statFrame.Label
label:SetText(L.DODGE_CHANCE_COLON)
if OffhandHasWeapon() == 1 then
text:SetText(format("%.1f%% | %.1f%%",
BCS:GetDodgeChance(BCS:GetMHWeaponSkill()),
BCS:GetDodgeChance(BCS:GetOHWeaponSkill())))
else
text:SetText(format("%.1f%%", BCS:GetDodgeChance(BCS:GetMHWeaponSkill())))
end
statFrame.tooltip = format(L.MELEE_DODGE_VS_BOSS_TOOLTIP)
statFrame.tooltipSubtext = format(L.MELEE_DODGE_VS_BOSS_TOOLTIP_SUB)
AddTooltip(statFrame)
end
function BCS:SetBossCritCap(statFrame)
local text = statFrame.StatText
local label = statFrame.Label
label:SetText(L.CRIT_CAP_COLON)
if OffhandHasWeapon() == 1 then
text:SetText(format("%.1f%% | %.1f%%",
BCS:GetDualWieldCritCap(BCS:GetMHWeaponSkill()),
BCS:GetDualWieldCritCap(BCS:GetOHWeaponSkill())))
else
text:SetText(format("%.1f%%", BCS:GetCritCap(BCS:GetMHWeaponSkill())))
end
AddTooltip(statFrame)
end
function BCS:SetEffectiveBossCrit(statFrame)
local text = statFrame.StatText
local label = statFrame.Label
label:SetText(L.BOSS_CRIT_COLON)
local critChance = BCS:GetCritChance() - 3 -- 3 % crit reduction vs lvl 63
if OffhandHasWeapon() == 1 then
text:SetText(format("%.1f%% | %.1f%%",
math.min(critChance, BCS:GetDualWieldCritCap(BCS:GetMHWeaponSkill())),
math.min(critChance, BCS:GetDualWieldCritCap(BCS:GetOHWeaponSkill()))
))
else
text:SetText(format("%.1f%%", math.min(critChance, BCS:GetCritCap(BCS:GetMHWeaponSkill()))))
end
statFrame.tooltip = format(L.MELEE_EFF_CRIT_VS_BOSS_TOOLTIP)
statFrame.tooltipSubtext = format(L.MELEE_EFF_CRIT_VS_BOSS_TOOLTIP_SUB)
AddTooltip(statFrame)
end
function BCS:SetSpellCritChance(statFrame)
local text = statFrame.StatText
local label = statFrame.Label
label:SetText(L.SPELL_CRIT_COLON)
local generic = BCS:GetSpellCritChance()
local spell1, spell2, spell3, spell4, spell5, spell6 = BCS:GetSpellCritFromClass(playerClass)
local total1 = generic + spell1
local total2 = generic + spell2
local total3 = generic + spell3
local total4 = generic + spell4
local total5 = generic + spell5
local total6 = generic + spell6
if total1 > 100 then total1 = 100 end
if total2 > 100 then total2 = 100 end
if total3 > 100 then total3 = 100 end
if total4 > 100 then total4 = 100 end
if total5 > 100 then total5 = 100 end
if total6 > 100 then total6 = 100 end
text:SetText(format("%.2f%%", generic))
-- warlock spells that can crit are all destruction so just add OctoStatsThis to generic
if playerClass == "WARLOCK" and spell1 > 0 then
text:SetText(format("%.2f%%", generic + spell1))
-- if priest have both talents add lowest to generic cos there will be no more spells left that can crit
elseif playerClass == "PRIEST" and spell3 > 0 and spell2 > 0 then
if spell2 < spell3 then
text:SetText(format("%.2f%%", generic + spell2))
elseif spell2 >= spell3 then
text:SetText(format("%.2f%%", generic + spell3))
end
end
statFrame.tooltip = L.SPELL_CRIT_TOOLTIP
statFrame.tooltipSubtext = L.SPELL_CRIT_TOOLTIP_SUB
statFrame:SetScript("OnEnter", function()
GameTooltip:SetOwner(OctoStatsThis, "ANCHOR_RIGHT")
GameTooltip:SetText(OctoStatsThis.tooltip)
GameTooltip:AddLine(OctoStatsThis.tooltipSubtext, NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b, 1)
if playerClass == "DRUID" then
if spell1 > 0 then
GameTooltip:AddLine(format(L.CRIT_MOONFIRE, total1))
end
if spell2 > 0 then
GameTooltip:AddLine(format(L.CRIT_REGROWTH, total2))
end
elseif playerClass == "PALADIN" then
if spell1 > 0 then
GameTooltip:AddLine(format(L.CRIT_HOLYLIGHT, total1))
end
if spell2 > 0 then
GameTooltip:AddLine(format(L.CRIT_FLASHOFLIGHT, total2))
end
if spell3 > 0 then
GameTooltip:AddLine(format(L.CRIT_HOLYSHOCK, total3))
end
elseif playerClass == "WARLOCK" then
if spell3 > 0 and spell3 ~= spell1 then
GameTooltip:AddLine(format(L.CRIT_FIRE, total1 + spell3))
if spell2 > 0 and (total2 + spell3) ~= total3 then
GameTooltip:AddLine(format(L.CRIT_SEARING, total2 + spell3))
end
else
if spell2 > 0 and spell2 ~= spell1 then
GameTooltip:AddLine(format(L.CRIT_SEARING, total2))
end
end
elseif playerClass == "PRIEST" then -- all healing spells are holy, change tooltip if player have both talents
if spell1 > 0 then
if spell3 > 0 then
GameTooltip:AddLine(format(L.CRIT_HEALING, total1))
end
GameTooltip:AddLine(format(L.CRIT_HOLY, total1 + spell3))
end
if spell2 > 0 then
GameTooltip:AddLine(format(L.CRIT_DISC, total2 + spell3))
end
if spell3 > 0 then
if spell2 > 0 then
GameTooltip:AddLine(format(L.CRIT_SHADOW, total3))
else
GameTooltip:AddLine(format(L.CRIT_OFFENCE, total3))
end
end
if spell4 > 0 then
GameTooltip:AddLine(format(L.CRIT_PRAYER, total4 + spell1))
end
elseif playerClass == "MAGE" then -- dont show specific spells if they have same chance as fire spells
if spell1 > 0 then
GameTooltip:AddLine(format(L.CRIT_ARCANE, total1))
end
if spell2 > 0 then
GameTooltip:AddLine(format(L.CRIT_FIRE, total2))
end
if spell3 > 0 and spell3 ~= spell2 then
GameTooltip:AddLine(format(L.CRIT_FIREBLAST, total3))
end
if spell4 > 0 and spell4 ~= spell2 then
GameTooltip:AddLine(format(L.CRIT_SCORCH, total4))
end
if spell5 > 0 and spell5 ~= spell2 then
GameTooltip:AddLine(format(L.CRIT_FLAMESTRIKE, total5))
end
if spell6 > 0 then
GameTooltip:AddLine(format(L.CRIT_FROZEN, total6))
end
elseif playerClass == "SHAMAN" then
if spell1 > 0 then
GameTooltip:AddLine(format(L.CRIT_LIGHTNINGBOLT, total1))
end
if spell2 > 0 then
GameTooltip:AddLine(format(L.CRIT_CHAINLIGHTNING, total2))
end
if spell3 > 0 then
GameTooltip:AddLine(format(L.CRIT_LIGHTNINGSHIELD, total3))
end
if spell4 > 0 then
GameTooltip:AddLine(format(L.CRIT_FIREFROST, total4))
end
if spell5 > 0 then
GameTooltip:AddLine(format(L.CRIT_HEALING, total5))
end
end
GameTooltip:Show()
end)
end
function BCS:SetRangedCritChance(statFrame)
local text = statFrame.StatText
local label = statFrame.Label
label:SetText(L.RANGED_CRIT_COLON)
-- If no ranged attack then set to n/a
if UnitHasRelicSlot("player") or not GetInventoryItemLink("player", 18) then
text:SetText(NOT_APPLICABLE)
return
end
local crit = BCS:GetRangedCritChance()
-- apply skill difference modifier
local skill = BCS:GetRangedWeaponSkill()
local level = UnitLevel("player")
local skillDiff = skill - (level * 5)
if skill >= (level * 5) then
crit = crit + (skillDiff * 0.04)
else
crit = crit + (skillDiff * 0.2)
end
if crit < 0 then
crit = 0
end
text:SetText(format("%.2f%%", crit))
statFrame.tooltip = L.RANGED_CRIT_TOOLTIP
statFrame.tooltipSubtext = L.RANGED_CRIT_TOOLTIP_SUB
AddTooltip(statFrame)
end
function BCS:SetHealing(statFrame)
local text = statFrame.StatText
local label = statFrame.Label
local damageAndHealing = BCS:GetSpellPower()
local healingOnly, treebonus, ironclad = BCS:GetHealingPower()
local total = damageAndHealing + healingOnly
local tooltipExtra
if ironclad > 0 then
tooltipExtra = format(L.IRONCLAD, ironclad)
end
if treebonus and aura <= treebonus then
total = total + treebonus
elseif (not treebonus and aura > 0) or (treebonus and aura > treebonus) then
total = total + aura
end
label:SetText(L.HEAL_POWER_COLON)
text:SetText(format("%d", total))
if healingOnly ~= 0 then
statFrame.tooltip = format(L.SPELL_HEALING_POWER_SECONDARY_TOOLTIP, total, damageAndHealing, healingOnly)
else
statFrame.tooltip = format(L.SPELL_HEALING_POWER_TOOLTIP, total)
end
statFrame.tooltipSubtext = L.SPELL_HEALING_POWER_TOOLTIP_SUB
statFrame.tooltipExtra = tooltipExtra
AddTooltip(statFrame)
end
function BCS:SetManaRegen(statFrame)
local text = statFrame.StatText
local label = statFrame.Label
label:SetText(L.MANA_REGEN_COLON)
-- if not a mana user and not a druid set to N/A
if UnitPowerType("player") ~= 0 and playerClass ~= "DRUID" then
text:SetText(NOT_APPLICABLE)
return
end
local base, casting, mp5 = BCS:GetManaRegen()
local mp2 = mp5 * 0.4
local totalRegen = base + mp2
local totalRegenWhileCasting = (casting / 100) * base + mp2
if totalRegenWhileCasting ~= totalRegen then
text:SetText(format("%d (%d)", totalRegen, totalRegenWhileCasting))
else
text:SetText(format("%d", totalRegen))
end
statFrame.tooltip = format(L.SPELL_MANA_REGEN_TOOLTIP, totalRegen, totalRegenWhileCasting)
statFrame.tooltipSubtext = format(L.SPELL_MANA_REGEN_TOOLTIP_SUB, base, casting, mp5, mp2)
AddTooltip(statFrame)
end
function BCS:SetSpellHaste(statFrame)
local text = statFrame.StatText
local label = statFrame.Label
label:SetText(L.HASTE_COLON)
local haste, spellOnly = BCS:GetHaste()
text:SetText(format("%d%%", haste + spellOnly))
local haste, spellOnly = BCS:GetHaste()
local total = haste + spellOnly
text:SetText(format("%d%%", total))
statFrame.tooltip = L.SPELL_HASTE_TOOLTIP
statFrame.tooltipSubtext = L.SPELL_HASTE_TOOLTIP_SUB
AddTooltip(statFrame)
end
function BCS:SetDodge(statFrame, leveldiff)
local text = statFrame.StatText
local label = statFrame.Label
label:SetText(L.DODGE_COLON)
text:SetText(format("%.2f%%", BCS:GetEffectiveDodgeChance(leveldiff)))
statFrame.tooltip = L.PLAYER_DODGE_TOOLTIP
statFrame.tooltipSubtext = L.PLAYER_DODGE_TOOLTIP_SUB
AddTooltip(statFrame)
end
function BCS:SetParry(statFrame, leveldiff)
local text = statFrame.StatText
local label = statFrame.Label
label:SetText(L.PARRY_COLON)
text:SetText(format("%.2f%%", BCS:GetEffectiveParryChance(leveldiff)))
statFrame.tooltip = L.PLAYER_PARRY_TOOLTIP
statFrame.tooltipSubtext = L.PLAYER_PARRY_TOOLTIP_SUB
AddTooltip(statFrame)
end
function BCS:SetBlock(statFrame, leveldiff)
local text = statFrame.StatText
local label = statFrame.Label
local blockChance = BCS:GetEffectiveBlockChance(leveldiff)
local tooltipExtra
if blockChance > 0 then
tooltipExtra = format(L.BLOCK_VALUE, BCS:GetBlockValue())
end
label:SetText(L.BLOCK_COLON)
text:SetText(format("%.2f%%", blockChance))
statFrame.tooltip = L.PLAYER_BLOCK_TOOLTIP
statFrame.tooltipSubtext = L.PLAYER_BLOCK_TOOLTIP_SUB
statFrame.tooltipExtra = tooltipExtra
AddTooltip(statFrame)
end
function BCS:SetTotalAvoidance(statFrame, leveldiff)
local text = statFrame.StatText
local label = statFrame.Label
-- apply skill modifier
local base, mod = UnitDefense("player")
local skillDiff = base + mod - (UnitLevel("player") * 5)
local missChance = 5 + (skillDiff * 0.04)
local block = BCS:GetEffectiveBlockChance(leveldiff)
local parry = BCS:GetEffectiveParryChance(leveldiff)
local dodge = BCS:GetEffectiveDodgeChance(leveldiff)
local total = missChance + (block + parry + dodge)
if total < 0 then
total = 0
end
label:SetText(L.TOTAL_COLON)
text:SetText(format("%.2f%%", total))
statFrame.tooltip = L.TOTAL_AVOIDANCE_TOOLTIP
statFrame.tooltipSubtext = L.TOTAL_AVOIDANCE_TOOLTIP_SUB
AddTooltip(statFrame)
end
function BCS:SetDefense(statFrame)
local label = statFrame.Label
local text = statFrame.StatText
local base, modifier = UnitDefense("player")
local posBuff = 0
local negBuff = 0
label:SetText(DEFENSE_COLON)
if (modifier > 0) then
posBuff = modifier
elseif (modifier < 0) then
negBuff = modifier
end
PaperDollFormatStat(DEFENSE_COLON, base, posBuff, negBuff, statFrame, text)
statFrame.tooltip = L.DEFENSE_TOOLTIP
statFrame.tooltipSubtext = L.DEFENSE_TOOLTIP_SUB
AddTooltip(statFrame)
end
function BCS:SetRangedDamage(statFrame)
local label = statFrame.Label
local damageText = statFrame.StatText
label:SetText(DAMAGE_COLON)
-- If no ranged attack then set to n/a
if UnitHasRelicSlot("player") or not GetInventoryItemLink("player", 18) then
damageText:SetText(NOT_APPLICABLE)
statFrame.damage = nil
return
end
AddDamageTooltip(damageText, statFrame, nil, nil, true)
end
function BCS:SetRangedAttackSpeed(statFrame)
local label = statFrame.Label
local damageText = statFrame.StatText
label:SetText(SPEED .. ":")
-- If no ranged attack then set to n/a
if UnitHasRelicSlot("player") or not GetInventoryItemLink("player", 18) then
damageText:SetText(NOT_APPLICABLE)
statFrame.damage = nil
return
end
AddDamageTooltip(damageText, statFrame, nil, nil, true)
damageText:SetText(format("%.2f", (UnitRangedDamage("player"))))
end
function BCS:SetRangedAttackPower(statFrame)
local text = statFrame.StatText
local label = statFrame.Label
label:SetText(ATTACK_POWER_COLON)
-- If no ranged attack then set to n/a
if UnitHasRelicSlot("player") or not GetInventoryItemLink("player", 18) then
text:SetText(NOT_APPLICABLE)
return
end
if HasWandEquipped() then
text:SetText("--")
return
end
local base, posBuff, negBuff = UnitRangedAttackPower("player")
PaperDollFormatStat(RANGED_ATTACK_POWER, base, posBuff, negBuff, statFrame, text)
statFrame.tooltipSubtext = format(RANGED_ATTACK_POWER_TOOLTIP, max((base + posBuff + negBuff), 0) / ATTACK_POWER_MAGIC_NUMBER)
AddTooltip(statFrame)
end