name: Zero
card_text: Activate this card by targeting 1 Link Monster you control that is co-linked to a Link Monster in the Extra Monster Zone. The targeted monster gains 800 ATK for each Link Monster on the field. If a Link Monster is Link Summoned using the targeted monster as material: That Link Monster gains the same ATK increase that the targeted monster had, until the end of this turn (even if this card leaves the field). After damage calculation, if the targeted monster attacked: 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:SetProperty(EFFECT_FLAG_CARD_TARGET + EFFECT_FLAG_CANNOT_DISABLE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.tgop)
  	c:RegisterEffect(e1)
  	--atkup
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_TARGET)
  	e3:SetCode(EFFECT_UPDATE_ATTACK)
  	e3:SetRange(LOCATION_SZONE)
  	e3:SetValue(s.atkval1)
  	c:RegisterEffect(e3)
  	--atkup
  	local e4 = Effect.CreateEffect(c)
  	e4:SetDescription(aux.Stringid(id, 0))
  	e4:SetCategory(CATEGORY_ATKCHANGE)
  	e4:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_F)
  	e4:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e4:SetRange(LOCATION_SZONE)
  	e4:SetTarget(s.atktg2)
  	e4:SetOperation(s.atkop2)
  	e4:SetLabelObject(e3)
  	c:RegisterEffect(e4)
  	local e5 = Effect.CreateEffect(c)
  	e5:SetType(EFFECT_TYPE_FIELD)
  	e5:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_SET_AVAILABLE + EFFECT_FLAG_IGNORE_RANGE)
  	e5:SetCode(EFFECT_MATERIAL_CHECK)
  	e5:SetRange(LOCATION_SZONE)
  	e5:SetValue(s.valcheck)
  	c:RegisterEffect(e5)
  	--destroy
  	local e6 = Effect.CreateEffect(c)
  	e6:SetDescription(aux.Stringid(id, 1))
  	e6:SetCategory(CATEGORY_DESTROY)
  	e6:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_F)
  	e6:SetCode(EVENT_BATTLED)
  	e6:SetRange(LOCATION_SZONE)
  	e6:SetCondition(s.descon)
  	e6:SetTarget(s.destg)
  	e6:SetOperation(s.desop)
  	c:RegisterEffect(e6)
  end
  function s.lkfilter(c)
  	return c:IsFaceup() and c:IsType(TYPE_LINK) and c:GetSequence() > 4
  end
  function s.filter(c, g)
  	return c:IsFaceup() and c:IsType(TYPE_LINK) and g:IsContains(c)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	local tg = Group.CreateGroup()
  	local lg = Duel.GetMatchingGroup(s.lkfilter, tp, LOCATION_MZONE, LOCATION_MZONE, nil)
  	for tc in aux.Next(lg) do
  		tg:Merge(tc:GetMutualLinkedGroup())
  	end
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and s.filter(chkc, tg)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.filter, tp, LOCATION_MZONE, 0, 1, nil, tg)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_FACEUP)
  	Duel.SelectTarget(tp, s.filter, tp, LOCATION_MZONE, 0, 1, 1, nil, tg)
  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.atkfilter(c)
  	return c:IsFaceup() and c:IsType(TYPE_LINK)
  end
  function s.atkval1(e, c)
  	local atk = Duel.GetMatchingGroupCount(s.atkfilter, c:GetControler(), LOCATION_MZONE, LOCATION_MZONE, nil) * 800
  	e:SetLabel(atk)
  	return atk
  end
  function s.matfilter(c, mc)
  	return mc:IsHasCardTarget(c)
  end
  function s.valcheck(e, c)
  	if c:GetMaterial():IsExists(s.matfilter, 1, nil, e:GetHandler()) then
  		c:RegisterFlagEffect(id, RESET_EVENT + 0x4fe0000 + RESET_PHASE + PHASE_END, 0, 1)
  	end
  end
  function s.cfilter(c, tp)
  	return c:IsControler(tp) and c:IsSummonType(SUMMON_TYPE_LINK) and c:GetFlagEffect(id) ~= 0
  end
  function s.atktg2(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return eg:IsExists(s.cfilter, 1, nil, tp)
  	end
  	Duel.SetTargetCard(eg)
  end
  function s.atkop2(e, tp, eg, ep, ev, re, r, rp)
  	local tc = eg:GetFirst()
  	if tc:IsRelateToEffect(e) and tc:IsFaceup() then
  		local atk = e:GetLabelObject():GetLabel()
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		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.descon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsHasCardTarget(Duel.GetAttacker())
  end
  function s.destg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, e:GetHandler(), 1, 0, 0)
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsRelateToEffect(e) then
  		Duel.Destroy(c, REASON_EFFECT)
  	end
  end
  
  
source_text: Zero
  Activate this card by targeting 1 Link Monster you control that is co-linked to a Link Monster in the Extra Monster Zone. The targeted monster gains 800 ATK for each Link Monster on the field. If a Link Monster is Link Summoned using the targeted monster as material: That Link Monster gains the same ATK increase that the targeted monster had, until the end of this turn (even if this card leaves the field). After damage calculation, if the targeted monster attacked: Destroy this card.
target_text: -- Zero
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET + EFFECT_FLAG_CANNOT_DISABLE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.tgop)
  	c:RegisterEffect(e1)
  	--atkup
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_TARGET)
  	e3:SetCode(EFFECT_UPDATE_ATTACK)
  	e3:SetRange(LOCATION_SZONE)
  	e3:SetValue(s.atkval1)
  	c:RegisterEffect(e3)
  	--atkup
  	local e4 = Effect.CreateEffect(c)
  	e4:SetDescription(aux.Stringid(id, 0))
  	e4:SetCategory(CATEGORY_ATKCHANGE)
  	e4:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_F)
  	e4:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e4:SetRange(LOCATION_SZONE)
  	e4:SetTarget(s.atktg2)
  	e4:SetOperation(s.atkop2)
  	e4:SetLabelObject(e3)
  	c:RegisterEffect(e4)
  	local e5 = Effect.CreateEffect(c)
  	e5:SetType(EFFECT_TYPE_FIELD)
  	e5:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_SET_AVAILABLE + EFFECT_FLAG_IGNORE_RANGE)
  	e5:SetCode(EFFECT_MATERIAL_CHECK)
  	e5:SetRange(LOCATION_SZONE)
  	e5:SetValue(s.valcheck)
  	c:RegisterEffect(e5)
  	--destroy
  	local e6 = Effect.CreateEffect(c)
  	e6:SetDescription(aux.Stringid(id, 1))
  	e6:SetCategory(CATEGORY_DESTROY)
  	e6:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_F)
  	e6:SetCode(EVENT_BATTLED)
  	e6:SetRange(LOCATION_SZONE)
  	e6:SetCondition(s.descon)
  	e6:SetTarget(s.destg)
  	e6:SetOperation(s.desop)
  	c:RegisterEffect(e6)
  end
  function s.lkfilter(c)
  	return c:IsFaceup() and c:IsType(TYPE_LINK) and c:GetSequence() > 4
  end
  function s.filter(c, g)
  	return c:IsFaceup() and c:IsType(TYPE_LINK) and g:IsContains(c)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	local tg = Group.CreateGroup()
  	local lg = Duel.GetMatchingGroup(s.lkfilter, tp, LOCATION_MZONE, LOCATION_MZONE, nil)
  	for tc in aux.Next(lg) do
  		tg:Merge(tc:GetMutualLinkedGroup())
  	end
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and s.filter(chkc, tg)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.filter, tp, LOCATION_MZONE, 0, 1, nil, tg)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_FACEUP)
  	Duel.SelectTarget(tp, s.filter, tp, LOCATION_MZONE, 0, 1, 1, nil, tg)
  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.atkfilter(c)
  	return c:IsFaceup() and c:IsType(TYPE_LINK)
  end
  function s.atkval1(e, c)
  	local atk = Duel.GetMatchingGroupCount(s.atkfilter, c:GetControler(), LOCATION_MZONE, LOCATION_MZONE, nil) * 800
  	e:SetLabel(atk)
  	return atk
  end
  function s.matfilter(c, mc)
  	return mc:IsHasCardTarget(c)
  end
  function s.valcheck(e, c)
  	if c:GetMaterial():IsExists(s.matfilter, 1, nil, e:GetHandler()) then
  		c:RegisterFlagEffect(id, RESET_EVENT + 0x4fe0000 + RESET_PHASE + PHASE_END, 0, 1)
  	end
  end
  function s.cfilter(c, tp)
  	return c:IsControler(tp) and c:IsSummonType(SUMMON_TYPE_LINK) and c:GetFlagEffect(id) ~= 0
  end
  function s.atktg2(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return eg:IsExists(s.cfilter, 1, nil, tp)
  	end
  	Duel.SetTargetCard(eg)
  end
  function s.atkop2(e, tp, eg, ep, ev, re, r, rp)
  	local tc = eg:GetFirst()
  	if tc:IsRelateToEffect(e) and tc:IsFaceup() then
  		local atk = e:GetLabelObject():GetLabel()
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		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.descon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsHasCardTarget(Duel.GetAttacker())
  end
  function s.destg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, e:GetHandler(), 1, 0, 0)
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsRelateToEffect(e) then
  		Duel.Destroy(c, REASON_EFFECT)
  	end
  end
  
  