-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathQuestAutoAccept.lua
More file actions
199 lines (184 loc) · 5.78 KB
/
Copy pathQuestAutoAccept.lua
File metadata and controls
199 lines (184 loc) · 5.78 KB
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
local me = ZygorGuidesViewer
local ZGV = me
if not ZGV then return end
local _G=_G
function ZGV_DeclineQuest()
ZGV.tmp_no_autoquest=time()
end
-- fixes for Blizzard autoaccepting madness.
--[[
function QuestFrameDetailPanel_OnShow_after()
if ZGV.db.profile.fixblizzardautoaccept and QuestFrame:IsVisible() and QuestFrame.autoQuest then
local forceful = false
if forceful then
print("un-autoquest, hamfisted approach")
-- hamfisted approach
local q = ZGV:FindData(ZGV.quests,"title",GetTitleText())
if q then
-- found the accepted quest - ABANDON it now
--
--local sound=GetCVar("Sound_EnableSFX")
--SetCVar("Sound_EnableSFX","0")
--SelectQuestLogEntry(q.index)
--SetAbandonQuest()
--print("abandoned "..q.index.." "..q.title)
--AbandonQuest()
--SetCVar("Sound_EnableSFX",sound)
QuestFrameDetailPanelBotRight:SetTexture("Interface\\QuestFrame\\UI-QuestGreeting-BotRight");
QuestFrameDeclineButton:Show();
QuestFrameAcceptButton:SetText(_G['ACCEPT'])
QuestFrame.autoQuest = nil;
end
else
-- purely cosmetic approach
local q = ZGV:FindData(ZGV.quests,"title",GetTitleText())
if q then
QuestFrameAcceptButton:SetText(_G['CALENDAR_STATUS_ACCEPTED'])
else
QuestFrameAcceptButton:SetText(_G['ACCEPT'])
end
end
end
end
--]]
function QuestFrameDetailPanel_fixAutoQuest()
if ZGV.db.profile.fixblizzardautoaccept and QuestFrame:IsVisible() and QuestFrame.autoQuest then
-- purely cosmetic approach
local q = ZGV:FindData(ZGV.quests,"title",GetTitleText())
if q then
QuestFrameAcceptButton:SetText(_G['CALENDAR_STATUS_ACCEPTED'])
else
QuestFrameAcceptButton:SetText(_G['ACCEPT'])
end
else
QuestFrameAcceptButton:SetText(_G['ACCEPT'])
end
end
tinsert(ZGV.startups,function(self)
-- quest auto turnin/accept
self:AddEvent("GOSSIP_SHOW")
self:AddEvent("QUEST_GREETING")
self:AddEvent("QUEST_DETAIL")
self:AddEvent("QUEST_PROGRESS")
self:AddEvent("QUEST_COMPLETE")
self:AddEvent("QUEST_LOG_UPDATE",QuestFrameDetailPanel_fixAutoQuest)
--hooksecurefunc("QuestRewardCancelButton_OnClick",ZGV_QuestRewardCancelButton_OnClick)
hooksecurefunc("DeclineQuest",ZGV_DeclineQuest)
--hooksecurefunc("QuestFrameDetailPanel_OnShow",QuestFrameDetailPanel_OnShow_after)
QuestFrameDetailPanel:HookScript("OnShow",QuestFrameDetailPanel_fixAutoQuest)
end)
function me:QUEST_GREETING()
if not self.CurrentStep then return end
if self.tmp_no_autoquest and time()-self.tmp_no_autoquest<10 then
self.tmp_no_autoquest=nil
return
end
if self.db.profile.autoturnin then
for qnum=1,GetNumActiveQuests() do
for i,goal in ipairs(self.CurrentStep.goals) do
if goal.action=="turnin" and goal.quest==GetActiveTitle(qnum) and goal:GetStatus()=="incomplete" then
self:Print("Activating quest")
SelectActiveQuest(qnum)
return
end
end
end
end
if self.db.profile.autoaccept then
for qnum=1,GetNumAvailableQuests() do
for i,goal in ipairs(self.CurrentStep.goals) do
if goal.action=="accept" and goal.quest==GetAvailableTitle(qnum) and goal:GetStatus()=="incomplete" then
self:Print("Opening quest")
SelectAvailableQuest(qnum)
return
end
end
end
end
end
function me:GOSSIP_SHOW()
if not self.CurrentStep then return end
if self.tmp_no_autoquest and time()-self.tmp_no_autoquest<10 then
self.tmp_no_autoquest=nil
return
end
if self.db.profile.autoturnin then
local quests={GetGossipActiveQuests()}
for qnum=1,GetNumGossipActiveQuests() do
for i,goal in ipairs(self.CurrentStep.goals) do
if goal.action=="turnin" and goal.quest==quests[qnum*3-2] and goal:GetStatus()=="incomplete" then
self:Print("Activating quest")
SelectGossipActiveQuest(qnum)
return
end
end
end
end
if self.db.profile.autoaccept then
local quests={GetGossipAvailableQuests()}
for qnum=1,GetNumGossipAvailableQuests() do
for i,goal in ipairs(self.CurrentStep.goals) do
if goal.action=="accept" and goal.quest==quests[qnum*3-2] and goal:GetStatus()=="incomplete" then
self:Print("Opening quest")
SelectGossipAvailableQuest(qnum)
return
end
end
end
end
end
function me:QUEST_DETAIL()
if not self.CurrentStep then return end
if self.tmp_no_autoquest and time()-self.tmp_no_autoquest<10 then
self.tmp_no_autoquest=nil
return
end
if self.db.profile.autoaccept then
local title = GetTitleText()
for i,goal in ipairs(self.CurrentStep.goals) do
if goal.action=="accept" and goal.quest==title and goal:IsCompleteable() and not goal:IsObsolete() then
self:Print("Accepting quest")
QuestDetailAcceptButton_OnClick()
-- ASSUMING it runs after the builtin QuestFrame code.
-- But it seems to, if the title matches...
return
end
end
end
end
function me:QUEST_PROGRESS()
if not self.CurrentStep then return end
if self.tmp_no_autoquest and time()-self.tmp_no_autoquest<10 then
self.tmp_no_autoquest=nil
return
end
if self.db.profile.autoturnin then
if not IsQuestCompletable() then return end
local title = GetTitleText()
for i,goal in ipairs(self.CurrentStep.goals) do
if goal.quest==title then
self:Print("Completing quest")
CompleteQuest()
return
end
end
end
end
function me:QUEST_COMPLETE()
if not self.CurrentStep then return end
-- 836: seems not necessary anymore; moving to QuestAutoAccept.lua
--self:Debug('QUEST_COMPLETE: '..tostring(GetTitleText()).." (talker: "..tostring(UnitName("target"))..")")
--self.completingQuest = GetTitleText()
--self:RecordData(self.questIndicesByTitle[GetTitleText()], 'finish', QuestFrameNpcNameText:GetText())
if self.db.profile.autoturnin then
if (GetNumQuestChoices()>0) then return end
local title = GetTitleText()
for i,goal in ipairs(self.CurrentStep.goals) do
if goal.quest==title then
self:Print("Turning in quest")
GetQuestReward()
return
end
end
end
end