Finished the first 'Alpha Version' of the Coach feature

This commit is contained in:
Tercio Jose
2020-12-19 19:25:11 -03:00
parent 4d1747f8a8
commit ec5fad443a
9 changed files with 318 additions and 308 deletions
+11 -4
View File
@@ -4,10 +4,10 @@
_ = nil
_detalhes = LibStub("AceAddon-3.0"):NewAddon("_detalhes", "AceTimer-3.0", "AceComm-3.0", "AceSerializer-3.0", "NickTag-1.0")
_detalhes.build_counter = 8002
_detalhes.alpha_build_counter = 8002 --if this is higher than the regular counter, use it instead
_detalhes.game_version = "v9.0.1"
_detalhes.userversion = "v9.0.1." .. _detalhes.build_counter
_detalhes.build_counter = 8093
_detalhes.alpha_build_counter = 8093 --if this is higher than the regular counter, use it instead
_detalhes.game_version = "v9.0.2"
_detalhes.userversion = "v9.0.2." .. _detalhes.build_counter
_detalhes.realversion = 144 --core version, this is used to check API version for scripts and plugins (see alias below)
_detalhes.APIVersion = _detalhes.realversion --core version
_detalhes.version = _detalhes.userversion .. " (core " .. _detalhes.realversion .. ")" --simple stirng to show to players
@@ -28,6 +28,13 @@ do
local Loc = _G.LibStub("AceLocale-3.0"):GetLocale( "Details" )
local news = {
{"v9.0.1.8001.144", "December 19th, 2020"},
"Added Details! Coach as a new experimental feature, you may want to test using /details coach",
"Coach feature allows the raid leader to stay outside the raid while seeing in real time player deaths and damage information.",
"Fixed issues with some raid encounters in Castle Nathria.",
"Druid Kyrian Spirits ability now has some rules to credit the druid for damage and heal.",
"Several small bug fixes has been done.",
{"v9.0.1.8001.144", "November 30rd, 2020"},
"Added back the report to bnet friend.",
"@Flamanis: fixed issues on custom displays.",
+4 -18
View File
@@ -412,14 +412,8 @@
return false
end
if (msgType == "CIEA") then --Coach Is Enabled Ask (regular player asked to raid leader)
--check if the player that received the msg is the raid leader
if (UnitIsGroupLeader("player")) then
return
end
--send the answer
Details:SendCommMessage(DETAILS_PREFIX_NETWORK, Details:Serialize(DETAILS_PREFIX_COACH, playerName, GetRealmName(), Details.realversion, "CIER", Details.Coach.Server.IsEnabled()), "WHISPER", sourcePlayer)
if (msgType == "CIEA") then --Is Coach Enabled Ask (regular player asked to raid leader)
Details.Coach.Server.CoachIsEnabled_Answer(sourcePlayer)
elseif (msgType == "CIER") then --Coach Is Enabled Response (regular player received a raid leader response)
local isEnabled = data
@@ -444,22 +438,14 @@
if (UnitIsGroupLeader("player")) then
if (Details.Coach.Server.IsEnabled()) then
--update the current combat with new information
--this is disabled due to lack of testing
if (_detalhes.debug) then
Details.packFunctions.DeployPackedCombatData(data)
end
Details.packFunctions.DeployPackedCombatData(data)
end
end
elseif (msgType == "CDD") then --Coach Death (a player in the raid sent to raid leader his death log)
if (UnitIsGroupLeader("player")) then
if (Details.Coach.Server.IsEnabled()) then
local currentCombat = Details:GetCurrentCombat()
tinsert(currentCombat.last_events_tables, data)
--tag the misc container as need refresh
currentCombat[DETAILS_ATTRIBUTE_MISC].need_refresh = true
Details.Coach.Server.AddPlayerDeath(sourcePlayer, data)
end
end
end
+22 -1
View File
@@ -264,6 +264,9 @@
local SPELLID_KYRIAN_DRUID_DAMAGE = 338411
local SPELLID_KYRIAN_DRUID_HEAL = 327149
local SPELLID_KYRIAN_DRUID_TANK = 327037
local SPELLID_BARGAST_DEBUFF = 334695
local bargastBuffs = {}
--> spells with special treatment
local special_damage_spells = {
@@ -718,6 +721,7 @@
if (absorbed) then
amount = absorbed + (amount or 0)
end
if (_is_in_instance) then
if (overkill and overkill > 0) then
--if enabled it'll cut the amount of overkill from the last hit (which killed the actor)
@@ -725,6 +729,14 @@
--amount = amount - overkill
end
end
if (bargastBuffs[alvo_serial]) then --REMOVE ON 10.0
local stacks = bargastBuffs[alvo_serial]
if (stacks) then
local newDamage = amount / stacks
amount = newDamage
end
end
if (este_jogador.grupo and not este_jogador.arena_enemy and not este_jogador.enemy) then --> source = friendly player and not an enemy player
--dano to adversario estava caindo aqui por nao estar checando .enemy
@@ -2134,8 +2146,12 @@ SPELL_HEAL,Player-3209-0A79112C,"Symantec-Azralon",0x511,0x0,Player-3209-065BAED
reflection_debuffs[who_serial][spellid] = true
end
if (spellid == SPELLID_BARGAST_DEBUFF) then --REMOVE ON 10.0
bargastBuffs[alvo_serial] = (bargastBuffs[alvo_serial] or 0) + 1
end
if (_in_combat) then
------------------------------------------------------------------------------------------------
--> buff uptime
if (_recording_buffs_and_debuffs) then
@@ -2387,6 +2403,10 @@ SPELL_HEAL,Player-3209-0A79112C,"Symantec-Azralon",0x511,0x0,Player-3209-065BAED
who_serial, who_name, who_flags = "", enemyName, 0xa48
end
if (spellid == SPELLID_BARGAST_DEBUFF) then
bargastBuffs[alvo_serial] = (bargastBuffs[alvo_serial] or 0) + 1
end
if (_in_combat) then
------------------------------------------------------------------------------------------------
--> buff uptime
@@ -4645,6 +4665,7 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1
_detalhes:SendEvent ("COMBAT_ENCOUNTER_END", nil, ...)
_table_wipe (_detalhes.encounter_table)
_table_wipe (bargastBuffs)
return true
end
+6 -1
View File
@@ -184,7 +184,12 @@ function Details.CooldownTracking.RefreshScreenPanel()
--print("timeLeft:", timeLeft, spellNameDebug)
else
bar:SetMinMaxValues(0, 100)
bar:SetValue(100)
bar:SetTimer(0)
--print(spellNameDebug)
C_Timer.After(1, function()
-- bar:SetMinMaxValues(0, 100)
-- bar:SetTimer(0)
end)
end
end
end
-6
View File
@@ -5054,12 +5054,6 @@ function _detalhes:SetWindowAlphaForCombat (entering_in_combat, true_hide, alpha
self:InstanceAlpha(min (amount, self.color[4]))
gump:Fade(self.rowframe, "ALPHAANIM", rowsamount)
gump:Fade(self.baseframe, "ALPHAANIM", rowsamount)
--self:SetIconAlpha(menuamount)
if (_detalhes.debug) then
_detalhes:Msg ("(debug) showing window SetWindowAlphaForCombat()", amount, rowsamount, menuamount)
end
--]]
end
+168 -2
View File
@@ -247,15 +247,32 @@ function Details.Coach.StartUp()
eventListener:RegisterEvent("ZONE_TYPE_CHANGED", "OnZoneChanged")
end
C_Timer.After(0.1, function()
--Details.debug = true
end)
--received an answer from server telling if the raidleader has the coach feature enabled
--the request is made when the player enters a new group or reconnects
function Details.Coach.Client.CoachIsEnabled_Response(isCoachEnabled, raidLeaderName)
if (_detalhes.debug) then
Details:Msg("[|cFFAAFFAADetails! Coach|r] Raid Leader sent response about the status of Coach Mode:", isCoachEnabled, raidLeaderName)
end
if (isCoachEnabled) then
--raid leader confirmed the coach feature is enabled and running
Details.Coach.Client.EnableCoach(raidLeaderName)
Details:Msg("[|cFFAAFFAADetails! Coach|r] current coach:", raidLeaderName)
end
end
function Details.Coach.Server.CoachIsEnabled_Answer(sourcePlayer)
if (not UnitIsGroupLeader("player")) then
return
end
--send the answer
Details:SendCommMessage(_G.DETAILS_PREFIX_NETWORK, Details:Serialize(_G.DETAILS_PREFIX_COACH, sourcePlayer, GetRealmName(), Details.realversion, "CIER", Details.Coach.Server.IsEnabled()), "WHISPER", sourcePlayer)
end
function Details.Coach.Disable()
Details.coach.enabled = false --profile
@@ -345,6 +362,8 @@ function Details.Coach.Client.EnableCoach(raidLeaderName)
if (_detalhes.debug) then
Details:Msg("[|cFFAAFFAADetails! Coach|r] there's a new coach: ", raidLeaderName)
end
Details:Msg("[|cFFAAFFAADetails! Coach|r] current coach:", raidLeaderName)
end
--raid leader received a notification that a new combat has started
@@ -443,14 +462,161 @@ Details.Coach.EventFrame:SetScript("OnEvent", function(event, ...)
end
end)
function Details.Coach.Client.SendMyDeath(_, _, _, _, _, _, playerGUID, _, _, deathTable)
function Details.Coach.Client.SendMyDeath(_, _, _, _, _, _, playerGUID, _, playerFlag, deathTable)
if (Details.Coach.Client.enabled) then
if (Details.Coach.Client.coachName) then
if (Details.in_combat) then
if (playerGUID == UnitGUID("player")) then
Details.Coach.SendDeathToRL(deathTable)
Details.Coach.SendDeathToRL({deathTable, playerGUID, playerFlag})
end
end
end
end
end
function Details.Coach.Server.AddPlayerDeath(playerName, data)
local currentCombat = Details:GetCurrentCombat()
local utilityContainer = currentCombat[4]
local deathLog = data[1]
local playerGUID = data[2]
local playerFlag = data[3]
local utilityActorObject = utilityContainer:GetOrCreateActor(playerGUID, playerName, playerFlag, true)
if (utilityActorObject) then
tinsert(currentCombat.last_events_tables, deathLog)
--tag the misc container as need refresh
currentCombat[DETAILS_ATTRIBUTE_MISC].need_refresh = true
end
end
function Details.Coach.WelcomePanel()
local welcomePanel = _G.DETAILSCOACHPANEL
if (not welcomePanel) then
welcomePanel = DetailsFramework:CreateSimplePanel(UIParent)
welcomePanel:SetSize (400, 280)
welcomePanel:SetTitle ("Details! Coach")
welcomePanel:ClearAllPoints()
welcomePanel:SetPoint ("left", UIParent, "left", 10, 0)
welcomePanel:Hide()
DetailsFramework:ApplyStandardBackdrop(welcomePanel)
local LibWindow = _G.LibStub("LibWindow-1.1")
welcomePanel:SetScript("OnMouseDown", nil)
welcomePanel:SetScript("OnMouseUp", nil)
LibWindow.RegisterConfig(welcomePanel, Details.coach.welcome_panel_pos)
LibWindow.MakeDraggable(welcomePanel)
LibWindow.RestorePosition(welcomePanel)
local detailsLogo = DetailsFramework:CreateImage(welcomePanel, [[Interface\AddOns\Details\images\logotipo]])
detailsLogo:SetPoint("topleft", welcomePanel, "topleft", 5, -30)
detailsLogo:SetSize(200, 50)
detailsLogo:SetTexCoord(36/512, 380/512, 128/256, 227/256)
local isLeaderTexture = DetailsFramework:CreateImage(welcomePanel, [[Interface\GLUES\LOADINGSCREENS\DynamicElements]], 32, 32)
isLeaderTexture:SetTexCoord(0, 0.5, 0, 0.5)
isLeaderTexture:SetPoint("topleft", detailsLogo, "topleft", 0, -60)
local isLeaderText = DetailsFramework:CreateLabel(welcomePanel, "In raid and You're the leader of the group.")
isLeaderText:SetPoint("left", isLeaderTexture, "right", 10, 0)
local isOutsideTexture = DetailsFramework:CreateImage(welcomePanel, [[Interface\GLUES\LOADINGSCREENS\DynamicElements]], 32, 32)
isOutsideTexture:SetTexCoord(0, 0.5, 0, 0.5)
isOutsideTexture:SetPoint("topleft", isLeaderTexture, "bottomleft", 0, -5)
local isOutsideText = DetailsFramework:CreateLabel(welcomePanel, "You're outside of the instance.")
isOutsideText:SetPoint("left", isOutsideTexture, "right", 10, 0)
local hasAssistantsTexture = DetailsFramework:CreateImage(welcomePanel, [[Interface\GLUES\LOADINGSCREENS\DynamicElements]], 32, 32)
hasAssistantsTexture:SetTexCoord(0, 0.5, 0, 0.5)
hasAssistantsTexture:SetPoint("topleft", isOutsideTexture, "bottomleft", 0, -5)
local hasAssistantsText = DetailsFramework:CreateLabel(welcomePanel, "There's an 'raid assistant' inside the raid.")
hasAssistantsText:SetPoint("left", hasAssistantsTexture, "right", 10, 0)
local beInGroupSevenTexture = DetailsFramework:CreateImage(welcomePanel, [[Interface\GLUES\LOADINGSCREENS\DynamicElements]], 32, 32)
beInGroupSevenTexture:SetTexCoord(0, 0.5, 0, 0.5)
beInGroupSevenTexture:SetPoint("topleft", hasAssistantsTexture, "bottomleft", 0, -5)
local beInGroupSevenText = DetailsFramework:CreateLabel(welcomePanel, "Stay in group 7 or 8.")
beInGroupSevenText:SetPoint("left", beInGroupSevenTexture, "right", 10, 0)
local startCoachButton = DetailsFramework:CreateButton(welcomePanel, function()
Details.coach.enabled = true
Details.Coach.Server.EnableCoach()
welcomePanel:Hide()
Details:Msg("welcome aboard commander!")
end, 80, 20, "Start Coaching!")
startCoachButton:SetPoint("bottomright", welcomePanel, "bottomright", -10, 10)
startCoachButton:SetTemplate(DetailsFramework:GetTemplate ("button", "OPTIONS_BUTTON_TEMPLATE"))
function welcomePanel.Update()
local good = 0
if (IsInRaid() and UnitIsGroupLeader("player")) then
isLeaderTexture:SetTexture([[Interface\COMMON\Indicator-Green]])
isLeaderTexture:SetTexCoord(0, 1, 0, 1)
good = good + 1
else
isLeaderTexture:SetTexture([[Interface\GLUES\LOADINGSCREENS\DynamicElements]])
isLeaderTexture:SetTexCoord(0, 0.5, 0, 0.5)
end
if (not IsInInstance()) then
isOutsideTexture:SetTexture([[Interface\COMMON\Indicator-Green]])
isOutsideTexture:SetTexCoord(0, 1, 0, 1)
good = good + 1
else
isOutsideTexture:SetTexture([[Interface\GLUES\LOADINGSCREENS\DynamicElements]])
isOutsideTexture:SetTexCoord(0, 0.5, 0, 0.5)
end
local hasAssistant = false
for i = 1, GetNumGroupMembers() do
if (UnitIsGroupAssistant("raid" .. i) and UnitName("raid" .. i) ~= UnitName("player")) then
hasAssistant = true
break
end
end
if (hasAssistant) then
hasAssistantsTexture:SetTexture([[Interface\COMMON\Indicator-Green]])
hasAssistantsTexture:SetTexCoord(0, 1, 0, 1)
good = good + 1
else
hasAssistantsTexture:SetTexture([[Interface\GLUES\LOADINGSCREENS\DynamicElements]])
hasAssistantsTexture:SetTexCoord(0, 0.5, 0, 0.5)
end
local isInCorrectGroup = false
for i = 1, GetNumGroupMembers() do
local name, rank, subgroup, level, class, fileName, zone, online, isDead, role, isML = GetRaidRosterInfo(i)
if (rank == 2) then
if (subgroup == 7 or subgroup == 8) then
isInCorrectGroup = true
break
end
end
end
if (isInCorrectGroup) then
beInGroupSevenTexture:SetTexture([[Interface\COMMON\Indicator-Green]])
beInGroupSevenTexture:SetTexCoord(0, 1, 0, 1)
good = good + 1
else
beInGroupSevenTexture:SetTexture([[Interface\GLUES\LOADINGSCREENS\DynamicElements]])
beInGroupSevenTexture:SetTexCoord(0, 0.5, 0, 0.5)
end
if (good == 4) then
startCoachButton:Enable()
else
startCoachButton:Disable()
end
end
end
welcomePanel:SetScript("OnUpdate", function()
welcomePanel:Update()
end)
welcomePanel:Show()
end
+104 -176
View File
@@ -50,13 +50,7 @@ local TOTAL_INDEXES_FOR_COMBAT_INFORMATION = 6
local entitySerialCounter = 0
local isDebugging = true
function Dexport() --test case
local combat = Details:GetCurrentCombat()
local readyToSendData = Details.packFunctions.PackCombatData(combat, 0x1)
local newCombatWithData = Details.packFunctions.UnPackCombatData(readyToSendData)
end
local isDebugging = false
function Details.packFunctions.GetAllData()
local combat = Details:GetCurrentCombat()
@@ -112,7 +106,7 @@ function Details.packFunctions.PackCombatData(combatObject, flags)
Details.packFunctions.PackDamage(combatObject)
end
if (bit.band(flags, 0x2) ~= 0) then
if (bit.band(flags, 0x2) ~= 0 and false) then
Details.packFunctions.PackHeal(combatObject)
end
@@ -140,7 +134,7 @@ function Details.packFunctions.PackCombatData(combatObject, flags)
end
--add the heal actors data
if (bit.band(flags, 0x2) ~= 0) then
if (bit.band(flags, 0x2) ~= 0 and false) then
exportedString = exportedString .. "!H" .. ","
for index, data in ipairs(actorHealInfo) do
exportedString = exportedString .. data .. ","
@@ -157,6 +151,8 @@ function Details.packFunctions.PackCombatData(combatObject, flags)
print(exportedString)
end
--Details:Dump({exportedString})
--compress
local LibDeflate = _G.LibStub:GetLibrary("LibDeflate")
local dataCompressed = LibDeflate:CompressDeflate(exportedString, {level = 9})
@@ -402,7 +398,7 @@ end
function Details.packFunctions.PackDamage(combatObject)
if (isDebugging) then
print("PackDamage(): START.")
print("PackDamage(): start.")
end
--store actorObjects to pack
@@ -413,7 +409,7 @@ function Details.packFunctions.PackDamage(combatObject)
local playerObject = combatObject:GetActor(DETAILS_ATTRIBUTE_DAMAGE, playerName)
if (not playerObject) then
if (isDebugging) then
print("PackDamage(): RETURN | no player object.")
print("PackDamage(): return | no player object.")
end
return
end
@@ -429,21 +425,11 @@ function Details.packFunctions.PackDamage(combatObject)
end
end
local playerIndex
--check if this player has to send information about an enemy npc
if (IsInGroup()) then
for i = 1, GetNumGroupMembers() do
local name = GetRaidRosterInfo(i) --, rank, subgroup, level, class, fileName, zone, online, isDead, role, isML
if (name == playerName) then
playerIndex = i
break
end
end
end
local playerIndex = UnitInRaid("player")
if (not playerIndex) then --no player index
if (isDebugging) then
print("PackDamage(): RETURN | no player index found.")
print("PackDamage(): return | no player index found.")
end
return
end
@@ -458,9 +444,10 @@ function Details.packFunctions.PackDamage(combatObject)
--check if is an enemy or neutral
if (actor:IsNeutralOrEnemy()) then
--get the spawnId
local spawnId = select(7, strsplit( "-", actor.serial))
local spawnId = select(7, strsplit("-", actor.serial))
if (spawnId) then
spawnId = tonumber(spawnId)
--convert hex to number
spawnId = tonumber(spawnId:sub(1, 10), 16)
if (spawnId) then
--first index is the actorObject, the second index is the spawnId to sort enemies
tinsert(allEnemies, {actor, spawnId})
@@ -468,12 +455,28 @@ function Details.packFunctions.PackDamage(combatObject)
end
end
end
--sort enemies by their spawnId
table.sort(allEnemies, Details.Sort2)
local allPlayerNames = {}
for i = 1, 20 do
local unitName = UnitName("raid" .. i)
if (unitName and not UnitIsGroupLeader("raid" .. i)) then
allPlayerNames[#allPlayerNames+1] = unitName
end
end
table.sort(allPlayerNames, DetailsFramework.SortOrder1R)
local playerName = UnitName("player")
for i = 1, #allPlayerNames do
if (playerName == allPlayerNames[i]) then
playerIndex = i
break
end
end
--this is the enemy that this player has to send
local enemyObjectToSend = allEnemies[playerIndex]
local enemyObjectToSend = allEnemies[playerIndex] and allEnemies[playerIndex][1]
if (enemyObjectToSend) then
tinsert(actorsToPack, enemyObjectToSend)
end
@@ -488,8 +491,6 @@ function Details.packFunctions.PackDamage(combatObject)
end
end
local spellSize = 0
for i = 1, #actorsToPack do
--get the actor object
local actor = actorsToPack[i]
@@ -523,24 +524,18 @@ function Details.packFunctions.PackDamage(combatObject)
actorDamageInfo [#actorDamageInfo + 1] = floor(spellId)
actorDamageInfo [#actorDamageInfo + 1] = floor(spellDamage)
actorDamageInfo [#actorDamageInfo + 1] = floor(spellHits)
totalSpellIndexes = totalSpellIndexes + 3
--build targets
local targetsSize = Details.packFunctions.CountTableEntriesValid(spellTargets) * 2
actorDamageInfo [#actorDamageInfo + 1] = targetsSize
totalSpellIndexes = totalSpellIndexes + 1
for actorName, damageDone in pairs(spellTargets) do
local actorInfoIndex = actorInformationIndexes[actorName]
if (actorInfoIndex) then
actorDamageInfo [#actorDamageInfo + 1] = actorInfoIndex
actorDamageInfo [#actorDamageInfo + 1] = floor(damageDone)
spellSize = spellSize + 2
end
actorDamageInfo [#actorDamageInfo + 1] = actorName
actorDamageInfo [#actorDamageInfo + 1] = floor(damageDone)
totalSpellIndexes = totalSpellIndexes + 2
end
--+3: spellId, damage, spellHits
--+1: the index that tell the size of targets
totalSpellIndexes = totalSpellIndexes + 3 + targetsSize + 1
spellSize = spellSize + 1 --debug
end
--amount of indexes spells are using
@@ -548,7 +543,7 @@ function Details.packFunctions.PackDamage(combatObject)
end
if (isDebugging) then
print("PackDamage(): DONE.")
print("PackDamage(): done.")
end
end
@@ -560,7 +555,7 @@ end
--@tablePosition: first index of the first damage actor
function Details.packFunctions.UnPackDamage(currentCombat, combatData, tablePosition)
if (isDebugging) then
print("UnPackDamage(): START.")
print("UnPackDamage(): start.")
end
--get the damage container
@@ -576,14 +571,14 @@ function Details.packFunctions.UnPackDamage(currentCombat, combatData, tablePosi
local actorName, actorFlag, serialNumber, class, spec = Details.packFunctions.RetriveActorInformation(combatData, actorReference)
if (isDebugging) then
print("UnPackDamage(): Retrivied Data From " .. actorReference .. ":", actorName, actorFlag, serialNumber, class, spec)
print("UnPackDamage(): Retrivied Data From " .. (actorReference or "nil") .. ":", actorName, actorFlag, serialNumber, class, spec)
end
--check if all damage actors has been processed
--if there's no actor name it means it reached the end
if (not actorName) then
if (isDebugging) then
print("UnPackDamage(): BREAK damage END index:", i, actorReference, "tablePosition:", tablePosition, "value:", combatData[tablePosition])
print("UnPackDamage(): break damage, end index:", i, (actorReference or "nil"), "tablePosition:", tablePosition, "value:", combatData[tablePosition])
end
break
end
@@ -595,6 +590,7 @@ function Details.packFunctions.UnPackDamage(currentCombat, combatData, tablePosi
actorObject.classe = class
actorObject.spec = spec
actorObject.grupo = isActorInGroup(class, actorFlag)
actorObject.flag_original = actorFlag
--> copy back the base damage
actorObject.total = tonumber(combatData[tablePosition+1]) --[2]
@@ -608,7 +604,12 @@ function Details.packFunctions.UnPackDamage(currentCombat, combatData, tablePosi
--> copy back the actor spells
--amount of indexes used to store spells for this actor
local spellsSize = tonumber(combatData [tablePosition]) --[7]
if (isDebugging) then
print("spell size unpack:", spellsSize)
end
tablePosition = tablePosition + 1
local newTargetsTable = {}
local spellIndex = tablePosition
while(spellIndex < tablePosition + spellsSize) do
@@ -616,21 +617,28 @@ function Details.packFunctions.UnPackDamage(currentCombat, combatData, tablePosi
local spellDamage = tonumber(combatData [spellIndex+1]) --[2]
local spellHits = tonumber(combatData [spellIndex+2]) --[3]
local targetsSize = combatData [spellIndex+3] --[4]
local targetsSize = tonumber(combatData[spellIndex+3]) --[4]
local targetTable = Details.packFunctions.UnpackTable(combatData, spellIndex+3, true)
local spellObject = actorObject.spells:GetOrCreateSpell(spellId, true) --this one need some translation
spellObject.total = spellDamage
spellObject.counter = spellHits
spellObject.targets = targetTable
for targetName, amount in pairs (spellObject.targets) do
newTargetsTable[targetName] = (newTargetsTable[targetName] or 0) + amount
end
spellIndex = spellIndex + targetsSize + 4
end
--each iteration need to build a new target table
actorObject.targets = newTargetsTable
tablePosition = tablePosition + spellsSize --increase table position
end
if (isDebugging) then
print("UnPackDamage(): DONE.")
print("UnPackDamage(): done.")
end
return tablePosition
@@ -638,7 +646,7 @@ end
function Details.packFunctions.PackHeal(combatObject)
if (isDebugging) then
print("PackHeal(): START.")
print("PackHeal(): start.")
end
--store actorObjects to pack
@@ -649,7 +657,7 @@ function Details.packFunctions.PackHeal(combatObject)
local playerObject = combatObject:GetActor(DETAILS_ATTRIBUTE_HEAL, playerName)
if (not playerObject) then
if (isDebugging) then
print("PackHeal(): RETURN | no player object.")
print("PackHeal(): return | no player object.")
end
return
end
@@ -679,7 +687,7 @@ function Details.packFunctions.PackHeal(combatObject)
if (not playerIndex) then
if (isDebugging) then
print("PackHeal(): RETURN | no player index found.")
print("PackHeal(): return | no player index found.")
end
return
end
@@ -784,7 +792,7 @@ function Details.packFunctions.PackHeal(combatObject)
end
if (isDebugging) then
print("PackHeal(): DONE.")
print("PackHeal(): done.")
end
end
@@ -794,7 +802,7 @@ end
function Details.packFunctions.UnPackHeal(currentCombat, combatData, tablePosition)
if (isDebugging) then
print("UnPackHeal(): START.")
print("UnPackHeal(): start.")
end
--get the healing container
@@ -806,13 +814,13 @@ function Details.packFunctions.UnPackHeal(currentCombat, combatData, tablePositi
local actorName, actorFlag, serialNumber, class, spec = Details.packFunctions.RetriveActorInformation(combatData, actorReference)
if (isDebugging) then
print("UnPackHeal(): Retrivied Data From " .. actorReference .. ":", actorName, actorFlag, serialNumber, class, spec)
print("UnPackHeal(): Retrivied Data From " .. (actorReference or "nil") .. ":", actorName, actorFlag, serialNumber, class, spec)
end
--if there's no actor name it means it reached the end
if (not actorName) then
if (isDebugging) then
print("UnPackHeal(): BREAK | Heal loop has been stopped", "index:", i, "tablePosition:", tablePosition, "value:", combatData[tablePosition])
print("UnPackHeal(): break | Heal loop has been stopped", "index:", i, "tablePosition:", tablePosition, "value:", combatData[tablePosition])
end
break
end
@@ -858,7 +866,7 @@ function Details.packFunctions.UnPackHeal(currentCombat, combatData, tablePositi
end
if (isDebugging) then
print("UnPackHeal(): DONE.")
print("UnPackHeal(): done.")
end
return tablePosition
@@ -866,15 +874,18 @@ end
--this function does the same as the function above but does not create a new combat, it just add new information
function Details.packFunctions.DeployPackedCombatData(packedCombatData)
if (isDebugging) then
print("DeployPackedCombatData(): START.")
print("DeployPackedCombatData(): start.")
end
local LibDeflate = _G.LibStub:GetLibrary("LibDeflate")
local dataCompressed = LibDeflate:DecodeForWoWAddonChannel(packedCombatData)
local combatDataString = LibDeflate:DecompressDeflate(dataCompressed)
if (isDebugging) then
print(combatDataString)
end
local function count(text, pattern)
return select(2, text:gsub(pattern, ""))
end
@@ -955,6 +966,38 @@ function Details.packFunctions.DeployPackedCombatData(packedCombatData)
currentCombat:SetDate(combatData[INDEX_COMBAT_START_DATE], combatData[INDEX_COMBAT_END_DATE])
currentCombat.enemy = combatData[INDEX_COMBAT_NAME]
end
--refresh container
currentCombat[DETAILS_ATTRIBUTE_DAMAGE]:Remap()
currentCombat[DETAILS_ATTRIBUTE_HEAL]:Remap()
--refresh damage taken
local damageContainer = currentCombat[DETAILS_ATTRIBUTE_DAMAGE]
local allActors = damageContainer._ActorTable
for i = 1, #allActors do --reset damage taken table
local actor = allActors[i]
actor.damage_taken = 0
actor.damage_from = {}
end
for i = 1, #allActors do
local actor = allActors[i]
for targetName, amount in pairs (actor.targets) do
local actorIndex = damageContainer._NameIndexTable[targetName]
if (actorIndex) then
local targetActor = allActors[actorIndex]
if (targetActor) then
targetActor.damage_taken = targetActor.damage_taken + amount
targetActor.damage_from[actor.nome] = (targetActor.damage_from[actor.nome] or 0) + amount
end
end
end
end
--refresh windows
currentCombat[DETAILS_ATTRIBUTE_DAMAGE].need_refresh = true
currentCombat[DETAILS_ATTRIBUTE_HEAL].need_refresh = true
end
--get the amount of entries of a hash table
@@ -970,9 +1013,9 @@ end
function Details.packFunctions.CountTableEntriesValid(hasTable)
local amount = 0
for actorName, _ in pairs(hasTable) do
if (actorInformationIndexes[actorName]) then
--if (actorInformationIndexes[actorName]) then
amount = amount + 1
end
--end
end
return amount
end
@@ -988,18 +1031,18 @@ end
function Details.packFunctions.UnpackTable(table, index, isPair, valueAsTable, amountOfValues)
local result = {}
local reservedIndexes = table[index]
local reservedIndexes = tonumber(table[index])
local indexStart = index+1
local indexEnd = reservedIndexes+index
if (isPair) then
amountOfValues = amountOfValues or 2
for i = indexStart, indexEnd, amountOfValues do
for i = indexStart, indexStart + reservedIndexes - 1, amountOfValues do
if (valueAsTable) then
local key = tonumber(table[i])
result[key] = {selectIndexes(table, i+1, amountOfValues-1)}
else
local key = tonumber(table[i])
local key = table[i]
local value = tonumber(table[i+1])
result[key] = value
end
@@ -1012,119 +1055,4 @@ function Details.packFunctions.UnpackTable(table, index, isPair, valueAsTable, a
end
return result
end
--DEPRECATED
--what this function receives:
--@packedCombatData: packed combat, ready to be unpacked
function Details.packFunctions.UnPackCombatData(packedCombatData)
if (true) then
print("Details is calling the wrong function UnPackCombatData()")
return
end
local LibDeflate = _G.LibStub:GetLibrary("LibDeflate")
local dataCompressed = LibDeflate:DecodeForWoWAddonChannel(packedCombatData)
local combatDataString = LibDeflate:DecompressDeflate(dataCompressed)
--[=
local function count(text, pattern)
return select(2, text:gsub(pattern, ""))
end
--]=]
local combatData = {}
local amountOfIndexes = count(combatDataString, ",") + 1
print ("amountOfIndexes (debug):", amountOfIndexes)
while (amountOfIndexes > 0) do
local splitPart = {strsplit(",", combatDataString, 4000)} --strsplit(): Stack overflow, max allowed: 4000
if (#splitPart == 4000 and amountOfIndexes > 4000) then
print ("#combatDataString (debug) must be > 4000:", amountOfIndexes)
for i = 1, 3999 do
combatData[#combatData+1] = splitPart[i]
end
--get get part that couldn't be read this loop
combatDataString = splitPart[4000]
amountOfIndexes = amountOfIndexes - 3999
print ("#combatDataString (debug) left over:", amountOfIndexes)
else
for i = 1, #splitPart do
combatData[#combatData+1] = splitPart[i]
end
amountOfIndexes = amountOfIndexes - #splitPart
end
end
print("total indexes (debug):", #combatData)
--if true then return end
local flags = tonumber(combatData[INDEX_EXPORT_FLAG])
local tablePosition = TOTAL_INDEXES_FOR_COMBAT_INFORMATION + 1 --[[ +1 to jump to damage ]] --DEPRECATED FUNC
--tablePosition now have the first index of the actorInfoTable
--stop the combat if already in one
if (Details.in_combat) then
Details:EndCombat()
end
--start a new combat
Details:StartCombat()
--get the current combat
local currentCombat = Details:GetCurrentCombat()
--check if this export has include damage info
if (bit.band(flags, 0x1) ~= 0) then
--find the index where the damage information start
for i = tablePosition, #combatData do
if (combatData[i] == "!D") then
tablePosition = i + 1;
break
end
end
--unpack damage
tablePosition = Details.packFunctions.UnPackDamage(currentCombat, combatData, tablePosition)
end
if (bit.band(flags, 0x2) ~= 0) then
--find the index where the heal information start
for i = tablePosition, #combatData do
if (combatData[i] == "!H") then
tablePosition = i + 1;
break
end
end
--unpack heal
Details.packFunctions.UnPackHeal(currentCombat, combatData, tablePosition)
end
--all done, end combat
Details:EndCombat()
--set the start and end of combat time and date
currentCombat:SetStartTime(combatData[INDEX_COMBAT_START_TIME])
currentCombat:SetEndTime(combatData[INDEX_COMBAT_END_TIME])
currentCombat:SetDate(combatData[INDEX_COMBAT_START_DATE], combatData[INDEX_COMBAT_END_DATE])
currentCombat.enemy = combatData[INDEX_COMBAT_NAME]
--debug: delete the segment just created (debug)
--[[
local combat2 = _detalhes.tabela_historico.tabelas[2]
if (combat2) then
tremove (_detalhes.tabela_historico.tabelas, 1)
_detalhes.tabela_historico.tabelas[1] = combat2
_detalhes.tabela_vigente = combat2
end
--]]
end
+1 -2
View File
@@ -1108,12 +1108,11 @@ local default_profile = {
_detalhes.default_profile = default_profile
-- aqui fica as propriedades do jogador que no sero armazenadas no profile
local default_player_data = {
coach = {
enabled = false,
welcome_panel_pos = {}
},
--> force all fonts to have this outline
+2 -98
View File
@@ -990,95 +990,6 @@ function SlashCmdList.DETAILS (msg, editbox)
print (Loc ["STRING_DETAILS1"] .. "diagnostic for character " .. rest .. " turned on.")
return
end
local current_combat = _detalhes.tabela_vigente
if (not _detalhes.DebugWindow) then
_detalhes.DebugWindow = _detalhes.gump:CreateSimplePanel (UIParent, 800, 600, "Details! Debug", "DetailsDebugPanel")
local TextBox = _detalhes.gump:NewSpecialLuaEditorEntry (_detalhes.DebugWindow, 760, 560, "text", "$parentTextEntry", true)
TextBox:SetPoint ("center", _detalhes.DebugWindow, "center", 0, -10)
TextBox:SetBackdrop ({edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true})
TextBox:SetBackdropColor (0, 0, 0, 0.9)
TextBox:SetBackdropBorderColor (0, 0, 0, 1)
_detalhes.DebugWindow.TextBox = TextBox
end
local text = [[
Hello World!
Details! Damage Meter Debug
Release Version: @VERSION Core Version: @CORE
Update Thread Status:
Tick Rate: @TICKRATE
Threat Health: @TICKHEALTH
Last Tick: @TICKLAST
Next Tick In: @TICKNEXT
Current Combat Status:
ID: @COMBATID
Container Status: @COMBATCONTAINERS
Damage Container Actors: @COMBATDAMAGEACTORS actors found
Parser Status:
Parser Health: @PARSERHEALTH
Parser Capture Status: @PARSERCAPTURE
Lower Instance Status (window 1):
Is Shown: @INSTANCESHOWN
Segment Status: @INSTANCESEGMENT
Damage Update Status: @INSTANCEDAMAGESTATUS
]]
text = text:gsub ([[@VERSION]], _detalhes.userversion)
text = text:gsub ([[@CORE]], _detalhes.realversion)
text = text:gsub ([[@TICKRATE]], _detalhes.update_speed)
text = text:gsub ([[@TICKHEALTH]], _detalhes:TimeLeft (_detalhes.atualizador) ~= 0 and "|cFF22FF22good|r" or "|cFFFF2222bad|r")
text = text:gsub ([[@TICKLAST]], _detalhes.LastUpdateTick .. " (" .. _detalhes._tempo - _detalhes.LastUpdateTick .. " seconds ago)")
text = text:gsub ([[@TICKNEXT]], _detalhes:TimeLeft (_detalhes.atualizador))
text = text:gsub ([[@COMBATID]], _detalhes.combat_id)
text = text:gsub ([[@COMBATCONTAINERS]], _detalhes.tabela_vigente[1] and _detalhes.tabela_vigente[2] and _detalhes.tabela_vigente[3] and _detalhes.tabela_vigente[4] and "|cFF22FF22good|r" or "|cFFFF2222bad|r")
text = text:gsub ([[@COMBATDAMAGEACTORS]], #_detalhes.tabela_vigente[1] and _detalhes.tabela_vigente[1]._ActorTable and #_detalhes.tabela_vigente[1]._ActorTable)
text = text:gsub ([[@PARSERHEALTH]], _detalhes.parser_frame:GetScript ("OnEvent") == _detalhes.OnParserEvent and "|cFF22FF22good|r" or "|cFFFF2222bad|r")
local captureStr = ""
for _ , captureName in ipairs (_detalhes.capture_types) do
if (_detalhes.capture_current [captureName]) then
captureStr = captureStr .. " " .. captureName .. ": |cFF22FF22okay|r"
else
captureStr = captureStr .. " " .. captureName .. ": |cFFFF2222X|r"
end
end
text = text:gsub ([[@PARSERCAPTURE]], captureStr)
local instance = _detalhes:GetLowerInstanceNumber()
if (instance) then
instance = _detalhes:GetInstance (instance)
end
if (instance) then
if (instance:IsEnabled()) then
text = text:gsub ([[@INSTANCESHOWN]], "|cFF22FF22good|r")
else
text = text:gsub ([[@INSTANCESHOWN]], "|cFFFFFF22not visible|r")
end
text = text:gsub ([[@INSTANCESEGMENT]], (instance.showing == _detalhes.tabela_vigente and "|cFF22FF22good|r" or "|cFFFFFF22isn't the current combat object|r") .. (" window segment: " .. instance:GetSegment()))
text = text:gsub ([[@INSTANCEDAMAGESTATUS]], (_detalhes._tempo - (_detalhes.LastFullDamageUpdate or 0)) < 3 and "|cFF22FF22good|r" or "|cFFFF2222last update registered is > than 3 seconds, is there actors to show?|r")
else
text = text:gsub ([[@INSTANCESHOWN]], "|cFFFFFF22not found|r")
text = text:gsub ([[@INSTANCESEGMENT]], "|cFFFFFF22not found|r")
text = text:gsub ([[@INSTANCEDAMAGESTATUS]], "|cFFFFFF22not found|r")
end
_detalhes.DebugWindow.TextBox:SetText (text)
_detalhes.DebugWindow:Show()
end
--> debug combat log
@@ -1591,15 +1502,8 @@ Damage Update Status: @INSTANCEDAMAGESTATUS
return
end
Details.coach.enabled = not Details.coach.enabled
if (Details.coach.enabled) then
Details:Msg("Details! Coach enabled, good luck commander!")
Details:Msg("[|cFFAAFFAADetails! Coach|r] raid leader stay outside the raid.")
Details:Msg("[|cFFAAFFAADetails! Coach|r] assistants, at least one player inside the raid need to have assistant.")
Details:Msg("[|cFFAAFFAADetails! Coach|r] players have an updated version of Details!.")
Details.Coach.Server.EnableCoach()
if (not Details.coach.enabled) then
Details.Coach.WelcomePanel()
else
Details:Msg("coach disabled.")
Details.Coach.Disable()