name: Slifer
card_text: Requires 3 Tributes to Normal Summon (cannot be Normal Set). This card's Normal Summon cannot be negated. When Normal Summoned, cards and effects cannot be activated. Once per turn, during the End Phase, if this card was Special Summoned: Send it to the GY. Gains 1000 ATK/DEF for each card in your hand. If a monster(s) is Normal or Special Summoned to your opponent's field in Attack Position: That monster(s) loses 2000 ATK, then if its ATK has been reduced to 0 as a result, destroy it.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--summon with 3 tribute
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 2))
  	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_LIMIT_SUMMON_PROC)
  	e1:SetCondition(s.ttcon)
  	e1:SetOperation(s.ttop)
  	e1:SetValue(SUMMON_TYPE_ADVANCE)
  	c:RegisterEffect(e1)
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_SINGLE)
  	e2:SetCode(EFFECT_LIMIT_SET_PROC)
  	e2:SetCondition(s.setcon)
  	c:RegisterEffect(e2)
  	--summon
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_SINGLE)
  	e3:SetCode(EFFECT_CANNOT_DISABLE_SUMMON)
  	e3:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	c:RegisterEffect(e3)
  	--summon success
  	local e4 = Effect.CreateEffect(c)
  	e4:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS)
  	e4:SetCode(EVENT_SUMMON_SUCCESS)
  	e4:SetOperation(s.sumsuc)
  	c:RegisterEffect(e4)
  	--to grave
  	local e5 = Effect.CreateEffect(c)
  	e5:SetDescription(aux.Stringid(id, 0))
  	e5:SetCategory(CATEGORY_TOGRAVE)
  	e5:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_F)
  	e5:SetRange(LOCATION_MZONE)
  	e5:SetCountLimit(1)
  	e5:SetCode(EVENT_PHASE + PHASE_END)
  	e5:SetCondition(s.tgcon)
  	e5:SetTarget(s.tgtg)
  	e5:SetOperation(s.tgop)
  	c:RegisterEffect(e5)
  	--atk/def
  	local e6 = Effect.CreateEffect(c)
  	e6:SetType(EFFECT_TYPE_SINGLE)
  	e6:SetCode(EFFECT_UPDATE_ATTACK)
  	e6:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e6:SetRange(LOCATION_MZONE)
  	e6:SetValue(s.adval)
  	c:RegisterEffect(e6)
  	local e7 = e6:Clone()
  	e7:SetCode(EFFECT_UPDATE_DEFENSE)
  	c:RegisterEffect(e7)
  	--atkdown
  	local e8 = Effect.CreateEffect(c)
  	e8:SetDescription(aux.Stringid(id, 1))
  	e8:SetCategory(CATEGORY_ATKCHANGE)
  	e8:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_F)
  	e8:SetRange(LOCATION_MZONE)
  	e8:SetCode(EVENT_SUMMON_SUCCESS)
  	e8:SetTarget(s.atktg)
  	e8:SetOperation(s.atkop)
  	c:RegisterEffect(e8)
  	local e9 = e8:Clone()
  	e9:SetCode(EVENT_SPSUMMON_SUCCESS)
  	c:RegisterEffect(e9)
  end
  function s.ttcon(e, c, minc)
  	if c == nil then
  		return true
  	end
  	return minc <= 3 and Duel.CheckTribute(c, 3)
  end
  function s.ttop(e, tp, eg, ep, ev, re, r, rp, c)
  	local g = Duel.SelectTribute(tp, c, 3, 3)
  	c:SetMaterial(g)
  	Duel.Release(g, REASON_SUMMON + REASON_MATERIAL)
  end
  function s.setcon(e, c, minc)
  	if not c then
  		return true
  	end
  	return false
  end
  function s.sumsuc(e, tp, eg, ep, ev, re, r, rp)
  	Duel.SetChainLimitTillChainEnd(aux.FALSE)
  end
  function s.tgcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsSummonType(SUMMON_TYPE_SPECIAL)
  end
  function s.tgtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOGRAVE, e:GetHandler(), 1, 0, 0)
  end
  function s.tgop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsRelateToEffect(e) and c:IsFaceup() then
  		Duel.SendtoGrave(c, REASON_EFFECT)
  	end
  end
  function s.adval(e, c)
  	return Duel.GetFieldGroupCount(c:GetControler(), LOCATION_HAND, 0) * 1000
  end
  function s.atkfilter(c, tp)
  	return c:IsControler(tp) and c:IsPosition(POS_FACEUP_ATTACK)
  end
  function s.atktg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return eg:IsExists(s.atkfilter, 1, e:GetHandler(), 1 - tp)
  	end
  	local g = eg:Filter(s.atkfilter, e:GetHandler(), 1 - tp)
  	Duel.SetTargetCard(g)
  end
  function s.atkop(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetTargetsRelateToChain():Filter(Card.IsFaceup, nil)
  	local dg = Group.CreateGroup()
  	local c = e:GetHandler()
  	local tc = g:GetFirst()
  	while tc do
  		local preatk = tc:GetAttack()
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_UPDATE_ATTACK)
  		e1:SetValue(-2000)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  		tc:RegisterEffect(e1)
  		if preatk ~= 0 and tc:IsAttack(0) then
  			dg:AddCard(tc)
  		end
  		tc = g:GetNext()
  	end
  	Duel.Destroy(dg, REASON_EFFECT)
  end
  
  
source_text: Slifer
  Requires 3 Tributes to Normal Summon (cannot be Normal Set). This card's Normal Summon cannot be negated. When Normal Summoned, cards and effects cannot be activated. Once per turn, during the End Phase, if this card was Special Summoned: Send it to the GY. Gains 1000 ATK/DEF for each card in your hand. If a monster(s) is Normal or Special Summoned to your opponent's field in Attack Position: That monster(s) loses 2000 ATK, then if its ATK has been reduced to 0 as a result, destroy it.
target_text: -- Slifer
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--summon with 3 tribute
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 2))
  	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_LIMIT_SUMMON_PROC)
  	e1:SetCondition(s.ttcon)
  	e1:SetOperation(s.ttop)
  	e1:SetValue(SUMMON_TYPE_ADVANCE)
  	c:RegisterEffect(e1)
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_SINGLE)
  	e2:SetCode(EFFECT_LIMIT_SET_PROC)
  	e2:SetCondition(s.setcon)
  	c:RegisterEffect(e2)
  	--summon
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_SINGLE)
  	e3:SetCode(EFFECT_CANNOT_DISABLE_SUMMON)
  	e3:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	c:RegisterEffect(e3)
  	--summon success
  	local e4 = Effect.CreateEffect(c)
  	e4:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS)
  	e4:SetCode(EVENT_SUMMON_SUCCESS)
  	e4:SetOperation(s.sumsuc)
  	c:RegisterEffect(e4)
  	--to grave
  	local e5 = Effect.CreateEffect(c)
  	e5:SetDescription(aux.Stringid(id, 0))
  	e5:SetCategory(CATEGORY_TOGRAVE)
  	e5:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_F)
  	e5:SetRange(LOCATION_MZONE)
  	e5:SetCountLimit(1)
  	e5:SetCode(EVENT_PHASE + PHASE_END)
  	e5:SetCondition(s.tgcon)
  	e5:SetTarget(s.tgtg)
  	e5:SetOperation(s.tgop)
  	c:RegisterEffect(e5)
  	--atk/def
  	local e6 = Effect.CreateEffect(c)
  	e6:SetType(EFFECT_TYPE_SINGLE)
  	e6:SetCode(EFFECT_UPDATE_ATTACK)
  	e6:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e6:SetRange(LOCATION_MZONE)
  	e6:SetValue(s.adval)
  	c:RegisterEffect(e6)
  	local e7 = e6:Clone()
  	e7:SetCode(EFFECT_UPDATE_DEFENSE)
  	c:RegisterEffect(e7)
  	--atkdown
  	local e8 = Effect.CreateEffect(c)
  	e8:SetDescription(aux.Stringid(id, 1))
  	e8:SetCategory(CATEGORY_ATKCHANGE)
  	e8:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_F)
  	e8:SetRange(LOCATION_MZONE)
  	e8:SetCode(EVENT_SUMMON_SUCCESS)
  	e8:SetTarget(s.atktg)
  	e8:SetOperation(s.atkop)
  	c:RegisterEffect(e8)
  	local e9 = e8:Clone()
  	e9:SetCode(EVENT_SPSUMMON_SUCCESS)
  	c:RegisterEffect(e9)
  end
  function s.ttcon(e, c, minc)
  	if c == nil then
  		return true
  	end
  	return minc <= 3 and Duel.CheckTribute(c, 3)
  end
  function s.ttop(e, tp, eg, ep, ev, re, r, rp, c)
  	local g = Duel.SelectTribute(tp, c, 3, 3)
  	c:SetMaterial(g)
  	Duel.Release(g, REASON_SUMMON + REASON_MATERIAL)
  end
  function s.setcon(e, c, minc)
  	if not c then
  		return true
  	end
  	return false
  end
  function s.sumsuc(e, tp, eg, ep, ev, re, r, rp)
  	Duel.SetChainLimitTillChainEnd(aux.FALSE)
  end
  function s.tgcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsSummonType(SUMMON_TYPE_SPECIAL)
  end
  function s.tgtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOGRAVE, e:GetHandler(), 1, 0, 0)
  end
  function s.tgop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsRelateToEffect(e) and c:IsFaceup() then
  		Duel.SendtoGrave(c, REASON_EFFECT)
  	end
  end
  function s.adval(e, c)
  	return Duel.GetFieldGroupCount(c:GetControler(), LOCATION_HAND, 0) * 1000
  end
  function s.atkfilter(c, tp)
  	return c:IsControler(tp) and c:IsPosition(POS_FACEUP_ATTACK)
  end
  function s.atktg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return eg:IsExists(s.atkfilter, 1, e:GetHandler(), 1 - tp)
  	end
  	local g = eg:Filter(s.atkfilter, e:GetHandler(), 1 - tp)
  	Duel.SetTargetCard(g)
  end
  function s.atkop(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetTargetsRelateToChain():Filter(Card.IsFaceup, nil)
  	local dg = Group.CreateGroup()
  	local c = e:GetHandler()
  	local tc = g:GetFirst()
  	while tc do
  		local preatk = tc:GetAttack()
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_UPDATE_ATTACK)
  		e1:SetValue(-2000)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  		tc:RegisterEffect(e1)
  		if preatk ~= 0 and tc:IsAttack(0) then
  			dg:AddCard(tc)
  		end
  		tc = g:GetNext()
  	end
  	Duel.Destroy(dg, REASON_EFFECT)
  end
  
  