From 4e7782bd5b9bfef577754ddc071b085381cf364a Mon Sep 17 00:00:00 2001 From: pigmonkey Date: Mon, 30 May 2011 13:25:40 -0400 Subject: [PATCH] battlegrounds and macros --- AllTheLittleThings.old.lua | 154 --------------------------------- modules/.battlegrounds.lua.swp | Bin 12288 -> 16384 bytes modules/battlegrounds.lua | 115 +++++++++++++++++++++++- modules/template.lua | 2 + 4 files changed, 115 insertions(+), 156 deletions(-) diff --git a/AllTheLittleThings.old.lua b/AllTheLittleThings.old.lua index 5f75644..3675f10 100644 --- a/AllTheLittleThings.old.lua +++ b/AllTheLittleThings.old.lua @@ -58,22 +58,6 @@ local options = { get = function(info) return core.db.profile.nixAFK end, set = function(info, v) core.db.profile.nixAFK = v core:OnEnable() end, }, - autoWG = { - order = 35, - name = "Auto Wintergrasp Join", - desc = "Automatically joins Wintergrasp if in Dalaran or Ironforge. Also boots that faggot Unhidenenemy.", - type = "toggle", - get = function(info) return core.db.profile.autoWG end, - set = function(info, v) core.db.profile.autoWG = v core:OnEnable() end, - }, - eotsFlag = { - order = 40, - name = "Eye of the Storm Flag", - desc = "Adds in points for a held flag based on bases owned.", - type = "toggle", - get = function(info) return core.db.profile.eotsFlag end, - set = function(info, v) core.db.profile.eotsFlag = v core:OnEnable() end, - }, achieveFilter = { order = 45, name = "Achievement Filter", @@ -153,12 +137,6 @@ local aoeSpellWatch = { ["Challenging Shout"] = true, ["Challenging Roar"] = true, }; -local gilneasTimes = { -- time in seconds to get a point - [0] = 0, - [1] = 8, - [2] = 3, - [3] = 1/3, -} local potList = { ["a"] = 58146, -- Golemblood ["b"] = 58145, -- Tol'vir @@ -180,9 +158,6 @@ core.guildView = nil core.interruptCast = false core.consolidateHook = false core.mlOrder = {"Chira", "Devotchka", "Yawning", "Brinkley", "Toney", "Dcon"} -core.wgStatus = 0 -core.flagStatus = 0 -core.eotsHook = false core.achieveHook = false core.hallowBuff = nil core.countDown = {"Pulling in 5", "4", "3", "2", "1", "Go"} -- used in /atlt cd @@ -265,10 +240,6 @@ function core:OnEnable() self:RegisterEvent("BATTLEFIELD_MGR_ENTRY_INVITE") end if self.db.profile.eotsFlag and not self.eotsHook then - self:RawHook("WorldStateAlwaysUpFrame_Update", true) - self.eotsHook = true - self:RegisterEvent("CHAT_MSG_BG_SYSTEM_ALLIANCE", "BattlegroundMessage") - self:RegisterEvent("CHAT_MSG_BG_SYSTEM_HORDE", "BattlegroundMessage") end if self.db.profile.achieveFilter and not self.achieveHook then self:RawHook("AchievementFrame_LoadUI", true) @@ -317,93 +288,11 @@ end function core:SlashProcess(msg) if msg == "debug" then self:BugInit() - elseif msg == "disbandraid" or msg == "dr" then - for i=1, GetNumRaidMembers() do - if not UnitIsUnit("raid"..i,"player") then - UninviteUnit("raid"..i) - end - end - elseif msg == "inviteguild" or msg == "ig" then - for i=1, select(2, GetNumGuildMembers()) do - if not UnitInRaid(GetGuildRosterInfo(i)) then - InviteUnit(GetGuildRosterInfo(i)) - end - end - elseif msg == "promoteall" or msg == "pa" then - for i=0, GetNumRaidMembers() do - PromoteToAssistant("raid"..i) - end - elseif msg == "printloot" or msg == "pl" then - self:RaidDump("Send tells for loot:", "raid_warning") - for i=1,GetNumLootItems() do - self:RaidDump(GetLootSlotLink(i) .. " (" .. ({"A", "B", "C", "D", "E", "F", "G", "H"})[i] .. ")", "raid_warning") - end - elseif msg == "clearmarks" or msg == "cm" then - for i=8,0,-1 do - SetRaidTarget("player", i) - end - self:ScheduleTimer(function() SetRaidTarget("player", 0) end, 0.5) elseif msg == "rolltally" or msg == "rt" then self:CHAT_MSG_RAID_WARNING(nil, "roll") elseif msg == "phone" then -- prints missing phone numbers self:FindMissingPhones(); - elseif msg == "masterloot" or msg == "ml" then - self:MasterLoot() - elseif msg == "randomloot" or msg == "rl" then - local members = {} - for i=1,40 do - if GetMasterLootCandidate(i) then - table.insert(members, i); - end - end - - for j=1, GetNumLootItems() do - GiveMasterLoot(j, members[random(#members)]) - end - elseif msg == "arathibasin" or msg == "ab" then - if GetRealZoneText() == "Arathi Basin" then - local _, _, aB, aP = string.find(select(4, GetWorldStateUIInfo(1)), "(%d).-(%d+)/") - local _, _, hB, hP = string.find(select(4, GetWorldStateUIInfo(2)), "(%d).-(%d+)/") - local ttw = math.min((1600-aP)*(5-aB)*.3, (1600-hP)*(5-hB)*.3) - local need = math.ceil(5/((1600-hP)/(1600-aP)+1)) - -- local timeDiff = (1600-aP)*(5-need)*.3 - (1600-hP)*need*.3) - -- local timeDiff = (hP-aP)/(2*need-6+(hP-aP)/math.abs(hP-aP))/3 - local timeDiff - if hP > aP then - timeDiff = (hP - aP) / (10/3 * (1/(5-need) - 1/need)) - elseif aP > hP then - timeDiff = (hP - aP) / (10/3 * (1/(need-1) - 1/(6-need))) - else - timeDiff = 0 - end - self:Print(string.format("Game end: %d:%02d, Bases needed: %d", floor(ttw/60), ttw%60, need)) --, floor(timeDiff/60), timeDiff%60, timeDiff)) - elseif GetRealZoneText() == "The Battle for Gilneas" then - -- gilneasTimes - table with time per point - local _, _, aB, aP = string.find(select(4, GetWorldStateUIInfo(1)), "(%d).-(%d+)/") - local _, _, hB, hP = string.find(select(4, GetWorldStateUIInfo(2)), "(%d).-(%d+)/") - local ttw = math.min((2000-aP)/10*gilneasTimes[aB], (2000-hP)/10*gilneasTimes[hB]) - local need = 0 - if (2000-aP)*8/3+hP > 2000 then - need = 2 - else - need = 1 - end - -- local timeDiff = (2000-aP)*(5-need)*.3 - (2000-hP)*need*.3) - -- local timeDiff = (hP-aP)/(2*need-6+(hP-aP)/math.abs(hP-aP))/3 - -- timeDiff means: "if we both keep going at the current rate, the point when we will need one less/more base is in x:xx" - local timeDiff - if hP > aP then - timeDiff = (hP - aP) / (10/3 * (1/(5-need) - 1/need)) - elseif aP > hP then - timeDiff = (hP - aP) / (10/3 * (1/(need-1) - 1/(6-need))) - else - timeDiff = 0 - end - self:Print(string.format("Game end: %d:%02d, Bases needed: %d", floor(ttw/60), ttw%60, need)) - else - self:Print("You must be in Arathi Basin or The Battle for Gilneas to use this command.") - end elseif msg == "ilevel" or msg == "il" then self:RaidDump("Tallying iLevel Sums...") r = {} @@ -429,8 +318,6 @@ function core:SlashProcess(msg) self:RaidDump("---") elseif msg == "combatlog" or msg == "cl" then CombatLogClearEntries() - elseif msg == "count" or msg == "ct" then - self:Countdown() elseif msg:match("^pots ") then -- get all guild members for i=1,GetNumGuildMembers() do @@ -790,13 +677,6 @@ function core:CHAT_MSG_SYSTEM(_, message, source) end end -function core:BATTLEFIELD_MGR_ENTRY_INVITE() - if self.db.profile.autoWG and (GetRealZoneText() == "Dalaran" or GetRealZoneText() == "Ironforge") then - BattlefieldMgrEntryInviteResponse(1, 1) - wgStatus = 1 - -- self:SetScript("OnKeyDown", self.OnKeyDown) - end -end -- g_allDebuffs = {} function core:COMBAT_LOG_EVENT_UNFILTERED(_, timestamp, event, _, srcGUID, srcName, srcFlags, dstGUID, dstName, dstFlags, spellid, spellName, spellSchool, extraSpellid, extraSpellName, ...) @@ -935,12 +815,6 @@ function core:GetMode() return diff; -- (dynFlag and (2-(diff%2)+2*dynHeroic)) or diff; end -function core:OnKeyDown() - if self.wgStatus > 0 and GetRealZoneText() ~= "Wintergrasp" then - self.wgStatus = 0 - BattlefieldMgrEntryInviteResponse(1, 1) - end -end function core:CheckSmash() local sum, str @@ -1041,35 +915,7 @@ function core:GuildRosterButton_OnClick(this, button, ...) end end -function core:WorldStateAlwaysUpFrame_Update(...) - self.hooks["WorldStateAlwaysUpFrame_Update"](...) - if GetRealZoneText() == "Eye of the Storm" then - local points = {[0]=0, 75, 85, 100, 500} - if self.flagStatus > 0 then - local i = self.flagStatus + 1 - if select(3, GetWorldStateUIInfo(i)) then -- extra if since I got a lua error while leaving a BG once - local _, _, full, bases, score = string.find(select(3, GetWorldStateUIInfo(i)), "(Bases: (%d).-(%d+)/.+)") - if not full then return end - -- self:Print(string.find(select(3, GetWorldStateUIInfo(i)), "(Bases: (%d).-(%d+)/.+)")) - -- self:Print(GetWorldStateUIInfo(i)) - local nScore = "|cff00ff00" .. (tonumber(score)+points[tonumber(bases)]) .. "|r" - local frame = _G["AlwaysUpFrame"..self.flagStatus.."Text"] - if frame then - frame:SetText(string.gsub(full, score.."/", nScore.."/")) - end - end - end - end -end -function core:BattlegroundMessage(event, msg) - local faction = ((event=="CHAT_MSG_BG_SYSTEM_ALLIANCE" and 1) or 2) - if string.find(msg, "captured.+flag") or string.find(msg, "dropped.+flag") then - self.flagStatus = 0 - elseif string.find(msg, "taken.+flag") then - self.flagStatus = faction - end -end function core:AchievementFrame_LoadUI(...) local args = {self.hooks["AchievementFrame_LoadUI"](...)} diff --git a/modules/.battlegrounds.lua.swp b/modules/.battlegrounds.lua.swp index 4d699fb04363803248131dd80d676d9df54900c2..f0509b19980ed0f2efe2a0ae9f706600e179ca48 100644 GIT binary patch literal 16384 zcmeHOO^h5z74C%aGXy&bP!dj58X0x(&h+%`#v5nE8qMyG*F$z~Yjt`~ITaxZiSkWp@N%IrkpAaG*KAMm?qNd8LBzt|0xFW)+3r0 z0879kU<0264gn7Xw+?IC-+^BOUjd#0mVu{%$AI4*(zF}EPk`&dTfkLd2M7THTma4k zb)W*+z-NHJeL~Y-2VMiN0pA3^3Oow@>S5Fg`~uhkHUJCw!^bu4C7=cz0&W&G?PXva zaDfu=81Sc$Y1(gq8^Cp-1pM=(n)Xv503HW!d_>cJ47>t-9k>iU2V4ZEfWLki_rSBj zN#GIS)t({2?5nS@5SQBv{XDWnI zDYA;G3Ke4EyVkI?F1Z}UY@XRF+jH6EgX7F*JaE{ukZXeb&xV0$ifw6_?8-dT&#Pk_ zINlNWbtbzaAR+D`XiF~)7|v@{PY2J4ouzOX7$&p;EmqAfq<^!^=vr`bR76zQg;ce~ zGQ!CZs}m1ehCA^6B8%H$BrHoW>qQoBqXRJFdT1SZ9kia?V7V%v3Xo1inxVulQZL9ZnuL$%AC?uTF` z-WX-Kcr0Rb)1;U67b9H>1xHkA^$a>E4KRD2j>FJMh_j7G;D&~m_Gj|VlnvJl9O~Ns zpW;`I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T^fSCy^N%p zr25-3;^bw)7j6sIK%AKzN&Nq^OhggF{lhN&6@-xaB^7^W3(If|+Z5qXyX8^)X`g7! z`JGll+@v8B4``qwhPaQ3?V?f15;;3!I`+^*}P9q=e;GHH4 zQttIhv+$&9UKfFec;ilyhE2n=tUa#&u2LKnoJb0cZ(HqUV;-KV+Uy#|SjWd3Q6FfS z=+dpt%`yv_U2IQZz91dQDNx11>K_s3pJMj{!Aw22r@ z!w?i7nx8)?Ks1W%s0}}CpP-_dF}}#_tR4_NN@NyU7USAGRQD9;n%FdiQWI~qJ-FVE zygmY5qy0s=%Zk%c289{N0yMPsaJL(zsamF?15!%brQ5UrNm`i(FLa{n;5SAwjcn*A w;#>>0W^<)}qETO2+FD&++p3>xu3gw_oI2NN))D(cf5!tR_ZBTg>4ePx0EQIfEC2ui delta 240 zcmZo@U~EWGNHPfX^i?p|GiCq+0S1Q6ryu)*m^P9O3@-Vl=@TESY;@Vj&(Fy4A1KNM z#9~0qxLHx)KL11mfk_H1X@7Yc7&7^QqCo8+$vylG3=KeB55ze@oCU-YKpY0dp+GDH z#6m#K0mT1+`aS{i2Oz!&#HWCG3lMJx;^{z~2gF%GoXNM?P=Jp)H7{lID;*z!)clfS zkNo^>1zUx*#GK;P$p*Up!a4cLi8%`S1tppJdBs4PYKGd$`uft7OY}`9@6vYz0RP1{ A3jhEB diff --git a/modules/battlegrounds.lua b/modules/battlegrounds.lua index 1dc95c8..b3c785b 100644 --- a/modules/battlegrounds.lua +++ b/modules/battlegrounds.lua @@ -1,9 +1,22 @@ local core = LibStub("AceAddon-4.0"):GetAddon("AllTheLittleThings") -local mod = core:NewModule("Battlegrounds", "AceEvent-3.0") +local mod = core:NewModule("Battlegrounds", "AceEvent-3.0", "AceConsole-3.0") +local db = core.db.profile[mod:GetName()] local defaults = { + autoWG = false, + eotsFlag = true, } local options = { + autoWG = { + name = "Auto Wintergrasp Join", + desc = "Automatically joins Wintergrasp if in Dalaran or Ironforge. Also boots that faggot Unhidenenemy.", + type = "toggle", + }, + eotsFlag = { + name = "Eye of the Storm Flag", + desc = "Adds in points for a held flag based on bases owned.", + type = "toggle", + }, } local gilneasTimes = { -- time in seconds to get a point @@ -14,9 +27,107 @@ local gilneasTimes = { -- time in seconds to get a point } core.wgStatus = 0 core.flagStatus = 0 -core.eotsHook = false function mod:OnInitialize() core:RegisterOptions(options, defaults) + core:RegisterSlash("ArathiPrint", "ab", "arathibasin") end +function mod:OnEnable() + self:RawHook("WorldStateAlwaysUpFrame_Update", true) + self:RegisterEvent("CHAT_MSG_BG_SYSTEM_ALLIANCE", "BattlegroundMessage") + self:RegisterEvent("CHAT_MSG_BG_SYSTEM_HORDE", "BattlegroundMessage") +end + +-- Arathi Basin ---------------------------------------------------------------- +function mod:ArathiPrint(msg) + if GetRealZoneText() == "Arathi Basin" then + local _, _, aB, aP = string.find(select(4, GetWorldStateUIInfo(1)), "(%d).-(%d+)/") + local _, _, hB, hP = string.find(select(4, GetWorldStateUIInfo(2)), "(%d).-(%d+)/") + local ttw = math.min((1600-aP)*(5-aB)*.3, (1600-hP)*(5-hB)*.3) + local need = math.ceil(5/((1600-hP)/(1600-aP)+1)) + -- local timeDiff = (1600-aP)*(5-need)*.3 - (1600-hP)*need*.3) + -- local timeDiff = (hP-aP)/(2*need-6+(hP-aP)/math.abs(hP-aP))/3 + local timeDiff + if hP > aP then + timeDiff = (hP - aP) / (10/3 * (1/(5-need) - 1/need)) + elseif aP > hP then + timeDiff = (hP - aP) / (10/3 * (1/(need-1) - 1/(6-need))) + else + timeDiff = 0 + end + self:Print(string.format("Game end: %d:%02d, Bases needed: %d", floor(ttw/60), ttw%60, need)) --, floor(timeDiff/60), timeDiff%60, timeDiff)) + elseif GetRealZoneText() == "The Battle for Gilneas" then + -- gilneasTimes - table with time per point + local _, _, aB, aP = string.find(select(4, GetWorldStateUIInfo(1)), "(%d).-(%d+)/") + local _, _, hB, hP = string.find(select(4, GetWorldStateUIInfo(2)), "(%d).-(%d+)/") + local ttw = math.min((2000-aP)/10*gilneasTimes[aB], (2000-hP)/10*gilneasTimes[hB]) + local need = 0 + if (2000-aP)*8/3+hP > 2000 then + need = 2 + else + need = 1 + end + -- local timeDiff = (2000-aP)*(5-need)*.3 - (2000-hP)*need*.3) + -- local timeDiff = (hP-aP)/(2*need-6+(hP-aP)/math.abs(hP-aP))/3 + -- timeDiff means: "if we both keep going at the current rate, the point when we will need one less/more base is in x:xx" + local timeDiff + if hP > aP then + timeDiff = (hP - aP) / (10/3 * (1/(5-need) - 1/need)) + elseif aP > hP then + timeDiff = (hP - aP) / (10/3 * (1/(need-1) - 1/(6-need))) + else + timeDiff = 0 + end + self:Print(string.format("Game end: %d:%02d, Bases needed: %d", floor(ttw/60), ttw%60, need)) + else + self:Print("You must be in Arathi Basin or The Battle for Gilneas to use this command.") + end +end + +-- Wintergrasp ----------------------------------------------------------------- +function mod:BATTLEFIELD_MGR_ENTRY_INVITE() + if db.autoWG and (GetRealZoneText() == "Dalaran" or GetRealZoneText() == "Ironforge") then + BattlefieldMgrEntryInviteResponse(1, 1) + wgStatus = 1 + -- self:SetScript("OnKeyDown", self.OnKeyDown) + end +end + +-- Eye of the Storm ------------------------------------------------------------ +function core:BattlegroundMessage(event, msg) + local faction = ((event=="CHAT_MSG_BG_SYSTEM_ALLIANCE" and 1) or 2) + if string.find(msg, "captured.+flag") or string.find(msg, "dropped.+flag") then + self.flagStatus = 0 + elseif string.find(msg, "taken.+flag") then + self.flagStatus = faction + end +end + +function mod:WorldStateAlwaysUpFrame_Update(...) + self.hooks["WorldStateAlwaysUpFrame_Update"](...) + if db.eotsFlag and GetRealZoneText() == "Eye of the Storm" then + local points = {[0]=0, 75, 85, 100, 500} + if self.flagStatus > 0 then + local i = self.flagStatus + 1 + if select(3, GetWorldStateUIInfo(i)) then -- extra if since I got a lua error while leaving a BG once + local _, _, full, bases, score = string.find(select(3, GetWorldStateUIInfo(i)), "(Bases: (%d).-(%d+)/.+)") + if not full then return end + -- self:Print(string.find(select(3, GetWorldStateUIInfo(i)), "(Bases: (%d).-(%d+)/.+)")) + -- self:Print(GetWorldStateUIInfo(i)) + local nScore = "|cff00ff00" .. (tonumber(score)+points[tonumber(bases)]) .. "|r" + local frame = _G["AlwaysUpFrame"..self.flagStatus.."Text"] + if frame then + frame:SetText(string.gsub(full, score.."/", nScore.."/")) + end + end + end + end +end + +-- function mod:OnKeyDown() +-- if self.wgStatus > 0 and GetRealZoneText() ~= "Wintergrasp" then +-- self.wgStatus = 0 +-- BattlefieldMgrEntryInviteResponse(1, 1) +-- end +-- end diff --git a/modules/template.lua b/modules/template.lua index b16f4f2..af15b03 100644 --- a/modules/template.lua +++ b/modules/template.lua @@ -1,5 +1,6 @@ local core = LibStub("AceAddon-3.0"):GetAddon("AllTheLittleThings") local mod = core:NewModule("Battlegrounds", "AceEvent-3.0") +local db = core.db.profile[mod:GetName()] local defaults = { } @@ -8,5 +9,6 @@ local options = { function mod:OnInitialize() core:RegisterOptions(options, defaults) + core:RegisterSlashCommand("method", "slsh1", "slash2") end