vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | Necronomicon = AceAddonClass:new({ |
2 | name = NECRONOMICON_CONST.Title, |
||
3 | description = NECRONOMICON_CONST.Desc, |
||
4 | version = NECRONOMICON_CONST.Version, |
||
5 | releaseDate = "", |
||
6 | aceCompatible = 103, |
||
7 | author = "Ammo", |
||
8 | email = "wouter@ctlaltdel.nl", |
||
9 | website = "http://www.wowace.com", |
||
10 | category = "interface", |
||
11 | db = AceDbClass:new("NecronomiconDB"), |
||
12 | cmd = AceChatCmdClass:new(NECRONOMICON_CONST.ChatCmd,NECRONOMICON_CONST.ChatOpt), |
||
13 | |||
14 | ---------------------------- |
||
15 | -- Module Loadup -- |
||
16 | ---------------------------- |
||
17 | |||
18 | |||
19 | Initialize = function(self) |
||
20 | self.Compost = CompostLib:GetInstance("compost-1") |
||
21 | self.Metrognome = Metrognome:GetInstance("1") |
||
22 | self.Metrognome:Register("Necronomicon", self.Heartbeat, NECRONOMICON_CONST.UpdateInterval, self ) |
||
23 | end, |
||
24 | |||
25 | Enable = function(self) |
||
26 | if( UnitClass("player") == NECRONOMICON_CONST.Pattern.Warlock ) then |
||
27 | self.shardcount = 0 |
||
28 | self.healthstone = {} |
||
29 | self.soulstone = {} |
||
30 | self.spellstone = {} |
||
31 | self.firestone = {} |
||
32 | self.spells = {} |
||
33 | |||
34 | self.timers = {} |
||
35 | self.timerstext = "" |
||
36 | self.lastupdate = 0 |
||
37 | self.currentspell = {} |
||
38 | self.mounttype = 0 |
||
39 | self.hasdemons = nil |
||
40 | self.soulstonetimer = nil |
||
41 | self.soulstonetarget = nil |
||
42 | self.soulstonestate = nil |
||
43 | |||
44 | if( not self:GetOpt("firsttimedone") ) then |
||
45 | self:SetOpt("timers", TRUE) |
||
46 | self:SetOpt("firsttimedone", TRUE) |
||
47 | end |
||
48 | |||
49 | self:ScanSpells() |
||
50 | self:ScanStones() |
||
51 | |||
52 | self:SetupFrames() |
||
53 | self.frames.main:Show() |
||
54 | self:UpdateButtons() |
||
55 | |||
56 | self:RegisterEvent("BAG_UPDATE") |
||
57 | self:RegisterEvent("NECRONOMICON_BAG_UPDATE") |
||
58 | |||
59 | self:RegisterEvent("SPELLS_CHANGED") |
||
60 | self:RegisterEvent("LEARNED_SPELL_IN_TAB", "SPELLS_CHANGED") |
||
61 | |||
62 | self:RegisterEvent("SPELLCAST_START") |
||
63 | self:RegisterEvent("SPELLCAST_FAILED") |
||
64 | self:RegisterEvent("SPELLCAST_INTERRUPTED") |
||
65 | self:RegisterEvent("SPELLCAST_CHANNEL_START") |
||
66 | -- self:RegisterEvent("SPELLCAST_CHANNEL_STOP") |
||
67 | self:RegisterEvent("SPELLCAST_STOP") |
||
68 | self:RegisterEvent("PLAYER_REGEN_ENABLED") |
||
69 | |||
70 | self:RegisterEvent("CHAT_MSG_SPELL_PERIODIC_SELF_BUFFS") |
||
71 | self:RegisterEvent("CHAT_MSG_SPELL_SELF_DAMAGE") |
||
72 | |||
73 | self:Hook("CastSpell", "OnCastSpell", Necronomicon ) |
||
74 | self:Hook("CastSpellByName", "OnCastSpellByName", Necronomicon ) |
||
75 | self:Hook("UseAction", "OnUseAction", Necronomicon ) |
||
76 | -- self:Hook("UseContainerItem", "OnUseContainerItem" ) |
||
77 | |||
78 | if( self:GetOpt("timers") ) then |
||
79 | self.Metrognome:Start("Necronomicon") |
||
80 | self.frames.timers:Show() |
||
81 | else |
||
82 | self.frames.timers:Hide() |
||
83 | end |
||
84 | end |
||
85 | end, |
||
86 | |||
87 | Disable = function(self) |
||
88 | if( UnitClass("player") == NECRONOMICON_CONST.Pattern.Warlock ) then |
||
89 | -- Stop the heartbeat and hide our main frame |
||
90 | self.Metrognome:Stop("Necronomicon") |
||
91 | self.frames.main:Hide() |
||
92 | |||
93 | self.UnregisterAllEvents() |
||
94 | |||
95 | self:Unhook("CastSpell") |
||
96 | self:Unhook("CastSpellByName") |
||
97 | self:Unhook("UseAction") |
||
98 | -- self:Unhook("UseContainerItem") |
||
99 | end |
||
100 | |||
101 | end, |
||
102 | |||
103 | ---------------------------- |
||
104 | -- General -- |
||
105 | ---------------------------- |
||
106 | |||
107 | GetGradient = function( self, perc ) |
||
108 | local gradient = "|CFF00FF00" -- BrightGreen |
||
109 | |||
110 | if( perc < 10 ) then |
||
111 | gradient = "|CFFFF0000" -- Red |
||
112 | elseif( perc < 20 ) then |
||
113 | gradient = "|CFFFF3300" -- RedOrange |
||
114 | elseif( perc < 30 ) then |
||
115 | gradient = "|CFFFF6600" -- DarkOrange |
||
116 | elseif( perc < 40 ) then |
||
117 | gradient = "|CFFFF9933" -- DirtyOrange |
||
118 | elseif( perc < 50 ) then |
||
119 | gradient = "|CFFFFCC00" -- DarkYellow |
||
120 | elseif( perc < 60 ) then |
||
121 | gradient = "|CFFFFFF66" -- LightYellow |
||
122 | elseif( perc < 70 ) then |
||
123 | gradient = "|CFFCCFF66" -- YellowGreen |
||
124 | elseif( perc < 80 ) then |
||
125 | gradient = "|CFF99FF66" -- LightGreen |
||
126 | elseif( perc < 90 ) then |
||
127 | gradient = "|CFF66FF66" -- LighterGreen |
||
128 | end |
||
129 | return gradient |
||
130 | end, |
||
131 | |||
132 | ScanStones = function( self ) |
||
133 | local bag |
||
134 | local shards = 0 |
||
135 | local itemLink |
||
136 | self.Compost:Erase(self.healthstone) |
||
137 | self.Compost:Erase(self.soulstone) |
||
138 | self.Compost:Erase(self.spellstone) |
||
139 | self.Compost:Erase(self.firestone) |
||
140 | for bag = 4, 0, -1 do |
||
141 | local size = GetContainerNumSlots(bag) |
||
142 | if (size > 0) then |
||
143 | local slot |
||
144 | for slot=1, size, 1 do |
||
145 | if (GetContainerItemLink(bag,slot)) then |
||
146 | itemLink = GetContainerItemLink(bag,slot) |
||
147 | if( string.find( itemLink, NECRONOMICON_CONST.Pattern.Shard ) and |
||
148 | not string.find( itemLink, NECRONOMICON_CONST.Pattern.Corrupted ) ) then |
||
149 | shards = shards + 1 |
||
150 | elseif( string.find( itemLink, NECRONOMICON_CONST.Pattern.Healthstone ) ) then |
||
151 | self.healthstone[0] = bag |
||
152 | self.healthstone[1] = slot |
||
153 | elseif( string.find( itemLink, NECRONOMICON_CONST.Pattern.Soulstone ) ) then |
||
154 | self.soulstone[0] = bag |
||
155 | self.soulstone[1] = slot |
||
156 | elseif( string.find( itemLink, NECRONOMICON_CONST.Pattern.Spellstone ) ) then |
||
157 | self.spellstone[0] = bag |
||
158 | self.spellstone[1] = slot |
||
159 | self.spellstone[2] = FALSE -- not equipped |
||
160 | elseif( string.find( itemLink, NECRONOMICON_CONST.Pattern.Firestone ) ) then |
||
161 | self.firestone[0] = bag |
||
162 | self.firestone[1] = slot |
||
163 | self.firestone[2] = FALSE -- not equipped |
||
164 | end |
||
165 | end |
||
166 | end |
||
167 | end |
||
168 | end |
||
169 | if( GetInventoryItemLink("player",GetInventorySlotInfo("SecondaryHandSlot") ) ) then |
||
170 | itemLink = GetInventoryItemLink("player",GetInventorySlotInfo("SecondaryHandSlot") ) |
||
171 | if( string.find( itemLink, NECRONOMICON_CONST.Pattern.Spellstone ) ) then |
||
172 | self.spellstone[0] = TRUE |
||
173 | self.spellstone[1] = TRUE |
||
174 | self.spellstone[2] = TRUE -- equipped |
||
175 | elseif( string.find( itemLink, NECRONOMICON_CONST.Pattern.Firestone ) ) then |
||
176 | self.firestone[0] = TRUE |
||
177 | self.firestone[1] = TRUE |
||
178 | self.firestone[2] = TRUE -- equipped |
||
179 | end |
||
180 | end |
||
181 | self.shardcount = shards |
||
182 | end, |
||
183 | |||
184 | ScanSpells = function( self ) |
||
185 | |||
186 | local spellName, spellRank, spellTotal, id, rank, maxrank, rankedSpell |
||
187 | local spellLevel = {} |
||
188 | |||
189 | self.spells.normal = {} |
||
190 | self.spells.timed = {} |
||
191 | self.spells.timedid = {} |
||
192 | self.spells.timedname = {} |
||
193 | self.spells.timeddisplay = {} |
||
194 | |||
195 | for id = 1, 180 do |
||
196 | rankedSpell = nil |
||
197 | spellName, spellRank = GetSpellName(id, "spell") |
||
198 | if (spellName) then |
||
199 | if( spellRank and spellRank ~= "" ) then |
||
200 | spellTotal = spellName .. " " .. spellRank |
||
201 | else |
||
202 | spellTotal = spellName |
||
203 | end |
||
204 | |||
205 | if( NECRONOMICON_CONST.Spell[spellName] ) then |
||
206 | self.spells.normal[NECRONOMICON_CONST.Spell[spellName]] = id |
||
207 | self.hasdemons = 1 |
||
208 | end |
||
209 | -- self:Msg("Spell: ##"..spellTotal.."##") |
||
210 | if( NECRONOMICON_CONST.RankedSpell[spellTotal] ) then |
||
211 | local thistag, thislevel |
||
212 | thistag = NECRONOMICON_CONST.RankedSpell[spellTotal][1] |
||
213 | thislevel = NECRONOMICON_CONST.RankedSpell[spellTotal][2] |
||
214 | if( not spellLevel[thistag] or thislevel > spellLevel[thistag] ) then |
||
215 | self.spells.normal[thistag] = id |
||
216 | spellLevel[thistag] = thislevel |
||
217 | if( thistag == "MOUNT" ) then |
||
218 | self.mounttype = thislevel |
||
219 | end |
||
220 | end |
||
221 | end |
||
222 | |||
223 | if( NECRONOMICON_CONST.RankedSpell[spellName] ) then |
||
224 | rankedSpell = spellName |
||
225 | end |
||
226 | if( NECRONOMICON_CONST.RankedSpell[spellTotal] ) then |
||
227 | rankedSpell = spellTotal |
||
228 | end |
||
229 | |||
230 | if( rankedSpell ) then |
||
231 | local thistag, thislevel |
||
232 | thistag = NECRONOMICON_CONST.RankedSpell[rankedSpell][1] |
||
233 | thislevel = NECRONOMICON_CONST.RankedSpell[rankedSpell][2] |
||
234 | if( not spellLevel[thistag] or thislevel > spellLevel[thistag] ) then |
||
235 | self.spells.normal[thistag] = id |
||
236 | spellLevel[thistag] = thislevel |
||
237 | if( thistag == "MOUNT" ) then |
||
238 | self.mounttype = thislevel |
||
239 | end |
||
240 | end |
||
241 | end |
||
242 | |||
243 | if( NECRONOMICON_CONST.TimedSpell[spellName] ) then |
||
244 | maxrank = 0 |
||
245 | if (string.find(spellRank, NECRONOMICON_CONST.Pattern.Rank )) then |
||
246 | for rank in string.gfind( spellRank, NECRONOMICON_CONST.Pattern.Rank ) do |
||
247 | rank = tonumber(rank) |
||
248 | if( rank > maxrank ) then |
||
249 | maxrank = rank |
||
250 | end |
||
251 | end |
||
252 | end |
||
253 | if( maxrank == 0 ) then |
||
254 | maxrank = 1 |
||
255 | end |
||
256 | if( not spellLevel[spellName] or maxrank > spellLevel[spellName] ) then |
||
257 | self.spells.timedname[strlower(spellName)] = strlower(spellTotal) |
||
258 | end |
||
259 | self.spells.timedid[id] = strlower(spellTotal) |
||
260 | self.spells.timed[strlower(spellTotal)] = NECRONOMICON_CONST.TimedSpell[spellName][maxrank] |
||
261 | self.spells.timeddisplay[strlower(spellTotal)] = spellName |
||
262 | end |
||
263 | end |
||
264 | end |
||
265 | end, |
||
266 | |||
267 | |||
268 | GetTargetInfo = function( self ) |
||
269 | |||
270 | local targetInfo = { } |
||
271 | |||
272 | if( UnitExists("target") ) then |
||
273 | |||
274 | targetInfo.Name = UnitName("target") |
||
275 | targetInfo.Sex = UnitSex("target") |
||
276 | targetInfo.Level = UnitLevel("target") |
||
277 | if( targetInfo.Level == -1 ) then targetInfo.Level = "??" end |
||
278 | |||
279 | targetInfo.Classification = UnitClassification("target") |
||
280 | if( targetInfo.Classification == "worldboss" ) then |
||
281 | targetInfo.Classification = "b+" |
||
282 | elseif( targetInfo.Classification == "rareelite" ) then |
||
283 | targetInfo.Classification = "r+" |
||
284 | elseif( targetInfo.Classification == "elite" ) then |
||
285 | targetInfo.Classification = "+" |
||
286 | elseif( targetInfo.Classification == "rare" ) then |
||
287 | targetInfo.Classification = "r" |
||
288 | else |
||
289 | targetInfo.Classification = "" |
||
290 | end |
||
291 | |||
292 | targetInfo.IsPlayer = UnitIsPlayer("target") |
||
293 | targetInfo.IsEnemy = UnitCanAttack("player", "target") |
||
294 | targetInfo.Id = targetInfo.Name..targetInfo.Sex..targetInfo.Level |
||
295 | targetInfo.Display = "["..targetInfo.Level..targetInfo.Classification.."] "..targetInfo.Name |
||
296 | |||
297 | return targetInfo |
||
298 | else |
||
299 | return FALSE |
||
300 | end |
||
301 | |||
302 | end, |
||
303 | |||
304 | RegisterSpellCast = function( self, spell ) |
||
305 | |||
306 | if( not self:GetOpt("timers") ) then return end |
||
307 | |||
308 | if( self.currentspell.state and |
||
309 | self.currentspell.state == NECRONOMICON_CONST.State.Start ) then |
||
310 | -- We do nothing. This happens when you cast a spell with a duration and |
||
311 | -- after that cast another spell, which attempt to register with the timers. |
||
312 | -- the state will be > 1 when SPELLCAST_START has fired we are casting atm. |
||
313 | -- so ignore this cast. |
||
314 | return |
||
315 | end |
||
316 | |||
317 | -- We reset the current spellcast whatever happens next. |
||
318 | self.Compost:Erase( self.currentspell ) |
||
319 | |||
320 | -- Not a valid spell? don't do a thing |
||
321 | if( not self.spells.timed[spell] ) then return end |
||
322 | |||
323 | -- If we don't have a target this spell is not worth monitoring for our purposes |
||
324 | local target = self:GetTargetInfo() |
||
325 | if( not target ) then return end |
||
326 | |||
327 | -- Valid Spell, Valid target |
||
328 | self.currentspell.state = NECRONOMICON_CONST.State.Cast |
||
329 | self.currentspell.target = target |
||
330 | self.currentspell.spell = spell |
||
331 | self.currentspell.spelldisplay = self.spells.timeddisplay[spell] |
||
332 | self.currentspell.duration = self.spells.timed[spell] |
||
333 | |||
334 | -- self:Msg( "Registered t:"..self.currentspell.target.Display.." s: "..self.currentspell.spell.." d: "..self.currentspell.duration ) |
||
335 | end, |
||
336 | |||
337 | DeleteSoulstoneTimer = function( self ) |
||
338 | self.soulstonetimer = nil |
||
339 | self.soulstonetarget = nil |
||
340 | if( self:GetOpt("soulstonesound") ) then |
||
341 | PlaySoundFile("Interface\\AddOns\\Necronomicon\\Sounds\\Soulstone.mp3") |
||
342 | end |
||
343 | end, |
||
344 | |||
345 | ClearTimers = function( self ) |
||
346 | local i,j |
||
347 | for i in pairs( self.timers ) do |
||
348 | for j in pairs( self.timers[i] ) do |
||
349 | if( j ~= "name" and j ~= "nr" ) then |
||
350 | Timex:DeleteSchedule("Necronomicon Timers "..i..j) |
||
351 | end |
||
352 | end |
||
353 | end |
||
354 | self.Compost:Erase( self.timers ) |
||
355 | end, |
||
356 | |||
357 | TimerDeleteSpell = function( self, mindex, sindex ) |
||
358 | if( self.timers[mindex] ) then |
||
359 | if( self.timers[mindex][sindex] ) then |
||
360 | self.timers[mindex][sindex]["duration"] = nil |
||
361 | self.timers[mindex][sindex] = nil |
||
362 | self.timers[mindex]["nr"] = self.timers[mindex]["nr"] - 1 |
||
363 | end |
||
364 | if( self.timers[mindex]["nr"] < 1 ) then |
||
365 | self.timers[mindex]["name"] = nil |
||
366 | self.timers[mindex]["nr"] = nil |
||
367 | self.timers[mindex] = nil |
||
368 | end |
||
369 | end |
||
370 | end, |
||
371 | |||
372 | TimerAddSpell = function( self ) |
||
373 | local mindex = self.currentspell.target.Id |
||
374 | local sindex = self.currentspell.spelldisplay |
||
375 | if( self.timers[mindex] ) then |
||
376 | if( self.timers[mindex][sindex] ) then |
||
377 | -- self:Msg("AddSpell Updating "..mindex..sindex ) |
||
378 | self.currentspell.state = NECRONOMICON_CONST.State.Update |
||
379 | self.currentspell.oldduration = Timex:ScheduleCheck("Necronomicon Timers "..mindex..sindex, TRUE) |
||
380 | Timex:DeleteSchedule("Necronomicon Timers "..mindex..sindex ) |
||
381 | Timex:AddSchedule("Necronomicon Timers "..mindex..sindex, self.currentspell.duration, nil, nil, Necronomicon.TimerDeleteSpell, Necronomicon, mindex, sindex ) |
||
382 | self.timers[mindex][sindex]["duration"] = self.currentspell.duration |
||
383 | else |
||
384 | -- self:Msg("AddSpell Newspell "..mindex..sindex ) |
||
385 | self.currentspell.state = NECRONOMICON_CONST.State.NewSpell |
||
386 | self.timers[mindex][sindex] = {} |
||
387 | self.timers[mindex][sindex]["duration"] = self.currentspell.duration |
||
388 | self.timers[mindex]["nr"] = self.timers[mindex]["nr"] + 1 |
||
389 | Timex:AddSchedule("Necronomicon Timers "..mindex..sindex, self.currentspell.duration, nil, nil, Necronomicon.TimerDeleteSpell, Necronomicon, mindex, sindex ) |
||
390 | end |
||
391 | else |
||
392 | -- self:Msg("AddSpell Newmonster&spell "..mindex..sindex ) |
||
393 | self.currentspell.state = NECRONOMICON_CONST.State.NewMonsterNewSpell |
||
394 | self.timers[mindex] = {} |
||
395 | self.timers[mindex]["nr"] = 0 |
||
396 | self.timers[mindex]["name"] = self.currentspell.target.Display |
||
397 | self.timers[mindex][sindex] = {} |
||
398 | self.timers[mindex][sindex]["duration"] = self.currentspell.duration |
||
399 | self.timers[mindex]["nr"] = self.timers[mindex]["nr"] + 1 |
||
400 | Timex:AddSchedule("Necronomicon Timers "..mindex..sindex, self.currentspell.duration, nil, nil, Necronomicon.TimerDeleteSpell, Necronomicon, mindex, sindex ) |
||
401 | end |
||
402 | end, |
||
403 | |||
404 | TimerRollback = function( self ) |
||
405 | local mindex = self.currentspell.target.Id |
||
406 | local sindex = self.currentspell.spelldisplay |
||
407 | local i |
||
408 | if( not mindex or not sindex ) then return end |
||
409 | if( self.currentspell.state == NECRONOMICON_CONST.State.NewMonsterNewSpell ) then |
||
410 | if( self.timers[mindex] and self.timers[mindex][sindex] ) then |
||
411 | self.timers[mindex][sindex]["duration"] = nil |
||
412 | self.timers[mindex][sindex] = nil |
||
413 | self.timers[mindex]["name"] = nil |
||
414 | self.timers[mindex]["nr"] = nil |
||
415 | self.timers[mindex] = nil |
||
416 | Timex:DeleteSchedule( "Necronomicon Timers "..mindex..sindex ) |
||
417 | end |
||
418 | elseif( self.currentspell.state == NECRONOMICON_CONST.State.NewSpell ) then |
||
419 | if( self.timers[mindex] and self.timers[mindex][sindex] ) then |
||
420 | self.timers[mindex][sindex]["duration"] = nil |
||
421 | self.timers[mindex][sindex] = nil |
||
422 | self.timers[mindex]["nr"] = self.timers[mindex]["nr"] - 1 |
||
423 | Timex:DeleteSchedule( "Necronomicon Timers "..mindex..sindex ) |
||
424 | end |
||
425 | elseif( self.currentspell.state == NECRONOMICON_CONST.State.Update ) then |
||
426 | Timex:DeleteSchedule( "Necronomicon Timers "..mindex..sindex ) |
||
427 | Timex:AddSchedule( "Necronomicon Timers "..mindex..sindex, (self.currentspell.duration - self.currentspell.oldduration), nil, nil, Necronomicon.TimerDeleteSpell, Necronomicon, mindex, sindex ) |
||
428 | end |
||
429 | end, |
||
430 | |||
431 | SendChatMessage = function( self, msg ) |
||
432 | if (GetNumRaidMembers() > 0) then |
||
433 | SendChatMessage(msg, "RAID"); |
||
434 | elseif (GetNumPartyMembers() > 0) then |
||
435 | SendChatMessage(msg, "PARTY"); |
||
436 | else |
||
437 | SendChatMessage(msg, "SAY"); |
||
438 | end |
||
439 | end, |
||
440 | |||
441 | BuildTime = function( self, duration ) |
||
442 | local minute |
||
443 | if( duration > 59 ) then |
||
444 | minute = floor( duration / 60 ) |
||
445 | duration = duration - (minute *60) |
||
446 | else |
||
447 | minute = 0 |
||
448 | end |
||
449 | if( minute < 10 ) then minute = "0"..minute end |
||
450 | if( duration < 10 ) then duration = "0"..duration end |
||
451 | return minute..":"..duration |
||
452 | end, |
||
453 | |||
454 | SummonDemon = function( self, spellid ) |
||
455 | local modifier = self:GetOpt("feldommodifier") |
||
456 | local modused = nil |
||
457 | |||
458 | if( modifier == "ctrl" and IsControlKeyDown() ) then |
||
459 | modused = TRUE |
||
460 | elseif( modifier == "alt" and IsAltKeyDown() ) then |
||
461 | modused = TRUE |
||
462 | elseif( modifier == "shift" and IsShiftKeyDown() ) then |
||
463 | modused = TRUE |
||
464 | end |
||
465 | if( modused and self.spells.normal["FELDOMINATION"] ) then |
||
466 | local start, dur = GetSpellCooldown( self.spells.normal["FELDOMINATION"], BOOKTYPE_SPELL ) |
||
467 | if( start == 0 and dur == 0 ) then |
||
468 | CastSpell(self.spells.normal["FELDOMINATION"], BOOKTYPE_SPELL ) |
||
469 | SpellStopCasting() |
||
470 | end |
||
471 | end |
||
472 | CastSpell( spellid, BOOKTYPE_SPELL ) |
||
473 | if( self:GetOpt("closeonclick") ) then |
||
474 | self:DemonsClicked() |
||
475 | end |
||
476 | end, |
||
477 | |||
478 | |||
479 | CastDemonsMenu = function( self, spellid ) |
||
480 | CastSpell( spellid, BOOKTYPE_SPELL ) |
||
481 | if( self:GetOpt("closeonclick") ) then |
||
482 | self:DemonsClicked() |
||
483 | end |
||
484 | end, |
||
485 | |||
486 | ---------------------------- |
||
487 | -- GUI Updating Functions -- |
||
488 | ---------------------------- |
||
489 | |||
490 | SetupFrames = function( self ) |
||
491 | local x, y |
||
492 | self.frames = {} |
||
493 | self.frames.main = CreateFrame( "Frame", nil, UIParent ) |
||
494 | self.frames.main.owner = self |
||
495 | self.frames.main:Hide() |
||
496 | self.frames.main:EnableMouse(true) |
||
497 | self.frames.main:SetMovable(true) |
||
498 | self.frames.main:SetWidth(1) |
||
499 | self.frames.main:SetHeight(1) |
||
500 | if( self:GetOpt("mainx") and self:GetOpt("mainy") ) then |
||
501 | x = self:GetOpt("mainx") |
||
502 | y = self:GetOpt("mainy") |
||
503 | self.frames.main:SetPoint("TOPLEFT", UIParent, "TOPLEFT", x, y ) |
||
504 | else |
||
505 | self.frames.main:SetPoint("TOPLEFT", UIParent, "TOPLEFT", 150, -150) |
||
506 | end |
||
507 | |||
508 | -- Graphical Shardcounter |
||
509 | self.frames.shard = CreateFrame( "Button", nil, self.frames.main ) |
||
510 | self.frames.shard.owner = self |
||
511 | self.frames.shard:SetWidth(64) |
||
512 | self.frames.shard:SetHeight(64) |
||
513 | self.frames.shard:SetPoint("CENTER", self.frames.main, "CENTER" ) |
||
514 | self.frames.shard:RegisterForDrag("LeftButton") |
||
515 | self.frames.shard:SetScript("OnDragStart", function() this.owner.frames.main:StartMoving() end ) |
||
516 | self.frames.shard:SetScript("OnDragStop", |
||
517 | function() |
||
518 | this.owner.frames.main:StopMovingOrSizing() |
||
519 | local _,_,_,x,y = this.owner.frames.main:GetPoint("CENTER") |
||
520 | this.owner:SetOpt("mainx", x) |
||
521 | this.owner:SetOpt("mainy", y) |
||
522 | end |
||
523 | ) |
||
524 | |||
525 | |||
526 | -- Text inside the counter |
||
527 | self.frames.shardtext = self.frames.shard:CreateFontString(nil, "OVERLAY") |
||
528 | self.frames.shardtext.owner = self |
||
529 | self.frames.shardtext:SetFontObject(GameFontNormalSmall) |
||
530 | self.frames.shardtext:ClearAllPoints() |
||
531 | self.frames.shardtext:SetTextColor(1, 1, 1, 1) |
||
532 | self.frames.shardtext:SetWidth(64) |
||
533 | self.frames.shardtext:SetHeight(64) |
||
534 | self.frames.shardtext:SetPoint("TOPLEFT", self.frames.shard, "TOPLEFT") |
||
535 | self.frames.shardtext:SetJustifyH("CENTER") |
||
536 | self.frames.shardtext:SetJustifyV("MIDDLE") |
||
537 | |||
538 | -- Healthstone button |
||
539 | self.frames.healthstone = CreateFrame("Button", nil, self.frames.main ) |
||
540 | self.frames.healthstone.owner = self |
||
541 | self.frames.healthstone:SetWidth(32) |
||
542 | self.frames.healthstone:SetHeight(32) |
||
543 | self.frames.healthstone:SetPoint("CENTER", self.frames.main, "CENTER", -14, -45 ) |
||
544 | self.frames.healthstone:SetNormalTexture( "Interface\\AddOns\\Necronomicon\\Images\\EmptyButton" ) |
||
545 | self.frames.healthstone:SetHighlightTexture( "Interface\\Minimap\\UI-Minimap-ZoomButton-Highlight" ) |
||
546 | self.frames.healthstone:SetScript("OnClick", function() this.owner:HealthstoneClicked() end ) |
||
547 | |||
548 | -- Soulstone button |
||
549 | self.frames.soulstone = CreateFrame("Button", nil, self.frames.main ) |
||
550 | self.frames.soulstone.owner = self |
||
551 | self.frames.soulstone:SetWidth(32) |
||
552 | self.frames.soulstone:SetHeight(32) |
||
553 | self.frames.soulstone:SetPoint("CENTER", self.frames.main, "CENTER", -40, -33 ) |
||
554 | self.frames.soulstone:SetNormalTexture( "Interface\\AddOns\\Necronomicon\\Images\\EmptyButton" ) |
||
555 | self.frames.soulstone:SetHighlightTexture( "Interface\\Minimap\\UI-Minimap-ZoomButton-Highlight" ) |
||
556 | self.frames.soulstone:SetScript("OnClick", function() this.owner:SoulstoneClicked() end ) |
||
557 | |||
558 | -- Spellstone button |
||
559 | self.frames.spellstone = CreateFrame("Button", nil, self.frames.main ) |
||
560 | self.frames.spellstone.owner = self |
||
561 | self.frames.spellstone:SetWidth(32) |
||
562 | self.frames.spellstone:SetHeight(32) |
||
563 | self.frames.spellstone:SetPoint("CENTER", self.frames.main, "CENTER", 14, -45 ) |
||
564 | self.frames.spellstone:SetNormalTexture( "Interface\\AddOns\\Necronomicon\\Images\\EmptyButton" ) |
||
565 | self.frames.spellstone:SetHighlightTexture( "Interface\\Minimap\\UI-Minimap-ZoomButton-Highlight" ) |
||
566 | self.frames.spellstone:SetScript("OnClick", function() this.owner:SpellstoneClicked() end ) |
||
567 | |||
568 | -- Firestone button |
||
569 | self.frames.firestone = CreateFrame("Button", nil, self.frames.main ) |
||
570 | self.frames.firestone.owner = self |
||
571 | self.frames.firestone:SetWidth(32) |
||
572 | self.frames.firestone:SetHeight(32) |
||
573 | self.frames.firestone:SetPoint("CENTER", self.frames.main, "CENTER", 40, -33 ) |
||
574 | self.frames.firestone:SetNormalTexture( "Interface\\AddOns\\Necronomicon\\Images\\EmptyButton" ) |
||
575 | self.frames.firestone:SetHighlightTexture( "Interface\\Minimap\\UI-Minimap-ZoomButton-Highlight" ) |
||
576 | self.frames.firestone:SetScript("OnClick", function() this.owner:FirestoneClicked() end ) |
||
577 | |||
578 | -- Demons button |
||
579 | self.frames.demons = CreateFrame("Button", nil, self.frames.main ) |
||
580 | self.frames.demons.owner = self |
||
581 | self.frames.demons:SetWidth(32) |
||
582 | self.frames.demons:SetHeight(32) |
||
583 | self.frames.demons:SetPoint("CENTER", self.frames.main, "CENTER", -40, 33 ) |
||
584 | self.frames.demons:SetNormalTexture( "Interface\\AddOns\\Necronomicon\\Images\\EmptyButton" ) |
||
585 | self.frames.demons:SetHighlightTexture( "Interface\\Minimap\\UI-Minimap-ZoomButton-Highlight" ) |
||
586 | self.frames.demons:SetScript("OnClick", function() this.owner:DemonsClicked() end ) |
||
587 | |||
588 | -- Mount button |
||
589 | self.frames.mount = CreateFrame("Button", nil, self.frames.main ) |
||
590 | self.frames.mount.owner = self |
||
591 | self.frames.mount:SetWidth(32) |
||
592 | self.frames.mount:SetHeight(32) |
||
593 | self.frames.mount:SetPoint("CENTER", self.frames.main, "CENTER", -14, 45 ) |
||
594 | self.frames.mount:SetNormalTexture( "Interface\\AddOns\\Necronomicon\\Images\\EmptyButton" ) |
||
595 | self.frames.mount:SetHighlightTexture( "Interface\\Minimap\\UI-Minimap-ZoomButton-Highlight" ) |
||
596 | self.frames.mount:SetScript("OnClick", function() this.owner:MountClicked() end ) |
||
597 | |||
598 | -- Demon Armor button |
||
599 | self.frames.armor = CreateFrame("Button", nil, self.frames.main ) |
||
600 | self.frames.armor.owner = self |
||
601 | self.frames.armor:SetWidth(32) |
||
602 | self.frames.armor:SetHeight(32) |
||
603 | self.frames.armor:SetPoint("CENTER", self.frames.main, "CENTER", 14, 45 ) |
||
604 | self.frames.armor:SetNormalTexture( "Interface\\AddOns\\Necronomicon\\Images\\EmptyButton" ) |
||
605 | self.frames.armor:SetHighlightTexture( "Interface\\Minimap\\UI-Minimap-ZoomButton-Highlight" ) |
||
606 | self.frames.armor:SetScript("OnClick", function() this.owner:ArmorClicked() end ) |
||
607 | |||
608 | -- Summon button |
||
609 | self.frames.summon = CreateFrame("Button", nil, self.frames.main ) |
||
610 | self.frames.summon.owner = self |
||
611 | self.frames.summon:SetWidth(32) |
||
612 | self.frames.summon:SetHeight(32) |
||
613 | self.frames.summon:SetPoint("CENTER", self.frames.main, "CENTER", 40, 33 ) |
||
614 | self.frames.summon:SetNormalTexture( "Interface\\AddOns\\Necronomicon\\Images\\EmptyButton" ) |
||
615 | self.frames.summon:SetHighlightTexture( "Interface\\Minimap\\UI-Minimap-ZoomButton-Highlight" ) |
||
616 | self.frames.summon:SetScript("OnClick", function() this.owner:SummonClicked() end ) |
||
617 | |||
618 | |||
619 | -- Teh Demons |
||
620 | self.frames.demonmenu = CreateFrame("Frame", nil, self.frames.demons ) |
||
621 | self.frames.demonmenu.owner = self |
||
622 | self.frames.demonmenu:SetWidth(1) |
||
623 | self.frames.demonmenu:SetHeight(1) |
||
624 | self.frames.demonmenu:SetPoint("TOPRIGHT", self.frames.demons, "TOPLEFT" ) |
||
625 | self.frames.demonmenu:Hide() |
||
626 | |||
627 | -- Imp |
||
628 | self.frames.imp = CreateFrame("Button", nil, self.frames.demonmenu ) |
||
629 | self.frames.imp.owner = self |
||
630 | self.frames.imp:SetWidth(36) |
||
631 | self.frames.imp:SetHeight(36) |
||
632 | self.frames.imp:SetNormalTexture( "Interface\\Icons\\Spell_Shadow_SummonImp") |
||
633 | self.frames.imp:SetHighlightTexture( "Interface\\Buttons\\ButtonHilight-Square" ) |
||
634 | self.frames.imp:SetPoint("TOPRIGHT", self.frames.demonmenu, "TOPLEFT", 0, 0 ) |
||
635 | self.frames.imp:SetScript("OnClick", function() this.owner:SummonDemon( this.owner.spells.normal["IMP"] ) end ) |
||
636 | |||
637 | -- Voidwalker |
||
638 | self.frames.voidwalker = CreateFrame("Button", nil, self.frames.demonmenu ) |
||
639 | self.frames.voidwalker.owner = self |
||
640 | self.frames.voidwalker:SetWidth(36) |
||
641 | self.frames.voidwalker:SetHeight(36) |
||
642 | self.frames.voidwalker:SetNormalTexture( "Interface\\Icons\\Spell_Shadow_SummonVoidwalker") |
||
643 | self.frames.voidwalker:SetHighlightTexture( "Interface\\Buttons\\ButtonHilight-Square" ) |
||
644 | self.frames.voidwalker:SetPoint("TOPRIGHT", self.frames.demonmenu, "TOPLEFT", -36, 0 ) |
||
645 | self.frames.voidwalker:SetScript("OnClick", function() this.owner:SummonDemon( this.owner.spells.normal["VOIDWALKER"] ) end ) |
||
646 | |||
647 | -- Succubus |
||
648 | self.frames.succubus = CreateFrame("Button", nil, self.frames.demonmenu ) |
||
649 | self.frames.succubus.owner = self |
||
650 | self.frames.succubus:SetWidth(36) |
||
651 | self.frames.succubus:SetHeight(36) |
||
652 | self.frames.succubus:SetNormalTexture( "Interface\\Icons\\Spell_Shadow_SummonSuccubus") |
||
653 | self.frames.succubus:SetHighlightTexture( "Interface\\Buttons\\ButtonHilight-Square" ) |
||
654 | self.frames.succubus:SetPoint("TOPRIGHT", self.frames.demonmenu, "TOPLEFT", -72, 0 ) |
||
655 | self.frames.succubus:SetScript("OnClick", function() this.owner:SummonDemon( this.owner.spells.normal["SUCCUBUS"] ) end ) |
||
656 | |||
657 | -- Felhunter |
||
658 | self.frames.felhunter = CreateFrame("Button", nil, self.frames.demonmenu ) |
||
659 | self.frames.felhunter.owner = self |
||
660 | self.frames.felhunter:SetWidth(36) |
||
661 | self.frames.felhunter:SetHeight(36) |
||
662 | self.frames.felhunter:SetNormalTexture( "Interface\\Icons\\Spell_Shadow_SummonFelhunter") |
||
663 | self.frames.felhunter:SetHighlightTexture( "Interface\\Buttons\\ButtonHilight-Square" ) |
||
664 | self.frames.felhunter:SetPoint("TOPRIGHT", self.frames.demonmenu, "TOPLEFT", -108, 0 ) |
||
665 | self.frames.felhunter:SetScript("OnClick", function() this.owner:SummonDemon( this.owner.spells.normal["FELHUNTER"] ) end ) |
||
666 | |||
667 | -- Inferno |
||
668 | self.frames.inferno = CreateFrame("Button", nil, self.frames.demonmenu ) |
||
669 | self.frames.inferno.owner = self |
||
670 | self.frames.inferno:SetWidth(36) |
||
671 | self.frames.inferno:SetHeight(36) |
||
672 | self.frames.inferno:SetNormalTexture( "Interface\\Icons\\Spell_Shadow_SummonInfernal") |
||
673 | self.frames.inferno:SetHighlightTexture( "Interface\\Buttons\\ButtonHilight-Square" ) |
||
674 | self.frames.inferno:SetPoint("TOPRIGHT", self.frames.demonmenu, "TOPLEFT", -108, -36 ) |
||
675 | self.frames.inferno:SetScript("OnClick", function() this.owner:CastDemonsMenu( this.owner.spells.normal["INFERNO"] ) end ) |
||
676 | |||
677 | -- Eye of Kilrogg |
||
678 | self.frames.kilrogg = CreateFrame("Button", nil, self.frames.demonmenu ) |
||
679 | self.frames.kilrogg.owner = self |
||
680 | self.frames.kilrogg:SetWidth(36) |
||
681 | self.frames.kilrogg:SetHeight(36) |
||
682 | self.frames.kilrogg:SetNormalTexture( "Interface\\Icons\\Spell_Shadow_EvilEye") |
||
683 | self.frames.kilrogg:SetHighlightTexture( "Interface\\Buttons\\ButtonHilight-Square" ) |
||
684 | self.frames.kilrogg:SetPoint("TOPRIGHT", self.frames.demonmenu, "TOPLEFT", -72, -36 ) |
||
685 | self.frames.kilrogg:SetScript("OnClick", function() this.owner:CastDemonsMenu( this.owner.spells.normal["KILROGG"] ) end ) |
||
686 | |||
687 | -- Health Funnel |
||
688 | self.frames.healthfunnel = CreateFrame("Button", nil, self.frames.demonmenu ) |
||
689 | self.frames.healthfunnel.owner = self |
||
690 | self.frames.healthfunnel:SetWidth(36) |
||
691 | self.frames.healthfunnel:SetHeight(36) |
||
692 | self.frames.healthfunnel:SetNormalTexture( "Interface\\Icons\\Spell_Shadow_LifeDrain") |
||
693 | self.frames.healthfunnel:SetHighlightTexture( "Interface\\Buttons\\ButtonHilight-Square" ) |
||
694 | self.frames.healthfunnel:SetPoint("TOPRIGHT", self.frames.demonmenu, "TOPLEFT", -36, -36 ) |
||
695 | self.frames.healthfunnel:SetScript("OnClick", function() this.owner:CastDemonsMenu( this.owner.spells.normal["HEALTHFUNNEL"] ) end ) |
||
696 | |||
697 | -- Ritual of Doom |
||
698 | self.frames.doomguard = CreateFrame("Button", nil, self.frames.demonmenu ) |
||
699 | self.frames.doomguard.owner = self |
||
700 | self.frames.doomguard:SetWidth(36) |
||
701 | self.frames.doomguard:SetHeight(36) |
||
702 | self.frames.doomguard:SetNormalTexture( "Interface\\Icons\\Spell_Shadow_AntiMagicShell") |
||
703 | self.frames.doomguard:SetHighlightTexture( "Interface\\Buttons\\ButtonHilight-Square" ) |
||
704 | self.frames.doomguard:SetPoint("TOPRIGHT", self.frames.demonmenu, "TOPLEFT", -108, -72 ) |
||
705 | self.frames.doomguard:SetScript("OnClick", function() this.owner:CastDemonsMenu( this.owner.spells.normal["DOOMGUARD"] ) end ) |
||
706 | |||
707 | -- Fel Domination |
||
708 | self.frames.feldomination = CreateFrame("Button", nil, self.frames.demonmenu ) |
||
709 | self.frames.feldomination.owner = self |
||
710 | self.frames.feldomination:SetWidth(36) |
||
711 | self.frames.feldomination:SetHeight(36) |
||
712 | self.frames.feldomination:SetNormalTexture( "Interface\\Icons\\Spell_Nature_RemoveCurse") |
||
713 | self.frames.feldomination:SetHighlightTexture( "Interface\\Buttons\\ButtonHilight-Square" ) |
||
714 | self.frames.feldomination:SetPoint("TOPRIGHT", self.frames.demonmenu, "TOPLEFT", -0, -36 ) |
||
715 | self.frames.feldomination:SetScript("OnClick", function() this.owner:CastDemonsMenu( this.owner.spells.normal["FELDOMINATION"] ) end ) |
||
716 | |||
717 | -- Demonic Sacrifice |
||
718 | self.frames.demonicsacrifice = CreateFrame("Button", nil, self.frames.demonmenu ) |
||
719 | self.frames.demonicsacrifice.owner = self |
||
720 | self.frames.demonicsacrifice:SetWidth(36) |
||
721 | self.frames.demonicsacrifice:SetHeight(36) |
||
722 | self.frames.demonicsacrifice:SetNormalTexture( "Interface\\Icons\\Spell_Shadow_PsychicScream") |
||
723 | self.frames.demonicsacrifice:SetHighlightTexture( "Interface\\Buttons\\ButtonHilight-Square" ) |
||
724 | self.frames.demonicsacrifice:SetPoint("TOPRIGHT", self.frames.demonmenu, "TOPLEFT", -0, -72 ) |
||
725 | self.frames.demonicsacrifice:SetScript("OnClick", function() this.owner:CastDemonsMenu( this.owner.spells.normal["DEMONICSACRIFICE"] ) end ) |
||
726 | |||
727 | -- Soul Link |
||
728 | self.frames.soullink = CreateFrame("Button", nil, self.frames.demonmenu ) |
||
729 | self.frames.soullink.owner = self |
||
730 | self.frames.soullink:SetWidth(36) |
||
731 | self.frames.soullink:SetHeight(36) |
||
732 | self.frames.soullink:SetNormalTexture( "Interface\\Icons\\Spell_Shadow_GatherShadows") |
||
733 | self.frames.soullink:SetHighlightTexture( "Interface\\Buttons\\ButtonHilight-Square" ) |
||
734 | self.frames.soullink:SetPoint("TOPRIGHT", self.frames.demonmenu, "TOPLEFT", -36, -72 ) |
||
735 | self.frames.soullink:SetScript("OnClick", function() this.owner:CastDemonsMenu( this.owner.spells.normal["SOULLINK"] ) end ) |
||
736 | |||
737 | -- Enslave Demon |
||
738 | self.frames.enslave = CreateFrame("Button", nil, self.frames.demonmenu ) |
||
739 | self.frames.enslave.owner = self |
||
740 | self.frames.enslave:SetWidth(36) |
||
741 | self.frames.enslave:SetHeight(36) |
||
742 | self.frames.enslave:SetNormalTexture( "Interface\\Icons\\Spell_Shadow_EnslaveDemon") |
||
743 | self.frames.enslave:SetHighlightTexture( "Interface\\Buttons\\ButtonHilight-Square" ) |
||
744 | self.frames.enslave:SetPoint("TOPRIGHT", self.frames.demonmenu, "TOPLEFT", -72, -72 ) |
||
745 | self.frames.enslave:SetScript("OnClick", function() this.owner:CastDemonsMenu( this.owner.spells.normal["ENSLAVE"] ) end ) |
||
746 | |||
747 | |||
748 | |||
749 | -- Spelltimers |
||
750 | self.frames.timers = CreateFrame("Button", nil, self.frames.main ) |
||
751 | self.frames.timers.owner = self |
||
752 | self.frames.timers:SetMovable(true) |
||
753 | self.frames.timers:EnableMouse(true) |
||
754 | self.frames.timers:SetWidth(150) |
||
755 | self.frames.timers:SetHeight(25) |
||
756 | self.frames.timers:SetBackdrop({bgFile = "Interface/Tooltips/UI-Tooltip-Background", |
||
757 | edgeFile = "Interface/Tooltips/UI-Tooltip-Border", |
||
758 | tile = false, tileSize = 16, edgeSize = 16, |
||
759 | insets = { left = 5, right =5, top = 5, bottom = 5 }}) |
||
760 | |||
761 | |||
762 | self.frames.timers:SetBackdropColor( 0.7, 0, 0.7, 1 ) |
||
763 | self.frames.timers:SetBackdropBorderColor( 1, 1, 1, 1) |
||
764 | if( self:GetOpt("timerx") and self:GetOpt("timery") ) then |
||
765 | x = self:GetOpt("timerx") |
||
766 | y = self:GetOpt("timery") |
||
767 | self.frames.timers:SetPoint("TOPLEFT", UIParent, "TOPLEFT", x, y ) |
||
768 | else |
||
769 | self.frames.timers:SetPoint("TOPLEFT", self.frames.main, "BOTTOM", 60, 40) |
||
770 | end |
||
771 | self.frames.timers:RegisterForDrag("LeftButton") |
||
772 | self.frames.timers:SetScript("OnDragStart", function() this:StartMoving() end ) |
||
773 | self.frames.timers:SetScript("OnDragStop", |
||
774 | function() |
||
775 | this:StopMovingOrSizing() |
||
776 | local _,_,_,x,y = this:GetPoint("TOPLEFT") |
||
777 | this.owner:SetOpt("timerx", x) |
||
778 | this.owner:SetOpt("timery", y) |
||
779 | end |
||
780 | ) |
||
781 | |||
782 | self.frames.timersheader = self.frames.timers:CreateFontString(nil, "OVERLAY") |
||
783 | self.frames.timersheader.owner = self |
||
784 | self.frames.timersheader:SetFontObject(GameFontNormalSmall) |
||
785 | self.frames.timersheader:ClearAllPoints() |
||
786 | self.frames.timersheader:SetTextColor(0.8, 0.8, 1, 1) |
||
787 | self.frames.timersheader:SetPoint("CENTER", self.frames.timers, "CENTER", 0, 1 ) |
||
788 | self.frames.timersheader:SetJustifyH("CENTER") |
||
789 | self.frames.timersheader:SetJustifyV("MIDDLE") |
||
790 | self.frames.timersheader:SetText( NECRONOMICON_CONST.Timerheader ) |
||
791 | |||
792 | |||
793 | self.frames.timerstext = self.frames.timers:CreateFontString(nil, "OVERLAY") |
||
794 | self.frames.timerstext.owner = self |
||
795 | self.frames.timerstext:SetFontObject(GameFontNormalSmall) |
||
796 | self.frames.timerstext:ClearAllPoints() |
||
797 | self.frames.timerstext:SetTextColor(1, 1, 1, 1) |
||
798 | self.frames.timerstext:SetPoint("TOPLEFT", self.frames.timers, "TOPLEFT", 10, -6 ) |
||
799 | self.frames.timerstext:SetJustifyH("LEFT") |
||
800 | self.frames.timerstext:SetJustifyV("MIDDLE") |
||
801 | self.frames.timerstext:SetWidth(200) |
||
802 | self.frames.timerstext:SetText( "" ) |
||
803 | |||
804 | self:UpdateFrameLocks() |
||
805 | end, |
||
806 | |||
807 | UpdateShardCount = function( self ) |
||
808 | local texture = self:GetOpt("texture") |
||
809 | |||
810 | if(texture) then |
||
811 | if( self.shardcount < 33 ) then |
||
812 | self.frames.shard:SetNormalTexture( "Interface\\AddOns\\Necronomicon\\Images\\".. texture .."\\Shard"..self.shardcount ) |
||
813 | else |
||
814 | self.frames.shard:SetNormalTexture( "Interface\\AddOns\\Necronomicon\\Images\\".. texture .."\\Shard32" ) |
||
815 | end |
||
816 | else |
||
817 | if( self.shardcount < 17 ) then |
||
818 | self.frames.shard:SetNormalTexture( "Interface\\AddOns\\Necronomicon\\Images\\CounterButton-"..self.shardcount ) |
||
819 | else |
||
820 | self.frames.shard:SetNormalTexture( "Interface\\AddOns\\Necronomicon\\Images\\CounterButton-16" ) |
||
821 | end |
||
822 | end |
||
823 | self.frames.shardtext:SetText(""..self.shardcount ) |
||
824 | end, |
||
825 | |||
826 | UpdateHealthstone = function( self ) |
||
827 | if( not self.spells.normal["HEALTHSTONE"] ) then |
||
828 | self.frames.healthstone:Hide() |
||
829 | return |
||
830 | end |
||
831 | |||
832 | if( self.healthstone[0] ~= nil ) then |
||
833 | self.frames.healthstone:SetNormalTexture( "Interface\\AddOns\\Necronomicon\\Images\\HealthstoneButton-03" ) |
||
834 | else |
||
835 | self.frames.healthstone:SetNormalTexture( "Interface\\AddOns\\Necronomicon\\Images\\HealthstoneButton-01" ) |
||
836 | end |
||
837 | self.frames.healthstone:Show() |
||
838 | end, |
||
839 | |||
840 | UpdateSoulstone = function( self ) |
||
841 | if( not self.spells.normal["SOULSTONE"] ) then |
||
842 | self.frames.soulstone:Hide() |
||
843 | return |
||
844 | end |
||
845 | if( self.soulstone[0] ) then |
||
846 | self.frames.soulstone:SetNormalTexture( "Interface\\AddOns\\Necronomicon\\Images\\SoulstoneButton-02" ) |
||
847 | else |
||
848 | self.frames.soulstone:SetNormalTexture( "Interface\\AddOns\\Necronomicon\\Images\\SoulstoneButton-01" ) |
||
849 | end |
||
850 | self.frames.soulstone:Show() |
||
851 | end, |
||
852 | |||
853 | UpdateSpellstone = function( self ) |
||
854 | if( not self.spells.normal["SPELLSTONE"] ) then |
||
855 | self.frames.spellstone:Hide() |
||
856 | return |
||
857 | end |
||
858 | if( self.spellstone[0] ~= nil ) then |
||
859 | if( self.spellstone[2] ) then |
||
860 | self.frames.spellstone:SetNormalTexture( "Interface\\AddOns\\Necronomicon\\Images\\SpellstoneButton-03" ) |
||
861 | else |
||
862 | self.frames.spellstone:SetNormalTexture( "Interface\\AddOns\\Necronomicon\\Images\\SpellstoneButton-02" ) |
||
863 | end |
||
864 | else |
||
865 | self.frames.spellstone:SetNormalTexture( "Interface\\AddOns\\Necronomicon\\Images\\SpellstoneButton-01" ) |
||
866 | end |
||
867 | self.frames.spellstone:Show() |
||
868 | end, |
||
869 | |||
870 | UpdateFirestone = function( self ) |
||
871 | if( not self.spells.normal["FIRESTONE"] ) then |
||
872 | self.frames.firestone:Hide() |
||
873 | return |
||
874 | end |
||
875 | if( self.firestone[0] ~= nil ) then |
||
876 | if( self.firestone[2] ) then |
||
877 | self.frames.firestone:SetNormalTexture( "Interface\\AddOns\\Necronomicon\\Images\\FirestoneButton-03" ) |
||
878 | else |
||
879 | self.frames.firestone:SetNormalTexture( "Interface\\AddOns\\Necronomicon\\Images\\FirestoneButton-02" ) |
||
880 | end |
||
881 | else |
||
882 | self.frames.firestone:SetNormalTexture( "Interface\\AddOns\\Necronomicon\\Images\\FirestoneButton-01" ) |
||
883 | end |
||
884 | self.frames.firestone:Show() |
||
885 | end, |
||
886 | |||
887 | |||
888 | UpdateOtherButtons = function( self ) |
||
889 | if( not self.spells.normal["ARMOR"] ) then |
||
890 | self.frames.armor:Hide() |
||
891 | else |
||
892 | self.frames.armor:SetNormalTexture( "Interface\\AddOns\\Necronomicon\\Images\\DemonicArmorButton-01" ) |
||
893 | self.frames.armor:Show() |
||
894 | end |
||
895 | if( not self.spells.normal["RITUALOFSUMMONING"] ) then |
||
896 | self.frames.summon:Hide() |
||
897 | else |
||
898 | self.frames.summon:SetNormalTexture( "Interface\\AddOns\\Necronomicon\\Images\\RitualSummonButton-01" ) |
||
899 | self.frames.summon:Show() |
||
900 | end |
||
901 | if( not self.spells.normal["MOUNT"] ) then |
||
902 | self.frames.mount:Hide() |
||
903 | else |
||
904 | self.frames.mount:SetNormalTexture( "Interface\\AddOns\\Necronomicon\\Images\\MountButton-0"..self.mounttype ) |
||
905 | self.frames.mount:Show() |
||
906 | end |
||
907 | if( not self.hasdemons ) then |
||
908 | self.frames.demons:Hide() |
||
909 | else |
||
910 | self.frames.demons:SetNormalTexture( "Interface\\AddOns\\Necronomicon\\Images\\SummonerButton-00" ) |
||
911 | self.frames.demons:Show() |
||
912 | if( self.spells.normal["IMP"] ) then |
||
913 | self.frames.imp:Show() |
||
914 | else |
||
915 | self.frames.imp:Hide() |
||
916 | end |
||
917 | if( self.spells.normal["VOIDWALKER"] ) then |
||
918 | self.frames.voidwalker:Show() |
||
919 | else |
||
920 | self.frames.voidwalker:Hide() |
||
921 | end |
||
922 | if( self.spells.normal["SUCCUBUS"] ) then |
||
923 | self.frames.succubus:Show() |
||
924 | else |
||
925 | self.frames.succubus:Hide() |
||
926 | end |
||
927 | if( self.spells.normal["FELHUNTER"] ) then |
||
928 | self.frames.felhunter:Show() |
||
929 | else |
||
930 | self.frames.felhunter:Hide() |
||
931 | end |
||
932 | |||
933 | if( self.spells.normal["INFERNO"] ) then |
||
934 | self.frames.inferno:Show() |
||
935 | else |
||
936 | self.frames.inferno:Hide() |
||
937 | end |
||
938 | |||
939 | if( self.spells.normal["DOOMGUARD"] ) then |
||
940 | self.frames.doomguard:Show() |
||
941 | else |
||
942 | self.frames.doomguard:Hide() |
||
943 | end |
||
944 | |||
945 | if( self.spells.normal["FELDOMINATION"] ) then |
||
946 | self.frames.feldomination:Show() |
||
947 | else |
||
948 | self.frames.feldomination:Hide() |
||
949 | end |
||
950 | |||
951 | if( self.spells.normal["DEMONICSACRIFICE"] ) then |
||
952 | self.frames.demonicsacrifice:Show() |
||
953 | else |
||
954 | self.frames.demonicsacrifice:Hide() |
||
955 | end |
||
956 | if( self.spells.normal["ENSLAVE"] ) then |
||
957 | self.frames.enslave:Show() |
||
958 | else |
||
959 | self.frames.enslave:Hide() |
||
960 | end |
||
961 | |||
962 | if( self.spells.normal["SOULLINK"] ) then |
||
963 | self.frames.soullink:Show() |
||
964 | else |
||
965 | self.frames.soullink:Hide() |
||
966 | end |
||
967 | if( self.spells.normal["KILROGG"] ) then |
||
968 | self.frames.kilrogg:Show() |
||
969 | else |
||
970 | self.frames.kilrogg:Hide() |
||
971 | end |
||
972 | if( self.spells.normal["HEALTHFUNNEL"] ) then |
||
973 | self.frames.healthfunnel:Show() |
||
974 | else |
||
975 | self.frames.healthfunnel:Hide() |
||
976 | end |
||
977 | |||
978 | end |
||
979 | end, |
||
980 | |||
981 | UpdateTimers = function( self ) |
||
982 | local mindex, sindex, duration, text, tleft, gradient |
||
983 | |||
984 | self.timerstext = "" |
||
985 | |||
986 | if( self.soulstonetimer and self.soulstonetimer == 2 ) then |
||
987 | duration = Timex:ScheduleCheck("Necronomicon Soulstone Timer", TRUE) |
||
988 | -- tleft = floor(1800 - duration) |
||
989 | tleft = floor(duration) |
||
990 | text = self:BuildTime(tleft) |
||
991 | gradient = self:GetGradient( floor((tleft/1800)*100) ) |
||
992 | self.timerstext = self.timerstext .. "\n\n|CFF00FF00"..self.soulstonetarget.."|r" |
||
993 | self.timerstext = self.timerstext .. "\n "..gradient..NECRONOMICON_CONST.Pattern.SoulstoneResurrection.." "..text.."|r" |
||
994 | end |
||
995 | |||
996 | for mindex in pairs(self.timers) do |
||
997 | if( self.timers[mindex]["name"] ) then |
||
998 | self.timerstext = self.timerstext .. "\n\n".."|CFFFF5555"..self.timers[mindex]["name"].."|r" |
||
999 | for sindex in pairs(self.timers[mindex]) do |
||
1000 | if( sindex ~= "name" and sindex ~= "nr" ) then |
||
1001 | duration = Timex:ScheduleCheck("Necronomicon Timers "..mindex..sindex, TRUE) |
||
1002 | if( duration ) then |
||
1003 | -- tleft = floor(self.timers[mindex][sindex]["duration"] - duration) |
||
1004 | tleft = floor( duration ) |
||
1005 | text = self:BuildTime(tleft) |
||
1006 | gradient = self:GetGradient( floor((tleft/self.timers[mindex][sindex]["duration"])*100) ) |
||
1007 | self.timerstext = self.timerstext .. "\n "..gradient..sindex.." "..text.."|r" |
||
1008 | else |
||
1009 | self.timerstext = self.timerstext .. "\n "..sindex.." ?? " |
||
1010 | end |
||
1011 | end |
||
1012 | end |
||
1013 | end |
||
1014 | end |
||
1015 | |||
1016 | self.frames.timerstext:SetText(self.timerstext) |
||
1017 | end, |
||
1018 | |||
1019 | UpdateButtons = function( self ) |
||
1020 | self:UpdateShardCount() |
||
1021 | self:UpdateHealthstone() |
||
1022 | self:UpdateSoulstone() |
||
1023 | self:UpdateFirestone() |
||
1024 | self:UpdateSpellstone() |
||
1025 | self:UpdateOtherButtons() |
||
1026 | end, |
||
1027 | |||
1028 | UpdateFrameLocks = function( self ) |
||
1029 | if( self:GetOpt("lock") ) then |
||
1030 | self.frames.timers:SetMovable(false) |
||
1031 | self.frames.timers:SetBackdrop(nil) |
||
1032 | self.frames.timers:SetBackdropColor(0,0,0,0) |
||
1033 | self.frames.timers:SetBackdropBorderColor(0,0,0,0) |
||
1034 | self.frames.main:SetMovable(false) |
||
1035 | self.frames.timers:RegisterForDrag() |
||
1036 | self.frames.shard:RegisterForDrag() |
||
1037 | else |
||
1038 | self.frames.timers:SetMovable(true) |
||
1039 | self.frames.timers:SetBackdrop({bgFile = "Interface/Tooltips/UI-Tooltip-Background", |
||
1040 | edgeFile = "Interface/Tooltips/UI-Tooltip-Border", |
||
1041 | tile = false, tileSize = 16, edgeSize = 16, |
||
1042 | insets = { left = 5, right =5, top = 5, bottom = 5 }}) |
||
1043 | self.frames.timers:SetBackdropColor( 0.7, 0, 0.7, 1 ) |
||
1044 | self.frames.timers:SetBackdropBorderColor( 1, 1, 1, 1) |
||
1045 | self.frames.main:SetMovable(true) |
||
1046 | self.frames.timers:RegisterForDrag("LeftButton") |
||
1047 | self.frames.shard:RegisterForDrag("LeftButton") |
||
1048 | end |
||
1049 | end, |
||
1050 | ---------------------------- |
||
1051 | -- ButtonClicks -- |
||
1052 | ---------------------------- |
||
1053 | |||
1054 | HealthstoneClicked = function( self ) |
||
1055 | if( self.healthstone[0] ~= nil ) then |
||
1056 | if( UnitExists("target") and UnitIsPlayer("target") and not UnitIsEnemy("target", "player") and UnitName("target") ~= UnitName("player") ) then |
||
1057 | if( not UnitCanCooperate("player", "target")) then |
||
1058 | self:Msg( NECRONOMICON_CONST.Message.Busy ) |
||
1059 | elseif (not CheckInteractDistance("target",2)) then |
||
1060 | self:Msg( NECRONOMICON_CONST.Message.TooFarAway ) |
||
1061 | else |
||
1062 | PickupContainerItem( self.healthstone[0], self.healthstone[1] ) |
||
1063 | if ( CursorHasItem() ) then |
||
1064 | DropItemOnUnit("target") |
||
1065 | Timex:AddSchedule("Necronomicon Healthstone Trade", 3, nil, nil, "AcceptTrade", "" ) |
||
1066 | end |
||
1067 | end |
||
1068 | elseif( (UnitHealth("player") < UnitHealthMax("player")) and GetContainerItemCooldown(self.healthstone[0],self.healthstone[1]) == 0) then |
||
1069 | UseContainerItem( self.healthstone[0], self.healthstone[1] ) |
||
1070 | end |
||
1071 | else |
||
1072 | CastSpell( self.spells.normal["HEALTHSTONE"], BOOKTYPE_SPELL ) |
||
1073 | end |
||
1074 | end, |
||
1075 | |||
1076 | SoulstoneClicked = function( self ) |
||
1077 | if( self.soulstone[0] ~= nil ) then |
||
1078 | if ( not UnitIsEnemy("player", "target") and UnitExists("target") ) then |
||
1079 | UseContainerItem( self.soulstone[0], self.soulstone[1] ) |
||
1080 | end |
||
1081 | else |
||
1082 | CastSpell( self.spells.normal["SOULSTONE"], BOOKTYPE_SPELL ) |
||
1083 | end |
||
1084 | end, |
||
1085 | |||
1086 | SpellstoneClicked = function( self ) |
||
1087 | if( self.spellstone[0] ~= nil ) then |
||
1088 | if( self.spellstone[2] ) then |
||
1089 | UseInventoryItem(GetInventorySlotInfo("SecondaryHandSlot")) |
||
1090 | self:BAG_UPDATE() |
||
1091 | else |
||
1092 | UseContainerItem(self.spellstone[0], self.spellstone[1]) |
||
1093 | end |
||
1094 | else |
||
1095 | CastSpell( self.spells.normal["SPELLSTONE"], BOOKTYPE_SPELL ) |
||
1096 | end |
||
1097 | end, |
||
1098 | |||
1099 | FirestoneClicked = function( self ) |
||
1100 | if( self.firestone[0] ~= nil ) then |
||
1101 | if( not self.firestone[2] ) then |
||
1102 | UseContainerItem(self.firestone[0], self.firestone[1]) |
||
1103 | end |
||
1104 | else |
||
1105 | CastSpell( self.spells.normal["FIRESTONE"], BOOKTYPE_SPELL ) |
||
1106 | end |
||
1107 | end, |
||
1108 | |||
1109 | DemonsClicked = function( self ) |
||
1110 | if( self.frames.demonmenu.opened ) then |
||
1111 | self.frames.demonmenu:Hide() |
||
1112 | self.frames.demonmenu.opened = FALSE |
||
1113 | else |
||
1114 | self.frames.demonmenu:Show() |
||
1115 | self.frames.demonmenu.opened = TRUE |
||
1116 | end |
||
1117 | end, |
||
1118 | |||
1119 | SummonClicked = function( self ) |
||
1120 | if( self.spells.normal["RITUALOFSUMMONING"] ) then |
||
1121 | CastSpell( self.spells.normal["RITUALOFSUMMONING"], BOOKTYPE_SPELL ) |
||
1122 | end |
||
1123 | end, |
||
1124 | |||
1125 | ArmorClicked = function( self ) |
||
1126 | if( self.spells.normal["ARMOR"] ) then |
||
1127 | CastSpell( self.spells.normal["ARMOR"], BOOKTYPE_SPELL ) |
||
1128 | end |
||
1129 | end, |
||
1130 | |||
1131 | MountClicked = function( self ) |
||
1132 | if( self.spells.normal["MOUNT"] ) then |
||
1133 | CastSpell( self.spells.normal["MOUNT"], BOOKTYPE_SPELL ) |
||
1134 | end |
||
1135 | end, |
||
1136 | |||
1137 | ---------------------------- |
||
1138 | -- WoW Event Handlers -- |
||
1139 | ---------------------------- |
||
1140 | |||
1141 | BAG_UPDATE = function( self ) |
||
1142 | local bag = arg1 |
||
1143 | Timex:AddSchedule("Necronomicon Bag Update", 0.5, nil, nil, "NECRONOMICON_BAG_UPDATE", Necronomicon ) |
||
1144 | end, |
||
1145 | |||
1146 | SPELLS_CHANGED = function( self ) |
||
1147 | self:ScanSpells() |
||
1148 | self:UpdateButtons() |
||
1149 | end, |
||
1150 | |||
1151 | SPELLCAST_START = function( self ) |
||
1152 | -- self:Msg("SPELLCAST_START: "..arg1 ) |
||
1153 | if( self.currentspell.state ) then |
||
1154 | if( self.currentspell.state == NECRONOMICON_CONST.State.Cast ) then |
||
1155 | self.currentspell.state = NECRONOMICON_CONST.State.Start |
||
1156 | -- we have started casting |
||
1157 | else |
||
1158 | -- I want nothing do do with this cast |
||
1159 | self.Compost:Erase(self.currentspell) |
||
1160 | end |
||
1161 | end |
||
1162 | self.soulstonestate = nil |
||
1163 | if( arg1 == NECRONOMICON_CONST.Pattern.SoulstoneResurrection ) then |
||
1164 | if( UnitName("target") ) then |
||
1165 | self.soulstonetimer = 1 |
||
1166 | self.soulstonetarget = "["..UnitLevel("target").."] "..UnitName("target") |
||
1167 | self.soulstonename = UnitName("target") |
||
1168 | self:SendChatMessage(string.format( NECRONOMICON_CONST.Message.PreSoulstone, UnitName("target") ) ) |
||
1169 | |||
1170 | end |
||
1171 | elseif( arg1 == NECRONOMICON_CONST.Pattern.RitualOfSummoning ) then |
||
1172 | if( UnitName("target") ) then |
||
1173 | self:SendChatMessage(string.format( NECRONOMICON_CONST.Message.PreSummon, UnitName("target") ) ) |
||
1174 | self.presummoncount = self.shardcount |
||
1175 | self.summoning = true |
||
1176 | self.summonvictim = UnitName("target") |
||
1177 | end |
||
1178 | end |
||
1179 | end, |
||
1180 | |||
1181 | SPELLCAST_FAILED = function( self ) |
||
1182 | -- self:Msg("SPELLCAST_FAILED" ) |
||
1183 | if( self.currentspell.state ) then |
||
1184 | self.currentspell.state = NECRONOMICON_CONST.State.Failed |
||
1185 | end |
||
1186 | end, |
||
1187 | |||
1188 | SPELLCAST_STOP = function( self ) |
||
1189 | -- self:Msg("SPELLCAST_STOP" ) |
||
1190 | if( self.currentspell.state and self.currentspell.state < NECRONOMICON_CONST.State.Stop ) then |
||
1191 | self.currentspell.state = NECRONOMICON_CONST.State.Stop |
||
1192 | self:TimerAddSpell() |
||
1193 | end |
||
1194 | if( self.soulstonetimer and self.soulstonetimer == 1 ) then |
||
1195 | self.soulstonetimer = 2 |
||
1196 | self.soulstonestate = 1 |
||
1197 | Timex:AddSchedule("Necronomicon Soulstone Timer", 1800, nil, nil, Necronomicon.DeleteSoulstoneTimer, Necronomicon ) |
||
1198 | self:SendChatMessage(string.format( NECRONOMICON_CONST.Message.Soulstone, self.soulstonename ) ) |
||
1199 | end |
||
1200 | end, |
||
1201 | |||
1202 | SPELLCAST_INTERRUPTED = function( self ) |
||
1203 | -- self:Msg("SPELLCAST_INTERRUPTED" ) |
||
1204 | if( self.currentspell.state and self.currentspell.state > NECRONOMICON_CONST.State.Stop ) then |
||
1205 | self:TimerRollback() |
||
1206 | end |
||
1207 | if( self.soulstonetimer and self.soulstonestate ) then |
||
1208 | self.soulstonetimer = nil |
||
1209 | self.soulstonestate = nil |
||
1210 | Timex:DeleteSchedule("Necronomicon Soulstone Timer") |
||
1211 | self:SendChatMessage( NECRONOMICON_CONST.Message.SoulstoneAborted ) |
||
1212 | end |
||
1213 | end, |
||
1214 | |||
1215 | SPELLCAST_CHANNEL_START = function( self ) |
||
1216 | -- self:Msg("SPELLCAST_CHANNEL_START: "..arg1) |
||
1217 | if( self.currentspell.state ) then |
||
1218 | if( self.currentspell.state == NECRONOMICON_CONST.State.Cast ) then |
||
1219 | self.currentspell.state = NECRONOMICON_CONST.State.Start |
||
1220 | -- we have started casting |
||
1221 | end |
||
1222 | end |
||
1223 | end, |
||
1224 | |||
1225 | SPELLCAST_CHANNEL_STOP = function( self ) |
||
1226 | -- self:Msg("SPELLCAST_CHANNEL_STOP") |
||
1227 | if( self.summoning ) then |
||
1228 | self:ScanStones() |
||
1229 | if( self.shardcount >= self.summoncount ) then |
||
1230 | -- failed summoning |
||
1231 | self:SendChatMessage( string.format( NECRONOMICON_CONST.Message.FailedSummon, self.summonvictim) ) |
||
1232 | end |
||
1233 | self.summoning = nil |
||
1234 | end |
||
1235 | end, |
||
1236 | |||
1237 | PLAYER_REGEN_ENABLED = function( self ) |
||
1238 | self:ClearTimers() |
||
1239 | end, |
||
1240 | |||
1241 | CHAT_MSG_SPELL_PERIODIC_SELF_BUFFS = function( self ) |
||
1242 | if( self:GetOpt("shadowtrancesound") and string.find( arg1, NECRONOMICON_CONST.Pattern.ShadowTrance ) ) then |
||
1243 | PlaySoundFile("Interface\\AddOns\\Necronomicon\\Sounds\\ShadowTrance.mp3") |
||
1244 | end |
||
1245 | end, |
||
1246 | |||
1247 | CHAT_MSG_SPELL_SELF_DAMAGE = function( self ) |
||
1248 | if( self.currentspell.state and self.currentspell.state > NECRONOMICON_CONST.State.Stop ) then |
||
1249 | if( string.find( arg1, NECRONOMICON_CONST.Pattern.Resisted ) or |
||
1250 | string.find( arg1, NECRONOMICON_CONST.Pattern.Immune ) ) then |
||
1251 | self:TimerRollback() |
||
1252 | end |
||
1253 | end |
||
1254 | end, |
||
1255 | |||
1256 | ---------------------------- |
||
1257 | -- My Event Handlers -- |
||
1258 | ---------------------------- |
||
1259 | |||
1260 | NECRONOMICON_BAG_UPDATE = function( self ) |
||
1261 | self:ScanStones() |
||
1262 | self:UpdateShardCount() |
||
1263 | self:UpdateHealthstone() |
||
1264 | self:UpdateSoulstone() |
||
1265 | self:UpdateSpellstone() |
||
1266 | self:UpdateFirestone() |
||
1267 | end, |
||
1268 | |||
1269 | |||
1270 | Heartbeat = function( self) |
||
1271 | self:UpdateTimers() |
||
1272 | end, |
||
1273 | |||
1274 | ---------------------------- |
||
1275 | -- My Hooks -- |
||
1276 | ---------------------------- |
||
1277 | |||
1278 | OnCastSpell = function( self, spellid, spellbooktab ) |
||
1279 | -- self:Msg( "OnCastSpell: "..spellid..", "..spellbooktab) |
||
1280 | |||
1281 | self:CallHook("CastSpell", spellid, spellbooktab ) |
||
1282 | |||
1283 | if( self.spells.timedid[spellid] ) then |
||
1284 | self:RegisterSpellCast( self.spells.timedid[spellid] ) |
||
1285 | end |
||
1286 | |||
1287 | end, |
||
1288 | |||
1289 | OnCastSpellByName = function( self, spellname ) |
||
1290 | -- self:Msg("OnCastSpellByName: "..spellname ) |
||
1291 | |||
1292 | self:CallHook("CastSpellByName", spellname ) |
||
1293 | |||
1294 | if( self.spells.timed[strlower(spellname)] ) then |
||
1295 | self:RegisterSpellCast( strlower(spellname) ) |
||
1296 | elseif( self.spells.timedname[strlower(spellname)] ) then |
||
1297 | self:RegisterSpellCast( self.spells.timedname[strlower(spellname)] ) |
||
1298 | end |
||
1299 | |||
1300 | end, |
||
1301 | |||
1302 | OnUseAction = function( self, actionid, a2, a3) |
||
1303 | -- self:Msg("OnUseAction: "..actionid ) |
||
1304 | |||
1305 | self:CallHook("UseAction", actionid, a2, a3 ) |
||
1306 | |||
1307 | NecronomiconTooltip:SetAction(actionid) |
||
1308 | |||
1309 | local lefttext = NecronomiconTooltipTextLeft1:GetText() |
||
1310 | local righttext = NecronomiconTooltipTextRight1:GetText() |
||
1311 | |||
1312 | if( lefttext ) then |
||
1313 | |||
1314 | if( righttext ) then |
||
1315 | righttext = lefttext.." "..righttext |
||
1316 | else |
||
1317 | righttext = lefttext |
||
1318 | end |
||
1319 | |||
1320 | lefttext = strlower( lefttext ) |
||
1321 | righttext = strlower( righttext ) |
||
1322 | |||
1323 | if( self.spells.timed[lefttext] ) then |
||
1324 | self:RegisterSpellCast( lefttext ) |
||
1325 | elseif( self.spells.timed[righttext] ) then |
||
1326 | self:RegisterSpellCast( righttext ) |
||
1327 | end |
||
1328 | end |
||
1329 | |||
1330 | |||
1331 | end, |
||
1332 | |||
1333 | -- Not using this for now |
||
1334 | OnUseContainerItem = function( self, index, slot ) |
||
1335 | self:Msg("OnUseContainerItem: "..index..", "..slot ) |
||
1336 | return self:CallHook("UseContainerItem", index, slot ) |
||
1337 | end, |
||
1338 | |||
1339 | ---------------------------- |
||
1340 | -- Chat -- |
||
1341 | ---------------------------- |
||
1342 | |||
1343 | chatReset = function( self ) |
||
1344 | self.frames.main:SetPoint("TOPLEFT", UIParent, "TOPLEFT", 150, -150) |
||
1345 | self.frames.timers:SetPoint("TOPLEFT", self.frames.main, "BOTTOM", 60, 40) |
||
1346 | end, |
||
1347 | |||
1348 | chatFelDom = function( self, modifier ) |
||
1349 | if( modifier == "ctrl" ) then |
||
1350 | self:SetOpt("feldommodifier", "ctrl") |
||
1351 | elseif( modifier == "alt" ) then |
||
1352 | self:SetOpt("feldommodifier", "alt") |
||
1353 | elseif( modifier == "shift" ) then |
||
1354 | self:SetOpt("feldommodifier", "shift") |
||
1355 | elseif( modifier == "none" ) then |
||
1356 | self:SetOpt("feldommodifier", nil ) |
||
1357 | else |
||
1358 | self:Msg( NECRONOMICON_CONST.Chat.FelDomValid ) |
||
1359 | end |
||
1360 | if( self:GetOpt("feldommodifier") ) then |
||
1361 | self:Msg( NECRONOMICON_CONST.Chat.FelDomModifier .. self:GetOpt("feldommodifier") ) |
||
1362 | else |
||
1363 | self:Msg( NECRONOMICON_CONST.Chat.FelDomModifier .. "none" ) |
||
1364 | end |
||
1365 | end, |
||
1366 | |||
1367 | |||
1368 | chatCloseClick = function( self ) |
||
1369 | self:TogOpt("closeonclick") |
||
1370 | self:Msg(NECRONOMICON_CONST.Chat.CloseOnClick, ACEG_MAP_ONOFF[self:GetOpt("closeonclick") or 0]) |
||
1371 | end, |
||
1372 | |||
1373 | |||
1374 | chatShadowTranceSound = function( self ) |
||
1375 | self:TogOpt("shadowtrancesound") |
||
1376 | self:Msg(NECRONOMICON_CONST.Chat.ShadowTranceSound, ACEG_MAP_ONOFF[self:GetOpt("shadowtrancesound") or 0]) |
||
1377 | end, |
||
1378 | |||
1379 | chatSoulstoneSound = function( self ) |
||
1380 | self:TogOpt("soulstonesound") |
||
1381 | self:Msg(NECRONOMICON_CONST.Chat.SoulstoneSound, ACEG_MAP_ONOFF[self:GetOpt("soulstonesound") or 0]) |
||
1382 | end, |
||
1383 | |||
1384 | chatTimers = function( self ) |
||
1385 | self:TogOpt("timers") |
||
1386 | self:Msg(NECRONOMICON_CONST.Chat.Timers, ACEG_MAP_ONOFF[self:GetOpt("timers") or 0]) |
||
1387 | if( self:GetOpt("timers") ) then |
||
1388 | self.Metrognome:Start("Necronomicon") |
||
1389 | self.frames.timers:Show() |
||
1390 | else |
||
1391 | self.Metrognome:Stop("Necronomicon") |
||
1392 | self.frames.timers:Hide() |
||
1393 | end |
||
1394 | end, |
||
1395 | |||
1396 | |||
1397 | chatLock = function( self ) |
||
1398 | self:TogOpt("lock") |
||
1399 | self:Msg(NECRONOMICON_CONST.Chat.Lock, ACEG_MAP_ONOFF[self:GetOpt("lock") or 0]) |
||
1400 | self:UpdateFrameLocks() |
||
1401 | end, |
||
1402 | |||
1403 | chatTexture = function( self, texture ) |
||
1404 | if( texture == "default" ) then |
||
1405 | self:SetOpt("texture", nil) |
||
1406 | elseif( texture == "blue" ) then |
||
1407 | self:SetOpt("texture", "Blue") |
||
1408 | elseif( texture == "orange" ) then |
||
1409 | self:SetOpt("texture", "Orange") |
||
1410 | elseif( texture == "rose" ) then |
||
1411 | self:SetOpt("texture", "Rose") |
||
1412 | elseif( texture == "turquoise" ) then |
||
1413 | self:SetOpt("texture", "Turquoise") |
||
1414 | elseif( texture == "violet" ) then |
||
1415 | self:SetOpt("texture", "Violet") |
||
1416 | elseif( texture == "x" ) then |
||
1417 | self:SetOpt("texture", "X") |
||
1418 | else |
||
1419 | self:Msg( NECRONOMICON_CONST.Chat.TextureValid ) |
||
1420 | end |
||
1421 | if( self:GetOpt("texture") ) then |
||
1422 | self:Msg( NECRONOMICON_CONST.Chat.Texture .. self:GetOpt("texture") ) |
||
1423 | else |
||
1424 | self:Msg( NECRONOMICON_CONST.Chat.Texture .. "default" ) |
||
1425 | end |
||
1426 | self:UpdateShardCount() |
||
1427 | end, |
||
1428 | |||
1429 | |||
1430 | |||
1431 | |||
1432 | Report = function( self ) |
||
1433 | if( self:GetOpt("texture") ) then |
||
1434 | self:Msg( NECRONOMICON_CONST.Chat.Texture .. self:GetOpt("texture") ) |
||
1435 | else |
||
1436 | self:Msg( NECRONOMICON_CONST.Chat.Texture .. "default" ) |
||
1437 | end |
||
1438 | if( self:GetOpt("feldommodifier") ) then |
||
1439 | self:Msg( NECRONOMICON_CONST.Chat.FelDomModifier .. self:GetOpt("feldommodifier") ) |
||
1440 | else |
||
1441 | self:Msg( NECRONOMICON_CONST.Chat.FelDomModifier .. "none" ) |
||
1442 | end |
||
1443 | self:Msg(NECRONOMICON_CONST.Chat.CloseOnClick, ACEG_MAP_ONOFF[self:GetOpt("closeonclick") or 0]) |
||
1444 | self:Msg(NECRONOMICON_CONST.Chat.SoulstoneSound, ACEG_MAP_ONOFF[self:GetOpt("soulstonesound") or 0]) |
||
1445 | self:Msg(NECRONOMICON_CONST.Chat.ShadowTranceSound, ACEG_MAP_ONOFF[self:GetOpt("shadowtrancesound") or 0]) |
||
1446 | self:Msg(NECRONOMICON_CONST.Chat.Lock, ACEG_MAP_ONOFF[self:GetOpt("lock") or 0]) |
||
1447 | end, |
||
1448 | |||
1449 | -- Command Reporting Closures |
||
1450 | |||
1451 | GetOpt = function(self, path, var) |
||
1452 | if (not var) then var = path; path = nil; end |
||
1453 | local profilePath = path and {self.profilePath, path} or self.profilePath; |
||
1454 | |||
1455 | return self.db:get(profilePath, var) |
||
1456 | end, |
||
1457 | |||
1458 | SetOpt = function(self, path, var, val) |
||
1459 | if (not val) then val = var; var = path; path = nil; end |
||
1460 | local profilePath = path and {self.profilePath, path} or self.profilePath; |
||
1461 | |||
1462 | return self.db:set(profilePath, var, val) |
||
1463 | end, |
||
1464 | |||
1465 | TogOpt = function(self, path, var) |
||
1466 | if (not var) then var = path; path = nil; end |
||
1467 | local profilePath = path and {self.profilePath, path} or self.profilePath; |
||
1468 | |||
1469 | return self.db:toggle(profilePath, var) |
||
1470 | end, |
||
1471 | |||
1472 | Msg = function(self, ...) |
||
1473 | self.cmd:result(NECRONOMICON_MSG_COLOR, unpack(arg)) |
||
1474 | end, |
||
1475 | |||
1476 | Result = function(self, text, val, map) |
||
1477 | if( map ) then val = map[val or 0] or val end |
||
1478 | self.cmd:result(NECRONOMICON_MSG_COLOR, text, " ", ACEG_TEXT_NOW_SET_TO, " ", |
||
1479 | format(NECRONOMICON_DISPLAY_OPTION, val or ACE_CMD_REPORT_NO_VAL) |
||
1480 | ) |
||
1481 | end, |
||
1482 | |||
1483 | |||
1484 | TogMsg = function(self, var, text) |
||
1485 | local val = self:TogOpt(var) |
||
1486 | self:Result(text, val, ACEG_MAP_ONOFF) |
||
1487 | return val |
||
1488 | end, |
||
1489 | |||
1490 | Error = function(self, ...) |
||
1491 | local text = ""; |
||
1492 | for i=1,getn(arg) do |
||
1493 | text = text .. arg[i] |
||
1494 | end |
||
1495 | error(NECRONOMICON_MSG_COLOR .. text, 2) |
||
1496 | end, |
||
1497 | |||
1498 | |||
1499 | }) |
||
1500 | |||
1501 | ---------------------------------- |
||
1502 | -- Load this bitch up! -- |
||
1503 | ---------------------------------- |
||
1504 | Necronomicon:RegisterForLoad() |
||
1505 |