diff --git a/boot.lua b/boot.lua index 866d6d567..07b1cc987 100644 --- a/boot.lua +++ b/boot.lua @@ -15,8 +15,8 @@ local addonName, Details222 = ... local version, build, date, tocversion = GetBuildInfo() - Details.build_counter = 11022 - Details.alpha_build_counter = 11022 --if this is higher than the regular counter, use it instead + Details.build_counter = 11023 + Details.alpha_build_counter = 11023 --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 @@ -1213,4 +1213,157 @@ end ---@param value number function Details222.PlayerStats:SetStat(statName, value) Details.player_stats[statName] = value +end + + + +---destroy a table and remove it from the object, if the key isn't passed, the object itself is destroyed +---@param object any +---@param key string|nil +function Details:Destroy(object, key) + if (key) then + if (getmetatable(object[key])) then + setmetatable(object[key], nil) + end + object[key].__index = nil + table.wipe(object[key]) + object[key] = nil + else + if (getmetatable(object)) then + setmetatable(object, nil) + end + object.__index = nil + table.wipe(object) + end +end + +---destroy an actor within a combat object, this call will +---@param actorObject actor +---@param combatObject combat +function Details:DestroyActor(actorObject, combatObject) + --using low level api here for performance + ---@type actor[] + local allActors = {} + + for containerType = 1, 4 do + local index = combatObject[containerType]._NameIndexTable[actorObject.nome] + if (index) then + ---@type actor + local actor = combatObject[containerType]._ActorTable[index] + + if (actor) then + allActors[#allActors+1] = actor + + --need to reduce the amount done by the actor from the combatObject + local combatTotalsTable = combatObject.totals --without group + local combatTotalsTableInGroup = combatObject.totals_grupo --with group + + if (containerType == 1 or containerType == 2) then --damage|healing done + combatTotalsTable[containerType] = combatTotalsTable[containerType] - actor.total + if (actor.grupo) then + combatTotalsTableInGroup[containerType] = combatTotalsTableInGroup[containerType] - actor.total + end + + elseif (containerType == 3) then + if (actor.total and actor.total > 0) then + combatTotalsTable[containerType][actor.powertype] = combatTotalsTable[containerType][actor.powertype] - actor.total + combatTotalsTableInGroup[containerType][actor.powertype] = combatTotalsTableInGroup[containerType][actor.powertype] - actor.total + end + if (actor.alternatepower and actor.alternatepower > 0) then + combatTotalsTable[containerType].alternatepower = combatTotalsTable[containerType].alternatepower - actor.alternatepower + combatTotalsTableInGroup[containerType].alternatepower = combatTotalsTableInGroup[containerType].alternatepower - actor.alternatepower + end + + elseif (containerType == 4) then + --decrease the amount of CC break from the combat totals + if (actor.cc_break and actor.cc_break > 0) then + if (combatTotalsTable[containerType].cc_break) then + combatTotalsTable[containerType].cc_break = combatTotalsTable[containerType].cc_break - actor.cc_break + end + if (combatTotalsTableInGroup[containerType].cc_break) then + combatTotalsTableInGroup[containerType].cc_break = combatTotalsTableInGroup[containerType].cc_break - actor.cc_break + end + end + + --decrease the amount of dispell from the combat totals + if (actor.dispell and actor.dispell > 0) then + if (combatTotalsTable[containerType].dispell) then + combatTotalsTable[containerType].dispell = combatTotalsTable[containerType].dispell - actor.dispell + end + if (combatTotalsTableInGroup[containerType].dispell) then + combatTotalsTableInGroup[containerType].dispell = combatTotalsTableInGroup[containerType].dispell - actor.dispell + end + end + + --decrease the amount of interrupt from the combat totals + if (actor.interrupt and actor.interrupt > 0) then + if (combatTotalsTable[containerType].interrupt) then + combatTotalsTable[containerType].interrupt = combatTotalsTable[containerType].interrupt - actor.interrupt + end + if (combatTotalsTableInGroup[containerType].interrupt) then + combatTotalsTableInGroup[containerType].interrupt = combatTotalsTableInGroup[containerType].interrupt - actor.interrupt + end + end + + --decrease the amount of ress from the combat totals + if (actor.ress and actor.ress > 0) then + if (combatTotalsTable[containerType].ress) then + combatTotalsTable[containerType].ress = combatTotalsTable[containerType].ress - actor.ress + end + if (combatTotalsTableInGroup[containerType].ress) then + combatTotalsTableInGroup[containerType].ress = combatTotalsTableInGroup[containerType].ress - actor.ress + end + end + + --decrease the amount of dead from the combat totals + if (actor.dead and actor.dead > 0) then + if (combatTotalsTable[containerType].dead) then + combatTotalsTable[containerType].dead = combatTotalsTable[containerType].dead - actor.dead + end + if (combatTotalsTableInGroup[containerType].dead) then + combatTotalsTableInGroup[containerType].dead = combatTotalsTableInGroup[containerType].dead - actor.dead + end + end + + --decreate the amount of cooldowns used from the combat totals + if (actor.cooldowns_defensive and actor.cooldowns_defensive > 0) then + if (combatTotalsTable[containerType].cooldowns_defensive) then + combatTotalsTable[containerType].cooldowns_defensive = combatTotalsTable[containerType].cooldowns_defensive - actor.cooldowns_defensive + end + if (combatTotalsTableInGroup[containerType].cooldowns_defensive) then + combatTotalsTableInGroup[containerType].cooldowns_defensive = combatTotalsTableInGroup[containerType].cooldowns_defensive - actor.cooldowns_defensive + end + end + + --decrease the amount of buff uptime from the combat totals + if (actor.buff_uptime and actor.buff_uptime > 0) then + if (combatTotalsTable[containerType].buff_uptime) then + combatTotalsTable[containerType].buff_uptime = combatTotalsTable[containerType].buff_uptime - actor.buff_uptime + end + if (combatTotalsTableInGroup[containerType].buff_uptime) then + combatTotalsTableInGroup[containerType].buff_uptime = combatTotalsTableInGroup[containerType].buff_uptime - actor.buff_uptime + end + end + + --decrease the amount of debuff uptime from the combat totals + if (actor.debuff_uptime and actor.debuff_uptime > 0) then + if (combatTotalsTable[containerType].debuff_uptime) then + combatTotalsTable[containerType].debuff_uptime = combatTotalsTable[containerType].debuff_uptime - actor.debuff_uptime + end + if (combatTotalsTableInGroup[containerType].debuff_uptime) then + combatTotalsTableInGroup[containerType].debuff_uptime = combatTotalsTableInGroup[containerType].debuff_uptime - actor.debuff_uptime + end + end + end + + for i = 1, #allActors do + local thisActor = allActors[i] + setmetatable(thisActor, nil) + thisActor.__index = nil + thisActor.__newindex = nil + Details:Destroy(thisActor) + end + end + end + end end \ No newline at end of file