name: Archfiend
card_text: 1 Level 6 "Archfiend" Normal Monster + 1 "Red-Eyes" Normal Monster
  You can only Special Summon "Archfiend Black Skull Dragon(s)" once per turn. If this card battles, your opponent's cards and effects cannot be activated until the end of the Damage Step. If damage calculation is performed involving this Fusion Summoned card, at the end of the Battle Phase: You can target 1 "Red-Eyes" Normal Monster in your Graveyard; inflict damage to your opponent equal to its ATK in the Graveyard, then shuffle it into the Deck.
external_ids: local SETCARD_ID_0 = 0x45 --Archfiend
  local SETCARD_ID_1 = 0x3b --Red-Eyes
  
lua: local SETCARD_ID_0 = 0x45 --Archfiend
  local SETCARD_ID_1 = 0x3b --Red-Eyes
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:SetSPSummonOnce(id)
  	--fusion material
  	aux.AddFusionProcFun2(c, s.mfilter1, s.mfilter2, true)
  	c:EnableReviveLimit()
  	--aclimit
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_CANNOT_ACTIVATE)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e1:SetTargetRange(0, 1)
  	e1:SetCondition(s.accon)
  	e1:SetValue(1)
  	c:RegisterEffect(e1)
  	--damage
  	local e2 = Effect.CreateEffect(c)
  	e2:SetCategory(CATEGORY_DAMAGE + CATEGORY_TODECK)
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e2:SetCode(EVENT_PHASE + PHASE_BATTLE)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e2:SetCountLimit(1)
  	e2:SetCondition(s.damcon)
  	e2:SetTarget(s.damtg)
  	e2:SetOperation(s.damop)
  	c:RegisterEffect(e2)
  end
  s.material_setcode = 0x3b
  function s.mfilter1(c)
  	return c:IsFusionSetCard(SETCARD_ID_1) and c:IsFusionType(TYPE_NORMAL) and c:IsLevel(6)
  end
  function s.mfilter2(c)
  	return c:IsFusionSetCard(SETCARD_ID_1) and c:IsFusionType(TYPE_NORMAL)
  end
  function s.accon(e)
  	return Duel.GetAttacker() == e:GetHandler() or Duel.GetAttackTarget() == e:GetHandler()
  end
  function s.damcon(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	return c:IsSummonType(SUMMON_TYPE_FUSION) and c:GetBattledGroupCount() > 0
  end
  function s.filter(c)
  	return c:IsSetCard(SETCARD_ID_1) and c:IsType(TYPE_NORMAL) and c:IsAbleToDeck()
  end
  function s.damtg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and s.filter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.filter, tp, LOCATION_GRAVE, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TARGET)
  	local g = Duel.SelectTarget(tp, s.filter, tp, LOCATION_GRAVE, 0, 1, 1, nil)
  	local atk = g:GetFirst():GetBaseAttack()
  	Duel.SetOperationInfo(0, CATEGORY_DAMAGE, nil, 0, 1 - tp, atk)
  	Duel.SetOperationInfo(0, CATEGORY_TODECK, g, 1, 0, 0)
  end
  function s.damop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) and Duel.Damage(1 - tp, tc:GetBaseAttack(), REASON_EFFECT) ~= 0 then
  		Duel.BreakEffect()
  		Duel.SendtoDeck(tc, nil, SEQ_DECKSHUFFLE, REASON_EFFECT)
  	end
  end
  
  
source_text: Archfiend
  1 Level 6 "Archfiend" Normal Monster + 1 "Red-Eyes" Normal Monster
  You can only Special Summon "Archfiend Black Skull Dragon(s)" once per turn. If this card battles, your opponent's cards and effects cannot be activated until the end of the Damage Step. If damage calculation is performed involving this Fusion Summoned card, at the end of the Battle Phase: You can target 1 "Red-Eyes" Normal Monster in your Graveyard; inflict damage to your opponent equal to its ATK in the Graveyard, then shuffle it into the Deck.
target_text: -- Archfiend
  local SETCARD_ID_0 = 0x45 --Archfiend
  local SETCARD_ID_1 = 0x3b --Red-Eyes
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:SetSPSummonOnce(id)
  	--fusion material
  	aux.AddFusionProcFun2(c, s.mfilter1, s.mfilter2, true)
  	c:EnableReviveLimit()
  	--aclimit
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_CANNOT_ACTIVATE)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e1:SetTargetRange(0, 1)
  	e1:SetCondition(s.accon)
  	e1:SetValue(1)
  	c:RegisterEffect(e1)
  	--damage
  	local e2 = Effect.CreateEffect(c)
  	e2:SetCategory(CATEGORY_DAMAGE + CATEGORY_TODECK)
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e2:SetCode(EVENT_PHASE + PHASE_BATTLE)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e2:SetCountLimit(1)
  	e2:SetCondition(s.damcon)
  	e2:SetTarget(s.damtg)
  	e2:SetOperation(s.damop)
  	c:RegisterEffect(e2)
  end
  s.material_setcode = 0x3b
  function s.mfilter1(c)
  	return c:IsFusionSetCard(SETCARD_ID_1) and c:IsFusionType(TYPE_NORMAL) and c:IsLevel(6)
  end
  function s.mfilter2(c)
  	return c:IsFusionSetCard(SETCARD_ID_1) and c:IsFusionType(TYPE_NORMAL)
  end
  function s.accon(e)
  	return Duel.GetAttacker() == e:GetHandler() or Duel.GetAttackTarget() == e:GetHandler()
  end
  function s.damcon(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	return c:IsSummonType(SUMMON_TYPE_FUSION) and c:GetBattledGroupCount() > 0
  end
  function s.filter(c)
  	return c:IsSetCard(SETCARD_ID_1) and c:IsType(TYPE_NORMAL) and c:IsAbleToDeck()
  end
  function s.damtg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and s.filter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.filter, tp, LOCATION_GRAVE, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TARGET)
  	local g = Duel.SelectTarget(tp, s.filter, tp, LOCATION_GRAVE, 0, 1, 1, nil)
  	local atk = g:GetFirst():GetBaseAttack()
  	Duel.SetOperationInfo(0, CATEGORY_DAMAGE, nil, 0, 1 - tp, atk)
  	Duel.SetOperationInfo(0, CATEGORY_TODECK, g, 1, 0, 0)
  end
  function s.damop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) and Duel.Damage(1 - tp, tc:GetBaseAttack(), REASON_EFFECT) ~= 0 then
  		Duel.BreakEffect()
  		Duel.SendtoDeck(tc, nil, SEQ_DECKSHUFFLE, REASON_EFFECT)
  	end
  end
  
  