Skip to content

Commit

Permalink
Fix for Battleground One Segment
Browse files Browse the repository at this point in the history
  • Loading branch information
Tercioo committed May 21, 2021
1 parent 9ea6081 commit e8a0380
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 58 deletions.
4 changes: 1 addition & 3 deletions core/control.lua
Original file line number Diff line number Diff line change
Expand Up @@ -454,9 +454,7 @@
end

function Details:EndCombat()
if (Details.in_combat) then
Details:SairDoCombate()
end
return Details:SairDoCombate()
end

-- ~end ~leave
Expand Down
75 changes: 39 additions & 36 deletions core/parser.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand All @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -5874,9 +5881,5 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1
end
end
end
end
end
--]=]

end
47 changes: 28 additions & 19 deletions core/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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!")
Expand All @@ -1142,7 +1151,7 @@ end

_detalhes:SairDoCombate()
end

function _detalhes:FindGUIDFromName (name)
if (_IsInRaid()) then
for i = 1, _GetNumGroupMembers(), 1 do
Expand Down

0 comments on commit e8a0380

Please sign in to comment.