name: Performapal
card_text: Pendulum Scale = 1
  [ Pendulum Effect ]
  Once per turn, when an attack is declared involving a monster you control and an opponent's monster: You can activate this effect; that monster you control cannot be destroyed by that battle.
  ----------------------------------------
  [ Monster Effect ]
  Once per turn, when an attack is declared involving a monster you control and an opponent's monster: You can activate this effect; that monster you control cannot be destroyed by that battle.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	aux.EnablePendulumAttribute(c)
  	--indes
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e1:SetCode(EVENT_ATTACK_ANNOUNCE)
  	e1:SetCountLimit(1)
  	e1:SetRange(LOCATION_PZONE)
  	e1:SetCondition(s.condition)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.operation1)
  	c:RegisterEffect(e1)
  	local e2 = e1:Clone()
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetOperation(s.operation2)
  	c:RegisterEffect(e2)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	local a = Duel.GetAttacker()
  	local d = Duel.GetAttackTarget()
  	if not d or a:GetControler() == d:GetControler() then
  		return false
  	end
  	if a:IsControler(tp) then
  		e:SetLabelObject(a)
  	else
  		e:SetLabelObject(d)
  	end
  	return true
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetTargetCard(e:GetLabelObject())
  end
  function s.operation1(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) then
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_INDESTRUCTABLE_BATTLE)
  		e1:SetValue(1)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_DAMAGE)
  		tc:RegisterEffect(e1)
  	end
  end
  function s.operation2(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) then
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_INDESTRUCTABLE_BATTLE)
  		e1:SetValue(1)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_DAMAGE)
  		tc:RegisterEffect(e1)
  	end
  end
  
  
source_text: Performapal
  Pendulum Scale = 1
  [ Pendulum Effect ]
  Once per turn, when an attack is declared involving a monster you control and an opponent's monster: You can activate this effect; that monster you control cannot be destroyed by that battle.
  ----------------------------------------
  [ Monster Effect ]
  Once per turn, when an attack is declared involving a monster you control and an opponent's monster: You can activate this effect; that monster you control cannot be destroyed by that battle.
target_text: -- Performapal
  local s, id, o = GetID()
  function s.initial_effect(c)
  	aux.EnablePendulumAttribute(c)
  	--indes
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e1:SetCode(EVENT_ATTACK_ANNOUNCE)
  	e1:SetCountLimit(1)
  	e1:SetRange(LOCATION_PZONE)
  	e1:SetCondition(s.condition)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.operation1)
  	c:RegisterEffect(e1)
  	local e2 = e1:Clone()
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetOperation(s.operation2)
  	c:RegisterEffect(e2)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	local a = Duel.GetAttacker()
  	local d = Duel.GetAttackTarget()
  	if not d or a:GetControler() == d:GetControler() then
  		return false
  	end
  	if a:IsControler(tp) then
  		e:SetLabelObject(a)
  	else
  		e:SetLabelObject(d)
  	end
  	return true
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetTargetCard(e:GetLabelObject())
  end
  function s.operation1(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) then
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_INDESTRUCTABLE_BATTLE)
  		e1:SetValue(1)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_DAMAGE)
  		tc:RegisterEffect(e1)
  	end
  end
  function s.operation2(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) then
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_INDESTRUCTABLE_BATTLE)
  		e1:SetValue(1)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_DAMAGE)
  		tc:RegisterEffect(e1)
  	end
  end
  
  