Skip to content

Commit

Permalink
Added API: SegmentInfo(), SegmentTotalDamage(), SegmentTotalHealing()…
Browse files Browse the repository at this point in the history
…, see '/details api' for more information
  • Loading branch information
Tercioo committed May 1, 2019
1 parent dfad8bc commit 5e5fd97
Show file tree
Hide file tree
Showing 6 changed files with 182 additions and 7 deletions.
2 changes: 0 additions & 2 deletions classes/classe_energy.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
41 changes: 41 additions & 0 deletions core/control.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
6 changes: 4 additions & 2 deletions core/parser.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)

------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -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)

------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -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)

------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -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()
Expand Down
13 changes: 13 additions & 0 deletions core/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
121 changes: 120 additions & 1 deletion functions/api2.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
--=]=]
Expand Down Expand Up @@ -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)
--=]=]
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 4 additions & 2 deletions functions/profiles.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5e5fd97

Please sign in to comment.