forked from BlackHobbiT/necrosis-twow
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathNecrosisTimerFunction.lua
More file actions
351 lines (311 loc) · 11.4 KB
/
Copy pathNecrosisTimerFunction.lua
File metadata and controls
351 lines (311 loc) · 11.4 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
------------------------------------------------------------------------------------------------------
-- Necrosis LdC
--
-- Créateur initial (US) : Infernal (http://www.revolvus.com/games/interface/necrosis/)
-- Implémentation de base (FR) : Tilienna Thorondor
-- Reprise du projet : Lomig & Nyx des Larmes de Cenarius, Kael'Thas
--
-- Skins et voix Françaises : Eliah, Ner'zhul
-- Version Allemande par Arne Meier et Halisstra, Lothar
-- Remerciements spéciaux pour Sadyre (JoL)
-- Version 23.04.2006-1
------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------
-- FONCTIONS D'INSERTION
------------------------------------------------------------------------------------------------------
-- La table des timers est là pour ça !
function Necrosis_InsertTimerParTable(IndexTable, Target, LevelTarget, SpellGroup, SpellTimer, TimerTable)
-- Insertion de l'entrée dans le tableau
table.insert(SpellTimer, {
Name = NECROSIS_SPELL_TABLE[IndexTable].Name,
Time = NECROSIS_SPELL_TABLE[IndexTable].Length,
TimeMax = floor(GetTime() + NECROSIS_SPELL_TABLE[IndexTable].Length),
Type = NECROSIS_SPELL_TABLE[IndexTable].Type,
Target = Target,
TargetLevel = LevelTarget,
Group = 0,
Gtimer = nil,
})
-- Association d'un timer graphique au timer
SpellTimer, TimerTable = Necrosis_AddFrame(SpellTimer, TimerTable)
-- Tri des entrées par type de sort
Necrosis_Tri(SpellTimer, "Type")
-- Création des groupes (noms des mobs) des timers
SpellGroup, SpellTimer = Necrosis_Parsing(SpellGroup, SpellTimer)
return SpellGroup, SpellTimer, TimerTable
end
-- Et pour insérer le timer de pierres
function Necrosis_InsertTimerStone(Stone, start, duration, SpellGroup, SpellTimer, TimerTable)
-- Insertion de l'entrée dans le tableau
if Stone == "Healthstone" then
table.insert(SpellTimer, {
Name = NECROSIS_COOLDOWN.Healthstone,
Time = 120,
TimeMax = floor(GetTime() + 120),
Type = 2,
Target = "",
TargetLevel = "",
Group = 2,
Gtimer = nil,
})
-- Association d'un timer graphique au timer
SpellTimer, TimerTable = Necrosis_AddFrame(SpellTimer, TimerTable)
elseif Stone == "Spellstone" then
table.insert(SpellTimer, {
Name = NECROSIS_COOLDOWN.Spellstone,
Time = 120,
TimeMax = floor(GetTime() + 120),
Type = 2,
Target = "",
TargetLevel = "",
Group = 2,
Gtimer = nil,
})
-- Association d'un timer graphique au timer
SpellTimer, TimerTable = Necrosis_AddFrame(SpellTimer, TimerTable)
elseif Stone == "Soulstone" then
table.insert(SpellTimer, {
Name = NECROSIS_SPELL_TABLE[11].Name,
Time = floor(duration - GetTime() + start),
TimeMax = floor(start + duration),
Type = NECROSIS_SPELL_TABLE[11].Type,
Target = "???",
TargetLevel = "",
Group = 1,
Gtimer = nil,
})
-- Association d'un timer graphique au timer
SpellTimer, TimerTable = Necrosis_AddFrame(SpellTimer, TimerTable)
end
-- Tri des entrées par type de sort
Necrosis_Tri(SpellTimer, "Type")
-- Création des groupes (noms des mobs) des timers
SpellGroup, SpellTimer = Necrosis_Parsing(SpellGroup, SpellTimer)
return SpellGroup, SpellTimer, TimerTable
end
-- Pour la création de timers personnels
function NecrosisTimerX(nom, duree, truc, Target, LevelTarget, SpellGroup, SpellTimer, TimerTable)
table.insert(SpellTimer, {
Name = nom,
Time = duree,
TimeMax = floor(GetTime() + duree),
Type = truc,
Target = Target,
TargetLevel = LevelTarget,
Group = 0,
Gtimer = nil,
})
-- Association d'un timer graphique au timer
SpellTimer, TimerTable = Necrosis_AddFrame(SpellTimer, TimerTable)
-- Tri des entrées par type de sort
Necrosis_Tri(SpellTimer, "Type")
-- Création des groupes (noms des mobs) des timers
SpellGroup, SpellTimer = Necrosis_Parsing(SpellGroup, SpellTimer)
return SpellGroup, SpellTimer, TimerTable
end
------------------------------------------------------------------------------------------------------
-- FONCTIONS DE RETRAIT
------------------------------------------------------------------------------------------------------
-- Connaissant l'index du Timer dans la liste, on le supprime
function Necrosis_RetraitTimerParIndex(index, SpellTimer, TimerTable)
-- Suppression du timer graphique
local Gtime = SpellTimer[index].Gtimer
TimerTable = Necrosis_RemoveFrame(Gtime, TimerTable)
-- On enlève le timer de la liste
table.remove(SpellTimer, index)
return SpellTimer, TimerTable
end
-- Si on veut supprimer spécifiquement un Timer...
function Necrosis_RetraitTimerParNom(name, SpellTimer, TimerTable)
for index = 1, table.getn(SpellTimer), 1 do
if SpellTimer[index].Name == name then
SpellTimer = Necrosis_RetraitTimerParIndex(index, SpellTimer, TimerTable)
break
end
end
return SpellTimer, TimerTable
end
-- Fonction pour enlever les timers de combat lors de la regen
function Necrosis_RetraitTimerCombat(SpellGroup, SpellTimer, TimerTable)
for index = 1, table.getn(SpellTimer), 1 do
if SpellTimer[index] then
-- Si les cooldowns sont nominatifs, on enlève le nom
if SpellTimer[index].Type == 3 then
SpellTimer[index].Target = ""
SpellTimer[index].TargetLevel = ""
end
-- Enlevage des timers de combat
if (SpellTimer[index].Type == 4) or (SpellTimer[index].Type == 5) then
SpellTimer = Necrosis_RetraitTimerParIndex(index, SpellTimer, TimerTable)
end
end
end
if table.getn(SpellGroup.Name) >= 4 then
for index = 4, table.getn(SpellGroup.Name), 1 do
table.remove(SpellGroup.Name)
table.remove(SpellGroup.SubName)
table.remove(SpellGroup.Visible)
end
end
return SpellGroup, SpellTimer, TimerTable
end
------------------------------------------------------------------------------------------------------
-- FONCTIONS BOOLEENNES
------------------------------------------------------------------------------------------------------
function Necrosis_TimerExisteDeja(Nom, SpellTimer)
for index = 1, table.getn(SpellTimer), 1 do
if SpellTimer[index].Name == Nom then
return true
end
end
return false
end
------------------------------------------------------------------------------------------------------
-- FONCTIONS DE TRI
------------------------------------------------------------------------------------------------------
-- On définit les groupes de chaque Timer
function Necrosis_Parsing(SpellGroup, SpellTimer)
local GroupeOK = false
for index = 1, table.getn(SpellTimer), 1 do
local GroupeOK = false
for i = 1, table.getn(SpellGroup.Name), 1 do
if
((SpellTimer[index].Type == i) and (i <= 3))
or (
SpellTimer[index].Target == SpellGroup.Name[i]
and SpellTimer[index].TargetLevel == SpellGroup.SubName[i]
)
then
GroupeOK = true
SpellTimer[index].Group = i
break
end
end
-- Si le groupe n'existe pas, on en crée un nouveau
if not GroupeOK then
table.insert(SpellGroup.Name, SpellTimer[index].Target)
table.insert(SpellGroup.SubName, SpellTimer[index].TargetLevel)
table.insert(SpellGroup.Visible, false)
SpellTimer[index].Group = table.getn(SpellGroup.Name)
end
end
Necrosis_Tri(SpellTimer, "Group")
return SpellGroup, SpellTimer
end
-- On trie les timers selon leur groupe
function Necrosis_Tri(SpellTimer, clef)
return table.sort(SpellTimer, function(SubTab1, SubTab2)
return SubTab1[clef] < SubTab2[clef]
end)
end
------------------------------------------------------------------------------------------------------
-- FONCTIONS D'AFFICHAGE : CREATION DE LA CHAINE DE CARACTERE
------------------------------------------------------------------------------------------------------
function Necrosis_DisplayTimer(display, index, SpellGroup, SpellTimer, GraphicalTimer, TimerTable)
if not SpellTimer then
return display, SpellGroup
end
local minutes = 0
local seconds = 0
local affichage
-- Changement de la couleur suivant le temps restant
local percent = (floor(SpellTimer[index].TimeMax - floor(GetTime())) / SpellTimer[index].Time) * 100
local color = NecrosisTimerColor(percent)
if
not SpellGroup.Visible[SpellTimer[index].Group]
and SpellGroup.SubName[SpellTimer[index].Group] ~= nil
and SpellGroup.Name[SpellTimer[index].Group] ~= nil
then
display = display
.. "<purple>-------------------------------\n"
.. SpellGroup.Name[SpellTimer[index].Group]
.. " "
.. SpellGroup.SubName[SpellTimer[index].Group]
.. "\n-------------------------------<close>\n"
-- Crée le tableau qui servira aux timers graphiques
table.insert(
GraphicalTimer.texte,
SpellGroup.Name[SpellTimer[index].Group] .. " " .. SpellGroup.SubName[SpellTimer[index].Group]
)
table.insert(GraphicalTimer.TimeMax, 0)
table.insert(GraphicalTimer.Time, 0)
table.insert(GraphicalTimer.titre, true)
table.insert(GraphicalTimer.temps, "")
table.insert(GraphicalTimer.Gtimer, 0)
SpellGroup.Visible[SpellTimer[index].Group] = true
end
-- Mise en place d'un Chrono plutôt qu'un Compte à Rebours pour l'asservissement
if SpellTimer[index].Name == NECROSIS_SPELL_TABLE[10].Name then
seconds = floor(GetTime()) - (SpellTimer[index].TimeMax - SpellTimer[index].Time)
else
seconds = SpellTimer[index].TimeMax - floor(GetTime())
end
minutes = floor(seconds / 60)
if minutes > 0 then
if minutes > 9 then
affichage = tostring(minutes) .. ":"
else
affichage = "0" .. minutes .. ":"
end
else
affichage = "0:"
end
seconds = mod(seconds, 60)
if seconds > 9 then
affichage = affichage .. seconds
else
affichage = affichage .. "0" .. seconds
end
display = display .. "<white>" .. affichage .. " - <close>"
-- Crée le tableau qui servira aux timers graphiques
if
(SpellTimer[index].Type == 1 or SpellTimer[index].Name == NECROSIS_SPELL_TABLE[16].Name)
and (SpellTimer[index].Target ~= "")
then
if NecrosisConfig.SpellTimerPos == 1 then
affichage = affichage .. " - " .. SpellTimer[index].Target
else
affichage = SpellTimer[index].Target .. " - " .. affichage
end
end
table.insert(GraphicalTimer.texte, SpellTimer[index].Name)
table.insert(GraphicalTimer.TimeMax, SpellTimer[index].TimeMax)
table.insert(GraphicalTimer.Time, SpellTimer[index].Time)
table.insert(GraphicalTimer.titre, false)
table.insert(GraphicalTimer.temps, affichage)
table.insert(GraphicalTimer.Gtimer, SpellTimer[index].Gtimer)
if NecrosisConfig.CountType == 3 then
if SpellTimer[index].Name == NECROSIS_SPELL_TABLE[11].Name then
if minutes > 0 then
NecrosisShardCount:SetText(minutes .. " m")
else
NecrosisShardCount:SetText(seconds)
end
end
end
if NecrosisConfig.Circle == 2 then
if SpellTimer[index].Name == NECROSIS_SPELL_TABLE[11].Name then
if minutes >= 16 then
NecrosisButton:SetNormalTexture("Interface\\AddOns\\Necrosis\\UI\\Turquoise\\Shard" .. minutes - 15)
elseif minutes >= 1 or seconds >= 33 then
NecrosisButton:SetNormalTexture("Interface\\AddOns\\Necrosis\\UI\\Orange\\Shard" .. minutes + 1)
else
NecrosisButton:SetNormalTexture("Interface\\AddOns\\Necrosis\\UI\\Rose\\Shard" .. seconds)
end
end
end
display = display .. color .. SpellTimer[index].Name .. "<close><white>"
if
(SpellTimer[index].Type == 1 or SpellTimer[index].Name == NECROSIS_SPELL_TABLE[16].Name)
and (SpellTimer[index].Target ~= "")
then
display = display .. " - " .. SpellTimer[index].Target .. "<close>\n"
else
display = display .. "<close>\n"
end
-- Affichage des timers graphiques (si sélectionnés)
if NecrosisConfig.Graphical then
NecrosisAfficheTimer(GraphicalTimer, TimerTable)
end
return display, SpellGroup, GraphicalTimer, TimerTable
end