forked from Sidoine/Ovale
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBanditsGuile.lua
194 lines (167 loc) · 6.97 KB
/
BanditsGuile.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
--[[--------------------------------------------------------------------
Copyright (C) 2013, 2014 Johnny C. Lam.
See the file LICENSE.txt for copying permission.
--]]-------------------------------------------------------------------
--[[
This addon tracks the hidden stacking damage buff from Bandit's Guile
on a combat rogue.
Bandit's Guile description from wowhead.com:
Take advantage of the natural ebb and flow of combat, causing your
Sinister Strike to gradually increase your damage dealt by up to 30%.
This maximum effect will last for 15 sec before fading and beginning
the cycle anew.
Mechanically, there is a hidden buff that stacks up to 12. At 4 stacks,
the rogue gains Shallow Insight (10% increased damage). At 8 stacks, the
rogue gains Moderate Insight (20% increased damage). At 12 stacks, the
rogue gains Deep Insight (30% increased damage).
This addon manages the hidden aura in OvaleAura using events triggered by
attacking with Sinister Strike or by changes to the Insight auras on the
player. The aura ID of the hidden aura is set to 84654, the spell ID of
Bandit's Guile, and can be checked like any other aura using OvaleAura's
public or state methods.
--]]
local OVALE, Ovale = ...
local OvaleBanditsGuile = Ovale:NewModule("OvaleBanditsGuile", "AceEvent-3.0")
Ovale.OvaleBanditsGuile = OvaleBanditsGuile
--<private-static-properties>
local OvaleDebug = Ovale.OvaleDebug
-- Forward declarations for module dependencies.
local OvaleAura = nil
local API_GetSpellInfo = GetSpellInfo
local API_GetTime = GetTime
-- Register for debugging messages.
OvaleDebug:RegisterDebugging(OvaleBanditsGuile)
-- Player's GUID.
local self_playerGUID = nil
-- Aura IDs for visible buff from Bandit's Guile.
local SHALLOW_INSIGHT = 84745
local MODERATE_INSIGHT = 84746
local DEEP_INSIGHT = 84747
local INSIGHT_BUFF = {
[ SHALLOW_INSIGHT] = API_GetSpellInfo(SHALLOW_INSIGHT),
[MODERATE_INSIGHT] = API_GetSpellInfo(MODERATE_INSIGHT),
[ DEEP_INSIGHT] = API_GetSpellInfo(DEEP_INSIGHT),
}
-- Bandit's Guile spell ID.
local BANDITS_GUILE = 84654
-- Spell IDs for abilities that proc Bandit's Guile.
local BANDITS_GUILE_ATTACK = {
[ 1752] = API_GetSpellInfo(1752), -- Sinister Strike
}
--</private-static-properties>
--<public-static-properties>
OvaleBanditsGuile.spellName = "Bandit's Guile"
-- Bandit's Guile spell ID from spellbook; re-used as the aura ID of the hidden, stacking buff.
OvaleBanditsGuile.spellId = BANDITS_GUILE
OvaleBanditsGuile.start = 0
OvaleBanditsGuile.ending = 0
OvaleBanditsGuile.duration = 15
OvaleBanditsGuile.stacks = 0
--</public-static-properties>
--<public-static-methods>
function OvaleBanditsGuile:OnInitialize()
-- Resolve module dependencies.
OvaleAura = Ovale.OvaleAura
end
function OvaleBanditsGuile:OnEnable()
if Ovale.playerClass == "ROGUE" then
self_playerGUID = Ovale.playerGUID
self:RegisterMessage("Ovale_SpecializationChanged")
end
end
function OvaleBanditsGuile:OnDisable()
if Ovale.playerClass == "ROGUE" then
self:UnregisterMessage("Ovale_SpecializationChanged")
end
end
function OvaleBanditsGuile:Ovale_SpecializationChanged(event, specialization, previousSpecialization)
self:Debug(event, specialization, previousSpecialization)
if specialization == "combat" then
self:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
self:RegisterMessage("Ovale_AuraAdded")
self:RegisterMessage("Ovale_AuraChanged")
self:RegisterMessage("Ovale_AuraRemoved")
else
self:UnregisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
self:UnregisterMessage("Ovale_AuraAdded")
self:UnregisterMessage("Ovale_AuraChanged")
self:UnregisterMessage("Ovale_AuraRemoved")
end
end
-- This event handler uses CLEU to track Bandit's Guile before it has procced any level of the
-- Insight buff.
function OvaleBanditsGuile:COMBAT_LOG_EVENT_UNFILTERED(event, timestamp, cleuEvent, hideCaster, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags, ...)
local arg12, arg13, arg14, arg15, arg16, arg17, arg18, arg19, arg20, arg21, arg22, arg23, arg24, arg25 = ...
if sourceGUID == self_playerGUID and cleuEvent == "SPELL_DAMAGE" then
local spellId, spellName, multistrike = arg12, arg13, arg25
if BANDITS_GUILE_ATTACK[spellId] and not multistrike then
local now = API_GetTime()
if self.ending < now then
self.stacks = 0
end
if self.stacks < 3 then
self.start = now
self.ending = self.start + self.duration
self.stacks = self.stacks + 1
self:Debug(cleuEvent, spellName, spellId, self.stacks)
self:GainedAura(now)
end
end
end
end
-- This event handler uses Ovale_AuraAdded to track the Insight buff being applied for the first
-- time and sets the implied stacks of Bandit's Guile.
function OvaleBanditsGuile:Ovale_AuraAdded(event, timestamp, target, auraId, caster)
if target == self_playerGUID then
local auraName = INSIGHT_BUFF[auraId]
if auraName then
local aura = OvaleAura:GetAura("player", auraId, "HELPFUL", true)
self.start, self.ending = aura.start, aura.ending
-- Set stacks to count implied by seeing the given aura added to the player.
if auraId == SHALLOW_INSIGHT then
self.stacks = 4
elseif auraId == MODERATE_INSIGHT then
self.stacks = 8
elseif auraId == DEEP_INSIGHT then
self.stacks = 12
end
self:Debug(event, auraName, self.stacks)
self:GainedAura(timestamp)
end
end
end
-- This event handler uses Ovale_AuraChanged to track refreshes of the Insight buff, which indicates
-- that it the hidden Bandit's Guile buff has gained extra stacks.
function OvaleBanditsGuile:Ovale_AuraChanged(event, timestamp, target, auraId, caster)
if target == self_playerGUID then
local auraName = INSIGHT_BUFF[auraId]
if auraName then
local aura = OvaleAura:GetAura("player", auraId, "HELPFUL", true)
self.start, self.ending = aura.start, aura.ending
-- A changed Insight buff also means that the Bandit's Guile hidden buff gained a stack.
self.stacks = self.stacks + 1
self:Debug(event, auraName, self.stacks)
self:GainedAura(timestamp)
end
end
end
function OvaleBanditsGuile:Ovale_AuraRemoved(event, timestamp, target, auraId, caster)
if target == self_playerGUID then
if ((auraId == SHALLOW_INSIGHT and self.stacks < 8) or (auraId == MODERATE_INSIGHT and self.stacks < 12) or auraId == DEEP_INSIGHT) and timestamp < self.ending then
self.ending = timestamp
self.stacks = 0
self:Debug(event, INSIGHT_BUFF[auraId], self.stacks)
OvaleAura:LostAuraOnGUID(self_playerGUID, timestamp, self.spellId, self_playerGUID)
end
end
end
function OvaleBanditsGuile:GainedAura(atTime)
OvaleAura:GainedAuraOnGUID(self_playerGUID, atTime, self.spellId, self_playerGUID, "HELPFUL", nil, nil, self.stacks, nil, self.duration, self.ending, nil, self.spellName, nil, nil, nil)
end
function OvaleBanditsGuile:DebugBanditsGuile()
local aura = OvaleAura:GetAuraByGUID(self_playerGUID, self.spellId, "HELPFUL", true)
if aura then
self:Print("Player has Bandit's Guile aura with start=%s, end=%s, stacks=%d.", aura.start, aura.ending, aura.stacks)
end
end
--</public-static-methods>