--Crocell, Bestia IV dell'Archivio del Mondo --Scripted by: XGlitchy30 local s,id=GetID() function s.initial_effect(c) --xyz summon aux.AddXyzProcedure(c,aux.FilterBoolFunction(Card.IsSetCard,0x29a),4,2,nil,nil,99) c:EnableReviveLimit() --fusion summon local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(id,0)) e1:SetCategory(CATEGORY_SPECIAL_SUMMON+CATEGORY_FUSION_SUMMON) e1:SetType(EFFECT_TYPE_QUICK_O) e1:SetCode(EVENT_FREE_CHAIN) e1:SetRange(LOCATION_MZONE) e1:SetHintTiming(0,TIMINGS_CHECK_MONSTER+TIMING_MAIN_END) e1:SetCountLimit(1,id) e1:SetCost(aux.DetachSelfCost) e1:SetTarget(s.target) e1:SetOperation(s.activate) c:RegisterEffect(e1) --ss local e3=Effect.CreateEffect(c) e3:Desc(1) e3:SetCategory(CATEGORY_SPECIAL_SUMMON+CATEGORY_TOGRAVE) e3:SetType(EFFECT_TYPE_IGNITION) e3:SetProperty(EFFECT_FLAG_CARD_TARGET) e3:SetRange(LOCATION_GRAVE) e3:SetCountLimit(1,id+100) e3:SetTarget(s.sptg) e3:SetOperation(s.spop) c:RegisterEffect(e3) end function s.filter0(c) return c:IsFusionType(TYPE_MONSTER+TYPE_SPELL) and c:IsCanBeFusionMaterial() and c:IsAbleToGrave() end function s.filter00(c) return c:IsFusionType(TYPE_SPELL) and c:IsCanBeFusionMaterial() and c:IsAbleToGrave() and (c:IsFaceup() or not c:IsLocation(LOCATION_MZONE)) end function s.filter1(c,e) return not c:IsImmuneToEffect(e) end function s.filter2(c,e,tp,m,f,gc,chkf) return c:IsType(TYPE_FUSION) and c:IsSetCard(0x29a) and (not f or f(c)) and c:IsCanBeSpecialSummoned(e,SUMMON_TYPE_FUSION,tp,false,false) and c:CheckFusionMaterial(m,gc,chkf) end function s.target(e,tp,eg,ep,ev,re,r,rp,chk) local c=e:GetHandler() if chk==0 then local chkf=tp local mg1=Duel.GetFusionMaterial(tp) local mg2=Duel.GetMatchingGroup(s.filter0,tp,LOCATION_DECK,0,nil) local mg3=Duel.GetMatchingGroup(s.filter00,tp,LOCATION_HAND+LOCATION_ONFIELD,0,nil) mg1:Merge(mg2) mg1:Merge(mg3) local res=Duel.IsExistingMatchingCard(s.filter2,tp,LOCATION_EXTRA,0,1,nil,e,tp,mg1,nil,c,chkf) if not res then local ce=Duel.GetChainMaterial(tp) if ce~=nil then local fgroup=ce:GetTarget() local mg2=fgroup(ce,e,tp) local mf=ce:GetValue() res=Duel.IsExistingMatchingCard(s.filter2,tp,LOCATION_EXTRA,0,1,nil,e,tp,mg2,mf,c,chkf) end end return res end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_EXTRA) end function s.activate(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() local chkf=tp if not c:IsRelateToEffect(e) or c:IsImmuneToEffect(e) then return end local mg1=Duel.GetFusionMaterial(tp):Filter(s.filter1,nil,e) local mg2=Duel.GetMatchingGroup(s.filter0,tp,LOCATION_DECK,0,nil):Filter(s.filter1,nil,e) local mg3=Duel.GetMatchingGroup(s.filter00,tp,LOCATION_HAND+LOCATION_ONFIELD,0,nil):Filter(s.filter1,nil,e) mg1:Merge(mg2) mg1:Merge(mg3) local sg1=Duel.GetMatchingGroup(s.filter2,tp,LOCATION_EXTRA,0,nil,e,tp,mg1,nil,c,chkf) local mg2=nil local sg2=nil local ce=Duel.GetChainMaterial(tp) if ce~=nil then local fgroup=ce:GetTarget() mg2=fgroup(ce,e,tp) local mf=ce:GetValue() sg2=Duel.GetMatchingGroup(s.filter2,tp,LOCATION_EXTRA,0,nil,e,tp,mg2,mf,c,chkf) end if sg1:GetCount()>0 or (sg2~=nil and sg2:GetCount()>0) then local sg=sg1:Clone() if sg2 then sg:Merge(sg2) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local tg=sg:Select(tp,1,1,nil) local tc=tg:GetFirst() if sg1:IsContains(tc) and (sg2==nil or not sg2:IsContains(tc) or not Duel.SelectYesNo(tp,ce:GetDescription())) then local mat1=Duel.SelectFusionMaterial(tp,tc,mg1,c,chkf) tc:SetMaterial(mat1) Duel.SendtoGrave(mat1,REASON_EFFECT+REASON_MATERIAL+REASON_FUSION) Duel.BreakEffect() Duel.SpecialSummon(tc,SUMMON_TYPE_FUSION,tp,tp,false,false,POS_FACEUP) else local mat2=Duel.SelectFusionMaterial(tp,tc,mg2,c,chkf) local fop=ce:GetOperation() fop(ce,e,tp,tc,mat2) end tc:CompleteProcedure() end end function s.tgfilter(c) return c:IsFaceup() and c:IsSetCard(0x29a) end function s.xyzf(c,e) return c:IsSetCard(0x29a) and c:IsType(TYPE_SPELL) and c:IsCanOverlay() and (not e or not c:IsImmuneToEffect(e)) end function s.sptg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsBanished() and chkc:IsControler(tp) and s.tgfilter(chkc) end if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and e:GetHandler():IsCanBeSpecialSummoned(e,0,tp,false,false) and Duel.IsExistingTarget(s.tgfilter,tp,LOCATION_REMOVED,0,2,nil) and Duel.IsExists(false,s.xyzf,tp,LOCATION_DECK,0,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOGRAVE) local g=Duel.SelectTarget(tp,s.tgfilter,tp,LOCATION_REMOVED,0,2,2,nil) Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,e:GetHandler(),1,0,0) Duel.SetOperationInfo(0,CATEGORY_TOGRAVE,g,1,0,0) end function s.spop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if c and c:IsRelateToEffect(e) and Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and Duel.SpecialSummon(c,0,tp,tp,false,false,POS_FACEUP)>0 then local tg=Duel.GetTargetCards(e) if #tg>0 then Duel.SendtoGrave(tg,REASON_EFFECT+REASON_RETURN) end if not c:IsLocation(LOCATION_MZONE) or not c:IsType(TYPE_XYZ) then return end local g=Duel.Select(HINTMSG_OPERATECARD,false,tp,s.xyzf,tp,LOCATION_DECK,0,1,1,nil,e) if #g>0 then Duel.Attach(g,c) end end end