Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local name, rds = ...
- RDS = rds
- local Frame1, Frame2
- local StrengthAdjust, ParryAdjust, DodgeAdjust, MasteryAdjust = 0, 0, 0, 0
- local BuffStrengthAdjust, BuffParryAdjust, BuffDodgeAdjust, BuffMasteryAdjust, BuffMultiplierAdjust = 0, 0, 0, 0, 1
- local function InjectRaidDefStats()
- local defenseCategory = PAPERDOLL_STATCATEGORIES["DEFENSE"]
- tinsert(defenseCategory.stats, "MASTERY")
- tinsert(defenseCategory.stats, "TOTALAVOIDANCE")
- tinsert(defenseCategory.stats, "COMBATTABLE")
- local MY_RACES = {
- NightElf = 194,
- BloodElf = 195,
- Goblin = 196,
- Orc = 192,
- Tauren = 194,
- Troll = 190,
- Undead = 197,
- Draenei = 190,
- Dwarf = 194,
- Gnome = 193,
- Human = 189,
- Worgen = 192,
- }
- local race = MY_RACES[select(2, UnitRace("player"))]
- PAPERDOLL_STATINFO["TOTALAVOIDANCE"] = {
- updateFunc = function(statFrame, unit)
- Frame1 = statFrame
- if (unit ~= "player") then
- statFrame:Hide();
- return;
- end
- local dodge = GetDodgeChance()
- local DodgeAdjustChance = ( DodgeAdjust + BuffDodgeAdjust ) / 176.7189
- local dodgeBeforeDR = 0.956 * ( 1 / (( 1 / ( dodge - 5 )) - 0.0152366 ))
- local dodgeAdjusted = dodgeBeforeDR + DodgeAdjustChance
- local dodgeAdjustedDR = ( 1 / (( 0.0152366 + ( 0.956 / dodgeAdjusted )))) + 5 -- total dodge % after DR
- local strength = select(1, UnitStat("player", 1))
- local raceStrength = strength - race
- local parryFromStrength = (floor((ceil(( raceStrength + StrengthAdjust + BuffStrengthAdjust ) * BuffMultiplierAdjust ) - raceStrength ) * 0.27 )) / 176.7189 -- Parry % from Strength adjustments(Including Kings/MOTW and BS/HoW )
- local parryFromAdjust = ( ParryAdjust + BuffParryAdjust ) / 176.7189 --parry% from Parry Adjustments
- local parryBeforeDR = 0.956 * ( 1 / (( 1 / ( GetParryChance() - 5 )) - 0.0152366 ))
- local parryAdjusted = parryFromStrength + parryFromAdjust + parryBeforeDR -- total parry % Buffed before DR
- local parryAdjustedDR = ( 1 / (( 0.0152366 + ( 0.956 / parryAdjusted)))) + 5 --total parry % (Buffed)after DR
- -- mastery with food
- local masteryRating = ( GetMastery() * 179.28004 ) + MasteryAdjust + BuffMasteryAdjust
- if select(2, UnitClass("player")) == "PALADIN" then
- BPM = 2.25 else
- BPM = 1.5
- end
- if select(2, UnitClass("player")) == "PALADIN" then
- blockAdjusted = (( masteryRating / 179.28004 )* BPM ) + 5 else
- blockAdjusted = (( masteryRating / 179.28004 )* BPM ) + 20
- end
- local missChance = 5
- if select(2, UnitRace("player")) == "NightElf" then
- missChance = 7
- end
- local totalChance = dodgeAdjustedDR + parryAdjustedDR + blockAdjusted + missChance
- local chance = dodgeAdjustedDR + parryAdjustedDR
- local ratio = parryAdjustedDR/dodgeAdjustedDR
- PaperDollFrame_SetLabelAndText(statFrame, "Total Avoidance", chance, 1);
- statFrame.tooltip = HIGHLIGHT_FONT_COLOR_CODE..format(PAPERDOLLFRAME_TOOLTIP_FORMAT, "Avoidance").." "..string.format("%.02f", chance).."%"..FONT_COLOR_CODE_CLOSE;
- statFrame:Show();
- end
- }
- PAPERDOLL_STATINFO["COMBATTABLE"] = {
- updateFunc = function(statFrame, unit)
- Frame2 = statFrame
- if (unit ~= "player") then
- statFrame:Hide();
- return;
- end
- local dodge = GetDodgeChance()
- local DodgeAdjustChance = ( DodgeAdjust + BuffDodgeAdjust ) / 176.7189
- local dodgeBeforeDR = 0.956 * ( 1 / (( 1 / ( dodge - 5 )) - 0.0152366 ))
- local dodgeAdjusted = dodgeBeforeDR + DodgeAdjustChance
- local dodgeAdjustedDR = ( 1 / (( 0.0152366 + ( 0.956 / dodgeAdjusted )))) + 5 -- total dodge % after DR
- local strength = select(1, UnitStat("player", 1))
- local raceStrength = strength - race
- local parryFromStrength = (floor((ceil(( raceStrength + StrengthAdjust + BuffStrengthAdjust ) * BuffMultiplierAdjust ) - raceStrength ) * 0.27 )) / 176.7189 -- Parry % from Strength adjustments(Including Kings/MOTW and BS/HoW )
- local parryFromAdjust = ( ParryAdjust + BuffParryAdjust ) / 176.7189 --parry% from Parry Adjustments
- local parryBeforeDR = 0.956 * ( 1 / (( 1 / ( GetParryChance() - 5 )) - 0.0152366 ))
- local parryAdjusted = parryFromStrength + parryFromAdjust + parryBeforeDR -- total parry % Buffed before DR
- local parryAdjustedDR = ( 1 / (( 0.0152366 + ( 0.956 / parryAdjusted)))) + 5 --total parry % (Buffed)after DR
- -- mastery with food
- local masteryRating = ( GetMastery() * 179.28004 ) + MasteryAdjust + BuffMasteryAdjust
- if select(2, UnitClass("player")) == "PALADIN" then
- BPM = 2.25 else
- BPM = 1.5
- end
- if select(2, UnitClass("player")) == "PALADIN" then
- blockAdjusted = (( masteryRating / 179.28 )* BPM ) + 5 else
- blockAdjusted = (( masteryRating / 179.28 )* BPM ) + 20
- end
- local missChance = 5
- if select(2, UnitRace("player")) == "NightElf" then
- missChance = 7
- end
- local totalChance = dodgeAdjustedDR + parryAdjustedDR + blockAdjusted + missChance
- local ratio = parryAdjustedDR/dodgeAdjustedDR
- PaperDollFrame_SetLabelAndText(statFrame, "C T Coverage", totalChance, 1, true)
- statFrame.tooltip = HIGHLIGHT_FONT_COLOR_CODE..format(PAPERDOLLFRAME_TOOLTIP_FORMAT, "Combat Table Coverage\n")..FONT_COLOR_CODE_CLOSE.."Automatically updates\nwhen you select buffs\nor input Stat change values\n\n\n".."Dodge: "..HIGHLIGHT_FONT_COLOR_CODE..string.format("%.02f", dodgeAdjustedDR).."% \n"..FONT_COLOR_CODE_CLOSE.."Parry: "..HIGHLIGHT_FONT_COLOR_CODE..string.format("%.02f", parryAdjustedDR).."% \n"..FONT_COLOR_CODE_CLOSE.."Block: "..HIGHLIGHT_FONT_COLOR_CODE..string.format("%.02f", blockAdjusted).."% \n\n"..FONT_COLOR_CODE_CLOSE.."TOTAL: "..HIGHLIGHT_FONT_COLOR_CODE..string.format("%.02f", totalChance).."% \n\n"..FONT_COLOR_CODE_CLOSE..string.format("Dodge: Parry Ratio: 1:%.02f",ratio);
- statFrame:Show();
- end
- }
- local class = select(2, UnitClass("player"))
- if class ~= "WARRIOR" and class ~= "PALADIN" then
- PAPERDOLL_STATINFO["BLOCK"] = nil
- end
- end
- local function onEvent(this, event, arg1)
- if event == "ADDON_LOADED" or event == "PLAYER_ALIVE" then
- rds.Opts.Load()
- InjectRaidDefStats()
- rds.frame:SetScript("OnEvent", nil)
- end
- end
- rds.Opts = CreateFrame("Frame", "R_D_S_Options", CharacterStatsPane, "BasicFrameTemplate") --Create the options Frame
- local NewEditbox = function(name)
- local parent = rds.Opts
- if _G[parent:GetName() .. name .. 'Editbox'] then
- return _G[parent:GetName() .. name .. 'Editbox']
- end
- local editBox = CreateFrame('EditBox', parent:GetName() .. name .. 'Editbox', parent, 'InputBoxTemplate')
- editBox:SetText(0)
- editBox:SetNumeric(true) --Makes the editbox only accept numbers.
- editBox:SetSize(45, 20)
- editBox:SetAutoFocus(false)
- editBox:SetScript('OnEscapePressed', function(self) self:ClearFocus() end)
- editBox.mod = 1
- editBox:SetScript('OnTextChanged', function(self)
- if editBox.AcquireText then
- editBox.AcquireText(self:GetNumber() * editBox.mod)
- end
- end)
- editBox:SetScript('OnEditFocusLost', function(self)
- if self:GetNumber() == 0 then
- self:SetText(0)
- end
- end)
- editBox:SetScript('OnEnterPressed', function(self)
- self:ClearFocus()
- end)
- editBox.title = editBox:CreateFontString(nil, "OVERLAY", "GameFontNormal")
- editBox.title:SetText(name)
- editBox.PosNeg = CreateFrame("Button", editBox:GetName().."PosNeg", editBox, "UIMenuButtonStretchTemplate")
- editBox.PosNeg:SetSize(30, 20)
- editBox.PosNeg:SetPoint("Right", editBox, "Left", -2, -0)
- editBox.PosNeg:SetText("+")
- editBox.PosNeg:SetNormalFontObject("GameFontNormalLarge")
- editBox.PosNeg.tooltipText = "Click to set positive or negative."
- editBox.PosNeg:SetScript("OnClick", function(self)
- if editBox.mod > 0 then
- editBox.mod = -1
- self:SetText("-")
- else
- editBox.mod = 1
- self:SetText("+")
- end
- editBox.AcquireText(editBox:GetNumber() * editBox.mod)
- end)
- local prev = parent.prevEditBox
- if prev then
- editBox:SetPoint("Top", prev,"Bottom", 0, -10)
- editBox.title:SetPoint("TopLeft", prev.title, "TopLeft", 0, -30)
- else
- editBox:SetPoint("TopLeft", 102, -53)
- editBox.title:SetPoint("TopLeft", parent, 20, -56)
- end
- editBox.title:SetJustifyH("LEFT")
- editBox.title:SetJustifyV("LEFT")
- parent.prevEditBox = editBox
- return editBox
- end
- local prevDrop
- local NewDropDownMenu = function(name, parent, title, items)
- if _G[name] then
- return _G[name]
- end
- local drop = CreateFrame("Button", name, rds.Opts, "UIDropDownMenuTemplate")
- drop:ClearAllPoints()
- drop:Show()
- drop.text = rds.Opts:CreateFontString(nil, "OVERLAY", "GameFontNormal")
- drop.text:SetPoint("BottomLeft", drop,"TopLeft",0, 0)
- drop.text:SetText(title)
- local function OnClick(self)
- UIDropDownMenu_SetSelectedID(drop, self:GetID())
- drop.OnClick(self.value)
- end
- local function initialize(self, level)
- local info = UIDropDownMenu_CreateInfo()
- for k,v in pairs(items) do
- info = UIDropDownMenu_CreateInfo()
- info.text = v
- info.value = v
- info.func = OnClick
- UIDropDownMenu_AddButton(info, level)
- end
- end
- UIDropDownMenu_Initialize(drop, initialize)
- UIDropDownMenu_SetWidth(drop, 160);
- UIDropDownMenu_SetButtonWidth(drop, 160)
- UIDropDownMenu_SetSelectedID(drop, 1)
- UIDropDownMenu_JustifyText(drop, "LEFT")
- local prev = prevDrop
- if prev then
- drop:SetPoint("Top", prev,"Bottom", 0 ,-17)
- else
- drop:SetPoint("TopLeft", rds.Opts,"TopLeft", 155, -47)
- end
- prevDrop = drop
- drop.StrengthValue = 0
- drop.ParryValue = 0
- drop.DodgeValue = 0
- drop.MasteryValue = 0
- drop.BuffValue = 1
- return drop
- end
- function rds.Opts.Load()
- rds.Opts:Hide()
- rds.Opts:SetPoint("TopRight", CharacterFrame, 380,-10)
- rds.Opts:SetSize(370, 260)
- rds.Opts.title = rds.Opts:CreateFontString(nil, "OVERLAY", "GameFontNormalLarge")
- rds.Opts.title:SetPoint("TopLeft", 110 ,-2)
- rds.Opts.title:SetText(HIGHLIGHT_FONT_COLOR_CODE..format(PAPERDOLLFRAME_TOOLTIP_FORMAT, "Raid Defense Stats")..FONT_COLOR_CODE_CLOSE)
- local f = CreateFrame("Button", rds.Opts:GetName().."Mini", CharacterStatsPane,"UIPanelButtonTemplate")
- f:SetSize(32, 32)
- f:SetPoint("TopRight", CharacterFrame, -150, -29)
- f:SetScript("OnEnter", function() f:ShowButtonTooltip() end)
- f:SetScript("OnLeave", function() f:HideButtonTooltip() end)
- f:SetScript("OnClick", function(self)
- PlaySound("igCharacterInfoTab")
- ToggleFrame(rds.Opts)
- end)
- function f:ShowButtonTooltip()
- GameTooltip:SetOwner(f, "ANCHOR_TOPRIGHT", 152,2 )
- GameTooltip:AddLine(HIGHLIGHT_FONT_COLOR_CODE..format(PAPERDOLLFRAME_TOOLTIP_FORMAT, "Raid Defense Stats")..FONT_COLOR_CODE_CLOSE)
- GameTooltip:Show()
- end
- function f:HideButtonTooltip()
- GameTooltip:Hide()
- end
- SLASH_RDS1 = "/rds";
- SlashCmdList["RDS"] = function(msg)
- rds_SlashCommandHandler(msg);
- end
- function rds_SlashCommandHandler(msg)
- PlaySound("igCharacterInfoTab")
- ToggleFrame(rds.Opts)
- end
- f:SetNormalTexture("Interface\\Icons\\INV_Shield_06")
- f:SetPushedTexture("Interface\\Icons\\INV_Shield_06")
- f:SetHighlightTexture("Interface\\Icons\\INV_Shield_06")
- f:GetNormalTexture():SetTexCoord(0, 1, 0, 1)
- f:GetPushedTexture():SetTexCoord(0, 1, 0, 1)
- f:GetHighlightTexture():SetTexCoord(0, 1, 0, 1)
- f:GetNormalTexture():SetBlendMode("DISABLE")
- f:GetPushedTexture():SetBlendMode("DISABLE")
- f:GetHighlightTexture():SetBlendMode("DISABLE")
- rds.Opts:UnregisterEvent("PLAYER_ENTERING_WORLD")
- NewEditbox("Strength").AcquireText = function(number)
- StrengthAdjust = number --These numbers are updated as you type.
- PAPERDOLL_STATINFO["TOTALAVOIDANCE"].updateFunc(Frame1, "player")
- PAPERDOLL_STATINFO["COMBATTABLE"].updateFunc(Frame2, "player")
- end
- NewEditbox("Dodge").AcquireText = function(number)
- DodgeAdjust = number
- PAPERDOLL_STATINFO["TOTALAVOIDANCE"].updateFunc(Frame1, "player")
- PAPERDOLL_STATINFO["COMBATTABLE"].updateFunc(Frame2, "player")
- end
- NewEditbox("Parry").AcquireText = function(number)
- ParryAdjust = number
- PAPERDOLL_STATINFO["TOTALAVOIDANCE"].updateFunc(Frame1, "player")
- PAPERDOLL_STATINFO["COMBATTABLE"].updateFunc(Frame2, "player")
- end
- NewEditbox("Mastery").AcquireText = function(number)
- MasteryAdjust = number
- PAPERDOLL_STATINFO["TOTALAVOIDANCE"].updateFunc(Frame1, "player")
- PAPERDOLL_STATINFO["COMBATTABLE"].updateFunc(Frame2, "player")
- end
- rds.Opts.text = rds.Opts:CreateFontString(nil, "OVERLAY", "GameFontNormal")
- rds.Opts.text:SetPoint("BottomLeft", 20 ,10)
- rds.Opts.text:SetText("The values are updated as you type or select a Buff.\nPlease ensure you have none of these Buffs present\nwhen using this:\nHorn of Winter/Battle Shout\nKings/GOTW\nWell Fed.")
- local food, strength, stat
- local function UpdateBuffStats()
- BuffStrengthAdjust = strength.StrengthValue + food.StrengthValue
- BuffParryAdjust = food.ParryValue
- BuffDodgeAdjust = food.DodgeValue
- BuffMasteryAdjust = food.MasteryValue
- BuffMultiplierAdjust = stat.BuffValue
- PAPERDOLL_STATINFO["TOTALAVOIDANCE"].updateFunc(Frame1, "player")
- PAPERDOLL_STATINFO["COMBATTABLE"].updateFunc(Frame2, "player")
- end
- --Start of foodbuffs dropdown
- food = NewDropDownMenu("FoodBuffs", rds.Opts, " Select the Food you use in a Raid.", {
- "None",
- "Beer-Basted Crocolisk",
- "Mushroom Sauce Mudfish",
- "Fortune Cookie",
- "Seafood Magnifique Feast",
- "Blackbelly Sushi",
- "Lavascale Minestrone",
- })
- food.OnClick = function(buff)
- if buff == "None" then
- food.StrengthValue = 0
- food.ParryValue = 0
- food.DodgeValue = 0
- food.MasteryValue = 0
- food.BuffValue = 0
- elseif buff == "Beer-Basted Crocolisk" then
- food.StrengthValue = 90
- food.ParryValue = 0
- food.DodgeValue = 0
- food.MasteryValue = 0
- food.BuffValue = 0
- elseif buff == "Mushroom Sauce Mudfish" then
- food.StrengthValue = 0
- food.ParryValue = 0
- food.DodgeValue = 90
- food.MasteryValue = 0
- food.BuffValue = 0
- elseif buff == "Fortune Cookie" then
- food.StrengthValue = 0
- food.ParryValue = 0
- food.DodgeValue = 90
- food.MasteryValue = 0
- food.BuffValue = 0
- elseif buff == "Seafood Magnifique Feast" then
- food.StrengthValue = 0
- food.ParryValue = 0
- food.DodgeValue = 90
- food.MasteryValue = 0
- food.BuffValue = 0
- elseif buff == "Blackbelly Sushi" then
- food.StrengthValue = 0
- food.ParryValue = 90
- food.DodgeValue = 0
- food.MasteryValue = 0
- food.BuffValue = 0
- elseif buff == "Lavascale Minestrone" then
- food.StrengthValue = 0
- food.ParryValue = 0
- food.DodgeValue = 0
- food.MasteryValue = 90
- food.BuffValue = 0
- end
- UpdateBuffStats()
- end
- --End of FoodBuffs dropdown
- --Start of StrengthBuffs dropdown
- strength = NewDropDownMenu("StrengthBuffs", rds.Opts, " Select Strength Buffs you receive.", {
- "None",
- "Battle Shout",
- "Horn of Winter",
- })
- strength.OnClick = function(buff)
- if buff == "None" then
- strength.StrengthValue = 0
- strength.BuffValue = 0
- else
- strength.StrengthValue = 549
- strength.BuffValue = 0
- end
- UpdateBuffStats()
- end
- --End of StrengthBuffs dropdown
- -- --Start of StatBuffs dropdown
- stat = NewDropDownMenu("StatBuffs", rds.Opts, " Select Stat Buffs you receive.", {
- "None",
- "Kings",
- "Gift of the Wild",
- })
- stat.OnClick = function(buff)
- if buff == "None" then
- stat.BuffValue = 1
- else stat.BuffValue = 1.05
- end
- UpdateBuffStats()
- end
- -- --End of StatBuffs dropdown
- end
- rds.frame = CreateFrame("Frame")
- rds.frame:RegisterEvent("ADDON_LOADED")
- rds.frame:SetScript("OnEvent", onEvent)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement