-
Notifications
You must be signed in to change notification settings - Fork 0
/
ReadyForTheFight.lua
551 lines (521 loc) · 16 KB
/
ReadyForTheFight.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
local addonName, addon = ...
ReadyForTheFight = {Locals = {}}
local L = ReadyForTheFight.Locals
ReadyForTheFight.Boss_location = {
["Mogu'shan Vaults"] = {
["The Stone Guard"] = {
["subzone"] = "The Golden Hall",
["id"] = 1,
},
["Feng the Accursed"] = {
["subzone"] = "Dais of Conquerors",
["id"] = 2,
},
["Gara'jal the Spiritbinder"] = {
["subzone"] = "Emperor's Reach",
["id"] = 3,
},
["The Spirit Kings"] = {
["subzone"] = "The Repository",
["id"] = 4,
},
["Elegon"] = {
["subzone"] = "Engine of Nalak'sha",
["id"] = 5,
},
["Will of the Emperor"] = {
["subzone"] = "Forge of the Endless",
["id"] = 6,
}
},
["Heart of Fear"] = {
["Imperial Vizier Zor'lok"] = {
["subzone"] = "Oratorium of the Voice",
["id"] = 1,
},
["Blade Lord Ta'yak"] = {
["subzone"] = "Training Quarters",
["id"] = 2,
},
["Garalon"] = {
["subzone"] = "Dread Terrace",
["id"] = 3,
},
["Wind Lord Mel'jarak"] = {
["subzone"] = "Staging Balcony",
["id"] = 4,
},
["Amber-Shaper Un'sok"] = {
["subzone"] = "Amber Research Sanctum",
["id"] = 5,
},
["Grand Empress Shek'zeer"] = {
["coordX"] = 0.289,
["coordY"] = 0.738,
["dist"] = 0.06,
["maplevel"] = 2,
["id"] = 6,
},
},
["Terrace of Endless Spring"] = {
["Protectors of the Endless"] = {
["coordX"] = 0.785,
["coordY"] = 0.487,
["dist"] = 0.1,
["maplevel"] = 0,
["id"] = 1,
},
["Tsulong"] = {
["coordX"] = 0.785,
["coordY"] = 0.487,
["dist"] = 0.1,
["maplevel"] = 0,
["id"] = 2,
["needkilledid"] = 1,
},
["Lei Shi"] = {
["coordX"] = 0.588,
["coordY"] = 0.487,
["dist"] = 0.07,
["maplevel"] = 0,
["id"] = 3,
},
["Sha of Fear"] = {
["coordX"] = 0.39,
["coordY"] = 0.487,
["dist"] = 0.1,
["maplevel"] = 0,
["id"] = 4,
},
},
["Throne of Thunder"] = {
["Jin'rokh the Breaker"] = {
["subzone"] = "Overgrown Statuary",
["id"] = 1,
},
["Horridon"] = {
["subzone"] = "Royal Amphitheater",
["id"] = 2,
},
["Council of Elders"] = {
["subzone"] = "Lightning Promenade",
["id"] = 3,
},
["Tortos"] = {
["subzone"] = "Lair of Tortos",
["id"] = 4,
},
["Magaera"] = {
["subzone"] = "Forgotten Depths",
["id"] = 5,
},
["Ji-Kun"] = {
["subzone"] = "Roost of Ji-Kun",
["id"] = 6,
},
["Durumu the Forgotten"] = {
["subzone"] = "Watcher's Sanctum",
["id"] = 7,
},
["Primordius"] = {
["subzone"] = "Saurok Creation Pit",
["id"] = 8,
},
["Dark Animus"] = {
["subzone"] = "Halls of Flesh-Shaping",
["id"] = 9,
},
["Iron Qon"] = {
["subzone"] = "Grand Courtyard",
["id"] = 10,
},
["Twin Consorts"] = {
["subzone"] = "Celestial Enclave",
["id"] = 11,
},
["Lei Shen"] = {
["subzone"] = "Pinnacle of Storms",
["id"] = 12,
},
["Ra-den"] = {
["subzone"] = "Hidden Cell",
["id"] = 12,
},
}
}
ReadyForTheFight.Wrong_equiped_item = { -- [itemID] = InventorySlotId
[32757] = 2, -- Blessed Medallion of Karabor
[51558] = 11, -- Runed Loop of the Kirin Tor
[51559] = 11, -- Runed Ring of the Kirin Tor
[51560] = 11, -- Runed Band of the Kirin Tor
[51557] = 11, -- Runed Signet of the Kirin Tor
[48954] = 11, -- Etched Band of the Kirin Tor
[48955] = 11, -- Etched Loop of the Kirin Tor
[48956] = 11, -- Etched Ring of the Kirin Tor
[48957] = 11, -- Etched Signet of the Kirin Tor
[45688] = 11, -- Inscribed Band of the Kirin Tor
[45689] = 11, -- Inscribed Loop of the Kirin Tor
[45690] = 11, -- Inscribed Ring of the Kirin Tor
[45691] = 11, -- Inscribed Signet of the Kirin Tor
[40585] = 11, -- Signet of the Kirin Tor
[40586] = 11, -- Band of the Kirin Tor
[44934] = 11, -- Loop of the Kirin Tor
[44935] = 11, -- Ring of the Kirin Tor
[63352] = 15, -- Shroud of Cooperation
[63206] = 15, -- Wrap of Unity
[65360] = 15, -- Cloak of Coordination
[63353] = 15, -- Shroud of Cooperation
[63207] = 15, -- Wrap of Unity
[65274] = 15, -- Cloak of Coordination
[50287] = 8, -- Boots of the Bay
[28585] = 8, -- Ruby Slippers
[22630] = 16, -- Atiesh, Greatstaff of the Guardian
[22631] = 16, -- Atiesh, Greatstaff of the Guardian
[22632] = 16, -- Atiesh, Greatstaff of the Guardian
[22589] = 16, -- Atiesh, Greatstaff of the Guardian
[92738] = 1, -- Safari Hat
}
ReadyForTheFight.alertMsg = {};
ReadyForTheFight.ConfigPanel = nil;
ReadyForTheFight.bossDetected = nil;
ReadyForTheFight.zoneDetected = nil;
local coordupdateregistered = false;
local bossfound,zonename = nil;
local totalseconds = 0;
local frame, events = CreateFrame("Button", "RftFFrame", UIParent), {};
local update_need = false; -- ha true, akkor valtozott a helyszin es ujraellenorzes szukseges (combat eseten fordulhat elo)
function ReadyForTheFight:dbg (msg)
if (ReadyForTheFight.debugmode) then
print (msg);
end
end
function ReadyForTheFight:addtooltip (msg)
table.insert (ReadyForTheFight.alertMsg, msg)
end
function ReadyForTheFight:HaveGlyph(glyph)
local i, j, _, enabled, name, glyphID, glyphID2;
for i = 1, NUM_GLYPH_SLOTS do
enabled, _, _, _, _, glyphID = GetGlyphSocketInfo(i);
if ( enabled ) then
for j = 1, GetNumGlyphs() do
name, _, _, _, glyphID2 = GetGlyphInfo(j)
if (name == glyph and glyphID2 == glyphID) then
return true;
end
end
end
end
return false;
end
function ReadyForTheFight:HaveTalent(talent)
local i, _, name, selected;
local activeTalentGroup = GetActiveSpecGroup() or 1;
for i=1, GetNumTalents() do
name, _, _, _, selected = GetTalentInfo(i,false,activeTalentGroup);
if selected then
if (name == talent) then
return true;
end
end
end
return false;
end
function ReadyForTheFight:CheckTheBoss(zonename,bossfound)
local vanhiba = false;
if ((zonename ~= nil) and (bossfound ~= nil)) then
local bosssetup = nil
if (RftFDB[zonename]) then
if (RftFDB[zonename][bossfound]) then
bosssetup = RftFDB[zonename][bossfound]
else
bosssetup = RftFDB["Default"]
end
else
bosssetup = RftFDB["Default"]
end
if GetSpecialization(false, false, GetActiveSpecGroup() ) then
local spec = select(2, GetSpecializationInfo(GetSpecialization(false, false, GetActiveSpecGroup())));
if (bosssetup[spec]) then
if (bosssetup[spec]["default"] == true) then
bosssetup = RftFDB["Default"]
end
end
if (bosssetup[spec]) then
if (bosssetup[spec]["glyph"]) then
for k,v in pairs(bosssetup[spec]["glyph"]) do
if (v and not ReadyForTheFight:HaveGlyph(k)) then
ReadyForTheFight:dbg("Missing glyph: |cffFFD100"..k);
ReadyForTheFight:addtooltip("Missing glyph: |cffFFD100"..k)
vanhiba = true
end
end
end
if (bosssetup[spec]["talent"]) then
for k,v in pairs(bosssetup[spec]["talent"]) do
if (v and not ReadyForTheFight:HaveTalent(k)) then
ReadyForTheFight:dbg("Missing talent: |cffFFD100"..k);
ReadyForTheFight:addtooltip("Missing talent: |cffFFD100"..k)
vanhiba = true
end
end
end
end
end
end
ReadyForTheFight.bossDetected = bossfound;
ReadyForTheFight.zoneDetected = zonename;
return(vanhiba)
end
function ReadyForTheFight:DoYouEquipSomethingWrong()
if (UnitIsDead("player")==1) then
return false
end
local vanhiba = false
local k, v, itemName, itemLink
for k,v in pairs(ReadyForTheFight.Wrong_equiped_item) do
if ((v==11 or v==12) and GetInventoryItemID("player", 11)==k or GetInventoryItemID("player", 12)==k) or GetInventoryItemID("player", v)==k then
vanhiba = true
itemName, itemLink = GetItemInfo(k)
ReadyForTheFight:addtooltip("Item equipped: "..itemLink)
end
end
return vanhiba
end
function ReadyForTheFight:DoYouNeedBuff()
if (UnitIsDead("player")==1 or not ReadyForTheFight.CheckBuffs) then
return false
end
local bStats, bStam, bAP, bAS, bSP, bSH, bCrit, bMas = false
local vanhiba = false
for i=1,40 do
local sid=select(11,UnitAura("player",i))
if (sid==90363 or sid==117667 or sid==1126 or sid==20217 or sid==115921) then
bStats=true
end
if (sid==90364 or sid==469 or sid==6307 or sid==21562) then
bStam=true
end
if (sid==19506 or sid==6673 or sid==57330) then
bAP=true
end
if (sid==128432 or sid==128433 or sid==30809 or sid==113742 or sid==55610) then
bAS=true
end
if (sid==126309 or sid==77747 or sid==109773 or sid==61316 or sid==1459) then
bSP=true
end
if (sid==24907 or sid==51470 or sid==49868 or sid==135678) then
bSH=true
end
if (sid==126309 or sid==24604 or sid==90309 or sid==126373 or sid==1459 or sid==61316 or sid==24932 or sid==116781) then
bCrit=true
end
if (sid==93435 or sid==128997 or sid==116956 or sid==19740) then
bMas=true
end
end
if not bStats then
ReadyForTheFight:addtooltip("Missing buff: |cffFFD100Stats")
vanhiba = true
end
if not bStam then
ReadyForTheFight:addtooltip("Missing buff: |cffFFD100Stamina")
vanhiba = true
end
if not bAP then
ReadyForTheFight:addtooltip("Missing buff: |cffFFD100Attack Power")
vanhiba = true
end
if not bAS then
ReadyForTheFight:addtooltip("Missing buff: |cffFFD100Attack Speed")
vanhiba = true
end
if not bSP then
ReadyForTheFight:addtooltip("Missing buff: |cffFFD100Spell Power")
vanhiba = true
end
if not bSH then
ReadyForTheFight:addtooltip("Missing buff: |cffFFD100Spell Haste")
vanhiba = true
end
if not bCrit then
ReadyForTheFight:addtooltip("Missing buff: |cffFFD100Critical Strike")
vanhiba = true
end
if not bMas then
ReadyForTheFight:addtooltip("Missing buff: |cffFFD100Mastery")
vanhiba = true
end
return vanhiba
end
function ReadyForTheFight:IsBossAlive(zone, boss_id)
local i, _,name, locked, numEncounters, isKilled;
for i=1,GetNumSavedInstances() do
name, _, _, _, locked, _, _, _, _, _, numEncounters = GetSavedInstanceInfo(i);
if (locked) and (name == zone) then
return not select(3, GetSavedInstanceEncounterInfo(i,boss_id))
end
end
return true
end
function updatezoneinfo ()
if (not InCombatLockdown()) then -- ha nincs combat, akkor mehet az ellenorzes
zonename = GetRealZoneText();
subzone = GetSubZoneText();
ReadyForTheFight.alertMsg = {};
if ((subzone == "") or (subzone == nil)) then
subzone = zonename;
end
if (zonename ~= nil) then
ReadyForTheFight:dbg("RealZone: ".. zonename);
end
if (subzone ~= nil) then
ReadyForTheFight:dbg("SubZone: ".. subzone);
end
if ((zonename ~= nil) and (subzone ~= nil)) then -- van zonainfo
if (ReadyForTheFight.Boss_location[zonename]) then -- a zona a boss helyszinek kozott is
if (not coordupdateregistered) then
coordupdateregistered = true;
end
local bossfound = false
local vanhiba = false
for k,v in pairs(ReadyForTheFight.Boss_location[zonename]) do
if (ReadyForTheFight.Boss_location[zonename][k]["subzone"] ~= nil) then -- a bossnak van subzone-ja
if (subzone == ReadyForTheFight.Boss_location[zonename][k]["subzone"]) then -- megvan a boss neve
bossfound = k;
ReadyForTheFight:dbg("Boss in this zone: |cffFFD100".. bossfound);
end
else -- nincs subzone
if (ReadyForTheFight.Boss_location[zonename][k]["coordX"] ~= nil) then -- a bossnak van koordinataja
SetMapToCurrentZone();
local posX, posY = GetPlayerMapPosition("player");
if ((math.abs(ReadyForTheFight.Boss_location[zonename][k]["coordX"]-posX) <= ReadyForTheFight.Boss_location[zonename][k]["dist"]) and (math.abs(ReadyForTheFight.Boss_location[zonename][k]["coordY"]-posY) <= ReadyForTheFight.Boss_location[zonename][k]["dist"]) and (select(1, GetCurrentMapDungeonLevel()) == ReadyForTheFight.Boss_location[zonename][k]["maplevel"])) then
ReadyForTheFight:dbg("Boss in distance: |cffFFD100".. k);
bossfound = k;
end
end
end
if (bossfound) then
if (ReadyForTheFight.Boss_location[zonename][k]["needkilledid"] ~= nil) then -- kell-e masik bosst leolni ehhez a bosshoz
if (ReadyForTheFight:IsBossAlive(zonename,ReadyForTheFight.Boss_location[zonename][k]["needkilledid"])) then
bossfound = false;
ReadyForTheFight:dbg("Boss is not active!");
ReadyForTheFight:addtooltip("Boss is not active!")
end
end
end
if (bossfound) then
bossalive= true;
if (ReadyForTheFight.Boss_location[zonename][bossfound]["id"]) then
bossalive = ReadyForTheFight:IsBossAlive(zonename,ReadyForTheFight.Boss_location[zonename][bossfound]["id"]);
end
if (bossalive) then
ReadyForTheFight:addtooltip("Boss in this zone: |cffFFD100".. bossfound)
ReadyForTheFight:dbg("Boss " .. k .. " is alive!");
vanhiba = ReadyForTheFight:CheckTheBoss(zonename,bossfound)
break;
else
ReadyForTheFight:dbg("Boss " .. k .. " killed!");
if ReadyForTheFight.debugmode then vanhiba = ReadyForTheFight:CheckTheBoss(zonename,bossfound) end
end
end
end
local kellbuff = ReadyForTheFight:DoYouNeedBuff()
local rosszcucc = ReadyForTheFight:DoYouEquipSomethingWrong()
vanhiba = (rosszcucc or vanhiba or kellbuff) and bossfound
if not ReadyForTheFight.debugmode and not vanhiba and ReadyForTheFight.alertFrame:IsVisible() then
ReadyForTheFight.alertFrame:Hide()
end
if vanhiba and not ReadyForTheFight.alertFrame:IsVisible() then
ReadyForTheFight.alertFrame:Show()
end
else
if (coordupdateregistered) then
coordupdateregistered = false;
end
if not ReadyForTheFight.debugmode and ReadyForTheFight.alertFrame:IsVisible() then
ReadyForTheFight.alertFrame:Hide()
end
end
end
-- frissítés megvolt
update_need = false;
else -- combat van, ellenorzes elhalasztva a combat utan
update_need = true;
end
end
function onUpdate(self, secs)
totalseconds = totalseconds + secs;
if coordupdateregistered and totalseconds >= 3 then
ReadyForTheFight:dbg("Timer activated");
updatezoneinfo();
totalseconds = 0;
end
end
function events:ZONE_CHANGED(...)
ReadyForTheFight:dbg("Event: ZONE_CHANGED");
updatezoneinfo();
end
function events:ZONE_CHANGED_INDOORS(...)
ReadyForTheFight:dbg("Event: ZONE_CHANGED_INDOORS");
updatezoneinfo();
end
function events:ZONE_CHANGED_NEW_AREA(...)
ReadyForTheFight:dbg("Event: ZONE_CHANGED_NEW_AREA");
updatezoneinfo();
end
function events:ADDON_LOADED(arg1,...)
if (arg1==addonName) then
ReadyForTheFight:dbg("Event: ADDON_LOADED");
if not RftFDB then
RftFDB = {} -- ures config
end
ReadyForTheFight.debugmode = RftFDB["Debug"]
ReadyForTheFight.CheckBuffs = RftFDB["CheckBuffs"]
if (not RftFDB["AlertFrame"]) then
RftFDB["AlertFrame"] = {};
RftFDB["AlertFrame"]["X"] = 0;
RftFDB["AlertFrame"]["Y"] = 0;
RftFDB["AlertFrame"]["rP"] = "CENTER";
RftFDB["AlertFrame"]["P"] = "CENTER";
end
SlashCmdList["ReadyForTheFight"] = ReadyForTheFight.Options;
SLASH_ReadyForTheFight1 = "/rftf"
ReadyForTheFight:CreateAlert();
updatezoneinfo();
end
end
function events:PLAYER_REGEN_ENABLED(...)
if (update_need) then -- ha combatba volt zona valtas, akkor combat utan frissitunk
ReadyForTheFight:dbg("Update: PLAYER_REGEN_ENABLED");
updatezoneinfo();
end
end
function events:PLAYER_REGEN_DISABLED(...)
if not ReadyForTheFight.debugmode and ReadyForTheFight.alertFrame:IsVisible() then
ReadyForTheFight.alertFrame:Hide()
end
ReadyForTheFight:dbg("Event: PLAYER_REGEN_DISABLED");
end
function events:WORLD_MAP_UPDATE(...)
updatezoneinfo();
end
function events:ACTIVE_TALENT_GROUP_CHANGED(...)
ReadyForTheFight:dbg("Event: ACTIVE_TALENT_GROUP_CHANGED");
updatezoneinfo();
end
function events:PLAYER_ENTERING_WORLD()
ReadyForTheFight:CreateConfig();
end
frame:SetScript("OnUpdate", onUpdate);
frame:SetScript("OnEvent", function(self, event, ...)
events[event](self, ...); -- call one of the functions above
end);
frame:RegisterEvent("PLAYER_ENTERING_WORLD");
frame:RegisterEvent("ZONE_CHANGED");
frame:RegisterEvent("ZONE_CHANGED_INDOORS");
frame:RegisterEvent("ZONE_CHANGED_NEW_AREA");
frame:RegisterEvent("PLAYER_REGEN_DISABLED");
frame:RegisterEvent("PLAYER_REGEN_ENABLED");
frame:RegisterEvent("ADDON_LOADED");
frame:RegisterEvent("ACTIVE_TALENT_GROUP_CHANGED");