-
Notifications
You must be signed in to change notification settings - Fork 0
/
encounterBuilders.lua
147 lines (120 loc) · 4.41 KB
/
encounterBuilders.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
-----------------------------------------------------------------------------------------------
-- Encounter Building Functions
-- Created by Ryan Park, aka Reglitch of Codex
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
-- CAST FUNCTIONS
-----------------------------------------------------------------------------------------------
--Modularization is heavy here, we do not reiterate on the same function to continually check
--We add the spell and unit into the tWatchedCasts table then check when the cast event is fired by LCLF
function ReStrat:createCastAlert(strUnit, strCast, duration_i, strIcon_i, color_i, fCallback_i)
if ReStrat.tEncounters[strUnit] then
if ReStrat.tEncounters[strUnit].tModules[strCast].bEnabled then
ReStrat.tWatchedCasts[#ReStrat.tWatchedCasts+1] = {
name = strUnit,
cast = strCast,
tAlertInfo = {
duration = duration_i,
strIcon = strIcon_i,
fCallback = fCallback_i,
strColor = color_i
}
}
end
end
end
--Add trigger to be checked
function ReStrat:createCastTrigger(strUnit, strCast, fCallback_i)
self.tSpellTriggers[#self.tSpellTriggers+1] = {
name = strUnit,
cast = strCast,
fCallback = fCallback_i
}
end
--Checks if the specified mob is casting ANYTHING
--strCast is entirely optional, if it isn't there we check for ANYTHING being cast
function ReStrat:isCasting(strUnit, strCast)
--If we don't have a specified cast to check for
if not strCast then
for i,v in ipairs(ReStrat.tUnits) do
if ReStrat.tUnits[i].name == strUnit then
if ReStrat.tUnits[i].unit.IsCasting() then return true end
end
end
return false
end
--We need to check for a specified cast
for i,v in ipairs(ReStrat.tUnits) do
if ReStrat.tUnits[i].name == strUnit then
if ReStrat.tUnits[i].unit.GetCastName() == strCast then return true end
end
end
return false
end
--Adds the requested spell into the checklist
--This is managed in the combat log hooks in combatlog.lua
function ReStrat:onPlayerHit(strSpell, strUnitSource, nCooldown, fCallback)
if not nCooldown then nCooldown = 1 end -- By default we place a 1 second cooldown on these to avoid spam
self.tSpellTriggers[#self.tSpellTriggers] = {source = strUnitSource, spell = strSpell, cooldown = nCooldown, callback = fCallback};
end
-----------------------------------------------------------------------------------
-- AURA FUNCTIONS
-----------------------------------------------------------------------------------------------
--Again modular, adds to tWatchedAuras
--All processing is handled by OnAuraApplied
function ReStrat:createAuraAlert(strUnit, strAuraName, duration_i, icon_i, fCallback_i)
if not ReStrat.tEncounters[strUnit] then
ReStrat.tWatchedAuras[#ReStrat.tWatchedAuras+1] = {
name = strUnit,
aura = strAuraName,
tAlertInfo = {
duration = duration_i,
strIcon = strIcon_i,
fCallback = fCallback_i,
strColor = color_i
}
}
return
end
if ReStrat.tEncounters[strUnit].tModules[strAuraName].bEnabled then
ReStrat.tWatchedAuras[#ReStrat.tWatchedAuras+1] = {
name = strUnit,
aura = strAuraName,
tAlertInfo = {
duration = duration_i,
strIcon = strIcon_i,
fCallback = fCallback_i,
strColor = color_i
}
}
return
end
end
--Not very accurate, better than nothing
function ReStrat:findAuraDuration(strBuffName, unit)
local tBuffs = unit:GetBuffs();
--Benficial
for i=1, #tBuffs["arBeneficial"] do
if tBuffs["arBeneficial"][i].splEffect:GetName() == strBuffName then
return tBuffs["arBeneficial"][i].fTimeRemaining
end
end
--Harmful
for i=1, #tBuffs["arHarmful"] do
if tBuffs["arHarmful"][i].splEffect:GetName() == strBuffName then
return tBuffs["arHarmful"][i].fTimeRemaining
end
end
end
--Just add into library, look in combatLog.lua for the real functionality
function ReStrat:createPinFromAura(auraName)
self.tPinAuras[auraName] = true
end
-----------------------------------------------------------------------------------
-- DATACHRON FUNCTIONS
-----------------------------------------------------------------------------------
--This is used in some fights as a phase trigger, quite useful
function ReStrat:OnDatachron(strText_i, fCallback_i)
if not self.tDatachron then self.tDatachron = {} end
self.tDatachron[#self.tDatachron+1] = { strText = strText_i, fCallback = fCallback_i };
end