forked from BigWigsMods/Capping
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbattlegrounds.lua
619 lines (587 loc) · 22.6 KB
/
battlegrounds.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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
local mod
do
local _
_, mod = ...
end
local L = mod.L
local ceil = math.ceil
local strmatch, pairs, format, tonumber = strmatch, pairs, format, tonumber
local GetIconAndTextWidgetVisualizationInfo = C_UIWidgetManager.GetIconAndTextWidgetVisualizationInfo
local GetAreaPOIForMap = C_AreaPoiInfo.GetAreaPOIForMap
local GetAreaPOIInfo = C_AreaPoiInfo.GetAreaPOIInfo
local SetupAssault, GetIconData
do -- POI handling
-- Easy world map icon checker
--[[local start = function(self) self:StartMoving() end
local stop = function(self) self:StopMovingOrSizing() end
local frames = {}
do
local f = CreateFrame("Frame", nil, UIParent)
f:SetPoint("CENTER")
f:SetSize(24,24)
f:EnableMouse(true)
f:SetMovable(true)
f:RegisterForDrag("LeftButton")
f:SetScript("OnDragStart", start)
f:SetScript("OnDragStop", stop)
frames[1] = f
local tx = f:CreateTexture()
tx:SetAllPoints(f)
tx:SetTexture(136441) -- Interface\\Minimap\\POIIcons
tx:SetTexCoord(GetPOITextureCoords(1))
local n = f:CreateFontString(nil, "OVERLAY", "GameFontNormalLarge")
n:SetPoint("BOTTOM", f, "TOP")
n:SetText(1)
end
for i = 2, 205 do
local f = CreateFrame("Frame", nil, UIParent)
f:SetPoint("LEFT", frames[i-1], "RIGHT", 10, 0)
f:SetSize(24,24)
f:EnableMouse(true)
f:SetMovable(true)
f:RegisterForDrag("LeftButton")
f:SetScript("OnDragStart", start)
f:SetScript("OnDragStop", stop)
frames[i] = f
local tx = f:CreateTexture()
tx:SetAllPoints(f)
tx:SetTexture(136441) -- Interface\\Minimap\\POIIcons
tx:SetTexCoord(GetPOITextureCoords(i))
local n = f:CreateFontString(nil, "OVERLAY", "GameFontNormalLarge")
n:SetPoint("BOTTOM", f, "TOP")
n:SetText(i)
end]]
local iconDataConflict = {
-- Graveyard
[4] = "colorAlliance",
[14] = "colorHorde",
-- Tower
[9] = "colorAlliance",
[12] = "colorHorde",
-- Mine/Stone
[17] = "colorAlliance",
[19] = "colorHorde",
-- Lumber/Wood
[22] = "colorAlliance",
[24] = "colorHorde",
-- Blacksmith/Anvil
[27] = "colorAlliance",
[29] = "colorHorde",
-- Farm/House
[32] = "colorAlliance",
[34] = "colorHorde",
-- Stables/Horse
[37] = "colorAlliance",
[39] = "colorHorde",
-- Workshop/Tent
[137] = "colorAlliance",
[139] = "colorHorde",
-- Hangar/Mushroom
[142] = "colorAlliance",
[144] = "colorHorde",
-- Docks/Anchor
[147] = "colorAlliance",
[149] = "colorHorde",
-- Oil/Refinery
[152] = "colorAlliance",
[154] = "colorHorde",
}
local GetPOITextureCoords = GetPOITextureCoords
local capTime = 0
local curMapID = 0
local path = {136441}
GetIconData = function(icon)
path[2], path[3], path[4], path[5] = GetPOITextureCoords(icon)
return path
end
local landmarkCache = {}
SetupAssault = function(bgcaptime, uiMapID)
capTime = bgcaptime -- cap time
curMapID = uiMapID -- current map
landmarkCache = {}
local pois = GetAreaPOIForMap(uiMapID)
for i = 1, #pois do
local tbl = GetAreaPOIInfo(uiMapID, pois[i])
landmarkCache[tbl.name] = tbl.textureIndex
end
mod:RegisterTempEvent("AREA_POIS_UPDATED")
end
-----------------------------------
function mod:AREA_POIS_UPDATED()
-----------------------------------
local pois = GetAreaPOIForMap(curMapID)
for i = 1, #pois do
local tbl = GetAreaPOIInfo(curMapID, pois[i])
local name, icon = tbl.name, tbl.textureIndex
if landmarkCache[name] ~= icon then
landmarkCache[name] = icon
if iconDataConflict[icon] then
self:StartBar(name, capTime, GetIconData(icon), iconDataConflict[icon])
if icon == 137 or icon == 139 then -- Workshop in IoC
self:StopBar((GetSpellInfo(56661))) -- Build Siege Engine
end
else
self:StopBar(name)
if icon == 136 or icon == 138 then -- Workshop in IoC
self:StartBar((GetSpellInfo(56661)), 181, 252187, icon == 136 and "colorAlliance" or "colorHorde") -- Build Siege Engine, 252187 = ability_vehicle_siegeengineram
elseif icon == 2 or icon == 3 then
local _, _, _, id = UnitPosition("player")
if id == 30 then -- Alterac Valley
local bar = self:StartBar(name, 3600, GetIconData(icon), icon == 3 and "colorAlliance" or "colorHorde") -- Paused bar for mine status
bar:Pause()
bar:SetTimeVisibility(false)
end
end
end
end
end
end
end
-- initialize or update a final score estimation bar (AB and EotS uses this)
local NewEstimator
do
local allianceWidget, hordeWidget, prevTime, updateBases, hordeWinning = 0, 0, 0, false, false
local update = function() updateBases = true end
local MaxScore, prevText = 1500, ""
local ppsTable
function mod:ScorePredictor()
local t = GetTime()
-- Conditions:
-- 1) Amount of owned bases changed
-- 2) Two updates happened in a short space of time and we want the data from the 2nd update (latest score info)
-- This happens when both teams have bases, the first update (alliance) will be incomplete, the second update (horde) will give us a complete outlook of final scores
if updateBases or (t - prevTime) < 0.8 then
prevTime = t
local ascore, abases = 0, 0
do
local dataTbl = GetIconAndTextWidgetVisualizationInfo(allianceWidget)
local base, score = strmatch(dataTbl.text, "^[^%d]+(%d)[^%d]+(%d+)[^%d]+%d+$") -- Bases: %d Resources: %d/%d
local ABases, AScore = tonumber(base), tonumber(score)
if ABases and AScore then
abases = ABases
ascore = AScore
end
end
local hscore, hbases = 0, 0
do
local dataTbl = GetIconAndTextWidgetVisualizationInfo(hordeWidget)
local base, score = strmatch(dataTbl.text, "^[^%d]+(%d)[^%d]+(%d+)[^%d]+%d+$") -- Bases: %d Resources: %d/%d
local HBases, HScore = tonumber(base), tonumber(score)
if HBases and HScore then
hbases = HBases
hscore = HScore
end
end
local apps, hpps = ppsTable[abases], ppsTable[hbases]
-- timeTilFinal = ((remainingScore) / scorePerSec) - (timeSinceLastUpdate)
local ATime = apps and ((MaxScore - ascore) / apps) or 1000000
local HTime = hpps and ((MaxScore - hscore) / hpps) or 1000000
if HTime < ATime then -- Horde is winning
updateBases = false
local score = apps and (ascore + ceil(apps * HTime)) or ascore
local txt = format(L.finalScore, score, MaxScore)
if txt ~= prevText or not hordeWinning then
hordeWinning = true
self:StopBar(prevText)
self:StartBar(txt, HTime, 132485, "colorHorde") -- 132485 = Interface/Icons/INV_BannerPVP_01
prevText = txt
end
elseif ATime < HTime then -- Alliance is winning
updateBases = false
local score = hpps and (hscore + ceil(hpps * ATime)) or hscore
local txt = format(L.finalScore, MaxScore, score)
if txt ~= prevText or hordeWinning then
hordeWinning = false
self:StopBar(prevText)
self:StartBar(txt, ATime, 132486, "colorAlliance") -- 132486 = Interface/Icons/INV_BannerPVP_02
prevText = txt
end
end
end
end
NewEstimator = function(pointsPerSecond, aW, hW) -- resets estimator and sets new battleground
allianceWidget, hordeWidget = aW, hW
ppsTable = pointsPerSecond
updateBases = false
prevText = ""
C_Timer.After(2, update) -- Delay the first update so we don't get bad data
mod:RegisterTempEvent("UPDATE_UI_WIDGET", "ScorePredictor")
end
function mod:UpdateBases()
C_Timer.After(1, update) -- Delay the first update so we don't get bad data
end
end
do
------------------------------------------------ Arathi Basin -----------------------------------------------------
local pointsPerSecond = {1, 1.5, 2, 3.5, 30} -- Updates every 2 seconds
local function ArathiBasin(self)
SetupAssault(60, 93)
NewEstimator(pointsPerSecond, 495, 496) -- BG table, alliance score widget, horde score widget
self:RegisterTempEvent("CHAT_MSG_BG_SYSTEM_HORDE", "UpdateBases")
self:RegisterTempEvent("CHAT_MSG_BG_SYSTEM_ALLIANCE", "UpdateBases")
end
mod:AddBG(529, ArathiBasin)
local function ArathiBasinSnowyPvPBrawl(self)
SetupAssault(60, 837)
NewEstimator(pointsPerSecond, 914, 915) -- BG table, alliance score widget, horde score widget
self:RegisterTempEvent("CHAT_MSG_BG_SYSTEM_HORDE", "UpdateBases")
self:RegisterTempEvent("CHAT_MSG_BG_SYSTEM_ALLIANCE", "UpdateBases")
end
mod:AddBG(1681, ArathiBasinSnowyPvPBrawl)
end
do
------------------------------------------------ Deepwind Gorge -----------------------------------------------------
local pointsPerSecond = {1.6, 3.2, 6.4} -- Updates every 5 seconds
local function DeepwindGorge(self)
SetupAssault(61, 519)
NewEstimator(pointsPerSecond, 734, 735) -- BG table, alliance score widget, horde score widget
self:RegisterTempEvent("CHAT_MSG_BG_SYSTEM_HORDE", "UpdateBases")
self:RegisterTempEvent("CHAT_MSG_BG_SYSTEM_ALLIANCE", "UpdateBases")
end
mod:AddBG(1105, DeepwindGorge)
end
do
------------------------------------------------ Gilneas -----------------------------------------------------
local pointsPerSecond = {1, 3, 30} -- Updates every 1 second
local function TheBattleForGilneas(self)
SetupAssault(60, 275) -- Base cap time, uiMapID
NewEstimator(pointsPerSecond, 699, 700) -- BG table, alliance score widget, horde score widget
self:RegisterTempEvent("CHAT_MSG_BG_SYSTEM_HORDE", "UpdateBases")
self:RegisterTempEvent("CHAT_MSG_BG_SYSTEM_ALLIANCE", "UpdateBases")
end
mod:AddBG(761, TheBattleForGilneas) -- Instance ID
end
do
------------------------------------------------ Alterac Valley ---------------------------------------------------
local function AlteracValley(self)
function mod:AVTurnIn()
local target = UnitGUID("npc")
if target then
local _, _, _, _, _, id = strsplit("-", target)
local mobId = tonumber(id)
if mobId == 13176 or mobId == 13257 then -- Smith Regzar, Murgot Deepforge
-- Open Quest to Smith or Murgot
if GetGossipOptions() and strmatch(GetGossipOptions(), L.upgradeToTrigger) then
SelectGossipOption(1)
elseif GetItemCount(17422) >= 20 then -- Armor Scraps 17422
SelectGossipAvailableQuest(1)
end
elseif mobId == 13617 or mobId == 13616 then -- Stormpike Stable Master, Frostwolf Stable Master
if GetGossipOptions() then
SelectGossipOption(1)
end
elseif mobId == 13236 then -- Primalist Thurloga
local num = GetItemCount(17306) -- Stormpike Soldier's Blood 17306
if num >= 5 then
SelectGossipAvailableQuest(2)
elseif num > 0 then
SelectGossipAvailableQuest(1)
end
elseif mobId == 13442 then -- Arch Druid Renferal
local num = GetItemCount(17423) -- Storm Crystal 17423
if num >= 5 then
SelectGossipAvailableQuest(2)
elseif num > 0 then
SelectGossipAvailableQuest(1)
end
elseif mobId == 13577 then -- Stormpike Ram Rider Commander
if GetItemCount(17643) > 0 then -- Frost Wolf Hide 17643
SelectGossipAvailableQuest(1)
end
elseif mobId == 13441 then -- Frostwolf Wolf Rider Commander
if GetItemCount(17642) > 0 then -- Alterac Ram Hide 17642
SelectGossipAvailableQuest(1)
end
end
end
end
function mod:AVTurnInProgress()
self:AVTurnIn()
if IsQuestCompletable() then
CompleteQuest()
end
end
function mod:AVTurnInComplete()
GetQuestReward(0)
end
SetupAssault(242, 91)
self:RegisterTempEvent("GOSSIP_SHOW", "AVTurnIn")
self:RegisterTempEvent("QUEST_PROGRESS", "AVTurnInProgress")
self:RegisterTempEvent("QUEST_COMPLETE", "AVTurnInComplete")
end
mod:AddBG(30, AlteracValley)
end
do
------------------------------------------------ Eye of the Storm -------------------------------------------------
local pointsPerSecond = {1, 1.5, 2, 3.5} -- Updates every 2 seconds
local function EyeOfTheStorm(self)
if not mod.FlagUpdate then
function mod:FlagUpdate(msg)
local found = strmatch(msg, L.takenTheFlagTrigger)
if (found and found == "L'Alliance") or strmatch(msg, L.capturedTheTrigger) then -- frFR
self:StartBar(L.flagRespawns, 21, GetIconData(45), "colorOther") -- 45 = White flag
end
self:UpdateBases()
end
-- EotS PvP Brawl: Gravity Lapse
local ticker1, ticker2 = nil, nil
local extraMsg = nil
local color = {r=0,g=1,b=0}
local function PrintExtraMessage()
local _, _, _, _, _, _, _, id = GetInstanceInfo()
if extraMsg and id == 566 then -- Check the game isn't over
RaidNotice_AddMessage(RaidBossEmoteFrame, extraMsg, color, 3)
end
end
local function StartNextGravTimer()
local _, _, _, _, _, _, _, id = GetInstanceInfo()
if id == 566 then -- Check the game isn't over
local name = GetSpellInfo(44224) -- Gravity Lapse
local icon = GetSpellTexture(44224)
self:StartBar(name, 55, icon, "colorOther")
ticker1 = C_Timer.NewTicker(55, StartNextGravTimer, 1) -- Compensate for being dead (you don't get the message)
ticker2 = C_Timer.NewTicker(50, PrintExtraMessage, 1)
end
end
function mod:CheckForGravity(msg)
if msg:find("15", nil, true) then
if not extraMsg then
extraMsg = msg:gsub("1", "")
end
local name = GetSpellInfo(44224) -- Gravity Lapse
local icon = GetSpellTexture(44224)
self:StartBar(name, 15, icon, "colorOther")
C_Timer.After(15, StartNextGravTimer)
C_Timer.After(10, PrintExtraMessage)
if ticker1 then
ticker1:Cancel()
ticker2:Cancel()
ticker1, ticker2 = nil, nil
end
end
end
end
-- setup for final score estimation (2 for EotS)
NewEstimator(pointsPerSecond, 523, 524) -- BG table, alliance score widget, horde score widget
self:RegisterTempEvent("CHAT_MSG_BG_SYSTEM_HORDE", "FlagUpdate")
self:RegisterTempEvent("CHAT_MSG_BG_SYSTEM_ALLIANCE", "FlagUpdate")
self:RegisterTempEvent("RAID_BOSS_WHISPER", "CheckForGravity")
end
local function EyeOfTheStormRated(self)
if not mod.FlagUpdate then
function mod:FlagUpdate(msg)
local found = strmatch(msg, L.takenTheFlagTrigger)
if (found and found == "L'Alliance") or strmatch(msg, L.capturedTheTrigger) then -- frFR
self:StartBar(L.flagRespawns, 21, GetIconData(45), "colorOther") -- 45 = White flag
end
self:UpdateBases()
end
end
NewEstimator(pointsPerSecond, 704, 705) -- BG table, alliance score widget, horde score widget
SetupAssault(60, 397) -- In RBG the four points have flags that need to be assaulted, like AB
self:RegisterTempEvent("CHAT_MSG_BG_SYSTEM_HORDE", "FlagUpdate")
self:RegisterTempEvent("CHAT_MSG_BG_SYSTEM_ALLIANCE", "FlagUpdate")
self:RegisterTempEvent("RAID_BOSS_WHISPER", "CheckForGravity")
end
mod:AddBG(566, EyeOfTheStorm)
mod:AddBG(968, EyeOfTheStormRated)
end
do
------------------------------------------------ Isle of Conquest --------------------------------------
local function IsleOfConquest()
SetupAssault(61, 169)
end
mod:AddBG(628, IsleOfConquest)
end
do
------------------------------------------------ Warsong Gulch ----------------------------------------------------
local function WarsongGulch(self)
if not self.WSGFlagCarrier then -- init some data and create carrier frames
--------------------------------------------
function mod:WSGFlagCarrier(a1) -- carrier detection and setup
--------------------------------------------
if strmatch(a1, L.capturedTheTrigger) then -- flag was captured
self:StartBar(L.flagRespawns, 12, GetIconData(45), "colorOther") -- White flag
end
end
-------------------------
function mod:WSGGetTimeRemaining()
-------------------------
local tbl = GetIconAndTextWidgetVisualizationInfo(6) or GetIconAndTextWidgetVisualizationInfo(630) -- WSG or Twin Peaks
if tbl and tbl.state == 1 then
local minutes, seconds = strmatch(tbl.text, "(%d+):(%d+)")
minutes = tonumber(minutes)
seconds = tonumber(seconds)
if minutes and seconds then
local remaining = seconds + (minutes*60) + 1
local text = gsub(TIME_REMAINING, ":", "")
local bar = self:GetBar(text)
if remaining > 3 and (not bar or bar.remaining > remaining+5 or bar.remaining < remaining-5) then -- Don't restart bars for subtle changes +/- 5s
self:StartBar(text, remaining, 134420, "colorOther") -- Interface/Icons/INV_Misc_Rune_07
end
end
end
end
end
self:RegisterTempEvent("CHAT_MSG_BG_SYSTEM_HORDE", "WSGFlagCarrier")
self:RegisterTempEvent("CHAT_MSG_BG_SYSTEM_ALLIANCE", "WSGFlagCarrier")
local func = function() self:WSGGetTimeRemaining() end
C_Timer.After(5, func)
C_Timer.After(30, func)
C_Timer.After(60, func)
C_Timer.After(130, func)
C_Timer.After(240, func)
end
mod:AddBG(489, WarsongGulch)
mod:AddBG(726, WarsongGulch) -- Twin Peaks
end
do
------------------------------------------------ Wintergrasp ------------------------------------------
local wallid, walls = nil, nil
local function Wintergrasp(self)
if not self.WinterAssault then
wallid = { -- wall section locations
[2222] = "NW ", [2223] = "NW ", [2224] = "NW ", [2225] = "NW ",
[2226] = "SW ", [2227] = "SW ", [2228] = "S ",
[2230] = "S ", [2231] = "SE ", [2232] = "SE ",
[2233] = "NE ", [2234] = "NE ", [2235] = "NE ", [2236] = "NE ",
[2237] = "Inner W ", [2238] = "Inner W ", [2239] = "Inner W ",
[2240] = "Inner S ", [2241] = "Inner S ", [2242] = "Inner S ",
[2243] = "Inner E ", [2244] = "Inner E ", [2245] = "Inner E ",
[2229] = "", [2246] = "", -- front gate and fortress door
}
-- POI icon texture id
local intact = { [77] = true, [80] = true, [86] = true, [89] = true, [95] = true, [98] = true, }
local damaged, destroyed, all = { }, { }, { }
for k in pairs(intact) do
damaged[k + 1] = true
destroyed[k + 2] = true
all[k], all[k + 1], all[k + 2] = true, true, true
end
function mod:WinterAssault() -- scans POI landmarks for changes in wall textures
local pois = GetAreaPOIForMap(123) -- Wintergrasp
for i = 1, #pois do
local POI = pois[i]
local tbl = GetAreaPOIInfo(123, POI)
local ti = walls[POI]
local textureIndex = tbl.textureIndex
if tbl and ((ti and ti ~= textureIndex) or (not ti and wallid[POI])) then
if intact[ti] and damaged[textureIndex] then -- intact before, damaged now
RaidWarningFrame_OnEvent(RaidBossEmoteFrame, "CHAT_MSG_RAID_WARNING", format("%s%s %s!", wallid[POI], tbl.name, ACTION_ENVIRONMENTAL_DAMAGE))
elseif damaged[ti] and destroyed[textureIndex] then -- damaged before, destroyed now
RaidWarningFrame_OnEvent(RaidBossEmoteFrame, "CHAT_MSG_RAID_WARNING", format("%s%s %s!", wallid[POI], tbl.name, ACTION_UNIT_DESTROYED))
end
walls[POI] = all[textureIndex] and textureIndex or ti
end
end
end
end
walls = { }
local pois = GetAreaPOIForMap(123) -- Wintergrasp
for i = 1, #pois do
local POI = pois[i]
local tbl = GetAreaPOIInfo(123, POI)
if wallid[POI] and tbl.textureIndex then
walls[POI] = tbl.textureIndex
end
end
self:RegisterTempEvent("AREA_POIS_UPDATED", "WinterAssault")
end
mod:AddBG(-123, Wintergrasp) -- map id
end
--do
-- ------------------------------------------------ Ashran ------------------------------------------
-- local function Ashran(self)
-- if not self.AshranControl then
-- function mod:AshranControl(msg)
-- --print(msg, ...)
-- --Ashran Herald yells: The Horde controls the Market Graveyard for 15 minutes!
-- local faction, point, timeString = strmatch(msg, "The (.+) controls the (.+) for (%d+) minutes!")
-- local timeLeft = tonumber(timeString)
-- if faction and point and timeLeft then
-- self:StartBar(point, timeLeft*60, GetIconData(faction == "Horde" and 14 or 4), faction == "Horde" and "colorHorde" or "colorAlliance")
-- end
-- end
-- end
-- if not self.AshranEvents then
-- function mod:AshranEvents(msg)
-- local idString = strmatch(msg, "spell:(%d+)")
-- local id = tonumber(idString)
-- --print(msg:gsub("|", "||"), ...)
-- if id and id ~= 168506 then -- 168506 = Ancient Artifact
-- local name, _, icon = GetSpellInfo(id)
-- self:StartBar(name, 180, icon, "colorOther")
-- end
-- end
-- end
-- if not self.AshranTimeLeft then
-- function mod:AshranTimeLeft()
-- local _, _, _, timeString = GetWorldStateUIInfo(12)
-- if timeString then
-- local minutes, seconds = strmatch(timeString, "(%d+):(%d+)")
-- minutes = tonumber(minutes)
-- seconds = tonumber(seconds)
-- if minutes and seconds then
-- local remaining = seconds + (minutes*60) + 1
-- if remaining > 4 then
-- local text = NEXT_BATTLE_LABEL
-- local bar = self:GetBar(text)
-- if not bar or remaining > bar.remaining+5 or remaining < bar.remaining-5 then -- Don't restart bars for subtle changes +/- 5s
-- self:StartBar(text, remaining, 1031537, "colorOther") -- Interface/Icons/Achievement_Zone_Ashran
-- end
-- end
-- end
-- end
-- end
-- end
-- self:RegisterTempEvent("CHAT_MSG_MONSTER_YELL", "AshranControl")
-- self:RegisterTempEvent("CHAT_MSG_MONSTER_EMOTE", "AshranEvents")
-- self:RegisterTempEvent("WORLD_STATE_UI_TIMER_UPDATE", "AshranTimeLeft")
-- end
-- mod:AddBG(X, Ashran) -- map id
--end
do
------------------------------------------------ Arena ------------------------------------------
local function Arena(self)
-- What we CAN'T use for Shadow Sight timer
-- COMBAT_LOG_EVENT_UNFILTERED for Arena Preparation removal event, it randomly removes and reapplies itself during the warmup
-- UPDATE_WORLD_STATES will sometimes fire during the warmup, so we can't assume the first time it fires is the doors opening
-- UNIT_SPELLCAST_SUCCEEDED arena1-5 events, probably won't work if the entire enemy team is stealth
-- What we CAN use for Shadow Sight timer
-- CHAT_MSG_BG_SYSTEM_NEUTRAL#The Arena battle has begun! - Requires localization
-- WORLD_STATE_UI_TIMER_UPDATE The first event fired with a valid remaining time (the current chosen method)
if not self.ArenaTimers then
function mod:ArenaTimers(tbl)
if tbl.widgetSetID == 1 and tbl.widgetType == 0 then
local id = tbl.widgetID
local dataTbl = GetIconAndTextWidgetVisualizationInfo(id)
if dataTbl and dataTbl.text and dataTbl.state == 1 then
local minutes, seconds = dataTbl.text:match("(%d+):(%d+)")
minutes = tonumber(minutes)
seconds = tonumber(seconds)
if minutes and seconds then
local remaining = seconds + (minutes*60) + 1
if remaining > 4 then
self:UnregisterEvent("UPDATE_UI_WIDGET")
local spell, _, icon = GetSpellInfo(34709)
self:StartBar(spell, 93, icon, "colorOther")
local text = gsub(TIME_REMAINING, ":", "")
self:StartBar(text, remaining, nil, "colorOther")
end
end
end
end
end
end
self:RegisterTempEvent("UPDATE_UI_WIDGET", "ArenaTimers")
end
mod:AddBG(572, Arena) -- Ruins of Lordaeron
mod:AddBG(617, Arena) -- Dalaran Sewers
mod:AddBG(980, Arena) -- Tol'Viron Arena
mod:AddBG(1134, Arena) -- The Tiger's Peak
mod:AddBG(1504, Arena) -- Black Rook Hold Arena
mod:AddBG(1505, Arena) -- Nagrand Arena
mod:AddBG(1552, Arena) -- Ashamane's Fall
mod:AddBG(1672, Arena) -- Blade's Edge Arena
mod:AddBG(1825, Arena) -- Hook Point
end