From 437d61724434a313e1661f0071f04bf3e44c6715 Mon Sep 17 00:00:00 2001 From: "Ashley (CuteOne)" Date: Sat, 11 May 2024 14:57:22 -0400 Subject: [PATCH] System - More Cleanup and Fixes --- .gitignore | 1 + BadRotations.toc | 27 +- Libs/DiesalGUI-1.0/DiesalGUI-1.0.lua | 204 +++--- Libs/DiesalStyle-1.0/DiesalStyle-1.0.lua | 604 ++++++++++-------- Libs/LibStub/LibStub.lua | 23 +- System/Functions/Cast.lua | 536 +++++++++------- System/Functions/Combat.lua | 49 +- System/Functions/Item.lua | 4 +- System/Functions/Misc.lua | 112 ++-- System/Functions/Range.lua | 197 +++--- System/Loader/cBuilder.lua | 12 +- System/LootManager.lua | 20 +- .../ProfessionHelper/ProfessionHelper.lua | 205 +++--- System/Unlockers.lua | 13 +- System/engines/EnemiesEngine.lua | 76 ++- System/engines/EnemiesEngineFunctions.lua | 2 +- System/ui/ui.lua | 11 +- 17 files changed, 1168 insertions(+), 928 deletions(-) diff --git a/.gitignore b/.gitignore index 91b98fa61..5ca421cc1 100644 --- a/.gitignore +++ b/.gitignore @@ -34,5 +34,6 @@ Rotations/Test Settings/* Unlockers/mmb.lua Unlockers/daemonic.lua +Unlockers/icc.lua Rotations/Rogue/Outlaw/OutlawRavens\.lua .DS_Store \ No newline at end of file diff --git a/BadRotations.toc b/BadRotations.toc index 2ce60e649..117a9b8be 100644 --- a/BadRotations.toc +++ b/BadRotations.toc @@ -3,6 +3,8 @@ ## Notes: |cffa330c9By CuteOne. ## Author: CuteOne ## Version: 1.36.0 +## Dependencies: SharedMedia +## Enabled: true ## Libs @@ -16,8 +18,27 @@ Libs\LibSharedMedia-3.0\LibSharedMedia-3.0.lua Libs\DiesalTools-1.0\DiesalTools-1.0.lua Libs\DiesalStyle-1.0\DiesalStyle-1.0.lua -Libs\DiesalGUI-1.0\DiesalGUI-1.0.xml -Libs\DiesalMenu-1.0\DiesalMenu-1.0.xml +Libs\DiesalGUI-1.0\DiesalGUI-1.0.lua +Libs\DiesalGUI-1.0\Objects\Window.lua +Libs\DiesalGUI-1.0\Objects\ScrollFrame.lua +Libs\DiesalGUI-1.0\Objects\ScrollingEditBox.lua +Libs\DiesalGUI-1.0\Objects\ScrollingMessageFrame.lua +Libs\DiesalGUI-1.0\Objects\CheckBox.lua +Libs\DiesalGUI-1.0\Objects\Button.lua +Libs\DiesalGUI-1.0\Objects\Spinner.lua +Libs\DiesalGUI-1.0\Objects\Input.lua +Libs\DiesalGUI-1.0\Objects\DropDown.lua +Libs\DiesalGUI-1.0\Objects\DropDownItem.lua +Libs\DiesalGUI-1.0\Objects\ComboBox.lua +Libs\DiesalGUI-1.0\Objects\ComboBoxItem.lua +Libs\DiesalGUI-1.0\Objects\Accordian.lua +Libs\DiesalGUI-1.0\Objects\AccordianSection.lua +Libs\DiesalGUI-1.0\Objects\Tree.lua +Libs\DiesalGUI-1.0\Objects\Branch.lua +Libs\DiesalGUI-1.0\Objects\Bar.lua +Libs\DiesalMenu-1.0\DiesalMenu-1.0.lua +Libs\DiesalMenu-1.0\Objects\Menu.lua +Libs\DiesalMenu-1.0\Objects\MenuItem.lua Libs\DiesalLibs.lua @@ -327,4 +348,4 @@ System\Updater.lua # exports.lua # ## Updater -------------------------------------------- -# System\Updater.lua +# System\Updater.lua \ No newline at end of file diff --git a/Libs/DiesalGUI-1.0/DiesalGUI-1.0.lua b/Libs/DiesalGUI-1.0/DiesalGUI-1.0.lua index 8ce1250fe..96bc3ae86 100644 --- a/Libs/DiesalGUI-1.0/DiesalGUI-1.0.lua +++ b/Libs/DiesalGUI-1.0/DiesalGUI-1.0.lua @@ -3,36 +3,36 @@ local MAJOR, MINOR = "DiesalGUI-1.0", "$Rev: 61 $" local DiesalGUI, oldminor = LibStub:NewLibrary(MAJOR, MINOR) if not DiesalGUI then return end -- No Upgrade needed. -- ~~| Libraries |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -local CallbackHandler = LibStub("CallbackHandler-1.0") -local DiesalTools = LibStub("DiesalTools-1.0") -local DiesalStyle = LibStub("DiesalStyle-1.0") +local CallbackHandler = LibStub("CallbackHandler-1.0") +local DiesalTools = LibStub("DiesalTools-1.0") +local DiesalStyle = LibStub("DiesalStyle-1.0") -- ~~| Lua Upvalues |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -local type, select, tonumber = type, select, tonumber -local setmetatable, getmetatable, next = setmetatable, getmetatable, next -local pairs, ipairs = pairs,ipairs -local tinsert, tremove = table.insert, table.remove +local type, select, tonumber = type, select, tonumber +local setmetatable, getmetatable, next = setmetatable, getmetatable, next +local pairs, ipairs = pairs, ipairs +local tinsert, tremove = table.insert, table.remove -- ~~| WoW Upvalues |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -local CreateFrame, UIParent = CreateFrame, UIParent +local CreateFrame, UIParent = CreateFrame, UIParent -- ~~| DiesalGUI Values |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -DiesalGUI.callbacks = DiesalGUI.callbacks or CallbackHandler:New(DiesalGUI) -DiesalGUI.ObjectFactory = DiesalGUI.ObjectFactory or {} -DiesalGUI.ObjectVersions = DiesalGUI.ObjectVersions or {} -DiesalGUI.ObjectPool = DiesalGUI.ObjectPool or {} -DiesalGUI.ObjectBase = DiesalGUI.ObjectBase or {} +DiesalGUI.callbacks = DiesalGUI.callbacks or CallbackHandler:New(DiesalGUI) +DiesalGUI.ObjectFactory = DiesalGUI.ObjectFactory or {} +DiesalGUI.ObjectVersions = DiesalGUI.ObjectVersions or {} +DiesalGUI.ObjectPool = DiesalGUI.ObjectPool or {} +DiesalGUI.ObjectBase = DiesalGUI.ObjectBase or {} -- ~~| DiesalGUI Upvalues |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -local ObjectFactory = DiesalGUI.ObjectFactory -local ObjectVersions = DiesalGUI.ObjectVersions -local ObjectPool = DiesalGUI.ObjectPool -local ObjectBase = DiesalGUI.ObjectBase +local ObjectFactory = DiesalGUI.ObjectFactory +local ObjectVersions = DiesalGUI.ObjectVersions +local ObjectPool = DiesalGUI.ObjectPool +local ObjectBase = DiesalGUI.ObjectBase -- ~~| DiesalGUI Local Methods |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -local function OnMouse(frame,button) +local function OnMouse(frame, button) DiesalGUI:ClearFocus() end -- capture mouse clicks on the WorldFrame -local function WorldFrameOnMouse(frame,button) - OnMouse(frame,button) +local function WorldFrameOnMouse(frame, button) + OnMouse(frame, button) end -_G.WorldFrame:HookScript("OnMouseDown", WorldFrameOnMouse ) +_G.WorldFrame:HookScript("OnMouseDown", WorldFrameOnMouse) -- Returns a new object local function newObject(objectType) if not ObjectFactory[objectType] then error("Attempt to construct unknown Object type", 2) end @@ -49,7 +49,7 @@ local function newObject(objectType) return newObj end -- Releases an object into ReleasedObjects -local function releaseObject(obj,objectType) +local function releaseObject(obj, objectType) ObjectPool[objectType] = ObjectPool[objectType] or {} if ObjectPool[objectType][obj] then @@ -73,22 +73,22 @@ end ObjectBase.SetWidth = function(self, width) self.settings.width = width self.frame:SetWidth(width) - self:FireEvent("OnWidthSet",width) + self:FireEvent("OnWidthSet", width) end ObjectBase.SetHeight = function(self, height) self.settings.height = height self.frame:SetHeight(height) - self:FireEvent("OnHeightSet",height) + self:FireEvent("OnHeightSet", height) end ObjectBase.SetSize = function(self, width, height) - self.settings.width = width + self.settings.width = width self.settings.height = height self.frame:SetHeight(height) - self.frame:SetWidth(width) + self.frame:SetWidth(width) - self:FireEvent("OnWidthSet",width) - self:FireEvent("OnHeightSet",height) + self:FireEvent("OnWidthSet", width) + self:FireEvent("OnHeightSet", height) end ObjectBase.GetWidth = function(self) return self.frame:GetWidth() @@ -118,7 +118,7 @@ ObjectBase.GetPoint = function(self, ...) return self.frame:GetPoint(...) end -- ~~| Object Diesal Base |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -ObjectBase.CreateRegion = function(self,regionType,regionName,parentRegion,defaultFontObject) +ObjectBase.CreateRegion = function(self, regionType, regionName, parentRegion, defaultFontObject) if regionType == 'FontString' then local fontString = parentRegion:CreateFontString() -- set Default font properties @@ -140,7 +140,7 @@ ObjectBase.CreateRegion = function(self,regionType,regionName,parentRegion,defau return self[regionName] end if regionType == 'EditBox' then - local editBox = CreateFrame(regionType,nil,parentRegion) + local editBox = CreateFrame(regionType, nil, parentRegion) -- set Default font properties if defaultFontObject then editBox.defaultFontObject = defaultFontObject @@ -150,14 +150,16 @@ ObjectBase.CreateRegion = function(self,regionType,regionName,parentRegion,defau editBox:SetFont(editBox.defaultFontObject:GetFont()) editBox:SetTextColor(editBox.defaultFontObject:GetTextColor()) editBox:SetSpacing(editBox.defaultFontObject:GetSpacing()) - editBox:HookScript('OnEscapePressed', function(this) DiesalGUI:ClearFocus(); end) - editBox:HookScript('OnEditFocusGained',function(this) DiesalGUI:SetFocus(this); GameTooltip:Hide(); end) + editBox:HookScript('OnEscapePressed', function(this) DiesalGUI:ClearFocus(); end) + editBox:HookScript('OnEditFocusGained', function(this) + DiesalGUI:SetFocus(this); GameTooltip:Hide(); + end) self[regionName] = editBox return editBox end if regionType == 'ScrollingMessageFrame' then - local srollingMessageFrame = CreateFrame(regionType,nil,parentRegion) + local srollingMessageFrame = CreateFrame(regionType, nil, parentRegion) -- set Default font properties if defaultFontObject then srollingMessageFrame.defaultFontObject = defaultFontObject @@ -172,11 +174,11 @@ ObjectBase.CreateRegion = function(self,regionType,regionName,parentRegion,defau return srollingMessageFrame end - self[regionName] = CreateFrame(regionType,nil,parentRegion) + self[regionName] = CreateFrame(regionType, nil, parentRegion) return self[regionName] end ObjectBase.ResetFonts = function(self) - for name,fontString in pairs(self.fontStrings) do + for name, fontString in pairs(self.fontStrings) do fontString:SetFont(fontString.defaultFontObject:GetFont()) fontString:SetTextColor(fontString.defaultFontObject:GetTextColor()) fontString:SetSpacing(fontString.defaultFontObject:GetSpacing()) @@ -185,19 +187,20 @@ end ObjectBase.AddChild = function(self, object) tinsert(self.children, object) end -ObjectBase.ReleaseChild = function(self,object) +ObjectBase.ReleaseChild = function(self, object) local children = self.children - for i = 1,#children do + for i = 1, #children do if children[i] == object then children[i]:Release() - tremove(children,i) - break end + tremove(children, i) + break + end end end ObjectBase.ReleaseChildren = function(self) local children = self.children - for i = 1,#children do + for i = 1, #children do children[i]:Release() children[i] = nil end @@ -211,17 +214,17 @@ ObjectBase.SetParentObject = function(self, parent) frame:SetParent(nil) frame:SetParent(parent.content) - settings.parent = parent.content - settings.parentObject = parent + settings.parent = parent.content + settings.parentObject = parent end -ObjectBase.SetSettings = function(self,settings,apply) - for key,value in pairs(settings) do +ObjectBase.SetSettings = function(self, settings, apply) + for key, value in pairs(settings) do self.settings[key] = value end if apply then self:ApplySettings() end end -ObjectBase.ResetSettings = function(self,apply) - self.settings = DiesalTools.TableCopy( self.defaults ) +ObjectBase.ResetSettings = function(self, apply) + self.settings = DiesalTools.TableCopy(self.defaults) if apply then self:ApplySettings() end end ObjectBase.SetEventListener = function(self, event, listener) @@ -238,24 +241,24 @@ ObjectBase.ResetEventListeners = function(self) end ObjectBase.FireEvent = function(self, event, ...) if self.eventListeners[event] then - return self.eventListeners[event]( self, event, ...) + return self.eventListeners[event](self, event, ...) end end -ObjectBase.SetStyle = function(self,name,style) - DiesalStyle:SetObjectStyle(self,name,style) +ObjectBase.SetStyle = function(self, name, style) + DiesalStyle:SetObjectStyle(self, name, style) end -ObjectBase.UpdateStyle = function(self,name,style) - DiesalStyle:UpdateObjectStyle(self,name,style) +ObjectBase.UpdateStyle = function(self, name, style) + DiesalStyle:UpdateObjectStyle(self, name, style) end -ObjectBase.UpdateStylesheet = function(self,Stylesheet) - DiesalStyle:UpdateObjectStylesheet(self,Stylesheet) +ObjectBase.UpdateStylesheet = function(self, Stylesheet) + DiesalStyle:UpdateObjectStylesheet(self, Stylesheet) end -ObjectBase.SetStylesheet = function(self,Stylesheet) - DiesalStyle:SetObjectStylesheet(self,Stylesheet) +ObjectBase.SetStylesheet = function(self, Stylesheet) + DiesalStyle:SetObjectStylesheet(self, Stylesheet) end -ObjectBase.ReleaseTexture = function(self,name) +ObjectBase.ReleaseTexture = function(self, name) if not self.textures[name] then return end - DiesalStyle:ReleaseTexture(self,name) + DiesalStyle:ReleaseTexture(self, name) end ObjectBase.ReleaseTextures = function(self) DiesalStyle:ReleaseTextures(self) @@ -264,15 +267,16 @@ end -- Returns an Object Base function DiesalGUI:CreateObjectBase(Type) local object = { - type = Type, - fontStrings = {}, - textures = {}, - children = {}, - eventListeners = {}, + type = Type, + fontStrings = {}, + textures = {}, + children = {}, + eventListeners = {}, } - setmetatable(object, {__index = ObjectBase}) + setmetatable(object, { __index = ObjectBase }) return object end + -- Registers an Object constructor in the ObjectFactory function DiesalGUI:RegisterObjectConstructor(Type, constructor, version) assert(type(constructor) == "function") @@ -282,10 +286,11 @@ function DiesalGUI:RegisterObjectConstructor(Type, constructor, version) if oldVersion and oldVersion >= version then return end ObjectVersions[Type] = version - ObjectFactory[Type] = constructor + ObjectFactory[Type] = constructor end + -- Create a new Object -function DiesalGUI:Create(objectType,name) +function DiesalGUI:Create(objectType, name) if ObjectFactory[objectType] then local object if name then -- needs a specific name, bypass the objectPool and create a new object @@ -301,40 +306,41 @@ function DiesalGUI:Create(objectType,name) end function DiesalGUI:CreateThrottle(duration, callback) - assert(callback and type(callback) == 'function','callback has to be a function ') - assert(duration and type(duration) == 'number','duration has to be a number ') + assert(callback and type(callback) == 'function', 'callback has to be a function ') + assert(duration and type(duration) == 'number', 'duration has to be a number ') - local throttle = CreateFrame("Frame", nil, UIParent):CreateAnimationGroup() - throttle.anim = throttle:CreateAnimation("Animation") - throttle.args = {} - local mt = getmetatable(throttle) - mt.__index.SetCallback = function(self,callback) - assert(callback and type(callback) == 'function','callback required to be a function ') - self:SetScript("OnFinished", function() callback(unpack(self.args)) end) - end - mt.__index.AddCallback = function(self,callback) - assert(callback and type(callback) == 'function','callback required to be a function ') - self:HookScript("OnFinished", function() callback(unpack(self.args)) end) - end - mt.__index.SetDuration = function(self,duration) - assert(duration and type(duration) == 'number','duration has to be a number ') - self.anim:SetDuration(duration) - end - mt.__call = function(self,...) - self.args = {...} - self:Stop() - self:Play() - end - setmetatable(throttle,mt) + local throttle = CreateFrame("Frame", nil, UIParent):CreateAnimationGroup() + throttle.anim = throttle:CreateAnimation("Animation") + throttle.args = {} + local mt = getmetatable(throttle) + mt.__index.SetCallback = function(self, callback) + assert(callback and type(callback) == 'function', 'callback required to be a function ') + self:SetScript("OnFinished", function() callback(unpack(self.args)) end) + end + mt.__index.AddCallback = function(self, callback) + assert(callback and type(callback) == 'function', 'callback required to be a function ') + self:HookScript("OnFinished", function() callback(unpack(self.args)) end) + end + mt.__index.SetDuration = function(self, duration) + assert(duration and type(duration) == 'number', 'duration has to be a number ') + self.anim:SetDuration(duration) + end + mt.__call = function(self, ...) + self.args = { ... } + self:Stop() + self:Play() + end + setmetatable(throttle, mt) - throttle:SetScript("OnFinished", function() callback(unpack(throttle.args)) end) - throttle:SetDuration(duration) + throttle:SetScript("OnFinished", function() callback(unpack(throttle.args)) end) + throttle:SetDuration(duration) - return throttle + return throttle end + -- Releases an object ready for reuse by Create function DiesalGUI:Release(object) - if object.OnRelease then object:OnRelease() end + if object.OnRelease then object:OnRelease() end object:FireEvent("OnRelease") object:ReleaseChildren() @@ -347,25 +353,28 @@ function DiesalGUI:Release(object) object.frame:SetParent(UIParent) releaseObject(object, object.type) end + -- Set FocusedObject: Menu, Dropdown, editBox etc.... function DiesalGUI:SetFocus(object) - if self.FocusedObject and self.FocusedObject ~= object then DiesalGUI:ClearFocus() end + if self.FocusedObject and self.FocusedObject ~= object then DiesalGUI:ClearFocus() end self.FocusedObject = object end + -- clear focus from the FocusedObject function DiesalGUI:ClearFocus() local FocusedObject = self.FocusedObject if FocusedObject then - if FocusedObject.ClearFocus then -- FocusedObject is Focusable Frame + if FocusedObject.ClearFocus then -- FocusedObject is Focusable Frame FocusedObject:ClearFocus() end self.FocusedObject = nil end end + -- Mouse Input capture for any DiesalGUI interactive region -function DiesalGUI:OnMouse(frame,button) +function DiesalGUI:OnMouse(frame, button) -- print(button) - OnMouse(frame,button) + OnMouse(frame, button) DiesalGUI.callbacks:Fire("DiesalGUI_OnMouse", frame, button) end @@ -378,6 +387,7 @@ function DiesalGUI:GetNextObjectNum(type) self.counts[type] = self.counts[type] + 1 return self.counts[type] end + --- Return the number of created widgets for this type. function DiesalGUI:GetObjectCount(type) return self.counts[type] or 0 diff --git a/Libs/DiesalStyle-1.0/DiesalStyle-1.0.lua b/Libs/DiesalStyle-1.0/DiesalStyle-1.0.lua index 0ec0a617e..666f4c287 100644 --- a/Libs/DiesalStyle-1.0/DiesalStyle-1.0.lua +++ b/Libs/DiesalStyle-1.0/DiesalStyle-1.0.lua @@ -29,22 +29,29 @@ local Media = DiesalStyle.Media local Colors = DiesalStyle.Colors local Formatters = DiesalStyle.Formatters -- ~~| Locals |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -local OUTLINES = {'_LEFT','_RIGHT','_TOP','_BOTTOM'} -local MEDIA_PATH = type(AddonName) ~= 'string' and string.format("Interface\\AddOns\\Media\\") - or AddonName == 'DiesalLibs' and string.format("Interface\\AddOns\\%s\\%s\\Media\\",AddonName,MAJOR) - or string.format("Interface\\AddOns\\%s\\Libs\\%s\\Media\\",AddonName,MAJOR) +local OUTLINES = { '_LEFT', '_RIGHT', '_TOP', '_BOTTOM' } +local MEDIA_PATH = AddonName == 'BadRotations' and string.format("Interface\\AddOns\\Media\\") + or type(AddonName) ~= 'string' and string.format("Interface\\AddOns\\Media\\") + or AddonName == 'DiesalLibs' and string.format("Interface\\AddOns\\%s\\%s\\Media\\", AddonName, MAJOR) + or string.format("Interface\\AddOns\\%s\\Libs\\%s\\Media\\", AddonName, MAJOR) local DEFAULT_COLOR = 'FFFFFF' local DEFAULT_GRADIENT_ORIENTATION = 'horizontal' local DEFAULT_LAYER = 'ARTWORK' -- ~~| Local Methods |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -local function addMedia(mediaType,name,mediaFile) +local function addMedia(mediaType, name, mediaFile) Media[mediaType] = Media[mediaType] or {} -- update or create new media entry - Media[mediaType][name] = MEDIA_PATH..mediaFile + Media[mediaType][name] = MEDIA_PATH .. mediaFile end -local function getMedia(mediaType,name) - if not Media[mediaType] then error('media type: '..mediaType..' does not exist',2) return end - if not Media[mediaType][name] then error('media: "'..name..'" does not exist',2) return end +local function getMedia(mediaType, name) + if not Media[mediaType] then + error('media type: ' .. mediaType .. ' does not exist', 2) + return + end + if not Media[mediaType][name] then + error('media: "' .. name .. '" does not exist', 2) + return + end return Media[mediaType][name] end local function newTexture() @@ -76,23 +83,24 @@ local function releaseTexture(texture) ReleasedTextures[texture] = true end local function round(number, base) - base = base or 1 - return floor((number + base/2)/base) * base + base = base or 1 + return floor((number + base / 2) / base) * base end local function GetBlizzColorValues(value) - if not value then return end + if not value then return end - if type(value) == 'table' and #value >= 3 then - return value[1]/255, value[2]/255, value[3]/255 - elseif type(value) == 'string' then - return tonumber(sub(value,1,2),16)/255, tonumber(sub(value,3,4),16)/255, tonumber(sub(value,5,6),16)/255 - end + if type(value) == 'table' and #value >= 3 then + return value[1] / 255, value[2] / 255, value[3] / 255 + elseif type(value) == 'string' then + return tonumber(sub(value, 1, 2), 16) / 255, tonumber(sub(value, 3, 4), 16) / 255, tonumber(sub(value, 5, 6), 16) / + 255 + end end local function formatCoords(coords) if type(coords) ~= 'table' then return end if #coords == 5 then - return {GetIconCoords(coords[1],coords[2],coords[3],coords[4],coords[5])} + return { GetIconCoords(coords[1], coords[2], coords[3], coords[4], coords[5]) } else return coords end @@ -105,7 +113,7 @@ end local function formatPosition(position) if type(position) ~= 'table' and type(position) ~= 'number' then return end - return type(position) == 'number' and {position,position,position,position} or position + return type(position) == 'number' and { position, position, position, position } or position end local function formatOrientation(orientation) if type(orientation) ~= 'string' then return end @@ -115,10 +123,10 @@ end local function formatAlpha(alpha) if type(alpha) ~= 'table' and type(alpha) ~= 'number' then return end - return type(alpha) == 'number' and {alpha,alpha} or alpha + return type(alpha) == 'number' and { alpha, alpha } or alpha end -local function CreateColor(r,g,b,a) +local function CreateColor(r, g, b, a) return { r = r or 0, g = g or 0, @@ -129,15 +137,22 @@ end -- error handling local function setColor(texture, r, g, b, a) - local status, err = pcall( texture.SetColorTexture, texture, r, g, b, a ) - if not status then errorhandler('error in "'..(texture.style.name or 'texture')..'" '..texture.style.mode..' or alpha setting',r, g, b, a) end + local status, err = pcall(texture.SetColorTexture, texture, r, g, b, a) + if not status then + errorhandler( + 'error in "' .. (texture.style.name or 'texture') .. '" ' .. texture.style.mode .. ' or alpha setting', r, g, b, a) + end end local function setGradient(texture, orientation, r1, g1, b1, a1, r2, g2, b2, a2) - local status, err = pcall( texture.SetGradient, texture, orientation, CreateColor(r1, g1, b1, a1), CreateColor(r2, g2, b2, a2) ) - if not status then errorhandler('error in "'..(texture.style.name or 'texture')..'" '..texture.style.mode..' or alpha setting.') end + local status, err = pcall(texture.SetGradient, texture, orientation, CreateColor(r1, g1, b1, a1), + CreateColor(r2, g2, b2, a2)) + if not status then + errorhandler('error in "' .. + (texture.style.name or 'texture') .. '" ' .. texture.style.mode .. ' or alpha setting.') + end end -- ~~| Media |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -do -- | Set Colors |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +do -- | Set Colors |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ do -- google material colors Colors.red_50 = 'fde0dc' Colors.red_100 = 'f9bdbb' @@ -395,106 +410,104 @@ do -- | Set Colors |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Colors.blue_gray_900 = '263238' end do -- Base UI Colors - - Colors.UI_Hue = 210 + Colors.UI_Hue = 210 Colors.UI_Saturation = .24 - Colors.UI_TEXT = HSL(Colors.UI_Hue,Colors.UI_Saturation,.9) + Colors.UI_TEXT = HSL(Colors.UI_Hue, Colors.UI_Saturation, .9) -- level 1 - Colors.UI_100 = HSL(Colors.UI_Hue,Colors.UI_Saturation,.03) -- BG - Colors.UI_150 = HSL(Colors.UI_Hue,Colors.UI_Saturation,.05) + Colors.UI_100 = HSL(Colors.UI_Hue, Colors.UI_Saturation, .03) -- BG + Colors.UI_150 = HSL(Colors.UI_Hue, Colors.UI_Saturation, .05) -- level 2 - Colors.UI_200 = HSL(Colors.UI_Hue,Colors.UI_Saturation,.07) + Colors.UI_200 = HSL(Colors.UI_Hue, Colors.UI_Saturation, .07) -- level 3 - Colors.UI_300 = HSL(Colors.UI_Hue,Colors.UI_Saturation,.12) - Colors.UI_300_GR = {HSL(Colors.UI_Hue,Colors.UI_Saturation,.12),HSL(Colors.UI_Hue,Colors.UI_Saturation,.11)} - Colors.UI_350 = HSL(Colors.UI_Hue,Colors.UI_Saturation,.15) - Colors.UI_350_GR = {HSL(Colors.UI_Hue,Colors.UI_Saturation,.17),HSL(Colors.UI_Hue,Colors.UI_Saturation,.14)} + Colors.UI_300 = HSL(Colors.UI_Hue, Colors.UI_Saturation, .12) + Colors.UI_300_GR = { HSL(Colors.UI_Hue, Colors.UI_Saturation, .12), HSL(Colors.UI_Hue, Colors.UI_Saturation, .11) } + Colors.UI_350 = HSL(Colors.UI_Hue, Colors.UI_Saturation, .15) + Colors.UI_350_GR = { HSL(Colors.UI_Hue, Colors.UI_Saturation, .17), HSL(Colors.UI_Hue, Colors.UI_Saturation, .14) } -- level 4 - Colors.UI_400 = HSL(Colors.UI_Hue,Colors.UI_Saturation,.20) - Colors.UI_400_GR = {HSL(Colors.UI_Hue,Colors.UI_Saturation,.20),HSL(Colors.UI_Hue,Colors.UI_Saturation,.17)} - Colors.UI_450_GR = {HSL(Colors.UI_Hue,Colors.UI_Saturation,.24),HSL(Colors.UI_Hue,Colors.UI_Saturation,.20)} + Colors.UI_400 = HSL(Colors.UI_Hue, Colors.UI_Saturation, .20) + Colors.UI_400_GR = { HSL(Colors.UI_Hue, Colors.UI_Saturation, .20), HSL(Colors.UI_Hue, Colors.UI_Saturation, .17) } + Colors.UI_450_GR = { HSL(Colors.UI_Hue, Colors.UI_Saturation, .24), HSL(Colors.UI_Hue, Colors.UI_Saturation, .20) } -- level 5 - Colors.UI_500 = HSL(Colors.UI_Hue,Colors.UI_Saturation,.29) - Colors.UI_500_GR = {HSL(Colors.UI_Hue,Colors.UI_Saturation,.29),HSL(Colors.UI_Hue,Colors.UI_Saturation,.26)} + Colors.UI_500 = HSL(Colors.UI_Hue, Colors.UI_Saturation, .29) + Colors.UI_500_GR = { HSL(Colors.UI_Hue, Colors.UI_Saturation, .29), HSL(Colors.UI_Hue, Colors.UI_Saturation, .26) } - Colors.UI_600_GR = {HSL(Colors.UI_Hue,Colors.UI_Saturation,.35),HSL(Colors.UI_Hue,Colors.UI_Saturation,.32)} + Colors.UI_600_GR = { HSL(Colors.UI_Hue, Colors.UI_Saturation, .35), HSL(Colors.UI_Hue, Colors.UI_Saturation, .32) } -- font Colors -35 - Colors.UI_F450 = HSL(Colors.UI_Hue,Colors.UI_Saturation,.75) - Colors.UI_F350 = HSL(Colors.UI_Hue,Colors.UI_Saturation,.60) - - Colors.UI_1000 = HSL(Colors.UI_Hue,Colors.UI_Saturation,1) - - Colors.UI_A900 = HSL(Colors.UI_Hue,1,.7) - Colors.UI_A800 = HSL(Colors.UI_Hue,1,.65) - Colors.UI_A700 = HSL(Colors.UI_Hue,1,.6) - Colors.UI_A600 = HSL(Colors.UI_Hue,1,.55) - Colors.UI_A500 = HSL(Colors.UI_Hue,1,.5) - Colors.UI_A400 = HSL(Colors.UI_Hue,1,.45) - Colors.UI_A300 = HSL(Colors.UI_Hue,1,.4) - Colors.UI_A200 = HSL(Colors.UI_Hue,1,.35) - Colors.UI_A100 = HSL(Colors.UI_Hue,1,.3) + Colors.UI_F450 = HSL(Colors.UI_Hue, Colors.UI_Saturation, .75) + Colors.UI_F350 = HSL(Colors.UI_Hue, Colors.UI_Saturation, .60) + + Colors.UI_1000 = HSL(Colors.UI_Hue, Colors.UI_Saturation, 1) + + Colors.UI_A900 = HSL(Colors.UI_Hue, 1, .7) + Colors.UI_A800 = HSL(Colors.UI_Hue, 1, .65) + Colors.UI_A700 = HSL(Colors.UI_Hue, 1, .6) + Colors.UI_A600 = HSL(Colors.UI_Hue, 1, .55) + Colors.UI_A500 = HSL(Colors.UI_Hue, 1, .5) + Colors.UI_A400 = HSL(Colors.UI_Hue, 1, .45) + Colors.UI_A300 = HSL(Colors.UI_Hue, 1, .4) + Colors.UI_A200 = HSL(Colors.UI_Hue, 1, .35) + Colors.UI_A100 = HSL(Colors.UI_Hue, 1, .3) end end do -- | Text Formatters |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - Formatters.tooltip = '|cff'..Colors.gray_50..'%s\n|cff'..Colors.yellow_500..'%s' - + Formatters.tooltip = '|cff' .. Colors.gray_50 .. '%s\n|cff' .. Colors.yellow_500 .. '%s' end do -- | Set Media |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - addMedia('font','calibrib','calibrib.ttf') + addMedia('font', 'calibrib', 'calibrib.ttf') -- monospaced - addMedia('font','DejaVuSansMono','DejaVuSansMono.ttf') - addMedia('font','DejaVuSansMonoBold','DejaVuSansMono-Bold.ttf') + addMedia('font', 'DejaVuSansMono', 'DejaVuSansMono.ttf') + addMedia('font', 'DejaVuSansMonoBold', 'DejaVuSansMono-Bold.ttf') - addMedia('font','FiraMonoMedium','FiraMono-Medium.ttf') - addMedia('font','FiraMonoRegular','FiraMono-Regular.ttf') - addMedia('font','FiraMonoBold','FiraMono-Bold.ttf') + addMedia('font', 'FiraMonoMedium', 'FiraMono-Medium.ttf') + addMedia('font', 'FiraMonoRegular', 'FiraMono-Regular.ttf') + addMedia('font', 'FiraMonoBold', 'FiraMono-Bold.ttf') - addMedia('font','HackRegular','Hack-Regular.ttf') - addMedia('font','HackBold','Hack-Bold.ttf') + addMedia('font', 'HackRegular', 'Hack-Regular.ttf') + addMedia('font', 'HackBold', 'Hack-Bold.ttf') - addMedia('font','InconsolataRegular','Inconsolata-Regular.ttf') - addMedia('font','InconsolataBold','Inconsolata-Bold.ttf') + addMedia('font', 'InconsolataRegular', 'Inconsolata-Regular.ttf') + addMedia('font', 'InconsolataBold', 'Inconsolata-Bold.ttf') - addMedia('font','LucidiaMono','LUCON.ttf') + addMedia('font', 'LucidiaMono', 'LUCON.ttf') - addMedia('font','MonoFur','monof55.ttf') - addMedia('font','MonoFurItalic','monof56.ttf') + addMedia('font', 'MonoFur', 'monof55.ttf') + addMedia('font', 'MonoFurItalic', 'monof56.ttf') - addMedia('font','OfficeCodeProRegular','OfficeCodePro-Regular.ttf') - addMedia('font','OfficeCodeProMedium','OfficeCodePro-Medium.ttf') - addMedia('font','OfficeCodeProBold','OfficeCodePro-Bold.ttf') + addMedia('font', 'OfficeCodeProRegular', 'OfficeCodePro-Regular.ttf') + addMedia('font', 'OfficeCodeProMedium', 'OfficeCodePro-Medium.ttf') + addMedia('font', 'OfficeCodeProBold', 'OfficeCodePro-Bold.ttf') - addMedia('font','RobotoMonoRegular','RobotoMono-Regular.ttf') - addMedia('font','RobotoMonoMedium','RobotoMono-Medium.ttf') - addMedia('font','RobotoMonoBold','RobotoMono-Bold.ttf') + addMedia('font', 'RobotoMonoRegular', 'RobotoMono-Regular.ttf') + addMedia('font', 'RobotoMonoMedium', 'RobotoMono-Medium.ttf') + addMedia('font', 'RobotoMonoBold', 'RobotoMono-Bold.ttf') - addMedia('font','SourceCodeProRegular','SourceCodePro-Regular.ttf') - addMedia('font','SourceCodeProMedium','SourceCodePro-Medium.ttf') - addMedia('font','SourceCodeProSemibold','SourceCodePro-Semibold.ttf') - addMedia('font','SourceCodeProBold','SourceCodePro-Bold.ttf') - addMedia('font','SourceCodeProBlack','SourceCodePro-Black.ttf') + addMedia('font', 'SourceCodeProRegular', 'SourceCodePro-Regular.ttf') + addMedia('font', 'SourceCodeProMedium', 'SourceCodePro-Medium.ttf') + addMedia('font', 'SourceCodeProSemibold', 'SourceCodePro-Semibold.ttf') + addMedia('font', 'SourceCodeProBold', 'SourceCodePro-Bold.ttf') + addMedia('font', 'SourceCodeProBlack', 'SourceCodePro-Black.ttf') - addMedia('font','UbuntuMonoBold','UbuntuMono-B.ttf') - addMedia('font','UbuntuMonoRegular','UbuntuMono-R.ttf') + addMedia('font', 'UbuntuMonoBold', 'UbuntuMono-B.ttf') + addMedia('font', 'UbuntuMonoRegular', 'UbuntuMono-R.ttf') -- pixel fonts - addMedia('font','FiraSans','FiraSans-Regular.ttf') - addMedia('font','Standard0755','Standard0755.ttf') - addMedia('font','FFF Intelligent Thin Condensed','FFF Intelligent Thin Condensed.ttf') - addMedia('texture','DiesalGUIcons','DiesalGUIcons16x256x128.tga') - addMedia('texture','DiesalGUIcons64','DiesalGUIcons64x256x256.tga') - addMedia('texture','DiesalGUIcons32','DiesalGUIcons32x256x256.tga') - addMedia('texture','DiesalButtonIcons32','DiesalButtonIcons32x128x512.tga') - addMedia('border','shadow','shadow.tga') - addMedia('border','shadowNoDist','shadowNoDist.tga') + addMedia('font', 'FiraSans', 'FiraSans-Regular.ttf') + addMedia('font', 'Standard0755', 'Standard0755.ttf') + addMedia('font', 'FFF Intelligent Thin Condensed', 'FFF Intelligent Thin Condensed.ttf') + addMedia('texture', 'DiesalGUIcons', 'DiesalGUIcons16x256x128.tga') + addMedia('texture', 'DiesalGUIcons64', 'DiesalGUIcons64x256x256.tga') + addMedia('texture', 'DiesalGUIcons32', 'DiesalGUIcons32x256x256.tga') + addMedia('texture', 'DiesalButtonIcons32', 'DiesalButtonIcons32x128x512.tga') + addMedia('border', 'shadow', 'shadow.tga') + addMedia('border', 'shadowNoDist', 'shadowNoDist.tga') end do -- | Add LibSharedMedia |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - LibSharedMedia:Register("font","Calibri Bold",getMedia('font','calibrib')) - LibSharedMedia:Register("font","Fira Sans",getMedia('font','FiraSans')) + LibSharedMedia:Register("font", "Calibri Bold", getMedia('font', 'calibrib')) + LibSharedMedia:Register("font", "Fira Sans", getMedia('font', 'FiraSans')) -- monospaced -- LibSharedMedia:Register("font","DejaVuSansMono",getMedia('font','DejaVuSansMono')) -- LibSharedMedia:Register("font","Hack",getMedia('font','Hack')) @@ -502,19 +515,19 @@ do -- | Add LibSharedMedia |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- LibSharedMedia:Register("font","Fira Sans",getMedia('font','FiraSans')) -- LibSharedMedia:Register("font","Source Code Pro",getMedia('font','SourceCodePro')) -- pixel fonts - LibSharedMedia:Register("font","Standard0755",getMedia('font','Standard0755')) - LibSharedMedia:Register("font","FFF Intelligent",getMedia('font','FFF Intelligent Thin Condensed')) + LibSharedMedia:Register("font", "Standard0755", getMedia('font', 'Standard0755')) + LibSharedMedia:Register("font", "FFF Intelligent", getMedia('font', 'FFF Intelligent Thin Condensed')) end do -- | Set Fonts |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ CreateFont("DiesalFontNormal") - DiesalFontNormal:SetFont( getMedia('font','calibrib'),11, '' ) + DiesalFontNormal:SetFont(getMedia('font', 'calibrib'), 11, '') CreateFont("DiesalFontPixel") - DiesalFontPixel:SetFont( getMedia('font','Standard0755'), 8, '' ) + DiesalFontPixel:SetFont(getMedia('font', 'Standard0755'), 8, '') CreateFont("DiesalFontPixelOutLine") - DiesalFontPixelOutLine:SetFont( getMedia('font','Standard0755'), 8, "OUTLINE, MONOCHROME" ) + DiesalFontPixelOutLine:SetFont(getMedia('font', 'Standard0755'), 8, "OUTLINE, MONOCHROME") DiesalFontPixelOutLine:SetSpacing(2) CreateFont("DiesalFontPixel2") - DiesalFontPixel2:SetFont( getMedia('font','FFF Intelligent Thin Condensed'), 8, "OUTLINE, MONOCHROME" ) + DiesalFontPixel2:SetFont(getMedia('font', 'FFF Intelligent Thin Condensed'), 8, "OUTLINE, MONOCHROME") end -- ~~| DiesalStyle API |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --[[ Texture style table format @@ -557,18 +570,18 @@ style.height height -- -- position = 0 | {0,0,0,0} -function DiesalStyle:StyleTexture(texture,style) +function DiesalStyle:StyleTexture(texture, style) -- | Setup Texture.style |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if not texture.style or style.clear then texture.style = {} end -- debugging - texture.style.name = style.name or texture.style.name + texture.style.name = style.name or texture.style.name texture.style.debug = style.debug or texture.style.debug -- | Format Settings |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- Gradient ~~~~~~~~~~~~~~~~~~~~~~~~~ if style.gradient and type(style.gradient) == 'table' then texture.style.gradient = { orientation = formatOrientation(style.gradient[1]), - color = style.gradient[2] and style.gradient[3] and {style.gradient[2],style.gradient[3]}, + color = style.gradient[2] and style.gradient[3] and { style.gradient[2], style.gradient[3] }, } end style.gradient_orientation = formatOrientation(style.gradient_orientation) -- fuck you @@ -579,28 +592,30 @@ function DiesalStyle:StyleTexture(texture,style) file = formatFile(style.image[1]), coords = formatCoords(style.image[2]), color = style.image[3], - tiling = {style.image[4],style.image[5]}, + tiling = { style.image[4], style.image[5] }, } end if not texture.style.image and style.image_file then texture.style.image = {} end -- | Update Settings |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - texture.style.layer = style.layer or texture.style.layer or DEFAULT_LAYER - texture.style.position = formatPosition(style.position) or texture.style.position or {0,0,0,0} - texture.style.width = style.width or texture.style.width - texture.style.height = style.height or texture.style.height - texture.style.color = style.color or texture.style.color - texture.style.alpha = formatAlpha(style.alpha) or texture.style.alpha or {1,1} + texture.style.layer = style.layer or texture.style.layer or DEFAULT_LAYER + texture.style.position = formatPosition(style.position) or texture.style.position or { 0, 0, 0, 0 } + texture.style.width = style.width or texture.style.width + texture.style.height = style.height or texture.style.height + texture.style.color = style.color or texture.style.color + texture.style.alpha = formatAlpha(style.alpha) or texture.style.alpha or { 1, 1 } -- gradient if texture.style.gradient then - texture.style.gradient.orientation = style.gradient_orientation or texture.style.gradient.orientation or DEFAULT_GRADIENT_ORIENTATION - texture.style.gradient.color = style.gradient_color or texture.style.gradient.color or {DEFAULT_COLOR,DEFAULT_COLOR} + texture.style.gradient.orientation = style.gradient_orientation or texture.style.gradient.orientation or + DEFAULT_GRADIENT_ORIENTATION + texture.style.gradient.color = style.gradient_color or texture.style.gradient.color or + { DEFAULT_COLOR, DEFAULT_COLOR } end -- image if texture.style.image then - texture.style.image.file = formatFile(style.image_file) or texture.style.image.file - texture.style.image.coords = formatCoords(style.image_coords) or texture.style.image.coords or {0,1,0,1} - texture.style.image.color = style.image_color or texture.style.image.color - texture.style.image.tiling = style.image_tiling or texture.style.image.tiling + texture.style.image.file = formatFile(style.image_file) or texture.style.image.file + texture.style.image.coords = formatCoords(style.image_coords) or texture.style.image.coords or { 0, 1, 0, 1 } + texture.style.image.color = style.image_color or texture.style.image.color + texture.style.image.tiling = style.image_tiling or texture.style.image.tiling end -- | Apply Settings |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -608,86 +623,99 @@ function DiesalStyle:StyleTexture(texture,style) texture:SetDrawLayer(texture.style.layer, 0) -- position texture:ClearAllPoints() -- clear offsets - if texture.style.position[1] then texture:SetPoint("LEFT", -texture.style.position[1],0) end - if texture.style.position[2] then texture:SetPoint("RIGHT", texture.style.position[2],0) end - if texture.style.position[3] then texture:SetPoint("TOP", 0,texture.style.position[3]) end - if texture.style.position[4] then texture:SetPoint("BOTTOM", 0,-texture.style.position[4]) end + if texture.style.position[1] then texture:SetPoint("LEFT", -texture.style.position[1], 0) end + if texture.style.position[2] then texture:SetPoint("RIGHT", texture.style.position[2], 0) end + if texture.style.position[3] then texture:SetPoint("TOP", 0, texture.style.position[3]) end + if texture.style.position[4] then texture:SetPoint("BOTTOM", 0, -texture.style.position[4]) end -- size - if texture.style.width then texture:SetWidth(texture.style.width) end + if texture.style.width then texture:SetWidth(texture.style.width) end if texture.style.height then texture:SetHeight(texture.style.height) end - if style.debug then print(texture:GetHeight(),texture.style.position[1], texture.style.position[2], texture.style.position[3], texture.style.position[4]) end + if style.debug then + print(texture:GetHeight(), texture.style.position[1], texture.style.position[2], + texture.style.position[3], texture.style.position[4]) + end -- [1] Texture > [2] gradient > [3] color if texture.style.image then -- [1] Texture -- set mode texture.style.mode = 'image' -- clear any old settings - setGradient(texture,'HORIZONTAL',1,1,1,1,1,1,1,1) -- clear gradient - texture:SetColorTexture(1,1,1,1) -- clear color + setGradient(texture, 'HORIZONTAL', 1, 1, 1, 1, 1, 1, 1, 1) -- clear gradient + texture:SetColorTexture(1, 1, 1, 1) -- clear color -- apply settings - texture:SetTexCoord(texture.style.image.coords[1],texture.style.image.coords[2],texture.style.image.coords[3],texture.style.image.coords[4]) - texture:SetTexture(texture.style.image.file,texture.style.image.tiling and texture.style.image.tiling[1], texture.style.image.tiling and texture.style.image.tiling[2]) + texture:SetTexCoord(texture.style.image.coords[1], texture.style.image.coords[2], texture.style.image.coords[3], + texture.style.image.coords[4]) + texture:SetTexture(texture.style.image.file, texture.style.image.tiling and texture.style.image.tiling[1], + texture.style.image.tiling and texture.style.image.tiling[2]) texture:SetHorizTile(texture.style.image.tiling[1]) texture:SetVertTile(texture.style.image.tiling[2]) - local r,g,b = GetBlizzColorValues(texture.style.image.color) + local r, g, b = GetBlizzColorValues(texture.style.image.color) texture:SetVertexColor(r or 1, g or 1, b or 1, texture.style.alpha[1]) elseif texture.style.gradient then -- [2] gradient -- set mode texture.style.mode = 'gradient' -- clear any old settings - texture:SetTexture() -- clear image - texture:SetColorTexture(1,1,1,1) -- clear color + texture:SetTexture() -- clear image + texture:SetColorTexture(1, 1, 1, 1) -- clear color -- apply settings - local r1,g1,b1 = GetBlizzColorValues(texture.style.gradient.color[texture.style.gradient.orientation == 'HORIZONTAL' and 1 or 2]) - local r2,g2,b2 = GetBlizzColorValues(texture.style.gradient.color[texture.style.gradient.orientation == 'HORIZONTAL' and 2 or 1]) - local a1,a2 = texture.style.alpha[texture.style.gradient.orientation == 'HORIZONTAL' and 1 or 2], texture.style.alpha[texture.style.gradient.orientation == 'HORIZONTAL' and 2 or 1] + local r1, g1, b1 = GetBlizzColorValues(texture.style.gradient.color + [texture.style.gradient.orientation == 'HORIZONTAL' and 1 or 2]) + local r2, g2, b2 = GetBlizzColorValues(texture.style.gradient.color + [texture.style.gradient.orientation == 'HORIZONTAL' and 2 or 1]) + local a1, a2 = texture.style.alpha[texture.style.gradient.orientation == 'HORIZONTAL' and 1 or 2], + texture.style.alpha[texture.style.gradient.orientation == 'HORIZONTAL' and 2 or 1] setGradient(texture, texture.style.gradient.orientation, r1, g1, b1, a1, r2, g2, b2, a2) elseif texture.style.color then -- [3] color -- set mode texture.style.mode = 'color' -- clear any old settings - texture:SetTexture() -- clear image - setGradient(texture,'HORIZONTAL',1,1,1,1,1,1,1,1) -- clear gradient + texture:SetTexture() -- clear image + setGradient(texture, 'HORIZONTAL', 1, 1, 1, 1, 1, 1, 1, 1) -- clear gradient -- apply settings - local r,g,b = GetBlizzColorValues(texture.style.color) + local r, g, b = GetBlizzColorValues(texture.style.color) setColor(texture, r, g, b, texture.style.alpha[1]) else -- set mode texture.style.mode = 'none!' -- clear the texture - texture:SetTexture() -- clear image - setGradient(texture,'HORIZONTAL',0,0,0,0,0,0,0,0) -- clear gradient - texture:SetColorTexture(0,0,0,0) -- clear color + texture:SetTexture() -- clear image + setGradient(texture, 'HORIZONTAL', 0, 0, 0, 0, 0, 0, 0, 0) -- clear gradient + texture:SetColorTexture(0, 0, 0, 0) -- clear color end end -function DiesalStyle:StyleOutline(leftTexture,rightTexture,topTexture,bottomTexture,style) +function DiesalStyle:StyleOutline(leftTexture, rightTexture, topTexture, bottomTexture, style) -- | Setup Texture.style |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - if not leftTexture.style or style.clear then leftTexture.style = {}; rightTexture.style = leftTexture.style; topTexture.style = leftTexture.style; bottomTexture.style = leftTexture.style end - local texture = leftTexture + if not leftTexture.style or style.clear then + leftTexture.style = {}; rightTexture.style = leftTexture.style; topTexture.style = leftTexture.style; bottomTexture.style = + leftTexture.style + end + local texture = leftTexture -- debugging - texture.style.name = style.name or texture.style.name + texture.style.name = style.name or texture.style.name texture.style.debug = style.debug or texture.style.debug -- | Format Settings |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if style.gradient and type(style.gradient) == 'table' then texture.style.gradient = { orientation = formatOrientation(style.gradient[1]), - color = style.gradient[2] and style.gradient[3] and {style.gradient[2],style.gradient[3]}, + color = style.gradient[2] and style.gradient[3] and { style.gradient[2], style.gradient[3] }, } end style.gradient_orientation = formatOrientation(style.gradient_orientation) -- fuck you if not texture.style.gradient and (style.gradient_orientation or style.gradient_alpha or style.gradient_color) then texture.style.gradient = {} end -- | Update Settings |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - texture.style.layer = style.layer or texture.style.layer or DEFAULT_LAYER - texture.style.position = formatPosition(style.position) or texture.style.position or {0,0,0,0} - texture.style.width = style.width or texture.style.width - texture.style.height = style.height or texture.style.height - texture.style.color = style.color or texture.style.color - texture.style.alpha = formatAlpha(style.alpha) or texture.style.alpha or {1,1} + texture.style.layer = style.layer or texture.style.layer or DEFAULT_LAYER + texture.style.position = formatPosition(style.position) or texture.style.position or { 0, 0, 0, 0 } + texture.style.width = style.width or texture.style.width + texture.style.height = style.height or texture.style.height + texture.style.color = style.color or texture.style.color + texture.style.alpha = formatAlpha(style.alpha) or texture.style.alpha or { 1, 1 } -- gradient if texture.style.gradient then - texture.style.gradient.orientation = style.gradient_orientation or texture.style.gradient.orientation or DEFAULT_GRADIENT_ORIENTATION - texture.style.gradient.color = style.gradient_color or texture.style.gradient.color or {DEFAULT_COLOR,DEFAULT_COLOR} + texture.style.gradient.orientation = style.gradient_orientation or texture.style.gradient.orientation or + DEFAULT_GRADIENT_ORIENTATION + texture.style.gradient.color = style.gradient_color or texture.style.gradient.color or + { DEFAULT_COLOR, DEFAULT_COLOR } end -- | Apply Settings |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -702,78 +730,90 @@ function DiesalStyle:StyleOutline(leftTexture,rightTexture,topTexture,bottomText topTexture:ClearAllPoints() bottomTexture:ClearAllPoints() - if texture.style.position [1] then leftTexture:SetPoint("LEFT", -texture.style.position [1],0) - else leftTexture:SetPoint("RIGHT", -texture.style.width,0) end - if texture.style.position [3] then leftTexture:SetPoint("TOP", 0,texture.style.position [3]) end - if texture.style.position [4] then leftTexture:SetPoint("BOTTOM", 0,-texture.style.position [4]) end - if texture.style.position [2] then rightTexture:SetPoint("RIGHT", texture.style.position [2],0) - else rightTexture:SetPoint("LEFT", texture.style.width-(texture.style.position [1]+1),0) end - if texture.style.position [3] then rightTexture:SetPoint("TOP", 0,texture.style.position [3]) end - if texture.style.position [4] then rightTexture:SetPoint("BOTTOM", 0,-texture.style.position [4]) end - if texture.style.position [1] then topTexture:SetPoint("LEFT", -texture.style.position [1]+1,0) end - if texture.style.position [2] then topTexture:SetPoint("RIGHT", (texture.style.position [2])-1,0) end - if texture.style.position [3] then topTexture:SetPoint("TOP", 0,texture.style.position [3]) - else topTexture:SetPoint("BOTTOM", 0,texture.style.height-1) end - if texture.style.position [1] then bottomTexture:SetPoint("LEFT", -texture.style.position [1]+1,0) end - if texture.style.position [2] then bottomTexture:SetPoint("RIGHT", texture.style.position [2]-1,0) end - if texture.style.position [4] then bottomTexture:SetPoint("BOTTOM", 0,-texture.style.position [4]) - else bottomTexture:SetPoint("TOP", 0,-(texture.style.height+1)+(texture.style.position [3]+2)) end + if texture.style.position[1] then + leftTexture:SetPoint("LEFT", -texture.style.position[1], 0) + else + leftTexture:SetPoint("RIGHT", -texture.style.width, 0) + end + if texture.style.position[3] then leftTexture:SetPoint("TOP", 0, texture.style.position[3]) end + if texture.style.position[4] then leftTexture:SetPoint("BOTTOM", 0, -texture.style.position[4]) end + if texture.style.position[2] then + rightTexture:SetPoint("RIGHT", texture.style.position[2], 0) + else + rightTexture:SetPoint("LEFT", texture.style.width - (texture.style.position[1] + 1), 0) + end + if texture.style.position[3] then rightTexture:SetPoint("TOP", 0, texture.style.position[3]) end + if texture.style.position[4] then rightTexture:SetPoint("BOTTOM", 0, -texture.style.position[4]) end + if texture.style.position[1] then topTexture:SetPoint("LEFT", -texture.style.position[1] + 1, 0) end + if texture.style.position[2] then topTexture:SetPoint("RIGHT", (texture.style.position[2]) - 1, 0) end + if texture.style.position[3] then + topTexture:SetPoint("TOP", 0, texture.style.position[3]) + else + topTexture:SetPoint("BOTTOM", 0, texture.style.height - 1) + end + if texture.style.position[1] then bottomTexture:SetPoint("LEFT", -texture.style.position[1] + 1, 0) end + if texture.style.position[2] then bottomTexture:SetPoint("RIGHT", texture.style.position[2] - 1, 0) end + if texture.style.position[4] then + bottomTexture:SetPoint("BOTTOM", 0, -texture.style.position[4]) + else + bottomTexture:SetPoint("TOP", 0, -(texture.style.height + 1) + (texture.style.position[3] + 2)) + end -- size leftTexture:SetWidth(1) if texture.style.height then leftTexture:SetHeight(texture.style.height) end rightTexture:SetWidth(1) if texture.style.height then rightTexture:SetHeight(texture.style.height) end topTexture:SetHeight(1) - if texture.style.width then topTexture:SetWidth(texture.style.width-2) end + if texture.style.width then topTexture:SetWidth(texture.style.width - 2) end bottomTexture:SetHeight(1) - if texture.style.width then bottomTexture:SetWidth(texture.style.width-2) end + if texture.style.width then bottomTexture:SetWidth(texture.style.width - 2) end -- texture if texture.style.gradient then -- set mode texture.style.mode = 'gradient' -- clear any old settings - leftTexture:SetTexture() -- clear image + leftTexture:SetTexture() -- clear image -- leftTexture:SetAlpha(1) -- reset alpha - rightTexture:SetTexture() -- clear image + rightTexture:SetTexture() -- clear image -- rightTexture:SetAlpha(1) -- reset alpha - topTexture:SetTexture() -- clear image + topTexture:SetTexture() -- clear image -- topTexture:SetAlpha(1) -- reset alpha bottomTexture:SetTexture() -- clear image -- bottomTexture:SetAlpha(1) -- reset alpha - local r1,g1,b1,r2,g2,b2,a1,a2 + local r1, g1, b1, r2, g2, b2, a1, a2 if texture.style.gradient.orientation == 'HORIZONTAL' then -- clear settings - setGradient(leftTexture,'HORIZONTAL',1,1,1,1,1,1,1,1) - setGradient(rightTexture,'HORIZONTAL',1,1,1,1,1,1,1,1) - topTexture:SetColorTexture(1,1,1,1) -- clear color - bottomTexture:SetColorTexture(1,1,1,1) -- clear color + setGradient(leftTexture, 'HORIZONTAL', 1, 1, 1, 1, 1, 1, 1, 1) + setGradient(rightTexture, 'HORIZONTAL', 1, 1, 1, 1, 1, 1, 1, 1) + topTexture:SetColorTexture(1, 1, 1, 1) -- clear color + bottomTexture:SetColorTexture(1, 1, 1, 1) -- clear color -- aply settings - r1,g1,b1 = GetBlizzColorValues(texture.style.gradient.color[1]) - r2,g2,b2 = GetBlizzColorValues(texture.style.gradient.color[2]) - a1,a2 = texture.style.alpha[1], texture.style.alpha[2] - - setColor( leftTexture, r1,g1,b1,a1 ) - setColor( rightTexture, r2,g2,b2,a2 ) - setGradient(topTexture, 'HORIZONTAL', r1, g1, b1, a1, r2, g2, b2, a2) - setGradient(bottomTexture,'HORIZONTAL', r1, g1, b1, a1, r2, g2, b2, a2) + r1, g1, b1 = GetBlizzColorValues(texture.style.gradient.color[1]) + r2, g2, b2 = GetBlizzColorValues(texture.style.gradient.color[2]) + a1, a2 = texture.style.alpha[1], texture.style.alpha[2] + + setColor(leftTexture, r1, g1, b1, a1) + setColor(rightTexture, r2, g2, b2, a2) + setGradient(topTexture, 'HORIZONTAL', r1, g1, b1, a1, r2, g2, b2, a2) + setGradient(bottomTexture, 'HORIZONTAL', r1, g1, b1, a1, r2, g2, b2, a2) elseif texture.style.gradient.orientation == 'VERTICAL' then -- clear settings - leftTexture:SetColorTexture(1,1,1,1) -- clear color - rightTexture:SetColorTexture(1,1,1,1) -- clear color - setGradient(topTexture,'HORIZONTAL',1,1,1,1,1,1,1,1) - setGradient(bottomTexture,'HORIZONTAL',1,1,1,1,1,1,1,1) + leftTexture:SetColorTexture(1, 1, 1, 1) -- clear color + rightTexture:SetColorTexture(1, 1, 1, 1) -- clear color + setGradient(topTexture, 'HORIZONTAL', 1, 1, 1, 1, 1, 1, 1, 1) + setGradient(bottomTexture, 'HORIZONTAL', 1, 1, 1, 1, 1, 1, 1, 1) -- aply settings - r1,g1,b1 = GetBlizzColorValues(texture.style.gradient.color[2]) - r2,g2,b2 = GetBlizzColorValues(texture.style.gradient.color[1]) - a1,a2 = texture.style.alpha[2], texture.style.alpha[1] + r1, g1, b1 = GetBlizzColorValues(texture.style.gradient.color[2]) + r2, g2, b2 = GetBlizzColorValues(texture.style.gradient.color[1]) + a1, a2 = texture.style.alpha[2], texture.style.alpha[1] - setColor( topTexture, r2,g2,b2,a2 ) - setColor( bottomTexture, r1,g1,b1,a1 ) - setGradient(leftTexture, 'VERTICAL', r1, g1, b1, a1, r2, g2, b2, a2) + setColor(topTexture, r2, g2, b2, a2) + setColor(bottomTexture, r1, g1, b1, a1) + setGradient(leftTexture, 'VERTICAL', r1, g1, b1, a1, r2, g2, b2, a2) setGradient(rightTexture, 'VERTICAL', r1, g1, b1, a1, r2, g2, b2, a2) else texture.style.mode = 'gradient: no orientation!' @@ -783,47 +823,48 @@ function DiesalStyle:StyleOutline(leftTexture,rightTexture,topTexture,bottomText -- set mode texture.style.mode = 'color' -- clear any old settings - setGradient(leftTexture,'HORIZONTAL',1,1,1,1,1,1,1,1) - setGradient(rightTexture,'HORIZONTAL',1,1,1,1,1,1,1,1) - setGradient(topTexture,'HORIZONTAL',1,1,1,1,1,1,1,1) - setGradient(bottomTexture,'HORIZONTAL',1,1,1,1,1,1,1,1) + setGradient(leftTexture, 'HORIZONTAL', 1, 1, 1, 1, 1, 1, 1, 1) + setGradient(rightTexture, 'HORIZONTAL', 1, 1, 1, 1, 1, 1, 1, 1) + setGradient(topTexture, 'HORIZONTAL', 1, 1, 1, 1, 1, 1, 1, 1) + setGradient(bottomTexture, 'HORIZONTAL', 1, 1, 1, 1, 1, 1, 1, 1) -- apply settings - local r,g,b = GetBlizzColorValues(texture.style.color) + local r, g, b = GetBlizzColorValues(texture.style.color) - setColor( leftTexture, r,g,b,texture.style.alpha[1] ) - setColor( rightTexture, r,g,b,texture.style.alpha[1] ) - setColor( topTexture, r,g,b,texture.style.alpha[1] ) - setColor( bottomTexture, r,g,b,texture.style.alpha[1] ) + setColor(leftTexture, r, g, b, texture.style.alpha[1]) + setColor(rightTexture, r, g, b, texture.style.alpha[1]) + setColor(topTexture, r, g, b, texture.style.alpha[1]) + setColor(bottomTexture, r, g, b, texture.style.alpha[1]) else -- set mode texture.style.mode = 'none!' -- clear the texture - leftTexture:SetTexture() -- clear image - setGradient(leftTexture,'HORIZONTAL',0,0,0,0,0,0,0,0) -- clear gradient - leftTexture:SetColorTexture(0,0,0,0) -- clear color - rightTexture:SetTexture() -- clear image - setGradient(rightTexture,'HORIZONTAL',0,0,0,0,0,0,0,0) -- clear gradient - rightTexture:SetColorTexture(0,0,0,0) -- clear color - topTexture:SetTexture() -- clear image - setGradient(topTexture,'HORIZONTAL',0,0,0,0,0,0,0,0) -- clear gradient - topTexture:SetColorTexture(0,0,0,0) -- clear color - bottomTexture:SetTexture() -- clear image - setGradient(bottomTexture,'HORIZONTAL',0,0,0,0,0,0,0,0) -- clear gradient - bottomTexture:SetColorTexture(0,0,0,0) -- clear color + leftTexture:SetTexture() -- clear image + setGradient(leftTexture, 'HORIZONTAL', 0, 0, 0, 0, 0, 0, 0, 0) -- clear gradient + leftTexture:SetColorTexture(0, 0, 0, 0) -- clear color + rightTexture:SetTexture() -- clear image + setGradient(rightTexture, 'HORIZONTAL', 0, 0, 0, 0, 0, 0, 0, 0) -- clear gradient + rightTexture:SetColorTexture(0, 0, 0, 0) -- clear color + topTexture:SetTexture() -- clear image + setGradient(topTexture, 'HORIZONTAL', 0, 0, 0, 0, 0, 0, 0, 0) -- clear gradient + topTexture:SetColorTexture(0, 0, 0, 0) -- clear color + bottomTexture:SetTexture() -- clear image + setGradient(bottomTexture, 'HORIZONTAL', 0, 0, 0, 0, 0, 0, 0, 0) -- clear gradient + bottomTexture:SetColorTexture(0, 0, 0, 0) -- clear color end end - -function DiesalStyle:StyleShadow(object,frame,style) - object.shadow = object.shadow or CreateFrame("Frame",nil,frame,BackdropTemplateMixin and "BackdropTemplate") --CreateFrame("Frame",nil,frame) +function DiesalStyle:StyleShadow(object, frame, style) + object.shadow = object.shadow or + CreateFrame("Frame", nil, frame, BackdropTemplateMixin and "BackdropTemplate") --CreateFrame("Frame",nil,frame) object.shadow:Show() if not object.shadow.style or style.clear then object.shadow.style = {} end local shadowStyle = object.shadow.style -- ~~ Format New Settings ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - local red,green,blue = DiesalTools.GetColor(style.color) - local offset = style.offset and type(style.offset)=='number' and {style.offset,style.offset,style.offset,style.offset} or style.offset + local red, green, blue = DiesalTools.GetColor(style.color) + local offset = style.offset and type(style.offset) == 'number' and + { style.offset, style.offset, style.offset, style.offset } or style.offset -- Setting ~~~~~~~~~~~~~~~~~~~~~~~ New Setting ~~~~~~~~~~~~~~~ Old Setting ~~~~~~~~~~~~~~~~~ Default ~~~~~~~~~~~~~~~~~~ - shadowStyle.edgeFile = style.edgeFile or shadowStyle.edgeFile or getMedia('border','shadow') + shadowStyle.edgeFile = style.edgeFile or shadowStyle.edgeFile or getMedia('border', 'shadow') shadowStyle.edgeSize = style.edgeSize or shadowStyle.edgeSize or 28 shadowStyle.red = red or shadowStyle.red or 0 @@ -831,17 +872,18 @@ function DiesalStyle:StyleShadow(object,frame,style) shadowStyle.blue = blue or shadowStyle.blue or 0 shadowStyle.alpha = style.alpha or shadowStyle.alpha or .45 - shadowStyle.offset = offset or shadowStyle.offset or {20,20,20,20} + shadowStyle.offset = offset or shadowStyle.offset or { 20, 20, 20, 20 } -- ~~ Apply Settings ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - if shadowStyle.offset[1] then object.shadow:SetPoint("LEFT", -shadowStyle.offset[1],0) end - if shadowStyle.offset[2] then object.shadow:SetPoint("RIGHT", shadowStyle.offset[2],0) end - if shadowStyle.offset[3] then object.shadow:SetPoint("TOP", 0,shadowStyle.offset[3]) end - if shadowStyle.offset[4] then object.shadow:SetPoint("BOTTOM", 0,-shadowStyle.offset[4]) end + if shadowStyle.offset[1] then object.shadow:SetPoint("LEFT", -shadowStyle.offset[1], 0) end + if shadowStyle.offset[2] then object.shadow:SetPoint("RIGHT", shadowStyle.offset[2], 0) end + if shadowStyle.offset[3] then object.shadow:SetPoint("TOP", 0, shadowStyle.offset[3]) end + if shadowStyle.offset[4] then object.shadow:SetPoint("BOTTOM", 0, -shadowStyle.offset[4]) end object.shadow:SetBackdrop({ edgeFile = shadowStyle.edgeFile, edgeSize = shadowStyle.edgeSize }) object.shadow:SetBackdropBorderColor(shadowStyle.red, shadowStyle.green, shadowStyle.blue, shadowStyle.alpha) end + --[[ Font style table format TODO style.offset ( offset|{ Left, Right, Top, Bottom }) TODO style.width ( width ) @@ -854,14 +896,14 @@ style.alpha ( alpha ) style.color ( hexColor|{ Red, Green, Blue } [0-255]) style.lineSpacing ( number - Sets the font instance's amount of spacing between lines) ]] -function DiesalStyle:StyleFont(fontInstance,name,style) +function DiesalStyle:StyleFont(fontInstance, name, style) local filename, fontSize, flags = fontInstance:GetFont() - local red,green,blue,alpha = fontInstance:GetTextColor() + local red, green, blue, alpha = fontInstance:GetTextColor() local lineSpacing = fontInstance:GetSpacing() - -- Fallback to DiesalFontNormal for Patch 8.1 - if not filename then + -- Fallback to DiesalFontNormal for Patch 8.1 + if not filename then filename, fontSize, flags = DiesalFontNormal:GetFont() - red,green,blue,alpha = DiesalFontNormal:GetTextColor() + red, green, blue, alpha = DiesalFontNormal:GetTextColor() lineSpacing = DiesalFontNormal:GetSpacing() end style.red, style.green, style.blue = DiesalTools.GetColor(style.color) @@ -876,23 +918,23 @@ function DiesalStyle:StyleFont(fontInstance,name,style) style.alpha = style.alpha or alpha style.lineSpacing = style.lineSpacing or lineSpacing -- ~~ Apply Settings ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - fontInstance:SetFont( style.filename, style.fontSize, style.flags ) + fontInstance:SetFont(style.filename, style.fontSize, style.flags) fontInstance:SetTextColor(style.red, style.green, style.blue, style.alpha) fontInstance:SetSpacing(style.lineSpacing) fontInstance.style = style end -function DiesalStyle:UpdateObjectStyle(object,name,style) - if not style or type(style) ~='table' then return end - if type(name) ~='string' then return end +function DiesalStyle:UpdateObjectStyle(object, name, style) + if not style or type(style) ~= 'table' then return end + if type(name) ~= 'string' then return end -- ~~ Clear Texture ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if style.clear then -- clear texture - if object.textures[name] then DiesalStyle:ReleaseTexture(object,name) end + if object.textures[name] then DiesalStyle:ReleaseTexture(object, name) end -- clear OUTLINE - for i=1, #OUTLINES do - if object.textures[name..OUTLINES[i]] then DiesalStyle:ReleaseTexture(object,name..OUTLINES[i]) end + for i = 1, #OUTLINES do + if object.textures[name .. OUTLINES[i]] then DiesalStyle:ReleaseTexture(object, name .. OUTLINES[i]) end end end -- add texture name to style for better debugging @@ -900,7 +942,10 @@ function DiesalStyle:UpdateObjectStyle(object,name,style) -- ~~ Get styleType ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if not style.type then return end local styleType = DiesalTools.Capitalize(style.type) - if not DiesalStyle['Style'..styleType] then geterrorhandler()(style.type..' is not a valid style type') return end + if not DiesalStyle['Style' .. styleType] then + geterrorhandler()(style.type .. ' is not a valid style type') + return + end -- ~~ Get Frame ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ local framename = name:match('^[ \t]*([%w%d%_]*)') local frame = object[framename] @@ -913,78 +958,87 @@ function DiesalStyle:UpdateObjectStyle(object,name,style) object.textures[name] = texture end texture:SetParent(frame) - DiesalStyle:StyleTexture(texture,style) - return end + DiesalStyle:StyleTexture(texture, style) + return + end if styleType == 'Outline' then local textures = {} - for i=1, #OUTLINES do - local texture = object.textures[name..OUTLINES[i]] + for i = 1, #OUTLINES do + local texture = object.textures[name .. OUTLINES[i]] if not texture then texture = newTexture() - object.textures[name..OUTLINES[i]] = texture + object.textures[name .. OUTLINES[i]] = texture end texture:SetParent(frame) textures[i] = texture end - DiesalStyle:StyleOutline(textures[1],textures[2],textures[3],textures[4],style) - return end + DiesalStyle:StyleOutline(textures[1], textures[2], textures[3], textures[4], style) + return + end if styleType == 'Shadow' then - DiesalStyle:StyleShadow(object,frame,style) - return end + DiesalStyle:StyleShadow(object, frame, style) + return + end if styleType == 'Font' then - DiesalStyle:StyleFont(frame,name,style) + DiesalStyle:StyleFont(frame, name, style) end end -function DiesalStyle:SetObjectStyle(object,name,style) - if not style or type(style) ~='table' then return end - if type(name) ~='string' then return end + +function DiesalStyle:SetObjectStyle(object, name, style) + if not style or type(style) ~= 'table' then return end + if type(name) ~= 'string' then return end -- clear texture - if object.textures[name] then DiesalStyle:ReleaseTexture(object,name) end + if object.textures[name] then DiesalStyle:ReleaseTexture(object, name) end -- clear OUTLINE - for i=1, #OUTLINES do - if object.textures[name..OUTLINES[i]] then DiesalStyle:ReleaseTexture(object,name..OUTLINES[i]) end + for i = 1, #OUTLINES do + if object.textures[name .. OUTLINES[i]] then DiesalStyle:ReleaseTexture(object, name .. OUTLINES[i]) end end -- Set object style - DiesalStyle:UpdateObjectStyle(object,name,style) + DiesalStyle:UpdateObjectStyle(object, name, style) end -function DiesalStyle:UpdateObjectStylesheet(object,Stylesheet) - if not Stylesheet or type(Stylesheet) ~='table' then return end + +function DiesalStyle:UpdateObjectStylesheet(object, Stylesheet) + if not Stylesheet or type(Stylesheet) ~= 'table' then return end if not object.textures then object.textures = {} end - for name,style in pairs(Stylesheet) do - self:UpdateObjectStyle(object,name,style) + for name, style in pairs(Stylesheet) do + self:UpdateObjectStyle(object, name, style) end end -function DiesalStyle:SetObjectStylesheet(object,Stylesheet) + +function DiesalStyle:SetObjectStylesheet(object, Stylesheet) if not object.textures then object.textures = {} end DiesalStyle:ReleaseTextures(object) - for name,style in pairs(Stylesheet) do - self:UpdateObjectStyle(object,name,style) + for name, style in pairs(Stylesheet) do + self:UpdateObjectStyle(object, name, style) end end -function DiesalStyle:ReleaseTexture(object,name) + +function DiesalStyle:ReleaseTexture(object, name) if not object or not object.textures or not object.textures[name] then - error('No such texture on ojbect',2) - return end + error('No such texture on ojbect', 2) + return + end releaseTexture(object.textures[name]) object.textures[name] = nil end + function DiesalStyle:ReleaseTextures(object) - for name,texture in pairs(object.textures) do + for name, texture in pairs(object.textures) do releaseTexture(texture) object.textures[name] = nil end end -function DiesalStyle:GetMedia(mediaType,name) - return getMedia(mediaType,name) -end -function DiesalStyle:AddMedia(mediaType,name,mediaFile) - addMedia(mediaType,name,mediaFile) -end +function DiesalStyle:GetMedia(mediaType, name) + return getMedia(mediaType, name) +end +function DiesalStyle:AddMedia(mediaType, name, mediaFile) + addMedia(mediaType, name, mediaFile) +end -- deprecated diff --git a/Libs/LibStub/LibStub.lua b/Libs/LibStub/LibStub.lua index 7e9b5cd15..a9ed213ff 100644 --- a/Libs/LibStub/LibStub.lua +++ b/Libs/LibStub/LibStub.lua @@ -2,31 +2,32 @@ -- LibStub is a simple versioning stub meant for use in Libraries. http://www.wowace.com/addons/libstub/ for more info -- LibStub is hereby placed in the Public Domain -- Credits: Kaelten, Cladhaire, ckknight, Mikk, Ammo, Nevcairiel, joshborke -local LIBSTUB_MAJOR, LIBSTUB_MINOR = "LibStub", 2 -- NEVER MAKE THIS AN SVN REVISION! IT NEEDS TO BE USABLE IN ALL REPOS! +local LIBSTUB_MAJOR, LIBSTUB_MINOR = "LibStub", + 2 -- NEVER MAKE THIS AN SVN REVISION! IT NEEDS TO BE USABLE IN ALL REPOS! local LibStub = _G[LIBSTUB_MAJOR] -- Check to see is this version of the stub is obsolete if not LibStub or LibStub.minor < LIBSTUB_MINOR then - LibStub = LibStub or {libs = {}, minors = {} } + LibStub = LibStub or { libs = {}, minors = {} } _G[LIBSTUB_MAJOR] = LibStub LibStub.minor = LIBSTUB_MINOR - + -- LibStub:NewLibrary(major, minor) -- major (string) - the major version of the library -- minor (string or number ) - the minor version of the library - -- + -- -- returns nil if a newer or same version of the lib is already present -- returns empty library object or old library object if upgrade is needed function LibStub:NewLibrary(major, minor) assert(type(major) == "string", "Bad argument #2 to `NewLibrary' (string expected)") minor = assert(tonumber(strmatch(minor, "%d+")), "Minor version must either be a number or contain a number.") - + local oldminor = self.minors[major] if oldminor and oldminor >= minor then return nil end self.minors[major], self.libs[major] = minor, self.libs[major] or {} return self.libs[major], oldminor end - + -- LibStub:GetLibrary(major, [silent]) -- major (string) - the major version of the library -- silent (boolean) - if true, library is optional, silently return nil if its not found @@ -39,13 +40,13 @@ if not LibStub or LibStub.minor < LIBSTUB_MINOR then end return self.libs[major], self.minors[major] end - + -- LibStub:IterateLibraries() - -- + -- -- Returns an iterator for the currently registered libraries - function LibStub:IterateLibraries() - return pairs(self.libs) + function LibStub:IterateLibraries() + return pairs(self.libs) end - + setmetatable(LibStub, { __call = LibStub.GetLibrary }) end diff --git a/System/Functions/Cast.lua b/System/Functions/Cast.lua index eaa240273..8da2301f5 100644 --- a/System/Functions/Cast.lua +++ b/System/Functions/Cast.lua @@ -1,40 +1,41 @@ local _, br = ... -- if canCast(12345,true) -function br.canCast(SpellID,KnownSkip,MovementCheck, thisUnit) +function br.canCast(SpellID, KnownSkip, MovementCheck, thisUnit) if thisUnit == nil then thisUnit = "target" end local myCooldown = br.getSpellCD(SpellID) or 0 -- local lagTolerance = br.getValue("Lag Tolerance") or 0 if (KnownSkip == true or br.isKnown(SpellID)) and (br._G.UnitIsUnit(thisUnit, "target") and br._G.IsUsableSpell(SpellID) or true) and myCooldown < 0.1 - and (MovementCheck == false or myCooldown == 0 or br.isMoving("player") ~= true or br.UnitBuffID("player",79206) ~= nil) then + and (MovementCheck == false or myCooldown == 0 or br.isMoving("player") ~= true or br.UnitBuffID("player", 79206) ~= nil) then return true end end -function br.castAoEHeal(spellID,numUnits,missingHP,rangeValue) +function br.castAoEHeal(spellID, numUnits, missingHP, rangeValue) -- i start an iteration that i use to build each units Table,which i will reuse for the next second if not br.holyRadianceRangeTable or not br.holyRadianceRangeTableTimer or br.holyRadianceRangeTableTimer <= br._G.GetTime() - 1 then - br.holyRadianceRangeTable = { } - for i = 1,#br.friend do + br.holyRadianceRangeTable = {} + for i = 1, #br.friend do -- i declare a sub-table for this unit if it dont exists - if br.friend[i].distanceTable == nil then br.friend[i].distanceTable = { } end + if br.friend[i].distanceTable == nil then br.friend[i].distanceTable = {} end -- i start a second iteration where i scan unit ranges from one another. - for j = 1,#br.friend do + for j = 1, #br.friend do -- i make sure i dont compute unit range to hisself. - if not br.GetUnitIsUnit(br.friend[i].unit,br.friend[j].unit) then + if not br.GetUnitIsUnit(br.friend[i].unit, br.friend[j].unit) then -- table the units - br.friend[i].distanceTable[j] = { distance = br.getDistance(br.friend[i].unit,br.friend[j].unit),unit = br.friend[j].unit,hp = br.friend[j].hp } + br.friend[i].distanceTable[j] = { distance = br.getDistance(br.friend[i].unit, br.friend[j].unit), unit = + br.friend[j].unit, hp = br.friend[j].hp } end end end end -- declare locals that will hold number - local bestTarget,bestTargetUnits = 1,1 + local bestTarget, bestTargetUnits = 1, 1 -- now that nova range is built,i can iterate it - local inRange,missingHealth,mostMissingHealth = 0,0,0 - for i = 1,#br.friend do + local inRange, missingHealth, mostMissingHealth = 0, 0, 0 + for i = 1, #br.friend do if br.friend[i].distanceTable ~= nil then -- i count units in range - for j = 1,#br.friend do + for j = 1, #br.friend do if br.friend[i].distanceTable[j] and br.friend[i].distanceTable[j].distance < rangeValue then inRange = inRange + 1 missingHealth = missingHealth + (100 - br.friend[i].distanceTable[j].hp) @@ -43,42 +44,44 @@ function br.castAoEHeal(spellID,numUnits,missingHP,rangeValue) br.friend[i].inRangeForHolyRadiance = inRange -- i check if this is going to be the best unit for my spell if missingHealth > mostMissingHealth then - bestTarget,bestTargetUnits,mostMissingHealth = i,inRange,missingHealth + bestTarget, bestTargetUnits, mostMissingHealth = i, inRange, missingHealth end end end if bestTargetUnits and bestTargetUnits > 3 and mostMissingHealth and missingHP and mostMissingHealth > missingHP then - if br.castSpell(br.friend[bestTarget].unit,spellID,true,true) then return true end + if br.castSpell(br.friend[bestTarget].unit, spellID, true, true) then return true end end end + -- castGround("target",12345,40) -function br.castGround(Unit,SpellID,maxDistance,minDistance,radius,castTime) +function br.castGround(Unit, SpellID, maxDistance, minDistance, radius, castTime) if radius == nil then radius = maxDistance end if minDistance == nil then minDistance = 0 end - local groundDistance = br.getDistance("player",Unit,"dist4")+1 - local distance = br.getDistance("player",Unit) + local groundDistance = br.getDistance("player", Unit, "dist4") + 1 + local distance = br.getDistance("player", Unit) local mouselookActive = false - if br.GetUnitExists(Unit) and br.getSpellCD(SpellID) == 0 and br.getLineOfSight("player",Unit) + if br.GetUnitExists(Unit) and br.getSpellCD(SpellID) == 0 and br.getLineOfSight("player", Unit) and distance < maxDistance and distance >= minDistance - and #br.getEnemies(Unit,radius) >= #br.getEnemies(Unit,radius,true) + and #br.getEnemies(Unit, radius) >= #br.getEnemies(Unit, radius, true) then if br._G.IsMouselooking() then mouselookActive = true br._G.MouselookStop() end br._G.CastSpellByName(br._G.GetSpellInfo(SpellID)) - local X,Y,Z + local X, Y, Z if castTime == nil or castTime == 0 then - X,Y,Z = br.GetObjectPosition(Unit) + X, Y, Z = br.GetObjectPosition(Unit) else - X,Y,Z = br.GetFuturePostion(Unit, castTime) + X, Y, Z = br.GetFuturePostion(Unit, castTime) end --local distanceToGround = getGroundDistance(Unit) or 0 - if groundDistance > maxDistance then X,Y,Z = br._G.GetPositionBetweenObjects(Unit,"player",groundDistance-maxDistance) end - br._G.ClickPosition((X + math.random() * 2),(Y + math.random() * 2),Z) --distanceToGround - br.castPosition.x = X - br.castPosition.y = Y - br.castPosition.z = Z + if groundDistance > maxDistance then X, Y, Z = br._G.GetPositionBetweenObjects(Unit, "player", + groundDistance - maxDistance) end + br._G.ClickPosition((X + math.random() * 2), (Y + math.random() * 2), Z) --distanceToGround + br.castPosition.x = X + br.castPosition.y = Y + br.castPosition.z = Z if mouselookActive then br._G.MouselookStart() end @@ -86,14 +89,15 @@ function br.castGround(Unit,SpellID,maxDistance,minDistance,radius,castTime) end return false end + --castGroundLocation(123,456,98765,40,0,8) -function br.castGroundLocation(X,Y,SpellID,maxDistance,minDistance,radius) +function br.castGroundLocation(X, Y, SpellID, maxDistance, minDistance, radius) if X == nil or Y == nil then return false end if radius == nil then radius = maxDistance end if minDistance == nil then minDistance = 0 end --local groundDistance = br.getDistance("player",Unit,"dist4")+1 local pX, pY, Z = br.GetObjectPosition("player") - local distance = br._G.sqrt(((X-pX)^2) + ((Y-pY)^2)) + local distance = br._G.sqrt(((X - pX) ^ 2) + ((Y - pY) ^ 2)) local mouselookActive = false if distance < maxDistance and distance >= minDistance then if br._G.IsMouselooking() then @@ -104,11 +108,11 @@ function br.castGroundLocation(X,Y,SpellID,maxDistance,minDistance,radius) br._G.CastSpellByName(br._G.GetSpellInfo(SpellID)) if br._G.IsAoEPending() then -- br._G.print("Clicking Position") - br._G.ClickPosition((X + math.random() * 2),(Y + math.random() * 2),Z) --distanceToGround + br._G.ClickPosition((X + math.random() * 2), (Y + math.random() * 2), Z) --distanceToGround end - br.castPosition.x = X - br.castPosition.y = Y - br.castPosition.z = Z + br.castPosition.x = X + br.castPosition.y = Y + br.castPosition.z = Z if mouselookActive then br._G.MouselookStart() end @@ -116,20 +120,22 @@ function br.castGroundLocation(X,Y,SpellID,maxDistance,minDistance,radius) end return false end + -- castGroundBetween("target",12345,40) -function br.castGroundBetween(Unit,SpellID,maxDistance) - if br.GetUnitExists(Unit) and br.getSpellCD(SpellID) <= 0.4 and br.getLineOfSight("player",Unit) and br.getDistance("player",Unit) <= maxDistance then +function br.castGroundBetween(Unit, SpellID, maxDistance) + if br.GetUnitExists(Unit) and br.getSpellCD(SpellID) <= 0.4 and br.getLineOfSight("player", Unit) and br.getDistance("player", Unit) <= maxDistance then br._G.CastSpellByName(br._G.GetSpellInfo(SpellID)) - local X,Y,Z = br.GetObjectPosition(Unit) - br._G.ClickPosition(X,Y,Z,true) + local X, Y, Z = br.GetObjectPosition(Unit) + br._G.ClickPosition(X, Y, Z, true) return true end return false end + -- if shouldNotOverheal(spellCastTarget) > 80 then function br.shouldNotOverheal(Unit) - local myIncomingHeal,allIncomingHeal = 0,0 - if br._G.UnitGetIncomingHeals(Unit,"player") ~= nil then myIncomingHeal = br._G.UnitGetIncomingHeals(Unit,"player") end + local myIncomingHeal, allIncomingHeal = 0, 0 + if br._G.UnitGetIncomingHeals(Unit, "player") ~= nil then myIncomingHeal = br._G.UnitGetIncomingHeals(Unit, "player") end if br._G.UnitGetIncomingHeals(Unit) ~= nil then allIncomingHeal = br._G.UnitGetIncomingHeals(Unit) end allIncomingHeal = allIncomingHeal or 0 local overheal @@ -139,42 +145,50 @@ function br.shouldNotOverheal(Unit) overheal = allIncomingHeal end local CurShield = br._G.UnitHealth(Unit) - if br.UnitDebuffID("player",142861) then --Ancient Miasma - CurShield = select(14,br.UnitDebuffID(Unit,142863)) or select(14,br.UnitDebuffID(Unit,142864)) or select(14,br.UnitDebuffID(Unit,142865)) or (br._G.UnitHealthMax(Unit) / 2) + if br.UnitDebuffID("player", 142861) then --Ancient Miasma + CurShield = select(14, br.UnitDebuffID(Unit, 142863)) or select(14, br.UnitDebuffID(Unit, 142864)) or + select(14, br.UnitDebuffID(Unit, 142865)) or (br._G.UnitHealthMax(Unit) / 2) overheal = 0 end - local overhealth = 100 * (CurShield+ overheal ) / br._G.UnitHealthMax(Unit) + local overhealth = 100 * (CurShield + overheal) / br._G.UnitHealthMax(Unit) if overhealth and overheal then - return overhealth,overheal + return overhealth, overheal else - return 0,0 + return 0, 0 end end + -- if castHealGround(_HealingRain,18,80,3) then -function br.castHealGround(SpellID,Radius,Health,NumberOfPlayers) +function br.castHealGround(SpellID, Radius, Health, NumberOfPlayers) if br.shouldStopCasting(SpellID) ~= true then - local lowHPTargets,foundTargets = { },{ } - for i = 1,#br.friend do + local lowHPTargets, foundTargets = {}, {} + for i = 1, #br.friend do if br.getHP(br.friend[i].unit) <= Health then if br.GetUnitIsVisible(br.friend[i].unit) and br.GetObjectExists(br.friend[i].unit) then - local X,Y,Z = br.GetObjectPosition(br.friend[i].unit) - br._G.tinsert(lowHPTargets,{ unit = br.friend[i].unit,x = X,y = Y,z = Z }) + local X, Y, Z = br.GetObjectPosition(br.friend[i].unit) + br._G.tinsert(lowHPTargets, { unit = br.friend[i].unit, x = X, y = Y, z = Z }) end end end if #lowHPTargets >= NumberOfPlayers then - for i = 1,#lowHPTargets do - for j = 1,#lowHPTargets do + for i = 1, #lowHPTargets do + for j = 1, #lowHPTargets do if lowHPTargets[i].unit ~= lowHPTargets[j].unit then - if math.sqrt(((lowHPTargets[j].x-lowHPTargets[i].x)^2)+((lowHPTargets[j].y-lowHPTargets[i].y)^2)) < Radius then - for k = 1,#lowHPTargets do + if math.sqrt(((lowHPTargets[j].x - lowHPTargets[i].x) ^ 2) + ((lowHPTargets[j].y - lowHPTargets[i].y) ^ 2)) < Radius then + for k = 1, #lowHPTargets do if lowHPTargets[i].unit ~= lowHPTargets[k].unit and lowHPTargets[j].unit ~= lowHPTargets[k].unit then - if math.sqrt(((lowHPTargets[k].x-lowHPTargets[i].x)^2)+((lowHPTargets[k].y-lowHPTargets[i].y)^2)) < Radius - and math.sqrt(((lowHPTargets[k].x-lowHPTargets[j].x)^2)+((lowHPTargets[k].y-lowHPTargets[j].y)^2)) < Radius + if math.sqrt(((lowHPTargets[k].x - lowHPTargets[i].x) ^ 2) + ((lowHPTargets[k].y - lowHPTargets[i].y) ^ 2)) < Radius + and math.sqrt(((lowHPTargets[k].x - lowHPTargets[j].x) ^ 2) + ((lowHPTargets[k].y - lowHPTargets[j].y) ^ 2)) < Radius then - br._G.tinsert(foundTargets,{ unit = lowHPTargets[i].unit,x = lowHPTargets[i].x,y = lowHPTargets[i].y,z = lowHPTargets[i].z }) - br._G.tinsert(foundTargets,{ unit = lowHPTargets[j].unit,x = lowHPTargets[j].x,y = lowHPTargets[j].y,z = lowHPTargets[i].z }) - br._G.tinsert(foundTargets,{ unit = lowHPTargets[k].unit,x = lowHPTargets[k].x,y = lowHPTargets[k].y,z = lowHPTargets[i].z }) + br._G.tinsert(foundTargets, + { unit = lowHPTargets[i].unit, x = lowHPTargets[i].x, y = lowHPTargets[i].y, z = + lowHPTargets[i].z }) + br._G.tinsert(foundTargets, + { unit = lowHPTargets[j].unit, x = lowHPTargets[j].x, y = lowHPTargets[j].y, z = + lowHPTargets[i].z }) + br._G.tinsert(foundTargets, + { unit = lowHPTargets[k].unit, x = lowHPTargets[k].x, y = lowHPTargets[k].y, z = + lowHPTargets[i].z }) end end end @@ -182,26 +196,26 @@ function br.castHealGround(SpellID,Radius,Health,NumberOfPlayers) end end end - local medX,medY,medZ = 0,0,0 + local medX, medY, medZ = 0, 0, 0 if foundTargets ~= nil and #foundTargets >= NumberOfPlayers then - for i = 1,3 do + for i = 1, 3 do medX = medX + foundTargets[i].x medY = medY + foundTargets[i].y medZ = medZ + foundTargets[i].z end - medX,medY,medZ = medX/3,medY/3,medZ/3 - local myX,myY = br.GetObjectPosition("player") - if math.sqrt(((medX-myX)^2)+((medY-myY)^2)) < 40 then - br._G.CastSpellByName(br._G.GetSpellInfo(SpellID),"target") - br._G.ClickPosition(medX,medY,medZ,true) - if SpellID == 145205 then br.shroomsTable[1] = { x = medX,y = medY,z = medZ} end + medX, medY, medZ = medX / 3, medY / 3, medZ / 3 + local myX, myY = br.GetObjectPosition("player") + if math.sqrt(((medX - myX) ^ 2) + ((medY - myY) ^ 2)) < 40 then + br._G.CastSpellByName(br._G.GetSpellInfo(SpellID), "target") + br._G.ClickPosition(medX, medY, medZ, true) + if SpellID == 145205 then br.shroomsTable[1] = { x = medX, y = medY, z = medZ } end return true end - elseif lowHPTargets~=nil and #lowHPTargets==1 and lowHPTargets[1].unit=="player" then - local myX,myY,myZ = br.GetObjectPosition("player") - br._G.CastSpellByName(br._G.GetSpellInfo(SpellID),"target") - br._G.ClickPosition(myX,myY,myZ,true) - if SpellID == 145205 then br.shroomsTable[1] = { x = medX,y = medY,z = medZ} end + elseif lowHPTargets ~= nil and #lowHPTargets == 1 and lowHPTargets[1].unit == "player" then + local myX, myY, myZ = br.GetObjectPosition("player") + br._G.CastSpellByName(br._G.GetSpellInfo(SpellID), "target") + br._G.ClickPosition(myX, myY, myZ, true) + if SpellID == 145205 then br.shroomsTable[1] = { x = medX, y = medY, z = medZ } end return true end end @@ -209,6 +223,7 @@ function br.castHealGround(SpellID,Radius,Health,NumberOfPlayers) return false end end + --[[castSpell(Unit,SpellID,FacingCheck,MovementCheck,SpamAllowed,KnownSkip) Parameter Value First UnitID Enter valid UnitID @@ -224,7 +239,8 @@ Tenth noCast True to return True/False instead of casting spell. ]] -- castSpell("target",12345,true) -- ( 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 ) -function br.castSpell(Unit,SpellID,FacingCheck,MovementCheck,SpamAllowed,KnownSkip,DeadCheck,DistanceSkip,usableSkip,noCast) +function br.castSpell(Unit, SpellID, FacingCheck, MovementCheck, SpamAllowed, KnownSkip, DeadCheck, DistanceSkip, + usableSkip, noCast) if br.GetObjectExists(Unit) --and betterStopCasting(SpellID) ~= true and (not br.GetUnitIsDeadOrGhost(Unit) or DeadCheck) then @@ -233,19 +249,19 @@ function br.castSpell(Unit,SpellID,FacingCheck,MovementCheck,SpamAllowed,KnownSk -- stop if not enough power for that spell if usableSkip ~= true and br._G.IsUsableSpell(SpellID) ~= true then return false end -- Table used to prevent refiring too quick - if br.timersTable == nil then br.timersTable = {} end + if br.timersTable == nil then br.timersTable = {} end -- default noCast to false if noCast == nil then noCast = false end -- make sure it is a known spell if not (KnownSkip == true or br.isKnown(SpellID)) then return false end -- gather our spell range information - local spellRange = select(6,br._G.GetSpellInfo(SpellID)) + local spellRange = select(6, br._G.GetSpellInfo(SpellID)) if DistanceSkip == nil then DistanceSkip = false end - if spellRange == nil or (spellRange < 4 and DistanceSkip==false) then spellRange = 4 end + if spellRange == nil or (spellRange < 4 and DistanceSkip == false) then spellRange = 4 end if DistanceSkip == true then spellRange = 40 end -- Check unit,if it's player then we can skip facing - if (Unit == nil or br.GetUnitIsUnit("player",Unit)) -- Player - or (Unit ~= nil and br.GetUnitIsFriend("player",Unit)) -- Ally + if (Unit == nil or br.GetUnitIsUnit("player", Unit)) -- Player + or (Unit ~= nil and br.GetUnitIsFriend("player", Unit)) -- Ally or br._G.IsHackEnabled("AlwaysFacing") then FacingCheck = true @@ -255,16 +271,16 @@ function br.castSpell(Unit,SpellID,FacingCheck,MovementCheck,SpamAllowed,KnownSk -- if MovementCheck is nil or false then we dont check it if MovementCheck == false or br.isMoving("player") ~= true -- skip movement check during spiritwalkers grace and aspect of the fox - or br.UnitBuffID("player",79206) ~= nil + or br.UnitBuffID("player", 79206) ~= nil then -- if ability is ready and in range - -- if br.getSpellCD(SpellID) < select(4,GetNetStats()) / 1000 - if (br.getSpellCD(SpellID) < select(4,br._G.GetNetStats()) / 1000) and (br.getOptionCheck("Skip Distance Check") or br.getDistance("player",Unit) <= spellRange or DistanceSkip == true or br.inRange(SpellID,Unit)) then + -- if br.getSpellCD(SpellID) < select(4,GetNetStats()) / 1000 + if (br.getSpellCD(SpellID) < select(4, br._G.GetNetStats()) / 1000) and (br.getOptionCheck("Skip Distance Check") or br.getDistance("player", Unit) <= spellRange or DistanceSkip == true or br.inRange(SpellID, Unit)) then -- if spam is not allowed if SpamAllowed == false then -- get our last/current cast - if br.timersTable == nil or (br.timersTable ~= nil and (br.timersTable[SpellID] == nil or br.timersTable[SpellID] <= br._G.GetTime() -0.6)) then - if (FacingCheck == true or br.getFacing("player",Unit) == true) and (br.GetUnitIsUnit("player",Unit) or br.units[Unit] ~= nil or br.getLineOfSight("player",Unit) == true) then + if br.timersTable == nil or (br.timersTable ~= nil and (br.timersTable[SpellID] == nil or br.timersTable[SpellID] <= br._G.GetTime() - 0.6)) then + if (FacingCheck == true or br.getFacing("player", Unit) == true) and (br.GetUnitIsUnit("player", Unit) or br.units[Unit] ~= nil or br.getLineOfSight("player", Unit) == true) then if noCast then return true else @@ -272,38 +288,38 @@ function br.castSpell(Unit,SpellID,FacingCheck,MovementCheck,SpamAllowed,KnownSk -- currentTarget = UnitGUID(Unit) -- Not Used br.botCast = true -- Used by old Queue Cast br.botSpell = SpellID -- Used by old Queue Cast - br._G.CastSpellByName(br._G.GetSpellInfo(SpellID),Unit) + br._G.CastSpellByName(br._G.GetSpellInfo(SpellID), Unit) if br._G.IsAoEPending() then - local X,Y,Z = br._G.ObjectPosition(Unit) - br._G.ClickPosition(X,Y,Z) + local X, Y, Z = br._G.ObjectPosition(Unit) + br._G.ClickPosition(X, Y, Z) end --lastSpellCast = SpellID -- change main button icon --if br.getOptionCheck("Start/Stop BadRotations") then - br.mainButton:SetNormalTexture(select(3,br._G.GetSpellInfo(SpellID))) - br.lastSpellCast = SpellID - br.lastSpellTarget = br._G.UnitGUID(Unit) + br.mainButton:SetNormalTexture(select(3, br._G.GetSpellInfo(SpellID))) + br.lastSpellCast = SpellID + br.lastSpellTarget = br._G.UnitGUID(Unit) --end return true end end end - elseif (FacingCheck == true or br.getFacing("player",Unit) == true) and (br.GetUnitIsUnit("player",Unit) or br.units[Unit] ~= nil or br.getLineOfSight("player",Unit) == true) then + elseif (FacingCheck == true or br.getFacing("player", Unit) == true) and (br.GetUnitIsUnit("player", Unit) or br.units[Unit] ~= nil or br.getLineOfSight("player", Unit) == true) then if noCast then return true else -- currentTarget = UnitGUID(Unit) -- Not Used br.botCast = true br.botSpell = SpellID - br._G.CastSpellByName(br._G.GetSpellInfo(SpellID),Unit) + br._G.CastSpellByName(br._G.GetSpellInfo(SpellID), Unit) if br._G.IsAoEPending() then - local X,Y,Z = br._G.ObjectPosition(Unit) - br._G.ClickPosition(X,Y,Z) + local X, Y, Z = br._G.ObjectPosition(Unit) + br._G.ClickPosition(X, Y, Z) end --if br.getOptionCheck("Start/Stop BadRotations") then - br.mainButton:SetNormalTexture(select(3,br._G.GetSpellInfo(SpellID))) - br.lastSpellCast = SpellID - br.lastSpellTarget = br._G.UnitGUID(Unit) + br.mainButton:SetNormalTexture(select(3, br._G.GetSpellInfo(SpellID))) + br.lastSpellCast = SpellID + br.lastSpellTarget = br._G.UnitGUID(Unit) --end return true end @@ -329,7 +345,8 @@ Tenth noCast True to return True/False instead of casting spell. ]] -- castSpell("target",12345,true) -- ( 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 ) -function br.castSpellMacro(Unit,SpellID,FacingCheck,MovementCheck,SpamAllowed,KnownSkip,DeadCheck,DistanceSkip,usableSkip,noCast) +function br.castSpellMacro(Unit, SpellID, FacingCheck, MovementCheck, SpamAllowed, KnownSkip, DeadCheck, DistanceSkip, + usableSkip, noCast) if br.GetObjectExists(Unit) and br.betterStopCasting(SpellID) ~= true and (not br.GetUnitIsDeadOrGhost(Unit) or DeadCheck) then -- we create an usableSkip for some specific spells like hammer of wrath aoe mode @@ -337,63 +354,63 @@ function br.castSpellMacro(Unit,SpellID,FacingCheck,MovementCheck,SpamAllowed,Kn -- stop if not enough power for that spell if usableSkip ~= true and br._G.IsUsableSpell(SpellID) ~= true then return false end -- Table used to prevent refiring too quick - if br.timersTable == nil then br.timersTable = {} end + if br.timersTable == nil then br.timersTable = {} end -- default noCast to false if noCast == nil then noCast = false end -- make sure it is a known spell if not (KnownSkip == true or br.isKnown(SpellID)) then return false end -- gather our spell range information - local spellRange = select(6,br._G.GetSpellInfo(SpellID)) + local spellRange = select(6, br._G.GetSpellInfo(SpellID)) if DistanceSkip == nil then DistanceSkip = false end - if spellRange == nil or (spellRange < 4 and DistanceSkip==false) then spellRange = 4 end + if spellRange == nil or (spellRange < 4 and DistanceSkip == false) then spellRange = 4 end if DistanceSkip == true then spellRange = 40 end -- Check unit,if it's player then we can skip facing - if (Unit == nil or br.GetUnitIsUnit("player",Unit)) or -- Player - (Unit ~= nil and br.GetUnitIsFriend("player",Unit)) then -- Ally + if (Unit == nil or br.GetUnitIsUnit("player", Unit)) or -- Player + (Unit ~= nil and br.GetUnitIsFriend("player", Unit)) then -- Ally FacingCheck = true - elseif br.isSafeToAttack(Unit) ~= true then -- enemy + elseif br.isSafeToAttack(Unit) ~= true then -- enemy return false end -- if MovementCheck is nil or false then we dont check it if MovementCheck == false or br.isMoving("player") ~= true -- skip movement check during spiritwalkers grace and aspect of the fox - or br.UnitBuffID("player",79206) ~= nil + or br.UnitBuffID("player", 79206) ~= nil then -- if ability is ready and in range - -- if br.getSpellCD(SpellID) < select(4,GetNetStats()) / 1000 - if (br.getSpellCD(SpellID) < select(4,br._G.GetNetStats()) / 1000) and (br.getOptionCheck("Skip Distance Check") or br.getDistance("player",Unit) <= spellRange or DistanceSkip == true or br.inRange(SpellID,Unit)) then + -- if br.getSpellCD(SpellID) < select(4,GetNetStats()) / 1000 + if (br.getSpellCD(SpellID) < select(4, br._G.GetNetStats()) / 1000) and (br.getOptionCheck("Skip Distance Check") or br.getDistance("player", Unit) <= spellRange or DistanceSkip == true or br.inRange(SpellID, Unit)) then -- if spam is not allowed if SpamAllowed == false then -- get our last/current cast - if br.timersTable == nil or (br.timersTable ~= nil and (br.timersTable[SpellID] == nil or br.timersTable[SpellID] <= br._G.GetTime() -0.6)) then - if (FacingCheck == true or br.getFacing("player",Unit) == true) and (br.GetUnitIsUnit("player",Unit) or br.getLineOfSight("player",Unit) == true) then + if br.timersTable == nil or (br.timersTable ~= nil and (br.timersTable[SpellID] == nil or br.timersTable[SpellID] <= br._G.GetTime() - 0.6)) then + if (FacingCheck == true or br.getFacing("player", Unit) == true) and (br.GetUnitIsUnit("player", Unit) or br.getLineOfSight("player", Unit) == true) then if noCast then return true else br.timersTable[SpellID] = br._G.GetTime() br.currentTarget = br._G.UnitGUID(Unit) - br._G.RunMacroText("/cast [@"..Unit.."] "..br._G.GetSpellInfo(SpellID)) + br._G.RunMacroText("/cast [@" .. Unit .. "] " .. br._G.GetSpellInfo(SpellID)) --lastSpellCast = SpellID -- change main button icon --if br.getOptionCheck("Start/Stop BadRotations") then - br.mainButton:SetNormalTexture(select(3,br._G.GetSpellInfo(SpellID))) - br.lastSpellCast = SpellID - br.lastSpellTarget = br._G.UnitGUID(Unit) + br.mainButton:SetNormalTexture(select(3, br._G.GetSpellInfo(SpellID))) + br.lastSpellCast = SpellID + br.lastSpellTarget = br._G.UnitGUID(Unit) --end return true end end end - elseif (FacingCheck == true or br.getFacing("player",Unit) == true) and (br.GetUnitIsUnit("player",Unit) or br.getLineOfSight("player",Unit) == true) then + elseif (FacingCheck == true or br.getFacing("player", Unit) == true) and (br.GetUnitIsUnit("player", Unit) or br.getLineOfSight("player", Unit) == true) then if noCast then return true else br.currentTarget = br._G.UnitGUID(Unit) - br._G.RunMacroText("/cast [@"..Unit.."] "..br._G.GetSpellInfo(SpellID)) + br._G.RunMacroText("/cast [@" .. Unit .. "] " .. br._G.GetSpellInfo(SpellID)) --if br.getOptionCheck("Start/Stop BadRotations") then - br.mainButton:SetNormalTexture(select(3,br._G.GetSpellInfo(SpellID))) - br.lastSpellCast = SpellID - br.lastSpellTarget = br._G.UnitGUID(Unit) + br.mainButton:SetNormalTexture(select(3, br._G.GetSpellInfo(SpellID))) + br.lastSpellCast = SpellID + br.lastSpellTarget = br._G.UnitGUID(Unit) --end return true end @@ -403,72 +420,75 @@ function br.castSpellMacro(Unit,SpellID,FacingCheck,MovementCheck,SpamAllowed,Kn end return false end + -- Used in openers -function br.castOpener(spellIndex,flag,index,checkdistance) +function br.castOpener(spellIndex, flag, index, checkdistance) local spellCast = br.player.spells[spellIndex] local castable = br.player.cast.able[spellIndex] local castSpell = br.player.cast[spellIndex] - local spellName = select(1,br._G.GetSpellInfo(spellCast)) - local maxRange = select(6,br._G.GetSpellInfo(spellCast)) + local spellName = select(1, br._G.GetSpellInfo(spellCast)) + local maxRange = select(6, br._G.GetSpellInfo(spellCast)) local cooldown = br.player.cd[spellIndex].remain() if not maxRange or maxRange == 0 then maxRange = 5 end if checkdistance == nil then checkdistance = true end if not checkdistance or br.getDistance("target") < maxRange then if (not castable() and (cooldown == 0 or cooldown > br.player.gcdMax)) then - br.castOpenerFail(spellName,flag,index) - -- Print(index..": "..spellName.." (Uncastable)"); - -- br._G[flag] = true; + br.castOpenerFail(spellName, flag, index) + -- Print(index..": "..spellName.." (Uncastable)"); + -- br._G[flag] = true; -- return true - else + else if castSpell() then if br.player.opener[flag] == nil then - br._G.print(index..": "..spellName) + br._G.print(index .. ": " .. spellName) br.player.opener[flag] = true elseif br.player.opener[flag] ~= true then - br._G.print(index..": "..spellName) + br._G.print(index .. ": " .. spellName) br.player.opener[flag] = true end return true end - end + end end end -function br.castOpenerFail(spellName,flag,index) + +function br.castOpenerFail(spellName, flag, index) if br.player.opener[flag] == nil then - br._G.print(index..": "..spellName.." (Uncastable)") + br._G.print(index .. ": " .. spellName .. " (Uncastable)") br.player.opener[flag] = true elseif br.player.opener[flag] ~= true then - br._G.print(index..": "..spellName.." (Uncastable)") + br._G.print(index .. ": " .. spellName .. " (Uncastable)") br.player.opener[flag] = true end return true end + function br.castMouseoverHealing(Class) if br._G.UnitAffectingCombat("player") then local spellTable = { - ["Druid"] = { heal = 8936,dispel = 88423 } + ["Druid"] = { heal = 8936, dispel = 88423 } } local npcTable = { - 71604,-- Contaminated Puddle- Immerseus - SoO - 71995,-- Norushen - 71996,-- Norushen - 72000,-- Norushen - 71357,-- Wrathion + 71604, -- Contaminated Puddle- Immerseus - SoO + 71995, -- Norushen + 71996, -- Norushen + 72000, -- Norushen + 71357, -- Wrathion } - local SpecialTargets = { "mouseover","target","focus"} + local SpecialTargets = { "mouseover", "target", "focus" } -- local dispelid = spellTable[Class].dispel - for i = 1,#SpecialTargets do + for i = 1, #SpecialTargets do local target = SpecialTargets[i] if br.GetUnitExists(target) and not br._G.UnitIsPlayer(target) then - local npcID = tonumber(string.match(br._G.UnitGUID(target),"-(%d+)-%x+$")) - for j = 1,#npcTable do + local npcID = tonumber(string.match(br._G.UnitGUID(target), "-(%d+)-%x+$")) + for j = 1, #npcTable do if npcID == npcTable[j] then -- Dispel - for n = 1,40 do - local buff,_,_,bufftype = br._G.UnitDebuff(target,n) + for n = 1, 40 do + local buff, _, _, bufftype = br._G.UnitDebuff(target, n) if buff then if bufftype == "Magic" or bufftype == "Curse" or bufftype == "Poison" then - if br.castSpell(target,88423,true,false) then + if br.castSpell(target, 88423, true, false) then return end end @@ -479,7 +499,7 @@ function br.castMouseoverHealing(Class) -- Heal local npcHP = br.getHP(target) if npcHP < 100 then - if br.castSpell(target,spellTable[Class].heal,true) then + if br.castSpell(target, spellTable[Class].heal, true) then return end end @@ -489,14 +509,15 @@ function br.castMouseoverHealing(Class) end end end + function br.isCastingTime(lagTolerance) lagTolerance = lagTolerance or 0 if br._G.UnitCastingInfo("player") ~= nil then - if select(5,br._G.UnitCastingInfo("player")) - br._G.GetTime() <= lagTolerance then + if select(5, br._G.UnitCastingInfo("player")) - br._G.GetTime() <= lagTolerance then return true end elseif br._G.UnitChannelInfo("player") ~= nil then - if select(5,br._G.UnitChannelInfo("player")) - br._G.GetTime() <= lagTolerance then + if select(5, br._G.UnitChannelInfo("player")) - br._G.GetTime() <= lagTolerance then return true end elseif (br._G.GetSpellCooldown(br._G.GetSpellInfo(61304)) ~= nil and br._G.GetSpellCooldown(br._G.GetSpellInfo(61304)) <= lagTolerance) then @@ -505,26 +526,32 @@ function br.isCastingTime(lagTolerance) return false end end + -- if getCastTime("Healing Touch")<3 then function br.getCastTime(spellID) if spellID == 202767 then - if select(3,br._G.GetSpellInfo(202767)) == 1392545 then spellID = 202767 - elseif select(3,br._G.GetSpellInfo(202767)) == 1392543 then spellID = 202768 - elseif select(3,br._G.GetSpellInfo(202767)) == 1392542 then spellID = 202771 - end - end - local castTime = select(4,br._G.GetSpellInfo(spellID))/1000 + if select(3, br._G.GetSpellInfo(202767)) == 1392545 then + spellID = 202767 + elseif select(3, br._G.GetSpellInfo(202767)) == 1392543 then + spellID = 202768 + elseif select(3, br._G.GetSpellInfo(202767)) == 1392542 then + spellID = 202771 + end + end + local castTime = select(4, br._G.GetSpellInfo(spellID)) / 1000 return castTime end + function br.getCastTimeRemain(unit) if br._G.UnitCastingInfo(unit) ~= nil then - return select(5,br._G.UnitCastingInfo(unit))/1000 - br._G.GetTime() + return select(5, br._G.UnitCastingInfo(unit)) / 1000 - br._G.GetTime() elseif br._G.UnitChannelInfo(unit) ~= nil then - return select(5,br._G.UnitChannelInfo(unit))/1000 - br._G.GetTime() + return select(5, br._G.UnitChannelInfo(unit)) / 1000 - br._G.GetTime() else return 0 end end + -- if isCasting() == true then function br.castingUnit(Unit) if Unit == nil then Unit = "player" end @@ -536,8 +563,9 @@ function br.castingUnit(Unit) return false end end + -- if br.isCastingSpell(12345) == true then -function br.isCastingSpell(spellID,unit) +function br.isCastingSpell(spellID, unit) if unit == nil then unit = "player" end local spellName = br._G.GetSpellInfo(spellID) local spellCasting = br._G.UnitCastingInfo(unit) @@ -550,8 +578,9 @@ function br.isCastingSpell(spellID,unit) return false end end + -- if isCasting(12345,"target") then -function br.isCasting(SpellID,Unit) +function br.isCasting(SpellID, Unit) if br.GetUnitIsVisible(Unit) and br._G.UnitCastingInfo(Unit) then if br._G.UnitCastingInfo(Unit) == br._G.GetSpellInfo(SpellID) then return true @@ -560,6 +589,7 @@ function br.isCasting(SpellID,Unit) return false end end + -- if br.isCastingSpell(12345) == true then function br.isUnitCasting(unit) if unit == nil then unit = "player" end @@ -575,18 +605,19 @@ function br.isUnitCasting(unit) end local castTimers -function br.createCastFunction(thisUnit,castType,minUnits,effectRng,spellID,index,predict,predictPad,enemies,debug) - -- Invalid Spell ID Check - if br._G.GetSpellInfo(spellID) == nil then br._G.print("Invalid Spell ID: "..spellID.." for key: "..index) end - local spellCast = spellID +function br.createCastFunction(thisUnit, castType, minUnits, effectRng, spellID, index, predict, predictPad, enemies, + debug) + -- Invalid Spell ID Check + if br._G.GetSpellInfo(spellID) == nil then br._G.print("Invalid Spell ID: " .. spellID .. " for key: " .. index) end + local spellCast = spellID local baseSpellID = br._G.FindBaseSpellByID(spellID) local overrideSpellID = br._G.FindSpellOverrideByID(spellID) local baseSpellName = br._G.GetSpellInfo(baseSpellID) - local spellName,_,icon,castTime,minRange,maxRange = br._G.GetSpellInfo(spellID) + local spellName, _, icon, castTime, minRange, maxRange = br._G.GetSpellInfo(spellID) local spellType = br.getSpellType(baseSpellName) if castTimers == nil then castTimers = {} end if castTimers[spellID] == nil then castTimers[spellID] = br._G.GetTime() end - if maxRange == 0 then _,_,_,_,minRange,maxRange = br._G.GetSpellInfo(baseSpellID) end + if maxRange == 0 then _, _, _, _, minRange, maxRange = br._G.GetSpellInfo(baseSpellID) end -- Quaking helper - M+ Affix if br.getOptionCheck("Quaking Helper") then --Detect channels @@ -600,7 +631,7 @@ function br.createCastFunction(thisUnit,castType,minUnits,effectRng,spellID,inde -- Quake check local quakeRemain = br.getDebuffRemain("player", 240448) if quakeRemain > 0 then - if (castTime > 0 and quakeRemain <= ((castTime+300)/1000)) or (castTime == 0 and channeledSpell and quakeRemain < 1.5) then + if (castTime > 0 and quakeRemain <= ((castTime + 300) / 1000)) or (castTime == 0 and channeledSpell and quakeRemain < 1.5) then return false end end @@ -619,14 +650,17 @@ function br.createCastFunction(thisUnit,castType,minUnits,effectRng,spellID,inde if debug == nil then debug = false end -- We should already have enemies counts, so let's get them instead of calculating them again. if enemies == nil then - if (castType == "norm" or castType == "pet") and br.player.enemies["yards"..effectRng.."f"] ~= nil then enemies = #br.player.enemies["yards"..effectRng.."f"] end - if castType == "cone" and br.player.enemies["yards"..effectRng.."c"] ~= nil then enemies = #br.player.enemies["yards"..effectRng.."c"] end - if castType == "rect" and br.player.enemies["yards"..effectRng.."r"] ~= nil then enemies = #br.player.enemies["yards"..effectRng.."r"] end + if (castType == "norm" or castType == "pet") and br.player.enemies["yards" .. effectRng .. "f"] ~= nil then enemies = # + br.player.enemies["yards" .. effectRng .. "f"] end + if castType == "cone" and br.player.enemies["yards" .. effectRng .. "c"] ~= nil then enemies = #br.player + .enemies["yards" .. effectRng .. "c"] end + if castType == "rect" and br.player.enemies["yards" .. effectRng .. "r"] ~= nil then enemies = #br.player + .enemies["yards" .. effectRng .. "r"] end if castType == "aoe" then - if thisUnit == "player" and br.player.enemies["yards"..effectRng] ~= nil then - enemies = #br.player.enemies["yards"..effectRng] - elseif br.player.enemies["yards"..effectRng.."t"] ~= nil then - enemies = #br.player.enemies["yards"..effectRng.."t"] + if thisUnit == "player" and br.player.enemies["yards" .. effectRng] ~= nil then + enemies = #br.player.enemies["yards" .. effectRng] + elseif br.player.enemies["yards" .. effectRng .. "t"] ~= nil then + enemies = #br.player.enemies["yards" .. effectRng .. "t"] end end end @@ -639,12 +673,13 @@ function br.createCastFunction(thisUnit,castType,minUnits,effectRng,spellID,inde br.botCast = true -- Used by old Queue Cast br.botSpell = spellID -- Used by old Queue Cast -- Condemn Patch (Blizz is an small indie developer!) - if spellID == br.player.spells.condemn or spellID == br.player.spells.condemnMassacre then spellName = br._G.GetSpellInfo(br.player.spells.execute) end + if spellID == br.player.spells.condemn or spellID == br.player.spells.condemnMassacre then spellName = br._G + .GetSpellInfo(br.player.spells.execute) end -- br._G.print("Spell: "..tostring(spellName).." - UnitName: "..tostring(br._G.UnitName(thisUnit)).." - Unit: "..tostring(thisUnit)) - br._G.CastSpellByName(spellName,thisUnit) + br._G.CastSpellByName(spellName, thisUnit) if br._G.IsAoEPending() then - local X,Y,Z = br._G.ObjectPosition(thisUnit) - br._G.ClickPosition(X,Y,Z) + local X, Y, Z = br._G.ObjectPosition(thisUnit) + br._G.ClickPosition(X, Y, Z) end -- add to cast timer castTimers[spellID] = br._G.GetTime() + 1 @@ -659,7 +694,7 @@ function br.createCastFunction(thisUnit,castType,minUnits,effectRng,spellID,inde end -- Talent Check local function hasTalent(spellID) - for k,v in pairs(br.player.spells.talents) do + for k, v in pairs(br.player.spells.talents) do if spellID == v then return br.player.talent[k] end end return true @@ -673,59 +708,78 @@ function br.createCastFunction(thisUnit,castType,minUnits,effectRng,spellID,inde end -- Queen's Court - BfA local function queensCourtCastCheck(spellID) - local queensCourtEncounter = br.UnitDebuffID("player",304409) -- EJ_GetEncounterInfo(2311) + local queensCourtEncounter = br.UnitDebuffID("player", 304409) -- EJ_GetEncounterInfo(2311) return queensCourtEncounter == nil or (queensCourtEncounter ~= nil and br.lastCastTable.tracker[1] ~= spellID) end -- Base Spell Availablility Check if ((baseSpellID == spellID or overrideSpellID == spellID) and (br.empowerID == nil or br.empowerID == 0) - and ((thisUnit ~= nil and br._G.UnitIsUnit(thisUnit, "target") and br._G.IsUsableSpell(spellID)) or true) and not select(2,br._G.IsUsableSpell(spellID)) -- Usability Checks - and (castTimers[spellID] < br._G.GetTime()) and br.getSpellCD(spellID) <= br:getUpdateRate() - and (br.getSpellCD(61304) <= 0 or select(2,br._G.GetSpellBaseCooldown(spellID)) <= 0 - or (br.getCastTime(spellID) > 0 and br.getCastTimeRemain("player") <= br:getUpdateRate())) -- Cooldown Checks - and (br.isKnown(spellID) or castType == "known" or spellID == br.player.spells.condemn or spellID == br.player.spells.condemnMassacre) -- Known/Current Checks - and hasTalent(spellID) and hasEssence() and not br.isIncapacitated(spellID) and queensCourtCastCheck(spellID) - and (not (br._G.IsAutoRepeatSpell(br._G.GetSpellInfo(spellID)) or (spellID == 6603 and br._G.IsCurrentSpell(spellID)))) and not br.hasNoControl(spellID) -- Talent/Essence/Incapacitated/Special Checks - and (thisUnit == nil or castType ~= "dead" or (thisUnit ~= nil and castType == "dead" and br._G.UnitIsDeadOrGhost(thisUnit)))) -- Dead Check + and ((thisUnit ~= nil and br._G.UnitIsUnit(thisUnit, "target") and br._G.IsUsableSpell(spellID)) or true) and not select(2, br._G.IsUsableSpell(spellID)) -- Usability Checks + and (castTimers[spellID] < br._G.GetTime()) and br.getSpellCD(spellID) <= br:getUpdateRate() + and (br.getSpellCD(61304) <= 0 or select(2, br._G.GetSpellBaseCooldown(spellID)) <= 0 + or (br.getCastTime(spellID) > 0 and br.getCastTimeRemain("player") <= br:getUpdateRate())) -- Cooldown Checks + and (br.isKnown(spellID) or castType == "known" or spellID == br.player.spells.condemn or spellID == br.player.spells.condemnMassacre) -- Known/Current Checks + and hasTalent(spellID) and hasEssence() and not br.isIncapacitated(spellID) and queensCourtCastCheck(spellID) + and (not (br._G.IsAutoRepeatSpell(br._G.GetSpellInfo(spellID)) or (spellID == 6603 and br._G.IsCurrentSpell(spellID)))) and not br.hasNoControl(spellID) -- Talent/Essence/Incapacitated/Special Checks + and (thisUnit == nil or castType ~= "dead" or (thisUnit ~= nil and castType == "dead" and br._G.UnitIsDeadOrGhost(thisUnit)))) -- Dead Check or spellID == br.empowerID then if castType == "known" then castType = "norm" end - local function printReport(debugOnly,debugReason,thisCount) + local function printReport(debugOnly, debugReason, thisCount) if debugReason == nil then debugReason = "" end if ((br.isChecked("Display Failcasts") and not debugOnly) or br.isChecked("Cast Debug")) and not debug then if debugReason == "No Unit" then - br.player.ui.debug("Spell: "..spellName.." failed to cast because there was not unit found in "..maxRange.."yrds.") + br.player.ui.debug("Spell: " .. + spellName .. " failed to cast because there was not unit found in " .. maxRange .. "yrds.") elseif debugReason == "Below Min Units" then - br.player.ui.debug("Spell: "..spellName.." failed to cast because there are "..thisCount.." enemies in "..maxRange.."yrds, but "..minUnits.." are needed to cast.") + br.player.ui.debug("Spell: " .. + spellName .. + " failed to cast because there are " .. + thisCount .. " enemies in " .. maxRange .. "yrds, but " .. minUnits .. " are needed to cast.") elseif debugReason == "Below Min Units Facing" then - br.player.ui.debug("Spell: "..spellName.." failed to cast because there are "..thisCount.." enemies in "..maxRange.."yrds in front, but "..minUnits.." are needed to cast.") + br.player.ui.debug("Spell: " .. + spellName .. + " failed to cast because there are " .. + thisCount .. " enemies in " .. maxRange .. "yrds in front, but " .. minUnits .. + " are needed to cast.") elseif debugReason == "Below Min Units Cone" then - br.player.ui.debug("Spell: "..spellName.." failed to cast because there are "..thisCount.." enemies in "..maxRange.."yrds in an "..effectRng.."deg cone, but "..minUnits.." are needed to cast.") + br.player.ui.debug("Spell: " .. + spellName .. + " failed to cast because there are " .. + thisCount .. + " enemies in " .. + maxRange .. "yrds in an " .. effectRng .. "deg cone, but " .. minUnits .. " are needed to cast.") elseif debugReason == "Below Min Units Rect" then - br.player.ui.debug("Spell: "..spellName.." failed to cast because there are "..thisCount.." enemies in "..maxRange.."yrds by "..effectRng.."yrd rectange, but "..minUnits.." are needed to cast.") + br.player.ui.debug("Spell: " .. + spellName .. + " failed to cast because there are " .. + thisCount .. + " enemies in " .. + maxRange .. "yrds by " .. effectRng .. "yrd rectange, but " .. minUnits .. " are needed to cast.") elseif debugReason == "Not Dead" then - br.player.ui.debug("Spell: "..spellName.." failed to cast because Unit is not dead.") + br.player.ui.debug("Spell: " .. spellName .. " failed to cast because Unit is not dead.") elseif debugReason == "No Range" then - br.player.ui.debug("Spell: "..spellName.." failed to cast because Unit is not in range.") + br.player.ui.debug("Spell: " .. spellName .. " failed to cast because Unit is not in range.") elseif debugReason == "Not Safe" then - br.player.ui.debug("Spell: "..spellName.." failed to cast because it is not safe to aoe.") + br.player.ui.debug("Spell: " .. spellName .. " failed to cast because it is not safe to aoe.") elseif debugReason == "Invalid Unit" then if not br._G.UnitIsFriend(thisUnit, "player") and br.units[thisUnit] == nil then - br.player.ui.debug("Spell: "..spellName.." failed to cast because Unit is not player, friend, or in br.units.") + br.player.ui.debug("Spell: " .. + spellName .. " failed to cast because Unit is not player, friend, or in br.units.") elseif not br.getLineOfSight(thisUnit) then - br.player.ui.debug("Spell: "..spellName.." failed to cast because Unit is out line of sight.") + br.player.ui.debug("Spell: " .. spellName .. " failed to cast because Unit is out line of sight.") else - br.player.ui.debug("Spell: "..spellName.." failed to cast for unknown reason.") + br.player.ui.debug("Spell: " .. spellName .. " failed to cast for unknown reason.") end else br._G.print("|cffFF0000Error: |r Failed to cast. - " - .."Spell: "..spellName - ..", ID: "..spellID - ..", Type: "..spellType - ..", Min Range: "..minRange - ..", Max Range: "..maxRange - ..", Distance: "..br.getDistance(thisUnit) - ..", SpellRange: "..tostring(br._G.IsSpellInRange(spellName,thisUnit) == 1) - ..", thisUnit: "..tostring(thisUnit) + .. "Spell: " .. spellName + .. ", ID: " .. spellID + .. ", Type: " .. spellType + .. ", Min Range: " .. minRange + .. ", Max Range: " .. maxRange + .. ", Distance: " .. br.getDistance(thisUnit) + .. ", SpellRange: " .. tostring(br._G.IsSpellInRange(spellName, thisUnit) == 1) + .. ", thisUnit: " .. tostring(thisUnit) ) end end @@ -735,50 +789,54 @@ function br.createCastFunction(thisUnit,castType,minUnits,effectRng,spellID,inde -- local unitAssigned = false if thisUnit == nil then if castType == "norm" or castType == "dead" or castType == "rect" or castType == "cone" then - thisUnit = br.getSpellUnit(baseSpellID,false,minRange,maxRange,spellType) - elseif castType == "groundCC" or "groundLocation" then return + thisUnit = br.getSpellUnit(baseSpellID, false, minRange, maxRange, spellType) + elseif castType == "groundCC" or "groundLocation" then + return else - thisUnit = br.getSpellUnit(baseSpellID,true,minRange,maxRange,spellType) + thisUnit = br.getSpellUnit(baseSpellID, true, minRange, maxRange, spellType) end -- if thisUnit ~= nil and thisUnit ~= "None" then unitAssigned = true end end -- Cast Ground AOE at "Best" Locaton - if thisUnit == "best" then + if thisUnit == "best" then if debug then return true end - return br.castGroundAtBestLocation(spellCast,effectRng,minUnits,maxRange,minRange,castType,castTime) + return br.castGroundAtBestLocation(spellCast, effectRng, minUnits, maxRange, minRange, castType, castTime) end -- Cast Ground AOE at Player/Target Location if thisUnit == "playerGround" or thisUnit == "targetGround" or castType == "groundCC" then local targetUnit targetUnit = thisUnit == "playerGround" and "player" or "target" if castType == "groundCC" then targetUnit = thisUnit end - if (br.getDistance(targetUnit) < maxRange or br._G.IsSpellInRange(spellName,targetUnit) == 1) then + if (br.getDistance(targetUnit) < maxRange or br._G.IsSpellInRange(spellName, targetUnit) == 1) then if debug then return true end - return br.castGroundAtUnit(spellCast,effectRng,minUnits,maxRange,minRange,castType,targetUnit) + return br.castGroundAtUnit(spellCast, effectRng, minUnits, maxRange, minRange, castType, targetUnit) end end -- Cast Ground AOE at Provide X/Y Location if thisUnit == "groundLocation" then if debug then return true end - return br.castGroundLocation(castType,minUnits,baseSpellID,maxRange,minRange,effectRng) + return br.castGroundLocation(castType, minUnits, baseSpellID, maxRange, minRange, effectRng) + end + if thisUnit == "None" then + printReport(true, "No Unit") + return false end - if thisUnit == "None" then printReport(true,"No Unit") return false end -- Other Cast Conditions - Require Target if thisUnit ~= nil and thisUnit ~= "None" - and (br.GetUnitIsUnit(thisUnit,"player") or br.GetUnitIsFriend(thisUnit,"player") or br.units[thisUnit] ~= nil or br.getLineOfSight(thisUnit)) + and (br.GetUnitIsUnit(thisUnit, "player") or br.GetUnitIsFriend(thisUnit, "player") or br.units[thisUnit] ~= nil or br.getLineOfSight(thisUnit)) then -- Range Check local inRange = function(minRange, maxRange) - local distance = castType == "pet" and br.getDistance(thisUnit,"pet") or br.getDistance(thisUnit) - return br._G.IsSpellInRange(spellName, thisUnit) == 1 or (distance >= minRange and distance < maxRange-1) + local distance = castType == "pet" and br.getDistance(thisUnit, "pet") or br.getDistance(thisUnit) + return br._G.IsSpellInRange(spellName, thisUnit) == 1 or (distance >= minRange and distance < maxRange - 1) end - if --[[br._G.IsSpellInRange(spellName,thisUnit) == 1 or]] inRange(minRange,maxRange) then + if --[[br._G.IsSpellInRange(spellName,thisUnit) == 1 or]] inRange(minRange, maxRange) then -- Dead Friend if castType == "dead" then - if br._G.UnitIsPlayer(thisUnit) and br.GetUnitIsDeadOrGhost(thisUnit) and br.GetUnitIsFriend(thisUnit,"player") then - return castingSpell(thisUnit,spellID,spellName,icon,castType,printReport,debug) + if br._G.UnitIsPlayer(thisUnit) and br.GetUnitIsDeadOrGhost(thisUnit) and br.GetUnitIsFriend(thisUnit, "player") then + return castingSpell(thisUnit, spellID, spellName, icon, castType, printReport, debug) else - return printReport(false,"Not Dead") + return printReport(false, "Not Dead") end end -- AOE/ST Casts @@ -786,44 +844,44 @@ function br.createCastFunction(thisUnit,castType,minUnits,effectRng,spellID,inde if (castType == "ground" or castType == "aoe" or castType == "cone" or castType == "rect") then -- Failsafe, incase we were unable to retrieve enemies counts local enemyCount = enemies - or ((castType == "ground" or castType == "aoe") and #br.getEnemies("player",maxRange)) - or (castType == "cone" and br.getEnemiesInCone(180,effectRng)) - or (castType == "rect" and br.getEnemiesInRect(effectRng,maxRange)) + or ((castType == "ground" or castType == "aoe") and #br.getEnemies("player", maxRange)) + or (castType == "cone" and br.getEnemiesInCone(180, effectRng)) + or (castType == "rect" and br.getEnemiesInRect(effectRng, maxRange)) or 0 - if enemyCount >= minUnits and (br.isSafeToAoE(spellID,thisUnit,effectRng,minUnits,castType,enemyCount) or br.isDummy("target")) then + if enemyCount >= minUnits and (br.isSafeToAoE(spellID, thisUnit, effectRng, minUnits, castType, enemyCount) or br.isDummy("target")) then if castType == "ground" then if debug then return true end - return br.castGround(thisUnit,spellCast,maxRange,minRange,effectRng,castTime) + return br.castGround(thisUnit, spellCast, maxRange, minRange, effectRng, castTime) else - return castingSpell(thisUnit,spellID,spellName,icon,castType,printReport,debug) + return castingSpell(thisUnit, spellID, spellName, icon, castType, printReport, debug) end else - if castType == "cone" then return printReport(false,"Below Min Units Cone",enemyCount) end - if castType == "rect" then return printReport(false,"Below Min Units Rect",enemyCount) end - return printReport(false,"Below Min Units",enemyCount) + if castType == "cone" then return printReport(false, "Below Min Units Cone", enemyCount) end + if castType == "rect" then return printReport(false, "Below Min Units Rect", enemyCount) end + return printReport(false, "Below Min Units", enemyCount) end end -- Cast Non-AOE - if (castType == "norm" or castType == "pet") and ((castType == "norm" and br.getFacing("player",thisUnit)) or (castType == "pet" and br.getFacing("pet",thisUnit)) - or spellType == "Helpful" or spellType == "Unknown") + if (castType == "norm" or castType == "pet") and ((castType == "norm" and br.getFacing("player", thisUnit)) or (castType == "pet" and br.getFacing("pet", thisUnit)) + or spellType == "Helpful" or spellType == "Unknown") then -- Failsafe, incase we were unable to retrieve enemies counts - local enemyFacingCount = enemies or #br.getEnemies("player",maxRange,false,true) or 0 + local enemyFacingCount = enemies or #br.getEnemies("player", maxRange, false, true) or 0 if (minUnits == 1 --[[and br._G.IsSpellInRange(spellName, thisUnit) == 1]]) or (enemyFacingCount >= minUnits) or spellType == "Helpful" or spellType == "Unknown" then - return castingSpell(thisUnit,spellID,spellName,icon,castType,printReport,debug) + return castingSpell(thisUnit, spellID, spellName, icon, castType, printReport, debug) else - return printReport(false,"Below Min Units Facing",enemyFacingCount) + return printReport(false, "Below Min Units Facing", enemyFacingCount) end end return false else - return printReport(false,"No Range") + return printReport(false, "No Range") end else - return printReport(false,"Invalid Unit") + return printReport(false, "Invalid Unit") end return printReport() - end + end return false end @@ -832,13 +890,13 @@ function br.castQueue() -- Catch for spells not registering on Combat log if br.player ~= nil then if br.player.queue ~= nil and #br.player.queue > 0 and not br._G.IsAoEPending() then - for i=1, #br.player.queue do + for i = 1, #br.player.queue do local thisUnit = br.player.queue[i].target local debug = br.player.queue[i].debug local minUnits = br.player.queue[i].minUnits local effectRng = br.player.queue[i].effectRng local spellID = br.player.queue[i].id - if br.createCastFunction(thisUnit,debug,minUnits,effectRng,spellID) then return end + if br.createCastFunction(thisUnit, debug, minUnits, effectRng, spellID) then return end end end end diff --git a/System/Functions/Combat.lua b/System/Functions/Combat.lua index 75cecf81b..4f8a793e3 100644 --- a/System/Functions/Combat.lua +++ b/System/Functions/Combat.lua @@ -19,6 +19,7 @@ function br.canAoE(unit, distance) end return true end + -- if canAttack("player","target") then function br.canAttack(Unit1, Unit2) if Unit1 == nil then @@ -29,6 +30,7 @@ function br.canAttack(Unit1, Unit2) end return br._G.UnitCanAttack(Unit1, Unit2) end + function br.canDisarm(Unit) if br.DisarmedTarget == nil then br.DisarmedTarget = 0 @@ -49,6 +51,7 @@ function br.canDisarm(Unit) end end end + -- if br.getCombatTime() <= 5 then function br.getCombatTime() local combatStarted = br.data.settings[br.selectedSpec]["Combat Started"] @@ -67,6 +70,7 @@ function br.getCombatTime() br.data.settings[br.selectedSpec]["Combat Time"] = combatTime return (math.floor(combatTime * 1000) / 1000) end + function br.getOoCTime() local combatStarted = br.data.settings[br.selectedSpec]["Combat Started"] local combatTime @@ -80,6 +84,7 @@ function br.getOoCTime() end return (math.floor(combatTime * 1000) / 1000) end + -- if getLowAllies(60) > 3 then function br.getLowAllies(Value) local lowAllies = 0 @@ -90,6 +95,7 @@ function br.getLowAllies(Value) end return lowAllies end + -- if getLowAlliesInTable(60, nNove) > 3 then function br.getLowAlliesInTable(Value, unitTable) local lowAllies = 0 @@ -100,6 +106,7 @@ function br.getLowAlliesInTable(Value, unitTable) end return lowAllies end + -- if getNumEnemies("target",10) >= 3 then function br.getNumEnemies(Unit, Radius) return #br.getEnemies(Unit, Radius) @@ -113,9 +120,9 @@ function br.isIncapacitated(spellID) event = br._G.C_LossOfControl.GetActiveLossOfControlData(i) if event then local eventType = event.locType - -- br._G.print("Incapacitated: "..tostring(event.locType).." - Can Regain Control: "..tostring(br.canRegainControl(spellID, event.locType))) + -- br._G.print("Incapacitated: " .. tostring(event.locType) .. " - Can Regain Control: " .. tostring(br.canRegainControl(spellID, event.locType))) if not br.canRegainControl(spellID, eventType) - and ( eventType ~= "ROOT" and eventType ~= "SNARE") + and (eventType ~= "ROOT" and eventType ~= "SNARE") then return true end @@ -124,6 +131,7 @@ function br.isIncapacitated(spellID) end return false end + function br.canRegainControl(spellID, controlEvent) local class = select(3, br._G.UnitClass("player")) -- Warrior @@ -217,6 +225,7 @@ function br.canRegainControl(spellID, controlEvent) end return false end + -- if hasNoControl(12345) == true then function br.hasNoControl(spellID) local event @@ -225,13 +234,14 @@ function br.hasNoControl(spellID) for i = 0, eventIndex do event = br._G.C_LossOfControl.GetActiveLossOfControlData(i) if event then - -- br._G.print("Has No Control: "..tostring(event.locType).." - Can Regain Control: "..tostring(br.canRegainControl(spellID, event.locType))) - return br.canRegainControl(spellID, event.locType) + -- br._G.print("Has No Control: " .. tostring(event.locType) .. " - Can Regain Control: " .. tostring(br.canRegainControl(spellID, event.locType))) + return not br.canRegainControl(spellID, event.locType) end end end return false end + -- if br.hasThreat("target") then function br.hasThreat(unit, playerUnit) -- Early Exit @@ -240,8 +250,8 @@ function br.hasThreat(unit, playerUnit) if br.isDummy(unit) and br.getDistance("target", unit) < 8 then return true end -- Damaged Validation if br.damaged[br._G.ObjectPointer(unit)] ~= nil then - if br.isChecked("Cast Debug") then--and not br.GetUnitExists("target") then - br._G.print("[Damage Threat] "..br._G.UnitName(unit).." was attacked, it now hates you.") + if br.isChecked("Threat Debug") then --and not br.GetUnitExists("target") then + br._G.print("[Damage Threat] " .. br._G.UnitName(unit) .. " was attacked, it now hates you.") end return true end @@ -281,18 +291,22 @@ function br.hasThreat(unit, playerUnit) local instance = select(2, br._G.IsInInstance()) -- Unit is Targeting Player/Pet/Party/Raid Validation if targetFriend then - if br.isChecked("Cast Debug") then--and not br.GetObjectExists("target") then - br._G.print("[Targeting Threat] "..br._G.UnitName(br.GetUnit(unit)) .. " is targeting " .. br._G.UnitName(targetUnit)) + if br.isChecked("Threat Debug") then --and not br.GetObjectExists("target") then + br._G.print("[Targeting Threat] " .. + br._G.UnitName(br.GetUnit(unit)) .. " is targeting " .. br._G.UnitName(targetUnit)) end return true end -- Boss Adds Validation if br.isBoss(unit) and unitInCombat and (instance == "party" or instance == "raid") then - if br.isChecked("Cast Debug") then br._G.print("[Boss Threat] "..br._G.UnitName(unit).." has threat with you.") end + if br.isChecked("Threat Debug") then + br._G.print("[Boss Threat] " .. br._G.UnitName(unit) .. + " has threat with you.") + end return true - -- Threat Bypass Validation - -- elseif playerInCombat and br.lists.threatBypass[unitID] ~= nil and #br.getEnemies(unit,20,true) == 0 then - -- return true + -- Threat Bypass Validation + -- elseif playerInCombat and br.lists.threatBypass[unitID] ~= nil and #br.getEnemies(unit,20,true) == 0 then + -- return true end -- Open World Mob Pack Validation if instance == "none" and playerInCombat and not br.isCritter(unitObject) and br.enemy[br._G.ObjectPointer("target")] ~= nil and br.enemy[unitObject] == nil and br.getDistance("target", unitObject) < 8 then @@ -301,8 +315,8 @@ function br.hasThreat(unit, playerUnit) end -- Player Threat Valdation if threatSituation(playerUnit, unit) then - if br.isChecked("Threat Debug") then - br._G.print("[Player Threat] "..br._G.UnitName(playerUnit).." has threat with "..br._G.UnitName(unit)) + if br.isChecked("Threat Debug") then --and not br.GetObjectExists("target") then + br._G.print("[Player Threat] " .. br._G.UnitName(playerUnit) .. " has threat with " .. br._G.UnitName(unit)) end return true end @@ -312,8 +326,9 @@ function br.hasThreat(unit, playerUnit) if br.friend[i] then local thisUnit = br.friend[i].unit if threatSituation(thisUnit, unit) then - if br.isChecked("Cast Debug") then--and not br.GetObjectExists("target") then - br._G.print("[Party/Raid Threat] "..br._G.UnitName(thisUnit).." has threat with "..br._G.UnitName(unit)) + if br.isChecked("Threat Debug") then --and not br.GetObjectExists("target") then + br._G.print("[Party/Raid Threat] " .. + br._G.UnitName(thisUnit) .. " has threat with " .. br._G.UnitName(unit)) end return true end @@ -322,9 +337,11 @@ function br.hasThreat(unit, playerUnit) end return false end + function br.isTanking(unit) return br._G.UnitThreatSituation("player", unit) ~= nil and br._G.UnitThreatSituation("player", unit) >= 2 end + -- if isAggroed("target") then function br.isAggroed(unit) for i = 1, #br.friend do diff --git a/System/Functions/Item.lua b/System/Functions/Item.lua index d482dddab..67b478acc 100644 --- a/System/Functions/Item.lua +++ b/System/Functions/Item.lua @@ -72,7 +72,7 @@ function br.useItem(itemID,thisUnit) if br._G.GetItemCooldown(slotItemID) == 0 then if not br.itemSpamDelay or br._G.GetTime() > br.itemSpamDelay then -- br._G.RunMacroText("/use " .. select(1, GetItemInfo(slotItemID))) - br._G.UseItemByName(select(1,br._G.GetItemInfo(slotItemID)),thisUnit); + br._G.UseItemByName(select(1, br._G.GetItemInfo(slotItemID)), thisUnit); br.itemSpamDelay = br._G.GetTime() + 1 return true end @@ -82,7 +82,7 @@ function br.useItem(itemID,thisUnit) if br._G.GetItemCooldown(itemID) == 0 then if not br.itemSpamDelay or br._G.GetTime() > br.itemSpamDelay then -- br._G.RunMacroText("/use " .. select(1, GetItemInfo(itemID))) - br._G.UseItemByName(select(1,br._G.GetItemInfo(itemID)),thisUnit); + br._G.UseItemByName(select(1, br._G.GetItemInfo(itemID)), thisUnit); br.itemSpamDelay = br._G.GetTime() + 1 return true end diff --git a/System/Functions/Misc.lua b/System/Functions/Misc.lua index b9da612e9..d29e0cea3 100644 --- a/System/Functions/Misc.lua +++ b/System/Functions/Misc.lua @@ -38,6 +38,7 @@ function br.getFallDistance() return zDist end + --if getFallTime() > 2 then function br.getFallTime() if br.fallStarted == nil then @@ -60,11 +61,12 @@ function br.getFallTime() end return br.fallTime end + -- if br.getLineOfSight("target"[,"target"]) then br.doLinesIntersect = function(a, b, c, d) -- parameter conversion - local L1 = {X1 = a.x, Y1 = a.y, X2 = b.x, Y2 = b.y} - local L2 = {X1 = c.x, Y1 = c.y, X2 = d.x, Y2 = d.y} + local L1 = { X1 = a.x, Y1 = a.y, X2 = b.x, Y2 = b.y } + local L2 = { X1 = c.x, Y1 = c.y, X2 = d.x, Y2 = d.y } -- Denominator for ua and ub are the same, so store this calculation d = (L2.Y2 - L2.Y1) * (L1.X2 - L1.X1) - (L2.X2 - L2.X1) * (L1.Y2 - L1.Y1) @@ -91,7 +93,7 @@ br.doLinesIntersect = function(a, b, c, d) if (ua >= 0 and ua <= 1 and ub >= 0 and ub <= 1) then local x = L1.X1 + (ua * (L1.X2 - L1.X1)) local y = L1.Y1 + (ua * (L1.Y2 - L1.Y1)) - return true, {x = x, y = y} + return true, { x = x, y = y } end return false @@ -142,18 +144,19 @@ function br.carapaceMath(Unit1, Unit2) if tentX ~= nil then for i = 1, #br.tentCache do if br.tentCache[i]["tentX"] ~= nil then - local a = {x = br.tentCache[i]["tentX"], y = br.tentCache[i]["tentY"]} - local b = {x = br.tentCache[i]["tentX2"], y = br.tentCache[i]["tentY2"]} - local c = {x = tX, y = tY} - local d = {x = pX, y = pY} + local a = { x = br.tentCache[i]["tentX"], y = br.tentCache[i]["tentY"] } + local b = { x = br.tentCache[i]["tentX2"], y = br.tentCache[i]["tentY2"] } + local c = { x = tX, y = tY } + local d = { x = pX, y = pY } if tX ~= nil then if br.doLinesIntersect(a, b, c, d) then --[[ LibDraw.SetColor(255,0,0) LibDraw.Line(tentCache[i]["tentX"],tentCache[i]["tentY"],tentCache[i]["tentZ"],tentCache[i]["tentX2"],tentCache[i]["tentY2"],tentCache[i]["tentZ"]) - ]] tentCheck = + ]] + tentCheck = false table.insert(tentfinal, tentCheck) - --[[ else + --[[ else LibDraw.SetColor(0,255,0) LibDraw.Line(tentCache[i]["tentX"],tentCache[i]["tentY"],tentCache[i]["tentZ"],tentCache[i]["tentX2"],tentCache[i]["tentY2"],tentCache[i]["tentZ"]) ]] @@ -183,8 +186,8 @@ function br.getLineOfSight(Unit1, Unit2) end local skipLoSTable = br.lists.los if skipLoSTable[br.GetObjectID(Unit1)] or skipLoSTable[br.GetObjectID(Unit2)] or -- Kyrian Hunter Ability - (Unit1 and Unit1 ~= "player" and br.getDebuffRemain(Unit1, 308498) > 0) or - (Unit2 and Unit2 ~= "player" and br.getDebuffRemain(Unit2, 308498) > 0) + (Unit1 and Unit1 ~= "player" and br.getDebuffRemain(Unit1, 308498) > 0) or + (Unit2 and Unit2 ~= "player" and br.getDebuffRemain(Unit2, 308498) > 0) then return true end @@ -198,7 +201,7 @@ function br.getLineOfSight(Unit1, Unit2) if (X1 == nil or X2 == nil or pX == nil) then return false end -- Trace to see if we are in Line of Sight if br.player and br.player.eID and (br.player.eID == 2398 or br.player.eID == 2399) then - trace = br._G.TraceLine(X1, Y1, Z1 + 2--[[.25]], X2, Y2, Z2 + 2--[[.25]], 0x100111) + trace = br._G.TraceLine(X1, Y1, Z1 + 2 --[[.25]], X2, Y2, Z2 + 2 --[[.25]], 0x100111) else trace = br._G.TraceLine(X1, Y1, Z1 + 2.25, X2, Y2, Z2 + 2.25, flags) -- if (br._G.UnitIsUnit(Unit2,"target")) then @@ -238,6 +241,7 @@ function br.getLineOfSight(Unit1, Unit2) return false end end + -- if getGround("target"[,"target"]) then function br.getGround(Unit) if br.GetObjectExists(Unit) and br.GetUnitIsVisible(Unit) then @@ -249,6 +253,7 @@ function br.getGround(Unit) end end end + function br.getGroundDistance(Unit) if br.GetObjectExists(Unit) and br.GetUnitIsVisible(Unit) then local X1, Y1, Z1 = br.GetObjectPosition(Unit) @@ -261,6 +266,7 @@ function br.getGroundDistance(Unit) return 0 end end + -- if getPetLineOfSight("target"[,"target"]) then function br.getPetLineOfSight(Unit) if br.GetObjectExists(Unit) and br.GetUnitIsVisible("pet") and br.GetUnitIsVisible(Unit) then @@ -281,6 +287,7 @@ function br.round2(num, idp) local mult = 10 ^ (idp or 0) return math.floor(num * mult + 0.5) / mult end + -- if getTalent(8) == true then function br.getTalent(Row, Column, specGroup) if specGroup == nil then @@ -293,7 +300,7 @@ end -- if hasEmptySlots() then function br.hasEmptySlots() local openSlots = 0 - for i = 0, 4 do --Let's look at each bag + for i = 0, 4 do --Let's look at each bag local numBagSlots = C_Container.GetContainerNumSlots(i) if numBagSlots > 0 then -- Only look for slots if bag present openSlots = openSlots + select(1, C_Container.GetContainerNumFreeSlots(i)) @@ -305,6 +312,7 @@ function br.hasEmptySlots() return false end end + -- if hasGlyph(1234) == true then function br.hasGlyph(glyphid) for i = 1, 6 do @@ -328,6 +336,7 @@ function br.isGarrMCd(Unit) return false end end + -- if isInCombat("target") then function br.isInCombat(Unit) if br._G.UnitAffectingCombat(Unit) or br.isChecked("Ignore Combat") then @@ -336,31 +345,37 @@ function br.isInCombat(Unit) return false end end + function br.isInArdenweald() local tContains = br._G.tContains local mapID = br._G.C_Map.GetBestMapForUnit("player") return tContains(br.lists.maps.Ardenweald, mapID) end + function br.isInBastion() local tContains = br._G.tContains local mapID = br._G.C_Map.GetBestMapForUnit("player") return tContains(br.lists.maps.Bastion, mapID) end + function br.isInMaldraxxus() local tContains = br._G.tContains local mapID = br._G.C_Map.GetBestMapForUnit("player") return tContains(br.lists.maps.Maldraxxus, mapID) end + function br.isInRevendreth() local tContains = br._G.tContains local mapID = br._G.C_Map.GetBestMapForUnit("player") return tContains(br.lists.maps.Revendreth, mapID) end + function br.isInTheMaw() local tContains = br._G.tContains local mapID = br._G.C_Map.GetBestMapForUnit("player") return tContains(br.lists.maps.TheMaw, mapID) end + -- if isInDraenor() then function br.isInDraenor() local tContains = br._G.tContains @@ -368,12 +383,14 @@ function br.isInDraenor() local draenorMapIDs = br.lists.maps.Draenor return tContains(draenorMapIDs, currentMapID) end + function br.isInLegion() local tContains = br._G.tContains local currentMapID = br._G.C_Map.GetBestMapForUnit("player") local legionMapIDs = br.lists.maps.Legion return tContains(legionMapIDs, currentMapID) end + function br.isInProvingGround() local currentMapID = br._G.C_Map.GetBestMapForUnit("player") return currentMapID == 480 @@ -407,10 +424,12 @@ function br.isLongTimeCCed(Unit) end return false end + -- if isLooting() then function br.isLooting() return br._G.GetNumLootItems() > 0 end + -- if not isMoving("target") then function br.isMoving(Unit) if Unit == nil then @@ -418,6 +437,7 @@ function br.isMoving(Unit) end return br._G.GetUnitSpeed(Unit) > 0 end + -- if IsMovingTime(5) then function br.IsMovingTime(time) if time == nil then @@ -441,6 +461,7 @@ function br.IsMovingTime(time) end end end + function br.isPlayer(Unit) if br.GetUnitExists(Unit) ~= true then return false @@ -461,13 +482,16 @@ function br.isPlayer(Unit) return false end end + function br.getStandingTime() return br.DontMoveStartTime and br._G.GetTime() - br.DontMoveStartTime or nil end + -- function br.isStanding(Seconds) return br._G.IsFalling() == false and br.DontMoveStartTime and br.getStandingTime() >= Seconds or false end + -- if IsStandingTime(5) then function br.IsStandingTime(time, unit) if time == nil then @@ -552,12 +576,14 @@ function br.enemyListCheck(Unit) end local phaseReason = br._G.UnitPhaseReason(Unit) local distance = br.getDistance(Unit, "player") - local mcCheck = (br.isChecked("Attack MC Targets") and (not br.GetUnitIsFriend(Unit, "player") or br._G.UnitIsCharmed(Unit))) or not br.GetUnitIsFriend(Unit, "player") + local mcCheck = (br.isChecked("Attack MC Targets") and (not br.GetUnitIsFriend(Unit, "player") or br._G.UnitIsCharmed(Unit))) or + not br.GetUnitIsFriend(Unit, "player") local inPhase = not phaseReason or phaseReason == 2 or phaseReason == 3 if (br.UnitDebuffID("player", 320102) or br.UnitDebuffID(Unit, 424495)) and br._G.UnitIsPlayer(Unit) then return true end - return br.GetObjectExists(Unit) and not br.GetUnitIsDeadOrGhost(Unit) and inPhase and br._G.UnitCanAttack("player", Unit) and br._G.UnitHealth(Unit) > 0 and distance < 50 and + return br.GetObjectExists(Unit) and not br.GetUnitIsDeadOrGhost(Unit) and inPhase and + br._G.UnitCanAttack("player", Unit) and br._G.UnitHealth(Unit) > 0 and distance < 50 and not br.isCritter(Unit) and mcCheck and not br.GetUnitIsUnit(Unit, "pet") and @@ -577,7 +603,7 @@ function br.isValidUnit(Unit) local dummy = br.isDummy(Unit) local burnUnit = br.getOptionCheck("Forced Burn") and br.isBurnTarget(Unit) > 0 local isCC = br.getOptionCheck("Don't break CCs") and br.isLongTimeCCed(Unit) or false - local mcCheck = (br.isChecked("Attack MC Targets") and (not br.GetUnitIsFriend(Unit, "player") or (br._G.UnitIsCharmed(Unit) and br._G.UnitCanAttack("player", Unit)))) + local mcCheck = (br.isChecked("Attack MC Targets") and (not br.GetUnitIsFriend(Unit, "player") or (br._G.UnitIsCharmed(Unit) and br._G.UnitCanAttack("player", Unit)))) or not br.GetUnitIsFriend(Unit, "player") if playerTarget and (br.UnitDebuffID("player", 320102) or br.UnitDebuffID(Unit, 424495)) and br._G.UnitIsPlayer(Unit) then return true @@ -587,9 +613,10 @@ function br.isValidUnit(Unit) end if not br.pause(true) and Unit ~= nil and (br.units[Unit] ~= nil or Unit == "target" or burnUnit or dummy) and mcCheck and not isCC and (dummy or burnUnit or (not br._G.UnitIsTapDenied(Unit) and br.isSafeToAttack(Unit) - and ((hostileOnly and reaction < 4) or (not hostileOnly and reaction < 5) or playerTarget or targeting))) + and ((hostileOnly and reaction < 4) or (not hostileOnly and reaction < 5) or playerTarget or targeting))) then - return (playerTarget and (not inInstance or (inInstance and (#br.friend == 1 or not br.hasTank())))) or targeting or burnUnit or br.isInProvingGround() or br.hasThreat(Unit) + return (playerTarget and (not inInstance or (inInstance and (#br.friend == 1 or not br.hasTank())))) or targeting or + burnUnit or br.isInProvingGround() or br.hasThreat(Unit) end return false end @@ -616,7 +643,7 @@ function br.SpecificToggle(toggle) elseif br.getOptionValue(toggle) == 9 then return br._G.GetKeyState(0x06) elseif br.getOptionValue(toggle) == 10 then - return br._G.GetKeyState(0xC0) + return br._G.GetKeyState(0xC0) end end @@ -625,40 +652,42 @@ function br.UpdateToggle(toggle, delay) if br.customToggle then toggle = br.toggleKey end - if _G[toggle .. "Timer"] == nil then - _G[toggle .. "Timer"] = 0 + if br._G[toggle .. "Timer"] == nil then + br._G[toggle .. "Timer"] = 0 end - if (br.SpecificToggle(toggle .. " Mode") or br.customToggle) and not br._G.GetCurrentKeyBoardFocus() and br._G.GetTime() - _G[toggle .. "Timer"] > delay then - _G[toggle .. "Timer"] = br._G.GetTime() + if (br.SpecificToggle(toggle .. " Mode") or br.customToggle) and not br._G.GetCurrentKeyBoardFocus() and br._G.GetTime() - br._G[toggle .. "Timer"] > delay then + br._G[toggle .. "Timer"] = br._G.GetTime() br.UpdateButton(tostring(toggle)) end end + function br.BurstToggle(toggle, delay) if br.burstKey == nil then br.burstKey = false end - if _G[toggle .. "Timer"] == nil then - _G[toggle .. "Timer"] = 0 + if br._G[toggle .. "Timer"] == nil then + br._G[toggle .. "Timer"] = 0 end if br.burst and not br._G.GetCurrentKeyBoardFocus() and br._G.GetTime() - _G[toggle .. "Timer"] > delay then if not br.burstKey then - _G[toggle .. "Timer"] = br._G.GetTime() + br._G[toggle .. "Timer"] = br._G.GetTime() br.burstKey = true else - _G[toggle .. "Timer"] = br._G.GetTime() + br._G[toggle .. "Timer"] = br._G.GetTime() br.burstKey = false end end end + -- if pause() then -- set skipCastingCheck to true, to not check if player is casting -- (useful if you want to use off-cd stuff, or spells which can be cast while other is casting) function br.pause(skipCastingCheck) - local food = {257427, 225737, 274914, 192001, 167152, 314646, 308433} + local food = { 257427, 225737, 274914, 192001, 167152, 314646, 308433 } local eating = false local pausekey for i = 1, #food do - if br.UnitBuffID("player",food[i]) then + if br.UnitBuffID("player", food[i]) then eating = true break end @@ -705,7 +734,8 @@ function br.pause(skipCastingCheck) if br.getCombatTime() >= (tonumber(br.getOptionValue("DPS Testing")) * 60) and br.isDummy() then br._G.StopAttack() br._G.ClearTarget() - br._G.print(tonumber(br.getOptionValue("DPS Testing")) .. " Minute Dummy Test Concluded - Profile Stopped") + br._G.print(tonumber(br.getOptionValue("DPS Testing")) .. + " Minute Dummy Test Concluded - Profile Stopped") br.profileStop = true else br.profileStop = false @@ -733,7 +763,7 @@ function br.pause(skipCastingCheck) or (br._G.UnitChannelInfo("player") and not skipCastingCheck) or br._G.UnitIsDeadOrGhost("player") or eating or br.UnitDebuffID("player", 252753) or -- Potion of Replenishment (BFA Mana channel) Apparently a debuff br.UnitBuffID("player", 114018) - then + then if br.empowerID ~= nil and br.empowerID > 0 and not (pausekey and br._G.GetCurrentKeyBoardFocus() == nil and br.isChecked("Pause Mode")) then return false elseif (br._G.UnitCastingInfo("player") and not skipCastingCheck) then @@ -752,6 +782,7 @@ function br.pause(skipCastingCheck) return false end end + -- feed a var function br.toggleTrueNil(var) if _G[var] ~= true then @@ -766,6 +797,7 @@ function br.spellDebug(Message) br.ChatOverlay(Message) end end + -- if br.isChecked("Debug") then function br.isChecked(Value) if br.data ~= nil and br.data.settings ~= nil then @@ -783,17 +815,19 @@ function br.isChecked(Value) end return false end + -- if isSelected("Stormlash Totem") then function br.isSelected(Value) if br.data.settings ~= nil and (br.data.settings[br.selectedSpec].toggles["Cooldowns"] == 3 or (br.isChecked(Value) and (br.getValue(Value) == 3 or (br.getValue(Value) == 2 and br.data.settings[br.selectedSpec].toggles["Cooldowns"] == 2)))) - then + then return true end return false end + -- if br.getValue("player") <= br.getValue("Eternal Flame") then -- function br.getValue(Value) -- if br.data~=nil then @@ -828,13 +862,16 @@ function br.getValue(Value) return 0 end end + -- used to gather informations from the bot options frame function br.getOptionCheck(Value) return br.isChecked(Value) end + function br.getOptionValue(Value) return br.getValue(Value) end + function br.getOptionText(Value) if br.data ~= nil and br.data.settings ~= nil then local selectedProfile = br.data.settings[br.selectedSpec][br.selectedProfile] @@ -903,8 +940,8 @@ function br.talentAnywhere() for column = 1, 3 do if br._G.IsMouseButtonDown(1) and br.newTalent == nil and br._G.MouseIsOver(_G["PlayerTalentFrameTalentsTalentRow" .. row .. "Talent" .. column]) and - not select(4, br._G.GetTalentInfoByID(br._G.GetTalentInfo(row, column, 1), 1)) - then + not select(4, br._G.GetTalentInfoByID(br._G.GetTalentInfo(row, column, 1), 1)) + then br.selectedTalent = nil br.newTalent = select(1, br._G.GetTalentInfo(row, column, 1)) br.newTalentRow = row @@ -938,6 +975,7 @@ function br.talentAnywhere() end end end + function br.getEssenceRank(essenceName) if br._G.GetSpellInfo(essenceName) == nil then return 0 @@ -948,8 +986,10 @@ function br.getEssenceRank(essenceName) for i = 1, #essenceTable do local milestone = essenceTable[i] if milestone.slot ~= nil and milestone.unlocked == true then - local eRank = br._G.C_AzeriteEssence.GetEssenceInfo(br._G.C_AzeriteEssence.GetMilestoneEssence(milestone.ID)).rank - local eIcon = br._G.C_AzeriteEssence.GetEssenceInfo(br._G.C_AzeriteEssence.GetMilestoneEssence(milestone.ID)).icon + local eRank = br._G.C_AzeriteEssence.GetEssenceInfo(br._G.C_AzeriteEssence.GetMilestoneEssence(milestone.ID)) + .rank + local eIcon = br._G.C_AzeriteEssence.GetEssenceInfo(br._G.C_AzeriteEssence.GetMilestoneEssence(milestone.ID)) + .icon if icon == eIcon then essenceRank = eRank end diff --git a/System/Functions/Range.lua b/System/Functions/Range.lua index 3e2ff4501..17d1bf8da 100644 --- a/System/Functions/Range.lua +++ b/System/Functions/Range.lua @@ -14,7 +14,7 @@ local testSpell = { ["SHUNTER"] = 186270 } -function br.getDistance(Unit1,Unit2,option) +function br.getDistance(Unit1, Unit2, option) if Unit2 == nil then Unit2 = Unit1 Unit1 = "player" @@ -26,21 +26,23 @@ function br.getDistance(Unit1,Unit2,option) if (br.units[br._G.ObjectPointer(Unit1)] ~= nil and Unit2 == "player") then return br.units[br._G.ObjectPointer(Unit1)].range end - local thisUnit = Unit1 == "player" and br.units[br._G.ObjectPointer(Unit2)] or br.units[br._G.ObjectPointer(Unit1)] + local thisUnit = Unit1 == "player" and br.units[br._G.ObjectPointer(Unit2)] or + br.units[br._G.ObjectPointer(Unit1)] if thisUnit ~= nil then return thisUnit.range end end - return br.getDistanceCalc(Unit1,Unit2,option) + return br.getDistanceCalc(Unit1, Unit2, option) end -function br.getDistanceCalc(Unit1,Unit2,option) + +function br.getDistanceCalc(Unit1, Unit2, option) local currentDist = 100 local meleeSpell = nil - local playerClass = select(2,br._G.UnitClass("player")) + local playerClass = select(2, br._G.UnitClass("player")) local playerSpec = br._G.GetSpecializationInfo(br._G.GetSpecialization()) if testSpell[playerClass] ~= nil then meleeSpell = testSpell[playerClass] - elseif playerClass == "DRUID" and br.UnitBuffID("player",768) then + elseif playerClass == "DRUID" and br.UnitBuffID("player", 768) then meleeSpell = testSpell["DRUIDC"] - elseif playerClass == "DRUID" and br.UnitBuffID("player",5487) then + elseif playerClass == "DRUID" and br.UnitBuffID("player", 5487) then meleeSpell = testSpell["DRUIDB"] elseif playerSpec == 255 then meleeSpell = testSpell["SHUNTER"] @@ -59,48 +61,50 @@ function br.getDistanceCalc(Unit1,Unit2,option) if Unit1 == nil or Unit2 == nil then return 100 end if option == nil then option = "none" end -- Check if objects exists and are visible - if (br.GetUnitIsUnit(Unit1,"player") or (br.GetObjectExists(Unit1) and br.GetUnitIsVisible(Unit1) == true)) - and (br.GetUnitIsUnit(Unit2,"player") or (br.GetObjectExists(Unit2) and br.GetUnitIsVisible(Unit2) == true)) + if (br.GetUnitIsUnit(Unit1, "player") or (br.GetObjectExists(Unit1) and br.GetUnitIsVisible(Unit1) == true)) + and (br.GetUnitIsUnit(Unit2, "player") or (br.GetObjectExists(Unit2) and br.GetUnitIsVisible(Unit2) == true)) then -- If melee spell is usable, ignore all other calcs if meleeSpell ~= nil then if Unit2 == "player" then - if br._G.IsSpellInRange(select(1,br._G.GetSpellInfo(meleeSpell)),Unit1) == 1 then + if br._G.IsSpellInRange(select(1, br._G.GetSpellInfo(meleeSpell)), Unit1) == 1 then return 0 end else - if br._G.IsSpellInRange(select(1,br._G.GetSpellInfo(meleeSpell)),Unit2) == 1 then + if br._G.IsSpellInRange(select(1, br._G.GetSpellInfo(meleeSpell)), Unit2) == 1 then return 0 end end end local rangeMod = 0 --See if we already have a position, else get position - local X1,Y1,Z1,X2,Y2,Z2 = 0,0,0,0,0,0 + local X1, Y1, Z1, X2, Y2, Z2 = 0, 0, 0, 0, 0, 0 -- if not string.find(Unit1,"0x") then Unit1 = br._G.GetObjectWithGUID(br._G.UnitGUID(Unit1)) end -- if not string.find(Unit2,"0x") then Unit2 = br._G.GetObjectWithGUID(br._G.UnitGUID(Unit2)) end --Unit1 Position - local unit1GUID = select(2,br.getGUID(Unit1)) + local unit1GUID = select(2, br.getGUID(Unit1)) if br.unitSetup ~= nil and br.unitSetup.cache[Unit1] ~= nil and br.unitSetup.cache[Unit1].posX ~= nil then - X1,Y1,Z1 = br.unitSetup.cache[Unit1].posX, br.unitSetup.cache[Unit1].posY, br.unitSetup.cache[Unit1].posZ - elseif br.GetUnitIsUnit(Unit1,"player") and br.player ~= nil and br.player.posX ~= nil then - X1,Y1,Z1 = br.player.posX, br.player.posY, br.player.posZ + X1, Y1, Z1 = br.unitSetup.cache[Unit1].posX, br.unitSetup.cache[Unit1].posY, br.unitSetup.cache[Unit1].posZ + elseif br.GetUnitIsUnit(Unit1, "player") and br.player ~= nil and br.player.posX ~= nil then + X1, Y1, Z1 = br.player.posX, br.player.posY, br.player.posZ elseif br.isChecked("HE Active") and br.memberSetup ~= nil and br.memberSetup.cache[unit1GUID] ~= nil and br.memberSetup.cache[unit1GUID].x ~= nil then - X1,Y1,Z1 = br.memberSetup.cache[unit1GUID].x, br.memberSetup.cache[unit1GUID].y, br.memberSetup.cache[unit1GUID].z + X1, Y1, Z1 = br.memberSetup.cache[unit1GUID].x, br.memberSetup.cache[unit1GUID].y, + br.memberSetup.cache[unit1GUID].z else - X1,Y1,Z1 = br.GetObjectPosition(Unit1) + X1, Y1, Z1 = br.GetObjectPosition(Unit1) end if not X1 then return 999 end --Unit2 Position - local unit2GUID = select(2,br.getGUID(Unit2)) + local unit2GUID = select(2, br.getGUID(Unit2)) if br.unitSetup ~= nil and br.unitSetup.cache[Unit2] ~= nil and br.unitSetup.cache[Unit2].posX ~= nil then - X2,Y2,Z2 = br.unitSetup.cache[Unit2].posX, br.unitSetup.cache[Unit2].posY, br.unitSetup.cache[Unit2].posZ - elseif br.GetUnitIsUnit(Unit2,"player") and br.player ~= nil and br.player.posX ~= nil then - X2,Y2,Z2 = br.player.posX, br.player.posY, br.player.posZ + X2, Y2, Z2 = br.unitSetup.cache[Unit2].posX, br.unitSetup.cache[Unit2].posY, br.unitSetup.cache[Unit2].posZ + elseif br.GetUnitIsUnit(Unit2, "player") and br.player ~= nil and br.player.posX ~= nil then + X2, Y2, Z2 = br.player.posX, br.player.posY, br.player.posZ elseif br.isChecked("HE Active") and br.memberSetup ~= nil and br.memberSetup.cache[unit2GUID] ~= nil and br.memberSetup.cache[unit2GUID].x ~= nil then - X2,Y2,Z2 = br.memberSetup.cache[unit2GUID].x, br.memberSetup.cache[unit2GUID].y, br.memberSetup.cache[unit2GUID].z + X2, Y2, Z2 = br.memberSetup.cache[unit2GUID].x, br.memberSetup.cache[unit2GUID].y, + br.memberSetup.cache[unit2GUID].z else - X2,Y2,Z2 = br.GetObjectPosition(Unit2) + X2, Y2, Z2 = br.GetObjectPosition(Unit2) end if not X2 then return 999 end -- Melee Range Bypass @@ -115,32 +119,36 @@ function br.getDistanceCalc(Unit1,Unit2,option) -- Get the distance local TargetCombatReach = br._G.UnitCombatReach(Unit2) or 0 local PlayerCombatReach = br._G.UnitCombatReach(Unit1) or 0 - local MeleeCombatReachConstant = 7/3 + local MeleeCombatReachConstant = 7 / 3 local IfSourceAndTargetAreRunning = 0 - if br.isMoving(Unit1) and br.isMoving(Unit2) then IfSourceAndTargetAreRunning = 8/3 end + if br.isMoving(Unit1) and br.isMoving(Unit2) then IfSourceAndTargetAreRunning = 8 / 3 end -- Rogue Melee Range Increase Mod if br.player ~= nil then if br.player.talent.acrobaticStrikes ~= nil and meleeSpell ~= nil then - if br.player.talent.acrobaticStrikes and option ~= "noMod" and br._G.IsSpellInRange(select(1,br._G.GetSpellInfo(meleeSpell)),Unit2) == 1 then + if br.player.talent.acrobaticStrikes and option ~= "noMod" and br._G.IsSpellInRange(select(1, br._G.GetSpellInfo(meleeSpell)), Unit2) == 1 then rangeMod = 3 end end end - local dist = sqrt(((X2-X1)^2) + ((Y2-Y1)^2) + ((Z2-Z1)^2)) - (PlayerCombatReach + TargetCombatReach) - rangeMod + local dist = sqrt(((X2 - X1) ^ 2) + ((Y2 - Y1) ^ 2) + ((Z2 - Z1) ^ 2)) - (PlayerCombatReach + TargetCombatReach) - + rangeMod local dist2 = dist + 0.03 * ((13 - dist) / 0.13) local dist3 = dist + 0.05 * ((8 - dist) / 0.15) + 1 local dist4 = dist + (PlayerCombatReach + TargetCombatReach) - local meleeRange = br._G.max(6, PlayerCombatReach + TargetCombatReach + MeleeCombatReachConstant + IfSourceAndTargetAreRunning) + local meleeRange = br._G.max(6, + PlayerCombatReach + TargetCombatReach + MeleeCombatReachConstant + IfSourceAndTargetAreRunning) if option == "dist" then return dist end if option == "dist2" then return dist2 end if option == "dist3" then return dist3 end if option == "dist4" then return dist4 end if option == "meleeRange" then return meleeRange end - -- if (br._G.UnitIsUnit("target",Unit1) or br._G.UnitIsUnit("target",Unit2)) then - -- br._G.print("Dist: "..tostring(br.round2(dist,0))) + -- if (br._G.UnitIsUnit("target", Unit1) or br._G.UnitIsUnit("target", Unit2)) then + -- br._G.print("Dist: " .. + -- tostring(br.round2(PlayerCombatReach, 0) .. ", " .. tostring(br.round2(TargetCombatReach, 0)))) -- end + -- currentDist = br._G.max(dist, meleeRange, 0) if dist > 13 then - currentDist = br._G.max(0,dist) + currentDist = br._G.max(0, dist) elseif dist2 > 8 and dist3 > 8 then currentDist = dist2 elseif dist3 > 5 and dist4 > 5 then @@ -157,39 +165,41 @@ function br.getDistanceCalc(Unit1,Unit2,option) end return currentDist end -function br.isInRange(spellID,unit) - return br._G.LibStub("SpellRange-1.0").IsSpellInRange(spellID,unit) + +function br.isInRange(spellID, unit) + return br._G.LibStub("SpellRange-1.0").IsSpellInRange(spellID, unit) end -function br.getDistanceToLocation(Unit1,X2,Y2,Z2) - if Unit1 == nil then - Unit1 = "player" - end - if br.GetObjectExists(Unit1) and br.GetUnitIsVisible(Unit1) then - local X1,Y1,Z1 = br.GetObjectPosition(Unit1) - return sqrt(((X2-X1)^2) + ((Y2-Y1)^2) + ((Z2-Z1)^2)) - else - return 100 - end + +function br.getDistanceToLocation(Unit1, X2, Y2, Z2) + if Unit1 == nil then + Unit1 = "player" + end + if br.GetObjectExists(Unit1) and br.GetUnitIsVisible(Unit1) then + local X1, Y1, Z1 = br.GetObjectPosition(Unit1) + return sqrt(((X2 - X1) ^ 2) + ((Y2 - Y1) ^ 2) + ((Z2 - Z1) ^ 2)) + else + return 100 + end end function br.getFacingDistance() if br.GetUnitIsVisible("player") and br.GetUnitIsVisible("target") then --local targetDistance = getRealDistance("target") local targetDistance = br.getDistance("target") - local Y1,X1 = br.GetObjectPosition("player"); - local Y2,X2 = br.GetObjectPosition("target"); + local Y1, X1 = br.GetObjectPosition("player"); + local Y2, X2 = br.GetObjectPosition("target"); local angle1 = br.GetObjectFacing("player") local angle2 local deltaY = Y2 - Y1 local deltaX = X2 - X1 - angle1 = deg(abs(angle1-math.pi*2)) + angle1 = deg(abs(angle1 - math.pi * 2)) if deltaX > 0 then - angle2 = deg(atan(deltaY/deltaX)+(math.pi/2)+math.pi) - elseif deltaX <0 then - angle2 = deg(atan(deltaY/deltaX)+(math.pi/2)) + angle2 = deg(atan(deltaY / deltaX) + (math.pi / 2) + math.pi) + elseif deltaX < 0 then + angle2 = deg(atan(deltaY / deltaX) + (math.pi / 2)) end - local Dist = br.round2(math.tan(abs(angle2 - angle1)*math.pi/180)*targetDistance*10000)/10000 - if br._G.ObjectIsFacing("player","target") then + local Dist = br.round2(math.tan(abs(angle2 - angle1) * math.pi / 180) * targetDistance * 10000) / 10000 + if br._G.ObjectIsFacing("player", "target") then return Dist else return -(abs(Dist)) @@ -198,66 +208,73 @@ function br.getFacingDistance() return 1000 end end + -- /dump getTotemDistance("target") function br.getTotemDistance(Unit1) - if Unit1 == nil then - Unit1 = "player" - end + if Unit1 == nil then + Unit1 = "player" + end - if br.GetUnitIsVisible(Unit1) then - -- local objectCount = GetObjectCountBR() or 0 - local X2, Y2, Z2 - for i = 1,br._G.GetObjectCount() do - if br.GetUnitIsUnit(br._G.UnitCreator(br._G.GetObjectWithIndex(i)), "Player") and (br._G.UnitName(br._G.GetObjectWithIndex(i)) == "Searing Totem" or br._G.UnitName(br._G.GetObjectWithIndex(i)) == "Magma Totem") then - X2,Y2,Z2 = br.GetObjectPosition(br._G.GetObjectWithIndex(i)) - end + if br.GetUnitIsVisible(Unit1) then + -- local objectCount = GetObjectCountBR() or 0 + local X2, Y2, Z2 + for i = 1, br._G.GetObjectCount() do + if br.GetUnitIsUnit(br._G.UnitCreator(br._G.GetObjectWithIndex(i)), "Player") and (br._G.UnitName(br._G.GetObjectWithIndex(i)) == "Searing Totem" or br._G.UnitName(br._G.GetObjectWithIndex(i)) == "Magma Totem") then + X2, Y2, Z2 = br.GetObjectPosition(br._G.GetObjectWithIndex(i)) + end + end + local X1, Y1, Z1 = br.GetObjectPosition(Unit1) + local totemDistance = sqrt(((X2 - X1) ^ 2) + ((Y2 - Y1) ^ 2) + ((Z2 - Z1) ^ 2)) + --Print(TotemDistance) + return totemDistance + else + return 0 end - local X1,Y1,Z1 = br.GetObjectPosition(Unit1) - local totemDistance = sqrt(((X2-X1)^2)+((Y2-Y1)^2)+((Z2-Z1)^2)) - --Print(TotemDistance) - return totemDistance - else - return 0 - end end + -- if isInMelee() then function br.isInMelee(Unit) - if Unit == nil then - Unit = "target" - end - if br.getDistance(Unit) < 4 then - return true - else - return false - end + if Unit == nil then + Unit = "target" + end + if br.getDistance(Unit) < 4 then + return true + else + return false + end end -function br.isSafeToAoE(spellID,Unit,effectRng,minUnits,aoeType, enemies) +function br.isSafeToAoE(spellID, Unit, effectRng, minUnits, aoeType, enemies) if not br.isChecked("Safe Damage Check") then return true end local enemiesValid, enemiesAll - local maxRange = select(6,br._G.GetSpellInfo(spellID)) + local maxRange = select(6, br._G.GetSpellInfo(spellID)) if effectRng == nil then effectRng = 5 end - if maxRange == nil or maxRange == 0 then maxRange = tonumber(effectRng) effectRng = 8 else maxRange = tonumber(maxRange) end + if maxRange == nil or maxRange == 0 then + maxRange = tonumber(effectRng) + effectRng = 8 + else + maxRange = tonumber(maxRange) + end if minUnits == nil then minUnits = 1 end if aoeType == "rect" then - enemiesValid = br.getEnemiesInRect(effectRng,maxRange,false) - enemiesAll = not enemies and br.getEnemiesInRect(effectRng,maxRange,false,true) or enemies + enemiesValid = br.getEnemiesInRect(effectRng, maxRange, false) + enemiesAll = not enemies and br.getEnemiesInRect(effectRng, maxRange, false, true) or enemies elseif aoeType == "cone" then - enemiesValid = br.getEnemiesInCone(180,effectRng,false) - enemiesAll = not enemies and br.getEnemiesInCone(180,effectRng,false,true) or enemies + enemiesValid = br.getEnemiesInCone(180, effectRng, false) + enemiesAll = not enemies and br.getEnemiesInCone(180, effectRng, false, true) or enemies else - enemiesValid = #br.getEnemies(Unit,effectRng) - enemiesAll = not enemies and #br.getEnemies(Unit,effectRng,true) or enemies + enemiesValid = #br.getEnemies(Unit, effectRng) + enemiesAll = not enemies and #br.getEnemies(Unit, effectRng, true) or enemies end return enemiesValid >= minUnits and enemiesValid >= enemiesAll end -function br.inRange(spellID,unit) +function br.inRange(spellID, unit) local spellName = br._G.GetSpellInfo(spellID) if unit == nil then unit = "target" end - local inRange = br._G.IsSpellInRange(spellName,unit) + local inRange = br._G.IsSpellInRange(spellName, unit) if inRange ~= nil then - return br._G.IsSpellInRange(spellName,unit) == 1 + return br._G.IsSpellInRange(spellName, unit) == 1 else return false end @@ -271,4 +288,4 @@ function br.getBaseDistance(unit1, unit2) local x2, y2, z2 = br._G.ObjectPosition(unit2) return math.sqrt(((x2 - x1) ^ 2) + ((y2 - y1) ^ 2) + ((z2 - z1) ^ 2)) - ((br._G.UnitCombatReach(unit1) or 0) + (br._G.UnitCombatReach(unit2) or 0)), z2 - z1 -end \ No newline at end of file +end diff --git a/System/Loader/cBuilder.lua b/System/Loader/cBuilder.lua index c6df3ee03..6aeee8ef7 100644 --- a/System/Loader/cBuilder.lua +++ b/System/Loader/cBuilder.lua @@ -50,19 +50,19 @@ function br.loader.loadProfiles() local IDLength = math.floor(math.log10(specID) + 1) local folderSpec = getFolderSpecName(class, specID) local path = getFilesLocation() .. sep .. 'Rotations' .. sep .. getFolderClassName(class) .. sep .. folderSpec .. sep - -- br._G.print("Path: "..tostring(path)) + -- br._G.print("Path: " .. tostring(path)) local profiles = br._G.GetDirectoryFiles(path) - -- br._G.print("Profiles: "..tostring(#profiles)) + -- br._G.print("Profiles: " .. tostring(#profiles)) for k, file in pairs(profiles) do - -- br._G.print("Path: "..path..", File: "..file) + -- br._G.print("Path: " .. path .. ", File: " .. file) local profile = br._G.ReadFile(path .. file) or "" - -- br._G.print("Profile: "..tostring(profile)) + -- br._G.print("Profile: " .. tostring(profile)) local start = string.find(profile, "local id = ", 1, true) or 0 local stringEnd = start + IDLength + 10 local profileID = math.floor(tonumber(string.sub(profile, start + 10, stringEnd)) or 0) - -- br._G.print("ProfileID: "..tostring(profileID)..", SpecID: "..tostring(specID)) + -- br._G.print("ProfileID: " .. tostring(profileID) .. ", SpecID: " .. tostring(specID)) if profileID == specID then - -- br._G.print("Loading Profile") + br._G.print("Loading Profile") loadFile(profile, file, false) end end diff --git a/System/LootManager.lua b/System/LootManager.lua index 816453724..be57d23d9 100644 --- a/System/LootManager.lua +++ b/System/LootManager.lua @@ -5,6 +5,7 @@ SLASH_Greys2 = "/greys" function br._G.SlashCmdList.Greys(msg, editbox) br.SellGreys() end + function br.SellGreys() for bag = 0, 4 do for slot = 1, br._G.C_Container.GetContainerNumSlots(bag) do @@ -26,12 +27,14 @@ function br.SellGreys() br._G.RepairAllItems(0) br.ChatOverlay("Sold Greys.") end + -- Dump Greys Macros SLASH_DumpGrey1 = "/dumpgreys" SLASH_DumpGrey2 = "/dg" function br._G.SlashCmdList.DumpGrey(msg, editbox) br.DumpGreys(1) end + function br.DumpGreys(Num) local greyTable = {} for bag = 0, 4 do @@ -43,7 +46,7 @@ function br.DumpGreys(Num) local containerItemInfo = br._G.C_Container.GetContainerItemInfo(bag, slot) local greyPrice = select(11, br._G.GetItemInfo(item)) * containerItemInfo.stackCount if greyPrice > 0 then - br._G.tinsert(greyTable, {Bag = bag, Slot = slot, Price = greyPrice, Item = item}) + br._G.tinsert(greyTable, { Bag = bag, Slot = slot, Price = greyPrice, Item = item }) end end end @@ -56,7 +59,7 @@ function br.DumpGreys(Num) return x.Price < y.Price elseif x.Price then -- If only 'x' has a Price, it assumes 'x' is more expensive and goes after 'y' return false - else -- if neither 'x' nor 'y' has a Price, or only 'y' has a Price, it assumes 'x' is cheaper and goes before 'y' + else -- if neither 'x' nor 'y' has a Price, or only 'y' has a Price, it assumes 'x' is cheaper and goes before 'y' return true end end @@ -69,6 +72,7 @@ function br.DumpGreys(Num) end end end + ------------------ -- Loot Manager -- ------------------ @@ -81,10 +85,11 @@ function br.lootManager:debug(message) br.lM.oldMessage = message end end + -- Check if availables bag slots, return true if at least 1 free bag space function br.lootManager:emptySlots() local openSlots = 0 - for i = 0, 4 do --Let's look at each bag + for i = 0, 4 do --Let's look at each bag local numBagSlots = br._G.C_Container.GetContainerNumSlots(i) if numBagSlots > 0 then -- Only look for slots if bag present openSlots = openSlots + select(1, br._G.C_Container.GetContainerNumFreeSlots(i)) @@ -101,6 +106,7 @@ function br.lootManager:getLoot(lootUnit) if not looting then looting = true br.lM:debug("Looting " .. br._G.UnitName(lootUnit)) + -- print("Looting " .. br._G.UnitName(lootUnit)) br._G.InteractUnit(lootUnit) -- Manually loot if Auto Loot Interface Option not set if br._G.GetCVar("AutoLootDefault") == "0" then @@ -124,6 +130,7 @@ function br.lootManager:getLoot(lootUnit) return end end + -- function br.lootManager:getLoot(lootUnit) -- local looting = false -- -- if we have a unit to loot, check if its time to @@ -184,18 +191,20 @@ function br.lootManager:lootCount() end return lootCount end + function br.autoLoot() if br.getOptionCheck("Auto Loot") then --br.player.enemies.get(40) if (not br.isInCombat("player") or br.player.enemies.get(10)[1] == nil) then -- start loot manager if br.lM and br.lM:lootCount() > 0 then + -- print("Looking for Loot!") if br.lM:emptySlots() ~= 0 then if br._G.UnitCastingInfo("player") == nil and br._G.UnitChannelInfo("player") == nil and not br._G.IsMounted("player") and br._G.GetUnitSpeed("player") == 0 and br.timer:useTimer("lootTimer", 1) and not br._G.UnitIsDeadOrGhost("player") - then - -- Print("Getting Loot") + then + -- print("Getting Loot") br.lM:getLoot(br.lM.lootUnit) end else @@ -205,4 +214,3 @@ function br.autoLoot() end end end - diff --git a/System/Misc/ProfessionHelper/ProfessionHelper.lua b/System/Misc/ProfessionHelper/ProfessionHelper.lua index 4e17b8f4e..3d6729a78 100644 --- a/System/Misc/ProfessionHelper/ProfessionHelper.lua +++ b/System/Misc/ProfessionHelper/ProfessionHelper.lua @@ -12,13 +12,13 @@ function br.ProfessionHelper() if br.lootTimer == nil or br.lootTimer <= br._G.GetTime() - lootDelay and not br._G.LootFrame:IsShown() then --local containerItemInfo = br._G.GetContainerItemInfo(bagID, slotID); --if containerItemInfo.hyperlink ~= nil then - -- local itemName, _, _, _, _, itemClass, itemSubClass = br._G.GetItemInfo(itemLink); - local itemID = select(10, br._G.C_Container.GetContainerItemIndo(bagID, slotID))--tonumber(string.match(containerItemInfo, "Hitem:(%d+)")) - if itemID == thisItem then - br._G.RunMacroText("/cast "..br._G.GetSpellInfo(spell)) - br._G.RunMacroText("/use item:"..itemID) - br.lootTimer = br._G.GetTime() - end + -- local itemName, _, _, _, _, itemClass, itemSubClass = br._G.GetItemInfo(itemLink); + local itemID = select(10, br._G.C_Container.GetContainerItemIndo(bagID, slotID)) --tonumber(string.match(containerItemInfo, "Hitem:(%d+)")) + if itemID == thisItem then + br._G.RunMacroText("/cast " .. br._G.GetSpellInfo(spell)) + br._G.RunMacroText("/use item:" .. itemID) + br.lootTimer = br._G.GetTime() + end --end elseif br._G.LootFrame:IsShown() then for l = 1, br._G.GetNumLootItems() do @@ -40,66 +40,66 @@ function br.ProfessionHelper() local millMode = br.getValue("Mill Herbs") if millMode == 7 or millMode == 1 then local tableMillSL = { - 168586, -- Rising Glory - 168589, -- Marrowroot - 170554, -- Vigil's Torch - 168583, -- Widowbloom - 169701, -- Death Blossom - 171315 -- Nightshade + 168586, -- Rising Glory + 168589, -- Marrowroot + 170554, -- Vigil's Torch + 168583, -- Widowbloom + 169701, -- Death Blossom + 171315 -- Nightshade } processThatTable(tableMillSL, 51005) end if millMode == 7 or millMode == 2 then local tableMillBFA = { - 152505, -- Riverbud - 152511, -- Sea Stalk - 152506, -- Star Moss - 152507, -- Akunda's Bite - 152508, -- Winter's Kiss - 152510, -- Anchor Weed - 168487 -- Zin'anthid + 152505, -- Riverbud + 152511, -- Sea Stalk + 152506, -- Star Moss + 152507, -- Akunda's Bite + 152508, -- Winter's Kiss + 152510, -- Anchor Weed + 168487 -- Zin'anthid } processThatTable(tableMillBFA, 51005) end if millMode == 7 or millMode == 3 then local tableMillLegion = { - 124105, -- Starlight Rose - 124104, -- Fjarnskaggl - 124103, -- Foxflower - 124102, -- Dreamleaf - 124101 -- Aethril + 124105, -- Starlight Rose + 124104, -- Fjarnskaggl + 124103, -- Foxflower + 124102, -- Dreamleaf + 124101 -- Aethril } processThatTable(tableMillLegion, 51005) end if millMode == 7 or millMode == 4 then local tableMillWoD = { - 109124, -- Frostweed - 109125, -- Fireweed - 109126, -- Gorgrond Flytrap - 109127, -- Starflower - 109128, -- Nagrand Arrowbloom - 109129 -- Talador Orchid + 109124, -- Frostweed + 109125, -- Fireweed + 109126, -- Gorgrond Flytrap + 109127, -- Starflower + 109128, -- Nagrand Arrowbloom + 109129 -- Talador Orchid } processThatTable(tableMillWoD, 51005) end if millMode == 7 or millMode == 5 then local tableMillMoP = { - 72234, -- Green Tea Leaf - 72237, -- Rain Poppy - 72235, -- Silkweed - 79010, -- Snow Lily - 79011, -- Fool's Cap - 89639 -- Desecrated Herb + 72234, -- Green Tea Leaf + 72237, -- Rain Poppy + 72235, -- Silkweed + 79010, -- Snow Lily + 79011, -- Fool's Cap + 89639 -- Desecrated Herb } processThatTable(tableMillMoP, 51005) end if millMode == 7 or millMode == 6 then local tableMillCata = { - 52986, -- Heartblossom - 52984, -- Stormvine - 52983, -- Cinderbloom - 52985, -- Azshara's Veil - 52987 -- Twilight Jasmine + 52986, -- Heartblossom + 52984, -- Stormvine + 52983, -- Cinderbloom + 52985, -- Azshara's Veil + 52987 -- Twilight Jasmine } processThatTable(tableMillCata, 51005) end @@ -111,51 +111,51 @@ function br.ProfessionHelper() local prospectMode = br.getValue("Prospect Ores") if prospectMode == 7 or prospectMode == 1 then local tableProspectSL = { - 171828, -- Laestrite Ore - 171833, -- Elethium Ore - 171829, -- Solenium Ore - 171830, -- Oxxein Ore - 171831, -- Phaedrum Ore - 171832 -- Sinvyr Ore + 171828, -- Laestrite Ore + 171833, -- Elethium Ore + 171829, -- Solenium Ore + 171830, -- Oxxein Ore + 171831, -- Phaedrum Ore + 171832 -- Sinvyr Ore } processThatTable(tableProspectSL, 31252) end if prospectMode == 7 or prospectMode == 2 then local tableProspectBFA = { - 152512, -- Monelite Ore - 152513, -- Platinum Ore - 152579 -- Storm Silver Ore + 152512, -- Monelite Ore + 152513, -- Platinum Ore + 152579 -- Storm Silver Ore } processThatTable(tableProspectBFA, 31252) end if prospectMode == 7 or prospectMode == 3 then local tableProspectLegion = { - 123918, -- Leystone Ore - 123919 -- Felslate Ore + 123918, -- Leystone Ore + 123919 -- Felslate Ore } processThatTable(tableProspectLegion, 31252) end if prospectMode == 7 or prospectMode == 4 then local tableProspectWoD = { - 109119, -- True Iron Ore - 109118 -- Blackrock Ore + 109119, -- True Iron Ore + 109118 -- Blackrock Ore } processThatTable(tableProspectWoD, 31252) end if prospectMode == 7 or prospectMode == 5 then local tableProspectMoP = { - 72092, -- Ghost Iron Ore - 72093, -- Kyparite - 72094, -- Black Trillium Ore - 72103 -- White Trillium Ore + 72092, -- Ghost Iron Ore + 72093, -- Kyparite + 72094, -- Black Trillium Ore + 72103 -- White Trillium Ore } processThatTable(tableProspectMoP, 31252) end if prospectMode == 7 or prospectMode == 6 then local tableProspectCata = { - 52183, -- Pyrite Ore - 52185, -- Elementium Ore - 53038 -- Obsidium Ore + 52183, -- Pyrite Ore + 52185, -- Elementium Ore + 53038 -- Obsidium Ore } processThatTable(tableProspectCata, 31252) end @@ -166,28 +166,28 @@ function br.ProfessionHelper() if br.isChecked("Disenchant") and br._G.IsSpellKnown(13262) then -- list of items to me DE local tableDisenchant = { - 90905, -- JC Blue Neck ilvl 415 - 90904, -- JC Blue Ring ilvl 415 - 83794, -- JC Green Neck ilvl 384 - 83793, -- JC Green Ring ilvl 384 - 82434, -- Contender's Satin Cuffs (ilvl 450) - 82426, -- Contender's Silk Cuffs (ilvl 450) - 82402, -- Windwool Bracers (ilvl 384) - 130223, -- Deep Amber Loop (ilvl 715) - 130224, -- Skystone Loop (ilvl 715) - 130225, -- Azsunite Loop (ilvl 715) - 130226, -- Deep Amber Pendant (ilvl 765) - 130227, -- Skystone Pendant (ilvl 765) - 130228, -- Azsunite Pendant (ilvl 765) - 130229, -- Prophetic Band (ilvl 835) - 130230, -- Maelstrom Band (ilvl 835) - 130231, -- Dawnlight Band (ilvl 835) - 136711, -- Queen's Opal Loop (ilvl 715) - 136712, -- Queen's Opal Pendant (ilvl 765) - 136713, -- Shadowruby Band (ilvl 835) - 128899, -- Battlebound Armbands - 128883, -- Warhide Bindings - 154692, -- Tidespray Linen Bracers + 90905, -- JC Blue Neck ilvl 415 + 90904, -- JC Blue Ring ilvl 415 + 83794, -- JC Green Neck ilvl 384 + 83793, -- JC Green Ring ilvl 384 + 82434, -- Contender's Satin Cuffs (ilvl 450) + 82426, -- Contender's Silk Cuffs (ilvl 450) + 82402, -- Windwool Bracers (ilvl 384) + 130223, -- Deep Amber Loop (ilvl 715) + 130224, -- Skystone Loop (ilvl 715) + 130225, -- Azsunite Loop (ilvl 715) + 130226, -- Deep Amber Pendant (ilvl 765) + 130227, -- Skystone Pendant (ilvl 765) + 130228, -- Azsunite Pendant (ilvl 765) + 130229, -- Prophetic Band (ilvl 835) + 130230, -- Maelstrom Band (ilvl 835) + 130231, -- Dawnlight Band (ilvl 835) + 136711, -- Queen's Opal Loop (ilvl 715) + 136712, -- Queen's Opal Pendant (ilvl 765) + 136713, -- Shadowruby Band (ilvl 835) + 128899, -- Battlebound Armbands + 128883, -- Warhide Bindings + 154692, -- Tidespray Linen Bracers } processThatTable(tableDisenchant, 13262) end @@ -210,7 +210,7 @@ function br.ProfessionHelper() ------------------------------------------------------------------------------------------------------ if br.isChecked("Lockboxes") then local tableLockBox = { - 121331 -- Leystone Lockbox + 121331 -- Leystone Lockbox } for i = 1, #tableLockBox do local thisItem = tableLockBox[i] @@ -218,7 +218,8 @@ function br.ProfessionHelper() if br.lootTimer == nil or br.lootTimer <= br._G.GetTime() - lootDelay and not br._G.LootFrame:IsShown() then br._G.CastSpellByName(br._G.GetSpellInfo(1804), "player") br._G.UseItemByName(tostring(select(1, br._G.GetItemInfo(thisItem)))) - br._G.C_Timer.After(1.5, function() br._G.UseItemByName(tostring(select(1, br._G.GetItemInfo(thisItem)))) end) + br._G.C_Timer.After(1.5, + function() br._G.UseItemByName(tostring(select(1, br._G.GetItemInfo(thisItem)))) end) br.lootTimer = br._G.GetTime() return end @@ -237,14 +238,14 @@ function br.ProfessionHelper() ------------------------------------------------------------------------------------------------------ if br.isChecked("Fish Oil") then local tableFish = { - 152545, -- Frenzied Fangtooth - 152547, -- Great Sea Catfish - 152546, -- Lane Snapper - 152549, -- Redtail Loach - 152543, -- Sand Shifter - 152544, -- Slimy Mackerel - 152548, -- Tiragarde Perch - 168646 -- Mauve Stinger + 152545, -- Frenzied Fangtooth + 152547, -- Great Sea Catfish + 152546, -- Lane Snapper + 152549, -- Redtail Loach + 152543, -- Sand Shifter + 152544, -- Slimy Mackerel + 152548, -- Tiragarde Perch + 168646 -- Mauve Stinger } for i = 1, #tableFish do local thisItem = tableFish[i] @@ -265,11 +266,11 @@ end function br.fishing() if br.isChecked("Fishing") and br.unlocked --[[EasyWoWToolbox ~= nil]] and br.getOptionValue("Fishing") == 1 then if not br._G.IsHackEnabled("fish") then - br._G.SetHackEnabled("fish",true) + br._G.SetHackEnabled("fish", true) end elseif br.isChecked("Fishing") and br.unlocked --[[EasyWoWToolbox ~= nil]] and br.getOptionValue("Fishing") == 2 then if br._G.IsHackEnabled("fish") then - br._G.SetHackEnabled("fish",false) + br._G.SetHackEnabled("fish", false) end end ------------------------------------------------------------------------------------------------------ @@ -278,42 +279,42 @@ function br.fishing() if br.isChecked("Bait") then local bait = br.getValue("Bait") if bait == 1 then -- Lost Sole Bait - if br.hasItem(173038) and br.getBuffRemain("player",331688) == 0 then + if br.hasItem(173038) and br.getBuffRemain("player", 331688) == 0 then if br.canUseItem(173038) then br.useItem(173038) end end end if bait == 2 then -- Silvergill Pike Bait - if br.hasItem(173040) and br.getBuffRemain("player",331690) == 0 then + if br.hasItem(173040) and br.getBuffRemain("player", 331690) == 0 then if br.canUseItem(173040) then br.useItem(173040) end end end if bait == 3 then -- Pocked Bonefish Bait - if br.hasItem(173041) and br.getBuffRemain("player",331695) == 0 then + if br.hasItem(173041) and br.getBuffRemain("player", 331695) == 0 then if br.canUseItem(173041) then br.useItem(173041) end end end if bait == 4 then -- Iridescent Amberjack Bait - if br.hasItem(173039) and br.getBuffRemain("player",331692) == 0 then + if br.hasItem(173039) and br.getBuffRemain("player", 331692) == 0 then if br.canUseItem(173039) then br.useItem(173039) end end end if bait == 5 then -- Spinefin Piranha Bait - if br.hasItem(173042) and br.getBuffRemain("player",331699) == 0 then + if br.hasItem(173042) and br.getBuffRemain("player", 331699) == 0 then if br.canUseItem(173042) then br.useItem(173042) end end end if bait == 6 then -- Elysian Thade Bait - if br.hasItem(173043) and br.getBuffRemain("player",331698) == 0 then + if br.hasItem(173043) and br.getBuffRemain("player", 331698) == 0 then if br.canUseItem(173043) then br.useItem(173043) end diff --git a/System/Unlockers.lua b/System/Unlockers.lua index e30a2a1a7..3a9db486f 100644 --- a/System/Unlockers.lua +++ b/System/Unlockers.lua @@ -13,9 +13,9 @@ function br:loadUnlockerAPI() end -- Set Spell Queue Window --if class == 8 or class == 9 then - if unlocked and self.prevQueueWindow ~= 400 then - b.RunMacroText("/console SpellQueueWindow 400") - end + if unlocked and self.prevQueueWindow ~= 400 then + b.RunMacroText("/console SpellQueueWindow 400") + end --else -- if unlocked and self.prevQueueWindow ~= 0 then -- b.RunMacroText("/console SpellQueueWindow 0") @@ -35,7 +35,7 @@ function br:checkBrOutOfDate() -- Request Current Version from GitHub if b["EasyWoWToolbox"] ~= nil then -- EWT --SendHTTPRequest('https://raw.githubusercontent.com/CuteOne/BadRotations/master/BadRotations.toc', nil, - --function(body) brcurrVersion =(string.match(body, "(%d+%p%d+%p%d+)")) end) + --function(body) brcurrVersion =(string.match(body, "(%d+%p%d+%p%d+)")) end) -- Check for commit updates from System/Updater.lua, which relies on EWT self.updater:CheckOutdated() @@ -62,9 +62,9 @@ function br:checkBrOutOfDate() local msg = "BadRotations is currently out of date. Local Version: " .. brlocVersion .. " Current Version: " .. brcurrVersion - .. ". Please download latest version for best performance." + .. ". Please download latest version for best performance." if self.isChecked("Overlay Messages") then - b["RaidNotice_AddMessage"](b["RaidWarningFrame"], msg, {r = 1, g = 0.3, b = 0.1}) + b["RaidNotice_AddMessage"](b["RaidWarningFrame"], msg, { r = 1, g = 0.3, b = 0.1 }) else b.print(msg) end @@ -75,4 +75,3 @@ function br:checkBrOutOfDate() self.debug.cpu:updateDebug(startTime, "outOfDate") end end - diff --git a/System/engines/EnemiesEngine.lua b/System/engines/EnemiesEngine.lua index 11aa05cae..22df44d12 100644 --- a/System/engines/EnemiesEngine.lua +++ b/System/engines/EnemiesEngine.lua @@ -3,19 +3,19 @@ local _, br = ... --Modified to enemies engine by fisker if not br.metaTable2 then -- localizing the commonly used functions while inside loops - local tinsert,tremove,GetTime = br._G.tinsert,br._G.tremove,br._G.GetTime + local tinsert, tremove, GetTime = br._G.tinsert, br._G.tremove, br._G.GetTime local pX, pY, pZ, pCR, autoLoot - br.om = {} -- This is our main Table that the world will see - br.ttd = {} -- Time to die table - br.unitSetup = {} -- This is one of our MetaTables that will be the default user/contructor + br.om = {} -- This is our main Table that the world will see + br.ttd = {} -- Time to die table + br.unitSetup = {} -- This is one of our MetaTables that will be the default user/contructor br.unitSetup.cache = {} -- This is for the cache Table to check against - br.unitBlacklist = { -- blacklist for units - [129359]=true, -- Sawtooth Shark - [129448]=true, -- Hammer Shark - [144942]=true, -- Spark Bot + br.unitBlacklist = { -- blacklist for units + [129359] = true, -- Sawtooth Shark + [129448] = true, -- Hammer Shark + [144942] = true, -- Spark Bot } - br.metaTable2 = {} -- This will be the MetaTable attached to our Main Table that the world will see - br.metaTable2.__index = {-- Setting the Metamethod of Index for our Main Table + br.metaTable2 = {} -- This will be the MetaTable attached to our Main Table that the world will see + br.metaTable2.__index = { -- Setting the Metamethod of Index for our Main Table name = "Enemies Table", author = "Bubba", } @@ -35,7 +35,7 @@ if not br.metaTable2 then local startTime = br._G.debugprofilestop() -- Seeing if we have already cached this unit before if br.unitSetup.cache[unit] then return false end - if br.UnitDebuffID("player",295249) and br._G.UnitIsPlayer(unit) then return false end + if br.UnitDebuffID("player", 295249) and br._G.UnitIsPlayer(unit) then return false end if br.unitBlacklist[br.GetObjectID(unit)] then return false end local o = {} setmetatable(o, br.unitSetup) @@ -56,19 +56,19 @@ if not br.metaTable2 then end -- initialize new unit if br.ttd[o.unit] == nil then - br.ttd[o.unit] = { } -- create unit - br.ttd[o.unit].values = { } -- create value table - value = {time = 0, hp = o.hp} -- create initial values + br.ttd[o.unit] = {} -- create unit + br.ttd[o.unit].values = {} -- create value table + value = { time = 0, hp = o.hp } -- create initial values tinsert(br.ttd[o.unit].values, 1, value) -- insert unit br.ttd[o.unit].lasthp = o.hp -- store current hp pct br.ttd[o.unit].startTime = timeNow -- store current time - br.ttd[o.unit].lastTime = 0 --store last time value + br.ttd[o.unit].lastTime = 0 --store last time value return 999 end local ttdUnit = br.ttd[o.unit] -- add current value to ttd table if HP changed or more than X sec since last update if o.hp ~= ttdUnit.lasthp or (timeNow - ttdUnit.startTime - ttdUnit.lastTime) > 0.5 then - value = {time = timeNow - ttdUnit.startTime, hp = o.hp} + value = { time = timeNow - ttdUnit.startTime, hp = o.hp } tinsert(ttdUnit.values, 1, value) br.ttd[o.unit].lasthp = o.hp br.ttd[o.unit].lastTime = timeNow - ttdUnit.startTime @@ -106,20 +106,22 @@ if not br.metaTable2 then end end -- Debugging - br.debug.cpu:updateDebug(startTime,"enemiesEngine.unitSetup.ttd") + br.debug.cpu:updateDebug(startTime, "enemiesEngine.unitSetup.ttd") return 999 -- not enough values end + --Distance function o:RawDistance() local x1, y1, z1 = pX, pY, pZ local x2, y2, z2 = o.posX, o.posY, o.posZ - if x1 == nil or x2 == nil or y1 == nil or y2 == nil or z1 == nil or z2 == nil then + if x1 == nil or x2 == nil or y1 == nil or y2 == nil or z1 == nil or z2 == nil then return 99 else return math.sqrt(((x2 - x1) ^ 2) + ((y2 - y1) ^ 2) + ((z2 - z1) ^ 2)) - - ((pCR or 0) + (br._G.UnitCombatReach(o.unit) or 0)), z2 - z1 + ((pCR or 0) + (br._G.UnitCombatReach(o.unit) or 0)), z2 - z1 end end + --Add unit to table function o:AddUnit(table) local thisUnit @@ -141,8 +143,9 @@ if not br.metaTable2 then -- br._G.print("Adding "..thisUnit.unit.." to table") rawset(table, o.unit, thisUnit) end + --Debuffs - function o:UpdateDebuffs(debuffList,unit) + function o:UpdateDebuffs(debuffList, unit) local startTime = br._G.debugprofilestop() if not br.isChecked("Cache Debuffs") then debuffList = {} @@ -153,7 +156,7 @@ if not br.metaTable2 then local buffName local buffUnit -- Add Debuffs - local function cacheDebuff(buffUnit,buffName,buffCaster) + local function cacheDebuff(buffUnit, buffName, buffCaster) -- Print("Caching Debuff!") -- Cache it to the OM if buffCaster ~= nil and buffCaster == "player" then --(buffCaster == "player" or UnitIsFriend("player",buffCaster)) then @@ -168,14 +171,14 @@ if not br.metaTable2 then end end -- Get the Info from Combat Log - for k,_ in pairs(br.read.debuffTracker) do + for k, _ in pairs(br.read.debuffTracker) do tracker = br.read.debuffTracker[k] for j, _ in pairs(tracker) do buffCaster = tracker[j][1] buffName = tracker[j][2] buffUnit = tracker[j][3] if buffUnit == unit and (debuffList[buffCaster] == nil or debuffList[buffCaster][buffName] == nil) then - cacheDebuff(buffUnit,buffName,buffCaster) + cacheDebuff(buffUnit, buffName, buffCaster) end end end @@ -183,7 +186,7 @@ if not br.metaTable2 then for buffCaster, buffs in pairs(debuffList) do for buffName, _ in pairs(buffs) do if debuffList[buffCaster][buffName] ~= nil then - if debuffList[buffCaster][buffName](buffName,unit) == nil then + if debuffList[buffCaster][buffName](buffName, unit) == nil then -- Print("Removing player expired - "..buffName) debuffList[buffCaster][buffName] = nil if br.read.debuffTracker[unit] ~= nil and br.read.debuffTracker[unit][buffName] ~= nil and br.read.debuffTracker[unit][buffName][1] == buffCaster then @@ -194,9 +197,10 @@ if not br.metaTable2 then end end -- Debugging - br.debug.cpu:updateDebug(startTime,"enemiesEngine.unitSetup.updateDebuffs") + br.debug.cpu:updateDebug(startTime, "enemiesEngine.unitSetup.updateDebuffs") return debuffList end + -- Updating the values of the Unit function o:UpdateUnit() -- br._G.print("Updating "..o.unit) @@ -238,7 +242,7 @@ if not br.metaTable2 then if o.enemyListCheck == true then o.isValidUnit = br.isValidUnit(o.unit) if o.isValidUnit == true then - o.debuffs = o:UpdateDebuffs(o.debuffs,o.unit) + o.debuffs = o:UpdateDebuffs(o.debuffs, o.unit) -- o.range = getDistanceCalc(o.unit) if br.enemy[o.unit] == nil then o:AddUnit(br.enemy) @@ -270,8 +274,10 @@ if not br.metaTable2 then end -- Check for loots if autoLoot and br.lootable[o.unit] == nil and br.GetUnitIsDeadOrGhost(o.unit) then + -- print("Checking unit: " .. o.guid .. " for loot.") local hasLoot = br._G.CanLootUnit(o.guid) if hasLoot then + -- print("Adding lootable unit") o:AddUnit(br.lootable) end end @@ -287,17 +293,19 @@ if not br.metaTable2 then -- add unit to setup cache br.unitSetup.cache[o.unit] = o -- Add unit to SetupTable -- Debugging - br.debug.cpu:updateDebug(startTime,"enemiesEngine.unitSetup.updateUnit") + br.debug.cpu:updateDebug(startTime, "enemiesEngine.unitSetup.updateUnit") end + -- Adding the user and functions we just created to this cached version in case we need it again -- This will also serve as a good check for if the unit is already in the table easily br.unitSetup.cache[o.unit] = o -- Debugging - br.debug.cpu:updateDebug(startTime,"enemiesEngine.unitSetup") + br.debug.cpu:updateDebug(startTime, "enemiesEngine.unitSetup") return o end + -- Setting up the tables on either Wipe or Initial Setup - function br.SetupEnemyTables() -- Creating the cache (we use this to check if some1 is already in the table) + function br.SetupEnemyTables() -- Creating the cache (we use this to check if some1 is already in the table) local startTime = br._G.debugprofilestop() setmetatable(br.om, br.metaTable2) -- Set the metaTable of Main to Meta function br.om:Update() @@ -319,13 +327,13 @@ if not br.metaTable2 then end end --Cycle and clean tables - local i=1 + local i = 1 while i <= #br.om do if br.om[i].pulseTime == nil or GetTime() >= br.om[i].pulseTime then -- this delay is extremely important as the unit updates are a major source of FPS loss for BR -- for non-raids, this code will spread out unit updates so that everything gets updated every update -- for raids, only half of units will be updated per BR update - local delay = ((math.random() * 0.25) + 0.75) * br:getUpdateRate() + local delay = ((math.random() * 0.25) + 0.75) * br:getUpdateRate() if br._G.IsInRaid() then delay = delay * 2.00 end @@ -375,9 +383,11 @@ if not br.metaTable2 then end end end + -- Debugging - br.debug.cpu:updateDebug(startTime,"enemiesEngine.enemySetup") + br.debug.cpu:updateDebug(startTime, "enemiesEngine.enemySetup") end + -- We are setting up the Tables for the first time br.SetupEnemyTables() -end \ No newline at end of file +end diff --git a/System/engines/EnemiesEngineFunctions.lua b/System/engines/EnemiesEngineFunctions.lua index 4c4a83af5..93b2117b6 100644 --- a/System/engines/EnemiesEngineFunctions.lua +++ b/System/engines/EnemiesEngineFunctions.lua @@ -46,7 +46,7 @@ function br.updateOM() local total = br._G.GetObjectCount(true, "BR") or 0 for i = 1, total do local thisUnit = br._G.GetObjectWithIndex(i) - -- br._G.print(thisUnit.." - Is Unit: "..tostring(br._G.ObjectIsUnit(thisUnit)).." - Name: "..tostring(br._G.UnitName(thisUnit))) + -- br._G.print(thisUnit .. " - Is Unit: " .. tostring(br._G.ObjectIsUnit(thisUnit)) .. " - Name: " .. tostring(br._G.UnitName(thisUnit))) if --[[br._G.IsGuid(thisUnit) and]] br._G.ObjectExists(thisUnit) and br._G.ObjectIsUnit(thisUnit) --[[and not unitExistsInOM(thisUnit) and br.omDist(thisUnit) < 50]] then if not br._G.UnitIsPlayer(thisUnit) and not br.isCritter(thisUnit) and not br._G.UnitIsUnit("player", thisUnit) and not br._G.UnitIsFriend("player", thisUnit) then local enemyUnit = br.unitSetup:new(thisUnit) diff --git a/System/ui/ui.lua b/System/ui/ui.lua index fe64e5f01..2d1772491 100644 --- a/System/ui/ui.lua +++ b/System/ui/ui.lua @@ -1,8 +1,11 @@ +local LSM = LibStub("LibSharedMedia-3.0") +local MediaType_FONT = LSM.MediaType.FONT local DiesalGUI = _G.LibStub("DiesalGUI-1.0") local _, br = ... -- Global setup br.ui = {} br.spacing = 15 +LSM:Register(MediaType_FONT, "calibrib", [[Interface\Addons\SharedMedia_MyMedia\font\calibrib.ttf]]) -- local Type = "UI" local BRFont = "DiesalFontNormal" @@ -83,19 +86,19 @@ br.ui.buttonStyleSheet = { } br.ui.arrowRight = { type = "texture", - offset = {-2, nil, -2, nil}, + offset = { -2, nil, -2, nil }, height = 16, width = 16, alpha = .7, - image = {"DiesalGUIcons", {7, 5, 16, 256, 128}} + image = { "DiesalGUIcons", { 7, 5, 16, 256, 128 } } } br.ui.arrowLeft = { type = "texture", - offset = {-2, nil, -2, nil}, + offset = { -2, nil, -2, nil }, height = 16, width = 16, alpha = .7, - image = {"DiesalGUIcons", {8, 5, 16, 256, 128}} + image = { "DiesalGUIcons", { 8, 5, 16, 256, 128 } } } br.ui.messageStylesheet = { ["track-background"] = {