PageRenderTime 84ms CodeModel.GetById 40ms app.highlight 13ms RepoModel.GetById 27ms app.codeStats 0ms

/Tukui/modules/buffs/raidbuffsreminder.lua

http://github.com/Asphyxia/Tukui
Lua | 315 lines | 278 code | 22 blank | 15 comment | 33 complexity | f208e96cb0b8870b4bbf8e0583f26506 MD5 | raw file
  1local T, C, L = unpack(select(2, ...)) -- Import Functions/Constants, Config, Locales
  2if C["buffreminder"].raidbuffreminder ~= true then return end
  3
  4--------------------------------------------------------------------------------------------
  5-- Raid Buff Reminder (Bar in the topright corner below minimap)
  6--------------------------------------------------------------------------------------------
  7
  8BuffReminderRaidBuffs = {
  9	Flask = {
 10		79470, --"Flask of the Draconic Mind"
 11		94160, --"Flask of Flowing Water"
 12		79469, --"Flask of Steelskin"
 13		79471, --"Flask of the Winds
 14		79472, --"Flask of Titanic Strength"
 15		79638, --"Flask of Enhancement-STR"
 16		79639, --"Flask of Enhancement-AGI"
 17		79640, --"Flask of Enhancement-INT"
 18		92679, --Flask of battle
 19	},
 20	BattleElixir = {
 21		--Scrolls
 22		89343, --Agility
 23		63308, --Armor 
 24		89347, --Int
 25		89342, --Spirit
 26		63306, --Stam
 27		89346, --Strength
 28
 29		--Elixirs
 30		79481, --Hit
 31		79632, --Haste
 32		79477, --Crit
 33		79635, --Mastery
 34		79474, --Expertise
 35		79468, --Spirit
 36	},
 37	GuardianElixir = {
 38		79480, --Armor
 39		79631, --Resistance+90
 40	},
 41	Food = {
 42		87545, --90 STR
 43		87546, --90 AGI
 44		87547, --90 INT
 45		87548, --90 SPI
 46		87549, --90 MAST
 47		87550, --90 HIT
 48		87551, --90 CRIT
 49		87552, --90 HASTE
 50		87554, --90 DODGE
 51		87555, --90 PARRY
 52		87635, --90 EXP
 53		87556, --60 STR
 54		87557, --60 AGI
 55		87558, --60 INT
 56		87559, --60 SPI
 57		87560, --60 MAST
 58		87561, --60 HIT
 59		87562, --60 CRIT
 60		87563, --60 HASTE
 61		87564, --60 DODGE
 62		87634, --60 EXP
 63		87554, --Seafood Feast
 64	},
 65}
 66
 67--Locals
 68local flaskbuffs = BuffReminderRaidBuffs["Flask"]
 69local battleelixirbuffs = BuffReminderRaidBuffs["BattleElixir"]
 70local guardianelixirbuffs = BuffReminderRaidBuffs["GuardianElixir"]
 71local foodbuffs = BuffReminderRaidBuffs["Food"]	
 72local battleelixired	
 73local guardianelixired	
 74
 75--Setup Caster Buffs (atm for Warlock)
 76local function SetCasterOnlyBuffs()
 77	if T.myclass == "WARLOCK" then
 78		Spell3Buff = {
 79			1126, -- "Mark of the wild"
 80			90363, --"Embrace of the Shale Spider"
 81			20217, --"Greater Blessing of Kings",
 82		}
 83		Spell4Buff = {
 84			24907, --Druid's aura 5% haste
 85			3738, --Totem 5% haste
 86			49868, --Shadowpriest's aura 5% haste
 87		}
 88		Spell5Buff = {
 89			28176, --Fel Armor
 90		}
 91		Spell6Buff = {
 92			85768, -- Warlock buff 3% haste (self)
 93		}
 94	else
 95		Spell3Buff = {
 96			1126, -- "Mark of the wild"
 97			90363, --"Embrace of the Shale Spider"
 98			20217, --"Greater Blessing of Kings",
 99		}
100		Spell4Buff = {
101			61316, --"Dalaran Brilliance"
102			1459, --"Arcane Brilliance"
103		}
104		Spell5Buff = {
105			19740, --"Blessing of Might"
106			5675, --"Mana Spring Totem"
107		}
108		Spell6Buff = {
109			53646, --10% spd aura
110			77747, -- 10% spd totem
111		}
112	end
113end
114
115--Setup everyone else's buffs
116local function SetBuffs()
117	Spell3Buff = {
118		1126, -- "Mark of the wild"
119		90363, --"Embrace of the Shale Spider"
120		20217, --"Greater Blessing of Kings",
121	}
122	Spell4Buff = {
123		19740, --"Blessing of Might"
124		30808, --"Unleashed Rage"
125		53138, --Abom Might
126		19506, --Trushot
127	}
128	Spell5Buff = {
129		469, -- Commanding
130		6307, -- Blood Pact
131		90364, -- Qiraji Fortitude
132		72590, -- Drums of fortitude
133		21562, -- Fortitude
134	}
135	Spell6Buff = {
136		57330, --DK str/agi
137		8075, --Totem str/agi
138	}
139end
140
141-- we need to check if you have two differant elixirs if your not flasked, before we say your not flasked
142local function CheckElixir(unit)
143	if (battleelixirbuffs and battleelixirbuffs[1]) then
144		for i, battleelixirbuffs in pairs(battleelixirbuffs) do
145			local spellname = select(1, GetSpellInfo(battleelixirbuffs))
146			if UnitAura("player", spellname) then
147				FlaskFrame.t:SetTexture(select(3, GetSpellInfo(battleelixirbuffs)))
148				battleelixired = true
149				break
150			else
151				battleelixired = false
152			end
153		end
154	end
155	
156	if (guardianelixirbuffs and guardianelixirbuffs[1]) then
157		for i, guardianelixirbuffs in pairs(guardianelixirbuffs) do
158			local spellname = select(1, GetSpellInfo(guardianelixirbuffs))
159			if UnitAura("player", spellname) then
160				guardianelixired = true
161				if not battleelixired then
162					FlaskFrame.t:SetTexture(select(3, GetSpellInfo(guardianelixirbuffs)))
163				end
164				break
165			else
166				guardianelixired = false
167			end
168		end
169	end	
170	
171	if guardianelixired == true and battleelixired == true then
172		FlaskFrame:SetAlpha(0.2)
173		return
174	else
175		FlaskFrame:SetAlpha(1)
176	end
177end
178
179--Main Script
180local function OnAuraChange(self, event, arg1, unit)
181	if (event == "UNIT_AURA" and arg1 ~= "player") then 
182		return
183	end
184	
185	--If We're a caster we may want to see differant buffs
186	if T.Role == "Caster" then 
187		SetCasterOnlyBuffs() 
188	else
189		SetBuffs()
190	end
191	
192	--Start checking buffs to see if we can find a match from the list
193	if (flaskbuffs and flaskbuffs[1]) then
194		FlaskFrame.t:SetTexture(select(3, GetSpellInfo(flaskbuffs[1])))
195		for i, flaskbuffs in pairs(flaskbuffs) do
196			local spellname = select(1, GetSpellInfo(flaskbuffs))
197			if UnitAura("player", spellname) then
198				FlaskFrame.t:SetTexture(select(3, GetSpellInfo(flaskbuffs)))
199				FlaskFrame:SetAlpha(0.2)
200				break
201			else
202				CheckElixir()
203			end
204		end
205	end
206	
207	if (foodbuffs and foodbuffs[1]) then
208		FoodFrame.t:SetTexture(select(3, GetSpellInfo(foodbuffs[1])))
209		for i, foodbuffs in pairs(foodbuffs) do
210			local spellname = select(1, GetSpellInfo(foodbuffs))
211			if UnitAura("player", spellname) then
212				FoodFrame:SetAlpha(0.2)
213				FoodFrame.t:SetTexture(select(3, GetSpellInfo(foodbuffs)))
214				break
215			else
216				FoodFrame:SetAlpha(1)
217			end
218		end
219	end
220	
221	for i, Spell3Buff in pairs(Spell3Buff) do
222		local spellname = select(1, GetSpellInfo(Spell3Buff))
223		if UnitAura("player", spellname) then
224			Spell3Frame:SetAlpha(0.2)
225			Spell3Frame.t:SetTexture(select(3, GetSpellInfo(Spell3Buff)))
226			break
227		else
228			Spell3Frame:SetAlpha(1)
229			Spell3Frame.t:SetTexture(select(3, GetSpellInfo(Spell3Buff)))
230		end
231	end
232	
233	for i, Spell4Buff in pairs(Spell4Buff) do
234		local spellname = select(1, GetSpellInfo(Spell4Buff))
235		if UnitAura("player", spellname) then
236			Spell4Frame:SetAlpha(0.2)
237			Spell4Frame.t:SetTexture(select(3, GetSpellInfo(Spell4Buff)))
238			break
239		else
240			Spell4Frame:SetAlpha(1)
241			Spell4Frame.t:SetTexture(select(3, GetSpellInfo(Spell4Buff)))
242		end
243	end
244	
245	for i, Spell5Buff in pairs(Spell5Buff) do
246		local spellname = select(1, GetSpellInfo(Spell5Buff))
247		if UnitAura("player", spellname) then
248			Spell5Frame:SetAlpha(0.2)
249			Spell5Frame.t:SetTexture(select(3, GetSpellInfo(Spell5Buff)))
250			break
251		else
252			Spell5Frame:SetAlpha(1)
253			Spell5Frame.t:SetTexture(select(3, GetSpellInfo(Spell5Buff)))
254		end
255	end	
256
257	for i, Spell6Buff in pairs(Spell6Buff) do
258		local spellname = select(1, GetSpellInfo(Spell6Buff))
259		if UnitAura("player", spellname) then
260			Spell6Frame:SetAlpha(0.2)
261			Spell6Frame.t:SetTexture(select(3, GetSpellInfo(Spell6Buff)))
262			break
263		else
264			Spell6Frame:SetAlpha(1)
265			Spell6Frame.t:SetTexture(select(3, GetSpellInfo(Spell6Buff)))
266		end
267	end
268
269end
270
271local bsize = 20
272
273--Create the Main bar
274local raidbuff_reminder = CreateFrame("Frame", "RaidBuffReminder", TukuiMinimap)
275raidbuff_reminder:CreatePanel("Default", bsize + 8, 153, "LEFT", TukuiMinimap, "RIGHT", 3, 0)
276raidbuff_reminder:CreateShadow("Default")
277raidbuff_reminder:RegisterEvent("ACTIVE_TALENT_GROUP_CHANGED")
278raidbuff_reminder:RegisterEvent("UNIT_INVENTORY_CHANGED")
279raidbuff_reminder:RegisterEvent("UNIT_AURA")
280raidbuff_reminder:RegisterEvent("PLAYER_REGEN_ENABLED")
281raidbuff_reminder:RegisterEvent("PLAYER_REGEN_DISABLED")
282raidbuff_reminder:RegisterEvent("PLAYER_ENTERING_WORLD")
283raidbuff_reminder:RegisterEvent("UPDATE_BONUS_ACTIONBAR")
284raidbuff_reminder:RegisterEvent("CHARACTER_POINTS_CHANGED")
285raidbuff_reminder:RegisterEvent("ZONE_CHANGED_NEW_AREA")
286raidbuff_reminder:SetScript("OnEvent", OnAuraChange)
287
288--Function to create buttons
289local function CreateButton(name, relativeTo, firstbutton)
290	local button = CreateFrame("Frame", name, RaidBuffReminder)
291	if firstbutton == true then
292		button:CreatePanel("Default", bsize, bsize, "TOP", relativeTo, "TOP", 0, -4)
293	else
294		button:CreatePanel("Default", bsize, bsize, "TOP", relativeTo, "BOTTOM", 0, -5)
295	end
296	button:SetFrameLevel(RaidBuffReminder:GetFrameLevel() + 2)
297	button.FrameBackdrop = CreateFrame("Frame", nil, button)
298	button.FrameBackdrop:SetTemplate("Default")
299	button.FrameBackdrop:SetPoint("TOPLEFT", -2, 2)
300	button.FrameBackdrop:SetPoint("BOTTOMRIGHT", 2, -2)
301	button.FrameBackdrop:SetFrameLevel(button:GetFrameLevel() - 1)	
302	button.t = button:CreateTexture(name..".t", "OVERLAY")
303	button.t:SetTexCoord(0.1, 0.9, 0.1, 0.9)
304	button.t:SetAllPoints(button)
305end
306
307--Create Buttons
308do
309	CreateButton("FlaskFrame", RaidBuffReminder, true)
310	CreateButton("FoodFrame", FlaskFrame, false)
311	CreateButton("Spell3Frame", FoodFrame, false)
312	CreateButton("Spell4Frame", Spell3Frame, false)
313	CreateButton("Spell5Frame", Spell4Frame, false)
314	CreateButton("Spell6Frame", Spell5Frame, false)
315end