From 3dfc1229467a0318818ec21acf656873a2a042cf Mon Sep 17 00:00:00 2001 From: andrew6180 <16847730+andrew6180@users.noreply.github.com> Date: Mon, 9 Dec 2024 12:08:52 -0700 Subject: [PATCH] change implementation of extra attacks to 'details' way --- boot.lua | 2 ++ core/control.lua | 2 +- core/parser.lua | 28 +++++++++++++++++----------- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/boot.lua b/boot.lua index c31fdbe8..19e14806 100644 --- a/boot.lua +++ b/boot.lua @@ -377,6 +377,8 @@ do _detalhes.cache_damage_group = {} _detalhes.cache_healing_group = {} _detalhes.cache_npc_ids = {} + -- extra attack cache + _detalhes.cache_extra_attack = {} --cache de specs _detalhes.cached_specs = {} _detalhes.cached_talents = {} diff --git a/core/control.lua b/core/control.lua index 9df1b1e4..8507528b 100644 --- a/core/control.lua +++ b/core/control.lua @@ -316,7 +316,6 @@ -- ~start function Details222.StartCombat(...) - Details.extra_attack = {} -- Reset Extra Attacks tracker ( used in parser.lua 470) if (Details.debug) then Details:Msg("(debug) |cFFFFFF00started a new combat|r|cFFFF7700", Details.encounter_table and Details.encounter_table.name or "") --local from = debugstack(2, 1, 0) @@ -378,6 +377,7 @@ Details:Destroy(Details.cache_damage_group) Details:Destroy(Details.cache_healing_group) + Details:Destroy(Details.cache_extra_attack) local bFromCombatStart = true Details:UpdateParserGears(bFromCombatStart) diff --git a/core/parser.lua b/core/parser.lua index 9aaa61ad..0e3de261 100755 --- a/core/parser.lua +++ b/core/parser.lua @@ -354,8 +354,6 @@ local spell_create_is_summon = { [34600] = true, -- snake trap } - - Details.extra_attack = Details.extra_attack or {} ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --internal functions @@ -468,19 +466,27 @@ if (token == "SWING_DAMAGE") then -- spellType or 00000001 because pets can have different melee damage types. spellId, spellName, spellType, amount, overkill, school, resisted, blocked, absorbed, critical, glacing, crushing, isoffhand = 1, meleeString, spellType or 00000001, spellId, spellName, spellType, amount, overkill, school, resisted, blocked, absorbed, critical - if Details.combat_log.separate_extra_attacks and Details.extra_attack[sourceSerial] and #(Details.extra_attack[sourceSerial])>0 then - local extraAttackData = Details.extra_attack[sourceSerial][#Details.extra_attack[sourceSerial]] - spellId = extraAttackData[1] - spellName = extraAttackData[2] - extraAttackData[3] = extraAttackData[3] -1 -- Amount of Extra attacks e.x Ironfoe gives 2 attacks - if extraAttackData[3] == 0 then - table.remove(Details.extra_attack[sourceSerial]) -- remove table entry if no extra attacks remain on the proc + if Details.combat_log.separate_extra_attacks then + local extraAttacks = Details.cache_extra_attack[sourceSerial] + local numExtraAttacks = extraAttacks and #extraAttacks + if extraAttacks and numExtraAttacks > 0 then + local extraAttackData = extraAttacks[numExtraAttacks] + spellId = extraAttackData[1] + spellName = extraAttackData[2] + extraAttackData[3] = extraAttackData[3] - 1 -- Amount of Extra attacks e.x Ironfoe gives 2 attacks + if extraAttackData[3] == 0 then + table.remove(extraAttacks) -- remove table entry if no extra attacks remain on the proc + end end end end if (Details.combat_log.separate_extra_attacks and token == "SPELL_EXTRA_ATTACKS") then - if not Details.extra_attack[sourceSerial] then Details.extra_attack[sourceSerial] = {} end - table.insert(Details.extra_attack[sourceSerial],{spellId,spellName,amount}) + local extraAttacks = Details.cache_extra_attack[sourceSerial] + if not extraAttacks then + extraAttacks = {} + Details.cache_extra_attack[sourceSerial] = extraAttacks + end + table.insert(extraAttacks,{ spellId, spellName, amount}) end if (not targetName) then