Pet container rewritten

This commit is contained in:
Tercio Jose
2024-06-14 18:30:20 -03:00
committed by andrew6180
parent 85fff228df
commit f6c59381ab
25 changed files with 784 additions and 469 deletions
+31 -19
View File
@@ -28,7 +28,6 @@
local _UnitGroupRolesAssigned = detailsFramework.UnitGroupRolesAssigned
local _GetSpellInfo = Details.getspellinfo
local _tempo = time()
local _, Details222 = ...
_ = nil
local shield_cache = Details.ShieldCache --details local
@@ -77,6 +76,10 @@
local _current_energy_container = _current_combat [3]
local _current_misc_container = _current_combat [4]
--pet container cache
---@type petcontainer
local petContainer = Details222.PetContainer
local names_cache = {}
--damage
local damage_cache = setmetatable({}, Details.weaktable)
@@ -112,7 +115,8 @@
--shield spellid cache
local shield_spellid_cache = {}
--pets
local container_pets = {} --just initialize table (placeholder)
local petCache = petContainer.Pets
--ignore deaths
local ignore_death_cache = {}
--cache
@@ -1682,18 +1686,24 @@
12/14 21:14:44.545 SPELL_SUMMON,Creature-0-4391-615-3107-15439-00001A8313,"Fire Elemental Totem",0x2112,0x0,Creature-0-4391-615-3107-15438-00001A8313,"Greater Fire Elemental",0x2112,0x0,32982,"Fire Elemental Totem",0x1
]]
if npcId == 15438 then
petContainer.AddPet(petSerial, "Greater Fire Elemental", petFlags, sourceSerial, sourceName, sourceFlags, spellId)
end
petName = Details222.Pets.GetPetNameFromCustomSpells(petName, spellId, npcId)
--pet summon another pet
local petTable = container_pets[sourceSerial]
local petTable = petCache[sourceSerial]
if (petTable) then
sourceName, sourceSerial, sourceFlags = petTable[1], petTable[2], petTable[3]
end
petTable = container_pets[petSerial]
petTable = petCache[petSerial]
if (petTable) then
sourceName, sourceSerial, sourceFlags = petTable[1], petTable[2], petTable[3]
end
Details.tabela_pets:AddPet(petSerial, petName, petFlags, sourceSerial, sourceName, sourceFlags)
petContainer.AddPet(petSerial, petName, petFlags, sourceSerial, sourceName, sourceFlags, spellId)
end
-----------------------------------------------------------------------------------------------------------------------------------------
@@ -2390,7 +2400,7 @@
--player itself
parser:add_buff_uptime(token, time, sourceSerial, sourceName, sourceFlags, targetSerial, targetName, targetFlags, targetFlags2, spellId, spellName, "BUFF_UPTIME_IN")
elseif (container_pets[sourceSerial] and container_pets[sourceSerial][2] == targetSerial) then
elseif (petCache[sourceSerial] and petCache[sourceSerial][2] == targetSerial) then
--pet putting an aura on its owner
parser:add_buff_uptime(token, time, targetSerial, targetName, targetFlags, targetSerial, targetName, targetFlags, targetFlags2, spellId, spellName, "BUFF_UPTIME_IN")
@@ -2505,7 +2515,7 @@
--call record buffs uptime
parser:add_buff_uptime (token, time, sourceSerial, sourceName, sourceFlags, targetSerial, targetName, targetFlags, targetFlags2, spellId, spellName, "BUFF_UPTIME_REFRESH")
elseif (container_pets [sourceSerial] and container_pets [sourceSerial][2] == targetSerial) then
elseif (petCache [sourceSerial] and petCache [sourceSerial][2] == targetSerial) then
--um pet colocando uma aura do dono
parser:add_buff_uptime (token, time, targetSerial, targetName, targetFlags, targetSerial, targetName, targetFlags, targetFlags2, spellId, spellName, "BUFF_UPTIME_REFRESH")
@@ -2572,7 +2582,7 @@
elseif (sourceName == targetName and raid_members_cache[sourceSerial] and _in_combat) then
--call record buffs uptime
parser:add_buff_uptime(token, time, sourceSerial, sourceName, sourceFlags, targetSerial, targetName, targetFlags, targetFlags2, spellId, spellName, "BUFF_UPTIME_OUT")
elseif (container_pets[sourceSerial] and container_pets[sourceSerial][2] == targetSerial) then
elseif (petCache[sourceSerial] and petCache[sourceSerial][2] == targetSerial) then
--um pet colocando uma aura do dono
parser:add_buff_uptime(token, time, targetSerial, targetName, targetFlags, targetSerial, targetName, targetFlags, targetFlags2, spellId, spellName, "BUFF_UPTIME_OUT")
@@ -3425,14 +3435,12 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1
end
if (not ownerActor) then
petName, ownerName, ownerGUID, ownerFlags = Details.tabela_pets:GetPetOwner(sourceSerial, sourceName, sourceFlags)
petName, ownerName, ownerGUID, ownerFlags = petContainer.GetOwner(sourceSerial, targetName)
if (petName) then
ownerActor = _current_misc_container:GetOrCreateActor(ownerGUID, ownerName, ownerFlags, true)
end
end
--local sourceActor, ownerActor, sourceName = _current_misc_container:GetOrCreateActor(sourceSerial, sourceName, sourceFlags, true)
------------------------------------------------------------------------------------------------
--build containers on the fly
if (not sourceActor.interrupt) then
@@ -3920,6 +3928,11 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1
---@param targetName string
---@param targetFlags number
function parser:dead(token, time, sourceSerial, sourceName, sourceFlags, targetSerial, targetName, targetFlags)
---@cast Details222 details222
if (petContainer.Pets[targetSerial]) then
petContainer.RemovePet(targetSerial)
end
--early checks and fixes
if (not targetName) then
return
@@ -4939,6 +4952,9 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1
end
end
petContainer.Reset()
C_Timer.After(1, function() petContainer.PetScan("ENCOUNTER_END") end)
--tag item level of all players
local openRaidLib = LibStub:GetLibrary("LibOpenRaid-1.0", true)
local allPlayersGear = openRaidLib and openRaidLib.GetAllUnitsGear()
@@ -4966,8 +4982,8 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1
return true
end
function Details.parser_functions:UNIT_PET(...)
Details.container_pets:Unpet(...)
function Details.parser_functions:UNIT_PET(unitId)
petContainer.UNIT_PET(unitId)
Details:SchedulePetUpdate(1)
end
@@ -5483,7 +5499,7 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1
if (Details.in_group) then
--player entered in a group, cleanup and set the new enviromnent
Details222.GarbageCollector.RestartInternalGarbageCollector(true)
Details:WipePets()
petContainer.Reset()
Details:SchedulePetUpdate(1)
Details:InstanceCall(Details.AdjustAlphaByContext)
@@ -5503,7 +5519,7 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1
if (not Details.in_group) then
--player left the group, run routines to cleanup the environment
Details222.GarbageCollector.RestartInternalGarbageCollector(true)
Details:WipePets()
petContainer.Reset()
Details:SchedulePetUpdate(1)
Details:Destroy(Details.details_users)
Details:InstanceCall(Details.AdjustAlphaByContext)
@@ -5967,10 +5983,6 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1
_tempo = Details._tempo
end
function Details:UpdatePetsOnParser()
container_pets = Details.tabela_pets.pets
end
function Details:GetActorFromCache(value)
return damage_cache[value] or damage_cache_pets[value] or damage_cache_petsOwners[value]
end