-
Notifications
You must be signed in to change notification settings - Fork 1
/
Smash.lua
3954 lines (3699 loc) · 124 KB
/
Smash.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
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
local ADDON = 'Smash'
local ADDON_PATH = 'Interface\\AddOns\\' .. ADDON .. '\\'
BINDING_CATEGORY_SMASH = ADDON
BINDING_NAME_SMASH_TARGETMORE = "Toggle Targets +"
BINDING_NAME_SMASH_TARGETLESS = "Toggle Targets -"
BINDING_NAME_SMASH_TARGET1 = "Set Targets to 1"
BINDING_NAME_SMASH_TARGET2 = "Set Targets to 2"
BINDING_NAME_SMASH_TARGET3 = "Set Targets to 3"
BINDING_NAME_SMASH_TARGET4 = "Set Targets to 4"
BINDING_NAME_SMASH_TARGET5 = "Set Targets to 5+"
local function log(...)
print(ADDON, '-', ...)
end
if select(2, UnitClass('player')) ~= 'WARRIOR' then
log('[|cFFFF0000Error|r]', 'Not loading because you are not the correct class! Consider disabling', ADDON, 'for this character.')
return
end
-- reference heavily accessed global functions from local scope for performance
local min = math.min
local max = math.max
local floor = math.floor
local GetSpellCharges = C_Spell.GetSpellCharges
local GetSpellCooldown = C_Spell.GetSpellCooldown
local GetSpellInfo = C_Spell.GetSpellInfo
local GetItemCount = C_Item.GetItemCount
local GetItemCooldown = C_Item.GetItemCooldown
local GetInventoryItemCooldown = _G.GetInventoryItemCooldown
local GetItemInfo = C_Item.GetItemInfo
local GetTime = _G.GetTime
local GetUnitSpeed = _G.GetUnitSpeed
local IsSpellUsable = C_Spell.IsSpellUsable
local IsItemUsable = C_Item.IsUsableItem
local UnitAttackSpeed = _G.UnitAttackSpeed
local UnitAura = C_UnitAuras.GetAuraDataByIndex
local UnitCastingInfo = _G.UnitCastingInfo
local UnitChannelInfo = _G.UnitChannelInfo
local UnitDetailedThreatSituation = _G.UnitDetailedThreatSituation
local UnitHealth = _G.UnitHealth
local UnitHealthMax = _G.UnitHealthMax
local UnitPower = _G.UnitPower
local UnitPowerMax = _G.UnitPowerMax
local UnitSpellHaste = _G.UnitSpellHaste
-- end reference global functions
-- useful functions
local function between(n, min, max)
return n >= min and n <= max
end
local function clamp(n, min, max)
return (n < min and min) or (n > max and max) or n
end
local function startsWith(str, start) -- case insensitive check to see if a string matches the start of another string
if type(str) ~= 'string' then
return false
end
return string.lower(str:sub(1, start:len())) == start:lower()
end
local function ToUID(guid)
local uid = guid:match('^%w+-%d+-%d+-%d+-%d+-(%d+)')
return uid and tonumber(uid)
end
-- end useful functions
Smash = {}
local Opt -- use this as a local table reference to Smash
SLASH_Smash1, SLASH_Smash2 = '/smash', '/sm'
local function InitOpts()
local function SetDefaults(t, ref)
for k, v in next, ref do
if t[k] == nil then
local pchar
if type(v) == 'boolean' then
pchar = v and 'true' or 'false'
elseif type(v) == 'table' then
pchar = 'table'
else
pchar = v
end
t[k] = v
elseif type(t[k]) == 'table' then
SetDefaults(t[k], v)
end
end
end
SetDefaults(Smash, { -- defaults
locked = false,
snap = false,
scale = {
main = 1,
previous = 0.7,
cooldown = 0.7,
interrupt = 0.4,
extra = 0.4,
glow = 1,
},
glow = {
main = true,
cooldown = true,
interrupt = false,
extra = true,
blizzard = false,
animation = false,
color = { r = 1, g = 1, b = 1 },
},
hide = {
arms = false,
fury = false,
protection = false,
},
alpha = 1,
frequency = 0.2,
previous = true,
always_on = false,
cooldown = true,
spell_swipe = true,
dimmer = true,
miss_effect = true,
boss_only = false,
interrupt = true,
aoe = false,
auto_aoe = false,
auto_aoe_ttl = 10,
cd_ttd = 10,
pot = false,
trinket = true,
heal = 60,
defensives = true,
})
end
-- UI related functions container
local UI = {
anchor = {},
glows = {},
}
-- combat event related functions container
local CombatEvent = {}
-- automatically registered events container
local Events = {}
-- player ability template
local Ability = {}
Ability.__index = Ability
-- classified player abilities
local Abilities = {
all = {},
bySpellId = {},
velocity = {},
autoAoe = {},
tracked = {},
}
-- methods for target tracking / aoe modes
local AutoAoe = {
targets = {},
blacklist = {},
ignored_units = {},
}
-- methods for tracking ticking debuffs on targets
local TrackedAuras = {}
-- timers for updating combat/display/hp info
local Timer = {
combat = 0,
display = 0,
health = 0,
}
-- specialization constants
local SPEC = {
NONE = 0,
ARMS = 1,
FURY = 2,
PROTECTION = 3,
}
-- action priority list container
local APL = {
[SPEC.NONE] = {},
[SPEC.ARMS] = {},
[SPEC.FURY] = {},
[SPEC.PROTECTION] = {},
}
-- current player information
local Player = {
time = 0,
time_diff = 0,
ctime = 0,
combat_start = 0,
level = 1,
spec = 0,
group_size = 1,
target_mode = 0,
gcd = 1.5,
gcd_remains = 0,
execute_remains = 0,
haste_factor = 1,
moving = false,
movement_speed = 100,
health = {
current = 0,
max = 100,
pct = 100,
},
rage = {
current = 0,
deficit = 0,
max = 100,
pct = 0,
},
cast = {
start = 0,
ends = 0,
remains = 0,
},
channel = {
chained = false,
start = 0,
ends = 0,
remains = 0,
tick_count = 0,
tick_interval = 0,
ticks = 0,
ticks_remain = 0,
ticks_extra = 0,
interruptible = false,
early_chainable = false,
},
threat = {
status = 0,
pct = 0,
lead = 0,
},
swing = {
mh = {
last = 0,
speed = 0,
remains = 0,
},
oh = {
last = 0,
speed = 0,
remains = 0,
},
last_taken = 0,
},
set_bonus = {
t33 = 0, -- Warsculptor's Masterwork
},
previous_gcd = {},-- list of previous GCD abilities
item_use_blacklist = { -- list of item IDs with on-use effects we should mark unusable
[190958] = true, -- Soleah's Secret Technique
[193757] = true, -- Ruby Whelp Shell
[202612] = true, -- Screaming Black Dragonscale
[203729] = true, -- Ominous Chromatic Essence
},
main_freecast = false,
}
-- current target information
local Target = {
boss = false,
dummy = false,
health = {
current = 0,
loss_per_sec = 0,
max = 100,
pct = 100,
history = {},
},
hostile = false,
estimated_range = 30,
}
-- target dummy unit IDs (count these units as bosses)
Target.Dummies = {
[189617] = true,
[189632] = true,
[194643] = true,
[194644] = true,
[194648] = true,
[194649] = true,
[197833] = true,
[198594] = true,
[219250] = true,
[225983] = true,
[225984] = true,
[225985] = true,
[225976] = true,
[225977] = true,
[225978] = true,
[225982] = true,
}
-- Start AoE
Player.target_modes = {
[SPEC.NONE] = {
{1, ''}
},
[SPEC.ARMS] = {
{1, ''},
{2, '2'},
{3, '3'},
{4, '4'},
{5, '5+'},
},
[SPEC.FURY] = {
{1, ''},
{2, '2'},
{3, '3'},
{4, '4'},
{5, '5+'},
},
[SPEC.PROTECTION] = {
{1, ''},
{2, '2'},
{3, '3'},
{4, '4+'},
{6, '6+'},
},
}
function Player:SetTargetMode(mode)
if mode == self.target_mode then
return
end
self.target_mode = min(mode, #self.target_modes[self.spec])
self.enemies = self.target_modes[self.spec][self.target_mode][1]
smashPanel.text.br:SetText(self.target_modes[self.spec][self.target_mode][2])
end
function Player:ToggleTargetMode()
local mode = self.target_mode + 1
self:SetTargetMode(mode > #self.target_modes[self.spec] and 1 or mode)
end
function Player:ToggleTargetModeReverse()
local mode = self.target_mode - 1
self:SetTargetMode(mode < 1 and #self.target_modes[self.spec] or mode)
end
-- Target Mode Keybinding Wrappers
function Smash_SetTargetMode(mode)
Player:SetTargetMode(mode)
end
function Smash_ToggleTargetMode()
Player:ToggleTargetMode()
end
function Smash_ToggleTargetModeReverse()
Player:ToggleTargetModeReverse()
end
-- End AoE
-- Start Auto AoE
function AutoAoe:Add(guid, update)
if self.blacklist[guid] then
return
end
local uid = ToUID(guid)
if uid and self.ignored_units[uid] then
self.blacklist[guid] = Player.time + 10
return
end
local new = not self.targets[guid]
self.targets[guid] = Player.time
if update and new then
self:Update()
end
end
function AutoAoe:Remove(guid)
-- blacklist enemies for 2 seconds when they die to prevent out of order events from re-adding them
self.blacklist[guid] = Player.time + 2
if self.targets[guid] then
self.targets[guid] = nil
self:Update()
end
end
function AutoAoe:Clear()
for _, ability in next, Abilities.autoAoe do
ability.auto_aoe.start_time = nil
for guid in next, ability.auto_aoe.targets do
ability.auto_aoe.targets[guid] = nil
end
end
for guid in next, self.targets do
self.targets[guid] = nil
end
self:Update()
end
function AutoAoe:Update()
local count = 0
for i in next, self.targets do
count = count + 1
end
if count <= 1 then
Player:SetTargetMode(1)
return
end
Player.enemies = count
for i = #Player.target_modes[Player.spec], 1, -1 do
if count >= Player.target_modes[Player.spec][i][1] then
Player:SetTargetMode(i)
Player.enemies = count
return
end
end
end
function AutoAoe:Purge()
local update
for guid, t in next, self.targets do
if Player.time - t > Opt.auto_aoe_ttl then
self.targets[guid] = nil
update = true
end
end
-- remove expired blacklisted enemies
for guid, t in next, self.blacklist do
if Player.time > t then
self.blacklist[guid] = nil
end
end
if update then
self:Update()
end
end
-- End Auto AoE
-- Start Abilities
function Ability:Add(spellId, buff, player, spellId2)
local ability = {
spellIds = type(spellId) == 'table' and spellId or { spellId },
spellId = 0,
spellId2 = spellId2,
name = false,
icon = false,
requires_charge = false,
requires_react = false,
triggers_gcd = true,
hasted_duration = false,
hasted_cooldown = false,
hasted_ticks = false,
known = false,
rank = 0,
rage_cost = 0,
rage_gain = 0,
cooldown_duration = 0,
buff_duration = 0,
tick_interval = 0,
max_range = 40,
velocity = 0,
last_gained = 0,
last_used = 0,
aura_target = buff and 'player' or 'target',
aura_filter = (buff and 'HELPFUL' or 'HARMFUL') .. (player and '|PLAYER' or ''),
}
setmetatable(ability, self)
Abilities.all[#Abilities.all + 1] = ability
return ability
end
function Ability:Match(spell)
if type(spell) == 'number' then
return spell == self.spellId or (self.spellId2 and spell == self.spellId2)
elseif type(spell) == 'string' then
return spell:lower() == self.name:lower()
elseif type(spell) == 'table' then
return spell == self
end
return false
end
function Ability:Ready(seconds)
return self:Cooldown() <= (seconds or 0) and (not self.requires_react or self:React() > (seconds or 0))
end
function Ability:Usable(seconds, pool)
if not self.known then
return false
end
if not pool and self:Cost() > Player.rage.current then
return false
end
if self.requires_charge and self:Charges() == 0 then
return false
end
return self:Ready(seconds)
end
function Ability:Remains()
if self:Casting() or self:Traveling() > 0 then
return self:Duration()
end
local aura
for i = 1, 40 do
aura = UnitAura(self.aura_target, i, self.aura_filter)
if not aura then
return 0
elseif self:Match(aura.spellId) then
if aura.expirationTime == 0 then
return 600 -- infinite duration
end
return max(0, aura.expirationTime - Player.ctime - (self.off_gcd and 0 or Player.execute_remains))
end
end
return 0
end
function Ability:React()
return self:Remains()
end
function Ability:Expiring(seconds)
local remains = self:Remains()
return remains > 0 and remains < (seconds or Player.gcd)
end
function Ability:Refreshable()
if self.buff_duration > 0 then
return self:Remains() < self:Duration() * 0.3
end
return self:Down()
end
function Ability:Up(...)
return self:Remains(...) > 0
end
function Ability:Down(...)
return self:Remains(...) <= 0
end
function Ability:SetVelocity(velocity)
if velocity > 0 then
self.velocity = velocity
self.traveling = {}
else
self.traveling = nil
self.velocity = 0
end
end
function Ability:Traveling(all)
if not self.traveling then
return 0
end
local count = 0
for _, cast in next, self.traveling do
if all or cast.dstGUID == Target.guid then
if Player.time - cast.start < self.max_range / self.velocity + (self.travel_delay or 0) then
count = count + 1
end
end
end
return count
end
function Ability:TravelTime()
return Target.estimated_range / self.velocity + (self.travel_delay or 0)
end
function Ability:Ticking()
local count, ticking = 0, {}
if self.aura_targets then
for guid, aura in next, self.aura_targets do
if aura.expires - Player.time > (self.off_gcd and 0 or Player.execute_remains) then
ticking[guid] = true
end
end
end
if self.traveling then
for _, cast in next, self.traveling do
if Player.time - cast.start < self.max_range / self.velocity + (self.travel_delay or 0) then
ticking[cast.dstGUID] = true
end
end
end
for _ in next, ticking do
count = count + 1
end
return count
end
function Ability:HighestRemains()
local highest
if self.traveling then
for _, cast in next, self.traveling do
if Player.time - cast.start < self.max_range / self.velocity then
highest = self:Duration()
end
end
end
if self.aura_targets then
local remains
for _, aura in next, self.aura_targets do
remains = max(0, aura.expires - Player.time - Player.execute_remains)
if remains > 0 and (not highest or remains > highest) then
highest = remains
end
end
end
return highest or 0
end
function Ability:LowestRemains()
local lowest
if self.traveling then
for _, cast in next, self.traveling do
if Player.time - cast.start < self.max_range / self.velocity then
lowest = self:Duration()
end
end
end
if self.aura_targets then
local remains
for _, aura in next, self.aura_targets do
remains = max(0, aura.expires - Player.time - Player.execute_remains)
if remains > 0 and (not lowest or remains < lowest) then
lowest = remains
end
end
end
return lowest or 0
end
function Ability:TickTime()
return self.hasted_ticks and (Player.haste_factor * self.tick_interval) or self.tick_interval
end
function Ability:CooldownDuration()
return self.hasted_cooldown and (Player.haste_factor * self.cooldown_duration) or self.cooldown_duration
end
function Ability:Cooldown()
if self.cooldown_duration > 0 and self:Casting() then
return self:CooldownDuration()
end
local cooldown = GetSpellCooldown(self.spellId)
if cooldown.startTime == 0 then
return 0
end
return max(0, cooldown.duration - (Player.ctime - cooldown.startTime) - (self.off_gcd and 0 or Player.execute_remains))
end
function Ability:CooldownExpected()
if self.last_used == 0 then
return self:Cooldown()
end
if self.cooldown_duration > 0 and self:Casting() then
return self:CooldownDuration()
end
local cooldown = GetSpellCooldown(self.spellId)
if cooldown.startTime == 0 then
return 0
end
local remains = cooldown.duration - (Player.ctime - cooldown.startTime)
local reduction = (Player.time - self.last_used) / (self:CooldownDuration() - remains)
return max(0, (remains * reduction) - (self.off_gcd and 0 or Player.execute_remains))
end
function Ability:Stack()
local aura
for i = 1, 40 do
aura = UnitAura(self.aura_target, i, self.aura_filter)
if not aura then
return 0
elseif self:Match(aura.spellId) then
return (aura.expirationTime == 0 or aura.expirationTime - Player.ctime > (self.off_gcd and 0 or Player.execute_remains)) and aura.applications or 0
end
end
return 0
end
function Ability:MaxStack()
return self.max_stack
end
function Ability:Cost()
return self.rage_cost
end
function Ability:Gain()
return self.rage_gain
end
function Ability:Free()
return self.rage_cost > 0 and self:Cost() == 0
end
function Ability:WontCapRage(reduction)
return (Player.rage.current + self:Gain()) < (Player.rage.max - (reduction or 5))
end
function Ability:ChargesFractional()
local info = GetSpellCharges(self.spellId)
if not info then
return 0
end
local charges = info.currentCharges
if self:Casting() then
if charges >= info.maxCharges then
return charges - 1
end
charges = charges - 1
end
if charges >= info.maxCharges then
return charges
end
return charges + ((max(0, Player.ctime - info.cooldownStartTime + (self.off_gcd and 0 or Player.execute_remains))) / info.cooldownDuration)
end
function Ability:Charges()
return floor(self:ChargesFractional())
end
function Ability:MaxCharges()
local info = GetSpellCharges(self.spellId)
return info and info.maxCharges or 0
end
function Ability:FullRechargeTime()
local info = GetSpellCharges(self.spellId)
if not info then
return 0
end
local charges = info.currentCharges
if self:Casting() then
if charges >= info.maxCharges then
return info.cooldownDuration
end
charges = charges - 1
end
if charges >= info.maxCharges then
return 0
end
return (info.maxCharges - charges - 1) * info.cooldownDuration + (info.cooldownDuration - (Player.ctime - info.cooldownStartTime) - (self.off_gcd and 0 or Player.execute_remains))
end
function Ability:Duration()
return self.hasted_duration and (Player.haste_factor * self.buff_duration) or self.buff_duration
end
function Ability:Casting()
return Player.cast.ability == self
end
function Ability:Channeling()
return Player.channel.ability == self
end
function Ability:CastTime()
local info = GetSpellInfo(self.spellId)
return info and info.castTime / 1000 or 0
end
function Ability:Previous(n)
local i = n or 1
if Player.cast.ability then
if i == 1 then
return Player.cast.ability == self
end
i = i - 1
end
return Player.previous_gcd[i] == self
end
function Ability:UsedWithin(seconds)
return self.last_used >= (Player.time - seconds)
end
function Ability:AutoAoe(removeUnaffected, trigger)
self.auto_aoe = {
remove = removeUnaffected,
targets = {},
target_count = 0,
trigger = 'SPELL_DAMAGE',
}
if trigger == 'periodic' then
self.auto_aoe.trigger = 'SPELL_PERIODIC_DAMAGE'
elseif trigger == 'apply' then
self.auto_aoe.trigger = 'SPELL_AURA_APPLIED'
elseif trigger == 'cast' then
self.auto_aoe.trigger = 'SPELL_CAST_SUCCESS'
end
end
function Ability:RecordTargetHit(guid)
self.auto_aoe.targets[guid] = Player.time
if not self.auto_aoe.start_time then
self.auto_aoe.start_time = self.auto_aoe.targets[guid]
end
end
function Ability:UpdateTargetsHit()
if self.auto_aoe.start_time and Player.time - self.auto_aoe.start_time >= 0.3 then
self.auto_aoe.start_time = nil
self.auto_aoe.target_count = 0
if self.auto_aoe.remove then
for guid in next, AutoAoe.targets do
AutoAoe.targets[guid] = nil
end
end
for guid in next, self.auto_aoe.targets do
AutoAoe:Add(guid)
self.auto_aoe.targets[guid] = nil
self.auto_aoe.target_count = self.auto_aoe.target_count + 1
end
AutoAoe:Update()
end
end
function Ability:Targets()
if self.auto_aoe and self:Up() then
return self.auto_aoe.target_count
end
return 0
end
function Ability:CastSuccess(dstGUID)
self.last_used = Player.time
if self.ignore_cast then
return
end
Player.last_ability = self
if self.triggers_gcd then
Player.previous_gcd[10] = nil
table.insert(Player.previous_gcd, 1, self)
end
if self.aura_targets and self.requires_react then
self:RemoveAura(self.aura_target == 'player' and Player.guid or dstGUID)
end
if Opt.auto_aoe and self.auto_aoe and self.auto_aoe.trigger == 'SPELL_CAST_SUCCESS' then
AutoAoe:Add(dstGUID, true)
end
if self.traveling and self.next_castGUID then
self.traveling[self.next_castGUID] = {
guid = self.next_castGUID,
start = self.last_used,
dstGUID = dstGUID,
}
self.next_castGUID = nil
end
if self.consumes_whirlwind and WhirlwindFury.known then
WhirlwindFury.buff.pending_stack_use = true
end
if Opt.previous then
smashPreviousPanel.ability = self
smashPreviousPanel.border:SetTexture(ADDON_PATH .. 'border.blp')
smashPreviousPanel.icon:SetTexture(self.icon)
smashPreviousPanel:SetShown(smashPanel:IsVisible())
end
end
function Ability:CastLanded(dstGUID, event, missType)
if self.traveling then
local oldest
for guid, cast in next, self.traveling do
if Player.time - cast.start >= self.max_range / self.velocity + (self.travel_delay or 0) + 0.2 then
self.traveling[guid] = nil -- spell traveled 0.2s past max range, delete it, this should never happen
elseif cast.dstGUID == dstGUID and (not oldest or cast.start < oldest.start) then
oldest = cast
end
end
if oldest then
Target.estimated_range = floor(clamp(self.velocity * max(0, Player.time - oldest.start - (self.travel_delay or 0)), 0, self.max_range))
self.traveling[oldest.guid] = nil
end
end
if self.range_est_start then
Target.estimated_range = floor(clamp(self.velocity * (Player.time - self.range_est_start - (self.travel_delay or 0)), 5, self.max_range))
self.range_est_start = nil
elseif self.max_range < Target.estimated_range then
Target.estimated_range = self.max_range
end
if Opt.auto_aoe and self.auto_aoe then
if event == 'SPELL_MISSED' and (missType == 'EVADE' or (missType == 'IMMUNE' and not self.ignore_immune)) then
AutoAoe:Remove(dstGUID)
elseif event == self.auto_aoe.trigger or (self.auto_aoe.trigger == 'SPELL_AURA_APPLIED' and event == 'SPELL_AURA_REFRESH') then
self:RecordTargetHit(dstGUID)
end
end
if Opt.previous and Opt.miss_effect and event == 'SPELL_MISSED' and smashPreviousPanel.ability == self then
smashPreviousPanel.border:SetTexture(ADDON_PATH .. 'misseffect.blp')
end
end
-- Start DoT tracking
function TrackedAuras:Purge()
for _, ability in next, Abilities.tracked do
for guid, aura in next, ability.aura_targets do
if aura.expires <= Player.time then
ability:RemoveAura(guid)
end
end
end
end
function TrackedAuras:Remove(guid)
for _, ability in next, Abilities.tracked do
ability:RemoveAura(guid)
end
end
function Ability:Track()
self.aura_targets = {}
end
function Ability:ApplyAura(guid)
if AutoAoe.blacklist[guid] then
return
end
local aura = self.aura_targets[guid] or {}
aura.expires = Player.time + self:Duration()
self.aura_targets[guid] = aura
return aura
end
function Ability:RefreshAura(guid, extend)
if AutoAoe.blacklist[guid] then
return
end
local aura = self.aura_targets[guid]
if not aura then
return self:ApplyAura(guid)
end
local duration = self:Duration()
aura.expires = max(aura.expires, Player.time + min(duration * (self.no_pandemic and 1.0 or 1.3), (aura.expires - Player.time) + (extend or duration)))
return aura
end
function Ability:RefreshAuraAll(extend)
local duration = self:Duration()
for guid, aura in next, self.aura_targets do
aura.expires = max(aura.expires, Player.time + min(duration * (self.no_pandemic and 1.0 or 1.3), (aura.expires - Player.time) + (extend or duration)))
end
end
function Ability:RemoveAura(guid)
if self.aura_targets[guid] then
self.aura_targets[guid] = nil
end
end
-- End DoT tracking
--[[
Note: To get talent_node value for a talent, hover over talent and use macro:
/dump GetMouseFoci()[1]:GetNodeID()
]]
-- Warrior Abilities
---- Class
------ Baseline
local BattleStance = Ability:Add(386164, true, true)
BattleStance.cooldown_duration = 3
local BerserkerRage = Ability:Add(18499, true, true)
BerserkerRage.buff_duration = 6
BerserkerRage.cooldown_duration = 60
local Charge = Ability:Add(100, false, true, 105771)
Charge.buff_duration = 1
Charge.cooldown_duration = 20
Charge.requires_charge = true
Charge.off_gcd = true
Charge.triggers_gcd = false
local HeroicLeap = Ability:Add(6544, false, true, 52174)
HeroicLeap.cooldown_duration = 45
HeroicLeap.requires_charge = true
HeroicLeap:AutoAoe()
local HeroicThrow = Ability:Add(57755, false, true)
HeroicThrow.cooldown_duration = 6
local Pummel = Ability:Add(6552, false, true)
Pummel.buff_duration = 4
Pummel.cooldown_duration = 15
Pummel.off_gcd = true
Pummel.triggers_gcd = false