From ab333051bc3b498414b1bf1173d4a4a50ef1f782 Mon Sep 17 00:00:00 2001 From: Tercioo Date: Sat, 23 Feb 2019 14:55:50 -0300 Subject: [PATCH] - Framework update. - Schedules run after combat ends and no more after regen_enabled. --- Libs/DF/fw.lua | 2 +- Libs/DF/panel.lua | 8 ++- boot.lua | 3 +- core/control.lua | 1 + core/parser.lua | 135 ++++++++++++++++++++++++++++++++++++++------ functions/slash.lua | 3 +- 6 files changed, 129 insertions(+), 23 deletions(-) diff --git a/Libs/DF/fw.lua b/Libs/DF/fw.lua index a2e86470..3684c778 100644 --- a/Libs/DF/fw.lua +++ b/Libs/DF/fw.lua @@ -1,5 +1,5 @@ -local dversion = 139 +local dversion = 140 local major, minor = "DetailsFramework-1.0", dversion local DF, oldminor = LibStub:NewLibrary (major, minor) diff --git a/Libs/DF/panel.lua b/Libs/DF/panel.lua index b033a2ef..e34b0b84 100644 --- a/Libs/DF/panel.lua +++ b/Libs/DF/panel.lua @@ -5599,9 +5599,13 @@ function DF:CreateLoadFilterParser (callback) if (event == "ENCOUNTER_START") then local encounterID = ... f.EncounterIDCached = encounterID - - elseif (event == "PLAYER_REGEN_ENABLED") then + + elseif (event == "ENCOUNTER_END") then f.EncounterIDCached = nil + + elseif (event == "PLAYER_REGEN_ENABLED") then + --f.EncounterIDCached = nil + --when the player dies during an encounter, the game is triggering regen enabled elseif (event == "PLAYER_SPECIALIZATION_CHANGED") then if (DetailsFrameworkLoadConditionsPanel and DetailsFrameworkLoadConditionsPanel:IsShown()) then diff --git a/boot.lua b/boot.lua index 90665be7..d12b4693 100644 --- a/boot.lua +++ b/boot.lua @@ -5,7 +5,8 @@ _detalhes = LibStub("AceAddon-3.0"):NewAddon("_detalhes", "AceTimer-3.0", "AceComm-3.0", "AceSerializer-3.0", "NickTag-1.0") _detalhes.build_counter = 6902 - _detalhes.alpha_build_counter = 6902 --if this is higher than the regular counter, use it instead + _detalhes.alpha_build_counter = 6926 --if this is higher than the regular counter, use it instead + _detalhes.game_version = "v8.1.0" _detalhes.userversion = "v8.1.0." .. _detalhes.build_counter _detalhes.realversion = 135 --core version, this is used to check API version for scripts and plugins (see alias below) _detalhes.APIVersion = _detalhes.realversion --core version diff --git a/core/control.lua b/core/control.lua index 7e9d8279..36d77099 100644 --- a/core/control.lua +++ b/core/control.lua @@ -875,6 +875,7 @@ _detalhes.StoreSpells() + _detalhes:RunScheduledEventsAfterCombat() end function _detalhes:GetPlayersInArena() diff --git a/core/parser.lua b/core/parser.lua index 87f5d4ae..5bd5e7a9 100644 --- a/core/parser.lua +++ b/core/parser.lua @@ -4224,6 +4224,7 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1 end _current_encounter_id = nil + _track_ghuun_bloodshield = nil --REMOVE ON PATCH 9.0 local _, instanceType = GetInstanceInfo() --> let's make sure it isn't a dungeon if (_detalhes.zone_type == "party" or instanceType == "party") then @@ -4306,22 +4307,53 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1 _detalhes.tabela_vigente.CombatStartedAt = GetTime() end - function _detalhes.parser_functions:PLAYER_REGEN_ENABLED (...) - - --elapsed combat time - _detalhes.LatestCombatDone = GetTime() - _detalhes.tabela_vigente.CombatEndedAt = GetTime() - _detalhes.tabela_vigente.TotalElapsedCombatTime = _detalhes.tabela_vigente.CombatEndedAt - (_detalhes.tabela_vigente.CombatStartedAt or 0) - - _current_encounter_id = nil - _track_ghuun_bloodshield = nil --REMOVE ON PATCH 9.0 - - --> playing alone, just finish the combat right now - if (not _IsInGroup() and not IsInRaid()) then - _detalhes.tabela_vigente.playing_solo = true - _detalhes:SairDoCombate() + --in case the player left the raid during the encounter + local check_for_encounter_end = function() + if (not _current_encounter_id) then + return end + if (IsInRaid()) then + --raid + local inCombat = false + for i = 1, GetNumGroupMembers() do + if (UnitAffectingCombat ("raid" .. i)) then + inCombat = true + break + end + end + + if (not inCombat) then + _current_encounter_id = nil + end + + elseif (IsInGroup()) then + --party (dungeon) + local inCombat = false + for i = 1, GetNumGroupMembers() -1 do + if (UnitAffectingCombat ("party" .. i)) then + inCombat = true + break + end + end + + if (not inCombat) then + _current_encounter_id = nil + end + + else + _current_encounter_id = nil + end + end + + --> this function is guaranteed to run after a combat is done + --> can also run when the player leaves combat state (regen enabled) + function _detalhes:RunScheduledEventsAfterCombat (OnRegenEnabled) + + if (_detalhes.debug) then + _detalhes:Msg ("(debug) running scheduled events after combat end.") + end + --> add segments to overall data if any scheduled if (_detalhes.schedule_add_to_overall and #_detalhes.schedule_add_to_overall > 0) then if (_detalhes.debug) then @@ -4411,7 +4443,7 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1 end end - if (_detalhes.wipe_called) then + if (_detalhes.wipe_called and false) then --disabled _detalhes.wipe_called = nil _detalhes:CaptureSet (nil, "damage", true) _detalhes:CaptureSet (nil, "energy", true) @@ -4426,10 +4458,77 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1 _detalhes:CaptureSet (false, "spellcast", false, 10) end - _table_wipe (bitfield_swap_cache) - _table_wipe (ignore_actors) + if (not OnRegenEnabled) then + _table_wipe (bitfield_swap_cache) + _table_wipe (ignore_actors) + + _detalhes:DispatchAutoRunCode ("on_leavecombat") + end + + end + + function _detalhes.parser_functions:PLAYER_REGEN_ENABLED (...) + + if (_detalhes.debug) then + _detalhes:Msg ("(debug) |cFFFFFF00PLAYER_REGEN_ENABLED|r event triggered.") + + print ("combat lockdown:", InCombatLockdown()) + print ("affecting combat:", UnitAffectingCombat ("player")) + + if (_current_encounter_id and IsInInstance()) then + print ("has a encounter ID") + print ("player is dead:", UnitHealth ("player") < 1) + end + end + + --elapsed combat time + _detalhes.LatestCombatDone = GetTime() + _detalhes.tabela_vigente.CombatEndedAt = GetTime() + _detalhes.tabela_vigente.TotalElapsedCombatTime = _detalhes.tabela_vigente.CombatEndedAt - (_detalhes.tabela_vigente.CombatStartedAt or 0) + + -- + C_Timer.After (10, check_for_encounter_end) + + --> playing alone, just finish the combat right now + if (not _IsInGroup() and not IsInRaid()) then + _detalhes.tabela_vigente.playing_solo = true + _detalhes:SairDoCombate() + + else + --is in a raid or party group + C_Timer.After (1, function() + local inCombat + if (IsInRaid()) then + --raid + local inCombat = false + for i = 1, GetNumGroupMembers() do + if (UnitAffectingCombat ("raid" .. i)) then + inCombat = true + break + end + end + + if (not inCombat) then + _detalhes:RunScheduledEventsAfterCombat (true) + end + + elseif (IsInGroup()) then + --party (dungeon) + local inCombat = false + for i = 1, GetNumGroupMembers() -1 do + if (UnitAffectingCombat ("party" .. i)) then + inCombat = true + break + end + end + + if (not inCombat) then + _detalhes:RunScheduledEventsAfterCombat (true) + end + end + end) + end - _detalhes:DispatchAutoRunCode ("on_leavecombat") end function _detalhes.parser_functions:PLAYER_TALENT_UPDATE() diff --git a/functions/slash.lua b/functions/slash.lua index 4a69d49a..5f742b91 100644 --- a/functions/slash.lua +++ b/functions/slash.lua @@ -1664,7 +1664,8 @@ Damage Update Status: @INSTANCEDAMAGESTATUS end print (" ") - print (Loc ["STRING_DETAILS1"] .. "" .. _detalhes.userversion .. " [|cFFFFFF00CORE: " .. _detalhes.realversion .. "|r] " .. Loc ["STRING_COMMAND_LIST"] .. ":") + local v = _detalhes.game_version .. "." .. (_detalhes.build_counter >= _detalhes.alpha_build_counter and _detalhes.build_counter or _detalhes.alpha_build_counter) + print (Loc ["STRING_DETAILS1"] .. "" .. v .. " [|cFFFFFF00CORE: " .. _detalhes.realversion .. "|r] " .. Loc ["STRING_COMMAND_LIST"] .. ":") print ("|cffffaeae/details|r |cffffff33" .. Loc ["STRING_SLASH_NEW"] .. "|r: " .. Loc ["STRING_SLASH_NEW_DESC"]) print ("|cffffaeae/details|r |cffffff33" .. Loc ["STRING_SLASH_SHOW"] .. " " .. Loc ["STRING_SLASH_HIDE"] .. " " .. Loc ["STRING_SLASH_TOGGLE"] .. "|r|cfffcffb0 <" .. Loc ["STRING_WINDOW_NUMBER"] .. ">|r: " .. Loc ["STRING_SLASH_SHOWHIDETOGGLE_DESC"])