-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAutoAccept.lua
105 lines (98 loc) · 4.37 KB
/
AutoAccept.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
local _, CGM = ...
-- Called on QUEST_ACCEPT_CONFIRM. Fires when an escort quest is started nearby.
function CGM:OnQuestAcceptConfirm(_, questTitle)
-- if C_QuestLog.GetQuestInfo(CGM.currentStep.questID) == questTitle then
-- Auto accept always for safety. If you don't want the quest after, just abandon it.
ConfirmAcceptQuest()
-- end
end
-- Called on QUEST_DETAIL. Fires when you're able to accept or decline a quest from an NPC.
function CGM:OnQuestDetail(...)
if CGM:ShouldAuto() and CGM.currentStep.type == CGM.Types.Accept and CGM.currentStep.questID == GetQuestID() then
AcceptQuest()
end
if CGMOptions.settings.debug then
CGM.debugQuestFrameIDLbl:SetText("Quest ID: " .. GetQuestID())
CGM.debugQuestFrameIDLbl:Show()
end
end
-- Called on QUEST_PROGRESS. Fires when the player is able to click the "Continue" button (right after choosing a quest in the menu and right before being able
-- to pick a quest reward).
function CGM:OnQuestProgress()
if CGM:ShouldAuto() and CGM.currentStepIndex then
local currentStep = CGM.currentStep
if currentStep.type == CGM.Types.Deliver then
if currentStep.questID == GetQuestID() then
CompleteQuest()
end
end
end
end
-- Called on QUEST_COMPLETE. Fires when the player is able to finally complete a quest (and choose a reward if there is any).
function CGM:OnQuestComplete()
if CGM:ShouldAuto() and CGM.currentStep.type == CGM.Types.Deliver then
local nbrOfChoices = GetNumQuestChoices()
-- Not sure if this is possible but just in case.
if nbrOfChoices == 1 then
GetQuestReward(1)
elseif nbrOfChoices > 1 then
if CGM.currentStep.rewardID then
for i = 1, nbrOfChoices do
local itemLink = GetQuestItemLink("choice", i)
local itemID = CGM:ParseIDFromLink(itemLink)
if itemID == CGM.currentStep.rewardID then
CGM:Message("picking quest reward: " .. itemLink .. ".")
GetQuestReward(i)
return
end
end
CGM:Message("no quest reward found with the specified item ID: " .. CGM.currentStep.rewardID .. ".")
end
else
GetQuestReward()
end
end
end
-- Called on GOSSIP_SHOW. Fires when the gossip frame shows. (Different from an NPC that only gives quests since gossip can be shown regardless of if there are
-- quests or not.)
function CGM:AutoAcceptOnGossipShow()
if CGM:ShouldAuto() and UnitExists("npc") then
if CGM.currentStep.type == CGM.Types.Accept then
local availableQuests = C_GossipInfo.GetAvailableQuests()
for i = 1, #availableQuests do
local questID = availableQuests[i].questID
if CGM.currentStep.questID == questID then
C_GossipInfo.SelectAvailableQuest(questID)
end
end
elseif CGM.currentStep.type == CGM.Types.Deliver then
local completableQuests = C_GossipInfo.GetActiveQuests()
for i = 1, #completableQuests do
local questID = completableQuests[i].questID
if CGM.currentStep.questID == questID and IsQuestComplete(questID) then
C_GossipInfo.SelectActiveQuest(questID)
end
end
end
end
end
-- Called on QUEST_GREETING.
function CGM:OnQuestGreeting(...)
if CGM:ShouldAuto() and UnitExists("npc") then
if CGM.currentStep.type == CGM.Types.Accept then
local availableQuests = GetNumAvailableQuests()
for i = 1, availableQuests do
if GetAvailableTitle(i) == C_QuestLog.GetQuestInfo(CGM.currentStep.questID) then
SelectAvailableQuest(i)
end
end
elseif CGM.currentStep.type == CGM.Types.Deliver then
local completableQuests = GetNumActiveQuests()
for i = 1, completableQuests do
if GetActiveTitle(i) == C_QuestLog.GetQuestInfo(CGM.currentStep.questID) and IsQuestComplete(CGM.currentStep.questID) then
SelectActiveQuest(i)
end
end
end
end
end