--Sacrifice Weaver local ref,id=GetID() function ref.initial_effect(c) local magick=Effect.CreateEffect(c) magick:SetDescription(aux.Stringid(id,0)) magick:SetCategory(CATEGORY_POSITION) magick:SetType(EFFECT_TYPE_TRIGGER_O) magick:SetProperty(EFFECT_FLAG_DELAY) magick:SetCondition(ref.poscon) magick:SetTarget(ref.postg) magick:SetOperation(ref.posop) aux.AddMagickProcChain(c,2,aux.MagickMatCost,magick,aux.TRUE,1) --Fusion local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(id,1)) e1:SetCategory(CATEGORY_SPECIAL_SUMMON) e1:SetType(EFFECT_TYPE_TRIGGER_O+EFFECT_TYPE_FLIP+EFFECT_TYPE_SINGLE) e1:SetCode(EVENT_FLIP) e1:SetProperty(EFFECT_FLAG_DELAY) e1:SetTarget(ref.fustg) e1:SetOperation(ref.fusop) c:RegisterEffect(e1) --To Hand local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(id,2)) e2:SetCategory(CATEGORY_TOHAND) e2:SetType(EFFECT_TYPE_TRIGGER_O+EFFECT_TYPE_SINGLE) e2:SetCode(EVENT_TO_GRAVE) e2:SetProperty(EFFECT_FLAG_DELAY+EFFECT_FLAG_DAMAGE_STEP) e2:SetCountLimit(1,id) e2:SetTarget(ref.thtg) e2:SetOperation(ref.thop) c:RegisterEffect(e2) end function ref.poscon(e,tp,eg,ep,ev,re,r,rp) return e:GetHandler():GetMaterial():IsExists(Card.IsType,1,nil,TYPE_MONSTER) end function ref.postg(e,tp,eg,ep,ev,re,r,rp,chk) local g=Duel.GetMatchingGroup(Card.IsFacedown,tp,LOCATION_MZONE,0,nil) if chk==0 then return #g>0 end Duel.SetOperationInfo(0,CATEGORY_POSITION,g,1,0,0) end function ref.posop(e,tp,eg,ep,ev,re,r,rp) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_POSCHANGE) local g=Duel.SelectMatchingCard(tp,Card.IsFacedown,tp,LOCATION_MZONE,0,1,1,nil) if #g>0 then Duel.ChangePosition(g,POS_FACEUP_DEFENSE) end end --Fusion function ref.filter1(c) return c:IsCanBeFusionMaterial() end function ref.filter2(c,e) return c:IsOnField() and not c:IsImmuneToEffect(e) end function ref.filter3(c,e) return ref.filter1(c) and not c:IsImmuneToEffect(e) end function ref.spfilter(c,e,tp,m,f,chkf) return c:IsType(TYPE_FUSION) and (not f or f(c)) and c:IsCanBeSpecialSummoned(e,SUMMON_TYPE_FUSION,tp,false,false) and c:CheckFusionMaterial(m,nil,chkf) end function ref.chkfilter(c,tp) return true end function ref.fcheck(tp,sg,fc) if sg:IsExists(ref.chkfilter,1,nil,tp) then return sg:FilterCount(Card.IsControler,nil,1-tp)<=1 else return sg:FilterCount(Card.IsControler,nil,1-tp)<=0 end end function ref.gcheck(tp) return function(sg) return sg:FilterCount(Card.IsControler,nil,1-tp)<=1 end end function ref.fustg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then local chkf=tp local mg1=Duel.GetFusionMaterial(tp):Filter(Card.IsOnField,nil) local mg2=Duel.GetMatchingGroup(ref.filter1,tp,0,LOCATION_MZONE,nil) if mg1:IsExists(ref.chkfilter,1,nil,tp) and mg2:GetCount()>0 then mg1:Merge(mg2) aux.FCheckAdditional=ref.fcheck aux.GCheckAdditional=ref.gcheck(tp) end local res=Duel.IsExistingMatchingCard(ref.spfilter,tp,LOCATION_EXTRA,0,1,nil,e,tp,mg1,nil,chkf) aux.FCheckAdditional=nil aux.GCheckAdditional=nil if not res then local ce=Duel.GetChainMaterial(tp) if ce~=nil then local fgroup=ce:GetTarget() local mg3=fgroup(ce,e,tp) local mf=ce:GetValue() res=Duel.IsExistingMatchingCard(ref.spfilter,tp,LOCATION_EXTRA,0,1,nil,e,tp,mg3,mf,chkf) end end return res end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_EXTRA) end function ref.fusop(e,tp,eg,ep,ev,re,r,rp) local chkf=tp local mg1=Duel.GetFusionMaterial(tp):Filter(ref.filter2,nil,e) local mg2=Duel.GetMatchingGroup(ref.filter3,tp,0,LOCATION_MZONE,nil,e) if mg1:IsExists(ref.chkfilter,1,nil,tp) and mg2:GetCount()>0 then mg1:Merge(mg2) exmat=true end if exmat then aux.FCheckAdditional=ref.fcheck aux.GCheckAdditional=ref.gcheck(tp) end local sg1=Duel.GetMatchingGroup(ref.spfilter,tp,LOCATION_EXTRA,0,nil,e,tp,mg1,nil,chkf) aux.FCheckAdditional=nil aux.GCheckAdditional=nil local mg3=nil local sg2=nil local ce=Duel.GetChainMaterial(tp) if ce~=nil then local fgroup=ce:GetTarget() mg3=fgroup(ce,e,tp) local mf=ce:GetValue() sg2=Duel.GetMatchingGroup(ref.spfilter,tp,LOCATION_EXTRA,0,nil,e,tp,mg3,mf,chkf) end 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 not tc then return end if sg1:IsContains(tc) and (sg2==nil or not sg2:IsContains(tc) or not Duel.SelectYesNo(tp,ce:GetDescription())) then if exmat then aux.FCheckAdditional=ref.fcheck aux.GCheckAdditional=ref.gcheck(tp) end local mat1=Duel.SelectFusionMaterial(tp,tc,mg1,nil,chkf) aux.FCheckAdditional=nil aux.GCheckAdditional=nil 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,mg3,nil,chkf) local fop=ce:GetOperation() fop(ce,e,tp,tc,mat2) end tc:CompleteProcedure() end --Recover function ref.thfilter(c) return c:IsType(TYPE_MONSTER) and c:IsAbleToHand() and HighTyper.IsUnique(c,tp) end function ref.thtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and ref.thfilter(chkc) end if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and Duel.IsExistingTarget(ref.thfilter,tp,LOCATION_GRAVE,0,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_RTOHAND) local g=Duel.SelectTarget(tp,ref.thfilter,tp,LOCATION_GRAVE,0,1,1,nil) Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,g,1,0,0) end function ref.thop(e,tp,eg,ep,ev,re,r,rp) local tc=Duel.GetFirstTarget() if tc and tc:IsRelateToEffect(e) then Duel.SendtoHand(tc,nil,REASON_EFFECT) end end