local mod	= DBM:NewMod("Rage", "DBM-Hyjal")
local L		= mod:GetLocalizedStrings()

mod:SetRevision(("$Revision: 265 $"):sub(12, -3))
mod:SetCreatureID(17767)
mod:SetZone()
mod:SetUsedIcons(8)

mod:RegisterCombat("combat")

mod:RegisterEvents(
	"SPELL_AURA_APPLIED",
	"SPELL_AURA_REMOVED",
	"SPELL_CAST_START"
)

local warnIceBolt		= mod:NewSpellAnnounce(31249, 3)
local warnDnd			= mod:NewSpellAnnounce(31258, 3)

local timerDnd			= mod:NewCastTimer(15, 31258)
local timerDndCD		= mod:NewCDTimer(46, 31258)

local specWarnIceBolt	= mod:NewSpecialWarningYou(31249)
local specWarnDnd		= mod:NewSpecialWarningMove(31258)

local berserkTimer		= mod:NewBerserkTimer(600)

mod:AddBoolOption("IceBoltIcon", true)

local decaySpam = 0

function mod:OnCombatStart(delay)
	decaySpam = 0
	berserkTimer:Start(-delay)
end

function mod:SPELL_AURA_APPLIED(args)
	if args:IsSpellID(31249) then
		warnIceBolt:Show(args.destName)
		if args:IsPlayer() then
			specWarnIceBolt:Show()
		end
		if self.Options.IceBoltIcon then
			self:SetIcon(args.destName, 8)
		end
	elseif args:IsSpellID(31258) and args:IsPlayer() and GetTime() - decaySpam >= 3 then
		specWarnDnD:Show()
		decaySpam = GetTime()
	end
end

function mod:SPELL_AURA_REMOVED(args)
	if args:IsSpellID(31249) then
		if self.Options.IceBoltIcon then
			self:SetIcon(args.destName, 0)
		end
	end
end

function mod:SPELL_CAST_START(args)
	if args:IsSpellID(31258) then
		warnDnd:Show()
		timerDnd:Start()
		timerDndCD:Start()
	end
end
