Skip to content
This repository has been archived by the owner on Aug 3, 2023. It is now read-only.

Commit

Permalink
#118 Save logs related to party member before its death
Browse files Browse the repository at this point in the history
  • Loading branch information
onechiporenko committed May 5, 2021
1 parent 02c8c2a commit 99837d1
Show file tree
Hide file tree
Showing 13 changed files with 526 additions and 35 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
### v2.9.0
### v2.10.0

* [#118](https://github.com/onechiporenko/my-dungeons-book/issues/118) Save logs related to party member before its death

### v2.9.0

* Track friendly fire damage separately
* Improve Equip tab (show rings, trinkets and weapon separately)
Expand Down
17 changes: 14 additions & 3 deletions Events.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,27 @@ function MyDungeonsBook:COMBAT_LOG_EVENT_UNFILTERED()
self:TrackSummonnedByPartyMembersUnit(srcName, srcGUID, dstName, dstGUID);
end
if (subEventName == "UNIT_DIED") then
self:TrackDeath(dstGUID, dstName);
self:TrackSummonByPartyMemberUnitDeath(dstGUID, dstName);
self:TrackDeath(timestamp, dstName, dstGUID);
self:TrackSummonByPartyMemberUnitDeath(dstName, dstGUID);
self:TrackEnemyUnitDied(dstName, dstGUID, dstFlags);
self:RemoveAurasFromPartyMember(dstName, dstGUID);
self:SaveDeathLogsForPartyMember(timestamp, dstName);
end
if (subEventName == "UNIT_DESTROYED") then
self:TrackSummonByPartyMemberUnitDeath(dstGUID, dstName);
self:TrackSummonByPartyMemberUnitDeath(dstName, dstGUID);
end
if (subEventSuffix == "HEAL") then
local spellId, _, _, amount, overheal, _, crit = select(12, CombatLogGetCurrentEventInfo());
self:TrackAllHealDoneByPartyMembersToEachOther(srcName, srcGUID, dstName, dstGUID, spellId, amount, overheal);
self:TrackAllHealBySpellDoneByPartyMembers(srcName, srcGUID, srcFlags, dstName, dstGUID, dstFlags, spellId, amount, overheal, crit);
self:TrackCombatEventWithPartyMember(timestamp, dstName, dstGUID);
end
if (subEventName == "DAMAGE_SPLIT" or
subEventName == "DAMAGE_SHIELD") then
local spellId, _, _, amount, overheal = select(12, CombatLogGetCurrentEventInfo());
self:TrackAllHealDoneByPartyMembersToEachOther(srcName, srcGUID, dstName, dstGUID, spellId, amount, overheal);
self:TrackAllHealBySpellDoneByPartyMembers(srcName, srcGUID, srcFlags, dstName, dstGUID, dstFlags, spellId, amount, overheal, false);
self:TrackCombatEventWithPartyMember(timestamp, dstName, dstGUID);
end
if (subEventName == "SPELL_ABSORBED") then
local unitGUID, unitName, unitFlags, _, spellId, _, _, amount = select(12, CombatLogGetCurrentEventInfo());
Expand All @@ -54,6 +57,7 @@ function MyDungeonsBook:COMBAT_LOG_EVENT_UNFILTERED()
end
self:TrackAllHealDoneByPartyMembersToEachOther(unitName, unitGUID, dstName, dstGUID, spellId, amount, -1);
self:TrackAllHealBySpellDoneByPartyMembers(unitName, unitGUID, unitFlags, dstName, dstGUID, dstFlags, spellId, amount, -1, false);
self:TrackCombatEventWithPartyMember(timestamp, dstName, dstGUID);
end
if (subEventSuffix == "INTERRUPT") then
local spellId, _, _, extraSpellId = select(12, CombatLogGetCurrentEventInfo());
Expand All @@ -63,6 +67,7 @@ function MyDungeonsBook:COMBAT_LOG_EVENT_UNFILTERED()
subEventName == "SPELL_STOLEN") then
local spellId, _, _, extraSpellId = select(12, CombatLogGetCurrentEventInfo());
self:TrackDispel(srcName, srcGUID, spellId, extraSpellId, dstFlags2);
self:TrackCombatEventWithPartyMember(timestamp, dstName, dstGUID);
end
if (subEventName == "SPELL_CAST_SUCCESS") then
local spellId = select(12, CombatLogGetCurrentEventInfo());
Expand All @@ -80,12 +85,14 @@ function MyDungeonsBook:COMBAT_LOG_EVENT_UNFILTERED()
self:TrackAllDamageDoneToPartyMembers(srcName, dstName, srcGUID, spellId, amount);
self:TrackAllDamageDoneByPartyMembers(srcName, srcGUID, srcFlags, dstName, dstGUID, dstFlags, spellId, amount, overkill, crit);
self:TrackSLDamageDoneToSpecificUnits(srcName, srcGUID, spellId, amount, overkill, dstName, dstGUID);
self:TrackCombatEventWithPartyMember(timestamp, dstName, dstGUID);
end
if (subEventName == "SWING_DAMAGE") then
local amount, overkill, _, _, _, _, crit = select(12, CombatLogGetCurrentEventInfo());
self:TrackAllDamageDoneToPartyMembers(srcName, dstName, srcGUID, -2, amount);
self:TrackAllDamageDoneByPartyMembers(srcName, srcGUID, srcFlags, dstName, dstGUID, dstFlags, -2, amount, overkill, crit);
self:TrackSLDamageDoneToSpecificUnits(srcName, srcGUID, -2, amount, overkill, dstName, dstGUID);
self:TrackCombatEventWithPartyMember(timestamp, dstName, dstGUID);
end
if (subEventName == "SPELL_EXTRA_ATTACKS") then
local amount = select(12, CombatLogGetCurrentEventInfo());
Expand All @@ -106,6 +113,7 @@ function MyDungeonsBook:COMBAT_LOG_EVENT_UNFILTERED()
self:TrackAllBuffOrDebuffOnUnit(dstName, dstGUID, dstFlags, spellId, auraType, amount or 1);
self:TrackAuraAddedToPartyMember(dstName, dstGUID, spellId, auraType, amount or 1);
self:TrackAuraAddedToEnemyUnit(srcName, srcGUID, srcFlags, dstName, dstGUID, dstFlags, spellId, auraType, amount or 1);
self:TrackCombatEventWithPartyMember(timestamp, dstName, dstGUID);
end
if (subEventName == "SPELL_AURA_REMOVED" or
subEventName == "SPELL_AURA_REMOVED_DOSE" or
Expand All @@ -115,6 +123,7 @@ function MyDungeonsBook:COMBAT_LOG_EVENT_UNFILTERED()
self:TrackAuraRemovedFromPartyMember(dstName, dstGUID, spellId, auraType, amount or 0);
self:TrackAuraRemovedFromEnemyUnit(dstName, dstGUID, spellId, auraType, amount or 0);
self:TrackSLSpecificBuffOrDebuffRemovedFromUnit(dstName, dstGUID, dstFlags, spellId, auraType, amount or 0);
self:TrackCombatEventWithPartyMember(timestamp, dstName, dstGUID);
end
end

Expand All @@ -135,6 +144,7 @@ function MyDungeonsBook:CHALLENGE_MODE_START()
self:RegisterEvent("PLAYER_REGEN_DISABLED");
self:RegisterEvent("PLAYER_REGEN_ENABLED");
self:DebugPrint("CHALLENGE_MODE_START");
wipe(self.allPartyMemberLogs or {});
if (self.partyAliveStatusCheckTimer) then
self:CancelTimer(self.partyAliveStatusCheckTimer);
end
Expand Down Expand Up @@ -293,6 +303,7 @@ function MyDungeonsBook:CHALLENGE_MODE_COMPLETED()
end
self:UnregisterEvent("PLAYER_REGEN_DISABLED");
self:UnregisterEvent("PLAYER_REGEN_ENABLED");
wipe(self.allPartyMemberLogs or {});
end

--[[--
Expand Down
5 changes: 5 additions & 0 deletions Locales/enUS.lua
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@ L["Critical Strike"] = "Critical Strike";
L["Haste"] = "Haste";
L["Mastery"] = "Mastery";
L["Versatility"] = "Versatility";
L["Event"] = "Event";
L["Source"] = "Source";
L["HP"] = "HP";
-- UI end

-- Help start
Expand Down Expand Up @@ -191,6 +194,8 @@ L["Release Time"] = "Release Time";
L["Time dead"] = "Time dead";
L["%s (start)"] = "%s (start)";
L["%s (end)"] = "%s (end)";
L["Death logs"] = "Death logs";
L["Time before death to track"] = "Time before death to track";
-- Settings end

-- Regex start (thanks to Exorsus Raid Tool)
Expand Down
7 changes: 6 additions & 1 deletion Locales/ruRU.lua
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ L["Critical Strike"] = "Критический удар";
L["Haste"] = "Скорость";
L["Mastery"] = "Искусность";
L["Versatility"] = "Универсальность";
L["Event"] = "Событие";
L["Source"] = "Источник";
L["HP"] = "Здоровье";
-- UI end

-- Help start
Expand All @@ -163,7 +166,7 @@ L["send some message via comm to other MDB user. unitId must be 'party1..4'."] =

-- Settings start
L["Performance"] = "Производительность";
L["Run garbage collector on close"] = "Выполнять сборку мусору при закрытии MDB";
L["Run garbage collector on close"] = "Выполнять сборку мусора при закрытии MDB";
L["Show DEV Tab"] = "Выводить DEV-вкладку";
L["Verbose"] = "Verbose";
L["Show DEBUG messages"] = "Выводить DEBUG-сообщения";
Expand Down Expand Up @@ -192,6 +195,8 @@ L["Release Time"] = "Время воскрешения";
L["Time dead"] = "Время мертвым";
L["%s (start)"] = "%s (начало)";
L["%s (end)"] = "%s (конец)";
L["Death logs"] = "Логи смертей";
L["Time before death to track"] = "Сколько записывать времени перед смертью";
-- Settings end

-- Regex start (thanks to Exorsus Raid Tools)
Expand Down
88 changes: 76 additions & 12 deletions Mechanics/Common.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ local L = LibStub("AceLocale-3.0"):GetLocale("MyDungeonsBook");

local petTooltipFrame = CreateFrame("GameTooltip", "MyDungeonsBookPetTooltip", nil, "GameTooltipTemplate");

local allPartyMemberLogs = {};

--[[--
Original idea is taken from Details addon
Expand Down Expand Up @@ -180,38 +182,39 @@ end
--[[--
Track each player's death.
@param[type=GUID] deadUnitGUID 8th result of `CombatLogGetCurrentEventInfo` call
@param[type=number] timestamp 1st result of `CombatLogGetCurrentEventInfo` call
@param[type=string] unit 9th result of `CombatLogGetCurrentEventInfo` call
@param[type=GUID] deadUnitGUID 8th result of `CombatLogGetCurrentEventInfo` call
]]
function MyDungeonsBook:TrackDeath(deadUnitGUID, unit)
function MyDungeonsBook:TrackDeath(timestamp, deadUnitName, deadUnitGUID)
local id = self.db.char.activeChallengeId;
local isPlayer = strfind(deadUnitGUID, "Player"); -- needed GUID is something like "Player-......"
if (not isPlayer) then
if (not UnitIsPlayer(deadUnitName)) then
return;
end
if (UnitIsFeignDeath(unit)) then
self:DebugPrint(string.format("%s is feign death", unit));
if (UnitIsFeignDeath(deadUnitName)) then
self:DebugPrint(string.format("%s is feign death", deadUnitName));
return;
end
local surrenderedSoul = GetSpellInfo(212570);
for i = 1, 40 do
local debuffName = UnitDebuff(unit, i);
local debuffName = UnitDebuff(deadUnitName, i);
if (debuffName == nil) then
break;
end
if (debuffName == surrenderedSoul) then
self:DebugPrint(string.format("%s is on Surrendered Soul debuff", unit));
self:DebugPrint(string.format("%s is on Surrendered Soul debuff", deadUnitName));
return;
end
end
local key = "DEATHS";
self:InitMechanics2Lvl(key, unit);
tinsert(self.db.char.challenges[id].mechanics[key][unit], time());
self:InitMechanics2Lvl(key, deadUnitName);
tinsert(self.db.char.challenges[id].mechanics[key][deadUnitName], {original = timestamp, rounded = floor(timestamp), ["local"] = time()});
self.db.char.challenges[id].challengeInfo.numDeaths = self.db.char.challenges[id].challengeInfo.numDeaths + 1;
if (self.db.global.meta.mechanics[key].verbose) then
self:LogPrint(string.format(L["%s died"], self:ClassColorText(unit, unit)));
self:LogPrint(string.format(L["%s died"], self:ClassColorText(deadUnitName, deadUnitName)));
end
self:RemoveAurasFromPartyMember(unit, deadUnitGUID);
-- Force to update internal death timers
self:PartyAliveStatusCheck();
end

--[[--
Expand Down Expand Up @@ -1332,3 +1335,64 @@ function MyDungeonsBook:AddAurasToPartyMember(sourceUnitName, unitId)
self:TrackAuraAddedToPartyMember(sourceUnitName, UnitGUID(unitId), spellId, "DEBUFF", (amount == 0 and 1) or amount);
end
end

--[[--
Track all combat logs related to party members
@param[type=timestamp] number
@param[type=string] unitName
]]
function MyDungeonsBook:TrackCombatEventWithPartyMember(timestamp, unitName, unitGUID)
if (not UnitIsPlayer(unitName)) then
return;
end
local ts = floor(timestamp);
local id = self.db.char.activeChallengeId;
self.allPartyMemberLogs = self.allPartyMemberLogs or {};
self.allPartyMemberLogs[unitName] = self.allPartyMemberLogs[unitName] or {};
self.allPartyMemberLogs[unitName][ts] = self.allPartyMemberLogs[unitName][ts] or {};
local unitId = self:GetPartyUnitByName(id, unitName);
local meta = {
hp = {
max = UnitHealthMax(unitId),
current = UnitHealth(unitId)
}
};
local log = {CombatLogGetCurrentEventInfo()};
tinsert(log, 1, meta);
tinsert(self.allPartyMemberLogs[unitName][ts], log);
end

--[[--
Save separately combat logs related for party member (last N seconds before death)
@param[type=timestamp] number
@param[type=string] unitName
]]
function MyDungeonsBook:SaveDeathLogsForPartyMember(timestamp, unitName)
if (not UnitIsPlayer(unitName)) then
return;
end
if (UnitIsFeignDeath(unitName)) then
return;
end
local logs = self.allPartyMemberLogs[unitName];
if (not logs) then
return;
end
local ts = floor(timestamp);
local KEY = "PARTY-MEMBER-DEATH-LOGS";
local id = self.db.char.activeChallengeId;
if (not id) then
return;
end
self:InitMechanics3Lvl(KEY, unitName, ts);
for i = ts - self.db.global.meta.mechanics["PARTY-MEMBER-DEATH-LOGS"].timeBeforeDeathToTrack, ts + 1 do
if (logs[i]) then
for _, log in pairs(logs[i]) do
tinsert(self.db.char.challenges[id].mechanics[KEY][unitName][ts], self:CopyTable(log));
end
end
end
wipe(self.allPartyMemberLogs[unitName]);
end
8 changes: 8 additions & 0 deletions Mechanics/SL/Common.lua
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,14 @@ function MyDungeonsBook:GetSLAvoidableSpellsNoTank()
return SLSpellsNoTank;
end

function MyDungeonsBook:GetSLAvoidableAuras()
return SLAuras;
end

function MyDungeonsBook:GetSLAvoidableAurasNoTank()
return SLAurasNoTank;
end

function MyDungeonsBook:TrackSLAvoidableSpells(damagedUnit, spellId, amount)
self:TrackAvoidableSpells("SL-AVOIDABLE-SPELLS", SLSpells, SLSpellsNoTank, damagedUnit, spellId, amount);
end
Expand Down
38 changes: 35 additions & 3 deletions Options.lua
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,10 @@ MyDungeonsBook.OptionsDefaults = {
},
["SL-DAMAGE-DONE-TO-UNITS"] = {
id = "SL-DAMAGE-DONE-TO-UNITS"
},
["PARTY-MEMBER-DEATH-LOGS"] = {
id = "PARTY-MEMBER-DEATH-LOGS",
timeBeforeDeathToTrack = 15
}
},
}
Expand Down Expand Up @@ -288,7 +292,7 @@ MyDungeonsBook.Options = {
}
},
verbose = {
order = 1,
order = 2,
name = L["Verbose"],
type = "group",
args = {
Expand Down Expand Up @@ -421,7 +425,7 @@ MyDungeonsBook.Options = {
}
},
performance = {
order = 2,
order = 3,
name = L["Performance"],
type = "group",
args = {
Expand Down Expand Up @@ -457,7 +461,7 @@ MyDungeonsBook.Options = {
type = "group",
args = {
mechanics = {
name = "Mechanics",
name = L["Mechanics"],
inline = true,
type = "group",
args = {
Expand All @@ -481,6 +485,34 @@ MyDungeonsBook.Options = {
}
}
}
},
mechanics = {
order = 5,
name = L["Mechanics"],
type = "group",
args = {
deathlogs = {
name = L["Death logs"],
type = "group",
args = {
timeBeforeDeathToTrack = {
order = 1,
name = L["Time before death to track"],
type = "range",
width = "full",
min = 5,
max = 15,
step = 1,
get = function()
return MyDungeonsBook.db.global.meta.mechanics["PARTY-MEMBER-DEATH-LOGS"].timeBeforeDeathToTrack;
end,
set = function(_, v)
MyDungeonsBook.db.global.meta.mechanics["PARTY-MEMBER-DEATH-LOGS"].timeBeforeDeathToTrack = v;
end
}
}
}
}
}
}
};
2 changes: 1 addition & 1 deletion UI/ChallengeDetails/Tabs/Encounters.lua
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function getSuccessFailIcon(success)
icon = "interface\\raidframe\\readycheck-notready.blp";
end
local suffix = MyDungeonsBook:GetIconTextureSuffix(16);
return "|T" .. (icon or "") .. suffix .. "|t"
return "|T" .. (icon or "") .. suffix .. "|t";
end

--[[--
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ function MyDungeonsBook:DamageDoneToPartyMembersFrame_Report_Create(row, cols)
spellLinkOrName = GetSpellLink(row.cols[1].value);
else
local npcId = math.abs(spellId);
local cellText = L["Swing Damage"];
local cellText = (spellId == -3 and L["Avoidable"]) or L["Swing Damage"];
local unitName = (self.db.global.meta.npcs[npcId] and self.db.global.meta.npcs[npcId].name) or npcId;
spellLinkOrName = string.format("%s (%s)", cellText, unitName);
end
Expand Down
Loading

0 comments on commit 99837d1

Please sign in to comment.