From c2db54566dc211103bbc476b7c8461901f0a31e6 Mon Sep 17 00:00:00 2001 From: onechiporenko Date: Tue, 10 Nov 2020 18:32:05 +0200 Subject: [PATCH] #77 Don't track heal done to enemy units --- CHANGELOG.md | 1 + Events.lua | 8 ++++---- Mechanics/Common.lua | 10 +++++++++- UI/ChallengeDetails/Tabs/DEV.lua | 3 ++- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a5bbe25..54c18de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ### v1.6.0 +* [#77](https://github.com/onechiporenko/my-dungeons-book/issues/77) Don't track heal done to enemy units * [#76](https://github.com/onechiporenko/my-dungeons-book/issues/76) Shield/offhand item sometimes is shifted to the second row * [#74](https://github.com/onechiporenko/my-dungeons-book/issues/74) Reset viewed challenge info when MDB is closed * [#73](https://github.com/onechiporenko/my-dungeons-book/issues/73) Show heal done by each spell diff --git a/Events.lua b/Events.lua index c96cb10..6df972f 100644 --- a/Events.lua +++ b/Events.lua @@ -36,18 +36,18 @@ function MyDungeonsBook:COMBAT_LOG_EVENT_UNFILTERED() 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, spellId, amount, overheal, crit); + self:TrackAllHealBySpellDoneByPartyMembers(srcName, srcGUID, srcFlags, dstName, dstGUID, dstFlags, spellId, amount, overheal, crit); 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, spellId, amount, overheal, false); + self:TrackAllHealBySpellDoneByPartyMembers(srcName, srcGUID, srcFlags, dstName, dstGUID, dstFlags, spellId, amount, overheal, false); end if (subEventName == "SPELL_ABSORBED") then - local unitGUID, unitName, _, _, spellId, _, _, amount = select(12, CombatLogGetCurrentEventInfo()); + local unitGUID, unitName, unitFlags, _, spellId, _, _, amount = select(12, CombatLogGetCurrentEventInfo()); self:TrackAllHealDoneByPartyMembersToEachOther(unitName, unitGUID, dstName, dstGUID, spellId, amount, -1); - self:TrackAllHealBySpellDoneByPartyMembers(srcName, srcGUID, spellId, amount, -1, false); + self:TrackAllHealBySpellDoneByPartyMembers(unitName, unitGUID, unitFlags, dstName, dstGUID, dstFlags, spellId, amount, -1, false); end if (subEventSuffix == "INTERRUPT") then local spellId, _, _, extraSpellId = select(12, CombatLogGetCurrentEventInfo()); diff --git a/Mechanics/Common.lua b/Mechanics/Common.lua index 11742d1..b1dd5a6 100644 --- a/Mechanics/Common.lua +++ b/Mechanics/Common.lua @@ -391,17 +391,25 @@ Track all heal done by party members (including pets and other summonned units) @param[type=string] sourceUnitName @param[type=GUID] sourceUnitGUID +@param[type=number] sourceUnitFlags +@param[type=string] targetUnitName +@param[type=GUID] targetUnitGUID +@param[type=number] targetUnitFlags @param[type=number] spellId @param[type=number] amount @param[type=number] overheal @param[type=bool] crit ]] -function MyDungeonsBook:TrackAllHealBySpellDoneByPartyMembers(sourceUnitName, sourceUnitGUID, spellId, amount, overheal, crit) +function MyDungeonsBook:TrackAllHealBySpellDoneByPartyMembers(sourceUnitName, sourceUnitGUID, sourceUnitFlags, targetUnitName, targetUnitGUID, targetUnitFlags, spellId, amount, overheal, crit) local id = self.db.char.activeChallengeId; local type = strsplit("-", sourceUnitGUID); self:InitMechanics1Lvl("PARTY-MEMBERS-SUMMON"); local summonedUnitOwner = self.db.char.challenges[id].mechanics["PARTY-MEMBERS-SUMMON"][sourceUnitGUID]; local sourceUnitNameToUse = sourceUnitName; + local targetIsEnemy = bit.band(targetUnitFlags, COMBATLOG_OBJECT_REACTION_HOSTILE) ~= 0; + if (targetIsEnemy) then + return; + end if ((not summonedUnitOwner) and (type ~= "Pet") and (type ~= "Player")) then return; end diff --git a/UI/ChallengeDetails/Tabs/DEV.lua b/UI/ChallengeDetails/Tabs/DEV.lua index 852997d..6cb25bf 100644 --- a/UI/ChallengeDetails/Tabs/DEV.lua +++ b/UI/ChallengeDetails/Tabs/DEV.lua @@ -24,7 +24,8 @@ function MyDungeonsBook:DevFrame_Create(parentFrame, challengeId) editBox.button:SetText("Get JSON"); editBox.button:Show(); editBox:SetCallback("OnEnterPressed", function () - editBox:SetText(self:Table2Json(select(2, self:Decompress(challenge.mechanics)))); + local isTable = type(challenge.mechanics) == "table"; + editBox:SetText(self:Table2Json((isTable and challenge.mechanics) or select(2, self:Decompress(challenge.mechanics)))); editBox:HighlightText(); end); devFrame:AddChild(editBox);