-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathHowToSunspire.lua
More file actions
2819 lines (2376 loc) · 89.7 KB
/
HowToSunspire.lua
File metadata and controls
2819 lines (2376 loc) · 89.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
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
-----------------
---- Globals ----
-----------------
HowToSunspire = HowToSunspire or {}
local HowToSunspire = HowToSunspire
HowToSunspire.name = "HowToSunspire"
HowToSunspire.version = "1.3.10"
HowToSunspire.slash = "/hts"
HowToSunspire.prefix = "|cffffffHT|cffbf00S|r: "
HowToSunspire.groupMembers = {}
HowToSunspire.testMembers = {
[1] = {
tag = "group1",
name = "@Test Name 1",
},
[2] = {
tag = "group2",
name = "@Test Name 2",
},
[3] = {
tag = "group3",
name = "@Test Name 3",
},
[4] = {
tag = "group4",
name = "@Test Name 4",
},
[5] = {
tag = "group5",
name = "@Test Name 5",
},
[6] = {
tag = "group6",
name = "@Test Name 6",
},
[7] = {
tag = "group7",
name = "@Test Name 7",
},
[8] = {
tag = "group8",
name = "@Test Name 8",
},
[9] = {
tag = "group9",
name = "@Test Name 9",
},
[10] = {
tag = "group10",
name = "@Test Name 10",
},
[11] = {
tag = "group11",
name = "@Test Name 11",
},
[12] = {
tag = "group12",
name = "@Test Name 12",
}
}
local playerTestIndex = 0
local function GetTestName(index)
if index == playerTestIndex then return " |cff9900==|r YOU |cff9900==|r "
else
if HowToSunspire.testMembers[index] then
return "|cff9900" .. HowToSunspire.testMembers[index].name .. "|r"
end
end
end
local sV
local EM = EVENT_MANAGER
local WROTHGAR_MAP_INDEX = 27
local WROTHGAR_MAP_STEP_SIZE = 1.428571431461e-005
---------------------------
---- Variables Default ----
---------------------------
HowToSunspire.Default = {
OffsetX = {
HA = 0,
Block = 0,
Comet = 0,
Shield = 0,
Leap = 0,
Breath = 0,
Spit = 0,
Geyser = 0,
HP = 350,
Landing = 350,
GlacialFist = 0,
IceTomb = 0,
LaserLokke = 0,
Atro = 0,
Cata = 0,
NextFlare = 0,
-- Flare = 0,
PowerfulSlam = 0,
Stonefist = 0,
-- HailOfStone = 0,
Thrash = 0,
SweepBreath = 0,
SoulTear = 0,
Storm = 0,
NextMeteor = 0,
Portal = 0,
Negate = 0,
Wipe = 0,
MeteorNames = 0
},
OffsetY = {
HA = 0,
Block = 50,
Comet = -150,
Shield = - 50,
Leap = - 50,
Breath = -100,
Spit = - 50,
Geyser = 50,
HP = 50,
Landing = 80,
GlacialFist = -200,
IceTomb = - 50,
LaserLokke = 50,
Atro = - 50,
Cata = - 50,
NextFlare = -100,
-- Flare = 50,
PowerfulSlam = 0,
Stonefist = -150,
-- HailOfStone = -200,
Thrash = 100,
SweepBreath = -100,
SoulTear = 100,
Storm = -100,
NextMeteor = 150,
Portal = 50,
Negate = - 50,
Wipe = 150,
MeteorNames = -500
},
Enable = {
HA = true,
Block = true,
Comet = true,
Shield = true,
Leap = true,
Breath = true,
Spit = true,
Geyser = true,
hpLokke = true,
hpYolna = true,
hpNahvii = true,
landingLokke = true,
landingYolna = true,
landingNahvii = true,
GlacialFist = true,
IceTomb = true,
LaserLokke = true,
Atro = true,
Cata = true,
NextFlare = true,
-- Flare = true,
PowerfulSlam = true,
Stonefist = true,
-- HailOfStone = true,
Thrash = true,
SweepBreath = true,
SoulTear = true,
Storm = true,
NextMeteor = true,
Portal = true,
Negate = true,
Interrupt = true,
Pins = true,
Wipe = true,
MeteorNames = true,
Sending = true,
Sound = true,
},
hpShowPercent = 5,
timeBeforeLanding = 7,
AlertSize = 40,
TimerSize = 40,
wipeCallLater = 90,
MeteorSelfOnly = true,
debug = false
}
local fightStart = 0
local bossFight = false
local function dbg( ... )
if sV.debug then
local message = zo_strformat( ... )
if bossFight then
local t = (GetGameTimeMilliseconds() / 1000) - fightStart
fT = ZO_FormatTime(t, TIME_FORMAT_STYLE_COLONS, TIME_FORMAT_PRECISION_MILLISECONDS)
d( HowToSunspire.prefix .. "[" .. fT .. "] " .. message)
else
d( HowToSunspire.prefix .. message )
end
end
end
local function setupTestGroup()
local group = {}
for k, v in pairs(HowToSunspire.testMembers) do
group[k] = v
end
return group
end
local forcePlayerIndex = false
local playerRow = 1
local isTest = false
function HowToSunspire.SlashCommand( string )
-- make all letters lower case for ease
local cmd = string.lower( string )
-- toggle debugging
if cmd == "dbg" then
sV.debug = not sV.debug
local state = sV.debug and "On" or "Off"
d( HowToSunspire.prefix .. "Debugging " .. state )
elseif string.sub(cmd, 1, 6) == "meteor" then
-- test meteor targets UI
if string.sub(cmd, 8, string.len(cmd)) == "fp" then
-- choose player number
forcePlayerIndex = not forcePlayerIndex
dbg("Testing with player always: |cffffff<<1>>|r.", forcePlayerIndex and "On" or "Off")
elseif (string.sub(cmd, 8, 9) == "pr" and string.len(cmd) == 11) then
-- choose player row
local R = tonumber(string.sub(cmd, 11, 11))
if R > 0 and R < 4 then
playerRow = R
dbg("Testing with player on row |cffffff<<1>>|r.", playerRow)
end
else -- run test scenario for the UI with or without added variables
HowToSunspire.HideMeteorUnits(true)
local n = string.sub(cmd, 7, string.len(cmd))
-- the number assigned as players
playerTestIndex = tonumber(n)
dbg("Testing with player as unit |cffffff<<1>>|r.", playerTestIndex)
-- tell function that this is a test to avoid running functions for getting actual player info
isTest = true
-- use only fake group members
HowToSunspire.groupMembers = setupTestGroup()
-- build table to use for keeping track of which numbers have been used.
local t = {}
for i = 1, 12 do t[i] = false end
for i = 1, 3 do
local r
-- check how to run the function
if (forcePlayerIndex and playerTestIndex > 0 and playerTestIndex < 13) then
if i == playerRow
then r = playerTestIndex
else r = math.random(1, 12) end
else r = math.random(1, 12) end
dbg("Random unit |cffffff[<<1>>]|r = |cffffff<<2>>|r", i, r)
-- only run each number once in case of duplicates
if t[r] == false then
t[r] = true
HowToSunspire.Comet(_, 2240, _, _, _, _, _, _, _, _, 4000, _, _, _, _, r, 117251)
end
end
end
end
end
----------------------
---- ENTIRE TRIAL ----
----------------------
local listHA = {}
function HowToSunspire.HeavyAttack(_, result, _, abilityName, _, _, _, _, _, targetType, hitValue, _, _, _, _, _, abilityId)
if targetType ~= COMBAT_UNIT_TYPE_PLAYER or hitValue < 100 or sV.Enable.HA ~= true then return end
if result == ACTION_RESULT_BEGIN then
table.insert(listHA, GetGameTimeMilliseconds() + hitValue)
Hts_Ha:SetHidden(false)
if sV.Enable.Sound then
PlaySound(SOUNDS.CHAMPION_POINTS_COMMITTED)
end
EM:UnregisterForUpdate(HowToSunspire.name .. "HeavyAttackTimer")
EM:RegisterForUpdate(HowToSunspire.name .. "HeavyAttackTimer", 100, HowToSunspire.HeavyAttackUI)
end
end
function HowToSunspire.HeavyAttackUI()
local text = ""
local currentTime = GetGameTimeMilliseconds()
for key, value in ipairs(listHA) do
local timer = value - currentTime
if timer >= 0 then
if text == "" then
text = text .. tostring(string.format("%.1f", timer / 1000))
else
text = text .. "|cff1493 / |r" .. tostring(string.format("%.1f", timer / 1000))
end
else
table.remove(listHA, key)
end
end
if text ~= "" then
Hts_Ha_Label:SetText("|cff1493HA|r: " .. text)
else
EM:UnregisterForUpdate(HowToSunspire.name .. "HeavyAttackTimer")
Hts_Ha:SetHidden(true)
end
end
function HowToSunspire.Block(_, result, _, _, _, _, _, _, _, targetType, hitValue, _, _, _, _, _, abilityId)
if result == ACTION_RESULT_BEGIN and sV.Enable.Block == true then
if hitValue > 400 then
zo_callLater(function ()
Hts_Block:SetHidden(false)
if sV.Enable.Sound then
PlaySound(SOUNDS.DUEL_START)
end
EM:UnregisterForUpdate(HowToSunspire.name .. "HideBlock")
EM:RegisterForUpdate(HowToSunspire.name .. "HideBlock", 2500, HowToSunspire.HideBlock)
end, hitValue - 400)
else
zo_callLater(function ()
Hts_Block:SetHidden(false)
if sV.Enable.Sound then
PlaySound(SOUNDS.DUEL_START)
end
EM:UnregisterForUpdate(HowToSunspire.name .. "HideBlock")
EM:RegisterForUpdate(HowToSunspire.name .. "HideBlock", 2500, HowToSunspire.HideBlock)
end, hitValue)
end
end
end
function HowToSunspire.HideBlock()
EM:UnregisterForUpdate(HowToSunspire.name .. "HideBlock")
Hts_Block:SetHidden(true)
end
function HowToSunspire.Leap(_, result, _, _, _, _, _, _, _, targetType, hitValue, _, _, _, _, _, abilityId)
if result == ACTION_RESULT_BEGIN and sV.Enable.Leap == true then
if hitValue > 400 then
zo_callLater(function ()
Hts_Leap:SetHidden(false)
EM:UnregisterForUpdate(HowToSunspire.name .. "HideLeap")
EM:RegisterForUpdate(HowToSunspire.name .. "HideLeap", 2500, HowToSunspire.HideLeap)
end, hitValue - 400)
else
zo_callLater(function ()
Hts_Leap:SetHidden(false)
EM:UnregisterForUpdate(HowToSunspire.name .. "HideLeap")
EM:RegisterForUpdate(HowToSunspire.name .. "HideLeap", 2500, HowToSunspire.HideLeap)
end, hitValue)
end
end
end
function HowToSunspire.HideLeap()
EM:UnregisterForUpdate(HowToSunspire.name .. "HideLeap")
Hts_Leap:SetHidden(true)
end
local cometTime
local isComet = true
local meteorUnits = {}
local sortedMeteorUnits = {
[1] = { tag = "", index = 0, isPlayer = false },
[2] = { tag = "", index = 0, isPlayer = false },
[3] = { tag = "", index = 0, isPlayer = false }
}
local meteorDisplayTime = 0
local meteorBegin = 0
function HowToSunspire.SetMeteorDirections()
if (meteorBegin + 100) - GetGameTimeMilliseconds() > 0 then return end
EM:UnregisterForUpdate(HowToSunspire.name .. "MeteorUnits")
-- local g = HowToSunspire.testMembers
local g = HowToSunspire.groupMembers
local m = meteorUnits
local s = sortedMeteorUnits
local c = Hts_MeteorNames
local tags = {}
local isPlayer = false
local playerIndex = 0
local function assignUnit(assignment, unitTag, index)
local unit = nil
local a = s[assignment]
local p = index == playerIndex and true or false
if a.index == 0 then
a.tag = unitTag
a.index = index
a.isPlayer = p
else
if a.index < index then
unit = { tag = unitTag, index = index, isPlayer = p }
else
unit = { tag = a.tag, index = a.index, isPlayer = a.isPlayer }
a.tag = unitTag
a.index = index
a.isPlayer = p
end
end
return unit
end
local function indexMeteorUnits(unitTag, index)
local u1 = assignUnit(1, unitTag, index)
if u1 ~= nil then
local u2 = assignUnit(2, u1.tag, u1.index)
if u2 ~= nil then
assignUnit(3, u2.tag, u2.index)
end
end
end
for id, tag in pairs(m) do
local index = tonumber(string.sub(tag, 6, string.len(tag)))
if (isTest) then
if index == playerTestIndex then
isPlayer = true
playerIndex = index
dbg("Test with |cffffff<<1>>|r registered as player", index)
end
else
dbg("not a test")
if AreUnitsEqual("player", tag) then
isPlayer = true
playerIndex = index
dbg("player id / tag: |cffffff<<1>>|r / |cffffff<<2>>|r.", id, tag)
end
end
dbg("[<<1>>] = <<2>>", index, tag)
indexMeteorUnits(tag, index)
end
if sV.MeteorSelfOnly then
if not isPlayer then
HowToSunspire.HideMeteorUnits(true)
dbg("Not Player (<<1>> / <<2>>)", tostring(isPlayer), playerIndex)
return
end
end
for i = 1, 3 do
local label = c.labels[i]
local a1, a2
if i == 1 then a1 = 1; a2 = 2
elseif i == 2 then a1 = 3; a2 = 4
elseif i == 3 then a1 = 5; a2 = 6 end
if s[i].index > 0 then
local name
if isTest then
name = GetTestName(s[i].index)
else
if s[i].isPlayer
then name = " |cff9900==|r YOU |cff9900==|r "
else name = "|cff9900" .. GetUnitDisplayName(s[i].tag) .. "|r" end
end
label:SetText(name)
label:SetHidden(false)
c.arrows[a1]:SetHidden(false)
c.arrows[a2]:SetHidden(false)
if s[i].isPlayer then
label:SetFont("EsoUI/Common/Fonts/univers67.otf" .. "|" .. zo_round(sV.AlertSize * 1.5) .. "|" .. "thick-outline")
end
dbg("displaying for (<<2>> / <<1>>)", tostring(s[i].isPlayer), s[i].tag)
HowToSunspire.UpdateArrowSizes()
else
label:SetHidden(true)
c.arrows[a1]:SetHidden(true)
c.arrows[a2]:SetHidden(true)
end
end
m = {}
s = {
[1] = { tag = "", index = 0 },
[2] = { tag = "", index = 0 },
[3] = { tag = "", index = 0 }
}
-- isTest = false
-- playerTestIndex = 0
meteorDisplayTime = GetGameTimeMilliseconds() + 4000
c:SetHidden(false)
EM:UnregisterForUpdate(HowToSunspire.name .. "HideMeteorNames")
EM:RegisterForUpdate(HowToSunspire.name .. "HideMeteorNames", 500, function() HowToSunspire.HideMeteorUnits(false) end)
-- zo_callLater(function()
-- HowToSunspire.HideMeteorUnits()
-- end, 4000)
end
function HowToSunspire.HideMeteorUnits(disable)
if not disable then
local t = meteorDisplayTime - GetGameTimeMilliseconds()
if t > 0 then return end
end
EM:UnregisterForUpdate(HowToSunspire.name .. "HideMeteorNames")
dbg("Hiding Meteor Names")
meteorDisplayTime = 0
meteorUnits = {}
isTest = false
sortedMeteorUnits = {
[1] = { tag = "", index = 0, isPlayer = false },
[2] = { tag = "", index = 0, isPlayer = false },
[3] = { tag = "", index = 0, isPlayer = false }
}
Hts_MeteorNames:SetHidden(true)
HowToSunspire.SetMeteorNameSize()
end
--[[
/script HowToSunspire.Comet(_, 2240, _, _, _, _, _, _, _, _, 4000, _, _, _, _, 1, 117251)
/script HowToSunspire.Comet(_, 2240, _, _, _, _, _, _, _, _, 4000, _, _, _, _, 2, 117251)
/script HowToSunspire.Comet(_, 2240, _, _, _, _, _, _, _, _, 4000, _, _, _, _, 3, 123067)
/script HowToSunspire.Comet(_, 2240, _, _, _, _, _, _, _, _, 4000, _, _, _, _, 36761, 117251) HowToSunspire.Comet(_, 2240, _, _, _, _, _, _, _, _, 4000, _, _, _, _, 35061, 117251) HowToSunspire.Comet(_, 2240, _, _, _, _, _, _, _, _, 4000, _, _, _, _, 35486, 123067)
36761 =
. (string): tag = group9
. (boolean): ice = false
. (string): name = @nogetrandom
35061 =
. (string): tag = group5
. (boolean): ice = false
. (string): name = @Pride.eso
35486 =
. (string): tag = group8
. (boolean): ice = false
. (string): name = @monkieponkie
36591 =
. (string): tag = group1
. (boolean): ice = false
. (string): name = @Nilasnms
]]
function HowToSunspire.Comet(_, result, _, _, _, _, _, _, targetName, targetType, hitValue, _, _, _, _, targetUnitId, abilityId)
if abilityId == 117251 or abilityId == 123067 then
isComet = false
HowToSunspire.NextMeteor(_, result, _, _, _, _, _, _, _, targetType, hitValue, _, _, _, _, _, abilityId)
if (result ~= ACTION_RESULT_EFFECT_FADED) then
if not targetUnitId then return end
if targetUnitId == 0 then return end
if not HowToSunspire.groupMembers[targetUnitId] then return end
if not isTest then
if GetGroupMemberSelectedRole(HowToSunspire.groupMembers[targetUnitId].tag) ~= 1 then return end
end
if not meteorUnits[targetUnitId] then
if meteorBegin + 2000 > GetGameTimeMilliseconds() then
meteorBegin = GetGameTimeMilliseconds()
end
meteorUnits[targetUnitId] = HowToSunspire.groupMembers[targetUnitId].tag
dbg("unit |cffffff<<1>>|r added to meteor", targetUnitId)
EM:UnregisterForUpdate(HowToSunspire.name .. "MeteorUnits")
EM:RegisterForUpdate(HowToSunspire.name .. "MeteorUnits", 50, HowToSunspire.SetMeteorDirections)
end
else
if meteorUnits[targetUnitId] then
meteorUnits[targetUnitId] = nil
end
end
else
isComet = true
end
if sV.Enable.Comet ~= true or hitValue < 100 or targetType ~= COMBAT_UNIT_TYPE_PLAYER then return end
if (abilityId == 120359 and result ~= ACTION_RESULT_BEGIN) or
(abilityId ~= 120359 and result ~= ACTION_RESULT_EFFECT_GAINED_DURATION) then return end
cometTime = GetGameTimeMilliseconds() + hitValue
if abilityId == 120359 then cometTime = cometTime + 1000 end
HowToSunspire.CometUI()
Hts_Comet:SetHidden(false)
if sV.Enable.Sound then PlaySound(SOUNDS.DUEL_START) end
EM:UnregisterForUpdate(HowToSunspire.name .. "CometTimer")
EM:RegisterForUpdate(HowToSunspire.name .. "CometTimer", 100, HowToSunspire.CometUI)
end
function HowToSunspire.CometUI()
local currentTime = GetGameTimeMilliseconds()
local timer = cometTime - currentTime
if timer >= 0 then
if isComet then
Hts_Comet_Label:SetText("|c87ceebComet: |r" .. tostring(string.format("%.1f", timer / 1000)))
else
Hts_Comet_Label:SetText("|cf51414Meteor: |r" .. tostring(string.format("%.1f", timer / 1000)))
end
else
EM:UnregisterForUpdate(HowToSunspire.name .. "CometTimer")
Hts_Comet:SetHidden(true)
end
end
local shieldChargeTime
function HowToSunspire.ShieldCharge(_, result, _, _, _, _, _, _, _, targetType, hitValue, _, _, _, _, _, abilityId)
if result == ACTION_RESULT_BEGIN and targetType == COMBAT_UNIT_TYPE_PLAYER and sV.Enable.Shield == true then
local currentTime = GetGameTimeMilliseconds()
shieldChargeTime = currentTime + hitValue
HowToSunspire.ShieldChargeTimerUI()
Hts_Shield:SetHidden(false)
EM:UnregisterForUpdate(HowToSunspire.name .. "ShieldChargeTimer")
EM:RegisterForUpdate(HowToSunspire.name .. "ShieldChargeTimer", 100, HowToSunspire.ShieldChargeTimerUI)
end
end
function HowToSunspire.ShieldChargeTimerUI()
local currentTime = GetGameTimeMilliseconds()
local timer = shieldChargeTime - currentTime
if timer >= 0 then
Hts_Shield_Label:SetText("|c7fffd4Shield Charge: |r" .. tostring(string.format("%.1f", timer / 1000)))
else
EM:UnregisterForUpdate(HowToSunspire.name .. "ShieldChargeTimer")
Hts_Shield:SetHidden(true)
end
end
local breathTime
function HowToSunspire.Breath(_, result, _, _, _, _, _, _, _, targetType, hitValue, _, _, _, _, _, abilityId)
if result == ACTION_RESULT_BEGIN and targetType == COMBAT_UNIT_TYPE_PLAYER and sV.Enable.Breath == true then
local currentTime = GetGameTimeMilliseconds()
breathTime = currentTime + hitValue
HowToSunspire.BreathTimerUI()
Hts_Breath:SetHidden(false)
EM:UnregisterForUpdate(HowToSunspire.name .. "BreathTimer")
EM:RegisterForUpdate(HowToSunspire.name .. "BreathTimer", 100, HowToSunspire.BreathTimerUI)
end
end
function HowToSunspire.BreathTimerUI()
local currentTime = GetGameTimeMilliseconds()
local timer = breathTime - currentTime
if timer >= 0 then
Hts_Breath_Label:SetText("|cff6633Breath|r: " .. tostring(string.format("%.1f", timer / 1000)))
else
EM:UnregisterForUpdate(HowToSunspire.name .. "BreathTimer")
Hts_Breath:SetHidden(true)
end
end
local isFlying = false
local flight = 0
local flying = 0
local grounded = 0
local landingTime = 0
local bossName = ""
local takeOff = 0
local estimate = 0
local logTime = 0
function HowToSunspire.CheckLandingTimer()
if IsUnitAttackable("boss1") then
EM:UnregisterForUpdate(HowToSunspire.name .. "TimeFlying")
local t = GetGameTimeMilliseconds() / 1000
local timeFlying = t - takeOff
local e = estimate - t
local diff
if e >= 0 then
-- to indicate that the time was less than expected
e = e - (e * 2)
diff = " (" .. e .. ")"
else
-- to indicate that the time was longer than expected
e = e * -2
diff = " (+" .. e .. ")"
end
dbg("[" .. bossName .. "]: #" .. flight .. " = " .. string.format("%.3fs", timeFlying) .. diff)
if string.find(bossName, "Yolna") then
dbg("Logtime was: " .. logTime)
end
end
end
function HowToSunspire.BossHealth()
local current, max, effective = GetUnitPower("boss1", POWERTYPE_HEALTH)
local bossHP = ( current / max ) * 100
-- bossName = GetUnitName("boss1")
if bossHP > 21 then
if (bossName == "Lokkestiiz" and sV.Enable.hpLokke == true) then
EM:RegisterForUpdate(HowToSunspire.name .. "BossHealth", 1000, HowToSunspire.LokkeHealth)
elseif (bossName == "Yolnahkriin" and sV.Enable.hpYolna == true) then
EM:RegisterForUpdate(HowToSunspire.name .. "BossHealth", 1000, HowToSunspire.YolnaHealth)
elseif (bossName == "Nahviintaas" and sV.Enable.hpNahvii == true) then
EM:RegisterForUpdate(HowToSunspire.name .. "BossHealth", 1000, HowToSunspire.NahviiHealth)
end
-- if sV.debug then
-- EM:RegisterForUpdate(HowToSunspire.name .. "TimeFlying", 50, HowToSunspire.CheckLandingTimer)
-- end
else
return
end
end
function HowToSunspire.LokkeHealth()
local current, max, effective = GetUnitPower("boss1", POWERTYPE_HEALTH)
local l = ( current / max ) * 100
if l >= 81 then flying = 81
elseif (l < 81 and l >= 51) then flying = 51
elseif (l < 50 and l >= 21) then flying = 21
else
Hts_HP:SetHidden(true)
EM:UnregisterForUpdate(HowToSunspire.name .. "BossHealth")
return
end
grounded = l - flying
if grounded <= sV.hpShowPercent then
Hts_HP:SetHidden(false)
HowToSunspire.LokkeHealthUI()
EM:UnregisterForUpdate(HowToSunspire.name .. "LokkestiizUI")
EM:RegisterForUpdate(HowToSunspire.name .. "LokkestiizUI", 100, HowToSunspire.LokkeHealthUI)
EM:UnregisterForUpdate(HowToSunspire.name .. "BossHealth")
end
end
function HowToSunspire.LokkeHealthUI()
local current, max, effective = GetUnitPower("boss1", POWERTYPE_HEALTH)
local lokkeHP = ( current / max ) * 100
grounded = lokkeHP - flying
if grounded > 0 then
Hts_HP_Label:SetText("|cffa500Can Fly In|r: " .. string.format("%.1f", grounded) .. "%")
elseif grounded <= 0 then Hts_HP_Label:SetText("|cff0000Can Fly Now|r") end
if grounded <= 0 then
zo_callLater(function()
Hts_HP:SetHidden(true)
EM:UnregisterForUpdate(HowToSunspire.name .. "LokkestiizUI")
end, 2500)
end
end
function HowToSunspire.YolnaHealth()
local current, max, effective = GetUnitPower("boss1", POWERTYPE_HEALTH)
local y = ( current / max ) * 100
if y >= 76 then flying = 76
elseif (y < 76 and y >= 51) then flying = 51
elseif (y < 51 and y >= 26) then flying = 26
else
Hts_HP:SetHidden(true)
EM:UnregisterForUpdate(HowToSunspire.name .. "BossHealth")
return
end
grounded = y - flying
if grounded <= sV.hpShowPercent then
Hts_HP:SetHidden(false)
HowToSunspire.YolnaHealthUI()
EM:UnregisterForUpdate(HowToSunspire.name .. "YolnahkriinUI")
EM:RegisterForUpdate(HowToSunspire.name .. "YolnahkriinUI", 100, HowToSunspire.YolnaHealthUI)
EM:UnregisterForUpdate(HowToSunspire.name .. "BossHealth")
end
end
function HowToSunspire.YolnaHealthUI()
local current, max, effective = GetUnitPower("boss1", POWERTYPE_HEALTH)
local yolnaHP = ( current / max ) * 100
grounded = yolnaHP - flying
if grounded > 0 then
Hts_HP_Label:SetText("|cffa500Can Fly In|r: " .. string.format("%.1f", grounded) .. "%")
elseif grounded <= 0 then Hts_HP_Label:SetText("|cff0000Can Fly Now|r") end
if grounded <= 0 then
zo_callLater(function()
Hts_HP:SetHidden(true)
EM:UnregisterForUpdate(HowToSunspire.name .. "YolnahkriinUI")
end, 2500)
end
end
local inPortal = false
function HowToSunspire.NahviiHealth()
if sV.Enable.hpNahvii ~= true or inPortal ~= false then return end
local current, max, effective = GetUnitPower("boss1", POWERTYPE_HEALTH)
local n = ( current / max ) * 100
if n >= 80 then flying = 80
elseif (n < 80 and n >= 60) then flying = 60
elseif (n < 60 and n >= 40) then flying = 40
else
Hts_HP:SetHidden(true)
EM:UnregisterForUpdate(HowToSunspire.name .. "BossHealth")
return
end
grounded = n - flying
if grounded <= sV.hpShowPercent then
Hts_HP:SetHidden(false)
HowToSunspire.NahviiHealthUI()
EM:UnregisterForUpdate(HowToSunspire.name .. "NahviintaasUI")
EM:RegisterForUpdate(HowToSunspire.name .. "NahviintaasUI", 100, HowToSunspire.NahviiHealthUI)
EM:UnregisterForUpdate(HowToSunspire.name .. "BossHealth")
end
end
function HowToSunspire.NahviiHealthUI()
local current, max, effective = GetUnitPower("boss1", POWERTYPE_HEALTH)
local nahviiHP = ( current / max ) * 100
grounded = nahviiHP - flying
if grounded > 0 then Hts_HP_Label:SetText("|cffa500Can Fly In|r: " .. string.format("%.1f", grounded) .. "%")
elseif grounded <= 0 then Hts_HP_Label:SetText("|cff0000Can Fly Now|r") end
if grounded <= 0 then
zo_callLater(function()
Hts_HP:SetHidden(true)
EM:UnregisterForUpdate(HowToSunspire.name .. "NahviintaasUI")
end, 2500)
end
if inPortal == true then
Hts_HP:SetHidden(true)
EM:UnregisterForUpdate(HowToSunspire.name .. "NahviintaasUI")
end
end
--------------------
---- LOKKESTIIZ ----
--------------------
local glacialFist = {}
function HowToSunspire.GlacialFist(_, result, _, _, _, _, _, _, targetName, targetType, hitValue, _, _, _, _, targetId, abilityId)
if ((sV.Enable.GlacialFist ~= true) or (hitValue < 100)) then return end
if targetType == COMBAT_UNIT_TYPE_PLAYER then
table.insert(glacialFist, GetGameTimeMilliseconds() + hitValue)
Hts_GlacialFist:SetHidden(false)
if sV.Enable.Sound == true then
PlaySound(SOUNDS.DUEL_START)
end
EM:UnregisterForUpdate(HowToSunspire.name .. "GlacialFistTimer")
EM:RegisterForUpdate(HowToSunspire.name .. "GlacialFistTimer", 100, HowToSunspire.GlacialFistUI)
elseif HowToSunspire.groupMembers[targetId].tag then
SetMapToPlayerLocation()
local x1, y1 = GetMapPlayerPosition("player")
local x2, y2 = GetMapPlayerPosition(HowToSunspire.groupMembers[targetId].tag)
if (math.sqrt((x1 - x2)^2 + (y1 - y2)^2) * 1000) <= 4.5 then
table.insert(glacialFist, GetGameTimeMilliseconds() + hitValue)
Hts_GlacialFist:SetHidden(false)
if sV.Enable.Sound == true then
PlaySound(SOUNDS.DUEL_START)
end
EM:UnregisterForUpdate(HowToSunspire.name .. "GlacialFistTimer")
EM:RegisterForUpdate(HowToSunspire.name .. "GlacialFistTimer", 100, HowToSunspire.GlacialFistUI)
end
end
end
function HowToSunspire.GlacialFistUI()
local text = ""
local currentTime = GetGameTimeMilliseconds()
for key, value in ipairs(glacialFist) do
local timer = value - currentTime
if timer >= 0 then
if text == ""
then text = text .. tostring(string.format("%.1f", timer / 1000))
else text = text .. "|c99ccff / |r" .. tostring(string.format("%.1f", timer / 1000)) end
else table.remove(glacialFist, key) end
end
if text ~= "" then Hts_GlacialFist_Label:SetText("|c99ccffGlacial Fist|r: " .. text)
else
EM:UnregisterForUpdate(HowToSunspire.name .. "GlacialFistTimer")
Hts_GlacialFist:SetHidden(true)
end
end
local iceTime
local tomb
local iceNext = 0
local iceNumber = 0
local prevIce = 0
local tombsArmed = false
local iceDouble = false
local tombsActive = 0
local tombsClear = true
local iceState = 0
local checkDouble = true
local laserTime
function HowToSunspire.IceTomb(_, result, _, _, _, _, _, _, _, targetType, hitValue, _, _, _, _, _, abilityId)
if result ~= ACTION_RESULT_BEGIN then return end
if sV.Enable.IceTomb == true then
local time = GetGameTimeMilliseconds()
isFlying = false
iceTime = time / 1000 + 13
iceNext = time / 1000 + 23
prevIce = time
iceNumber = iceNumber % 3 + 1
tombsClear = false
iceState = 1
checkDouble = true
HowToSunspire.IceTombTimerUI()
Hts_Ice:SetHidden(false)
if sV.Enable.Sound then PlaySound(SOUNDS.DUEL_START) end
EM:UnregisterForUpdate(HowToSunspire.name .. "IceTombTimer")
EM:RegisterForUpdate(HowToSunspire.name .. "IceTombTimer", 100, HowToSunspire.IceTombTimerUI)
--update all 1 seconds instead of all 0.1 seconds