-
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathaudio.lua
More file actions
97 lines (83 loc) · 4.05 KB
/
Copy pathaudio.lua
File metadata and controls
97 lines (83 loc) · 4.05 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
-- 'ang' is the angleur namespace
local addonName, ang = ...
local debugChannel = 9
local colorDebug = CreateColor(0.29, 1, 0) -- bright green
PHASE1_SUBTRACTAMOUNT = 0.5
PHASE2_DURATION = 2
DELAYER_THRESHOLD = 0.5
INFO_SPELLID_INDEX = 8
-- function Angleur_EventHandler_Audio(self, event, unit, ...)
-- end
-- local audioHandlerFrame = CreateFrame("Frame")
-- audioHandlerFrame:RegisterEvent("UNIT_SPELLCAST_CHANNEL_START")
-- audioHandlerFrame:RegisterEvent("UNIT_SPELLCAST_CHANNEL_STOP")
-- audioHandlerFrame:SetScript("OnEvent", )
local getChannelDuration
if ang.gameVersion == 1 or ang.gameVersion == 2 then
getChannelDuration = function()
local durationObject = UnitChannelDuration("player")
local channelDuration = durationObject:GetTotalDuration()
return channelDuration
end
elseif ang.gameVersion == 3 then
getChannelDuration = function()
local _, _, _, startTimeMs, endTimeMs = UnitChannelInfo("player")
local durationMs = endTimeMs - startTimeMs
local channelDuration = durationMs/1000
Angleur_BetaPrint(debugChannel, colorDebug:WrapTextInColorCode("Recast Reminder: ") .. "Classic channel duration: ", channelDuration)
return channelDuration
end
end
local reminderDelayer = CreateFrame("Frame")
-- 0 -> inactive | 1 -> first part active(waiting until channel ends) | 2 -> second part active(waiting an arbitrary amount until audio warning)
local scriptPhase = 0
local function phase2()
scriptPhase = 2
Angleur_BetaPrint(debugChannel, colorDebug:WrapTextInColorCode("Recast Reminder: ") .. "Phase 1 complete, starting phase 2")
Angleur_SingleDelayer(PHASE2_DURATION, 0, DELAYER_THRESHOLD, reminderDelayer, nil, function()
scriptPhase = 0
Angleur_BetaPrint(debugChannel, colorDebug:WrapTextInColorCode("Recast Reminder: ") .. "Phase 2 complete, playing sound")
PlaySoundFile("Interface/AddOns/Angleur/sounds/angleurFailRecast.ogg")
end)
end
local function phase1(channelDuration)
scriptPhase = 1
Angleur_BetaPrint(debugChannel, colorDebug:WrapTextInColorCode("Recast Reminder: ") .. "Phase 1 Delayer duration: ", channelDuration)
-- TODO: set a delayer that will play the sound effect upon expiry
Angleur_SingleDelayer(channelDuration, 0, DELAYER_THRESHOLD, reminderDelayer, nil, function()
phase2()
end)
end
function Angleur_RecastReminder_Start(spellID)
if not AngleurAudio.checkboxes.recastReminder then return end
local channelInfo = {UnitChannelInfo("player")}
if not channelInfo then return end
local spellIDFromUnit = Angleur_ScrubSecret(channelInfo[INFO_SPELLID_INDEX])
if not spellIDFromUnit or spellIDFromUnit ~= spellID then
Angleur_BetaPrint(debugChannel, colorDebug:WrapTextInColorCode("Recast Reminder: ") .. "Channeled spell isn't fishing. Don't start.")
return
end
if scriptPhase == 2 then
reminderDelayer:SetScript("OnUpdate", nil)
scriptPhase = 0
Angleur_BetaPrint(debugChannel, colorDebug:WrapTextInColorCode("Recast Reminder: ") .. "Phase 2 ended prematurely, removing script.")
end
local channelDuration = getChannelDuration()
if not channelDuration then Angleur_BetaPrint(debugChannel, colorDebug:WrapTextInColorCode("Recast Reminder: ") .. "Channel duration nil. Returning.") return end
channelDuration = channelDuration - PHASE1_SUBTRACTAMOUNT
if channelDuration <= 0 then
Angleur_BetaPrint(debugChannel, colorDebug:WrapTextInColorCode("Recast Reminder: ") .. "Channel too short, not starting phase 1 of delayer. (" .. channelDuration .. ")")
return
end
phase1(channelDuration)
end
function Angleur_RecastReminder_Stop()
if scriptPhase ~= 1 then return end
Angleur_BetaPrint(debugChannel, colorDebug:WrapTextInColorCode("Recast Reminder: ") .. "Phase 1 ended prematurely, removing script.")
reminderDelayer:SetScript("OnUpdate", nil)
scriptPhase = 0
end
-- SLASH_ANGLEURAUDIOTEST1 = "/atest"
-- SlashCmdList["ANGLEURAUDIOTEST"] = function()
-- PlaySoundFile("Interface/AddOns/Angleur/sounds/angleurFailRecast.ogg")
-- end