local Netherspite = DBM:NewBossMod("Netherspite", DBM_NS_NAME, DBM_NS_DESCRIPTION, DBM_KARAZHAN, DBM_KARAZHAN_TAB, 11);

Netherspite.Version			= "1.0";
Netherspite.Author			= "Tandanu";
Netherspite.Phase			= 1;


Netherspite:RegisterEvents(
	"CHAT_MSG_SPELL_CREATURE_VS_CREATURE_DAMAGE",
	"CHAT_MSG_SPELL_CREATURE_VS_CREATURE_BUFF",
	"CHAT_MSG_RAID_BOSS_EMOTE"
);

Netherspite:RegisterCombat("COMBAT");

Netherspite:AddOption("PhaseWarn", true, DBM_NS_OPTION_1);
Netherspite:AddOption("PhasePreWarn", true, DBM_NS_OPTION_2);
Netherspite:AddOption("VoidWarn", true, DBM_NS_OPTION_3);
Netherspite:AddOption("BreathWarn", true, DBM_NS_OPTION_4);

function Netherspite:OnCombatStart(delay)
	self.Phase = 1;
	self:StartStatusBarTimer(60 - delay, "Portal Phase", "Interface\\Icons\\Spell_Arcane_PortalIronForge");
	self:ScheduleSelf(55 - delay, "PhaseWarning", 2);
end

function Netherspite:OnCombatEnd()
	self.Phase = 1;
end

function Netherspite:OnEvent(event, arg1)
	if event == "CHAT_MSG_SPELL_CREATURE_VS_CREATURE_DAMAGE" or event == "CHAT_MSG_SPELL_CREATURE_VS_CREATURE_BUFF" then
		if arg1 == DBM_NS_CAST_BREATH then
			if self.Options.BreathWarn then
				self:Announce(DBM_NS_WARN_BREATH);
			end
			self:StartStatusBarTimer(2.5, "Netherbreath", "Interface\\Icons\\Spell_Arcane_MassDispel");
			
		elseif arg1 == DBM_NS_CAST_VOID_ZONE then
			if self.Options.VoidWarn then
				self:Announce(DBM_NS_WARN_VOID_ZONE);
			end
		end
	elseif event == "CHAT_MSG_RAID_BOSS_EMOTE" then
		if arg1 == DBM_NS_EMOTE_PHASE_2 then
			self.Phase = 2;
			self:EndStatusBarTimer("Portal Phase");
			self:StartStatusBarTimer(30, "Banish Phase", "Interface\\Icons\\Spell_Shadow_Cripple");
			self:ScheduleSelf(25, "PhaseWarning", 1);
			
			if self.Options.PhaseWarn then
				self:Announce(DBM_NS_WARN_BANISH);
			end
		elseif arg1 == DBM_NS_EMOTE_PHASE_1 then
			self.Phase = 1;
			self:EndStatusBarTimer("Banish Phase");
			self:StartStatusBarTimer(60, "Portal Phase", "Interface\\Icons\\Spell_Arcane_PortalIronForge");
			self:ScheduleSelf(55, "PhaseWarning", 2);
			
			if self.Options.PhaseWarn then
				self:Announce(DBM_NS_WARN_PORTAL);
			end
		end
	elseif event == "PhaseWarning" and arg1 and self.Options.PhasePreWarn then
		if arg1 == 1 then
			self:Announce(DBM_NS_WARN_PORTAL_SOON);
		elseif arg1 == 2 then
			self:Announce(DBM_NS_WARN_BANISH_SOON);
		end
	end
end