Skip to content

Commit

Permalink
Finished the first 'Alpha Version' of the Coach feature
Browse files Browse the repository at this point in the history
  • Loading branch information
Tercioo committed Dec 19, 2020
1 parent 4d1747f commit ec5fad4
Show file tree
Hide file tree
Showing 9 changed files with 318 additions and 308 deletions.
15 changes: 11 additions & 4 deletions boot.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.",
Expand Down
22 changes: 4 additions & 18 deletions core/network.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
23 changes: 22 additions & 1 deletion core/parser.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -718,13 +721,22 @@
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)
--when disabled it'll show the total damage done for the latest hit
--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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion frames/window_cdtracker.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 0 additions & 6 deletions frames/window_main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
170 changes: 168 additions & 2 deletions functions/coach.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Loading

0 comments on commit ec5fad4

Please sign in to comment.