467 lines
22 KiB
Lua
467 lines
22 KiB
Lua
-- OctoTextSize: addon-local factory; Blizzard CreateFrame is unchanged.
|
|
local CreateFrame = OctoTextSize and OctoTextSize.WrapFactory(CreateFrame) or CreateFrame
|
|
-- SPDX-License-Identifier: GPL-2.0-or-later
|
|
-- Lazy Pig: the Octo 1.12 _LazyPig automation on native 70334 APIs. Options live in the native Settings panel
|
|
-- (Esc > Options > AddOns > Lazy Pig). Only unprotected API is used; Blizzard globals are never written (taint).
|
|
local ADDON = ...
|
|
|
|
-- Saved settings. Roll settings: -1 off, 0 pass, 1 need, 2 greed (1.12 LPCONFIG used nil for off).
|
|
local DEFAULTS = {
|
|
DISMOUNT = true, CAM = false, GINV = true, FINV = true, SINV = false, DINV = true, SUMM = false,
|
|
LBG = true, RBG = true, SBG = false, LOOT = false,
|
|
GREEN = -1, ZG = 1, MC = -1, AQ = -1, SAND = 1, ES_SHARDS = -1, NAXX = -1, ROLLMSG = false,
|
|
DUEL = false, SPECIALKEY = false,
|
|
WORLDDUNGEON = false, WORLDRAID = false, WORLDBG = false, WORLDUNCHECK = false,
|
|
SPAM = false, SPAM_UNCOMMON = false, SPAM_RARE = false, SPAM_LOOT = false,
|
|
REZ = false, GOSSIP = true, QUESTALT = true, MERCHANTALT = true, SALVA = false, REMOVEMANABUFFS = false,
|
|
}
|
|
|
|
local LOOT_TABLES = {
|
|
ZG = {19698,19699,19700,19701,19702,19703,19704,19705,19706,19707,19708,19709,19710,19711,19712,19713,19714,19715},
|
|
MC = {11382,17010,17011},
|
|
AQ = {20858,20859,20860,20861,20862,20863,20864,20865,20866,20867,20868,20869,20870,20871,20872,20873,20874,
|
|
20875,20876,20877,20878,20879,20881,20882},
|
|
SAND = {50203},
|
|
ES_SHARDS = {20381,61197,61198},
|
|
NAXX = {22373,22374,22375,22376},
|
|
}
|
|
local LOOT_KEY = {}
|
|
for key, ids in pairs(LOOT_TABLES) do for _, id in ipairs(ids) do LOOT_KEY[id] = key end end
|
|
|
|
local ROLL_NAME = {[0] = "Pass", [1] = "Need", [2] = "Greed"}
|
|
local function out(msg) DEFAULT_CHAT_FRAME:AddMessage("|cffffcc00LazyPig:|r " .. msg) end
|
|
local function cfg(key) return LPCONFIG and LPCONFIG[key] end
|
|
local function roll(key) local r = cfg(key); return type(r) == "number" and r >= 0 and r or nil end
|
|
|
|
local function instanceType() local inside, kind = IsInInstance(); return inside and kind or nil end
|
|
local function inBG() return instanceType() == "pvp" end
|
|
local function bgQueued()
|
|
for i = 1, (GetMaxBattlefieldID and GetMaxBattlefieldID() or MAX_BATTLEFIELD_QUEUES or 3) do
|
|
local status = GetBattlefieldStatus(i)
|
|
if status == "confirm" or status == "active" or status == "queued" then return true end
|
|
end
|
|
return false
|
|
end
|
|
|
|
-- Loot rolls ---------------------------------------------------------------------------------------------------
|
|
local autoRolled = {}
|
|
local lastGreenRoll = 0
|
|
local function doRoll(id, choice, link, quality)
|
|
autoRolled[id] = choice
|
|
RollOnLoot(id, choice)
|
|
if cfg("ROLLMSG") then
|
|
local hex = select(4, C_Item.GetItemQualityColor(quality or 1)) or "ffffffff"
|
|
out("Auto |c" .. hex .. ROLL_NAME[choice] .. "|r " .. (link or ""))
|
|
end
|
|
end
|
|
local function autoRoll(id)
|
|
local _, _, _, quality = GetLootRollItemInfo(id)
|
|
local link = GetLootRollItemLink(id)
|
|
local itemID = link and tonumber(link:match("item:(%d+)"))
|
|
if not itemID then return end
|
|
if itemID == 22484 then return doRoll(id, 1, link, quality) end -- Necrotic Rune: always need (Octo)
|
|
if inBG() then return doRoll(id, 1, link, quality) end -- Alterac Valley: need everything (Octo)
|
|
local key = LOOT_KEY[itemID]
|
|
local choice = key and roll(key)
|
|
if choice then doRoll(id, choice, link, quality) end
|
|
end
|
|
-- Ctrl+Alt rolls the green items that are open (1.12 behaviour).
|
|
local function greenRoll()
|
|
local choice = roll("GREEN")
|
|
if not choice then return end
|
|
local ids = {}
|
|
if GetActiveLootRollIDs then ids = GetActiveLootRollIDs() else
|
|
for i = 1, NUM_GROUP_LOOT_FRAMES or 4 do
|
|
local f = _G["GroupLootFrame" .. i]
|
|
if f and f:IsShown() and f.rollID then ids[#ids + 1] = f.rollID end
|
|
end
|
|
end
|
|
for _, id in ipairs(ids) do
|
|
local _, _, _, quality = GetLootRollItemInfo(id)
|
|
if quality == 2 and not autoRolled[id] then lastGreenRoll = GetTime() + 1; doRoll(id, choice, GetLootRollItemLink(id), quality) end
|
|
end
|
|
end
|
|
|
|
-- Gossip / quests / merchant -----------------------------------------------------------------------------------
|
|
local ICON_TYPE = {}
|
|
for kind, path in pairs({gossip = "GossipGossipIcon", vendor = "VendorGossipIcon", taxi = "TaxiGossipIcon",
|
|
trainer = "TrainerGossipIcon", binder = "BinderGossipIcon", banker = "BankerGossipIcon",
|
|
petition = "PetitionGossipIcon", tabard = "TabardGossipIcon", battlemaster = "BattleMasterGossipIcon"}) do
|
|
local id = GetFileIDFromPath and GetFileIDFromPath("Interface\\GossipFrame\\" .. path .. ".blp")
|
|
if id then ICON_TYPE[id] = kind end
|
|
end
|
|
local function optionType(o)
|
|
local kind = ICON_TYPE[o.icon or 0]
|
|
if kind then return kind end
|
|
local icon = type(o.icon) == "string" and o.icon:lower() or ""
|
|
for k, path in pairs({vendor = "vendor", taxi = "taxi", trainer = "trainer", binder = "binder", banker = "banker",
|
|
petition = "petition", tabard = "tabard", battlemaster = "battlemaster"}) do
|
|
if icon:find(path, 1, true) then return k end
|
|
end
|
|
return "gossip"
|
|
end
|
|
|
|
local function replyGossipQuests()
|
|
local available, active = C_GossipInfo.GetAvailableQuests(), C_GossipInfo.GetActiveQuests()
|
|
for _, q in ipairs(active) do if q.isComplete then return C_GossipInfo.SelectActiveQuest(q.questID) end end
|
|
if available[1] then return C_GossipInfo.SelectAvailableQuest(available[1].questID) end
|
|
end
|
|
local function onGossip()
|
|
if cfg("QUESTALT") and IsAltKeyDown() then return replyGossipQuests() end
|
|
if not cfg("GOSSIP") or IsShiftKeyDown() then return end
|
|
if #C_GossipInfo.GetAvailableQuests() > 0 or #C_GossipInfo.GetActiveQuests() > 0 then return end
|
|
local pick
|
|
for _, o in ipairs(C_GossipInfo.GetOptions()) do
|
|
local kind = optionType(o)
|
|
if kind == "binder" then
|
|
local bind = GetBindLocation()
|
|
if not (bind == GetSubZoneText() or bind == GetZoneText() or bind == GetRealZoneText() or bind == GetMinimapZoneText()) then return end
|
|
elseif pick then
|
|
return -- several choices: the player decides
|
|
elseif kind == "trainer" or kind == "vendor" or kind == "battlemaster" or kind == "gossip" or kind == "taxi"
|
|
or (kind == "banker" and (o.name or ""):find("^I would like to check my deposit box"))
|
|
or (kind == "petition" and (IsAltKeyDown() or (o.name or ""):find("Teleport me to the Molten Core"))) then
|
|
pick = o
|
|
end
|
|
end
|
|
if pick and not (optionType(pick) == "trainer" and pick.name == "Reset my talents.") then
|
|
C_GossipInfo.SelectOption(pick.gossipOptionID)
|
|
end
|
|
end
|
|
local function onQuestGreeting()
|
|
if not (cfg("QUESTALT") and IsAltKeyDown()) then return end
|
|
for i = 1, GetNumActiveQuests() do
|
|
if select(2, GetActiveTitle(i)) then return SelectActiveQuest(i) end
|
|
end
|
|
if GetNumAvailableQuests() > 0 then return SelectAvailableQuest(1) end
|
|
end
|
|
local function onQuestEvent(event)
|
|
if not (cfg("QUESTALT") and IsAltKeyDown()) then return end
|
|
if event == "QUEST_DETAIL" then AcceptQuest()
|
|
elseif event == "QUEST_PROGRESS" then if IsQuestCompletable() then CompleteQuest() end
|
|
elseif event == "QUEST_COMPLETE" then
|
|
local choices = GetNumQuestChoices()
|
|
if choices <= 1 then GetQuestReward(choices) end
|
|
end
|
|
end
|
|
|
|
local merchantOpen = false
|
|
local function sellGreysAndRepair()
|
|
if not (merchantOpen and cfg("MERCHANTALT") and IsAltKeyDown()) then return end
|
|
local sold = 0
|
|
for bag = 0, 4 do
|
|
for slot = 1, C_Container.GetContainerNumSlots(bag) do
|
|
local info = C_Container.GetContainerItemInfo(bag, slot)
|
|
if info and info.quality == 0 and not info.hasNoValue and not info.isLocked then
|
|
C_Container.UseContainerItem(bag, slot); sold = sold + 1
|
|
end
|
|
end
|
|
end
|
|
if CanMerchantRepair() then
|
|
local cost, need = GetRepairAllCost()
|
|
if need and cost > 0 and cost <= GetMoney() then RepairAllItems(); out("repaired for " .. GetCoinTextureString(cost)) end
|
|
end
|
|
if sold > 0 then out("sold " .. sold .. " grey item(s)") end
|
|
end
|
|
|
|
-- Group, duel, summon, resurrect, battleground -----------------------------------------------------------------
|
|
local function isGuildMate(name, guid)
|
|
if guid and IsGuildMember then return IsGuildMember(guid) end
|
|
if not IsInGuild() then return false end
|
|
for i = 1, GetNumGuildMembers() do
|
|
local member = GetGuildRosterInfo(i)
|
|
if member and (member == name or Ambiguate(member, "short") == name) then return true end
|
|
end
|
|
return false
|
|
end
|
|
local function isFriend(name, guid)
|
|
if guid and C_FriendList.IsFriend then return C_FriendList.IsFriend(guid) end
|
|
return C_FriendList.GetFriendInfo(name) ~= nil
|
|
end
|
|
local function onInvite(name, ...)
|
|
local guid = select(6, ...)
|
|
if cfg("DINV") and (inBG() or bgQueued()) then return end
|
|
local guild, friend = isGuildMate(name, guid), isFriend(name, guid)
|
|
if (cfg("GINV") and guild) or (cfg("FINV") and friend) or (cfg("SINV") and not guild and not friend) then
|
|
AcceptGroup()
|
|
StaticPopup_Hide("PARTY_INVITE")
|
|
end
|
|
end
|
|
|
|
local summonTicker
|
|
local function summonCheck()
|
|
if not cfg("SUMM") then return end
|
|
local left = C_SummonInfo.GetSummonConfirmTimeLeft()
|
|
if left <= 0 then if summonTicker then summonTicker:Cancel(); summonTicker = nil end return end
|
|
if left <= 3 or (IsAltKeyDown() and IsControlKeyDown()) then
|
|
C_SummonInfo.ConfirmSummon()
|
|
StaticPopup_Hide("CONFIRM_SUMMON")
|
|
if summonTicker then summonTicker:Cancel(); summonTicker = nil end
|
|
end
|
|
end
|
|
local function onSummon()
|
|
if not cfg("SUMM") or summonTicker then return end
|
|
out("Auto Summon in " .. math.floor(C_SummonInfo.GetSummonConfirmTimeLeft()) .. "s")
|
|
summonTicker = C_Timer.NewTicker(0.25, summonCheck)
|
|
end
|
|
|
|
local function onResurrect(who)
|
|
if not cfg("REZ") then return end
|
|
local kind = instanceType()
|
|
if not (kind == "party" or kind == "raid" or kind == "pvp") then return end
|
|
if who and UnitAffectingCombat(who) then return end
|
|
if GetCorpseRecoveryDelay() > 0 then return end
|
|
AcceptResurrect()
|
|
StaticPopup_Hide("RESURRECT"); StaticPopup_Hide("RESURRECT_NO_SICKNESS"); StaticPopup_Hide("RESURRECT_NO_TIMER")
|
|
end
|
|
|
|
local function onDead()
|
|
if not (cfg("RBG") and inBG()) then return end
|
|
local options = C_DeathInfo and C_DeathInfo.GetSelfResurrectOptions and C_DeathInfo.GetSelfResurrectOptions()
|
|
if options and #options > 0 then return end -- soulstone/ankh: the player chooses
|
|
RepopMe()
|
|
end
|
|
|
|
local leftBG = 0
|
|
local function onBattlefieldStatus()
|
|
if not (cfg("LBG") and inBG()) or GetTime() < leftBG then return end
|
|
local winner = GetBattlefieldWinner()
|
|
if winner then
|
|
leftBG = GetTime() + 5
|
|
UIErrorsFrame:AddMessage((winner == 0 and "Horde" or "Alliance") .. " Wins")
|
|
LeaveBattlefield()
|
|
end
|
|
end
|
|
|
|
-- World chat mute, camera, loot position, auto dismount -------------------------------------------------------
|
|
local worldMuted = false
|
|
local function zoneCheck()
|
|
local kind = instanceType()
|
|
local mute = cfg("WORLDUNCHECK") or (cfg("WORLDRAID") and kind == "raid") or (cfg("WORLDDUNGEON") and kind == "party")
|
|
or (cfg("WORLDBG") and kind == "pvp")
|
|
local id, name = GetChannelName("world")
|
|
if not id or id == 0 or not name then return end
|
|
if mute and not worldMuted then
|
|
ChatFrame_RemoveChannel(ChatFrame1, name); worldMuted = true
|
|
UIErrorsFrame:AddMessage("Leaving World")
|
|
elseif not mute and worldMuted then
|
|
ChatFrame_AddChannel(ChatFrame1, name); worldMuted = false
|
|
UIErrorsFrame:AddMessage("Joining World")
|
|
end
|
|
end
|
|
|
|
local function setCVarIfKnown(name, value)
|
|
if C_CVar.GetCVarInfo(name) ~= nil then C_CVar.SetCVar(name, value) end
|
|
end
|
|
local function applyCVars()
|
|
if cfg("CAM") then
|
|
setCVarIfKnown("cameraDistanceMaxZoomFactor", "2.6")
|
|
else
|
|
local default = C_CVar.GetCVarDefault("cameraDistanceMaxZoomFactor")
|
|
if default then setCVarIfKnown("cameraDistanceMaxZoomFactor", default) end
|
|
end
|
|
setCVarIfKnown("lootUnderMouse", cfg("LOOT") and "1" or "0")
|
|
setCVarIfKnown("autoDismount", cfg("DISMOUNT") and "1" or "0")
|
|
setCVarIfKnown("autoDismountFlying", cfg("DISMOUNT") and "1" or "0")
|
|
end
|
|
|
|
-- Blessing of Salvation / mana buffs removal (out of combat only; CancelUnitBuff is combat-restricted).
|
|
local SALVATION = {[1038] = true, [25895] = true}
|
|
local MANA_BUFFS = {[19742]=1,[19850]=1,[19852]=1,[19853]=1,[19854]=1,[25290]=1,[25894]=1,[25918]=1,
|
|
[1459]=1,[1460]=1,[1461]=1,[10156]=1,[10157]=1,[23028]=1,[14752]=1,[14818]=1,[14819]=1,[27681]=1}
|
|
local function removeBuffs()
|
|
if InCombatLockdown() or not (cfg("SALVA") or cfg("REMOVEMANABUFFS")) then return end
|
|
for i = 1, 40 do
|
|
local aura = C_UnitAuras.GetBuffDataByIndex("player", i)
|
|
if not aura then break end
|
|
local id = aura.spellId
|
|
if (cfg("SALVA") and SALVATION[id]) or (cfg("REMOVEMANABUFFS") and MANA_BUFFS[id]) then
|
|
CancelUnitBuff("player", i, "HELPFUL")
|
|
return
|
|
end
|
|
end
|
|
end
|
|
|
|
-- Special key combinations (1.12 SPECIALKEY): Ctrl+Shift follow, Alt+Shift inspect, Ctrl+Alt trade/rolls.
|
|
local lastCombo = 0
|
|
local function onModifier()
|
|
if merchantOpen then sellGreysAndRepair() end
|
|
local ctrl, alt, shift = IsControlKeyDown(), IsAltKeyDown(), IsShiftKeyDown()
|
|
if ctrl and alt and not shift then greenRoll() end
|
|
if not cfg("SPECIALKEY") or GetTime() < lastCombo then return end
|
|
local friendlyPlayer = UnitExists("target") and UnitIsPlayer("target") and UnitIsFriend("target", "player")
|
|
and not UnitIsUnit("target", "player")
|
|
if ctrl and shift and not alt and friendlyPlayer then
|
|
lastCombo = GetTime() + 1.5; FollowUnit("target")
|
|
elseif alt and shift and not ctrl and UnitIsPlayer("target") then
|
|
lastCombo = GetTime() + 1.5; InspectUnit("target")
|
|
elseif ctrl and alt and not shift and friendlyPlayer and CheckInteractDistance("target", 2) then
|
|
lastCombo = GetTime() + 2; InitiateTrade("target")
|
|
end
|
|
end
|
|
|
|
-- Chat filters -------------------------------------------------------------------------------------------------
|
|
local seen, seenLine = {}, {}
|
|
local function spamFilter(_, event, msg, author, ...)
|
|
local lineID = select(9, ...)
|
|
if msg and msg:find("^#showtooltip") then return true end
|
|
if msg and msg:find("=== .+ RESTED XP") and author ~= UnitName("player") then return true end
|
|
if not cfg("SPAM") or not author then return false end
|
|
local short = Ambiguate(author, "short")
|
|
if short == UnitName("player") then return false end
|
|
if event == "CHAT_MSG_SAY" and msg and msg:find("^Casted %u[%a%s]+ on %u[%a%s]+") then return true end
|
|
if event == "CHAT_MSG_EMOTE" and (isGuildMate(short) or isFriend(short)) then return false end
|
|
if lineID and seenLine[lineID] ~= nil then return seenLine[lineID] end -- same line in another chat frame
|
|
local now, key = GetTime(), short .. "\0" .. (msg or "")
|
|
local hide = seen[key] and seen[key] + 70 > now or false
|
|
if not hide then seen[key] = now end
|
|
if lineID then seenLine[lineID] = hide end
|
|
return hide
|
|
end
|
|
local function lootFilter(_, event, msg)
|
|
if not msg then return false end
|
|
local mine = msg:find("You") ~= nil
|
|
local wonOrReceived = msg:find("won") or msg:find("receive")
|
|
local zgaq = (roll("AQ") and (msg:find("Idol") or msg:find("Scarab"))) or (roll("ZG") and (msg:find("Bijou") or msg:find("Coin")))
|
|
local keep = (mine and not zgaq and GetTime() > lastGreenRoll) or wonOrReceived
|
|
local uncommon = cfg("SPAM_UNCOMMON") and msg:find("1eff00")
|
|
local rare = cfg("SPAM_RARE") and msg:find("0070dd")
|
|
local junk = cfg("SPAM_LOOT") and (msg:find("9d9d9d") or msg:find("ffffff"))
|
|
local money = cfg("SPAM_LOOT") and msg:find("Your share of the loot")
|
|
return (not keep and (uncommon or rare)) or (junk and not mine) or money or false
|
|
end
|
|
|
|
local lpCategory
|
|
-- Settings panel -----------------------------------------------------------------------------------------------
|
|
local function buildSettings()
|
|
if not (Settings and Settings.RegisterVerticalLayoutCategory) then return end
|
|
local category, layout = Settings.RegisterVerticalLayoutCategory("Lazy Pig")
|
|
local function header(text) layout:AddInitializer(CreateSettingsListSectionHeaderInitializer(text)) end
|
|
local function check(key, label, tip, onChange)
|
|
local s = Settings.RegisterAddOnSetting(category, "OctoLazyPig_" .. key, key, LPCONFIG, Settings.VarType.Boolean, label, DEFAULTS[key])
|
|
if onChange then s:SetValueChangedCallback(onChange) end
|
|
Settings.CreateCheckbox(category, s, tip)
|
|
end
|
|
local function rollOptions()
|
|
local c = Settings.CreateControlTextContainer()
|
|
c:Add(-1, OFF or "Off"); c:Add(1, NEED or "Need"); c:Add(2, GREED or "Greed"); c:Add(0, PASS or "Pass")
|
|
return c:GetData()
|
|
end
|
|
local function rollDrop(key, label, tip)
|
|
local s = Settings.RegisterAddOnSetting(category, "OctoLazyPig_" .. key, key, LPCONFIG, Settings.VarType.Number, label, DEFAULTS[key])
|
|
Settings.CreateDropdown(category, s, rollOptions, tip)
|
|
end
|
|
|
|
header("Auto roll")
|
|
rollDrop("GREEN", "Green items (Ctrl+Alt)", "Hold Ctrl+Alt while green loot rolls are open.")
|
|
rollDrop("ZG", "Zul'Gurub coins and bijous")
|
|
rollDrop("MC", "Molten Core materials", "Blood of the Mountain, Fiery Core, Lava Core.")
|
|
rollDrop("AQ", "Ahn'Qiraj scarabs and idols")
|
|
rollDrop("SAND", "Corrupted Sand")
|
|
rollDrop("ES_SHARDS", "Emerald Sanctum shards")
|
|
rollDrop("NAXX", "Naxxramas wartorn scraps")
|
|
check("ROLLMSG", "Auto roll messages", "Print a chat line for every automatic roll.")
|
|
|
|
header("Accept group invites")
|
|
check("GINV", "From guild members")
|
|
check("FINV", "From friends")
|
|
check("SINV", "From strangers")
|
|
check("DINV", "Never in BG or BG queue")
|
|
|
|
header("Battlegrounds")
|
|
check("LBG", "Leave BG when it ends")
|
|
check("RBG", "Release spirit in BG")
|
|
check("SBG", "Decline BG quest shares")
|
|
|
|
header("Hide World chat")
|
|
check("WORLDDUNGEON", "In dungeons", nil, zoneCheck)
|
|
check("WORLDRAID", "In raids", nil, zoneCheck)
|
|
check("WORLDBG", "In battlegrounds", nil, zoneCheck)
|
|
check("WORLDUNCHECK", "Always", nil, zoneCheck)
|
|
|
|
header("Chat filters")
|
|
check("SPAM", "Repeated player messages", "The same message from the same player within 70 seconds.")
|
|
check("SPAM_UNCOMMON", "Green item roll messages")
|
|
check("SPAM_RARE", "Blue item roll messages")
|
|
check("SPAM_LOOT", "Grey loot and money share")
|
|
|
|
header("Automation")
|
|
check("GOSSIP", "Auto-process gossip", "Picks the only service option (vendor, trainer, taxi, ...). Hold Shift to see the menu.")
|
|
check("QUESTALT", "Alt: quick quests", "Hold Alt when talking to a quest giver.")
|
|
check("MERCHANTALT", "Alt: sell greys and repair", "Hold Alt while a merchant window is open.")
|
|
check("SUMM", "Accept summons", "Accepts 3 seconds before the summon expires (Ctrl+Alt: now).")
|
|
check("REZ", "Accept instance resurrects", "Only when the resurrecter is out of combat.")
|
|
check("DUEL", "Decline duels", "Hold Shift to see the request.")
|
|
check("SPECIALKEY", "Key combinations", "Ctrl+Shift follow, Alt+Shift inspect, Ctrl+Alt trade with the target.")
|
|
check("SALVA", "Remove Salvation", "Removes Blessing of Salvation out of combat.", removeBuffs)
|
|
check("REMOVEMANABUFFS", "Remove mana buffs", "Removes Blessing of Wisdom, Arcane Intellect and Divine Spirit out of combat.", removeBuffs)
|
|
|
|
header("Interface")
|
|
check("DISMOUNT", "Dismount automatically", nil, applyCVars)
|
|
check("CAM", "Extended camera distance", nil, applyCVars)
|
|
check("LOOT", "Loot window at cursor", nil, applyCVars)
|
|
|
|
Settings.RegisterAddOnCategory(category)
|
|
lpCategory = category
|
|
end
|
|
|
|
-- Events -------------------------------------------------------------------------------------------------------
|
|
local frame = CreateFrame("Frame")
|
|
local handlers = {
|
|
START_LOOT_ROLL = function(id) autoRoll(id) end,
|
|
CONFIRM_LOOT_ROLL = function(id, rollType)
|
|
if autoRolled[id] == rollType then ConfirmLootRoll(id, rollType); StaticPopup_Hide("CONFIRM_LOOT_ROLL") end
|
|
end,
|
|
CANCEL_LOOT_ROLL = function(id) autoRolled[id] = nil end,
|
|
GOSSIP_SHOW = onGossip,
|
|
QUEST_GREETING = onQuestGreeting,
|
|
QUEST_DETAIL = function()
|
|
if cfg("SBG") and inBG() and (UnitIsPlayer("npc") or not UnitExists("npc")) then DeclineQuest(); return end
|
|
onQuestEvent("QUEST_DETAIL")
|
|
end,
|
|
QUEST_PROGRESS = function() onQuestEvent("QUEST_PROGRESS") end,
|
|
QUEST_COMPLETE = function() onQuestEvent("QUEST_COMPLETE") end,
|
|
MERCHANT_SHOW = function() merchantOpen = true; sellGreysAndRepair() end,
|
|
MERCHANT_CLOSED = function() merchantOpen = false end,
|
|
MODIFIER_STATE_CHANGED = onModifier,
|
|
PARTY_INVITE_REQUEST = onInvite,
|
|
CONFIRM_SUMMON = onSummon,
|
|
RESURRECT_REQUEST = onResurrect,
|
|
PLAYER_DEAD = onDead,
|
|
UPDATE_BATTLEFIELD_STATUS = onBattlefieldStatus,
|
|
DUEL_REQUESTED = function()
|
|
if cfg("DUEL") and not IsShiftKeyDown() then CancelDuel(); StaticPopup_Hide("DUEL_REQUESTED") end
|
|
end,
|
|
ZONE_CHANGED_NEW_AREA = zoneCheck,
|
|
PLAYER_ENTERING_WORLD = function() zoneCheck(); applyCVars() end,
|
|
UNIT_AURA = function(unit) if unit == "player" then removeBuffs() end end,
|
|
PLAYER_REGEN_ENABLED = removeBuffs,
|
|
}
|
|
frame:SetScript("OnEvent", function(_, event, ...)
|
|
if event == "ADDON_LOADED" then
|
|
if ... ~= ADDON then return end
|
|
LPCONFIG = type(LPCONFIG) == "table" and LPCONFIG or {}
|
|
for k, v in pairs(DEFAULTS) do
|
|
if LPCONFIG[k] == nil or type(LPCONFIG[k]) ~= type(v) then LPCONFIG[k] = v end
|
|
end
|
|
buildSettings()
|
|
for name in pairs(handlers) do frame:RegisterEvent(name) end
|
|
for _, e in ipairs({"CHAT_MSG_SAY", "CHAT_MSG_YELL", "CHAT_MSG_CHANNEL", "CHAT_MSG_EMOTE"}) do
|
|
ChatFrame_AddMessageEventFilter(e, spamFilter)
|
|
end
|
|
ChatFrame_AddMessageEventFilter("CHAT_MSG_LOOT", lootFilter)
|
|
ChatFrame_AddMessageEventFilter("CHAT_MSG_MONEY", lootFilter)
|
|
frame:UnregisterEvent("ADDON_LOADED")
|
|
return
|
|
end
|
|
local h = handlers[event]
|
|
if h then h(...) end
|
|
end)
|
|
frame:RegisterEvent("ADDON_LOADED")
|
|
|
|
SLASH_OCTOLAZYPIG1 = "/lp"
|
|
SLASH_OCTOLAZYPIG2 = "/lazypig"
|
|
SlashCmdList.OCTOLAZYPIG = function()
|
|
if lpCategory then Settings.OpenToCategory(lpCategory:GetID()) end
|
|
end
|