Some code modernize on container actors

This commit is contained in:
Tercio Jose
2023-01-11 23:41:35 -03:00
parent d728c07cd5
commit 2bbb7be419
+145 -196
View File
@@ -1,27 +1,24 @@
-- actor container file -- actor container file
-- group members are the actors which will be shown in the window while in standard view mode, most of the times they are players in the same group as the player
local _detalhes = _G._detalhes local Details = _G._detalhes
local Details = _G.Details
local DF = _G.DetailsFramework local DF = _G.DetailsFramework
local _ local _
local addonName, Details222 = ... local addonName, Details222 = ...
local bIsDragonflight = DetailsFramework.IsDragonflight() local bIsDragonflight = DetailsFramework.IsDragonflight()
local CONST_CLIENT_LANGUAGE = DF.ClientLanguage local CONST_CLIENT_LANGUAGE = DF.ClientLanguage
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--local pointers --local pointers
local _UnitClass = UnitClass --api local
local _IsInInstance = IsInInstance --api local local _IsInInstance = IsInInstance --api local
local UnitGUID = UnitGUID --api local local UnitGUID = UnitGUID --api local
local strsplit = strsplit --api local local strsplit = strsplit --api local
local setmetatable = setmetatable --lua local local setmetatable = setmetatable --lua local
local _getmetatable = getmetatable --lua local local bitBand = bit.band --lua local
local _bit_band = bit.band --lua local local tableSort = table.sort --lua local
local _table_sort = table.sort --lua local
local ipairs = ipairs --lua local local ipairs = ipairs --lua local
local pairs = pairs --lua local local pairs = pairs --lua local
@@ -36,25 +33,24 @@
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--constants --constants
local actorContainer = _detalhes.container_combatentes local actorContainer = Details.container_combatentes
local alvo_da_habilidade = _detalhes.alvo_da_habilidade local alvo_da_habilidade = Details.alvo_da_habilidade
local atributo_damage = _detalhes.atributo_damage local atributo_damage = Details.atributo_damage
local atributo_heal = _detalhes.atributo_heal local atributo_heal = Details.atributo_heal
local atributo_energy = _detalhes.atributo_energy local atributo_energy = Details.atributo_energy
local atributo_misc = _detalhes.atributo_misc local atributo_misc = Details.atributo_misc
local container_playernpc = _detalhes.container_type.CONTAINER_PLAYERNPC local container_damage = Details.container_type.CONTAINER_DAMAGE_CLASS
local container_damage = _detalhes.container_type.CONTAINER_DAMAGE_CLASS local container_heal = Details.container_type.CONTAINER_HEAL_CLASS
local container_heal = _detalhes.container_type.CONTAINER_HEAL_CLASS local container_heal_target = Details.container_type.CONTAINER_HEALTARGET_CLASS
local container_heal_target = _detalhes.container_type.CONTAINER_HEALTARGET_CLASS local container_friendlyfire = Details.container_type.CONTAINER_FRIENDLYFIRE
local container_friendlyfire = _detalhes.container_type.CONTAINER_FRIENDLYFIRE local container_damage_target = Details.container_type.CONTAINER_DAMAGETARGET_CLASS
local container_damage_target = _detalhes.container_type.CONTAINER_DAMAGETARGET_CLASS local container_energy = Details.container_type.CONTAINER_ENERGY_CLASS
local container_energy = _detalhes.container_type.CONTAINER_ENERGY_CLASS local container_energy_target = Details.container_type.CONTAINER_ENERGYTARGET_CLASS
local container_energy_target = _detalhes.container_type.CONTAINER_ENERGYTARGET_CLASS local container_misc = Details.container_type.CONTAINER_MISC_CLASS
local container_misc = _detalhes.container_type.CONTAINER_MISC_CLASS local container_misc_target = Details.container_type.CONTAINER_MISCTARGET_CLASS
local container_misc_target = _detalhes.container_type.CONTAINER_MISCTARGET_CLASS local container_enemydebufftarget_target = Details.container_type.CONTAINER_ENEMYDEBUFFTARGET_CLASS
local container_enemydebufftarget_target = _detalhes.container_type.CONTAINER_ENEMYDEBUFFTARGET_CLASS
local container_pets = {} local container_pets = {}
@@ -183,25 +179,6 @@ end
end end
end end
end end
--[=[
if (tooltipData.lines[1].leftText == petName) then --should rely on the first line carrying the pet name?
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, 0x514
end
end
end
end
end
--]=]
end end
end end
@@ -211,7 +188,7 @@ end
if (actorNameString) then if (actorNameString) then
local actorName = actorNameString:GetText() local actorName = actorNameString:GetText()
if (actorName and type(actorName) == "string") then if (actorName and type(actorName) == "string") then
local isInRaid = _detalhes.tabela_vigente.raid_roster[actorName] local isInRaid = Details.tabela_vigente.raid_roster[actorName]
if (isInRaid) then if (isInRaid) then
ownerGUID = UnitGUID(actorName) ownerGUID = UnitGUID(actorName)
ownerName = actorName ownerName = actorName
@@ -219,7 +196,7 @@ end
else else
for playerName in actorName:gmatch("([^%s]+)") do for playerName in actorName:gmatch("([^%s]+)") do
playerName = playerName:gsub(",", "") playerName = playerName:gsub(",", "")
local playerIsOnRaidCache = _detalhes.tabela_vigente.raid_roster[playerName] local playerIsOnRaidCache = Details.tabela_vigente.raid_roster[playerName]
if (playerIsOnRaidCache) then if (playerIsOnRaidCache) then
ownerGUID = UnitGUID(playerName) ownerGUID = UnitGUID(playerName)
ownerName = playerName ownerName = playerName
@@ -327,49 +304,49 @@ end
end end
--try to get the actor class from name --try to get the actor class from name
local function get_actor_class (novo_objeto, nome, flag, serial) local getActorClass = function(actorObject, actorName, actorFlags, actorSerial)
--get spec --get spec
if (_detalhes.track_specs) then if (Details.track_specs) then
local have_cached = _detalhes.cached_specs [serial] local specId = Details.cached_specs[actorSerial]
if (have_cached) then if (specId) then
novo_objeto:SetSpecId(have_cached) actorObject:SetSpecId(specId)
--check is didn't changed the spec: --check is didn't changed the spec:
if (_detalhes.streamer_config.quick_detection) then if (Details.streamer_config.quick_detection) then
--validate the spec more times if on quick detection --validate the spec more times if on quick detection
_detalhes:ScheduleTimer("ReGuessSpec", 2, {novo_objeto}) Details:ScheduleTimer("ReGuessSpec", 2, {actorObject})
_detalhes:ScheduleTimer("ReGuessSpec", 4, {novo_objeto}) Details:ScheduleTimer("ReGuessSpec", 4, {actorObject})
_detalhes:ScheduleTimer("ReGuessSpec", 6, {novo_objeto}) Details:ScheduleTimer("ReGuessSpec", 6, {actorObject})
end end
_detalhes:ScheduleTimer("ReGuessSpec", 15, {novo_objeto}) Details:ScheduleTimer("ReGuessSpec", 15, {actorObject})
--print(nome, "spec em cache:", have_cached)
else else
if (_detalhes.streamer_config.quick_detection) then if (Details.streamer_config.quick_detection) then
--shoot detection early if in quick detection --shoot detection early if in quick detection
_detalhes:ScheduleTimer("GuessSpec", 1, {novo_objeto, nil, 1}) Details:ScheduleTimer("GuessSpec", 1, {actorObject, nil, 1})
else else
_detalhes:ScheduleTimer("GuessSpec", 3, {novo_objeto, nil, 1}) Details:ScheduleTimer("GuessSpec", 3, {actorObject, nil, 1})
end end
end end
end end
local _, engClass = _UnitClass(nome or "") local _, engClass = UnitClass(actorName or "")
if (engClass) then if (engClass) then
novo_objeto.classe = engClass actorObject.classe = engClass
return return
else else
if (flag) then if (actorFlags) then
--conferir se o jogador um player --check if the actor is a player
if (_bit_band (flag, OBJECT_TYPE_PLAYER) ~= 0) then if (bitBand(actorFlags, OBJECT_TYPE_PLAYER) ~= 0) then
novo_objeto.classe = "UNGROUPPLAYER" actorObject.classe = "UNGROUPPLAYER"
return return
elseif (_bit_band (flag, OBJECT_TYPE_PETGUARDIAN) ~= 0) then
novo_objeto.classe = "PET" elseif (bitBand(actorFlags, OBJECT_TYPE_PETGUARDIAN) ~= 0) then
actorObject.classe = "PET"
return return
end end
end end
novo_objeto.classe = "UNKNOW" actorObject.classe = "UNKNOW" --it's a typo, can't be changed at this point
return true return true
end end
end end
@@ -382,90 +359,85 @@ end
elseif (nickname:find(" ")) then elseif (nickname:find(" ")) then
return playerName return playerName
--elseif(#nickname > 14) then --cannot check for size as other alphabets uses 2 or 4 bytes to represent letters
-- return playerName
end end
else else
return playerName return playerName
end end
--remove scapes
--nickname = nickname:gsub("|","") --a bug report told about covenant icons plugin being broke, this like is probably the culprit
return nickname return nickname
end end
--read the actor flag --read the actor flag
local read_actor_flag = function(actorObject, dono_do_pet, serial, flag, nome, container_type) local readActorFlag = function(actorObject, ownerActorObject, actorSerial, actorFlags, actorName)
if (actorFlags) then
if (flag) then
--this is player actor --this is player actor
if (_bit_band (flag, OBJECT_TYPE_PLAYER) ~= 0) then if (bitBand(actorFlags, OBJECT_TYPE_PLAYER) ~= 0) then
if (not _detalhes.ignore_nicktag) then if (not Details.ignore_nicktag) then
actorObject.displayName = checkValidNickname(Details:GetNickname(nome, false, true), nome) --defaults to player name actorObject.displayName = checkValidNickname(Details:GetNickname(actorName, false, true), actorName) --defaults to player name
if (_detalhes.remove_realm_from_name) then if (Details.remove_realm_from_name) then
actorObject.displayName = actorObject.displayName:gsub(("%-.*"), "") actorObject.displayName = actorObject.displayName:gsub(("%-.*"), "")
end end
end end
if (not actorObject.displayName) then if (not actorObject.displayName) then
if (_detalhes.remove_realm_from_name) then if (Details.remove_realm_from_name) then
actorObject.displayName = nome:gsub(("%-.*"), "") actorObject.displayName = actorName:gsub(("%-.*"), "")
else else
actorObject.displayName = nome actorObject.displayName = actorName
end end
end end
if (_detalhes.all_players_are_group or _detalhes.immersion_enabled) then if (Details.all_players_are_group or Details.immersion_enabled) then
actorObject.grupo = true actorObject.grupo = true
end end
--special spells to add into the group view --special spells to add into the group view - they are set within the parser.lua file
local spellId = Details.SpecialSpellActorsName[actorObject.nome] local spellId = Details.SpecialSpellActorsName[actorObject.nome]
if (spellId) then if (spellId) then
actorObject.grupo = true actorObject.grupo = true
if (Details.KyrianWeaponSpellIds[spellId]) then if (Details.KyrianWeaponSpellIds[spellId]) then --can be deprecated
actorObject.spellicon = GetSpellTexture(Details.KyrianWeaponActorSpellId) actorObject.spellicon = GetSpellTexture(Details.KyrianWeaponActorSpellId)
actorObject.nome = Details.KyrianWeaponActorName actorObject.nome = Details.KyrianWeaponActorName
actorObject.displayName = Details.KyrianWeaponActorName actorObject.displayName = Details.KyrianWeaponActorName
actorObject.customColor = Details.KyrianWeaponColor actorObject.customColor = Details.KyrianWeaponColor
nome = Details.KyrianWeaponActorName actorName = Details.KyrianWeaponActorName
elseif (Details.GrimrailDepotCannonWeaponSpellIds[spellId]) then elseif (Details.GrimrailDepotCannonWeaponSpellIds[spellId]) then --can be deprecated
actorObject.spellicon = GetSpellTexture(Details.GrimrailDepotCannonWeaponActorSpellId) actorObject.spellicon = GetSpellTexture(Details.GrimrailDepotCannonWeaponActorSpellId)
actorObject.nome = Details.GrimrailDepotCannonWeaponActorName actorObject.nome = Details.GrimrailDepotCannonWeaponActorName
actorObject.displayName = Details.GrimrailDepotCannonWeaponActorName actorObject.displayName = Details.GrimrailDepotCannonWeaponActorName
actorObject.customColor = Details.GrimrailDepotCannonWeaponColor actorObject.customColor = Details.GrimrailDepotCannonWeaponColor
nome = Details.GrimrailDepotCannonWeaponActorName actorName = Details.GrimrailDepotCannonWeaponActorName
else else
actorObject.spellicon = GetSpellTexture(spellId) actorObject.spellicon = GetSpellTexture(spellId)
end end
end end
if ((_bit_band (flag, IS_GROUP_OBJECT) ~= 0 and actorObject.classe ~= "UNKNOW" and actorObject.classe ~= "UNGROUPPLAYER") or _detalhes:IsInCache(serial)) then --check if this actor can be flagged as a unit in the player's group
if ((bitBand(actorFlags, IS_GROUP_OBJECT) ~= 0 and actorObject.classe ~= "UNKNOW" and actorObject.classe ~= "UNGROUPPLAYER") or Details:IsInCache(actorSerial)) then
actorObject.grupo = true actorObject.grupo = true
--check if this actor is a tank (player)
if (_detalhes:IsATank(serial)) then if (Details:IsATank(actorSerial)) then
actorObject.isTank = true actorObject.isTank = true
end end
else else
if (_detalhes.pvp_as_group and (_detalhes.tabela_vigente and _detalhes.tabela_vigente.is_pvp) and _detalhes.is_in_battleground) then --if this is a pvp segment (combat) and the option to show pvp players as group is enabled
if (Details.pvp_as_group and (Details.tabela_vigente and Details.tabela_vigente.is_pvp) and Details.is_in_battleground) then
actorObject.grupo = true actorObject.grupo = true
end end
end end
--pvp duel --pvp duel - this functionality needs more development, the goal is to show the duel players as group members
if (_detalhes.duel_candidates [serial]) then if (Details.duel_candidates[actorSerial]) then
--check if is recent --check if is recent
if (_detalhes.duel_candidates [serial]+20 > GetTime()) then if (Details.duel_candidates[actorSerial]+20 > GetTime()) then
actorObject.grupo = true actorObject.grupo = true
actorObject.enemy = true actorObject.enemy = true
end end
end end
if (_detalhes.is_in_arena) then if (Details.is_in_arena) then
--local my_team_color = GetBattlefieldArenaFaction and GetBattlefieldArenaFaction() or 0 --local my_team_color = GetBattlefieldArenaFaction and GetBattlefieldArenaFaction() or 0
--my team --my team
@@ -479,16 +451,16 @@ end
actorObject.arena_enemy = true actorObject.arena_enemy = true
actorObject.arena_team = 1 -- former my_team_color actorObject.arena_team = 1 -- former my_team_color
Details:GuessArenaEnemyUnitId(nome) Details:GuessArenaEnemyUnitId(actorName)
end end
local arena_props = _detalhes.arena_table [nome] local playerArenaInfo = Details.arena_table[actorName]
if (arena_props) then if (playerArenaInfo) then
actorObject.role = arena_props.role actorObject.role = playerArenaInfo.role
if (arena_props.role == "NONE") then if (playerArenaInfo.role == "NONE") then
local role = UnitGroupRolesAssigned and UnitGroupRolesAssigned(nome) local role = UnitGroupRolesAssigned and UnitGroupRolesAssigned(actorName)
if (role and role ~= "NONE") then if (role and role ~= "NONE") then
actorObject.role = role actorObject.role = role
end end
@@ -498,10 +470,10 @@ end
local found = false local found = false
for i = 1, oponentes do for i = 1, oponentes do
local name = GetUnitName("arena" .. i, true) local name = GetUnitName("arena" .. i, true)
if (name == nome) then if (name == actorName) then
local spec = GetArenaOpponentSpec and GetArenaOpponentSpec (i) local spec = GetArenaOpponentSpec and GetArenaOpponentSpec(i)
if (spec) then if (spec) then
local id, name, description, icon, role, class = DetailsFramework.GetSpecializationInfoByID (spec) --thanks pas06 local id, name, description, icon, role, class = DetailsFramework.GetSpecializationInfoByID(spec) --thanks pas06
actorObject.role = role actorObject.role = role
actorObject.classe = class actorObject.classe = class
actorObject.enemy = true actorObject.enemy = true
@@ -511,19 +483,18 @@ end
end end
end end
local role = UnitGroupRolesAssigned and UnitGroupRolesAssigned(nome) local role = UnitGroupRolesAssigned and UnitGroupRolesAssigned(actorName)
if (role and role ~= "NONE") then if (role and role ~= "NONE") then
actorObject.role = role actorObject.role = role
found = true found = true
end end
if (not found and nome == _detalhes.playername) then if (not found and actorName == Details.playername) then
local role = UnitGroupRolesAssigned("player") local role = UnitGroupRolesAssigned("player")
if (role and role ~= "NONE") then if (role and role ~= "NONE") then
actorObject.role = role actorObject.role = role
end end
end end
end end
actorObject.grupo = true actorObject.grupo = true
@@ -532,75 +503,53 @@ end
--player custom bar color --player custom bar color
--at this position in the code, the color will replace colors from arena matches --at this position in the code, the color will replace colors from arena matches
if (Details.use_self_color) then if (Details.use_self_color) then
if (nome == _detalhes.playername) then if (actorName == Details.playername) then
actorObject.customColor = Details.class_colors.SELF actorObject.customColor = Details.class_colors.SELF
end end
end end
-- um pet --does this actor has an owner?
elseif (dono_do_pet) then elseif (ownerActorObject) then
actorObject.owner = dono_do_pet actorObject.owner = ownerActorObject
actorObject.ownerName = dono_do_pet.nome actorObject.ownerName = ownerActorObject.nome
if (_IsInInstance() and _detalhes.remove_realm_from_name) then if (_IsInInstance() and Details.remove_realm_from_name) then
actorObject.displayName = nome:gsub(("%-.*"), ">") actorObject.displayName = actorName:gsub(("%-.*"), ">")
else else
actorObject.displayName = nome actorObject.displayName = actorName
end end
--local pet_npc_template = _detalhes:GetNpcIdFromGuid (serial)
--if (pet_npc_template == 86933) then --viviane
-- actorObject.grupo = true
--end
else else
--anything else that isn't a player or a pet --anything else that isn't a player or a pet
actorObject.displayName = nome actorObject.displayName = actorName
--[=[
--Chromie - From 'The Deaths of Chromie'
if (serial and type(serial) == "string") then
if (serial:match ("^Creature%-0%-%d+%-%d+%-%d+%-122663%-%w+$")) then
actorObject.grupo = true
end
end
--]=]
end end
--check if is hostile --check if is hostile
if (_bit_band (flag, REACTION_HOSTILE) ~= 0) then if (bitBand(actorFlags, REACTION_HOSTILE) ~= 0) then
if (bitBand(actorFlags, OBJECT_TYPE_PLAYER) == 0) then
if (_bit_band (flag, OBJECT_TYPE_PLAYER) == 0) then
--is hostile and isn't a player --is hostile and isn't a player
if (bitBand(actorFlags, OBJECT_TYPE_PETGUARDIAN) == 0) then
if (_bit_band (flag, OBJECT_TYPE_PETGUARDIAN) == 0) then
--isn't a pet or guardian --isn't a pet or guardian
actorObject.monster = true actorObject.monster = true
end end
if (serial and type(serial) == "string") then if (actorSerial and type(actorSerial) == "string") then
local npcID = _detalhes:GetNpcIdFromGuid (serial) local npcID = Details:GetNpcIdFromGuid(actorSerial)
if (npcID and not _detalhes.npcid_pool [npcID] and type(npcID) == "number") then if (npcID and not Details.npcid_pool[npcID] and type(npcID) == "number") then
_detalhes.npcid_pool [npcID] = nome Details.npcid_pool [npcID] = actorName
end end
end end
end end
end end
end end
end end
local petBlackList = {} local petBlackList = {}
local pet_text_object = _G ["DetailsPetOwnerFinderTextLeft2"] --not in use
local follower_text_object = _G ["DetailsPetOwnerFinderTextLeft3"] --not in use
local petOwnerFound = function(ownerName, petGUID, petName, petFlags, self, ownerGUID) local petOwnerFound = function(ownerName, petGUID, petName, petFlags, self, ownerGUID)
local ownerGuid = ownerGUID or UnitGUID(ownerName) local ownerGuid = ownerGUID or UnitGUID(ownerName)
if (ownerGuid) then if (ownerGuid) then
_detalhes.tabela_pets:Adicionar(petGUID, petName, petFlags, ownerGuid, ownerName, 0x00000417) Details.tabela_pets:Adicionar(petGUID, petName, petFlags, ownerGuid, ownerName, 0x00000417)
local petNameWithOwner, ownerName, ownerGUID, ownerFlags = _detalhes.tabela_pets:PegaDono(petGUID, petName, petFlags) local petNameWithOwner, ownerName, ownerGUID, ownerFlags = Details.tabela_pets:PegaDono(petGUID, petName, petFlags)
local petOwnerActorObject local petOwnerActorObject
@@ -630,7 +579,7 @@ end
end end
local find_pet_owner = function(petGUID, petName, petFlags, self) local find_pet_owner = function(petGUID, petName, petFlags, self)
if (not _detalhes.tabela_vigente) then if (not Details.tabela_vigente) then
return return
end end
@@ -664,7 +613,7 @@ end
local text1 = line1 and line1:GetText() local text1 = line1 and line1:GetText()
if (text1 and text1 ~= "") then if (text1 and text1 ~= "") then
--for _, playerName in ipairs(Details.tabela_vigente.raid_roster_indexed) do --for _, playerName in ipairs(Details.tabela_vigente.raid_roster_indexed) do
for playerName, _ in pairs(_detalhes.tabela_vigente.raid_roster) do for playerName, _ in pairs(Details.tabela_vigente.raid_roster) do
local pName = playerName local pName = playerName
playerName = playerName:gsub("%-.*", "") --remove realm name playerName = playerName:gsub("%-.*", "") --remove realm name
@@ -686,7 +635,7 @@ end
else else
local ownerName = (string.match(text1, string.gsub(UNITNAME_TITLE_PET, "%%s", "(%.*)")) or string.match(text1, string.gsub(UNITNAME_TITLE_MINION, "%%s", "(%.*)")) or string.match(text1, string.gsub(UNITNAME_TITLE_GUARDIAN, "%%s", "(%.*)"))) local ownerName = (string.match(text1, string.gsub(UNITNAME_TITLE_PET, "%%s", "(%.*)")) or string.match(text1, string.gsub(UNITNAME_TITLE_MINION, "%%s", "(%.*)")) or string.match(text1, string.gsub(UNITNAME_TITLE_GUARDIAN, "%%s", "(%.*)")))
if (ownerName) then if (ownerName) then
if (_detalhes.tabela_vigente.raid_roster[ownerName]) then if (Details.tabela_vigente.raid_roster[ownerName]) then
return petOwnerFound (ownerName, petGUID, petName, petFlags, self) return petOwnerFound (ownerName, petGUID, petName, petFlags, self)
end end
end end
@@ -698,7 +647,7 @@ end
local line2 = _G ["DetailsPetOwnerFinderTextLeft3"] local line2 = _G ["DetailsPetOwnerFinderTextLeft3"]
local text2 = line2 and line2:GetText() local text2 = line2 and line2:GetText()
if (text2 and text2 ~= "") then if (text2 and text2 ~= "") then
for playerName, _ in pairs(_detalhes.tabela_vigente.raid_roster) do for playerName, _ in pairs(Details.tabela_vigente.raid_roster) do
--for _, playerName in ipairs(Details.tabela_vigente.raid_roster_indexed) do --for _, playerName in ipairs(Details.tabela_vigente.raid_roster_indexed) do
local pName = playerName local pName = playerName
playerName = playerName:gsub("%-.*", "") --remove realm name playerName = playerName:gsub("%-.*", "") --remove realm name
@@ -718,7 +667,7 @@ end
else else
local ownerName = (string.match(text2, string.gsub(UNITNAME_TITLE_PET, "%%s", "(%.*)")) or string.match(text2, string.gsub(UNITNAME_TITLE_MINION, "%%s", "(%.*)")) or string.match(text2, string.gsub(UNITNAME_TITLE_GUARDIAN, "%%s", "(%.*)"))) local ownerName = (string.match(text2, string.gsub(UNITNAME_TITLE_PET, "%%s", "(%.*)")) or string.match(text2, string.gsub(UNITNAME_TITLE_MINION, "%%s", "(%.*)")) or string.match(text2, string.gsub(UNITNAME_TITLE_GUARDIAN, "%%s", "(%.*)")))
if (ownerName) then if (ownerName) then
if (_detalhes.tabela_vigente.raid_roster[ownerName]) then if (Details.tabela_vigente.raid_roster[ownerName]) then
return petOwnerFound (ownerName, petGUID, petName, petFlags, self) return petOwnerFound (ownerName, petGUID, petName, petFlags, self)
end end
end end
@@ -755,7 +704,7 @@ end
if (container_pets[serial]) then -- um pet reconhecido if (container_pets[serial]) then -- um pet reconhecido
--[[statistics]]-- _detalhes.statistics.container_pet_calls = _detalhes.statistics.container_pet_calls + 1 --[[statistics]]-- _detalhes.statistics.container_pet_calls = _detalhes.statistics.container_pet_calls + 1
local petName, ownerName, ownerGUID, ownerFlag = _detalhes.tabela_pets:PegaDono (serial, nome, flag) local petName, ownerName, ownerGUID, ownerFlag = Details.tabela_pets:PegaDono (serial, nome, flag)
if (petName and ownerName) then if (petName and ownerName) then
nome = petName nome = petName
dono_do_pet = self:PegarCombatente(ownerGUID, ownerName, ownerFlag, true) dono_do_pet = self:PegarCombatente(ownerGUID, ownerName, ownerFlag, true)
@@ -765,7 +714,7 @@ end
petBlackList[serial] = true petBlackList[serial] = true
--try to find the owner --try to find the owner
if (flag and _bit_band(flag, OBJECT_TYPE_PETGUARDIAN) ~= 0) then if (flag and bitBand(flag, OBJECT_TYPE_PETGUARDIAN) ~= 0) then
--[[statistics]]-- _detalhes.statistics.container_unknow_pet = _detalhes.statistics.container_unknow_pet + 1 --[[statistics]]-- _detalhes.statistics.container_unknow_pet = _detalhes.statistics.container_unknow_pet + 1
local find_nome, find_owner = find_pet_owner(serial, nome, flag, self) local find_nome, find_owner = find_pet_owner(serial, nome, flag, self)
if (find_nome and find_owner) then if (find_nome and find_owner) then
@@ -825,28 +774,28 @@ end
if (self.tipo == container_damage) then --CONTAINER DAMAGE if (self.tipo == container_damage) then --CONTAINER DAMAGE
local shouldScanOnce = get_actor_class (novo_objeto, nome, flag, serial) local shouldScanOnce = getActorClass (novo_objeto, nome, flag, serial)
read_actor_flag (novo_objeto, dono_do_pet, serial, flag, nome, "damage") readActorFlag (novo_objeto, dono_do_pet, serial, flag, nome, "damage")
if (dono_do_pet) then if (dono_do_pet) then
AddUnique (dono_do_pet.pets, nome) AddUnique (dono_do_pet.pets, nome)
end end
if (self.shadow) then if (self.shadow) then
if (novo_objeto.grupo and _detalhes.in_combat) then if (novo_objeto.grupo and Details.in_combat) then
_detalhes.cache_damage_group [#_detalhes.cache_damage_group+1] = novo_objeto Details.cache_damage_group [#Details.cache_damage_group+1] = novo_objeto
end end
end end
if (novo_objeto.classe == "UNGROUPPLAYER") then --is a player if (novo_objeto.classe == "UNGROUPPLAYER") then --is a player
if (_bit_band (flag, REACTION_HOSTILE ) ~= 0) then --is hostile if (bitBand (flag, REACTION_HOSTILE ) ~= 0) then --is hostile
novo_objeto.enemy = true novo_objeto.enemy = true
end end
--try to guess his class --try to guess his class
if (self.shadow) then --no executar 2x if (self.shadow) then --no executar 2x
_detalhes:ScheduleTimer("GuessClass", 1, {novo_objeto, self, 1}) Details:ScheduleTimer("GuessClass", 1, {novo_objeto, self, 1})
end end
elseif (shouldScanOnce) then elseif (shouldScanOnce) then
@@ -855,73 +804,73 @@ end
end end
if (novo_objeto.isTank) then if (novo_objeto.isTank) then
novo_objeto.avoidance = _detalhes:CreateActorAvoidanceTable() novo_objeto.avoidance = Details:CreateActorAvoidanceTable()
end end
elseif (self.tipo == container_heal) then --CONTAINER HEALING elseif (self.tipo == container_heal) then --CONTAINER HEALING
local shouldScanOnce = get_actor_class (novo_objeto, nome, flag, serial) local shouldScanOnce = getActorClass (novo_objeto, nome, flag, serial)
read_actor_flag (novo_objeto, dono_do_pet, serial, flag, nome, "heal") readActorFlag (novo_objeto, dono_do_pet, serial, flag, nome, "heal")
if (dono_do_pet) then if (dono_do_pet) then
AddUnique (dono_do_pet.pets, nome) AddUnique (dono_do_pet.pets, nome)
end end
if (self.shadow) then if (self.shadow) then
if (novo_objeto.grupo and _detalhes.in_combat) then if (novo_objeto.grupo and Details.in_combat) then
_detalhes.cache_healing_group [#_detalhes.cache_healing_group+1] = novo_objeto Details.cache_healing_group [#Details.cache_healing_group+1] = novo_objeto
end end
end end
if (novo_objeto.classe == "UNGROUPPLAYER") then --is a player if (novo_objeto.classe == "UNGROUPPLAYER") then --is a player
if (_bit_band (flag, REACTION_HOSTILE ) ~= 0) then --is hostile if (bitBand (flag, REACTION_HOSTILE ) ~= 0) then --is hostile
novo_objeto.enemy = true --print(nome.." EH UM INIMIGO -> " .. engRace) novo_objeto.enemy = true --print(nome.." EH UM INIMIGO -> " .. engRace)
end end
--try to guess his class --try to guess his class
if (self.shadow) then --no executar 2x if (self.shadow) then --no executar 2x
_detalhes:ScheduleTimer("GuessClass", 1, {novo_objeto, self, 1}) Details:ScheduleTimer("GuessClass", 1, {novo_objeto, self, 1})
end end
end end
elseif (self.tipo == container_energy) then --CONTAINER ENERGY elseif (self.tipo == container_energy) then --CONTAINER ENERGY
local shouldScanOnce = get_actor_class (novo_objeto, nome, flag, serial) local shouldScanOnce = getActorClass (novo_objeto, nome, flag, serial)
read_actor_flag (novo_objeto, dono_do_pet, serial, flag, nome, "energy") readActorFlag (novo_objeto, dono_do_pet, serial, flag, nome, "energy")
if (dono_do_pet) then if (dono_do_pet) then
AddUnique (dono_do_pet.pets, nome) AddUnique (dono_do_pet.pets, nome)
end end
if (novo_objeto.classe == "UNGROUPPLAYER") then --is a player if (novo_objeto.classe == "UNGROUPPLAYER") then --is a player
if (_bit_band (flag, REACTION_HOSTILE ) ~= 0) then --is hostile if (bitBand (flag, REACTION_HOSTILE ) ~= 0) then --is hostile
novo_objeto.enemy = true novo_objeto.enemy = true
end end
--try to guess his class --try to guess his class
if (self.shadow) then --no executar 2x if (self.shadow) then --no executar 2x
_detalhes:ScheduleTimer("GuessClass", 1, {novo_objeto, self, 1}) Details:ScheduleTimer("GuessClass", 1, {novo_objeto, self, 1})
end end
end end
elseif (self.tipo == container_misc) then --CONTAINER MISC elseif (self.tipo == container_misc) then --CONTAINER MISC
local shouldScanOnce = get_actor_class (novo_objeto, nome, flag, serial) local shouldScanOnce = getActorClass (novo_objeto, nome, flag, serial)
read_actor_flag (novo_objeto, dono_do_pet, serial, flag, nome, "misc") readActorFlag (novo_objeto, dono_do_pet, serial, flag, nome, "misc")
if (dono_do_pet) then if (dono_do_pet) then
AddUnique (dono_do_pet.pets, nome) AddUnique (dono_do_pet.pets, nome)
end end
if (novo_objeto.classe == "UNGROUPPLAYER") then --is a player if (novo_objeto.classe == "UNGROUPPLAYER") then --is a player
if (_bit_band (flag, REACTION_HOSTILE ) ~= 0) then --is hostile if (bitBand (flag, REACTION_HOSTILE ) ~= 0) then --is hostile
novo_objeto.enemy = true novo_objeto.enemy = true
end end
--try to guess his class --try to guess his class
if (self.shadow) then --no executar 2x if (self.shadow) then --no executar 2x
_detalhes:ScheduleTimer("GuessClass", 1, {novo_objeto, self, 1}) Details:ScheduleTimer("GuessClass", 1, {novo_objeto, self, 1})
end end
end end
@@ -945,7 +894,7 @@ end
elseif (self.tipo == container_friendlyfire) then --CONTAINER FRIENDLY FIRE elseif (self.tipo == container_friendlyfire) then --CONTAINER FRIENDLY FIRE
local shouldScanOnce = get_actor_class (novo_objeto, nome, serial) local shouldScanOnce = getActorClass (novo_objeto, nome, serial)
end end
@@ -960,12 +909,12 @@ end
self._ActorTable [size] = novo_objeto --grava na tabela de indexes self._ActorTable [size] = novo_objeto --grava na tabela de indexes
self._NameIndexTable [nome] = size --grava no hash map o index deste jogador self._NameIndexTable [nome] = size --grava no hash map o index deste jogador
if (_detalhes.is_in_battleground or _detalhes.is_in_arena) then if (Details.is_in_battleground or Details.is_in_arena) then
novo_objeto.pvp = true novo_objeto.pvp = true
end end
if (_detalhes.debug) then if (Details.debug) then
if (_detalhes.debug_chr and nome:find(_detalhes.debug_chr) and self.tipo == 1) then if (Details.debug_chr and nome:find(Details.debug_chr) and self.tipo == 1) then
local logLine = "" local logLine = ""
local when = "[" .. date ("%H:%M:%S") .. format(".%4f", GetTime()-floor(GetTime())) .. "]" local when = "[" .. date ("%H:%M:%S") .. format(".%4f", GetTime()-floor(GetTime())) .. "]"
local log = "actor created - class: " .. (novo_objeto.classe or "noclass") local log = "actor created - class: " .. (novo_objeto.classe or "noclass")
@@ -991,22 +940,22 @@ end
--core --core
--_detalhes:AddToNpcIdCache (novo_objeto) --_detalhes:AddToNpcIdCache (novo_objeto)
function _detalhes:AddToNpcIdCache (actor) function Details:AddToNpcIdCache (actor)
if (flag and serial) then if (flag and serial) then
if (_bit_band (flag, REACTION_HOSTILE) ~= 0 and _bit_band (flag, OBJECT_TYPE_NPC) ~= 0 and _bit_band (flag, OBJECT_TYPE_PETGUARDIAN) == 0) then if (bitBand (flag, REACTION_HOSTILE) ~= 0 and bitBand (flag, OBJECT_TYPE_NPC) ~= 0 and bitBand (flag, OBJECT_TYPE_PETGUARDIAN) == 0) then
local npc_id = _detalhes:GetNpcIdFromGuid (serial) local npc_id = Details:GetNpcIdFromGuid (serial)
if (npc_id) then if (npc_id) then
_detalhes.cache_npc_ids [npc_id] = nome Details.cache_npc_ids [npc_id] = nome
end end
end end
end end
end end
function _detalhes:UpdateContainerCombatentes() function Details:UpdateContainerCombatentes()
container_pets = _detalhes.tabela_pets.pets container_pets = Details.tabela_pets.pets
_detalhes:UpdatePetsOnParser() Details:UpdatePetsOnParser()
end end
function _detalhes:ClearCCPetsBlackList() function Details:ClearCCPetsBlackList()
table.wipe(petBlackList) table.wipe(petBlackList)
end end
@@ -1056,7 +1005,7 @@ end
function actorContainer:SortByKey (key) function actorContainer:SortByKey (key)
assert(type(key) == "string", "Container:SortByKey() expects a keyname on parameter 1.") assert(type(key) == "string", "Container:SortByKey() expects a keyname on parameter 1.")
bykey = key bykey = key
_table_sort (self._ActorTable, sort) tableSort (self._ActorTable, sort)
self:remapear() self:remapear()
end end
@@ -1072,10 +1021,10 @@ end
end end
end end
function _detalhes.refresh:r_container_combatentes (container, shadow) function Details.refresh:r_container_combatentes (container, shadow)
--reconstri meta e indexes --reconstri meta e indexes
setmetatable(container, _detalhes.container_combatentes) setmetatable(container, Details.container_combatentes)
container.__index = _detalhes.container_combatentes container.__index = Details.container_combatentes
container.funcao_de_criacao = actorContainer:FuncaoDeCriacao (container.tipo) container.funcao_de_criacao = actorContainer:FuncaoDeCriacao (container.tipo)
--repara mapa --repara mapa
@@ -1089,13 +1038,13 @@ end
container.shadow = shadow container.shadow = shadow
end end
function _detalhes.clear:c_container_combatentes (container) function Details.clear:c_container_combatentes (container)
container.__index = nil container.__index = nil
container.shadow = nil container.shadow = nil
--container._NameIndexTable = nil --container._NameIndexTable = nil
container.need_refresh = nil container.need_refresh = nil
container.funcao_de_criacao = nil container.funcao_de_criacao = nil
end end
function _detalhes.clear:c_container_combatentes_index (container) function Details.clear:c_container_combatentes_index (container)
container._NameIndexTable = nil container._NameIndexTable = nil
end end