--Uru-Chain Fuser function c249001210.initial_effect(c) aux.EnablePendulumAttribute(c,false) --chain material local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(249001210,0)) e1:SetType(EFFECT_TYPE_IGNITION) e1:SetCountLimit(1,249001210) e1:SetRange(LOCATION_MZONE) e1:SetCost(c249001210.cost) e1:SetOperation(c249001210.operation) c:RegisterEffect(e1) --fusion summon local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(249001210,1)) e2:SetCategory(CATEGORY_SPECIAL_SUMMON+CATEGORY_FUSION_SUMMON) e2:SetType(EFFECT_TYPE_IGNITION) e2:SetCountLimit(2) e2:SetRange(LOCATION_MZONE) e2:SetTarget(c249001210.target) e2:SetOperation(c249001210.operation2) c:RegisterEffect(e2) --Activate local e3=Effect.CreateEffect(c) e3:SetDescription(1160) e3:SetType(EFFECT_TYPE_ACTIVATE) e3:SetCode(EVENT_FREE_CHAIN) e3:SetRange(LOCATION_HAND) e3:SetCost(c249001210.reg) c:RegisterEffect(e3) --to hand local e4=Effect.CreateEffect(c) e4:SetDescription(aux.Stringid(3040496,0)) e4:SetCategory(CATEGORY_TOHAND+CATEGORY_SEARCH+CATEGORY_DECKDES) e4:SetType(EFFECT_TYPE_IGNITION) e4:SetRange(LOCATION_PZONE) e4:SetCountLimit(1,249001210) e4:SetCondition(c249001210.thcon) e4:SetTarget(c249001210.thtg) e4:SetOperation(c249001210.thop) c:RegisterEffect(e4) end function c249001210.costfilter(c) return c:IsSetCard(0x232) and c:IsAbleToRemoveAsCost() and c:IsType(TYPE_MONSTER) and (c:IsFaceup() or not c:IsLocation(LOCATION_EXTRA)) end function c249001210.costfilter2(c,e) return c:IsSetCard(0x232) and not c:IsPublic() and c:IsType(TYPE_MONSTER) end function c249001210.cost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return (Duel.IsExistingMatchingCard(c249001210.costfilter,tp,LOCATION_GRAVE+LOCATION_EXTRA,0,1,nil) or Duel.IsExistingMatchingCard(c249001210.costfilter2,tp,LOCATION_HAND,0,1,nil)) end local option if Duel.IsExistingMatchingCard(c249001210.costfilter2,tp,LOCATION_HAND,0,1,nil) then option=0 end if Duel.IsExistingMatchingCard(c249001210.costfilter,tp,LOCATION_GRAVE+LOCATION_EXTRA,0,1,nil) then option=1 end if Duel.IsExistingMatchingCard(c249001210.costfilter,tp,LOCATION_GRAVE+LOCATION_EXTRA,0,1,nil) and Duel.IsExistingMatchingCard(c249001210.costfilter2,tp,LOCATION_HAND,0,1,nil) then option=Duel.SelectOption(tp,526,1102) end if option==0 then g=Duel.SelectMatchingCard(tp,c249001210.costfilter2,tp,LOCATION_HAND,0,1,1,nil) 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,c249001210.costfilter,tp,LOCATION_GRAVE+LOCATION_EXTRA,0,1,1,nil) Duel.Remove(g,POS_FACEUP,REASON_COST) end end function c249001210.operation(e,tp,eg,ep,ev,re,r,rp) local e1=Effect.CreateEffect(e:GetHandler()) e1:SetDescription(aux.Stringid(58199906,0)) e1:SetType(EFFECT_TYPE_FIELD) e1:SetCode(EFFECT_CHAIN_MATERIAL) e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET) e1:SetTargetRange(1,0) e1:SetReset(RESET_PHASE+PHASE_END) e1:SetTarget(c249001210.chain_target) e1:SetOperation(c249001210.chain_operation) e1:SetValue(aux.True) Duel.RegisterEffect(e1,tp) end function c249001210.filter(c,e) return c:IsType(TYPE_MONSTER) and c:IsCanBeFusionMaterial() and c:IsAbleToRemove() and not c:IsImmuneToEffect(e) end function c249001210.chain_target(e,te,tp) return Duel.GetMatchingGroup(c249001210.filter,tp,LOCATION_MZONE+LOCATION_GRAVE+LOCATION_HAND,0,nil,te) end function c249001210.chain_operation(e,te,tp,tc,mat,sumtype) if not sumtype then sumtype=SUMMON_TYPE_FUSION end tc:SetMaterial(mat) Duel.Remove(mat,POS_FACEUP,REASON_EFFECT+REASON_MATERIAL+REASON_FUSION) Duel.BreakEffect() Duel.SpecialSummon(tc,sumtype,tp,tp,false,false,POS_FACEUP) end function c249001210.filter1(c,e) return not c:IsImmuneToEffect(e) end function c249001210.filter2(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 c249001210.target(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then local chkf=tp local mg1=Duel.GetFusionMaterial(tp) local res=Duel.IsExistingMatchingCard(c249001210.filter2,tp,LOCATION_EXTRA,0,1,nil,e,tp,mg1,nil,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(c249001210.filter2,tp,LOCATION_EXTRA,0,1,nil,e,tp,mg2,mf,chkf) end end return res end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_EXTRA) end function c249001210.operation2(e,tp,eg,ep,ev,re,r,rp) local chkf=tp local mg1=Duel.GetFusionMaterial(tp):Filter(c249001210.filter1,nil,e) local sg1=Duel.GetMatchingGroup(c249001210.filter2,tp,LOCATION_EXTRA,0,nil,e,tp,mg1,nil,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(c249001210.filter2,tp,LOCATION_EXTRA,0,nil,e,tp,mg2,mf,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,nil,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,nil,chkf) local fop=ce:GetOperation() fop(ce,e,tp,tc,mat2) end tc:CompleteProcedure() end end function c249001210.reg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return true end e:GetHandler():RegisterFlagEffect(249001210,RESET_PHASE+PHASE_END,EFFECT_FLAG_OATH,1) end function c249001210.thcon(e,tp,eg,ep,ev,re,r,rp) return e:GetHandler():GetFlagEffect(249001210)~=0 end function c249001210.thfilter(c) return c:IsSetCard(0x232) and c:IsAbleToHand() end function c249001210.thtg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsPlayerCanDiscardDeck(tp,3) end end function c249001210.thop(e,tp,eg,ep,ev,re,r,rp) if Duel.IsPlayerCanDiscardDeck(tp,3) then Duel.ConfirmDecktop(tp,3) local g=Duel.GetDecktopGroup(tp,3) if g:GetCount()>0 then Duel.DisableShuffleCheck() if g:IsExists(c249001210.thfilter,1,nil) and Duel.SelectYesNo(tp,aux.Stringid(3040496,1)) then Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND) local sg=g:FilterSelect(tp,c249001210.thfilter,1,1,nil) Duel.SendtoHand(sg,nil,REASON_EFFECT) Duel.ConfirmCards(1-tp,sg) Duel.ShuffleHand(tp) g:Sub(sg) end Duel.SendtoGrave(g,REASON_EFFECT+REASON_REVEAL) end end end