name: Reptilianne
card_text: You can target 1 monster you control with 0 ATK and 1 DARK Reptile monster in your GY; destroy that monster on the field, and if you do, Special Summon that other monster from the GY. If your opponent activates a monster effect: You can target 1 monster your opponent controls with 0 ATK; take control of it, then, Special Summon 1 "Reptilianne Token" (Reptile/EARTH/Level 1/ATK 0/DEF 0) to your opponent's field. You can only use each effect of "Reptilianne Recoil" once per turn.
external_ids: local CARD_ID_0 = 21179144 --Reptilianne Token
  local CARD_ID_1 = 17000166 --Reptilianne Token
  local SETCARD_ID_0 = 0x3c --Reptilianne
  
lua: local CARD_ID_0 = 21179144 --Reptilianne Token
  local CARD_ID_1 = 17000166 --Reptilianne Token
  local SETCARD_ID_0 = 0x3c --Reptilianne
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	c:RegisterEffect(e1)
  	--destroy
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_DESTROY + CATEGORY_SPECIAL_SUMMON)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetRange(LOCATION_FZONE)
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e2:SetCountLimit(1, id)
  	e2:SetTarget(s.destg)
  	e2:SetOperation(s.desop)
  	c:RegisterEffect(e2)
  	--control
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetCategory(CATEGORY_CONTROL + CATEGORY_SPECIAL_SUMMON)
  	e3:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e3:SetCode(EVENT_CHAINING)
  	e3:SetProperty(EFFECT_FLAG_DELAY + EFFECT_FLAG_CARD_TARGET)
  	e3:SetRange(LOCATION_FZONE)
  	e3:SetCountLimit(1, id + 1)
  	e3:SetCondition(s.ctcon)
  	e3:SetTarget(s.cttg)
  	e3:SetOperation(s.ctop)
  	c:RegisterEffect(e3)
  end
  function s.desfilter(c, tp)
  	return c:IsFaceup() and c:IsAttack(0) and Duel.GetMZoneCount(tp, c) > 0
  end
  function s.spfilter(c, e, tp)
  	return c:IsRace(RACE_REPTILE) and c:IsAttribute(ATTRIBUTE_DARK) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.destg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return false
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.desfilter, tp, LOCATION_MZONE, 0, 1, nil, tp) and Duel.IsExistingTarget(s.spfilter, tp, LOCATION_GRAVE, 0, 1, nil, e, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
  	local g1 = Duel.SelectTarget(tp, s.desfilter, tp, LOCATION_MZONE, 0, 1, 1, nil, tp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g2 = Duel.SelectTarget(tp, s.spfilter, tp, LOCATION_GRAVE, 0, 1, 1, nil, e, tp)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g1, 1, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, g2, 1, 0, 0)
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local ex, g1 = Duel.GetOperationInfo(0, CATEGORY_DESTROY)
  	local ex, g2 = Duel.GetOperationInfo(0, CATEGORY_SPECIAL_SUMMON)
  	local tc1 = g1:GetFirst()
  	local tc2 = g2:GetFirst()
  	if tc1:IsRelateToEffect(e) and Duel.Destroy(tc1, REASON_EFFECT) ~= 0 and tc2:IsRelateToEffect(e) then
  		Duel.SpecialSummon(tc2, 0, tp, tp, false, false, POS_FACEUP)
  	end
  end
  function s.ctcon(e, tp, eg, ep, ev, re, r, rp)
  	return rp == 1 - tp and re:IsActiveType(TYPE_MONSTER)
  end
  function s.ctfilter(c, tp)
  	return c:IsFaceup() and c:IsAttack(0) and c:IsControlerCanBeChanged() and Duel.GetMZoneCount(1 - tp, c, tp) > 0
  end
  function s.cttg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(1 - tp) and s.ctfilter(chkc, tp)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.ctfilter, tp, 0, LOCATION_MZONE, 1, nil, tp)
  			and Duel.IsPlayerCanSpecialSummonMonster(tp, CARD_ID_0, SETCARD_ID_0, TYPES_TOKEN_MONSTER, 0, 0, 1, RACE_REPTILE, ATTRIBUTE_EARTH)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_CONTROL)
  	local g = Duel.SelectTarget(tp, s.ctfilter, tp, 0, LOCATION_MZONE, 1, 1, nil, tp)
  	Duel.SetOperationInfo(0, CATEGORY_CONTROL, g, 1, 0, 0)
  end
  function s.ctop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if
  		tc:IsRelateToEffect(e)
  		and Duel.GetControl(tc, tp)
  		and Duel.GetLocationCount(1 - tp, LOCATION_MZONE, tp) > 0
  		and Duel.IsPlayerCanSpecialSummonMonster(tp, CARD_ID_0, SETCARD_ID_0, TYPES_TOKEN_MONSTER, 0, 0, 1, RACE_REPTILE, ATTRIBUTE_EARTH)
  	then
  		Duel.BreakEffect()
  		local token = Duel.CreateToken(tp, id + 1)
  		Duel.SpecialSummon(token, 0, tp, 1 - tp, false, false, POS_FACEUP)
  	end
  end
  
  
source_text: Reptilianne
  You can target 1 monster you control with 0 ATK and 1 DARK Reptile monster in your GY; destroy that monster on the field, and if you do, Special Summon that other monster from the GY. If your opponent activates a monster effect: You can target 1 monster your opponent controls with 0 ATK; take control of it, then, Special Summon 1 "Reptilianne Token" (Reptile/EARTH/Level 1/ATK 0/DEF 0) to your opponent's field. You can only use each effect of "Reptilianne Recoil" once per turn.
target_text: -- Reptilianne
  local CARD_ID_0 = 21179144 --Reptilianne Token
  local CARD_ID_1 = 17000166 --Reptilianne Token
  local SETCARD_ID_0 = 0x3c --Reptilianne
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	c:RegisterEffect(e1)
  	--destroy
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_DESTROY + CATEGORY_SPECIAL_SUMMON)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetRange(LOCATION_FZONE)
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e2:SetCountLimit(1, id)
  	e2:SetTarget(s.destg)
  	e2:SetOperation(s.desop)
  	c:RegisterEffect(e2)
  	--control
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetCategory(CATEGORY_CONTROL + CATEGORY_SPECIAL_SUMMON)
  	e3:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e3:SetCode(EVENT_CHAINING)
  	e3:SetProperty(EFFECT_FLAG_DELAY + EFFECT_FLAG_CARD_TARGET)
  	e3:SetRange(LOCATION_FZONE)
  	e3:SetCountLimit(1, id + 1)
  	e3:SetCondition(s.ctcon)
  	e3:SetTarget(s.cttg)
  	e3:SetOperation(s.ctop)
  	c:RegisterEffect(e3)
  end
  function s.desfilter(c, tp)
  	return c:IsFaceup() and c:IsAttack(0) and Duel.GetMZoneCount(tp, c) > 0
  end
  function s.spfilter(c, e, tp)
  	return c:IsRace(RACE_REPTILE) and c:IsAttribute(ATTRIBUTE_DARK) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.destg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return false
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.desfilter, tp, LOCATION_MZONE, 0, 1, nil, tp) and Duel.IsExistingTarget(s.spfilter, tp, LOCATION_GRAVE, 0, 1, nil, e, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
  	local g1 = Duel.SelectTarget(tp, s.desfilter, tp, LOCATION_MZONE, 0, 1, 1, nil, tp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g2 = Duel.SelectTarget(tp, s.spfilter, tp, LOCATION_GRAVE, 0, 1, 1, nil, e, tp)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g1, 1, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, g2, 1, 0, 0)
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local ex, g1 = Duel.GetOperationInfo(0, CATEGORY_DESTROY)
  	local ex, g2 = Duel.GetOperationInfo(0, CATEGORY_SPECIAL_SUMMON)
  	local tc1 = g1:GetFirst()
  	local tc2 = g2:GetFirst()
  	if tc1:IsRelateToEffect(e) and Duel.Destroy(tc1, REASON_EFFECT) ~= 0 and tc2:IsRelateToEffect(e) then
  		Duel.SpecialSummon(tc2, 0, tp, tp, false, false, POS_FACEUP)
  	end
  end
  function s.ctcon(e, tp, eg, ep, ev, re, r, rp)
  	return rp == 1 - tp and re:IsActiveType(TYPE_MONSTER)
  end
  function s.ctfilter(c, tp)
  	return c:IsFaceup() and c:IsAttack(0) and c:IsControlerCanBeChanged() and Duel.GetMZoneCount(1 - tp, c, tp) > 0
  end
  function s.cttg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(1 - tp) and s.ctfilter(chkc, tp)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.ctfilter, tp, 0, LOCATION_MZONE, 1, nil, tp)
  			and Duel.IsPlayerCanSpecialSummonMonster(tp, CARD_ID_0, SETCARD_ID_0, TYPES_TOKEN_MONSTER, 0, 0, 1, RACE_REPTILE, ATTRIBUTE_EARTH)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_CONTROL)
  	local g = Duel.SelectTarget(tp, s.ctfilter, tp, 0, LOCATION_MZONE, 1, 1, nil, tp)
  	Duel.SetOperationInfo(0, CATEGORY_CONTROL, g, 1, 0, 0)
  end
  function s.ctop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if
  		tc:IsRelateToEffect(e)
  		and Duel.GetControl(tc, tp)
  		and Duel.GetLocationCount(1 - tp, LOCATION_MZONE, tp) > 0
  		and Duel.IsPlayerCanSpecialSummonMonster(tp, CARD_ID_0, SETCARD_ID_0, TYPES_TOKEN_MONSTER, 0, 0, 1, RACE_REPTILE, ATTRIBUTE_EARTH)
  	then
  		Duel.BreakEffect()
  		local token = Duel.CreateToken(tp, id + 1)
  		Duel.SpecialSummon(token, 0, tp, 1 - tp, false, false, POS_FACEUP)
  	end
  end
  
  