Files

651 lines
29 KiB
Lua

-- Equip Compare Adv: what each stat is worth to each spec.
--
-- Every spec has weights for the stats that do the work: attack power, crit, hit, spell damage, health...
-- Strength, Agility, Stamina, Intellect and Spirit get their value from what they turn into for that
-- class (a warrior's Strength is 2 attack power, a rogue's Agility is attack power, crit and dodge), using
-- the 1.12 conversion rates scaled to your level. Melee specs count in attack power, casters in spell
-- damage, healers in healing, tanks in stamina, so scores only compare within one spec.
local ECA = EquipCompareAdv
ECA.ROLE_NAMES = {
tank = "Tank", melee = "DPS (melee)", ranged = "DPS (ranged)", caster = "DPS (caster)", healer = "Healer",
}
ECA.CLASS_ORDER = { "WARRIOR", "PALADIN", "HUNTER", "ROGUE", "PRIEST", "SHAMAN", "MAGE", "WARLOCK", "DRUID" }
ECA.CLASS_NAMES = {
WARRIOR = "Warrior", PALADIN = "Paladin", HUNTER = "Hunter", ROGUE = "Rogue", PRIEST = "Priest",
SHAMAN = "Shaman", MAGE = "Mage", WARLOCK = "Warlock", DRUID = "Druid",
}
ECA.CLASS_COLORS = {
WARRIOR = "|cffc79c6e", PALADIN = "|cfff58cba", HUNTER = "|cffabd473", ROGUE = "|cfffff569",
PRIEST = "|cffffffff", SHAMAN = "|cff0070de", MAGE = "|cff69ccf0", WARLOCK = "|cff9482c9", DRUID = "|cffff7d0a",
}
-- How primary stats convert at level 60. agiCrit / agiDodge / intCrit = points needed for 1%.
-- spiMP5 = mana per 5 sec from 1 Spirit while regenerating.
local CONV = {
WARRIOR = { strAP = 2, agiAP = 0, agiRAP = 0, agiCrit = 20, agiDodge = 20, intCrit = 0, spiMP5 = 0, strBlock = 0.05 },
PALADIN = { strAP = 2, agiAP = 0, agiRAP = 0, agiCrit = 20, agiDodge = 20, intCrit = 54, spiMP5 = 0.5, strBlock = 0.05 },
HUNTER = { strAP = 1, agiAP = 1, agiRAP = 2, agiCrit = 53, agiDodge = 26.5, intCrit = 0, spiMP5 = 0.5, strBlock = 0 },
ROGUE = { strAP = 1, agiAP = 1, agiRAP = 0, agiCrit = 29, agiDodge = 14.5, intCrit = 0, spiMP5 = 0, strBlock = 0 },
PRIEST = { strAP = 1, agiAP = 0, agiRAP = 0, agiCrit = 20, agiDodge = 20, intCrit = 59.2, spiMP5 = 0.625, strBlock = 0 },
SHAMAN = { strAP = 2, agiAP = 0, agiRAP = 0, agiCrit = 20, agiDodge = 20, intCrit = 59.5, spiMP5 = 0.5, strBlock = 0.05 },
MAGE = { strAP = 1, agiAP = 0, agiRAP = 0, agiCrit = 20, agiDodge = 20, intCrit = 59.5, spiMP5 = 0.625, strBlock = 0 },
WARLOCK = { strAP = 1, agiAP = 0, agiRAP = 0, agiCrit = 20, agiDodge = 20, intCrit = 60.6, spiMP5 = 0.5, strBlock = 0 },
DRUID = { strAP = 2, agiAP = 0, agiRAP = 0, agiCrit = 20, agiDodge = 20, intCrit = 60, spiMP5 = 0.5, strBlock = 0 },
}
-- Shared weight sets. Melee and ranged count in attack power, casters in spell damage, healers in
-- healing, tanks in stamina.
local function Melee(extra)
local w = { AP = 1, CRIT = 29, HIT = 28, HASTE = 19, WEAPONSKILL = 11, ARMORPEN = 0.25, DPS = 14,
HEALTH = 0.02, ARMOR = 0.01, DODGE = 1, PARRY = 1, DEFENSE = 0.2 }
for k, v in pairs(extra or {}) do w[k] = v end
return w
end
local function Tank(extra)
local w = { HEALTH = 0.12, ARMOR = 0.1, DEFENSE = 1.7, DODGE = 12, PARRY = 13, BLOCK = 5, BLOCKVALUE = 0.5,
AP = 0.35, HIT = 8, CRIT = 5, DPS = 4, WEAPONSKILL = 5, HP5 = 0.5, HASTE = 4,
FIRERES = 0.15, NATURERES = 0.15, FROSTRES = 0.15, SHADOWRES = 0.15, ARCANERES = 0.15 }
for k, v in pairs(extra or {}) do w[k] = v end
return w
end
local function Caster(extra)
local w = { SP = 1, SPELLCRIT = 10, SPELLHIT = 12, SPELLPEN = 0.3, HASTE = 10, MP5 = 1, MANA = 0.02,
HEALTH = 0.01, ARMOR = 0.005 }
for k, v in pairs(extra or {}) do w[k] = v end
return w
end
local function Healer(extra)
local w = { HEAL = 1, SPELLCRIT = 4, HASTE = 8, MP5 = 3, MANA = 0.035, HEALTH = 0.01, ARMOR = 0.005 }
for k, v in pairs(extra or {}) do w[k] = v end
return w
end
-- tabs = talent trees that pick this spec when "auto" is on. spirit = share of Spirit regeneration that
-- really happens in a fight. feral = "attack power in forms" counts. wand = wand DPS matters while
-- leveling. no2H / noShield = two-handers / shields are never "made for" this spec.
ECA.SPECS = {
WARRIOR = {
{ key = "arms", name = "Arms", role = "melee", tabs = { 1 }, noShield = true, w = Melee({ CRIT = 30, HIT = 30 }), slowMH = true },
{ key = "fury", name = "Fury", role = "melee", tabs = { 2 }, noShield = true, w = Melee({ CRIT = 32, HIT = 30, HASTE = 21 }), slowMH = true },
-- OctoWow: Shield Slam's damage is modified by your shield block value, so it is worth more here.
{ key = "prot", name = "Protection", role = "tank", tabs = { 3 }, no2H = true, w = Tank({ BLOCKVALUE = 0.8 }) },
},
PALADIN = {
-- Turtle: Ironclad gives healing power equal to up to 2% of the armor on your items.
{ key = "holy", name = "Holy", role = "healer", tabs = { 1 }, spirit = 0.1,
w = Healer({ SPELLCRIT = 12, MANA = 0.04, ARMOR = 0.02 }) },
-- Turtle: Crusader Strike, Holy Strike, Holy Shield and Bulwark of the Righteous all add spell power
-- damage (33-43%), so Spell Power is worth more to Protection (0.5 -> 0.7) and Retribution (0.35 -> 0.5).
{ key = "prot", name = "Protection", role = "tank", tabs = { 2 }, no2H = true,
w = Tank({ SP = 0.7, MANA = 0.015, BLOCKVALUE = 0.6, MP5 = 1 }) },
{ key = "ret", name = "Retribution", role = "melee", tabs = { 3 }, slowMH = true, noShield = true,
w = Melee({ CRIT = 27, HIT = 26, HASTE = 18, WEAPONSKILL = 10, SP = 0.5, SPELLCRIT = 2, MANA = 0.01 }) },
},
HUNTER = {
{ key = "hunter", name = "Hunter", role = "ranged", tabs = { 1, 2 },
w = { RAP = 1, AP = 0.05, CRIT = 30, HIT = 30, HASTE = 15, RDPS = 14, DPS = 0.3, MP5 = 1.5, MANA = 0.01,
HEALTH = 0.02, ARMOR = 0.01, WEAPONSKILL = 2 } },
-- Turtle: Survival is a melee hunter (Raptor Strike, Mongoose Bite, Carve) and Lightning Reflexes turns
-- up to 100% of your Agility into melee attack power, so Agility counts twice as much attack power.
{ key = "surv", name = "Survival (melee)", role = "melee", tabs = { 3 }, agiAP = 2,
w = Melee({ CRIT = 28, HIT = 26, HASTE = 15, WEAPONSKILL = 8, MP5 = 1.2, MANA = 0.01 }) },
},
ROGUE = {
{ key = "rogue", name = "Rogue", role = "melee", tabs = { 1, 2, 3 }, slowMH = true,
w = Melee({ CRIT = 28, HIT = 28, HASTE = 20, WEAPONSKILL = 12 }) },
},
PRIEST = {
-- OctoWow: Discipline is a damage tree (Chastise, Enlighten, Starshards, Searing Shot), so it
-- scores like a Holy-damage caster; vanilla's "Holy / Discipline" healer is Holy alone.
{ key = "disc", name = "Discipline", role = "caster", tabs = { 1 }, spirit = 0.3, wand = true,
w = Caster({ HOLYDMG = 1, SHADOWDMG = 0.1, SPELLCRIT = 8, MP5 = 1.2, MANA = 0.03 }) },
{ key = "holy", name = "Holy", role = "healer", tabs = { 2 }, spirit = 0.35, wand = true,
w = Healer() },
{ key = "shadow", name = "Shadow", role = "caster", tabs = { 3 }, spirit = 0.25, wand = true,
w = Caster({ SHADOWDMG = 1, SPELLCRIT = 5, HOLYDMG = 0.1 }) },
},
SHAMAN = {
{ key = "ele", name = "Elemental", role = "caster", tabs = { 1 }, spirit = 0.1,
w = Caster({ NATUREDMG = 1, FIREDMG = 0.15, FROSTDMG = 0.15, SPELLCRIT = 11, MP5 = 1.2, MANA = 0.025 }) },
{ key = "enh", name = "Enhancement", role = "melee", tabs = { 2 }, slowMH = true, noShield = true,
w = Melee({ CRIT = 28, HIT = 26, HASTE = 18, WEAPONSKILL = 10, SP = 0.3, MANA = 0.01 }) },
{ key = "resto", name = "Restoration", role = "healer", tabs = { 3 }, spirit = 0.1,
w = Healer({ SPELLCRIT = 5 }) },
},
MAGE = {
-- Turtle: Arcane was reworked around casting speed (Accelerated Arcana, Arcane Power) and Arcane Rupture /
-- Surge / Missiles scale well with spell power, so haste counts a bit more (10 -> 14).
{ key = "arcane", name = "Arcane", role = "caster", tabs = { 1 }, spirit = 0.3, wand = true,
w = Caster({ ARCANEDMG = 1, FIREDMG = 0.3, FROSTDMG = 0.3, SPELLCRIT = 9, MANA = 0.03, HASTE = 14 }) },
{ key = "fire", name = "Fire", role = "caster", tabs = { 2 }, spirit = 0.2, wand = true,
w = Caster({ FIREDMG = 1, FROSTDMG = 0.2, ARCANEDMG = 0.2, SPELLCRIT = 11 }) },
{ key = "frost", name = "Frost", role = "caster", tabs = { 3 }, spirit = 0.2, wand = true,
w = Caster({ FROSTDMG = 1, FIREDMG = 0.2, ARCANEDMG = 0.2, SPELLCRIT = 9 }) },
},
WARLOCK = {
{ key = "shadow", name = "Shadow", role = "caster", tabs = { 1, 2, 3 }, spirit = 0.05, wand = true,
w = Caster({ SHADOWDMG = 1, FIREDMG = 0.15, SPELLCRIT = 9, HEALTH = 0.03, MP5 = 0.5 }) },
{ key = "fire", name = "Fire", role = "caster", tabs = {}, spirit = 0.05, wand = true,
w = Caster({ FIREDMG = 1, SHADOWDMG = 0.3, SPELLCRIT = 10, HEALTH = 0.03, MP5 = 0.5 }) },
},
DRUID = {
-- Turtle/Octo: Moonkin Form raises the armor from your items by 180% (from level 30) and 360% (from
-- level 40), so armor counts about 4.6 times as much as it does for other casters at 60 (0.005 -> 0.025).
{ key = "balance", name = "Balance", role = "caster", tabs = { 1 }, spirit = 0.2,
w = Caster({ ARCANEDMG = 0.7, NATUREDMG = 0.6, MP5 = 1.2, MANA = 0.025, ARMOR = 0.025 }) },
{ key = "cat", name = "Feral (Cat)", role = "melee", tabs = { 2 }, feral = true, agiAP = 1,
w = Melee({ CRIT = 28, HIT = 24, HASTE = 15, DPS = 0, WEAPONSKILL = 0, MANA = 0.005 }) },
{ key = "bear", name = "Feral (Bear)", role = "tank", tabs = {}, feral = true,
w = Tank({ ARMOR = 0.3, DEFENSE = 1.2, PARRY = 0, BLOCK = 0, BLOCKVALUE = 0, DPS = 0, WEAPONSKILL = 0 }) },
{ key = "resto", name = "Restoration", role = "healer", tabs = { 3 }, spirit = 0.35,
w = Healer({ SPELLCRIT = 3 }) },
},
}
------------------------------------------------------------------------------------------------------
-- Which spec, and its numbers
------------------------------------------------------------------------------------------------------
local cache = {}
function ECA.InvalidateProfiles()
cache = {}
end
-- The hit cap depends on whether you're dual wielding, so new gear means a fresh look.
function ECA.InvalidateCaps()
cache.caps = nil
end
local function Level()
local level = UnitLevel("player") or 60
if level < 1 then level = 60 end
return level
end
local function FindSpec(class, key)
local specs = ECA.SPECS[class]
for i = 1, table.getn(specs) do
if specs[i].key == key then return specs[i] end
end
return nil
end
-- The talent tree with the most points picks the spec.
local function DetectSpec(class)
local specs = ECA.SPECS[class]
local bestTab, bestPoints = nil, 0
if GetNumTalentTabs then
for tab = 1, (GetNumTalentTabs() or 0) do
local _, _, points = GetTalentTabInfo(tab)
if points and points > bestPoints then bestTab, bestPoints = tab, points end
end
end
if bestTab then
for i = 1, table.getn(specs) do
local tabs = specs[i].tabs
for j = 1, table.getn(tabs) do
if tabs[j] == bestTab then return specs[i] end
end
end
end
return specs[1]
end
local function TalentPoints()
local total = 0
if GetNumTalentTabs then
for tab = 1, (GetNumTalentTabs() or 0) do
local _, _, points = GetTalentTabInfo(tab)
total = total + (points or 0)
end
end
return total
end
-- Right after logging in or a /reload the game can report no talent points at all. A character past
-- level 10 with none is more likely that than a real blank sheet, so look again every couple of seconds
-- for a while before believing it.
local recheck = CreateFrame("Frame")
recheck:Hide()
recheck.elapsed, recheck.tries = 0, 0
recheck:SetScript("OnUpdate", function()
this.elapsed = this.elapsed + arg1
if this.elapsed < 2 then return end
this.elapsed = 0
this.tries = this.tries + 1
if TalentPoints() > 0 then
this:Hide()
ECA.SettingsChanged()
elseif this.tries >= 15 then
this:Hide()
end
end)
-- The spec being scored for, and whether it came from the talents.
function ECA.Spec()
if not cache.spec then
local class = ECA.class
local spec = ECA.char.spec ~= "auto" and FindSpec(class, ECA.char.spec)
if spec then
cache.spec, cache.specAuto = spec, false
else
cache.spec, cache.specAuto = DetectSpec(class), true
if Level() >= 10 and recheck.tries < 15 and TalentPoints() == 0 then recheck:Show() end
end
end
return cache.spec, cache.specAuto
end
function ECA.SpecLabel()
local spec, auto = ECA.Spec()
local label = spec.name
if label ~= ECA.CLASS_NAMES[ECA.class] then label = ECA.CLASS_NAMES[ECA.class] .. " - " .. label end
if auto then label = label .. " (auto)" end
local other = ECA.LevelingMix()
if other then label = label .. " + " .. other.name .. " while leveling" end
return label
end
local PERCENT_STATS = { "CRIT", "HIT", "HASTE", "SPELLCRIT", "SPELLHIT", "DODGE", "PARRY", "BLOCK" }
-- A spec's weights with the player's own changes on top.
local function BuildWeights(class, spec, custom, level)
local w = {}
for k, v in pairs(spec.w) do w[k] = v end
-- 1% of a level 20's damage is a much smaller number than 1% of a level 60's, so the percent stats
-- shrink with level. It also keeps Agility honest: a point gives more crit at low level, but each
-- percent is worth less, and the two cancel out.
if level < 60 then
local f = level / 60
if f < 0.2 then f = 0.2 end
for i = 1, table.getn(PERCENT_STATS) do
local k = PERCENT_STATS[i]
if w[k] then w[k] = w[k] * f end
end
end
-- On the way to 60 you fight alone, so staying alive is worth more to a damage spec or a healer than
-- it is in a raid: a little extra for health and armor that fades out by 60.
if level < 60 and spec.role ~= "tank" then
local young = 1 - level / 60
w.HEALTH = (w.HEALTH or 0) + 0.07 * young
w.ARMOR = (w.ARMOR or 0) + 0.03 * young
end
-- A wand is most of a leveling caster's damage and none of a level 60's.
if spec.wand and level < 60 then w.RDPS = 4 * (1 - level / 60) end
if custom then
for k, v in pairs(custom) do w[k] = v end
end
return w
end
-- Points for 1 of each stat as it appears on an item.
local function BuildUnits(class, spec, w, level)
local c = CONV[class]
local f = level / 60
if f < 0.2 then f = 0.2 elseif f > 1 then f = 1 end
local function W(k) return w[k] or 0 end
local u = {}
for k, v in pairs(w) do u[k] = v end
local agiAP = spec.agiAP or c.agiAP
u.STR = W("STR") + c.strAP * W("AP") + c.strBlock * W("BLOCKVALUE")
u.AGI = W("AGI") + agiAP * W("AP") + c.agiRAP * W("RAP") + W("CRIT") / (c.agiCrit * f) +
W("DODGE") / (c.agiDodge * f) + 2 * W("ARMOR")
u.STA = W("STA") + 10 * W("HEALTH")
u.INT = W("INT") + 15 * W("MANA")
if c.intCrit > 0 then u.INT = u.INT + W("SPELLCRIT") / (c.intCrit * f) end
u.SPI = W("SPI") + c.spiMP5 * (spec.spirit or 0.15) * W("MP5")
u.AP = W("AP") + W("RAP") -- attack power on gear is ranged attack power too
u.FERALAP = W("FERALAP")
if spec.feral then u.FERALAP = u.FERALAP + W("AP") end
u.SP = W("SP") + W("HEAL") -- "damage and healing" is healing too
return u
end
function ECA.Weights()
if not cache.weights then
local spec = ECA.Spec()
cache.weights = BuildWeights(ECA.class, spec, ECA.char.custom[spec.key], Level())
end
return cache.weights
end
function ECA.DefaultWeights()
return BuildWeights(ECA.class, ECA.Spec(), nil, Level())
end
-- Healers and tanks still have to kill things on the way to 60, so until then their class's damage
-- spec is mixed into the score: almost all of it at level 10, none of it at 60.
local LEVELING_SPEC = { WARRIOR = "arms", PALADIN = "ret", PRIEST = "shadow", SHAMAN = "enh", DRUID = "cat" }
-- The damage spec being mixed in, and its share of the score (0..1). nil when nothing is mixed in.
function ECA.LevelingMix()
local spec, level = ECA.Spec(), Level()
if not ECA.db.levelingMix or level >= 60 then return nil, 0 end
if spec.role ~= "tank" and spec.role ~= "healer" then return nil, 0 end
local other = FindSpec(ECA.class, LEVELING_SPEC[ECA.class] or "")
if not other or other == spec then return nil, 0 end
return other, 1 - level / 60
end
-- The spec's name for the panel header: "Holy", or "Holy + leveling" while damage is mixed in.
function ECA.SpecShort()
local name = ECA.Spec().name
if ECA.LevelingMix() then name = name .. " + leveling" end
return name
end
function ECA.Units()
if not cache.units then
local level = Level()
local units = BuildUnits(ECA.class, ECA.Spec(), ECA.Weights(), level)
local other, share = ECA.LevelingMix()
if other then
local otherUnits = BuildUnits(ECA.class, other,
BuildWeights(ECA.class, other, ECA.char.custom[other.key], level), level)
local mixed = {}
for k, v in pairs(units) do mixed[k] = v * (1 - share) end
for k, v in pairs(otherUnits) do mixed[k] = (mixed[k] or 0) + v * share end
units = mixed
end
cache.units = units
end
return cache.units
end
-- One spec for each role this class can fill, for the "by role" verdicts: { spec, label }.
local ROLE_GOALS = { tank = "Tanking", healer = "Healing", melee = "Damage", ranged = "Damage", caster = "Damage" }
function ECA.RoleSpecs()
if not cache.roleSpecs then
local list, seen, damage = {}, {}, 0
local specs = ECA.SPECS[ECA.class]
for i = 1, table.getn(specs) do
local spec = specs[i]
if not seen[spec.role] then
seen[spec.role] = true
if ROLE_GOALS[spec.role] == "Damage" then damage = damage + 1 end
table.insert(list, { spec = spec, label = ROLE_GOALS[spec.role] })
end
end
-- druids and shamans deal damage two ways, so there the spec has to be named
for i = 1, table.getn(list) do
if list[i].label ~= "Damage" or damage > 1 then
list[i].label = list[i].label .. " (" .. list[i].spec.name .. ")"
end
end
cache.roleSpecs = list
end
return cache.roleSpecs
end
-- Points per stat for one spec on its own: no leveling mix, but with your changes to its weights.
function ECA.UnitsFor(spec)
local key = "role" .. spec.key
if not cache[key] then
local level = Level()
cache[key] = BuildUnits(ECA.class, spec, BuildWeights(ECA.class, spec, ECA.char.custom[spec.key], level), level)
end
return cache[key]
end
function ECA.PlayerLevel()
return Level()
end
-- What a set of stat changes turns into for this character: attack power, crit, armor, health...
function ECA.DerivedNumbers(d)
local spec = ECA.Spec()
local c = CONV[ECA.class]
local f = Level() / 60
if f < 0.2 then f = 0.2 elseif f > 1 then f = 1 end
local function D(k) return d[k] or 0 end
local n = {}
n.ap = D("AP") + D("STR") * c.strAP + D("AGI") * (spec.agiAP or c.agiAP)
if spec.feral then n.ap = n.ap + D("FERALAP") end
n.rap = D("AP") + D("RAP") + D("AGI") * c.agiRAP
n.crit = D("CRIT") + D("AGI") / (c.agiCrit * f)
n.dodge = D("DODGE") + D("AGI") / (c.agiDodge * f)
n.armor = D("ARMOR") + D("AGI") * 2
n.health = D("HEALTH") + D("STA") * 10
n.mana = D("MANA") + D("INT") * 15
n.spellCrit = D("SPELLCRIT")
if c.intCrit > 0 then n.spellCrit = n.spellCrit + D("INT") / (c.intCrit * f) end
n.healing = D("SP") + D("HEAL")
-- spell damage: the all-schools kind, plus the schools this spec really casts
n.spell = D("SP")
local w = ECA.Weights()
local schools = { "SHADOWDMG", "FIREDMG", "FROSTDMG", "ARCANEDMG", "NATUREDMG", "HOLYDMG" }
for i = 1, 6 do
if (w[schools[i]] or 0) >= 0.5 then n.spell = n.spell + D(schools[i]) end
end
return n
end
function ECA.SetWeight(stat, value)
local spec = ECA.Spec()
local custom = ECA.char.custom
if type(custom[spec.key]) ~= "table" then custom[spec.key] = {} end
custom[spec.key][stat] = value
ECA.SettingsChanged()
end
function ECA.ResetWeights()
ECA.char.custom[ECA.Spec().key] = nil
ECA.SettingsChanged()
end
------------------------------------------------------------------------------------------------------
-- Caps: hit (and a tank's defense) stops being worth much once you have enough of it
------------------------------------------------------------------------------------------------------
local MELEE_HIT_TALENTS = { ["Precision"] = 1, ["Surefooted"] = 1, ["Nature's Guidance"] = 1 }
local SPELL_HIT_TALENTS = { ["Elemental Precision"] = 2, ["Arcane Focus"] = 2, ["Shadow Focus"] = 2,
["Suppression"] = 2, ["Nature's Guidance"] = 1 }
-- Hit % from talents: melee/ranged, spell (the best single spell talent, as they cover one school each).
function ECA.TalentHit()
if not cache.talentHit then
local melee, spell = 0, 0
if GetNumTalentTabs and GetNumTalents and GetTalentInfo then
for tab = 1, (GetNumTalentTabs() or 0) do
for i = 1, (GetNumTalents(tab) or 0) do
local name, _, _, _, rank = GetTalentInfo(tab, i)
if name and rank and rank > 0 then
if MELEE_HIT_TALENTS[name] then melee = melee + rank * MELEE_HIT_TALENTS[name] end
if SPELL_HIT_TALENTS[name] and rank * SPELL_HIT_TALENTS[name] > spell then
spell = rank * SPELL_HIT_TALENTS[name]
end
end
end
end
end
cache.talentHit = { melee = melee, spell = spell }
end
return cache.talentHit.melee, cache.talentHit.spell
end
function ECA.CapMode()
local mode = ECA.db.capMode
if mode == "auto" then
if Level() >= 60 then mode = "raid" else mode = "leveling" end
end
return mode
end
-- { STAT = { cap = from gear, over = share of the value kept past the cap } }
function ECA.Caps()
if not cache.caps then
local caps = {}
local mode = ECA.CapMode()
if mode ~= "off" then
local role = ECA.Spec().role
local raid = (mode == "raid")
local meleeTalents, spellTalents = ECA.TalentHit()
if role == "caster" then
local cap = (raid and 16 or 3) - spellTalents - ECA.char.extraSpellHit
if cap < 0 then cap = 0 end
caps.SPELLHIT = { cap = cap, over = 0 }
elseif role ~= "healer" then
-- Special attacks cap at 9% against a raid boss, 5% against things your own level. Past that, hit
-- only helps the white swings of someone dual wielding.
local cap = (raid and 9 or 5) - meleeTalents - ECA.char.extraHit
if cap < 0 then cap = 0 end
local over = 0
if role ~= "ranged" and ECA.IsDualWielding and ECA.IsDualWielding() then over = 0.5 end
caps.HIT = { cap = cap, over = over }
end
if role == "tank" and raid then
caps.DEFENSE = { cap = 140, over = 0.5 } -- 440 defense: no more crushing crits from bosses
end
end
cache.caps = caps
end
return cache.caps
end
------------------------------------------------------------------------------------------------------
-- Who is this item made for?
------------------------------------------------------------------------------------------------------
-- Roughly what each stat costs out of an item's budget in 1.12 itemization. Weapon DPS and armor come
-- with the slot rather than the budget, so they stay out.
local BUDGET = {
STR = 1, AGI = 1, STA = 1, INT = 1, SPI = 1, AP = 0.5, RAP = 0.4, FERALAP = 0.15, CRIT = 14, HIT = 10, SPELLCRIT = 14,
SPELLHIT = 8, DODGE = 12, PARRY = 20, BLOCK = 5, BLOCKVALUE = 0.65, DEFENSE = 1.5, SP = 0.86, HEAL = 0.45,
SHADOWDMG = 0.7, FIREDMG = 0.7, FROSTDMG = 0.7, ARCANEDMG = 0.7, NATUREDMG = 0.7, HOLYDMG = 0.7,
MP5 = 2.5, HP5 = 1, HEALTH = 0.07, MANA = 0.07, HASTE = 10, SPELLPEN = 0.8, WEAPONSKILL = 1.2, ARMORPEN = 0.1,
FIRERES = 1, NATURERES = 1, FROSTRES = 1, SHADOWRES = 1, ARCANERES = 1,
}
-- The everyday stats a spec's "best case" is measured against.
local NORM_STATS = { "STR", "AGI", "STA", "INT", "SPI", "AP", "RAP", "CRIT", "HIT", "SPELLCRIT", "SPELLHIT",
"DODGE", "PARRY", "BLOCKVALUE", "DEFENSE", "SP", "HEAL", "SHADOWDMG", "FIREDMG", "FROSTDMG", "ARCANEDMG",
"NATUREDMG", "MP5" }
-- Stats that mark an item as tank gear (with Stamina, which is counted apart).
local TANK_STATS = { DEFENSE = true, DODGE = true, PARRY = true, BLOCK = true, BLOCKVALUE = true, HEALTH = true,
HP5 = true, FIRERES = true, NATURERES = true, FROSTRES = true, SHADOWRES = true, ARCANERES = true }
local ARMOR_RANK = { Cloth = 1, Leather = 2, Mail = 3, Plate = 4 }
local CLASS_ARMOR = { WARRIOR = 4, PALADIN = 4, HUNTER = 3, SHAMAN = 3, ROGUE = 2, DRUID = 2, PRIEST = 1, MAGE = 1, WARLOCK = 1 }
local SHIELD_CLASSES = { WARRIOR = true, PALADIN = true, SHAMAN = true }
local DUAL_WIELD = { WARRIOR = true, ROGUE = true, HUNTER = true }
local RELIC_CLASS = { Libram = "PALADIN", Idol = "DRUID", Totem = "SHAMAN" }
local WEAPONS = {
WARRIOR = { Axe = 2, Sword = 2, Mace = 2, Dagger = 1, ["Fist Weapon"] = 1, Polearm = 2, Staff = 2, Bow = 1, Gun = 1, Crossbow = 1, Thrown = 1 },
PALADIN = { Axe = 2, Sword = 2, Mace = 2, Polearm = 2 },
HUNTER = { Axe = 2, Sword = 2, Dagger = 1, ["Fist Weapon"] = 1, Polearm = 2, Staff = 2, Bow = 1, Gun = 1, Crossbow = 1, Thrown = 1 },
ROGUE = { Sword = 1, Mace = 1, Dagger = 1, ["Fist Weapon"] = 1, Bow = 1, Gun = 1, Crossbow = 1, Thrown = 1 },
PRIEST = { Mace = 1, Dagger = 1, Staff = 2, Wand = 1 },
SHAMAN = { Axe = 2, Mace = 2, Dagger = 1, ["Fist Weapon"] = 1, Staff = 2 },
MAGE = { Sword = 1, Dagger = 1, Staff = 2, Wand = 1 },
WARLOCK = { Sword = 1, Dagger = 1, Staff = 2, Wand = 1 },
DRUID = { Mace = 2, Dagger = 1, ["Fist Weapon"] = 1, Staff = 2 },
} -- 1 = one-handed only, 2 = two-handed as well
local function CanUse(class, item)
if item.classes and not string.find(item.classes, string.lower(ECA.CLASS_NAMES[class]), 1, true) then
return false
end
local sub = item.subType
if not sub then return true end
if ARMOR_RANK[sub] then return ARMOR_RANK[sub] <= CLASS_ARMOR[class] end
if sub == "Shield" then return SHIELD_CLASSES[class] or false end
if RELIC_CLASS[sub] then return RELIC_CLASS[sub] == class end
local skill = WEAPONS[class][sub]
if not skill then return false end
if item.kind == "TWOHAND" and skill < 2 then return false end
if item.kind == "OFFHAND" and not DUAL_WIELD[class] then return false end
return true
end
ECA.CanUse = CanUse -- the upgrade arrows skip items your class can never wear
-- Units and the "best case" value per budget point for any class and spec, at the player's level.
local function FitProfile(class, spec)
local key = "fit" .. class .. spec.key
if not cache[key] then
local level = Level()
local units = BuildUnits(class, spec, BuildWeights(class, spec, nil, level), level)
local top = {}
for i = 1, table.getn(NORM_STATS) do
local k = NORM_STATS[i]
table.insert(top, (units[k] or 0) / BUDGET[k])
end
table.sort(top, function(a, b) return a > b end)
local norm = (top[1] + top[2] + top[3]) / 3
if norm <= 0 then norm = 1 end
cache[key] = { units = units, norm = norm }
end
return cache[key]
end
-- How well the item's stat budget is spent for every spec that can use it, best first.
-- Stamina is on nearly everything, so it only counts for tanks; for everyone else it is left out of both
-- sides. Returns nil for items with no real stats to judge (white weapons, plain armor).
-- Also sets item.myFit (0..1) for the player's own spec, or item.notMyClass when the class can't use it.
function ECA.Fits(item)
if item.fits ~= nil then return item.fits or nil end
item.fits = false
local stats = item.stats
local budget, stamina, tankBudget = 0, 0, 0
for k, v in pairs(stats) do
if k == "STA" then
stamina = math.abs(v)
elseif BUDGET[k] then
budget = budget + math.abs(v) * BUDGET[k]
if TANK_STATS[k] then tankBudget = tankBudget + math.abs(v) * BUDGET[k] end
end
end
if budget + stamina < 3 then return nil end
local mainArmor = type(item.kind) == "number" and item.subType and ARMOR_RANK[item.subType]
local mySpec = ECA.Spec()
local mixSpec, mixShare = ECA.LevelingMix()
local mixFit
local fits = {}
if not CanUse(ECA.class, item) then item.notMyClass = true end
for c = 1, table.getn(ECA.CLASS_ORDER) do
local class = ECA.CLASS_ORDER[c]
if CanUse(class, item) then
local specs = ECA.SPECS[class]
for i = 1, table.getn(specs) do
local spec = specs[i]
local suits = not ((spec.no2H and item.kind == "TWOHAND") or (spec.noShield and item.subType == "Shield"))
local profile = FitProfile(class, spec)
local tank = (spec.role == "tank")
local value, cost = 0, budget
for k, v in pairs(stats) do
if BUDGET[k] and (tank or k ~= "STA") then value = value + v * (profile.units[k] or 0) end
end
if tank then cost = cost + stamina end
local raw = 0
if suits and cost > 0 then raw = value / (cost * profile.norm) end
-- A tank can use Agility or Strength, but gear is only made for tanks when it carries tank
-- stats: stamina, defense, dodge, parry, block.
if tank and cost > 0 then raw = raw * (0.55 + 0.45 * (tankBudget + stamina) / cost) end
-- Classes mostly want their own armor type: plate wearers skip leather unless it is special.
if mainArmor and mainArmor < CLASS_ARMOR[class] then raw = raw * 0.88 end
local fit = raw
if fit > 1 then fit = 1 elseif fit < 0 then fit = 0 end
if class == ECA.class and spec == mySpec then item.myFit = fit end
if class == ECA.class and spec == mixSpec then mixFit = fit end
if raw > 0 then
table.insert(fits, { class = class, spec = spec, role = spec.role, fit = fit, raw = raw })
end
end
end
end
-- while a damage spec is mixed into the score, it is mixed into "fit for your spec" the same way
if mixSpec and item.myFit then item.myFit = item.myFit * (1 - mixShare) + (mixFit or 0) * mixShare end
table.sort(fits, function(a, b) return a.raw > b.raw end)
item.fits = fits
return fits
end