Skip to content

Commit

Permalink
Round of fixes, cleanups and library upgrades
Browse files Browse the repository at this point in the history
  • Loading branch information
Tercioo committed Jul 29, 2023
1 parent f41ecaf commit 89e6ffd
Show file tree
Hide file tree
Showing 9 changed files with 469 additions and 388 deletions.
1 change: 1 addition & 0 deletions Details.toc
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ core\network.lua

core\parser.lua

functions\spec_augmentation.lua
functions\loaddata.lua

startup.lua
Expand Down
1 change: 1 addition & 0 deletions Details_Classic.toc
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ core\network.lua
core\parser.lua
#core\parser_timewalk.lua

functions\spec_augmentation.lua
functions\loaddata.lua

startup.lua
Expand Down
1 change: 1 addition & 0 deletions Details_Wrath.toc
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ core\network.lua
core\parser.lua
#core\parser_timewalk.lua

functions\spec_augmentation.lua
functions\loaddata.lua

startup.lua
Expand Down
5 changes: 3 additions & 2 deletions Libs/LibLuaServer/LibLuaServer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -211,15 +211,16 @@
---@alias npcid number a number that identifies a specific npc in the game.
---@alias textureid number each texture from the game client has an id.
---@alias texturepath string access textures from addons.
---@alias unixtime number
---@alias valueamount number used to represent a value, such as a damage amount, a healing amount, or a resource amount.
---@alias unixtime number a number that represents the number of seconds that have elapsed since 00:00:00 Coordinated Universal Time (UTC), Thursday, 1 January 1970, not counting leap seconds.
---@alias timestring string refers to a string showing a time value, such as "1:23" or "1:23:45".
---@alias combattime number elapsed time of a combat or time in seconds that a unit has been in combat.
---@alias auraduration number
---@alias gametime number number of seconds that have elapsed since the start of the game session.
---@alias coordleft number
---@alias coordright number
---@alias coordtop number
---@alias coordbottom number
---@alias auraduration number

---@class _G
---@field RegisterAttributeDriver fun(statedriver: frame, attribute: string, conditional: string)
Expand Down
7 changes: 5 additions & 2 deletions boot.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
local addonName, Details222 = ...
local version, build, date, tocversion = GetBuildInfo()

Details.build_counter = 11718
Details.alpha_build_counter = 11718 --if this is higher than the regular counter, use it instead
Details.build_counter = 11770
Details.alpha_build_counter = 11770 --if this is higher than the regular counter, use it instead
Details.dont_open_news = true
Details.game_version = version
Details.userversion = version .. " " .. Details.build_counter
Expand Down Expand Up @@ -115,6 +115,9 @@
Details222.ClassCache.ByGUID = {}
Details222.UnitIdCache = {}
Details222.Roskash = {}
Details222.SpecHelpers = {
[1473] = {},
}

Details222.Actors = {}

Expand Down
79 changes: 44 additions & 35 deletions classes/class_damage.lua
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ function Details:IsFriendlyNpc() --[[exported]]
return false
end

function Details:IsEnemy() --[[exported]]
function Details:IsEnemy() --[[exported]]
if (self.flag_original) then
if (bitBand(self.flag_original, 0x00000060) ~= 0) then
local npcId = Details:GetNpcIdFromGuid(self.serial)
Expand All @@ -214,7 +214,7 @@ function Details:IsEnemy() --[[exported]]
end
return false
end

function Details:GetSpellList() --[[exported]]
return self.spells._ActorTable
end
Expand Down Expand Up @@ -772,34 +772,34 @@ end
local DTBS_search_code = [[
---@type combat, table, instance
local combatObject, instanceContainer, instanceObject = ...
--declade the values to return
local totalDamage, topDamage, amount = 0, 0, 0
---@type {key1: actorname, key2: number, key3: actor}[]
local damageTakenFrom = {}
local spellId = @SPELLID@
local spellName
if (spellId) then
spellName = select(1, GetSpellInfo(spellId))
end
---@type actorcontainer
local damageContainer = combatObject:GetContainer(DETAILS_ATTRIBUTE_DAMAGE)
---@type actorcontainer
local healContainer = combatObject:GetContainer(DETAILS_ATTRIBUTE_HEAL)
local bIsCustomSpell = false
for _, customSpellObject in ipairs(Details.savedCustomSpells) do
if (customSpellObject[1] == spellId) then
bIsCustomSpell = true
end
end
for index, actorObject in damageContainer:ListActors() do
---@cast actorObject actordamage
--> handle friendly fire spell damage taken
if (actorObject:IsPlayer()) then
if (bIsCustomSpell) then --if the spell has been modified, check only by its spellId, as it can't get other spells with the same name
Expand All @@ -810,10 +810,10 @@ end
local damageActor = damageContainer:GetActor(playerName)
---@type actorheal
local healingActor = healContainer:GetActor(playerName)
if ((damageActor and damageActor:IsPlayer()) or (healingActor and healingActor:IsPlayer())) then
local got
for index, damageTakenTable in ipairs(damageTakenFrom) do
if (damageTakenTable[1] == playerName) then
damageTakenTable[2] = damageTakenTable[2] + friendlyFireTable.spells[spellId]
Expand All @@ -824,7 +824,7 @@ end
break
end
end
if (not got) then
---@type {key1: actorname, key2: number, key3: actor}
local damageTakenTable = {playerName, friendlyFireTable.spells[spellId], damageActor or healingActor}
Expand All @@ -846,7 +846,7 @@ end
local damageActor = damageContainer:GetActor(playerName)
---@type actorheal
local healingActor = healContainer:GetActor(playerName)
if ((damageActor and damageActor:IsPlayer()) or (healingActor and healingActor:IsPlayer())) then
local got
for index, damageTakenTable in ipairs(damageTakenFrom) do
Expand All @@ -859,7 +859,7 @@ end
break
end
end
if (not got) then
---@type {key1: actorname, key2: number, key3: actor}
local damageTakenTable = {playerName, damageAmount, damageActor or healingActor}
Expand All @@ -874,20 +874,20 @@ end
end
end
end
--> handle regular damage taken from spells
---@type spelltable
local spellTable = actorObject:GetSpell(spellId)
if (spellTable) then
for targetName, damageAmount in pairs(spellTable.targets) do
local got = false
---@type actordamage
local damageActor = damageContainer:GetActor(targetName)
---@type actorheal
local healingActor = healContainer:GetActor(targetName)
if ((damageActor and damageActor:IsPlayer()) or (healingActor and healingActor:IsPlayer())) then
for index, damageTakenTable in ipairs(damageTakenFrom) do
if (damageTakenTable[1] == targetName) then
Expand All @@ -899,7 +899,7 @@ end
break
end
end
if (not got) then
---@type {key1: actorname, key2: number, key3: actor}
local damageTakenTable = {targetName, damageAmount, damageActor or healingActor}
Expand All @@ -911,20 +911,20 @@ end
end
end
end
if (not bIsCustomSpell) then
for thisSpellId, spellTable in pairs(actorObject.spells._ActorTable) do
if (thisSpellId ~= spellId) then --this is invalid
local spellname = select(1, GetSpellInfo(thisSpellId))
if (spellname == spellName) then
for targetName, damageAmount in pairs(spellTable.targets) do
local got = false
---@type actordamage
local damageActor = damageContainer:GetActor(targetName)
---@type actorheal
local healingActor = healContainer:GetActor(targetName)
if ((damageActor and damageActor:IsPlayer()) or (healingActor and healingActor:IsPlayer())) then
for index, damageTakenTable in ipairs(damageTakenFrom) do
if (damageTakenTable[1] == targetName) then
Expand All @@ -936,7 +936,7 @@ end
break
end
end
if (not got) then
---@type {key1: actorname, key2: number, key3: actor}
local damageTakenTable = {targetName, damageAmount, damageActor or healingActor}
Expand All @@ -952,15 +952,15 @@ end
end
end
end
table.sort(damageTakenFrom, Details.Sort2)
for index, damageTakenTable in ipairs(damageTakenFrom) do
instanceContainer:AddValue(damageTakenTable[3], damageTakenTable[2]) --actorObject, amountDamage
totalDamage = totalDamage + damageTakenTable[2] --amountDamage
amount = amount + 1
end
return totalDamage, topDamage, amount
]]

Expand Down Expand Up @@ -1116,7 +1116,7 @@ end
thisLine.iconHighlight:SetTexCoord(classIcon:GetTexCoord())
thisLine.iconHighlight:SetVertexColor(classIcon:GetVertexColor())
end

end

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -3398,20 +3398,29 @@ function damageClass.PredictedAugSpellsOnEnter(self)
local spellName, _, spellTexture = GetSpellInfo(spellId)
if (spellName) then
GameCooltip:AddLine(spellName, Details:Format(spellTable.total))
GameCooltip:AddIcon(spellTexture, 1, 1, 18, 18)
GameCooltip:AddIcon(spellTexture, 1, 1, 14, 14)

--the damage sources are added into the targets table for reciclying
local spellsAugmented = {}

--the damage sources are added into the targets table for recycling
---@type table<actorname, valueamount>
local sources = spellTable.targets
for sourceName, sourceAmount in pairs(sources) do
spellsAugmented[#spellsAugmented+1] = {sourceName, sourceAmount}
end

table.sort(spellsAugmented, Details.Sort2)

for i = 1, #spellsAugmented do
local sourceName, sourceAmount = unpack(spellsAugmented[i])
GameCooltip:AddLine(sourceName, Details:Format(sourceAmount), 1, "yellow", "yellow", 10)
local actorObject = combatObject:GetActor(1, sourceName)
if (actorObject) then
local actorIcon = Details:GetActorIcon(actorObject)
if (actorIcon) then
GameCooltip:AddIcon(actorIcon.texture, 1, 1, 18, 18, actorIcon.coords.left, actorIcon.coords.right, actorIcon.coords.top, actorIcon.coords.bottom)
GameCooltip:AddIcon(actorIcon.texture, 1, 1, 14, 14, actorIcon.coords.left, actorIcon.coords.right, actorIcon.coords.top, actorIcon.coords.bottom)
else
GameCooltip:AddIcon([[Interface\COMMON\Indicator-Gray]], 1, 1, 18, 18)
GameCooltip:AddIcon([[Interface\COMMON\Indicator-Gray]], 1, 1, 14, 14)
end
end
end
Expand Down Expand Up @@ -3640,7 +3649,7 @@ function damageClass:ToolTip_DamageDone (instancia, numero, barra, keydown)
for i = 1, math.min(max_targets, #ActorTargetsSortTable) do
local enemyTable = ActorTargetsSortTable[i]
GameCooltip:AddLine(enemyTable[1], FormatTooltipNumber(_, enemyTable[2]) .." ("..format("%.1f", enemyTable[2] / ActorDamageWithPet * 100).."%)")

local portraitTexture-- = Details222.Textures.GetPortraitTextureForNpcID(enemyTable[3]) --disabled atm
if (portraitTexture) then
GameCooltip:AddIcon(portraitTexture, 1, 1, icon_size.W, icon_size.H)
Expand Down Expand Up @@ -4842,7 +4851,7 @@ end
não passar nada e deixar o sistema aprender sozinho, como o sistema vai saber que precisa por uma arrow na linha? (para expandi-la)
--]=]

------ Damage Done & Dps
Expand Down Expand Up @@ -4980,7 +4989,7 @@ function damageClass:MontaInfoDamageDone() --I guess this fills the list of spel
--output
breakdownSpellDataList[#breakdownSpellDataList+1] = bkSpellData

--fill here the spellTables using the actor abilities
--fill here the spellTables using the actor abilities
--all these spells belong to the current actor in the loop
for spellId, spellTable in petSpellContainer:ListSpells() do
local spellName, _, spellIcon = GetSpellInfo(spellId)
Expand Down Expand Up @@ -6885,7 +6894,7 @@ damageClass.__add = function(tabela1, tabela2)
if (not habilidade_tabela1[key]) then
habilidade_tabela1[key] = {}
end
for empowermentLevel, empowermentValue in pairs(habilidade[key]) do
for empowermentLevel, empowermentValue in pairs(habilidade[key]) do
habilidade_tabela1[key][empowermentLevel] = habilidade_tabela1[key][empowermentValue] or 0 + empowermentValue
end
end
Expand Down
Loading

0 comments on commit 89e6ffd

Please sign in to comment.