name: Raidraptor
card_text: 3 Level 12 monsters
  If this card has a "Raidraptor" Xyz Monster as material, it is unaffected by other cards' effects. Once per turn: You can detach 1 material from this card; return all your banished "Raidraptor" monsters to your GY. Up to twice per turn, when this attacking card destroys a monster by battle: You can banish 1 "Raidraptor" Xyz Monster from your GY; this card can attack again in a row.
external_ids: local SETCARD_ID_0 = 0xba --Raidraptor
  
lua: local SETCARD_ID_0 = 0xba --Raidraptor
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--xyz summon
  	aux.AddXyzProcedure(c, nil, 12, 3)
  	c:EnableReviveLimit()
  	--immune
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_IMMUNE_EFFECT)
  	e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCondition(s.imcon)
  	e1:SetValue(s.efilter)
  	c:RegisterEffect(e1)
  	--return
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_TOGRAVE)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetCountLimit(1)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCost(s.cost)
  	e2:SetTarget(s.target)
  	e2:SetOperation(s.operation)
  	c:RegisterEffect(e2)
  	--chain attack
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e3:SetCode(EVENT_BATTLE_DESTROYING)
  	e3:SetCountLimit(2)
  	e3:SetCondition(s.atcon)
  	e3:SetCost(s.atcost)
  	e3:SetOperation(s.atop)
  	c:RegisterEffect(e3)
  end
  function s.imfilter(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_XYZ)
  end
  function s.imcon(e)
  	return e:GetHandler():GetOverlayGroup():IsExists(s.imfilter, 1, nil)
  end
  function s.efilter(e, te)
  	return te:GetOwner() ~= e:GetOwner()
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():CheckRemoveOverlayCard(tp, 1, REASON_COST)
  	end
  	e:GetHandler():RemoveOverlayCard(tp, 1, 1, REASON_COST)
  end
  function s.filter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_MONSTER)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_REMOVED, 0, 1, nil)
  	end
  	local g = Duel.GetMatchingGroup(s.filter, tp, LOCATION_REMOVED, 0, nil)
  	Duel.SetOperationInfo(0, CATEGORY_TOGRAVE, g, g:GetCount(), 0, 0)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetMatchingGroup(s.filter, tp, LOCATION_REMOVED, 0, nil)
  	if g:GetCount() > 0 then
  		Duel.SendtoGrave(g, REASON_EFFECT + REASON_RETURN)
  	end
  end
  function s.atcon(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	return Duel.GetAttacker() == c and aux.bdocon(e, tp, eg, ep, ev, re, r, rp) and c:IsChainAttackable(0)
  end
  function s.atfilter(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_XYZ) and c:IsAbleToRemoveAsCost()
  end
  function s.atcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.atfilter, tp, LOCATION_GRAVE, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local g = Duel.SelectMatchingCard(tp, s.atfilter, tp, LOCATION_GRAVE, 0, 1, 1, nil)
  	Duel.Remove(g, POS_FACEUP, REASON_COST)
  end
  function s.atop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.ChainAttack()
  end
  
  
source_text: Raidraptor
  3 Level 12 monsters
  If this card has a "Raidraptor" Xyz Monster as material, it is unaffected by other cards' effects. Once per turn: You can detach 1 material from this card; return all your banished "Raidraptor" monsters to your GY. Up to twice per turn, when this attacking card destroys a monster by battle: You can banish 1 "Raidraptor" Xyz Monster from your GY; this card can attack again in a row.
target_text: -- Raidraptor
  local SETCARD_ID_0 = 0xba --Raidraptor
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--xyz summon
  	aux.AddXyzProcedure(c, nil, 12, 3)
  	c:EnableReviveLimit()
  	--immune
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_IMMUNE_EFFECT)
  	e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCondition(s.imcon)
  	e1:SetValue(s.efilter)
  	c:RegisterEffect(e1)
  	--return
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_TOGRAVE)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetCountLimit(1)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCost(s.cost)
  	e2:SetTarget(s.target)
  	e2:SetOperation(s.operation)
  	c:RegisterEffect(e2)
  	--chain attack
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e3:SetCode(EVENT_BATTLE_DESTROYING)
  	e3:SetCountLimit(2)
  	e3:SetCondition(s.atcon)
  	e3:SetCost(s.atcost)
  	e3:SetOperation(s.atop)
  	c:RegisterEffect(e3)
  end
  function s.imfilter(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_XYZ)
  end
  function s.imcon(e)
  	return e:GetHandler():GetOverlayGroup():IsExists(s.imfilter, 1, nil)
  end
  function s.efilter(e, te)
  	return te:GetOwner() ~= e:GetOwner()
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():CheckRemoveOverlayCard(tp, 1, REASON_COST)
  	end
  	e:GetHandler():RemoveOverlayCard(tp, 1, 1, REASON_COST)
  end
  function s.filter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_MONSTER)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_REMOVED, 0, 1, nil)
  	end
  	local g = Duel.GetMatchingGroup(s.filter, tp, LOCATION_REMOVED, 0, nil)
  	Duel.SetOperationInfo(0, CATEGORY_TOGRAVE, g, g:GetCount(), 0, 0)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetMatchingGroup(s.filter, tp, LOCATION_REMOVED, 0, nil)
  	if g:GetCount() > 0 then
  		Duel.SendtoGrave(g, REASON_EFFECT + REASON_RETURN)
  	end
  end
  function s.atcon(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	return Duel.GetAttacker() == c and aux.bdocon(e, tp, eg, ep, ev, re, r, rp) and c:IsChainAttackable(0)
  end
  function s.atfilter(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_XYZ) and c:IsAbleToRemoveAsCost()
  end
  function s.atcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.atfilter, tp, LOCATION_GRAVE, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local g = Duel.SelectMatchingCard(tp, s.atfilter, tp, LOCATION_GRAVE, 0, 1, 1, nil)
  	Duel.Remove(g, POS_FACEUP, REASON_COST)
  end
  function s.atop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.ChainAttack()
  end
  
  