--Skyburner Flying Fortress --Commissioned by: Leon Duvall --Scripted by: Remnance --Bugfixing by: XGlitchy30 local cid,id=GetID() function cid.initial_effect(c) c:SetSPSummonOnce(id) --fusion material c:EnableReviveLimit() aux.AddFusionProcFun2(c,aux.FilterBoolFunction(Card.IsFusionSetCard,0xf41),cid.ffilter2,true) --spsummon condition local e1=Effect.CreateEffect(c) e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_SPSUMMON_CONDITION) e1:SetValue(cid.splimit) c:RegisterEffect(e1) --fusion summon itself local e2=Effect.CreateEffect(c) e2:SetCategory(CATEGORY_SPECIAL_SUMMON+CATEGORY_FUSION_SUMMON) e2:SetType(EFFECT_TYPE_QUICK_O) e2:SetProperty(EFFECT_FLAG_SET_AVAILABLE) e2:SetCode(EVENT_FREE_CHAIN) e2:SetRange(LOCATION_EXTRA) e2:SetCondition(cid.spcon) e2:SetTarget(cid.sptg) e2:SetOperation(cid.spop) c:RegisterEffect(e2) --shuffle and draw local e3=Effect.CreateEffect(c) e3:SetCategory(CATEGORY_TODECK+CATEGORY_DRAW) e3:SetType(EFFECT_TYPE_IGNITION) e3:SetRange(LOCATION_MZONE) e3:SetCost(cid.spcost) e3:SetTarget(cid.sptg1) e3:SetOperation(cid.spop1) c:RegisterEffect(e3) --destroy local e4=Effect.CreateEffect(c) e4:SetDescription(aux.Stringid(id,1)) e4:SetCategory(CATEGORY_DESTROY) e4:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e4:SetCode(EVENT_SPSUMMON_SUCCESS) e4:SetProperty(EFFECT_FLAG_CARD_TARGET+EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DELAY) e4:SetCondition(cid.descon) e4:SetTarget(cid.destg) e4:SetOperation(cid.desop) c:RegisterEffect(e4) local e5=e4:Clone() e5:SetCode(EVENT_FLIP_SUMMON_SUCCESS) c:RegisterEffect(e5) local e6=e4:Clone() e6:SetCode(EVENT_SUMMON_SUCCESS) c:RegisterEffect(e6) end --filters function cid.filter2(c,e,tp,m,f,chkf) return c==e:GetHandler() and (not f or f(c)) and c:IsCanBeSpecialSummoned(e,SUMMON_TYPE_FUSION,tp,false,false) and c:CheckFusionMaterial(m,nil,chkf) end function cid.filter1(c,e) return c:IsOnField() and not c:IsImmuneToEffect(e) end function cid.ffilter2(c) return (c:IsLevel(3) or c:IsLevel(6)) and c:IsFusionSetCard(0xf41) end function cid.cfilter(c) return c:IsFaceup() and c:IsType(TYPE_MONSTER) and c:IsSetCard(0xf41) end function cid.filter(c,e,tp) return c:IsSetCard(0xf41) and c:IsType(TYPE_MONSTER) and c:IsCanBeSpecialSummoned(e,0,tp,false,false) end function cid.costfilter(c,tp) return c:IsFaceup() and c:IsSetCard(0xf41) and c:IsType(TYPE_MONSTER) and Duel.IsExistingMatchingCard(cid.clfilter,tp,0,LOCATION_ONFIELD,1,nil,c,tp) end function cid.clfilter(c,tg,tp) local g=tg:GetColumnGroup() return g:IsContains(c) and c:GetControler()~=tp end function cid.tdfilter(c) return c:IsSetCard(0xf41) and c:IsAbleToDeck() end --spsummon condition function cid.splimit(e,se,sp,st) return se:IsActiveType(TYPE_MONSTER) and se:GetHandler()==e:GetHandler() end --fusion summon itself function cid.spcon(e,tp,eg,ep,ev,re,r,rp) if Duel.GetCurrentChain()>0 then return false end return Duel.IsExistingMatchingCard(cid.cfilter,tp,LOCATION_MZONE,0,2,nil) end function cid.sptg(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 res=Duel.IsExistingMatchingCard(cid.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(cid.filter2,tp,LOCATION_EXTRA,0,1,nil,e,tp,mg2,mf,chkf) end end return res end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,e:GetHandler(),1,0,0) end function cid.spop(e,tp,eg,ep,ev,re,r,rp) local chkf=tp local mg1=Duel.GetFusionMaterial(tp):Filter(cid.filter1,nil,e) local sg1=Duel.GetMatchingGroup(cid.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(cid.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 --SHUFFLE AND DRAW function cid.checkloc(c,p) return c:IsLocation(LOCATION_DECK) and c:IsControler(p) end function cid.spcost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return e:GetHandler():IsAbleToExtraAsCost() end Duel.SendtoDeck(e:GetHandler(),nil,0,REASON_COST) end function cid.sptg1(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsPlayerCanDraw(tp,1) and Duel.IsExistingMatchingCard(cid.tdfilter,tp,LOCATION_GRAVE,0,5,nil) end Duel.SetOperationInfo(0,CATEGORY_TODECK,nil,5,tp,LOCATION_GRAVE) Duel.SetOperationInfo(0,CATEGORY_DRAW,nil,0,tp,1) end function cid.spop1(e,tp,eg,ep,ev,re,r,rp) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TODECK) local tg=Duel.SelectMatchingCard(tp,aux.NecroValleyFilter(cid.tdfilter),tp,LOCATION_GRAVE,0,5,5,nil) if tg:GetCount()<=0 then return end Duel.SendtoDeck(tg,nil,0,REASON_EFFECT) local g=Duel.GetOperatedGroup() for p=0,1 do if g:IsExists(cid.checkloc,1,nil,p) then Duel.ShuffleDeck(p) end end local ct=g:FilterCount(Card.IsLocation,nil,LOCATION_DECK+LOCATION_EXTRA) if ct>0 then Duel.Draw(tp,1,REASON_EFFECT) end end --destroy function cid.descon(e,tp,eg,ep,ev,re,r,rp) local lg1=Duel.GetLinkedGroup(tp,1,1) local lg2=Duel.GetLinkedGroup(1-tp,1,1) lg1:Merge(lg2) return Duel.GetTurnPlayer()~=tp and (e:GetHandler():GetSequence()>4 or lg1 and lg1:IsContains(e:GetHandler())) end function cid.destg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsControler(tp) and chkc:IsLocation(LOCATION_MZONE) and cid.costfilter(chkc,tp) end if chk==0 then return Duel.IsExistingTarget(cid.costfilter,tp,LOCATION_MZONE,0,1,nil,tp) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_FACEUP) local g=Duel.SelectTarget(tp,cid.costfilter,tp,LOCATION_MZONE,0,1,1,nil,tp) local cl=g:GetFirst():GetColumnGroup():Filter(Card.IsControler,nil,1-tp) Duel.SetOperationInfo(0,CATEGORY_DESTROY,cl,#cl,0,0) end function cid.desop(e,tp,eg,ep,ev,re,r,rp) local tc=Duel.GetFirstTarget() if tc and tc:IsRelateToEffect(e) then local cl=tc:GetColumnGroup():Filter(Card.IsControler,nil,1-tp) if #cl>0 then Duel.Destroy(cl,REASON_EFFECT) end end end