-
Notifications
You must be signed in to change notification settings - Fork 9
/
Achievements.lua
162 lines (141 loc) · 5.73 KB
/
Achievements.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
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
local WQA = WQAchievements
WQA.Achievements = {}
function WQA.Achievements:Register(achievement, forced, forcedByMe)
if achievement.criteriaType == "SPECIAL" then
return
end
local id = achievement.id
forced = forced or false
forcedByMe = false
if WQA.db.profile.achievements[id] == "disabled" then
return
end
if WQA.db.profile.achievements[id] == "exclusive" and WQA.db.profile.achievements.exclusive[id] ~= WQA.playerName then
return
end
if WQA.db.profile.achievements[id] == "always" then
forced = true
end
if WQA.db.profile.achievements[id] == "wasEarnedByMe" then
forcedByMe = true
end
local _, _, _, completed, _, _, _, _, _, _, _, _, wasEarnedByMe = GetAchievementInfo(id)
if (achievement.notAccountwide and not wasEarnedByMe) or not completed or forced or forcedByMe then
if achievement.criteriaType == "ACHIEVEMENT" then
self:Register_ACHIEVEMENT(achievement, forced, forcedByMe)
elseif achievement.criteriaType == "QUEST_SINGLE" then
self:Register_QUEST_SINGLE(achievement)
elseif achievement.criteriaType == "QUEST_PIN" then
self:Register_QUEST_PIN(achievement, forced)
elseif achievement.criteriaType == "QUEST_FLAG" then
self:Register_QUEST_FLAG(achievement)
else
local achievementNumCriteria = GetAchievementNumCriteria(id)
if achievementNumCriteria > 0 then
for i = 1, achievementNumCriteria do
local _, _, criteriaCompleted, _, _, _, _, questID = GetAchievementCriteriaInfo(id, i)
if not criteriaCompleted or forced then
if achievement.criteriaType == "QUESTS" then
self:Register_QUESTS(achievement, i)
elseif achievement.criteriaType == "MISSION_TABLE" then
self:Register_MISSION_TABLE(achievement, i, questID)
elseif achievement.criteriaType == "AREA_POI" then
self:Register_AREA_POI(achievement, i)
else
WQA:AddRewardToQuest(questID, "ACHIEVEMENT", id)
end
end
end
else
if achievement.criteriaType == "QUESTS" then
self:Register_QUESTS(achievement, 1)
end
end
end
end
end
function WQA.Achievements:Register_ACHIEVEMENT(achievement, forced, forcedByMe)
for _, criteriaAchievement in pairs(achievement.criteria) do
self:Register(criteriaAchievement, forced, forcedByMe)
end
end
function WQA.Achievements:Register_QUEST_SINGLE(achievement)
local id = achievement.id
if type(achievement.criteria) == "table" then
for _, questID in pairs(achievement.criteria) do
WQA:AddRewardToQuest(questID, "ACHIEVEMENT", id)
end
else
WQA:AddRewardToQuest(achievement.criteria, "ACHIEVEMENT", id)
end
end
function WQA.Achievements:Register_QUEST_PIN(achievement, forced)
local id = achievement.id
C_QuestLine.RequestQuestLinesForMap(achievement.mapID)
for i = 1, GetAchievementNumCriteria(id) do
local _, _, completed, _, _, _, _, questID = GetAchievementCriteriaInfo(id, i)
if not questID then
return
end
if not completed or forced then
if achievement.criteriaInfo[i] then
for _, questID in pairs(achievement.criteriaInfo[i]) do
WQA:AddRewardToQuest(questID, "ACHIEVEMENT", id)
WQA.questPinMapList[achievement.mapID] = true
WQA.questPinList[questID] = true
end
else
WQA:AddRewardToQuest(questID, "ACHIEVEMENT", id)
WQA.questPinMapList[achievement.mapID] = true
WQA.questPinList[questID] = true
end
end
end
end
function WQA.Achievements:Register_QUEST_FLAG(achievement)
WQA:AddRewardToQuest(achievement.criteria, "ACHIEVEMENT", achievement.id)
WQA.questFlagList[achievement.criteria] = true
end
function WQA.Achievements:Register_QUESTS(achievement, index)
local id = achievement.id
if type(achievement.criteria[index]) == "table" then
for _, questID in pairs(achievement.criteria[index]) do
WQA:AddRewardToQuest(questID, "ACHIEVEMENT", id)
end
else
local questID = achievement.criteria[index]
if questID then
WQA:AddRewardToQuest(questID, "ACHIEVEMENT", id)
end
end
end
function WQA.Achievements:Register_MISSION_TABLE(achievement, index, criteriaQuestId)
local id = achievement.id
if achievement.criteria and achievement.criteria[index] then
if type(achievement.criteria[index]) == "table" then
for _, questID in pairs(achievement.criteria[index]) do
WQA:AddRewardToMission(questID, "ACHIEVEMENT", id)
end
else
local questID = achievement.criteria[index]
if questID then
WQA:AddRewardToMission(questID, "ACHIEVEMENT", id)
end
end
else
WQA:AddRewardToMission(criteriaQuestId, "ACHIEVEMENT", id)
end
end
function WQA.Achievements:Register_AREA_POI(achievement, index)
local id = achievement.id
if not achievement.criteria[index].AreaPoiId then
for _, areaPoi in pairs(achievement.criteria[index]) do
WQA.Criterias.AreaPoi:AddReward(areaPoi, "ACHIEVEMENT", id)
end
else
local areaPoi = achievement.criteria[index]
if areaPoi then
WQA.Criterias.AreaPoi:AddReward(areaPoi, "ACHIEVEMENT", id)
end
end
end