------------------------------------------------------- -- RepWatch by Seglberg|Dragonspew (Horde) on THRALL -- Whisper Me or Email Me at Seglberg@live.com -- -- Thanks to Ephemerality for Helping me with the "Default Watch" Feature ------------------------------------------------------- -- Future Additions and Improvments: -- -- o) Ability to Stop the Bar from Changing if you are Already Exalted with that Faction -- o) Sub-Zone Support -- o) Classic Instance Support -- o) Wrath of the Lich King Support -- ------------------------------------------------------- RepWatch = LibStub("AceAddon-3.0"):NewAddon("RepWatch", "AceEvent-3.0", "AceConsole-3.0") --This Build's Version --Underlay Version: 1.0.9 RepWatch.Version = "2.0.2 (WotlK BETA)" --RepWatch.VersionDesc = "\n\n\n\n\n\n\n\n\n\n\n\n\n\n|cffFF7F24[RepWatch] Version:" .. RepWatch.Version .. "\nAuthor: Seglberg of Thrall|r" RepWatch.VersionDesc = "\n\n\n\n\nNOTES:\nThis is A Beta For |cff6495EDWrath of the Lich King|r.\nThis Version is to be Used at the User's Risk.\n\nThis Version uses the RepWatch 1.0.8 Underlay and Will Have Similar Bugs to that Version.\nCheck the Documentation for More Info.\n\n\n\n|cffFF7F24[RepWatch] Version:" .. RepWatch.Version .. "\nAuthor: Seglberg of Thrall|r" --#######################-- --# Option Tables #-- --#######################-- local options = { name = "RepWatch", handler = RepWatch, type = "group", args = { changeOptionsDesc = { order = 1, type = "description", name = " |cffFFD700Auto-Changing Options|r", cmdHidden = true, }, changeWotlK = { order = 2, type = "toggle", name = "|cff6495EDWotlK Instances|r", desc = "Toggle this on/off to Enable or Disable the Changing of the Reputation Bar when you Zone into a Wrath of the Lich King Instance (Default: On)", get = "IsChangeWotlK", set = "ToggleChangeWotlK", }, changeBC = { order = 3, type = "toggle", name = "|cff00CD00BC Instances|r", desc = "Toggle this on/off to Enable or Disable the Changing of the Reputation Bar when you Zone into a Burning Crusade Instance (Default: On)", get = "IsChangeBC", set = "ToggleChangeBC", }, changeClassic = { order = 4, type = "toggle", name = "|cffD2691EClassic Instances|r", desc = "Toggle this on/off to Enable or Disable the Changing of the Reputation Bar when you Zone into a Classic Instance (Default: On)", get = "IsChangeClassic", set = "ToggleChangeClassic", }, changeCities = { order = 5, type = "toggle", name = "In Cities", desc = "Toggle this on/off to Enable or Disable the Changing of the Reputation Bar when you Zone into Capital Cities (Default: On)", get = "IsChangeCities", set = "ToggleChangeCities", }, changeBGs = { order = 6, type = "toggle", name = "In Battlegrounds", desc = "Toggle this on/off to Enable or Disable the Changing of the Reputation Bar when you Zone into a Battleground (Default: On)", get = "IsChangeBGs", set = "ToggleChangeBGs", }, changeSubZones = { order = 6, type = "toggle", name = "In Sub-Zones", desc = "Toggle this on/off to Enable or Disable the Changing of the Reputation Bar when you Enter a Sub-Zone (Default: On)", get = "IsChangeSubZones", set = "ToggleChangeSubZones", }, otherOptionsDesc = { order = 10, type = "description", name = " |cffFFD700Other Options|r", cmdHidden = true, }, showInChat = { order = 11, type = "toggle", name = "Display Notice", desc = "Toggle this on/off to Enable or Disable the Announcements in the Chatbox (Default: On)", get = "IsShowInChat", set = "ToggleShowInChat", }, changeIfExalted = { order = 12, type = "toggle", name = "Change if Exalted", desc = "Toggle this on/off to Enable or Disable the Changing of the Reputation Bar when you are Exalted with the Zone's Faction (Default: Off)", get = "IsChangeIfExalted", set = "ToggleChangeIfExalted", }, defaultFaction = { order = 20, type = "select", name = " Default Faction", desc = "Selects the Faction to Be Used if No Faction Is Available for the Area. Does NOT Apply for Sub-Zone Changes. (Default: None)", values = "GetAllFactions", get = "GetDefaultFaction", set = "SetDefaultFaction", style = "dropdown", }, versionDesc = { order = 100, type = "description", name = RepWatch.VersionDesc, cmdHidden = true, }, }, } local defaults = { char = { changeWotlK = true, changeBC = true, changeClassic = true, changeCities = true, changeBGs = true, changeSubZones = true, showInChat = true, changeIfExalted = false, defaultFaction = 1, --"None" }, } --#####################-- --# Reputation Tables #-- --#####################-- ---------|WotlK Instances|---------- ---------|WotlK Instances|---------- ----------|BC Instances|------------ if UnitFactionGroup("player") == "Horde" then RepWatch.HellfireRep = "Thrallmar" else RepWatch.HellfireRep = "Honor Hold" end local BCInstances = { ["Magisters' Terrace"] = "Shattered Sun Offensive", ["Sunwell Plateau"] = "Shattered Sun Offensive", ["Old Hillsbrad Foothills"] = "Keepers of Time", ["The Black Morass"] = "Keepers of Time", ["Hyjal Summit"] = "The Scale of the Sands", ["Mana-Tombs"] = "The Consortium", ["Auchenai Crypts"] = "Lower City", ["Sethekk Halls"] = "Lower City", ["Shadow Labyrinth"] = "Lower City", ["The Slave Pens"] = "Cenarion Expedition", ["The Underbog"] = "Cenarion Expedition", ["The Streamvault"] = "Cenarion Expedition", ["Serpentshrine Cavern"] = "Cenarion Expedition", ["The Mechanar"] = "The Sha'tar", ["The Botanica"] = "The Sha'tar", ["The Arcatraz"] = "The Sha'tar", ["The Blood Furnace"] = RepWatch.HellfireRep, ["Hellfire Ramparts"] = RepWatch.HellfireRep, ["The Shattered Halls"] = RepWatch.HellfireRep, ["Karazhan"] = "The Violet Eye", ["Black Temple"] = "Ashtongue Deathsworn", } ----------|BC Instances|------------ --------|Classic Instances|--------- local ClassicInstances = { ["Blackrock Depths"] = "Thorium Brotherhood", ["Blackwing Lair"] = nil, ["Dire Maul"] = "Shen'Dralar", ["Maraudon"] = "Cenarion Circle", ["Molten Core"] = "Hydraxian Waterlords", ["Naxxramas"] = "Argent Dawn", ["Ruins of Ahn'Qiraj"] = "Cenarion Circle", ["Scholomance"] = "Argent Dawn", ["Ahn'Qiraj"] = "Brood of Nozdormu", ["Zul'Gurub"] = "Zandalar Tribe", } --------|Classic Instances|--------- ---------|Capital Cities|----------- local CapitalCities = { ["Orgrimmar"] = "Orgrimmar", ["Undercity"] = "Undercity", ["Thunder Bluff"] = "Thunder Bluff", ["Silvermoon City"] = "Silvermoon City", ["Stormwind City"] = "Stormwind", ["Ironforge"] = "Ironforge", ["Darnassus"] = "Darnassus", ["The Exodar"] = "Exodar", ["Shattrath City"] = "The Sha'tar", } ---------|Capital Cities|----------- ----------|Battlegrounds|----------- local Battlegrounds = { Horde = { ["Warsong Gulch"] ="Warsong Outriders", ["Arathi Basin"] = "The Defilers", ["Alterac Valley"] = "Frostwolf Clan", }, Alliance = { ["Warsong Gulch"] ="Silverwing Sentinels", ["Arathi Basin"] = "The League of Arathor", ["Alterac Valley"] = "Stormpike Guard", }, } ----------|Battlegrounds|----------- ------------|Sub-Zones|------------- local SubZones = { ["Isle of Quel'Danas"] = "Shattered Sun Offensive", ["Scryer's Tier"] = "The Scryers", ["Aldor Rise"] = "The Aldor", --Orgi'la Reps ["Forge Camp: Wrath"] = "Ogri'la", ["Vortex Pinnacle"] = "Ogri'la", ["Ogri'la"] = "Ogri'la", ["Forge Camp: Terror"] = "Ogri'la", --Timbermaw Reps ["Timbermaw Hold"] = "Timbermaw Hold", ["Timbermaw Post"] = "Timbermaw Hold", --Thrallmar ["Thrallmar"] = "Thrallmar", --The Mag'har ["Mag'har Grounds"] = "The Mag'har", ["Garadar"] = "The Mag'har", --Sporeggar ["Funggor Cavern"] = "Sporeggar", ["The Spawning Glen"] = "Sporeggar", --Cenarion Expedition ["Cenarion Watchpost"] = "Cenarion Expedition", } ------------|Sub-Zones|------------- --#############-- --# Functions #-- --#############-- ------------------------------------- function RepWatch:OnInitialize() ------------------------------------- --Called When the Addon is Loaded --Register the Database RepWatch.db = LibStub("AceDB-3.0"):New("RepWatchDB", defaults, "Char") --Register Options Table and Menu LibStub("AceConfig-3.0"):RegisterOptionsTable("RepWatch", options) --Adds Menu to Blizzard's Menu self.optionsFrame = LibStub("AceConfigDialog-3.0"):AddToBlizOptions("RepWatch", "RepWatch") --Register the /RepWatch Chat Command self:RegisterChatCommand("RepWatch", "ChatCommand") end ------------------------------------- ------------------------------------- ------------------------------------- function RepWatch:OnEnable() ------------------------------------- --Called When the Addon is Enabled --Register Event Triggers RepWatch:RegisterEvent("ZONE_CHANGED_NEW_AREA") --Fires everytime Channels Switch RepWatch:RegisterEvent("ZONE_CHANGED") --Fires everytime Subzones Switch --Print off Version and Enable Message self:Print("RepWatch Ver.|cff6495ED", RepWatch.Version, "|rLoaded") self:Print("Type /RepWatch for Options Menu") self:Print("No |cff6495EDWotlK|r Reputations are Working Yet,\nThis Version is Meant to Test out Compatability\nwith Client 3.0") --Manually Fires Change to Check when Initially Logging In RepWatch:ZONE_CHANGED_NEW_AREA() end ------------------------------------- ------------------------------------- ------------------------------------- function RepWatch:OnDisable() ------------------------------------- --called when the Addon is Disabled end ------------------------------------- ------------------------------------- ------------------------------------- function RepWatch:ChatCommand(input) ------------------------------------- --Handles chat command input if not input or input:trim() == "" then InterfaceOptionsFrame_OpenToFrame(self.optionsFrame) else --LibStub("AceConfigDialog-3.0").HandleCommand(RepWatch, "RepWatch", input) RepWatch:Print("Command Not Available, type /RepWatch for Options Menu") end end ------------------------------------- ------------------------------------- ------------------------------------- function RepWatch:IsChangeWotlK(info) ------------------------------------- return (self.db.char.changeWotlK) end ------------------------------------- ------------------------------------- ------------------------------------- function RepWatch:ToggleChangeWotlK(info, value) ------------------------------------- self.db.char.changeWotlK = value if (self.db.char.showInChat) then if (self.db.char.changeWotlK) then self:Print("Entering |cff6495EDWotlK|r Instances |cff32cd32Will Now|r Switch the Rep Bar") else self:Print("Entering |cff6495EDWotlK|r Instances |cffff0000Will Not|r Switch the Rep Bar") end end RepWatch:ZONE_CHANGED_NEW_AREA() end ------------------------------------- ------------------------------------- ------------------------------------- function RepWatch:IsChangeBC(info) ------------------------------------- return (self.db.char.changeBC) end ------------------------------------- ------------------------------------- ------------------------------------- function RepWatch:ToggleChangeBC(info, value) ------------------------------------- self.db.char.changeBC = value if (self.db.char.showInChat) then if (self.db.char.changeBC) then self:Print("Entering |cff00CD00BC|r Instances |cff32cd32Will Now|r Switch the Rep Bar") else self:Print("Entering |cff00CD00BC|r Instances |cffff0000Will Not|r Switch the Rep Bar") end end RepWatch:ZONE_CHANGED_NEW_AREA() end ------------------------------------- ------------------------------------- ------------------------------------- function RepWatch:IsChangeClassic(info) ------------------------------------- return (self.db.char.changeClassic) end ------------------------------------- ------------------------------------- ------------------------------------- function RepWatch:ToggleChangeClassic(info, value) ------------------------------------- self.db.char.changeClassic = value if (self.db.char.showInChat) then if (self.db.char.changeClassic) then self:Print("Entering |cffD2691EClassic|r Instances |cff32cd32Will Now|r Switch the Rep Bar") else self:Print("Entering |cffD2691EClassic|r Instances |cffff0000Will Not|r Switch the Rep Bar") end end RepWatch:ZONE_CHANGED_NEW_AREA() end ------------------------------------- ------------------------------------- ------------------------------------- function RepWatch:IsChangeCities(info) ------------------------------------- return (self.db.char.changeCities) end ------------------------------------- ------------------------------------- ------------------------------------- function RepWatch:ToggleChangeCities(info, value) ------------------------------------- self.db.char.changeCities = value if (self.db.char.showInChat) then if (self.db.char.changeCities) then self:Print("Entering Capital Cities |cff32cd32Will Now|r Switch the Rep Bar") else self:Print("Entering capital Cities |cffff0000Will Not|r Switch the Rep Bar") end end RepWatch:ZONE_CHANGED_NEW_AREA() end ------------------------------------- ------------------------------------- ------------------------------------- function RepWatch:IsChangeBGs(info) ------------------------------------- return (self.db.char.changeBGs) end ------------------------------------- ------------------------------------- ------------------------------------- function RepWatch:ToggleChangeBGs(info, value) ------------------------------------- self.db.char.changeBGs = value if (self.db.char.showInChat) then if (self.db.char.changeBGs) then self:Print("Entering Battlegrounds |cff32cd32Will Now|r Switch the Rep Bar") else self:Print("Entering Battlegrounds |cffff0000Will Not|r Switch the Rep Bar") end end RepWatch:ZONE_CHANGED_NEW_AREA() end ------------------------------------- ------------------------------------- ------------------------------------- function RepWatch:IsChangeSubZones(info) ------------------------------------- return (self.db.char.changeSubZones) end ------------------------------------- ------------------------------------- ------------------------------------- function RepWatch:ToggleChangeSubZones(info, value) ------------------------------------- self.db.char.changeSubZones = value if (self.db.char.showInChat) then if (self.db.char.changeSubZones) then self:Print("Entering Sub-Zones |cff32cd32Will Now|r Switch the Rep Bar") else self:Print("Entering Sub-Zones |cffff0000Will Not|r Switch the Rep Bar") end end RepWatch:ZONE_CHANGED_NEW_AREA() end ------------------------------------- ------------------------------------- ------------------------------------- function RepWatch:IsShowInChat(info) ------------------------------------- return (self.db.char.showInChat) end ------------------------------------- ------------------------------------- ------------------------------------- function RepWatch:ToggleShowInChat(info, value) ------------------------------------- self.db.char.showInChat = value if (self.db.char.showInChat) then self:Print("Notices |cff32cd32Will Now|r Be Shown in the Chat Window") else self:Print("Notices |cffff0000Will Not|r Be Shown in the Chat Window") end end ------------------------------------- ------------------------------------- ------------------------------------- function RepWatch:IsChangeIfExalted(info) ------------------------------------- return (self.db.char.changeIfExalted) end ------------------------------------- ------------------------------------- ------------------------------------- function RepWatch:ToggleChangeIfExalted(info, value) ------------------------------------- self.db.char.changeIfExalted = value if (self.db.char.showInChat) then if (value) then self:Print("The Rep Bar |cff32cd32Will Now|r Change When You Are Exalted with a Faction") else self:Print("The Rep Bar |cffff0000Will Not|r Change When You Are Exalted with a Faction") end end RepWatch:ZONE_CHANGED_NEW_AREA() end ------------------------------------- ------------------------------------- ------------------------------------- function RepWatch:GetDefaultFaction(info) ------------------------------------- return (self.db.char.defaultFaction) end ------------------------------------- ------------------------------------- ------------------------------------- function RepWatch:SetDefaultFaction(info, value) ------------------------------------- self.db.char.defaultFaction = value if (self.db.char.showInChat) then if (value) == 1 then --Remember: 1 is the eqiv. to "None" self:Print("The Rep Bar |cffff0000Will Not|r Change if No Faction is Available for the Area") elseif (value) == 2 then --Remember: 2 is the quiv. to "Auto-Off" self:Print("The Rep Bar |cff32cd32Will Disappear|r if No Faction is Available for the Area") else self:Print("The Rep Bar Will Change to |cff32cd32", GetFactionInfo(value - 2), "|r if No Faction is Available for the Area") end end end ------------------------------------- ------------------------------------- ------------------------------------- function RepWatch:GetAllFactions() ------------------------------------- local factionList = { "None", "Auto-Off", } factionListIndex = 3 for factionIndex = 1, GetNumFactions() do local isHeader = select(9, GetFactionInfo(factionIndex)) if isHeader ~= 1 then factionList[factionListIndex] = GetFactionInfo(factionIndex) end factionListIndex = (factionListIndex + 1) end return (factionList) end ------------------------------------- ------------------------------------- ------------------------------------- function RepWatch:ZONE_CHANGED() ------------------------------------- --RepWatch.Print("Zone Changed Fired") RepWatch:ZONE_CHANGED_NEW_AREA() end ------------------------------------- function RepWatch:ZONE_CHANGED_NEW_AREA() ------------------------------------- RepWatch.ZoneFound = 0 RepWatch.SubZoneFound = 0 self.usedDefault = 0 RepWatch.usedMini = 0 --self:Print("Zone Changed New Area Fired") --if (self.db.char.changeWotlK) then -- RepWatch.ZoneFound = RepWatch:ChangeRep("WotlKInstances") -- self.colorCode = "|cff6495ED" --end if (self.db.char.changeBC) and (RepWatch.ZoneFound ~= 1) then tableName = BCInstances RepWatch.ZoneFound = RepWatch:ChangeRep(tableName) self.colorCode = "|cff00CD00" end if (self.db.char.changeClassic) and (RepWatch.ZoneFound ~= 1) then tableName = ClassicInstances RepWatch.ZoneFound = RepWatch:ChangeRep(tableName) self.colorCode = "|cffEE7621" end if (self.db.char.changeCities) and (RepWatch.ZoneFound ~= 1) then tableName = CapitalCities RepWatch.ZoneFound = RepWatch:ChangeRep(tableName) self.colorCode = "|cffFFD700" end if (self.db.char.changeBGs) and (RepWatch.ZoneFound ~= 1) then tableName = Battlegrounds RepWatch.ZoneFound = RepWatch:ChangeBGRep(tableName) self.colorCode = "|cffFFD700" end if (self.db.char.changeSubZones) then tableName = SubZones RepWatch.SubZoneFound = RepWatch:ChangeSubRep(tableName) self.colorCode = "|cffFFD700" end --Checks the showInChat Option for Display if (self.db.char.showInChat == false) then RepWatch.noDisplay = 1 end if (RepWatch.ZoneFound == 0) and (RepWatch.SubZoneFound == 0) then self.usedDefault = 1 if (GetWatchedFactionInfo() == GetFactionInfo(self.db.char.defaultFaction - 2)) then RepWatch.noDisplay = 1 end if (self.db.char.defaultFaction == 2) then SetWatchedFactionIndex(0) if (RepWatch.noDisplay ~= 1) then self:Print("Auto-Off") end elseif (self.db.char.defaultFaction ~= 1) then SetWatchedFactionIndex(self.db.char.defaultFaction - 2) if (RepWatch.noDisplay ~= 1) then self:Print("Changing To: [|cffFFD700" .. GetFactionInfo(self.db.char.defaultFaction - 2) .. "|r]") end end end if (RepWatch.noDisplay ~= 1) and (RepWatch.usedMini ~= 1) then if (RepWatch.ZoneFound == 1) or (RepWatch.SubZoneFound == 1) then self:Print("Changing To: [" .. self.colorCode .. RepWatch.factionName .. "|r]") end elseif (RepWatch.noDisplay ~= 1) then if (RepWatch.ZoneFound == 1) or (RepWatch.SubZoneFound == 1) then self:Print("Changing To: [" .. self.colorCode .. RepWatch.factionName .. "|r]") end end end ------------------------------------- ------------------------------------- ------------------------------------- function RepWatch:ChangeRep(tableName) ------------------------------------- RepWatch.noDisplay = 0 --RepWatch:Print("Table Name:", tableName) if (GetWatchedFactionInfo() == tableName[GetRealZoneText()]) then RepWatch.noDisplay = 1 end --Sets the Watched Faction using Real Zone Text for factionIndex = 1, GetNumFactions() do RepWatch.factionName = GetFactionInfo(factionIndex) if RepWatch.factionName == tableName[GetRealZoneText()] then if (select(6, GetFactionInfo(factionIndex)) == 42999) then if (self.db.char.changeIfExalted) then SetWatchedFactionIndex(factionIndex) else return (0) end else SetWatchedFactionIndex(factionIndex) end return (1) end end if (GetWatchedFactionInfo() == tableName[GetMinimapZoneText()]) then RepWatch.noDisplay = 1 end --Sets the Watched Faction using Minimap Zone Text for factionIndex = 1, GetNumFactions() do RepWatch.factionName = GetFactionInfo(factionIndex) if RepWatch.factionName == tableName[GetMinimapZoneText()] then if (select(6, GetFactionInfo(factionIndex)) == 42999) then if (self.db.char.changeIfExalted) then SetWatchedFactionIndex(factionIndex) else return (0) end else SetWatchedFactionIndex(factionIndex) end return (1) end end return (0) end ------------------------------------- ------------------------------------- ------------------------------------- function RepWatch:ChangeBGRep(tableName) ------------------------------------- RepWatch.noDisplay = 0 --RepWatch:Print("Table Name:", tableName) if (GetWatchedFactionInfo() == tableName[UnitFactionGroup("player")][GetRealZoneText()]) then RepWatch.noDisplay = 1 end --Sets the Watched Faction for factionIndex = 1, GetNumFactions() do RepWatch.factionName = GetFactionInfo(factionIndex) if RepWatch.factionName == tableName[UnitFactionGroup("player")][GetRealZoneText()] then if (select(6, GetFactionInfo(factionIndex)) == 42999) then self.isExalted = 1 if (self.db.char.changeIfExalted) then SetWatchedFactionIndex(factionIndex) else return (0) end else SetWatchedFactionIndex(factionIndex) end return (1) end end return (0) end ------------------------------------- ------------------------------------- ------------------------------------- function RepWatch:ChangeSubRep(tableName) ------------------------------------- --RepWatch:Print("Table Name:", tableName) if (GetWatchedFactionInfo() == tableName[GetRealZoneText()]) then RepWatch.noDisplay = 1 end --Sets the Watched Faction using Real Zone Text for factionIndex = 1, GetNumFactions() do RepWatch.factionName2 = GetFactionInfo(factionIndex) if RepWatch.factionName2 == tableName[GetRealZoneText()] then RepWatch.noDisplay = 0 if (GetWatchedFactionInfo() == tableName[GetRealZoneText()]) then RepWatch.noDisplay = 1 end RepWatch.factionName = RepWatch.factionName2 if (select(6, GetFactionInfo(factionIndex)) == 42999) then self.isExalted = 1 if (self.db.char.changeIfExalted) then SetWatchedFactionIndex(factionIndex) else return (0) end else SetWatchedFactionIndex(factionIndex) end return (1) end end --Sets the Watched Faction using Sub Zone Text for factionIndex = 1, GetNumFactions() do RepWatch.factionName2 = GetFactionInfo(factionIndex) if RepWatch.factionName2 == tableName[GetSubZoneText()] then RepWatch.noDisplay = 0 if (GetWatchedFactionInfo() == tableName[GetSubZoneText()]) then RepWatch.noDisplay = 1 end RepWatch.factionName = RepWatch.factionName2 if (select(6, GetFactionInfo(factionIndex)) == 42999) then self.isExalted = 1 if (self.db.char.changeIfExalted) then SetWatchedFactionIndex(factionIndex) else return (0) end else SetWatchedFactionIndex(factionIndex) end return (1) end end return (0) end ------------------------------------- -------------------------------------