--Absolute Ritual of Darkness function c249001049.initial_effect(c) --Activate local e1=Effect.CreateEffect(c) e1:SetDescription(1152) e1:SetCategory(CATEGORY_SPECIAL_SUMMON) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_FREE_CHAIN) e1:SetTarget(c249001049.target) e1:SetOperation(c249001049.activate) c:RegisterEffect(e1) --search local e2=Effect.CreateEffect(c) e2:SetDescription(1190) e2:SetType(EFFECT_TYPE_IGNITION) e2:SetCategory(CATEGORY_TOHAND+CATEGORY_SEARCH) e2:SetRange(LOCATION_HAND) e2:SetCountLimit(1,249001049) e2:SetCost(c249001049.thcost) e2:SetTarget(c249001049.thtg) e2:SetOperation(c249001049.thop) c:RegisterEffect(e2) end function c249001049.filter(c,e,tp,m1,m2,level_function,greater_or_equal,chk) if not c:IsAttribute(ATTRIBUTE_DARK) or not c:IsCanBeSpecialSummoned(e,SUMMMON_TYPE_RITUAL,tp,true,false) then return false end local mg=m1:Filter(Card.IsCanBeRitualMaterial,c,c) if m2 then mg:Merge(m2) end if c.mat_filter then mg=mg:Filter(c.mat_filter,c,tp) else mg:RemoveCard(c) end local lv=level_function(c) Auxiliary.GCheckAdditional=Auxiliary.RitualCheckAdditional(c,lv,greater_or_equal) local res=mg:CheckSubGroup(Auxiliary.RitualCheck,1,lv,tp,c,lv,greater_or_equal) Auxiliary.GCheckAdditional=nil return res end function c249001049.mfilter(c) return c:GetLevel()>0 and c:IsAbleToRemove() end function c249001049.target(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then local mg=Duel.GetRitualMaterial(tp) local mg2=nil if Duel.IsExistingMatchingCard(aux.FilterEqualFunction(Card.GetSummonLocation,LOCATION_EXTRA),tp,0,LOCATION_MZONE,1,nil) then mg2=Duel.GetMatchingGroup(c249001049.mfilter,tp,LOCATION_GRAVE,0,nil) end return Duel.IsExistingMatchingCard(c249001049.filter,tp,LOCATION_HAND,0,1,nil,e,tp,mg,mg2,Card.GetLevel,"Greater") end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_HAND) Duel.SetOperationInfo(0,CATEGORY_REMOVE,nil,0,tp,LOCATION_GRAVE) end function c249001049.activate(e,tp,eg,ep,ev,re,r,rp) local mg=Duel.GetRitualMaterial(tp) local mg2=nil if Duel.IsExistingMatchingCard(aux.FilterEqualFunction(Card.GetSummonLocation,LOCATION_EXTRA),tp,0,LOCATION_MZONE,1,nil) then mg2=Duel.GetMatchingGroup(c249001049.mfilter,tp,LOCATION_GRAVE,0,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local tg=Duel.SelectMatchingCard(tp,c249001049.filter,tp,LOCATION_HAND,0,1,1,nil,e,tp,mg,mg2,Card.GetLevel,"Greater") local tc=tg:GetFirst() if tc then mg=mg:Filter(Card.IsCanBeRitualMaterial,tc,tc) if mg2 then mg:Merge(mg2) end 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) aux.GCheckAdditional=aux.RitualCheckAdditional(tc,tc:GetLevel(),"Greater") local mat=mg:SelectSubGroup(tp,aux.RitualCheck,false,1,tc:GetLevel(),tp,tc,tc:GetLevel(),"Greater") aux.GCheckAdditional=nil if not mat or mat:GetCount()==0 then return end tc:SetMaterial(mat) local mat2=mat:Filter(Card.IsLocation,nil,LOCATION_GRAVE) mat:Sub(mat2) Duel.ReleaseRitualMaterial(mat) Duel.Remove(mat2,POS_FACEUP,REASON_EFFECT+REASON_MATERIAL+REASON_RITUAL) Duel.BreakEffect() local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_ADD_TYPE) e1:SetValue(TYPE_RITUAL) e1:SetReset(RESET_EVENT+RESETS_STANDARD) tc:RegisterEffect(e1) Duel.SpecialSummon(tc,SUMMON_TYPE_RITUAL,tp,tp,false,true,POS_FACEUP) tc:CompleteProcedure() end end function c249001049.costfilter(c) return c:IsSetCard(0x225) and c:IsAbleToRemoveAsCost() end function c249001049.costfilter2(c,e) return c:IsSetCard(0x225) and not c:IsPublic() end function c249001049.thcost(e,tp,eg,ep,ev,re,r,rp,chk) local c=e:GetHandler() if chk==0 then return (Duel.IsExistingMatchingCard(c249001049.costfilter,tp,LOCATION_GRAVE,0,1,nil) or Duel.IsExistingMatchingCard(c249001049.costfilter2,tp,LOCATION_HAND,0,1,c)) and not c:IsPublic() end local option if Duel.IsExistingMatchingCard(c249001049.costfilter2,tp,LOCATION_HAND,0,1,c) then option=0 end if Duel.IsExistingMatchingCard(c249001049.costfilter,tp,LOCATION_GRAVE,0,1,nil) then option=1 end if Duel.IsExistingMatchingCard(c249001049.costfilter,tp,LOCATION_GRAVE,0,1,nil) and Duel.IsExistingMatchingCard(c249001049.costfilter2,tp,LOCATION_HAND,0,1,c) then option=Duel.SelectOption(tp,526,1102) end if option==0 then g=Duel.SelectMatchingCard(tp,c249001049.costfilter2,tp,LOCATION_HAND,0,1,1,c) 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,c249001049.costfilter,tp,LOCATION_GRAVE,0,1,1,nil) Duel.Remove(g,POS_FACEUP,REASON_COST) end end function c249001049.thfilter(c) return c:IsAttribute(ATTRIBUTE_DARK) and c:IsLevelAbove(5) and c:IsAbleToHand() end function c249001049.thtg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(c249001049.thfilter,tp,LOCATION_DECK,0,1,nil) end Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK) end function c249001049.thop(e,tp,eg,ep,ev,re,r,rp) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND) local g=Duel.SelectMatchingCard(tp,c249001049.thfilter,tp,LOCATION_DECK,0,1,1,nil) local tc=g:GetFirst() if not tc then return end if Duel.SendtoHand(tc,nil,REASON_EFFECT)~=0 and tc:IsLocation(LOCATION_HAND) then Duel.ConfirmCards(1-tp,tc) local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_FIELD) e1:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON) e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET) e1:SetTargetRange(1,0) e1:SetTarget(c249001049.splimit) e1:SetLabel(tc:GetCode()) e1:SetReset(RESET_PHASE+PHASE_END) Duel.RegisterEffect(e1,tp) end end function c249001049.splimit(e,c,sump,sumtype,sumpos,targetp,se) return (not sumtype==SUMMON_TYPE_RITUAL) and c:IsCode(e:GetLabel()) end