name: Follow
card_text: Activate this card by targeting 1 Synchro Monster you control; it cannot be destroyed by battle or your opponent's card effects. At the start of the Damage Step, if it battles an opponent's Level 5 or higher monster: You can destroy that opponent's monster, and if you do, the targeted Synchro Monster gains ATK equal to the original ATK of the destroyed monster, until the end of this turn. When that monster leaves the field, destroy this card.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetHintTiming(0, TIMINGS_CHECK_MONSTER + TIMING_END_PHASE)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET + EFFECT_FLAG_CONTINUOUS_TARGET)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.tgop)
  	c:RegisterEffect(e1)
  	--indes
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_TARGET)
  	e3:SetCode(EFFECT_INDESTRUCTABLE_BATTLE)
  	e3:SetRange(LOCATION_SZONE)
  	e3:SetValue(1)
  	c:RegisterEffect(e3)
  	local e4 = e3:Clone()
  	e4:SetCode(EFFECT_INDESTRUCTABLE_EFFECT)
  	e4:SetValue(s.efilter)
  	c:RegisterEffect(e4)
  	--destroy
  	local e5 = Effect.CreateEffect(c)
  	e5:SetDescription(aux.Stringid(id, 0))
  	e5:SetCategory(CATEGORY_DESTROY)
  	e5:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e5:SetCode(EVENT_BATTLE_START)
  	e5:SetRange(LOCATION_SZONE)
  	e5:SetCondition(s.atkcon)
  	e5:SetOperation(s.atkop)
  	c:RegisterEffect(e5)
  	--self destroy
  	local e7 = Effect.CreateEffect(c)
  	e7:SetType(EFFECT_TYPE_CONTINUOUS + EFFECT_TYPE_FIELD)
  	e7:SetRange(LOCATION_SZONE)
  	e7:SetCode(EVENT_LEAVE_FIELD)
  	e7:SetProperty(EFFECT_FLAG_DELAY)
  	e7:SetCondition(s.descon2)
  	e7:SetOperation(s.desop2)
  	c:RegisterEffect(e7)
  end
  function s.filter(c)
  	return c:IsFaceup() and c:IsType(TYPE_SYNCHRO)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and s.filter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.filter, tp, LOCATION_MZONE, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_FACEUP)
  	Duel.SelectTarget(tp, s.filter, tp, LOCATION_MZONE, 0, 1, 1, nil)
  end
  function s.tgop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = Duel.GetFirstTarget()
  	if c:IsRelateToEffect(e) and tc:IsFaceup() and tc:IsRelateToEffect(e) then
  		c:SetCardTarget(tc)
  	end
  end
  function s.efilter(e, re)
  	return e:GetOwnerPlayer() ~= re:GetOwnerPlayer()
  end
  function s.atkcon(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = c:GetFirstCardTarget()
  	if not tc then
  		return false
  	end
  	local bc = tc:GetBattleTarget()
  	return tc:IsLocation(LOCATION_MZONE) and bc and bc:IsFaceup() and bc:IsLocation(LOCATION_MZONE) and bc:IsLevelAbove(5)
  end
  function s.atkop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = c:GetFirstCardTarget()
  	if not tc then
  		return false
  	end
  	local bc = tc:GetBattleTarget()
  	local atk = bc:GetBaseAttack()
  	if bc:IsRelateToBattle() and Duel.Destroy(bc, REASON_EFFECT) ~= 0 and bc:IsType(TYPE_MONSTER) then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_UPDATE_ATTACK)
  		e1:SetValue(atk)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  		tc:RegisterEffect(e1)
  	end
  end
  function s.descon2(e, tp, eg, ep, ev, re, r, rp)
  	local tc = e:GetHandler():GetFirstCardTarget()
  	return tc and eg:IsContains(tc)
  end
  function s.desop2(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Destroy(e:GetHandler(), REASON_EFFECT)
  end
  
  
source_text: Follow
  Activate this card by targeting 1 Synchro Monster you control; it cannot be destroyed by battle or your opponent's card effects. At the start of the Damage Step, if it battles an opponent's Level 5 or higher monster: You can destroy that opponent's monster, and if you do, the targeted Synchro Monster gains ATK equal to the original ATK of the destroyed monster, until the end of this turn. When that monster leaves the field, destroy this card.
target_text: -- Follow
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetHintTiming(0, TIMINGS_CHECK_MONSTER + TIMING_END_PHASE)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET + EFFECT_FLAG_CONTINUOUS_TARGET)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.tgop)
  	c:RegisterEffect(e1)
  	--indes
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_TARGET)
  	e3:SetCode(EFFECT_INDESTRUCTABLE_BATTLE)
  	e3:SetRange(LOCATION_SZONE)
  	e3:SetValue(1)
  	c:RegisterEffect(e3)
  	local e4 = e3:Clone()
  	e4:SetCode(EFFECT_INDESTRUCTABLE_EFFECT)
  	e4:SetValue(s.efilter)
  	c:RegisterEffect(e4)
  	--destroy
  	local e5 = Effect.CreateEffect(c)
  	e5:SetDescription(aux.Stringid(id, 0))
  	e5:SetCategory(CATEGORY_DESTROY)
  	e5:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e5:SetCode(EVENT_BATTLE_START)
  	e5:SetRange(LOCATION_SZONE)
  	e5:SetCondition(s.atkcon)
  	e5:SetOperation(s.atkop)
  	c:RegisterEffect(e5)
  	--self destroy
  	local e7 = Effect.CreateEffect(c)
  	e7:SetType(EFFECT_TYPE_CONTINUOUS + EFFECT_TYPE_FIELD)
  	e7:SetRange(LOCATION_SZONE)
  	e7:SetCode(EVENT_LEAVE_FIELD)
  	e7:SetProperty(EFFECT_FLAG_DELAY)
  	e7:SetCondition(s.descon2)
  	e7:SetOperation(s.desop2)
  	c:RegisterEffect(e7)
  end
  function s.filter(c)
  	return c:IsFaceup() and c:IsType(TYPE_SYNCHRO)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and s.filter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.filter, tp, LOCATION_MZONE, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_FACEUP)
  	Duel.SelectTarget(tp, s.filter, tp, LOCATION_MZONE, 0, 1, 1, nil)
  end
  function s.tgop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = Duel.GetFirstTarget()
  	if c:IsRelateToEffect(e) and tc:IsFaceup() and tc:IsRelateToEffect(e) then
  		c:SetCardTarget(tc)
  	end
  end
  function s.efilter(e, re)
  	return e:GetOwnerPlayer() ~= re:GetOwnerPlayer()
  end
  function s.atkcon(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = c:GetFirstCardTarget()
  	if not tc then
  		return false
  	end
  	local bc = tc:GetBattleTarget()
  	return tc:IsLocation(LOCATION_MZONE) and bc and bc:IsFaceup() and bc:IsLocation(LOCATION_MZONE) and bc:IsLevelAbove(5)
  end
  function s.atkop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = c:GetFirstCardTarget()
  	if not tc then
  		return false
  	end
  	local bc = tc:GetBattleTarget()
  	local atk = bc:GetBaseAttack()
  	if bc:IsRelateToBattle() and Duel.Destroy(bc, REASON_EFFECT) ~= 0 and bc:IsType(TYPE_MONSTER) then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_UPDATE_ATTACK)
  		e1:SetValue(atk)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  		tc:RegisterEffect(e1)
  	end
  end
  function s.descon2(e, tp, eg, ep, ev, re, r, rp)
  	local tc = e:GetHandler():GetFirstCardTarget()
  	return tc and eg:IsContains(tc)
  end
  function s.desop2(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Destroy(e:GetHandler(), REASON_EFFECT)
  end
  
  