forked from Djouley/Redfella-s-WA-Custom-Functions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbdk_apl.lua
265 lines (222 loc) · 13.1 KB
/
bdk_apl.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
-- UNIT_POWER_FREQUENT, SPELL_UPDATE_COOLDOWN, SPELL_UPDATE_CHARGES, PLAYER_TARGET_CHANGED, UNIT_SPELLCAST_SUCCEEDED
function ()
if not WA_Redfellas_Rot_BDK_Enabled or UnitOnTaxi("player") or not UnitCanAttack("player", "target") then
return false
end
local now = GetTime()
if now < aura_env.lastUpdate + aura_env.updateInterval then
return true
end
aura_env.lastUpdate = now
local targets = aura_env.targets
local talentList = aura_env.talents
local talented = aura_env.talented
local abilities = aura_env.abilities
local abilityNames = aura_env.abilityNames
local cooldowns = aura_env.cooldowns
local charges = aura_env.charges
local chargeTime = aura_env.chargeTime
local chargedAbilities = aura_env.chargedAbilities
local chargesMax = aura_env.chargesMax
local buffList = aura_env.buffs
local buffNames = aura_env.buffNames
local buffRemains = aura_env.buffRemains
local debuffList = aura_env.debuffs
local debuffNames = aura_env.debuffNames
local debuffRemains = aura_env.debuffRemains
local chargeCt = aura_env.chargeCt
local cdLeft = aura_env.cdLeft
local health_percentage = math.ceil( (UnitHealth("player") / UnitHealthMax("player") * 100) )
local missing_health_percentage = 100 - health_percentage
for k,v in pairs( targets ) do
if now - v > aura_env.targetWipeInterval then
targets[k] = nil
aura_env.targetCount = max(0, aura_env.targetCount - 1)
end
end
local gcdStart, gcdDuration = GetSpellCooldown(61304)
local gcd = gcdStart + gcdDuration
-- if GCD is active, we'll just advance to the end of the GCD.
now = max( now, gcd )
-- if the GCD isn't active, calculate what the GCD should be.
if gcdDuration == 0 then
gcdDuration = max( 1, 1.5 / ( 1 + ( GetHaste() / 100 ) ) )
end
-- Get active talents.
for k,v in pairs( talentList ) do
talented[ k ] = select(4, GetTalentInfo( unpack( v ) ) )
end
-- Grab ability CDs.
for k,v in pairs( abilities ) do
local start, duration = GetSpellCooldown(v)
cooldowns[ k ] = select(2, IsUsableSpell(v)) and 999 or max( 0, start + duration - now )
end
-- Check # of charges.
for k,v in pairs( chargedAbilities ) do
local c, maxCharges, start, duration = GetSpellCharges(v)
charges[ k ] = min( maxCharges, c + ( max(0, 1 - ( start + duration - now) / duration ) ) )
chargeTime[ k ] = duration
chargesMax[ k ] = maxCharges
end
-- Check if buffs are up.
for k,v in pairs( buffList ) do
local _, _, _, _, _, _, expires = UnitBuff("player", buffNames[ v ] )
buffRemains[ k ] = 0
if expires then
if expires == 0 then
buffRemains[ k ] = 10 -- No real duration, i.e. Fury of Air.
else
buffRemains[ k ] = expires - now
end
end
end
-- Check if debuffs are up.
for k,v in pairs( debuffList ) do
local _, _, _, _, _, _, expires = UnitDebuff("target", debuffNames[ v ] )
debuffRemains[ k ] = expires and expires - now or 0
end
aura_env.lastRec = aura_env.recommended
aura_env.recommended = 0
aura_env.timeToReady = 10
local spend_runes = false
local danger_treshold = aura_env.danger_treshold
local critical_treshold = aura_env.critical_treshold
local ready = aura_env.ready
local rec = aura_env.rec
local runes = aura_env.runes_available()
local ds_heal = aura_env.death_strike_heal()
local bone_shield_stacks = aura_env.get_unit_aura_value(195181, 'count') or 0
local death_strike_available = false
local two_death_strikes_available = false
local blooddrinker_heal = aura_env.blooddrinker_heal()
local artifact_weapon = IsEquippedItem(128402)
local consumption_heal = 9999999999999
if artifact_weapon then consumption_heal = aura_env.consumption_heal() * aura_env.targetCount end
-- Calculate time to soft-capping runes, we always, ALWAYS prefer to have three runes charging
local time_to_3_runes = aura_env.time_to_x_runes(3)
if time_to_3_runes <= 3.75 then spend_runes = true end
local runic_power = UnitPower("player")
local runic_power_max = UnitPowerMax("player")
local runic_power_deficit = runic_power_max - runic_power
local runic_power_cap = 20 -- Base for Marrowrend
local rd_mult = 1
-- Standing in DnD with RD
if talented.rapid_decomposition and buffRemains.death_and_decay then rd_mult = 1.15 end
if talented.heartbreaker then
if aura_env.targetCount >= 2 and aura_env.targetCount <= 5 then
runic_power_cap = 15 + (aura_env.targetCount * 3)
elseif aura_env.targetCount >= 6 then
runic_power_cap = 30
end
end
-- Factor RD multiplier to whatever RP cap we calculated and subtract from max RP
runic_power_cap = runic_power_max - runic_power_cap * rd_mult
-- Easy booleans for how many death strikes we can pump out, we can actually do three with Ossuary but no need in this APL
if (buffRemains.ossuary > 0 and runic_power >= 40) or runic_power >= 45 then death_strike_available = true end
if (buffRemains.ossuary > 0 and runic_power >= 80) or runic_power >= 90 then two_death_strikes_available = true end
-- Grab the expiration of Bone Shield aura
local bone_shield_aura = select(7,UnitBuff("player",GetSpellInfo(195181))) or 0
aura_env.bone_shield_danger = bone_shield_aura - GetTime()
---------------
-- APL START --
---------------
if not in_combat and ready( 'death_and_decay' ) then rec( 'death_and_decay' ) end
-- DANGER TRESHOLD START
-- Marrowrend if aura duration is less than 6 seconds
if ready( 'marrowrend' ) and aura_env.bone_shield_danger > 0 and aura_env.bone_shield_danger < 6 and runes >= 2 then rec( 'marrowrend') end
-- Cooldowns Enabled: below danger treshold (default: 55%)
if WA_Redfellas_Rot_BDK_Def_CDs and health_percentage <= danger_treshold then
if artifact_weapon
and health_percentage <= critical_treshold
and ready( 'consumption' )
then rec( 'consumption' ) end
-- Vampiric Embrace if: player is below critical treshold (default: 25%) --OR-- RP for two Death Strikes
if ready( 'vampiric_blood' ) and health_percentage <= critical_treshold or two_death_strikes_available then rec( 'vampiric_blood' ) end
-- Death Strike if: VE is active --OR-- VE is on cooldown
if ready( 'death_strike' ) and death_strike_available and (buffRemains.vampiric_blood > 0 or cooldowns.vampiric_blood > 0) then rec( 'death_strike' ) end
-- Consumption if: critical treshold and can't DS
if ready( 'dancing_rune_weapon' ) and not death_strike_available and cooldowns.vampiric_blood > 0 and buffRemains.vampiric_blood == 0 then rec( 'dancing_rune_weapon' ) end
-- Dancing Rune Weapon if: we can't Death Strike or VE, and VE isn't active
if ready( 'dancing_rune_weapon' ) and not death_strike_available and cooldowns.vampiric_blood > 0 and buffRemains.vampiric_blood == 0 then rec( 'dancing_rune_weapon' ) end
-- Prio RP generators when in danger
if ready( 'death_and_decay' ) and (talented.rapid_decomposition or buffRemains.crimson_scourge >= 0 or aura_env.targetCount > 1) then rec( 'death_and_decay' ) end
-- Marrowrend if: six or less Bone Shield stacks & Heart Strike if above
if ready( 'marrowrend' ) and bone_shield_stacks <= 6 and runes >= 2 then rec( 'marrowrend') end
if ready( 'heart_strike' ) and bone_shield_stacks >= 7 and runes >= 1 then rec( 'heart_strike') end
end
-- Cooldowns Disabled: below danger treshold (default: 55%)
if not WA_Redfellas_Rot_BDK_Def_CDs and health_percentage <= danger_treshold then
-- Death Strike
if ready( 'death_strike' ) and death_strike_available then rec( 'death_strike' ) end
end
-- SELFHEALS IF: Will not overheal
if artifact_weapon
and WA_Redfellas_Rot_BDK_Def_CDs
and ready( 'consumption')
and missing_health_percentage >= consumption_heal
and missing_health_percentage >= 25
then rec( 'consumption' ) end
-- Blooddrinker if: talented & got runes
if talented.blooddrinker and WA_Redfellas_Rot_BDK_Def_CDs and ready( 'blooddrinker' ) and missing_health_percentage >= blooddrinker_heal then rec( 'blooddrinker' ) end
-- Death Strike if: not banking for Bonestorm
if (not talented.bonestorm or (WA_Redfellas_Rot_BDK_Off_CDs and cooldowns.bonestorm > 0)) and ready( 'death_strike' ) and health_percentage > danger_treshold and missing_health_percentage >= ds_heal then rec( 'death_strike' ) end
-- Blood Boil if: Blood Plague missing
if ready( 'blood_boil' ) and charges.blood_boil >= 0 and debuffRemains.blood_plague == 0 then rec( 'blood_boil' ) end
-- Death and Decay on CD if: using Rapid Decomposition talent -- OR -- Crimson Scourge -- OR -- fighting more than one target
if ready( 'death_and_decay' ) and (talented.rapid_decomposition or buffRemains.crimson_scourge >= 0 or aura_env.targetCount > 1) then rec( 'death_and_decay' ) end
-- Blood Boil if: over 1.5 charges available
if ready( 'blood_boil' ) and chargeCt( 'blood_boil' ) >= 1.5 then rec( 'blood_boil' ) end
-- Cooldowns Enabled: Dancing Rune Weapon to generate Bone Shield stacks
if WA_Redfellas_Rot_BDK_Off_CDs and ready( 'dancing_rune_weapon' ) and bone_shield_stacks <= 4 and runes >= 2 then rec( 'dancing_rune_weapon' ) end
-- Marrowrend if: missing Bone Shield
if ready( 'marrowrend' ) and bone_shield_stacks == 0 and runes >= 2 then rec( 'marrowrend') end
-- Bonestorm if: CD usage enabled, talented and 100+ RP, max RP BS will consume is 100
if WA_Redfellas_Rot_BDK_Off_CDs and talented.bonestorm and ready( 'bonestorm' ) and runic_power >= 100 then rec( 'bonestorm' ) end
-- Death Strike if: Need to spend RP and not talented Bonestorm / Bonestorm on CD
if (not talented.bonestorm or (WA_Redfellas_Rot_BDK_Off_CDs and cooldowns.bonestorm > 0)) and ready( 'death_strike' ) and death_strike_available and runic_power >= runic_power_cap then rec( 'death_strike' ) end
-- Marrowrend if: Need 6 or more BS stacks and DRW active
if ready( 'marrowrend' ) and buffRemains.dancing_rune_weapon > 0 and bone_shield_stacks <= 4 and runes >= 2 then rec( 'marrowrend') end
-- If standing in DnD with Rapid Decomposition
if talented.rapid_decomposition and buffRemains.death_and_decay > 0 then
-- Fighting one target, keeping up Ossuary is optimal, but let's still use as many runes as we can
if talented.ossuary and aura_env.targetCount == 1 and ready( 'marrowrend' ) and bone_shield_stacks <= 6 and spend_runes then rec( 'marrowrend') end
if talented.ossuary and aura_env.targetCount == 1 and ready( 'heart_strike' ) and bone_shield_stacks >= 7 and spend_runes then rec( 'heart_strike') end
-- At 5 mobs, the two Heart Strikes will get you +24 RP (+15 Bonus RP per Heart Strike vs 5 mobs, -3 RP from losing a Heart Strike vs. one mob later.)
-- At 4 mobs, +18 RP, at 3 mobs, +12 RP, at 2 mobs, +6 RP
if talented.ossuary and aura_env.targetCount >= 2 and ready( 'marrowrend' ) and bone_shield_stacks <= 4 and spend_runes then rec( 'marrowrend') end
if talented.ossuary and aura_env.targetCount >= 2 and ready( 'heart_strike' ) and bone_shield_stacks >= 5 and spend_runes then rec( 'heart_strike') end
-- Regular rune spending: stay below 4 ready runes, but keep near it for next DnD
else
if ready( 'marrowrend' ) and bone_shield_stacks <= 6 and spend_runes then rec( 'marrowrend') end
if ready( 'heart_strike' ) and bone_shield_stacks >= 7 and spend_runes then rec( 'heart_strike') end
end
-- Blood Tap if: time to 3 runes available is higher than 5 seconds
if talented.blood_tap and ready ('blood_tap') and aura_env.time_to_x_runes(3) > 5 then rec( 'blood_tap' ) end
-- Blood Boil if: really nothing else to cast
if ready( 'blood_boil' ) then rec( 'blood_boil' ) end
-- Blood Tap if: really nothing else to cast
if talented.blood_tap and ready ('blood_tap') then rec( 'blood_tap' ) end
---------------
-- APL END --
---------------
if aura_env.timeToReady < 5 then
if aura_env.showCooldownRing then
local start, duration = GetSpellCooldown( aura_env.recommended )
if not start or start == 0 then
start, duration = GetSpellCooldown( 61304 )
end
WeakAuras.regions[aura_env.id].region.cooldown:SetReverse(aura_env.invertCooldownRing)
WeakAuras.regions[aura_env.id].region.cooldown:SetCooldown(start, duration)
end
if aura_env.showRangeHighlight then
local range = aura_env.recommended == 0 and 0 or IsSpellInRange( abilityNames[ aura_env.recommended ] )
if range == 0 then WeakAuras.regions[aura_env.id].region:Color(1, 0, 0, 1)
else WeakAuras.regions[aura_env.id].region:Color(1, 1, 1, 1)
end
end
else
WeakAuras.regions[aura_env.id].region.cooldown:SetCooldown(0,0)
WeakAuras.regions[aura_env.id].region:Color(1,1,1,1)
end
return true
end