forked from Zidras/DBM-Warmane
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMCTrash.lua
79 lines (67 loc) · 2.57 KB
/
MCTrash.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
local mod = DBM:NewMod("MCTrash", "DBM-MC", 1)
local L = mod:GetLocalizedStrings()
mod:SetRevision("20220518110528")
--mod:SetModelID(47785)
mod.isTrashMod = true
mod:AddSpeedClearOption("MC", true)
--Speed Clear variables
mod.vb.firstEngageTime = nil
--Register all damage events on mod load
mod:RegisterShortTermEvents(
"SPELL_DAMAGE",
"SPELL_MISSED",
"SWING_DAMAGE",
"SWING_MISSED",
"SPELL_PERIODIC_DAMAGE",
"SPELL_PERIODIC_MISSED"
)
--Request speed clear variables, in case it was already started before mod loaded
mod:SendSync("IsMCStarted")
do
local startCreatureIds = {
[11658] = true--Molten Giant
}
local function checkFirstPull(self, GUID)
local cid = self:GetCIDFromGUID(GUID)
if startCreatureIds[cid] then
if not self.vb.firstEngageTime then
self.vb.firstEngageTime = time()
if self.Options.FastestClear2 and self.Options.SpeedClearTimer then
--Custom bar creation that's bound to core, not mod, so timer doesn't stop when mod stops it's own timers
DBT:CreateBar(self.Options.FastestClear2, DBM_CORE_L.SPEED_CLEAR_TIMER_TEXT, "Interface\\Icons\\Spell_Nature_TimeStop")
end
self:SendSync("MCStarted", self.vb.firstEngageTime)--Also sync engage time
end
--Unregister high CPU combat log events
self:UnregisterShortTermEvents()
end
end
function mod:SPELL_DAMAGE(_, _, _, destGUID)
checkFirstPull(self, destGUID or 0)
end
mod.SPELL_MISSED = mod.SPELL_DAMAGE
function mod:SPELL_PERIODIC_DAMAGE(_, _, _, destGUID)
checkFirstPull(self, destGUID or 0)
end
mod.SPELL_PERIODIC_MISSED = mod.SPELL_PERIODIC_DAMAGE
function mod:SWING_DAMAGE(_, _, _, destGUID)
checkFirstPull(self, destGUID or 0)
end
mod.SWING_MISSED = mod.SWING_DAMAGE
function mod:OnSync(msg, startTime)
--Sync recieved with start time and ours is currently not started
if msg == "MCStarted" and startTime and not self.vb.firstEngageTime then
self.vb.firstEngageTime = tonumber(startTime)
if self.Options.FastestClear2 and self.Options.SpeedClearTimer then
--Custom bar creation that's bound to core, not mod, so timer doesn't stop when mod stops it's own timers
local adjustment = time() - self.vb.firstEngageTime
DBT:CreateBar(self.Options.FastestClear2 - adjustment, DBM_CORE_L.SPEED_CLEAR_TIMER_TEXT)
end
--Unregister high CPU combat log events
self:UnregisterShortTermEvents()
elseif msg == "IsMCStarted" and self.vb.firstEngageTime then
--Sadly this has to be done with two syncs, one for variables for bosses that have been killed and one to instruct starting of timer
self:SendSync("MCStarted", self.vb.firstEngageTime)
end
end
end