Skip to content

Commit

Permalink
added exclusive function for pet detection
Browse files Browse the repository at this point in the history
  • Loading branch information
Tercioo committed Dec 12, 2022
1 parent 641e5cf commit dc1d276
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 31 deletions.
3 changes: 3 additions & 0 deletions boot.lua
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@
--namespace for texture
Details222.Textures = {}

--namespace for pet
Details222.Pets = {}

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--initialization stuff
local _
Expand Down
90 changes: 59 additions & 31 deletions classes/container_actors.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
local GetNumDeclensionSets = _G.GetNumDeclensionSets
local DeclineName = _G.DeclineName

local pet_tooltip_frame = _G.DetailsPetOwnerFinder

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--constants

Expand Down Expand Up @@ -95,6 +97,63 @@
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--api functions

function Details222.Pets.GetPetOwner(petGUID, petName)
pet_tooltip_frame:SetOwner(WorldFrame, "ANCHOR_NONE")
pet_tooltip_frame:SetHyperlink(("unit:" .. petGUID) or "")

if (bIsDragonflight) then
local tooltipData = pet_tooltip_frame:GetTooltipData()
if (tooltipData and tooltipData.lines[1]) then
if (tooltipData.lines[1].leftText == petName) then
for i = 2, #tooltipData.lines do
local tooltipLine = tooltipData.lines[i]
local args = tooltipLine.args
if (args) then
if (args[4] and args[4].field == "guid") then
local ownerGUID = args[4].guidVal
local guidCache = Details:GetParserPlayerCache()
local ownerName = guidCache[ownerGUID]
if (ownerName) then
return ownerName, ownerGUID
end
end
end
end
end
end
end

local actorNameString = _G["DetailsPetOwnerFinderTextLeft1"]
local ownerName, ownerGUID, ownerFlags

if (actorNameString) then
local actorName = actorNameString:GetText()
if (actorName and type(actorName) == "string") then
local isInRaid = _detalhes.tabela_vigente.raid_roster[actorName]
if (isInRaid) then
ownerGUID = UnitGUID(actorName)
ownerName = actorName
ownerFlags = 0x514
else
for playerName in actorName:gmatch("([^%s]+)") do
playerName = playerName:gsub(",", "")
local playerIsOnRaidCache = _detalhes.tabela_vigente.raid_roster[playerName]
if (playerIsOnRaidCache) then
ownerGUID = UnitGUID(playerName)
ownerName = playerName
ownerFlags = 0x514
break
end
end
end
end
end

if (ownerGUID) then
return ownerName, ownerGUID, ownerFlags
end
end

function container_combatentes:GetActor(actorName)
local index = self._NameIndexTable [actorName]
if (index) then
Expand Down Expand Up @@ -437,7 +496,6 @@
end

local petBlackList = {}
local pet_tooltip_frame = _G.DetailsPetOwnerFinder
local pet_text_object = _G ["DetailsPetOwnerFinderTextLeft2"] --not in use
local follower_text_object = _G ["DetailsPetOwnerFinderTextLeft3"] --not in use

Expand Down Expand Up @@ -589,36 +647,6 @@

local npcId = Details:GetNpcIdFromGuid(serial or "")

--fix for rogue secret technich, can also be fixed by getting the time of the rogue's hit as the other hits go right after
if (npcId == 144961) then
pet_tooltip_frame:SetOwner(WorldFrame, "ANCHOR_NONE")
pet_tooltip_frame:SetHyperlink(("unit:" .. serial) or "")

local pname = _G["DetailsPetOwnerFinderTextLeft1"]
if (pname) then
local text = pname:GetText()
if (text and type(text) == "string") then
local isInRaid = _detalhes.tabela_vigente.raid_roster[text]
if (isInRaid) then
serial = UnitGUID(text)
nome = text
flag = 0x514
else
for playerName in text:gmatch("([^%s]+)") do
playerName = playerName:gsub(",", "")
local playerIsOnRaidCache = _detalhes.tabela_vigente.raid_roster[playerName]
if (playerIsOnRaidCache) then
serial = UnitGUID(playerName)
nome = playerName
flag = 0x514
break
end
end
end
end
end
end

--verifica se � um pet, se for confere se tem o nome do dono, se n�o tiver, precisa por
local dono_do_pet
serial = serial or "ns"
Expand Down
14 changes: 14 additions & 0 deletions core/parser.lua
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,20 @@
who_serial = "Creature-0-3134-2289-28065-" .. spellid .. "-000164C698"
end

--if (spellname:find("Secret")) then --debug
--print(time, spellid, spellname, who_serial, who_name, who_flags)
--end

--secret technique
if (spellid == 282449) then
local ownerName, ownerGUID, ownerFlags = Details222.Pets.GetPetOwner(who_serial, who_name)
if (ownerName and ownerGUID) then
who_serial = ownerGUID
who_name = ownerName
who_flags = ownerFlags
end
end

------------------------------------------------------------------------------------------------
--spell reflection
if (who_serial == alvo_serial and not reflection_ignore[spellid]) then --~reflect
Expand Down

0 comments on commit dc1d276

Please sign in to comment.