From e8a0380153fd775985c9fd867d5711b4df18e068 Mon Sep 17 00:00:00 2001 From: Tercio Jose Date: Thu, 20 May 2021 21:15:50 -0300 Subject: [PATCH] Fix for Battleground One Segment --- core/control.lua | 4 +-- core/parser.lua | 75 +++++++++++++++++++++++++----------------------- core/util.lua | 47 ++++++++++++++++++------------ 3 files changed, 68 insertions(+), 58 deletions(-) diff --git a/core/control.lua b/core/control.lua index d5196d249..3e97b1401 100644 --- a/core/control.lua +++ b/core/control.lua @@ -454,9 +454,7 @@ end function Details:EndCombat() - if (Details.in_combat) then - Details:SairDoCombate() - end + return Details:SairDoCombate() end -- ~end ~leave diff --git a/core/parser.lua b/core/parser.lua index 30545673f..80ac761a7 100755 --- a/core/parser.lua +++ b/core/parser.lua @@ -4448,11 +4448,13 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1 function _detalhes:GetZoneType() return _detalhes.zone_type end + function _detalhes.parser_functions:ZONE_CHANGED_NEW_AREA (...) - return _detalhes:ScheduleTimer ("Check_ZONE_CHANGED_NEW_AREA", 0.5) + return Details.Schedules.After(1, Details.Check_ZONE_CHANGED_NEW_AREA) end - function _detalhes:Check_ZONE_CHANGED_NEW_AREA (...) + function _detalhes:Check_ZONE_CHANGED_NEW_AREA() + local zoneName, zoneType, _, _, _, _, _, zoneMapID = _GetInstanceInfo() _detalhes.zone_type = zoneType @@ -4489,8 +4491,10 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1 if (_detalhes.is_in_arena and zoneType ~= "arena") then _detalhes:LeftArena() end + + --check if the player left a battleground if (_detalhes.is_in_battleground and zoneType ~= "pvp") then - --_detalhes.pvp_parser_frame:StopBgUpdater() + _detalhes.pvp_parser_frame:StopBgUpdater() _detalhes.is_in_battleground = nil _detalhes.time_type = _detalhes.time_type_original end @@ -4519,7 +4523,7 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1 _detalhes.time_type_original = 1 _detalhes.time_type = 2 end - --_detalhes.pvp_parser_frame:StartBgUpdater() --battleground parser has been disbled + _detalhes.pvp_parser_frame:StartBgUpdater() else if (_detalhes.force_activity_time_pvp) then _detalhes.time_type_original = _detalhes.time_type @@ -4576,12 +4580,12 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1 _detalhes:CheckForPerformanceProfile() end - function _detalhes.parser_functions:PLAYER_ENTERING_WORLD (...) - return _detalhes.parser_functions:ZONE_CHANGED_NEW_AREA (...) + function _detalhes.parser_functions:PLAYER_ENTERING_WORLD () + return _detalhes.parser_functions:ZONE_CHANGED_NEW_AREA() end -- ~encounter - function _detalhes.parser_functions:ENCOUNTER_START (...) + function _detalhes.parser_functions:ENCOUNTER_START(...) if (_detalhes.debug) then _detalhes:Msg ("(debug) |cFFFFFF00ENCOUNTER_START|r event triggered.") end @@ -5183,32 +5187,34 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1 --check if the player is inside a battleground elseif (zoneType == "battleground") then - if (_detalhes.debug) then - _detalhes:Msg ("(debug) timer is a battleground countdown.") + if (Details.debug) then + Details:Msg ("(debug) timer is a battleground countdown.") end local _, timeSeconds = select (1, ...) - if (_detalhes.start_battleground) then - _detalhes:CancelTimer(_detalhes.start_battleground, true) + if (Details.start_battleground) then + Details.Schedules.Cancel(Details.start_battleground) end - - _detalhes.start_battleground = _detalhes:ScheduleTimer("CreateBattlegroundSegment", timeSeconds) + + --create new schedule + Details.start_battleground = Details.Schedules.NewTimer(timeSeconds, Details.CreateBattlegroundSegment) + Details.Schedules.SetName(Details.start_battleground, "Battleground Start Timer") end end - function _detalhes:CreateBattlegroundSegment() + function Details:CreateBattlegroundSegment() if (_in_combat) then _detalhes.tabela_vigente.discard_segment = true - _detalhes:SairDoCombate() + Details:EndCombat() end - _detalhes:EntrarEmCombate() + Details:StartCombat() end -- ~load local start_details = function() if (not _detalhes.gump) then - --> failed to load the framework. + --> failed to load the framework if (not _detalhes.instance_load_failed) then _detalhes:CreatePanicWarning() @@ -5784,9 +5790,7 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --> battleground parser - - --[=[ - + _detalhes.pvp_parser_frame:SetScript ("OnEvent", function (self, event) self:ReadPvPData() end) @@ -5795,30 +5799,32 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1 RequestBattlefieldScoreData() end + --start the virtual parser function _detalhes.pvp_parser_frame:StartBgUpdater() - - _detalhes.pvp_parser_frame:RegisterEvent ("UPDATE_BATTLEFIELD_SCORE") + _detalhes.pvp_parser_frame:RegisterEvent("UPDATE_BATTLEFIELD_SCORE") + if (_detalhes.pvp_parser_frame.ticker) then - _detalhes:CancelTimer (_detalhes.pvp_parser_frame.ticker) + Details.Schedules.Cancel(_detalhes.pvp_parser_frame.ticker) end - _detalhes.pvp_parser_frame.ticker = _detalhes:ScheduleRepeatingTimer ("BgScoreUpdate", 10) + _detalhes.pvp_parser_frame.ticker = Details.Schedules.NewTicker(10, Details.BgScoreUpdate) + Details.Schedules.SetName(_detalhes.pvp_parser_frame.ticker, "Battleground Updater") end + --stop the virtual parser function _detalhes.pvp_parser_frame:StopBgUpdater() - _detalhes.pvp_parser_frame:UnregisterEvent ("UPDATE_BATTLEFIELD_SCORE") - _detalhes:CancelTimer (_detalhes.pvp_parser_frame.ticker) + _detalhes.pvp_parser_frame:UnregisterEvent("UPDATE_BATTLEFIELD_SCORE") + Details.Schedules.Cancel(_detalhes.pvp_parser_frame.ticker) _detalhes.pvp_parser_frame.ticker = nil end function _detalhes.pvp_parser_frame:ReadPvPData() - local players = GetNumBattlefieldScores() for i = 1, players do - - local name, killingBlows, honorableKills, deaths, honorGained, faction, race, class, classToken, damageDone, healingDone, bgRating, ratingChange, preMatchMMR, mmrChange, talentSpec = GetBattlefieldScore (i) + local name, killingBlows, honorableKills, deaths, honorGained, faction, race, class, classToken, damageDone, healingDone, bgRating, ratingChange, preMatchMMR, mmrChange, talentSpec = GetBattlefieldScore(i) - local actor = _detalhes.tabela_vigente (1, name) + --damage done + local actor = _detalhes.tabela_vigente(1, name) if (actor) then if (damageDone == 0) then damageDone = damageDone + _detalhes:GetOrderNumber() @@ -5846,7 +5852,8 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1 end end - local actor = _detalhes.tabela_vigente (2, name) + --healing done + local actor = _detalhes.tabela_vigente(2, name) if (actor) then if (healingDone == 0) then healingDone = healingDone + _detalhes:GetOrderNumber() @@ -5874,9 +5881,5 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1 end end end - end - - end - --]=] - + end \ No newline at end of file diff --git a/core/util.lua b/core/util.lua index d55d22d73..76ddda802 100644 --- a/core/util.lua +++ b/core/util.lua @@ -1101,39 +1101,48 @@ end _detalhes:TimeDataTick() _detalhes:BrokerTick() _detalhes:HealthTick() - + + local _, zoneType = GetInstanceInfo() + if (Details.Coach.Server.IsEnabled()) then if (Details.debug) then print("coach server is enabled, can't leave combat...") end return true - elseif ((_detalhes.zonetype == "pvp" and _detalhes.use_battleground_server_parser) or _detalhes.zonetype == "arena" or _InCombatLockdown()) then + --battleground + elseif (zoneType == "pvp" and _detalhes.use_battleground_server_parser) then return true - - elseif (_UnitAffectingCombat("player")) then + + --arena + elseif (zoneType == "arena" or _InCombatLockdown()) then return true - - elseif (_IsInRaid()) then - for i = 1, _GetNumGroupMembers(), 1 do - if (_UnitAffectingCombat ("raid"..i)) then - return true + + --is in combat + elseif (_UnitAffectingCombat("player")) then + return true + + elseif (_IsInRaid()) then + for i = 1, _GetNumGroupMembers(), 1 do + if (_UnitAffectingCombat ("raid"..i)) then + return true + end end - end - - elseif (_IsInGroup()) then - for i = 1, _GetNumGroupMembers()-1, 1 do - if (_UnitAffectingCombat ("party"..i)) then - return true + + elseif (_IsInGroup()) then + for i = 1, _GetNumGroupMembers()-1, 1 do + if (_UnitAffectingCombat ("party"..i)) then + return true + end end end - end - - --mythic dungeon test + + --mythic dungeon always in combat if (_detalhes.MythicPlus.Started and _detalhes.mythic_plus.always_in_combat) then return true end + --coach feature if (not Details.Coach.Server.IsEnabled()) then if (Details.debug) then Details:Msg("coach is disabled, the combat is now over!") @@ -1142,7 +1151,7 @@ end _detalhes:SairDoCombate() end - + function _detalhes:FindGUIDFromName (name) if (_IsInRaid()) then for i = 1, _GetNumGroupMembers(), 1 do