-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathNecrosis.lua
3188 lines (2985 loc) · 121 KB
/
Necrosis.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
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
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
------------------------------------------------------------------------------------------------------
-- 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 05.09.2006-1
------------------------------------------------------------------------------------------------------
-- Configuration par défaut
-- Se charge en cas d'absence de configuration ou de changement de version
Default_NecrosisConfig = {
Version = NecrosisData.Version;
SoulshardContainer = 4;
SoulshardSort = false;
SoulshardDestroy = false;
ShadowTranceAlert = true;
ShowSpellTimers = true;
AntiFearAlert = true;
NecrosisLockServ = true;
NecrosisAngle = 180;
StonePosition = {true, true, true, true, true, true, true, true};
NecrosisToolTip = true;
NoDragAll = false;
PetMenuPos = 34;
BuffMenuPos = 34;
CurseMenuPos = 34;
ChatMsg = true;
ChatType = true;
NecrosisLanguage = GetLocale();
ShowCount = true;
CountType = 1;
ShadowTranceScale = 100;
NecrosisButtonScale = 90;
NecrosisColor = "Rose";
Sound = true;
SpellTimerPos = 1;
SpellTimerJust = "LEFT";
Circle = 1;
Graphical = true;
Yellow = true;
SensListe = 1;
PetName = {
[1] = " ",
[2] = " ",
[3] = " ",
[4] = " "
};
DominationUp = false;
AmplifyUp = false;
SM = false;
SteedSummon = false;
DemonSummon = true;
BanishScale = 100;
};
NecrosisConfig = {};
local Debug = false;
local Loaded = false
-- Détection des initialisations du mod
local NecrosisRL = true;
-- Initialisation des variables utilisées par Necrosis pour la gestion des sorts lancés
local SpellCastName = nil;
local SpellCastRank = nil;
local SpellTargetName = nil;
local SpellTargetLevel = nil;
local SpellCastTime = 0;
-- Initialisation des tableaux gérant les Timers
-- Un pour les sorts à timer, l'autre pour les groupes de mobs
-- Le dernier permet l'association d'un timer à une frame graphique
SpellTimer = {};
local SpellGroup = {
Name = {"Rez", "Main", "Cooldown"},
SubName = {" ", " ", " "},
Visible = {true, true, true}
};
local TimerTable = {};
for i = 1, 50, 1 do
TimerTable[i] = false;
end
-- Menus : Permet l'affichage des menus de buff et de pet
local PetShow = false;
local PetMenuShow = false;
local BuffShow = false;
local BuffMenuShow = false;
local CurseShow = false;
local CurseMenuShow = false;
-- Menus : Permet la disparition progressive du menu des pets (transparence)
local AlphaPetMenu = 1;
local AlphaPetVar = 0;
local PetVisible = false;
-- Menus : Permet la disparition progressive du menu des buffs (transparence)
local AlphaBuffMenu = 1;
local AlphaBuffVar = 0;
local BuffVisible = false;
-- Menus : Permet la disparition progressive du menu des curses (transparence)
local AlphaCurseMenu = 1;
local AlphaCurseVar = 0;
local CurseVisible = false;
-- Menus : Permet de recaster le dernier cast du menu en cliquant milieu sur celui-ci
local LastDemon = 0;
local LastBuff = 0;
local LastCurse = 0;
local LastCurseClick = "LeftButton";
-- Liste des boutons disponible pour le démoniste dans chaque menu
local PetMenuCreate = {};
local BuffMenuCreate = {};
local CurseMenuCreate = {};
-- Variables utilisées pour la gestion des montures
local MountAvailable = false;
local NecrosisMounted = false;
local NecrosisTellMounted = true;
local PlayerCombat = false;
-- Variables utilisées pour la gestion des transes de l'ombre
local ShadowTrance = false;
local AntiFearInUse = false;
local ShadowTranceID = -1;
-- Variables utilisées pour la gestion des fragments d'âme
-- (principalement comptage)
local Soulshards = 0;
local SoulshardContainer = 4;
local SoulshardSlot = {};
local SoulshardSlotID = 1;
local SoulshardMP = 0;
local SoulshardTime = 0;
-- Variables utilisées pour la gestion des composants d'invocation
-- (principalement comptage)
local InfernalStone = 0;
local DemoniacStone = 0;
-- Variables utilisées pour la gestion des boutons d'invocation et d'utilisation des pierres
local StoneIDInSpellTable = {0, 0, 0, 0}
local SoulstoneUsedOnTarget = false;
local SoulstoneOnHand = false;
local SoulstoneLocation = {nil,nil};
local SoulstoneMode = 1;
local HealthstoneOnHand = false;
local HealthstoneLocation = {nil,nil};
local HealthstoneMode = 1;
local FirestoneOnHand = false;
local FirestoneLocation = {nil,nil};
local FirestoneMode = 1;
local SpellstoneOnHand = false;
local SpellstoneLocation = {nil,nil};
local SpellstoneMode = 1;
local HearthstoneOnHand = false;
local HearthstoneLocation = {nil,nil};
local ItemswitchLocation = {nil,nil};
local ItemOnHand = false;
-- Variables gérant la possibilité ou l'impossibilité d'utiliser un timer de rez
local SoulstoneWaiting = false;
local SoulstoneCooldown = false;
local SoulstoneAdvice = false;
local SoulstoneTarget = "";
-- Variables utilisées dans la gestion des démons
local DemonType = nil;
local DemonEnslaved = false;
-- Variables utilisées pour l'anti-fear
local AFblink1, AFBlink2 = 0;
local AFImageType = { "", "Immu", "Prot"}; -- Fear warning button filename variations
local AFCurrentTargetImmune = false;
-- Variables utilisées pour les échanges de pierre avec les joueurs
local NecrosisTradeRequest = false;
local Trading = false;
local TradingNow = 0;
-- Gestion des sacs à fragment d'âme
local BagIsSoulPouch = {nil, nil, nil, nil, nil};
-- Variable contenant les derniers messages invoqués
local PetMess = 0
local SteedMess = 0
local RezMess = 0
local TPMess = 0
-- Permet la gestion des tooltips dans Necrosis (sans la frame des pièces de monnaie)
local lOriginal_GameTooltip_ClearMoney;
local Necrosis_In = true;
------------------------------------------------------------------------------------------------------
-- FONCTIONS NECROSIS APPLIQUEES A L'ENTREE DANS LE JEU
------------------------------------------------------------------------------------------------------
-- Fonction appliquée au chargement
function Necrosis_OnLoad()
-- Permet de repérer les sorts lancés
Necrosis_Hook("UseAction", "Necrosis_UseAction", "before");
Necrosis_Hook("CastSpell", "Necrosis_CastSpell", "before");
Necrosis_Hook("CastSpellByName", "Necrosis_CastSpellByName", "before");
-- Enregistrement des événements interceptés par Necrosis
this:RegisterEvent("PLAYER_ENTERING_WORLD");
this:RegisterEvent("PLAYER_LEAVING_WORLD");
NecrosisButton:RegisterEvent("BAG_UPDATE");
NecrosisButton:RegisterEvent("CHAT_MSG_SPELL_PERIODIC_SELF_BUFFS");
NecrosisButton:RegisterEvent("CHAT_MSG_SPELL_AURA_GONE_SELF");
NecrosisButton:RegisterEvent("CHAT_MSG_SPELL_BREAK_AURA");
NecrosisButton:RegisterEvent("PLAYER_REGEN_DISABLED");
NecrosisButton:RegisterEvent("PLAYER_REGEN_ENABLED");
NecrosisButton:RegisterEvent("UNIT_PET");
NecrosisButton:RegisterEvent("SPELLCAST_START");
NecrosisButton:RegisterEvent("SPELLCAST_FAILED");
NecrosisButton:RegisterEvent("SPELLCAST_INTERRUPTED");
NecrosisButton:RegisterEvent("SPELLCAST_STOP");
NecrosisButton:RegisterEvent("LEARNED_SPELL_IN_TAB");
NecrosisButton:RegisterEvent("CHAT_MSG_SPELL_SELF_DAMAGE");
NecrosisButton:RegisterEvent("PLAYER_TARGET_CHANGED");
NecrosisButton:RegisterEvent("TRADE_REQUEST");
NecrosisButton:RegisterEvent("TRADE_REQUEST_CANCEL");
NecrosisButton:RegisterEvent("TRADE_SHOW");
NecrosisButton:RegisterEvent("TRADE_CLOSED");
-- Enregistrement des composants graphiques
NecrosisButton:RegisterForDrag("LeftButton");
NecrosisButton:RegisterForClicks("LeftButtonUp", "RightButtonUp");
NecrosisButton:SetFrameLevel(1);
-- Enregistrement de la commande console
SlashCmdList["NecrosisCommand"] = Necrosis_SlashHandler;
SLASH_NecrosisCommand1 = "/necro";
end
-- Fonction appliquée une fois les paramètres des mods chargés
function Necrosis_LoadVariables()
if Loaded or UnitClass("player") ~= NECROSIS_UNIT_WARLOCK then
return
end
Necrosis_Initialize();
Loaded = true ;
-- Détection du type de démon présent à la connexion
DemonType = UnitCreatureFamily("pet");
end
------------------------------------------------------------------------------------------------------
-- FONCTIONS NECROSIS
------------------------------------------------------------------------------------------------------
-- Fonction lancée à la mise à jour de l'interface (main) -- toutes les 0,1 secondes environ
function Necrosis_OnUpdate()
-- La fonction n'est utilisée que si Necrosis est initialisé et le joueur un Démoniste --
if (not Loaded) and UnitClass("player") ~= NECROSIS_UNIT_WARLOCK then
return;
end
-- La fonction n'est utilisée que si Necrosis est initialisé et le joueur un Démoniste --
-- Gestion des fragments d'âme : Tri des fragment toutes les secondes
local curTime = GetTime();
if ((curTime-SoulshardTime) >= 1) then
SoulshardTime = curTime;
if (SoulshardMP > 0) then
Necrosis_SoulshardSwitch("MOVE");
end
end
----------------------------------------------------------
-- Gestion des sorts du Démoniste
----------------------------------------------------------
-- Gestion du menu d'invocation des démons
if PetShow then
if GetTime() >= AlphaPetVar and AlphaPetMenu > 0 and (not PetVisible) then
AlphaPetVar = GetTime() + 0.1;
NecrosisPetMenu1:SetAlpha(AlphaPetMenu);
NecrosisPetMenu2:SetAlpha(AlphaPetMenu);
NecrosisPetMenu3:SetAlpha(AlphaPetMenu);
NecrosisPetMenu4:SetAlpha(AlphaPetMenu);
NecrosisPetMenu5:SetAlpha(AlphaPetMenu);
NecrosisPetMenu6:SetAlpha(AlphaPetMenu);
NecrosisPetMenu7:SetAlpha(AlphaPetMenu);
NecrosisPetMenu8:SetAlpha(AlphaPetMenu);
NecrosisPetMenu9:SetAlpha(AlphaPetMenu);
AlphaPetMenu = AlphaPetMenu - 0.1;
end
if AlphaPetMenu <= 0 then
Necrosis_PetMenu();
end
end
-- Gestion du menu des Buffs
if BuffShow then
if GetTime() >= AlphaBuffVar and AlphaBuffMenu > 0 and (not BuffVisible) then
AlphaBuffVar = GetTime() + 0.1;
NecrosisBuffMenu1:SetAlpha(AlphaBuffMenu);
NecrosisBuffMenu2:SetAlpha(AlphaBuffMenu);
NecrosisBuffMenu3:SetAlpha(AlphaBuffMenu);
NecrosisBuffMenu4:SetAlpha(AlphaBuffMenu);
NecrosisBuffMenu5:SetAlpha(AlphaBuffMenu);
NecrosisBuffMenu6:SetAlpha(AlphaBuffMenu);
NecrosisBuffMenu7:SetAlpha(AlphaBuffMenu);
NecrosisBuffMenu8:SetAlpha(AlphaBuffMenu);
NecrosisBuffMenu9:SetAlpha(AlphaBuffMenu);
AlphaBuffMenu = AlphaBuffMenu - 0.1;
end
if AlphaBuffMenu <= 0 then
Necrosis_BuffMenu();
end
end
-- Gestion du menu des Curses
if CurseShow then
if GetTime() >= AlphaCurseVar and AlphaCurseMenu > 0 and (not CurseVisible) then
AlphaCurseVar = GetTime() + 0.1;
NecrosisCurseMenu1:SetAlpha(AlphaCurseMenu);
NecrosisCurseMenu2:SetAlpha(AlphaCurseMenu);
NecrosisCurseMenu3:SetAlpha(AlphaCurseMenu);
NecrosisCurseMenu4:SetAlpha(AlphaCurseMenu);
NecrosisCurseMenu5:SetAlpha(AlphaCurseMenu);
NecrosisCurseMenu6:SetAlpha(AlphaCurseMenu);
NecrosisCurseMenu7:SetAlpha(AlphaCurseMenu);
NecrosisCurseMenu8:SetAlpha(AlphaCurseMenu);
NecrosisCurseMenu9:SetAlpha(AlphaCurseMenu);
AlphaCurseMenu = AlphaCurseMenu - 0.1;
end
if AlphaCurseMenu <= 0 then
Necrosis_CurseMenu();
end
end
-- Gestion du talent "Crépuscule"
if NecrosisConfig.ShadowTranceAlert then
local Actif = false;
local TimeLeft = 0;
Necrosis_UnitHasTrance();
if ShadowTranceID ~= -1 then Actif = true; end
if Actif and not ShadowTrance then
ShadowTrance = true;
Necrosis_Msg(NECROSIS_NIGHTFALL_TEXT.Message, "USER");
if NecrosisConfig.Sound then PlaySoundFile(NECROSIS_SOUND.ShadowTrance); end
local ShadowTranceIndex, cancel = GetPlayerBuff(ShadowTranceID,"HELPFUL|HARMFUL|PASSIVE");
TimeLeft = floor(GetPlayerBuffTimeLeft(ShadowTranceIndex));
NecrosisShadowTranceTimer:SetText(TimeLeft);
ShowUIPanel(NecrosisShadowTranceButton);
end
if not Actif and ShadowTrance then
HideUIPanel(NecrosisShadowTranceButton);
ShadowTrance = false;
end
if Actif and ShadowTrance then
local ShadowTranceIndex, cancel = GetPlayerBuff(ShadowTranceID,"HELPFUL|HARMFUL|PASSIVE");
TimeLeft = floor(GetPlayerBuffTimeLeft(ShadowTranceIndex));
NecrosisShadowTranceTimer:SetText(TimeLeft);
end
end
-- Gestion des Antifears
if NecrosisConfig.AntiFearAlert then
local Actif = false; -- must be False, or a number from 1 to AFImageType[] max element.
-- Checking if we have a target. Any fear need a target to be casted on
if UnitExists("target") and UnitCanAttack("player", "target") and not UnitIsDead("target") then
-- Checking if the target has natural immunity (only NPC target)
if not UnitIsPlayer("target") then
for index=1, table.getn(NECROSIS_ANTI_FEAR_UNIT), 1 do
if (UnitCreatureType("target") == NECROSIS_ANTI_FEAR_UNIT[index] ) then
Actif = 2; -- Immun
break;
end
end
end
-- We'll start to parse the target buffs, as his class doesn't give him natural permanent immunity
if not Actif then
for index=1, table.getn(NECROSIS_ANTI_FEAR_SPELL.Buff), 1 do
if Necrosis_UnitHasBuff("target",NECROSIS_ANTI_FEAR_SPELL.Buff[index]) then
Actif = 3; -- Prot
break;
end
end
-- No buff found, let's try the debuffs
for index=1, table.getn(NECROSIS_ANTI_FEAR_SPELL.Debuff), 1 do
if Necrosis_UnitHasEffect("target",NECROSIS_ANTI_FEAR_SPELL.Debuff[index]) then
Actif = 3; -- Prot
break;
end
end
end
-- an immunity has been detected before, but we still don't know why => show the button anyway
if AFCurrentTargetImmune and not Actif then
Actif = 1;
end
end
if Actif then
-- Antifear button is currently not visible, we have to change that
if not AntiFearInUse then
AntiFearInUse = true;
Necrosis_Msg(NECROSIS_MESSAGE.Information.FearProtect, "USER");
NecrosisAntiFearButton:SetNormalTexture("Interface\\Addons\\Necrosis\\UI\\AntiFear"..AFImageType[Actif].."-02");
if NecrosisConfig.Sound then PlaySoundFile(NECROSIS_SOUND.Fear); end
ShowUIPanel(NecrosisAntiFearButton);
AFBlink1 = GetTime() + 0.6;
AFBlink2 = 2;
-- Timer to make the button blink
elseif GetTime() >= AFBlink1 then
if AFBlink2 == 1 then
AFBlink2 = 2;
else
AFBlink2 = 1;
end
AFBlink1 = GetTime() + 0.4;
NecrosisAntiFearButton:SetNormalTexture("Interface\\Addons\\Necrosis\\UI\\AntiFear"..AFImageType[Actif].."-0"..AFBlink2);
end
elseif AntiFearInUse then -- No antifear on target, but the button is still visible => gonna hide it
AntiFearInUse = false;
HideUIPanel(NecrosisAntiFearButton);
end
end
-- Gestion du Timer des sorts
if (not NecrosisSpellTimerButton:IsVisible()) then
ShowUIPanel(NecrosisSpellTimerButton);
end
local display = "";
if NecrosisConfig.CountType == 3 then
NecrosisShardCount:SetText("");
end
local update = false;
if ((curTime - SpellCastTime) >= 1) then
SpellCastTime = curTime;
update = true;
end
-- On met à jour les boutons toutes les secondes
-- On accepte le trade de la pierre de soin si transfert en cours
if update then
if Trading then
TradingNow = TradingNow - 1;
if TradingNow == 0 then
AcceptTrade();
Trading = false;
end
end
Necrosis_UpdateIcons();
end
-- Parcours du tableau des Timers
local GraphicalTimer = {texte = {}, TimeMax = {}, Time = {}, titre = {}, temps = {}, Gtimer = {}};
if SpellTimer then
for index = 1, table.getn(SpellTimer), 1 do
if SpellTimer[index] then
if (GetTime() <= SpellTimer[index].TimeMax) then
-- Création de l'affichage des timers
display, SpellGroup, GraphicalTimer, TimerTable = Necrosis_DisplayTimer(display, index, SpellGroup, SpellTimer, GraphicalTimer, TimerTable);
end
-- Action toutes les secondes
if (update) then
-- On enlève les timers terminés
local TimeLocal = GetTime();
if TimeLocal >= (SpellTimer[index].TimeMax - 0.5) and SpellTimer[index].TimeMax ~= -1 then
-- Si le timer était celui de la Pierre d'âme, on prévient le Démoniste
if SpellTimer[index].Name == NECROSIS_SPELL_TABLE[11].Name then
Necrosis_Msg(NECROSIS_MESSAGE.Information.SoulstoneEnd, "USER");
SpellTimer[index].Target = "";
SpellTimer[index].TimeMax = -1;
if NecrosisConfig.Sound then PlaySoundFile(NECROSIS_SOUND.SoulstoneEnd); end
Necrosis_RemoveFrame(SpellTimer[index].Gtimer, TimerTable);
-- On met à jour l'apparence du bouton de la pierre d'âme
Necrosis_UpdateIcons();
-- Sinon on enlève le timer silencieusement (mais pas en cas d'enslave)
elseif SpellTimer[index].Name ~= NECROSIS_SPELL_TABLE[10].Name then
SpellTimer, TimerTable = Necrosis_RetraitTimerParIndex(index, SpellTimer, TimerTable);
index = 0;
break;
end
end
-- Si le Démoniste n'est plus sous l'emprise du Sacrifice
if SpellTimer and SpellTimer[index].Name == NECROSIS_SPELL_TABLE[17].Name then -- Sacrifice
if not Necrosis_UnitHasEffect("player", SpellTimer[index].Name) and SpellTimer[index].TimeMax ~= nil then
SpellTimer, TimerTable = Necrosis_RetraitTimerParIndex(index, SpellTimer, TimerTable);
index = 0;
break;
end
end
-- Si la cible visée n'est plus atteinte par un sort lancé [résists]
if SpellTimer and (SpellTimer[index].Type == 4 or SpellTimer[index].Type == 5)
and SpellTimer[index].Target == UnitName("target")
then
-- On triche pour laisser le temps au mob de bien sentir qu'il est débuffé ^^
if TimeLocal >= ((SpellTimer[index].TimeMax - SpellTimer[index].Time) + 1.5)
and SpellTimer[index] ~= 6 then
if not Necrosis_UnitHasEffect("target", SpellTimer[index].Name) then
SpellTimer, TimerTable = Necrosis_RetraitTimerParIndex(index, SpellTimer, TimerTable);
index = 0;
break;
end
end
end
end
end
end
else
for i = 1, 10, 1 do
local frameName = "NecrosisTarget"..i.."Text";
local frameItem = getglobal(frameName);
if frameItem:IsShown() then
frameItem:Hide();
end
end
end
if NecrosisConfig.ShowSpellTimers or NecrosisConfig.Graphical then
-- Si affichage de timer texte
if not NecrosisConfig.Graphical then
-- Coloration de l'affichage des timers
display = Necrosis_MsgAddColor(display);
-- Affichage des timers
NecrosisListSpells:SetText(display);
else
NecrosisListSpells:SetText("");
end
for i = 4, table.getn(SpellGroup.Name) do
SpellGroup.Visible[i] = false;
end
else
if (NecrosisSpellTimerButton:IsVisible()) then
NecrosisListSpells:SetText("");
HideUIPanel(NecrosisSpellTimerButton);
end
end
end
-- Fonction lancée selon l'événement intercepté
function Necrosis_OnEvent(event)
if (event == "PLAYER_ENTERING_WORLD") then
Necrosis_In = true;
elseif (event == "PLAYER_LEAVING_WORLD") then
Necrosis_In = false;
end
-- Traditionnel test : Le joueur est-il bien Démoniste ?
-- Le jeu est-il bine chargé ?
if (not Loaded) or (not Necrosis_In) or UnitClass("player") ~= NECROSIS_UNIT_WARLOCK then
return;
end
-- Si le contenu des sacs a changé, on vérifie que les Fragments d'âme sont toujours dans le bon sac
if (event == "BAG_UPDATE") then
if (NecrosisConfig.SoulshardSort) then
Necrosis_SoulshardSwitch("CHECK");
else
Necrosis_BagExplore();
end
-- Gestion de la fin de l'incantation des sorts
elseif (event == "SPELLCAST_STOP") then
Necrosis_SpellManagement();
-- Quand le démoniste commence à incanter un sort, on intercepte le nom de celui-ci
-- On sauve également le nom de la cible du sort ainsi que son niveau
elseif (event == "SPELLCAST_START") then
SpellCastName = arg1;
SpellTargetName = UnitName("target");
if not SpellTargetName then
SpellTargetName = "";
end
SpellTargetLevel = UnitLevel("target");
if not SpellTargetLevel then
SpellTargetLevel = "";
end
-- Quand le démoniste stoppe son incantation, on relache le nom de celui-ci
elseif (event == "SPELLCAST_FAILED") or (event == "SPELLCAST_INTERRUPTED") then
SpellCastName = nil;
SpellCastRank = nil;
SpellTargetName = nil;
SpellTargetLevel = nil;
-- Flag si une fenetre de Trade est ouverte, afin de pouvoir trader automatiquement les pierres de soin
elseif event == "TRADE_REQUEST" or event == "TRADE_SHOW" then
NecrosisTradeRequest = true;
elseif event == "TRADE_REQUEST_CANCEL" or event == "TRADE_CLOSED" then
NecrosisTradeRequest = false;
-- AntiFear button hide on target change
elseif event == "PLAYER_TARGET_CHANGED" then
if NecrosisConfig.AntiFearAlert and AFCurrentTargetImmune then
AFCurrentTargetImmune = false;
end
-- AntiFear immunity on cast detection
elseif event == "CHAT_MSG_SPELL_SELF_DAMAGE" then
if NecrosisConfig.AntiFearAlert then
for spell, creatureName in string.gfind(arg1, NECROSIS_ANTI_FEAR_SRCH) do
-- We check if the casted spell on the immune target is Fear or Death Coil
if spell == NECROSIS_SPELL_TABLE[13].Name or spell == NECROSIS_SPELL_TABLE[19].Name then
AFCurrentTargetImmune = true;
break;
end
end
end
-- Si le Démoniste apprend un nouveau sort / rang de sort, on récupère la nouvelle liste des sorts
-- Si le Démoniste apprend un nouveau sort de buff ou d'invocation, on recrée les boutons
elseif (event == "LEARNED_SPELL_IN_TAB") then
Necrosis_SpellSetup();
Necrosis_CreateMenu();
Necrosis_ButtonSetup();
-- A la fin du combat, on arrête de signaler le Crépuscule
-- On enlève les timers de sorts ainsi que les noms des mobs
elseif (event == "PLAYER_REGEN_ENABLED") then
PlayerCombat = false;
SpellGroup, SpellTimer, TimerTable = Necrosis_RetraitTimerCombat(SpellGroup, SpellTimer, TimerTable);
for i = 1, 10, 1 do
local frameName = "NecrosisTarget"..i.."Text";
local frameItem = getglobal(frameName);
if frameItem:IsShown() then
frameItem:Hide();
end
end
-- Quand le démoniste change de démon
elseif (event == "UNIT_PET" and arg1 == "player") then
Necrosis_ChangeDemon();
-- Actions personnelles -- "Buffs"
elseif (event == "CHAT_MSG_SPELL_PERIODIC_SELF_BUFFS") then
Necrosis_SelfEffect("BUFF");
-- Actions personnelles -- "Debuffs"
elseif event == "CHAT_MSG_SPELL_AURA_GONE_SELF" or event == "CHAT_MSG_SPELL_BREAK_AURA" then
Necrosis_SelfEffect("DEBUFF");
elseif event == "PLAYER_REGEN_DISABLED" then
PlayerCombat = true;
-- Fin de l'écran de chargement
end
return;
end
------------------------------------------------------------------------------------------------------
-- FONCTIONS NECROSIS "ON EVENT"
------------------------------------------------------------------------------------------------------
-- Events : PLAYER_ENTERING_WORLD et PLAYER_LEAVING_WORLD
-- Fonction appliquée à chaque écran de chargement
-- Quand on sort d'une zone, on arrête de surveiller les envents
-- Quand on rentre dans une zone, on reprend la surveillance
-- Cela permet d'éviter un temps de chargement trop long du mod
function Necrosis_RegisterManagement(RegistrationType)
if RegistrationType == "IN" then
NecrosisButton:RegisterEvent("BAG_UPDATE");
NecrosisButton:RegisterEvent("CHAT_MSG_SPELL_PERIODIC_SELF_BUFFS");
NecrosisButton:RegisterEvent("CHAT_MSG_SPELL_AURA_GONE_SELF");
NecrosisButton:RegisterEvent("CHAT_MSG_SPELL_BREAK_AURA");
NecrosisButton:RegisterEvent("PLAYER_REGEN_DISABLED");
NecrosisButton:RegisterEvent("PLAYER_REGEN_ENABLED");
NecrosisButton:RegisterEvent("UNIT_PET");
NecrosisButton:RegisterEvent("SPELLCAST_START");
NecrosisButton:RegisterEvent("SPELLCAST_FAILED");
NecrosisButton:RegisterEvent("SPELLCAST_INTERRUPTED");
NecrosisButton:RegisterEvent("SPELLCAST_STOP");
NecrosisButton:RegisterEvent("LEARNED_SPELL_IN_TAB");
NecrosisButton:RegisterEvent("CHAT_MSG_SPELL_SELF_DAMAGE");
NecrosisButton:RegisterEvent("PLAYER_TARGET_CHANGED");
NecrosisButton:RegisterEvent("TRADE_REQUEST");
NecrosisButton:RegisterEvent("TRADE_REQUEST_CANCEL");
NecrosisButton:RegisterEvent("TRADE_SHOW");
NecrosisButton:RegisterEvent("TRADE_CLOSED");
else
NecrosisButton:UnregisterEvent("BAG_UPDATE");
NecrosisButton:UnregisterEvent("CHAT_MSG_SPELL_PERIODIC_SELF_BUFFS");
NecrosisButton:UnregisterEvent("CHAT_MSG_SPELL_AURA_GONE_SELF");
NecrosisButton:UnregisterEvent("CHAT_MSG_SPELL_BREAK_AURA");
NecrosisButton:UnregisterEvent("PLAYER_REGEN_DISABLED");
NecrosisButton:UnregisterEvent("PLAYER_REGEN_ENABLED");
NecrosisButton:UnregisterEvent("UNIT_PET");
NecrosisButton:UnregisterEvent("SPELLCAST_START");
NecrosisButton:UnregisterEvent("SPELLCAST_FAILED");
NecrosisButton:UnregisterEvent("SPELLCAST_INTERRUPTED");
NecrosisButton:UnregisterEvent("SPELLCAST_STOP");
NecrosisButton:UnregisterEvent("LEARNED_SPELL_IN_TAB");
NecrosisButton:UnregisterEvent("CHAT_MSG_SPELL_SELF_DAMAGE");
NecrosisButton:UnregisterEvent("PLAYER_TARGET_CHANGED");
NecrosisButton:UnregisterEvent("TRADE_REQUEST");
NecrosisButton:UnregisterEvent("TRADE_REQUEST_CANCEL");
NecrosisButton:UnregisterEvent("TRADE_SHOW");
NecrosisButton:UnregisterEvent("TRADE_CLOSED");
end
return;
end
-- event : UNIT_PET
-- Permet de timer les asservissements, ainsi que de prévenir pour les ruptures d'asservissement
-- Change également le nom du pet au remplacement de celui-ci
function Necrosis_ChangeDemon()
-- Si le nouveau démon est un démon asservi, on place un timer de 5 minutes
if (Necrosis_UnitHasEffect("pet", NECROSIS_SPELL_TABLE[10].Name)) then
if (not DemonEnslaved) then
DemonEnslaved = true;
SpellGroup, SpellTimer, TimerTable = Necrosis_InsertTimerParTable(10, "","", SpellGroup, SpellTimer, TimerTable);
end
else
-- Quand le démon asservi est perdu, on retire le Timer et on prévient le Démoniste
if (DemonEnslaved) then
DemonEnslaved = false;
SpellTimer, TimerTable = Necrosis_RetraitTimerParNom(NECROSIS_SPELL_TABLE[10].Name, SpellTimer, TimerTable);
if NecrosisConfig.Sound then PlaySoundFile(NECROSIS_SOUND.EnslaveEnd); end
Necrosis_Msg(NECROSIS_MESSAGE.Information.EnslaveBreak, "USER");
end
end
-- Si le démon n'est pas asservi on définit son titre, et on met à jour son nom dans Necrosis
DemonType = UnitCreatureFamily("pet");
for i = 1, 4, 1 do
if DemonType == NECROSIS_PET_LOCAL_NAME[i] and NecrosisConfig.PetName[i] == " " and UnitName("pet") ~= UNKNOWNOBJECT then
NecrosisConfig.PetName[i] = UnitName("pet");
NecrosisLocalization();
break;
end
end
return;
end
-- events : CHAT_MSG_SPELL_PERIODIC_SELF_BUFFS, CHAT_MSG_SPELL_AURA_GONE_SELF et CHAT_MSG_SPELL_BREAK_AURA
-- Permet de gérer les effets apparaissants et disparaissants sur le démoniste
-- Basé sur le CombatLog
function Necrosis_SelfEffect(action)
if action == "BUFF" then
-- Insertion d'un timer quand le Démoniste subit "Sacrifice"
if arg1 == NECROSIS_TRANSLATION.SacrificeGain then
SpellGroup, SpellTimer, TimerTable = Necrosis_InsertTimerParTable(17, "", "", SpellGroup, SpellTimer, TimerTable);
end
-- Changement du bouton de monture quand le Démoniste chevauche
if string.find(arg1, NECROSIS_SPELL_TABLE[1].Name) or string.find(arg1, NECROSIS_SPELL_TABLE[2].Name) then
NecrosisMounted = true;
if NecrosisConfig.SteedSummon and NecrosisTellMounted
and NecrosisConfig.ChatMsg and NECROSIS_PET_MESSAGE[6] and not NecrosisConfig.SM
then
local tempnum = random(1, table.getn(NECROSIS_PET_MESSAGE[6]));
while tempnum == SteedMess and table.getn(NECROSIS_PET_MESSAGE[6]) >= 2 do
tempnum = random(1, table.getn(NECROSIS_PET_MESSAGE[6]));
end
SteedMess = tempnum;
for i = 1, table.getn(NECROSIS_PET_MESSAGE[6][tempnum]) do
Necrosis_Msg(Necrosis_MsgReplace(NECROSIS_PET_MESSAGE[6][tempnum][i]), "SAY");
end
NecrosisTellMounted = false;
end
NecrosisMountButton:SetNormalTexture("Interface\\Addons\\Necrosis\\UI\\MountButton-02");
end
-- Changement du bouton de la domination corrompue si celle-ci est activée + Timer de cooldown
if string.find(arg1, NECROSIS_SPELL_TABLE[15].Name) and NECROSIS_SPELL_TABLE[15].ID ~= nil then
DominationUp = true;
NecrosisPetMenu1:SetNormalTexture("Interface\\Addons\\Necrosis\\UI\\Domination-02");
end
-- Changement du bouton de la malédiction amplifiée si celle-ci est activée + Timer de cooldown
if string.find(arg1, NECROSIS_SPELL_TABLE[42].Name) and NECROSIS_SPELL_TABLE[42].ID ~= nil then
AmplifyUp = true;
NecrosisCurseMenu1:SetNormalTexture("Interface\\Addons\\Necrosis\\UI\\Amplify-02");
end
else
-- Changement du bouton de monture quand le Démoniste est démonté
if string.find(arg1, NECROSIS_SPELL_TABLE[1].Name) or string.find(arg1, NECROSIS_SPELL_TABLE[2].Name) then
NecrosisMounted = false;
NecrosisTellMounted = true;
NecrosisMountButton:SetNormalTexture("Interface\\Addons\\Necrosis\\UI\\MountButton-01");
end
-- Changement du bouton de Domination quand le Démoniste n'est plus sous son emprise
if string.find(arg1, NECROSIS_SPELL_TABLE[15].Name) and NECROSIS_SPELL_TABLE[15].ID ~= nil then
DominationUp = false;
NecrosisPetMenu1:SetNormalTexture("Interface\\Addons\\Necrosis\\UI\\Domination-01");
end
-- Changement du bouton de la malédiction amplifiée quand le Démoniste n'est plus sous son emprise
if string.find(arg1, NECROSIS_SPELL_TABLE[42].Name) and NECROSIS_SPELL_TABLE[42].ID ~= nil then
AmplifyUp = false;
NecrosisCurseMenu1:SetNormalTexture("Interface\\Addons\\Necrosis\\UI\\Amplify-01");
end
end
return;
end
-- event : SPELLCAST_STOP
-- Permet de gérer tout ce qui touche aux sorts une fois leur incantation réussie
function Necrosis_SpellManagement()
local SortActif = false;
if (SpellCastName) then
-- Si le sort lancé à été une Résurrection de Pierre d'âme, on place un timer
if (SpellCastName == NECROSIS_SPELL_TABLE[11].Name) then
if SpellTargetName == UnitName("player") then
SpellTargetName = "";
end
-- Si les messages sont actifs et que la pierre est posée sur un joueur ciblé, hop, message !
if (NecrosisConfig.ChatMsg or NecrosisConfig.SM)
and SoulstoneUsedOnTarget then
SoulstoneTarget = SpellTargetName;
SoulstoneAdvice = true;
end
SpellGroup, SpellTimer, TimerTable = Necrosis_InsertTimerParTable(11, SpellTargetName, "", SpellGroup, SpellTimer, TimerTable);
-- Si le sort était un rituel d'invocation, alors on écrit une phrase a caractère informatif aux joueurs
elseif (SpellCastName == NECROSIS_TRANSLATION.SummoningRitual)
and (NecrosisConfig.ChatMsg or NecrosisConfig.SM)
and NECROSIS_INVOCATION_MESSAGES then
local tempnum = random(1, table.getn(NECROSIS_INVOCATION_MESSAGES));
while tempnum == TPMess and table.getn(NECROSIS_INVOCATION_MESSAGES) >= 2 do
tempnum = random(1, table.getn(NECROSIS_INVOCATION_MESSAGES));
end
TPMess = tempnum;
for i = 1, table.getn(NECROSIS_INVOCATION_MESSAGES[tempnum]) do
Necrosis_Msg(Necrosis_MsgReplace(NECROSIS_INVOCATION_MESSAGES[tempnum][i], SpellTargetName), "WORLD");
end
-- Pour les autres sorts castés, tentative de timer si valable
else
for spell=1, table.getn(NECROSIS_SPELL_TABLE), 1 do
if SpellCastName == NECROSIS_SPELL_TABLE[spell].Name and not (spell == 10) then
-- Si le timer existe déjà sur la cible, on le met à jour
for thisspell=1, table.getn(SpellTimer), 1 do
if SpellTimer[thisspell].Name == SpellCastName
and SpellTimer[thisspell].Target == SpellTargetName
and SpellTimer[thisspell].TargetLevel == SpellTargetLevel
and NECROSIS_SPELL_TABLE[spell].Type ~= 4
and spell ~= 16
then
-- Si c'est sort lancé déjà présent sur un mob, on remet le timer à fond
if spell ~= 9 or (spell == 9 and not Necrosis_UnitHasEffect("target", SpellCastName)) then
SpellTimer[thisspell].Time = NECROSIS_SPELL_TABLE[spell].Length;
SpellTimer[thisspell].TimeMax = floor(GetTime() + NECROSIS_SPELL_TABLE[spell].Length);
if spell == 9 and SpellCastRank == 1 then
SpellTimer[thisspell].Time = 20;
SpellTimer[thisspell].TimeMax = floor(GetTime() + 20);
end
end
SortActif = true;
break;
end
-- Si c'est un banish sur une nouvelle cible, on supprime le timer précédent
if SpellTimer[thisspell].Name == SpellCastName and spell == 9
and
(SpellTimer[thisspell].Target ~= SpellTargetName
or SpellTimer[thisspell].TargetLevel ~= SpellTargetLevel)
then
SpellTimer, TimerTable = Necrosis_RetraitTimerParIndex(thisspell, SpellTimer, TimerTable);
SortActif = false;
break;
end
-- Si c'est un fear, on supprime le timer du fear précédent
if SpellTimer[thisspell].Name == SpellCastName and spell == 13 then
SpellTimer, TimerTable = Necrosis_RetraitTimerParIndex(thisspell, SpellTimer, TimerTable);
SortActif = false;
break;
end
if SortActif then break; end
end
-- Si le timer est une malédiction, on enlève la précédente malédiction sur la cible
if (NECROSIS_SPELL_TABLE[spell].Type == 4) or (spell == 16) then
for thisspell=1, table.getn(SpellTimer), 1 do
-- Mais on garde le cooldown de la malédiction funeste
if SpellTimer[thisspell].Name == NECROSIS_SPELL_TABLE[16].Name then
SpellTimer[thisspell].Target = "";
SpellTimer[thisspell].TargetLevel = "";
end
if SpellTimer[thisspell].Type == 4
and SpellTimer[thisspell].Target == SpellTargetName
and SpellTimer[thisspell].TargetLevel == SpellTargetLevel
then
SpellTimer, TimerTable = Necrosis_RetraitTimerParIndex(thisspell, SpellTimer, TimerTable);
break;
end
end
SortActif = false;
end
if not SortActif
and NECROSIS_SPELL_TABLE[spell].Type ~= 0
and spell ~= 10
then
if spell == 9 then
if SpellCastRank == 1 then
NECROSIS_SPELL_TABLE[spell].Length = 20;
else
NECROSIS_SPELL_TABLE[spell].Length = 30;
end
end
SpellGroup, SpellTimer, TimerTable = Necrosis_InsertTimerParTable(spell, SpellTargetName, SpellTargetLevel, SpellGroup, SpellTimer, TimerTable);
break;
end
end
end
end
end
SpellCastName = nil;
SpellCastRank = nil;
return;
end
------------------------------------------------------------------------------------------------------
-- FONCTIONS DE L'INTERFACE -- LIENS XML
------------------------------------------------------------------------------------------------------
-- En cliquant droit sur Necrosis, on affiche ou masque les deux panneaux de configurations
function Necrosis_Toggle(button)
if button == "LeftButton" then
if NECROSIS_SPELL_TABLE[41].ID then
CastSpell(NECROSIS_SPELL_TABLE[41].ID, "spell");
end
return;
elseif (NecrosisGeneralFrame:IsVisible()) then
HideUIPanel(NecrosisGeneralFrame);
return;
else
if NecrosisConfig.SM then
Necrosis_Msg("!!! Short Messages : <brightGreen>On", "USER");
end
ShowUIPanel(NecrosisGeneralFrame);
NecrosisGeneralTab_OnClick(1);
return;
end
end
-- Fonction permettant le déplacement d'éléments de Necrosis sur l'écran
function Necrosis_OnDragStart(button)
if (button == "NecrosisIcon") then GameTooltip:Hide(); end
button:StartMoving();
end
-- Fonction arrêtant le déplacement d'éléments de Necrosis sur l'écran
function Necrosis_OnDragStop(button)
if (button == "NecrosisIcon") then Necrosis_BuildTooltip("OVERALL"); end
button:StopMovingOrSizing();
end
-- Fonction alternant Timers graphiques et Timers textes
function Necrosis_HideGraphTimer()
for i = 1, 50, 1 do
local elements = {"Text", "Bar", "Texture", "OutText"}
if NecrosisConfig.Graphical then
if TimerTable[i] then
for j = 1, 4, 1 do
frameName = "NecrosisTimer"..i..elements[j];
frameItem = getglobal(frameName);
frameItem:Show();
end
end
else
for j = 1, 4, 1 do
frameName = "NecrosisTimer"..i..elements[j];
frameItem = getglobal(frameName);
frameItem:Hide();
end
end
end
end
-- Fonction gérant les bulles d'aide
function Necrosis_BuildTooltip(button, type, anchor)
-- Si l'affichage des bulles d'aide est désactivé, Bye bye !
if not NecrosisConfig.NecrosisToolTip then
return;
end
-- On regarde si la domination corrompue, le gardien de l'ombre ou l'amplification de malédiction sont up (pour tooltips)
local start, duration, start2, duration2, start3, duration3
if NECROSIS_SPELL_TABLE[15].ID then
start, duration = GetSpellCooldown(NECROSIS_SPELL_TABLE[15].ID, BOOKTYPE_SPELL);
else
start = 1;
duration = 1;
end
if NECROSIS_SPELL_TABLE[43].ID then
start2, duration2 = GetSpellCooldown(NECROSIS_SPELL_TABLE[43].ID, BOOKTYPE_SPELL);
else
start2 = 1;
duration2 = 1;
end
if NECROSIS_SPELL_TABLE[42].ID then
start3, duration3 = GetSpellCooldown(NECROSIS_SPELL_TABLE[42].ID, BOOKTYPE_SPELL);
else
start3 = 1;
duration3 = 1;