name: Fallen
card_text: If a Level/Rank/Link 2 monster is on the field, you can Special Summon this card (from your hand) to either field. You can only Special Summon "Fallen of Argyros" once per turn this way. Neither player can activate the effects of Link Monsters that point to this card. During your opponent's turn (Quick Effect): You can target 1 Xyz Monster on the field; detach 1 or 2 materials from it. You can only use this effect of "Fallen of Argyros" once per turn.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--spsummon rule or self
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_SPSUMMON_PROC)
  	e1:SetProperty(EFFECT_FLAG_UNCOPYABLE)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetCondition(s.sprcon1)
  	c:RegisterEffect(e1)
  	--spsummon rule or your opponent
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_SPSUMMON_PROC)
  	e2:SetRange(LOCATION_HAND)
  	e2:SetProperty(EFFECT_FLAG_UNCOPYABLE + EFFECT_FLAG_SPSUM_PARAM)
  	e2:SetTargetRange(POS_FACEUP, 1)
  	e2:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e2:SetCondition(s.sprcon2)
  	c:RegisterEffect(e2)
  	--act limit
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_FIELD)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCode(EFFECT_CANNOT_TRIGGER)
  	e3:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
  	e3:SetTargetRange(LOCATION_MZONE, LOCATION_MZONE)
  	e3:SetTarget(s.actfilter)
  	c:RegisterEffect(e3)
  	--xyz material detach
  	local e4 = Effect.CreateEffect(c)
  	e4:SetDescription(aux.Stringid(id, 2))
  	e4:SetType(EFFECT_TYPE_QUICK_O)
  	e4:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e4:SetCode(EVENT_FREE_CHAIN)
  	e4:SetRange(LOCATION_MZONE)
  	e4:SetHintTiming(0, TIMINGS_CHECK_MONSTER + TIMING_END_PHASE)
  	e4:SetCountLimit(1, id + 1)
  	e4:SetCondition(s.dhcon)
  	e4:SetTarget(s.dhtg)
  	e4:SetOperation(s.dhop)
  	c:RegisterEffect(e4)
  end
  function s.twofilter(c)
  	return c:IsFaceup() and (c:IsLevel(2) or c:IsLink(2) or c:IsRank(2))
  end
  function s.sprcon1(e, c)
  	if c == nil then
  		return true
  	end
  	local tp = c:GetControler()
  	return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingMatchingCard(s.twofilter, tp, LOCATION_MZONE, LOCATION_MZONE, 1, nil)
  end
  function s.sprcon2(e, c)
  	if c == nil then
  		return true
  	end
  	local tp = c:GetControler()
  	return Duel.GetLocationCount(1 - tp, LOCATION_MZONE) > 0 and Duel.IsExistingMatchingCard(s.twofilter, tp, LOCATION_MZONE, LOCATION_MZONE, 1, nil)
  end
  function s.actfilter(e, c)
  	local g = c:GetLinkedGroup()
  	return c:IsType(TYPE_LINK) and g:IsContains(e:GetHandler())
  end
  function s.dhcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetTurnPlayer() == 1 - tp
  end
  function s.xfilter(c)
  	return c:IsFaceup() and c:IsType(TYPE_XYZ) and c:GetOverlayCount() > 0
  end
  function s.dhtg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and s.xfilter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.xfilter, tp, LOCATION_MZONE, LOCATION_MZONE, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TARGET)
  	Duel.SelectTarget(tp, s.xfilter, tp, LOCATION_MZONE, LOCATION_MZONE, 1, 1, nil)
  end
  function s.dhop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) and tc:GetOverlayCount() > 0 then
  		tc:RemoveOverlayCard(tp, 1, 2, REASON_EFFECT)
  	end
  end
  
  
source_text: Fallen
  If a Level/Rank/Link 2 monster is on the field, you can Special Summon this card (from your hand) to either field. You can only Special Summon "Fallen of Argyros" once per turn this way. Neither player can activate the effects of Link Monsters that point to this card. During your opponent's turn (Quick Effect): You can target 1 Xyz Monster on the field; detach 1 or 2 materials from it. You can only use this effect of "Fallen of Argyros" once per turn.
target_text: -- Fallen
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--spsummon rule or self
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_SPSUMMON_PROC)
  	e1:SetProperty(EFFECT_FLAG_UNCOPYABLE)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetCondition(s.sprcon1)
  	c:RegisterEffect(e1)
  	--spsummon rule or your opponent
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_SPSUMMON_PROC)
  	e2:SetRange(LOCATION_HAND)
  	e2:SetProperty(EFFECT_FLAG_UNCOPYABLE + EFFECT_FLAG_SPSUM_PARAM)
  	e2:SetTargetRange(POS_FACEUP, 1)
  	e2:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e2:SetCondition(s.sprcon2)
  	c:RegisterEffect(e2)
  	--act limit
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_FIELD)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCode(EFFECT_CANNOT_TRIGGER)
  	e3:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
  	e3:SetTargetRange(LOCATION_MZONE, LOCATION_MZONE)
  	e3:SetTarget(s.actfilter)
  	c:RegisterEffect(e3)
  	--xyz material detach
  	local e4 = Effect.CreateEffect(c)
  	e4:SetDescription(aux.Stringid(id, 2))
  	e4:SetType(EFFECT_TYPE_QUICK_O)
  	e4:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e4:SetCode(EVENT_FREE_CHAIN)
  	e4:SetRange(LOCATION_MZONE)
  	e4:SetHintTiming(0, TIMINGS_CHECK_MONSTER + TIMING_END_PHASE)
  	e4:SetCountLimit(1, id + 1)
  	e4:SetCondition(s.dhcon)
  	e4:SetTarget(s.dhtg)
  	e4:SetOperation(s.dhop)
  	c:RegisterEffect(e4)
  end
  function s.twofilter(c)
  	return c:IsFaceup() and (c:IsLevel(2) or c:IsLink(2) or c:IsRank(2))
  end
  function s.sprcon1(e, c)
  	if c == nil then
  		return true
  	end
  	local tp = c:GetControler()
  	return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingMatchingCard(s.twofilter, tp, LOCATION_MZONE, LOCATION_MZONE, 1, nil)
  end
  function s.sprcon2(e, c)
  	if c == nil then
  		return true
  	end
  	local tp = c:GetControler()
  	return Duel.GetLocationCount(1 - tp, LOCATION_MZONE) > 0 and Duel.IsExistingMatchingCard(s.twofilter, tp, LOCATION_MZONE, LOCATION_MZONE, 1, nil)
  end
  function s.actfilter(e, c)
  	local g = c:GetLinkedGroup()
  	return c:IsType(TYPE_LINK) and g:IsContains(e:GetHandler())
  end
  function s.dhcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetTurnPlayer() == 1 - tp
  end
  function s.xfilter(c)
  	return c:IsFaceup() and c:IsType(TYPE_XYZ) and c:GetOverlayCount() > 0
  end
  function s.dhtg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and s.xfilter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.xfilter, tp, LOCATION_MZONE, LOCATION_MZONE, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TARGET)
  	Duel.SelectTarget(tp, s.xfilter, tp, LOCATION_MZONE, LOCATION_MZONE, 1, 1, nil)
  end
  function s.dhop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) and tc:GetOverlayCount() > 0 then
  		tc:RemoveOverlayCard(tp, 1, 2, REASON_EFFECT)
  	end
  end
  
  