Repository navigation
Expand file tree
/
Copy pathMessage.lua
More file actions
390 lines (376 loc) · 16.7 KB
/
Copy pathMessage.lua
File metadata and controls
390 lines (376 loc) · 16.7 KB
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
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
--[[
Necrosis LdC
Copyright (C) 2005-2008 Lom Enfroy
This file is part of Necrosis LdC.
Necrosis LdC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
Necrosis LdC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Necrosis LdC; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--]]
------------------------------------------------------------------------------------------------------
-- Necrosis LdC
-- Par Lomig (Kael'Thas EU/FR) & Tarcalion (Nagrand US/Oceanic)
-- Contributions deLiadora et Nyx (Kael'Thas et Elune EU/FR)
--
-- Skins et voix Françaises : Eliah, Ner'zhul
--
-- Version Allemande par Geschan
-- Version Espagnole par DosS (Zul’jin)
-- Version Russe par Komsomolka
--
-- Version $LastChangedDate$
------------------------------------------------------------------------------------------------------
-- One defines G as being the table containing all the existing frames.
local _G = getfenv(0)
------------------------------------------------------------------------------------------------------
-- Message handler (CONSOLE, CHAT, MESSAGE SYSTEM)
------------------------------------------------------------------------------------------------------
function Necrosis:Msg(msg, type)
if msg then
-- dispatch the message to the appropriate chat channel depending on the message type
if (type == "WORLD") then
if (GetNumRaidMembers() > 0) then
-- send to all raid members
SendChatMessage(msg, "RAID")
elseif (GetNumPartyMembers() > 0) then
-- send to party members
SendChatMessage(msg, "PARTY")
else
-- not in a group so lets use the 'say' channel
SendChatMessage(msg, "SAY")
end
elseif (type == "PARTY") then
SendChatMessage(msg, "PARTY")
elseif (type == "RAID") then
SendChatMessage(msg, "RAID")
elseif (type == "SAY") then
SendChatMessage(msg, "SAY")
elseif (type == "EMOTE") then
SendChatMessage(msg, "EMOTE")
elseif (type == "YELL") then
SendChatMessage(msg, "YELL")
else
-- Add some color to our message :D
msg = self:MsgAddColor(msg)
local Intro = "|CFFFF00FFNe|CFFFF50FFcr|CFFFF99FFos|CFFFFC4FFis|CFFFFFFFF: "
if NecrosisConfig.ChatType then
-- ...... on the first chat frame
ChatFrame1:AddMessage(Intro..msg, 1.0, 0.7, 1.0, 1.0, UIERRORS_HOLD_TIME)
else
-- ...... on the middle of the screen
UIErrorsFrame:AddMessage(Intro..msg, 1.0, 0.7, 1.0, 1.0, UIERRORS_HOLD_TIME)
end
end
end
end
------------------------------------------------------------------------------------------------------
-- Color functions
------------------------------------------------------------------------------------------------------
-- Replace any color strings in the message with its associated value
function Necrosis:MsgAddColor(msg)
if type(msg) == "string" then
msg = msg:gsub("<white>", "|CFFFFFFFF")
msg = msg:gsub("<lightBlue>", "|CFF99CCFF")
msg = msg:gsub("<brightGreen>", "|CFF00FF00")
msg = msg:gsub("<lightGreen2>", "|CFF66FF66")
msg = msg:gsub("<lightGreen1>", "|CFF99FF66")
msg = msg:gsub("<yellowGreen>", "|CFFCCFF66")
msg = msg:gsub("<lightYellow>", "|CFFFFFF66")
msg = msg:gsub("<darkYellow>", "|CFFFFCC00")
msg = msg:gsub("<lightOrange>", "|CFFFFCC66")
msg = msg:gsub("<dirtyOrange>", "|CFFFF9933")
msg = msg:gsub("<darkOrange>", "|CFFFF6600")
msg = msg:gsub("<redOrange>", "|CFFFF3300")
msg = msg:gsub("<red>", "|CFFFF0000")
msg = msg:gsub("<lightRed>", "|CFFFF5555")
msg = msg:gsub("<lightPurple1>", "|CFFFFC4FF")
msg = msg:gsub("<lightPurple2>", "|CFFFF99FF")
msg = msg:gsub("<purple>", "|CFFFF50FF")
msg = msg:gsub("<darkPurple1>", "|CFFFF00FF")
msg = msg:gsub("<darkPurple2>", "|CFFB700B7")
msg = msg:gsub("<close>", "|r")
end
return msg
end
-- Adjusts the timer color based on the percentage of time left.
function NecrosisTimerColor(percent)
local color = "<brightGreen>"
if (percent < 10) then
color = "<red>"
elseif (percent < 20) then
color = "<redOrange>"
elseif (percent < 30) then
color = "<darkOrange>"
elseif (percent < 40) then
color = "<dirtyOrange>"
elseif (percent < 50) then
color = "<darkYellow>"
elseif (percent < 60) then
color = "<lightYellow>"
elseif (percent < 70) then
color = "<yellowGreen>"
elseif (percent < 80) then
color = "<lightGreen1>"
elseif (percent < 90) then
color = "<lightGreen2>"
end
return color
end
------------------------------------------------------------------------------------------------------
-- Replace user-friendly string variables in the invocation messages
------------------------------------------------------------------------------------------------------
function Necrosis:MsgReplace(msg, target, pet)
msg = msg:gsub("<player>", UnitName("player"))
msg = msg:gsub("<emote>", "")
msg = msg:gsub("<after>", "")
msg = msg:gsub("<sacrifice>", "")
msg = msg:gsub("<yell>", "")
if target then
msg = msg:gsub("<target>", target)
end
if pet and NecrosisConfig.PetName[pet] then
msg = msg:gsub("<pet>", NecrosisConfig.PetName[pet])
end
return msg
end
------------------------------------------------------------------------------------------------------
-- Handles the posting of messages while casting a spell.
------------------------------------------------------------------------------------------------------
function Necrosis:Speech_It(Spell, Speeches, metatable)
-- messages to be posted while summoning a mount
if (Spell.Name == Necrosis.Spell[1].Name or Spell.Name == Necrosis.Spell[2].Name) then
Speeches.SpellSucceed.Steed = setmetatable({}, metatable)
if NecrosisConfig.SteedSummon and NecrosisConfig.ChatMsg and self.Speech.Demon[7] and not NecrosisConfig.SM then
local tempnum = math.random(1, #self.Speech.Demon[7])
while tempnum == Speeches.LastSpeech.Steed and #self.Speech.Demon[7] >= 2 do
tempnum = math.random(1, #self.Speech.Demon[7])
end
Speeches.LastSpeech.Steed = tempnum
for i in ipairs(self.Speech.Demon[7][tempnum]) do
if self.Speech.Demon[7][tempnum][i]:find("<after>") then
Speeches.SpellSucceed.Steed:insert(self.Speech.Demon[7][tempnum][i])
elseif self.Speech.Demon[7][tempnum][i]:find("<emote>") then
self:Msg(self:MsgReplace(self.Speech.Demon[7][tempnum][i]), "EMOTE")
elseif self.Speech.Demon[7][tempnum][i]:find("<yell>") then
self:Msg(self:MsgReplace(self.Speech.Demon[7][tempnum][i]), "YELL")
else
self:Msg(self:MsgReplace(self.Speech.Demon[7][tempnum][i]), "SAY")
end
end
end
-- messsages to be posted while casting 'Ritual of Souls' -Draven (April 3rd, 2008)
elseif Spell.Name == Necrosis.Spell[50].Name then
Speeches.SpellSucceed.RoS = setmetatable({}, metatable)
if (NecrosisConfig.ChatMsg or NecrosisConfig.SM) and NecrosisConfig.RoSSummon and self.Speech.RoS then
local tempnum = math.random(1, #self.Speech.RoS)
while tempnum == Speeches.LastSpeech.RoS and #self.Speech.RoS >= 2 do
tempnum = math.random(1, #self.Speech.RoS)
end
Speeches.LastSpeech.RoS = tempnum
for i in ipairs(self.Speech.RoS[tempnum]) do
if self.Speech.RoS[tempnum][i]:find("<after>") then
Speeches.SpellSucceed.RoS:insert(self.Speech.RoS[tempnum][i])
elseif self.Speech.RoS[tempnum][i]:find("<emote>") then
self:Msg(self:MsgReplace(self.Speech.RoS[tempnum][i]), "EMOTE")
elseif self.Speech.RoS[tempnum][i]:find("<yell>") then
self:Msg(self:MsgReplace(self.Speech.RoS[tempnum][i]), "YELL")
else
self:Msg(self:MsgReplace(self.Speech.RoS[tempnum][i]), "WORLD")
end
end
end
-- messages to be posted while casting 'Soulstone' on a friendly target
elseif Spell.Name == Necrosis.Spell[11].Name and not (Spell.TargetName == UnitName("player")) then
Speeches.SpellSucceed.Rez = setmetatable({}, metatable)
if (NecrosisConfig.ChatMsg or NecrosisConfig.SM) and self.Speech.Rez then
local tempnum = math.random(1, #self.Speech.Rez)
while tempnum == Speeches.LastSpeech.Rez and #self.Speech.Rez >= 2 do
tempnum = math.random(1, #self.Speech.Rez)
end
Speeches.LastSpeech.Rez = tempnum
for i in ipairs(self.Speech.Rez[tempnum]) do
if self.Speech.Rez[tempnum][i]:find("<after>") then
Speeches.SpellSucceed.Rez:insert(self.Speech.Rez[tempnum][i])
elseif self.Speech.Rez[tempnum][i]:find("<emote>") then
self:Msg(self:MsgReplace(self.Speech.Rez[tempnum][i], Spell.TargetName), "EMOTE")
elseif self.Speech.Rez[tempnum][i]:find("<yell>") then
self:Msg(self:MsgReplace(self.Speech.Rez[tempnum][i], Spell.TargetName), "YELL")
else
self:Msg(self:MsgReplace(self.Speech.Rez[tempnum][i], Spell.TargetName), "WORLD")
end
end
end
-- messages to be posted while casting 'Ritual of Summoning'
elseif Spell.Name == Necrosis.Spell[37].Name then
Speeches.SpellSucceed.TP = setmetatable({}, metatable)
if (NecrosisConfig.ChatMsg or NecrosisConfig.SM) and self.Speech.TP then
local tempnum = math.random(1, #self.Speech.TP)
while tempnum == Speeches.LastSpeech.TP and #self.Speech.TP >= 2 do
tempnum = math.random(1, #self.Speech.TP)
end
Speeches.LastSpeech.TP = tempnum
for i in ipairs(self.Speech.TP[tempnum]) do
if self.Speech.TP[tempnum][i]:find("<after>") then
Speeches.SpellSucceed.TP:insert(self.Speech.TP[tempnum][i])
elseif self.Speech.TP[tempnum][i]:find("<emote>") then
self:Msg(self:MsgReplace(self.Speech.TP[tempnum][i], Spell.TargetName), "EMOTE")
elseif self.Speech.TP[tempnum][i]:find("<yell>") then
self:Msg(self:MsgReplace(self.Speech.TP[tempnum][i], Spell.TargetName), "YELL")
else
self:Msg(self:MsgReplace(self.Speech.TP[tempnum][i], Spell.TargetName), "WORLD")
end
end
end
AlphaBuffMenu = 1
AlphaBuffVar = GetTime() + 3
-- messages to be posted while summoning a pet demon
else for type = 3, 7, 1 do
if Spell.Name == Necrosis.Spell[type].Name then
Speeches.SpellSucceed.Pet = setmetatable({}, metatable)
Speeches.SpellSucceed.Sacrifice = setmetatable({}, metatable)
Speeches.DemonName = type - 2
if NecrosisConfig.DemonSummon and NecrosisConfig.ChatMsg and not NecrosisConfig.SM then
if not NecrosisConfig.PetName[Speeches.DemonName] and self.Speech.Demon[6] then
local tempnum = math.random(1, #self.Speech.Demon[6])
while tempnum == Speeches.LastSpeech.Pet and #self.Speech.Demon[6] >= 2 do
tempnum = math.random(1, #self.Speech.Demon[6])
end
Speeches.LastSpeech.Pet = tempnum
for i in ipairs(self.Speech.Demon[6][tempnum]) do
if self.Speech.Demon[6][tempnum][i]:find("<after>") then
Speeches.SpellSucceed.Pet:insert(self.Speech.Demon[6][tempnum][i])
elseif self.Speech.Demon[6][tempnum][i]:find("<sacrifice>")then
Speeches.SpellSucceed.Sacrifice:insert(self.Speech.Demon[6][tempnum][i])
elseif self.Speech.Demon[6][tempnum][i]:find("<emote>") then
self:Msg(self:MsgReplace(self.Speech.Demon[6][tempnum][i]), "EMOTE")
elseif self.Speech.Demon[6][tempnum][i]:find("<yell>") then
self:Msg(self:MsgReplace(self.Speech.Demon[6][tempnum][i]), "YELL")
else
self:Msg(self:MsgReplace(self.Speech.Demon[6][tempnum][i]), "SAY")
end
end
elseif self.Speech.Demon[Speeches.DemonName] then
local tempnum = math.random(1, #self.Speech.Demon[Speeches.DemonName])
while tempnum == Speeches.LastSpeech.Pet and #self.Speech.Demon[Speeches.DemonName] >= 2 do
tempnum = math.random(1, #self.Speech.Demon[Speeches.DemonName])
end
Speeches.LastSpeech.Pet = tempnum
for i in ipairs(self.Speech.Demon[Speeches.DemonName][tempnum]) do
if self.Speech.Demon[Speeches.DemonName][tempnum][i]:find("<after>") then
Speeches.SpellSucceed.Pet:insert(
self.Speech.Demon[Speeches.DemonName][tempnum][i]
)
elseif self.Speech.Demon[Speeches.DemonName][tempnum][i]:find("<sacrifice>")then
Speeches.SpellSucceed.Sacrifice:insert(
self.Speech.Demon[Speeches.DemonName][tempnum][i]
)
elseif self.Speech.Demon[Speeches.DemonName][tempnum][i]:find("<emote>") then
self:Msg(self:MsgReplace(self.Speech.Demon[Speeches.DemonName][tempnum][i], nil , Speeches.DemonName), "EMOTE")
elseif self.Speech.Demon[Speeches.DemonName][tempnum][i]:find("<yell>") then
self:Msg(self:MsgReplace(self.Speech.Demon[Speeches.DemonName][tempnum][i], nil , Speeches.DemonName), "YELL")
else
self:Msg(self:MsgReplace(self.Speech.Demon[Speeches.DemonName][tempnum][i], nil , Speeches.DemonName), "SAY")
end
end
end
end
AlphaPetMenu = 1
AlphaPetVar = GetTime() + 3
end
end end
return Speeches
end
------------------------------------------------------------------------------------------------------
-- Handles the posting of messages after a spell has been cast.
------------------------------------------------------------------------------------------------------
function Necrosis:Speech_Then(Spell, DemonName, Speech)
-- messages to be posted after a mount is summoned.
if (Spell.Name == Necrosis.Spell[1].Name or Spell.Name == Necrosis.Spell[2].Name) then
for i in ipairs(Speech.Steed) do
if Speech.Steed[i]:find("<emote>") then
self:Msg(self:MsgReplace(Speech.Steed[i]), "EMOTE")
elseif Speech.Steed[i]:find("<yell>") then
self:Msg(self:MsgReplace(Speech.Steed[i]), "YELL")
else
self:Msg(self:MsgReplace(Speech.Steed[i]), "WORLD")
end
end
Speech.Steed = {}
if _G["NecrosisMountButton"] then
NecrosisMountButton:SetNormalTexture("Interface\\Addons\\Necrosis\\UI\\MountButton-02")
end
-- messages to be posted after a 'Ritual of Souls' is cast -Draven (April 3rd, 2008)
elseif Spell.Name == Necrosis.Spell[50].Name then
for i in ipairs(Speech.RoS) do
if Speech.RoS[i]:find("<emote>") then
self:Msg(self:MsgReplace(Speech.RoS[i]), "EMOTE")
elseif Speech.RoS[i]:find("<yell>") then
self:Msg(self:MsgReplace(Speech.RoS[i]), "YELL")
else
self:Msg(self:MsgReplace(Speech.RoS[i]), "WORLD")
end
end
Speech.RoS = {}
-- messages to be posted after 'Soulstone' is cast
elseif Spell.Name == Necrosis.Spell[11].Name then
for i in ipairs(Speech.Rez) do
if Speech.Rez[i]:find("<emote>") then
self:Msg(self:MsgReplace(Speech.Rez[i], Spell.TargetName), "EMOTE")
elseif Speech.Rez[i]:find("<yell>") then
self:Msg(self:MsgReplace(Speech.Rez[i], Spell.TargetName), "YELL")
else
self:Msg(self:MsgReplace(Speech.Rez[i], Spell.TargetName), "WORLD")
end
end
Speech.Rez = {}
-- messages to be posted after 'Ritual of Summoning' is cast
elseif (Spell.Name == Necrosis.Spell[37].Name) then
for i in ipairs(Speech.TP) do
if Speech.TP[i]:find("<emote>") then
self:Msg(self:MsgReplace(Speech.TP[i], Spell.TargetName), "EMOTE")
elseif Speech.TP[i]:find("<yell>") then
self:Msg(self:MsgReplace(Speech.TP[i], Spell.TargetName), "YELL")
else
self:Msg(self:MsgReplace(Speech.TP[i], Spell.TargetName), "WORLD")
end
end
Speech.TP = {}
-- messages to be posted after sacrificing a demon
elseif Spell.Name == Necrosis.Spell[44].Name then
for i in ipairs(Speech.Sacrifice) do
if Speech.Sacrifice[i]:find("<emote>") then
self:Msg(self:MsgReplace(Speech.Sacrifice[i], nil, DemonName), "EMOTE")
elseif Speech.Sacrifice[i]:find("<yell>") then
self:Msg(self:MsgReplace(Speech.Sacrifice[i], nil, DemonName), "YELL")
else
self:Msg(self:MsgReplace(Speech.Sacrifice[i], nil, DemonName), "SAY")
end
end
Speech.Sacrifice = {}
-- messages to be posted after summoning a demon
elseif Spell.Name == Necrosis.Spell[3].Name
or Spell.Name == Necrosis.Spell[4].Name
or Spell.Name == Necrosis.Spell[5].Name
or Spell.Name == Necrosis.Spell[6].Name
or Spell.Name == Necrosis.Spell[7].Name
then
for i in ipairs(Speech.Pet) do
if Speech.Pet[i]:find("<emote>") then
self:Msg(self:MsgReplace(Speech.Pet[i], nil, DemonName), "EMOTE")
elseif Speech.Pet[i]:find("<yell>") then
self:Msg(self:MsgReplace(Speech.Pet[i], nil, DemonName), "YELL")
else
self:Msg(self:MsgReplace(Speech.Pet[i], nil, DemonName), "SAY")
end
end
Speech.Pet = {}
end
return Speech
end