More naming conventions and variables translations for container actors

This commit is contained in:
Tercio Jose
2023-01-12 15:36:22 -03:00
parent 2bbb7be419
commit 764b779813
8 changed files with 164 additions and 212 deletions
+1 -1
View File
@@ -117,4 +117,4 @@ local spamLimit = {}
spamLimit["openRaidLib.cooldownManager.GetPlayerCooldowns"] = true
end
end
setmetatable(openRaidLib.cooldownManager, deprecatedMetatable)
setmetatable(openRaidLib.cooldownManager, deprecatedMetatable)
+1 -1
View File
@@ -511,4 +511,4 @@ function openRaidLib.GearManager.BuildEquipmentItemLinks(equippedGearList)
end
end
end
end
end
+8 -9
View File
@@ -701,13 +701,12 @@ end
--@spellId: the spellId to check for cooldown
--return timeLeft, charges, startTimeOffset, duration, buffDuration
function openRaidLib.CooldownManager.GetPlayerCooldownStatus(spellId)
--get the cooldown info from the cooldowns database of the lib
--check if is a charge spell
local cooldownInfo = LIB_OPEN_RAID_COOLDOWNS_INFO[spellId]
if (cooldownInfo) then
local buffDuration = getAuraDuration(spellId)
local chargesAvailable, chargesTotal, start, duration = GetSpellCharges(spellId)
if (chargesAvailable) then
if chargesAvailable then
if (chargesAvailable == chargesTotal) then
return 0, chargesTotal, 0, 0, 0 --all charges are ready to use
else
@@ -717,13 +716,13 @@ function openRaidLib.CooldownManager.GetPlayerCooldownStatus(spellId)
return ceil(timeLeft), chargesAvailable, startTimeOffset, duration, buffDuration --time left, charges, startTime, duration, buffDuration
end
else
local startTime, cooldownDuration = GetSpellCooldown(spellId)
if (startTime == 0) then --cooldown is ready
local start, duration = GetSpellCooldown(spellId)
if (start == 0) then --cooldown is ready
return 0, 1, 0, 0, 0 --time left, charges, startTime
else
local timeLeft = startTime + cooldownDuration - GetTime()
local startTimeOffset = startTime - GetTime()
return ceil(timeLeft), 0, ceil(startTimeOffset), cooldownDuration, buffDuration --time left, charges, startTime, duration, buffDuration
local timeLeft = start + duration - GetTime()
local startTimeOffset = start - GetTime()
return ceil(timeLeft), 0, ceil(startTimeOffset), duration, buffDuration --time left, charges, startTime, duration, buffDuration
end
end
else
@@ -861,4 +860,4 @@ openRaidLib.specAttribute = {
[1467] = 1, --Devastation
[1468] = 1, --Preservation
},
}
}
+97 -142
View File
@@ -2,7 +2,7 @@
--[=[
Please refer to the docs.txt within this file folder for a guide on how to use this library.
If you get lost on implementing the lib, be free to contact Tercio on Details! discord: https://discord.gg/AGSzAZX or email to terciob19@hotmail.com
If you get lost on implementing the lib, be free to contact Tercio on Details! discord: https://discord.gg/AGSzAZX or email to terciob@gmail.com
UnitID:
UnitID use: "player", "target", "raid18", "party3", etc...
@@ -14,6 +14,23 @@ Code Rules:
- Internal callbacks are the internal communication of the library, e.g. when an event triggers it send to all modules that registered that event.
- Public callbacks are callbacks registered by an external addon.
Change Log (most recent on 2022 Nov 18):
- added racials with cooldown type 9
- added buff duration in the index 6 of the cooldownInfo table returned on any cooldown event
- added 'durationSpellId' for cooldowns where the duration effect is another spell other than the casted cooldown spellId, add this member on cooldown table at LIB_OPEN_RAID_COOLDOWNS_INFO
------- Nov 07 and older
- added:
* added openRaidLib.GetSpellFilters(spellId, defaultFilterOnly, customFiltersOnly) (see docs)
- passing a spellId of a non registered cooldown on LIB_OPEN_RAID_COOLDOWNS_INFO will trigger a diagnostic error if diagnostic errors are enabled.
- player cast doesn't check anymore for cooldowns in the player spec, now it check towards the cache LIB_OPEN_RAID_PLAYERCOOLDOWNS.
LIB_OPEN_RAID_PLAYERCOOLDOWNS is a cache built with cooldowns present in the player spellbook.
- things to maintain now has 1 file per expansion
- player conduits, covenant internally renamed to playerInfo1 and playerInfo2 to make the lib more future proof
- player conduits tree is now Borrowed Talents Tree, for future proof
- removed the talent size limitation on 7 indexes
- added:
* openRaidLib.GetFlaskInfoBySpellId(spellId)
* openRaidLib.GetFlaskTierFromAura(auraInfo)
@@ -22,14 +39,14 @@ Code Rules:
* added dragonflight talents support
* added openRaidLib.RequestCooldownInfo(spellId)
* added openRaidLib.AddCooldownFilter(filterName, spells)
- ensure to register events after 'PLAYER_ENTERING_WORLD' has triggered
TODO:
- [not required as the lib is passing the entire gear equipped] add into gear info how many tier set parts the player has
- add into gear info how many tier set parts the player has
- raid lockouts normal-heroic-mythic
BUGS:
- after a /reload, it is not starting new tickers for spells under cooldown
- (asakawa report) after receiving a comm, the callback is firing twice
--]=]
@@ -47,7 +64,8 @@ if (WOW_PROJECT_ID ~= WOW_PROJECT_MAINLINE and not isExpansion_Dragonflight()) t
end
local major = "LibOpenRaid-1.0"
local CONST_LIB_VERSION = 91
--local CONST_LIB_VERSION = 87
local CONST_LIB_VERSION = 92 --this is a rollback version, due to some zero hour bug issues
if (not LIB_OPEN_RAID_MAX_VERSION) then
LIB_OPEN_RAID_MAX_VERSION = CONST_LIB_VERSION
@@ -712,7 +730,6 @@ end
["playerPetChange"] = {},
["mythicDungeonEnd"] = {},
["unitAuraRemoved"] = {},
["cleanUpData"] = {},
}
openRaidLib.internalCallback.RegisterCallback = function(event, func)
@@ -774,13 +791,6 @@ end
--using random time, players won't trigger all at the same time
local randomTime = 0.3 + math.random(0, 0.7)
openRaidLib.Schedules.NewUniqueTimer(randomTime, openRaidLib.mainControl.SendFullData, "mainControl", "sendFullData_Schedule")
local groupSize = GetNumGroupMembers()
if (groupSize < openRaidLib.currentGroupSize) then
--a member left the group and the group size is smaller, trigger an event to modules clean up data
openRaidLib.Schedules.NewUniqueTimer(2, openRaidLib.mainControl.CleanUpData, "mainControl", "sendCleanUpData_Schedule")
openRaidLib.currentGroupSize = groupSize
end
end
openRaidLib.UpdateUnitIDCache()
@@ -799,16 +809,11 @@ end
["PLAYER_ENTERING_WORLD"] = function(...)
--has the selected character just loaded?
if (not openRaidLib.bHasEnteredWorld) then
--save the amount of members in the group
openRaidLib.currentGroupSize = GetNumGroupMembers()
--register events
openRaidLib.OnEnterWorldRegisterEvents()
--openRaidLib.AuraTracker.StartScanUnitAuras("player")
openRaidLib.StartScanningCooldownsRoutine()
if (IsInGroup()) then
openRaidLib.RequestAllData()
openRaidLib.UpdateUnitIDCache()
@@ -1071,10 +1076,6 @@ end
openRaidLib.publicCallback.TriggerCallback("UnitAlive", "player")
end
function openRaidLib.mainControl.CleanUpData()
openRaidLib.internalCallback.TriggerEvent("cleanUpData")
end
openRaidLib.internalCallback.RegisterCallback("onEnterWorld", openRaidLib.mainControl.onEnterWorld)
openRaidLib.internalCallback.RegisterCallback("onEnterWorld", openRaidLib.mainControl.scheduleUpdatePlayerData)
openRaidLib.internalCallback.RegisterCallback("onEnterGroup", openRaidLib.mainControl.OnEnterGroup)
@@ -1688,81 +1689,8 @@ openRaidLib.CooldownManager = {
HasFullCooldownList = {}, --store player names with the library
}
function openRaidLib.StartScanningCooldownsRoutine()
--store spells which isn't ready (most likelly it is on cooldown)
local spellCooldownControl = {}
local startTime = GetTime()
local playerName = UnitName("player")
--currently this is running only for the spells which doesn't have charges
C_Timer.NewTicker(0.5, function()
--technically, the deltaTie is 0.5, but it is framerate dependent, so we calculate it
local deltaTime = GetTime() - startTime
startTime = GetTime()
--check first if the list of cooldown spells is ready
if (LIB_OPEN_RAID_PLAYERCOOLDOWNS) then
for spellId, spellData in pairs(LIB_OPEN_RAID_PLAYERCOOLDOWNS) do
local hasCharges = spellData.charges >= 2
if (not hasCharges) then
local timeLeft, charges, startTimeOffset, duration, auraDuration = openRaidLib.CooldownManager.GetPlayerCooldownStatus(spellId)
--check if the spell is on cooldown
if (timeLeft > 0) then
if (not spellCooldownControl[spellId]) then
--put the spell on cooldown
spellCooldownControl[spellId] = {
onCooldown = true,
timeLeft = timeLeft,
}
else
--the spell is already on cooldown, check if the time left has changed
local deprectedTimeLeft = spellCooldownControl[spellId].timeLeft - deltaTime
if (not openRaidLib.isNearlyEqual(deprectedTimeLeft, timeLeft, 1.5)) then
--if the prediction failed, then the cooldown time left got changed, the code doesn't know if it got shorter or longer
openRaidLib.CooldownManager.SendPlayerCooldownUpdate(spellId, timeLeft, charges, startTimeOffset, duration, auraDuration)
--update locally
--get the cooldown time for this spell
openRaidLib.CooldownManager.CooldownSpellUpdate(playerName, spellId, timeLeft, charges, startTimeOffset, duration, auraDuration) --need 7 values
local playerCooldownTable = openRaidLib.GetUnitCooldowns(playerName)
local cooldownInfo = openRaidLib.GetUnitCooldownInfo(playerName, spellId)
openRaidLib.publicCallback.TriggerCallback("CooldownUpdate", "player", spellId, cooldownInfo, playerCooldownTable, openRaidLib.CooldownManager.UnitData)
end
--update the time left on the control table for this spell
spellCooldownControl[spellId].timeLeft = timeLeft
end
else
--the spell has no cooldown, check if it was on cooldown before
if (spellCooldownControl[spellId]) then
spellCooldownControl[spellId] = nil
--on ENCOUNTER_END all cooldowns are reset, this may trigger a few cooldowns getting ready
--as the lib send a full cooldown update when the encounter end, it is better avoid sending a cooldown update from here
local encounterEndTime = openRaidLib.CooldownManager.EncounterEndTime
if (not encounterEndTime or GetTime() > encounterEndTime+1) then
openRaidLib.CooldownManager.SendPlayerCooldownUpdate(spellId, 0, charges, 0, 0, 0)
--update locally
--get the cooldown time for this spell
openRaidLib.CooldownManager.CooldownSpellUpdate(playerName, spellId, timeLeft, charges, startTimeOffset, duration, auraDuration) --need 7 values
local playerCooldownTable = openRaidLib.GetUnitCooldowns(playerName)
local cooldownInfo = openRaidLib.GetUnitCooldownInfo(playerName, spellId)
openRaidLib.publicCallback.TriggerCallback("CooldownUpdate", "player", spellId, cooldownInfo, playerCooldownTable, openRaidLib.CooldownManager.UnitData)
end
end
end
end
end
end
end)
end
--check if a cooldown time has changed or finished
--this function run within a ticker, the interval is CONST_COOLDOWN_CHECK_INTERVAL
--atm the ticker is only running for spells with 2 or more charges delcared in the things to maintain list
--this function run within a ticker, the internal is CONST_COOLDOWN_CHECK_INTERVAL
local cooldownTimeLeftCheck_Ticker = function(tickerObject)
local spellId = tickerObject.spellId
@@ -1808,29 +1736,24 @@ local cooldownTimeLeftCheck_Ticker = function(tickerObject)
end
--after a spell is casted by the player, start a ticker to check its cooldown
---@spellId: number ---is the spell id of the spell that was casted
---@cooldownTimeLeft: number ---is the time left of the cooldown
---@chargesOnFile: number ---is the amount of charges declared in the things to maintain
local cooldownStartTicker = function(spellId, cooldownTimeLeft, chargesOnFile)
local cooldownStartTicker = function(spellId, cooldownTimeLeft)
local existingTicker = openRaidLib.CooldownManager.CooldownTickers[spellId]
if (existingTicker) then
--if a ticker already exists, might be the cooldown of a charge
--if the ticker isn't about to expire, just keep the timer
--when the ticker finishes it'll check again for charges
if (chargesOnFile and chargesOnFile >= 2) then
if (existingTicker.startTime + existingTicker.cooldownTimeLeft - GetTime() > 2) then
return
end
if (existingTicker.startTime + existingTicker.cooldownTimeLeft - GetTime() > 2) then
return
end
--check if the existing ticker is not cancelled
--cancel the existing ticker
if (not existingTicker:IsCancelled()) then
existingTicker:Cancel()
end
end
--create a new ticker
local maxTicks = ceil(cooldownTimeLeft / CONST_COOLDOWN_CHECK_INTERVAL) + 1
local maxTicks = ceil(cooldownTimeLeft / CONST_COOLDOWN_CHECK_INTERVAL)
local newTicker = C_Timer.NewTicker(CONST_COOLDOWN_CHECK_INTERVAL, cooldownTimeLeftCheck_Ticker, maxTicks)
--store the ticker
@@ -1841,7 +1764,6 @@ local cooldownStartTicker = function(spellId, cooldownTimeLeft, chargesOnFile)
newTicker.endTime = GetTime() + cooldownTimeLeft
end
--called from the encounter end event, check all tickers and cancel those with a cooldown time left of 0
function openRaidLib.CooldownManager.CleanupCooldownTickers()
for spellId, tickerObject in pairs(openRaidLib.CooldownManager.CooldownTickers) do
local timeLeft, charges, startTimeOffset, duration, auraDuration = openRaidLib.CooldownManager.GetPlayerCooldownStatus(spellId)
@@ -1852,10 +1774,6 @@ function openRaidLib.CooldownManager.CleanupCooldownTickers()
end
end
---get the table containing all cooldowns for a unit
---@param unitName string
---@param shouldWipe boolean
---@return table
local cooldownGetUnitTable = function(unitName, shouldWipe)
local unitCooldownTable = openRaidLib.CooldownManager.UnitData[unitName]
--check if the unit has a cooldownTable
@@ -1954,8 +1872,8 @@ end
end
end
---return a table containing values about the cooldown time
---values returned: {timeLeft, charges, timeOffset, duration, updateTime}
--return a table containing values about the cooldown time
--values returned: {timeLeft, charges, timeOffset, duration, updateTime}
function openRaidLib.GetUnitCooldownInfo(unitId, spellId)
local unitCooldownsTable = openRaidLib.GetUnitCooldowns(unitId)
if (unitCooldownsTable) then
@@ -1964,7 +1882,6 @@ end
end
end
---comment: this function is used to calculate the percent of a cooldown
local calculatePercent = function(timeOffset, duration, updateTime, charges)
timeOffset = abs(timeOffset)
local minValue = updateTime - timeOffset
@@ -2042,10 +1959,9 @@ end
--send to comm
openRaidLib.CooldownManager.SendPlayerCooldownUpdate(spellId, timeLeft, charges, startTimeOffset, duration, auraDuration)
--create a ticker to monitor spells with charges
if (LIB_OPEN_RAID_COOLDOWNS_INFO[spellId].charges >= 2) then
cooldownStartTicker(spellId, timeLeft, LIB_OPEN_RAID_COOLDOWNS_INFO[spellId].charges)
end
--create a timer to monitor the time of this cooldown
--as there's just a few of them to monitor, there's no issue on creating one timer per spell
cooldownStartTicker(spellId, timeLeft)
end
end
@@ -2080,10 +1996,9 @@ end
--check cooldown reset after a raid encounter ends finishing ongoing timeLeft tickers
function openRaidLib.CooldownManager.CheckCooldownsAfterEncounterEnd()
openRaidLib.CooldownManager.CleanupCooldownTickers()
openRaidLib.Schedules.NewUniqueTimer(3 + math.random(1, 4), openRaidLib.CooldownManager.SendAllPlayerCooldowns, "CooldownManager", "sendAllPlayerCooldowns_Schedule")
openRaidLib.Schedules.NewUniqueTimer(1 + math.random(1, 4), openRaidLib.CooldownManager.SendAllPlayerCooldowns, "CooldownManager", "sendAllPlayerCooldowns_Schedule")
end
function openRaidLib.CooldownManager.OnEncounterEnd()
openRaidLib.CooldownManager.EncounterEndTime = GetTime()
--run on next frame
openRaidLib.Schedules.NewUniqueTimer(0.1, openRaidLib.CooldownManager.CheckCooldownsAfterEncounterEnd, "CooldownManager", "encounterEndCooldownsCheck_Schedule")
end
@@ -2125,26 +2040,6 @@ end
end
end
function openRaidLib.CooldownManager.OnCleanUpCall()
--the group has less players, need to check which players isn't in the group anymore and remove them from the cooldown database
--get the cooldown database table with all players
local cooldownDatabase = openRaidLib.CooldownManager.UnitData
local bAnyUnitGotRemoved = false
--foreach player in the database
for unitName in pairs(cooldownDatabase) do
--check if the player is in the group
if (not UnitInRaid(unitName) and not UnitInParty(unitName)) then
--remove the player from the database
openRaidLib.CooldownManager.UnitData[unitName] = nil
bAnyUnitGotRemoved = true
end
end
if (bAnyUnitGotRemoved) then
end
end
openRaidLib.internalCallback.RegisterCallback("onLeaveGroup", openRaidLib.CooldownManager.OnPlayerLeaveGroup)
openRaidLib.internalCallback.RegisterCallback("playerCast", openRaidLib.CooldownManager.OnPlayerCast)
openRaidLib.internalCallback.RegisterCallback("onPlayerRess", openRaidLib.CooldownManager.OnPlayerRess)
@@ -2154,7 +2049,6 @@ end
openRaidLib.internalCallback.RegisterCallback("mythicDungeonStart", openRaidLib.CooldownManager.OnMythicPlusStart)
openRaidLib.internalCallback.RegisterCallback("playerPetChange", openRaidLib.CooldownManager.OnPlayerPetChanged)
openRaidLib.internalCallback.RegisterCallback("unitAuraRemoved", openRaidLib.CooldownManager.OnAuraRemoved)
openRaidLib.internalCallback.RegisterCallback("cleanUpData", openRaidLib.CooldownManager.OnCleanUpCall)
--send a list through comm with cooldowns added or removed
function openRaidLib.CooldownManager.CheckCooldownChanges()
@@ -2315,8 +2209,7 @@ end
--adds a list of cooldowns for another player in the group
--this is only called from the received cooldown list from comm
function openRaidLib.CooldownManager.AddUnitCooldownsList(unitName, cooldownsTable, noCallback)
local bShouldWipe = true
local unitCooldownTable = cooldownGetUnitTable(unitName, bShouldWipe) --sending true to wipe previous data
local unitCooldownTable = cooldownGetUnitTable(unitName, true) --sending true to wipe previous data
openRaidLib.TCopy(unitCooldownTable, cooldownsTable)
--add the unitName to the list of units detected with the lib
@@ -2703,5 +2596,67 @@ openRaidLib.commHandler.RegisterComm(CONST_COMM_COOLDOWNREQUEST_PREFIX, openRaid
openRaidLib.internalCallback.RegisterCallback("mythicDungeonEnd", openRaidLib.KeystoneInfoManager.OnMythicDungeonFinished)
--------------------------------------------------------------------------------------------------------------------------------
--data
--vintage cooldown tracker and interrupt tracker
C_Timer.After(0.1, function()
local vintageCDTrackerFrame = CreateFrame("frame")
vintageCDTrackerFrame:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED")
local allCooldownsFromLib = LIB_OPEN_RAID_COOLDOWNS_INFO
local recentCastedSpells = {}
vintageCDTrackerFrame:SetScript("OnEvent", function(self, event, ...)
if (event == "UNIT_SPELLCAST_SUCCEEDED") then
local unit, castGUID, spellId = ...
local unitIsThePlayer = UnitIsUnit(unit, "player")
if (not unitIsThePlayer) then
local unitName = GetUnitName(unit, true)
local hasLib = openRaidLib.CooldownManager.HasFullCooldownList[unitName]
if (unitName and not hasLib) then
local unitInGroup = UnitInParty(unit) or UnitInRaid(unit)
if (unitInGroup) then
local cooldownInfo = allCooldownsFromLib[spellId]
if (cooldownInfo) then -- and not openRaidLib.GetUnitCooldown(unitName)
--check for cast_success spam from channel spells
local unitCastCooldown = recentCastedSpells[unitName]
if (not unitCastCooldown) then
unitCastCooldown = {}
recentCastedSpells[unitName] = unitCastCooldown
end
if (not unitCastCooldown[spellId] or unitCastCooldown[spellId]+5 < GetTime()) then
unitCastCooldown[spellId] = GetTime()
--trigger a cooldown usage
local duration = cooldownInfo.duration
--time left, charges, startTimeOffset, duration
openRaidLib.CooldownManager.CooldownSpellUpdate(unitName, spellId, duration, 0, 0, duration, 0)
local cooldownInfo = cooldownGetSpellInfo(unitName, spellId)
local unitCooldownsTable = openRaidLib.GetUnitCooldowns(unitName)
--trigger a public callback
openRaidLib.publicCallback.TriggerCallback("CooldownUpdate", openRaidLib.GetUnitID(unitName), spellId, cooldownInfo, unitCooldownsTable, openRaidLib.CooldownManager.UnitData)
end
end
end
end
end
end
end)
end)
tempCache.RestoreData()
--[=[
3x ...ns/Details/Libs/LibOpenRaid/GetPlayerInformation.lua:603: attempt to index field '?' (a nil value)
[string "@Interface/AddOns/Details/Libs/LibOpenRaid/GetPlayerInformation.lua"]:634: in function `GetPlayerCooldownStatus'
[string "@Interface/AddOns/Details/Libs/LibOpenRaid/LibOpenRaid.lua"]:1696: in function `CleanupCooldownTickers'
[string "@Interface/AddOns/Details/Libs/LibOpenRaid/LibOpenRaid.lua"]:1925: in function <...face/AddOns/Details/Libs/LibOpenRaid/LibOpenRaid.lua:1924>
[string "=[C]"]: in function `xpcall'
[string "@Interface/AddOns/Details/Libs/LibOpenRaid/LibOpenRaid.lua"]:506: in function <...face/AddOns/Details/Libs/LibOpenRaid/LibOpenRaid.lua:496>
]=]
@@ -121,7 +121,7 @@ do
[INVSLOT_MAINHAND] = true,
[INVSLOT_FEET] = true,
[INVSLOT_WRIST] = true,
[INVSLOT_HAND] = false,
[INVSLOT_HAND] = true,
}
-- how to get the enchantId:
@@ -676,4 +676,4 @@ LIB_OPEN_RAID_SPELL_DEFAULT_IDS = {
}
--need to add mass dispell (32375)
LIB_OPEN_RAID_DATABASE_LOADED = true
LIB_OPEN_RAID_DATABASE_LOADED = true
+2 -2
View File
@@ -7,8 +7,8 @@
local addonName, Details222 = ...
local version, build, date, tocversion = GetBuildInfo()
_detalhes.build_counter = 10405
_detalhes.alpha_build_counter = 10405 --if this is higher than the regular counter, use it instead
_detalhes.build_counter = 10406
_detalhes.alpha_build_counter = 10406 --if this is higher than the regular counter, use it instead
_detalhes.dont_open_news = true
_detalhes.game_version = version
_detalhes.userversion = version .. " " .. _detalhes.build_counter
+53 -55
View File
@@ -677,72 +677,70 @@ end
end
end
---get an actor from the container, if the actor doesn't exists, and the bShouldCreate is true, create a new actor
---@param serial string
---get an actor from the container, if the actor doesn't exists, and the bShouldCreateActor is true, create a new actor
---this function is an alias for PegarCombatente which is the function name is in portuguese
---@param actorSerial string
---@param actorName string
---@param actorFlags number
---@param bShouldCreate boolean
---@param bShouldCreateActor boolean
---@return table
function actorContainer:GetOrCreateActor (serial, actorName, actorFlags, bShouldCreate)
return self:PegarCombatente(serial, actorName, actorFlags, criar)
function actorContainer:GetOrCreateActor(actorSerial, actorName, actorFlags, bShouldCreateActor)
return self:PegarCombatente(actorSerial, actorName, actorFlags, bShouldCreateActor)
end
function actorContainer:PegarCombatente (serial, nome, flag, criar)
---@param actorSerial string
---@param actorName string
---@param actorFlags number
---@param bShouldCreateActor boolean
---@return table
function actorContainer:PegarCombatente(actorSerial, actorName, actorFlags, bShouldCreateActor)
--[[statistics]]-- _detalhes.statistics.container_calls = _detalhes.statistics.container_calls + 1
--if (flag and nome:find("Kastfall") and bit.band(flag, 0x2000) ~= 0) then
--print("PET:", nome, _detalhes.tabela_pets.pets [serial], container_pets [serial])
--else
--print(nome, flag)
--end
local npcId = Details:GetNpcIdFromGuid(serial or "")
--verifica se um pet, se for confere se tem o nome do dono, se no tiver, precisa por
local dono_do_pet
serial = serial or "ns"
actorSerial = actorSerial or "ns"
if (container_pets[serial]) then -- um pet reconhecido
if (container_pets[actorSerial]) then -- um pet reconhecido
--[[statistics]]-- _detalhes.statistics.container_pet_calls = _detalhes.statistics.container_pet_calls + 1
local petName, ownerName, ownerGUID, ownerFlag = Details.tabela_pets:PegaDono (serial, nome, flag)
local petName, ownerName, ownerGUID, ownerFlag = Details.tabela_pets:PegaDono (actorSerial, actorName, actorFlags)
if (petName and ownerName) then
nome = petName
actorName = petName
dono_do_pet = self:PegarCombatente(ownerGUID, ownerName, ownerFlag, true)
end
elseif (not petBlackList[serial]) then --verifica se um pet
petBlackList[serial] = true
elseif (not petBlackList[actorSerial]) then --verifica se um pet
petBlackList[actorSerial] = true
--try to find the owner
if (flag and bitBand(flag, OBJECT_TYPE_PETGUARDIAN) ~= 0) then
if (actorFlags and bitBand(actorFlags, OBJECT_TYPE_PETGUARDIAN) ~= 0) then
--[[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(actorSerial, actorName, actorFlags, self)
if (find_nome and find_owner) then
nome, dono_do_pet = find_nome, find_owner
actorName, dono_do_pet = find_nome, find_owner
end
end
end
--pega o index no mapa
local index = self._NameIndexTable[nome]
local index = self._NameIndexTable[actorName]
--retorna o actor
if (index) then
return self._ActorTable[index], dono_do_pet, nome
return self._ActorTable[index], dono_do_pet, actorName
--no achou, criar
elseif (criar) then
local novo_objeto = self.funcao_de_criacao(_, serial, nome)
novo_objeto.nome = nome
novo_objeto.flag_original = flag
novo_objeto.serial = serial
elseif (bShouldCreateActor) then
local novo_objeto = self.funcao_de_criacao(_, actorSerial, actorName)
novo_objeto.nome = actorName
novo_objeto.flag_original = actorFlags
novo_objeto.serial = actorSerial
--seta a classe default para desconhecido, assim nenhum objeto fica com classe nil
novo_objeto.classe = "UNKNOW"
local forceClass
--get the aID (actor id)
if (serial:match("^C")) then
novo_objeto.aID = tostring(Details:GetNpcIdFromGuid(serial))
if (actorSerial:match("^C")) then
novo_objeto.aID = tostring(Details:GetNpcIdFromGuid(actorSerial))
if (Details.immersion_special_units) then
local shouldBeInGroup, class = Details.Immersion.IsNpcInteresting(novo_objeto.aID)
@@ -753,8 +751,8 @@ end
end
end
elseif (serial:match("^P")) then
novo_objeto.aID = serial:gsub("Player%-", "")
elseif (actorSerial:match("^P")) then
novo_objeto.aID = actorSerial:gsub("Player%-", "")
else
novo_objeto.aID = ""
@@ -774,12 +772,12 @@ end
if (self.tipo == container_damage) then --CONTAINER DAMAGE
local shouldScanOnce = getActorClass (novo_objeto, nome, flag, serial)
local shouldScanOnce = getActorClass (novo_objeto, actorName, actorFlags, actorSerial)
readActorFlag (novo_objeto, dono_do_pet, serial, flag, nome, "damage")
readActorFlag (novo_objeto, dono_do_pet, actorSerial, actorFlags, actorName, "damage")
if (dono_do_pet) then
AddUnique (dono_do_pet.pets, nome)
AddUnique (dono_do_pet.pets, actorName)
end
if (self.shadow) then
@@ -789,7 +787,7 @@ end
end
if (novo_objeto.classe == "UNGROUPPLAYER") then --is a player
if (bitBand (flag, REACTION_HOSTILE ) ~= 0) then --is hostile
if (bitBand (actorFlags, REACTION_HOSTILE ) ~= 0) then --is hostile
novo_objeto.enemy = true
end
@@ -809,11 +807,11 @@ end
elseif (self.tipo == container_heal) then --CONTAINER HEALING
local shouldScanOnce = getActorClass (novo_objeto, nome, flag, serial)
readActorFlag (novo_objeto, dono_do_pet, serial, flag, nome, "heal")
local shouldScanOnce = getActorClass (novo_objeto, actorName, actorFlags, actorSerial)
readActorFlag (novo_objeto, dono_do_pet, actorSerial, actorFlags, actorName, "heal")
if (dono_do_pet) then
AddUnique (dono_do_pet.pets, nome)
AddUnique (dono_do_pet.pets, actorName)
end
if (self.shadow) then
@@ -823,7 +821,7 @@ end
end
if (novo_objeto.classe == "UNGROUPPLAYER") then --is a player
if (bitBand (flag, REACTION_HOSTILE ) ~= 0) then --is hostile
if (bitBand (actorFlags, REACTION_HOSTILE ) ~= 0) then --is hostile
novo_objeto.enemy = true --print(nome.." EH UM INIMIGO -> " .. engRace)
end
@@ -836,15 +834,15 @@ end
elseif (self.tipo == container_energy) then --CONTAINER ENERGY
local shouldScanOnce = getActorClass (novo_objeto, nome, flag, serial)
readActorFlag (novo_objeto, dono_do_pet, serial, flag, nome, "energy")
local shouldScanOnce = getActorClass (novo_objeto, actorName, actorFlags, actorSerial)
readActorFlag (novo_objeto, dono_do_pet, actorSerial, actorFlags, actorName, "energy")
if (dono_do_pet) then
AddUnique (dono_do_pet.pets, nome)
AddUnique (dono_do_pet.pets, actorName)
end
if (novo_objeto.classe == "UNGROUPPLAYER") then --is a player
if (bitBand (flag, REACTION_HOSTILE ) ~= 0) then --is hostile
if (bitBand (actorFlags, REACTION_HOSTILE ) ~= 0) then --is hostile
novo_objeto.enemy = true
end
@@ -856,15 +854,15 @@ end
elseif (self.tipo == container_misc) then --CONTAINER MISC
local shouldScanOnce = getActorClass (novo_objeto, nome, flag, serial)
readActorFlag (novo_objeto, dono_do_pet, serial, flag, nome, "misc")
local shouldScanOnce = getActorClass (novo_objeto, actorName, actorFlags, actorSerial)
readActorFlag (novo_objeto, dono_do_pet, actorSerial, actorFlags, actorName, "misc")
if (dono_do_pet) then
AddUnique (dono_do_pet.pets, nome)
AddUnique (dono_do_pet.pets, actorName)
end
if (novo_objeto.classe == "UNGROUPPLAYER") then --is a player
if (bitBand (flag, REACTION_HOSTILE ) ~= 0) then --is hostile
if (bitBand (actorFlags, REACTION_HOSTILE ) ~= 0) then --is hostile
novo_objeto.enemy = true
end
@@ -894,12 +892,12 @@ end
elseif (self.tipo == container_friendlyfire) then --CONTAINER FRIENDLY FIRE
local shouldScanOnce = getActorClass (novo_objeto, nome, serial)
local shouldScanOnce = getActorClass (novo_objeto, actorName, actorSerial)
end
--sanguine affix
if (nome == sanguineActorName) then
if (actorName == sanguineActorName) then
novo_objeto.grupo = true
end
@@ -907,14 +905,14 @@ end
-- grava o objeto no mapa do container
local size = #self._ActorTable+1
self._ActorTable [size] = novo_objeto --grava na tabela de indexes
self._NameIndexTable [nome] = size --grava no hash map o index deste jogador
self._NameIndexTable [actorName] = size --grava no hash map o index deste jogador
if (Details.is_in_battleground or Details.is_in_arena) then
novo_objeto.pvp = true
end
if (Details.debug) then
if (Details.debug_chr and nome:find(Details.debug_chr) and self.tipo == 1) then
if (Details.debug_chr and actorName:find(Details.debug_chr) and self.tipo == 1) then
local logLine = ""
local when = "[" .. date ("%H:%M:%S") .. format(".%4f", GetTime()-floor(GetTime())) .. "]"
local log = "actor created - class: " .. (novo_objeto.classe or "noclass")
@@ -930,7 +928,7 @@ end
novo_objeto.classe = forceClass
end
return novo_objeto, dono_do_pet, nome
return novo_objeto, dono_do_pet, actorName
else
return nil, nil, nil
end