From 5e5fd97e5553c0014a6f2efac5fdcde7d55ae40c Mon Sep 17 00:00:00 2001 From: Tercioo Date: Wed, 1 May 2019 14:54:56 -0300 Subject: [PATCH] Added API: SegmentInfo(), SegmentTotalDamage(), SegmentTotalHealing(), see '/details api' for more information --- classes/classe_energy.lua | 2 - core/control.lua | 41 +++++++++++++ core/parser.lua | 6 +- core/util.lua | 13 ++++ functions/api2.lua | 121 +++++++++++++++++++++++++++++++++++++- functions/profiles.lua | 6 +- 6 files changed, 182 insertions(+), 7 deletions(-) diff --git a/classes/classe_energy.lua b/classes/classe_energy.lua index b0230af73..52bfbf355 100644 --- a/classes/classe_energy.lua +++ b/classes/classe_energy.lua @@ -796,9 +796,7 @@ function atributo_energy:ToolTip (instancia, numero, barra, keydown) elseif (instancia.sub_atributo == 5) then --resources local resource_string = _detalhes.resource_strings [self.resource_type] - if (resource_string) then - local icon = _detalhes.resource_icons [self.resource_type] GameCooltip:AddLine (resource_string, _cstr ("%.2f", self.resource / instancia.showing:GetCombatTime()) .. " per minute", 1, "white") diff --git a/core/control.lua b/core/control.lua index 9c0573ab2..d27724dd6 100644 --- a/core/control.lua +++ b/core/control.lua @@ -757,6 +757,47 @@ --8.0.1 miss data isn't required at the moment, spells like akari's soul has been removed from the game --_detalhes:CanSendMissData() + if (_detalhes.tabela_vigente.is_boss) then + if (IsInRaid()) then + local cleuID = _detalhes.tabela_vigente.is_boss.id + local diff = _detalhes.tabela_vigente.is_boss.diff + if (cleuID and diff == 16) then -- 16 mythic + local raidData = _detalhes.raid_data + + --get or build mythic raid data table + local mythicRaidData = raidData.mythic_raid_data + if (not mythicRaidData) then + mythicRaidData = {} + raidData.mythic_raid_data = mythicRaidData + end + + --get or build a table for this cleuID + mythicRaidData [cleuID] = mythicRaidData [cleuID] or {wipes = 0, kills = 0, best_try = 1, longest = 0, try_history = {}} + local cleuIDData = mythicRaidData [cleuID] + + --store encounter data for plugins and weakauras + if (_detalhes.tabela_vigente:GetCombatTime() > cleuIDData.longest) then + cleuIDData.longest = _detalhes.tabela_vigente:GetCombatTime() + end + + if (_detalhes.tabela_vigente.is_boss.killed) then + cleuIDData.kills = cleuIDData.kills + 1 + cleuIDData.best_try = 0 + tinsert (cleuIDData.try_history, {0, _detalhes.tabela_vigente:GetCombatTime()}) + --print ("KILL", "best try", cleuIDData.best_try, "amt kills", cleuIDData.kills, "wipes", cleuIDData.wipes, "longest", cleuIDData.longest) + else + cleuIDData.wipes = cleuIDData.wipes + 1 + if (_detalhes.boss1_health_percent and _detalhes.boss1_health_percent < cleuIDData.best_try) then + cleuIDData.best_try = _detalhes.boss1_health_percent + tinsert (cleuIDData.try_history, {_detalhes.boss1_health_percent, _detalhes.tabela_vigente:GetCombatTime()}) + end + --print ("WIPE", "best try", cleuIDData.best_try, "amt kills", cleuIDData.kills, "wipes", cleuIDData.wipes, "longest", cleuIDData.longest) + end + end + end + -- + end + --the combat is valid, see if the user is sharing data with somebody if (_detalhes.shareData) then local zipData = Details:CompressData (_detalhes.tabela_vigente, "comm") diff --git a/core/parser.lua b/core/parser.lua index 985c5f86f..b71d834f6 100644 --- a/core/parser.lua +++ b/core/parser.lua @@ -2750,6 +2750,7 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1 end end) + -- ~energy ~resource function parser:energize (token, time, who_serial, who_name, who_flags, alvo_serial, alvo_name, alvo_flags, alvo_flags2, spellid, spellname, spelltype, amount, powertype, p6, p7) ------------------------------------------------------------------------------------------------ @@ -2874,7 +2875,7 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1 ----------------------------------------------------------------------------------------------------------------------------------------- --> MISC search key: ~cooldown | ----------------------------------------------------------------------------------------------------------------------------------------- - + function parser:add_defensive_cooldown (token, time, who_serial, who_name, who_flags, alvo_serial, alvo_name, alvo_flags, alvo_flags2, spellid, spellname) ------------------------------------------------------------------------------------------------ @@ -2977,7 +2978,7 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1 end - --serach key: ~interrupt + --serach key: ~interrupts function parser:interrupt (token, time, who_serial, who_name, who_flags, alvo_serial, alvo_name, alvo_flags, alvo_flags2, spellid, spellname, spelltype, extraSpellID, extraSpellName, extraSchool) ------------------------------------------------------------------------------------------------ @@ -4193,6 +4194,7 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1 end _current_encounter_id = encounterID + _detalhes.boss1_health_percent = 1 if (_current_encounter_id == 2122) then --g'huun --REMOVE ON 9,0 PATCH C_Timer.After (1, function() diff --git a/core/util.lua b/core/util.lua index 89517360d..879b4ec80 100644 --- a/core/util.lua +++ b/core/util.lua @@ -871,11 +871,24 @@ end ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --> internal functions + function _detalhes:HealthTick() + if (UnitExists ("boss1") and IsInRaid() and IsInInstance()) then + local health = (UnitHealth ("boss1") or 0) / (UnitHealthMax ("boss1") or 0) + if (_detalhes.boss1_health_percent) then + if (_detalhes.boss1_health_percent < health) then + return + end + end + _detalhes.boss1_health_percent = health + end + end + --> is in combat yet? function _detalhes:EstaEmCombate() _detalhes:TimeDataTick() _detalhes:BrokerTick() + _detalhes:HealthTick() if ((_detalhes.zone_type == "pvp" and _detalhes.use_battleground_server_parser) or _detalhes.zone_type == "arena" or _InCombatLockdown()) then return true diff --git a/functions/api2.lua b/functions/api2.lua index d8b111441..d63ea4c2a 100644 --- a/functions/api2.lua +++ b/functions/api2.lua @@ -91,6 +91,47 @@ Details.API_Description = { ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ --> ~segments +--[=[ + Details.SegmentInfo (segment) +--=]=] +tinsert (Details.API_Description.namespaces[1].api, { + name = "SegmentInfo", + desc = "Return a table containing information about the segment.", + parameters = { + { + name = "segment", + type = "number", + default = "0", + desc = "Which segment to retrive data, default value is zero (current segment). Use -1 for overall data or value from 1 to 25 for other segments.", + }, + }, + returnValues = { + { + name = "segmentInfo", + type = "table", + desc = "Table containing the following members: ", + } + }, + type = 0, --misc +}) + +function Details.SegmentInfo (segment) + segment = segment or 0 + local combatObject = getCombatObject (segment) + + local segmentInfo = { + + } + + if (not combatObject) then + return segmentInfo + end + + + + return segmentInfo +end + --[=[ Details.SegmentElapsedTime (segment) --=]=] @@ -283,6 +324,79 @@ function Details.SegmentHealingUnits (includePlayerUnits, includeEnemyUnits, inc return units end +--[=[ + Details.SegmentTotalDamage (segment) +--=]=] + +tinsert (Details.API_Description.namespaces[1].api, { + name = "SegmentTotalDamage", + desc = "Query the total damage done in the segment and only by players in the group.", + parameters = { + { + name = "segment", + type = "number", + default = "0", + desc = "Which segment to retrive data, default value is zero (current segment). Use -1 for overall data or value from 1 to 25 for other segments.", + }, + }, + returnValues = { + { + name = "totalDamage", + type = "number", + desc = "Amount of damage done by players in the group.", + } + }, + type = 1, --damage +}) + +function Details.SegmentTotalDamage (segment) + segment = segment or 0 + local combatObject = getCombatObject (segment) + + if (not combatObject) then + return 0 + end + + return floor (combatObject.totals_grupo [1]) +end + + +--[=[ + Details.SegmentTotalHealing (segment) +--=]=] + +tinsert (Details.API_Description.namespaces[1].api, { + name = "SegmentTotalHealing", + desc = "Query the total healing done in the segment and only by players in the group.", + parameters = { + { + name = "segment", + type = "number", + default = "0", + desc = "Which segment to retrive data, default value is zero (current segment). Use -1 for overall data or value from 1 to 25 for other segments.", + }, + }, + returnValues = { + { + name = "totalHealing", + type = "number", + desc = "Amount of healing done by players in the group.", + } + }, + type = 2, --healing +}) + +function Details.SegmentTotalHealing (segment) + segment = segment or 0 + local combatObject = getCombatObject (segment) + + if (not combatObject) then + return 0 + end + + return floor (combatObject.totals_grupo [2]) +end + --[=[ Details.SegmentPhases (segment) --=]=] @@ -312,9 +426,14 @@ function Details.SegmentPhases (segment) segment = segment or 0 local combatObject = getCombatObject (segment) + local phases = {} + + if (not combatObject) then + return phases + end + local phaseData = combatObject.PhaseData - local phases = {} for phaseChangeId, phaseTable in ipairs (phaseData) do local phaseNumber = phaseTable [1] DetailsFramework.table.addunique (phases, phaseNumber) diff --git a/functions/profiles.lua b/functions/profiles.lua index a62f89796..12c88490e 100644 --- a/functions/profiles.lua +++ b/functions/profiles.lua @@ -1385,9 +1385,11 @@ local default_global_data = { }, - --> dungeon information + --> dungeon information - can be accessed by plugins and third party mods dungeon_data = {}, - + + --> raid information - can be accessed by plugins and third party mods + raid_data = {}, } _detalhes.default_global_data = default_global_data