⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sheepwatch.lua

📁 时间太紧了
💻 LUA
📖 第 1 页 / 共 2 页
字号:
end---------------------------------------------------------- Check if a target is polymorhped.--------------------------------------------------------function isPolymorphed( unit )  local i = 1;  local debuff;  if ( UnitIsDead("target") or UnitIsCorpse("target") ) then  	return false 	else   	while ( UnitDebuff( unit, i ) ) do 			if( SHEEPWATCH.DEBUG ) then				DEFAULT_CHAT_FRAME:AddMessage("SheepWatch Debug: " .. unit .. " is debuffed with: " .. UnitDebuff( unit, i ));			end			if( string.find( UnitDebuff( unit, i ), SHEEPWATCH.DEBUFF ) ) then				return true    	end    	i = i + 1;  	end  	return false  endend---------------------------------------------------------- Helper function to be called from macros for debugging-- (no direct call from the script)--------------------------------------------------------function showAllUnitDebuffs(unit)  local i = 1  while (UnitDebuff(unit, i)) do    DEFAULT_CHAT_FRAME:AddMessage(UnitDebuff(unit, i));    i = i + 1;  endendfunction showAllUnitBuffs(unit)  local i = 1  while (UnitBuff(unit, i)) do    DEFAULT_CHAT_FRAME:AddMessage(UnitBuff(unit, i));    i = i + 1;  endend---------------------------------------------------------- Polymorphs the current target with your highest rank--------------------------------------------------------function SheepWatch_SheepTarget()	if ( UnitName("target") and UnitCanAttack("player", "target") ) then--	if ( SHEEPWATCH.ANNOUNCE and SHEEPWATCH.ANNOUNCE_TIME_ID == 1) then--		SheepWatch_SendAnnounce(UnitName("target"), UnitLevel("target"));--	end	CastSpellByName( SHEEPWATCH_SPELL .. "(" .. SHEEPWATCH.RANK .. ")");	endendfunction SheepWatch_ReSheepTarget()	if( SheepWatch_ReTargetMob() ) then		CastSpellByName( SHEEPWATCH_SPELL .. "(" .. SHEEPWATCH.RANK .. ")");	else		DEFAULT_CHAT_FRAME:AddMessage( SHEEPWATCH_TEXT_ANNOUNCE_TARGETFAILED );	endend---------------------------------------------------------- Tries to retargets our sheep when clicked on progessbar--------------------------------------------------------function SheepWatch_ReTargetMob()	local i	local foundSheep = false;	-- Atfirst the obvisious ones..	TargetLastEnemy();	if ( isPolymorphed("target") ) then		foundSheep = true;	else		TargetByName(SHEEPWATCH.MOBNAME);		if ( isPolymorphed("target") ) then			foundSheep = true;		else		-- Let's cycle a bit (but not until Harry Potter 7 arrives in the stores :).			for i=1,20 do				if( SHEEPWATCH.DEBUG ) then					DEFAULT_CHAT_FRAME:AddMessage("SheepWatch Debug: ReTargetMob Cycle: " .. i);				end				TargetNearestEnemy();				if ( isPolymorphed("target") ) then					if( SHEEPWATCH.DEBUG ) then						DEFAULT_CHAT_FRAME:AddMessage("SheepWatch Debug: Found Sheep");					end					foundSheep = true;					break				end			end		end	end	if( foundSheep ) then		if( SHEEPWATCH.VERBOSE ) then		 	DEFAULT_CHAT_FRAME:AddMessage( SHEEPWATCH_TEXT_ANNOUNCE_TARGETSUCCESS );		end		return true	else		if( SHEEPWATCH.VERBOSE ) then		 	DEFAULT_CHAT_FRAME:AddMessage( SHEEPWATCH_TEXT_ANNOUNCE_TARGETFAILED );		end		return false	endend---------------------------------------------------------- Get the highest rank of Polymorph spell--------------------------------------------------------local function SheepWatch_GetSpellRank(spell)	local rank = 0;	for i = 1, 180 do		local spellName, spellRank = GetSpellName(i, BOOKTYPE_SPELL);		if( spellName ) then			if( string.find(spellName, spell, 1, true) and ( spellName ~= SHEEPWATCH_SPELL2) ) then				--DEFAULT_CHAT_FRAME:AddMessage(spellName .. " " .. spellRank);				rank = spellRank;			end		end 	end  return rank;end---------------------------------------------------------- Set SHEEPWATCH.LENGTH based on the highest spell rank--------------------------------------------------------function SheepWatch_SetTimerLength()	local rank = SheepWatch_GetSpellRank( SHEEPWATCH_SPELL );	if ( GetLocale() == "koKR" ) then  	_, _, ranknumber = string.find( rank, "(.+) " );  else		_, _, _, ranknumber = string.find( rank, "(.+) (.+)" ); 	end	SHEEPWATCH.RANK = rank;	-- DEBUG	if (SHEEPWATCH.DEBUG) then		SheepWatch_DebugLog("Rank set to:" .. SHEEPWATCH.RANK);	end	if( ranknumber ) then		--DEFAULT_CHAT_FRAME:AddMessage("SheepWatch: " .. SHEEPWATCH.RANK .. SHEEPWATCH_TEXT_RANK);		if( ranknumber == "1" ) then			SHEEPWATCH.LENGTH = 20.0;		elseif( ranknumber == "2" ) then			SHEEPWATCH.LENGTH = 30.0;		elseif( ranknumber == "3" ) then			SHEEPWATCH.LENGTH = 40.0;		elseif( ranknumber == "4" ) then			SHEEPWATCH.LENGTH = 50.0;		end	else		-- DEBUG		if (SHEEPWATCH.DEBUG) then			SheepWatch_DebugLog("No rank found.");		end		-- If we don't get a rank, we disable ourself.		DEFAULT_CHAT_FRAME:AddMessage(SHEEPWATCH_TEXT_NORANK);		SHEEPWATCH.STATUS = 0;		DEFAULT_CHAT_FRAME:AddMessage(SHEEPWATCH_TEXT_DISABLED);	endend---------------------------------------------------------- Sends a message to the target"--------------------------------------------------------function SheepWatch_SendAnnounce( target, level )	local chan = SHEEPWATCH.ANNOUNCE_TARGET;	local msg = SHEEPWATCH.ANNOUNCEPATTERN;	msg = string.gsub(msg, "$t", target);	msg = string.gsub(msg, "$l", level);	msg = string.gsub(msg, "$s", arg1);	if arg1 ==  SHEEPWATCH_SPELL2 then		msg = string.gsub(msg, "$r", "Lvl 1");	else		msg = string.gsub(msg, "$r", SHEEPWATCH.RANK);	end;	if ( chan == "SAY" ) then		SendChatMessage(msg, "SAY");	elseif ( chan == "YELL" ) then        	SendChatMessage( msg, "YELL" );	elseif ( chan == "PARTY" ) then		if ( GetNumPartyMembers() > 0 ) then			SendChatMessage( msg, "PARTY" );		end	elseif ( chan == "GUILD" ) then		if ( IsInGuild() ) then			SendChatMessage( msg, "GUILD" );		end	elseif ( chan == "RAID" ) then		if ( GetNumRaidMembers() > 0 ) then			SendChatMessage( msg, "RAID" );		end	elseif ( chan == "AUTO") then		if ( GetNumRaidMembers() > 0 ) then			SendChatMessage( msg, "RAID" );		elseif ( GetNumPartyMembers() > 0 ) then			SendChatMessage( msg, "PARTY" );		else			SendChatMessage( msg, "SAY" );		end	endend---------------------------------------------------------- Load the variables.--------------------------------------------------------function SheepWatch_LoadVariables()	if SHEEPWATCH_VARIABLES_LOADED then		return	end	-- Disable debugging by default	SHEEPWATCH.DEBUG = false;	if ( SheepWatch_Log == nil ) then		SheepWatch_Log = { };	end	-- Get the actual Polymorph rank	SheepWatch_SetTimerLength();	-- Apply default settings to the profile if the aren't set yet	-- Default settings are defined in SheepWatch_Globals.lua	if( SheepWatch_Settings == nil ) then		SheepWatch_Settings = { };		SheepWatch_Settings.version = SHEEPWATCH_VERSION;	else		SheepWatch_CheckProfile();	end	if( SheepWatch_Settings.status == nil ) then		SheepWatch_Settings.status = SHEEPWATCH.STATUS;	end	if( SheepWatch_Settings.direction == nil ) then		SheepWatch_Settings.direction = SHEEPWATCH.DIRECTION;	end	if( SheepWatch_Settings.verbose == nil ) then		SheepWatch_Settings.verbose = SHEEPWATCH.VERBOSE;	end	if( SheepWatch_Settings.counter == nil ) then		SheepWatch_Settings.counter = SHEEPWATCH.COUNTER;	end	if( SheepWatch_Settings.decimals == nil ) then		SheepWatch_Settings.decimals = SHEEPWATCH.DECIMALS;	end	if (SheepWatch_Settings.announce == nil )then		SheepWatch_Settings.announce = SHEEPWATCH.ANNOUNCE;	end	if (SheepWatch_Settings.targetid == nil ) then		SheepWatch_Settings.targetid = SHEEPWATCH.ANNOUNCE_TARGET_ID;	end	if (SheepWatch_Settings.timeid == nil ) then		SheepWatch_Settings.timeid = SHEEPWATCH.ANNOUNCE_TIME_ID;	end	if (SheepWatch_Settings.alpha == nil ) then		SheepWatch_Settings.alpha = SHEEPWATCH.ALPHA;	end	if (SheepWatch_Settings.scale == nil ) then		SheepWatch_Settings.scale = SHEEPWATCH.SCALE;	end	if (SheepWatch_Settings.pattern == nil ) then		SheepWatch_Settings.pattern = SHEEPWATCH.ANNOUNCEPATTERN;	end	if (SheepWatch_Settings["barcolor"] == nil ) then		SheepWatch_Settings["barcolor"] = { };		SheepWatch_Settings["barcolor"].r = "1.0";		SheepWatch_Settings["barcolor"].g = "1.0";		SheepWatch_Settings["barcolor"].b = "0.0";	end	-- Read settings from the profile	SHEEPWATCH.STATUS = SheepWatch_Settings.status;	SHEEPWATCH.DIRECTION = SheepWatch_Settings.direction;	SHEEPWATCH.VERBOSE = SheepWatch_Settings.verbose;	SHEEPWATCH.COUNTER = SheepWatch_Settings.counter;	SHEEPWATCH.DECIMALS = SheepWatch_Settings.decimals;	SHEEPWATCH.ANNOUNCE = SheepWatch_Settings.announce;	SHEEPWATCH.ANNOUNCE_TIME_ID = SheepWatch_Settings.timeid;	SHEEPWATCH.ANNOUNCE_TARGET_ID = SheepWatch_Settings.targetid;	SHEEPWATCH.ANNOUNCE_TARGET = SHEEPWATCH_LIST_ANNOUNCETARGETS[SHEEPWATCH.ANNOUNCE_TARGET_ID].name;	SHEEPWATCH.ANNOUNCEPATTERN = SheepWatch_Settings.pattern;	SheepWatchConfigBarColorSwatchNormalTexture:SetVertexColor(SheepWatch_Settings["barcolor"].r, SheepWatch_Settings["barcolor"].g, SheepWatch_Settings["barcolor"].b);	SheepWatchFrameStatusBar:SetStatusBarColor(SheepWatch_Settings["barcolor"].r, SheepWatch_Settings["barcolor"].g, SheepWatch_Settings["barcolor"].b);	SHEEPWATCH.ALPHA = SheepWatch_Settings.alpha;	SHEEPWATCH.SCALE = SheepWatch_Settings.scale;	SheepWatch:SetScale(UIParent:GetScale() * SHEEPWATCH.SCALE);	SHEEPWATCH_VARIABLES_LOADED = true;end---------------------------------------------------------- Print the internal variables for debugging purposes.--------------------------------------------------------function SheepWatch_PrintStatus()	DEFAULT_CHAT_FRAME:AddMessage("SheepWatch Status:");	DEFAULT_CHAT_FRAME:AddMessage("Version: " .. SHEEPWATCH_VERSION);	DEFAULT_CHAT_FRAME:AddMessage("Status: " .. SHEEPWATCH.STATUS .. " \(0=disabled, 1=enabled\)");	DEFAULT_CHAT_FRAME:AddMessage("Spell: " .. SHEEPWATCH_SPELL);	DEFAULT_CHAT_FRAME:AddMessage("Rank: " .. SHEEPWATCH.RANK .. " \(determined at loading time\)");	DEFAULT_CHAT_FRAME:AddMessage("Length: " .. SHEEPWATCH.LENGTH .. " \(defined through the rank\)");	if( SHEEPWATCH.VERBOSE ) then		DEFAULT_CHAT_FRAME:AddMessage("Verbose: On");	else		DEFAULT_CHAT_FRAME:AddMessage("Verbose: Off");	end	DEFAULT_CHAT_FRAME:AddMessage("Direction: " .. SHEEPWATCH.DIRECTION);	if( SHEEPWATCH.COUNTER ) then		DEFAULT_CHAT_FRAME:AddMessage("Counter: On");	else		DEFAULT_CHAT_FRAME:AddMessage("Counter: Off");	end	if( SHEEPWATCH.DECIMALS ) then		DEFAULT_CHAT_FRAME:AddMessage("Decimals: On");	else		DEFAULT_CHAT_FRAME:AddMessage("Decimals: Off");	end	if( SHEEPWATCH.ANNOUNCE ) then		DEFAULT_CHAT_FRAME:AddMessage("Announce: On");	else		DEFAULT_CHAT_FRAME:AddMessage("Announce: Off");	end	DEFAULT_CHAT_FRAME:AddMessage("Target: " .. SHEEPWATCH.ANNOUNCE_TARGET);	DEFAULT_CHAT_FRAME:AddMessage("Time: " .. SHEEPWATCH_LIST_ANNOUNCETIME[SHEEPWATCH.ANNOUNCE_TIME_ID].name);end---------------------------------------------------------- Check if user's profile need to be cleared--------------------------------------------------------function SheepWatch_CheckProfile()	local profileversion = nil;	local version = SHEEPWATCH_VERSION;	if( SheepWatch_Settings.version ~= nil ) then		-- Get the actual version in the profile when already set.		profileversion = SheepWatch_Settings.version;	end	if( profileversion == nil and SHEEPWATCH.CLEAR == 1 ) then		-- Clear when we are asked to do so and no version was set yet.		SheepWatch_ClearProfile();		SheepWatch_Settings.version = version;		-- DEFAULT_CHAT_FRAME:AddMessage( SHEEPWATCH_TEXT_PROFILECLEARED );	elseif( version ~= profileversion and SHEEPWATCH.CLEAR ) then		-- Clear because we are asked to do so.		SheepWatch_ClearProfile();		SheepWatch_Settings.version = version;		-- DEFAULT_CHAT_FRAME:AddMessage( SHEEPWATCH_TEXT_PROFILECLEARED );	endend---------------------------------------------------------- Clear user's profile from SavedVariables.lua--------------------------------------------------------function SheepWatch_ClearProfile()	SheepWatch_Settings = nil;	SHEEPWATCH_VARIABLES_LOADED = false;	SheepWatch_LoadVariables();end---------------------------------------------------------- Print the help--------------------------------------------------------function SheepWatch_Help()	DEFAULT_CHAT_FRAME:AddMessage("SheepWatch " .. SHEEPWATCH_VERSION .. SHEEPWATCH_HELP1);endfunction SW_Register()	gLim_RegisterButton (	"Sheep Watcher",	"变形监视",	"Interface\\AddOns\\SheepWatch\\Icon",	function()		gLimModSecBookShowConfig("gLimSheepWatch");	end,	2,	8	);	gLim_RegisterConfigClass("gLimSheepWatch","Sheep Watcher","CraZy aPpLe");	gLim_RegisterConfigSection("gLimAutoRepairSection","变形监视器","显示变形术剩余的时间进度","CraZy aPpLe","gLimSheepWatch");	gLim_RegisterConfigButton(		"gLim_SW",		"变形监视设置",		"开启变形监视设置",		"变形监视",		function()			SheepWatchConfig:Show();			gLimConfigSubFrame:Hide();		end,		"gLimSheepWatch"	);	gLim_RegisterConfigCheckBox(	"gLim_SW_ANNOUNCE",	"开启变形通知",	"对目标变形时发出通知",	SheepWatch_Settings.announce,	SW_ANNOUNCE,	"gLimSheepWatch"	);endfunction SW_ANNOUNCE(toggle)	SheepWatch_Settings.announce = toggle;	SHEEPWATCH.ANNOUNCE = toggle;end

⌨️ 快捷键说明

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