local IMBA_SLASH_COMMAND = "/imba"; IMBA_Version="1.4"; IMBA_RaidVersions={}; IMBA_Addons = {}; IMBA_SavedVariables = {}; IMBA_SavedVariables.Mods = {}; -- Raid zones IMBA_LOCATIONS_MC = "Molten Core"; IMBA_LOCATIONS_BWL = "Blackwing Lair"; IMBA_LOCATIONS_ZG = "Zul'Gurub"; IMBA_LOCATIONS_AQ20 = "Ruins of Ahn'Qiraj"; IMBA_LOCATIONS_AQ40 = "Temple of Ahn'Qiraj"; IMBA_LOCATIONS_NAXX = "Naxxramas"; IMBA_LOCATIONS_NAXX_ABOM = "Naxxramas - Abomination Wing"; IMBA_LOCATIONS_NAXX_DK = "Naxxramas - Deathknight Wing"; IMBA_LOCATIONS_NAXX_PLAGUE = "Naxxramas - Plague Wing"; IMBA_LOCATIONS_NAXX_SPIDER = "Naxxramas - Spider Wing"; IMBA_LOCATIONS_NAXX_LAIR = "Naxxramas - Frostwyrm Lair"; IMBA_LOCATIONS_OTHER = "Other"; IMBA_Locations = {{IMBA_LOCATIONS_MC,0}, {IMBA_LOCATIONS_BWL,0}, {IMBA_LOCATIONS_ZG,0}, {IMBA_LOCATIONS_AQ20,0}, {IMBA_LOCATIONS_AQ40,0}, { IMBA_LOCATIONS_NAXX_ABOM, 0 }, { IMBA_LOCATIONS_NAXX_DK, 0 }, { IMBA_LOCATIONS_NAXX_PLAGUE, 0 }, { IMBA_LOCATIONS_NAXX_SPIDER, 0 }, { IMBA_LOCATIONS_NAXX_LAIR, 0}, { IMBA_LOCATIONS_OTHER, 0}}; IMBA_DEATH_MSG = "(.+) dies." if (GetLocale()=="frFR") then --Translation by A.su.K.A IMBA_DEATH_MSG = "(.+) meurt." end function IMBA_SetBackdrops(num) for k, v in IMBA_Addons do if v.MainFrame~=nil then getglobal(v.MainFrame):SetBackdrop(IMBA_BG[num].table); getglobal(v.MainFrame):SetBackdropBorderColor(IMBA_SavedVariables.Colors["FrameBorder"].r,IMBA_SavedVariables.Colors["FrameBorder"].g,IMBA_SavedVariables.Colors["FrameBorder"].b,IMBA_SavedVariables.Colors["FrameBorder"].a); getglobal(v.MainFrame):SetBackdropColor(IMBA_SavedVariables.Colors["FrameBG"].r,IMBA_SavedVariables.Colors["FrameBG"].g,IMBA_SavedVariables.Colors["FrameBG"].b,IMBA_SavedVariables.Colors["FrameBG"].a); if getglobal(v.MainFrame.."_Close_Image") then getglobal(v.MainFrame.."_Close_Image"):SetTexture(IMBA_BG[num].close); getglobal(v.MainFrame.."_Close_Image"):SetVertexColor(IMBA_SavedVariables.Colors["FrameBorder"].r,IMBA_SavedVariables.Colors["FrameBorder"].g,IMBA_SavedVariables.Colors["FrameBorder"].b,IMBA_SavedVariables.Colors["FrameBorder"].a); end end end IMBA_Alerts:SetBackdrop(IMBA_BG[num].table); if IMBA_SavedVariables.ShowAlertWindow then IMBA_Alerts:SetBackdropBorderColor(IMBA_SavedVariables.Colors["FrameBorder"].r,IMBA_SavedVariables.Colors["FrameBorder"].g,IMBA_SavedVariables.Colors["FrameBorder"].b,IMBA_SavedVariables.Colors["FrameBorder"].a); IMBA_Alerts:SetBackdropColor(IMBA_SavedVariables.Colors["FrameBG"].r,IMBA_SavedVariables.Colors["FrameBG"].g,IMBA_SavedVariables.Colors["FrameBG"].b,IMBA_SavedVariables.Colors["FrameBG"].a); else IMBA_Alerts:SetBackdropBorderColor(IMBA_SavedVariables.Colors["FrameBorder"].r,IMBA_SavedVariables.Colors["FrameBorder"].g,IMBA_SavedVariables.Colors["FrameBorder"].b,0); IMBA_Alerts:SetBackdropColor(IMBA_SavedVariables.Colors["FrameBG"].r,IMBA_SavedVariables.Colors["FrameBG"].g,IMBA_SavedVariables.Colors["FrameBG"].b,0); end end function IMBA_HideCloseButtons() for k, v in IMBA_Addons do if v.MainFrame~=nil then if getglobal(v.MainFrame.."_Close") then getglobal(v.MainFrame.."_Close"):Hide(); end end end end function IMBA_ShowCloseButtons() for k, v in IMBA_Addons do if v.MainFrame~=nil then if getglobal(v.MainFrame.."_Close") then getglobal(v.MainFrame.."_Close"):Show(); end end end end function IMBA_ResetPositions() for k, v in IMBA_Addons do if v.MainFrame~=nil then getglobal(v.MainFrame):ClearAllPoints(); getglobal(v.MainFrame):SetPoint("CENTER", "UIParent", "CENTER", 0, 0); end end IMBA_Alerts:ClearAllPoints(); IMBA_Alerts:SetPoint("CENTER", "UIParent", "CENTER", 0, 0); end function IMBA_AddAddon(BossName, Description, Location, RegenActivator, YellActivator, TestYell, MainFrame) IMBA_Addons[BossName]={}; IMBA_Addons[BossName].Active=true; IMBA_Addons[BossName].Running=false; IMBA_Addons[BossName].BossName=BossName; IMBA_Addons[BossName].Location=Location; IMBA_Addons[BossName].Description=Description; IMBA_Addons[BossName].RegenActivator=RegenActivator; IMBA_Addons[BossName].YellActivator=YellActivator; IMBA_Addons[BossName].TestYell=TestYell; IMBA_Addons[BossName].MainFrame=MainFrame; IMBA_Addons[BossName].MultiBoss=0; IMBA_Addons[BossName].BossNames={}; IMBA_SavedVariables.Mods[BossName]={}; IMBA_SavedVariables.Mods[BossName].Active=true; IMBA_SavedVariables.Mods[BossName].Visible=false; getglobal(MainFrame):Hide(); --Sync Variables we track if the last change has been sent(delay by one cycle to allow for combat log variances), --then check the last value to see if its change update the last value and set Sent to false --The method determines how the variable gets sycned ("MAX" - whichever value is max gets chosen, "MIN" whatever value is minimum is chosen, "REPLACE" allows you to overwrite the value) IMBA_Addons[BossName].SyncVariableFunc=nil; IMBA_Addons[BossName].SyncVariablesSent={}; IMBA_Addons[BossName].SyncVariablesLastVal={}; IMBA_Addons[BossName].SyncVariablesMethod={}; --DEFAULT_CHAT_FRAME:AddMessage("IMBA - "..BossName.." Added", 1.0, 1.0, 0.0); end function IMBA_AddBossName(AddonName,BossName) IMBA_Addons[AddonName].MultiBoss=IMBA_Addons[AddonName].MultiBoss+1; IMBA_Addons[AddonName].BossNames[IMBA_Addons[AddonName].MultiBoss]=BossName; IMBA_Addons[AddonName].BossesAlive=IMBA_Addons[AddonName].MultiBoss; end function IMBA_AddOption(AddonName,OptionText,Func,ValueFunc) if IMBA_Addons[AddonName].Options==nil then IMBA_Addons[AddonName].Options={}; end IMBA_Addons[AddonName].Options[OptionText]={}; IMBA_Addons[AddonName].Options[OptionText].text=OptionText; IMBA_Addons[AddonName].Options[OptionText].valuefunc=ValueFunc; IMBA_Addons[AddonName].Options[OptionText].func=Func; if IMBA_Addons[AddonName].OptionsOrder==nil then IMBA_Addons[AddonName].OptionsOrder={}; end tinsert(IMBA_Addons[AddonName].OptionsOrder,OptionText); end function IMBA_AddOption2(AddonName,VarName, OptionText) if IMBA_SavedVariables.Mods[AddonName].Var==nil then IMBA_SavedVariables.Mods[AddonName].Var={}; IMBA_Addons[AddonName].VarText={}; end IMBA_SavedVariables.Mods[AddonName].Var[VarName]=false; IMBA_Addons[AddonName].VarText[VarName]=OptionText; if IMBA_Addons[AddonName].OptionsOrder2==nil then IMBA_Addons[AddonName].OptionsOrder2={}; end tinsert(IMBA_Addons[AddonName].OptionsOrder2,VarName); end function IMBA_CheckVar(AddonName,VarName) if IMBA_SavedVariables.Mods[AddonName]==nil then IMBA_SavedVariables.Mods[AddonName]={}; end if IMBA_SavedVariables.Mods[AddonName].Var==nil then IMBA_SavedVariables.Mods[AddonName].Var={}; end if IMBA_SavedVariables.Mods[AddonName].Var[VarName]==nil then IMBA_SavedVariables.Mods[AddonName].Var[VarName]=false; end return IMBA_SavedVariables.Mods[AddonName].Var[VarName] end function IMBA_CheckSyncVariables(Addon) for k, v in Addon.SyncVariablesLastVal do --First Checking to see if need to send a variable if Addon.SyncVariablesSent[k]==false then SendAddonMessage("IMBA", "VARSYNC "..k.." "..Addon.SyncVariablesLastVal[k].." "..Addon.SyncVariablesMethod[k],"RAID"); Addon.SyncVariablesSent[k]=true; end --Only want to potentially send if the variable has changed if Addon.SyncVariablesLastVal[k]~=getglobal(k) then Addon.SyncVariablesLastVal[k]=getglobal(k); Addon.SyncVariablesSent[k]=false; end end end function IMBA_SyncVar(Addon,VarName,Value,Method) if Method=="MAX" then if Value>getglobal(VarName) then setglobal(VarName,Value); Addon.SyncVariablesLastVal[VarName]=Value; Addon.SyncVariablesSent[VarName]=true; if Addon.SyncVariableFunc~=nil then getglobal(Addon.SyncVariableFunc)(); end end elseif Method=="MIN" then if Value0) then if k==MobName then getglobal(v.MainFrame):Hide(); v.Running=false; end else for i=1,v.MultiBoss do if MobName==v.BossNames[i] then v.BossesAlive=v.BossesAlive-1; if v.BossesAlive<=0 then getglobal(v.MainFrame):Hide(); v.Running=false; end end end end end end end end end function IMBA_Command(msg) msg=strlower(msg); if msg=="lock" then IMBA_LockWindows(); elseif msg=="unlock" then IMBA_UnlockWindows(); elseif msg=="options" then IMBA_Options:Show(); elseif msg=="minimap" then if IMBA_SavedVariables.HideMinimapIcon then IMBA_SavedVariables.HideMinimapIcon=false; IMBA_OptionsButton:Show(); else IMBA_SavedVariables.HideMinimapIcon=true; IMBA_OptionsButton:Hide(); end IMBA_Options_GraphicsFrame_HideMinimapIcon:SetChecked(IMBA_SavedVariables.HideMinimapIcon) else DEFAULT_CHAT_FRAME:AddMessage("IMBA Commands "..IMBA_Version, 1.0, 1.0, 0.0); DEFAULT_CHAT_FRAME:AddMessage(" lock - Locks all windows", 1.0, 1.0, 0.0); DEFAULT_CHAT_FRAME:AddMessage(" minimap - Toggles Minimap Icon", 1.0, 1.0, 0.0); DEFAULT_CHAT_FRAME:AddMessage(" options - Shows the options window", 1.0, 1.0, 0.0); DEFAULT_CHAT_FRAME:AddMessage(" unlock - Unlocks all windows", 1.0, 1.0, 0.0); end end function IMBA_SetScale(loading) for k, v in IMBA_Addons do if v.MainFrame then if getglobal(v.MainFrame) then if not loading then local pointNum=getglobal(v.MainFrame):GetNumPoints() local curScale=getglobal(v.MainFrame):GetScale(); local pointsCleared=false local points={} for i=1,pointNum,1 do points[i]={}; points[i][1], points[i][2], points[i][3], points[i][4], points[i][5]=getglobal(v.MainFrame):GetPoint(i) points[i][4]=points[i][4]*curScale/IMBA_SavedVariables.Scale; points[i][5]=points[i][5]*curScale/IMBA_SavedVariables.Scale; end pointsCleared=false for i=1,pointNum,1 do if points[i][1] and points[i][2] and points[i][3] and points[i][4] and points[i][5] then if not pointsCleared then getglobal(v.MainFrame):ClearAllPoints() pointsCleared=true; end getglobal(v.MainFrame):SetPoint(points[i][1],UIParent,points[i][3],points[i][4],points[i][5]); end end end getglobal(v.MainFrame):SetScale(IMBA_SavedVariables.Scale); end end end end function IMBA_LockWindows() for k, v in IMBA_Addons do if v.MainFrame then getglobal(v.MainFrame).isLocked=true; end end IMBA_SavedVariables.LockedWindows=true; DEFAULT_CHAT_FRAME:AddMessage("IMBA - Windows Locked", 1.0, 1.0, 0.0); end function IMBA_UnlockWindows() for k, v in IMBA_Addons do if v.MainFrame then getglobal(v.MainFrame).isLocked=false; end end IMBA_SavedVariables.LockedWindows=false; DEFAULT_CHAT_FRAME:AddMessage("IMBA - Windows Unlocked", 1.0, 1.0, 0.0); end function IMBA_RegisterEvents() this:RegisterEvent("CHAT_MSG_MONSTER_YELL"); this:RegisterEvent("PLAYER_REGEN_DISABLED"); this:RegisterEvent("CHAT_MSG_ADDON"); this:RegisterEvent("CHAT_MSG_COMBAT_HOSTILE_DEATH"); this:RegisterEvent("PLAYER_LOGIN"); end function IMBA_UnregisterEvents() this:UnregisterEvent("CHAT_MSG_MONSTER_YELL"); this:UnregisterEvent("PLAYER_REGEN_DISABLED"); this:UnregisterEvent("CHAT_MSG_ADDON"); this:UnregisterEvent("PLAYER_LOGIN"); this:UnregisterEvent("CHAT_MSG_COMBAT_HOSTILE_DEATH") end function IMBA_CloseAllWindows() for k, v in IMBA_Addons do if v.MainFrame then getglobal(v.MainFrame):Hide(); end end end function IMBA_OnLoad() DEFAULT_CHAT_FRAME:AddMessage("IMBA (IMPervious Boss Addons) "..IMBA_Version.." is Loading", 1.0, 1.0, 0.0); IMBA_LoadColors(); IMBA_RegisterEvents(); --Register the slash commands SLASH_IMBA1= IMBA_SLASH_COMMAND; SlashCmdList["IMBA"] = function(msg) IMBA_Command(msg); end IMBA_AddonRunning=false; --To check if an addon is currently doing something IMBA_CombatCheckTime=0; --Last time checked if still in combat IMBA_SyncTime=0; --Last Time synced IMBA_CheckVisibility=GetTime()+1000000000; --Don't want it to start checking till variables are loaded IMBA_SavedVariables.Mods={}; DEFAULT_CHAT_FRAME:AddMessage(" Access the command via /imba", 1.0, 1.0, 0.0); end