Skip to content

Commit

Permalink
More bug fixes and implementations on the backend of mythic dungeons …
Browse files Browse the repository at this point in the history
…handling.
  • Loading branch information
Tercioo committed Mar 1, 2024
1 parent a8d8733 commit 7d8b84a
Show file tree
Hide file tree
Showing 6 changed files with 250 additions and 236 deletions.
26 changes: 13 additions & 13 deletions Definitions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -115,19 +115,19 @@
---@field key7 guid pet guid

---@class bossinfo : table .is_boss on combatObjects
---@field diff_string string
---@field index number
---@field zone string
---@field encounter string
---@field mapid number
---@field try_number number
---@field name string
---@field ej_instance_id number
---@field id number
---@field unixtime unixtime
---@field diff number
---@field killed boolean
---@field bossimage texturepath|number
---@field diff_string string?
---@field index number?
---@field zone string?
---@field encounter string?
---@field mapid number?
---@field try_number number?
---@field name string?
---@field ej_instance_id number?
---@field id number?
---@field unixtime unixtime?
---@field diff number?
---@field killed boolean?
---@field bossimage texturepath|number?

---@class details
---@field pets table<guid, petinfo> store the pet guid as the key and the petinfo as the value
Expand Down
4 changes: 4 additions & 0 deletions Libs/LibLuaServer/LibLuaServer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1459,6 +1459,10 @@ function loadstring(code) return function()end end
---@return string
function date(format, time) return "" end

---lua os.time() function
---@return number
function time() return 0 end

---returns the number of members in the current group.
---@return number
GetNumGroupMembers = function() return 0 end
Expand Down
2 changes: 1 addition & 1 deletion classes/class_combat.lua
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ local segmentTypeToString = {
---@return boolean
---@return number
function classCombat:IsMythicDungeon()
local bIsMythicPlusSegment = self.is_mythic_dungeon_segment and self:GetMythicDungeonInfo()
local bIsMythicPlusSegment = self.is_mythic_dungeon_segment
local runId = self.is_mythic_dungeon_run_id
return bIsMythicPlusSegment, runId
end
Expand Down
88 changes: 49 additions & 39 deletions core/control.lua
Original file line number Diff line number Diff line change
Expand Up @@ -558,14 +558,12 @@
currentCombat.player_last_events = {}

--flag instance type
local _, InstanceType = GetInstanceInfo()
currentCombat.instance_type = InstanceType
local zoneName, instanceType, DifficultyID, DifficultyName, _, _, _, zoneMapID = GetInstanceInfo()
currentCombat.instance_type = instanceType

if (not currentCombat.is_boss and bIsFromEncounterEnd and type(bIsFromEncounterEnd) == "table") then
local encounterID, encounterName, difficultyID, raidSize, endStatus = unpack(bIsFromEncounterEnd)
if (encounterID) then
local ZoneName, InstanceType, DifficultyID, DifficultyName, _, _, _, ZoneMapID = GetInstanceInfo()

local mapID = C_Map.GetBestMapForUnit("player")

if (not mapID) then
Expand All @@ -577,14 +575,14 @@
ejid = Details:GetInstanceEJID()
end

local _, boss_index = Details:GetBossEncounterDetailsFromEncounterId(ZoneMapID, encounterID)
local _, boss_index = Details:GetBossEncounterDetailsFromEncounterId(zoneMapID, encounterID)

currentCombat.is_boss = {
index = boss_index or 0,
name = encounterName,
encounter = encounterName,
zone = ZoneName,
mapid = ZoneMapID,
zone = zoneName,
mapid = zoneMapID,
diff = DifficultyID,
diff_string = DifficultyName,
ej_instance_id = ejid or 0,
Expand All @@ -599,6 +597,23 @@
if (mythicLevel and mythicLevel >= 2) then
currentCombat.is_mythic_dungeon_segment = true
currentCombat.is_mythic_dungeon_run_id = Details.mythic_dungeon_id

---@type mythicdungeoninfo
local mythicPlusInfo = {
ZoneName = Details.MythicPlus.DungeonName or zoneName,
MapID = Details.MythicPlus.DungeonID or zoneMapID,
Level = Details.MythicPlus.Level,
EJID = Details.MythicPlus.ejID,
RunID = Details.mythic_dungeon_id,
StartedAt = time() - currentCombat:GetCombatTime(),
EndedAt = time(),
SegmentID = Details.MythicPlus.SegmentID, --segment number within the dungeon
--default to trash
SegmentType = DETAILS_SEGMENTTYPE_MYTHICDUNGEON_TRASH,
SegmentName = "Trash #" .. (Details.MythicPlus.SegmentID or 0), --localize-me
}

currentCombat.is_mythic_dungeon = mythicPlusInfo
end

--send item level after a combat if is in raid or party group
Expand All @@ -614,43 +629,27 @@
currentCombat.enemy = "[" .. ARENA .. "] " .. currentCombat.is_arena.name
end

local in_instance = IsInInstance() --garrison returns party as instance type.
if ((InstanceType == "party" or InstanceType == "raid") and in_instance) then
if (InstanceType == "party") then
if (currentCombat.is_mythic_dungeon_segment) then --setted just above
--is inside a mythic+ dungeon and this is not a boss segment, so tag it as a dungeon mythic+ trash segment
local zoneName, instanceType, difficultyID, difficultyName, maxPlayers, dynamicDifficulty, isDynamic, instanceMapID, instanceGroupSize = GetInstanceInfo()

---@type mythicdungeoninfo
local mythicPlusInfo = {
ZoneName = Details.MythicPlus.DungeonName or zoneName,
MapID = Details.MythicPlus.DungeonID or instanceMapID,
Level = Details.MythicPlus.Level,
EJID = Details.MythicPlus.ejID,
RunID = Details.mythic_dungeon_id,
StartedAt = time() - currentCombat:GetCombatTime(),
EndedAt = time(),
SegmentID = Details.MythicPlus.SegmentID, --segment number within the dungeon
OverallSegment = false,
SegmentType = DETAILS_SEGMENTTYPE_MYTHICDUNGEON_TRASH,
SegmentName = "Trash #" .. (Details.MythicPlus.SegmentID or 0), --localize-me
}
currentCombat.is_mythic_dungeon = mythicPlusInfo

currentCombat.is_mythic_dungeon_trash = true

if (Details.debug) then
Details:Msg("segment tagged as mythic+ trash.")
end
else
if (currentCombat.is_mythic_dungeon_segment) then
--is inside a mythic+ dungeon and this is not a boss segment, so tag it as a dungeon mythic+ trash segment
currentCombat.is_mythic_dungeon.SegmentType = DETAILS_SEGMENTTYPE_MYTHICDUNGEON_TRASH
currentCombat.is_mythic_dungeon.SegmentName = "Trash #" .. (Details.MythicPlus.SegmentID or 0) --localize-me
currentCombat.is_mythic_dungeon_trash = true

if (Details.debug) then
Details:Msg("segment tagged as mythic+ trash.")
end
end

local bInInstance = IsInInstance() --garrison returns party as instance type.
if ((instanceType == "party" or instanceType == "raid") and bInInstance) then
if (instanceType == "party") then
if (currentCombat.is_mythic_dungeon_segment) then
--tag the combat as trash clean up
currentCombat.is_trash = true
end
else
currentCombat.is_trash = true
end
else
if (not in_instance) then
if (not bInInstance) then
if (Details.world_combat_is_trash) then
currentCombat.is_world_trash_combat = true
end
Expand All @@ -669,6 +668,7 @@

Details:FlagActorsOnCommonFight() --fight_component
else
--combat is boss encounter
--calling here without checking for combat since the does not ran too long for scripts
Details:FlagActorsOnBossFight()

Expand All @@ -685,6 +685,11 @@
Details.schedule_store_boss_encounter = true
end

if (currentCombat.is_mythic_dungeon_segment) then
currentCombat.is_mythic_dungeon.SegmentType = DETAILS_SEGMENTTYPE_MYTHICDUNGEON_BOSS
currentCombat.is_mythic_dungeon.SegmentName = (currentCombat.is_boss.name or Loc["STRING_UNKNOW"]) .. " (" .. string.lower(_G["BOSS"]) .. ")"
end

Details:SendEvent("COMBAT_BOSS_DEFEATED", nil, currentCombat)
Details:CheckFor_TrashSuppressionOnEncounterEnd()
else
Expand All @@ -698,6 +703,11 @@
else
Details.schedule_store_boss_encounter_wipe = true
end

if (currentCombat.is_mythic_dungeon_segment) then
currentCombat.is_mythic_dungeon.SegmentType = DETAILS_SEGMENTTYPE_MYTHICDUNGEON_BOSSWIPE
currentCombat.is_mythic_dungeon.SegmentName = (currentCombat.is_boss.name or Loc["STRING_UNKNOW"]) .. " (" .. string.lower(_G["BOSS"]) .. ")"
end
end

currentCombat.is_boss.index = currentCombat.is_boss.index or 1
Expand Down
11 changes: 6 additions & 5 deletions frames/window_main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6658,7 +6658,7 @@ local buildSegmentTooltip = function(self, deltaTime)
--> current combat
local thisCombat = Details:GetCurrentCombat()
local dateStart, dateEnd = thisCombat:GetDate()
local segment_info_added
local bSegmentInfoAdded

local enemy = thisCombat.is_boss and thisCombat.is_boss.name or thisCombat.enemy or "--x--x--"
local file, coords
Expand All @@ -6675,8 +6675,9 @@ local buildSegmentTooltip = function(self, deltaTime)
if (mythicDungeonInfo) then
--is a boss, trash overall or run overall segment
local bossInfo = thisCombat.is_boss
local isMythicOverallSegment, segmentID, mythicLevel, EJID, mapID, zoneName, encounterID, encounterName, startedAt, endedAt, runID = Details:UnpackMythicDungeonInfo (mythicDungeonInfo)
local isMythicOverallSegment, segmentID, mythicLevel, EJID, mapID, zoneName, encounterID, encounterName, startedAt, endedAt, runID = Details:UnpackMythicDungeonInfo(mythicDungeonInfo)
local combatElapsedTime = thisCombat:GetCombatTime()
local combatName = thisCombat:GetCombatName()

--is mythic overall
if (isMythicOverallSegment) then
Expand All @@ -6694,7 +6695,7 @@ local buildSegmentTooltip = function(self, deltaTime)
gameCooltip:AddLine(encounterName .. " (" .. Loc["STRING_SEGMENTS_LIST_TRASH"] .. ")", nil, 2, "white", "white")
else
--CoolTip:AddLine(encounterName .. " (" .. Loc["STRING_SEGMENTS_LIST_BOSS"] .. ")", _detalhes.gump:IntegerToTimer(combat_time), 1, dungeon_color, "gray")
gameCooltip:AddLine(encounterName .. " (" .. Loc["STRING_SEGMENTS_LIST_BOSS"] .. ")", nil, 2, "white", "white")
gameCooltip:AddLine(combatName, nil, 2, "white", "white")
end
--CoolTip:AddIcon([[Interface\AddOns\Details\images\icons]], "main", "left", 14, 10, 479/512, 510/512, 24/512, 51/512)
end
Expand Down Expand Up @@ -6768,7 +6769,7 @@ local buildSegmentTooltip = function(self, deltaTime)
end
end

segment_info_added = true
bSegmentInfoAdded = true

elseif (thisCombat.is_boss and thisCombat.is_boss.name) then
local portrait = Details:GetBossPortrait(thisCombat.is_boss.mapid, thisCombat.is_boss.index) or thisCombat.is_boss.bossimage
Expand Down Expand Up @@ -6828,7 +6829,7 @@ local buildSegmentTooltip = function(self, deltaTime)
end
end

if (not segment_info_added) then
if (not bSegmentInfoAdded) then
gameCooltip:AddLine(Loc["STRING_SEGMENT_ENEMY"] .. ":", enemy, 2, "white", "white")

if (not thisCombat:GetEndTime()) then
Expand Down
Loading

0 comments on commit 7d8b84a

Please sign in to comment.