mirror of
https://github.com/TheRealFayz/SHalts.git
synced 2026-11-16 09:30:34 +00:00
- Server events on the Raids tab now has a Weekly Dungeon Quests line that counts down to the weekly turnover, Thursday at server midnight. - SHAlts now keeps track of whether each character has handed in Call to Arms: Dungeon Delving this week. A hand-in only counts once the quest has left the quest log, so a failed hand-in or an abandoned quest is not counted. /shalts quest shows the current state. - A red message across the center of the screen tells you when you log in that the weekly dungeon quest can be picked up. It stays quiet if the quest is done this week, already in your quest log, or the character is under level 60. - A second red message tells you when you have profession cooldowns ready on any of your characters. Finished custom timers and cooldowns you switched off are not counted. - Both messages wait out combat and do not repeat within 10 minutes for the same character.
162 lines
6.0 KiB
Lua
162 lines
6.0 KiB
Lua
-------------------------------------------------------------------------------
|
|
-- Server raid reset schedule: when each raid resets for everyone, so you know
|
|
-- when you can run it again. This is separate from your own saves and timers.
|
|
--
|
|
-- Each raid resets every N days from a known starting moment. The schedule and
|
|
-- the way daylight saving is handled keep the times matching the server.
|
|
-------------------------------------------------------------------------------
|
|
local S = SHAlts
|
|
|
|
S.Try("Raids.lua", function()
|
|
|
|
local DAY = 86400
|
|
|
|
-- seconds since 1970 for a calendar date and hour, read as UTC
|
|
local function UTC(y, m, d, h)
|
|
if m <= 2 then y = y - 1 end
|
|
local era = math.floor(y / 400)
|
|
local yoe = y - era * 400
|
|
local mp = math.mod(m + 9, 12)
|
|
local doy = math.floor((153 * mp + 2) / 5) + d - 1
|
|
local doe = yoe * 365 + math.floor(yoe / 4) - math.floor(yoe / 100) + doy
|
|
return (era * 146097 + doe - 719468) * DAY + h * 3600
|
|
end
|
|
S.UTCSeconds = UTC
|
|
|
|
-- how often each reset timer repeats; raids that share a timer reset together
|
|
local GROUPS = { raid40 = 7, ony = 5, kara = 5, zg = 3, tmh = 7, eom = 14 }
|
|
|
|
-- every raid on its own line, with its size range where it is known
|
|
local RAIDS = {
|
|
{ name = "Timbermaw Hold", group = "tmh", size = "12-20" },
|
|
{ name = "Molten Core", group = "raid40", size = "20-40" },
|
|
{ name = "Blackwing Lair", group = "raid40", size = "20-40" },
|
|
{ name = "Emerald Sanctum", group = "raid40", size = "20-40" },
|
|
{ name = "Temple of Ahn'Qiraj", group = "raid40", size = "20-40" },
|
|
{ name = "Naxxramas", group = "raid40", size = "20-40" },
|
|
{ name = "Upper Karazhan Halls", group = "raid40", size = "35-40" },
|
|
{ name = "Onyxia's Lair", group = "ony", size = "20-40" },
|
|
{ name = "Lower Karazhan Halls", group = "kara", size = "10" },
|
|
{ name = "Ruins of Ahn'Qiraj", group = "zg", size = "12-20" },
|
|
{ name = "Zul'Gurub", group = "zg", size = "12-20" },
|
|
{ name = "Edge of Madness", group = "eom" },
|
|
}
|
|
|
|
-- the Edge of Madness bosses, in the order they take turns
|
|
local EOM_BOSSES = { "Gri'lek", "Hazza'rah", "Renataki", "Wushoolay" }
|
|
|
|
-- the first reset of each cycle, per realm group
|
|
local SET_A = {
|
|
raid40 = UTC(2026, 6, 17, 1),
|
|
ony = UTC(2026, 6, 17, 1),
|
|
kara = UTC(2026, 6, 17, 1),
|
|
zg = UTC(2025, 8, 30, 3),
|
|
tmh = UTC(2025, 8, 29, 3),
|
|
eom = UTC(2025, 4, 7, 23),
|
|
}
|
|
local SET_B = {
|
|
raid40 = UTC(2026, 6, 17, 1),
|
|
ony = UTC(2025, 9, 1, 3),
|
|
kara = UTC(2025, 9, 2, 3),
|
|
zg = UTC(2025, 8, 30, 3),
|
|
tmh = UTC(2025, 8, 29, 3),
|
|
eom = UTC(2025, 4, 7, 23),
|
|
}
|
|
local REALMS = {
|
|
["N'Zoth"] = SET_A, ["C'Thun"] = SET_A, ["Y'Shaarj"] = SET_A,
|
|
["Nordanaar"] = SET_B, ["Ambershire"] = SET_B,
|
|
}
|
|
|
|
-- Returns a list of { id, name, sub, days, nextAt, prevAt } (real clock times,
|
|
-- in seconds), and true when this realm's schedule is a guess.
|
|
function S.RaidSchedule(now)
|
|
now = now or time()
|
|
local set = REALMS[GetRealmName() or ""]
|
|
local assumed = false
|
|
if not set then set = SET_A; assumed = true end
|
|
|
|
-- outside daylight saving the clock is an hour behind
|
|
local t = date("*t", now)
|
|
local shift = 0
|
|
if not (t and t.isdst) then shift = 3600 end
|
|
local serverNow = now - shift
|
|
|
|
-- work out each timer once, then give every raid its timer's times
|
|
local times = {}
|
|
for group, days in pairs(GROUPS) do
|
|
local anchor = set[group]
|
|
local interval = days * DAY
|
|
local cycles = math.floor((serverNow - anchor) / interval)
|
|
local prev = anchor + cycles * interval
|
|
times[group] = { days = days, nextAt = prev + interval + shift, prevAt = prev + shift }
|
|
end
|
|
|
|
-- Edge of Madness: the boss in play changes every 14 days, cycling through four
|
|
local sday = math.floor(serverNow / DAY)
|
|
local cycle = math.floor((sday + 2) / 14)
|
|
local boss = EOM_BOSSES[math.mod(cycle, 4) + 1]
|
|
local bossNext = EOM_BOSSES[math.mod(cycle + 1, 4) + 1]
|
|
local bossChangeAt = ((cycle + 1) * 14 - 2) * DAY + shift
|
|
|
|
local out = {}
|
|
for i = 1, table.getn(RAIDS) do
|
|
local r = RAIDS[i]
|
|
local t = times[r.group]
|
|
table.insert(out, {
|
|
name = r.name, size = r.size, group = r.group, days = t.days,
|
|
nextAt = t.nextAt, prevAt = t.prevAt,
|
|
boss = (r.group == "eom") and boss or nil,
|
|
bossNext = (r.group == "eom") and bossNext or nil,
|
|
bossChangeAt = (r.group == "eom") and bossChangeAt or nil,
|
|
})
|
|
end
|
|
return out, assumed
|
|
end
|
|
|
|
-- The weekly quest week runs Thursday to Thursday and turns over at server midnight,
|
|
-- the same moment the Darkmoon Faire changes place. Returns when this week started
|
|
-- and when the next begins (real clock seconds).
|
|
function S.WeeklyQuestWindow(now)
|
|
now = now or time()
|
|
local t = date("*t", now)
|
|
local shift = 0
|
|
if not (t and t.isdst) then shift = 3600 end
|
|
local sday = math.floor((now - shift) / DAY)
|
|
-- day number 0 was a Thursday, so every multiple of 7 starts a new week
|
|
local week = math.floor(sday / 7)
|
|
return week * 7 * DAY + shift, (week + 1) * 7 * DAY + shift
|
|
end
|
|
|
|
-- Battleground of the day and the Darkmoon Faire location. Both follow the server's
|
|
-- calendar day, which starts at midnight server time.
|
|
local BGS = { "Alterac Valley", "Warsong Gulch", "Arathi Basin", "Blood Ring Arena", "Thorn Gorge" }
|
|
local DMF = { "Goldshire", "Thunder Bluff" }
|
|
|
|
-- Returns { bg, bgNext, bgChangeAt, dmf, dmfNext, dmfDayOff, dmfMoveAt, dmfBackAt }
|
|
-- (times are real clock seconds). The Faire moves out every Wednesday and is back
|
|
-- the next day in the other place.
|
|
function S.ServerEvents(now)
|
|
now = now or time()
|
|
local t = date("*t", now)
|
|
local shift = 0
|
|
if not (t and t.isdst) then shift = 3600 end
|
|
local serverNow = now - shift
|
|
local sday = math.floor(serverNow / DAY)
|
|
|
|
local ev = {}
|
|
ev.bg = BGS[math.mod(sday - 3, 5) + 1]
|
|
ev.bgNext = BGS[math.mod(sday - 2, 5) + 1]
|
|
ev.bgChangeAt = (sday + 1) * DAY + shift
|
|
|
|
local idx = math.mod(math.floor(sday / 7), 2) + 1
|
|
ev.dmf = DMF[idx]
|
|
ev.dmfNext = DMF[3 - idx]
|
|
-- day 0 was a Thursday, so a day number that leaves 6 when divided by 7 is a Wednesday
|
|
ev.dmfDayOff = (math.mod(sday, 7) == 6)
|
|
ev.dmfBackAt = (sday + 1) * DAY + shift
|
|
ev.dmfMoveAt = (math.floor(sday / 7) + 1) * 7 * DAY - DAY + shift
|
|
return ev
|
|
end
|
|
|
|
end)
|