--Sayuri·Bad Apple II Duel.LoadScript("c37564765.lua") local m,cm=Senya.SayuriRitualPreload(37564916) function cm.initial_effect(c) c:EnableReviveLimit() local e0=Effect.CreateEffect(c) e0:SetType(EFFECT_TYPE_SINGLE) e0:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE) e0:SetCode(EFFECT_SPSUMMON_CONDITION) e0:SetValue(function(e,se,sp,st) local sc=se:GetHandler() return aux.ritlimit(e,se,sp,st) and Senya.check_set_sayuri(sc) end) c:RegisterEffect(e0) Senya.AddSummonMusic(c,m*16,SUMMON_TYPE_RITUAL) local e4=Effect.CreateEffect(c) e4:SetCategory(CATEGORY_SPECIAL_SUMMON) e4:SetDescription(aux.Stringid(37564765,0)) e4:SetCountLimit(1,m) e4:SetType(EFFECT_TYPE_IGNITION) e4:SetRange(LOCATION_HAND) e4:SetTarget(cm.sptg2) e4:SetOperation(cm.spop2) c:RegisterEffect(e4) local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(37564765,0)) e1:SetCategory(CATEGORY_SPECIAL_SUMMON) e1:SetCustomCategory(CATEGORY_SPSUMMON_RITUAL_MONSTER) e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e1:SetCode(EVENT_SPSUMMON_SUCCESS) e1:SetProperty(EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DELAY) e1:SetCountLimit(1,m-1000) e1:SetCondition(function(e,tp,eg,ep,ev,re,r,rp) return e:GetHandler():IsSummonType(SUMMON_TYPE_RITUAL) end) e1:SetTarget(cm.sptg) e1:SetOperation(cm.spop) c:RegisterEffect(e1) local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(37564765,0)) e1:SetCategory(CATEGORY_SPECIAL_SUMMON+CATEGORY_TODECK) e1:SetCustomCategory(CATEGORY_SPSUMMON_RITUAL_MONSTER) e1:SetType(EFFECT_TYPE_IGNITION) e1:SetRange(LOCATION_GRAVE) e1:SetProperty(EFFECT_FLAG_CARD_TARGET) e1:SetCountLimit(1,m-2000) e1:SetTarget(cm.target) e1:SetOperation(cm.activate) c:RegisterEffect(e1) end function cm.matfilter(c,rc) return c:IsCanBeRitualMaterial(rc) and Senya.check_set_sayuri(c) and c:IsType(TYPE_MONSTER) end function cm.sptg2(e,tp,eg,ep,ev,re,r,rp,chk) local c=e:GetHandler() if chk==0 then local mg=Duel.GetRitualMaterial(tp):Filter(cm.matfilter,c,c) if c.mat_filter then mg=mg:Filter(c.mat_filter,nil) end if not c:IsCanBeSpecialSummoned(e,SUMMON_TYPE_RITUAL,tp,true,true) then return end return Senya.CheckRitualMaterial(c,mg,tp,c:GetLevel(),nil,true) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_HAND) end function cm.spop2(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if not c:IsRelateToEffect(e) or not c:IsCanBeSpecialSummoned(e,SUMMON_TYPE_RITUAL,tp,true,true) then return end local mg=Duel.GetRitualMaterial(tp):Filter(cm.matfilter,c,c) if c.mat_filter then mg=mg:Filter(c.mat_filter,nil) end local mat=Senya.SelectRitualMaterial(c,mg,tp,c:GetLevel(),nil,true) c:SetMaterial(mat) Duel.ReleaseRitualMaterial(mat) Duel.BreakEffect() Duel.SpecialSummon(c,SUMMON_TYPE_RITUAL,tp,tp,true,true,POS_FACEUP) c:CompleteProcedure() end function cm.sfilter(c,e,tp) return c:IsCode(m) and c:IsCanBeSpecialSummoned(e,0,tp,true,true) and c:IsType(TYPE_MONSTER) end function cm.sfilter1(c,e,tp) return c:IsLevelBelow(8) and Senya.check_set_sayuri(c) and c:IsCanBeSpecialSummoned(e,0,tp,true,true) and (c:GetType() & 0x81)==0x81 end function cm.sptg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetMZoneCount(tp)>0 and Duel.IsExistingMatchingCard(cm.sfilter,tp,LOCATION_DECK,0,1,nil,e,tp) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_DECK) Duel.SetCustomOperationInfo(0,CATEGORY_SPSUMMON_RITUAL_MONSTER,nil,1,tp,LOCATION_DECK) end function cm.spop(e,tp,eg,ep,ev,re,r,rp) if Duel.GetMZoneCount(tp)<=0 then return end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local g=Duel.SelectMatchingCard(tp,cm.sfilter,tp,LOCATION_DECK,0,1,1,nil,e,tp) local tc=g:GetFirst() if tc then Duel.SpecialSummon(tc,0,tp,tp,true,true,POS_FACEUP) tc:CompleteProcedure() end end function cm.filter(c) return c:IsCode(m) and c:IsAbleToDeck() end function cm.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and cm.filter(chkc) end if chk==0 then return Duel.GetMZoneCount(tp)>0 and Duel.IsExistingMatchingCard(cm.sfilter1,tp,LOCATION_DECK,0,1,nil,e,tp) and Duel.IsExistingTarget(cm.filter,tp,LOCATION_GRAVE,0,2,e:GetHandler()) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TODECK) local g=Duel.SelectTarget(tp,cm.filter,tp,LOCATION_GRAVE,0,2,2,e:GetHandler()) Duel.SetOperationInfo(0,CATEGORY_TODECK,g,3,0,0) Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_DECK) Duel.SetCustomOperationInfo(0,CATEGORY_SPSUMMON_RITUAL_MONSTER,nil,1,tp,LOCATION_DECK) end function cm.activate(e,tp,eg,ep,ev,re,r,rp) local tg=Duel.GetChainInfo(0,CHAININFO_TARGET_CARDS):Clone() tg:AddCard(e:GetHandler()) if tg:FilterCount(Card.IsRelateToEffect,nil,e)~=3 then return end Duel.SendtoDeck(tg,nil,0,REASON_EFFECT) local g=Duel.GetOperatedGroup() if g:IsExists(Card.IsLocation,1,nil,LOCATION_DECK) then Duel.ShuffleDeck(tp) end local ct=g:FilterCount(Card.IsLocation,nil,LOCATION_DECK+LOCATION_EXTRA) if ct==3 and Duel.GetMZoneCount(tp)>0 then Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local g=Duel.SelectMatchingCard(tp,cm.sfilter1,tp,LOCATION_DECK,0,1,1,nil,e,tp) local tc=g:GetFirst() if tc then Duel.BreakEffect() Duel.SpecialSummon(tc,SUMMON_TYPE_RITUAL,tp,tp,true,true,POS_FACEUP) tc:CompleteProcedure() end end end