Thread Tools Display Modes
04-02-16, 10:16 AM   #1
klala
A Kobold Labourer
Join Date: Apr 2016
Posts: 1
Need help fixing an addon for 3.3.5

Hi everyone so I am playing on a 3.3.5 client and I am using "rating buster" addon (version 1.5 r284)
The addon works fine... until I try to get it to calculate dodge from agility for a certain level.

The addon calculates dodge from agility correctly for all levels
But when I go to the interface settings and set it to calculate a certain level, it doesn't show the dodge chance at all. It will show the dodge chance only if I set it to my level.

So I was trying to see if I can fix it myself and went into it's lua file to take a look and I found this line:
Lua Code:
  1. if profileDB.showDodgeFromAgi and (calcLevel == playerLevel) then
  2.                             local effect = StatLogic:GetDodgeFromAgi(value)
  3.                             if profileDB.enableAvoidanceDiminishingReturns then
  4.                                 local effectNoDR = effect
  5.                                 effect = StatLogic:GetAvoidanceGainAfterDR("DODGE", processedDodge + effect) - StatLogic:GetAvoidanceGainAfterDR("DODGE", processedDodge)
  6.                                 processedDodge = processedDodge + effectNoDR
  7.                             end
  8.                             if effect > 0 then
  9.                                 tinsert(infoTable, (gsub(L["$value% Dodge"], "$value", format("%+.2f", effect))))
  10.                             end
  11.                         else
  12.                             local effect = StatLogic:GetDodgeFromAgi(value)
  13.                             processedDodge = processedDodge + effect
  14.                         end
So after tweaking with it for a while I got it to show the dodge when I select a certain level and it looks like this:
Lua Code:
  1. if profileDB.showDodgeFromAgi then
  2.                             local effect = StatLogic:GetDodgeFromAgi(value, class, calcLevel)
  3.                             if profileDB.enableAvoidanceDiminishingReturns then
  4.                                 local effectNoDR = effect
  5.                                 effect = StatLogic:GetAvoidanceGainAfterDR("DODGE", processedDodge + effect) - StatLogic:GetAvoidanceGainAfterDR("DODGE", processedDodge)
  6.                                 processedDodge = processedDodge + effectNoDR
  7.                             end
  8.                             if effect > 0 then
  9.                                 tinsert(infoTable, (gsub(L["$value% Dodge"], "$value", format("%+.2f", effect))))
  10.                             end
  11.                             else
  12.                             local effect = StatLogic:GetDodgeFromAgi(value, class, calcLevel)
  13.                             processedDodge = processedDodge + effect
  14.                             if effect > 0 then
  15.                                 tinsert(infoTable, (gsub(L["$value% Dodge"], "$value", format("%+.2f", effect))))
  16.                             end

But when I did that and tried to set different certain levels it just show the dodge coming from agility like it's my level.
In short what needs to happen is the addon should show the dodge chance coming from agility and calculate the dodge chance if I set a certain level in the addon's settings.
Right now it shows the dodge chance from agility but when I set it to a different level it shows the same value as my character's level.

Here's the original code:
Lua Code:
  1. --[[
  2. Name: RatingBuster
  3. Description: Converts combat ratings in tooltips into normal percentages.
  4. Revision: $Revision: 284 $
  5. Author: Whitetooth
  6. Email: hotdogee [at] gmail [dot] com
  7. LastUpdate: $Date: 2010-04-28 03:39:19 +0000 (Wed, 28 Apr 2010) $
  8. ]]
  9.  
  10. ---------------
  11. -- Libraries --
  12. ---------------
  13. local AceConfig = LibStub("AceConfig-3.0")
  14. local AceConfigDialog = LibStub("AceConfigDialog-3.0")
  15. local AceConfigRegistry = LibStub("AceConfigRegistry-3.0")
  16. local AceDB = LibStub("AceDB-3.0")
  17. local TipHooker = LibStub("LibTipHooker-1.1")
  18. local StatLogic = LibStub("LibStatLogic-1.1")
  19. local L = LibStub("AceLocale-3.0"):GetLocale("RatingBuster")
  20. local BI = LibStub("LibBabble-Inventory-3.0"):GetLookupTable()
  21.  
  22.  
  23. --------------------
  24. -- AceAddon Setup --
  25. --------------------
  26. -- AceAddon Initialization
  27. RatingBuster = LibStub("AceAddon-3.0"):NewAddon("RatingBuster", "AceConsole-3.0", "AceEvent-3.0")
  28. RatingBuster.version = "1.5.0 (r"..gsub("$Revision: 284 $", "$Revision: (%d+) %$", "%1")..")"
  29. RatingBuster.date = gsub("$Date: 2010-04-28 03:39:19 +0000 (Wed, 28 Apr 2010) $", "^.-(%d%d%d%d%-%d%d%-%d%d).-$", "%1")
  30.  
  31.  
  32. -----------
  33. -- Cache --
  34. -----------
  35. local cache = {}
  36. setmetatable(cache, {__mode = "kv"}) -- weak table to enable garbage collection
  37. local function clearCache()
  38.     for k in pairs(cache) do
  39.         cache[k] = nil
  40.     end
  41. end
  42. --debug
  43. --RatingBuster.cache = cache
  44.  
  45.  
  46. ---------------------
  47. -- Local Variables --
  48. ---------------------
  49. local _
  50. local _, class = UnitClass("player")
  51. local playerLevel = UnitLevel("player") or 80
  52. local calcLevel
  53. local profileDB -- Initialized in :OnInitialize()
  54. -- Cached GetItemInfo
  55. local GetItemInfo = StatLogic.GetItemInfo
  56. -- Localize globals
  57. local _G = getfenv(0)
  58. local strfind = strfind
  59. local strsub = strsub
  60. local gsub = gsub
  61. local pairs = pairs
  62. local ipairs = ipairs
  63. local type = type
  64. local select = select
  65. local tinsert = tinsert
  66. local tremove = tremove
  67. local tsort = table.sort
  68. local strsplit = strsplit
  69. local strjoin = strjoin
  70. local unpack = unpack
  71. local tonumber = tonumber
  72. local UnitStat = UnitStat
  73. local wowBuildNo = select(2, GetBuildInfo())
  74. local GetParryChance = GetParryChance
  75. local GetBlockChance = GetBlockChance
  76. local SPELL_STAT1_NAME = SPELL_STAT1_NAME
  77. local SPELL_STAT2_NAME = SPELL_STAT2_NAME
  78. local SPELL_STAT3_NAME = SPELL_STAT3_NAME
  79. local SPELL_STAT4_NAME = SPELL_STAT4_NAME
  80. local SPELL_STAT5_NAME = SPELL_STAT5_NAME
  81. local ARMOR = ARMOR
  82.  
  83. -----------------
  84. -- DB Defaults --
  85. -----------------
  86. local profileDefault = {
  87.     hideBlizzardComparisons = true,
  88.     showItemLevel = true,
  89.     showItemID = false,
  90.     useRequiredLevel = true,
  91.     customLevel = 0,
  92.     textColor = {r = 1.0, g = 0.996,  b = 0.545, hex = "|cfffffe8b"},
  93.     enableTextColor = true,
  94.     enableStatMods = true,
  95.     enableAvoidanceDiminishingReturns = true,
  96.     showRatings = 0,
  97.     ratingSpell = false,
  98.     ratingPhysical = false,
  99.     detailedConversionText = false,
  100.     defBreakDown = false,
  101.     wpnBreakDown = false,
  102.     expBreakDown = false,
  103.     showStats = 0,
  104.     showSum = 0,
  105.     sumIgnoreUnused = true,
  106.     sumMinQuality = 2, -- uncommon
  107.     sumIgnoreCloth = true,
  108.     sumIgnoreLeather = true,
  109.     sumIgnoreMail = true,
  110.     sumIgnorePlate = true,
  111.     sumIgnoreEquipped = false,
  112.     sumIgnoreEnchant = true,
  113.     sumIgnoreGems = false,
  114.     sumIgnorePris = true,
  115.     sumBlankLine = true,
  116.     sumBlankLineAfter = false,
  117.     sumShowIcon = true,
  118.     sumShowTitle = true,
  119.     sumDiffStyle = "main",
  120.     sumSortAlpha = false,
  121.     sumAvoidWithBlock = false,
  122.     showZeroValueStat = false,
  123.     calcDiff = true,
  124.     calcSum = true,
  125. --[[
  126. Str -> AP, Block, Healing
  127. Agi -> Crit, Dodge, AP, RAP, Armor
  128. Sta -> Health, SpellDmg
  129. Int -> Mana, SpellCrit, SpellDmg, Healing, MP5, RAP, Armor
  130. Spi -> MP5, MP5NC, HP5, SpellDmg, Healing
  131. --]]
  132.     -- Base stat conversions
  133.     showAPFromStr = false,
  134.     showBlockValueFromStr = false,
  135.    
  136.     showCritFromAgi = true,
  137.     showDodgeFromAgi = true,
  138.     showAPFromAgi = false,
  139.     showRAPFromAgi = false,
  140.     showArmorFromAgi = false,
  141.     showHealingFromAgi = false, -- Druid - Nurturing Instinct
  142.    
  143.     showHealthFromSta = false,
  144.     showSpellDmgFromSta = false, -- Warlock
  145.    
  146.     showManaFromInt = false,
  147.     showSpellCritFromInt = true,
  148.     showSpellDmgFromInt = false, -- Druid, Mage, Paladin, Shaman, Warlock
  149.     showHealingFromInt = false, -- Druid, Paladin, Shaman
  150.     showMP5FromInt = false,
  151.     showMP5NCFromInt = false,
  152.     showRAPFromInt = false, -- Hunter
  153.     showArmorFromInt = false, -- Mage
  154.    
  155.     showMP5FromSpi = false, -- Druid, Mage, Priest
  156.     showMP5NCFromSpi = false,
  157.     showHP5FromSpi = false,
  158.     showSpellDmgFromSpi = false, -- Priest
  159.     showHealingFromSpi = false, -- Priest
  160.     showSpellCritFromSpi = false, -- Mage
  161.    
  162.     showAPFromArmor = false, -- Warrior, DK
  163.     ------------------
  164.     -- Stat Summary --
  165.     ------------------
  166.     -- Basic
  167.     sumHP = false,
  168.     sumMP = false,
  169.     sumMP5 = false,
  170.     sumMP5NC = false,
  171.     sumHP5 = false,
  172.     sumHP5OC = false,
  173.     sumStr = false,
  174.     sumAgi = false,
  175.     sumSta = false,
  176.     sumInt = false,
  177.     sumSpi = false,
  178.     -- Physical
  179.     sumAP = false,
  180.     sumRAP = false,
  181.     sumFAP = false,
  182.     sumHit = false,
  183.     sumHitRating = false,
  184.     sumRangedHit = false,
  185.     sumRangedHitRating = false,
  186.     sumCrit = false,
  187.     sumCritRating = false,
  188.     sumRangedCrit = false,
  189.     sumRangedCritRating = false,
  190.     sumHaste = false,
  191.     sumHasteRating = false,
  192.     sumRangedHaste = false,
  193.     sumRangedHasteRating = false,
  194.     sumExpertise = false,
  195.   sumExpertiseRating = false,
  196.     sumWeaponSkill = false,
  197.     sumDodgeNeglect = false,
  198.     sumParryNeglect = false,
  199.     sumBlockNeglect = false,
  200.     sumWeaponMaxDamage = false,
  201.     sumWeaponDPS = false,
  202.     sumIgnoreArmor = false,
  203.     sumArmorPenetration = false, -- new
  204.     sumArmorPenetrationRating = false, -- new
  205.     -- Spell
  206.     sumSpellDmg = false,
  207.     sumArcaneDmg = false,
  208.     sumFrostDmg = false,
  209.     sumNatureDmg = false,
  210.     sumFireDmg = false,
  211.     sumShadowDmg = false,
  212.     sumHolyDmg = false,
  213.     sumHealing = false,
  214.     sumSpellHit = false,
  215.     sumSpellHitRating = false,
  216.     sumSpellCrit = false,
  217.     sumSpellCritRating = false,
  218.     sumSpellHaste = false,
  219.     sumSpellHasteRating = false,
  220.     sumPenetration = false,
  221.     -- Tank
  222.     sumArmor = false,
  223.     sumDodge = false,
  224.     sumDodgeRating = false,
  225.     sumParry = false,
  226.     sumParryRating = false,
  227.     sumBlock = false,
  228.     sumBlockRating = false,
  229.     sumBlockValue = false,
  230.     sumHitAvoid = false,
  231.     sumCritAvoid = false,
  232.     sumArcaneResist = false,
  233.     sumFrostResist = false,
  234.     sumNatureResist = false,
  235.     sumFireResist = false,
  236.     sumShadowResist = false,
  237.     sumResilience = false,
  238.     sumDefense = false,
  239.     sumTankPoints = false,
  240.     sumTotalReduction = false,
  241.     sumAvoidance = false,
  242.     -- Gems
  243.     sumGemRed = {
  244.         itemID = nil,
  245.         gemID = nil,
  246.         gemText = nil,
  247.         gemName = nil,
  248.         gemLink = nil,
  249.     },
  250.     sumGemYellow = {
  251.         itemID = nil,
  252.         gemID = nil,
  253.         gemText = nil,
  254.         gemName = nil,
  255.         gemLink = nil,
  256.     },
  257.     sumGemBlue = {
  258.         itemID = nil,
  259.         gemID = nil,
  260.         gemText = nil,
  261.         gemName = nil,
  262.         gemLink = nil,
  263.     },
  264.     sumGemMeta = {
  265.         itemID = nil,
  266.         gemID = nil,
  267.         gemText = nil,
  268.         gemName = nil,
  269.         gemLink = nil,
  270.     },
  271.     -- Gems Set 2
  272.     sumGem2Toggle = 4,
  273.     sumGemRed2 = {
  274.         itemID = nil,
  275.         gemID = nil,
  276.         gemText = nil,
  277.         gemName = nil,
  278.         gemLink = nil,
  279.     },
  280.     sumGemYellow2 = {
  281.         itemID = nil,
  282.         gemID = nil,
  283.         gemText = nil,
  284.         gemName = nil,
  285.         gemLink = nil,
  286.     },
  287.     sumGemBlue2 = {
  288.         itemID = nil,
  289.         gemID = nil,
  290.         gemText = nil,
  291.         gemName = nil,
  292.         gemLink = nil,
  293.     },
  294.     sumGemMeta2 = {
  295.         itemID = nil,
  296.         gemID = nil,
  297.         gemText = nil,
  298.         gemName = nil,
  299.         gemLink = nil,
  300.     },
  301.     -- Gems Set 3
  302.     sumGem3Toggle = 4,
  303.     sumGemRed3 = {
  304.         itemID = nil,
  305.         gemID = nil,
  306.         gemText = nil,
  307.         gemName = nil,
  308.         gemLink = nil,
  309.     },
  310.     sumGemYellow3 = {
  311.         itemID = nil,
  312.         gemID = nil,
  313.         gemText = nil,
  314.         gemName = nil,
  315.         gemLink = nil,
  316.     },
  317.     sumGemBlue3 = {
  318.         itemID = nil,
  319.         gemID = nil,
  320.         gemText = nil,
  321.         gemName = nil,
  322.         gemLink = nil,
  323.     },
  324.     sumGemMeta3 = {
  325.         itemID = nil,
  326.         gemID = nil,
  327.         gemText = nil,
  328.         gemName = nil,
  329.         gemLink = nil,
  330.     },
  331. }
  332.  
  333. -- Class specific defaults
  334. if class == "DRUID" then
  335.     profileDefault.ratingSpell = true
  336.     profileDefault.ratingPhysical = true
  337.     profileDefault.sumHP = true
  338.     profileDefault.sumMP = true
  339.     profileDefault.sumFAP = true
  340.     profileDefault.sumHit = true
  341.     profileDefault.sumCrit = true
  342.     profileDefault.sumHaste = true
  343.     profileDefault.sumExpertise = true
  344.     profileDefault.sumArmorPenetration = true
  345.     profileDefault.sumDodge = true
  346.     profileDefault.sumArmor = true
  347.     profileDefault.sumResilience = true
  348.     profileDefault.sumSpellDmg = true
  349.     profileDefault.sumSpellHit = true
  350.     profileDefault.sumSpellCrit = true
  351.     profileDefault.sumSpellHaste = true
  352.     profileDefault.sumHealing = true
  353.     profileDefault.sumMP5 = true
  354.     profileDefault.showHealingFromAgi = true
  355.     profileDefault.showSpellDmgFromInt = true
  356.     profileDefault.showHealingFromInt = true
  357.     profileDefault.showMP5FromInt = true -- Dreamstate (Rank 3) - 1,17
  358.     profileDefault.showMP5FromSpi = true
  359.     profileDefault.showSpellDmgFromSpi = true
  360.     profileDefault.showHealingFromSpi = true
  361.     profileDefault.sumIgnoreCloth = false
  362.     profileDefault.sumIgnoreLeather = false
  363. elseif class == "HUNTER" then
  364.     profileDefault.ratingPhysical = true
  365.     profileDefault.sumHP = true
  366.     profileDefault.sumMP = true
  367.     profileDefault.sumResilience = true
  368.     profileDefault.sumRAP = true
  369.     profileDefault.sumRangedHit = true
  370.     profileDefault.sumRangedCrit = true
  371.     profileDefault.sumRangedHaste = true
  372.     profileDefault.sumArmorPenetration = true
  373.     profileDefault.sumMP5 = true
  374.     profileDefault.showMP5FromInt = true -- Aspect of the Viper
  375.     profileDefault.showDodgeFromAgi = false
  376.     profileDefault.showSpellCritFromInt = false
  377.     profileDefault.showRAPFromInt = true
  378.     profileDefault.showAPFromSta = true
  379.     profileDefault.sumIgnoreLeather = false
  380.     profileDefault.sumIgnoreMail = false
  381. elseif class == "MAGE" then
  382.     profileDefault.ratingSpell = true
  383.     profileDefault.sumHP = true
  384.     profileDefault.sumMP = true
  385.     profileDefault.sumResilience = true
  386.     profileDefault.sumSpellDmg = true
  387.     profileDefault.sumSpellHit = true
  388.     profileDefault.sumSpellCrit = true
  389.     profileDefault.sumSpellHaste = true
  390.     profileDefault.sumMP5 = true
  391.     profileDefault.showCritFromAgi = false
  392.     profileDefault.showDodgeFromAgi = false
  393.     profileDefault.showSpellDmgFromInt = true
  394.     profileDefault.showArmorFromInt = true
  395.     profileDefault.showMP5FromInt = true
  396.     profileDefault.showMP5FromSpi = true
  397.     profileDefault.showSpellCritFromSpi = true -- Molten Armor
  398.     profileDefault.sumIgnoreCloth = false
  399. elseif class == "PALADIN" then
  400.     profileDefault.ratingSpell = true
  401.     profileDefault.ratingPhysical = true
  402.     profileDefault.sumHP = true
  403.     profileDefault.sumMP = true
  404.     profileDefault.sumResilience = true
  405.     profileDefault.sumAP = true
  406.     profileDefault.sumHit = true
  407.     profileDefault.sumCrit = true
  408.     profileDefault.sumHaste = true
  409.     profileDefault.sumExpertise = true
  410.     profileDefault.sumArmorPenetration = true
  411.     profileDefault.sumHolyDmg = true
  412.     profileDefault.sumSpellHit = true
  413.     profileDefault.sumSpellCrit = true
  414.     profileDefault.sumSpellHaste = true
  415.     profileDefault.sumHealing = true
  416.     profileDefault.sumMP5 = true
  417.     profileDefault.sumDodge = true
  418.     profileDefault.sumParry = true
  419.     profileDefault.sumBlock = true
  420.     profileDefault.sumBlockValue = true
  421.     profileDefault.sumDefense = true
  422.     profileDefault.showSpellDmgFromInt = true
  423.     profileDefault.showHealingFromInt = true
  424.     profileDefault.showSpellDmgFromStr = true
  425.     profileDefault.showHealingFromStr = true
  426.     profileDefault.sumIgnoreCloth = false
  427.     profileDefault.sumIgnoreLeather = false
  428.     profileDefault.sumIgnoreMail = false
  429.     profileDefault.sumIgnorePlate = false
  430. elseif class == "PRIEST" then
  431.     profileDefault.ratingSpell = true
  432.     profileDefault.sumHP = true
  433.     profileDefault.sumMP = true
  434.     profileDefault.sumResilience = true
  435.     profileDefault.sumSpellDmg = true
  436.     profileDefault.sumSpellHit = true
  437.     profileDefault.sumSpellCrit = true
  438.     profileDefault.sumSpellHaste = true
  439.     profileDefault.sumHealing = true
  440.     profileDefault.sumMP5 = true
  441.     profileDefault.showCritFromAgi = false
  442.     profileDefault.showDodgeFromAgi = false
  443.     profileDefault.showMP5FromInt = true
  444.     profileDefault.showMP5FromSpi = true
  445.     profileDefault.showSpellDmgFromSpi = true
  446.     profileDefault.showHealingFromSpi = true
  447.     profileDefault.sumIgnoreCloth = false
  448. elseif class == "ROGUE" then
  449.     profileDefault.ratingPhysical = true
  450.     profileDefault.sumHP = true
  451.     profileDefault.sumResilience = true
  452.     profileDefault.sumAP = true
  453.     profileDefault.sumHit = true
  454.     profileDefault.sumCrit = true
  455.     profileDefault.sumHaste = true
  456.     profileDefault.sumExpertise = true
  457.     profileDefault.sumArmorPenetration = true
  458.     profileDefault.showSpellCritFromInt = false
  459.     profileDefault.sumIgnoreLeather = false
  460. elseif class == "SHAMAN" then
  461.     profileDefault.ratingSpell = true
  462.     profileDefault.ratingPhysical = true
  463.     profileDefault.sumHP = true
  464.     profileDefault.sumMP = true
  465.     profileDefault.sumResilience = true
  466.     profileDefault.sumSpellDmg = true
  467.     profileDefault.sumSpellHit = true
  468.     profileDefault.sumSpellCrit = true
  469.     profileDefault.sumSpellHaste = true
  470.     profileDefault.sumHealing = true
  471.     profileDefault.sumMP5 = true
  472.     profileDefault.showSpellDmgFromStr = true
  473.     profileDefault.showHealingFromStr = true
  474.     profileDefault.showSpellDmgFromInt = true
  475.     profileDefault.showHealingFromInt = true
  476.     profileDefault.showMP5FromInt = true
  477.     profileDefault.showAPFromInt = true
  478.     profileDefault.sumIgnoreCloth = false
  479.     profileDefault.sumIgnoreLeather = false
  480.     profileDefault.sumIgnoreMail = false
  481. elseif class == "WARLOCK" then
  482.     profileDefault.ratingSpell = true
  483.     profileDefault.sumHP = true
  484.     profileDefault.sumMP = true
  485.     profileDefault.sumResilience = true
  486.     profileDefault.sumSpellDmg = true
  487.     profileDefault.sumSpellHit = true
  488.     profileDefault.sumSpellCrit = true
  489.     profileDefault.sumSpellHaste = true
  490.     profileDefault.showCritFromAgi = false
  491.     profileDefault.showDodgeFromAgi = false
  492.     profileDefault.showSpellDmgFromSta = true
  493.     profileDefault.showSpellDmgFromInt = true
  494.     profileDefault.showMP5FromSpi = true
  495.     profileDefault.showSpellDmgFromSpi = true
  496.     profileDefault.sumIgnoreCloth = false
  497. elseif class == "WARRIOR" then
  498.     profileDefault.ratingPhysical = true
  499.     profileDefault.sumHP = true
  500.     profileDefault.sumResilience = true
  501.     profileDefault.sumAP = true
  502.     profileDefault.sumHit = true
  503.     profileDefault.sumCrit = true
  504.     profileDefault.sumHaste = true
  505.     profileDefault.sumExpertise = true
  506.     profileDefault.sumArmorPenetration = true
  507.     profileDefault.sumDodge = true
  508.     profileDefault.sumParry = true
  509.     profileDefault.sumBlock = true
  510.     profileDefault.sumBlockValue = true
  511.     profileDefault.sumDefense = true
  512.     profileDefault.showSpellCritFromInt = false
  513.     profileDefault.showAPFromArmor = true
  514.     if playerLevel < 40 then
  515.         profileDefault.sumIgnoreMail = false
  516.     end
  517.     profileDefault.sumIgnorePlate = false
  518. elseif class == "DEATHKNIGHT" then
  519.     profileDefault.ratingPhysical = true
  520.     profileDefault.sumHP = true
  521.     profileDefault.sumResilience = true
  522.     profileDefault.sumAP = true
  523.     profileDefault.sumHit = true
  524.     profileDefault.sumCrit = true
  525.     profileDefault.sumHaste = true
  526.     profileDefault.sumExpertise = true
  527.     profileDefault.sumArmorPenetration = true
  528.     profileDefault.sumDodge = true
  529.     profileDefault.sumParry = true
  530.     profileDefault.sumDefense = true
  531.     profileDefault.showSpellCritFromInt = false
  532.     profileDefault.showParryFromStr = true
  533.     profileDefault.showAPFromArmor = true
  534.     profileDefault.sumIgnorePlate = false
  535. end
  536.  
  537. local defaults = {}
  538. defaults.profile = profileDefault
  539.  
  540. ---------------------------
  541. -- Slash Command Options --
  542. ---------------------------
  543.  
  544. local function getProfileOption(info)
  545.     return profileDB[info.arg]
  546. end
  547.  
  548. local function setProfileOptionAndClearCache(info, value)
  549.     profileDB[info.arg] = value
  550.     if info.uiType == "cmd" then
  551.         RatingBuster:Print(L["|cffffff7f%s|r is now set to |cffffff7f[%s]|r"]:format(info.option.name, tostring(value)))
  552.     end
  553.     clearCache()
  554. end
  555.  
  556. local function getGem(info)
  557.     return profileDB[info.arg].gemLink
  558. end
  559.  
  560. local function setGem(info, value)
  561.     local key = info.arg
  562.     if value == "" then
  563.         profileDB[key].itemID = nil
  564.         profileDB[key].gemID = nil
  565.         profileDB[key].gemName = nil
  566.         profileDB[key].gemLink = nil
  567.         profileDB[key].gemText = nil
  568.         clearCache()
  569.         return
  570.     end
  571.     local gemID, gemText = StatLogic:GetGemID(value)
  572.     if gemID and gemText then
  573.         local name, link = GetItemInfo(value)
  574.         local itemID = link:match("item:(%d+)")
  575.         profileDB[key].itemID = itemID
  576.         profileDB[key].gemID = gemID
  577.         profileDB[key].gemName = name
  578.         profileDB[key].gemLink = link
  579.         -- Trim spaces
  580.         gemText = strtrim(gemText)
  581.         -- Strip color codes
  582.         if strsub(gemText, -2) == "|r" then
  583.             gemText = strsub(gemText, 1, -3)
  584.         end
  585.         if strfind(strsub(gemText, 1, 10), "|c%x%x%x%x%x%x%x%x") then
  586.             gemText = strsub(gemText, 11)
  587.         end
  588.         profileDB[key].gemText = gemText
  589.         clearCache()
  590.         -- Is option set by AceConfigCmd or AceConfigDialog?
  591.         --if not debugstack():find("AceConfigCmd") then
  592.             RatingBuster:Print(L["|cffffff7f%s|r is now set to |cffffff7f[%s]|r"]:format(info.option.name, link))
  593.         --end
  594.     elseif gemID == false then -- invalid input
  595.         RatingBuster:Print(L["Invalid input: %s. ItemID or ItemLink required."]:format(value))
  596.     else -- query sent
  597.         RatingBuster:Print(L["Queried server for Gem: %s. Try again in 5 secs."]:format(value))
  598.     end
  599. end
  600.  
  601. local selectedGemSet = 1
  602.  
  603. local options = {
  604.     type = 'group',
  605.     get = getProfileOption,
  606.     set = setProfileOptionAndClearCache,
  607.     args = {
  608.         general = {
  609.             type = 'group',
  610.             name = L["General Settings"],
  611.             cmdInline = true,
  612.             order = -1,
  613.             args = {
  614.                 win = {
  615.                     type = "execute",
  616.                     name = L["Options Window"],
  617.                     desc = L["Shows the Options Window"],
  618.                     func = function()
  619.                         RatingBuster:ShowConfig()
  620.                     end,
  621.                     guiHidden = true,
  622.                 },
  623.                 standby = {
  624.                     type = 'toggle',
  625.                     order = 1,
  626.                     width = "double",
  627.                     name = L["Enabled"],
  628.                     desc = L["Suspend/resume this addon"],
  629.                     get = function() return RatingBuster:IsEnabled() end,
  630.                     set = function()
  631.                         if RatingBuster:IsEnabled() then
  632.                             RatingBuster:Disable()
  633.                         else
  634.                             RatingBuster:Enable()
  635.                         end
  636.                     end,
  637.                 },
  638.                 hidebzcomp = {
  639.                     type = 'toggle',
  640.                     order = 2,
  641.                     width = "double",
  642.                     name = L["Hide Blizzard Item Comparisons"],
  643.                     desc = L["Disable Blizzard stat change summary when using the built-in comparison tooltip"],
  644.                     arg = "hideBlizzardComparisons",
  645.                     get = getProfileOption,
  646.                     set = setProfileOptionAndClearCache,
  647.                 },
  648.                 statmod = {
  649.                     type = 'toggle',
  650.                     order = 3,
  651.                     width = "double",
  652.                     name = L["Enable Stat Mods"],
  653.                     desc = L["Enable support for Stat Mods"],
  654.                     arg = "enableStatMods",
  655.                     get = getProfileOption,
  656.                     set = setProfileOptionAndClearCache,
  657.                 },
  658.                 avoidancedr = {
  659.                     type = 'toggle',
  660.                     order = 4,
  661.                     width = "double",
  662.                     name = L["Enable Avoidance Diminishing Returns"],
  663.                     desc = L["Dodge, Parry, Hit Avoidance values will be calculated using the avoidance deminishing return formula with your current stats"],
  664.                     arg = "enableAvoidanceDiminishingReturns",
  665.                     get = getProfileOption,
  666.                     set = setProfileOptionAndClearCache,
  667.                 },
  668.                 itemid = {
  669.                     type = 'toggle',
  670.                     order = 5,
  671.                     width = "double",
  672.                     name = L["Show ItemID"],
  673.                     desc = L["Show the ItemID in tooltips"],
  674.                     arg = "showItemID",
  675.                     get = getProfileOption,
  676.                     set = setProfileOptionAndClearCache,
  677.                 },
  678.                 itemlevel = {
  679.                     type = 'toggle',
  680.                     order = 6,
  681.                     width = "double",
  682.                     name = L["Show ItemLevel"],
  683.                     desc = L["Show the ItemLevel in tooltips"],
  684.                     arg = "showItemLevel",
  685.                     get = getProfileOption,
  686.                     set = setProfileOptionAndClearCache,
  687.                 },
  688.                 usereqlv = {
  689.                     type = 'toggle',
  690.                     order = 7,
  691.                     width = "double",
  692.                     name = L["Use Required Level"],
  693.                     desc = L["Calculate using the required level if you are below the required level"],
  694.                     arg = "useRequiredLevel",
  695.                     get = getProfileOption,
  696.                     set = setProfileOptionAndClearCache,
  697.                 },
  698.                 level = {
  699.                     type = 'range',
  700.                     order = 8,
  701.                     width = "double",
  702.                     name = L["Set Level"],
  703.                     desc = L["Set the level used in calculations (0 = your level)"],
  704.                     arg = "customLevel",
  705.                     get = getProfileOption,
  706.                     set = setProfileOptionAndClearCache,
  707.                     min = 0,
  708.                     max = 83, -- set to level cap + 3
  709.                     step = 1,
  710.                 },
  711.             },
  712.         },
  713.         rating = {
  714.             type = 'group',
  715.             name = L["Rating"],
  716.             desc = L["Options for Rating display"],
  717.             args = {
  718.                 show = {
  719.                     type = 'select',
  720.                     order = 1,
  721.                     name = L["Show Rating Conversions"],
  722.                     desc = L["Show Rating conversions in tooltips"],
  723.                     values = {
  724.                         [0] = L["Always"],
  725.                         [1] = L["ALT Key"],
  726.                         [2] = L["CTRL Key"],
  727.                         [3] = L["SHIFT Key"],
  728.                         [4] = L["Never"],
  729.                     },
  730.                     arg = "showRatings",
  731.                 },
  732.                 spell = {
  733.                     type = 'toggle',
  734.                     order = 2,
  735.                     width = "double",
  736.                     name = L["Show Spell Hit/Haste"],
  737.                     desc = L["Show Spell Hit/Haste from Hit/Haste Rating"],
  738.                     arg = "ratingSpell",
  739.                     get = getProfileOption,
  740.                     set = setProfileOptionAndClearCache,
  741.                 },
  742.                 physical = {
  743.                     type = 'toggle',
  744.                     order = 3,
  745.                     width = "double",
  746.                     name = L["Show Physical Hit/Haste"],
  747.                     desc = L["Show Physical Hit/Haste from Hit/Haste Rating"],
  748.                     arg = "ratingPhysical",
  749.                     get = getProfileOption,
  750.                     set = setProfileOptionAndClearCache,
  751.                 },
  752.                 detail = {
  753.                     type = 'toggle',
  754.                     order = 4,
  755.                     width = "double",
  756.                     name = L["Show Detailed Conversions Text"],
  757.                     desc = L["Show detailed text for Resilience and Expertise conversions"],
  758.                     arg = "detailedConversionText",
  759.                     get = getProfileOption,
  760.                     set = setProfileOptionAndClearCache,
  761.                 },
  762.                 def = {
  763.                     type = 'toggle',
  764.                     order = 5,
  765.                     width = "double",
  766.                     name = L["Defense Breakdown"],
  767.                     desc = L["Convert Defense into Crit Avoidance, Hit Avoidance, Dodge, Parry and Block"],
  768.                     arg = "defBreakDown",
  769.                     get = getProfileOption,
  770.                     set = setProfileOptionAndClearCache,
  771.                 },
  772.                 wpn = {
  773.                     type = 'toggle',
  774.                     order = 6,
  775.                     width = "double",
  776.                     name = L["Weapon Skill Breakdown"],
  777.                     desc = L["Convert Weapon Skill into Crit, Hit, Dodge Neglect, Parry Neglect and Block Neglect"],
  778.                     arg = "wpnBreakDown",
  779.                     get = getProfileOption,
  780.                     set = setProfileOptionAndClearCache,
  781.                 },
  782.                 exp = {
  783.                     type = 'toggle',
  784.                     order = 7,
  785.                     width = "double",
  786.                     name = L["Expertise Breakdown"],
  787.                     desc = L["Convert Expertise into Dodge Neglect and Parry Neglect"],
  788.                     arg = "expBreakDown",
  789.                     get = getProfileOption,
  790.                     set = setProfileOptionAndClearCache,
  791.                 },
  792.                 color = {
  793.                     type = 'group',
  794.                     order = 8,
  795.                     name = L["Change Text Color"],
  796.                     desc = L["Changes the color of added text"],
  797.                     guiInline = true,
  798.                     args = {
  799.                         enable = {
  800.                             type = 'toggle',
  801.                             order = 1,
  802.                             name = L["Enable Color"],
  803.                             desc = L["Enable colored text"],
  804.                             arg = "enableTextColor",
  805.                             get = getProfileOption,
  806.                             set = setProfileOptionAndClearCache,
  807.                         },
  808.                         pick_dialog = {
  809.                             type = 'color',
  810.                             order = 2,
  811.                             cmdHidden = true,
  812.                             dropdownHidden = true,
  813.                             name = L["Pick Color"],
  814.                             desc = L["Pick a color"],
  815.                             get = function()
  816.                                 return profileDB.textColor.r, profileDB.textColor.g, profileDB.textColor.b, 1.0
  817.                             end,
  818.                             set = function(info, r, g, b, a)
  819.                                 profileDB.textColor.r, profileDB.textColor.g, profileDB.textColor.b = r, g, b
  820.                                 profileDB.textColor.hex = "|cff"..string.format("%02x%02x%02x", profileDB.textColor.r * 255, profileDB.textColor.g * 255, profileDB.textColor.b * 255)
  821.                                 clearCache()
  822.                             end,
  823.                         },
  824.                         pick = {
  825.                             type = 'execute',
  826.                             order = 2,
  827.                             dialogHidden = true,
  828.                             name = L["Pick Color"],
  829.                             desc = L["Pick a color"],
  830.                             func = function()
  831.                                 CloseMenus()
  832.                                 ColorPickerFrame.func = function()
  833.                                     profileDB.textColor.r, profileDB.textColor.g, profileDB.textColor.b = ColorPickerFrame:GetColorRGB();
  834.                                     profileDB.textColor.hex = "|cff"..string.format("%02x%02x%02x", profileDB.textColor.r * 255, profileDB.textColor.g * 255, profileDB.textColor.b * 255)
  835.                                     --clear cache
  836.                                     clearCache()
  837.                                 end
  838.                                 ColorPickerFrame:SetColorRGB(profileDB.textColor.r, profileDB.textColor.g, profileDB.textColor.b);
  839.                                 ColorPickerFrame.previousValues = {r = profileDB.textColor.r, g = profileDB.textColor.g, b = profileDB.textColor.b};
  840.                                 ColorPickerFrame:Show()
  841.                             end,
  842.                         },
  843.                     },
  844.                 },
  845.             },
  846.         },
  847.         stat = {
  848.             type = 'group',
  849.             name = L["Stat Breakdown"],
  850.             desc = L["Changes the display of base stats"],
  851.             args = {
  852.                 show = {
  853.                     type = 'select',
  854.                     order = 1,
  855.                     name = L["Show Base Stat Conversions"],
  856.                     desc = L["Show base stat conversions in tooltips"],
  857.                     values = {
  858.                         [0] = L["Always"],
  859.                         [1] = L["ALT Key"],
  860.                         [2] = L["CTRL Key"],
  861.                         [3] = L["SHIFT Key"],
  862.                         [4] = L["Never"],
  863.                     },
  864.                     arg = "showStats",
  865.                 },
  866.                 str = {
  867.                     type = 'group',
  868.                     order = 2,
  869.                     name = L["Strength"],
  870.                     desc = L["Changes the display of Strength"],
  871.                     args = {
  872.                         ap = {
  873.                             type = 'toggle',
  874.                             width = "full",
  875.                             name = L["Show Attack Power"],
  876.                             desc = L["Show Attack Power from Strength"],
  877.                             arg = "showAPFromStr",
  878.                             get = getProfileOption,
  879.                             set = setProfileOptionAndClearCache,
  880.                         },
  881.                         block = {
  882.                             type = 'toggle',
  883.                             width = "full",
  884.                             name = L["Show Block Value"],
  885.                             desc = L["Show Block Value from Strength"],
  886.                             arg = "showBlockValueFromStr",
  887.                             get = getProfileOption,
  888.                             set = setProfileOptionAndClearCache,
  889.                         },
  890.                     },
  891.                 },
  892.                 agi = {
  893.                     type = 'group',
  894.                     order = 3,
  895.                     name = L["Agility"],
  896.                     desc = L["Changes the display of Agility"],
  897.                     args = {
  898.                         crit = {
  899.                             type = 'toggle',
  900.                             width = "full",
  901.                             name = L["Show Crit"],
  902.                             desc = L["Show Crit chance from Agility"],
  903.                             arg = "showCritFromAgi",
  904.                             get = getProfileOption,
  905.                             set = setProfileOptionAndClearCache,
  906.                         },
  907.                         dodge = {
  908.                             type = 'toggle',
  909.                             width = "full",
  910.                             name = L["Show Dodge"],
  911.                             desc = L["Show Dodge chance from Agility"],
  912.                             arg = "showDodgeFromAgi",
  913.                             get = getProfileOption,
  914.                             set = setProfileOptionAndClearCache,
  915.                         },
  916.                         ap = {
  917.                             type = 'toggle',
  918.                             width = "full",
  919.                             name = L["Show Attack Power"],
  920.                             desc = L["Show Attack Power from Agility"],
  921.                             arg = "showAPFromAgi",
  922.                             get = getProfileOption,
  923.                             set = setProfileOptionAndClearCache,
  924.                         },
  925.                         rap = {
  926.                             type = 'toggle',
  927.                             width = "full",
  928.                             name = L["Show Ranged Attack Power"],
  929.                             desc = L["Show Ranged Attack Power from Agility"],
  930.                             arg = "showRAPFromAgi",
  931.                             get = getProfileOption,
  932.                             set = setProfileOptionAndClearCache,
  933.                         },
  934.                         armor = {
  935.                             type = 'toggle',
  936.                             width = "full",
  937.                             name = L["Show Armor"],
  938.                             desc = L["Show Armor from Agility"],
  939.                             arg = "showArmorFromAgi",
  940.                             get = getProfileOption,
  941.                             set = setProfileOptionAndClearCache,
  942.                         },
  943.                     },
  944.                 },
  945.                 sta = {
  946.                     type = 'group',
  947.                     order = 4,
  948.                     name = L["Stamina"],
  949.                     desc = L["Changes the display of Stamina"],
  950.                     args = {
  951.                         hp = {
  952.                             type = 'toggle',
  953.                             width = "full",
  954.                             name = L["Show Health"],
  955.                             desc = L["Show Health from Stamina"],
  956.                             arg = "showHealthFromSta",
  957.                             get = getProfileOption,
  958.                             set = setProfileOptionAndClearCache,
  959.                         },
  960.                     },
  961.                 },
  962.                 int = {
  963.                     type = 'group',
  964.                     order = 5,
  965.                     name = L["Intellect"],
  966.                     desc = L["Changes the display of Intellect"],
  967.                     args = {
  968.                         spellcrit = {
  969.                             type = 'toggle',
  970.                             width = "full",
  971.                             name = L["Show Spell Crit"],
  972.                             desc = L["Show Spell Crit chance from Intellect"],
  973.                             arg = "showSpellCritFromInt",
  974.                             get = getProfileOption,
  975.                             set = setProfileOptionAndClearCache,
  976.                         },
  977.                         mp = {
  978.                             type = 'toggle',
  979.                             width = "full",
  980.                             name = L["Show Mana"],
  981.                             desc = L["Show Mana from Intellect"],
  982.                             arg = "showManaFromInt",
  983.                             get = getProfileOption,
  984.                             set = setProfileOptionAndClearCache,
  985.                         },
  986.                         mp5 = {
  987.                             type = 'toggle',
  988.                             width = "full",
  989.                             name = L["Show Mana Regen"],
  990.                             desc = L["Show Mana Regen while casting from Intellect"],
  991.                             arg = "showMP5FromInt",
  992.                             get = getProfileOption,
  993.                             set = setProfileOptionAndClearCache,
  994.                         },
  995.                         mp5nc = {
  996.                             type = 'toggle',
  997.                             width = "full",
  998.                             name = L["Show Mana Regen while NOT casting"],
  999.                             desc = L["Show Mana Regen while NOT casting from Intellect"],
  1000.                             arg = "showMP5NCFromInt",
  1001.                             get = getProfileOption,
  1002.                             set = setProfileOptionAndClearCache,
  1003.                         },
  1004.                     },
  1005.                 },
  1006.                 spi = {
  1007.                     type = 'group',
  1008.                     order = 6,
  1009.                     name = L["Spirit"],
  1010.                     desc = L["Changes the display of Spirit"],
  1011.                     args = {
  1012.                         mp5nc = {
  1013.                             type = 'toggle',
  1014.                             width = "full",
  1015.                             name = L["Show Mana Regen while NOT casting"],
  1016.                             desc = L["Show Mana Regen while NOT casting from Spirit"],
  1017.                             arg = "showMP5NCFromSpi",
  1018.                             get = getProfileOption,
  1019.                             set = setProfileOptionAndClearCache,
  1020.                         },
  1021.                         hp5 = {
  1022.                             type = 'toggle',
  1023.                             width = "full",
  1024.                             name = L["Show Health Regen"],
  1025.                             desc = L["Show Health Regen from Spirit"],
  1026.                             arg = "showHP5FromSpi",
  1027.                             get = getProfileOption,
  1028.                             set = setProfileOptionAndClearCache,
  1029.                         },
  1030.                     },
  1031.                 },
  1032.             },
  1033.         },
  1034.         sum = {
  1035.             type = 'group',
  1036.             childGroups = "tab",
  1037.             name = L["Stat Summary"],
  1038.             desc = L["Options for stat summary"],
  1039.             args = {
  1040.                 show = {
  1041.                     type = 'select',
  1042.                     order = 1,
  1043.                     name = L["Show Stat Summary"],
  1044.                     desc = L["Show stat summary in tooltips"],
  1045.                     values = {
  1046.                         [0] = L["Always"],
  1047.                         [1] = L["ALT Key"],
  1048.                         [2] = L["CTRL Key"],
  1049.                         [3] = L["SHIFT Key"],
  1050.                         [4] = L["Never"],
  1051.                     },
  1052.                     arg = "showSum",
  1053.                 },
  1054.                 diffstyle = {
  1055.                     type = 'select',
  1056.                     order = 2,
  1057.                     name = L["Display Style For Diff Value"],
  1058.                     desc = L["Display diff values in the main tooltip or only in compare tooltips"],
  1059.                     values = {comp = "comp", main = "main"},
  1060.                     arg = "sumDiffStyle",
  1061.                 },
  1062.                 ignore = {
  1063.                     type = 'group',
  1064.                     order = 3,
  1065.                     dialogInline = true,
  1066.                     name = L["Ignore Settings"],
  1067.                     desc = L["Ignore stuff when calculating the stat summary"],
  1068.                     args = {
  1069.                         unused = {
  1070.                             type = 'toggle',
  1071.                             order = 1,
  1072.                             width = "double",
  1073.                             name = L["Ignore Undesirable Items"],
  1074.                             desc = L["Hide stat summary for undesirable items"],
  1075.                             arg = "sumIgnoreUnused",
  1076.                         },
  1077.                         quality = {
  1078.                             type = 'select',
  1079.                             order = 2,
  1080.                             name = L["Minimum Item Quality"],
  1081.                             desc = L["Show stat summary only for selected quality items and up"],
  1082.                             values = {
  1083.                                 [0] = "|cff9d9d9d"..ITEM_QUALITY0_DESC.."|r",
  1084.                                 [1] = "|cffffffff"..ITEM_QUALITY1_DESC.."|r",
  1085.                                 [2] = "|cff1eff00"..ITEM_QUALITY2_DESC.."|r",
  1086.                                 [3] = "|cff0070dd"..ITEM_QUALITY3_DESC.."|r",
  1087.                                 [4] = "|cffa335ee"..ITEM_QUALITY4_DESC.."|r",
  1088.                             },
  1089.                             arg = "sumMinQuality",
  1090.                             disabled = function() return not profileDB.sumIgnoreUnused end,
  1091.                         },
  1092.                         armor = {
  1093.                             type = 'group',
  1094.                             order = 3,
  1095.                             dialogInline = true,
  1096.                             name = L["Armor Types"],
  1097.                             desc = L["Select armor types you want to ignore"],
  1098.                             disabled = function() return not profileDB.sumIgnoreUnused end,
  1099.                             args = {
  1100.                                 cloth = {
  1101.                                     type = 'toggle',
  1102.                                     order = 1,
  1103.                                     name = L["Ignore Cloth"],
  1104.                                     desc = L["Hide stat summary for all cloth armor"],
  1105.                                     arg = "sumIgnoreCloth",
  1106.                                 },
  1107.                                 leather = {
  1108.                                     type = 'toggle',
  1109.                                     order = 2,
  1110.                                     name = L["Ignore Leather"],
  1111.                                     desc = L["Hide stat summary for all leather armor"],
  1112.                                     arg = "sumIgnoreLeather",
  1113.                                 },
  1114.                                 mail = {
  1115.                                     type = 'toggle',
  1116.                                     order = 3,
  1117.                                     name = L["Ignore Mail"],
  1118.                                     desc = L["Hide stat summary for all mail armor"],
  1119.                                     arg = "sumIgnoreMail",
  1120.                                 },
  1121.                                 plate = {
  1122.                                     type = 'toggle',
  1123.                                     order = 4,
  1124.                                     name = L["Ignore Plate"],
  1125.                                     desc = L["Hide stat summary for all plate armor"],
  1126.                                     arg = "sumIgnorePlate",
  1127.                                 },
  1128.                             },
  1129.                         },
  1130.                         equipped = {
  1131.                             type = 'toggle',
  1132.                             order = 5,
  1133.                             width = "double",
  1134.                             name = L["Ignore Equipped Items"],
  1135.                             desc = L["Hide stat summary for equipped items"],
  1136.                             arg = "sumIgnoreEquipped",
  1137.                         },
  1138.                         enchant = {
  1139.                             type = 'toggle',
  1140.                             order = 10,
  1141.                             width = "double",
  1142.                             name = L["Ignore Enchants"],
  1143.                             desc = L["Ignore enchants on items when calculating the stat summary"],
  1144.                             arg = "sumIgnoreEnchant",
  1145.                         },
  1146.                         prismaticSocket = {
  1147.                             type = 'toggle',
  1148.                             order = 11,
  1149.                             width = "double",
  1150.                             name = L["Ignore Prismatic Sockets"],
  1151.                             desc = L["Ignore gems in prismatic sockets when calculating the stat summary"],
  1152.                             arg = "sumIgnorePris",
  1153.                         },
  1154.                         gem = {
  1155.                             type = 'toggle',
  1156.                             order = 15,
  1157.                             width = "double",
  1158.                             name = L["Ignore Gems"],
  1159.                             desc = L["Ignore gems on items when calculating the stat summary"],
  1160.                             arg = "sumIgnoreGems",
  1161.                         },
  1162.                     },
  1163.                 },
  1164.                 space = {
  1165.                     type = 'group',
  1166.                     order = 4,
  1167.                     dialogInline = true,
  1168.                     name = L["Add Empty Line"],
  1169.                     desc = L["Add a empty line before or after stat summary"],
  1170.                     args = {
  1171.                         before = {
  1172.                             type = 'toggle',
  1173.                             name = L["Add Before Summary"],
  1174.                             desc = L["Add a empty line before stat summary"],
  1175.                             arg = "sumBlankLine",
  1176.                             get = getProfileOption,
  1177.                             set = setProfileOptionAndClearCache,
  1178.                         },
  1179.                         after = {
  1180.                             type = 'toggle',
  1181.                             name = L["Add After Summary"],
  1182.                             desc = L["Add a empty line after stat summary"],
  1183.                             arg = "sumBlankLineAfter",
  1184.                             get = getProfileOption,
  1185.                             set = setProfileOptionAndClearCache,
  1186.                         },
  1187.                     },
  1188.                 },
  1189.                 icon = {
  1190.                     type = 'toggle',
  1191.                     order = 5,
  1192.                     name = L["Show Icon"],
  1193.                     desc = L["Show the sigma icon before summary listing"],
  1194.                     arg = "sumShowIcon",
  1195.                     get = getProfileOption,
  1196.                     set = setProfileOptionAndClearCache,
  1197.                 },
  1198.                 title = {
  1199.                     type = 'toggle',
  1200.                     order = 6,
  1201.                     name = L["Show Title Text"],
  1202.                     desc = L["Show the title text before summary listing"],
  1203.                     arg = "sumShowTitle",
  1204.                     get = getProfileOption,
  1205.                     set = setProfileOptionAndClearCache,
  1206.                 },
  1207.                 showzerostat = {
  1208.                     type = 'toggle',
  1209.                     order = 7,
  1210.                     width = "double",
  1211.                     name = L["Show Zero Value Stats"],
  1212.                     desc = L["Show zero value stats in summary for consistancy"],
  1213.                     arg = "showZeroValueStat",
  1214.                     get = getProfileOption,
  1215.                     set = setProfileOptionAndClearCache,
  1216.                 },
  1217.                 calcsum = {
  1218.                     type = 'toggle',
  1219.                     order = 8,
  1220.                     name = L["Calculate Stat Sum"],
  1221.                     desc = L["Calculate the total stats for the item"],
  1222.                     arg = "calcSum",
  1223.                     get = getProfileOption,
  1224.                     set = setProfileOptionAndClearCache,
  1225.                 },
  1226.                 calcdiff = {
  1227.                     type = 'toggle',
  1228.                     order = 9,
  1229.                     name = L["Calculate Stat Diff"],
  1230.                     desc = L["Calculate the stat difference for the item and equipped items"],
  1231.                     arg = "calcDiff",
  1232.                     get = getProfileOption,
  1233.                     set = setProfileOptionAndClearCache,
  1234.                 },
  1235.                 sort = {
  1236.                     type = 'toggle',
  1237.                     name = L["Sort StatSummary Alphabetically"],
  1238.                     order = 10,
  1239.                     width = "double",
  1240.                     desc = L["Enable to sort StatSummary alphabetically, disable to sort according to stat type(basic, physical, spell, tank)"],
  1241.                     arg = "sumSortAlpha",
  1242.                     get = getProfileOption,
  1243.                     set = setProfileOptionAndClearCache,
  1244.                 },
  1245.                 avoidhasblock = {
  1246.                     type = 'toggle',
  1247.                     order = 11,
  1248.                     width = "full",
  1249.                     name = L["Include Block Chance In Avoidance Summary"],
  1250.                     desc = L["Enable to include block chance in Avoidance summary, Disable for only dodge, parry, miss"],
  1251.                     arg = "sumAvoidWithBlock",
  1252.                     get = getProfileOption,
  1253.                     set = setProfileOptionAndClearCache,
  1254.                 },
  1255.                 basic = {
  1256.                     type = 'group',
  1257.                     dialogInline = true,
  1258.                     name = L["Stat - Basic"],
  1259.                     desc = L["Choose basic stats for summary"],
  1260.                     args = {
  1261.                         hp = {
  1262.                             type = 'toggle',
  1263.                             name = L["Sum Health"],
  1264.                             desc = L["Health <- Health, Stamina"],
  1265.                             arg = "sumHP",
  1266.                             get = getProfileOption,
  1267.                             set = setProfileOptionAndClearCache,
  1268.                         },
  1269.                         mp = {
  1270.                             type = 'toggle',
  1271.                             name = L["Sum Mana"],
  1272.                             desc = L["Mana <- Mana, Intellect"],
  1273.                             arg = "sumMP",
  1274.                             get = getProfileOption,
  1275.                             set = setProfileOptionAndClearCache,
  1276.                         },
  1277.                         mp5 = {
  1278.                             type = 'toggle',
  1279.                             name = L["Sum Mana Regen"],
  1280.                             desc = L["Mana Regen <- Mana Regen, Spirit"],
  1281.                             arg = "sumMP5",
  1282.                             get = getProfileOption,
  1283.                             set = setProfileOptionAndClearCache,
  1284.                         },
  1285.                         mp5nc = {
  1286.                             type = 'toggle',
  1287.                             name = L["Sum Mana Regen while not casting"],
  1288.                             desc = L["Mana Regen while not casting <- Spirit"],
  1289.                             arg = "sumMP5NC",
  1290.                             get = getProfileOption,
  1291.                             set = setProfileOptionAndClearCache,
  1292.                         },
  1293.                         hp5 = {
  1294.                             type = 'toggle',
  1295.                             name = L["Sum Health Regen"],
  1296.                             desc = L["Health Regen <- Health Regen"],
  1297.                             arg = "sumHP5",
  1298.                             get = getProfileOption,
  1299.                             set = setProfileOptionAndClearCache,
  1300.                         },
  1301.                         hp5oc = {
  1302.                             type = 'toggle',
  1303.                             name = L["Sum Health Regen when out of combat"],
  1304.                             desc = L["Health Regen when out of combat <- Spirit"],
  1305.                             arg = "sumHP5OC",
  1306.                             get = getProfileOption,
  1307.                             set = setProfileOptionAndClearCache,
  1308.                         },
  1309.                         str = {
  1310.                             type = 'toggle',
  1311.                             name = L["Sum Strength"],
  1312.                             desc = L["Strength Summary"],
  1313.                             arg = "sumStr",
  1314.                             get = getProfileOption,
  1315.                             set = setProfileOptionAndClearCache,
  1316.                         },
  1317.                         agi = {
  1318.                             type = 'toggle',
  1319.                             name = L["Sum Agility"],
  1320.                             desc = L["Agility Summary"],
  1321.                             arg = "sumAgi",
  1322.                             get = getProfileOption,
  1323.                             set = setProfileOptionAndClearCache,
  1324.                         },
  1325.                         sta = {
  1326.                             type = 'toggle',
  1327.                             name = L["Sum Stamina"],
  1328.                             desc = L["Stamina Summary"],
  1329.                             arg = "sumSta",
  1330.                             get = getProfileOption,
  1331.                             set = setProfileOptionAndClearCache,
  1332.                         },
  1333.                         int = {
  1334.                             type = 'toggle',
  1335.                             name = L["Sum Intellect"],
  1336.                             desc = L["Intellect Summary"],
  1337.                             arg = "sumInt",
  1338.                             get = getProfileOption,
  1339.                             set = setProfileOptionAndClearCache,
  1340.                         },
  1341.                         spi = {
  1342.                             type = 'toggle',
  1343.                             name = L["Sum Spirit"],
  1344.                             desc = L["Spirit Summary"],
  1345.                             arg = "sumSpi",
  1346.                             get = getProfileOption,
  1347.                             set = setProfileOptionAndClearCache,
  1348.                         },
  1349.                     },
  1350.                 },
  1351.                 physical = {
  1352.                     type = 'group',
  1353.                     dialogInline = true,
  1354.                     name = L["Stat - Physical"],
  1355.                     desc = L["Choose physical damage stats for summary"],
  1356.                     args = {
  1357.                         ap = {
  1358.                             type = 'toggle',
  1359.                             name = L["Sum Attack Power"],
  1360.                             desc = L["Attack Power <- Attack Power, Strength, Agility"],
  1361.                             arg = "sumAP",
  1362.                             get = getProfileOption,
  1363.                             set = setProfileOptionAndClearCache,
  1364.                         },
  1365.                         rap = {
  1366.                             type = 'toggle',
  1367.                             name = L["Sum Ranged Attack Power"],
  1368.                             desc = L["Ranged Attack Power <- Ranged Attack Power, Intellect, Attack Power, Strength, Agility"],
  1369.                             arg = "sumRAP",
  1370.                             get = getProfileOption,
  1371.                             set = setProfileOptionAndClearCache,
  1372.                         },
  1373.                         fap = {
  1374.                             type = 'toggle',
  1375.                             name = L["Sum Feral Attack Power"],
  1376.                             desc = L["Feral Attack Power <- Feral Attack Power, Attack Power, Strength, Agility"],
  1377.                             arg = "sumFAP",
  1378.                             get = getProfileOption,
  1379.                             set = setProfileOptionAndClearCache,
  1380.                         },
  1381.                         hit = {
  1382.                             type = 'toggle',
  1383.                             name = L["Sum Hit Chance"],
  1384.                             desc = L["Hit Chance <- Hit Rating, Weapon Skill Rating"],
  1385.                             arg = "sumHit",
  1386.                             get = getProfileOption,
  1387.                             set = setProfileOptionAndClearCache,
  1388.                         },
  1389.                         hitrating = {
  1390.                             type = 'toggle',
  1391.                             name = L["Sum Hit Rating"],
  1392.                             desc = L["Hit Rating Summary"],
  1393.                             arg = "sumHitRating",
  1394.                             get = getProfileOption,
  1395.                             set = setProfileOptionAndClearCache,
  1396.                         },
  1397.                         rangedhit = {
  1398.                             type = 'toggle',
  1399.                             name = L["Sum Ranged Hit Chance"],
  1400.                             desc = L["Ranged Hit Chance <- Hit Rating, Weapon Skill Rating, Ranged Hit Rating"],
  1401.                             arg = "sumRangedHit",
  1402.                             get = getProfileOption,
  1403.                             set = setProfileOptionAndClearCache,
  1404.                         },
  1405.                         rangedhitrating = {
  1406.                             type = 'toggle',
  1407.                             name = L["Sum Ranged Hit Rating"],
  1408.                             desc = L["Ranged Hit Rating Summary"],
  1409.                             arg = "sumRangedHitRating",
  1410.                             get = getProfileOption,
  1411.                             set = setProfileOptionAndClearCache,
  1412.                         },
  1413.                         crit = {
  1414.                             type = 'toggle',
  1415.                             name = L["Sum Crit Chance"],
  1416.                             desc = L["Crit Chance <- Crit Rating, Agility, Weapon Skill Rating"],
  1417.                             arg = "sumCrit",
  1418.                             get = getProfileOption,
  1419.                             set = setProfileOptionAndClearCache,
  1420.                         },
  1421.                         critrating = {
  1422.                             type = 'toggle',
  1423.                             name = L["Sum Crit Rating"],
  1424.                             desc = L["Crit Rating Summary"],
  1425.                             arg = "sumCritRating",
  1426.                             get = getProfileOption,
  1427.                             set = setProfileOptionAndClearCache,
  1428.                         },
  1429.                         rangedcrit = {
  1430.                             type = 'toggle',
  1431.                             name = L["Sum Ranged Crit Chance"],
  1432.                             desc = L["Ranged Crit Chance <- Crit Rating, Agility, Weapon Skill Rating, Ranged Crit Rating"],
  1433.                             arg = "sumRangedCrit",
  1434.                             get = getProfileOption,
  1435.                             set = setProfileOptionAndClearCache,
  1436.                         },
  1437.                         rangedcritrating = {
  1438.                             type = 'toggle',
  1439.                             name = L["Sum Ranged Crit Rating"],
  1440.                             desc = L["Ranged Crit Rating Summary"],
  1441.                             arg = "sumRangedCritRating",
  1442.                             get = getProfileOption,
  1443.                             set = setProfileOptionAndClearCache,
  1444.                         },
  1445.                         haste = {
  1446.                             type = 'toggle',
  1447.                             name = L["Sum Haste"],
  1448.                             desc = L["Haste <- Haste Rating"],
  1449.                             arg = "sumHaste",
  1450.                             get = getProfileOption,
  1451.                             set = setProfileOptionAndClearCache,
  1452.                         },
  1453.                         hasterating = {
  1454.                             type = 'toggle',
  1455.                             name = L["Sum Haste Rating"],
  1456.                             desc = L["Haste Rating Summary"],
  1457.                             arg = "sumHasteRating",
  1458.                             get = getProfileOption,
  1459.                             set = setProfileOptionAndClearCache,
  1460.                         },
  1461.                         rangedhaste = {
  1462.                             type = 'toggle',
  1463.                             name = L["Sum Ranged Haste"],
  1464.                             desc = L["Ranged Haste <- Haste Rating, Ranged Haste Rating"],
  1465.                             arg = "sumRangedHaste",
  1466.                             get = getProfileOption,
  1467.                             set = setProfileOptionAndClearCache,
  1468.                         },
  1469.                         rangedhasterating = {
  1470.                             type = 'toggle',
  1471.                             name = L["Sum Ranged Haste Rating"],
  1472.                             desc = L["Ranged Haste Rating Summary"],
  1473.                             arg = "sumRangedHasteRating",
  1474.                             get = getProfileOption,
  1475.                             set = setProfileOptionAndClearCache,
  1476.                         },
  1477.                         neglectdodge = {
  1478.                             type = 'toggle',
  1479.                             name = L["Sum Dodge Neglect"],
  1480.                             desc = L["Dodge Neglect <- Expertise, Weapon Skill Rating"],
  1481.                             arg = "sumDodgeNeglect",
  1482.                             get = getProfileOption,
  1483.                             set = setProfileOptionAndClearCache,
  1484.                         },
  1485.                         neglectparry = {
  1486.                             type = 'toggle',
  1487.                             name = L["Sum Parry Neglect"],
  1488.                             desc = L["Parry Neglect <- Expertise, Weapon Skill Rating"],
  1489.                             arg = "sumParryNeglect",
  1490.                             get = getProfileOption,
  1491.                             set = setProfileOptionAndClearCache,
  1492.                         },
  1493.                         neglectblock = {
  1494.                             type = 'toggle',
  1495.                             name = L["Sum Block Neglect"],
  1496.                             desc = L["Block Neglect <- Weapon Skill Rating"],
  1497.                             arg = "sumBlockNeglect",
  1498.                             get = getProfileOption,
  1499.                             set = setProfileOptionAndClearCache,
  1500.                         },
  1501.                         wpn = {
  1502.                             type = 'toggle',
  1503.                             name = L["Sum Weapon Skill"],
  1504.                             desc = L["Weapon Skill <- Weapon Skill Rating"],
  1505.                             arg = "sumWeaponSkill",
  1506.                             get = getProfileOption,
  1507.                             set = setProfileOptionAndClearCache,
  1508.                         },
  1509.                         exp = {
  1510.                             type = 'toggle',
  1511.                             name = L["Sum Expertise"],
  1512.                             desc = L["Expertise <- Expertise Rating"],
  1513.                             arg = "sumExpertise",
  1514.                             get = getProfileOption,
  1515.                             set = setProfileOptionAndClearCache,
  1516.                         },
  1517.                         exprating = {
  1518.                             type = 'toggle',
  1519.                             name = L["Sum Expertise Rating"],
  1520.                             desc = L["Expertise Rating Summary"],
  1521.                             arg = "sumExpertiseRating",
  1522.                             get = getProfileOption,
  1523.                             set = setProfileOptionAndClearCache,
  1524.                         },
  1525.                         maxdamage = {
  1526.                             type = 'toggle',
  1527.                             name = L["Sum Weapon Max Damage"],
  1528.                             desc = L["Weapon Max Damage Summary"],
  1529.                             arg = "sumWeaponMaxDamage",
  1530.                             get = getProfileOption,
  1531.                             set = setProfileOptionAndClearCache,
  1532.                         },
  1533.                         --[[
  1534.                         weapondps = {
  1535.                             type = 'toggle',
  1536.                             name = L["Sum Weapon DPS"],
  1537.                             desc = L["Weapon DPS Summary"],
  1538.                             get = function() return profileDB.sumWeaponDPS end,
  1539.                             set = function(v)
  1540.                                 profileDB.sumWeaponDPS = v
  1541.                                 -- clear cache
  1542.                                 clearCache()
  1543.                             end,
  1544.                         },
  1545.                         --]]
  1546.                         ignorearmor = {
  1547.                             type = 'toggle',
  1548.                             name = L["Sum Ignore Armor"],
  1549.                             desc = L["Ignore Armor Summary"],
  1550.                             arg = "sumIgnoreArmor",
  1551.                             get = getProfileOption,
  1552.                             set = setProfileOptionAndClearCache,
  1553.                         },
  1554.                         arp = {
  1555.                             type = 'toggle',
  1556.                             name = L["Sum Armor Penetration"],
  1557.                             desc = L["Armor Penetration Summary"],
  1558.                             arg = "sumArmorPenetration",
  1559.                             get = getProfileOption,
  1560.                             set = setProfileOptionAndClearCache,
  1561.                         },
  1562.                         arprating = {
  1563.                             type = 'toggle',
  1564.                             name = L["Sum Armor Penetration Rating"],
  1565.                             desc = L["Armor Penetration Rating Summary"],
  1566.                             arg = "sumArmorPenetrationRating",
  1567.                             get = getProfileOption,
  1568.                             set = setProfileOptionAndClearCache,
  1569.                         },
  1570.                     },
  1571.                 },
  1572.                 spell = {
  1573.                     type = 'group',
  1574.                     dialogInline = true,
  1575.                     name = L["Stat - Spell"],
  1576.                     desc = L["Choose spell damage and healing stats for summary"],
  1577.                     args = {
  1578.                         dmg = {
  1579.                             type = 'toggle',
  1580.                             name = L["Sum Spell Damage"],
  1581.                             desc = L["Spell Damage <- Spell Damage, Intellect, Spirit, Stamina"],
  1582.                             arg = "sumSpellDmg",
  1583.                             get = getProfileOption,
  1584.                             set = setProfileOptionAndClearCache,
  1585.                         },
  1586.                         dmgholy = {
  1587.                             type = 'toggle',
  1588.                             name = L["Sum Holy Spell Damage"],
  1589.                             desc = L["Holy Spell Damage <- Holy Spell Damage, Spell Damage, Intellect, Spirit"],
  1590.                             arg = "sumHolyDmg",
  1591.                             get = getProfileOption,
  1592.                             set = setProfileOptionAndClearCache,
  1593.                         },
  1594.                         dmgarcane = {
  1595.                             type = 'toggle',
  1596.                             name = L["Sum Arcane Spell Damage"],
  1597.                             desc = L["Arcane Spell Damage <- Arcane Spell Damage, Spell Damage, Intellect"],
  1598.                             arg = "sumArcaneDmg",
  1599.                             get = getProfileOption,
  1600.                             set = setProfileOptionAndClearCache,
  1601.                         },
  1602.                         dmgfire = {
  1603.                             type = 'toggle',
  1604.                             name = L["Sum Fire Spell Damage"],
  1605.                             desc = L["Fire Spell Damage <- Fire Spell Damage, Spell Damage, Intellect, Stamina"],
  1606.                             arg = "sumFireDmg",
  1607.                             get = getProfileOption,
  1608.                             set = setProfileOptionAndClearCache,
  1609.                         },
  1610.                         dmgnature = {
  1611.                             type = 'toggle',
  1612.                             name = L["Sum Nature Spell Damage"],
  1613.                             desc = L["Nature Spell Damage <- Nature Spell Damage, Spell Damage, Intellect"],
  1614.                             arg = "sumNatureDmg",
  1615.                             get = getProfileOption,
  1616.                             set = setProfileOptionAndClearCache,
  1617.                         },
  1618.                         dmgfrost = {
  1619.                             type = 'toggle',
  1620.                             name = L["Sum Frost Spell Damage"],
  1621.                             desc = L["Frost Spell Damage <- Frost Spell Damage, Spell Damage, Intellect"],
  1622.                             arg = "sumFrostDmg",
  1623.                             get = getProfileOption,
  1624.                             set = setProfileOptionAndClearCache,
  1625.                         },
  1626.                         dmgshadow = {
  1627.                             type = 'toggle',
  1628.                             name = L["Sum Shadow Spell Damage"],
  1629.                             desc = L["Shadow Spell Damage <- Shadow Spell Damage, Spell Damage, Intellect, Spirit, Stamina"],
  1630.                             arg = "sumShadowDmg",
  1631.                             get = getProfileOption,
  1632.                             set = setProfileOptionAndClearCache,
  1633.                         },
  1634.                         heal = {
  1635.                             type = 'toggle',
  1636.                             name = L["Sum Healing"],
  1637.                             desc = L["Healing <- Healing, Intellect, Spirit, Agility, Strength"],
  1638.                             arg = "sumHealing",
  1639.                             get = getProfileOption,
  1640.                             set = setProfileOptionAndClearCache,
  1641.                         },
  1642.                         hit = {
  1643.                             type = 'toggle',
  1644.                             name = L["Sum Spell Hit Chance"],
  1645.                             desc = L["Spell Hit Chance <- Spell Hit Rating"],
  1646.                             arg = "sumSpellHit",
  1647.                             get = getProfileOption,
  1648.                             set = setProfileOptionAndClearCache,
  1649.                         },
  1650.                         hitrating = {
  1651.                             type = 'toggle',
  1652.                             name = L["Sum Spell Hit Rating"],
  1653.                             desc = L["Spell Hit Rating Summary"],
  1654.                             arg = "sumSpellHitRating",
  1655.                             get = getProfileOption,
  1656.                             set = setProfileOptionAndClearCache,
  1657.                         },
  1658.                         crit = {
  1659.                             type = 'toggle',
  1660.                             name = L["Sum Spell Crit Chance"],
  1661.                             desc = L["Spell Crit Chance <- Spell Crit Rating, Intellect"],
  1662.                             arg = "sumSpellCrit",
  1663.                             get = getProfileOption,
  1664.                             set = setProfileOptionAndClearCache,
  1665.                         },
  1666.                         critrating = {
  1667.                             type = 'toggle',
  1668.                             name = L["Sum Spell Crit Rating"],
  1669.                             desc = L["Spell Crit Rating Summary"],
  1670.                             arg = "sumSpellCritRating",
  1671.                             get = getProfileOption,
  1672.                             set = setProfileOptionAndClearCache,
  1673.                         },
  1674.                         haste = {
  1675.                             type = 'toggle',
  1676.                             name = L["Sum Spell Haste"],
  1677.                             desc = L["Spell Haste <- Spell Haste Rating"],
  1678.                             arg = "sumSpellHaste",
  1679.                             get = getProfileOption,
  1680.                             set = setProfileOptionAndClearCache,
  1681.                         },
  1682.                         hasterating = {
  1683.                             type = 'toggle',
  1684.                             name = L["Sum Spell Haste Rating"],
  1685.                             desc = L["Spell Haste Rating Summary"],
  1686.                             arg = "sumSpellHasteRating",
  1687.                             get = getProfileOption,
  1688.                             set = setProfileOptionAndClearCache,
  1689.                         },
  1690.                         pen = {
  1691.                             type = 'toggle',
  1692.                             name = L["Sum Penetration"],
  1693.                             desc = L["Spell Penetration Summary"],
  1694.                             arg = "sumPenetration",
  1695.                             get = getProfileOption,
  1696.                             set = setProfileOptionAndClearCache,
  1697.                         },
  1698.                     },
  1699.                 },
  1700.                 tank = {
  1701.                     type = 'group',
  1702.                     dialogInline = true,
  1703.                     name = L["Stat - Tank"],
  1704.                     desc = L["Choose tank stats for summary"],
  1705.                     args = {
  1706.                         armor = {
  1707.                             type = 'toggle',
  1708.                             name = L["Sum Armor"],
  1709.                             desc = L["Armor <- Armor from items, Armor from bonuses, Agility, Intellect"],
  1710.                             arg = "sumArmor",
  1711.                             get = getProfileOption,
  1712.                             set = setProfileOptionAndClearCache,
  1713.                         },
  1714.                         def = {
  1715.                             type = 'toggle',
  1716.                             name = L["Sum Defense"],
  1717.                             desc = L["Defense <- Defense Rating"],
  1718.                             arg = "sumDefense",
  1719.                             get = getProfileOption,
  1720.                             set = setProfileOptionAndClearCache,
  1721.                         },
  1722.                         dodge = {
  1723.                             type = 'toggle',
  1724.                             name = L["Sum Dodge Chance"],
  1725.                             desc = L["Dodge Chance <- Dodge Rating, Agility, Defense Rating"],
  1726.                             arg = "sumDodge",
  1727.                             get = getProfileOption,
  1728.                             set = setProfileOptionAndClearCache,
  1729.                         },
  1730.                         dodgerating = {
  1731.                             type = 'toggle',
  1732.                             name = L["Sum Dodge Rating"],
  1733.                             desc = L["Dodge Rating Summary"],
  1734.                             arg = "sumDodgeRating",
  1735.                             get = getProfileOption,
  1736.                             set = setProfileOptionAndClearCache,
  1737.                         },
  1738.                         parry = {
  1739.                             type = 'toggle',
  1740.                             name = L["Sum Parry Chance"],
  1741.                             desc = L["Parry Chance <- Parry Rating, Defense Rating"],
  1742.                             arg = "sumParry",
  1743.                             get = getProfileOption,
  1744.                             set = setProfileOptionAndClearCache,
  1745.                         },
  1746.                         parryrating = {
  1747.                             type = 'toggle',
  1748.                             name = L["Sum Parry Rating"],
  1749.                             desc = L["Parry Rating Summary"],
  1750.                             arg = "sumParryRating",
  1751.                             get = getProfileOption,
  1752.                             set = setProfileOptionAndClearCache,
  1753.                         },
  1754.                         block = {
  1755.                             type = 'toggle',
  1756.                             name = L["Sum Block Chance"],
  1757.                             desc = L["Block Chance <- Block Rating, Defense Rating"],
  1758.                             arg = "sumBlock",
  1759.                             get = getProfileOption,
  1760.                             set = setProfileOptionAndClearCache,
  1761.                         },
  1762.                         blockrating = {
  1763.                             type = 'toggle',
  1764.                             name = L["Sum Block Rating"],
  1765.                             desc = L["Block Rating Summary"],
  1766.                             arg = "sumBlockRating",
  1767.                             get = getProfileOption,
  1768.                             set = setProfileOptionAndClearCache,
  1769.                         },
  1770.                         blockvalue = {
  1771.                             type = 'toggle',
  1772.                             name = L["Sum Block Value"],
  1773.                             desc = L["Block Value <- Block Value, Strength"],
  1774.                             arg = "sumBlockValue",
  1775.                             get = getProfileOption,
  1776.                             set = setProfileOptionAndClearCache,
  1777.                         },
  1778.                         avoidhit = {
  1779.                             type = 'toggle',
  1780.                             name = L["Sum Hit Avoidance"],
  1781.                             desc = L["Hit Avoidance <- Defense Rating"],
  1782.                             arg = "sumHitAvoid",
  1783.                             get = getProfileOption,
  1784.                             set = setProfileOptionAndClearCache,
  1785.                         },
  1786.                         avoidcrit = {
  1787.                             type = 'toggle',
  1788.                             name = L["Sum Crit Avoidance"],
  1789.                             desc = L["Crit Avoidance <- Defense Rating, Resilience"],
  1790.                             arg = "sumCritAvoid",
  1791.                             get = getProfileOption,
  1792.                             set = setProfileOptionAndClearCache,
  1793.                         },
  1794.                         res = {
  1795.                             type = 'toggle',
  1796.                             name = L["Sum Resilience"],
  1797.                             desc = L["Resilience Summary"],
  1798.                             arg = "sumResilience",
  1799.                             get = getProfileOption,
  1800.                             set = setProfileOptionAndClearCache,
  1801.                         },
  1802.                         resarcane = {
  1803.                             type = 'toggle',
  1804.                             name = L["Sum Arcane Resistance"],
  1805.                             desc = L["Arcane Resistance Summary"],
  1806.                             arg = "sumArcaneResist",
  1807.                             get = getProfileOption,
  1808.                             set = setProfileOptionAndClearCache,
  1809.                         },
  1810.                         resfire = {
  1811.                             type = 'toggle',
  1812.                             name = L["Sum Fire Resistance"],
  1813.                             desc = L["Fire Resistance Summary"],
  1814.                             arg = "sumFireResist",
  1815.                             get = getProfileOption,
  1816.                             set = setProfileOptionAndClearCache,
  1817.                         },
  1818.                         resnature = {
  1819.                             type = 'toggle',
  1820.                             name = L["Sum Nature Resistance"],
  1821.                             desc = L["Nature Resistance Summary"],
  1822.                             arg = "sumNatureResist",
  1823.                             get = getProfileOption,
  1824.                             set = setProfileOptionAndClearCache,
  1825.                         },
  1826.                         resfrost = {
  1827.                             type = 'toggle',
  1828.                             name = L["Sum Frost Resistance"],
  1829.                             desc = L["Frost Resistance Summary"],
  1830.                             arg = "sumFrostResist",
  1831.                             get = getProfileOption,
  1832.                             set = setProfileOptionAndClearCache,
  1833.                         },
  1834.                         resshadow = {
  1835.                             type = 'toggle',
  1836.                             name = L["Sum Shadow Resistance"],
  1837.                             desc = L["Shadow Resistance Summary"],
  1838.                             arg = "sumShadowResist",
  1839.                             get = getProfileOption,
  1840.                             set = setProfileOptionAndClearCache,
  1841.                         },
  1842.                         avoid = {
  1843.                             type = 'toggle',
  1844.                             name = L["Sum Avoidance"],
  1845.                             desc = L["Avoidance <- Dodge, Parry, MobMiss, Block(Optional)"],
  1846.                             arg = "sumAvoidance",
  1847.                             get = getProfileOption,
  1848.                             set = setProfileOptionAndClearCache,
  1849.                         },
  1850.                     },
  1851.                 },
  1852.                 gemset = {
  1853.                     type = 'select',
  1854.                     order = 12,
  1855.                     cmdHidden = true,
  1856.                     name = L["Gem Set"],
  1857.                     desc = L["Select a gem set to configure"],
  1858.                     values = {
  1859.                         [1] = L["Default Gem Set 1"],
  1860.                         [2] = L["Default Gem Set 2"],
  1861.                         [3] = L["Default Gem Set 3"],
  1862.                     },
  1863.                     arg = "selectedGemSet",
  1864.                     get = function() return selectedGemSet end,
  1865.                     set = function(info, value) selectedGemSet = value end,
  1866.                 },
  1867.                 gem = {
  1868.                     type = 'group',
  1869.                     order = 13,
  1870.                     dialogInline = true,
  1871.                     hidden = function() return selectedGemSet ~= 1 end,
  1872.                     name = L["Default Gem Set 1"],
  1873.                     desc = L["Auto fill empty gem slots"],
  1874.                     args = {
  1875.                         red = {
  1876.                             type = 'input',
  1877.                             order = 1,
  1878.                             width = "double",
  1879.                             name = L["Red Socket"],
  1880.                             desc = L["ItemID or Link of the gem you would like to auto fill"],
  1881.                             usage = L["<ItemID|Link>"],
  1882.                             arg = "sumGemRed",
  1883.                             get = getGem,
  1884.                             set = setGem,
  1885.                         },
  1886.                         yellow = {
  1887.                             type = 'input',
  1888.                             order = 2,
  1889.                             width = "double",
  1890.                             name = L["Yellow Socket"],
  1891.                             desc = L["ItemID or Link of the gem you would like to auto fill"],
  1892.                             usage = L["<ItemID|Link>"],
  1893.                             arg = "sumGemYellow",
  1894.                             get = getGem,
  1895.                             set = setGem,
  1896.                         },
  1897.                         blue = {
  1898.                             type = 'input',
  1899.                             order = 3,
  1900.                             width = "double",
  1901.                             name = L["Blue Socket"],
  1902.                             desc = L["ItemID or Link of the gem you would like to auto fill"],
  1903.                             usage = L["<ItemID|Link>"],
  1904.                             arg = "sumGemBlue",
  1905.                             get = getGem,
  1906.                             set = setGem,
  1907.                         },
  1908.                         meta = {
  1909.                             type = 'input',
  1910.                             order = 4,
  1911.                             width = "double",
  1912.                             name = L["Meta Socket"],
  1913.                             desc = L["ItemID or Link of the gem you would like to auto fill"],
  1914.                             usage = L["<ItemID|Link>"],
  1915.                             arg = "sumGemMeta",
  1916.                             get = getGem,
  1917.                             set = setGem,
  1918.                         },
  1919.                     },
  1920.                 },
  1921.                 gem2 = {
  1922.                     type = 'group',
  1923.                     order = 14,
  1924.                     dialogInline = true,
  1925.                     hidden = function() return selectedGemSet ~= 2 end,
  1926.                     name = L["Default Gem Set 2"],
  1927.                     desc = L["Second set of default gems which can be toggled with a modifier key"],
  1928.                     args = {
  1929.                         key = {
  1930.                             type = 'select',
  1931.                             order = 0,
  1932.                             name = L["Toggle Key"],
  1933.                             desc = L["Use this key to toggle alternate gems"],
  1934.                             values = {
  1935.                                 [1] = L["ALT Key"],
  1936.                                 [2] = L["CTRL Key"],
  1937.                                 [3] = L["SHIFT Key"],
  1938.                                 [4] = L["Never"],
  1939.                             },
  1940.                             arg = "sumGem2Toggle",
  1941.                             get = function() return profileDB.sumGem2Toggle end,
  1942.                             set = function(info, value)
  1943.                                 if value ~= 4 and value == profileDB.sumGem3Toggle then
  1944.                                     AceConfigRegistry:NotifyChange("RatingBuster")
  1945.                                     RatingBuster:Print(L["Can't use the same modifier as Gem Set 3"])
  1946.                                 else
  1947.                                     profileDB.sumGem2Toggle = value
  1948.                                 end
  1949.                             end,
  1950.                         },
  1951.                         red = {
  1952.                             type = 'input',
  1953.                             order = 1,
  1954.                             width = "double",
  1955.                             name = L["Red Socket"],
  1956.                             desc = L["ItemID or Link of the gem you would like to auto fill"],
  1957.                             usage = L["<ItemID|Link>"],
  1958.                             arg = "sumGemRed2",
  1959.                             get = getGem,
  1960.                             set = setGem,
  1961.                             disabled = function() return profileDB.sumGem2Toggle == 4 end,
  1962.                         },
  1963.                         yellow = {
  1964.                             type = 'input',
  1965.                             order = 2,
  1966.                             width = "double",
  1967.                             name = L["Yellow Socket"],
  1968.                             desc = L["ItemID or Link of the gem you would like to auto fill"],
  1969.                             usage = L["<ItemID|Link>"],
  1970.                             arg = "sumGemYellow2",
  1971.                             get = getGem,
  1972.                             set = setGem,
  1973.                             disabled = function() return profileDB.sumGem2Toggle == 4 end,
  1974.                         },
  1975.                         blue = {
  1976.                             type = 'input',
  1977.                             order = 3,
  1978.                             width = "double",
  1979.                             name = L["Blue Socket"],
  1980.                             desc = L["ItemID or Link of the gem you would like to auto fill"],
  1981.                             usage = L["<ItemID|Link>"],
  1982.                             arg = "sumGemBlue2",
  1983.                             get = getGem,
  1984.                             set = setGem,
  1985.                             disabled = function() return profileDB.sumGem2Toggle == 4 end,
  1986.                         },
  1987.                         meta = {
  1988.                             type = 'input',
  1989.                             order = 4,
  1990.                             width = "double",
  1991.                             name = L["Meta Socket"],
  1992.                             desc = L["ItemID or Link of the gem you would like to auto fill"],
  1993.                             usage = L["<ItemID|Link>"],
  1994.                             arg = "sumGemMeta2",
  1995.                             get = getGem,
  1996.                             set = setGem,
  1997.                             disabled = function() return profileDB.sumGem2Toggle == 4 end,
  1998.                         },
  1999.                     },
  2000.                 },
  2001.                 gem3 = {
  2002.                     type = 'group',
  2003.                     order = 15,
  2004.                     dialogInline = true,
  2005.                     hidden = function() return selectedGemSet ~= 3 end,
  2006.                     name = L["Default Gem Set 3"],
  2007.                     desc = L["Third set of default gems which can be toggled with a modifier key"],
  2008.                     args = {
  2009.                         key = {
  2010.                             type = 'select',
  2011.                             order = 0,
  2012.                             name = L["Toggle Key"],
  2013.                             desc = L["Use this key to toggle alternate gems"],
  2014.                             values = {
  2015.                                 [1] = L["ALT Key"],
  2016.                                 [2] = L["CTRL Key"],
  2017.                                 [3] = L["SHIFT Key"],
  2018.                                 [4] = L["Never"],
  2019.                             },
  2020.                             arg = "sumGem3Toggle",
  2021.                             get = function() return profileDB.sumGem3Toggle end,
  2022.                             set = function(info, value)
  2023.                                 if value ~= 4 and value == profileDB.sumGem2Toggle then
  2024.                                     AceConfigRegistry:NotifyChange("RatingBuster")
  2025.                                     RatingBuster:Print(L["Can't use the same modifier as Gem Set 2"])
  2026.                                 else
  2027.                                     profileDB.sumGem3Toggle = value
  2028.                                 end
  2029.                             end,
  2030.                         },
  2031.                         red = {
  2032.                             type = 'input',
  2033.                             order = 1,
  2034.                             width = "double",
  2035.                             name = L["Red Socket"],
  2036.                             desc = L["ItemID or Link of the gem you would like to auto fill"],
  2037.                             usage = L["<ItemID|Link>"],
  2038.                             arg = "sumGemRed3",
  2039.                             get = getGem,
  2040.                             set = setGem,
  2041.                             disabled = function() return profileDB.sumGem3Toggle == 4 end,
  2042.                         },
  2043.                         yellow = {
  2044.                             type = 'input',
  2045.                             order = 2,
  2046.                             width = "double",
  2047.                             name = L["Yellow Socket"],
  2048.                             desc = L["ItemID or Link of the gem you would like to auto fill"],
  2049.                             usage = L["<ItemID|Link>"],
  2050.                             arg = "sumGemYellow3",
  2051.                             get = getGem,
  2052.                             set = setGem,
  2053.                             disabled = function() return profileDB.sumGem3Toggle == 4 end,
  2054.                         },
  2055.                         blue = {
  2056.                             type = 'input',
  2057.                             order = 3,
  2058.                             width = "double",
  2059.                             name = L["Blue Socket"],
  2060.                             desc = L["ItemID or Link of the gem you would like to auto fill"],
  2061.                             usage = L["<ItemID|Link>"],
  2062.                             arg = "sumGemBlue3",
  2063.                             get = getGem,
  2064.                             set = setGem,
  2065.                             disabled = function() return profileDB.sumGem3Toggle == 4 end,
  2066.                         },
  2067.                         meta = {
  2068.                             type = 'input',
  2069.                             order = 4,
  2070.                             width = "double",
  2071.                             name = L["Meta Socket"],
  2072.                             desc = L["ItemID or Link of the gem you would like to auto fill"],
  2073.                             usage = L["<ItemID|Link>"],
  2074.                             arg = "sumGemMeta3",
  2075.                             get = getGem,
  2076.                             set = setGem,
  2077.                             disabled = function() return profileDB.sumGem3Toggle == 4 end,
  2078.                         },
  2079.                     },
  2080.                 },
  2081.             },
  2082.         },
  2083.     },
  2084. }
  2085.  
  2086. -- TankPoints support, version check
  2087. local tpSupport
  2088. local tpLocale
  2089. if TankPoints and (tonumber(strsub(TankPoints.version, 1, 3)) >= 2.6) then
  2090.     tpSupport = true
  2091.     tpLocale = AceLibrary("AceLocale-2.2"):new("TankPoints")
  2092.     options.args.sum.args.tank.args.tp = {
  2093.         type = 'toggle',
  2094.         name = L["Sum TankPoints"],
  2095.         desc = L["TankPoints <- Health, Total Reduction"],
  2096.         arg = "sumTankPoints",
  2097.         get = getProfileOption,
  2098.         set = setProfileOptionAndClearCache,
  2099.     }
  2100.     options.args.sum.args.tank.args.tr = {
  2101.         type = 'toggle',
  2102.         name = L["Sum Total Reduction"],
  2103.         desc = L["Total Reduction <- Armor, Dodge, Parry, Block, Block Value, Defense, Resilience, MobMiss, MobCrit, MobCrush, DamageTakenMods"],
  2104.         arg = "sumTotalReduction",
  2105.         get = getProfileOption,
  2106.         set = setProfileOptionAndClearCache,
  2107.     }
  2108.     --[[
  2109.     options.args.sum.args.tank.args.avoid = {
  2110.         type = 'toggle',
  2111.         name = L["Sum Avoidance"],
  2112.         desc = L["Avoidance <- Dodge, Parry, MobMiss"],
  2113.         arg = "sumAvoidance",
  2114.         get = getProfileOption,
  2115.         set = setProfileOptionAndClearCache,
  2116.     }
  2117.     --]]
  2118. end
  2119.  
  2120.  
  2121. -- Class specific options
  2122. if class == "DRUID" then
  2123.     options.args.stat.args.agi.args.heal = { -- Nurturing Instinct (Rank 2) - 2,14
  2124.         type = 'toggle',
  2125.         width = "full",
  2126.         name = L["Show Healing"].." ("..GetSpellInfo(47180)..")",                       -- ["Nurturing Instinct"]
  2127.         desc = L["Show Healing from Agility"].." ("..GetSpellInfo(47180)..")",          -- ["Nurturing Instinct"]
  2128.         arg = "showHealingFromAgi",
  2129.         get = getProfileOption,
  2130.         set = setProfileOptionAndClearCache,
  2131.     }
  2132.     options.args.stat.args.int.args.dmg = { -- Lunar Guidance (Rank 3) - 1,12
  2133.         type = 'toggle',
  2134.         width = "full",
  2135.         name = L["Show Spell Damage"].." ("..GetSpellInfo(33591)..")",                  -- ["Lunar Guidance"]
  2136.         desc = L["Show Spell Damage from Intellect"].." ("..GetSpellInfo(33591)..")",   -- ["Lunar Guidance"]
  2137.         arg = "showSpellDmgFromInt",
  2138.         get = getProfileOption,
  2139.         set = setProfileOptionAndClearCache,
  2140.     }
  2141.     options.args.stat.args.int.args.heal = { -- Lunar Guidance (Rank 3) - 1,12
  2142.         type = 'toggle',
  2143.         width = "full",
  2144.         name = L["Show Healing"].." ("..GetSpellInfo(33591)..")",
  2145.         desc = L["Show Healing from Intellect"].." ("..GetSpellInfo(33591)..")",
  2146.         arg = "showHealingFromInt",
  2147.         get = getProfileOption,
  2148.         set = setProfileOptionAndClearCache,
  2149.     }
  2150.     options.args.stat.args.spi.args.mp5 = { -- Intensity (Rank 3) - 3,6
  2151.         type = 'toggle',
  2152.         width = "full",
  2153.         name = L["Show Mana Regen"].." ("..GetSpellInfo(35359)..")",
  2154.         desc = L["Show Mana Regen while casting from Spirit"].." ("..GetSpellInfo(35359)..")",
  2155.         arg = "showMP5FromSpi",
  2156.         get = getProfileOption,
  2157.         set = setProfileOptionAndClearCache,
  2158.     }
  2159.     options.args.stat.args.spi.args.dmg = { -- Improved Moonkin Form (Rank 3) - 1,19
  2160.         type = 'toggle',
  2161.         width = "full",
  2162.         name = L["Show Spell Damage"].." ("..GetSpellInfo(48384)..")",                
  2163.         desc = L["Show Spell Damage from Spirit"].." ("..GetSpellInfo(48384)..")",    
  2164.         arg = "showSpellDmgFromSpi",
  2165.         get = getProfileOption,
  2166.         set = setProfileOptionAndClearCache,
  2167.     }
  2168.     options.args.stat.args.spi.args.heal = { -- Improved Tree of Life (Rank 3) - 3,24
  2169.         type = 'toggle',
  2170.         width = "full",
  2171.         name = L["Show Healing"].." ("..GetSpellInfo(48537)..")",                
  2172.         desc = L["Show Healing from Spirit"].." ("..GetSpellInfo(48537)..")",    
  2173.         arg = "showHealingFromSpi",
  2174.         get = getProfileOption,
  2175.         set = setProfileOptionAndClearCache,
  2176.     }
  2177. elseif class == "HUNTER" then
  2178.     options.args.stat.args.int.args.rap = { -- Careful Aim
  2179.         type = 'toggle',
  2180.         width = "full",
  2181.         name = L["Show Ranged Attack Power"].." ("..GetSpellInfo(34484)..")",
  2182.         desc = L["Show Ranged Attack Power from Intellect"].." ("..GetSpellInfo(34484)..")",
  2183.         arg = "showRAPFromInt",
  2184.         get = getProfileOption,
  2185.         set = setProfileOptionAndClearCache,
  2186.     }
  2187.     options.args.stat.args.sta.args.ap = { -- Hunter: Hunter vs. Wild
  2188.         type = 'toggle',
  2189.         width = "full",
  2190.         name = L["Show Attack Power"].." ("..GetSpellInfo(56341)..")",
  2191.         desc = L["Show Attack Power from Stamina"].." ("..GetSpellInfo(56341)..")",
  2192.         arg = "showAPFromSta",
  2193.         get = getProfileOption,
  2194.         set = setProfileOptionAndClearCache,
  2195.     }
  2196. elseif class == "MAGE" then
  2197.     options.args.stat.args.int.args.dmg = { -- Mind Mastery (Rank 5) - 1,22
  2198.         type = 'toggle',
  2199.         width = "full",
  2200.         name = L["Show Spell Damage"].." ("..GetSpellInfo(31588)..")",
  2201.         desc = L["Show Spell Damage from Intellect"].." ("..GetSpellInfo(31588)..")",
  2202.         arg = "showSpellDmgFromInt",
  2203.         get = getProfileOption,
  2204.         set = setProfileOptionAndClearCache,
  2205.     }
  2206.     options.args.stat.args.int.args.armor = { -- Arcane Fortitude - 1,9
  2207.         type = 'toggle',
  2208.         width = "full",
  2209.         name = L["Show Armor"].." ("..GetSpellInfo(28574)..")",
  2210.         desc = L["Show Armor from Intellect"].." ("..GetSpellInfo(28574)..")",
  2211.         arg = "showArmorFromInt",
  2212.         get = getProfileOption,
  2213.         set = setProfileOptionAndClearCache,
  2214.     }
  2215.     options.args.stat.args.spi.args.mp5 = { -- Arcane Meditation (Rank 3) - 1,12
  2216.         type = 'toggle',
  2217.         width = "full",
  2218.         name = L["Show Mana Regen"].." ("..GetSpellInfo(18464)..")",
  2219.         desc = L["Show Mana Regen while casting from Spirit"].." ("..GetSpellInfo(18464)..")",
  2220.         arg = "showMP5FromSpi",
  2221.         get = getProfileOption,
  2222.         set = setProfileOptionAndClearCache,
  2223.     }
  2224.     options.args.stat.args.spi.args.spellcrit = { -- Molten Armor
  2225.         type = 'toggle',
  2226.         width = "full",
  2227.         name = L["Show Spell Crit"].." ("..GetSpellInfo(30482)..")",
  2228.         desc = L["Show Spell Crit chance from Spirit"].." ("..GetSpellInfo(30482)..")",
  2229.         arg = "showSpellCritFromSpi",
  2230.         get = getProfileOption,
  2231.         set = setProfileOptionAndClearCache,
  2232.     }
  2233. elseif class == "PALADIN" then
  2234.     options.args.stat.args.int.args.dmg = { -- Paladin: Holy Guidance (Rank 5) - 1,19
  2235.         type = 'toggle',
  2236.         width = "full",
  2237.         name = L["Show Spell Damage"].." ("..GetSpellInfo(31841)..")",
  2238.         desc = L["Show Spell Damage from Intellect"].." ("..GetSpellInfo(31841)..")",
  2239.         arg = "showSpellDmgFromInt",
  2240.         get = getProfileOption,
  2241.         set = setProfileOptionAndClearCache,
  2242.     }
  2243.     options.args.stat.args.int.args.heal = { -- Paladin: Holy Guidance (Rank 5) - 1,19
  2244.         type = 'toggle',
  2245.         width = "full",
  2246.         name = L["Show Healing"].." ("..GetSpellInfo(31841)..")",
  2247.         desc = L["Show Healing from Intellect"].." ("..GetSpellInfo(31841)..")",
  2248.         arg = "showHealingFromInt",
  2249.         get = getProfileOption,
  2250.         set = setProfileOptionAndClearCache,
  2251.     }
  2252.     options.args.stat.args.str.args.dmg = { -- Paladin: Sheath of Light, Touched by the Light
  2253.         type = 'toggle',
  2254.         width = "full",
  2255.         name = L["Show Spell Damage"].." ("..GetSpellInfo(53501)..", "..GetSpellInfo(53592)..")",
  2256.         desc = L["Show Spell Damage from Strength"].." ("..GetSpellInfo(53501)..", "..GetSpellInfo(53592)..")",
  2257.         arg = "showSpellDmgFromStr",
  2258.         get = getProfileOption,
  2259.         set = setProfileOptionAndClearCache,
  2260.     }
  2261.     options.args.stat.args.str.args.heal = { -- Paladin: Sheath of Light, Touched by the Light
  2262.         type = 'toggle',
  2263.         width = "full",
  2264.         name = L["Show Healing"].." ("..GetSpellInfo(53501)..", "..GetSpellInfo(53592)..")",
  2265.         desc = L["Show Healing from Strength"].." ("..GetSpellInfo(53501)..", "..GetSpellInfo(53592)..")",
  2266.         arg = "showHealingFromStr",
  2267.         get = getProfileOption,
  2268.         set = setProfileOptionAndClearCache,
  2269.     }
  2270. elseif class == "PRIEST" then
  2271.     options.args.stat.args.spi.args.mp5 = { -- Meditation (Rank 3) - 1,9
  2272.         type = 'toggle',
  2273.         width = "full",
  2274.         name = L["Show Mana Regen"].." ("..GetSpellInfo(38346)..")",
  2275.         desc = L["Show Mana Regen while casting from Spirit"].." ("..GetSpellInfo(38346)..")",
  2276.         arg = "showMP5FromSpi",
  2277.         get = getProfileOption,
  2278.         set = setProfileOptionAndClearCache,
  2279.     }
  2280.     options.args.stat.args.spi.args.dmg = { -- Spiritual Guidance (Rank 5) - 2,14, Twisted Faith - 3,26
  2281.         type = 'toggle',
  2282.         width = "full",
  2283.         name = L["Show Spell Damage"].." ("..GetSpellInfo(15031)..", "..GetSpellInfo(47573)..")",
  2284.         desc = L["Show Spell Damage from Spirit"].." ("..GetSpellInfo(15031)..", "..GetSpellInfo(47573)..")",
  2285.         arg = "showSpellDmgFromSpi",
  2286.         get = getProfileOption,
  2287.         set = setProfileOptionAndClearCache,
  2288.     }
  2289.     options.args.stat.args.spi.args.heal = { -- Spiritual Guidance (Rank 5) - 2,14, Twisted Faith - 3,26
  2290.         type = 'toggle',
  2291.         width = "full",
  2292.         name = L["Show Healing"].." ("..GetSpellInfo(15031)..", "..GetSpellInfo(47573)..")",
  2293.         desc = L["Show Healing from Spirit"].." ("..GetSpellInfo(15031)..", "..GetSpellInfo(47573)..")",
  2294.         arg = "showHealingFromSpi",
  2295.         get = getProfileOption,
  2296.         set = setProfileOptionAndClearCache,
  2297.     }
  2298. elseif class == "ROGUE" then
  2299. elseif class == "SHAMAN" then
  2300.     options.args.stat.args.str.args.dmg = { -- Mental Quickness (Rank 3) - 2,15
  2301.         type = 'toggle',
  2302.         width = "full",
  2303.         name = L["Show Spell Damage"].." ("..GetSpellInfo(30814)..")",
  2304.         desc = L["Show Spell Damage from Strength"].." ("..GetSpellInfo(30814)..")",
  2305.         arg = "showSpellDmgFromStr",
  2306.         get = getProfileOption,
  2307.         set = setProfileOptionAndClearCache,
  2308.     }
  2309.     options.args.stat.args.str.args.heal = { -- Mental Quickness (Rank 3) - 2,15
  2310.         type = 'toggle',
  2311.         width = "full",
  2312.         name = L["Show Healing"].." ("..GetSpellInfo(30814)..")",
  2313.         desc = L["Show Healing from Strength"].." ("..GetSpellInfo(30814)..")",
  2314.         arg = "showHealingFromStr",
  2315.         get = getProfileOption,
  2316.         set = setProfileOptionAndClearCache,
  2317.     }
  2318.     options.args.stat.args.int.args.dmg = { -- Nature's Blessing (Rank 3) - 3,18
  2319.         type = 'toggle',
  2320.         width = "full",
  2321.         name = L["Show Spell Damage"].." ("..GetSpellInfo(30869)..")",
  2322.         desc = L["Show Spell Damage from Intellect"].." ("..GetSpellInfo(30869)..")",
  2323.         arg = "showSpellDmgFromInt",
  2324.         get = getProfileOption,
  2325.         set = setProfileOptionAndClearCache,
  2326.     }
  2327.     options.args.stat.args.int.args.heal = { -- Nature's Blessing (Rank 3) - 3,18
  2328.         type = 'toggle',
  2329.         width = "full",
  2330.         name = L["Show Healing"].." ("..GetSpellInfo(30869)..")",
  2331.         desc = L["Show Healing from Intellect"].." ("..GetSpellInfo(30869)..")",
  2332.         arg = "showHealingFromInt",
  2333.         get = getProfileOption,
  2334.         set = setProfileOptionAndClearCache,
  2335.     }
  2336.     options.args.stat.args.int.args.ap = { -- Shaman: Mental Dexterity
  2337.         type = 'toggle',
  2338.         width = "full",
  2339.         name = L["Show Attack Power"].." ("..GetSpellInfo(51885)..")",
  2340.         desc = L["Show Attack Power from Intellect"].." ("..GetSpellInfo(51885)..")",
  2341.         arg = "showAPFromInt",
  2342.         get = getProfileOption,
  2343.         set = setProfileOptionAndClearCache,
  2344.     }
  2345. elseif class == "WARLOCK" then
  2346.     options.args.stat.args.sta.args.dmg = { -- Demonic Knowledge (Rank 3) - 2,20 - UnitExists("pet")
  2347.         type = 'toggle',
  2348.         width = "full",
  2349.         name = L["Show Spell Damage"].." ("..GetSpellInfo(35693)..")",
  2350.         desc = L["Show Spell Damage from Stamina"].." ("..GetSpellInfo(35693)..")",
  2351.         arg = "showSpellDmgFromSta",
  2352.         get = getProfileOption,
  2353.         set = setProfileOptionAndClearCache,
  2354.     }
  2355.     options.args.stat.args.int.args.dmg = { -- Demonic Knowledge (Rank 3) - 2,20 - UnitExists("pet")
  2356.         type = 'toggle',
  2357.         width = "full",
  2358.         name = L["Show Spell Damage"].." ("..GetSpellInfo(35693)..")",
  2359.         desc = L["Show Spell Damage from Intellect"].." ("..GetSpellInfo(35693)..")",
  2360.         arg = "showSpellDmgFromInt",
  2361.         get = getProfileOption,
  2362.         set = setProfileOptionAndClearCache,
  2363.     }
  2364.     options.args.stat.args.spi.args.dmg = { -- Warlock: Fel Armor
  2365.         type = 'toggle',
  2366.         width = "full",
  2367.         name = L["Show Spell Damage"].." ("..GetSpellInfo(28176)..")",
  2368.         desc = L["Show Spell Damage from Spirit"].." ("..GetSpellInfo(28176)..")",
  2369.         arg = "showSpellDmgFromSpi",
  2370.         get = getProfileOption,
  2371.         set = setProfileOptionAndClearCache,
  2372.     }
  2373.     options.args.stat.args.spi.args.heal = { -- Warlock: Fel Armor
  2374.         type = 'toggle',
  2375.         width = "full",
  2376.         name = L["Show Healing"].." ("..GetSpellInfo(28176)..")",
  2377.         desc = L["Show Healing from Spirit"].." ("..GetSpellInfo(28176)..")",
  2378.         arg = "showHealingFromSpi",
  2379.         get = getProfileOption,
  2380.         set = setProfileOptionAndClearCache,
  2381.     }
  2382. elseif class == "WARRIOR" then
  2383.     options.args.stat.args.armor = { -- Armored to the Teeth (Rank 3) - 2,1
  2384.         type = 'group',
  2385.         order = 7,
  2386.         name = L["Armor"],
  2387.         desc = L["Changes the display of Armor"],
  2388.         args = {
  2389.             ap = {
  2390.                 type = 'toggle',
  2391.                 width = "full",
  2392.                 name = L["Show Attack Power"],
  2393.                 desc = L["Show Attack Power from Armor"],
  2394.                 arg = "showAPFromArmor",
  2395.                 get = getProfileOption,
  2396.                 set = setProfileOptionAndClearCache,
  2397.             },
  2398.         },
  2399.     }
  2400. elseif class == "DEATHKNIGHT" then
  2401.     options.args.stat.args.str.args.parry = { -- Death Knight: Forceful Deflection - Passive
  2402.         type = 'toggle',
  2403.         width = "full",
  2404.         name = L["Show Parry"].." ("..GetSpellInfo(49410)..")",
  2405.         desc = L["Show Parry from Strength"].." ("..GetSpellInfo(49410)..")",
  2406.         arg = "showParryFromStr",
  2407.         get = getProfileOption,
  2408.         set = setProfileOptionAndClearCache,
  2409.     }
  2410.     options.args.stat.args.armor = { -- Bladed Armor (Rank 5) - 1,4
  2411.         type = 'group',
  2412.         order = 7,
  2413.         name = L["Armor"],
  2414.         desc = L["Changes the display of Armor"],
  2415.         args = {
  2416.             ap = {
  2417.                 type = 'toggle',
  2418.                 width = "full",
  2419.                 name = L["Show Attack Power"],
  2420.                 desc = L["Show Attack Power from Armor"],
  2421.                 arg = "showAPFromArmor",
  2422.                 get = getProfileOption,
  2423.                 set = setProfileOptionAndClearCache,
  2424.             },
  2425.         },
  2426.     }
  2427. end
  2428.  
  2429. function RatingBuster:SetupOptions()
  2430.     -- Inject profile options
  2431.     options.args.profile = LibStub("AceDBOptions-3.0"):GetOptionsTable(self.db)
  2432.     options.args.profile.order = -2
  2433.    
  2434.     -- Add dual-spec support
  2435.     local LibDualSpec = LibStub("LibDualSpec-1.0", true)
  2436.     if LibDualSpec then
  2437.         LibDualSpec:EnhanceDatabase(self.db, "RatingBuster")
  2438.         LibDualSpec:EnhanceOptions(options.args.profile, self.db)
  2439.     end
  2440.    
  2441.     -- Register options table
  2442.     AceConfig:RegisterOptionsTable("RatingBuster", options, {"rb", "rabu", "ratingbuster"})
  2443.    
  2444.     -- Setup Blizzard option frames
  2445.     self.optionsFrames = {}
  2446.     -- The ordering here matters, it determines the order in the Blizzard Interface Options
  2447.     self.optionsFrames.general = AceConfigDialog:AddToBlizOptions("RatingBuster", nil, nil, "general")
  2448.     self.optionsFrames.rating = AceConfigDialog:AddToBlizOptions("RatingBuster", L["Rating"], "RatingBuster", "rating")
  2449.     self.optionsFrames.stat = AceConfigDialog:AddToBlizOptions("RatingBuster", L["Stat Breakdown"], "RatingBuster", "stat")
  2450.     self.optionsFrames.sum = AceConfigDialog:AddToBlizOptions("RatingBuster", L["Stat Summary"], "RatingBuster", "sum")
  2451.     self.optionsFrames.profile = AceConfigDialog:AddToBlizOptions("RatingBuster", L["Profiles"], "RatingBuster", "profile")
  2452.     --self.optionsFrames.help = AceConfigDialog:AddToBlizOptions("RatingBuster", L["Help File"], "RatingBuster", "Help")
  2453. end
  2454.  
  2455. function RatingBuster:ShowConfig()
  2456.     -- Open the profiles tab before, so the menu expands
  2457.     InterfaceOptionsFrame_OpenToCategory(self.optionsFrames.profile)
  2458.     InterfaceOptionsFrame_OpenToCategory(self.optionsFrames.general)
  2459. end
  2460.  
  2461. -----------
  2462. -- Tools --
  2463. -----------
  2464. -- copyTable
  2465. local function copyTable(to, from)
  2466.     if to then
  2467.         for k in pairs(to) do
  2468.             to[k] = nil
  2469.         end
  2470.         setmetatable(to, nil)
  2471.     else
  2472.         to = {}
  2473.     end
  2474.     for k,v in pairs(from) do
  2475.         if type(k) == "table" then
  2476.             k = copyTable({}, k)
  2477.         end
  2478.         if type(v) == "table" then
  2479.             v = copyTable({}, v)
  2480.         end
  2481.         to[k] = v
  2482.     end
  2483.     setmetatable(to, getmetatable(from))
  2484.     return to
  2485. end
  2486.  
  2487. ------------------------------------
  2488. -- Hide Blizzard Item Comparisons --
  2489. ------------------------------------
  2490. local function HookSetHyperlinkCompareItem(shoppingtip)
  2491.     local old = shoppingtip.SetHyperlinkCompareItem
  2492.     shoppingtip.SetHyperlinkCompareItem = function(self, link, level, shift, main, ...)
  2493.         if profileDB.hideBlizzardComparisons then
  2494.             main = nil
  2495.         end
  2496.         return old(self, link, level, shift, main, ...)
  2497.     end
  2498. end
  2499.  
  2500. ---------
  2501. -- API --
  2502. ---------
  2503. function RatingBuster:GetStatMod(stat, school, talentGroup)
  2504.   return StatLogic:GetStatMod(stat, school, talentGroup)
  2505. end
  2506. function RatingBuster:ClearCache()
  2507.   clearCache()
  2508. end
  2509.  
  2510. ---------------------
  2511. -- Initializations --
  2512. ---------------------
  2513. --[[ Loading Process Event Reference
  2514. {
  2515. ADDON_LOADED - When this addon is loaded
  2516. VARIABLES_LOADED - When all addons are loaded
  2517. PLAYER_LOGIN - Most information about the game world should now be available to the UI
  2518. }
  2519. --]]
  2520.  
  2521. function RatingBuster:OnProfileChanged(event, database, newProfileKey)
  2522.     -- this is called every time our profile changes (after the change)
  2523.     profileDB = database.profile
  2524.     clearCache()
  2525. end
  2526.  
  2527. -- OnInitialize(name) called at ADDON_LOADED
  2528. function RatingBuster:OnInitialize()
  2529.     -- Create DB
  2530.     self.db = AceDB:New("RatingBusterDB", defaults)
  2531.     self.db.RegisterCallback(self, "OnProfileChanged", "OnProfileChanged")
  2532.     self.db.RegisterCallback(self, "OnProfileCopied", "OnProfileChanged")
  2533.     self.db.RegisterCallback(self, "OnProfileReset", "OnProfileChanged")
  2534.    
  2535.     profileDB = self.db.profile
  2536.  
  2537.     self:SetupOptions()
  2538.    
  2539.     -- Hook ShoppingTooltips to enable options to Hide Blizzard Item Comparisons
  2540.     HookSetHyperlinkCompareItem(ShoppingTooltip1)
  2541.     HookSetHyperlinkCompareItem(ShoppingTooltip2)
  2542.     HookSetHyperlinkCompareItem(ShoppingTooltip3)
  2543. end
  2544.  
  2545. -- OnEnable() called at PLAYER_LOGIN
  2546. function RatingBuster:OnEnable()
  2547.     -- Hook item tooltips
  2548.     TipHooker:Hook(self.ProcessTooltip, "item")
  2549.     -- Initialize playerLevel
  2550.     playerLevel = UnitLevel("player")
  2551.     -- for setting a new level
  2552.     self:RegisterEvent("PLAYER_LEVEL_UP")
  2553.     -- Events that require cache clearing
  2554.     self:RegisterEvent("CHARACTER_POINTS_CHANGED", clearCache) -- talent point changed
  2555.     self:RegisterEvent("MODIFIER_STATE_CHANGED") -- modifier key press
  2556.     self:RegisterEvent("UNIT_AURA") -- fire at most once every 1 second
  2557. end
  2558.  
  2559. function RatingBuster:OnDisable()
  2560.     -- Unhook item tooltips
  2561.     TipHooker:Unhook(self.ProcessTooltip, "item")
  2562. end
  2563.  
  2564. -- event = PLAYER_LEVEL_UP
  2565. -- arg1 = New player level
  2566. function RatingBuster:PLAYER_LEVEL_UP(event, newlevel)
  2567.     playerLevel = newlevel
  2568.     clearCache()
  2569. end
  2570.  
  2571. -- event = UNIT_AURA
  2572. -- arg1 = the UnitID of the entity
  2573. function RatingBuster:UNIT_AURA(event, unit)
  2574.     if unit ~= "player" then return end
  2575.     clearCache()
  2576. end
  2577. --local tooltips = {}
  2578. function RatingBuster:MODIFIER_STATE_CHANGED(event, key, state)
  2579.     -- self:Print("MODIFIER_STATE_CHANGED")
  2580.     -- for tooltip, link in pairs(tooltips) do
  2581.         -- if tooltip:IsShown() and not strfind(tooltip:GetName(), "ompar") and not strfind(tooltip:GetName(), "Shopping") then
  2582.             -- tooltip:ClearLines()
  2583.             -- ShowUIPanel(tooltip)
  2584.             -- tooltip:SetHyperlink(link)
  2585.         -- end
  2586.     -- end
  2587.     clearCache()
  2588. end
  2589.  
  2590. --------------------------
  2591. -- Process Tooltip Core --
  2592. --------------------------
  2593. --[[
  2594. "+15 Agility"
  2595. -> "+15 Agility (+0.46% Crit)"
  2596. "+15 Crit Rating"
  2597. -> "+15 Crit Rating (+1.20%)"
  2598. "Equip: Increases your hit rating by 10."
  2599. -> "Equip: Increases your hit rating by 10 (+1.20%)."
  2600. --]]
  2601. -- Empty Sockets
  2602. local EMPTY_SOCKET_RED = EMPTY_SOCKET_RED
  2603. local EMPTY_SOCKET_YELLOW = EMPTY_SOCKET_YELLOW
  2604. local EMPTY_SOCKET_BLUE = EMPTY_SOCKET_BLUE
  2605. local EMPTY_SOCKET_META = EMPTY_SOCKET_META
  2606. local EmptySocketLookup = {
  2607.     [EMPTY_SOCKET_RED] = "sumGemRed", -- EMPTY_SOCKET_RED = "Red Socket";
  2608.     [EMPTY_SOCKET_YELLOW] = "sumGemYellow", -- EMPTY_SOCKET_YELLOW = "Yellow Socket";
  2609.     [EMPTY_SOCKET_BLUE] = "sumGemBlue", -- EMPTY_SOCKET_BLUE = "Blue Socket";
  2610.     [EMPTY_SOCKET_META] = "sumGemMeta", -- EMPTY_SOCKET_META = "Meta Socket";
  2611. }
  2612. -- Color code (used to fix gem text color)
  2613. local currentColorCode
  2614. -- Avoidance DR calculation
  2615. local summaryFunc = {}
  2616. local equippedSum = {}
  2617. local equippedDodge, equippedParry, equippedMissed
  2618. local processedDodge, processedParry, processedMissed
  2619.  
  2620. -- Modifier Keys
  2621. local isModifierKeyDown = {
  2622.     [0] = function() return true end,
  2623.     [1] = IsAltKeyDown,
  2624.     [2] = IsControlKeyDown,
  2625.     [3] = IsShiftKeyDown,
  2626. }
  2627. function RatingBuster.ProcessTooltip(tooltip, name, link, ...)
  2628.     -- Check if we're in standby mode
  2629.     if not RatingBuster:IsEnabled() then return end
  2630.     --tooltips[tooltip] = link
  2631.     ---------------------------
  2632.     -- Set calculation level --
  2633.     ---------------------------
  2634.     calcLevel = profileDB.customLevel or 0
  2635.     if calcLevel == 0 then
  2636.         calcLevel = playerLevel
  2637.     end
  2638.     if profileDB.useRequiredLevel and link then
  2639.         local _, _, _, _, reqLevel = GetItemInfo(link)
  2640.         --RatingBuster:Print(link..", "..calcLevel)
  2641.         if reqLevel and calcLevel < reqLevel then
  2642.             calcLevel = reqLevel
  2643.         end
  2644.     end
  2645.     ---------------------
  2646.     -- Tooltip Scanner --
  2647.     ---------------------
  2648.     -- Get equipped item avoidances
  2649.     if profileDB.enableAvoidanceDiminishingReturns then
  2650.         local red, yellow, blue, meta
  2651.         if isModifierKeyDown[profileDB.sumGem2Toggle] and isModifierKeyDown[profileDB.sumGem2Toggle]() then
  2652.             red = profileDB.sumGemRed2.gemID
  2653.             yellow = profileDB.sumGemYellow2.gemID
  2654.             blue = profileDB.sumGemBlue2.gemID
  2655.             meta = profileDB.sumGemMeta2.gemID
  2656.         elseif isModifierKeyDown[profileDB.sumGem3Toggle] and isModifierKeyDown[profileDB.sumGem3Toggle]() then
  2657.             red = profileDB.sumGemRed3.gemID
  2658.             yellow = profileDB.sumGemYellow3.gemID
  2659.             blue = profileDB.sumGemBlue3.gemID
  2660.             meta = profileDB.sumGemMeta3.gemID
  2661.         else
  2662.             red = profileDB.sumGemRed.gemID
  2663.             yellow = profileDB.sumGemYellow.gemID
  2664.             blue = profileDB.sumGemBlue.gemID
  2665.             meta = profileDB.sumGemMeta.gemID
  2666.         end
  2667.         local _, mainlink, difflink1, difflink2 = StatLogic:GetDiffID(tooltip, profileDB.sumIgnoreEnchant, profileDB.sumIgnoreGems, red, yellow, blue, meta, profileDB.sumIgnorePris)
  2668.         StatLogic:GetSum(difflink1, equippedSum)
  2669.         equippedSum["STR"] = (equippedSum["STR"] or 0) * RatingBuster:GetStatMod("MOD_STR")
  2670.         equippedSum["AGI"] = (equippedSum["AGI"] or 0) * RatingBuster:GetStatMod("MOD_AGI")
  2671.         equippedDodge = summaryFunc["DODGE_NO_DR"](equippedSum, "sum", difflink1) * -1
  2672.         equippedParry = summaryFunc["PARRY_NO_DR"](equippedSum, "sum", difflink1) * -1
  2673.         equippedMissed = summaryFunc["MELEE_HIT_AVOID_NO_DR"](equippedSum, "sum", difflink1) * -1
  2674.         processedDodge = equippedDodge
  2675.         processedParry = equippedParry
  2676.         processedMissed = equippedMissed
  2677.     else
  2678.         equippedDodge = 0
  2679.         equippedParry = 0
  2680.         equippedMissed = 0
  2681.         processedDodge = 0
  2682.         processedParry = 0
  2683.         processedMissed = 0
  2684.     end
  2685.    
  2686.     if isModifierKeyDown[profileDB.sumGem2Toggle] and isModifierKeyDown[profileDB.sumGem2Toggle]() then
  2687.         EmptySocketLookup[EMPTY_SOCKET_RED] = "sumGemRed2"
  2688.         EmptySocketLookup[EMPTY_SOCKET_YELLOW] = "sumGemYellow2"
  2689.         EmptySocketLookup[EMPTY_SOCKET_BLUE] = "sumGemBlue2"
  2690.         EmptySocketLookup[EMPTY_SOCKET_META] = "sumGemMeta2"
  2691.     elseif isModifierKeyDown[profileDB.sumGem3Toggle] and isModifierKeyDown[profileDB.sumGem3Toggle]() then
  2692.         EmptySocketLookup[EMPTY_SOCKET_RED] = "sumGemRed3"
  2693.         EmptySocketLookup[EMPTY_SOCKET_YELLOW] = "sumGemYellow3"
  2694.         EmptySocketLookup[EMPTY_SOCKET_BLUE] = "sumGemBlue3"
  2695.         EmptySocketLookup[EMPTY_SOCKET_META] = "sumGemMeta3"
  2696.     else
  2697.         EmptySocketLookup[EMPTY_SOCKET_RED] = "sumGemRed"
  2698.         EmptySocketLookup[EMPTY_SOCKET_YELLOW] = "sumGemYellow"
  2699.         EmptySocketLookup[EMPTY_SOCKET_BLUE] = "sumGemBlue"
  2700.         EmptySocketLookup[EMPTY_SOCKET_META] = "sumGemMeta"
  2701.     end
  2702.     -- Loop through tooltip lines starting at line 2
  2703.     local tipTextLeft = tooltip:GetName().."TextLeft"
  2704.     for i = 2, tooltip:NumLines() do
  2705.         local fontString = _G[tipTextLeft..i]
  2706.         local text = fontString:GetText()
  2707.         if text then
  2708.             -- Get data from cache if available
  2709.             local cacheID = text..calcLevel
  2710.             local cacheText = cache[cacheID]
  2711.             if cacheText then
  2712.                 if cacheText ~= text then
  2713.                     fontString:SetText(cacheText)
  2714.                 end
  2715.             elseif EmptySocketLookup[text] and profileDB[EmptySocketLookup[text]].gemText then -- Replace empty sockets with gem text
  2716.                 text = profileDB[EmptySocketLookup[text]].gemText
  2717.                 cache[cacheID] = text
  2718.                 -- SetText
  2719.                 fontString:SetText(text)
  2720.             elseif strfind(text, "%d") then -- do nothing if we don't find a number
  2721.                 -- Find and set color code (used to fix gem text color) pattern:|cxxxxxxxx
  2722.                 currentColorCode = select(3, strfind(text, "(|c%x%x%x%x%x%x%x%x)")) or "|r"
  2723.                 -- Initial pattern check, do nothing if not found
  2724.                 -- Check for separators and bulid separatorTable
  2725.                 local separatorTable = {}
  2726.                 for _, sep in ipairs(L["separators"]) do
  2727.                     if strfind(text, sep) then
  2728.                         tinsert(separatorTable, sep)
  2729.                     end
  2730.                 end
  2731.                 -- SplitDoJoin
  2732.                 text = RatingBuster:SplitDoJoin(text, separatorTable, tooltip)
  2733.                 cache[cacheID] = text
  2734.                 -- SetText
  2735.                 fontString:SetText(text)
  2736.             end
  2737.         end
  2738.     end
  2739.     ----------------------------
  2740.     -- Item Level and Item ID --
  2741.     ----------------------------
  2742.     -- Check for ItemLevel addon, do nothing if found
  2743.     if not ItemLevel_AddInfo and (profileDB.showItemLevel or profileDB.showItemID) and link then
  2744.         if cache[link] then
  2745.             tooltip:AddLine(cache[link])
  2746.         else
  2747.             -- Get the Item ID from the link string
  2748.             local _, link, _, level = GetItemInfo(link)
  2749.             if link then
  2750.                 local _, _, id = strfind(link, "item:(%d+)")
  2751.                 local newLine = ""
  2752.                 if level and profileDB.showItemLevel then
  2753.                     newLine = newLine..L["ItemLevel: "]..level
  2754.                 end
  2755.                 if id and profileDB.showItemID then
  2756.                     if newLine ~= "" then
  2757.                         newLine = newLine..", "
  2758.                     end
  2759.                     newLine = newLine..L["ItemID: "]..id
  2760.                 end
  2761.                 if newLine ~= "" then
  2762.                     cache[link] = newLine
  2763.                     tooltip:AddLine(newLine)
  2764.                 end
  2765.             end
  2766.         end
  2767.     end
  2768.     ------------------
  2769.     -- Stat Summary --
  2770.     ------------------
  2771.     --[[
  2772.     ----------------
  2773.     -- Base Stats --
  2774.     ----------------
  2775.     -- Health - HEALTH, STA
  2776.     -- Mana - MANA, INT
  2777.     -- Attack Power - AP, STR, AGI
  2778.     -- Ranged Attack Power - RANGED_AP, INT, AP, STR, AGI
  2779.     -- Feral Attack Power - FERAL_AP, AP, STR, AGI
  2780.     -- Spell Damage - SPELL_DMG, STA, INT, SPI
  2781.     -- Holy Damage - HOLY_SPELL_DMG, SPELL_DMG, INT, SPI
  2782.     -- Arcane Damage - ARCANE_SPELL_DMG, SPELL_DMG, INT
  2783.     -- Fire Damage - FIRE_SPELL_DMG, SPELL_DMG, STA, INT
  2784.     -- Nature Damage - NATURE_SPELL_DMG, SPELL_DMG, INT
  2785.     -- Frost Damage - FROST_SPELL_DMG, SPELL_DMG, INT
  2786.     -- Shadow Damage - SHADOW_SPELL_DMG, SPELL_DMG, STA, INT, SPI
  2787.     -- Healing - HEAL, STR, INT, SPI
  2788.     -- Hit Chance - MELEE_HIT_RATING, WEAPON_RATING
  2789.     -- Crit Chance - MELEE_CRIT_RATING, WEAPON_RATING, AGI
  2790.     -- Spell Hit Chance - SPELL_HIT_RATING
  2791.     -- Spell Crit Chance - SPELL_CRIT_RATING, INT
  2792.     -- Mana Regen - MANA_REG, SPI
  2793.     -- Health Regen - HEALTH_REG
  2794.     -- Mana Regen Not Casting - SPI
  2795.     -- Health Regen While Casting - SPI
  2796.     -- Armor - ARMOR, ARMOR_BONUS, AGI, INT
  2797.     -- Block Value - BLOCK_VALUE, STR
  2798.     -- Dodge Chance - DODGE_RATING, DEFENSE_RATING, AGI
  2799.     -- Parry Chance - PARRY_RATING, DEFENSE_RATING
  2800.     -- Block Chance - BLOCK_RATING, DEFENSE_RATING
  2801.     -- Hit Avoidance - DEFENSE_RATING, MELEE_HIT_AVOID_RATING
  2802.     -- Crit Avoidance - DEFENSE_RATING, RESILIENCE_RATING, MELEE_CRIT_AVOID_RATING
  2803.     -- Dodge Neglect - EXPERTISE_RATING, WEAPON_RATING
  2804.     -- Parry Neglect - EXPERTISE_RATING, WEAPON_RATING
  2805.     -- Block Neglect - WEAPON_RATING
  2806.     ---------------------
  2807.     -- Composite Stats --
  2808.     ---------------------
  2809.     -- Strength - STR
  2810.     -- Agility - AGI
  2811.     -- Stamina - STA
  2812.     -- Intellect - INT
  2813.     -- Spirit - SPI
  2814.     -- Defense - DEFENSE_RATING
  2815.     -- Weapon Skill - WEAPON_RATING
  2816.     -- Expertise - EXPERTISE_RATING
  2817.     --]]
  2818.     if isModifierKeyDown[profileDB.showSum] and isModifierKeyDown[profileDB.showSum]() then
  2819.         RatingBuster:StatSummary(tooltip, name, link, ...)
  2820.     end
  2821.     ---------------------
  2822.     -- Repaint tooltip --
  2823.     ---------------------
  2824.     tooltip:Show()
  2825. end
  2826.  
  2827. ---------------------------------------------------------------------------------
  2828. -- Recursive algorithm that divides a string into pieces using the separators in separatorTable,
  2829. -- processes them separately, then joins them back together
  2830. ---------------------------------------------------------------------------------
  2831. -- text = "+24 Agility/+4 Stamina and +4 Spell Crit/+5 Spirit"
  2832. -- separatorTable = {"/", " and ", ","}
  2833. -- RatingBuster:SplitDoJoin("+24 Agility/+4 Stamina, +4 Dodge and +4 Spell Crit/+5 Spirit", {"/", " and ", ",", "%. ", " for ", "&"})
  2834. -- RatingBuster:SplitDoJoin("+6法術傷害及5耐力", {"/", "和", ",", "。", " 持續 ", "&", "及",})
  2835. function RatingBuster:SplitDoJoin(text, separatorTable, tooltip)
  2836.     if type(separatorTable) == "table" and table.maxn(separatorTable) > 0 then
  2837.         local sep = tremove(separatorTable, 1)
  2838.         text =  gsub(text, sep, "@")
  2839.         text = {strsplit("@", text)}
  2840.         local processedText = {}
  2841.         local tempTable = {}
  2842.         for _, t in ipairs(text) do
  2843.             --self:Print(t[1])
  2844.             copyTable(tempTable, separatorTable)
  2845.             tinsert(processedText, self:SplitDoJoin(t, tempTable, tooltip))
  2846.         end
  2847.         -- Join text
  2848.         return (gsub(strjoin("@", unpack(processedText)), "@", sep))
  2849.     else
  2850.         --self:Print(cacheID)
  2851.         return self:ProcessText(text, tooltip)
  2852.     end
  2853. end
  2854.  
  2855.  
  2856. function RatingBuster:ProcessText(text, tooltip)
  2857.     --self:Print(text)
  2858.     -- Check if test has a matching pattern
  2859.     for _, num in ipairs(L["numberPatterns"]) do
  2860.         -- Convert text to lower so we don't have to worry about same ratings with different cases
  2861.         local lowerText = string.lower(text)
  2862.         -- Capture the stat value
  2863.         local s, e, value, partialtext = strfind(lowerText, num.pattern)
  2864.         if value then
  2865.             -- Check and switch captures if needed
  2866.             if partialtext and tonumber(partialtext) then
  2867.                 value, partialtext = partialtext, value
  2868.             end
  2869.             -- Capture the stat name
  2870.             for _, stat in ipairs(L["statList"]) do
  2871.                 if (not partialtext and strfind(lowerText, stat.pattern)) or (partialtext and strfind(partialtext, stat.pattern)) then
  2872.                     value = tonumber(value)
  2873.                     local infoString = ""
  2874.                     if type(stat.id) == "number" and stat.id >= 1 and stat.id <= 25 and isModifierKeyDown[profileDB.showRatings] and isModifierKeyDown[profileDB.showRatings]() then
  2875.                         --------------------
  2876.                         -- Combat Ratings --
  2877.                         --------------------
  2878.                         -- Calculate stat value
  2879.                         local effect, strID = StatLogic:GetEffectFromRating(value, stat.id, calcLevel)
  2880.                         --self:Print(reversedAmount..", "..amount..", "..v[2]..", "..RatingBuster.targetLevel)-- debug
  2881.                         -- If rating is resilience, add a minus sign
  2882.                         -- (d0.12%, p0.12%, b0.12%, m0.12%, c-0.12%)
  2883.                         if strID == "DEFENSE" and profileDB.defBreakDown then
  2884.                             effect = effect * 0.04
  2885.                             processedDodge = processedDodge + effect
  2886.                             processedMissed = processedMissed + effect
  2887.                             local numStats = 5
  2888.                             if GetParryChance() == 0 then
  2889.                                 numStats = numStats - 1
  2890.                             else
  2891.                                 processedParry = processedParry + effect
  2892.                             end
  2893.                             if GetBlockChance() == 0 then
  2894.                                 numStats = numStats - 1
  2895.                             end
  2896.                             infoString = format("%+.2f%% x"..numStats, effect)
  2897.                         elseif strID == "DODGE" and profileDB.enableAvoidanceDiminishingReturns then
  2898.                             infoString = format("%+.2f%%", StatLogic:GetAvoidanceGainAfterDR("DODGE", processedDodge + effect) - StatLogic:GetAvoidanceGainAfterDR("DODGE", processedDodge))
  2899.                             processedDodge = processedDodge + effect
  2900.                         elseif strID == "PARRY" and profileDB.enableAvoidanceDiminishingReturns then
  2901.                             infoString = format("%+.2f%%", StatLogic:GetAvoidanceGainAfterDR("PARRY", processedParry + effect) - StatLogic:GetAvoidanceGainAfterDR("PARRY", processedParry))
  2902.                             processedParry = processedParry + effect
  2903.                         elseif strID == "WEAPON_SKILL" and profileDB.wpnBreakDown then
  2904.                             effect = effect * 0.04
  2905.                             infoString = format("%+.2f%% x5", effect)
  2906.                         elseif strID == "EXPERTISE" and profileDB.expBreakDown then
  2907.                             effect = effect * -0.25
  2908.                             if profileDB.detailedConversionText then
  2909.                                 infoString = gsub(L["$value to be Dodged/Parried"], "$value", format("%+.2f%%%%", effect))
  2910.                             else
  2911.                                 infoString = format("%+.2f%%", effect)
  2912.                             end
  2913.                         elseif stat.id >= 15 and stat.id <= 17 then -- Resilience
  2914.                             effect = effect * -1
  2915.                             if profileDB.detailedConversionText then
  2916.                                 infoString = gsub(L["$value to be Crit"], "$value", format("%+.2f%%%%", effect))..", "..gsub(L["$value Crit Dmg Taken"], "$value", format("%+.2f%%%%", effect * 2))..", "..gsub(L["$value DOT Dmg Taken"], "$value", format("%+.2f%%%%", effect))
  2917.                             else
  2918.                                 infoString = format("%+.2f%%", effect)
  2919.                             end
  2920.                         -- CR_HIT_MELEE = 6
  2921.                         -- CR_CRIT_MELEE = 9
  2922.                         -- CR_HASTE_MELEE = 18
  2923.                         -- Crit and Haste conversions are the same for melee and haste, only hit is different
  2924.                         elseif stat.id == 6 then
  2925.                             if profileDB.ratingPhysical and profileDB.ratingSpell then
  2926.                                 -- stat.id + 2 = SpellID
  2927.                                 local effectSpell = StatLogic:GetEffectFromRating(value, stat.id + 2, calcLevel)
  2928.                                 infoString = format("%+.2f%%, ", effect)..gsub(L["$value Spell"], "$value", format("%+.2f%%%%", effectSpell))
  2929.                             elseif profileDB.ratingPhysical then
  2930.                                 infoString = format("%+.2f%%", effect)
  2931.                             elseif profileDB.ratingSpell then
  2932.                                 local effectSpell = StatLogic:GetEffectFromRating(value, stat.id + 2, calcLevel)
  2933.                                 infoString = format("%+.2f%%", effectSpell)
  2934.                             end
  2935.             -- CR_HASTE_MELEE = 18
  2936.             -- shamans7, paladins2, druids10, and death knights6 now receive 30% more melee haste from Haste Rating.
  2937.                         elseif stat.id == 18 then
  2938.                             if profileDB.ratingPhysical and profileDB.ratingSpell then
  2939.                                 -- stat.id + 2 = SpellID
  2940.                                 local effectSpell = StatLogic:GetEffectFromRating(value, stat.id + 2, calcLevel)
  2941.                 if effectSpell == effect then
  2942.                   infoString = format("%+.2f%%", effect)
  2943.                 else
  2944.                   infoString = format("%+.2f%%, ", effect)..gsub(L["$value Spell"], "$value", format("%+.2f%%%%", effectSpell))
  2945.                 end
  2946.                             elseif profileDB.ratingPhysical then
  2947.                                 infoString = format("%+.2f%%", effect)
  2948.                             elseif profileDB.ratingSpell then
  2949.                                 local effectSpell = StatLogic:GetEffectFromRating(value, stat.id + 2, calcLevel)
  2950.                                 infoString = format("%+.2f%%", effectSpell)
  2951.                             end
  2952.                         else
  2953.                             --self:Print(text..", "..tostring(effect)..", "..value..", "..stat.id..", "..calcLevel)
  2954.                             -- Build info string
  2955.                             infoString = format("%+.2f", effect)
  2956.                             if (stat.id > 2 and stat.id < 21) or stat.id == 25 then -- if rating is a percentage
  2957.                                 infoString = infoString.."%"
  2958.                             end
  2959.                         end
  2960.                     elseif stat.id == SPELL_STAT1_NAME and isModifierKeyDown[profileDB.showStats] and isModifierKeyDown[profileDB.showStats]() then
  2961.                         --------------
  2962.                         -- Strength --
  2963.                         --------------
  2964.                         local statmod = 1
  2965.                         if profileDB.enableStatMods then
  2966.                             statmod = RatingBuster:GetStatMod("MOD_STR")
  2967.                             value = value * statmod
  2968.                         end
  2969.                         local infoTable = {}
  2970.                         if profileDB.showAPFromStr then
  2971.                             local mod = RatingBuster:GetStatMod("MOD_AP")
  2972.                             local effect = value * StatLogic:GetAPPerStr(class) * mod
  2973.                             if (mod ~= 1 or statmod ~= 1) and floor(abs(effect) * 10 + 0.5) > 0 then
  2974.                                 tinsert(infoTable, (gsub(L["$value AP"], "$value", format("%+.1f", effect))))
  2975.                             elseif floor(abs(effect) + 0.5) > 0 then -- so we don't get +0 AP when effect < 0.5
  2976.                                 tinsert(infoTable, (gsub(L["$value AP"], "$value", format("%+.0f", effect))))
  2977.                             end
  2978.                         end
  2979.                         if profileDB.showBlockValueFromStr then
  2980.                             local effect = value * StatLogic:GetBlockValuePerStr(class) * RatingBuster:GetStatMod("MOD_BLOCK_VALUE")
  2981.                             if floor(abs(effect) * 10 + 0.5) > 0 then
  2982.                                 tinsert(infoTable, (gsub(L["$value Block"], "$value", format("%+.1f", effect))))
  2983.                             end
  2984.                         end
  2985.                         -- Shaman: Mental Quickness (Rank 3) - 2,15
  2986.                         -- Paladin: Sheath of Light
  2987.                         if profileDB.showSpellDmgFromStr then
  2988.                             local mod = RatingBuster:GetStatMod("MOD_AP") * RatingBuster:GetStatMod("MOD_SPELL_DMG")
  2989.                             local effect = (value * StatLogic:GetAPPerStr(class) * RatingBuster:GetStatMod("ADD_SPELL_DMG_MOD_AP")
  2990.                                 + value * RatingBuster:GetStatMod("ADD_SPELL_DMG_MOD_STR")) * mod
  2991.                             if (mod ~= 1 or statmod ~= 1) and floor(abs(effect) * 10 + 0.5) > 0 then
  2992.                                 tinsert(infoTable, (gsub(L["$value Dmg"], "$value", format("%+.1f", effect))))
  2993.                             elseif floor(abs(effect) + 0.5) > 0 then
  2994.                                 tinsert(infoTable, (gsub(L["$value Dmg"], "$value", format("%+.0f", effect))))
  2995.                             end
  2996.                         end
  2997.                         -- Shaman: Mental Quickness (Rank 3) - 2,15
  2998.                         -- Paladin: Sheath of Light
  2999.                         if profileDB.showHealingFromStr then
  3000.                             local mod = RatingBuster:GetStatMod("MOD_AP") * RatingBuster:GetStatMod("MOD_HEALING")
  3001.                             local effect = (value * StatLogic:GetAPPerStr(class) * RatingBuster:GetStatMod("ADD_HEALING_MOD_AP")
  3002.                                 + value * RatingBuster:GetStatMod("ADD_HEALING_MOD_STR")) * mod
  3003.                             if (mod ~= 1 or statmod ~= 1) and floor(abs(effect) * 10 + 0.5) > 0 then
  3004.                                 tinsert(infoTable, (gsub(L["$value Heal"], "$value", format("%+.1f", effect))))
  3005.                             elseif floor(abs(effect) + 0.5) > 0 then
  3006.                                 tinsert(infoTable, (gsub(L["$value Heal"], "$value", format("%+.0f", effect))))
  3007.                             end
  3008.                         end
  3009.                         if profileDB.showParryFromStr then -- Death Knight: Forceful Deflection - Passive
  3010.                             local rating = value * RatingBuster:GetStatMod("ADD_CR_PARRY_MOD_STR")
  3011.                             local effect = StatLogic:GetEffectFromRating(rating, 4, calcLevel)
  3012.                             if profileDB.enableAvoidanceDiminishingReturns then
  3013.                                 local effectNoDR = effect
  3014.                                 effect = StatLogic:GetAvoidanceGainAfterDR("PARRY", processedParry + effect) - StatLogic:GetAvoidanceGainAfterDR("PARRY", processedParry)
  3015.                                 processedParry = processedParry + effectNoDR
  3016.                             end
  3017.                             if effect > 0 then
  3018.                                 tinsert(infoTable, (gsub(L["$value% Parry"], "$value", format("%+.2f", effect))))
  3019.                             end
  3020.                         else
  3021.                             local rating = value * RatingBuster:GetStatMod("ADD_CR_PARRY_MOD_STR")
  3022.                             local effect = StatLogic:GetEffectFromRating(rating, 4, calcLevel)
  3023.                             processedParry = processedParry + effect
  3024.                         end
  3025.                         infoString = strjoin(", ", unpack(infoTable))
  3026.                     elseif stat.id == SPELL_STAT2_NAME and isModifierKeyDown[profileDB.showStats] and isModifierKeyDown[profileDB.showStats]() then
  3027.                         -------------
  3028.                         -- Agility --
  3029.                         -------------
  3030.                         local statmod = 1
  3031.                         if profileDB.enableStatMods then
  3032.                             statmod = RatingBuster:GetStatMod("MOD_AGI")
  3033.                             value = value * statmod
  3034.                         end
  3035.                         local infoTable = {}
  3036.                         if profileDB.showAPFromAgi then
  3037.                             local mod = RatingBuster:GetStatMod("MOD_AP")
  3038.                             local effect = value * StatLogic:GetAPPerAgi(class) * mod
  3039.                             if (mod ~= 1 or statmod ~= 1) and floor(abs(effect) * 10 + 0.5) > 0 then
  3040.                                 tinsert(infoTable, (gsub(L["$value AP"], "$value", format("%+.1f", effect))))
  3041.                             elseif floor(abs(effect) + 0.5) > 0 then
  3042.                                 tinsert(infoTable, (gsub(L["$value AP"], "$value", format("%+.0f", effect))))
  3043.                             end
  3044.                         end
  3045.                         if profileDB.showRAPFromAgi then
  3046.                             local mod = RatingBuster:GetStatMod("MOD_RANGED_AP")
  3047.                             local effect = value * StatLogic:GetRAPPerAgi(class) * mod
  3048.                             if (mod ~= 1 or statmod ~= 1) and floor(abs(effect) * 10 + 0.5) > 0 then
  3049.                                 tinsert(infoTable, (gsub(L["$value RAP"], "$value", format("%+.1f", effect))))
  3050.                             elseif floor(abs(effect) + 0.5) > 0 then
  3051.                                 tinsert(infoTable, (gsub(L["$value RAP"], "$value", format("%+.0f", effect))))
  3052.                             end
  3053.                         end
  3054.                         if profileDB.showCritFromAgi then
  3055.                             local effect = StatLogic:GetCritFromAgi(value, class, calcLevel)
  3056.                             if effect > 0 then
  3057.                                 tinsert(infoTable, (gsub(L["$value% Crit"], "$value", format("%+.2f", effect))))
  3058.                             end
  3059.                         end
  3060.                         if profileDB.showDodgeFromAgi and (calcLevel == playerLevel) then
  3061.                             local effect = StatLogic:GetDodgeFromAgi(value)
  3062.                             if profileDB.enableAvoidanceDiminishingReturns then
  3063.                                 local effectNoDR = effect
  3064.                                 effect = StatLogic:GetAvoidanceGainAfterDR("DODGE", processedDodge + effect) - StatLogic:GetAvoidanceGainAfterDR("DODGE", processedDodge)
  3065.                                 processedDodge = processedDodge + effectNoDR
  3066.                             end
  3067.                             if effect > 0 then
  3068.                                 tinsert(infoTable, (gsub(L["$value% Dodge"], "$value", format("%+.2f", effect))))
  3069.                             end
  3070.                         else
  3071.                             local effect = StatLogic:GetDodgeFromAgi(value)
  3072.                             processedDodge = processedDodge + effect
  3073.                         end
  3074.                         if profileDB.showArmorFromAgi then
  3075.                             local effect = value * 2
  3076.                             if effect > 0 then
  3077.                                 tinsert(infoTable, (gsub(L["$value Armor"], "$value", format("%+.0f", effect))))
  3078.                             end
  3079.                         end
  3080.                         if profileDB.showHealingFromAgi then
  3081.                             local mod = RatingBuster:GetStatMod("MOD_HEALING")
  3082.                             local effect = value * RatingBuster:GetStatMod("ADD_HEALING_MOD_AGI") * mod
  3083.                             if floor(abs(effect) * 10 + 0.5) > 0 then
  3084.                                 tinsert(infoTable, (gsub(L["$value Heal"], "$value", format("%+.1f", effect))))
  3085.                             end
  3086.                         end
  3087.                         infoString = strjoin(", ", unpack(infoTable))
  3088.                     elseif stat.id == SPELL_STAT3_NAME and isModifierKeyDown[profileDB.showStats] and isModifierKeyDown[profileDB.showStats]() then
  3089.                         -------------
  3090.                         -- Stamina --
  3091.                         -------------
  3092.                         local statmod = 1
  3093.                         if profileDB.enableStatMods then
  3094.                             statmod = RatingBuster:GetStatMod("MOD_STA")
  3095.                             value = value * statmod
  3096.                         end
  3097.                         local infoTable = {}
  3098.                         if profileDB.showHealthFromSta then
  3099.                             local mod = RatingBuster:GetStatMod("MOD_HEALTH")
  3100.                             local effect = value * 10 * mod -- 10 Health per Sta
  3101.                             if (mod ~= 1 or statmod ~= 1) and floor(abs(effect) * 10 + 0.5) > 0 then
  3102.                                 tinsert(infoTable, (gsub(L["$value HP"], "$value", format("%+.1f", effect))))
  3103.                             elseif floor(abs(effect) + 0.5) > 0 then
  3104.                                 tinsert(infoTable, (gsub(L["$value HP"], "$value", format("%+.0f", effect))))
  3105.                             end
  3106.                         end
  3107.                         -- "ADD_SPELL_DMG_MOD_AP" -- Warlock: Demonic Knowledge
  3108.                         if profileDB.showSpellDmgFromSta then
  3109.                             local mod = RatingBuster:GetStatMod("MOD_SPELL_DMG")
  3110.                             local effect = value * mod * (RatingBuster:GetStatMod("ADD_SPELL_DMG_MOD_STA")
  3111.                                 + RatingBuster:GetStatMod("ADD_SPELL_DMG_MOD_PET_STA") * RatingBuster:GetStatMod("ADD_PET_STA_MOD_STA"))
  3112.                             if floor(abs(effect) * 10 + 0.5) > 0 then
  3113.                                 tinsert(infoTable, (gsub(L["$value Dmg"], "$value", format("%+.1f", effect))))
  3114.                             end
  3115.                         end
  3116.                         -- "ADD_HEALING_MOD_STA" -- Warlock: Demonic Knowledge
  3117.                         if profileDB.showHealingFromSta then
  3118.                             local mod = RatingBuster:GetStatMod("MOD_HEALING")
  3119.                             local effect = value * RatingBuster:GetStatMod("ADD_HEALING_MOD_STA") * mod
  3120.                             if floor(abs(effect) * 10 + 0.5) > 0 then
  3121.                                 tinsert(infoTable, (gsub(L["$value Heal"], "$value", format("%+.1f", effect))))
  3122.                             end
  3123.                         end
  3124.                         -- "ADD_AP_MOD_STA" -- Hunter: Hunter vs. Wild
  3125.                         if profileDB.showAPFromSta then
  3126.                             local mod = RatingBuster:GetStatMod("MOD_AP")
  3127.                             local effect = value * RatingBuster:GetStatMod("ADD_AP_MOD_STA") * mod
  3128.                             if (mod ~= 1 or statmod ~= 1) and floor(abs(effect) * 10 + 0.5) > 0 then
  3129.                                 tinsert(infoTable, (gsub(L["$value AP"], "$value", format("%+.1f", effect))))
  3130.                             elseif floor(abs(effect) + 0.5) > 0 then
  3131.                                 tinsert(infoTable, (gsub(L["$value AP"], "$value", format("%+.0f", effect))))
  3132.                             end
  3133.                         end
  3134.                         infoString = strjoin(", ", unpack(infoTable))
  3135.                     elseif stat.id == SPELL_STAT4_NAME and isModifierKeyDown[profileDB.showStats] and isModifierKeyDown[profileDB.showStats]() then
  3136.                         ---------------
  3137.                         -- Intellect --
  3138.                         ---------------
  3139.                         local statmod = 1
  3140.                         if profileDB.enableStatMods then
  3141.                             statmod = RatingBuster:GetStatMod("MOD_INT")
  3142.                             value = value * statmod
  3143.                         end
  3144.                         local infoTable = {}
  3145.                         if profileDB.showManaFromInt then
  3146.                             local mod = RatingBuster:GetStatMod("MOD_MANA")
  3147.                             local effect = value * 15 * mod -- 15 Mana per Int
  3148.                             if (mod ~= 1 or statmod ~= 1) and floor(abs(effect) * 10 + 0.5) > 0 then
  3149.                                 tinsert(infoTable, (gsub(L["$value MP"], "$value", format("%+.1f", effect))))
  3150.                             elseif floor(abs(effect) + 0.5) > 0 then
  3151.                                 tinsert(infoTable, (gsub(L["$value MP"], "$value", format("%+.0f", effect))))
  3152.                             end
  3153.                         end
  3154.                         if profileDB.showSpellCritFromInt then
  3155.                             local effect = StatLogic:GetSpellCritFromInt(value, class, calcLevel)
  3156.                             if effect > 0 then
  3157.                                 tinsert(infoTable, (gsub(L["$value% Spell Crit"], "$value", format("%+.2f", effect))))
  3158.                             end
  3159.                         end
  3160.                         if profileDB.showSpellDmgFromInt then
  3161.                             local mod = RatingBuster:GetStatMod("MOD_SPELL_DMG")
  3162.                             local effect = value * mod * (RatingBuster:GetStatMod("ADD_SPELL_DMG_MOD_INT")
  3163.                                 + RatingBuster:GetStatMod("ADD_SPELL_DMG_MOD_PET_INT") * RatingBuster:GetStatMod("ADD_PET_INT_MOD_INT"))
  3164.                             if floor(abs(effect) * 10 + 0.5) > 0 then
  3165.                                 tinsert(infoTable, (gsub(L["$value Dmg"], "$value", format("%+.1f", effect))))
  3166.                             end
  3167.                         end
  3168.                         if profileDB.showHealingFromInt then
  3169.                             local mod = RatingBuster:GetStatMod("MOD_HEALING")
  3170.                             local effect = value * RatingBuster:GetStatMod("ADD_HEALING_MOD_INT") * mod
  3171.                             if floor(abs(effect) * 10 + 0.5) > 0 then
  3172.                                 tinsert(infoTable, (gsub(L["$value Heal"], "$value", format("%+.1f", effect))))
  3173.                             end
  3174.                         end
  3175.                         if profileDB.showMP5FromInt then
  3176.                             local _, int = UnitStat("player", 4)
  3177.                             local _, spi = UnitStat("player", 5)
  3178.                             local effect = value * RatingBuster:GetStatMod("ADD_MANA_REG_MOD_INT")
  3179.                + (StatLogic:GetNormalManaRegenFromSpi(spi, int + value, calcLevel)
  3180.                - StatLogic:GetNormalManaRegenFromSpi(spi, int, calcLevel)) * RatingBuster:GetStatMod("ADD_MANA_REG_MOD_NORMAL_MANA_REG")
  3181.                + value * 15 * RatingBuster:GetStatMod("MOD_MANA") * RatingBuster:GetStatMod("ADD_MANA_REG_MOD_MANA") -- Replenishment
  3182.                             if floor(abs(effect) * 10 + 0.5) > 0 then
  3183.                                 tinsert(infoTable, (gsub(L["$value MP5"], "$value", format("%+.1f", effect))))
  3184.                             end
  3185.                         end
  3186.                         if profileDB.showMP5NCFromInt then
  3187.                             local _, int = UnitStat("player", 4)
  3188.                             local _, spi = UnitStat("player", 5)
  3189.                             local effect = value * RatingBuster:GetStatMod("ADD_MANA_REG_MOD_INT")
  3190.                + StatLogic:GetNormalManaRegenFromSpi(spi, int + value, calcLevel)
  3191.                - StatLogic:GetNormalManaRegenFromSpi(spi, int, calcLevel)
  3192.                + value * 15 * RatingBuster:GetStatMod("MOD_MANA") * RatingBuster:GetStatMod("ADD_MANA_REG_MOD_MANA")
  3193.                             if floor(abs(effect) * 10 + 0.5) > 0 then
  3194.                                 tinsert(infoTable, (gsub(L["$value MP5(NC)"], "$value", format("%+.1f", effect))))
  3195.                             end
  3196.                         end
  3197.                         if profileDB.showRAPFromInt then
  3198.                             local mod = RatingBuster:GetStatMod("MOD_RANGED_AP")
  3199.                             local effect = value * RatingBuster:GetStatMod("ADD_RANGED_AP_MOD_INT") * mod
  3200.                             if floor(abs(effect) * 10 + 0.5) > 0 then
  3201.                                 tinsert(infoTable, (gsub(L["$value RAP"], "$value", format("%+.1f", effect))))
  3202.                             end
  3203.                         end
  3204.                         if profileDB.showArmorFromInt then
  3205.                             local effect = value * RatingBuster:GetStatMod("ADD_ARMOR_MOD_INT")
  3206.                             if floor(abs(effect) + 0.5) > 0 then
  3207.                                 tinsert(infoTable, (gsub(L["$value Armor"], "$value", format("%+.0f", effect))))
  3208.                             end
  3209.                         end
  3210.                         -- "ADD_AP_MOD_INT" -- Shaman: Mental Dexterity
  3211.                         if profileDB.showAPFromInt then
  3212.                             local mod = RatingBuster:GetStatMod("MOD_AP")
  3213.                             local effect = value * RatingBuster:GetStatMod("ADD_AP_MOD_INT") * mod
  3214.                             if (mod ~= 1 or statmod ~= 1) and floor(abs(effect) * 10 + 0.5) > 0 then
  3215.                                 tinsert(infoTable, (gsub(L["$value AP"], "$value", format("%+.1f", effect))))
  3216.                             elseif floor(abs(effect) + 0.5) > 0 then
  3217.                                 tinsert(infoTable, (gsub(L["$value AP"], "$value", format("%+.0f", effect))))
  3218.                             end
  3219.                         end
  3220.                         infoString = strjoin(", ", unpack(infoTable))
  3221.                     elseif stat.id == SPELL_STAT5_NAME and isModifierKeyDown[profileDB.showStats] and isModifierKeyDown[profileDB.showStats]() then
  3222.                         ------------
  3223.                         -- Spirit --
  3224.                         ------------
  3225.                         local statmod = 1
  3226.                         if profileDB.enableStatMods then
  3227.                             statmod = RatingBuster:GetStatMod("MOD_SPI")
  3228.                             value = value * statmod
  3229.                         end
  3230.                         local infoTable = {}
  3231.                         if profileDB.showMP5FromSpi then
  3232.                             local mod = RatingBuster:GetStatMod("ADD_MANA_REG_MOD_NORMAL_MANA_REG")
  3233.                             local effect = StatLogic:GetNormalManaRegenFromSpi(value, nil, calcLevel) * mod
  3234.                             if floor(abs(effect) * 10 + 0.5) > 0 then
  3235.                                 tinsert(infoTable, (gsub(L["$value MP5"], "$value", format("%+.1f", effect))))
  3236.                             end
  3237.                         end
  3238.                         if profileDB.showMP5NCFromSpi then
  3239.                             local effect = StatLogic:GetNormalManaRegenFromSpi(value, nil, calcLevel)
  3240.                             if floor(abs(effect) * 10 + 0.5) > 0 then
  3241.                                 tinsert(infoTable, (gsub(L["$value MP5(NC)"], "$value", format("%+.1f", effect))))
  3242.                             end
  3243.                         end
  3244.                         if profileDB.showHP5FromSpi then
  3245.                             local effect = StatLogic:GetHealthRegenFromSpi(value, class)
  3246.                             if floor(abs(effect) * 10 + 0.5) > 0 then
  3247.                                 tinsert(infoTable, (gsub(L["$value HP5"], "$value", format("%+.1f", effect))))
  3248.                             end
  3249.                         end
  3250.                         -- "ADD_SCHOOL_SP_MOD_SPI" -- Priest: Twisted Faith,  Warlock: Fel Armor
  3251.                         if profileDB.showSpellDmgFromSpi then
  3252.                             local mod = RatingBuster:GetStatMod("MOD_SPELL_DMG")
  3253.                             local effect = value * (RatingBuster:GetStatMod("ADD_SPELL_DMG_MOD_SPI") + RatingBuster:GetStatMod("ADD_SCHOOL_SP_MOD_SPI", "SHADOW")) * mod
  3254.                             if floor(abs(effect) * 10 + 0.5) > 0 then
  3255.                                 tinsert(infoTable, (gsub(L["$value Dmg"], "$value", format("%+.1f", effect))))
  3256.                             end
  3257.                         end
  3258.                         if profileDB.showHealingFromSpi then
  3259.                             local mod = RatingBuster:GetStatMod("MOD_HEALING")
  3260.                             local effect = value * RatingBuster:GetStatMod("ADD_HEALING_MOD_SPI") * mod
  3261.                             if floor(abs(effect) * 10 + 0.5) > 0 then
  3262.                                 tinsert(infoTable, (gsub(L["$value Heal"], "$value", format("%+.1f", effect))))
  3263.                             end
  3264.                         end
  3265.                         if profileDB.showSpellCritFromSpi then
  3266.                             local mod = RatingBuster:GetStatMod("ADD_SPELL_CRIT_RATING_MOD_SPI")
  3267.                             local effect = StatLogic:GetEffectFromRating(value * mod, CR_CRIT_SPELL, calcLevel)
  3268.                             if effect > 0 then
  3269.                                 tinsert(infoTable, (gsub(L["$value% Spell Crit"], "$value", format("%+.2f", effect))))
  3270.                             end
  3271.                         end
  3272.                         infoString = strjoin(", ", unpack(infoTable))
  3273.                     elseif profileDB.showAPFromArmor and stat.id == ARMOR and isModifierKeyDown[profileDB.showStats] and isModifierKeyDown[profileDB.showStats]() then
  3274.                         -----------
  3275.                         -- Armor --
  3276.                         -----------
  3277.                         local statmod = 1
  3278.                         if profileDB.enableStatMods then
  3279.                             local finalArmor = StatLogic:GetFinalArmor(tooltip, lowerText)
  3280.                             if finalArmor then
  3281.                                 value = finalArmor
  3282.                             end
  3283.                         end
  3284.                         local infoTable = {}
  3285.                         --if profileDB.showAPFromArmor then
  3286.                             local effect = value * RatingBuster:GetStatMod("ADD_AP_MOD_ARMOR") * RatingBuster:GetStatMod("MOD_AP")
  3287.                             if floor(abs(effect) * 10 + 0.5) > 0 then
  3288.                                 tinsert(infoTable, (gsub(L["$value AP"], "$value", format("%+.1f", effect))))
  3289.                             end
  3290.                         --end
  3291.                         infoString = strjoin(", ", unpack(infoTable))
  3292.                     end
  3293.                     if infoString ~= "" then
  3294.                         -- Add parenthesis
  3295.                         infoString = "("..infoString..")"
  3296.                         -- Add Color
  3297.                         if profileDB.enableTextColor then
  3298.                             infoString = profileDB.textColor.hex..infoString..currentColorCode
  3299.                         end
  3300.                         -- Build replacement string
  3301.                         if num.addInfo == "AfterNumber" then -- Add after number
  3302.                             infoString = gsub(infoString, "%%", "%%%%%%%%") -- sub "%" with "%%%%"
  3303.                             infoString = gsub(strsub(text, s, e), "%d+", "%0 "..infoString, 1) -- sub "33" with "33 (3.33%)"
  3304.                         else -- Add after stat
  3305.                             infoString = gsub(infoString, "%%", "%%%%")
  3306.                             s, e = strfind(lowerText, stat.pattern)
  3307.                             infoString = "%0 "..infoString
  3308.                         end
  3309.                         -- Insert info into text
  3310.                         RusLocalstr = gsub(strsub(text, s, e),"%(","%%(")
  3311.                         RusLocalstr = gsub(RusLocalstr,"%)","%%)")
  3312.                         --RatingBuster:Print("Итоговая строка состоит из " .. text .. " в котором " .. strsub(text, s, e) .. " меняется на " .. infoString ..", в итоге " .. gsub(text, RusLocalstr, infoString, 1))
  3313.                         --RatingBuster:Print(RusLocalstr)
  3314.                         --RatingBuster:Print("-----------------------")
  3315.                         return (gsub(text, RusLocalstr, infoString, 1)) -- because gsub has 2 return values, but we only want 1
  3316.                     end
  3317.                     return text
  3318.                 end
  3319.             end
  3320.         end
  3321.     end
  3322.     return text
  3323. end
  3324.  
  3325.  
  3326. -- Color Numbers
  3327. local GREEN_FONT_COLOR_CODE = GREEN_FONT_COLOR_CODE -- "|cff20ff20" Green
  3328. local HIGHLIGHT_FONT_COLOR_CODE = HIGHLIGHT_FONT_COLOR_CODE -- "|cffffffff" White
  3329. local RED_FONT_COLOR_CODE = RED_FONT_COLOR_CODE -- "|cffffffff" White
  3330. local FONT_COLOR_CODE_CLOSE = FONT_COLOR_CODE_CLOSE -- "|r"
  3331. local function colorNum(text, num)
  3332.     if num > 0 then
  3333.         return GREEN_FONT_COLOR_CODE..text..FONT_COLOR_CODE_CLOSE
  3334.     elseif num < 0 then
  3335.         return RED_FONT_COLOR_CODE..text..FONT_COLOR_CODE_CLOSE
  3336.     else
  3337.         return HIGHLIGHT_FONT_COLOR_CODE..text..FONT_COLOR_CODE_CLOSE
  3338.     end
  3339. end
  3340.  
  3341. local armorTypes = {
  3342.     [BI["Plate"]] = "sumIgnorePlate",
  3343.     [BI["Mail"]] = "sumIgnoreMail",
  3344.     [BI["Leather"]] = "sumIgnoreLeather",
  3345.     [BI["Cloth"]] = "sumIgnoreCloth",
  3346. }
  3347.  
  3348. -- Acts as a cache so we only need to check text color once
  3349. local canUseItemType = {
  3350. }
  3351.  
  3352. -- Druid: Predatory Strikes 2,10: Increases 7%/14%/20% of any attack power on your equipped weapon.
  3353. local weaponItemEquipLoc = {
  3354.     ["INVTYPE_WEAPON"] = true,
  3355.     ["INVTYPE_2HWEAPON"] = true,
  3356.     ["INVTYPE_WEAPONMAINHAND"] = true,
  3357.     ["INVTYPE_WEAPONOFFHAND"] = true,
  3358. }
  3359.  
  3360. local summaryCalcData = {
  3361.     -----------
  3362.     -- Basic --
  3363.     -----------
  3364.     -- Strength - STR
  3365.     {
  3366.         option = "sumStr",
  3367.         name = "STR",
  3368.         func = function(sum, sumType, link) return sum["STR"] end,
  3369.     },
  3370.     -- Agility - AGI
  3371.     {
  3372.         option = "sumAgi",
  3373.         name = "AGI",
  3374.         func = function(sum, sumType, link) return sum["AGI"] end,
  3375.     },
  3376.     -- Stamina - STA
  3377.     {
  3378.         option = "sumSta",
  3379.         name = "STA",
  3380.         func = function(sum, sumType, link) return sum["STA"] end,
  3381.     },
  3382.     -- Health - HEALTH, STA
  3383.     {
  3384.         option = "sumHP",
  3385.         name = "HEALTH",
  3386.         func = function(sum, sumType, link) return ((sum["HEALTH"] or 0) + (sum["STA"] * 10)) * RatingBuster:GetStatMod("MOD_HEALTH") end,
  3387.     },
  3388.     -- Intellect - INT
  3389.     {
  3390.         option = "sumInt",
  3391.         name = "INT",
  3392.         func = function(sum, sumType, link) return sum["INT"] end,
  3393.     },
  3394.     -- Mana - MANA, INT
  3395.     {
  3396.         option = "sumMP",
  3397.         name = "MANA",
  3398.         func = function(sum, sumType, link) return ((sum["MANA"] or 0) + (sum["INT"] * 15)) * RatingBuster:GetStatMod("MOD_MANA") end,
  3399.     },
  3400.     -- Spirit - SPI
  3401.     {
  3402.         option = "sumSpi",
  3403.         name = "SPI",
  3404.         func = function(sum, sumType, link) return sum["SPI"] end,
  3405.     },
  3406.     -- Health Regen - HEALTH_REG
  3407.     {
  3408.         option = "sumHP5",
  3409.         name = "HEALTH_REG",
  3410.         func = function(sum, sumType, link) return (sum["HEALTH_REG"] or 0) end,
  3411.     },
  3412.     -- Health Regen while Out of Combat - HEALTH_REG, SPI
  3413.     {
  3414.         option = "sumHP5OC",
  3415.         name = "HEALTH_REG_OUT_OF_COMBAT",
  3416.         func = function(sum, sumType, link) return (sum["HEALTH_REG"] or 0) + StatLogic:GetHealthRegenFromSpi(sum["SPI"], class) end,
  3417.     },
  3418.     -- Mana Regen - MANA_REG, SPI, INT
  3419.     {
  3420.         option = "sumMP5",
  3421.         name = "MANA_REG",
  3422.         func = function(sum, sumType, link)
  3423.             local _, int = UnitStat("player", 4)
  3424.             local _, spi = UnitStat("player", 5)
  3425.             return (sum["MANA_REG"] or 0)
  3426.              + (sum["INT"] * RatingBuster:GetStatMod("ADD_MANA_REG_MOD_INT"))
  3427.              + (StatLogic:GetNormalManaRegenFromSpi(spi + sum["SPI"], int + sum["INT"], calcLevel)
  3428.              - StatLogic:GetNormalManaRegenFromSpi(spi, int, calcLevel)) * RatingBuster:GetStatMod("ADD_MANA_REG_MOD_NORMAL_MANA_REG")
  3429.              + summaryFunc["MANA"](sum, sumType, link) * RatingBuster:GetStatMod("ADD_MANA_REG_MOD_MANA")
  3430.         end,
  3431.     },
  3432.     -- Mana Regen while Not casting - MANA_REG, SPI, INT
  3433.     {
  3434.         option = "sumMP5NC",
  3435.         name = "MANA_REG_NOT_CASTING",
  3436.         func = function(sum, sumType, link)
  3437.             local _, int = UnitStat("player", 4)
  3438.             local _, spi = UnitStat("player", 5)
  3439.             return (sum["MANA_REG"] or 0)
  3440.              + (sum["INT"] * RatingBuster:GetStatMod("ADD_MANA_REG_MOD_INT"))
  3441.              + StatLogic:GetNormalManaRegenFromSpi(spi + sum["SPI"], int + sum["INT"], calcLevel)
  3442.              - StatLogic:GetNormalManaRegenFromSpi(spi, int, calcLevel)
  3443.              + summaryFunc["MANA"](sum, sumType, link) * RatingBuster:GetStatMod("ADD_MANA_REG_MOD_MANA")
  3444.         end,
  3445.     },
  3446.     ---------------------
  3447.     -- Physical Damage --
  3448.     ---------------------
  3449.     -- Attack Power - AP, STR, AGI.
  3450.     -- "ADD_AP_MOD_STA" -- Hunter: Hunter vs. Wild
  3451.     -- "ADD_AP_MOD_ARMOR" -- Death Knight: Bladed Armor
  3452.     -- "ADD_AP_MOD_INT" -- Shaman: Mental Dexterity
  3453.     -- "ADD_AP_MOD_SPELL_DMG" -- Warlock: Metamorphosis
  3454.     {
  3455.         option = "sumAP",
  3456.         name = "AP",
  3457.         func = function(sum, sumType, link)
  3458.             local ap = (sum["AP"] or 0)
  3459.              + (sum["STR"] * StatLogic:GetAPPerStr(class))
  3460.              + (sum["AGI"] * StatLogic:GetAPPerAgi(class))
  3461.             if RatingBuster:GetStatMod("ADD_AP_MOD_STA") ~= 0 then
  3462.                 ap = ap + (sum["STA"] * RatingBuster:GetStatMod("ADD_AP_MOD_STA"))
  3463.             end
  3464.             if RatingBuster:GetStatMod("ADD_AP_MOD_ARMOR") ~= 0 then
  3465.                 ap = ap + (summaryFunc["ARMOR"](sum, sumType, link) * RatingBuster:GetStatMod("ADD_AP_MOD_ARMOR"))
  3466.             end
  3467.             if RatingBuster:GetStatMod("ADD_AP_MOD_INT") ~= 0 then
  3468.                 ap = ap + (sum["INT"] * RatingBuster:GetStatMod("ADD_AP_MOD_INT"))
  3469.             end
  3470.             if RatingBuster:GetStatMod("ADD_AP_MOD_SPELL_DMG") ~= 0 then
  3471.                 local spellDmg = ((sum["SPELL_DMG"] or 0)
  3472.                  + (sum["STA"] * RatingBuster:GetStatMod("ADD_SPELL_DMG_MOD_STA"))
  3473.                  + (sum["INT"] * RatingBuster:GetStatMod("ADD_SPELL_DMG_MOD_INT"))
  3474.                  + (sum["SPI"] * RatingBuster:GetStatMod("ADD_SPELL_DMG_MOD_SPI"))
  3475.                  ) * RatingBuster:GetStatMod("MOD_SPELL_DMG")
  3476.                 ap = ap + (spellDmg * RatingBuster:GetStatMod("ADD_AP_MOD_SPELL_DMG"))
  3477.             end
  3478.             -- Druid: Predatory Strikes 2,10: Increases 7%/14%/20% of any attack power on your equipped weapon.
  3479.             local p = 0
  3480.             if class == "DRUID" and select(5, GetTalentInfo(2, 10)) > 0 and weaponItemEquipLoc[select(9, GetItemInfo(link))] then
  3481.                 local r = select(5, GetTalentInfo(2, 10))
  3482.                 if r == 1 then
  3483.                     p = 0.07
  3484.                 elseif r == 2 then
  3485.                     p = 0.14
  3486.                 elseif r == 3 then
  3487.                     p = 0.2
  3488.                 end
  3489.             end
  3490.             local mod = RatingBuster:GetStatMod("MOD_AP") + p
  3491.             return ap * mod
  3492.         end,
  3493.     },
  3494.     -- Ranged Attack Power - RANGED_AP, AP, AGI, INT
  3495.     {
  3496.         option = "sumRAP",
  3497.         name = "RANGED_AP",
  3498.         func = function(sum, sumType, link)
  3499.             local rap = (sum["RANGED_AP"] or 0)
  3500.              + (sum["AP"] or 0)
  3501.              + (sum["AGI"] * StatLogic:GetRAPPerAgi(class))
  3502.             if RatingBuster:GetStatMod("ADD_RANGED_AP_MOD_INT") ~= 0 then
  3503.                 rap = rap + (sum["INT"] * RatingBuster:GetStatMod("ADD_RANGED_AP_MOD_INT"))
  3504.             end
  3505.             if RatingBuster:GetStatMod("ADD_AP_MOD_STA") ~= 0 then
  3506.                 rap = rap + (sum["STA"] * RatingBuster:GetStatMod("ADD_AP_MOD_STA"))
  3507.             end
  3508.             if RatingBuster:GetStatMod("ADD_AP_MOD_ARMOR") ~= 0 then
  3509.                 rap = rap + (summaryFunc["ARMOR"](sum, sumType, link) * RatingBuster:GetStatMod("ADD_AP_MOD_ARMOR"))
  3510.             end
  3511.             if RatingBuster:GetStatMod("ADD_AP_MOD_INT") ~= 0 then
  3512.                 rap = rap + (sum["INT"] * RatingBuster:GetStatMod("ADD_AP_MOD_INT"))
  3513.             end
  3514.             if RatingBuster:GetStatMod("ADD_AP_MOD_SPELL_DMG") ~= 0 then
  3515.                 local spellDmg = ((sum["SPELL_DMG"] or 0)
  3516.                  + (sum["STA"] * RatingBuster:GetStatMod("ADD_SPELL_DMG_MOD_STA"))
  3517.                  + (sum["INT"] * RatingBuster:GetStatMod("ADD_SPELL_DMG_MOD_INT"))
  3518.                  + (sum["SPI"] * RatingBuster:GetStatMod("ADD_SPELL_DMG_MOD_SPI"))
  3519.                  ) * RatingBuster:GetStatMod("MOD_SPELL_DMG")
  3520.                 rap = rap + (spellDmg * RatingBuster:GetStatMod("ADD_AP_MOD_SPELL_DMG"))
  3521.             end
  3522.             return rap * (RatingBuster:GetStatMod("MOD_RANGED_AP") + RatingBuster:GetStatMod("MOD_AP") - 1)
  3523.         end,
  3524.     },
  3525.     -- Feral Attack Power - FERAL_AP, AP, STR, AGI
  3526.     {
  3527.         option = "sumFAP",
  3528.         name = "FERAL_AP",
  3529.         func = function(sum, sumType, link)
  3530.             -- Druid: Predatory Strikes 2,10: Increases 7%/14%/20% of any attack power on your equipped weapon.
  3531.             local p = 0
  3532.             if class == "DRUID" and select(5, GetTalentInfo(2, 10)) > 0 and weaponItemEquipLoc[select(9, GetItemInfo(link))] then
  3533.                 local r = select(5, GetTalentInfo(2, 10))
  3534.                 if r == 1 then
  3535.                     p = 0.07
  3536.                 elseif r == 2 then
  3537.                     p = 0.14
  3538.                 elseif r == 3 then
  3539.                     p = 0.2
  3540.                 end
  3541.             end
  3542.             local mod = RatingBuster:GetStatMod("MOD_AP") + p
  3543.             local fap = summaryFunc["AP"](sum, sumType, link) + (sum["FERAL_AP"] or 0) * mod
  3544.             return fap
  3545.         end,
  3546.     },
  3547.     -- Hit Chance - MELEE_HIT_RATING, WEAPON_RATING
  3548.     {
  3549.         option = "sumHit",
  3550.         name = "MELEE_HIT",
  3551.         func = function(sum, sumType, link)
  3552.             local s = 0
  3553.             for id, v in pairs(sum) do
  3554.                 if strsub(id, -13) == "WEAPON_RATING" then
  3555.                     s = s + StatLogic:GetEffectFromRating(v, CR_WEAPON_SKILL, calcLevel) * 0.04
  3556.                     break
  3557.                 end
  3558.             end
  3559.             return s + StatLogic:GetEffectFromRating((sum["MELEE_HIT_RATING"] or 0), "MELEE_HIT_RATING", calcLevel)
  3560.         end,
  3561.         ispercent = true,
  3562.     },
  3563.     -- Hit Rating - MELEE_HIT_RATING
  3564.     {
  3565.         option = "sumHitRating",
  3566.         name = "MELEE_HIT_RATING",
  3567.         func = function(sum, sumType, link) return (sum["MELEE_HIT_RATING"] or 0) end,
  3568.     },
  3569.     -- Ranged Hit Chance - MELEE_HIT_RATING, WEAPON_RATING, RANGED_HIT_RATING
  3570.     {
  3571.         option = "sumRangedHit",
  3572.         name = "RANGED_HIT",
  3573.         func = function(sum, sumType, link)
  3574.             local s = 0
  3575.             for id, v in pairs(sum) do
  3576.                 if strsub(id, -13) == "WEAPON_RATING" then
  3577.                     s = s + StatLogic:GetEffectFromRating(v, CR_WEAPON_SKILL, calcLevel) * 0.04
  3578.                     break
  3579.                 end
  3580.             end
  3581.             return s + StatLogic:GetEffectFromRating((sum["MELEE_HIT_RATING"] or 0), "MELEE_HIT_RATING", calcLevel)
  3582.                      + StatLogic:GetEffectFromRating((sum["RANGED_HIT_RATING"] or 0), "RANGED_HIT_RATING", calcLevel)
  3583.         end,
  3584.         ispercent = true,
  3585.     },
  3586.     -- Ranged Hit Rating - MELEE_HIT_RATING, RANGED_HIT_RATING
  3587.     {
  3588.         option = "sumRangedHitRating",
  3589.         name = "RANGED_HIT_RATING",
  3590.         func = function(sum, sumType, link) return (sum["MELEE_HIT_RATING"] or 0) + (sum["RANGED_HIT_RATING"] or 0) end,
  3591.     },
  3592.     -- Crit Chance - MELEE_CRIT_RATING, WEAPON_RATING, AGI
  3593.     {
  3594.         option = "sumCrit",
  3595.         name = "MELEE_CRIT",
  3596.         func = function(sum, sumType, link)
  3597.             local s = 0
  3598.             for id, v in pairs(sum) do
  3599.                 if strsub(id, -13) == "WEAPON_RATING" then
  3600.                     s = s + StatLogic:GetEffectFromRating(v, CR_WEAPON_SKILL, calcLevel) * 0.04
  3601.                     break
  3602.                 end
  3603.             end
  3604.             return s + StatLogic:GetEffectFromRating((sum["MELEE_CRIT_RATING"] or 0), "MELEE_CRIT_RATING", calcLevel)
  3605.                      + StatLogic:GetCritFromAgi(sum["AGI"], class, calcLevel)
  3606.         end,
  3607.         ispercent = true,
  3608.     },
  3609.     -- Crit Rating - MELEE_CRIT_RATING
  3610.     {
  3611.         option = "sumCritRating",
  3612.         name = "MELEE_CRIT_RATING",
  3613.         func = function(sum, sumType, link) return (sum["MELEE_CRIT_RATING"] or 0) end,
  3614.     },
  3615.     -- Ranged Crit Chance - MELEE_CRIT_RATING, WEAPON_RATING, AGI, RANGED_CRIT_RATING
  3616.     {
  3617.         option = "sumRangedCrit",
  3618.         name = "RANGED_CRIT",
  3619.         func = function(sum, sumType, link)
  3620.             local s = 0
  3621.             for id, v in pairs(sum) do
  3622.                 if strsub(id, -13) == "WEAPON_RATING" then
  3623.                     s = s + StatLogic:GetEffectFromRating(v, CR_WEAPON_SKILL, calcLevel) * 0.04
  3624.                     break
  3625.                 end
  3626.             end
  3627.             return s + StatLogic:GetEffectFromRating((sum["MELEE_CRIT_RATING"] or 0), "MELEE_CRIT_RATING", calcLevel)
  3628.                      + StatLogic:GetEffectFromRating((sum["RANGED_CRIT_RATING"] or 0), "RANGED_CRIT_RATING", calcLevel)
  3629.                      + StatLogic:GetCritFromAgi(sum["AGI"], class, calcLevel)
  3630.         end,
  3631.         ispercent = true,
  3632.     },
  3633.     -- Ranged Crit Rating - MELEE_CRIT_RATING, RANGED_CRIT_RATING
  3634.     {
  3635.         option = "sumRangedCritRating",
  3636.         name = "RANGED_CRIT_RATING",
  3637.         func = function(sum, sumType, link) return (sum["MELEE_CRIT_RATING"] or 0) + (sum["RANGED_CRIT_RATING"] or 0) end,
  3638.     },
  3639.     -- Haste - MELEE_HASTE_RATING
  3640.     {
  3641.         option = "sumHaste",
  3642.         name = "MELEE_HASTE",
  3643.         func = function(sum, sumType, link) return StatLogic:GetEffectFromRating((sum["MELEE_HASTE_RATING"] or 0), "MELEE_HASTE_RATING", calcLevel) end,
  3644.         ispercent = true,
  3645.     },
  3646.     -- Haste Rating - MELEE_HASTE_RATING
  3647.     {
  3648.         option = "sumHasteRating",
  3649.         name = "MELEE_HASTE_RATING",
  3650.         func = function(sum, sumType, link) return (sum["MELEE_HASTE_RATING"] or 0) end,
  3651.     },
  3652.     -- Ranged Haste - MELEE_HASTE_RATING, RANGED_HASTE_RATING
  3653.     {
  3654.         option = "sumRangedHaste",
  3655.         name = "RANGED_HASTE",
  3656.         func = function(sum, sumType, link)
  3657.             return StatLogic:GetEffectFromRating((sum["MELEE_HASTE_RATING"] or 0), "MELEE_HASTE_RATING", calcLevel)
  3658.                 + StatLogic:GetEffectFromRating((sum["RANGED_HASTE_RATING"] or 0), "RANGED_HASTE_RATING", calcLevel)
  3659.         end,
  3660.         ispercent = true,
  3661.     },
  3662.     -- Ranged Haste Rating - MELEE_HASTE_RATING, RANGED_HASTE_RATING
  3663.     {
  3664.         option = "sumRangedHasteRating",
  3665.         name = "RANGED_HASTE_RATING",
  3666.         func = function(sum, sumType, link) return (sum["MELEE_HASTE_RATING"] or 0) + (sum["RANGED_HASTE_RATING"] or 0) end,
  3667.     },
  3668.     -- Expertise - EXPERTISE_RATING
  3669.     {
  3670.         option = "sumExpertise",
  3671.         name = "EXPERTISE",
  3672.         func = function(sum, sumType, link) return StatLogic:GetEffectFromRating((sum["EXPERTISE_RATING"] or 0), "EXPERTISE_RATING", calcLevel) end,
  3673.     },
  3674.     -- Expertise Rating - EXPERTISE_RATING
  3675.     {
  3676.         option = "sumExpertiseRating",
  3677.         name = "EXPERTISE_RATING",
  3678.         func = function(sum, sumType, link) return (sum["EXPERTISE_RATING"] or 0) end,
  3679.     },
  3680.     -- Armor Penetration - ARMOR_PENETRATION_RATING
  3681.     {
  3682.         option = "sumArmorPenetration",
  3683.         name = "ARMOR_PENETRATION",
  3684.         func = function(sum, sumType, link) return StatLogic:GetEffectFromRating((sum["ARMOR_PENETRATION_RATING"] or 0), "ARMOR_PENETRATION_RATING", calcLevel) end,
  3685.         ispercent = true,
  3686.     },
  3687.     -- Armor Penetration Rating - ARMOR_PENETRATION_RATING
  3688.     {
  3689.         option = "sumArmorPenetrationRating",
  3690.         name = "ARMOR_PENETRATION_RATING",
  3691.         func = function(sum, sumType, link) return (sum["ARMOR_PENETRATION_RATING"] or 0) end,
  3692.     },
  3693.     -- Dodge Neglect - EXPERTISE_RATING, WEAPON_RATING -- 2.3.0
  3694.     {
  3695.         option = "sumDodgeNeglect",
  3696.         name = "DODGE_NEGLECT",
  3697.         func = function(sum, sumType, link)
  3698.             local s = 0
  3699.             for id, v in pairs(sum) do
  3700.                 if strsub(id, -13) == "WEAPON_RATING" then
  3701.                     s = StatLogic:GetEffectFromRating(v, CR_WEAPON_SKILL, calcLevel) * 0.04
  3702.                 end
  3703.             end
  3704.             s = s + StatLogic:GetEffectFromRating((sum["EXPERTISE_RATING"] or 0), "EXPERTISE_RATING", calcLevel) * 0.25
  3705.             return s
  3706.         end,
  3707.         ispercent = true,
  3708.     },
  3709.     -- Parry Neglect - EXPERTISE_RATING, WEAPON_RATING -- 2.3.0
  3710.     {
  3711.         option = "sumParryNeglect",
  3712.         name = "PARRY_NEGLECT",
  3713.         func = function(sum, sumType, link)
  3714.             local s = 0
  3715.             for id, v in pairs(sum) do
  3716.                 if strsub(id, -13) == "WEAPON_RATING" then
  3717.                     s = StatLogic:GetEffectFromRating(v, CR_WEAPON_SKILL, calcLevel) * 0.04
  3718.                 end
  3719.             end
  3720.             s = s + StatLogic:GetEffectFromRating((sum["EXPERTISE_RATING"] or 0), "EXPERTISE_RATING", calcLevel) * 0.25
  3721.             return s
  3722.         end,
  3723.         ispercent = true,
  3724.     },
  3725.     -- Block Neglect - WEAPON_RATING
  3726.     {
  3727.         option = "sumBlockNeglect",
  3728.         name = "BLOCK_NEGLECT",
  3729.         func = function(sum, sumType, link)
  3730.             for id, v in pairs(sum) do
  3731.                 if strsub(id, -13) == "WEAPON_RATING" then
  3732.                     return StatLogic:GetEffectFromRating(v, CR_WEAPON_SKILL, calcLevel) * 0.04
  3733.                 end
  3734.             end
  3735.             return 0
  3736.         end,
  3737.         ispercent = true,
  3738.     },
  3739.     -- Weapon Max Damage - MAX_DAMAGE
  3740.     {
  3741.         option = "sumWeaponMaxDamage",
  3742.         name = "MAX_DAMAGE",
  3743.         func = function(sum, sumType, link) return (sum["MAX_DAMAGE"] or 0) end,
  3744.     },
  3745.     -- Ignore Armor - IGNORE_ARMOR
  3746.     {
  3747.         option = "sumIgnoreArmor",
  3748.         name = "IGNORE_ARMOR",
  3749.         func = function(sum, sumType, link) return (sum["IGNORE_ARMOR"] or 0) end,
  3750.     },
  3751.     ------------------------------
  3752.     -- Spell Damage and Healing --
  3753.     ------------------------------
  3754.     -- Spell Damage - SPELL_DMG, ADD_SPELL_DMG_MOD_STA, ADD_SPELL_DMG_MOD_INT, ADD_SPELL_DMG_MOD_SPI, ADD_SPELL_DMG_MOD_AP
  3755.     {
  3756.         option = "sumSpellDmg",
  3757.         name = "SPELL_DMG",
  3758.         func = function(sum, sumType, link)
  3759.             local spellDmg = (sum["SPELL_DMG"] or 0)
  3760.             if RatingBuster:GetStatMod("ADD_SPELL_DMG_MOD_STR") ~= 0 then
  3761.                 spellDmg = spellDmg + (sum["STR"] * RatingBuster:GetStatMod("ADD_SPELL_DMG_MOD_STR"))
  3762.             end
  3763.             if RatingBuster:GetStatMod("ADD_SPELL_DMG_MOD_STA") ~= 0 then
  3764.                 spellDmg = spellDmg + (sum["STA"] * RatingBuster:GetStatMod("ADD_SPELL_DMG_MOD_STA"))
  3765.             end
  3766.             if RatingBuster:GetStatMod("ADD_SPELL_DMG_MOD_INT") ~= 0 then
  3767.                 spellDmg = spellDmg + (sum["INT"] * RatingBuster:GetStatMod("ADD_SPELL_DMG_MOD_INT"))
  3768.             end
  3769.             if RatingBuster:GetStatMod("ADD_SPELL_DMG_MOD_SPI") ~= 0 then
  3770.                 spellDmg = spellDmg + (sum["SPI"] * RatingBuster:GetStatMod("ADD_SPELL_DMG_MOD_SPI"))
  3771.             end
  3772.             if RatingBuster:GetStatMod("ADD_SPELL_DMG_MOD_AP") ~= 0 then
  3773.                 spellDmg = spellDmg + (summaryFunc["AP"](sum, sumType, link) * RatingBuster:GetStatMod("ADD_SPELL_DMG_MOD_AP"))
  3774.             end
  3775.             if RatingBuster:GetStatMod("ADD_PET_STA_MOD_STA") ~= 0 then
  3776.                 spellDmg = spellDmg + (sum["STA"] * RatingBuster:GetStatMod("ADD_SPELL_DMG_MOD_PET_STA") * RatingBuster:GetStatMod("ADD_PET_STA_MOD_STA"))
  3777.                 spellDmg = spellDmg + (sum["INT"] * RatingBuster:GetStatMod("ADD_SPELL_DMG_MOD_PET_INT") * RatingBuster:GetStatMod("ADD_PET_INT_MOD_INT"))
  3778.             end
  3779.             return spellDmg * RatingBuster:GetStatMod("MOD_SPELL_DMG")
  3780.         end,
  3781.     },
  3782.     -- Holy Damage - HOLY_SPELL_DMG, SPELL_DMG,
  3783.     {
  3784.         option = "sumHolyDmg",
  3785.         name = "HOLY_SPELL_DMG",
  3786.         func = function(sum, sumType, link)
  3787.             return summaryFunc["SPELL_DMG"](sum, sumType, link)
  3788.              + ((sum["HOLY_SPELL_DMG"] or 0)
  3789.              + (sum["SPI"] * RatingBuster:GetStatMod("ADD_SCHOOL_SP_MOD_SPI", "HOLY")))
  3790.              * RatingBuster:GetStatMod("MOD_SPELL_DMG")
  3791.         end,
  3792.     },
  3793.     -- Arcane Damage - ARCANE_SPELL_DMG, SPELL_DMG,
  3794.     {
  3795.         option = "sumArcaneDmg",
  3796.         name = "ARCANE_SPELL_DMG",
  3797.         func = function(sum, sumType, link)
  3798.             return summaryFunc["SPELL_DMG"](sum, sumType, link)
  3799.              + ((sum["ARCANE_SPELL_DMG"] or 0)
  3800.              + (sum["SPI"] * RatingBuster:GetStatMod("ADD_SCHOOL_SP_MOD_SPI", "ARCANE")))
  3801.              * RatingBuster:GetStatMod("MOD_SPELL_DMG")
  3802.         end,
  3803.     },
  3804.     -- Fire Damage - FIRE_SPELL_DMG, SPELL_DMG,
  3805.     {
  3806.         option = "sumFireDmg",
  3807.         name = "FIRE_SPELL_DMG",
  3808.         func = function(sum, sumType, link)
  3809.             return summaryFunc["SPELL_DMG"](sum, sumType, link)
  3810.              + ((sum["FIRE_SPELL_DMG"] or 0)
  3811.              + (sum["SPI"] * RatingBuster:GetStatMod("ADD_SCHOOL_SP_MOD_SPI", "FIRE")))
  3812.              * RatingBuster:GetStatMod("MOD_SPELL_DMG")
  3813.         end,
  3814.     },
  3815.     -- Nature Damage - NATURE_SPELL_DMG, SPELL_DMG,
  3816.     {
  3817.         option = "sumNatureDmg",
  3818.         name = "NATURE_SPELL_DMG",
  3819.         func = function(sum, sumType, link)
  3820.             return summaryFunc["SPELL_DMG"](sum, sumType, link)
  3821.              + ((sum["NATURE_SPELL_DMG"] or 0)
  3822.              + (sum["SPI"] * RatingBuster:GetStatMod("ADD_SCHOOL_SP_MOD_SPI", "NATURE")))
  3823.              * RatingBuster:GetStatMod("MOD_SPELL_DMG")
  3824.         end,
  3825.     },
  3826.     -- Frost Damage - FROST_SPELL_DMG, SPELL_DMG,
  3827.     {
  3828.         option = "sumFrostDmg",
  3829.         name = "FROST_SPELL_DMG",
  3830.         func = function(sum, sumType, link)
  3831.             return summaryFunc["SPELL_DMG"](sum, sumType, link)
  3832.              + ((sum["FROST_SPELL_DMG"] or 0)
  3833.              + (sum["SPI"] * RatingBuster:GetStatMod("ADD_SCHOOL_SP_MOD_SPI", "FROST")))
  3834.              * RatingBuster:GetStatMod("MOD_SPELL_DMG")
  3835.         end,
  3836.     },
  3837.     -- Shadow Damage - SHADOW_SPELL_DMG, SPELL_DMG, ADD_SCHOOL_SP_MOD_SPI
  3838.     {
  3839.         option = "sumShadowDmg",
  3840.         name = "SHADOW_SPELL_DMG",
  3841.         func = function(sum, sumType, link)
  3842.             return summaryFunc["SPELL_DMG"](sum, sumType, link)
  3843.              + ((sum["SHADOW_SPELL_DMG"] or 0)
  3844.              + (sum["SPI"] * RatingBuster:GetStatMod("ADD_SCHOOL_SP_MOD_SPI", "SHADOW")))
  3845.              * RatingBuster:GetStatMod("MOD_SPELL_DMG")
  3846.         end,
  3847.     },
  3848.     -- Healing - HEAL, AGI, STR, INT, SPI
  3849.     -- "ADD_HEALING_MOD_STR" -- Paladin: Touched by the Light
  3850.     -- "ADD_HEALING_MOD_AGI" -- Druid: Nurturing Instinct
  3851.     -- "ADD_HEALING_MOD_STA"
  3852.     -- "ADD_HEALING_MOD_INT"
  3853.     -- "ADD_HEALING_MOD_SPI"
  3854.     -- "ADD_HEALING_MOD_AP" -- Shaman: Mental Quickness
  3855.     {
  3856.         option = "sumHealing",
  3857.         name = "HEAL",
  3858.         func = function(sum, sumType, link)
  3859.             local heal = (sum["HEAL"] or 0)
  3860.             if RatingBuster:GetStatMod("ADD_HEALING_MOD_STR") ~= 0 then
  3861.                 heal = heal + (sum["STR"] * RatingBuster:GetStatMod("ADD_HEALING_MOD_STR"))
  3862.             end
  3863.             if RatingBuster:GetStatMod("ADD_HEALING_MOD_AGI") ~= 0 then
  3864.                 heal = heal + (sum["AGI"] * RatingBuster:GetStatMod("ADD_HEALING_MOD_AGI"))
  3865.             end
  3866.             if RatingBuster:GetStatMod("ADD_HEALING_MOD_STA") ~= 0 then
  3867.                 heal = heal + (sum["STA"] * RatingBuster:GetStatMod("ADD_HEALING_MOD_STA"))
  3868.             end
  3869.             if RatingBuster:GetStatMod("ADD_HEALING_MOD_INT") ~= 0 then
  3870.                 heal = heal + (sum["INT"] * RatingBuster:GetStatMod("ADD_HEALING_MOD_INT"))
  3871.             end
  3872.             if RatingBuster:GetStatMod("ADD_HEALING_MOD_SPI") ~= 0 then
  3873.                 heal = heal + (sum["SPI"] * RatingBuster:GetStatMod("ADD_HEALING_MOD_SPI"))
  3874.             end
  3875.             if RatingBuster:GetStatMod("ADD_HEALING_MOD_AP") ~= 0 then
  3876.                 heal = heal + (summaryFunc["AP"](sum, sumType, link) * RatingBuster:GetStatMod("ADD_HEALING_MOD_AP"))
  3877.             end
  3878.             return heal * RatingBuster:GetStatMod("MOD_HEALING")
  3879.         end,
  3880.     },
  3881.     -- Spell Hit Chance - SPELL_HIT_RATING
  3882.     {
  3883.         option = "sumSpellHit",
  3884.         name = "SPELL_HIT",
  3885.         func = function(sum, sumType, link) return StatLogic:GetEffectFromRating((sum["SPELL_HIT_RATING"] or 0), "SPELL_HIT_RATING", calcLevel) end,
  3886.         ispercent = true,
  3887.     },
  3888.     -- Spell Hit Rating - SPELL_HIT_RATING
  3889.     {
  3890.         option = "sumSpellHitRating",
  3891.         name = "SPELL_HIT_RATING",
  3892.         func = function(sum, sumType, link) return (sum["SPELL_HIT_RATING"] or 0) end,
  3893.     },
  3894.     -- Spell Crit Chance - SPELL_CRIT_RATING, INT
  3895.     {
  3896.         option = "sumSpellCrit",
  3897.         name = "SPELL_CRIT",
  3898.         func = function(sum, sumType, link)
  3899.             return StatLogic:GetEffectFromRating((sum["SPELL_CRIT_RATING"] or 0) + sum["SPI"] * RatingBuster:GetStatMod("ADD_SPELL_CRIT_RATING_MOD_SPI"), "SPELL_CRIT_RATING", calcLevel)
  3900.              + StatLogic:GetSpellCritFromInt(sum["INT"], class, calcLevel)
  3901.         end,
  3902.         ispercent = true,
  3903.     },
  3904.     -- Spell Crit Rating - SPELL_CRIT_RATING
  3905.     {
  3906.         option = "sumSpellCritRating",
  3907.         name = "SPELL_CRIT_RATING",
  3908.         func = function(sum, sumType, link) return (sum["SPELL_CRIT_RATING"] or 0) + sum["SPI"] * RatingBuster:GetStatMod("ADD_SPELL_CRIT_RATING_MOD_SPI") end,
  3909.     },
  3910.     -- Spell Haste - SPELL_HASTE_RATING
  3911.     {
  3912.         option = "sumSpellHaste",
  3913.         name = "SPELL_HASTE",
  3914.         func = function(sum, sumType, link) return StatLogic:GetEffectFromRating((sum["SPELL_HASTE_RATING"] or 0), "SPELL_HASTE_RATING", calcLevel) end,
  3915.         ispercent = true,
  3916.     },
  3917.     -- Spell Haste Rating - SPELL_HASTE_RATING
  3918.     {
  3919.         option = "sumSpellHasteRating",
  3920.         name = "SPELL_HASTE_RATING",
  3921.         func = function(sum, sumType, link) return (sum["SPELL_HASTE_RATING"] or 0) end,
  3922.     },
  3923.     -- Spell Penetration - SPELLPEN
  3924.     {
  3925.         option = "sumPenetration",
  3926.         name = "SPELLPEN",
  3927.         func = function(sum, sumType, link) return (sum["SPELLPEN"] or 0) end,
  3928.     },
  3929.     ----------
  3930.     -- Tank --
  3931.     ----------
  3932.     -- Armor - ARMOR, ARMOR_BONUS, AGI, INT
  3933.     {
  3934.         option = "sumArmor",
  3935.         name = "ARMOR",
  3936.         func = function(sum, sumType, link)
  3937.             -- Bonus armor beyond the base armor of an item will no longer be multiplied,
  3938.             -- this includes armor from Necks, Rings, Trinkets, Weapons
  3939.             -- Commented out because StatLogic now handles this
  3940.             -- local itemType = select(9, GetItemInfo(link))
  3941.             -- local mod = 1
  3942.             -- if not modFreeArmorItemEquipLoc[itemType] then
  3943.                 -- mod = RatingBuster:GetStatMod("MOD_ARMOR")
  3944.             -- end
  3945.             return (sum["ARMOR"] or 0) * RatingBuster:GetStatMod("MOD_ARMOR")
  3946.              + (sum["ARMOR_BONUS"] or 0) + ((sum["AGI"] or 0) * 2)
  3947.              + ((sum["INT"] or 0) * RatingBuster:GetStatMod("ADD_ARMOR_MOD_INT"))
  3948.         end,
  3949.     },
  3950.     -- Dodge Chance Before DR - DODGE_RATING, DEFENSE_RATING, AGI
  3951.     {
  3952.         option = "sumDodgeBeforeDR",
  3953.         name = "DODGE_NO_DR",
  3954.         func = function(sum, sumType, link)
  3955.             local dodge = StatLogic:GetEffectFromRating((sum["DODGE_RATING"] or 0), "DODGE_RATING", calcLevel)
  3956.                 + StatLogic:GetEffectFromRating((sum["DEFENSE_RATING"] or 0), "DEFENSE_RATING", calcLevel) * 0.04
  3957.                 + StatLogic:GetDodgeFromAgi(sum["AGI"] or 0)
  3958.             return dodge
  3959.         end,
  3960.         ispercent = true,
  3961.     },
  3962.     -- Dodge Chance - DODGE_RATING, DEFENSE_RATING, AGI
  3963.     {
  3964.         option = "sumDodge",
  3965.         name = "DODGE",
  3966.         func = function(sum, sumType, link)
  3967.             local dodge = summaryFunc["DODGE_NO_DR"](sum, sumType, link)
  3968.             if profileDB.enableAvoidanceDiminishingReturns then
  3969.                 if (sumType == "diff1") or (sumType == "diff2") then
  3970.                     dodge = StatLogic:GetAvoidanceGainAfterDR("DODGE", dodge)
  3971.                 elseif sumType == "sum" then
  3972.                     dodge = StatLogic:GetAvoidanceGainAfterDR("DODGE", equippedDodge + dodge) - StatLogic:GetAvoidanceGainAfterDR("DODGE", equippedDodge)
  3973.                 end
  3974.             end
  3975.             return dodge
  3976.         end,
  3977.         ispercent = true,
  3978.     },
  3979.     -- Dodge Rating - DODGE_RATING
  3980.     {
  3981.         option = "sumDodgeRating",
  3982.         name = "DODGE_RATING",
  3983.         func = function(sum, sumType, link) return (sum["DODGE_RATING"] or 0) end,
  3984.     },
  3985.     -- Parry Chance Before DR - PARRY_RATING, DEFENSE_RATING
  3986.     {
  3987.         option = "sumParryBeforeDR",
  3988.         name = "PARRY_NO_DR",
  3989.         func = function(sum, sumType, link)
  3990.             if GetParryChance() == 0 then return 0 end
  3991.             local parryRating = (sum["PARRY_RATING"] or 0)
  3992.             if RatingBuster:GetStatMod("ADD_CR_PARRY_MOD_STR") ~= 0 then
  3993.                 if(sumType == "diff1" or sumType == "diff2") then
  3994.                     local str = UnitStat("player", 1)
  3995.                     local newStr = (sum["STR"] or 0) + str
  3996.                     parryRating = parryRating + floor(newStr * RatingBuster:GetStatMod("ADD_CR_PARRY_MOD_STR")) - floor(str * RatingBuster:GetStatMod("ADD_CR_PARRY_MOD_STR"))
  3997.                 else
  3998.                     parryRating = parryRating + (sum["STR"] or 0) * RatingBuster:GetStatMod("ADD_CR_PARRY_MOD_STR")
  3999.                 end
  4000.             end
  4001.             local parry = StatLogic:GetEffectFromRating(parryRating, "PARRY_RATING", calcLevel)
  4002.                 + StatLogic:GetEffectFromRating((sum["DEFENSE_RATING"] or 0), "DEFENSE_RATING", calcLevel) * 0.04
  4003.             return parry
  4004.         end,
  4005.         ispercent = true,
  4006.     },
  4007.     -- Parry Chance - PARRY_RATING, DEFENSE_RATING
  4008.     {
  4009.         option = "sumParry",
  4010.         name = "PARRY",
  4011.         func = function(sum, sumType, link)
  4012.             local parry = summaryFunc["PARRY_NO_DR"](sum, sumType, link)
  4013.             if profileDB.enableAvoidanceDiminishingReturns then
  4014.                 if (sumType == "diff1") or (sumType == "diff2") then
  4015.                     parry = StatLogic:GetAvoidanceGainAfterDR("PARRY", parry)
  4016.                 elseif sumType == "sum" then
  4017.                     parry = StatLogic:GetAvoidanceGainAfterDR("PARRY", equippedParry + parry) - StatLogic:GetAvoidanceGainAfterDR("PARRY", equippedParry)
  4018.                 end
  4019.             end
  4020.             return parry
  4021.         end,
  4022.         ispercent = true,
  4023.     },
  4024.     -- Parry Rating - PARRY_RATING
  4025.     -- "ADD_CR_PARRY_MOD_STR" -- Death Knight: Forceful Deflection - Passive
  4026.     {
  4027.         option = "sumParryRating",
  4028.         name = "PARRY_RATING",
  4029.         func = function(sum, sumType, link) return (sum["PARRY_RATING"] or 0) + (sum["STR"] * RatingBuster:GetStatMod("ADD_CR_PARRY_MOD_STR")) end,
  4030.     },
  4031.     -- Block Chance - BLOCK_RATING, DEFENSE_RATING
  4032.     {
  4033.         option = "sumBlock",
  4034.         name = "BLOCK",
  4035.         func = function(sum, sumType, link)
  4036.             if GetBlockChance() == 0 then return 0 end
  4037.             return StatLogic:GetEffectFromRating((sum["BLOCK_RATING"] or 0), "BLOCK_RATING", calcLevel)
  4038.                  + StatLogic:GetEffectFromRating((sum["DEFENSE_RATING"] or 0), "DEFENSE_RATING", calcLevel) * 0.04
  4039.         end,
  4040.         ispercent = true,
  4041.     },
  4042.     -- Block Rating - BLOCK_RATING
  4043.     {
  4044.         option = "sumBlockRating",
  4045.         name = "BLOCK_RATING",
  4046.         func = function(sum, sumType, link) return (sum["BLOCK_RATING"] or 0) end,
  4047.     },
  4048.     -- Block Value - BLOCK_VALUE, STR
  4049.     {
  4050.         option = "sumBlockValue",
  4051.         name = "BLOCK_VALUE",
  4052.         func = function(sum, sumType, link)
  4053.             if GetBlockChance() == 0 then return 0 end
  4054.             return ((sum["BLOCK_VALUE"] or 0) + ((sum["STR"] or 0) * StatLogic:GetBlockValuePerStr(class))) * RatingBuster:GetStatMod("MOD_BLOCK_VALUE")
  4055.                  
  4056.         end,
  4057.     },
  4058.     -- Hit Avoidance Before DR - DEFENSE_RATING, MELEE_HIT_AVOID_RATING
  4059.     {
  4060.         option = "sumHitAvoidBeforeDR",
  4061.         name = "MELEE_HIT_AVOID_NO_DR",
  4062.         func = function(sum, sumType, link) return StatLogic:GetEffectFromRating((sum["MELEE_HIT_AVOID_RATING"] or 0), "MELEE_HIT_AVOID_RATING", calcLevel)
  4063.              + StatLogic:GetEffectFromRating((sum["DEFENSE_RATING"] or 0), "DEFENSE_RATING", calcLevel) * 0.04 end,
  4064.         ispercent = true,
  4065.     },
  4066.     -- Hit Avoidance Before DR - DEFENSE_RATING, MELEE_HIT_AVOID_RATING
  4067.     {
  4068.         option = "sumHitAvoid",
  4069.         name = "MELEE_HIT_AVOID",
  4070.         func = function(sum, sumType, link)
  4071.             local missed = summaryFunc["MELEE_HIT_AVOID_NO_DR"](sum, sumType, link)
  4072.             if profileDB.enableAvoidanceDiminishingReturns then
  4073.                 if (sumType == "diff1") or (sumType == "diff2") then
  4074.                     missed = StatLogic:GetAvoidanceGainAfterDR("MELEE_HIT_AVOID", missed)
  4075.                 elseif sumType == "sum" then
  4076.                     missed = StatLogic:GetAvoidanceGainAfterDR("MELEE_HIT_AVOID", equippedMissed + missed) - StatLogic:GetAvoidanceGainAfterDR("MELEE_HIT_AVOID", equippedMissed)
  4077.                 end
  4078.             end
  4079.             return missed
  4080.         end,
  4081.         ispercent = true,
  4082.     },
  4083.     -- Crit Avoidance - DEFENSE_RATING, RESILIENCE_RATING, MELEE_CRIT_AVOID_RATING
  4084.     {
  4085.         option = "sumCritAvoid",
  4086.         name = "MELEE_CRIT_AVOID",
  4087.         func = function(sum, sumType, link) return StatLogic:GetEffectFromRating((sum["MELEE_CRIT_AVOID_RATING"] or 0), "MELEE_CRIT_AVOID_RATING", calcLevel)
  4088.              + StatLogic:GetEffectFromRating((sum["RESILIENCE_RATING"] or 0), "RESILIENCE_RATING", calcLevel)
  4089.              + StatLogic:GetEffectFromRating((sum["DEFENSE_RATING"] or 0), "DEFENSE_RATING", calcLevel) * 0.04 end,
  4090.         ispercent = true,
  4091.     },
  4092.     -- Resilience - RESILIENCE_RATING
  4093.     {
  4094.         option = "sumResilience",
  4095.         name = "RESILIENCE_RATING",
  4096.         func = function(sum, sumType, link) return (sum["RESILIENCE_RATING"] or 0) end,
  4097.     },
  4098.     -- Arcane Resistance - ARCANE_RES
  4099.     {
  4100.         option = "sumArcaneResist",
  4101.         name = "ARCANE_RES",
  4102.         func = function(sum, sumType, link) return (sum["ARCANE_RES"] or 0) end,
  4103.     },
  4104.     -- Fire Resistance - FIRE_RES
  4105.     {
  4106.         option = "sumFireResist",
  4107.         name = "FIRE_RES",
  4108.         func = function(sum, sumType, link) return (sum["FIRE_RES"] or 0) end,
  4109.     },
  4110.     -- Nature Resistance - NATURE_RES
  4111.     {
  4112.         option = "sumNatureResist",
  4113.         name = "NATURE_RES",
  4114.         func = function(sum, sumType, link) return (sum["NATURE_RES"] or 0) end,
  4115.     },
  4116.     -- Frost Resistance - FROST_RES
  4117.     {
  4118.         option = "sumFrostResist",
  4119.         name = "FROST_RES",
  4120.         func = function(sum, sumType, link) return (sum["FROST_RES"] or 0) end,
  4121.     },
  4122.     -- Shadow Resistance - SHADOW_RES
  4123.     {
  4124.         option = "sumShadowResist",
  4125.         name = "SHADOW_RES",
  4126.         func = function(sum, sumType, link) return (sum["SHADOW_RES"] or 0) end,
  4127.     },
  4128.     -- Defense - DEFENSE_RATING
  4129.     {
  4130.         option = "sumDefense",
  4131.         name = "DEFENSE",
  4132.         func = function(sum, sumType, link) return StatLogic:GetEffectFromRating((sum["DEFENSE_RATING"] or 0), "DEFENSE_RATING", calcLevel) end,
  4133.     },
  4134.     -- Avoidance - DODGE, PARRY, MELEE_HIT_AVOID, BLOCK(Optional)
  4135.     {
  4136.         option = "sumAvoidance",
  4137.         name = "AVOIDANCE",
  4138.         ispercent = true,
  4139.         func = function(sum, sumType, link)
  4140.             local dodge, parry, mobMiss, block
  4141.             dodge = summaryFunc["DODGE"](sum, sumType, link)
  4142.             parry = summaryFunc["PARRY"](sum, sumType, link)
  4143.             mobMiss = summaryFunc["MELEE_HIT_AVOID"](sum, sumType, link)
  4144.             block = 0
  4145.             if profileDB.sumAvoidWithBlock then
  4146.                 block = summaryFunc["BLOCK"](sum, sumType, link)
  4147.             end
  4148.             return parry + dodge + mobMiss + block
  4149.         end,
  4150.         ispercent = true,
  4151.     },
  4152. }
  4153. if tpSupport == true then
  4154.     -- TankPoints
  4155.     tinsert(summaryCalcData, {
  4156.         option = "sumTankPoints",
  4157.         name = "TANKPOINTS",
  4158.         func = function(diffTable1, sumType)
  4159.             if sumType == "sum" then return nil end
  4160.             -- Item type
  4161.             local itemType = diffTable1.itemType
  4162.             -- Calculate current TankPoints
  4163.             local tpSource = {}
  4164.             local TP = TankPoints
  4165.             local TPTips = TankPointsTooltips
  4166.             TP:GetSourceData(tpSource, TP_MELEE)
  4167.             local tpResults = {}
  4168.             copyTable(tpResults, tpSource)
  4169.             TP:GetTankPoints(tpResults, TP_MELEE)
  4170.             -- Update if different
  4171.             if floor(TP.resultsTable.tankPoints[TP_MELEE]) ~= floor(tpResults.tankPoints[TP_MELEE]) then
  4172.                 copyTable(TP.sourceTable, tpSource)
  4173.                 copyTable(TP.resultsTable, tpResults)
  4174.             end
  4175.             ----------------------------------------------------
  4176.             -- Calculate TP difference with 1st equipped item --
  4177.             ----------------------------------------------------
  4178.             local tpTable = {}
  4179.             -- Set the forceShield arg
  4180.             local forceShield
  4181.             -- if not equipped shield and item is shield then force on
  4182.             -- if not equipped shield and item is not shield then nil
  4183.             -- if equipped shield and item is shield then nil
  4184.             -- if equipped shield and item is not shield then force off
  4185.             if ((diffTable1.diffItemType1 ~= "INVTYPE_SHIELD") and (diffTable1.diffItemType2 ~= "INVTYPE_SHIELD")) and (itemType == "INVTYPE_SHIELD") then
  4186.                 forceShield = true
  4187.             elseif ((diffTable1.diffItemType1 == "INVTYPE_SHIELD") or (diffTable1.diffItemType2 == "INVTYPE_SHIELD")) and (itemType ~= "INVTYPE_SHIELD") then
  4188.                 forceShield = false
  4189.             end
  4190.             -- Get the tp table
  4191.             TP:GetSourceData(tpTable, TP_MELEE, forceShield)
  4192.             -- Build changes table
  4193.             local changes = TPTips:BuildChanges({}, diffTable1)
  4194.             -- Alter tp table
  4195.             TP:AlterSourceData(tpTable, changes, forceShield)
  4196.             -- Calculate TankPoints from tpTable
  4197.             TP:GetTankPoints(tpTable, TP_MELEE, forceShield)
  4198.             -- Calculate tp difference
  4199.             local diff = floor(tpTable.tankPoints[TP_MELEE]) - floor(TP.resultsTable.tankPoints[TP_MELEE])
  4200.    
  4201.             return diff
  4202.         end,
  4203.     })
  4204.     -- Total Reduction
  4205.     tinsert(summaryCalcData, {
  4206.         option = "sumTotalReduction",
  4207.         name = "TOTALREDUCTION",
  4208.         ispercent = true,
  4209.         func = function(diffTable1, sumType)
  4210.             if sumType == "sum" then return nil end
  4211.             -- Item type
  4212.             local itemType = diffTable1.itemType
  4213.             local right
  4214.             -- Calculate current TankPoints
  4215.             local tpSource = {}
  4216.             local TP = TankPoints
  4217.             local TPTips = TankPointsTooltips
  4218.             TP:GetSourceData(tpSource, TP_MELEE)
  4219.             local tpResults = {}
  4220.             copyTable(tpResults, tpSource)
  4221.             TP:GetTankPoints(tpResults, TP_MELEE)
  4222.             -- Update if different
  4223.             if floor(TP.resultsTable.tankPoints[TP_MELEE]) ~= floor(tpResults.tankPoints[TP_MELEE]) then
  4224.                 copyTable(TP.sourceTable, tpSource)
  4225.                 copyTable(TP.resultsTable, tpResults)
  4226.             end
  4227.             ----------------------------------------------------
  4228.             -- Calculate TP difference with 1st equipped item --
  4229.             ----------------------------------------------------
  4230.             local tpTable = {}
  4231.             -- Set the forceShield arg
  4232.             local forceShield
  4233.             -- if not equipped shield and item is shield then force on
  4234.             -- if not equipped shield and item is not shield then nil
  4235.             -- if equipped shield and item is shield then nil
  4236.             -- if equipped shield and item is not shield then force off
  4237.             if ((diffTable1.diffItemType1 ~= "INVTYPE_SHIELD") and (diffTable1.diffItemType2 ~= "INVTYPE_SHIELD")) and (itemType == "INVTYPE_SHIELD") then
  4238.                 forceShield = true
  4239.             elseif ((diffTable1.diffItemType1 == "INVTYPE_SHIELD") or (diffTable1.diffItemType2 == "INVTYPE_SHIELD")) and (itemType ~= "INVTYPE_SHIELD") then
  4240.                 forceShield = false
  4241.             end
  4242.             -- Get the tp table
  4243.             TP:GetSourceData(tpTable, TP_MELEE, forceShield)
  4244.             -- Build changes table
  4245.             local changes = TPTips:BuildChanges({}, diffTable1)
  4246.             -- Alter tp table
  4247.             TP:AlterSourceData(tpTable, changes, forceShield)
  4248.             -- Calculate TankPoints from tpTable
  4249.             TP:GetTankPoints(tpTable, TP_MELEE, forceShield)
  4250.             -- Calculate tp difference
  4251.             local diff = tpTable.totalReduction[TP_MELEE] - TP.resultsTable.totalReduction[TP_MELEE]
  4252.            
  4253.             return diff * 100
  4254.         end,
  4255.     })
  4256.     --[[
  4257.     -- Avoidance
  4258.     tinsert(summaryCalcData, {
  4259.         option = "sumAvoidance",
  4260.         name = "AVOIDANCE",
  4261.         ispercent = true,
  4262.         func = function(diffTable1)
  4263.             -- Item type
  4264.             local itemType = diffTable1.itemType
  4265.             local right
  4266.             -- Calculate current TankPoints
  4267.             local tpSource = {}
  4268.             local TP = TankPoints
  4269.             local TPTips = TankPointsTooltips
  4270.             TP:GetSourceData(tpSource, TP_MELEE)
  4271.             local tpResults = {}
  4272.             copyTable(tpResults, tpSource)
  4273.             TP:GetTankPoints(tpResults, TP_MELEE)
  4274.             -- Update if different
  4275.             if floor(TP.resultsTable.tankPoints[TP_MELEE]) ~= floor(tpResults.tankPoints[TP_MELEE]) then
  4276.                 copyTable(TP.sourceTable, tpSource)
  4277.                 copyTable(TP.resultsTable, tpResults)
  4278.             end
  4279.             ----------------------------------------------------
  4280.             -- Calculate TP difference with 1st equipped item --
  4281.             ----------------------------------------------------
  4282.             local tpTable = {}
  4283.             -- Set the forceShield arg
  4284.             local forceShield
  4285.             -- if not equipped shield and item is shield then force on
  4286.             -- if not equipped shield and item is not shield then nil
  4287.             -- if equipped shield and item is shield then nil
  4288.             -- if equipped shield and item is not shield then force off
  4289.             if ((diffTable1.diffItemType1 ~= "INVTYPE_SHIELD") and (diffTable1.diffItemType2 ~= "INVTYPE_SHIELD")) and (itemType == "INVTYPE_SHIELD") then
  4290.                 forceShield = true
  4291.             elseif ((diffTable1.diffItemType1 == "INVTYPE_SHIELD") or (diffTable1.diffItemType2 == "INVTYPE_SHIELD")) and (itemType ~= "INVTYPE_SHIELD") then
  4292.                 forceShield = false
  4293.             end
  4294.             -- Get the tp table
  4295.             TP:GetSourceData(tpTable, TP_MELEE, forceShield)
  4296.             -- Build changes table
  4297.             local changes = TPTips:BuildChanges({}, diffTable1)
  4298.             -- Alter tp table
  4299.             TP:AlterSourceData(tpTable, changes, forceShield)
  4300.             -- Calculate TankPoints from tpTable
  4301.             TP:GetTankPoints(tpTable, TP_MELEE, forceShield)
  4302.             -- Calculate tp difference
  4303.             local diff = tpTable.mobMissChance + tpTable.dodgeChance + tpTable.parryChance - TP.resultsTable.mobMissChance - TP.resultsTable.dodgeChance - TP.resultsTable.parryChance
  4304.            
  4305.             return diff * 100
  4306.         end,
  4307.     })
  4308.     --]]
  4309. end
  4310.  
  4311. -- Build summaryFunc
  4312. for _, calcData in pairs(summaryCalcData) do
  4313.     summaryFunc[calcData.name] = calcData.func
  4314. end
  4315.  
  4316.  
  4317. function sumSortAlphaComp(a, b)
  4318.     return a[1] < b[1]
  4319. end
  4320.  
  4321. function RatingBuster:StatSummary(tooltip, name, link, ...)
  4322.     -- Hide stat summary for equipped items
  4323.     if profileDB.sumIgnoreEquipped and IsEquippedItem(link) then return end
  4324.    
  4325.     -- Show stat summary only for highest level armor type and items you can use with uncommon quality and up
  4326.     if profileDB.sumIgnoreUnused then
  4327.         local _, _, itemRarity, _, _, _, itemSubType, _, itemEquipLoc = GetItemInfo(link)
  4328.         -- Check rarity
  4329.         if not itemRarity or itemRarity < profileDB.sumMinQuality then return end
  4330.         -- Check armor type
  4331.         if armorTypes[itemSubType] and profileDB[armorTypes[itemSubType]] and itemEquipLoc ~= "INVTYPE_CLOAK" then
  4332.             --self:Print("Check armor type", itemSubType)
  4333.             return
  4334.         end
  4335.         -- Check for Red item types
  4336.         if canUseItemType[itemSubType] == false then
  4337.             return
  4338.         elseif canUseItemType[itemSubType] == nil then
  4339.             local tName = tooltip:GetName()
  4340.             if (_G[tName.."TextRight3"]:GetText() and select(2, _G[tName.."TextRight3"]:GetTextColor()) < 0.2) or
  4341.             (_G[tName.."TextRight4"]:GetText() and select(2, _G[tName.."TextRight4"]:GetTextColor()) < 0.2) or
  4342.             (_G[tName.."TextRight5"]:GetText() and select(2, _G[tName.."TextRight5"]:GetTextColor()) < 0.2) or
  4343.             select(2, _G[tName.."TextLeft3"]:GetTextColor()) < 0.2 or select(2, _G[tName.."TextLeft4"]:GetTextColor()) < 0.2 or
  4344.             select(2, _G[tName.."TextLeft5"]:GetTextColor()) < 0.2 then
  4345.                 canUseItemType[itemSubType] = false
  4346.                 return
  4347.             else
  4348.                 canUseItemType[itemSubType] = true
  4349.             end
  4350.         end
  4351.     end
  4352.    
  4353.     -- Ignore enchants and gems on items when calculating the stat summarythen
  4354.     local red, yellow, blue, meta
  4355.     if isModifierKeyDown[profileDB.sumGem2Toggle] and isModifierKeyDown[profileDB.sumGem2Toggle]() then
  4356.         red = profileDB.sumGemRed2.gemID
  4357.         yellow = profileDB.sumGemYellow2.gemID
  4358.         blue = profileDB.sumGemBlue2.gemID
  4359.         meta = profileDB.sumGemMeta2.gemID
  4360.     elseif isModifierKeyDown[profileDB.sumGem3Toggle] and isModifierKeyDown[profileDB.sumGem3Toggle]() then
  4361.         red = profileDB.sumGemRed3.gemID
  4362.         yellow = profileDB.sumGemYellow3.gemID
  4363.         blue = profileDB.sumGemBlue3.gemID
  4364.         meta = profileDB.sumGemMeta3.gemID
  4365.     else
  4366.         red = profileDB.sumGemRed.gemID
  4367.         yellow = profileDB.sumGemYellow.gemID
  4368.         blue = profileDB.sumGemBlue.gemID
  4369.         meta = profileDB.sumGemMeta.gemID
  4370.     end
  4371.    
  4372.     if profileDB.sumIgnoreEnchant then
  4373.         link = StatLogic:RemoveEnchant(link)
  4374.     end
  4375.     if profileDB.sumIgnorePris then
  4376.         link = StatLogic:RemoveExtraSocketGem(link)
  4377.     end
  4378.     if profileDB.sumIgnoreGems then
  4379.         link = StatLogic:RemoveGem(link)
  4380.     else
  4381.         link = StatLogic:BuildGemmedTooltip(link, red, yellow, blue, meta)
  4382.     end
  4383.    
  4384.     -- Diff Display Style
  4385.     -- Main Tooltip: tooltipLevel = 0
  4386.     -- Compare Tooltip 1: tooltipLevel = 1
  4387.     -- Compare Tooltip 2: tooltipLevel = 2
  4388.     local id
  4389.     local tooltipLevel = 0
  4390.     local mainTooltip = tooltip
  4391.     -- Determine tooltipLevel and id
  4392.     if profileDB.calcDiff and (profileDB.sumDiffStyle == "comp") then
  4393.         -- Obtain main tooltip
  4394.         -- Detemine tooltip level
  4395.         if mainTooltip:GetOwner():GetObjectType() == "GameTooltip" then
  4396.             mainTooltip = mainTooltip:GetOwner()
  4397.             -- This is a comparison tooltip
  4398.             local _, level = ...
  4399.             if type(level) == "number" then
  4400.                 tooltipLevel = level
  4401.             else
  4402.                 tooltipLevel = 1
  4403.             end
  4404.             if mainTooltip:GetOwner():GetObjectType() == "GameTooltip" then
  4405.                 mainTooltip = mainTooltip:GetOwner()
  4406.                 if type(level) ~= "number" then
  4407.                     tooltipLevel = 2
  4408.                 end
  4409.             end
  4410.         end
  4411.         local _, mainlink = StatLogic:GetDiffID(mainTooltip, profileDB.sumIgnoreEnchant, profileDB.sumIgnoreGems, red, yellow, blue, meta, profileDB.sumIgnorePris)
  4412.         if not mainlink then return end
  4413.         -- Construct id
  4414.         if tooltipLevel > 0 then
  4415.             id = link..mainlink
  4416.         else
  4417.             id = "sum"..link
  4418.         end
  4419.     else
  4420.         id = StatLogic:GetDiffID(link, profileDB.sumIgnoreEnchant, profileDB.sumIgnoreGems, red, yellow, blue, meta, profileDB.sumIgnorePris)
  4421.         if not id then return end
  4422.     end
  4423.    
  4424.     -- Check Cache
  4425.     if cache[id] then
  4426.         if #cache[id] == 0 then return end
  4427.         -- Write Tooltip
  4428.         if profileDB.sumBlankLine then
  4429.             tooltip:AddLine(" ")
  4430.         end
  4431.         if profileDB.sumShowTitle then
  4432.             tooltip:AddLine(HIGHLIGHT_FONT_COLOR_CODE..L["Stat Summary"]..FONT_COLOR_CODE_CLOSE)
  4433.             if profileDB.sumShowIcon then
  4434.                 tooltip:AddTexture("Interface\\AddOns\\RatingBuster\\images\\Sigma")
  4435.             end
  4436.         end
  4437.         -- local left, right = "", ""
  4438.         -- for _, o in ipairs(cache[id]) do
  4439.             -- left = left..o[1].."\n"
  4440.             -- right = right..o[2].."\n"
  4441.         -- end
  4442.         -- left = strsub(left, 1, -3)
  4443.         -- right = strsub(right, 1, -3)
  4444.         -- tooltip:AddDoubleLine(left, right)
  4445.         for _, o in ipairs(cache[id]) do
  4446.             tooltip:AddDoubleLine(o[1], o[2])
  4447.         end
  4448.         if profileDB.sumBlankLineAfter then
  4449.             tooltip:AddLine(" ")
  4450.         end
  4451.         return
  4452.     end
  4453.    
  4454.     -------------------------
  4455.     -- Build Summary Table --
  4456.     local statData = {}
  4457.     statData.sum = StatLogic:GetSum(link)
  4458.     if not statData.sum then return end
  4459.     if not profileDB.calcSum then
  4460.         statData.sum = nil
  4461.     end
  4462.    
  4463.     -- Ignore bags
  4464.     if not StatLogic:GetDiff(link) then return end
  4465.    
  4466.     -- Get Diff Data
  4467.     if profileDB.calcDiff then
  4468.         if profileDB.sumDiffStyle == "comp" then
  4469.             if tooltipLevel > 0 then
  4470.                 statData.diff1 = select(tooltipLevel, StatLogic:GetDiff(mainTooltip, nil, nil, profileDB.sumIgnoreEnchant, profileDB.sumIgnoreGems, red, yellow, blue, meta, profileDB.sumIgnorePris))
  4471.             end
  4472.         else
  4473.             statData.diff1, statData.diff2 = StatLogic:GetDiff(link, nil, nil, profileDB.sumIgnoreEnchant, profileDB.sumIgnoreGems, red, yellow, blue, meta, profileDB.sumIgnorePris)
  4474.         end
  4475.     end
  4476.     -- Apply Base Stat Mods
  4477.     for _, v in pairs(statData) do
  4478.         v["STR"] = (v["STR"] or 0)
  4479.         v["AGI"] = (v["AGI"] or 0)
  4480.         v["STA"] = (v["STA"] or 0)
  4481.         v["INT"] = (v["INT"] or 0)
  4482.         v["SPI"] = (v["SPI"] or 0)
  4483.     end
  4484.     if profileDB.enableStatMods then
  4485.         for _, v in pairs(statData) do
  4486.             v["STR"] = v["STR"] * RatingBuster:GetStatMod("MOD_STR")
  4487.             v["AGI"] = v["AGI"] * RatingBuster:GetStatMod("MOD_AGI")
  4488.             v["STA"] = v["STA"] * RatingBuster:GetStatMod("MOD_STA")
  4489.             v["INT"] = v["INT"] * RatingBuster:GetStatMod("MOD_INT")
  4490.             v["SPI"] = v["SPI"] * RatingBuster:GetStatMod("MOD_SPI")
  4491.         end
  4492.     end
  4493.     -- Summary Table
  4494.     --[[
  4495.     local statData = {
  4496.         sum = {},
  4497.         diff1 = {},
  4498.         diff2 = {},
  4499.     }
  4500.     if profileDB.sumHP then
  4501.         local d = {name = "HEALTH"}
  4502.         for k, sum in pairs(data) do
  4503.             d[k] = ((sum["HEALTH"] or 0) + (sum["STA"] * 10)) * RatingBuster:GetStatMod("MOD_HEALTH")
  4504.         end
  4505.         tinsert(summary, d)
  4506.     end
  4507.     local summaryCalcData = {
  4508.         -- Health - HEALTH, STA
  4509.         sumHP = {
  4510.             name = "HEALTH",
  4511.             func = function(sum, sumType, link) return ((sum["HEALTH"] or 0) + (sum["STA"] * 10)) * RatingBuster:GetStatMod("MOD_HEALTH") end,
  4512.             ispercent = false,
  4513.         },
  4514.     }
  4515.     --]]
  4516.     local summary = {}
  4517.     for _, calcData in pairs(summaryCalcData) do
  4518.         if profileDB[calcData.option] then
  4519.             local entry = {
  4520.                 name = calcData.name,
  4521.                 ispercent = calcData.ispercent,
  4522.             }
  4523.             for sumType, statTable in pairs(statData) do
  4524.                 entry[sumType] = calcData.func(statTable, sumType, link)
  4525.             end
  4526.             tinsert(summary, entry)
  4527.         end
  4528.     end
  4529.    
  4530.     local calcSum = profileDB.calcSum
  4531.     local calcDiff = profileDB.calcDiff
  4532.     -- Weapon Skill - WEAPON_RATING
  4533.     if profileDB.sumWeaponSkill then
  4534.         local weapon = {}
  4535.         if calcSum then
  4536.             for id, v in pairs(statData.sum) do
  4537.                 if strsub(id, -13) == "WEAPON_RATING" then
  4538.                     weapon[id] = true
  4539.                     local entry = {
  4540.                         name = strsub(id, 1, -8),
  4541.                     }
  4542.                     entry.sum = StatLogic:GetEffectFromRating(v, CR_WEAPON_SKILL, calcLevel)
  4543.                     if calcDiff and statData.diff1 then
  4544.                         entry.diff1 = StatLogic:GetEffectFromRating((statData.diff1[id] or 0), CR_WEAPON_SKILL, calcLevel)
  4545.                         if statData.diff2 then
  4546.                             entry.diff2 = StatLogic:GetEffectFromRating((statData.diff2[id] or 0), CR_WEAPON_SKILL, calcLevel)
  4547.                         end
  4548.                     end
  4549.                     tinsert(summary, entry)
  4550.                 end
  4551.             end
  4552.         end
  4553.         if calcDiff and statData.diff1 then
  4554.             for id, v in pairs(statData.diff1) do
  4555.                 if (strsub(id, -13) == "WEAPON_RATING") and not weapon[id] then
  4556.                     weapon[id] = true
  4557.                     local entry = {
  4558.                         name = strsub(id, 1, -8),
  4559.                         sum = 0,
  4560.                     }
  4561.                     entry.diff1 = StatLogic:GetEffectFromRating(v, CR_WEAPON_SKILL, calcLevel)
  4562.                     if statData.diff2 then
  4563.                         entry.diff2 = StatLogic:GetEffectFromRating((statData.diff2[id] or 0), CR_WEAPON_SKILL, calcLevel)
  4564.                     end
  4565.                     tinsert(summary, entry)
  4566.                 end
  4567.             end
  4568.             if statData.diff2 then
  4569.                 for id, v in pairs(statData.diff2) do
  4570.                     if (strsub(id, -13) == "WEAPON_RATING") and not weapon[id] then
  4571.                         weapon[id] = true
  4572.                         local entry = {
  4573.                             name = strsub(id, 1, -8),
  4574.                             sum = 0,
  4575.                             diff1 = 0,
  4576.                         }
  4577.                         entry.diff2 = StatLogic:GetEffectFromRating(v, CR_WEAPON_SKILL, calcLevel)
  4578.                         tinsert(summary, entry)
  4579.                     end
  4580.                 end
  4581.             end
  4582.         end
  4583.     end
  4584.    
  4585.     local showZeroValueStat = profileDB.showZeroValueStat
  4586.     ------------------------
  4587.     -- Build Output Table --
  4588.     local output = {}
  4589.     for _, t in ipairs(summary) do
  4590.         local n, s, d1, d2, ispercent = t.name, t.sum, t.diff1, t.diff2, t.ispercent
  4591.         local right, left
  4592.         local skip
  4593.         if not showZeroValueStat then
  4594.             -- Don't show this line if sum, diff1, diff2 are all 0
  4595.             if (s == 0 or not s) and (d1 == 0 or not d1) and (d2 == 0 or not d2) then
  4596.                 skip = true
  4597.             end
  4598.         end
  4599.         if not skip then
  4600.             if calcSum and calcDiff then
  4601.                 local d = ((not s) or ((s - floor(s)) == 0)) and ((not d1) or ((d1 - floor(d1)) == 0)) and ((not d2) or ((d2 - floor(d2)) == 0))
  4602.                 if s then
  4603.                     if d then
  4604.                         s = format("%d", s)
  4605.                     elseif ispercent then
  4606.                         s = format("%.2f%%", s)
  4607.                     else
  4608.                         s = format("%.1f", s)
  4609.                     end
  4610.                     if d1 then
  4611.                         if d then
  4612.                             d1 = colorNum(format("%+d", d1), d1)
  4613.                         elseif ispercent then
  4614.                             d1 = colorNum(format("%+.2f%%", d1), d1)
  4615.                         else
  4616.                             d1 = colorNum(format("%+.1f", d1), d1)
  4617.                         end
  4618.                         if d2 then
  4619.                             if d then
  4620.                                 d2 = colorNum(format("%+d", d2), d2)
  4621.                             elseif ispercent then
  4622.                                 d2 = colorNum(format("%+.2f%%", d2), d2)
  4623.                             else
  4624.                                 d2 = colorNum(format("%+.1f", d2), d2)
  4625.                             end
  4626.                             right = format("%s (%s||%s)", s, d1, d2)
  4627.                         else
  4628.                             right = format("%s (%s)", s, d1)
  4629.                         end
  4630.                     else
  4631.                         right = s
  4632.                     end
  4633.                 else
  4634.                     if d1 then
  4635.                         if d then
  4636.                             d1 = colorNum(format("%+d", d1), d1)
  4637.                         elseif ispercent then
  4638.                             d1 = colorNum(format("%+.2f%%", d1), d1)
  4639.                         else
  4640.                             d1 = colorNum(format("%+.1f", d1), d1)
  4641.                         end
  4642.                         if d2 then
  4643.                             if d then
  4644.                                 d2 = colorNum(format("%+d", d2), d2)
  4645.                             elseif ispercent then
  4646.                                 d2 = colorNum(format("%+.2f%%", d2), d2)
  4647.                             else
  4648.                                 d2 = colorNum(format("%+.1f", d2), d2)
  4649.                             end
  4650.                             right = format("(%s||%s)", d1, d2)
  4651.                         else
  4652.                             right = format("(%s)", d1)
  4653.                         end
  4654.                     end
  4655.                 end
  4656.             elseif calcSum then
  4657.                 if s then
  4658.                     if (s - floor(s)) == 0 then
  4659.                         s = format("%d", s)
  4660.                     elseif ispercent then
  4661.                         s = format("%.2f%%", s)
  4662.                     else
  4663.                         s = format("%.1f", s)
  4664.                     end
  4665.                     right = s
  4666.                 end
  4667.             elseif calcDiff then
  4668.                 local d = ((not d1) or (d1 - floor(d1)) == 0) and ((not d2) or ((d2 - floor(d2)) == 0))
  4669.                 if d1 then
  4670.                     if d then
  4671.                         d1 = colorNum(format("%+d", d1), d1)
  4672.                     elseif ispercent then
  4673.                         d1 = colorNum(format("%+.2f%%", d1), d1)
  4674.                     else
  4675.                         d1 = colorNum(format("%+.1f", d1), d1)
  4676.                     end
  4677.                     if d2 then
  4678.                         if d then
  4679.                             d2 = colorNum(format("%+d", d2), d2)
  4680.                         elseif ispercent then
  4681.                             d2 = colorNum(format("%+.2f%%", d2), d2)
  4682.                         else
  4683.                             d2 = colorNum(format("%+.1f", d2), d2)
  4684.                         end
  4685.                         right = format("%s||%s", d1, d2)
  4686.                     else
  4687.                         right = d1
  4688.                     end
  4689.                 end
  4690.             end
  4691.             if right then
  4692.                 if n == "TANKPOINTS" then
  4693.                     if tpSupport then
  4694.                         left = tpLocale["TankPoints"]
  4695.                     else
  4696.                         left = "TankPoints"
  4697.                     end
  4698.                 elseif n == "TOTALREDUCTION" then
  4699.                     if tpSupport then
  4700.                         left = tpLocale["Total Reduction"]
  4701.                     else
  4702.                         left = "Total Reduction"
  4703.                     end
  4704.                 else
  4705.                     left = StatLogic:GetStatNameFromID(n)
  4706.                 end
  4707.                 tinsert(output, {left, right})
  4708.             end
  4709.         end
  4710.     end
  4711.     -- sort alphabetically if option enabled
  4712.     if profileDB.sumSortAlpha then
  4713.         tsort(output, sumSortAlphaComp)
  4714.     end
  4715.     -- Write cache
  4716.     cache[id] = output
  4717.     if #output == 0 then return end
  4718.     -------------------
  4719.     -- Write Tooltip --
  4720.     if profileDB.sumBlankLine then
  4721.         tooltip:AddLine(" ")
  4722.     end
  4723.     if profileDB.sumShowTitle then
  4724.         tooltip:AddLine(HIGHLIGHT_FONT_COLOR_CODE..L["Stat Summary"]..FONT_COLOR_CODE_CLOSE)
  4725.         if profileDB.sumShowIcon then
  4726.             tooltip:AddTexture("Interface\\AddOns\\RatingBuster\\images\\Sigma")
  4727.         end
  4728.     end
  4729.     for _, o in ipairs(output) do
  4730.         tooltip:AddDoubleLine(o[1], o[2])
  4731.     end
  4732.     if profileDB.sumBlankLineAfter then
  4733.         tooltip:AddLine(" ")
  4734.     end
  4735. end
  4736.  
  4737.  
  4738. -- RatingBuster:Bench(1000)
  4739. ---------
  4740. -- self:SplitDoJoin("+24 Agility/+4 Stamina, +4 Dodge and +4 Spell Crit/+5 Spirit", {"/", " and ", ","})
  4741. -- 1000 times: 0.16 - 0.18 without Compost
  4742. -- 1000 times: 0.22 - 0.24 with Compost
  4743. ---------
  4744. -- RatingBuster.ProcessTooltip(ItemRefTooltip, link)
  4745. -- 1000 times: 0.31 sec - 0.7.6
  4746. -- 1000 times: 0.29 sec - 0.
  4747. -- 1000 times: 0.24 sec - 0.8.58.0
  4748. ---------
  4749. -- strjoin 1000000 times: 0.46
  4750. -- ..      1000000 times: 0.27
  4751. --------------
  4752. function RatingBuster:Bench(k)
  4753.     local t1 = GetTime()
  4754.     local link = GetInventoryItemLink("player", 12)
  4755.     for i = 1, k, 1 do
  4756.         ---------------------------------------------------------------------------
  4757.         --self:SplitDoJoin("+24 Agility/+4 Stamina, +4 Dodge and +4 Spell Crit/+5 Spirit", {"/", " and ", ","})
  4758.         ---------------------------------------------------------------------------
  4759.         ItemRefTooltip:SetInventoryItem("player", 12)
  4760.         RatingBuster.ProcessTooltip(ItemRefTooltip, link)
  4761.         ---------------------------------------------------------------------------
  4762.         --ItemRefTooltip:SetScript("OnTooltipSetItem", function(frame, ...) RatingBuster:Print("OnTooltipSetItem") end)
  4763.         ----------------------------------------------------------------------
  4764.         --local h = strjoin("", "test", "123")
  4765.         --local h = "test".."123"
  4766.         --------------------------------------------------------------------------------
  4767.     end
  4768.     return GetTime() - t1
  4769. end
 
04-02-16, 10:45 AM   #2
sirann
A Flamescale Wyrmkin
Join Date: Mar 2007
Posts: 142
We can't help you as playing on private servers are against the ToS, and this is an official wow website, where we HAVE to abide by the ToS.

Repeated postings of this will get you banned.
 
04-02-16, 11:07 AM   #3
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
What sirann said. ^^

Discussion of Private Servers, in any manner other than theoretical, is completely against our rules. We are an Official Fan Site. We follow Blizzard's rules, on top of our own rules.

Threads requesting assistance with Private Servers get locked. Repeated postings get you banned.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

 

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » Need help fixing an addon for 3.3.5


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off