169 lines
8.7 KiB
Lua
169 lines
8.7 KiB
Lua
-- Ragnaros (Octo BigWigs Raids/MC/Ragnaros.lua), native server events.
|
|
-- boss_ragnaros.cpp: Wrath of Ragnaros 20566 (knockback), Elemental Fire 20564 (from aura 20563),
|
|
-- Submerge 21107 (stealth aura while submerged), Emerge visual 20568. Son of Flame 12143.
|
|
-- The tank is read from Ragnaros's own target instead of melee-log parsing; Octo's weapon-durability counter needs
|
|
-- the item name from the client's damage text, which has no server event, so it is not ported.
|
|
local RAGNAROS, SON = 11502, 12143
|
|
local L = {
|
|
msg_submergeHpSoon = "Submerge soon (50% HP) - Prepare for Sons of Flame!",
|
|
bar_domoStart = "Ragnaros Engage", msg_domoStart = "Ragnaros RP has started - Tanks, equip your Fire Resist!",
|
|
bar_nextEmerge = "Emerge", msg_submerge = "Ragnaros Submerged - Incoming Sons of Flame!",
|
|
msg_emergeSoon = "Emerge in 10 seconds!", msg_emerge = "Ragnaros Emerged!",
|
|
bar_knockbackCd = "Knockback CD", bar_knockbackSoon = "Knockback Soon...",
|
|
msg_knockbackSoon = "Knockback Soon - Melee Out!", msg_knockback = "Knockback - Melee In!",
|
|
msg_addDead = "/8 Son of Flame Dead", bar_elementalFire = "%s - Elemental Fire",
|
|
msg_newTank = "%s is tanking", msg_youTank = "YOU are tanking",
|
|
msg_tankWrathHit = "Knockback on Tank! %s is flying.", msg_tankWrathResist = "Resisted Knockback. %s still tanking.",
|
|
trigger_engage = "NOW FOR YOU, INSECTS! BOLDLY, YOU SOUGHT THE POWER OF RAGNAROS.",
|
|
trigger_submerge = "COME FORTH, MY SERVANTS! DEFEND YOUR MASTER!",
|
|
trigger_submerge2 = "YOU CANNOT DEFEAT THE LIVING FLAME!",
|
|
}
|
|
-- Majordomo's summoning speech, seconds from each line to the real engage (Octo's calibration).
|
|
local domo = {
|
|
{"Imprudent whelps! You've rushed headlong to your own deaths!", 74.137},
|
|
{"Behold Ragnaros, the Firelord!", 58.792},
|
|
{"TOO SOON! YOU HAVE AWAKENED ME TOO SOON, EXECUTUS!", 45.457},
|
|
{"These mortal infidels, my lord!", 32.144},
|
|
{"FOOL! YOU ALLOWED THESE INSECTS TO RUN RAMPANT", 23.9},
|
|
}
|
|
local timer = {nextEmerge = 90, firstKnockbackCd = 31, firstKnockbackSoon = 7, knockbackCd = 22, knockbackSoon = 5, elementalFire = 8}
|
|
local icon = {domoStart = "inv_misc_pocketwatch_01", emerge = "ability_stealth", knockback = "ability_smash", elementalFire = "spell_fire_flametongue"}
|
|
local color = {domoStart = "White", emerge = "White", knockbackCd = "Black", knockbackSoon = "Cyan", elementalFire = "Red"}
|
|
|
|
local m = OctoBossMods:NewModule("Ragnaros", {npcs = {RAGNAROS, SON}, killNpcs = {RAGNAROS}, displayName = "Ragnaros",
|
|
zone = "Molten Core", engageYells = {L.trigger_engage}})
|
|
|
|
local function caster() local _, c = UnitClass("player") return c == "MAGE" or c == "PRIEST" or c == "WARLOCK" end
|
|
local function cancelKnock(self)
|
|
self:RemoveBar(L.bar_knockbackCd)
|
|
self:CancelDelayedBar(L.bar_knockbackSoon)
|
|
self:RemoveBar(L.bar_knockbackSoon)
|
|
self:CancelDelayedMessage(L.msg_knockbackSoon)
|
|
self:CancelScheduledEvent("knockSign")
|
|
self:RemoveWarningSign(icon.knockback)
|
|
end
|
|
-- Knockback in `seconds`: a CD bar, then a "soon" bar for the last 5 s with a melee-out warning 3 s before it.
|
|
local function knockIn(self, seconds)
|
|
cancelKnock(self)
|
|
local cd = seconds - timer.knockbackSoon
|
|
local function warn()
|
|
if caster() then return end
|
|
self:Message(L.msg_knockbackSoon, "Urgent", false, "RunAway")
|
|
self:WarningSign(icon.knockback, 10)
|
|
end
|
|
if cd > 3 then
|
|
self:Bar(L.bar_knockbackCd, cd, icon.knockback, true, color.knockbackCd)
|
|
self:DelayedBar(cd, L.bar_knockbackSoon, timer.knockbackSoon, icon.knockback, true, color.knockbackSoon)
|
|
self:ScheduleEvent("knockSign", warn, cd - 3)
|
|
else
|
|
self:Bar(L.bar_knockbackSoon, seconds, icon.knockback, true, color.knockbackSoon)
|
|
warn()
|
|
end
|
|
end
|
|
|
|
-- Pre-pull: Majordomo's speech runs while no encounter is active.
|
|
local function domoLine(mod, text)
|
|
for _, line in ipairs(domo) do
|
|
if strfind(text, line[1], 1, true) then
|
|
OctoBossMods.Bars:Start(L.bar_domoStart, line[2], icon.domoStart, color.domoStart)
|
|
if line == domo[1] then OctoBossMods:ShowMessage(L.msg_domoStart, "Attention") end
|
|
end
|
|
end
|
|
end
|
|
m.idleYells = {}
|
|
for _, line in ipairs(domo) do m.idleYells[#m.idleYells + 1] = {line[1], domoLine} end
|
|
|
|
function m:OnEngage()
|
|
self.phase, self.sons, self.lastKnock, self.submergeTime, self.tank, self.submergeWarned = "emerged", 0, GetTime(), nil, nil, nil
|
|
self:RemoveBar(L.bar_domoStart)
|
|
knockIn(self, timer.firstKnockbackCd + timer.firstKnockbackSoon)
|
|
self:ScheduleRepeatingEvent("watch", function() self:Watch() end, 0.5)
|
|
end
|
|
function m:Watch()
|
|
for _, unit in ipairs({"target", "focus", "mouseover", "targettarget"}) do
|
|
if OctoBossMods.NpcId(UnitGUID(unit)) == RAGNAROS then
|
|
if self.phase == "emerged" then
|
|
local ok, pct = pcall(function() return UnitHealth(unit) * 100 / UnitHealthMax(unit) end)
|
|
if ok and pct > 50 and pct <= 55 and not self.submergeWarned then
|
|
self.submergeWarned = true
|
|
self:Message(L.msg_submergeHpSoon, "Urgent", false, "Alarm")
|
|
elseif ok and pct > 55 then
|
|
self.submergeWarned = nil
|
|
end
|
|
local tank = UnitName(unit .. "target")
|
|
if tank and not OctoBossMods.IsSecret(tank) and tank ~= self.tank and UnitIsPlayer(unit .. "target") then self:NewTank(tank) end
|
|
end
|
|
return
|
|
end
|
|
end
|
|
end
|
|
function m:NewTank(name)
|
|
if self.tank then self:RestorePreviousRaidTargetForPlayer(self.tank) end
|
|
self.tank = name
|
|
if name == UnitName("player") then
|
|
local _, fr = UnitResistance("player", 2)
|
|
if (fr or 0) < 200 then self:Message(L.msg_youTank, "Important", true, "Beware")
|
|
else self:Message(L.msg_youTank, "Positive", true, "Long") end
|
|
else
|
|
self:Message(format(L.msg_newTank, name), "Attention", true, "Alarm")
|
|
end
|
|
self:SetRaidTargetForPlayer(name, 8)
|
|
end
|
|
function m:Knockback(_, _, _, dstName)
|
|
if not self:Throttle("knock", 5) then return end
|
|
self.lastKnock = GetTime()
|
|
self:Message(L.msg_knockback, "Important")
|
|
knockIn(self, timer.knockbackCd + timer.knockbackSoon)
|
|
end
|
|
function m:WrathHit(_, _, _, dstName)
|
|
if dstName and dstName == self.tank and self:Throttle("tankhit", 5) then
|
|
self:Message(format(L.msg_tankWrathHit, dstName), "Urgent", true, "Beware")
|
|
end
|
|
end
|
|
function m:WrathMiss(_, _, _, dstName)
|
|
if dstName and dstName == self.tank and self:Throttle("tankresist", 5) then
|
|
self:Message(format(L.msg_tankWrathResist, dstName), "Positive", true, "Long")
|
|
end
|
|
end
|
|
function m:Submerge()
|
|
if self.phase == "submerged" then return end
|
|
self.phase, self.submergeTime, self.sons = "submerged", GetTime(), 0
|
|
if self.tank then self:RestorePreviousRaidTargetForPlayer(self.tank) end
|
|
self.tank = nil
|
|
cancelKnock(self)
|
|
self:Message(L.msg_submerge, "Attention")
|
|
self:Bar(L.bar_nextEmerge, timer.nextEmerge, icon.emerge, true, color.emerge)
|
|
self:DelayedMessage(timer.nextEmerge - 10, L.msg_emergeSoon, "Attention")
|
|
end
|
|
function m:SubmergeAura(_, _, dstGUID) if OctoBossMods.NpcId(dstGUID) == RAGNAROS then self:Submerge() end end
|
|
function m:Emerge(_, _, dstGUID)
|
|
if dstGUID and OctoBossMods.NpcId(dstGUID) ~= RAGNAROS then return end
|
|
if self.phase ~= "submerged" then return end
|
|
self.phase, self.submergeWarned = "emerged", nil
|
|
self:RemoveBar(L.bar_nextEmerge)
|
|
self:CancelDelayedMessage(L.msg_emergeSoon)
|
|
self:Message(L.msg_emerge, "Attention")
|
|
-- The knockback cycle resumes where it stopped at the submerge.
|
|
local cycle = timer.knockbackCd + timer.knockbackSoon
|
|
local spent = (self.submergeTime and self.lastKnock and self.submergeTime >= self.lastKnock) and (self.submergeTime - self.lastKnock) or 0
|
|
knockIn(self, math.min(cycle, math.max(5, cycle - spent)))
|
|
end
|
|
function m:ElementalFire(_, _, _, dstName)
|
|
if dstName then self:Bar(format(L.bar_elementalFire, dstName), timer.elementalFire, icon.elementalFire, true, color.elementalFire) end
|
|
end
|
|
function m:ElementalFireFade(_, _, _, dstName) if dstName then self:RemoveBar(format(L.bar_elementalFire, dstName)) end end
|
|
function m:OnCombatLog(sub, _, _, dstGUID)
|
|
if sub == "UNIT_DIED" and OctoBossMods.NpcId(dstGUID) == SON then
|
|
self.sons = (self.sons or 0) + 1
|
|
self:Message(self.sons .. L.msg_addDead, "Positive")
|
|
end
|
|
end
|
|
m.yells = {{L.trigger_submerge, "Submerge"}, {L.trigger_submerge2, "Submerge"}}
|
|
m.events = {
|
|
SPELL_CAST_SUCCESS = {[20566] = "Knockback", [20568] = "Emerge"},
|
|
SPELL_DAMAGE = {[20566] = "WrathHit"},
|
|
SPELL_MISSED = {[20566] = "WrathMiss"},
|
|
SPELL_AURA_APPLIED = {[21107] = "SubmergeAura", [20564] = "ElementalFire"},
|
|
SPELL_AURA_REMOVED = {[21107] = "Emerge", [20564] = "ElementalFireFade"},
|
|
}
|