name: Steel
card_text: 3 non-Link Monsters
  Gains ATK equal to the combined original Levels/Ranks of monsters used for its Link Summon x 100. You can target 1 non-Link Monster your opponent controls with ATK less than or equal to this card; destroy it, then if this card was Link Summoned using an Xyz Monster as material, inflict damage to your opponent equal to half the destroyed monster's original ATK. You can only use this effect of "Steel Star Regulator" once per turn.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--link summon
  	aux.AddLinkProcedure(c, aux.NOT(aux.FilterBoolFunction(Card.IsLinkType, TYPE_LINK)), 3, 3)
  	c:EnableReviveLimit()
  	--atkup
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS)
  	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  	e1:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e1:SetCondition(s.atkcon)
  	e1:SetOperation(s.atkop)
  	c:RegisterEffect(e1)
  	--Destroy
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_DESTROY + CATEGORY_DAMAGE)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e2:SetCountLimit(1, id)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetTarget(s.destg)
  	e2:SetOperation(s.desop)
  	c:RegisterEffect(e2)
  	--
  	local e4 = Effect.CreateEffect(c)
  	e4:SetType(EFFECT_TYPE_SINGLE)
  	e4:SetCode(EFFECT_MATERIAL_CHECK)
  	e4:SetValue(s.valcheck)
  	c:RegisterEffect(e4)
  	e4:SetLabelObject(e1)
  end
  function s.atkcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsSummonType(SUMMON_TYPE_LINK)
  end
  function s.atkop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local g = c:GetMaterial()
  	local atk = 0
  	local tc = g:GetFirst()
  	while tc do
  		local lk
  		if tc:IsType(TYPE_XYZ) then
  			lk = tc:GetOriginalRank()
  		else
  			lk = tc:GetOriginalLevel()
  		end
  		atk = atk + lk
  		tc = g:GetNext()
  	end
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_UPDATE_ATTACK)
  	e1:SetValue(atk * 100)
  	e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_DISABLE)
  	c:RegisterEffect(e1)
  	if e:GetLabel() == 1 then
  		c:RegisterFlagEffect(id, RESET_EVENT + RESETS_STANDARD, 0, 1)
  	end
  end
  function s.desfilter(c, atk)
  	return c:IsFaceup() and c:IsAttackBelow(atk) and not c:IsType(TYPE_LINK)
  end
  function s.destg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	local c = e:GetHandler()
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(1 - tp) and s.desfilter(chkc, c:GetAttack())
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.desfilter, tp, 0, LOCATION_MZONE, 1, nil, c:GetAttack())
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
  	local g = Duel.SelectTarget(tp, s.desfilter, tp, 0, LOCATION_MZONE, 1, 1, nil, c:GetAttack())
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, 1, 0, 0)
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) then
  		if Duel.Destroy(tc, REASON_EFFECT) ~= 0 and e:GetHandler():GetFlagEffect(id) ~= 0 then
  			local atk = tc:GetBaseAttack()
  			if atk > 0 then
  				Duel.BreakEffect()
  				Duel.Damage(1 - tp, math.ceil(atk / 2), REASON_EFFECT)
  			end
  		end
  	end
  end
  function s.valcheck(e, c)
  	local g = c:GetMaterial()
  	if g:IsExists(Card.IsLinkType, 1, nil, TYPE_XYZ) then
  		e:GetLabelObject():SetLabel(1)
  	else
  		e:GetLabelObject():SetLabel(0)
  	end
  end
  
  
source_text: Steel
  3 non-Link Monsters
  Gains ATK equal to the combined original Levels/Ranks of monsters used for its Link Summon x 100. You can target 1 non-Link Monster your opponent controls with ATK less than or equal to this card; destroy it, then if this card was Link Summoned using an Xyz Monster as material, inflict damage to your opponent equal to half the destroyed monster's original ATK. You can only use this effect of "Steel Star Regulator" once per turn.
target_text: -- Steel
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--link summon
  	aux.AddLinkProcedure(c, aux.NOT(aux.FilterBoolFunction(Card.IsLinkType, TYPE_LINK)), 3, 3)
  	c:EnableReviveLimit()
  	--atkup
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS)
  	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  	e1:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e1:SetCondition(s.atkcon)
  	e1:SetOperation(s.atkop)
  	c:RegisterEffect(e1)
  	--Destroy
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_DESTROY + CATEGORY_DAMAGE)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e2:SetCountLimit(1, id)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetTarget(s.destg)
  	e2:SetOperation(s.desop)
  	c:RegisterEffect(e2)
  	--
  	local e4 = Effect.CreateEffect(c)
  	e4:SetType(EFFECT_TYPE_SINGLE)
  	e4:SetCode(EFFECT_MATERIAL_CHECK)
  	e4:SetValue(s.valcheck)
  	c:RegisterEffect(e4)
  	e4:SetLabelObject(e1)
  end
  function s.atkcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsSummonType(SUMMON_TYPE_LINK)
  end
  function s.atkop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local g = c:GetMaterial()
  	local atk = 0
  	local tc = g:GetFirst()
  	while tc do
  		local lk
  		if tc:IsType(TYPE_XYZ) then
  			lk = tc:GetOriginalRank()
  		else
  			lk = tc:GetOriginalLevel()
  		end
  		atk = atk + lk
  		tc = g:GetNext()
  	end
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_UPDATE_ATTACK)
  	e1:SetValue(atk * 100)
  	e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_DISABLE)
  	c:RegisterEffect(e1)
  	if e:GetLabel() == 1 then
  		c:RegisterFlagEffect(id, RESET_EVENT + RESETS_STANDARD, 0, 1)
  	end
  end
  function s.desfilter(c, atk)
  	return c:IsFaceup() and c:IsAttackBelow(atk) and not c:IsType(TYPE_LINK)
  end
  function s.destg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	local c = e:GetHandler()
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(1 - tp) and s.desfilter(chkc, c:GetAttack())
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.desfilter, tp, 0, LOCATION_MZONE, 1, nil, c:GetAttack())
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
  	local g = Duel.SelectTarget(tp, s.desfilter, tp, 0, LOCATION_MZONE, 1, 1, nil, c:GetAttack())
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, 1, 0, 0)
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) then
  		if Duel.Destroy(tc, REASON_EFFECT) ~= 0 and e:GetHandler():GetFlagEffect(id) ~= 0 then
  			local atk = tc:GetBaseAttack()
  			if atk > 0 then
  				Duel.BreakEffect()
  				Duel.Damage(1 - tp, math.ceil(atk / 2), REASON_EFFECT)
  			end
  		end
  	end
  end
  function s.valcheck(e, c)
  	local g = c:GetMaterial()
  	if g:IsExists(Card.IsLinkType, 1, nil, TYPE_XYZ) then
  		e:GetLabelObject():SetLabel(1)
  	else
  		e:GetLabelObject():SetLabel(0)
  	end
  end
  
  