欢迎来到虫虫下载站 | 资源下载 资源专辑 关于我们
虫虫下载站

combatsct.lua

时间太紧了
LUA
第 1 页 / 共 4 页
字号:
end

----------------------
--Set a value in player config
function DSCT_Set(option, newVal)
	if (DSCTPlayer ~= nil) then
		if ( option ) then
			DSCTPlayer[option] = newVal;
			if newVal == 1 and EVENT_LIST[option] then
				for keyB ,valueB in EVENT_LIST[option] do
					DSCT_RegisterEvent(valueB);
				end
			end
		end
	end
end

----------------------
--Get a color in the player config
function DSCT_nGetColor(key)
	local color = {r = 1.0, g = 1.0, b = 1.0};	
	if (DSCTPlayer ~= nil) and (DSCTPlayer["COLORS"][key] ~= nil) then
		color.r = DSCTPlayer["COLORS"][key].r;
		color.g = DSCTPlayer["COLORS"][key].g;
		color.b = DSCTPlayer["COLORS"][key].b;		
	else
		if default_config["COLORS"][key] ~= nil then
			color.r = default_config["COLORS"][key].r;
			color.g = default_config["COLORS"][key].g;
			color.b = default_config["COLORS"][key].b;
		else
			DSCT_Debug("DSCT_Debug:"..key);
		end		
	end
	return color;
end
function DSCT_GetColor(key)
	return {r = 1.0, g = 1.0, b = 1.0};
end
----------------------
--Set a color in the player config
function DSCT_SetColor(key, r, g, b)
	if (DSCTPlayer ~= nil) and (DSCTPlayer["COLORS"][key] ~= nil) then
		DSCTPlayer["COLORS"][key].r = r;
		DSCTPlayer["COLORS"][key].g = g;
		DSCTPlayer["COLORS"][key].b = b;
	else
		local color = {r = 1.0, g = 1.0, b = 1.0};
		color.r = default_config["COLORS"][key].r;
		color.g = default_config["COLORS"][key].g;
		color.b = default_config["COLORS"][key].b;
		DSCTPlayer["COLORS"][key] = color;
	end
end

----------------------
-- Event Handler
-- this function parses events that are printed in the combat
-- chat window then displays the health changes
function DSCT_OnEvent()
	if (event == "VARIABLES_LOADED") or ( event == "ADDON_LOADED" and arg1 == "sct" ) or (event == "PLAYER_ENTERING_WORLD") then
		DSCT_Initialize();
		if event == "PLAYER_ENTERING_WORLD" and fixfor_sw_stats == true then
			DSCT_AllSearch_Filter();
			if DSCT_Support then DSCT_Support();end
			fixfor_sw_stats = false;			
		end
		if (GlimSCTHASLOAD == nil) then
			if(not gLimSctEnable) then
				gLimSctEnable = 1;
			end
			gLim_Sct_Register();
			GlimSCTHASLOAD = 1;
		end
		return;
	end
	if DSCT_NameRegistered == 0 then		
		return;
	end
	if DSCT_Get("ENABLED") == 0 then return;end
	
	
	local critical;
	local mob,mob2, spell, amountk;	
	
	if DSCT_Get("CUSTOMEVENT") ~= 0 and event ~= "UNIT_HEALTH" then
		if DSCT_CustomEventSearch(arg1) == true then return;end
	end
	
	if event == "UNIT_HEALTH" then		
		if arg1 == "player" and DSCT_Get("SHOWLOWHP") ~= 0 and (DSCT_NameRegistered == 1) then
			local warnlevel = DSCT_Get("LOWHP");
			local HPPercent = UnitHealth("player") / UnitHealthMax("player");
			if (HPPercent < warnlevel) and (DSCT_LastHPPercent >= warnlevel) then
				local txt = (DSCT_Get("LOWHP") *100).."%";
				txt = string.sub(txt,1,2);
				DSCT_Display_Toggle("SHOWLOWHP",DSCT_LowHP[DSCT_ENTEXT]..UnitHealth("player").."* <"..txt.."%");
			end
			DSCT_LastHPPercent = HPPercent;
		end
		if arg1 == "target" and DSCT_Get("SHOWEXECUTE") ~= 0 then			
			if (UnitIsEnemy("target", "player")) and (not UnitIsDead("target")) and
					(not UnitIsCorpse("target")) and 
					((currentclass == DSCT_PALADIN) or (currentclass == DSCT_WARRIOR)) then
				local HPTargetPercent = UnitHealth("target");
				if (HPTargetPercent < 20) and (DSCT_LastTargetHPPercent >= 20) then
					local msg;
					if (currentclass == DSCT_WARRIOR) then
						msg = DSCT_ExecuteMessage;
					else
						msg = DSCT_WrathMessage;
					end
					DSCT_Display_Toggle("SHOWEXECUTE", msg);
				end
				DSCT_LastTargetHPPercent = HPTargetPercent;
			end
		end
		return;
	elseif (event == "PLAYER_TARGET_CHANGED") then
			if (UnitIsEnemy("target", "player") and (not UnitIsDead("target")) and (not UnitIsCorpse("target"))) then
				DSCT_LastTargetHPPercent = UnitHealth("target");
			else
				DSCT_LastTargetHPPercent = 100;
			end
	elseif event == "UNIT_MANA" then
		if arg1 == "player" and DSCT_Get("SHOWLOWMANA") ~= 0 and DSCT_NameRegistered == 1 and UnitPowerType("player")== 0 then
			local warnlevel = DSCT_Get("LOWMANA");
			local ManaPercent = UnitMana("player") / UnitManaMax("player");
			if (ManaPercent < warnlevel) and (DSCT_LastManaPercent >= warnlevel) then
				local txt = (DSCT_Get("LOWMANA") *100).."%";
				txt = string.sub(txt,1,2);
				DSCT_Display_Toggle("SHOWLOWMANA",DSCT_LowMana[DSCT_ENTEXT]..UnitMana("player").."* <"..txt.."%");
			end
			DSCT_LastManaPercent = ManaPercent;
		end
		return;
	elseif event =="PLAYER_REGEN_DISABLED" then
		if DSCT_Get("SHOWCOMBATIN") ~= 0 then
			--PlaySoundFile("Sound\\Doodad\\BellTollNightElf.wav");
			DSCT_Display_Toggle("SHOWCOMBATIN",DSCT_Combat[DSCT_ENTEXT]);		
		end
		return;
	elseif event =="PLAYER_REGEN_ENABLED" then
		if DSCT_Get("SHOWCOMBATOUT") ~= 0 then			
			DSCT_Display_Toggle("SHOWCOMBATOUT",DSCT_NoCombat[DSCT_ENTEXT]);		
		end
		return;
	elseif event == "PLAYER_COMBO_POINTS" then
		if DSCT_Get("SHOWCOMBOPOINTS") ~= 0 then
			local DSCT_CP = GetComboPoints();
			if (DSCT_CP ~= 0) then
				local DSCT_CP_Message = DSCT_CP.." "..DSCT_ComboPoint[DSCT_ENTEXT];
				if (DSCT_CP == 5) then
					DSCT_CP_Message = DSCT_CP_Message.." "..DSCT_FiveCPMessage[DSCT_ENTEXT];
				end;					
				DSCT_Display_Toggle("SHOWCOMBOPOINTS",DSCT_CP_Message);
			end
		end
		return;
	elseif event == "CHAT_MSG_COMBAT_HONOR_GAIN" then
		if DSCT_Get("SHOWHONOR_DSCT") ~= 0 then
			for honor in string.gfind(arg1, DSCT_HONOR_SEARCH) do			
				DSCT_Display_Toggle("SHOWHONOR_DSCT","+"..honor.." "..DSCT_Honor[DSCT_ENTEXT]);
			end
		end
		return;
	elseif event == "CHAT_MSG_COMBAT_CREATURE_VS_SELF_MISSES" or event == "CHAT_MSG_COMBAT_HOSTILEPLAYER_MISSES" then
		if DSCT_Get("SHOWABSORB") ~= 0 then
			for mob in string.gfind( arg1, DSCT_ABSORB_AMOUNT_SEARCH1) do						
				DSCT_Display_Toggle("SHOWABSORB",DSCT_Absorb[DSCT_ENTEXT]);
				return;
			end
			for mob,spell in string.gfind( arg1, DSCT_ABSORB_AMOUNT_SEARCH2) do						
				DSCT_Display_Toggle("SHOWABSORB",DSCT_Absorb[DSCT_ENTEXT]);	
				return;
			end
		end
		--if none, return
		return;
	elseif event == "CHAT_MSG_COMBAT_CREATURE_VS_SELF_HITS" or event == "CHAT_MSG_COMBAT_HOSTILEPLAYER_HITS" then
		if event == "CHAT_MSG_COMBAT_CREATURE_VS_SELF_HITS" and DSCT_Get("SHOWABSORB") ~= 0 then
			for num3 in string.gfind( arg1, DSCT_ABSORB_TRAILER_SEARCH) do
				DSCT_Display_Toggle("SHOWABSORB",DSCT_Absorb[DSCT_ENTEXT].." *"..num3);	
				return;
			end
		end
		--partial block
		for num, num2 in string.gfind( arg1, DSCT_BLOCK_AMOUNT_SEARCH) do		
			if DSCT_Get("SHOWBLOCK") ~= 0 then
				DSCT_Display_Toggle("SHOWBLOCK",num2);					
			end			
		end		
		--if none, return
		return;
	elseif event == "CHAT_MSG_COMBAT_SELF_HITS" then
		if DSCT_Get("SHOWDMGCRIT") ~= 0 then
			for mob, num in string.gfind( arg1, DSCT_YOUCRIT_SEARCH3 ) do											
				DSCT_Display_Toggle("SHOWDMGCRIT",DSCT_CRIT..num);
			end
		end
		return;
	--Debuffs
	elseif event == "CHAT_MSG_SPELL_PERIODIC_SELF_DAMAGE" then
		if DSCT_Get("SHOWPOWER") ~= 0 then
			for spell,mob,virnum,virname,num,name in string.gfind( arg1, DSCT_YOU_GAIN_POWER_SEARCH1 ) do
				if ((name == MANA) or (name == ENERGY) or (name == RAGE)) then
					local id = 1;
					if name == ENERGY then id = 2;end
					if name == RAGE then id = 3;end
					DSCT_Display_Toggle("SHOWPOWER","+"..num..DSCT_PowerList[id][DSCT_ENTEXT]);
					return;
				end				
			end
			for mob,num,name in string.gfind( arg1, DSCT_YOU_GAIN_POWER_SEARCH2 ) do
				if ((name == MANA) or (name == ENERGY) or (name == RAGE)) then
					local id = 1;
					if name == ENERGY then id = 2;end
					if name == RAGE then id = 3;end
					DSCT_Display_Toggle("SHOWPOWER","+"..num..DSCT_PowerList[id][DSCT_ENTEXT]);
					return;
				end	
			end
			for mob,spell,num,name in string.gfind( arg1, DSCT_YOU_GAIN_POWER_SEARCH3 ) do
				if ((name == MANA) or (name == ENERGY) or (name == RAGE)) then
					local id = 1;
					if name == ENERGY then id = 2;end
					if name == RAGE then id = 3;end
					DSCT_Display_Toggle("SHOWPOWER","+"..num..DSCT_PowerList[id][DSCT_ENTEXT]);
					return;
				end
			end
		end		
		if DSCT_Get("SHOWDEBUFF") ~= 0 then
			for num in string.gfind(arg1, DSCT_DEBUFF_NAME_SEARCH) do				
				DSCT_Display_Toggle("SHOWDEBUFF","「"..num.."」",0,format(DSCT_AFFLICTED_BY, num));
			end
		end	
		return;
	--Self Buffs
	elseif event == "CHAT_MSG_SPELL_SELF_BUFF" then		
		--Configured self buffs
		--DoT Heal, Mana, Rage, Energy
		if DSCT_Get("SHOWHEAL") ~= 0 then	
			for spell,num in string.gfind( arg1, DSCT_HEAL_SEARCH2 ) do	
				DSCT_Display_Toggle("SHOWHEAL","+"..num);
				return;		
			end
			for spell,num in string.gfind( arg1, DSCT_CRITHEAL_SEARCH2 ) do	
				DSCT_Display_Toggle("SHOWHEAL","+"..num,1);
				return;		
			end	
		end
		if DSCT_Get("SHOWPOWER") ~= 0 then
			for spell,mob,virnum,virname,num,name in string.gfind( arg1, DSCT_YOU_GAIN_POWER_SEARCH1 ) do
				if ((name == MANA) or (name == ENERGY) or (name == RAGE)) then
					local id = 1;
					if name == ENERGY then id = 2;end
					if name == RAGE then id = 3;end
					DSCT_Display_Toggle("SHOWPOWER","+"..num..DSCT_PowerList[id][DSCT_ENTEXT]);
					return;
				end				
			end
			for mob,num,name in string.gfind( arg1, DSCT_YOU_GAIN_POWER_SEARCH2 ) do
				if ((name == MANA) or (name == ENERGY) or (name == RAGE)) then
					local id = 1;
					if name == ENERGY then id = 2;end
					if name == RAGE then id = 3;end
					DSCT_Display_Toggle("SHOWPOWER","+"..num..DSCT_PowerList[id][DSCT_ENTEXT]);
					return;
				end	
			end
			for mob,spell,num,name in string.gfind( arg1, DSCT_YOU_GAIN_POWER_SEARCH3 ) do
				if ((name == MANA) or (name == ENERGY) or (name == RAGE)) then
					local id = 1;
					if name == ENERGY then id = 2;end
					if name == RAGE then id = 3;end
					DSCT_Display_Toggle("SHOWPOWER","+"..num..DSCT_PowerList[id][DSCT_ENTEXT]);
					return;
				end
			end
		end
		--Buff
		if DSCT_Get("SHOWBUFF") ~= 0 then
			for name in string.gfind( arg1, DSCT_YOU_GAIN_SEARCH ) do					
				DSCT_Display_Toggle("SHOWBUFF",DSCT_YOU_GAIN_UNM..name.."*", 0, DSCT_YOU_GAIN..name);						
			end				
		end
		return;	
	elseif event == "CHAT_MSG_SPELL_SELF_DAMAGE" then
		if DSCT_Get("SHOWSPELLCRIT") ~= 0 then
			for spell, mob,num,typ in string.gfind(arg1, DSCT_YOUCRIT_SEARCH) do
				if spell and mob and num then						
					DSCT_Display_Toggle("SHOWSPELLCRIT",DSCT_CRIT..spell.." "..num,0);
					return;
				end
			end
			for spell, mob,num in string.gfind(arg1, DSCT_YOUCRIT_SEARCH2) do
				if spell and mob and num then
					DSCT_Display_Toggle("SHOWSPELLCRIT",DSCT_CRIT..spell.." "..num, 0);
					return;
				end
			end
		end
		return;
	elseif event == "CHAT_MSG_SPELL_PERIODIC_SELF_BUFFS" then		
		--Configured self buffs
		--DoT Heal, Mana, Rage, Energy
		if DSCT_Get("SHOWPOWER") ~= 0 then
			for spell,mob,virnum,virname,num,name in string.gfind( arg1, DSCT_YOU_GAIN_POWER_SEARCH1 ) do
				if ((name == MANA) or (name == ENERGY) or (name == RAGE)) then
					local id = 1;
					if name == ENERGY then id = 2;end
					if name == RAGE then id = 3;end
					DSCT_Display_Toggle("SHOWPOWER","+"..num..DSCT_PowerList[id][DSCT_ENTEXT]);
					return;
				end				
			end
			for mob,num,name in string.gfind( arg1, DSCT_YOU_GAIN_POWER_SEARCH2 ) do
				if ((name == MANA) or (name == ENERGY) or (name == RAGE)) then
					local id = 1;
					if name == ENERGY then id = 2;end
					if name == RAGE then id = 3;end
					DSCT_Display_Toggle("SHOWPOWER","+"..num..DSCT_PowerList[id][DSCT_ENTEXT]);
					return;
				end	
			end
			for mob,spell,num,name in string.gfind( arg1, DSCT_YOU_GAIN_POWER_SEARCH3 ) do
				if ((name == MANA) or (name == ENERGY) or (name == RAGE)) then
					local id = 1;
					if name == ENERGY then id = 2;end
					if name == RAGE then id = 3;end
					DSCT_Display_Toggle("SHOWPOWER","+"..num..DSCT_PowerList[id][DSCT_ENTEXT]);
					return;
				end
			end
		end
		--Buff
		if DSCT_Get("SHOWBUFF") ~= 0 then
			for name in string.gfind( arg1, DSCT_YOU_GAIN_SEARCH ) do					
				DSCT_Display_Toggle("SHOWBUFF",DSCT_YOU_GAIN_UNM..name.."*", 0, DSCT_YOU_GAIN..name);					
				return;
			end
		end
		--if none, return		
		if DSCT_Get("SHOWHEAL") ~= 0 then	
			for name,spell,num in string.gfind( arg1, DSCT_AURAHEAL_SEARCH1 ) do	
				if DSCT_Get("HEALERNAME") ~= 0 then
					DSCT_Display_Toggle("SHOWHEAL","+"..num.."  *"..name);					
				else
					DSCT_Display_Toggle("SHOWHEAL","+"..num);
				end
				return;		
			end
			for spell,num in string.gfind( arg1, DSCT_AURAHEAL_SEARCH2 ) do	
				DSCT_Display_Toggle("SHOWHEAL","+"..num);
				return;		
			end			
		end		
		return;
	--Buff Fades
	elseif event == "CHAT_MSG_SPELL_AURA_GONE_SELF" then			
		--Buff Fades		
		if DSCT_Get("SHOWFADE") ~= 0 then
			for name in string.gfind(arg1, DSCT_FADE_SEARCH) do					
				DSCT_Display_Toggle("SHOWFADE",DSCT_YOU_FADE_UNM..name.."*", 0, DSCT_YOU_FADE..name);	
				return;
			end
		end
		--if none, return
		return;
	elseif event == "UNIT_COMBAT" then		
		--if it didn't happen to the player, leave
		if (arg1 ~= "player") then
			return;
		end

		--Set Crit Flag
		if(arg3 == "CRITICAL") then
			critical=1;
		else
			critical=0;
		end
		
		--If Damage
		if arg2 == "WOUND" then
			-- If Absorb
			if arg3 == "ABSORB" then
				if DSCT_Get("SHOWABSORB") ~= 0 then
					DSCT_Display_Toggle("SHOWABSORB",DSCT_Absorb[DSCT_ENTEXT]);
					return;	
				end				
			end
			
			--If Damage
			if arg4 ~= 0 or arg4 ~= nil then
				--Spell
				if arg5 > 0 then
					if DSCT_Get("SHOWSPELL") ~= 0 then
						if DSCT_Get("DAMAGETYPE") == 1 then											
							DSCT_Display_Toggle("SHOWSPELL","-"..arg4.."  "..sct_spelltypes[arg5][DSCT_ENTEXT] , critical);							
						else
							DSCT_Display_Toggle("SHOWSPELL","-"..arg4, critical);
						end
					end
				else
					if DSCT_Get("SHOWHIT") ~= 0 then							
						DSCT_Display_Toggle("SHOWHIT","-"..arg4 , critical);
					end
				end
			end
			return;
		
		elseif arg2 == "MANA" then
			if arg4 ~= 0 or arg4 ~= nil then
				if DSCT_Get("SHOWPOWER") ~= 0 then						
					DSCT_Display_Toggle("SHOWPOWER","+"..arg4.." "..DSCT_PowerList[1][DSCT_ENTEXT]);
				end
			end
			return;
			
		--If a Dodge
		elseif arg2 == "DODGE" then
			if DSCT_Get("SHOWDODGE") ~= 0 then					
				DSCT_Display_Toggle("SHOWDODGE",DSCT_DodgeMsg[DSCT_ENTEXT]);								
			end
			return;
		
		--If a Full Block
		elseif arg2 == "BLOCK" then
			if DSCT_Get("SHOWBLOCK") ~= 0 then
				DSCT_Display_Toggle("SHOWBLOCK",DSCT_BlockMsg[DSCT_ENTEXT]);								
			end
			return;
		
		--If a Parry
		elseif arg2 == "PARRY" then
			if DSCT_Get("SHOWPARRY") ~= 0 then
				DSCT_Display_Toggle("SHOWPARRY",DSCT_ParryMsg[DSCT_ENTEXT]);								
			end
			return;
		
		elseif arg2 == "RESIST" then				
			if DSCT_Get("SHOWRESIST") ~= 0 then
				DSCT_Display_Toggle("SHOWRESIST",DSCT_ResistMsg[DSCT_ENTEXT]);								
			end
			--if none, return
			return;			
		--if none, return
			
		--If a Miss
		elseif arg2 == "MISS" then			
			if DSCT_Get("SHOWMISS") ~= 0 then
				DSCT_Display_Toggle("SHOWMISS",DSCT_MissMsg[DSCT_ENTEXT]);								
			end
			--if none, return
			return;
		end
		--if none, return
		return;
	--Sepll Miss events
	elseif event == "UNIT_SPELLMISS" then			
		--if it didn't happen to the player, leave
		if arg1 ~= "player" then
			return;--Dennie add
		end
			
		--If Resist
		if arg2 == "RESIST" then
			if DSCT_Get("SHOWRESIST") ~= 0 then
				DSCT_Display_Toggle("SHOWRESIST",DSCT_ResistMsg[DSCT_ENTEXT]);
			end
			return;
			
		--If Resist Ranged attack
		elseif arg2 == "PHYSICAL" then
			if DSCT_Get("SHOWRESIST") ~= 0 then
				DSCT_Display_Toggle("SHOWRESIST",DSCT_ResistMsg[DSCT_ENTEXT]);								
			end
			return;
			
		--If Deflected
		elseif arg2 == "DEFLECTED" then
			if DSCT_Get("SHOWRESIST") ~= 0 then
				DSCT_Display_Toggle("SHOWRESIST",DSCT_DeflectMsg[DSCT_ENTEXT]);						
			end
			return;
		end
	elseif (event == "CHAT_MSG_SPELL_HOSTILEPLAYER_BUFF") then
		if DSCT_Get("SHOWHEAL") ~= 0 then	
			for name,spell,num in string.gfind( arg1, DSCT_HEAL_SEARCH1 ) do	
				if DSCT_Get("HEALERNAME") ~= 0 then
					DSCT_Display_Toggle("SHOWHEAL","+"..num.."  *"..name);
				else
					DSCT_Display_Toggle("SHOWHEAL","+"..num);
				end
				return;		
			end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -