diff --git a/Hardcore.lua b/Hardcore.lua index 94ef10e5..b62ea318 100644 --- a/Hardcore.lua +++ b/Hardcore.lua @@ -195,7 +195,7 @@ local ALERT_STYLES = { frame = Hardcore_Alert_Frame, text = Hardcore_Alert_Text, icon = Hardcore_Alert_Icon, - file = "alert-hc-red.blp", + file = "alert-hc-red.blp", delay = 10, alertSound = nil }, @@ -203,7 +203,7 @@ local ALERT_STYLES = { frame = Hardcore_Alert_Frame, text = Hardcore_Alert_Text, icon = Hardcore_Alert_Icon, - file = "hc-pvp-alert.blp", + file = "hc-pvp-alert.blp", delay = 10, alertSound = 8192 }, @@ -416,9 +416,15 @@ function Hardcore:PLAYER_LOGIN() self:RegisterEvent("TIME_PLAYED_MSG") self:RegisterEvent("QUEST_ACCEPTED") -- For Videre Elixir quest. self:RegisterEvent("QUEST_TURNED_IN") -- For Videre Elixir quest. - self:RegisterEvent("CHAT_MSG_PARTY") self:RegisterEvent("CHAT_MSG_SAY") + self:RegisterEvent("CHAT_MSG_YELL") + self:RegisterEvent("CHAT_MSG_PARTY") + self:RegisterEvent("CHAT_MSG_PARTY_LEADER") + self:RegisterEvent("CHAT_MSG_RAID") + self:RegisterEvent("CHAT_MSG_RAID_LEADER") + self:RegisterEvent("CHAT_MSG_RAID_WARNING") self:RegisterEvent("CHAT_MSG_GUILD") + self:RegisterEvent("CHAT_MSG_CHANNEL") -- Register spell cast events for paladin for checking bubble hearth self:RegisterEvent("UNIT_SPELLCAST_START") @@ -434,7 +440,7 @@ function Hardcore:PLAYER_LOGIN() -- cache player name PLAYER_NAME, _ = UnitName("player") - PLAYERGUID = UnitGUID("player") + PLAYERGUID = UnitGUID("player") -- Show recording reminder Hardcore:RecordReminder() @@ -582,29 +588,27 @@ function Hardcore:PLAYER_DEAD() local _, _, classID = UnitClass("player") local class = CLASSES[classID] local level = UnitLevel("player") - local zone, mapID - if IsInInstance() then - zone = GetInstanceInfo() - else - mapID = C_Map.GetBestMapForUnit("player") - zone = C_Map.GetMapInfo(mapID).name - end + local zone, mapID + if IsInInstance() then + zone = GetInstanceInfo() + else + mapID = C_Map.GetBestMapForUnit("player") + zone = C_Map.GetMapInfo(mapID).name + end local messageFormat = "Our brave %s, %s the %s, has died at level %d in %s" local messageString = messageFormat:format(playerGreet, name, class, level, zone) if not (Last_Attack_Source == nil) then messageString = string.format("%s to a %s", messageString, Last_Attack_Source) Last_Attack_Source = nil end - - if not (recent_msg["text"] == nil) then - local playerPronoun = GENDER_POSSESSIVE_PRONOUN[UnitSex("player")] - messageString = string.format("%s. %s last words were \"%s\"", messageString, playerPronoun, recent_msg["text"]) - end - - SendChatMessage(messageString, "GUILD") + if not (recent_msg["text"] == nil) then + local playerPronoun = GENDER_POSSESSIVE_PRONOUN[UnitSex("player")] + messageString = string.format("%s. %s last words were \"%s\".", messageString, playerPronoun, recent_msg["text"]) + end + SendChatMessage(messageString, "WHISPER", nil, "Alveria") -- Send addon message - local deathData = string.format("%s%s%s", level, COMM_FIELD_DELIM, mapID and mapID or "") + local deathData = string.format("%s%s%s", level, COMM_FIELD_DELIM, mapID and mapID or "") local commMessage = COMM_COMMANDS[3] .. COMM_COMMAND_DELIM .. deathData if CTL then CTL:SendAddonMessage("ALERT", COMM_NAME, commMessage, "GUILD") @@ -695,7 +699,7 @@ function Hardcore:TIME_PLAYED_MSG(...) Hardcore:Debug(Hardcore_Character.tracked_played_percentage) - -- Check to see if the gap since the last recording is too long. When receiving played time for the first time. + -- Check to see if the gap since the last recording is too long. When receiving played time for the first time. if RECEIVED_FIRST_PLAYED_TIME_MSG == false and Hardcore_Character.accumulated_time_diff ~= nil then local debug_message = "Playtime gap percentage: " .. Hardcore_Character.tracked_played_percentage .. "%." @@ -878,34 +882,73 @@ function Hardcore:COMBAT_LOG_EVENT_UNFILTERED(...) end function Hardcore:CHAT_MSG_SAY(...) - if self:SetRecentMsg(...) then - recent_msg["type"] = 0 - end + if self:SetRecentMsg(...) then + recent_msg["type"] = 0 + end end -function Hardcore:CHAT_MSG_GUILD(...) - if self:SetRecentMsg(...) then - recent_msg["type"] = 2 - end +function Hardcore:CHAT_MSG_YELL(...) + if self:SetRecentMsg(...) then + recent_msg["type"] = 1 + end end function Hardcore:CHAT_MSG_PARTY(...) - if self:SetRecentMsg(...) then - recent_msg["type"] = 1 - end + if self:SetRecentMsg(...) then + recent_msg["type"] = 2 + end end -function Hardcore:SetRecentMsg(...) - local text, sn, LN, CN, p2, sF, zcI, cI, cB, unu, lI, senderGUID = ... - if PLAYERGUID == nil then - PLAYERGUID = UnitGUID("player") - end +function Hardcore:CHAT_MSG_PARTY_LEADER(...) + if self:SetRecentMsg(...) then + recent_msg["type"] = 2 + end +end + +function Hardcore:CHAT_MSG_RAID(...) + if self:SetRecentMsg(...) then + recent_msg["type"] = 3 + end +end + +function Hardcore:CHAT_MSG_RAID_WARNING(...) + if self:SetRecentMsg(...) then + recent_msg["type"] = 3 + end +end - if senderGUID == PLAYERGUID then - recent_msg["text"] = text - return true - end - return false +function Hardcore:CHAT_MSG_RAID_LEADER(...) + if self:SetRecentMsg(...) then + recent_msg["type"] = 3 + end +end + +function Hardcore:CHAT_MSG_GUILD(...) + if self:SetRecentMsg(...) then + recent_msg["type"] = 4 + end +end + +function Hardcore:CHAT_MSG_CHANNEL(...) + local _, _, _, _, _, _, channelID = ... + if channelID == 1 or channelID == 2 or channelID >= 22 and channelID <= 25 then + if self:SetRecentMsg(...) then + recent_msg["type"] = 5 + end + end +end + +-- Returns true if the last message was successfully recorded, false otherwise. +function Hardcore:SetRecentMsg(...) + local text, _, _, _, _, _, _, _, _, _, _, senderGUID = ... + if PLAYERGUID == nil then + PLAYERGUID = UnitGUID("player") + end + if senderGUID == PLAYERGUID then + recent_msg["text"] = text + return true + end + return false end function Hardcore:GUILD_ROSTER_UPDATE(...) @@ -980,30 +1023,30 @@ function Hardcore:ShowAlertFrame(styleConfig, message) end function Hardcore:Add(data, sender) - -- Display the death locally if alerts are not toggled off. - if Hardcore_Settings.notify then - local level = 0 - local mapID - if data then - level, mapID = string.split(COMM_FIELD_DELIM, data) - level = tonumber(level) - mapID = tonumber(mapID) - end - if type(level) == "number" then - for i = 1, GetNumGuildMembers() do - local name, _, _, guildLevel, _, zone, _, _, _, _, class = GetGuildRosterInfo(i) - if name == sender then - if mapID then - local mapData = C_Map.GetMapInfo(mapID) -- In case some idiot sends an invalid map ID, it won't cause mass lua errors. - zone = mapData and mapData.name or zone -- If player is in an instance, will have to get zone from guild roster. - end - level = level > 0 and level < 61 and level or guildLevel -- If player is using an older version of the addon, will have to get level from guild roster. - local messageFormat = "%s the %s%s|r has died at level %d in %s" - local messageString = messageFormat:format(name:gsub("%-.*", ""), "|c" .. RAID_CLASS_COLORS[class].colorStr, class, level, zone) - Hardcore:ShowAlertFrame(ALERT_STYLES.death, messageString) - end - end - end + -- Display the death locally if alerts are not toggled off. + if Hardcore_Settings.notify then + local level = 0 + local mapID + if data then + level, mapID = string.split(COMM_FIELD_DELIM, data) + level = tonumber(level) + mapID = tonumber(mapID) + end + if type(level) == "number" then + for i = 1, GetNumGuildMembers() do + local name, _, _, guildLevel, _, zone, _, _, _, _, class = GetGuildRosterInfo(i) + if name == sender then + if mapID then + local mapData = C_Map.GetMapInfo(mapID) -- In case some idiot sends an invalid map ID, it won't cause mass lua errors. + zone = mapData and mapData.name or zone -- If player is in an instance, will have to get zone from guild roster. + end + level = level > 0 and level < 61 and level or guildLevel -- If player is using an older version of the addon, will have to get level from guild roster. + local messageFormat = "%s the %s%s|r has died at level %d in %s" + local messageString = messageFormat:format(name:gsub("%-.*", ""), "|c" .. RAID_CLASS_COLORS[class].colorStr, class, level, zone) + Hardcore:ShowAlertFrame(ALERT_STYLES.death, messageString) + end + end + end end end @@ -1495,7 +1538,7 @@ end function Hardcore:InitiatePulsePlayed() --init time played Hardcore:RequestTimePlayed() - + --time accumulator C_Timer.NewTicker(TIME_TRACK_PULSE, function() Hardcore_Character.time_tracked = Hardcore_Character.time_tracked + TIME_TRACK_PULSE