--Varia-Mage Creation Ritualist Duel.LoadScript("bannedlist.lua") function c249000525.initial_effect(c) --create local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_TOHAND) e1:SetType(EFFECT_TYPE_IGNITION) e1:SetCountLimit(1) e1:SetRange(LOCATION_MZONE) e1:SetCost(c249000525.cost) e1:SetOperation(c249000525.op) c:RegisterEffect(e1) --special summon local e2=Effect.CreateEffect(c) e2:SetDescription(2) e2:SetCategory(CATEGORY_SPECIAL_SUMMON) e2:SetType(EFFECT_TYPE_IGNITION) e2:SetProperty(EFFECT_FLAG_CARD_TARGET) e2:SetRange(LOCATION_MZONE) e2:SetCountLimit(1) e2:SetCondition(c249000525.spcon) e2:SetTarget(c249000525.sptg) e2:SetOperation(c249000525.spop) c:RegisterEffect(e2) --special summon local e3=Effect.CreateEffect(c) e3:SetType(EFFECT_TYPE_FIELD) e3:SetCode(EFFECT_SPSUMMON_PROC) e3:SetProperty(EFFECT_FLAG_UNCOPYABLE) e3:SetRange(LOCATION_HAND) e3:SetCondition(c249000525.spcon2) e3:SetOperation(c249000525.spop2) c:RegisterEffect(e3) if not c249000525.global_check then c249000525.global_check=true c249000525.used_table={} c249000525.used_table[0]={} c249000525.used_table[1]={} end end function c249000525.costfilter(c) return c:IsSetCard(0x1C8) and c:IsAbleToRemoveAsCost() end function c249000525.costfilter2(c,e) return c:IsSetCard(0x1C8) and not c:IsPublic() and c~=e:GetHandler() end function c249000525.cost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return (Duel.IsExistingMatchingCard(c249000525.costfilter,tp,LOCATION_GRAVE,0,1,nil) or Duel.IsExistingMatchingCard(c249000525.costfilter2,tp,LOCATION_HAND,0,1,nil,e)) end local option if Duel.IsExistingMatchingCard(c249000525.costfilter2,tp,LOCATION_HAND,0,1,nil,e) then option=0 end if Duel.IsExistingMatchingCard(c249000525.costfilter,tp,LOCATION_GRAVE,0,1,nil) then option=1 end if Duel.IsExistingMatchingCard(c249000525.costfilter,tp,LOCATION_GRAVE,0,1,nil) and Duel.IsExistingMatchingCard(c249000525.costfilter2,tp,LOCATION_HAND,0,1,nil,e) then option=Duel.SelectOption(tp,526,1102) end if option==0 then g=Duel.SelectMatchingCard(tp,c249000525.costfilter2,tp,LOCATION_HAND,0,1,1,nil,e) Duel.ConfirmCards(1-tp,g) Duel.ShuffleHand(tp) end if option==1 then Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE) local g=Duel.SelectMatchingCard(tp,c249000525.costfilter,tp,LOCATION_GRAVE,0,1,1,nil) Duel.Remove(g,POS_FACEUP,REASON_COST) end end function c249000525.op(e,tp,eg,ep,ev,re,r,rp) local ac local cc local i=1 local code_table={} for key,value in pairs(c249000525.used_table[tp]) do code_table[i]=key i=i+1 code_table[i]=OPCODE_ISCODE i=i+1 code_table[i]=OPCODE_NOT i=i+1 code_table[i]=OPCODE_AND i=i+1 end repeat ac=Duel.AnnounceCardFilter(tp,TYPE_RITUAL,OPCODE_ISTYPE,TYPE_SPELL,OPCODE_ISTYPE,OPCODE_NOT,OPCODE_AND,table.unpack(code_table)) cc=Duel.CreateToken(tp,ac) until not banned_list_table[ac] and cc:IsAbleToHand() -- and cc:GetType()==0x81 --and not c249000525.used_table[tp][ac] c249000525.used_table[tp][ac]=true Duel.SendtoHand(cc,nil,REASON_EFFECT) repeat ac=Duel.AnnounceCardFilter(tp,TYPE_RITUAL,OPCODE_ISTYPE,TYPE_MONSTER,OPCODE_ISTYPE,OPCODE_NOT,OPCODE_AND,table.unpack(code_table)) cc=Duel.CreateToken(tp,ac) until not banned_list_table[ac] and cc:IsAbleToHand() -- and cc:GetType()==0x82 --and not c249000525.used_table[tp][ac] c249000525.used_table[tp][ac]=true Duel.SendtoHand(cc,nil,REASON_EFFECT) e:GetHandler():RegisterFlagEffect(249000525,RESET_EVENT+RESETS_STANDARD+RESET_PHASE+PHASE_END,0,1) end function c249000525.spcon(e,tp,eg,ep,ev,re,r,rp) return e:GetHandler():GetFlagEffect(249000525)~=0 end function c249000525.spfilter(c,e,tp) return c:IsLevelBelow(4) and c:IsCanBeSpecialSummoned(e,0,tp,false,false) end function c249000525.sptg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsControler(tp) and chkc:IsLocation(LOCATION_GRAVE) and c249000525.spfilter(chkc,e,tp) end if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and Duel.IsExistingTarget(c249000525.spfilter,tp,LOCATION_GRAVE,0,1,nil,e,tp) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local g=Duel.SelectTarget(tp,c249000525.spfilter,tp,LOCATION_GRAVE,0,1,1,nil,e,tp) Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,g,1,0,0) end function c249000525.spop(e,tp,eg,ep,ev,re,r,rp) local tc=Duel.GetFirstTarget() local c=e:GetHandler() if tc:IsRelateToEffect(e) and Duel.SpecialSummonStep(tc,0,tp,tp,false,false,POS_FACEUP_DEFENSE) then local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_DISABLE) e1:SetReset(RESET_EVENT+RESETS_STANDARD) tc:RegisterEffect(e1) local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_SINGLE) e2:SetCode(EFFECT_DISABLE_EFFECT) e2:SetReset(RESET_EVENT+RESETS_STANDARD) tc:RegisterEffect(e2) end Duel.SpecialSummonComplete() end function c249000525.spcon2(e,c) if c==nil then return true end local tp=c:GetControler() return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and Duel.IsExistingMatchingCard(aux.TRUE,tp,LOCATION_HAND,0,1,c) end function c249000525.spop2(e,tp,eg,ep,ev,re,r,rp,c) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DISCARD) local g=Duel.SelectMatchingCard(tp,aux.TRUE,tp,LOCATION_HAND,0,1,1,c) Duel.SendtoGrave(g,REASON_COST+REASON_DISCARD) end