This repository has been archived by the owner on Dec 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ParaxisSiren.lua
64 lines (57 loc) · 2.28 KB
/
ParaxisSiren.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
-- Copyright (C) 2017 Walter Kuppens
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
local PARAXIS_DEBUFF = "Paraxis Incoming"
local UPDATE_INTERVAL = 10.0
local warningActive = false
-- Calls ParaxisSirenDebuffHandler every 10 seconds while the Paraxis is in
-- view.
function ParaxisSirenUpdate(self, elapsed)
if warningActive then
self.lastUpdate = self.lastUpdate + elapsed
else
self.lastUpdate = 0
end
if self.lastUpdate > UPDATE_INTERVAL then
self.lastUpdate = 0
ParaxisSirenDebuffHandler()
end
end
-- Filters out irrelevant aura events and calls ParaxisSirenDebuffDetected
-- whenever a debuff event relevant to the player is detected.
function ParaxisSirenEventDispatcher(self, event, arg1)
if event == "UNIT_AURA" and arg1 == "player" then
ParaxisSirenDebuffDetected(arg1)
end
end
-- Toggles the state of the warningActive global when depending on the state of
-- the Paraxis debuff. This function will also play the sound immediately when
-- toggled for the first time.
function ParaxisSirenDebuffDetected(unitID)
local debuff = UnitDebuff(unitID, PARAXIS_DEBUFF)
if debuff == PARAXIS_DEBUFF then
-- Start the sound ASAP, the timer should trigger for the first time
-- just as the first sound ends.
if not warningActive then
ParaxisSirenDebuffHandler()
end
warningActive = true
else
warningActive = false
end
end
-- Plays an air raid siren sound ideally when the Paraxis is in view.
function ParaxisSirenDebuffHandler()
PlaySoundFile("Interface\\AddOns\\ParaxisSiren\\Media\\Sound\\siren.ogg", "Master")
end