Rework death reporter a lil
This commit is contained in:
@@ -133,61 +133,23 @@ function shared.DeathReporter.Init()
|
||||
local systemMessageFrame = CreateFrame("Frame")
|
||||
systemMessageFrame:RegisterEvent("CHAT_MSG_SYSTEM")
|
||||
systemMessageFrame:SetScript("OnEvent", function(self, event, msg)
|
||||
if not Heimdall_Data.config.deathReporter.enabled then return end
|
||||
local source, destination = string.match(msg, "([^ ]+) has defeated ([^ ]+) in a duel")
|
||||
if Heimdall_Data.config.deathReporter.debug then
|
||||
print(string.format("[%s] Received system message: %s", ModuleName, msg))
|
||||
print(string.format("[%s] Source: %s, Destination: %s", ModuleName, source, destination))
|
||||
end
|
||||
|
||||
if not Heimdall_Data.config.deathReporter.enabled then
|
||||
if not source or not destination then return end
|
||||
source = string.match(source, "([^-]+)")
|
||||
destination = string.match(destination, "([^-]+)")
|
||||
if source and destination then
|
||||
if Heimdall_Data.config.deathReporter.debug then
|
||||
print(string.format("[%s] Module disabled, ignoring event", ModuleName))
|
||||
print(string.format("[%s] Detected duel between %s and %s", ModuleName, source, destination))
|
||||
end
|
||||
return
|
||||
local now = GetTime()
|
||||
recentDuels[source] = now
|
||||
recentDuels[destination] = now
|
||||
end
|
||||
|
||||
if event == "DUEL_REQUESTED" then
|
||||
local opponent = ...
|
||||
if Heimdall_Data.config.deathReporter.debug then
|
||||
print(string.format("[%s] Duel requested with: %s", ModuleName, opponent))
|
||||
end
|
||||
recentDuels[opponent] = GetTime()
|
||||
recentDuels[UnitName("player")] = GetTime()
|
||||
return
|
||||
end
|
||||
|
||||
if event == "DUEL_FINISHED" or event == "DUEL_CANCELLED" then
|
||||
if Heimdall_Data.config.deathReporter.debug then
|
||||
print(string.format("[%s] Duel ended: %s", ModuleName, event))
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
local subevent = select(2, ...)
|
||||
if subevent ~= "PARTY_KILL" and subevent ~= "UNIT_DIED" then return end
|
||||
|
||||
local source, err = CLEUParser.GetSourceName(...)
|
||||
if err then
|
||||
if Heimdall_Data.config.deathReporter.debug then
|
||||
print(string.format("[%s] Error getting source: %s", ModuleName, err))
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
local destination, err = CLEUParser.GetDestName(...)
|
||||
if err then
|
||||
if Heimdall_Data.config.deathReporter.debug then
|
||||
print(string.format("[%s] Error getting destination: %s", ModuleName, err))
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
if Heimdall_Data.config.deathReporter.debug then
|
||||
print(string.format("[%s] Death event detected - Source: %s, Target: %s", ModuleName, source, destination))
|
||||
end
|
||||
|
||||
local spellId = CLEUParser.GetSpellId(...)
|
||||
local spellName = GetSpellInfo(spellId) or "Unknown Spell"
|
||||
|
||||
RegisterDeath(source, destination, spellName)
|
||||
end)
|
||||
|
||||
if Heimdall_Data.config.deathReporter.debug then
|
||||
|
||||
Reference in New Issue
Block a user