You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

399 lines
14 KiB

4 years ago
do
local _detalhes = _G._detalhes
_detalhes.EncounterInformation = {}
3 years ago
local ipairs = ipairs --lua local
4 years ago
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
3 years ago
--details api functions
4 years ago
3 years ago
--return if the player is inside a raid supported by details
4 years ago
function _detalhes:IsInInstance()
local _, _, _, _, _, _, _, zoneMapID = GetInstanceInfo()
if (_detalhes.EncounterInformation [zoneMapID]) then
return true
else
return false
end
end
3 years ago
--return the full table with all data for the instance
4 years ago
function _detalhes:GetRaidInfoFromEncounterID (encounterID, encounterEJID)
3 years ago
for id, raidTable in pairs(_detalhes.EncounterInformation) do
4 years ago
if (encounterID) then
local ids = raidTable.encounter_ids2 --combatlog
if (ids) then
if (ids [encounterID]) then
return raidTable
end
end
end
if (encounterEJID) then
local ejids = raidTable.encounter_ids --encounter journal
if (ejids) then
if (ejids [encounterEJID]) then
return raidTable
end
end
end
end
end
3 years ago
--return the ids of trash mobs in the instance
4 years ago
function _detalhes:GetInstanceTrashInfo (mapid)
return _detalhes.EncounterInformation [mapid] and _detalhes.EncounterInformation [mapid].trash_ids
end
function _detalhes:GetInstanceIdFromEncounterId (encounterid)
3 years ago
for id, instanceTable in pairs(_detalhes.EncounterInformation) do
4 years ago
--combatlog encounter id
local ids = instanceTable.encounter_ids2
if (ids) then
if (ids [encounterid]) then
return id
end
end
--encounter journal id
local ids_ej = instanceTable.encounter_ids
if (ids) then
if (ids_ej [encounterid]) then
return id
end
end
end
end
3 years ago
--return the boss table using a encounter id
4 years ago
function _detalhes:GetBossEncounterDetailsFromEncounterId (mapid, encounterid)
if (not mapid) then
local bossIndex, instance
3 years ago
for id, instanceTable in pairs(_detalhes.EncounterInformation) do
4 years ago
local ids = instanceTable.encounter_ids2
if (ids) then
bossIndex = ids [encounterid]
if (bossIndex) then
instance = instanceTable
break
end
end
end
if (instance) then
local bosses = instance.encounters
if (bosses) then
return bosses [bossIndex], instance
end
end
return
end
local bossindex = _detalhes.EncounterInformation [mapid] and _detalhes.EncounterInformation [mapid].encounter_ids and _detalhes.EncounterInformation [mapid].encounter_ids [encounterid]
if (bossindex) then
return _detalhes.EncounterInformation [mapid] and _detalhes.EncounterInformation [mapid].encounters [bossindex], bossindex
else
local bossindex = _detalhes.EncounterInformation [mapid] and _detalhes.EncounterInformation [mapid].encounter_ids2 and _detalhes.EncounterInformation [mapid].encounter_ids2 [encounterid]
if (bossindex) then
return _detalhes.EncounterInformation [mapid] and _detalhes.EncounterInformation [mapid].encounters [bossindex], bossindex
end
end
end
3 years ago
--return the EJ boss id
4 years ago
function _detalhes:GetEncounterIdFromBossIndex (mapid, index)
return _detalhes.EncounterInformation [mapid] and _detalhes.EncounterInformation [mapid].encounter_ids and _detalhes.EncounterInformation [mapid].encounter_ids [index]
end
3 years ago
--return the table which contain information about the start of a encounter
4 years ago
function _detalhes:GetEncounterStartInfo (mapid, encounterid)
local bossindex = _detalhes.EncounterInformation [mapid] and _detalhes.EncounterInformation [mapid].encounter_ids and _detalhes.EncounterInformation [mapid].encounter_ids [encounterid]
if (bossindex) then
return _detalhes.EncounterInformation [mapid].encounters [bossindex] and _detalhes.EncounterInformation [mapid].encounters [bossindex].encounter_start
end
end
3 years ago
--return the table which contain information about the end of a encounter
4 years ago
function _detalhes:GetEncounterEndInfo (mapid, encounterid)
local bossindex = _detalhes.EncounterInformation [mapid] and _detalhes.EncounterInformation [mapid].encounter_ids and _detalhes.EncounterInformation [mapid].encounter_ids [encounterid]
if (bossindex) then
return _detalhes.EncounterInformation [mapid].encounters [bossindex] and _detalhes.EncounterInformation [mapid].encounters [bossindex].encounter_end
end
end
3 years ago
--return the function for the boss
4 years ago
function _detalhes:GetEncounterEnd (mapid, bossindex)
local t = _detalhes.EncounterInformation [mapid] and _detalhes.EncounterInformation [mapid].encounters [bossindex]
if (t) then
local _end = t.combat_end
if (_end) then
3 years ago
return unpack(_end)
4 years ago
end
end
return
end
3 years ago
--generic boss find function
4 years ago
function _detalhes:GetRaidBossFindFunction (mapid)
return _detalhes.EncounterInformation [mapid] and _detalhes.EncounterInformation [mapid].find_boss_encounter
end
3 years ago
--return if the boss need sync
4 years ago
function _detalhes:GetEncounterEqualize (mapid, bossindex)
return _detalhes.EncounterInformation [mapid] and _detalhes.EncounterInformation [mapid].encounters [bossindex] and _detalhes.EncounterInformation [mapid].encounters [bossindex].equalize
end
3 years ago
--return the function for the boss
4 years ago
function _detalhes:GetBossFunction (mapid, bossindex)
local func = _detalhes.EncounterInformation [mapid] and _detalhes.EncounterInformation [mapid].encounters [bossindex] and _detalhes.EncounterInformation [mapid].encounters [bossindex].func
if (func) then
return func, _detalhes.EncounterInformation [mapid].encounters [bossindex].funcType
end
return
end
3 years ago
--return the boss table with information about name, adds, spells, etc
4 years ago
function _detalhes:GetBossDetails (mapid, bossindex)
return _detalhes.EncounterInformation [mapid] and _detalhes.EncounterInformation [mapid].encounters [bossindex]
end
3 years ago
--return a table with all names of boss enemies
4 years ago
function _detalhes:GetEncounterActors (mapid, bossindex)
end
3 years ago
--return a table with spells id of specified encounter
4 years ago
function _detalhes:GetEncounterSpells (mapid, bossindex)
local encounter = _detalhes:GetBossDetails (mapid, bossindex)
local habilidades_poll = {}
if (encounter.continuo) then
3 years ago
for index, spellid in ipairs(encounter.continuo) do
4 years ago
habilidades_poll [spellid] = true
end
end
local fases = encounter.phases
if (fases) then
3 years ago
for fase_id, fase in ipairs(fases) do
4 years ago
if (fase.spells) then
3 years ago
for index, spellid in ipairs(fase.spells) do
4 years ago
habilidades_poll [spellid] = true
end
end
end
end
return habilidades_poll
end
3 years ago
--return a table with all boss ids from a raid instance
4 years ago
function _detalhes:GetBossIds (mapid)
return _detalhes.EncounterInformation [mapid] and _detalhes.EncounterInformation [mapid].boss_ids
end
function _detalhes:InstanceIsRaid (mapid)
return _detalhes:InstanceisRaid (mapid)
end
function _detalhes:InstanceisRaid (mapid)
return _detalhes.EncounterInformation [mapid] and _detalhes.EncounterInformation [mapid].is_raid
end
3 years ago
--return a table with all encounter names present in raid instance
4 years ago
function _detalhes:GetBossNames (mapid)
return _detalhes.EncounterInformation [mapid] and _detalhes.EncounterInformation [mapid].boss_names
end
3 years ago
--return the encounter name
4 years ago
function _detalhes:GetBossName (mapid, bossindex)
return _detalhes.EncounterInformation [mapid] and _detalhes.EncounterInformation [mapid].boss_names [bossindex]
end
3 years ago
--same thing as GetBossDetails, just a alias
4 years ago
function _detalhes:GetBossEncounterDetails (mapid, bossindex)
return _detalhes.EncounterInformation [mapid] and _detalhes.EncounterInformation [mapid].encounters [bossindex]
end
function _detalhes:GetEncounterInfoFromEncounterName (EJID, encountername)
DetailsFramework.EncounterJournal.EJ_SelectInstance (EJID)
for i = 1, 20 do
local name = DetailsFramework.EncounterJournal.EJ_GetEncounterInfoByIndex (i, EJID)
if (not name) then
return
end
3 years ago
if (name == encountername or name:find(encountername)) then
4 years ago
return i, DetailsFramework.EncounterJournal.EJ_GetEncounterInfoByIndex (i, EJID)
end
end
end
3 years ago
--return the wallpaper for the raid instance
4 years ago
function _detalhes:GetRaidBackground (mapid)
local bosstables = _detalhes.EncounterInformation [mapid]
if (bosstables) then
local bg = bosstables.backgroundFile
if (bg) then
3 years ago
return bg.file, unpack(bg.coords)
4 years ago
end
end
end
3 years ago
--return the icon for the raid instance
4 years ago
function _detalhes:GetRaidIcon (mapid, ejID, instanceType)
local raidIcon = _detalhes.EncounterInformation [mapid] and _detalhes.EncounterInformation [mapid].icon
if (raidIcon) then
return raidIcon
end
if (ejID and ejID ~= 0) then
local name, description, bgImage, buttonImage, loreImage, dungeonAreaMapID, link = DetailsFramework.EncounterJournal.EJ_GetInstanceInfo (ejID)
if (name) then
if (instanceType == "party") then
return loreImage --bgImage
elseif (instanceType == "raid") then
return loreImage
end
end
end
return nil
end
function _detalhes:GetBossIndex (mapid, encounterCLID, encounterEJID, encounterName)
local raidInfo = _detalhes.EncounterInformation [mapid]
if (raidInfo) then
local index = raidInfo.encounter_ids2 [encounterCLID] or raidInfo.encounter_ids [encounterEJID]
if (not index) then
for i = 1, #raidInfo.boss_names do
if (raidInfo.boss_names [i] == encounterName) then
index = i
break
end
end
end
return index
end
end
3 years ago
--return the boss icon
4 years ago
function _detalhes:GetBossIcon (mapid, bossindex)
if (_detalhes.EncounterInformation [mapid]) then
local line = math.ceil (bossindex / 4)
local x = ( bossindex - ( (line-1) * 4 ) ) / 4
return x-0.25, x, 0.25 * (line-1), 0.25 * line, _detalhes.EncounterInformation [mapid].icons
end
end
3 years ago
--return the boss portrit
function _detalhes:GetBossPortrait(mapid, bossindex, encounterName, ejID)
4 years ago
if (mapid and bossindex) then
local haveIcon = _detalhes.EncounterInformation [mapid] and _detalhes.EncounterInformation [mapid].encounters [bossindex] and _detalhes.EncounterInformation [mapid].encounters [bossindex].portrait
if (haveIcon) then
return haveIcon
end
end
if (encounterName and ejID and ejID ~= 0) then
local index, name, description, encounterID, rootSectionID, link = _detalhes:GetEncounterInfoFromEncounterName (ejID, encounterName)
if (index and name and encounterID) then
local id, name, description, displayInfo, iconImage = DetailsFramework.EncounterJournal.EJ_GetCreatureInfo (1, encounterID)
if (iconImage) then
return iconImage
end
end
end
return nil
end
3 years ago
--return a list with names of adds and bosses
4 years ago
function _detalhes:GetEncounterActorsName (EJ_EncounterID)
--code snippet from wowpedia
local actors = {}
local stack, encounter, _, _, curSectionID = {}, DetailsFramework.EncounterJournal.EJ_GetEncounterInfo (EJ_EncounterID)
if (not curSectionID) then
return actors
end
repeat
local title, description, depth, abilityIcon, displayInfo, siblingID, nextSectionID, filteredByDifficulty, link, startsOpen, flag1, flag2, flag3, flag4 = DetailsFramework.EncounterJournal.EJ_GetSectionInfo (curSectionID)
if (displayInfo ~= 0 and abilityIcon == "") then
actors [title] = {model = displayInfo, info = description}
end
3 years ago
table.insert(stack, siblingID)
table.insert(stack, nextSectionID)
4 years ago
curSectionID = table.remove (stack)
until not curSectionID
return actors
end
function _detalhes:GetInstanceEJID (mapid)
3 years ago
mapid = mapid or select(8, GetInstanceInfo())
4 years ago
if (mapid) then
local instance_info = _detalhes.EncounterInformation [mapid]
if (instance_info) then
return instance_info.ej_id or 0
end
end
return 0
end
function _detalhes:GetCurrentDungeonBossListFromEJ()
local mapID = C_Map.GetBestMapForUnit ("player")
if (not mapID) then
3 years ago
--print("Details! exeption handled: zone has no map")
4 years ago
return
end
local EJ_CInstance = DetailsFramework.EncounterJournal.EJ_GetInstanceForMap(mapID)
if (EJ_CInstance and EJ_CInstance ~= 0) then
if (_detalhes.encounter_dungeons [EJ_CInstance]) then
return _detalhes.encounter_dungeons [EJ_CInstance]
end
DetailsFramework.EncounterJournal.EJ_SelectInstance (EJ_CInstance)
local name, description, bgImage, buttonImage, loreImage, dungeonAreaMapID, link = DetailsFramework.EncounterJournal.EJ_GetInstanceInfo (EJ_CInstance)
local boss_list = {
[EJ_CInstance] = {name, description, bgImage, buttonImage, loreImage, dungeonAreaMapID, link}
}
for i = 1, 20 do
local encounterName, description, encounterID, rootSectionID, link = DetailsFramework.EncounterJournal.EJ_GetEncounterInfoByIndex (i, EJ_CInstance)
if (encounterName) then
for o = 1, 6 do
local id, creatureName, creatureDescription, displayInfo, iconImage = DetailsFramework.EncounterJournal.EJ_GetCreatureInfo (o, encounterID)
if (id) then
boss_list [creatureName] = {encounterName, encounterID, creatureName, iconImage, EJ_CInstance}
else
break
end
end
else
break
end
end
_detalhes.encounter_dungeons [EJ_CInstance] = boss_list
return boss_list
end
end
function _detalhes:IsRaidRegistered (mapid)
return _detalhes.EncounterInformation [mapid] and true
end
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
3 years ago
--core
4 years ago
function _detalhes:InstallEncounter (InstanceTable)
_detalhes.EncounterInformation [InstanceTable.id] = InstanceTable
return true
end
end
--functionas