name: Crusadia
card_text: When you activate this card: You can also Tribute 1 "Crusadia" or "World Legacy" monster; if you did, Special Summon 1 "Crusadia" or "World Legacy" monster, with a different original name, from your Deck or GY. While you control a "Crusadia" Link Monster, your opponent's monsters can only target Link Monsters for attacks. You can only activate 1 "Crusadia Vanguard" per turn.
external_ids: local SETCARD_ID_0 = 0x116 --Crusadia
  local SETCARD_ID_1 = 0xfe --World
  
lua: local SETCARD_ID_0 = 0x116 --Crusadia
  local SETCARD_ID_1 = 0xfe --World
  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)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetTarget(s.target)
  	c:RegisterEffect(e1)
  	--atk limit
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_CANNOT_DIRECT_ATTACK)
  	e2:SetRange(LOCATION_SZONE)
  	e2:SetTargetRange(0, LOCATION_MZONE)
  	e2:SetCondition(s.atcon)
  	c:RegisterEffect(e2)
  	local e3 = e2:Clone()
  	e3:SetCode(EFFECT_CANNOT_SELECT_BATTLE_TARGET)
  	e3:SetValue(s.atlimit)
  	c:RegisterEffect(e3)
  end
  function s.spfilter1(c, e, tp)
  	return c:IsSetCard(0xfe, SETCARD_ID_1)
  		and c:IsType(TYPE_MONSTER)
  		and Duel.GetMZoneCount(tp, c) > 0
  		and Duel.IsExistingMatchingCard(s.spfilter2, tp, LOCATION_DECK + LOCATION_GRAVE, 0, 1, nil, e, tp, c)
  end
  function s.spfilter2(c, e, tp, rc)
  	return c:IsSetCard(0xfe, SETCARD_ID_1) and c:IsType(TYPE_MONSTER) and not c:IsOriginalCodeRule(rc:GetOriginalCodeRule()) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	if Duel.CheckReleaseGroup(tp, s.spfilter1, 1, nil, e, tp) and Duel.SelectEffectYesNo(tp, e:GetHandler(), aux.Stringid(id, 0)) then
  		e:SetCategory(CATEGORY_SPECIAL_SUMMON)
  		e:SetOperation(s.activate)
  		local rg = Duel.SelectReleaseGroup(tp, s.spfilter1, 1, 1, nil, e, tp)
  		e:SetLabelObject(rg:GetFirst())
  		Duel.Release(rg, REASON_COST)
  		Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_DECK + LOCATION_GRAVE)
  	else
  		e:SetCategory(0)
  		e:SetOperation(nil)
  	end
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetLocationCount(tp, LOCATION_MZONE) <= 0 then
  		return
  	end
  	local rc = e:GetLabelObject()
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectMatchingCard(tp, aux.NecroValleyFilter(s.spfilter2), tp, LOCATION_DECK + LOCATION_GRAVE, 0, 1, 1, nil, e, tp, rc)
  	if g:GetCount() > 0 then
  		Duel.SpecialSummon(g, 0, tp, tp, false, false, POS_FACEUP)
  	end
  end
  function s.cfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_1) and c:IsType(TYPE_LINK)
  end
  function s.atcon(e)
  	return Duel.IsExistingMatchingCard(s.cfilter, e:GetHandlerPlayer(), LOCATION_MZONE, 0, 1, nil)
  end
  function s.atlimit(e, c)
  	return c:IsFacedown() or not c:IsType(TYPE_LINK)
  end
  
  
source_text: Crusadia
  When you activate this card: You can also Tribute 1 "Crusadia" or "World Legacy" monster; if you did, Special Summon 1 "Crusadia" or "World Legacy" monster, with a different original name, from your Deck or GY. While you control a "Crusadia" Link Monster, your opponent's monsters can only target Link Monsters for attacks. You can only activate 1 "Crusadia Vanguard" per turn.
target_text: -- Crusadia
  local SETCARD_ID_0 = 0x116 --Crusadia
  local SETCARD_ID_1 = 0xfe --World
  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)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetTarget(s.target)
  	c:RegisterEffect(e1)
  	--atk limit
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_CANNOT_DIRECT_ATTACK)
  	e2:SetRange(LOCATION_SZONE)
  	e2:SetTargetRange(0, LOCATION_MZONE)
  	e2:SetCondition(s.atcon)
  	c:RegisterEffect(e2)
  	local e3 = e2:Clone()
  	e3:SetCode(EFFECT_CANNOT_SELECT_BATTLE_TARGET)
  	e3:SetValue(s.atlimit)
  	c:RegisterEffect(e3)
  end
  function s.spfilter1(c, e, tp)
  	return c:IsSetCard(0xfe, SETCARD_ID_1)
  		and c:IsType(TYPE_MONSTER)
  		and Duel.GetMZoneCount(tp, c) > 0
  		and Duel.IsExistingMatchingCard(s.spfilter2, tp, LOCATION_DECK + LOCATION_GRAVE, 0, 1, nil, e, tp, c)
  end
  function s.spfilter2(c, e, tp, rc)
  	return c:IsSetCard(0xfe, SETCARD_ID_1) and c:IsType(TYPE_MONSTER) and not c:IsOriginalCodeRule(rc:GetOriginalCodeRule()) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	if Duel.CheckReleaseGroup(tp, s.spfilter1, 1, nil, e, tp) and Duel.SelectEffectYesNo(tp, e:GetHandler(), aux.Stringid(id, 0)) then
  		e:SetCategory(CATEGORY_SPECIAL_SUMMON)
  		e:SetOperation(s.activate)
  		local rg = Duel.SelectReleaseGroup(tp, s.spfilter1, 1, 1, nil, e, tp)
  		e:SetLabelObject(rg:GetFirst())
  		Duel.Release(rg, REASON_COST)
  		Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_DECK + LOCATION_GRAVE)
  	else
  		e:SetCategory(0)
  		e:SetOperation(nil)
  	end
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetLocationCount(tp, LOCATION_MZONE) <= 0 then
  		return
  	end
  	local rc = e:GetLabelObject()
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectMatchingCard(tp, aux.NecroValleyFilter(s.spfilter2), tp, LOCATION_DECK + LOCATION_GRAVE, 0, 1, 1, nil, e, tp, rc)
  	if g:GetCount() > 0 then
  		Duel.SpecialSummon(g, 0, tp, tp, false, false, POS_FACEUP)
  	end
  end
  function s.cfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_1) and c:IsType(TYPE_LINK)
  end
  function s.atcon(e)
  	return Duel.IsExistingMatchingCard(s.cfilter, e:GetHandlerPlayer(), LOCATION_MZONE, 0, 1, nil)
  end
  function s.atlimit(e, c)
  	return c:IsFacedown() or not c:IsType(TYPE_LINK)
  end
  
  