All pastes #114965 Raw Edit

sarf Smartbuff Fix

public lua v1 · immutable
·published 2006-08-04 08:29 UTC
rendered paste body
To fix the "casting of blessings target change triggering more blessing castings", add:local IgnoreNextTargetSwitch = false;Change	elseif (event == "PLAYER_TARGET_CHANGED") then	elseif (event == "PLAYER_TARGET_CHANGED") then	  if (SMARTBUFF_Options.TargetSwitch) then      if (GetTime() > tAutoBuff + GlobalCd) then        tAutoBuff = GetTime();        SMARTBUFF_Check(5);      end		endto	elseif (event == "PLAYER_TARGET_CHANGED") then	  if (SMARTBUFF_Options.TargetSwitch) and ( not IgnoreNextTargetSwitch ) then      if (GetTime() > tAutoBuff + GlobalCd) then        tAutoBuff = GetTime();        SMARTBUFF_Check(5);      end		end       IgnoreNextTargetSwitch = false;new (or rather: extensively rewritten) SMARTBUFF_doCast:function SMARTBUFF_doCast(unit, id, actionSlot, levels, type)  if (id == nil) then return 9; end  if (type == SMARTBUFF_CONST_GROUP and actionSlot == nil) then return 8; end  if (type == SMARTBUFF_CONST_TRACK and GetTrackingTexture()) then     local iconTrack = GetTrackingTexture();    SMARTBUFF_AddMsgD("Track already enabled: " .. iconTrack);    return 7;   end  		-- check if spell has cooldown	local _, cd = GetSpellCooldown(id, SMARTBUFF_BOOK_TYPE_SPELL)	if (cd > maxSkipCoolDown) then	  return 4;  elseif (cd > 0) then     return 1;  end  	if ( not UnitIsVisible(unit) ) or ( not CheckInteractDistance(unit, 4) ) then		return 3;	end	id = SMARTBUFF_CheckUnitLevel(unit, id, levels);	-- check if target is to low for this spell	if (id == nil) then	  return 5;	end    if (actionSlot ~= nil) then    -- check if you have enough mana to cast    local isUsable, notEnoughMana = IsUsableAction(actionSlot);    if (notEnoughMana) then      return 6;    end  end    local oldTarget = nil;  local oldTargetWasPlayer = nil;  local name = UnitName("target");  if (type == SMARTBUFF_CONST_GROUP or type == SMARTBUFF_CONST_FORCESELF) then    if ( ( unit~="player" ) and ( actionSlot ) ) and (not UnitIsUnit("target", unit)) and ( not UnitIsEnemy("player", "target") ) then    	oldTargetWasPlayer = UnitIsPlayer("target");    	oldTarget=UnitName("target");	  	IgnoreNextTargetSwitch = true;    	ClearTarget();    end  end  if ( unit == "player" ) and ( actionSlot ) then  	UseAction(actionSlot, 0, 1);  else    CastSpell(id, SMARTBUFF_BOOK_TYPE_SPELL);  end  if (SpellIsTargeting()) then   	SpellTargetUnit(unit);    --return 10;  end  if (oldTarget) then  	IgnoreNextTargetSwitch = true;  	if ( oldTargetWasPlayer ) then  		TargetByName(oldTarget, 1);  	else  		TargetLastTarget();	  	--TargetUnit("playertarget")  	end  	oldTarget = nil;  end    return 0;end