Skip to content

Commit

Permalink
Viscidus: Track frost and melee hits per second
Browse files Browse the repository at this point in the history
  • Loading branch information
emmericp committed Jan 23, 2025
1 parent 3706cc6 commit ee3c6af
Show file tree
Hide file tree
Showing 2 changed files with 130 additions and 6 deletions.
131 changes: 128 additions & 3 deletions DBM-Raids-Vanilla/AQ40/Viscidus.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,14 @@ mod:SetZone(531)
mod:RegisterCombat("combat")

mod:RegisterEventsInCombat(
"SPELL_CAST_SUCCESS 25991 25896",
"SPELL_CAST_SUCCESS 25991 25896 25896",
"SPELL_AURA_APPLIED 25989",
"CHAT_MSG_MONSTER_EMOTE"
"CHAT_MSG_MONSTER_EMOTE",
"SPELL_DAMAGE",
"SPELL_PERIODIC_DAMAGE",
"SWING_DAMAGE",
"SWING_MISSED",
"UNIT_SPELLCAST_SUCCEEDED"
)

local warnPoisonBoltVolley = mod:NewCountAnnounce(25991, 3)
Expand All @@ -34,17 +39,85 @@ local specWarnGTFO = mod:NewSpecialWarningGTFO(25989, nil, nil, nil, 1, 8)
local timerPoisonBoltVolleyCD = mod:NewCDCountTimer(11, 25991, nil, nil, nil, 2, nil, DBM_COMMON_L.POISON_ICON)

mod.vb.volleyCount = 0
mod.vb.freezeState = 0

mod:AddInfoFrameOption(nil, true)

-- Failure case for not getting enough melee hits, only 11.7 seconds? Doesn't seem like a lot?
-- This does not seem to be consistent across attempts, so no timer for now
-- "<238.72 21:44:46> [CHAT_MSG_MONSTER_EMOTE] %s is frozen solid!#Viscidus###Viscidus##0#0##0#5362#nil#0#false#false#false#false",
-- "<243.88 21:44:51> [CHAT_MSG_MONSTER_EMOTE] %s begins to crack!#Viscidus###Viscidus##0#0##0#5364#nil#0#false#false#false#false",
-- "<247.55 21:44:55> [CHAT_MSG_MONSTER_EMOTE] %s looks ready to shatter!#Viscidus###Viscidus##0#0##0#5365#nil#0#false#false#false#false",
-- "<250.46 21:44:58> [CLEU] SWING_MISSED#Creature-0-5251-531-20035-15299-000059DDD3#Viscidus#Player-5827-027104E6#Paszeko#DODGE#false#nil#nil#nil#nil#nil#nil",

-- TODO: "Viscidus Frost Weakness" (25926 and 1215736), seems to happen after he respawns (only UCS events), but well after he is targetable.
-- It might be useless or it might be the relevant trigger for counting frost attacks? Let's see how wrong our count is

local meleeHits = 0
local frostHits = 0
local meleeHitTimes = {}
local frostHitTimes = {}
local lastFreeze = 0

local function getHitsPerSecond(times, treshold1, treshold2)
if #times >= treshold1 then
return (treshold1 - 1) / (times[#times] - times[#times - treshold1 + 1])
elseif #times >= treshold2 then
return (treshold2 - 1) / (times[#times] - times[#times - treshold2 + 1])
else
return 0
end
end

local lines, sortedLines = {}, {}
local function updateInfoFrame()
table.wipe(lines)
table.wipe(sortedLines)
if mod.vb.freezeState == 0 then
sortedLines[1] = L.FrostHitsPerSecond
lines[L.FrostHitsPerSecond] = ("%.1f"):format(getHitsPerSecond(frostHitTimes, 7, 15))
elseif mod.vb.freezeState == 1 then
sortedLines[1] = L.MeleeHitsPerSecond
lines[L.MeleeHitsPerSecond] = ("%.1f"):format(getHitsPerSecond(meleeHitTimes, 10, 20))
end
return lines, sortedLines
end


local function resetHitCounts()
meleeHits = 0
frostHits = 0
table.wipe(meleeHitTimes)
table.wipe(frostHitTimes)
end

function mod:OnCombatStart(delay)
self.vb.volleyCount = 0
timerPoisonBoltVolleyCD:Start(-delay, 1)
self.vb.freezeState = 0
resetHitCounts()
if self.Options.InfoFrame then
DBM.InfoFrame:Show(20, "function", updateInfoFrame)
end
end

function mod:OnCombatEnd()
if self.Options.InfoFrame then
DBM.InfoFrame:Hide()
end
resetHitCounts()
end


function mod:SPELL_CAST_SUCCESS(args)
if args:IsSpell(25991) then
self.vb.volleyCount = self.vb.volleyCount + 1
warnPoisonBoltVolley:Show(self.vb.volleyCount)
timerPoisonBoltVolleyCD:Start(11, self.vb.volleyCount+1)
elseif args:IsSpell(25896) and self:AntiSpam(8, "Respawn") then -- All surviging globs cast this, trigger only on the first one to avoid accidental late resets
DBM:Debug("Viscidus respawned, frostHits=" .. tostring(frostHits) .. ", meleeHits=" .. tostring(meleeHits))
resetHitCounts()
self.vb.freezeState = 0
end
end

Expand All @@ -60,7 +133,7 @@ function mod:CHAT_MSG_MONSTER_EMOTE(msg)
self:SendSync("Shatter", 1)
elseif msg == L.Phase5 or msg:find(L.Phase5) then
self:SendSync("Shatter", 2)
elseif msg == L.Phase6 or msg:find(L.Phase6) then--No longer present in classic?
elseif msg == L.Phase6 or msg:find(L.Phase6) then -- Missing in Classic :(
self:SendSync("Shatter", 3)
elseif msg == L.Slow or msg:find(L.Slow) then
self:SendSync("Freeze", 1)
Expand All @@ -71,6 +144,51 @@ function mod:CHAT_MSG_MONSTER_EMOTE(msg)
end
end

function mod:UNIT_SPELLCAST_SUCCEEDED(uId, _, spellId)
if spellId == 25926 or spellId == 1215736 then
self:SendSync("FrostWeakness", spellId)
end
end

function mod:SPELL_DAMAGE(_, _, _, _, destGuid, _, _, _, _, _, _, _, _, school)
school = school or 0
if DBM:GetCIDFromGUID(destGuid) == 15299 and bit.band(school, 0x10) ~= 0 then
frostHits = frostHits + 1
DBM:Debug("frostHits=" .. frostHits)
frostHitTimes[#frostHitTimes + 1] = GetTime()
end
end
mod.SPELL_PERIODIC_DAMAGE = mod.SPELL_DAMAGE

-- Failure case of not shattering him in time
function mod:Unfreeze()
if GetTime() - lastFreeze > 5 then
DBM:Debug("Viscidus unfroze (failed shatter), frostHits=" .. tostring(frostHits) .. ", meleeHits=" .. tostring(meleeHits))
resetHitCounts()
self.vb.freezeState = 0
end
end

function mod:SWING_DAMAGE(srcGuid, _, _, _, destGuid)
if DBM:GetCIDFromGUID(destGuid) == 15299 then
meleeHits = meleeHits + 1
DBM:Debug("meleeHits=" .. meleeHits)
meleeHitTimes[#meleeHitTimes + 1] = GetTime()
elseif DBM:GetCIDFromGUID(srcGuid) == 15299 then
if self.vb.freezeState == 1 then
self:Unfreeze()
end
end
end

function mod:SWING_MISSED(srcGuid)
if DBM:GetCIDFromGUID(srcGuid) == 15299 then
if self.vb.freezeState == 1 then
self:Unfreeze()
end
end
end

function mod:OnSync(msg, count, sender)
if msg == "Shatter" and sender then
count = tonumber(count)
Expand All @@ -80,6 +198,13 @@ function mod:OnSync(msg, count, sender)
warnFreeze:Show(count)
if count == 3 then
timerPoisonBoltVolleyCD:Stop()
DBM:Debug("Viscidus frozen, frostHits=" .. tostring(frostHits) .. ", meleeHits=" .. tostring(meleeHits))
resetHitCounts()
lastFreeze = GetTime()
self.vb.freezeState = 1
end
elseif msg == "FrostWeakness" and self:AntiSpam(3, "FrostWeaknessSync") then
-- Just to gather logs because there are two different Frost Weakness spells he uses, maybe they differ in required hits/time or something
DBM:Debug("USC for viscidus frost weakness " .. tostring(count))
end
end
5 changes: 2 additions & 3 deletions DBM-Raids-Vanilla/localization.en.lua
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,8 @@ L:SetMiscLocalization{
Phase5 = "looks ready to shatter",
Phase6 = "Explodes.",

HitsRemain = "Hits Remaining",
Frost = "Frost",
Physical = "Physical"
FrostHitsPerSecond = "Frost hits per second",
MeleeHitsPerSecond = "Melee hits per second",
}
-------------
-- Huhuran --
Expand Down

0 comments on commit ee3c6af

Please sign in to comment.