local m=77702003 local cm=_G["c"..m] function cm.initial_effect(c) local e3=Effect.CreateEffect(c) e3:SetCategory(CATEGORY_TOHAND+CATEGORY_SEARCH) e3:SetType(EFFECT_TYPE_IGNITION) e3:SetRange(LOCATION_GRAVE) e3:SetCost(aux.bfgcost) e3:SetTarget(cm.thtg) e3:SetOperation(cm.thop) c:RegisterEffect(e3) local e3=Effect.CreateEffect(c) e3:SetCategory(CATEGORY_SPECIAL_SUMMON+CATEGORY_TOHAND) e3:SetType(EFFECT_TYPE_ACTIVATE) e3:SetCode(EVENT_FREE_CHAIN) e3:SetTarget(cm.thtg1) e3:SetOperation(cm.thop1) c:RegisterEffect(e3) end function cm.thfilter(c) return c:IsAbleToHand() and c:IsCode(m-1) end function cm.thtg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(cm.thfilter,tp,LOCATION_DECK,0,1,nil) end Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK) end function cm.thop(e,tp,eg,ep,ev,re,r,rp) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND) local g=Duel.SelectMatchingCard(tp,cm.thfilter,tp,LOCATION_DECK,0,1,1,nil) if g:GetCount()>0 then Duel.SendtoHand(g,nil,REASON_EFFECT) Duel.ConfirmCards(1-tp,g) end end function cm.thfilter1(c) return c:IsAbleToHand() and c:IsLevelAbove(7) and c:IsType(TYPE_RITUAL) and not c:IsHasEffect(EFFECT_NECRO_VALLEY) end function cm.thtg1(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(cm.thfilter1,tp,LOCATION_GRAVE,0,1,nil) end Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_GRAVE) end function cm.thop1(e,tp,eg,ep,ev,re,r,rp) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_RTOHAND) local g=Duel.SelectMatchingCard(tp,cm.thfilter1,tp,LOCATION_GRAVE,0,1,1,nil) if g:GetCount()>0 and Duel.SendtoHand(g,nil,REASON_EFFECT)>0 then local mg=Duel.GetMatchingGroup(Auxiliary.RitualExtraFilter,tp,LOCATION_GRAVE,LOCATION_GRAVE,nil,aux.TRUE) if Duel.IsPlayerAffectedByEffect(tp,EFFECT_MAP_OF_HEAVEN) then local exg=Duel.GetMatchingGroup(function(c) return c:IsLevelAbove(1) end,tp,LOCATION_EXTRA,0,nil) mg:Merge(exg) end local sg=Duel.GetMatchingGroup(Auxiliary.RitualUltimateFilter,tp,LOCATION_HAND,0,nil,nil,e,tp,Group.CreateGroup(),mg,Card.GetLevel,"Equal") Duel.ShuffleHand(tp) if #sg>0 and Duel.SelectYesNo(tp,m*16) then Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local tc=sg:Select(tp,1,1,nil):GetFirst() if tc.mat_filter then mg=mg:Filter(tc.mat_filter,tc,tp) else mg:RemoveCard(tc) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_RELEASE) local lv=tc:GetLevel() Auxiliary.GCheckAdditional=Auxiliary.RitualCheckAdditional(tc,lv,"Equal") local mat=mg:SelectSubGroup(tp,Auxiliary.RitualCheck,false,1,lv,tp,tc,lv,"Equal") Auxiliary.GCheckAdditional=nil tc:SetMaterial(mat) Duel.BreakEffect() Duel.ReleaseRitualMaterial(mat) Duel.BreakEffect() Duel.SpecialSummon(tc,SUMMON_TYPE_RITUAL,tp,tp,false,true,POS_FACEUP) tc:CompleteProcedure() end end end