-
Notifications
You must be signed in to change notification settings - Fork 0
/
Core.lua
198 lines (176 loc) · 6.54 KB
/
Core.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
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 GottaGoFast = LibStub("AceAddon-3.0"):GetAddon("GottaGoFast")
local utility = GottaGoFast.Utility;
local debugPrint = utility.DebugPrint;
local LOP = LibStub("LibObjectiveProgress-1.0", true);
function GottaGoFast:OnInitialize()
-- Called when the addon is loaded
-- Register Frames
GottaGoFastFrame = CreateFrame("Frame", "GottaGoFastFrame", UIParent);
GottaGoFastHideFrame = CreateFrame("Frame");
GottaGoFastHideFrame:Hide();
end
function GottaGoFast:OnEnable()
-- Called when the addon is enabled
-- Register Events
RegisterAddonMessagePrefix("GottaGoFast");
RegisterAddonMessagePrefix("GottaGoFastCM");
self:RegisterEvent("CHALLENGE_MODE_COMPLETED");
self:RegisterEvent("CHALLENGE_MODE_RESET");
self:RegisterEvent("CHALLENGE_MODE_START");
--self:RegisterEvent("GOSSIP_SHOW");
self:RegisterEvent("PLAYER_ENTERING_WORLD");
self:RegisterEvent("SCENARIO_POI_UPDATE");
self:RegisterEvent("UPDATE_MOUSEOVER_UNIT");
self:RegisterEvent("WORLD_STATE_TIMER_START");
self:RegisterEvent("ZONE_CHANGED_NEW_AREA")
self:RegisterChatCommand("ggf", "ChatCommand");
self:RegisterChatCommand("GottaGoFast", "ChatCommand");
self:RegisterComm("GottaGoFast", "ChatComm");
self:RegisterComm("GottaGoFastCM", "CMChatComm");
-- Setup AddOn
self:InitState();
self:InitOptions();
self:InitFrame();
self:VersionCheck();
end
function GottaGoFast:OnDisable()
-- Called when the addon is disabled
end
function GottaGoFast:CHALLENGE_MODE_COMPLETED()
debugPrint("CM Complete");
GottaGoFast.CompleteCM();
GottaGoFast.CreateRun(GottaGoFast.CurrentCM);
end
function GottaGoFast:CHALLENGE_MODE_RESET()
debugPrint("CM Reset")
GottaGoFast.ResetState()
GottaGoFast.HideObjectiveTracker()
end
function GottaGoFast:CHALLENGE_MODE_START()
debugPrint("CM Start")
GottaGoFast.ResetState()
GottaGoFast.HideObjectiveTracker()
end
function GottaGoFast:PLAYER_ENTERING_WORLD()
debugPrint("Player Entered World")
self:WhereAmI()
end
function GottaGoFast:SCENARIO_POI_UPDATE()
if (self.inCM) then
debugPrint("Scenario POI Update");
if (self.CurrentCM["Steps"] == 0 and self.CurrentCM["Completed"] == false and next(self.CurrentCM["Bosses"]) == nil) then
self:WhereAmI();
end
self.UpdateCMInformation();
self.UpdateCMObjectives();
end
end
function GottaGoFast:WORLD_STATE_TIMER_START(_, timerID)
debugPrint("World Start Timer Start"..timerID)
if (self.inCM == false or next(self.CurrentCM) == nil or next(self.CurrentCM) == nil or self.CurrentCM["Steps"] == 0) then
self:WhereAmI()
end
if (self.inCM and self.CurrentCM["Completed"] == false) then
local _, timeCM, type = GetWorldElapsedTime(timerID)
if (type == LE_WORLD_ELAPSED_TIMER_TYPE_CHALLENGE_MODE and timeCM ~= nil and timeCM <= 2) then
self.StartCM(0)
self.UpdateCMObjectives()
elseif (self.CurrentCM["Deaths"]) then
self.CurrentCM["Deaths"] = self.CurrentCM["Deaths"] + 1
self.UpdateCMObjectives()
end
end
end
function GottaGoFast:UPDATE_MOUSEOVER_UNIT()
if (self.inCM == true and self.GetIndividualMobValue(nil) == true and self.CurrentCM ~= nil and next(self.CurrentCM) ~= nil) then
local npcID = GottaGoFast.MouseoverUnitID();
local mapID = self.CurrentCM["ZoneID"];
local cmID = self.CurrentCM["CmID"]
local isTeeming = self.HasTeeming(self.CurrentCM["Affixes"]);
if (npcID ~= nil and mapID ~= nil and isTeeming ~= nil) then
-- Upper Karazhan Check Should Be Param 4
local upper = cmID == 234
local weight = LOP:GetNPCWeightByMap(mapID, npcID, isTeeming, upper);
if (weight ~= nil) then
local appendString = string.format(" (%.1f%%)", weight);
GameTooltip:AppendText(appendString);
end
end
end
end
--[[
function GottaGoFast:GOSSIP_SHOW()
if (self.inCM == true and self.CurrentCM ~= nil and next(self.CurrentCM) ~= nil) then
GottaGoFast.HandleGossip();
end
end
]]--
function GottaGoFast:ZONE_CHANGED_NEW_AREA()
debugPrint("Zone Changed New Area")
self:WhereAmI();
end
function GottaGoFast:ChatCommand(input)
if (string.lower(input) == "debugmode") then
--local setting = not GottaGoFast.GetDebugMode(nil);
GottaGoFast.SetDebugMode(nil, (not GottaGoFast.GetDebugMode(nil)));
else
InterfaceOptionsFrame_OpenToCategory(GottaGoFast.optionsFrame);
InterfaceOptionsFrame_OpenToCategory(GottaGoFast.optionsFrame);
end
end
function GottaGoFast:ChatComm(prefix, input, distribution, sender)
debugPrint("History Message (From History Addon) Received");
if (prefix == "GottaGoFast" and input == "HistoryLoaded") then
debugPrint("Input: History Loaded")
if (GottaGoFast.SendHistoryFlag == true) then
GottaGoFast.SendHistory(self.db.profile.History);
end
end
end
function GottaGoFast:CMChatComm(prefix, input, distribution, sender)
-- Right Now This Is Only Used For Syncing Timer
debugPrint("CM Message Received");
if (prefix == "GottaGoFastCM" and input == "FixCM" and GottaGoFast.inCM == true and GottaGoFast.CurrentCM and next(GottaGoFast.CurrentCM) ~= nil) then
GottaGoFast.CheckCMTimer();
elseif (prefix == "GottaGoFastCM" and GottaGoFast.inCM == true and GottaGoFast.CurrentCM and next(GottaGoFast.CurrentCM) ~= nil) then
-- Received Timer, See If You Need It, Then Update
GottaGoFast.FixCMTimer(input)
end
end
local reset_time = 8.0
local last_cm_zoneid = nil
function GottaGoFast.ResetState()
GottaGoFast.WipeCM();
GottaGoFast.inCM = false;
GottaGoFast.demoMode = false;
GottaGoFast.tooltip = GottaGoFast.defaultTooltip;
GottaGoFastFrame:SetScript("OnUpdate", nil);
GottaGoFast.HideFrames();
GottaGoFast.ShowObjectiveTracker();
last_cm_zoneid = nil
end
function GottaGoFast:WhereAmI()
local _, _, difficulty, _, _, _, _, currentZoneID = GetInstanceInfo();
debugPrint("Difficulty: " .. difficulty);
debugPrint("Zone ID: " .. currentZoneID);
local challengeMapID = C_ChallengeMode.GetActiveChallengeMapID()
if (difficulty == 8 and challengeMapID ~= nil) then
if (not last_cm_zoneid) or (last_cm_zoneid ~= currentZoneID) then
last_cm_zoneid = currentZoneID;
self:InitCM(challengeMapID, currentZoneID);
end
else
--GottaGoFast.ResetState();
if self.CurrentCM["Completed"] == false then
self:ScheduleTimer(self.CheckLeftForGood, reset_time, self.CurrentCM["ZoneID"]);
else
self:ScheduleTimer(self.CheckLeftForGood, 1, self.CurrentCM["ZoneID"]);
end
end
end
function GottaGoFast.CheckLeftForGood(ZoneID)
local _, _, difficulty, _, _, _, _, currentZoneID = GetInstanceInfo();
if (difficulty ~= 8) then
GottaGoFast.ResetState();
end
end