vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | --[[ |
2 | Author 1: Znadul (Kor'gall) |
||
3 | Author 2: Corvian (Warsong) |
||
4 | Date: 21/06/2006 |
||
5 | Version: 0.8 |
||
6 | |||
7 | Description: |
||
8 | |||
9 | Special thnx: |
||
10 | AeneasKuM and mrpel (ui.worldofwar.net) - 1.12 fix |
||
11 | ]]-- |
||
12 | |||
13 | --------------------------------------------------------------------------------- |
||
14 | -- VARIABLES |
||
15 | --------------------------------------------------------------------------------- |
||
16 | local lOriginalWorldStateAlwaysUpFrame_Update; |
||
17 | ABHEFS_VERSION = "0.8"; |
||
18 | |||
19 | local ABHEFS_FlagsData = { |
||
20 | [0] = { time = 999999, rate = 999999 }, |
||
21 | [1] = { time = 11, rate = 1.1 }, |
||
22 | [2] = { time = 10, rate = 1 }, |
||
23 | [3] = { time = 6, rate = 0.6 }, |
||
24 | [4] = { time = 3, rate = 0.3 }, |
||
25 | [5] = { time = 1, rate = 0.03333 } |
||
26 | }; |
||
27 | |||
28 | local ABHEFS_POIsData = { |
||
29 | -- ids: 1-Mine, 2-Lumber, 3-BS, 4-Farm, 5-Stables (not used) |
||
30 | [16] = { id = 1, faction = "Neutral", conflict = false }, |
||
31 | [17] = { id = 1, faction = "Aliance", conflict = true }, |
||
32 | [18] = { id = 1, faction = "Aliance", conflict = false }, |
||
33 | [19] = { id = 1, faction = "Horde", conflict = true }, |
||
34 | [20] = { id = 1, faction = "Horde", conflict = false }, |
||
35 | [21] = { id = 2, faction = "Neutral", conflict = false }, |
||
36 | [22] = { id = 2, faction = "Aliance", conflict = true }, |
||
37 | [23] = { id = 2, faction = "Aliance", conflict = false }, |
||
38 | [24] = { id = 2, faction = "Horde", conflict = true }, |
||
39 | [25] = { id = 2, faction = "Horde", conflict = false }, |
||
40 | [26] = { id = 3, faction = "Neutral", conflict = false }, |
||
41 | [27] = { id = 3, faction = "Aliance", conflict = true }, |
||
42 | [28] = { id = 3, faction = "Aliance", conflict = false }, |
||
43 | [29] = { id = 3, faction = "Horde", conflict = true }, |
||
44 | [30] = { id = 3, faction = "Horde", conflict = false }, |
||
45 | [31] = { id = 4, faction = "Neutral", conflict = false }, |
||
46 | [32] = { id = 4, faction = "Aliance", conflict = true }, |
||
47 | [33] = { id = 4, faction = "Aliance", conflict = false }, |
||
48 | [34] = { id = 4, faction = "Horde", conflict = true }, |
||
49 | [35] = { id = 4, faction = "Horde", conflict = false }, |
||
50 | [36] = { id = 5, faction = "Neutral", conflict = false }, |
||
51 | [37] = { id = 5, faction = "Aliance", conflict = true }, |
||
52 | [38] = { id = 5, faction = "Aliance", conflict = false }, |
||
53 | [39] = { id = 5, faction = "Horde", conflict = true }, |
||
54 | [40] = { id = 5, faction = "Horde", conflict = false } |
||
55 | }; |
||
56 | |||
57 | local ABHEFS_FlagsStatus = { |
||
58 | [ABHEFS_GOLDMINE] = { id = 1, status = -1, timeLeft = 0 }, |
||
59 | [ABHEFS_LUMBERMILL] = { id = 2, status = -1, timeLeft = 0 }, |
||
60 | [ABHEFS_BLACKSMITH] = { id = 3, status = -1, timeLeft = 0 }, |
||
61 | [ABHEFS_FARM] = { id = 4, status = -1, timeLeft = 0 }, |
||
62 | [ABHEFS_STABLES] = { id = 5, status = -1, timeLeft = 0 } |
||
63 | }; |
||
64 | |||
65 | local ABHEFS_ScoreStatus = { |
||
66 | ["Aliance"] = { score = 0, lastUpdate = 0, flags = 0, updated = false}, |
||
67 | ["Horde"] = { score = 0, lastUpdate = 0, flags = 0, updated = false } |
||
68 | }; |
||
69 | |||
70 | local ABHEFS_DebugData = { }; |
||
71 | |||
72 | local ABHEFS_PlayerFaction = nil; |
||
73 | |||
74 | local ABHEFS_TimeLeft = 0; |
||
75 | local ABHEFS_FlagAssaultTime = 64; |
||
76 | local ABHEFS_ShowTime = false; |
||
77 | local ABHEFS_LastLeftTimerUpdate; |
||
78 | local ABHEFS_LastTimersUpdate; |
||
79 | local ABHEFS_isWinning = { faction = 0, score = 0}; -- faction: 1-alliance 2-horde |
||
80 | |||
81 | --------------------------------------------------------------------------------- |
||
82 | -- LOCAL FUNCTIONS |
||
83 | --------------------------------------------------------------------------------- |
||
84 | |||
85 | --------------------------------------------------------------------------------- |
||
86 | -- GLOBAL FUNCTIONS |
||
87 | --------------------------------------------------------------------------------- |
||
88 | |||
89 | function ABHEFSPrint(msg) --* |
||
90 | if (DEFAULT_CHAT_FRAME) then |
||
91 | DEFAULT_CHAT_FRAME:AddMessage(msg, 1.0, 0.5, 1.0); |
||
92 | end |
||
93 | end |
||
94 | |||
95 | function ABHEFS_ResetStatus() --* |
||
96 | for i, value in ABHEFS_FlagsStatus do |
||
97 | value.status = -1; |
||
98 | value.timeLeft = 0; |
||
99 | end |
||
100 | for i, value in ABHEFS_ScoreStatus do |
||
101 | value.score = 0; |
||
102 | value.lastUpdate = 0; |
||
103 | value.flags = 0; |
||
104 | value.updated = false; |
||
105 | end |
||
106 | |||
107 | end |
||
108 | |||
109 | function ABHEFS_TimeToStr(time) --* |
||
110 | if ( time >= 60 ) then |
||
111 | secs = mod(time, 60); |
||
112 | mins = (time - secs) / 60; |
||
113 | else |
||
114 | mins = 0; |
||
115 | secs = time; |
||
116 | end |
||
117 | if ( mins < 10 ) then mins = "0" .. mins; end |
||
118 | if ( secs < 10 ) then secs = "0" .. secs; end |
||
119 | |||
120 | timeText = mins .. ":" .. secs; |
||
121 | |||
122 | return timeText; |
||
123 | end |
||
124 | |||
125 | function ABHEFS_SlashHandler(command) --* |
||
126 | local i,j, cmd, param = string.find(command, "^([^ ]+) (.+)$"); |
||
127 | |||
128 | -- nil prevention |
||
129 | if (not cmd) then cmd = command; end |
||
130 | if (not cmd) then cmd = ""; end |
||
131 | if (not param) then param = ""; end |
||
132 | |||
133 | if (cmd == "on") then |
||
134 | -- hook |
||
135 | WorldStateAlwaysUpFrame_Update = ABHEFS_WorldStateAlwaysUpFrame_Update; |
||
136 | ABHEFSPrint("ABHEFS enabled"); |
||
137 | WorldStateAlwaysUpFrame_Update(); |
||
138 | end |
||
139 | |||
140 | if (cmd == "off") then |
||
141 | -- unhook |
||
142 | WorldStateAlwaysUpFrame_Update = lOriginalWorldStateAlwaysUpFrame_Update; |
||
143 | ABHEFSPrint("ABHEFS disabled"); |
||
144 | getglobal("ABHEFS_Frame"):Hide(); |
||
145 | -- WorldStateAlwaysUpFrame_Update(); |
||
146 | end |
||
147 | |||
148 | if (cmd == "resetpos") then |
||
149 | getglobal("ABHEFS_Frame"):ClearAllPoints(); |
||
150 | getglobal("ABHEFS_Frame"):SetPoint("TOPLEFT", "AlwaysUpFrame2", "BOTTOMLEFT", 0, 0); |
||
151 | end |
||
152 | |||
153 | |||
154 | if ((cmd == "") or (cmd == "help")) then |
||
155 | ABHEFSPrint("Usage:"); |
||
156 | ABHEFSPrint(" /ABHEFS (on/off) | Enable / Disable"); |
||
157 | ABHEFSPrint(" /ABHEFS resetpos | Reset the frame position"); |
||
158 | end |
||
159 | |||
160 | end |
||
161 | |||
162 | function ABHEFS_TimeTo(faction, endScore) --* |
||
163 | -- check for endScore reached |
||
164 | if (ABHEFS_ScoreStatus[faction].score >= endScore) then |
||
165 | return 0; |
||
166 | end |
||
167 | |||
168 | timePerTick = ABHEFS_FlagsData[ABHEFS_ScoreStatus[faction].flags].time; |
||
169 | |||
170 | |||
171 | timeToNextTick = timePerTick - (time() - ABHEFS_ScoreStatus[faction].lastUpdate); |
||
172 | |||
173 | -- check for reached at next tick |
||
174 | if (endScore == ABHEFS_ScoreStatus[faction].score + 10) then |
||
175 | return timeToNextTick; |
||
176 | end |
||
177 | |||
178 | timeTo = (((endScore - (ABHEFS_ScoreStatus[faction].score + 10)) / 10) * timePerTick) + timeToNextTick; |
||
179 | return timeTo; |
||
180 | end |
||
181 | |||
182 | function ABHEFS_scoreAfter(faction, seconds) --* |
||
183 | timePerTick = ABHEFS_FlagsData[ABHEFS_ScoreStatus[faction].flags].time; |
||
184 | |||
185 | timeToNextTick = timePerTick - (time() - ABHEFS_ScoreStatus[faction].lastUpdate); |
||
186 | |||
187 | -- check for no changes until second |
||
188 | if (timeToNextTick > seconds) then |
||
189 | return ABHEFS_ScoreStatus[faction].score; |
||
190 | end |
||
191 | |||
192 | scoreAfter = ABHEFS_ScoreStatus[faction].score + 10 + (floor((seconds - timeToNextTick) / timePerTick) * 10); |
||
193 | |||
194 | return scoreAfter; |
||
195 | end |
||
196 | |||
197 | function ABHEFS_GetData() --* |
||
198 | local winner, stat1, stat2; |
||
199 | local scoreWinner; |
||
200 | local estimatedTime; |
||
201 | local min, secs; |
||
202 | _, stat1 = GetWorldStateUIInfo(1); |
||
203 | _, stat2 = GetWorldStateUIInfo(2); |
||
204 | _, _, strAllyBases, strAllyScore = string.find(stat1, ABHEFS_WORLDSTATESTRING); |
||
205 | _, _, strHordeBases, strHordeScore = string.find(stat2, ABHEFS_WORLDSTATESTRING); |
||
206 | |||
207 | allyBases = tonumber(strAllyBases); |
||
208 | hordeBases = tonumber(strHordeBases); |
||
209 | allyScore = tonumber(strAllyScore); |
||
210 | hordeScore = tonumber(strHordeScore); |
||
211 | needed = ABHEFS_GetNeeded(allyScore, hordeScore); |
||
212 | -- check for data and victory |
||
213 | if (not allyScore) or (not hordeScore) or (allyScore == 2000) or (hordeScore == 2000) then |
||
214 | getglobal("ABHEFS_Frame"):Hide(); |
||
215 | ABHEFS_ResetStatus(); |
||
216 | ABHEFS_TimeLeft = 0; |
||
217 | return; |
||
218 | else |
||
219 | getglobal("ABHEFS_Frame"):Show(); |
||
220 | end |
||
221 | |||
222 | -- bases are always updated |
||
223 | ABHEFS_ScoreStatus["Aliance"].flags = allyBases; |
||
224 | ABHEFS_ScoreStatus["Horde"].flags = hordeBases; |
||
225 | |||
226 | -- check for first update |
||
227 | if (ABHEFS_ScoreStatus["Horde"].lastUpdate == 0) then |
||
228 | ABHEFS_ScoreStatus["Horde"].score = hordeScore; |
||
229 | ABHEFS_ScoreStatus["Horde"].lastUpdate = time(); |
||
230 | end |
||
231 | if (ABHEFS_ScoreStatus["Aliance"].lastUpdate == 0) then |
||
232 | ABHEFS_ScoreStatus["Aliance"].score = allyScore; |
||
233 | ABHEFS_ScoreStatus["Aliance"].lastUpdate = time(); |
||
234 | end |
||
235 | |||
236 | -- check for 5-0 |
||
237 | if (allyBases == 5) then |
||
238 | return 2000, hordeScore; |
||
239 | elseif (hordeBases == 5) then |
||
240 | return allyScore, 2000, nil, needed; |
||
241 | end |
||
242 | |||
243 | if (allyBases == 0) and (hordeBases == 0) then |
||
244 | estimatedAlly = "ind."; |
||
245 | estimatedHorde = "ind."; |
||
246 | return estimatedAlly, estimatedHorde, nil, needed; |
||
247 | end |
||
248 | |||
249 | -- if some1 is 0 then updated is true anyway |
||
250 | if (allyBases == 0) then |
||
251 | ABHEFS_ScoreStatus["Aliance"].updated = true; |
||
252 | end |
||
253 | |||
254 | if (hordeBases == 0) then |
||
255 | ABHEFS_ScoreStatus["Horde"].updated = true; |
||
256 | end |
||
257 | |||
258 | if (hordeScore ~= ABHEFS_ScoreStatus["Horde"].score) then |
||
259 | ABHEFS_ScoreStatus["Horde"].score = hordeScore; |
||
260 | ABHEFS_ScoreStatus["Horde"].lastUpdate = time(); |
||
261 | ABHEFS_ScoreStatus["Horde"].updated = true; |
||
262 | elseif (allyScore ~= ABHEFS_ScoreStatus["Aliance"].score) then |
||
263 | ABHEFS_ScoreStatus["Aliance"].score = allyScore; |
||
264 | ABHEFS_ScoreStatus["Aliance"].lastUpdate = time(); |
||
265 | ABHEFS_ScoreStatus["Aliance"].updated = true; |
||
266 | end -- TODO: check for only flags change |
||
267 | |||
268 | |||
269 | -- only show when both factions updateds |
||
270 | if not ABHEFS_ScoreStatus["Aliance"].updated or not ABHEFS_ScoreStatus["Horde"].updated then |
||
271 | estimatedAlly = "ind."; |
||
272 | estimatedHorde = "ind."; |
||
273 | return estimatedAlly, estimatedHorde, nil, needed; |
||
274 | end |
||
275 | |||
276 | |||
277 | estiHordeTime = ABHEFS_TimeTo("Horde", 2000); |
||
278 | estiAlianceTime = ABHEFS_TimeTo("Aliance", 2000); |
||
279 | |||
280 | if (estiHordeTime > estiAlianceTime) or (hordeBases == 0) then -- aliance victory |
||
281 | estimatedAlly = 2000; |
||
282 | estimatedHorde = ABHEFS_scoreAfter("Horde", estiAlianceTime); |
||
283 | winner = 1; |
||
284 | scoreWinner = allyScore; |
||
285 | estimatedTime = estiAlianceTime; |
||
286 | else |
||
287 | estimatedHorde = 2000; |
||
288 | estimatedAlly = ABHEFS_scoreAfter("Aliance", estiHordeTime); |
||
289 | winner = 2; |
||
290 | scoreWinner = hordeScore; |
||
291 | estimatedTime = estiHordeTime; |
||
292 | end |
||
293 | |||
294 | |||
295 | if estimatedTime then |
||
296 | -- only return estimatedTime for resources changes on winner |
||
297 | if (winner ~= ABHEFS_isWinning.faction) or (scoreWinner ~= ABHEFS_isWinning.score) then |
||
298 | ABHEFS_TimeLeft = estimatedTime; |
||
299 | ABHEFS_LastLeftTimerUpdate = time(); |
||
300 | ABHEFS_isWinning.faction = winner; |
||
301 | ABHEFS_isWinning.score = scoreWinner; |
||
302 | return estimatedAlly, estimatedHorde, ABHEFS_TimeToStr(estimatedTime), needed; |
||
303 | else |
||
304 | return estimatedAlly, estimatedHorde, ABHEFS_TimeToStr(ABHEFS_TimeLeft),needed; |
||
305 | end |
||
306 | else |
||
307 | return estimatedAlly, estimatedHorde, nil, needed; |
||
308 | end |
||
309 | end |
||
310 | |||
311 | function ABHEFS_GetNeeded(aScore, hScore) |
||
312 | if (aScore and hScore) then |
||
313 | aScore = tonumber(aScore); |
||
314 | hScore = tonumber(hScore); |
||
315 | if (((2000 - aScore) * ABHEFS_FlagsData[1].rate) < ((2000 - hScore) * ABHEFS_FlagsData[4].rate)) then |
||
316 | return 1; |
||
317 | elseif (((2000 - aScore) * ABHEFS_FlagsData[2].rate) < ((2000 - hScore) * ABHEFS_FlagsData[3].rate)) then |
||
318 | return 2; |
||
319 | elseif (((2000 - aScore) * ABHEFS_FlagsData[3].rate) < ((2000 - hScore) * ABHEFS_FlagsData[2].rate)) then |
||
320 | return 3; |
||
321 | elseif (((2000 - aScore) * ABHEFS_FlagsData[4].rate) < ((2000 - hScore) * ABHEFS_FlagsData[1].rate)) then |
||
322 | return 4; |
||
323 | else |
||
324 | return 5; |
||
325 | end |
||
326 | else |
||
327 | return; |
||
328 | end |
||
329 | end |
||
330 | |||
331 | function ABHEFS_UpdateFlags() --* |
||
332 | local name, status, lastStatus; |
||
333 | local timeLeft; |
||
334 | local ownerFaction, oppositeFaction; |
||
335 | local x1, x2, y1, y2; |
||
336 | |||
337 | SetMapToCurrentZone(); |
||
338 | |||
339 | -- read data |
||
340 | local numLMs = GetNumMapLandmarks(); |
||
341 | for i = 1, numLMs, 1 do |
||
342 | name, _, status = GetMapLandmarkInfo(i); |
||
343 | -- check for change status (only trackeable status, with entry in ABHEFS_POIsData) |
||
344 | if ABHEFS_FlagsStatus[name] and (ABHEFS_FlagsStatus[name].status ~= status) and ABHEFS_POIsData[status] then |
||
345 | lastStatus = ABHEFS_FlagsStatus[name].status; |
||
346 | ABHEFS_FlagsStatus[name].status = status; |
||
347 | |||
348 | if (lastStatus ~= -1) and ABHEFS_POIsData[status].conflict then -- just assaulted |
||
349 | -- if lastStatus == -1 the new status is the first known status |
||
350 | ABHEFS_FlagsStatus[name].timeLeft = ABHEFS_FlagAssaultTime; |
||
351 | else |
||
352 | ABHEFS_FlagsStatus[name].timeLeft = 0; |
||
353 | end |
||
354 | end |
||
355 | end |
||
356 | |||
357 | -- write flags |
||
358 | for index, value in ABHEFS_FlagsStatus do |
||
359 | status = value.status; |
||
360 | timeLeft = value.timeLeft; |
||
361 | i = value.id; |
||
362 | |||
363 | |||
364 | if ABHEFS_POIsData[status] and (ABHEFS_POIsData[status].faction ~= "Neutral") then |
||
365 | ownerFaction = ABHEFS_POIsData[status].faction; |
||
366 | if (ownerFaction == "Aliance") then |
||
367 | oppositeFaction = "Horde"; |
||
368 | else |
||
369 | oppositeFaction = "Aliance"; |
||
370 | end |
||
371 | |||
372 | flagFrameShow = getglobal("ABHEFS_"..ownerFaction.."Flag"..i); |
||
373 | flagFrameTextShow = getglobal("ABHEFS_"..ownerFaction.."Flag"..i.."TimeText"); |
||
374 | flagFrameTextureShow = getglobal("ABHEFS_"..ownerFaction.."Flag"..i.."Texture"); |
||
375 | flagFrameHide = getglobal("ABHEFS_"..oppositeFaction.."Flag"..i); |
||
376 | |||
377 | x1, x2, y1, y2 = WorldMap_GetPOITextureCoords(status); |
||
378 | flagFrameTextureShow:SetTexCoord(x1, x2, y1, y2); |
||
379 | |||
380 | if (timeLeft > 0) then |
||
381 | flagFrameTextShow:SetText(ABHEFS_TimeToStr(timeLeft)); |
||
382 | else |
||
383 | flagFrameTextShow:SetText(""); |
||
384 | end |
||
385 | |||
386 | flagFrameShow:Show(); |
||
387 | flagFrameHide:Hide(); |
||
388 | else |
||
389 | getglobal("ABHEFS_AlianceFlag"..i):Hide(); |
||
390 | getglobal("ABHEFS_HordeFlag"..i):Hide(); |
||
391 | end |
||
392 | end |
||
393 | end |
||
394 | |||
395 | |||
396 | --------------------------------------------------------------------------------- |
||
397 | -- EVENT FUNCTIONS |
||
398 | --------------------------------------------------------------------------------- |
||
399 | |||
400 | function ABHEFS_OnLoad() |
||
401 | -- events |
||
402 | this:RegisterEvent("UPDATE_WORLD_STATES"); |
||
403 | this:RegisterEvent("CHAT_MSG_BG_SYSTEM_ALLIANCE"); |
||
404 | this:RegisterEvent("CHAT_MSG_BG_SYSTEM_HORDE"); |
||
405 | |||
406 | -- drag |
||
407 | this:RegisterForDrag("LeftButton"); |
||
408 | |||
409 | -- hook |
||
410 | lOriginalWorldStateAlwaysUpFrame_Update = WorldStateAlwaysUpFrame_Update; |
||
411 | |||
412 | -- enabled on load |
||
413 | WorldStateAlwaysUpFrame_Update = ABHEFS_WorldStateAlwaysUpFrame_Update; |
||
414 | |||
415 | ABHEFS_LastTimersUpdate = time(); |
||
416 | |||
417 | ABHEFSPrint("ABHEFS redux v."..ABHEFS_VERSION.."has loaded!"); |
||
418 | |||
419 | SLASH_ABHEFS1 = "/ABHEFS"; |
||
420 | SlashCmdList["ABHEFS"] = ABHEFS_SlashHandler; |
||
421 | end |
||
422 | |||
423 | function ABHEFS_OnEvent() |
||
424 | if (event == "UPDATE_WORLD_STATES") then |
||
425 | -- void atm |
||
426 | end |
||
427 | if (event == "CHAT_MSG_BG_SYSTEM_ALLIANCE" or event == "CHAT_MSG_BG_SYSTEM_HORDE") then |
||
428 | ABHEFS_UpdateFlags(); |
||
429 | end |
||
430 | end |
||
431 | |||
432 | function ABHEFS_OnUpdate() |
||
433 | -- check for Arathi Basin |
||
434 | local inArathi = false; |
||
435 | |||
436 | for i=1, MAX_BATTLEFIELD_QUEUES do |
||
437 | local status, mapName = GetBattlefieldStatus(i); |
||
438 | |||
439 | if (status == "active") and (mapName == ABHEFS_MAPNAME) then |
||
440 | inArathi = true; |
||
441 | end |
||
442 | end |
||
443 | |||
444 | if not inArathi then |
||
445 | getglobal("ABHEFS_Frame"):Hide(); |
||
446 | ABHEFS_ResetStatus(); |
||
447 | return; |
||
448 | end |
||
449 | |||
450 | -- execute code every second |
||
451 | if (ABHEFS_LastTimersUpdate ~= time()) then |
||
452 | ABHEFS_LastTimersUpdate = time(); |
||
453 | |||
454 | -- flags time |
||
455 | for i, value in ABHEFS_FlagsStatus do |
||
456 | timeLeft = value.timeLeft; |
||
457 | |||
458 | if (timeLeft > 0) then |
||
459 | value.timeLeft = timeLeft - 1; |
||
460 | end |
||
461 | end |
||
462 | ABHEFS_UpdateFlags(false); |
||
463 | |||
464 | -- Estimated End time |
||
465 | if (ABHEFS_TimeLeft == 0) or not ABHEFS_ShowTime then return; end |
||
466 | |||
467 | if (ABHEFS_LastLeftTimerUpdate ~= time()) then |
||
468 | -- get time elapsed |
||
469 | elapsed = time() - ABHEFS_LastLeftTimerUpdate; |
||
470 | ABHEFS_TimeLeft = ABHEFS_TimeLeft - elapsed; |
||
471 | |||
472 | getglobal("ABHEFS_FrameTimeText"):SetText(ABHEFS_TIMELEFT .. ABHEFS_TimeToStr(ABHEFS_TimeLeft)); |
||
473 | |||
474 | ABHEFS_LastLeftTimerUpdate = time(); |
||
475 | end |
||
476 | end |
||
477 | end |
||
478 | |||
479 | function ABHEFS_OnDragStart() |
||
480 | ABHEFS_Frame:StartMoving(); |
||
481 | end |
||
482 | |||
483 | function ABHEFS_OnDragStop() |
||
484 | ABHEFS_Frame:StopMovingOrSizing(); |
||
485 | end |
||
486 | |||
487 | |||
488 | --------------------------------------------------------------------------------- |
||
489 | -- HOOK |
||
490 | --------------------------------------------------------------------------------- |
||
491 | |||
492 | function ABHEFS_WorldStateAlwaysUpFrame_Update() |
||
493 | local inArathi = false; |
||
494 | |||
495 | lOriginalWorldStateAlwaysUpFrame_Update(); |
||
496 | |||
497 | -- check for Arathi Basin |
||
498 | for i=1, MAX_BATTLEFIELD_QUEUES do |
||
499 | local status, mapName = GetBattlefieldStatus(i); |
||
500 | |||
501 | if (status == "active") and (mapName == ABHEFS_MAPNAME) then |
||
502 | inArathi = true; |
||
503 | end |
||
504 | end |
||
505 | |||
506 | if not inArathi then |
||
507 | getglobal("ABHEFS_Frame"):Hide(); |
||
508 | ABHEFS_ResetStatus(); |
||
509 | return; |
||
510 | end |
||
511 | |||
512 | if (ABHEFS_PlayerFaction == nil) then |
||
513 | ABHEFS_PlayerFaction = UnitFactionGroup("player"); |
||
514 | end |
||
515 | ABHEFS_UpdateFlags(); |
||
516 | |||
517 | -- update scores |
||
518 | frameTextAlly = getglobal("ABHEFS_FrameText1"); |
||
519 | frameTextHorde = getglobal("ABHEFS_FrameText2"); |
||
520 | frameTimeLeft = getglobal("ABHEFS_FrameTimeText"); |
||
521 | frameBasesNeeded = getglobal("ABHEFS_FrameNeededText"); |
||
522 | |||
523 | estimatedAlly, estimatedHorde, estimatedTime, needed = ABHEFS_GetData(); |
||
524 | |||
525 | if estimatedAlly then |
||
526 | frameTextAlly:SetText(estimatedAlly); |
||
527 | end |
||
528 | if estimatedHorde then |
||
529 | frameTextHorde:SetText(estimatedHorde); |
||
530 | end |
||
531 | if needed then |
||
532 | if (ABHEFS_PlayerFaction == "Horde") then |
||
533 | needed = 6 - needed; |
||
534 | end |
||
535 | frameBasesNeeded:SetText(ABHEFS_BASESNEEDED..needed); |
||
536 | end |
||
537 | if estimatedTime then |
||
538 | ABHEFS_ShowTime = true; |
||
539 | frameTimeLeft:SetText(ABHEFS_TIMELEFT..estimatedTime); |
||
540 | else |
||
541 | ABHEFS_ShowTime = false; |
||
542 | frameTimeLeft:SetText(""); |
||
543 | end; |
||
544 | |||
545 | end |