General Fixes

This commit is contained in:
Tercio Jose
2023-04-30 23:23:56 -03:00
parent 6be5ab14f4
commit 11a6c48ddd
24 changed files with 420 additions and 696 deletions
+157 -187
View File
@@ -12,7 +12,7 @@ local addonName, Details222 = ...
--local helpers
local getCombatObject = function(segmentNumber)
local combatObject
--select which segment to use, use low level variables for performance
if (segmentNumber == -1) then
combatObject = _detalhes.tabela_overall
@@ -21,7 +21,7 @@ local getCombatObject = function(segmentNumber)
else
combatObject = _detalhes.tabela_historico.tabelas [segmentNumber]
end
return combatObject
end
@@ -46,17 +46,17 @@ end
--return the spell object and the spellId
local getSpellObject = function(playerObject, spellId, isLiteral)
local parameterType = type(spellId)
if (parameterType == "number" and isLiteral) then
--is the id of a spell and literal, directly get the spell object
return playerObject.spells._ActorTable [spellId], spellId
else
local passedSpellName
if (parameterType == "string") then
--passed a spell name, make the spell be in lower case
passedSpellName = spellId:lower()
elseif (parameterType == "number") then
--passed a number but with literal off, transform the spellId into a spell name
local spellName = GetSpellInfo(spellid)
@@ -64,7 +64,7 @@ local getSpellObject = function(playerObject, spellId, isLiteral)
passedSpellName = spellName:lower()
end
end
if (passedSpellName) then
for thisSpellId, spellObject in pairs(playerObject.spells._ActorTable) do
local spellName = Details.GetSpellInfo(thisSpellId)
@@ -120,17 +120,17 @@ tinsert(Details.API_Description.namespaces[1].api, {
function Details.SegmentInfo (segment)
segment = segment or 0
local combatObject = getCombatObject (segment)
local segmentInfo = {
}
if (not combatObject) then
return segmentInfo
end
return segmentInfo
end
@@ -161,11 +161,11 @@ tinsert(Details.API_Description.namespaces[1].api, {
function Details.SegmentElapsedTime (segment)
segment = segment or 0
local combatObject = getCombatObject (segment)
if (not combatObject) then
return 0
end
return combatObject:GetCombatTime()
end
@@ -216,34 +216,34 @@ function Details.SegmentDamagingUnits (includePlayerUnits, includeEnemyUnits, in
if (type(includePlayerUnits) ~= "boolean") then
includePlayerUnits = true
end
local combatObject = getCombatObject (segment)
local units = {}
local nextIndex = 1
if (not combatObject) then
return units
end
local damageContainer = combatObject:GetContainer (DETAILS_ATTRIBUTE_DAMAGE)
for i = 1, #damageContainer._ActorTable do
local playerObject = damageContainer._ActorTable [i]
if (includePlayerUnits and playerObject.grupo) then
units [nextIndex] = playerObject:GetName()
nextIndex = nextIndex + 1
elseif (includeEnemyUnits and playerObject:IsEnemy()) then
units [nextIndex] = playerObject:GetName()
nextIndex = nextIndex + 1
elseif (includeFriendlyPetUnits and playerObject:IsPetOrGuardian()) then
units [nextIndex] = playerObject:GetName()
nextIndex = nextIndex + 1
end
end
return units
end
@@ -295,34 +295,34 @@ function Details.SegmentHealingUnits (includePlayerUnits, includeEnemyUnits, inc
if (type(includePlayerUnits) ~= "boolean") then
includePlayerUnits = true
end
local combatObject = getCombatObject (segment)
local units = {}
local nextIndex = 1
if (not combatObject) then
return units
end
local damageContainer = combatObject:GetContainer (DETAILS_ATTRIBUTE_HEAL)
for i = 1, #damageContainer._ActorTable do
local playerObject = damageContainer._ActorTable [i]
if (includePlayerUnits and playerObject.grupo) then
units [nextIndex] = playerObject:GetName()
nextIndex = nextIndex + 1
elseif (includeEnemyUnits and playerObject:IsEnemy()) then
units [nextIndex] = playerObject:GetName()
nextIndex = nextIndex + 1
elseif (includeFriendlyPetUnits and playerObject:IsPetOrGuardian()) then
units [nextIndex] = playerObject:GetName()
nextIndex = nextIndex + 1
end
end
return units
end
@@ -354,11 +354,11 @@ tinsert(Details.API_Description.namespaces[1].api, {
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
@@ -391,11 +391,11 @@ tinsert(Details.API_Description.namespaces[1].api, {
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
@@ -427,20 +427,20 @@ tinsert(Details.API_Description.namespaces[1].api, {
function Details.SegmentPhases (segment)
segment = segment or 0
local combatObject = getCombatObject (segment)
local phases = {}
if (not combatObject) then
return phases
end
end
local phaseData = combatObject.PhaseData
for phaseChangeId, phaseTable in ipairs(phaseData) do
local phaseNumber = phaseTable [1]
DetailsFramework.table.addunique (phases, phaseNumber)
end
return phases
end
@@ -481,7 +481,7 @@ tinsert(Details.API_Description.namespaces[1].api, {
function Details.UnitInfo (unitId, segment)
segment = segment or 0
local combatObject = getCombatObject (segment)
local unitInfo = {
class = "UNKNOW", --old typo in details
spec = 0,
@@ -494,18 +494,18 @@ function Details.UnitInfo (unitId, segment)
isArenaEnemy = false,
arenaTeam = false,
}
if (not combatObject) then
return unitInfo
end
local unitName = getUnitName (unitId)
local playerObject = getActorObjectFromCombat (combatObject, 1, unitName)
if (not playerObject) then
return unitInfo
end
local specCache = Details.cached_specs
local unitSerial = UnitGUID(unitId)
local _, class = UnitClass(unitId)
@@ -566,7 +566,7 @@ tinsert(Details.API_Description.namespaces[1].api, {
function Details.UnitTexture (unitId, segment)
segment = segment or 0
local combatObject = getCombatObject (segment)
local textureInfo = {
classTexture = [[Interface\LFGFRAME\LFGROLE_BW]],
classLeft = 0.25,
@@ -579,32 +579,32 @@ function Details.UnitTexture (unitId, segment)
specTop = 0,
specBottom = 1,
}
if (not combatObject) then
return textureInfo
end
local unitName = getUnitName (unitId)
local playerObject = getActorObjectFromCombat (combatObject, 1, unitName)
if (not playerObject) then
return textureInfo
end
local texture, left, right, top, bottom = playerObject:GetClassIcon()
textureInfo.classTexture = texture
textureInfo.classLeft = left
textureInfo.classRight = right
textureInfo.classTop = top
textureInfo.classBottom = bottom
local texture, left, right, top, bottom = Details:GetSpecIcon (playerObject.spec)
textureInfo.specTexture = texture
textureInfo.specLeft = left
textureInfo.specRight = right
textureInfo.specTop = top
textureInfo.specBottom = bottom
return textureInfo
end
@@ -644,18 +644,18 @@ tinsert(Details.API_Description.namespaces[1].api, {
function Details.UnitDamage (unitId, segment)
segment = segment or 0
local combatObject = getCombatObject (segment)
if (not combatObject) then
return 0
end
local unitName = getUnitName (unitId)
local playerObject = getActorObjectFromCombat (combatObject, 1, unitName)
if (not playerObject) then
return 0
end
return floor(playerObject.total or 0)
end
@@ -699,22 +699,22 @@ tinsert(Details.API_Description.namespaces[1].api, {
function Details.UnitDamageByPhase (unitId, phaseNumber, segment)
segment = segment or 0
local combatObject = getCombatObject (segment)
if (not combatObject) then
return 0
end
if (not phaseNumber) then
return 0
end
local unitName = getUnitName (unitId)
local damagePhaseData = combatObject.PhaseData.damage [phaseNumber]
if (not damagePhaseData) then
return 0
end
local phaseDamage = damagePhaseData [unitName] or 0
return floor(phaseDamage)
end
@@ -752,13 +752,13 @@ tinsert(Details.API_Description.namespaces[1].api, {
function Details.UnitDamageInfo (unitId, segment)
segment = segment or 0
local combatObject = getCombatObject (segment)
if (not combatObject) then
return 0
end
local unitName = getUnitName (unitId)
local damageInfo = {
total = 0,
totalWithoutPet = 0,
@@ -767,19 +767,19 @@ function Details.UnitDamageInfo (unitId, segment)
friendlyFire = 0,
activityTime = 0,
}
local playerObject = getActorObjectFromCombat (combatObject, 1, unitName)
if (not playerObject) then
return damageInfo
end
damageInfo.total = floor(playerObject.total)
damageInfo.totalWithoutPet = floor(playerObject.total_without_pet)
damageInfo.damageAbsorbed = floor(playerObject.totalabsorbed)
damageInfo.damageTaken = floor(playerObject.damage_taken)
damageInfo.friendlyFire = playerObject.friendlyfire_total
damageInfo.activityTime = playerObject:Tempo()
return damageInfo
end
@@ -838,14 +838,14 @@ function Details.UnitDamageBySpell (unitId, spellId, isLiteral, segment)
if (not combatObject) then
return 0
end
local unitName = getUnitName (unitId)
local playerObject = getActorObjectFromCombat (combatObject, 1, unitName)
if (not playerObject) then
return 0
end
local spellObject, spellId = getSpellObject (playerObject, spellId, isLiteral)
if (spellObject) then
@@ -903,15 +903,15 @@ function Details.UnitDamageSpellInfo (unitId, spellId, isLiteral, segment)
isLiteral = true
end
segment = segment or 0
local combatObject = getCombatObject (segment)
if (not combatObject) then
return 0
end
local unitName = getUnitName (unitId)
local spellInfo = {
total = 0,
spellId = 0,
@@ -927,35 +927,20 @@ function Details.UnitDamageSpellInfo (unitId, spellId, isLiteral, segment)
criticalHits = 0,
criticalDamage = 0,
}
local playerObject = getActorObjectFromCombat (combatObject, 1, unitName)
local playerObject = getActorObjectFromCombat(combatObject, 1, unitName)
if (not playerObject) then
return spellInfo
end
local spellObject, spellId = getSpellObject (playerObject, spellId, isLiteral)
local spellObject, spellId = getSpellObject(playerObject, spellId, isLiteral)
if (not spellObject) then
return spellInfo
end
local miscPlayerObject = getActorObjectFromCombat (combatObject, 4, unitName)
if (miscPlayerObject) then
local spellName = GetSpellInfo(spellId)
local castedAmount = miscPlayerObject.spell_cast and miscPlayerObject.spell_cast [spellId]
if (castedAmount) then
spellInfo.casted = castedAmount
else
for castedSpellId, castedAmount in pairs(miscPlayerObject.spell_cast) do
local castedSpellName = GetSpellInfo(castedSpellId)
if (castedSpellName == spellName) then
spellInfo.casted = castedAmount
break
end
end
end
end
local spellName = GetSpellInfo(spellId)
spellInfo.casted = combatObject:GetSpellCastAmount(unitName, spellName)
if (spellObject) then
spellInfo.total = spellObject.total
spellInfo.count = spellObject.counter
@@ -970,7 +955,7 @@ function Details.UnitDamageSpellInfo (unitId, spellId, isLiteral, segment)
spellInfo.criticalHits = spellObject.c_amt
spellInfo.criticalDamage = spellObject.c_total
end
return spellInfo
end
@@ -1027,19 +1012,19 @@ function Details.UnitDamageSpellOnUnit (unitId, spellId, targetUnitId, isLiteral
isLiteral = true
end
segment = segment or 0
local combatObject = getCombatObject (segment)
if (not combatObject) then
return 0
end
local unitName = getUnitName (unitId)
local playerObject = getActorObjectFromCombat (combatObject, 1, unitName)
if (not playerObject) then
return 0
end
local spellObject, spellId = getSpellObject (playerObject, spellId, isLiteral)
if (spellObject) then
local targetName = getUnitName (targetUnitId)
@@ -1086,14 +1071,14 @@ function Details.UnitDamageTaken (unitId, segment)
if (not combatObject) then
return 0
end
local unitName = getUnitName (unitId)
local playerObject = getActorObjectFromCombat (combatObject, 1, unitName)
if (not playerObject) then
return 0
end
return floor(playerObject.damage_taken)
end
@@ -1136,18 +1121,18 @@ tinsert(Details.API_Description.namespaces[1].api, {
function Details.UnitDamageOnUnit (unitId, targetUnitId, segment)
segment = segment or 0
local combatObject = getCombatObject (segment)
if (not combatObject) then
return 0
end
local unitName = getUnitName (unitId)
local playerObject = getActorObjectFromCombat (combatObject, 1, unitName)
if (not playerObject) then
return 0
end
local targetName = getUnitName (targetUnitId)
return playerObject.targets [targetName] or 0
end
@@ -1193,16 +1178,16 @@ function Details.UnitDamageTakenFromSpell (unitId, spellId, isLiteral, segment)
if (type(isLiteral) ~= "boolean") then
isLiteral = true
end
local combatObject = getCombatObject (segment)
if (not combatObject) then
return 0
end
local unitName = getUnitName (unitId)
local damageContainer = combatObject:GetContainer (DETAILS_ATTRIBUTE_DAMAGE)
local totalDamageTaken = 0
if (isLiteral and type(spellId) == "number") then
for i = 1, #damageContainer._ActorTable do
@@ -1265,20 +1250,20 @@ function Details.UnitDamagingSpells (unitId, segment)
if (not combatObject) then
return {}
end
local unitName = getUnitName (unitId)
local playerObject = getActorObjectFromCombat (combatObject, 1, unitName)
if (not playerObject) then
return {}
end
local unitSpells = playerObject.spells._ActorTable
local resultTable = {}
for spellId, spellObject in pairs(unitSpells) do
resultTable [#resultTable + 1] = spellId
end
return resultTable
end
@@ -1315,23 +1300,23 @@ tinsert(Details.API_Description.namespaces[1].api, {
function Details.UnitDamagingTargets (unitId, segment)
segment = segment or 0
local combatObject = getCombatObject (segment)
if (not combatObject) then
return 0
end
local unitName = getUnitName (unitId)
local offensiveTargetNames = {}
local playerObject = getActorObjectFromCombat (combatObject, 1, unitName)
if (not playerObject) then
return offensiveTargetNames
end
for targetName, _ in pairs(playerObject.targets) do
offensiveTargetNames [#offensiveTargetNames + 1] = targetName
end
return offensiveTargetNames
end
@@ -1369,23 +1354,23 @@ tinsert(Details.API_Description.namespaces[1].api, {
function Details.UnitDamagingPets (unitId, segment)
segment = segment or 0
local combatObject = getCombatObject (segment)
if (not combatObject) then
return 0
end
local unitName = getUnitName (unitId)
local petNames = {}
local playerObject = getActorObjectFromCombat (combatObject, 1, unitName)
if (not playerObject) then
return petNames
end
for i = 1, #playerObject.pets do
petNames [#petNames + 1] = playerObject.pets [i]
end
return petNames
end
@@ -1427,18 +1412,18 @@ tinsert(Details.API_Description.namespaces[1].api, {
function Details.UnitHealing (unitId, segment)
segment = segment or 0
local combatObject = getCombatObject (segment)
if (not combatObject) then
return 0
end
local unitName = getUnitName (unitId)
local playerObject = getActorObjectFromCombat (combatObject, 2, unitName)
if (not playerObject) then
return 0
end
return floor(playerObject.total or 0)
end
@@ -1476,13 +1461,13 @@ tinsert(Details.API_Description.namespaces[1].api, {
function Details.UnitHealingInfo (unitId, segment)
segment = segment or 0
local combatObject = getCombatObject (segment)
if (not combatObject) then
return 0
end
local unitName = getUnitName (unitId)
local healingInfo = {
total = 0,
totalWithoutPet = 0,
@@ -1494,12 +1479,12 @@ function Details.UnitHealingInfo (unitId, segment)
healingTaken = 0,
activityTime = 0,
}
local playerObject = getActorObjectFromCombat (combatObject, 2, unitName)
if (not playerObject) then
return healingInfo
end
healingInfo.total = floor(playerObject.total)
healingInfo.totalWithoutPet = floor(playerObject.total_without_pet)
healingInfo.totalOverhealWithoutPet = floor(playerObject.totalover_without_pet)
@@ -1567,16 +1552,16 @@ function Details.UnitHealingBySpell (unitId, spellId, isLiteral, segment)
if (not combatObject) then
return 0
end
local unitName = getUnitName (unitId)
local playerObject = getActorObjectFromCombat (combatObject, 2, unitName)
if (not playerObject) then
return 0
end
local spellObject, spellId = getSpellObject (playerObject, spellId, isLiteral)
if (spellObject) then
return spellObject.total
else
@@ -1634,13 +1619,13 @@ function Details.UnitHealingSpellInfo (unitId, spellId, isLiteral, segment)
isLiteral = true
end
segment = segment or 0
local combatObject = getCombatObject (segment)
if (not combatObject) then
return 0
end
local unitName = getUnitName (unitId)
local spellInfo = {
@@ -1658,35 +1643,20 @@ function Details.UnitHealingSpellInfo (unitId, spellId, isLiteral, segment)
criticalHits = 0,
criticalHealing = 0,
}
local playerObject = getActorObjectFromCombat (combatObject, 2, unitName)
if (not playerObject) then
return spellInfo
end
local spellObject, spellId = getSpellObject (playerObject, spellId, isLiteral)
if (not spellObject) then
return spellInfo
end
local miscPlayerObject = getActorObjectFromCombat (combatObject, 4, unitName)
if (miscPlayerObject) then
local spellName = GetSpellInfo(spellId)
local castedAmount = miscPlayerObject.spell_cast and miscPlayerObject.spell_cast [spellId]
if (castedAmount) then
spellInfo.casted = castedAmount
else
for castedSpellId, castedAmount in pairs(miscPlayerObject.spell_cast) do
local castedSpellName = GetSpellInfo(castedSpellId)
if (castedSpellName == spellName) then
spellInfo.casted = castedAmount
break
end
end
end
end
local spellName = GetSpellInfo(spellId)
spellInfo.casted = combatObject:GetSpellCastAmount(unitName, spellName)
if (spellObject) then
spellInfo.total = spellObject.total
spellInfo.count = spellObject.counter
@@ -1701,7 +1671,7 @@ function Details.UnitHealingSpellInfo (unitId, spellId, isLiteral, segment)
spellInfo.criticalHits = spellObject.c_amt
spellInfo.criticalHealing = spellObject.c_total
end
return spellInfo
end
@@ -1759,19 +1729,19 @@ function Details.UnitHealingSpellOnUnit (unitId, spellId, targetUnitId, isLitera
isLiteral = true
end
segment = segment or 0
local combatObject = getCombatObject (segment)
if (not combatObject) then
return 0
end
local unitName = getUnitName (unitId)
local playerObject = getActorObjectFromCombat (combatObject, 2, unitName)
if (not playerObject) then
return 0
end
local spellObject, spellId = getSpellObject (playerObject, spellId, isLiteral)
if (spellObject) then
local targetName = getUnitName (targetUnitId)
@@ -1820,14 +1790,14 @@ function Details.UnitHealingTaken (unitId, segment)
if (not combatObject) then
return 0
end
local unitName = getUnitName (unitId)
local playerObject = getActorObjectFromCombat (combatObject, 2, unitName)
if (not playerObject) then
return 0
end
return floor(playerObject.healing_taken)
end
@@ -1872,18 +1842,18 @@ tinsert(Details.API_Description.namespaces[1].api, {
function Details.UnitHealingOnUnit (unitId, targetUnitId, segment)
segment = segment or 0
local combatObject = getCombatObject (segment)
if (not combatObject) then
return 0
end
local unitName = getUnitName (unitId)
local playerObject = getActorObjectFromCombat (combatObject, 2, unitName)
if (not playerObject) then
return 0
end
local targetName = getUnitName (targetUnitId)
return playerObject.targets [targetName] or 0
end
@@ -1932,16 +1902,16 @@ function Details.UnitHealingTakenFromSpell (unitId, spellId, isLiteral, segment)
if (type(isLiteral) ~= "boolean") then
isLiteral = true
end
local combatObject = getCombatObject (segment)
if (not combatObject) then
return 0
end
local unitName = getUnitName (unitId)
local healingContainer = combatObject:GetContainer (DETAILS_ATTRIBUTE_HEAL)
local totalHealingTaken = 0
if (isLiteral and type(spellId) == "number") then
for i = 1, #healingContainer._ActorTable do
@@ -2005,20 +1975,20 @@ function Details.UnitHealingSpells (unitId, segment)
if (not combatObject) then
return {}
end
local unitName = getUnitName (unitId)
local playerObject = getActorObjectFromCombat (combatObject, 2, unitName)
if (not playerObject) then
return {}
end
local unitSpells = playerObject.spells._ActorTable
local resultTable = {}
for spellId, spellObject in pairs(unitSpells) do
resultTable [#resultTable + 1] = spellId
end
return resultTable
end
@@ -2056,23 +2026,23 @@ tinsert(Details.API_Description.namespaces[1].api, {
function Details.UnitHealingTargets (unitId, segment)
segment = segment or 0
local combatObject = getCombatObject (segment)
if (not combatObject) then
return 0
end
local unitName = getUnitName (unitId)
local healingTargetNames = {}
local playerObject = getActorObjectFromCombat (combatObject, 2, unitName)
if (not playerObject) then
return healingTargetNames
end
for targetName, _ in pairs(playerObject.targets) do
healingTargetNames [#healingTargetNames + 1] = targetName
end
return healingTargetNames
end
@@ -2111,24 +2081,24 @@ tinsert(Details.API_Description.namespaces[1].api, {
function Details.UnitHealingPets (unitId, segment)
segment = segment or 0
local combatObject = getCombatObject (segment)
if (not combatObject) then
return 0
end
local unitName = getUnitName (unitId)
local petNames = {}
local playerObject = getActorObjectFromCombat (combatObject, 2, unitName)
if (not playerObject) then
return petNames
end
for i = 1, #playerObject.pets do
petNames [#petNames + 1] = playerObject.pets [i]
end
return petNames
end
--stop auto complete: doo ende endp elsez
--stop auto complete: doo ende endp elsez