name: Raidraptor
card_text: Cannot be used as an Xyz Material for an Xyz Summon, except for the Xyz Summon of a Winged Beast-Type monster. If this card is in your hand: You can target 1 "Raidraptor" monster you control that has a Level; take damage equal to its ATK or DEF (whichever is lower, but your choice if tied), and if you do, Special Summon this card, and if you do that, this card's Level becomes the current Level of the targeted monster. You can only use this effect of "Raidraptor - Pain Lanius" once per turn.
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)
  	--spsummon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetCountLimit(1, id)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  	--
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_SINGLE)
  	e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e2:SetCode(EFFECT_CANNOT_BE_XYZ_MATERIAL)
  	e2:SetValue(s.xyzlimit)
  	c:RegisterEffect(e2)
  end
  function s.cfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and c:IsLevelAbove(1) and c:IsAttackAbove(1) and c:IsDefenseAbove(1)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and s.cfilter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.cfilter, tp, LOCATION_MZONE, 0, 1, nil)
  			and Duel.GetLocationCount(tp, LOCATION_MZONE) > 0
  			and e:GetHandler():IsCanBeSpecialSummoned(e, 0, tp, false, false)
  			and not Duel.IsPlayerAffectedByEffect(tp, EFFECT_NO_EFFECT_DAMAGE)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TARGET)
  	local g = Duel.SelectTarget(tp, s.cfilter, tp, LOCATION_MZONE, 0, 1, 1, nil)
  	local tc = g:GetFirst()
  	local atk = tc:GetAttack()
  	local def = tc:GetDefense()
  	local val = math.min(atk, def)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, e:GetHandler(), 1, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_DAMAGE, 0, 0, tp, val)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = Duel.GetFirstTarget()
  	if tc:IsFacedown() or not tc:IsRelateToEffect(e) then
  		return
  	end
  	local atk = tc:GetAttack()
  	local def = tc:GetDefense()
  	local val = math.min(atk, def)
  	if Duel.Damage(tp, val, REASON_EFFECT) ~= 0 and c:IsRelateToEffect(e) then
  		if Duel.SpecialSummonStep(c, 0, tp, tp, false, false, POS_FACEUP) then
  			local e1 = Effect.CreateEffect(c)
  			e1:SetType(EFFECT_TYPE_SINGLE)
  			e1:SetCode(EFFECT_CHANGE_LEVEL)
  			e1:SetValue(tc:GetLevel())
  			e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_DISABLE)
  			c:RegisterEffect(e1)
  		end
  		Duel.SpecialSummonComplete()
  	end
  end
  function s.xyzlimit(e, c)
  	if not c then
  		return false
  	end
  	return not c:IsRace(RACE_WINDBEAST)
  end
  
  
source_text: Raidraptor
  Cannot be used as an Xyz Material for an Xyz Summon, except for the Xyz Summon of a Winged Beast-Type monster. If this card is in your hand: You can target 1 "Raidraptor" monster you control that has a Level; take damage equal to its ATK or DEF (whichever is lower, but your choice if tied), and if you do, Special Summon this card, and if you do that, this card's Level becomes the current Level of the targeted monster. You can only use this effect of "Raidraptor - Pain Lanius" once per turn.
target_text: -- Raidraptor
  local SETCARD_ID_0 = 0xba --Raidraptor
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--spsummon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetCountLimit(1, id)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  	--
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_SINGLE)
  	e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e2:SetCode(EFFECT_CANNOT_BE_XYZ_MATERIAL)
  	e2:SetValue(s.xyzlimit)
  	c:RegisterEffect(e2)
  end
  function s.cfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and c:IsLevelAbove(1) and c:IsAttackAbove(1) and c:IsDefenseAbove(1)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and s.cfilter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.cfilter, tp, LOCATION_MZONE, 0, 1, nil)
  			and Duel.GetLocationCount(tp, LOCATION_MZONE) > 0
  			and e:GetHandler():IsCanBeSpecialSummoned(e, 0, tp, false, false)
  			and not Duel.IsPlayerAffectedByEffect(tp, EFFECT_NO_EFFECT_DAMAGE)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TARGET)
  	local g = Duel.SelectTarget(tp, s.cfilter, tp, LOCATION_MZONE, 0, 1, 1, nil)
  	local tc = g:GetFirst()
  	local atk = tc:GetAttack()
  	local def = tc:GetDefense()
  	local val = math.min(atk, def)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, e:GetHandler(), 1, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_DAMAGE, 0, 0, tp, val)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = Duel.GetFirstTarget()
  	if tc:IsFacedown() or not tc:IsRelateToEffect(e) then
  		return
  	end
  	local atk = tc:GetAttack()
  	local def = tc:GetDefense()
  	local val = math.min(atk, def)
  	if Duel.Damage(tp, val, REASON_EFFECT) ~= 0 and c:IsRelateToEffect(e) then
  		if Duel.SpecialSummonStep(c, 0, tp, tp, false, false, POS_FACEUP) then
  			local e1 = Effect.CreateEffect(c)
  			e1:SetType(EFFECT_TYPE_SINGLE)
  			e1:SetCode(EFFECT_CHANGE_LEVEL)
  			e1:SetValue(tc:GetLevel())
  			e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_DISABLE)
  			c:RegisterEffect(e1)
  		end
  		Duel.SpecialSummonComplete()
  	end
  end
  function s.xyzlimit(e, c)
  	if not c then
  		return false
  	end
  	return not c:IsRace(RACE_WINDBEAST)
  end
  
  