-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathevl_CombatText.lua
More file actions
162 lines (131 loc) · 4.38 KB
/
evl_CombatText.lua
File metadata and controls
162 lines (131 loc) · 4.38 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
local addonName, addon = ...
local spreeSounds = {
[3] = "Killing_Spree",
[4] = "Dominating",
[5] = "Mega_Kill",
[6] = "Unstoppable",
[7] = "Wicked_Sick",
[8] = "Monster_Kill",
[9] = "Ludicrous_Kill",
[10] = "God_Like",
[11] = "Holy_Shit"
}
local multiSounds = {
[2] = "Double_Kill",
[3] = "Triple_Kill",
}
local path = "Interface\\AddOns\\" .. addonName .. "\\sounds\\%s.mp3"
local multiKillDecayTime = 11.5
local killingStreak = 0
local multiKill = 0
local lastKillTime = 0
local executeThreshold
local executeMessage
local previousHealth
local pendingSound
local bit_band = bit.band
local bit_bor = bit.bor
local hasFlag = function(flags, flag)
return bit_band(flags, flag) == flag
end
local onEvent = function(self, event, ...)
addon[event](self, event, ...)
end
local lastUpdate = 0
local onUpdate = function(self, elapsed)
lastUpdate = lastUpdate + elapsed
if lastUpdate > 2 then
lastUpdate = 0
if pendingSound then
PlaySoundFile(pendingSound)
pendingSound = nil
end
end
end
local playSounds = function()
local multiFileName = multiSounds[math.min(3, multiKill)]
local spreeFileName = spreeSounds[math.min(11, killingStreak)]
if multiFileName then
PlaySoundFile(string.format(path, multiFileName))
end
if spreeFileName then
local spreeFilePath = string.format(path, spreeFileName)
if not multiFileName then
PlaySoundFile(spreeFilePath)
else
pendingSound = spreeFilePath
end
end
end
function addon:ADDON_LOADED(event, addonName)
-- Override default Blizzard colors if present
if addonName == "Blizzard_CombatText" then
-- We could set the table but we just want to change color and Blizzard frequently changes this format
COMBAT_TEXT_TYPE_INFO["ENTERING_COMBAT"].r = 0.1
COMBAT_TEXT_TYPE_INFO["ENTERING_COMBAT"].g = 0.1
COMBAT_TEXT_TYPE_INFO["ENTERING_COMBAT"].b = 1
COMBAT_TEXT_TYPE_INFO["LEAVING_COMBAT"].r = 0.1
COMBAT_TEXT_TYPE_INFO["LEAVING_COMBAT"].g = 0.1
COMBAT_TEXT_TYPE_INFO["LEAVING_COMBAT"].b = 1
COMBAT_TEXT_TYPE_INFO["COMBO_POINTS"].r = 0.7
COMBAT_TEXT_TYPE_INFO["COMBO_POINTS"].g = 0.7
COMBAT_TEXT_TYPE_INFO["COMBO_POINTS"].b = 1
-- Override default Blizzard strings
ENTERING_COMBAT = "Fight!"
LEAVING_COMBAT = "Ninja Time!"
HEALTH_LOW = "Low Health"
self:UnregisterEvent("ADDON_LOADED")
end
end
function addon:PLAYER_TARGET_CHANGED()
previousHealth = 0
end
function addon:PLAYER_DEAD()
killingStreak = 0
end
function addon:COMBAT_LOG_EVENT_UNFILTERED(event, timestamp, eventType, sourceGUID, sourceName, sourceFlags, destGUID, destName, destFlags, ...)
-- Killing blows
if eventType == "PARTY_KILL" and hasFlag(sourceFlags, COMBATLOG_OBJECT_AFFILIATION_MINE) and hasFlag(destFlags, COMBATLOG_OBJECT_TYPE_PLAYER) then
if COMBAT_TEXT_TYPE_INFO then
CombatText_AddMessage("Killing Blow! (" .. destName .. ")", COMBAT_TEXT_SCROLL_FUNCTION, .7, .7, 1, nil, nil)
end
local now = GetTime()
if lastKillTime + multiKillDecayTime > now then
multiKill = multiKill + 1
else
multiKill = 1
end
lastKillTime = now
killingStreak = killingStreak + 1
playSounds()
-- Interrupts
elseif eventType == "SPELL_INTERRUPT" and hasFlag(sourceFlags, COMBATLOG_OBJECT_AFFILIATION_MINE) then
local spellID, spellName, spellSchool, extraSpellID, extraSpellName, extraSpellSchool = ...
CombatText_AddMessage(format("%s Interrupted!", extraSpellName), COMBAT_TEXT_SCROLL_FUNCTION, .1, .1, 1, nil, nil)
end
end
function addon:UNIT_HEALTH(event, unit)
if executeThreshold and unit == "target" and UnitCanAttack("player", unit) then
local value, max = UnitHealth(unit), UnitHealthMax(unit)
local threshold = max * executeThreshold
if (previousHealth == 0 or previousHealth > threshold) and value < threshold then
CombatText_AddMessage("Execute!", COMBAT_TEXT_SCROLL_FUNCTION, 1, .1, .1, nil, nil)
end
previousHealth = value
end
end
local frame = CreateFrame("Frame")
frame:SetScript("OnEvent", onEvent)
frame:SetScript("OnUpdate", onUpdate)
frame:RegisterEvent("ADDON_LOADED")
frame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
frame:RegisterEvent("PLAYER_DEAD")
frame:RegisterEvent("PLAYER_TARGET_CHANGED")
-- Execute range notification, currently only implemented for rogues
local playerClass = select(2, UnitClass("player"))
-- Assassination's Murderous Intent
if playerClass == "ROGUE" and GetPrimaryTalentTree() == 1 then
executeThreshold = 0.35
executeMessage = "Execute!"
frame:RegisterEvent("UNIT_HEALTH")
end