--Majestic Mage Paladin function c249000781.initial_effect(c) c:SetSPSummonOnce(249000781) c:EnableReviveLimit() aux.AddLinkProcedure(c,aux.FilterBoolFunction(Card.IsLinkType,TYPE_EFFECT),3) --You can also Link Summon this card using... local e0=Effect.CreateEffect(c) e0:SetType(EFFECT_TYPE_FIELD) e0:SetCode(EFFECT_SPSUMMON_PROC) e0:SetProperty(EFFECT_FLAG_UNCOPYABLE+EFFECT_FLAG_IGNORE_IMMUNE) e0:SetRange(LOCATION_EXTRA) e0:SetCondition(c249000781.linkcon) e0:SetOperation(c249000781.linkop) e0:SetValue(SUMMON_TYPE_LINK) c:RegisterEffect(e0) --special summon local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_SPECIAL_SUMMON) e1:SetDescription(aux.Stringid(249000781,0)) e1:SetType(EFFECT_TYPE_IGNITION) e1:SetRange(LOCATION_MZONE) e1:SetCountLimit(1) e1:SetCost(c249000781.cost) e1:SetTarget(c249000781.target) e1:SetOperation(c249000781.operation) c:RegisterEffect(e1) end function c249000781.linkfilter(c,tp,c2) return c:GetCode()==249000780 and Duel.GetLocationCountFromEx(tp,tp,c)>0 end function c249000781.linkcon(e,c) if c==nil then return true end local tp=c:GetControler() return Duel.IsExistingMatchingCard(c249000781.linkfilter,tp,LOCATION_MZONE,0,1,nil,tp,c) and Duel.IsExistingMatchingCard(aux.TRUE,tp,LOCATION_HAND,0,1,nil,tp,c) end function c249000781.linkop(e,tp,eg,ep,ev,re,r,rp,c) local g1=Duel.SelectMatchingCard(tp,c249000781.linkfilter,tp,LOCATION_MZONE,0,1,1,nil,c) local g2=Duel.SelectMatchingCard(tp,aux.TRUE,tp,LOCATION_HAND,0,1,1,nil,c) g1:Merge(g2) c:SetMaterial(g1) Duel.SendtoGrave(g1,REASON_MATERIAL+REASON_LINK) end function c249000781.cfilter(c) return c:IsAbleToRemoveAsCost() and c:IsSetCard(0x103F) end function c249000781.cost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(c249000781.cfilter,tp,LOCATION_GRAVE+LOCATION_HAND,0,1,nil) end if Duel.GetLP(tp)< 3000 then Duel.PayLPCost(tp,math.floor(Duel.GetLP(tp)/2)) else Duel.PayLPCost(tp,1500) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOGRAVE) local g=Duel.SelectMatchingCard(tp,c249000781.cfilter,tp,LOCATION_GRAVE+LOCATION_HAND,0,1,1,nil) Duel.Remove(g,POS_FACEUP,REASON_COST) end function c249000781.filter1(c,e,tp) local lvrk=0 if c:IsType(TYPE_XYZ) then lvrk=c:GetRank() elseif c:IsLevelAbove(1) then lvrk=c:GetLevel() end return (lvrk>0) and (c:IsFaceup() or c:IsLocation(LOCATION_GRAVE)) and Duel.IsExistingMatchingCard(c249000781.filter2,tp,LOCATION_EXTRA,0,1,nil,e,tp,c,lvrk,c:GetRace()) and Duel.GetLocationCountFromEx(tp,tp,c)>0 end function c249000781.filter2(c,e,tp,mc,lvrk,rc) return (c:GetRank()==lvrk+1 or c:GetRank()==lvrk+2) and c:IsRace(rc) and mc:IsCanBeXyzMaterial(c,true) and c:IsCanBeSpecialSummoned(e,SUMMON_TYPE_XYZ,tp,false,false) end function c249000781.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsControler(tp) and chkc:IsLocation(LOCATION_MZONE+LOATION_GRAVE) and c249000781.filter1(chkc,e,tp) end if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and Duel.IsExistingTarget(c249000781.filter1,tp,LOCATION_MZONE+LOCATION_GRAVE,0,1,nil,e,tp) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TARGET) local g=Duel.SelectTarget(tp,c249000781.filter1,tp,LOCATION_MZONE+LOCATION_GRAVE,0,1,1,nil,e,tp) Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_EXTRA) end function c249000781.operation(e,tp,eg,ep,ev,re,r,rp) local tc=Duel.GetFirstTarget() if Duel.GetLocationCountFromEx(tp,tp,tc)<=0 then return end if tc:IsFacedown() or not tc:IsRelateToEffect(e) or tc:IsControler(1-tp) or tc:IsImmuneToEffect(e) then return end local lvrk=0 if tc:IsType(TYPE_XYZ) then lvrk=tc:GetRank() elseif tc:IsLevelAbove(1) then lvrk=tc:GetLevel() end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local g=Duel.SelectMatchingCard(tp,c249000781.filter2,tp,LOCATION_EXTRA,0,1,1,nil,e,tp,tc,lvrk,tc:GetRace()) local sc=g:GetFirst() if sc then local mg=tc:GetOverlayGroup() if mg:GetCount()~=0 then Duel.Overlay(sc,mg) end sc:SetMaterial(Group.FromCards(tc)) Duel.Overlay(sc,Group.FromCards(tc)) Duel.SpecialSummon(sc,SUMMON_TYPE_XYZ,tp,tp,false,false,POS_FACEUP) sc:CompleteProcedure() local tc2=Duel.GetFieldCard(tp,LOCATION_GRAVE,Duel.GetFieldGroupCount(tp,LOCATION_GRAVE,0)-1) if tc2 then Duel.Overlay(sc,tc2) end end end