SHADERMOD_VERSION = "|cFFFFFFFFv3.01 |cFF00FFFFFR";
---------------------------------------
---Current Combo Colors------
DISPLAY_RED = ".55";	
DISPLAY_GREEN = ".55";
DISPLAY_BLUE = ".5"; 
---------------------------------------
---------------------------------------
---Finished Combo Colors-----
FDISPLAY_RED = ".7";	
FDISPLAY_GREEN = ".1";
FDISPLAY_BLUE = ".1"; 
---------------------------------------
-- Function: 		SMOnLoad()
-- Arguments:		None
-- Returns:  		None
-- Used for: 		General OnLoad function
function SMOnLoad()
	--Register Events
	this:RegisterEvent("VARIABLES_LOADED");
	this:RegisterEvent("CHAT_MSG_COMBAT_SELF_HITS");
	this:RegisterEvent("CHAT_MSG_SPELL_SELF_DAMAGE");
	this:RegisterEvent("CHAT_MSG_COMBAT_SELF_MISSES");
	this:RegisterEvent("PLAYER_ENTERING_WORLD");
	this:RegisterEvent("PLAYER_REGEN_ENABLED");
	this:RegisterEvent("UNIT_COMBO_POINTS");

	--Variables used to parse variables from CHAT_MSG events

	COMBAT_HIT = "Vous touchez (.+) et infligez (%d+)."; 
	COMBAT_CRIT	= "Vous infligez un coup critique \195\160 (.+) %((%d+)."; 
			
	SPELL_HIT = "Votre (.+) touche (.+) et lui inflige (%d+) points (.+)."
	SPELL_HIT2 = "Votre (.+) touche (.+) et inflige (%d+)." 
	SPELL_CRIT = "Votre (.+) inflige un coup critique \195\160 (.+) %((%d+) points de d\195\169g\195\162ts(.+).";

	--Misc Variables used to compare to records
	CritDmg = 0;
	CritCombo = 0;
	CritComboDmg = 0;
	CurrentSpell = 0;
        CritMsg = ".";
		
	DEFAULT_CHAT_FRAME:AddMessage("|cFF00FFFFSky-|cFF0000FFDexter. |cFF00FF00ShaderMod |cFFFFFFFFv3.01 |cFFFF0000.:Loaded:. |cFFFFFFFF: /sm for options", .2, .0);
	
	--Get Player Name and Current Realm so Options can be saved per character
	SMPlayerRealm = GetCVar("realmName");
	SMPlayerName = UnitName("player");	
	
	--MyAddons Support for options frame
	UIPanelWindows["ShaderModOptionsFrame"] = {area = "center", pushable = 0};
end


-- Function: 		SMInitialize()
-- Arguments:		None
-- Returns:  		None
-- Used for: 		Register Slash Commands and calls SMInitializeSMData to initialize SMData incase it isn't already in SavedVariables
function SMInitialize()
	SlashCmdList["CritCombo"] = SMCommand;
	SLASH_CritCombo1 = "/ShaderMod";
	SLASH_CritCombo2 = "/ShaderM";
	SLASH_CritCombo3 = "/sm"
	
	SMInitializeSMData();
end


-- Function: 		SMCommand()
-- Arguments:		msg == whatever is typed after a slash command (Example: show)
-- Returns:  		None
-- Used for: 		Handles all the slash commands
function SMCommand(msg)
	if (string.lower(msg) == "records") then
		DEFAULT_CHAT_FRAME:AddMessage("[ShaderMod] " .. SHADERMOD_VERSION .. " ", .2, .0);
		DEFAULT_CHAT_FRAME:AddMessage("--- Hits Based Record ---", .65, .65, .6);
		DEFAULT_CHAT_FRAME:AddMessage("*" .. SMData[SMPlayerRealm][SMPlayerName].RecordHitsCritCombo .. "* crits for *" .. SMData[SMPlayerRealm][SMPlayerName].RecordHitsCritComboDmg .. "* damage. ");
		DEFAULT_CHAT_FRAME:AddMessage("--- Damage Based Record ---", .65, .65, .6);
		DEFAULT_CHAT_FRAME:AddMessage("*" .. SMData[SMPlayerRealm][SMPlayerName].RecordDmgCritCombo .. "* crits for *" .. SMData[SMPlayerRealm][SMPlayerName].RecordDmgCritComboDmg .. "* damage. ");
		return;
	end
	
	if (string.lower(msg) == "help") then
		SMDisplayHelp();
		return;
	end
	if (string.lower(msg) == "lock") then
		SMMessageFrame.Locked = true;
		SMMessageFrame:EnableMouse(false);
		DEFAULT_CHAT_FRAME:AddMessage("|cFF00FFFFSky-|cFF0000FFDexter. |cFF00FF00ShaderMod |cFFFFFFFFv3.01 : |cFF00FF00Now |cFFFF0000Locked ", .2, .0);
	  return;
	end
	if (string.lower(msg) == "unlock") then
		SMMessageFrame.Locked = false;
		SMMessageFrame:EnableMouse(true);
		DEFAULT_CHAT_FRAME:AddMessage("|cFF00FFFFSky-|cFF0000FFDexter. |cFF00FF00ShaderMod |cFFFFFFFFv3.01 : |cFF00FF00Now |cFFFF0000Unlocked ", .2, .0);
	  return;
	end
	if (string.lower(msg) == "hide") then
		SMMessageFrame.Visible = false;
		SMMessageFrame:Hide();
		DEFAULT_CHAT_FRAME:AddMessage("|cFF00FFFFSky-|cFF0000FFDexter. |cFF00FF00ShaderMod |cFFFFFFFFv3.01 : |cFF00FF00Now |cFFFF0000Hidden ", .2, .0);
	  return;
	end
	if (string.lower(msg) == "show") then
		SMMessageFrame.Visible = true;
		SMMessageFrame:Show();
		DEFAULT_CHAT_FRAME:AddMessage("|cFF00FFFFSky-|cFF0000FFDexter. |cFF00FF00ShaderMod |cFFFFFFFFv3.01 : |cFF00FF00Now |cFFFF0000Visible ", .2, .0);
	  return;
	end
	if (string.lower(msg) == "menu") then
		PlaySound("igMainMenuOpen");
		ShowUIPanel(ShaderModOptionsFrame);
	  return;
	end

	if (string.lower(msg) == "options") then
		PlaySound("igMainMenuOpen");
		ShowUIPanel(ShaderModOptionsFrame);
	  return;
	end

	if (string.lower(msg) == "version") then
		DEFAULT_CHAT_FRAME:AddMessage("|cFF00FFFFSky-|cFF0000FFDexter. |cFF00FF00ShaderMod |cFFFFFFFFCurrent Version: " .. SHADERMOD_VERSION, .2, .0);
	  return;
	end
	
	if (string.lower(msg) == "resetconfig") then
		SMSetDefaultOptions();
		DEFAULT_CHAT_FRAME:AddMessage("|cFF00FFFFSky-|cFF0000FFDexter. |cFF00FF00ShaderMod |cFFFFFFFFConfiguration Reset.", .2, .0);
	  return;
	end
	
	--Handle Everything else
	SMDisplayHelp();
end


-- Function: 		SMOnEvent()
-- Arguments:		event == event action that is triggered
--              arg1 == argument sent by the event if applicable
-- Returns:  		None
-- Used for: 		General Event handler function
function SMOnEvent(event, arg1)
	--Call SMInitialize() after variables have been loaded from SavedVariables
	if (event == "VARIABLES_LOADED") then 
		SMInitialize(); 
		
		-- MyAddon's Support
		if(myAddOnsFrame) then
			myAddOnsList.CritCombo = { name = "ShaderMod",
						description = "Shadermod v3.0.",
						version = SHADERMOD_VERSION,
						category = MYADDONS_CATEGORY_COMBAT,
						optionsframe = "ShaderModOptionsFrame"
					};
		end
	end
	
-- CHECKING FOR HITS / CRITS
	if (event == "CHAT_MSG_SPELL_SELF_DAMAGE") then
		CurrentSpell = 0;
		--HIT--
		for spellname, creaturename, damage in string.gfind(arg1, SPELL_HIT)do
		CurrentSpell = tostring(spellname);
		--DEFAULT_CHAT_FRAME:AddMessage("[ShaderMod] Current String CurrentSpell: ->" .. CurrentSpell .. "<-", .2, .0);
if ((CurrentSpell == "\195\169clat lunaire") or 
(CurrentSpell == "Feu stellaire") or 
(CurrentSpell == "Col\195\168re") or 
(CurrentSpell == "Swipe") or 
(CurrentSpell == "Maul") or 
(CurrentSpell == "Claw") or 
(CurrentSpell == "Shred") or 
(CurrentSpell == "Ravage") or 
(CurrentSpell == "Pounce") or 
(CurrentSpell == "Morsure f\195\169roce") or 
(CurrentSpell == "Raptor Strike") or 
(CurrentSpell == "Tir Automatique") or 
(CurrentSpell == "Tir des arcanes") or 
(CurrentSpell == "Multi-Shot") or 
(CurrentSpell == "Vis\195\169e") or 
(CurrentSpell == "Arcane Missiles") or 
(CurrentSpell == "Trait de feu") or 
(CurrentSpell == "Boulle de feu") or 
(CurrentSpell == "Explosion pyrotechnique") or 
(CurrentSpell == "Br\195\187lure") or 
(CurrentSpell == "\195\169clair de givre") or 
(CurrentSpell == "Blizzard") or 
(CurrentSpell == "Ch\195\162timent") or 
(CurrentSpell == "Attaque mentale") or 
(CurrentSpell == "Flammes sacr\195\169es") or 
(CurrentSpell == "Attaque sournoise") or 
(CurrentSpell == "Attaque pernicieuse") or 
(CurrentSpell == "Evisc\195\169ration") or 
(CurrentSpell == "Embuscade") or 
(CurrentSpell == "Blade Flurry") or 
(CurrentSpell == "Riposte") or 
(CurrentSpell == "Horion de Terre") or 
(CurrentSpell == "\195\169clair") or 
(CurrentSpell == "Chaine d'\195\169clair") or 
(CurrentSpell == "Horion de givre") or 
(CurrentSpell == "Horion de flammes") or 
(CurrentSpell == "Death Coil") or 
(CurrentSpell == "Douleur br\195\187lante") or 
(CurrentSpell == "Immolation") or 
(CurrentSpell == "Hellfire") or 
(CurrentSpell == "Feu de l'\195\162me") or 
(CurrentSpell == "Conflagration") or 
(CurrentSpell == "Br\195\187lure de l'ombre") or 
(CurrentSpell == "Trait de l'ombre") or 
(CurrentSpell == "Frappe h\195\169ro\195\175que") or 
(CurrentSpell == "Slam") or 
(CurrentSpell == "Retaliation") or 
(CurrentSpell == "Ex\195\169cution") or 
(CurrentSpell == "Fulgurance") or 
(CurrentSpell == "Cleave") or 
(CurrentSpell == "Whirlwind") or 
(CurrentSpell == "Frappe Mortelle") or 
(CurrentSpell == "Sweeping Strikes") or 
(CurrentSpell == "Shield Slam") or 
(CurrentSpell == "Exorcism") or
(CurrentSpell == "Judgement of Command") or
(CurrentSpell == "Seal of Command") or
(CurrentSpell == "Judgement of Righteousness") or
(CurrentSpell == "Holy Shock")) then
					--Check for 5 combo points // play "finishhim.wav"
					if ((SMData[SMPlayerRealm][SMPlayerName].Enable_Sound_Small == true) and (GetComboPoints("Player") == 5)) then
						PlaySoundFile("Interface\\AddOns\\ShaderMod\\Sounds\\finishhim.wav");
					end
					if (CritCombo ~= 0) then
						SMCompare_Combos();
					end
					SMMessageFrame:AddMessage(" [" .. damage .. "] Damage" , DISPLAY_RED, DISPLAY_GREEN, DISPLAY_BLUE, 1, 3);
			end
		end
		--HIT--
		for spellname, creaturename, damage in string.gfind(arg1, SPELL_HIT2)do
		CurrentSpell = tostring(spellname);
		--DEFAULT_CHAT_FRAME:AddMessage("[ShaderMod] Current String CurrentSpell: ->" .. CurrentSpell .. "<-", .2, .0);
if ((CurrentSpell == "\195\169clat lunaire") or 
(CurrentSpell == "Feu stellaire") or 
(CurrentSpell == "Col\195\168re") or 
(CurrentSpell == "Swipe") or 
(CurrentSpell == "Maul") or 
(CurrentSpell == "Claw") or 
(CurrentSpell == "Shred") or 
(CurrentSpell == "Ravage") or 
(CurrentSpell == "Pounce") or 
(CurrentSpell == "Morsure f\195\169roce") or 
(CurrentSpell == "Raptor Strike") or 
(CurrentSpell == "Tir Automatique") or 
(CurrentSpell == "Tir des arcanes") or 
(CurrentSpell == "Multi-Shot") or 
(CurrentSpell == "Vis\195\169e") or 
(CurrentSpell == "Arcane Missiles") or 
(CurrentSpell == "Trait de feu") or 
(CurrentSpell == "Boulle de feu") or 
(CurrentSpell == "Explosion pyrotechnique") or 
(CurrentSpell == "Br\195\187lure") or 
(CurrentSpell == "\195\169clair de givre") or 
(CurrentSpell == "Blizzard") or 
(CurrentSpell == "Ch\195\162timent") or 
(CurrentSpell == "Attaque mentale") or 
(CurrentSpell == "Flammes sacr\195\169es") or 
(CurrentSpell == "Attaque sournoise") or 
(CurrentSpell == "Attaque pernicieuse") or 
(CurrentSpell == "Evisc\195\169ration") or 
(CurrentSpell == "Embuscade") or 
(CurrentSpell == "Blade Flurry") or 
(CurrentSpell == "Riposte") or 
(CurrentSpell == "Horion de Terre") or 
(CurrentSpell == "\195\169clair") or 
(CurrentSpell == "Chaine d'\195\169clair") or 
(CurrentSpell == "Horion de givre") or 
(CurrentSpell == "Horion de flammes") or 
(CurrentSpell == "Death Coil") or 
(CurrentSpell == "Douleur br\195\187lante") or 
(CurrentSpell == "Immolation") or 
(CurrentSpell == "Hellfire") or 
(CurrentSpell == "Feu de l'\195\162me") or 
(CurrentSpell == "Conflagration") or 
(CurrentSpell == "Br\195\187lure de l'ombre") or 
(CurrentSpell == "Trait de l'ombre") or 
(CurrentSpell == "Frappe h\195\169ro\195\175que") or 
(CurrentSpell == "Slam") or 
(CurrentSpell == "Retaliation") or 
(CurrentSpell == "Ex\195\169cution") or 
(CurrentSpell == "Fulgurance") or 
(CurrentSpell == "Cleave") or 
(CurrentSpell == "Whirlwind") or 
(CurrentSpell == "Frappe Mortelle") or 
(CurrentSpell == "Sweeping Strikes") or 
(CurrentSpell == "Shield Slam") or 
(CurrentSpell == "Exorcism") or
(CurrentSpell == "Judgement of Command") or
(CurrentSpell == "Seal of Command") or
(CurrentSpell == "Judgement of Righteousness") or
(CurrentSpell == "Holy Shock")) then
					--Check for 5 combo points // play "finishhim.wav"
					if ((SMData[SMPlayerRealm][SMPlayerName].Enable_Sound_Small == true) and (GetComboPoints("Player") == 5)) then
						PlaySoundFile("Interface\\AddOns\\ShaderMod\\Sounds\\finishhim.wav");
					end
					if (CritCombo ~= 0) then
						SMCompare_Combos();
					end
					SMMessageFrame:AddMessage(" [" .. damage .. "] Damage" , DISPLAY_RED, DISPLAY_GREEN, DISPLAY_BLUE, 1, 3);
			end
		end
		--CRIT--
		for spellname, creaturename, damage in string.gfind(arg1, SPELL_CRIT)do
		CurrentSpell = tostring(spellname);
		--DEFAULT_CHAT_FRAME:AddMessage("[ShaderMod] Current String CurrentSpell: ->" .. CurrentSpell .. "<-", .2, .0);
if ((CurrentSpell == "\195\169clat lunaire") or 
(CurrentSpell == "Feu stellaire") or 
(CurrentSpell == "Col\195\168re") or 
(CurrentSpell == "Swipe") or 
(CurrentSpell == "Maul") or 
(CurrentSpell == "Claw") or 
(CurrentSpell == "Shred") or 
(CurrentSpell == "Ravage") or 
(CurrentSpell == "Pounce") or 
(CurrentSpell == "Morsure f\195\169roce") or 
(CurrentSpell == "Raptor Strike") or 
(CurrentSpell == "Tir Automatique") or 
(CurrentSpell == "Tir des arcanes") or 
(CurrentSpell == "Multi-Shot") or 
(CurrentSpell == "Vis\195\169e") or 
(CurrentSpell == "Arcane Missiles") or 
(CurrentSpell == "Trait de feu") or 
(CurrentSpell == "Boulle de feu") or 
(CurrentSpell == "Explosion pyrotechnique") or 
(CurrentSpell == "Br\195\187lure") or 
(CurrentSpell == "\195\169clair de givre") or 
(CurrentSpell == "Blizzard") or 
(CurrentSpell == "Ch\195\162timent") or 
(CurrentSpell == "Attaque mentale") or 
(CurrentSpell == "Flammes sacr\195\169es") or 
(CurrentSpell == "Attaque sournoise") or 
(CurrentSpell == "Attaque pernicieuse") or 
(CurrentSpell == "Evisc\195\169ration") or 
(CurrentSpell == "Embuscade") or 
(CurrentSpell == "Blade Flurry") or 
(CurrentSpell == "Riposte") or 
(CurrentSpell == "Horion de Terre") or 
(CurrentSpell == "\195\169clair") or 
(CurrentSpell == "Chaine d'\195\169clair") or 
(CurrentSpell == "Horion de givre") or 
(CurrentSpell == "Horion de flammes") or 
(CurrentSpell == "Death Coil") or 
(CurrentSpell == "Douleur br\195\187lante") or 
(CurrentSpell == "Immolation") or 
(CurrentSpell == "Hellfire") or 
(CurrentSpell == "Feu de l'\195\162me") or 
(CurrentSpell == "Conflagration") or 
(CurrentSpell == "Br\195\187lure de l'ombre") or 
(CurrentSpell == "Trait de l'ombre") or 
(CurrentSpell == "Frappe h\195\169ro\195\175que") or 
(CurrentSpell == "Slam") or 
(CurrentSpell == "Retaliation") or 
(CurrentSpell == "Ex\195\169cution") or 
(CurrentSpell == "Fulgurance") or 
(CurrentSpell == "Cleave") or 
(CurrentSpell == "Whirlwind") or 
(CurrentSpell == "Frappe Mortelle") or 
(CurrentSpell == "Sweeping Strikes") or 
(CurrentSpell == "Shield Slam") or 
(CurrentSpell == "Exorcism") or
(CurrentSpell == "Judgement of Command") or
(CurrentSpell == "Seal of Command") or
(CurrentSpell == "Judgement of Righteousness") or
(CurrentSpell == "Holy Shock")) then
							
				--Check for 5 combo points // play "finishhim.wav"
				if ((SMData[SMPlayerRealm][SMPlayerName].Enable_Sound_Small == true) and (GetComboPoints("Player") == 5)) then
					PlaySoundFile("Interface\\AddOns\\ShaderMod\\Sounds\\finishhim.wav");
				end
				CritDmg = tonumber(damage);
				CritCombo = CritCombo + 1;
				CritComboDmg = CritComboDmg + damage;
				if (CritCombo >= 1 and SMData[SMPlayerRealm][SMPlayerName].Running_Combo_Display == true) then
							if (CritCombo > 0 and CritCombo < 2) then
								if (SMData[SMPlayerRealm][SMPlayerName].Enable_Sound_Big == true) then
									PlaySoundFile("Interface\\AddOns\\ShaderMod\\Sounds\\yeah.wav");
								end
								CritMsg = "Yeah!";
--								SMMessageFrame:AddMessage("Yeah! x" .. CritCombo .. " [" .. CritComboDmg .. "] total damage" , DISPLAY_RED, DISPLAY_GREEN, DISPLAY_BLUE, 1, 3);
							end
							if (CritCombo > 1 and CritCombo < 3) then
								if (SMData[SMPlayerRealm][SMPlayerName].Enable_Sound_Big == true) then
									PlaySoundFile("Interface\\AddOns\\ShaderMod\\Sounds\\ohyeah.wav");
								end
								CritMsg = "Oh Yeah!";
--								SMMessageFrame:AddMessage("Oh Yeah! x" .. CritCombo, DISPLAY_RED, DISPLAY_GREEN, DISPLAY_BLUE, 1, 3);
							end
							if (CritCombo > 2 and CritCombo < 4) then
								if (SMData[SMPlayerRealm][SMPlayerName].Enable_Sound_Big == true) then
									PlaySoundFile("Interface\\AddOns\\ShaderMod\\Sounds\\unstoppable.wav");
								end
								CritMsg = "Unstoppable!";
--								SMMessageFrame:AddMessage("Unstoppable! x" .. CritCombo, DISPLAY_RED, DISPLAY_GREEN, DISPLAY_BLUE, 1, 3);
							end
							if (CritCombo > 3 and CritCombo < 5) then
								if (SMData[SMPlayerRealm][SMPlayerName].Enable_Sound_Big == true) then
									PlaySoundFile("Interface\\AddOns\\ShaderMod\\Sounds\\killer.wav");
								end
								CritMsg = "Killing Spree!";
--								SMMessageFrame:AddMessage("Killing Spree! x" .. CritCombo, DISPLAY_RED, DISPLAY_GREEN, DISPLAY_BLUE, 1, 3);
							end
							if (CritCombo > 4 and CritCombo < 6) then
								if (SMData[SMPlayerRealm][SMPlayerName].Enable_Sound_Big == true) then
									PlaySoundFile("Interface\\AddOns\\ShaderMod\\Sounds\\dominating.wav");
								end
								CritMsg = "Dominating!";
--								SMMessageFrame:AddMessage("Dominating! x" .. CritCombo, DISPLAY_RED, DISPLAY_GREEN, DISPLAY_BLUE, 1, 3);
							end
							if (CritCombo > 5 and CritCombo < 7) then
								if (SMData[SMPlayerRealm][SMPlayerName].Enable_Sound_Big == true) then
									PlaySoundFile("Interface\\AddOns\\ShaderMod\\Sounds\\ultrakill.wav");
								end
								CritMsg = "Ultra Kill!";
--								SMMessageFrame:AddMessage("Ultra Kill! x" .. CritCombo, DISPLAY_RED, DISPLAY_GREEN, DISPLAY_BLUE, 1, 3);
							end
							if (CritCombo > 6 and CritCombo < 8) then
								if (SMData[SMPlayerRealm][SMPlayerName].Enable_Sound_Big == true) then
									PlaySoundFile("Interface\\AddOns\\ShaderMod\\Sounds\\wickedsick.wav");
								end
								CritMsg = "Wicked Sick!";
--								SMMessageFrame:AddMessage("Wicked Sick! x" .. CritCombo, DISPLAY_RED, DISPLAY_GREEN, DISPLAY_BLUE, 1, 3);
							end
							if (CritCombo > 7 and CritCombo < 10) then
								if (SMData[SMPlayerRealm][SMPlayerName].Enable_Sound_Big == true) then
									PlaySoundFile("Interface\\AddOns\\ShaderMod\\Sounds\\godlike.wav");
								end
								CritMsg = "God Like!";
--								SMMessageFrame:AddMessage("God Like! x" .. CritCombo, DISPLAY_RED, DISPLAY_GREEN, DISPLAY_BLUE, 1, 3);
							end
							if (CritCombo > 9 and CritCombo < 15) then
								if (SMData[SMPlayerRealm][SMPlayerName].Enable_Sound_Big == true) then
									PlaySoundFile("Interface\\AddOns\\ShaderMod\\Sounds\\holyshit.wav");
								end
								CritMsg = "Holy Shit!";
--								SMMessageFrame:AddMessage("Holy Shit! x" .. CritCombo, DISPLAY_RED, DISPLAY_GREEN, DISPLAY_BLUE, 1, 3);
							end
							if (CritCombo > 14 and CritCombo < 19) then
								if (SMData[SMPlayerRealm][SMPlayerName].Enable_Sound_Big == true) then
									PlaySoundFile("Interface\\AddOns\\ShaderMod\\Sounds\\monsterkill.wav");
								end
								CritMsg = "Mm-mmm-Monster Kill!";
--								SMMessageFrame:AddMessage("Mm-mmm-Monster Kill! x" .. CritCombo, DISPLAY_RED, DISPLAY_GREEN, DISPLAY_BLUE, 1, 3);
							end
							if (CritCombo > 20) then
								if (SMData[SMPlayerRealm][SMPlayerName].Enable_Sound_Big == true) then
									PlaySoundFile("Interface\\AddOns\\ShaderMod\\Sounds\\ludicrouskill.wav");
								end
								CritMsg = "Lu-lu-lu-lu-ludicrous kill!";
--								SMMessageFrame:AddMessage("Lu-lu-lu-lu-ludicrous Kill! x" .. CritCombo, DISPLAY_RED, DISPLAY_GREEN, DISPLAY_BLUE, 1, 3);
							end
							SMMessageFrame:AddMessage(CritMsg .. " x" .. CritCombo .. " [" .. CritComboDmg .. "] total damage (+" .. damage .. ")" , DISPLAY_RED, DISPLAY_GREEN, DISPLAY_BLUE, 1, 3);
				end
			end
		end	
	end
	

	--If player looses agro or kills the current target and SMData[SMPlayerRealm][SMPlayerName].Combos_End_After_Battle is on,
	--  end the combo and compare the combo to the record by calling SMCompare_Combos()
	if (event == "PLAYER_REGEN_ENABLED") then
		if (SMData[SMPlayerRealm][SMPlayerName].Combos_End_After_Battle == true and CritCombo ~= 0) then
			SMCompare_Combos();
		end
	end

end

-- Function: 		SMCompare_Combos()
-- Arguments:		None
-- Returns:  		None
-- Used for: 		Used to compare current combo to combo records to see if it beats any of the records.
function SMCompare_Combos()
	--if statement to see if records meets or breaks both records
	extra_crits_toggle = 0;
	if (CritCombo >= SMData[SMPlayerRealm][SMPlayerName].RecordHitsCritCombo and CritComboDmg >= SMData[SMPlayerRealm][SMPlayerName].RecordDmgCritComboDmg) then
		SMData[SMPlayerRealm][SMPlayerName].RecordHitsCritCombo = CritCombo;
		SMData[SMPlayerRealm][SMPlayerName].RecordHitsCritComboDmg = CritComboDmg;
		SMData[SMPlayerRealm][SMPlayerName].RecordDmgCritCombo = CritCombo;
		SMData[SMPlayerRealm][SMPlayerName].RecordDmgCritComboDmg = CritComboDmg;
	else
		--Used to check if current combo has more hits, if it ties the record for hits, checks to see if the damage is higher than the current record for most hits
		if (CritCombo >= SMData[SMPlayerRealm][SMPlayerName].RecordHitsCritCombo) then
			if (CritCombo == SMData[SMPlayerRealm][SMPlayerName].RecordHitsCritCombo) then
				if (CritComboDmg > SMData[SMPlayerRealm][SMPlayerName].RecordHitsCritComboDmg) then
					SMData[SMPlayerRealm][SMPlayerName].RecordHitsCritCombo = CritCombo;
					SMData[SMPlayerRealm][SMPlayerName].RecordHitsCritComboDmg = CritComboDmg;
				end
			end
			if (CritCombo > SMData[SMPlayerRealm][SMPlayerName].RecordHitsCritCombo) then
				SMData[SMPlayerRealm][SMPlayerName].RecordHitsCritCombo = CritCombo;
				SMData[SMPlayerRealm][SMPlayerName].RecordHitsCritComboDmg = CritComboDmg;
			end
		end
		
		--Used to check if the damage done by the combo is higher than the record for damage dealt in a combo,
		--  if it ties the record for damage, then it checks to see how many hits it took and will set the higher number of hits as the record
		if (CritComboDmg >= SMData[SMPlayerRealm][SMPlayerName].RecordDmgCritComboDmg) then
			if (CritComboDmg == SMData[SMPlayerRealm][SMPlayerName].RecordDmgCritComboDmg) then
				if (CritCombo > SMData[SMPlayerRealm][SMPlayerName].RecordDmgCritCombo) then
					SMData[SMPlayerRealm][SMPlayerName].RecordDmgCritCombo = CritCombo;
					SMData[SMPlayerRealm][SMPlayerName].RecordDmgCritComboDmg = CritComboDmg;
				end
			end
			if (CritComboDmg > SMData[SMPlayerRealm][SMPlayerName].RecordDmgCritComboDmg) then
				SMData[SMPlayerRealm][SMPlayerName].RecordDmgCritCombo = CritCombo;
				SMData[SMPlayerRealm][SMPlayerName].RecordDmgCritComboDmg = CritComboDmg;
			end
		end
	end
	
	
-- BIG LETTER COMBO DISPLAY**
--	if (CritCombo > 2 and CritCombo < 4) then
--		if (SMData[SMPlayerRealm][SMPlayerName].Running_Combo_Display == false and SMData[SMPlayerRealm][SMPlayerName].Enable_Sound_Big == true) then
--			PlaySoundFile("Interface\\AddOns\\ShaderMod\\Sounds\\unstoppable.wav");	
--		end		
--		SMMessageFrame:AddMessage("Damage: " .. CritComboDmg, 1, 1, 1, 1, 3);
--		SMMessageFrame:AddMessage("Combo: " .. CritCombo, 1, 1, 1, 1, 3);
--		SMMessageFrame:AddMessage("Unstoppable!",FDISPLAY_RED, FDISPLAY_GREEN, FDISPLAY_BLUE, 1, 3);
--	end
--	if (CritCombo > 3 and CritCombo < 5) then
--		if (SMData[SMPlayerRealm][SMPlayerName].Running_Combo_Display == false and SMData[SMPlayerRealm][SMPlayerName].Enable_Sound_Big == true) then
--			PlaySoundFile("Interface\\AddOns\\ShaderMod\\Sounds\\killer.wav");
--		end
--		SMMessageFrame:AddMessage("Damage: " .. CritComboDmg, 1, 1, 1, 1, 3);
--		SMMessageFrame:AddMessage("Combo: " .. CritCombo, 1, 1, 1, 1, 3);
--		SMMessageFrame:AddMessage("Killing Spree!",FDISPLAY_RED, FDISPLAY_GREEN, FDISPLAY_BLUE, 1, 3);
--	end
--	if (CritCombo > 4 and CritCombo < 6) then
--		if (SMData[SMPlayerRealm][SMPlayerName].Running_Combo_Display == false and SMData[SMPlayerRealm][SMPlayerName].Enable_Sound_Big == true) then
--			PlaySoundFile("Interface\\AddOns\\ShaderMod\\Sounds\\dominating.wav");
--		end
--		SMMessageFrame:AddMessage("Damage: " .. CritComboDmg, 1, 1, 1, 1, 3);
--		SMMessageFrame:AddMessage("Combo: " .. CritCombo, 1, 1, 1, 1, 3);
--		SMMessageFrame:AddMessage("Dominating!",FDISPLAY_RED, FDISPLAY_GREEN, FDISPLAY_BLUE, 1, 3);
--	end
--	if (CritCombo > 5 and CritCombo < 7) then
--		if (SMData[SMPlayerRealm][SMPlayerName].Running_Combo_Display == false and SMData[SMPlayerRealm][SMPlayerName].Enable_Sound_Big == true) then
--			PlaySoundFile("Interface\\AddOns\\ShaderMod\\Sounds\\ultrakill.wav");
--		end
--		SMMessageFrame:AddMessage("Damage: " .. CritComboDmg, 1, 1, 1, 1, 3);
--		SMMessageFrame:AddMessage("Combo: " .. CritCombo, 1, 1, 1, 1, 3);
--		SMMessageFrame:AddMessage("Ultra Kill!",FDISPLAY_RED, FDISPLAY_GREEN, FDISPLAY_BLUE, 1, 3);
--	end
--	if (CritCombo > 6 and CritCombo < 8) then
--		if (SMData[SMPlayerRealm][SMPlayerName].Running_Combo_Display == false and SMData[SMPlayerRealm][SMPlayerName].Enable_Sound_Big == true) then
--			PlaySoundFile("Interface\\AddOns\\ShaderMod\\Sounds\\WickedSick.wav");
--		end
--		SMMessageFrame:AddMessage("Damage: " .. CritComboDmg, 1, 1, 1, 1, 3);
--		SMMessageFrame:AddMessage("Combo: " .. CritCombo, 1, 1, 1, 1, 3);
--		SMMessageFrame:AddMessage("Wicked Sick!",FDISPLAY_RED, FDISPLAY_GREEN, FDISPLAY_BLUE, 1, 3);
--	end
--	if (CritCombo > 7 and CritCombo < 10) then
--		if (SMData[SMPlayerRealm][SMPlayerName].Running_Combo_Display == false and SMData[SMPlayerRealm][SMPlayerName].Enable_Sound_Big == true) then
--			PlaySoundFile("Interface\\AddOns\\ShaderMod\\Sounds\\godlike.wav");
--		end
--		SMMessageFrame:AddMessage("Damage: " .. CritComboDmg, 1, 1, 1, 1, 3);
--		SMMessageFrame:AddMessage("Combo: " .. CritCombo, 1, 1, 1, 1, 3);
--		SMMessageFrame:AddMessage("God Like!",FDISPLAY_RED, FDISPLAY_GREEN, FDISPLAY_BLUE, 1, 3);
--	end
--	if (CritCombo > 9 and CritCombo < 15) then
--		if (SMData[SMPlayerRealm][SMPlayerName].Running_Combo_Display == false and SMData[SMPlayerRealm][SMPlayerName].Enable_Sound_Big == true) then
--			PlaySoundFile("Interface\\AddOns\\ShaderMod\\Sounds\\holyshit.wav");
--		end
--		SMMessageFrame:AddMessage("Damage: " .. CritComboDmg, 1, 1, 1, 1, 3);
--		SMMessageFrame:AddMessage("Combo: " .. CritCombo, 1, 1, 1, 1, 3);
--		SMMessageFrame:AddMessage("Holy Shit!",FDISPLAY_RED, FDISPLAY_GREEN, FDISPLAY_BLUE, 1, 3);
--	end
--	if (CritCombo > 14 and CritCombo < 19) then
--		if (SMData[SMPlayerRealm][SMPlayerName].Running_Combo_Display == false and SMData[SMPlayerRealm][SMPlayerName].Enable_Sound_Big == true) then
--			PlaySoundFile("Interface\\AddOns\\ShaderMod\\Sounds\\monsterkill.wav");
--		end
--		SMMessageFrame:AddMessage("Damage: " .. CritComboDmg, 1, 1, 1, 1, 3);
--		SMMessageFrame:AddMessage("Combo: " .. CritCombo, 1, 1, 1, 1, 3);
--		SMMessageFrame:AddMessage("Mm-mmm-Monster Kill!",FDISPLAY_RED, FDISPLAY_GREEN, FDISPLAY_BLUE, 1, 3);
--	end
--	if (CritCombo > 20) then
--		if (SMData[SMPlayerRealm][SMPlayerName].Running_Combo_Display == false and SMData[SMPlayerRealm][SMPlayerName].Enable_Sound_Big == true) then
--			PlaySoundFile("Interface\\AddOns\\ShaderMod\\Sounds\\ludicrouskill.wav");
--		end
--		SMMessageFrame:AddMessage("Damage: " .. CritComboDmg, 1, 1, 1, 1, 3);
--		SMMessageFrame:AddMessage("Combo: " .. CritCombo, 1, 1, 1, 1, 3);
--		SMMessageFrame:AddMessage("Lu-lu-lu-lu-ludicrous Kill!",FDISPLAY_RED, FDISPLAY_GREEN, FDISPLAY_BLUE, 1, 3);
--	end
--
-- PARTY DISPLAY **
	if (SMData[SMPlayerRealm][SMPlayerName].Party_Display == true) then
		if ((CritCombo > 20)) then
			SendChatMessage("[ShaderMod] Lu-lu-lu-lu-ludicrous Kill!  *" .. CritCombo .. "* crits for *" .. CritComboDmg .. "* damage! ", "PARTY");
		else
			if ((CritCombo > 14 and CritCombo < 19)) then
				SendChatMessage("[ShaderMod] Mm-mmm-Monster Kill!  *" .. CritCombo .. "* crits for *" .. CritComboDmg .. "* damage! ", "PARTY");
		     else
			    if ((CritCombo > 9 and CritCombo < 15)) then
				    SendChatMessage("[ShaderMod] Holy Shit!  *" .. CritCombo .. "* crits for *" .. CritComboDmg .. "* damage! ", "PARTY");
			 else
				if ((CritCombo > 7 and CritCombo < 10)) then
					SendChatMessage("[ShaderMod] God Like!  *" .. CritCombo .. "* crits for *" .. CritComboDmg .. "* damage! ", "PARTY");
				else
					if ((CritCombo > 6 and CritCombo < 8)) then
						SendChatMessage("[ShaderMod] Wicked Sick!  *" .. CritCombo .. "* crits for *" .. CritComboDmg .. "* damage! ", "PARTY");
					else
						if ((CritCombo > 5 and CritCombo < 7)) then
							SendChatMessage("[ShaderMod] Ultra Kill!  *" .. CritCombo .. "* crits for *" .. CritComboDmg .. "* damage! ", "PARTY");
						end

					end
				end
			end
		end
	end
 end

-- RAID DISPLAY **
	if (SMData[SMPlayerRealm][SMPlayerName].Raid_Display == true) then
		if ((CritCombo > 20)) then
			SendChatMessage("[ShaderMod] Lu-lu-lu-lu-ludicrous Kill!  *" .. CritCombo .. "* crits for *" .. CritComboDmg .. "* damage! ", "RAID");
		else
			if ((CritCombo > 14 and CritCombo < 19)) then
				SendChatMessage("[ShaderMod] Mm-mmm-Monster Kill!  *" .. CritCombo .. "* crits for *" .. CritComboDmg .. "* damage! ", "RAID");
		     else
			    if ((CritCombo > 9 and CritCombo < 15)) then
				    SendChatMessage("[ShaderMod] Holy Shit!  *" .. CritCombo .. "* crits for *" .. CritComboDmg .. "* damage! ", "RAID");
			 else
				if ((CritCombo > 7 and CritCombo < 10)) then
					SendChatMessage("[ShaderMod] God Like!  *" .. CritCombo .. "* crits for *" .. CritComboDmg .. "* damage! ", "RAID");
				else
					if ((CritCombo > 6 and CritCombo < 8)) then
						SendChatMessage("[ShaderMod] Wicked Sick!  *" .. CritCombo .. "* crits for *" .. CritComboDmg .. "* damage! ", "RAID");
					else
						if ((CritCombo > 5 and CritCombo < 7)) then
							SendChatMessage("[ShaderMod] Ultra Kill!  *" .. CritCombo .. "* crits for *" .. CritComboDmg .. "* damage! ", "RAID");
						end

					end
				end
			end
		end
	end
 end
	
	-- Crit Varibles reset.
	CritCombo = 0;
	CritComboDmg = 0;
end


-- Function: 		SMInitializeSMData()
-- Arguments:		None
-- Returns:  		None
-- Used for: 		Initializes SMData incase it isn't already in SavedVariables
function SMInitializeSMData()
	if (SMData == nil) then
		SMData = {};
	end
	
	if (SMData[SMPlayerRealm] == nil) then
		SMData[SMPlayerRealm] = {};
	end

	if (SMPlayerName ~= nil and SMPlayerName ~= UNKNOWNOBJECT and SMPlayerName ~= UKNOWNBEING) then
		if (SMData[SMPlayerRealm][SMPlayerName] == nil) then
			SMData[SMPlayerRealm][SMPlayerName] = {};
			SMSetCurrentPlayerToZeros();
			SMSetDefaultOptions();
		end
	end
end


-- Function: 		SMSetCurrentPlayerToZeros()
-- Arguments:		None
-- Returns:  		None
-- Used for: 		Sets all the records to be 0 hits with 0 damage
function SMSetCurrentPlayerToZeros()
	SMData[SMPlayerRealm][SMPlayerName].RecordHitsCritCombo = 0;
	SMData[SMPlayerRealm][SMPlayerName].RecordHitsCritComboDmg = 0;
	SMData[SMPlayerRealm][SMPlayerName].RecordDmgCritCombo = 0;
	SMData[SMPlayerRealm][SMPlayerName].RecordDmgCritComboDmg = 0;
end


-- Function: 		SMSetDefaultOptions()
-- Arguments:		None
-- Returns:  		None
-- Used for: 		Sets all the records to be 0 hits with 0 damage
function SMSetDefaultOptions()
	SMData[SMPlayerRealm][SMPlayerName].Misses_Break_Combo = true;
	SMData[SMPlayerRealm][SMPlayerName].Combos_End_After_Battle = true;
	SMData[SMPlayerRealm][SMPlayerName].Party_Display = false;
	SMData[SMPlayerRealm][SMPlayerName].Raid_Display = false;
	SMData[SMPlayerRealm][SMPlayerName].Running_Combo_Display = true;
	SMData[SMPlayerRealm][SMPlayerName].Enable_Sound_Big = true;
	SMData[SMPlayerRealm][SMPlayerName].Enable_Sound_Small = true;
end

-- Function: 		SMResetAll()
-- Arguments:		None
-- Returns:  		None
-- Used for: 		Used when clicking Reset All in the options menu. Deletes all options and records
function SMResetAll()
	SMData = {};
	SMInitializeSMData();
	SMOptionsFrame_OnShow();
		
	DEFAULT_CHAT_FRAME:AddMessage("[ShaderMod] All records and options reset.", .2, .0);
end


-- Function: 		SMDisplayHelp()
-- Arguments:		None
-- Returns:  		None
-- Used for: 		Outputs Help menu to DEFAULT_CHAT_FRAME
function SMDisplayHelp()
	DEFAULT_CHAT_FRAME:AddMessage("|cFF00FF00[ShaderMod] " .. SHADERMOD_VERSION .. " |cFF00FF00: Modifications by |cFF00FFFFSky-|cFF0000FFDexter.", .2, .0);
	DEFAULT_CHAT_FRAME:AddMessage("[Commands] (/ShaderMod, /ShaderM, /sm)",.65,.65,.6);
	DEFAULT_CHAT_FRAME:AddMessage("   menu - Shows the options menu.");
	DEFAULT_CHAT_FRAME:AddMessage("   records - Shows your records.");
	DEFAULT_CHAT_FRAME:AddMessage("   version - Displays current version.");
	DEFAULT_CHAT_FRAME:AddMessage("   lock/unlock - Lock or unlock combat log.");
	DEFAULT_CHAT_FRAME:AddMessage("   hide/show - Hide or show combat log.");
end



-- Function: 		SMOptionsFrame_OnShow()
-- Arguments:		None
-- Returns:  		None
-- Used for: 		Populates checkboxes of options panel when it is opened
function SMOptionsFrame_OnShow()	
	if (SMData[SMPlayerRealm][SMPlayerName].Running_Combo_Display) then
		SMCheckBoxRunning_Combo_Display:SetChecked(1);
	else
		SMCheckBoxRunning_Combo_Display:SetChecked(0);
	end

	if (SMData[SMPlayerRealm][SMPlayerName].Party_Display) then
		SMCheckBoxParty_Display:SetChecked(1);
	else
		SMCheckBoxParty_Display:SetChecked(0);
	end

	if (SMData[SMPlayerRealm][SMPlayerName].Raid_Display) then
		SMCheckBoxRaid_Display:SetChecked(1);
	else
		SMCheckBoxRaid_Display:SetChecked(0);
	end

	if (SMData[SMPlayerRealm][SMPlayerName].Enable_Sound_Big) then
		SMCheckBoxEnable_Sound_Big:SetChecked(1);
	else
		SMCheckBoxEnable_Sound_Big:SetChecked(0);
	end

	if (SMData[SMPlayerRealm][SMPlayerName].Enable_Sound_Small) then
		SMCheckBoxEnable_Sound_Small:SetChecked(1);
	else
		SMCheckBoxEnable_Sound_Small:SetChecked(0);
	end
	
end


-- Function: 		SMCheckBoxClick()
-- Arguments:		var_to_toggle == variable that will be toggled from either true to false
-- Returns:  		None
-- Used for: 		Populates checkboxes of options panel when it is opened
function SMCheckBoxClick(var_to_toggle)
	if ( this:GetChecked() ) then
		var_to_toggle = true;
	else
		var_to_toggle = false;
	end
end


