Skip to content

Commit

Permalink
More naming conventions and variables translations for container actors
Browse files Browse the repository at this point in the history
  • Loading branch information
Tercioo committed Jan 12, 2023
1 parent 2bbb7be commit 764b779
Show file tree
Hide file tree
Showing 8 changed files with 164 additions and 212 deletions.
2 changes: 1 addition & 1 deletion Libs/LibOpenRaid/Deprecated.lua
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,4 @@ local spamLimit = {}
spamLimit["openRaidLib.cooldownManager.GetPlayerCooldowns"] = true
end
end
setmetatable(openRaidLib.cooldownManager, deprecatedMetatable)
setmetatable(openRaidLib.cooldownManager, deprecatedMetatable)
2 changes: 1 addition & 1 deletion Libs/LibOpenRaid/Functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -511,4 +511,4 @@ function openRaidLib.GearManager.BuildEquipmentItemLinks(equippedGearList)
end
end
end
end
end
17 changes: 8 additions & 9 deletions Libs/LibOpenRaid/GetPlayerInformation.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -861,4 +860,4 @@ openRaidLib.specAttribute = {
[1467] = 1, --Devastation
[1468] = 1, --Preservation
},
}
}
239 changes: 97 additions & 142 deletions Libs/LibOpenRaid/LibOpenRaid.lua

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Libs/LibOpenRaid/ThingsToMantain_Dragonflight.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion Libs/LibOpenRaid/ThingsToMantain_Shadowlands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions boot.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
108 changes: 53 additions & 55 deletions classes/container_actors.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 n�o 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

--n�o 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)
Expand All @@ -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 = ""
Expand All @@ -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
Expand All @@ -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

Expand All @@ -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
Expand All @@ -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

Expand All @@ -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

Expand All @@ -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

Expand Down Expand Up @@ -894,27 +892,27 @@ 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

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- 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")
Expand All @@ -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
Expand Down

0 comments on commit 764b779

Please sign in to comment.