local mod	= DBM:NewMod("Tonks", "DBM-WorldEvents", 3)
local L		= mod:GetLocalizedStrings()

mod:SetRevision("20260523021914")
mod:SetZone(974)

if DBM:IsPostMidnight() then
	mod:RegisterSafeEvents(
		"UNIT_SPELLCAST_SUCCEEDED player",
		"UNIT_EXITED_VEHICLE player"
	)
else
	mod:RegisterEvents(
		"SPELL_CAST_SUCCESS 102341",
		"UNIT_SPELLCAST_SUCCEEDED player",
		"UNIT_DIED",
		"UNIT_EXITED_VEHICLE player"
	)
end
mod.noStatistics = true

local specWarnMarked			= mod:NewSpecialWarningRun(102341, nil, nil, 2, 4, 2, nil, nil, "justrun")

local timerGame					= mod:NewBuffActiveTimer(60, 102178, nil, nil, nil, 5, nil, nil, nil, 1, 5)

function mod:SPELL_CAST_SUCCESS(args)
	if args.spellId == 102341 and UnitGUID("pet") == args.destGUID and self:AntiSpam() then
		specWarnMarked:Show()
		specWarnMarked:Play("justrun")
	end
end

function mod:UNIT_SPELLCAST_SUCCEEDED(_, _, spellId)
	if self:issecretvalue(spellId) then return end
	if spellId == 102178 then
		timerGame:Start()
	end
end

function mod:UNIT_DIED(args)
	local cid = self:GetCIDFromGUID(args.destGUID)
	if cid == 54588 and UnitGUID("pet") == args.destGUID then
		timerGame:Cancel()
	end
end

function mod:UNIT_EXITED_VEHICLE()
	timerGame:Cancel()
end
