From f779f20a52ea964f50962f307d942036e9fdb56f Mon Sep 17 00:00:00 2001 From: atomaka Date: Sun, 21 Feb 2021 00:56:02 +0000 Subject: [PATCH] Automatically activate NW goliath (#11) (fixes #10) --- MyAddon.lua | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/MyAddon.lua b/MyAddon.lua index db62af9..d8bf2ed 100755 --- a/MyAddon.lua +++ b/MyAddon.lua @@ -9,6 +9,18 @@ StaticPopupDialogs["REPAIR_ALERT"] = { preferredIndex = 3 } +StaticPopupDialogs["GOLIATH_MISSING"] = { + text = "Option to repair goliath not found; move closer", + button1 = "Ok", + OnAccept = function() + C_GossipInfo.CloseGossip() + end, + timeout = 5, + whileDead = false, + hideOnEscape = true, + preferredIndex = 3 +} + MyAddon.keyItemID = 180653 MyAddon.taunts = { [56222] = true, -- Dark Command @@ -27,6 +39,13 @@ function MyAddon.OnEvent(self, event, ...) events[event](self, ...) end +function events:GOSSIP_SHOW() + local isNecroticWake = GetZoneText() == 'The Necrotic Wake' + local isSteward = GetUnitName('npc') == 'Steward' + + if isNecroticWake and isSteward then MyAddon.activateGoliath() end +end + function events:CHAT_MSG_PARTY_LEADER(message, ...) if message == '!keys' then MyAddon.announceKey() @@ -102,6 +121,21 @@ function MyAddon.announceTaunts(...) print(message) end +function MyAddon.activateGoliath() + options = C_GossipInfo.GetOptions() + + found = false + for k, v in pairs(options) do + if v['name'] == 'Can you reactivate this goliath?' then + found = true + C_GossipInfo.SelectOption(k) + break + end + end + + if not found then StaticPopup_Show("GOLIATH_MISSING") end +end + function MyAddon.needsRepair() local slots = { "HeadSlot", "ShoulderSlot", "ChestSlot", "WristSlot", "HandsSlot",