-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSpeedrunMenu.lua
More file actions
1606 lines (1408 loc) · 62.5 KB
/
SpeedrunMenu.lua
File metadata and controls
1606 lines (1408 loc) · 62.5 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
Speedrun = Speedrun or {}
local Speedrun = Speedrun
local LAM = LibAddonMenu2
local wm = WINDOW_MANAGER
local EM = EVENT_MANAGER
local CM = CALLBACK_MANAGER
local sV
local cV
local isST = false
local profileToAdd = ""
local profileToLoad = ""
local profileToDelete = ""
-- local profileToCopyFrom = ""
-- local profileToCopyTo = ""
local trialMenuTimers = {
[635] = {},
[636] = {},
[638] = {},
[639] = {},
[677] = {},
[725] = {},
[975] = {},
[1000] = {},
[1051] = {},
[1082] = {},
[1121] = {},
[1196] = {},
[1227] = {},
[1263] = {}
}
local trialSubmenus = {
[635] = {},
[636] = {},
[638] = {},
[639] = {},
[677] = {},
[725] = {},
[975] = {},
[1000] = {},
[1051] = {},
[1082] = {},
[1121] = {},
[1196] = {},
[1227] = {},
[1263] = {}
}
local NAMEPLATE_CHOICE_NEVER = NAMEPLATE_CHOICE_NEVER
local NAMEPLATE_CHOICE_ALWAYS = NAMEPLATE_CHOICE_ALWAYS
local NAMEPLATE_CHOICE_INJURED = NAMEPLATE_CHOICE_INJURED
local NAMEPLATE_CHOICE_TARGETED = NAMEPLATE_CHOICE_TARGETED
local NAMEPLATE_CHOICE_INJURED_OR_TARGETED = NAMEPLATE_CHOICE_INJURED_OR_TARGETED
local npGroupHiddenSettings = {
["never"] = NAMEPLATE_CHOICE_NEVER, -- 1
["always"] = NAMEPLATE_CHOICE_ALWAYS, -- 2
["injured"] = NAMEPLATE_CHOICE_INJURED -- 3
}
local npGroupShownSettings = {
["never"] = NAMEPLATE_CHOICE_NEVER, -- 1
["always"] = NAMEPLATE_CHOICE_ALWAYS, -- 2
["injured"] = NAMEPLATE_CHOICE_INJURED, -- 3
["targeted"] = NAMEPLATE_CHOICE_TARGETED, -- 8
["injured or targeted"] = NAMEPLATE_CHOICE_INJURED_OR_TARGETED -- 9 NAMEPLATE_CHOICE_HURT,
}
local npGroupHiddenOptions = {
[NAMEPLATE_CHOICE_NEVER] = "never",
[NAMEPLATE_CHOICE_ALWAYS] = "always",
[NAMEPLATE_CHOICE_INJURED] = "injured",
}
local npGroupShownOptions = {
[NAMEPLATE_CHOICE_NEVER] = "never", -- 1
[NAMEPLATE_CHOICE_ALWAYS] = "always", -- 2
[NAMEPLATE_CHOICE_INJURED] = "injured", -- 3
[NAMEPLATE_CHOICE_TARGETED] = "targeted", -- 8
[NAMEPLATE_CHOICE_INJURED_OR_TARGETED] = "injured or targeted" -- 9 NAMEPLATE_CHOICE_HURT,
}
local isChangingToFalse = false
----------------------------------------------------------------------------------------------------------
------------------------------------[ NAMEPLATES ]----------------------------------------------------
----------------------------------------------------------------------------------------------------------
local function OnNameplatesChanged(eventCode, type, id)
-- 18 = NAMEPLATE_TYPE_GROUP_MEMBER_NAMEPLATES
-- 19 = NAMEPLATE_TYPE_GROUP_MEMBER_HEALTHBARS
-- 20 = NAMEPLATE_TYPE_GROUP_MEMBER_NAMEPLATES_HIGHLIGHT
-- 21 = NAMEPLATE_TYPE_GROUP_MEMBER_HEALTHBARS_HIGHLIGHT
-- nameplates = GetSetting(SETTING_TYPE_NAMEPLATES, NAMEPLATE_TYPE_GROUP_MEMBER_NAMEPLATES),
-- healthBars = GetSetting(SETTING_TYPE_NAMEPLATES, NAMEPLATE_TYPE_GROUP_MEMBER_HEALTHBARS),
-- nameplatesHL = GetSetting(SETTING_TYPE_NAMEPLATES, NAMEPLATE_TYPE_GROUP_MEMBER_NAMEPLATES_HIGHLIGHT),
-- healthBarsHL = GetSetting(SETTING_TYPE_NAMEPLATES, NAMEPLATE_TYPE_GROUP_MEMBER_HEALTHBARS_HIGHLIGHT),
if Speedrun.isLocalChange == false and type == SETTING_TYPE_NAMEPLATES then
if id == NAMEPLATE_TYPE_GROUP_MEMBER_NAMEPLATES then
sV.nameplates = GetSetting(type, id)
elseif id == NAMEPLATE_TYPE_GROUP_MEMBER_HEALTHBARS then
sV.healthBars = GetSetting(type, id)
elseif id == NAMEPLATE_TYPE_GROUP_MEMBER_NAMEPLATES_HIGHLIGHT then
sV.nameplatesHL = GetSetting(type, id)
elseif id == NAMEPLATE_TYPE_GROUP_MEMBER_HEALTHBARS_HIGHLIGHT then
sV.healthBarsHL = GetSetting(type, id)
end
end
if Speedrun.isLocalChange == true and isChangingToFalse == false then
isChangingToFalse = true
zo_callLater(function()
Speedrun.isLocalChange = false
isChangingToFalse = false
CM:FireCallbacks("LAM-RefreshPanel", Speedrun_Settings)
end, 500)
end
end
function Speedrun.GetSavedNameplateSetting(value)
local option = npGroupShownOptions[value]
if option then return option end
end
local function GetNameplateChoice(value)
local choice = npGroupShownSettings[value]
if choice then return choice end
end
function Speedrun.GetNameplateGroupHiddenOptions()
local h = {}
for option in pairs(npGroupHiddenSettings) do table.insert(h, option) end
return h
end
function Speedrun.GetNameplateGroupShownOptions()
local s = {}
for option in pairs(npGroupShownSettings) do table.insert(s, option) end
return s
end
function Speedrun.ApplyNameplateGroupHiddenChoice()
if cV.groupHidden and sV.changeNameplates then
Speedrun.isLocalChange = true
local setting = npGroupHiddenSettings[sV.nameplatesHidden]
SetSetting(SETTING_TYPE_NAMEPLATES, NAMEPLATE_TYPE_GROUP_MEMBER_NAMEPLATES, tostring(setting))
Speedrun.npChanged = true
zo_callLater(function() Speedrun.isLocalChange = false end, 500)
end
end
function Speedrun.ApplyHealthbarGroupHiddenChoice()
if cV.groupHidden and sV.changeHealthBars then
Speedrun.isLocalChange = true
local setting = npGroupHiddenSettings[sV.healthBarsHidden]
SetSetting(SETTING_TYPE_NAMEPLATES, NAMEPLATE_TYPE_GROUP_MEMBER_HEALTHBARS, tostring(setting))
Speedrun.hbChanged = true
end
end
function Speedrun.ApplyNameplateHighlightGroupHiddenChoice()
if cV.groupHidden and sV.changeNameplates then
Speedrun.isLocalChange = true
local setting = npGroupHiddenSettings[sV.nameplatesHiddenHL]
SetSetting(SETTING_TYPE_NAMEPLATES, NAMEPLATE_TYPE_GROUP_MEMBER_NAMEPLATES_HIGHLIGHT, tostring(setting))
Speedrun.npHlChanged = true
end
end
function Speedrun.ApplyHealthbarHighlightGroupHiddenChoice()
if cV.groupHidden and sV.changeHealthBars then
Speedrun.isLocalChange = true
local setting = npGroupHiddenSettings[sV.healthBarsHiddenHL]
SetSetting(SETTING_TYPE_NAMEPLATES, NAMEPLATE_TYPE_GROUP_MEMBER_HEALTHBARS_HIGHLIGHT, tostring(setting))
Speedrun.hbHlChanged = true
end
end
----------------------------------------------------------------------------------------------------------
------------------------------------[ PROFILE ]----------------------------------------------------
----------------------------------------------------------------------------------------------------------
function Speedrun.CreateProfileDescriptionTitle()
local parent = Speedrun_ProfileSubmenu
local data = { type = "description" }
local name = "Speedrun_ActiveProfileDecriptionTitle"
local control = LAM.util.CreateBaseControl(parent, data, name)
-- local control = wm:CreateControl(name, parent, CT_CONTROL)
local width = (parent:GetWidth() - 60) / 2 --225
control:SetWidth(width)
control:SetResizeToFitDescendents(true)
control:SetDimensionConstraints(width, 0, width, 0)
control.title = wm:CreateControl(nil, control, CT_LABEL)
local title = control.title
title:SetWidth(width)
title:SetAnchor(TOPLEFT, control, TOPLEFT)
title:SetFont("ZoFontWinH4")
title:SetText("Currently Active Profile:")
return control
end
function Speedrun.CreateProfileDescriptionDisplay()
local parent = "Speedrun_ProfileSubmenu"
local name = "Speedrun_ActiveProfileDecriptionName"
local control = wm:CreateControl(name, parent, CT_CONTROL)
local width = 225
control:SetWidth(width)
control:SetResizeToFitDescendents(true)
control:SetDimensionConstraints(width, 0, width, 0)
local title = wm:CreateControl(nil, control, CT_LABEL)
title:SetWidth(width)
title:SetAnchor(TOPRIGHT, control, TOPRIGHT)
title:SetFont("ZoFontWinH4")
title:SetText(Speedrun.GetActiveProfileDisplay())
return control
end
function Speedrun:GetProfileNames()
local profiles = {}
Speedrun.numProfiles = 0
for name, v in pairs(sV.profiles) do
table.insert(profiles, name)
Speedrun.numProfiles = Speedrun.numProfiles + 1
end
return profiles
end
function Speedrun:GetProfileNamesToCopyTo()
local profilesToCopyTo = {}
for name, v in pairs(sV.profiles) do
if name ~= profileToCopyFrom then table.insert(profilesToCopyTo, name) end
end
return profilesToCopyTo
end
function Speedrun.AddProfile()
local name = Speedrun_ProfileEditbox.editbox:GetText()
Speedrun:dbg(0, "Adding new profile [<<1>>]", name)
if name == "Default" then return end
if sV.profiles[name] ~= nil then Speedrun:dbg(0, "Profile [".. name .."] Already Exist!") return end
if (name ~= "") then
sV.profiles[name] = Speedrun.GetDefaultProfile()
Speedrun.activeProfile = name
cV.activeProfile = Speedrun.activeProfile
Speedrun.LoadProfile(name)
-- Speedrun.UpdateDropdowns()
else Speedrun:dbg(0, "Failed to add profile!") end
profileToAdd = ""
end
function Speedrun.CopyProfile(from, to)
for k, v in pairs(sV.profiles) do
if sV.profiles[k] == to then
sV.profiles[k] = {}
sV.profiles[k] = sV.profiles[from]
end
end
if (sV.profiles[to] == Speedrun.activeProfile and Speedrun.IsInTrialZone()) then ReloadUI("ingame") end
profileToCopyFrom = ""
profileToCopyTo = ""
end
function Speedrun.DeleteProfile(name)
local name = profileToDelete -- = Speedrun_ProfileDeleteDropdown.data.getFunc() -- profileToDelete
local setDefault = profileToDelete == Speedrun.activeProfile and true or false
-- "Default" profile can't be deleted
if name == "Default" then
Speedrun:dbg(0, "[Default] can't be deleted!")
return
end
Speedrun:dbg(0, "Deleting profile: [<<1>>]", name)
-- update profile vars
local new_list = { }
for k, v in pairs(sV.profiles) do
if name ~= k then new_list[k] = v end
end
sV.profiles = new_list
-- set "Default" as active if deleted profile was active
if setDefault == true then Speedrun.LoadProfile("Default")
else Speedrun.UpdateDropdowns() end
profileToDelete = ""
end
function Speedrun.LoadProfile(name)
if sV.profiles[name] == nil then Speedrun:dbg(0, "ERROR! Profile: [<<1>>] not found.", name) return end
if sV.profiles[name] == Speedrun.activeProfile then Speedrun:dbg(0, "Profile: [<<1>>] is already active.", name) return end
Speedrun.activeProfile = name
cV.activeProfile = Speedrun.activeProfile
Speedrun:dbg(0, "Loading profile: <<1>>", Speedrun.GetActiveProfileDisplay())
-- profileToLoad = ""
Speedrun.ValidateProfile(Speedrun.activeProfile)
Speedrun.RefreshProfileSettings()
if Speedrun.IsInTrialZone() then
Speedrun.ResetUI()
Speedrun.CreateRaidSegment(Speedrun.raidID)
if GetRaidDuration() <= 0 and not IsRaidInProgress() then SpeedRun_Score_Label:SetText(Speedrun.BestPossible(Speedrun.raidID)) end
Speedrun.UpdateCurrentVitality()
else
if Speedrun.inMenu then
if Speedrun.currentTrialMenu ~= nil then Speedrun.CreateRaidSegment(Speedrun.currentTrialMenu)
else
if Speedrun.isUIDrawn then Speedrun.CreateRaidSegment(Speedrun.raidID)
else SpeedRun_Timer_Container_Profile:SetText(Speedrun.GetActiveProfileDisplay()) end
end
else SpeedRun_Timer_Container_Profile:SetText(Speedrun.GetActiveProfileDisplay()) end
end
end
function Speedrun.UpdateDropdowns()
if Speedrun.inMenu then
local profileNames = Speedrun:GetProfileNames()
Speedrun_ProfileDropdown:UpdateChoices(profileNames)
Speedrun_ProfileDeleteDropdown:UpdateChoices(profileNames)
-- Speedrun_ProfileCopyFrom:UpdateChoices(profileNames)
-- Speedrun_ProfileCopyTo:UpdateChoices(Speedrun:GetProfileNamesToCopyTo())
Speedrun_ProfileImportTo:UpdateChoices(profileNames)
end
-- Speedrun.UpdateProfileList()
end
function Speedrun.RefreshProfileSettings()
Speedrun:dbg(2, "Updating Menu")
Speedrun.addsOnCR = sV.profiles[Speedrun.activeProfile].addsOnCR
Speedrun.hmOnSS = sV.profiles[Speedrun.activeProfile].hmOnSS
Speedrun.LoadRaidlist(Speedrun.activeProfile)
Speedrun.LoadCustomTimers(Speedrun.activeProfile)
Speedrun.UpdateDropdowns()
Speedrun.RefreshTrialTimers()
if Speedrun.currentTrialMenu and Speedrun.stepList[Speedrun.currentTrialMenu]
then Speedrun.CreateRaidSegmentFromMenu(Speedrun.currentTrialMenu) end
end
----------------------------------------------------------------------------------------------------------
------------------------------------[ FOOD REMINDER ]---------------------------------------------------
----------------------------------------------------------------------------------------------------------
function Speedrun.CreateFoodReminderSettings()
local settings = {
{ type = "submenu", name = "Food Reminder",
controls = {
{ type = "description", text = "The food reminder will let you know when there is less than 10 minutes left of your food buff, and will keep informing you in intervals.\nOnly in trials."
},
{ type = "checkbox", name = "Enable",
tooltip = "Enable food reminder.",
default = false,
getFunc = function() return sV.food.show end,
setFunc = function(newValue)
sV.food.show = newValue
Speedrun.ToggleFoodReminder()
end,
width = "half"
},
{ type = "checkbox", name = "Unlock",
default = false,
getFunc = function() return Speedrun.foodUnlocked end,
setFunc = function(newValue)
Speedrun.foodUnlocked = newValue
Speedrun.ShowFoodReminder(newValue)
end,
width = "half"
},
{ type = "slider", name = "Size",
getFunc = function() return sV.food.size end,
setFunc = function(newValue)
sV.food.size = newValue
Speedrun.UpdateFoodReminderSize()
end,
min = 17,
max = 50,
default = 30,
width = "half"
},
{ type = "slider", name = "Reminder Interval",
tooltip = "How often you want to be reminded when your food buff has expired (in seconds).\n0 = Always show if no food is active.",
getFunc = function() return sV.food.time end,
setFunc = function(newValue)
sV.food.time = newValue
if sV.food.show then
Speedrun.UpdateFoodReminderInterval((GetGameTimeMilliseconds() / 1000), sV.food.time)
end
end,
min = 30,
max = 300,
default = 120,
width = "half"
}
}
}
}
return settings
end
----------------------------------------------------------------------------------------------------------
------------------------------------[ TRIAL ]------------------------------------------------------
----------------------------------------------------------------------------------------------------------
local function SubmenuMouseEnter(id)
Speedrun.currentTrialMenu = id
end
-- local function SubmenuMouseExit(id)
-- Speedrun.currentTrialMenu = nil
-- end
--
-- function Speedrun.GetTime(seconds)
-- if seconds then
-- if seconds > 10 then
-- return "|cffffff" .. seconds .. " seconds|r"
-- elseif seconds < 60 then
-- return "|cffffff" .. string.format("%02d", seconds % 60) .. " seconds|r"
-- elseif seconds < 3600 then
-- return "|cffffff" .. string.format("%02d:%02d", math.floor((seconds / 60) % 60), seconds % 60) .. "|r"
-- else
-- return "|cffffff" .. string.format("%02d:%02d:%02d", math.floor(seconds / 3600), math.floor((seconds / 60) % 60), seconds % 60) .. "|r"
-- end
-- end
-- end
function Speedrun.GetTime(seconds)
if seconds then
if seconds < 3600
then return "|cffffff"..string.format("%02d:%02d", math.floor((seconds / 60) % 60), seconds % 60).."|r"
else return "|cffffff"..string.format("%02d:%02d:%02d", math.floor(seconds / 3600), math.floor((seconds / 60) % 60), seconds % 60).."|r" end
end
end
function Speedrun.GetTooltip(timer)
if timer then
local t = "|cffffff" .. string.format(math.floor(timer / 1000)) .. "|r"
return zo_strformat(SI_SPEEDRUN_STEP_DESC_EXIST, t, Speedrun.GetTime(math.floor(timer / 1000)))
else
return zo_strformat(SI_SPEEDRUN_STEP_DESC_NULL)
end
end
function Speedrun.Simulate(raidID)
local timer = 0
for i, x in pairs(Speedrun.Data.customTimerSteps[raidID]) do
local s = Speedrun.GetSavedTimer(raidID, i)
if s then
timer = s + timer
Speedrun:dbg(2, "[<<1>>]: <<2>>.", i, string.format("%.2f", s / 1000))
end
end
local r = 0
if timer > 0 then if (timer % 1000) >= 500 then r = 1 end end
local t = math.floor(timer / 1000) + r
local vitality = Speedrun.GetTrialMaxVitality(raidID)
local score = tostring(math.floor(Speedrun.GetScore(t, vitality, raidID)))
local fScore = string.sub(score,string.len(score)-2,string.len(score))
local dScore = string.gsub(score,fScore,"")
score = dScore .. "'" .. fScore
d("|cdf4242" .. zo_strformat(SI_ZONE_NAME,GetZoneNameById(raidID)) .. "|r")
d(zo_strformat(SI_SPEEDRUN_SIMULATE_FUNCTION, Speedrun.GetTime(t), score))
end
function Speedrun.Overwrite(raidID)
for k, v in pairs(Speedrun.customTimerSteps[raidID]) do
if Speedrun.customTimerSteps[raidID][k] ~= "" then
if Speedrun.GetCustomTimerStep(raidID, k) == "0"
then Speedrun.SaveTimerStep(raidID, k, nil)
else Speedrun.SaveTimerStep(raidID, k, tonumber(Speedrun.GetCustomTimerStep(raidID, k)) * 1000) end
Speedrun.SaveCustomStep(raidID, k, "")
end
end
if Speedrun.IsInTrialZone() then
ReloadUI("ingame")
Speedrun.ResetUI()
Speedrun.CreateRaidSegment(raidID)
if GetRaidDuration() <= 0 and not IsRaidInProgress()
then SpeedRun_Score_Label:SetText(Speedrun.BestPossible(Speedrun.raidID)) end
else
Speedrun.RefreshTrial(raidID)
Speedrun.CreateRaidSegmentFromMenu(raidID)
end
end
function Speedrun.ResetData(raidID)
-- For MA and VH
if raidID == 677 or raidID == 1227 then
if cV.individualArenaTimers then
if cV.arenaList[raidID].timerSteps then cV.arenaList[raidID].timerSteps = {} end
else
if sV.profiles[Speedrun.activeProfile].raidList[raidID].timerSteps
then sV.profiles[Speedrun.activeProfile].raidList[raidID].timerSteps = {} end
end
else
if Speedrun.raidList[raidID].timerSteps then
Speedrun.raidList[raidID].timerSteps = {}
sV.profiles[Speedrun.activeProfile].raidList = Speedrun.raidList
end
end
-- ReloadUI("ingame")
if Speedrun.IsInTrialZone() then
Speedrun.ResetUI()
Speedrun.CreateRaidSegment(raidID)
else
Speedrun.RefreshTrial(raidID)
Speedrun.CreateRaidSegmentFromMenu(raidID)
end
end
function Speedrun.CreateOptionTable(raidID, step)
local settingsTimer = {
saved = Speedrun.GetSavedTimerStep(raidID, step),
custom = Speedrun.GetCustomTimerStep(raidID, step),
toolTip = ""
}
trialMenuTimers[raidID][step] = settingsTimer
trialMenuTimers[raidID][step].toolTip = Speedrun.GetTooltip(Speedrun.GetSavedTimerStep(raidID, step))
return
{ type = "editbox",
name = zo_strformat(SI_SPEEDRUN_STEP_NAME, Speedrun.Data.stepList[raidID][step]),
tooltip = function() return trialMenuTimers[raidID][step].toolTip end,
default = "",
getFunc = function() return trialMenuTimers[raidID][step].custom end,
setFunc = function(newValue)
Speedrun.SaveCustomStep(raidID, step, newValue)
trialMenuTimers[raidID][step].custom = newValue
end,
reference = "SpeedRun_Editbox_" .. raidID .. step
}
end
function Speedrun.CreateRaidMenu(raidID)
local raidMenu = {}
table.insert(raidMenu, { type = "description", text = zo_strformat(SI_SPEEDRUN_RAID_DESC) })
if raidID == 1051 then
table.insert(raidMenu,
{ type = "checkbox",
name = zo_strformat(SI_SPEEDRUN_ADDS_CR_NAME),
tooltip = zo_strformat(SI_SPEEDRUN_ADDS_CR_DESC),
default = true,
getFunc = function() return Speedrun.addsOnCR end,
setFunc = function(newValue)
Speedrun.addsOnCR = newValue
sV.profiles[Speedrun.activeProfile].addsOnCR = Speedrun.addsOnCR
end
}
)
end
if raidID == 1121 then
local choices = {
[1] = zo_strformat(SI_SPEEDRUN_ZERO),
[2] = zo_strformat(SI_SPEEDRUN_ONE),
[3] = zo_strformat(SI_SPEEDRUN_TWO),
[4] = zo_strformat(SI_SPEEDRUN_THREE),
}
table.insert(raidMenu,
{ type = "dropdown",
name = zo_strformat(SI_SPEEDRUN_HM_SS_NAME),
tooltip = zo_strformat(SI_SPEEDRUN_HM_SS_DESC),
choices = choices,
default = choices[4],
getFunc = function() return choices[Speedrun.hmOnSS] end,
setFunc = function(selected)
for index, name in ipairs(choices) do
if name == selected then
Speedrun.hmOnSS = index
sV.profiles[Speedrun.activeProfile].hmOnSS = Speedrun.hmOnSS
break
end
end
end,
}
)
end
for i, x in ipairs(Speedrun.Data.stepList[raidID]) do
table.insert(raidMenu, Speedrun.CreateOptionTable(raidID, i))
end
table.insert(raidMenu,
{ type = "button",
name = zo_strformat(SI_SPEEDRUN_SIMULATE_NAME),
tooltip = zo_strformat(SI_SPEEDRUN_SIMULATE_DESC),
func = function()
Speedrun.Simulate(raidID)
Speedrun.currentTrialMenu = raidID
end,
width = "half"
}
)
table.insert(raidMenu,
{ type = "button",
name = "Apply to UI",
tooltip = "If you are not currently inside a trial, this button will make the SpeedRun UI window display your currently saved steps for this trial.",
func = function()
Speedrun.currentTrialMenu = raidID
Speedrun.CreateRaidSegmentFromMenu(raidID)
end,
disabled = function() return Speedrun.IsInTrialZone() end,
width = "half"
}
)
table.insert(raidMenu,
{ type = "button",
name = "Apply Times",
tooltip = "Overwrite current saved times with entered custom times.\nEntering '0' to a field will delete your saved time for that step when this button is pressed.\nFields left blank wont be changed.",
func = function()
Speedrun.Overwrite(raidID)
Speedrun.currentTrialMenu = raidID
end,
width = "half",
isDangerous = true,
warning = "Confirm Changes.",
}
)
table.insert(raidMenu,
{ type = "button",
name = zo_strformat(SI_SPEEDRUN_RESET_NAME),
tooltip = zo_strformat(SI_SPEEDRUN_RESET_DESC),
func = function()
Speedrun.ResetData(raidID)
Speedrun.currentTrialMenu = raidID
end,
width = "half",
isDangerous = true,
warning = zo_strformat(SI_SPEEDRUN_RESET_WARNING)
}
)
local menu = { id = raidID, control = "SpeedRun_TrialMenu_" .. raidID }
trialSubmenus[raidID] = menu
local trialControls = {
type = "submenu",
name = (zo_strformat(SI_ZONE_NAME, GetZoneNameById(raidID))),
controls = raidMenu,
reference = "SpeedRun_TrialMenu_" .. raidID,
}
return trialControls
end
function Speedrun.SetTrialMenuHandlers()
for i, x in pairs(trialSubmenus) do
local m = trialSubmenus[i]
local s = wm:GetControlByName("SpeedRun_TrialMenu_" .. m.control)
if s then
s:SetHandler("OnMouseEnter", function() SubmenuMouseEnter(m.id) end)
-- s:SetHandler("OnMouseExit" , function() SubmenuMouseExit(m.id) end)
end
end
end
function Speedrun.RefreshTrial(raidID)
trialMenuTimers[raidID] = {}
for i, x in pairs(Speedrun.Data.customTimerSteps[raidID]) do
if Speedrun.Data.customTimerSteps[raidID][i] then
local settingsTimer = {
saved = Speedrun.GetSavedTimerStep(raidID, i),
custom = Speedrun.GetCustomTimerStep(raidID, i),
toolTip = ""
}
trialMenuTimers[raidID][i] = settingsTimer
trialMenuTimers[raidID][i].toolTip = Speedrun.GetTooltip(Speedrun.GetSavedTimerStep(raidID, i))
local editbox = wm:GetControlByName("SpeedRun_Editbox_" .. raidID .. i)
if editbox then editbox.data.tooltipText = trialMenuTimers[raidID][i].toolTip end
end
end
end
function Speedrun.RefreshTrialTimers()
for i, x in pairs(Speedrun.Data.customTimerSteps) do
if Speedrun.Data.customTimerSteps[i] then Speedrun.RefreshTrial(i) end
end
end
function Speedrun.StressTestedConfirmed()
isST = true
end
local ka = {
-- adds
wrathOfTides = {
id = 134050,
options = { -3, 0, false, { 1, 0, 0.6, 0.4 }, { 1, 0, 0.6, 0.8 } }
},
-- yandir
yandirName = "yandir",
chaurus = {
id = 133515,
name = 133559,
options = { -3, 0, false, { 0, 0.8, 0, 0.4 }, { 0, 0.8, 0, 0.8 } }
},
gargoyle = {
id = 133546,
options = { -3, 0, false, { 0.6, 0.4, 0.2, 0.4 }, { 0.6, 0.4, 0.2, 0.8 } }
},
-- vrol
vrolName = "vrol",
portalTime = 0,
conjurer = 136941, -- conjurer spawn
portal1 = 133994, -- portal summon
portal2 = 134004, -- portal synergy taken
-- falgravn
falgravName = "falgrav",
bloodCleave = {
id = 136976,
options = { -3, 0, false, { 1, 0, 0.6, 0.4 }, { 1, 0, 0.6, 0.8 } }
},
uppercut = 136961,
units = {}
}
local function StopVrolPortal()
EM:UnregisterForUpdate(Speedrun.name .. "VrolPortal")
CombatAlerts.panel.rows[2]:SetHidden(true)
CombatAlerts.panel.rows[2].label:SetText("")
CombatAlerts.panel.rows[2].data:SetText("")
CombatAlerts.panel.rows[2].label:SetColor(1, 1, 1, 1)
CombatAlerts.panel.rows[2].data:SetColor(1, 1, 1, 1)
end
local function VrolPortal()
local t = GetGameTimeMilliseconds() / 1000
local time = ka.portalTime - t
if time > 0 then
CombatAlerts.panel.rows[2]:SetHidden(false)
if time >= 4 then
CombatAlerts.panel.rows[2].label:SetColor(1, 0.6, 0.2, 1)
CombatAlerts.panel.rows[2].data:SetColor(1, 0.6, 0.2, 1)
CombatAlerts.panel.rows[2].data:SetText(string.format("%0.1f", time - 4))
else
CombatAlerts.panel.rows[2].label:SetColor(1, 0, 0, 1)
CombatAlerts.panel.rows[2].data:SetColor(1, 0, 0, 1)
CombatAlerts.panel.rows[2].label:SetText("Portal Closing")
CombatAlerts.panel.rows[2].data:SetText(string.format("%0.1f", time))
end
else StopVrolPortal() end
end
function Speedrun.KynesAegisAlerts( _, result, _, _, _, _, sName, _, _, tType, hValue, _, _, _, sId, tId, abilityId, _)
-- Wrath of Tides
if (result == ACTION_RESULT_BEGIN and tType ~= COMBAT_UNIT_TYPE_PLAYER and abilityId == ka.wrathOfTides.id) then
local id = CombatAlerts.AlertCast(ka.wrathOfTides.id, sName, hValue, ka.wrathOfTides.options )
if (tId and tId ~= 0) then
CombatAlerts.castAlerts.sources[tId] = id
end
--Chaurus Totem
elseif (result == ACTION_RESULT_BEGIN and abilityId == ka.chaurus.id) then
-- local id = CombatAlerts.StartBanner(nil, GetFormattedAbilityName(ka.chaurus.name), 0x33FF00FF, ka.chaurus.name, true, nil)
-- EM:UnregisterForUpdate(CombatAlerts.banners[id].name)
-- EM:RegisterForUpdate(CombatAlerts.banners[id].name, 4250, function()
-- CombatAlerts.DisableBanner(id)
-- end)
local id = CombatAlerts.AlertCast(ka.chaurus.name, sName, 4250, ka.chaurus.options )
elseif result == ACTION_RESULT_BEGIN and abilityId == ka.chaurus.name then
CombatAlerts.AlertCast( abilityId, sName, hValue, ka.chaurus.options )
-- Gargoyle Totem
elseif (result == ACTION_RESULT_BEGIN and abilityId == ka.gargoyle.id) then
local id = CombatAlerts.AlertCast(ka.gargoyle.id, sName, hValue, ka.gargoyle.options )
if (sId and sId ~= 0) then
CombatAlerts.castAlerts.sources[sId] = id
end
-- conjurer spawn
elseif (result == ACTION_RESULT_BEGIN and abilityId == ka.conjurer) then
local t = ( GetGameTimeMilliseconds() / 1000 )
CombatAlerts.panel.rows[2].label:SetColor(1, 0.6, 0, 1)
CombatAlerts.panel.rows[2].data:SetFont("$(BOLD_FONT)|$(KB_28)|soft-shadow-thick")
if CombatAlerts.panel.enabled ~= true then
CombatAlerts.ka.panelMode = 1
CombatAlerts.TogglePanel(true, {GetFormattedAbilityName(CombatAlertsData.ka.shockingHarpoon), "Conjurer Spawned"}, true, true)
else
CombatAlerts.panel.rows[2].label:SetText("Conjurer Spawned")
CombatAlerts.panel.rows[2].data:SetText("")
CombatAlerts.panel.rows[2]:SetHidden(false)
end
-- summon portal
elseif (result == ACTION_RESULT_BEGIN and abilityId == ka.portal1) then
if ka.portalTime - ( GetGameTimeMilliseconds() / 1000 ) > 0 then return end
ka.portalTime = ( GetGameTimeMilliseconds() / 1000 ) + 7.1
if CombatAlerts.panel.enabled ~= true then
CombatAlerts.ka.panelMode = 1
CombatAlerts.TogglePanel(true, {GetFormattedAbilityName(CombatAlertsData.ka.shockingHarpoon), "Portal Opening"}, true, true)
else
CombatAlerts.panel.rows[2].label:SetText("Portal Opening")
CombatAlerts.panel.rows[2]:SetHidden(false)
end
VrolPortal()
EM:RegisterForUpdate(Speedrun.name .. "VrolPortal", 100, VrolPortal)
-- portal synergy taken
elseif (result == ACTION_RESULT_EFFECT_GAINED or result == ACTION_RESULT_EFFECT_GAINED_DURATION and abilityId == ka.portal2) then
if ka.portalTime - ( GetGameTimeMilliseconds() / 1000 ) > 0 then
ka.portalTime = 0
StopVrolPortal()
end
-- Blood Cleave
elseif (result == ACTION_RESULT_BEGIN and abilityId == ka.bloodCleave.id) then
local id = CombatAlerts.AlertCast(ka.bloodCleave.id, sName, hValue, ka.bloodCleave.options )
if (tId and tId ~= 0) then
CombatAlerts.castAlerts.sources[tId] = id
end
elseif (result == ACTION_RESULT_BEGIN and tType == COMBAT_UNIT_TYPE_PLAYER and abilityId == ka.uppercut) then
CombatAlerts.Alert(nil, GetFormattedAbilityName(136961), 0xFF6600FF, SOUNDS.CHAMPION_POINTS_COMMITTED, hValue)
-- CombatAlerts.AlertCast( abilityId, "Dodge!", hValue, { hValue, "Dodge!", 1, 0.4, 0, 0.5, nil } )
CombatAlerts.CastAlertsStart(136961, "", hValue, nil, nil, { hValue, "Dodge!", 1, 0.4, 0, 0.5, nil })
end
end
local function ValenIsACutiePie()
if not DoesUnitExist("boss1") then
Speedrun.ValenIsStillCuteButStopTrackingKA(false)
CombatAlerts.panel.rows[2].data:SetFont("$(MEDIUM_FONT)|$(KB_28)|soft-shadow-thick")
return
end
local boss = string.lower( GetUnitName( "boss1" ) )
local yandir = string.find ( boss, ka.yandirName )
local vrol = string.find ( boss, ka.vrolName )
local falgravn = string.find ( boss, ka.falgravName )
if yandir then
EM:RegisterForEvent( Speedrun.name .. "Chaurus", EVENT_COMBAT_EVENT, Speedrun.KynesAegisAlerts )
EM:AddFilterForEvent( Speedrun.name .. "Chaurus", EVENT_COMBAT_EVENT, REGISTER_FILTER_ABILITY_ID, 133515 )
EM:RegisterForEvent( Speedrun.name .. "Stone", EVENT_COMBAT_EVENT, Speedrun.KynesAegisAlerts )
EM:AddFilterForEvent( Speedrun.name .. "Stone", EVENT_COMBAT_EVENT, REGISTER_FILTER_ABILITY_ID, 133546 )
else
EM:UnregisterForEvent( Speedrun.name .. "Chaurus", EVENT_COMBAT_EVENT )
EM:UnregisterForEvent( Speedrun.name .. "Stone", EVENT_COMBAT_EVENT )
end
if vrol then
EM:RegisterForEvent( Speedrun.name .. "Vrol1", EVENT_COMBAT_EVENT, Speedrun.KynesAegisAlerts )
EM:AddFilterForEvent( Speedrun.name .. "Vrol1", EVENT_COMBAT_EVENT, REGISTER_FILTER_ABILITY_ID, 136941 )
EM:RegisterForEvent( Speedrun.name .. "Vrol2", EVENT_COMBAT_EVENT, Speedrun.KynesAegisAlerts )
EM:AddFilterForEvent( Speedrun.name .. "Vrol2", EVENT_COMBAT_EVENT, REGISTER_FILTER_ABILITY_ID, 133994 )
EM:RegisterForEvent( Speedrun.name .. "Vrol3", EVENT_COMBAT_EVENT, Speedrun.KynesAegisAlerts )
EM:AddFilterForEvent( Speedrun.name .. "Vrol3", EVENT_COMBAT_EVENT, REGISTER_FILTER_ABILITY_ID, 134004 )
CombatAlerts.panel.rows[2].data:SetFont("$(BOLD_FONT)|$(KB_28)|soft-shadow-thick")
else
EM:UnregisterForEvent( Speedrun.name .. "Vrol1", EVENT_COMBAT_EVENT )
EM:UnregisterForEvent( Speedrun.name .. "Vrol2", EVENT_COMBAT_EVENT )
EM:UnregisterForEvent( Speedrun.name .. "Vrol3", EVENT_COMBAT_EVENT )
EM:UnregisterForUpdate(Speedrun.name .. "VrolPortal")
CombatAlerts.panel.rows[2].data:SetFont("$(MEDIUM_FONT)|$(KB_28)|soft-shadow-thick")
end
if falgravn then
EM:RegisterForEvent( Speedrun.name .. "BloodCleave", EVENT_COMBAT_EVENT, Speedrun.KynesAegisAlerts )
EM:AddFilterForEvent( Speedrun.name .. "BloodCleave", EVENT_COMBAT_EVENT, REGISTER_FILTER_ABILITY_ID, 136976 )
EM:RegisterForEvent( Speedrun.name .. "Uppercut", EVENT_COMBAT_EVENT, Speedrun.KynesAegisAlerts )
EM:AddFilterForEvent( Speedrun.name .. "Uppercut", EVENT_COMBAT_EVENT, REGISTER_FILTER_ABILITY_ID, 136961 )
else
EM:UnregisterForEvent( Speedrun.name .. "BloodCleave", EVENT_COMBAT_EVENT )
EM:UnregisterForEvent( Speedrun.name .. "Uppercut", EVENT_COMBAT_EVENT )
end
end
function Speedrun.ValenIsStillCuteButStopTrackingKA(stopAll)
if stopAll then
EM:UnregisterForEvent( Speedrun.name .. "ValenIsACutiepie", EVENT_PLAYER_COMBAT_STATE )
EM:UnregisterForEvent( Speedrun.name .. "ValenIsACutiepie", EVENT_BOSSES_CHANGED )
EM:UnregisterForEvent( Speedrun.name .. "WrathOfTides", EVENT_COMBAT_EVENT )
end
EM:UnregisterForEvent( Speedrun.name .. "Chaurus", EVENT_COMBAT_EVENT )
EM:UnregisterForEvent( Speedrun.name .. "Stone", EVENT_COMBAT_EVENT )
EM:UnregisterForEvent( Speedrun.name .. "Vrol1", EVENT_COMBAT_EVENT )
EM:UnregisterForEvent( Speedrun.name .. "Vrol2", EVENT_COMBAT_EVENT )
EM:UnregisterForEvent( Speedrun.name .. "Vrol3", EVENT_COMBAT_EVENT )
EM:UnregisterForEvent( Speedrun.name .. "BloodCleave", EVENT_COMBAT_EVENT )
EM:UnregisterForEvent( Speedrun.name .. "Uppercut", EVENT_COMBAT_EVENT )
EM:UnregisterForUpdate(Speedrun.name .. "VrolPortal" )
end
function Speedrun.ChaosIsABellend()
if (not isST or not sV.valenFinallyGotGH) then return end
if CombatAlerts and GetZoneId(GetUnitZoneIndex("player")) == 1196 then
EM:RegisterForEvent( Speedrun.name .. "ValenIsACutiepie", EVENT_PLAYER_COMBAT_STATE, ValenIsACutiePie )
EM:RegisterForEvent( Speedrun.name .. "ValenIsACutiepie", EVENT_BOSSES_CHANGED, ValenIsACutiePie )
EM:RegisterForEvent( Speedrun.name .. "WrathOfTides", EVENT_COMBAT_EVENT, Speedrun.KynesAegisAlerts )
EM:AddFilterForEvent( Speedrun.name .. "WrathOfTides", EVENT_COMBAT_EVENT, REGISTER_FILTER_ABILITY_ID, 134050 )
else Speedrun.ValenIsStillCuteButStopTrackingKA(true) end
end
----------------------------------------------------------------------------------------------------------
-----------------------------------[ SETTINGS WINDOW ]----------------------------------------------
----------------------------------------------------------------------------------------------------------
-- function Speedrun.BuildSettingsTable()
-- local p = Speedrun.activeProfile
-- local c = sV.profiles[p].customTimerSteps
-- local r = sV.profiles[p].raidList
function Speedrun.RegisterNameplateSettingChanges()
EM:UnregisterForEvent(Speedrun.name .. "Nameplate", EVENT_INTERFACE_SETTING_CHANGED)
if (sV.changeNamePlates or sV.changeHealthBars) then
EM:RegisterForEvent(Speedrun.name .. "Nameplate", EVENT_INTERFACE_SETTING_CHANGED, OnNameplatesChanged) EM:AddFilterForEvent(Speedrun.name .. "Nameplate", EVENT_INTERFACE_SETTING_CHANGED,
REGISTER_FILTER_SETTING_SYSTEM_TYPE, SETTING_TYPE_NAMEPLATES)
end
end
function Speedrun.ConfigureNameplates()
sV = Speedrun.savedVariables
cV = Speedrun.savedSettings
if sV.nameplatesHidden == "" then
if sV.hideNameplates ~= nil then
if sV.hideNameplates == true then sV.nameplatesHidden = "always"
else sV.nameplatesHidden = npGroupHiddenOptions[sV.nameplates] end
sV.hideNameplates = nil
else sV.nameplatesHidden = npGroupHiddenOptions[sV.nameplates] end
end
if sV.healthBarsHidden == "" then
if sV.hideHealthBars ~= nil then
if sV.healthBars == true then sV.healthBarsHidden = "always"
else sV.healthBarsHidden = npGroupHiddenOptions[sV.healthBars] end
sV.hideHealthBars = nil
else sV.healthBarsHidden = npGroupHiddenOptions[sV.healthBars] end
end
if sV.nameplatesHiddenHL == "" then sV.nameplatesHiddenHL = npGroupHiddenOptions[sV.nameplatesHL] end
if sV.healthBarsHiddenHL == "" then sV.healthBarsHiddenHL = npGroupHiddenOptions[sV.healthBarsHL] end
Speedrun.RegisterNameplateSettingChanges()
end
function Speedrun.CreateSettingsWindow()
local panelData = {
type = "panel",
name = "SpeedRun",
displayName = "Speed|cdf4242Run|r",
author = "Floliroy, Panaa, @nogetrandom [PC EU]",
version = Speedrun.version,
slashCommand = "/speed menu",
registerForRefresh = true
}
local cntrlOptionsPanel = LAM:RegisterAddonPanel("Speedrun_Settings", panelData)
-- Speedrun.RefreshTrialTimers()
CM:RegisterCallback("LAM-PanelOpened", function(panel)
if panel ~= cntrlOptionsPanel then return end
Speedrun.inMenu = true
Speedrun.UpdateVisibility()
-- SpeedRun_Panel:SetHidden(false)
-- Speedrun.ShowInMenu()
end)
CM:RegisterCallback("LAM-PanelClosed", function(panel)
if panel ~= cntrlOptionsPanel then return end
Speedrun.inMenu = false
Speedrun.currentTrialMenu = nil
Speedrun.UpdateVisibility()
-- SpeedRun_Panel:SetHidden(true)
-- Speedrun.SetUIHidden(true)
end)
local function WalkInLava()
local ChaosMadeMeDoThis = nil
if (CombatAlerts and isST) then
ChaosMadeMeDoThis = {
type = "checkbox", name = "Valen is a |cFF99CCC|cF989B7u|cF47AA3t|cEF6B8Ei|cEA5B7Ae|cE54C66p|cE03D51i|cDB2D3De|r",
tooltip = "Walk in Lava",
default = false,
getFunc = function() return sV.valenFinallyGotGH end,
setFunc = function() sV.valenFinallyGotGH = not sV.valenFinallyGotGH end
}